@fanvue/ui 1.18.2 → 1.20.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/charts.d.ts +372 -0
- package/dist/charts.mjs +28 -0
- package/dist/charts.mjs.map +1 -0
- package/dist/cjs/charts.cjs +28 -0
- package/dist/cjs/charts.cjs.map +1 -0
- package/dist/cjs/components/Autocomplete/Autocomplete.cjs +6 -6
- package/dist/cjs/components/Autocomplete/Autocomplete.cjs.map +1 -1
- package/dist/cjs/components/Chart/ChartCard.cjs +88 -0
- package/dist/cjs/components/Chart/ChartCard.cjs.map +1 -0
- package/dist/cjs/components/Chart/ChartCenterLabel.cjs +51 -0
- package/dist/cjs/components/Chart/ChartCenterLabel.cjs.map +1 -0
- package/dist/cjs/components/Chart/ChartContainer.cjs +64 -0
- package/dist/cjs/components/Chart/ChartContainer.cjs.map +1 -0
- package/dist/cjs/components/Chart/ChartLegend.cjs +69 -0
- package/dist/cjs/components/Chart/ChartLegend.cjs.map +1 -0
- package/dist/cjs/components/Chart/ChartLoadingOverlay.cjs +35 -0
- package/dist/cjs/components/Chart/ChartLoadingOverlay.cjs.map +1 -0
- package/dist/cjs/components/Chart/ChartPieLegend.cjs +54 -0
- package/dist/cjs/components/Chart/ChartPieLegend.cjs.map +1 -0
- package/dist/cjs/components/Chart/ChartSeriesToggle.cjs +65 -0
- package/dist/cjs/components/Chart/ChartSeriesToggle.cjs.map +1 -0
- package/dist/cjs/components/Chart/ChartStyle.cjs +40 -0
- package/dist/cjs/components/Chart/ChartStyle.cjs.map +1 -0
- package/dist/cjs/components/Chart/ChartTooltip.cjs +147 -0
- package/dist/cjs/components/Chart/ChartTooltip.cjs.map +1 -0
- package/dist/cjs/components/Chart/chartUtils.cjs +23 -0
- package/dist/cjs/components/Chart/chartUtils.cjs.map +1 -0
- package/dist/cjs/components/Chart/useChart.cjs +32 -0
- package/dist/cjs/components/Chart/useChart.cjs.map +1 -0
- package/dist/cjs/components/InfoBox/InfoBox.cjs +111 -0
- package/dist/cjs/components/InfoBox/InfoBox.cjs.map +1 -0
- package/dist/cjs/components/TextField/TextField.cjs +0 -4
- package/dist/cjs/components/TextField/TextField.cjs.map +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.cjs +17 -92
- package/dist/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
- package/dist/cjs/index.cjs +4 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/Autocomplete/Autocomplete.mjs +5 -5
- package/dist/components/Autocomplete/Autocomplete.mjs.map +1 -1
- package/dist/components/Chart/ChartCard.mjs +71 -0
- package/dist/components/Chart/ChartCard.mjs.map +1 -0
- package/dist/components/Chart/ChartCenterLabel.mjs +34 -0
- package/dist/components/Chart/ChartCenterLabel.mjs.map +1 -0
- package/dist/components/Chart/ChartContainer.mjs +47 -0
- package/dist/components/Chart/ChartContainer.mjs.map +1 -0
- package/dist/components/Chart/ChartLegend.mjs +52 -0
- package/dist/components/Chart/ChartLegend.mjs.map +1 -0
- package/dist/components/Chart/ChartLoadingOverlay.mjs +18 -0
- package/dist/components/Chart/ChartLoadingOverlay.mjs.map +1 -0
- package/dist/components/Chart/ChartPieLegend.mjs +37 -0
- package/dist/components/Chart/ChartPieLegend.mjs.map +1 -0
- package/dist/components/Chart/ChartSeriesToggle.mjs +48 -0
- package/dist/components/Chart/ChartSeriesToggle.mjs.map +1 -0
- package/dist/components/Chart/ChartStyle.mjs +23 -0
- package/dist/components/Chart/ChartStyle.mjs.map +1 -0
- package/dist/components/Chart/ChartTooltip.mjs +130 -0
- package/dist/components/Chart/ChartTooltip.mjs.map +1 -0
- package/dist/components/Chart/chartUtils.mjs +23 -0
- package/dist/components/Chart/chartUtils.mjs.map +1 -0
- package/dist/components/Chart/useChart.mjs +15 -0
- package/dist/components/Chart/useChart.mjs.map +1 -0
- package/dist/components/InfoBox/InfoBox.mjs +93 -0
- package/dist/components/InfoBox/InfoBox.mjs.map +1 -0
- package/dist/components/TextField/TextField.mjs +0 -4
- package/dist/components/TextField/TextField.mjs.map +1 -1
- package/dist/components/Tooltip/Tooltip.mjs +18 -93
- package/dist/components/Tooltip/Tooltip.mjs.map +1 -1
- package/dist/index.d.ts +50 -88
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -2
package/dist/charts.d.ts
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { Legend } from 'recharts';
|
|
2
|
+
import { LegendPayload } from 'recharts/types/component/DefaultLegendContent';
|
|
3
|
+
import { NameType } from 'recharts/types/component/DefaultTooltipContent';
|
|
4
|
+
import { Payload } from 'recharts/types/component/DefaultTooltipContent';
|
|
5
|
+
import * as React_2 from 'react';
|
|
6
|
+
import { ResponsiveContainer } from 'recharts';
|
|
7
|
+
import { Tooltip } from 'recharts';
|
|
8
|
+
import { ValueType } from 'recharts/types/component/DefaultTooltipContent';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps any chart with a structured header containing title, subtitle,
|
|
12
|
+
* optional trend chip, date range label, info tooltip, and a loading
|
|
13
|
+
* skeleton state.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <ChartCard
|
|
18
|
+
* title="Revenue"
|
|
19
|
+
* subtitle="$4,523"
|
|
20
|
+
* trendChip={{ label: "+12.5%", trend: "positive" }}
|
|
21
|
+
* dateInfo="Jan 1 – Mar 17"
|
|
22
|
+
* tooltip="Total revenue for the selected period."
|
|
23
|
+
* >
|
|
24
|
+
* <MyLineChart />
|
|
25
|
+
* </ChartCard>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const ChartCard: React_2.ForwardRefExoticComponent<ChartCardProps & React_2.RefAttributes<HTMLDivElement>>;
|
|
29
|
+
|
|
30
|
+
/** Props for {@link ChartCard}. */
|
|
31
|
+
export declare interface ChartCardProps extends Omit<React_2.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
32
|
+
/** Card title text. Pass translated string for i18n. */
|
|
33
|
+
title: React_2.ReactNode;
|
|
34
|
+
/** Large subtitle value (e.g. formatted price or count). */
|
|
35
|
+
subtitle?: React_2.ReactNode;
|
|
36
|
+
/** Tooltip text shown next to the title. Pass translated string for i18n. */
|
|
37
|
+
tooltip?: React_2.ReactNode;
|
|
38
|
+
/** Accessible label for the info tooltip trigger. Override for i18n. @default "More info" */
|
|
39
|
+
tooltipAriaLabel?: string;
|
|
40
|
+
/** Date range or period label shown below the subtitle. */
|
|
41
|
+
dateInfo?: React_2.ReactNode;
|
|
42
|
+
/** Trend indicator chip config. */
|
|
43
|
+
trendChip?: {
|
|
44
|
+
/** Display label (e.g. "12.5%"). */
|
|
45
|
+
label: React_2.ReactNode;
|
|
46
|
+
/** Whether the trend is positive (green) or negative (red). */
|
|
47
|
+
trend: "positive" | "negative";
|
|
48
|
+
};
|
|
49
|
+
/** Show loading skeleton instead of content. @default false */
|
|
50
|
+
loading?: boolean;
|
|
51
|
+
/** Chart content rendered below the header. */
|
|
52
|
+
children?: React_2.ReactNode;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Centered label for radial/pie charts, rendered inside a Recharts `<Label>`.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```tsx
|
|
60
|
+
* <PolarRadiusAxis tick={false} tickLine={false} axisLine={false}>
|
|
61
|
+
* <Label content={({ viewBox }) => (
|
|
62
|
+
* <ChartCenterLabel viewBox={viewBox} value="78%" subtitle="Complete" />
|
|
63
|
+
* )} />
|
|
64
|
+
* </PolarRadiusAxis>
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare const ChartCenterLabel: React_2.ForwardRefExoticComponent<ChartCenterLabelProps & React_2.RefAttributes<SVGTextElement>>;
|
|
68
|
+
|
|
69
|
+
/** Props for {@link ChartCenterLabel}. */
|
|
70
|
+
export declare interface ChartCenterLabelProps extends Omit<React_2.SVGAttributes<SVGTextElement>, "viewBox"> {
|
|
71
|
+
/** Recharts viewBox with center coordinates. */
|
|
72
|
+
viewBox?: {
|
|
73
|
+
cx?: number;
|
|
74
|
+
cy?: number;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
};
|
|
77
|
+
/** Primary value displayed in the center. */
|
|
78
|
+
value: React_2.ReactNode;
|
|
79
|
+
/** Secondary text below the value. */
|
|
80
|
+
subtitle: React_2.ReactNode;
|
|
81
|
+
/** Custom className for the value tspan. @default "fill-foreground-default font-bold text-3xl" */
|
|
82
|
+
valueClassName?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Maps data keys to their display configuration (label, color, icon).
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* const config: ChartConfig = {
|
|
91
|
+
* revenue: {
|
|
92
|
+
* label: t("chart.revenue"),
|
|
93
|
+
* color: "var(--color-special-chart-teal)",
|
|
94
|
+
* },
|
|
95
|
+
* subscribers: {
|
|
96
|
+
* label: t("chart.subscribers"),
|
|
97
|
+
* theme: { light: "#2563eb", dark: "#60a5fa" },
|
|
98
|
+
* },
|
|
99
|
+
* };
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare type ChartConfig = Record<string, ChartConfigEntry>;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Configuration for a single data series in a chart.
|
|
106
|
+
*
|
|
107
|
+
* Each key in a {@link ChartConfig} record maps to a data key used by Recharts.
|
|
108
|
+
* Provide a human-readable `label` (supports i18n — pass translated strings)
|
|
109
|
+
* and either a single `color` or a `theme` map for light/dark mode.
|
|
110
|
+
*/
|
|
111
|
+
export declare type ChartConfigEntry = {
|
|
112
|
+
/** Human-readable label for this series. Pass a translated string for i18n. */
|
|
113
|
+
label?: React_2.ReactNode;
|
|
114
|
+
/** Optional icon component rendered in tooltips and legends. */
|
|
115
|
+
icon?: React_2.ComponentType;
|
|
116
|
+
/** Single color for all themes. */
|
|
117
|
+
color?: string;
|
|
118
|
+
/** Per-theme color overrides. Takes precedence over `color` when present. */
|
|
119
|
+
theme?: Record<ChartThemeKey, string>;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Wraps a Recharts chart with responsive sizing, design-token theming, and
|
|
124
|
+
* accessible config context for tooltips and legends.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```tsx
|
|
128
|
+
* <ChartContainer config={chartConfig} className="min-h-48">
|
|
129
|
+
* <LineChart data={data} accessibilityLayer>
|
|
130
|
+
* <Line dataKey="revenue" stroke="var(--color-revenue)" />
|
|
131
|
+
* </LineChart>
|
|
132
|
+
* </ChartContainer>
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export declare const ChartContainer: React_2.ForwardRefExoticComponent<ChartContainerProps & React_2.RefAttributes<HTMLDivElement>>;
|
|
136
|
+
|
|
137
|
+
/** Props for {@link ChartContainer}. */
|
|
138
|
+
export declare interface ChartContainerProps extends React_2.HTMLAttributes<HTMLDivElement> {
|
|
139
|
+
/** Series configuration mapping data keys to labels, colors, and icons. */
|
|
140
|
+
config: ChartConfig;
|
|
141
|
+
/**
|
|
142
|
+
* Recharts chart element(s) to render inside the responsive container.
|
|
143
|
+
* Typically a single `<AreaChart>`, `<BarChart>`, `<LineChart>`, etc.
|
|
144
|
+
*/
|
|
145
|
+
children: React_2.ComponentProps<typeof ResponsiveContainer>["children"];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
declare type ChartContextValue = {
|
|
149
|
+
config: ChartConfig;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** Re-export of Recharts `Legend` — use with `content={<ChartLegendContent />}`. */
|
|
153
|
+
export declare const ChartLegend: typeof Legend;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Styled legend content for use with `<ChartLegend content={<ChartLegendContent />} />`.
|
|
157
|
+
*
|
|
158
|
+
* Reads chart config from context to resolve labels and icons.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```tsx
|
|
162
|
+
* <ChartLegend content={<ChartLegendContent />} />
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export declare const ChartLegendContent: React_2.ForwardRefExoticComponent<ChartLegendContentProps & React_2.RefAttributes<HTMLDivElement>>;
|
|
166
|
+
|
|
167
|
+
/** Props for {@link ChartLegendContent}. */
|
|
168
|
+
export declare interface ChartLegendContentProps extends React_2.HTMLAttributes<HTMLDivElement> {
|
|
169
|
+
/** Legend payload data. Passed by Recharts. */
|
|
170
|
+
payload?: readonly LegendPayload[];
|
|
171
|
+
/** Vertical alignment — controls padding direction. @default "bottom" */
|
|
172
|
+
verticalAlign?: "top" | "bottom";
|
|
173
|
+
/** Hide the color/icon indicator. @default false */
|
|
174
|
+
hideIcon?: boolean;
|
|
175
|
+
/** Data key used to resolve the display name from config. */
|
|
176
|
+
nameKey?: string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* A positioned overlay that displays a loading spinner on top of chart content.
|
|
181
|
+
* The children are always rendered to maintain layout dimensions; the overlay
|
|
182
|
+
* covers them with a semi-transparent background and a centered spinner.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```tsx
|
|
186
|
+
* <ChartLoadingOverlay loading={isFetching}>
|
|
187
|
+
* <ChartContainer config={config} className="min-h-48">
|
|
188
|
+
* <LineChart data={data}>...</LineChart>
|
|
189
|
+
* </ChartContainer>
|
|
190
|
+
* </ChartLoadingOverlay>
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
export declare const ChartLoadingOverlay: React_2.ForwardRefExoticComponent<ChartLoadingOverlayProps & React_2.RefAttributes<HTMLDivElement>>;
|
|
194
|
+
|
|
195
|
+
/** Props for {@link ChartLoadingOverlay}. */
|
|
196
|
+
export declare interface ChartLoadingOverlayProps extends React_2.HTMLAttributes<HTMLDivElement> {
|
|
197
|
+
/** Whether to show the loading overlay. @default false */
|
|
198
|
+
loading?: boolean;
|
|
199
|
+
/** Chart content to render underneath the overlay. */
|
|
200
|
+
children: React_2.ReactNode;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* A side legend for pie/donut charts that shows each slice's label,
|
|
205
|
+
* formatted value, and a proportional progress bar.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```tsx
|
|
209
|
+
* <ChartPieLegend
|
|
210
|
+
* items={[
|
|
211
|
+
* { label: "Subscriptions", value: 4500, formattedValue: "$4,500", color: "var(--color-special-chart-teal)" },
|
|
212
|
+
* { label: "Messages", value: 2100, formattedValue: "$2,100", color: "var(--color-special-chart-sky)" },
|
|
213
|
+
* { label: "Tips", value: 1200, formattedValue: "$1,200", color: "var(--color-special-chart-orange)" },
|
|
214
|
+
* ]}
|
|
215
|
+
* />
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
export declare const ChartPieLegend: React_2.ForwardRefExoticComponent<ChartPieLegendProps & React_2.RefAttributes<HTMLDivElement>>;
|
|
219
|
+
|
|
220
|
+
/** A single item in a {@link ChartPieLegend}. */
|
|
221
|
+
export declare interface ChartPieLegendItem {
|
|
222
|
+
/** Display label. Pass translated string for i18n. */
|
|
223
|
+
label: React_2.ReactNode;
|
|
224
|
+
/** Numeric value for this slice. Used to calculate the proportional bar width. */
|
|
225
|
+
value: number;
|
|
226
|
+
/** Formatted display value (e.g. "$4,500"). If omitted, `value.toLocaleString()` is used. */
|
|
227
|
+
formattedValue?: React_2.ReactNode;
|
|
228
|
+
/** Slice color (CSS value). */
|
|
229
|
+
color: string;
|
|
230
|
+
/** Optional icon to show instead of the color dot. */
|
|
231
|
+
icon?: React_2.ReactNode;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** Props for {@link ChartPieLegend}. */
|
|
235
|
+
export declare interface ChartPieLegendProps extends React_2.HTMLAttributes<HTMLDivElement> {
|
|
236
|
+
/** Legend items to display. */
|
|
237
|
+
items: ChartPieLegendItem[];
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Renders a grid of toggleable chips that control which series are visible
|
|
242
|
+
* on a multi-series chart. Each toggle shows a color indicator dot and a label.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```tsx
|
|
246
|
+
* const [visible, setVisible] = useState(new Set(["subscription", "message", "tip"]));
|
|
247
|
+
*
|
|
248
|
+
* <ChartSeriesToggle
|
|
249
|
+
* items={[
|
|
250
|
+
* { key: "subscription", label: "Subscription", color: "var(--color-special-chart-teal)" },
|
|
251
|
+
* { key: "message", label: "Message", color: "var(--color-special-chart-sky)" },
|
|
252
|
+
* { key: "tip", label: "Tip", color: "var(--color-special-chart-orange)" },
|
|
253
|
+
* ]}
|
|
254
|
+
* value={visible}
|
|
255
|
+
* onValueChange={setVisible}
|
|
256
|
+
* />
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
export declare const ChartSeriesToggle: React_2.ForwardRefExoticComponent<ChartSeriesToggleProps & React_2.RefAttributes<HTMLDivElement>>;
|
|
260
|
+
|
|
261
|
+
/** A single toggleable series in a {@link ChartSeriesToggle}. */
|
|
262
|
+
export declare interface ChartSeriesToggleItem {
|
|
263
|
+
/** Unique key matching the data series key and ChartConfig key. */
|
|
264
|
+
key: string;
|
|
265
|
+
/** Human-readable label. Pass translated string for i18n. */
|
|
266
|
+
label: React_2.ReactNode;
|
|
267
|
+
/** Series color (CSS value). Shown as indicator dot. */
|
|
268
|
+
color: string;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Props for {@link ChartSeriesToggle}. */
|
|
272
|
+
export declare interface ChartSeriesToggleProps extends React_2.HTMLAttributes<HTMLDivElement> {
|
|
273
|
+
/** Available series that can be toggled. */
|
|
274
|
+
items: ChartSeriesToggleItem[];
|
|
275
|
+
/** Set of currently visible series keys. */
|
|
276
|
+
value: Set<string>;
|
|
277
|
+
/** Called when a series is toggled. Receives the updated Set. */
|
|
278
|
+
onValueChange: (value: Set<string>) => void;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Injects a scoped `<style>` tag that maps each config entry to a
|
|
283
|
+
* `--color-{key}` CSS custom property, with light/dark theme support.
|
|
284
|
+
*
|
|
285
|
+
* Rendered automatically by {@link ChartContainer} — you rarely need this directly.
|
|
286
|
+
*/
|
|
287
|
+
export declare const ChartStyle: React_2.NamedExoticComponent<ChartStyleProps>;
|
|
288
|
+
|
|
289
|
+
/** Props for the scoped CSS variable injector used by {@link ChartContainer}. */
|
|
290
|
+
export declare interface ChartStyleProps {
|
|
291
|
+
/** Unique identifier scoped to the chart instance. */
|
|
292
|
+
id: string;
|
|
293
|
+
/** Chart configuration mapping data keys to colors and themes. */
|
|
294
|
+
config: ChartConfig;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** Light/dark theme key for chart color resolution. */
|
|
298
|
+
export declare type ChartThemeKey = "light" | "dark";
|
|
299
|
+
|
|
300
|
+
/** Re-export of Recharts `Tooltip` — use with `content={<ChartTooltipContent />}`. */
|
|
301
|
+
export declare const ChartTooltip: typeof Tooltip;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Styled tooltip content for use with `<ChartTooltip content={<ChartTooltipContent />} />`.
|
|
305
|
+
*
|
|
306
|
+
* Reads chart config from context to resolve labels, colors, and icons.
|
|
307
|
+
* Supports dot/line/dashed indicators. Pass translated `label`s in config for i18n.
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```tsx
|
|
311
|
+
* <ChartTooltip
|
|
312
|
+
* content={<ChartTooltipContent indicator="line" />}
|
|
313
|
+
* />
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
export declare const ChartTooltipContent: React_2.ForwardRefExoticComponent<ChartTooltipContentProps & React_2.RefAttributes<HTMLDivElement>>;
|
|
317
|
+
|
|
318
|
+
/** Props for {@link ChartTooltipContent}. */
|
|
319
|
+
export declare interface ChartTooltipContentProps extends React_2.HTMLAttributes<HTMLDivElement> {
|
|
320
|
+
/** Whether the tooltip is currently active/visible. Passed by Recharts. */
|
|
321
|
+
active?: boolean;
|
|
322
|
+
/** Tooltip payload data. Passed by Recharts. */
|
|
323
|
+
payload?: Payload<ValueType, NameType>[];
|
|
324
|
+
/** Axis label. Passed by Recharts. */
|
|
325
|
+
label?: string | number;
|
|
326
|
+
/** Custom label formatter. */
|
|
327
|
+
labelFormatter?: (label: string | number, payload: Payload<ValueType, NameType>[]) => React_2.ReactNode;
|
|
328
|
+
/** Custom value formatter. */
|
|
329
|
+
formatter?: (value: ValueType, name: NameType, item: Payload<ValueType, NameType>, index: number, payload: Payload<ValueType, NameType>[]) => React_2.ReactNode;
|
|
330
|
+
/** CSS class for the label element. */
|
|
331
|
+
labelClassName?: string;
|
|
332
|
+
/** Hide the tooltip header label. @default false */
|
|
333
|
+
hideLabel?: boolean;
|
|
334
|
+
/** Hide the color indicator beside each row. @default false */
|
|
335
|
+
hideIndicator?: boolean;
|
|
336
|
+
/** Visual style of the color indicator. @default "dot" */
|
|
337
|
+
indicator?: ChartTooltipIndicator;
|
|
338
|
+
/**
|
|
339
|
+
* Data key used to resolve the display name from config.
|
|
340
|
+
* Useful when the payload `name` differs from the config key.
|
|
341
|
+
*/
|
|
342
|
+
nameKey?: string;
|
|
343
|
+
/**
|
|
344
|
+
* Data key used to resolve the header label from config.
|
|
345
|
+
* Falls back to the first payload item's `dataKey`.
|
|
346
|
+
*/
|
|
347
|
+
labelKey?: string;
|
|
348
|
+
/** Override indicator color for all rows. */
|
|
349
|
+
color?: string;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** Indicator shape rendered beside each tooltip row. */
|
|
353
|
+
export declare type ChartTooltipIndicator = "dot" | "line" | "dashed";
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Resolves the {@link ChartConfig} entry for a given tooltip/legend payload
|
|
357
|
+
* item. Recharts wraps the original data point inside `payload.payload` —
|
|
358
|
+
* this function checks both levels before falling back to a direct `key` lookup.
|
|
359
|
+
*/
|
|
360
|
+
export declare function resolveConfigEntry(config: ChartConfig, payload: unknown, key: string): ChartConfigEntry | undefined;
|
|
361
|
+
|
|
362
|
+
/** Access the nearest {@link ChartContainer}'s config. Throws if used outside a chart. */
|
|
363
|
+
export declare function useChart(): ChartContextValue;
|
|
364
|
+
|
|
365
|
+
export { }
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
declare module "vitest" {
|
|
369
|
+
interface Assertion<T> {
|
|
370
|
+
toHaveNoViolations(): T;
|
|
371
|
+
}
|
|
372
|
+
}
|
package/dist/charts.mjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ChartCard } from "./components/Chart/ChartCard.mjs";
|
|
3
|
+
import { ChartCenterLabel } from "./components/Chart/ChartCenterLabel.mjs";
|
|
4
|
+
import { ChartContainer } from "./components/Chart/ChartContainer.mjs";
|
|
5
|
+
import { ChartLegend, ChartLegendContent } from "./components/Chart/ChartLegend.mjs";
|
|
6
|
+
import { ChartLoadingOverlay } from "./components/Chart/ChartLoadingOverlay.mjs";
|
|
7
|
+
import { ChartPieLegend } from "./components/Chart/ChartPieLegend.mjs";
|
|
8
|
+
import { ChartSeriesToggle } from "./components/Chart/ChartSeriesToggle.mjs";
|
|
9
|
+
import { ChartStyle } from "./components/Chart/ChartStyle.mjs";
|
|
10
|
+
import { ChartTooltip, ChartTooltipContent } from "./components/Chart/ChartTooltip.mjs";
|
|
11
|
+
import { resolveConfigEntry } from "./components/Chart/chartUtils.mjs";
|
|
12
|
+
import { useChart } from "./components/Chart/useChart.mjs";
|
|
13
|
+
export {
|
|
14
|
+
ChartCard,
|
|
15
|
+
ChartCenterLabel,
|
|
16
|
+
ChartContainer,
|
|
17
|
+
ChartLegend,
|
|
18
|
+
ChartLegendContent,
|
|
19
|
+
ChartLoadingOverlay,
|
|
20
|
+
ChartPieLegend,
|
|
21
|
+
ChartSeriesToggle,
|
|
22
|
+
ChartStyle,
|
|
23
|
+
ChartTooltip,
|
|
24
|
+
ChartTooltipContent,
|
|
25
|
+
resolveConfigEntry,
|
|
26
|
+
useChart
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=charts.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"charts.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const ChartCard = require("./components/Chart/ChartCard.cjs");
|
|
5
|
+
const ChartCenterLabel = require("./components/Chart/ChartCenterLabel.cjs");
|
|
6
|
+
const ChartContainer = require("./components/Chart/ChartContainer.cjs");
|
|
7
|
+
const ChartLegend = require("./components/Chart/ChartLegend.cjs");
|
|
8
|
+
const ChartLoadingOverlay = require("./components/Chart/ChartLoadingOverlay.cjs");
|
|
9
|
+
const ChartPieLegend = require("./components/Chart/ChartPieLegend.cjs");
|
|
10
|
+
const ChartSeriesToggle = require("./components/Chart/ChartSeriesToggle.cjs");
|
|
11
|
+
const ChartStyle = require("./components/Chart/ChartStyle.cjs");
|
|
12
|
+
const ChartTooltip = require("./components/Chart/ChartTooltip.cjs");
|
|
13
|
+
const chartUtils = require("./components/Chart/chartUtils.cjs");
|
|
14
|
+
const useChart = require("./components/Chart/useChart.cjs");
|
|
15
|
+
exports.ChartCard = ChartCard.ChartCard;
|
|
16
|
+
exports.ChartCenterLabel = ChartCenterLabel.ChartCenterLabel;
|
|
17
|
+
exports.ChartContainer = ChartContainer.ChartContainer;
|
|
18
|
+
exports.ChartLegend = ChartLegend.ChartLegend;
|
|
19
|
+
exports.ChartLegendContent = ChartLegend.ChartLegendContent;
|
|
20
|
+
exports.ChartLoadingOverlay = ChartLoadingOverlay.ChartLoadingOverlay;
|
|
21
|
+
exports.ChartPieLegend = ChartPieLegend.ChartPieLegend;
|
|
22
|
+
exports.ChartSeriesToggle = ChartSeriesToggle.ChartSeriesToggle;
|
|
23
|
+
exports.ChartStyle = ChartStyle.ChartStyle;
|
|
24
|
+
exports.ChartTooltip = ChartTooltip.ChartTooltip;
|
|
25
|
+
exports.ChartTooltipContent = ChartTooltip.ChartTooltipContent;
|
|
26
|
+
exports.resolveConfigEntry = chartUtils.resolveConfigEntry;
|
|
27
|
+
exports.useChart = useChart.useChart;
|
|
28
|
+
//# sourceMappingURL=charts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"charts.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
-
const
|
|
5
|
+
const PopoverPrimitive = require("@radix-ui/react-popover");
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const cn = require("../../utils/cn.cjs");
|
|
8
8
|
const ChevronDownIcon = require("../Icons/ChevronDownIcon.cjs");
|
|
@@ -27,7 +27,7 @@ function _interopNamespaceDefault(e) {
|
|
|
27
27
|
n.default = e;
|
|
28
28
|
return Object.freeze(n);
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const PopoverPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(PopoverPrimitive);
|
|
31
31
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
32
32
|
const CONTAINER_HEIGHT = {
|
|
33
33
|
"48": "min-h-12",
|
|
@@ -79,7 +79,7 @@ const Autocomplete = React__namespace.forwardRef((props, ref) => {
|
|
|
79
79
|
React__namespace.useImperativeHandle(ref, () => ac.inputRef.current);
|
|
80
80
|
warnMissingAccessibleName(label, ariaLabel, ariaLabelledby);
|
|
81
81
|
const bottomText = error && errorMessage ? errorMessage : helperText;
|
|
82
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
82
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Root, { open: ac.isOpen && !disabled, onOpenChange: ac.handleOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
83
83
|
"div",
|
|
84
84
|
{
|
|
85
85
|
className: cn.cn("flex flex-col", fullWidth && "w-full", className),
|
|
@@ -95,7 +95,7 @@ const Autocomplete = React__namespace.forwardRef((props, ref) => {
|
|
|
95
95
|
children: label
|
|
96
96
|
}
|
|
97
97
|
),
|
|
98
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
98
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Anchor, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
99
99
|
"div",
|
|
100
100
|
{
|
|
101
101
|
className: cn.cn(
|
|
@@ -174,8 +174,8 @@ const Autocomplete = React__namespace.forwardRef((props, ref) => {
|
|
|
174
174
|
]
|
|
175
175
|
}
|
|
176
176
|
) }),
|
|
177
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
178
|
-
|
|
177
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
178
|
+
PopoverPrimitive__namespace.Content,
|
|
179
179
|
{
|
|
180
180
|
sideOffset: 4,
|
|
181
181
|
collisionPadding: 8,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.cjs","sources":["../../../../src/components/Autocomplete/Autocomplete.tsx"],"sourcesContent":["import * as Popover from \"@radix-ui/react-popover\";\nimport * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { SpinnerIcon } from \"../Icons/SpinnerIcon\";\nimport { AutocompleteDropdownContent } from \"./AutocompleteDropdownContent\";\nimport { AutocompleteTag } from \"./AutocompleteTag\";\nimport { useAutocomplete } from \"./useAutocomplete\";\n\nexport type AutocompleteSize = \"48\" | \"40\" | \"32\";\n\nexport interface AutocompleteOption {\n value: string;\n label?: string;\n disabled?: boolean;\n}\n\ninterface AutocompleteBaseProps {\n label?: string;\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n helperText?: string;\n /** @default \"48\" */\n size?: AutocompleteSize;\n /** @default false */\n error?: boolean;\n errorMessage?: string;\n placeholder?: string;\n leftIcon?: React.ReactNode;\n /** @default false */\n fullWidth?: boolean;\n /** @default false */\n disabled?: boolean;\n /** @default false */\n clearable?: boolean;\n clearAriaLabel?: string;\n id?: string;\n className?: string;\n options: AutocompleteOption[];\n inputValue?: string;\n onInputChange?: (value: string) => void;\n filterFn?: (option: AutocompleteOption, query: string) => boolean;\n /** @default false */\n creatable?: boolean;\n creatableLabel?: (inputValue: string) => string;\n onCreate?: (inputValue: string) => void;\n /** @default false */\n loading?: boolean;\n loadingText?: string;\n emptyText?: string;\n renderOption?: (\n option: AutocompleteOption,\n state: { selected: boolean; active: boolean },\n ) => React.ReactNode;\n renderTag?: (option: AutocompleteOption, onRemove: () => void) => React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\ninterface AutocompleteSingleProps extends AutocompleteBaseProps {\n multiple?: false;\n value?: string | null;\n defaultValue?: string | null;\n onChange?: (value: string | null) => void;\n}\n\ninterface AutocompleteMultiProps extends AutocompleteBaseProps {\n multiple: true;\n value?: string[];\n defaultValue?: string[];\n onChange?: (values: string[]) => void;\n}\n\nexport type AutocompleteProps = AutocompleteSingleProps | AutocompleteMultiProps;\n\nconst CONTAINER_HEIGHT: Record<AutocompleteSize, string> = {\n \"48\": \"min-h-12\",\n \"40\": \"min-h-10\",\n \"32\": \"min-h-8\",\n};\n\nconst INPUT_SIZE_CLASSES: Record<AutocompleteSize, string> = {\n \"48\": \"typography-regular-body-lg\",\n \"40\": \"typography-regular-body-lg\",\n \"32\": \"typography-regular-body-md\",\n};\n\nconst PADDING_CLASSES: Record<AutocompleteSize, string> = {\n \"48\": \"px-4 py-1.5 gap-3\",\n \"40\": \"px-4 py-1 gap-3\",\n \"32\": \"px-3 py-1 gap-2\",\n};\n\nfunction warnMissingAccessibleName(label?: string, ariaLabel?: string, ariaLabelledBy?: string) {\n if (process.env.NODE_ENV !== \"production\") {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n \"Autocomplete: no accessible name provided. Pass a `label`, `aria-label`, or `aria-labelledby` prop.\",\n );\n }\n }\n}\n\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Conditional JSX branches in the render template\nexport const Autocomplete = React.forwardRef<HTMLInputElement, AutocompleteProps>((props, ref) => {\n const {\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n helperText,\n size = \"48\",\n error = false,\n errorMessage,\n placeholder,\n leftIcon,\n fullWidth = false,\n disabled = false,\n clearable = false,\n clearAriaLabel = \"Clear\",\n className,\n loading = false,\n loadingText,\n emptyText = \"No results\",\n renderOption,\n renderTag,\n } = props;\n\n const ac = useAutocomplete(props);\n\n React.useImperativeHandle(ref, () => ac.inputRef.current as HTMLInputElement);\n\n warnMissingAccessibleName(label, ariaLabel, ariaLabelledby);\n\n const bottomText = error && errorMessage ? errorMessage : helperText;\n\n return (\n <Popover.Root open={ac.isOpen && !disabled} onOpenChange={ac.handleOpenChange}>\n <div\n className={cn(\"flex flex-col\", fullWidth && \"w-full\", className)}\n data-autocomplete-root=\"\"\n data-disabled={disabled ? \"\" : undefined}\n data-error={error ? \"\" : undefined}\n >\n {label && (\n <label\n htmlFor={ac.inputId}\n className=\"typography-semibold-body-sm px-1 pt-1 pb-2 text-foreground-default\"\n >\n {label}\n </label>\n )}\n\n <Popover.Anchor asChild>\n {/* biome-ignore lint/a11y/noStaticElementInteractions: Container delegates click to the inner input */}\n {/* biome-ignore lint/a11y/useKeyWithClickEvents: Keyboard interaction is handled by the inner combobox input */}\n <div\n className={cn(\n \"flex flex-wrap items-center overflow-hidden rounded-xl border bg-neutral-100 has-focus-visible:outline-none motion-safe:transition-colors\",\n error ? \"border-error-default\" : \"border-transparent\",\n !disabled && !error && \"hover:border-neutral-400\",\n ac.isOpen && !error && !disabled && \"border-neutral-400\",\n CONTAINER_HEIGHT[size],\n PADDING_CLASSES[size],\n disabled && \"opacity-50\",\n )}\n onClick={ac.handleContainerClick}\n >\n {leftIcon && (\n <div className=\"flex size-5 shrink-0 items-center justify-center text-foreground-secondary\">\n {leftIcon}\n </div>\n )}\n\n <div className=\"flex min-w-0 flex-1 flex-wrap items-center gap-1.5\">\n {ac.isMulti &&\n ac.selectedMultiOptions.map((opt) => (\n <AutocompleteTag\n key={opt.value}\n option={opt}\n disabled={disabled}\n onRemove={() => ac.toggleMulti(opt.value)}\n renderTag={renderTag}\n />\n ))}\n\n <input\n ref={ac.inputRef}\n id={ac.inputId}\n role=\"combobox\"\n type=\"text\"\n disabled={disabled}\n aria-expanded={ac.isOpen}\n aria-controls={ac.isOpen ? ac.listboxId : undefined}\n aria-activedescendant={ac.activeDescendantId}\n aria-autocomplete=\"list\"\n aria-describedby={bottomText ? ac.helperTextId : undefined}\n aria-invalid={error || undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n autoComplete=\"off\"\n placeholder={\n ac.isMulti && ac.selectedMultiValues.length > 0 ? undefined : placeholder\n }\n value={ac.displayInputValue}\n onChange={ac.handleInputChange}\n onKeyDown={ac.handleKeyDown}\n onFocus={ac.handleFocus}\n onBlur={ac.handleBlur}\n className={cn(\n \"min-w-[40px] flex-1 truncate rounded-xl bg-transparent text-foreground-default no-underline placeholder:text-foreground-secondary placeholder:opacity-40 focus:outline-none disabled:cursor-not-allowed\",\n INPUT_SIZE_CLASSES[size],\n )}\n />\n </div>\n\n <div className=\"flex shrink-0 items-center gap-1\">\n {loading && <SpinnerIcon className=\"size-4 animate-spin text-foreground-secondary\" />}\n {clearable && ac.hasClearableValue && !disabled && (\n <button\n type=\"button\"\n tabIndex={-1}\n aria-label={clearAriaLabel}\n className=\"flex size-5 shrink-0 cursor-pointer items-center justify-center text-foreground-secondary hover:text-foreground-default active:scale-95\"\n onClick={ac.handleClear}\n >\n <CloseIcon className=\"size-4\" />\n </button>\n )}\n <div className=\"flex size-5 shrink-0 items-center justify-center text-foreground-secondary\">\n <ChevronDownIcon\n className={cn(\"size-5 transition-transform\", ac.isOpen && \"rotate-180\")}\n />\n </div>\n </div>\n </div>\n </Popover.Anchor>\n\n <Popover.Portal>\n <Popover.Content\n sideOffset={4}\n collisionPadding={8}\n onOpenAutoFocus={(e) => e.preventDefault()}\n onCloseAutoFocus={(e) => e.preventDefault()}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\" }}\n className={cn(\n \"w-(--radix-popover-trigger-width) min-w-(--radix-popper-anchor-width) overflow-hidden rounded-xl border border-neutral-200 bg-surface-page text-foreground-default shadow-[0_4px_16px_rgba(0,0,0,0.10)]\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n \"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95\",\n \"data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2\",\n )}\n >\n <div\n ref={ac.listRef}\n id={ac.listboxId}\n role=\"listbox\"\n aria-label={label ?? ariaLabel ?? \"Options\"}\n aria-multiselectable={ac.isMulti || undefined}\n className=\"max-h-60 overflow-y-auto p-1\"\n >\n <AutocompleteDropdownContent\n loading={loading}\n loadingText={loadingText}\n emptyText={emptyText}\n visibleOptions={ac.visibleOptions}\n listboxId={ac.listboxId}\n activeIndex={ac.activeIndex}\n isMulti={ac.isMulti}\n selectedMultiValues={ac.selectedMultiValues}\n selectedValue={ac.selectedValue}\n onSelect={ac.handleSelect}\n onMouseEnter={ac.setActiveIndex}\n renderOption={renderOption}\n />\n </div>\n </Popover.Content>\n </Popover.Portal>\n\n {bottomText && (\n <p\n id={ac.helperTextId}\n className={cn(\n \"typography-regular-body-sm px-2 pt-1 pb-0.5\",\n error ? \"text-error-default\" : \"text-foreground-secondary\",\n )}\n >\n {bottomText}\n </p>\n )}\n </div>\n </Popover.Root>\n );\n});\n\nAutocomplete.displayName = \"Autocomplete\";\n"],"names":["React","useAutocomplete","jsx","Popover","jsxs","cn","AutocompleteTag","SpinnerIcon","CloseIcon","ChevronDownIcon","AutocompleteDropdownContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EA,MAAM,mBAAqD;AAAA,EACzD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,qBAAuD;AAAA,EAC3D,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,kBAAoD;AAAA,EACxD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,SAAS,0BAA0B,OAAgB,WAAoB,gBAAyB;AAC9F,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAI,CAAC,SAAS,CAAC,aAAa,CAAC,gBAAgB;AAC3C,cAAQ;AAAA,QACN;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AACF;AAGO,MAAM,eAAeA,iBAAM,WAAgD,CAAC,OAAO,QAAQ;AAChG,QAAM;AAAA,IACJ;AAAA,IACA,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB;AAAA,IACA,OAAO;AAAA,IACP,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,EAAA,IACE;AAEJ,QAAM,KAAKC,g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ACCR,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,IAAI,GAAG;AAAA,YACP,WAAWG,GAAAA;AAAAA,cACT;AAAA,cACA,QAAQ,uBAAuB;AAAA,YAAA;AAAA,YAGhC,UAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA,GAGN;AAEJ,CAAC;AAED,aAAa,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"Autocomplete.cjs","sources":["../../../../src/components/Autocomplete/Autocomplete.tsx"],"sourcesContent":["import * as Popover from \"@radix-ui/react-popover\";\nimport * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { SpinnerIcon } from \"../Icons/SpinnerIcon\";\nimport { AutocompleteDropdownContent } from \"./AutocompleteDropdownContent\";\nimport { AutocompleteTag } from \"./AutocompleteTag\";\nimport { useAutocomplete } from \"./useAutocomplete\";\n\nexport type AutocompleteSize = \"48\" | \"40\" | \"32\";\n\nexport interface AutocompleteOption {\n value: string;\n label?: string;\n disabled?: boolean;\n}\n\ninterface AutocompleteBaseProps {\n label?: string;\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n helperText?: string;\n /** @default \"48\" */\n size?: AutocompleteSize;\n /** @default false */\n error?: boolean;\n errorMessage?: string;\n placeholder?: string;\n leftIcon?: React.ReactNode;\n /** @default false */\n fullWidth?: boolean;\n /** @default false */\n disabled?: boolean;\n /** @default false */\n clearable?: boolean;\n clearAriaLabel?: string;\n id?: string;\n className?: string;\n options: AutocompleteOption[];\n inputValue?: string;\n onInputChange?: (value: string) => void;\n filterFn?: (option: AutocompleteOption, query: string) => boolean;\n /** @default false */\n creatable?: boolean;\n creatableLabel?: (inputValue: string) => string;\n onCreate?: (inputValue: string) => void;\n /** @default false */\n loading?: boolean;\n loadingText?: string;\n emptyText?: string;\n renderOption?: (\n option: AutocompleteOption,\n state: { selected: boolean; active: boolean },\n ) => React.ReactNode;\n renderTag?: (option: AutocompleteOption, onRemove: () => void) => React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\ninterface AutocompleteSingleProps extends AutocompleteBaseProps {\n multiple?: false;\n value?: string | null;\n defaultValue?: string | null;\n onChange?: (value: string | null) => void;\n}\n\ninterface AutocompleteMultiProps extends AutocompleteBaseProps {\n multiple: true;\n value?: string[];\n defaultValue?: string[];\n onChange?: (values: string[]) => void;\n}\n\nexport type AutocompleteProps = AutocompleteSingleProps | AutocompleteMultiProps;\n\nconst CONTAINER_HEIGHT: Record<AutocompleteSize, string> = {\n \"48\": \"min-h-12\",\n \"40\": \"min-h-10\",\n \"32\": \"min-h-8\",\n};\n\nconst INPUT_SIZE_CLASSES: Record<AutocompleteSize, string> = {\n \"48\": \"typography-regular-body-lg\",\n \"40\": \"typography-regular-body-lg\",\n \"32\": \"typography-regular-body-md\",\n};\n\nconst PADDING_CLASSES: Record<AutocompleteSize, string> = {\n \"48\": \"px-4 py-1.5 gap-3\",\n \"40\": \"px-4 py-1 gap-3\",\n \"32\": \"px-3 py-1 gap-2\",\n};\n\nfunction warnMissingAccessibleName(label?: string, ariaLabel?: string, ariaLabelledBy?: string) {\n if (process.env.NODE_ENV !== \"production\") {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n \"Autocomplete: no accessible name provided. Pass a `label`, `aria-label`, or `aria-labelledby` prop.\",\n );\n }\n }\n}\n\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Conditional JSX branches in the render template\nexport const Autocomplete = React.forwardRef<HTMLInputElement, AutocompleteProps>((props, ref) => {\n const {\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n helperText,\n size = \"48\",\n error = false,\n errorMessage,\n placeholder,\n leftIcon,\n fullWidth = false,\n disabled = false,\n clearable = false,\n clearAriaLabel = \"Clear\",\n className,\n loading = false,\n loadingText,\n emptyText = \"No results\",\n renderOption,\n renderTag,\n } = props;\n\n const ac = useAutocomplete(props);\n\n React.useImperativeHandle(ref, () => ac.inputRef.current as HTMLInputElement);\n\n warnMissingAccessibleName(label, ariaLabel, ariaLabelledby);\n\n const bottomText = error && errorMessage ? errorMessage : helperText;\n\n return (\n <Popover.Root open={ac.isOpen && !disabled} onOpenChange={ac.handleOpenChange}>\n <div\n className={cn(\"flex flex-col\", fullWidth && \"w-full\", className)}\n data-autocomplete-root=\"\"\n data-disabled={disabled ? \"\" : undefined}\n data-error={error ? \"\" : undefined}\n >\n {label && (\n <label\n htmlFor={ac.inputId}\n className=\"typography-semibold-body-sm px-1 pt-1 pb-2 text-foreground-default\"\n >\n {label}\n </label>\n )}\n\n <Popover.Anchor asChild>\n {/* biome-ignore lint/a11y/noStaticElementInteractions: Container delegates click to the inner input */}\n {/* biome-ignore lint/a11y/useKeyWithClickEvents: Keyboard interaction is handled by the inner combobox input */}\n <div\n className={cn(\n \"flex flex-wrap items-center overflow-hidden rounded-xl border bg-neutral-100 has-focus-visible:outline-none motion-safe:transition-colors\",\n error ? \"border-error-default\" : \"border-transparent\",\n !disabled && !error && \"hover:border-neutral-400\",\n ac.isOpen && !error && !disabled && \"border-neutral-400\",\n CONTAINER_HEIGHT[size],\n PADDING_CLASSES[size],\n disabled && \"opacity-50\",\n )}\n onClick={ac.handleContainerClick}\n >\n {leftIcon && (\n <div className=\"flex size-5 shrink-0 items-center justify-center text-foreground-secondary\">\n {leftIcon}\n </div>\n )}\n\n <div className=\"flex min-w-0 flex-1 flex-wrap items-center gap-1.5\">\n {ac.isMulti &&\n ac.selectedMultiOptions.map((opt) => (\n <AutocompleteTag\n key={opt.value}\n option={opt}\n disabled={disabled}\n onRemove={() => ac.toggleMulti(opt.value)}\n renderTag={renderTag}\n />\n ))}\n\n <input\n ref={ac.inputRef}\n id={ac.inputId}\n role=\"combobox\"\n type=\"text\"\n disabled={disabled}\n aria-expanded={ac.isOpen}\n aria-controls={ac.isOpen ? ac.listboxId : undefined}\n aria-activedescendant={ac.activeDescendantId}\n aria-autocomplete=\"list\"\n aria-describedby={bottomText ? ac.helperTextId : undefined}\n aria-invalid={error || undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n autoComplete=\"off\"\n placeholder={\n ac.isMulti && ac.selectedMultiValues.length > 0 ? undefined : placeholder\n }\n value={ac.displayInputValue}\n onChange={ac.handleInputChange}\n onKeyDown={ac.handleKeyDown}\n onFocus={ac.handleFocus}\n onBlur={ac.handleBlur}\n className={cn(\n \"min-w-[40px] flex-1 truncate rounded-xl bg-transparent text-foreground-default no-underline placeholder:text-foreground-secondary placeholder:opacity-40 focus:outline-none disabled:cursor-not-allowed\",\n INPUT_SIZE_CLASSES[size],\n )}\n />\n </div>\n\n <div className=\"flex shrink-0 items-center gap-1\">\n {loading && <SpinnerIcon className=\"size-4 animate-spin text-foreground-secondary\" />}\n {clearable && ac.hasClearableValue && !disabled && (\n <button\n type=\"button\"\n tabIndex={-1}\n aria-label={clearAriaLabel}\n className=\"flex size-5 shrink-0 cursor-pointer items-center justify-center text-foreground-secondary hover:text-foreground-default active:scale-95\"\n onClick={ac.handleClear}\n >\n <CloseIcon className=\"size-4\" />\n </button>\n )}\n <div className=\"flex size-5 shrink-0 items-center justify-center text-foreground-secondary\">\n <ChevronDownIcon\n className={cn(\"size-5 transition-transform\", ac.isOpen && \"rotate-180\")}\n />\n </div>\n </div>\n </div>\n </Popover.Anchor>\n\n <Popover.Portal>\n <Popover.Content\n sideOffset={4}\n collisionPadding={8}\n onOpenAutoFocus={(e) => e.preventDefault()}\n onCloseAutoFocus={(e) => e.preventDefault()}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\" }}\n className={cn(\n \"w-(--radix-popover-trigger-width) min-w-(--radix-popper-anchor-width) overflow-hidden rounded-xl border border-neutral-200 bg-surface-page text-foreground-default shadow-[0_4px_16px_rgba(0,0,0,0.10)]\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n \"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95\",\n \"data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2\",\n )}\n >\n <div\n ref={ac.listRef}\n id={ac.listboxId}\n role=\"listbox\"\n aria-label={label ?? ariaLabel ?? \"Options\"}\n aria-multiselectable={ac.isMulti || undefined}\n className=\"max-h-60 overflow-y-auto p-1\"\n >\n <AutocompleteDropdownContent\n loading={loading}\n loadingText={loadingText}\n emptyText={emptyText}\n visibleOptions={ac.visibleOptions}\n listboxId={ac.listboxId}\n activeIndex={ac.activeIndex}\n isMulti={ac.isMulti}\n selectedMultiValues={ac.selectedMultiValues}\n selectedValue={ac.selectedValue}\n onSelect={ac.handleSelect}\n onMouseEnter={ac.setActiveIndex}\n renderOption={renderOption}\n />\n </div>\n </Popover.Content>\n </Popover.Portal>\n\n {bottomText && (\n <p\n id={ac.helperTextId}\n className={cn(\n \"typography-regular-body-sm px-2 pt-1 pb-0.5\",\n error ? \"text-error-default\" : \"text-foreground-secondary\",\n )}\n >\n {bottomText}\n </p>\n )}\n </div>\n </Popover.Root>\n );\n});\n\nAutocomplete.displayName = \"Autocomplete\";\n"],"names":["React","useAutocomplete","jsx","Popover","jsxs","cn","AutocompleteTag","SpinnerIcon","CloseIcon","ChevronDownIcon","AutocompleteDropdownContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EA,MAAM,mBAAqD;AAAA,EACzD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,qBAAuD;AAAA,EAC3D,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,kBAAoD;AAAA,EACxD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,SAAS,0BAA0B,OAAgB,WAAoB,gBAAyB;AAC9F,MAAI,QAAQ,IAAI,aAAa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BACP,MAAK;AAAA,gBACL,cAAY,SAAS,aAAa;AAAA,gBAClC,wBAAsB,GAAG,WAAW;AAAA,gBACpC,WAAU;AAAA,gBAEV,UAAAA,2BAAAA;AAAAA,kBAACQ,4BAAAA;AAAAA,kBAAA;AAAA,oBACC;AAAA,oBACA;AAAA,oBACA;AAAA,oBACA,gBAAgB,GAAG;AAAA,oBACnB,WAAW,GAAG;AAAA,oBACd,aAAa,GAAG;AAAA,oBAChB,SAAS,GAAG;AAAA,oBACZ,qBAAqB,GAAG;AAAA,oBACxB,eAAe,GAAG;AAAA,oBAClB,UAAU,GAAG;AAAA,oBACb,cAAc,GAAG;AAAA,oBACjB;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACF;AAAA,YAAA;AAAA,UACF;AAAA,QAAA,GAEJ;AAAA,QAEC,cACCR,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YACC,IAAI,GAAG;AAAA,YACP,WAAWG,GAAAA;AAAAA,cACT;AAAA,cACA,QAAQ,uBAAuB;AAAA,YAAA;AAAA,YAGhC,UAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA,GAGN;AAEJ,CAAC;AAED,aAAa,cAAc;;"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const cn = require("../../utils/cn.cjs");
|
|
7
|
+
const Card = require("../Card/Card.cjs");
|
|
8
|
+
const IconButton = require("../IconButton/IconButton.cjs");
|
|
9
|
+
const InfoCircleIcon = require("../Icons/InfoCircleIcon.cjs");
|
|
10
|
+
const Skeleton = require("../Skeleton/Skeleton.cjs");
|
|
11
|
+
const Tooltip = require("../Tooltip/Tooltip.cjs");
|
|
12
|
+
function _interopNamespaceDefault(e) {
|
|
13
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
14
|
+
if (e) {
|
|
15
|
+
for (const k in e) {
|
|
16
|
+
if (k !== "default") {
|
|
17
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: () => e[k]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
29
|
+
const TREND_CLASSES = {
|
|
30
|
+
positive: "bg-success-background text-success-default",
|
|
31
|
+
negative: "bg-error-background text-error-default"
|
|
32
|
+
};
|
|
33
|
+
const ChartCard = React__namespace.forwardRef(
|
|
34
|
+
({
|
|
35
|
+
className,
|
|
36
|
+
title,
|
|
37
|
+
subtitle,
|
|
38
|
+
tooltip,
|
|
39
|
+
tooltipAriaLabel = "More info",
|
|
40
|
+
dateInfo,
|
|
41
|
+
trendChip,
|
|
42
|
+
loading = false,
|
|
43
|
+
children,
|
|
44
|
+
...props
|
|
45
|
+
}, ref) => {
|
|
46
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Card.Card, { ref, variant: "outlined", noPadding: true, className, ...props, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 p-4", children: [
|
|
47
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
48
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton.Skeleton, { animation: "wave", variant: "rounded", className: "h-4 w-32" }),
|
|
49
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton.Skeleton, { animation: "wave", variant: "rounded", className: "h-7 w-44" }),
|
|
50
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton.Skeleton, { animation: "wave", variant: "rounded", className: "h-3 w-24" })
|
|
51
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
52
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
53
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "typography-semibold-body-md text-foreground-default", children: title }),
|
|
54
|
+
tooltip && /* @__PURE__ */ jsxRuntime.jsx(Tooltip.TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip.Tooltip, { children: [
|
|
55
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
56
|
+
IconButton.IconButton,
|
|
57
|
+
{
|
|
58
|
+
variant: "tertiary",
|
|
59
|
+
size: "24",
|
|
60
|
+
"aria-label": tooltipAriaLabel,
|
|
61
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(InfoCircleIcon.InfoCircleIcon, { className: "size-4 text-foreground-tertiary" })
|
|
62
|
+
}
|
|
63
|
+
) }),
|
|
64
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tooltip.TooltipContent, { children: tooltip })
|
|
65
|
+
] }) })
|
|
66
|
+
] }),
|
|
67
|
+
subtitle && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
68
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "typography-bold-heading-sm text-foreground-default", children: subtitle }),
|
|
69
|
+
trendChip && /* @__PURE__ */ jsxRuntime.jsx(
|
|
70
|
+
"span",
|
|
71
|
+
{
|
|
72
|
+
className: cn.cn(
|
|
73
|
+
"typography-semibold-body-sm rounded-full px-2 py-0.5",
|
|
74
|
+
TREND_CLASSES[trendChip.trend]
|
|
75
|
+
),
|
|
76
|
+
children: trendChip.label
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
] }),
|
|
80
|
+
dateInfo && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "typography-regular-body-sm text-foreground-tertiary", children: dateInfo })
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-auto", children })
|
|
83
|
+
] }) });
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
ChartCard.displayName = "ChartCard";
|
|
87
|
+
exports.ChartCard = ChartCard;
|
|
88
|
+
//# sourceMappingURL=ChartCard.cjs.map
|