@trackunit/custom-field-components 1.14.15 → 1.15.0
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 +23 -19
- package/index.esm.js +23 -19
- package/package.json +7 -7
package/index.cjs.js
CHANGED
|
@@ -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
|
|
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 }) }));
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
/**
|
|
@@ -177,12 +177,12 @@ const DateCustomField = (props) => {
|
|
|
177
177
|
}
|
|
178
178
|
}, [setValue, id]);
|
|
179
179
|
react.useEffect(() => {
|
|
180
|
-
const value = defaultValue && new Date(defaultValue);
|
|
180
|
+
const value = Boolean(defaultValue) && defaultValue !== undefined ? new Date(defaultValue) : undefined;
|
|
181
181
|
if (register) {
|
|
182
182
|
register(id, { ...validationRules, value });
|
|
183
183
|
}
|
|
184
184
|
}, [register, validationRules, defaultValue, id]);
|
|
185
|
-
return (react.createElement(reactFormComponents.DateField, { ...rest, defaultValue: defaultValue, helpAddon: props.helpAddon
|
|
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 }));
|
|
186
186
|
};
|
|
187
187
|
|
|
188
188
|
const convertToValueFormat = (value) => {
|
|
@@ -348,18 +348,22 @@ const getWebAddressValidationRules = (definition) => {
|
|
|
348
348
|
*/
|
|
349
349
|
const getNumberValidationRules = (definition) => {
|
|
350
350
|
const defaultRules = { valueAsNumber: true };
|
|
351
|
-
const minimum = definition.minimumNumber &&
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
351
|
+
const minimum = definition.minimumNumber !== null && definition.minimumNumber !== undefined
|
|
352
|
+
? {
|
|
353
|
+
min: {
|
|
354
|
+
value: definition.minimumNumber,
|
|
355
|
+
message: `minimum value is ${definition.minimumNumber}`,
|
|
356
|
+
},
|
|
357
|
+
}
|
|
358
|
+
: undefined;
|
|
359
|
+
const maximum = definition.maximumNumber !== null && definition.maximumNumber !== undefined
|
|
360
|
+
? {
|
|
361
|
+
max: {
|
|
362
|
+
value: definition.maximumNumber,
|
|
363
|
+
message: `maximum value is ${definition.maximumNumber}`,
|
|
364
|
+
},
|
|
365
|
+
}
|
|
366
|
+
: undefined;
|
|
363
367
|
// TODO: Validate if integer if definition requires integer
|
|
364
368
|
return definition.uiEditable
|
|
365
369
|
? {
|
|
@@ -377,7 +381,7 @@ const getNumberValidationRules = (definition) => {
|
|
|
377
381
|
*/
|
|
378
382
|
const getStringValidationRules = (definition) => {
|
|
379
383
|
const defaultRules = {};
|
|
380
|
-
const minLength = definition.minimumLength
|
|
384
|
+
const minLength = definition.minimumLength !== null && definition.minimumLength !== undefined
|
|
381
385
|
? {
|
|
382
386
|
minLength: {
|
|
383
387
|
value: definition.minimumLength,
|
|
@@ -389,7 +393,7 @@ const getStringValidationRules = (definition) => {
|
|
|
389
393
|
},
|
|
390
394
|
}
|
|
391
395
|
: undefined;
|
|
392
|
-
const maxLength = definition.maximumLength
|
|
396
|
+
const maxLength = definition.maximumLength !== null && definition.maximumLength !== undefined
|
|
393
397
|
? {
|
|
394
398
|
maxLength: {
|
|
395
399
|
value: definition.maximumLength,
|
|
@@ -448,7 +452,7 @@ const getDropdownValidationRules = (definition) => {
|
|
|
448
452
|
*/
|
|
449
453
|
const getStringListValidationRules = (definition) => {
|
|
450
454
|
const defaultRules = {};
|
|
451
|
-
const itemMinLength = definition.itemMinimumLength
|
|
455
|
+
const itemMinLength = definition.itemMinimumLength !== null && definition.itemMinimumLength !== undefined
|
|
452
456
|
? {
|
|
453
457
|
minLength: {
|
|
454
458
|
value: definition.itemMinimumLength,
|
|
@@ -456,7 +460,7 @@ const getStringListValidationRules = (definition) => {
|
|
|
456
460
|
},
|
|
457
461
|
}
|
|
458
462
|
: undefined;
|
|
459
|
-
const itemMaxLength = definition.itemMaximumLength
|
|
463
|
+
const itemMaxLength = definition.itemMaximumLength !== null && definition.itemMaximumLength !== undefined
|
|
460
464
|
? {
|
|
461
465
|
maxLength: {
|
|
462
466
|
value: definition.itemMaximumLength,
|
package/index.esm.js
CHANGED
|
@@ -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
|
|
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 }) }));
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
/**
|
|
@@ -175,12 +175,12 @@ const DateCustomField = (props) => {
|
|
|
175
175
|
}
|
|
176
176
|
}, [setValue, id]);
|
|
177
177
|
useEffect(() => {
|
|
178
|
-
const value = defaultValue && new Date(defaultValue);
|
|
178
|
+
const value = Boolean(defaultValue) && defaultValue !== undefined ? new Date(defaultValue) : undefined;
|
|
179
179
|
if (register) {
|
|
180
180
|
register(id, { ...validationRules, value });
|
|
181
181
|
}
|
|
182
182
|
}, [register, validationRules, defaultValue, id]);
|
|
183
|
-
return (createElement(DateField, { ...rest, defaultValue: defaultValue, helpAddon: props.helpAddon
|
|
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 }));
|
|
184
184
|
};
|
|
185
185
|
|
|
186
186
|
const convertToValueFormat = (value) => {
|
|
@@ -346,18 +346,22 @@ const getWebAddressValidationRules = (definition) => {
|
|
|
346
346
|
*/
|
|
347
347
|
const getNumberValidationRules = (definition) => {
|
|
348
348
|
const defaultRules = { valueAsNumber: true };
|
|
349
|
-
const minimum = definition.minimumNumber &&
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
349
|
+
const minimum = definition.minimumNumber !== null && definition.minimumNumber !== undefined
|
|
350
|
+
? {
|
|
351
|
+
min: {
|
|
352
|
+
value: definition.minimumNumber,
|
|
353
|
+
message: `minimum value is ${definition.minimumNumber}`,
|
|
354
|
+
},
|
|
355
|
+
}
|
|
356
|
+
: undefined;
|
|
357
|
+
const maximum = definition.maximumNumber !== null && definition.maximumNumber !== undefined
|
|
358
|
+
? {
|
|
359
|
+
max: {
|
|
360
|
+
value: definition.maximumNumber,
|
|
361
|
+
message: `maximum value is ${definition.maximumNumber}`,
|
|
362
|
+
},
|
|
363
|
+
}
|
|
364
|
+
: undefined;
|
|
361
365
|
// TODO: Validate if integer if definition requires integer
|
|
362
366
|
return definition.uiEditable
|
|
363
367
|
? {
|
|
@@ -375,7 +379,7 @@ const getNumberValidationRules = (definition) => {
|
|
|
375
379
|
*/
|
|
376
380
|
const getStringValidationRules = (definition) => {
|
|
377
381
|
const defaultRules = {};
|
|
378
|
-
const minLength = definition.minimumLength
|
|
382
|
+
const minLength = definition.minimumLength !== null && definition.minimumLength !== undefined
|
|
379
383
|
? {
|
|
380
384
|
minLength: {
|
|
381
385
|
value: definition.minimumLength,
|
|
@@ -387,7 +391,7 @@ const getStringValidationRules = (definition) => {
|
|
|
387
391
|
},
|
|
388
392
|
}
|
|
389
393
|
: undefined;
|
|
390
|
-
const maxLength = definition.maximumLength
|
|
394
|
+
const maxLength = definition.maximumLength !== null && definition.maximumLength !== undefined
|
|
391
395
|
? {
|
|
392
396
|
maxLength: {
|
|
393
397
|
value: definition.maximumLength,
|
|
@@ -446,7 +450,7 @@ const getDropdownValidationRules = (definition) => {
|
|
|
446
450
|
*/
|
|
447
451
|
const getStringListValidationRules = (definition) => {
|
|
448
452
|
const defaultRules = {};
|
|
449
|
-
const itemMinLength = definition.itemMinimumLength
|
|
453
|
+
const itemMinLength = definition.itemMinimumLength !== null && definition.itemMinimumLength !== undefined
|
|
450
454
|
? {
|
|
451
455
|
minLength: {
|
|
452
456
|
value: definition.itemMinimumLength,
|
|
@@ -454,7 +458,7 @@ const getStringListValidationRules = (definition) => {
|
|
|
454
458
|
},
|
|
455
459
|
}
|
|
456
460
|
: undefined;
|
|
457
|
-
const itemMaxLength = definition.itemMaximumLength
|
|
461
|
+
const itemMaxLength = definition.itemMaximumLength !== null && definition.itemMaximumLength !== undefined
|
|
458
462
|
? {
|
|
459
463
|
maxLength: {
|
|
460
464
|
value: definition.itemMaximumLength,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/custom-field-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -10,14 +10,14 @@
|
|
|
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.
|
|
13
|
+
"@trackunit/react-form-components": "1.16.0",
|
|
14
14
|
"@trackunit/shared-utils": "1.13.68",
|
|
15
|
-
"@trackunit/custom-field-api": "1.
|
|
16
|
-
"@trackunit/iris-app-runtime-core": "1.13.
|
|
15
|
+
"@trackunit/custom-field-api": "1.15.0",
|
|
16
|
+
"@trackunit/iris-app-runtime-core": "1.13.54",
|
|
17
17
|
"@trackunit/react-components": "1.18.9",
|
|
18
|
-
"@trackunit/react-modal": "1.
|
|
19
|
-
"@trackunit/react-core-hooks": "1.12.
|
|
20
|
-
"@trackunit/i18n-library-translation": "1.
|
|
18
|
+
"@trackunit/react-modal": "1.16.0",
|
|
19
|
+
"@trackunit/react-core-hooks": "1.12.57",
|
|
20
|
+
"@trackunit/i18n-library-translation": "1.13.0",
|
|
21
21
|
"@trackunit/iris-app-runtime-core-api": "1.12.51"
|
|
22
22
|
},
|
|
23
23
|
"module": "./index.esm.js",
|