@rio-cloud/rio-uikit 1.3.0 → 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 (93) hide show
  1. package/ChartLabel.d.ts +2 -0
  2. package/ChartLabel.js +2 -0
  3. package/ComposedChart.d.ts +2 -0
  4. package/ComposedChart.js +2 -0
  5. package/GroupedItemList.d.ts +2 -0
  6. package/GroupedItemList.js +2 -0
  7. package/LicensePlate.d.ts +2 -0
  8. package/LicensePlate.js +2 -0
  9. package/ReferenceLine.d.ts +2 -0
  10. package/ReferenceLine.js +2 -0
  11. package/components/assetTree/TreeOptions.js +7 -3
  12. package/components/charts/Area.d.ts +5 -0
  13. package/components/charts/Area.js +1 -9
  14. package/components/charts/AreaChart.d.ts +2 -0
  15. package/components/charts/AreaChart.js +9 -6
  16. package/components/charts/BarChart.js +4 -4
  17. package/components/charts/ChartLabel.d.ts +5 -0
  18. package/components/charts/ChartLabel.js +2 -0
  19. package/components/charts/ComposedChart.d.ts +34 -0
  20. package/components/charts/ComposedChart.js +30 -0
  21. package/components/charts/Legend.d.ts +8 -10
  22. package/components/charts/Legend.js +3 -12
  23. package/components/charts/Line.d.ts +5 -0
  24. package/components/charts/Line.js +1 -9
  25. package/components/charts/LineChart.d.ts +2 -0
  26. package/components/charts/LineChart.js +8 -5
  27. package/components/charts/PieChart.js +5 -5
  28. package/components/charts/RadialBarChart.js +5 -5
  29. package/components/charts/ReferenceLine.d.ts +7 -0
  30. package/components/charts/ReferenceLine.js +2 -0
  31. package/components/dialog/Dialog.d.ts +12 -4
  32. package/components/dialog/SplitDialog.d.ts +3 -3
  33. package/components/groupedItemList/GroupedItemList.d.ts +79 -0
  34. package/components/groupedItemList/GroupedItemList.js +77 -0
  35. package/components/licensePlate/LicensePlate.d.ts +19 -0
  36. package/components/licensePlate/LicensePlate.js +14 -0
  37. package/components/selects/BaseSelectDropdown.d.ts +1 -0
  38. package/components/selects/BaseSelectDropdown.js +16 -14
  39. package/components/selects/Multiselect.d.ts +5 -0
  40. package/components/selects/Multiselect.js +2 -2
  41. package/components/selects/Select.d.ts +5 -0
  42. package/components/selects/Select.js +2 -2
  43. package/hooks/useKey.d.ts +7 -4
  44. package/hooks/useKey.js +36 -8
  45. package/lib/es/ChartLabel.d.ts +2 -0
  46. package/lib/es/ChartLabel.js +7 -0
  47. package/lib/es/ComposedChart.d.ts +2 -0
  48. package/lib/es/ComposedChart.js +7 -0
  49. package/lib/es/GroupedItemList.d.ts +2 -0
  50. package/lib/es/GroupedItemList.js +7 -0
  51. package/lib/es/LicensePlate.d.ts +2 -0
  52. package/lib/es/LicensePlate.js +7 -0
  53. package/lib/es/ReferenceLine.d.ts +2 -0
  54. package/lib/es/ReferenceLine.js +7 -0
  55. package/lib/es/components/assetTree/TreeOptions.js +7 -3
  56. package/lib/es/components/charts/Area.d.ts +5 -0
  57. package/lib/es/components/charts/Area.js +1 -9
  58. package/lib/es/components/charts/AreaChart.d.ts +2 -0
  59. package/lib/es/components/charts/AreaChart.js +7 -4
  60. package/lib/es/components/charts/BarChart.js +3 -3
  61. package/lib/es/components/charts/ChartLabel.d.ts +5 -0
  62. package/lib/es/components/charts/ChartLabel.js +4 -0
  63. package/lib/es/components/charts/ComposedChart.d.ts +34 -0
  64. package/lib/es/components/charts/ComposedChart.js +32 -0
  65. package/lib/es/components/charts/Legend.d.ts +8 -10
  66. package/lib/es/components/charts/Legend.js +5 -12
  67. package/lib/es/components/charts/Line.d.ts +5 -0
  68. package/lib/es/components/charts/Line.js +1 -9
  69. package/lib/es/components/charts/LineChart.d.ts +2 -0
  70. package/lib/es/components/charts/LineChart.js +7 -4
  71. package/lib/es/components/charts/PieChart.js +4 -4
  72. package/lib/es/components/charts/RadialBarChart.js +4 -4
  73. package/lib/es/components/charts/ReferenceLine.d.ts +7 -0
  74. package/lib/es/components/charts/ReferenceLine.js +4 -0
  75. package/lib/es/components/dialog/Dialog.d.ts +12 -4
  76. package/lib/es/components/dialog/SplitDialog.d.ts +3 -3
  77. package/lib/es/components/groupedItemList/GroupedItemList.d.ts +79 -0
  78. package/lib/es/components/groupedItemList/GroupedItemList.js +80 -0
  79. package/lib/es/components/licensePlate/LicensePlate.d.ts +19 -0
  80. package/lib/es/components/licensePlate/LicensePlate.js +16 -0
  81. package/lib/es/components/selects/BaseSelectDropdown.d.ts +1 -0
  82. package/lib/es/components/selects/BaseSelectDropdown.js +16 -14
  83. package/lib/es/components/selects/Multiselect.d.ts +5 -0
  84. package/lib/es/components/selects/Multiselect.js +2 -2
  85. package/lib/es/components/selects/Select.d.ts +5 -0
  86. package/lib/es/components/selects/Select.js +2 -2
  87. package/lib/es/hooks/useKey.d.ts +7 -4
  88. package/lib/es/hooks/useKey.js +35 -7
  89. package/lib/es/utils/colorScheme.js +10 -8
  90. package/lib/es/version.json +1 -1
  91. package/package.json +11 -11
  92. package/utils/colorScheme.js +10 -8
  93. package/version.json +1 -1
