index.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6. return function (d, b) {
  7. extendStatics(d, b);
  8. function __() { this.constructor = d; }
  9. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10. };
  11. })();
  12. Object.defineProperty(exports, "__esModule", { value: true });
  13. var React = require("react");
  14. var ReactDOM = require("react-dom");
  15. var index_1 = require("./NormalLayout/index");
  16. var SortedTable_1 = require("./SortedTable");
  17. var StaticHeader_1 = require("./StaticHeader");
  18. require("./index.css");
  19. var DemoMap = {
  20. normalLayout: React.createElement(index_1.LayoutDemo, null),
  21. SortedTable: React.createElement(SortedTable_1.SortedTable, null),
  22. StaticHeader: React.createElement(StaticHeader_1.SortedTableWithStatic, null)
  23. };
  24. var DemoDispatcher = /** @class */ (function (_super) {
  25. __extends(DemoDispatcher, _super);
  26. function DemoDispatcher() {
  27. var _this = _super !== null && _super.apply(this, arguments) || this;
  28. _this.state = {
  29. demo: React.createElement(index_1.LayoutDemo, null)
  30. };
  31. _this.handleLayoutChange = function (demoName) {
  32. _this.setState({
  33. demo: DemoMap[demoName]
  34. });
  35. };
  36. return _this;
  37. }
  38. DemoDispatcher.prototype.render = function () {
  39. var _this = this;
  40. return (React.createElement("div", null,
  41. React.createElement("div", { className: 'demo-button-layout' },
  42. React.createElement("div", null, "Switch Demos"),
  43. React.createElement("button", { onClick: function () { return _this.handleLayoutChange('normalLayout'); } }, "normalLayout"),
  44. React.createElement("button", { onClick: function () { return _this.handleLayoutChange('SortedTable'); } }, "SortedTable"),
  45. React.createElement("button", { onClick: function () { return _this.handleLayoutChange('StaticHeader'); } }, "StaticHeader")),
  46. this.state.demo));
  47. };
  48. return DemoDispatcher;
  49. }(React.Component));
  50. ReactDOM.render(React.createElement(DemoDispatcher, null), document.getElementById('root'));