@timeax/form-palette 0.0.3 → 0.0.5

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.
Files changed (120) hide show
  1. package/{src/schema/adapter.ts → dist/adapters.d.mts} +118 -43
  2. package/dist/adapters.d.ts +292 -0
  3. package/dist/adapters.js +13283 -0
  4. package/dist/adapters.js.map +1 -0
  5. package/dist/adapters.mjs +13269 -0
  6. package/dist/adapters.mjs.map +1 -0
  7. package/dist/index.d.mts +3744 -0
  8. package/dist/index.d.ts +3744 -0
  9. package/dist/index.js +43014 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/index.mjs +42965 -0
  12. package/dist/index.mjs.map +1 -0
  13. package/package.json +22 -7
  14. package/.scaffold-cache.json +0 -537
  15. package/src/.scaffold-cache.json +0 -544
  16. package/src/adapters/axios.ts +0 -117
  17. package/src/adapters/index.ts +0 -91
  18. package/src/adapters/inertia.ts +0 -187
  19. package/src/core/adapter-registry.ts +0 -87
  20. package/src/core/bound/bind-host.ts +0 -14
  21. package/src/core/bound/observe-bound-field.ts +0 -172
  22. package/src/core/bound/wait-for-bound-field.ts +0 -57
  23. package/src/core/context.ts +0 -23
  24. package/src/core/core-provider.tsx +0 -818
  25. package/src/core/core-root.tsx +0 -72
  26. package/src/core/core-shell.tsx +0 -44
  27. package/src/core/errors/error-strip.tsx +0 -71
  28. package/src/core/errors/index.ts +0 -2
  29. package/src/core/errors/map-error-bag.ts +0 -51
  30. package/src/core/errors/map-zod.ts +0 -39
  31. package/src/core/hooks/use-button.ts +0 -220
  32. package/src/core/hooks/use-core-context.ts +0 -20
  33. package/src/core/hooks/use-core-utility.ts +0 -0
  34. package/src/core/hooks/use-core.ts +0 -13
  35. package/src/core/hooks/use-field.ts +0 -497
  36. package/src/core/hooks/use-optional-field.ts +0 -28
  37. package/src/core/index.ts +0 -0
  38. package/src/core/registry/binder-registry.ts +0 -82
  39. package/src/core/registry/field-registry.ts +0 -187
  40. package/src/core/test.tsx +0 -17
  41. package/src/global.d.ts +0 -14
  42. package/src/index.ts +0 -68
  43. package/src/input/index.ts +0 -4
  44. package/src/input/input-field.tsx +0 -854
  45. package/src/input/input-layout-graph.ts +0 -230
  46. package/src/input/input-props.ts +0 -190
  47. package/src/lib/get-global-countries.ts +0 -87
  48. package/src/lib/utils.ts +0 -6
  49. package/src/presets/index.ts +0 -0
  50. package/src/presets/shadcn-preset.ts +0 -0
  51. package/src/presets/shadcn-variants/checkbox.tsx +0 -849
  52. package/src/presets/shadcn-variants/chips.tsx +0 -756
  53. package/src/presets/shadcn-variants/color.tsx +0 -284
  54. package/src/presets/shadcn-variants/custom.tsx +0 -227
  55. package/src/presets/shadcn-variants/date.tsx +0 -796
  56. package/src/presets/shadcn-variants/file.tsx +0 -764
  57. package/src/presets/shadcn-variants/keyvalue.tsx +0 -556
  58. package/src/presets/shadcn-variants/multiselect.tsx +0 -1132
  59. package/src/presets/shadcn-variants/number.tsx +0 -176
  60. package/src/presets/shadcn-variants/password.tsx +0 -737
  61. package/src/presets/shadcn-variants/phone.tsx +0 -628
  62. package/src/presets/shadcn-variants/radio.tsx +0 -578
  63. package/src/presets/shadcn-variants/select.tsx +0 -956
  64. package/src/presets/shadcn-variants/slider.tsx +0 -622
  65. package/src/presets/shadcn-variants/text.tsx +0 -343
  66. package/src/presets/shadcn-variants/textarea.tsx +0 -66
  67. package/src/presets/shadcn-variants/toggle.tsx +0 -218
  68. package/src/presets/shadcn-variants/treeselect.tsx +0 -784
  69. package/src/presets/ui/badge.tsx +0 -46
  70. package/src/presets/ui/button.tsx +0 -60
  71. package/src/presets/ui/calendar.tsx +0 -214
  72. package/src/presets/ui/checkbox.tsx +0 -115
  73. package/src/presets/ui/custom.tsx +0 -0
  74. package/src/presets/ui/dialog.tsx +0 -141
  75. package/src/presets/ui/field.tsx +0 -246
  76. package/src/presets/ui/input-mask.tsx +0 -739
  77. package/src/presets/ui/input-otp.tsx +0 -77
  78. package/src/presets/ui/input.tsx +0 -1011
  79. package/src/presets/ui/label.tsx +0 -22
  80. package/src/presets/ui/number.tsx +0 -1370
  81. package/src/presets/ui/popover.tsx +0 -46
  82. package/src/presets/ui/radio-group.tsx +0 -43
  83. package/src/presets/ui/scroll-area.tsx +0 -56
  84. package/src/presets/ui/select.tsx +0 -190
  85. package/src/presets/ui/separator.tsx +0 -28
  86. package/src/presets/ui/slider.tsx +0 -61
  87. package/src/presets/ui/switch.tsx +0 -32
  88. package/src/presets/ui/textarea.tsx +0 -634
  89. package/src/presets/ui/time-dropdowns.tsx +0 -350
  90. package/src/schema/core.ts +0 -429
  91. package/src/schema/field-map.ts +0 -0
  92. package/src/schema/field.ts +0 -224
  93. package/src/schema/index.ts +0 -0
  94. package/src/schema/input-field.ts +0 -260
  95. package/src/schema/presets.ts +0 -0
  96. package/src/schema/variant.ts +0 -216
  97. package/src/variants/core/checkbox.tsx +0 -54
  98. package/src/variants/core/chips.tsx +0 -22
  99. package/src/variants/core/color.tsx +0 -16
  100. package/src/variants/core/custom.tsx +0 -18
  101. package/src/variants/core/date.tsx +0 -25
  102. package/src/variants/core/file.tsx +0 -9
  103. package/src/variants/core/keyvalue.tsx +0 -12
  104. package/src/variants/core/multiselect.tsx +0 -28
  105. package/src/variants/core/number.tsx +0 -115
  106. package/src/variants/core/password.tsx +0 -35
  107. package/src/variants/core/phone.tsx +0 -16
  108. package/src/variants/core/radio.tsx +0 -38
  109. package/src/variants/core/select.tsx +0 -15
  110. package/src/variants/core/slider.tsx +0 -55
  111. package/src/variants/core/text.tsx +0 -114
  112. package/src/variants/core/textarea.tsx +0 -22
  113. package/src/variants/core/toggle.tsx +0 -50
  114. package/src/variants/core/treeselect.tsx +0 -11
  115. package/src/variants/helpers/selection-summary.tsx +0 -236
  116. package/src/variants/index.ts +0 -75
  117. package/src/variants/registry.ts +0 -38
  118. package/src/variants/select-shared.ts +0 -0
  119. package/src/variants/shared.ts +0 -126
  120. package/tsconfig.json +0 -14
