@trackunit/custom-field-components 1.12.17 → 1.13.6
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 +11 -4
- package/index.esm.js +11 -4
- package/package.json +10 -10
package/index.cjs.js
CHANGED
|
@@ -143,7 +143,9 @@ const BooleanCustomField = ({ defaultValue, "data-testid": dataTestId = "boolean
|
|
|
143
143
|
setInternalValue((value === undefined ? defaultValue : value) || false);
|
|
144
144
|
}, [value, setInternalValue, defaultValue]);
|
|
145
145
|
const onChangeHandler = react.useCallback((event) => {
|
|
146
|
-
|
|
146
|
+
if (onChange) {
|
|
147
|
+
onChange(event);
|
|
148
|
+
}
|
|
147
149
|
const isChecked = event.target.checked || false;
|
|
148
150
|
if (setValue) {
|
|
149
151
|
setValue(id, isChecked);
|
|
@@ -151,7 +153,9 @@ const BooleanCustomField = ({ defaultValue, "data-testid": dataTestId = "boolean
|
|
|
151
153
|
setInternalValue(isChecked);
|
|
152
154
|
}, [setInternalValue, onChange, id, setValue]);
|
|
153
155
|
react.useEffect(() => {
|
|
154
|
-
|
|
156
|
+
if (register) {
|
|
157
|
+
register(id, { ...validationRules, value: internalValue.toString() });
|
|
158
|
+
}
|
|
155
159
|
});
|
|
156
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 => (!rest.readOnly ? onChangeHandler(event) : null), ...rest }) }));
|
|
157
161
|
};
|
|
@@ -165,15 +169,18 @@ const BooleanCustomField = ({ defaultValue, "data-testid": dataTestId = "boolean
|
|
|
165
169
|
const DateCustomField = (props) => {
|
|
166
170
|
const { setValue, defaultValue, register, id, validationRules, ...rest } = props;
|
|
167
171
|
const onChangeHandler = react.useCallback((e) => {
|
|
168
|
-
setValue
|
|
172
|
+
if (setValue) {
|
|
169
173
|
setValue(id, e.target.valueAsDate?.toISOString(), {
|
|
170
174
|
shouldDirty: true,
|
|
171
175
|
shouldValidate: true,
|
|
172
176
|
});
|
|
177
|
+
}
|
|
173
178
|
}, [setValue, id]);
|
|
174
179
|
react.useEffect(() => {
|
|
175
180
|
const value = defaultValue && new Date(defaultValue);
|
|
176
|
-
|
|
181
|
+
if (register) {
|
|
182
|
+
register(id, { ...validationRules, value });
|
|
183
|
+
}
|
|
177
184
|
}, [register, validationRules, defaultValue, id]);
|
|
178
185
|
return (react.createElement(reactFormComponents.DateField, { ...rest, defaultValue: defaultValue, helpAddon: props.helpAddon || null, helpText: props.errorMessage || props.helpText, id: id, key: id, label: props.title, onChange: onChangeHandler }));
|
|
179
186
|
};
|
package/index.esm.js
CHANGED
|
@@ -141,7 +141,9 @@ const BooleanCustomField = ({ defaultValue, "data-testid": dataTestId = "boolean
|
|
|
141
141
|
setInternalValue((value === undefined ? defaultValue : value) || false);
|
|
142
142
|
}, [value, setInternalValue, defaultValue]);
|
|
143
143
|
const onChangeHandler = useCallback((event) => {
|
|
144
|
-
|
|
144
|
+
if (onChange) {
|
|
145
|
+
onChange(event);
|
|
146
|
+
}
|
|
145
147
|
const isChecked = event.target.checked || false;
|
|
146
148
|
if (setValue) {
|
|
147
149
|
setValue(id, isChecked);
|
|
@@ -149,7 +151,9 @@ const BooleanCustomField = ({ defaultValue, "data-testid": dataTestId = "boolean
|
|
|
149
151
|
setInternalValue(isChecked);
|
|
150
152
|
}, [setInternalValue, onChange, id, setValue]);
|
|
151
153
|
useEffect(() => {
|
|
152
|
-
|
|
154
|
+
if (register) {
|
|
155
|
+
register(id, { ...validationRules, value: internalValue.toString() });
|
|
156
|
+
}
|
|
153
157
|
});
|
|
154
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 => (!rest.readOnly ? onChangeHandler(event) : null), ...rest }) }));
|
|
155
159
|
};
|
|
@@ -163,15 +167,18 @@ const BooleanCustomField = ({ defaultValue, "data-testid": dataTestId = "boolean
|
|
|
163
167
|
const DateCustomField = (props) => {
|
|
164
168
|
const { setValue, defaultValue, register, id, validationRules, ...rest } = props;
|
|
165
169
|
const onChangeHandler = useCallback((e) => {
|
|
166
|
-
setValue
|
|
170
|
+
if (setValue) {
|
|
167
171
|
setValue(id, e.target.valueAsDate?.toISOString(), {
|
|
168
172
|
shouldDirty: true,
|
|
169
173
|
shouldValidate: true,
|
|
170
174
|
});
|
|
175
|
+
}
|
|
171
176
|
}, [setValue, id]);
|
|
172
177
|
useEffect(() => {
|
|
173
178
|
const value = defaultValue && new Date(defaultValue);
|
|
174
|
-
|
|
179
|
+
if (register) {
|
|
180
|
+
register(id, { ...validationRules, value });
|
|
181
|
+
}
|
|
175
182
|
}, [register, validationRules, defaultValue, id]);
|
|
176
183
|
return (createElement(DateField, { ...rest, defaultValue: defaultValue, helpAddon: props.helpAddon || null, helpText: props.errorMessage || props.helpText, id: id, key: id, label: props.title, onChange: onChangeHandler }));
|
|
177
184
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/custom-field-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.6",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
"react": "19.0.0",
|
|
11
11
|
"react-hook-form": "7.62.0",
|
|
12
12
|
"react-select": "^5.10.2",
|
|
13
|
-
"@trackunit/react-form-components": "1.
|
|
14
|
-
"@trackunit/shared-utils": "1.13.
|
|
15
|
-
"@trackunit/custom-field-api": "1.
|
|
16
|
-
"@trackunit/iris-app-runtime-core": "1.13.
|
|
17
|
-
"@trackunit/react-components": "1.
|
|
18
|
-
"@trackunit/react-modal": "1.
|
|
19
|
-
"@trackunit/react-core-hooks": "1.12.
|
|
20
|
-
"@trackunit/i18n-library-translation": "1.12.
|
|
21
|
-
"@trackunit/iris-app-runtime-core-api": "1.12.
|
|
13
|
+
"@trackunit/react-form-components": "1.14.5",
|
|
14
|
+
"@trackunit/shared-utils": "1.13.32",
|
|
15
|
+
"@trackunit/custom-field-api": "1.13.5",
|
|
16
|
+
"@trackunit/iris-app-runtime-core": "1.13.15",
|
|
17
|
+
"@trackunit/react-components": "1.17.3",
|
|
18
|
+
"@trackunit/react-modal": "1.14.6",
|
|
19
|
+
"@trackunit/react-core-hooks": "1.12.16",
|
|
20
|
+
"@trackunit/i18n-library-translation": "1.12.16",
|
|
21
|
+
"@trackunit/iris-app-runtime-core-api": "1.12.13"
|
|
22
22
|
},
|
|
23
23
|
"module": "./index.esm.js",
|
|
24
24
|
"main": "./index.cjs.js",
|