@enact/ui 4.5.1 → 4.5.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.
Files changed (167) hide show
  1. package/AnnounceDecorator/Announce.js +1 -40
  2. package/AnnounceDecorator/AnnounceDecorator.js +3 -21
  3. package/AnnounceDecorator/tests/Announce-specs.js +2 -7
  4. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +2 -6
  5. package/AnnounceDecorator/tests/useAnnounce-specs.js +8 -19
  6. package/AnnounceDecorator/useAnnounce.js +0 -6
  7. package/BodyText/BodyText.js +6 -26
  8. package/BodyText/tests/BodyText-specs.js +0 -19
  9. package/Button/Button.js +26 -56
  10. package/Button/tests/Button-specs.js +0 -26
  11. package/CHANGELOG.md +10 -0
  12. package/Cancelable/Cancelable.js +8 -47
  13. package/Cancelable/cancelHandler.js +5 -12
  14. package/Cancelable/modalHandler.js +3 -11
  15. package/Cancelable/tests/Cancelable-specs.js +3 -57
  16. package/Changeable/Changeable.js +2 -34
  17. package/Changeable/tests/Changeable-specs.js +20 -66
  18. package/ComponentOverride/ComponentOverride.js +1 -13
  19. package/FloatingLayer/FloatingLayer.js +17 -73
  20. package/FloatingLayer/FloatingLayerContainer.js +0 -15
  21. package/FloatingLayer/FloatingLayerDecorator.js +4 -17
  22. package/FloatingLayer/Scrim.js +9 -53
  23. package/FloatingLayer/index.js +0 -4
  24. package/FloatingLayer/tests/FloatingLayer-specs.js +8 -22
  25. package/FloatingLayer/tests/Scrim-specs.js +0 -9
  26. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +0 -13
  27. package/FloatingLayer/useFloatingLayer.js +3 -14
  28. package/FloatingLayer/useFloatingLayerDecorator.js +3 -11
  29. package/ForwardRef/ForwardRef.js +1 -10
  30. package/GridListImageItem/GridListImageItem.js +17 -50
  31. package/Group/Group.js +4 -35
  32. package/Group/GroupItem.js +15 -32
  33. package/Group/tests/Group-specs.js +0 -32
  34. package/Heading/Heading.js +7 -35
  35. package/Heading/tests/Heading-specs.js +81 -14
  36. package/Icon/Icon.js +14 -48
  37. package/Icon/tests/Icon-specs.js +0 -22
  38. package/IconButton/IconButton.js +12 -50
  39. package/IconButton/tests/IconButton-specs.js +0 -7
  40. package/Image/Image.js +16 -45
  41. package/Image/tests/Image-specs.js +0 -14
  42. package/ImageItem/ImageItem.js +17 -46
  43. package/ImageItem/tests/ImageItem-specs.js +0 -25
  44. package/Item/Item.js +8 -32
  45. package/Item/tests/Item-specs.js +0 -24
  46. package/LabeledIcon/LabeledIcon.js +19 -50
  47. package/LabeledIcon/tests/LabeledIcon-specs.js +0 -14
  48. package/Layout/Cell.js +11 -37
  49. package/Layout/Layout.js +14 -37
  50. package/Layout/tests/Layout-specs.js +10 -39
  51. package/Marquee/MarqueeBase.js +31 -64
  52. package/Marquee/MarqueeController.js +11 -72
  53. package/Marquee/MarqueeDecorator.js +62 -196
  54. package/Marquee/index.js +1 -5
  55. package/Marquee/tests/Marquee-specs.js +258 -87
  56. package/Measurable/Measurable.js +12 -34
  57. package/Measurable/tests/Measurable-specs.js +115 -0
  58. package/Media/Media.js +15 -65
  59. package/Media/tests/Media-specs.js +168 -0
  60. package/Placeholder/PlaceholderControllerDecorator.js +7 -43
  61. package/Placeholder/PlaceholderDecorator.js +7 -38
  62. package/Placeholder/index.js +0 -4
  63. package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +25 -0
  64. package/Placeholder/tests/PlaceholderDecorator-specs.js +28 -0
  65. package/ProgressBar/ProgressBar.js +13 -44
  66. package/ProgressBar/tests/ProgressBar-specs.js +0 -17
  67. package/RadioDecorator/RadioControllerDecorator.js +1 -29
  68. package/RadioDecorator/RadioDecorator.js +4 -42
  69. package/RadioDecorator/tests/RadioDecorator-specs.js +12 -49
  70. package/Repeater/Repeater.js +9 -33
  71. package/Repeater/tests/Repeater-specs.js +0 -38
  72. package/Resizable/Resizable.js +7 -35
  73. package/Resizable/tests/Resizable-specs.js +34 -0
  74. package/Routable/Link.js +8 -44
  75. package/Routable/Routable.js +10 -33
  76. package/Routable/Route.js +0 -6
  77. package/Routable/Router.js +13 -56
  78. package/Routable/tests/Routable-specs.js +7 -33
  79. package/Routable/tests/Router-specs.js +18 -44
  80. package/Routable/useLink.js +4 -8
  81. package/Routable/util.js +18 -24
  82. package/Scrollable/ScrollAnimator.js +49 -65
  83. package/Scrollable/ScrollThumb.js +2 -13
  84. package/Scrollable/Scrollable.js +179 -386
  85. package/Scrollable/ScrollableNative.js +188 -391
  86. package/Scrollable/Scrollbar.js +28 -100
  87. package/Scroller/Scroller.js +15 -39
  88. package/Scroller/ScrollerBasic.js +34 -89
  89. package/Scroller/UiScrollerBase.js +31 -84
  90. package/Skinnable/Skinnable.js +11 -38
  91. package/Skinnable/tests/Skinnable-specs.js +3 -74
  92. package/Skinnable/tests/useSkins-specs.js +1 -13
  93. package/Skinnable/tests/util-specs.js +0 -14
  94. package/Skinnable/useSkins.js +8 -15
  95. package/Skinnable/util.js +9 -20
  96. package/Slider/Knob.js +5 -24
  97. package/Slider/PositionDecorator.js +16 -54
  98. package/Slider/Slider.js +26 -64
  99. package/Slider/tests/Slider-specs.js +94 -7
  100. package/Slider/utils.js +0 -2
  101. package/SlotItem/SlotItem.js +15 -41
  102. package/SlotItem/tests/SlotItem-specs.js +0 -5
  103. package/Slottable/Slottable.js +4 -12
  104. package/Slottable/tests/Slottable-specs.js +19 -46
  105. package/Slottable/tests/useSlots-specs.js +27 -65
  106. package/Slottable/useSlots.js +8 -33
  107. package/Spinner/Spinner.js +15 -42
  108. package/Spinner/tests/Spinner-specs.js +0 -15
  109. package/ToggleIcon/ToggleIcon.js +10 -36
  110. package/ToggleIcon/tests/ToggleIcon-specs.js +0 -16
  111. package/ToggleItem/ToggleItem.js +15 -52
  112. package/ToggleItem/tests/ToggleItem-specs.js +0 -30
  113. package/Toggleable/Toggle.js +1 -15
  114. package/Toggleable/Toggleable.js +12 -45
  115. package/Toggleable/tests/Toggleable-specs.js +28 -96
  116. package/Toggleable/useToggle.js +3 -19
  117. package/Touchable/ClickAllow.js +5 -14
  118. package/Touchable/Drag.js +16 -54
  119. package/Touchable/Flick.js +11 -42
  120. package/Touchable/Hold.js +21 -68
  121. package/Touchable/Touch.js +37 -65
  122. package/Touchable/Touchable.js +32 -71
  123. package/Touchable/config.js +8 -22
  124. package/Touchable/tests/Touchable-specs.js +270 -119
  125. package/Touchable/tests/useTouch-specs.js +6 -80
  126. package/Touchable/useTouch.js +17 -34
  127. package/Transition/Transition.js +37 -118
  128. package/Transition/tests/Transition-specs.js +20 -60
  129. package/ViewManager/Arranger.js +10 -22
  130. package/ViewManager/TransitionGroup.js +31 -106
  131. package/ViewManager/View.js +35 -91
  132. package/ViewManager/ViewManager.js +19 -83
  133. package/ViewManager/tests/View-specs.js +0 -17
  134. package/ViewManager/tests/ViewManager-specs.js +236 -305
  135. package/ViewManager/tests/test-utils.js +0 -8
  136. package/VirtualList/UiVirtualListBase.js +256 -406
  137. package/VirtualList/VirtualList.js +29 -69
  138. package/VirtualList/VirtualListBase.js +0 -3
  139. package/VirtualList/VirtualListBasic.js +270 -428
  140. package/VirtualList/tests/VirtualList-specs.js +9 -37
  141. package/internal/IdProvider/IdProvider.js +7 -21
  142. package/internal/IdProvider/Provider.js +4 -17
  143. package/internal/IdProvider/tests/IdProvider-specs.js +44 -0
  144. package/internal/IdProvider/tests/useId-specs.js +7 -22
  145. package/internal/IdProvider/useId.js +0 -6
  146. package/internal/Pure/Pure.js +3 -30
  147. package/internal/Pure/tests/Pure-specs.js +88 -0
  148. package/internal/localized-fonts/localized-fonts.js +33 -62
  149. package/internal/localized-fonts/tests/localized-fonts-specs.js +33 -0
  150. package/internal/selection/selection.js +1 -6
  151. package/internal/selection/tests/selection-specs.js +6 -4
  152. package/internal/validators/tests/validators-specs.js +80 -0
  153. package/internal/validators/validators.js +14 -34
  154. package/package.json +8 -2
  155. package/resolution/ResolutionDecorator.js +4 -40
  156. package/resolution/index.js +0 -7
  157. package/resolution/resolution.js +42 -80
  158. package/resolution/tests/ResolutionDecorator-specs.js +4 -11
  159. package/resolution/tests/resolution-specs.js +2 -2
  160. package/useControlledState/tests/useControlledState-specs.js +15 -46
  161. package/useControlledState/useControlledState.js +11 -22
  162. package/useScroll/ScrollAnimator.js +49 -65
  163. package/useScroll/Scrollbar.js +22 -58
  164. package/useScroll/ScrollbarTrack.js +3 -19
  165. package/useScroll/useScroll.js +267 -454
  166. package/useScroll/utilDOM.js +8 -14
  167. package/useScroll/utilEvent.js +0 -4
