@rio-cloud/rio-uikit 1.7.1 → 1.9.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/BarList.d.ts +2 -0
- package/BarList.js +2 -0
- package/README.md +4 -0
- package/SaveableDateInput.d.ts +2 -0
- package/SaveableDateInput.js +2 -0
- package/SvgImage.d.ts +2 -0
- package/SvgImage.js +2 -0
- package/TableCol.d.ts +2 -0
- package/TableCol.js +2 -0
- package/TableHead.d.ts +2 -0
- package/TableHead.js +2 -0
- package/components/actionBarItem/ActionBarItemIcon.js +1 -1
- package/components/actionBarItem/ActionBarOverlay.js +1 -1
- package/components/activity/Activity.d.ts +2 -2
- package/components/applicationHeader/CollapsedNavItem.js +1 -0
- package/components/assetTree/Tree.d.ts +20 -0
- package/components/assetTree/Tree.js +75 -38
- package/components/assetTree/TreeLeaf.js +1 -1
- package/components/assetTree/TreeNodeContainer.d.ts +1 -1
- package/components/assetTree/TreeSearch.js +1 -1
- package/components/assetTree/TreeSummary.js +1 -1
- package/components/assetTree/TypeCounter.d.ts +2 -0
- package/components/assetTree/TypeCounter.js +1 -1
- package/components/assetTree/useTreeExpansion.d.ts +4 -0
- package/components/assetTree/useTreeExpansion.js +25 -0
- package/components/assetTree/useTreeHeight.d.ts +1 -0
- package/components/assetTree/useTreeHeight.js +60 -0
- package/components/assetTree/useTreeScrollPosition.d.ts +3 -0
- package/components/assetTree/useTreeScrollPosition.js +19 -0
- package/components/assetTree/useTreeVirtualization.d.ts +17 -0
- package/components/assetTree/useTreeVirtualization.js +71 -0
- package/components/autosuggest/AutoSuggest.js +2 -1
- package/components/barList/BarList.d.ts +97 -0
- package/components/barList/BarList.js +42 -0
- package/components/barList/useSortedBars.d.ts +2 -0
- package/components/barList/useSortedBars.js +14 -0
- package/components/button/ButtonToolbar.d.ts +1 -1
- package/components/button/ButtonToolbar.js +1 -1
- package/components/button/ToggleButton.js +0 -1
- package/components/charts/PieChart.js +1 -1
- package/components/clearableInput/ClearableInput.d.ts +20 -7
- package/components/clearableInput/ClearableInput.js +68 -8
- package/components/dialog/Dialog.js +1 -1
- package/components/dialog/FrameDialog.js +1 -1
- package/components/dropdown/ButtonDropdown.d.ts +11 -3
- package/components/dropdown/ButtonDropdown.js +79 -64
- package/components/dropdown/DropdownToggleButton.d.ts +7 -4
- package/components/dropdown/DropdownToggleButton.js +11 -3
- package/components/formLabel/FormLabel.d.ts +2 -2
- package/components/formLabel/FormLabel.js +1 -1
- package/components/listMenu/ListMenu.js +4 -1
- package/components/map/components/Map.js +21 -6
- package/components/map/components/constants.d.ts +2 -0
- package/components/map/components/constants.js +3 -0
- package/components/map/components/features/basics/InfoBubble.js +1 -1
- package/components/map/components/features/layers/overlayLayers/IncidentsLayer.js +1 -1
- package/components/map/utils/mapTypes.d.ts +5 -0
- package/components/map/utils/rendering.d.ts +5 -2
- package/components/map/utils/rendering.js +46 -39
- package/components/menuItems/MenuItem.js +1 -1
- package/components/notification/Notification.js +1 -1
- package/components/overlay/OverlayTrigger.js +3 -3
- package/components/saveableInput/SaveableDateInput.d.ts +83 -0
- package/components/saveableInput/SaveableDateInput.js +122 -0
- package/components/selects/BaseSelectDropdown.js +1 -1
- package/components/selects/Multiselect.d.ts +8 -0
- package/components/selects/Multiselect.js +4 -4
- package/components/smoothScrollbars/SmoothScrollbars.d.ts +1 -0
- package/components/smoothScrollbars/SmoothScrollbars.js +3 -3
- package/components/statsWidget/StatsWidget.d.ts +2 -2
- package/components/statsWidget/StatsWidgets.d.ts +2 -2
- package/components/svgImage/SvgElement.d.ts +8 -0
- package/components/svgImage/SvgElement.js +11 -0
- package/components/svgImage/SvgImage.d.ts +30 -0
- package/components/svgImage/SvgImage.js +20 -0
- package/components/svgImage/svgConverter.d.ts +17 -0
- package/components/svgImage/svgConverter.js +78 -0
- package/components/svgImage/useSvgLoader.d.ts +9 -0
- package/components/svgImage/useSvgLoader.js +43 -0
- package/components/switch/Switch.d.ts +4 -0
- package/components/switch/Switch.js +5 -6
- package/components/table/TableCardsSorting.d.ts +0 -1
- package/components/table/TableCol.d.ts +18 -0
- package/components/table/TableCol.js +11 -0
- package/components/table/TableHead.d.ts +33 -0
- package/components/table/TableHead.js +11 -0
- package/components/table/TableSettingsDialog.js +1 -1
- package/components/tag/Tag.js +1 -1
- package/components/timepicker/TimePicker.d.ts +1 -2
- package/components/timepicker/TimePicker.js +35 -8
- package/components/tooltip/SimpleTooltip.d.ts +1 -1
- package/components/virtualList/VirtualList.js +1 -1
- package/hooks/useIsFocusWithin.d.ts +33 -0
- package/hooks/useIsFocusWithin.js +55 -0
- package/hooks/useLocationSuggestions.d.ts +27 -0
- package/hooks/useLocationSuggestions.js +94 -0
- package/hooks/useOnboarding.d.ts +17 -5
- package/hooks/useOnboarding.js +7 -1
- package/hooks/usePostMessage.js +0 -1
- package/hooks/useSearch.d.ts +63 -0
- package/hooks/useSearch.js +73 -0
- package/hooks/useSorting.d.ts +6 -0
- package/hooks/useSorting.js +7 -4
- package/hooks/useTableExport.d.ts +49 -0
- package/hooks/useTableExport.js +57 -0
- package/hooks/useTableSelection.d.ts +166 -0
- package/hooks/useTableSelection.js +201 -0
- package/lib/es/BarList.d.ts +2 -0
- package/lib/es/BarList.js +7 -0
- package/lib/es/SaveableDateInput.d.ts +2 -0
- package/lib/es/SaveableDateInput.js +7 -0
- package/lib/es/SvgImage.d.ts +2 -0
- package/lib/es/SvgImage.js +7 -0
- package/lib/es/TableCol.d.ts +2 -0
- package/lib/es/TableCol.js +7 -0
- package/lib/es/TableHead.d.ts +2 -0
- package/lib/es/TableHead.js +7 -0
- package/lib/es/components/actionBarItem/ActionBarItemIcon.js +1 -1
- package/lib/es/components/actionBarItem/ActionBarOverlay.js +1 -1
- package/lib/es/components/activity/Activity.d.ts +2 -2
- package/lib/es/components/applicationHeader/CollapsedNavItem.js +1 -0
- package/lib/es/components/assetTree/Tree.d.ts +20 -0
- package/lib/es/components/assetTree/Tree.js +74 -37
- package/lib/es/components/assetTree/TreeLeaf.js +1 -1
- package/lib/es/components/assetTree/TreeNodeContainer.d.ts +1 -1
- package/lib/es/components/assetTree/TreeSearch.js +1 -1
- package/lib/es/components/assetTree/TreeSummary.js +1 -1
- package/lib/es/components/assetTree/TypeCounter.d.ts +2 -0
- package/lib/es/components/assetTree/TypeCounter.js +1 -1
- package/lib/es/components/assetTree/useTreeExpansion.d.ts +4 -0
- package/lib/es/components/assetTree/useTreeExpansion.js +29 -0
- package/lib/es/components/assetTree/useTreeHeight.d.ts +1 -0
- package/lib/es/components/assetTree/useTreeHeight.js +64 -0
- package/lib/es/components/assetTree/useTreeScrollPosition.d.ts +3 -0
- package/lib/es/components/assetTree/useTreeScrollPosition.js +23 -0
- package/lib/es/components/assetTree/useTreeVirtualization.d.ts +17 -0
- package/lib/es/components/assetTree/useTreeVirtualization.js +76 -0
- package/lib/es/components/autosuggest/AutoSuggest.js +2 -1
- package/lib/es/components/barList/BarList.d.ts +97 -0
- package/lib/es/components/barList/BarList.js +45 -0
- package/lib/es/components/barList/useSortedBars.d.ts +2 -0
- package/lib/es/components/barList/useSortedBars.js +17 -0
- package/lib/es/components/button/ButtonToolbar.d.ts +1 -1
- package/lib/es/components/button/ButtonToolbar.js +1 -1
- package/lib/es/components/button/ToggleButton.js +0 -1
- package/lib/es/components/charts/PieChart.js +1 -1
- package/lib/es/components/clearableInput/ClearableInput.d.ts +20 -7
- package/lib/es/components/clearableInput/ClearableInput.js +67 -7
- package/lib/es/components/dialog/Dialog.js +1 -1
- package/lib/es/components/dialog/FrameDialog.js +1 -1
- package/lib/es/components/dropdown/ButtonDropdown.d.ts +11 -3
- package/lib/es/components/dropdown/ButtonDropdown.js +79 -64
- package/lib/es/components/dropdown/DropdownToggleButton.d.ts +7 -4
- package/lib/es/components/dropdown/DropdownToggleButton.js +11 -3
- package/lib/es/components/formLabel/FormLabel.d.ts +2 -2
- package/lib/es/components/formLabel/FormLabel.js +1 -1
- package/lib/es/components/listMenu/ListMenu.js +4 -1
- package/lib/es/components/map/components/Map.js +20 -5
- package/lib/es/components/map/components/constants.d.ts +2 -0
- package/lib/es/components/map/components/constants.js +4 -1
- package/lib/es/components/map/components/features/basics/InfoBubble.js +1 -1
- package/lib/es/components/map/components/features/layers/overlayLayers/IncidentsLayer.js +1 -1
- package/lib/es/components/map/utils/mapTypes.d.ts +5 -0
- package/lib/es/components/map/utils/rendering.d.ts +5 -2
- package/lib/es/components/map/utils/rendering.js +46 -39
- package/lib/es/components/menuItems/MenuItem.js +1 -1
- package/lib/es/components/notification/Notification.js +1 -1
- package/lib/es/components/overlay/OverlayTrigger.js +3 -3
- package/lib/es/components/saveableInput/SaveableDateInput.d.ts +83 -0
- package/lib/es/components/saveableInput/SaveableDateInput.js +125 -0
- package/lib/es/components/selects/BaseSelectDropdown.js +1 -1
- package/lib/es/components/selects/Multiselect.d.ts +8 -0
- package/lib/es/components/selects/Multiselect.js +4 -4
- package/lib/es/components/smoothScrollbars/SmoothScrollbars.d.ts +1 -0
- package/lib/es/components/smoothScrollbars/SmoothScrollbars.js +3 -3
- package/lib/es/components/statsWidget/StatsWidget.d.ts +2 -2
- package/lib/es/components/statsWidget/StatsWidgets.d.ts +2 -2
- package/lib/es/components/svgImage/SvgElement.d.ts +8 -0
- package/lib/es/components/svgImage/SvgElement.js +14 -0
- package/lib/es/components/svgImage/SvgImage.d.ts +30 -0
- package/lib/es/components/svgImage/SvgImage.js +23 -0
- package/lib/es/components/svgImage/svgConverter.d.ts +17 -0
- package/lib/es/components/svgImage/svgConverter.js +84 -0
- package/lib/es/components/svgImage/useSvgLoader.d.ts +9 -0
- package/lib/es/components/svgImage/useSvgLoader.js +48 -0
- package/lib/es/components/switch/Switch.d.ts +4 -0
- package/lib/es/components/switch/Switch.js +5 -6
- package/lib/es/components/table/TableCardsSorting.d.ts +0 -1
- package/lib/es/components/table/TableCol.d.ts +18 -0
- package/lib/es/components/table/TableCol.js +13 -0
- package/lib/es/components/table/TableHead.d.ts +33 -0
- package/lib/es/components/table/TableHead.js +14 -0
- package/lib/es/components/table/TableSettingsDialog.js +1 -1
- package/lib/es/components/tag/Tag.js +1 -1
- package/lib/es/components/timepicker/TimePicker.d.ts +1 -2
- package/lib/es/components/timepicker/TimePicker.js +35 -8
- package/lib/es/components/tooltip/SimpleTooltip.d.ts +1 -1
- package/lib/es/components/virtualList/VirtualList.js +1 -1
- package/lib/es/hooks/useIsFocusWithin.d.ts +33 -0
- package/lib/es/hooks/useIsFocusWithin.js +57 -0
- package/lib/es/hooks/useLocationSuggestions.d.ts +27 -0
- package/lib/es/hooks/useLocationSuggestions.js +97 -0
- package/lib/es/hooks/useOnboarding.d.ts +17 -5
- package/lib/es/hooks/useOnboarding.js +7 -1
- package/lib/es/hooks/usePostMessage.js +0 -1
- package/lib/es/hooks/useSearch.d.ts +63 -0
- package/lib/es/hooks/useSearch.js +75 -0
- package/lib/es/hooks/useSorting.d.ts +6 -0
- package/lib/es/hooks/useSorting.js +7 -4
- package/lib/es/hooks/useTableExport.d.ts +49 -0
- package/lib/es/hooks/useTableExport.js +59 -0
- package/lib/es/hooks/useTableSelection.d.ts +166 -0
- package/lib/es/hooks/useTableSelection.js +210 -0
- package/lib/es/themes/Volkswagen/components/applicationHeader/VolkswagenApplicationHeader.js +1 -1
- package/lib/es/useIsFocusWithin.d.ts +2 -0
- package/lib/es/useIsFocusWithin.js +7 -0
- package/lib/es/useLocationSuggestions.d.ts +2 -0
- package/lib/es/useLocationSuggestions.js +7 -0
- package/lib/es/useSearch.d.ts +2 -0
- package/lib/es/useSearch.js +7 -0
- package/lib/es/useTableExport.d.ts +2 -0
- package/lib/es/useTableExport.js +7 -0
- package/lib/es/useTableSelection.d.ts +2 -0
- package/lib/es/useTableSelection.js +7 -0
- package/lib/es/utils/storageUtils.d.ts +2 -2
- package/lib/es/utils/storageUtils.js +2 -0
- package/lib/es/utils/urlFeatureToggles.d.ts +12 -6
- package/lib/es/utils/urlFeatureToggles.js +14 -8
- package/lib/es/utils/useDropDirection.js +1 -0
- package/lib/es/version.json +1 -1
- package/package.json +48 -40
- package/themes/Volkswagen/components/applicationHeader/VolkswagenApplicationHeader.js +1 -1
- package/useIsFocusWithin.d.ts +2 -0
- package/useIsFocusWithin.js +2 -0
- package/useLocationSuggestions.d.ts +2 -0
- package/useLocationSuggestions.js +2 -0
- package/useSearch.d.ts +2 -0
- package/useSearch.js +2 -0
- package/useTableExport.d.ts +2 -0
- package/useTableExport.js +2 -0
- package/useTableSelection.d.ts +2 -0
- package/useTableSelection.js +2 -0
- package/utils/storageUtils.d.ts +2 -2
- package/utils/storageUtils.js +2 -0
- package/utils/urlFeatureToggles.d.ts +12 -6
- package/utils/urlFeatureToggles.js +10 -7
- package/utils/useDropDirection.js +1 -0
- package/version.json +1 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SortDirectionType } from '../../utils/SortUtils';
|
|
3
|
+
export type BarListRow<T> = T & {
|
|
4
|
+
key?: string;
|
|
5
|
+
href?: string;
|
|
6
|
+
value: number;
|
|
7
|
+
name: string;
|
|
8
|
+
color?: string;
|
|
9
|
+
barColor?: string;
|
|
10
|
+
background?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Props for the BarList component.
|
|
14
|
+
*
|
|
15
|
+
* @template T - The type of the custom data associated with each bar row.
|
|
16
|
+
*/
|
|
17
|
+
type BarListProps<T = unknown> = React.HTMLAttributes<HTMLDivElement> & {
|
|
18
|
+
/**
|
|
19
|
+
* Array of bar row data to be rendered.
|
|
20
|
+
*/
|
|
21
|
+
data: BarListRow<T>[];
|
|
22
|
+
/**
|
|
23
|
+
* Optional function to format the numeric value displayed on the right side of each bar.
|
|
24
|
+
* Can return a string or a React element.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* valueFormatter={(value) => `${value}%`}
|
|
28
|
+
*/
|
|
29
|
+
valueFormatter?: (value: number) => string | React.ReactElement;
|
|
30
|
+
/**
|
|
31
|
+
* A reference value used to calculate relative widths.
|
|
32
|
+
* If not provided, the maximum value in `data` will be used.
|
|
33
|
+
*
|
|
34
|
+
* @default max(data.value)
|
|
35
|
+
*/
|
|
36
|
+
referenceValue?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Whether to animate the bar width transitions using Framer Motion.
|
|
39
|
+
*
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
showAnimation?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Callback fired when a bar is clicked.
|
|
45
|
+
*
|
|
46
|
+
* @param payload - The full data object of the clicked bar.
|
|
47
|
+
*/
|
|
48
|
+
onSelectRow?: (payload: BarListRow<T>) => void;
|
|
49
|
+
/**
|
|
50
|
+
* The sort order for the bars. Options are 'asc', 'desc', or 'none'.
|
|
51
|
+
*
|
|
52
|
+
* @default 'none'
|
|
53
|
+
*/
|
|
54
|
+
sortOrder?: SortDirectionType | 'none';
|
|
55
|
+
/**
|
|
56
|
+
* Height of each bar row in pixels.
|
|
57
|
+
*
|
|
58
|
+
* @default 32
|
|
59
|
+
*/
|
|
60
|
+
rowHeight?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Opacity applied to non-hovered bars (between 0 and 1).
|
|
63
|
+
*
|
|
64
|
+
* @default 0.5
|
|
65
|
+
*/
|
|
66
|
+
opacity?: number;
|
|
67
|
+
/**
|
|
68
|
+
* CSS color string used for the active/progress portion of each bar.
|
|
69
|
+
*
|
|
70
|
+
* @default 'bg-highlight-light'
|
|
71
|
+
*/
|
|
72
|
+
barColor?: string;
|
|
73
|
+
/**
|
|
74
|
+
* CSS color string used for the text labels.
|
|
75
|
+
*
|
|
76
|
+
* @default 'text-color-darker'
|
|
77
|
+
*/
|
|
78
|
+
labelColor?: string;
|
|
79
|
+
/**
|
|
80
|
+
* CSS color string used for the bar background.
|
|
81
|
+
*
|
|
82
|
+
* @default 'bg-transparent'
|
|
83
|
+
*/
|
|
84
|
+
background?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Additional className added to the wrapper element.
|
|
87
|
+
*/
|
|
88
|
+
className?: string;
|
|
89
|
+
};
|
|
90
|
+
declare const BarListInner: {
|
|
91
|
+
<T>(props: BarListProps<T>, forwardedRef: React.ForwardedRef<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
92
|
+
displayName: string;
|
|
93
|
+
};
|
|
94
|
+
declare const BarList: <T>(props: BarListProps<T> & {
|
|
95
|
+
ref?: React.ForwardedRef<HTMLDivElement>;
|
|
96
|
+
}) => ReturnType<typeof BarListInner>;
|
|
97
|
+
export default BarList;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { motion } from 'framer-motion';
|
|
5
|
+
import { SortDirection } from '../../utils/SortUtils';
|
|
6
|
+
import { useSortedBars } from './useSortedBars';
|
|
7
|
+
// Animation variants
|
|
8
|
+
const containerVariants = {
|
|
9
|
+
animate: {
|
|
10
|
+
transition: {
|
|
11
|
+
staggerChildren: 0.1,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
const barVariants = {
|
|
16
|
+
initial: { width: 0 },
|
|
17
|
+
animate: (width) => ({
|
|
18
|
+
width: `${width}%`,
|
|
19
|
+
transition: { duration: 0.8, ease: 'easeOut' },
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
const DEFAULT_ROW_HEIGHT = 25;
|
|
23
|
+
const DEFAULT_OPACITY = 0.5;
|
|
24
|
+
const BarListInner = (props, forwardedRef) => {
|
|
25
|
+
const { data = [], valueFormatter = value => value.toString(), showAnimation = false, onSelectRow, referenceValue, sortOrder = SortDirection.DESCENDING, barColor = 'bg-highlight-light', labelColor = 'text-color-darker', background = 'bg-transparent', rowHeight = DEFAULT_ROW_HEIGHT, opacity = DEFAULT_OPACITY, className = '', ...remainingProps } = props;
|
|
26
|
+
const sortedData = useSortedBars(data, sortOrder, item => item.value);
|
|
27
|
+
const [hoveredIndex, setHoveredIndex] = React.useState(null);
|
|
28
|
+
const widths = useMemo(() => {
|
|
29
|
+
const base = referenceValue ?? Math.max(...sortedData.map(item => item.value), 0);
|
|
30
|
+
return sortedData.map(item => (base === 0 || item.value === 0 ? 0 : Math.max((item.value / base) * 100, 2)));
|
|
31
|
+
}, [sortedData, referenceValue]);
|
|
32
|
+
return (_jsxs("div", { ...remainingProps, ref: forwardedRef, className: classNames('display-flex justify-content-between gap-15', className), children: [_jsx(motion.div, { variants: showAnimation ? containerVariants : undefined, initial: 'initial', animate: 'animate', className: 'width-100pct space-y-5', children: sortedData.map((item, index) => {
|
|
33
|
+
const width = widths[index];
|
|
34
|
+
const itemLabelColor = item.color ?? labelColor;
|
|
35
|
+
const itemBarColor = item.barColor ?? barColor;
|
|
36
|
+
const itemBackground = item.background ?? background;
|
|
37
|
+
return (_jsxs("div", { onMouseEnter: () => setHoveredIndex(index), onMouseLeave: () => setHoveredIndex(null), onClick: () => onSelectRow?.(item), className: classNames('position-relative width-100pct rounded-small', 'transition-all transition-ease-in-out transition-duration-01', itemBackground, onSelectRow && 'cursor-pointer', hoveredIndex === index && 'bg-lightest'), children: [_jsx(motion.div, { custom: width, variants: showAnimation ? barVariants : undefined, className: classNames('display-flex align-items-center rounded-small', 'transition-all transition-ease-in-out transition-duration-01', itemBarColor), style: { height: `${rowHeight}px`, opacity: hoveredIndex === index ? 1 : opacity }, role: 'presentation' }), _jsx("div", { className: 'position-absolute left-0 top-50pct translate-y-50pct display-flex width-100pct padding-left-10', children: item.href ? (_jsx("a", { href: item.href, className: itemLabelColor, target: '_blank', rel: 'noreferrer', onClick: event => event.stopPropagation(), children: item.name })) : (_jsx("div", { className: itemLabelColor, children: item.name })) })] }, item.key ?? item.name));
|
|
38
|
+
}) }), _jsx("div", { className: 'space-y-5', children: sortedData.map(item => (_jsx("div", { className: classNames('display-flex align-items-center justify-content-end'), style: { height: `${rowHeight}px` }, children: _jsx("div", { className: 'text-color-darkest', children: valueFormatter(item.value) }) }, item.key ?? item.name))) })] }));
|
|
39
|
+
};
|
|
40
|
+
BarListInner.displayName = 'BarList';
|
|
41
|
+
const BarList = React.forwardRef(BarListInner);
|
|
42
|
+
export default BarList;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { SortDirection } from '../../utils/SortUtils';
|
|
3
|
+
export function useSortedBars(data, sortOrder, getValue) {
|
|
4
|
+
return useMemo(() => {
|
|
5
|
+
if (sortOrder === 'none') {
|
|
6
|
+
return data;
|
|
7
|
+
}
|
|
8
|
+
return [...data].sort((a, b) => {
|
|
9
|
+
const aVal = getValue(a);
|
|
10
|
+
const bVal = getValue(b);
|
|
11
|
+
return sortOrder === SortDirection.ASCENDING ? aVal - bVal : bVal - aVal;
|
|
12
|
+
});
|
|
13
|
+
}, [data, sortOrder, getValue]);
|
|
14
|
+
}
|
|
@@ -3,7 +3,7 @@ export type ButtonToolbarProps = ComponentProps<'div'> & {
|
|
|
3
3
|
/**
|
|
4
4
|
* Align buttons to a defined side or set them apart.
|
|
5
5
|
*/
|
|
6
|
-
alignment?: 'left' | 'right' | 'space-between';
|
|
6
|
+
alignment?: 'left' | 'right' | 'center' | 'space-between';
|
|
7
7
|
/**
|
|
8
8
|
* Additional classes set to the outer element.
|
|
9
9
|
*/
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
const ButtonToolbar = (props) => {
|
|
4
4
|
const { className = '', alignment, children, ...remainingProps } = props;
|
|
5
|
-
const classes = classNames(className, 'btn-toolbar', alignment === 'left' && 'justify-content-start', alignment === 'right' && 'justify-content-end', alignment === 'space-between' && 'justify-content-between');
|
|
5
|
+
const classes = classNames(className, 'btn-toolbar', alignment === 'left' && 'justify-content-start', alignment === 'right' && 'justify-content-end', alignment === 'center' && 'justify-content-center', alignment === 'space-between' && 'justify-content-between');
|
|
6
6
|
return (_jsx("div", { ...remainingProps, className: classes, children: children }));
|
|
7
7
|
};
|
|
8
8
|
export default ButtonToolbar;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import Button from './Button';
|
|
3
|
-
// @ts-ignore - the Button throws TS error due to refs that may be checked at a later point in time
|
|
4
3
|
const ToggleButton = (props) => _jsx(Button, { ...props, asToggle: true });
|
|
5
4
|
export default ToggleButton;
|
|
@@ -14,7 +14,7 @@ const renderCustomInnerLabel = (dataUnit) => ({ cx, cy, midAngle, innerRadius, o
|
|
|
14
14
|
};
|
|
15
15
|
const PieChart = (props) => {
|
|
16
16
|
const { width, height, innerRadius, outerRadius, data = [], dataKey = 'value', dataUnit = '', nameKey = 'name', color, filled = false, labels = true, innerLabels = false, paddingAngle = 3, legend = _jsx(RechartsLegend, {}), tooltip = true, pieOptions, containerOptions, ...remainingProps } = props;
|
|
17
|
-
// biome-ignore lint/suspicious/noExplicitAny:
|
|
17
|
+
// biome-ignore lint/suspicious/noExplicitAny: unknown type
|
|
18
18
|
const renderLabels = (entry) => `${isFunction(dataKey) ? dataKey(entry) : entry[dataKey]} ${dataUnit}`;
|
|
19
19
|
const pieLabel = labels && (innerLabels ? renderCustomInnerLabel(dataUnit) : renderLabels);
|
|
20
20
|
const tooltipProps = isObject(tooltip) ? tooltip.props : {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare const DEFAULT_TYPE = "text";
|
|
3
3
|
export declare const SUPPORTED_TYPES: string[];
|
|
4
|
+
export type MaskVisibility = 'always' | 'onFocus' | 'never';
|
|
4
5
|
export type ClearableInputProps = {
|
|
5
6
|
/**
|
|
6
7
|
* Gives the input element the id.
|
|
@@ -69,7 +70,7 @@ export type ClearableInputProps = {
|
|
|
69
70
|
* @param event
|
|
70
71
|
* @returns
|
|
71
72
|
*/
|
|
72
|
-
onFocus?: (event: React.
|
|
73
|
+
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
73
74
|
/**
|
|
74
75
|
* Callback function for when the value is cleared via the clear button.
|
|
75
76
|
* @param event
|
|
@@ -93,22 +94,24 @@ export type ClearableInputProps = {
|
|
|
93
94
|
* It defines the pattern that should be followed.
|
|
94
95
|
*
|
|
95
96
|
* For more details on masking, checkout the third party documentation for the
|
|
96
|
-
* input mask here: {@link https://
|
|
97
|
+
* input mask here: {@link https://imask.js.org/guide.html}
|
|
97
98
|
*
|
|
98
99
|
* Simple masks can be defined as strings.
|
|
99
100
|
*
|
|
100
101
|
* The following characters will define mask format:
|
|
101
102
|
*
|
|
102
|
-
* Character: "
|
|
103
|
+
* Character: "0" = allowed input: "0-9" (digit)
|
|
103
104
|
*
|
|
104
|
-
* Character: "a"
|
|
105
|
+
* Character: "a" = allowed input: "a-z, A-Z" (letter)
|
|
105
106
|
*
|
|
106
|
-
* Character: "*"
|
|
107
|
+
* Character: "*" = allowed input: any character
|
|
107
108
|
*
|
|
108
|
-
*
|
|
109
|
+
* Character: "#" = allowed input: "0-9, a-z, A-Z" (digit or letter)
|
|
110
|
+
*
|
|
111
|
+
* Any other character in the mask is considered a fixed value.
|
|
109
112
|
*
|
|
110
113
|
* @example
|
|
111
|
-
* '--
|
|
114
|
+
* '-- ### ### ###' or '+49 00 000 00'
|
|
112
115
|
*
|
|
113
116
|
* @example
|
|
114
117
|
* ['0', '0', /[0-9]/, ' ', /[a-zA-Z]/]
|
|
@@ -127,11 +130,21 @@ export type ClearableInputProps = {
|
|
|
127
130
|
* @default false
|
|
128
131
|
*/
|
|
129
132
|
disabled?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Controls when the mask pattern is visible.
|
|
135
|
+
* - 'always': Mask is always visible
|
|
136
|
+
* - 'onFocus': Mask is hidden but shown when input is focused (default)
|
|
137
|
+
* - 'never': Mask is never shown
|
|
138
|
+
*
|
|
139
|
+
* @default 'always'
|
|
140
|
+
*/
|
|
141
|
+
maskVisibility?: MaskVisibility;
|
|
130
142
|
/**
|
|
131
143
|
* Whether mask prefix and placeholder should be displayed when input is empty and
|
|
132
144
|
* has no focus.
|
|
133
145
|
*
|
|
134
146
|
* @default false
|
|
147
|
+
* @deprecated please use maskVisibility='always' instead
|
|
135
148
|
*/
|
|
136
149
|
alwaysShowMask?: boolean;
|
|
137
150
|
/**
|
|
@@ -1,23 +1,45 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
|
|
2
|
+
// biome-ignore lint/style/useImportType: <explanation>
|
|
3
|
+
import { useState, forwardRef, useRef } from 'react';
|
|
3
4
|
import omit from 'lodash/fp/omit';
|
|
4
5
|
import isNil from 'lodash/fp/isNil';
|
|
5
6
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
import isFunction from 'lodash/fp/isFunction';
|
|
8
9
|
import noop from 'lodash/fp/noop';
|
|
9
|
-
import
|
|
10
|
+
import { IMaskInput } from 'react-imask';
|
|
10
11
|
import usePrevious from '../../hooks/usePrevious';
|
|
12
|
+
import useMergeRefs from '../../hooks/useMergeRefs';
|
|
11
13
|
export const DEFAULT_TYPE = 'text';
|
|
12
14
|
export const SUPPORTED_TYPES = ['text', 'password', 'email'];
|
|
13
15
|
const hasValue = (value) => !isEmpty(`${value}`);
|
|
14
16
|
const ClearableInput = forwardRef((props, ref) => {
|
|
15
|
-
const { type = DEFAULT_TYPE, defaultValue, value, maxLength, tabIndex = 0, hasError = false, inputRef, autoComplete, onChange = noop, onBlur = noop, onFocus = noop, onClear = noop, onKeyPress = noop, onClick = noop, mask, maskPlaceholder = '_', alwaysShowMask = false, inputClassName = '', disabled = false, className = '', children, ...remainingProps } = props;
|
|
17
|
+
const { type = DEFAULT_TYPE, defaultValue, value, maxLength, tabIndex = 0, hasError = false, inputRef, autoComplete, onChange = noop, onBlur = noop, onFocus = noop, onClear = noop, onKeyPress = noop, onClick = noop, mask, maskPlaceholder = '_', maskVisibility = 'always', alwaysShowMask = false, inputClassName = '', disabled = false, className = '', children, ...remainingProps } = props;
|
|
16
18
|
const initialValue = value || defaultValue || '';
|
|
17
19
|
const [inputValue, setInputValue] = useState(initialValue);
|
|
18
20
|
const [showClear, setShowClear] = useState(hasValue(initialValue));
|
|
21
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
19
22
|
const isControlled = !isNil(value);
|
|
23
|
+
const internalMaskRef = useRef(null);
|
|
24
|
+
const mergedInternalMaskRef = useMergeRefs(internalMaskRef, inputRef, ref);
|
|
20
25
|
const hasMask = !!mask;
|
|
26
|
+
// Calculate if mask should be visible (lazy=false means visible, lazy=true means hidden)
|
|
27
|
+
const shouldShowMask = () => {
|
|
28
|
+
// For backward compatibility
|
|
29
|
+
if (alwaysShowMask) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
switch (maskVisibility) {
|
|
33
|
+
case 'always':
|
|
34
|
+
return true;
|
|
35
|
+
case 'onFocus':
|
|
36
|
+
return isFocused;
|
|
37
|
+
case 'never':
|
|
38
|
+
return false;
|
|
39
|
+
default:
|
|
40
|
+
return isFocused;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
21
43
|
// Handles new input value and saves it in the local state.
|
|
22
44
|
// The value stored in the state is used for rendering.
|
|
23
45
|
const changeInternalValue = (newValue = '') => {
|
|
@@ -44,6 +66,45 @@ const ClearableInput = forwardRef((props, ref) => {
|
|
|
44
66
|
onChange(newValue, event);
|
|
45
67
|
}
|
|
46
68
|
};
|
|
69
|
+
const handleAccept = (newValue, maskRef, event) => {
|
|
70
|
+
if (!internalMaskRef.current) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// Simulate a ChangeEvent for backwards compatibility since react-imask does not return a change event itself
|
|
74
|
+
const syntheticEvent = {
|
|
75
|
+
target: internalMaskRef.current,
|
|
76
|
+
currentTarget: internalMaskRef.current,
|
|
77
|
+
// Standard synthetic event props
|
|
78
|
+
bubbles: true,
|
|
79
|
+
cancelable: true,
|
|
80
|
+
defaultPrevented: false,
|
|
81
|
+
isTrusted: true,
|
|
82
|
+
preventDefault: () => { },
|
|
83
|
+
stopPropagation: () => { },
|
|
84
|
+
persist: () => { },
|
|
85
|
+
nativeEvent: {},
|
|
86
|
+
type: 'change',
|
|
87
|
+
timeStamp: Date.now(),
|
|
88
|
+
};
|
|
89
|
+
// Set unmasked value manually if needed
|
|
90
|
+
// (you can use data-attributes or attach it directly)
|
|
91
|
+
syntheticEvent.target.unmaskedValue = maskRef.unmaskedValue;
|
|
92
|
+
if (isControlled) {
|
|
93
|
+
onChange(newValue, syntheticEvent);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
changeInternalValue(newValue);
|
|
97
|
+
onChange(newValue, syntheticEvent);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const handleInputFocus = (event) => {
|
|
101
|
+
setIsFocused(true);
|
|
102
|
+
onFocus(event);
|
|
103
|
+
};
|
|
104
|
+
const handleInputBlur = (event) => {
|
|
105
|
+
setIsFocused(false);
|
|
106
|
+
onBlur(event);
|
|
107
|
+
};
|
|
47
108
|
// Will be triggered on every key press but also when pressing 'Enter' for example
|
|
48
109
|
const handleKeyPress = (event) => {
|
|
49
110
|
onKeyPress(event);
|
|
@@ -66,17 +127,16 @@ const ClearableInput = forwardRef((props, ref) => {
|
|
|
66
127
|
autoComplete,
|
|
67
128
|
type: inputType,
|
|
68
129
|
value: inputValue,
|
|
69
|
-
onChange: handleChange,
|
|
70
130
|
onKeyPress: handleKeyPress,
|
|
71
|
-
onBlur,
|
|
72
|
-
onFocus,
|
|
131
|
+
onBlur: handleInputBlur,
|
|
132
|
+
onFocus: handleInputFocus,
|
|
133
|
+
onChange: hasMask ? undefined : handleChange, // In case of masked input, the onAccept callback is used
|
|
73
134
|
onClick,
|
|
74
135
|
disabled,
|
|
75
136
|
maxLength: hasMask ? undefined : maxLength,
|
|
76
137
|
tabIndex,
|
|
77
|
-
ref: inputRef || ref,
|
|
78
138
|
};
|
|
79
|
-
const input = hasMask ? (_jsx(
|
|
139
|
+
const input = hasMask ? (_jsx(IMaskInput, { ...inputProps, inputRef: mergedInternalMaskRef, mask: mask, placeholderChar: maskPlaceholder, onAccept: handleAccept, lazy: !shouldShowMask(), overwrite: true })) : (_jsx("input", { ...inputProps, ref: inputRef || ref }));
|
|
80
140
|
return (_jsxs("div", { className: classes, children: [children && isFunction(children) ? children(inputProps) : input, _jsx("span", { className: clearButtonClassNames, onClick: clearInputValue, children: _jsx("span", { className: 'clearButtonIcon rioglyph rioglyph-remove-sign' }) })] }));
|
|
81
141
|
});
|
|
82
142
|
export default ClearableInput;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
//
|
|
2
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
3
3
|
import { useState, useRef } from 'react';
|
|
4
4
|
import ReactDOM from 'react-dom';
|
|
5
5
|
import classNames from 'classnames';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
//
|
|
2
|
+
// biome-ignore lint/style/useImportType: required for JSX runtime compatibility with older toolchains
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import IframeResizer from 'iframe-resizer-react';
|
|
5
5
|
import Dialog from './Dialog';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type DropdownToggleEvent, type DropdownToggleButtonType } from './DropdownToggleButton';
|
|
2
3
|
import type { MenuItemProps as MenuItem } from '../menuItems/MenuItem';
|
|
3
4
|
import type { BUTTON_SIZE, BUTTON_STYLE, BUTTON_VARIANT } from '../button/Button';
|
|
4
|
-
export type ButtonDropdownProps = {
|
|
5
|
+
export type ButtonDropdownProps<T extends DropdownToggleButtonType = 'button'> = {
|
|
5
6
|
/**
|
|
6
7
|
* Unique button id. If not present a random id is generated.
|
|
7
8
|
*/
|
|
@@ -46,6 +47,13 @@ export type ButtonDropdownProps = {
|
|
|
46
47
|
* Possible values are: `link`, `link-inline`, `outline`, `action`
|
|
47
48
|
*/
|
|
48
49
|
variant?: BUTTON_VARIANT;
|
|
50
|
+
/**
|
|
51
|
+
* Specify the toggle element type.
|
|
52
|
+
* It supports the following types: "button" | "tag" | "label"
|
|
53
|
+
*
|
|
54
|
+
* @default 'button'
|
|
55
|
+
*/
|
|
56
|
+
toggleButtonType?: DropdownToggleButtonType;
|
|
49
57
|
/**
|
|
50
58
|
* Optional prop to defines whether the dropdown title is icon only which
|
|
51
59
|
* applies different padding so the button is a square.
|
|
@@ -90,7 +98,7 @@ export type ButtonDropdownProps = {
|
|
|
90
98
|
* @param event
|
|
91
99
|
* @returns
|
|
92
100
|
*/
|
|
93
|
-
onOpen?: (event
|
|
101
|
+
onOpen?: (event: DropdownToggleEvent<T>) => void;
|
|
94
102
|
/**
|
|
95
103
|
* Callback for when the toggle button was clicked to close it.
|
|
96
104
|
* @returns
|
|
@@ -117,7 +125,7 @@ export type ButtonDropdownProps = {
|
|
|
117
125
|
*/
|
|
118
126
|
className?: string;
|
|
119
127
|
};
|
|
120
|
-
declare const ButtonDropdown: React.ForwardRefExoticComponent<ButtonDropdownProps & {
|
|
128
|
+
declare const ButtonDropdown: React.ForwardRefExoticComponent<ButtonDropdownProps<"button"> & {
|
|
121
129
|
children?: React.ReactNode | undefined;
|
|
122
130
|
} & React.RefAttributes<HTMLButtonElement>>;
|
|
123
131
|
export default ButtonDropdown;
|
|
@@ -25,71 +25,86 @@ const getPlacement = (pullRight, dropup) => {
|
|
|
25
25
|
}
|
|
26
26
|
return 'bottom-start';
|
|
27
27
|
};
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
28
|
+
const createButtonDropdown = () => {
|
|
29
|
+
return forwardRef((props, ref) => {
|
|
30
|
+
const { id = Math.random().toString(36).slice(2, 16), items = [], bsSize = 'md', bsStyle = 'default', variant, disabled = false, iconOnly = false, title, splitButton = false, customDropdown, open, dropup = false, pullRight = false, noCaret = false, onOpen = noop, onClose = noop, onLabelButtonClick = noop, usePortal = false, popperConfig, toggleButtonType = 'button', toggleClassName = '', dropdownClassName, className = '', ...remainingProps } = props;
|
|
31
|
+
const [internalOpen, setInternalOpen] = useState(open);
|
|
32
|
+
const [refDropdownToggle, setRefDropdownToggle] = useState(null);
|
|
33
|
+
const [refDropdownMenu, setRefDropdownMenu] = useState(null);
|
|
34
|
+
const [refSplitButtonToggle, setRefSplitButtonToggle] = useState(null);
|
|
35
|
+
const defaultPopperConfig = {
|
|
36
|
+
placement: getPlacement(pullRight, dropup),
|
|
37
|
+
modifiers: [],
|
|
38
|
+
};
|
|
39
|
+
const popperParentRef = splitButton && pullRight ? refSplitButtonToggle : refDropdownToggle;
|
|
40
|
+
const { styles, attributes } = usePopper(popperParentRef, refDropdownMenu, popperConfig || defaultPopperConfig);
|
|
41
|
+
const isUncontrolled = isNil(open);
|
|
42
|
+
const isOpen = isUncontrolled ? internalOpen : open;
|
|
43
|
+
const wrapperRef = useClickOutside(event => {
|
|
44
|
+
if (usePortal) {
|
|
45
|
+
// In case the dropdown is rendered via portal the clickOutside the toggle button element is
|
|
46
|
+
// triggered since the dropdown is not a child of the wrapper element.
|
|
47
|
+
// In this case we need to check if the event target is inside the dropdown-menu and prevent closing
|
|
48
|
+
// the dropdown
|
|
49
|
+
if (!refDropdownMenu?.contains(event.target)) {
|
|
50
|
+
closeMenu();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
49
54
|
closeMenu();
|
|
50
55
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
}, DEFAULT_EVENT_TYPES, Boolean(isOpen) // only listen to clicks outside when the dropdown is open
|
|
57
|
+
);
|
|
58
|
+
const dropdownRoot = getOrCreatePortalRoot();
|
|
59
|
+
const shouldShowCaret = !noCaret && !splitButton && !iconOnly;
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (!isUncontrolled) {
|
|
62
|
+
setInternalOpen(open);
|
|
63
|
+
}
|
|
64
|
+
}, [isUncontrolled, open]);
|
|
65
|
+
const toggleOpen = (event) => {
|
|
66
|
+
const isDropdownOpen = isUncontrolled ? internalOpen : open;
|
|
67
|
+
if (isDropdownOpen) {
|
|
68
|
+
closeMenu();
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
openMenu(event);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const openMenu = (event) => {
|
|
75
|
+
if (isUncontrolled) {
|
|
76
|
+
setInternalOpen(true);
|
|
77
|
+
}
|
|
78
|
+
if (event) {
|
|
79
|
+
onOpen(event);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const closeMenu = () => {
|
|
83
|
+
if (isUncontrolled) {
|
|
84
|
+
setInternalOpen(false);
|
|
85
|
+
}
|
|
86
|
+
onClose();
|
|
87
|
+
};
|
|
88
|
+
const handleSplitLabelButtonClick = () => {
|
|
67
89
|
closeMenu();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
89
|
-
const handleDropdownButtonClick = splitButton ? handleSplitLabelButtonClick : toggleOpen;
|
|
90
|
-
const wrapperClasses = classNames('dropdown', 'btn-group', isOpen && 'open', className);
|
|
91
|
-
const dropdownClasses = classNames(usePortal && 'dropdown-portal', splitButton && pullRight && 'pull-right', dropdownClassName);
|
|
92
|
-
const dropdownMenu = (_jsx(MenuItemList, { className: dropdownClasses, ref: setRefDropdownMenu, style: styles.popper, ...attributes.popper, children: customDropdown ? customDropdown : _jsx(MenuItems, { items: items, closeMenu: toggleOpen }) }));
|
|
93
|
-
return (_jsxs("div", { ...remainingProps, className: wrapperClasses, ref: wrapperRef, children: [_jsx(DropdownToggleButton, { id: id, splitButton: splitButton, bsStyle: bsStyle, bsSize: bsSize, variant: variant, iconOnly: iconOnly, disabled: disabled, ref: setRefDropdownToggle, onClick: handleDropdownButtonClick, outerRef: ref, className: toggleClassName, children: _jsxs(_Fragment, { children: [title, shouldShowCaret && _jsx(Caret, {})] }) }), splitButton && (_jsx(SplitCaretButton, { id: id, bsStyle: bsStyle, bsSize: bsSize, disabled: disabled, className: toggleClassName, onClick: toggleOpen, ref: setRefSplitButtonToggle })), isOpen && usePortal && ReactDOM.createPortal(dropdownMenu, dropdownRoot), isOpen && !usePortal && dropdownMenu] }));
|
|
94
|
-
});
|
|
90
|
+
onLabelButtonClick();
|
|
91
|
+
};
|
|
92
|
+
const handleSplitCaretButtonClick = (event) => {
|
|
93
|
+
toggleOpen(event);
|
|
94
|
+
};
|
|
95
|
+
const handleDropdownButtonClick = (event) => {
|
|
96
|
+
if (splitButton) {
|
|
97
|
+
handleSplitLabelButtonClick();
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
toggleOpen(event);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const wrapperClasses = classNames('dropdown', 'btn-group', isOpen && 'open', className);
|
|
104
|
+
const dropdownClasses = classNames(usePortal && 'dropdown-portal', splitButton && pullRight && 'pull-right', dropdownClassName);
|
|
105
|
+
const dropdownMenu = (_jsx(MenuItemList, { className: dropdownClasses, ref: setRefDropdownMenu, style: styles.popper, ...attributes.popper, children: customDropdown ? customDropdown : _jsx(MenuItems, { items: items, closeMenu: toggleOpen }) }));
|
|
106
|
+
return (_jsxs("div", { ...remainingProps, className: wrapperClasses, ref: wrapperRef, children: [_jsx(DropdownToggleButton, { id: id, splitButton: splitButton, bsStyle: bsStyle, bsSize: bsSize, variant: variant, iconOnly: iconOnly, disabled: disabled, ref: setRefDropdownToggle, onClick: handleDropdownButtonClick, outerRef: ref, toggleButtonType: toggleButtonType, className: toggleClassName, children: _jsxs(_Fragment, { children: [title, shouldShowCaret && _jsx(Caret, {})] }) }), splitButton && (_jsx(SplitCaretButton, { id: id, bsStyle: bsStyle, bsSize: bsSize, disabled: disabled, className: toggleClassName, onClick: handleSplitCaretButtonClick, ref: setRefSplitButtonToggle })), isOpen && usePortal && ReactDOM.createPortal(dropdownMenu, dropdownRoot), isOpen && !usePortal && dropdownMenu] }));
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
const ButtonDropdown = createButtonDropdown();
|
|
95
110
|
export default ButtonDropdown;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type HTMLProps, type PropsWithChildren } from 'react';
|
|
2
2
|
import { type BUTTON_VARIANT, type BUTTON_SIZE, type BUTTON_STYLE } from '../button/Button';
|
|
3
|
+
export type DropdownToggleButtonType = 'button' | 'tag' | 'label';
|
|
4
|
+
export type DropdownToggleEvent<T extends DropdownToggleButtonType = 'button'> = T extends 'button' ? React.MouseEvent<HTMLButtonElement> : React.MouseEvent<HTMLDivElement>;
|
|
3
5
|
export type DropdownToggleButtonProps = HTMLProps<HTMLButtonElement> & {
|
|
4
6
|
id?: string;
|
|
5
7
|
disabled?: boolean;
|
|
6
8
|
splitButton?: boolean;
|
|
7
9
|
iconOnly?: boolean;
|
|
8
|
-
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
10
|
+
onClick: (event: React.MouseEvent<HTMLButtonElement | HTMLDivElement>) => void;
|
|
9
11
|
bsSize: BUTTON_SIZE;
|
|
10
12
|
bsStyle: BUTTON_STYLE;
|
|
11
13
|
variant?: BUTTON_VARIANT;
|
|
12
|
-
|
|
14
|
+
toggleButtonType?: DropdownToggleButtonType;
|
|
15
|
+
outerRef?: React.Ref<HTMLButtonElement | HTMLDivElement>;
|
|
13
16
|
className?: string;
|
|
14
17
|
};
|
|
15
|
-
declare const DropdownToggleButton:
|
|
18
|
+
declare const DropdownToggleButton: import("react").ForwardRefExoticComponent<Omit<PropsWithChildren<DropdownToggleButtonProps>, "ref"> & import("react").RefAttributes<HTMLDivElement | HTMLButtonElement>>;
|
|
16
19
|
export default DropdownToggleButton;
|