@trackunit/custom-field-components 1.0.6 → 1.0.8
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/index.cjs.js +2 -4
- package/index.esm.js +2 -4
- package/package.json +4 -4
package/index.cjs.js
CHANGED
|
@@ -269,7 +269,7 @@ const StringListField = ({ defaultValue = [], label, description, disabled, vali
|
|
|
269
269
|
const { t } = useTranslation();
|
|
270
270
|
return (jsxRuntime.jsx(reactHookForm.Controller, { control: control, defaultValue: defaultValue, name: id, render: ({ field }) => {
|
|
271
271
|
const handleRemoveValue = (index) => {
|
|
272
|
-
const newValues = field.value.filter((_, i) => i !== index);
|
|
272
|
+
const newValues = [...field.value].filter((_, i) => i !== index);
|
|
273
273
|
field.onChange(newValues);
|
|
274
274
|
};
|
|
275
275
|
const handleFieldChange = (index, value) => {
|
|
@@ -289,9 +289,7 @@ const StringListField = ({ defaultValue = [], label, description, disabled, vali
|
|
|
289
289
|
handleRemoveValue(index);
|
|
290
290
|
}
|
|
291
291
|
};
|
|
292
|
-
return (jsxRuntime.jsxs(reactComponents.Card, { ...props, className: "w-full", "data-testid": dataTestId, children: [jsxRuntime.jsx(reactComponents.CardHeader, { accessories: jsxRuntime.jsx(reactComponents.Tooltip, { label: description }), heading: label, headingVariant: "secondary" }), jsxRuntime.jsx(reactComponents.CardBody, { children: field.value.length === 0 ? (jsxRuntime.jsx(reactComponents.Text, { children: t("customfield.stringlistfield.noValuesAddedYet") })) : (jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: field.value.map((value, index) => (jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx(reactFormComponents.TextInput, { disabled: disabled,
|
|
293
|
-
onChange: e => handleFieldChange(index, e.target.value),
|
|
294
|
-
}), defaultValue: value }), jsxRuntime.jsx(reactComponents.IconButton, { disabled: disabled, icon: jsxRuntime.jsx(reactComponents.Icon, { name: "Trash", size: "small" }), onClick: () => handleRemoveValueConfirmation(index), variant: "secondary-danger" })] }, index))) })) }), !disabled ? (jsxRuntime.jsx(reactComponents.CardFooter, { children: jsxRuntime.jsx(reactComponents.Button, { disabled: disabled, onClick: () => setIsEditing(true), variant: "secondary", children: t("customfield.stringlistfield.add", { label: label }) }) })) : null, jsxRuntime.jsx(AddStringListField, { id: id, isEditing: isEditing, label: label, onAdd: (newItem) => {
|
|
292
|
+
return (jsxRuntime.jsxs(reactComponents.Card, { ...props, className: "w-full", "data-testid": dataTestId, children: [jsxRuntime.jsx(reactComponents.CardHeader, { accessories: jsxRuntime.jsx(reactComponents.Tooltip, { label: description }), heading: label, headingVariant: "secondary" }), jsxRuntime.jsx(reactComponents.CardBody, { children: field.value.length === 0 ? (jsxRuntime.jsx(reactComponents.Text, { children: t("customfield.stringlistfield.noValuesAddedYet") })) : (jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: field.value.map((value, index) => (jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx(reactFormComponents.TextInput, { "data-testid": `${id}-${index}-input`, disabled: disabled, onChange: e => handleFieldChange(index, e.target.value), value: value }), jsxRuntime.jsx(reactComponents.IconButton, { disabled: disabled, icon: jsxRuntime.jsx(reactComponents.Icon, { name: "Trash", size: "small" }), onClick: () => handleRemoveValueConfirmation(index), variant: "secondary-danger" })] }, `${id}-${index}-${value}`))) })) }), !disabled ? (jsxRuntime.jsx(reactComponents.CardFooter, { children: jsxRuntime.jsx(reactComponents.Button, { disabled: disabled, onClick: () => setIsEditing(true), variant: "secondary", children: t("customfield.stringlistfield.add", { label: label }) }) })) : null, jsxRuntime.jsx(AddStringListField, { id: id, isEditing: isEditing, label: label, onAdd: (newItem) => {
|
|
295
293
|
field.onChange([...field.value, newItem]);
|
|
296
294
|
}, setIsEditing: setIsEditing })] }));
|
|
297
295
|
}, rules: validationRules }));
|
package/index.esm.js
CHANGED
|
@@ -249,7 +249,7 @@ const StringListField = ({ defaultValue = [], label, description, disabled, vali
|
|
|
249
249
|
const { t } = useTranslation();
|
|
250
250
|
return (jsx(Controller, { control: control, defaultValue: defaultValue, name: id, render: ({ field }) => {
|
|
251
251
|
const handleRemoveValue = (index) => {
|
|
252
|
-
const newValues = field.value.filter((_, i) => i !== index);
|
|
252
|
+
const newValues = [...field.value].filter((_, i) => i !== index);
|
|
253
253
|
field.onChange(newValues);
|
|
254
254
|
};
|
|
255
255
|
const handleFieldChange = (index, value) => {
|
|
@@ -269,9 +269,7 @@ const StringListField = ({ defaultValue = [], label, description, disabled, vali
|
|
|
269
269
|
handleRemoveValue(index);
|
|
270
270
|
}
|
|
271
271
|
};
|
|
272
|
-
return (jsxs(Card, { ...props, className: "w-full", "data-testid": dataTestId, children: [jsx(CardHeader, { accessories: jsx(Tooltip, { label: description }), heading: label, headingVariant: "secondary" }), jsx(CardBody, { children: field.value.length === 0 ? (jsx(Text, { children: t("customfield.stringlistfield.noValuesAddedYet") })) : (jsx("div", { className: "flex flex-wrap gap-2", children: field.value.map((value, index) => (jsxs("div", { className: "flex items-center gap-2", children: [jsx(TextInput, { disabled: disabled,
|
|
273
|
-
onChange: e => handleFieldChange(index, e.target.value),
|
|
274
|
-
}), defaultValue: value }), jsx(IconButton, { disabled: disabled, icon: jsx(Icon, { name: "Trash", size: "small" }), onClick: () => handleRemoveValueConfirmation(index), variant: "secondary-danger" })] }, index))) })) }), !disabled ? (jsx(CardFooter, { children: jsx(Button, { disabled: disabled, onClick: () => setIsEditing(true), variant: "secondary", children: t("customfield.stringlistfield.add", { label: label }) }) })) : null, jsx(AddStringListField, { id: id, isEditing: isEditing, label: label, onAdd: (newItem) => {
|
|
272
|
+
return (jsxs(Card, { ...props, className: "w-full", "data-testid": dataTestId, children: [jsx(CardHeader, { accessories: jsx(Tooltip, { label: description }), heading: label, headingVariant: "secondary" }), jsx(CardBody, { children: field.value.length === 0 ? (jsx(Text, { children: t("customfield.stringlistfield.noValuesAddedYet") })) : (jsx("div", { className: "flex flex-wrap gap-2", children: field.value.map((value, index) => (jsxs("div", { className: "flex items-center gap-2", children: [jsx(TextInput, { "data-testid": `${id}-${index}-input`, disabled: disabled, onChange: e => handleFieldChange(index, e.target.value), value: value }), jsx(IconButton, { disabled: disabled, icon: jsx(Icon, { name: "Trash", size: "small" }), onClick: () => handleRemoveValueConfirmation(index), variant: "secondary-danger" })] }, `${id}-${index}-${value}`))) })) }), !disabled ? (jsx(CardFooter, { children: jsx(Button, { disabled: disabled, onClick: () => setIsEditing(true), variant: "secondary", children: t("customfield.stringlistfield.add", { label: label }) }) })) : null, jsx(AddStringListField, { id: id, isEditing: isEditing, label: label, onAdd: (newItem) => {
|
|
275
273
|
field.onChange([...field.value, newItem]);
|
|
276
274
|
}, setIsEditing: setIsEditing })] }));
|
|
277
275
|
}, rules: validationRules }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/custom-field-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"react-select": "^5.8.0",
|
|
13
13
|
"@testing-library/react": "15.0.6",
|
|
14
14
|
"jest-fetch-mock": "^3.0.3",
|
|
15
|
-
"@trackunit/react-form-components": "^1.0.
|
|
15
|
+
"@trackunit/react-form-components": "^1.0.7",
|
|
16
16
|
"@trackunit/shared-utils": "^1.0.2",
|
|
17
17
|
"@trackunit/custom-field-api": "^1.0.3",
|
|
18
18
|
"@trackunit/iris-app-runtime-core": "^1.0.3",
|
|
19
|
-
"@trackunit/react-components": "^1.0.
|
|
20
|
-
"@trackunit/react-modal": "^1.0.
|
|
19
|
+
"@trackunit/react-components": "^1.0.7",
|
|
20
|
+
"@trackunit/react-modal": "^1.0.8",
|
|
21
21
|
"@trackunit/react-core-hooks": "^1.0.3",
|
|
22
22
|
"@trackunit/i18n-library-translation": "^1.0.3",
|
|
23
23
|
"@trackunit/iris-app-runtime-core-api": "^1.0.3"
|