@enact/core 3.4.9-experimental-3 → 3.4.9-experimental-7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/{build/dispatcher → dispatcher}/dispatcher.d.ts +0 -0
  3. package/dispatcher/dispatcher.js +76 -57
  4. package/dispatcher/listeners.js +31 -19
  5. package/dispatcher/tests/dispatcher-specs.js +75 -100
  6. package/{build/handle → handle}/handle.d.ts +0 -0
  7. package/handle/handle.js +260 -212
  8. package/handle/tests/handle-specs.js +476 -601
  9. package/{build/hoc → hoc}/hoc.d.ts +0 -0
  10. package/hoc/hoc.js +47 -33
  11. package/hoc/tests/hoc-specs.js +85 -126
  12. package/{build/index.d.ts → index.d.ts} +0 -0
  13. package/index.js +1 -0
  14. package/{build/internal → internal}/ApiDecorator/ApiDecorator.d.ts +0 -0
  15. package/internal/ApiDecorator/ApiDecorator.js +107 -61
  16. package/internal/ApiDecorator/tests/ApiDecorator-specs.js +106 -97
  17. package/{build/internal → internal}/Registry/Registry.d.ts +0 -0
  18. package/internal/Registry/Registry.js +68 -51
  19. package/internal/Registry/tests/Registry-specs.js +201 -143
  20. package/{build/internal → internal}/deprecate/deprecate.d.ts +0 -0
  21. package/internal/deprecate/deprecate.js +85 -60
  22. package/{build/internal → internal}/prop-types/prop-types.d.ts +0 -0
  23. package/internal/prop-types/prop-types.js +68 -61
  24. package/{build/keymap → keymap}/index.d.ts +0 -0
  25. package/keymap/index.js +27 -15
  26. package/keymap/keymap.js +67 -52
  27. package/keymap/tests/keymap-specs.js +75 -104
  28. package/kind/computed.js +29 -16
  29. package/{build/kind → kind}/kind.d.ts +0 -0
  30. package/kind/kind.js +150 -114
  31. package/kind/styles.js +62 -47
  32. package/kind/tests/computed-specs.js +87 -86
  33. package/kind/tests/kind-specs.js +216 -214
  34. package/kind/tests/styles-specs.js +170 -223
  35. package/kind/util.js +15 -7
  36. package/package.json +1 -1
  37. package/{build/platform → platform}/platform.d.ts +0 -0
  38. package/platform/platform.js +263 -169
  39. package/platform/tests/platform-specs.js +92 -90
  40. package/{build/snapshot → snapshot}/snapshot.d.ts +0 -0
  41. package/snapshot/snapshot.js +34 -27
  42. package/useChainRefs/tests/useChainRefs-specs.js +46 -30
  43. package/{build/useChainRefs → useChainRefs}/useChainRefs.d.ts +0 -0
  44. package/useChainRefs/useChainRefs.js +49 -29
  45. package/useClass/tests/useClass-specs.js +51 -46
  46. package/{build/useClass → useClass}/useClass.d.ts +0 -0
  47. package/useClass/useClass.js +27 -9
  48. package/useHandlers/Handlers.js +55 -30
  49. package/useHandlers/tests/useHandlers-specs.js +79 -95
  50. package/{build/useHandlers → useHandlers}/useHandlers.d.ts +0 -0
  51. package/useHandlers/useHandlers.js +18 -11
  52. package/util/Job.js +203 -241
  53. package/util/tests/Job-specs.js +216 -204
  54. package/util/tests/util-specs.js +123 -146
  55. package/{build/util → util}/util.d.ts +0 -0
  56. package/util/util.js +146 -103
  57. package/build/CHANGELOG.md +0 -699
  58. package/build/README.md +0 -33
  59. package/build/dispatcher/dispatcher.js +0 -160
  60. package/build/dispatcher/listeners.js +0 -37
  61. package/build/dispatcher/package.json +0 -3
  62. package/build/dispatcher/tests/dispatcher-specs.js +0 -75
  63. package/build/handle/handle.js +0 -846
  64. package/build/handle/package.json +0 -3
  65. package/build/handle/tests/handle-specs.js +0 -476
  66. package/build/hoc/hoc.js +0 -102
  67. package/build/hoc/package.json +0 -3
  68. package/build/hoc/tests/hoc-specs.js +0 -90
  69. package/build/index.js +0 -2
  70. package/build/internal/ApiDecorator/ApiDecorator.js +0 -143
  71. package/build/internal/ApiDecorator/package.json +0 -3
  72. package/build/internal/ApiDecorator/tests/ApiDecorator-specs.js +0 -106
  73. package/build/internal/Registry/Registry.js +0 -76
  74. package/build/internal/Registry/package.json +0 -3
  75. package/build/internal/Registry/tests/Registry-specs.js +0 -201
  76. package/build/internal/deprecate/deprecate.js +0 -116
  77. package/build/internal/deprecate/package.json +0 -3
  78. package/build/internal/prop-types/package.json +0 -3
  79. package/build/internal/prop-types/prop-types.js +0 -90
  80. package/build/keymap/index.js +0 -54
  81. package/build/keymap/keymap.js +0 -201
  82. package/build/keymap/package.json +0 -3
  83. package/build/keymap/tests/keymap-specs.js +0 -75
  84. package/build/kind/computed.js +0 -60
  85. package/build/kind/kind.js +0 -266
  86. package/build/kind/package.json +0 -3
  87. package/build/kind/styles.js +0 -105
  88. package/build/kind/tests/computed-specs.js +0 -87
  89. package/build/kind/tests/kind-specs.js +0 -216
  90. package/build/kind/tests/styles-specs.js +0 -170
  91. package/build/kind/util.js +0 -17
  92. package/build/package-lock.json +0 -206
  93. package/build/package.json +0 -38
  94. package/build/platform/package.json +0 -3
  95. package/build/platform/platform.js +0 -306
  96. package/build/platform/tests/platform-specs.js +0 -92
  97. package/build/snapshot/package.json +0 -3
  98. package/build/snapshot/snapshot.js +0 -89
  99. package/build/useChainRefs/package.json +0 -3
  100. package/build/useChainRefs/tests/useChainRefs-specs.js +0 -57
  101. package/build/useChainRefs/useChainRefs.js +0 -78
  102. package/build/useClass/package.json +0 -3
  103. package/build/useClass/tests/useClass-specs.js +0 -51
  104. package/build/useClass/useClass.js +0 -59
  105. package/build/useHandlers/Handlers.js +0 -55
  106. package/build/useHandlers/package.json +0 -3
  107. package/build/useHandlers/tests/useHandlers-specs.js +0 -84
  108. package/build/useHandlers/useHandlers.js +0 -36
  109. package/build/util/Job.js +0 -211
  110. package/build/util/package.json +0 -3
  111. package/build/util/tests/Job-specs.js +0 -216
  112. package/build/util/tests/util-specs.js +0 -123
  113. package/build/util/util.js +0 -322
