@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
@@ -1,15 +1,147 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // @ts-ignore-next-line importsNotUsedAsValues
3
- import 'react';
4
- import BSOverlayTrigger from 'react-bootstrap/OverlayTrigger';
5
- import omit from 'lodash/omit';
3
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
4
+ import ReactDOM from 'react-dom';
5
+ import { usePopper } from 'react-popper';
6
6
  import { PLACEMENT } from '../../values/Placement';
7
7
  import { TRIGGER } from '../../values/Trigger';
8
+ import mergeRefs from '../../utils/mergeRefs';
9
+ import { useClickOutsideWithRef } from '../../hooks/useClickOutside';
10
+ import { useChainedTimeout } from '../../hooks/useTimeout';
11
+ import { useUncontrolledProp } from '../../hooks/useUncontrollable';
8
12
  const OverlayTrigger = (props) => {
9
- const usedProps = Object.assign({ rootClose: true }, omit(props, 'children'));
10
- const { children } = props;
11
- // @ts-ignore
12
- return _jsx(BSOverlayTrigger, Object.assign({}, usedProps, { children: children }));
13
+ var _a, _b;
14
+ const { show: propsShow, defaultShow = false, enablePortal = true, trigger = TRIGGER.HOVER, delay, overlay, placement = 'top', popperConfig, onToggle = () => { }, rootClose = true, children, } = props;
15
+ // Use a hook to handle controlled props that work in pairs like in this case the "show" and "onToggle"
16
+ // props. It returns a setter function that automatically triggers the callback.
17
+ const [show, setShow] = useUncontrolledProp(propsShow, defaultShow, onToggle);
18
+ const hoverStateRef = useRef('');
19
+ const timeout = useChainedTimeout();
20
+ const { onFocus, onBlur, onClick } = typeof children !== 'function' ? React.Children.only(children).props : {};
21
+ // Simple implementation of mouseEnter and mouseLeave.
22
+ // React's built version is broken: https://github.com/facebook/react/issues/4251
23
+ // for cases when the trigger is disabled and mouseOut/Over can cause flicker
24
+ // moving from one child element to another.
25
+ const handleMouseOverOut = (handler, args, relatedNative) => {
26
+ const [event] = args;
27
+ const target = event.currentTarget;
28
+ const related = event.relatedTarget;
29
+ if ((!related || related !== target) && !target.contains(related)) {
30
+ handler(...args);
31
+ }
32
+ };
33
+ const handleShow = () => {
34
+ timeout.clear();
35
+ hoverStateRef.current = 'show';
36
+ if (typeof delay === 'number' || !(delay === null || delay === void 0 ? void 0 : delay.show)) {
37
+ setShow(true);
38
+ return;
39
+ }
40
+ timeout.set(() => {
41
+ if (hoverStateRef.current === 'show') {
42
+ setShow(true);
43
+ }
44
+ }, typeof delay === 'number' ? delay : delay === null || delay === void 0 ? void 0 : delay.show);
45
+ };
46
+ const handleHide = () => {
47
+ timeout.clear();
48
+ hoverStateRef.current = 'hide';
49
+ if (typeof delay === 'number' || !(delay === null || delay === void 0 ? void 0 : delay.hide)) {
50
+ setShow(false);
51
+ return;
52
+ }
53
+ timeout.set(() => {
54
+ if (hoverStateRef.current === 'hide') {
55
+ setShow(false);
56
+ }
57
+ }, typeof delay === 'number' ? delay : delay === null || delay === void 0 ? void 0 : delay.hide);
58
+ };
59
+ const handleFocus = useCallback((...args) => {
60
+ handleShow();
61
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(...args);
62
+ }, [handleShow, onFocus]);
63
+ const handleBlur = useCallback((...args) => {
64
+ handleHide();
65
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(...args);
66
+ }, [handleHide, onBlur]);
67
+ const handleClick = useCallback((...args) => {
68
+ setShow(!show);
69
+ onClick === null || onClick === void 0 ? void 0 : onClick(...args);
70
+ }, [onClick, setShow, show]);
71
+ const handleMouseOver = useCallback((...args) => {
72
+ handleMouseOverOut(handleShow, args, 'fromElement');
73
+ }, [handleShow]);
74
+ const handleMouseOut = useCallback((...args) => {
75
+ handleMouseOverOut(handleHide, args, 'toElement');
76
+ }, [handleHide]);
77
+ const [triggerNode, setTriggerNode] = useState(null);
78
+ const [popperElement, setPopperElement] = useState(null);
79
+ const [arrowElement, setArrowElement] = useState(null);
80
+ const [arrowPlacement, setArrowPlacement] = useState(placement);
81
+ const handleClickOutside = useCallback((event) => {
82
+ const isToggleTarget = triggerNode === null || triggerNode === void 0 ? void 0 : triggerNode.contains(event.target);
83
+ const isOverlayTarget = popperElement === null || popperElement === void 0 ? void 0 : popperElement.contains(event.target);
84
+ // Check if the click occurred outside the trigger element. Clicking on the trigger
85
+ // itself is handled by the onClick handler
86
+ if (show && rootClose && !isToggleTarget && !isOverlayTarget) {
87
+ handleHide();
88
+ }
89
+ }, [triggerNode, popperElement, rootClose, handleHide]);
90
+ useClickOutsideWithRef(triggerNode, handleClickOutside);
91
+ const triggerProps = {
92
+ ref: mergeRefs([children.ref, setTriggerNode]),
93
+ };
94
+ if (trigger === 'click') {
95
+ triggerProps.onClick = handleClick;
96
+ }
97
+ else if (trigger === 'focus') {
98
+ triggerProps.onFocus = handleFocus;
99
+ triggerProps.onBlur = handleBlur;
100
+ }
101
+ else if (trigger === 'hover') {
102
+ triggerProps.onMouseOver = handleMouseOver;
103
+ triggerProps.onMouseOut = handleMouseOut;
104
+ }
105
+ const defaultPopperConfig = {
106
+ placement,
107
+ modifiers: [
108
+ {
109
+ name: 'arrow',
110
+ options: {
111
+ element: arrowElement,
112
+ },
113
+ },
114
+ {
115
+ name: 'flip',
116
+ options: {
117
+ fallbackPlacements: ['right', 'left', 'top'],
118
+ },
119
+ },
120
+ ],
121
+ };
122
+ if (popperConfig) {
123
+ popperConfig.placement = placement;
124
+ // if it has an arrow modifier, inject the arrow element
125
+ const updatedModifiers = [];
126
+ (_a = popperConfig.modifiers) === null || _a === void 0 ? void 0 : _a.forEach((mod) => {
127
+ if (mod.name !== 'arrow') {
128
+ return updatedModifiers.push(mod);
129
+ }
130
+ return updatedModifiers.push(Object.assign(Object.assign({}, mod), { options: Object.assign(Object.assign({}, mod.options), { element: arrowElement }) }));
131
+ });
132
+ popperConfig.modifiers = updatedModifiers;
133
+ }
134
+ const popper = usePopper(triggerNode, popperElement, popperConfig || defaultPopperConfig);
135
+ // In case the overlay causes an overflow and the "flip" modifier
136
+ // changes the overlays placement, we nee to update the arrow placement as well
137
+ useEffect(() => {
138
+ if (popper.state) {
139
+ // Adjust arrow styles based on placement if necessary
140
+ setArrowPlacement(popper.state.placement);
141
+ }
142
+ }, [(_b = popper.state) === null || _b === void 0 ? void 0 : _b.placement]);
143
+ const overlayElement = React.cloneElement(overlay, Object.assign(Object.assign({}, popper.attributes.popper), { ref: setPopperElement, placement: arrowPlacement, style: Object.assign({}, popper.styles.popper), arrowProps: Object.assign(Object.assign({}, popper.attributes.arrow), { style: popper.styles.arrow, ref: setArrowElement }) }));
144
+ return (_jsxs(_Fragment, { children: [show && (enablePortal ? ReactDOM.createPortal(overlayElement, document.body) : overlayElement), React.cloneElement(children, triggerProps)] }));
13
145
  };
