@enact/core 4.5.2 → 4.5.4
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 +8 -0
- package/dispatcher/dispatcher.js +8 -27
- package/dispatcher/listeners.js +0 -8
- package/dispatcher/tests/dispatcher-specs.js +0 -3
- package/handle/handle.js +33 -90
- package/handle/tests/handle-specs.js +21 -42
- package/hoc/hoc.js +2 -13
- package/hoc/tests/hoc-specs.js +0 -23
- package/internal/ApiDecorator/ApiDecorator.js +4 -34
- package/internal/ApiDecorator/tests/ApiDecorator-specs.js +0 -24
- package/internal/Registry/Registry.js +0 -7
- package/internal/Registry/tests/Registry-specs.js +10 -70
- package/internal/deprecate/deprecate.js +8 -22
- package/internal/prop-types/prop-types.js +3 -20
- package/keymap/index.js +2 -3
- package/keymap/keymap.js +10 -18
- package/keymap/tests/keymap-specs.js +0 -3
- package/kind/computed.js +2 -9
- package/kind/kind.js +14 -53
- package/kind/styles.js +6 -19
- package/kind/tests/computed-specs.js +4 -6
- package/kind/tests/kind-specs.js +9 -44
- package/kind/tests/styles-specs.js +12 -7
- package/kind/util.js +0 -2
- package/package.json +7 -1
- package/platform/platform.js +51 -57
- package/platform/tests/platform-specs.js +2 -2
- package/snapshot/snapshot.js +4 -9
- package/useChainRefs/tests/useChainRefs-specs.js +0 -14
- package/useChainRefs/useChainRefs.js +3 -11
- package/useClass/tests/useClass-specs.js +6 -21
- package/useClass/useClass.js +0 -8
- package/useHandlers/Handlers.js +0 -11
- package/useHandlers/tests/useHandlers-specs.js +11 -23
- package/useHandlers/useHandlers.js +0 -5
- package/usePublicClassNames/tests/usePublicClassNames-specs.js +21 -28
- package/usePublicClassNames/usePublicClassNames.js +4 -10
- package/util/Job.js +1 -43
- package/util/tests/Job-specs.js +0 -14
- package/util/tests/util-specs.js +9 -10
- package/util/util.js +14 -54
|
@@ -1,71 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _react = require("react");
|
|
4
|
-
|
|
5
4
|
require("@testing-library/jest-dom");
|
|
6
|
-
|
|
7
5
|
var _react2 = require("@testing-library/react");
|
|
8
|
-
|
|
9
6
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
10
|
-
|
|
11
7
|
var _Registry = _interopRequireDefault(require("../Registry"));
|
|
12
|
-
|
|
13
8
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
-
|
|
15
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
|
-
|
|
17
10
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
-
|
|
19
11
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
|
-
|
|
21
12
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
|
-
|
|
23
13
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
24
|
-
|
|
25
14
|
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); } }
|
|
26
|
-
|
|
27
15
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
28
|
-
|
|
29
16
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
30
|
-
|
|
31
17
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
32
|
-
|
|
33
18
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
34
|
-
|
|
35
19
|
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
36
|
-
|
|
37
20
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
38
|
-
|
|
39
21
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
40
|
-
|
|
41
22
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
42
|
-
|
|
43
23
|
var SomeContext = /*#__PURE__*/(0, _react.createContext)();
|
|
44
24
|
describe('Registry', function () {
|
|
45
25
|
var NotifiesTree = /*#__PURE__*/function (_Component) {
|
|
46
26
|
_inherits(NotifiesTree, _Component);
|
|
47
|
-
|
|
48
27
|
var _super = _createSuper(NotifiesTree);
|
|
49
|
-
|
|
50
28
|
function NotifiesTree() {
|
|
51
29
|
var _this;
|
|
52
|
-
|
|
53
30
|
_classCallCheck(this, NotifiesTree);
|
|
54
|
-
|
|
55
31
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
56
32
|
args[_key] = arguments[_key];
|
|
57
33
|
}
|
|
58
|
-
|
|
59
34
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
60
35
|
_this.registry = _Registry["default"].create();
|
|
61
|
-
|
|
62
36
|
_this.handleClick = function () {
|
|
63
37
|
_this.registry.notify({});
|
|
64
38
|
};
|
|
65
|
-
|
|
66
39
|
return _this;
|
|
67
40
|
}
|
|
68
|
-
|
|
69
41
|
_createClass(NotifiesTree, [{
|
|
70
42
|
key: "componentDidMount",
|
|
71
43
|
value: function componentDidMount() {
|
|
@@ -83,31 +55,22 @@ describe('Registry', function () {
|
|
|
83
55
|
});
|
|
84
56
|
}
|
|
85
57
|
}]);
|
|
86
|
-
|
|
87
58
|
return NotifiesTree;
|
|
88
59
|
}(_react.Component);
|
|
89
|
-
|
|
90
60
|
NotifiesTree.contextType = SomeContext;
|
|
91
|
-
|
|
92
61
|
var HandlesNotification = /*#__PURE__*/function (_Component2) {
|
|
93
62
|
_inherits(HandlesNotification, _Component2);
|
|
94
|
-
|
|
95
63
|
var _super2 = _createSuper(HandlesNotification);
|
|
96
|
-
|
|
97
64
|
function HandlesNotification() {
|
|
98
65
|
var _this2;
|
|
99
|
-
|
|
100
66
|
_classCallCheck(this, HandlesNotification);
|
|
101
|
-
|
|
102
67
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
103
68
|
args[_key2] = arguments[_key2];
|
|
104
69
|
}
|
|
105
|
-
|
|
106
70
|
_this2 = _super2.call.apply(_super2, [this].concat(args));
|
|
107
71
|
_this2.state = {
|
|
108
72
|
number: 0
|
|
109
73
|
};
|
|
110
|
-
|
|
111
74
|
_this2.handleResize = function () {
|
|
112
75
|
_this2.setState(function (prevState) {
|
|
113
76
|
var number = prevState.number + 1;
|
|
@@ -116,10 +79,8 @@ describe('Registry', function () {
|
|
|
116
79
|
};
|
|
117
80
|
});
|
|
118
81
|
};
|
|
119
|
-
|
|
120
82
|
return _this2;
|
|
121
83
|
}
|
|
122
|
-
|
|
123
84
|
_createClass(HandlesNotification, [{
|
|
124
85
|
key: "componentDidMount",
|
|
125
86
|
value: function componentDidMount() {
|
|
@@ -142,10 +103,8 @@ describe('Registry', function () {
|
|
|
142
103
|
}));
|
|
143
104
|
}
|
|
144
105
|
}]);
|
|
145
|
-
|
|
146
106
|
return HandlesNotification;
|
|
147
107
|
}(_react.Component);
|
|
148
|
-
|
|
149
108
|
HandlesNotification.contextType = SomeContext;
|
|
150
109
|
test('should increment child on click', function () {
|
|
151
110
|
(0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(NotifiesTree, {
|
|
@@ -154,13 +113,9 @@ describe('Registry', function () {
|
|
|
154
113
|
"data-testid": "a"
|
|
155
114
|
})
|
|
156
115
|
}));
|
|
157
|
-
|
|
158
116
|
_userEvent["default"].click(_react2.screen.getByTestId('a-btn'));
|
|
159
|
-
|
|
160
117
|
var expected = '1';
|
|
161
|
-
|
|
162
118
|
var child = _react2.screen.getByTestId('a');
|
|
163
|
-
|
|
164
119
|
expect(child).toHaveTextContent(expected);
|
|
165
120
|
});
|
|
166
121
|
test('should increment both children on top click', function () {
|
|
@@ -175,15 +130,10 @@ describe('Registry', function () {
|
|
|
175
130
|
})
|
|
176
131
|
})]
|
|
177
132
|
}));
|
|
178
|
-
|
|
179
133
|
_userEvent["default"].click(_react2.screen.getByTestId('a-btn'));
|
|
180
|
-
|
|
181
134
|
var expected = '1';
|
|
182
|
-
|
|
183
135
|
var childA = _react2.screen.getByTestId('a');
|
|
184
|
-
|
|
185
136
|
var childB = _react2.screen.getByTestId('b');
|
|
186
|
-
|
|
187
137
|
expect(childA).toHaveTextContent(expected);
|
|
188
138
|
expect(childB).toHaveTextContent(expected);
|
|
189
139
|
});
|
|
@@ -199,46 +149,36 @@ describe('Registry', function () {
|
|
|
199
149
|
})
|
|
200
150
|
})]
|
|
201
151
|
}));
|
|
202
|
-
|
|
203
152
|
_userEvent["default"].click(_react2.screen.getByTestId('b-btn'));
|
|
204
|
-
|
|
205
153
|
var expectedA = '0';
|
|
206
154
|
var expectedB = '1';
|
|
207
|
-
|
|
208
155
|
var childA = _react2.screen.getByTestId('a');
|
|
209
|
-
|
|
210
156
|
var childB = _react2.screen.getByTestId('b');
|
|
211
|
-
|
|
212
157
|
expect(childA).toHaveTextContent(expectedA);
|
|
213
158
|
expect(childB).toHaveTextContent(expectedB);
|
|
214
159
|
});
|
|
215
160
|
test('should support removing children without error', function () {
|
|
216
161
|
var _render = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
_userEvent["default"].click(_react2.screen.getByTestId('a-btn')); // changing children should be safe and not throw errors when notifying instances
|
|
227
|
-
|
|
162
|
+
"data-testid": "a-btn",
|
|
163
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
|
|
164
|
+
"data-testid": "a"
|
|
165
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
|
|
166
|
+
"data-testid": "b"
|
|
167
|
+
})]
|
|
168
|
+
})),
|
|
169
|
+
rerender = _render.rerender;
|
|
170
|
+
_userEvent["default"].click(_react2.screen.getByTestId('a-btn'));
|
|
228
171
|
|
|
172
|
+
// changing children should be safe and not throw errors when notifying instances
|
|
229
173
|
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(NotifiesTree, {
|
|
230
174
|
"data-testid": "a-btn",
|
|
231
175
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
|
|
232
176
|
"data-testid": "c"
|
|
233
177
|
})
|
|
234
178
|
}));
|
|
235
|
-
|
|
236
179
|
_userEvent["default"].click(_react2.screen.getByTestId('a-btn'));
|
|
237
|
-
|
|
238
180
|
var expectedC = '1';
|
|
239
|
-
|
|
240
181
|
var childC = _react2.screen.getByTestId('c');
|
|
241
|
-
|
|
242
182
|
expect(childC).toHaveTextContent(expectedC);
|
|
243
183
|
});
|
|
244
184
|
});
|
|
@@ -4,63 +4,55 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.deprecate = exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Provides the `deprecate` method
|
|
10
9
|
*
|
|
11
10
|
* @module core/internal/deprecate
|
|
12
11
|
* @private
|
|
13
12
|
*/
|
|
13
|
+
|
|
14
14
|
// Utility method to format deprecate message
|
|
15
15
|
var formatMsg = function formatMsg(_ref) {
|
|
16
16
|
var message = _ref.message,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
name = _ref.name,
|
|
18
|
+
until = _ref.until,
|
|
19
|
+
replacedBy = _ref.replacedBy,
|
|
20
|
+
since = _ref.since;
|
|
21
21
|
var msg = 'DEPRECATED:';
|
|
22
|
-
|
|
23
22
|
if (name) {
|
|
24
23
|
msg += " ".concat(name);
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
if (since) {
|
|
28
26
|
msg += " since ".concat(since);
|
|
29
27
|
}
|
|
30
|
-
|
|
31
28
|
if (until) {
|
|
32
29
|
if (name || since) {
|
|
33
30
|
msg += '.';
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
msg += " Will be removed in ".concat(until);
|
|
37
33
|
}
|
|
38
|
-
|
|
39
34
|
if (replacedBy) {
|
|
40
35
|
if (name || since || until) {
|
|
41
36
|
msg += '.';
|
|
42
37
|
}
|
|
43
|
-
|
|
44
38
|
msg += " Replaced by ".concat(replacedBy);
|
|
45
39
|
}
|
|
46
|
-
|
|
47
40
|
if (name || since || until || replacedBy) {
|
|
48
41
|
msg += '.';
|
|
49
42
|
}
|
|
50
|
-
|
|
51
43
|
if (message) {
|
|
52
44
|
msg += " ".concat(message, ".");
|
|
53
45
|
}
|
|
54
|
-
|
|
55
46
|
return msg;
|
|
56
|
-
};
|
|
57
|
-
|
|
47
|
+
};
|
|
58
48
|
|
|
49
|
+
// Utility method for console warning
|
|
59
50
|
var warn = function warn(msg) {
|
|
60
51
|
if (typeof console !== 'undefined') {
|
|
61
52
|
console.warn(msg); // eslint-disable-line no-console
|
|
62
53
|
}
|
|
63
54
|
};
|
|
55
|
+
|
|
64
56
|
/**
|
|
65
57
|
* Marks a function, component or property (via `propTypes`) as deprecated. Deprecated items will
|
|
66
58
|
* log a message on first invocation. Can also be used 'stand-alone' to issue a deprecation warning.
|
|
@@ -81,8 +73,6 @@ var warn = function warn(msg) {
|
|
|
81
73
|
* @memberof core/internal/deprecate
|
|
82
74
|
* @private
|
|
83
75
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
76
|
var deprecate = function deprecate(thing, config) {
|
|
87
77
|
if (process.env.NODE_ENV !== "production") {
|
|
88
78
|
if (!config) {
|
|
@@ -92,17 +82,14 @@ var deprecate = function deprecate(thing, config) {
|
|
|
92
82
|
return thing;
|
|
93
83
|
} else {
|
|
94
84
|
var displayed, _msg;
|
|
95
|
-
|
|
96
85
|
return function () {
|
|
97
86
|
if (!displayed || config.alwaysWarn) {
|
|
98
87
|
if (!_msg) {
|
|
99
88
|
_msg = formatMsg(config);
|
|
100
89
|
}
|
|
101
|
-
|
|
102
90
|
warn(_msg);
|
|
103
91
|
displayed = true;
|
|
104
92
|
}
|
|
105
|
-
|
|
106
93
|
return thing.apply(void 0, arguments);
|
|
107
94
|
};
|
|
108
95
|
}
|
|
@@ -110,7 +97,6 @@ var deprecate = function deprecate(thing, config) {
|
|
|
110
97
|
return thing;
|
|
111
98
|
}
|
|
112
99
|
};
|
|
113
|
-
|
|
114
100
|
exports.deprecate = deprecate;
|
|
115
101
|
var _default = deprecate;
|
|
116
102
|
exports["default"] = _default;
|
|
@@ -4,63 +4,47 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
8
|
var _util = require("../../util");
|
|
11
|
-
|
|
12
9
|
var _deprecate = _interopRequireDefault(require("../deprecate"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
11
|
var isRequired = function isRequired(fn) {
|
|
17
12
|
fn.isRequired = function (props, key, componentName, location, propFullName) {
|
|
18
13
|
var propValue = props[key];
|
|
19
|
-
|
|
20
14
|
if (typeof propValue === 'undefined') {
|
|
21
15
|
return new Error("'".concat(propFullName, "' is required for '").concat(componentName, "' but was undefined."));
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
for (var _len = arguments.length, rest = new Array(_len > 5 ? _len - 5 : 0), _key = 5; _key < _len; _key++) {
|
|
25
18
|
rest[_key - 5] = arguments[_key];
|
|
26
19
|
}
|
|
27
|
-
|
|
28
20
|
return fn.apply(void 0, [propValue, key, componentName, location, propFullName].concat(rest));
|
|
29
21
|
};
|
|
30
|
-
|
|
31
22
|
return fn;
|
|
32
23
|
};
|
|
33
|
-
|
|
34
24
|
var renderable = isRequired(function (props, key, componentName) {
|
|
35
25
|
var propValue = props[key];
|
|
36
|
-
|
|
37
26
|
if (propValue && !(0, _util.isRenderable)(propValue)) {
|
|
38
27
|
return new Error("Invalid prop '".concat(key, "' supplied to '").concat(componentName, "'. ") + "Expected a renderable value but received '".concat(typeof propValue, "' instead."));
|
|
39
28
|
}
|
|
40
29
|
});
|
|
41
30
|
var component = isRequired(function (props, key, componentName) {
|
|
42
31
|
var propValue = props[key];
|
|
43
|
-
|
|
44
32
|
if (propValue && (typeof propValue === 'string' || !(0, _util.isRenderable)(propValue))) {
|
|
45
33
|
return new Error("Invalid prop '".concat(key, "' supplied to '").concat(componentName, "'. ") + "Expected a function but received '".concat(typeof propValue, "' instead."));
|
|
46
34
|
}
|
|
47
35
|
});
|
|
48
|
-
|
|
49
36
|
var renderableOverride = _propTypes["default"].oneOfType([_propTypes["default"].element, renderable]);
|
|
50
|
-
|
|
51
37
|
var componentOverride = _propTypes["default"].oneOfType([_propTypes["default"].element, component]);
|
|
52
|
-
|
|
53
38
|
var ref = _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
54
39
|
current: _propTypes["default"].any
|
|
55
40
|
}), _propTypes["default"].func]);
|
|
41
|
+
|
|
56
42
|
/*
|
|
57
43
|
* Wrap a prop type validator with a deprecation warning when the prop has a non-null value
|
|
58
44
|
*
|
|
59
45
|
* @param {Function} base Prop type validator
|
|
60
46
|
* @param {Object} config deprecatioon configuration
|
|
61
47
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
48
|
var deprecated = function deprecated(base, config) {
|
|
65
49
|
// Wrap in a no-op so deprecate only warns once
|
|
66
50
|
var warn = (0, _deprecate["default"])(function () {
|
|
@@ -68,16 +52,15 @@ var deprecated = function deprecated(base, config) {
|
|
|
68
52
|
}, config);
|
|
69
53
|
return function (props, key) {
|
|
70
54
|
// Warn on a non-null value for the prop
|
|
71
|
-
if (props[key] != null) warn();
|
|
55
|
+
if (props[key] != null) warn();
|
|
72
56
|
|
|
57
|
+
// Pass on to the prop type validator
|
|
73
58
|
for (var _len2 = arguments.length, rest = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
74
59
|
rest[_key2 - 2] = arguments[_key2];
|
|
75
60
|
}
|
|
76
|
-
|
|
77
61
|
return base.apply(void 0, [props, key].concat(rest));
|
|
78
62
|
};
|
|
79
63
|
};
|
|
80
|
-
|
|
81
64
|
var EnactPropTypes = {
|
|
82
65
|
component: component,
|
|
83
66
|
componentOverride: componentOverride,
|
package/keymap/index.js
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _keymap = require("./keymap");
|
|
8
|
-
|
|
9
7
|
Object.keys(_keymap).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _keymap[key]) return;
|
|
@@ -16,7 +14,6 @@ Object.keys(_keymap).forEach(function (key) {
|
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
16
|
});
|
|
19
|
-
|
|
20
17
|
/**
|
|
21
18
|
* Manages a map of names to key codes to simplify event handlers
|
|
22
19
|
*
|
|
@@ -40,9 +37,11 @@ Object.keys(_keymap).forEach(function (key) {
|
|
|
40
37
|
* @exports remove
|
|
41
38
|
* @exports removeAll
|
|
42
39
|
*/
|
|
40
|
+
|
|
43
41
|
// keymap uses a singleton object, map, to manage the keymap. since webpack may make multiple copies
|
|
44
42
|
// of the module available if the import path is different, we ensure a consistent import path for
|
|
45
43
|
// the singleton instance by facading it with this module.
|
|
44
|
+
|
|
46
45
|
// Add the default 5-way navigation key codes
|
|
47
46
|
(0, _keymap.addAll)({
|
|
48
47
|
enter: [13, 16777221],
|
package/keymap/keymap.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.removeAll = exports.remove = exports.is = exports.addAll = exports.add = void 0;
|
|
7
|
-
|
|
8
7
|
var _curry = _interopRequireDefault(require("ramda/src/curry"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The singleton map of names to keyCodes. If a name doesn't have any keyCodes mapped to it, it will
|
|
14
11
|
* not exist in this map. If it does, its value will be an array of its keyCodes.
|
|
@@ -17,6 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
17
14
|
* @private
|
|
18
15
|
*/
|
|
19
16
|
var map = {};
|
|
17
|
+
|
|
20
18
|
/*
|
|
21
19
|
* Safely converts keymap name to lowercase.
|
|
22
20
|
*
|
|
@@ -27,10 +25,10 @@ var map = {};
|
|
|
27
25
|
* @memberof core/keymap
|
|
28
26
|
* @private
|
|
29
27
|
*/
|
|
30
|
-
|
|
31
28
|
var toLowerCase = function toLowerCase(name) {
|
|
32
29
|
return name ? name.toLowerCase() : '';
|
|
33
30
|
};
|
|
31
|
+
|
|
34
32
|
/*
|
|
35
33
|
* Iterates over `set` and invokes `fn` with the key and value of each item.
|
|
36
34
|
*
|
|
@@ -42,13 +40,12 @@ var toLowerCase = function toLowerCase(name) {
|
|
|
42
40
|
* @memberof core/keymap
|
|
43
41
|
* @private
|
|
44
42
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
43
|
var forEachObj = (0, _curry["default"])(function (fn, set) {
|
|
48
44
|
Object.keys(set).forEach(function (name) {
|
|
49
45
|
return fn(name, set[name]);
|
|
50
46
|
});
|
|
51
47
|
});
|
|
48
|
+
|
|
52
49
|
/*
|
|
53
50
|
* Invokes `fn` with `name` and `keyCode` for each key code provided.
|
|
54
51
|
*
|
|
@@ -62,7 +59,6 @@ var forEachObj = (0, _curry["default"])(function (fn, set) {
|
|
|
62
59
|
* @memberof core/keymap
|
|
63
60
|
* @private
|
|
64
61
|
*/
|
|
65
|
-
|
|
66
62
|
var oneOrArray = (0, _curry["default"])(function (fn, name, keyCode) {
|
|
67
63
|
if (Array.isArray(keyCode)) {
|
|
68
64
|
keyCode.forEach(fn(name));
|
|
@@ -70,6 +66,7 @@ var oneOrArray = (0, _curry["default"])(function (fn, name, keyCode) {
|
|
|
70
66
|
fn(name, keyCode);
|
|
71
67
|
}
|
|
72
68
|
});
|
|
69
|
+
|
|
73
70
|
/*
|
|
74
71
|
* Adds `keyCode` to `name`.
|
|
75
72
|
*
|
|
@@ -82,13 +79,10 @@ var oneOrArray = (0, _curry["default"])(function (fn, name, keyCode) {
|
|
|
82
79
|
* @memberof core/keymap
|
|
83
80
|
* @private
|
|
84
81
|
*/
|
|
85
|
-
|
|
86
82
|
var addOne = (0, _curry["default"])(function (name, keyCode) {
|
|
87
83
|
name = toLowerCase(name);
|
|
88
|
-
|
|
89
84
|
if (name in map) {
|
|
90
85
|
var index = map[name].indexOf(keyCode);
|
|
91
|
-
|
|
92
86
|
if (index === -1) {
|
|
93
87
|
map[name].push(keyCode);
|
|
94
88
|
}
|
|
@@ -96,6 +90,7 @@ var addOne = (0, _curry["default"])(function (name, keyCode) {
|
|
|
96
90
|
map[name] = [keyCode];
|
|
97
91
|
}
|
|
98
92
|
});
|
|
93
|
+
|
|
99
94
|
/*
|
|
100
95
|
* Removes `keyCode` from `name`.
|
|
101
96
|
*
|
|
@@ -108,14 +103,11 @@ var addOne = (0, _curry["default"])(function (name, keyCode) {
|
|
|
108
103
|
* @memberof core/keymap
|
|
109
104
|
* @private
|
|
110
105
|
*/
|
|
111
|
-
|
|
112
106
|
var removeOne = (0, _curry["default"])(function (name, keyCode) {
|
|
113
107
|
name = toLowerCase(name);
|
|
114
|
-
|
|
115
108
|
if (name in map) {
|
|
116
109
|
var keys = map[name];
|
|
117
110
|
var index = keys.indexOf(keyCode);
|
|
118
|
-
|
|
119
111
|
if (index === -1) {
|
|
120
112
|
delete map[name];
|
|
121
113
|
} else {
|
|
@@ -123,6 +115,7 @@ var removeOne = (0, _curry["default"])(function (name, keyCode) {
|
|
|
123
115
|
}
|
|
124
116
|
}
|
|
125
117
|
});
|
|
118
|
+
|
|
126
119
|
/**
|
|
127
120
|
* Registers `keyCode` for `name`.
|
|
128
121
|
*
|
|
@@ -135,8 +128,8 @@ var removeOne = (0, _curry["default"])(function (name, keyCode) {
|
|
|
135
128
|
* @memberof core/keymap
|
|
136
129
|
* @public
|
|
137
130
|
*/
|
|
138
|
-
|
|
139
131
|
var add = oneOrArray(addOne);
|
|
132
|
+
|
|
140
133
|
/**
|
|
141
134
|
* Registers a set of key codes.
|
|
142
135
|
*
|
|
@@ -148,9 +141,9 @@ var add = oneOrArray(addOne);
|
|
|
148
141
|
* @memberof core/keymap
|
|
149
142
|
* @public
|
|
150
143
|
*/
|
|
151
|
-
|
|
152
144
|
exports.add = add;
|
|
153
145
|
var addAll = forEachObj(add);
|
|
146
|
+
|
|
154
147
|
/**
|
|
155
148
|
* Unregisters `keyCode` from `name`.
|
|
156
149
|
*
|
|
@@ -163,9 +156,9 @@ var addAll = forEachObj(add);
|
|
|
163
156
|
* @memberof core/keymap
|
|
164
157
|
* @public
|
|
165
158
|
*/
|
|
166
|
-
|
|
167
159
|
exports.addAll = addAll;
|
|
168
160
|
var remove = oneOrArray(removeOne);
|
|
161
|
+
|
|
169
162
|
/**
|
|
170
163
|
* Unregisters a set of key codes.
|
|
171
164
|
*
|
|
@@ -177,9 +170,9 @@ var remove = oneOrArray(removeOne);
|
|
|
177
170
|
* @memberof core/keymap
|
|
178
171
|
* @public
|
|
179
172
|
*/
|
|
180
|
-
|
|
181
173
|
exports.remove = remove;
|
|
182
174
|
var removeAll = forEachObj(remove);
|
|
175
|
+
|
|
183
176
|
/**
|
|
184
177
|
* Determines if `keyCode` is mapped to `name`.
|
|
185
178
|
*
|
|
@@ -192,7 +185,6 @@ var removeAll = forEachObj(remove);
|
|
|
192
185
|
* @memberof core/keymap
|
|
193
186
|
* @public
|
|
194
187
|
*/
|
|
195
|
-
|
|
196
188
|
exports.removeAll = removeAll;
|
|
197
189
|
var is = (0, _curry["default"])(function (name, keyCode) {
|
|
198
190
|
name = toLowerCase(name);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var keymap = _interopRequireWildcard(require("../"));
|
|
4
|
-
|
|
5
4
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
6
|
-
|
|
7
5
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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
6
|
describe('keymap', function () {
|
|
10
7
|
test('should support adding single keyCodes for a name', function () {
|
|
11
8
|
keymap.add('testEnter', 13);
|
package/kind/computed.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.computed = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Accepts an object of computed property configurations and a property object, passes the property
|
|
10
9
|
* object through each computed property handler, and merges the resulting computed properties with
|
|
@@ -32,29 +31,23 @@ exports["default"] = exports.computed = void 0;
|
|
|
32
31
|
*/
|
|
33
32
|
var computed = function computed(cfg, optProps) {
|
|
34
33
|
var keys = Object.keys(cfg);
|
|
35
|
-
|
|
36
34
|
var renderComputed = function renderComputed(props) {
|
|
37
35
|
var updated = {};
|
|
38
|
-
|
|
39
36
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
40
37
|
args[_key - 1] = arguments[_key];
|
|
41
38
|
}
|
|
42
|
-
|
|
43
39
|
for (var i = keys.length - 1; i >= 0; i--) {
|
|
44
40
|
updated[keys[i]] = cfg[keys[i]].apply(cfg, [props].concat(args));
|
|
45
41
|
}
|
|
46
|
-
|
|
47
42
|
return Object.assign(props, updated);
|
|
48
|
-
};
|
|
49
|
-
|
|
43
|
+
};
|
|
50
44
|
|
|
45
|
+
// maintain compatibility with 1.x
|
|
51
46
|
if (optProps) {
|
|
52
47
|
return renderComputed(optProps);
|
|
53
48
|
}
|
|
54
|
-
|
|
55
49
|
return renderComputed;
|
|
56
50
|
};
|
|
57
|
-
|
|
58
51
|
exports.computed = computed;
|
|
59
52
|
var _default = computed;
|
|
60
53
|
exports["default"] = _default;
|