@@ -1,3 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isWindowReady = isWindowReady;
7
+ exports.onWindowReady = onWindowReady;
8
+ exports.windowReady = windowReady;
9
+ exports["default"] = void 0;
10
+
11
+ var _invariant = _interopRequireDefault(require("invariant"));
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
+
1
15
  /**
2
16
  * Utilities to facilitate integration with v8 snapshot builds
3
17
  *
@@ -7,11 +21,7 @@
7
21
  * @exports windowReady
8
22
  * @public
9
23
  */
10
-
11
- import invariant from 'invariant';
12
-
13
- const windowCallbacks = [];
14
-
24
+ var windowCallbacks = [];
15
25
  /**
16
26
  * Determines if the `window` is available
17
27
  *
@@ -21,10 +31,10 @@ const windowCallbacks = [];
21
31
  * @memberof core/snapshot
22
32
  * @public
23
33
  */
24
- function isWindowReady () {
25
- return typeof window !== 'undefined';
26
- }
27
34
 
35
+ function isWindowReady() {
36
+ return typeof window !== 'undefined';
37
+ }
28
38
  /**
29
39
  * Executes a callback, such as registering event handlers, when a valid `window` is available.
30
40
  *
@@ -46,14 +56,15 @@ function isWindowReady () {
46
56
  * @memberof core/snapshot
47
57
  * @public
48
58
  */
49
- function onWindowReady (callback) {
50
- if (isWindowReady()) {
51
- callback();
52
- } else {
53
- windowCallbacks.push(callback);
54
- }
55
- }
56
59
 
60
+
61
+ function onWindowReady(callback) {
62
+ if (isWindowReady()) {
63
+ callback();
64
+ } else {
65
+ windowCallbacks.push(callback);
66
+ }
67
+ }
57
68
  /**
58
69
  * Executes all queued window callbacks.
59
70
  *
@@ -65,18 +76,14 @@ function onWindowReady (callback) {
65
76
  * @memberof core/snapshot
66
77
  * @public
67
78
  */
