azamat-ui-kit-cli 0.2.2 → 0.3.4
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/README.md +11 -0
- package/dist/index.cjs +452 -0
- package/package.json +2 -2
- package/vendor/src/components/actions/action-menu.tsx +21 -18
- package/vendor/src/components/calendar/calendar.tsx +153 -102
- package/vendor/src/components/calendar/date-picker.tsx +24 -14
- package/vendor/src/components/calendar/date-range-picker.tsx +137 -58
- package/vendor/src/components/charts/charts.tsx +32 -21
- package/vendor/src/components/command/command-palette.tsx +68 -57
- package/vendor/src/components/data-table/data-table-bulk-actions.tsx +23 -20
- package/vendor/src/components/data-table/data-table-column-visibility-menu.tsx +21 -10
- package/vendor/src/components/data-table/data-table-pagination.tsx +6 -6
- package/vendor/src/components/data-table/data-table-toolbar.tsx +72 -44
- package/vendor/src/components/data-table/data-table.tsx +15 -11
- package/vendor/src/components/data-table/table-export-menu.tsx +1 -1
- package/vendor/src/components/data-table/table-import-button.tsx +1 -1
- package/vendor/src/components/display/data-state.tsx +20 -8
- package/vendor/src/components/display/index.ts +19 -15
- package/vendor/src/components/display/metric-card.tsx +35 -0
- package/vendor/src/components/display/progress-circle.tsx +24 -0
- package/vendor/src/components/display/smart-card.tsx +49 -27
- package/vendor/src/components/display/status-dot.tsx +45 -0
- package/vendor/src/components/display/user-card.tsx +30 -0
- package/vendor/src/components/feedback/alert.tsx +21 -11
- package/vendor/src/components/feedback/empty-state.tsx +2 -2
- package/vendor/src/components/feedback/loading-state.tsx +2 -2
- package/vendor/src/components/feedback/page-state.tsx +19 -15
- package/vendor/src/components/feedback/status-badge.tsx +43 -43
- package/vendor/src/components/form/form-app-input.tsx +147 -0
- package/vendor/src/components/form/form-date-input.tsx +16 -19
- package/vendor/src/components/form/form-field-shell.tsx +11 -8
- package/vendor/src/components/form/form-field-utils.ts +76 -0
- package/vendor/src/components/form/form-input.tsx +423 -44
- package/vendor/src/components/form/form-number-input.tsx +16 -15
- package/vendor/src/components/form/form-phone-input.tsx +15 -9
- package/vendor/src/components/form/form-search-input.tsx +16 -19
- package/vendor/src/components/form/form-select.tsx +4 -3
- package/vendor/src/components/form/public.ts +16 -14
- package/vendor/src/components/form/smart-form-shell.tsx +13 -12
- package/vendor/src/components/inputs/app-input.tsx +27 -0
- package/vendor/src/components/inputs/async-select.tsx +113 -84
- package/vendor/src/components/inputs/clearable-input.tsx +81 -61
- package/vendor/src/components/inputs/date-input.tsx +21 -17
- package/vendor/src/components/inputs/date-range-input.tsx +10 -10
- package/vendor/src/components/inputs/index.ts +1 -0
- package/vendor/src/components/inputs/input-decorator.tsx +101 -57
- package/vendor/src/components/inputs/masked-input.tsx +20 -20
- package/vendor/src/components/inputs/money-input.tsx +2 -2
- package/vendor/src/components/inputs/number-input.tsx +29 -19
- package/vendor/src/components/inputs/password-input.tsx +82 -45
- package/vendor/src/components/inputs/phone-input.tsx +24 -2
- package/vendor/src/components/inputs/quantity-input.tsx +2 -2
- package/vendor/src/components/inputs/search-input.tsx +54 -3
- package/vendor/src/components/inputs/simple-select.tsx +110 -22
- package/vendor/src/components/layout/app-shell.tsx +2 -2
- package/vendor/src/components/layout/index.ts +5 -4
- package/vendor/src/components/layout/page-header.tsx +79 -35
- package/vendor/src/components/layout/public.ts +12 -10
- package/vendor/src/components/layout/section-header.tsx +56 -0
- package/vendor/src/components/layout/stack.tsx +106 -0
- package/vendor/src/components/layout/stat-card.tsx +66 -29
- package/vendor/src/components/navigation/index.ts +1 -0
- package/vendor/src/components/navigation/nav-tabs.tsx +60 -0
- package/vendor/src/components/navigation/page-tabs.tsx +41 -26
- package/vendor/src/components/navigation/pagination.tsx +14 -10
- package/vendor/src/components/overlay/alert-dialog.tsx +65 -0
- package/vendor/src/components/overlay/drawer.tsx +71 -0
- package/vendor/src/components/overlay/index.ts +4 -2
- package/vendor/src/components/patterns/data-view.tsx +13 -8
- package/vendor/src/components/ui/badge.tsx +96 -52
- package/vendor/src/components/ui/button.tsx +99 -61
- package/vendor/src/components/ui/card.tsx +84 -25
- package/vendor/src/components/ui/checkbox.tsx +68 -68
- package/vendor/src/components/ui/command.tsx +32 -32
- package/vendor/src/components/ui/dialog.tsx +135 -138
- package/vendor/src/components/ui/dropdown-menu.tsx +21 -21
- package/vendor/src/components/ui/hover-card.tsx +49 -0
- package/vendor/src/components/ui/input-primitive.tsx +24 -0
- package/vendor/src/components/ui/input.tsx +191 -20
- package/vendor/src/components/ui/kbd.tsx +33 -0
- package/vendor/src/components/ui/popover.tsx +11 -11
- package/vendor/src/components/ui/radio-group.tsx +102 -0
- package/vendor/src/components/ui/right-click-menu.tsx +60 -0
- package/vendor/src/components/ui/scroll-box.tsx +27 -0
- package/vendor/src/components/ui/segmented-control.tsx +21 -17
- package/vendor/src/components/ui/select.tsx +187 -189
- package/vendor/src/components/ui/skeleton.tsx +2 -2
- package/vendor/src/components/ui/switch.tsx +60 -60
- package/vendor/src/components/ui/table.tsx +114 -114
- package/vendor/src/components/ui/tabs.tsx +2 -2
- package/vendor/src/components/ui/textarea.tsx +1 -1
- package/vendor/src/components/upload/file-dropzone.tsx +38 -0
- package/vendor/src/components/upload/file-upload.tsx +4 -4
- package/vendor/src/components/upload/image-upload.tsx +22 -19
- package/vendor/src/components/upload/index.ts +2 -0
- package/vendor/src/families/catalog.ts +1 -0
- package/vendor/src/families/docs-groups.ts +10 -1
- package/vendor/src/families/member-metadata.ts +24 -0
- package/vendor/src/families/member-snippets.ts +41 -2
- package/vendor/src/families/migration-map.ts +3 -0
- package/vendor/src/index.ts +23 -18
- package/vendor/templates/styles/globals.css +253 -0
- package/dist/index.js +0 -432
|
@@ -2,23 +2,54 @@
|
|
|
2
2
|
import * as React from "react"
|
|
3
3
|
import { Controller, type Control, type FieldPath, type FieldValues } from "react-hook-form"
|
|
4
4
|
|
|
5
|
+
import {
|
|
6
|
+
DateRangeInput,
|
|
7
|
+
type DateRangeInputProps,
|
|
8
|
+
type DateRangeValue,
|
|
9
|
+
} from "@/components/inputs/date-range-input"
|
|
5
10
|
import { DateInput, type DateInputProps } from "@/components/inputs/date-input"
|
|
11
|
+
import { Input, type InputTextProps } from "@/components/ui/input"
|
|
12
|
+
import { MaskedInput, type MaskedInputProps } from "@/components/inputs/masked-input"
|
|
13
|
+
import { MoneyInput, type MoneyInputProps } from "@/components/inputs/money-input"
|
|
6
14
|
import { NumberInput, type NumberInputProps } from "@/components/inputs/number-input"
|
|
7
15
|
import {
|
|
8
16
|
PhoneInput,
|
|
9
17
|
formatPhoneDigits,
|
|
10
18
|
type PhoneInputProps,
|
|
11
19
|
} from "@/components/inputs/phone-input"
|
|
12
|
-
import {
|
|
20
|
+
import { QuantityInput, type QuantityInputProps } from "@/components/inputs/quantity-input"
|
|
13
21
|
import { SearchInput, type SearchInputProps } from "@/components/inputs/search-input"
|
|
22
|
+
import {
|
|
23
|
+
ClearableInput,
|
|
24
|
+
type ClearableInputProps,
|
|
25
|
+
} from "@/components/inputs/clearable-input"
|
|
14
26
|
import {
|
|
15
27
|
FormFieldShell,
|
|
16
28
|
type FormFieldShellControlProps,
|
|
17
29
|
} from "@/components/form/form-field-shell"
|
|
18
|
-
import { Input } from "@/components/ui/input"
|
|
19
30
|
|
|
20
|
-
export type FormInputKind =
|
|
21
|
-
|
|
31
|
+
export type FormInputKind =
|
|
32
|
+
| "text"
|
|
33
|
+
| "search"
|
|
34
|
+
| "password"
|
|
35
|
+
| "number"
|
|
36
|
+
| "phone"
|
|
37
|
+
| "date"
|
|
38
|
+
| "date-range"
|
|
39
|
+
| "clearable"
|
|
40
|
+
| "masked"
|
|
41
|
+
| "money"
|
|
42
|
+
| "quantity"
|
|
43
|
+
|
|
44
|
+
export type FormInputPhoneInputValueMode = "raw" | "masked"
|
|
45
|
+
type TextInputElementChangeEvent = React.ChangeEvent<HTMLInputElement>
|
|
46
|
+
|
|
47
|
+
type FormTextInputControlProps = Omit<
|
|
48
|
+
React.ComponentProps<"input">,
|
|
49
|
+
"name" | "value" | "defaultValue"
|
|
50
|
+
> & {
|
|
51
|
+
onChange?: (event: TextInputElementChangeEvent) => void
|
|
52
|
+
}
|
|
22
53
|
|
|
23
54
|
type FormControlledFieldProps<
|
|
24
55
|
TFieldValues extends FieldValues,
|
|
@@ -33,11 +64,11 @@ type FormControlledFieldProps<
|
|
|
33
64
|
export type FormTextInputProps<
|
|
34
65
|
TFieldValues extends FieldValues = FieldValues,
|
|
35
66
|
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
36
|
-
> = Omit<
|
|
67
|
+
> = Omit<FormTextInputControlProps, "inputMode" | "autoComplete" | "autoCorrect" | "autoCapitalize" | "className" | "size"> &
|
|
37
68
|
FormControlledFieldProps<TFieldValues, TName> & {
|
|
38
69
|
kind?: "text"
|
|
39
70
|
transformIn?: (value: unknown) => string | number | readonly string[] | undefined
|
|
40
|
-
transformOut?: (event:
|
|
71
|
+
transformOut?: (event: TextInputElementChangeEvent) => unknown
|
|
41
72
|
}
|
|
42
73
|
|
|
43
74
|
export type FormInputSearchVariantProps<
|
|
@@ -52,11 +83,12 @@ export type FormInputSearchVariantProps<
|
|
|
52
83
|
export type FormInputPasswordVariantProps<
|
|
53
84
|
TFieldValues extends FieldValues = FieldValues,
|
|
54
85
|
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
55
|
-
> = Omit<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
86
|
+
> = Omit<React.ComponentProps<"input">, "name" | "value" | "defaultValue"> & {
|
|
87
|
+
kind: "password"
|
|
88
|
+
onValueChange?: (value: string) => void
|
|
89
|
+
min?: never
|
|
90
|
+
max?: never
|
|
91
|
+
} & FormControlledFieldProps<TFieldValues, TName>
|
|
60
92
|
|
|
61
93
|
export type FormInputNumberVariantProps<
|
|
62
94
|
TFieldValues extends FieldValues = FieldValues,
|
|
@@ -74,7 +106,7 @@ export type FormInputPhoneVariantProps<
|
|
|
74
106
|
> = Omit<PhoneInputProps, "name" | "value" | "defaultValue" | "onValueChange"> &
|
|
75
107
|
FormControlledFieldProps<TFieldValues, TName> & {
|
|
76
108
|
kind: "phone"
|
|
77
|
-
valueMode?:
|
|
109
|
+
valueMode?: FormInputPhoneInputValueMode
|
|
78
110
|
onValueChange?: (value: string, rawValue: string, maskedValue: string) => void
|
|
79
111
|
}
|
|
80
112
|
|
|
@@ -88,6 +120,55 @@ export type FormInputDateVariantProps<
|
|
|
88
120
|
onValueChange?: (value: string) => void
|
|
89
121
|
}
|
|
90
122
|
|
|
123
|
+
export type FormInputDateRangeVariantProps<
|
|
124
|
+
TFieldValues extends FieldValues = FieldValues,
|
|
125
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
126
|
+
> = Omit<DateRangeInputProps, "name" | "value" | "onValueChange"> &
|
|
127
|
+
FormControlledFieldProps<TFieldValues, TName> & {
|
|
128
|
+
kind: "date-range"
|
|
129
|
+
onValueChange?: (value: DateRangeValue) => void
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export type FormInputClearableVariantProps<
|
|
133
|
+
TFieldValues extends FieldValues = FieldValues,
|
|
134
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
135
|
+
> = Omit<ClearableInputProps, "name" | "value" | "defaultValue" | "onValueChange"> &
|
|
136
|
+
FormControlledFieldProps<TFieldValues, TName> & {
|
|
137
|
+
kind: "clearable"
|
|
138
|
+
emptyValue?: unknown
|
|
139
|
+
onValueChange?: (value: string) => void
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export type FormInputMaskedVariantProps<
|
|
143
|
+
TFieldValues extends FieldValues = FieldValues,
|
|
144
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
145
|
+
> = Omit<MaskedInputProps, "name" | "value" | "defaultValue" | "onValueChange"> &
|
|
146
|
+
FormControlledFieldProps<TFieldValues, TName> & {
|
|
147
|
+
kind: "masked"
|
|
148
|
+
valueMode?: "masked" | "raw"
|
|
149
|
+
onValueChange?: (maskedValue: string, rawValue: string) => void
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export type FormInputMoneyVariantProps<
|
|
153
|
+
TFieldValues extends FieldValues = FieldValues,
|
|
154
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
155
|
+
> = Omit<MoneyInputProps, "name" | "value" | "defaultValue" | "onValueChange"> &
|
|
156
|
+
FormControlledFieldProps<TFieldValues, TName> & {
|
|
157
|
+
kind: "money"
|
|
158
|
+
emptyValue?: unknown
|
|
159
|
+
onValueChange?: (value: number | null, rawValue: string) => void
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export type FormInputQuantityVariantProps<
|
|
163
|
+
TFieldValues extends FieldValues = FieldValues,
|
|
164
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
165
|
+
> = Omit<QuantityInputProps, "name" | "value" | "defaultValue" | "onValueChange"> &
|
|
166
|
+
FormControlledFieldProps<TFieldValues, TName> & {
|
|
167
|
+
kind: "quantity"
|
|
168
|
+
emptyValue?: unknown
|
|
169
|
+
onValueChange?: (value: number | null) => void
|
|
170
|
+
}
|
|
171
|
+
|
|
91
172
|
export type FormInputProps<
|
|
92
173
|
TFieldValues extends FieldValues = FieldValues,
|
|
93
174
|
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
@@ -98,7 +179,15 @@ export type FormInputProps<
|
|
|
98
179
|
| FormInputNumberVariantProps<TFieldValues, TName>
|
|
99
180
|
| FormInputPhoneVariantProps<TFieldValues, TName>
|
|
100
181
|
| FormInputDateVariantProps<TFieldValues, TName>
|
|
182
|
+
| FormInputDateRangeVariantProps<TFieldValues, TName>
|
|
183
|
+
| FormInputClearableVariantProps<TFieldValues, TName>
|
|
184
|
+
| FormInputMaskedVariantProps<TFieldValues, TName>
|
|
185
|
+
| FormInputMoneyVariantProps<TFieldValues, TName>
|
|
186
|
+
| FormInputQuantityVariantProps<TFieldValues, TName>
|
|
187
|
+
|
|
188
|
+
type FormPasswordInputElement = React.ChangeEvent<HTMLInputElement>
|
|
101
189
|
|
|
190
|
+
type InputTextInputProps = Omit<InputTextProps, "kind">
|
|
102
191
|
function buildShellProps<
|
|
103
192
|
TFieldValues extends FieldValues,
|
|
104
193
|
TName extends FieldPath<TFieldValues>,
|
|
@@ -131,6 +220,7 @@ function FormInput<
|
|
|
131
220
|
const inputId = props.id ?? props.name
|
|
132
221
|
const shellProps = buildShellProps(props)
|
|
133
222
|
const kind = props.kind ?? "text"
|
|
223
|
+
const resolvedFieldClassName = props.fieldClassName ?? "w-full"
|
|
134
224
|
|
|
135
225
|
return (
|
|
136
226
|
<Controller
|
|
@@ -177,13 +267,13 @@ function FormInput<
|
|
|
177
267
|
ref={field.ref}
|
|
178
268
|
value={field.value ?? ""}
|
|
179
269
|
disabled={disabled}
|
|
180
|
-
inputClassName={fieldClassName}
|
|
270
|
+
inputClassName={fieldClassName ?? resolvedFieldClassName}
|
|
181
271
|
aria-invalid={fieldState.invalid || undefined}
|
|
182
|
-
onBlur={(event) => {
|
|
272
|
+
onBlur={(event: React.FocusEvent<HTMLInputElement>) => {
|
|
183
273
|
field.onBlur()
|
|
184
274
|
onBlur?.(event)
|
|
185
275
|
}}
|
|
186
|
-
onValueChange={(value) => {
|
|
276
|
+
onValueChange={(value: string) => {
|
|
187
277
|
field.onChange(value)
|
|
188
278
|
onValueChange?.(value)
|
|
189
279
|
}}
|
|
@@ -215,31 +305,33 @@ function FormInput<
|
|
|
215
305
|
contentClassName: _contentClassName,
|
|
216
306
|
fieldClassName,
|
|
217
307
|
id,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
308
|
+
kind: _kind,
|
|
309
|
+
onValueChange,
|
|
310
|
+
onBlur,
|
|
311
|
+
...passwordProps
|
|
312
|
+
} = props as FormInputPasswordVariantProps<TFieldValues, TName>
|
|
223
313
|
|
|
224
314
|
return (
|
|
225
315
|
<FormFieldShell {...shellProps} error={error} htmlFor={id ?? inputId}>
|
|
226
|
-
<
|
|
227
|
-
{...passwordProps}
|
|
316
|
+
<Input
|
|
317
|
+
{...(passwordProps as Omit<InputTextInputProps, "kind">)}
|
|
318
|
+
type="password"
|
|
228
319
|
id={id ?? inputId}
|
|
229
|
-
name={field.name}
|
|
230
320
|
ref={field.ref}
|
|
321
|
+
name={field.name}
|
|
231
322
|
value={field.value ?? ""}
|
|
232
323
|
disabled={disabled}
|
|
233
|
-
inputClassName={fieldClassName}
|
|
234
|
-
|
|
235
|
-
onBlur={(event) => {
|
|
324
|
+
inputClassName={fieldClassName ?? resolvedFieldClassName}
|
|
325
|
+
onBlur={(event: React.FocusEvent<HTMLInputElement>) => {
|
|
236
326
|
field.onBlur()
|
|
237
327
|
onBlur?.(event)
|
|
238
328
|
}}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
329
|
+
onChange={(event: FormPasswordInputElement) => {
|
|
330
|
+
const nextValue = event.currentTarget.value
|
|
331
|
+
field.onChange(nextValue)
|
|
332
|
+
onValueChange?.(nextValue)
|
|
242
333
|
}}
|
|
334
|
+
aria-invalid={fieldState.invalid || undefined}
|
|
243
335
|
/>
|
|
244
336
|
</FormFieldShell>
|
|
245
337
|
)
|
|
@@ -285,13 +377,13 @@ function FormInput<
|
|
|
285
377
|
value={field.value ?? ""}
|
|
286
378
|
disabled={disabled}
|
|
287
379
|
readOnly={props.readOnly}
|
|
288
|
-
className={fieldClassName}
|
|
380
|
+
className={fieldClassName ?? resolvedFieldClassName}
|
|
289
381
|
aria-invalid={fieldState.invalid || undefined}
|
|
290
|
-
onBlur={(event) => {
|
|
382
|
+
onBlur={(event: React.FocusEvent<HTMLInputElement>) => {
|
|
291
383
|
field.onBlur()
|
|
292
384
|
onBlur?.(event)
|
|
293
385
|
}}
|
|
294
|
-
onNumberChange={(value) => {
|
|
386
|
+
onNumberChange={(value: number | null) => {
|
|
295
387
|
field.onChange(value ?? emptyValue)
|
|
296
388
|
onNumberChange?.(value)
|
|
297
389
|
}}
|
|
@@ -348,13 +440,13 @@ function FormInput<
|
|
|
348
440
|
readOnly={props.readOnly}
|
|
349
441
|
countryCode={countryCode}
|
|
350
442
|
maxDigits={maxDigits}
|
|
351
|
-
className={fieldClassName}
|
|
443
|
+
className={fieldClassName ?? resolvedFieldClassName}
|
|
352
444
|
aria-invalid={fieldState.invalid || undefined}
|
|
353
|
-
onBlur={(event) => {
|
|
445
|
+
onBlur={(event: React.FocusEvent<HTMLInputElement>) => {
|
|
354
446
|
field.onBlur()
|
|
355
447
|
onBlur?.(event)
|
|
356
448
|
}}
|
|
357
|
-
onValueChange={(maskedValue, rawValue) => {
|
|
449
|
+
onValueChange={(maskedValue: string, rawValue: string) => {
|
|
358
450
|
const nextValue = valueMode === "raw" ? rawValue : maskedValue
|
|
359
451
|
field.onChange(nextValue)
|
|
360
452
|
onValueChange?.(nextValue, rawValue, maskedValue)
|
|
@@ -404,13 +496,13 @@ function FormInput<
|
|
|
404
496
|
value={field.value ?? ""}
|
|
405
497
|
disabled={disabled}
|
|
406
498
|
readOnly={props.readOnly}
|
|
407
|
-
className={fieldClassName}
|
|
499
|
+
className={fieldClassName ?? resolvedFieldClassName}
|
|
408
500
|
aria-invalid={fieldState.invalid || undefined}
|
|
409
|
-
onBlur={(event) => {
|
|
501
|
+
onBlur={(event: React.FocusEvent<HTMLInputElement>) => {
|
|
410
502
|
field.onBlur()
|
|
411
503
|
onBlur?.(event)
|
|
412
504
|
}}
|
|
413
|
-
onValueChange={(value) => {
|
|
505
|
+
onValueChange={(value: string) => {
|
|
414
506
|
field.onChange(value || emptyValue)
|
|
415
507
|
onValueChange?.(value)
|
|
416
508
|
}}
|
|
@@ -419,6 +511,290 @@ function FormInput<
|
|
|
419
511
|
)
|
|
420
512
|
}
|
|
421
513
|
|
|
514
|
+
if (kind === "clearable") {
|
|
515
|
+
const {
|
|
516
|
+
control: _control,
|
|
517
|
+
name: _name,
|
|
518
|
+
label: _label,
|
|
519
|
+
description: _description,
|
|
520
|
+
required: _required,
|
|
521
|
+
className: _className,
|
|
522
|
+
layout: _layout,
|
|
523
|
+
descriptionPosition: _descriptionPosition,
|
|
524
|
+
labelAction: _labelAction,
|
|
525
|
+
requiredIndicator: _requiredIndicator,
|
|
526
|
+
errorIcon: _errorIcon,
|
|
527
|
+
showErrorIcon: _showErrorIcon,
|
|
528
|
+
disabled,
|
|
529
|
+
readOnly: _readOnly,
|
|
530
|
+
labelClassName: _labelClassName,
|
|
531
|
+
labelRowClassName: _labelRowClassName,
|
|
532
|
+
descriptionClassName: _descriptionClassName,
|
|
533
|
+
errorClassName: _errorClassName,
|
|
534
|
+
contentClassName: _contentClassName,
|
|
535
|
+
fieldClassName,
|
|
536
|
+
id,
|
|
537
|
+
kind: _kind,
|
|
538
|
+
emptyValue = "",
|
|
539
|
+
onValueChange,
|
|
540
|
+
onBlur,
|
|
541
|
+
...clearableProps
|
|
542
|
+
} = props as FormInputClearableVariantProps<TFieldValues, TName>
|
|
543
|
+
|
|
544
|
+
return (
|
|
545
|
+
<FormFieldShell {...shellProps} error={error} htmlFor={id ?? inputId}>
|
|
546
|
+
<ClearableInput
|
|
547
|
+
{...clearableProps}
|
|
548
|
+
id={id ?? inputId}
|
|
549
|
+
name={field.name}
|
|
550
|
+
ref={field.ref}
|
|
551
|
+
value={field.value ?? ""}
|
|
552
|
+
disabled={disabled}
|
|
553
|
+
className={fieldClassName ?? resolvedFieldClassName}
|
|
554
|
+
aria-invalid={fieldState.invalid || undefined}
|
|
555
|
+
onBlur={(event: React.FocusEvent<HTMLInputElement>) => {
|
|
556
|
+
field.onBlur()
|
|
557
|
+
onBlur?.(event)
|
|
558
|
+
}}
|
|
559
|
+
onValueChange={(nextValue: string) => {
|
|
560
|
+
field.onChange(nextValue || emptyValue)
|
|
561
|
+
onValueChange?.(nextValue)
|
|
562
|
+
}}
|
|
563
|
+
/>
|
|
564
|
+
</FormFieldShell>
|
|
565
|
+
)
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if (kind === "masked") {
|
|
569
|
+
const {
|
|
570
|
+
control: _control,
|
|
571
|
+
name: _name,
|
|
572
|
+
label: _label,
|
|
573
|
+
description: _description,
|
|
574
|
+
required: _required,
|
|
575
|
+
className: _className,
|
|
576
|
+
layout: _layout,
|
|
577
|
+
descriptionPosition: _descriptionPosition,
|
|
578
|
+
labelAction: _labelAction,
|
|
579
|
+
requiredIndicator: _requiredIndicator,
|
|
580
|
+
errorIcon: _errorIcon,
|
|
581
|
+
showErrorIcon: _showErrorIcon,
|
|
582
|
+
disabled,
|
|
583
|
+
readOnly: _readOnly,
|
|
584
|
+
labelClassName: _labelClassName,
|
|
585
|
+
labelRowClassName: _labelRowClassName,
|
|
586
|
+
descriptionClassName: _descriptionClassName,
|
|
587
|
+
errorClassName: _errorClassName,
|
|
588
|
+
contentClassName: _contentClassName,
|
|
589
|
+
fieldClassName,
|
|
590
|
+
id,
|
|
591
|
+
kind: _kind,
|
|
592
|
+
valueMode = "raw",
|
|
593
|
+
onValueChange,
|
|
594
|
+
onBlur,
|
|
595
|
+
...maskedProps
|
|
596
|
+
} = props as FormInputMaskedVariantProps<TFieldValues, TName>
|
|
597
|
+
|
|
598
|
+
return (
|
|
599
|
+
<FormFieldShell {...shellProps} error={error} htmlFor={id ?? inputId}>
|
|
600
|
+
<MaskedInput
|
|
601
|
+
{...maskedProps}
|
|
602
|
+
id={id ?? inputId}
|
|
603
|
+
name={field.name}
|
|
604
|
+
ref={field.ref}
|
|
605
|
+
value={String(field.value ?? "")}
|
|
606
|
+
disabled={disabled}
|
|
607
|
+
readOnly={props.readOnly}
|
|
608
|
+
className={fieldClassName ?? resolvedFieldClassName}
|
|
609
|
+
aria-invalid={fieldState.invalid || undefined}
|
|
610
|
+
onBlur={(event: React.FocusEvent<HTMLInputElement>) => {
|
|
611
|
+
field.onBlur()
|
|
612
|
+
onBlur?.(event)
|
|
613
|
+
}}
|
|
614
|
+
onValueChange={(maskedValue: string, rawValue: string) => {
|
|
615
|
+
const nextValue = valueMode === "raw" ? rawValue : maskedValue
|
|
616
|
+
field.onChange(nextValue)
|
|
617
|
+
onValueChange?.(maskedValue, rawValue)
|
|
618
|
+
}}
|
|
619
|
+
/>
|
|
620
|
+
</FormFieldShell>
|
|
621
|
+
)
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
if (kind === "money") {
|
|
625
|
+
const {
|
|
626
|
+
control: _control,
|
|
627
|
+
name: _name,
|
|
628
|
+
label: _label,
|
|
629
|
+
description: _description,
|
|
630
|
+
required: _required,
|
|
631
|
+
className: _className,
|
|
632
|
+
layout: _layout,
|
|
633
|
+
descriptionPosition: _descriptionPosition,
|
|
634
|
+
labelAction: _labelAction,
|
|
635
|
+
requiredIndicator: _requiredIndicator,
|
|
636
|
+
errorIcon: _errorIcon,
|
|
637
|
+
showErrorIcon: _showErrorIcon,
|
|
638
|
+
disabled,
|
|
639
|
+
readOnly: _readOnly,
|
|
640
|
+
labelClassName: _labelClassName,
|
|
641
|
+
labelRowClassName: _labelRowClassName,
|
|
642
|
+
descriptionClassName: _descriptionClassName,
|
|
643
|
+
errorClassName: _errorClassName,
|
|
644
|
+
contentClassName: _contentClassName,
|
|
645
|
+
fieldClassName,
|
|
646
|
+
id,
|
|
647
|
+
kind: _kind,
|
|
648
|
+
emptyValue = null,
|
|
649
|
+
onValueChange,
|
|
650
|
+
onBlur,
|
|
651
|
+
...moneyProps
|
|
652
|
+
} = props as FormInputMoneyVariantProps<TFieldValues, TName>
|
|
653
|
+
|
|
654
|
+
return (
|
|
655
|
+
<FormFieldShell {...shellProps} error={error} htmlFor={id ?? inputId}>
|
|
656
|
+
<MoneyInput
|
|
657
|
+
{...moneyProps}
|
|
658
|
+
id={id ?? inputId}
|
|
659
|
+
name={field.name}
|
|
660
|
+
ref={field.ref}
|
|
661
|
+
value={field.value ?? null}
|
|
662
|
+
disabled={disabled}
|
|
663
|
+
readOnly={props.readOnly}
|
|
664
|
+
className={fieldClassName ?? resolvedFieldClassName}
|
|
665
|
+
aria-invalid={fieldState.invalid || undefined}
|
|
666
|
+
onBlur={(event: React.FocusEvent<HTMLInputElement>) => {
|
|
667
|
+
field.onBlur()
|
|
668
|
+
onBlur?.(event)
|
|
669
|
+
}}
|
|
670
|
+
onValueChange={(nextValue: number | null, rawValue: string) => {
|
|
671
|
+
field.onChange(nextValue ?? emptyValue)
|
|
672
|
+
onValueChange?.(nextValue, rawValue)
|
|
673
|
+
}}
|
|
674
|
+
/>
|
|
675
|
+
</FormFieldShell>
|
|
676
|
+
)
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
if (kind === "quantity") {
|
|
680
|
+
const {
|
|
681
|
+
control: _control,
|
|
682
|
+
name: _name,
|
|
683
|
+
label: _label,
|
|
684
|
+
description: _description,
|
|
685
|
+
required: _required,
|
|
686
|
+
className: _className,
|
|
687
|
+
layout: _layout,
|
|
688
|
+
descriptionPosition: _descriptionPosition,
|
|
689
|
+
labelAction: _labelAction,
|
|
690
|
+
requiredIndicator: _requiredIndicator,
|
|
691
|
+
errorIcon: _errorIcon,
|
|
692
|
+
showErrorIcon: _showErrorIcon,
|
|
693
|
+
disabled,
|
|
694
|
+
readOnly: _readOnly,
|
|
695
|
+
labelClassName: _labelClassName,
|
|
696
|
+
labelRowClassName: _labelRowClassName,
|
|
697
|
+
descriptionClassName: _descriptionClassName,
|
|
698
|
+
errorClassName: _errorClassName,
|
|
699
|
+
contentClassName: _contentClassName,
|
|
700
|
+
fieldClassName,
|
|
701
|
+
id,
|
|
702
|
+
kind: _kind,
|
|
703
|
+
emptyValue = null,
|
|
704
|
+
onValueChange,
|
|
705
|
+
onBlur,
|
|
706
|
+
...quantityProps
|
|
707
|
+
} = props as FormInputQuantityVariantProps<TFieldValues, TName>
|
|
708
|
+
|
|
709
|
+
return (
|
|
710
|
+
<FormFieldShell {...shellProps} error={error} htmlFor={id ?? inputId}>
|
|
711
|
+
<QuantityInput
|
|
712
|
+
{...quantityProps}
|
|
713
|
+
id={id ?? inputId}
|
|
714
|
+
name={field.name}
|
|
715
|
+
ref={field.ref}
|
|
716
|
+
value={field.value}
|
|
717
|
+
disabled={disabled}
|
|
718
|
+
readOnly={props.readOnly}
|
|
719
|
+
className={fieldClassName ?? resolvedFieldClassName}
|
|
720
|
+
aria-invalid={fieldState.invalid || undefined}
|
|
721
|
+
onBlur={(event: React.FocusEvent<HTMLInputElement>) => {
|
|
722
|
+
field.onBlur()
|
|
723
|
+
onBlur?.(event)
|
|
724
|
+
}}
|
|
725
|
+
onValueChange={(nextValue: number | null) => {
|
|
726
|
+
field.onChange(nextValue ?? emptyValue)
|
|
727
|
+
onValueChange?.(nextValue)
|
|
728
|
+
}}
|
|
729
|
+
/>
|
|
730
|
+
</FormFieldShell>
|
|
731
|
+
)
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
if (kind === "date-range") {
|
|
735
|
+
const {
|
|
736
|
+
control: _control,
|
|
737
|
+
name: _name,
|
|
738
|
+
label: _label,
|
|
739
|
+
description: _description,
|
|
740
|
+
required: _required,
|
|
741
|
+
className: _className,
|
|
742
|
+
layout: _layout,
|
|
743
|
+
descriptionPosition: _descriptionPosition,
|
|
744
|
+
labelAction: _labelAction,
|
|
745
|
+
requiredIndicator: _requiredIndicator,
|
|
746
|
+
errorIcon: _errorIcon,
|
|
747
|
+
showErrorIcon: _showErrorIcon,
|
|
748
|
+
disabled,
|
|
749
|
+
labelClassName: _labelClassName,
|
|
750
|
+
labelRowClassName: _labelRowClassName,
|
|
751
|
+
descriptionClassName: _descriptionClassName,
|
|
752
|
+
errorClassName: _errorClassName,
|
|
753
|
+
contentClassName: _contentClassName,
|
|
754
|
+
fieldClassName,
|
|
755
|
+
id,
|
|
756
|
+
kind: _kind,
|
|
757
|
+
onValueChange,
|
|
758
|
+
onBlur,
|
|
759
|
+
...rangeProps
|
|
760
|
+
} = props as FormInputDateRangeVariantProps<TFieldValues, TName>
|
|
761
|
+
|
|
762
|
+
const currentValue = field.value as DateRangeValue | undefined
|
|
763
|
+
|
|
764
|
+
return (
|
|
765
|
+
<FormFieldShell {...shellProps} error={error} htmlFor={id ?? inputId}>
|
|
766
|
+
<DateRangeInput
|
|
767
|
+
{...rangeProps}
|
|
768
|
+
id={id ?? inputId}
|
|
769
|
+
value={
|
|
770
|
+
currentValue && typeof currentValue === "object"
|
|
771
|
+
? { from: currentValue.from, to: currentValue.to }
|
|
772
|
+
: { from: "", to: "" }
|
|
773
|
+
}
|
|
774
|
+
fromInputProps={{
|
|
775
|
+
...(rangeProps.fromInputProps ?? {}),
|
|
776
|
+
disabled,
|
|
777
|
+
readOnly: props.readOnly,
|
|
778
|
+
}}
|
|
779
|
+
toInputProps={{
|
|
780
|
+
...(rangeProps.toInputProps ?? {}),
|
|
781
|
+
disabled,
|
|
782
|
+
readOnly: props.readOnly,
|
|
783
|
+
}}
|
|
784
|
+
onValueChange={(value) => {
|
|
785
|
+
field.onChange(value)
|
|
786
|
+
onValueChange?.(value)
|
|
787
|
+
}}
|
|
788
|
+
aria-invalid={fieldState.invalid || undefined}
|
|
789
|
+
onBlur={(event: React.FocusEvent<HTMLInputElement>) => {
|
|
790
|
+
field.onBlur()
|
|
791
|
+
onBlur?.(event)
|
|
792
|
+
}}
|
|
793
|
+
/>
|
|
794
|
+
</FormFieldShell>
|
|
795
|
+
)
|
|
796
|
+
}
|
|
797
|
+
|
|
422
798
|
const {
|
|
423
799
|
control: _control,
|
|
424
800
|
name: _name,
|
|
@@ -452,23 +828,26 @@ function FormInput<
|
|
|
452
828
|
return (
|
|
453
829
|
<FormFieldShell {...shellProps} error={error} htmlFor={id ?? inputId}>
|
|
454
830
|
<Input
|
|
455
|
-
{...inputProps}
|
|
831
|
+
{...(inputProps as Omit<InputTextInputProps, "kind">)}
|
|
456
832
|
id={id ?? inputId}
|
|
457
833
|
ref={field.ref}
|
|
458
834
|
name={field.name}
|
|
459
|
-
value={
|
|
835
|
+
value={
|
|
836
|
+
(transformIn ? transformIn(field.value) : field.value ?? "") as unknown as
|
|
837
|
+
InputTextInputProps["value"]
|
|
838
|
+
}
|
|
460
839
|
disabled={disabled}
|
|
461
840
|
readOnly={readOnly}
|
|
462
|
-
onBlur={(event) => {
|
|
841
|
+
onBlur={(event: React.FocusEvent<HTMLInputElement>) => {
|
|
463
842
|
field.onBlur()
|
|
464
843
|
onBlur?.(event)
|
|
465
844
|
}}
|
|
466
|
-
onChange={(event) => {
|
|
467
|
-
field.onChange(transformOut ? transformOut(event) : event)
|
|
845
|
+
onChange={(event: TextInputElementChangeEvent) => {
|
|
846
|
+
field.onChange(transformOut ? transformOut(event) : event.target.value)
|
|
468
847
|
onChange?.(event)
|
|
469
848
|
}}
|
|
470
849
|
aria-invalid={fieldState.invalid || undefined}
|
|
471
|
-
className={fieldClassName}
|
|
850
|
+
className={fieldClassName ?? resolvedFieldClassName}
|
|
472
851
|
/>
|
|
473
852
|
</FormFieldShell>
|
|
474
853
|
)
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "@/components/form/form-input"
|
|
5
|
-
import type { FieldPath, FieldValues } from "react-hook-form"
|
|
6
|
-
|
|
1
|
+
import { FormAppInput, type FormAppInputProps } from "@/components/form/form-app-input"
|
|
2
|
+
import type { FieldPath, FieldValues } from "react-hook-form"
|
|
3
|
+
|
|
7
4
|
export type FormNumberInputProps<
|
|
8
5
|
TFieldValues extends FieldValues = FieldValues,
|
|
9
6
|
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
10
|
-
> = Omit<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
15
|
-
>(props: FormNumberInputProps<TFieldValues, TName>) {
|
|
16
|
-
return <FormInput {...props} kind="number" />
|
|
7
|
+
> = Omit<FormAppInputProps<TFieldValues, TName>, "kind" | "step" | "max" | "min"> & {
|
|
8
|
+
step?: number
|
|
9
|
+
min?: number
|
|
10
|
+
max?: number
|
|
17
11
|
}
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
|
|
13
|
+
function FormNumberInput<
|
|
14
|
+
TFieldValues extends FieldValues = FieldValues,
|
|
15
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
16
|
+
>(props: FormNumberInputProps<TFieldValues, TName>) {
|
|
17
|
+
return <FormAppInput {...props} kind="number" />
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { FormNumberInput }
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
type
|
|
5
|
-
} from "@/components/form/form-input"
|
|
2
|
+
FormAppInput,
|
|
3
|
+
type FormAppInputPhoneValueMode,
|
|
4
|
+
type FormAppInputProps,
|
|
5
|
+
} from "@/components/form/form-app-input"
|
|
6
6
|
import type { FieldPath, FieldValues } from "react-hook-form"
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import type { FormInputPhoneInputValueMode } from "@/components/form/form-input"
|
|
9
9
|
|
|
10
|
+
export type FormPhoneInputValueMode = FormAppInputPhoneValueMode
|
|
11
|
+
export type { FormInputPhoneInputValueMode, FormAppInputPhoneValueMode }
|
|
12
|
+
|
|
10
13
|
export type FormPhoneInputProps<
|
|
11
14
|
TFieldValues extends FieldValues = FieldValues,
|
|
12
15
|
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
13
|
-
> = Omit<
|
|
16
|
+
> = Omit<FormAppInputProps<TFieldValues, TName>, "kind" | "phoneValueMode"> & {
|
|
17
|
+
valueMode?: FormInputPhoneInputValueMode
|
|
18
|
+
}
|
|
14
19
|
|
|
15
20
|
function FormPhoneInput<
|
|
16
21
|
TFieldValues extends FieldValues = FieldValues,
|
|
17
22
|
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
18
23
|
>(props: FormPhoneInputProps<TFieldValues, TName>) {
|
|
19
|
-
|
|
24
|
+
const { valueMode, ...rest } = props
|
|
25
|
+
return <FormAppInput {...rest} phoneValueMode={valueMode} kind="phone" />
|
|
20
26
|
}
|
|
21
|
-
|
|
22
|
-
export { FormPhoneInput }
|
|
27
|
+
|
|
28
|
+
export { FormPhoneInput }
|