14
146
  OverlayTrigger.TRIGGER_CLICK = TRIGGER.CLICK;
15
147
  OverlayTrigger.TRIGGER_HOVER = TRIGGER.HOVER;
@@ -1,6 +1,12 @@
1
- import React, { type ReactNode } from 'react';
2
- import type { RefComponent } from '../../utils/RefComponent';
3
- export type PopoverProps = {
1
+ import React, { type ForwardRefExoticComponent, type RefAttributes, type PropsWithChildren, type ReactNode, type ComponentProps } from 'react';
2
+ export declare const PLACEMENT_MAP: {
3
+ readonly AUTO: "auto";
4
+ readonly TOP: "top";
5
+ readonly RIGHT: "right";
6
+ readonly BOTTOM: "bottom";
7
+ readonly LEFT: "left";
8
+ };
9
+ export type PopoverProps = Omit<ComponentProps<'div'>, 'title'> & {
4
10
  /**
5
11
  * HTML ID attribute, necessary for accessibility.
6
12
  */
@@ -18,6 +24,10 @@ export type PopoverProps = {
18
24
  * - `left`
19
25
  */
20
26
  placement?: 'auto' | 'top' | 'right' | 'bottom' | 'left';
27
+ /**
28
+ * Additional props assigned to the arrow element. Internally used.
29
+ */
30
+ arrowProps?: Record<string, unknown>;
21
31
  /**
22
32
  * Any element to be rendered as the title of the Popover.
23
33
  *
@@ -32,12 +42,20 @@ export type PopoverProps = {
32
42
  * Additional classes to be set on the `Popover.Content` element.
33
43
  */
34
44
  contentClassName?: string;
45
+ /**
46
+ * Additional class names for the wrapper element.
47
+ */
48
+ className?: string;
35
49
  };
36
- declare const Popover: RefComponent<React.PropsWithChildren<PopoverProps>, HTMLDivElement> & {
37
- readonly AUTO: "auto";
38
- readonly TOP: "top";
39
- readonly RIGHT: "right";
40
- readonly BOTTOM: "bottom";
41
- readonly LEFT: "left";
50
+ declare const PopoverTitle: ({ className, children }: React.PropsWithChildren<{
51
+ className?: string | undefined;
52
+ }>) => import("react/jsx-runtime").JSX.Element;
53
+ declare const PopoverContent: ({ className, children }: React.PropsWithChildren<{
54
+ className?: string | undefined;
55
+ }>) => import("react/jsx-runtime").JSX.Element;
56
+ type PopoverType = ForwardRefExoticComponent<PropsWithChildren<PopoverProps> & RefAttributes<HTMLDivElement>> & {
57
+ Title: typeof PopoverTitle;
58
+ Content: typeof PopoverContent;
42
59
  };
60
+ declare const Popover: PopoverType;
43
61
  export default Popover;
@@ -1,18 +1,31 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { forwardRef } from 'react';
4
- import { default as RBPopover } from 'react-bootstrap/Popover';
3
+ import React, { forwardRef, isValidElement, useState, useEffect, } from 'react';
4
+ import 'framer-motion';
5
5
  import { PLACEMENT } from '../../values/Placement';
6
- const PLACEMENT_MAP = {
6
+ export const PLACEMENT_MAP = {
7
7
  AUTO: PLACEMENT.AUTO,
8
8
  TOP: PLACEMENT.TOP,
9
9
  RIGHT: PLACEMENT.RIGHT,
10
10
  BOTTOM: PLACEMENT.BOTTOM,
11
11
  LEFT: PLACEMENT.LEFT,
12
12
  };
13
+ const PopoverTitle = ({ className = '', children }) => (_jsx("div", Object.assign({ className: `popover-header popover-title ${className}` }, { children: children })));
14
+ const PopoverContent = ({ className = '', children }) => (_jsx("div", Object.assign({ className: `popover-content popover-body ${className}` }, { children: children })));
15
+ const isPopoverTitleOrContent = (element) => {
16
+ return isValidElement(element) && (element.type === PopoverTitle || element.type === PopoverContent);
17
+ };
13
18
  const Popover = forwardRef((props, ref) => {
14
- const { title, titleClassName = '', contentClassName = '', children } = props, remainingProps = __rest(props, ["title", "titleClassName", "contentClassName", "children"]);
15
- return (_jsxs(RBPopover, Object.assign({ ref: ref }, remainingProps, { children: [title && _jsx(RBPopover.Title, Object.assign({ className: `popover-title ${titleClassName}` }, { children: title })), children && (_jsx(RBPopover.Content, Object.assign({ className: `popover-content ${contentClassName}` }, { children: children })))] })));
19
+ const { placement = 'bottom', arrowProps, title, titleClassName = '', contentClassName = '', children, className = '' } = props, remainingProps = __rest(props, ["placement", "arrowProps", "title", "titleClassName", "contentClassName", "children", "className"]);
20
+ const hasTitle = !!title;
21
+ const hasCustomContent = React.Children.toArray(children).some(isPopoverTitleOrContent);
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] = useState(false);
25
+ useEffect(() => setIsMounted(true), []);
26
+ return (_jsxs("div", Object.assign({}, remainingProps, { role: 'tooltip', "x-placement": placement, ref: ref, className: `popover fade ${isMounted ? 'show' : ''} ${className}` }, { children: [_jsx("div", Object.assign({ className: 'arrow' }, arrowProps)), hasTitle && _jsx(PopoverTitle, Object.assign({ className: titleClassName }, { children: title })), hasCustomContent ? children : _jsx(PopoverContent, Object.assign({ className: contentClassName }, { children: children }))] })));
16
27
  });
28
+ Popover.Title = PopoverTitle;
29
+ Popover.Content = PopoverContent;
17
30
  Object.assign(Popover, PLACEMENT_MAP);
18
31
  export default Popover;
@@ -36,6 +36,7 @@ export type SelectOption = {
36
36
  export type BaseSelectDropdownProps<T extends SelectOption> = {
37
37
  options?: T[];
38
38
  isOpen?: boolean;
39
+ isLoading?: boolean;
39
40
  updateDOMValues?: (values: OptionDOMValue[] | undefined) => void;
40
41
  onOpen?: (hasDropup: boolean) => void;
41
42
  onSelect?: (selectedItem: T | undefined) => void;
@@ -10,11 +10,12 @@ import useEffectOnce from '../../hooks/useEffectOnce';
10
10
  import useKey from '../../useKey';
11
11
  import DropdownHeader from './DropdownHeader';
12
12
  import NoItemMessage from './NoItemMessage';
13
+ import Spinner from '../spinner/Spinner';
13
14
  const DATA_ATTRIBUTE_ID = 'data-item-id';
14
15
  const DEFAULT_FOCUSED_ITEM_INDEX = 0;
15
16
  const HIGHLIGHT_CLASS = 'focus';
16
17
  const BaseSelectDropdown = (props) => {
17
- const { isOpen = false, updateDOMValues = noop, onOpen = noop, onSelect = noop, onClose = noop, options = [], autoDropDirection = true, dropup = false, pullRight = false, useActiveClass = false, focusedItemIndex: externalFocusedItemIndex, keyboardUsed: externalKeyboardUsed, noItemMessage, dropdownClassName, } = props;
18
+ const { isOpen = false, isLoading = false, updateDOMValues = noop, onOpen = noop, onSelect = noop, onClose = noop, options = [], autoDropDirection = true, dropup = false, pullRight = false, useActiveClass = false, focusedItemIndex: externalFocusedItemIndex, keyboardUsed: externalKeyboardUsed, noItemMessage, dropdownClassName, } = props;
18
19
  const [focusedItemIndex, setFocusedItemIndex] = useState(externalFocusedItemIndex || DEFAULT_FOCUSED_ITEM_INDEX);
19
20
  const [keyboardUsed, setKeyboardUsed] = useState(externalKeyboardUsed);
20
21
  const dropdownMenuRef = useRef(null);
@@ -150,19 +151,20 @@ const BaseSelectDropdown = (props) => {
150
151
  if (isEmpty(options)) {
151
152
  return _jsx(NoItemMessage, { noItemMessage: noItemMessage, className: dropdownMenuClasses });
152
153
  }
153
- return (_jsx("ul", Object.assign({ className: dropdownMenuClasses, ref: dropdownMenuRef, role: 'menu' }, { children: options.map((option, index) => {
154
- if (option.header) {
155
- return _jsx(DropdownHeader, { icon: option.icon, label: option.label }, option.id);
156
- }
157
- // Show focused style only when keyboard is in use
158
- const anchorClassNames = classNames('display-flex align-items-center', keyboardUsed && focusedItemIndex === index ? HIGHLIGHT_CLASS : '', option.disabled && 'pointer-events-none');
159
- const wrapperClassNames = classNames(option.disabled && 'disabled', useActiveClass && option.selected && 'active');
160
- return (_jsx("li", Object.assign({ className: wrapperClassNames, role: 'listitem' }, { children: _jsxs("a", Object.assign({ role: 'menuitem', className: anchorClassNames, "data-item-id": option.id, "data-item-index": index,
161
- // Note, we need to assign the click callback only when it's not disabled
162
- // otherwise the functions is still triggered
163
- // biome-ignore lint/a11y/useValidAnchor: due to old structure and backwards compatibility
164
- onClick: option.disabled ? undefined : handleOptionChange }, { children: [_jsxs("span", { children: [option.icon && _jsx("span", Object.assign({ className: 'margin-right-5' }, { children: option.icon })), option.label] }), _jsx("input", { type: 'hidden', value: option.id })] })) }), option.id));
165
- }) })));
154
+ return (_jsxs("ul", Object.assign({ className: dropdownMenuClasses, ref: dropdownMenuRef, role: 'menu' }, { children: [isLoading && (_jsx("div", Object.assign({ className: 'display-flex justify-content-center padding-10' }, { children: _jsx(Spinner, {}) }))), !isLoading &&
155
+ options.map((option, index) => {
156
+ if (option.header) {
157
+ return _jsx(DropdownHeader, { icon: option.icon, label: option.label }, option.id);
158
+ }
159
+ // Show focused style only when keyboard is in use
160
+ const anchorClassNames = classNames('display-flex align-items-center', keyboardUsed && focusedItemIndex === index ? HIGHLIGHT_CLASS : '', option.disabled && 'pointer-events-none');
161
+ const wrapperClassNames = classNames(option.disabled && 'disabled', useActiveClass && option.selected && 'active');
162
+ return (_jsx("li", Object.assign({ className: wrapperClassNames, role: 'listitem' }, { children: _jsxs("a", Object.assign({ role: 'menuitem', className: anchorClassNames, "data-item-id": option.id, "data-item-index": index,
163
+ // Note, we need to assign the click callback only when it's not disabled
164
+ // otherwise the functions is still triggered
165
+ // biome-ignore lint/a11y/useValidAnchor: due to old structure + backwards compatibility
166
+ onClick: option.disabled ? undefined : handleOptionChange }, { children: [_jsxs("span", { children: [option.icon && _jsx("span", Object.assign({ className: 'margin-right-5' }, { children: option.icon })), option.label] }), _jsx("input", { type: 'hidden', value: option.id })] })) }), option.id));
167
+ })] })));
166
168
  };
167
169
  export const filterOptions = (itemDOMValues, filterValue, options) => {
168
170
  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
  *
@@ -16,7 +16,7 @@ import useMergeRefs from '../../hooks/useMergeRefs';
16
16
  import WithFeedbackAndAddon from './WithFeedbackAndAddon';
17
17
  const DEFAULT_FOCUSED_ITEM_INDEX = -1;
18
18
  const Multiselect = (props) => {
19
- const { name, id = name, options = [], value, onChange = noop, 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 = __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"]);
19
+ const { name, id = name, options = [], value, onChange = noop, 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 = __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"]);
20
20
  const [isOpen, setIsOpen] = useState(false);
21
21
  const [selectedItemIds, setSelectedItemIds] = useState(value || []);
22
22
  const [isFilterActive, setIsFilterActive] = useState(false);
@@ -86,7 +86,7 @@ const Multiselect = (props) => {
86
86
  option.selected = selectedItemIds.indexOf(option.id) !== -1;
87
87
  return option;
88
88
  });
89
- return (_jsx(BaseSelectDropdown, { 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 }));
89
+ return (_jsx(BaseSelectDropdown, { 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 }));
90
90
  };
91
91
  const handleFilterChange = (event) => {
92
92
  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
  */
@@ -15,7 +15,7 @@ import SelectedOption from './SelectedOption';
15
15
  import WithFeedbackAndAddon from './WithFeedbackAndAddon';
16
16
  const DEFAULT_FOCUSED_ITEM_INDEX = -1;
17
17
  const Select = (props) => {
18
- const { name, id = name, label, options = [], value, onChange = noop, 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 = __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"]);
18
+ const { name, id = name, label, options = [], value, onChange = noop, 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 = __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"]);
19
19
  const [isOpen, setIsOpen] = useState(false);
20
20
  const [selectedItem, setSelectedItem] = useState(null);
21
21
  const [isFilterActive, setIsFilterActive] = useState(false);
@@ -82,7 +82,7 @@ const Select = (props) => {
82
82
  else if (keyboardUsed) {
83
83
  currentFocusedItemIndex = 0;
84
84
  }
85
- return (_jsx(BaseSelectDropdown, { 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 }));
85
+ return (_jsx(BaseSelectDropdown, { 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 }));
86
86
  };
87
87
  const handleFilterChange = (event) => {
88
88
  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
  *
@@ -3,13 +3,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useState } from 'react';
4
4
  import classNames from 'classnames';
5
5
  import noop from 'lodash/noop';
6
+ import { getCurrentBackgroundColor } from '../../utils/currentColors';
6
7
  const getRangeValues = (valueLeft, valueRight) => {
7
8
  const finalLeftValue = valueRight <= valueLeft ? valueRight : valueLeft;
8
9
  const finalRightValue = valueLeft >= valueRight ? valueLeft : valueRight;
9
10
  return [finalLeftValue, finalRightValue];
10
11
  };
11
12
  const RangeSlider = (props) => {
12
- const { minValue = 0, maxValue = Number.MAX_VALUE, valueLabels = false, valueLabelUnit, step = 1, leftValue, rightValue, className, disabled = false, onChange = noop, onDragEnd = noop } = props, remainingProps = __rest(props, ["minValue", "maxValue", "valueLabels", "valueLabelUnit", "step", "leftValue", "rightValue", "className", "disabled", "onChange", "onDragEnd"]);
13
+ const { minValue = 0, maxValue = Number.MAX_VALUE, valueLabels = false, valueLabelUnit, step = 1, color = 'primary', leftValue, rightValue, className, disabled = false, onChange = noop, onDragEnd = noop } = props, remainingProps = __rest(props, ["minValue", "maxValue", "valueLabels", "valueLabelUnit", "step", "color", "leftValue", "rightValue", "className", "disabled", "onChange", "onDragEnd"]);
13
14
  const [activeLeft, setActiveLeft] = useState(false);
14
15
  const [activeRight, setActiveRight] = useState(false);
15
16
  const [valueLeft, setValueLeft] = useState(leftValue ? leftValue : minValue);
@@ -32,8 +33,12 @@ const RangeSlider = (props) => {
32
33
  const [newLeftValue, newRightValue] = getRangeValues(newValueLeft, newValueRight);
33
34
  onChange(newLeftValue, newRightValue);
34
35
  };
35
- const handleChangeValueLeft = (event) => changeValues({ valueLeft: parseInt(event.target.value, 10) });
36
- const handleChangeValueRight = (event) => changeValues({ valueRight: parseInt(event.target.value, 10) });
36
+ const handleChangeValueLeft = (event) => {
37
+ changeValues({ valueLeft: Number.parseInt(event.target.value, 10) });
38
+ };
39
+ const handleChangeValueRight = (event) => {
40
+ changeValues({ valueRight: Number.parseInt(event.target.value, 10) });
41
+ };
37
42
  const onMouseDownLeft = () => {
38
43
  setIsChangingLeft(true);
39
44
  setIsChangingRight(false);
@@ -98,6 +103,7 @@ const RangeSlider = (props) => {
98
103
  const trackWidth = (100 * (finalRightValue - finalLeftValue)) / (maxValue - minValue);
99
104
  const trackLeft = (100 * (finalLeftValue - minValue)) / (maxValue - minValue);
100
105
  const wrapperClassNames = classNames('range-slider', disabled && 'disabled', valueLabels && 'show-value-labels', className && className);
101
- return (_jsxs("div", Object.assign({}, remainingProps, { className: wrapperClassNames }, { children: [_jsx("div", { className: 'range-whole-track' }), _jsx("div", Object.assign({ className: 'range-track', style: { width: `${trackWidth}%`, left: `${trackLeft}%` } }, { children: valueLabels && (_jsxs("div", Object.assign({ className: 'user-select-none' }, { children: [_jsx("div", Object.assign({ className: 'range-value' }, { children: valueLabelUnit ? `${finalLeftValue} ${valueLabelUnit}` : finalLeftValue })), _jsx("div", Object.assign({ className: 'range-value' }, { children: valueLabelUnit ? `${finalRightValue} ${valueLabelUnit}` : finalRightValue }))] }))) })), _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 }), _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 })] })));
106
+ const sliderBackgroundColor = getCurrentBackgroundColor(color);
107
+ return (_jsxs("div", Object.assign({}, remainingProps, { className: wrapperClassNames, style: { color: sliderBackgroundColor } }, { children: [_jsx("div", { className: 'range-whole-track' }), _jsx("div", Object.assign({ className: 'range-track', style: { width: `${trackWidth}%`, left: `${trackLeft}%` } }, { children: valueLabels && (_jsxs("div", Object.assign({ className: 'user-select-none' }, { children: [_jsx("div", Object.assign({ className: 'range-value' }, { children: _jsx("span", { children: valueLabelUnit ? `${finalLeftValue} ${valueLabelUnit}` : finalLeftValue }) })), _jsx("div", Object.assign({ className: 'range-value' }, { children: _jsx("span", { children: valueLabelUnit ? `${finalRightValue} ${valueLabelUnit}` : finalRightValue }) }))] }))) })), _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 }), _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 })] })));
102
108
  };
103
109
  export 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
  *
@@ -3,8 +3,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useState } from 'react';
4
4
  import classNames from 'classnames';
5
5
  import noop from 'lodash/noop';
6
+ import { getCurrentBackgroundColor } from '../../utils/currentColors';
6
7
  const Slider = (props) => {
7
- const { value = 0, minValue = 0, maxValue = Number.MAX_VALUE, valueLabels = false, valueLabelUnit, largeValueLabels = false, hideValueBar = false, step = 1, onChange = noop, onDragEnd = noop, className, disabled = false } = props, remainingProps = __rest(props, ["value", "minValue", "maxValue", "valueLabels", "valueLabelUnit", "largeValueLabels", "hideValueBar", "step", "onChange", "onDragEnd", "className", "disabled"]);
8
+ const { value = 0, minValue = 0, maxValue = Number.MAX_VALUE, valueLabels = false, valueLabelUnit, largeValueLabels = false, hideValueBar = false, color = 'primary', step = 1, onChange = noop, onDragEnd = noop, className, disabled = false } = props, remainingProps = __rest(props, ["value", "minValue", "maxValue", "valueLabels", "valueLabelUnit", "largeValueLabels", "hideValueBar", "color", "step", "onChange", "onDragEnd", "className", "disabled"]);
8
9
  const [currentValue, setCurrentValue] = useState(value ? value : minValue);
9
10
  const [isChanging, setIsChanging] = useState(false);
10
11
  useEffect(() => {
@@ -13,7 +14,7 @@ const Slider = (props) => {
13
14
  }
14
15
  }, [value, minValue, maxValue]);
15
16
  const handleChange = (event) => {
16
- const newValue = parseInt(event.target.value, 10);
17
+ const newValue = Number.parseInt(event.target.value, 10);
17
18
  setCurrentValue(newValue);
18
19
  setIsChanging(true);
19
20
  onChange(newValue);
@@ -27,6 +28,7 @@ const Slider = (props) => {
27
28
  };
28
29
  const wrapperClassNames = classNames('range-slider', disabled && 'disabled', valueLabels && 'show-value-labels', hideValueBar && 'hide-value-bar', largeValueLabels && 'large-value-labels', className && className);
29
30
  const trackWidth = (100 * (currentValue - minValue)) / (maxValue - minValue);
30
- return (_jsxs("div", Object.assign({}, remainingProps, { className: wrapperClassNames }, { children: [_jsx("div", { className: 'range-whole-track' }), _jsx("div", Object.assign({ className: 'range-track', style: { width: `${trackWidth}%` } }, { children: valueLabels && (_jsx("div", Object.assign({ className: 'range-value' }, { children: _jsx("div", { children: valueLabelUnit ? `${currentValue} ${valueLabelUnit}` : currentValue }) }))) })), _jsx("input", { className: `${isChanging ? 'changing' : ''}`, value: currentValue, min: minValue, max: maxValue, step: step, type: 'range', onChange: handleChange, onMouseDown: onMouseDown, onMouseUp: onMouseUp })] })));
31
+ const sliderBackgroundColor = getCurrentBackgroundColor(color);
32
+ return (_jsxs("div", Object.assign({}, remainingProps, { className: wrapperClassNames, style: { color: sliderBackgroundColor } }, { children: [_jsx("div", { className: 'range-whole-track' }), _jsx("div", Object.assign({ className: 'range-track', style: { width: `${trackWidth}%` } }, { children: valueLabels && (_jsx("div", Object.assign({ className: 'range-value' }, { children: _jsx("span", { children: valueLabelUnit ? `${currentValue} ${valueLabelUnit}` : currentValue }) }))) })), _jsx("input", { className: `${isChanging ? 'changing' : ''}`, value: currentValue, min: minValue, max: maxValue, step: step, type: 'range', onChange: handleChange, onMouseDown: onMouseDown, onMouseUp: onMouseUp })] })));
31
33
  };
32
34
  export default Slider;
@@ -6,6 +6,7 @@ import classNames from 'classnames';
6
6
  import isEmpty from 'lodash/fp/isEmpty';
7
7
  import StateButton from './StateButton';
8
8
  import StateIcon from './StateIcon';
9
+ import { hasPaddingClass } from '../../utils/hasUtilityClass';
9
10
  const justify = {
10
11
  left: 'justify-content-start',
11
12
  center: 'justify-content-center',
@@ -26,11 +27,9 @@ const renderButtons = (buttons) => {
26
27
  }) }))] }));
