@ultraviolet/form 6.2.1 → 6.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/asyncToGenerator.js +5 -3
  2. package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js +19 -0
  3. package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/objectSpread2.js +8 -4
  4. package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.js +22 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutPropertiesLoose.js +17 -0
  6. package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/toPrimitive.js +8 -4
  7. package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.js +17 -0
  8. package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/typeof.js +5 -3
  9. package/dist/_virtual/_rolldown/runtime.js +2 -1
  10. package/dist/components/CheckboxField/index.js +59 -51
  11. package/dist/components/CheckboxGroupField/index.js +67 -59
  12. package/dist/components/DateInputField/index.js +94 -84
  13. package/dist/components/FileInputField/index.js +64 -60
  14. package/dist/components/Form/defaultErrors.js +25 -21
  15. package/dist/components/Form/index.d.ts +2 -1
  16. package/dist/components/Form/index.d.ts.map +1 -1
  17. package/dist/components/Form/index.js +41 -31
  18. package/dist/components/KeyValueField/index.js +88 -86
  19. package/dist/components/NumberInputField/index.js +66 -57
  20. package/dist/components/RadioField/index.js +65 -57
  21. package/dist/components/RadioGroupField/index.js +50 -42
  22. package/dist/components/SelectInputField/index.js +56 -48
  23. package/dist/components/SelectableCardField/index.js +64 -58
  24. package/dist/components/SelectableCardGroupField/SelectableCardGroupField.js +56 -48
  25. package/dist/components/SelectableCardGroupField/index.js +9 -0
  26. package/dist/components/SelectableCardOptionGroupField/index.js +61 -53
  27. package/dist/components/SliderField/index.js +83 -75
  28. package/dist/components/Submit/index.js +22 -18
  29. package/dist/components/SubmitErrorAlert/index.js +15 -11
  30. package/dist/components/SwitchButtonField/index.js +47 -41
  31. package/dist/components/TagInputField/index.js +54 -45
  32. package/dist/components/TextAreaField/index.js +78 -72
  33. package/dist/components/TextInputField/index.js +67 -61
  34. package/dist/components/TimeInputField/index.js +50 -46
  35. package/dist/components/ToggleField/index.js +63 -55
  36. package/dist/components/ToggleGroupField/index.js +53 -45
  37. package/dist/components/UnitInputField/index.js +61 -53
  38. package/dist/components/VerificationCodeField/index.js +47 -39
  39. package/dist/components/compositions/CodeEditorField/index.js +48 -42
  40. package/dist/components/compositions/CustomerSatisfactionField/index.js +17 -13
  41. package/dist/components/compositions/OfferListField/index.js +54 -48
  42. package/dist/components/compositions/OptionSelectorField/index.js +53 -45
  43. package/dist/components/compositions/PlansField/index.js +25 -21
  44. package/dist/components/compositions/index.js +17 -5
  45. package/dist/components/index.js +59 -0
  46. package/dist/hooks/index.js +9 -0
  47. package/dist/hooks/useOnFieldChange.js +25 -24
  48. package/dist/index.js +14 -1
  49. package/dist/providers/ErrorContext/index.js +28 -24
  50. package/dist/providers/index.js +11 -0
  51. package/dist/utils/validateRegex.js +7 -3
  52. package/dist/validators/isInteger.js +11 -7
  53. package/dist/validators/maxDate.js +7 -3
  54. package/dist/validators/minDate.js +7 -3
  55. package/package.json +6 -6
  56. package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/defineProperty.js +0 -15
  57. package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/objectWithoutProperties.js +0 -18
  58. package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/objectWithoutPropertiesLoose.js +0 -15
  59. package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/toPropertyKey.js +0 -12
@@ -1,71 +1,75 @@
1
1
  'use client';
