@enact/ui 4.1.0 → 4.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AnnounceDecorator/tests/Announce-specs.js +13 -5
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +9 -7
- package/AnnounceDecorator/tests/useAnnounce-specs.js +25 -17
- package/BodyText/BodyText.d.ts +1 -1
- package/BodyText/tests/BodyText-specs.js +49 -35
- package/Button/Button.d.ts +6 -6
- package/Button/tests/Button-specs.js +104 -3
- package/CHANGELOG.md +15 -0
- package/Cancelable/Cancelable.js +1 -1
- package/Cancelable/tests/Cancelable-specs.js +131 -70
- package/Changeable/tests/Changeable-specs.js +162 -110
- package/FloatingLayer/FloatingLayer.js +5 -17
- package/FloatingLayer/tests/FloatingLayer-specs.js +83 -8
- package/FloatingLayer/tests/Scrim-specs.js +20 -11
- package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +15 -9
- package/GridListImageItem/GridListImageItem.d.ts +1 -1
- package/Group/Group.d.ts +2 -2
- package/Group/tests/Group-specs.js +71 -41
- package/Heading/Heading.d.ts +2 -1
- package/Heading/tests/Heading-specs.js +27 -20
- package/Icon/Icon.d.ts +4 -4
- package/Icon/tests/Icon-specs.js +52 -31
- package/IconButton/IconButton.d.ts +4 -4
- package/IconButton/tests/IconButton-specs.js +2 -2
- package/Image/tests/Image-specs.js +39 -29
- package/ImageItem/tests/ImageItem-specs.js +71 -68
- package/Item/tests/Item-specs.js +59 -35
- package/LabeledIcon/LabeledIcon.d.ts +4 -4
- package/LabeledIcon/tests/LabeledIcon-specs.js +30 -19
- package/Layout/Layout.d.ts +16 -16
- package/Layout/tests/Layout-specs.js +37 -25
- package/Marquee/MarqueeBase.js +1 -5
- package/Marquee/tests/Marquee-specs.js +221 -116
- package/Media/Media.js +1 -3
- package/ProgressBar/tests/ProgressBar-specs.js +60 -42
- package/README.md +1 -1
- package/RadioDecorator/RadioDecorator.js +3 -5
- package/RadioDecorator/tests/RadioDecorator-specs.js +179 -65
- package/Repeater/Repeater.d.ts +2 -1
- package/Repeater/tests/Repeater-specs.js +86 -45
- package/Routable/Routable.d.ts +2 -2
- package/Routable/tests/Routable-specs.js +26 -17
- package/Routable/tests/Router-specs.js +65 -41
- package/Scrollable/Scrollable.js +2 -1
- package/Scrollable/ScrollableNative.js +2 -1
- package/Scroller/Scroller.d.ts +2 -2
- package/Scroller/ScrollerBasic.js +1 -1
- package/Scroller/UiScrollerBase.js +1 -1
- package/Skinnable/tests/Skinnable-specs.js +102 -54
- package/Skinnable/tests/useSkins-specs.js +37 -42
- package/Slider/Slider.d.ts +3 -3
- package/Slider/tests/Slider-specs.js +4 -4
- package/SlotItem/SlotItem.d.ts +2 -2
- package/SlotItem/tests/SlotItem-specs.js +4 -4
- package/Slottable/tests/Slottable-specs.js +67 -36
- package/Slottable/tests/useSlots-specs.js +68 -35
- package/Spinner/Spinner.d.ts +1 -1
- package/Spinner/tests/Spinner-specs.js +46 -31
- package/ToggleIcon/tests/ToggleIcon-specs.js +32 -20
- package/ToggleItem/ToggleItem.d.ts +13 -11
- package/ToggleItem/tests/ToggleItem-specs.js +51 -34
- package/Toggleable/Toggle.js +6 -6
- package/Toggleable/Toggleable.js +6 -12
- package/Toggleable/tests/Toggleable-specs.js +428 -324
- package/Touchable/Drag.js +13 -17
- package/Touchable/Flick.js +20 -16
- package/Touchable/Hold.js +14 -19
- package/Touchable/Touchable.d.ts +3 -3
- package/Touchable/tests/Touchable-specs.js +223 -109
- package/Touchable/tests/useTouch-specs.js +159 -84
- package/Transition/Transition.d.ts +29 -27
- package/Transition/Transition.js +5 -9
- package/Transition/tests/Transition-specs.js +135 -31
- package/ViewManager/TransitionGroup.js +6 -5
- package/ViewManager/View.js +1 -1
- package/ViewManager/ViewManager.d.ts +4 -4
- package/ViewManager/ViewManager.js +10 -10
- package/ViewManager/tests/View-specs.js +109 -81
- package/ViewManager/tests/ViewManager-specs.js +471 -185
- package/VirtualList/UiVirtualListBase.js +1 -1
- package/VirtualList/VirtualList.d.ts +11 -9
- package/VirtualList/VirtualListBasic.js +1 -1
- package/VirtualList/tests/VirtualList-specs.js +44 -31
- package/internal/IdProvider/tests/useId-specs.js +35 -18
- package/package.json +11 -11
- package/resolution/tests/ResolutionDecorator-specs.js +17 -8
- package/styles/mixins.less +14 -2
- package/useControlledState/tests/useControlledState-specs.js +67 -42
- package/useScroll/useScroll.js +2 -2
|
@@ -777,7 +777,7 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
|
|
|
777
777
|
}
|
|
778
778
|
|
|
779
779
|
if (rtl) {
|
|
780
|
-
x = _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 ? -x : this.scrollBounds.maxLeft - x;
|
|
780
|
+
x = _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 || _platform.platform.androidChrome >= 85 ? -x : this.scrollBounds.maxLeft - x;
|
|
781
781
|
}
|
|
782
782
|
|
|
783
783
|
this.containerRef.current.scrollTo(x, y);
|
|
@@ -7,7 +7,7 @@ type Merge<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The shape for the grid list item size
|
|
10
|
-
in a list for
|
|
10
|
+
in a list for [VirtualGridList] .
|
|
11
11
|
*/
|
|
12
12
|
export interface gridListItemSizeShape {
|
|
13
13
|
/**
|
|
@@ -36,7 +36,7 @@ This option is available for only `VirtualList` kind.
|
|
|
36
36
|
* * {animate} - When `true` , scroll occurs with animation. When `false` , no
|
|
37
37
|
animation occurs.
|
|
38
38
|
* * {focus} - When `true` , attempts to focus item after scroll. Only valid when scrolling
|
|
39
|
-
|
|
39
|
+
by `index` or `node` .
|
|
40
40
|
*
|
|
41
41
|
* Note: Only specify one of: `position` , `align` , `index` or `node`
|
|
42
42
|
*
|
|
@@ -156,7 +156,7 @@ export class VirtualList extends React.Component<
|
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
158
|
* The shape for the list different item size
|
|
159
|
-
in a list for
|
|
159
|
+
in a list for [VirtualList] .
|
|
160
160
|
*/
|
|
161
161
|
export interface itemSizesShape {
|
|
162
162
|
/**
|
|
@@ -173,7 +173,8 @@ export interface VirtualListBasicProps {
|
|
|
173
173
|
* The rendering function called for each item in the list.
|
|
174
174
|
*
|
|
175
175
|
* Note : The list does not always render a component whenever its render function is called
|
|
176
|
-
|
|
176
|
+
*
|
|
177
|
+
* due to performance optimization.
|
|
177
178
|
*
|
|
178
179
|
* Example:
|
|
179
180
|
* ```
|
|
@@ -237,7 +238,7 @@ renderItem = ({index, ...rest}) => {
|
|
|
237
238
|
}
|
|
238
239
|
/**
|
|
239
240
|
* A basic base component for
|
|
240
|
-
|
|
241
|
+
[VirtualList] and [VirtualGridList] .
|
|
241
242
|
*/
|
|
242
243
|
|
|
243
244
|
export class VirtualListBasic extends React.Component<
|
|
@@ -249,7 +250,8 @@ export interface VirtualListBaseProps {
|
|
|
249
250
|
* The rendering function called for each item in the list.
|
|
250
251
|
*
|
|
251
252
|
* Note : The list does not always render a component whenever its render function is called
|
|
252
|
-
|
|
253
|
+
*
|
|
254
|
+
* due to performance optimization.
|
|
253
255
|
*
|
|
254
256
|
* Example:
|
|
255
257
|
* ```
|
|
@@ -279,7 +281,7 @@ This option is available for only `VirtualList` kind.
|
|
|
279
281
|
* * {animate} - When `true` , scroll occurs with animation. When `false` , no
|
|
280
282
|
animation occurs.
|
|
281
283
|
* * {focus} - When `true` , attempts to focus item after scroll. Only valid when scrolling
|
|
282
|
-
|
|
284
|
+
by `index` or `node` .
|
|
283
285
|
*
|
|
284
286
|
* Note: Only specify one of: `position` , `align` , `index` or `node`
|
|
285
287
|
*
|
|
@@ -403,7 +405,7 @@ render = () => (
|
|
|
403
405
|
}
|
|
404
406
|
/**
|
|
405
407
|
* A basic base component for
|
|
406
|
-
|
|
408
|
+
[VirtualList] and [VirtualGridList] .
|
|
407
409
|
*/
|
|
408
410
|
|
|
409
411
|
export class VirtualListBase extends React.Component<
|
|
@@ -427,7 +429,7 @@ This option is available for only `VirtualList` kind.
|
|
|
427
429
|
* * {animate} - When `true` , scroll occurs with animation. When `false` , no
|
|
428
430
|
animation occurs.
|
|
429
431
|
* * {focus} - When `true` , attempts to focus item after scroll. Only valid when scrolling
|
|
430
|
-
|
|
432
|
+
by `index` or `node` .
|
|
431
433
|
*
|
|
432
434
|
* Note: Only specify one of: `position` , `align` , `index` or `node`
|
|
433
435
|
*
|
|
@@ -840,7 +840,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
840
840
|
|
|
841
841
|
if (this.props.scrollContentRef.current && this.props.scrollContentRef.current.scrollTo) {
|
|
842
842
|
if (rtl) {
|
|
843
|
-
x = _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 ? -x : this.scrollBounds.maxLeft - x;
|
|
843
|
+
x = _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 || _platform.platform.androidChrome >= 85 ? -x : this.scrollBounds.maxLeft - x;
|
|
844
844
|
}
|
|
845
845
|
|
|
846
846
|
this.props.scrollContentRef.current.scrollTo(x, y);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require("@testing-library/jest-dom");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _react = require("@testing-library/react");
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _VirtualList = _interopRequireDefault(require("../VirtualList"));
|
|
8
8
|
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
|
|
@@ -88,18 +88,20 @@ describe('VirtualList', function () {
|
|
|
88
88
|
resultScrollTop = null;
|
|
89
89
|
});
|
|
90
90
|
test('should render a list of \'items\'', function () {
|
|
91
|
-
|
|
91
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
92
92
|
clientSize: clientSize,
|
|
93
93
|
dataSize: dataSize,
|
|
94
94
|
itemRenderer: renderItem,
|
|
95
95
|
itemSize: 30
|
|
96
96
|
}));
|
|
97
97
|
var expected = 'Account 0';
|
|
98
|
-
|
|
98
|
+
|
|
99
|
+
var actual = _react.screen.getByRole('list').children.item(0).textContent;
|
|
100
|
+
|
|
99
101
|
expect(actual).toBe(expected);
|
|
100
102
|
});
|
|
101
103
|
test('should render (clientHeight / itemHeight + overhang) items', function () {
|
|
102
|
-
|
|
104
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
103
105
|
clientSize: clientSize,
|
|
104
106
|
dataSize: dataSize,
|
|
105
107
|
itemRenderer: renderItem,
|
|
@@ -107,7 +109,8 @@ describe('VirtualList', function () {
|
|
|
107
109
|
}));
|
|
108
110
|
var expected = 27; // 720 / 30 + 3
|
|
109
111
|
|
|
110
|
-
var actual =
|
|
112
|
+
var actual = _react.screen.getByRole('list').children.length;
|
|
113
|
+
|
|
111
114
|
expect(actual).toBe(expected);
|
|
112
115
|
});
|
|
113
116
|
describe('ScrollTo', function () {
|
|
@@ -117,7 +120,7 @@ describe('VirtualList', function () {
|
|
|
117
120
|
var actual = resultScrollTop;
|
|
118
121
|
expect(actual).toBe(expected);
|
|
119
122
|
});
|
|
120
|
-
(0,
|
|
123
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
121
124
|
cbScrollTo: getScrollTo,
|
|
122
125
|
clientSize: clientSize,
|
|
123
126
|
dataSize: dataSize,
|
|
@@ -136,7 +139,7 @@ describe('VirtualList', function () {
|
|
|
136
139
|
var actual = onScrollStopCount;
|
|
137
140
|
expect(actual).toBe(expected);
|
|
138
141
|
});
|
|
139
|
-
(0,
|
|
142
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
140
143
|
cbScrollTo: getScrollTo,
|
|
141
144
|
clientSize: clientSize,
|
|
142
145
|
dataSize: dataSize,
|
|
@@ -158,7 +161,7 @@ describe('VirtualList', function () {
|
|
|
158
161
|
var actual = resultScrollTop;
|
|
159
162
|
expect(actual).toBe(expected);
|
|
160
163
|
});
|
|
161
|
-
(0,
|
|
164
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
162
165
|
cbScrollTo: getScrollTo,
|
|
163
166
|
clientSize: clientSize,
|
|
164
167
|
dataSize: dataSize,
|
|
@@ -175,7 +178,7 @@ describe('VirtualList', function () {
|
|
|
175
178
|
});
|
|
176
179
|
describe('scroll events', function () {
|
|
177
180
|
test('should call onScrollStart once', function () {
|
|
178
|
-
(0,
|
|
181
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
179
182
|
cbScrollTo: getScrollTo,
|
|
180
183
|
clientSize: clientSize,
|
|
181
184
|
dataSize: dataSize,
|
|
@@ -194,7 +197,7 @@ describe('VirtualList', function () {
|
|
|
194
197
|
expect(actual).toBe(expected);
|
|
195
198
|
});
|
|
196
199
|
test('should call onScroll once', function () {
|
|
197
|
-
(0,
|
|
200
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
198
201
|
cbScrollTo: getScrollTo,
|
|
199
202
|
clientSize: clientSize,
|
|
200
203
|
dataSize: dataSize,
|
|
@@ -218,7 +221,7 @@ describe('VirtualList', function () {
|
|
|
218
221
|
var actual = onScrollStopCount;
|
|
219
222
|
expect(actual).toBe(expected);
|
|
220
223
|
});
|
|
221
|
-
(0,
|
|
224
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
222
225
|
cbScrollTo: getScrollTo,
|
|
223
226
|
clientSize: clientSize,
|
|
224
227
|
dataSize: dataSize,
|
|
@@ -255,21 +258,28 @@ describe('VirtualList', function () {
|
|
|
255
258
|
}));
|
|
256
259
|
};
|
|
257
260
|
|
|
258
|
-
var
|
|
261
|
+
var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
259
262
|
clientSize: clientSize,
|
|
260
263
|
dataSize: itemArray.length,
|
|
261
264
|
itemRenderer: renderItemArray,
|
|
262
265
|
itemSize: 30
|
|
263
|
-
}))
|
|
266
|
+
})),
|
|
267
|
+
rerender = _render.rerender;
|
|
268
|
+
|
|
264
269
|
itemArray.unshift({
|
|
265
270
|
name: 'Password 0'
|
|
266
271
|
});
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
272
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
273
|
+
clientSize: clientSize,
|
|
274
|
+
dataSize: itemArray.length,
|
|
275
|
+
itemRenderer: renderItemArray,
|
|
276
|
+
itemSize: 30
|
|
277
|
+
}));
|
|
270
278
|
setTimeout(function () {
|
|
271
279
|
var expected = itemArray[0].name;
|
|
272
|
-
|
|
280
|
+
|
|
281
|
+
var actual = _react.screen.getByRole('list').children.item(0).textContent;
|
|
282
|
+
|
|
273
283
|
expect(actual).toBe(expected);
|
|
274
284
|
done();
|
|
275
285
|
}, 0);
|
|
@@ -277,7 +287,7 @@ describe('VirtualList', function () {
|
|
|
277
287
|
});
|
|
278
288
|
describe('Voice Control', function () {
|
|
279
289
|
test('should render "data-webos-voice-focused" to outermost node of VirtualList', function () {
|
|
280
|
-
|
|
290
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
281
291
|
cbScrollTo: getScrollTo,
|
|
282
292
|
clientSize: clientSize,
|
|
283
293
|
dataSize: dataSize,
|
|
@@ -285,13 +295,14 @@ describe('VirtualList', function () {
|
|
|
285
295
|
itemSize: 30,
|
|
286
296
|
"data-webos-voice-focused": true
|
|
287
297
|
}));
|
|
288
|
-
|
|
289
|
-
var actual =
|
|
290
|
-
|
|
298
|
+
|
|
299
|
+
var actual = _react.screen.getByRole('list').parentElement;
|
|
300
|
+
|
|
301
|
+
expect(actual).toHaveAttribute('data-webos-voice-focused', 'true');
|
|
291
302
|
});
|
|
292
303
|
test('should render "data-webos-voice-group-label" to outermost node of VirtualList', function () {
|
|
293
304
|
var label = 'group label';
|
|
294
|
-
|
|
305
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
295
306
|
cbScrollTo: getScrollTo,
|
|
296
307
|
clientSize: clientSize,
|
|
297
308
|
dataSize: dataSize,
|
|
@@ -299,12 +310,13 @@ describe('VirtualList', function () {
|
|
|
299
310
|
itemSize: 30,
|
|
300
311
|
"data-webos-voice-group-label": label
|
|
301
312
|
}));
|
|
302
|
-
|
|
303
|
-
var actual =
|
|
304
|
-
|
|
313
|
+
|
|
314
|
+
var actual = _react.screen.getByRole('list').parentElement;
|
|
315
|
+
|
|
316
|
+
expect(actual).toHaveAttribute('data-webos-voice-group-label', label);
|
|
305
317
|
});
|
|
306
318
|
test('should render "data-webos-voice-disabled" to outermost node of VirtualList', function () {
|
|
307
|
-
|
|
319
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
|
|
308
320
|
cbScrollTo: getScrollTo,
|
|
309
321
|
clientSize: clientSize,
|
|
310
322
|
dataSize: dataSize,
|
|
@@ -312,9 +324,10 @@ describe('VirtualList', function () {
|
|
|
312
324
|
itemSize: 30,
|
|
313
325
|
"data-webos-voice-disabled": true
|
|
314
326
|
}));
|
|
315
|
-
|
|
316
|
-
var actual =
|
|
317
|
-
|
|
327
|
+
|
|
328
|
+
var actual = _react.screen.getByRole('list').parentElement;
|
|
329
|
+
|
|
330
|
+
expect(actual).toHaveAttribute('data-webos-voice-disabled', 'true');
|
|
318
331
|
});
|
|
319
332
|
});
|
|
320
333
|
});
|
|
@@ -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 _useId = _interopRequireDefault(require("../useId"));
|
|
6
8
|
|
|
@@ -15,8 +17,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
15
17
|
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; }
|
|
16
18
|
|
|
17
19
|
describe('useId', function () {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
var data = [];
|
|
21
|
+
|
|
22
|
+
function Base(props) {
|
|
23
|
+
data.push(props);
|
|
24
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
25
|
+
id: data.id,
|
|
26
|
+
generateid: data.generateId
|
|
27
|
+
});
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
function Component(_ref) {
|
|
@@ -31,41 +39,50 @@ describe('useId', function () {
|
|
|
31
39
|
}));
|
|
32
40
|
}
|
|
33
41
|
|
|
42
|
+
afterEach(function () {
|
|
43
|
+
return data.splice(0, data.length);
|
|
44
|
+
});
|
|
34
45
|
test('should provide a generateId method', function () {
|
|
35
|
-
|
|
46
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
|
|
36
47
|
var expected = 'function';
|
|
37
|
-
var actual = typeof
|
|
48
|
+
var actual = typeof data[0].generateId;
|
|
38
49
|
expect(actual).toBe(expected);
|
|
39
50
|
});
|
|
40
51
|
test('should generate different ids for different instances of the same component', function () {
|
|
41
|
-
|
|
52
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
42
53
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {})]
|
|
43
54
|
}));
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
expect(
|
|
55
|
+
var firstID = data[0].id;
|
|
56
|
+
var lastID = data[1].id;
|
|
57
|
+
expect(firstID).not.toBe(lastID);
|
|
47
58
|
});
|
|
48
59
|
test('should maintain the same id across renders', function () {
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var
|
|
60
|
+
var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {})),
|
|
61
|
+
rerender = _render.rerender;
|
|
62
|
+
|
|
63
|
+
var expected = data[0].id;
|
|
64
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
|
|
65
|
+
var actual = data[1].id;
|
|
53
66
|
expect(actual).toBe(expected);
|
|
54
67
|
});
|
|
55
68
|
test('should prefix the id with the provided value', function () {
|
|
56
|
-
|
|
69
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
57
70
|
prefix: "my-id"
|
|
58
71
|
}));
|
|
72
|
+
var id = data[0].id;
|
|
59
73
|
var expected = 'my-id';
|
|
60
|
-
var actual =
|
|
74
|
+
var actual = id.substring(0, 5);
|
|
61
75
|
expect(actual).toBe(expected);
|
|
62
76
|
});
|
|
63
77
|
test('should call onUnmount callback', function () {
|
|
64
78
|
var spy = jest.fn();
|
|
65
|
-
|
|
79
|
+
|
|
80
|
+
var _render2 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
66
81
|
onUnmount: spy
|
|
67
|
-
}))
|
|
68
|
-
|
|
82
|
+
})),
|
|
83
|
+
unmount = _render2.unmount;
|
|
84
|
+
|
|
85
|
+
unmount();
|
|
69
86
|
expect(spy).toHaveBeenCalledTimes(1);
|
|
70
87
|
});
|
|
71
88
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/ui",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"description": "A collection of simplified unstyled cross-platform UI components for Enact",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@enact/core": "^4.1.
|
|
29
|
-
"classnames": "^2.
|
|
30
|
-
"direction": "^1.0.
|
|
31
|
-
"invariant": "^2.2.
|
|
32
|
-
"prop-types": "^15.
|
|
33
|
-
"ramda": "^0.
|
|
34
|
-
"react": "^17.0.
|
|
35
|
-
"react-dom": "^17.0.
|
|
36
|
-
"react-is": "^17.0.
|
|
37
|
-
"warning": "^
|
|
28
|
+
"@enact/core": "^4.1.3",
|
|
29
|
+
"classnames": "^2.3.1",
|
|
30
|
+
"direction": "^1.0.4",
|
|
31
|
+
"invariant": "^2.2.4",
|
|
32
|
+
"prop-types": "^15.8.0",
|
|
33
|
+
"ramda": "^0.27.1",
|
|
34
|
+
"react": "^17.0.2",
|
|
35
|
+
"react-dom": "^17.0.2",
|
|
36
|
+
"react-is": "^17.0.2",
|
|
37
|
+
"warning": "^4.0.3"
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -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 _ResolutionDecorator = _interopRequireDefault(require("../ResolutionDecorator"));
|
|
6
8
|
|
|
@@ -11,10 +13,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
11
13
|
describe('ResolutionDecorator Specs', function () {
|
|
12
14
|
test('should apply resolution classes to the wrapped component', function () {
|
|
13
15
|
var Component = (0, _ResolutionDecorator["default"])('div');
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
17
|
+
"data-testid": "component"
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
var div = _react.screen.getByTestId('component').className;
|
|
21
|
+
|
|
16
22
|
var expected = true;
|
|
17
|
-
var actual = div.
|
|
23
|
+
var actual = div.includes('enact-res-standard') && (div.includes('enact-orientation-landscape') || div.includes('enact-orientation-portrait'));
|
|
18
24
|
expect(actual).toBe(expected);
|
|
19
25
|
});
|
|
20
26
|
test('should allow custom screen types', function () {
|
|
@@ -30,10 +36,13 @@ describe('ResolutionDecorator Specs', function () {
|
|
|
30
36
|
var Component = (0, _ResolutionDecorator["default"])({
|
|
31
37
|
screenTypes: screens
|
|
32
38
|
}, 'div');
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
40
|
+
"data-testid": "component"
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
var div = _react.screen.getByTestId('component');
|
|
44
|
+
|
|
45
|
+
expect(div).toHaveClass('enact-res-mhd');
|
|
37
46
|
});
|
|
38
47
|
test.skip('should update the resolution when the screen is resized', function () {// TODO: write a test
|
|
39
48
|
});
|
package/styles/mixins.less
CHANGED
|
@@ -356,12 +356,24 @@
|
|
|
356
356
|
@rules();
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
|
+
|
|
360
|
+
// `length()` below refers to specifying font-weight ranges: `600 900`.
|
|
361
|
+
// Ex:
|
|
362
|
+
// .buildFontFace("fontName"; local("name"); 400 600);
|
|
363
|
+
// -> .buildFontFace("fontName"; local("name"); 400); .buildFontFace("fontName"; local("name"); 600);
|
|
364
|
+
// .buildFontFace("fontName"; local("name"); 400 600; normal);
|
|
365
|
+
// -> .buildFontFace("fontName"; local("name"); 400; normal); .buildFontFace("fontName"; local("name"); 600; normal);
|
|
366
|
+
.buildFontFace(@name; @src; @weight: normal; @style: "") when (length(@weight) > 1) {
|
|
367
|
+
each(@weight, {
|
|
368
|
+
.buildFontFace(@name; @src; @value; @style);
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
|
|
359
372
|
// The default version of this mixin (below) is the shorthand version, which rearranges its arguments into the format the above mixin expects.
|
|
360
373
|
.buildFontFace(@name; @src; @weight: normal; @style: "") when (default()) {
|
|
361
374
|
.buildFontFace(@name; @src; {
|
|
362
375
|
// Conditionally add the following
|
|
363
|
-
|
|
364
|
-
& when ((iskeyword(@weight)) or (isnumber(@weight)) or (length(@weight) > 1)) {
|
|
376
|
+
& when ((iskeyword(@weight)) or (isnumber(@weight))) {
|
|
365
377
|
font-weight: @weight;
|
|
366
378
|
}
|
|
367
379
|
& when (iskeyword(@style)) {
|
|
@@ -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 _useControlledState3 = _interopRequireDefault(require("../useControlledState"));
|
|
6
8
|
|
|
@@ -21,80 +23,103 @@ function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "und
|
|
|
21
23
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
24
|
|
|
23
25
|
describe('useControlledState', function () {
|
|
26
|
+
var data;
|
|
27
|
+
|
|
24
28
|
function Component(props) {
|
|
25
29
|
var _useControlledState = (0, _useControlledState3["default"])(props.defaultValue, props.value, 'value' in props),
|
|
26
30
|
_useControlledState2 = _slicedToArray(_useControlledState, 2),
|
|
27
31
|
value = _useControlledState2[0],
|
|
28
32
|
setValue = _useControlledState2[1];
|
|
29
33
|
|
|
34
|
+
var handleChange = function handleChange(ev) {
|
|
35
|
+
return setValue(ev.value);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
data = setValue;
|
|
30
39
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
31
|
-
|
|
40
|
+
onChange: handleChange,
|
|
32
41
|
children: value
|
|
33
42
|
});
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
test('should use the default value when the value is undefined', function () {
|
|
37
|
-
|
|
46
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
38
47
|
defaultValue: "abc"
|
|
39
48
|
}));
|
|
40
|
-
|
|
41
|
-
var actual =
|
|
42
|
-
|
|
49
|
+
|
|
50
|
+
var actual = _react.screen.queryByText('abc');
|
|
51
|
+
|
|
52
|
+
expect(actual).toBeInTheDocument();
|
|
43
53
|
});
|
|
44
54
|
test('should not change default value', function () {
|
|
45
|
-
var
|
|
55
|
+
var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
46
56
|
defaultValue: "abc"
|
|
57
|
+
})),
|
|
58
|
+
rerender = _render.rerender;
|
|
59
|
+
|
|
60
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
61
|
+
defaultValue: "def"
|
|
47
62
|
}));
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var actual = subject.find('div').prop('children');
|
|
53
|
-
expect(actual).toBe(expected);
|
|
63
|
+
|
|
64
|
+
var actual = _react.screen.queryByText('abc');
|
|
65
|
+
|
|
66
|
+
expect(actual).toBeInTheDocument();
|
|
54
67
|
});
|
|
55
68
|
test('should not change uncontrolled setting', function () {
|
|
56
|
-
var
|
|
69
|
+
var _render2 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
57
70
|
defaultValue: "abc"
|
|
58
|
-
}))
|
|
59
|
-
|
|
71
|
+
})),
|
|
72
|
+
rerender = _render2.rerender;
|
|
73
|
+
|
|
74
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
60
75
|
defaultValue: null,
|
|
61
|
-
value:
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
var actual =
|
|
65
|
-
|
|
76
|
+
value: "def"
|
|
77
|
+
}));
|
|
78
|
+
|
|
79
|
+
var actual = _react.screen.queryByText('abc');
|
|
80
|
+
|
|
81
|
+
expect(actual).toBeInTheDocument();
|
|
66
82
|
});
|
|
67
83
|
test('should update controlled value', function () {
|
|
68
|
-
var
|
|
84
|
+
var _render3 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
69
85
|
value: "abc"
|
|
86
|
+
})),
|
|
87
|
+
rerender = _render3.rerender;
|
|
88
|
+
|
|
89
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
90
|
+
value: "def"
|
|
70
91
|
}));
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
var actual = subject.find('div').prop('children');
|
|
76
|
-
expect(actual).toBe(expected);
|
|
92
|
+
|
|
93
|
+
var actual = _react.screen.queryByText('def');
|
|
94
|
+
|
|
95
|
+
expect(actual).toBeInTheDocument();
|
|
77
96
|
});
|
|
78
97
|
test('should not change controlled setting', function () {
|
|
79
|
-
var
|
|
98
|
+
var _render4 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
80
99
|
value: "abc"
|
|
100
|
+
})),
|
|
101
|
+
rerender = _render4.rerender;
|
|
102
|
+
|
|
103
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
104
|
+
defaultValue: "def",
|
|
105
|
+
value: "ghi"
|
|
81
106
|
}));
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var expected = 'ghi';
|
|
87
|
-
var actual = subject.find('div').prop('children');
|
|
88
|
-
expect(actual).toBe(expected);
|
|
107
|
+
|
|
108
|
+
var actual = _react.screen.queryByText('ghi');
|
|
109
|
+
|
|
110
|
+
expect(actual).toBeInTheDocument();
|
|
89
111
|
});
|
|
90
112
|
test('should not allow setting a value when controlled', function () {
|
|
91
|
-
var
|
|
113
|
+
var handleChange = jest.fn();
|
|
114
|
+
var value = 'ghi';
|
|
115
|
+
(0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
116
|
+
onChange: handleChange,
|
|
92
117
|
value: "abc"
|
|
93
118
|
}));
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
expect(
|
|
119
|
+
|
|
120
|
+
var component = _react.screen.queryByText('abc');
|
|
121
|
+
|
|
122
|
+
data(value);
|
|
123
|
+
expect(component).toBeInTheDocument();
|
|
99
124
|
});
|
|
100
125
|
});
|