index.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 { 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. 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. };
  39. var Mobile = /** @class */ (function (_super) {
  40. __extends(Mobile, _super);
  41. function Mobile() {
  42. return _super !== null && _super.apply(this, arguments) || this;
  43. }
  44. Mobile.prototype.render = function () {
  45. var margin = [5, 5];
  46. var dragactInit = {
  47. width: 500,
  48. col: 16,
  49. rowHeight: 45,
  50. margin: margin,
  51. className: 'normal-layout',
  52. layout: fakeData()
  53. };
  54. return (React.createElement("div", { style: {
  55. display: 'flex',
  56. justifyContent: 'center'
  57. } },
  58. React.createElement("div", null,
  59. React.createElement("h1", { style: { textAlign: 'center' } }, "\u624B\u673A\u666E\u901A\u5E03\u5C40demo"),
  60. React.createElement(Dragact, __assign({}, dragactInit, { placeholder: true, style: {
  61. background: '#003A8C'
  62. } }), function (item, provided) {
  63. return React.createElement(Card, { item: item, provided: provided });
  64. }))));
  65. };
  66. return Mobile;
  67. }(React.Component));
  68. export { Mobile };