@trackunit/custom-field-components 1.3.226 → 1.3.229

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 CHANGED
@@ -221,7 +221,13 @@ const DropdownCustomField = ({ defaultValue, dataTestId, onChange, onBlur, id, d
221
221
  * Modal for adding a new string list field
222
222
  */
223
223
  const AddStringListField = ({ id, label, isEditing, setIsEditing, onAdd }) => {
224
- const { Modal } = reactModal.useModal();
224
+ const modal = reactModal.useModal({
225
+ isOpen: isEditing,
226
+ onClose: () => {
227
+ setInputValue("");
228
+ setIsEditing(false);
229
+ },
230
+ });
225
231
  const [inputValue, setInputValue] = react.useState("");
226
232
  const { t } = useTranslation();
227
233
  const handleAdd = () => {
@@ -231,11 +237,7 @@ const AddStringListField = ({ id, label, isEditing, setIsEditing, onAdd }) => {
231
237
  setIsEditing(false);
232
238
  }
233
239
  };
234
- const handleDiscard = () => {
235
- setInputValue("");
236
- setIsEditing(false);
237
- };
238
- return (jsxRuntime.jsxs(Modal, { className: "max-w-lg", dataTestId: `${id}-edit-modal`, isOpen: isEditing, onDismissClick: handleDiscard, children: [jsxRuntime.jsx(reactComponents.CardHeader, { heading: t("customfield.stringlistfield.addField.Heading", { label: label }), onClose: handleDiscard }), jsxRuntime.jsx(reactComponents.CardBody, { children: jsxRuntime.jsx(reactFormComponents.TextInput, { dataTestId: `${id}-edit-modal-input`, onChange: e => setInputValue(e.target.value), placeholder: t("customfield.stringlistfield.addField.InputPlaceholder", { label: label }), value: inputValue }) }), jsxRuntime.jsxs(reactComponents.CardFooter, { children: [jsxRuntime.jsx(reactComponents.Button, { dataTestId: `${id}-edit-modal-discard-button`, onClick: handleDiscard, variant: "secondary", children: t("customfield.stringlistfield.discard") }), jsxRuntime.jsx(reactComponents.Button, { dataTestId: `${id}-edit-modal-add-button`, onClick: handleAdd, children: t("customfield.stringlistfield.add") })] })] }));
240
+ return (jsxRuntime.jsxs(reactModal.Modal, { ...modal, className: "max-w-lg", dataTestId: `${id}-edit-modal`, children: [jsxRuntime.jsx(reactComponents.CardHeader, { heading: t("customfield.stringlistfield.addField.Heading", { label: label }), onClose: modal.close }), jsxRuntime.jsx(reactComponents.CardBody, { children: jsxRuntime.jsx(reactFormComponents.TextInput, { dataTestId: `${id}-edit-modal-input`, onChange: e => setInputValue(e.target.value), placeholder: t("customfield.stringlistfield.addField.InputPlaceholder", { label: label }), value: inputValue }) }), jsxRuntime.jsxs(reactComponents.CardFooter, { children: [jsxRuntime.jsx(reactComponents.Button, { dataTestId: `${id}-edit-modal-discard-button`, onClick: modal.close, variant: "secondary", children: t("customfield.stringlistfield.discard") }), jsxRuntime.jsx(reactComponents.Button, { dataTestId: `${id}-edit-modal-add-button`, onClick: handleAdd, children: t("customfield.stringlistfield.add") })] })] }));
239
241
  };
240
242
 
241
243
  const StringListInput = ({ value: initialValue, onSave, onDelete, disabled, id, index }) => {
package/index.esm.js CHANGED
@@ -7,7 +7,7 @@ import { useState, useEffect, useCallback, createElement, useMemo } from 'react'
7
7
  import { Controller, useWatch } from 'react-hook-form';
8
8
  import { CardHeader, CardBody, CardFooter, Button, Card, Tooltip, Text, IconButton, Icon } from '@trackunit/react-components';
9
9
  import { useConfirmationDialog } from '@trackunit/react-core-hooks';
10
- import { useModal } from '@trackunit/react-modal';
10
+ import { useModal, Modal } from '@trackunit/react-modal';
11
11
 
12
12
  var defaultTranslations = {
13
13
  "customfield.stringlistfield.add": "Add",
@@ -219,7 +219,13 @@ const DropdownCustomField = ({ defaultValue, dataTestId, onChange, onBlur, id, d
219
219
  * Modal for adding a new string list field
220
220
  */
221
221
  const AddStringListField = ({ id, label, isEditing, setIsEditing, onAdd }) => {
222
- const { Modal } = useModal();
222
+ const modal = useModal({
223
+ isOpen: isEditing,
224
+ onClose: () => {
225
+ setInputValue("");
226
+ setIsEditing(false);
227
+ },
228
+ });
223
229
  const [inputValue, setInputValue] = useState("");
224
230
  const { t } = useTranslation();
225
231
  const handleAdd = () => {
@@ -229,11 +235,7 @@ const AddStringListField = ({ id, label, isEditing, setIsEditing, onAdd }) => {
229
235
  setIsEditing(false);
230
236
  }
231
237
  };
232
- const handleDiscard = () => {
233
- setInputValue("");
234
- setIsEditing(false);
235
- };
236
- return (jsxs(Modal, { className: "max-w-lg", dataTestId: `${id}-edit-modal`, isOpen: isEditing, onDismissClick: handleDiscard, children: [jsx(CardHeader, { heading: t("customfield.stringlistfield.addField.Heading", { label: label }), onClose: handleDiscard }), jsx(CardBody, { children: jsx(TextInput, { dataTestId: `${id}-edit-modal-input`, onChange: e => setInputValue(e.target.value), placeholder: t("customfield.stringlistfield.addField.InputPlaceholder", { label: label }), value: inputValue }) }), jsxs(CardFooter, { children: [jsx(Button, { dataTestId: `${id}-edit-modal-discard-button`, onClick: handleDiscard, variant: "secondary", children: t("customfield.stringlistfield.discard") }), jsx(Button, { dataTestId: `${id}-edit-modal-add-button`, onClick: handleAdd, children: t("customfield.stringlistfield.add") })] })] }));
238
+ return (jsxs(Modal, { ...modal, className: "max-w-lg", dataTestId: `${id}-edit-modal`, children: [jsx(CardHeader, { heading: t("customfield.stringlistfield.addField.Heading", { label: label }), onClose: modal.close }), jsx(CardBody, { children: jsx(TextInput, { dataTestId: `${id}-edit-modal-input`, onChange: e => setInputValue(e.target.value), placeholder: t("customfield.stringlistfield.addField.InputPlaceholder", { label: label }), value: inputValue }) }), jsxs(CardFooter, { children: [jsx(Button, { dataTestId: `${id}-edit-modal-discard-button`, onClick: modal.close, variant: "secondary", children: t("customfield.stringlistfield.discard") }), jsx(Button, { dataTestId: `${id}-edit-modal-add-button`, onClick: handleAdd, children: t("customfield.stringlistfield.add") })] })] }));
237
239
  };
238
240
 
239
241
  const StringListInput = ({ value: initialValue, onSave, onDelete, disabled, id, index }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/custom-field-components",
3
- "version": "1.3.226",
3
+ "version": "1.3.229",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -12,16 +12,16 @@
12
12
  "react-select": "^5.10.0",
13
13
  "@testing-library/react": "16.2.0",
14
14
  "jest-fetch-mock": "^3.0.3",
15
- "@trackunit/react-form-components": "1.3.207",
16
- "@trackunit/shared-utils": "1.5.150",
17
- "@trackunit/custom-field-api": "1.3.182",
18
- "@trackunit/iris-app-runtime-core": "1.4.161",
19
- "@trackunit/react-components": "1.4.182",
20
- "@trackunit/react-modal": "1.3.199",
21
- "@trackunit/react-core-hooks": "1.3.164",
22
- "@trackunit/i18n-library-translation": "1.3.171",
23
- "@trackunit/iris-app-runtime-core-api": "1.3.161",
24
- "@trackunit/react-test-setup": "1.0.40"
15
+ "@trackunit/react-form-components": "1.3.210",
16
+ "@trackunit/shared-utils": "1.5.151",
17
+ "@trackunit/custom-field-api": "1.3.185",
18
+ "@trackunit/iris-app-runtime-core": "1.4.162",
19
+ "@trackunit/react-components": "1.4.185",
20
+ "@trackunit/react-modal": "1.3.202",
21
+ "@trackunit/react-core-hooks": "1.3.165",
22
+ "@trackunit/i18n-library-translation": "1.3.172",
23
+ "@trackunit/iris-app-runtime-core-api": "1.3.162",
24
+ "@trackunit/react-test-setup": "1.0.41"
25
25
  },
26
26
  "module": "./index.esm.js",
27
27
  "main": "./index.cjs.js",