index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 { Dragact } from '../../src/lib/dragact';
  21. import './index.css';
  22. var Words = [
  23. { content: 'You can do anything, but not everything.' },
  24. { content: 'Those who dare to fail miserably can achieve greatly.' },
  25. { content: 'You miss 100 percent of the shots you never take.' },
  26. { content: 'Those who believe in telekinetics, raise my hand.' },
  27. { content: 'I’d rather live with a good question than a bad answer.' }
  28. ];
  29. var fakeData = function () {
  30. var Y = 0;
  31. return Words.map(function (item, index) {
  32. if (index % 4 === 0)
  33. Y++;
  34. return __assign({}, item, { GridX: index % 4 * 4, GridY: Y * 4, w: 4, h: 2, key: index + '' });
  35. });
  36. };
  37. var Card = function (_a) {
  38. var item = _a.item, provided = _a.provided;
  39. var style = { padding: 5, textAlign: 'center', color: '#595959' };
  40. if (item.key !== '3') {
  41. return (React.createElement("div", __assign({ className: 'layout-Item' }, provided.props, provided.dragHandle),
  42. React.createElement("div", { style: style }, item.content)));
  43. }
  44. return (React.createElement("div", __assign({ className: 'layout-Item' }, provided.props),
  45. React.createElement("div", { style: style },
  46. item.content,
  47. React.createElement("div", __assign({ className: 'card-handle' }, provided.dragHandle), "\u70B9\u6211\u62D6\u52A8"))));
  48. };
  49. var HandleLayout = /** @class */ (function (_super) {
  50. __extends(HandleLayout, _super);
  51. function HandleLayout() {
  52. return _super !== null && _super.apply(this, arguments) || this;
  53. }
  54. HandleLayout.prototype.render = function () {
  55. var margin = [5, 5];
  56. var dragactInit = {
  57. width: 600,
  58. col: 12,
  59. rowHeight: 800 / 12,
  60. margin: margin,
  61. className: 'normal-layout',
  62. layout: fakeData(),
  63. placeholder: true
  64. };
  65. return (React.createElement("div", null,
  66. React.createElement("div", { style: { display: 'flex', justifyContent: 'center' } },
  67. React.createElement("div", null,
  68. React.createElement("h1", { style: { textAlign: 'center' } }, "\u62D6\u62FD\u628A\u624B Demo"),
  69. React.createElement(Dragact, __assign({}, dragactInit), function (item, provided) {
  70. return React.createElement(Card, { item: item, provided: provided });
  71. })))));
  72. };
  73. return HandleLayout;
  74. }(React.Component));
  75. export { HandleLayout };