Package Exports
- text-mask-addons/dist/createNumberMask
- text-mask-addons/dist/createNumberMask.js
- text-mask-addons/dist/emailMask
- text-mask-addons/dist/emailMask.js
- text-mask-addons/src/createNumberMask
- text-mask-addons/src/emailMask.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (text-mask-addons) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Text Mask Addons
These addons are ready-to-use pipes and masks that can be used with Text Mask.
Installation
npm i text-mask-addons --saveMasks
These can be passed as a
mask
to Text Mask.
createNumberMask
createNumberMask returns a numberMask function that will format user input as currency.
createNumberMask accepts an object with the following keys:
prefix(string): what to display before the amount. Defaults to'$'.suffix(string): what to display after the amount. Defaults to empty string.includeThousandsSeparator(boolean): whether or not to separate thousands. Defaults to totrue.thousandsSeparatorSymbol(string): character with which to separate thousands. Default to','.allowDecimal(boolean): whether or not to allow the user to enter a fraction with the amount. Default tofalse.decimalSymbol(string): character that will act as a decimal point. Defaults to'.'decimalLimit(number): how many digits to allow after the decimal. Defaults to2requireDecimal(boolean): whether or not to always include a decimal point and placeholder for decimal digits after the integer. Defaults tofalse.
Usage
import createNumberMask from 'text-mask-addons/dist/createNumberMask.js'
const numberMask = createNumberMask({
prefix: '',
suffix: ' $' // This will put the dollar sign at the end, with a space.
})
// ...then pass `numberMask` to the Text Mask componentemailMask
emailMask formats user input as an email address.
Usage
import emailMask from 'text-mask-addons/dist/emailMask.js'
// ...then pass `emailMask` to the Text Mask componentTechnical side note: even though emailMask is passed as a mask, it is actually made of both a mask and a pipe bundled
together for convenience. The Text Mask component knows how to unwrap and separate the pipe and mask functions to use them.
Pipes
These functions here can be passed as a
pipe
to Text Mask.
autoCorrectedMmddyyyyPipe
The autoCorrectedMmddyyyyPipe helps the user in entering a date in the MM/DD/YYYY format.
For example, if the user enters a value
larger than 1 in the 1st slot of month, it appends 0 to it. That is 4 => 04. It does a similar thing for the
day slots.
And for the year, when the user enters 0 in the 1st slot of the year, it transforms that to 200.
It also blocks the user from entering invalid days or months such as 33/44.
For autoCorrectedMmddyyyyPipe to work properly, the Text Mask component needs to be
configured with
keepCharPositions
set to true.
Usage
import autoCorrectedMmddyyyyPipe from 'text-mask-addons/dist/autoCorrectedMmddyyyyPipe.js'
// ...then pass `autoCorrectedMmddyyyyPipe` to the Text Mask component