@uipath/apollo-vertex 1.1.0 → 1.2.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.
@@ -1,5 +1,5 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { Bar, BarChart, Cell, LabelList, XAxis, YAxis } from "recharts";
2
+ import { Bar, BarChart, LabelList, Rectangle, XAxis, YAxis } from "recharts";
3
3
  import { ChartContainer, ChartTooltip, ChartTooltipContent } from "../chart/chart.js";
4
4
  import { BarLabel } from "./bar-label.js";
5
5
  import { MetricColumn } from "./metric-column.js";
@@ -9,6 +9,12 @@ import { isRechartsBarData } from "./util/recharts-bar-data.js";
9
9
  const BAR_SIZE = 20;
10
10
  const BAR_GAP = 4;
11
11
  const CATEGORY_GAP = 8;
12
+ function PaletteBar(props) {
13
+ return /*#__PURE__*/ jsx(Rectangle, {
14
+ ...props,
15
+ fill: PALETTE[props.index % PALETTE.length]
16
+ });
17
+ }
12
18
  function bar_chart_view_BarChart({ rows, series }) {
13
19
  const dimensionKeys = rows[0]?.dimensions.map((d)=>d.key) ?? [];
14
20
  const dimensionCount = dimensionKeys.length;
@@ -159,24 +165,20 @@ function bar_chart_view_BarChart({ rows, series }) {
159
165
  }),
160
166
  cursor: false
161
167
  }),