@@ -0,0 +1,79 @@
1
+ import React from 'react';
2
+ import { SortDirectionType } from '../../SortUtils';
3
+ export type Group = {
4
+ groupKey: string;
5
+ items: any[];
6
+ };
7
+ export type GroupedItemListProps<T> = {
8
+ /**
9
+ * The list of items to be grouped and rendered.
10
+ *
11
+ * By default, the component assumes an item object containing an 'id' and 'name' property
12
+ * plus some other attributes.
13
+ */
14
+ items: T[];
15
+ /**
16
+ * The property of the items to group by as a string, or a custom group function.
17
+ * Defaults to 'name' if not provided.
18
+ *
19
+ * @default 'name'
20
+ */
21
+ groupBy?: keyof T | ((item: T) => string);
22
+ /**
23
+ * The order in which to sort the groups. Accepts 'asc' for ascending or 'desc' for descending.
24
+ * @default 'asc'.
25
+ */
26
+ groupSortOrder?: SortDirectionType;
27
+ /**
28
+ * The order in which to sort the items inside a group. Accepts 'asc' for ascending or 'desc' for descending.
29
+ * @default 'asc'.
30
+ */
31
+ itemSortOrder?: SortDirectionType;
32
+ /**
33
+ * Sorting function for the groups.
34
+ */
35
+ groupSortFunction?: (groups: Group[]) => Group[];
36
+ /**
37
+ * Sorting function for the items within each group.
38
+ */
39
+ itemSortFunction?: (items: T[]) => T[];
40
+ /**
41
+ * A custom render function for the group divider.
42
+ * Receives the group key (e.g., letter or date) as a parameter.
43
+ */
44
+ renderDivider?: (groupKey: string) => React.ReactNode;
45
+ /**
46
+ * A custom render function for individual list items.
47
+ * Receives an item as a parameter.
48
+ */
49
+ renderItem?: (item: T) => React.ReactNode;
50
+ /**
51
+ * Specifies the HTML element to use for the list inside each group.
52
+ * Default is 'div'. Use 'ul' for rendering the list items as `<li>` elements.
53
+ */
54
+ listElement?: 'div' | 'ul';
55
+ /**
56
+ * Optional class name for the list element inside each group.
57
+ * Applied to the `div` or `ul` wrapping the items.
58
+ */
59
+ listElementClassName?: string;
60
+ /**
61
+ * Optional class name for the divider element in each group.
62
+ * Applied to the `div` wrapping each group divider.
63
+ */
64
+ dividerElementClassName?: string;
65
+ /**
66
+ * Optional class name for the outer wrapper element.
67
+ * Applied to the outer `div` wrapping the entire component.
68
+ */
69
+ className?: string;
70
+ };
71
+ /**
72
+ * A React component that groups and renders a list of items based on a specified property.
73
+ * The component can be customized to render dividers and list items in different styles.
74
+ *
75
+ * @param {GroupedItemListProps} props - The props for the component.
76
+ * @returns {JSX.Element} The grouped and rendered list component.
77
+ */
78
+ declare const GroupedItemList: <T>(props: GroupedItemListProps<T>) => import("react/jsx-runtime").JSX.Element;
79
+ export default GroupedItemList;
@@ -0,0 +1,77 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useMemo } from 'react';
3
+ import { naturalSortByProperty, sortByProperty } from '../../SortUtils';
4
+ /**
5
+ * A React component that groups and renders a list of items based on a specified property.
6
+ * The component can be customized to render dividers and list items in different styles.
7
+ *
8
+ * @param {GroupedItemListProps} props - The props for the component.
9
+ * @returns {JSX.Element} The grouped and rendered list component.
10
+ */
11
+ const GroupedItemList = (props) => {
12
+ const { items, groupBy = 'name', groupSortOrder = 'asc', // Default to ascending order if not specified
13
+ groupSortFunction, itemSortFunction, itemSortOrder = 'asc', // Default to ascending order if not specified
14
+ renderDivider, renderItem, listElement = 'div', // Default to 'div' if not specified
15
+ listElementClassName, dividerElementClassName, className, } = props;
16
+ // Default group sorting function or specific function provided
17
+ const groupSortFn = groupSortFunction
18
+ ? groupSortFunction
19
+ : (groups) => naturalSortByProperty(groups, 'groupKey', groupSortOrder);
20
+ // Default item sorting within groups or specific function provided
21
+ const itemSortFn = itemSortFunction
22
+ ? itemSortFunction
23
+ : (itemsToSort) => sortByProperty(itemsToSort, groupBy, itemSortOrder);
24
+ // Determine the grouping function based on the type of groupBy
25
+ // const getGroupKey = (item: T): string => {
26
+ // if (typeof groupBy === 'string') {
27
+ // if (groupBy === 'name') {
28
+ // return (item as any).name?.[0]?.toUpperCase() ?? '';
29
+ // }
30
+ // return (item as any)[groupBy]?.toString() ?? '';
31
+ // } else if (typeof groupBy === 'function') {
32
+ // return groupBy(item);
33
+ // }
34
+ // throw new Error('Please define a "groupBy" property as a string or function.');
35
+ // };
36
+ const getGroupKey = typeof groupBy === 'function'
37
+ ? groupBy
38
+ : (item) => { var _a, _b, _c; return (_c = (_b = (_a = item[groupBy]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toUpperCase()) !== null && _c !== void 0 ? _c : ''; };
39
+ // Group items by the specified property
40
+ // const allGroups = useMemo(
41
+ // () =>
42
+ // items.reduce<Record<string, T[]>>((acc, item) => {
43
+ // const groupKey = getGroupKey(item);
44
+ // if (!acc[groupKey]) {
45
+ // acc[groupKey] = [];
46
+ // }
47
+ // acc[groupKey].push(item);
48
+ // return acc;
49
+ // }, {}),
50
+ // [items, getGroupKey]
51
+ // );
52
+ // Group items by the specified property
53
+ const groupedItems = useMemo(() => {
54
+ // Explicitly typing the accumulator as Record<string, T[]>
55
+ const groups = items.reduce((acc, item) => {
56
+ const groupKey = getGroupKey(item);
57
+ if (!acc[groupKey]) {
58
+ acc[groupKey] = [];
59
+ }
60
+ acc[groupKey].push(item);
61
+ return acc;
62
+ }, {});
63
+ return Object.keys(groups).map(groupKey => ({
64
+ groupKey,
65
+ items: groups[groupKey],
66
+ }));
67
+ }, [items, getGroupKey]);
68
+ // Assign the specified list element ('div' or 'ul')
69
+ const ListElement = listElement;
70
+ // Sort groups using the provided sort function
71
+ const sortedGroups = useMemo(() => groupSortFn(groupedItems), [groupedItems, groupSortFn]);
72
+ return (_jsx("div", Object.assign({ className: `grouped-item-list ${className !== null && className !== void 0 ? className : ''}` }, { children: sortedGroups.map(group => (_jsxs(React.Fragment, { children: [_jsx("div", Object.assign({ className: `group-divider ${dividerElementClassName !== null && dividerElementClassName !== void 0 ? dividerElementClassName : ''}` }, { children: renderDivider ? renderDivider(group.groupKey) : group.groupKey })), _jsx(ListElement, Object.assign({ className: listElementClassName }, { children: itemSortFn(group.items).map(item => {
73
+ var _a;
74
+ return renderItem ? (renderItem(item)) : (_jsx(React.Fragment, { children: _jsx("div", Object.assign({ className: 'item-name' }, { children: item.name })) }, (_a = item.id) !== null && _a !== void 0 ? _a : crypto.randomUUID()));
75
+ }) }))] }, group.groupKey))) })));
76
+ };
77
+ export default GroupedItemList;
@@ -0,0 +1,19 @@
1
+ import { type PropsWithChildren } from 'react';
2
+ export type LicensePlateProps = {
3
+ /**
4
+ * The country code.
5
+ *
6
+ * Should be a string with 1-3 capital letters.
7
+ */
8
+ countryCode?: string;
9
+ /**
10
+ * Whether the EU stars should be hidden.
11
+ */
12
+ hideStars?: boolean;
13
+ /**
14
+ * Additional classes added to the wrapping element.
15
+ */
16
+ className?: string;
17
+ };
18
+ declare const LicensePlate: (props: PropsWithChildren<LicensePlateProps>) => import("react/jsx-runtime").JSX.Element;
19
+ export default LicensePlate;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // @ts-ignore-next-line importsNotUsedAsValues
3
+ import 'react';
4
+ const euStars = (_jsx("svg", Object.assign({ xmlns: 'http://www.w3.org/2000/svg', width: '10', height: '10' }, { children: _jsx("path", { fill: '#FFC200', fillRule: 'nonzero', d: 'M5.143.439H5.6L5.23.71l.141.438L5 .88l-.371.27.14-.438L4.4.439h.459L5 0zm2.198.594h.458l-.37.272.141.44-.371-.271-.372.27.142-.439-.372-.271h.46l.142-.44zm1.607 1.625h.458l-.37.272.141.44-.371-.271-.372.27.142-.438-.371-.272.459-.001.142-.438zm.593 2.208H10l-.37.272.14.44-.37-.272-.372.271.14-.438-.37-.272.46-.001.141-.438zm-.59 2.214h.459l-.37.271.14.44-.37-.271-.372.271.141-.439-.371-.271.46-.001.141-.439zM7.337 8.701h.459l-.371.272.141.44-.371-.27-.371.27.14-.44-.37-.27.459-.002.142-.438zm-2.201.588h.458l-.37.272.141.439-.371-.27-.372.27.142-.439-.372-.271.46-.001.142-.438zM2.938 8.7h.458l-.37.273.141.439-.371-.27-.372.27.141-.44-.37-.27h.459l.142-.44zM1.33 7.083h.458l-.37.272.14.44-.371-.271-.372.27.142-.439-.37-.271h.458l.143-.44zM.743 4.869H1.2l-.37.272.141.439-.371-.27-.372.27.142-.439L0 4.87l.459-.001L.6 4.43zm.581-2.217h.459l-.37.272.14.439-.37-.27-.372.27.14-.439-.37-.271h.459l.142-.44zM2.94 1.03h.459l-.37.272.14.44-.37-.272-.372.271.14-.439-.37-.271.458-.001.143-.439z' }) })));
5
+ const LicensePlate = (props) => {
6
+ const { countryCode, hideStars, className = '', children } = props;
7
+ let letterCount = '';
8
+ if ((countryCode === null || countryCode === void 0 ? void 0 : countryCode.length) === 2)
9
+ letterCount = 'two-letters';
10
+ if ((countryCode === null || countryCode === void 0 ? void 0 : countryCode.length) === 3)
11
+ letterCount = 'three-letters';
12
+ return (_jsx("div", Object.assign({ className: `license-plate ${className}` }, { children: _jsxs("div", Object.assign({ className: 'plate-content' }, { children: [countryCode && (_jsxs("div", Object.assign({ className: 'plate-country' }, { children: [!hideStars && _jsx("span", Object.assign({ className: 'stars' }, { children: euStars })), _jsx("span", Object.assign({ className: `plate-country-code ${letterCount}` }, { children: countryCode }))] }))), _jsx("div", Object.assign({ className: 'plate-number' }, { children: children }))] })) })));
13
+ };
14
+ export default LicensePlate;
@@ -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();
package/hooks/useKey.d.ts CHANGED
@@ -2,9 +2,12 @@ type KeyboardEventType = 'keyup' | 'keydown' | 'keypress';
2
2
  /**
3
3
  * Custom hook to handle keyboard events.
4
4
  *
5
- * @param callback - The callback function to be executed when a keyboard event occurs.
6
- * @param [eventTypes=['keydown']] - The types of keyboard events to listen for.
7
- * @param [node=document] - The DOM node to attach the event listener to (defaults to document).
5
+ * @param keyOrCallback - Either a key string (e.g., 'Enter') or a callback function.
6
+ * @param callbackOrEventTypes - If the first argument is a key, this should be the callback function.
7
+ * If the first argument is a callback, this is an optional array of event types.
8
+ * @param [eventTypesOrNode=['keydown']] - If the first argument is a key, this should be an array of event types.
9
+ * If the first argument is a callback, this is the node (defaults to document).
10
+ * @param [node=document] - Optional DOM node to attach the event listener to (defaults to document).
8
11
  */
9
- declare const useKey: (callback: (event: KeyboardEvent) => void, eventTypes?: KeyboardEventType[], node?: Document) => void;
12
+ declare const useKey: (keyOrCallback: string | ((event: KeyboardEvent) => void), callbackOrEventTypes?: ((event: KeyboardEvent) => void | KeyboardEventType[]) | undefined, eventTypesOrNode?: KeyboardEventType[] | Document, node?: Document | HTMLElement) => void;
10
13
  export default useKey;
package/hooks/useKey.js CHANGED
@@ -1,21 +1,49 @@
1
- import { useEffect } from 'react';
1
+ import { useEffect, useRef } from 'react';
2
2
  /**
3
3
  * Custom hook to handle keyboard events.
4
4
  *
5
- * @param callback - The callback function to be executed when a keyboard event occurs.
6
- * @param [eventTypes=['keydown']] - The types of keyboard events to listen for.
7
- * @param [node=document] - The DOM node to attach the event listener to (defaults to document).
5
+ * @param keyOrCallback - Either a key string (e.g., 'Enter') or a callback function.
6
+ * @param callbackOrEventTypes - If the first argument is a key, this should be the callback function.
7
+ * If the first argument is a callback, this is an optional array of event types.
8
+ * @param [eventTypesOrNode=['keydown']] - If the first argument is a key, this should be an array of event types.
9
+ * If the first argument is a callback, this is the node (defaults to document).
10
+ * @param [node=document] - Optional DOM node to attach the event listener to (defaults to document).
8
11
  */
9
- const useKey = (callback, eventTypes = ['keydown'], node = document) => {
12
+ const useKey = (keyOrCallback, callbackOrEventTypes, eventTypesOrNode = ['keydown'], node = document) => {
13
+ const callbacksRef = useRef([]);
10
14
  useEffect(() => {
15
+ const isKeyMode = typeof keyOrCallback === 'string';
16
+ const callback = isKeyMode
17
+ ? callbackOrEventTypes
18
+ : keyOrCallback;
19
+ const keyHandler = (event) => {
20
+ if (isKeyMode) {
21
+ if (event.key === keyOrCallback) {
22
+ callback(event);
23
+ }
24
+ }
25
+ else {
26
+ callback(event);
27
+ }
28
+ };
29
+ // Register the keyHandler
30
+ callbacksRef.current.push(keyHandler);
31
+ const genericHandler = (event) => {
32
+ for (const callBecky of callbacksRef.current) {
33
+ callBecky(event);
34
+ }
35
+ };
36
+ const eventTypes = Array.isArray(eventTypesOrNode) ? eventTypesOrNode : ['keydown'];
11
37
  for (const eventType of eventTypes) {
12
- node.addEventListener(eventType, callback);
38
+ node.addEventListener(eventType, genericHandler);
13
39
  }
14
40
  return () => {
15
41
  for (const eventType of eventTypes) {
16
- node.removeEventListener(eventType, callback);
42
+ node.removeEventListener(eventType, genericHandler);
17
43
  }
44
+ // Clean up callback reference
45
+ callbacksRef.current = callbacksRef.current.filter(singleCallback => singleCallback !== keyHandler);
18
46
  };
19
- }, [callback]);
47
+ }, [keyOrCallback, callbackOrEventTypes, eventTypesOrNode, node]);
20
48
  };
21
49
  export default useKey;
@@ -0,0 +1,2 @@
1
+ export { default } from './components/charts/ChartLabel';
2
+ export * from './components/charts/ChartLabel';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var ChartLabel_1 = require("./components/charts/ChartLabel");
6
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(ChartLabel_1).default; } });
7
+ tslib_1.__exportStar(require("./components/charts/ChartLabel"), exports);
@@ -0,0 +1,2 @@
1
+ export { default } from './components/charts/ComposedChart';
2
+ export * from './components/charts/ComposedChart';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var ComposedChart_1 = require("./components/charts/ComposedChart");
6
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(ComposedChart_1).default; } });
7
+ tslib_1.__exportStar(require("./components/charts/ComposedChart"), exports);
@@ -0,0 +1,2 @@
1
+ export { default } from './components/groupedItemList/GroupedItemList';
2
+ export * from './components/groupedItemList/GroupedItemList';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var GroupedItemList_1 = require("./components/groupedItemList/GroupedItemList");
6
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(GroupedItemList_1).default; } });
7
+ tslib_1.__exportStar(require("./components/groupedItemList/GroupedItemList"), exports);
@@ -0,0 +1,2 @@
1
+ export { default } from './components/licensePlate/LicensePlate';
2
+ export * from './components/licensePlate/LicensePlate';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var LicensePlate_1 = require("./components/licensePlate/LicensePlate");
6
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(LicensePlate_1).default; } });
7
+ tslib_1.__exportStar(require("./components/licensePlate/LicensePlate"), exports);
@@ -0,0 +1,2 @@
1
+ export { default } from './components/charts/ReferenceLine';
2
+ export * from './components/charts/ReferenceLine';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var ReferenceLine_1 = require("./components/charts/ReferenceLine");
6
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(ReferenceLine_1).default; } });
7
+ tslib_1.__exportStar(require("./components/charts/ReferenceLine"), exports);
@@ -17,16 +17,20 @@ const TreeOptions = (props) => {
17
17
  const customDropdown = (0, jsx_runtime_1.jsx)("div", Object.assign({ className: dropdownClasses }, { children: treeOptions }));
18
18
  const dropdown = ((0, jsx_runtime_1.jsx)(ButtonDropdown_1.default, { title: (0, jsx_runtime_1.jsx)("span", { className: 'rioglyph rioglyph-option-vertical', "aria-hidden": 'true' }), bsStyle: 'default', bsSize: 'sm', customDropdown: customDropdown, toggleClassName: 'hover-bg-white border-none text-color-gray hover-text-color-dark', className: 'TreeHeaderOptions height-20', pullRight: true, iconOnly: true }));
19
19
  if (treeOptionsTooltip) {
20
- return ((0, jsx_runtime_1.jsx)(SimpleTooltip_1.default, Object.assign({ content: treeOptionsTooltip, placement: 'bottom', delay: { show: 1000, hide: 0 }, popperConfig: {
20
+ return ((0, jsx_runtime_1.jsx)(SimpleTooltip_1.default, Object.assign({ content: treeOptionsTooltip, placement: 'bottom-end', delay: { show: 1000, hide: 0 }, popperConfig: {
21
21
  modifiers: [
22
22
  {
23
23
  name: 'offset',
24
24
  options: {
25
- offset: [-20, 10],
25
+ offset: [10, 5],
26
26
  },
27
27
  },
28
+ {
29
+ name: 'arrow',
30
+ options: {},
31
+ },
28
32
  ],
29
- } }, { children: dropdown })));
33
+ } }, { children: (0, jsx_runtime_1.jsx)("div", { children: dropdown }) })));
30
34
  }
31
35
  return dropdown;
32
36
  };
