@ultraviolet/form 6.0.0-beta.9 → 6.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 +5 -6
- package/dist/components/CheckboxField/index.d.ts +1 -1
- package/dist/components/CheckboxField/index.js +25 -21
- package/dist/components/CheckboxGroupField/index.d.ts +4 -4
- package/dist/components/CheckboxGroupField/index.js +50 -35
- package/dist/components/DateInputField/index.d.ts +1 -1
- package/dist/components/DateInputField/index.js +52 -41
- package/dist/components/Form/index.d.ts +1 -1
- package/dist/components/Form/index.js +15 -11
- package/dist/components/KeyValueField/index.d.ts +1 -1
- package/dist/components/KeyValueField/index.js +75 -27
- package/dist/components/NumberInputField/index.d.ts +1 -1
- package/dist/components/NumberInputField/index.js +29 -19
- package/dist/components/RadioField/index.d.ts +1 -1
- package/dist/components/RadioField/index.js +25 -20
- package/dist/components/RadioGroupField/index.d.ts +4 -3
- package/dist/components/RadioGroupField/index.js +21 -13
- package/dist/components/SelectInputField/index.d.ts +1 -1
- package/dist/components/SelectInputField/index.js +28 -17
- package/dist/components/SelectableCardField/index.d.ts +1 -1
- package/dist/components/SelectableCardField/index.js +40 -29
- package/dist/components/SelectableCardGroupField/index.d.ts +1 -1
- package/dist/components/SelectableCardGroupField/index.js +34 -21
- package/dist/components/SelectableCardOptionGroupField/index.d.ts +2 -2
- package/dist/components/SelectableCardOptionGroupField/index.js +26 -22
- package/dist/components/SliderField/index.d.ts +1 -1
- package/dist/components/SliderField/index.js +38 -24
- package/dist/components/Submit/index.d.ts +1 -1
- package/dist/components/Submit/index.js +18 -6
- package/dist/components/SubmitErrorAlert/index.d.ts +1 -1
- package/dist/components/SubmitErrorAlert/index.js +3 -7
- package/dist/components/SwitchButtonField/index.d.ts +4 -3
- package/dist/components/SwitchButtonField/index.js +24 -11
- package/dist/components/TagInputField/index.d.ts +1 -1
- package/dist/components/TagInputField/index.js +21 -14
- package/dist/components/TextAreaField/index.d.ts +1 -1
- package/dist/components/TextAreaField/index.js +35 -27
- package/dist/components/TextInputField/index.d.ts +1 -1
- package/dist/components/TextInputField/index.js +36 -20
- package/dist/components/TimeInputField/index.d.ts +1 -1
- package/dist/components/TimeInputField/index.js +27 -17
- package/dist/components/ToggleField/index.d.ts +1 -1
- package/dist/components/ToggleField/index.js +27 -16
- package/dist/components/ToggleGroupField/index.d.ts +4 -4
- package/dist/components/ToggleGroupField/index.js +61 -0
- package/dist/components/UnitInputField/index.d.ts +1 -1
- package/dist/components/UnitInputField/index.js +27 -23
- package/dist/components/VerificationCodeField/index.d.ts +1 -1
- package/dist/components/VerificationCodeField/index.js +18 -13
- package/dist/components/index.d.ts +1 -0
- package/dist/hooks/useOnFieldChange.js +4 -5
- package/dist/index.js +2 -0
- package/dist/providers/ErrorContext/index.d.ts +1 -1
- package/dist/providers/ErrorContext/index.js +21 -18
- package/dist/utils/validateRegex.js +3 -1
- package/package.json +10 -15
- package/dist/components/CheckboxField/index.cjs +0 -55
- package/dist/components/CheckboxGroupField/index.cjs +0 -80
- package/dist/components/DateInputField/index.cjs +0 -85
- package/dist/components/Form/defaultErrors.cjs +0 -22
- package/dist/components/Form/index.cjs +0 -35
- package/dist/components/KeyValueField/index.cjs +0 -60
- package/dist/components/NumberInputField/index.cjs +0 -59
- package/dist/components/RadioField/index.cjs +0 -64
- package/dist/components/RadioGroupField/index.cjs +0 -45
- package/dist/components/SelectInputField/index.cjs +0 -50
- package/dist/components/SelectableCardField/index.cjs +0 -66
- package/dist/components/SelectableCardGroupField/index.cjs +0 -55
- package/dist/components/SelectableCardOptionGroupField/index.cjs +0 -59
- package/dist/components/SliderField/index.cjs +0 -76
- package/dist/components/Submit/index.cjs +0 -25
- package/dist/components/SubmitErrorAlert/index.cjs +0 -15
- package/dist/components/SwitchButtonField/index.cjs +0 -35
- package/dist/components/TagInputField/index.cjs +0 -51
- package/dist/components/TextAreaField/index.cjs +0 -84
- package/dist/components/TextInputField/index.cjs +0 -62
- package/dist/components/TimeInputField/index.cjs +0 -46
- package/dist/components/ToggleField/index.cjs +0 -55
- package/dist/components/UnitInputField/index.cjs +0 -58
- package/dist/components/VerificationCodeField/index.cjs +0 -48
- package/dist/hooks/useOnFieldChange.cjs +0 -21
- package/dist/index.cjs +0 -78
- package/dist/providers/ErrorContext/index.cjs +0 -34
- package/dist/utils/validateRegex.cjs +0 -4
- package/dist/validators/isInteger.cjs +0 -12
- package/dist/validators/maxDate.cjs +0 -4
- package/dist/validators/minDate.cjs +0 -4
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const reactHookForm = require("react-hook-form");
|
|
7
|
-
const index = require("../../providers/ErrorContext/index.cjs");
|
|
8
|
-
const RadioGroupField = ({
|
|
9
|
-
control,
|
|
10
|
-
name,
|
|
11
|
-
onChange,
|
|
12
|
-
required,
|
|
13
|
-
children,
|
|
14
|
-
error: customError,
|
|
15
|
-
shouldUnregister = false,
|
|
16
|
-
validate,
|
|
17
|
-
legend = "",
|
|
18
|
-
...props
|
|
19
|
-
}) => {
|
|
20
|
-
const {
|
|
21
|
-
getError
|
|
22
|
-
} = index.useErrors();
|
|
23
|
-
const {
|
|
24
|
-
field,
|
|
25
|
-
fieldState: {
|
|
26
|
-
error
|
|
27
|
-
}
|
|
28
|
-
} = reactHookForm.useController({
|
|
29
|
-
control,
|
|
30
|
-
name,
|
|
31
|
-
rules: {
|
|
32
|
-
required,
|
|
33
|
-
validate
|
|
34
|
-
},
|
|
35
|
-
shouldUnregister
|
|
36
|
-
});
|
|
37
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.RadioGroup, { ...props, error: getError({
|
|
38
|
-
label: legend
|
|
39
|
-
}, error) ?? customError, legend, name: field.name, onChange: (event) => {
|
|
40
|
-
field.onChange(event);
|
|
41
|
-
onChange?.(event.target.value);
|
|
42
|
-
}, required, value: field.value, children });
|
|
43
|
-
};
|
|
44
|
-
RadioGroupField.Radio = ui.RadioGroup.Radio;
|
|
45
|
-
exports.RadioGroupField = RadioGroupField;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const react = require("react");
|
|
7
|
-
const reactHookForm = require("react-hook-form");
|
|
8
|
-
const index = require("../../providers/ErrorContext/index.cjs");
|
|
9
|
-
const SelectInputField = ({
|
|
10
|
-
label = "",
|
|
11
|
-
onBlur,
|
|
12
|
-
required,
|
|
13
|
-
name,
|
|
14
|
-
"aria-label": ariaLabel,
|
|
15
|
-
shouldUnregister = false,
|
|
16
|
-
control,
|
|
17
|
-
validate,
|
|
18
|
-
onChange,
|
|
19
|
-
multiselect,
|
|
20
|
-
...props
|
|
21
|
-
}) => {
|
|
22
|
-
const {
|
|
23
|
-
field,
|
|
24
|
-
fieldState: {
|
|
25
|
-
error
|
|
26
|
-
}
|
|
27
|
-
} = reactHookForm.useController({
|
|
28
|
-
control,
|
|
29
|
-
name,
|
|
30
|
-
rules: {
|
|
31
|
-
required,
|
|
32
|
-
validate
|
|
33
|
-
},
|
|
34
|
-
shouldUnregister
|
|
35
|
-
});
|
|
36
|
-
const {
|
|
37
|
-
getError
|
|
38
|
-
} = index.useErrors();
|
|
39
|
-
const handleChange = react.useCallback((value) => {
|
|
40
|
-
onChange?.(value);
|
|
41
|
-
field.onChange(value);
|
|
42
|
-
}, [onChange, field]);
|
|
43
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectInput, { "aria-label": ariaLabel, error: getError({
|
|
44
|
-
label: label ?? ariaLabel ?? name
|
|
45
|
-
}, error), label, multiselect, name: field.name, onBlur: (event) => {
|
|
46
|
-
field.onBlur();
|
|
47
|
-
onBlur?.(event);
|
|
48
|
-
}, onChange: handleChange, required, value: field.value, ...props });
|
|
49
|
-
};
|
|
50
|
-
exports.SelectInputField = SelectInputField;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const reactHookForm = require("react-hook-form");
|
|
7
|
-
const SelectableCardField = ({
|
|
8
|
-
name,
|
|
9
|
-
control,
|
|
10
|
-
value,
|
|
11
|
-
onChange,
|
|
12
|
-
type,
|
|
13
|
-
onFocus,
|
|
14
|
-
onBlur,
|
|
15
|
-
required,
|
|
16
|
-
label,
|
|
17
|
-
shouldUnregister = false,
|
|
18
|
-
validate,
|
|
19
|
-
productIcon,
|
|
20
|
-
illustration,
|
|
21
|
-
"aria-label": ariaLabel,
|
|
22
|
-
...props
|
|
23
|
-
}) => {
|
|
24
|
-
const {
|
|
25
|
-
field,
|
|
26
|
-
fieldState: {
|
|
27
|
-
error
|
|
28
|
-
}
|
|
29
|
-
} = reactHookForm.useController({
|
|
30
|
-
control,
|
|
31
|
-
name,
|
|
32
|
-
rules: {
|
|
33
|
-
required,
|
|
34
|
-
validate
|
|
35
|
-
},
|
|
36
|
-
shouldUnregister
|
|
37
|
-
});
|
|
38
|
-
const isChecked = type === "checkbox" && Array.isArray(field.value) && value ? (field.value ?? []).includes(value) : field.value === value;
|
|
39
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectableCard, { ...props, ...productIcon ? {
|
|
40
|
-
productIcon
|
|
41
|
-
} : {
|
|
42
|
-
illustration
|
|
43
|
-
}, ...label ? {
|
|
44
|
-
label
|
|
45
|
-
} : {
|
|
46
|
-
"aria-label": ariaLabel
|
|
47
|
-
}, checked: isChecked, isError: !!error, name: field.name, onBlur: (event) => {
|
|
48
|
-
field.onBlur();
|
|
49
|
-
onBlur?.(event);
|
|
50
|
-
}, onChange: (event) => {
|
|
51
|
-
if (type === "checkbox") {
|
|
52
|
-
const fieldValue = field.value ?? [];
|
|
53
|
-
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
54
|
-
field.onChange(fieldValue?.filter((currentValue) => currentValue !== event.currentTarget.value));
|
|
55
|
-
} else {
|
|
56
|
-
field.onChange([...fieldValue, event.currentTarget.value]);
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
field.onChange(event);
|
|
60
|
-
}
|
|
61
|
-
onChange?.(event.currentTarget.value);
|
|
62
|
-
}, onFocus: (event) => {
|
|
63
|
-
onFocus?.(event);
|
|
64
|
-
}, type, value: value ?? "" });
|
|
65
|
-
};
|
|
66
|
-
exports.SelectableCardField = SelectableCardField;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const reactHookForm = require("react-hook-form");
|
|
7
|
-
const index = require("../../providers/ErrorContext/index.cjs");
|
|
8
|
-
const SelectableCardGroupField = ({
|
|
9
|
-
legend = "",
|
|
10
|
-
control,
|
|
11
|
-
name,
|
|
12
|
-
onChange,
|
|
13
|
-
required = false,
|
|
14
|
-
error: customError,
|
|
15
|
-
columns = 1,
|
|
16
|
-
type = "radio",
|
|
17
|
-
shouldUnregister = false,
|
|
18
|
-
validate,
|
|
19
|
-
...props
|
|
20
|
-
}) => {
|
|
21
|
-
const {
|
|
22
|
-
getError
|
|
23
|
-
} = index.useErrors();
|
|
24
|
-
const {
|
|
25
|
-
field,
|
|
26
|
-
fieldState: {
|
|
27
|
-
error
|
|
28
|
-
}
|
|
29
|
-
} = reactHookForm.useController({
|
|
30
|
-
control,
|
|
31
|
-
name,
|
|
32
|
-
rules: {
|
|
33
|
-
required,
|
|
34
|
-
validate
|
|
35
|
-
},
|
|
36
|
-
shouldUnregister
|
|
37
|
-
});
|
|
38
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectableCardGroup, { ...props, columns, error: getError({
|
|
39
|
-
label: legend
|
|
40
|
-
}, error) ?? customError, legend, name, onChange: (event) => {
|
|
41
|
-
if (type === "checkbox") {
|
|
42
|
-
const fieldValue = field.value ?? [];
|
|
43
|
-
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
44
|
-
field.onChange(fieldValue?.filter((currentValue) => currentValue !== event.currentTarget.value));
|
|
45
|
-
} else {
|
|
46
|
-
field.onChange([...fieldValue, event.currentTarget.value]);
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
field.onChange(event);
|
|
50
|
-
}
|
|
51
|
-
onChange?.(event.currentTarget.value);
|
|
52
|
-
}, required, type, value: field.value });
|
|
53
|
-
};
|
|
54
|
-
SelectableCardGroupField.Card = ui.SelectableCardGroup.Card;
|
|
55
|
-
exports.SelectableCardGroupField = SelectableCardGroupField;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const reactHookForm = require("react-hook-form");
|
|
7
|
-
const index = require("../../providers/ErrorContext/index.cjs");
|
|
8
|
-
const SelectableCardOptionGroupField = ({
|
|
9
|
-
legend = "",
|
|
10
|
-
control,
|
|
11
|
-
name,
|
|
12
|
-
optionName,
|
|
13
|
-
onChange,
|
|
14
|
-
onChangeOption,
|
|
15
|
-
required = false,
|
|
16
|
-
children,
|
|
17
|
-
error: customError,
|
|
18
|
-
shouldUnregister = false,
|
|
19
|
-
validate,
|
|
20
|
-
...props
|
|
21
|
-
}) => {
|
|
22
|
-
const {
|
|
23
|
-
getError
|
|
24
|
-
} = index.useErrors();
|
|
25
|
-
const {
|
|
26
|
-
field,
|
|
27
|
-
fieldState: {
|
|
28
|
-
error
|
|
29
|
-
}
|
|
30
|
-
} = reactHookForm.useController({
|
|
31
|
-
control,
|
|
32
|
-
name,
|
|
33
|
-
rules: {
|
|
34
|
-
required,
|
|
35
|
-
validate
|
|
36
|
-
},
|
|
37
|
-
shouldUnregister
|
|
38
|
-
});
|
|
39
|
-
const {
|
|
40
|
-
field: optionField
|
|
41
|
-
} = reactHookForm.useController({
|
|
42
|
-
name: optionName ?? `${name}Option`,
|
|
43
|
-
rules: {
|
|
44
|
-
required
|
|
45
|
-
},
|
|
46
|
-
shouldUnregister
|
|
47
|
-
});
|
|
48
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectableCardOptionGroup, { error: getError({
|
|
49
|
-
label: legend
|
|
50
|
-
}, error) ?? customError, legend, name, onChange: (event) => {
|
|
51
|
-
field.onChange(event);
|
|
52
|
-
onChange?.(event);
|
|
53
|
-
}, onChangeOption: (value) => {
|
|
54
|
-
optionField.onChange(value);
|
|
55
|
-
onChangeOption?.(value);
|
|
56
|
-
}, optionValue: String(optionField.value), required, value: field.value, ...props, children });
|
|
57
|
-
};
|
|
58
|
-
SelectableCardOptionGroupField.Option = ui.SelectableCardOptionGroup.Option;
|
|
59
|
-
exports.SelectableCardOptionGroupField = SelectableCardOptionGroupField;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const react = require("react");
|
|
7
|
-
const reactHookForm = require("react-hook-form");
|
|
8
|
-
const index = require("../../providers/ErrorContext/index.cjs");
|
|
9
|
-
const SliderField = ({
|
|
10
|
-
name,
|
|
11
|
-
control,
|
|
12
|
-
shouldUnregister,
|
|
13
|
-
max,
|
|
14
|
-
min,
|
|
15
|
-
required,
|
|
16
|
-
validate,
|
|
17
|
-
onBlur,
|
|
18
|
-
onChange,
|
|
19
|
-
label,
|
|
20
|
-
value,
|
|
21
|
-
defaultValue,
|
|
22
|
-
options,
|
|
23
|
-
"aria-label": ariaLabel,
|
|
24
|
-
...props
|
|
25
|
-
}) => {
|
|
26
|
-
const {
|
|
27
|
-
getError
|
|
28
|
-
} = index.useErrors();
|
|
29
|
-
const {
|
|
30
|
-
field,
|
|
31
|
-
fieldState: {
|
|
32
|
-
error
|
|
33
|
-
}
|
|
34
|
-
} = reactHookForm.useController({
|
|
35
|
-
control,
|
|
36
|
-
name,
|
|
37
|
-
rules: {
|
|
38
|
-
max,
|
|
39
|
-
min,
|
|
40
|
-
required,
|
|
41
|
-
validate
|
|
42
|
-
},
|
|
43
|
-
shouldUnregister
|
|
44
|
-
});
|
|
45
|
-
const finalValue = react.useMemo(() => {
|
|
46
|
-
if (options && field.value) {
|
|
47
|
-
if (!Array.isArray(field.value)) {
|
|
48
|
-
const processedValue = options.map((option) => option.value).indexOf(field.value);
|
|
49
|
-
return processedValue;
|
|
50
|
-
}
|
|
51
|
-
if (Array.isArray(field.value)) {
|
|
52
|
-
const processedValue = field.value.map((val) => options.map((option) => option.value).indexOf(val));
|
|
53
|
-
return processedValue;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return field.value;
|
|
57
|
-
}, [field.value, options]);
|
|
58
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Slider, { "aria-label": ariaLabel, error: getError({
|
|
59
|
-
label: label ?? ariaLabel ?? name,
|
|
60
|
-
max,
|
|
61
|
-
min
|
|
62
|
-
}, error), label, max, min, name: field.name, onBlur: (event) => {
|
|
63
|
-
field.onBlur();
|
|
64
|
-
onBlur?.(event);
|
|
65
|
-
}, onChange: (newValue) => {
|
|
66
|
-
if (options) {
|
|
67
|
-
const processedValue = !Array.isArray(newValue) ? options[newValue]?.value : newValue.map((val) => val ? options[val]?.value : options[0]?.value);
|
|
68
|
-
field.onChange(processedValue);
|
|
69
|
-
onChange?.(processedValue);
|
|
70
|
-
} else {
|
|
71
|
-
field.onChange(newValue);
|
|
72
|
-
onChange?.(newValue);
|
|
73
|
-
}
|
|
74
|
-
}, options, required, value: finalValue, ...props });
|
|
75
|
-
};
|
|
76
|
-
exports.SliderField = SliderField;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const reactHookForm = require("react-hook-form");
|
|
7
|
-
const Submit = ({
|
|
8
|
-
children,
|
|
9
|
-
className,
|
|
10
|
-
disabled = false,
|
|
11
|
-
size,
|
|
12
|
-
variant = "filled",
|
|
13
|
-
sentiment = "primary",
|
|
14
|
-
tooltip,
|
|
15
|
-
fullWidth,
|
|
16
|
-
onClick
|
|
17
|
-
}) => {
|
|
18
|
-
const {
|
|
19
|
-
isSubmitting,
|
|
20
|
-
isValid
|
|
21
|
-
} = reactHookForm.useFormState();
|
|
22
|
-
const isDisabled = disabled || isSubmitting || !isValid;
|
|
23
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { className, disabled: isDisabled, fullWidth, isLoading: isSubmitting, onClick, sentiment, size, tooltip, type: "submit", variant, children });
|
|
24
|
-
};
|
|
25
|
-
exports.Submit = Submit;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const reactHookForm = require("react-hook-form");
|
|
7
|
-
const SubmitErrorAlert = ({
|
|
8
|
-
className
|
|
9
|
-
}) => {
|
|
10
|
-
const {
|
|
11
|
-
errors
|
|
12
|
-
} = reactHookForm.useFormState();
|
|
13
|
-
return errors?.root?.["submit"]?.message ? /* @__PURE__ */ jsxRuntime.jsx(ui.Alert, { className, sentiment: "danger", children: errors.root["submit"].message }) : null;
|
|
14
|
-
};
|
|
15
|
-
exports.SubmitErrorAlert = SubmitErrorAlert;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const reactHookForm = require("react-hook-form");
|
|
7
|
-
const SwitchButtonField = ({
|
|
8
|
-
name,
|
|
9
|
-
size,
|
|
10
|
-
control,
|
|
11
|
-
shouldUnregister,
|
|
12
|
-
onBlur,
|
|
13
|
-
onChange,
|
|
14
|
-
onFocus,
|
|
15
|
-
tooltip,
|
|
16
|
-
className,
|
|
17
|
-
...props
|
|
18
|
-
}) => {
|
|
19
|
-
const {
|
|
20
|
-
field
|
|
21
|
-
} = reactHookForm.useController({
|
|
22
|
-
control,
|
|
23
|
-
name,
|
|
24
|
-
shouldUnregister
|
|
25
|
-
});
|
|
26
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.SwitchButton, { ...props, className, name, onBlur: (event) => {
|
|
27
|
-
field.onBlur();
|
|
28
|
-
onBlur?.(event);
|
|
29
|
-
}, onChange: (event) => {
|
|
30
|
-
field.onChange(event);
|
|
31
|
-
onChange?.(event.target);
|
|
32
|
-
}, onFocus, size, tooltip, value: field.value });
|
|
33
|
-
};
|
|
34
|
-
SwitchButtonField.Option = ui.SwitchButton.Option;
|
|
35
|
-
exports.SwitchButtonField = SwitchButtonField;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const reactHookForm = require("react-hook-form");
|
|
7
|
-
const validateRegex = require("../../utils/validateRegex.cjs");
|
|
8
|
-
const index = require("../../providers/ErrorContext/index.cjs");
|
|
9
|
-
const TagInputField = ({
|
|
10
|
-
regex: regexes,
|
|
11
|
-
control,
|
|
12
|
-
name,
|
|
13
|
-
onChange,
|
|
14
|
-
required,
|
|
15
|
-
shouldUnregister = false,
|
|
16
|
-
label,
|
|
17
|
-
validate,
|
|
18
|
-
"aria-label": ariaLabel,
|
|
19
|
-
...props
|
|
20
|
-
}) => {
|
|
21
|
-
const {
|
|
22
|
-
getError
|
|
23
|
-
} = index.useErrors();
|
|
24
|
-
const {
|
|
25
|
-
field,
|
|
26
|
-
fieldState: {
|
|
27
|
-
error
|
|
28
|
-
}
|
|
29
|
-
} = reactHookForm.useController({
|
|
30
|
-
control,
|
|
31
|
-
name,
|
|
32
|
-
rules: {
|
|
33
|
-
required,
|
|
34
|
-
shouldUnregister,
|
|
35
|
-
validate: {
|
|
36
|
-
...regexes ? {
|
|
37
|
-
pattern: (value) => value.every((val) => validateRegex.validateRegex(val, regexes))
|
|
38
|
-
} : {},
|
|
39
|
-
...validate
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.TagInput, { ...props, "aria-label": ariaLabel, error: getError({
|
|
44
|
-
label: label ?? ariaLabel ?? name,
|
|
45
|
-
regex: regexes
|
|
46
|
-
}, error), label, name: field.name, onChange: (newTags) => {
|
|
47
|
-
field.onChange(newTags);
|
|
48
|
-
onChange?.(newTags);
|
|
49
|
-
}, value: field.value });
|
|
50
|
-
};
|
|
51
|
-
exports.TagInputField = TagInputField;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const reactHookForm = require("react-hook-form");
|
|
7
|
-
const validateRegex = require("../../utils/validateRegex.cjs");
|
|
8
|
-
const index = require("../../providers/ErrorContext/index.cjs");
|
|
9
|
-
const TextAreaField = ({
|
|
10
|
-
control,
|
|
11
|
-
label,
|
|
12
|
-
onChange,
|
|
13
|
-
minLength,
|
|
14
|
-
maxLength,
|
|
15
|
-
name,
|
|
16
|
-
onBlur,
|
|
17
|
-
onKeyDown,
|
|
18
|
-
required,
|
|
19
|
-
regex: regexes,
|
|
20
|
-
submitOnEnter,
|
|
21
|
-
validate,
|
|
22
|
-
"aria-label": ariaLabel,
|
|
23
|
-
...props
|
|
24
|
-
}) => {
|
|
25
|
-
const {
|
|
26
|
-
getError
|
|
27
|
-
} = index.useErrors();
|
|
28
|
-
const {
|
|
29
|
-
field,
|
|
30
|
-
fieldState: {
|
|
31
|
-
error
|
|
32
|
-
}
|
|
33
|
-
} = reactHookForm.useController({
|
|
34
|
-
control,
|
|
35
|
-
name,
|
|
36
|
-
rules: {
|
|
37
|
-
maxLength,
|
|
38
|
-
minLength,
|
|
39
|
-
required,
|
|
40
|
-
validate: {
|
|
41
|
-
...regexes ? {
|
|
42
|
-
pattern: (value) => validateRegex.validateRegex(value, regexes)
|
|
43
|
-
} : {},
|
|
44
|
-
...validate
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
const onKeyDownHandler = (event) => {
|
|
49
|
-
if (submitOnEnter && event.key === "Enter" && !event.shiftKey) {
|
|
50
|
-
event.preventDefault();
|
|
51
|
-
event.stopPropagation();
|
|
52
|
-
const {
|
|
53
|
-
form
|
|
54
|
-
} = event.currentTarget;
|
|
55
|
-
if (form) {
|
|
56
|
-
const submitEvent = new Event("submit", {
|
|
57
|
-
bubbles: true,
|
|
58
|
-
cancelable: true
|
|
59
|
-
});
|
|
60
|
-
form.dispatchEvent(submitEvent);
|
|
61
|
-
}
|
|
62
|
-
} else {
|
|
63
|
-
onKeyDown?.(event);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.TextArea, { ...props, error: getError({
|
|
67
|
-
label: label ?? ariaLabel ?? name,
|
|
68
|
-
maxLength,
|
|
69
|
-
minLength,
|
|
70
|
-
regex: regexes,
|
|
71
|
-
value: field.value
|
|
72
|
-
}, error), maxLength, minLength, name, onBlur: (event) => {
|
|
73
|
-
onBlur?.(event);
|
|
74
|
-
field.onBlur();
|
|
75
|
-
}, onChange: (event) => {
|
|
76
|
-
field.onChange(event);
|
|
77
|
-
onChange?.(event);
|
|
78
|
-
}, onKeyDown: onKeyDownHandler, required, value: field.value, ...label ? {
|
|
79
|
-
label
|
|
80
|
-
} : {
|
|
81
|
-
"aria-label": ariaLabel
|
|
82
|
-
} });
|
|
83
|
-
};
|
|
84
|
-
exports.TextAreaField = TextAreaField;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const reactHookForm = require("react-hook-form");
|
|
7
|
-
const validateRegex = require("../../utils/validateRegex.cjs");
|
|
8
|
-
const index = require("../../providers/ErrorContext/index.cjs");
|
|
9
|
-
const TextInputField = ({
|
|
10
|
-
regex: regexes,
|
|
11
|
-
onChange,
|
|
12
|
-
label,
|
|
13
|
-
required = false,
|
|
14
|
-
name,
|
|
15
|
-
onBlur,
|
|
16
|
-
minLength,
|
|
17
|
-
maxLength,
|
|
18
|
-
"aria-label": ariaLabel,
|
|
19
|
-
shouldUnregister,
|
|
20
|
-
validate,
|
|
21
|
-
control,
|
|
22
|
-
...props
|
|
23
|
-
}) => {
|
|
24
|
-
const {
|
|
25
|
-
getError
|
|
26
|
-
} = index.useErrors();
|
|
27
|
-
const {
|
|
28
|
-
field,
|
|
29
|
-
fieldState: {
|
|
30
|
-
error
|
|
31
|
-
}
|
|
32
|
-
} = reactHookForm.useController({
|
|
33
|
-
control,
|
|
34
|
-
name,
|
|
35
|
-
rules: {
|
|
36
|
-
maxLength,
|
|
37
|
-
minLength,
|
|
38
|
-
required,
|
|
39
|
-
validate: {
|
|
40
|
-
...regexes ? {
|
|
41
|
-
pattern: (value) => validateRegex.validateRegex(value, regexes)
|
|
42
|
-
} : {},
|
|
43
|
-
...validate
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
shouldUnregister
|
|
47
|
-
});
|
|
48
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.TextInput, { ...props, "aria-label": ariaLabel, error: getError({
|
|
49
|
-
label: label ?? ariaLabel ?? name,
|
|
50
|
-
maxLength,
|
|
51
|
-
minLength,
|
|
52
|
-
regex: regexes,
|
|
53
|
-
value: field.value
|
|
54
|
-
}, error), label, maxLength, minLength, name, onBlur: (event) => {
|
|
55
|
-
onBlur?.(event);
|
|
56
|
-
field.onBlur();
|
|
57
|
-
}, onChange: (event) => {
|
|
58
|
-
field.onChange(event);
|
|
59
|
-
onChange?.(event.target.value);
|
|
60
|
-
}, required, value: field.value === void 0 ? "" : field.value });
|
|
61
|
-
};
|
|
62
|
-
exports.TextInputField = TextInputField;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const ui = require("@ultraviolet/ui");
|
|
6
|
-
const reactHookForm = require("react-hook-form");
|
|
7
|
-
const index = require("../../providers/ErrorContext/index.cjs");
|
|
8
|
-
const TimeInputField = ({
|
|
9
|
-
onChange,
|
|
10
|
-
label,
|
|
11
|
-
required = false,
|
|
12
|
-
name,
|
|
13
|
-
onBlur,
|
|
14
|
-
"aria-label": ariaLabel,
|
|
15
|
-
shouldUnregister,
|
|
16
|
-
control,
|
|
17
|
-
...props
|
|
18
|
-
}) => {
|
|
19
|
-
const {
|
|
20
|
-
getError
|
|
21
|
-
} = index.useErrors();
|
|
22
|
-
const {
|
|
23
|
-
field,
|
|
24
|
-
fieldState: {
|
|
25
|
-
error
|
|
26
|
-
}
|
|
27
|
-
} = reactHookForm.useController({
|
|
28
|
-
control,
|
|
29
|
-
name,
|
|
30
|
-
rules: {
|
|
31
|
-
required
|
|
32
|
-
},
|
|
33
|
-
shouldUnregister
|
|
34
|
-
});
|
|
35
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.TimeInput, { ...props, error: getError({
|
|
36
|
-
label: label ?? ariaLabel ?? name,
|
|
37
|
-
value: field.value
|
|
38
|
-
}, error), label, onBlur: (event) => {
|
|
39
|
-
onBlur?.(event);
|
|
40
|
-
field.onBlur();
|
|
41
|
-
}, onChange: (value) => {
|
|
42
|
-
field.onChange(value);
|
|
43
|
-
onChange?.(value);
|
|
44
|
-
}, required, value: field.value });
|
|
45
|
-
};
|
|
46
|
-
exports.TimeInputField = TimeInputField;
|