@trackunit/custom-field-components 1.24.12 → 1.24.16

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
@@ -12,6 +12,8 @@ var reactCoreHooks = require('@trackunit/react-core-hooks');
12
12
  var reactModal = require('@trackunit/react-modal');
13
13
 
14
14
  var defaultTranslations = {
15
+ "customfield.input.email": "Email",
16
+ "customfield.input.webaddress": "Web Address",
15
17
  "customfield.stringlistfield.add": "Add",
16
18
  "customfield.stringlistfield.addField.Heading": "Add {{label}}",
17
19
  "customfield.stringlistfield.addField.InputPlaceholder": "Enter {{label}}",
@@ -275,6 +277,7 @@ const AddStringListField = ({ id, label, isEditing, setIsEditing, onAdd, }) => {
275
277
  };
276
278
 
277
279
  const StringListInput = ({ value: initialValue, onSave, onClickDelete, disabled, id, index }) => {
280
+ const [t] = useTranslation();
278
281
  const [localValue, setLocalValue] = react.useState(initialValue);
279
282
  react.useEffect(() => {
280
283
  setLocalValue(initialValue);
@@ -284,7 +287,7 @@ const StringListInput = ({ value: initialValue, onSave, onClickDelete, disabled,
284
287
  onSave(localValue);
285
288
  }
286
289
  }, [localValue, initialValue, onSave]);
287
- return (jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx(reactFormComponents.TextBaseInput, { "data-testid": `${id}-${index}-input`, disabled: disabled, onBlur: handleBlur, onChange: e => setLocalValue(e.target.value), value: localValue }), jsxRuntime.jsx(reactComponents.IconButton, { disabled: disabled, icon: jsxRuntime.jsx(reactComponents.Icon, { name: "Trash", size: "small" }), onClick: onClickDelete, variant: "secondary-danger" })] }));
290
+ return (jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [jsxRuntime.jsx(reactFormComponents.TextBaseInput, { "data-testid": `${id}-${index}-input`, disabled: disabled, onBlur: handleBlur, onChange: e => setLocalValue(e.target.value), value: localValue }), jsxRuntime.jsx(reactComponents.IconButton, { disabled: disabled, icon: jsxRuntime.jsx(reactComponents.Icon, { name: "Trash", size: "small" }), onClick: onClickDelete, title: t("customfield.stringlistfield.deleteField.PrimaryActionLabel"), variant: "secondary-danger" })] }));
288
291
  };
289
292
  /**
290
293
  * A custom field that displays a list of strings.
@@ -540,6 +543,7 @@ const useUnitTranslation = () => {
540
543
  * @returns {ReactElement | null} - The JSX Element for the custom field or null if the field definition is not provided.
541
544
  */
