@dartech/arsenal-ui 1.4.5 → 1.4.7
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +27 -32
- package/package.json +1 -1
- package/src/lib/Forms/ControlPhoneInput.d.ts +3 -1
package/index.js
CHANGED
@@ -1054,8 +1054,7 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1054
1054
|
rules: {
|
1055
1055
|
required: required && 'Please, fill this field',
|
1056
1056
|
validate: val => {
|
1057
|
-
|
1058
|
-
if (val && validateJson) {
|
1057
|
+
if (val && validateJson && typeof val === 'string') {
|
1059
1058
|
try {
|
1060
1059
|
JSON.parse(val);
|
1061
1060
|
return true;
|
@@ -1112,7 +1111,7 @@ const ControlAceEditor = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
1112
1111
|
}
|
1113
1112
|
}, {
|
1114
1113
|
children: required ? jsxs(Fragment, {
|
1115
|
-
children: [label,
|
1114
|
+
children: [label, ' ', jsx(Box, Object.assign({
|
1116
1115
|
component: "span",
|
1117
1116
|
color: "#D6331F"
|
1118
1117
|
}, {
|
@@ -2552,9 +2551,10 @@ const ControlPhoneInput = _a => {
|
|
2552
2551
|
name,
|
2553
2552
|
label,
|
2554
2553
|
required,
|
2555
|
-
mask = '+7 (799) 999 99 99'
|
2554
|
+
mask = '+7 (799) 999 99 99',
|
2555
|
+
inputMaskProps
|
2556
2556
|
} = _a,
|
2557
|
-
textFieldProps = __rest(_a, ["control", "name", "label", "required", "mask"]);
|
2557
|
+
textFieldProps = __rest(_a, ["control", "name", "label", "required", "mask", "inputMaskProps"]);
|
2558
2558
|
return jsx(Controller, {
|
2559
2559
|
control: control,
|
2560
2560
|
name: name,
|
@@ -2573,8 +2573,11 @@ const ControlPhoneInput = _a => {
|
|
2573
2573
|
error
|
2574
2574
|
}
|
2575
2575
|
}) => jsx(InputMask, Object.assign({
|
2576
|
-
mask: mask
|
2577
|
-
|
2576
|
+
mask: mask,
|
2577
|
+
value: field.value,
|
2578
|
+
onChange: field.onChange,
|
2579
|
+
onBlur: field.onBlur
|
2580
|
+
}, inputMaskProps, {
|
2578
2581
|
children: jsx(TextField, Object.assign({
|
2579
2582
|
fullWidth: true,
|
2580
2583
|
size: "small",
|
@@ -5816,11 +5819,12 @@ const PropertyFiller = ({
|
|
5816
5819
|
const {
|
5817
5820
|
control,
|
5818
5821
|
clearErrors,
|
5819
|
-
setValue
|
5820
|
-
watch
|
5822
|
+
setValue
|
5821
5823
|
} = useFormContext();
|
5822
5824
|
const {
|
5823
|
-
|
5825
|
+
field: {
|
5826
|
+
value
|
5827
|
+
},
|
5824
5828
|
fieldState: {
|
5825
5829
|
error,
|
5826
5830
|
isDirty
|
@@ -5835,11 +5839,6 @@ const PropertyFiller = ({
|
|
5835
5839
|
}
|
5836
5840
|
}
|
5837
5841
|
});
|
5838
|
-
// const value = watch(name);
|
5839
|
-
const value = useWatch({
|
5840
|
-
control,
|
5841
|
-
name
|
5842
|
-
});
|
5843
5842
|
const prevValueRef = useRef({});
|
5844
5843
|
const {
|
5845
5844
|
propertyType,
|
@@ -5913,26 +5912,22 @@ const PropertyFiller = ({
|
|
5913
5912
|
clearErrors();
|
5914
5913
|
}, [name, defaultProperyValue, clearErrors, value, setFillOption, fillOption, propertyType, setValue, property]);
|
5915
5914
|
useEffect(() => {
|
5916
|
-
|
5917
|
-
|
5918
|
-
|
5919
|
-
|
5915
|
+
var _a;
|
5916
|
+
if (!isDirty && isPropertyValueEmpty(value)) {
|
5917
|
+
if (property.isRequired && (property.defaultValue === null || property.value === null)) {
|
5918
|
+
setValue(name, (_a = prevValueRef.current[fillOption]) !== null && _a !== void 0 ? _a : defaultProperyValue);
|
5919
|
+
} else if (!property.isRequired && (property.defaultValue === null || property.value === null)) {
|
5920
|
+
setValue(name, null);
|
5921
|
+
} else if (!(isPropertyValueEmpty(property.defaultValue) || isPropertyValueEmpty(property.value))) {
|
5922
|
+
setValue(name, property.defaultValue || property.value);
|
5923
|
+
}
|
5920
5924
|
}
|
5921
|
-
}, [
|
5925
|
+
}, [value, setValue, defaultProperyValue, property, name, fillOption, isDirty]);
|
5922
5926
|
useEffect(() => {
|
5923
|
-
|
5924
|
-
|
5925
|
-
// value === undefined ||
|
5926
|
-
property.isRequired && isPropertyValueEmpty(value) && (property.defaultValue === null || property.value === null)) {
|
5927
|
-
setValue(name, (_a = prevValueRef.current[fillOption]) !== null && _a !== void 0 ? _a : defaultProperyValue, {
|
5928
|
-
shouldDirty: true
|
5929
|
-
});
|
5930
|
-
} else if ((value === undefined || value === null) && !property.isRequired && (property.defaultValue === null || property.value === null)) {
|
5931
|
-
setValue(name, null, {
|
5932
|
-
shouldDirty: true
|
5933
|
-
});
|
5927
|
+
if (!isPropertyValueEmpty(value) && property.propertyType !== PropertyType.JSON) {
|
5928
|
+
setValue(name, value);
|
5934
5929
|
}
|
5935
|
-
}, [
|
5930
|
+
}, [name, setValue, value, property]);
|
5936
5931
|
return jsxs(Grid, Object.assign({
|
5937
5932
|
xs: 12
|
5938
5933
|
}, {
|
package/package.json
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
import { ReactNode } from 'react';
|
2
2
|
import { TextFieldProps } from '@mui/material/TextField';
|
3
3
|
import { Control } from 'react-hook-form';
|
4
|
+
import { Props as InputMaskProps } from 'react-input-mask';
|
4
5
|
type Props = TextFieldProps & {
|
5
6
|
control: Control<any>;
|
6
7
|
name: string;
|
7
8
|
required?: boolean;
|
8
9
|
mask?: string;
|
9
10
|
label?: ReactNode;
|
11
|
+
inputMaskProps?: InputMaskProps;
|
10
12
|
};
|
11
|
-
export declare const ControlPhoneInput: ({ control, name, label, required, mask, ...textFieldProps }: Props) => JSX.Element;
|
13
|
+
export declare const ControlPhoneInput: ({ control, name, label, required, mask, inputMaskProps, ...textFieldProps }: Props) => JSX.Element;
|
12
14
|
export default ControlPhoneInput;
|