@rio-cloud/rio-uikit 1.2.2 → 1.3.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.
- package/.DS_Store +0 -0
- package/DateRangePicker.d.ts +6 -7
- package/DateRangePicker.js +7 -3
- package/README.md +3 -3
- package/components/actionBarItem/ActionBarItem.js +5 -1
- package/components/actionBarItem/ActionBarItemIcon.d.ts +6 -8
- package/components/actionBarItem/ActionBarItemIcon.js +4 -4
- package/components/actionBarItem/ActionBarOverlay.d.ts +3 -2
- package/components/actionBarItem/ActionBarOverlay.js +7 -7
- package/components/applicationLayout/ApplicationLayout.js +1 -0
- package/components/applicationLayout/ApplicationLayoutHeader.js +0 -4
- package/components/assetTree/TreeOptions.js +1 -1
- package/components/assetTree/treeUtils.js +1 -1
- package/components/calendarStripe/CalendarStripe.d.ts +8 -0
- package/components/calendarStripe/CalendarStripe.js +7 -4
- package/components/dataTabs/DataTab.js +2 -1
- package/components/dialog/SimpleDialog.d.ts +2 -2
- package/components/dialog/SplitDialog.d.ts +6 -0
- package/components/expander/ExpanderList.js +2 -1
- package/components/listMenu/ListMenu.js +1 -1
- package/components/onboarding/OnboardingTip.d.ts +2 -2
- package/components/onboarding/OnboardingTip.js +2 -0
- package/components/overlay/OverlayTrigger.d.ts +92 -3
- package/components/overlay/OverlayTrigger.js +140 -8
- package/components/popover/Popover.d.ts +27 -9
- package/components/popover/Popover.js +18 -5
- package/components/slider/RangeSlider.d.ts +7 -0
- package/components/slider/RangeSlider.js +10 -4
- package/components/slider/Slider.d.ts +7 -0
- package/components/slider/Slider.js +5 -3
- package/components/states/CustomState.js +4 -5
- package/components/switch/Switch.d.ts +7 -0
- package/components/switch/Switch.js +4 -3
- package/components/tooltip/SimpleTooltip.d.ts +2 -2
- package/components/tooltip/Tooltip.d.ts +2 -2
- package/components/tooltip/Tooltip.js +6 -2
- package/hooks/useClickOutside.d.ts +1 -0
- package/hooks/useClickOutside.js +9 -3
- package/hooks/useElapsedTime.d.ts +26 -0
- package/hooks/useElapsedTime.js +36 -0
- package/hooks/useEvent.d.ts +1 -1
- package/hooks/useTimeout.d.ts +5 -0
- package/hooks/useTimeout.js +39 -1
- package/hooks/useUncontrollable.d.ts +13 -0
- package/hooks/useUncontrollable.js +41 -0
- package/lib/es/DateRangePicker.d.ts +6 -7
- package/lib/es/DateRangePicker.js +5 -1
- package/lib/es/components/actionBarItem/ActionBarItem.js +5 -1
- package/lib/es/components/actionBarItem/ActionBarItemIcon.d.ts +6 -8
- package/lib/es/components/actionBarItem/ActionBarItemIcon.js +4 -4
- package/lib/es/components/actionBarItem/ActionBarOverlay.d.ts +3 -2
- package/lib/es/components/actionBarItem/ActionBarOverlay.js +7 -7
- package/lib/es/components/applicationLayout/ApplicationLayout.js +1 -0
- package/lib/es/components/applicationLayout/ApplicationLayoutHeader.js +0 -4
- package/lib/es/components/assetTree/TreeOptions.js +1 -1
- package/lib/es/components/assetTree/treeUtils.js +1 -1
- package/lib/es/components/calendarStripe/CalendarStripe.d.ts +8 -0
- package/lib/es/components/calendarStripe/CalendarStripe.js +7 -4
- package/lib/es/components/dataTabs/DataTab.js +2 -1
- package/lib/es/components/dialog/SimpleDialog.d.ts +2 -2
- package/lib/es/components/dialog/SplitDialog.d.ts +6 -0
- package/lib/es/components/expander/ExpanderList.js +2 -1
- package/lib/es/components/listMenu/ListMenu.js +1 -1
- package/lib/es/components/onboarding/OnboardingTip.d.ts +2 -2
- package/lib/es/components/onboarding/OnboardingTip.js +2 -0
- package/lib/es/components/overlay/OverlayTrigger.d.ts +92 -3
- package/lib/es/components/overlay/OverlayTrigger.js +139 -7
- package/lib/es/components/popover/Popover.d.ts +27 -9
- package/lib/es/components/popover/Popover.js +20 -6
- package/lib/es/components/slider/RangeSlider.d.ts +7 -0
- package/lib/es/components/slider/RangeSlider.js +10 -4
- package/lib/es/components/slider/Slider.d.ts +7 -0
- package/lib/es/components/slider/Slider.js +5 -3
- package/lib/es/components/states/CustomState.js +4 -5
- package/lib/es/components/switch/Switch.d.ts +7 -0
- package/lib/es/components/switch/Switch.js +4 -3
- package/lib/es/components/tooltip/SimpleTooltip.d.ts +2 -2
- package/lib/es/components/tooltip/Tooltip.d.ts +2 -2
- package/lib/es/components/tooltip/Tooltip.js +5 -1
- package/lib/es/hooks/useClickOutside.d.ts +1 -0
- package/lib/es/hooks/useClickOutside.js +11 -3
- package/lib/es/hooks/useElapsedTime.d.ts +26 -0
- package/lib/es/hooks/useElapsedTime.js +38 -0
- package/lib/es/hooks/useEvent.d.ts +1 -1
- package/lib/es/hooks/useTimeout.d.ts +5 -0
- package/lib/es/hooks/useTimeout.js +40 -0
- package/lib/es/hooks/useUncontrollable.d.ts +13 -0
- package/lib/es/hooks/useUncontrollable.js +46 -0
- package/lib/es/styles/variables/colors/colors.json +3 -3
- package/lib/es/useElapsedTime.d.ts +2 -0
- package/lib/es/useElapsedTime.js +7 -0
- package/lib/es/utils/currentColors.d.ts +3 -0
- package/lib/es/utils/currentColors.js +14 -0
- package/lib/es/utils/hasUtilityClass.d.ts +30 -0
- package/lib/es/utils/hasUtilityClass.js +71 -0
- package/lib/es/utils/init/initCSS.js +12 -0
- package/lib/es/utils/mergeRefs.d.ts +1 -1
- package/lib/es/values/Trigger.d.ts +1 -2
- package/lib/es/version.json +1 -1
- package/package.json +18 -12
- package/styles/variables/colors/colors.json +3 -3
- package/useElapsedTime.d.ts +2 -0
- package/useElapsedTime.js +2 -0
- package/utils/currentColors.d.ts +3 -0
- package/utils/currentColors.js +10 -0
- package/utils/hasUtilityClass.d.ts +30 -0
- package/utils/hasUtilityClass.js +40 -0
- package/utils/init/initCSS.js +12 -0
- package/utils/mergeRefs.d.ts +1 -1
- package/values/Trigger.d.ts +1 -2
- package/version.json +1 -1
- package/components/.DS_Store +0 -0
- package/components/feedback/Feedback.d.ts +0 -2
- package/components/feedback/Feedback.js +0 -5
- package/components/map/.DS_Store +0 -0
- package/components/map/components/.DS_Store +0 -0
- package/lib/.DS_Store +0 -0
- package/lib/es/.DS_Store +0 -0
- package/lib/es/components/.DS_Store +0 -0
- package/lib/es/components/feedback/Feedback.d.ts +0 -2
- package/lib/es/components/feedback/Feedback.js +0 -7
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import React, { type ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
|
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
|
-
|
|
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;
|
|
@@ -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) =>
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
31
|
-
const
|
|
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
|
|
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:
|
|
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
|
|
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?:
|
|
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
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef, } from 'react';
|
|
3
|
+
import { useEffect, useState, forwardRef, } from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import omit from 'lodash/fp/omit';
|
|
6
6
|
import { isDesktop } from '../../utils/deviceUtils';
|
|
@@ -17,13 +17,17 @@ const TEXT_ALIGNMENT_MAP = {
|
|
|
17
17
|
};
|
|
18
18
|
const Tooltip = forwardRef((props, ref) => {
|
|
19
19
|
const _a = omit(['popper', 'positionLeft', 'positionTop'], props), { allowOnTouch = false, arrowProps, children, className = '', innerClassName = '', placement = 'bottom', style, textAlignment = 'center', tooltipStyle = 'default', width = 'auto' } = _a, remainingProps = __rest(_a, ["allowOnTouch", "arrowProps", "children", "className", "innerClassName", "placement", "style", "textAlignment", "tooltipStyle", "width"]);
|
|
20
|
+
// Mount the component but don't show it yet via CSS.
|
|
21
|
+
// After it is mounted, we set the visibility class to use CSS animation
|
|
22
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
23
|
+
useEffect(() => setIsMounted(true), []);
|
|
20
24
|
if (!isDesktop() && !allowOnTouch) {
|
|
21
25
|
// Workaround: we have to return a DOM node as otherwise the
|
|
22
26
|
// react-transition library would throw an error on mobile
|
|
23
27
|
// when triggering a browser reflow and accessing the node directly.
|
|
24
28
|
return _jsx("span", { className: 'display-none' });
|
|
25
29
|
}
|
|
26
|
-
const wrapperClasses = classNames('tooltip', tooltipStyle && `tooltip-${tooltipStyle}`, placement, className);
|
|
30
|
+
const wrapperClasses = classNames('tooltip', tooltipStyle && `tooltip-${tooltipStyle}`, placement, 'fade', isMounted && 'show', className);
|
|
27
31
|
const innerClasses = classNames('tooltip-inner', textAlignment && `text-${textAlignment}`, width && `width-${width}`, innerClassName && innerClassName);
|
|
28
32
|
/* eslint-disable react/no-unknown-property */
|
|
29
33
|
return (_jsxs("div", Object.assign({}, remainingProps, { role: 'tooltip', "x-placement": placement, ref: ref, className: wrapperClasses, style: Object.assign({}, style), "data-offset": 20 }, { children: [_jsx("div", Object.assign({ className: 'tooltip-arrow' }, arrowProps)), _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;
|
package/hooks/useClickOutside.js
CHANGED
|
@@ -12,10 +12,17 @@ import { useEffect, useRef } from 'react';
|
|
|
12
12
|
*/
|
|
13
13
|
const useClickOutside = (callback, events = ['mousedown', 'touchstart']) => {
|
|
14
14
|
const targetRef = useRef(null);
|
|
15
|
+
useClickOutsideWithRef(targetRef, callback, events);
|
|
16
|
+
return targetRef;
|
|
17
|
+
};
|
|
18
|
+
// Internal use for now - extend it later to be used outside
|
|
19
|
+
export const useClickOutsideWithRef = (ref, callback, events = ['mousedown', 'touchstart']) => {
|
|
15
20
|
useEffect(() => {
|
|
21
|
+
// In case the ref is actually a state and will be set via the state setter function
|
|
22
|
+
const element = ref && 'current' in ref ? ref.current : ref;
|
|
16
23
|
// Event listener function to check if the click is outside the target element
|
|
17
24
|
const listener = (event) => {
|
|
18
|
-
if (
|
|
25
|
+
if (element && !element.contains(event.target)) {
|
|
19
26
|
callback(event);
|
|
20
27
|
}
|
|
21
28
|
};
|
|
@@ -25,7 +32,6 @@ const useClickOutside = (callback, events = ['mousedown', 'touchstart']) => {
|
|
|
25
32
|
return () => {
|
|
26
33
|
events.forEach(eventType => document.removeEventListener(eventType, listener));
|
|
27
34
|
};
|
|
28
|
-
}, [
|
|
29
|
-
return targetRef;
|
|
35
|
+
}, [ref, callback, events]);
|
|
30
36
|
};
|
|
31
37
|
export 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,36 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Custom React hook to measure the elapsed time since a specified start time or the component's mount time.
|
|
4
|
+
*
|
|
5
|
+
* @param {number} [startTime=Date.now()] - The start time in milliseconds from which to measure the elapsed time.
|
|
6
|
+
* @returns {Function} A function that returns the elapsed time in milliseconds since the specified start time
|
|
7
|
+
* or the component's mount time.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* import useElapsedTime from '@rio-cloud/rio-uikit/useElapsedTime';
|
|
11
|
+
* import Button from '@rio-cloud/rio-uikit/Button';
|
|
12
|
+
*
|
|
13
|
+
* const MyComponent = () => {
|
|
14
|
+
* const getElapsedTime = useElapsedTime();
|
|
15
|
+
*
|
|
16
|
+
* const handleClick = () => {
|
|
17
|
+
* const elapsedTime = getElapsedTime();
|
|
18
|
+
* console.log(`Elapsed time: ${elapsedTime} ms`);
|
|
19
|
+
* };
|
|
20
|
+
*
|
|
21
|
+
* return (
|
|
22
|
+
* <Button onClick={handleClick}>Get elapsed time</Button>
|
|
23
|
+
* );
|
|
24
|
+
* };
|
|
25
|
+
*/
|
|
26
|
+
const useElapsedTime = (startTime = Date.now()) => {
|
|
27
|
+
const startTimeRef = useRef(startTime);
|
|
28
|
+
const getElapsedTime = () => {
|
|
29
|
+
return Date.now() - startTimeRef.current;
|
|
30
|
+
};
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
startTimeRef.current = startTime;
|
|
33
|
+
}, [startTime]);
|
|
34
|
+
return getElapsedTime;
|
|
35
|
+
};
|
|
36
|
+
export default useElapsedTime;
|
package/hooks/useEvent.d.ts
CHANGED
|
@@ -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?:
|
|
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;
|
package/hooks/useTimeout.d.ts
CHANGED
|
@@ -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;
|
package/hooks/useTimeout.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
1
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
// See www.joshwcomeau.com/snippets/react-hooks/use-timeout/
|
|
3
3
|
/**
|
|
4
4
|
* A custom hook for handling timeout events.
|
|
@@ -31,4 +31,42 @@ const useTimeout = (callback, delay) => {
|
|
|
31
31
|
}, [delay]);
|
|
32
32
|
return timeoutRef;
|
|
33
33
|
};
|
|
34
|
+
export const useChainedTimeout = () => {
|
|
35
|
+
const MAX_DELAY_MS = Math.pow(2, 31) - 1;
|
|
36
|
+
const setChainedTimeout = (ref, fn, timeoutAtMs) => {
|
|
37
|
+
const delayMs = timeoutAtMs - Date.now();
|
|
38
|
+
ref.current =
|
|
39
|
+
delayMs <= MAX_DELAY_MS
|
|
40
|
+
? setTimeout(fn, delayMs)
|
|
41
|
+
: setTimeout(() => setChainedTimeout(ref, fn, timeoutAtMs), MAX_DELAY_MS);
|
|
42
|
+
};
|
|
43
|
+
const handleRef = useRef();
|
|
44
|
+
const { set, clear } = useMemo(() => {
|
|
45
|
+
const clear = () => clearTimeout(handleRef.current);
|
|
46
|
+
const set = (fn, delayMs = 0) => {
|
|
47
|
+
clear();
|
|
48
|
+
if (delayMs <= MAX_DELAY_MS) {
|
|
49
|
+
// For simplicity, if the timeout is short, just set a normal timeout.
|
|
50
|
+
handleRef.current = setTimeout(fn, delayMs);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
setChainedTimeout(handleRef, fn, Date.now() + delayMs);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
set,
|
|
58
|
+
clear,
|
|
59
|
+
};
|
|
60
|
+
}, []);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
return () => {
|
|
63
|
+
clear();
|
|
64
|
+
};
|
|
65
|
+
}, [clear]);
|
|
66
|
+
return {
|
|
67
|
+
set,
|
|
68
|
+
clear,
|
|
69
|
+
handleRef,
|
|
70
|
+
};
|
|
71
|
+
};
|
|
34
72
|
export default useTimeout;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type Handler = (value: any, ...args: any[]) => any;
|
|
2
|
+
export declare function defaultKey(key: string): string;
|
|
3
|
+
declare function useUncontrolledProp<TProp, THandler extends Handler = Handler>(propValue: TProp | undefined, defaultValue: TProp, handler?: THandler): readonly [TProp, THandler];
|
|
4
|
+
declare function useUncontrolledProp<TProp, THandler extends Handler = Handler>(propValue: TProp | undefined, defaultValue?: TProp | undefined, handler?: THandler): readonly [TProp | undefined, (...args: Parameters<THandler>) => ReturnType<THandler> | void];
|
|
5
|
+
export { useUncontrolledProp };
|
|
6
|
+
type FilterFlags<Base, Condition> = {
|
|
7
|
+
[Key in keyof Base]: NonNullable<Base[Key]> extends Condition ? Key : never;
|
|
8
|
+
};
|
|
9
|
+
type AllowedNames<Base, Condition> = FilterFlags<Base, Condition>[keyof Base];
|
|
10
|
+
type ConfigMap<TProps extends object> = {
|
|
11
|
+
[p in keyof TProps]?: AllowedNames<TProps, Function>;
|
|
12
|
+
};
|
|
13
|
+
export declare function useUncontrolled<TProps extends object, TDefaults extends string = never>(props: TProps, config: ConfigMap<TProps>): Omit<TProps, TDefaults>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
/* eslint-disable prefer-arrow/prefer-arrow-functions */
|
|
3
|
+
// forked from https://github.com/jquense/uncontrollable/blob/master/src/index.ts
|
|
4
|
+
import { useCallback, useRef, useState } from 'react';
|
|
5
|
+
export function defaultKey(key) {
|
|
6
|
+
return 'default' + key.charAt(0).toUpperCase() + key.substr(1);
|
|
7
|
+
}
|
|
8
|
+
function useUncontrolledProp(propValue, defaultValue, handler) {
|
|
9
|
+
const wasPropRef = useRef(propValue !== undefined);
|
|
10
|
+
const [stateValue, setState] = useState(defaultValue);
|
|
11
|
+
const isProp = propValue !== undefined;
|
|
12
|
+
const wasProp = wasPropRef.current;
|
|
13
|
+
wasPropRef.current = isProp;
|
|
14
|
+
/**
|
|
15
|
+
* If a prop switches from controlled to Uncontrolled
|
|
16
|
+
* reset its value to the defaultValue
|
|
17
|
+
*/
|
|
18
|
+
if (!isProp && wasProp && stateValue !== defaultValue) {
|
|
19
|
+
setState(defaultValue);
|
|
20
|
+
}
|
|
21
|
+
return [
|
|
22
|
+
isProp ? propValue : stateValue,
|
|
23
|
+
useCallback((...args) => {
|
|
24
|
+
const [value, ...rest] = args;
|
|
25
|
+
const returnValue = handler === null || handler === void 0 ? void 0 : handler(value, ...rest);
|
|
26
|
+
setState(value);
|
|
27
|
+
return returnValue;
|
|
28
|
+
}, [handler]),
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
export { useUncontrolledProp };
|
|
32
|
+
export function useUncontrolled(props, config) {
|
|
33
|
+
return Object.keys(config).reduce((result, fieldName) => {
|
|
34
|
+
const _a = result, _b = defaultKey(fieldName), defaultValue = _a[_b], _c = fieldName, propsValue = _a[_c], rest = __rest(_a, [typeof _b === "symbol" ? _b : _b + "", typeof _c === "symbol" ? _c : _c + ""]);
|
|
35
|
+
// @ts-ignore-next-line
|
|
36
|
+
const handlerName = config[fieldName];
|
|
37
|
+
// @ts-ignore-next-line
|
|
38
|
+
const [value, handler] = useUncontrolledProp(propsValue, defaultValue, props[handlerName]);
|
|
39
|
+
return Object.assign(Object.assign({}, rest), { [fieldName]: value, [handlerName]: handler });
|
|
40
|
+
}, props);
|
|
41
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JSX, PropsWithChildren, ReactNode } from 'react';
|
|
2
2
|
import type { Moment } from 'moment/moment';
|
|
3
|
-
export
|
|
3
|
+
export type DateRangePickerCustomPresets = {
|
|
4
4
|
startValue: Moment;
|
|
5
5
|
endValue: Moment;
|
|
6
6
|
text: string | JSX.Element;
|
|
7
7
|
onSelect?: Function;
|
|
8
|
-
}
|
|
9
|
-
export
|
|
8
|
+
};
|
|
9
|
+
export type DateRangePickerProps = {
|
|
10
10
|
startValue?: Moment;
|
|
11
11
|
endValue?: Moment;
|
|
12
12
|
defaultStartValue?: Moment;
|
|
@@ -34,11 +34,10 @@ export interface DateRangePickerProps {
|
|
|
34
34
|
dropup?: boolean;
|
|
35
35
|
pullRight?: boolean;
|
|
36
36
|
autoDropDirection?: boolean;
|
|
37
|
-
}
|
|
37
|
+
};
|
|
38
38
|
/**
|
|
39
39
|
* Wrapper component for React-Datetime.
|
|
40
40
|
*
|
|
41
41
|
* @deprecated This will be removed from the UIKIT at some time.
|
|
42
42
|
*/
|
|
43
|
-
declare const DateRangePicker:
|
|
44
|
-
export { DateRangePicker };
|
|
43
|
+
export declare const DateRangePicker: (props: PropsWithChildren<DateRangePickerProps>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DateRangePicker = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
6
|
const DateRangePicker_1 = tslib_1.__importDefault(require("./components/datepicker/DateRangePicker"));
|
|
6
7
|
/**
|
|
7
8
|
* Wrapper component for React-Datetime.
|
|
8
9
|
*
|
|
9
10
|
* @deprecated This will be removed from the UIKIT at some time.
|
|
10
11
|
*/
|
|
11
|
-
const DateRangePicker =
|
|
12
|
+
const DateRangePicker = (props) => {
|
|
13
|
+
const { children } = props, remainingProps = tslib_1.__rest(props, ["children"]);
|
|
14
|
+
return (0, jsx_runtime_1.jsx)(DateRangePicker_1.default, Object.assign({}, remainingProps, { children: children }));
|
|
15
|
+
};
|
|
12
16
|
exports.DateRangePicker = DateRangePicker;
|