@trackunit/custom-field-components 0.0.565 → 0.0.569
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 -2
- package/index.esm.js +7 -3
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -278,7 +278,9 @@ const getEmailValidationRules = (definition) => {
|
|
|
278
278
|
const getPhoneNumberValidationRules = (definition) => {
|
|
279
279
|
const defaultRules = {};
|
|
280
280
|
const pattern = {
|
|
281
|
-
validate: value =>
|
|
281
|
+
validate: value => {
|
|
282
|
+
return value === "" || value === undefined || libphonenumberJs.isValidPhoneNumber(value);
|
|
283
|
+
},
|
|
282
284
|
};
|
|
283
285
|
return definition.uiEditable
|
|
284
286
|
? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
|
|
@@ -334,7 +336,9 @@ const useCustomFieldResolver = ({ field, register, setValue, formState, unitPref
|
|
|
334
336
|
case "PhoneNumberFieldValueAndDefinition": {
|
|
335
337
|
const value = field.stringValue;
|
|
336
338
|
const rules = getPhoneNumberValidationRules(field.definition);
|
|
337
|
-
return (jsxRuntime.jsx(reactFormComponents.
|
|
339
|
+
return (jsxRuntime.jsx(reactFormComponents.PhoneField, Object.assign({ label: title, id: uniqueIdentifier, placeholder: title !== null && title !== void 0 ? title : "", defaultValue: value !== null && value !== void 0 ? value : "", value: value !== null && value !== void 0 ? value : "", dataTestId: `${field.definition.key}`, readOnly: !isEditableCombined, helpText: description, isCountryCodeClearable: !!isEditableCombined }, validation.register(key, rules), { onChangeValue: props => {
|
|
340
|
+
validation.setValue(key, props.phone);
|
|
341
|
+
} })));
|
|
338
342
|
}
|
|
339
343
|
case "StringFieldValueAndDefinition": {
|
|
340
344
|
const value = field.stringValue;
|
package/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { CustomFieldRuntime } from '@trackunit/iris-app-runtime-core';
|
|
3
|
-
import { FormGroup, Checkbox, DateField, Select, NumberField, TextField, ActionButton } from '@trackunit/react-form-components';
|
|
3
|
+
import { FormGroup, Checkbox, DateField, Select, NumberField, TextField, PhoneField, ActionButton } from '@trackunit/react-form-components';
|
|
4
4
|
import { exhaustiveCheck } from '@trackunit/shared-utils';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { useCallback, useEffect, createElement, useState } from 'react';
|
|
@@ -255,7 +255,9 @@ const getEmailValidationRules = (definition) => {
|
|
|
255
255
|
const getPhoneNumberValidationRules = (definition) => {
|
|
256
256
|
const defaultRules = {};
|
|
257
257
|
const pattern = {
|
|
258
|
-
validate: value =>
|
|
258
|
+
validate: value => {
|
|
259
|
+
return value === "" || value === undefined || isValidPhoneNumber(value);
|
|
260
|
+
},
|
|
259
261
|
};
|
|
260
262
|
return definition.uiEditable
|
|
261
263
|
? Object.assign(Object.assign({}, pattern), defaultRules) : defaultRules;
|
|
@@ -311,7 +313,9 @@ const useCustomFieldResolver = ({ field, register, setValue, formState, unitPref
|
|
|
311
313
|
case "PhoneNumberFieldValueAndDefinition": {
|
|
312
314
|
const value = field.stringValue;
|
|
313
315
|
const rules = getPhoneNumberValidationRules(field.definition);
|
|
314
|
-
return (jsx(
|
|
316
|
+
return (jsx(PhoneField, Object.assign({ label: title, id: uniqueIdentifier, placeholder: title !== null && title !== void 0 ? title : "", defaultValue: value !== null && value !== void 0 ? value : "", value: value !== null && value !== void 0 ? value : "", dataTestId: `${field.definition.key}`, readOnly: !isEditableCombined, helpText: description, isCountryCodeClearable: !!isEditableCombined }, validation.register(key, rules), { onChangeValue: props => {
|
|
317
|
+
validation.setValue(key, props.phone);
|
|
318
|
+
} })));
|
|
315
319
|
}
|
|
316
320
|
case "StringFieldValueAndDefinition": {
|
|
317
321
|
const value = field.stringValue;
|