@rio-cloud/rio-uikit 1.2.2 → 1.4.0

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 (207) hide show
  1. package/.DS_Store +0 -0
  2. package/ChartLabel.d.ts +2 -0
  3. package/ChartLabel.js +2 -0
  4. package/ComposedChart.d.ts +2 -0
  5. package/ComposedChart.js +2 -0
  6. package/DateRangePicker.d.ts +6 -7
  7. package/DateRangePicker.js +7 -3
  8. package/GroupedItemList.d.ts +2 -0
  9. package/GroupedItemList.js +2 -0
  10. package/LicensePlate.d.ts +2 -0
  11. package/LicensePlate.js +2 -0
  12. package/README.md +3 -3
  13. package/ReferenceLine.d.ts +2 -0
  14. package/ReferenceLine.js +2 -0
  15. package/components/actionBarItem/ActionBarItem.js +5 -1
  16. package/components/actionBarItem/ActionBarItemIcon.d.ts +6 -8
  17. package/components/actionBarItem/ActionBarItemIcon.js +4 -4
  18. package/components/actionBarItem/ActionBarOverlay.d.ts +3 -2
  19. package/components/actionBarItem/ActionBarOverlay.js +7 -7
  20. package/components/applicationLayout/ApplicationLayout.js +1 -0
  21. package/components/applicationLayout/ApplicationLayoutHeader.js +0 -4
  22. package/components/assetTree/TreeOptions.js +8 -4
  23. package/components/assetTree/treeUtils.js +1 -1
  24. package/components/calendarStripe/CalendarStripe.d.ts +8 -0
  25. package/components/calendarStripe/CalendarStripe.js +7 -4
  26. package/components/charts/Area.d.ts +5 -0
  27. package/components/charts/Area.js +1 -9
  28. package/components/charts/AreaChart.d.ts +2 -0
  29. package/components/charts/AreaChart.js +9 -6
  30. package/components/charts/BarChart.js +4 -4
  31. package/components/charts/ChartLabel.d.ts +5 -0
  32. package/components/charts/ChartLabel.js +2 -0
  33. package/components/charts/ComposedChart.d.ts +34 -0
  34. package/components/charts/ComposedChart.js +30 -0
  35. package/components/charts/Legend.d.ts +8 -10
  36. package/components/charts/Legend.js +3 -12
  37. package/components/charts/Line.d.ts +5 -0
  38. package/components/charts/Line.js +1 -9
  39. package/components/charts/LineChart.d.ts +2 -0
  40. package/components/charts/LineChart.js +8 -5
  41. package/components/charts/PieChart.js +5 -5
  42. package/components/charts/RadialBarChart.js +5 -5
  43. package/components/charts/ReferenceLine.d.ts +7 -0
  44. package/components/charts/ReferenceLine.js +2 -0
  45. package/components/dataTabs/DataTab.js +2 -1
  46. package/components/dialog/Dialog.d.ts +12 -4
  47. package/components/dialog/SimpleDialog.d.ts +2 -2
  48. package/components/dialog/SplitDialog.d.ts +6 -0
  49. package/components/expander/ExpanderList.js +2 -1
  50. package/components/groupedItemList/GroupedItemList.d.ts +79 -0
  51. package/components/groupedItemList/GroupedItemList.js +77 -0
  52. package/components/licensePlate/LicensePlate.d.ts +19 -0
  53. package/components/licensePlate/LicensePlate.js +14 -0
  54. package/components/listMenu/ListMenu.js +1 -1
  55. package/components/onboarding/OnboardingTip.d.ts +2 -2
  56. package/components/onboarding/OnboardingTip.js +2 -0
  57. package/components/overlay/OverlayTrigger.d.ts +92 -3
  58. package/components/overlay/OverlayTrigger.js +140 -8
  59. package/components/popover/Popover.d.ts +27 -9
  60. package/components/popover/Popover.js +18 -5
  61. package/components/selects/BaseSelectDropdown.d.ts +1 -0
  62. package/components/selects/BaseSelectDropdown.js +16 -14
  63. package/components/selects/Multiselect.d.ts +5 -0
  64. package/components/selects/Multiselect.js +2 -2
  65. package/components/selects/Select.d.ts +5 -0
  66. package/components/selects/Select.js +2 -2
  67. package/components/slider/RangeSlider.d.ts +7 -0
  68. package/components/slider/RangeSlider.js +10 -4
  69. package/components/slider/Slider.d.ts +7 -0
  70. package/components/slider/Slider.js +5 -3
  71. package/components/states/CustomState.js +4 -5
  72. package/components/switch/Switch.d.ts +7 -0
  73. package/components/switch/Switch.js +4 -3
  74. package/components/tooltip/SimpleTooltip.d.ts +2 -2
  75. package/components/tooltip/Tooltip.d.ts +2 -2
  76. package/components/tooltip/Tooltip.js +6 -2
  77. package/hooks/useClickOutside.d.ts +1 -0
  78. package/hooks/useClickOutside.js +9 -3
  79. package/hooks/useElapsedTime.d.ts +26 -0
  80. package/hooks/useElapsedTime.js +36 -0
  81. package/hooks/useEvent.d.ts +1 -1
  82. package/hooks/useKey.d.ts +7 -4
  83. package/hooks/useKey.js +36 -8
  84. package/hooks/useTimeout.d.ts +5 -0
  85. package/hooks/useTimeout.js +39 -1
  86. package/hooks/useUncontrollable.d.ts +13 -0
  87. package/hooks/useUncontrollable.js +41 -0
  88. package/lib/es/ChartLabel.d.ts +2 -0
  89. package/lib/es/ChartLabel.js +7 -0
  90. package/lib/es/ComposedChart.d.ts +2 -0
  91. package/lib/es/ComposedChart.js +7 -0
  92. package/lib/es/DateRangePicker.d.ts +6 -7
  93. package/lib/es/DateRangePicker.js +5 -1
  94. package/lib/es/GroupedItemList.d.ts +2 -0
  95. package/lib/es/GroupedItemList.js +7 -0
  96. package/lib/es/LicensePlate.d.ts +2 -0
  97. package/lib/es/LicensePlate.js +7 -0
  98. package/lib/es/ReferenceLine.d.ts +2 -0
  99. package/lib/es/ReferenceLine.js +7 -0
  100. package/lib/es/components/actionBarItem/ActionBarItem.js +5 -1
  101. package/lib/es/components/actionBarItem/ActionBarItemIcon.d.ts +6 -8
  102. package/lib/es/components/actionBarItem/ActionBarItemIcon.js +4 -4
  103. package/lib/es/components/actionBarItem/ActionBarOverlay.d.ts +3 -2
  104. package/lib/es/components/actionBarItem/ActionBarOverlay.js +7 -7
  105. package/lib/es/components/applicationLayout/ApplicationLayout.js +1 -0
  106. package/lib/es/components/applicationLayout/ApplicationLayoutHeader.js +0 -4
  107. package/lib/es/components/assetTree/TreeOptions.js +8 -4
  108. package/lib/es/components/assetTree/treeUtils.js +1 -1
  109. package/lib/es/components/calendarStripe/CalendarStripe.d.ts +8 -0
  110. package/lib/es/components/calendarStripe/CalendarStripe.js +7 -4
  111. package/lib/es/components/charts/Area.d.ts +5 -0
  112. package/lib/es/components/charts/Area.js +1 -9
  113. package/lib/es/components/charts/AreaChart.d.ts +2 -0
  114. package/lib/es/components/charts/AreaChart.js +7 -4
  115. package/lib/es/components/charts/BarChart.js +3 -3
  116. package/lib/es/components/charts/ChartLabel.d.ts +5 -0
  117. package/lib/es/components/charts/ChartLabel.js +4 -0
  118. package/lib/es/components/charts/ComposedChart.d.ts +34 -0
  119. package/lib/es/components/charts/ComposedChart.js +32 -0
  120. package/lib/es/components/charts/Legend.d.ts +8 -10
  121. package/lib/es/components/charts/Legend.js +5 -12
  122. package/lib/es/components/charts/Line.d.ts +5 -0
  123. package/lib/es/components/charts/Line.js +1 -9
  124. package/lib/es/components/charts/LineChart.d.ts +2 -0
  125. package/lib/es/components/charts/LineChart.js +7 -4
  126. package/lib/es/components/charts/PieChart.js +4 -4
  127. package/lib/es/components/charts/RadialBarChart.js +4 -4
  128. package/lib/es/components/charts/ReferenceLine.d.ts +7 -0
  129. package/lib/es/components/charts/ReferenceLine.js +4 -0
  130. package/lib/es/components/dataTabs/DataTab.js +2 -1
  131. package/lib/es/components/dialog/Dialog.d.ts +12 -4
  132. package/lib/es/components/dialog/SimpleDialog.d.ts +2 -2
  133. package/lib/es/components/dialog/SplitDialog.d.ts +6 -0
  134. package/lib/es/components/expander/ExpanderList.js +2 -1
  135. package/lib/es/components/groupedItemList/GroupedItemList.d.ts +79 -0
  136. package/lib/es/components/groupedItemList/GroupedItemList.js +80 -0
  137. package/lib/es/components/licensePlate/LicensePlate.d.ts +19 -0
  138. package/lib/es/components/licensePlate/LicensePlate.js +16 -0
  139. package/lib/es/components/listMenu/ListMenu.js +1 -1
  140. package/lib/es/components/onboarding/OnboardingTip.d.ts +2 -2
  141. package/lib/es/components/onboarding/OnboardingTip.js +2 -0
  142. package/lib/es/components/overlay/OverlayTrigger.d.ts +92 -3
  143. package/lib/es/components/overlay/OverlayTrigger.js +139 -7
  144. package/lib/es/components/popover/Popover.d.ts +27 -9
  145. package/lib/es/components/popover/Popover.js +20 -6
  146. package/lib/es/components/selects/BaseSelectDropdown.d.ts +1 -0
  147. package/lib/es/components/selects/BaseSelectDropdown.js +16 -14
  148. package/lib/es/components/selects/Multiselect.d.ts +5 -0
  149. package/lib/es/components/selects/Multiselect.js +2 -2
  150. package/lib/es/components/selects/Select.d.ts +5 -0
  151. package/lib/es/components/selects/Select.js +2 -2
  152. package/lib/es/components/slider/RangeSlider.d.ts +7 -0
  153. package/lib/es/components/slider/RangeSlider.js +10 -4
  154. package/lib/es/components/slider/Slider.d.ts +7 -0
  155. package/lib/es/components/slider/Slider.js +5 -3
  156. package/lib/es/components/states/CustomState.js +4 -5
  157. package/lib/es/components/switch/Switch.d.ts +7 -0
  158. package/lib/es/components/switch/Switch.js +4 -3
  159. package/lib/es/components/tooltip/SimpleTooltip.d.ts +2 -2
  160. package/lib/es/components/tooltip/Tooltip.d.ts +2 -2
  161. package/lib/es/components/tooltip/Tooltip.js +5 -1
  162. package/lib/es/hooks/useClickOutside.d.ts +1 -0
  163. package/lib/es/hooks/useClickOutside.js +11 -3
  164. package/lib/es/hooks/useElapsedTime.d.ts +26 -0
  165. package/lib/es/hooks/useElapsedTime.js +38 -0
  166. package/lib/es/hooks/useEvent.d.ts +1 -1
  167. package/lib/es/hooks/useKey.d.ts +7 -4
  168. package/lib/es/hooks/useKey.js +35 -7
  169. package/lib/es/hooks/useTimeout.d.ts +5 -0
  170. package/lib/es/hooks/useTimeout.js +40 -0
  171. package/lib/es/hooks/useUncontrollable.d.ts +13 -0
  172. package/lib/es/hooks/useUncontrollable.js +46 -0
  173. package/lib/es/styles/variables/colors/colors.json +3 -3
  174. package/lib/es/useElapsedTime.d.ts +2 -0
  175. package/lib/es/useElapsedTime.js +7 -0
  176. package/lib/es/utils/colorScheme.js +10 -8
  177. package/lib/es/utils/currentColors.d.ts +3 -0
  178. package/lib/es/utils/currentColors.js +14 -0
  179. package/lib/es/utils/hasUtilityClass.d.ts +30 -0
  180. package/lib/es/utils/hasUtilityClass.js +71 -0
  181. package/lib/es/utils/init/initCSS.js +12 -0
  182. package/lib/es/utils/mergeRefs.d.ts +1 -1
  183. package/lib/es/values/Trigger.d.ts +1 -2
  184. package/lib/es/version.json +1 -1
  185. package/package.json +26 -20
  186. package/styles/variables/colors/colors.json +3 -3
  187. package/useElapsedTime.d.ts +2 -0
  188. package/useElapsedTime.js +2 -0
  189. package/utils/colorScheme.js +10 -8
  190. package/utils/currentColors.d.ts +3 -0
  191. package/utils/currentColors.js +10 -0
  192. package/utils/hasUtilityClass.d.ts +30 -0
  193. package/utils/hasUtilityClass.js +40 -0
  194. package/utils/init/initCSS.js +12 -0
  195. package/utils/mergeRefs.d.ts +1 -1
  196. package/values/Trigger.d.ts +1 -2
  197. package/version.json +1 -1
  198. package/components/.DS_Store +0 -0
  199. package/components/feedback/Feedback.d.ts +0 -2
  200. package/components/feedback/Feedback.js +0 -5
  201. package/components/map/.DS_Store +0 -0
  202. package/components/map/components/.DS_Store +0 -0
  203. package/lib/.DS_Store +0 -0
  204. package/lib/es/.DS_Store +0 -0
  205. package/lib/es/components/.DS_Store +0 -0
  206. package/lib/es/components/feedback/Feedback.d.ts +0 -2
  207. package/lib/es/components/feedback/Feedback.js +0 -7
