@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/kind/kind.js
CHANGED
|
@@ -1,23 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.kind = exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _useHandlers = _interopRequireDefault(require("../useHandlers"));
|
|
11
|
+
|
|
12
|
+
var _Handlers = _interopRequireDefault(require("../useHandlers/Handlers"));
|
|
13
|
+
|
|
14
|
+
var _computed = _interopRequireDefault(require("./computed"));
|
|
15
|
+
|
|
16
|
+
var _styles = _interopRequireDefault(require("./styles"));
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
+
|
|
20
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
+
|
|
22
|
+
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); } }
|
|
7
23
|
|
|
8
|
-
|
|
24
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
9
25
|
|
|
10
|
-
|
|
11
|
-
import Handlers from '../useHandlers/Handlers';
|
|
26
|
+
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
12
27
|
|
|
13
|
-
|
|
14
|
-
|
|
28
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
29
|
+
|
|
30
|
+
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
|
+
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
33
|
+
|
|
34
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
35
|
+
|
|
36
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
|
+
|
|
38
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
|
+
|
|
40
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
41
|
+
|
|
42
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
43
|
+
|
|
44
|
+
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; }
|
|
15
45
|
|
|
16
46
|
// Because contextType is optional and hooks must be called in the same order, we need a fallback
|
|
17
47
|
// context when none is specified. This likely has some overhead so we may want to deprecate and
|
|
18
48
|
// remove contextType support for 4.0 since the context APIs have improved since this was added.
|
|
19
|
-
|
|
20
|
-
|
|
49
|
+
var NoContext = /*#__PURE__*/_react["default"].createContext(null);
|
|
21
50
|
/**
|
|
22
51
|
* @callback RenderFunction
|
|
23
52
|
* @memberof core/kind
|
|
@@ -125,106 +154,113 @@ const NoContext = React.createContext(null);
|
|
|
125
154
|
* @see {@link core/handle}
|
|
126
155
|
* @public
|
|
127
156
|
*/
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
var kind = function kind(config) {
|
|
160
|
+
var cfgComputed = config.computed,
|
|
161
|
+
_config$contextType = config.contextType,
|
|
162
|
+
contextType = _config$contextType === void 0 ? NoContext : _config$contextType,
|
|
163
|
+
defaultProps = config.defaultProps,
|
|
164
|
+
functional = config.functional,
|
|
165
|
+
handlers = config.handlers,
|
|
166
|
+
name = config.name,
|
|
167
|
+
propTypes = config.propTypes,
|
|
168
|
+
render = config.render,
|
|
169
|
+
cfgStyles = config.styles;
|
|
170
|
+
var renderStyles = cfgStyles ? (0, _styles["default"])(cfgStyles) : false;
|
|
171
|
+
var renderComputed = cfgComputed ? (0, _computed["default"])(cfgComputed) : false;
|
|
172
|
+
|
|
173
|
+
var renderKind = function renderKind(props, context) {
|
|
174
|
+
if (renderStyles) props = renderStyles(props, context);
|
|
175
|
+
if (renderComputed) props = renderComputed(props, context);
|
|
176
|
+
return render(props, context);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
var Component; // In 4.x, this branch will become the only supported version and the class branch will be
|
|
180
|
+
// removed.
|
|
181
|
+
|
|
182
|
+
if (functional) {
|
|
183
|
+
Component = function Component(props) {
|
|
184
|
+
var ctx = _react["default"].useContext(contextType);
|
|
185
|
+
|
|
186
|
+
var boundHandlers = (0, _useHandlers["default"])(handlers, props, ctx);
|
|
187
|
+
|
|
188
|
+
var merged = _objectSpread(_objectSpread({}, props), boundHandlers);
|
|
189
|
+
|
|
190
|
+
return renderKind(merged, ctx);
|
|
191
|
+
};
|
|
192
|
+
} else {
|
|
193
|
+
var _class, _temp;
|
|
194
|
+
|
|
195
|
+
// eslint-disable-next-line enact/display-name
|
|
196
|
+
Component = (_temp = _class = /*#__PURE__*/function (_React$Component) {
|
|
197
|
+
_inherits(Component, _React$Component);
|
|
198
|
+
|
|
199
|
+
var _super = _createSuper(Component);
|
|
200
|
+
|
|
201
|
+
function Component() {
|
|
202
|
+
var _this;
|
|
203
|
+
|
|
204
|
+
_classCallCheck(this, Component);
|
|
205
|
+
|
|
206
|
+
_this = _super.call(this);
|
|
207
|
+
_this.handlers = new _Handlers["default"](handlers);
|
|
208
|
+
return _this;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
_createClass(Component, [{
|
|
212
|
+
key: "render",
|
|
213
|
+
value: function render() {
|
|
214
|
+
this.handlers.setContext(this.props, this.context);
|
|
215
|
+
|
|
216
|
+
var merged = _objectSpread(_objectSpread({}, this.props), this.handlers.handlers);
|
|
217
|
+
|
|
218
|
+
return renderKind(merged, this.context);
|
|
219
|
+
}
|
|
220
|
+
}]);
|
|
221
|
+
|
|
222
|
+
return Component;
|
|
223
|
+
}(_react["default"].Component), _class.contextType = contextType, _temp);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (name) Component.displayName = name;
|
|
227
|
+
if (propTypes) Component.propTypes = propTypes;
|
|
228
|
+
if (defaultProps) Component.defaultProps = defaultProps; // Decorate the Component with the computed property object in DEV for easier testability
|
|
229
|
+
|
|
230
|
+
if (process.env.NODE_ENV !== "production" && cfgComputed) Component.computed = cfgComputed;
|
|
231
|
+
var defaultPropKeys = defaultProps ? Object.keys(defaultProps) : null;
|
|
232
|
+
var handlerKeys = handlers ? Object.keys(handlers) : null;
|
|
233
|
+
|
|
234
|
+
Component.inline = function (props, context) {
|
|
235
|
+
var updated = _objectSpread({}, props);
|
|
236
|
+
|
|
237
|
+
if (defaultPropKeys && defaultPropKeys.length > 0) {
|
|
238
|
+
defaultPropKeys.forEach(function (key) {
|
|
239
|
+
// eslint-disable-next-line no-undefined
|
|
240
|
+
if (props == null || props[key] === undefined) {
|
|
241
|
+
updated[key] = defaultProps[key];
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (handlerKeys && handlerKeys.length > 0) {
|
|
247
|
+
// generate a handler with a clone of updated to ensure each handler receives the same
|
|
248
|
+
// props without the kind.handlers injected.
|
|
249
|
+
updated = handlerKeys.reduce(function (_props, key) {
|
|
250
|
+
_props[key] = function (ev) {
|
|
251
|
+
return handlers[key](ev, updated, context);
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
return _props;
|
|
255
|
+
}, _objectSpread({}, updated));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return renderKind(updated, context);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
return Component;
|
|
227
262
|
};
|
|
228
263
|
|
|
229
|
-
|
|
230
|
-
|
|
264
|
+
exports.kind = kind;
|
|
265
|
+
var _default = kind;
|
|
266
|
+
exports["default"] = _default;
|
package/kind/styles.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.styles = exports["default"] = void 0;
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
var _bind = _interopRequireDefault(require("classnames/bind"));
|
|
9
|
+
|
|
10
|
+
var _util = require("../util");
|
|
11
|
+
|
|
12
|
+
var _util2 = require("./util");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
15
|
|
|
7
16
|
/**
|
|
8
17
|
* Merges external and internal CSS classes and style objects. Internal CSS classes can be
|
|
@@ -42,49 +51,55 @@ import {addInternalProp} from './util';
|
|
|
42
51
|
* `css` merged class name map
|
|
43
52
|
* @private
|
|
44
53
|
*/
|
|
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
|
-
|
|
54
|
+
var styles = function styles(cfg, optProps) {
|
|
55
|
+
var className = cfg.className,
|
|
56
|
+
configCss = cfg.css,
|
|
57
|
+
_cfg$prop = cfg.prop,
|
|
58
|
+
prop = _cfg$prop === void 0 ? 'className' : _cfg$prop,
|
|
59
|
+
style = cfg.style;
|
|
60
|
+
var allowedClassNames = cfg.publicClassNames;
|
|
61
|
+
|
|
62
|
+
if (configCss && allowedClassNames === true) {
|
|
63
|
+
allowedClassNames = Object.keys(configCss);
|
|
64
|
+
} else if (typeof allowedClassNames === 'string') {
|
|
65
|
+
allowedClassNames = allowedClassNames.split(/\s+/);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var renderStyles = function renderStyles(props) {
|
|
69
|
+
var css = configCss;
|
|
70
|
+
|
|
71
|
+
if (style) {
|
|
72
|
+
props.style = Object.assign({}, style, props.style);
|
|
73
|
+
} // if the props includes a css map, merge them together now
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
if (css && allowedClassNames && props.css) {
|
|
77
|
+
css = (0, _util.mergeClassNameMaps)(css, props.css, allowedClassNames);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
var cn = css ? _bind["default"].bind(css) : _bind["default"];
|
|
81
|
+
var joinedClassName = props[prop] = (0, _bind["default"])(className ? cn(className.split(' ')) : null, props.className);
|
|
82
|
+
(0, _util2.addInternalProp)(props, 'css', css);
|
|
83
|
+
(0, _util2.addInternalProp)(props, 'styler', {
|
|
84
|
+
join: cn,
|
|
85
|
+
append: function append() {
|
|
86
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
87
|
+
args[_key] = arguments[_key];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return cn.apply(void 0, [joinedClassName].concat(args));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return props;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
if (optProps) {
|
|
97
|
+
return renderStyles(optProps);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return renderStyles;
|
|
87
101
|
};
|
|
88
102
|
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
exports.styles = styles;
|
|
104
|
+
var _default = styles;
|
|
105
|
+
exports["default"] = _default;
|
|
@@ -1,86 +1,87 @@
|
|
|
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
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _computed = _interopRequireDefault(require("../computed"));
|
|
4
|
+
|
|
5
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
|
+
|
|
7
|
+
describe('computed', function () {
|
|
8
|
+
var exampleCfg = {
|
|
9
|
+
sum: function sum(_ref) {
|
|
10
|
+
var x = _ref.x,
|
|
11
|
+
y = _ref.y,
|
|
12
|
+
z = _ref.z;
|
|
13
|
+
return x + y + z;
|
|
14
|
+
},
|
|
15
|
+
product: function product(_ref2) {
|
|
16
|
+
var x = _ref2.x,
|
|
17
|
+
y = _ref2.y,
|
|
18
|
+
z = _ref2.z;
|
|
19
|
+
return x * y * z;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var exampleProps = {
|
|
23
|
+
x: 2,
|
|
24
|
+
y: 3,
|
|
25
|
+
z: 4
|
|
26
|
+
};
|
|
27
|
+
test('should add new props to updated object', function () {
|
|
28
|
+
var props = {
|
|
29
|
+
value: true
|
|
30
|
+
};
|
|
31
|
+
var cfg = {
|
|
32
|
+
count: function count() {
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var updated = (0, _computed["default"])(cfg, props);
|
|
37
|
+
var expected = 1;
|
|
38
|
+
var actual = updated.count;
|
|
39
|
+
expect(actual).toBe(expected);
|
|
40
|
+
});
|
|
41
|
+
test('should overwrite properties with computed values', function () {
|
|
42
|
+
var props = {
|
|
43
|
+
value: true,
|
|
44
|
+
count: 2
|
|
45
|
+
};
|
|
46
|
+
var cfg = {
|
|
47
|
+
count: function count() {
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var updated = (0, _computed["default"])(cfg, props);
|
|
52
|
+
var expected = 1;
|
|
53
|
+
var actual = updated.count;
|
|
54
|
+
expect(actual).toBe(expected);
|
|
55
|
+
});
|
|
56
|
+
test('should not leak updated prop values into other computed props', function () {
|
|
57
|
+
var props = {
|
|
58
|
+
count: 1
|
|
59
|
+
};
|
|
60
|
+
var cfg = {
|
|
61
|
+
value: function value(_ref3) {
|
|
62
|
+
var count = _ref3.count;
|
|
63
|
+
return count + 5;
|
|
64
|
+
},
|
|
65
|
+
count: function count(_ref4) {
|
|
66
|
+
var _count = _ref4.count;
|
|
67
|
+
return _count + 1;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var updated = (0, _computed["default"])(cfg, props);
|
|
71
|
+
var expected = 6;
|
|
72
|
+
var actual = updated.value;
|
|
73
|
+
expect(actual).toBe(expected);
|
|
74
|
+
});
|
|
75
|
+
test('should work with its documented example - sum', function () {
|
|
76
|
+
var updated = (0, _computed["default"])(exampleCfg, exampleProps);
|
|
77
|
+
var expected = 9;
|
|
78
|
+
var actual = updated.sum;
|
|
79
|
+
expect(actual).toBe(expected);
|
|
80
|
+
});
|
|
81
|
+
test('should work with its documented example - product', function () {
|
|
82
|
+
var updated = (0, _computed["default"])(exampleCfg, exampleProps);
|
|
83
|
+
var expected = 24;
|
|
84
|
+
var actual = updated.product;
|
|
85
|
+
expect(actual).toBe(expected);
|
|
86
|
+
});
|
|
87
|
+
});
|