542
545
  const useCustomFieldResolver = ({ field, definition, register, setValue, formState, formValue, unitPreference = "SI", language, fieldId, isEditable = true, control, }) => {
546
+ const [t] = useTranslation();
543
547
  const validation = { register, setValue, formState };
544
548
  const { unitTranslation } = useUnitTranslation();
545
549
  const [numberValue, setNumberValue] = react.useState(() => {
@@ -569,14 +573,14 @@ const useCustomFieldResolver = ({ field, definition, register, setValue, formSta
569
573
  switch (def.__typename) {
570
574
  case "WebAddressFieldDefinition": {
571
575
  const rules = getWebAddressValidationRules(def);
572
- return (jsxRuntime.jsx(reactFormComponents.TextField, { actions: !isEditableCombined && formValue ? jsxRuntime.jsx(reactFormComponents.ActionButton, { type: "WEB_ADDRESS", value: formValue }) : null, "data-testid": `${key}`, disabled: !isEditableCombined, errorMessage: errorMessage, helpText: description, id: uniqueIdentifier, label: title, placeholder: title ?? "", readOnly: !isEditableCombined, ...validation.register(uniqueIdentifier, {
576
+ return (jsxRuntime.jsx(reactFormComponents.TextField, { actions: !isEditableCombined && formValue ? (jsxRuntime.jsx(reactFormComponents.ActionButton, { title: t("customfield.input.webaddress"), type: "WEB_ADDRESS", value: formValue })) : null, "data-testid": `${key}`, disabled: !isEditableCombined, errorMessage: errorMessage, helpText: description, id: uniqueIdentifier, label: title, placeholder: title ?? "", readOnly: !isEditableCombined, ...validation.register(uniqueIdentifier, {
573
577
  ...rules,
574
578
  value,
575
579
  }) }));
576
580
  }
577
581
  case "EmailFieldDefinition": {
578
582
  const rules = getEmailValidationRules(def);
579
- return (jsxRuntime.jsx(reactFormComponents.TextField, { actions: !isEditableCombined && formValue ? jsxRuntime.jsx(reactFormComponents.ActionButton, { type: "EMAIL", value: formValue }) : null, "data-testid": `${key}`, disabled: !isEditableCombined, errorMessage: errorMessage, helpText: description, id: uniqueIdentifier, label: title, placeholder: title ?? "", readOnly: !isEditableCombined, ...validation.register(uniqueIdentifier, {
583
+ return (jsxRuntime.jsx(reactFormComponents.TextField, { actions: !isEditableCombined && formValue ? (jsxRuntime.jsx(reactFormComponents.ActionButton, { title: t("customfield.input.email"), type: "EMAIL", value: formValue })) : null, "data-testid": `${key}`, disabled: !isEditableCombined, errorMessage: errorMessage, helpText: description, id: uniqueIdentifier, label: title, placeholder: title ?? "", readOnly: !isEditableCombined, ...validation.register(uniqueIdentifier, {
580
584
  ...rules,
581
585
  value,
582
586
  }) }));
package/index.esm.js CHANGED
@@ -10,6 +10,8 @@ import { useConfirmationDialog } from '@trackunit/react-core-hooks';
10
10
  import { useModal, Modal, ModalHeader, ModalBody, ModalFooter } from '@trackunit/react-modal';
11
11
 
12
12
  var defaultTranslations = {
13
+ "customfield.input.email": "Email",
14
+ "customfield.input.webaddress": "Web Address",
13
15
  "customfield.stringlistfield.add": "Add",
14
16
  "customfield.stringlistfield.addField.Heading": "Add {{label}}",
15
17
  "customfield.stringlistfield.addField.InputPlaceholder": "Enter {{label}}",
@@ -273,6 +275,7 @@ const AddStringListField = ({ id, label, isEditing, setIsEditing, onAdd, }) => {
273
275
  };
274
276
 
275
277
  const StringListInput = ({ value: initialValue, onSave, onClickDelete, disabled, id, index }) => {
278
+ const [t] = useTranslation();
276
279
  const [localValue, setLocalValue] = useState(initialValue);
277
280
  useEffect(() => {
278
281
  setLocalValue(initialValue);
@@ -282,7 +285,7 @@ const StringListInput = ({ value: initialValue, onSave, onClickDelete, disabled,
282
285
  onSave(localValue);
283
286
  }
284
287
  }, [localValue, initialValue, onSave]);
285
- return (jsxs("div", { className: "flex items-center gap-2", children: [jsx(TextBaseInput, { "data-testid": `${id}-${index}-input`, disabled: disabled, onBlur: handleBlur, onChange: e => setLocalValue(e.target.value), value: localValue }), jsx(IconButton, { disabled: disabled, icon: jsx(Icon, { name: "Trash", size: "small" }), onClick: onClickDelete, variant: "secondary-danger" })] }));
288
+ return (jsxs("div", { className: "flex items-center gap-2", children: [jsx(TextBaseInput, { "data-testid": `${id}-${index}-input`, disabled: disabled, onBlur: handleBlur, onChange: e => setLocalValue(e.target.value), value: localValue }), jsx(IconButton, { disabled: disabled, icon: jsx(Icon, { name: "Trash", size: "small" }), onClick: onClickDelete, title: t("customfield.stringlistfield.deleteField.PrimaryActionLabel"), variant: "secondary-danger" })] }));
286
289
  };
287
290
  /**
288
291
  * A custom field that displays a list of strings.
@@ -538,6 +541,7 @@ const useUnitTranslation = () => {
538
541
  * @returns {ReactElement | null} - The JSX Element for the custom field or null if the field definition is not provided.
539
542
  */
540
543
  const useCustomFieldResolver = ({ field, definition, register, setValue, formState, formValue, unitPreference = "SI", language, fieldId, isEditable = true, control, }) => {
544
+ const [t] = useTranslation();
541
545
  const validation = { register, setValue, formState };
542
546
  const { unitTranslation } = useUnitTranslation();
543
547
  const [numberValue, setNumberValue] = useState(() => {
@@ -567,14 +571,14 @@ const useCustomFieldResolver = ({ field, definition, register, setValue, formSta
567
571
  switch (def.__typename) {
568
572
  case "WebAddressFieldDefinition": {
569
573
  const rules = getWebAddressValidationRules(def);
570
- return (jsx(TextField, { actions: !isEditableCombined && formValue ? jsx(ActionButton, { type: "WEB_ADDRESS", value: formValue }) : null, "data-testid": `${key}`, disabled: !isEditableCombined, errorMessage: errorMessage, helpText: description, id: uniqueIdentifier, label: title, placeholder: title ?? "", readOnly: !isEditableCombined, ...validation.register(uniqueIdentifier, {
574
+ return (jsx(TextField, { actions: !isEditableCombined && formValue ? (jsx(ActionButton, { title: t("customfield.input.webaddress"), type: "WEB_ADDRESS", value: formValue })) : null, "data-testid": `${key}`, disabled: !isEditableCombined, errorMessage: errorMessage, helpText: description, id: uniqueIdentifier, label: title, placeholder: title ?? "", readOnly: !isEditableCombined, ...validation.register(uniqueIdentifier, {
571
575
  ...rules,
572
576
  value,
573
577
  }) }));
574
578
  }
575
579
  case "EmailFieldDefinition": {
576
580
  const rules = getEmailValidationRules(def);
577
- return (jsx(TextField, { actions: !isEditableCombined && formValue ? jsx(ActionButton, { type: "EMAIL", value: formValue }) : null, "data-testid": `${key}`, disabled: !isEditableCombined, errorMessage: errorMessage, helpText: description, id: uniqueIdentifier, label: title, placeholder: title ?? "", readOnly: !isEditableCombined, ...validation.register(uniqueIdentifier, {
581
+ return (jsx(TextField, { actions: !isEditableCombined && formValue ? (jsx(ActionButton, { title: t("customfield.input.email"), type: "EMAIL", value: formValue })) : null, "data-testid": `${key}`, disabled: !isEditableCombined, errorMessage: errorMessage, helpText: description, id: uniqueIdentifier, label: title, placeholder: title ?? "", readOnly: !isEditableCombined, ...validation.register(uniqueIdentifier, {
578
582
  ...rules,
579
583
  value,
580
584
  }) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/custom-field-components",
3
- "version": "1.24.12",
3
+ "version": "1.24.16",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,15 +8,15 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "react-select": "^5.10.2",
11
- "@trackunit/react-form-components": "1.25.11",
12
- "@trackunit/shared-utils": "1.15.4",
13
- "@trackunit/custom-field-api": "1.24.8",
14
- "@trackunit/iris-app-runtime-core": "1.17.4",
15
- "@trackunit/react-components": "1.24.7",
16
- "@trackunit/react-modal": "1.25.11",
17
- "@trackunit/react-core-hooks": "1.17.7",
18
- "@trackunit/i18n-library-translation": "1.21.7",
19
- "@trackunit/iris-app-runtime-core-api": "1.16.4"
11
+ "@trackunit/react-form-components": "1.25.15",
12
+ "@trackunit/shared-utils": "1.15.5",
13
+ "@trackunit/custom-field-api": "1.24.12",
14
+ "@trackunit/iris-app-runtime-core": "1.17.5",
15
+ "@trackunit/react-components": "1.24.10",
16
+ "@trackunit/react-modal": "1.25.15",
17
+ "@trackunit/react-core-hooks": "1.17.9",
18
+ "@trackunit/i18n-library-translation": "1.21.10",
19
+ "@trackunit/iris-app-runtime-core-api": "1.16.5"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "@apollo/client": "^3.13.8",