@councilbox/councilbox-ui 2.0.55 → 2.0.57

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 (54) hide show
  1. package/ScrollbarOld.js +3 -0
  2. package/dist/HOCs/usePopoverPosition.js +2 -0
  3. package/dist/build-index.js +3 -3
  4. package/dist/components/1.Introduction.stories.mdx +1 -1
  5. package/dist/components/2.Changelog.stories.mdx +12 -1
  6. package/dist/components/Button/Button.js +15 -0
  7. package/dist/components/ButtonBasic/ButtonBasic.js +15 -0
  8. package/dist/components/Checkbox/Checkbox.js +2 -2
  9. package/dist/components/DatePicker/DatePicker.js +105 -24
  10. package/dist/components/DatePicker/dateUtils.js +62 -15
  11. package/dist/components/DateRangePicker/DateRangePicker.js +134 -39
  12. package/dist/components/DateTimePicker/DateTimePicker.js +99 -39
  13. package/dist/components/DragDrop/DragDrop.js +17 -4
  14. package/dist/components/DrawerPanel/DrawerPanel.js +1 -1
  15. package/dist/components/Grid/GridItem.js +1 -1
  16. package/dist/components/Header/Header.js +104 -17
  17. package/dist/components/InputAutocomplete/InputAutocomplete.js +107 -18
  18. package/dist/components/InputAutocomplete/InputAutocomplete.stories.js +90 -1
  19. package/dist/components/InputPassword/InputPassword.js +14 -1
  20. package/dist/components/InputText/InputText.css +0 -10
  21. package/dist/components/InputText/InputText.stories.js +15 -1
  22. package/dist/components/InputTextArea/InputTextArea.js +14 -0
  23. package/dist/components/LoadingSection/LoadingSection.js +16 -4
  24. package/dist/components/MenuItem/MenuItem.js +13 -0
  25. package/dist/components/MenuLateralLeft/MenuLateralLeft.js +16 -2
  26. package/dist/components/MenuLateralRight/MenuLateralRight.js +16 -2
  27. package/dist/components/Modal/Modal.js +14 -1
  28. package/dist/components/RadioButton/Radio.js +15 -0
  29. package/dist/components/RichTextInput/DesignRichTextInput.stories.js +2 -2
  30. package/dist/components/RichTextInput/RichTextInput.css +55 -12
  31. package/dist/components/RichTextInput/RichTextInput.js +223 -17
  32. package/dist/components/Scrollbar/Scrollbar.css +60 -19
  33. package/dist/components/Scrollbar/Scrollbar.js +386 -62
  34. package/dist/components/{ScrollbarNew/DesignScrollbarNew.js → ScrollbarOld/DesignScrollbarOld.js} +5 -5
  35. package/dist/components/ScrollbarOld/ScrollbarOld.css +38 -0
  36. package/dist/components/ScrollbarOld/ScrollbarOld.js +104 -0
  37. package/dist/components/{ScrollbarNew/ScrollbarNew.stories.js → ScrollbarOld/ScrollbarOld.stories.js} +13 -13
  38. package/dist/components/SelectInput/SelectInput.js +39 -14
  39. package/dist/components/Slider/Slider.js +15 -0
  40. package/dist/components/Stars/Stars.js +13 -0
  41. package/dist/components/Stepper/Stepper.js +17 -3
  42. package/dist/components/Table/TableSortLabel.js +11 -0
  43. package/dist/components/Tabs/Tabs.js +13 -1
  44. package/dist/components/Tag/Tag.js +16 -0
  45. package/dist/components/TextInput/TextInput.js +13 -0
  46. package/dist/components/TimePicker/TimePicker.js +97 -15
  47. package/dist/components/Toast/Toast.js +15 -2
  48. package/dist/components/Toast/toastStore.js +13 -2
  49. package/dist/components/Toggle/Toggle.js +1 -1
  50. package/dist/components/Tooltip/Tooltip.js +17 -0
  51. package/package.json +2 -2
  52. package/ScrollbarNew.js +0 -3
  53. package/dist/components/ScrollbarNew/ScrollbarNew.css +0 -79
  54. package/dist/components/ScrollbarNew/ScrollbarNew.js +0 -426
@@ -6,14 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports["default"] = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
10
  require("../../styles/main.css");
10
11
  require("./Scrollbar.css");
11
- var _reactCustomScrollbars = require("react-custom-scrollbars-2");
12
- var _getScrollbarWidth = _interopRequireDefault(require("react-custom-scrollbars-2/lib/utils/getScrollbarWidth"));
13
12
  var _useDynamicStyles2 = _interopRequireDefault(require("../../HOCs/useDynamicStyles"));
14
13
  var _excluded = ["prefixClass"];
15
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
16
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) { ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } } return n; }, _extends.apply(null, arguments); }
17
15
  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; }
18
16
  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; }