@@ -1,112 +1,83 @@
1
1
  "use strict";
2
2
 
3
3
  require("@testing-library/jest-dom");
4
-
5
4
  var _react = require("@testing-library/react");
6
-
7
5
  var _useControlledState3 = _interopRequireDefault(require("../useControlledState"));
8
-
9
6
  var _jsxRuntime = require("react/jsx-runtime");
10
-
11
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
-
13
8
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
-
15
9
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
16
-
17
10
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18
-
19
11
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
20
-
21
12
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
22
-
23
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
-
25
14
  describe('useControlledState', function () {
26
15
  var data;
27
-
28
16
  function Component(props) {
29
17
  var _useControlledState = (0, _useControlledState3["default"])(props.defaultValue, props.value, 'value' in props),
30
- _useControlledState2 = _slicedToArray(_useControlledState, 2),
31
- value = _useControlledState2[0],
32
- setValue = _useControlledState2[1];
33
-
18
+ _useControlledState2 = _slicedToArray(_useControlledState, 2),
19
+ value = _useControlledState2[0],
20
+ setValue = _useControlledState2[1];
34
21
  var handleChange = function handleChange(ev) {
35
22
  return setValue(ev.value);
36
23
  };
37
-
38
24
  data = setValue;
39
25
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
40
26
  onChange: handleChange,
41
27
  children: value
42
28
  });
43
29
  }
