@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.
- package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/asyncToGenerator.js +5 -3
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js +19 -0
- package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/objectSpread2.js +8 -4
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.js +22 -0
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutPropertiesLoose.js +17 -0
- package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/toPrimitive.js +8 -4
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.js +17 -0
- package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/typeof.js +5 -3
- package/dist/_virtual/_rolldown/runtime.js +2 -1
- package/dist/components/CheckboxField/index.js +59 -51
- package/dist/components/CheckboxGroupField/index.js +67 -59
- package/dist/components/DateInputField/index.js +94 -84
- package/dist/components/FileInputField/index.js +64 -60
- package/dist/components/Form/defaultErrors.js +25 -21
- package/dist/components/Form/index.d.ts +2 -1
- package/dist/components/Form/index.d.ts.map +1 -1
- package/dist/components/Form/index.js +41 -31
- package/dist/components/KeyValueField/index.js +88 -86
- package/dist/components/NumberInputField/index.js +66 -57
- package/dist/components/RadioField/index.js +65 -57
- package/dist/components/RadioGroupField/index.js +50 -42
- package/dist/components/SelectInputField/index.js +56 -48
- package/dist/components/SelectableCardField/index.js +64 -58
- package/dist/components/SelectableCardGroupField/SelectableCardGroupField.js +56 -48
- package/dist/components/SelectableCardGroupField/index.js +9 -0
- package/dist/components/SelectableCardOptionGroupField/index.js +61 -53
- package/dist/components/SliderField/index.js +83 -75
- package/dist/components/Submit/index.js +22 -18
- package/dist/components/SubmitErrorAlert/index.js +15 -11
- package/dist/components/SwitchButtonField/index.js +47 -41
- package/dist/components/TagInputField/index.js +54 -45
- package/dist/components/TextAreaField/index.js +78 -72
- package/dist/components/TextInputField/index.js +67 -61
- package/dist/components/TimeInputField/index.js +50 -46
- package/dist/components/ToggleField/index.js +63 -55
- package/dist/components/ToggleGroupField/index.js +53 -45
- package/dist/components/UnitInputField/index.js +61 -53
- package/dist/components/VerificationCodeField/index.js +47 -39
- package/dist/components/compositions/CodeEditorField/index.js +48 -42
- package/dist/components/compositions/CustomerSatisfactionField/index.js +17 -13
- package/dist/components/compositions/OfferListField/index.js +54 -48
- package/dist/components/compositions/OptionSelectorField/index.js +53 -45
- package/dist/components/compositions/PlansField/index.js +25 -21
- package/dist/components/compositions/index.js +17 -5
- package/dist/components/index.js +59 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/useOnFieldChange.js +25 -24
- package/dist/index.js +14 -1
- package/dist/providers/ErrorContext/index.js +28 -24
- package/dist/providers/index.js +11 -0
- package/dist/utils/validateRegex.js +7 -3
- package/dist/validators/isInteger.js +11 -7
- package/dist/validators/maxDate.js +7 -3
- package/dist/validators/minDate.js +7 -3
- package/package.json +6 -6
- package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/defineProperty.js +0 -15
- package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/objectWithoutProperties.js +0 -18
- package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/objectWithoutPropertiesLoose.js +0 -15
- 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.
|
|
4
|
-
import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
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;
|
|
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.
|
|
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 {
|
|
6
|
-
import {
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
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.
|
|
4
|
-
import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.
|
|
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 {
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
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
|
-
|
|
77
|
+
init_NumberInputField();
|
|
78
|
+
export { NumberInputField, init_NumberInputField };
|