index.js 5.2 KB

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