@enact/ui 4.1.1 → 4.1.4

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.
Files changed (92) hide show
  1. package/AnnounceDecorator/tests/Announce-specs.js +13 -5
  2. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +9 -7
  3. package/AnnounceDecorator/tests/useAnnounce-specs.js +25 -17
  4. package/BodyText/BodyText.d.ts +1 -1
  5. package/BodyText/tests/BodyText-specs.js +49 -35
  6. package/Button/Button.d.ts +6 -6
  7. package/Button/Button.js +5 -3
  8. package/Button/tests/Button-specs.js +104 -3
  9. package/CHANGELOG.md +26 -0
  10. package/Cancelable/Cancelable.js +1 -1
  11. package/Cancelable/tests/Cancelable-specs.js +131 -70
  12. package/Changeable/tests/Changeable-specs.js +162 -110
  13. package/FloatingLayer/FloatingLayer.js +5 -17
  14. package/FloatingLayer/tests/FloatingLayer-specs.js +83 -8
  15. package/FloatingLayer/tests/Scrim-specs.js +20 -11
  16. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +15 -9
  17. package/GridListImageItem/GridListImageItem.d.ts +1 -1
  18. package/Group/Group.d.ts +2 -2
  19. package/Group/tests/Group-specs.js +71 -41
  20. package/Heading/Heading.d.ts +2 -1
  21. package/Heading/tests/Heading-specs.js +27 -20
  22. package/Icon/Icon.d.ts +4 -4
  23. package/Icon/tests/Icon-specs.js +52 -31
  24. package/IconButton/IconButton.d.ts +4 -4
  25. package/IconButton/tests/IconButton-specs.js +2 -2
  26. package/Image/tests/Image-specs.js +39 -29
  27. package/ImageItem/tests/ImageItem-specs.js +71 -68
  28. package/Item/tests/Item-specs.js +59 -35
  29. package/LabeledIcon/LabeledIcon.d.ts +4 -4
  30. package/LabeledIcon/tests/LabeledIcon-specs.js +30 -19
  31. package/Layout/Layout.d.ts +16 -16
  32. package/Layout/tests/Layout-specs.js +37 -25
  33. package/Marquee/MarqueeBase.js +1 -5
  34. package/Marquee/MarqueeDecorator.js +6 -3
  35. package/Marquee/index.d.ts +4 -1
  36. package/Marquee/tests/Marquee-specs.js +242 -116
  37. package/Media/Media.js +1 -3
  38. package/ProgressBar/tests/ProgressBar-specs.js +60 -42
  39. package/README.md +1 -1
  40. package/RadioDecorator/RadioDecorator.js +3 -5
  41. package/RadioDecorator/tests/RadioDecorator-specs.js +179 -65
  42. package/Repeater/Repeater.d.ts +2 -1
  43. package/Repeater/tests/Repeater-specs.js +86 -45
  44. package/Routable/Routable.d.ts +2 -2
  45. package/Routable/tests/Routable-specs.js +26 -17
  46. package/Routable/tests/Router-specs.js +65 -41
  47. package/Scrollable/Scrollable.js +2 -1
  48. package/Scrollable/ScrollableNative.js +2 -1
  49. package/Scroller/Scroller.d.ts +2 -14
  50. package/Scroller/ScrollerBasic.js +10 -29
  51. package/Scroller/UiScrollerBase.js +1 -1
  52. package/Skinnable/tests/Skinnable-specs.js +102 -54
  53. package/Skinnable/tests/useSkins-specs.js +37 -42
  54. package/Slider/Slider.d.ts +3 -3
  55. package/Slider/tests/Slider-specs.js +4 -4
  56. package/SlotItem/SlotItem.d.ts +2 -2
  57. package/SlotItem/tests/SlotItem-specs.js +4 -4
  58. package/Slottable/tests/Slottable-specs.js +67 -36
  59. package/Slottable/tests/useSlots-specs.js +68 -35
  60. package/Spinner/Spinner.d.ts +1 -1
  61. package/Spinner/tests/Spinner-specs.js +46 -31
  62. package/ToggleIcon/tests/ToggleIcon-specs.js +32 -20
  63. package/ToggleItem/ToggleItem.d.ts +13 -11
  64. package/ToggleItem/tests/ToggleItem-specs.js +51 -34
  65. package/Toggleable/Toggle.js +6 -6
  66. package/Toggleable/Toggleable.js +6 -12
  67. package/Toggleable/tests/Toggleable-specs.js +428 -324
  68. package/Touchable/Drag.js +13 -17
  69. package/Touchable/Flick.js +20 -16
  70. package/Touchable/Hold.js +14 -19
  71. package/Touchable/Touchable.d.ts +3 -3
  72. package/Touchable/tests/Touchable-specs.js +223 -109
  73. package/Touchable/tests/useTouch-specs.js +159 -84
  74. package/Transition/Transition.d.ts +29 -27
  75. package/Transition/Transition.js +11 -9
  76. package/Transition/tests/Transition-specs.js +111 -31
  77. package/ViewManager/TransitionGroup.js +6 -5
  78. package/ViewManager/View.js +1 -1
  79. package/ViewManager/ViewManager.d.ts +4 -4
  80. package/ViewManager/ViewManager.js +10 -10
  81. package/ViewManager/tests/View-specs.js +109 -81
  82. package/ViewManager/tests/ViewManager-specs.js +471 -185
  83. package/VirtualList/UiVirtualListBase.js +11 -21
  84. package/VirtualList/VirtualList.d.ts +11 -29
  85. package/VirtualList/VirtualListBasic.js +33 -49
  86. package/VirtualList/tests/VirtualList-specs.js +29 -61
  87. package/internal/IdProvider/tests/useId-specs.js +35 -18
  88. package/package.json +11 -11
  89. package/resolution/tests/ResolutionDecorator-specs.js +17 -8
  90. package/styles/mixins.less +14 -2
  91. package/useControlledState/tests/useControlledState-specs.js +67 -42
  92. package/useScroll/useScroll.js +12 -26
