@trackunit/custom-field-components 1.17.2 → 1.17.4
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 +6 -6
- package/index.esm.js +6 -6
- package/package.json +7 -7
- package/src/BooleanCustomField.d.ts +1 -1
package/index.cjs.js
CHANGED
|
@@ -134,14 +134,14 @@ const setupLibraryTranslations = () => {
|
|
|
134
134
|
*
|
|
135
135
|
* @returns {ReactElement} A component that can be used to render a boolean field.
|
|
136
136
|
*/
|
|
137
|
-
const BooleanCustomField = ({ defaultValue, "data-testid": dataTestId = "booleanField", onChange, value, id, setValue, register, validationRules, disabled = false, label, tip, isInvalid, errorMessage, helpAddon, maxLength, helpText, ...rest }) => {
|
|
138
|
-
const initialValue = value
|
|
137
|
+
const BooleanCustomField = ({ defaultValue = false, "data-testid": dataTestId = "booleanField", onChange, value = defaultValue, id, setValue, register, validationRules, disabled = false, readOnly = false, label, tip, isInvalid = false, errorMessage, helpAddon, maxLength, helpText, ...rest }) => {
|
|
138
|
+
const initialValue = value;
|
|
139
139
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
140
140
|
const htmlForId = id ? id : "boolean-custom-field-" + sharedUtils.uuidv4();
|
|
141
141
|
const [internalValue, setInternalValue] = react.useState(initialValue);
|
|
142
142
|
react.useEffect(() => {
|
|
143
|
-
setInternalValue(
|
|
144
|
-
}, [value, setInternalValue
|
|
143
|
+
setInternalValue(value);
|
|
144
|
+
}, [value, setInternalValue]);
|
|
145
145
|
const onChangeHandler = react.useCallback((event) => {
|
|
146
146
|
if (onChange) {
|
|
147
147
|
onChange(event);
|
|
@@ -157,7 +157,7 @@ const BooleanCustomField = ({ defaultValue, "data-testid": dataTestId = "boolean
|
|
|
157
157
|
register(id, { ...validationRules, value: internalValue.toString() });
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
|
-
return (jsxRuntime.jsx(reactFormComponents.FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ?? null, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(reactFormComponents.Checkbox, { checked: internalValue, "data-testid": dataTestId, disabled: disabled, id: htmlForId, isInvalid: renderAsInvalid, name: id, onChange: event => (!
|
|
160
|
+
return (jsxRuntime.jsx(reactFormComponents.FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ?? null, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(reactFormComponents.Checkbox, { checked: internalValue, "data-testid": dataTestId, disabled: disabled, id: htmlForId, isInvalid: renderAsInvalid, name: id, onChange: event => (!readOnly ? onChangeHandler(event) : null), readOnly: readOnly, ...rest }) }));
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
/**
|
|
@@ -288,7 +288,7 @@ const StringListInput = ({ value: initialValue, onSave, onClickDelete, disabled,
|
|
|
288
288
|
/**
|
|
289
289
|
* A custom field that displays a list of strings.
|
|
290
290
|
*/
|
|
291
|
-
const StringListField = ({ defaultValue = [], label, description, disabled, validationRules, id, control, register, setValue, "data-testid": dataTestId, ...props }) => {
|
|
291
|
+
const StringListField = ({ defaultValue = [], label, description, disabled = false, validationRules, id, control, register, setValue, "data-testid": dataTestId, ...props }) => {
|
|
292
292
|
const [isEditing, setIsEditing] = react.useState(false);
|
|
293
293
|
const { confirm } = reactCoreHooks.useConfirmationDialog();
|
|
294
294
|
const { t } = useTranslation();
|
package/index.esm.js
CHANGED
|
@@ -132,14 +132,14 @@ const setupLibraryTranslations = () => {
|
|
|
132
132
|
*
|
|
133
133
|
* @returns {ReactElement} A component that can be used to render a boolean field.
|
|
134
134
|
*/
|
|
135
|
-
const BooleanCustomField = ({ defaultValue, "data-testid": dataTestId = "booleanField", onChange, value, id, setValue, register, validationRules, disabled = false, label, tip, isInvalid, errorMessage, helpAddon, maxLength, helpText, ...rest }) => {
|
|
136
|
-
const initialValue = value
|
|
135
|
+
const BooleanCustomField = ({ defaultValue = false, "data-testid": dataTestId = "booleanField", onChange, value = defaultValue, id, setValue, register, validationRules, disabled = false, readOnly = false, label, tip, isInvalid = false, errorMessage, helpAddon, maxLength, helpText, ...rest }) => {
|
|
136
|
+
const initialValue = value;
|
|
137
137
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
138
138
|
const htmlForId = id ? id : "boolean-custom-field-" + uuidv4();
|
|
139
139
|
const [internalValue, setInternalValue] = useState(initialValue);
|
|
140
140
|
useEffect(() => {
|
|
141
|
-
setInternalValue(
|
|
142
|
-
}, [value, setInternalValue
|
|
141
|
+
setInternalValue(value);
|
|
142
|
+
}, [value, setInternalValue]);
|
|
143
143
|
const onChangeHandler = useCallback((event) => {
|
|
144
144
|
if (onChange) {
|
|
145
145
|
onChange(event);
|
|
@@ -155,7 +155,7 @@ const BooleanCustomField = ({ defaultValue, "data-testid": dataTestId = "boolean
|
|
|
155
155
|
register(id, { ...validationRules, value: internalValue.toString() });
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
|
-
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ?? null, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(Checkbox, { checked: internalValue, "data-testid": dataTestId, disabled: disabled, id: htmlForId, isInvalid: renderAsInvalid, name: id, onChange: event => (!
|
|
158
|
+
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ?? null, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsx(Checkbox, { checked: internalValue, "data-testid": dataTestId, disabled: disabled, id: htmlForId, isInvalid: renderAsInvalid, name: id, onChange: event => (!readOnly ? onChangeHandler(event) : null), readOnly: readOnly, ...rest }) }));
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
/**
|
|
@@ -286,7 +286,7 @@ const StringListInput = ({ value: initialValue, onSave, onClickDelete, disabled,
|
|
|
286
286
|
/**
|
|
287
287
|
* A custom field that displays a list of strings.
|
|
288
288
|
*/
|
|
289
|
-
const StringListField = ({ defaultValue = [], label, description, disabled, validationRules, id, control, register, setValue, "data-testid": dataTestId, ...props }) => {
|
|
289
|
+
const StringListField = ({ defaultValue = [], label, description, disabled = false, validationRules, id, control, register, setValue, "data-testid": dataTestId, ...props }) => {
|
|
290
290
|
const [isEditing, setIsEditing] = useState(false);
|
|
291
291
|
const { confirm } = useConfirmationDialog();
|
|
292
292
|
const { t } = useTranslation();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/custom-field-components",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.4",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"react-select": "^5.10.2",
|
|
11
|
-
"@trackunit/react-form-components": "1.18.
|
|
11
|
+
"@trackunit/react-form-components": "1.18.4",
|
|
12
12
|
"@trackunit/shared-utils": "1.13.77",
|
|
13
|
-
"@trackunit/custom-field-api": "1.17.
|
|
13
|
+
"@trackunit/custom-field-api": "1.17.4",
|
|
14
14
|
"@trackunit/iris-app-runtime-core": "1.14.2",
|
|
15
|
-
"@trackunit/react-components": "1.20.
|
|
16
|
-
"@trackunit/react-modal": "1.18.
|
|
17
|
-
"@trackunit/react-core-hooks": "1.14.
|
|
18
|
-
"@trackunit/i18n-library-translation": "1.15.
|
|
15
|
+
"@trackunit/react-components": "1.20.4",
|
|
16
|
+
"@trackunit/react-modal": "1.18.4",
|
|
17
|
+
"@trackunit/react-core-hooks": "1.14.3",
|
|
18
|
+
"@trackunit/i18n-library-translation": "1.15.4",
|
|
19
19
|
"@trackunit/iris-app-runtime-core-api": "1.13.2"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
@@ -77,4 +77,4 @@ export interface BooleanCustomFieldProps extends Omit<CheckboxProps, "value" | "
|
|
|
77
77
|
*
|
|
78
78
|
* @returns {ReactElement} A component that can be used to render a boolean field.
|
|
79
79
|
*/
|
|
80
|
-
export declare const BooleanCustomField: ({ defaultValue, "data-testid": dataTestId, onChange, value, id, setValue, register, validationRules, disabled, label, tip, isInvalid, errorMessage, helpAddon, maxLength, helpText, ...rest }: BooleanCustomFieldProps) => ReactElement;
|
|
80
|
+
export declare const BooleanCustomField: ({ defaultValue, "data-testid": dataTestId, onChange, value, id, setValue, register, validationRules, disabled, readOnly, label, tip, isInvalid, errorMessage, helpAddon, maxLength, helpText, ...rest }: BooleanCustomFieldProps) => ReactElement;
|