@enact/ui 4.1.2 → 4.5.0-alpha.1
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 +9 -9
- package/AnnounceDecorator/AnnounceDecorator.js +6 -4
- package/AnnounceDecorator/tests/Announce-specs.js +13 -5
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +9 -7
- package/AnnounceDecorator/tests/useAnnounce-specs.js +25 -17
- package/AnnounceDecorator/useAnnounce.js +1 -1
- package/BodyText/BodyText.d.ts +1 -1
- package/BodyText/BodyText.js +6 -4
- package/BodyText/tests/BodyText-specs.js +51 -37
- package/Button/Button.d.ts +6 -6
- package/Button/Button.js +11 -7
- package/Button/tests/Button-specs.js +104 -3
- package/CHANGELOG.md +25 -0
- package/Cancelable/Cancelable.js +12 -11
- package/Cancelable/tests/Cancelable-specs.js +133 -70
- package/Changeable/Changeable.js +9 -9
- package/Changeable/tests/Changeable-specs.js +172 -110
- package/ComponentOverride/ComponentOverride.js +6 -4
- package/FloatingLayer/FloatingLayer.js +40 -49
- package/FloatingLayer/FloatingLayer.module.css +3 -0
- package/FloatingLayer/FloatingLayerContainer.js +2 -2
- package/FloatingLayer/FloatingLayerDecorator.js +6 -4
- package/FloatingLayer/Scrim.js +9 -7
- package/FloatingLayer/index.js +1 -1
- package/FloatingLayer/tests/FloatingLayer-specs.js +83 -8
- package/FloatingLayer/tests/Scrim-specs.js +20 -11
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +17 -11
- package/FloatingLayer/useFloatingLayer.js +2 -2
- package/FloatingLayer/useFloatingLayerDecorator.js +1 -1
- package/ForwardRef/ForwardRef.js +3 -3
- package/GridListImageItem/GridListImageItem.d.ts +1 -1
- package/GridListImageItem/GridListImageItem.js +6 -4
- package/Group/Group.d.ts +2 -2
- package/Group/Group.js +7 -4
- package/Group/GroupItem.js +6 -4
- package/Group/tests/Group-specs.js +73 -43
- package/Heading/Heading.d.ts +2 -1
- package/Heading/Heading.js +6 -4
- package/Heading/tests/Heading-specs.js +27 -20
- package/Icon/Icon.d.ts +4 -4
- package/Icon/Icon.js +6 -4
- package/Icon/tests/Icon-specs.js +54 -33
- package/IconButton/IconButton.d.ts +4 -4
- package/IconButton/IconButton.js +6 -4
- package/IconButton/tests/IconButton-specs.js +2 -2
- package/Image/Image.js +6 -4
- package/Image/tests/Image-specs.js +41 -31
- package/ImageItem/ImageItem.js +8 -5
- package/ImageItem/tests/ImageItem-specs.js +75 -72
- package/Item/Item.js +6 -4
- package/Item/tests/Item-specs.js +59 -35
- package/LabeledIcon/LabeledIcon.d.ts +4 -4
- package/LabeledIcon/LabeledIcon.js +6 -4
- package/LabeledIcon/tests/LabeledIcon-specs.js +30 -19
- package/Layout/Cell.js +6 -4
- package/Layout/Layout.d.ts +16 -16
- package/Layout/Layout.js +6 -4
- package/Layout/tests/Layout-specs.js +42 -30
- package/Marquee/MarqueeBase.js +7 -9
- package/Marquee/MarqueeController.js +9 -9
- package/Marquee/MarqueeDecorator.js +18 -13
- package/Marquee/index.d.ts +4 -1
- package/Marquee/index.js +2 -1
- package/Marquee/tests/Marquee-specs.js +254 -122
- package/Measurable/Measurable.js +4 -4
- package/Media/Media.js +10 -10
- package/Placeholder/PlaceholderControllerDecorator.js +9 -9
- package/Placeholder/PlaceholderDecorator.js +9 -9
- package/ProgressBar/ProgressBar.js +6 -4
- package/ProgressBar/tests/ProgressBar-specs.js +60 -42
- package/README.md +1 -1
- package/RadioDecorator/RadioControllerDecorator.js +9 -9
- package/RadioDecorator/RadioDecorator.js +12 -14
- package/RadioDecorator/tests/RadioDecorator-specs.js +179 -65
- package/Repeater/Repeater.d.ts +2 -1
- package/Repeater/Repeater.js +6 -4
- package/Repeater/tests/Repeater-specs.js +90 -49
- package/Resizable/Resizable.js +10 -10
- package/Routable/Link.js +9 -7
- package/Routable/Routable.d.ts +2 -2
- package/Routable/Routable.js +10 -6
- package/Routable/Route.js +1 -1
- package/Routable/Router.js +14 -11
- package/Routable/tests/Routable-specs.js +29 -20
- package/Routable/tests/Router-specs.js +65 -41
- package/Routable/useLink.js +1 -1
- package/Routable/util.js +1 -1
- package/Scrollable/ScrollAnimator.js +2 -2
- package/Scrollable/ScrollThumb.js +3 -3
- package/Scrollable/Scrollable.js +14 -10
- package/Scrollable/ScrollableNative.js +14 -10
- package/Scrollable/Scrollbar.js +14 -8
- package/Scroller/Scroller.d.ts +2 -14
- package/Scroller/Scroller.js +8 -7
- package/Scroller/ScrollerBasic.js +18 -35
- package/Scroller/UiScrollerBase.js +9 -7
- package/Skinnable/Skinnable.js +6 -4
- package/Skinnable/tests/Skinnable-specs.js +104 -56
- package/Skinnable/tests/useSkins-specs.js +39 -44
- package/Skinnable/useSkins.js +1 -1
- package/Slider/Knob.js +6 -4
- package/Slider/PositionDecorator.js +9 -9
- package/Slider/Slider.d.ts +3 -3
- package/Slider/Slider.js +6 -4
- package/Slider/tests/Slider-specs.js +4 -4
- package/SlotItem/SlotItem.d.ts +2 -2
- package/SlotItem/SlotItem.js +6 -4
- package/SlotItem/tests/SlotItem-specs.js +4 -4
- package/Slottable/Slottable.js +3 -3
- package/Slottable/tests/Slottable-specs.js +67 -36
- package/Slottable/tests/useSlots-specs.js +68 -35
- package/Slottable/useSlots.js +6 -4
- package/Spinner/Spinner.d.ts +1 -1
- package/Spinner/Spinner.js +6 -4
- package/Spinner/tests/Spinner-specs.js +46 -31
- package/ToggleIcon/ToggleIcon.js +6 -4
- package/ToggleIcon/tests/ToggleIcon-specs.js +32 -20
- package/ToggleItem/ToggleItem.d.ts +13 -11
- package/ToggleItem/ToggleItem.js +6 -4
- package/ToggleItem/tests/ToggleItem-specs.js +54 -37
- package/Toggleable/Toggle.js +10 -10
- package/Toggleable/Toggleable.js +11 -17
- package/Toggleable/tests/Toggleable-specs.js +464 -324
- package/Toggleable/useToggle.js +4 -2
- package/Touchable/ClickAllow.js +2 -2
- package/Touchable/Drag.js +22 -22
- package/Touchable/Flick.js +22 -18
- package/Touchable/Hold.js +18 -23
- package/Touchable/Touch.js +2 -2
- package/Touchable/Touchable.d.ts +3 -3
- package/Touchable/Touchable.js +7 -4
- package/Touchable/config.js +3 -3
- package/Touchable/tests/Touchable-specs.js +225 -109
- package/Touchable/tests/useTouch-specs.js +163 -86
- package/Touchable/useTouch.js +4 -4
- package/Transition/Transition.d.ts +29 -27
- package/Transition/Transition.js +22 -17
- package/Transition/tests/Transition-specs.js +116 -36
- package/ViewManager/Arranger.js +3 -3
- package/ViewManager/TransitionGroup.js +10 -9
- package/ViewManager/View.js +7 -7
- package/ViewManager/ViewManager.d.ts +4 -4
- package/ViewManager/ViewManager.js +24 -22
- package/ViewManager/tests/View-specs.js +141 -81
- package/ViewManager/tests/ViewManager-specs.js +486 -193
- package/VirtualList/UiVirtualListBase.js +26 -35
- package/VirtualList/VirtualList.d.ts +11 -29
- package/VirtualList/VirtualList.js +10 -9
- package/VirtualList/VirtualListBase.js +1 -1
- package/VirtualList/VirtualListBasic.js +44 -61
- package/VirtualList/tests/VirtualList-specs.js +81 -95
- package/internal/IdProvider/IdProvider.js +3 -3
- package/internal/IdProvider/Provider.js +2 -2
- package/internal/IdProvider/tests/useId-specs.js +37 -20
- package/internal/Pure/Pure.js +9 -9
- package/internal/localized-fonts/localized-fonts.js +1 -1
- package/internal/validators/validators.js +1 -1
- package/package.json +11 -11
- package/resolution/ResolutionDecorator.js +9 -9
- package/resolution/index.js +2 -2
- package/resolution/resolution.js +4 -2
- package/resolution/tests/ResolutionDecorator-specs.js +17 -8
- package/styles/mixins.less +14 -2
- package/useControlledState/tests/useControlledState-specs.js +68 -43
- package/useControlledState/useControlledState.js +2 -2
- package/useScroll/ScrollAnimator.js +2 -2
- package/useScroll/Scrollbar.js +7 -4
- package/useScroll/ScrollbarTrack.js +6 -4
- package/useScroll/useScroll.js +18 -29
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
|
+
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
4
6
|
|
|
5
7
|
var _useSlots = _interopRequireDefault(require("../useSlots"));
|
|
6
8
|
|
|
@@ -23,11 +25,12 @@ describe('useSlots', function () {
|
|
|
23
25
|
children: children
|
|
24
26
|
});
|
|
25
27
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
28
|
+
"data-testid": "useSlots",
|
|
26
29
|
children: [slots.c, slots.b, slots.a]
|
|
27
30
|
});
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
|
|
33
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
31
34
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
32
35
|
slot: "a",
|
|
33
36
|
children: "A"
|
|
@@ -40,8 +43,10 @@ describe('useSlots', function () {
|
|
|
40
43
|
})]
|
|
41
44
|
}));
|
|
42
45
|
var expected = 'CBA';
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
|
|
47
|
+
var actual = _react.screen.getByTestId('useSlots');
|
|
48
|
+
|
|
49
|
+
expect(actual.textContent).toBe(expected);
|
|
45
50
|
});
|
|
46
51
|
test('should have no children when all have been distributed', function () {
|
|
47
52
|
function Component(_ref2) {
|
|
@@ -56,11 +61,12 @@ describe('useSlots', function () {
|
|
|
56
61
|
children: children
|
|
57
62
|
});
|
|
58
63
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
64
|
+
"data-testid": "useSlots",
|
|
59
65
|
children: slots.children
|
|
60
66
|
});
|
|
61
67
|
}
|
|
62
68
|
|
|
63
|
-
|
|
69
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
64
70
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
65
71
|
slot: "a",
|
|
66
72
|
children: "A"
|
|
@@ -73,8 +79,10 @@ describe('useSlots', function () {
|
|
|
73
79
|
})]
|
|
74
80
|
}));
|
|
75
81
|
var expected = '';
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
|
|
83
|
+
var actual = _react.screen.getByTestId('useSlots');
|
|
84
|
+
|
|
85
|
+
expect(actual).toHaveTextContent(expected);
|
|
78
86
|
});
|
|
79
87
|
test('should distribute children with a \'type\' that matches a slot', function () {
|
|
80
88
|
function Component(_ref3) {
|
|
@@ -91,11 +99,12 @@ describe('useSlots', function () {
|
|
|
91
99
|
custom: custom
|
|
92
100
|
});
|
|
93
101
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
102
|
+
"data-testid": "useSlots",
|
|
94
103
|
children: [slots.c, slots.b, slots.a, slots.custom]
|
|
95
104
|
});
|
|
96
105
|
}
|
|
97
106
|
|
|
98
|
-
|
|
107
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
99
108
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
100
109
|
slot: "a",
|
|
101
110
|
children: "A"
|
|
@@ -110,8 +119,10 @@ describe('useSlots', function () {
|
|
|
110
119
|
})]
|
|
111
120
|
}));
|
|
112
121
|
var expected = 'CBAD';
|
|
113
|
-
|
|
114
|
-
|
|
122
|
+
|
|
123
|
+
var actual = _react.screen.getByTestId('useSlots');
|
|
124
|
+
|
|
125
|
+
expect(actual.textContent).toBe(expected);
|
|
115
126
|
});
|
|
116
127
|
test('should distribute children whose \'type\' has a \'defaultSlot\' property that matches a slot', function () {
|
|
117
128
|
function Custom(props) {
|
|
@@ -134,11 +145,12 @@ describe('useSlots', function () {
|
|
|
134
145
|
children: children
|
|
135
146
|
});
|
|
136
147
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
148
|
+
"data-testid": "useSlots",
|
|
137
149
|
children: [slots.c, slots.b, slots.a]
|
|
138
150
|
});
|
|
139
151
|
}
|
|
140
152
|
|
|
141
|
-
|
|
153
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
142
154
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
143
155
|
slot: "a",
|
|
144
156
|
children: "A"
|
|
@@ -150,8 +162,10 @@ describe('useSlots', function () {
|
|
|
150
162
|
})]
|
|
151
163
|
}));
|
|
152
164
|
var expected = 'CBA';
|
|
153
|
-
|
|
154
|
-
|
|
165
|
+
|
|
166
|
+
var actual = _react.screen.getByTestId('useSlots');
|
|
167
|
+
|
|
168
|
+
expect(actual.textContent).toBe(expected);
|
|
155
169
|
});
|
|
156
170
|
test('should distribute children with no \'slot\' property to Slottable\'s \'children\'', function () {
|
|
157
171
|
function Component(_ref5) {
|
|
@@ -164,11 +178,12 @@ describe('useSlots', function () {
|
|
|
164
178
|
children: children
|
|
165
179
|
});
|
|
166
180
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
181
|
+
"data-testid": "useSlots",
|
|
167
182
|
children: [slots.children, slots.b, slots.a]
|
|
168
183
|
});
|
|
169
184
|
}
|
|
170
185
|
|
|
171
|
-
|
|
186
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
172
187
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
173
188
|
slot: "a",
|
|
174
189
|
children: "A"
|
|
@@ -180,8 +195,10 @@ describe('useSlots', function () {
|
|
|
180
195
|
})]
|
|
181
196
|
}));
|
|
182
197
|
var expected = 'CBA';
|
|
183
|
-
|
|
184
|
-
|
|
198
|
+
|
|
199
|
+
var actual = _react.screen.getByTestId('useSlots');
|
|
200
|
+
|
|
201
|
+
expect(actual.textContent).toBe(expected);
|
|
185
202
|
});
|
|
186
203
|
test('should not distribute children with an invalid \'slot\' property', function () {
|
|
187
204
|
// Modify the console spy to silence error output with
|
|
@@ -198,11 +215,12 @@ describe('useSlots', function () {
|
|
|
198
215
|
children: children
|
|
199
216
|
});
|
|
200
217
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
218
|
+
"data-testid": "useSlots",
|
|
201
219
|
children: [slots.c, slots.b, slots.a]
|
|
202
220
|
});
|
|
203
221
|
}
|
|
204
222
|
|
|
205
|
-
|
|
223
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
206
224
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
207
225
|
slot: "a",
|
|
208
226
|
children: "A"
|
|
@@ -215,8 +233,11 @@ describe('useSlots', function () {
|
|
|
215
233
|
})]
|
|
216
234
|
}));
|
|
217
235
|
var expected = 'BA';
|
|
218
|
-
|
|
219
|
-
|
|
236
|
+
|
|
237
|
+
var actual = _react.screen.getByTestId('useSlots');
|
|
238
|
+
|
|
239
|
+
expect(actual.textContent).toBe(expected);
|
|
240
|
+
expect(actual.textContent).toHaveLength(2); // Check to make sure that we only get the one expected error
|
|
220
241
|
|
|
221
242
|
var actualErrorsLength = console.error.mock.calls.length;
|
|
222
243
|
var expectedErrorLength = 1;
|
|
@@ -241,11 +262,12 @@ describe('useSlots', function () {
|
|
|
241
262
|
});
|
|
242
263
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
243
264
|
className: "root-div",
|
|
265
|
+
"data-testid": "useSlots",
|
|
244
266
|
children: [slots.c, slots.b, slots.a, slots.custom]
|
|
245
267
|
});
|
|
246
268
|
}
|
|
247
269
|
|
|
248
|
-
|
|
270
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
249
271
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
250
272
|
slot: "a",
|
|
251
273
|
title: "Div A"
|
|
@@ -260,11 +282,15 @@ describe('useSlots', function () {
|
|
|
260
282
|
})]
|
|
261
283
|
}));
|
|
262
284
|
var expected = 'CBD';
|
|
263
|
-
|
|
264
|
-
|
|
285
|
+
|
|
286
|
+
var actual = _react.screen.getByTestId('useSlots');
|
|
287
|
+
|
|
288
|
+
expect(actual.textContent).toBe(expected);
|
|
265
289
|
var expectedTitle = 'Div A';
|
|
266
|
-
|
|
267
|
-
|
|
290
|
+
|
|
291
|
+
var actualChild = _react.screen.getByTestId('useSlots').children[2];
|
|
292
|
+
|
|
293
|
+
expect(actualChild).toHaveAttribute('title', expectedTitle);
|
|
268
294
|
});
|
|
269
295
|
test('should distribute multiple children with the same slot into the same slot', function () {
|
|
270
296
|
function Component(_ref8) {
|
|
@@ -275,11 +301,12 @@ describe('useSlots', function () {
|
|
|
275
301
|
children: children
|
|
276
302
|
});
|
|
277
303
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
304
|
+
"data-testid": "useSlots",
|
|
278
305
|
children: slots.a
|
|
279
306
|
});
|
|
280
307
|
}
|
|
281
308
|
|
|
282
|
-
|
|
309
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(Component, {
|
|
283
310
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
284
311
|
slot: "a",
|
|
285
312
|
children: "A"
|
|
@@ -292,8 +319,10 @@ describe('useSlots', function () {
|
|
|
292
319
|
})]
|
|
293
320
|
}));
|
|
294
321
|
var expected = 'AAA';
|
|
295
|
-
|
|
296
|
-
|
|
322
|
+
|
|
323
|
+
var actual = _react.screen.getByTestId('useSlots');
|
|
324
|
+
|
|
325
|
+
expect(actual.textContent).toBe(expected);
|
|
297
326
|
});
|
|
298
327
|
test('should override prop with slot value', function () {
|
|
299
328
|
function Component(_ref9) {
|
|
@@ -304,20 +333,22 @@ describe('useSlots', function () {
|
|
|
304
333
|
children: children
|
|
305
334
|
});
|
|
306
335
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
336
|
+
"data-testid": "useSlots",
|
|
307
337
|
children: slots.a
|
|
308
338
|
});
|
|
309
339
|
}
|
|
310
340
|
|
|
311
|
-
|
|
341
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
312
342
|
a: "B",
|
|
313
343
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
314
344
|
slot: "a",
|
|
315
345
|
children: "A"
|
|
316
346
|
})
|
|
317
347
|
}));
|
|
318
|
-
|
|
319
|
-
var actual =
|
|
320
|
-
|
|
348
|
+
|
|
349
|
+
var actual = _react.screen.getByTestId('useSlots');
|
|
350
|
+
|
|
351
|
+
expect(actual).toHaveTextContent('A');
|
|
321
352
|
});
|
|
322
353
|
test('should fallback to prop when slot is omitted', function () {
|
|
323
354
|
function Component(_ref10) {
|
|
@@ -328,15 +359,17 @@ describe('useSlots', function () {
|
|
|
328
359
|
children: children
|
|
329
360
|
});
|
|
330
361
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
362
|
+
"data-testid": "useSlots",
|
|
331
363
|
children: slots.a
|
|
332
364
|
});
|
|
333
365
|
}
|
|
334
366
|
|
|
335
|
-
|
|
367
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
336
368
|
a: "B"
|
|
337
369
|
}));
|
|
338
|
-
|
|
339
|
-
var actual =
|
|
340
|
-
|
|
370
|
+
|
|
371
|
+
var actual = _react.screen.getByTestId('useSlots');
|
|
372
|
+
|
|
373
|
+
expect(actual).toHaveTextContent('B');
|
|
341
374
|
});
|
|
342
375
|
});
|
package/Slottable/useSlots.js
CHANGED
|
@@ -3,18 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useSlots = useSlots;
|
|
7
6
|
exports["default"] = void 0;
|
|
7
|
+
exports.useSlots = useSlots;
|
|
8
8
|
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
|
|
11
11
|
var _warning = _interopRequireDefault(require("warning"));
|
|
12
12
|
|
|
13
|
+
var _excluded = ["children"];
|
|
14
|
+
|
|
13
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
16
|
|
|
15
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
17
|
+
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; }
|
|
16
18
|
|
|
17
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
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; }
|
|
18
20
|
|
|
19
21
|
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; }
|
|
20
22
|
|
|
@@ -83,7 +85,7 @@ function distributeChild(child, index, slots, props) {
|
|
|
83
85
|
|
|
84
86
|
function distribute(_ref) {
|
|
85
87
|
var children = _ref.children,
|
|
86
|
-
slots = _objectWithoutProperties(_ref,
|
|
88
|
+
slots = _objectWithoutProperties(_ref, _excluded);
|
|
87
89
|
|
|
88
90
|
var slotNames = Object.keys(slots);
|
|
89
91
|
var props = {
|
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 [scrim] prop to `true` .
|
|
30
30
|
*/
|
|
31
31
|
blockClickOn?: string | any;
|
|
32
32
|
/**
|
package/Spinner/Spinner.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SpinnerDecorator = exports.SpinnerBase = exports.Spinner =
|
|
6
|
+
exports["default"] = exports.SpinnerDecorator = exports.SpinnerBase = exports.Spinner = void 0;
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
|
|
9
9
|
|
|
@@ -19,11 +19,13 @@ var _SpinnerModule = _interopRequireDefault(require("./Spinner.module.css"));
|
|
|
19
19
|
|
|
20
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
21
|
|
|
22
|
+
var _excluded = ["blockClickOn", "component", "componentRef", "scrimClassName", "scrimType", "spinnerContainerClassName"];
|
|
23
|
+
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
25
|
|
|
24
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
26
|
+
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; }
|
|
25
27
|
|
|
26
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
28
|
+
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; }
|
|
27
29
|
|
|
28
30
|
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; }
|
|
29
31
|
|
|
@@ -186,7 +188,7 @@ var SpinnerBase = (0, _kind["default"])({
|
|
|
186
188
|
scrimClassName = _ref5.scrimClassName,
|
|
187
189
|
scrimType = _ref5.scrimType,
|
|
188
190
|
spinnerContainerClassName = _ref5.spinnerContainerClassName,
|
|
189
|
-
rest = _objectWithoutProperties(_ref5,
|
|
191
|
+
rest = _objectWithoutProperties(_ref5, _excluded);
|
|
190
192
|
|
|
191
193
|
delete rest.centered;
|
|
192
194
|
delete rest.paused;
|
|
@@ -1,62 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
|
+
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
4
6
|
|
|
5
7
|
var _Spinner = require("../Spinner");
|
|
6
8
|
|
|
7
|
-
var
|
|
9
|
+
var _FloatingLayer = require("../../FloatingLayer");
|
|
8
10
|
|
|
9
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
12
|
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
-
|
|
13
13
|
describe('Spinner Specs', function () {
|
|
14
14
|
test('should have centered class when centered prop equals true', function () {
|
|
15
|
-
|
|
16
|
-
component: "div",
|
|
15
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.SpinnerBase, {
|
|
17
16
|
centered: true,
|
|
17
|
+
component: "div",
|
|
18
18
|
children: "Loading..."
|
|
19
19
|
}));
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
|
|
20
|
+
|
|
21
|
+
var spinner = _react.screen.getByText('Loading...');
|
|
22
|
+
|
|
23
|
+
var expected = 'centered';
|
|
24
|
+
expect(spinner).toHaveClass(expected);
|
|
23
25
|
});
|
|
24
26
|
test('should not have content class when Spinner has no children', function () {
|
|
25
|
-
|
|
26
|
-
component: "div"
|
|
27
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.SpinnerBase, {
|
|
28
|
+
component: "div",
|
|
29
|
+
"data-testid": "spinner"
|
|
27
30
|
}));
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
var spinner = _react.screen.getByTestId('spinner');
|
|
33
|
+
|
|
34
|
+
var expected = 'content';
|
|
35
|
+
expect(spinner).not.toHaveClass(expected);
|
|
31
36
|
});
|
|
32
37
|
test('should have no scrim class when blockClickOn prop equals container', function () {
|
|
33
|
-
|
|
38
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.SpinnerBase, {
|
|
39
|
+
blockClickOn: "container",
|
|
34
40
|
component: "div",
|
|
35
|
-
|
|
41
|
+
"data-testid": "spinner"
|
|
36
42
|
}));
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
43
|
+
|
|
44
|
+
var spinnerContainer = _react.screen.getByTestId('spinner').previousElementSibling;
|
|
45
|
+
|
|
46
|
+
var expected = 'scrim';
|
|
47
|
+
expect(spinnerContainer).not.toHaveClass(expected);
|
|
40
48
|
});
|
|
41
49
|
test('should have scrim class when blockClickOn prop equals container and when scrim prop equals true', function () {
|
|
42
|
-
|
|
43
|
-
component: "div",
|
|
50
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.SpinnerBase, {
|
|
44
51
|
blockClickOn: "container",
|
|
52
|
+
component: "div",
|
|
53
|
+
"data-testid": "spinner",
|
|
45
54
|
scrim: true
|
|
46
55
|
}));
|
|
47
|
-
|
|
48
|
-
var
|
|
49
|
-
|
|
56
|
+
|
|
57
|
+
var spinnerContainer = _react.screen.getByTestId('spinner').previousElementSibling;
|
|
58
|
+
|
|
59
|
+
var expected = 'scrim';
|
|
60
|
+
expect(spinnerContainer).toHaveClass(expected);
|
|
50
61
|
});
|
|
51
62
|
test('should have FloatingLayer when blockClickOn prop equals screen', function () {
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
var Root = (0, _FloatingLayer.FloatingLayerDecorator)('div');
|
|
64
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, {
|
|
65
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.SpinnerBase, {
|
|
66
|
+
blockClickOn: "screen",
|
|
67
|
+
component: "div",
|
|
68
|
+
"data-testid": "spinner"
|
|
69
|
+
})
|
|
55
70
|
}));
|
|
56
|
-
var expected = true; // FloatingLayer is wrapped by Cancelable so it's undiscoverable by name with shallow
|
|
57
|
-
// mounting
|
|
58
71
|
|
|
59
|
-
var
|
|
60
|
-
|
|
72
|
+
var spinner = _react.screen.getByTestId('spinner');
|
|
73
|
+
|
|
74
|
+
expect(spinner).toBeInTheDocument();
|
|
75
|
+
expect(spinner.parentElement.parentElement.id).toBe('floatLayer');
|
|
61
76
|
});
|
|
62
77
|
});
|
package/ToggleIcon/ToggleIcon.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.ToggleIconDecorator = exports.ToggleIconBase = exports.ToggleIcon =
|
|
6
|
+
exports["default"] = exports.ToggleIconDecorator = exports.ToggleIconBase = exports.ToggleIcon = void 0;
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("@enact/core/internal/prop-types"));
|
|
9
9
|
|
|
@@ -23,11 +23,13 @@ var _ToggleIconModule = _interopRequireDefault(require("./ToggleIcon.module.css"
|
|
|
23
23
|
|
|
24
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
25
|
|
|
26
|
+
var _excluded = ["children", "componentRef", "iconComponent", "iconClassName"];
|
|
27
|
+
|
|
26
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
27
29
|
|
|
28
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
30
|
+
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; }
|
|
29
31
|
|
|
30
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
32
|
+
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; }
|
|
31
33
|
|
|
32
34
|
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; }
|
|
33
35
|
|
|
@@ -147,7 +149,7 @@ var ToggleIconBase = (0, _kind["default"])({
|
|
|
147
149
|
componentRef = _ref3.componentRef,
|
|
148
150
|
IconComponent = _ref3.iconComponent,
|
|
149
151
|
iconClassName = _ref3.iconClassName,
|
|
150
|
-
rest = _objectWithoutProperties(_ref3,
|
|
152
|
+
rest = _objectWithoutProperties(_ref3, _excluded);
|
|
151
153
|
|
|
152
154
|
delete rest.selected;
|
|
153
155
|
delete rest.iconClasses;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
4
|
+
|
|
5
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
4
6
|
|
|
5
7
|
var _ToggleIcon = _interopRequireDefault(require("../ToggleIcon"));
|
|
6
8
|
|
|
@@ -9,59 +11,69 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
9
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
12
|
|
|
11
13
|
var tap = function tap(node) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
_react.fireEvent.mouseDown(node);
|
|
15
|
+
|
|
16
|
+
_react.fireEvent.mouseUp(node);
|
|
14
17
|
};
|
|
15
18
|
|
|
16
19
|
describe('ToggleIcon Specs', function () {
|
|
17
20
|
test('should call onToggle when tapped', function () {
|
|
18
21
|
var handleToggle = jest.fn();
|
|
19
|
-
|
|
22
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleIcon["default"], {
|
|
20
23
|
onToggle: handleToggle,
|
|
21
24
|
children: "star"
|
|
22
25
|
}));
|
|
23
|
-
|
|
26
|
+
|
|
27
|
+
var toggleIcon = _react.screen.getByText('star');
|
|
28
|
+
|
|
29
|
+
tap(toggleIcon);
|
|
24
30
|
var expected = 1;
|
|
25
|
-
|
|
26
|
-
expect(expected).toBe(actual);
|
|
31
|
+
expect(handleToggle).toHaveBeenCalledTimes(expected);
|
|
27
32
|
});
|
|
28
33
|
test('should call onClick when clicked', function () {
|
|
29
34
|
var handleClick = jest.fn();
|
|
30
|
-
|
|
35
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleIcon["default"], {
|
|
31
36
|
onClick: handleClick,
|
|
32
37
|
children: "star"
|
|
33
38
|
}));
|
|
34
|
-
|
|
39
|
+
|
|
40
|
+
var toggleIcon = _react.screen.getByText('star');
|
|
41
|
+
|
|
42
|
+
_userEvent["default"].click(toggleIcon);
|
|
43
|
+
|
|
35
44
|
var expected = 1;
|
|
36
|
-
|
|
37
|
-
expect(expected).toBe(actual);
|
|
45
|
+
expect(handleClick).toHaveBeenCalledTimes(expected);
|
|
38
46
|
});
|
|
39
47
|
test('should call onTap when tapped', function () {
|
|
40
48
|
var handleTap = jest.fn();
|
|
41
|
-
|
|
49
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleIcon["default"], {
|
|
42
50
|
onTap: handleTap,
|
|
43
51
|
children: "star"
|
|
44
52
|
}));
|
|
45
|
-
|
|
53
|
+
|
|
54
|
+
var toggleIcon = _react.screen.getByText('star');
|
|
55
|
+
|
|
56
|
+
tap(toggleIcon);
|
|
46
57
|
var expected = 1;
|
|
47
|
-
|
|
48
|
-
expect(expected).toBe(actual);
|
|
58
|
+
expect(handleTap).toHaveBeenCalledTimes(expected);
|
|
49
59
|
});
|
|
50
60
|
test('should call both onToggle and onTap when tapped', function () {
|
|
51
61
|
var handleBoth = jest.fn();
|
|
52
|
-
|
|
62
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleIcon["default"], {
|
|
53
63
|
onTap: handleBoth,
|
|
54
64
|
onToggle: handleBoth,
|
|
55
65
|
children: "star"
|
|
56
66
|
}));
|
|
57
|
-
|
|
67
|
+
|
|
68
|
+
var toggleIcon = _react.screen.getByText('star');
|
|
69
|
+
|
|
70
|
+
tap(toggleIcon);
|
|
58
71
|
var expected = 2;
|
|
59
|
-
|
|
60
|
-
expect(expected).toBe(actual);
|
|
72
|
+
expect(handleBoth).toHaveBeenCalledTimes(expected);
|
|
61
73
|
});
|
|
62
74
|
test('should return a DOM node reference for `componentRef`', function () {
|
|
63
75
|
var ref = jest.fn();
|
|
64
|
-
(0,
|
|
76
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleIcon["default"], {
|
|
65
77
|
ref: ref,
|
|
66
78
|
children: "star"
|
|
67
79
|
}));
|
|
@@ -18,7 +18,7 @@ export interface ToggleItemBaseProps {
|
|
|
18
18
|
*
|
|
19
19
|
* This receives the `css` prop for theme extension and therefore must be a custom
|
|
20
20
|
component and not a simple HTML DOM node. Recommended component or themed
|
|
21
|
-
derivative:
|
|
21
|
+
derivative: [SlotItem]
|
|
22
22
|
*/
|
|
23
23
|
component: React.ComponentType;
|
|
24
24
|
/**
|
|
@@ -26,7 +26,7 @@ derivative: SlotItem
|
|
|
26
26
|
*
|
|
27
27
|
* This component receives the `selected` prop and value,
|
|
28
28
|
and must therefore respond to it in some way. It is recommended to use
|
|
29
|
-
|
|
29
|
+
[ToggleIcon] for this.
|
|
30
30
|
*/
|
|
31
31
|
iconComponent: React.ComponentType | JSX.Element;
|
|
32
32
|
/**
|
|
@@ -51,7 +51,7 @@ corresponding internal elements and states of this component.
|
|
|
51
51
|
/**
|
|
52
52
|
* An optional prop that lets you override the icon of the `iconComponent` component.
|
|
53
53
|
*
|
|
54
|
-
* This accepts any string that the
|
|
54
|
+
* This accepts any string that the [Icon] component supports, provided
|
|
55
55
|
the recommendations of `iconComponent` are followed.
|
|
56
56
|
*/
|
|
57
57
|
icon?: string | object;
|
|
@@ -68,14 +68,16 @@ or behind the existing `icon` . See `itemIconPosition` for options.
|
|
|
68
68
|
*/
|
|
69
69
|
itemIcon?: React.ReactNode;
|
|
70
70
|
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
after`
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
* Specifies where `itemIcon` appears.
|
|
72
|
+
* * `'before'` - first element in the item
|
|
73
|
+
* * `'beforeChildren'` - before `children` . If `iconPosition` is `'before'` , `icon` will be
|
|
74
|
+
*
|
|
75
|
+
* before `itemIcon`
|
|
76
|
+
* * `'afterChildren'` - after `children` . If iconPosition `is` 'after' `, ` icon` will be
|
|
77
|
+
*
|
|
78
|
+
* after `itemIcon`
|
|
79
|
+
* * `'after'` - the last element in the item
|
|
80
|
+
*/
|
|
79
81
|
itemIconPosition?: "before" | "beforeChildren" | "afterChildren" | "after";
|
|
80
82
|
/**
|
|
81
83
|
* Called when the toggle item is toggled. Developers should generally use `onToggle` instead.
|