@bluemarble/bm-components 0.0.86 → 0.0.88
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/dist/esm/index.js
CHANGED
|
@@ -14817,28 +14817,39 @@ function InputMask(_a) {
|
|
|
14817
14817
|
return React__default.createElement(BaseInputMask, Object.assign({}, rest));
|
|
14818
14818
|
}
|
|
14819
14819
|
const BaseInputMask = (_a) => {
|
|
14820
|
-
var { mask, defaultValue, onChangeValue } = _a, rest = __rest(_a, ["mask", "defaultValue", "onChangeValue"]);
|
|
14821
|
-
const { ref, value,
|
|
14820
|
+
var { mask, defaultValue, onChangeValue, value: controlledValue } = _a, rest = __rest(_a, ["mask", "defaultValue", "onChangeValue", "value"]);
|
|
14821
|
+
const { ref, value, setValue, maskRef, unmaskedValue } = useIMask(mask, {
|
|
14822
|
+
onComplete: (...params) => {
|
|
14823
|
+
// console.log( )
|
|
14824
|
+
if (onChangeValue)
|
|
14825
|
+
onChangeValue(params[0], unmaskedValue);
|
|
14826
|
+
// params[1].updateValue()
|
|
14827
|
+
}
|
|
14828
|
+
});
|
|
14822
14829
|
useEffect(() => {
|
|
14823
14830
|
if (!value)
|
|
14824
14831
|
setValue(String(defaultValue));
|
|
14832
|
+
maskRef.current.value = String(defaultValue);
|
|
14825
14833
|
}, [defaultValue]);
|
|
14826
14834
|
useEffect(() => {
|
|
14827
|
-
|
|
14828
|
-
|
|
14829
|
-
}, [
|
|
14835
|
+
setValue(controlledValue);
|
|
14836
|
+
maskRef.current.value = controlledValue;
|
|
14837
|
+
}, [controlledValue]);
|
|
14830
14838
|
return React__default.createElement(BaseInput$1, Object.assign({ inputRef: ref }, rest));
|
|
14831
14839
|
};
|
|
14832
14840
|
function FormikInputMask(_a) {
|
|
14833
14841
|
var { mask, defaultValue, name } = _a, rest = __rest(_a, ["mask", "defaultValue", "name"]);
|
|
14834
|
-
const { ref, value, unmaskedValue, setValue } = useIMask(mask);
|
|
14842
|
+
const { ref, value, unmaskedValue, maskRef, setValue } = useIMask(mask);
|
|
14835
14843
|
const initialValue = useRef();
|
|
14836
14844
|
const formikSaveFunction = useRef();
|
|
14837
14845
|
useEffect(() => {
|
|
14838
|
-
if (!value && defaultValue)
|
|
14846
|
+
if (!value && defaultValue) {
|
|
14839
14847
|
setValue(String(defaultValue));
|
|
14848
|
+
maskRef.current.value = String(defaultValue);
|
|
14849
|
+
}
|
|
14840
14850
|
else if (initialValue.current) {
|
|
14841
14851
|
setValue(String(initialValue.current));
|
|
14852
|
+
maskRef.current.value = String(initialValue.current);
|
|
14842
14853
|
}
|
|
14843
14854
|
}, [defaultValue]);
|
|
14844
14855
|
useEffect(() => {
|