@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,143 +1,201 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
|
|
5
|
+
var _enzyme = require("enzyme");
|
|
6
|
+
|
|
7
|
+
var _Registry = _interopRequireDefault(require("../Registry"));
|
|
8
|
+
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
+
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
|
|
13
|
+
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); } }
|
|
14
|
+
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
16
|
+
|
|
17
|
+
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); }
|
|
18
|
+
|
|
19
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
20
|
+
|
|
21
|
+
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); }; }
|
|
22
|
+
|
|
23
|
+
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
24
|
+
|
|
25
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
26
|
+
|
|
27
|
+
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; } }
|
|
28
|
+
|
|
29
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
30
|
+
|
|
31
|
+
var SomeContext = /*#__PURE__*/_react["default"].createContext();
|
|
32
|
+
|
|
33
|
+
describe('Registry', function () {
|
|
34
|
+
var NotifiesTree = /*#__PURE__*/function (_React$Component) {
|
|
35
|
+
_inherits(NotifiesTree, _React$Component);
|
|
36
|
+
|
|
37
|
+
var _super = _createSuper(NotifiesTree);
|
|
38
|
+
|
|
39
|
+
function NotifiesTree() {
|
|
40
|
+
var _this;
|
|
41
|
+
|
|
42
|
+
_classCallCheck(this, NotifiesTree);
|
|
43
|
+
|
|
44
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
45
|
+
args[_key] = arguments[_key];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
49
|
+
_this.registry = _Registry["default"].create();
|
|
50
|
+
|
|
51
|
+
_this.handleClick = function () {
|
|
52
|
+
_this.registry.notify({});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return _this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
_createClass(NotifiesTree, [{
|
|
59
|
+
key: "componentDidMount",
|
|
60
|
+
value: function componentDidMount() {
|
|
61
|
+
this.registry.parent = this.context;
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "render",
|
|
65
|
+
value: function render() {
|
|
66
|
+
return /*#__PURE__*/_react["default"].createElement(SomeContext.Provider, {
|
|
67
|
+
value: this.registry.register
|
|
68
|
+
}, /*#__PURE__*/_react["default"].createElement("button", Object.assign({}, this.props, {
|
|
69
|
+
onClick: this.handleClick
|
|
70
|
+
}), "Notify!"), this.props.children);
|
|
71
|
+
}
|
|
72
|
+
}]);
|
|
73
|
+
|
|
74
|
+
return NotifiesTree;
|
|
75
|
+
}(_react["default"].Component);
|
|
76
|
+
|
|
77
|
+
NotifiesTree.contextType = SomeContext;
|
|
78
|
+
|
|
79
|
+
var HandlesNotification = /*#__PURE__*/function (_React$Component2) {
|
|
80
|
+
_inherits(HandlesNotification, _React$Component2);
|
|
81
|
+
|
|
82
|
+
var _super2 = _createSuper(HandlesNotification);
|
|
83
|
+
|
|
84
|
+
function HandlesNotification() {
|
|
85
|
+
var _this2;
|
|
86
|
+
|
|
87
|
+
_classCallCheck(this, HandlesNotification);
|
|
88
|
+
|
|
89
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
90
|
+
args[_key2] = arguments[_key2];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
_this2 = _super2.call.apply(_super2, [this].concat(args));
|
|
94
|
+
_this2.state = {
|
|
95
|
+
number: 0
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
_this2.handleResize = function () {
|
|
99
|
+
_this2.setState(function (prevState) {
|
|
100
|
+
var number = prevState.number + 1;
|
|
101
|
+
return {
|
|
102
|
+
number: number
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return _this2;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
_createClass(HandlesNotification, [{
|
|
111
|
+
key: "componentDidMount",
|
|
112
|
+
value: function componentDidMount() {
|
|
113
|
+
if (this.context && typeof this.context === 'function') {
|
|
114
|
+
this.registry = this.context(this.handleResize);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "componentWillUnmount",
|
|
119
|
+
value: function componentWillUnmount() {
|
|
120
|
+
if (this.registry) {
|
|
121
|
+
this.registry.unregister();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}, {
|
|
125
|
+
key: "render",
|
|
126
|
+
value: function render() {
|
|
127
|
+
return /*#__PURE__*/_react["default"].createElement("div", this.props, this.state.number);
|
|
128
|
+
}
|
|
129
|
+
}]);
|
|
130
|
+
|
|
131
|
+
return HandlesNotification;
|
|
132
|
+
}(_react["default"].Component);
|
|
133
|
+
|
|
134
|
+
HandlesNotification.contextType = SomeContext;
|
|
135
|
+
test('should increment child on click', function () {
|
|
136
|
+
var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(NotifiesTree, {
|
|
137
|
+
id: "a-btn"
|
|
138
|
+
}, /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
|
|
139
|
+
id: "a"
|
|
140
|
+
})));
|
|
141
|
+
RegistryApp.find('button#a-btn').simulate('click');
|
|
142
|
+
var expected = '1';
|
|
143
|
+
var actual = RegistryApp.find('div#a').text();
|
|
144
|
+
expect(expected).toBe(actual);
|
|
145
|
+
});
|
|
146
|
+
test('should increment both children on top click', function () {
|
|
147
|
+
var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(NotifiesTree, {
|
|
148
|
+
id: "a-btn"
|
|
149
|
+
}, /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
|
|
150
|
+
id: "a"
|
|
151
|
+
}), /*#__PURE__*/_react["default"].createElement(NotifiesTree, {
|
|
152
|
+
id: "b-btn"
|
|
153
|
+
}, /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
|
|
154
|
+
id: "b"
|
|
155
|
+
}))));
|
|
156
|
+
RegistryApp.find('button#a-btn').simulate('click');
|
|
157
|
+
var expected = '1';
|
|
158
|
+
var actualA = RegistryApp.find('div#a').text();
|
|
159
|
+
var actualB = RegistryApp.find('div#b').text();
|
|
160
|
+
expect(expected).toBe(actualA);
|
|
161
|
+
expect(expected).toBe(actualB);
|
|
162
|
+
});
|
|
163
|
+
test('should increment the deepest child when we click child button', function () {
|
|
164
|
+
var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(NotifiesTree, {
|
|
165
|
+
id: "a-btn"
|
|
166
|
+
}, /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
|
|
167
|
+
id: "a"
|
|
168
|
+
}), /*#__PURE__*/_react["default"].createElement(NotifiesTree, {
|
|
169
|
+
id: "b-btn"
|
|
170
|
+
}, /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
|
|
171
|
+
id: "b"
|
|
172
|
+
}))));
|
|
173
|
+
RegistryApp.find('button#b-btn').simulate('click');
|
|
174
|
+
var expectedA = '0';
|
|
175
|
+
var expectedB = '1';
|
|
176
|
+
var actualA = RegistryApp.find('div#a').text();
|
|
177
|
+
var actualB = RegistryApp.find('div#b').text();
|
|
178
|
+
expect(expectedA).toBe(actualA);
|
|
179
|
+
expect(expectedB).toBe(actualB);
|
|
180
|
+
});
|
|
181
|
+
test('should support removing children without error', function () {
|
|
182
|
+
var RegistryApp = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(NotifiesTree, {
|
|
183
|
+
id: "a-btn"
|
|
184
|
+
}, /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
|
|
185
|
+
id: "a"
|
|
186
|
+
}), /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
|
|
187
|
+
id: "b"
|
|
188
|
+
})));
|
|
189
|
+
RegistryApp.find('button#a-btn').simulate('click'); // changing children should be safe and not throw errors when notifying instances
|
|
190
|
+
|
|
191
|
+
RegistryApp.setProps({
|
|
192
|
+
children: /*#__PURE__*/_react["default"].createElement(HandlesNotification, {
|
|
193
|
+
id: "c"
|
|
194
|
+
})
|
|
195
|
+
});
|
|
196
|
+
RegistryApp.find('button#a-btn').simulate('click');
|
|
197
|
+
var expectedC = '1';
|
|
198
|
+
var actualC = RegistryApp.find('div#c').text();
|
|
199
|
+
expect(expectedC).toBe(actualC);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
File without changes
|
|
@@ -1,48 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.deprecate = exports["default"] = void 0;
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Provides the `deprecate` method
|
|
3
10
|
*
|
|
4
11
|
* @module core/internal/deprecate
|
|
5
12
|
* @private
|
|
6
13
|
*/
|
|
7
|
-
|
|
8
14
|
// Utility method to format deprecate message
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
msg += ` since ${since}`;
|
|
17
|
-
}
|
|
18
|
-
if (until) {
|
|
19
|
-
if (name || since) {
|
|
20
|
-
msg += '.';
|
|
21
|
-
}
|
|
22
|
-
msg += ` Will be removed in ${until}`;
|
|
23
|
-
}
|
|
24
|
-
if (replacedBy) {
|
|
25
|
-
if (name || since || until) {
|
|
26
|
-
msg += '.';
|
|
27
|
-
}
|
|
28
|
-
msg += ` Replaced by ${replacedBy}`;
|
|
29
|
-
}
|
|
30
|
-
if (name || since || until || replacedBy) {
|
|
31
|
-
msg += '.';
|
|
32
|
-
}
|
|
33
|
-
if (message) {
|
|
34
|
-
msg += ` ${message}.`;
|
|
35
|
-
}
|
|
36
|
-
return msg;
|
|
37
|
-
};
|
|
15
|
+
var formatMsg = function formatMsg(_ref) {
|
|
16
|
+
var message = _ref.message,
|
|
17
|
+
name = _ref.name,
|
|
18
|
+
until = _ref.until,
|
|
19
|
+
replacedBy = _ref.replacedBy,
|
|
20
|
+
since = _ref.since;
|
|
21
|
+
var msg = 'DEPRECATED:';
|
|
38
22
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
23
|
+
if (name) {
|
|
24
|
+
msg += " ".concat(name);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (since) {
|
|
28
|
+
msg += " since ".concat(since);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (until) {
|
|
32
|
+
if (name || since) {
|
|
33
|
+
msg += '.';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
msg += " Will be removed in ".concat(until);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (replacedBy) {
|
|
40
|
+
if (name || since || until) {
|
|
41
|
+
msg += '.';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
msg += " Replaced by ".concat(replacedBy);
|
|
45
|
+
}
|
|
45
46
|
|
|
47
|
+
if (name || since || until || replacedBy) {
|
|
48
|
+
msg += '.';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (message) {
|
|
52
|
+
msg += " ".concat(message, ".");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return msg;
|
|
56
|
+
}; // Utility method for console warning
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
var warn = function warn(msg) {
|
|
60
|
+
if (typeof console !== 'undefined') {
|
|
61
|
+
console.warn(msg); // eslint-disable-line no-console
|
|
62
|
+
}
|
|
63
|
+
};
|
|
46
64
|
/**
|
|
47
65
|
* Marks a function, component or property (via `propTypes`) as deprecated. Deprecated items will
|
|
48
66
|
* log a message on first invocation. Can also be used 'stand-alone' to issue a deprecation warning.
|
|
@@ -63,29 +81,36 @@ const warn = (msg) => {
|
|
|
63
81
|
* @memberof core/internal/deprecate
|
|
64
82
|
* @private
|
|
65
83
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
var deprecate = function deprecate(thing, config) {
|
|
87
|
+
if (process.env.NODE_ENV !== "production") {
|
|
88
|
+
if (!config) {
|
|
89
|
+
// If no config, config only invocation, just log message
|
|
90
|
+
var msg = formatMsg(thing);
|
|
91
|
+
warn(msg);
|
|
92
|
+
return thing;
|
|
93
|
+
} else {
|
|
94
|
+
var displayed, _msg;
|
|
95
|
+
|
|
96
|
+
return function () {
|
|
97
|
+
if (!displayed || config.alwaysWarn) {
|
|
98
|
+
if (!_msg) {
|
|
99
|
+
_msg = formatMsg(config);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
warn(_msg);
|
|
103
|
+
displayed = true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return thing.apply(void 0, arguments);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
return thing;
|
|
111
|
+
}
|
|
88
112
|
};
|
|
89
113
|
|
|
90
|
-
|
|
91
|
-
|
|
114
|
+
exports.deprecate = deprecate;
|
|
115
|
+
var _default = deprecate;
|
|
116
|
+
exports["default"] = _default;
|
|
File without changes
|
|
@@ -1,83 +1,90 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
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"));
|
|
4
13
|
|
|
5
|
-
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
15
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (typeof propValue === 'undefined') {
|
|
11
|
-
return new Error(
|
|
12
|
-
`'${propFullName}' is required for '${componentName}' but was undefined.`
|
|
13
|
-
);
|
|
14
|
-
}
|
|
16
|
+
var isRequired = function isRequired(fn) {
|
|
17
|
+
fn.isRequired = function (props, key, componentName, location, propFullName) {
|
|
18
|
+
var propValue = props[key];
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
if (typeof propValue === 'undefined') {
|
|
21
|
+
return new Error("'".concat(propFullName, "' is required for '").concat(componentName, "' but was undefined."));
|
|
22
|
+
}
|
|
18
23
|
|
|
19
|
-
|
|
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;
|
|
20
32
|
};
|
|
21
33
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (propValue && !isRenderable(propValue)) {
|
|
25
|
-
return new Error(
|
|
26
|
-
`Invalid prop '${key}' supplied to '${componentName}'. ` +
|
|
27
|
-
`Expected a renderable value but received '${typeof propValue}' instead.`
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
34
|
+
var renderable = isRequired(function (props, key, componentName) {
|
|
35
|
+
var propValue = props[key];
|
|
31
36
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return new Error(
|
|
36
|
-
`Invalid prop '${key}' supplied to '${componentName}'. ` +
|
|
37
|
-
`Expected a function but received '${typeof propValue}' instead.`
|
|
38
|
-
);
|
|
39
|
-
}
|
|
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
40
|
});
|
|
41
|
+
var component = isRequired(function (props, key, componentName) {
|
|
42
|
+
var propValue = props[key];
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
+
});
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
PropTypes.element,
|
|
49
|
-
component
|
|
50
|
-
]);
|
|
49
|
+
var renderableOverride = _propTypes["default"].oneOfType([_propTypes["default"].element, renderable]);
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
current: PropTypes.any
|
|
54
|
-
}), PropTypes.func]);
|
|
51
|
+
var componentOverride = _propTypes["default"].oneOfType([_propTypes["default"].element, component]);
|
|
55
52
|
|
|
53
|
+
var ref = _propTypes["default"].oneOfType([_propTypes["default"].shape({
|
|
54
|
+
current: _propTypes["default"].any
|
|
55
|
+
}), _propTypes["default"].func]);
|
|
56
56
|
/*
|
|
57
57
|
* Wrap a prop type validator with a deprecation warning when the prop has a non-null value
|
|
58
58
|
*
|
|
59
59
|
* @param {Function} base Prop type validator
|
|
60
60
|
* @param {Object} config deprecatioon configuration
|
|
61
61
|
*/
|
|
62
|
-
const deprecated = (base, config) => {
|
|
63
|
-
// Wrap in a no-op so deprecate only warns once
|
|
64
|
-
const warn = deprecate(() => true, config);
|
|
65
|
-
return (props, key, ...rest) => {
|
|
66
|
-
// Warn on a non-null value for the prop
|
|
67
|
-
if (props[key] != null) warn();
|
|
68
|
-
|
|
69
|
-
// Pass on to the prop type validator
|
|
70
|
-
return base(props, key, ...rest);
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
62
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
+
};
|
|
81
79
|
};
|
|
82
80
|
|
|
83
|
-
|
|
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;
|