@alpic-ai/ui 1.127.1 → 1.129.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/components/form.d.mts +36 -1
- package/dist/components/form.mjs +114 -4
- package/dist/components/tabs.mjs +4 -4
- package/dist/components/task-progress.d.mts +27 -0
- package/dist/components/task-progress.mjs +66 -0
- package/dist/components/tooltip.mjs +1 -1
- package/dist/components/wizard.d.mts +34 -0
- package/dist/components/wizard.mjs +46 -0
- package/package.json +1 -1
- package/src/components/form.tsx +164 -3
- package/src/components/tabs.tsx +4 -4
- package/src/components/task-progress.tsx +107 -0
- package/src/components/tooltip.tsx +1 -1
- package/src/components/wizard.tsx +69 -0
- package/src/stories/form.stories.tsx +64 -2
- package/src/stories/tabs.stories.tsx +4 -2
- package/src/stories/task-progress.stories.tsx +81 -0
- package/src/stories/wizard.stories.tsx +64 -0
|
@@ -115,5 +115,40 @@ declare function SelectField<TFieldValues extends FieldValues, TName extends Fie
|
|
|
115
115
|
options,
|
|
116
116
|
placeholder
|
|
117
117
|
}: SelectFieldProps<TFieldValues, TName>): _$react_jsx_runtime0.JSX.Element;
|
|
118
|
+
interface RadioFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> extends FormFieldBaseProps<TFieldValues, TName> {
|
|
119
|
+
options: SelectFieldOption[];
|
|
120
|
+
}
|
|
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;
|
|
131
|
+
interface ChecklistFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> extends FormFieldBaseProps<TFieldValues, TName> {
|
|
132
|
+
options: SelectFieldOption[];
|
|
133
|
+
}
|
|
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;
|
|
144
|
+
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;
|
|
118
153
|
//#endregion
|
|
119
|
-
export { Form, FormControl, FormDescription, FormField, FormFields, FormHeader, FormItem, FormLabel, FormMessage, InputField, SelectField, type SelectFieldOption, TextareaField, useFormField };
|
|
154
|
+
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
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.mjs";
|
|
3
3
|
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.mjs";
|
|
4
|
+
import { Checkbox } from "./checkbox.mjs";
|
|
4
5
|
import { Label } from "./label.mjs";
|
|
5
6
|
import { Input } from "./input.mjs";
|
|
7
|
+
import { RadioGroup, RadioGroupItem } from "./radio-group.mjs";
|
|
6
8
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.mjs";
|
|
7
9
|
import { Textarea } from "./textarea.mjs";
|
|
8
10
|
import { Info } from "lucide-react";
|
|
@@ -88,7 +90,7 @@ function FormDescription({ className, ...props }) {
|
|
|
88
90
|
return /* @__PURE__ */ jsx("p", {
|
|
89
91
|
"data-slot": "form-description",
|
|
90
92
|
id: formDescriptionId,
|
|
91
|
-
className: cn("text-muted-foreground text-sm", className),
|
|
93
|
+
className: cn("text-muted-foreground type-text-sm whitespace-pre-line", className),
|
|
92
94
|
...props
|
|
93
95
|
});
|
|
94
96
|
}
|
|
@@ -134,11 +136,11 @@ function InputField({ control, name, rules, required, label, description, toolti
|
|
|
134
136
|
tooltip,
|
|
135
137
|
children: label
|
|
136
138
|
}),
|
|
139
|
+
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
137
140
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Input, {
|
|
138
141
|
...inputProps,
|
|
139
142
|
...field
|
|
140
143
|
}) }),
|
|
141
|
-
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
142
144
|
/* @__PURE__ */ jsx(FormMessage, {})
|
|
143
145
|
] })
|
|
144
146
|
});
|
|
@@ -154,11 +156,11 @@ function TextareaField({ control, name, rules, required, label, description, too
|
|
|
154
156
|
tooltip,
|
|
155
157
|
children: label
|
|
156
158
|
}),
|
|
159
|
+
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
157
160
|
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Textarea, {
|
|
158
161
|
...textareaProps,
|
|
159
162
|
...field
|
|
160
163
|
}) }),
|
|
161
|
-
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
162
164
|
/* @__PURE__ */ jsx(FormMessage, {})
|
|
163
165
|
] })
|
|
164
166
|
});
|
|
@@ -174,6 +176,7 @@ function SelectField({ control, name, rules, required, label, description, toolt
|
|
|
174
176
|
tooltip,
|
|
175
177
|
children: label
|
|
176
178
|
}),
|
|
179
|
+
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
177
180
|
/* @__PURE__ */ jsxs(Select, {
|
|
178
181
|
value: field.value,
|
|
179
182
|
onValueChange: field.onChange,
|
|
@@ -183,10 +186,117 @@ function SelectField({ control, name, rules, required, label, description, toolt
|
|
|
183
186
|
children: option.label
|
|
184
187
|
}, option.value)) })]
|
|
185
188
|
}),
|
|
189
|
+
/* @__PURE__ */ jsx(FormMessage, {})
|
|
190
|
+
] })
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
function RadioField({ control, name, rules, required, label, description, tooltip, options }) {
|
|
194
|
+
return /* @__PURE__ */ jsx(FormField, {
|
|
195
|
+
control,
|
|
196
|
+
name,
|
|
197
|
+
rules,
|
|
198
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(FormItem, { children: [
|
|
199
|
+
label && /* @__PURE__ */ jsx(FormLabel, {
|
|
200
|
+
required,
|
|
201
|
+
tooltip,
|
|
202
|
+
children: label
|
|
203
|
+
}),
|
|
186
204
|
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
205
|
+
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(RadioGroup, {
|
|
206
|
+
value: field.value ?? "",
|
|
207
|
+
onValueChange: field.onChange,
|
|
208
|
+
onBlur: field.onBlur,
|
|
209
|
+
children: options.map((option) => {
|
|
210
|
+
const itemId = `${field.name}-${option.value}`;
|
|
211
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
212
|
+
className: "flex items-center gap-2",
|
|
213
|
+
children: [/* @__PURE__ */ jsx(RadioGroupItem, {
|
|
214
|
+
id: itemId,
|
|
215
|
+
value: option.value,
|
|
216
|
+
disabled: option.disabled
|
|
217
|
+
}), /* @__PURE__ */ jsx(Label, {
|
|
218
|
+
htmlFor: itemId,
|
|
219
|
+
className: "type-text-sm font-normal",
|
|
220
|
+
children: option.label
|
|
221
|
+
})]
|
|
222
|
+
}, option.value);
|
|
223
|
+
})
|
|
224
|
+
}) }),
|
|
187
225
|
/* @__PURE__ */ jsx(FormMessage, {})
|
|
188
226
|
] })
|
|
189
227
|
});
|
|
190
228
|
}
|
|
229
|
+
function ChecklistField({ control, name, rules, required, label, description, tooltip, options }) {
|
|
230
|
+
return /* @__PURE__ */ jsx(FormField, {
|
|
231
|
+
control,
|
|
232
|
+
name,
|
|
233
|
+
rules,
|
|
234
|
+
render: ({ field }) => {
|
|
235
|
+
const selected = Array.isArray(field.value) ? field.value : [];
|
|
236
|
+
const toggle = (value, checked) => {
|
|
237
|
+
if (checked) field.onChange([...selected, value]);
|
|
238
|
+
else field.onChange(selected.filter((existing) => existing !== value));
|
|
239
|
+
};
|
|
240
|
+
return /* @__PURE__ */ jsxs(FormItem, { children: [
|
|
241
|
+
label && /* @__PURE__ */ jsx(FormLabel, {
|
|
242
|
+
required,
|
|
243
|
+
tooltip,
|
|
244
|
+
children: label
|
|
245
|
+
}),
|
|
246
|
+
description && /* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
247
|
+
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx("fieldset", {
|
|
248
|
+
className: "m-0 flex flex-col gap-2 border-0 p-0",
|
|
249
|
+
onBlur: field.onBlur,
|
|
250
|
+
children: options.map((option) => {
|
|
251
|
+
const itemId = `${field.name}-${option.value}`;
|
|
252
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
253
|
+
className: "flex items-start gap-2",
|
|
254
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
255
|
+
id: itemId,
|
|
256
|
+
checked: selected.includes(option.value),
|
|
257
|
+
onCheckedChange: (next) => toggle(option.value, Boolean(next)),
|
|
258
|
+
disabled: option.disabled
|
|
259
|
+
}), /* @__PURE__ */ jsx(Label, {
|
|
260
|
+
htmlFor: itemId,
|
|
261
|
+
className: "type-text-sm font-normal leading-tight",
|
|
262
|
+
children: option.label
|
|
263
|
+
})]
|
|
264
|
+
}, option.value);
|
|
265
|
+
})
|
|
266
|
+
}) }),
|
|
267
|
+
/* @__PURE__ */ jsx(FormMessage, {})
|
|
268
|
+
] });
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
function CheckboxField({ control, name, rules, label, description, tooltip }) {
|
|
273
|
+
return /* @__PURE__ */ jsx(FormField, {
|
|
274
|
+
control,
|
|
275
|
+
name,
|
|
276
|
+
rules,
|
|
277
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(FormItem, {
|
|
278
|
+
className: "gap-1.5",
|
|
279
|
+
children: [
|
|
280
|
+
/* @__PURE__ */ jsxs("div", {
|
|
281
|
+
className: "flex items-start gap-2",
|
|
282
|
+
children: [/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Checkbox, {
|
|
283
|
+
checked: field.value ?? false,
|
|
284
|
+
onCheckedChange: (next) => field.onChange(Boolean(next)),
|
|
285
|
+
onBlur: field.onBlur
|
|
286
|
+
}) }), label && /* @__PURE__ */ jsx(FormLabel, {
|
|
287
|
+
tooltip,
|
|
288
|
+
className: "font-normal",
|
|
289
|
+
children: label
|
|
290
|
+
})]
|
|
291
|
+
}),
|
|
292
|
+
description && /* @__PURE__ */ jsx(FormDescription, {
|
|
293
|
+
className: "ml-6",
|
|
294
|
+
children: description
|
|
295
|
+
}),
|
|
296
|
+
/* @__PURE__ */ jsx(FormMessage, { className: "ml-6" })
|
|
297
|
+
]
|
|
298
|
+
})
|
|
299
|
+
});
|
|
300
|
+
}
|
|
191
301
|
//#endregion
|
|
192
|
-
export { Form, FormControl, FormDescription, FormField, FormFields, FormHeader, FormItem, FormLabel, FormMessage, InputField, SelectField, TextareaField, useFormField };
|
|
302
|
+
export { CheckboxField, ChecklistField, Form, FormControl, FormDescription, FormField, FormFields, FormHeader, FormItem, FormLabel, FormMessage, InputField, RadioField, SelectField, TextareaField, useFormField };
|
package/dist/components/tabs.mjs
CHANGED
|
@@ -21,10 +21,10 @@ const tabsTriggerVariants = cva([
|
|
|
21
21
|
"data-[state=active]:border-b-2 data-[state=active]:border-foreground data-[state=active]:text-foreground"
|
|
22
22
|
],
|
|
23
23
|
pill: [
|
|
24
|
-
"rounded-
|
|
25
|
-
"text-
|
|
26
|
-
"[@media(hover:hover)]:hover:bg-accent [@media(hover:hover)]:hover:text-
|
|
27
|
-
"data-[state=active]:bg-accent data-[state=active]:text-
|
|
24
|
+
"rounded-md px-2 py-1.5",
|
|
25
|
+
"text-quaternary-foreground",
|
|
26
|
+
"[@media(hover:hover)]:hover:bg-accent [@media(hover:hover)]:hover:text-muted-foreground",
|
|
27
|
+
"data-[state=active]:bg-accent data-[state=active]:text-muted-foreground"
|
|
28
28
|
]
|
|
29
29
|
} },
|
|
30
30
|
defaultVariants: { variant: "default" }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/components/task-progress.d.ts
|
|
4
|
+
type TaskProgressStatus = "pending" | "running" | "done";
|
|
5
|
+
interface TaskProgressStep {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
status: TaskProgressStatus;
|
|
9
|
+
}
|
|
10
|
+
interface TaskProgressProps extends Omit<React.ComponentProps<"div">, "children"> {
|
|
11
|
+
steps: readonly TaskProgressStep[];
|
|
12
|
+
trailingLabel?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Optional mount-time stagger: each row fades + slides in with `animation-delay = index × stepRevealDelayMs`.
|
|
15
|
+
* Pure CSS, runs once on mount. Omit for no animation.
|
|
16
|
+
*/
|
|
17
|
+
stepRevealDelayMs?: number;
|
|
18
|
+
}
|
|
19
|
+
declare function TaskProgress({
|
|
20
|
+
steps,
|
|
21
|
+
trailingLabel,
|
|
22
|
+
stepRevealDelayMs,
|
|
23
|
+
className,
|
|
24
|
+
...props
|
|
25
|
+
}: TaskProgressProps): _$react_jsx_runtime0.JSX.Element;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { TaskProgress, type TaskProgressStatus, type TaskProgressStep };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.mjs";
|
|
3
|
+
import { Separator } from "./separator.mjs";
|
|
4
|
+
import { CheckIcon } from "lucide-react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/task-progress.tsx
|
|
7
|
+
const REVEAL_CLASSES = "animate-in fade-in slide-in-from-bottom-2 duration-300";
|
|
8
|
+
function TaskProgress({ steps, trailingLabel, stepRevealDelayMs, className, ...props }) {
|
|
9
|
+
const total = steps.length;
|
|
10
|
+
const doneCount = steps.filter((step) => step.status === "done").length;
|
|
11
|
+
const percent = total > 0 ? Math.round(doneCount / total * 100) : 0;
|
|
12
|
+
const stagger = stepRevealDelayMs != null;
|
|
13
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
14
|
+
className: cn("flex flex-col gap-4", className),
|
|
15
|
+
...props,
|
|
16
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
17
|
+
className: "bg-muted h-2 w-full overflow-hidden rounded-full",
|
|
18
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
19
|
+
className: "h-full rounded-full bg-success transition-all duration-500",
|
|
20
|
+
style: { width: `${percent}%` }
|
|
21
|
+
})
|
|
22
|
+
}), /* @__PURE__ */ jsxs("div", { children: [steps.map((step, idx) => /* @__PURE__ */ jsxs("div", {
|
|
23
|
+
className: stagger ? REVEAL_CLASSES : void 0,
|
|
24
|
+
style: stagger ? {
|
|
25
|
+
animationDelay: `${idx * (stepRevealDelayMs ?? 0)}ms`,
|
|
26
|
+
animationFillMode: "both"
|
|
27
|
+
} : void 0,
|
|
28
|
+
children: [/* @__PURE__ */ jsx(TaskProgressRow, {
|
|
29
|
+
label: step.label,
|
|
30
|
+
status: step.status
|
|
31
|
+
}), idx < steps.length - 1 && /* @__PURE__ */ jsx(Separator, {})]
|
|
32
|
+
}, step.id)), trailingLabel && /* @__PURE__ */ jsxs("div", {
|
|
33
|
+
className: stagger ? REVEAL_CLASSES : void 0,
|
|
34
|
+
children: [/* @__PURE__ */ jsx(Separator, {}), /* @__PURE__ */ jsx(TaskProgressRow, {
|
|
35
|
+
label: trailingLabel,
|
|
36
|
+
status: "running",
|
|
37
|
+
muted: true
|
|
38
|
+
})]
|
|
39
|
+
})] })]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function TaskProgressRow({ label, status, muted }) {
|
|
43
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
44
|
+
className: "flex items-center justify-between py-2",
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ jsx("span", {
|
|
47
|
+
className: cn("type-text-sm", muted && "text-muted-foreground"),
|
|
48
|
+
children: label
|
|
49
|
+
}),
|
|
50
|
+
status === "done" && /* @__PURE__ */ jsxs("span", {
|
|
51
|
+
className: "flex items-center gap-1 type-text-sm text-success",
|
|
52
|
+
children: [/* @__PURE__ */ jsx(CheckIcon, { className: "size-3.5" }), /* @__PURE__ */ jsx("span", { children: "done" })]
|
|
53
|
+
}),
|
|
54
|
+
status === "running" && /* @__PURE__ */ jsxs("span", {
|
|
55
|
+
className: "flex items-center gap-1.5 type-text-sm text-warning",
|
|
56
|
+
children: [/* @__PURE__ */ jsx("span", { className: "size-2 rounded-full bg-warning" }), /* @__PURE__ */ jsx("span", { children: "running…" })]
|
|
57
|
+
}),
|
|
58
|
+
status === "pending" && /* @__PURE__ */ jsxs("span", {
|
|
59
|
+
className: "flex items-center gap-1.5 type-text-sm text-muted-foreground",
|
|
60
|
+
children: [/* @__PURE__ */ jsx("span", { className: "size-2 rounded-full border border-muted-foreground" }), /* @__PURE__ */ jsx("span", { children: "pending" })]
|
|
61
|
+
})
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { TaskProgress };
|
|
@@ -26,7 +26,7 @@ function TooltipContent({ className, sideOffset = 6, children, ...props }) {
|
|
|
26
26
|
return /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsxs(TooltipPrimitive.Content, {
|
|
27
27
|
"data-slot": "tooltip-content",
|
|
28
28
|
sideOffset,
|
|
29
|
-
className: cn("bg-inverted text-inverted-foreground dark:bg-subtle dark:text-foreground", "z-50 w-fit rounded-md px-3 py-2 shadow-lg dark:shadow-none dark:drop-shadow-[0_0_0.5px_var(--color-border)]", "type-text-xs font-semibold text-balance text-center", "animate-in fade-in-0 zoom-in-95", "data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95", "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", "origin-(--radix-tooltip-content-transform-origin)", className),
|
|
29
|
+
className: cn("bg-inverted text-inverted-foreground dark:bg-subtle dark:text-foreground", "z-50 w-fit rounded-md px-3 py-2 shadow-lg dark:shadow-none dark:drop-shadow-[0_0_0.5px_var(--color-border)]", "type-text-xs font-semibold text-balance text-center whitespace-pre-line", "animate-in fade-in-0 zoom-in-95", "data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95", "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", "origin-(--radix-tooltip-content-transform-origin)", className),
|
|
30
30
|
...props,
|
|
31
31
|
children: [children, /* @__PURE__ */ jsx(TooltipPrimitive.Arrow, { className: "bg-inverted fill-inverted dark:bg-subtle dark:fill-subtle z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })]
|
|
32
32
|
}) });
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/wizard.d.ts
|
|
5
|
+
interface WizardStep {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
}
|
|
9
|
+
interface WizardStepsProps {
|
|
10
|
+
steps: readonly WizardStep[];
|
|
11
|
+
activeIdx: number;
|
|
12
|
+
onSelect: (idx: number) => void;
|
|
13
|
+
ariaLabel?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function WizardSteps({
|
|
17
|
+
steps,
|
|
18
|
+
activeIdx,
|
|
19
|
+
onSelect,
|
|
20
|
+
ariaLabel,
|
|
21
|
+
className
|
|
22
|
+
}: WizardStepsProps): _$react_jsx_runtime0.JSX.Element;
|
|
23
|
+
interface WizardProgressProps extends React.ComponentProps<"div"> {
|
|
24
|
+
current: number;
|
|
25
|
+
total: number;
|
|
26
|
+
}
|
|
27
|
+
declare function WizardProgress({
|
|
28
|
+
current,
|
|
29
|
+
total,
|
|
30
|
+
className,
|
|
31
|
+
...props
|
|
32
|
+
}: WizardProgressProps): _$react_jsx_runtime0.JSX.Element;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { WizardProgress, type WizardStep, WizardSteps };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.mjs";
|
|
3
|
+
import { TabsNav, TabsNavList, TabsNavTrigger } from "./tabs.mjs";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/wizard.tsx
|
|
6
|
+
function WizardSteps({ steps, activeIdx, onSelect, ariaLabel = "Wizard steps", className }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(TabsNav, {
|
|
8
|
+
orientation: "vertical",
|
|
9
|
+
"aria-label": ariaLabel,
|
|
10
|
+
className,
|
|
11
|
+
children: /* @__PURE__ */ jsx(TabsNavList, { children: steps.map((step, idx) => /* @__PURE__ */ jsx(TabsNavTrigger, {
|
|
12
|
+
active: idx === activeIdx,
|
|
13
|
+
asChild: true,
|
|
14
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
15
|
+
type: "button",
|
|
16
|
+
onClick: () => onSelect(idx),
|
|
17
|
+
className: "w-full justify-start text-left",
|
|
18
|
+
children: step.label
|
|
19
|
+
})
|
|
20
|
+
}, step.id)) })
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function WizardProgress({ current, total, className, ...props }) {
|
|
24
|
+
const percent = total > 0 ? Math.round(current / total * 100) : 0;
|
|
25
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
26
|
+
className: cn("flex flex-col gap-1.5 px-2", className),
|
|
27
|
+
...props,
|
|
28
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
29
|
+
className: "text-muted-foreground flex items-center justify-between text-xs",
|
|
30
|
+
children: [/* @__PURE__ */ jsxs("span", { children: [
|
|
31
|
+
"Step ",
|
|
32
|
+
current,
|
|
33
|
+
"/",
|
|
34
|
+
total
|
|
35
|
+
] }), /* @__PURE__ */ jsxs("span", { children: [percent, "%"] })]
|
|
36
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
37
|
+
className: "bg-muted h-1.5 overflow-hidden rounded-full",
|
|
38
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
39
|
+
className: "bg-primary h-full transition-all",
|
|
40
|
+
style: { width: `${percent}%` }
|
|
41
|
+
})
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { WizardProgress, WizardSteps };
|
package/package.json
CHANGED
package/src/components/form.tsx
CHANGED
|
@@ -14,8 +14,10 @@ import {
|
|
|
14
14
|
} from "react-hook-form";
|
|
15
15
|
|
|
16
16
|
import { cn } from "../lib/cn";
|
|
17
|
+
import { Checkbox } from "./checkbox";
|
|
17
18
|
import { Input, type InputProps } from "./input";
|
|
18
19
|
import { Label } from "./label";
|
|
20
|
+
import { RadioGroup, RadioGroupItem } from "./radio-group";
|
|
19
21
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select";
|
|
20
22
|
import { Textarea, type TextareaProps } from "./textarea";
|
|
21
23
|
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip";
|
|
@@ -141,7 +143,7 @@ function FormDescription({ className, ...props }: React.ComponentProps<"p">) {
|
|
|
141
143
|
<p
|
|
142
144
|
data-slot="form-description"
|
|
143
145
|
id={formDescriptionId}
|
|
144
|
-
className={cn("text-muted-foreground text-sm", className)}
|
|
146
|
+
className={cn("text-muted-foreground type-text-sm whitespace-pre-line", className)}
|
|
145
147
|
{...props}
|
|
146
148
|
/>
|
|
147
149
|
);
|
|
@@ -220,10 +222,10 @@ function InputField<TFieldValues extends FieldValues, TName extends FieldPath<TF
|
|
|
220
222
|
{label}
|
|
221
223
|
</FormLabel>
|
|
222
224
|
)}
|
|
225
|
+
{description && <FormDescription>{description}</FormDescription>}
|
|
223
226
|
<FormControl>
|
|
224
227
|
<Input {...inputProps} {...field} />
|
|
225
228
|
</FormControl>
|
|
226
|
-
{description && <FormDescription>{description}</FormDescription>}
|
|
227
229
|
<FormMessage />
|
|
228
230
|
</FormItem>
|
|
229
231
|
)}
|
|
@@ -257,10 +259,10 @@ function TextareaField<TFieldValues extends FieldValues, TName extends FieldPath
|
|
|
257
259
|
{label}
|
|
258
260
|
</FormLabel>
|
|
259
261
|
)}
|
|
262
|
+
{description && <FormDescription>{description}</FormDescription>}
|
|
260
263
|
<FormControl>
|
|
261
264
|
<Textarea {...textareaProps} {...field} />
|
|
262
265
|
</FormControl>
|
|
263
|
-
{description && <FormDescription>{description}</FormDescription>}
|
|
264
266
|
<FormMessage />
|
|
265
267
|
</FormItem>
|
|
266
268
|
)}
|
|
@@ -303,6 +305,7 @@ function SelectField<TFieldValues extends FieldValues, TName extends FieldPath<T
|
|
|
303
305
|
{label}
|
|
304
306
|
</FormLabel>
|
|
305
307
|
)}
|
|
308
|
+
{description && <FormDescription>{description}</FormDescription>}
|
|
306
309
|
<Select value={field.value} onValueChange={field.onChange}>
|
|
307
310
|
<FormControl>
|
|
308
311
|
<SelectTrigger>
|
|
@@ -317,7 +320,56 @@ function SelectField<TFieldValues extends FieldValues, TName extends FieldPath<T
|
|
|
317
320
|
))}
|
|
318
321
|
</SelectContent>
|
|
319
322
|
</Select>
|
|
323
|
+
<FormMessage />
|
|
324
|
+
</FormItem>
|
|
325
|
+
)}
|
|
326
|
+
/>
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
interface RadioFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>
|
|
331
|
+
extends FormFieldBaseProps<TFieldValues, TName> {
|
|
332
|
+
options: SelectFieldOption[];
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function RadioField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({
|
|
336
|
+
control,
|
|
337
|
+
name,
|
|
338
|
+
rules,
|
|
339
|
+
required,
|
|
340
|
+
label,
|
|
341
|
+
description,
|
|
342
|
+
tooltip,
|
|
343
|
+
options,
|
|
344
|
+
}: RadioFieldProps<TFieldValues, TName>) {
|
|
345
|
+
return (
|
|
346
|
+
<FormField
|
|
347
|
+
control={control}
|
|
348
|
+
name={name}
|
|
349
|
+
rules={rules}
|
|
350
|
+
render={({ field }) => (
|
|
351
|
+
<FormItem>
|
|
352
|
+
{label && (
|
|
353
|
+
<FormLabel required={required} tooltip={tooltip}>
|
|
354
|
+
{label}
|
|
355
|
+
</FormLabel>
|
|
356
|
+
)}
|
|
320
357
|
{description && <FormDescription>{description}</FormDescription>}
|
|
358
|
+
<FormControl>
|
|
359
|
+
<RadioGroup value={field.value ?? ""} onValueChange={field.onChange} onBlur={field.onBlur}>
|
|
360
|
+
{options.map((option) => {
|
|
361
|
+
const itemId = `${field.name}-${option.value}`;
|
|
362
|
+
return (
|
|
363
|
+
<div key={option.value} className="flex items-center gap-2">
|
|
364
|
+
<RadioGroupItem id={itemId} value={option.value} disabled={option.disabled} />
|
|
365
|
+
<Label htmlFor={itemId} className="type-text-sm font-normal">
|
|
366
|
+
{option.label}
|
|
367
|
+
</Label>
|
|
368
|
+
</div>
|
|
369
|
+
);
|
|
370
|
+
})}
|
|
371
|
+
</RadioGroup>
|
|
372
|
+
</FormControl>
|
|
321
373
|
<FormMessage />
|
|
322
374
|
</FormItem>
|
|
323
375
|
)}
|
|
@@ -325,8 +377,116 @@ function SelectField<TFieldValues extends FieldValues, TName extends FieldPath<T
|
|
|
325
377
|
);
|
|
326
378
|
}
|
|
327
379
|
|
|
380
|
+
interface ChecklistFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>
|
|
381
|
+
extends FormFieldBaseProps<TFieldValues, TName> {
|
|
382
|
+
options: SelectFieldOption[];
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function ChecklistField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({
|
|
386
|
+
control,
|
|
387
|
+
name,
|
|
388
|
+
rules,
|
|
389
|
+
required,
|
|
390
|
+
label,
|
|
391
|
+
description,
|
|
392
|
+
tooltip,
|
|
393
|
+
options,
|
|
394
|
+
}: ChecklistFieldProps<TFieldValues, TName>) {
|
|
395
|
+
return (
|
|
396
|
+
<FormField
|
|
397
|
+
control={control}
|
|
398
|
+
name={name}
|
|
399
|
+
rules={rules}
|
|
400
|
+
render={({ field }) => {
|
|
401
|
+
const selected: string[] = Array.isArray(field.value) ? field.value : [];
|
|
402
|
+
const toggle = (value: string, checked: boolean) => {
|
|
403
|
+
if (checked) {
|
|
404
|
+
field.onChange([...selected, value]);
|
|
405
|
+
} else {
|
|
406
|
+
field.onChange(selected.filter((existing) => existing !== value));
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
return (
|
|
410
|
+
<FormItem>
|
|
411
|
+
{label && (
|
|
412
|
+
<FormLabel required={required} tooltip={tooltip}>
|
|
413
|
+
{label}
|
|
414
|
+
</FormLabel>
|
|
415
|
+
)}
|
|
416
|
+
{description && <FormDescription>{description}</FormDescription>}
|
|
417
|
+
<FormControl>
|
|
418
|
+
<fieldset className="m-0 flex flex-col gap-2 border-0 p-0" onBlur={field.onBlur}>
|
|
419
|
+
{options.map((option) => {
|
|
420
|
+
const itemId = `${field.name}-${option.value}`;
|
|
421
|
+
const checked = selected.includes(option.value);
|
|
422
|
+
return (
|
|
423
|
+
<div key={option.value} className="flex items-start gap-2">
|
|
424
|
+
<Checkbox
|
|
425
|
+
id={itemId}
|
|
426
|
+
checked={checked}
|
|
427
|
+
onCheckedChange={(next) => toggle(option.value, Boolean(next))}
|
|
428
|
+
disabled={option.disabled}
|
|
429
|
+
/>
|
|
430
|
+
<Label htmlFor={itemId} className="type-text-sm font-normal leading-tight">
|
|
431
|
+
{option.label}
|
|
432
|
+
</Label>
|
|
433
|
+
</div>
|
|
434
|
+
);
|
|
435
|
+
})}
|
|
436
|
+
</fieldset>
|
|
437
|
+
</FormControl>
|
|
438
|
+
<FormMessage />
|
|
439
|
+
</FormItem>
|
|
440
|
+
);
|
|
441
|
+
}}
|
|
442
|
+
/>
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
interface CheckboxFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>
|
|
447
|
+
extends Omit<FormFieldBaseProps<TFieldValues, TName>, "required"> {}
|
|
448
|
+
|
|
449
|
+
function CheckboxField<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>({
|
|
450
|
+
control,
|
|
451
|
+
name,
|
|
452
|
+
rules,
|
|
453
|
+
label,
|
|
454
|
+
description,
|
|
455
|
+
tooltip,
|
|
456
|
+
}: CheckboxFieldProps<TFieldValues, TName>) {
|
|
457
|
+
return (
|
|
458
|
+
<FormField
|
|
459
|
+
control={control}
|
|
460
|
+
name={name}
|
|
461
|
+
rules={rules}
|
|
462
|
+
render={({ field }) => (
|
|
463
|
+
<FormItem className="gap-1.5">
|
|
464
|
+
<div className="flex items-start gap-2">
|
|
465
|
+
<FormControl>
|
|
466
|
+
<Checkbox
|
|
467
|
+
checked={field.value ?? false}
|
|
468
|
+
onCheckedChange={(next) => field.onChange(Boolean(next))}
|
|
469
|
+
onBlur={field.onBlur}
|
|
470
|
+
/>
|
|
471
|
+
</FormControl>
|
|
472
|
+
{label && (
|
|
473
|
+
<FormLabel tooltip={tooltip} className="font-normal">
|
|
474
|
+
{label}
|
|
475
|
+
</FormLabel>
|
|
476
|
+
)}
|
|
477
|
+
</div>
|
|
478
|
+
{description && <FormDescription className="ml-6">{description}</FormDescription>}
|
|
479
|
+
<FormMessage className="ml-6" />
|
|
480
|
+
</FormItem>
|
|
481
|
+
)}
|
|
482
|
+
/>
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
|
|
328
486
|
export type { SelectFieldOption };
|
|
329
487
|
export {
|
|
488
|
+
CheckboxField,
|
|
489
|
+
ChecklistField,
|
|
330
490
|
Form,
|
|
331
491
|
FormControl,
|
|
332
492
|
FormDescription,
|
|
@@ -337,6 +497,7 @@ export {
|
|
|
337
497
|
FormLabel,
|
|
338
498
|
FormMessage,
|
|
339
499
|
InputField,
|
|
500
|
+
RadioField,
|
|
340
501
|
SelectField,
|
|
341
502
|
TextareaField,
|
|
342
503
|
useFormField,
|
package/src/components/tabs.tsx
CHANGED
|
@@ -44,10 +44,10 @@ const tabsTriggerVariants = cva(
|
|
|
44
44
|
"data-[state=active]:border-b-2 data-[state=active]:border-foreground data-[state=active]:text-foreground",
|
|
45
45
|
],
|
|
46
46
|
pill: [
|
|
47
|
-
"rounded-
|
|
48
|
-
"text-
|
|
49
|
-
"[@media(hover:hover)]:hover:bg-accent [@media(hover:hover)]:hover:text-
|
|
50
|
-
"data-[state=active]:bg-accent data-[state=active]:text-
|
|
47
|
+
"rounded-md px-2 py-1.5",
|
|
48
|
+
"text-quaternary-foreground",
|
|
49
|
+
"[@media(hover:hover)]:hover:bg-accent [@media(hover:hover)]:hover:text-muted-foreground",
|
|
50
|
+
"data-[state=active]:bg-accent data-[state=active]:text-muted-foreground",
|
|
51
51
|
],
|
|
52
52
|
},
|
|
53
53
|
},
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* TaskProgress — multi-step async progress primitive.
|
|
5
|
+
*
|
|
6
|
+
* Dumb component: the consumer owns orchestration (timer, websocket, polling) and
|
|
7
|
+
* passes `steps` with each step's status. Renders a percentage bar at the top
|
|
8
|
+
* and one row per step with done/running/pending state badges.
|
|
9
|
+
*
|
|
10
|
+
* `trailingLabel` is for "still working on something not in the step list" —
|
|
11
|
+
* shows after the last step as a running row that isn't counted in the percent.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { CheckIcon } from "lucide-react";
|
|
15
|
+
|
|
16
|
+
import { cn } from "../lib/cn";
|
|
17
|
+
import { Separator } from "./separator";
|
|
18
|
+
|
|
19
|
+
type TaskProgressStatus = "pending" | "running" | "done";
|
|
20
|
+
|
|
21
|
+
interface TaskProgressStep {
|
|
22
|
+
id: string;
|
|
23
|
+
label: string;
|
|
24
|
+
status: TaskProgressStatus;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface TaskProgressProps extends Omit<React.ComponentProps<"div">, "children"> {
|
|
28
|
+
steps: readonly TaskProgressStep[];
|
|
29
|
+
trailingLabel?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Optional mount-time stagger: each row fades + slides in with `animation-delay = index × stepRevealDelayMs`.
|
|
32
|
+
* Pure CSS, runs once on mount. Omit for no animation.
|
|
33
|
+
*/
|
|
34
|
+
stepRevealDelayMs?: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const REVEAL_CLASSES = "animate-in fade-in slide-in-from-bottom-2 duration-300";
|
|
38
|
+
|
|
39
|
+
function TaskProgress({ steps, trailingLabel, stepRevealDelayMs, className, ...props }: TaskProgressProps) {
|
|
40
|
+
const total = steps.length;
|
|
41
|
+
const doneCount = steps.filter((step) => step.status === "done").length;
|
|
42
|
+
const percent = total > 0 ? Math.round((doneCount / total) * 100) : 0;
|
|
43
|
+
const stagger = stepRevealDelayMs != null;
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div className={cn("flex flex-col gap-4", className)} {...props}>
|
|
47
|
+
<div className="bg-muted h-2 w-full overflow-hidden rounded-full">
|
|
48
|
+
<div className="h-full rounded-full bg-success transition-all duration-500" style={{ width: `${percent}%` }} />
|
|
49
|
+
</div>
|
|
50
|
+
<div>
|
|
51
|
+
{steps.map((step, idx) => (
|
|
52
|
+
<div
|
|
53
|
+
key={step.id}
|
|
54
|
+
className={stagger ? REVEAL_CLASSES : undefined}
|
|
55
|
+
style={
|
|
56
|
+
stagger ? { animationDelay: `${idx * (stepRevealDelayMs ?? 0)}ms`, animationFillMode: "both" } : undefined
|
|
57
|
+
}
|
|
58
|
+
>
|
|
59
|
+
<TaskProgressRow label={step.label} status={step.status} />
|
|
60
|
+
{idx < steps.length - 1 && <Separator />}
|
|
61
|
+
</div>
|
|
62
|
+
))}
|
|
63
|
+
{trailingLabel && (
|
|
64
|
+
<div className={stagger ? REVEAL_CLASSES : undefined}>
|
|
65
|
+
<Separator />
|
|
66
|
+
<TaskProgressRow label={trailingLabel} status="running" muted />
|
|
67
|
+
</div>
|
|
68
|
+
)}
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface TaskProgressRowProps {
|
|
75
|
+
label: string;
|
|
76
|
+
status: TaskProgressStatus;
|
|
77
|
+
muted?: boolean;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function TaskProgressRow({ label, status, muted }: TaskProgressRowProps) {
|
|
81
|
+
return (
|
|
82
|
+
<div className="flex items-center justify-between py-2">
|
|
83
|
+
<span className={cn("type-text-sm", muted && "text-muted-foreground")}>{label}</span>
|
|
84
|
+
{status === "done" && (
|
|
85
|
+
<span className="flex items-center gap-1 type-text-sm text-success">
|
|
86
|
+
<CheckIcon className="size-3.5" />
|
|
87
|
+
<span>done</span>
|
|
88
|
+
</span>
|
|
89
|
+
)}
|
|
90
|
+
{status === "running" && (
|
|
91
|
+
<span className="flex items-center gap-1.5 type-text-sm text-warning">
|
|
92
|
+
<span className="size-2 rounded-full bg-warning" />
|
|
93
|
+
<span>running…</span>
|
|
94
|
+
</span>
|
|
95
|
+
)}
|
|
96
|
+
{status === "pending" && (
|
|
97
|
+
<span className="flex items-center gap-1.5 type-text-sm text-muted-foreground">
|
|
98
|
+
<span className="size-2 rounded-full border border-muted-foreground" />
|
|
99
|
+
<span>pending</span>
|
|
100
|
+
</span>
|
|
101
|
+
)}
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type { TaskProgressStatus, TaskProgressStep };
|
|
107
|
+
export { TaskProgress };
|
|
@@ -35,7 +35,7 @@ function TooltipContent({
|
|
|
35
35
|
className={cn(
|
|
36
36
|
"bg-inverted text-inverted-foreground dark:bg-subtle dark:text-foreground",
|
|
37
37
|
"z-50 w-fit rounded-md px-3 py-2 shadow-lg dark:shadow-none dark:drop-shadow-[0_0_0.5px_var(--color-border)]",
|
|
38
|
-
"type-text-xs font-semibold text-balance text-center",
|
|
38
|
+
"type-text-xs font-semibold text-balance text-center whitespace-pre-line",
|
|
39
39
|
"animate-in fade-in-0 zoom-in-95",
|
|
40
40
|
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
|
41
41
|
"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Wizard family — primitives for multi-step flows.
|
|
5
|
+
*
|
|
6
|
+
* - WizardSteps — vertical step rail (controlled by activeIdx + onSelect)
|
|
7
|
+
* - WizardProgress — step counter + progress bar
|
|
8
|
+
*
|
|
9
|
+
* Consumers compose these inside whatever container they need (sticky aside, modal, etc.).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type * as React from "react";
|
|
13
|
+
|
|
14
|
+
import { cn } from "../lib/cn";
|
|
15
|
+
import { TabsNav, TabsNavList, TabsNavTrigger } from "./tabs";
|
|
16
|
+
|
|
17
|
+
interface WizardStep {
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface WizardStepsProps {
|
|
23
|
+
steps: readonly WizardStep[];
|
|
24
|
+
activeIdx: number;
|
|
25
|
+
onSelect: (idx: number) => void;
|
|
26
|
+
ariaLabel?: string;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function WizardSteps({ steps, activeIdx, onSelect, ariaLabel = "Wizard steps", className }: WizardStepsProps) {
|
|
31
|
+
return (
|
|
32
|
+
<TabsNav orientation="vertical" aria-label={ariaLabel} className={className}>
|
|
33
|
+
<TabsNavList>
|
|
34
|
+
{steps.map((step, idx) => (
|
|
35
|
+
<TabsNavTrigger key={step.id} active={idx === activeIdx} asChild>
|
|
36
|
+
<button type="button" onClick={() => onSelect(idx)} className="w-full justify-start text-left">
|
|
37
|
+
{step.label}
|
|
38
|
+
</button>
|
|
39
|
+
</TabsNavTrigger>
|
|
40
|
+
))}
|
|
41
|
+
</TabsNavList>
|
|
42
|
+
</TabsNav>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface WizardProgressProps extends React.ComponentProps<"div"> {
|
|
47
|
+
current: number;
|
|
48
|
+
total: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function WizardProgress({ current, total, className, ...props }: WizardProgressProps) {
|
|
52
|
+
const percent = total > 0 ? Math.round((current / total) * 100) : 0;
|
|
53
|
+
return (
|
|
54
|
+
<div className={cn("flex flex-col gap-1.5 px-2", className)} {...props}>
|
|
55
|
+
<div className="text-muted-foreground flex items-center justify-between text-xs">
|
|
56
|
+
<span>
|
|
57
|
+
Step {current}/{total}
|
|
58
|
+
</span>
|
|
59
|
+
<span>{percent}%</span>
|
|
60
|
+
</div>
|
|
61
|
+
<div className="bg-muted h-1.5 overflow-hidden rounded-full">
|
|
62
|
+
<div className="bg-primary h-full transition-all" style={{ width: `${percent}%` }} />
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type { WizardStep };
|
|
69
|
+
export { WizardProgress, WizardSteps };
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { Story } from "@ladle/react";
|
|
2
2
|
import { useForm } from "react-hook-form";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
CheckboxField,
|
|
6
|
+
ChecklistField,
|
|
7
|
+
Form,
|
|
8
|
+
FormFields,
|
|
9
|
+
FormHeader,
|
|
10
|
+
InputField,
|
|
11
|
+
RadioField,
|
|
12
|
+
SelectField,
|
|
13
|
+
TextareaField,
|
|
14
|
+
} from "../components/form";
|
|
4
15
|
|
|
5
16
|
/* ── Types ───────────────────────────────────────────────────────────────── */
|
|
6
17
|
|
|
@@ -8,6 +19,9 @@ interface CreateProjectForm {
|
|
|
8
19
|
email: string;
|
|
9
20
|
role: string;
|
|
10
21
|
description: string;
|
|
22
|
+
visibility: string;
|
|
23
|
+
capabilities: string[];
|
|
24
|
+
acceptTerms: boolean;
|
|
11
25
|
}
|
|
12
26
|
|
|
13
27
|
const roles = [
|
|
@@ -16,11 +30,31 @@ const roles = [
|
|
|
16
30
|
{ value: "viewer", label: "Viewer" },
|
|
17
31
|
];
|
|
18
32
|
|
|
33
|
+
const visibilities = [
|
|
34
|
+
{ value: "public", label: "Public" },
|
|
35
|
+
{ value: "private", label: "Private" },
|
|
36
|
+
{ value: "internal", label: "Internal" },
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const capabilities = [
|
|
40
|
+
{ value: "read", label: "Read" },
|
|
41
|
+
{ value: "write", label: "Write" },
|
|
42
|
+
{ value: "deploy", label: "Deploy" },
|
|
43
|
+
{ value: "admin", label: "Admin" },
|
|
44
|
+
];
|
|
45
|
+
|
|
19
46
|
/* ── Composed Form ───────────────────────────────────────────────────────── */
|
|
20
47
|
|
|
21
48
|
function ComposedForm() {
|
|
22
49
|
const form = useForm<CreateProjectForm>({
|
|
23
|
-
defaultValues: {
|
|
50
|
+
defaultValues: {
|
|
51
|
+
email: "",
|
|
52
|
+
role: "",
|
|
53
|
+
description: "",
|
|
54
|
+
visibility: "",
|
|
55
|
+
capabilities: [],
|
|
56
|
+
acceptTerms: false,
|
|
57
|
+
},
|
|
24
58
|
});
|
|
25
59
|
|
|
26
60
|
const onSubmit = (data: CreateProjectForm) => {
|
|
@@ -64,6 +98,34 @@ function ComposedForm() {
|
|
|
64
98
|
placeholder="A short description of your project..."
|
|
65
99
|
required
|
|
66
100
|
/>
|
|
101
|
+
|
|
102
|
+
<RadioField
|
|
103
|
+
control={form.control}
|
|
104
|
+
name="visibility"
|
|
105
|
+
rules={{ required: "Pick a visibility." }}
|
|
106
|
+
label="Visibility"
|
|
107
|
+
description="Who can see and access this project."
|
|
108
|
+
options={visibilities}
|
|
109
|
+
required
|
|
110
|
+
/>
|
|
111
|
+
|
|
112
|
+
<ChecklistField
|
|
113
|
+
control={form.control}
|
|
114
|
+
name="capabilities"
|
|
115
|
+
rules={{ validate: (value) => (value?.length ? true : "Pick at least one capability.") }}
|
|
116
|
+
label="Capabilities"
|
|
117
|
+
description="Select all that apply."
|
|
118
|
+
options={capabilities}
|
|
119
|
+
required
|
|
120
|
+
/>
|
|
121
|
+
|
|
122
|
+
<CheckboxField
|
|
123
|
+
control={form.control}
|
|
124
|
+
name="acceptTerms"
|
|
125
|
+
rules={{ validate: (value) => (value ? true : "You must accept the terms.") }}
|
|
126
|
+
label="I accept the terms and conditions"
|
|
127
|
+
description="Required to create the project."
|
|
128
|
+
/>
|
|
67
129
|
</FormFields>
|
|
68
130
|
|
|
69
131
|
<button
|
|
@@ -18,9 +18,11 @@ const navTabs = [
|
|
|
18
18
|
|
|
19
19
|
const sideNavTabs = [
|
|
20
20
|
{ id: "general", label: "General" },
|
|
21
|
+
{ id: "build-settings", label: "Build settings" },
|
|
22
|
+
{ id: "environment-variables", label: "Environment variables" },
|
|
23
|
+
{ id: "domains", label: "Domains" },
|
|
21
24
|
{ id: "authentication", label: "Authentication" },
|
|
22
|
-
{ id: "
|
|
23
|
-
{ id: "billing", label: "Billing" },
|
|
25
|
+
{ id: "marketplace", label: "Marketplace" },
|
|
24
26
|
];
|
|
25
27
|
|
|
26
28
|
function useHashRoute(fallback: string) {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Story } from "@ladle/react";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import { TaskProgress, type TaskProgressStep } from "../components/task-progress";
|
|
5
|
+
|
|
6
|
+
const SECTION_HEADER = "type-text-xs font-medium text-subtle-foreground uppercase tracking-wide pt-4";
|
|
7
|
+
|
|
8
|
+
const beaconSteps: TaskProgressStep[] = [
|
|
9
|
+
{ id: "init", label: "Initialize MCP connection", status: "done" },
|
|
10
|
+
{ id: "fetch", label: "Fetch tools and resources", status: "done" },
|
|
11
|
+
{ id: "compat", label: "Check ChatGPT & Claude.ai compatibility", status: "done" },
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
const partialSteps: TaskProgressStep[] = [
|
|
15
|
+
{ id: "a", label: "Reading project metadata", status: "done" },
|
|
16
|
+
{ id: "b", label: "Fetching MCP server manifest", status: "running" },
|
|
17
|
+
{ id: "c", label: "Preparing your submission", status: "pending" },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const allDoneSteps: TaskProgressStep[] = [
|
|
21
|
+
{ id: "a", label: "Reading project metadata", status: "done" },
|
|
22
|
+
{ id: "b", label: "Fetching MCP server manifest", status: "done" },
|
|
23
|
+
{ id: "c", label: "Preparing your submission", status: "done" },
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const STEP_INTERVAL_MS = 1200;
|
|
27
|
+
|
|
28
|
+
function AnimatedExample() {
|
|
29
|
+
const [activeIdx, setActiveIdx] = useState(0);
|
|
30
|
+
|
|
31
|
+
const labels = ["Reading project metadata", "Fetching MCP server manifest", "Preparing your submission"];
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (activeIdx >= labels.length) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const timeoutId = setTimeout(() => setActiveIdx((prev) => prev + 1), STEP_INTERVAL_MS);
|
|
38
|
+
return () => clearTimeout(timeoutId);
|
|
39
|
+
}, [activeIdx, labels.length]);
|
|
40
|
+
|
|
41
|
+
const steps: TaskProgressStep[] = labels.map((label, idx) => ({
|
|
42
|
+
id: String(idx),
|
|
43
|
+
label,
|
|
44
|
+
status: idx < activeIdx ? "done" : idx === activeIdx ? "running" : "pending",
|
|
45
|
+
}));
|
|
46
|
+
const allDone = activeIdx >= labels.length;
|
|
47
|
+
|
|
48
|
+
return <TaskProgress steps={steps} trailingLabel={allDone ? "Almost there…" : undefined} />;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const AllVariants: Story = () => (
|
|
52
|
+
<div className="flex flex-col gap-8 p-8 max-w-[640px]">
|
|
53
|
+
<div>
|
|
54
|
+
<p className={SECTION_HEADER}>In-progress (running step in the middle)</p>
|
|
55
|
+
<div className="mt-4">
|
|
56
|
+
<TaskProgress steps={partialSteps} />
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div>
|
|
61
|
+
<p className={SECTION_HEADER}>All done</p>
|
|
62
|
+
<div className="mt-4">
|
|
63
|
+
<TaskProgress steps={allDoneSteps} />
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<div>
|
|
68
|
+
<p className={SECTION_HEADER}>All done + trailing "Running checks…" row</p>
|
|
69
|
+
<div className="mt-4">
|
|
70
|
+
<TaskProgress steps={beaconSteps} trailingLabel="Running checks…" />
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<div>
|
|
75
|
+
<p className={SECTION_HEADER}>Animated (timer-driven, mirrors the submission-prefill flow)</p>
|
|
76
|
+
<div className="mt-4">
|
|
77
|
+
<AnimatedExample />
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Story } from "@ladle/react";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
|
|
4
|
+
import { WizardProgress, type WizardStep, WizardSteps } from "../components/wizard";
|
|
5
|
+
|
|
6
|
+
const SECTION_HEADER = "type-text-xs font-medium text-muted-foreground uppercase tracking-wide pt-4";
|
|
7
|
+
|
|
8
|
+
const steps: WizardStep[] = [
|
|
9
|
+
{ id: "overview", label: "Overview" },
|
|
10
|
+
{ id: "branding", label: "Branding & metadata" },
|
|
11
|
+
{ id: "auth", label: "Authentication" },
|
|
12
|
+
{ id: "tools", label: "Tools & test cases" },
|
|
13
|
+
{ id: "review", label: "Review & submit" },
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
export const AllVariants: Story = () => {
|
|
17
|
+
const [activeIdx, setActiveIdx] = useState(1);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div className="flex flex-col gap-10 p-8">
|
|
21
|
+
{/* Full rail (steps + progress) */}
|
|
22
|
+
<div>
|
|
23
|
+
<p className={SECTION_HEADER}>Full rail — steps + progress</p>
|
|
24
|
+
<div className="mt-4 flex gap-6">
|
|
25
|
+
<aside className="basis-56 shrink-0 flex flex-col gap-4 self-start">
|
|
26
|
+
<WizardSteps steps={steps} activeIdx={activeIdx} onSelect={setActiveIdx} ariaLabel="Submission steps" />
|
|
27
|
+
<WizardProgress current={activeIdx + 1} total={steps.length} />
|
|
28
|
+
</aside>
|
|
29
|
+
<div className="flex-1 rounded-md border p-4">
|
|
30
|
+
<p className="type-text-sm text-muted-foreground">Content for step "{steps[activeIdx]?.label}"</p>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
{/* Steps only */}
|
|
36
|
+
<div>
|
|
37
|
+
<p className={SECTION_HEADER}>Steps only</p>
|
|
38
|
+
<div className="mt-4 max-w-56">
|
|
39
|
+
<WizardSteps steps={steps} activeIdx={activeIdx} onSelect={setActiveIdx} />
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
{/* Progress only — various positions */}
|
|
44
|
+
<div>
|
|
45
|
+
<p className={SECTION_HEADER}>Progress — first step</p>
|
|
46
|
+
<div className="mt-4 max-w-56">
|
|
47
|
+
<WizardProgress current={1} total={5} />
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
<div>
|
|
51
|
+
<p className={SECTION_HEADER}>Progress — mid-flow</p>
|
|
52
|
+
<div className="mt-4 max-w-56">
|
|
53
|
+
<WizardProgress current={3} total={5} />
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
<div>
|
|
57
|
+
<p className={SECTION_HEADER}>Progress — complete</p>
|
|
58
|
+
<div className="mt-4 max-w-56">
|
|
59
|
+
<WizardProgress current={5} total={5} />
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
};
|