@enact/ui 4.9.2 → 5.0.0-alpha.2

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 (181) hide show
  1. package/AnnounceDecorator/Announce.js +20 -22
  2. package/AnnounceDecorator/AnnounceDecorator.js +5 -5
  3. package/AnnounceDecorator/tests/Announce-specs.js +1 -1
  4. package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +1 -1
  5. package/AnnounceDecorator/tests/useAnnounce-specs.js +1 -1
  6. package/AnnounceDecorator/useAnnounce.js +1 -1
  7. package/BodyText/BodyText.js +5 -5
  8. package/BodyText/tests/BodyText-specs.js +1 -1
  9. package/Button/Button.js +5 -5
  10. package/Button/tests/Button-specs.js +3 -3
  11. package/CHANGELOG.md +33 -0
  12. package/Cancelable/Cancelable.js +22 -24
  13. package/Cancelable/tests/Cancelable-specs.js +4 -4
  14. package/Changeable/Changeable.js +22 -24
  15. package/Changeable/tests/Changeable-specs.js +1 -1
  16. package/ComponentOverride/ComponentOverride.js +4 -4
  17. package/FloatingLayer/FloatingLayer.js +20 -22
  18. package/FloatingLayer/FloatingLayerContainer.js +6 -7
  19. package/FloatingLayer/FloatingLayerDecorator.js +5 -5
  20. package/FloatingLayer/Scrim.js +18 -20
  21. package/FloatingLayer/tests/FloatingLayer-specs.js +1 -1
  22. package/FloatingLayer/tests/Scrim-specs.js +1 -1
  23. package/FloatingLayer/tests/useFloatingLayerDecorator-specs.js +2 -2
  24. package/FloatingLayer/useFloatingLayer.js +4 -4
  25. package/FloatingLayer/useFloatingLayerDecorator.js +1 -1
  26. package/ForwardRef/ForwardRef.js +3 -3
  27. package/Group/Group.js +5 -5
  28. package/Group/GroupItem.js +5 -5
  29. package/Group/tests/Group-specs.js +4 -4
  30. package/Heading/Heading.js +5 -5
  31. package/Heading/tests/Heading-specs.js +1 -1
  32. package/Icon/Icon.js +5 -5
  33. package/Icon/tests/Icon-specs.js +1 -1
  34. package/Image/Image.js +5 -5
  35. package/Image/tests/Image-specs.js +1 -1
  36. package/ImageItem/ImageItem.js +5 -5
  37. package/ImageItem/tests/ImageItem-specs.js +3 -3
  38. package/Item/Item.js +5 -5
  39. package/Item/tests/Item-specs.js +3 -3
  40. package/LabeledIcon/LabeledIcon.js +5 -5
  41. package/LabeledIcon/tests/LabeledIcon-specs.js +1 -1
  42. package/Layout/Cell.js +5 -5
  43. package/Layout/Layout.js +5 -5
  44. package/Layout/tests/Layout-specs.js +7 -7
  45. package/Marquee/MarqueeBase.js +5 -5
  46. package/Marquee/MarqueeController.js +3 -3
  47. package/Marquee/MarqueeDecorator.js +30 -51
  48. package/Marquee/index.d.ts +10 -14
  49. package/Marquee/index.js +1 -1
  50. package/Marquee/tests/Marquee-specs.js +5 -6
  51. package/Marquee/useMarqueeController.js +2 -2
  52. package/Measurable/Measurable.js +8 -8
  53. package/Measurable/tests/Measurable-specs.js +8 -10
  54. package/Media/Media.js +17 -19
  55. package/Placeholder/PlaceholderControllerDecorator.js +22 -24
  56. package/Placeholder/PlaceholderDecorator.js +20 -22
  57. package/Placeholder/index.js +1 -1
  58. package/Placeholder/tests/PlaceholderControllerDecorator-specs.js +2 -2
  59. package/Placeholder/tests/PlaceholderDecorator-specs.js +1 -1
  60. package/ProgressBar/ProgressBar.js +5 -5
  61. package/ProgressBar/tests/ProgressBar-specs.js +1 -1
  62. package/Repeater/Repeater.js +5 -5
  63. package/Repeater/tests/Repeater-specs.js +3 -3
  64. package/Resizable/Resizable.js +3 -3
  65. package/Resizable/tests/Resizable-specs.js +2 -2
  66. package/Resizable/tests/useResize-specs.js +3 -3
  67. package/Resizable/useResize.js +3 -3
  68. package/Routable/Link.js +17 -19
  69. package/Routable/Routable.js +5 -5
  70. package/Routable/Route.js +1 -1
  71. package/Routable/Router.js +22 -24
  72. package/Routable/tests/Routable-specs.js +9 -9
  73. package/Routable/tests/Router-specs.js +1 -1
  74. package/Routable/util.js +1 -1
  75. package/Scroller/Scroller.d.ts +0 -120
  76. package/Scroller/Scroller.js +3 -11
  77. package/Scroller/ScrollerBasic.js +19 -21
  78. package/Scroller/tests/Scroller-specs.js +1 -1
  79. package/Skinnable/Skinnable.js +5 -5
  80. package/Skinnable/tests/Skinnable-specs.js +3 -3
  81. package/Skinnable/tests/useSkins-specs.js +3 -3
  82. package/Skinnable/util.js +1 -1
  83. package/Slider/Knob.js +5 -5
  84. package/Slider/PositionDecorator.js +25 -27
  85. package/Slider/Slider.js +5 -5
  86. package/Slider/tests/Slider-specs.js +1 -1
  87. package/Slottable/Slottable.js +3 -5
  88. package/Slottable/tests/Slottable-specs.js +1 -1
  89. package/Slottable/tests/useSlots-specs.js +1 -1
  90. package/Slottable/useSlots.js +5 -5
  91. package/Spinner/Spinner.js +5 -5
  92. package/ToggleIcon/ToggleIcon.js +5 -5
  93. package/ToggleIcon/tests/ToggleIcon-specs.js +3 -3
  94. package/Toggleable/Toggle.js +6 -7
  95. package/Toggleable/Toggleable.js +6 -6
  96. package/Toggleable/tests/Toggleable-specs.js +1 -1
  97. package/Toggleable/useToggle.js +8 -8
  98. package/Touchable/ClickAllow.js +5 -6
  99. package/Touchable/Drag.js +6 -6
  100. package/Touchable/Flick.js +7 -8
  101. package/Touchable/Hold.js +7 -8
  102. package/Touchable/Pinch.js +6 -6
  103. package/Touchable/Touch.js +6 -7
  104. package/Touchable/Touchable.js +5 -5
  105. package/Touchable/config.js +2 -2
  106. package/Touchable/tests/Touchable-specs.js +3 -3
  107. package/Touchable/tests/useTouch-specs.js +5 -5
  108. package/Touchable/useTouch.js +7 -7
  109. package/Transition/Transition.js +17 -19
  110. package/Transition/tests/Transition-specs.js +7 -7
  111. package/ViewManager/Arranger.js +3 -3
  112. package/ViewManager/TransitionGroup.js +18 -20
  113. package/ViewManager/View.js +15 -17
  114. package/ViewManager/ViewManager.js +25 -27
  115. package/ViewManager/tests/View-specs.js +1 -1
  116. package/ViewManager/tests/ViewManager-specs.js +16 -18
  117. package/VirtualList/VirtualList.d.ts +0 -158
  118. package/VirtualList/VirtualList.js +3 -17
  119. package/VirtualList/VirtualListBasic.js +42 -43
  120. package/VirtualList/tests/VirtualGridList-native-specs.js +4 -4
  121. package/VirtualList/tests/VirtualGridList-specs.js +6 -6
  122. package/VirtualList/tests/VirtualList-native-specs.js +5 -5
  123. package/VirtualList/tests/VirtualList-specs.js +7 -7
  124. package/internal/IdProvider/IdProvider.js +3 -3
  125. package/internal/IdProvider/Provider.js +5 -6
  126. package/internal/IdProvider/tests/IdProvider-specs.js +3 -3
  127. package/internal/IdProvider/tests/useId-specs.js +3 -3
  128. package/internal/IdProvider/useId.js +1 -1
  129. package/internal/Pure/Pure.js +20 -22
  130. package/internal/Pure/tests/Pure-specs.js +15 -17
  131. package/internal/localized-fonts/localized-fonts.js +4 -4
  132. package/internal/selection/selection.js +1 -1
  133. package/package.json +5 -4
  134. package/resolution/ResolutionDecorator.js +21 -23
  135. package/resolution/index.js +2 -2
  136. package/resolution/tests/ResolutionDecorator-specs.js +1 -1
  137. package/useControlledState/tests/useControlledState-specs.js +5 -5
  138. package/useControlledState/useControlledState.js +4 -4
  139. package/useScroll/ScrollAnimator.js +6 -7
  140. package/useScroll/Scrollbar.js +5 -5
  141. package/useScroll/ScrollbarTrack.js +5 -5
  142. package/useScroll/useScroll.js +9 -9
  143. package/useScroll/utilDOM.js +1 -1
  144. package/GridListImageItem/GridListImageItem.d.ts +0 -85
  145. package/GridListImageItem/GridListImageItem.js +0 -250
  146. package/GridListImageItem/GridListImageItem.module.css +0 -28
  147. package/GridListImageItem/package.json +0 -3
  148. package/IconButton/IconButton.d.ts +0 -115
  149. package/IconButton/IconButton.js +0 -253
  150. package/IconButton/IconButton.module.css +0 -11
  151. package/IconButton/package.json +0 -3
  152. package/IconButton/tests/IconButton-specs.js +0 -29
  153. package/RadioDecorator/RadioControllerDecorator.js +0 -101
  154. package/RadioDecorator/RadioDecorator.d.ts +0 -35
  155. package/RadioDecorator/RadioDecorator.js +0 -177
  156. package/RadioDecorator/package.json +0 -3
  157. package/RadioDecorator/tests/RadioDecorator-specs.js +0 -247
  158. package/Scrollable/ScrollAnimator.js +0 -130
  159. package/Scrollable/ScrollThumb.js +0 -57
  160. package/Scrollable/ScrollThumb.module.css +0 -34
  161. package/Scrollable/Scrollable.js +0 -1430
  162. package/Scrollable/Scrollable.module.css +0 -36
  163. package/Scrollable/ScrollableNative.js +0 -1429
  164. package/Scrollable/Scrollbar.js +0 -281
  165. package/Scrollable/Scrollbar.module.css +0 -24
  166. package/Scrollable/package.json +0 -3
  167. package/Scroller/UiScroller.module.css +0 -10
  168. package/Scroller/UiScrollerBase.js +0 -372
  169. package/SlotItem/SlotItem.d.ts +0 -118
  170. package/SlotItem/SlotItem.js +0 -248
  171. package/SlotItem/SlotItem.module.css +0 -12
  172. package/SlotItem/package.json +0 -3
  173. package/SlotItem/tests/SlotItem-specs.js +0 -24
  174. package/ToggleItem/ToggleItem.d.ts +0 -132
  175. package/ToggleItem/ToggleItem.js +0 -301
  176. package/ToggleItem/ToggleItem.module.css +0 -9
  177. package/ToggleItem/package.json +0 -3
  178. package/ToggleItem/tests/ToggleItem-specs.js +0 -120
  179. package/VirtualList/UiVirtualList.module.css +0 -26
  180. package/VirtualList/UiVirtualListBase.js +0 -1410
  181. package/VirtualList/VirtualListBase.js +0 -33