44
-
45
30
  test('should use the default value when the value is undefined', function () {
46
31
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
47
32
  defaultValue: "abc"
48
33
  }));
49
-
50
34
  var actual = _react.screen.queryByText('abc');
51
-
52
35
  expect(actual).toBeInTheDocument();
53
36
  });
54
37
  test('should not change default value', function () {
55
38
  var _render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
56
- defaultValue: "abc"
57
- })),
58
- rerender = _render.rerender;
59
-
39
+ defaultValue: "abc"
40
+ })),
41
+ rerender = _render.rerender;
60
42
  rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
61
43
  defaultValue: "def"
62
44
  }));
63
-
64
45
  var actual = _react.screen.queryByText('abc');
65
-
66
46
  expect(actual).toBeInTheDocument();
67
47
  });
68
48
  test('should not change uncontrolled setting', function () {
69
49
  var _render2 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
70
- defaultValue: "abc"
71
- })),
72
- rerender = _render2.rerender;
73
-
50
+ defaultValue: "abc"
51
+ })),
52
+ rerender = _render2.rerender;
74
53
  rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
75
54
  defaultValue: null,
76
55
  value: "def"
77
56
  }));
78
-
79
57
  var actual = _react.screen.queryByText('abc');
80
-
81
58
  expect(actual).toBeInTheDocument();
82
59
  });
83
60
  test('should update controlled value', function () {
84
61
  var _render3 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
85
- value: "abc"
86
- })),
87
- rerender = _render3.rerender;
88
-
62
+ value: "abc"
63
+ })),
64
+ rerender = _render3.rerender;
89
65
  rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
90
66
  value: "def"
91
67
  }));
92
-
93
68
  var actual = _react.screen.queryByText('def');