19
17
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -21,6 +19,37 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
21
19
  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); }
22
20
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) { o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } } return i; }
23
21
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) { if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } } return t; }
22
+ var THUMB_MIN_SIZE = 30;
23
+ var AUTO_HIDE_TIMEOUT = 1000;
24
+ var SCROLL_STOP_DELAY = 100;
25
+ var TRACK_FADE_DURATION = 200;
26
+ var INTERACTIVE_SELECTOR = ['input', 'select', 'textarea', 'button', '[role="listbox"]', '[role="option"]', '[role="combobox"]', '[role="slider"]', '[role="tablist"]', '[role="tab"]', '[contenteditable="true"]'].join(', ');
27
+ var clampThumbSize = function clampThumbSize(trackSize, contentRatio) {
28
+ var proportionalSize = Math.ceil(contentRatio * trackSize);
29
+ return Math.min(trackSize, Math.max(proportionalSize, THUMB_MIN_SIZE));
30
+ };
31
+ var EMPTY_AXIS_GEOMETRY = {
32
+ size: 0,
33
+ offset: 0,
34
+ visible: false
35
+ };
36
+
37
+ // Same measurement react-custom-scrollbars-2 uses: on systems with overlay/0-width
38
+ // native scrollbars (macOS trackpad default, some modern Chrome setups), this is 0 -
39
+ // and the library shows no custom thumb at all there, relying on the native overlay.
40
+ // We replicate that exactly instead of always drawing our own thumb.
41
+ var cachedScrollbarWidth = null;
42
+ var getScrollbarWidth = function getScrollbarWidth() {
43
+ var useCache = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
44
+ if (useCache && cachedScrollbarWidth !== null) return cachedScrollbarWidth;
45
+ if (typeof document === 'undefined') return 0;
46
+ var div = document.createElement('div');
47
+ div.style.cssText = 'width:100px;height:100px;position:absolute;top:-9999px;overflow:scroll;-ms-overflow-style:scrollbar;';
48
+ document.body.appendChild(div);
49
+ cachedScrollbarWidth = div.offsetWidth - div.clientWidth;
50
+ document.body.removeChild(div);
51
+ return cachedScrollbarWidth;
52
+ };
24
53
  var Scrollbar = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
25
54
  var propPrefixClass = _ref.prefixClass,
26
55
  props = _objectWithoutProperties(_ref, _excluded);
@@ -28,77 +57,372 @@ var Scrollbar = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
28
57
  stylesInLine = _useDynamicStyles.stylesInLine,
29
58
  dynamicPrefixClass = _useDynamicStyles.prefixClass;
30
59
  var prefixClass = propPrefixClass || dynamicPrefixClass;
