index.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. import * as React from "react";
  12. import * as ReactDOM from "react-dom";
  13. import { LayoutDemo } from './NormalLayout/index';
  14. // import { SortedTable } from "./SortedTable/index";
  15. // import { SortedTableWithStatic } from "./StaticHeader/index";
  16. // import { LayoutRestore } from "./LayoutRestore/index";
  17. // import { HandleLayout } from "./HandleLayout/index";
  18. // import { AddRemove } from "./AddRemove/index";
  19. // import { SortableList } from "./SortableList/index";
  20. import './index.css';
  21. import { Dragact } from "./lib/dragact";
  22. var DemoMap = {
  23. normalLayout: React.createElement(LayoutDemo, null),
  24. };
  25. var DemoDispatcher = /** @class */ (function (_super) {
  26. __extends(DemoDispatcher, _super);
  27. function DemoDispatcher() {
  28. var _this = _super !== null && _super.apply(this, arguments) || this;
  29. _this.state = {
  30. demo: React.createElement(LayoutDemo, null)
  31. };
  32. _this.handleLayoutChange = function (demoName) {
  33. _this.setState({
  34. demo: DemoMap[demoName]
  35. });
  36. };
  37. return _this;
  38. }
  39. DemoDispatcher.prototype.render = function () {
  40. var _this = this;
  41. return (React.createElement("div", null,
  42. React.createElement("div", { className: 'demo-button-layout' },
  43. React.createElement("div", null, "Switch Demos"),
  44. React.createElement("button", { onClick: function () { return _this.handleLayoutChange('normalLayout'); } }, "normalLayout")),
  45. this.state.demo));
  46. };
  47. return DemoDispatcher;
  48. }(React.Component));
  49. React.createElement(DemoDispatcher, null);
  50. var fakeData = [
  51. { GridX: 0, GridY: 0, w: 4, h: 2, key: '0' },
  52. { GridX: 0, GridY: 0, w: 4, h: 2, key: '1' },
  53. { GridX: 0, GridY: 0, w: 4, h: 2, key: '2' }
  54. ];
  55. var blockStyle = {
  56. background: 'grey',
  57. height: '100%'
  58. };
  59. ReactDOM.render(React.createElement(Dragact, { layout: fakeData, col: 16, width: 800, rowHeight: 40, margin: [5, 5], className: 'plant-layout', style: { background: '#eee' }, placeholder: true }, function (item, isDragging) {
  60. return React.createElement("div", { style: blockStyle }, isDragging ? '正在抓取' : '停放');
  61. }), document.getElementById('root'));