@enact/ui 5.4.4 → 5.5.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.
Files changed (65) hide show
  1. package/AnnounceDecorator/Announce.js +9 -5
  2. package/AnnounceDecorator/AnnounceDecorator.js +5 -3
  3. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +4 -1
  4. package/AnnounceDecorator/tests/useAnnounce-specs.js +4 -1
  5. package/CHANGELOG.md +30 -0
  6. package/Cancelable/Cancelable.js +7 -0
  7. package/Cancelable/tests/Cancelable-specs.js +26 -0
  8. package/Changeable/Changeable.js +6 -0
  9. package/Changeable/tests/Changeable-specs.js +4 -1
  10. package/FloatingLayer/FloatingLayer.js +3 -0
  11. package/FloatingLayer/FloatingLayerDecorator.js +2 -0
  12. package/FloatingLayer/Scrim.js +3 -0
  13. package/Marquee/Marquee.module.css +1 -1
  14. package/Marquee/MarqueeDecorator.js +19 -3
  15. package/Marquee/tests/Marquee-specs.js +306 -1
  16. package/Marquee/useMarqueeController.js +6 -4
  17. package/Measurable/tests/Measurable-specs.js +6 -2
  18. package/Media/Media.js +5 -2
  19. package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +4 -1
  20. package/Resizable/tests/Resizable-specs.js +4 -1
  21. package/Resizable/tests/useResize-specs.js +4 -1
  22. package/Routable/Route.js +5 -3
  23. package/Routable/Router.js +25 -16
  24. package/Routable/tests/Routable-specs.js +16 -0
  25. package/Scroller/Scroller.js +6 -5
  26. package/Scroller/ScrollerBasic.js +5 -5
  27. package/Skinnable/Skinnable.js +9 -7
  28. package/Skinnable/tests/Skinnable-specs.js +7 -2
  29. package/Skinnable/useSkins.js +6 -2
  30. package/Slider/PositionDecorator.js +20 -5
  31. package/Slider/Slider.d.ts +4 -0
  32. package/Slider/Slider.js +10 -0
  33. package/Slider/tests/Slider-specs.js +18 -0
  34. package/Slider/utils.js +9 -1
  35. package/Toggleable/Toggleable.js +4 -2
  36. package/Toggleable/tests/Toggleable-specs.js +4 -1
  37. package/Touchable/Touchable.js +6 -4
  38. package/Touchable/tests/Touchable-specs.js +4 -1
  39. package/Touchable/tests/useTouch-specs.js +4 -1
  40. package/Touchable/useTouch.js +7 -2
  41. package/Transition/Transition.js +2 -0
  42. package/ViewManager/TransitionGroup.js +3 -0
  43. package/ViewManager/View.js +2 -0
  44. package/ViewManager/ViewManager.js +7 -0
  45. package/VirtualList/VirtualList.js +7 -5
  46. package/VirtualList/VirtualListBasic.js +170 -32
  47. package/VirtualList/tests/VirtualList-native-specs.js +233 -3
  48. package/VirtualList/tests/VirtualList-specs.js +13 -0
  49. package/internal/IdProvider/IdProvider.js +2 -0
  50. package/internal/IdProvider/tests/IdProvider-specs.js +4 -1
  51. package/internal/Pure/tests/Pure-specs.js +7 -0
  52. package/package.json +8 -3
  53. package/resolution/ResolutionDecorator.js +21 -18
  54. package/resolution/index.d.ts +63 -4
  55. package/resolution/index.js +18 -2
  56. package/resolution/resolution.js +209 -29
  57. package/resolution/tests/ResolutionDecorator-specs.js +84 -4
  58. package/resolution/tests/resolution-specs.js +217 -599
  59. package/useControlledState/tests/useControlledState-specs.js +4 -1
  60. package/useControlledState/useControlledState.js +11 -7
  61. package/useScroll/Scrollbar.js +27 -24
  62. package/useScroll/ScrollbarTrack.js +5 -3
  63. package/useScroll/tests/useScroll-specs.js +408 -42
  64. package/useScroll/useScroll.js +132 -27
  65. package/useScroll/utilEvent.js +18 -0
@@ -5,6 +5,16 @@ var _react = require("@testing-library/react");
5
5
  var _ResolutionDecorator = _interopRequireDefault(require("../ResolutionDecorator"));
6
6
  var _jsxRuntime = require("react/jsx-runtime");