@@ -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);
@@ -1113,11 +1113,10 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1113
1113
  value: function render() {
1114
1114
  var _this$props7 = this.props,
1115
1115
  className = _this$props7.className,
1116
- voiceFocused = _this$props7['data-webos-voice-focused'],
1117
- voiceGroupLabel = _this$props7['data-webos-voice-group-label'],
1116
+ containerProps = _this$props7.containerProps,
1118
1117
  itemsRenderer = _this$props7.itemsRenderer,
1119
1118
  style = _this$props7.style,
1120
- rest = _objectWithoutProperties(_this$props7, ["className", "data-webos-voice-focused", "data-webos-voice-group-label", "itemsRenderer", "style"]),
1119
+ rest = _objectWithoutProperties(_this$props7, ["className", "containerProps", "itemsRenderer", "style"]),
1121
1120
  cc = this.cc,
1122
1121
  itemContainerRef = this.itemContainerRef,
1123
1122
  primary = this.primary,
@@ -1147,10 +1146,9 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1147
1146
  this.positionItems();
1148
1147
  }
1149
1148
 
1150
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1151
- className: containerClasses,
1152
- "data-webos-voice-focused": voiceFocused,
1153
- "data-webos-voice-group-label": voiceGroupLabel,
1149
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
1150
+ className: containerClasses
1151
+ }, containerProps), {}, {
1154
1152
  ref: this.containerRef,
1155
1153
  style: style,
1156
1154
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
@@ -1162,7 +1160,7 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1162
1160
  primary: primary
1163
1161
  })
1164
1162
  }))
1165
- });
1163
+ }));
1166
1164
  }
1167
1165
  }], [{
1168
1166
  key: "getDerivedStateFromProps",
@@ -1264,20 +1262,12 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
1264
1262
  }),
1265
1263
 