@@ -14,11 +14,12 @@ const useEffectOnce_1 = tslib_1.__importDefault(require("../../hooks/useEffectOn
14
14
  const useKey_1 = tslib_1.__importDefault(require("../../useKey"));
15
15
  const DropdownHeader_1 = tslib_1.__importDefault(require("./DropdownHeader"));
16
16
  const NoItemMessage_1 = tslib_1.__importDefault(require("./NoItemMessage"));
17
+ const Spinner_1 = tslib_1.__importDefault(require("../spinner/Spinner"));
17
18
  const DATA_ATTRIBUTE_ID = 'data-item-id';
18
19
  const DEFAULT_FOCUSED_ITEM_INDEX = 0;
19
20
  const HIGHLIGHT_CLASS = 'focus';
20
21
  const BaseSelectDropdown = (props) => {
21
- const { isOpen = false, updateDOMValues = noop_1.default, onOpen = noop_1.default, onSelect = noop_1.default, onClose = noop_1.default, options = [], autoDropDirection = true, dropup = false, pullRight = false, useActiveClass = false, focusedItemIndex: externalFocusedItemIndex, keyboardUsed: externalKeyboardUsed, noItemMessage, dropdownClassName, } = props;
22
+ const { isOpen = false, isLoading = false, updateDOMValues = noop_1.default, onOpen = noop_1.default, onSelect = noop_1.default, onClose = noop_1.default, options = [], autoDropDirection = true, dropup = false, pullRight = false, useActiveClass = false, focusedItemIndex: externalFocusedItemIndex, keyboardUsed: externalKeyboardUsed, noItemMessage, dropdownClassName, } = props;
22
23
  const [focusedItemIndex, setFocusedItemIndex] = (0, react_1.useState)(externalFocusedItemIndex || DEFAULT_FOCUSED_ITEM_INDEX);
23
24
  const [keyboardUsed, setKeyboardUsed] = (0, react_1.useState)(externalKeyboardUsed);
24
25
  const dropdownMenuRef = (0, react_1.useRef)(null);
@@ -154,19 +155,20 @@ const BaseSelectDropdown = (props) => {
154
155
  if ((0, isEmpty_1.default)(options)) {
155
156
  return (0, jsx_runtime_1.jsx)(NoItemMessage_1.default, { noItemMessage: noItemMessage, className: dropdownMenuClasses });
156
157
  }
157
- return ((0, jsx_runtime_1.jsx)("ul", Object.assign({ className: dropdownMenuClasses, ref: dropdownMenuRef, role: 'menu' }, { children: options.map((option, index) => {
158
- if (option.header) {
159
- return (0, jsx_runtime_1.jsx)(DropdownHeader_1.default, { icon: option.icon, label: option.label }, option.id);
160
- }
161
- // Show focused style only when keyboard is in use
162
- const anchorClassNames = (0, classnames_1.default)('display-flex align-items-center', keyboardUsed && focusedItemIndex === index ? HIGHLIGHT_CLASS : '', option.disabled && 'pointer-events-none');
163
- const wrapperClassNames = (0, classnames_1.default)(option.disabled && 'disabled', useActiveClass && option.selected && 'active');
164
- return ((0, jsx_runtime_1.jsx)("li", Object.assign({ className: wrapperClassNames, role: 'listitem' }, { children: (0, jsx_runtime_1.jsxs)("a", Object.assign({ role: 'menuitem', className: anchorClassNames, "data-item-id": option.id, "data-item-index": index,
165
- // Note, we need to assign the click callback only when it's not disabled
166
- // otherwise the functions is still triggered
167
- // biome-ignore lint/a11y/useValidAnchor: due to old structure and backwards compatibility
168
- onClick: option.disabled ? undefined : handleOptionChange }, { children: [(0, jsx_runtime_1.jsxs)("span", { children: [option.icon && (0, jsx_runtime_1.jsx)("span", Object.assign({ className: 'margin-right-5' }, { children: option.icon })), option.label] }), (0, jsx_runtime_1.jsx)("input", { type: 'hidden', value: option.id })] })) }), option.id));
169
- }) })));
158
+ return ((0, jsx_runtime_1.jsxs)("ul", Object.assign({ className: dropdownMenuClasses, ref: dropdownMenuRef, role: 'menu' }, { children: [isLoading && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'display-flex justify-content-center padding-10' }, { children: (0, jsx_runtime_1.jsx)(Spinner_1.default, {}) }))), !isLoading &&
159
+ options.map((option, index) => {
160
+ if (option.header) {
161
+ return (0, jsx_runtime_1.jsx)(DropdownHeader_1.default, { icon: option.icon, label: option.label }, option.id);
162
+ }
163
+ // Show focused style only when keyboard is in use
164
+ const anchorClassNames = (0, classnames_1.default)('display-flex align-items-center', keyboardUsed && focusedItemIndex === index ? HIGHLIGHT_CLASS : '', option.disabled && 'pointer-events-none');
165
+ const wrapperClassNames = (0, classnames_1.default)(option.disabled && 'disabled', useActiveClass && option.selected && 'active');
166
+ return ((0, jsx_runtime_1.jsx)("li", Object.assign({ className: wrapperClassNames, role: 'listitem' }, { children: (0, jsx_runtime_1.jsxs)("a", Object.assign({ role: 'menuitem', className: anchorClassNames, "data-item-id": option.id, "data-item-index": index,
167
+ // Note, we need to assign the click callback only when it's not disabled
168
+ // otherwise the functions is still triggered
169
+ // biome-ignore lint/a11y/useValidAnchor: due to old structure + backwards compatibility
170
+ onClick: option.disabled ? undefined : handleOptionChange }, { children: [(0, jsx_runtime_1.jsxs)("span", { children: [option.icon && (0, jsx_runtime_1.jsx)("span", Object.assign({ className: 'margin-right-5' }, { children: option.icon })), option.label] }), (0, jsx_runtime_1.jsx)("input", { type: 'hidden', value: option.id })] })) }), option.id));
171
+ })] })));
170
172
  };
