UNPKG

react-native-advanced-input-mask

Version:

Text input mask for React Native on iOS, Android and web. Synchronous and easy formatting without hustle

60 lines 1.81 kB
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } import React, { forwardRef, memo, useImperativeHandle, useRef } from "react"; import { TextInput } from "react-native"; import useMaskedTextInputListener from "../../hooks/useMaskedTextInputListener"; const MaskedTextInput = /*#__PURE__*/forwardRef(({ affinityCalculationStrategy, affinityFormat, autocomplete = true, autoSkip = false, customNotations, isRTL = false, mask, autoCapitalize = "words", allowedKeys, defaultValue, onChange, onChangeText, onTailPlaceholderChange, onFocus, renderTextInputComponent, validationRegex, ...rest }, ref) => { const InputComponent = renderTextInputComponent ?? TextInput; const inputRef = useRef(null); const { defaultValue: maskedDefaultValue, handleFocus, handleOnChange, setTextField } = useMaskedTextInputListener({ mask, affinityFormat, affinityCalculationStrategy, customNotations, allowedKeys, autocomplete, autoSkip, isRTL, onChange, onChangeText, onTailPlaceholderChange, onFocus, validationRegex, defaultValue }); useImperativeHandle(ref, () => { setTextField(inputRef.current); return inputRef.current; }, [setTextField, inputRef]); return /*#__PURE__*/React.createElement(InputComponent, _extends({ ref: inputRef, autoCapitalize: autoCapitalize, defaultValue: maskedDefaultValue, onChange: handleOnChange, onFocus: handleFocus }, rest)); }); export default /*#__PURE__*/memo(MaskedTextInput); //# sourceMappingURL=index.js.map