@@ -1,246 +0,0 @@
1
- import { useMemo } from "react"
2
- import { cva, type VariantProps } from "class-variance-authority"
3
-
4
- import { cn } from "@/lib/utils"
5
- import { Label } from "@/presets/ui/label"
6
- import { Separator } from "@/presets/ui/separator"
7
-
8
- function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
9
- return (
10
- <fieldset
11
- data-slot="field-set"
12
- className={cn(
13
- "flex flex-col gap-6",
14
- "has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
15
- className
16
- )}
17
- {...props}
18
- />
19
- )
20
- }
21
-
22
- function FieldLegend({
23
- className,
24
- variant = "legend",
25
- ...props
26
- }: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) {
27
- return (
28
- <legend
29
- data-slot="field-legend"
30
- data-variant={variant}
31
- className={cn(
32
- "mb-3 font-medium",
33
- "data-[variant=legend]:text-base",
34
- "data-[variant=label]:text-sm",
35
- className
36
- )}
37
- {...props}
38
- />
39
- )
40
- }
41
-
42
- function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
43
- return (
44
- <div
45
- data-slot="field-group"
46
- className={cn(
47
- "group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",
48
- className
49
- )}
50
- {...props}
51
- />
52
- )
53
- }
54
-
55
- const fieldVariants = cva(
56
- "group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
57
- {
58
- variants: {
59
- orientation: {
60
- vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
61
- horizontal: [
62
- "flex-row items-center",
63
- "[&>[data-slot=field-label]]:flex-auto",
64
- "has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
65
- ],
66
- responsive: [
67
- "flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto",
68
- "@md/field-group:[&>[data-slot=field-label]]:flex-auto",
69
- "@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
70
- ],
71
- },
72
- },
73
- defaultVariants: {
74
- orientation: "vertical",
75
- },
76
- }
77
- )
78
-
79
- function Field({
80
- className,
81
- orientation = "vertical",
82
- ...props
83
- }: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {
84
- return (
85
- <div
86
- role="group"
87
- data-slot="field"
88
- data-orientation={orientation}
89
- className={cn(fieldVariants({ orientation }), className)}
90
- {...props}
91
- />
92
- )
93
- }
94
-
95
- function FieldContent({ className, ...props }: React.ComponentProps<"div">) {
96
- return (
97
- <div
98
- data-slot="field-content"
99
- className={cn(
100
- "group/field-content flex flex-1 flex-col gap-1.5 leading-snug",
101
- className
102
- )}
103
- {...props}
104
- />
105
- )
106
- }
107
-
108
- function FieldLabel({
109
- className,
110
- ...props
111
- }: React.ComponentProps<typeof Label>) {
112
- return (
113
- <Label
114
- data-slot="field-label"
115
- className={cn(
116
- "group/field-label peer/field-label flex w-fit gap-1 leading-snug group-data-[disabled=true]/field:opacity-50",
117
- "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4",
118
- "has-data-[state=checked]:bg-primary/5 has-data-[state=checked]:border-primary dark:has-data-[state=checked]:bg-primary/10",
119
- className
120
- )}
121
- {...props}
122
- />
123
- )
124
- }
125
-
126
- function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
127
- return (
128
- <div
129
- data-slot="field-label"
130
- className={cn(
131
- "flex w-fit items-center gap-1 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50",
132
- className
133
- )}
134
- {...props}
135
- />
136
- )
137
- }
138
-
139
- function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
140
- return (
141
- <p
142
- data-slot="field-description"
143
- className={cn(
144
- "text-muted-foreground text-sm leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance",
145
- "last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5",
146
- "[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",
147
- className
148
- )}
149
- {...props}
150
- />
151
- )
152
- }
153
-
154
- function FieldSeparator({
155
- children,
156
- className,
157
- ...props
158
- }: React.ComponentProps<"div"> & {
159
- children?: React.ReactNode
160
- }) {
161
- return (
162
- <div
163
- data-slot="field-separator"
164
- data-content={!!children}
165
- className={cn(
166
- "relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
167
- className
168
- )}
169
- {...props}
170
- >
171
- <Separator className="absolute inset-0 top-1/2" />
172
- {children && (
173
- <span
174
- className="bg-background text-muted-foreground relative mx-auto block w-fit px-2"
175
- data-slot="field-separator-content"
176
- >
177
- {children}
178
- </span>
179
- )}
180
- </div>
181
- )
182
- }
183
-
184
- function FieldError({
185
- className,
186
- children,
187
- errors,
188
- ...props
189
- }: React.ComponentProps<"div"> & {
190
- errors?: Array<{ message?: string } | undefined>
191
- }) {
192
- const content = useMemo(() => {
193
- if (children) {
194
- return children
195
- }
196
-
197
- if (!errors?.length) {
198
- return null
199
- }
200
-
201
- const uniqueErrors = [
202
- ...new Map(errors.map((error) => [error?.message, error])).values(),
203
- ]
204
-
205
- if (uniqueErrors?.length == 1) {
206
- return uniqueErrors[0]?.message
207
- }
208
-
209
- return (
210
- <ul className="ml-4 flex list-disc flex-col gap-1">
211
- {uniqueErrors.map(
212
- (error, index) =>
213
- error?.message && <li key={index}>{error.message}</li>
214
- )}
215
- </ul>
216
- )
217
- }, [children, errors])
218
-
219
- if (!content) {
220
- return null
221
- }
222
-
223
- return (
224
- <div
225
- role="alert"
226
- data-slot="field-error"
227
- className={cn("text-destructive text-sm font-normal", className)}
228
- {...props}
229
- >
230
- {content}
231
- </div>
232
- )
233
- }
234
-
235
- export {
236
- Field,
237
- FieldLabel,
238
- FieldDescription,
239
- FieldError,
240
- FieldGroup,
241
- FieldLegend,
242
- FieldSeparator,
243
- FieldSet,
244
- FieldContent,
245
- FieldTitle,
246
- }