171
173
  const filterOptions = (itemDOMValues, filterValue, options) => {
172
174
  const filteredDOMValues = itemDOMValues.filter(item => item.text.toLowerCase().includes(filterValue.toLowerCase()));
@@ -69,6 +69,11 @@ export type MultiselectProps<T extends MultiselectOption> = Omit<WithFeedbackAnd
69
69
  * @default true
70
70
  */
71
71
  autoDropDirection?: boolean;
72
+ /**
73
+ * Shows a loading spinner instead of the menu items if set to true.
74
+ * @default false
75
+ */
76
+ isLoading?: boolean;
72
77
  /**
73
78
  * Defines the size of the select to be rendered.
74
79
  *
@@ -18,7 +18,7 @@ const useMergeRefs_1 = tslib_1.__importDefault(require("../../hooks/useMergeRefs
18
18
  const WithFeedbackAndAddon_1 = tslib_1.__importDefault(require("./WithFeedbackAndAddon"));
19
19
  const DEFAULT_FOCUSED_ITEM_INDEX = -1;
20
20
  const Multiselect = (props) => {
21
- const { name, id = name, options = [], value, onChange = noop_1.default, placeholder, dropup = false, pullRight = false, autoDropDirection = true, bsSize = 'md', disabled = false, tabIndex = 0, hasError = false, useFilter = false, multiline = false, noItemMessage, counterMessage, renderCounterMessage, showSelectedItemIcon = false, showUnselectedItemIcons = false, className, inputAddon, errorMessage, warningMessage, messageWhiteSpace = 'normal' } = props, remainingProps = tslib_1.__rest(props, ["name", "id", "options", "value", "onChange", "placeholder", "dropup", "pullRight", "autoDropDirection", "bsSize", "disabled", "tabIndex", "hasError", "useFilter", "multiline", "noItemMessage", "counterMessage", "renderCounterMessage", "showSelectedItemIcon", "showUnselectedItemIcons", "className", "inputAddon", "errorMessage", "warningMessage", "messageWhiteSpace"]);
21
+ const { name, id = name, options = [], value, onChange = noop_1.default, placeholder, isLoading = false, dropup = false, pullRight = false, autoDropDirection = true, bsSize = 'md', disabled = false, tabIndex = 0, hasError = false, useFilter = false, multiline = false, noItemMessage, counterMessage, renderCounterMessage, showSelectedItemIcon = false, showUnselectedItemIcons = false, className, inputAddon, errorMessage, warningMessage, messageWhiteSpace = 'normal' } = props, remainingProps = tslib_1.__rest(props, ["name", "id", "options", "value", "onChange", "placeholder", "isLoading", "dropup", "pullRight", "autoDropDirection", "bsSize", "disabled", "tabIndex", "hasError", "useFilter", "multiline", "noItemMessage", "counterMessage", "renderCounterMessage", "showSelectedItemIcon", "showUnselectedItemIcons", "className", "inputAddon", "errorMessage", "warningMessage", "messageWhiteSpace"]);
22
22
  const [isOpen, setIsOpen] = (0, react_1.useState)(false);
23
23
  const [selectedItemIds, setSelectedItemIds] = (0, react_1.useState)(value || []);
24
24
  const [isFilterActive, setIsFilterActive] = (0, react_1.useState)(false);
@@ -88,7 +88,7 @@ const Multiselect = (props) => {
88
88
  option.selected = selectedItemIds.indexOf(option.id) !== -1;
89
89
  return option;
90
90
  });
91
- return ((0, jsx_runtime_1.jsx)(BaseSelectDropdown_1.default, { isOpen: isOpen, options: nonSelectedOptions, focusedItemIndex: focusedItemIndex, keyboardUsed: keyboardUsed, updateDOMValues: updateDOMValues, onSelect: onOptionChange, onClose: closeMenu, noItemMessage: noItemMessage, pullRight: pullRight, useActiveClass: true, dropup: dropup, autoDropDirection: autoDropDirection, requestItemDOMValues: requestItemDOMValues }));
91
+ return ((0, jsx_runtime_1.jsx)(BaseSelectDropdown_1.default, { isOpen: isOpen, isLoading: isLoading, options: nonSelectedOptions, focusedItemIndex: focusedItemIndex, keyboardUsed: keyboardUsed, updateDOMValues: updateDOMValues, onSelect: onOptionChange, onClose: closeMenu, noItemMessage: noItemMessage, pullRight: pullRight, useActiveClass: true, dropup: dropup, autoDropDirection: autoDropDirection, requestItemDOMValues: requestItemDOMValues }));
92
92
  };
93
93
  const handleFilterChange = (event) => {
94
94
  event.preventDefault();
@@ -103,6 +103,11 @@ export type SelectProps<T extends SelectOption> = Omit<WithFeedbackAndAddonProps
103
103
  * @default false
104
104
  */
105
105
  useClear?: boolean;
106
+ /**
107
+ * Shows a loading spinner instead of the menu items if set to true.
108
+ * @default false
109
+ */
110
+ isLoading?: boolean;
106
111
  /**
107
112
  * Text that shall be shown when not match was found when filtering.
108
113
  */
@@ -17,7 +17,7 @@ const SelectedOption_1 = tslib_1.__importDefault(require("./SelectedOption"));
17
17
  const WithFeedbackAndAddon_1 = tslib_1.__importDefault(require("./WithFeedbackAndAddon"));
18
18
  const DEFAULT_FOCUSED_ITEM_INDEX = -1;
19
19
  const Select = (props) => {
20
- const { name, id = name, label, options = [], value, onChange = noop_1.default, placeholder, dropup = false, pullRight = false, autoDropDirection = true, bsSize = 'md', disabled = false, tabIndex = 0, hasError = false, useFilter = false, useClear = false, noItemMessage, selectedOptionText, showSelectedItemIcon = false, showUnselectedItemIcons = false, dropdownClassName, btnClassName, className, inputAddon, errorMessage, warningMessage, messageWhiteSpace = 'normal' } = props, remainingProps = tslib_1.__rest(props, ["name", "id", "label", "options", "value", "onChange", "placeholder", "dropup", "pullRight", "autoDropDirection", "bsSize", "disabled", "tabIndex", "hasError", "useFilter", "useClear", "noItemMessage", "selectedOptionText", "showSelectedItemIcon", "showUnselectedItemIcons", "dropdownClassName", "btnClassName", "className", "inputAddon", "errorMessage", "warningMessage", "messageWhiteSpace"]);
20
+ const { name, id = name, label, options = [], value, onChange = noop_1.default, placeholder, isLoading = false, dropup = false, pullRight = false, autoDropDirection = true, bsSize = 'md', disabled = false, tabIndex = 0, hasError = false, useFilter = false, useClear = false, noItemMessage, selectedOptionText, showSelectedItemIcon = false, showUnselectedItemIcons = false, dropdownClassName, btnClassName, className, inputAddon, errorMessage, warningMessage, messageWhiteSpace = 'normal' } = props, remainingProps = tslib_1.__rest(props, ["name", "id", "label", "options", "value", "onChange", "placeholder", "isLoading", "dropup", "pullRight", "autoDropDirection", "bsSize", "disabled", "tabIndex", "hasError", "useFilter", "useClear", "noItemMessage", "selectedOptionText", "showSelectedItemIcon", "showUnselectedItemIcons", "dropdownClassName", "btnClassName", "className", "inputAddon", "errorMessage", "warningMessage", "messageWhiteSpace"]);
21
21
  const [isOpen, setIsOpen] = (0, react_1.useState)(false);
22
22
  const [selectedItem, setSelectedItem] = (0, react_1.useState)(null);
23
23
  const [isFilterActive, setIsFilterActive] = (0, react_1.useState)(false);
@@ -84,7 +84,7 @@ const Select = (props) => {
84
84
  else if (keyboardUsed) {
85
85
  currentFocusedItemIndex = 0;
86
86
  }
87
- return ((0, jsx_runtime_1.jsx)(BaseSelectDropdown_1.default, { isOpen: isOpen, options: filteredOptions, focusedItemIndex: currentFocusedItemIndex, keyboardUsed: keyboardUsed, updateDOMValues: updateDOMValues, onSelect: onOptionChange, onClose: closeMenu, noItemMessage: noItemMessage, pullRight: pullRight, dropup: dropup, autoDropDirection: autoDropDirection, dropdownClassName: dropdownClassName, requestItemDOMValues: requestItemDOMValues }));
87
+ return ((0, jsx_runtime_1.jsx)(BaseSelectDropdown_1.default, { isOpen: isOpen, isLoading: isLoading, options: filteredOptions, focusedItemIndex: currentFocusedItemIndex, keyboardUsed: keyboardUsed, updateDOMValues: updateDOMValues, onSelect: onOptionChange, onClose: closeMenu, noItemMessage: noItemMessage, pullRight: pullRight, dropup: dropup, autoDropDirection: autoDropDirection, dropdownClassName: dropdownClassName, requestItemDOMValues: requestItemDOMValues }));
88
88
  };
89
89
  const handleFilterChange = (event) => {
90
90
  event.preventDefault();
@@ -1,4 +1,5 @@
1
1
  import React, { type HTMLAttributes } from 'react';
2
+ import { type CurrentColor } from '../../utils/currentColors';
2
3
  export type RangeSliderProps = {
3
4
  /**
4
5
  * The current left value of the selected range.
@@ -36,6 +37,12 @@ export type RangeSliderProps = {
36
37
  * @default 1
37
38
  */
38
39
  step?: number;
40
+ /**
41
+ * Defines the color of the slider.
42
+ *
43
+ * @default 'primary'
44
+ */
45
+ color?: CurrentColor;
39
46
  /**
40
47
  * Disables all pointer events.
41
48
  *
@@ -5,13 +5,14 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
7
7
  const noop_1 = tslib_1.__importDefault(require("lodash/noop"));
8
+ const currentColors_1 = require("../../utils/currentColors");
8
9
  const getRangeValues = (valueLeft, valueRight) => {
9
10
  const finalLeftValue = valueRight <= valueLeft ? valueRight : valueLeft;
10
11
  const finalRightValue = valueLeft >= valueRight ? valueLeft : valueRight;
11
12
  return [finalLeftValue, finalRightValue];
12
13
  };
13
14
  const RangeSlider = (props) => {
14
- const { minValue = 0, maxValue = Number.MAX_VALUE, valueLabels = false, valueLabelUnit, step = 1, leftValue, rightValue, className, disabled = false, onChange = noop_1.default, onDragEnd = noop_1.default } = props, remainingProps = tslib_1.__rest(props, ["minValue", "maxValue", "valueLabels", "valueLabelUnit", "step", "leftValue", "rightValue", "className", "disabled", "onChange", "onDragEnd"]);
15
+ const { minValue = 0, maxValue = Number.MAX_VALUE, valueLabels = false, valueLabelUnit, step = 1, color = 'primary', leftValue, rightValue, className, disabled = false, onChange = noop_1.default, onDragEnd = noop_1.default } = props, remainingProps = tslib_1.__rest(props, ["minValue", "maxValue", "valueLabels", "valueLabelUnit", "step", "color", "leftValue", "rightValue", "className", "disabled", "onChange", "onDragEnd"]);
15
16
  const [activeLeft, setActiveLeft] = (0, react_1.useState)(false);
16
17
  const [activeRight, setActiveRight] = (0, react_1.useState)(false);
17
18
  const [valueLeft, setValueLeft] = (0, react_1.useState)(leftValue ? leftValue : minValue);
@@ -34,8 +35,12 @@ const RangeSlider = (props) => {
34
35
  const [newLeftValue, newRightValue] = getRangeValues(newValueLeft, newValueRight);
35
36
  onChange(newLeftValue, newRightValue);
36
37
  };
37
- const handleChangeValueLeft = (event) => changeValues({ valueLeft: parseInt(event.target.value, 10) });
38
- const handleChangeValueRight = (event) => changeValues({ valueRight: parseInt(event.target.value, 10) });
38
+ const handleChangeValueLeft = (event) => {
39
+ changeValues({ valueLeft: Number.parseInt(event.target.value, 10) });
40
+ };
41
+ const handleChangeValueRight = (event) => {
42
+ changeValues({ valueRight: Number.parseInt(event.target.value, 10) });
43
+ };
39
44
  const onMouseDownLeft = () => {
40
45
  setIsChangingLeft(true);
41
46
  setIsChangingRight(false);
@@ -100,6 +105,7 @@ const RangeSlider = (props) => {
100
105
  const trackWidth = (100 * (finalRightValue - finalLeftValue)) / (maxValue - minValue);
101
106
  const trackLeft = (100 * (finalLeftValue - minValue)) / (maxValue - minValue);
102
107
  const wrapperClassNames = (0, classnames_1.default)('range-slider', disabled && 'disabled', valueLabels && 'show-value-labels', className && className);
103
- return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, remainingProps, { className: wrapperClassNames }, { children: [(0, jsx_runtime_1.jsx)("div", { className: 'range-whole-track' }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'range-track', style: { width: `${trackWidth}%`, left: `${trackLeft}%` } }, { children: valueLabels && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: 'user-select-none' }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'range-value' }, { children: valueLabelUnit ? `${finalLeftValue} ${valueLabelUnit}` : finalLeftValue })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'range-value' }, { children: valueLabelUnit ? `${finalRightValue} ${valueLabelUnit}` : finalRightValue }))] }))) })), (0, jsx_runtime_1.jsx)("input", { className: `${isChangingLeft ? 'changing' : ''}`, style: { zIndex: activeLeft ? '6' : '5' }, value: valueLeft, min: minValue, max: maxValue, step: step, type: 'range', onChange: handleChangeValueLeft, onMouseDown: onMouseDownLeft, onMouseMove: onMouseMoveLeft, onMouseUp: onMouseUpLeft }), (0, jsx_runtime_1.jsx)("input", { className: `${isChangingRight ? 'changing' : ''}`, style: { zIndex: activeRight ? '6' : '5' }, value: valueRight, min: minValue, max: maxValue, step: step, type: 'range', onChange: handleChangeValueRight, onMouseDown: onMouseDownRight, onMouseMove: onMouseMoveRight, onMouseUp: onMouseUpRight })] })));
108
+ const sliderBackgroundColor = (0, currentColors_1.getCurrentBackgroundColor)(color);
109
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, remainingProps, { className: wrapperClassNames, style: { color: sliderBackgroundColor } }, { children: [(0, jsx_runtime_1.jsx)("div", { className: 'range-whole-track' }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'range-track', style: { width: `${trackWidth}%`, left: `${trackLeft}%` } }, { children: valueLabels && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: 'user-select-none' }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'range-value' }, { children: (0, jsx_runtime_1.jsx)("span", { children: valueLabelUnit ? `${finalLeftValue} ${valueLabelUnit}` : finalLeftValue }) })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'range-value' }, { children: (0, jsx_runtime_1.jsx)("span", { children: valueLabelUnit ? `${finalRightValue} ${valueLabelUnit}` : finalRightValue }) }))] }))) })), (0, jsx_runtime_1.jsx)("input", { className: `${isChangingLeft ? 'changing' : ''}`, style: { zIndex: activeLeft ? '6' : '5' }, value: valueLeft, min: minValue, max: maxValue, step: step, type: 'range', onChange: handleChangeValueLeft, onMouseDown: onMouseDownLeft, onMouseMove: onMouseMoveLeft, onMouseUp: onMouseUpLeft }), (0, jsx_runtime_1.jsx)("input", { className: `${isChangingRight ? 'changing' : ''}`, style: { zIndex: activeRight ? '6' : '5' }, value: valueRight, min: minValue, max: maxValue, step: step, type: 'range', onChange: handleChangeValueRight, onMouseDown: onMouseDownRight, onMouseMove: onMouseMoveRight, onMouseUp: onMouseUpRight })] })));
104
110
  };
105
111
  exports.default = RangeSlider;
@@ -1,4 +1,5 @@
1
1
  import React, { type HTMLAttributes } from 'react';
2
+ import { type CurrentColor } from '../../utils/currentColors';
2
3
  export type SliderProps = {
3
4
  /**
4
5
  * The current value.
@@ -46,6 +47,12 @@ export type SliderProps = {
46
47
  * @default 1
47
48
  */
48
49
  step?: number;
50
+ /**
51
+ * Defines the color of the slider.
52
+ *
53
+ * @default 'primary'
54
+ */
55
+ color?: CurrentColor;
49
56
  /**
50
57
  * Disables all pointer events.
51
58
  *
@@ -5,8 +5,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
7
7
  const noop_1 = tslib_1.__importDefault(require("lodash/noop"));
8
+ const currentColors_1 = require("../../utils/currentColors");
8
9
  const Slider = (props) => {
9
- const { value = 0, minValue = 0, maxValue = Number.MAX_VALUE, valueLabels = false, valueLabelUnit, largeValueLabels = false, hideValueBar = false, step = 1, onChange = noop_1.default, onDragEnd = noop_1.default, className, disabled = false } = props, remainingProps = tslib_1.__rest(props, ["value", "minValue", "maxValue", "valueLabels", "valueLabelUnit", "largeValueLabels", "hideValueBar", "step", "onChange", "onDragEnd", "className", "disabled"]);
10
+ const { value = 0, minValue = 0, maxValue = Number.MAX_VALUE, valueLabels = false, valueLabelUnit, largeValueLabels = false, hideValueBar = false, color = 'primary', step = 1, onChange = noop_1.default, onDragEnd = noop_1.default, className, disabled = false } = props, remainingProps = tslib_1.__rest(props, ["value", "minValue", "maxValue", "valueLabels", "valueLabelUnit", "largeValueLabels", "hideValueBar", "color", "step", "onChange", "onDragEnd", "className", "disabled"]);
10
11
  const [currentValue, setCurrentValue] = (0, react_1.useState)(value ? value : minValue);
11
12
  const [isChanging, setIsChanging] = (0, react_1.useState)(false);
12
13
  (0, react_1.useEffect)(() => {
@@ -15,7 +16,7 @@ const Slider = (props) => {
15
16
  }
16
17
  }, [value, minValue, maxValue]);
17
18
  const handleChange = (event) => {
18
- const newValue = parseInt(event.target.value, 10);
19
+ const newValue = Number.parseInt(event.target.value, 10);
19
20
  setCurrentValue(newValue);
20
21
  setIsChanging(true);
21
22
  onChange(newValue);
@@ -29,6 +30,7 @@ const Slider = (props) => {
29
30
  };
30
31
  const wrapperClassNames = (0, classnames_1.default)('range-slider', disabled && 'disabled', valueLabels && 'show-value-labels', hideValueBar && 'hide-value-bar', largeValueLabels && 'large-value-labels', className && className);
31
32
  const trackWidth = (100 * (currentValue - minValue)) / (maxValue - minValue);
32
- return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, remainingProps, { className: wrapperClassNames }, { children: [(0, jsx_runtime_1.jsx)("div", { className: 'range-whole-track' }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'range-track', style: { width: `${trackWidth}%` } }, { children: valueLabels && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'range-value' }, { children: (0, jsx_runtime_1.jsx)("div", { children: valueLabelUnit ? `${currentValue} ${valueLabelUnit}` : currentValue }) }))) })), (0, jsx_runtime_1.jsx)("input", { className: `${isChanging ? 'changing' : ''}`, value: currentValue, min: minValue, max: maxValue, step: step, type: 'range', onChange: handleChange, onMouseDown: onMouseDown, onMouseUp: onMouseUp })] })));
33
+ const sliderBackgroundColor = (0, currentColors_1.getCurrentBackgroundColor)(color);
34
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, remainingProps, { className: wrapperClassNames, style: { color: sliderBackgroundColor } }, { children: [(0, jsx_runtime_1.jsx)("div", { className: 'range-whole-track' }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'range-track', style: { width: `${trackWidth}%` } }, { children: valueLabels && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'range-value' }, { children: (0, jsx_runtime_1.jsx)("span", { children: valueLabelUnit ? `${currentValue} ${valueLabelUnit}` : currentValue }) }))) })), (0, jsx_runtime_1.jsx)("input", { className: `${isChanging ? 'changing' : ''}`, value: currentValue, min: minValue, max: maxValue, step: step, type: 'range', onChange: handleChange, onMouseDown: onMouseDown, onMouseUp: onMouseUp })] })));
33
35
  };
34
36
  exports.default = Slider;
@@ -8,6 +8,7 @@ const classnames_1 = tslib_1.__importDefault(require("classnames"));
8
8
  const isEmpty_1 = tslib_1.__importDefault(require("lodash/fp/isEmpty"));
9
9
  const StateButton_1 = tslib_1.__importDefault(require("./StateButton"));
10
10
  const StateIcon_1 = tslib_1.__importDefault(require("./StateIcon"));
11
+ const hasUtilityClass_1 = require("../../utils/hasUtilityClass");
11
12
  const justify = {
12
13
  left: 'justify-content-start',
13
14
  center: 'justify-content-center',
@@ -28,11 +29,9 @@ const renderButtons = (buttons) => {
28
29
  }) }))] }));
29
30
  };
30
31
  const CustomState = (props) => {
31
- const { icon, icons = [], image, headline, message, buttons = [], alignment = 'center', fullWidth = false, condensed = false, outerClassName, innerClassName, children } = props, remainingProps = tslib_1.__rest(props, ["icon", "icons", "image", "headline", "message", "buttons", "alignment", "fullWidth", "condensed", "outerClassName", "innerClassName", "children"]);
32
- const hasCustomInnerPadding = innerClassName === null || innerClassName === void 0 ? void 0 : innerClassName.includes('padding');
33
- const hasCustomOuterPadding = outerClassName === null || outerClassName === void 0 ? void 0 : outerClassName.includes('padding');
34
- const wrapperClasses = (0, classnames_1.default)('margin-0', 'width-100pct', !fullWidth && 'max-width-600', 'panel-default', 'panel', !hasCustomOuterPadding && condensed ? 'padding-10' : 'padding-15', outerClassName && outerClassName);
35
- const innerClassNames = (0, classnames_1.default)('display-flex', 'flex-column', 'align-items-center', 'text-center', !hasCustomInnerPadding && condensed ? 'padding-15' : 'padding-25', innerClassName && innerClassName);
32
+ const { icon, icons = [], image, headline, message, buttons = [], alignment = 'center', fullWidth = false, condensed = false, outerClassName = '', innerClassName = '', children } = props, remainingProps = tslib_1.__rest(props, ["icon", "icons", "image", "headline", "message", "buttons", "alignment", "fullWidth", "condensed", "outerClassName", "innerClassName", "children"]);
33
+ const wrapperClasses = (0, classnames_1.default)('margin-0', 'width-100pct', !fullWidth && 'max-width-600', 'panel-default', 'panel', !(0, hasUtilityClass_1.hasPaddingClass)(outerClassName) && condensed ? 'padding-10' : 'padding-15', outerClassName);
34
+ const innerClassNames = (0, classnames_1.default)('display-flex', 'flex-column', 'align-items-center', 'text-center', !(0, hasUtilityClass_1.hasPaddingClass)(innerClassName) && condensed ? 'padding-15' : 'padding-25', innerClassName);
36
35
  const iconClasses = (0, classnames_1.default)(condensed ? 'text-size-16 margin-bottom-10' : 'text-size-h2 margin-bottom-20');
37
36
  const iconsClasses = (0, classnames_1.default)(condensed ? 'text-size-16 margin-bottom-10' : 'text-size-h2 margin-bottom-20', 'display-flex', 'align-items-center', 'max-width-100pct');
38
37
  const headlineClassNames = (0, classnames_1.default)(condensed ? 'text-size-h4' : 'text-size-h3 text-size-h2-xl', 'line-height-125rel', 'text-color-dark', 'text-medium', 'width-500', 'max-width-100pct', 'text-wrap-balance');
@@ -1,4 +1,5 @@
1
1
  import { type PropsWithChildren } from 'react';
2
+ import { type CurrentColor } from '../../utils/currentColors';
2
3
  export type SwitchProps = {
3
4
  /**
4
5
  * Optional key that is used as key and as the id on the internal input.
@@ -14,6 +15,12 @@ export type SwitchProps = {
14
15
  * @default false
15
16
  */
16
17
  checked?: boolean;
18
+ /**
19
+ * Defines the color of the switch.
20
+ *
21
+ * @default 'primary'
22
+ */
23
+ color?: CurrentColor;
17
24
  /**
18
25
  * The min-width of the switch.
19
26
  */
@@ -6,8 +6,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  require("react");
7
7
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
8
8
  const noop_1 = tslib_1.__importDefault(require("lodash/fp/noop"));
9
+ const currentColors_1 = require("../../utils/currentColors");
9
10
  const Switch = (props) => {
10
- const { keyName, checked = false, enabledText, minWidth = 40, disabled = false, disabledText, children, labelPosition = !!children ? 'right' : undefined, onChange = noop_1.default } = props, remainingProps = tslib_1.__rest(props, ["keyName", "checked", "enabledText", "minWidth", "disabled", "disabledText", "children", "labelPosition", "onChange"]);
11
+ const { keyName, checked = false, enabledText, minWidth = 40, disabled = false, color = 'primary', disabledText, children, labelPosition = !!children ? 'right' : undefined, onChange = noop_1.default } = props, remainingProps = tslib_1.__rest(props, ["keyName", "checked", "enabledText", "minWidth", "disabled", "color", "disabledText", "children", "labelPosition", "onChange"]);
11
12
  const handleChange = (event) => {
12
13
  onChange(event.target.checked);
13
14
  };
@@ -17,8 +18,8 @@ const Switch = (props) => {
17
18
  const switchContentClasses = (0, classnames_1.default)('switch-content'
18
19
  // !hasMultipleText && !hasSingleText && 'width-40'
19
20
  );
20
- const switchContentStyles = { minWidth };
21
- return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, remainingProps, { className: 'uikit-switch' }, { children: (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: switchLabelClasses }, { children: [(0, jsx_runtime_1.jsx)("input", { onChange: handleChange, checked: checked, type: 'checkbox', id: keyName, className: 'switch-input', disabled: disabled }, keyName), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: switchContentClasses, style: switchContentStyles }, { children: [hasMultipleText ? ((0, jsx_runtime_1.jsx)("div", { className: 'switch-text', "data-on": enabledText, "data-off": disabledText })) : (hasSingleText && (0, jsx_runtime_1.jsx)("div", { className: 'switch-text', "data-on": enabledText, "data-off": enabledText })), (0, jsx_runtime_1.jsx)("div", { className: 'switch-handle' })] })), children && children] })) })));
21
+ const switchBackgroundColor = (0, currentColors_1.getCurrentBackgroundColor)(color);
22
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, remainingProps, { className: 'uikit-switch' }, { children: (0, jsx_runtime_1.jsxs)("label", Object.assign({ className: switchLabelClasses }, { children: [(0, jsx_runtime_1.jsx)("input", { onChange: handleChange, checked: checked, type: 'checkbox', id: keyName, className: 'switch-input', disabled: disabled }, keyName), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: switchContentClasses, style: { color: switchBackgroundColor, minWidth } }, { children: [hasMultipleText ? ((0, jsx_runtime_1.jsx)("div", { className: 'switch-text', "data-on": enabledText, "data-off": disabledText })) : (hasSingleText && (0, jsx_runtime_1.jsx)("div", { className: 'switch-text', "data-on": enabledText, "data-off": enabledText })), (0, jsx_runtime_1.jsx)("div", { className: 'switch-handle' })] })), children && children] })) })));
22
23
  };
