1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.reactStory = reactStory;
|
7 | exports.default = void 0;
|
8 |
|
9 | var _react = _interopRequireDefault(require("react"));
|
10 |
|
11 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
12 |
|
13 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14 |
|
15 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
16 |
|
17 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
18 |
|
19 | function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
20 |
|
21 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
22 |
|
23 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
24 |
|
25 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
26 |
|
27 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
28 |
|
29 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
30 |
|
31 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
32 |
|
33 | var ReactDecorator =
|
34 |
|
35 | function (_React$Component) {
|
36 | _inherits(ReactDecorator, _React$Component);
|
37 |
|
38 | function ReactDecorator(props) {
|
39 | var _this;
|
40 |
|
41 | _classCallCheck(this, ReactDecorator);
|
42 |
|
43 | _this = _possibleConstructorReturn(this, _getPrototypeOf(ReactDecorator).call(this, props));
|
44 |
|
45 | _this.props.onMount();
|
46 |
|
47 | return _this;
|
48 | }
|
49 |
|
50 | _createClass(ReactDecorator, [{
|
51 | key: "componentWillUnmount",
|
52 | value: function componentWillUnmount() {
|
53 | this.props.onUnMount();
|
54 | }
|
55 | }, {
|
56 | key: "render",
|
57 | value: function render() {
|
58 | return this.props.story;
|
59 | }
|
60 | }]);
|
61 |
|
62 | return ReactDecorator;
|
63 | }(_react.default.Component);
|
64 |
|
65 | ReactDecorator.propTypes = {
|
66 | story: _propTypes.default.node.isRequired,
|
67 | onMount: _propTypes.default.func.isRequired,
|
68 | onUnMount: _propTypes.default.func.isRequired
|
69 | };
|
70 | var _default = ReactDecorator;
|
71 | exports.default = _default;
|
72 |
|
73 | function reactStory(story, onMount, onUnMount) {
|
74 | return _react.default.createElement(ReactDecorator, {
|
75 | story: story,
|
76 | onMount: onMount,
|
77 | onUnMount: onUnMount
|
78 | });
|
79 | } |
\ | No newline at end of file |