index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. var __assign = (this && this.__assign) || Object.assign || function(t) {
  2. for (var s, i = 1, n = arguments.length; i < n; i++) {
  3. s = arguments[i];
  4. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  5. t[p] = s[p];
  6. }
  7. return t;
  8. };
  9. import * as React from 'react';
  10. import { Dragact } from '../../src/lib/dragact';
  11. import './index.css';
  12. var Words = [
  13. { content: 'Sorry I just can not move in any circumstances', static: true },
  14. { content: 'Those who dare to fail miserably can achieve greatly.' },
  15. { content: 'You miss 100 percent of the shots you never take.' },
  16. { content: 'Sorry I just can not move in any circumstances,too' },
  17. { content: 'I’d rather live with a good question than a bad answer.' }
  18. ];
  19. var fakeData = function () {
  20. var Y = 0;
  21. return Words.map(function (item, index) {
  22. if (index % 4 === 0)
  23. Y++;
  24. return __assign({}, item, { GridX: index % 4 * 4, GridY: Y * 4, w: 4, h: 4, key: index + '', canResize: false });
  25. });
  26. };
  27. var Cell = function (_a) {
  28. var item = _a.item, provided = _a.provided;
  29. return (React.createElement("div", __assign({}, provided.props, provided.dragHandle, { className: "layout-Cell " + (item.static ? "static" : ""), style: __assign({}, provided.props.style, { background: item.static ? "#e8e8e8" : "" }) }),
  30. React.createElement("div", { style: { padding: 10, color: '#595959' } }, item.content)));
  31. };
  32. export var SortedTableWithStatic = function () {
  33. return (React.createElement("div", { style: { display: 'flex', justifyContent: 'center' } },
  34. React.createElement("div", null,
  35. React.createElement("h1", { style: { textAlign: 'center' } }, "\u9759\u6001\u7EC4\u4EF6 Demo"),
  36. React.createElement(Dragact, { width: 600, col: 16, rowHeight: 30, margin: [2, 2], className: 'normal-layout', layout: fakeData(), placeholder: true }, function (item, provided) {
  37. return React.createElement(Cell, { item: item, provided: provided });
  38. }))));
  39. };