@alpic-ai/ui 0.0.0-staging.gcd4957c → 0.0.0-staging.gcd7c19c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/accordion-card.d.mts +6 -28
- package/dist/components/accordion.d.mts +5 -20
- package/dist/components/alert.d.mts +9 -30
- package/dist/components/area-chart.d.mts +43 -0
- package/dist/components/area-chart.mjs +182 -0
- package/dist/components/attachment-tile.d.mts +1 -10
- package/dist/components/avatar.d.mts +8 -33
- package/dist/components/badge.d.mts +2 -11
- package/dist/components/bar-chart.d.mts +34 -0
- package/dist/components/bar-chart.mjs +238 -0
- package/dist/components/bar-list.d.mts +19 -0
- package/dist/components/bar-list.mjs +104 -0
- package/dist/components/breadcrumb.d.mts +10 -38
- package/dist/components/button.d.mts +6 -21
- package/dist/components/card.d.mts +9 -33
- package/dist/components/chart-card.d.mts +14 -0
- package/dist/components/chart-card.mjs +48 -0
- package/dist/components/chart-container.d.mts +15 -0
- package/dist/components/chart-container.mjs +37 -0
- package/dist/components/chart-legend.d.mts +14 -0
- package/dist/components/chart-legend.mjs +35 -0
- package/dist/components/chart-primitives.d.mts +69 -0
- package/dist/components/chart-primitives.mjs +134 -0
- package/dist/components/chart-tooltip.d.mts +23 -0
- package/dist/components/chart-tooltip.mjs +79 -0
- package/dist/components/checkbox.d.mts +2 -7
- package/dist/components/collapsible.d.mts +4 -12
- package/dist/components/combobox.d.mts +10 -47
- package/dist/components/command.d.mts +9 -34
- package/dist/components/copyable.d.mts +2 -10
- package/dist/components/description-list.d.mts +5 -19
- package/dist/components/dialog.d.mts +15 -49
- package/dist/components/donut-chart.d.mts +31 -0
- package/dist/components/donut-chart.mjs +187 -0
- package/dist/components/dropdown-menu.d.mts +18 -62
- package/dist/components/field.d.mts +14 -0
- package/dist/components/field.mjs +41 -0
- package/dist/components/form.d.mts +19 -102
- package/dist/components/form.mjs +9 -7
- package/dist/components/github-button.d.mts +1 -7
- package/dist/components/heatmap-chart.d.mts +32 -0
- package/dist/components/heatmap-chart.mjs +259 -0
- package/dist/components/input-group.d.mts +5 -19
- package/dist/components/input.d.mts +4 -18
- package/dist/components/input.mjs +27 -51
- package/dist/components/label.d.mts +2 -7
- package/dist/components/line-chart.d.mts +37 -0
- package/dist/components/line-chart.mjs +132 -0
- package/dist/components/page-loader.d.mts +1 -5
- package/dist/components/pagination.d.mts +3 -11
- package/dist/components/popover.d.mts +5 -18
- package/dist/components/radio-group.d.mts +3 -11
- package/dist/components/scroll-area.d.mts +3 -13
- package/dist/components/select-trigger-variants.d.mts +1 -3
- package/dist/components/select.d.mts +9 -37
- package/dist/components/separator.d.mts +2 -9
- package/dist/components/sheet.d.mts +11 -38
- package/dist/components/shimmer-text.d.mts +3 -7
- package/dist/components/sidebar.d.mts +34 -127
- package/dist/components/sidebar.mjs +11 -11
- package/dist/components/skeleton.d.mts +2 -9
- package/dist/components/skeleton.mjs +1 -1
- package/dist/components/sonner.d.mts +5 -13
- package/dist/components/spinner.d.mts +3 -17
- package/dist/components/stat.d.mts +28 -0
- package/dist/components/stat.mjs +124 -0
- package/dist/components/status-dot.d.mts +2 -10
- package/dist/components/switch.d.mts +2 -7
- package/dist/components/table.d.mts +13 -37
- package/dist/components/table.mjs +2 -2
- package/dist/components/tabs.d.mts +12 -43
- package/dist/components/tag.d.mts +3 -22
- package/dist/components/task-progress.d.mts +1 -9
- package/dist/components/textarea.d.mts +3 -14
- package/dist/components/textarea.mjs +19 -43
- package/dist/components/toggle-group.d.mts +4 -19
- package/dist/components/toggle-group.mjs +3 -3
- package/dist/components/tooltip-icon-button.d.mts +1 -3
- package/dist/components/tooltip.d.mts +5 -19
- package/dist/components/typography.d.mts +8 -22
- package/dist/components/wizard.d.mts +4 -29
- package/dist/components/wizard.mjs +1 -19
- package/dist/hooks/use-chart-theme.d.mts +18 -0
- package/dist/hooks/use-chart-theme.mjs +57 -0
- package/dist/hooks/use-copy-to-clipboard.d.mts +1 -3
- package/dist/hooks/use-mobile.mjs +3 -3
- package/dist/lib/chart-palette.d.mts +38 -0
- package/dist/lib/chart-palette.mjs +116 -0
- package/dist/lib/chart.d.mts +19 -0
- package/dist/lib/chart.mjs +42 -0
- package/dist/lib/cn.d.mts +0 -1
- package/package.json +35 -30
- package/src/components/area-chart.tsx +228 -0
- package/src/components/bar-chart.tsx +297 -0
- package/src/components/bar-list.tsx +158 -0
- package/src/components/chart-card.tsx +65 -0
- package/src/components/chart-container.tsx +51 -0
- package/src/components/chart-legend.tsx +49 -0
- package/src/components/chart-primitives.tsx +188 -0
- package/src/components/chart-tooltip.tsx +109 -0
- package/src/components/donut-chart.tsx +214 -0
- package/src/components/field.tsx +57 -0
- package/src/components/form.tsx +4 -2
- package/src/components/heatmap-chart.tsx +375 -0
- package/src/components/input.tsx +3 -33
- package/src/components/line-chart.tsx +167 -0
- package/src/components/skeleton.tsx +1 -1
- package/src/components/stat.tsx +141 -0
- package/src/components/table.tsx +11 -2
- package/src/components/textarea.tsx +4 -34
- package/src/components/wizard.tsx +1 -35
- package/src/hooks/use-chart-theme.ts +75 -0
- package/src/lib/chart-palette.ts +113 -0
- package/src/lib/chart.ts +90 -0
- package/src/stories/area-chart.stories.tsx +200 -0
- package/src/stories/bar-chart.stories.tsx +169 -0
- package/src/stories/bar-list.stories.tsx +83 -0
- package/src/stories/donut-chart.stories.tsx +112 -0
- package/src/stories/heatmap-chart.stories.tsx +105 -0
- package/src/stories/line-chart.stories.tsx +146 -0
- package/src/stories/stat.stories.tsx +66 -0
- package/src/stories/textarea.stories.tsx +7 -0
- package/src/stories/wizard.stories.tsx +23 -5
- package/src/styles/tokens.css +18 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.mjs";
|
|
3
|
+
import { paletteColor } from "../lib/chart-palette.mjs";
|
|
4
|
+
import { formatShare } from "../lib/chart.mjs";
|
|
5
|
+
import { useChartContext } from "./chart-container.mjs";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import * as React$1 from "react";
|
|
8
|
+
import { Cell, Pie, PieChart, ResponsiveContainer } from "recharts";
|
|
9
|
+
//#region src/components/donut-chart.tsx
|
|
10
|
+
const GEOMETRY = {
|
|
11
|
+
donut: {
|
|
12
|
+
inner: "64%",
|
|
13
|
+
outer: "92%"
|
|
14
|
+
},
|
|
15
|
+
ring: {
|
|
16
|
+
inner: "78%",
|
|
17
|
+
outer: "92%"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function DonutChart({ data, index, dataKey = "value", variant = "donut", legend = false, paddingAngle = 1, height = 220, palette, centerLabel = "total", loading = false, valueFormatter = (value) => value.toLocaleString("en-US"), labelFormatter, className }) {
|
|
21
|
+
const { palette: paletteColors, theme } = useChartContext(palette);
|
|
22
|
+
const reactId = React$1.useId().replace(/:/g, "");
|
|
23
|
+
const [active, setActive] = React$1.useState(null);
|
|
24
|
+
const rowRefs = React$1.useRef([]);
|
|
25
|
+
const slices = React$1.useMemo(() => {
|
|
26
|
+
const mapped = data.map((row) => ({
|
|
27
|
+
name: String(row[index] ?? ""),
|
|
28
|
+
value: Number(row[dataKey]) || 0
|
|
29
|
+
}));
|
|
30
|
+
mapped.sort((lower, upper) => upper.value - lower.value);
|
|
31
|
+
return mapped.map((slice, rank) => ({
|
|
32
|
+
...slice,
|
|
33
|
+
color: paletteColor(paletteColors, rank)
|
|
34
|
+
}));
|
|
35
|
+
}, [
|
|
36
|
+
data,
|
|
37
|
+
index,
|
|
38
|
+
dataKey,
|
|
39
|
+
paletteColors
|
|
40
|
+
]);
|
|
41
|
+
const total = slices.reduce((sum, slice) => sum + slice.value, 0);
|
|
42
|
+
const maxValue = slices.reduce((max, slice) => slice.value > max ? slice.value : max, 0);
|
|
43
|
+
const geometry = GEOMETRY[variant] ?? GEOMETRY.donut;
|
|
44
|
+
const formatName = (name) => labelFormatter ? labelFormatter(name) : name;
|
|
45
|
+
const isEmpty = slices.length === 0 || total <= 0;
|
|
46
|
+
const activeSlice = active !== null ? slices[active] : void 0;
|
|
47
|
+
const centerTitle = activeSlice ? formatName(activeSlice.name) : centerLabel;
|
|
48
|
+
const centerValue = valueFormatter(activeSlice ? activeSlice.value : total);
|
|
49
|
+
React$1.useEffect(() => {
|
|
50
|
+
if (active !== null) rowRefs.current[active]?.scrollIntoView({ block: "nearest" });
|
|
51
|
+
}, [active]);
|
|
52
|
+
return /* @__PURE__ */ jsx("div", {
|
|
53
|
+
"data-slot": "donut-chart",
|
|
54
|
+
className: cn("@container flex w-full flex-col gap-3", className),
|
|
55
|
+
children: loading ? /* @__PURE__ */ jsxs("div", {
|
|
56
|
+
className: "flex items-center justify-center gap-2.5 font-mono text-quaternary-foreground text-text-xs",
|
|
57
|
+
style: { height },
|
|
58
|
+
children: [/* @__PURE__ */ jsx("span", { className: "size-4 animate-spin rounded-full border-2 border-border border-t-foreground" }), "loading…"]
|
|
59
|
+
}) : isEmpty ? /* @__PURE__ */ jsx("div", {
|
|
60
|
+
className: "flex items-center justify-center rounded-lg border border-border border-dashed font-mono text-quaternary-foreground text-text-xs",
|
|
61
|
+
style: { height },
|
|
62
|
+
children: "no data in range"
|
|
63
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
64
|
+
className: "flex flex-col items-center gap-5 @md:flex-row",
|
|
65
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
66
|
+
className: "relative shrink-0",
|
|
67
|
+
style: {
|
|
68
|
+
width: height,
|
|
69
|
+
height
|
|
70
|
+
},
|
|
71
|
+
children: [/* @__PURE__ */ jsx(ResponsiveContainer, {
|
|
72
|
+
width: "100%",
|
|
73
|
+
height: "100%",
|
|
74
|
+
initialDimension: {
|
|
75
|
+
width: 0,
|
|
76
|
+
height
|
|
77
|
+
},
|
|
78
|
+
children: /* @__PURE__ */ jsxs(PieChart, { children: [/* @__PURE__ */ jsx("defs", { children: slices.map((slice, slot) => /* @__PURE__ */ jsxs("linearGradient", {
|
|
79
|
+
id: `donut-${reactId}-${slot}`,
|
|
80
|
+
x1: "0",
|
|
81
|
+
y1: "0",
|
|
82
|
+
x2: "0",
|
|
83
|
+
y2: "1",
|
|
84
|
+
children: [/* @__PURE__ */ jsx("stop", {
|
|
85
|
+
offset: "0%",
|
|
86
|
+
stopColor: slice.color,
|
|
87
|
+
stopOpacity: 1
|
|
88
|
+
}), /* @__PURE__ */ jsx("stop", {
|
|
89
|
+
offset: "100%",
|
|
90
|
+
stopColor: slice.color,
|
|
91
|
+
stopOpacity: .7
|
|
92
|
+
})]
|
|
93
|
+
}, slice.name)) }), /* @__PURE__ */ jsx(Pie, {
|
|
94
|
+
data: slices,
|
|
95
|
+
dataKey: "value",
|
|
96
|
+
nameKey: "name",
|
|
97
|
+
innerRadius: geometry.inner,
|
|
98
|
+
outerRadius: geometry.outer,
|
|
99
|
+
paddingAngle,
|
|
100
|
+
startAngle: 90,
|
|
101
|
+
endAngle: -270,
|
|
102
|
+
cornerRadius: 2,
|
|
103
|
+
stroke: theme.card,
|
|
104
|
+
strokeWidth: 1.5,
|
|
105
|
+
isAnimationActive: false,
|
|
106
|
+
animationDuration: 650,
|
|
107
|
+
animationEasing: "ease-out",
|
|
108
|
+
onMouseEnter: (_entry, sliceIndex) => setActive(sliceIndex),
|
|
109
|
+
onMouseLeave: () => setActive(null),
|
|
110
|
+
children: slices.map((slice, slot) => /* @__PURE__ */ jsx(Cell, {
|
|
111
|
+
className: "motion-safe:[transition:fill-opacity_180ms_ease-out]",
|
|
112
|
+
fill: `url(#donut-${reactId}-${slot})`,
|
|
113
|
+
fillOpacity: active === null || active === slot ? 1 : .55,
|
|
114
|
+
stroke: theme.card,
|
|
115
|
+
strokeWidth: 1.5
|
|
116
|
+
}, slice.name))
|
|
117
|
+
})] })
|
|
118
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
119
|
+
className: "pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-1 text-center",
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ jsx("span", {
|
|
122
|
+
className: "max-w-[52%] truncate font-mono text-[10px] text-quaternary-foreground uppercase tracking-[0.18em]",
|
|
123
|
+
children: centerTitle
|
|
124
|
+
}),
|
|
125
|
+
/* @__PURE__ */ jsx("span", {
|
|
126
|
+
className: "font-mono font-semibold text-[28px] text-foreground leading-none tabular-nums",
|
|
127
|
+
children: centerValue
|
|
128
|
+
}),
|
|
129
|
+
activeSlice && /* @__PURE__ */ jsx("span", {
|
|
130
|
+
className: "font-mono font-medium text-[11px] tabular-nums",
|
|
131
|
+
style: { color: activeSlice.color },
|
|
132
|
+
children: formatShare(activeSlice.value / total)
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
})]
|
|
136
|
+
}), legend && /* @__PURE__ */ jsx("div", {
|
|
137
|
+
"data-slot": "donut-readout",
|
|
138
|
+
className: "flex min-w-0 flex-1 flex-col overflow-y-auto pr-1",
|
|
139
|
+
style: { maxHeight: height },
|
|
140
|
+
children: slices.map((slice, slot) => /* @__PURE__ */ jsxs("div", {
|
|
141
|
+
ref: (node) => {
|
|
142
|
+
rowRefs.current[slot] = node;
|
|
143
|
+
},
|
|
144
|
+
onMouseEnter: () => setActive(slot),
|
|
145
|
+
onMouseLeave: () => setActive(null),
|
|
146
|
+
className: cn("flex flex-col gap-1.5 border-border/40 border-b px-2 py-2 text-text-xs last:border-b-0 motion-safe:transition-colors", active === slot ? "bg-muted/50" : "bg-transparent"),
|
|
147
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
148
|
+
className: "flex items-center justify-between gap-2",
|
|
149
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
150
|
+
className: "inline-flex min-w-0 items-center gap-2 text-muted-foreground",
|
|
151
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
152
|
+
"aria-hidden": true,
|
|
153
|
+
className: "h-2 w-2.5 shrink-0 rounded-[3px]",
|
|
154
|
+
style: { background: slice.color }
|
|
155
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
156
|
+
className: "truncate",
|
|
157
|
+
children: formatName(slice.name)
|
|
158
|
+
})]
|
|
159
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
160
|
+
className: "flex shrink-0 items-center gap-2 font-mono tabular-nums",
|
|
161
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
162
|
+
className: "min-w-[2.25rem] text-right font-semibold text-foreground",
|
|
163
|
+
children: valueFormatter(slice.value)
|
|
164
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
165
|
+
className: "w-9 text-right text-quaternary-foreground",
|
|
166
|
+
children: formatShare(slice.value / total)
|
|
167
|
+
})]
|
|
168
|
+
})]
|
|
169
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
170
|
+
"aria-hidden": true,
|
|
171
|
+
className: "relative block h-[2px] w-full overflow-hidden rounded-full bg-border/40",
|
|
172
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
173
|
+
className: "absolute inset-y-0 left-0 rounded-full motion-safe:transition-[width] motion-safe:duration-500",
|
|
174
|
+
style: {
|
|
175
|
+
width: `${maxValue > 0 ? slice.value / maxValue * 100 : 0}%`,
|
|
176
|
+
background: slice.color,
|
|
177
|
+
opacity: active === null || active === slot ? 1 : .45
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
})]
|
|
181
|
+
}, slice.name))
|
|
182
|
+
})]
|
|
183
|
+
})
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
export { DonutChart };
|
|
@@ -1,72 +1,28 @@
|
|
|
1
|
-
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
1
|
import { VariantProps } from "class-variance-authority";
|
|
3
|
-
import * as React from "react";
|
|
2
|
+
import * as React$1 from "react";
|
|
4
3
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
5
|
-
import * as _$class_variance_authority_types0 from "class-variance-authority/types";
|
|
6
|
-
|
|
7
4
|
//#region src/components/dropdown-menu.d.ts
|
|
8
|
-
declare function DropdownMenu({
|
|
9
|
-
|
|
10
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.
|
|
11
|
-
declare function
|
|
12
|
-
|
|
13
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>): _$react_jsx_runtime0.JSX.Element;
|
|
14
|
-
declare function DropdownMenuTrigger({
|
|
15
|
-
...props
|
|
16
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>): _$react_jsx_runtime0.JSX.Element;
|
|
17
|
-
declare function DropdownMenuContent({
|
|
18
|
-
className,
|
|
19
|
-
sideOffset,
|
|
20
|
-
...props
|
|
21
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>): _$react_jsx_runtime0.JSX.Element;
|
|
22
|
-
declare function DropdownMenuGroup({
|
|
23
|
-
...props
|
|
24
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>): _$react_jsx_runtime0.JSX.Element;
|
|
5
|
+
declare function DropdownMenu({ ...props }: React$1.ComponentProps<typeof DropdownMenuPrimitive.Root>): React$1.JSX.Element;
|
|
6
|
+
declare function DropdownMenuPortal({ ...props }: React$1.ComponentProps<typeof DropdownMenuPrimitive.Portal>): React$1.JSX.Element;
|
|
7
|
+
declare function DropdownMenuTrigger({ ...props }: React$1.ComponentProps<typeof DropdownMenuPrimitive.Trigger>): React$1.JSX.Element;
|
|
8
|
+
declare function DropdownMenuContent({ className, sideOffset, ...props }: React$1.ComponentProps<typeof DropdownMenuPrimitive.Content>): React$1.JSX.Element;
|
|
9
|
+
declare function DropdownMenuGroup({ ...props }: React$1.ComponentProps<typeof DropdownMenuPrimitive.Group>): React$1.JSX.Element;
|
|
25
10
|
declare const dropdownMenuItemVariants: (props?: ({
|
|
26
11
|
variant?: "default" | "destructive" | null | undefined;
|
|
27
|
-
} &
|
|
28
|
-
declare function DropdownMenuItem({
|
|
29
|
-
className,
|
|
30
|
-
inset,
|
|
31
|
-
variant,
|
|
32
|
-
...props
|
|
33
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & VariantProps<typeof dropdownMenuItemVariants> & {
|
|
12
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
13
|
+
declare function DropdownMenuItem({ className, inset, variant, ...props }: React$1.ComponentProps<typeof DropdownMenuPrimitive.Item> & VariantProps<typeof dropdownMenuItemVariants> & {
|
|
34
14
|
inset?: boolean;
|
|
35
|
-
}):
|
|
36
|
-
declare function DropdownMenuLabel({
|
|
37
|
-
className,
|
|
38
|
-
inset,
|
|
39
|
-
...props
|
|
40
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
|
15
|
+
}): React$1.JSX.Element;
|
|
16
|
+
declare function DropdownMenuLabel({ className, inset, ...props }: React$1.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
|
41
17
|
inset?: boolean;
|
|
42
|
-
}):
|
|
43
|
-
declare function DropdownMenuHeader({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}: React.
|
|
48
|
-
declare function DropdownMenuSeparator({
|
|
49
|
-
className,
|
|
50
|
-
...props
|
|
51
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>): _$react_jsx_runtime0.JSX.Element;
|
|
52
|
-
declare function DropdownMenuShortcut({
|
|
53
|
-
className,
|
|
54
|
-
...props
|
|
55
|
-
}: React.ComponentProps<"span">): _$react_jsx_runtime0.JSX.Element;
|
|
56
|
-
declare function DropdownMenuSub({
|
|
57
|
-
...props
|
|
58
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>): _$react_jsx_runtime0.JSX.Element;
|
|
59
|
-
declare function DropdownMenuSubTrigger({
|
|
60
|
-
className,
|
|
61
|
-
inset,
|
|
62
|
-
children,
|
|
63
|
-
...props
|
|
64
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
18
|
+
}): React$1.JSX.Element;
|
|
19
|
+
declare function DropdownMenuHeader({ className, children, ...props }: React$1.HTMLAttributes<HTMLDivElement>): React$1.JSX.Element;
|
|
20
|
+
declare function DropdownMenuSeparator({ className, ...props }: React$1.ComponentProps<typeof DropdownMenuPrimitive.Separator>): React$1.JSX.Element;
|
|
21
|
+
declare function DropdownMenuShortcut({ className, ...props }: React$1.ComponentProps<"span">): React$1.JSX.Element;
|
|
22
|
+
declare function DropdownMenuSub({ ...props }: React$1.ComponentProps<typeof DropdownMenuPrimitive.Sub>): React$1.JSX.Element;
|
|
23
|
+
declare function DropdownMenuSubTrigger({ className, inset, children, ...props }: React$1.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
65
24
|
inset?: boolean;
|
|
66
|
-
}):
|
|
67
|
-
declare function DropdownMenuSubContent({
|
|
68
|
-
className,
|
|
69
|
-
...props
|
|
70
|
-
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>): _$react_jsx_runtime0.JSX.Element;
|
|
25
|
+
}): React$1.JSX.Element;
|
|
26
|
+
declare function DropdownMenuSubContent({ className, ...props }: React$1.ComponentProps<typeof DropdownMenuPrimitive.SubContent>): React$1.JSX.Element;
|
|
71
27
|
//#endregion
|
|
72
28
|
export { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuHeader, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, dropdownMenuItemVariants };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
//#region src/components/field.d.ts
|
|
3
|
+
interface FieldProps {
|
|
4
|
+
fieldId: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
hint?: string;
|
|
8
|
+
error?: string;
|
|
9
|
+
tooltip?: string;
|
|
10
|
+
children: React$1.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
declare function Field({ fieldId, label, required, hint, error, tooltip, children }: FieldProps): React$1.JSX.Element;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { Field, type FieldProps };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.mjs";
|
|
3
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.mjs";
|
|
4
|
+
import { Label } from "./label.mjs";
|
|
5
|
+
import { Info } from "lucide-react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/field.tsx
|
|
8
|
+
function Field({ fieldId, label, required, hint, error, tooltip, children }) {
|
|
9
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
10
|
+
className: "flex flex-col gap-1.5",
|
|
11
|
+
children: [
|
|
12
|
+
label && /* @__PURE__ */ jsxs("div", {
|
|
13
|
+
className: "flex items-center gap-0.5",
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ jsx(Label, {
|
|
16
|
+
htmlFor: fieldId,
|
|
17
|
+
className: "type-text-sm font-medium text-muted-foreground",
|
|
18
|
+
children: label
|
|
19
|
+
}),
|
|
20
|
+
required && /* @__PURE__ */ jsx("span", {
|
|
21
|
+
"aria-hidden": true,
|
|
22
|
+
className: "type-text-sm font-medium text-required",
|
|
23
|
+
children: "*"
|
|
24
|
+
}),
|
|
25
|
+
tooltip && /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
26
|
+
asChild: true,
|
|
27
|
+
children: /* @__PURE__ */ jsx(Info, { className: "size-4 text-muted-foreground" })
|
|
28
|
+
}), /* @__PURE__ */ jsx(TooltipContent, { children: tooltip })] })
|
|
29
|
+
]
|
|
30
|
+
}),
|
|
31
|
+
children,
|
|
32
|
+
(hint || error) && /* @__PURE__ */ jsx("p", {
|
|
33
|
+
id: fieldId ? `${fieldId}-description` : void 0,
|
|
34
|
+
className: cn("type-text-sm", error ? "text-destructive" : "text-subtle-foreground"),
|
|
35
|
+
children: error ?? hint
|
|
36
|
+
})
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { Field };
|
|
@@ -1,69 +1,39 @@
|
|
|
1
1
|
import { InputProps } from "./input.mjs";
|
|
2
2
|
import { Label } from "./label.mjs";
|
|
3
3
|
import { TextareaProps } from "./textarea.mjs";
|
|
4
|
-
import * as
|
|
5
|
-
import * as React from "react";
|
|
4
|
+
import * as React$1 from "react";
|
|
6
5
|
import { Slot } from "@radix-ui/react-slot";
|
|
7
|
-
import * as _$react_hook_form0 from "react-hook-form";
|
|
8
6
|
import { ControllerProps, FieldPath, FieldValues } from "react-hook-form";
|
|
9
|
-
|
|
10
7
|
//#region src/components/form.d.ts
|
|
11
|
-
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(
|
|
12
|
-
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({
|
|
13
|
-
...props
|
|
14
|
-
}: ControllerProps<TFieldValues, TName>) => _$react_jsx_runtime0.JSX.Element;
|
|
8
|
+
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>({ children, watch, getValues, getFieldState, setError, clearErrors, setValue, setValues, trigger, formState, resetField, reset, resetDefaultValues, handleSubmit, unregister, control, register, setFocus, subscribe }: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React$1.JSX.Element;
|
|
9
|
+
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => React$1.JSX.Element;
|
|
15
10
|
declare const useFormField: () => {
|
|
16
11
|
invalid: boolean;
|
|
17
12
|
isDirty: boolean;
|
|
18
13
|
isTouched: boolean;
|
|
19
14
|
isValidating: boolean;
|
|
20
|
-
error?:
|
|
15
|
+
error?: import("react-hook-form").FieldError;
|
|
21
16
|
id: string;
|
|
22
17
|
name: string;
|
|
23
18
|
formItemId: string;
|
|
24
19
|
formDescriptionId: string;
|
|
25
20
|
formMessageId: string;
|
|
26
21
|
};
|
|
27
|
-
declare function FormItem({
|
|
28
|
-
|
|
29
|
-
...props
|
|
30
|
-
}: React.ComponentProps<"div">): _$react_jsx_runtime0.JSX.Element;
|
|
31
|
-
interface FormLabelProps extends React.ComponentProps<typeof Label> {
|
|
22
|
+
declare function FormItem({ className, ...props }: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
|
23
|
+
interface FormLabelProps extends React$1.ComponentProps<typeof Label> {
|
|
32
24
|
required?: boolean;
|
|
33
25
|
tooltip?: string;
|
|
34
26
|
}
|
|
35
|
-
declare function FormLabel({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
...props
|
|
41
|
-
}: FormLabelProps): _$react_jsx_runtime0.JSX.Element;
|
|
42
|
-
declare function FormControl({
|
|
43
|
-
...props
|
|
44
|
-
}: React.ComponentProps<typeof Slot>): _$react_jsx_runtime0.JSX.Element;
|
|
45
|
-
declare function FormDescription({
|
|
46
|
-
className,
|
|
47
|
-
...props
|
|
48
|
-
}: React.ComponentProps<"p">): _$react_jsx_runtime0.JSX.Element;
|
|
49
|
-
declare function FormMessage({
|
|
50
|
-
className,
|
|
51
|
-
...props
|
|
52
|
-
}: React.ComponentProps<"p">): _$react_jsx_runtime0.JSX.Element | null;
|
|
53
|
-
interface FormHeaderProps extends React.ComponentProps<"div"> {
|
|
27
|
+
declare function FormLabel({ className, required, tooltip, children, ...props }: FormLabelProps): React$1.JSX.Element;
|
|
28
|
+
declare function FormControl({ ...props }: React$1.ComponentProps<typeof Slot>): React$1.JSX.Element;
|
|
29
|
+
declare function FormDescription({ className, ...props }: React$1.ComponentProps<"p">): React$1.JSX.Element;
|
|
30
|
+
declare function FormMessage({ className, ...props }: React$1.ComponentProps<"p">): React$1.JSX.Element | null;
|
|
31
|
+
interface FormHeaderProps extends React$1.ComponentProps<"div"> {
|
|
54
32
|
title: string;
|
|
55
33
|
description?: string;
|
|
56
34
|
}
|
|
57
|
-
declare function FormHeader({
|
|
58
|
-
|
|
59
|
-
description,
|
|
60
|
-
className,
|
|
61
|
-
...props
|
|
62
|
-
}: FormHeaderProps): _$react_jsx_runtime0.JSX.Element;
|
|
63
|
-
declare function FormFields({
|
|
64
|
-
className,
|
|
65
|
-
...props
|
|
66
|
-
}: React.ComponentProps<"div">): _$react_jsx_runtime0.JSX.Element;
|
|
35
|
+
declare function FormHeader({ title, description, className, ...props }: FormHeaderProps): React$1.JSX.Element;
|
|
36
|
+
declare function FormFields({ className, ...props }: React$1.ComponentProps<"div">): React$1.JSX.Element;
|
|
67
37
|
interface FormFieldBaseProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> {
|
|
68
38
|
control: ControllerProps<TFieldValues, TName>["control"];
|
|
69
39
|
name: TName;
|
|
@@ -74,27 +44,9 @@ interface FormFieldBaseProps<TFieldValues extends FieldValues, TName extends Fie
|
|
|
74
44
|
tooltip?: string;
|
|
75
45
|
}
|
|
76
46
|
interface InputFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> extends FormFieldBaseProps<TFieldValues, TName>, Omit<InputProps, "name" | "label"> {}
|
|
77
|
-
declare function InputField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({
|
|
78
|
-
control,
|
|
79
|
-
name,
|
|
80
|
-
rules,
|
|
81
|
-
required,
|
|
82
|
-
label,
|
|
83
|
-
description,
|
|
84
|
-
tooltip,
|
|
85
|
-
...inputProps
|
|
86
|
-
}: InputFieldProps<TFieldValues, TName>): _$react_jsx_runtime0.JSX.Element;
|
|
47
|
+
declare function InputField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({ control, name, rules, required, label, description, tooltip, ...inputProps }: InputFieldProps<TFieldValues, TName>): React$1.JSX.Element;
|
|
87
48
|
interface TextareaFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> extends FormFieldBaseProps<TFieldValues, TName>, Omit<TextareaProps, "name" | "label"> {}
|
|
88
|
-
declare function TextareaField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({
|
|
89
|
-
control,
|
|
90
|
-
name,
|
|
91
|
-
rules,
|
|
92
|
-
required,
|
|
93
|
-
label,
|
|
94
|
-
description,
|
|
95
|
-
tooltip,
|
|
96
|
-
...textareaProps
|
|
97
|
-
}: TextareaFieldProps<TFieldValues, TName>): _$react_jsx_runtime0.JSX.Element;
|
|
49
|
+
declare function TextareaField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({ control, name, rules, required, label, description, tooltip, ...textareaProps }: TextareaFieldProps<TFieldValues, TName>): React$1.JSX.Element;
|
|
98
50
|
interface SelectFieldOption {
|
|
99
51
|
value: string;
|
|
100
52
|
label: string;
|
|
@@ -104,51 +56,16 @@ interface SelectFieldProps<TFieldValues extends FieldValues, TName extends Field
|
|
|
104
56
|
options: SelectFieldOption[];
|
|
105
57
|
placeholder?: string;
|
|
106
58
|
}
|
|
107
|
-
declare function SelectField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({
|
|
108
|
-
control,
|
|
109
|
-
name,
|
|
110
|
-
rules,
|
|
111
|
-
required,
|
|
112
|
-
label,
|
|
113
|
-
description,
|
|
114
|
-
tooltip,
|
|
115
|
-
options,
|
|
116
|
-
placeholder
|
|
117
|
-
}: SelectFieldProps<TFieldValues, TName>): _$react_jsx_runtime0.JSX.Element;
|
|
59
|
+
declare function SelectField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({ control, name, rules, required, label, description, tooltip, options, placeholder }: SelectFieldProps<TFieldValues, TName>): React$1.JSX.Element;
|
|
118
60
|
interface RadioFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> extends FormFieldBaseProps<TFieldValues, TName> {
|
|
119
61
|
options: SelectFieldOption[];
|
|
120
62
|
}
|
|
121
|
-
declare function RadioField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({
|
|
122
|
-
control,
|
|
123
|
-
name,
|
|
124
|
-
rules,
|
|
125
|
-
required,
|
|
126
|
-
label,
|
|
127
|
-
description,
|
|
128
|
-
tooltip,
|
|
129
|
-
options
|
|
130
|
-
}: RadioFieldProps<TFieldValues, TName>): _$react_jsx_runtime0.JSX.Element;
|
|
63
|
+
declare function RadioField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({ control, name, rules, required, label, description, tooltip, options }: RadioFieldProps<TFieldValues, TName>): React$1.JSX.Element;
|
|
131
64
|
interface ChecklistFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> extends FormFieldBaseProps<TFieldValues, TName> {
|
|
132
65
|
options: SelectFieldOption[];
|
|
133
66
|
}
|
|
134
|
-
declare function ChecklistField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({
|
|
135
|
-
control,
|
|
136
|
-
name,
|
|
137
|
-
rules,
|
|
138
|
-
required,
|
|
139
|
-
label,
|
|
140
|
-
description,
|
|
141
|
-
tooltip,
|
|
142
|
-
options
|
|
143
|
-
}: ChecklistFieldProps<TFieldValues, TName>): _$react_jsx_runtime0.JSX.Element;
|
|
67
|
+
declare function ChecklistField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({ control, name, rules, required, label, description, tooltip, options }: ChecklistFieldProps<TFieldValues, TName>): React$1.JSX.Element;
|
|
144
68
|
interface CheckboxFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> extends Omit<FormFieldBaseProps<TFieldValues, TName>, "required"> {}
|
|
145
|
-
declare function CheckboxField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({
|
|
146
|
-
control,
|
|
147
|
-
name,
|
|
148
|
-
rules,
|
|
149
|
-
label,
|
|
150
|
-
description,
|
|
151
|
-
tooltip
|
|
152
|
-
}: CheckboxFieldProps<TFieldValues, TName>): _$react_jsx_runtime0.JSX.Element;
|
|
69
|
+
declare function CheckboxField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({ control, name, rules, label, description, tooltip }: CheckboxFieldProps<TFieldValues, TName>): React$1.JSX.Element;
|
|
153
70
|
//#endregion
|
|
154
71
|
export { CheckboxField, ChecklistField, Form, FormControl, FormDescription, FormField, FormFields, FormHeader, FormItem, FormLabel, FormMessage, InputField, RadioField, SelectField, type SelectFieldOption, TextareaField, useFormField };
|
package/dist/components/form.mjs
CHANGED
|
@@ -9,12 +9,12 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from ".
|
|
|
9
9
|
import { Textarea } from "./textarea.mjs";
|
|
10
10
|
import { Info } from "lucide-react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
import * as React from "react";
|
|
12
|
+
import * as React$1 from "react";
|
|
13
13
|
import { Slot } from "@radix-ui/react-slot";
|
|
14
14
|
import { Controller, FormProvider, useFormContext, useFormState } from "react-hook-form";
|
|
15
15
|
//#region src/components/form.tsx
|
|
16
16
|
const Form = FormProvider;
|
|
17
|
-
const FormFieldContext = React.createContext({});
|
|
17
|
+
const FormFieldContext = React$1.createContext({});
|
|
18
18
|
const FormField = ({ ...props }) => {
|
|
19
19
|
return /* @__PURE__ */ jsx(FormFieldContext.Provider, {
|
|
20
20
|
value: { name: props.name },
|
|
@@ -22,8 +22,8 @@ const FormField = ({ ...props }) => {
|
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
24
|
const useFormField = () => {
|
|
25
|
-
const fieldContext = React.useContext(FormFieldContext);
|
|
26
|
-
const itemContext = React.useContext(FormItemContext);
|
|
25
|
+
const fieldContext = React$1.useContext(FormFieldContext);
|
|
26
|
+
const itemContext = React$1.useContext(FormItemContext);
|
|
27
27
|
if (!fieldContext.name) throw new Error("useFormField should be used within <FormField>");
|
|
28
28
|
const { getFieldState } = useFormContext();
|
|
29
29
|
const formState = useFormState({ name: fieldContext.name });
|
|
@@ -38,13 +38,15 @@ const useFormField = () => {
|
|
|
38
38
|
...fieldState
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
-
const FormItemContext = React.createContext({});
|
|
41
|
+
const FormItemContext = React$1.createContext({});
|
|
42
42
|
function FormItem({ className, ...props }) {
|
|
43
|
-
const id = React.useId();
|
|
43
|
+
const id = React$1.useId();
|
|
44
|
+
const { name } = React$1.useContext(FormFieldContext);
|
|
44
45
|
return /* @__PURE__ */ jsx(FormItemContext.Provider, {
|
|
45
46
|
value: { id },
|
|
46
47
|
children: /* @__PURE__ */ jsx("div", {
|
|
47
48
|
"data-slot": "form-item",
|
|
49
|
+
"data-field-name": name,
|
|
48
50
|
className: cn("grid gap-2", className),
|
|
49
51
|
...props
|
|
50
52
|
})
|
|
@@ -65,7 +67,7 @@ function FormLabel({ className, required, tooltip, children, ...props }) {
|
|
|
65
67
|
}),
|
|
66
68
|
required && /* @__PURE__ */ jsx("span", {
|
|
67
69
|
"aria-hidden": true,
|
|
68
|
-
className: "type-text-sm font-medium text-required",
|
|
70
|
+
className: "type-text-sm font-medium text-required leading-none",
|
|
69
71
|
children: "*"
|
|
70
72
|
}),
|
|
71
73
|
tooltip && /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { Button } from "./button.mjs";
|
|
2
|
-
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
2
|
import { ComponentProps } from "react";
|
|
4
|
-
|
|
5
3
|
//#region src/components/github-button.d.ts
|
|
6
4
|
type GitHubButtonProps = Omit<ComponentProps<typeof Button>, "variant" | "icon">;
|
|
7
|
-
declare function GitHubButton({
|
|
8
|
-
className,
|
|
9
|
-
children,
|
|
10
|
-
...props
|
|
11
|
-
}: GitHubButtonProps): _$react_jsx_runtime0.JSX.Element;
|
|
5
|
+
declare function GitHubButton({ className, children, ...props }: GitHubButtonProps): import("react").JSX.Element;
|
|
12
6
|
//#endregion
|
|
13
7
|
export { GitHubButton, type GitHubButtonProps };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ChartPaletteName } from "../lib/chart-palette.mjs";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
//#region src/components/heatmap-chart.d.ts
|
|
4
|
+
interface HeatmapChartProps {
|
|
5
|
+
data: ReadonlyArray<Record<string, string | number | null | undefined>>;
|
|
6
|
+
xKey: string;
|
|
7
|
+
yKey: string;
|
|
8
|
+
dataKey?: string;
|
|
9
|
+
variant?: "square" | "dot";
|
|
10
|
+
palette?: ChartPaletteName;
|
|
11
|
+
xLabels?: readonly string[];
|
|
12
|
+
yLabels?: readonly string[];
|
|
13
|
+
showAllXLabels?: boolean;
|
|
14
|
+
highlightPeak?: boolean;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
valueFormatter?: (value: number) => string;
|
|
17
|
+
xTickFormatter?: (label: string) => string;
|
|
18
|
+
yTickFormatter?: (label: string) => string;
|
|
19
|
+
tooltipMetrics?: ReadonlyArray<{
|
|
20
|
+
key: string;
|
|
21
|
+
label: string;
|
|
22
|
+
format?: (value: number) => string;
|
|
23
|
+
}>;
|
|
24
|
+
tooltipTitleKey?: string;
|
|
25
|
+
colorScale?: "linear" | "rank";
|
|
26
|
+
showLegend?: boolean;
|
|
27
|
+
ariaLabel?: string;
|
|
28
|
+
className?: string;
|
|
29
|
+
}
|
|
30
|
+
declare function HeatmapChart({ data, xKey, yKey, dataKey, variant, palette, xLabels, yLabels, showAllXLabels, highlightPeak, loading, valueFormatter, xTickFormatter, yTickFormatter, tooltipMetrics, tooltipTitleKey, colorScale, showLegend, ariaLabel, className }: HeatmapChartProps): React$1.JSX.Element;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { HeatmapChart, HeatmapChartProps };
|