@hanzo/ui 5.3.31 → 5.3.33

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.
@@ -0,0 +1,250 @@
1
+ "use client";
2
+ import * as React from 'react';
3
+ import * as RechartsPrimitive from 'recharts';
4
+ import { clsx } from 'clsx';
5
+ import { twMerge } from 'tailwind-merge';
6
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ function cn(...inputs) {
11
+ return twMerge(clsx(inputs));
12
+ }
13
+ __name(cn, "cn");
14
+ var THEMES = { light: "", dark: ".dark" };
15
+ var ChartContext = React.createContext(null);
16
+ function useChart() {
17
+ const context = React.useContext(ChartContext);
18
+ if (!context) {
19
+ throw new Error("useChart must be used within a <ChartContainer />");
20
+ }
21
+ return context;
22
+ }
23
+ __name(useChart, "useChart");
24
+ function ChartContainer({
25
+ id,
26
+ className,
27
+ children,
28
+ config,
29
+ ...props
30
+ }) {
31
+ const uniqueId = React.useId();
32
+ const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
33
+ return /* @__PURE__ */ jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs(
34
+ "div",
35
+ {
36
+ "data-slot": "chart",
37
+ "data-chart": chartId,
38
+ className: cn(
39
+ "[&_.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",
40
+ className
41
+ ),
42
+ ...props,
43
+ children: [
44
+ /* @__PURE__ */ jsx(ChartStyle, { id: chartId, config }),
45
+ /* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, { children })
46
+ ]
47
+ }
48
+ ) });
49
+ }
50
+ __name(ChartContainer, "ChartContainer");
51
+ var ChartStyle = /* @__PURE__ */ __name(({ id, config }) => {
52
+ const colorConfig = Object.entries(config).filter(
53
+ ([, config2]) => config2.theme || config2.color
54
+ );
55
+ if (!colorConfig.length) {
56
+ return null;
57
+ }
58
+ return /* @__PURE__ */ jsx(
59
+ "style",
60
+ {
61
+ dangerouslySetInnerHTML: {
62
+ __html: Object.entries(THEMES).map(
63
+ ([theme, prefix]) => `
64
+ ${prefix} [data-chart=${id}] {
65
+ ${colorConfig.map(([key, itemConfig]) => {
66
+ const color = itemConfig.theme?.[theme] || itemConfig.color;
67
+ return color ? ` --color-${key}: ${color};` : null;
68
+ }).join("\n")}
69
+ }
70
+ `
71
+ ).join("\n")
72
+ }
73
+ }
74
+ );
75
+ }, "ChartStyle");
76
+ var ChartTooltip = RechartsPrimitive.Tooltip;
77
+ function ChartTooltipContent({
78
+ active,
79
+ payload,
80
+ className,
81
+ indicator = "dot",
82
+ hideLabel = false,
83
+ hideIndicator = false,
84
+ label,
85
+ labelFormatter,
86
+ labelClassName,
87
+ formatter,
88
+ color,
89
+ nameKey,
90
+ labelKey
91
+ }) {
92
+ const { config } = useChart();
93
+ const tooltipLabel = React.useMemo(() => {
94
+ if (hideLabel || !payload?.length) {
95
+ return null;
96
+ }
97
+ const [item] = payload;
98
+ const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
99
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
100
+ const value = !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;
101
+ if (labelFormatter) {
102
+ return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
103
+ }
104
+ if (!value) {
105
+ return null;
106
+ }
107
+ return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: value });
108
+ }, [
109
+ label,
110
+ labelFormatter,
111
+ payload,
112
+ hideLabel,
113
+ labelClassName,
114
+ config,
115
+ labelKey
116
+ ]);
117
+ if (!active || !payload?.length) {
118
+ return null;
119
+ }
120
+ const nestLabel = payload.length === 1 && indicator !== "dot";
121
+ return /* @__PURE__ */ jsxs(
122
+ "div",
123
+ {
124
+ className: cn(
125
+ "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",
126
+ className
127
+ ),
128
+ children: [
129
+ !nestLabel ? tooltipLabel : null,
130
+ /* @__PURE__ */ jsx("div", { className: "grid gap-1.5", children: payload.map((item, index) => {
131
+ const key = `${nameKey || item.name || item.dataKey || "value"}`;
132
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
133
+ const indicatorColor = color || item.payload.fill || item.color;
134
+ return /* @__PURE__ */ jsx(
135
+ "div",
136
+ {
137
+ className: cn(
138
+ "[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
139
+ indicator === "dot" && "items-center"
140
+ ),
141
+ children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxs(Fragment, { children: [
142
+ itemConfig?.icon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx(
143
+ "div",
144
+ {
145
+ className: cn(
146
+ "shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
147
+ {
148
+ "h-2.5 w-2.5": indicator === "dot",
149
+ "w-1": indicator === "line",
150
+ "w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
151
+ "my-0.5": nestLabel && indicator === "dashed"
152
+ }
153
+ ),
154
+ style: {
155
+ "--color-bg": indicatorColor,
156
+ "--color-border": indicatorColor
157
+ }
158
+ }
159
+ ),
160
+ /* @__PURE__ */ jsxs(
161
+ "div",
162
+ {
163
+ className: cn(
164
+ "flex flex-1 justify-between leading-none",
165
+ nestLabel ? "items-end" : "items-center"
166
+ ),
167
+ children: [
168
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
169
+ nestLabel ? tooltipLabel : null,
170
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: itemConfig?.label || item.name })
171
+ ] }),
172
+ item.value && /* @__PURE__ */ jsx("span", { className: "text-foreground font-mono font-medium tabular-nums", children: item.value.toLocaleString() })
173
+ ]
174
+ }
175
+ )
176
+ ] })
177
+ },
178
+ item.dataKey
179
+ );
180
+ }) })
181
+ ]
182
+ }
183
+ );
184
+ }
185
+ __name(ChartTooltipContent, "ChartTooltipContent");
186
+ var ChartLegend = RechartsPrimitive.Legend;
187
+ function ChartLegendContent({
188
+ className,
189
+ hideIcon = false,
190
+ payload,
191
+ verticalAlign = "bottom",
192
+ nameKey
193
+ }) {
194
+ const { config } = useChart();
195
+ if (!payload?.length) {
196
+ return null;
197
+ }
198
+ return /* @__PURE__ */ jsx(
199
+ "div",
200
+ {
201
+ className: cn(
202
+ "flex items-center justify-center gap-4",
203
+ verticalAlign === "top" ? "pb-3" : "pt-3",
204
+ className
205
+ ),
206
+ children: payload.map((item) => {
207
+ const key = `${nameKey || item.dataKey || "value"}`;
208
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
209
+ return /* @__PURE__ */ jsxs(
210
+ "div",
211
+ {
212
+ className: cn(
213
+ "[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
214
+ ),
215
+ children: [
216
+ itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsx(
217
+ "div",
218
+ {
219
+ className: "h-2 w-2 shrink-0 rounded-[2px]",
220
+ style: {
221
+ backgroundColor: item.color
222
+ }
223
+ }
224
+ ),
225
+ itemConfig?.label
226
+ ]
227
+ },
228
+ item.value
229
+ );
230
+ })
231
+ }
232
+ );
233
+ }
234
+ __name(ChartLegendContent, "ChartLegendContent");
235
+ function getPayloadConfigFromPayload(config, payload, key) {
236
+ if (typeof payload !== "object" || payload === null) {
237
+ return void 0;
238
+ }
239
+ const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
240
+ let configLabelKey = key;
241
+ if (key in payload && typeof payload[key] === "string") {
242
+ configLabelKey = payload[key];
243
+ } else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
244
+ configLabelKey = payloadPayload[key];
245
+ }
246
+ return configLabelKey in config ? config[configLabelKey] : config[key];
247
+ }
248
+ __name(getPayloadConfigFromPayload, "getPayloadConfigFromPayload");
249
+
250
+ export { ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent };
package/dist/index.js CHANGED
@@ -3726,7 +3726,6 @@ var MediaStack = /* @__PURE__ */ __name(({
3726
3726
  height: dim.h,
3727
3727
  style: {
3728
3728
  minHeight: dim.h,
3729
- // prevents layout jumps
3730
3729
  ...spread_to_transform_default(transform)
3731
3730
  },
3732
3731
  ...video.videoProps
package/dist/index.mjs CHANGED
@@ -3675,7 +3675,6 @@ var MediaStack = /* @__PURE__ */ __name(({
3675
3675
  height: dim.h,
3676
3676
  style: {
3677
3677
  minHeight: dim.h,
3678
- // prevents layout jumps
3679
3678
  ...spread_to_transform_default(transform)
3680
3679
  },
3681
3680
  ...video.videoProps