68
- function windowReady () {
69
- invariant(
70
- isWindowReady(),
71
- 'windowReady cannot be run until the window is available'
72
- );
73
79
 
74
- windowCallbacks.forEach(f => f());
80
+
81
+ function windowReady() {
82
+ !isWindowReady() ? process.env.NODE_ENV !== "production" ? (0, _invariant["default"])(false, 'windowReady cannot be run until the window is available') : invariant(false) : void 0;
83
+ windowCallbacks.forEach(function (f) {
84
+ return f();
85
+ });
75
86
  }
76
87
 
77
- export default onWindowReady;
78
- export {
79
- isWindowReady,
80
- onWindowReady,
81
- windowReady
82
- };
88
+ var _default = onWindowReady;
89
+ exports["default"] = _default;
@@ -1,41 +1,57 @@
1
- /* eslint-disable enact/prop-types */
1
+ "use strict";
2
2
 
3
- import {mount} from 'enzyme';
4
- import React from 'react';
3
+ var _enzyme = require("enzyme");
5
4
 
6
- import useChainRefs from '../useChainRefs';
5
+ var _react = _interopRequireDefault(require("react"));
7
6
 
8
- describe('useChainRefs', () => {
9
- function Component (props) {
10
- const ref = useChainRefs(...props.refs);
7
+ var _useChainRefs = _interopRequireDefault(require("../useChainRefs"));
11
8
 
12
- return (
13
- <div ref={ref} />
14
- );
15
- }
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
10
 
17
- test('should call a single functional ref', () => {
18
- const ref = jest.fn();
19
- mount(<Component refs={[ref]} />);
11
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
20
12
 
21
- expect(ref).toHaveBeenCalledTimes(1);
22
- });
13
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
23
14
 
24
- test('should call a single object ref', () => {
25
- const ref = React.createRef();
26
- mount(<Component refs={[ref]} />);
15
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
27
16
 
28
- const expected = 'DIV';
29
- const actual = ref.current.nodeName;
17
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
30
18
 
31
- expect(actual).toBe(expected);
32
- });
19
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
33
20
 
34
- test('should ignore invalid refs', () => {
35
- const invalid = {};
36
- const ref = jest.fn();
37
- mount(<Component refs={[invalid, ref]} />);
21
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
38
22
 
39
- expect(ref).toHaveBeenCalledTimes(1);
40
- });
41
- });
23
+ describe('useChainRefs', function () {
24
+ function Component(props) {
25
+ var ref = _useChainRefs["default"].apply(void 0, _toConsumableArray(props.refs));
26
+
27
+ return /*#__PURE__*/_react["default"].createElement("div", {
28
+ ref: ref
29
+ });
30
+ }
31
+
32
+ test('should call a single functional ref', function () {
33
+ var ref = jest.fn();
34
+ (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
35
+ refs: [ref]
36
+ }));
37
+ expect(ref).toHaveBeenCalledTimes(1);
38
+ });
39
+ test('should call a single object ref', function () {
40
+ var ref = /*#__PURE__*/_react["default"].createRef();
41
+
42
+ (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
43
+ refs: [ref]
44
+ }));
45
+ var expected = 'DIV';
46
+ var actual = ref.current.nodeName;
47
+ expect(actual).toBe(expected);
48
+ });
49
+ test('should ignore invalid refs', function () {
50
+ var invalid = {};
51
+ var ref = jest.fn();
52
+ (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
53
+ refs: [invalid, ref]
54
+ }));
55
+ expect(ref).toHaveBeenCalledTimes(1);
56
+ });
57
+ });
@@ -1,3 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useChainRefs = useChainRefs;
7
+ exports.chainRefs = chainRefs;
8
+ exports["default"] = void 0;
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var _warning = _interopRequireDefault(require("warning"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
+
1
16
  /**
2
17
  * Updates multiple reference callbacks or objects
3
18
  *
@@ -6,24 +21,19 @@
6
21
  * @exports chainRefs
7
22
  * @private
8
23
  */
9
-
10
- import React from 'react';
11
- import warning from 'warning';
12
-
13
24
  // Safely handles functional and object refs (and ignores invalid refs)
14
- function updateRef (ref, node) {
15
- if (ref) {
16
- if (typeof ref === 'function') {
17
- ref(node);
18
- } else if (Object.prototype.hasOwnProperty.call(ref, 'current')) {
19
- ref.current = node;
20
- } else {
21
- // warn for a truthy ref that isn't a function or is an object without `current`
22
- warning(ref, `Invalid ref "${ref}" passed to useChainRefs.`);
23
- }
24
- }
25
+ function updateRef(ref, node) {
26
+ if (ref) {
27
+ if (typeof ref === 'function') {
28
+ ref(node);
29
+ } else if (Object.prototype.hasOwnProperty.call(ref, 'current')) {
30
+ ref.current = node;
31
+ } else {
32
+ // warn for a truthy ref that isn't a function or is an object without `current`
33
+ process.env.NODE_ENV !== "production" ? (0, _warning["default"])(ref, "Invalid ref \"".concat(ref, "\" passed to useChainRefs.")) : void 0;
34
+ }
35
+ }
25
36
  }
26
-
27
37
  /**
28
38
  * Creates a reference callback that updates each of the provided references
29
39
  *
@@ -32,12 +42,19 @@ function updateRef (ref, node) {
32
42
  * @returns {Function} A callback that updates each reference
33
43
  * @public
34
44
  */
35
- function chainRefs (...refs) {
36
- return (node) => {
37
- refs.forEach(ref => updateRef(ref, node));
38
- };
39
- }
40
45
 
46
+
47
+ function chainRefs() {
48
+ for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
49
+ refs[_key] = arguments[_key];
50
+ }
51
+
52
+ return function (node) {
53
+ refs.forEach(function (ref) {
54
+ return updateRef(ref, node);
55
+ });
56
+ };
57
+ }
41
58
  /**
42
59
  * Creates a memoized reference callback that updates each of the provided references
43
60
  *
@@ -46,13 +63,16 @@ function chainRefs (...refs) {
46
63
  * @returns {Function} A memoized callback that updates each reference
47
64
  * @public
48
65
  */
49
- function useChainRefs (...refs) {
50
- // eslint-disable-next-line react-hooks/exhaustive-deps
51
- return React.useCallback(chainRefs(...refs), refs);
66
+
67
+
68
+ function useChainRefs() {
69
+ for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
70
+ refs[_key2] = arguments[_key2];
71
+ }
72
+
73
+ // eslint-disable-next-line react-hooks/exhaustive-deps
74
+ return _react["default"].useCallback(chainRefs.apply(void 0, refs), refs);
52
75
  }
53
76
 
54
- export default useChainRefs;
55
- export {
56
- useChainRefs,
57
- chainRefs
58
- };
77
+ var _default = useChainRefs;
78
+ exports["default"] = _default;
@@ -1,46 +1,51 @@
1
- /* eslint-disable enact/prop-types */
2
-
3
- import {shallow} from 'enzyme';
4
- import React from 'react';
5
-
6
- import useClass from '../useClass';
7
-
8
- describe('useClass', () => {
9
- class Class {
10
- constructor (arg) {
11
- this.arg = arg;
12
- }
13
- }
14
-
15
- function Component (props) {
16
- const instance = useClass(Class, props.arg);
17
-
18
- return (
19
- <div fromProps={props.arg} fromClass={instance.arg} />
20
- );
21
- }
22
-
23
- test('should pass arg to Class', () => {
24
- const arg = 'arg';
25
- const subject = shallow(<Component arg={arg} />);
26
-
27
- const expected = arg;
28
- const actual = subject.prop('fromClass');
29
-
30
- expect(actual).toBe(expected);
31
- });
32
-
33
- test('should use the same instance of Class across renders', () => {
34
- const arg = 'arg';
35
- const subject = shallow(<Component arg={arg} />);
36
-
37
- expect(subject.prop('fromProps')).toBe(arg);
38
-
39
- subject.setProps({arg: 'changed'});
40
-
41
- // verify that the children still reflects the class value set at construction but the prop
42
- // value was updated when props were updated
43
- expect(subject.prop('fromClass')).toBe(arg);
44
- expect(subject.prop('fromProps')).toBe('changed');
45
- });
46
- });
1
+ "use strict";
2
+
3
+ var _enzyme = require("enzyme");
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _useClass = _interopRequireDefault(require("../useClass"));
8
+
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
+
11
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
+
13
+ describe('useClass', function () {
14
+ var Class = function Class(arg) {
15
+ _classCallCheck(this, Class);
16
+
17
+ this.arg = arg;
18
+ };
19
+
20
+ function Component(props) {
21
+ var instance = (0, _useClass["default"])(Class, props.arg);
22
+ return /*#__PURE__*/_react["default"].createElement("div", {
23
+ fromProps: props.arg,
24
+ fromClass: instance.arg
25
+ });
26
+ }
27
+
28
+ test('should pass arg to Class', function () {
29
+ var arg = 'arg';
30
+ var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
31
+ arg: arg
32
+ }));
33
+ var expected = arg;
34
+ var actual = subject.prop('fromClass');
35
+ expect(actual).toBe(expected);
36
+ });
37
+ test('should use the same instance of Class across renders', function () {
38
+ var arg = 'arg';
39
+ var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, {
40
+ arg: arg
41
+ }));
42
+ expect(subject.prop('fromProps')).toBe(arg);
43
+ subject.setProps({
44
+ arg: 'changed'
45
+ }); // verify that the children still reflects the class value set at construction but the prop
46
+ // value was updated when props were updated
47
+
48
+ expect(subject.prop('fromClass')).toBe(arg);
49
+ expect(subject.prop('fromProps')).toBe('changed');
50
+ });
51
+ });
File without changes
@@ -1,4 +1,20 @@
1
- import React from 'react';
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useClass = useClass;
7
+ exports["default"] = void 0;
8
+
9
+ var _react = _interopRequireDefault(require("react"));
10
+
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
+
13
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
14
+
15
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
16
+
17
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
2
18
 