162
- 1 === seriesCount ? /*#__PURE__*/ jsxs(Bar, {
168
+ 1 === seriesCount ? /*#__PURE__*/ jsx(Bar, {
163
169
  dataKey: series[0]?.label ?? "",
164
170
  barSize: BAR_SIZE,
165
- children: [
166
- /*#__PURE__*/ jsx(LabelList, {
167
- content: (props)=>{
168
- const payload = isRechartsBarData(props.payload) ? props.payload : null;
169
- const formatted = payload && series[0] ? payload.__formatted[series[0].id] ?? "" : "";
170
- return /*#__PURE__*/ jsx(BarLabel, {
171
- ...props,
172
- formatted: formatted
173
- });
174
- }
175
- }),
176
- rechartsData.map((row, index)=>/*#__PURE__*/ jsx(Cell, {
177
- fill: PALETTE[index % PALETTE.length]
178
- }, row.__id))
179
- ]
171
+ shape: PaletteBar,
172
+ children: /*#__PURE__*/ jsx(LabelList, {
173
+ content: (props)=>{
174
+ const payload = isRechartsBarData(props.payload) ? props.payload : null;
175
+ const formatted = payload && series[0] ? payload.__formatted[series[0].id] ?? "" : "";
176
+ return /*#__PURE__*/ jsx(BarLabel, {
177
+ ...props,
178
+ formatted: formatted
179
+ });
180
+ }
181
+ })
180
182
  }) : series.map((s, idx)=>/*#__PURE__*/ jsx(Bar, {
181
183
  dataKey: s.label,
182
184
  fill: s.color ?? COLORS[idx % COLORS.length],
@@ -5,8 +5,8 @@ function getBarColor({ seriesCount, seriesIndex, item, payload, rechartsData })
5
5
  const payloadFill = item.payload?.fill;
6
6
  if (1 === seriesCount) {
7
7
  const rowIndex = rechartsData.findIndex((row)=>row.__id === payload?.__id);
8
- const fallbackColor = PALETTE[rowIndex >= 0 ? rowIndex % PALETTE.length : 0];
9
- return assertDefined(itemColor ?? payloadFill ?? fallbackColor, "Bar color");
8
+ if (rowIndex >= 0) return assertDefined(PALETTE[rowIndex % PALETTE.length], "Bar color");
9
+ return assertDefined(itemColor ?? payloadFill ?? PALETTE["0"], "Bar color");
10
10
  }
11
11
  const fallbackColor = COLORS[seriesIndex % COLORS.length];
12
12
  return assertDefined(itemColor ?? payloadFill ?? fallbackColor, "Bar color");
@@ -4,21 +4,23 @@ declare const THEMES: {
4
4
  readonly light: "";
5
5
  readonly dark: ".dark";
6
6
  };
7
- export type ChartConfig = {
8
- [k in string]: {
9
- label?: React.ReactNode;
10
- icon?: React.ComponentType;
11
- } & ({
12
- color?: string;
13
- theme?: never;
14
- } | {
15
- color?: never;
16
- theme: Record<keyof typeof THEMES, string>;
17
- });
18
- };
19
- declare function ChartContainer({ id, className, children, config, ...props }: React.ComponentProps<"div"> & {
7
+ export type ChartConfig = Record<string, {
8
+ label?: React.ReactNode;
9
+ icon?: React.ComponentType;
10
+ } & ({
11
+ color?: string;
12
+ theme?: never;
13
+ } | {
14
+ color?: never;
15
+ theme: Record<keyof typeof THEMES, string>;
16
+ })>;
17
+ declare function ChartContainer({ id, className, children, config, initialDimension, ...props }: React.ComponentProps<"div"> & {
20
18
  config: ChartConfig;
21
19
  children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
20
+ initialDimension?: {
21
+ width: number;
22
+ height: number;
23
+ };
22
24
  }): import("react/jsx-runtime").JSX.Element;
23
25
  declare const ChartStyle: ({ id, config }: {
24
26
  id: string;
@@ -31,10 +33,10 @@ declare function ChartTooltipContent({ active, payload, className, indicator, hi
31
33
  indicator?: "line" | "dot" | "dashed";
32
34
  nameKey?: string;
33
35
  labelKey?: string;
34
- }): import("react/jsx-runtime").JSX.Element | null;
35
- declare const ChartLegend: typeof RechartsPrimitive.Legend;
36
- declare function ChartLegendContent({ className, hideIcon, payload, verticalAlign, nameKey, }: React.ComponentProps<"div"> & Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
36
+ } & Omit<RechartsPrimitive.DefaultTooltipContentProps, "accessibilityLayer">): import("react/jsx-runtime").JSX.Element | null;
37
+ declare const ChartLegend: React.MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
38
+ declare function ChartLegendContent({ className, hideIcon, payload, verticalAlign, nameKey, }: React.ComponentProps<"div"> & {
37
39
  hideIcon?: boolean;
38
40
  nameKey?: string;
39
- }): import("react/jsx-runtime").JSX.Element | null;
41
+ } & RechartsPrimitive.DefaultLegendContentProps): import("react/jsx-runtime").JSX.Element | null;
40
42
  export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle, };
@@ -1,19 +1,33 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { createContext, useContext, useId } from "react";
3
+ import { createContext, useContext, useId, useMemo } from "react";
4
4
  import { Legend, ResponsiveContainer, Tooltip } from "recharts";
5
5
  import { cn } from "../../lib/utils.js";
6
6
  const THEMES = {
7
7
  light: "",
8
8
  dark: ".dark"
9
9
  };
10
+ const THEME_SELECTORS = [
11
+ [
12
+ "light",
13
+ THEMES.light
14
+ ],
15
+ [
16
+ "dark",
17
+ THEMES.dark
18
+ ]
19
+ ];
20
+ const INITIAL_DIMENSION = {
21
+ width: 320,
22
+ height: 200
23
+ };
10
24
  const ChartContext = /*#__PURE__*/ createContext(null);
11
25
  function useChart() {
12
26
  const context = useContext(ChartContext);
13
27
  if (!context) throw new Error("useChart must be used within a <ChartContainer />");
14
28
  return context;
15
29
  }
16
- function ChartContainer({ id, className, children, config, ...props }) {
30
+ function ChartContainer({ id, className, children, config, initialDimension = INITIAL_DIMENSION, ...props }) {
17
31
  const uniqueId = useId();
18
32
  const chartId = `chart-${id ?? uniqueId.replaceAll(":", "")}`;
19
33
  return /*#__PURE__*/ jsx(ChartContext.Provider, {
@@ -23,7 +37,7 @@ function ChartContainer({ id, className, children, config, ...props }) {
23
37
  children: /*#__PURE__*/ jsxs("div", {
24
38
  "data-slot": "chart",
25
39
  "data-chart": chartId,
26
- className: cn("[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden", className),
40
+ className: cn("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden", className),
27
41
  ...props,
28
42
  children: [
29
43
  /*#__PURE__*/ jsx(ChartStyle, {
@@ -31,6 +45,7 @@ function ChartContainer({ id, className, children, config, ...props }) {
31
45
  config: config
32
46
  }),
33
47
  /*#__PURE__*/ jsx(ResponsiveContainer, {
48
+ initialDimension: initialDimension,
34
49
  children: children
35
50
  })
36
51
  ]
@@ -42,7 +57,7 @@ const ChartStyle = ({ id, config })=>{
42
57
  if (0 === colorConfig.length) return null;
43
58
  return /*#__PURE__*/ jsx("style", {
44
59
  dangerouslySetInnerHTML: {
45
- __html: Object.entries(THEMES).map(([theme, prefix])=>`
60
+ __html: THEME_SELECTORS.map(([theme, prefix])=>`
46
61
  ${prefix} [data-chart=${id}] {
47
62
  ${colorConfig.map(([key, itemConfig])=>{
48
63
  const color = itemConfig.theme?.[theme] ?? itemConfig.color;
@@ -56,10 +71,10 @@ ${colorConfig.map(([key, itemConfig])=>{
56
71
  const ChartTooltip = Tooltip;
57
72
  function ChartTooltipContent({ active, payload, className, indicator = "dot", hideLabel = false, hideIndicator = false, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey }) {
58
73
  const { config } = useChart();
59
- function getTooltipLabel() {
74
+ const tooltipLabel = useMemo(()=>{
60
75
  if (hideLabel || !payload?.length) return null;
61
76
  const [item] = payload;
62
- const key = `${(labelKey ?? item?.dataKey) || (item?.name ?? "value")}`;
77
+ const key = chartConfigKey(labelKey ?? item?.dataKey ?? item?.name);
63
78
  const itemConfig = getPayloadConfigFromPayload(config, item, key);
64
79
  const value = labelKey || "string" != typeof label ? itemConfig?.label : config[label]?.label ?? label;
65
80
  if (labelFormatter) return /*#__PURE__*/ jsx("div", {
@@ -71,22 +86,29 @@ function ChartTooltipContent({ active, payload, className, indicator = "dot", hi
71
86
  className: cn("font-medium", labelClassName),
72
87
  children: value
73
88
  });
74
- }
75
- const tooltipLabel = getTooltipLabel();
89
+ }, [
90
+ label,
91
+ labelFormatter,
92
+ payload,
93
+ hideLabel,
94
+ labelClassName,
95
+ config,
96
+ labelKey
97
+ ]);
76
98
  if (!active || !payload?.length) return null;
77
99
  const nestLabel = 1 === payload.length && "dot" !== indicator;
78
100
  return /*#__PURE__*/ jsxs("div", {
79
- className: cn("border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl", className),
101
+ className: cn("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl", className),
80
102
  children: [
81
103
  nestLabel ? null : tooltipLabel,
82
104
  /*#__PURE__*/ jsx("div", {
83
105
  className: "grid gap-1.5",
84
106
  children: payload.filter((item)=>"none" !== item.type).map((item, index)=>{
85
- const key = `${(nameKey ?? item.name) || (item.dataKey ?? "value")}`;
107
+ const key = chartConfigKey(nameKey ?? item.name ?? item.dataKey);
86
108
  const itemConfig = getPayloadConfigFromPayload(config, item, key);
87
- const indicatorColor = color ?? item.payload.fill ?? item.color;
109
+ const indicatorColor = readIndicatorColor(color, item);
88
110
  return /*#__PURE__*/ jsx("div", {
89
- className: cn("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5", "dot" === indicator && "items-center"),
111
+ className: cn("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground", "dot" === indicator && "items-center"),
90
112
  children: formatter && item?.value != null && item.name ? formatter(item.value, item.name, item, index, item.payload) : /*#__PURE__*/ jsxs(Fragment, {
91
113
  children: [
92
114
  itemConfig?.icon ? /*#__PURE__*/ jsx(itemConfig.icon, {}) : !hideIndicator && /*#__PURE__*/ jsx("div", {
@@ -114,15 +136,15 @@ function ChartTooltipContent({ active, payload, className, indicator = "dot", hi
114
136
  })
115
137
  ]
116
138
  }),
117
- item.value && /*#__PURE__*/ jsx("span", {
118
- className: "text-foreground font-mono font-medium tabular-nums",
119
- children: item.value.toLocaleString()
139
+ null != item.value && /*#__PURE__*/ jsx("span", {
140
+ className: "font-mono font-medium text-foreground tabular-nums",
141
+ children: "number" == typeof item.value ? item.value.toLocaleString() : String(item.value)
120
142
  })
121
143
  ]
122
144
  })
123
145
  ]
124
146
  })
125
- }, item.dataKey);
147
+ }, index);
126
148
  })
127
149
  })
128
150
  ]
@@ -134,11 +156,11 @@ function ChartLegendContent({ className, hideIcon = false, payload, verticalAlig
134
156
  if (!payload?.length) return null;
135
157
  return /*#__PURE__*/ jsx("div", {
136
158
  className: cn("flex items-center justify-center gap-4", "top" === verticalAlign ? "pb-3" : "pt-3", className),
137
- children: payload.filter((item)=>"none" !== item.type).map((item)=>{
138
- const key = String(nameKey ?? item.dataKey ?? "value");
159
+ children: payload.filter((item)=>"none" !== item.type).map((item, index)=>{
160
+ const key = chartConfigKey(nameKey ?? item.dataKey);
139
161
  const itemConfig = getPayloadConfigFromPayload(config, item, key);
140
162
  return /*#__PURE__*/ jsxs("div", {
141
- className: cn("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),
163
+ className: cn("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),
142
164
  children: [
143
165
  itemConfig?.icon && !hideIcon ? /*#__PURE__*/ jsx(itemConfig.icon, {}) : /*#__PURE__*/ jsx("div", {
144
166
  className: "h-2 w-2 shrink-0 rounded-[2px]",
@@ -148,10 +170,20 @@ function ChartLegendContent({ className, hideIcon = false, payload, verticalAlig
148
170
  }),
149
171
  itemConfig?.label
150
172
  ]
151
- }, item.value);
173
+ }, index);
152
174
  })
153
175
  });
154
176
  }
177
+ function chartConfigKey(value) {
178
+ if ("string" == typeof value || "number" == typeof value || "function" == typeof value) return String(value);
179
+ return "value";
180
+ }
181
+ function readIndicatorColor(color, item) {
182
+ const point = item.payload;
183
+ if ("object" != typeof point || null === point || !("fill" in point)) return color ?? item.color;
184
+ const { fill } = point;
185
+ return color ?? ("string" == typeof fill ? fill : item.color);
186
+ }
155
187
  function getPayloadConfigFromPayload(config, payload, key) {
156
188
  if ("object" != typeof payload || null === payload) return;
157
189
  const payloadPayload = "payload" in payload && "object" == typeof payload.payload && null !== payload.payload ? payload.payload : null;
@@ -42,6 +42,16 @@ const cssVarMap = {
42
42
  function isValidTheme(value) {
43
43
  return "light" === value || "dark" === value || "system" === value;
44
44
  }
45
+ function useSystemDark() {
46
+ return useSyncExternalStore((cb)=>{
47
+ const mq = window.matchMedia("(prefers-color-scheme: dark)");
48
+ mq.addEventListener("change", cb);
49
+ return ()=>mq.removeEventListener("change", cb);
50
+ }, ()=>window.matchMedia("(prefers-color-scheme: dark)").matches, ()=>false);
51
+ }
52
+ function resolveSystemTheme(systemDark) {
53
+ return systemDark ? "dark" : "light";
54
+ }
45
55
  function applyThemeClass(resolved) {
46
56
  const root = window.document.documentElement;
47
57
  root.classList.remove("light", "dark");
@@ -69,12 +79,8 @@ function ThemeProvider({ children, defaultTheme = "system", themeConfig, storage
69
79
  const stored = localStorage.getItem(storageKey);
70
80
  return isValidTheme(stored) ? stored : defaultTheme;
71
81
  });
72
- const systemDark = useSyncExternalStore((cb)=>{
73
- const mq = window.matchMedia("(prefers-color-scheme: dark)");
74
- mq.addEventListener("change", cb);
75
- return ()=>mq.removeEventListener("change", cb);
76
- }, ()=>window.matchMedia("(prefers-color-scheme: dark)").matches, ()=>false);
77
- const resolvedTheme = "system" === theme ? systemDark ? "dark" : "light" : theme;
82
+ const systemDark = useSystemDark();
83
+ const resolvedTheme = "system" === theme ? resolveSystemTheme(systemDark) : theme;
78
84
  const setTheme = (newTheme)=>{
79
85
  localStorage.setItem(storageKey, newTheme);
80
86
  setThemeState(newTheme);
@@ -1,4 +1,4 @@
1
1
  import { type ToasterProps } from "sonner";
2
2
  export declare const apolloToastClassNames: NonNullable<NonNullable<ToasterProps["toastOptions"]>["classNames"]>;
3
- declare const Toaster: ({ ...props }: ToasterProps) => import("react/jsx-runtime").JSX.Element;
3
+ declare const Toaster: ({ theme: _theme, ...props }: ToasterProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export { Toaster };
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { CircleCheckIcon, InfoIcon, Loader2Icon, OctagonXIcon, TriangleAlertIcon } from "lucide-react";
4
- import { useTheme } from "next-themes";
5
4
  import { Toaster } from "sonner";
5
+ import { useTheme } from "../shell/shell-theme-provider.js";
6
6
  const iconAlign = "[&>[data-icon]]:!items-start [&>[data-icon]>svg]:!mt-0.5";
7
7
  const statusTextClasses = "[&>[data-icon]>svg]:!text-[oklch(0.166_0.0283_203.34)] dark:[&>[data-icon]>svg]:!text-foreground [&_[data-title]]:!text-[oklch(0.166_0.0283_203.34)] dark:[&_[data-title]]:!text-foreground [&_[data-description]]:!text-[oklch(0.166_0.0283_203.34)] dark:[&_[data-description]]:!text-foreground [&_[data-close-button]]:!text-[oklch(0.166_0.0283_203.34)] dark:[&_[data-close-button]]:!text-foreground";
8
8
  const apolloToastClassNames = {
@@ -12,10 +12,10 @@ const apolloToastClassNames = {
12
12
  error: `!border-destructive !bg-[color-mix(in_srgb,var(--destructive)_50%,var(--card)_50%)] dark:!bg-[color-mix(in_srgb,var(--destructive)_50%,var(--popover)_50%)] ${statusTextClasses} ${iconAlign}`,
13
13
  closeButton: "!left-auto !right-2 !top-2 !transform-none !border-none !bg-transparent !rounded-sm"
14
14
  };
15
- const sonner_Toaster = ({ ...props })=>{
16
- const { theme = "system" } = useTheme();
15
+ const sonner_Toaster = ({ theme: _theme, ...props })=>{
16
+ const { resolvedTheme } = useTheme();
17
17
  return /*#__PURE__*/ jsx(Toaster, {
18
- theme: "light" === theme || "dark" === theme || "system" === theme ? theme : "system",
18
+ theme: resolvedTheme,
19
19
  className: "toaster group",
20
20
  position: "top-center",
21
21
  duration: 5000,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/apollo-vertex",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "UiPath Apollo Vertex design system components",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -68,7 +68,6 @@
68
68
  "input-otp": "^1.4.2",
69
69
  "lucide-react": "^0.577.0",
70
70
  "luxon": "^3.7.1",
71
- "next-themes": "^0.4.6",
72
71
  "react-day-picker": "^9.13.0",
73
72
  "react-joyride": "^3.0.2",
74
73
  "react-resizable-panels": "^4.7.3",
@@ -95,7 +94,7 @@
95
94
  "react-error-boundary": "^6.0.0",
96
95
  "react-i18next": "^16.5.4 || ^17.0.0",
97
96
  "react-markdown": "^10.1.0",
98
- "recharts": "^2.15.4",
97
+ "recharts": "^3.8.0",
99
98
  "remark-breaks": "^4.0.0",
100
99
  "remark-gfm": "^4.0.1",
101
100
  "tailwindcss": "^4.0.0"
@@ -143,7 +142,7 @@
143
142
  "react-error-boundary": "^6.0.0",
144
143
  "react-i18next": "^17.0.15",
145
144
  "react-markdown": "^10.1.0",
146
- "recharts": "2.15.4",
145
+ "recharts": "3.8.0",
147
146
  "remark-breaks": "^4.0.0",
148
147
  "remark-gfm": "^4.0.1",
149
148
  "tailwindcss": "^4.1.17",