index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = Object.setPrototypeOf ||
  3. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5. return function (d, b) {
  6. extendStatics(d, b);
  7. function __() { this.constructor = d; }
  8. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9. };
  10. })();
  11. var __assign = (this && this.__assign) || Object.assign || function(t) {
  12. for (var s, i = 1, n = arguments.length; i < n; i++) {
  13. s = arguments[i];
  14. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  15. t[p] = s[p];
  16. }
  17. return t;
  18. };
  19. import * as React from 'react';
  20. import { HistoryDragact } from './HistoryLayout';
  21. import { Words } from './largedata';
  22. import './index.css';
  23. var fakeData = function () {
  24. var Y = 0;
  25. return Words.map(function (item, index) {
  26. if (index % 4 === 0)
  27. Y++;
  28. return __assign({}, item, { GridX: index % 4 * 4, GridY: Y * 4, w: 4, h: 3, key: index + '' });
  29. });
  30. };
  31. export var Card = function (_a) {
  32. var item = _a.item, provided = _a.provided;
  33. return (React.createElement("div", __assign({ className: 'layout-Item' }, provided.props, provided.dragHandle, { style: __assign({}, provided.props.style, { background: "" + (provided.isDragging ? '#eaff8f' : 'white') }) }),
  34. React.createElement("div", { style: { padding: 5, textAlign: 'center', color: '#595959' } },
  35. React.createElement("span", null, "title"),
  36. React.createElement("div", { style: { borderBottom: '1px solid rgba(120,120,120,0.1)' } }),
  37. item.content),
  38. React.createElement("span", __assign({}, provided.resizeHandle, { style: {
  39. position: 'absolute',
  40. width: 10, height: 10, right: 2, bottom: 2, cursor: 'se-resize',
  41. borderRight: '2px solid rgba(15,15,15,0.2)',
  42. borderBottom: '2px solid rgba(15,15,15,0.2)'
  43. } }))));
  44. };
  45. var HistoryDemo = /** @class */ (function (_super) {
  46. __extends(HistoryDemo, _super);
  47. function HistoryDemo() {
  48. return _super !== null && _super.apply(this, arguments) || this;
  49. }
  50. HistoryDemo.prototype.render = function () {
  51. var _this = this;
  52. var margin = [5, 5];
  53. var dragactInit = {
  54. width: 600,
  55. col: 16,
  56. rowHeight: 40,
  57. margin: margin,
  58. className: 'normal-layout',
  59. layout: fakeData()
  60. };
  61. return (React.createElement("div", { style: {
  62. display: 'flex',
  63. justifyContent: 'center'
  64. } },
  65. React.createElement("div", null,
  66. React.createElement("h1", { style: { textAlign: 'center' } }, "\u590D\u539F\u64CD\u4F5Cdemo"),
  67. React.createElement("button", { onClick: function () {
  68. if (_this.drag) {
  69. _this.drag.goBack();
  70. }
  71. } }, "back"),
  72. React.createElement("button", { onClick: function () {
  73. if (_this.drag) {
  74. _this.drag.reset();
  75. }
  76. } }, "reset"),
  77. React.createElement("button", { onClick: function () {
  78. if (_this.drag) {
  79. _this.drag.clear();
  80. }
  81. } }, "clear"),
  82. React.createElement(HistoryDragact, __assign({}, dragactInit, { placeholder: true, ref: function (n) { return _this.drag = n; }, style: {
  83. background: '#003A8C'
  84. } }), function (item, provided) {
  85. return React.createElement(Card, { item: item, provided: provided });
  86. }))));
  87. };
  88. return HistoryDemo;
  89. }(React.Component));
  90. export { HistoryDemo };