@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.
- package/CHANGELOG.md +16 -0
- package/{build/dispatcher → dispatcher}/dispatcher.d.ts +0 -0
- package/dispatcher/dispatcher.js +76 -57
- package/dispatcher/listeners.js +31 -19
- package/dispatcher/tests/dispatcher-specs.js +75 -100
- package/{build/handle → handle}/handle.d.ts +0 -0
- package/handle/handle.js +260 -212
- package/handle/tests/handle-specs.js +476 -601
- package/{build/hoc → hoc}/hoc.d.ts +0 -0
- package/hoc/hoc.js +47 -33
- package/hoc/tests/hoc-specs.js +85 -126
- package/{build/index.d.ts → index.d.ts} +0 -0
- package/index.js +1 -0
- package/{build/internal → internal}/ApiDecorator/ApiDecorator.d.ts +0 -0
- package/internal/ApiDecorator/ApiDecorator.js +107 -61
- package/internal/ApiDecorator/tests/ApiDecorator-specs.js +106 -97
- package/{build/internal → internal}/Registry/Registry.d.ts +0 -0
- package/internal/Registry/Registry.js +68 -51
- package/internal/Registry/tests/Registry-specs.js +201 -143
- package/{build/internal → internal}/deprecate/deprecate.d.ts +0 -0
- package/internal/deprecate/deprecate.js +85 -60
- package/{build/internal → internal}/prop-types/prop-types.d.ts +0 -0
- package/internal/prop-types/prop-types.js +68 -61
- package/{build/keymap → keymap}/index.d.ts +0 -0
- package/keymap/index.js +27 -15
- package/keymap/keymap.js +67 -52
- package/keymap/tests/keymap-specs.js +75 -104
- package/kind/computed.js +29 -16
- package/{build/kind → kind}/kind.d.ts +0 -0
- package/kind/kind.js +150 -114
- package/kind/styles.js +62 -47
- package/kind/tests/computed-specs.js +87 -86
- package/kind/tests/kind-specs.js +216 -214
- package/kind/tests/styles-specs.js +170 -223
- package/kind/util.js +15 -7
- package/package.json +1 -1
- package/{build/platform → platform}/platform.d.ts +0 -0
- package/platform/platform.js +263 -169
- package/platform/tests/platform-specs.js +92 -90
- package/{build/snapshot → snapshot}/snapshot.d.ts +0 -0
- package/snapshot/snapshot.js +34 -27
- package/useChainRefs/tests/useChainRefs-specs.js +46 -30
- package/{build/useChainRefs → useChainRefs}/useChainRefs.d.ts +0 -0
- package/useChainRefs/useChainRefs.js +49 -29
- package/useClass/tests/useClass-specs.js +51 -46
- package/{build/useClass → useClass}/useClass.d.ts +0 -0
- package/useClass/useClass.js +27 -9
- package/useHandlers/Handlers.js +55 -30
- package/useHandlers/tests/useHandlers-specs.js +79 -95
- package/{build/useHandlers → useHandlers}/useHandlers.d.ts +0 -0
- package/useHandlers/useHandlers.js +18 -11
- package/util/Job.js +203 -241
- package/util/tests/Job-specs.js +216 -204
- package/util/tests/util-specs.js +123 -146
- package/{build/util → util}/util.d.ts +0 -0
- package/util/util.js +146 -103
- package/build/CHANGELOG.md +0 -699
- package/build/README.md +0 -33
- package/build/dispatcher/dispatcher.js +0 -160
- package/build/dispatcher/listeners.js +0 -37
- package/build/dispatcher/package.json +0 -3
- package/build/dispatcher/tests/dispatcher-specs.js +0 -75
- package/build/handle/handle.js +0 -846
- package/build/handle/package.json +0 -3
- package/build/handle/tests/handle-specs.js +0 -476
- package/build/hoc/hoc.js +0 -102
- package/build/hoc/package.json +0 -3
- package/build/hoc/tests/hoc-specs.js +0 -90
- package/build/index.js +0 -2
- package/build/internal/ApiDecorator/ApiDecorator.js +0 -143
- package/build/internal/ApiDecorator/package.json +0 -3
- package/build/internal/ApiDecorator/tests/ApiDecorator-specs.js +0 -106
- package/build/internal/Registry/Registry.js +0 -76
- package/build/internal/Registry/package.json +0 -3
- package/build/internal/Registry/tests/Registry-specs.js +0 -201
- package/build/internal/deprecate/deprecate.js +0 -116
- package/build/internal/deprecate/package.json +0 -3
- package/build/internal/prop-types/package.json +0 -3
- package/build/internal/prop-types/prop-types.js +0 -90
- package/build/keymap/index.js +0 -54
- package/build/keymap/keymap.js +0 -201
- package/build/keymap/package.json +0 -3
- package/build/keymap/tests/keymap-specs.js +0 -75
- package/build/kind/computed.js +0 -60
- package/build/kind/kind.js +0 -266
- package/build/kind/package.json +0 -3
- package/build/kind/styles.js +0 -105
- package/build/kind/tests/computed-specs.js +0 -87
- package/build/kind/tests/kind-specs.js +0 -216
- package/build/kind/tests/styles-specs.js +0 -170
- package/build/kind/util.js +0 -17
- package/build/package-lock.json +0 -206
- package/build/package.json +0 -38
- package/build/platform/package.json +0 -3
- package/build/platform/platform.js +0 -306
- package/build/platform/tests/platform-specs.js +0 -92
- package/build/snapshot/package.json +0 -3
- package/build/snapshot/snapshot.js +0 -89
- package/build/useChainRefs/package.json +0 -3
- package/build/useChainRefs/tests/useChainRefs-specs.js +0 -57
- package/build/useChainRefs/useChainRefs.js +0 -78
- package/build/useClass/package.json +0 -3
- package/build/useClass/tests/useClass-specs.js +0 -51
- package/build/useClass/useClass.js +0 -59
- package/build/useHandlers/Handlers.js +0 -55
- package/build/useHandlers/package.json +0 -3
- package/build/useHandlers/tests/useHandlers-specs.js +0 -84
- package/build/useHandlers/useHandlers.js +0 -36
- package/build/util/Job.js +0 -211
- package/build/util/package.json +0 -3
- package/build/util/tests/Job-specs.js +0 -216
- package/build/util/tests/util-specs.js +0 -123
- package/build/util/util.js +0 -322
package/util/tests/util-specs.js
CHANGED
|
@@ -1,146 +1,123 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const actual = mapAndFilterChildren(
|
|
125
|
-
children,
|
|
126
|
-
val => val === 2 ? null : val,
|
|
127
|
-
(val) => val === 1
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
expect(actual).toEqual(expected);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
test('should forward value and index to callback', () => {
|
|
134
|
-
const spy = jest.fn();
|
|
135
|
-
mapAndFilterChildren([1], spy);
|
|
136
|
-
|
|
137
|
-
const expected = [
|
|
138
|
-
1, // value
|
|
139
|
-
0 // index
|
|
140
|
-
];
|
|
141
|
-
const actual = spy.mock.calls[0];
|
|
142
|
-
|
|
143
|
-
expect(expected).toEqual(actual);
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
});
|
|
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
|
+
});
|
|
File without changes
|
package/util/util.js
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
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
|
+
|
|
1
32
|
/**
|
|
2
33
|
* A collection of utility methods.
|
|
3
34
|
*
|
|
@@ -14,13 +45,6 @@
|
|
|
14
45
|
* @exports perfNow
|
|
15
46
|
* @exports mapAndFilterChildren
|
|
16
47
|
*/
|
|
17
|
-
import always from 'ramda/src/always';
|
|
18
|
-
import isType from 'ramda/src/is';
|
|
19
|
-
import unless from 'ramda/src/unless';
|
|
20
|
-
import React from 'react';
|
|
21
|
-
import * as ReactIs from 'react-is';
|
|
22
|
-
|
|
23
|
-
import Job from './Job';
|
|
24
48
|
|
|
25
49
|
/**
|
|
26
50
|
* Capitalizes a given string (not locale-aware).
|
|
@@ -32,10 +56,9 @@ import Job from './Job';
|
|
|
32
56
|
* @memberof core/util
|
|
33
57
|
* @public
|
|
34
58
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
59
|
+
var cap = function cap(str) {
|
|
60
|
+
return str.slice(0, 1).toUpperCase() + str.slice(1);
|
|
37
61
|
};
|
|
38
|
-
|
|
39
62
|
/**
|
|
40
63
|
* Limits `value` to be between `min` and `max`.
|
|
41
64
|
*
|
|
@@ -50,12 +73,15 @@ const cap = function (str) {
|
|
|
50
73
|
* @memberof core/util
|
|
51
74
|
* @public
|
|
52
75
|
*/
|
|
53
|
-
const clamp = (min, max, value) => {
|
|
54
|
-
if (min > max || value < min) return min;
|
|
55
|
-
if (value > max) return max;
|
|
56
|
-
return value;
|
|
57
|
-
};
|
|
58
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
|
+
};
|
|
59
85
|
/**
|
|
60
86
|
* If `arg` is a function, return it. Otherwise returns a function that returns `arg`.
|
|
61
87
|
*
|
|
@@ -71,8 +97,10 @@ const clamp = (min, max, value) => {
|
|
|
71
97
|
* @memberof core/util
|
|
72
98
|
* @public
|
|
73
99
|
*/
|
|
74
|
-
const coerceFunction = unless(isType(Function), always);
|
|
75
100
|
|
|
101
|
+
|
|
102
|
+
exports.clamp = clamp;
|
|
103
|
+
var coerceFunction = (0, _unless["default"])((0, _is["default"])(Function), _always["default"]);
|
|
76
104
|
/**
|
|
77
105
|
* If `arg` is array-like, return it. Otherwise returns a single element array containing `arg`.
|
|
78
106
|
*
|
|
@@ -90,10 +118,12 @@ const coerceFunction = unless(isType(Function), always);
|
|
|
90
118
|
* @memberof core/util
|
|
91
119
|
* @public
|
|
92
120
|
*/
|
|
93
|
-
const coerceArray = function (array) {
|
|
94
|
-
return Array.isArray(array) ? array : [array];
|
|
95
|
-
};
|
|
96
121
|
|
|
122
|
+
exports.coerceFunction = coerceFunction;
|
|
123
|
+
|
|
124
|
+
var coerceArray = function coerceArray(array) {
|
|
125
|
+
return Array.isArray(array) ? array : [array];
|
|
126
|
+
};
|
|
97
127
|
/**
|
|
98
128
|
* Loosely determines if `tag` is a renderable component (either a string or a function).
|
|
99
129
|
*
|
|
@@ -104,10 +134,13 @@ const coerceArray = function (array) {
|
|
|
104
134
|
* @memberof core/util
|
|
105
135
|
* @public
|
|
106
136
|
*/
|
|
107
|
-
const isRenderable = function (tag) {
|
|
108
|
-
return ReactIs.isValidElementType(tag);
|
|
109
|
-
};
|
|
110
137
|
|
|
138
|
+
|
|
139
|
+
exports.coerceArray = coerceArray;
|
|
140
|
+
|
|
141
|
+
var isRenderable = function isRenderable(tag) {
|
|
142
|
+
return ReactIs.isValidElementType(tag);
|
|
143
|
+
};
|
|
111
144
|
/**
|
|
112
145
|
* Removes ARIA-related props from `props` and returns them in a new object.
|
|
113
146
|
*
|
|
@@ -121,18 +154,20 @@ const isRenderable = function (tag) {
|
|
|
121
154
|
* @memberof core/util
|
|
122
155
|
* @public
|
|
123
156
|
*/
|
|
124
|
-
const extractAriaProps = function (props) {
|
|
125
|
-
const aria = {};
|
|
126
|
-
Object.keys(props).forEach(key => {
|
|
127
|
-
if (key === 'role' || key.indexOf('aria-') === 0) {
|
|
128
|
-
aria[key] = props[key];
|
|
129
|
-
delete props[key];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
return aria;
|
|
134
|
-
};
|
|
135
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
|
+
};
|
|
136
171
|
/**
|
|
137
172
|
* Gets the current timestamp of either `window.performance.now` or `Date.now`
|
|
138
173
|
*
|
|
@@ -142,14 +177,17 @@ const extractAriaProps = function (props) {
|
|
|
142
177
|
* @memberof core/util
|
|
143
178
|
* @public
|
|
144
179
|
*/
|
|
145
|
-
const perfNow = function () {
|
|
146
|
-
if (typeof window === 'object') {
|
|
147
|
-
return window.performance.now();
|
|
148
|
-
} else {
|
|
149
|
-
return Date.now();
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
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
|
+
};
|
|
153
191
|
/**
|
|
154
192
|
* Merges two class name maps into one.
|
|
155
193
|
*
|
|
@@ -179,31 +217,35 @@ const perfNow = function () {
|
|
|
179
217
|
* @memberof core/util
|
|
180
218
|
* @public
|
|
181
219
|
*/
|
|
182
|
-
const mergeClassNameMaps = (baseMap, additiveMap, allowedClassNames) => {
|
|
183
|
-
let css = baseMap;
|
|
184
|
-
if (baseMap && additiveMap) {
|
|
185
|
-
allowedClassNames = allowedClassNames || Object.keys(additiveMap);
|
|
186
|
-
// if the props includes a css map, merge them together now
|
|
187
|
-
css = Object.assign({}, baseMap);
|
|
188
|
-
allowedClassNames.forEach(key => {
|
|
189
|
-
if (baseMap[key] && additiveMap[key]) {
|
|
190
|
-
css[key] = baseMap[key] + ' ' + additiveMap[key];
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
if (process.env.NODE_ENV === 'test') {
|
|
195
|
-
return new Proxy({}, {
|
|
196
|
-
get (target, key) {
|
|
197
|
-
// use the merged value if it exists and the key otherwise
|
|
198
|
-
return css[key] || key;
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return css;
|
|
205
|
-
};
|
|
206
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
|
+
};
|
|
207
249
|
/**
|
|
208
250
|
* Creates a function that memoizes the result of `fn`.
|
|
209
251
|
*
|
|
@@ -217,20 +259,24 @@ const mergeClassNameMaps = (baseMap, additiveMap, allowedClassNames) => {
|
|
|
217
259
|
* @memberof core/util
|
|
218
260
|
* @public
|
|
219
261
|
*/
|
|
220
|
-
const memoize = (fn) => {
|
|
221
|
-
let cache = {};
|
|
222
|
-
return (...args) => {
|
|
223
|
-
let n = args[0];
|
|
224
|
-
if (n in cache) {
|
|
225
|
-
return cache[n];
|
|
226
|
-
} else {
|
|
227
|
-
let result = fn(...args);
|
|
228
|
-
cache[n] = result;
|
|
229
|
-
return result;
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
};
|
|
233
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
|
+
};
|
|
234
280
|
/**
|
|
235
281
|
* Maps over the `children`, discarding any `null` children before and after calling the callback.
|
|
236
282
|
*
|
|
@@ -249,31 +295,28 @@ const memoize = (fn) => {
|
|
|
249
295
|
* @see https://reactjs.org/docs/react-api.html#reactchildrenmap
|
|
250
296
|
* @public
|
|
251
297
|
*/
|
|
252
|
-
const mapAndFilterChildren = (children, callback, filter) => {
|
|
253
|
-
const result = React.Children.map(children, (child, ...rest) => {
|
|
254
|
-
if (child != null) {
|
|
255
|
-
return callback(child, ...rest);
|
|
256
|
-
} else {
|
|
257
|
-
return child;
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
if (result && filter) {
|
|
261
|
-
return result.filter(filter);
|
|
262
|
-
} else {
|
|
263
|
-
return result;
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
298
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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
|
+
}
|
|
279
320
|
};
|
|
321
|
+
|
|
322
|
+
exports.mapAndFilterChildren = mapAndFilterChildren;
|