@enact/ui 4.5.2 → 4.6.0
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/AnnounceDecorator/Announce.js +1 -40
- package/AnnounceDecorator/AnnounceDecorator.js +3 -21
- package/AnnounceDecorator/tests/Announce-specs.js +2 -7
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +2 -6
- package/AnnounceDecorator/tests/useAnnounce-specs.js +8 -19
- package/AnnounceDecorator/useAnnounce.js +0 -6
- package/BodyText/BodyText.d.ts +1 -1
- package/BodyText/BodyText.js +8 -28
- package/BodyText/tests/BodyText-specs.js +0 -19
- package/Button/Button.d.ts +6 -6
- package/Button/Button.js +33 -63
- package/Button/tests/Button-specs.js +0 -26
- package/CHANGELOG.md +30 -0
- package/Cancelable/Cancelable.js +8 -47
- package/Cancelable/cancelHandler.js +5 -12
- package/Cancelable/modalHandler.js +3 -11
- package/Cancelable/tests/Cancelable-specs.js +3 -57
- package/Changeable/Changeable.js +2 -34
- package/Changeable/tests/Changeable-specs.js +20 -66
- package/ComponentOverride/ComponentOverride.js +1 -13
- package/FloatingLayer/FloatingLayer.js +17 -73
- package/FloatingLayer/FloatingLayerContainer.js +0 -15
- package/FloatingLayer/FloatingLayerDecorator.js +4 -17
- package/FloatingLayer/Scrim.js +9 -53
- package/FloatingLayer/index.js +0 -4
- package/FloatingLayer/tests/FloatingLayer-specs.js +8 -22
- package/FloatingLayer/tests/Scrim-specs.js +0 -9
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +0 -13
- package/FloatingLayer/useFloatingLayer.js +3 -14
- package/FloatingLayer/useFloatingLayerDecorator.js +3 -11
- package/ForwardRef/ForwardRef.js +1 -10
- package/GridListImageItem/GridListImageItem.d.ts +1 -1
- package/GridListImageItem/GridListImageItem.js +18 -51
- package/Group/Group.js +5 -36
- package/Group/GroupItem.js +16 -33
- package/Group/tests/Group-specs.js +0 -32
- package/Heading/Heading.js +8 -36
- package/Heading/tests/Heading-specs.js +81 -14
- package/Icon/Icon.d.ts +4 -4
- package/Icon/Icon.js +19 -53
- package/Icon/tests/Icon-specs.js +0 -22
- package/IconButton/IconButton.d.ts +4 -4
- package/IconButton/IconButton.js +17 -55
- package/IconButton/tests/IconButton-specs.js +0 -7
- package/Image/Image.js +17 -46
- package/Image/tests/Image-specs.js +0 -14
- package/ImageItem/ImageItem.js +18 -47
- package/ImageItem/tests/ImageItem-specs.js +0 -25
- package/Item/Item.js +9 -33
- package/Item/tests/Item-specs.js +0 -24
- package/LabeledIcon/LabeledIcon.d.ts +2 -2
- package/LabeledIcon/LabeledIcon.js +22 -53
- package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
- package/Layout/Cell.js +18 -44
- package/Layout/Layout.d.ts +16 -16
- package/Layout/Layout.js +23 -46
- package/Layout/tests/Layout-specs.js +10 -39
- package/Marquee/MarqueeBase.js +29 -63
- package/Marquee/MarqueeController.js +11 -72
- package/Marquee/MarqueeDecorator.js +70 -196
- package/Marquee/index.js +1 -5
- package/Marquee/tests/Marquee-specs.js +295 -87
- package/Measurable/Measurable.js +12 -34
- package/Measurable/tests/Measurable-specs.js +115 -0
- package/Media/Media.js +15 -65
- package/Media/tests/Media-specs.js +168 -0
- package/Placeholder/PlaceholderControllerDecorator.js +7 -43
- package/Placeholder/PlaceholderDecorator.js +7 -38
- package/Placeholder/index.js +1 -5
- package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
- package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
- package/ProgressBar/ProgressBar.js +14 -45
- package/ProgressBar/tests/ProgressBar-specs.js +0 -17
- package/RadioDecorator/RadioControllerDecorator.js +1 -29
- package/RadioDecorator/RadioDecorator.js +4 -42
- package/RadioDecorator/tests/RadioDecorator-specs.js +12 -49
- package/Repeater/Repeater.js +9 -33
- package/Repeater/tests/Repeater-specs.js +0 -38
- package/Resizable/Resizable.js +9 -37
- package/Resizable/tests/Resizable-specs.js +34 -0
- package/Routable/Link.js +11 -47
- package/Routable/Routable.d.ts +2 -2
- package/Routable/Routable.js +12 -35
- package/Routable/Route.js +0 -6
- package/Routable/Router.js +15 -58
- package/Routable/tests/Routable-specs.js +7 -33
- package/Routable/tests/Router-specs.js +18 -44
- package/Routable/useLink.js +4 -8
- package/Routable/util.js +18 -24
- package/Scrollable/ScrollAnimator.js +49 -65
- package/Scrollable/ScrollThumb.js +2 -13
- package/Scrollable/Scrollable.js +180 -387
- package/Scrollable/ScrollableNative.js +189 -392
- package/Scrollable/Scrollbar.js +30 -102
- package/Scroller/Scroller.js +15 -39
- package/Scroller/ScrollerBasic.js +34 -89
- package/Scroller/UiScrollerBase.js +31 -84
- package/Scroller/tests/Scroller-specs.js +56 -0
- package/Skinnable/Skinnable.js +11 -38
- package/Skinnable/tests/Skinnable-specs.js +3 -74
- package/Skinnable/tests/useSkins-specs.js +1 -13
- package/Skinnable/tests/util-specs.js +0 -14
- package/Skinnable/useSkins.js +8 -15
- package/Skinnable/util.js +9 -20
- package/Slider/Knob.js +5 -24
- package/Slider/PositionDecorator.js +16 -54
- package/Slider/Slider.d.ts +2 -2
- package/Slider/Slider.js +29 -67
- package/Slider/tests/Slider-specs.js +94 -7
- package/Slider/utils.js +0 -2
- package/SlotItem/SlotItem.d.ts +1 -1
- package/SlotItem/SlotItem.js +17 -43
- package/SlotItem/tests/SlotItem-specs.js +0 -5
- package/Slottable/Slottable.js +4 -12
- package/Slottable/tests/Slottable-specs.js +19 -46
- package/Slottable/tests/useSlots-specs.js +27 -65
- package/Slottable/useSlots.js +8 -33
- package/Spinner/Spinner.d.ts +1 -1
- package/Spinner/Spinner.js +16 -43
- package/Spinner/tests/Spinner-specs.js +0 -15
- package/ToggleIcon/ToggleIcon.js +10 -36
- package/ToggleIcon/tests/ToggleIcon-specs.js +0 -16
- package/ToggleItem/ToggleItem.d.ts +3 -3
- package/ToggleItem/ToggleItem.js +18 -55
- package/ToggleItem/tests/ToggleItem-specs.js +0 -30
- package/Toggleable/Toggle.js +1 -15
- package/Toggleable/Toggleable.js +12 -45
- package/Toggleable/tests/Toggleable-specs.js +28 -96
- package/Toggleable/useToggle.js +3 -19
- package/Touchable/ClickAllow.js +5 -14
- package/Touchable/Drag.js +16 -54
- package/Touchable/Flick.js +11 -42
- package/Touchable/Hold.js +21 -68
- package/Touchable/Touch.js +37 -65
- package/Touchable/Touchable.js +32 -71
- package/Touchable/config.js +8 -22
- package/Touchable/tests/Touchable-specs.js +270 -119
- package/Touchable/tests/useTouch-specs.js +6 -80
- package/Touchable/useTouch.js +17 -34
- package/Transition/Transition.js +37 -118
- package/Transition/tests/Transition-specs.js +20 -60
- package/ViewManager/Arranger.js +10 -22
- package/ViewManager/TransitionGroup.js +32 -107
- package/ViewManager/View.js +35 -91
- package/ViewManager/ViewManager.d.ts +1 -1
- package/ViewManager/ViewManager.js +20 -84
- package/ViewManager/tests/View-specs.js +0 -17
- package/ViewManager/tests/ViewManager-specs.js +236 -305
- package/ViewManager/tests/test-utils.js +0 -8
- package/VirtualList/UiVirtualListBase.js +259 -409
- package/VirtualList/VirtualList.d.ts +4 -4
- package/VirtualList/VirtualList.js +29 -69
- package/VirtualList/VirtualListBase.js +0 -3
- package/VirtualList/VirtualListBasic.js +273 -431
- package/VirtualList/tests/VirtualGridList-native-specs.js +161 -0
- package/VirtualList/tests/VirtualGridList-specs.js +614 -0
- package/VirtualList/tests/VirtualList-native-specs.js +152 -0
- package/VirtualList/tests/VirtualList-specs.js +423 -95
- package/internal/IdProvider/IdProvider.js +7 -21
- package/internal/IdProvider/Provider.js +4 -17
- package/internal/IdProvider/tests/IdProvider-specs.js +44 -0
- package/internal/IdProvider/tests/useId-specs.js +6 -20
- package/internal/IdProvider/useId.js +0 -6
- package/internal/Pure/Pure.js +3 -30
- package/internal/Pure/tests/Pure-specs.js +88 -0
- package/internal/localized-fonts/localized-fonts.js +33 -62
- package/internal/localized-fonts/tests/localized-fonts-specs.js +33 -0
- package/internal/selection/selection.js +1 -6
- package/internal/selection/tests/selection-specs.js +6 -4
- package/internal/validators/tests/validators-specs.js +80 -0
- package/internal/validators/validators.js +14 -34
- package/package.json +9 -3
- package/resolution/ResolutionDecorator.js +4 -40
- package/resolution/index.js +0 -7
- package/resolution/resolution.js +42 -80
- package/resolution/tests/ResolutionDecorator-specs.js +4 -11
- package/resolution/tests/resolution-specs.js +2 -2
- package/useControlledState/tests/useControlledState-specs.js +15 -46
- package/useControlledState/useControlledState.js +11 -22
- package/useScroll/ScrollAnimator.js +49 -65
- package/useScroll/Scrollbar.js +22 -58
- package/useScroll/ScrollbarTrack.js +3 -19
- package/useScroll/useScroll.js +267 -454
- package/useScroll/utilDOM.js +8 -14
- package/useScroll/utilEvent.js +0 -4
|
@@ -1,23 +1,19 @@
|
|
|
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 _useSlots = _interopRequireDefault(require("../useSlots"));
|
|
8
|
-
|
|
9
6
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
-
|
|
11
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
-
|
|
13
8
|
/* eslint no-console: ["error", { allow: ["warn", "error"] }] */
|
|
9
|
+
|
|
14
10
|
describe('useSlots', function () {
|
|
15
11
|
test('should distribute children with a \'slot\' property', function () {
|
|
16
12
|
function Component(_ref) {
|
|
17
13
|
var a = _ref.a,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
b = _ref.b,
|
|
15
|
+
c = _ref.c,
|
|
16
|
+
children = _ref.children;
|
|
21
17
|
var slots = (0, _useSlots["default"])({
|
|
22
18
|
a: a,
|
|
23
19
|
b: b,
|
|
@@ -29,7 +25,6 @@ describe('useSlots', function () {
|
|
|
29
25
|
children: [slots.c, slots.b, slots.a]
|
|
30
26
|
});
|
|
31
27
|
}
|
|
32
|
-
|
|
33
28
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
34
29
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
35
30
|
slot: "a",
|
|
@@ -43,17 +38,15 @@ describe('useSlots', function () {
|
|
|
43
38
|
})]
|
|
44
39
|
}));
|
|
45
40
|
var expected = 'CBA';
|
|
46
|
-
|
|
47
41
|
var actual = _react.screen.getByTestId('useSlots');
|
|
48
|
-
|
|
49
42
|
expect(actual.textContent).toBe(expected);
|
|
50
43
|
});
|
|
51
44
|
test('should have no children when all have been distributed', function () {
|
|
52
45
|
function Component(_ref2) {
|
|
53
46
|
var a = _ref2.a,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
b = _ref2.b,
|
|
48
|
+
c = _ref2.c,
|
|
49
|
+
children = _ref2.children;
|
|
57
50
|
var slots = (0, _useSlots["default"])({
|
|
58
51
|
a: a,
|
|
59
52
|
b: b,
|
|
@@ -65,7 +58,6 @@ describe('useSlots', function () {
|
|
|
65
58
|
children: slots.children
|
|
66
59
|
});
|
|
67
60
|
}
|
|
68
|
-
|
|
69
61
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
70
62
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
71
63
|
slot: "a",
|
|
@@ -79,18 +71,16 @@ describe('useSlots', function () {
|
|
|
79
71
|
})]
|
|
80
72
|
}));
|
|
81
73
|
var expected = '';
|
|
82
|
-
|
|
83
74
|
var actual = _react.screen.getByTestId('useSlots');
|
|
84
|
-
|
|
85
75
|
expect(actual).toHaveTextContent(expected);
|
|
86
76
|
});
|
|
87
77
|
test('should distribute children with a \'type\' that matches a slot', function () {
|
|
88
78
|
function Component(_ref3) {
|
|
89
79
|
var a = _ref3.a,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
80
|
+
b = _ref3.b,
|
|
81
|
+
c = _ref3.c,
|
|
82
|
+
children = _ref3.children,
|
|
83
|
+
custom = _ref3.custom;
|
|
94
84
|
var slots = (0, _useSlots["default"])({
|
|
95
85
|
a: a,
|
|
96
86
|
b: b,
|
|
@@ -103,7 +93,6 @@ describe('useSlots', function () {
|
|
|
103
93
|
children: [slots.c, slots.b, slots.a, slots.custom]
|
|
104
94
|
});
|
|
105
95
|
}
|
|
106
|
-
|
|
107
96
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
108
97
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
109
98
|
slot: "a",
|
|
@@ -119,9 +108,7 @@ describe('useSlots', function () {
|
|
|
119
108
|
})]
|
|
120
109
|
}));
|
|
121
110
|
var expected = 'CBAD';
|
|
122
|
-
|
|
123
111
|
var actual = _react.screen.getByTestId('useSlots');
|
|
124
|
-
|
|
125
112
|
expect(actual.textContent).toBe(expected);
|
|
126
113
|
});
|
|
127
114
|
test('should distribute children whose \'type\' has a \'defaultSlot\' property that matches a slot', function () {
|
|
@@ -130,14 +117,12 @@ describe('useSlots', function () {
|
|
|
130
117
|
children: props.children
|
|
131
118
|
});
|
|
132
119
|
}
|
|
133
|
-
|
|
134
120
|
Custom.defaultSlot = 'c';
|
|
135
|
-
|
|
136
121
|
function Component(_ref4) {
|
|
137
122
|
var a = _ref4.a,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
123
|
+
b = _ref4.b,
|
|
124
|
+
c = _ref4.c,
|
|
125
|
+
children = _ref4.children;
|
|
141
126
|
var slots = (0, _useSlots["default"])({
|
|
142
127
|
a: a,
|
|
143
128
|
b: b,
|
|
@@ -149,7 +134,6 @@ describe('useSlots', function () {
|
|
|
149
134
|
children: [slots.c, slots.b, slots.a]
|
|
150
135
|
});
|
|
151
136
|
}
|
|
152
|
-
|
|
153
137
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
154
138
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
155
139
|
slot: "a",
|
|
@@ -162,16 +146,14 @@ describe('useSlots', function () {
|
|
|
162
146
|
})]
|
|
163
147
|
}));
|
|
164
148
|
var expected = 'CBA';
|
|
165
|
-
|
|
166
149
|
var actual = _react.screen.getByTestId('useSlots');
|
|
167
|
-
|
|
168
150
|
expect(actual.textContent).toBe(expected);
|
|
169
151
|
});
|
|
170
152
|
test('should distribute children with no \'slot\' property to Slottable\'s \'children\'', function () {
|
|
171
153
|
function Component(_ref5) {
|
|
172
154
|
var a = _ref5.a,
|
|
173
|
-
|
|
174
|
-
|
|
155
|
+
b = _ref5.b,
|
|
156
|
+
children = _ref5.children;
|
|
175
157
|
var slots = (0, _useSlots["default"])({
|
|
176
158
|
a: a,
|
|
177
159
|
b: b,
|
|
@@ -182,7 +164,6 @@ describe('useSlots', function () {
|
|
|
182
164
|
children: [slots.children, slots.b, slots.a]
|
|
183
165
|
});
|
|
184
166
|
}
|
|
185
|
-
|
|
186
167
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
187
168
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
188
169
|
slot: "a",
|
|
@@ -195,20 +176,17 @@ describe('useSlots', function () {
|
|
|
195
176
|
})]
|
|
196
177
|
}));
|
|
197
178
|
var expected = 'CBA';
|
|
198
|
-
|
|
199
179
|
var actual = _react.screen.getByTestId('useSlots');
|
|
200
|
-
|
|
201
180
|
expect(actual.textContent).toBe(expected);
|
|
202
181
|
});
|
|
203
182
|
test('should not distribute children with an invalid \'slot\' property', function () {
|
|
204
183
|
// Modify the console spy to silence error output with
|
|
205
184
|
// an empty mock implementation
|
|
206
185
|
console.error.mockImplementation();
|
|
207
|
-
|
|
208
186
|
function Component(_ref6) {
|
|
209
187
|
var a = _ref6.a,
|
|
210
|
-
|
|
211
|
-
|
|
188
|
+
b = _ref6.b,
|
|
189
|
+
children = _ref6.children;
|
|
212
190
|
var slots = (0, _useSlots["default"])({
|
|
213
191
|
a: a,
|
|
214
192
|
b: b,
|
|
@@ -219,7 +197,6 @@ describe('useSlots', function () {
|
|
|
219
197
|
children: [slots.c, slots.b, slots.a]
|
|
220
198
|
});
|
|
221
199
|
}
|
|
222
|
-
|
|
223
200
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
224
201
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
225
202
|
slot: "a",
|
|
@@ -233,12 +210,11 @@ describe('useSlots', function () {
|
|
|
233
210
|
})]
|
|
234
211
|
}));
|
|
235
212
|
var expected = 'BA';
|
|
236
|
-
|
|
237
213
|
var actual = _react.screen.getByTestId('useSlots');
|
|
238
|
-
|
|
239
214
|
expect(actual.textContent).toBe(expected);
|
|
240
|
-
expect(actual.textContent).toHaveLength(2);
|
|
215
|
+
expect(actual.textContent).toHaveLength(2);
|
|
241
216
|
|
|
217
|
+
// Check to make sure that we only get the one expected error
|
|
242
218
|
var actualErrorsLength = console.error.mock.calls.length;
|
|
243
219
|
var expectedErrorLength = 1;
|
|
244
220
|
expect(actualErrorsLength).toBe(expectedErrorLength);
|
|
@@ -249,10 +225,10 @@ describe('useSlots', function () {
|
|
|
249
225
|
test('should distribute children with props other than simply \'children\', in entirety, to the matching destination slot', function () {
|
|
250
226
|
function Component(_ref7) {
|
|
251
227
|
var a = _ref7.a,
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
228
|
+
b = _ref7.b,
|
|
229
|
+
c = _ref7.c,
|
|
230
|
+
children = _ref7.children,
|
|
231
|
+
custom = _ref7.custom;
|
|
256
232
|
var slots = (0, _useSlots["default"])({
|
|
257
233
|
a: a,
|
|
258
234
|
b: b,
|
|
@@ -266,7 +242,6 @@ describe('useSlots', function () {
|
|
|
266
242
|
children: [slots.c, slots.b, slots.a, slots.custom]
|
|
267
243
|
});
|
|
268
244
|
}
|
|
269
|
-
|
|
270
245
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
271
246
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
272
247
|
slot: "a",
|
|
@@ -282,20 +257,16 @@ describe('useSlots', function () {
|
|
|
282
257
|
})]
|
|
283
258
|
}));
|
|
284
259
|
var expected = 'CBD';
|
|
285
|
-
|
|
286
260
|
var actual = _react.screen.getByTestId('useSlots');
|
|
287
|
-
|
|
288
261
|
expect(actual.textContent).toBe(expected);
|
|
289
262
|
var expectedTitle = 'Div A';
|
|
290
|
-
|
|
291
263
|
var actualChild = _react.screen.getByTestId('useSlots').children[2];
|
|
292
|
-
|
|
293
264
|
expect(actualChild).toHaveAttribute('title', expectedTitle);
|
|
294
265
|
});
|
|
295
266
|
test('should distribute multiple children with the same slot into the same slot', function () {
|
|
296
267
|
function Component(_ref8) {
|
|
297
268
|
var a = _ref8.a,
|
|
298
|
-
|
|
269
|
+
children = _ref8.children;
|
|
299
270
|
var slots = (0, _useSlots["default"])({
|
|
300
271
|
a: a,
|
|
301
272
|
children: children
|
|
@@ -305,7 +276,6 @@ describe('useSlots', function () {
|
|
|
305
276
|
children: slots.a
|
|
306
277
|
});
|
|
307
278
|
}
|
|
308
|
-
|
|
309
279
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
310
280
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
311
281
|
slot: "a",
|
|
@@ -319,15 +289,13 @@ describe('useSlots', function () {
|
|
|
319
289
|
})]
|
|
320
290
|
}));
|
|
321
291
|
var expected = 'AAA';
|
|
322
|
-
|
|
323
292
|
var actual = _react.screen.getByTestId('useSlots');
|
|
324
|
-
|
|
325
293
|
expect(actual.textContent).toBe(expected);
|
|
326
294
|
});
|
|
327
295
|
test('should override prop with slot value', function () {
|
|
328
296
|
function Component(_ref9) {
|
|
329
297
|
var a = _ref9.a,
|
|
330
|
-
|
|
298
|
+
children = _ref9.children;
|
|
331
299
|
var slots = (0, _useSlots["default"])({
|
|
332
300
|
a: a,
|
|
333
301
|
children: children
|
|
@@ -337,7 +305,6 @@ describe('useSlots', function () {
|
|
|
337
305
|
children: slots.a
|
|
338
306
|
});
|
|
339
307
|
}
|
|
340
|
-
|
|
341
308
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
342
309
|
a: "B",
|
|
343
310
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -345,15 +312,13 @@ describe('useSlots', function () {
|
|
|
345
312
|
children: "A"
|
|
346
313
|
})
|
|
347
314
|
}));
|
|
348
|
-
|
|
349
315
|
var actual = _react.screen.getByTestId('useSlots');
|
|
350
|
-
|
|
351
316
|
expect(actual).toHaveTextContent('A');
|
|
352
317
|
});
|
|
353
318
|
test('should fallback to prop when slot is omitted', function () {
|
|
354
319
|
function Component(_ref10) {
|
|
355
320
|
var a = _ref10.a,
|
|
356
|
-
|
|
321
|
+
children = _ref10.children;
|
|
357
322
|
var slots = (0, _useSlots["default"])({
|
|
358
323
|
a: a,
|
|
359
324
|
children: children
|
|
@@ -363,13 +328,10 @@ describe('useSlots', function () {
|
|
|
363
328
|
children: slots.a
|
|
364
329
|
});
|
|
365
330
|
}
|
|
366
|
-
|
|
367
331
|
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
368
332
|
a: "B"
|
|
369
333
|
}));
|
|
370
|
-
|
|
371
334
|
var actual = _react.screen.getByTestId('useSlots');
|
|
372
|
-
|
|
373
335
|
expect(actual).toHaveTextContent('B');
|
|
374
336
|
});
|
|
375
337
|
});
|
package/Slottable/useSlots.js
CHANGED
|
@@ -5,25 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
exports.useSlots = useSlots;
|
|
8
|
-
|
|
9
8
|
var _react = require("react");
|
|
10
|
-
|
|
11
9
|
var _warning = _interopRequireDefault(require("warning"));
|
|
12
|
-
|
|
13
10
|
var _excluded = ["children"];
|
|
14
|
-
|
|
15
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
|
-
|
|
17
12
|
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
13
|
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
14
|
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
15
|
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; }
|
|
24
|
-
|
|
25
16
|
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; }
|
|
26
|
-
|
|
27
17
|
// ** WARNING ** This is an intentional but likely dangerous hack necessary to clone a child while
|
|
28
18
|
// omitting the `slot` property. It relies on the black box structure of a React element which could
|
|
29
19
|
// change breaking this code. Without it, the slot property will cascade to a DOM node causing a
|
|
@@ -34,20 +24,16 @@ function cloneElement(child, index) {
|
|
|
34
24
|
newProps.key = "slot-".concat(index);
|
|
35
25
|
return /*#__PURE__*/(0, _react.createElement)(child.type, newProps);
|
|
36
26
|
}
|
|
37
|
-
|
|
38
27
|
function distributeChild(child, index, slots, props) {
|
|
39
28
|
var c, slot;
|
|
40
|
-
|
|
41
29
|
var hasSlot = function hasSlot(name) {
|
|
42
30
|
return slots.indexOf(name) !== -1;
|
|
43
31
|
};
|
|
44
|
-
|
|
45
32
|
if (! /*#__PURE__*/(0, _react.isValidElement)(child)) {
|
|
46
33
|
return false;
|
|
47
34
|
} else if (child.props.slot) {
|
|
48
35
|
var hasUserSlot = hasSlot(slot = child.props.slot);
|
|
49
36
|
process.env.NODE_ENV !== "production" ? (0, _warning["default"])(hasUserSlot, 'The slot "%s" specified on %s does not exist', child.props.slot, typeof child.type === 'string' ? child.type : child.type.name || child.type.displayName || 'component') : void 0;
|
|
50
|
-
|
|
51
37
|
if (hasUserSlot) {
|
|
52
38
|
c = cloneElement(child, index);
|
|
53
39
|
}
|
|
@@ -55,17 +41,14 @@ function distributeChild(child, index, slots, props) {
|
|
|
55
41
|
c = child;
|
|
56
42
|
} else if (hasSlot(slot = child.type)) {
|
|
57
43
|
var propNames = Object.keys(child.props);
|
|
58
|
-
|
|
59
44
|
if (propNames.length === 1 && propNames[0] === 'children') {
|
|
60
45
|
c = child.props.children;
|
|
61
46
|
} else {
|
|
62
47
|
c = child;
|
|
63
48
|
}
|
|
64
49
|
}
|
|
65
|
-
|
|
66
50
|
if (c) {
|
|
67
51
|
var prop = props[slot];
|
|
68
|
-
|
|
69
52
|
if (prop) {
|
|
70
53
|
if (Array.isArray(prop)) {
|
|
71
54
|
prop.push(c);
|
|
@@ -75,48 +58,43 @@ function distributeChild(child, index, slots, props) {
|
|
|
75
58
|
} else {
|
|
76
59
|
prop = c;
|
|
77
60
|
}
|
|
78
|
-
|
|
79
61
|
props[slot] = prop;
|
|
80
62
|
return true;
|
|
81
63
|
}
|
|
82
|
-
|
|
83
64
|
return false;
|
|
84
65
|
}
|
|
85
|
-
|
|
86
66
|
function distribute(_ref) {
|
|
87
67
|
var children = _ref.children,
|
|
88
|
-
|
|
89
|
-
|
|
68
|
+
slots = _objectWithoutProperties(_ref, _excluded);
|
|
90
69
|
var slotNames = Object.keys(slots);
|
|
91
70
|
var props = {
|
|
92
71
|
children: children
|
|
93
72
|
};
|
|
94
|
-
|
|
95
73
|
if (slotNames.length > 0) {
|
|
96
74
|
var remaining = [];
|
|
97
|
-
|
|
98
75
|
_react.Children.forEach(children, function (child, index) {
|
|
99
76
|
if (!distributeChild(child, index, slotNames, props)) {
|
|
100
77
|
remaining.push(child);
|
|
101
78
|
}
|
|
102
|
-
});
|
|
103
|
-
// author spreads the return of useSlots over props
|
|
104
|
-
|
|
79
|
+
});
|
|
105
80
|
|
|
81
|
+
// we need to retain the children prop so that it can overwrite the value from props if the
|
|
82
|
+
// author spreads the return of useSlots over props
|
|
106
83
|
props.children = remaining.length === 0 ? null : remaining;
|
|
107
84
|
}
|
|
108
|
-
|
|
109
85
|
slotNames.forEach(function (slot) {
|
|
110
86
|
if (slots[slot] === undefined) {
|
|
111
87
|
// eslint-disable-line no-undefined
|
|
112
88
|
delete slots[slot];
|
|
113
89
|
}
|
|
114
|
-
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// We handle fallback here (rather than at the props initialization) because distributeChild
|
|
115
93
|
// will append to existing props and we want the distributed value to override the fallback
|
|
116
94
|
// value.
|
|
117
|
-
|
|
118
95
|
return _objectSpread(_objectSpread({}, slots), props);
|
|
119
96
|
}
|
|
97
|
+
|
|
120
98
|
/**
|
|
121
99
|
* Configuration for `useSlots`
|
|
122
100
|
*
|
|
@@ -175,11 +153,8 @@ function distribute(_ref) {
|
|
|
175
153
|
* @memberof ui/Slottable
|
|
176
154
|
* @private
|
|
177
155
|
*/
|
|
178
|
-
|
|
179
|
-
|
|
180
156
|
function useSlots(slots) {
|
|
181
157
|
return distribute(slots);
|
|
182
158
|
}
|
|
183
|
-
|
|
184
159
|
var _default = useSlots;
|
|
185
160
|
exports["default"] = _default;
|
package/Spinner/Spinner.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ changes the rendering tree and where this is used.
|
|
|
26
26
|
* * 'container' blocks up to the nearest ancestor with absolute or relative positioning
|
|
27
27
|
*
|
|
28
28
|
* When `blockClickOn` is either `'screen'` or `'container'` , a translucent scrim can be added
|
|
29
|
-
by setting
|
|
29
|
+
by setting prop to `true` .
|
|
30
30
|
*/
|
|
31
31
|
blockClickOn?: string | any;
|
|
32
32
|
/**
|
package/Spinner/Spinner.js
CHANGED
|
@@ -4,35 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.SpinnerDecorator = exports.SpinnerBase = exports.Spinner = void 0;
|
|
7
|
-
|
|
8
7
|
var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
|
|
9
|
-
|
|
10
8
|
var _kind = _interopRequireDefault(require("@enact/core/kind"));
|
|
11
|
-
|
|
12
9
|
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _FloatingLayer = _interopRequireDefault(require("../FloatingLayer"));
|
|
15
|
-
|
|
16
11
|
var _ForwardRef = _interopRequireDefault(require("../ForwardRef"));
|
|
17
|
-
|
|
18
12
|
var _SpinnerModule = _interopRequireDefault(require("./Spinner.module.css"));
|
|
19
|
-
|
|
20
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
-
|
|
22
14
|
var _excluded = ["blockClickOn", "component", "componentRef", "scrimClassName", "scrimType", "spinnerContainerClassName"];
|
|
23
|
-
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
|
-
|
|
26
16
|
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; }
|
|
27
|
-
|
|
28
17
|
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; }
|
|
29
|
-
|
|
30
18
|
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; }
|
|
31
|
-
|
|
32
19
|
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; }
|
|
33
|
-
|
|
34
20
|
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; }
|
|
35
|
-
|
|
36
21
|
/**
|
|
37
22
|
* A minimally styled component that controls `Spinner` positioning and interaction states, without
|
|
38
23
|
* [SpinnerDecorator](ui/Spinner.SpinnerDecorator) applied.
|
|
@@ -44,9 +29,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
44
29
|
*/
|
|
45
30
|
var SpinnerBase = (0, _kind["default"])({
|
|
46
31
|
name: 'ui:Spinner',
|
|
47
|
-
propTypes:
|
|
48
|
-
/** @lends ui/Spinner.SpinnerBase.prototype */
|
|
49
|
-
{
|
|
32
|
+
propTypes: /** @lends ui/Spinner.SpinnerBase.prototype */{
|
|
50
33
|
/**
|
|
51
34
|
* A theme-supplied component that performs the animation.
|
|
52
35
|
*
|
|
@@ -63,7 +46,6 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
63
46
|
* @public
|
|
64
47
|
*/
|
|
65
48
|
component: _propTypes["default"].renderable.isRequired,
|
|
66
|
-
|
|
67
49
|
/**
|
|
68
50
|
* Determines how far the click-blocking should extend.
|
|
69
51
|
*
|
|
@@ -72,13 +54,12 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
72
54
|
* * 'container' blocks up to the nearest ancestor with absolute or relative positioning
|
|
73
55
|
*
|
|
74
56
|
* When `blockClickOn` is either `'screen'` or `'container'`, a translucent scrim can be added
|
|
75
|
-
* by setting
|
|
57
|
+
* by setting {@link ui/Spinner.Spinner#scrim|scrim} prop to `true`.
|
|
76
58
|
*
|
|
77
59
|
* @type {String|null}
|
|
78
60
|
* @public
|
|
79
61
|
*/
|
|
80
62
|
blockClickOn: _propTypes2["default"].oneOf(['screen', 'container', null]),
|
|
81
|
-
|
|
82
63
|
/**
|
|
83
64
|
* Centers the spinner horizontally and vertically relative to its containing component.
|
|
84
65
|
*
|
|
@@ -87,7 +68,6 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
87
68
|
* @public
|
|
88
69
|
*/
|
|
89
70
|
centered: _propTypes2["default"].bool,
|
|
90
|
-
|
|
91
71
|
/**
|
|
92
72
|
* Called with a reference to the root component.
|
|
93
73
|
*
|
|
@@ -98,7 +78,6 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
98
78
|
* @public
|
|
99
79
|
*/
|
|
100
80
|
componentRef: _propTypes["default"].ref,
|
|
101
|
-
|
|
102
81
|
/**
|
|
103
82
|
* Customizes the component by mapping the supplied collection of CSS class names to the
|
|
104
83
|
* corresponding internal elements and states of this component.
|
|
@@ -116,7 +95,6 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
116
95
|
* @public
|
|
117
96
|
*/
|
|
118
97
|
css: _propTypes2["default"].object,
|
|
119
|
-
|
|
120
98
|
/**
|
|
121
99
|
* Halts the animation of the spinner
|
|
122
100
|
*
|
|
@@ -125,7 +103,6 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
125
103
|
* @public
|
|
126
104
|
*/
|
|
127
105
|
paused: _propTypes2["default"].bool,
|
|
128
|
-
|
|
129
106
|
/**
|
|
130
107
|
* Sets a scrim behind the spinner with the `css.scrim` class applied.
|
|
131
108
|
*
|
|
@@ -151,8 +128,8 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
151
128
|
computed: {
|
|
152
129
|
className: function className(_ref) {
|
|
153
130
|
var centered = _ref.centered,
|
|
154
|
-
|
|
155
|
-
|
|
131
|
+
paused = _ref.paused,
|
|
132
|
+
styler = _ref.styler;
|
|
156
133
|
return styler.append({
|
|
157
134
|
centered: centered,
|
|
158
135
|
running: !paused
|
|
@@ -160,8 +137,8 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
160
137
|
},
|
|
161
138
|
scrimClassName: function scrimClassName(_ref2) {
|
|
162
139
|
var blockClickOn = _ref2.blockClickOn,
|
|
163
|
-
|
|
164
|
-
|
|
140
|
+
scrim = _ref2.scrim,
|
|
141
|
+
styler = _ref2.styler;
|
|
165
142
|
return styler.join({
|
|
166
143
|
blockClickOn: blockClickOn,
|
|
167
144
|
scrim: scrim
|
|
@@ -173,8 +150,8 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
173
150
|
},
|
|
174
151
|
spinnerContainerClassName: function spinnerContainerClassName(_ref4) {
|
|
175
152
|
var blockClickOn = _ref4.blockClickOn,
|
|
176
|
-
|
|
177
|
-
|
|
153
|
+
centered = _ref4.centered,
|
|
154
|
+
styler = _ref4.styler;
|
|
178
155
|
return styler.join({
|
|
179
156
|
centered: centered,
|
|
180
157
|
spinnerContainer: blockClickOn
|
|
@@ -183,17 +160,15 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
183
160
|
},
|
|
184
161
|
render: function render(_ref5) {
|
|
185
162
|
var blockClickOn = _ref5.blockClickOn,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
163
|
+
Component = _ref5.component,
|
|
164
|
+
componentRef = _ref5.componentRef,
|
|
165
|
+
scrimClassName = _ref5.scrimClassName,
|
|
166
|
+
scrimType = _ref5.scrimType,
|
|
167
|
+
spinnerContainerClassName = _ref5.spinnerContainerClassName,
|
|
168
|
+
rest = _objectWithoutProperties(_ref5, _excluded);
|
|
193
169
|
delete rest.centered;
|
|
194
170
|
delete rest.paused;
|
|
195
171
|
delete rest.scrim;
|
|
196
|
-
|
|
197
172
|
switch (blockClickOn) {
|
|
198
173
|
case 'screen':
|
|
199
174
|
{
|
|
@@ -206,7 +181,6 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
206
181
|
}, rest))
|
|
207
182
|
});
|
|
208
183
|
}
|
|
209
|
-
|
|
210
184
|
case 'container':
|
|
211
185
|
{
|
|
212
186
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
@@ -218,7 +192,6 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
218
192
|
}, rest))]
|
|
219
193
|
});
|
|
220
194
|
}
|
|
221
|
-
|
|
222
195
|
default:
|
|
223
196
|
{
|
|
224
197
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, _objectSpread({
|
|
@@ -228,6 +201,7 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
228
201
|
}
|
|
229
202
|
}
|
|
230
203
|
});
|
|
204
|
+
|
|
231
205
|
/**
|
|
232
206
|
* Applies Spinner behaviors
|
|
233
207
|
*
|
|
@@ -237,11 +211,11 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
237
211
|
* @hoc
|
|
238
212
|
* @public
|
|
239
213
|
*/
|
|
240
|
-
|
|
241
214
|
exports.SpinnerBase = SpinnerBase;
|
|
242
215
|
var SpinnerDecorator = (0, _ForwardRef["default"])({
|
|
243
216
|
prop: 'componentRef'
|
|
244
217
|
});
|
|
218
|
+
|
|
245
219
|
/**
|
|
246
220
|
* A minimally styled component that controls `Spinner` positioning and interaction states.
|
|
247
221
|
*
|
|
@@ -253,7 +227,6 @@ var SpinnerDecorator = (0, _ForwardRef["default"])({
|
|
|
253
227
|
* @ui
|
|
254
228
|
* @public
|
|
255
229
|
*/
|
|
256
|
-
|
|
257
230
|
exports.SpinnerDecorator = SpinnerDecorator;
|
|
258
231
|
var Spinner = SpinnerDecorator(SpinnerBase);
|
|
259
232
|
exports.Spinner = Spinner;
|