1266
1264
  /**
1267
- * Activates the component for voice control.
1268
- *
1269
- * @type {Boolean}
1270
- * @public
1271
- */
1272
- 'data-webos-voice-focused': _propTypes["default"].bool,
1273
-
1274
- /**
1275
- * The voice control group label.
1265
+ * An object with properties to be passed to the container DOM.
1276
1266
  *
1277
- * @type {String}
1278
- * @public
1267
+ * @type {Object}
1268
+ * @private
1279
1269
  */
1280
- 'data-webos-voice-group-label': _propTypes["default"].string,
1270
+ containerProps: _propTypes["default"].object,
1281
1271
 
1282
1272
  /**
1283
1273
  * The number of items of data the list contains.
@@ -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 VirtualGridList .
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
- by `index` or `node` .
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 VirtualList .
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
- due to performance optimization.
176
+ *
177
+ * due to performance optimization.
177
178
  *
178
179
  * Example:
179
180
  * ```
@@ -194,18 +195,6 @@ renderItem = ({index, ...rest}) => {
194
195
  * Client size of the list; valid values are an object that has `clientWidth` and `clientHeight` .
195
196
  */
196
197
  clientSize?: object;
197
- /**
198
- * Disable voice control feature of component.
199
- */
200
- "data-webos-voice-disabled"?: boolean;
201
- /**
202
- * Activates the component for voice control.
203
- */
204
- "data-webos-voice-focused"?: boolean;
205
- /**
206
- * The voice control group label.
207
- */
208
- "data-webos-voice-group-label"?: string;
209
198
  /**
210
199
  * The number of items of data the list contains.
211
200
  */
@@ -237,7 +226,7 @@ renderItem = ({index, ...rest}) => {
237
226
  }
238
227
  /**
239
228
  * A basic base component for
240
- VirtualList and VirtualGridList .
229
+ [VirtualList] and [VirtualGridList] .
241
230
  */
242
231
 
243
232
  export class VirtualListBasic extends React.Component<