@@ -1,1430 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = exports.constants = exports.ScrollableBase = exports.Scrollable = void 0;
7
- var _classnames = _interopRequireDefault(require("classnames"));
8
- var _handle = _interopRequireWildcard(require("@enact/core/handle"));
9
- var _keymap = require("@enact/core/keymap");
10
- var _Registry = _interopRequireDefault(require("@enact/core/internal/Registry"));
11
- var _util = require("@enact/core/util");
12
- var _propTypes = _interopRequireDefault(require("prop-types"));
13
- var _clamp = _interopRequireDefault(require("ramda/src/clamp"));
14
- var _react = require("react");
15
- var _ForwardRef = _interopRequireDefault(require("../ForwardRef"));
16
- var _Resizable = require("../Resizable");
17
- var _resolution = _interopRequireDefault(require("../resolution"));
18
- var _Touchable = _interopRequireDefault(require("../Touchable"));
19
- var _ScrollAnimator = _interopRequireDefault(require("./ScrollAnimator"));
20
- var _Scrollbar = _interopRequireDefault(require("./Scrollbar"));
21
- var _ScrollableModule = _interopRequireDefault(require("./Scrollable.module.css"));
22
- var _jsxRuntime = require("react/jsx-runtime");
23
- var _excluded = ["className", "containerRenderer", "noScrollByDrag", "rtl", "style"],
24
- _excluded2 = ["childRenderer"];
25
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
26
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
27
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
28
- 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
- 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; }
30
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
31
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
32
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
33
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
34
- 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, _toPropertyKey(descriptor.key), descriptor); } }
35
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
36
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
37
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
38
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
39
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
40
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
41
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
42
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
43
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
44
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /**
45
- * Unstyled scrollable components and behaviors to be customized by a theme or application.
46
- *
47
- * @module ui/Scrollable
48
- * @exports constants
49
- * @exports Scrollable
50
- * @exports ScrollableBase
51
- * @private
52
- */
53
- var constants = exports.constants = {
54
- animationDuration: 1000,
55
- epsilon: 1,
56
- flickConfig: {
57
- maxDuration: null
58
- },
59
- isPageDown: (0, _keymap.is)('pageDown'),
60
- isPageUp: (0, _keymap.is)('pageUp'),
61
- nop: function nop() {},
62
- overscrollTypeNone: 0,
63
- overscrollTypeHold: 1,
64
- overscrollTypeOnce: 2,
65
- overscrollTypeDone: 9,
66
- paginationPageMultiplier: 0.66,
67
- scrollStopWaiting: 200,
68
- scrollWheelPageMultiplierForMaxPixel: 0.2 // The ratio of the maximum distance scrolled by wheel to the size of the viewport.
69
- },
70
- animationDuration = constants.animationDuration,
71
- epsilon = constants.epsilon,
72
- flickConfig = constants.flickConfig,
73
- isPageDown = constants.isPageDown,
74
- isPageUp = constants.isPageUp,
75
- nop = constants.nop,
76
- overscrollTypeDone = constants.overscrollTypeDone,
77
- overscrollTypeHold = constants.overscrollTypeHold,
78
- overscrollTypeNone = constants.overscrollTypeNone,
79
- overscrollTypeOnce = constants.overscrollTypeOnce,
80
- paginationPageMultiplier = constants.paginationPageMultiplier,
81
- scrollStopWaiting = constants.scrollStopWaiting,
82
- scrollWheelPageMultiplierForMaxPixel = constants.scrollWheelPageMultiplierForMaxPixel;
83
- var TouchableDiv = (0, _ForwardRef["default"])({
84
- prop: 'ref'
85
- }, (0, _Touchable["default"])('div'));
86
-
87
- /**
88
- * An unstyled component that passes scrollable behavior information as its render prop's arguments.
89
- *
90
- * @class ScrollableBase
91
- * @memberof ui/Scrollable
92
- * @ui
93
- * @private
94
- */
95
- var ScrollableBase = exports.ScrollableBase = /*#__PURE__*/function (_Component) {
96
- _inherits(ScrollableBase, _Component);
97
- var _super = _createSuper(ScrollableBase);
98
- function ScrollableBase(props) {
99
- var _this;
100
- _classCallCheck(this, ScrollableBase);
101
- _this = _super.call(this, props);
102
- _this.handleResizeWindow = function () {
103
- // `handleSize` in `ui/resolution.ResolutionDecorator` should be executed first.
104
- setTimeout(function () {
105
- var handleResizeWindow = _this.props.handleResizeWindow;
106
- if (handleResizeWindow) {
107
- handleResizeWindow();
108
- }
109
- _this.scrollTo({
110
- position: {
111
- x: 0,
112
- y: 0
113
- },
114
- animate: false
115
- });
116
- _this.enqueueForceUpdate();
117
- });
118
- };
119
- // constants
120
- _this.pixelPerLine = 39;
121
- _this.scrollWheelMultiplierForDeltaPixel = 1.5;
122
- // The ratio of wheel 'delta' units to pixels scrolled.
123
- // status
124
- _this.deferScrollTo = true;
125
- _this.isScrollAnimationTargetAccumulated = false;
126
- _this.isUpdatedScrollThumb = false;
127
- // overscroll
128
- _this.lastInputType = null;
129
- _this.overscrollEnabled = false;
130
- _this.overscrollStatus = {
131
- horizontal: {
132
- before: {
133
- type: overscrollTypeNone,
134
- ratio: 0
135
- },
136
- after: {
137
- type: overscrollTypeNone,
138
- ratio: 0
139
- }
140
- },
141
- vertical: {
142
- before: {
143
- type: overscrollTypeNone,
144
- ratio: 0
145
- },
146
- after: {
147
- type: overscrollTypeNone,
148
- ratio: 0
149
- }
150
- }
151
- };
152
- // bounds info
153
- _this.bounds = {
154
- clientWidth: 0,
155
- clientHeight: 0,
156
- scrollWidth: 0,
157
- scrollHeight: 0,
158
- maxTop: 0,
159
- maxLeft: 0
160
- };
161
- // wheel/drag/flick info
162
- _this.wheelDirection = 0;
163
- _this.isDragging = false;
164
- // scroll info
165
- _this.scrolling = false;
166
- _this.scrollLeft = 0;
167
- _this.scrollTop = 0;
168
- _this.scrollToInfo = null;
169
- // component info
170
- _this.childRefCurrent = null;
171
- // scroll animator
172
- _this.animator = new _ScrollAnimator["default"]();
173
- // drag/flick event handlers
174
- _this.getRtlX = function (x) {
175
- return _this.props.rtl ? -x : x;
176
- };
177
- _this.onMouseDown = (0, _handle["default"])((0, _handle.forwardWithPrevent)('onMouseDown'), _this.stop).bindAs(_assertThisInitialized(_this), 'onMouseDown');
178
- _this.onDragStart = function (ev) {
179
- if (ev.type === 'dragstart') return;
180
- (0, _handle.forward)('onDragStart', ev, _this.props);
181
- _this.stop();
182
- _this.isDragging = true;
183
- _this.dragStartX = _this.scrollLeft + _this.getRtlX(ev.x);
184
- _this.dragStartY = _this.scrollTop + ev.y;
185
- };
186
- _this.onDrag = function (ev) {
187
- if (ev.type === 'drag') return;
188
- var direction = _this.props.direction;
189
- _this.lastInputType = 'drag';
190
- (0, _handle.forward)('onDrag', ev, _this.props);
191
- _this.start({
192
- targetX: direction === 'vertical' ? 0 : _this.dragStartX - _this.getRtlX(ev.x),
193
- // 'horizontal' or 'both'
194
- targetY: direction === 'horizontal' ? 0 : _this.dragStartY - ev.y,
195
- // 'vertical' or 'both'
196
- animate: false,
197
- overscrollEffect: _this.props.overscrollEffectOn.drag
198
- });
199
- };
200
- _this.onDragEnd = function (ev) {
201
- if (ev.type === 'dragend') return;
202
- _this.isDragging = false;
203
- (0, _handle.forward)('onDragEnd', ev, _this.props);
204
- if (_this.flickTarget) {
205
- var _this$flickTarget = _this.flickTarget,
206
- targetX = _this$flickTarget.targetX,
207
- targetY = _this$flickTarget.targetY,
208
- duration = _this$flickTarget.duration;
209
- _this.lastInputType = 'drag';
210
- _this.isScrollAnimationTargetAccumulated = false;
211
- _this.start({
212
- targetX: targetX,
213
- targetY: targetY,
214
- duration: duration,
215
- overscrollEffect: _this.props.overscrollEffectOn.drag
216
- });
217
- } else {
218
- _this.stop();
219
- }
220
- if (_this.overscrollEnabled) {
221
- // not check this.props.overscrollEffectOn.drag for safety
222
- _this.clearAllOverscrollEffects();
223
- }
224
- _this.flickTarget = null;
225
- };
226
- _this.onFlick = function (ev) {
227
- var direction = _this.props.direction;
228
- _this.flickTarget = _this.animator.simulate(_this.scrollLeft, _this.scrollTop, direction !== 'vertical' ? _this.getRtlX(-ev.velocityX) : 0, direction !== 'horizontal' ? -ev.velocityY : 0);
229
- if (_this.props.onFlick) {
230
- (0, _handle.forward)('onFlick', ev, _this.props);
231
- }
232
- };
233
- _this.onWheel = function (ev) {
234
- if (_this.isDragging) {
235
- ev.preventDefault();
236
- ev.stopPropagation();
237
- } else {
238
- var _assertThisInitialize = _assertThisInitialized(_this),
239
- verticalScrollbarRef = _assertThisInitialize.verticalScrollbarRef,
240
- horizontalScrollbarRef = _assertThisInitialize.horizontalScrollbarRef,
241
- bounds = _this.getScrollBounds(),
242
- canScrollHorizontally = _this.canScrollHorizontally(bounds),
243
- canScrollVertically = _this.canScrollVertically(bounds),
244
- eventDeltaMode = ev.deltaMode,
245
- eventDelta = -ev.wheelDeltaY || ev.deltaY;
246
- var delta = 0,
247
- direction;
248
- _this.lastInputType = 'wheel';
249
- if (_this.props.noScrollByWheel) {
250
- return;
251
- }
252
- if (canScrollVertically) {
253
- delta = _this.calculateDistanceByWheel(eventDeltaMode, eventDelta, bounds.clientHeight * scrollWheelPageMultiplierForMaxPixel);
254
- } else if (canScrollHorizontally) {
255
- delta = _this.calculateDistanceByWheel(eventDeltaMode, eventDelta, bounds.clientWidth * scrollWheelPageMultiplierForMaxPixel);
256
- }
257
- direction = Math.sign(delta);
258
- if (direction !== _this.wheelDirection) {
259
- _this.isScrollAnimationTargetAccumulated = false;
260
- _this.wheelDirection = direction;
261
- }
262
- (0, _handle.forward)('onWheel', {
263
- delta: delta,
264
- horizontalScrollbarRef: horizontalScrollbarRef,
265
- verticalScrollbarRef: verticalScrollbarRef
266
- }, _this.props);
267
- if (delta !== 0) {
268
- _this.scrollToAccumulatedTarget(delta, canScrollVertically, _this.props.overscrollEffectOn.wheel);
269
- ev.preventDefault();
270
- ev.stopPropagation();
271
- }
272
- }
273
- };
274
- _this.scrollByPage = function (keyCode) {
275
- var bounds = _this.getScrollBounds(),
276
- canScrollVertically = _this.canScrollVertically(bounds),
277
- pageDistance = (isPageUp(keyCode) ? -1 : 1) * (canScrollVertically ? bounds.clientHeight : bounds.clientWidth) * paginationPageMultiplier;
278
- _this.lastInputType = 'pageKey';
279
- _this.scrollToAccumulatedTarget(pageDistance, canScrollVertically, _this.props.overscrollEffectOn.pageKey);
280
- };
281
- _this.onKeyDown = function (ev) {
282
- if (_this.props.onKeyDown) {
283
- (0, _handle.forward)('onKeyDown', ev, _this.props);
284
- } else if (isPageUp(ev.keyCode) || isPageDown(ev.keyCode)) {
285
- _this.scrollByPage(ev.keyCode);
286
- }
287
- };
288
- _this.scrollToAccumulatedTarget = function (delta, vertical, overscrollEffect) {
289
- if (!_this.isScrollAnimationTargetAccumulated) {
290
- _this.accumulatedTargetX = _this.scrollLeft;
291
- _this.accumulatedTargetY = _this.scrollTop;
292
- _this.isScrollAnimationTargetAccumulated = true;
293
- }
294
- if (vertical) {
295
- _this.accumulatedTargetY += delta;
296
- } else {
297
- _this.accumulatedTargetX += delta;
298
- }
299
- _this.start({
300
- targetX: _this.accumulatedTargetX,
301
- targetY: _this.accumulatedTargetY,
302
- overscrollEffect: overscrollEffect
303
- });
304
- };
305
- // overscroll effect
306
- _this.getEdgeFromPosition = function (position, maxPosition) {
307
- if (position <= 0) {
308
- return 'before';
309
- } else if (position >= maxPosition) {
310
- return 'after';
311
- } else {
312
- return null;
313
- }
314
- };
315
- _this.setOverscrollStatus = function (orientation, edge, type, ratio) {
316
- var status = _this.overscrollStatus[orientation][edge];
317
- status.type = type;
318
- status.ratio = ratio;
319
- };
320
- _this.getOverscrollStatus = function (orientation, edge) {
321
- return _this.overscrollStatus[orientation][edge];
322
- };
323
- _this.calculateOverscrollRatio = function (orientation, position) {
324
- var bounds = _this.getScrollBounds(),
325
- isVertical = orientation === 'vertical',
326
- baseSize = isVertical ? bounds.clientHeight : bounds.clientWidth,
327
- maxPos = bounds[isVertical ? 'maxTop' : 'maxLeft'];
328
- var overDistance = 0;
329
- if (position < 0) {
330
- overDistance = -position;
331
- } else if (position > maxPos) {
332
- overDistance = position - maxPos;
333
- } else {
334
- return 0;
335
- }
336
- return Math.min(1, 2 * overDistance / baseSize);
337
- };
338
- _this.applyOverscrollEffect = function (orientation, edge, type, ratio) {
339
- _this.props.applyOverscrollEffect(orientation, edge, type, ratio);
340
- _this.setOverscrollStatus(orientation, edge, type === overscrollTypeOnce ? overscrollTypeDone : type, ratio);
341
- };
342
- _this.checkAndApplyOverscrollEffect = function (orientation, edge, type) {
343
- var ratio = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
344
- var isVertical = orientation === 'vertical',
345
- curPos = isVertical ? _this.scrollTop : _this.scrollLeft,
346
- maxPos = _this.getScrollBounds()[isVertical ? 'maxTop' : 'maxLeft'];
347
- if (edge === 'before' && curPos <= 0 || edge === 'after' && curPos >= maxPos) {
348
- // Already on the edge
349
- _this.applyOverscrollEffect(orientation, edge, type, ratio);
350
- } else {
351
- _this.setOverscrollStatus(orientation, edge, type, ratio);
352
- }
353
- };
354
- _this.clearOverscrollEffect = function (orientation, edge) {
355
- if (_this.getOverscrollStatus(orientation, edge).type !== overscrollTypeNone) {
356
- if (_this.props.clearOverscrollEffect) {
357
- _this.props.clearOverscrollEffect(orientation, edge);
358
- } else {
359
- _this.applyOverscrollEffect(orientation, edge, overscrollTypeNone, 0);
360
- }
361
- }
362
- };
363
- _this.clearAllOverscrollEffects = function () {
364
- ['horizontal', 'vertical'].forEach(function (orientation) {
365
- ['before', 'after'].forEach(function (edge) {
366
- _this.clearOverscrollEffect(orientation, edge);
367
- });
368
- });
369
- };
370
- _this.applyOverscrollEffectOnDrag = function (orientation, edge, targetPosition, type) {
371
- if (edge) {
372
- var oppositeEdge = edge === 'before' ? 'after' : 'before',
373
- ratio = _this.calculateOverscrollRatio(orientation, targetPosition);
374
- _this.applyOverscrollEffect(orientation, edge, type, ratio);
375
- _this.clearOverscrollEffect(orientation, oppositeEdge);
376
- } else {
377
- _this.clearOverscrollEffect(orientation, 'before');
378
- _this.clearOverscrollEffect(orientation, 'after');
379
- }
380
- };
381
- _this.checkAndApplyOverscrollEffectOnScroll = function (orientation) {
382
- ['before', 'after'].forEach(function (edge) {
383
- var _this$getOverscrollSt = _this.getOverscrollStatus(orientation, edge),
384
- ratio = _this$getOverscrollSt.ratio,
385
- type = _this$getOverscrollSt.type;
386
- if (type === overscrollTypeOnce) {
387
- _this.checkAndApplyOverscrollEffect(orientation, edge, type, ratio);
388
- }
389
- });
390
- };
391
- _this.checkAndApplyOverscrollEffectOnStart = function (orientation, edge, targetPosition) {
392
- if (_this.isDragging) {
393
- _this.applyOverscrollEffectOnDrag(orientation, edge, targetPosition, overscrollTypeHold);
394
- } else if (edge) {
395
- _this.checkAndApplyOverscrollEffect(orientation, edge, overscrollTypeOnce);
396
- }
397
- };
398
- _this.getReachedEdgeInfo = function () {
399
- var bounds = _this.getScrollBounds(),
400
- reachedEdgeInfo = {
401
- bottom: false,
402
- left: false,
403
- right: false,
404
- top: false
405
- };
406
- if (_this.canScrollHorizontally(bounds)) {
407
- var rtl = _this.props.rtl,
408
- edge = _this.getEdgeFromPosition(_this.scrollLeft, bounds.maxLeft);
409
- if (edge) {
410
- // if edge is null, no need to check which edge is reached.
411
- if (edge === 'before' && !rtl || edge === 'after' && rtl) {
412
- reachedEdgeInfo.left = true;
413
- } else {
414
- reachedEdgeInfo.right = true;
415
- }
416
- }
417
- }
418
- if (_this.canScrollVertically(bounds)) {
419
- var _edge = _this.getEdgeFromPosition(_this.scrollTop, bounds.maxTop);
420
- if (_edge === 'before') {
421
- reachedEdgeInfo.top = true;
422
- } else if (_edge === 'after') {
423
- reachedEdgeInfo.bottom = true;
424
- }
425
- }
426
- return reachedEdgeInfo;
427
- };
428
- // scroll start/stop
429
- _this.doScrollStop = function () {
430
- _this.scrolling = false;
431
- _this.forwardScrollEvent('onScrollStop', _this.getReachedEdgeInfo());
432
- };
433
- _this.scrollStopJob = new _util.Job(_this.doScrollStop, scrollStopWaiting);
434
- _this.scrollAnimation = function (animationInfo) {
435
- return function (curTime) {
436
- var sourceX = animationInfo.sourceX,
437
- sourceY = animationInfo.sourceY,
438
- targetX = animationInfo.targetX,
439
- targetY = animationInfo.targetY,
440
- duration = animationInfo.duration,
441
- bounds = _this.getScrollBounds();
442
- if (curTime < duration) {
443
- var toBeContinued = false,
444
- curTargetX = sourceX,
445
- curTargetY = sourceY;
446
- if (_this.canScrollHorizontally(bounds)) {
447
- curTargetX = _this.animator.timingFunction(sourceX, targetX, duration, curTime);
448
- if (Math.abs(curTargetX - targetX) < epsilon) {
449
- curTargetX = targetX;
450
- } else {
451
- toBeContinued = true;
452
- }
453
- }
454
- if (_this.canScrollVertically(bounds)) {
455
- curTargetY = _this.animator.timingFunction(sourceY, targetY, duration, curTime);
456
- if (Math.abs(curTargetY - targetY) < epsilon) {
457
- curTargetY = targetY;
458
- } else {
459
- toBeContinued = true;
460
- }
461
- }
462
- _this.scroll(curTargetX, curTargetY, targetX, targetY);
463
- if (!toBeContinued) {
464
- _this.stop();
465
- }
466
- } else {
467
- _this.scroll(targetX, targetY, targetX, targetY);
468
- _this.stop();
469
- }
470
- };
471
- };
472
- _this.scroll = function (left, top) {
473
- var _this$childRefCurrent;
474
- if (left !== _this.scrollLeft) {
475
- _this.setScrollLeft(left);
476
- }
477
- if (top !== _this.scrollTop) {
478
- _this.setScrollTop(top);
479
- }
480
- for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
481
- rest[_key - 2] = arguments[_key];
482
- }
483
- (_this$childRefCurrent = _this.childRefCurrent).setScrollPosition.apply(_this$childRefCurrent, [_this.scrollLeft, _this.scrollTop, _this.props.rtl].concat(rest));
484
- _this.forwardScrollEvent('onScroll');
485
- };
486
- // scrollTo API
487
- _this.getPositionForScrollTo = function (opt) {
488
- var bounds = _this.getScrollBounds(),
489
- canScrollHorizontally = _this.canScrollHorizontally(bounds),
490
- canScrollVertically = _this.canScrollVertically(bounds);
491
- var itemPos,
492
- left = null,
493
- top = null;
494
- if (opt instanceof Object) {
495
- if (opt.position instanceof Object) {
496
- if (canScrollHorizontally) {
497
- // We need '!=' to check if opt.position.x is null or undefined
498
- left = opt.position.x != null ? opt.position.x : _this.scrollLeft;
499
- } else {
500
- left = 0;
501
- }
502
- if (canScrollVertically) {
503
- // We need '!=' to check if opt.position.y is null or undefined
504
- top = opt.position.y != null ? opt.position.y : _this.scrollTop;
505
- } else {
506
- top = 0;
507
- }
508
- } else if (typeof opt.align === 'string') {
509
- if (canScrollHorizontally) {
510
- if (opt.align.includes('left')) {
511
- left = 0;
512
- } else if (opt.align.includes('right')) {
513
- left = bounds.maxLeft;
514
- }
515
- }
516
- if (canScrollVertically) {
517
- if (opt.align.includes('top')) {
518
- top = 0;
519
- } else if (opt.align.includes('bottom')) {
520
- top = bounds.maxTop;
521
- }
522
- }
523
- } else {
524
- if (typeof opt.index === 'number' && typeof _this.childRefCurrent.getItemPosition === 'function') {
525
- itemPos = _this.childRefCurrent.getItemPosition(opt.index, opt.stickTo);
526
- } else if (opt.node instanceof Object) {
527
- if (opt.node.nodeType === 1 && typeof _this.childRefCurrent.getNodePosition === 'function') {
528
- itemPos = _this.childRefCurrent.getNodePosition(opt.node);
529
- }
530
- }
531
- if (itemPos) {
532
- if (canScrollHorizontally) {
533
- left = itemPos.left;
534
- }
535
- if (canScrollVertically) {
536
- top = itemPos.top;
537
- }
538
- }
539
- }
540
- }
541
- return {
542
- left: left,
543
- top: top
544
- };
545
- };
546
- _this.scrollTo = function (opt) {
547
- if (!_this.deferScrollTo) {
548
- var _this$getPositionForS = _this.getPositionForScrollTo(opt),
549
- left = _this$getPositionForS.left,
550
- top = _this$getPositionForS.top;
551
- if (_this.props.scrollTo) {
552
- _this.props.scrollTo(opt);
553
- }
554
- _this.scrollToInfo = null;
555
- _this.start({
556
- targetX: left !== null ? left : _this.scrollLeft,
557
- targetY: top !== null ? top : _this.scrollTop,
558
- animate: opt.animate
559
- });
560
- } else {
561
- _this.scrollToInfo = opt;
562
- }
563
- };
564
- _this.canScrollHorizontally = function (bounds) {
565
- var direction = _this.props.direction;
566
- return (direction === 'horizontal' || direction === 'both') && bounds.scrollWidth > bounds.clientWidth && !isNaN(bounds.scrollWidth);
567
- };
568
- _this.canScrollVertically = function (bounds) {
569
- var direction = _this.props.direction;
570
- return (direction === 'vertical' || direction === 'both') && bounds.scrollHeight > bounds.clientHeight && !isNaN(bounds.scrollHeight);
571
- };
572
- _this.startHidingThumb = function () {
573
- if (_this.state.isHorizontalScrollbarVisible && _this.horizontalScrollbarRef.current) {
574
- _this.horizontalScrollbarRef.current.startHidingThumb();
575
- }
576
- if (_this.state.isVerticalScrollbarVisible && _this.verticalScrollbarRef.current) {
577
- _this.verticalScrollbarRef.current.startHidingThumb();
578
- }
579
- };
580
- _this.updateScrollbars = function () {
581
- var _this$props = _this.props,
582
- horizontalScrollbar = _this$props.horizontalScrollbar,
583
- verticalScrollbar = _this$props.verticalScrollbar,
584
- _this$state = _this.state,
585
- isHorizontalScrollbarVisible = _this$state.isHorizontalScrollbarVisible,
586
- isVerticalScrollbarVisible = _this$state.isVerticalScrollbarVisible,
587
- bounds = _this.getScrollBounds(),
588
- canScrollHorizontally = _this.canScrollHorizontally(bounds),
589
- canScrollVertically = _this.canScrollVertically(bounds),
590
- curHorizontalScrollbarVisible = horizontalScrollbar === 'auto' ? canScrollHorizontally : horizontalScrollbar === 'visible',
591
- curVerticalScrollbarVisible = verticalScrollbar === 'auto' ? canScrollVertically : verticalScrollbar === 'visible';
592
-
593
- // determine if we should hide or show any scrollbars
594
- var isVisibilityChanged = isHorizontalScrollbarVisible !== curHorizontalScrollbarVisible || isVerticalScrollbarVisible !== curVerticalScrollbarVisible;
595
- if (isVisibilityChanged) {
596
- // one or both scrollbars have changed visibility
597
- _this.setState({
598
- isHorizontalScrollbarVisible: curHorizontalScrollbarVisible,
599
- isVerticalScrollbarVisible: curVerticalScrollbarVisible
600
- });
601
- } else {
602
- _this.deferScrollTo = false;
603
- _this.isUpdatedScrollThumb = _this.updateScrollThumbSize();
604
- }
605
- };
606
- _this.updateScrollThumbSize = function () {
607
- var _this$props2 = _this.props,
608
- horizontalScrollbar = _this$props2.horizontalScrollbar,
609
- verticalScrollbar = _this$props2.verticalScrollbar,
610
- bounds = _this.getScrollBounds(),
611
- canScrollHorizontally = _this.canScrollHorizontally(bounds),
612
- canScrollVertically = _this.canScrollVertically(bounds),
613
- curHorizontalScrollbarVisible = horizontalScrollbar === 'auto' ? canScrollHorizontally : horizontalScrollbar === 'visible',
614
- curVerticalScrollbarVisible = verticalScrollbar === 'auto' ? canScrollVertically : verticalScrollbar === 'visible';
615
- if (curHorizontalScrollbarVisible || curVerticalScrollbarVisible) {
616
- // no visibility change but need to notify whichever scrollbars are visible of the
617
- // updated bounds and scroll position
618
- var updatedBounds = _objectSpread(_objectSpread({}, bounds), {}, {
619
- scrollLeft: _this.scrollLeft,
620
- scrollTop: _this.scrollTop
621
- });
622
- if (curHorizontalScrollbarVisible && _this.horizontalScrollbarRef.current) {
623
- _this.horizontalScrollbarRef.current.update(updatedBounds);
624
- }
625
- if (curVerticalScrollbarVisible && _this.verticalScrollbarRef.current) {
626
- _this.verticalScrollbarRef.current.update(updatedBounds);
627
- }
628
- return true;
629
- }
630
- return false;
631
- };
632
- // render
633
- _this.initChildRef = function (ref) {
634
- if (ref) {
635
- _this.childRefCurrent = ref;
636
- }
637
- };
638
- _this.handleScroll = function () {
639
- var childRefCurrent = _this.childRefCurrent;
640
-
641
- // Prevent scroll by focus.
642
- // VirtualList and VirtualGridList DO NOT receive `onscroll` event.
643
- // Only Scroller could get `onscroll` event.
644
- if (!_this.animator.isAnimating() && childRefCurrent && childRefCurrent.containerRef.current && childRefCurrent.getRtlPositionX && !_this.isDragging) {
645
- // For Scroller
646
- childRefCurrent.containerRef.current.scrollTop = _this.scrollTop;
647
- childRefCurrent.containerRef.current.scrollLeft = childRefCurrent.getRtlPositionX(_this.scrollLeft);
648
- }
649
- };
650
- _this.state = {
651
- remeasure: false,
652
- isHorizontalScrollbarVisible: props.horizontalScrollbar === 'visible',
653
- isVerticalScrollbarVisible: props.verticalScrollbar === 'visible'
654
- };
655
- _this.containerRef = /*#__PURE__*/(0, _react.createRef)();
656
- _this.horizontalScrollbarRef = /*#__PURE__*/(0, _react.createRef)();
657
- _this.verticalScrollbarRef = /*#__PURE__*/(0, _react.createRef)();
658
- _this.horizontalScrollbarProps = {
659
- ref: _this.horizontalScrollbarRef,
660
- vertical: false,
661
- clientSize: props.clientSize
662
- };
663
- _this.verticalScrollbarProps = {
664
- ref: _this.verticalScrollbarRef,
665
- vertical: true,
666
- clientSize: props.clientSize
667
- };
668
- _this.overscrollEnabled = !!props.applyOverscrollEffect;
669
-
670
- // Enable the early bail out of repeated scrolling to the same position
671
- _this.animationInfo = null;
672
- _this.resizeRegistry = _Registry["default"].create(_this.handleResize.bind(_assertThisInitialized(_this)));
673
- props.cbScrollTo(_this.scrollTo);
674
- return _this;
675
- }
676
- _createClass(ScrollableBase, [{
677
- key: "componentDidMount",
678
- value: function componentDidMount() {
679
- this.resizeRegistry.parent = this.context;
680
- this.addEventListeners();
681
- this.updateScrollbars();
682
- }
683
- }, {
684
- key: "componentDidUpdate",
685
- value: function componentDidUpdate(prevProps, prevState) {
686
- var _this$state2 = this.state,
687
- isHorizontalScrollbarVisible = _this$state2.isHorizontalScrollbarVisible,
688
- isVerticalScrollbarVisible = _this$state2.isVerticalScrollbarVisible,
689
- hasDataSizeChanged = this.childRefCurrent.hasDataSizeChanged;
690
-
691
- // Need to sync calculated client size if it is different from the real size
692
- if (this.childRefCurrent.syncClientSize) {
693
- // If we actually synced, we need to reset scroll position.
694
- if (this.childRefCurrent.syncClientSize()) {
695
- this.setScrollLeft(0);
696
- this.setScrollTop(0);
697
- }
698
- }
699
- this.clampScrollPosition();
700
- this.addEventListeners();
701
- if (hasDataSizeChanged === false && (isHorizontalScrollbarVisible && !prevState.isHorizontalScrollbarVisible || isVerticalScrollbarVisible && !prevState.isVerticalScrollbarVisible)) {
702
- this.deferScrollTo = false;
703
- this.isUpdatedScrollThumb = this.updateScrollThumbSize();
704
- } else {
705
- this.updateScrollbars();
706
- }
707
- if (this.scrollToInfo !== null) {
708
- if (!this.deferScrollTo) {
709
- this.scrollTo(this.scrollToInfo);
710
- }
711
- }
712
-
713
- // publish container resize changes
714
- var horizontal = isHorizontalScrollbarVisible !== prevState.isHorizontalScrollbarVisible;
715
- var vertical = isVerticalScrollbarVisible !== prevState.isVerticalScrollbarVisible;
716
- if (horizontal || vertical) {
717
- this.resizeRegistry.notify({});
718
- }
719
- }
720
- }, {
721
- key: "componentWillUnmount",
722
- value: function componentWillUnmount() {
723
- this.resizeRegistry.parent = null;
724
- // Before call cancelAnimationFrame, you must send scrollStop Event.
725
- if (this.scrolling) {
726
- this.forwardScrollEvent('onScrollStop', this.getReachedEdgeInfo());
727
- }
728
- this.scrollStopJob.stop();
729
- if (this.animator.isAnimating()) {
730
- this.animator.stop();
731
- }
732
- this.removeEventListeners();
733
- }
734
- }, {
735
- key: "handleResize",
736
- value: function handleResize(ev) {
737
- if (ev.action === 'invalidateBounds') {
738
- this.enqueueForceUpdate();
739
- }
740
- }
741
- }, {
742
- key: "enqueueForceUpdate",
743
- value:
744
- // TODO: consider replacing forceUpdate() by storing bounds in state rather than a non-
745
- // state member.
746
- function enqueueForceUpdate() {
747
- this.childRefCurrent.calculateMetrics(this.childRefCurrent.props);
748
- this.forceUpdate();
749
- }
750
- }, {
751
- key: "clampScrollPosition",
752
- value: function clampScrollPosition() {
753
- var bounds = this.getScrollBounds();
754
- if (this.scrollTop > bounds.maxTop) {
755
- this.scrollTop = bounds.maxTop;
756
- }
757
- if (this.scrollLeft > bounds.maxLeft) {
758
- this.scrollLeft = bounds.maxLeft;
759
- }
760
- }
761
- }, {
762
- key: "calculateDistanceByWheel",
763
- value: function calculateDistanceByWheel(deltaMode, delta, maxPixel) {
764
- if (deltaMode === 0) {
765
- delta = (0, _clamp["default"])(-maxPixel, maxPixel, _resolution["default"].scale(delta * this.scrollWheelMultiplierForDeltaPixel));
766
- } else if (deltaMode === 1) {
767
- // line; firefox
768
- delta = (0, _clamp["default"])(-maxPixel, maxPixel, _resolution["default"].scale(delta * this.pixelPerLine * this.scrollWheelMultiplierForDeltaPixel));
769
- } else if (deltaMode === 2) {
770
- // page
771
- delta = delta < 0 ? -maxPixel : maxPixel;
772
- }
773
- return delta;
774
- }
775
- }, {
776
- key: "forwardScrollEvent",
777
- value:
778
- // call scroll callbacks
779
-
780
- function forwardScrollEvent(type, reachedEdgeInfo) {
781
- (0, _handle.forward)(type, {
782
- type: type,
783
- scrollLeft: this.scrollLeft,
784
- scrollTop: this.scrollTop,
785
- moreInfo: this.getMoreInfo(),
786
- reachedEdgeInfo: reachedEdgeInfo
787
- }, this.props);
788
- }
789
-
790
- // update scroll position
791
- }, {
792
- key: "setScrollLeft",
793
- value: function setScrollLeft(value) {
794
- var bounds = this.getScrollBounds();
795
- this.scrollLeft = (0, _clamp["default"])(0, bounds.maxLeft, value);
796
- if (this.overscrollEnabled && this.props.overscrollEffectOn[this.lastInputType]) {
797
- this.checkAndApplyOverscrollEffectOnScroll('horizontal');
798
- }
799
- if (this.state.isHorizontalScrollbarVisible) {
800
- this.updateThumb(this.horizontalScrollbarRef, bounds);
801
- }
802
- }
803
- }, {
804
- key: "setScrollTop",
805
- value: function setScrollTop(value) {
806
- var bounds = this.getScrollBounds();
807
- this.scrollTop = (0, _clamp["default"])(0, bounds.maxTop, value);
808
- if (this.overscrollEnabled && this.props.overscrollEffectOn[this.lastInputType]) {
809
- this.checkAndApplyOverscrollEffectOnScroll('vertical');
810
- }
811
- if (this.state.isVerticalScrollbarVisible) {
812
- this.updateThumb(this.verticalScrollbarRef, bounds);
813
- }
814
- }
815
- }, {
816
- key: "start",
817
- value: function start(_ref) {
818
- var targetX = _ref.targetX,
819
- targetY = _ref.targetY,
820
- _ref$animate = _ref.animate,
821
- animate = _ref$animate === void 0 ? true : _ref$animate,
822
- _ref$duration = _ref.duration,
823
- duration = _ref$duration === void 0 ? animationDuration : _ref$duration,
824
- _ref$overscrollEffect = _ref.overscrollEffect,
825
- overscrollEffect = _ref$overscrollEffect === void 0 ? false : _ref$overscrollEffect;
826
- var scrollLeft = this.scrollLeft,
827
- scrollTop = this.scrollTop,
828
- bounds = this.getScrollBounds(),
829
- maxLeft = bounds.maxLeft,
830
- maxTop = bounds.maxTop;
831
- var updatedAnimationInfo = {
832
- sourceX: scrollLeft,
833
- sourceY: scrollTop,
834
- targetX: targetX,
835
- targetY: targetY,
836
- duration: duration
837
- };
838
-
839
- // bail early when scrolling to the same position
840
- if (this.animator.isAnimating() && this.animationInfo && this.animationInfo.targetX === targetX && this.animationInfo.targetY === targetY) {
841
- return;
842
- }
843
- this.animationInfo = updatedAnimationInfo;
844
- this.animator.stop();
845
- if (!this.scrolling) {
846
- this.scrolling = true;
847
- this.forwardScrollEvent('onScrollStart');
848
- }
849
- this.scrollStopJob.stop();
850
- if (Math.abs(maxLeft - targetX) < epsilon) {
851
- targetX = maxLeft;
852
- }
853
- if (Math.abs(maxTop - targetY) < epsilon) {
854
- targetY = maxTop;
855
- }
856
- if (this.overscrollEnabled && overscrollEffect) {
857
- if (scrollLeft !== targetX && this.canScrollHorizontally(bounds)) {
858
- this.checkAndApplyOverscrollEffectOnStart('horizontal', this.getEdgeFromPosition(targetX, maxLeft), targetX);
859
- }
860
- if (scrollTop !== targetY && this.canScrollVertically(bounds)) {
861
- this.checkAndApplyOverscrollEffectOnStart('vertical', this.getEdgeFromPosition(targetY, maxTop), targetY);
862
- }
863
- }
864
- this.showThumb(bounds);
865
- if (animate) {
866
- this.animator.animate(this.scrollAnimation(this.animationInfo));
867
- } else {
868
- this.scroll(targetX, targetY, targetX, targetY);
869
- this.stop();
870
- }
871
- }
872
- }, {
873
- key: "stop",
874
- value: function stop() {
875
- this.animator.stop();
876
- this.lastInputType = null;
877
- this.isScrollAnimationTargetAccumulated = false;
878
- this.startHidingThumb();
879
- if (this.overscrollEnabled && !this.isDragging) {
880
- // not check this.props.overscrollEffectOn for safety
881
- this.clearAllOverscrollEffects();
882
- }
883
- if (this.props.stop) {
884
- this.props.stop();
885
- }
886
- if (this.scrolling) {
887
- this.scrollStopJob.start();
888
- }
889
- }
890
- }, {
891
- key: "showThumb",
892
- value:
893
- // scroll bar
894
-
895
- function showThumb(bounds) {
896
- if (this.state.isHorizontalScrollbarVisible && this.canScrollHorizontally(bounds) && this.horizontalScrollbarRef.current) {
897
- this.horizontalScrollbarRef.current.showThumb();
898
- }
899
- if (this.state.isVerticalScrollbarVisible && this.canScrollVertically(bounds) && this.verticalScrollbarRef.current) {
900
- this.verticalScrollbarRef.current.showThumb();
901
- }
902
- }
903
- }, {
904
- key: "updateThumb",
905
- value: function updateThumb(scrollbarRef, bounds) {
906
- scrollbarRef.current.update(_objectSpread(_objectSpread({}, bounds), {}, {
907
- scrollLeft: this.scrollLeft,
908
- scrollTop: this.scrollTop
909
- }));
910
- }
911
- }, {
912
- key: "getScrollBounds",
913
- value:
914
- // ref
915
-
916
- function getScrollBounds() {
917
- if (this.childRefCurrent && typeof this.childRefCurrent.getScrollBounds === 'function') {
918
- return this.childRefCurrent.getScrollBounds();
919
- }
920
- }
921
- }, {
922
- key: "getMoreInfo",
923
- value: function getMoreInfo() {
924
- if (this.childRefCurrent && typeof this.childRefCurrent.getMoreInfo === 'function') {
925
- return this.childRefCurrent.getMoreInfo();
926
- }
927
- }
928
-
929
- // FIXME setting event handlers directly to work on the V8 snapshot.
930
- }, {
931
- key: "addEventListeners",
932
- value: function addEventListeners() {
933
- var childRefCurrent = this.childRefCurrent,
934
- containerRef = this.containerRef;
935
- if (containerRef.current && containerRef.current.addEventListener) {
936
- containerRef.current.addEventListener('wheel', this.onWheel);
937
- containerRef.current.addEventListener('keydown', this.onKeyDown);
938
- containerRef.current.addEventListener('mousedown', this.onMouseDown);
939
- }
940
- if (this.props.addEventListeners) {
941
- this.props.addEventListeners(childRefCurrent.containerRef);
942
- }
943
- if (window) {
944
- window.addEventListener('resize', this.handleResizeWindow);
945
- }
946
- }
947
-
948
- // FIXME setting event handlers directly to work on the V8 snapshot.
949
- }, {
950
- key: "removeEventListeners",
951
- value: function removeEventListeners() {
952
- var childRefCurrent = this.childRefCurrent,
953
- containerRef = this.containerRef;
954
- if (containerRef.current && containerRef.current.removeEventListener) {
955
- containerRef.current.removeEventListener('wheel', this.onWheel);
956
- containerRef.current.removeEventListener('keydown', this.onKeyDown);
957
- containerRef.current.removeEventListener('mousedown', this.onMouseDown);
958
- }
959
- if (this.props.removeEventListeners) {
960
- this.props.removeEventListeners(childRefCurrent.containerRef);
961
- }
962
- if (window) {
963
- window.removeEventListener('resize', this.handleResizeWindow);
964
- }
965
- }
966
- }, {
967
- key: "render",
968
- value: function render() {
969
- var _this$props3 = this.props,
970
- className = _this$props3.className,
971
- containerRenderer = _this$props3.containerRenderer,
972
- noScrollByDrag = _this$props3.noScrollByDrag,
973
- rtl = _this$props3.rtl,
974
- style = _this$props3.style,
975
- rest = _objectWithoutProperties(_this$props3, _excluded),
976
- _this$state3 = this.state,
977
- isHorizontalScrollbarVisible = _this$state3.isHorizontalScrollbarVisible,
978
- isVerticalScrollbarVisible = _this$state3.isVerticalScrollbarVisible,
979
- scrollableClasses = (0, _classnames["default"])(_ScrollableModule["default"].scrollable, className),
980
- childWrapper = noScrollByDrag ? 'div' : TouchableDiv,
981
- childWrapperProps = _objectSpread({
982
- className: _ScrollableModule["default"].content
983
- }, !noScrollByDrag && {
984
- flickConfig: flickConfig,
985
- onDrag: this.onDrag,
986
- onDragEnd: this.onDragEnd,
987
- onDragStart: this.onDragStart,
988
- onFlick: this.onFlick
989
- });
990
- delete rest.addEventListeners;
991
- delete rest.applyOverscrollEffect;
992
- delete rest.cbScrollTo;
993
- delete rest.clearOverscrollEffect;
994
- delete rest.handleResizeWindow;
995
- delete rest.horizontalScrollbar;
996
- delete rest.noScrollByWheel;
997
- delete rest.onFlick;
998
- delete rest.onKeyDown;
999
- delete rest.onMouseDown;
1000
- delete rest.onScroll;
1001
- delete rest.onScrollStart;
1002
- delete rest.onScrollStop;
1003
- delete rest.onWheel;
1004
- delete rest.overscrollEffectOn;
1005
- delete rest.removeEventListeners;
1006
- delete rest.scrollTo;
1007
- delete rest.stop;
1008
- delete rest.verticalScrollbar;
1009
- this.deferScrollTo = true;
1010
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Resizable.ResizeContext.Provider, {
1011
- value: this.resizeRegistry.register,
1012
- children: containerRenderer({
1013
- childComponentProps: rest,
1014
- childWrapper: childWrapper,
1015
- childWrapperProps: childWrapperProps,
1016
- className: scrollableClasses,
1017
- componentCss: _ScrollableModule["default"],
1018
- containerRef: this.containerRef,
1019
- handleScroll: this.handleScroll,
1020
- horizontalScrollbarProps: this.horizontalScrollbarProps,
1021
- initChildRef: this.initChildRef,
1022
- isHorizontalScrollbarVisible: isHorizontalScrollbarVisible,
1023
- isVerticalScrollbarVisible: isVerticalScrollbarVisible,
1024
- rtl: rtl,
1025
- scrollTo: this.scrollTo,
1026
- style: style,
1027
- verticalScrollbarProps: this.verticalScrollbarProps
1028
- })
1029
- });
1030
- }
1031
- }]);
1032
- return ScrollableBase;
1033
- }(_react.Component);
1034
- /**
1035
- * An unstyled component that provides horizontal and vertical scrollbars and makes a render prop element scrollable.
1036
- *
1037
- * @class Scrollable
1038
- * @memberof ui/Scrollable
1039
- * @extends ui/Scrollable.ScrollableBase
1040
- * @ui
1041
- * @private
1042
- */
1043
- ScrollableBase.displayName = 'ui:ScrollableBase';
1044
- ScrollableBase.propTypes = /** @lends ui/Scrollable.Scrollable.prototype */{
1045
- /**
1046
- * Render function.
1047
- *
1048
- * @type {Function}
1049
- * @required
1050
- * @private
1051
- */
1052
- containerRenderer: _propTypes["default"].func.isRequired,
1053
- /**
1054
- * Called when adding additional event listeners in a themed component.
1055
- *
1056
- * @type {Function}
1057
- * @private
1058
- */
1059
- addEventListeners: _propTypes["default"].func,
1060
- /**
1061
- * Called to execute additional logic in a themed component to show overscroll effect.
1062
- *
1063
- * @type {Function}
1064
- * @private
1065
- */
1066
- applyOverscrollEffect: _propTypes["default"].func,
1067
- /**
1068
- * A callback function that receives a reference to the `scrollTo` feature.
1069
- *
1070
- * Once received, the `scrollTo` method can be called as an imperative interface.
1071
- *
1072
- * The `scrollTo` function accepts the following parameters:
1073
- * - {position: {x, y}} - Pixel value for x and/or y position
1074
- * - {align} - Where the scroll area should be aligned. Values are:
1075
- * `'left'`, `'right'`, `'top'`, `'bottom'`,
1076
- * `'topleft'`, `'topright'`, `'bottomleft'`, and `'bottomright'`.
1077
- * - {index} - Index of specific item. (`0` or positive integer)
1078
- * This option is available for only `VirtualList` kind.
1079
- * - {node} - Node to scroll into view
1080
- * - {animate} - When `true`, scroll occurs with animation. When `false`, no
1081
- * animation occurs.
1082
- * - {focus} - When `true`, attempts to focus item after scroll. Only valid when scrolling
1083
- * by `index` or `node`.
1084
- * > Note: Only specify one of: `position`, `align`, `index` or `node`
1085
- *
1086
- * Example:
1087
- * ```
1088
- * // If you set cbScrollTo prop like below;
1089
- * cbScrollTo: (fn) => {this.scrollTo = fn;}
1090
- * // You can simply call like below;
1091
- * this.scrollTo({align: 'top'}); // scroll to the top
1092
- * ```
1093
- *
1094
- * @type {Function}
1095
- * @public
1096
- */
1097
- cbScrollTo: _propTypes["default"].func,
1098
- /**
1099
- * Called to execute additional logic in a themed component to clear overscroll effect.
1100
- *
1101
- * @type {Function}
1102
- * @private
1103
- */
1104
- clearOverscrollEffect: _propTypes["default"].func,
1105
- /**
1106
- * Client size of the container; valid values are an object that has `clientWidth` and `clientHeight`.
1107
- *
1108
- * @type {Object}
1109
- * @property {Number} clientHeight The client height of the list.
1110
- * @property {Number} clientWidth The client width of the list.
1111
- * @public
1112
- */
1113
- clientSize: _propTypes["default"].shape({
1114
- clientHeight: _propTypes["default"].number.isRequired,
1115
- clientWidth: _propTypes["default"].number.isRequired
1116
- }),
1117
- /**
1118
- * Direction of the list or the scroller.
1119
- *
1120
- * `'both'` could be only used for {@link ui/Scroller.Scroller|Scroller}.
1121
- *
1122
- * Valid values are:
1123
- * * `'both'`,
1124
- * * `'horizontal'`, and
1125
- * * `'vertical'`.
1126
- *
1127
- * @type {String}
1128
- * @private
1129
- */
1130
- direction: _propTypes["default"].oneOf(['both', 'horizontal', 'vertical']),
1131
- /**
1132
- * Called when resizing window
1133
- *
1134
- * @type {Function}
1135
- * @private
1136
- */
1137
- handleResizeWindow: _propTypes["default"].func,
1138
- /**
1139
- * Specifies how to show horizontal scrollbar.
1140
- *
1141
- * Valid values are:
1142
- * * `'auto'`,
1143
- * * `'visible'`, and
1144
- * * `'hidden'`.
1145
- *
1146
- * @type {String}
1147
- * @default 'auto'
1148
- * @public
1149
- */
1150
- horizontalScrollbar: _propTypes["default"].oneOf(['auto', 'visible', 'hidden']),
1151
- /**
1152
- * Prevents scroll by dragging or flicking on the list or the scroller.
1153
- *
1154
- * @type {Boolean}
1155
- * @default false
1156
- * @private
1157
- */
1158
- noScrollByDrag: _propTypes["default"].bool,
1159
- /**
1160
- * Prevents scroll by wheeling on the list or the scroller.
1161
- *
1162
- * @type {Boolean}
1163
- * @default false
1164
- * @public
1165
- */
1166
- noScrollByWheel: _propTypes["default"].bool,
1167
- /**
1168
- * Called when triggering a drag event.
1169
- *
1170
- * @type {Function}
1171
- * @private
1172
- */
1173
- onDrag: _propTypes["default"].func,
1174
- /**
1175
- * Called when triggering a dragend event.
1176
- *
1177
- * @type {Function}
1178
- * @private
1179
- */
1180
- onDragEnd: _propTypes["default"].func,
1181
- /**
1182
- * Called when triggering a dragstart event.
1183
- *
1184
- * @type {Function}
1185
- * @private
1186
- */
1187
- onDragStart: _propTypes["default"].func,
1188
- /**
1189
- * Called when flicking with a mouse or a touch screen.
1190
- *
1191
- * @type {Function}
1192
- * @private
1193
- */
1194
- onFlick: _propTypes["default"].func,
1195
- /**
1196
- * Called when pressing a key.
1197
- *
1198
- * @type {Function}
1199
- * @private
1200
- */
1201
- onKeyDown: _propTypes["default"].func,
1202
- /**
1203
- * Called when triggering a mousedown event.
1204
- *
1205
- * @type {Function}
1206
- * @private
1207
- */
1208
- onMouseDown: _propTypes["default"].func,
1209
- /**
1210
- * Called when scrolling.
1211
- *
1212
- * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
1213
- * It is not recommended to set this prop since it can cause performance degradation.
1214
- * Use `onScrollStart` or `onScrollStop` instead.
1215
- *
1216
- * @type {Function}
1217
- * @param {Object} event
1218
- * @param {Number} event.scrollLeft Scroll left value.
1219
- * @param {Number} event.scrollTop Scroll top value.
1220
- * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
1221
- * @public
1222
- */
1223
- onScroll: _propTypes["default"].func,
1224
- /**
1225
- * Called when scroll starts.
1226
- *
1227
- * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
1228
- * You can get firstVisibleIndex and lastVisibleIndex from VirtualList with `moreInfo`.
1229
- *
1230
- * Example:
1231
- * ```
1232
- * onScrollStart = ({scrollLeft, scrollTop, moreInfo}) => {
1233
- * const {firstVisibleIndex, lastVisibleIndex} = moreInfo;
1234
- * // do something with firstVisibleIndex and lastVisibleIndex
1235
- * }
1236
- *
1237
- * render = () => (
1238
- * <VirtualList
1239
- * ...
1240
- * onScrollStart={this.onScrollStart}
1241
- * ...
1242
- * />
1243
- * )
1244
- * ```
1245
- *
1246
- * @type {Function}
1247
- * @param {Object} event
1248
- * @param {Number} event.scrollLeft Scroll left value.
1249
- * @param {Number} event.scrollTop Scroll top value.
1250
- * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
1251
- * @public
1252
- */
1253
- onScrollStart: _propTypes["default"].func,
1254
- /**
1255
- * Called when scroll stops.
1256
- *
1257
- * Passes `scrollLeft`, `scrollTop`, and `moreInfo`.
1258
- * You can get firstVisibleIndex and lastVisibleIndex from VirtualList with `moreInfo`.
1259
- *
1260
- * Example:
1261
- * ```
1262
- * onScrollStop = ({scrollLeft, scrollTop, moreInfo}) => {
1263
- * const {firstVisibleIndex, lastVisibleIndex} = moreInfo;
1264
- * // do something with firstVisibleIndex and lastVisibleIndex
1265
- * }
1266
- *
1267
- * render = () => (
1268
- * <VirtualList
1269
- * ...
1270
- * onScrollStop={this.onScrollStop}
1271
- * ...
1272
- * />
1273
- * )
1274
- * ```
1275
- *
1276
- * @type {Function}
1277
- * @param {Object} event
1278
- * @param {Number} event.scrollLeft Scroll left value.
1279
- * @param {Number} event.scrollTop Scroll top value.
1280
- * @param {Object} event.moreInfo The object including `firstVisibleIndex` and `lastVisibleIndex` properties.
1281
- * @public
1282
- */
1283
- onScrollStop: _propTypes["default"].func,
1284
- /**
1285
- * Called when wheeling.
1286
- *
1287
- * @type {Function}
1288
- * @private
1289
- */
1290
- onWheel: _propTypes["default"].func,
1291
- /**
1292
- * Specifies overscroll effects shows on which type of inputs.
1293
- *
1294
- * @type {Object}
1295
- * @default {drag: false, pageKey: false, wheel: false}
1296
- * @private
1297
- */
1298
- overscrollEffectOn: _propTypes["default"].shape({
1299
- drag: _propTypes["default"].bool,
1300
- pageKey: _propTypes["default"].bool,
1301
- wheel: _propTypes["default"].bool
1302
- }),
1303
- /**
1304
- * Called when removing additional event listeners in a themed component.
1305
- *
1306
- * @type {Function}
1307
- * @private
1308
- */
1309
- removeEventListeners: _propTypes["default"].func,
1310
- /**
1311
- * Indicates the content's text direction is right-to-left.
1312
- *
1313
- * @type {Boolean}
1314
- * @private
1315
- */
1316
- rtl: _propTypes["default"].bool,
1317
- /**
1318
- * Called to execute additional logic in a themed component when scrollTo is called.
1319
- *
1320
- * @type {Function}
1321
- * @private
1322
- */
1323
- scrollTo: _propTypes["default"].func,
1324
- /**
1325
- * Called to execute additional logic in a themed component when scroll stops.
1326
- *
1327
- * @type {Function}
1328
- * @private
1329
- */
1330
- stop: _propTypes["default"].func,
1331
- /**
1332
- * Specifies how to show vertical scrollbar.
1333
- *
1334
- * Valid values are:
1335
- * * `'auto'`,
1336
- * * `'visible'`, and
1337
- * * `'hidden'`.
1338
- *
1339
- * @type {String}
1340
- * @default 'auto'
1341
- * @public
1342
- */
1343
- verticalScrollbar: _propTypes["default"].oneOf(['auto', 'visible', 'hidden'])
1344
- };
1345
- ScrollableBase.defaultProps = {
1346
- cbScrollTo: nop,
1347
- horizontalScrollbar: 'auto',
1348
- noScrollByDrag: false,
1349
- noScrollByWheel: false,
1350
- onScroll: nop,
1351
- onScrollStart: nop,
1352
- onScrollStop: nop,
1353
- overscrollEffectOn: {
1354
- drag: false,
1355
- pageKey: false,
1356
- wheel: false
1357
- },
1358
- verticalScrollbar: 'auto'
1359
- };
1360
- ScrollableBase.contextType = _Resizable.ResizeContext;
1361
- var Scrollable = exports.Scrollable = /*#__PURE__*/function (_Component2) {
1362
- _inherits(Scrollable, _Component2);
1363
- var _super2 = _createSuper(Scrollable);
1364
- function Scrollable() {
1365
- _classCallCheck(this, Scrollable);
1366
- return _super2.apply(this, arguments);
1367
- }
1368
- _createClass(Scrollable, [{
1369
- key: "render",
1370
- value: function render() {
1371
- var _this$props4 = this.props,
1372
- childRenderer = _this$props4.childRenderer,
1373
- rest = _objectWithoutProperties(_this$props4, _excluded2);
1374
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(ScrollableBase, _objectSpread(_objectSpread({}, rest), {}, {
1375
- containerRenderer: function containerRenderer(_ref2) {
1376
- var childComponentProps = _ref2.childComponentProps,
1377
- ChildWrapper = _ref2.childWrapper,
1378
- childWrapperProps = _ref2.childWrapperProps,
1379
- containerRef = _ref2.containerRef,
1380
- className = _ref2.className,
1381
- componentCss = _ref2.componentCss,
1382
- handleScroll = _ref2.handleScroll,
1383
- horizontalScrollbarProps = _ref2.horizontalScrollbarProps,
1384
- initChildRef = _ref2.initChildRef,
1385
- isHorizontalScrollbarVisible = _ref2.isHorizontalScrollbarVisible,
1386
- isVerticalScrollbarVisible = _ref2.isVerticalScrollbarVisible,
1387
- rtl = _ref2.rtl,
1388
- scrollTo = _ref2.scrollTo,
1389
- style = _ref2.style,
1390
- verticalScrollbarProps = _ref2.verticalScrollbarProps;
1391
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1392
- className: className,
1393
- ref: containerRef,
1394
- style: style,
1395
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1396
- className: componentCss.container,
1397
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ChildWrapper, _objectSpread(_objectSpread({}, childWrapperProps), {}, {
1398
- children: childRenderer(_objectSpread(_objectSpread({}, childComponentProps), {}, {
1399
- cbScrollTo: scrollTo,
1400
- className: componentCss.scrollableFill,
1401
- initChildRef: initChildRef,
1402
- onScroll: handleScroll,
1403
- rtl: rtl
1404
- }))
1405
- })), isVerticalScrollbarVisible ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Scrollbar["default"], _objectSpread(_objectSpread({}, verticalScrollbarProps), {}, {
1406
- disabled: !isVerticalScrollbarVisible
1407
- })) : null]
1408
- }), isHorizontalScrollbarVisible ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Scrollbar["default"], _objectSpread(_objectSpread({}, horizontalScrollbarProps), {}, {
1409
- corner: isVerticalScrollbarVisible,
1410
- disabled: !isHorizontalScrollbarVisible
1411
- })) : null]
1412
- });
1413
- }
1414
- }));
1415
- }
1416
- }]);
1417
- return Scrollable;
1418
- }(_react.Component);
1419
- Scrollable.displayName = 'ui:Scrollable';
1420
- Scrollable.propTypes = /** @lends ui/Scrollable.Scrollable.prototype */{
1421
- /**
1422
- * Render function.
1423
- *
1424
- * @type {Function}
1425
- * @required
1426
- * @private
1427
- */
1428
- childRenderer: _propTypes["default"].func.isRequired
1429
- };
1430
- var _default = exports["default"] = Scrollable;