7
7
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
8
+ var changeTargetResolution = function changeTargetResolution(target, width, height) {
9
+ Object.defineProperty(target, 'clientWidth', {
10
+ configurable: true,
11
+ value: width
12
+ });
13
+ Object.defineProperty(target, 'clientHeight', {
14
+ configurable: true,
15
+ value: height
16
+ });
17
+ };
8
18
  describe('ResolutionDecorator Specs', function () {
9
19
  test('should apply resolution classes to the wrapped component', function () {
10
20
  var Component = (0, _ResolutionDecorator["default"])('div');
@@ -16,6 +26,23 @@ describe('ResolutionDecorator Specs', function () {
16
26
  var actual = div.includes('enact-res-standard') && (div.includes('enact-orientation-landscape') || div.includes('enact-orientation-portrait'));
17
27
  expect(actual).toBe(expected);
18
28
  });
29
+ test('should not change resolution between renders if the screen stays the same', function () {
30
+ var Component = (0, _ResolutionDecorator["default"])('div');
31
+ var _render = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
32
+ "data-testid": "component"
33
+ })),
34
+ rerender = _render.rerender;
35
+ var expected = true;
36
+ var div = _react.screen.getByTestId('component').className;
37
+ var actual = div.includes('enact-res-standard') && (div.includes('enact-orientation-landscape') || div.includes('enact-orientation-portrait'));
38
+ expect(actual).toBe(expected);
39
+ rerender(/*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
40
+ "data-testid": "component"
41
+ }));
42
+ div = _react.screen.getByTestId('component').className;
43
+ actual = div.includes('enact-res-standard') && (div.includes('enact-orientation-landscape') || div.includes('enact-orientation-portrait'));
44
+ expect(actual).toBe(expected);
45
+ });
19
46
  test('should allow custom screen types', function () {
20
47
  var name = 'mhd';
21
48
  var screens = [{
@@ -35,10 +62,63 @@ describe('ResolutionDecorator Specs', function () {
35
62
  var div = _react.screen.getByTestId('component');
36
63
  expect(div).toHaveClass('enact-res-mhd');
37
64
  });
38
- test.skip('should update the resolution when the screen is resized', function () {
39
- // TODO: write a test
65
+ test('should update the resolution when the screen is resized', function () {
66
+ var screens = [{
67
+ name: 'hd',
68
+ pxPerRem: 16,
69
+ width: 1280,
70
+ height: 720,
71
+ aspectRatioName: 'hdtv',
72
+ base: true
73
+ }, {
74
+ name: 'fhd',
75
+ pxPerRem: 24,
76
+ width: 1920,
77
+ height: 1080,
78
+ aspectRatioName: 'hdtv'
79
+ }];
80
+ var Component = (0, _ResolutionDecorator["default"])({
81
+ screenTypes: screens
82
+ }, 'div');
83
+ (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
84
+ "data-testid": "component"
85
+ }));
86
+ var div = _react.screen.getByTestId('component');
87
+ changeTargetResolution(div, 1920, 1080);
88
+ (0, _react.fireEvent)(window, new Event('resize'));
89
+ expect(div).toHaveClass('enact-res-fhd');
90
+ changeTargetResolution(div, 1280, 720);
91
+ (0, _react.fireEvent)(window, new Event('resize'));
92
+ expect(div).toHaveClass('enact-res-hd');
93
+ expect(div).not.toHaveClass('enact-res-fhd');
40
94
  });
41
- test.skip('should not allow dynamic resolution updates when \'dynamic\' config option is false', function () {
42
- // TODO: write a test
95
+ test('should not allow dynamic resolution updates when \'dynamic\' config option is false', function () {
96
+ var screens = [{
97
+ name: 'mhd',
98
+ pxPerRem: 36,
99
+ width: 1440,
100
+ height: 920,
101
+ aspectRatioName: 'hdtv',
102
+ base: true
103
+ }, {
104
+ name: 'fhd',
105
+ pxPerRem: 24,
106
+ width: 1920,
107
+ height: 1080,
108
+ aspectRatioName: 'hdtv'
109
+ }];
110
+ var Component = (0, _ResolutionDecorator["default"])({
111
+ dynamic: false,
112
+ screenTypes: screens
113
+ }, 'div');
114
+ (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
115
+ "data-testid": "component"
116
+ }));
117
+ var div = _react.screen.getByTestId('component');
118
+ expect(div).toHaveClass('enact-res-mhd');
119
+ changeTargetResolution(div, 1920, 1080);
120
+ (0, _react.fireEvent)(window, new Event('resize'));
121
+ expect(div).toHaveClass('enact-res-mhd');
122
+ expect(div).not.toHaveClass('enact-res-fhd');
43
123
  });
44
124
  });