@@ -249,7 +238,8 @@ export interface VirtualListBaseProps {
249
238
  * The rendering function called for each item in the list.
250
239
  *
251
240
  * Note : The list does not always render a component whenever its render function is called
252
- due to performance optimization.
241
+ *
242
+ * due to performance optimization.
253
243
  *
254
244
  * Example:
255
245
  * ```
@@ -279,7 +269,7 @@ This option is available for only `VirtualList` kind.
279
269
  * * {animate} - When `true` , scroll occurs with animation. When `false` , no
280
270
  animation occurs.
281
271
  * * {focus} - When `true` , attempts to focus item after scroll. Only valid when scrolling
282
- by `index` or `node` .
272
+ by `index` or `node` .
283
273
  *
284
274
  * Note: Only specify one of: `position` , `align` , `index` or `node`
285
275
  *
@@ -300,14 +290,6 @@ this.scrollTo({align: 'top'}); // scroll to the top
300
290
  * Client size of the list; valid values are an object that has `clientWidth` and `clientHeight` .
301
291
  */
302
292
  clientSize?: object;
303
- /**
304
- * Activates the component for voice control.
305
- */
306
- "data-webos-voice-focused"?: boolean;
307
- /**
308
- * The voice control group label.
309
- */
310
- "data-webos-voice-group-label"?: string;
311
293
  /**
312
294
  * The number of items of data the list contains.
313
295
  */
@@ -403,7 +385,7 @@ render = () => (
403
385
  }
404
386
  /**
405
387
  * A basic base component for
406
- VirtualList and VirtualGridList .
388
+ [VirtualList] and [VirtualGridList] .
407
389
  */
408
390
 
409
391
  export class VirtualListBase extends React.Component<
@@ -427,7 +409,7 @@ This option is available for only `VirtualList` kind.
427
409
  * * {animate} - When `true` , scroll occurs with animation. When `false` , no
428
410
  animation occurs.
429
411
  * * {focus} - When `true` , attempts to focus item after scroll. Only valid when scrolling
430
- by `index` or `node` .
412
+ by `index` or `node` .
431
413
  *
432
414
  * Note: Only specify one of: `position` , `align` , `index` or `node`
433
415
  *
@@ -159,17 +159,16 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
159
159
  _this.itemPositions = [];
160
160
  _this.indexToScrollIntoView = -1;
161
161
 
162
- _this.updateScrollPosition = function (_ref) {
162
+ _this.updateScrollPosition = function (_ref, behavior) {
163
163
  var x = _ref.x,
164
164
  y = _ref.y;
165
- var rtl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.props.rtl;
166
165
 
167
166
  if (_this.props.scrollMode === 'native') {
168
- _this.scrollToPosition(x, y, rtl);
167
+ _this.scrollToPosition(x, y, behavior);
169
168
  } else {
170
169
  _this.setScrollPositionTarget(x, y);
171
170
 
172
- _this.setScrollPosition(x, y, rtl);
171
+ _this.setScrollPosition(x, y);
173
172
  }
174
173
  };
175
174
 
@@ -319,6 +318,14 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
319
318
  }
320
319
  };
321
320
 
321
+ _this.getRtlPositionX = function (x) {
322
+ if (_this.props.rtl) {
323
+ return _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 || _platform.platform.androidChrome >= 85 ? -x : _this.scrollBounds.maxLeft - x;
324
+ }
325
+
326
+ return x;
327
+ };
328
+
322
329
  _this.applyStyleToNewNode = function (index) {
323
330
  var _this2;
324
331
 
@@ -538,7 +545,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
538
545
  this.updateScrollPosition({
539
546
  x: xMax > x ? x : xMax,
540
547
  y: yMax > y ? y : yMax
541
- });
548
+ }, 'instant');
542
549
  deferScrollTo = true;
543
550
  } else if (this.hasDataSizeChanged) {
544
551
  var newState = this.getStatesAndUpdateBounds(this.props, this.state.firstIndex); // eslint-disable-next-line react/no-did-update-set-state
@@ -547,7 +554,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
547
554
  this.setContainerSize();
548
555
  deferScrollTo = true;
549
556
  } else if (prevProps.rtl !== this.props.rtl) {
550
- this.updateScrollPosition(this.getXY(this.scrollPosition, 0));
557
+ this.updateScrollPosition(this.getXY(this.scrollPosition, 0), 'instant');
551
558
  }
552
559
 
553
560
  var maxPos = this.isPrimaryDirectionVertical ? this.scrollBounds.maxTop : this.scrollBounds.maxLeft;
@@ -692,9 +699,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
692
699
  if (scrollMode === 'translate' && this.contentRef.current) {
693
700
  this.contentRef.current.style.transform = null;
694
701
  } else if (scrollMode === 'native' && node) {
695
- node.style.scrollBehavior = null;
696
- this.updateScrollPosition(this.getXY(this.scrollPosition, 0));
697
- node.style.scrollBehavior = 'smooth';
702
+ this.updateScrollPosition(this.getXY(this.scrollPosition, 0), 'instant');
698
703
  }
699
704
  }
700
705
  }, {
@@ -835,15 +840,14 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
835
840
 
836
841
  }, {
837
842
  key: "scrollToPosition",
838
- value: function scrollToPosition(x, y) {
839
- var rtl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.props.rtl;
840
-
843
+ value: // scrollMode 'native' only
844
+ function scrollToPosition(left, top, behavior) {
841
845
  if (this.props.scrollContentRef.current && this.props.scrollContentRef.current.scrollTo) {
842
- if (rtl) {
843
- x = _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 ? -x : this.scrollBounds.maxLeft - x;
844
- }
845
-
846
- this.props.scrollContentRef.current.scrollTo(x, y);
846
+ this.props.scrollContentRef.current.scrollTo({
847
+ left: this.getRtlPositionX(left),
848
+ top: top,
849
+ behavior: behavior
850
+ });
847
851
  }
848
852
  } // scrollMode 'native' only
849
853
 
@@ -860,7 +864,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
860
864
  }, {
861
865
  key: "setScrollPositionTarget",
862
866
  value: function setScrollPositionTarget(x, y) {
863
- // The `x`, `y` as parameters in scrollToPosition() are the position when stopping scrolling.
867
+ // The `left`, `top` as parameters in scrollToPosition() are the position when stopping scrolling.
864
868
  // But the `x`, `y` as parameters in setScrollPosition() are the position between current position and the position stopping scrolling.
865
869
  // To know the position when stopping scrolling properly, `x` and `y` are passed and cached in `this.scrollPositionTarget`.
866
870
  if (this.isPrimaryDirectionVertical) {
@@ -873,7 +877,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
873
877
  }, {
874
878
  key: "setScrollPosition",
875
879
  value: function setScrollPosition(x, y) {
876
- var rtl = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.props.rtl;
880
+ var rtl = this.props.rtl;
877
881
 
878
882
  if (this.contentRef.current) {
879
883
  this.contentRef.current.style.transform = "translate3d(".concat(rtl ? x : -x, "px, -").concat(y, "px, 0)");
@@ -1170,14 +1174,12 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
1170
1174
  function render() {
1171
1175
  var _this$props7 = this.props,
1172
1176
  className = _this$props7.className,
1173
- voiceFocused = _this$props7['data-webos-voice-focused'],
1174
- voiceGroupLabel = _this$props7['data-webos-voice-group-label'],
1175
- voiceDisabled = _this$props7['data-webos-voice-disabled'],
1177
+ containerProps = _this$props7.containerProps,
1176
1178
  placeholderRenderer = _this$props7.placeholderRenderer,
1177
1179
  role = _this$props7.role,
1178
1180
  style = _this$props7.style,
1179
1181
  scrollMode = _this$props7.scrollMode,
1180
- rest = _objectWithoutProperties(_this$props7, ["className", "data-webos-voice-focused", "data-webos-voice-group-label", "data-webos-voice-disabled", "placeholderRenderer", "role", "style", "scrollMode"]),
1182
+ rest = _objectWithoutProperties(_this$props7, ["className", "containerProps", "placeholderRenderer", "role", "style", "scrollMode"]),
1181
1183
  cc = this.cc,
1182
1184
  isPrimaryDirectionVertical = this.isPrimaryDirectionVertical,
1183
1185
  primary = this.primary,
@@ -1214,11 +1216,9 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
1214
1216
  this.positionItems();
1215
1217
  }
1216
1218
 
1217
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1218
- className: containerClasses,
1219
- "data-webos-voice-focused": voiceFocused,
1220
- "data-webos-voice-group-label": voiceGroupLabel,
1221
- "data-webos-voice-disabled": voiceDisabled,
1219
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
1220
+ className: containerClasses
1221
+ }, containerProps), {}, {
1222
1222
  ref: this.props.scrollContentRef,
1223
1223
  style: style,
1224
1224
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
@@ -1227,7 +1227,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
1227
1227
  role: role,
1228
1228
  children: [].concat(_toConsumableArray(cc), [placeholderRenderer && placeholderRenderer(primary)])
1229
1229
  }))
1230
- });
1230
+ }));
1231
1231
  }
1232
1232
  }], [{
1233
1233
  key: "getDerivedStateFromProps",
@@ -1321,28 +1321,12 @@ VirtualListBasic.propTypes =
1321
1321
  }),
1322
1322
 
1323
1323
  /**
1324
- * Disable voice control feature of component.
1325
- *
1326
- * @type {Boolean}
1327
- * @public
1328
- */
1329
- 'data-webos-voice-disabled': _propTypes2["default"].bool,
1330
-
1331
- /**
1332
- * Activates the component for voice control.
1324
+ * An object with properties to be passed to the container DOM.
1333
1325
  *
1334
- * @type {Boolean}
1335
- * @public
1336
- */
1337
- 'data-webos-voice-focused': _propTypes2["default"].bool,
1338
-
1339
- /**
1340
- * The voice control group label.
1341
- *
1342
- * @type {String}
1343
- * @public
1326
+ * @type {Object}
1327
+ * @private
1344
1328
  */
1345
- 'data-webos-voice-group-label': _propTypes2["default"].string,
1329
+ containerProps: _propTypes2["default"].object,
1346
1330
 
1347
1331
  /**
1348
1332
  * The number of items of data the list contains.
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var _enzyme = require("enzyme");
3
+ require("@testing-library/jest-dom");
4
4
 
5
- var _VirtualList = _interopRequireDefault(require("../VirtualList"));
5
+ var _react = require("@testing-library/react");
6
6
 
7
- var _VirtualListModule = _interopRequireDefault(require("../VirtualList.module.css"));
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
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
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
- var actual = subject.find('#item0').text();
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
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
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 = subject.childAt(0).text().split('Account').length - 1;
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, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
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, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
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, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
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, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
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, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
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, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
224
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
222
225
  cbScrollTo: getScrollTo,
223
226
  clientSize: clientSize,
224
227
  dataSize: dataSize,
@@ -255,66 +258,31 @@ describe('VirtualList', function () {
255
258
  }));
256
259
  };
257
260
 
258
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
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
- subject.setProps({
268
- dataSize: itemArray.length
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
- var actual = subject.find('#item0').text();
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);
276
286
  });
277
287
  });
278
- describe('Voice Control', function () {
279
- test('should render "data-webos-voice-focused" to outermost node of VirtualList', function () {
280
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
281
- cbScrollTo: getScrollTo,
282
- clientSize: clientSize,
283
- dataSize: dataSize,
284
- itemRenderer: renderItem,
285
- itemSize: 30,
286
- "data-webos-voice-focused": true
287
- }));
288
- var expected = true;
289
- var actual = subject.find(".".concat(_VirtualListModule["default"].virtualList)).prop('data-webos-voice-focused');
290
- expect(actual).toBe(expected);
291
- });
292
- test('should render "data-webos-voice-group-label" to outermost node of VirtualList', function () {
293
- var label = 'group label';
294
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
295
- cbScrollTo: getScrollTo,
296
- clientSize: clientSize,
297
- dataSize: dataSize,
298
- itemRenderer: renderItem,
299
- itemSize: 30,
300
- "data-webos-voice-group-label": label
301
- }));
302
- var expected = label;
303
- var actual = subject.find(".".concat(_VirtualListModule["default"].virtualList)).prop('data-webos-voice-group-label');
304
- expect(actual).toBe(expected);
305
- });
306
- test('should render "data-webos-voice-disabled" to outermost node of VirtualList', function () {
307
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_VirtualList["default"], {
308
- cbScrollTo: getScrollTo,
309
- clientSize: clientSize,
310
- dataSize: dataSize,
311
- itemRenderer: renderItem,
312
- itemSize: 30,
313
- "data-webos-voice-disabled": true
314
- }));
315
- var expected = true;
316
- var actual = subject.find(".".concat(_VirtualListModule["default"].virtualList)).prop('data-webos-voice-disabled');
317
- expect(actual).toBe(expected);
318
- });
319
- });
320
288
  });
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
 
3
- var _enzyme = require("enzyme");
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
- function Base() {
19
- return null;
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
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
46
+ (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
36
47
  var expected = 'function';
37
- var actual = typeof subject.find(Base).prop('generateId');
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
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
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 first = subject.find(Base).first().prop('id');
45
- var last = subject.find(Base).last().prop('id');
46
- expect(first).not.toBe(last);
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 subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {}));
50
- var expected = subject.find(Base).prop('id');
51
- subject.setProps({});
52
- var actual = subject.find(Base).prop('id');
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
- var subject = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
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 = subject.find(Base).prop('id').substring(0, 5);
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
- var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
79
+
80
+ var _render2 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
66
81
  onUnmount: spy
67
- }));
68
- subject.unmount();
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.1",
3
+ "version": "4.1.4",
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.1",
29
- "classnames": "^2.2.5",
30
- "direction": "^1.0.1",
31
- "invariant": "^2.2.2",
32
- "prop-types": "^15.7.2",
33
- "ramda": "^0.24.1",
34
- "react": "^17.0.1",
35
- "react-dom": "^17.0.1",
36
- "react-is": "^17.0.1",
37
- "warning": "^3.0.0"
28
+ "@enact/core": "^4.1.4",
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
  }