31
- var scrollbar = _react["default"].useRef(null);
60
+ var style = props.style,
61
+ autoHide = props.autoHide,
62
+ children = props.children,
63
+ showX = props.showX,
64
+ onScrollStop = props.onScrollStop,
65
+ classFixProp = props.classFix,
66
+ _props$horizontalScro = props.horizontalScroll,
67
+ horizontalScroll = _props$horizontalScro === void 0 ? false : _props$horizontalScro;
68
+
69
+ // Consumers often pass `isMobile && 'ScrollbarMobile'`, which yields false/null instead of a string
70
+ var classFix = typeof classFixProp === 'string' ? classFixProp : '';
71
+ var isMobileMode = classFix.split(' ').filter(Boolean).includes('ScrollbarMobile');
72
+ var showHorizontalThumb = horizontalScroll && showX && !isMobileMode;
73
+ var viewRef = _react["default"].useRef(null);
74
+ var trackVerticalRef = _react["default"].useRef(null);
75
+ var trackHorizontalRef = _react["default"].useRef(null);
76
+ var thumbVerticalRef = _react["default"].useRef(null);
77
+ var thumbHorizontalRef = _react["default"].useRef(null);
78
+ var dragStateRef = _react["default"].useRef(null);
79
+ var trackMouseOverRef = _react["default"].useRef(false);
80
+ var scrollStopTimerRef = _react["default"].useRef(null);
81
+ var hideTracksTimerRef = _react["default"].useRef(null);
82
+ var geometryRef = _react["default"].useRef({
83
+ vertical: EMPTY_AXIS_GEOMETRY,
84
+ horizontal: EMPTY_AXIS_GEOMETRY
85
+ });
86
+ var tracksVisibleRef = _react["default"].useRef(true);
87
+ var hasNativeScrollbarRef = _react["default"].useRef(getScrollbarWidth() > 0);
88
+ var isCustomTrackHidden = _react["default"].useCallback(function () {
89
+ return isMobileMode || !hasNativeScrollbarRef.current;
90
+ }, [isMobileMode]);
91
+
92
+ // Thumb size/offset and track opacity are mutated directly on the DOM (like the
93
+ // original library's own dom-css updates) instead of through setState, since this
94
+ // runs on every scroll/resize frame and must never trigger a React re-render.
95
+ var applyTrackStyles = _react["default"].useCallback(function () {
96
+ var _geometryRef$current = geometryRef.current,
97
+ vertical = _geometryRef$current.vertical,
98
+ horizontal = _geometryRef$current.horizontal;
99
+ var showTracks = tracksVisibleRef.current;
100
+ var display = isCustomTrackHidden() ? 'none' : '';
101
+ if (thumbVerticalRef.current) {
102
+ thumbVerticalRef.current.style.height = "".concat(vertical.size, "px");
103
+ thumbVerticalRef.current.style.transform = "translateY(".concat(vertical.offset, "px)");
104
+ }
105
+ if (trackVerticalRef.current) {
106
+ trackVerticalRef.current.style.display = display;
107
+ trackVerticalRef.current.style.opacity = vertical.visible && showTracks ? '1' : '0';
108
+ trackVerticalRef.current.style.pointerEvents = vertical.visible ? 'auto' : 'none';
109
+ }
110
+ if (thumbHorizontalRef.current) {
111
+ thumbHorizontalRef.current.style.width = "".concat(horizontal.size, "px");
112
+ thumbHorizontalRef.current.style.transform = "translateX(".concat(horizontal.offset, "px)");
113
+ }
114
+ if (trackHorizontalRef.current) {
115
+ trackHorizontalRef.current.style.display = display;
116
+ trackHorizontalRef.current.style.opacity = horizontal.visible && showTracks ? '1' : '0';
117
+ trackHorizontalRef.current.style.pointerEvents = horizontal.visible ? 'auto' : 'none';
118
+ }
119
+ }, [isCustomTrackHidden]);
120
+ var setTracksVisibility = _react["default"].useCallback(function (visible) {
121
+ tracksVisibleRef.current = visible;
122
+ applyTrackStyles();
123
+ }, [applyTrackStyles]);
124
+ var updateThumbs = _react["default"].useCallback(function () {
125
+ var view = viewRef.current;
126
+ if (!view || isCustomTrackHidden()) return;
127
+ var scrollTop = view.scrollTop,
128
+ scrollHeight = view.scrollHeight,
129
+ clientHeight = view.clientHeight,
130
+ scrollLeft = view.scrollLeft,
131
+ scrollWidth = view.scrollWidth,
132
+ clientWidth = view.clientWidth;
133
+ var trackVerticalSize = trackVerticalRef.current ? trackVerticalRef.current.clientHeight : 0;
134
+ var trackHorizontalSize = trackHorizontalRef.current ? trackHorizontalRef.current.clientWidth : 0;
135
+ var verticalNeeded = scrollHeight > clientHeight + 1;
136
+ var horizontalNeeded = showHorizontalThumb && scrollWidth > clientWidth + 1;
137
+ var verticalThumbSize = trackVerticalSize ? clampThumbSize(trackVerticalSize, clientHeight / scrollHeight) : 0;
138
+ var verticalOffset = verticalNeeded ? scrollTop / (scrollHeight - clientHeight) * (trackVerticalSize - verticalThumbSize) : 0;
139
+ var horizontalThumbSize = trackHorizontalSize ? clampThumbSize(trackHorizontalSize, clientWidth / scrollWidth) : 0;
140
+ var horizontalOffset = horizontalNeeded ? scrollLeft / (scrollWidth - clientWidth) * (trackHorizontalSize - horizontalThumbSize) : 0;
141
+ geometryRef.current = {
142
+ vertical: {
143
+ size: verticalThumbSize,
144
+ offset: verticalOffset,
145
+ visible: verticalNeeded
146
+ },
147
+ horizontal: {
148
+ size: horizontalThumbSize,
149
+ offset: horizontalOffset,
150
+ visible: horizontalNeeded
151
+ }
152
+ };
153
+ applyTrackStyles();
154
+ }, [isCustomTrackHidden, showHorizontalThumb, applyTrackStyles]);
155
+ var showTracksNow = _react["default"].useCallback(function () {
156
+ clearTimeout(hideTracksTimerRef.current);
157
+ setTracksVisibility(true);
158
+ }, [setTracksVisibility]);
159
+ var scheduleHideTracks = _react["default"].useCallback(function () {
160
+ if (!autoHide) return;
161
+ if (dragStateRef.current || trackMouseOverRef.current) return;
162
+ clearTimeout(hideTracksTimerRef.current);
163
+ hideTracksTimerRef.current = setTimeout(function () {
164
+ return setTracksVisibility(false);
165
+ }, AUTO_HIDE_TIMEOUT);
166
+ }, [autoHide, setTracksVisibility]);
167
+ var rafIdRef = _react["default"].useRef(null);
168
+
169
+ // The library coalesces scroll/resize-driven updates into a single rAF (cancelling
170
+ // any pending frame first) so a burst of scroll events only recomputes once per
171
+ // paint. Prop/content-driven updates (below, in useLayoutEffect) stay synchronous
172
+ // so there's never a stale-thumb flash right after mount or a re-render.
173
+ var scheduleUpdateThumbs = _react["default"].useCallback(function () {
174
+ if (rafIdRef.current !== null) cancelAnimationFrame(rafIdRef.current);
175
+ rafIdRef.current = requestAnimationFrame(function () {
176
+ rafIdRef.current = null;
177
+ updateThumbs();
178
+ });
179
+ }, [updateThumbs]);
180
+ var handleScroll = _react["default"].useCallback(function () {
181
+ scheduleUpdateThumbs();
182
+ if (autoHide) showTracksNow();
183
+ clearTimeout(scrollStopTimerRef.current);
184
+ scrollStopTimerRef.current = setTimeout(function () {
185
+ onScrollStop === null || onScrollStop === void 0 ? void 0 : onScrollStop();
186
+ scheduleHideTracks();
187
+ }, SCROLL_STOP_DELAY);
188
+ }, [scheduleUpdateThumbs, autoHide, showTracksNow, onScrollStop, scheduleHideTracks]);
189
+ _react["default"].useLayoutEffect(function () {
190
+ updateThumbs();
191
+ });
192
+ _react["default"].useEffect(function () {
193
+ if (!autoHide) {
194
+ setTracksVisibility(true);
195
+ } else {
196
+ scheduleHideTracks();
197
+ }
198
+ }, [autoHide, scheduleHideTracks, setTracksVisibility]);
199
+ _react["default"].useEffect(function () {
200
+ var view = viewRef.current;
201
+ if (!view || typeof ResizeObserver === 'undefined') return undefined;
202
+ var observer = new ResizeObserver(function () {
203
+ return scheduleUpdateThumbs();
204
+ });
205
+ observer.observe(view);
206
+ if (view.firstElementChild) observer.observe(view.firstElementChild);
207
+ var handleWindowResize = function handleWindowResize() {
208
+ hasNativeScrollbarRef.current = getScrollbarWidth(false) > 0;
209
+ scheduleUpdateThumbs();
210
+ applyTrackStyles();
211
+ };
212
+ window.addEventListener('resize', handleWindowResize);
213
+ return function () {
214
+ observer.disconnect();
215
+ window.removeEventListener('resize', handleWindowResize);
216
+ };
217
+ }, [scheduleUpdateThumbs, applyTrackStyles]);
218
+ _react["default"].useEffect(function () {
219
+ return function () {
220
+ clearTimeout(scrollStopTimerRef.current);
221
+ clearTimeout(hideTracksTimerRef.current);
222
+ if (rafIdRef.current !== null) cancelAnimationFrame(rafIdRef.current);
223
+ };
224
+ }, []);
225
+ var startDrag = _react["default"].useCallback(function (axis, event) {
226
+ event.preventDefault();
227
+ event.stopPropagation();
228
+ var view = viewRef.current;
229
+ if (!view) return;
230
+ dragStateRef.current = {
231
+ axis: axis,
232
+ startClient: axis === 'vertical' ? event.clientY : event.clientX,
233
+ startScroll: axis === 'vertical' ? view.scrollTop : view.scrollLeft,
234
+ trackSize: axis === 'vertical' ? trackVerticalRef.current.clientHeight : trackHorizontalRef.current.clientWidth,
235
+ thumbSize: axis === 'vertical' ? geometryRef.current.vertical.size : geometryRef.current.horizontal.size
236
+ };
237
+ document.body.style.userSelect = 'none';
238
+ showTracksNow();
239
+ var handleMouseMove = function handleMouseMove(moveEvent) {
240
+ var drag = dragStateRef.current;
241
+ if (!drag) return;
242
+ var trackRange = drag.trackSize - drag.thumbSize;
243
+ if (trackRange <= 0) return;
244
+ var client = drag.axis === 'vertical' ? moveEvent.clientY : moveEvent.clientX;
245
+ var delta = client - drag.startClient;
246
+ if (drag.axis === 'vertical') {
247
+ var scrollable = view.scrollHeight - view.clientHeight;
248
+ view.scrollTop = drag.startScroll + delta / trackRange * scrollable;
249
+ } else {
250
+ var _scrollable = view.scrollWidth - view.clientWidth;
251
+ view.scrollLeft = drag.startScroll + delta / trackRange * _scrollable;
252
+ }
253
+ };
254
+ var handleMouseUp = function handleMouseUp() {
255
+ dragStateRef.current = null;
256
+ document.body.style.userSelect = '';
257
+ document.removeEventListener('mousemove', handleMouseMove);
258
+ document.removeEventListener('mouseup', handleMouseUp);
259
+ scheduleHideTracks();
260
+ };
261
+ document.addEventListener('mousemove', handleMouseMove);
262
+ document.addEventListener('mouseup', handleMouseUp);
263
+ }, [showTracksNow, scheduleHideTracks]);
264
+ var handleTrackMouseDown = _react["default"].useCallback(function (axis, event) {
265
+ var thumbEl = axis === 'vertical' ? thumbVerticalRef.current : thumbHorizontalRef.current;
266
+ if (event.target === thumbEl) return;
267
+ var view = viewRef.current;
268
+ var trackEl = axis === 'vertical' ? trackVerticalRef.current : trackHorizontalRef.current;
269
+ if (!view || !trackEl) return;
270
+ var rect = trackEl.getBoundingClientRect();
271
+ var thumbSize = axis === 'vertical' ? geometryRef.current.vertical.size : geometryRef.current.horizontal.size;
272
+ var trackSize = axis === 'vertical' ? trackEl.clientHeight : trackEl.clientWidth;
273
+ var trackRange = trackSize - thumbSize;
274
+ if (trackRange <= 0) return;
275
+ var clickOffset = axis === 'vertical' ? event.clientY - rect.top : event.clientX - rect.left;
276
+ var ratio = Math.min(Math.max((clickOffset - thumbSize / 2) / trackRange, 0), 1);
277
+ if (axis === 'vertical') {
278
+ view.scrollTop = ratio * (view.scrollHeight - view.clientHeight);
279
+ } else {
280
+ view.scrollLeft = ratio * (view.scrollWidth - view.clientWidth);
281
+ }
282
+ }, []);
283
+ var handleTrackMouseEnter = _react["default"].useCallback(function () {
284
+ trackMouseOverRef.current = true;
285
+ showTracksNow();
286
+ }, [showTracksNow]);
287
+ var handleTrackMouseLeave = _react["default"].useCallback(function () {
288
+ trackMouseOverRef.current = false;
289
+ scheduleHideTracks();
290
+ }, [scheduleHideTracks]);
291
+ var handleKeyUpToScroll = _react["default"].useCallback(function (e) {
292
+ var target = e.target;
293
+ if (target.closest(INTERACTIVE_SELECTOR)) return;
294
+ if (!viewRef.current) return;
295
+ if (e.key === 'ArrowDown') viewRef.current.scrollTop = viewRef.current.scrollHeight;
296
+ if (e.key === 'ArrowUp') viewRef.current.scrollTop = 0;
297
+ }, []);
32
298
  _react["default"].useImperativeHandle(ref, function () {
33
299
  return {
34
300
  scrollToBottom: function scrollToBottom() {
35
- scrollbar.current.scrollToBottom();
301
+ if (viewRef.current) viewRef.current.scrollTop = viewRef.current.scrollHeight;
36
302
  },
37
303
  scrollToTop: function scrollToTop() {
38
- scrollbar.current.scrollToTop();
304
+ if (viewRef.current) viewRef.current.scrollTop = 0;
305
+ },
306
+ scrollToLeft: function scrollToLeft() {
307
+ if (viewRef.current) viewRef.current.scrollLeft = 0;
308
+ },
309
+ scrollToRight: function scrollToRight() {
310
+ if (viewRef.current) viewRef.current.scrollLeft = viewRef.current.scrollWidth;
39
311
  },
40
312
  getScrollHeight: function getScrollHeight() {
41
- return scrollbar.current.getScrollHeight();
313
+ return viewRef.current ? viewRef.current.scrollHeight : 0;
314
+ },
315
+ getScrollTop: function getScrollTop() {
316
+ return viewRef.current ? viewRef.current.scrollTop : 0;
317
+ },
318
+ getScrollLeft: function getScrollLeft() {
319
+ return viewRef.current ? viewRef.current.scrollLeft : 0;
320
+ },
321
+ getScrollWidth: function getScrollWidth() {
322
+ return viewRef.current ? viewRef.current.scrollWidth : 0;
323
+ },
324
+ getClientHeight: function getClientHeight() {
325
+ return viewRef.current ? viewRef.current.clientHeight : 0;
326
+ },
327
+ getClientWidth: function getClientWidth() {
328
+ return viewRef.current ? viewRef.current.clientWidth : 0;
42
329
  },
43
330
  getValues: function getValues() {
44
- return scrollbar.current.getValues();
331
+ var view = viewRef.current;
332
+ if (!view) {
333
+ return {
334
+ top: 0,
335
+ left: 0,
336
+ scrollTop: 0,
337
+ scrollLeft: 0,
338
+ scrollWidth: 0,
339
+ scrollHeight: 0,
340
+ clientWidth: 0,
341
+ clientHeight: 0 // eslint-disable-line max-len
342
+ };
343
+ }
344
+ var scrollTop = view.scrollTop,
345
+ scrollLeft = view.scrollLeft,
346
+ scrollWidth = view.scrollWidth,
347
+ scrollHeight = view.scrollHeight,
348
+ clientWidth = view.clientWidth,
349
+ clientHeight = view.clientHeight;
350
+ return {
351
+ left: scrollLeft / (scrollWidth - clientWidth) || 0,
352
+ top: scrollTop / (scrollHeight - clientHeight) || 0,
353
+ scrollTop: scrollTop,
354
+ scrollLeft: scrollLeft,
355
+ scrollWidth: scrollWidth,
356
+ scrollHeight: scrollHeight,
357
+ clientWidth: clientWidth,
358
+ clientHeight: clientHeight
359
+ };
45
360
  }
46
361
  };
47
362
  }, []);
