@ultraviolet/form 3.3.0 → 3.3.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.
|
@@ -10,7 +10,7 @@ const KeyValueField = ({
|
|
|
10
10
|
inputValue,
|
|
11
11
|
addButton,
|
|
12
12
|
maxSize = 100,
|
|
13
|
-
|
|
13
|
+
readOnly = false,
|
|
14
14
|
control
|
|
15
15
|
}) => {
|
|
16
16
|
const {
|
|
@@ -25,9 +25,9 @@ const KeyValueField = ({
|
|
|
25
25
|
const maxSizeReachedTooltip = addButton.maxSizeReachedTooltip ?? `Cannot add more than ${maxSize} elements`;
|
|
26
26
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { gap: 3, children: [
|
|
27
27
|
fields.length ? /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { gap: 3, children: fields.map((field, index$1) => /* @__PURE__ */ jsxRuntime.jsxs(ui.Row, { templateColumns: "1fr 1fr auto", gap: 2, alignItems: "end", children: [
|
|
28
|
-
/* @__PURE__ */ jsxRuntime.jsx(index.TextInputField, { readOnly
|
|
29
|
-
/* @__PURE__ */ jsxRuntime.jsx(index.TextInputField, { readOnly
|
|
30
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { disabled:
|
|
28
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.TextInputField, { readOnly, required: inputKey.required, name: `${name}.${index$1}.key`, label: inputKey.label, regex: inputKey.regex }),
|
|
29
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.TextInputField, { readOnly, required: inputValue.required, name: `${name}.${index$1}.value`, label: inputValue.label, placeholder: inputValue.placeholder, type: inputValue.type, autoComplete: "off", regex: inputValue.regex }),
|
|
30
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { disabled: readOnly, "data-testid": `remove-button-${index$1}`, icon: "delete", variant: "outlined", sentiment: "danger", size: "large", onClick: () => remove(index$1) })
|
|
31
31
|
] }, field.id)) }) : null,
|
|
32
32
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { direction: "row", justifyContent: "flex-start", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
33
33
|
ui.Button,
|
|
@@ -37,7 +37,7 @@ const KeyValueField = ({
|
|
|
37
37
|
variant: "filled",
|
|
38
38
|
sentiment: "neutral",
|
|
39
39
|
fullWidth: addButton.fullWidth,
|
|
40
|
-
disabled: !canAdd ||
|
|
40
|
+
disabled: !canAdd || readOnly,
|
|
41
41
|
tooltip: !canAdd ? maxSizeReachedTooltip : addButton.tooltip,
|
|
42
42
|
onClick: () => append({
|
|
43
43
|
key: "",
|
|
@@ -23,11 +23,11 @@ type KeyValueFieldProps<TFieldValues extends FieldValues, TFieldArrayName extend
|
|
|
23
23
|
inputValue: InputValueProps;
|
|
24
24
|
addButton: AddButtonProps;
|
|
25
25
|
maxSize?: number;
|
|
26
|
-
|
|
26
|
+
readOnly?: boolean;
|
|
27
27
|
control?: Control<TFieldValues>;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
30
|
* A React component that allows users to manage key-value pairs
|
|
31
31
|
*/
|
|
32
|
-
export declare const KeyValueField: <TFieldValues extends FieldValues = FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>>({ name, inputKey, inputValue, addButton, maxSize,
|
|
32
|
+
export declare const KeyValueField: <TFieldValues extends FieldValues = FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>>({ name, inputKey, inputValue, addButton, maxSize, readOnly, control, }: KeyValueFieldProps<TFieldValues, TFieldArrayName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
33
33
|
export {};
|
|
@@ -8,7 +8,7 @@ const KeyValueField = ({
|
|
|
8
8
|
inputValue,
|
|
9
9
|
addButton,
|
|
10
10
|
maxSize = 100,
|
|
11
|
-
|
|
11
|
+
readOnly = false,
|
|
12
12
|
control
|
|
13
13
|
}) => {
|
|
14
14
|
const {
|
|
@@ -23,9 +23,9 @@ const KeyValueField = ({
|
|
|
23
23
|
const maxSizeReachedTooltip = addButton.maxSizeReachedTooltip ?? `Cannot add more than ${maxSize} elements`;
|
|
24
24
|
return /* @__PURE__ */ jsxs(Stack, { gap: 3, children: [
|
|
25
25
|
fields.length ? /* @__PURE__ */ jsx(Stack, { gap: 3, children: fields.map((field, index) => /* @__PURE__ */ jsxs(Row, { templateColumns: "1fr 1fr auto", gap: 2, alignItems: "end", children: [
|
|
26
|
-
/* @__PURE__ */ jsx(TextInputField, { readOnly
|
|
27
|
-
/* @__PURE__ */ jsx(TextInputField, { readOnly
|
|
28
|
-
/* @__PURE__ */ jsx(Button, { disabled:
|
|
26
|
+
/* @__PURE__ */ jsx(TextInputField, { readOnly, required: inputKey.required, name: `${name}.${index}.key`, label: inputKey.label, regex: inputKey.regex }),
|
|
27
|
+
/* @__PURE__ */ jsx(TextInputField, { readOnly, required: inputValue.required, name: `${name}.${index}.value`, label: inputValue.label, placeholder: inputValue.placeholder, type: inputValue.type, autoComplete: "off", regex: inputValue.regex }),
|
|
28
|
+
/* @__PURE__ */ jsx(Button, { disabled: readOnly, "data-testid": `remove-button-${index}`, icon: "delete", variant: "outlined", sentiment: "danger", size: "large", onClick: () => remove(index) })
|
|
29
29
|
] }, field.id)) }) : null,
|
|
30
30
|
/* @__PURE__ */ jsx(Stack, { direction: "row", justifyContent: "flex-start", children: /* @__PURE__ */ jsx(
|
|
31
31
|
Button,
|
|
@@ -35,7 +35,7 @@ const KeyValueField = ({
|
|
|
35
35
|
variant: "filled",
|
|
36
36
|
sentiment: "neutral",
|
|
37
37
|
fullWidth: addButton.fullWidth,
|
|
38
|
-
disabled: !canAdd ||
|
|
38
|
+
disabled: !canAdd || readOnly,
|
|
39
39
|
tooltip: !canAdd ? maxSizeReachedTooltip : addButton.tooltip,
|
|
40
40
|
onClick: () => append({
|
|
41
41
|
key: "",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultraviolet/form",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"description": "Ultraviolet Form",
|
|
5
5
|
"homepage": "https://github.com/scaleway/ultraviolet#readme",
|
|
6
6
|
"repository": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"react-hook-form": "7.52.1"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@babel/core": "7.24.
|
|
61
|
+
"@babel/core": "7.24.9",
|
|
62
62
|
"@types/final-form-focus": "1.1.7",
|
|
63
63
|
"@types/react": "18.3.3",
|
|
64
64
|
"@types/react-dom": "18.3.0",
|
|
@@ -67,12 +67,12 @@
|
|
|
67
67
|
"@utils/test": "0.0.1"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@babel/runtime": "7.24.
|
|
70
|
+
"@babel/runtime": "7.24.8",
|
|
71
71
|
"@emotion/react": "11.11.4",
|
|
72
72
|
"@emotion/styled": "11.11.5",
|
|
73
73
|
"react-select": "5.8.0",
|
|
74
74
|
"react-hook-form": "7.52.1",
|
|
75
|
-
"@ultraviolet/ui": "1.
|
|
75
|
+
"@ultraviolet/ui": "1.62.0",
|
|
76
76
|
"@ultraviolet/themes": "1.12.2"
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|