@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
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
|
-
var _util = require("../../util");
|
|
11
|
-
|
|
12
|
-
var _deprecate = _interopRequireDefault(require("../deprecate"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
|
-
var isRequired = function isRequired(fn) {
|
|
17
|
-
fn.isRequired = function (props, key, componentName, location, propFullName) {
|
|
18
|
-
var propValue = props[key];
|
|
19
|
-
|
|
20
|
-
if (typeof propValue === 'undefined') {
|
|
21
|
-
return new Error("'".concat(propFullName, "' is required for '").concat(componentName, "' but was undefined."));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
for (var _len = arguments.length, rest = new Array(_len > 5 ? _len - 5 : 0), _key = 5; _key < _len; _key++) {
|
|
25
|
-
rest[_key - 5] = arguments[_key];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return fn.apply(void 0, [propValue, key, componentName, location, propFullName].concat(rest));
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return fn;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
var renderable = isRequired(function (props, key, componentName) {
|
|
35
|
-
var propValue = props[key];
|
|
36
|
-
|
|
37
|
-
if (propValue && !(0, _util.isRenderable)(propValue)) {
|
|
38
|
-
return new Error("Invalid prop '".concat(key, "' supplied to '").concat(componentName, "'. ") + "Expected a renderable value but received '".concat(typeof propValue, "' instead."));
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
var component = isRequired(function (props, key, componentName) {
|
|
42
|
-
var propValue = props[key];
|
|
43
|
-
|
|
44
|
-
if (propValue && (typeof propValue === 'string' || !(0, _util.isRenderable)(propValue))) {
|
|
45
|
-
return new Error("Invalid prop '".concat(key, "' supplied to '").concat(componentName, "'. ") + "Expected a function but received '".concat(typeof propValue, "' instead."));
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
var renderableOverride = _propTypes["default"].oneOfType([_propTypes["default"].element, renderable]);
|
|
50
|
-
|
|
51
|
-
var componentOverride = _propTypes["default"].oneOfType([_propTypes["default"].element, component]);
|
|
52
|
-
|
|
53
|
-
var ref = _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
54
|
-
current: _propTypes["default"].any
|
|
55
|
-
}), _propTypes["default"].func]);
|
|
56
|
-
/*
|
|
57
|
-
* Wrap a prop type validator with a deprecation warning when the prop has a non-null value
|
|
58
|
-
*
|
|
59
|
-
* @param {Function} base Prop type validator
|
|
60
|
-
* @param {Object} config deprecatioon configuration
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var deprecated = function deprecated(base, config) {
|
|
65
|
-
// Wrap in a no-op so deprecate only warns once
|
|
66
|
-
var warn = (0, _deprecate["default"])(function () {
|
|
67
|
-
return true;
|
|
68
|
-
}, config);
|
|
69
|
-
return function (props, key) {
|
|
70
|
-
// Warn on a non-null value for the prop
|
|
71
|
-
if (props[key] != null) warn(); // Pass on to the prop type validator
|
|
72
|
-
|
|
73
|
-
for (var _len2 = arguments.length, rest = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
74
|
-
rest[_key2 - 2] = arguments[_key2];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return base.apply(void 0, [props, key].concat(rest));
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
var EnactPropTypes = {
|
|
82
|
-
component: component,
|
|
83
|
-
componentOverride: componentOverride,
|
|
84
|
-
ref: ref,
|
|
85
|
-
deprecated: deprecated,
|
|
86
|
-
renderable: renderable,
|
|
87
|
-
renderableOverride: renderableOverride
|
|
88
|
-
};
|
|
89
|
-
var _default = EnactPropTypes;
|
|
90
|
-
exports["default"] = _default;
|
package/build/keymap/index.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _keymap = require("./keymap");
|
|
8
|
-
|
|
9
|
-
Object.keys(_keymap).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
Object.defineProperty(exports, key, {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function get() {
|
|
14
|
-
return _keymap[key];
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Manages a map of names to key codes to simplify event handlers
|
|
21
|
-
*
|
|
22
|
-
* Example:
|
|
23
|
-
* ```
|
|
24
|
-
* import {add, is} from '@enact/core/keymap';
|
|
25
|
-
*
|
|
26
|
-
* add('enter', 13);
|
|
27
|
-
* const isEnter = is('enter');
|
|
28
|
-
*
|
|
29
|
-
* // within event handler
|
|
30
|
-
* if (isEnter(ev.keyCode)) {
|
|
31
|
-
* // handle enter
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* @module core/keymap
|
|
36
|
-
* @exports add
|
|
37
|
-
* @exports addAll
|
|
38
|
-
* @exports is
|
|
39
|
-
* @exports remove
|
|
40
|
-
* @exports removeAll
|
|
41
|
-
*/
|
|
42
|
-
// keymap uses a singleton object, map, to manage the keymap. since webpack may make multiple copies
|
|
43
|
-
// of the module available if the import path is different, we ensure a consistent import path for
|
|
44
|
-
// the singleton instance by facading it with this module.
|
|
45
|
-
// Add the default 5-way navigation key codes
|
|
46
|
-
(0, _keymap.addAll)({
|
|
47
|
-
enter: [13, 16777221],
|
|
48
|
-
left: 37,
|
|
49
|
-
up: 38,
|
|
50
|
-
right: 39,
|
|
51
|
-
down: 40,
|
|
52
|
-
pageUp: 33,
|
|
53
|
-
pageDown: 34
|
|
54
|
-
});
|
package/build/keymap/keymap.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.removeAll = exports.remove = exports.is = exports.addAll = exports.add = void 0;
|
|
7
|
-
|
|
8
|
-
var _curry = _interopRequireDefault(require("ramda/src/curry"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* The singleton map of names to keyCodes. If a name doesn't have any keyCodes mapped to it, it will
|
|
14
|
-
* not exist in this map. If it does, its value will be an array of its keyCodes.
|
|
15
|
-
*
|
|
16
|
-
* @type {Object}
|
|
17
|
-
* @private
|
|
18
|
-
*/
|
|
19
|
-
var map = {};
|
|
20
|
-
/*
|
|
21
|
-
* Safely converts keymap name to lowercase.
|
|
22
|
-
*
|
|
23
|
-
* @function
|
|
24
|
-
* @param {String} name Name for keyCode
|
|
25
|
-
*
|
|
26
|
-
* @returns {String} Name for keyCode in lowercase
|
|
27
|
-
* @memberof core/keymap
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
var toLowerCase = function toLowerCase(name) {
|
|
32
|
-
return name ? name.toLowerCase() : '';
|
|
33
|
-
};
|
|
34
|
-
/*
|
|
35
|
-
* Iterates over `set` and invokes `fn` with the key and value of each item.
|
|
36
|
-
*
|
|
37
|
-
* @function
|
|
38
|
-
* @param {Function} fn Function to invoke
|
|
39
|
-
* @param {Object} set A map of names to keyCodes
|
|
40
|
-
*
|
|
41
|
-
* @returns {undefined}
|
|
42
|
-
* @memberof core/keymap
|
|
43
|
-
* @private
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var forEachObj = (0, _curry["default"])(function (fn, set) {
|
|
48
|
-
Object.keys(set).forEach(function (name) {
|
|
49
|
-
return fn(name, set[name]);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
/*
|
|
53
|
-
* Invokes `fn` with `name` and `keyCode` for each key code provided.
|
|
54
|
-
*
|
|
55
|
-
* @function
|
|
56
|
-
* @param {Function} fn Function to invoke
|
|
57
|
-
* @param {String} name Name for the key codes
|
|
58
|
-
* @param {Number|Number[]} keyCode A key code or array of key codes
|
|
59
|
-
*
|
|
60
|
-
* @returns {undefined}
|
|
61
|
-
* @curried
|
|
62
|
-
* @memberof core/keymap
|
|
63
|
-
* @private
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
var oneOrArray = (0, _curry["default"])(function (fn, name, keyCode) {
|
|
67
|
-
if (Array.isArray(keyCode)) {
|
|
68
|
-
keyCode.forEach(fn(name));
|
|
69
|
-
} else {
|
|
70
|
-
fn(name, keyCode);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
/*
|
|
74
|
-
* Adds `keyCode` to `name`.
|
|
75
|
-
*
|
|
76
|
-
* @function
|
|
77
|
-
* @param {String} name Name for the key code
|
|
78
|
-
* @param {Number} keyCode A key code
|
|
79
|
-
*
|
|
80
|
-
* @returns {undefined}
|
|
81
|
-
* @curried
|
|
82
|
-
* @memberof core/keymap
|
|
83
|
-
* @private
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
var addOne = (0, _curry["default"])(function (name, keyCode) {
|
|
87
|
-
name = toLowerCase(name);
|
|
88
|
-
|
|
89
|
-
if (name in map) {
|
|
90
|
-
var index = map[name].indexOf(keyCode);
|
|
91
|
-
|
|
92
|
-
if (index === -1) {
|
|
93
|
-
map[name].push(keyCode);
|
|
94
|
-
}
|
|
95
|
-
} else if (name) {
|
|
96
|
-
map[name] = [keyCode];
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
/*
|
|
100
|
-
* Removes `keyCode` from `name`.
|
|
101
|
-
*
|
|
102
|
-
* @function
|
|
103
|
-
* @param {String} name Name for the key code
|
|
104
|
-
* @param {Number} keyCode A key code
|
|
105
|
-
*
|
|
106
|
-
* @returns {undefined}
|
|
107
|
-
* @curried
|
|
108
|
-
* @memberof core/keymap
|
|
109
|
-
* @private
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
var removeOne = (0, _curry["default"])(function (name, keyCode) {
|
|
113
|
-
name = toLowerCase(name);
|
|
114
|
-
|
|
115
|
-
if (name in map) {
|
|
116
|
-
var keys = map[name];
|
|
117
|
-
var index = keys.indexOf(keyCode);
|
|
118
|
-
|
|
119
|
-
if (index === -1) {
|
|
120
|
-
delete map[name];
|
|
121
|
-
} else {
|
|
122
|
-
keys.splice(index, 1);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
/**
|
|
127
|
-
* Registers `keyCode` for `name`.
|
|
128
|
-
*
|
|
129
|
-
* @function add
|
|
130
|
-
* @param {String} name Name for the key code
|
|
131
|
-
* @param {Number|Number[]} keyCode A key code or array of key codes
|
|
132
|
-
*
|
|
133
|
-
* @returns {undefined}
|
|
134
|
-
* @curried
|
|
135
|
-
* @memberof core/keymap
|
|
136
|
-
* @public
|
|
137
|
-
*/
|
|
138
|
-
|
|
139
|
-
var add = oneOrArray(addOne);
|
|
140
|
-
/**
|
|
141
|
-
* Registers a set of key codes.
|
|
142
|
-
*
|
|
143
|
-
* @function addAll
|
|
144
|
-
* @param {Object<String,Number|Number[]>} set A map of names to keyCodes
|
|
145
|
-
*
|
|
146
|
-
* @returns {undefined}
|
|
147
|
-
* @curried
|
|
148
|
-
* @memberof core/keymap
|
|
149
|
-
* @public
|
|
150
|
-
*/
|
|
151
|
-
|
|
152
|
-
exports.add = add;
|
|
153
|
-
var addAll = forEachObj(add);
|
|
154
|
-
/**
|
|
155
|
-
* Unregisters `keyCode` from `name`.
|
|
156
|
-
*
|
|
157
|
-
* @function remove
|
|
158
|
-
* @param {String} name Name for the key code
|
|
159
|
-
* @param {Number|Number[]} keyCode A key code or array of key codes
|
|
160
|
-
*
|
|
161
|
-
* @returns {undefined}
|
|
162
|
-
* @curried
|
|
163
|
-
* @memberof core/keymap
|
|
164
|
-
* @public
|
|
165
|
-
*/
|
|
166
|
-
|
|
167
|
-
exports.addAll = addAll;
|
|
168
|
-
var remove = oneOrArray(removeOne);
|
|
169
|
-
/**
|
|
170
|
-
* Unregisters a set of key codes.
|
|
171
|
-
*
|
|
172
|
-
* @function removeAll
|
|
173
|
-
* @param {Object} set A map of names to keyCodes
|
|
174
|
-
*
|
|
175
|
-
* @returns {undefined}
|
|
176
|
-
* @curried
|
|
177
|
-
* @memberof core/keymap
|
|
178
|
-
* @public
|
|
179
|
-
*/
|
|
180
|
-
|
|
181
|
-
exports.remove = remove;
|
|
182
|
-
var removeAll = forEachObj(remove);
|
|
183
|
-
/**
|
|
184
|
-
* Determines if `keyCode` is mapped to `name`.
|
|
185
|
-
*
|
|
186
|
-
* @function is
|
|
187
|
-
* @param {String} name Name for the key code
|
|
188
|
-
* @param {Number} keyCode A key code
|
|
189
|
-
*
|
|
190
|
-
* @returns {Boolean} `true` if `keyCode` is mapped to `name`
|
|
191
|
-
* @curried
|
|
192
|
-
* @memberof core/keymap
|
|
193
|
-
* @public
|
|
194
|
-
*/
|
|
195
|
-
|
|
196
|
-
exports.removeAll = removeAll;
|
|
197
|
-
var is = (0, _curry["default"])(function (name, keyCode) {
|
|
198
|
-
name = toLowerCase(name);
|
|
199
|
-
return name in map && map[name].indexOf(keyCode) >= 0;
|
|
200
|
-
});
|
|
201
|
-
exports.is = is;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var keymap = _interopRequireWildcard(require("../"));
|
|
4
|
-
|
|
5
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
6
|
-
|
|
7
|
-
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; }
|
|
8
|
-
|
|
9
|
-
describe('keymap', function () {
|
|
10
|
-
test('should support adding single keyCodes for a name', function () {
|
|
11
|
-
keymap.add('testEnter', 13);
|
|
12
|
-
var expected = true;
|
|
13
|
-
var actual = keymap.is('testEnter', 13);
|
|
14
|
-
keymap.remove('testEnter', 13);
|
|
15
|
-
expect(actual).toBe(expected);
|
|
16
|
-
});
|
|
17
|
-
test('should support removing a single keyCode for a name', function () {
|
|
18
|
-
keymap.add('testEnter', 13);
|
|
19
|
-
keymap.remove('testEnter', 13);
|
|
20
|
-
var expected = false;
|
|
21
|
-
var actual = keymap.is('testEnter', 13);
|
|
22
|
-
expect(actual).toBe(expected);
|
|
23
|
-
});
|
|
24
|
-
test('should support adding an array of keyCodes for a name', function () {
|
|
25
|
-
keymap.add('testEnter', [13, 16777221]);
|
|
26
|
-
var expected = true;
|
|
27
|
-
var actual = keymap.is('testEnter', 13) && keymap.is('testEnter', 16777221);
|
|
28
|
-
keymap.remove('testEnter', [13, 16777221]);
|
|
29
|
-
expect(actual).toBe(expected);
|
|
30
|
-
});
|
|
31
|
-
test('should support removing an array of keyCodes for a name', function () {
|
|
32
|
-
keymap.add('testEnter', [13, 16777221]);
|
|
33
|
-
keymap.remove('testEnter', [13, 16777221]);
|
|
34
|
-
var expected = false;
|
|
35
|
-
var actual = keymap.is('testEnter', 13) || keymap.is('testEnter', 16777221);
|
|
36
|
-
expect(actual).toBe(expected);
|
|
37
|
-
});
|
|
38
|
-
test('should support adding an map of keyCodes', function () {
|
|
39
|
-
var map = {
|
|
40
|
-
testEnter: [13, 16777221],
|
|
41
|
-
testUp: 38,
|
|
42
|
-
testDown: 40
|
|
43
|
-
};
|
|
44
|
-
keymap.addAll(map);
|
|
45
|
-
var expected = true;
|
|
46
|
-
var actual = keymap.is('testEnter', 13) && keymap.is('testEnter', 16777221) && keymap.is('testUp', 38) && keymap.is('testDown', 40);
|
|
47
|
-
keymap.removeAll(map);
|
|
48
|
-
expect(actual).toBe(expected);
|
|
49
|
-
});
|
|
50
|
-
test('should removing an map of keyCodes', function () {
|
|
51
|
-
var map = {
|
|
52
|
-
testEnter: [13, 16777221],
|
|
53
|
-
testUp: 38,
|
|
54
|
-
testDown: 40
|
|
55
|
-
};
|
|
56
|
-
keymap.addAll(map);
|
|
57
|
-
keymap.removeAll(map);
|
|
58
|
-
var expected = false;
|
|
59
|
-
var actual = keymap.is('testEnter', 13) || keymap.is('testEnter', 16777221) || keymap.is('testUp', 38) || keymap.is('testDown', 40);
|
|
60
|
-
expect(actual).toBe(expected);
|
|
61
|
-
});
|
|
62
|
-
test('should use case-insensitive names', function () {
|
|
63
|
-
keymap.add('testEnter', 13);
|
|
64
|
-
var expected = true;
|
|
65
|
-
var actual = keymap.is('TeStEnTeR', 13);
|
|
66
|
-
keymap.remove('testEnter', 13);
|
|
67
|
-
expect(actual).toBe(expected);
|
|
68
|
-
});
|
|
69
|
-
test('should not add entry with a falsy name', function () {
|
|
70
|
-
keymap.add('', 13);
|
|
71
|
-
var expected = false;
|
|
72
|
-
var actual = keymap.is('', 13);
|
|
73
|
-
expect(actual).toBe(expected);
|
|
74
|
-
});
|
|
75
|
-
});
|
package/build/kind/computed.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.computed = exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Accepts an object of computed property configurations and a property object, passes the property
|
|
10
|
-
* object through each computed property handler, and merges the resulting computed properties with
|
|
11
|
-
* the original properties.
|
|
12
|
-
*
|
|
13
|
-
* ```
|
|
14
|
-
* const cfg = {
|
|
15
|
-
* sum: ({x,y,z}) => x+y+z,
|
|
16
|
-
* product: ({x,y,z}) => x*y*z
|
|
17
|
-
* }
|
|
18
|
-
* const props = {
|
|
19
|
-
* x: 2,
|
|
20
|
-
* y: 3,
|
|
21
|
-
* z: 4
|
|
22
|
-
* }
|
|
23
|
-
* computed(cfg)(props) // => {x: 2, y: 3, z: 4, sum: 9, product: 24}
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @method computed
|
|
27
|
-
* @param {Object} cfg Configuration object mapping transformation functions to property names
|
|
28
|
-
*
|
|
29
|
-
* @returns {Function} Function that accepts a props object and mutates it to include the
|
|
30
|
-
* computed props
|
|
31
|
-
* @private
|
|
32
|
-
*/
|
|
33
|
-
var computed = function computed(cfg, optProps) {
|
|
34
|
-
var keys = Object.keys(cfg);
|
|
35
|
-
|
|
36
|
-
var renderComputed = function renderComputed(props) {
|
|
37
|
-
var updated = {};
|
|
38
|
-
|
|
39
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
40
|
-
args[_key - 1] = arguments[_key];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
for (var i = keys.length - 1; i >= 0; i--) {
|
|
44
|
-
updated[keys[i]] = cfg[keys[i]].apply(cfg, [props].concat(args));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return Object.assign(props, updated);
|
|
48
|
-
}; // maintain compatibility with 1.x
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (optProps) {
|
|
52
|
-
return renderComputed(optProps);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return renderComputed;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
exports.computed = computed;
|
|
59
|
-
var _default = computed;
|
|
60
|
-
exports["default"] = _default;
|