94
-
95
69
  expect(actual).toBeInTheDocument();
96
70
  });
97
71
  test('should not change controlled setting', function () {
98
72
  var _render4 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
99
- value: "abc"
100
- })),
101
- rerender = _render4.rerender;
102
-
73
+ value: "abc"
74
+ })),
75
+ rerender = _render4.rerender;
103
76
  rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
104
77
  defaultValue: "def",
105
78
  value: "ghi"
106
79
  }));
107
-
108
80
  var actual = _react.screen.queryByText('ghi');
109
-
110
81
  expect(actual).toBeInTheDocument();
111
82
  });
112
83
  test('should not allow setting a value when controlled', function () {
@@ -116,9 +87,7 @@ describe('useControlledState', function () {
116
87
  onChange: handleChange,
117
88
  value: "abc"
118
89
  }));
119
-
120
90
  var component = _react.screen.queryByText('abc');
121
-
122
91
  data(value);
123
92
  expect(component).toBeInTheDocument();
124
93
  });
@@ -5,60 +5,49 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  exports.useControlledState = useControlledState;
8
-
9
8
  var _react = require("react");
10
-
11
9
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
-
13
10
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
-
15
11
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
-
17
12
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
18
-
19
13
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
20
-
21
14
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
+ function nop() {}
22
16
 
23
- function nop() {} // Generate a handler that hides the controlled value from users, supports functional callbacks,
17
+ // Generate a handler that hides the controlled value from users, supports functional callbacks,
24
18
  // and is memoized by the onChange provided by useState
25
-
26
-
27
19
  function createHandler() {
28
20
  return function (onChange, currentValue, controlled) {
29
21
  if (controlled) {
30
22
  return nop;
31
23
  }
32
-
33
24
  return function (value) {
34
25
  if (value !== currentValue) {
35
26
  onChange(value);
36
27
  }
37
28
  };
38
29
  };
39
- } // always return the prop value when controlled and the state value when not
40
-
30
+ }
41
31
 
32
+ // always return the prop value when controlled and the state value when not
42
33
  function calcValue(defaultValue, propValue, stateValue, controlled) {
43
34
  if (!controlled) {
44
35
  return stateValue;
45
- } // eslint-disable-next-line no-undefined
46
-
36
+ }
47
37
 
38
+ // eslint-disable-next-line no-undefined
48
39
  return propValue !== undefined ? propValue : defaultValue;
49
40
  }
50
-
51
41
  function useControlledState(defaultValue, propValue, controlled) {
52
- var isControlled = (0, _react.useRef)(controlled); // Store both the value and the "controlled" flag in a state hook
42
+ var isControlled = (0, _react.useRef)(controlled);
53
43
 
44
+ // Store both the value and the "controlled" flag in a state hook
54
45
  var _useState = (0, _react.useState)(defaultValue),
55
- _useState2 = _slicedToArray(_useState, 2),
56
- value = _useState2[0],
57
- onChange = _useState2[1];
58
-
46
+ _useState2 = _slicedToArray(_useState, 2),
47
+ value = _useState2[0],
48
+ onChange = _useState2[1];
59
49
  var memoOnChange = (0, _react.useMemo)(createHandler, [onChange, value, isControlled.current]);
60
50
  return [calcValue(defaultValue, propValue, value, isControlled.current), memoOnChange(onChange, value, isControlled.current)];
61
51
  }
62
-
63
52
  var _default = useControlledState;
64
53
  exports["default"] = _default;
@@ -4,56 +4,49 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = exports.ScrollAnimator = void 0;
7
-
8
7
  var _util = require("@enact/core/util");
