@enact/core 4.5.1 → 4.5.3
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/package.json +3 -0
- package/usePublicClassNames/tests/usePublicClassNames-specs.js +66 -0
- package/usePublicClassNames/usePublicClassNames.d.ts +0 -0
- package/usePublicClassNames/usePublicClassNames.js +44 -0
- 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
package/kind/kind.js
CHANGED
|
@@ -4,49 +4,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.kind = exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _useHandlers = _interopRequireDefault(require("../useHandlers"));
|
|
11
|
-
|
|
12
9
|
var _Handlers = _interopRequireDefault(require("../useHandlers/Handlers"));
|
|
13
|
-
|
|
14
10
|
var _computed = _interopRequireDefault(require("./computed"));
|
|
15
|
-
|
|
16
11
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
13
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
-
|
|
22
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); } }
|
|
23
|
-
|
|
24
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; }
|
|
25
|
-
|
|
26
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); }
|
|
27
|
-
|
|
28
17
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
29
|
-
|
|
30
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); }; }
|
|
31
|
-
|
|
32
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); }
|
|
33
|
-
|
|
34
20
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
35
|
-
|
|
36
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; } }
|
|
37
|
-
|
|
38
22
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
|
-
|
|
40
23
|
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; }
|
|
41
|
-
|
|
42
24
|
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; }
|
|
43
|
-
|
|
44
25
|
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; }
|
|
45
|
-
|
|
46
26
|
// Because contextType is optional and hooks must be called in the same order, we need a fallback
|
|
47
27
|
// context when none is specified. This likely has some overhead so we may want to deprecate and
|
|
48
28
|
// remove contextType support for 4.0 since the context APIs have improved since this was added.
|
|
49
29
|
var NoContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
30
|
+
|
|
50
31
|
/**
|
|
51
32
|
* @callback RenderFunction
|
|
52
33
|
* @memberof core/kind
|
|
@@ -154,83 +135,68 @@ var NoContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
|
154
135
|
* @see {@link core/handle}
|
|
155
136
|
* @public
|
|
156
137
|
*/
|
|
157
|
-
|
|
158
138
|
var kind = function kind(config) {
|
|
159
139
|
var cfgComputed = config.computed,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
140
|
+
_config$contextType = config.contextType,
|
|
141
|
+
contextType = _config$contextType === void 0 ? NoContext : _config$contextType,
|
|
142
|
+
defaultProps = config.defaultProps,
|
|
143
|
+
functional = config.functional,
|
|
144
|
+
handlers = config.handlers,
|
|
145
|
+
name = config.name,
|
|
146
|
+
propTypes = config.propTypes,
|
|
147
|
+
render = config.render,
|
|
148
|
+
cfgStyles = config.styles;
|
|
169
149
|
var renderStyles = cfgStyles ? (0, _styles["default"])(cfgStyles) : false;
|
|
170
150
|
var renderComputed = cfgComputed ? (0, _computed["default"])(cfgComputed) : false;
|
|
171
|
-
|
|
172
151
|
var renderKind = function renderKind(props, context) {
|
|
173
152
|
if (renderStyles) props = renderStyles(props, context);
|
|
174
153
|
if (renderComputed) props = renderComputed(props, context);
|
|
175
154
|
return render(props, context);
|
|
176
155
|
};
|
|
156
|
+
var Component;
|
|
177
157
|
|
|
178
|
-
|
|
158
|
+
// In 4.x, this branch will become the only supported version and the class branch will be
|
|
179
159
|
// removed.
|
|
180
|
-
|
|
181
160
|
if (functional) {
|
|
182
161
|
Component = function Component(props) {
|
|
183
162
|
var ctx = (0, _react.useContext)(contextType);
|
|
184
163
|
var boundHandlers = (0, _useHandlers["default"])(handlers, props, ctx);
|
|
185
|
-
|
|
186
164
|
var merged = _objectSpread(_objectSpread({}, props), boundHandlers);
|
|
187
|
-
|
|
188
165
|
return renderKind(merged, ctx);
|
|
189
166
|
};
|
|
190
167
|
} else {
|
|
191
168
|
var _class;
|
|
192
|
-
|
|
193
169
|
Component = (_class = /*#__PURE__*/function (_ReactComponent) {
|
|
194
170
|
_inherits(Component, _ReactComponent);
|
|
195
|
-
|
|
196
171
|
var _super = _createSuper(Component);
|
|
197
|
-
|
|
198
172
|
function Component() {
|
|
199
173
|
var _this;
|
|
200
|
-
|
|
201
174
|
_classCallCheck(this, Component);
|
|
202
|
-
|
|
203
175
|
_this = _super.call(this);
|
|
204
176
|
_this.handlers = new _Handlers["default"](handlers);
|
|
205
177
|
return _this;
|
|
206
178
|
}
|
|
207
|
-
|
|
208
179
|
_createClass(Component, [{
|
|
209
180
|
key: "render",
|
|
210
181
|
value: function render() {
|
|
211
182
|
this.handlers.setContext(this.props, this.context);
|
|
212
|
-
|
|
213
183
|
var merged = _objectSpread(_objectSpread({}, this.props), this.handlers.handlers);
|
|
214
|
-
|
|
215
184
|
return renderKind(merged, this.context);
|
|
216
185
|
}
|
|
217
186
|
}]);
|
|
218
|
-
|
|
219
187
|
return Component;
|
|
220
188
|
}(_react.Component), _class.contextType = contextType, _class);
|
|
221
189
|
}
|
|
222
|
-
|
|
223
190
|
if (name) Component.displayName = name;
|
|
224
191
|
if (propTypes) Component.propTypes = propTypes;
|
|
225
|
-
if (defaultProps) Component.defaultProps = defaultProps;
|
|
192
|
+
if (defaultProps) Component.defaultProps = defaultProps;
|
|
226
193
|
|
|
194
|
+
// Decorate the Component with the computed property object in DEV for easier testability
|
|
227
195
|
if (process.env.NODE_ENV !== "production" && cfgComputed) Component.computed = cfgComputed;
|
|
228
196
|
var defaultPropKeys = defaultProps ? Object.keys(defaultProps) : null;
|
|
229
197
|
var handlerKeys = handlers ? Object.keys(handlers) : null;
|
|
230
|
-
|
|
231
198
|
Component.inline = function (props, context) {
|
|
232
199
|
var updated = _objectSpread({}, props);
|
|
233
|
-
|
|
234
200
|
if (defaultPropKeys && defaultPropKeys.length > 0) {
|
|
235
201
|
defaultPropKeys.forEach(function (key) {
|
|
236
202
|
// eslint-disable-next-line no-undefined
|
|
@@ -239,7 +205,6 @@ var kind = function kind(config) {
|
|
|
239
205
|
}
|
|
240
206
|
});
|
|
241
207
|
}
|
|
242
|
-
|
|
243
208
|
if (handlerKeys && handlerKeys.length > 0) {
|
|
244
209
|
// generate a handler with a clone of updated to ensure each handler receives the same
|
|
245
210
|
// props without the kind.handlers injected.
|
|
@@ -247,17 +212,13 @@ var kind = function kind(config) {
|
|
|
247
212
|
_props[key] = function (ev) {
|
|
248
213
|
return handlers[key](ev, updated, context);
|
|
249
214
|
};
|
|
250
|
-
|
|
251
215
|
return _props;
|
|
252
216
|
}, _objectSpread({}, updated));
|
|
253
217
|
}
|
|
254
|
-
|
|
255
218
|
return renderKind(updated, context);
|
|
256
219
|
};
|
|
257
|
-
|
|
258
220
|
return Component;
|
|
259
221
|
};
|
|
260
|
-
|
|
261
222
|
exports.kind = kind;
|
|
262
223
|
var _default = kind;
|
|
263
224
|
exports["default"] = _default;
|
package/kind/styles.js
CHANGED
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.styles = exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _bind = _interopRequireDefault(require("classnames/bind"));
|
|
9
|
-
|
|
10
8
|
var _util = require("../util");
|
|
11
|
-
|
|
12
9
|
var _util2 = require("./util");
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* Merges external and internal CSS classes and style objects. Internal CSS classes can be
|
|
18
13
|
* optionally mapped to alternate names (e.g. those generated by CSS modules) by including a
|
|
@@ -53,30 +48,26 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
53
48
|
*/
|
|
54
49
|
var styles = function styles(cfg, optProps) {
|
|
55
50
|
var className = cfg.className,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
configCss = cfg.css,
|
|
52
|
+
_cfg$prop = cfg.prop,
|
|
53
|
+
prop = _cfg$prop === void 0 ? 'className' : _cfg$prop,
|
|
54
|
+
style = cfg.style;
|
|
60
55
|
var allowedClassNames = cfg.publicClassNames;
|
|
61
|
-
|
|
62
56
|
if (configCss && allowedClassNames === true) {
|
|
63
57
|
allowedClassNames = Object.keys(configCss);
|
|
64
58
|
} else if (typeof allowedClassNames === 'string') {
|
|
65
59
|
allowedClassNames = allowedClassNames.split(/\s+/);
|
|
66
60
|
}
|
|
67
|
-
|
|
68
61
|
var renderStyles = function renderStyles(props) {
|
|
69
62
|
var css = configCss;
|
|
70
|
-
|
|
71
63
|
if (style) {
|
|
72
64
|
props.style = Object.assign({}, style, props.style);
|
|
73
|
-
}
|
|
74
|
-
|
|
65
|
+
}
|
|
75
66
|
|
|
67
|
+
// if the props includes a css map, merge them together now
|
|
76
68
|
if (css && allowedClassNames && props.css) {
|
|
77
69
|
css = (0, _util.mergeClassNameMaps)(css, props.css, allowedClassNames);
|
|
78
70
|
}
|
|
79
|
-
|
|
80
71
|
var cn = css ? _bind["default"].bind(css) : _bind["default"];
|
|
81
72
|
var joinedClassName = props[prop] = (0, _bind["default"])(className ? cn(className.split(' ')) : null, props.className);
|
|
82
73
|
(0, _util2.addInternalProp)(props, 'css', css);
|
|
@@ -86,20 +77,16 @@ var styles = function styles(cfg, optProps) {
|
|
|
86
77
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
87
78
|
args[_key] = arguments[_key];
|
|
88
79
|
}
|
|
89
|
-
|
|
90
80
|
return cn.apply(void 0, [joinedClassName].concat(args));
|
|
91
81
|
}
|
|
92
82
|
});
|
|
93
83
|
return props;
|
|
94
84
|
};
|
|
95
|
-
|
|
96
85
|
if (optProps) {
|
|
97
86
|
return renderStyles(optProps);
|
|
98
87
|
}
|
|
99
|
-
|
|
100
88
|
return renderStyles;
|
|
101
89
|
};
|
|
102
|
-
|
|
103
90
|
exports.styles = styles;
|
|
104
91
|
var _default = styles;
|
|
105
92
|
exports["default"] = _default;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _computed = _interopRequireDefault(require("../computed"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
|
-
|
|
7
5
|
describe('computed', function () {
|
|
8
6
|
var exampleCfg = {
|
|
9
7
|
sum: function sum(_ref) {
|
|
10
8
|
var x = _ref.x,
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
y = _ref.y,
|
|
10
|
+
z = _ref.z;
|
|
13
11
|
return x + y + z;
|
|
14
12
|
},
|
|
15
13
|
product: function product(_ref2) {
|
|
16
14
|
var x = _ref2.x,
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
y = _ref2.y,
|
|
16
|
+
z = _ref2.z;
|
|
19
17
|
return x * y * z;
|
|
20
18
|
}
|
|
21
19
|
};
|
package/kind/tests/kind-specs.js
CHANGED
|
@@ -1,45 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("@testing-library/jest-dom");
|
|
4
|
-
|
|
5
4
|
var _react = require("@testing-library/react");
|
|
6
|
-
|
|
7
5
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
8
|
-
|
|
9
6
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
-
|
|
11
7
|
var _react2 = require("react");
|
|
12
|
-
|
|
13
8
|
var _kind = _interopRequireDefault(require("../kind"));
|
|
14
|
-
|
|
15
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
-
|
|
17
10
|
var _excluded = ["contextValue", "label", "value"];
|
|
18
|
-
|
|
19
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
20
|
-
|
|
21
12
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
22
|
-
|
|
23
13
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
24
|
-
|
|
25
14
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
26
|
-
|
|
27
15
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
28
|
-
|
|
29
16
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
30
|
-
|
|
31
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
32
|
-
|
|
33
18
|
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; }
|
|
34
|
-
|
|
35
19
|
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; }
|
|
36
|
-
|
|
37
20
|
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; }
|
|
38
|
-
|
|
39
21
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
40
|
-
|
|
41
22
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
42
|
-
|
|
43
23
|
describe('kind', function () {
|
|
44
24
|
var TestContext = /*#__PURE__*/(0, _react2.createContext)({
|
|
45
25
|
value: 'initial'
|
|
@@ -73,10 +53,9 @@ describe('kind', function () {
|
|
|
73
53
|
},
|
|
74
54
|
render: function render(_ref2) {
|
|
75
55
|
var contextValue = _ref2.contextValue,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
56
|
+
label = _ref2.label,
|
|
57
|
+
value = _ref2.value,
|
|
58
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
80
59
|
delete rest.prop;
|
|
81
60
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
|
|
82
61
|
"data-context": contextValue,
|
|
@@ -100,9 +79,7 @@ describe('kind', function () {
|
|
|
100
79
|
}
|
|
101
80
|
});
|
|
102
81
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Minimal, {}));
|
|
103
|
-
|
|
104
82
|
var minimalDiv = _react.screen.queryByTestId('minimal');
|
|
105
|
-
|
|
106
83
|
expect(minimalDiv).toBeInTheDocument();
|
|
107
84
|
});
|
|
108
85
|
test('should default {label} property', function () {
|
|
@@ -129,9 +106,7 @@ describe('kind', function () {
|
|
|
129
106
|
prop: 1
|
|
130
107
|
}));
|
|
131
108
|
var expected = 'kind';
|
|
132
|
-
|
|
133
109
|
var kindDiv = _react.screen.getByTitle('Label');
|
|
134
|
-
|
|
135
110
|
expect(kindDiv).toHaveClass(expected);
|
|
136
111
|
});
|
|
137
112
|
test('should compute {value} property', function () {
|
|
@@ -139,9 +114,7 @@ describe('kind', function () {
|
|
|
139
114
|
prop: 1
|
|
140
115
|
}));
|
|
141
116
|
var expected = '2';
|
|
142
|
-
|
|
143
117
|
var kindDiv = _react.screen.getByTitle('Label');
|
|
144
|
-
|
|
145
118
|
expect(kindDiv).toHaveTextContent(expected);
|
|
146
119
|
});
|
|
147
120
|
test('should support contextType in handlers', function () {
|
|
@@ -150,11 +123,8 @@ describe('kind', function () {
|
|
|
150
123
|
onClick: onClick,
|
|
151
124
|
prop: 1
|
|
152
125
|
}));
|
|
153
|
-
|
|
154
126
|
var kindDiv = _react.screen.getByTitle('Label');
|
|
155
|
-
|
|
156
127
|
_userEvent["default"].click(kindDiv);
|
|
157
|
-
|
|
158
128
|
var expected = 'initial';
|
|
159
129
|
var actual = onClick.mock.calls[0][0];
|
|
160
130
|
expect(actual).toBe(expected);
|
|
@@ -164,9 +134,7 @@ describe('kind', function () {
|
|
|
164
134
|
prop: 1
|
|
165
135
|
}));
|
|
166
136
|
var expected = 'contextinitial';
|
|
167
|
-
|
|
168
137
|
var kindDiv = _react.screen.getByTitle('Label');
|
|
169
|
-
|
|
170
138
|
expect(kindDiv).toHaveAttribute('data-context', expected);
|
|
171
139
|
});
|
|
172
140
|
test('support using hooks within kind instances', function () {
|
|
@@ -176,10 +144,9 @@ describe('kind', function () {
|
|
|
176
144
|
render: function render() {
|
|
177
145
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
178
146
|
var _useState = (0, _react2.useState)(0),
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
147
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
148
|
+
state = _useState2[0],
|
|
149
|
+
setState = _useState2[1];
|
|
183
150
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
184
151
|
"data-testid": "button",
|
|
185
152
|
onClick: function onClick() {
|
|
@@ -190,11 +157,8 @@ describe('kind', function () {
|
|
|
190
157
|
}
|
|
191
158
|
});
|
|
192
159
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, {}));
|
|
193
|
-
|
|
194
160
|
var button = _react.screen.getByTestId('button');
|
|
195
|
-
|
|
196
161
|
_userEvent["default"].click(button);
|
|
197
|
-
|
|
198
162
|
var expected = '1';
|
|
199
163
|
expect(button).toHaveTextContent(expected);
|
|
200
164
|
});
|
|
@@ -212,10 +176,11 @@ describe('kind', function () {
|
|
|
212
176
|
expect(actual).toBe(expected);
|
|
213
177
|
});
|
|
214
178
|
test('should set default props when prop is not passed', function () {
|
|
215
|
-
var component = Kind.inline();
|
|
179
|
+
var component = Kind.inline();
|
|
180
|
+
|
|
181
|
+
// since we're inlining the output, we have to reference where the label prop lands --
|
|
216
182
|
// the title prop of the <div> -- rather than the label prop on the component (which
|
|
217
183
|
// doesn't exist due to inlining).
|
|
218
|
-
|
|
219
184
|
var expected = 'Label';
|
|
220
185
|
var actual = component.props.title;
|
|
221
186
|
expect(actual).toBe(expected);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _styles = _interopRequireDefault(require("../styles"));
|
|
4
|
-
|
|
5
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
|
-
|
|
7
5
|
describe('styles', function () {
|
|
8
6
|
var css = {
|
|
9
7
|
button: 'unambiguous-button-class-name',
|
|
10
8
|
client: 'unambiguous-button-class-name-client'
|
|
11
|
-
};
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// className tests
|
|
12
12
|
|
|
13
13
|
test('should add cfg.className to props', function () {
|
|
14
14
|
var cfg = {
|
|
@@ -62,7 +62,9 @@ describe('styles', function () {
|
|
|
62
62
|
var expected = props.className;
|
|
63
63
|
var actual = updated.className;
|
|
64
64
|
expect(actual).toBe(expected);
|
|
65
|
-
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// style tests
|
|
66
68
|
|
|
67
69
|
test('should add cfg.style to props', function () {
|
|
68
70
|
var cfg = {
|
|
@@ -101,9 +103,10 @@ describe('styles', function () {
|
|
|
101
103
|
var expected = 2;
|
|
102
104
|
var actual = Object.keys(updated.style).length;
|
|
103
105
|
expect(actual).toBe(expected);
|
|
104
|
-
});
|
|
105
|
-
// e.g. borderWidth: 3px + border: 1px solid black = border: 3px solid black
|
|
106
|
+
});
|
|
106
107
|
|
|
108
|
+
// Doesn't support merging shorthand properties and individual properties
|
|
109
|
+
// e.g. borderWidth: 3px + border: 1px solid black = border: 3px solid black
|
|
107
110
|
test('should not merge shorthand properties', function () {
|
|
108
111
|
var props = {
|
|
109
112
|
style: {
|
|
@@ -119,7 +122,9 @@ describe('styles', function () {
|
|
|
119
122
|
var expected = 1;
|
|
120
123
|
var actual = Object.keys(updated.style).length;
|
|
121
124
|
expect(actual).not.toBe(expected);
|
|
122
|
-
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// styler tests
|
|
123
128
|
|
|
124
129
|
test('should add styler.join() to props', function () {
|
|
125
130
|
var updated = (0, _styles["default"])({}, {});
|
package/kind/util.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.addInternalProp = void 0;
|
|
7
|
-
|
|
8
7
|
var addInternalProp = function addInternalProp(props, name, value) {
|
|
9
8
|
Object.defineProperty(props, name, {
|
|
10
9
|
value: value,
|
|
@@ -13,5 +12,4 @@ var addInternalProp = function addInternalProp(props, name, value) {
|
|
|
13
12
|
});
|
|
14
13
|
return props;
|
|
15
14
|
};
|
|
16
|
-
|
|
17
15
|
exports.addInternalProp = addInternalProp;
|
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/core",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.3",
|
|
4
4
|
"description": "Enact is an open source JavaScript framework containing everything you need to create a fast, scalable mobile or web application.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/enactjs/enact.git",
|
|
8
|
+
"directory": "packages/core"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://enactjs.com",
|
|
5
11
|
"main": "index.js",
|
|
6
12
|
"scripts": {
|
|
7
13
|
"clean": "enact clean",
|