CaioQuirinoMedeiros / react-native-mask-input

🎭:iphone: A simple and effective Text Input with mask for ReactNative on iOS and Android. Includes obfuscation characters feature.
https://www.npmjs.com/package/react-native-mask-input
MIT License
309 stars 31 forks source link

Support "suffix" with `createNumberMask ` #39

Closed robbporto closed 1 year ago

robbporto commented 1 year ago

Is it possible to have a suffix option, similar to the already implemented prefix option for the createNumberMask function?

Something like:

import MaskInput, { createNumberMask } from 'react-native-mask-input';

const dollarMask = createNumberMask({
  suffix: ['%'],
  delimiter: '',
  separator: '',
  precision: 0,
})

function MyComponent() {
  const [value, setValue] = React.useState('');

  return (
    <MaskInput
      value={value}
      mask={dollarMask}
      onChangeText={(masked, unmasked) => {
        setValue(unmasked); // you can use the masked value as well

        // assuming you typed "10":
        console.log(masked); // "10%"
        console.log(unmasked); // "10"
      }}
    />
  );
}
CaioQuirinoMedeiros commented 1 year ago

no, it's not