9
-
10
8
  var _clamp = _interopRequireDefault(require("ramda/src/clamp"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
10
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
-
16
11
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17
-
18
12
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
19
-
20
- var // Use eases library
21
- timingFunctions = {
22
- 'linear': function linear(source, target, duration, curTime) {
23
- curTime /= duration;
24
- return (target - source) * curTime + source;
25
- },
26
- 'ease-in': function easeIn(source, target, duration, curTime) {
27
- curTime /= duration;
28
- return (target - source) * curTime * curTime * curTime * curTime + source;
29
- },
30
- 'ease-out': function easeOut(source, target, duration, curTime) {
31
- curTime /= duration;
32
- curTime--;
33
- return (target - source) * (curTime * curTime * curTime * curTime * curTime + 1) + source;
34
- },
35
- 'ease-in-out': function easeInOut(source, target, duration, curTime) {
36
- curTime /= duration / 2;
37
-
38
- if (curTime < 1) {
39
- return (target - source) / 2 * curTime * curTime * curTime * curTime + source;
40
- } else {
41
- curTime -= 2;
13
+ var
14
+ // Use eases library
15
+ timingFunctions = {
16
+ 'linear': function linear(source, target, duration, curTime) {
17
+ curTime /= duration;
18
+ return (target - source) * curTime + source;
19
+ },
20
+ 'ease-in': function easeIn(source, target, duration, curTime) {
21
+ curTime /= duration;
22
+ return (target - source) * curTime * curTime * curTime * curTime + source;
23
+ },
24
+ 'ease-out': function easeOut(source, target, duration, curTime) {
25
+ curTime /= duration;
26
+ curTime--;
27
+ return (target - source) * (curTime * curTime * curTime * curTime * curTime + 1) + source;
28
+ },
29
+ 'ease-in-out': function easeInOut(source, target, duration, curTime) {
30
+ curTime /= duration / 2;
31
+ if (curTime < 1) {
32
+ return (target - source) / 2 * curTime * curTime * curTime * curTime + source;
33
+ } else {
34
+ curTime -= 2;
35
+ }
36
+ return (source - target) / 2 * (curTime * curTime * curTime * curTime - 2) + source;
42
37
  }
38
+ },
39
+ // for simulate()
40
+ frameTime = 16.0,
41
+ // time for one frame
42
+ maxVelocity = 100,
43
+ // speed cap
44
+ stopVelocity = 0.04,
45
+ // velocity to stop
46
+ velocityFriction = 0.95,
47
+ // velocity decreasing factor
48
+ clampVelocity = (0, _clamp["default"])(-maxVelocity, maxVelocity);
43
49
 
44
- return (source - target) / 2 * (curTime * curTime * curTime * curTime - 2) + source;
45
- }
46
- },
47
- // for simulate()
48
- frameTime = 16.0,
49
- // time for one frame
50
- maxVelocity = 100,
51
- // speed cap
52
- stopVelocity = 0.04,
53
- // velocity to stop
54
- velocityFriction = 0.95,
55
- // velocity decreasing factor
56
- clampVelocity = (0, _clamp["default"])(-maxVelocity, maxVelocity);
57
50
  /**
58
51
  * The class to scroll a list or a scroller with animation.
59
52
  *
@@ -61,7 +54,6 @@ clampVelocity = (0, _clamp["default"])(-maxVelocity, maxVelocity);
61
54
  * @memberof ui/useScroll
62
55
  * @private
63
56
  */
64
-
65
57
  var ScrollAnimator = /*#__PURE__*/function () {
66
58
  /**
67
59
  * @param {String|null} type - Timing function type for list scroll animation. Must be one of
@@ -72,21 +64,18 @@ var ScrollAnimator = /*#__PURE__*/function () {
72
64
  */
73
65
  function ScrollAnimator(type) {
74
66
  _classCallCheck(this, ScrollAnimator);
75
-
76
67
  this.rAFId = null;
77
68
  this.type = 'ease-out';
78
69
  this.timingFunction = timingFunctions[type || this.type];
79
70
  }
80
-
81
71
  _createClass(ScrollAnimator, [{
82
72
  key: "simulate",
83
73
  value: function simulate(sourceX, sourceY, velocityX, velocityY) {
84
74
  var stepX = clampVelocity(velocityX * frameTime),
85
- stepY = clampVelocity(velocityY * frameTime),
86
- deltaX = 0,
87
- deltaY = 0,
88
- duration = 0;
89
-
75
+ stepY = clampVelocity(velocityY * frameTime),
76
+ deltaX = 0,
77
+ deltaY = 0,
78
+ duration = 0;
90
79
  do {
91
80
  stepX *= velocityFriction;
92
81
  stepY *= velocityFriction;
@@ -94,7 +83,6 @@ var ScrollAnimator = /*#__PURE__*/function () {
94
83
  deltaY += stepY;
95
84
  duration += frameTime;
96
85
  } while (stepX * stepX + stepY * stepY > stopVelocity);
97
-
98
86
  return {
99
87
  targetX: sourceX + deltaX,
100
88
  targetY: sourceY + deltaY,
@@ -105,20 +93,19 @@ var ScrollAnimator = /*#__PURE__*/function () {
105
93
  key: "animate",
106
94
  value: function animate(rAFCallbackFuntion) {
107
95
  var _this = this;
108
-
109
96
  var rAF = window.requestAnimationFrame,
110
- startTimeStamp = (0, _util.perfNow)(),
111
- fn = function fn() {
112
- var // schedule next frame
113
- rAFId = rAF(fn),
97
+ startTimeStamp = (0, _util.perfNow)(),
98
+ fn = function fn() {
99
+ var
100
+ // schedule next frame
101
+ rAFId = rAF(fn),
114
102
  // current timestamp
115
- curTimeStamp = (0, _util.perfNow)(),
103
+ curTimeStamp = (0, _util.perfNow)(),
116
104
  // current time if 0 at starting position
117
- curTime = curTimeStamp - startTimeStamp;
118
- _this.rAFId = rAFId;
119
- rAFCallbackFuntion(curTime);
120
- };
121
-
105
+ curTime = curTimeStamp - startTimeStamp;
106
+ _this.rAFId = rAFId;
107
+ rAFCallbackFuntion(curTime);
108
+ };
122
109
  this.rAFId = rAF(fn);
123
110
  }
124
111
  }, {
@@ -130,17 +117,14 @@ var ScrollAnimator = /*#__PURE__*/function () {
130
117
  key: "stop",
131
118
  value: function stop() {
132
119
  var cAF = window.cancelAnimationFrame;
133
-
134
120
  if (this.rAFId !== null) {
135
121
  cAF(this.rAFId);
136
122
  this.rAFId = null;
137
123
  }
138
124
  }
139
125
  }]);
140
-
141
126
  return ScrollAnimator;
142
127
  }();
143
-
144
128
  exports.ScrollAnimator = ScrollAnimator;
145
129
  var _default = ScrollAnimator;
146
130
  exports["default"] = _default;
@@ -11,37 +11,21 @@ Object.defineProperty(exports, "ScrollbarTrack", {
11
11
  }
12
12
  });
13
13
  exports.useScrollbar = exports["default"] = void 0;
14
-
15
14
  var _classnames = _interopRequireDefault(require("classnames"));
16
-
17
15
  var _util = require("@enact/core/util");
18
-
19
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
20
-
21
17
  var _react = require("react");
22
-
23
18
  var _resolution = _interopRequireDefault(require("../resolution"));
24
-
25
19
  var _ScrollbarTrack = _interopRequireDefault(require("./ScrollbarTrack"));
26
-
27
20
  var _ScrollbarModule = _interopRequireDefault(require("./Scrollbar.module.css"));
28
-
29
21
  var _jsxRuntime = require("react/jsx-runtime");
30
-
31
22
  var _excluded = ["className", "clientSize", "corner", "css", "minThumbSize", "scrollbarHandle", "vertical"];
32
-
33
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
34
-
35
24
  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; }
36
-
37
25
  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; }
38
-
39
26
  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; }
40
-
41
27
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
42
-
43
28
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
44
-
45
29
  var scrollbarTrackHidingDelay = 900; // 900ms + 100ms(fade out duration) = 1000ms.
46
30
 
47
31
  var addClass = function addClass(element, className) {
@@ -49,12 +33,12 @@ var addClass = function addClass(element, className) {
49
33
  element.classList.add(className);
50
34
  }
51
35
  };
52
-
53
36
  var removeClass = function removeClass(element, className) {
54
37
  if (element) {
55
38
  element.classList.remove(className);
56
39
  }
57
40
  };
41
+
58
42
  /*
59
43
  * Set CSS Variable value.
60
44
  *
@@ -63,11 +47,10 @@ var removeClass = function removeClass(element, className) {
63
47
  * @param {String} variable - CSS Variable property.
64
48
  * @param {String} value - CSS Variable value.
65
49
  */
66
-
67
-
68
50
  var setCSSVariable = function setCSSVariable(element, variable, value) {
69
51
  element.style.setProperty(variable, value);
70
52
  };
53
+
71
54
  /**
72
55
  * A custom hook that passes scrollbar behavior information as its render prop.
73
56
  *
@@ -76,60 +59,50 @@ var setCSSVariable = function setCSSVariable(element, variable, value) {
76
59
  * @ui
77
60
  * @private
78
61
  */
79
-
80
-
81
62
  var useScrollbar = function useScrollbar(props) {
82
63
  var className = props.className,
83
- clientSize = props.clientSize,
84
- corner = props.corner,
85
- css = props.css,
86
- minThumbSize = props.minThumbSize,
87
- scrollbarHandle = props.scrollbarHandle,
88
- vertical = props.vertical,
89
- rest = _objectWithoutProperties(props, _excluded); // Refs
90
-
91
-
64
+ clientSize = props.clientSize,
65
+ corner = props.corner,
66
+ css = props.css,
67
+ minThumbSize = props.minThumbSize,
68
+ scrollbarHandle = props.scrollbarHandle,
69
+ vertical = props.vertical,
70
+ rest = _objectWithoutProperties(props, _excluded);
71
+ // Refs
92
72
  var scrollbarContainerRef = (0, _react.useRef)();
93
73
  var scrollbarTrackRef = (0, _react.useRef)();
94
74
  var hideScrollbarTrackJob = (0, _react.useRef)(null);
95
75
  hideScrollbarTrackJob.current = hideScrollbarTrackJob.current || new _util.Job(hideScrollbarTrack, scrollbarTrackHidingDelay);
96
-
97
76
  function hideScrollbarTrack() {
98
77
  removeClass(scrollbarTrackRef.current, css.scrollbarTrackShown);
99
78
  }
100
-
101
79
  (0, _react.useEffect)(function () {
102
80
  return function () {
103
81
  hideScrollbarTrackJob.current.stop();
104
82
  };
105
83
  }, []);
106
-
107
84
  function getContainerRef() {
108
85
  return scrollbarContainerRef;
109
86
  }
110
-
111
87
  function showScrollbarTrack() {
112
88
  hideScrollbarTrackJob.current.stop();
113
89
  addClass(scrollbarTrackRef.current, css.scrollbarTrackShown);
114
90
  }
115
-
116
91
  function startHidingScrollbarTrack() {
117
92
  hideScrollbarTrackJob.current.start();
118
93
  }
119
-
120
94
  function update(bounds) {
121
95
  var primaryDimension = vertical ? 'clientHeight' : 'clientWidth',
122
- trackSize = clientSize ? clientSize[primaryDimension] : scrollbarContainerRef.current[primaryDimension],
123
- scrollViewSize = vertical ? bounds.clientHeight : bounds.clientWidth,
124
- scrollContentSize = vertical ? bounds.scrollHeight : bounds.scrollWidth,
125
- scrollOrigin = vertical ? bounds.scrollTop : bounds.scrollLeft,
126
- scrollbarThumbSizeRatioBase = scrollViewSize / scrollContentSize,
127
- scrollbarThumbProgressRatio = scrollOrigin / (scrollContentSize - scrollViewSize),
128
- scrollbarThumbSizeRatio = Math.max(_resolution["default"].scale(minThumbSize) / trackSize, Math.min(1, scrollbarThumbSizeRatioBase));
96
+ trackSize = clientSize ? clientSize[primaryDimension] : scrollbarContainerRef.current[primaryDimension],
97
+ scrollViewSize = vertical ? bounds.clientHeight : bounds.clientWidth,
98
+ scrollContentSize = vertical ? bounds.scrollHeight : bounds.scrollWidth,
99
+ scrollOrigin = vertical ? bounds.scrollTop : bounds.scrollLeft,
100
+ scrollbarThumbSizeRatioBase = scrollViewSize / scrollContentSize,
101
+ scrollbarThumbProgressRatio = scrollOrigin / (scrollContentSize - scrollViewSize),
102
+ scrollbarThumbSizeRatio = Math.max(_resolution["default"].scale(minThumbSize) / trackSize, Math.min(1, scrollbarThumbSizeRatioBase));
129
103
  setCSSVariable(scrollbarTrackRef.current, '--scrollbar-thumb-size-ratio', scrollbarThumbSizeRatio);
130
104
  setCSSVariable(scrollbarTrackRef.current, '--scrollbar-thumb-progress-ratio', scrollbarThumbProgressRatio);
131
105
  }
132
-
133
106
  if (scrollbarHandle) {
134
107
  scrollbarHandle.current = {
135
108
  getContainerRef: getContainerRef,
@@ -138,7 +111,6 @@ var useScrollbar = function useScrollbar(props) {
138
111
  update: update
139
112
  };
140
113
  }
141
-
142
114
  return {
143
115
  restProps: rest,
144
116
  scrollbarProps: {
@@ -151,6 +123,7 @@ var useScrollbar = function useScrollbar(props) {
151
123
  }
152
124
  };
153
125
  };
126
+
154
127
  /**
155
128
  * An unstyled scroll bar.
156
129
  *
@@ -159,24 +132,19 @@ var useScrollbar = function useScrollbar(props) {
159
132
  * @ui
160
133
  * @private
161
134
  */
162
-
163
-
164
135
  exports.useScrollbar = useScrollbar;
165
136
  var Scrollbar = /*#__PURE__*/(0, _react.memo)(function (props) {
166
137
  var _useScrollbar = useScrollbar(props),
167
- restProps = _useScrollbar.restProps,
168
- scrollbarProps = _useScrollbar.scrollbarProps,
169
- scrollbarTrackProps = _useScrollbar.scrollbarTrackProps;
170
-
138
+ restProps = _useScrollbar.restProps,
139
+ scrollbarProps = _useScrollbar.scrollbarProps,
140
+ scrollbarTrackProps = _useScrollbar.scrollbarTrackProps;
171
141
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread(_objectSpread({}, restProps), scrollbarProps), {}, {
172
142
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScrollbarTrack["default"], _objectSpread({}, scrollbarTrackProps))
173
143
  }));
174
144
  });
175
145
  exports.ScrollbarBase = exports.Scrollbar = Scrollbar;
176
146
  Scrollbar.displayName = 'ui:Scrollbar';
177
- Scrollbar.propTypes =
178
- /** @lends ui/useScroll.Scrollbar.prototype */
179
- {
147
+ Scrollbar.propTypes = /** @lends ui/useScroll.Scrollbar.prototype */{
180
148
  /**
181
149
  * Client size of the container; valid values are an object that has `clientWidth` and `clientHeight`.
182
150
  *
@@ -189,7 +157,6 @@ Scrollbar.propTypes =
189
157
  clientHeight: _propTypes["default"].number.isRequired,
190
158
  clientWidth: _propTypes["default"].number.isRequired
191
159
  }),
192
-
193
160
  /**
194
161
  * Adds a corner between the vertical and horizontal scrollbars.
195
162
  *
@@ -198,7 +165,6 @@ Scrollbar.propTypes =
198
165
  * @public
199
166
  */
200
167
  corner: _propTypes["default"].bool,
201
-
202
168
  /**
203
169
  * Customizes the component by mapping the supplied collection of CSS class names to the
204
170
  * corresponding internal elements and states of this component.
@@ -211,7 +177,6 @@ Scrollbar.propTypes =
211
177
  * @public
212
178
  */
213
179
  css: _propTypes["default"].object,
214
-
215
180
  /**
216
181
  * The minimum size of the thumb.
217
182
  *
@@ -221,7 +186,6 @@ Scrollbar.propTypes =
221
186
  * @public
222
187
  */
223
188
  minThumbSize: _propTypes["default"].number,
224
-
225
189
  /**
226
190
  * If `true`, the scrollbar will be oriented vertically.
227
191
  *
@@ -4,31 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = exports.ScrollbarTrackBase = exports.ScrollbarTrack = void 0;
7
-
8
7
  var _classnames = _interopRequireDefault(require("classnames"));
9
-
10
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
9
  var _react = require("react");
13
-
14
10
  var _ScrollbarTrackModule = _interopRequireDefault(require("./ScrollbarTrack.module.css"));
15
-
16
11
  var _jsxRuntime = require("react/jsx-runtime");
17
-
18
12
  var _excluded = ["vertical"];
19
-
20
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
-
22
14
  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; }
23
-
24
15
  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; }
25
-
26
16
  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; }
27
-
28
17
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
29
-
30
18
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
31
-
32
19
  /**
33
20
  * An unstyled scroll track without any behavior.
34
21
  *
@@ -39,9 +26,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
39
26
  */
40
27
  var ScrollbarTrack = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
41
28
  var vertical = props.vertical,
42
- rest = _objectWithoutProperties(props, _excluded),
43
- className = (0, _classnames["default"])(_ScrollbarTrackModule["default"].scrollbarTrack, vertical ? _ScrollbarTrackModule["default"].vertical : null);
44
-
29
+ rest = _objectWithoutProperties(props, _excluded),
30
+ className = (0, _classnames["default"])(_ScrollbarTrackModule["default"].scrollbarTrack, vertical ? _ScrollbarTrackModule["default"].vertical : null);
45
31
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, rest), {}, {
46
32
  className: className,
47
33
  ref: ref
@@ -49,9 +35,7 @@ var ScrollbarTrack = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
49
35
  });
50
36
  exports.ScrollbarTrackBase = exports.ScrollbarTrack = ScrollbarTrack;
51
37
  ScrollbarTrack.displayName = 'ui:ScrollbarTrack';
52
- ScrollbarTrack.propTypes =
53
- /** @lends ui/useScroll.ScrollbarTrack.prototype */
54
- {
38
+ ScrollbarTrack.propTypes = /** @lends ui/useScroll.ScrollbarTrack.prototype */{
55
39
  /**
56
40
  * If `true`, the scrollbar will be oriented vertically.
57
41
  *