@ultraviolet/form 4.0.0-beta.2 → 4.0.0-beta.20
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/CheckboxGroupField/index.cjs +3 -3
- package/dist/components/CheckboxGroupField/index.d.ts +3 -5
- package/dist/components/CheckboxGroupField/index.js +3 -3
- package/dist/components/{DateField → DateInputField}/index.cjs +9 -19
- package/dist/components/DateInputField/index.d.ts +7 -0
- package/dist/components/{DateField → DateInputField}/index.js +9 -19
- package/dist/components/Form/index.cjs +20 -1
- package/dist/components/Form/index.js +18 -1
- package/dist/components/KeyValueField/index.cjs +1 -1
- package/dist/components/KeyValueField/index.d.ts +6 -6
- package/dist/components/KeyValueField/index.js +1 -1
- package/dist/components/NumberInputField/index.cjs +24 -24
- package/dist/components/NumberInputField/index.d.ts +3 -9
- package/dist/components/NumberInputField/index.js +24 -24
- package/dist/components/RadioField/index.d.ts +1 -4
- package/dist/components/RadioGroupField/index.cjs +3 -4
- package/dist/components/RadioGroupField/index.d.ts +19 -9
- package/dist/components/RadioGroupField/index.js +3 -4
- package/dist/components/SelectInputField/index.cjs +19 -71
- package/dist/components/SelectInputField/index.d.ts +3 -81
- package/dist/components/SelectInputField/index.js +20 -72
- package/dist/components/SelectableCardField/index.cjs +5 -11
- package/dist/components/SelectableCardField/index.d.ts +3 -11
- package/dist/components/SelectableCardField/index.js +5 -11
- package/dist/components/SelectableCardGroupField/index.cjs +6 -10
- package/dist/components/SelectableCardGroupField/index.d.ts +2 -2
- package/dist/components/SelectableCardGroupField/index.js +6 -10
- package/dist/components/SelectableCardOptionGroupField/index.cjs +2 -3
- package/dist/components/SelectableCardOptionGroupField/index.d.ts +5 -5
- package/dist/components/SelectableCardOptionGroupField/index.js +2 -3
- package/dist/components/SliderField/index.d.ts +1 -1
- package/dist/components/SwitchButtonField/index.cjs +2 -3
- package/dist/components/SwitchButtonField/index.d.ts +11 -2
- package/dist/components/SwitchButtonField/index.js +2 -3
- package/dist/components/TagInputField/index.cjs +5 -16
- package/dist/components/TagInputField/index.d.ts +2 -2
- package/dist/components/TagInputField/index.js +5 -16
- package/dist/components/TextAreaField/index.cjs +5 -19
- package/dist/components/TextAreaField/index.d.ts +1 -1
- package/dist/components/TextAreaField/index.js +5 -19
- package/dist/components/TextInputField/index.cjs +19 -73
- package/dist/components/TextInputField/index.d.ts +5 -11
- package/dist/components/TextInputField/index.js +19 -73
- package/dist/components/{TimeInputFieldV2 → TimeInputField}/index.cjs +6 -20
- package/dist/components/TimeInputField/index.d.ts +11 -0
- package/dist/components/{TimeInputFieldV2 → TimeInputField}/index.js +7 -21
- package/dist/components/ToggleField/index.cjs +4 -9
- package/dist/components/ToggleField/index.d.ts +5 -5
- package/dist/components/ToggleField/index.js +4 -9
- package/dist/components/ToggleGroupField/index.d.ts +2 -2
- package/dist/components/UnitInputField/index.cjs +5 -15
- package/dist/components/UnitInputField/index.d.ts +2 -4
- package/dist/components/UnitInputField/index.js +5 -15
- package/dist/components/VerificationCodeField/index.cjs +5 -14
- package/dist/components/VerificationCodeField/index.d.ts +2 -7
- package/dist/components/VerificationCodeField/index.js +5 -14
- package/dist/components/index.d.ts +3 -7
- package/dist/index.cjs +38 -46
- package/dist/index.js +5 -13
- package/package.json +12 -12
- package/dist/components/DateField/index.d.ts +0 -17
- package/dist/components/NumberInputFieldV2/index.cjs +0 -72
- package/dist/components/NumberInputFieldV2/index.d.ts +0 -9
- package/dist/components/NumberInputFieldV2/index.js +0 -72
- 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 -90
- package/dist/components/TextInputFieldV2/index.d.ts +0 -12
- package/dist/components/TextInputFieldV2/index.js +0 -90
- 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/).
|
|
@@ -16,12 +16,12 @@ const CheckboxGroupField = ({
|
|
|
16
16
|
control,
|
|
17
17
|
children,
|
|
18
18
|
onChange,
|
|
19
|
-
label = "",
|
|
20
19
|
error: customError,
|
|
21
20
|
name,
|
|
22
21
|
required = false,
|
|
23
22
|
shouldUnregister = false,
|
|
24
23
|
validate,
|
|
24
|
+
legend = "",
|
|
25
25
|
...props
|
|
26
26
|
}) => {
|
|
27
27
|
const {
|
|
@@ -73,8 +73,8 @@ const CheckboxGroupField = ({
|
|
|
73
73
|
}
|
|
74
74
|
onChange?.(event.currentTarget.value);
|
|
75
75
|
}, error: getError({
|
|
76
|
-
label
|
|
77
|
-
}, error) ?? customError, name, required, children });
|
|
76
|
+
label: legend
|
|
77
|
+
}, error) ?? customError, name, required, legend, children });
|
|
78
78
|
};
|
|
79
79
|
CheckboxGroupField.Checkbox = ui.CheckboxGroup.Checkbox;
|
|
80
80
|
exports.CheckboxGroupField = CheckboxGroupField;
|
|
@@ -2,13 +2,11 @@ import { CheckboxGroup } from '@ultraviolet/ui';
|
|
|
2
2
|
import type { ComponentProps } from 'react';
|
|
3
3
|
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
4
|
import type { BaseFieldProps } from '../../types';
|
|
5
|
-
type CheckboxGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof CheckboxGroup>, 'value' | 'onChange'>;
|
|
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
|
-
<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ control, children, onChange,
|
|
8
|
-
Checkbox: ({ onFocus, onBlur, disabled, error, name, value, children, helper, className, autoFocus, "data-testid": dataTestId, required, }: Omit<({
|
|
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, 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";
|
|
@@ -14,12 +14,12 @@ const CheckboxGroupField = ({
|
|
|
14
14
|
control,
|
|
15
15
|
children,
|
|
16
16
|
onChange,
|
|
17
|
-
label = "",
|
|
18
17
|
error: customError,
|
|
19
18
|
name,
|
|
20
19
|
required = false,
|
|
21
20
|
shouldUnregister = false,
|
|
22
21
|
validate,
|
|
22
|
+
legend = "",
|
|
23
23
|
...props
|
|
24
24
|
}) => {
|
|
25
25
|
const {
|
|
@@ -71,8 +71,8 @@ const CheckboxGroupField = ({
|
|
|
71
71
|
}
|
|
72
72
|
onChange?.(event.currentTarget.value);
|
|
73
73
|
}, error: getError({
|
|
74
|
-
label
|
|
75
|
-
}, error) ?? customError, name, required, children });
|
|
74
|
+
label: legend
|
|
75
|
+
}, error) ?? customError, name, required, legend, children });
|
|
76
76
|
};
|
|
77
77
|
CheckboxGroupField.Checkbox = CheckboxGroup.Checkbox;
|
|
78
78
|
export {
|
|
@@ -9,31 +9,21 @@ 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,
|
|
16
16
|
label = "",
|
|
17
17
|
format,
|
|
18
|
-
locale,
|
|
19
|
-
maxDate: maxDate$1,
|
|
20
18
|
minDate: minDate$1,
|
|
21
|
-
|
|
19
|
+
maxDate: maxDate$1,
|
|
22
20
|
onChange,
|
|
23
21
|
onBlur,
|
|
24
|
-
onFocus,
|
|
25
22
|
validate,
|
|
26
|
-
autoFocus = false,
|
|
27
|
-
excludeDates,
|
|
28
23
|
selectsRange,
|
|
29
|
-
size,
|
|
30
|
-
placeholder,
|
|
31
|
-
tooltip,
|
|
32
|
-
clearable,
|
|
33
|
-
"data-testid": dataTestId,
|
|
34
|
-
shouldUnregister = false,
|
|
35
24
|
showMonthYearPicker,
|
|
36
|
-
|
|
25
|
+
shouldUnregister = false,
|
|
26
|
+
...props
|
|
37
27
|
}) => {
|
|
38
28
|
const {
|
|
39
29
|
getError
|
|
@@ -56,14 +46,14 @@ const DateField = ({
|
|
|
56
46
|
}
|
|
57
47
|
}
|
|
58
48
|
});
|
|
59
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.DateInput, { name: field.name, label,
|
|
49
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.DateInput, { ...props, name: field.name, label, value: Array.isArray(field.value) ? void 0 : field.value, format: format || ((value) => {
|
|
60
50
|
if (!value) return "";
|
|
61
51
|
const date = parseDate(value);
|
|
62
52
|
return showMonthYearPicker ? date.toLocaleDateString(void 0, {
|
|
63
53
|
year: "numeric",
|
|
64
54
|
month: "numeric"
|
|
65
55
|
}) : date.toLocaleDateString();
|
|
66
|
-
}),
|
|
56
|
+
}), required, onChange: (val) => {
|
|
67
57
|
if (val && val instanceof Date) {
|
|
68
58
|
onChange?.(val);
|
|
69
59
|
const newDate = parseDate(val);
|
|
@@ -84,10 +74,10 @@ const DateField = ({
|
|
|
84
74
|
}, onBlur: (e) => {
|
|
85
75
|
field.onBlur();
|
|
86
76
|
onBlur?.(e);
|
|
87
|
-
},
|
|
77
|
+
}, maxDate: maxDate$1, minDate: minDate$1, error: getError({
|
|
88
78
|
minDate: minDate$1,
|
|
89
79
|
maxDate: maxDate$1,
|
|
90
80
|
label
|
|
91
|
-
}, error),
|
|
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 });
|
|
92
82
|
};
|
|
93
|
-
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,31 +7,21 @@ 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,
|
|
14
14
|
label = "",
|
|
15
15
|
format,
|
|
16
|
-
locale,
|
|
17
|
-
maxDate,
|
|
18
16
|
minDate,
|
|
19
|
-
|
|
17
|
+
maxDate,
|
|
20
18
|
onChange,
|
|
21
19
|
onBlur,
|
|
22
|
-
onFocus,
|
|
23
20
|
validate,
|
|
24
|
-
autoFocus = false,
|
|
25
|
-
excludeDates,
|
|
26
21
|
selectsRange,
|
|
27
|
-
size,
|
|
28
|
-
placeholder,
|
|
29
|
-
tooltip,
|
|
30
|
-
clearable,
|
|
31
|
-
"data-testid": dataTestId,
|
|
32
|
-
shouldUnregister = false,
|
|
33
22
|
showMonthYearPicker,
|
|
34
|
-
|
|
23
|
+
shouldUnregister = false,
|
|
24
|
+
...props
|
|
35
25
|
}) => {
|
|
36
26
|
const {
|
|
37
27
|
getError
|
|
@@ -54,14 +44,14 @@ const DateField = ({
|
|
|
54
44
|
}
|
|
55
45
|
}
|
|
56
46
|
});
|
|
57
|
-
return /* @__PURE__ */ jsx(DateInput, { name: field.name, label,
|
|
47
|
+
return /* @__PURE__ */ jsx(DateInput, { ...props, name: field.name, label, value: Array.isArray(field.value) ? void 0 : field.value, format: format || ((value) => {
|
|
58
48
|
if (!value) return "";
|
|
59
49
|
const date = parseDate(value);
|
|
60
50
|
return showMonthYearPicker ? date.toLocaleDateString(void 0, {
|
|
61
51
|
year: "numeric",
|
|
62
52
|
month: "numeric"
|
|
63
53
|
}) : date.toLocaleDateString();
|
|
64
|
-
}),
|
|
54
|
+
}), required, onChange: (val) => {
|
|
65
55
|
if (val && val instanceof Date) {
|
|
66
56
|
onChange?.(val);
|
|
67
57
|
const newDate = parseDate(val);
|
|
@@ -82,12 +72,12 @@ const DateField = ({
|
|
|
82
72
|
}, onBlur: (e) => {
|
|
83
73
|
field.onBlur();
|
|
84
74
|
onBlur?.(e);
|
|
85
|
-
},
|
|
75
|
+
}, maxDate, minDate, error: getError({
|
|
86
76
|
minDate,
|
|
87
77
|
maxDate,
|
|
88
78
|
label
|
|
89
|
-
}, error),
|
|
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 });
|
|
90
80
|
};
|
|
91
81
|
export {
|
|
92
|
-
|
|
82
|
+
DateInputField
|
|
93
83
|
};
|
|
@@ -2,9 +2,28 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
+
const _styled = require("@emotion/styled/base");
|
|
5
6
|
const reactHookForm = require("react-hook-form");
|
|
6
7
|
const defaultErrors = require("./defaultErrors.cjs");
|
|
7
8
|
const index = require("../../providers/ErrorContext/index.cjs");
|
|
9
|
+
const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
10
|
+
const _styled__default = /* @__PURE__ */ _interopDefaultCompat(_styled);
|
|
11
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() {
|
|
12
|
+
return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop).";
|
|
13
|
+
}
|
|
14
|
+
const StyledForm = /* @__PURE__ */ _styled__default.default("form", process.env.NODE_ENV === "production" ? {
|
|
15
|
+
target: "ep3wzi00"
|
|
16
|
+
} : {
|
|
17
|
+
target: "ep3wzi00",
|
|
18
|
+
label: "StyledForm"
|
|
19
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
20
|
+
name: "49aokf",
|
|
21
|
+
styles: "display:contents"
|
|
22
|
+
} : {
|
|
23
|
+
name: "49aokf",
|
|
24
|
+
styles: "display:contents/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2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SlcbiAgICAgICAgICB9fVxuICAgICAgICAgIG5hbWU9e25hbWV9XG4gICAgICAgICAgbm9WYWxpZGF0ZVxuICAgICAgICA+XG4gICAgICAgICAge2NoaWxkcmVufVxuICAgICAgICA8L1N0eWxlZEZvcm0+XG4gICAgICA8L0Vycm9yUHJvdmlkZXI+XG4gICAgPC9Gb3JtUHJvdmlkZXI+XG4gIClcbn1cbiJdfQ== */",
|
|
25
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
26
|
+
});
|
|
8
27
|
const Form = ({
|
|
9
28
|
children,
|
|
10
29
|
methods,
|
|
@@ -24,7 +43,7 @@ const Form = ({
|
|
|
24
43
|
return /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.FormProvider, { ...methods, children: /* @__PURE__ */ jsxRuntime.jsx(index.ErrorProvider, { errors: {
|
|
25
44
|
...defaultErrors.defaultErrors,
|
|
26
45
|
...errors
|
|
27
|
-
}, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
46
|
+
}, children: /* @__PURE__ */ jsxRuntime.jsx(StyledForm, { onSubmit: async (e) => {
|
|
28
47
|
e.preventDefault();
|
|
29
48
|
e.stopPropagation();
|
|
30
49
|
await handleSubmit(e);
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
3
|
+
import _styled from "@emotion/styled/base";
|
|
3
4
|
import { FormProvider } from "react-hook-form";
|
|
4
5
|
import { defaultErrors } from "./defaultErrors.js";
|
|
5
6
|
import { ErrorProvider } from "../../providers/ErrorContext/index.js";
|
|
7
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() {
|
|
8
|
+
return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop).";
|
|
9
|
+
}
|
|
10
|
+
const StyledForm = /* @__PURE__ */ _styled("form", process.env.NODE_ENV === "production" ? {
|
|
11
|
+
target: "ep3wzi00"
|
|
12
|
+
} : {
|
|
13
|
+
target: "ep3wzi00",
|
|
14
|
+
label: "StyledForm"
|
|
15
|
+
})(process.env.NODE_ENV === "production" ? {
|
|
16
|
+
name: "49aokf",
|
|
17
|
+
styles: "display:contents"
|
|
18
|
+
} : {
|
|
19
|
+
name: "49aokf",
|
|
20
|
+
styles: "display:contents/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9ob21lL3J1bm5lci93b3JrL3VsdHJhdmlvbGV0L3VsdHJhdmlvbGV0L3BhY2thZ2VzL2Zvcm0vc3JjL2NvbXBvbmVudHMvRm9ybS9pbmRleC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBb0I4QiIsImZpbGUiOiIvaG9tZS9ydW5uZXIvd29yay91bHRyYXZpb2xldC91bHRyYXZpb2xldC9wYWNrYWdlcy9mb3JtL3NyYy9jb21wb25lbnRzL0Zvcm0vaW5kZXgudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBjbGllbnQnXG5cbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJ1xuaW1wb3J0IHR5cGUgeyBSZWFjdE5vZGUgfSBmcm9tICdyZWFjdCdcbmltcG9ydCB0eXBlIHsgRmllbGRWYWx1ZXMsIFVzZUZvcm1SZXR1cm4gfSBmcm9tICdyZWFjdC1ob29rLWZvcm0nXG5pbXBvcnQgeyBGb3JtUHJvdmlkZXIgfSBmcm9tICdyZWFjdC1ob29rLWZvcm0nXG5pbXBvcnQgeyBFcnJvclByb3ZpZGVyIH0gZnJvbSAnLi4vLi4vcHJvdmlkZXJzJ1xuaW1wb3J0IHR5cGUgeyBGb3JtRXJyb3JzIH0gZnJvbSAnLi4vLi4vdHlwZXMnXG5pbXBvcnQgeyBkZWZhdWx0RXJyb3JzIH0gZnJvbSAnLi9kZWZhdWx0RXJyb3JzJ1xuXG50eXBlIE9u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ZpZGVyIGVycm9ycz17eyAuLi5kZWZhdWx0RXJyb3JzLCAuLi5lcnJvcnMgfX0+XG4gICAgICAgIDxTdHlsZWRGb3JtXG4gICAgICAgICAgb25TdWJtaXQ9e2FzeW5jIGUgPT4ge1xuICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpXG4gICAgICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpXG4gICAgICAgICAgICBhd2FpdCBoYW5kbGVTdWJtaXQoZSlcbiAgICAgICAgICB9fVxuICAgICAgICAgIG5hbWU9e25hbWV9XG4gICAgICAgICAgbm9WYWxpZGF0ZVxuICAgICAgICA+XG4gICAgICAgICAge2NoaWxkcmVufVxuICAgICAgICA8L1N0eWxlZEZvcm0+XG4gICAgICA8L0Vycm9yUHJvdmlkZXI+XG4gICAgPC9Gb3JtUHJvdmlkZXI+XG4gIClcbn1cbiJdfQ== */",
|
|
21
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
22
|
+
});
|
|
6
23
|
const Form = ({
|
|
7
24
|
children,
|
|
8
25
|
methods,
|
|
@@ -22,7 +39,7 @@ const Form = ({
|
|
|
22
39
|
return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsx(ErrorProvider, { errors: {
|
|
23
40
|
...defaultErrors,
|
|
24
41
|
...errors
|
|
25
|
-
}, children: /* @__PURE__ */ jsx(
|
|
42
|
+
}, children: /* @__PURE__ */ jsx(StyledForm, { onSubmit: async (e) => {
|
|
26
43
|
e.preventDefault();
|
|
27
44
|
e.stopPropagation();
|
|
28
45
|
await handleSubmit(e);
|
|
@@ -5,7 +5,7 @@ const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
5
5
|
const icons = require("@ultraviolet/icons");
|
|
6
6
|
const ui = require("@ultraviolet/ui");
|
|
7
7
|
const reactHookForm = require("react-hook-form");
|
|
8
|
-
const index = require("../
|
|
8
|
+
const index = require("../TextInputField/index.cjs");
|
|
9
9
|
const KeyValueField = ({
|
|
10
10
|
name,
|
|
11
11
|
inputKey,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Button } from '@ultraviolet/ui';
|
|
2
2
|
import type { ComponentProps } from 'react';
|
|
3
3
|
import type { Control, FieldArrayPath, FieldValues } from 'react-hook-form';
|
|
4
|
-
import { TextInputField
|
|
4
|
+
import { TextInputField } from '../TextInputField';
|
|
5
5
|
type InputKeyProps = {
|
|
6
|
-
label: ComponentProps<typeof
|
|
7
|
-
required?: ComponentProps<typeof
|
|
8
|
-
regex?: ComponentProps<typeof
|
|
6
|
+
label: ComponentProps<typeof TextInputField>['label'];
|
|
7
|
+
required?: ComponentProps<typeof TextInputField>['required'];
|
|
8
|
+
regex?: ComponentProps<typeof TextInputField>['regex'];
|
|
9
9
|
};
|
|
10
10
|
type InputValueProps = {
|
|
11
|
-
type?: ComponentProps<typeof
|
|
12
|
-
placeholder?: ComponentProps<typeof
|
|
11
|
+
type?: ComponentProps<typeof TextInputField>['type'];
|
|
12
|
+
placeholder?: ComponentProps<typeof TextInputField>['placeholder'];
|
|
13
13
|
} & InputKeyProps;
|
|
14
14
|
type AddButtonProps = {
|
|
15
15
|
name: ComponentProps<typeof Button>['children'];
|
|
@@ -3,7 +3,7 @@ import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
|
3
3
|
import { DeleteIcon, PlusIcon } from "@ultraviolet/icons";
|
|
4
4
|
import { Stack, Row, Button } from "@ultraviolet/ui";
|
|
5
5
|
import { useFieldArray } from "react-hook-form";
|
|
6
|
-
import { TextInputField } from "../
|
|
6
|
+
import { TextInputField } from "../TextInputField/index.js";
|
|
7
7
|
const KeyValueField = ({
|
|
8
8
|
name,
|
|
9
9
|
inputKey,
|
|
@@ -4,26 +4,22 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
4
4
|
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const ui = require("@ultraviolet/ui");
|
|
6
6
|
const reactHookForm = require("react-hook-form");
|
|
7
|
+
const isInteger = require("../../validators/isInteger.cjs");
|
|
7
8
|
const index = require("../../providers/ErrorContext/index.cjs");
|
|
8
9
|
const NumberInputField = ({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
control,
|
|
11
|
+
max = Number.MAX_SAFE_INTEGER,
|
|
12
|
+
min = 0,
|
|
12
13
|
name,
|
|
13
14
|
onChange,
|
|
14
15
|
onBlur,
|
|
15
|
-
onFocus,
|
|
16
|
-
onMaxCrossed,
|
|
17
|
-
onMinCrossed,
|
|
18
|
-
required,
|
|
19
|
-
size,
|
|
20
16
|
step,
|
|
21
|
-
text,
|
|
22
|
-
className,
|
|
23
17
|
label,
|
|
18
|
+
"aria-label": ariaLabel,
|
|
19
|
+
required,
|
|
24
20
|
shouldUnregister = false,
|
|
25
21
|
validate,
|
|
26
|
-
|
|
22
|
+
...props
|
|
27
23
|
}) => {
|
|
28
24
|
const {
|
|
29
25
|
getError
|
|
@@ -35,25 +31,29 @@ const NumberInputField = ({
|
|
|
35
31
|
}
|
|
36
32
|
} = reactHookForm.useController({
|
|
37
33
|
name,
|
|
38
|
-
shouldUnregister,
|
|
39
34
|
control,
|
|
35
|
+
shouldUnregister,
|
|
40
36
|
rules: {
|
|
41
|
-
max
|
|
42
|
-
min
|
|
37
|
+
max,
|
|
38
|
+
min,
|
|
43
39
|
required,
|
|
44
|
-
validate
|
|
40
|
+
validate: {
|
|
41
|
+
...validate,
|
|
42
|
+
isInteger: isInteger.isInteger(step)
|
|
43
|
+
}
|
|
45
44
|
}
|
|
46
45
|
});
|
|
47
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.NumberInput, { name: field.name, value: field.value,
|
|
46
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.NumberInput, { ...props, name: field.name, value: field.value, onBlur: (event) => {
|
|
48
47
|
field.onBlur();
|
|
49
48
|
onBlur?.(event);
|
|
50
|
-
}, onChange: (
|
|
51
|
-
field.onChange(
|
|
52
|
-
onChange?.(
|
|
53
|
-
},
|
|
54
|
-
label: label ??
|
|
55
|
-
max
|
|
56
|
-
min
|
|
57
|
-
|
|
49
|
+
}, onChange: (newValue) => {
|
|
50
|
+
field.onChange(newValue);
|
|
51
|
+
onChange?.(newValue);
|
|
52
|
+
}, max, min, step, label, error: getError({
|
|
53
|
+
label: label ?? ariaLabel ?? name,
|
|
54
|
+
max,
|
|
55
|
+
min,
|
|
56
|
+
isInteger: step
|
|
57
|
+
}, error), "aria-label": ariaLabel, required });
|
|
58
58
|
};
|
|
59
59
|
exports.NumberInputField = NumberInputField;
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { NumberInput } from '@ultraviolet/ui';
|
|
2
|
-
import type { ComponentProps
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
3
|
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
4
|
import type { BaseFieldProps } from '../../types';
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
onFocus?: FocusEventHandler<HTMLInputElement>;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated This component is deprecated, use `NumberInputFieldV2` instead.
|
|
11
|
-
*/
|
|
12
|
-
export declare const NumberInputField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ disabled, maxValue, minValue, name, onChange, onBlur, onFocus, onMaxCrossed, onMinCrossed, required, size, step, text, className, label, shouldUnregister, validate, control, }: NumberInputValueFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
5
|
+
type NumberInputProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof NumberInput>, 'onChange'>;
|
|
6
|
+
export declare const NumberInputField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ control, max, min, name, onChange, onBlur, step, label, "aria-label": ariaLabel, required, shouldUnregister, validate, ...props }: NumberInputProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
13
7
|
export {};
|