23
24
  Switch.LABEL_POSITION_LEFT = 'left';
24
25
  Switch.LABEL_POSITION_RIGHT = 'right';
@@ -1,6 +1,6 @@
1
1
  import React, { type MutableRefObject, type PropsWithChildren } from 'react';
2
2
  import { type TooltipProps } from './Tooltip';
3
- import { type Trigger } from '../../values/Trigger';
3
+ import { type TriggerType } from '../../values/Trigger';
4
4
  export type delayProp = {
5
5
  show: number;
6
6
  hide: number;
@@ -15,7 +15,7 @@ export type SimpleTooltipProps = Omit<TooltipProps, 'content'> & {
15
15
  * Possible values are: `hover`, `click`, `focus`
16
16
  * @default 'hover'
17
17
  */
18
- trigger?: Trigger;
18
+ trigger?: TriggerType;
19
19
  /**
20
20
  * The react ref object assigned to the target of the tooltip.
21
21
  */
@@ -47,9 +47,9 @@ export type TooltipProps = {
47
47
  */
48
48
  allowOnTouch?: boolean;
49
49
  /**
50
- * Additional props assigned to the arrow element.
50
+ * Additional props assigned to the arrow element. Internally used.
51
51
  */
52
- arrowProps?: {};
52
+ arrowProps?: Record<string, unknown>;
53
53
  /**
54
54
  * Additional style properties assigned to the wrapper element.
55
55
  */
@@ -19,13 +19,17 @@ const TEXT_ALIGNMENT_MAP = {
19
19
  };
20
20
  const Tooltip = (0, react_1.forwardRef)((props, ref) => {
21
21
  const _a = (0, omit_1.default)(['popper', 'positionLeft', 'positionTop'], props), { allowOnTouch = false, arrowProps, children, className = '', innerClassName = '', placement = 'bottom', style, textAlignment = 'center', tooltipStyle = 'default', width = 'auto' } = _a, remainingProps = tslib_1.__rest(_a, ["allowOnTouch", "arrowProps", "children", "className", "innerClassName", "placement", "style", "textAlignment", "tooltipStyle", "width"]);
22
+ // Mount the component but don't show it yet via CSS.
23
+ // After it is mounted, we set the visibility class to use CSS animation
24
+ const [isMounted, setIsMounted] = (0, react_1.useState)(false);
25
+ (0, react_1.useEffect)(() => setIsMounted(true), []);
22
26
  if (!(0, deviceUtils_1.isDesktop)() && !allowOnTouch) {
23
27
  // Workaround: we have to return a DOM node as otherwise the
24
28
  // react-transition library would throw an error on mobile
25
29
  // when triggering a browser reflow and accessing the node directly.
26
30
  return (0, jsx_runtime_1.jsx)("span", { className: 'display-none' });
27
31
  }
28
- const wrapperClasses = (0, classnames_1.default)('tooltip', tooltipStyle && `tooltip-${tooltipStyle}`, placement, className);
32
+ const wrapperClasses = (0, classnames_1.default)('tooltip', tooltipStyle && `tooltip-${tooltipStyle}`, placement, 'fade', isMounted && 'show', className);
29
33
  const innerClasses = (0, classnames_1.default)('tooltip-inner', textAlignment && `text-${textAlignment}`, width && `width-${width}`, innerClassName && innerClassName);
30
34
  /* eslint-disable react/no-unknown-property */
31
35
  return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, remainingProps, { role: 'tooltip', "x-placement": placement, ref: ref, className: wrapperClasses, style: Object.assign({}, style), "data-offset": 20 }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'tooltip-arrow' }, arrowProps)), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: innerClasses }, { children: children }))] })));
