@rio-cloud/rio-uikit 1.4.0 → 1.5.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/FadeExpander.d.ts +2 -0
- package/FadeExpander.js +2 -0
- package/FadeUp.d.ts +2 -0
- package/FadeUp.js +2 -0
- package/XAxis.d.ts +2 -0
- package/XAxis.js +2 -0
- package/YAxis.d.ts +2 -0
- package/YAxis.js +2 -0
- package/components/applicationLayout/ApplicationLayoutBody.d.ts +5 -0
- package/components/applicationLayout/ApplicationLayoutBody.js +10 -1
- package/components/charts/Area.d.ts +11 -3
- package/components/charts/Area.js +9 -1
- package/components/charts/AreaChart.d.ts +4 -3
- package/components/charts/AreaChart.js +9 -8
- package/components/charts/Bar.d.ts +6 -2
- package/components/charts/Bar.js +3 -4
- package/components/charts/BarChart.d.ts +2 -1
- package/components/charts/BarChart.js +8 -4
- package/components/charts/ComposedChart.d.ts +6 -5
- package/components/charts/ComposedChart.js +16 -11
- package/components/charts/Legend.js +1 -1
- package/components/charts/Line.d.ts +11 -3
- package/components/charts/Line.js +9 -1
- package/components/charts/LineChart.d.ts +6 -4
- package/components/charts/LineChart.js +10 -9
- package/components/charts/ReferenceLine.d.ts +8 -4
- package/components/charts/ReferenceLine.js +18 -2
- package/components/charts/XAxis.d.ts +7 -0
- package/components/charts/XAxis.js +18 -0
- package/components/charts/YAxis.d.ts +5 -0
- package/components/charts/YAxis.js +2 -0
- package/components/collapse/Collapse.js +3 -2
- package/components/dropdown/ButtonDropdown.d.ts +3 -1
- package/components/dropdown/ButtonDropdown.js +6 -5
- package/components/dropdown/DropdownToggleButton.d.ts +1 -0
- package/components/dropdown/DropdownToggleButton.js +4 -2
- package/components/fade/FadeExpander.d.ts +27 -0
- package/components/fade/FadeExpander.js +41 -0
- package/components/fade/FadeUp.d.ts +27 -0
- package/components/fade/FadeUp.js +28 -0
- package/components/listMenu/ListMenu.d.ts +7 -0
- package/components/listMenu/ListMenu.js +6 -3
- package/components/map/components/features/Route.d.ts +13 -2
- package/components/map/components/features/Route.js +19 -11
- package/components/map/components/features/basics/Polygon.d.ts +1 -0
- package/components/map/components/features/basics/Polygon.js +1 -0
- package/components/map/components/features/basics/Polyline.d.ts +3 -1
- package/components/map/components/features/basics/Polyline.js +5 -16
- package/components/map/components/features/basics/polygonColors.d.ts +252 -0
- package/components/map/components/features/basics/polygonColors.js +252 -0
- package/components/map/utils/mapTypes.d.ts +1 -1
- package/components/map/utils/mapTypes.js +2 -0
- package/components/mapMarker/SingleMapMarker.d.ts +3 -2
- package/components/mapMarker/SingleMapMarker.js +3 -3
- package/components/selects/BaseSelectDropdown.d.ts +0 -1
- package/components/selects/BaseSelectDropdown.js +7 -1
- package/components/selects/Multiselect.js +1 -4
- package/components/selects/Select.d.ts +1 -1
- package/components/selects/Select.js +1 -4
- package/components/smoothScrollbars/SmoothScrollbars.js +28 -3
- package/components/switch/Switch.d.ts +6 -5
- package/components/switch/Switch.js +5 -5
- package/components/tag/Tag.d.ts +2 -2
- package/components/tag/Tag.js +5 -6
- package/hooks/useDOMNodeCount.d.ts +2 -0
- package/hooks/useDOMNodeCount.js +29 -0
- package/hooks/useEventListenerCount.d.ts +5 -0
- package/hooks/useEventListenerCount.js +42 -0
- package/hooks/useSorting.d.ts +29 -0
- package/hooks/useSorting.js +41 -0
- package/lib/es/FadeExpander.d.ts +2 -0
- package/lib/es/FadeExpander.js +7 -0
- package/lib/es/FadeUp.d.ts +2 -0
- package/lib/es/FadeUp.js +7 -0
- package/lib/es/XAxis.d.ts +2 -0
- package/lib/es/XAxis.js +7 -0
- package/lib/es/YAxis.d.ts +2 -0
- package/lib/es/YAxis.js +7 -0
- package/lib/es/components/applicationLayout/ApplicationLayoutBody.d.ts +5 -0
- package/lib/es/components/applicationLayout/ApplicationLayoutBody.js +10 -1
- package/lib/es/components/charts/Area.d.ts +11 -3
- package/lib/es/components/charts/Area.js +11 -1
- package/lib/es/components/charts/AreaChart.d.ts +4 -3
- package/lib/es/components/charts/AreaChart.js +8 -7
- package/lib/es/components/charts/Bar.d.ts +6 -2
- package/lib/es/components/charts/Bar.js +5 -4
- package/lib/es/components/charts/BarChart.d.ts +2 -1
- package/lib/es/components/charts/BarChart.js +7 -3
- package/lib/es/components/charts/ComposedChart.d.ts +6 -5
- package/lib/es/components/charts/ComposedChart.js +15 -10
- package/lib/es/components/charts/Legend.js +1 -1
- package/lib/es/components/charts/Line.d.ts +11 -3
- package/lib/es/components/charts/Line.js +11 -1
- package/lib/es/components/charts/LineChart.d.ts +6 -4
- package/lib/es/components/charts/LineChart.js +9 -8
- package/lib/es/components/charts/ReferenceLine.d.ts +8 -4
- package/lib/es/components/charts/ReferenceLine.js +21 -2
- package/lib/es/components/charts/XAxis.d.ts +7 -0
- package/lib/es/components/charts/XAxis.js +23 -0
- package/lib/es/components/charts/YAxis.d.ts +5 -0
- package/lib/es/components/charts/YAxis.js +4 -0
- package/lib/es/components/collapse/Collapse.js +3 -2
- package/lib/es/components/dropdown/ButtonDropdown.d.ts +3 -1
- package/lib/es/components/dropdown/ButtonDropdown.js +5 -4
- package/lib/es/components/dropdown/DropdownToggleButton.d.ts +1 -0
- package/lib/es/components/dropdown/DropdownToggleButton.js +4 -2
- package/lib/es/components/fade/FadeExpander.d.ts +27 -0
- package/lib/es/components/fade/FadeExpander.js +43 -0
- package/lib/es/components/fade/FadeUp.d.ts +27 -0
- package/lib/es/components/fade/FadeUp.js +30 -0
- package/lib/es/components/listMenu/ListMenu.d.ts +7 -0
- package/lib/es/components/listMenu/ListMenu.js +6 -3
- package/lib/es/components/map/components/features/Route.d.ts +13 -2
- package/lib/es/components/map/components/features/Route.js +20 -12
- package/lib/es/components/map/components/features/basics/Polygon.d.ts +1 -0
- package/lib/es/components/map/components/features/basics/Polygon.js +10 -0
- package/lib/es/components/map/components/features/basics/Polyline.d.ts +3 -1
- package/lib/es/components/map/components/features/basics/Polyline.js +5 -16
- package/lib/es/components/map/components/features/basics/polygonColors.d.ts +252 -0
- package/lib/es/components/map/components/features/basics/polygonColors.js +255 -0
- package/lib/es/components/map/utils/mapTypes.d.ts +1 -1
- package/lib/es/components/map/utils/mapTypes.js +2 -0
- package/lib/es/components/mapMarker/SingleMapMarker.d.ts +3 -2
- package/lib/es/components/mapMarker/SingleMapMarker.js +3 -3
- package/lib/es/components/selects/BaseSelectDropdown.d.ts +0 -1
- package/lib/es/components/selects/BaseSelectDropdown.js +6 -0
- package/lib/es/components/selects/Multiselect.js +1 -4
- package/lib/es/components/selects/Select.d.ts +1 -1
- package/lib/es/components/selects/Select.js +1 -4
- package/lib/es/components/smoothScrollbars/SmoothScrollbars.js +27 -2
- package/lib/es/components/switch/Switch.d.ts +6 -5
- package/lib/es/components/switch/Switch.js +5 -5
- package/lib/es/components/tag/Tag.d.ts +2 -2
- package/lib/es/components/tag/Tag.js +5 -6
- package/lib/es/hooks/useDOMNodeCount.d.ts +2 -0
- package/lib/es/hooks/useDOMNodeCount.js +31 -0
- package/lib/es/hooks/useEventListenerCount.d.ts +5 -0
- package/lib/es/hooks/useEventListenerCount.js +45 -0
- package/lib/es/hooks/useSorting.d.ts +29 -0
- package/lib/es/hooks/useSorting.js +43 -0
- package/lib/es/storageUtils.d.ts +1 -0
- package/lib/es/storageUtils.js +4 -0
- package/lib/es/styles/variables/colors/colors.json +4 -3
- package/lib/es/urlFeatureToggles.d.ts +1 -0
- package/lib/es/urlFeatureToggles.js +4 -0
- package/lib/es/useDOMNodeCount.d.ts +2 -0
- package/lib/es/useDOMNodeCount.js +7 -0
- package/lib/es/useEventListenerCount.d.ts +2 -0
- package/lib/es/useEventListenerCount.js +7 -0
- package/lib/es/useSorting.d.ts +2 -0
- package/lib/es/useSorting.js +7 -0
- package/lib/es/utils/storageUtils.d.ts +5 -0
- package/lib/es/utils/storageUtils.js +32 -0
- package/lib/es/utils/urlFeatureToggles.d.ts +10 -0
- package/lib/es/utils/urlFeatureToggles.js +41 -0
- package/lib/es/version.json +1 -1
- package/package.json +4 -1
- package/storageUtils.d.ts +1 -0
- package/storageUtils.js +1 -0
- package/styles/variables/colors/colors.json +4 -3
- package/urlFeatureToggles.d.ts +1 -0
- package/urlFeatureToggles.js +1 -0
- package/useDOMNodeCount.d.ts +2 -0
- package/useDOMNodeCount.js +2 -0
- package/useEventListenerCount.d.ts +2 -0
- package/useEventListenerCount.js +2 -0
- package/useSorting.d.ts +2 -0
- package/useSorting.js +2 -0
- package/utils/storageUtils.d.ts +5 -0
- package/utils/storageUtils.js +29 -0
- package/utils/urlFeatureToggles.d.ts +10 -0
- package/utils/urlFeatureToggles.js +32 -0
- package/version.json +1 -1
|
@@ -1,17 +1,42 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
// @ts-ignore-next-line importsNotUsedAsValues
|
|
3
|
-
import { forwardRef } from 'react';
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef, } from 'react';
|
|
4
4
|
import { Scrollbars } from 'react-custom-scrollbars-2';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import noop from 'lodash/fp/noop';
|
|
7
|
+
import debounce from 'lodash/fp/debounce';
|
|
8
|
+
const RESIZE_THROTTLING = 100;
|
|
7
9
|
const SmoothScrollbars = forwardRef((componentProps, ref) => {
|
|
8
10
|
const { slideIn = false, largeTrack = false, trackOffset = false, className = '', onScroll = noop, tagName = 'div', autoHeight = false, autoHeightMin = 0, autoHeightMax = 200, children, } = componentProps;
|
|
11
|
+
const scrollbarsRef = useRef(null);
|
|
12
|
+
const contentRef = useRef(null);
|
|
13
|
+
useImperativeHandle(ref, () => scrollbarsRef.current);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!contentRef.current || !scrollbarsRef.current) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const updateScrollbars = debounce(RESIZE_THROTTLING)(() => {
|
|
19
|
+
if (scrollbarsRef.current) {
|
|
20
|
+
// Trigger a update for the scrollbars.
|
|
21
|
+
// This is needed since the lib does not automatically update on content height changes
|
|
22
|
+
// See: https://github.com/RobPethick/react-custom-scrollbars-2/issues/12
|
|
23
|
+
// Use type assertion to tell TypeScript that 'update' exists
|
|
24
|
+
scrollbarsRef.current.update();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const resizeObserver = new ResizeObserver(updateScrollbars);
|
|
28
|
+
resizeObserver.observe(contentRef.current);
|
|
29
|
+
return () => {
|
|
30
|
+
resizeObserver.disconnect();
|
|
31
|
+
updateScrollbars.cancel();
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
9
34
|
const wrapperClassNames = classNames(className, slideIn && 'scrollbar-fly-in', 'smooth-scrollbar-wrapper');
|
|
10
35
|
const renderTrackVerticalNames = classNames('scrollbar-track-vertical', largeTrack && 'scrollbar-track-size-large', trackOffset && 'scrollbar-track-offset');
|
|
11
36
|
const renderThumbVerticalNames = classNames('scrollbar-thumb-vertical', largeTrack && 'scrollbar-thumb-size-large');
|
|
12
37
|
const renderTrackHorizontalNames = classNames('scrollbar-track-horizontal', largeTrack && 'scrollbar-track-size-large', trackOffset && 'scrollbar-track-offset');
|
|
13
38
|
const renderThumbHorizontalNames = classNames('scrollbar-thumb-horizontal', largeTrack && 'scrollbar-thumb-size-large');
|
|
14
|
-
return (_jsx(Scrollbars, Object.assign({ ref:
|
|
39
|
+
return (_jsx(Scrollbars, Object.assign({ ref: scrollbarsRef, tagName: tagName, onScroll: onScroll, className: wrapperClassNames, hideTracksWhenNotNeeded: true, autoHeight: autoHeight, autoHeightMin: autoHeightMin, autoHeightMax: autoHeightMax, renderView: props => {
|
|
15
40
|
return _jsx("div", Object.assign({}, props, { className: 'scrollbar-view' }));
|
|
16
41
|
}, renderTrackVertical: props => {
|
|
17
42
|
return _jsx("div", Object.assign({}, props, { className: renderTrackVerticalNames }));
|
|
@@ -21,6 +46,6 @@ const SmoothScrollbars = forwardRef((componentProps, ref) => {
|
|
|
21
46
|
return _jsx("div", Object.assign({}, props, { className: renderTrackHorizontalNames }));
|
|
22
47
|
}, renderThumbHorizontal: props => {
|
|
23
48
|
return _jsx("div", Object.assign({}, props, { className: renderThumbHorizontalNames }));
|
|
24
|
-
} }, { children: children })));
|
|
49
|
+
} }, { children: _jsx("div", Object.assign({ className: 'scrollbar-content-wrapper', ref: contentRef }, { children: children })) })));
|
|
25
50
|
});
|
|
26
51
|
export default SmoothScrollbars;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { type CurrentColor } from '../../utils/currentColors';
|
|
3
3
|
export type SwitchProps = {
|
|
4
4
|
/**
|
|
@@ -46,9 +46,10 @@ export type SwitchProps = {
|
|
|
46
46
|
*/
|
|
47
47
|
labelPosition?: 'left' | 'right';
|
|
48
48
|
};
|
|
49
|
-
declare const Switch: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
declare const Switch: React.ForwardRefExoticComponent<SwitchProps & {
|
|
50
|
+
children?: React.ReactNode;
|
|
51
|
+
} & React.RefAttributes<HTMLDivElement>> & {
|
|
52
|
+
LABEL_POSITION_LEFT: 'left';
|
|
53
|
+
LABEL_POSITION_RIGHT: 'right';
|
|
53
54
|
};
|
|
54
55
|
export default Switch;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
// @ts-ignore-next-line importsNotUsedAsValues
|
|
4
|
-
import 'react';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import noop from 'lodash/fp/noop';
|
|
7
7
|
import { getCurrentBackgroundColor } from '../../utils/currentColors';
|
|
8
|
-
const Switch = (props) => {
|
|
9
|
-
const { keyName, checked = false, enabledText, minWidth = 40, disabled = false, color = 'primary', disabledText, children, labelPosition =
|
|
8
|
+
const Switch = forwardRef((props, ref) => {
|
|
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"]);
|
|
10
10
|
const handleChange = (event) => {
|
|
11
11
|
onChange(event.target.checked);
|
|
12
12
|
};
|
|
@@ -17,8 +17,8 @@ const Switch = (props) => {
|
|
|
17
17
|
// !hasMultipleText && !hasSingleText && 'width-40'
|
|
18
18
|
);
|
|
19
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] })) })));
|
|
21
|
-
};
|
|
20
|
+
return (_jsx("div", Object.assign({ ref: ref }, 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] })) })));
|
|
21
|
+
});
|
|
22
22
|
Switch.LABEL_POSITION_LEFT = 'left';
|
|
23
23
|
Switch.LABEL_POSITION_RIGHT = 'right';
|
|
24
24
|
export default Switch;
|
package/components/tag/Tag.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export type TagProps = {
|
|
3
3
|
/**
|
|
4
4
|
* Defines if the tag is active.
|
|
@@ -65,5 +65,5 @@ export type TagProps = {
|
|
|
65
65
|
*/
|
|
66
66
|
className?: string;
|
|
67
67
|
};
|
|
68
|
-
declare const Tag:
|
|
68
|
+
declare const Tag: React.ForwardRefExoticComponent<Omit<React.PropsWithChildren<TagProps>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
69
69
|
export default Tag;
|
package/components/tag/Tag.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
// @ts-ignore-next-line importsNotUsedAsValues
|
|
4
|
-
import 'react';
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
const Tag = (props) => {
|
|
6
|
+
const Tag = forwardRef((props, ref) => {
|
|
7
7
|
const { children, icon, active = false, disabled = false, clickable = false, selectable = false, deletable = false, revertable = false, multiline = false, muted = false, round = true, size, className } = props, remainingProps = __rest(props, ["children", "icon", "active", "disabled", "clickable", "selectable", "deletable", "revertable", "multiline", "muted", "round", "size", "className"]);
|
|
8
|
-
const tagClasses = classNames('tag', size === 'small' && 'tag-small', icon && `rioglyph ${icon}`, active && 'active clickable rioglyph rioglyph-ok', disabled && 'disabled', clickable && 'clickable', selectable && 'selectable clickable rioglyph rioglyph-checkbox', deletable && 'deletable clickable rioglyph rioglyph-remove', revertable && 'revertable clickable rioglyph rioglyph-revert', multiline && 'multiline', muted && 'tag-muted', !round && 'rounded',
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
8
|
+
const tagClasses = classNames('tag', size === 'small' && 'tag-small', icon && `rioglyph ${icon}`, active && 'active clickable rioglyph rioglyph-ok', disabled && 'disabled', clickable && 'clickable', selectable && 'selectable clickable rioglyph rioglyph-checkbox', deletable && 'deletable clickable rioglyph rioglyph-remove', revertable && 'revertable clickable rioglyph rioglyph-revert', multiline && 'multiline', muted && 'tag-muted', !round && 'rounded', className);
|
|
9
|
+
return (_jsx("div", Object.assign({ ref: ref }, remainingProps, { className: tagClasses }, { children: _jsx("div", Object.assign({ className: 'tag-inner' }, { children: children })) })));
|
|
10
|
+
});
|
|
12
11
|
export default Tag;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
const useDOMNodeCount = () => {
|
|
3
|
+
const [nodeCount, setNodeCount] = useState(0);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const countNodes = () => {
|
|
6
|
+
const body = document.body;
|
|
7
|
+
if (body) {
|
|
8
|
+
setNodeCount(body.getElementsByTagName('*').length);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
// Initial count
|
|
12
|
+
countNodes();
|
|
13
|
+
// Create a MutationObserver to watch for changes in the DOM
|
|
14
|
+
const observer = new MutationObserver(() => {
|
|
15
|
+
countNodes();
|
|
16
|
+
});
|
|
17
|
+
// Observe the body element for changes in the child list or subtree
|
|
18
|
+
observer.observe(document.body, {
|
|
19
|
+
childList: true,
|
|
20
|
+
subtree: true,
|
|
21
|
+
});
|
|
22
|
+
// Cleanup on unmount
|
|
23
|
+
return () => {
|
|
24
|
+
observer.disconnect();
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
return nodeCount;
|
|
28
|
+
};
|
|
29
|
+
export default useDOMNodeCount;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import throttle from 'lodash/fp/throttle';
|
|
3
|
+
const useEventListenerCount = () => {
|
|
4
|
+
const [listenerCounts, setListenerCounts] = useState({});
|
|
5
|
+
const [totalCount, setTotalCount] = useState(0);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
console.log('init useEventListener interceptor');
|
|
8
|
+
const eventListeners = new Set();
|
|
9
|
+
const originalAddEventListener = EventTarget.prototype.addEventListener;
|
|
10
|
+
const originalRemoveEventListener = EventTarget.prototype.removeEventListener;
|
|
11
|
+
const updateListeners = throttle(1000)(() => {
|
|
12
|
+
const counts = Array.from(eventListeners).reduce((acc, { type }) => {
|
|
13
|
+
acc[type] = (acc[type] || 0) + 1;
|
|
14
|
+
return acc;
|
|
15
|
+
}, {});
|
|
16
|
+
setListenerCounts(counts);
|
|
17
|
+
setTotalCount(eventListeners.size);
|
|
18
|
+
});
|
|
19
|
+
EventTarget.prototype.addEventListener = function (type, listener, options) {
|
|
20
|
+
if (listener) {
|
|
21
|
+
eventListeners.add({ type, listener });
|
|
22
|
+
updateListeners();
|
|
23
|
+
}
|
|
24
|
+
originalAddEventListener.call(this, type, listener, options);
|
|
25
|
+
};
|
|
26
|
+
EventTarget.prototype.removeEventListener = function (type, listener, options) {
|
|
27
|
+
eventListeners.forEach(item => {
|
|
28
|
+
if (item.type === type && item.listener === listener) {
|
|
29
|
+
eventListeners.delete(item);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
updateListeners();
|
|
33
|
+
originalRemoveEventListener.call(this, type, listener, options);
|
|
34
|
+
};
|
|
35
|
+
return () => {
|
|
36
|
+
EventTarget.prototype.addEventListener = originalAddEventListener;
|
|
37
|
+
EventTarget.prototype.removeEventListener = originalRemoveEventListener;
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
return { counts: listenerCounts, total: totalCount };
|
|
41
|
+
};
|
|
42
|
+
export default useEventListenerCount;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type SortDirectionType } from '../utils/SortUtils';
|
|
2
|
+
type SortKey<T> = keyof T | [keyof T, keyof T];
|
|
3
|
+
type UseSortingResult<T> = {
|
|
4
|
+
/**
|
|
5
|
+
* The sorted data
|
|
6
|
+
*/
|
|
7
|
+
sortedItems: T[];
|
|
8
|
+
/**
|
|
9
|
+
* The key(s) to sort the data for
|
|
10
|
+
*/
|
|
11
|
+
sortKey: SortKey<T>;
|
|
12
|
+
/**
|
|
13
|
+
* The current direction that the data is sorted
|
|
14
|
+
*/
|
|
15
|
+
sortDirection: SortDirectionType;
|
|
16
|
+
/**
|
|
17
|
+
* Function to change the sorting key(s) afterwards
|
|
18
|
+
* @param newKey the new sorting key(s)
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
setSortKey: (newKey: SortKey<T>) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Function to toggle the sorting between ascending and descending order
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
toggleDirection: () => void;
|
|
27
|
+
};
|
|
28
|
+
declare const useSorting: <T>(items: T[], initialKey: SortKey<T>, initialDirection?: SortDirectionType, enableNaturalSort?: boolean, isCaseSensitive?: boolean) => UseSortingResult<T>;
|
|
29
|
+
export default useSorting;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useState, useMemo } from 'react';
|
|
2
|
+
import { naturalSortByProperty, SortDirection } from '../utils/SortUtils';
|
|
3
|
+
const useSorting = (items, initialKey, initialDirection = SortDirection.ASCENDING, enableNaturalSort = true, isCaseSensitive = false) => {
|
|
4
|
+
const [sortKey, setSortKey] = useState(initialKey);
|
|
5
|
+
const [sortDirection, setSortDirection] = useState(initialDirection);
|
|
6
|
+
const sortedItems = useMemo(() => {
|
|
7
|
+
const sortByKey = (arr, key) => {
|
|
8
|
+
return enableNaturalSort
|
|
9
|
+
? naturalSortByProperty(arr, key, sortDirection, isCaseSensitive)
|
|
10
|
+
: arr.sort((a, b) => {
|
|
11
|
+
const aVal = a[key];
|
|
12
|
+
const bVal = b[key];
|
|
13
|
+
if (aVal < bVal)
|
|
14
|
+
return sortDirection === SortDirection.ASCENDING ? -1 : 1;
|
|
15
|
+
if (aVal > bVal)
|
|
16
|
+
return sortDirection === SortDirection.ASCENDING ? 1 : -1;
|
|
17
|
+
return 0;
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
if (Array.isArray(sortKey)) {
|
|
21
|
+
const [primaryKey, secondaryKey] = sortKey;
|
|
22
|
+
const primarySorted = sortByKey(items, primaryKey);
|
|
23
|
+
// Group items with the same primary key value
|
|
24
|
+
const groups = primarySorted.reduce((acc, item) => {
|
|
25
|
+
const key = String(item[primaryKey]);
|
|
26
|
+
if (!acc[key])
|
|
27
|
+
acc[key] = [];
|
|
28
|
+
acc[key].push(item);
|
|
29
|
+
return acc;
|
|
30
|
+
}, {});
|
|
31
|
+
// Sort each group by the secondary key and flatten the result
|
|
32
|
+
return Object.values(groups).flatMap(group => sortByKey(group, secondaryKey));
|
|
33
|
+
}
|
|
34
|
+
return sortByKey(items, sortKey);
|
|
35
|
+
}, [items, sortKey, sortDirection, enableNaturalSort, isCaseSensitive]);
|
|
36
|
+
const toggleDirection = () => {
|
|
37
|
+
setSortDirection(prev => prev === SortDirection.ASCENDING ? SortDirection.DESCENDING : SortDirection.ASCENDING);
|
|
38
|
+
};
|
|
39
|
+
return { sortedItems, sortKey, sortDirection, setSortKey, toggleDirection };
|
|
40
|
+
};
|
|
41
|
+
export default useSorting;
|
|
@@ -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 FadeExpander_1 = require("./components/fade/FadeExpander");
|
|
6
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(FadeExpander_1).default; } });
|
|
7
|
+
tslib_1.__exportStar(require("./components/fade/FadeExpander"), exports);
|
package/lib/es/FadeUp.js
ADDED
|
@@ -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 FadeUp_1 = require("./components/fade/FadeUp");
|
|
6
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(FadeUp_1).default; } });
|
|
7
|
+
tslib_1.__exportStar(require("./components/fade/FadeUp"), exports);
|
package/lib/es/XAxis.js
ADDED
|
@@ -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 XAxis_1 = require("./components/charts/XAxis");
|
|
6
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(XAxis_1).default; } });
|
|
7
|
+
tslib_1.__exportStar(require("./components/charts/XAxis"), exports);
|
package/lib/es/YAxis.js
ADDED
|
@@ -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 YAxis_1 = require("./components/charts/YAxis");
|
|
6
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(YAxis_1).default; } });
|
|
7
|
+
tslib_1.__exportStar(require("./components/charts/YAxis"), exports);
|
|
@@ -12,6 +12,11 @@ export type ApplicationLayoutBodyProps = {
|
|
|
12
12
|
* @default true
|
|
13
13
|
*/
|
|
14
14
|
forceScrollbar?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Prop to trigger scroll reset from outside. This comes in handy when changing the body content
|
|
17
|
+
* and to reset the scrolling like when the pathname changes from an body internal menu.
|
|
18
|
+
*/
|
|
19
|
+
scrollResetTrigger?: any;
|
|
15
20
|
/**
|
|
16
21
|
* The ApplicationLayoutBodyBanner component.
|
|
17
22
|
*/
|
|
@@ -9,11 +9,20 @@ const SmoothScrollbars_1 = tslib_1.__importDefault(require("../smoothScrollbars/
|
|
|
9
9
|
const RESIZE_THROTTLING = 200;
|
|
10
10
|
const DEFAULT_BOTTOM_BAR_HEIGHT = 54;
|
|
11
11
|
const ApplicationLayoutBody = (0, react_1.forwardRef)((props, ref) => {
|
|
12
|
-
const { className, innerClassName, forceScrollbar = true, enableScrollToTop = true, banner, navigation, bottomBar, bottomBarHeight = DEFAULT_BOTTOM_BAR_HEIGHT, children } = props, remainingProps = tslib_1.__rest(props, ["className", "innerClassName", "forceScrollbar", "enableScrollToTop", "banner", "navigation", "bottomBar", "bottomBarHeight", "children"]);
|
|
12
|
+
const { className, innerClassName, forceScrollbar = true, enableScrollToTop = true, banner, navigation, bottomBar, bottomBarHeight = DEFAULT_BOTTOM_BAR_HEIGHT, scrollResetTrigger, children } = props, remainingProps = tslib_1.__rest(props, ["className", "innerClassName", "forceScrollbar", "enableScrollToTop", "banner", "navigation", "bottomBar", "bottomBarHeight", "scrollResetTrigger", "children"]);
|
|
13
13
|
const [offset, setOffset] = (0, react_1.useState)(0);
|
|
14
14
|
const moduleContentRef = (0, react_1.useRef)(null);
|
|
15
15
|
const layoutBodyRef = (0, react_1.useRef)(null);
|
|
16
16
|
(0, react_1.useImperativeHandle)(ref, () => layoutBodyRef, []);
|
|
17
|
+
// Reset scroll position when children are different. This fixes the issue of
|
|
18
|
+
// changing body content (like in another route) and still having the same scroll position
|
|
19
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
20
|
+
(0, react_1.useEffect)(() => {
|
|
21
|
+
if (moduleContentRef.current) {
|
|
22
|
+
moduleContentRef.current.scrollTop(0);
|
|
23
|
+
setOffset(0);
|
|
24
|
+
}
|
|
25
|
+
}, [scrollResetTrigger]);
|
|
17
26
|
(0, react_1.useEffect)(() => {
|
|
18
27
|
var _a;
|
|
19
28
|
if (((_a = layoutBodyRef.current) === null || _a === void 0 ? void 0 : _a.parentNode) instanceof HTMLElement) {
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { AreaProps as RechartsAreaProps } from 'recharts';
|
|
2
|
+
import type { CurveType } from 'recharts/types/shape/Curve';
|
|
3
3
|
export type AreaProps = Omit<RechartsAreaProps, 'ref'> & {
|
|
4
4
|
strokeColor?: string;
|
|
5
5
|
dataKey?: string;
|
|
6
6
|
unit?: string;
|
|
7
7
|
legendType?: string;
|
|
8
|
-
type?:
|
|
8
|
+
type?: CurveType;
|
|
9
9
|
isAnimationActive?: boolean;
|
|
10
10
|
};
|
|
11
|
-
declare const
|
|
11
|
+
export declare const getAreaDefaultProps: () => {
|
|
12
|
+
dataKey: string;
|
|
13
|
+
unit: string;
|
|
14
|
+
strokeColor: string;
|
|
15
|
+
legendType: string;
|
|
16
|
+
type: string;
|
|
17
|
+
isAnimationActive: boolean;
|
|
18
|
+
};
|
|
19
|
+
declare const Area: (props: AreaProps) => null;
|
|
12
20
|
export default Area;
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.getAreaDefaultProps = void 0;
|
|
4
|
+
const getAreaDefaultProps = () => ({
|
|
5
|
+
dataKey: 'value',
|
|
6
|
+
unit: '',
|
|
7
|
+
strokeColor: 'color-coldplay-fountain',
|
|
8
|
+
legendType: 'square',
|
|
9
|
+
type: 'monotone',
|
|
10
|
+
isAnimationActive: true,
|
|
11
|
+
});
|
|
12
|
+
exports.getAreaDefaultProps = getAreaDefaultProps;
|
|
13
|
+
const Area = (props) => null;
|
|
4
14
|
exports.default = Area;
|
|
@@ -3,10 +3,10 @@ import { AreaChart as RechartsAreaChart, type XAxisProps, type YAxisProps } from
|
|
|
3
3
|
import { type AreaGradientProps } from './AreaGradient';
|
|
4
4
|
import { type ChartTooltipProps } from './ChartTooltip';
|
|
5
5
|
import { type LegendProps } from './Legend';
|
|
6
|
-
import type
|
|
6
|
+
import { type AreaProps } from './Area';
|
|
7
7
|
import type { GridProps } from './ChartGrid';
|
|
8
8
|
import type { ResponsiveContainerProps } from './ResponsiveContainer';
|
|
9
|
-
import type
|
|
9
|
+
import { type ReferenceLineProps } from './ReferenceLine';
|
|
10
10
|
type RechartsAreaChartProps = React.ComponentProps<typeof RechartsAreaChart>;
|
|
11
11
|
export type AreaChartProps<T extends object> = Omit<RechartsAreaChartProps, 'data'> & {
|
|
12
12
|
width?: number;
|
|
@@ -19,11 +19,12 @@ export type AreaChartProps<T extends object> = Omit<RechartsAreaChartProps, 'dat
|
|
|
19
19
|
referenceLines?: React.ReactElement<ReferenceLineProps>[];
|
|
20
20
|
xAxisOptions?: XAxisProps;
|
|
21
21
|
yAxisOptions?: YAxisProps;
|
|
22
|
+
additionalAxes?: React.ReactElement<XAxisProps | YAxisProps>[];
|
|
22
23
|
gridOptions?: GridProps;
|
|
24
|
+
showGrid?: boolean;
|
|
23
25
|
containerOptions?: ResponsiveContainerProps;
|
|
24
26
|
showXAxis?: boolean;
|
|
25
27
|
showYAxis?: boolean;
|
|
26
|
-
showGrid?: boolean;
|
|
27
28
|
legend?: React.ReactElement<LegendProps> | boolean;
|
|
28
29
|
tooltip?: React.ReactElement<ChartTooltipProps> | boolean;
|
|
29
30
|
brush?: boolean;
|
|
@@ -11,22 +11,23 @@ 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
13
|
const Legend_1 = require("./Legend");
|
|
14
|
+
const XAxis_1 = require("./XAxis");
|
|
15
|
+
const Area_1 = require("./Area");
|
|
16
|
+
const ReferenceLine_1 = require("./ReferenceLine");
|
|
14
17
|
const AreaChart = (props) => {
|
|
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"]);
|
|
18
|
+
const { width, height, data = [], dataUnit = '', dataKey = 'value', gradients = [], areas = [], referenceLines = [], xAxisOptions, yAxisOptions, gridOptions, containerOptions, showXAxis = true, showYAxis = false, additionalAxes = [], 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", "additionalAxes", "showGrid", "legend", "brush", "tooltip"]);
|
|
16
19
|
const areasWithGradient = areas.map(area => {
|
|
17
|
-
const
|
|
20
|
+
const areaPropsWithDefault = Object.assign(Object.assign({}, (0, Area_1.getAreaDefaultProps)()), area.props);
|
|
21
|
+
const { strokeColor } = areaPropsWithDefault, remainingAreaProps = tslib_1.__rest(areaPropsWithDefault, ["strokeColor"]);
|
|
18
22
|
const gradientId = area.key;
|
|
19
23
|
const stroke = (0, chartHelper_1.getColor)(strokeColor);
|
|
20
24
|
return {
|
|
21
|
-
area: (0, react_1.createElement)(recharts_1.Area, Object.assign({}, remainingAreaProps, { key: area.key, stroke: stroke, fill: `url(#${gradientId})` })),
|
|
25
|
+
area: ((0, react_1.createElement)(recharts_1.Area, Object.assign({}, remainingAreaProps, { key: area.key, stroke: stroke, fill: `url(#${gradientId})` }))),
|
|
22
26
|
gradient: (0, jsx_runtime_1.jsx)(AreaGradient_1.default, { id: gradientId || AreaGradient_1.DEFAULT_ARIA_GRADIENT_ID, color: strokeColor }, area.key),
|
|
23
27
|
};
|
|
24
28
|
});
|
|
25
29
|
const tooltipProps = (0, isObject_1.default)(tooltip) ? tooltip.props : {};
|
|
26
30
|
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(
|
|
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') })] })) })));
|
|
31
|
+
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)), additionalAxes.map(XAxis_1.renderAxis), 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_1.renderReferenceLine), brush && (0, jsx_runtime_1.jsx)(recharts_1.Brush, { stroke: (0, chartHelper_1.getColor)('gray') })] })) })));
|
|
31
32
|
};
|
|
32
33
|
exports.default = AreaChart;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { BarProps as RechartsBarProps } from 'recharts';
|
|
3
2
|
export type BarProps = Omit<RechartsBarProps, 'ref'> & {};
|
|
4
|
-
declare const
|
|
3
|
+
export declare const getBarDefaultProps: () => {
|
|
4
|
+
dataKey: string;
|
|
5
|
+
color: string;
|
|
6
|
+
isAnimationActive: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const Bar: (props: BarProps) => null;
|
|
5
9
|
export default Bar;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
exports.getBarDefaultProps = void 0;
|
|
4
|
+
const getBarDefaultProps = () => ({
|
|
5
5
|
dataKey: 'value',
|
|
6
|
-
unit: '',
|
|
7
6
|
color: 'color-coldplay-fountain',
|
|
8
7
|
isAnimationActive: true,
|
|
9
|
-
};
|
|
8
|
+
});
|
|
9
|
+
exports.getBarDefaultProps = getBarDefaultProps;
|
|
10
|
+
const Bar = (props) => null;
|
|
10
11
|
exports.default = Bar;
|
|
@@ -3,7 +3,7 @@ import { BarChart as RechartsBarChart, type XAxisProps, type YAxisProps } from '
|
|
|
3
3
|
import { type DataType } from './chartHelper';
|
|
4
4
|
import { type ChartTooltipProps } from './ChartTooltip';
|
|
5
5
|
import { type LegendProps } from './Legend';
|
|
6
|
-
import type
|
|
6
|
+
import { type BarProps } from './Bar';
|
|
7
7
|
import type { GridProps } from './ChartGrid';
|
|
8
8
|
import type { ResponsiveContainerProps } from './ResponsiveContainer';
|
|
9
9
|
export type BarChartDataType = DataType;
|
|
@@ -22,6 +22,7 @@ export type BarChartProps<T extends DataType> = Omit<RechartsBarChartProps, with
|
|
|
22
22
|
useDataColors?: boolean;
|
|
23
23
|
xAxisOptions?: XAxisProps;
|
|
24
24
|
yAxisOptions?: YAxisProps;
|
|
25
|
+
additionalAxes?: React.ReactElement<XAxisProps | YAxisProps>[];
|
|
25
26
|
gridOptions?: GridProps;
|
|
26
27
|
containerOptions?: ResponsiveContainerProps;
|
|
27
28
|
legend?: React.ReactElement<LegendProps> | boolean;
|
|
@@ -10,8 +10,10 @@ 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
12
|
const Legend_1 = require("./Legend");
|
|
13
|
+
const XAxis_1 = require("./XAxis");
|
|
14
|
+
const Bar_1 = require("./Bar");
|
|
13
15
|
const BarChart = (props) => {
|
|
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"]);
|
|
16
|
+
const { width, height, data = [], dataUnit, dataKey = 'value', layout = 'horizontal', legend = false, bars = [], xAxisOptions, yAxisOptions, additionalAxes = [], 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", "additionalAxes", "gridOptions", "containerOptions", "showGrid", "showXAxis", "showYAxis", "useDataColors", "brush", "tooltip"]);
|
|
15
17
|
const tooltipProps = (0, isObject_1.default)(tooltip) ? tooltip.props : {};
|
|
16
18
|
const legendProps = (0, isObject_1.default)(legend) ? Object.assign(Object.assign({}, (0, Legend_1.getLegendDefaultProps)()), legend.props) : {};
|
|
17
19
|
let legendPayload;
|
|
@@ -21,12 +23,14 @@ const BarChart = (props) => {
|
|
|
21
23
|
return Object.assign(Object.assign({}, entry), { value: (0, isFunction_1.default)(dataKey) ? dataKey(entry) : entry[dataKey], color: legendColor });
|
|
22
24
|
});
|
|
23
25
|
}
|
|
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
|
-
const
|
|
26
|
+
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)), additionalAxes.map(XAxis_1.renderAxis), 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 => {
|
|
27
|
+
const barPropsWithDefault = Object.assign(Object.assign({}, (0, Bar_1.getBarDefaultProps)()), bar.props);
|
|
28
|
+
const { color } = barPropsWithDefault, remainingBarProps = tslib_1.__rest(barPropsWithDefault, ["color"]);
|
|
26
29
|
const cellColor = color && (0, chartHelper_1.getColor)(color);
|
|
27
30
|
return ((0, jsx_runtime_1.jsx)(recharts_1.Bar, Object.assign({ unit: dataUnit }, remainingBarProps, { fill: cellColor }, { children: useDataColors &&
|
|
28
31
|
data.map((entry, index) => {
|
|
29
32
|
const entryCellColor = (0, chartHelper_1.getColor)(entry.color) || (0, chartHelper_1.getFromDefaultColors)(index);
|
|
33
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: unknown key
|
|
30
34
|
return (0, jsx_runtime_1.jsx)(recharts_1.Cell, { fill: entryCellColor }, `cell-${index}`);
|
|
31
35
|
}) }), bar.key));
|
|
32
36
|
}), brush && (0, jsx_runtime_1.jsx)(recharts_1.Brush, { stroke: (0, chartHelper_1.getColor)('gray') })] })) })));
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ComposedChart as RechartsComposedChart, type XAxisProps, type YAxisProps } from 'recharts';
|
|
3
|
-
import { ChartTooltipProps } from './ChartTooltip';
|
|
3
|
+
import { type ChartTooltipProps } from './ChartTooltip';
|
|
4
4
|
import { type LegendProps } from './Legend';
|
|
5
|
-
import type
|
|
6
|
-
import type
|
|
7
|
-
import type
|
|
5
|
+
import { type BarProps } from './Bar';
|
|
6
|
+
import { type ReferenceLineProps } from './ReferenceLine';
|
|
7
|
+
import { type LineProps } from './Line';
|
|
8
|
+
import { type AreaProps } from './Area';
|
|
8
9
|
import type { GridProps } from './ChartGrid';
|
|
9
10
|
import type { ResponsiveContainerProps } from './ResponsiveContainer';
|
|
10
|
-
import type { AreaProps } from './Area';
|
|
11
11
|
type RechartsComposedChartProps = React.ComponentProps<typeof RechartsComposedChart>;
|
|
12
12
|
export type ComposedChartProps<T extends object> = Omit<RechartsComposedChartProps, 'data'> & {
|
|
13
13
|
width?: number;
|
|
@@ -21,6 +21,7 @@ export type ComposedChartProps<T extends object> = Omit<RechartsComposedChartPro
|
|
|
21
21
|
referenceLines?: React.ReactElement<ReferenceLineProps>[];
|
|
22
22
|
xAxisOptions?: XAxisProps;
|
|
23
23
|
yAxisOptions?: YAxisProps;
|
|
24
|
+
additionalAxes?: React.ReactElement<XAxisProps | YAxisProps>[];
|
|
24
25
|
gridOptions?: GridProps;
|
|
25
26
|
containerOptions?: ResponsiveContainerProps;
|
|
26
27
|
showXAxis?: boolean;
|