@@ -2,6 +2,11 @@
2
2
  import type { AreaProps as RechartsAreaProps } from 'recharts';
3
3
  export type AreaProps = Omit<RechartsAreaProps, 'ref'> & {
4
4
  strokeColor?: string;
5
+ dataKey?: string;
6
+ unit?: string;
7
+ legendType?: string;
8
+ type?: string;
9
+ isAnimationActive?: boolean;
5
10
  };
6
11
  declare const Area: React.FC<AreaProps>;
7
12
  export default Area;
@@ -1,12 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Area = () => null;
4
- Area.defaultProps = {
5
- dataKey: 'value',
6
- unit: '',
7
- strokeColor: 'color-coldplay-fountain',
8
- legendType: 'square',
9
- type: 'monotone',
10
- isAnimationActive: true,
11
- };
3
+ const Area = ({ dataKey = 'value', unit = '', strokeColor = 'color-coldplay-fountain', legendType = 'square', type = 'monotone', isAnimationActive = true, }) => null;
12
4
  exports.default = Area;
@@ -6,6 +6,7 @@ import { type LegendProps } from './Legend';
6
6
  import type { AreaProps } from './Area';
7
7
  import type { GridProps } from './ChartGrid';
8
8
  import type { ResponsiveContainerProps } from './ResponsiveContainer';
