index.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6. return function (d, b) {
  7. extendStatics(d, b);
  8. function __() { this.constructor = d; }
  9. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10. };
  11. })();
  12. var __assign = (this && this.__assign) || Object.assign || function(t) {
  13. for (var s, i = 1, n = arguments.length; i < n; i++) {
  14. s = arguments[i];
  15. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  16. t[p] = s[p];
  17. }
  18. return t;
  19. };
  20. Object.defineProperty(exports, "__esModule", { value: true });
  21. var React = require("react");
  22. var dragact_1 = require("../../src/lib/dragact");
  23. require("./index.css");
  24. var Words = [
  25. { content: 'You can do anything, but not everything.' },
  26. { content: 'Those who dare to fail miserably can achieve greatly.' },
  27. { content: 'You miss 100 percent of the shots you never take.' },
  28. { content: 'Those who believe in telekinetics, raise my hand.' },
  29. { content: 'I’d rather live with a good question than a bad answer.' }
  30. ];
  31. var fakeData = function () {
  32. var Y = 0;
  33. return Words.map(function (item, index) {
  34. if (index % 4 === 0)
  35. Y++;
  36. return __assign({}, item, { GridX: (index % 4) * 4, GridY: Y * 4, w: 4, h: 2, key: index + '' });
  37. });
  38. };
  39. var Card = function (_a) {
  40. var item = _a.item, provided = _a.provided;
  41. if (item.key !== '3') {
  42. return (React.createElement("div", __assign({ className: "layout-Item" }, provided.props, provided.dragHandle),
  43. React.createElement("div", { style: {
  44. padding: 5,
  45. textAlign: 'center',
  46. color: '#595959'
  47. } }, item.content)));
  48. }
  49. return (React.createElement("div", __assign({ className: "layout-Item" }, provided.props),
  50. React.createElement("div", { style: { padding: 5, textAlign: 'center', color: '#595959' } },
  51. item.content,
  52. React.createElement("div", __assign({ className: "card-handle" }, provided.dragHandle), "\u70B9\u6211\u62D6\u52A8"))));
  53. };
  54. var HandleLayout = /** @class */ (function (_super) {
  55. __extends(HandleLayout, _super);
  56. function HandleLayout() {
  57. return _super !== null && _super.apply(this, arguments) || this;
  58. }
  59. HandleLayout.prototype.render = function () {
  60. var margin = [5, 5];
  61. var dragactInit = {
  62. width: 600,
  63. col: 12,
  64. rowHeight: 800 / 12,
  65. margin: margin,
  66. className: 'normal-layout',
  67. layout: fakeData(),
  68. placeholder: true
  69. };
  70. return (React.createElement("div", null,
  71. React.createElement("div", { style: { display: 'flex', justifyContent: 'center' } },
  72. React.createElement("div", null,
  73. React.createElement("h1", { style: { textAlign: 'center' } }, "\u62D6\u62FD\u628A\u624B Demo"),
  74. React.createElement(dragact_1.Dragact, __assign({}, dragactInit), function (item, provided) {
  75. return React.createElement(Card, { item: item, provided: provided });
  76. })))));
  77. };
  78. return HandleLayout;
  79. }(React.Component));
  80. exports.HandleLayout = HandleLayout;