@@ -9,4 +9,5 @@ export type EventListenerType = keyof DocumentEventMap;
9
9
  * @returns A mutable ref object representing the target element.
10
10
  */
11
11
  declare const useClickOutside: <T extends HTMLElement = any>(callback: (event: MouseEvent | TouchEvent) => void, events?: EventListenerType[]) => import("react").MutableRefObject<T>;
12
+ export declare const useClickOutsideWithRef: <T extends HTMLElement = any>(ref: React.MutableRefObject<HTMLElement | null> | HTMLElement | null, callback: (event: MouseEvent | TouchEvent) => void, events?: EventListenerType[]) => void;
12
13
  export default useClickOutside;
@@ -3,6 +3,7 @@
3
3
  // eslint-disable-next-line max-len
4
4
  // Inspired from https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-click-outside/use-click-outside.ts
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useClickOutsideWithRef = void 0;
6
7
  const react_1 = require("react");
7
8
  /**
8
9
  * Custom hook to detect clicks outside a specified element.
@@ -14,10 +15,17 @@ const react_1 = require("react");
14
15
  */
15
16
  const useClickOutside = (callback, events = ['mousedown', 'touchstart']) => {
16
17
  const targetRef = (0, react_1.useRef)(null);
18
+ (0, exports.useClickOutsideWithRef)(targetRef, callback, events);
19
+ return targetRef;
20
+ };
21
+ // Internal use for now - extend it later to be used outside
22
+ const useClickOutsideWithRef = (ref, callback, events = ['mousedown', 'touchstart']) => {
17
23
  (0, react_1.useEffect)(() => {
24
+ // In case the ref is actually a state and will be set via the state setter function
25
+ const element = ref && 'current' in ref ? ref.current : ref;
18
26
  // Event listener function to check if the click is outside the target element
19
27
  const listener = (event) => {
20
- if (targetRef.current && !targetRef.current.contains(event.target)) {
28
+ if (element && !element.contains(event.target)) {
21
29
  callback(event);
22
30
  }
23
31
  };
@@ -27,7 +35,7 @@ const useClickOutside = (callback, events = ['mousedown', 'touchstart']) => {
27
35
  return () => {
28
36
  events.forEach(eventType => document.removeEventListener(eventType, listener));
29
37
  };
30
- }, [targetRef, callback, events]);
31
- return targetRef;
38
+ }, [ref, callback, events]);
32
39
  };