9
+ import type { ReferenceLineProps } from './ReferenceLine';
9
10
  type RechartsAreaChartProps = React.ComponentProps<typeof RechartsAreaChart>;
10
11
  export type AreaChartProps<T extends object> = Omit<RechartsAreaChartProps, 'data'> & {
11
12
  width?: number;
@@ -15,6 +16,7 @@ export type AreaChartProps<T extends object> = Omit<RechartsAreaChartProps, 'dat
15
16
  dataKey?: string | number | ((obj: T) => any);
16
17
  gradients?: React.ReactElement<AreaGradientProps>[];
17
18
  areas: React.ReactElement<AreaProps>[];
19
+ referenceLines?: React.ReactElement<ReferenceLineProps>[];
18
20
  xAxisOptions?: XAxisProps;
19
21
  yAxisOptions?: YAxisProps;
20
22
  gridOptions?: GridProps;
@@ -10,9 +10,9 @@ const isObject_1 = tslib_1.__importDefault(require("lodash/fp/isObject"));
10
10
  const chartHelper_1 = require("./chartHelper");
11
11
  const AreaGradient_1 = tslib_1.__importStar(require("./AreaGradient"));
12
12
  const ChartTooltip_1 = tslib_1.__importDefault(require("./ChartTooltip"));
13
- const Legend_1 = tslib_1.__importDefault(require("./Legend"));
13
+ const Legend_1 = require("./Legend");
14
14
  const AreaChart = (props) => {
15
- const { width, height, data = [], dataUnit = '', dataKey = 'value', gradients = [], areas = [], xAxisOptions, yAxisOptions, gridOptions, containerOptions, showXAxis = true, showYAxis = false, showGrid = false, legend, brush = false, tooltip = true } = props, remainingProps = tslib_1.__rest(props, ["width", "height", "data", "dataUnit", "dataKey", "gradients", "areas", "xAxisOptions", "yAxisOptions", "gridOptions", "containerOptions", "showXAxis", "showYAxis", "showGrid", "legend", "brush", "tooltip"]);
15
+ const { width, height, data = [], dataUnit = '', dataKey = 'value', gradients = [], areas = [], referenceLines = [], xAxisOptions, yAxisOptions, gridOptions, containerOptions, showXAxis = true, showYAxis = false, showGrid = false, legend, brush = false, tooltip = true } = props, remainingProps = tslib_1.__rest(props, ["width", "height", "data", "dataUnit", "dataKey", "gradients", "areas", "referenceLines", "xAxisOptions", "yAxisOptions", "gridOptions", "containerOptions", "showXAxis", "showYAxis", "showGrid", "legend", "brush", "tooltip"]);
16
16
  const areasWithGradient = areas.map(area => {
17
17
  const _a = area.props, { strokeColor } = _a, remainingAreaProps = tslib_1.__rest(_a, ["strokeColor"]);
18
18
  const gradientId = area.key;
@@ -23,7 +23,10 @@ const AreaChart = (props) => {
23
23
  };
24
24
  });
25
25
  const tooltipProps = (0, isObject_1.default)(tooltip) ? tooltip.props : {};
26
- const legendProps = (0, isObject_1.default)(legend) ? legend.props : {};
27
- return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, Object.assign({}, containerOptions, { children: (0, jsx_runtime_1.jsxs)(recharts_1.AreaChart, Object.assign({ width: width, height: height, data: data, margin: { top: 15, right: 15, left: 15, bottom: 15 } }, remainingProps, { children: [(0, jsx_runtime_1.jsxs)("defs", { children: [gradients, areasWithGradient.map(areaWithGradient => areaWithGradient.gradient)] }), showGrid && (0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, Object.assign({ strokeDasharray: '3 3' }, (0, chartHelper_1.mapGridOptions)(gridOptions))), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, Object.assign({ hide: !showXAxis, dataKey: dataKey }, xAxisOptions)), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, Object.assign({ hide: !showYAxis, unit: dataUnit }, yAxisOptions)), tooltip && (0, jsx_runtime_1.jsx)(ChartTooltip_1.default, Object.assign({}, tooltipProps)), legend && (0, jsx_runtime_1.jsx)(Legend_1.default, Object.assign({}, legendProps)), areasWithGradient.map(areaWithGradient => areaWithGradient.area), brush && (0, jsx_runtime_1.jsx)(recharts_1.Brush, { stroke: (0, chartHelper_1.getColor)('gray') })] })) })));
26
+ const legendProps = (0, isObject_1.default)(legend) ? Object.assign(Object.assign({}, (0, Legend_1.getLegendDefaultProps)()), legend.props) : {};
27
+ return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, Object.assign({}, containerOptions, { children: (0, jsx_runtime_1.jsxs)(recharts_1.AreaChart, Object.assign({ width: width, height: height, data: data, margin: { top: 15, right: 15, left: 15, bottom: 15 } }, remainingProps, { children: [(0, jsx_runtime_1.jsxs)("defs", { children: [gradients, areasWithGradient.map(areaWithGradient => areaWithGradient.gradient)] }), showGrid && (0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, Object.assign({ strokeDasharray: '3 3' }, (0, chartHelper_1.mapGridOptions)(gridOptions))), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, Object.assign({ hide: !showXAxis, dataKey: dataKey }, xAxisOptions)), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, Object.assign({ hide: !showYAxis, unit: dataUnit }, yAxisOptions)), tooltip && (0, jsx_runtime_1.jsx)(ChartTooltip_1.default, Object.assign({}, tooltipProps)), legend && legendProps && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(recharts_1.Legend, Object.assign({ wrapperStyle: legendProps.verticalAlign === 'bottom' ? { bottom: 0 } : legendProps.wrapperStyle }, legendProps)) })), areasWithGradient.map(areaWithGradient => areaWithGradient.area), referenceLines.map(referenceLine => {
28
+ const _a = referenceLine.props, { stroke } = _a, remainingReferenceLineProps = tslib_1.__rest(_a, ["stroke"]);
29
+ return ((0, react_1.createElement)(recharts_1.ReferenceLine, Object.assign({}, remainingReferenceLineProps, { key: referenceLine.key, stroke: (0, chartHelper_1.getColor)(stroke) })));
30
+ }), brush && (0, jsx_runtime_1.jsx)(recharts_1.Brush, { stroke: (0, chartHelper_1.getColor)('gray') })] })) })));
28
31
  };
