@enact/ui 4.9.0-beta.1 → 5.0.0-alpha.1

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