@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,100 +1,84 @@
1
- /* eslint-disable enact/prop-types */
2
-
3
- import {shallow} from 'enzyme';
4
- import React from 'react';
5
-
6
- import useHandlers from '../useHandlers';
7
-
8
- describe('useHandlers', () => {
9
- const context = {
10
- value: 1
11
- };
12
- function Component (props) {
13
- const handlers = useHandlers({
14
- testEvent: (ev, p, c) => {
15
- return ev(p, c);
16
- }
17
- }, props, context);
18
-
19
- return (
20
- <div {...props} {...handlers} />
21
- );
22
- }
23
-
24
- // Sanity test for Component moreso than useHandlers test
25
- test('should include handlers in props', () => {
26
- const subject = shallow(<Component />);
27
-
28
- const expected = 'testEvent';
29
- const actual = subject.props();
30
-
31
- expect(actual).toHaveProperty(expected);
32
- });
33
-
34
- test('should have the same reference across renders', () => {
35
- const subject = shallow(<Component />);
36
-
37
- const expected = subject.prop('testEvent');
38
-
39
- subject.setProps({});
40
-
41
- const actual = subject.prop('testEvent');
42
-
43
- expect(actual).toBe(expected);
44
- });
1
+ "use strict";
45
2
 
46
- test('should receive the event', () => {
47
- const spy = jest.fn();
48
- const subject = shallow(<Component />);
3
+ var _enzyme = require("enzyme");
49
4
 
50
- const props = {children: 'updated'};
51
- subject.setProps(props);
5
+ var _react = _interopRequireDefault(require("react"));
52
6
 
53
- subject.find('div').invoke('testEvent')(spy);
7
+ var _useHandlers = _interopRequireDefault(require("../useHandlers"));
54
8
 
55
- expect(spy).toHaveBeenCalled();
56
- });
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
57
10
 
58
- test('should reflect the latest props', () => {
59
- const spy = jest.fn();
60
- const subject = shallow(<Component />);
61
-
62
- const props = {children: 'updated'};
63
- subject.setProps(props);
64
-
65
- subject.find('div').invoke('testEvent')(spy);
66
-
67
- const expected = props;
68
- const actual = spy.mock.calls[0][0];
69
-
70
- expect(actual).toMatchObject(expected);
71
- });
72
-
73
- test('should support component-driven context', () => {
74
- const spy = jest.fn();
75
- const subject = shallow(<Component />);
76
-
77
- subject.find('div').invoke('testEvent')(spy);
78
-
79
- // defined a "global" context to ease testability but this isn't representative of the
80
- // expected use case of this feature.
81
- const expected = context;
82
- const actual = spy.mock.calls[0][1];
83
-
84
- expect(actual).toMatchObject(expected);
85
- });
86
-
87
- test('should return the value from the handler', () => {
88
- const spy = jest.fn().mockImplementation(() => 'ok');
89
- const subject = shallow(<Component />);
90
-
91
- const returnValue = subject.find('div').invoke('testEvent')(spy);
92
-
93
- // defined a "global" context to ease testability but this isn't representative of the
94
- // expected use case of this feature.
95
- const expected = 'ok';
96
- const actual = returnValue;
97
-
98
- expect(actual).toBe(expected);
99
- });
100
- });
11
+ /* eslint-disable enact/prop-types */
12
+ describe('useHandlers', function () {
13
+ var context = {
14
+ value: 1
15
+ };
16
+
17
+ function Component(props) {
18
+ var handlers = (0, _useHandlers["default"])({
19
+ testEvent: function testEvent(ev, p, c) {
20
+ return ev(p, c);
21
+ }
22
+ }, props, context);
23
+ return /*#__PURE__*/_react["default"].createElement("div", Object.assign({}, props, handlers));
24
+ } // Sanity test for Component moreso than useHandlers test
25
+
26
+
27
+ test('should include handlers in props', function () {
28
+ var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
29
+ var expected = 'testEvent';
30
+ var actual = subject.props();
31
+ expect(actual).toHaveProperty(expected);
32
+ });
33
+ test('should have the same reference across renders', function () {
34
+ var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
35
+ var expected = subject.prop('testEvent');
36
+ subject.setProps({});
37
+ var actual = subject.prop('testEvent');
38
+ expect(actual).toBe(expected);
39
+ });
40
+ test('should receive the event', function () {
41
+ var spy = jest.fn();
42
+ var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
43
+ var props = {
44
+ children: 'updated'
45
+ };
46
+ subject.setProps(props);
47
+ subject.find('div').invoke('testEvent')(spy);
48
+ expect(spy).toHaveBeenCalled();
49
+ });
50
+ test('should reflect the latest props', function () {
51
+ var spy = jest.fn();
52
+ var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
53
+ var props = {
54
+ children: 'updated'
55
+ };
56
+ subject.setProps(props);
57
+ subject.find('div').invoke('testEvent')(spy);
58
+ var expected = props;
59
+ var actual = spy.mock.calls[0][0];
60
+ expect(actual).toMatchObject(expected);
61
+ });
62
+ test('should support component-driven context', function () {
63
+ var spy = jest.fn();
64
+ var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
65
+ subject.find('div').invoke('testEvent')(spy); // defined a "global" context to ease testability but this isn't representative of the
66
+ // expected use case of this feature.
67
+
68
+ var expected = context;
69
+ var actual = spy.mock.calls[0][1];
70
+ expect(actual).toMatchObject(expected);
71
+ });
72
+ test('should return the value from the handler', function () {
73
+ var spy = jest.fn().mockImplementation(function () {
74
+ return 'ok';
75
+ });
76
+ var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
77
+ var returnValue = subject.find('div').invoke('testEvent')(spy); // defined a "global" context to ease testability but this isn't representative of the
78
+ // expected use case of this feature.
79
+
80
+ var expected = 'ok';
81
+ var actual = returnValue;
82
+ expect(actual).toBe(expected);
83
+ });
84
+ });
@@ -1,6 +1,16 @@
1
- import useClass from '../useClass';
1
+ "use strict";
2
2
 
3
- import Handlers from './Handlers';
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useHandlers = useHandlers;
7
+ exports["default"] = void 0;
8
+
9
+ var _useClass = _interopRequireDefault(require("../useClass"));
10
+
11
+ var _Handlers = _interopRequireDefault(require("./Handlers"));
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
4
14
 
5
15
  /**
6
16
  * Creates a map of event handlers with consistent references across renders.
@@ -16,14 +26,11 @@ import Handlers from './Handlers';
16
26
  * @returns {Object} A map of bound handlers
17
27
  * @private
18
28
  */
19
- function useHandlers (handlers, props, context) {
20
- const h = useClass(Handlers, handlers);
21
- h.setContext(props, context);
22
-
23
- return h.handlers;
29
+ function useHandlers(handlers, props, context) {
30
+ var h = (0, _useClass["default"])(_Handlers["default"], handlers);
31
+ h.setContext(props, context);
32
+ return h.handlers;
24
33
  }
25
34
 
26
- export default useHandlers;
27
- export {
28
- useHandlers
29
- };
35
+ var _default = useHandlers;
36
+ exports["default"] = _default;