index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 '../lib/dragact';
  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 + '', canResize: false });
  29. });
  30. };
  31. var Card = function (props) {
  32. var item = props.item;
  33. var isDragging = props.isDragging;
  34. return (React.createElement("div", { className: 'layout-Item', style: { background: "" + (isDragging ? '#eaff8f' : 'white') } },
  35. React.createElement("div", { style: { padding: 5, textAlign: 'center', color: '#595959' } },
  36. React.createElement("span", null, "title"),
  37. React.createElement("div", { style: { borderBottom: '1px solid rgba(120,120,120,0.1)' } }),
  38. item.content)));
  39. };
  40. var Mobile = /** @class */ (function (_super) {
  41. __extends(Mobile, _super);
  42. function Mobile() {
  43. return _super !== null && _super.apply(this, arguments) || this;
  44. }
  45. Mobile.prototype.render = function () {
  46. var margin = [5, 5];
  47. var dragactInit = {
  48. width: 500,
  49. col: 16,
  50. rowHeight: 45,
  51. margin: margin,
  52. className: 'normal-layout',
  53. layout: fakeData()
  54. };
  55. return (React.createElement("div", { style: {
  56. display: 'flex',
  57. justifyContent: 'center'
  58. } },
  59. React.createElement("div", null,
  60. React.createElement("h1", { style: { textAlign: 'center' } }, "\u624B\u673A\u666E\u901A\u5E03\u5C40demo"),
  61. React.createElement(Dragact, __assign({}, dragactInit, { placeholder: true, style: {
  62. background: '#003A8C'
  63. } }), function (item, isDragging) {
  64. return React.createElement(Card, { item: item, isDragging: isDragging });
  65. }))));
  66. };
  67. return Mobile;
  68. }(React.Component));
  69. export { Mobile };