@indusaction/cms-design-system 0.2.0 → 0.2.1
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/index.cjs +812 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +170 -3
- package/dist/index.d.ts +170 -3
- package/dist/index.js +802 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -733,6 +733,682 @@ var Card = React__default.default.forwardRef(
|
|
|
733
733
|
}
|
|
734
734
|
);
|
|
735
735
|
Card.displayName = "Card";
|
|
736
|
+
var statusColors = {
|
|
737
|
+
primary: colors.brand.primary,
|
|
738
|
+
success: colors.semantic.success,
|
|
739
|
+
warning: colors.semantic.warning,
|
|
740
|
+
error: colors.semantic.error,
|
|
741
|
+
info: colors.semantic.info,
|
|
742
|
+
neutral: colors.neutral.gray600
|
|
743
|
+
};
|
|
744
|
+
var sizeStyles = {
|
|
745
|
+
small: {
|
|
746
|
+
padding: spacing.sm,
|
|
747
|
+
titleSize: fontSize.xs,
|
|
748
|
+
valueSize: fontSize.md,
|
|
749
|
+
iconSize: spacing.xl
|
|
750
|
+
},
|
|
751
|
+
default: {
|
|
752
|
+
minHeight: 120,
|
|
753
|
+
padding: spacing.md,
|
|
754
|
+
titleSize: fontSize.sm,
|
|
755
|
+
valueSize: fontSize.xl,
|
|
756
|
+
iconSize: 40
|
|
757
|
+
},
|
|
758
|
+
large: {
|
|
759
|
+
minHeight: 160,
|
|
760
|
+
padding: spacing.md,
|
|
761
|
+
titleSize: fontSize.md,
|
|
762
|
+
valueSize: fontSize.xxl,
|
|
763
|
+
iconSize: spacing.xxl
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
var MetricCard = React__default.default.forwardRef(
|
|
767
|
+
({
|
|
768
|
+
title,
|
|
769
|
+
value,
|
|
770
|
+
description,
|
|
771
|
+
variant = "outlined",
|
|
772
|
+
layout = "vertical",
|
|
773
|
+
size = "default",
|
|
774
|
+
status = "primary",
|
|
775
|
+
color,
|
|
776
|
+
textColor,
|
|
777
|
+
icon,
|
|
778
|
+
prefix,
|
|
779
|
+
suffix,
|
|
780
|
+
precision,
|
|
781
|
+
formatter,
|
|
782
|
+
groupSeparator = ",",
|
|
783
|
+
decimalSeparator = ".",
|
|
784
|
+
loading = false,
|
|
785
|
+
className,
|
|
786
|
+
style
|
|
787
|
+
}, ref) => {
|
|
788
|
+
const isMissingValue = value == null || typeof value === "number" && !Number.isFinite(value);
|
|
789
|
+
const displayValue = isMissingValue ? "\u2014" : value;
|
|
790
|
+
const accent = color ?? statusColors[status];
|
|
791
|
+
const dimensions = sizeStyles[size];
|
|
792
|
+
const isSolid = variant === "solid";
|
|
793
|
+
const isTinted = variant === "tinted";
|
|
794
|
+
const lightPreset = color == null && ["success", "warning", "error"].includes(status);
|
|
795
|
+
const foreground = textColor ?? (isSolid && !lightPreset ? colors.neutral.white : colors.neutral.gray800);
|
|
796
|
+
const tintedBackground = `color-mix(in srgb, ${accent} 12%, ${colors.neutral.white})`;
|
|
797
|
+
const cardBackground = isSolid ? accent : isTinted ? tintedBackground : colors.neutral.white;
|
|
798
|
+
const cardBorder = isTinted ? "none" : `1px solid ${variant === "outlined" ? colors.neutral.gray200 : accent}`;
|
|
799
|
+
const iconBadge = icon ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
800
|
+
"span",
|
|
801
|
+
{
|
|
802
|
+
"aria-hidden": "true",
|
|
803
|
+
style: {
|
|
804
|
+
display: "inline-flex",
|
|
805
|
+
alignItems: "center",
|
|
806
|
+
justifyContent: "center",
|
|
807
|
+
flexShrink: 0,
|
|
808
|
+
width: dimensions.iconSize,
|
|
809
|
+
height: dimensions.iconSize,
|
|
810
|
+
borderRadius: "50%",
|
|
811
|
+
fontSize: fontSize.lg,
|
|
812
|
+
color: foreground,
|
|
813
|
+
background: isSolid ? "rgba(255, 255, 255, 0.18)" : isTinted ? `color-mix(in srgb, ${accent} 22%, ${colors.neutral.white})` : colors.brand.primaryLight
|
|
814
|
+
},
|
|
815
|
+
children: icon
|
|
816
|
+
}
|
|
817
|
+
) : null;
|
|
818
|
+
const hasDescription = description != null && description !== false && description !== "";
|
|
819
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
820
|
+
Card,
|
|
821
|
+
{
|
|
822
|
+
ref,
|
|
823
|
+
className,
|
|
824
|
+
loading,
|
|
825
|
+
loadingRows: 2,
|
|
826
|
+
"aria-busy": loading,
|
|
827
|
+
styles: {
|
|
828
|
+
body: {
|
|
829
|
+
boxSizing: "border-box",
|
|
830
|
+
padding: dimensions.padding
|
|
831
|
+
}
|
|
832
|
+
},
|
|
833
|
+
style: {
|
|
834
|
+
background: cardBackground,
|
|
835
|
+
border: cardBorder,
|
|
836
|
+
color: foreground,
|
|
837
|
+
minHeight: dimensions.minHeight,
|
|
838
|
+
minWidth: 0,
|
|
839
|
+
...style
|
|
840
|
+
},
|
|
841
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
842
|
+
"div",
|
|
843
|
+
{
|
|
844
|
+
style: {
|
|
845
|
+
display: "flex",
|
|
846
|
+
flexDirection: layout === "horizontal" ? "row" : "column",
|
|
847
|
+
gap: spacing.sm,
|
|
848
|
+
minWidth: 0
|
|
849
|
+
},
|
|
850
|
+
children: [
|
|
851
|
+
layout === "horizontal" ? iconBadge : null,
|
|
852
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
853
|
+
"div",
|
|
854
|
+
{
|
|
855
|
+
style: {
|
|
856
|
+
display: "flex",
|
|
857
|
+
flexDirection: "column",
|
|
858
|
+
flex: 1,
|
|
859
|
+
minWidth: 0
|
|
860
|
+
},
|
|
861
|
+
children: [
|
|
862
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
863
|
+
"div",
|
|
864
|
+
{
|
|
865
|
+
style: {
|
|
866
|
+
color: foreground,
|
|
867
|
+
fontSize: dimensions.titleSize,
|
|
868
|
+
fontWeight: 500,
|
|
869
|
+
lineHeight: 1.4,
|
|
870
|
+
overflowWrap: "anywhere"
|
|
871
|
+
},
|
|
872
|
+
children: title
|
|
873
|
+
}
|
|
874
|
+
),
|
|
875
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
876
|
+
"div",
|
|
877
|
+
{
|
|
878
|
+
style: {
|
|
879
|
+
display: "flex",
|
|
880
|
+
alignItems: "flex-end",
|
|
881
|
+
justifyContent: "space-between",
|
|
882
|
+
gap: spacing.sm,
|
|
883
|
+
paddingTop: spacing.xs,
|
|
884
|
+
flexWrap: "wrap"
|
|
885
|
+
},
|
|
886
|
+
children: [
|
|
887
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
888
|
+
antd.Statistic,
|
|
889
|
+
{
|
|
890
|
+
value: displayValue,
|
|
891
|
+
prefix: isMissingValue ? void 0 : prefix,
|
|
892
|
+
suffix: isMissingValue ? void 0 : suffix,
|
|
893
|
+
precision,
|
|
894
|
+
formatter: isMissingValue ? void 0 : formatter,
|
|
895
|
+
groupSeparator,
|
|
896
|
+
decimalSeparator,
|
|
897
|
+
style: { flex: 1, minWidth: 0 },
|
|
898
|
+
valueStyle: {
|
|
899
|
+
color: foreground,
|
|
900
|
+
fontSize: dimensions.valueSize,
|
|
901
|
+
fontWeight: 600,
|
|
902
|
+
lineHeight: 1.5,
|
|
903
|
+
overflowWrap: "anywhere"
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
),
|
|
907
|
+
layout === "vertical" ? iconBadge : null
|
|
908
|
+
]
|
|
909
|
+
}
|
|
910
|
+
),
|
|
911
|
+
hasDescription ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
912
|
+
"div",
|
|
913
|
+
{
|
|
914
|
+
style: {
|
|
915
|
+
color: foreground,
|
|
916
|
+
marginTop: spacing.xs,
|
|
917
|
+
overflowWrap: "anywhere"
|
|
918
|
+
},
|
|
919
|
+
children: description
|
|
920
|
+
}
|
|
921
|
+
) : null
|
|
922
|
+
]
|
|
923
|
+
}
|
|
924
|
+
)
|
|
925
|
+
]
|
|
926
|
+
}
|
|
927
|
+
)
|
|
928
|
+
}
|
|
929
|
+
);
|
|
930
|
+
}
|
|
931
|
+
);
|
|
932
|
+
MetricCard.displayName = "MetricCard";
|
|
933
|
+
var defaultPalette = [
|
|
934
|
+
colors.brand.primary,
|
|
935
|
+
colors.brand.accent,
|
|
936
|
+
colors.semantic.success,
|
|
937
|
+
colors.semantic.warning,
|
|
938
|
+
colors.semantic.error,
|
|
939
|
+
colors.neutral.gray500
|
|
940
|
+
];
|
|
941
|
+
var defaultFormatter = (value) => value.toLocaleString("en-IN");
|
|
942
|
+
var truncateLabel = (label, max) => label.length > max ? `${label.slice(0, max - 1)}\u2026` : label;
|
|
943
|
+
function isGroupedData(data) {
|
|
944
|
+
return data.length > 0 && "values" in data[0];
|
|
945
|
+
}
|
|
946
|
+
function ChartLegend({ items }) {
|
|
947
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
948
|
+
"div",
|
|
949
|
+
{
|
|
950
|
+
"aria-label": "Chart legend",
|
|
951
|
+
style: { display: "flex", flexWrap: "wrap", gap: spacing.md, marginBottom: spacing.xs },
|
|
952
|
+
children: items.map(({ label, color }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
953
|
+
"span",
|
|
954
|
+
{
|
|
955
|
+
style: { alignItems: "center", color: colors.neutral.gray700, display: "inline-flex", fontSize: fontSize.xs, gap: spacing.xs },
|
|
956
|
+
children: [
|
|
957
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", style: { background: color, borderRadius: "50%", height: 8, width: 8 } }),
|
|
958
|
+
label
|
|
959
|
+
]
|
|
960
|
+
},
|
|
961
|
+
label
|
|
962
|
+
))
|
|
963
|
+
}
|
|
964
|
+
);
|
|
965
|
+
}
|
|
966
|
+
function ChartGrid({
|
|
967
|
+
padding,
|
|
968
|
+
width,
|
|
969
|
+
chartHeight,
|
|
970
|
+
maxValue,
|
|
971
|
+
formatValue
|
|
972
|
+
}) {
|
|
973
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: [0, 0.5, 1].map((ratio) => {
|
|
974
|
+
const y = padding.top + chartHeight * (1 - ratio);
|
|
975
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
976
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: padding.left, x2: width - padding.right, y1: y, y2: y, stroke: colors.neutral.gray200 }),
|
|
977
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: padding.left - 8, y: y + 4, textAnchor: "end", fill: colors.neutral.gray500, fontSize: 11, children: formatValue(Math.round(maxValue * ratio)) })
|
|
978
|
+
] }, ratio);
|
|
979
|
+
}) });
|
|
980
|
+
}
|
|
981
|
+
function ChartEmptyState({ height }) {
|
|
982
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
983
|
+
"div",
|
|
984
|
+
{
|
|
985
|
+
style: { alignItems: "center", color: colors.neutral.gray500, display: "flex", height, justifyContent: "center" },
|
|
986
|
+
children: "No data available"
|
|
987
|
+
}
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
function ColumnChart({
|
|
991
|
+
data,
|
|
992
|
+
mode = "basic",
|
|
993
|
+
seriesColors = defaultPalette,
|
|
994
|
+
showLegend = true,
|
|
995
|
+
height = 280,
|
|
996
|
+
color = colors.brand.primary,
|
|
997
|
+
ariaLabel = "Column chart",
|
|
998
|
+
formatValue = defaultFormatter,
|
|
999
|
+
style
|
|
1000
|
+
}) {
|
|
1001
|
+
if (!data.length) return /* @__PURE__ */ jsxRuntime.jsx(ChartEmptyState, { height });
|
|
1002
|
+
const grouped = isGroupedData(data);
|
|
1003
|
+
const activeMode = grouped && mode === "basic" ? "stacked" : mode;
|
|
1004
|
+
const W = 640;
|
|
1005
|
+
const pad = { top: 28, right: 20, bottom: 48, left: 48 };
|
|
1006
|
+
const cH = height - pad.top - pad.bottom;
|
|
1007
|
+
const cW = W - pad.left - pad.right;
|
|
1008
|
+
let maxVal = 1;
|
|
1009
|
+
let legendKeys = [];
|
|
1010
|
+
let barContent;
|
|
1011
|
+
if (activeMode === "stacked" && grouped) {
|
|
1012
|
+
const gd = data;
|
|
1013
|
+
legendKeys = [...new Set(gd.flatMap((d) => Object.keys(d.values)))];
|
|
1014
|
+
const totals = gd.map((d) => Object.values(d.values).reduce((s, v) => s + v, 0));
|
|
1015
|
+
maxVal = Math.max(...totals, 1);
|
|
1016
|
+
const slotW = cW / gd.length;
|
|
1017
|
+
const bw = Math.min(56, slotW * 0.58);
|
|
1018
|
+
barContent = gd.map((datum, i) => {
|
|
1019
|
+
const x = pad.left + slotW * i + (slotW - bw) / 2;
|
|
1020
|
+
let curY = pad.top + cH;
|
|
1021
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
1022
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { children: `${datum.label}: ${formatValue(totals[i])}` }),
|
|
1023
|
+
legendKeys.map((series, sIdx) => {
|
|
1024
|
+
const val = datum.values[series] ?? 0;
|
|
1025
|
+
if (val <= 0) return null;
|
|
1026
|
+
const h = val / maxVal * cH;
|
|
1027
|
+
curY -= h;
|
|
1028
|
+
return /* @__PURE__ */ jsxRuntime.jsx("rect", { x, y: curY, width: bw, height: h, fill: seriesColors[sIdx % seriesColors.length], children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${datum.label} - ${series}: ${formatValue(val)}` }) }, series);
|
|
1029
|
+
}),
|
|
1030
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: x + bw / 2, y: curY - 8, textAnchor: "middle", fill: colors.neutral.gray700, fontSize: 11, children: formatValue(totals[i]) }),
|
|
1031
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: x + bw / 2, y: height - 18, textAnchor: "middle", fill: colors.neutral.gray700, fontSize: 11, children: truncateLabel(datum.label, 16) })
|
|
1032
|
+
] }, datum.id ?? datum.label);
|
|
1033
|
+
});
|
|
1034
|
+
} else if (activeMode === "grouped" && grouped) {
|
|
1035
|
+
const gd = data;
|
|
1036
|
+
legendKeys = [...new Set(gd.flatMap((d) => Object.keys(d.values)))];
|
|
1037
|
+
maxVal = Math.max(...gd.flatMap((d) => Object.values(d.values)), 1);
|
|
1038
|
+
const slotW = cW / gd.length;
|
|
1039
|
+
const n = legendKeys.length;
|
|
1040
|
+
const gap = 2;
|
|
1041
|
+
const subW = Math.min(28, (slotW * 0.75 - (n - 1) * gap) / Math.max(n, 1));
|
|
1042
|
+
const grpW = n * subW + (n - 1) * gap;
|
|
1043
|
+
barContent = gd.map((datum, i) => {
|
|
1044
|
+
const gx = pad.left + slotW * i + (slotW - grpW) / 2;
|
|
1045
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
1046
|
+
legendKeys.map((series, sIdx) => {
|
|
1047
|
+
const val = datum.values[series] ?? 0;
|
|
1048
|
+
const h = Math.max(0, val / maxVal * cH);
|
|
1049
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
1050
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { children: `${datum.label} - ${series}: ${formatValue(val)}` }),
|
|
1051
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: gx + sIdx * (subW + gap), y: pad.top + cH - h, width: subW, height: h, rx: 3, fill: seriesColors[sIdx % seriesColors.length] })
|
|
1052
|
+
] }, series);
|
|
1053
|
+
}),
|
|
1054
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: pad.left + slotW * i + slotW / 2, y: height - 18, textAnchor: "middle", fill: colors.neutral.gray700, fontSize: 11, children: truncateLabel(datum.label, 16) })
|
|
1055
|
+
] }, datum.id ?? datum.label);
|
|
1056
|
+
});
|
|
1057
|
+
} else {
|
|
1058
|
+
const sd = data;
|
|
1059
|
+
maxVal = Math.max(...sd.map((d) => d.value), 1);
|
|
1060
|
+
const slotW = cW / sd.length;
|
|
1061
|
+
const bw = Math.min(56, slotW * 0.58);
|
|
1062
|
+
barContent = sd.map((datum, i) => {
|
|
1063
|
+
const h = Math.max(0, datum.value / maxVal * cH);
|
|
1064
|
+
const x = pad.left + slotW * i + (slotW - bw) / 2;
|
|
1065
|
+
const y = pad.top + cH - h;
|
|
1066
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
1067
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { children: `${datum.label}: ${formatValue(datum.value)}` }),
|
|
1068
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x, y, width: bw, height: h, rx: 4, fill: datum.color ?? color }),
|
|
1069
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: x + bw / 2, y: y - 8, textAnchor: "middle", fill: colors.neutral.gray700, fontSize: 11, children: formatValue(datum.value) }),
|
|
1070
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: x + bw / 2, y: height - 18, textAnchor: "middle", fill: colors.neutral.gray700, fontSize: 11, children: truncateLabel(datum.label, 16) })
|
|
1071
|
+
] }, datum.id ?? datum.label);
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
const hasLegend = showLegend && legendKeys.length > 1;
|
|
1075
|
+
const legendH = hasLegend ? 28 : 0;
|
|
1076
|
+
const svgH = height - legendH;
|
|
1077
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", height, justifyContent: "flex-end", ...style }, children: [
|
|
1078
|
+
hasLegend && /* @__PURE__ */ jsxRuntime.jsx(ChartLegend, { items: legendKeys.map((k, i) => ({ label: k, color: seriesColors[i % seriesColors.length] })) }),
|
|
1079
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { "aria-label": ariaLabel, role: "img", viewBox: `0 0 ${W} ${height}`, style: { display: "block", height: svgH, maxWidth: "100%", width: "100%" }, children: [
|
|
1080
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { children: ariaLabel }),
|
|
1081
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChartGrid, { padding: pad, width: W, chartHeight: cH, maxValue: maxVal, formatValue }),
|
|
1082
|
+
barContent
|
|
1083
|
+
] })
|
|
1084
|
+
] });
|
|
1085
|
+
}
|
|
1086
|
+
var defaultPalette2 = [
|
|
1087
|
+
colors.brand.primary,
|
|
1088
|
+
colors.brand.accent,
|
|
1089
|
+
colors.semantic.success,
|
|
1090
|
+
colors.semantic.warning,
|
|
1091
|
+
colors.semantic.error,
|
|
1092
|
+
colors.neutral.gray500
|
|
1093
|
+
];
|
|
1094
|
+
function BarChart({
|
|
1095
|
+
data,
|
|
1096
|
+
mode = "basic",
|
|
1097
|
+
seriesColors = defaultPalette2,
|
|
1098
|
+
showLegend = true,
|
|
1099
|
+
height = 280,
|
|
1100
|
+
color = colors.brand.primary,
|
|
1101
|
+
ariaLabel = "Bar chart",
|
|
1102
|
+
formatValue = defaultFormatter,
|
|
1103
|
+
style
|
|
1104
|
+
}) {
|
|
1105
|
+
if (!data.length) return /* @__PURE__ */ jsxRuntime.jsx(ChartEmptyState, { height });
|
|
1106
|
+
const grouped = isGroupedData(data);
|
|
1107
|
+
const activeMode = grouped && mode === "basic" ? "stacked" : mode;
|
|
1108
|
+
const W = 640;
|
|
1109
|
+
const pad = { top: 18, right: 70, bottom: 16, left: 145 };
|
|
1110
|
+
const cH = height - pad.top - pad.bottom;
|
|
1111
|
+
const cW = W - pad.left - pad.right;
|
|
1112
|
+
let maxVal = 1;
|
|
1113
|
+
let legendKeys = [];
|
|
1114
|
+
let rowContent;
|
|
1115
|
+
if (activeMode === "stacked" && grouped) {
|
|
1116
|
+
const gd = data;
|
|
1117
|
+
legendKeys = [...new Set(gd.flatMap((d) => Object.keys(d.values)))];
|
|
1118
|
+
const totals = gd.map((d) => Object.values(d.values).reduce((s, v) => s + v, 0));
|
|
1119
|
+
const maxVal2 = Math.max(...totals, 1);
|
|
1120
|
+
const rowH = cH / gd.length;
|
|
1121
|
+
const bh = Math.min(28, rowH * 0.62);
|
|
1122
|
+
rowContent = gd.map((datum, i) => {
|
|
1123
|
+
const y = pad.top + i * rowH + (rowH - bh) / 2;
|
|
1124
|
+
let curX = pad.left;
|
|
1125
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
1126
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { children: `${datum.label}: ${formatValue(totals[i])}` }),
|
|
1127
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: pad.left - 10, y: y + bh / 2 + 4, textAnchor: "end", fill: colors.neutral.gray700, fontSize: 11, children: truncateLabel(datum.label, 22) }),
|
|
1128
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: pad.left, y, width: cW, height: bh, fill: colors.neutral.gray200, rx: 4 }),
|
|
1129
|
+
legendKeys.map((series, sIdx) => {
|
|
1130
|
+
const val = datum.values[series] ?? 0;
|
|
1131
|
+
if (val <= 0) return null;
|
|
1132
|
+
const w = val / maxVal2 * cW;
|
|
1133
|
+
const segX = curX;
|
|
1134
|
+
curX += w;
|
|
1135
|
+
return /* @__PURE__ */ jsxRuntime.jsx("rect", { x: segX, y, width: w, height: bh, fill: seriesColors[sIdx % seriesColors.length], children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${datum.label} - ${series}: ${formatValue(val)}` }) }, series);
|
|
1136
|
+
}),
|
|
1137
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: curX + 8, y: y + bh / 2 + 4, fill: colors.neutral.gray700, fontSize: 11, children: formatValue(totals[i]) })
|
|
1138
|
+
] }, datum.id ?? datum.label);
|
|
1139
|
+
});
|
|
1140
|
+
} else if (activeMode === "grouped" && grouped) {
|
|
1141
|
+
const gd = data;
|
|
1142
|
+
legendKeys = [...new Set(gd.flatMap((d) => Object.keys(d.values)))];
|
|
1143
|
+
const maxVal2 = Math.max(...gd.flatMap((d) => Object.values(d.values)), 1);
|
|
1144
|
+
const rowH = cH / gd.length;
|
|
1145
|
+
const n = legendKeys.length;
|
|
1146
|
+
const gap = 2;
|
|
1147
|
+
const subH = Math.min(18, (rowH * 0.75 - (n - 1) * gap) / Math.max(n, 1));
|
|
1148
|
+
const grpH = n * subH + (n - 1) * gap;
|
|
1149
|
+
rowContent = gd.map((datum, i) => {
|
|
1150
|
+
const gy = pad.top + i * rowH + (rowH - grpH) / 2;
|
|
1151
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
1152
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: pad.left - 10, y: gy + grpH / 2 + 4, textAnchor: "end", fill: colors.neutral.gray700, fontSize: 11, children: truncateLabel(datum.label, 22) }),
|
|
1153
|
+
legendKeys.map((series, sIdx) => {
|
|
1154
|
+
const val = datum.values[series] ?? 0;
|
|
1155
|
+
const bw = val / maxVal2 * cW;
|
|
1156
|
+
const sy = gy + sIdx * (subH + gap);
|
|
1157
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
1158
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { children: `${datum.label} - ${series}: ${formatValue(val)}` }),
|
|
1159
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: pad.left, y: sy, width: cW, height: subH, fill: colors.neutral.gray200, rx: 2 }),
|
|
1160
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: pad.left, y: sy, width: bw, height: subH, fill: seriesColors[sIdx % seriesColors.length], rx: 2 }),
|
|
1161
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: pad.left + bw + 6, y: sy + subH / 2 + 4, fill: colors.neutral.gray700, fontSize: 10, children: formatValue(val) })
|
|
1162
|
+
] }, series);
|
|
1163
|
+
})
|
|
1164
|
+
] }, datum.id ?? datum.label);
|
|
1165
|
+
});
|
|
1166
|
+
} else {
|
|
1167
|
+
const sd = data;
|
|
1168
|
+
maxVal = Math.max(...sd.map((d) => d.value), 1);
|
|
1169
|
+
const rowH = cH / sd.length;
|
|
1170
|
+
const bh = Math.min(28, rowH * 0.62);
|
|
1171
|
+
rowContent = sd.map((datum, i) => {
|
|
1172
|
+
const y = pad.top + i * rowH + (rowH - bh) / 2;
|
|
1173
|
+
const bw = datum.value / maxVal * cW;
|
|
1174
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
1175
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { children: `${datum.label}: ${formatValue(datum.value)}` }),
|
|
1176
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: pad.left - 10, y: y + bh / 2 + 4, textAnchor: "end", fill: colors.neutral.gray700, fontSize: 11, children: truncateLabel(datum.label, 22) }),
|
|
1177
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: pad.left, y, width: cW, height: bh, fill: colors.neutral.gray200, rx: 4 }),
|
|
1178
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: pad.left, y, width: bw, height: bh, fill: datum.color ?? color, rx: 4 }),
|
|
1179
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: pad.left + bw + 8, y: y + bh / 2 + 4, fill: colors.neutral.gray700, fontSize: 11, children: formatValue(datum.value) })
|
|
1180
|
+
] }, datum.id ?? datum.label);
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
const hasLegend = showLegend && legendKeys.length > 1;
|
|
1184
|
+
const legendH = hasLegend ? 28 : 0;
|
|
1185
|
+
const svgH = height - legendH;
|
|
1186
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", height, justifyContent: "flex-end", ...style }, children: [
|
|
1187
|
+
hasLegend && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { paddingLeft: pad.left }, children: /* @__PURE__ */ jsxRuntime.jsx(ChartLegend, { items: legendKeys.map((k, i) => ({ label: k, color: seriesColors[i % seriesColors.length] })) }) }),
|
|
1188
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { "aria-label": ariaLabel, role: "img", viewBox: `0 0 ${W} ${height}`, style: { display: "block", height: svgH, maxWidth: "100%", width: "100%" }, children: [
|
|
1189
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { children: ariaLabel }),
|
|
1190
|
+
rowContent
|
|
1191
|
+
] })
|
|
1192
|
+
] });
|
|
1193
|
+
}
|
|
1194
|
+
var defaultPalette3 = [
|
|
1195
|
+
colors.brand.primary,
|
|
1196
|
+
colors.brand.accent,
|
|
1197
|
+
colors.semantic.success,
|
|
1198
|
+
colors.semantic.warning,
|
|
1199
|
+
colors.semantic.error,
|
|
1200
|
+
colors.neutral.gray500
|
|
1201
|
+
];
|
|
1202
|
+
function DonutChart({
|
|
1203
|
+
data,
|
|
1204
|
+
height = 280,
|
|
1205
|
+
centerLabel = "Total",
|
|
1206
|
+
ariaLabel = "Donut chart",
|
|
1207
|
+
showLegend = true,
|
|
1208
|
+
formatValue = defaultFormatter,
|
|
1209
|
+
style
|
|
1210
|
+
}) {
|
|
1211
|
+
const usableData = data.filter(({ value }) => value > 0);
|
|
1212
|
+
const total = usableData.reduce((sum, { value }) => sum + value, 0);
|
|
1213
|
+
if (!total) return /* @__PURE__ */ jsxRuntime.jsx(ChartEmptyState, { height });
|
|
1214
|
+
const radius = 76;
|
|
1215
|
+
const circumference = 2 * Math.PI * radius;
|
|
1216
|
+
let consumed = 0;
|
|
1217
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { alignItems: "center", display: "flex", flexWrap: "wrap", gap: spacing.lg, justifyContent: "center", height, minHeight: height, ...style }, children: [
|
|
1218
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { "aria-label": ariaLabel, role: "img", viewBox: "0 0 220 220", style: { height: Math.min(height, 220), width: Math.min(height, 220) }, children: [
|
|
1219
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { children: ariaLabel }),
|
|
1220
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "110", cy: "110", fill: "none", r: radius, stroke: colors.neutral.gray200, strokeWidth: "30" }),
|
|
1221
|
+
usableData.map((datum, index) => {
|
|
1222
|
+
const segment = datum.value / total * circumference;
|
|
1223
|
+
const offset = -consumed;
|
|
1224
|
+
consumed += segment;
|
|
1225
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1226
|
+
"circle",
|
|
1227
|
+
{
|
|
1228
|
+
cx: "110",
|
|
1229
|
+
cy: "110",
|
|
1230
|
+
fill: "none",
|
|
1231
|
+
r: radius,
|
|
1232
|
+
stroke: datum.color ?? defaultPalette3[index % defaultPalette3.length],
|
|
1233
|
+
strokeDasharray: `${segment} ${circumference - segment}`,
|
|
1234
|
+
strokeDashoffset: offset,
|
|
1235
|
+
strokeWidth: "30",
|
|
1236
|
+
transform: "rotate(-90 110 110)",
|
|
1237
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${datum.label}: ${formatValue(datum.value)}` })
|
|
1238
|
+
},
|
|
1239
|
+
datum.id ?? datum.label
|
|
1240
|
+
);
|
|
1241
|
+
}),
|
|
1242
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: "110", y: "102", textAnchor: "middle", fill: colors.neutral.gray500, fontSize: "13", children: centerLabel }),
|
|
1243
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: "110", y: "128", textAnchor: "middle", fill: colors.neutral.gray700, fontSize: "22", fontWeight: "600", children: formatValue(total) })
|
|
1244
|
+
] }),
|
|
1245
|
+
showLegend ? /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-label": "Chart legend", style: { display: "grid", gap: spacing.xs }, children: usableData.map((datum, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { alignItems: "center", display: "flex", gap: spacing.xs }, children: [
|
|
1246
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", style: { background: datum.color ?? defaultPalette3[index % defaultPalette3.length], borderRadius: "50%", height: 10, width: 10 } }),
|
|
1247
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { color: colors.neutral.gray700, fontSize: fontSize.xs }, children: [
|
|
1248
|
+
datum.label,
|
|
1249
|
+
": ",
|
|
1250
|
+
formatValue(datum.value)
|
|
1251
|
+
] })
|
|
1252
|
+
] }, datum.id ?? datum.label)) }) : null
|
|
1253
|
+
] });
|
|
1254
|
+
}
|
|
1255
|
+
var defaultPalette4 = [
|
|
1256
|
+
colors.brand.primary,
|
|
1257
|
+
colors.brand.accent,
|
|
1258
|
+
colors.semantic.success,
|
|
1259
|
+
colors.semantic.warning,
|
|
1260
|
+
colors.semantic.error,
|
|
1261
|
+
colors.neutral.gray500
|
|
1262
|
+
];
|
|
1263
|
+
function createSmoothSplinePath(points) {
|
|
1264
|
+
if (points.length === 0) return "";
|
|
1265
|
+
if (points.length === 1) return `M ${points[0].x} ${points[0].y}`;
|
|
1266
|
+
if (points.length === 2)
|
|
1267
|
+
return `M ${points[0].x} ${points[0].y} L ${points[1].x} ${points[1].y}`;
|
|
1268
|
+
let path = `M ${points[0].x} ${points[0].y}`;
|
|
1269
|
+
const tension = 0.2;
|
|
1270
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
1271
|
+
const p0 = points[i > 0 ? i - 1 : i];
|
|
1272
|
+
const p1 = points[i];
|
|
1273
|
+
const p2 = points[i + 1];
|
|
1274
|
+
const p3 = points[i + 2 < points.length ? i + 2 : i + 1];
|
|
1275
|
+
const cp1x = p1.x + (p2.x - p0.x) * tension;
|
|
1276
|
+
const cp1y = p1.y + (p2.y - p0.y) * tension;
|
|
1277
|
+
const cp2x = p2.x - (p3.x - p1.x) * tension;
|
|
1278
|
+
const cp2y = p2.y - (p3.y - p1.y) * tension;
|
|
1279
|
+
path += ` C ${cp1x.toFixed(2)} ${cp1y.toFixed(2)}, ${cp2x.toFixed(2)} ${cp2y.toFixed(2)}, ${p2.x.toFixed(2)} ${p2.y.toFixed(2)}`;
|
|
1280
|
+
}
|
|
1281
|
+
return path;
|
|
1282
|
+
}
|
|
1283
|
+
function TimeSeriesChart({
|
|
1284
|
+
data,
|
|
1285
|
+
type = "line",
|
|
1286
|
+
smooth = false,
|
|
1287
|
+
height = 280,
|
|
1288
|
+
colors: seriesColors = defaultPalette4,
|
|
1289
|
+
ariaLabel = "Time series chart",
|
|
1290
|
+
showLegend = true,
|
|
1291
|
+
formatValue = defaultFormatter,
|
|
1292
|
+
formatDate = (date) => date,
|
|
1293
|
+
threshold,
|
|
1294
|
+
thresholdLabel,
|
|
1295
|
+
style
|
|
1296
|
+
}) {
|
|
1297
|
+
if (!data.length) return /* @__PURE__ */ jsxRuntime.jsx(ChartEmptyState, { height });
|
|
1298
|
+
const W = 640;
|
|
1299
|
+
const pad = { top: 28, right: 20, bottom: 48, left: 48 };
|
|
1300
|
+
const cH = height - pad.top - pad.bottom;
|
|
1301
|
+
const cW = W - pad.left - pad.right;
|
|
1302
|
+
const maxVal = Math.max(...data.map(({ value }) => value), threshold ?? 0, 1);
|
|
1303
|
+
const dates = [...new Set(data.map(({ date }) => date))];
|
|
1304
|
+
const seriesGroups = [...new Map(data.map((d) => [d.series ?? "Value", true])).keys()].map((s) => ({
|
|
1305
|
+
series: s,
|
|
1306
|
+
data: data.filter((d) => (d.series ?? "Value") === s)
|
|
1307
|
+
}));
|
|
1308
|
+
const xFor = (date) => pad.left + (dates.length > 1 ? dates.indexOf(date) / (dates.length - 1) * cW : cW / 2);
|
|
1309
|
+
const yFor = (v) => pad.top + cH - v / maxVal * cH;
|
|
1310
|
+
const bottom = pad.top + cH;
|
|
1311
|
+
const dateIdxs = dates.length <= 6 ? dates.map((_, i) => i) : [0, Math.round((dates.length - 1) / 2), dates.length - 1];
|
|
1312
|
+
const hasLegend = showLegend && seriesGroups.length > 1;
|
|
1313
|
+
const legendH = hasLegend ? 28 : 0;
|
|
1314
|
+
const svgH = height - legendH;
|
|
1315
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column", height, justifyContent: "flex-end", ...style }, children: [
|
|
1316
|
+
hasLegend && /* @__PURE__ */ jsxRuntime.jsx(ChartLegend, { items: seriesGroups.map(({ series: s }, i) => ({ label: s, color: seriesColors[i % seriesColors.length] })) }),
|
|
1317
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { "aria-label": ariaLabel, role: "img", viewBox: `0 0 ${W} ${height}`, style: { display: "block", height: svgH, maxWidth: "100%", width: "100%" }, children: [
|
|
1318
|
+
/* @__PURE__ */ jsxRuntime.jsx("title", { children: ariaLabel }),
|
|
1319
|
+
/* @__PURE__ */ jsxRuntime.jsx(ChartGrid, { padding: pad, width: W, chartHeight: cH, maxValue: maxVal, formatValue }),
|
|
1320
|
+
dateIdxs.map((i) => /* @__PURE__ */ jsxRuntime.jsx("text", { x: xFor(dates[i]), y: height - 18, textAnchor: "middle", fill: colors.neutral.gray700, fontSize: 11, children: formatDate(dates[i]) }, dates[i])),
|
|
1321
|
+
threshold != null && /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
1322
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: pad.left, x2: W - pad.right, y1: yFor(threshold), y2: yFor(threshold), stroke: colors.semantic.error, strokeDasharray: "5 4" }),
|
|
1323
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x: W - pad.right, y: yFor(threshold) - 6, textAnchor: "end", fill: colors.semantic.error, fontSize: 11, children: thresholdLabel ?? formatValue(threshold) })
|
|
1324
|
+
] }),
|
|
1325
|
+
seriesGroups.map(({ series: sName, data: sd }, idx) => {
|
|
1326
|
+
const clr = seriesColors[idx % seriesColors.length];
|
|
1327
|
+
const coords = sd.map((d) => ({ x: xFor(d.date), y: yFor(d.value) }));
|
|
1328
|
+
const first = coords[0];
|
|
1329
|
+
const last = coords[coords.length - 1];
|
|
1330
|
+
let pathD;
|
|
1331
|
+
if (type === "step") {
|
|
1332
|
+
pathD = sd.reduce((p, d, i) => {
|
|
1333
|
+
const x = xFor(d.date), y = yFor(d.value);
|
|
1334
|
+
return i === 0 ? `M ${x} ${y}` : `${p} H ${x} V ${y}`;
|
|
1335
|
+
}, "");
|
|
1336
|
+
} else if (smooth) {
|
|
1337
|
+
pathD = createSmoothSplinePath(coords);
|
|
1338
|
+
} else {
|
|
1339
|
+
pathD = coords.map((c, i) => `${i === 0 ? "M" : "L"} ${c.x} ${c.y}`).join(" ");
|
|
1340
|
+
}
|
|
1341
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
1342
|
+
type === "area" && first && last && /* @__PURE__ */ jsxRuntime.jsx("path", { d: `${pathD} L ${last.x} ${bottom} L ${first.x} ${bottom} Z`, fill: clr, fillOpacity: 0.14 }),
|
|
1343
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: pathD, fill: "none", stroke: clr, strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2.5" }),
|
|
1344
|
+
sd.map((d) => /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: xFor(d.date), cy: yFor(d.value), fill: clr, r: "3", children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${sName}, ${formatDate(d.date)}: ${formatValue(d.value)}` }) }, d.id ?? `${sName}-${d.date}`))
|
|
1345
|
+
] }, sName);
|
|
1346
|
+
})
|
|
1347
|
+
] })
|
|
1348
|
+
] });
|
|
1349
|
+
}
|
|
1350
|
+
var LineChart = TimeSeriesChart;
|
|
1351
|
+
function BulletChart({
|
|
1352
|
+
data,
|
|
1353
|
+
height = 280,
|
|
1354
|
+
ariaLabel = "Bullet chart",
|
|
1355
|
+
formatValue = defaultFormatter,
|
|
1356
|
+
style
|
|
1357
|
+
}) {
|
|
1358
|
+
if (!data.length) return /* @__PURE__ */ jsxRuntime.jsx(ChartEmptyState, { height });
|
|
1359
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-label": ariaLabel, role: "img", style: { display: "flex", flexDirection: "column", justifyContent: "center", gap: spacing.md, height, minHeight: height, ...style }, children: data.map((datum) => {
|
|
1360
|
+
const max = datum.max ?? Math.max(datum.value, datum.target, ...datum.ranges ?? [], 1);
|
|
1361
|
+
const ranges = datum.ranges ?? [max * 0.6, max * 0.8, max];
|
|
1362
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1363
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { color: colors.neutral.gray700, display: "flex", fontSize: fontSize.xs, justifyContent: "space-between", marginBottom: spacing.xxs }, children: [
|
|
1364
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: datum.label }),
|
|
1365
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
1366
|
+
formatValue(datum.value),
|
|
1367
|
+
" / ",
|
|
1368
|
+
formatValue(datum.target)
|
|
1369
|
+
] })
|
|
1370
|
+
] }),
|
|
1371
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { background: colors.neutral.gray200, height: 20, overflow: "hidden", position: "relative" }, children: [
|
|
1372
|
+
ranges.map((range, index) => /* @__PURE__ */ jsxRuntime.jsx("span", { style: { background: ["#F5F5F5", "#E8EBF2", "#D9DFF0"][Math.min(index, 2)], height: "100%", left: index === 0 ? 0 : `${ranges[index - 1] / max * 100}%`, position: "absolute", width: `${(range - (ranges[index - 1] ?? 0)) / max * 100}%` } }, range)),
|
|
1373
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { background: colors.brand.primary, height: 8, left: 0, position: "absolute", top: 6, width: `${Math.min(100, datum.value / max * 100)}%` } }),
|
|
1374
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-label": `Target ${formatValue(datum.target)}`, style: { background: colors.neutral.gray700, height: "100%", left: `${Math.min(100, datum.target / max * 100)}%`, position: "absolute", top: 0, width: 2 } })
|
|
1375
|
+
] })
|
|
1376
|
+
] }, datum.id ?? datum.label);
|
|
1377
|
+
}) });
|
|
1378
|
+
}
|
|
1379
|
+
function HistogramChart({
|
|
1380
|
+
data,
|
|
1381
|
+
bins = "auto",
|
|
1382
|
+
height = 280,
|
|
1383
|
+
color,
|
|
1384
|
+
ariaLabel = "Histogram",
|
|
1385
|
+
style
|
|
1386
|
+
}) {
|
|
1387
|
+
if (!data.length) return /* @__PURE__ */ jsxRuntime.jsx(ChartEmptyState, { height });
|
|
1388
|
+
const min = Math.min(...data);
|
|
1389
|
+
const max = Math.max(...data);
|
|
1390
|
+
const binCount = typeof bins === "number" ? Math.max(1, Math.floor(bins)) : Math.max(1, Math.ceil(Math.sqrt(data.length)));
|
|
1391
|
+
const size = max === min ? 1 : (max - min) / binCount;
|
|
1392
|
+
const bucketData = Array.from({ length: binCount }, (_, index) => {
|
|
1393
|
+
const start = min + index * size;
|
|
1394
|
+
const end = index === binCount - 1 ? max : start + size;
|
|
1395
|
+
const count = data.filter(
|
|
1396
|
+
(value) => index === binCount - 1 ? value >= start && value <= end : value >= start && value < end
|
|
1397
|
+
).length;
|
|
1398
|
+
return { label: `${start.toFixed(0)}\u2013${end.toFixed(0)}`, value: count };
|
|
1399
|
+
});
|
|
1400
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1401
|
+
ColumnChart,
|
|
1402
|
+
{
|
|
1403
|
+
ariaLabel,
|
|
1404
|
+
color,
|
|
1405
|
+
data: bucketData,
|
|
1406
|
+
formatValue: defaultFormatter,
|
|
1407
|
+
height,
|
|
1408
|
+
style
|
|
1409
|
+
}
|
|
1410
|
+
);
|
|
1411
|
+
}
|
|
736
1412
|
var Modal = ({ children, ...rest }) => {
|
|
737
1413
|
return /* @__PURE__ */ jsxRuntime.jsx(antd.Modal, { ...rest, children });
|
|
738
1414
|
};
|
|
@@ -811,8 +1487,10 @@ var Header = React__default.default.forwardRef(
|
|
|
811
1487
|
gap: spacing.lg,
|
|
812
1488
|
flexWrap: "nowrap",
|
|
813
1489
|
padding: `${spacing.lg}px ${spacing.xl}px`,
|
|
814
|
-
background:
|
|
1490
|
+
background: "transparent",
|
|
1491
|
+
border: "none",
|
|
815
1492
|
borderBottom: `1px solid ${colors.neutral.gray200}`,
|
|
1493
|
+
boxShadow: "none",
|
|
816
1494
|
position: sticky ? "sticky" : void 0,
|
|
817
1495
|
top: sticky ? 0 : void 0,
|
|
818
1496
|
zIndex: sticky ? 20 : void 0,
|
|
@@ -1056,6 +1734,21 @@ function CloseIcon({ size = 14, className, style }) {
|
|
|
1056
1734
|
}
|
|
1057
1735
|
);
|
|
1058
1736
|
}
|
|
1737
|
+
function DownloadIcon({ size = 14, className, style }) {
|
|
1738
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1739
|
+
"svg",
|
|
1740
|
+
{
|
|
1741
|
+
width: size,
|
|
1742
|
+
height: size,
|
|
1743
|
+
viewBox: "64 64 896 896",
|
|
1744
|
+
fill: "currentColor",
|
|
1745
|
+
"aria-hidden": "true",
|
|
1746
|
+
className,
|
|
1747
|
+
style,
|
|
1748
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M505.7 661a8 8 0 0012.6 0l112-122c4.6-5 1-13-5.7-13H544V224c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v302h-80.6c-6.7 0-10.4 8-5.7 13l112 122zM832 768H192c-17.7 0-32 14.3-32 32v48c0 4.4 3.6 8 8 8h688c4.4 0 8-3.6 8-8v-48c0-17.7-14.3-32-32-32z" })
|
|
1749
|
+
}
|
|
1750
|
+
);
|
|
1751
|
+
}
|
|
1059
1752
|
var { Sider } = antd.Layout;
|
|
1060
1753
|
var MOBILE_HEADER = spacing.xxl;
|
|
1061
1754
|
var LOGO_HEIGHT = spacing.xxl + spacing.md;
|
|
@@ -1106,7 +1799,6 @@ function SideNavFooter({
|
|
|
1106
1799
|
{
|
|
1107
1800
|
style: {
|
|
1108
1801
|
flexShrink: 0,
|
|
1109
|
-
borderTop: `1px solid ${colors.neutral.gray200}`,
|
|
1110
1802
|
padding: collapsed ? spacing.sm : spacing.md,
|
|
1111
1803
|
display: "flex",
|
|
1112
1804
|
flexDirection: collapsed ? "column" : "row",
|
|
@@ -1227,8 +1919,7 @@ function SideNavPanel({
|
|
|
1227
1919
|
flexDirection: collapsed ? "column" : "row",
|
|
1228
1920
|
alignItems: "center",
|
|
1229
1921
|
gap: spacing.xs,
|
|
1230
|
-
padding: collapsed ? spacing.sm : spacing.md
|
|
1231
|
-
borderBottom: `1px solid ${colors.neutral.gray200}`
|
|
1922
|
+
padding: collapsed ? spacing.sm : spacing.md
|
|
1232
1923
|
},
|
|
1233
1924
|
children: [
|
|
1234
1925
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1430,7 +2121,6 @@ function SideNav({
|
|
|
1430
2121
|
justifyContent: "space-between",
|
|
1431
2122
|
gap: spacing.xs,
|
|
1432
2123
|
paddingInline: spacing.md,
|
|
1433
|
-
borderBottom: `1px solid ${colors.neutral.gray200}`,
|
|
1434
2124
|
background: colors.neutral.white
|
|
1435
2125
|
},
|
|
1436
2126
|
children: [
|
|
@@ -1639,18 +2329,132 @@ function UnauthorizedPage({
|
|
|
1639
2329
|
);
|
|
1640
2330
|
}
|
|
1641
2331
|
UnauthorizedPage.displayName = "UnauthorizedPage";
|
|
2332
|
+
var FILLED_BG = {
|
|
2333
|
+
success: colors.semantic.success,
|
|
2334
|
+
error: colors.semantic.error,
|
|
2335
|
+
warning: colors.semantic.warning,
|
|
2336
|
+
info: colors.brand.primary
|
|
2337
|
+
};
|
|
2338
|
+
var InlineAlert = React__default.default.forwardRef(function InlineAlert2({
|
|
2339
|
+
type = "info",
|
|
2340
|
+
showIcon = true,
|
|
2341
|
+
variant = "outlined",
|
|
2342
|
+
style,
|
|
2343
|
+
className,
|
|
2344
|
+
...rest
|
|
2345
|
+
}, ref) {
|
|
2346
|
+
const isFilled = variant === "filled";
|
|
2347
|
+
const alertStyle = {
|
|
2348
|
+
...isFilled ? {
|
|
2349
|
+
backgroundColor: FILLED_BG[type],
|
|
2350
|
+
borderColor: FILLED_BG[type],
|
|
2351
|
+
color: colors.neutral.white
|
|
2352
|
+
} : void 0,
|
|
2353
|
+
...style
|
|
2354
|
+
};
|
|
2355
|
+
const alertElement = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2356
|
+
antd.Alert,
|
|
2357
|
+
{
|
|
2358
|
+
ref,
|
|
2359
|
+
type,
|
|
2360
|
+
showIcon,
|
|
2361
|
+
style: alertStyle,
|
|
2362
|
+
className: [
|
|
2363
|
+
isFilled ? "cms-alert-filled" : "cms-alert-outlined",
|
|
2364
|
+
className
|
|
2365
|
+
].filter(Boolean).join(" "),
|
|
2366
|
+
...rest
|
|
2367
|
+
}
|
|
2368
|
+
);
|
|
2369
|
+
if (isFilled) {
|
|
2370
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2371
|
+
antd.ConfigProvider,
|
|
2372
|
+
{
|
|
2373
|
+
theme: {
|
|
2374
|
+
components: {
|
|
2375
|
+
Alert: {
|
|
2376
|
+
colorText: colors.neutral.white,
|
|
2377
|
+
colorTextHeading: colors.neutral.white,
|
|
2378
|
+
colorIcon: colors.neutral.white,
|
|
2379
|
+
colorIconHover: colors.neutral.gray200
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
},
|
|
2383
|
+
children: alertElement
|
|
2384
|
+
}
|
|
2385
|
+
);
|
|
2386
|
+
}
|
|
2387
|
+
return alertElement;
|
|
2388
|
+
});
|
|
2389
|
+
InlineAlert.displayName = "InlineAlert";
|
|
2390
|
+
var NotificationContext = React.createContext(null);
|
|
2391
|
+
var useNotification = () => {
|
|
2392
|
+
const context = React.useContext(NotificationContext);
|
|
2393
|
+
if (!context) {
|
|
2394
|
+
throw new Error(
|
|
2395
|
+
"useNotification must be used within a <NotificationProvider>. Wrap your component tree with <NotificationProvider>."
|
|
2396
|
+
);
|
|
2397
|
+
}
|
|
2398
|
+
return context;
|
|
2399
|
+
};
|
|
2400
|
+
var useNotifications = useNotification;
|
|
2401
|
+
var toAntNotifyArgs = (config) => ({
|
|
2402
|
+
...config,
|
|
2403
|
+
btn: config.actions ?? config.btn
|
|
2404
|
+
});
|
|
2405
|
+
var InternalNotificationProvider = ({
|
|
2406
|
+
children
|
|
2407
|
+
}) => {
|
|
2408
|
+
const [messageApi, messageContextHolder] = antd.message.useMessage();
|
|
2409
|
+
const [notificationApi, notificationContextHolder] = antd.notification.useNotification();
|
|
2410
|
+
const value = React.useMemo(
|
|
2411
|
+
() => ({
|
|
2412
|
+
toast: messageApi,
|
|
2413
|
+
notify: {
|
|
2414
|
+
...notificationApi,
|
|
2415
|
+
open: (config) => notificationApi.open(toAntNotifyArgs(config)),
|
|
2416
|
+
success: (config) => notificationApi.success(toAntNotifyArgs(config)),
|
|
2417
|
+
error: (config) => notificationApi.error(toAntNotifyArgs(config)),
|
|
2418
|
+
info: (config) => notificationApi.info(toAntNotifyArgs(config)),
|
|
2419
|
+
warning: (config) => notificationApi.warning(toAntNotifyArgs(config))
|
|
2420
|
+
}
|
|
2421
|
+
}),
|
|
2422
|
+
[messageApi, notificationApi]
|
|
2423
|
+
);
|
|
2424
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(NotificationContext.Provider, { value, children: [
|
|
2425
|
+
messageContextHolder,
|
|
2426
|
+
notificationContextHolder,
|
|
2427
|
+
children
|
|
2428
|
+
] });
|
|
2429
|
+
};
|
|
2430
|
+
var NotificationProvider = Object.assign(
|
|
2431
|
+
InternalNotificationProvider,
|
|
2432
|
+
{
|
|
2433
|
+
Alert: InlineAlert
|
|
2434
|
+
}
|
|
2435
|
+
);
|
|
1642
2436
|
|
|
2437
|
+
exports.BarChart = BarChart;
|
|
2438
|
+
exports.BulletChart = BulletChart;
|
|
1643
2439
|
exports.Button = Button;
|
|
1644
2440
|
exports.Card = Card;
|
|
1645
2441
|
exports.CloseIcon = CloseIcon;
|
|
1646
2442
|
exports.CollapseIcon = CollapseIcon;
|
|
2443
|
+
exports.ColumnChart = ColumnChart;
|
|
2444
|
+
exports.DonutChart = DonutChart;
|
|
2445
|
+
exports.DownloadIcon = DownloadIcon;
|
|
1647
2446
|
exports.Dropdown = Dropdown;
|
|
1648
2447
|
exports.Header = Header;
|
|
2448
|
+
exports.HistogramChart = HistogramChart;
|
|
2449
|
+
exports.InlineAlert = InlineAlert;
|
|
2450
|
+
exports.LineChart = LineChart;
|
|
1649
2451
|
exports.Link = Link;
|
|
1650
2452
|
exports.LogoutIcon = LogoutIcon;
|
|
1651
2453
|
exports.MenuIcon = MenuIcon;
|
|
2454
|
+
exports.MetricCard = MetricCard;
|
|
1652
2455
|
exports.Modal = Modal;
|
|
1653
2456
|
exports.NotFoundPage = NotFoundPage;
|
|
2457
|
+
exports.NotificationProvider = NotificationProvider;
|
|
1654
2458
|
exports.SideNav = SideNav;
|
|
1655
2459
|
exports.Skeleton = Skeleton;
|
|
1656
2460
|
exports.StatusPage = StatusPage;
|
|
@@ -1658,6 +2462,7 @@ exports.Table = Table;
|
|
|
1658
2462
|
exports.Tabs = Tabs;
|
|
1659
2463
|
exports.Tag = Tag;
|
|
1660
2464
|
exports.ThemeProvider = ThemeProvider;
|
|
2465
|
+
exports.TimeSeriesChart = TimeSeriesChart;
|
|
1661
2466
|
exports.UnauthorizedPage = UnauthorizedPage;
|
|
1662
2467
|
exports.breakpoints = breakpoints;
|
|
1663
2468
|
exports.colors = colors;
|
|
@@ -1665,5 +2470,7 @@ exports.fontSize = fontSize;
|
|
|
1665
2470
|
exports.indusActionLogo = indusActionLogo;
|
|
1666
2471
|
exports.spacing = spacing;
|
|
1667
2472
|
exports.theme = theme;
|
|
2473
|
+
exports.useNotification = useNotification;
|
|
2474
|
+
exports.useNotifications = useNotifications;
|
|
1668
2475
|
//# sourceMappingURL=index.cjs.map
|
|
1669
2476
|
//# sourceMappingURL=index.cjs.map
|