29
32
  exports.default = AreaChart;
@@ -9,11 +9,11 @@ const isFunction_1 = tslib_1.__importDefault(require("lodash/fp/isFunction"));
9
9
  const isObject_1 = tslib_1.__importDefault(require("lodash/fp/isObject"));
10
10
  const chartHelper_1 = require("./chartHelper");
11
11
  const ChartTooltip_1 = tslib_1.__importDefault(require("./ChartTooltip"));
12
- const Legend_1 = tslib_1.__importDefault(require("./Legend"));
12
+ const Legend_1 = require("./Legend");
13
13
  const BarChart = (props) => {
14
14
  const { width, height, data = [], dataUnit, dataKey = 'value', layout = 'horizontal', legend = false, bars = [], xAxisOptions, yAxisOptions, gridOptions, containerOptions, showGrid = false, showXAxis = true, showYAxis = true, useDataColors = false, brush = false, tooltip = true } = props, remainingProps = tslib_1.__rest(props, ["width", "height", "data", "dataUnit", "dataKey", "layout", "legend", "bars", "xAxisOptions", "yAxisOptions", "gridOptions", "containerOptions", "showGrid", "showXAxis", "showYAxis", "useDataColors", "brush", "tooltip"]);
15
15
  const tooltipProps = (0, isObject_1.default)(tooltip) ? tooltip.props : {};
16
- const legendProps = (0, isObject_1.default)(legend) ? legend.props : {};
16
+ const legendProps = (0, isObject_1.default)(legend) ? Object.assign(Object.assign({}, (0, Legend_1.getLegendDefaultProps)()), legend.props) : {};
17
17
  let legendPayload;
18
18
  if (useDataColors) {
19
19
  legendPayload = data.map((entry, index) => {
@@ -21,7 +21,7 @@ const BarChart = (props) => {
21
21
  return Object.assign(Object.assign({}, entry), { value: (0, isFunction_1.default)(dataKey) ? dataKey(entry) : entry[dataKey], color: legendColor });
22
22
  });
23
23
  }
24
- return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, Object.assign({}, containerOptions, { children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, Object.assign({ layout: layout, width: width, height: height, data: data }, remainingProps, { children: [showGrid && (0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, Object.assign({ strokeDasharray: '3 3' }, (0, chartHelper_1.mapGridOptions)(gridOptions))), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, Object.assign({ hide: !showXAxis, dataKey: dataKey }, xAxisOptions)), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, Object.assign({ hide: !showYAxis, unit: dataUnit }, yAxisOptions)), legend && (0, jsx_runtime_1.jsx)(Legend_1.default, Object.assign({}, legendProps, { payload: legendPayload })), tooltip && (0, jsx_runtime_1.jsx)(ChartTooltip_1.default, Object.assign({ cursor: { fill: chartHelper_1.CURSOR_BACKGROUND_COLOR } }, tooltipProps)), bars.map(bar => {
24
+ return ((0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, Object.assign({}, containerOptions, { children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, Object.assign({ layout: layout, width: width, height: height, data: data }, remainingProps, { children: [showGrid && (0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, Object.assign({ strokeDasharray: '3 3' }, (0, chartHelper_1.mapGridOptions)(gridOptions))), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, Object.assign({ hide: !showXAxis, dataKey: dataKey }, xAxisOptions)), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, Object.assign({ hide: !showYAxis, unit: dataUnit }, yAxisOptions)), tooltip && (0, jsx_runtime_1.jsx)(ChartTooltip_1.default, Object.assign({ cursor: { fill: chartHelper_1.CURSOR_BACKGROUND_COLOR } }, tooltipProps)), legend && (0, jsx_runtime_1.jsx)(recharts_1.Legend, Object.assign({ payload: useDataColors ? legendPayload : undefined }, legendProps)), bars.map(bar => {
25
25
  const _a = bar.props, { color } = _a, remainingBarProps = tslib_1.__rest(_a, ["color"]);
26
26
  const cellColor = color && (0, chartHelper_1.getColor)(color);
27
27
  return ((0, jsx_runtime_1.jsx)(recharts_1.Bar, Object.assign({ unit: dataUnit }, remainingBarProps, { fill: cellColor }, { children: useDataColors &&
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import type { LabelProps as RechartsLabelProps } from 'recharts';
3
+ export type LabelProps = Omit<RechartsLabelProps, 'ref'> & {};
4
+ declare const ChartLabel: React.FC<LabelProps>;
5
+ export default ChartLabel;