48
- var handleKeyUpToScroll = _react["default"].useCallback(function (e) {
49
- var interactiveSelector = 'input, select, textarea, button, [role="listbox"], [role="option"], [role="combobox"], [role="slider"], [role="tablist"], [role="tab"], [contenteditable="true"]';
50
- var target = e.target;
51
- if (target.closest(interactiveSelector)) {
52
- return;
53
- }
54
- if (e.key === 'ArrowDown') {
55
- var _scrollbar$current;
56
- scrollbar === null || scrollbar === void 0 ? void 0 : (_scrollbar$current = scrollbar.current) === null || _scrollbar$current === void 0 ? void 0 : _scrollbar$current.scrollToBottom();
57
- }
58
- if (e.key === 'ArrowUp') {
59
- var _scrollbar$current2;
60
- scrollbar === null || scrollbar === void 0 ? void 0 : (_scrollbar$current2 = scrollbar.current) === null || _scrollbar$current2 === void 0 ? void 0 : _scrollbar$current2.scrollToTop();
61
- }
62
- }, []);
63
- var style = props.style,
64
- autoHide = props.autoHide,
65
- children = props.children,
66
- showX = props.showX,
67
- onScrollStop = props.onScrollStop,
68
- _props$classFix = props.classFix,
69
- classFix = _props$classFix === void 0 ? '' : _props$classFix,
70
- _props$horizontalScro = props.horizontalScroll,
71
- horizontalScroll = _props$horizontalScro === void 0 ? false : _props$horizontalScro;
72
- var extraClass = '';
73
- if (classFix === 'scrollflex' && !(0, _getScrollbarWidth["default"])()) {
74
- extraClass = 'macOSFlexFix';
75
- }
76
- return /*#__PURE__*/_react["default"].createElement(_reactCustomScrollbars.Scrollbars, _extends({
77
- ref: scrollbar,
78
- autoHide: autoHide,
79
- className: prefixClass("Scrollbar ".concat(classFix, " ").concat(extraClass, " ").concat(horizontalScroll ? 'scrollbarBoth' : 'scrollbarOnlyY', " scrollbarFixHeight")),
80
- onScrollStop: onScrollStop,
81
- onKeyDown: handleKeyUpToScroll,
82
- style: _objectSpread(_objectSpread({
83
- width: '100%',
84
- height: '100%'
85
- }, style), stylesInLine)
86
- }, !showX ? {
87
- renderTrackHorizontal: function renderTrackHorizontal(scrollbarProps) {
88
- return /*#__PURE__*/_react["default"].createElement("div", _extends({
89
- style: {
90
- display: 'hidden'
91
- }
92
- }, scrollbarProps));
93
- },
94
- renderThumbHorizontal: function renderThumbHorizontal(scrollbarProps) {
95
- return /*#__PURE__*/_react["default"].createElement("div", _extends({
96
- style: {
97
- display: 'hidden'
98
- }
99
- }, scrollbarProps));
100
- }
101
- } : {}), children);
363
+ return (
364
+ /*#__PURE__*/
365
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
366
+ _react["default"].createElement("div", {
367
+ className: prefixClass("Scrollbar ".concat(classFix, " ").concat(horizontalScroll ? 'scrollbarBoth' : 'scrollbarOnlyY', " scrollbarFixHeight")),
368
+ style: _objectSpread(_objectSpread({
369
+ position: 'relative',
370
+ overflow: 'hidden',
371
+ width: '100%',
372
+ height: '100%'
373
+ }, style), stylesInLine),
374
+ onKeyDown: handleKeyUpToScroll
375
+ }, /*#__PURE__*/_react["default"].createElement("div", {
376
+ ref: viewRef,
377
+ className: prefixClass('cbx-scrollbarNew-view'),
378
+ onScroll: handleScroll
379
+ }, children), /*#__PURE__*/_react["default"].createElement("div", {
380
+ ref: trackHorizontalRef,
381
+ className: prefixClass('cbx-scrollbarNew-trackHorizontal'),
382
+ style: {
383
+ transitionDuration: autoHide ? "".concat(TRACK_FADE_DURATION, "ms") : '0ms'
384
+ },
385
+ onMouseEnter: handleTrackMouseEnter,
386
+ onMouseLeave: handleTrackMouseLeave,
387
+ onMouseDown: function onMouseDown(e) {
388
+ return handleTrackMouseDown('horizontal', e);
389
+ }
390
+ }, /*#__PURE__*/_react["default"].createElement("div", {
391
+ ref: thumbHorizontalRef,
392
+ className: prefixClass('cbx-scrollbarNew-thumbHorizontal'),
393
+ onMouseDown: function onMouseDown(e) {
394
+ return startDrag('horizontal', e);
395
+ }
396
+ })), /*#__PURE__*/_react["default"].createElement("div", {
397
+ ref: trackVerticalRef,
398
+ className: prefixClass('cbx-scrollbarNew-trackVertical'),
399
+ style: {
400
+ transitionDuration: autoHide ? "".concat(TRACK_FADE_DURATION, "ms") : '0ms'
401
+ },
402
+ onMouseEnter: handleTrackMouseEnter,
403
+ onMouseLeave: handleTrackMouseLeave,
404
+ onMouseDown: function onMouseDown(e) {
405
+ return handleTrackMouseDown('vertical', e);
406
+ }
407
+ }, /*#__PURE__*/_react["default"].createElement("div", {
408
+ ref: thumbVerticalRef,
409
+ className: prefixClass('cbx-scrollbarNew-thumbVertical'),
410
+ onMouseDown: function onMouseDown(e) {
411
+ return startDrag('vertical', e);
412
+ }
413
+ })))
414
+ );
102
415
  });
