@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,123 +0,0 @@
1
- "use strict";
2
-
3
- var _react = _interopRequireDefault(require("react"));
4
-
5
- var _util = require("../util");
6
-
7
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8
-
9
- describe('util', function () {
10
- describe('isRenderable', function () {
11
- test('should return {true} for function', function () {
12
- var expected = true;
13
- var actual = (0, _util.isRenderable)(function () {});
14
- expect(actual).toEqual(expected);
15
- });
16
- test('should return {true} for string', function () {
17
- var expected = true;
18
- var actual = (0, _util.isRenderable)('div');
19
- expect(actual).toEqual(expected);
20
- });
21
- test('should return {true} for React.forwardRef', function () {
22
- var expected = true;
23
- var actual = (0, _util.isRenderable)( /*#__PURE__*/_react["default"].forwardRef(function () {}));
24
- expect(actual).toEqual(expected);
25
- });
26
- test('should return {true} for React.memo', function () {
27
- var expected = true;
28
- var actual = (0, _util.isRenderable)( /*#__PURE__*/_react["default"].memo(function () {}));
29
- expect(actual).toEqual(expected);
30
- });
31
- test('should return {true} for React.lazy', function () {
32
- var expected = true;
33
- var actual = (0, _util.isRenderable)( /*#__PURE__*/_react["default"].lazy(function () {}));
34
- expect(actual).toEqual(expected);
35
- });
36
- });
37
- describe('memoize', function () {
38
- test('should memoize function', function () {
39
- var obj = {},
40
- testMethod = function testMethod(key) {
41
- obj[key] = (obj[key] || 0) + 1;
42
- },
43
- memoizedTest = (0, _util.memoize)(testMethod);
44
-
45
- expect(obj).not.toHaveProperty('a');
46
- memoizedTest('a');
47
- expect(obj).toHaveProperty('a', 1);
48
- memoizedTest('a');
49
- memoizedTest('a');
50
- expect(obj).toHaveProperty('a', 1);
51
- });
52
- test('should forward all args to memoized function', function () {
53
- var spy = jest.fn();
54
- var memoized = (0, _util.memoize)(spy);
55
- memoized(1, 2);
56
- var expected = [1, 2];
57
- var actual = spy.mock.calls[0];
58
- expect(expected).toEqual(actual);
59
- });
60
- });
61
- describe('mapAndFilterChildren', function () {
62
- test('Returns null if null passed', function () {
63
- var expected = null;
64
- var actual = (0, _util.mapAndFilterChildren)(null, function (val) {
65
- return val;
66
- });
67
- expect(actual).toBe(expected);
68
- });
69
- test('Returns passed array if identity filter', function () {
70
- var children = [1, 2, 3];
71
- var expected = children;
72
- var actual = (0, _util.mapAndFilterChildren)(children, function (val) {
73
- return val;
74
- });
75
- expect(actual).toEqual(expected);
76
- });
77
- test('Returns passed array without nullish or false entries with identity filter', function () {
78
- // eslint-disable-next-line no-undefined
79
- var children = [1, 2, null, 3, undefined, false];
80
- var expected = [1, 2, 3];
81
- var actual = (0, _util.mapAndFilterChildren)(children, function (val) {
82
- return val;
83
- });
84
- expect(actual).toEqual(expected);
85
- });
86
- test('Does not call filter with nullish or false entries', function () {
87
- var spy = jest.fn(); // eslint-disable-next-line no-undefined
88
-
89
- var children = [1, 2, null, 3, undefined, false];
90
- (0, _util.mapAndFilterChildren)(children, spy);
91
- var expected = 3;
92
- var actual = spy.mock.calls.length;
93
- expect(actual).toBe(expected);
94
- });
95
- test('Returns without null entries from filter', function () {
96
- var children = [1, 2, 3];
97
- var expected = [1, 3];
98
- var actual = (0, _util.mapAndFilterChildren)(children, function (val) {
99
- return val === 2 ? null : val;
100
- });
101
- expect(actual).toEqual(expected);
102
- });
103
- test('Runs custom filter', function () {
104
- var children = [1, 2, 3];
105
- var expected = [1];
106
- var actual = (0, _util.mapAndFilterChildren)(children, function (val) {
107
- return val === 2 ? null : val;
108
- }, function (val) {
109
- return val === 1;
110
- });
111
- expect(actual).toEqual(expected);
112
- });
113
- test('should forward value and index to callback', function () {
114
- var spy = jest.fn();
115
- (0, _util.mapAndFilterChildren)([1], spy);
116
- var expected = [1, // value
117
- 0 // index
118
- ];
119
- var actual = spy.mock.calls[0];
120
- expect(expected).toEqual(actual);
121
- });
122
- });
123
- });
@@ -1,322 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "Job", {
7
- enumerable: true,
8
- get: function get() {
9
- return _Job["default"];
10
- }
11
- });
12
- exports.mapAndFilterChildren = exports.perfNow = exports.mergeClassNameMaps = exports.memoize = exports.isRenderable = exports.extractAriaProps = exports.coerceFunction = exports.coerceArray = exports.clamp = exports.cap = void 0;
13
-
14
- var _always = _interopRequireDefault(require("ramda/src/always"));
15
-
16
- var _is = _interopRequireDefault(require("ramda/src/is"));
17
-
18
- var _unless = _interopRequireDefault(require("ramda/src/unless"));
19
-
20
- var _react = _interopRequireDefault(require("react"));
21
-
22
- var ReactIs = _interopRequireWildcard(require("react-is"));
23
-
24
- var _Job = _interopRequireDefault(require("./Job"));
25
-
26
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
27
-
28
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
-
30
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
31
-
32
- /**
33
- * A collection of utility methods.
34
- *
35
- * @module core/util
36
- * @exports cap
37
- * @exports clamp
38
- * @exports coerceArray
39
- * @exports coerceFunction
40
- * @exports extractAriaProps
41
- * @exports isRenderable
42
- * @exports Job
43
- * @exports memoize
44
- * @exports mergeClassNameMaps
45
- * @exports perfNow
46
- * @exports mapAndFilterChildren
47
- */
48
-
49
- /**
50
- * Capitalizes a given string (not locale-aware).
51
- *
52
- * @function
53
- * @param {String} str The string to capitalize.
54
- *
55
- * @returns {String} The capitalized string.
56
- * @memberof core/util
57
- * @public
58
- */
59
- var cap = function cap(str) {
60
- return str.slice(0, 1).toUpperCase() + str.slice(1);
61
- };
62
- /**
63
- * Limits `value` to be between `min` and `max`.
64
- *
65
- * If `min` is greater than `max`, `min` is returned.
66
- *
67
- * @function
68
- * @param {Number} min The minimum value of the range
69
- * @param {Number} max The maximum value of the range
70
- * @param {Number} value The value that must be within the range
71
- *
72
- * @returns {Number} The clamped value
73
- * @memberof core/util
74
- * @public
75
- */
76
-
77
-
78
- exports.cap = cap;
79
-
80
- var clamp = function clamp(min, max, value) {
81
- if (min > max || value < min) return min;
82
- if (value > max) return max;
83
- return value;
84
- };
85
- /**
86
- * If `arg` is a function, return it. Otherwise returns a function that returns `arg`.
87
- *
88
- * Example:
89
- * ```
90
- * const returnsZero = coerceFunction(0);
91
- * const returnsArg = coerceFunction(() => 0);
92
- * ```
93
- * @function
94
- * @param {*} arg Function or value
95
- *
96
- * @returns {Function} Either `arg` if `arg` is a function, or a function that returns `arg`
97
- * @memberof core/util
98
- * @public
99
- */
100
-
101
-
102
- exports.clamp = clamp;
103
- var coerceFunction = (0, _unless["default"])((0, _is["default"])(Function), _always["default"]);
104
- /**
105
- * If `arg` is array-like, return it. Otherwise returns a single element array containing `arg`.
106
- *
107
- * Example:
108
- * ```
109
- * const returnsArray = coerceArray(0); // [0]
110
- * const returnsArg = coerceArray([0]); // [0]
111
- * const returnsObjArg = coerceArray({0: 'zeroth', length: 1});
112
- * ```
113
- * @see http://ramdajs.com/docs/#isArrayLike
114
- * @function
115
- * @param {*} array Array or value
116
- *
117
- * @returns {Array} Either `array` or `[array]`
118
- * @memberof core/util
119
- * @public
120
- */
121
-
122
- exports.coerceFunction = coerceFunction;
123
-
124
- var coerceArray = function coerceArray(array) {
125
- return Array.isArray(array) ? array : [array];
126
- };
127
- /**
128
- * Loosely determines if `tag` is a renderable component (either a string or a function).
129
- *
130
- * @function
131
- * @param {*} tag Component to test
132
- *
133
- * @returns {Boolean} `true` if `tag` is either a string or a function
134
- * @memberof core/util
135
- * @public
136
- */
137
-
138
-
139
- exports.coerceArray = coerceArray;
140
-
141
- var isRenderable = function isRenderable(tag) {
142
- return ReactIs.isValidElementType(tag);
143
- };
144
- /**
145
- * Removes ARIA-related props from `props` and returns them in a new object.
146
- *
147
- * Specifically, it removes the `role` prop and any prop prefixed with `aria-`. This is useful when
148
- * redirecting ARIA-related props from a non-focusable root element to a focusable child element.
149
- *
150
- * @function
151
- * @param {Object} props Props object
152
- *
153
- * @returns {Object} ARIA-related props
154
- * @memberof core/util
155
- * @public
156
- */
157
-
158
-
159
- exports.isRenderable = isRenderable;
160
-
161
- var extractAriaProps = function extractAriaProps(props) {
162
- var aria = {};
163
- Object.keys(props).forEach(function (key) {
164
- if (key === 'role' || key.indexOf('aria-') === 0) {
165
- aria[key] = props[key];
166
- delete props[key];
167
- }
168
- });
169
- return aria;
170
- };
171
- /**
172
- * Gets the current timestamp of either `window.performance.now` or `Date.now`
173
- *
174
- * @function
175
- *
176
- * @returns {Number} The timestamp from `window.performance.now` or `Date.now`
177
- * @memberof core/util
178
- * @public
179
- */
180
-
181
-
182
- exports.extractAriaProps = extractAriaProps;
183
-
184
- var perfNow = function perfNow() {
185
- if (typeof window === 'object') {
186
- return window.performance.now();
187
- } else {
188
- return Date.now();
189
- }
190
- };
191
- /**
192
- * Merges two class name maps into one.
193
- *
194
- * The resulting map will only contain the class names defined in the `baseMap` and will be appended
195
- * with the value from `additiveMap` if it exists. Further, `allowedClassNames` may optionally limit
196
- * which keys will be merged from `additiveMap` into `baseMap`.
197
- *
198
- * Example:
199
- * ```
200
- * // merges all matching class names from additiveMap1 with baseMap1
201
- * const newMap1 = mergeClassNameMaps(baseMap1, additiveMap1);
202
- *
203
- * // merge only 'a' and 'b' class names from additiveMap2 with baseMap2
204
- * const newMap2 = mergeClassNameMaps(baseMap2, additiveMap2, ['a', 'b']);
205
- * ```
206
- *
207
- * @function
208
- * @param {Object} baseMap The source mapping of logical class name to physical
209
- * class name
210
- * @param {Object} additiveMap Mapping of logical to physical class names which are
211
- * concatenated with `baseMap` where the logical names match
212
- * @param {String[]} [allowedClassNames] Array of logical class names that can be augmented. When
213
- * set, the logical class name must exist in `baseMap`,
214
- * `additiveMap`, and this array to be concatenated.
215
- *
216
- * @returns {Object} The merged class name map.
217
- * @memberof core/util
218
- * @public
219
- */
220
-
221
-
222
- exports.perfNow = perfNow;
223
-
224
- var mergeClassNameMaps = function mergeClassNameMaps(baseMap, additiveMap, allowedClassNames) {
225
- var css = baseMap;
226
-
227
- if (baseMap && additiveMap) {
228
- allowedClassNames = allowedClassNames || Object.keys(additiveMap); // if the props includes a css map, merge them together now
229
-
230
- css = Object.assign({}, baseMap);
231
- allowedClassNames.forEach(function (key) {
232
- if (baseMap[key] && additiveMap[key]) {
233
- css[key] = baseMap[key] + ' ' + additiveMap[key];
234
- }
235
- });
236
-
237
- if (process.env.NODE_ENV === 'test') {
238
- return new Proxy({}, {
239
- get: function get(target, key) {
240
- // use the merged value if it exists and the key otherwise
241
- return css[key] || key;
242
- }
243
- });
244
- }
245
- }
246
-
247
- return css;
248
- };
249
- /**
250
- * Creates a function that memoizes the result of `fn`.
251
- *
252
- * Note that this function is a naive implementation and only checks the first argument for
253
- * memoization.
254
- *
255
- * @function
256
- * @param {Function} fn The function to have its output memoized.
257
- *
258
- * @returns {Function} The new memoized function.
259
- * @memberof core/util
260
- * @public
261
- */
262
-
263
-
264
- exports.mergeClassNameMaps = mergeClassNameMaps;
265
-
266
- var memoize = function memoize(fn) {
267
- var cache = {};
268
- return function () {
269
- var n = arguments.length <= 0 ? undefined : arguments[0];
270
-
271
- if (n in cache) {
272
- return cache[n];
273
- } else {
274
- var result = fn.apply(void 0, arguments);
275
- cache[n] = result;
276
- return result;
277
- }
278
- };
279
- };
280
- /**
281
- * Maps over the `children`, discarding any `null` children before and after calling the callback.
282
- *
283
- * A replacement for `React.Children.map`.
284
- *
285
- * @function
286
- * @param {*} children Children to map over
287
- * @param {Function} callback Function to apply to each child. Will not be called if the child is
288
- * `null`. If `callback` returns `null`, the child will be removed from
289
- * the result. If `null` is returned, the item will not be included in
290
- * the final output, regardless of the filter function.
291
- * @param {Function} [filter] Filter function applied after mapping.
292
- *
293
- * @returns {*} The processed children or the value of `children` if not an array.
294
- * @memberof core/util
295
- * @see https://reactjs.org/docs/react-api.html#reactchildrenmap
296
- * @public
297
- */
298
-
299
-
300
- exports.memoize = memoize;
301
-
302
- var mapAndFilterChildren = function mapAndFilterChildren(children, callback, filter) {
303
- var result = _react["default"].Children.map(children, function (child) {
304
- if (child != null) {
305
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
306
- rest[_key - 1] = arguments[_key];
307
- }
308
-
309
- return callback.apply(void 0, [child].concat(rest));
310
- } else {
311
- return child;
312
- }
313
- });
314
-
315
- if (result && filter) {
316
- return result.filter(filter);
317
- } else {
318
- return result;
319
- }
320
- };
321
-
322
- exports.mapAndFilterChildren = mapAndFilterChildren;