index.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 { SortedTableWithStatic } from "./StaticWidget/index";
  15. import { LayoutRestore } from "./LayoutRestore/index";
  16. import { HandleLayout } from "./HandleLayout/index";
  17. import { AddRemove } from "./AddRemove/index";
  18. import { HistoryDemo } from "./HistoryLayout/index";
  19. import { Mobile } from "./mobileLayout/index";
  20. import './index.css';
  21. // import { Dragact } from "./lib/dragact";
  22. var DemoMap = {
  23. normalLayout: React.createElement(LayoutDemo, null),
  24. // SortedTable: <SortedTable />,
  25. StaticHeader: React.createElement(SortedTableWithStatic, null),
  26. LayoutRestore: React.createElement(LayoutRestore, null),
  27. HandleLayout: React.createElement(HandleLayout, null),
  28. AddRemove: React.createElement(AddRemove, null),
  29. Mobile: React.createElement(Mobile, null),
  30. HistoryLayout: React.createElement(HistoryDemo, null)
  31. };
  32. var DemoDispatcher = /** @class */ (function (_super) {
  33. __extends(DemoDispatcher, _super);
  34. function DemoDispatcher() {
  35. var _this = _super !== null && _super.apply(this, arguments) || this;
  36. _this.state = {
  37. demo: React.createElement(LayoutDemo, null)
  38. };
  39. _this.handleLayoutChange = function (demoName) {
  40. _this.setState({
  41. demo: DemoMap[demoName]
  42. });
  43. };
  44. return _this;
  45. }
  46. DemoDispatcher.prototype.render = function () {
  47. var _this = this;
  48. return (React.createElement("div", null,
  49. React.createElement("iframe", { src: "https://ghbtns.com/github-btn.html?user=215566435&repo=Dragact&type=star&count=true&size=large", frameBorder: '0', scrolling: "0", width: "160px", height: "30px" }),
  50. React.createElement("iframe", { src: "https://ghbtns.com/github-btn.html?user=215566435&repo=Dragact&type=fork&count=true&size=large", frameBorder: "0", scrolling: "0", width: "158px", height: "30px" }),
  51. React.createElement("div", null, "\u5207\u6362 Demos"),
  52. React.createElement("div", { className: 'demo-button-layout' },
  53. React.createElement("button", { onClick: function () { return _this.handleLayoutChange('normalLayout'); } }, "\u666E\u901A\u5E03\u5C40"),
  54. React.createElement("button", { onClick: function () { return _this.handleLayoutChange('StaticHeader'); } }, "\u9759\u6001\u7EC4\u4EF6"),
  55. React.createElement("button", { onClick: function () { return _this.handleLayoutChange('LayoutRestore'); } }, "\u5B58\u50A8\u5E03\u5C40"),
  56. React.createElement("button", { onClick: function () { return _this.handleLayoutChange('HistoryLayout'); } }, "\u8BB0\u5FC6\u64CD\u4F5C\u5E03\u5C40"),
  57. React.createElement("button", { onClick: function () { return _this.handleLayoutChange('HandleLayout'); } }, "\u62D6\u62FD\u628A\u624B"),
  58. React.createElement("button", { onClick: function () { return _this.handleLayoutChange('AddRemove'); } }, "\u589E\u52A0\u548C\u5220\u9664"),
  59. React.createElement("button", { onClick: function () { return _this.handleLayoutChange('Mobile'); } }, "\u79FB\u52A8\u7AEF")),
  60. this.state.demo));
  61. };
  62. return DemoDispatcher;
  63. }(React.Component));
  64. { }
  65. //<Dragact/> */}
  66. // const fakeData = [
  67. // { GridX: 0, GridY: 0, w: 4, h: 2, key: '0' },
  68. // { GridX: 0, GridY: 0, w: 4, h: 2, key: '1' },
  69. // { GridX: 0, GridY: 0, w: 4, h: 2, key: '2' }
  70. // ]
  71. // const getblockStyle = (isDragging: Boolean) => {
  72. // return {
  73. // background: isDragging ? '#1890ff' : 'white',
  74. // }
  75. // };
  76. // const Handle = ({ provided }: any) => {
  77. // return (
  78. // <div
  79. // {...provided.dragHandle}
  80. // style={{
  81. // ...getblockStyle(provided.isDragging),
  82. // borderBottom: '1px solid rgba(120,120,120,0.3)',
  83. // textAlign: 'center'
  84. // }}
  85. // >
  86. // 点击拖拽
  87. // </div>
  88. // )
  89. // }
  90. // ReactDOM.render(
  91. // <Dragact
  92. // layout={fakeData}//必填项
  93. // col={16}//必填项
  94. // width={800}//必填项
  95. // rowHeight={40}//必填项
  96. // margin={[5, 5]}//必填项
  97. // className='plant-layout'//必填项
  98. // style={{ background: '#333' }}//非必填项
  99. // placeholder={true}//非必填项
  100. // >
  101. // {(item: any, provided: any) => {
  102. // return (
  103. // <div
  104. // {...provided.props}
  105. // style={{ ...provided.props.style, background: 'white' }}
  106. // >
  107. // <Handle provided={provided} />
  108. // {provided.isDragging ? '正在抓取' : '停放'}
  109. // </div>
  110. // )
  111. // }}
  112. // </Dragact>,
  113. // document.getElementById('root')
  114. // );
  115. ReactDOM.render(React.createElement(DemoDispatcher, null), document.getElementById('root'));
  116. document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);