416
+ Scrollbar.propTypes = {
417
+ style: _propTypes["default"].object,
418
+ sx: _propTypes["default"].object,
419
+ autoHide: _propTypes["default"].bool,
420
+ showX: _propTypes["default"].bool,
421
+ horizontalScroll: _propTypes["default"].bool,
422
+ classFix: _propTypes["default"].string,
423
+ onScrollStop: _propTypes["default"].func,
424
+ prefixClass: _propTypes["default"].func,
425
+ children: _propTypes["default"].node
426
+ };
103
427
  var _default = Scrollbar;
104
428
  exports["default"] = _default;
@@ -5,20 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
- var _ScrollbarNew = _interopRequireDefault(require("./ScrollbarNew"));
8
+ var _ScrollbarOld = _interopRequireDefault(require("./ScrollbarOld"));
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
- var DesignScrollbarNew = function DesignScrollbarNew() {
10
+ var DesignScrollbarOld = function DesignScrollbarOld() {
11
11
  return /*#__PURE__*/_react["default"].createElement("div", {
12
12
  style: {
13
13
  height: '18.75rem'
14
14
  }
15
- }, /*#__PURE__*/_react["default"].createElement(_ScrollbarNew["default"], null, /*#__PURE__*/_react["default"].createElement("div", {
15
+ }, /*#__PURE__*/_react["default"].createElement(_ScrollbarOld["default"], null, /*#__PURE__*/_react["default"].createElement("div", {
16
16
  style: {
17
17
  height: '31.25rem',
18
18
  background: 'gainsboro'
19
19
  }
20
20
  }, "Prueba")));
21
21
  };
22
- DesignScrollbarNew.displayName = "DesignScrollbarNew";
23
- var _default = DesignScrollbarNew;
22
+ DesignScrollbarOld.displayName = "DesignScrollbarOld";
23
+ var _default = DesignScrollbarOld;
24
24
  exports["default"] = _default;
@@ -0,0 +1,38 @@
1
+ .scrollbarFix {
2
+ margin-right: -17px;
3
+ scroll-behavior: smooth;
4
+ }
5
+
6
+ .Scrollbar>div:first-child {
7
+ scroll-behavior: smooth;
8
+ }
9
+
10
+ .scrollbarBoth>div:first-child {
11
+ margin-right: -17px !important;
12
+ margin-bottom: -0 !important;
13
+ overflow-x: auto !important;
14
+ }
15
+
16
+ .scrollbarOnlyY>div:first-child {
17
+ overflow-x: hidden !important;
18
+ margin-right: -17px !important;
19
+ margin-bottom: -0 !important;
20
+ }
21
+
22
+ .scrollflex>div:first-child {
23
+ display: flex;
24
+ flex-grow: 1;
25
+ min-height: 100%;
26
+ }
27
+
28
+ .scrollbarFixHeight > div > div {
29
+ /* flex-grow: 1; */
30
+ }
31
+
32
+ .scrollbarFixHeightIos > div > div {
33
+ padding-bottom: 0!important;
34
+ }
35
+
36
+ .macOSFlexFix> div > div > div {
37
+ min-height: 100%;
38
+ }
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ require("../../styles/main.css");
10
+ require("./ScrollbarOld.css");
11
+ var _reactCustomScrollbars = require("react-custom-scrollbars-2");
12
+ var _getScrollbarWidth = _interopRequireDefault(require("react-custom-scrollbars-2/lib/utils/getScrollbarWidth"));
13
+ var _useDynamicStyles2 = _interopRequireDefault(require("../../HOCs/useDynamicStyles"));
14
+ var _excluded = ["prefixClass"];
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
16
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) { ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } } return n; }, _extends.apply(null, arguments); }
17
+ 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; }
18
+ 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; }
19
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
20
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
21
+ 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); }
22
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) { o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } } return i; }
23
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) { if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } } return t; }
24
+ var ScrollbarOld = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
25
+ var propPrefixClass = _ref.prefixClass,
26
+ props = _objectWithoutProperties(_ref, _excluded);
27
+ var _useDynamicStyles = (0, _useDynamicStyles2["default"])(props.sx),
28
+ stylesInLine = _useDynamicStyles.stylesInLine,
29
+ dynamicPrefixClass = _useDynamicStyles.prefixClass;
30
+ var prefixClass = propPrefixClass || dynamicPrefixClass;
31
+ var scrollbar = _react["default"].useRef(null);
32
+ _react["default"].useImperativeHandle(ref, function () {
33
+ return {
34
+ scrollToBottom: function scrollToBottom() {
35
+ scrollbar.current.scrollToBottom();
36
+ },
37
+ scrollToTop: function scrollToTop() {
38
+ scrollbar.current.scrollToTop();
39
+ },
40
+ getScrollHeight: function getScrollHeight() {
41
+ return scrollbar.current.getScrollHeight();
42
+ },
43
+ getValues: function getValues() {
44
+ return scrollbar.current.getValues();
45
+ }
46
+ };
47
+ }, []);
48
+ var handleKeyUpToScroll = _react["default"].useCallback(function (e) {
49
+ var interactiveSelector = 'input, select, textarea, button, [role="listbox"], [role="option"], [role="combobox"], [role="slider"], [role="tablist"], [role="tab"], [contenteditable="true"]';
50
+ var target = e.target;
51
+ if (target.closest(interactiveSelector)) {
52
+ return;
53
+ }
54
+ if (e.key === 'ArrowDown') {
55
+ var _scrollbar$current;
56
+ scrollbar === null || scrollbar === void 0 ? void 0 : (_scrollbar$current = scrollbar.current) === null || _scrollbar$current === void 0 ? void 0 : _scrollbar$current.scrollToBottom();
57
+ }
58
+ if (e.key === 'ArrowUp') {
59
+ var _scrollbar$current2;
60
+ scrollbar === null || scrollbar === void 0 ? void 0 : (_scrollbar$current2 = scrollbar.current) === null || _scrollbar$current2 === void 0 ? void 0 : _scrollbar$current2.scrollToTop();
61
+ }
62
+ }, []);
63
+ var style = props.style,
64
+ autoHide = props.autoHide,
65
+ children = props.children,
66
+ showX = props.showX,
67
+ onScrollStop = props.onScrollStop,
68
+ classFixProp = props.classFix,
69
+ _props$horizontalScro = props.horizontalScroll,
70
+ horizontalScroll = _props$horizontalScro === void 0 ? false : _props$horizontalScro;
71
+ var classFix = typeof classFixProp === 'string' ? classFixProp : '';
72
+ var extraClass = '';
73
+ if (classFix === 'scrollflex' && !(0, _getScrollbarWidth["default"])()) {
74
+ extraClass = 'macOSFlexFix';
75
+ }
76
+ return /*#__PURE__*/_react["default"].createElement(_reactCustomScrollbars.Scrollbars, _extends({
77
+ ref: scrollbar,
78
+ autoHide: autoHide,
79
+ className: prefixClass("Scrollbar ".concat(classFix, " ").concat(extraClass, " ").concat(horizontalScroll ? 'scrollbarBoth' : 'scrollbarOnlyY', " scrollbarFixHeight")),
80
+ onScrollStop: onScrollStop,
81
+ onKeyDown: handleKeyUpToScroll,
82
+ style: _objectSpread(_objectSpread({
83
+ width: '100%',
84
+ height: '100%'
85
+ }, style), stylesInLine)
86
+ }, !showX ? {
87
+ renderTrackHorizontal: function renderTrackHorizontal(scrollbarProps) {
88
+ return /*#__PURE__*/_react["default"].createElement("div", _extends({
89
+ style: {
90
+ display: 'hidden'
91
+ }
92
+ }, scrollbarProps));
93
+ },
94
+ renderThumbHorizontal: function renderThumbHorizontal(scrollbarProps) {
95
+ return /*#__PURE__*/_react["default"].createElement("div", _extends({
96
+ style: {
97
+ display: 'hidden'
98
+ }
99
+ }, scrollbarProps));
100
+ }
101
+ } : {}), children);
102
+ });
103
+ var _default = ScrollbarOld;
104
+ exports["default"] = _default;