This packages requires react@16.8
and react-dom@16.8
. That's because it uses hooks under the hood, even though everything could be done with class-based components. If you need support for a version prior than the one with hooks, please open an issue.
yarn add maskose maskose-react
or with npm:
npm install maskose maskose-react
Prop name | Type | Description |
---|---|---|
mask | MaskoseMask |
The mask to be used when masking the value. |
maskedValue | string |
The current masked value (the value in the input). |
onMaskedValueChange | (maskedValue: string) => void |
Callback that will be called every time the masked value (input value) changes. |
const priceMask = mkBoostMask(
mkCreate([
mkCharBoostRepeat(3)(mkCharNum()),
mkCharToBePut('.'),
mkCharBoostRepeat(2)(mkCharNum()),
])
)([
mkMaskBoostRightToLeft()
]);
function Form() {
const [price, setPrice] = useState('');
return (
<>
<MaskoseInput
mask={priceMask}
maskedValue={price}
onMaskedValueChange={setPrice}
/>
</>
);
}
If you're looking for the docs of the maskose lib, you can find them here.