27
28
  };
28
29
  const CustomState = (props) => {
29
- const { icon, icons = [], image, headline, message, buttons = [], alignment = 'center', fullWidth = false, condensed = false, outerClassName, innerClassName, children } = props, remainingProps = __rest(props, ["icon", "icons", "image", "headline", "message", "buttons", "alignment", "fullWidth", "condensed", "outerClassName", "innerClassName", "children"]);
30
- const hasCustomInnerPadding = innerClassName === null || innerClassName === void 0 ? void 0 : innerClassName.includes('padding');
31
- const hasCustomOuterPadding = outerClassName === null || outerClassName === void 0 ? void 0 : outerClassName.includes('padding');
32
- const wrapperClasses = classNames('margin-0', 'width-100pct', !fullWidth && 'max-width-600', 'panel-default', 'panel', !hasCustomOuterPadding && condensed ? 'padding-10' : 'padding-15', outerClassName && outerClassName);
33
- const innerClassNames = classNames('display-flex', 'flex-column', 'align-items-center', 'text-center', !hasCustomInnerPadding && condensed ? 'padding-15' : 'padding-25', innerClassName && innerClassName);
30
+ const { icon, icons = [], image, headline, message, buttons = [], alignment = 'center', fullWidth = false, condensed = false, outerClassName = '', innerClassName = '', children } = props, remainingProps = __rest(props, ["icon", "icons", "image", "headline", "message", "buttons", "alignment", "fullWidth", "condensed", "outerClassName", "innerClassName", "children"]);
31
+ const wrapperClasses = classNames('margin-0', 'width-100pct', !fullWidth && 'max-width-600', 'panel-default', 'panel', !hasPaddingClass(outerClassName) && condensed ? 'padding-10' : 'padding-15', outerClassName);
32
+ const innerClassNames = classNames('display-flex', 'flex-column', 'align-items-center', 'text-center', !hasPaddingClass(innerClassName) && condensed ? 'padding-15' : 'padding-25', innerClassName);
34
33
  const iconClasses = classNames(condensed ? 'text-size-16 margin-bottom-10' : 'text-size-h2 margin-bottom-20');
35
34
  const iconsClasses = classNames(condensed ? 'text-size-16 margin-bottom-10' : 'text-size-h2 margin-bottom-20', 'display-flex', 'align-items-center', 'max-width-100pct');
36
35
  const headlineClassNames = classNames(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
  */
@@ -4,8 +4,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  import 'react';
5
5
  import classNames from 'classnames';
6
6
  import noop from 'lodash/fp/noop';
7
+ import { getCurrentBackgroundColor } from '../../utils/currentColors';
7
8
  const Switch = (props) => {
8
- const { keyName, checked = false, enabledText, minWidth = 40, disabled = false, disabledText, children, labelPosition = !!children ? 'right' : undefined, onChange = noop } = props, remainingProps = __rest(props, ["keyName", "checked", "enabledText", "minWidth", "disabled", "disabledText", "children", "labelPosition", "onChange"]);
9
+ const { keyName, checked = false, enabledText, minWidth = 40, disabled = false, color = 'primary', disabledText, children, labelPosition = !!children ? 'right' : undefined, onChange = noop } = props, remainingProps = __rest(props, ["keyName", "checked", "enabledText", "minWidth", "disabled", "color", "disabledText", "children", "labelPosition", "onChange"]);
9
10
  const handleChange = (event) => {
10
11
  onChange(event.target.checked);
11
12
  };
@@ -15,8 +16,8 @@ const Switch = (props) => {
15
16
  const switchContentClasses = classNames('switch-content'
16
17
  // !hasMultipleText && !hasSingleText && 'width-40'
17
18
  );
18
- const switchContentStyles = { minWidth };
19
- return (_jsx("div", Object.assign({}, remainingProps, { className: 'uikit-switch' }, { children: _jsxs("label", Object.assign({ className: switchLabelClasses }, { children: [_jsx("input", { onChange: handleChange, checked: checked, type: 'checkbox', id: keyName, className: 'switch-input', disabled: disabled }, keyName), _jsxs("div", Object.assign({ className: switchContentClasses, style: switchContentStyles }, { children: [hasMultipleText ? (_jsx("div", { className: 'switch-text', "data-on": enabledText, "data-off": disabledText })) : (hasSingleText && _jsx("div", { className: 'switch-text', "data-on": enabledText, "data-off": enabledText })), _jsx("div", { className: 'switch-handle' })] })), children && children] })) })));
19
+ const switchBackgroundColor = getCurrentBackgroundColor(color);
20
+ return (_jsx("div", Object.assign({}, remainingProps, { className: 'uikit-switch' }, { children: _jsxs("label", Object.assign({ className: switchLabelClasses }, { children: [_jsx("input", { onChange: handleChange, checked: checked, type: 'checkbox', id: keyName, className: 'switch-input', disabled: disabled }, keyName), _jsxs("div", Object.assign({ className: switchContentClasses, style: { color: switchBackgroundColor, minWidth } }, { children: [hasMultipleText ? (_jsx("div", { className: 'switch-text', "data-on": enabledText, "data-off": disabledText })) : (hasSingleText && _jsx("div", { className: 'switch-text', "data-on": enabledText, "data-off": enabledText })), _jsx("div", { className: 'switch-handle' })] })), children && children] })) })));
20
21
  };
21
22
  Switch.LABEL_POSITION_LEFT = 'left';
22
23
  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
  */