40
+ exports.useClickOutsideWithRef = useClickOutsideWithRef;
33
41
  exports.default = useClickOutside;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Custom React hook to measure the elapsed time since a specified start time or the component's mount time.
3
+ *
4
+ * @param {number} [startTime=Date.now()] - The start time in milliseconds from which to measure the elapsed time.
5
+ * @returns {Function} A function that returns the elapsed time in milliseconds since the specified start time
6
+ * or the component's mount time.
7
+ *
8
+ * @example
9
+ * import useElapsedTime from '@rio-cloud/rio-uikit/useElapsedTime';
10
+ * import Button from '@rio-cloud/rio-uikit/Button';
11
+ *
12
+ * const MyComponent = () => {
13
+ * const getElapsedTime = useElapsedTime();
14
+ *
15
+ * const handleClick = () => {
16
+ * const elapsedTime = getElapsedTime();
17
+ * console.log(`Elapsed time: ${elapsedTime} ms`);
18
+ * };
19
+ *
20
+ * return (
21
+ * <Button onClick={handleClick}>Get elapsed time</Button>
22
+ * );
23
+ * };
24
+ */
25
+ declare const useElapsedTime: (startTime?: number) => (() => number);
26
+ export default useElapsedTime;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ /**
5
+ * Custom React hook to measure the elapsed time since a specified start time or the component's mount time.
6
+ *
7
+ * @param {number} [startTime=Date.now()] - The start time in milliseconds from which to measure the elapsed time.
8
+ * @returns {Function} A function that returns the elapsed time in milliseconds since the specified start time
9
+ * or the component's mount time.
10
+ *
11
+ * @example
12
+ * import useElapsedTime from '@rio-cloud/rio-uikit/useElapsedTime';
13
+ * import Button from '@rio-cloud/rio-uikit/Button';
14
+ *
15
+ * const MyComponent = () => {
16
+ * const getElapsedTime = useElapsedTime();
17
+ *
18
+ * const handleClick = () => {
19
+ * const elapsedTime = getElapsedTime();
20
+ * console.log(`Elapsed time: ${elapsedTime} ms`);
21
+ * };
22
+ *
23
+ * return (
24
+ * <Button onClick={handleClick}>Get elapsed time</Button>
25
+ * );
26
+ * };
27
+ */
28
+ const useElapsedTime = (startTime = Date.now()) => {
29
+ const startTimeRef = (0, react_1.useRef)(startTime);
30
+ const getElapsedTime = () => {
31
+ return Date.now() - startTimeRef.current;
32
+ };
33
+ (0, react_1.useEffect)(() => {
34
+ startTimeRef.current = startTime;
35
+ }, [startTime]);
36
+ return getElapsedTime;
37
+ };
38
+ exports.default = useElapsedTime;
@@ -14,5 +14,5 @@ type WindowEventMapWithFullscreen = {
14
14
  * @param options - Optional. An object that specifies characteristics about the event listener.
15
15
  * @param target - Optional. The target element to which to attach the event listener.
16
16
  */
17
- declare const useEvent: <K extends keyof WindowEventMap, W extends keyof WindowEventMapWithFullscreen, T extends HTMLElement = HTMLDivElement>(eventType: K | W, callback: EventListener, options?: boolean | AddEventListenerOptions, target?: Window | Document | T | null) => void;
17
+ declare const useEvent: <K extends keyof WindowEventMap, W extends keyof WindowEventMapWithFullscreen, T extends HTMLElement = HTMLDivElement>(eventType: K | W, callback: EventListener, options?: boolean | AddEventListenerOptions, target?: Document | Window | T | null) => void;
18
18
  export default useEvent;
@@ -2,9 +2,12 @@ type KeyboardEventType = 'keyup' | 'keydown' | 'keypress';
2
2
  /**
3
3
  * Custom hook to handle keyboard events.
4
4
  *
5
- * @param callback - The callback function to be executed when a keyboard event occurs.
6
- * @param [eventTypes=['keydown']] - The types of keyboard events to listen for.
7
- * @param [node=document] - The DOM node to attach the event listener to (defaults to document).
5
+ * @param keyOrCallback - Either a key string (e.g., 'Enter') or a callback function.
6
+ * @param callbackOrEventTypes - If the first argument is a key, this should be the callback function.
7
+ * If the first argument is a callback, this is an optional array of event types.
8
+ * @param [eventTypesOrNode=['keydown']] - If the first argument is a key, this should be an array of event types.
9
+ * If the first argument is a callback, this is the node (defaults to document).
10
+ * @param [node=document] - Optional DOM node to attach the event listener to (defaults to document).
8
11
  */
9
- declare const useKey: (callback: (event: KeyboardEvent) => void, eventTypes?: KeyboardEventType[], node?: Document) => void;
12
+ declare const useKey: (keyOrCallback: string | ((event: KeyboardEvent) => void), callbackOrEventTypes?: ((event: KeyboardEvent) => void | KeyboardEventType[]) | undefined, eventTypesOrNode?: KeyboardEventType[] | Document, node?: Document | HTMLElement) => void;
10
13
  export default useKey;
@@ -4,20 +4,48 @@ const react_1 = require("react");
4
4
  /**
5
5
  * Custom hook to handle keyboard events.
6
6
  *
7
- * @param callback - The callback function to be executed when a keyboard event occurs.
8
- * @param [eventTypes=['keydown']] - The types of keyboard events to listen for.
9
- * @param [node=document] - The DOM node to attach the event listener to (defaults to document).
7
+ * @param keyOrCallback - Either a key string (e.g., 'Enter') or a callback function.
8
+ * @param callbackOrEventTypes - If the first argument is a key, this should be the callback function.
9
+ * If the first argument is a callback, this is an optional array of event types.
10
+ * @param [eventTypesOrNode=['keydown']] - If the first argument is a key, this should be an array of event types.
11
+ * If the first argument is a callback, this is the node (defaults to document).
12
+ * @param [node=document] - Optional DOM node to attach the event listener to (defaults to document).
10
13
  */
11
- const useKey = (callback, eventTypes = ['keydown'], node = document) => {
14
+ const useKey = (keyOrCallback, callbackOrEventTypes, eventTypesOrNode = ['keydown'], node = document) => {
15
+ const callbacksRef = (0, react_1.useRef)([]);
12
16
  (0, react_1.useEffect)(() => {
17
+ const isKeyMode = typeof keyOrCallback === 'string';
18
+ const callback = isKeyMode
19
+ ? callbackOrEventTypes
20
+ : keyOrCallback;
21
+ const keyHandler = (event) => {
22
+ if (isKeyMode) {
23
+ if (event.key === keyOrCallback) {
24
+ callback(event);
25
+ }
26
+ }
27
+ else {
28
+ callback(event);
29
+ }
30
+ };
31
+ // Register the keyHandler
32
+ callbacksRef.current.push(keyHandler);
33
+ const genericHandler = (event) => {
34
+ for (const callBecky of callbacksRef.current) {
35
+ callBecky(event);
36
+ }
37
+ };
38
+ const eventTypes = Array.isArray(eventTypesOrNode) ? eventTypesOrNode : ['keydown'];
13
39
  for (const eventType of eventTypes) {
14
- node.addEventListener(eventType, callback);
40
+ node.addEventListener(eventType, genericHandler);
15
41
  }
16
42
  return () => {
17
43
  for (const eventType of eventTypes) {
18
- node.removeEventListener(eventType, callback);
44
+ node.removeEventListener(eventType, genericHandler);
19
45
  }
46
+ // Clean up callback reference
47
+ callbacksRef.current = callbacksRef.current.filter(singleCallback => singleCallback !== keyHandler);
20
48
  };
21
- }, [callback]);
49
+ }, [keyOrCallback, callbackOrEventTypes, eventTypesOrNode, node]);
22
50
  };
23
51
  exports.default = useKey;
@@ -8,4 +8,9 @@ import React from 'react';
8
8
  * @returns A mutable ref object to manage the timeout ID.
9
9
  */
10
10
  declare const useTimeout: (callback: () => void, delay: number | null) => React.MutableRefObject<number | null>;
11
+ export declare const useChainedTimeout: () => {
12
+ set: (fn: () => void, delayMs?: number) => void;
13
+ clear: () => void;
14
+ handleRef: React.MutableRefObject<any>;
15
+ };
11
16
  export default useTimeout;