@ultraviolet/form 4.0.0-beta.9 → 4.0.1
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 +191 -3
- package/dist/components/CheckboxField/index.cjs +13 -13
- package/dist/components/CheckboxField/index.js +13 -13
- package/dist/components/CheckboxGroupField/index.cjs +7 -7
- package/dist/components/CheckboxGroupField/index.d.ts +1 -3
- package/dist/components/CheckboxGroupField/index.js +7 -7
- package/dist/components/{DateField → DateInputField}/index.cjs +18 -18
- package/dist/components/DateInputField/index.d.ts +7 -0
- package/dist/components/{DateField → DateInputField}/index.js +18 -18
- package/dist/components/Form/defaultErrors.cjs +10 -10
- package/dist/components/Form/defaultErrors.js +10 -10
- package/dist/components/Form/index.cjs +5 -5
- package/dist/components/Form/index.js +5 -5
- package/dist/components/KeyValueField/index.cjs +11 -11
- package/dist/components/KeyValueField/index.d.ts +6 -6
- package/dist/components/KeyValueField/index.js +11 -11
- package/dist/components/NumberInputField/index.cjs +26 -26
- package/dist/components/NumberInputField/index.d.ts +3 -9
- package/dist/components/NumberInputField/index.js +26 -26
- package/dist/components/RadioField/index.cjs +8 -8
- package/dist/components/RadioField/index.d.ts +1 -4
- package/dist/components/RadioField/index.js +8 -8
- package/dist/components/RadioGroupField/index.cjs +7 -7
- package/dist/components/RadioGroupField/index.d.ts +17 -7
- package/dist/components/RadioGroupField/index.js +7 -7
- package/dist/components/SelectInputField/index.cjs +21 -73
- package/dist/components/SelectInputField/index.d.ts +3 -81
- package/dist/components/SelectInputField/index.js +22 -74
- package/dist/components/SelectableCardField/index.cjs +8 -8
- package/dist/components/SelectableCardField/index.js +8 -8
- package/dist/components/SelectableCardGroupField/index.cjs +7 -7
- package/dist/components/SelectableCardGroupField/index.js +7 -7
- package/dist/components/SelectableCardOptionGroupField/index.cjs +9 -9
- package/dist/components/SelectableCardOptionGroupField/index.d.ts +3 -3
- package/dist/components/SelectableCardOptionGroupField/index.js +9 -9
- package/dist/components/SliderField/index.cjs +9 -9
- package/dist/components/SliderField/index.d.ts +1 -1
- package/dist/components/SliderField/index.js +9 -9
- package/dist/components/Submit/index.cjs +1 -1
- package/dist/components/Submit/index.js +1 -1
- package/dist/components/SwitchButtonField/index.cjs +8 -9
- package/dist/components/SwitchButtonField/index.d.ts +11 -2
- package/dist/components/SwitchButtonField/index.js +8 -9
- package/dist/components/TagInputField/index.cjs +6 -6
- package/dist/components/TagInputField/index.js +6 -6
- package/dist/components/TextAreaField/index.cjs +8 -8
- package/dist/components/TextAreaField/index.js +8 -8
- package/dist/components/TextInputField/index.cjs +23 -77
- package/dist/components/TextInputField/index.d.ts +5 -11
- package/dist/components/TextInputField/index.js +23 -77
- package/dist/components/{TimeInputFieldV2 → TimeInputField}/index.cjs +6 -6
- package/dist/components/TimeInputField/index.d.ts +11 -0
- package/dist/components/{TimeInputFieldV2 → TimeInputField}/index.js +7 -7
- package/dist/components/ToggleField/index.cjs +7 -7
- package/dist/components/ToggleField/index.js +7 -7
- package/dist/components/UnitInputField/index.cjs +10 -10
- package/dist/components/UnitInputField/index.js +10 -10
- package/dist/components/VerificationCodeField/index.cjs +4 -4
- package/dist/components/VerificationCodeField/index.js +4 -4
- package/dist/components/index.d.ts +11 -15
- package/dist/index.cjs +45 -53
- package/dist/index.d.ts +5 -5
- package/dist/index.js +15 -23
- package/dist/providers/index.d.ts +1 -1
- package/dist/validators/index.d.ts +1 -1
- package/package.json +10 -10
- package/dist/components/DateField/index.d.ts +0 -7
- package/dist/components/NumberInputFieldV2/index.cjs +0 -59
- package/dist/components/NumberInputFieldV2/index.d.ts +0 -7
- package/dist/components/NumberInputFieldV2/index.js +0 -59
- package/dist/components/SelectInputFieldV2/index.cjs +0 -50
- package/dist/components/SelectInputFieldV2/index.d.ts +0 -7
- package/dist/components/SelectInputFieldV2/index.js +0 -50
- package/dist/components/TextInputFieldV2/index.cjs +0 -62
- package/dist/components/TextInputFieldV2/index.d.ts +0 -12
- package/dist/components/TextInputFieldV2/index.js +0 -62
- package/dist/components/TimeField/index.cjs +0 -68
- package/dist/components/TimeField/index.d.ts +0 -7
- package/dist/components/TimeField/index.js +0 -68
- package/dist/components/TimeInputFieldV2/index.d.ts +0 -11
package/README.md
CHANGED
|
@@ -21,18 +21,206 @@ import { Form, TextInputField } from '@ultraviolet/form'
|
|
|
21
21
|
import { theme } from '@ultraviolet/ui'
|
|
22
22
|
import { useForm } from '@ultraviolet/form'
|
|
23
23
|
|
|
24
|
+
// Here are the input types of your form
|
|
25
|
+
type FormValues = {
|
|
26
|
+
firstName: string
|
|
27
|
+
lastName: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// We define the initial values of the form
|
|
31
|
+
const INITIAL_VALUES: FormValues = {
|
|
32
|
+
firstName: 'Marc',
|
|
33
|
+
lastName: 'Scout',
|
|
34
|
+
} as const
|
|
35
|
+
|
|
36
|
+
export default function App() {
|
|
37
|
+
const methods = useForm<FormValues>({
|
|
38
|
+
defaultValues: INITIAL_VALUES,
|
|
39
|
+
mode: 'onChange',
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
const formErrors = {
|
|
43
|
+
required: () => 'This field is required',
|
|
44
|
+
// Add more error messages as needed for min, max, etc.
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const onSubmit = async ({
|
|
48
|
+
firstName,
|
|
49
|
+
lastName,
|
|
50
|
+
}: FormValues) => {
|
|
51
|
+
// Add your form submission logic here
|
|
52
|
+
console.log('Form submitted with values:', { firstName, lastName })
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<ThemeProvider theme={theme}>
|
|
57
|
+
<Form methods={methods} errors={formErrors} onSubmit={onSubmit}>
|
|
58
|
+
<TextInputField name="firstName" />
|
|
59
|
+
<TextInputField name="lastName" />
|
|
60
|
+
</Form>
|
|
61
|
+
</ThemeProvider>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### `useWatch` Hook
|
|
67
|
+
|
|
68
|
+
You can use the `useWatch` hook from `@ultraviolet/form` to watch specific fields in your form thus subscribing to their changes.
|
|
69
|
+
It can be useful for displaying real-time updates or triggering actions based on field values.
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
// FirstNameWatched is a component that needs to watch the firstName field
|
|
73
|
+
function FirstNameWatched({ control }: { control: Control<FormInputs> }) {
|
|
74
|
+
const firstName = useWatch({
|
|
75
|
+
control,
|
|
76
|
+
name: "firstName",
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
return <p>Watch: {firstName}</p>
|
|
80
|
+
}
|
|
81
|
+
|
|
24
82
|
export default function App() {
|
|
25
|
-
|
|
83
|
+
... // same setup as before
|
|
84
|
+
|
|
26
85
|
return (
|
|
27
86
|
<ThemeProvider theme={theme}>
|
|
28
|
-
<Form methods={methods}>
|
|
29
|
-
<TextInputField name="
|
|
87
|
+
<Form methods={methods} errors={formErrors} onSubmit={onSubmit}>
|
|
88
|
+
<TextInputField name="firstName" />
|
|
89
|
+
<TextInputField name="lastName" />
|
|
90
|
+
|
|
91
|
+
<FirstNameWatched control={control} />
|
|
30
92
|
</Form>
|
|
31
93
|
</ThemeProvider>
|
|
32
94
|
)
|
|
33
95
|
}
|
|
34
96
|
```
|
|
35
97
|
|
|
98
|
+
### Form Validation
|
|
99
|
+
|
|
100
|
+
You can validate each fields passing either `regex` or `validate` to any field that support it. Not all field supports `regex` for instance but all fields support `validate`.
|
|
101
|
+
In addition many field support `required`, `minLength`, `maxLength`, `min`, and `max` validation.
|
|
102
|
+
|
|
103
|
+
#### Native Validation
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
<TextInputField
|
|
107
|
+
name="firstName"
|
|
108
|
+
required
|
|
109
|
+
minLength={2}
|
|
110
|
+
maxLength={30}
|
|
111
|
+
/>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### With Validate
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
const EXISTING_IPS = ['192.168.1.1']
|
|
118
|
+
|
|
119
|
+
<TextInputField
|
|
120
|
+
name="ip"
|
|
121
|
+
validate={{
|
|
122
|
+
ipAlreadyExists: (ip: string) =>
|
|
123
|
+
EXISTING_IPS.includes(ip) ? 'This ip is already in use' : undefined,
|
|
124
|
+
}}
|
|
125
|
+
/>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### With Regex
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
<TextInputField
|
|
132
|
+
name="email"
|
|
133
|
+
regex={[/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/]}
|
|
134
|
+
/>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
We all know regex can be tricky, so to help you with that we made [Scaleway Regex](https://github.com/scaleway/scaleway-lib/tree/main/packages/regex) library that contains a lot of useful regexes that you can use in your forms.
|
|
138
|
+
You can easily install it with:
|
|
139
|
+
|
|
140
|
+
```sh
|
|
141
|
+
pnpm add @scaleway/regex
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
You can then use it like this:
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import { email } from '@scaleway/regex'
|
|
148
|
+
|
|
149
|
+
<TextInputField
|
|
150
|
+
name="email"
|
|
151
|
+
regex={[email]}
|
|
152
|
+
/>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Check all the available regexes in the [Scaleway Regex file](https://github.com/scaleway/scaleway-lib/blob/main/packages/regex/src/index.ts)
|
|
156
|
+
|
|
157
|
+
### Resolvers | Zod
|
|
158
|
+
|
|
159
|
+
You can use [Zod](https://zod.dev/) for validation by integrating it with `@ultraviolet/form`. First you will need to install Zod and the Zod resolver for React Hook Form:
|
|
160
|
+
|
|
161
|
+
```sh
|
|
162
|
+
pnpm add zod @hookform/resolvers
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
Here's how you can do it:
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
import { ThemeProvider } from '@emotion/react'
|
|
170
|
+
import { Form, TextInputField } from '@ultraviolet/form'
|
|
171
|
+
import { theme } from '@ultraviolet/ui'
|
|
172
|
+
import { useForm } from '@ultraviolet/form'
|
|
173
|
+
import { zodResolver } from "@hookform/resolvers/zod"
|
|
174
|
+
import * as z from "zod"
|
|
175
|
+
|
|
176
|
+
// Define your Zod schema for validation
|
|
177
|
+
const schema = z.object({
|
|
178
|
+
firstName: z.string(),
|
|
179
|
+
lastName: z.string(),
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
// Types are inferred from the Zod schema
|
|
183
|
+
type FormValues = z.infer<typeof schema>
|
|
184
|
+
|
|
185
|
+
// We define the initial values of the form
|
|
186
|
+
const INITIAL_VALUES: FormValues = {
|
|
187
|
+
firstName: 'Marc',
|
|
188
|
+
lastName: 'Scout',
|
|
189
|
+
} as const
|
|
190
|
+
|
|
191
|
+
export default function App() {
|
|
192
|
+
const methods = useForm<FormValues>({
|
|
193
|
+
defaultValues: INITIAL_VALUES,
|
|
194
|
+
resolver: zodResolver(schema),
|
|
195
|
+
mode: 'onChange',
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
const formErrors = {
|
|
199
|
+
required: () => 'This field is required',
|
|
200
|
+
// Add more error messages as needed for min, max, etc.
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const onSubmit = async ({
|
|
204
|
+
firstName,
|
|
205
|
+
lastName,
|
|
206
|
+
}: FormValues) => {
|
|
207
|
+
// Add your form submission logic here
|
|
208
|
+
console.log('Form submitted with values:', { firstName, lastName })
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<ThemeProvider theme={theme}>
|
|
213
|
+
<Form methods={methods} errors={formErrors} onSubmit={onSubmit}>
|
|
214
|
+
<TextInputField name="firstName" />
|
|
215
|
+
<TextInputField name="lastName" />
|
|
216
|
+
</Form>
|
|
217
|
+
</ThemeProvider>
|
|
218
|
+
)
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
If you need more examples with other resolvers we invite you to check [React Hook Form Resolvers Documentation](https://github.com/react-hook-form/resolvers#quickstart)
|
|
223
|
+
|
|
36
224
|
## Documentation
|
|
37
225
|
|
|
38
226
|
Checkout our [documentation website](https://storybook.ultraviolet.scaleway.com/).
|
|
@@ -28,26 +28,26 @@ const CheckboxField = ({
|
|
|
28
28
|
error
|
|
29
29
|
}
|
|
30
30
|
} = reactHookForm.useController({
|
|
31
|
-
name,
|
|
32
|
-
disabled,
|
|
33
|
-
shouldUnregister,
|
|
34
31
|
control,
|
|
32
|
+
disabled,
|
|
33
|
+
name,
|
|
35
34
|
rules: {
|
|
36
35
|
required,
|
|
37
36
|
validate
|
|
38
|
-
}
|
|
37
|
+
},
|
|
38
|
+
shouldUnregister
|
|
39
39
|
});
|
|
40
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Checkbox, { ...props,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, onBlur: (event) => {
|
|
40
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Checkbox, { ...props, checked: !!field.value, disabled: field.disabled, error: getError({
|
|
41
|
+
label: label ?? ariaLabel ?? name
|
|
42
|
+
}, error), name: field.name, onBlur: (event) => {
|
|
44
43
|
field.onBlur();
|
|
45
44
|
onBlur?.(event);
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"aria-label": void 0
|
|
45
|
+
}, onChange: (event) => {
|
|
46
|
+
field.onChange(event.target.checked);
|
|
47
|
+
onChange?.(event.target.checked);
|
|
48
|
+
}, ref: field.ref, ...children ? {
|
|
49
|
+
"aria-label": void 0,
|
|
50
|
+
children
|
|
51
51
|
} : {
|
|
52
52
|
"aria-label": ariaLabel
|
|
53
53
|
} });
|
|
@@ -26,26 +26,26 @@ const CheckboxField = ({
|
|
|
26
26
|
error
|
|
27
27
|
}
|
|
28
28
|
} = useController({
|
|
29
|
-
name,
|
|
30
|
-
disabled,
|
|
31
|
-
shouldUnregister,
|
|
32
29
|
control,
|
|
30
|
+
disabled,
|
|
31
|
+
name,
|
|
33
32
|
rules: {
|
|
34
33
|
required,
|
|
35
34
|
validate
|
|
36
|
-
}
|
|
35
|
+
},
|
|
36
|
+
shouldUnregister
|
|
37
37
|
});
|
|
38
|
-
return /* @__PURE__ */ jsx(Checkbox, { ...props,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}, onBlur: (event) => {
|
|
38
|
+
return /* @__PURE__ */ jsx(Checkbox, { ...props, checked: !!field.value, disabled: field.disabled, error: getError({
|
|
39
|
+
label: label ?? ariaLabel ?? name
|
|
40
|
+
}, error), name: field.name, onBlur: (event) => {
|
|
42
41
|
field.onBlur();
|
|
43
42
|
onBlur?.(event);
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"aria-label": void 0
|
|
43
|
+
}, onChange: (event) => {
|
|
44
|
+
field.onChange(event.target.checked);
|
|
45
|
+
onChange?.(event.target.checked);
|
|
46
|
+
}, ref: field.ref, ...children ? {
|
|
47
|
+
"aria-label": void 0,
|
|
48
|
+
children
|
|
49
49
|
} : {
|
|
50
50
|
"aria-label": ariaLabel
|
|
51
51
|
} });
|
|
@@ -54,17 +54,19 @@ const CheckboxGroupField = ({
|
|
|
54
54
|
error
|
|
55
55
|
}
|
|
56
56
|
} = reactHookForm.useController({
|
|
57
|
-
name,
|
|
58
57
|
control,
|
|
59
|
-
|
|
58
|
+
name,
|
|
60
59
|
rules: {
|
|
61
60
|
validate: {
|
|
62
61
|
checkboxValid,
|
|
63
62
|
...validate
|
|
64
63
|
}
|
|
65
|
-
}
|
|
64
|
+
},
|
|
65
|
+
shouldUnregister
|
|
66
66
|
});
|
|
67
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.CheckboxGroup, { ...props,
|
|
67
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.CheckboxGroup, { ...props, error: getError({
|
|
68
|
+
label: legend
|
|
69
|
+
}, error) ?? customError, legend, name, onChange: (event) => {
|
|
68
70
|
const fieldValue = field.value;
|
|
69
71
|
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
70
72
|
field.onChange(fieldValue?.filter((currentValue) => currentValue !== event.currentTarget.value));
|
|
@@ -72,9 +74,7 @@ const CheckboxGroupField = ({
|
|
|
72
74
|
field.onChange([...field.value, event.currentTarget.value]);
|
|
73
75
|
}
|
|
74
76
|
onChange?.(event.currentTarget.value);
|
|
75
|
-
},
|
|
76
|
-
label: legend
|
|
77
|
-
}, error) ?? customError, name, required, legend, children });
|
|
77
|
+
}, required, value: field.value, children });
|
|
78
78
|
};
|
|
79
79
|
CheckboxGroupField.Checkbox = ui.CheckboxGroup.Checkbox;
|
|
80
80
|
exports.CheckboxGroupField = CheckboxGroupField;
|
|
@@ -5,10 +5,8 @@ import type { BaseFieldProps } from '../../types';
|
|
|
5
5
|
type CheckboxGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = Omit<BaseFieldProps<TFieldValues, TFieldName>, 'label'> & Omit<ComponentProps<typeof CheckboxGroup>, 'value' | 'onChange'>;
|
|
6
6
|
export declare const CheckboxGroupField: {
|
|
7
7
|
<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ control, children, onChange, error: customError, name, required, shouldUnregister, validate, legend, ...props }: CheckboxGroupFieldProps<TFieldValues, TFieldName>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
8
|
-
Checkbox: ({ onFocus, onBlur, disabled, error, name, value, children, helper, className, autoFocus, "data-testid": dataTestId, required, }: Omit<({
|
|
8
|
+
Checkbox: ({ onFocus, onBlur, disabled, error, name, value, children, helper, className, autoFocus, "data-testid": dataTestId, required, tooltip, }: Omit<({
|
|
9
9
|
error?: string | import("react").ReactNode;
|
|
10
|
-
size?: number;
|
|
11
|
-
progress?: boolean;
|
|
12
10
|
helper?: import("react").ReactNode;
|
|
13
11
|
disabled?: boolean;
|
|
14
12
|
checked?: boolean | "indeterminate";
|
|
@@ -52,17 +52,19 @@ const CheckboxGroupField = ({
|
|
|
52
52
|
error
|
|
53
53
|
}
|
|
54
54
|
} = useController({
|
|
55
|
-
name,
|
|
56
55
|
control,
|
|
57
|
-
|
|
56
|
+
name,
|
|
58
57
|
rules: {
|
|
59
58
|
validate: {
|
|
60
59
|
checkboxValid,
|
|
61
60
|
...validate
|
|
62
61
|
}
|
|
63
|
-
}
|
|
62
|
+
},
|
|
63
|
+
shouldUnregister
|
|
64
64
|
});
|
|
65
|
-
return /* @__PURE__ */ jsx(CheckboxGroup, { ...props,
|
|
65
|
+
return /* @__PURE__ */ jsx(CheckboxGroup, { ...props, error: getError({
|
|
66
|
+
label: legend
|
|
67
|
+
}, error) ?? customError, legend, name, onChange: (event) => {
|
|
66
68
|
const fieldValue = field.value;
|
|
67
69
|
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
68
70
|
field.onChange(fieldValue?.filter((currentValue) => currentValue !== event.currentTarget.value));
|
|
@@ -70,9 +72,7 @@ const CheckboxGroupField = ({
|
|
|
70
72
|
field.onChange([...field.value, event.currentTarget.value]);
|
|
71
73
|
}
|
|
72
74
|
onChange?.(event.currentTarget.value);
|
|
73
|
-
},
|
|
74
|
-
label: legend
|
|
75
|
-
}, error) ?? customError, name, required, legend, children });
|
|
75
|
+
}, required, value: field.value, children });
|
|
76
76
|
};
|
|
77
77
|
CheckboxGroupField.Checkbox = CheckboxGroup.Checkbox;
|
|
78
78
|
export {
|
|
@@ -9,7 +9,7 @@ const minDate = require("../../validators/minDate.cjs");
|
|
|
9
9
|
const index = require("../../providers/ErrorContext/index.cjs");
|
|
10
10
|
const parseDate = (value) => typeof value === "string" ? new Date(value) : value;
|
|
11
11
|
const isEmpty = (value) => !value;
|
|
12
|
-
const
|
|
12
|
+
const DateInputField = ({
|
|
13
13
|
required,
|
|
14
14
|
name,
|
|
15
15
|
control,
|
|
@@ -34,26 +34,33 @@ const DateField = ({
|
|
|
34
34
|
error
|
|
35
35
|
}
|
|
36
36
|
} = reactHookForm.useController({
|
|
37
|
-
name,
|
|
38
37
|
control,
|
|
39
|
-
|
|
38
|
+
name,
|
|
40
39
|
rules: {
|
|
41
40
|
required,
|
|
42
41
|
validate: {
|
|
43
|
-
minDate: minDate.minDateValidator(minDate$1),
|
|
44
42
|
maxDate: maxDate.maxDateValidator(maxDate$1),
|
|
43
|
+
minDate: minDate.minDateValidator(minDate$1),
|
|
45
44
|
...validate
|
|
46
45
|
}
|
|
47
|
-
}
|
|
46
|
+
},
|
|
47
|
+
shouldUnregister
|
|
48
48
|
});
|
|
49
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.DateInput, { ...props,
|
|
49
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.DateInput, { ...props, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0, error: getError({
|
|
50
|
+
label,
|
|
51
|
+
maxDate: maxDate$1,
|
|
52
|
+
minDate: minDate$1
|
|
53
|
+
}, error), format: format || ((value) => {
|
|
50
54
|
if (!value) return "";
|
|
51
55
|
const date = parseDate(value);
|
|
52
56
|
return showMonthYearPicker ? date.toLocaleDateString(void 0, {
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
month: "numeric",
|
|
58
|
+
year: "numeric"
|
|
55
59
|
}) : date.toLocaleDateString();
|
|
56
|
-
}),
|
|
60
|
+
}), label, maxDate: maxDate$1, minDate: minDate$1, name: field.name, onBlur: (e) => {
|
|
61
|
+
field.onBlur();
|
|
62
|
+
onBlur?.(e);
|
|
63
|
+
}, onChange: (val) => {
|
|
57
64
|
if (val && val instanceof Date) {
|
|
58
65
|
onChange?.(val);
|
|
59
66
|
const newDate = parseDate(val);
|
|
@@ -71,13 +78,6 @@ const DateField = ({
|
|
|
71
78
|
onChange?.(val);
|
|
72
79
|
field.onChange(val);
|
|
73
80
|
}
|
|
74
|
-
},
|
|
75
|
-
field.onBlur();
|
|
76
|
-
onBlur?.(e);
|
|
77
|
-
}, maxDate: maxDate$1, minDate: minDate$1, error: getError({
|
|
78
|
-
minDate: minDate$1,
|
|
79
|
-
maxDate: maxDate$1,
|
|
80
|
-
label
|
|
81
|
-
}, error), selectsRange, showMonthYearPicker, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0 });
|
|
81
|
+
}, required, selectsRange, showMonthYearPicker, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, value: Array.isArray(field.value) ? void 0 : field.value });
|
|
82
82
|
};
|
|
83
|
-
exports.
|
|
83
|
+
exports.DateInputField = DateInputField;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DateInput } from '@ultraviolet/ui';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
|
+
import type { BaseFieldProps } from '../../types';
|
|
5
|
+
type DateInputFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof DateInput>, 'required' | 'name' | 'onChange' | 'value'>;
|
|
6
|
+
export declare const DateInputField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ required, name, control, label, format, minDate, maxDate, onChange, onBlur, validate, selectsRange, showMonthYearPicker, shouldUnregister, ...props }: DateInputFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -7,7 +7,7 @@ import { minDateValidator } from "../../validators/minDate.js";
|
|
|
7
7
|
import { useErrors } from "../../providers/ErrorContext/index.js";
|
|
8
8
|
const parseDate = (value) => typeof value === "string" ? new Date(value) : value;
|
|
9
9
|
const isEmpty = (value) => !value;
|
|
10
|
-
const
|
|
10
|
+
const DateInputField = ({
|
|
11
11
|
required,
|
|
12
12
|
name,
|
|
13
13
|
control,
|
|
@@ -32,26 +32,33 @@ const DateField = ({
|
|
|
32
32
|
error
|
|
33
33
|
}
|
|
34
34
|
} = useController({
|
|
35
|
-
name,
|
|
36
35
|
control,
|
|
37
|
-
|
|
36
|
+
name,
|
|
38
37
|
rules: {
|
|
39
38
|
required,
|
|
40
39
|
validate: {
|
|
41
|
-
minDate: minDateValidator(minDate),
|
|
42
40
|
maxDate: maxDateValidator(maxDate),
|
|
41
|
+
minDate: minDateValidator(minDate),
|
|
43
42
|
...validate
|
|
44
43
|
}
|
|
45
|
-
}
|
|
44
|
+
},
|
|
45
|
+
shouldUnregister
|
|
46
46
|
});
|
|
47
|
-
return /* @__PURE__ */ jsx(DateInput, { ...props,
|
|
47
|
+
return /* @__PURE__ */ jsx(DateInput, { ...props, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0, error: getError({
|
|
48
|
+
label,
|
|
49
|
+
maxDate,
|
|
50
|
+
minDate
|
|
51
|
+
}, error), format: format || ((value) => {
|
|
48
52
|
if (!value) return "";
|
|
49
53
|
const date = parseDate(value);
|
|
50
54
|
return showMonthYearPicker ? date.toLocaleDateString(void 0, {
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
month: "numeric",
|
|
56
|
+
year: "numeric"
|
|
53
57
|
}) : date.toLocaleDateString();
|
|
54
|
-
}),
|
|
58
|
+
}), label, maxDate, minDate, name: field.name, onBlur: (e) => {
|
|
59
|
+
field.onBlur();
|
|
60
|
+
onBlur?.(e);
|
|
61
|
+
}, onChange: (val) => {
|
|
55
62
|
if (val && val instanceof Date) {
|
|
56
63
|
onChange?.(val);
|
|
57
64
|
const newDate = parseDate(val);
|
|
@@ -69,15 +76,8 @@ const DateField = ({
|
|
|
69
76
|
onChange?.(val);
|
|
70
77
|
field.onChange(val);
|
|
71
78
|
}
|
|
72
|
-
},
|
|
73
|
-
field.onBlur();
|
|
74
|
-
onBlur?.(e);
|
|
75
|
-
}, maxDate, minDate, error: getError({
|
|
76
|
-
minDate,
|
|
77
|
-
maxDate,
|
|
78
|
-
label
|
|
79
|
-
}, error), selectsRange, showMonthYearPicker, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0 });
|
|
79
|
+
}, required, selectsRange, showMonthYearPicker, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, value: Array.isArray(field.value) ? void 0 : field.value });
|
|
80
80
|
};
|
|
81
81
|
export {
|
|
82
|
-
|
|
82
|
+
DateInputField
|
|
83
83
|
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const defaultErrors = {
|
|
4
|
+
deps: () => "",
|
|
5
|
+
disabled: () => "",
|
|
6
|
+
max: () => "",
|
|
4
7
|
maxDate: () => "",
|
|
5
8
|
maxLength: () => "",
|
|
6
|
-
minLength: () => "",
|
|
7
|
-
max: () => "",
|
|
8
9
|
min: () => "",
|
|
9
|
-
|
|
10
|
-
pattern: () => "",
|
|
11
|
-
deps: () => "",
|
|
12
|
-
value: () => "",
|
|
10
|
+
minLength: () => "",
|
|
13
11
|
onBlur: () => "",
|
|
14
|
-
disabled: () => "",
|
|
15
12
|
onChange: () => "",
|
|
16
|
-
|
|
13
|
+
pattern: () => "",
|
|
14
|
+
required: () => "",
|
|
17
15
|
setValueAs: () => "",
|
|
16
|
+
shouldUnregister: () => "",
|
|
17
|
+
validate: () => "",
|
|
18
|
+
value: () => "",
|
|
18
19
|
valueAsDate: () => "",
|
|
19
|
-
valueAsNumber: () => ""
|
|
20
|
-
shouldUnregister: () => ""
|
|
20
|
+
valueAsNumber: () => ""
|
|
21
21
|
};
|
|
22
22
|
exports.defaultErrors = defaultErrors;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
const defaultErrors = {
|
|
2
|
+
deps: () => "",
|
|
3
|
+
disabled: () => "",
|
|
4
|
+
max: () => "",
|
|
2
5
|
maxDate: () => "",
|
|
3
6
|
maxLength: () => "",
|
|
4
|
-
minLength: () => "",
|
|
5
|
-
max: () => "",
|
|
6
7
|
min: () => "",
|
|
7
|
-
|
|
8
|
-
pattern: () => "",
|
|
9
|
-
deps: () => "",
|
|
10
|
-
value: () => "",
|
|
8
|
+
minLength: () => "",
|
|
11
9
|
onBlur: () => "",
|
|
12
|
-
disabled: () => "",
|
|
13
10
|
onChange: () => "",
|
|
14
|
-
|
|
11
|
+
pattern: () => "",
|
|
12
|
+
required: () => "",
|
|
15
13
|
setValueAs: () => "",
|
|
14
|
+
shouldUnregister: () => "",
|
|
15
|
+
validate: () => "",
|
|
16
|
+
value: () => "",
|
|
16
17
|
valueAsDate: () => "",
|
|
17
|
-
valueAsNumber: () => ""
|
|
18
|
-
shouldUnregister: () => ""
|
|
18
|
+
valueAsNumber: () => ""
|
|
19
19
|
};
|
|
20
20
|
export {
|
|
21
21
|
defaultErrors
|
|
@@ -21,7 +21,7 @@ const StyledForm = /* @__PURE__ */ _styled__default.default("form", process.env.
|
|
|
21
21
|
styles: "display:contents"
|
|
22
22
|
} : {
|
|
23
23
|
name: "49aokf",
|
|
24
|
-
styles: "display:contents/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9ob21lL3J1bm5lci93b3JrL3VsdHJhdmlvbGV0L3VsdHJhdmlvbGV0L3BhY2thZ2VzL2Zvcm0vc3JjL2NvbXBvbmVudHMvRm9ybS9pbmRleC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBb0I4QiIsImZpbGUiOiIvaG9tZS9ydW5uZXIvd29yay91bHRyYXZpb2xldC91bHRyYXZpb2xldC9wYWNrYWdlcy9mb3JtL3NyYy9jb21wb25lbnRzL0Zvcm0vaW5kZXgudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBjbGllbnQnXG5cbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24v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4gICAgICAgICAgICBhd2FpdCBoYW5kbGVTdWJtaXQoZSlcbiAgICAgICAgICB9fVxuICAgICAgICA+XG4gICAgICAgICAge2NoaWxkcmVufVxuICAgICAgICA8L1N0eWxlZEZvcm0+XG4gICAgICA8L0Vycm9yUHJvdmlkZXI+XG4gICAgPC9Gb3JtUHJvdmlkZXI+XG4gIClcbn1cbiJdfQ== */",
|
|
25
25
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
26
26
|
});
|
|
27
27
|
const Form = ({
|
|
@@ -35,18 +35,18 @@ const Form = ({
|
|
|
35
35
|
const result = await onSubmit(values);
|
|
36
36
|
if (result) {
|
|
37
37
|
methods.setError("root.submit", {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
message: result,
|
|
39
|
+
type: "custom"
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
return /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.FormProvider, { ...methods, children: /* @__PURE__ */ jsxRuntime.jsx(index.ErrorProvider, { errors: {
|
|
44
44
|
...defaultErrors.defaultErrors,
|
|
45
45
|
...errors
|
|
46
|
-
}, children: /* @__PURE__ */ jsxRuntime.jsx(StyledForm, { onSubmit: async (e) => {
|
|
46
|
+
}, children: /* @__PURE__ */ jsxRuntime.jsx(StyledForm, { name, noValidate: true, onSubmit: async (e) => {
|
|
47
47
|
e.preventDefault();
|
|
48
48
|
e.stopPropagation();
|
|
49
49
|
await handleSubmit(e);
|
|
50
|
-
},
|
|
50
|
+
}, children }) }) });
|
|
51
51
|
};
|
|
52
52
|
exports.Form = Form;
|
|
@@ -17,7 +17,7 @@ const StyledForm = /* @__PURE__ */ _styled("form", process.env.NODE_ENV === "pro
|
|
|
17
17
|
styles: "display:contents"
|
|
18
18
|
} : {
|
|
19
19
|
name: "49aokf",
|
|
20
|
-
styles: "display:contents/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi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G4gIH0pXG5cbiAgcmV0dXJuIChcbiAgICA8Rm9ybVByb3ZpZGVyIHsuLi5tZXRob2RzfT5cbiAgICAgIDxFcnJvclByb3ZpZGVyIGVycm9ycz17eyAuLi5kZWZhdWx0RXJyb3JzLCAuLi5lcnJvcnMgfX0+XG4gICAgICAgIDxTdHlsZWRGb3JtXG4gICAgICAgICAgbmFtZT17bmFtZX1cbiAgICAgICAgICBub1ZhbGlkYXRlXG4gICAgICAgICAgb25TdWJtaXQ9e2FzeW5jIGUgPT4ge1xuICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpXG4gICAgICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpXG4gICAgICAgICAgICBhd2FpdCBoYW5kbGVTdWJtaXQoZSlcbiAgICAgICAgICB9fVxuICAgICAgICA+XG4gICAgICAgICAge2NoaWxkcmVufVxuICAgICAgICA8L1N0eWxlZEZvcm0+XG4gICAgICA8L0Vycm9yUHJvdmlkZXI+XG4gICAgPC9Gb3JtUHJvdmlkZXI+XG4gIClcbn1cbiJdfQ== */",
|
|
21
21
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
22
22
|
});
|
|
23
23
|
const Form = ({
|
|
@@ -31,19 +31,19 @@ const Form = ({
|
|
|
31
31
|
const result = await onSubmit(values);
|
|
32
32
|
if (result) {
|
|
33
33
|
methods.setError("root.submit", {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
message: result,
|
|
35
|
+
type: "custom"
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsx(ErrorProvider, { errors: {
|
|
40
40
|
...defaultErrors,
|
|
41
41
|
...errors
|
|
42
|
-
}, children: /* @__PURE__ */ jsx(StyledForm, { onSubmit: async (e) => {
|
|
42
|
+
}, children: /* @__PURE__ */ jsx(StyledForm, { name, noValidate: true, onSubmit: async (e) => {
|
|
43
43
|
e.preventDefault();
|
|
44
44
|
e.stopPropagation();
|
|
45
45
|
await handleSubmit(e);
|
|
46
|
-
},
|
|
46
|
+
}, children }) }) });
|
|
47
47
|
};
|
|
48
48
|
export {
|
|
49
49
|
Form
|