3
19
  /**
4
20
  * Creates one instance of the class, `Ctor` with the provided `args`, for the life of the
@@ -28,14 +44,16 @@ import React from 'react';
28
44
  * @returns {Object} An instance of `Ctor`
29
45
  * @private
30
46
  */
31
- function useClass (Ctor, ...args) {
32
- const ref = React.useRef(null);
33
- ref.current = ref.current || new Ctor(...args);
47
+ function useClass(Ctor) {
48
+ var ref = _react["default"].useRef(null);
49
+
50
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
51
+ args[_key - 1] = arguments[_key];
52
+ }
34
53
 
35
- return ref.current;
54
+ ref.current = ref.current || _construct(Ctor, args);
55
+ return ref.current;
36
56
  }
37
57
 
38
- export default useClass;
39
- export {
40
- useClass
41
- };
58
+ var _default = useClass;
59
+ exports["default"] = _default;
@@ -1,30 +1,55 @@
1
- class Handlers {
2
- constructor (_handlers) {
3
- this.props = {};
4
- this.context = {};
5
-
6
- this._handlers = {};
7
- if (_handlers) {
8
- Object.keys(_handlers).forEach(fn => {
9
- this._handlers[fn] = (ev) => {
10
- return _handlers[fn](ev, this.props, this.context);
11
- };
12
- this._handlers[fn].displayName = fn;
13
- });
14
- }
15
- }
16
-
17
- get handlers () {
18
- return this._handlers;
19
- }
20
-
21
- setContext (props = {}, context = {}) {
22
- this.props = props;
23
- this.context = context;
24
- }
25
- }
26
-
27
- export default Handlers;
28
- export {
29
- Handlers
30
- };
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Handlers = exports["default"] = void 0;
7
+
8
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
+
10
+ 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); } }
11
+
12
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
13
+
14
+ var Handlers = /*#__PURE__*/function () {
15
+ function Handlers(_handlers) {
16
+ var _this = this;
17
+
18
+ _classCallCheck(this, Handlers);
19
+
20
+ this.props = {};
21
+ this.context = {};
22
+ this._handlers = {};
23
+
24
+ if (_handlers) {
25
+ Object.keys(_handlers).forEach(function (fn) {
26
+ _this._handlers[fn] = function (ev) {
27
+ return _handlers[fn](ev, _this.props, _this.context);
28
+ };
29
+
30
+ _this._handlers[fn].displayName = fn;
31
+ });
32
+ }
33
+ }
34
+
35
+ _createClass(Handlers, [{
36
+ key: "setContext",
37
+ value: function setContext() {
38
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
39
+ var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
40
+ this.props = props;
41
+ this.context = context;
42
+ }
43
+ }, {
44
+ key: "handlers",
45
+ get: function get() {
46
+ return this._handlers;
47
+ }
48
+ }]);
49
+
50
+ return Handlers;
51
+ }();
52
+
53
+ exports.Handlers = Handlers;
54
+ var _default = Handlers;
55
+ exports["default"] = _default;