@ssa-ui-kit/core 2.8.2 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Charts/GaugeChart/GaugeChart.d.ts +25 -0
- package/dist/components/Charts/GaugeChart/components/GaugeChartBase.d.ts +7 -0
- package/dist/components/Charts/GaugeChart/components/GaugeChartCanvas.d.ts +4 -0
- package/dist/components/Charts/GaugeChart/components/GaugeChartHeader.d.ts +8 -0
- package/dist/components/Charts/GaugeChart/components/GaugeChartLabels.d.ts +14 -0
- package/dist/components/Charts/GaugeChart/components/GaugeChartLayer.d.ts +4 -0
- package/dist/components/Charts/GaugeChart/components/GaugeChartNeedle.d.ts +12 -0
- package/dist/components/Charts/GaugeChart/components/GaugeChartTickers.d.ts +17 -0
- package/dist/components/Charts/GaugeChart/components/index.d.ts +7 -0
- package/dist/components/Charts/GaugeChart/index.d.ts +1 -0
- package/dist/components/Charts/GaugeChart/utils/index.d.ts +1 -0
- package/dist/components/Charts/GaugeChart/utils/math.d.ts +19 -0
- package/dist/components/Charts/TreeMapChart/TreeMapChart.d.ts +2 -2
- package/dist/components/Charts/index.d.ts +1 -0
- package/dist/index.js +428 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { WidgetCardProps } from '../../WidgetCard';
|
|
2
|
+
import { GaugeChartBaseProps, GaugeChartLabelsProps, GaugeChartTickersProps } from './components';
|
|
3
|
+
export type GaugeChartFeature = 'header' | 'fullscreenMode';
|
|
4
|
+
export interface GaugeChartProps extends Pick<GaugeChartLabelsProps, 'maxLabel' | 'minLabel' | 'unitLabel' | 'totalLabel'>, Pick<GaugeChartTickersProps, 'ticks'> {
|
|
5
|
+
minValue: number;
|
|
6
|
+
maxValue: number;
|
|
7
|
+
value: number;
|
|
8
|
+
title?: string;
|
|
9
|
+
segments?: {
|
|
10
|
+
value: number;
|
|
11
|
+
id?: string;
|
|
12
|
+
color?: string;
|
|
13
|
+
}[];
|
|
14
|
+
withLabels?: boolean;
|
|
15
|
+
withTrack?: boolean;
|
|
16
|
+
withNeedle?: boolean;
|
|
17
|
+
chartProps?: Omit<GaugeChartBaseProps, 'data'>;
|
|
18
|
+
trackProps?: Omit<GaugeChartBaseProps, 'data'>;
|
|
19
|
+
features?: GaugeChartFeature[];
|
|
20
|
+
widgetCardProps?: WidgetCardProps;
|
|
21
|
+
}
|
|
22
|
+
export declare const GaugeChart: {
|
|
23
|
+
(props: GaugeChartProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
24
|
+
displayName: string;
|
|
25
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MayHaveLabel, ResponsivePie } from '@nivo/pie';
|
|
2
|
+
export type GaugeChartData = {
|
|
3
|
+
color?: string;
|
|
4
|
+
value?: number;
|
|
5
|
+
} & MayHaveLabel;
|
|
6
|
+
export type GaugeChartBaseProps = React.ComponentProps<typeof ResponsivePie<GaugeChartData>>;
|
|
7
|
+
export declare const GaugeChartBase: ({ ...props }: GaugeChartBaseProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MustInclude } from '@ssa-ui-kit/utils';
|
|
2
|
+
export declare const FullScreenButton: import("@emotion/styled").StyledComponent<import("../../../Button/types").ButtonProps & import("react").RefAttributes<HTMLButtonElement> & {
|
|
3
|
+
theme?: import("@emotion/react").Theme;
|
|
4
|
+
}, {}, {}>;
|
|
5
|
+
export interface GaugeChartHeaderProps<T extends string[]> {
|
|
6
|
+
features: MustInclude<T, 'fullscreenMode'>;
|
|
7
|
+
}
|
|
8
|
+
export declare const GaugeChartHeader: <F extends string[]>({ features, }: GaugeChartHeaderProps<F>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const GaugeChartLabel: import("@emotion/styled").StyledComponent<{
|
|
2
|
+
theme?: import("@emotion/react").Theme;
|
|
3
|
+
as?: React.ElementType;
|
|
4
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
5
|
+
export interface GaugeChartLabelsProps {
|
|
6
|
+
width: string;
|
|
7
|
+
withLabels?: boolean;
|
|
8
|
+
value?: number;
|
|
9
|
+
unitLabel?: string;
|
|
10
|
+
minLabel?: string;
|
|
11
|
+
maxLabel?: string;
|
|
12
|
+
totalLabel?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const GaugeChartLabels: ({ width, withLabels, value, unitLabel, minLabel, maxLabel, totalLabel, }: GaugeChartLabelsProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface GaugeChartNeedleProps {
|
|
2
|
+
pieSize: {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
};
|
|
6
|
+
pieOffset: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
needleAngle: number;
|
|
11
|
+
}
|
|
12
|
+
export declare const GaugeChartNeedle: ({ pieSize, pieOffset, needleAngle, }: GaugeChartNeedleProps) => import("@emotion/react/jsx-runtime").JSX.Element | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface GaugeChartTickersProps {
|
|
2
|
+
pieSize: {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
};
|
|
6
|
+
pieOffset: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
minValue: number;
|
|
11
|
+
maxValue: number;
|
|
12
|
+
ticks?: ({
|
|
13
|
+
value: number;
|
|
14
|
+
label?: React.ReactNode;
|
|
15
|
+
} | number)[];
|
|
16
|
+
}
|
|
17
|
+
export declare const GaugeChartTickers: ({ pieOffset, pieSize, minValue, maxValue, ticks, }: GaugeChartTickersProps) => import("@emotion/react/jsx-runtime").JSX.Element | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GaugeChart';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './math';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const scaleFromBase: (baseValue: number, base: number, current: number) => number;
|
|
2
|
+
export declare const normalizeToRange: (value: number, min: number, max: number, targetMin?: number, targetMax?: number) => number;
|
|
3
|
+
export declare const calculateFittedSize: (container: {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}, aspectRatio: number) => {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const centeredOffset: (container: {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}, content: {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
}) => {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ResponsiveTreeMap } from '@nivo/treemap';
|
|
2
|
-
import React from 'react';
|
|
3
2
|
import { WidgetCardProps } from '../../WidgetCard';
|
|
4
3
|
export type TreeNode = {
|
|
5
4
|
name: string;
|
|
6
5
|
value?: number;
|
|
6
|
+
color?: string;
|
|
7
7
|
children?: TreeNode[];
|
|
8
8
|
};
|
|
9
9
|
export type TreeMapChartFeature = 'header' | 'fullscreenMode';
|
|
10
|
-
type NivoTreeMapChartProps = React.ComponentProps<typeof ResponsiveTreeMap
|
|
10
|
+
type NivoTreeMapChartProps = React.ComponentProps<typeof ResponsiveTreeMap<TreeNode>>;
|
|
11
11
|
export interface TreeMapChartProps extends Omit<NivoTreeMapChartProps, 'data'> {
|
|
12
12
|
data: TreeNode;
|
|
13
13
|
title?: string;
|
package/dist/index.js
CHANGED
|
@@ -110,6 +110,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
110
110
|
FormRadioGroup: () => (/* reexport */ FormRadioGroup_FormRadioGroup),
|
|
111
111
|
FullscreenModeContext: () => (/* reexport */ FullscreenModeContext),
|
|
112
112
|
FullscreenModeProvider: () => (/* reexport */ FullscreenModeProvider),
|
|
113
|
+
GaugeChart: () => (/* reexport */ GaugeChart),
|
|
113
114
|
Icon: () => (/* reexport */ Icon_Icon),
|
|
114
115
|
ImageItem: () => (/* reexport */ ImageItem),
|
|
115
116
|
Indicator: () => (/* reexport */ Indicator_Indicator),
|
|
@@ -15716,7 +15717,6 @@ function TreeMapChart_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried
|
|
|
15716
15717
|
|
|
15717
15718
|
|
|
15718
15719
|
|
|
15719
|
-
|
|
15720
15720
|
var TreeMapChart_ref = true ? {
|
|
15721
15721
|
name: "1qkt16r",
|
|
15722
15722
|
styles: "position:relative;height:100%;width:100%"
|
|
@@ -15782,6 +15782,429 @@ const TreeMapChart = WithFullscreenMode(TreeMapChartComponent);
|
|
|
15782
15782
|
|
|
15783
15783
|
;// ./src/components/Charts/hooks/index.ts
|
|
15784
15784
|
|
|
15785
|
+
;// ./src/components/Charts/GaugeChart/components/GaugeChartHeader.tsx
|
|
15786
|
+
|
|
15787
|
+
function GaugeChartHeader_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
15788
|
+
|
|
15789
|
+
|
|
15790
|
+
|
|
15791
|
+
|
|
15792
|
+
const GaugeChartHeader_FullScreenButton = /*#__PURE__*/base_default()(Button_Button, true ? {
|
|
15793
|
+
target: "e1mg237f0"
|
|
15794
|
+
} : 0)("height:auto;padding:0;background:none;box-shadow:none;&:hover,&:focus{background:none;box-shadow:none;&::before{display:none;}}&:hover{svg path{fill:", ({
|
|
15795
|
+
theme
|
|
15796
|
+
}) => theme.colors.greyDarker, ";}}" + ( true ? "" : 0));
|
|
15797
|
+
var GaugeChartHeader_ref = true ? {
|
|
15798
|
+
name: "1pqzlpx",
|
|
15799
|
+
styles: "width:auto;margin-left:auto"
|
|
15800
|
+
} : 0;
|
|
15801
|
+
var GaugeChartHeader_ref2 = true ? {
|
|
15802
|
+
name: "e0dnmk",
|
|
15803
|
+
styles: "cursor:pointer"
|
|
15804
|
+
} : 0;
|
|
15805
|
+
const GaugeChartHeader = ({
|
|
15806
|
+
features = []
|
|
15807
|
+
}) => {
|
|
15808
|
+
const {
|
|
15809
|
+
isFullscreenMode,
|
|
15810
|
+
toggleFullscreenMode
|
|
15811
|
+
} = useFullscreenMode();
|
|
15812
|
+
const theme = (0,react_namespaceObject.useTheme)();
|
|
15813
|
+
return (0,jsx_runtime_namespaceObject.jsx)(Wrapper_Wrapper, {
|
|
15814
|
+
css: GaugeChartHeader_ref,
|
|
15815
|
+
children: features.includes('fullscreenMode') && (0,jsx_runtime_namespaceObject.jsx)(GaugeChartHeader_FullScreenButton, {
|
|
15816
|
+
variant: "tertiary",
|
|
15817
|
+
onClick: toggleFullscreenMode,
|
|
15818
|
+
children: (0,jsx_runtime_namespaceObject.jsx)(Icon_Icon, {
|
|
15819
|
+
name: isFullscreenMode ? 'cross' : 'maximize',
|
|
15820
|
+
css: GaugeChartHeader_ref2,
|
|
15821
|
+
tooltip: isFullscreenMode ? 'Close' : 'Maximize',
|
|
15822
|
+
size: 18,
|
|
15823
|
+
color: theme.colors.greyFilterIcon
|
|
15824
|
+
})
|
|
15825
|
+
})
|
|
15826
|
+
});
|
|
15827
|
+
};
|
|
15828
|
+
;// ./src/components/Charts/GaugeChart/components/GaugeChartCanvas.tsx
|
|
15829
|
+
|
|
15830
|
+
function GaugeChartCanvas_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
15831
|
+
const GaugeChartCanvas = /*#__PURE__*/base_default()("div", true ? {
|
|
15832
|
+
target: "e838210"
|
|
15833
|
+
} : 0)( true ? {
|
|
15834
|
+
name: "1f0ps9l",
|
|
15835
|
+
styles: "position:relative;width:100%;max-height:100%;aspect-ratio:3"
|
|
15836
|
+
} : 0);
|
|
15837
|
+
;// ./src/components/Charts/GaugeChart/components/GaugeChartLayer.tsx
|
|
15838
|
+
|
|
15839
|
+
function GaugeChartLayer_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
15840
|
+
const GaugeChartLayer = /*#__PURE__*/base_default()("div", true ? {
|
|
15841
|
+
target: "ecz750w0"
|
|
15842
|
+
} : 0)( true ? {
|
|
15843
|
+
name: "xyyuvf",
|
|
15844
|
+
styles: "position:absolute;height:100%;width:100%"
|
|
15845
|
+
} : 0);
|
|
15846
|
+
;// ./src/components/Charts/GaugeChart/components/GaugeChartBase.tsx
|
|
15847
|
+
|
|
15848
|
+
|
|
15849
|
+
|
|
15850
|
+
const GaugeChartBase = ({
|
|
15851
|
+
...props
|
|
15852
|
+
}) => {
|
|
15853
|
+
const theme = (0,react_namespaceObject.useTheme)();
|
|
15854
|
+
return (0,jsx_runtime_namespaceObject.jsx)(pie_namespaceObject.ResponsivePie, {
|
|
15855
|
+
startAngle: -90,
|
|
15856
|
+
endAngle: 90,
|
|
15857
|
+
innerRadius: 0.8,
|
|
15858
|
+
padAngle: 1,
|
|
15859
|
+
cornerRadius: 100,
|
|
15860
|
+
enableArcLabels: false,
|
|
15861
|
+
enableArcLinkLabels: false,
|
|
15862
|
+
colors: ({
|
|
15863
|
+
data
|
|
15864
|
+
}) => data.color ?? theme.colors.greyLighter,
|
|
15865
|
+
isInteractive: false,
|
|
15866
|
+
animate: false,
|
|
15867
|
+
sortByValue: false,
|
|
15868
|
+
fit: true,
|
|
15869
|
+
layers: ['arcs', 'legends'],
|
|
15870
|
+
...props
|
|
15871
|
+
});
|
|
15872
|
+
};
|
|
15873
|
+
;// ./src/components/Charts/GaugeChart/utils/math.ts
|
|
15874
|
+
const scaleFromBase = (baseValue, base, current) => {
|
|
15875
|
+
return current / base * baseValue;
|
|
15876
|
+
};
|
|
15877
|
+
const normalizeToRange = (value, min, max, targetMin = 0, targetMax = 100) => {
|
|
15878
|
+
if (max === min) return targetMin;
|
|
15879
|
+
const clampedValue = Math.min(Math.max(value, min), max);
|
|
15880
|
+
const ratio = (clampedValue - min) / (max - min);
|
|
15881
|
+
return ratio * (targetMax - targetMin) + targetMin;
|
|
15882
|
+
};
|
|
15883
|
+
const calculateFittedSize = (container, aspectRatio) => {
|
|
15884
|
+
const containerRatio = container.width / container.height;
|
|
15885
|
+
if (containerRatio < aspectRatio) {
|
|
15886
|
+
// container is too tall → constrain by width
|
|
15887
|
+
const width = container.width;
|
|
15888
|
+
return {
|
|
15889
|
+
width,
|
|
15890
|
+
height: width / aspectRatio
|
|
15891
|
+
};
|
|
15892
|
+
} else {
|
|
15893
|
+
// container is too wide → constrain by height
|
|
15894
|
+
const height = container.height;
|
|
15895
|
+
return {
|
|
15896
|
+
width: height * aspectRatio,
|
|
15897
|
+
height
|
|
15898
|
+
};
|
|
15899
|
+
}
|
|
15900
|
+
};
|
|
15901
|
+
const centeredOffset = (container, content) => {
|
|
15902
|
+
return {
|
|
15903
|
+
x: (container.width - content.width) / 2,
|
|
15904
|
+
y: (container.height - content.height) / 2
|
|
15905
|
+
};
|
|
15906
|
+
};
|
|
15907
|
+
;// ./src/components/Charts/GaugeChart/components/GaugeChartTickers.tsx
|
|
15908
|
+
|
|
15909
|
+
|
|
15910
|
+
|
|
15911
|
+
const GaugeChartTickers = ({
|
|
15912
|
+
pieOffset,
|
|
15913
|
+
pieSize,
|
|
15914
|
+
minValue,
|
|
15915
|
+
maxValue,
|
|
15916
|
+
ticks = []
|
|
15917
|
+
}) => {
|
|
15918
|
+
const theme = (0,react_namespaceObject.useTheme)();
|
|
15919
|
+
if (pieSize.height <= 0) {
|
|
15920
|
+
return;
|
|
15921
|
+
}
|
|
15922
|
+
const radius = pieSize.width / 2;
|
|
15923
|
+
const labelRadius = radius * 1.05;
|
|
15924
|
+
const pieBottomCenter = {
|
|
15925
|
+
x: pieOffset.x + pieSize.width / 2,
|
|
15926
|
+
y: pieOffset.y + pieSize.height
|
|
15927
|
+
};
|
|
15928
|
+
const tickLabels = ticks.map(tick => {
|
|
15929
|
+
const {
|
|
15930
|
+
value,
|
|
15931
|
+
label
|
|
15932
|
+
} = typeof tick === 'number' ? {
|
|
15933
|
+
value: tick,
|
|
15934
|
+
label: tick
|
|
15935
|
+
} : tick;
|
|
15936
|
+
const normalizedValue = normalizeToRange(value, minValue, maxValue, 0, 100);
|
|
15937
|
+
const angle = (-90 + normalizedValue / 100 * 180) * (Math.PI / 180);
|
|
15938
|
+
const x = pieBottomCenter.x + labelRadius * Math.sin(angle);
|
|
15939
|
+
const y = pieBottomCenter.y - labelRadius * Math.cos(angle);
|
|
15940
|
+
const align = normalizedValue > 50 ? 'left' : 'right';
|
|
15941
|
+
return {
|
|
15942
|
+
x,
|
|
15943
|
+
y,
|
|
15944
|
+
normalizedValue,
|
|
15945
|
+
label: label ?? value,
|
|
15946
|
+
align
|
|
15947
|
+
};
|
|
15948
|
+
});
|
|
15949
|
+
return (0,jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {
|
|
15950
|
+
children: tickLabels.map(({
|
|
15951
|
+
normalizedValue,
|
|
15952
|
+
label,
|
|
15953
|
+
align,
|
|
15954
|
+
x,
|
|
15955
|
+
y
|
|
15956
|
+
}, index) => {
|
|
15957
|
+
let translateX = '-50%'; // center
|
|
15958
|
+
if (align === 'right') {
|
|
15959
|
+
translateX = '-100%';
|
|
15960
|
+
}
|
|
15961
|
+
if (align === 'left') {
|
|
15962
|
+
translateX = '0%';
|
|
15963
|
+
}
|
|
15964
|
+
return (0,jsx_runtime_namespaceObject.jsx)("div", {
|
|
15965
|
+
// prevents class creation for each label
|
|
15966
|
+
style: {
|
|
15967
|
+
left: `${x}px`,
|
|
15968
|
+
top: `${y}px`,
|
|
15969
|
+
transform: `translate(${translateX}, -50%)`
|
|
15970
|
+
},
|
|
15971
|
+
css: /*#__PURE__*/(0,react_namespaceObject.css)({
|
|
15972
|
+
color: theme.colors.greyDarker60,
|
|
15973
|
+
position: 'absolute',
|
|
15974
|
+
fontSize: 12,
|
|
15975
|
+
fontWeight: 500
|
|
15976
|
+
}, true ? "" : 0, true ? "" : 0),
|
|
15977
|
+
children: label
|
|
15978
|
+
}, normalizedValue + index);
|
|
15979
|
+
})
|
|
15980
|
+
});
|
|
15981
|
+
};
|
|
15982
|
+
;// ./src/components/Charts/GaugeChart/components/GaugeChartNeedle.tsx
|
|
15983
|
+
|
|
15984
|
+
|
|
15985
|
+
const GaugeChartNeedle = ({
|
|
15986
|
+
pieSize,
|
|
15987
|
+
pieOffset,
|
|
15988
|
+
needleAngle
|
|
15989
|
+
}) => {
|
|
15990
|
+
if (pieSize.height <= 0) {
|
|
15991
|
+
return;
|
|
15992
|
+
}
|
|
15993
|
+
const needle = {
|
|
15994
|
+
x: pieOffset.x + pieSize.width / 2,
|
|
15995
|
+
y: pieOffset.y + pieSize.height - scaleFromBase(10, 100, pieSize.height),
|
|
15996
|
+
width: scaleFromBase(40, 100, pieSize.width) - scaleFromBase(10, 100, pieSize.height),
|
|
15997
|
+
height: scaleFromBase(8, 100, pieSize.height)
|
|
15998
|
+
};
|
|
15999
|
+
return (0,jsx_runtime_namespaceObject.jsx)("div", {
|
|
16000
|
+
style: {
|
|
16001
|
+
position: 'absolute',
|
|
16002
|
+
top: `${needle.y}px`,
|
|
16003
|
+
left: `${needle.x}px`,
|
|
16004
|
+
width: `${needle.width}px`,
|
|
16005
|
+
borderRadius: needle.height / 2,
|
|
16006
|
+
height: `${needle.height}px`,
|
|
16007
|
+
backgroundColor: '#73767B',
|
|
16008
|
+
transformOrigin: 'left center',
|
|
16009
|
+
transform: `rotate(${needleAngle}deg)`
|
|
16010
|
+
}
|
|
16011
|
+
});
|
|
16012
|
+
};
|
|
16013
|
+
;// ./src/components/Charts/GaugeChart/components/GaugeChartLabels.tsx
|
|
16014
|
+
|
|
16015
|
+
|
|
16016
|
+
function GaugeChartLabels_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
16017
|
+
|
|
16018
|
+
|
|
16019
|
+
|
|
16020
|
+
const GaugeChartLabel = /*#__PURE__*/base_default()("span", true ? {
|
|
16021
|
+
target: "e1hn6mi60"
|
|
16022
|
+
} : 0)("line-height:0;color:", ({
|
|
16023
|
+
theme
|
|
16024
|
+
}) => theme.colors.greyDarker60, ";" + ( true ? "" : 0));
|
|
16025
|
+
var GaugeChartLabels_ref = true ? {
|
|
16026
|
+
name: "1azakc",
|
|
16027
|
+
styles: "text-align:center"
|
|
16028
|
+
} : 0;
|
|
16029
|
+
var GaugeChartLabels_ref2 = true ? {
|
|
16030
|
+
name: "5bhc30",
|
|
16031
|
+
styles: "margin-bottom:8px"
|
|
16032
|
+
} : 0;
|
|
16033
|
+
var GaugeChartLabels_ref3 = true ? {
|
|
16034
|
+
name: "6r7ers",
|
|
16035
|
+
styles: "font-size:28px;font-weight:700;white-space:nowrap;color:unset"
|
|
16036
|
+
} : 0;
|
|
16037
|
+
const GaugeChartLabels = ({
|
|
16038
|
+
width,
|
|
16039
|
+
withLabels,
|
|
16040
|
+
value,
|
|
16041
|
+
unitLabel,
|
|
16042
|
+
minLabel,
|
|
16043
|
+
maxLabel,
|
|
16044
|
+
totalLabel
|
|
16045
|
+
}) => {
|
|
16046
|
+
const theme = (0,react_namespaceObject.useTheme)();
|
|
16047
|
+
return (0,jsx_runtime_namespaceObject.jsxs)(Wrapper_Wrapper, {
|
|
16048
|
+
css: /*#__PURE__*/(0,react_namespaceObject.css)({
|
|
16049
|
+
width,
|
|
16050
|
+
justifyContent: 'space-between'
|
|
16051
|
+
}, true ? "" : 0, true ? "" : 0),
|
|
16052
|
+
children: [(0,jsx_runtime_namespaceObject.jsx)(GaugeChartLabel, {
|
|
16053
|
+
children: withLabels && minLabel
|
|
16054
|
+
}), (0,jsx_runtime_namespaceObject.jsxs)("div", {
|
|
16055
|
+
css: GaugeChartLabels_ref,
|
|
16056
|
+
children: [(0,jsx_runtime_namespaceObject.jsx)("div", {
|
|
16057
|
+
css: GaugeChartLabels_ref2,
|
|
16058
|
+
children: (0,jsx_runtime_namespaceObject.jsx)(GaugeChartLabel, {
|
|
16059
|
+
children: withLabels && totalLabel
|
|
16060
|
+
})
|
|
16061
|
+
}), (0,jsx_runtime_namespaceObject.jsxs)(GaugeChartLabel, {
|
|
16062
|
+
css: GaugeChartLabels_ref3,
|
|
16063
|
+
children: [(0,jsx_runtime_namespaceObject.jsxs)("span", {
|
|
16064
|
+
children: [value, " "]
|
|
16065
|
+
}), (0,jsx_runtime_namespaceObject.jsx)(GaugeChartLabel, {
|
|
16066
|
+
css: /*#__PURE__*/(0,react_namespaceObject.css)({
|
|
16067
|
+
fontSize: 18,
|
|
16068
|
+
fontWeight: 500,
|
|
16069
|
+
color: theme.colors.greyDarker80
|
|
16070
|
+
}, true ? "" : 0, true ? "" : 0),
|
|
16071
|
+
children: unitLabel
|
|
16072
|
+
})]
|
|
16073
|
+
})]
|
|
16074
|
+
}), (0,jsx_runtime_namespaceObject.jsx)(GaugeChartLabel, {
|
|
16075
|
+
children: withLabels && maxLabel
|
|
16076
|
+
})]
|
|
16077
|
+
});
|
|
16078
|
+
};
|
|
16079
|
+
;// ./src/components/Charts/GaugeChart/GaugeChart.tsx
|
|
16080
|
+
function GaugeChart_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
16081
|
+
|
|
16082
|
+
|
|
16083
|
+
|
|
16084
|
+
|
|
16085
|
+
|
|
16086
|
+
|
|
16087
|
+
|
|
16088
|
+
|
|
16089
|
+
var GaugeChart_ref = true ? {
|
|
16090
|
+
name: "13udsys",
|
|
16091
|
+
styles: "height:100%"
|
|
16092
|
+
} : 0;
|
|
16093
|
+
var GaugeChart_ref2 = true ? {
|
|
16094
|
+
name: "67cb9k",
|
|
16095
|
+
styles: "justify-content:center;height:100%"
|
|
16096
|
+
} : 0;
|
|
16097
|
+
const GaugeChartComponent = ({
|
|
16098
|
+
minLabel,
|
|
16099
|
+
maxLabel,
|
|
16100
|
+
totalLabel,
|
|
16101
|
+
unitLabel,
|
|
16102
|
+
minValue,
|
|
16103
|
+
maxValue,
|
|
16104
|
+
value,
|
|
16105
|
+
title,
|
|
16106
|
+
chartProps,
|
|
16107
|
+
trackProps,
|
|
16108
|
+
widgetCardProps,
|
|
16109
|
+
withLabels = true,
|
|
16110
|
+
withTrack = true,
|
|
16111
|
+
withNeedle = true,
|
|
16112
|
+
features = [],
|
|
16113
|
+
segments = [],
|
|
16114
|
+
ticks = []
|
|
16115
|
+
}) => {
|
|
16116
|
+
const theme = (0,react_namespaceObject.useTheme)();
|
|
16117
|
+
const {
|
|
16118
|
+
ref: containerRef,
|
|
16119
|
+
...containerSize
|
|
16120
|
+
} = (0,hooks_namespaceObject.useElementSize)();
|
|
16121
|
+
const normalizedValue = normalizeToRange(value, minValue, maxValue, 0, 100);
|
|
16122
|
+
const normalizedSegments = segments.map((segment, index) => {
|
|
16123
|
+
const prev = segments[index - 1];
|
|
16124
|
+
const start = normalizeToRange(prev?.value ?? minValue, minValue, maxValue, 0, 100);
|
|
16125
|
+
const end = normalizeToRange(segment.value, minValue, maxValue, 0, 100);
|
|
16126
|
+
return {
|
|
16127
|
+
...segment,
|
|
16128
|
+
value: end - start
|
|
16129
|
+
};
|
|
16130
|
+
});
|
|
16131
|
+
if (normalizedSegments.length === 0) {
|
|
16132
|
+
normalizedSegments.push({
|
|
16133
|
+
value: normalizedValue,
|
|
16134
|
+
color: theme.colors.blueLight
|
|
16135
|
+
});
|
|
16136
|
+
}
|
|
16137
|
+
|
|
16138
|
+
// ensure normalized segments value sum to 100
|
|
16139
|
+
const totalValue = normalizedSegments.reduce((acc, segment) => acc + segment.value, 0);
|
|
16140
|
+
if (totalValue !== 100) {
|
|
16141
|
+
normalizedSegments.push({
|
|
16142
|
+
value: 100 - totalValue,
|
|
16143
|
+
color: 'transparent'
|
|
16144
|
+
});
|
|
16145
|
+
}
|
|
16146
|
+
const needleAngle = 180 + normalizedValue / 100 * 180;
|
|
16147
|
+
const trackSize = 100;
|
|
16148
|
+
const pieAspectRatio = 2;
|
|
16149
|
+
const pieSize = calculateFittedSize(containerSize, pieAspectRatio);
|
|
16150
|
+
const pieOffset = centeredOffset(containerSize, pieSize);
|
|
16151
|
+
return (0,jsx_runtime_namespaceObject.jsx)("div", {
|
|
16152
|
+
css: GaugeChart_ref,
|
|
16153
|
+
children: (0,jsx_runtime_namespaceObject.jsx)(WithWidgetCard, {
|
|
16154
|
+
features: features,
|
|
16155
|
+
cardProps: {
|
|
16156
|
+
title,
|
|
16157
|
+
headerContent: (0,jsx_runtime_namespaceObject.jsx)(GaugeChartHeader, {
|
|
16158
|
+
features: features
|
|
16159
|
+
}),
|
|
16160
|
+
...widgetCardProps
|
|
16161
|
+
},
|
|
16162
|
+
children: (0,jsx_runtime_namespaceObject.jsxs)(Wrapper_Wrapper, {
|
|
16163
|
+
direction: "column",
|
|
16164
|
+
css: GaugeChart_ref2,
|
|
16165
|
+
children: [(0,jsx_runtime_namespaceObject.jsxs)(GaugeChartCanvas, {
|
|
16166
|
+
children: [(0,jsx_runtime_namespaceObject.jsx)(GaugeChartLayer, {
|
|
16167
|
+
children: withTrack && (0,jsx_runtime_namespaceObject.jsx)(GaugeChartBase, {
|
|
16168
|
+
data: [{
|
|
16169
|
+
value: trackSize
|
|
16170
|
+
}],
|
|
16171
|
+
colors: theme.colors.greyLighter,
|
|
16172
|
+
layers: ['arcs'],
|
|
16173
|
+
...trackProps
|
|
16174
|
+
})
|
|
16175
|
+
}), (0,jsx_runtime_namespaceObject.jsxs)(GaugeChartLayer, {
|
|
16176
|
+
ref: containerRef,
|
|
16177
|
+
children: [(0,jsx_runtime_namespaceObject.jsx)(GaugeChartBase, {
|
|
16178
|
+
data: normalizedSegments,
|
|
16179
|
+
...chartProps
|
|
16180
|
+
}), (0,jsx_runtime_namespaceObject.jsx)(GaugeChartTickers, {
|
|
16181
|
+
pieOffset: pieOffset,
|
|
16182
|
+
pieSize: pieSize,
|
|
16183
|
+
minValue: minValue,
|
|
16184
|
+
maxValue: maxValue,
|
|
16185
|
+
ticks: ticks
|
|
16186
|
+
}), withNeedle && (0,jsx_runtime_namespaceObject.jsx)(GaugeChartNeedle, {
|
|
16187
|
+
needleAngle: needleAngle,
|
|
16188
|
+
pieOffset: pieOffset,
|
|
16189
|
+
pieSize: pieSize
|
|
16190
|
+
})]
|
|
16191
|
+
})]
|
|
16192
|
+
}), pieSize.height > 0 && (0,jsx_runtime_namespaceObject.jsx)(GaugeChartLabels, {
|
|
16193
|
+
withLabels: withLabels,
|
|
16194
|
+
width: `${pieSize.width}px`,
|
|
16195
|
+
value: value,
|
|
16196
|
+
unitLabel: unitLabel,
|
|
16197
|
+
minLabel: minLabel,
|
|
16198
|
+
maxLabel: maxLabel,
|
|
16199
|
+
totalLabel: totalLabel
|
|
16200
|
+
})]
|
|
16201
|
+
})
|
|
16202
|
+
})
|
|
16203
|
+
});
|
|
16204
|
+
};
|
|
16205
|
+
const GaugeChart = WithFullscreenMode(GaugeChartComponent);
|
|
16206
|
+
;// ./src/components/Charts/GaugeChart/index.ts
|
|
16207
|
+
|
|
15785
16208
|
;// ./src/components/Charts/index.ts
|
|
15786
16209
|
|
|
15787
16210
|
|
|
@@ -15789,6 +16212,7 @@ const TreeMapChart = WithFullscreenMode(TreeMapChartComponent);
|
|
|
15789
16212
|
|
|
15790
16213
|
|
|
15791
16214
|
|
|
16215
|
+
|
|
15792
16216
|
;// ./src/components/Popover/hooks/index.ts
|
|
15793
16217
|
|
|
15794
16218
|
|
|
@@ -16386,13 +16810,15 @@ function Typeahead_styles_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tr
|
|
|
16386
16810
|
|
|
16387
16811
|
|
|
16388
16812
|
|
|
16813
|
+
// TODO: automatically calculate max-height
|
|
16814
|
+
// https://github.com/ssagroup/ui-kit/issues/385
|
|
16389
16815
|
const TypeaheadOptionsBase = /*#__PURE__*/base_default()("ul", true ? {
|
|
16390
16816
|
target: "e1vig1dw6"
|
|
16391
16817
|
} : 0)("padding:0;margin:0;list-style:none;background:#fff;border-radius:8px;filter:", ({
|
|
16392
16818
|
theme
|
|
16393
16819
|
}) => `drop-shadow(-4px 4px 14px ${theme.colors.greyDarker14})`, ";backdrop-filter:", ({
|
|
16394
16820
|
theme
|
|
16395
|
-
}) => `drop-shadow(-4px 4px 14px ${theme.colors.greyDarker14})`, ";" + ( true ? "" : 0));
|
|
16821
|
+
}) => `drop-shadow(-4px 4px 14px ${theme.colors.greyDarker14})`, ";overflow-y:auto;max-height:350px;" + ( true ? "" : 0));
|
|
16396
16822
|
const TypeaheadOption = /*#__PURE__*/base_default()("li", true ? {
|
|
16397
16823
|
target: "e1vig1dw5"
|
|
16398
16824
|
} : 0)("display:flex;align-items:center;padding:8px 16px;border:none;cursor:pointer;font-size:14px;gap:8px;padding:12px;height:40px;background:", ({
|