2
- import { __name } from "../../_virtual/_rolldown/runtime.js";
3
- import { _objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.114.0/helpers/objectWithoutProperties.js";
4
- import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.114.0/helpers/objectSpread2.js";
2
+ import { __esmMin, __name } from "../../_virtual/_rolldown/runtime.js";
3
+ import { _objectWithoutProperties, init_objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.js";
4
+ import { _objectSpread2, init_objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.js";
5
5
  import { useErrors } from "../../providers/ErrorContext/index.js";
6
+ import { init_providers } from "../../providers/index.js";
6
7
  import { FileInput } from "@ultraviolet/ui";
7
8
  import { useController } from "react-hook-form";
8
9
  import { jsx } from "react/jsx-runtime";
9
10
 
10
11
  //#region src/components/FileInputField/index.tsx
11
- const _excluded = [
12
- "onChange",
13
- "label",
14
- "required",
15
- "name",
16
- "shouldUnregister",
17
- "control",
18
- "variant",
19
- "size",
20
- "title",
21
- "bottom",
22
- "children"
23
- ];
24
- /**
25
- * This component offers a form field based on Ultraviolet UI FileInput component
26
- * @experimental This component is experimental and may be subject to breaking changes in the future.
27
- */
28
- const FileInputFieldBase = (_ref) => {
29
- let { onChange, label, required = false, name, shouldUnregister, control, variant, size, title, bottom, children } = _ref;
30
- let props = _objectWithoutProperties(_ref, _excluded);
31
- const { getError } = useErrors();
32
- const { field, fieldState: { error } } = useController({
33
- control,
34
- name,
35
- rules: { required },
36
- shouldUnregister
12
+ var _excluded, FileInputFieldBase, FileInputField;
13
+ var init_FileInputField = __esmMin(() => {
14
+ init_providers();
15
+ init_objectWithoutProperties();
16
+ init_objectSpread2();
17
+ _excluded = [
18
+ "onChange",
19
+ "label",
20
+ "required",
21
+ "name",
22
+ "shouldUnregister",
23
+ "control",
24
+ "variant",
25
+ "size",
26
+ "title",
27
+ "bottom",
28
+ "children"
29
+ ];
30
+ FileInputFieldBase = (_ref) => {
31
+ let { onChange, label, required = false, name, shouldUnregister, control, variant, size, title, bottom, children } = _ref;
32
+ let props = _objectWithoutProperties(_ref, _excluded);
33
+ const { getError } = useErrors();
34
+ const { field, fieldState: { error } } = useController({
35
+ control,
36
+ name,
37
+ rules: { required },
38
+ shouldUnregister
39
+ });
40
+ if (variant === "overlay" && children) return /* @__PURE__ */ jsx(FileInput, _objectSpread2(_objectSpread2({}, props), {}, {
41
+ error: getError({ label }, error),
42
+ label,
43
+ onChangeFiles: (files) => {
44
+ field.onChange(files);
45
+ onChange === null || onChange === void 0 || onChange(files);
46
+ },
47
+ required,
48
+ title,
49
+ variant: "overlay",
50
+ children: typeof children === "function" ? (inputId, inputRef) => children(inputId, inputRef) : children
51
+ }));
52
+ return /* @__PURE__ */ jsx(FileInput, _objectSpread2(_objectSpread2({}, props), {}, {
53
+ bottom,
54
+ error: getError({ label }, error),
55
+ label,
56
+ onChangeFiles: (files) => {
57
+ field.onChange(files);
58
+ onChange === null || onChange === void 0 || onChange(files);
59
+ },
60
+ required,
61
+ size,
62
+ title,
63
+ variant: "dropzone",
64
+ children: typeof children === "function" ? (inputId, inputRef) => children(inputId, inputRef) : children
65
+ }));
66
+ };
67
+ FileInputField = Object.assign(FileInputFieldBase, {
68
+ Button: FileInput.Button,
69
+ List: FileInput.List
37
70
  });
38
- if (variant === "overlay" && children) return /* @__PURE__ */ jsx(FileInput, _objectSpread2(_objectSpread2({}, props), {}, {
39
- error: getError({ label }, error),
40
- label,
41
- onChangeFiles: (files) => {
42
- field.onChange(files);
43
- onChange === null || onChange === void 0 || onChange(files);
44
- },
45
- required,
46
- title,
47
- variant: "overlay",
48
- children: typeof children === "function" ? (inputId, inputRef) => children(inputId, inputRef) : children
49
- }));
50
- return /* @__PURE__ */ jsx(FileInput, _objectSpread2(_objectSpread2({}, props), {}, {
51
- bottom,
52
- error: getError({ label }, error),
53
- label,
54
- onChangeFiles: (files) => {
55
- field.onChange(files);
56
- onChange === null || onChange === void 0 || onChange(files);
57
- },
58
- required,
59
- size,
60
- title,
61
- variant: "dropzone",
62
- children: typeof children === "function" ? (inputId, inputRef) => children(inputId, inputRef) : children
63
- }));
64
- };
65
- const FileInputField = Object.assign(FileInputFieldBase, {
66
- Button: FileInput.Button,
67
- List: FileInput.List
68
71
  });
69
72
 
70
73
  //#endregion
71
- export { FileInputField };
74
+ init_FileInputField();
75
+ export { FileInputField, init_FileInputField };
@@ -1,25 +1,29 @@
1
- import { __name } from "../../_virtual/_rolldown/runtime.js";
1
+ import { __esmMin, __name } from "../../_virtual/_rolldown/runtime.js";
2
2
 
3
3
  //#region src/components/Form/defaultErrors.ts
4
- const defaultErrors = {
5
- deps: () => "",
6
- disabled: () => "",
7
- max: () => "",
8
- maxDate: () => "",
9
- maxLength: () => "",
10
- min: () => "",
11
- minLength: () => "",
12
- onBlur: () => "",
13
- onChange: () => "",
14
- pattern: () => "",
15
- required: () => "",
16
- setValueAs: () => "",
17
- shouldUnregister: () => "",
18
- validate: () => "",
19
- value: () => "",
20
- valueAsDate: () => "",
21
- valueAsNumber: () => ""
22
- };
4
+ var defaultErrors;
5
+ var init_defaultErrors = __esmMin(() => {
6
+ defaultErrors = {
7
+ deps: () => "",
8
+ disabled: () => "",
9
+ max: () => "",
10
+ maxDate: () => "",
11
+ maxLength: () => "",
12
+ min: () => "",
13
+ minLength: () => "",
14
+ onBlur: () => "",
15
+ onChange: () => "",
16
+ pattern: () => "",
17
+ required: () => "",
18
+ setValueAs: () => "",
19
+ shouldUnregister: () => "",
20
+ validate: () => "",
21
+ value: () => "",
22
+ valueAsDate: () => "",
23
+ valueAsNumber: () => ""
24
+ };
25
+ });
23
26
 
24
27
  //#endregion
25
- export { defaultErrors };
28
+ init_defaultErrors();
29
+ export { defaultErrors, init_defaultErrors };
@@ -8,7 +8,8 @@ type FormProps<TFieldValues extends FieldValues> = {
8
8
  name?: string;
9
9
  onSubmit: (data: TFieldValues) => Promise<OnSubmitReturn> | OnSubmitReturn;
10
10
  methods: UseFormReturn<TFieldValues>;
11
+ 'aria-label'?: string;
11
12
  };
12
- export declare const Form: <TFieldValues extends FieldValues>({ children, methods, errors, onSubmit, name, }: FormProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const Form: <TFieldValues extends FieldValues>({ children, methods, errors, onSubmit, name, 'aria-label': ariaLabel, }: FormProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
13
14
  export {};
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAGjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7C,KAAK,cAAc,GACf,MAAM,GACN,IAAI,GACJ,SAAS,GAET,IAAI,CAAA;AAER,KAAK,SAAS,CAAC,YAAY,SAAS,WAAW,IAAI;IACjD,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,UAAU,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAAA;IAC1E,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;CACrC,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,YAAY,yIAqChC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAGjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7C,KAAK,cAAc,GACf,MAAM,GACN,IAAI,GACJ,SAAS,GAET,IAAI,CAAA;AAER,KAAK,SAAS,CAAC,YAAY,SAAS,WAAW,IAAI;IACjD,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,UAAU,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAAA;IAC1E,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;IACpC,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,YAAY,kKAuChC,CAAA"}
@@ -1,41 +1,51 @@
1
1
  'use client';
2
- import { __name } from "../../_virtual/_rolldown/runtime.js";
3
- import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.114.0/helpers/objectSpread2.js";
2
+ import { __esmMin, __name } from "../../_virtual/_rolldown/runtime.js";
3
+ import { _objectSpread2, init_objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.js";
4
4
  import { ErrorProvider } from "../../providers/ErrorContext/index.js";
5
- import { defaultErrors } from "./defaultErrors.js";
6
- import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.114.0/helpers/asyncToGenerator.js";
5
+ import { init_providers } from "../../providers/index.js";
6
+ import { defaultErrors, init_defaultErrors } from "./defaultErrors.js";
7
+ import { _asyncToGenerator, init_asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.115.0/helpers/asyncToGenerator.js";
7
8
  import { FormProvider } from "react-hook-form";
8
9
  import { jsx } from "react/jsx-runtime";
9
10
 
10
11
  //#region src/components/Form/index.tsx
11
- const Form = ({ children, methods, errors, onSubmit, name }) => {
12
- const handleSubmit = methods.handleSubmit(function() {
13
- var _ref = _asyncToGenerator(function* (values) {
14
- const result = yield onSubmit(values);
15
- if (result) methods.setError("root.submit", {
16
- message: result,
17
- type: "custom"
12
+ var Form;
13
+ var init_Form = __esmMin(() => {
14
+ init_providers();
15
+ init_defaultErrors();
16
+ init_asyncToGenerator();
17
+ init_objectSpread2();
18
+ Form = ({ children, methods, errors, onSubmit, name, "aria-label": ariaLabel }) => {
19
+ const handleSubmit = methods.handleSubmit(function() {
20
+ var _ref = _asyncToGenerator(function* (values) {
21
+ const result = yield onSubmit(values);
22
+ if (result) methods.setError("root.submit", {
23
+ message: result,
24
+ type: "custom"
25
+ });
18
26
  });
19
- });
20
- return function(_x) {
21
- return _ref.apply(this, arguments);
22
- };
23
- }());
24
- return /* @__PURE__ */ jsx(FormProvider, _objectSpread2(_objectSpread2({}, methods), {}, { children: /* @__PURE__ */ jsx(ErrorProvider, {
25
- errors: _objectSpread2(_objectSpread2({}, defaultErrors), errors),
26
- children: /* @__PURE__ */ jsx("form", {
27
- name,
28
- noValidate: true,
29
- onSubmit: (e) => {
30
- e.preventDefault();
31
- e.stopPropagation();
32
- handleSubmit(e).catch(() => null);
33
- },
34
- style: { display: "contents" },
35
- children
36
- })
37
- }) }));
38
- };
27
+ return function(_x) {
28
+ return _ref.apply(this, arguments);
29
+ };
30
+ }());
31
+ return /* @__PURE__ */ jsx(FormProvider, _objectSpread2(_objectSpread2({}, methods), {}, { children: /* @__PURE__ */ jsx(ErrorProvider, {
32
+ errors: _objectSpread2(_objectSpread2({}, defaultErrors), errors),
33
+ children: /* @__PURE__ */ jsx("form", {
34
+ "aria-label": ariaLabel,
35
+ name,
36
+ noValidate: true,
37
+ onSubmit: (e) => {
38
+ e.preventDefault();
39
+ e.stopPropagation();
40
+ handleSubmit(e).catch(() => null);
41
+ },
42
+ style: { display: "contents" },
43
+ children
44
+ })
45
+ }) }));
46
+ };
47
+ });
39
48
 
40
49
  //#endregion
50
+ init_Form();
41
51
  export { Form };
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- import { __name } from "../../_virtual/_rolldown/runtime.js";
3
- import { TextInputField } from "../TextInputField/index.js";
2
+ import { __esmMin, __name } from "../../_virtual/_rolldown/runtime.js";
3
+ import { TextInputField, init_TextInputField } from "../TextInputField/index.js";
4
4
  import { Button, Row, Stack } from "@ultraviolet/ui";
5
5
  import { useFieldArray, useFormContext } from "react-hook-form";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -8,90 +8,92 @@ import { DeleteIcon } from "@ultraviolet/icons/DeleteIcon";
8
8
  import { PlusIcon } from "@ultraviolet/icons/PlusIcon";
9
9
 
10
10
  //#region src/components/KeyValueField/index.tsx
11
- /**
12
- * A React component that allows users to manage key-value pairs
13
- */
14
- const KeyValueField = ({ name, inputKey, inputValue, addButton, maxSize = 100, readOnly = false, control, onChange, onBlur }) => {
15
- var _addButton$maxSizeRea;
16
- const { fields, append, remove } = useFieldArray({
17
- control,
18
- name
19
- });
20
- const { getValues } = useFormContext();
21
- const handleFieldChange = () => {
22
- onChange === null || onChange === void 0 || onChange(getValues(name));
23
- };
24
- const handleFieldBlur = () => {
25
- onBlur === null || onBlur === void 0 || onBlur(getValues(name));
26
- };
27
- const canAdd = fields.length !== void 0 && fields.length < maxSize;
28
- const maxSizeReachedTooltip = (_addButton$maxSizeRea = addButton.maxSizeReachedTooltip) !== null && _addButton$maxSizeRea !== void 0 ? _addButton$maxSizeRea : `Cannot add more than ${maxSize} elements`;
29
- return /* @__PURE__ */ jsxs(Stack, {
30
- gap: 3,
31
- children: [fields.length > 0 ? /* @__PURE__ */ jsx(Stack, {
11
+ var KeyValueField;
12
+ var init_KeyValueField = __esmMin(() => {
13
+ init_TextInputField();
14
+ KeyValueField = ({ name, inputKey, inputValue, addButton, maxSize = 100, readOnly = false, control, onChange, onBlur }) => {
15
+ var _addButton$maxSizeRea;
16
+ const { fields, append, remove } = useFieldArray({
17
+ control,
18
+ name
19
+ });
20
+ const { getValues } = useFormContext();
21
+ const handleFieldChange = () => {
22
+ onChange === null || onChange === void 0 || onChange(getValues(name));
23
+ };
24
+ const handleFieldBlur = () => {
25
+ onBlur === null || onBlur === void 0 || onBlur(getValues(name));
26
+ };
27
+ const canAdd = fields.length !== void 0 && fields.length < maxSize;
28
+ const maxSizeReachedTooltip = (_addButton$maxSizeRea = addButton.maxSizeReachedTooltip) !== null && _addButton$maxSizeRea !== void 0 ? _addButton$maxSizeRea : `Cannot add more than ${maxSize} elements`;
29
+ return /* @__PURE__ */ jsxs(Stack, {
32
30
  gap: 3,
33
- children: fields.map((field, index) => /* @__PURE__ */ jsxs(Row, {
34
- alignItems: "flex-end",
35
- gap: 2,
36
- templateColumns: "1fr 1fr auto",
37
- children: [
38
- /* @__PURE__ */ jsx(TextInputField, {
39
- label: inputKey.label,
40
- name: `${name}.${index}.key`,
41
- onBlur: handleFieldBlur,
42
- onChange: handleFieldChange,
43
- readOnly,
44
- regex: inputKey.regex,
45
- required: inputKey.required
46
- }),
47
- /* @__PURE__ */ jsx(TextInputField, {
48
- autoComplete: "off",
49
- label: inputValue.label,
50
- name: `${name}.${index}.value`,
51
- onBlur: handleFieldBlur,
52
- onChange: handleFieldChange,
53
- placeholder: inputValue.placeholder,
54
- readOnly,
55
- regex: inputValue.regex,
56
- required: inputValue.required,
57
- type: inputValue.type
58
- }),
59
- /* @__PURE__ */ jsx(Button, {
60
- "data-testid": `remove-button-${index}`,
61
- disabled: readOnly,
62
- onClick: () => {
63
- remove(index);
64
- handleFieldChange();
65
- },
66
- sentiment: "danger",
67
- size: "large",
68
- variant: "outlined",
69
- children: /* @__PURE__ */ jsx(DeleteIcon, {})
70
- })
71
- ]
72
- }, field.id))
73
- }) : null, /* @__PURE__ */ jsx(Stack, {
74
- direction: "row",
75
- justifyContent: "flex-start",
76
- children: /* @__PURE__ */ jsxs(Button, {
77
- "data-testid": "add-button",
78
- disabled: !canAdd || readOnly,
79
- fullWidth: addButton.fullWidth,
80
- onClick: () => {
81
- append({
82
- key: "",
83
- value: ""
84
- });
85
- handleFieldChange();
86
- },
87
- sentiment: "primary",
88
- tooltip: canAdd ? addButton.tooltip : maxSizeReachedTooltip,
89
- variant: "outlined",
90
- children: [/* @__PURE__ */ jsx(PlusIcon, {}), addButton.name]
91
- })
92
- })]
93
- });
94
- };
31
+ children: [fields.length > 0 ? /* @__PURE__ */ jsx(Stack, {
32
+ gap: 3,
33
+ children: fields.map((field, index) => /* @__PURE__ */ jsxs(Row, {
34
+ alignItems: "flex-end",
35
+ gap: 2,
36
+ templateColumns: "1fr 1fr auto",
37
+ children: [
38
+ /* @__PURE__ */ jsx(TextInputField, {
39
+ label: inputKey.label,
40
+ name: `${name}.${index}.key`,
41
+ onBlur: handleFieldBlur,
42
+ onChange: handleFieldChange,
43
+ readOnly,
44
+ regex: inputKey.regex,
45
+ required: inputKey.required
46
+ }),
47
+ /* @__PURE__ */ jsx(TextInputField, {
48
+ autoComplete: "off",
49
+ label: inputValue.label,
50
+ name: `${name}.${index}.value`,
51
+ onBlur: handleFieldBlur,
52
+ onChange: handleFieldChange,
53
+ placeholder: inputValue.placeholder,
54
+ readOnly,
55
+ regex: inputValue.regex,
56
+ required: inputValue.required,
57
+ type: inputValue.type
58
+ }),
59
+ /* @__PURE__ */ jsx(Button, {
60
+ "data-testid": `remove-button-${index}`,
61
+ disabled: readOnly,
62
+ onClick: () => {
63
+ remove(index);
64
+ handleFieldChange();
65
+ },
66
+ sentiment: "danger",
67
+ size: "large",
68
+ variant: "outlined",
69
+ children: /* @__PURE__ */ jsx(DeleteIcon, {})
70
+ })
71
+ ]
72
+ }, field.id))
73
+ }) : null, /* @__PURE__ */ jsx(Stack, {
74
+ direction: "row",
75
+ justifyContent: "flex-start",
76
+ children: /* @__PURE__ */ jsxs(Button, {
77
+ "data-testid": "add-button",
78
+ disabled: !canAdd || readOnly,
79
+ fullWidth: addButton.fullWidth,
80
+ onClick: () => {
81
+ append({
82
+ key: "",
83
+ value: ""
84
+ });
85
+ handleFieldChange();
86
+ },
87
+ sentiment: "primary",
88
+ tooltip: canAdd ? addButton.tooltip : maxSizeReachedTooltip,
89
+ variant: "outlined",
90
+ children: [/* @__PURE__ */ jsx(PlusIcon, {}), addButton.name]
91
+ })
92
+ })]
93
+ });
94
+ };
95
+ });
95
96
 
96
97
  //#endregion
97
- export { KeyValueField };
98
+ init_KeyValueField();
99
+ export { KeyValueField, init_KeyValueField };
@@ -1,69 +1,78 @@
1
1
  'use client';
2
- import { __name } from "../../_virtual/_rolldown/runtime.js";
3
- import { _objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.114.0/helpers/objectWithoutProperties.js";
4
- import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.114.0/helpers/objectSpread2.js";
2
+ import { __esmMin, __name } from "../../_virtual/_rolldown/runtime.js";
3
+ import { _objectWithoutProperties, init_objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.js";
4
+ import { _objectSpread2, init_objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.js";
5
5
  import { useErrors } from "../../providers/ErrorContext/index.js";
6
- import { isInteger } from "../../validators/isInteger.js";
6
+ import { init_providers } from "../../providers/index.js";
7
+ import { init_isInteger, isInteger } from "../../validators/isInteger.js";
7
8
  import { NumberInput } from "@ultraviolet/ui";
8
9
  import { useController } from "react-hook-form";
9
10
  import { jsx } from "react/jsx-runtime";
10
11
 
11
12
  //#region src/components/NumberInputField/index.tsx
12
- const _excluded = [
13
- "control",
14
- "max",
15
- "min",
16
- "name",
17
- "onChange",
18
- "onBlur",
19
- "step",
20
- "label",
21
- "aria-label",
22
- "required",
23
- "shouldUnregister",
24
- "validate"
25
- ];
26
- const NumberInputField = (_ref) => {
27
- var _ref2;
28
- let { control, max = Number.MAX_SAFE_INTEGER, min = 0, name, onChange, onBlur, step, label, "aria-label": ariaLabel, required, shouldUnregister = false, validate } = _ref;
29
- let props = _objectWithoutProperties(_ref, _excluded);
30
- const { getError } = useErrors();
31
- const { field, fieldState: { error } } = useController({
32
- control,
33
- name,
34
- rules: {
13
+ var _excluded, NumberInputField;
14
+ var init_NumberInputField = __esmMin(() => {
15
+ init_providers();
16
+ init_isInteger();
17
+ init_objectWithoutProperties();
18
+ init_objectSpread2();
19
+ _excluded = [
20
+ "control",
21
+ "max",
22
+ "min",
23
+ "name",
24
+ "onChange",
25
+ "onBlur",
26
+ "step",
27
+ "label",
28
+ "aria-label",
29
+ "required",
30
+ "shouldUnregister",
31
+ "validate"
32
+ ];
33
+ NumberInputField = (_ref) => {
34
+ var _ref2;
35
+ let { control, max = Number.MAX_SAFE_INTEGER, min = 0, name, onChange, onBlur, step, label, "aria-label": ariaLabel, required, shouldUnregister = false, validate } = _ref;
36
+ let props = _objectWithoutProperties(_ref, _excluded);
37
+ const { getError } = useErrors();
38
+ const { field, fieldState: { error } } = useController({
39
+ control,
40
+ name,
41
+ rules: {
42
+ max,
43
+ min,
44
+ required,
45
+ validate: _objectSpread2(_objectSpread2({}, validate), {}, { isInteger: isInteger(step) })
46
+ },
47
+ shouldUnregister
48
+ });
49
+ return /* @__PURE__ */ jsx(NumberInput, _objectSpread2(_objectSpread2({}, props), {}, {
50
+ "aria-label": ariaLabel,
51
+ error: getError({
52
+ isInteger: step,
53
+ label: (_ref2 = label !== null && label !== void 0 ? label : ariaLabel) !== null && _ref2 !== void 0 ? _ref2 : name,
54
+ max,
55
+ min
56
+ }, error),
57
+ label,
35
58
  max,
36
59
  min,
60
+ name: field.name,
61
+ onBlur: (event) => {
62
+ field.onBlur();
63
+ onBlur === null || onBlur === void 0 || onBlur(event);
64
+ },
65
+ onChange: (newValue) => {
66
+ field.onChange(newValue);
67
+ onChange === null || onChange === void 0 || onChange(newValue);
68
+ },
37
69
  required,
38
- validate: _objectSpread2(_objectSpread2({}, validate), {}, { isInteger: isInteger(step) })
39
- },
40
- shouldUnregister
41
- });
42
- return /* @__PURE__ */ jsx(NumberInput, _objectSpread2(_objectSpread2({}, props), {}, {
43
- "aria-label": ariaLabel,
44
- error: getError({
45
- isInteger: step,
46
- label: (_ref2 = label !== null && label !== void 0 ? label : ariaLabel) !== null && _ref2 !== void 0 ? _ref2 : name,
47
- max,
48
- min
49
- }, error),
50
- label,
51
- max,
52
- min,
53
- name: field.name,
54
- onBlur: (event) => {
55
- field.onBlur();
56
- onBlur === null || onBlur === void 0 || onBlur(event);
57
- },
58
- onChange: (newValue) => {
59
- field.onChange(newValue);
60
- onChange === null || onChange === void 0 || onChange(newValue);
61
- },
62
- required,
63
- step,
64
- value: field.value
65
- }));
66
- };
70
+ step,
71
+ value: field.value
72
+ }));
73
+ };
74
+ });
67
75
 
68
76
  //#endregion
69
- export { NumberInputField };
77
+ init_NumberInputField();
78
+ export { NumberInputField, init_NumberInputField };