omni-rest 0.3.3 → 0.4.2
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/adapters/express.d.mts +1 -1
- package/dist/adapters/express.d.ts +1 -1
- package/dist/adapters/express.js +51 -9
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +51 -9
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/fastify.d.mts +1 -1
- package/dist/adapters/fastify.d.ts +1 -1
- package/dist/adapters/fastify.js +51 -9
- package/dist/adapters/fastify.js.map +1 -1
- package/dist/adapters/fastify.mjs +51 -9
- package/dist/adapters/fastify.mjs.map +1 -1
- package/dist/adapters/nextjs.d.mts +1 -1
- package/dist/adapters/nextjs.d.ts +1 -1
- package/dist/adapters/nextjs.js +51 -9
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +51 -9
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/cli.js +75 -2
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +75 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +22 -5
- package/dist/index.d.ts +22 -5
- package/dist/index.js +114 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +114 -10
- package/dist/index.mjs.map +1 -1
- package/dist/{types-jvppYvku.d.mts → types-Dhk8VaWX.d.mts} +12 -0
- package/dist/{types-jvppYvku.d.ts → types-Dhk8VaWX.d.ts} +12 -0
- package/frontend-next/form-generator.tsx +52 -59
- package/package.json +1 -1
|
@@ -62,18 +62,18 @@ import { Label, LabelRequired, LabelOptional } from "@/components/ui/label";
|
|
|
62
62
|
|
|
63
63
|
// ── Icons ─────────────────────────────────────────────────────
|
|
64
64
|
import {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
} from "
|
|
65
|
+
Calendar as CalendarIcon,
|
|
66
|
+
Check,
|
|
67
|
+
ChevronsUpDown,
|
|
68
|
+
Loader2,
|
|
69
|
+
X,
|
|
70
|
+
Eye,
|
|
71
|
+
EyeOff,
|
|
72
|
+
ChevronRight,
|
|
73
|
+
ChevronLeft,
|
|
74
|
+
CheckCheck,
|
|
75
|
+
Circle,
|
|
76
|
+
} from "lucide-react";
|
|
77
77
|
|
|
78
78
|
// ═══════════════════════════════════════════════════════════════
|
|
79
79
|
// TYPES
|
|
@@ -259,7 +259,7 @@ function PasswordInput<T extends FieldValues>({ field, config, disabled }: { fie
|
|
|
259
259
|
<Button type="button" variant="ghost" size="icon" tabIndex={-1}
|
|
260
260
|
className="absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7 text-muted-foreground hover:text-foreground"
|
|
261
261
|
onClick={() => setShow(s => !s)}>
|
|
262
|
-
{show ? <
|
|
262
|
+
{show ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
|
|
263
263
|
</Button>
|
|
264
264
|
)}
|
|
265
265
|
</div>
|
|
@@ -287,15 +287,13 @@ function SearchableSelect<T extends FieldValues>({ field, config, disabled }: {
|
|
|
287
287
|
const selected = config.options.find(o => o.value === field.value);
|
|
288
288
|
return (
|
|
289
289
|
<Popover open={open} onOpenChange={setOpen}>
|
|
290
|
-
<PopoverTrigger
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
{selected?.label ?? config.placeholder ?? "Select option…"}
|
|
298
|
-
<RiArrowUpDownLine className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
|
290
|
+
<PopoverTrigger asChild>
|
|
291
|
+
<Button variant="outline" role="combobox" aria-expanded={open}
|
|
292
|
+
disabled={disabled || config.disabled}
|
|
293
|
+
className={cn("w-full justify-between font-normal", !field.value && "text-muted-foreground", config.className)}>
|
|
294
|
+
{selected?.label ?? config.placeholder ?? "Select option…"}
|
|
295
|
+
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
|
296
|
+
</Button>
|
|
299
297
|
</PopoverTrigger>
|
|
300
298
|
<PopoverContent className="w-[--radix-popover-trigger-width] p-0">
|
|
301
299
|
<Command>
|
|
@@ -306,7 +304,7 @@ function SearchableSelect<T extends FieldValues>({ field, config, disabled }: {
|
|
|
306
304
|
{config.options.map(opt => (
|
|
307
305
|
<CommandItem key={opt.value} value={opt.value} disabled={opt.disabled}
|
|
308
306
|
onSelect={val => { field.onChange(val === field.value ? "" : val); setOpen(false); }}>
|
|
309
|
-
<
|
|
307
|
+
<Check className={cn("mr-2 h-4 w-4", field.value === opt.value ? "opacity-100" : "opacity-0")} />
|
|
310
308
|
{opt.label}
|
|
311
309
|
{opt.badge && <Badge variant="secondary" className="ml-auto text-xs">{opt.badge}</Badge>}
|
|
312
310
|
</CommandItem>
|
|
@@ -339,21 +337,19 @@ function MultiSelect<T extends FieldValues>({ field, config, disabled }: { field
|
|
|
339
337
|
{config.options.find(o => o.value === val)?.label ?? val}
|
|
340
338
|
<button type="button" onClick={() => toggle(val)} disabled={disabled || config.disabled}
|
|
341
339
|
className="rounded-sm opacity-70 hover:opacity-100">
|
|
342
|
-
<
|
|
340
|
+
<X className="h-3 w-3" />
|
|
343
341
|
</button>
|
|
344
342
|
</Badge>
|
|
345
343
|
))}
|
|
346
344
|
</div>
|
|
347
345
|
)}
|
|
348
346
|
<Popover open={open} onOpenChange={setOpen}>
|
|
349
|
-
<PopoverTrigger
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
{selected.length === 0 ? config.placeholder ?? "Select options…" : `${selected.length} selected`}
|
|
356
|
-
<RiArrowUpDownLine className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
|
347
|
+
<PopoverTrigger asChild>
|
|
348
|
+
<Button variant="outline" role="combobox" disabled={disabled || config.disabled}
|
|
349
|
+
className={cn("w-full justify-between font-normal", selected.length === 0 && "text-muted-foreground")}>
|
|
350
|
+
{selected.length === 0 ? config.placeholder ?? "Select options…" : `${selected.length} selected`}
|
|
351
|
+
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
|
352
|
+
</Button>
|
|
357
353
|
</PopoverTrigger>
|
|
358
354
|
<PopoverContent className="w-[--radix-popover-trigger-width] p-0">
|
|
359
355
|
<Command>
|
|
@@ -367,7 +363,7 @@ function MultiSelect<T extends FieldValues>({ field, config, disabled }: { field
|
|
|
367
363
|
return (
|
|
368
364
|
<CommandItem key={opt.value} value={opt.value}
|
|
369
365
|
disabled={opt.disabled || maxed} onSelect={() => toggle(opt.value)}>
|
|
370
|
-
<
|
|
366
|
+
<Check className={cn("mr-2 h-4 w-4", isSel ? "opacity-100" : "opacity-0")} />
|
|
371
367
|
{opt.label}
|
|
372
368
|
{opt.badge && <Badge variant="secondary" className="ml-auto text-xs">{opt.badge}</Badge>}
|
|
373
369
|
</CommandItem>
|
|
@@ -387,14 +383,12 @@ function MultiSelect<T extends FieldValues>({ field, config, disabled }: { field
|
|
|
387
383
|
function DatePicker<T extends FieldValues>({ field, config, disabled }: { field: ControllerRenderProps<T, Path<T>>; config: DateField<T>; disabled?: boolean }) {
|
|
388
384
|
return (
|
|
389
385
|
<Popover>
|
|
390
|
-
<PopoverTrigger
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
<RiCalendarLine className="mr-2 h-4 w-4" />
|
|
397
|
-
{field.value ? format(field.value, config.dateFormat ?? "PPP") : config.placeholder ?? "Pick a date"}
|
|
386
|
+
<PopoverTrigger asChild>
|
|
387
|
+
<Button variant="outline" disabled={disabled || config.disabled}
|
|
388
|
+
className={cn("w-full justify-start text-left font-normal", !field.value && "text-muted-foreground", config.className)}>
|
|
389
|
+
<CalendarIcon className="mr-2 h-4 w-4" />
|
|
390
|
+
{field.value ? format(field.value, config.dateFormat ?? "PPP") : config.placeholder ?? "Pick a date"}
|
|
391
|
+
</Button>
|
|
398
392
|
</PopoverTrigger>
|
|
399
393
|
<PopoverContent className="w-auto p-0" align="start">
|
|
400
394
|
<Calendar mode="single" selected={field.value} onSelect={field.onChange}
|
|
@@ -410,16 +404,15 @@ function DateRangePicker<T extends FieldValues>({ field, config, disabled }: { f
|
|
|
410
404
|
const range: DateRange = field.value ?? {};
|
|
411
405
|
return (
|
|
412
406
|
<Popover>
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
: config.placeholder ?? "Pick a date range"}
|
|
407
|
+
<Popover>
|
|
408
|
+
<PopoverTrigger asChild>
|
|
409
|
+
<Button variant="outline" disabled={disabled || config.disabled}
|
|
410
|
+
className={cn("w-full justify-start text-left font-normal", !range.from && "text-muted-foreground", config.className)}>
|
|
411
|
+
<CalendarIcon className="mr-2 h-4 w-4" />
|
|
412
|
+
{range.from
|
|
413
|
+
? range.to ? <>{format(range.from, fmt)} – {format(range.to, fmt)}</> : format(range.from, fmt)
|
|
414
|
+
: config.placeholder ?? "Pick a date range"}
|
|
415
|
+
</Button>
|
|
423
416
|
</PopoverTrigger>
|
|
424
417
|
<PopoverContent className="w-auto p-0" align="start">
|
|
425
418
|
<Calendar mode="range" selected={range as any} onSelect={field.onChange}
|
|
@@ -695,7 +688,7 @@ function ProgressIndicator<T extends FieldValues>({
|
|
|
695
688
|
done && "border-primary bg-primary/10 text-primary",
|
|
696
689
|
!active && !done && "border-muted-foreground/30 bg-background text-muted-foreground"
|
|
697
690
|
)}>
|
|
698
|
-
{done ? <
|
|
691
|
+
{done ? <Check className="h-3.5 w-3.5" /> : i + 1}
|
|
699
692
|
</div>
|
|
700
693
|
<span className={cn(
|
|
701
694
|
"text-[11px] font-medium hidden sm:block text-center leading-tight max-w-[72px]",
|
|
@@ -730,10 +723,10 @@ function TabsIndicator<T extends FieldValues>({
|
|
|
730
723
|
active ? "bg-background shadow-sm text-foreground" : "text-muted-foreground"
|
|
731
724
|
)}>
|
|
732
725
|
{done
|
|
733
|
-
? <
|
|
726
|
+
? <Check className="h-3.5 w-3.5 text-primary flex-shrink-0" />
|
|
734
727
|
: step.icon
|
|
735
728
|
? <span className="h-3.5 w-3.5 flex-shrink-0">{step.icon}</span>
|
|
736
|
-
: <
|
|
729
|
+
: <Circle className={cn("h-3.5 w-3.5 flex-shrink-0", active && "text-primary")} />
|
|
737
730
|
}
|
|
738
731
|
{step.title}
|
|
739
732
|
</div>
|
|
@@ -763,7 +756,7 @@ function SidebarIndicator<T extends FieldValues>({
|
|
|
763
756
|
done && "bg-primary/15 text-primary",
|
|
764
757
|
!active && !done && "bg-muted text-muted-foreground"
|
|
765
758
|
)}>
|
|
766
|
-
{done ? <
|
|
759
|
+
{done ? <Check className="h-3.5 w-3.5" /> : i + 1}
|
|
767
760
|
</div>
|
|
768
761
|
<div>
|
|
769
762
|
<p className={cn("text-sm font-medium", active ? "text-foreground" : "text-muted-foreground")}>
|
|
@@ -872,12 +865,12 @@ function MultiStepForm<T extends FieldValues>(props: {
|
|
|
872
865
|
<div className="mt-6 pt-4 border-t flex items-center justify-between">
|
|
873
866
|
<Button type="button" variant="outline" onClick={() => goTo(currentStep - 1)}
|
|
874
867
|
disabled={isFirst || isLoading}>
|
|
875
|
-
<
|
|
868
|
+
<ChevronLeft className="mr-1.5 h-4 w-4" />{prevLabel}
|
|
876
869
|
</Button>
|
|
877
870
|
|
|
878
871
|
{!isLast ? (
|
|
879
872
|
<Button type="button" onClick={handleNext} disabled={isLoading}>
|
|
880
|
-
{nextLabel}<
|
|
873
|
+
{nextLabel}<ChevronRight className="ml-1.5 h-4 w-4" />
|
|
881
874
|
</Button>
|
|
882
875
|
) : (
|
|
883
876
|
footer ?? (
|
|
@@ -956,7 +949,7 @@ export function FormGenerator<T extends FieldValues = FieldValues>({
|
|
|
956
949
|
{footer ?? (
|
|
957
950
|
<div className="flex items-center gap-3">
|
|
958
951
|
<Button type="submit" disabled={disabled || isLoading}>
|
|
959
|
-
{isLoading && <
|
|
952
|
+
{isLoading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
|
960
953
|
{submitLabel}
|
|
961
954
|
</Button>
|
|
962
955
|
{showReset && (
|
|
@@ -1059,4 +1052,4 @@ export function FormGenerator<T extends FieldValues = FieldValues>({
|
|
|
1059
1052
|
// onSubmit={console.log}
|
|
1060
1053
|
// submitLabel="Create Account"
|
|
1061
1054
|
// nextLabel="Continue →" prevLabel="← Back"
|
|
1062
|
-
// />
|
|
1055
|
+
// />
|