@councilbox/councilbox-ui 2.0.54 → 2.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/Accordion.js +3 -0
  2. package/Alert.js +3 -0
  3. package/Avatar.js +3 -0
  4. package/AvatarGroup.js +3 -0
  5. package/Block.js +3 -0
  6. package/Button.js +3 -0
  7. package/ButtonBasic.js +3 -0
  8. package/Checkbox.js +3 -0
  9. package/DatePicker.js +3 -0
  10. package/DateRangePicker.js +3 -0
  11. package/DateTimePicker.js +3 -0
  12. package/DragDrop.js +3 -0
  13. package/DrawerPanel.js +3 -0
  14. package/DropDown.js +3 -0
  15. package/EnhancedTable.js +3 -0
  16. package/FabButton.js +3 -0
  17. package/Grid.js +3 -0
  18. package/Header.js +3 -0
  19. package/IconButton.js +3 -0
  20. package/IconButtonSquare.js +3 -0
  21. package/IconFont.js +3 -0
  22. package/InputAutocomplete.js +3 -0
  23. package/InputPassword.js +3 -0
  24. package/InputText.js +3 -0
  25. package/InputTextArea.js +3 -0
  26. package/LoadingSection.js +3 -0
  27. package/MenuItem.js +3 -0
  28. package/MenuLateralLeft.js +3 -0
  29. package/MenuLateralRight.js +3 -0
  30. package/Modal.js +3 -0
  31. package/Radio.js +3 -0
  32. package/RichTextInput.js +3 -0
  33. package/Scrollbar.js +3 -0
  34. package/ScrollbarOld.js +3 -0
  35. package/SelectInput.js +3 -0
  36. package/Slider.js +3 -0
  37. package/Spacing.js +3 -0
  38. package/Stars.js +3 -0
  39. package/Stepper.js +3 -0
  40. package/Table.js +3 -0
  41. package/TableBody.js +3 -0
  42. package/TableCell.js +3 -0
  43. package/TableContainer.js +3 -0
  44. package/TableHead.js +3 -0
  45. package/TableRow.js +3 -0
  46. package/TableSortLabel.js +3 -0
  47. package/Tabs.js +3 -0
  48. package/Tag.js +3 -0
  49. package/TextInput.js +3 -0
  50. package/ThemeProvider.js +3 -0
  51. package/TimePicker.js +3 -0
  52. package/Timeline.js +3 -0
  53. package/ToastProvider.js +3 -0
  54. package/Toggle.js +3 -0
  55. package/Tooltip.js +3 -0
  56. package/Typography.js +3 -0
  57. package/dist/HOCs/useDynamicStyles.js +25 -24
  58. package/dist/HOCs/usePopoverPosition.js +2 -0
  59. package/dist/build-index.js +70 -0
  60. package/dist/components/1.Introduction.stories.mdx +4 -1
  61. package/dist/components/2.Changelog.stories.mdx +25 -2
  62. package/dist/components/Button/Button.js +15 -0
  63. package/dist/components/ButtonBasic/ButtonBasic.js +15 -0
  64. package/dist/components/Checkbox/Checkbox.js +2 -2
  65. package/dist/components/DatePicker/Calendar.js +243 -0
  66. package/dist/components/DatePicker/DatePicker.css +197 -0
  67. package/dist/components/DatePicker/DatePicker.js +465 -0
  68. package/dist/components/DatePicker/DatePicker.stories.js +180 -0
  69. package/dist/components/DatePicker/dateUtils.js +525 -0
  70. package/dist/components/DateRangePicker/DateRangePicker.css +41 -0
  71. package/dist/components/DateRangePicker/DateRangePicker.js +530 -0
  72. package/dist/components/DateRangePicker/DateRangePicker.stories.js +147 -0
  73. package/dist/components/DateRangePicker/RangeCalendar.js +188 -0
  74. package/dist/components/DateTimePicker/DateTimePicker.css +4 -0
  75. package/dist/components/DateTimePicker/DateTimePicker.js +541 -0
  76. package/dist/components/DateTimePicker/DateTimePicker.stories.js +144 -0
  77. package/dist/components/DateTimePicker/TimeColumns.css +46 -0
  78. package/dist/components/DateTimePicker/TimeColumns.js +175 -0
  79. package/dist/components/DragDrop/DragDrop.js +21 -5
  80. package/dist/components/DropDown/DesignDropDown.stories.js +8 -0
  81. package/dist/components/DropDown/DropDown.js +14 -4
  82. package/dist/components/Header/Header.js +134 -25
  83. package/dist/components/IconButton/IconButton.js +3 -2
  84. package/dist/components/IconButtonSquare/IconButtonSquare.js +3 -3
  85. package/dist/components/InputAutocomplete/InputAutocomplete.js +17 -2
  86. package/dist/components/InputPassword/InputPassword.js +14 -1
  87. package/dist/components/InputText/InputText.css +10 -5
  88. package/dist/components/InputText/InputText.js +4 -4
  89. package/dist/components/InputTextArea/InputTextArea.js +14 -0
  90. package/dist/components/LoadingSection/LoadingSection.js +16 -4
  91. package/dist/components/MenuItem/MenuItem.js +78 -61
  92. package/dist/components/MenuLateralLeft/MenuLateralLeft.js +16 -2
  93. package/dist/components/MenuLateralRight/MenuLateralRight.js +34 -4
  94. package/dist/components/Modal/Modal.js +16 -1
  95. package/dist/components/RadioButton/Radio.js +15 -0
  96. package/dist/components/RichTextInput/DesignRichTextInput.stories.js +119 -0
  97. package/dist/components/RichTextInput/RichTextInput.css +352 -0
  98. package/dist/components/RichTextInput/RichTextInput.js +1057 -0
  99. package/dist/components/RichTextInput/RichTextInput.stories.js +33 -0
  100. package/dist/components/Ripple/DesignRipple.js +17 -0
  101. package/dist/components/Scrollbar/Scrollbar.css +60 -19
  102. package/dist/components/Scrollbar/Scrollbar.js +384 -62
  103. package/dist/components/ScrollbarOld/DesignScrollbarOld.js +24 -0
  104. package/dist/components/ScrollbarOld/ScrollbarOld.css +38 -0
  105. package/dist/components/ScrollbarOld/ScrollbarOld.js +104 -0
  106. package/dist/components/ScrollbarOld/ScrollbarOld.stories.js +37 -0
  107. package/dist/components/SelectInput/SelectInput.js +112 -86
  108. package/dist/components/Slider/Slider.js +15 -0
  109. package/dist/components/Stars/Stars.js +13 -0
  110. package/dist/components/Stepper/Stepper.js +15 -2
  111. package/dist/components/Table/TableSortLabel.js +11 -0
  112. package/dist/components/Tabs/DesignTabs.js +1 -1
  113. package/dist/components/Tabs/Tabs.js +13 -2
  114. package/dist/components/Tag/Tag.js +16 -0
  115. package/dist/components/TextInput/TextInput.js +13 -0
  116. package/dist/components/TimePicker/TimePicker.css +3 -0
  117. package/dist/components/TimePicker/TimePicker.js +441 -0
  118. package/dist/components/TimePicker/TimePicker.stories.js +132 -0
  119. package/dist/components/Toast/DesignToast.stories.js +174 -0
  120. package/dist/components/Toast/Toast.css +154 -0
  121. package/dist/components/Toast/Toast.js +178 -0
  122. package/dist/components/Toast/Toast.stories.js +33 -0
  123. package/dist/components/Toast/ToastProvider.js +33 -0
  124. package/dist/components/Toast/ToastRoot.js +89 -0
  125. package/dist/components/Toast/toastStore.js +138 -0
  126. package/dist/components/Toast/useToast.js +42 -0
  127. package/dist/components/Toggle/Toggle.js +20 -14
  128. package/dist/components/Tooltip/Tooltip.js +24 -2
  129. package/dist/styles/styleFont.css +1 -1
  130. package/dist/styles/zIndexConsts.css +2 -0
  131. package/package.json +63 -3
  132. package/toast.js +7 -0
  133. package/useCouncilboxTheme.js +7 -0
  134. package/useToast.js +7 -0
  135. package/dist/components/Accordion/AccordionOld.css +0 -16
  136. package/dist/components/Accordion/AccordionOld.js +0 -91
  137. package/dist/components/Avatar/AvatarOld.js +0 -124
  138. package/dist/components/ButtonBasic/ButtonBasicOld.css +0 -41
  139. package/dist/components/ButtonBasic/ButtonBasicOld.js +0 -211
  140. package/dist/components/Checkbox/CheckboxOld.css +0 -31
  141. package/dist/components/Checkbox/CheckboxOld.js +0 -96
  142. package/dist/components/DrawerPanel/DrawerPanelOld.css +0 -56
  143. package/dist/components/DrawerPanel/DrawerPanelOld.js +0 -211
  144. package/dist/components/DropDown/DropDownOld.css +0 -3
  145. package/dist/components/DropDown/DropDownOld.js +0 -154
  146. package/dist/components/Grid/GridItemOld.js +0 -38
  147. package/dist/components/Grid/GridOld.css +0 -0
  148. package/dist/components/Grid/GridOld.js +0 -46
  149. package/dist/components/IconButton/IconButtonOld.css +0 -0
  150. package/dist/components/IconButton/IconButtonOld.js +0 -122
  151. package/dist/components/IconButtonSquare/IconButtonSquareOld.css +0 -43
  152. package/dist/components/IconButtonSquare/IconButtonSquareOld.js +0 -115
  153. package/dist/components/InputAutocomplete/InputAutocompleteOld.css +0 -5
  154. package/dist/components/InputAutocomplete/InputAutocompleteOld.js +0 -159
  155. package/dist/components/InputText/InputTextOld.css +0 -10
  156. package/dist/components/InputText/InputTextOld.js +0 -314
  157. package/dist/components/MenuItem/MenuItemOld.js +0 -123
  158. package/dist/components/Modal/ModalOld.css +0 -3
  159. package/dist/components/Modal/ModalOld.js +0 -213
  160. package/dist/components/RadioButton/RadioOld.css +0 -31
  161. package/dist/components/RadioButton/RadioOld.js +0 -126
  162. package/dist/components/SelectInput/SelectInputOld.css +0 -17
  163. package/dist/components/SelectInput/SelectInputOld.js +0 -296
  164. package/dist/components/Table/TableOld.css +0 -79
  165. package/dist/components/Table/TableOld.js +0 -133
  166. package/dist/components/Tabs/TabsOld.js +0 -78
  167. package/dist/components/Typography/TypographyOld.js +0 -119
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = exports.DesignRichTextInputTemplate = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _RichTextInput = _interopRequireDefault(require("./RichTextInput"));
9
+ var _DesignRichTextInput = _interopRequireDefault(require("./DesignRichTextInput.stories"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
+ var _default = {
12
+ title: 'Components/RichTextInput',
13
+ component: _RichTextInput["default"],
14
+ parameters: {
15
+ storybookCodePanel: {
16
+ disabled: false,
17
+ files: [{
18
+ fileName: 'RichTextInput.jsx',
19
+ /* eslint-disable-next-line import/no-webpack-loader-syntax, global-require,
20
+ import/extensions, import/no-unresolved */
21
+ code: require('!!raw-loader!./RichTextInput.jsx')
22
+ }]
23
+ }
24
+ }
25
+ };
26
+ exports["default"] = _default;
27
+ var TemplateRichTextInput = function TemplateRichTextInput(args) {
28
+ return /*#__PURE__*/_react["default"].createElement(_DesignRichTextInput["default"], args);
29
+ };
30
+ TemplateRichTextInput.displayName = "TemplateRichTextInput";
31
+ var DesignRichTextInputTemplate = TemplateRichTextInput.bind({});
32
+ exports.DesignRichTextInputTemplate = DesignRichTextInputTemplate;
33
+ DesignRichTextInputTemplate.parameters = {};
@@ -14,6 +14,14 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
14
14
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; }
15
15
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
16
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
17
+ var handleRippleKeyDown = function handleRippleKeyDown(addRipple) {
18
+ return function (event) {
19
+ if (event.key === 'Enter' || event.key === ' ') {
20
+ event.preventDefault();
21
+ addRipple(event);
22
+ }
23
+ };
24
+ };
17
25
  var DesignRipple = function DesignRipple(_ref) {
18
26
  var color = _ref.color;
19
27
  var _useRipple = (0, _useRipple7["default"])(),
@@ -32,6 +40,9 @@ var DesignRipple = function DesignRipple(_ref) {
32
40
  ripples3 = _useRipple6[1];
33
41
  return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
34
42
  onClick: addRipple,
43
+ onKeyDown: handleRippleKeyDown(addRipple),
44
+ role: "button",
45
+ tabIndex: 0,
35
46
  className: "cbx-ripple",
36
47
  style: {
37
48
  width: '120px',
@@ -40,6 +51,9 @@ var DesignRipple = function DesignRipple(_ref) {
40
51
  }
41
52
  }, ripples, "ripples"), /*#__PURE__*/_react["default"].createElement("div", {
42
53
  onClick: addRipple2,
54
+ onKeyDown: handleRippleKeyDown(addRipple2),
55
+ role: "button",
56
+ tabIndex: 0,
43
57
  className: "cbx-ripple",
44
58
  style: {
45
59
  width: '120px',
@@ -48,6 +62,9 @@ var DesignRipple = function DesignRipple(_ref) {
48
62
  }
49
63
  }, ripples2, "ripples2"), /*#__PURE__*/_react["default"].createElement("div", {
50
64
  onClick: addRipple3,
65
+ onKeyDown: handleRippleKeyDown(addRipple3),
66
+ role: "button",
67
+ tabIndex: 0,
51
68
  className: "cbx-ripple",
52
69
  style: {
53
70
  width: '120px',
@@ -1,38 +1,79 @@
1
- .scrollbarFix {
2
- margin-right: -17px;
1
+ .Scrollbar>.cbx-scrollbarNew-view {
2
+ position: absolute;
3
+ top: 0;
4
+ left: 0;
5
+ right: 0;
6
+ bottom: 0;
7
+ overflow-y: auto;
8
+ overflow-x: hidden;
3
9
  scroll-behavior: smooth;
10
+ -webkit-overflow-scrolling: touch;
11
+ scrollbar-width: none;
4
12
  }
5
13
 
6
- .Scrollbar>div:first-child {
7
- scroll-behavior: smooth;
14
+ .Scrollbar.ScrollbarMobile>.cbx-scrollbarNew-view {
15
+ scrollbar-width: auto;
16
+ }
17
+
18
+ .Scrollbar:not(.ScrollbarMobile)>.cbx-scrollbarNew-view::-webkit-scrollbar {
19
+ display: none;
8
20
  }
9
21
 
10
- .scrollbarBoth>div:first-child {
11
- margin-right: -17px !important;
12
- margin-bottom: -0 !important;
13
- overflow-x: auto !important;
22
+ .scrollbarBoth>.cbx-scrollbarNew-view {
23
+ overflow-x: auto;
14
24
  }
15
25
 
16
- .scrollbarOnlyY>div:first-child {
17
- overflow-x: hidden !important;
18
- margin-right: -17px !important;
19
- margin-bottom: -0 !important;
26
+ .scrollbarOnlyY>.cbx-scrollbarNew-view {
27
+ overflow-x: hidden;
20
28
  }
21
29
 
22
- .scrollflex>div:first-child {
30
+ .scrollflex>.cbx-scrollbarNew-view {
23
31
  display: flex;
24
32
  flex-grow: 1;
25
33
  min-height: 100%;
26
34
  }
27
35
 
28
- .scrollbarFixHeight > div > div {
29
- /* flex-grow: 1; */
36
+ .cbx-scrollbarNew-trackVertical,
37
+ .cbx-scrollbarNew-trackHorizontal {
38
+ position: absolute;
39
+ opacity: 1;
40
+ transition-property: opacity;
41
+ transition-timing-function: ease;
30
42
  }
31
43
 
32
- .scrollbarFixHeightIos > div > div {
33
- padding-bottom: 0!important;
44
+ .cbx-scrollbarNew-trackVertical {
45
+ top: 2px;
46
+ right: 2px;
47
+ bottom: 2px;
48
+ width: 6px;
49
+ border-radius: 3px;
34
50
  }
35
51
 
36
- .macOSFlexFix> div > div > div {
37
- min-height: 100%;
52
+ .cbx-scrollbarNew-trackHorizontal {
53
+ left: 2px;
54
+ right: 2px;
55
+ bottom: 2px;
56
+ height: 6px;
57
+ border-radius: 3px;
58
+ }
59
+
60
+ .cbx-scrollbarNew-thumbVertical,
61
+ .cbx-scrollbarNew-thumbHorizontal {
62
+ position: relative;
63
+ background-color: rgba(0, 0, 0, .2);
64
+ border-radius: inherit;
65
+ cursor: pointer;
66
+ }
67
+
68
+ .cbx-scrollbarNew-thumbVertical {
69
+ width: 100%;
70
+ }
71
+
72
+ .cbx-scrollbarNew-thumbHorizontal {
73
+ height: 100%;
74
+ }
75
+
76
+ .ScrollbarMobile .cbx-scrollbarNew-trackVertical,
77
+ .ScrollbarMobile .cbx-scrollbarNew-trackHorizontal {
78
+ display: none;
38
79
  }
@@ -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,370 @@ 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
+ _props$classFix = props.classFix,
66
+ classFix = _props$classFix === void 0 ? '' : _props$classFix,
67
+ _props$horizontalScro = props.horizontalScroll,
68
+ horizontalScroll = _props$horizontalScro === void 0 ? false : _props$horizontalScro;
69
+ var isMobileMode = classFix.split(' ').filter(Boolean).includes('ScrollbarMobile');
70
+ var showHorizontalThumb = horizontalScroll && showX && !isMobileMode;
71
+ var viewRef = _react["default"].useRef(null);
72
+ var trackVerticalRef = _react["default"].useRef(null);
73
+ var trackHorizontalRef = _react["default"].useRef(null);
74
+ var thumbVerticalRef = _react["default"].useRef(null);
75
+ var thumbHorizontalRef = _react["default"].useRef(null);
76
+ var dragStateRef = _react["default"].useRef(null);
77
+ var trackMouseOverRef = _react["default"].useRef(false);
78
+ var scrollStopTimerRef = _react["default"].useRef(null);
79
+ var hideTracksTimerRef = _react["default"].useRef(null);
80
+ var geometryRef = _react["default"].useRef({
81
+ vertical: EMPTY_AXIS_GEOMETRY,
82
+ horizontal: EMPTY_AXIS_GEOMETRY
83
+ });
84
+ var tracksVisibleRef = _react["default"].useRef(true);
85
+ var hasNativeScrollbarRef = _react["default"].useRef(getScrollbarWidth() > 0);
86
+ var isCustomTrackHidden = _react["default"].useCallback(function () {
87
+ return isMobileMode || !hasNativeScrollbarRef.current;
88
+ }, [isMobileMode]);
89
+
90
+ // Thumb size/offset and track opacity are mutated directly on the DOM (like the
91
+ // original library's own dom-css updates) instead of through setState, since this
92
+ // runs on every scroll/resize frame and must never trigger a React re-render.
93
+ var applyTrackStyles = _react["default"].useCallback(function () {
94
+ var _geometryRef$current = geometryRef.current,
95
+ vertical = _geometryRef$current.vertical,
96
+ horizontal = _geometryRef$current.horizontal;
97
+ var showTracks = tracksVisibleRef.current;
98
+ var display = isCustomTrackHidden() ? 'none' : '';
99
+ if (thumbVerticalRef.current) {
100
+ thumbVerticalRef.current.style.height = "".concat(vertical.size, "px");
101
+ thumbVerticalRef.current.style.transform = "translateY(".concat(vertical.offset, "px)");
102
+ }
103
+ if (trackVerticalRef.current) {
104
+ trackVerticalRef.current.style.display = display;
105
+ trackVerticalRef.current.style.opacity = vertical.visible && showTracks ? '1' : '0';
106
+ trackVerticalRef.current.style.pointerEvents = vertical.visible ? 'auto' : 'none';
107
+ }
108
+ if (thumbHorizontalRef.current) {
109
+ thumbHorizontalRef.current.style.width = "".concat(horizontal.size, "px");
110
+ thumbHorizontalRef.current.style.transform = "translateX(".concat(horizontal.offset, "px)");
111
+ }
112
+ if (trackHorizontalRef.current) {
113
+ trackHorizontalRef.current.style.display = display;
114
+ trackHorizontalRef.current.style.opacity = horizontal.visible && showTracks ? '1' : '0';
115
+ trackHorizontalRef.current.style.pointerEvents = horizontal.visible ? 'auto' : 'none';
116
+ }
117
+ }, [isCustomTrackHidden]);
118
+ var setTracksVisibility = _react["default"].useCallback(function (visible) {
119
+ tracksVisibleRef.current = visible;
120
+ applyTrackStyles();
121
+ }, [applyTrackStyles]);
122
+ var updateThumbs = _react["default"].useCallback(function () {
123
+ var view = viewRef.current;
124
+ if (!view || isCustomTrackHidden()) return;
125
+ var scrollTop = view.scrollTop,
126
+ scrollHeight = view.scrollHeight,
127
+ clientHeight = view.clientHeight,
128
+ scrollLeft = view.scrollLeft,
129
+ scrollWidth = view.scrollWidth,
130
+ clientWidth = view.clientWidth;
131
+ var trackVerticalSize = trackVerticalRef.current ? trackVerticalRef.current.clientHeight : 0;
132
+ var trackHorizontalSize = trackHorizontalRef.current ? trackHorizontalRef.current.clientWidth : 0;
133
+ var verticalNeeded = scrollHeight > clientHeight + 1;
134
+ var horizontalNeeded = showHorizontalThumb && scrollWidth > clientWidth + 1;
135
+ var verticalThumbSize = trackVerticalSize ? clampThumbSize(trackVerticalSize, clientHeight / scrollHeight) : 0;
136
+ var verticalOffset = verticalNeeded ? scrollTop / (scrollHeight - clientHeight) * (trackVerticalSize - verticalThumbSize) : 0;
137
+ var horizontalThumbSize = trackHorizontalSize ? clampThumbSize(trackHorizontalSize, clientWidth / scrollWidth) : 0;
138
+ var horizontalOffset = horizontalNeeded ? scrollLeft / (scrollWidth - clientWidth) * (trackHorizontalSize - horizontalThumbSize) : 0;
139
+ geometryRef.current = {
140
+ vertical: {
141
+ size: verticalThumbSize,
142
+ offset: verticalOffset,
143
+ visible: verticalNeeded
144
+ },
145
+ horizontal: {
146
+ size: horizontalThumbSize,
147
+ offset: horizontalOffset,
148
+ visible: horizontalNeeded
149
+ }
150
+ };
151
+ applyTrackStyles();
152
+ }, [isCustomTrackHidden, showHorizontalThumb, applyTrackStyles]);
153
+ var showTracksNow = _react["default"].useCallback(function () {
154
+ clearTimeout(hideTracksTimerRef.current);
155
+ setTracksVisibility(true);
156
+ }, [setTracksVisibility]);
157
+ var scheduleHideTracks = _react["default"].useCallback(function () {
158
+ if (!autoHide) return;
159
+ if (dragStateRef.current || trackMouseOverRef.current) return;
160
+ clearTimeout(hideTracksTimerRef.current);
161
+ hideTracksTimerRef.current = setTimeout(function () {
162
+ return setTracksVisibility(false);
163
+ }, AUTO_HIDE_TIMEOUT);
164
+ }, [autoHide, setTracksVisibility]);
165
+ var rafIdRef = _react["default"].useRef(null);
166
+
167
+ // The library coalesces scroll/resize-driven updates into a single rAF (cancelling
168
+ // any pending frame first) so a burst of scroll events only recomputes once per
169
+ // paint. Prop/content-driven updates (below, in useLayoutEffect) stay synchronous
170
+ // so there's never a stale-thumb flash right after mount or a re-render.
171
+ var scheduleUpdateThumbs = _react["default"].useCallback(function () {
172
+ if (rafIdRef.current !== null) cancelAnimationFrame(rafIdRef.current);
173
+ rafIdRef.current = requestAnimationFrame(function () {
174
+ rafIdRef.current = null;
175
+ updateThumbs();
176
+ });
177
+ }, [updateThumbs]);
178
+ var handleScroll = _react["default"].useCallback(function () {
179
+ scheduleUpdateThumbs();
180
+ if (autoHide) showTracksNow();
181
+ clearTimeout(scrollStopTimerRef.current);
182
+ scrollStopTimerRef.current = setTimeout(function () {
183
+ onScrollStop === null || onScrollStop === void 0 ? void 0 : onScrollStop();
184
+ scheduleHideTracks();
185
+ }, SCROLL_STOP_DELAY);
186
+ }, [scheduleUpdateThumbs, autoHide, showTracksNow, onScrollStop, scheduleHideTracks]);
187
+ _react["default"].useLayoutEffect(function () {
188
+ updateThumbs();
189
+ });
190
+ _react["default"].useEffect(function () {
191
+ if (!autoHide) {
192
+ setTracksVisibility(true);
193
+ } else {
194
+ scheduleHideTracks();
195
+ }
196
+ }, [autoHide, scheduleHideTracks, setTracksVisibility]);
197
+ _react["default"].useEffect(function () {
198
+ var view = viewRef.current;
199
+ if (!view || typeof ResizeObserver === 'undefined') return undefined;
200
+ var observer = new ResizeObserver(function () {
201
+ return scheduleUpdateThumbs();
202
+ });
203
+ observer.observe(view);
204
+ if (view.firstElementChild) observer.observe(view.firstElementChild);
205
+ var handleWindowResize = function handleWindowResize() {
206
+ hasNativeScrollbarRef.current = getScrollbarWidth(false) > 0;
207
+ scheduleUpdateThumbs();
208
+ applyTrackStyles();
209
+ };
210
+ window.addEventListener('resize', handleWindowResize);
211
+ return function () {
212
+ observer.disconnect();
213
+ window.removeEventListener('resize', handleWindowResize);
214
+ };
215
+ }, [scheduleUpdateThumbs, applyTrackStyles]);
216
+ _react["default"].useEffect(function () {
217
+ return function () {
218
+ clearTimeout(scrollStopTimerRef.current);
219
+ clearTimeout(hideTracksTimerRef.current);
220
+ if (rafIdRef.current !== null) cancelAnimationFrame(rafIdRef.current);
221
+ };
222
+ }, []);
223
+ var startDrag = _react["default"].useCallback(function (axis, event) {
224
+ event.preventDefault();
225
+ event.stopPropagation();
226
+ var view = viewRef.current;
227
+ if (!view) return;
228
+ dragStateRef.current = {
229
+ axis: axis,
230
+ startClient: axis === 'vertical' ? event.clientY : event.clientX,
231
+ startScroll: axis === 'vertical' ? view.scrollTop : view.scrollLeft,
232
+ trackSize: axis === 'vertical' ? trackVerticalRef.current.clientHeight : trackHorizontalRef.current.clientWidth,
233
+ thumbSize: axis === 'vertical' ? geometryRef.current.vertical.size : geometryRef.current.horizontal.size
234
+ };
235
+ document.body.style.userSelect = 'none';
236
+ showTracksNow();
237
+ var handleMouseMove = function handleMouseMove(moveEvent) {
238
+ var drag = dragStateRef.current;
239
+ if (!drag) return;
240
+ var trackRange = drag.trackSize - drag.thumbSize;
241
+ if (trackRange <= 0) return;
242
+ var client = drag.axis === 'vertical' ? moveEvent.clientY : moveEvent.clientX;
243
+ var delta = client - drag.startClient;
244
+ if (drag.axis === 'vertical') {
245
+ var scrollable = view.scrollHeight - view.clientHeight;
246
+ view.scrollTop = drag.startScroll + delta / trackRange * scrollable;
247
+ } else {
248
+ var _scrollable = view.scrollWidth - view.clientWidth;
249
+ view.scrollLeft = drag.startScroll + delta / trackRange * _scrollable;
250
+ }
251
+ };
252
+ var handleMouseUp = function handleMouseUp() {
253
+ dragStateRef.current = null;
254
+ document.body.style.userSelect = '';
255
+ document.removeEventListener('mousemove', handleMouseMove);
256
+ document.removeEventListener('mouseup', handleMouseUp);
257
+ scheduleHideTracks();
258
+ };
259
+ document.addEventListener('mousemove', handleMouseMove);
260
+ document.addEventListener('mouseup', handleMouseUp);
261
+ }, [showTracksNow, scheduleHideTracks]);
262
+ var handleTrackMouseDown = _react["default"].useCallback(function (axis, event) {
263
+ var thumbEl = axis === 'vertical' ? thumbVerticalRef.current : thumbHorizontalRef.current;
264
+ if (event.target === thumbEl) return;
265
+ var view = viewRef.current;
266
+ var trackEl = axis === 'vertical' ? trackVerticalRef.current : trackHorizontalRef.current;
267
+ if (!view || !trackEl) return;
268
+ var rect = trackEl.getBoundingClientRect();
269
+ var thumbSize = axis === 'vertical' ? geometryRef.current.vertical.size : geometryRef.current.horizontal.size;
270
+ var trackSize = axis === 'vertical' ? trackEl.clientHeight : trackEl.clientWidth;
271
+ var trackRange = trackSize - thumbSize;
272
+ if (trackRange <= 0) return;
273
+ var clickOffset = axis === 'vertical' ? event.clientY - rect.top : event.clientX - rect.left;
274
+ var ratio = Math.min(Math.max((clickOffset - thumbSize / 2) / trackRange, 0), 1);
275
+ if (axis === 'vertical') {
276
+ view.scrollTop = ratio * (view.scrollHeight - view.clientHeight);
277
+ } else {
278
+ view.scrollLeft = ratio * (view.scrollWidth - view.clientWidth);
279
+ }
280
+ }, []);
281
+ var handleTrackMouseEnter = _react["default"].useCallback(function () {
282
+ trackMouseOverRef.current = true;
283
+ showTracksNow();
284
+ }, [showTracksNow]);
285
+ var handleTrackMouseLeave = _react["default"].useCallback(function () {
286
+ trackMouseOverRef.current = false;
287
+ scheduleHideTracks();
288
+ }, [scheduleHideTracks]);
289
+ var handleKeyUpToScroll = _react["default"].useCallback(function (e) {
290
+ var target = e.target;
291
+ if (target.closest(INTERACTIVE_SELECTOR)) return;
292
+ if (!viewRef.current) return;
293
+ if (e.key === 'ArrowDown') viewRef.current.scrollTop = viewRef.current.scrollHeight;
294
+ if (e.key === 'ArrowUp') viewRef.current.scrollTop = 0;
295
+ }, []);
32
296
  _react["default"].useImperativeHandle(ref, function () {
33
297
  return {
34
298
  scrollToBottom: function scrollToBottom() {
35
- scrollbar.current.scrollToBottom();
299
+ if (viewRef.current) viewRef.current.scrollTop = viewRef.current.scrollHeight;
36
300
  },
37
301
  scrollToTop: function scrollToTop() {
38
- scrollbar.current.scrollToTop();
302
+ if (viewRef.current) viewRef.current.scrollTop = 0;
303
+ },
304
+ scrollToLeft: function scrollToLeft() {
305
+ if (viewRef.current) viewRef.current.scrollLeft = 0;
306
+ },
307
+ scrollToRight: function scrollToRight() {
308
+ if (viewRef.current) viewRef.current.scrollLeft = viewRef.current.scrollWidth;
39
309
  },
40
310
  getScrollHeight: function getScrollHeight() {
41
- return scrollbar.current.getScrollHeight();
311
+ return viewRef.current ? viewRef.current.scrollHeight : 0;
312
+ },
313
+ getScrollTop: function getScrollTop() {
314
+ return viewRef.current ? viewRef.current.scrollTop : 0;
315
+ },
316
+ getScrollLeft: function getScrollLeft() {
317
+ return viewRef.current ? viewRef.current.scrollLeft : 0;
318
+ },
319
+ getScrollWidth: function getScrollWidth() {
320
+ return viewRef.current ? viewRef.current.scrollWidth : 0;
321
+ },
322
+ getClientHeight: function getClientHeight() {
323
+ return viewRef.current ? viewRef.current.clientHeight : 0;
324
+ },
325
+ getClientWidth: function getClientWidth() {
326
+ return viewRef.current ? viewRef.current.clientWidth : 0;
42
327
  },
43
328
  getValues: function getValues() {
44
- return scrollbar.current.getValues();
329
+ var view = viewRef.current;
330
+ if (!view) {
331
+ return {
332
+ top: 0,
333
+ left: 0,
334
+ scrollTop: 0,
335
+ scrollLeft: 0,
336
+ scrollWidth: 0,
337
+ scrollHeight: 0,
338
+ clientWidth: 0,
339
+ clientHeight: 0 // eslint-disable-line max-len
340
+ };
341
+ }
342
+ var scrollTop = view.scrollTop,
343
+ scrollLeft = view.scrollLeft,
344
+ scrollWidth = view.scrollWidth,
345
+ scrollHeight = view.scrollHeight,
346
+ clientWidth = view.clientWidth,
347
+ clientHeight = view.clientHeight;
348
+ return {
349
+ left: scrollLeft / (scrollWidth - clientWidth) || 0,
350
+ top: scrollTop / (scrollHeight - clientHeight) || 0,
351
+ scrollTop: scrollTop,
352
+ scrollLeft: scrollLeft,
353
+ scrollWidth: scrollWidth,
354
+ scrollHeight: scrollHeight,
355
+ clientWidth: clientWidth,
356
+ clientHeight: clientHeight
357
+ };
45
358
  }
46
359
  };
47
360
  }, []);
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);
361
+ return (
362
+ /*#__PURE__*/
363
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
364
+ _react["default"].createElement("div", {
365
+ className: prefixClass("Scrollbar ".concat(classFix, " ").concat(horizontalScroll ? 'scrollbarBoth' : 'scrollbarOnlyY', " scrollbarFixHeight")),
366
+ style: _objectSpread(_objectSpread({
367
+ position: 'relative',
368
+ overflow: 'hidden',
369
+ width: '100%',
370
+ height: '100%'
371
+ }, style), stylesInLine),
372
+ onKeyDown: handleKeyUpToScroll
373
+ }, /*#__PURE__*/_react["default"].createElement("div", {
374
+ ref: viewRef,
375
+ className: prefixClass('cbx-scrollbarNew-view'),
376
+ onScroll: handleScroll
377
+ }, children), /*#__PURE__*/_react["default"].createElement("div", {
378
+ ref: trackHorizontalRef,
379
+ className: prefixClass('cbx-scrollbarNew-trackHorizontal'),
380
+ style: {
381
+ transitionDuration: autoHide ? "".concat(TRACK_FADE_DURATION, "ms") : '0ms'
382
+ },
383
+ onMouseEnter: handleTrackMouseEnter,
384
+ onMouseLeave: handleTrackMouseLeave,
385
+ onMouseDown: function onMouseDown(e) {
386
+ return handleTrackMouseDown('horizontal', e);
387
+ }
388
+ }, /*#__PURE__*/_react["default"].createElement("div", {
389
+ ref: thumbHorizontalRef,
390
+ className: prefixClass('cbx-scrollbarNew-thumbHorizontal'),
391
+ onMouseDown: function onMouseDown(e) {
392
+ return startDrag('horizontal', e);
393
+ }
394
+ })), /*#__PURE__*/_react["default"].createElement("div", {
395
+ ref: trackVerticalRef,
396
+ className: prefixClass('cbx-scrollbarNew-trackVertical'),
397
+ style: {
398
+ transitionDuration: autoHide ? "".concat(TRACK_FADE_DURATION, "ms") : '0ms'
399
+ },
400
+ onMouseEnter: handleTrackMouseEnter,
401
+ onMouseLeave: handleTrackMouseLeave,
402
+ onMouseDown: function onMouseDown(e) {
403
+ return handleTrackMouseDown('vertical', e);
404
+ }
405
+ }, /*#__PURE__*/_react["default"].createElement("div", {
406
+ ref: thumbVerticalRef,
407
+ className: prefixClass('cbx-scrollbarNew-thumbVertical'),
408
+ onMouseDown: function onMouseDown(e) {
409
+ return startDrag('vertical', e);
410
+ }
411
+ })))
412
+ );
102
413
  });
414
+ Scrollbar.propTypes = {
415
+ style: _propTypes["default"].object,
416
+ sx: _propTypes["default"].object,
417
+ autoHide: _propTypes["default"].bool,
418
+ showX: _propTypes["default"].bool,
419
+ horizontalScroll: _propTypes["default"].bool,
420
+ classFix: _propTypes["default"].string,
421
+ onScrollStop: _propTypes["default"].func,
422
+ prefixClass: _propTypes["default"].func,
423
+ children: _propTypes["default"].node
424
+ };
103
425
  var _default = Scrollbar;
104
426
  exports["default"] = _default;