How to use the text-mask-addons.createNumberMask function in text-mask-addons

To help you get started, we’ve selected a few text-mask-addons examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github formio / formio.js / src / components / number / Number.js View on Github external
this.delimiter = this.options.thousandsSeparator || separators.delimiter;
    }
    else {
      this.delimiter = '';
    }

    this.decimalLimit = getNumberDecimalLimit(this.component);

    // Currencies to override BrowserLanguage Config. Object key {}
    if (_.has(this.options, `languageOverride.${this.options.language}`)) {
      const override = _.get(this.options, `languageOverride.${this.options.language}`);
      this.decimalSeparator = override.decimalSeparator;
      this.delimiter = override.delimiter;
    }
    this.numberMask = createNumberMask({
      prefix: '',
      suffix: '',
      requireDecimal: this.component.requireDecimal ?? false,
      thousandsSeparatorSymbol: this.component.thousandsSeparator ?? this.delimiter,
      decimalSymbol: this.component.decimalSymbol ?? this.decimalSeparator,
      decimalLimit: this.component.decimalLimit ?? this.decimalLimit,
      allowNegative: this.component.allowNegative ?? true,
      allowDecimal: this.component.allowDecimal ?? !this.component.validate?.integer,
      fillGaps: this.component.decimalLimit && this.component.requireDecimal,
    });
  }
github formio / ngFormio / src / directives / formioMask.js View on Github external
}

        var mask;
        if (scope.component.inputMask) {
          // Text or other input mask, including number with inputMask.
          mask = formioUtils.getInputMask(scope.component.inputMask);
        }
        else if (format === 'currency') {
          maskOptions.prefix = scope.prefix;
          maskOptions.suffix = scope.suffix;
          // Currency mask.
          mask = createNumberMask(maskOptions);
        }
        else if (format === 'number') {
          // Numeric input mask.
          mask = createNumberMask(maskOptions);
        }
        else if (format === 'datetime') {
          mask = formioUtils.getInputMask((scope.component.format.replace(/[hHmMyYdD]/g, '9').replace(/[a]/g, 'P')));
          mask.forEach(function(item, index) {
            if (item === 'P') {
              mask[index] = /[AP]/;
              mask.splice(index + 1, 0, /[M]/);
            }
          });
        }

        // Set the mask on the input element.
        if (mask) {
          scope.inputMask = mask;
          maskInput({
            inputElement: input,
github formio / formio.js / src / components / currency / Currency.js View on Github external
createNumberMask() {
    const decimalLimit = _.get(this.component, 'decimalLimit', 2);
    const affixes = getCurrencyAffixes({
      currency: this.component.currency,
      decimalLimit: decimalLimit,
      decimalSeparator: this.decimalSeparator,
      lang: this.options.language
    });
    this.prefix = this.options.prefix || affixes.prefix;
    this.suffix = this.options.suffix || affixes.suffix;
    return createNumberMask({
      prefix: this.prefix,
      suffix: this.suffix,
      thousandsSeparatorSymbol: _.get(this.component, 'thousandsSeparator', this.delimiter),
      decimalSymbol: _.get(this.component, 'decimalSymbol', this.decimalSeparator),
      decimalLimit: decimalLimit,
      allowNegative: _.get(this.component, 'allowNegative', true),
      allowDecimal: _.get(this.component, 'allowDecimal', true)
    });
  }
github webkom-co / airframe-next / pages / forms / text-mask.js View on Github external
Row,
    Card,
    CardBody,
    Container,
    Col,
    FormGroup,
    Label,
    Input
} from './../../components';

import { HeaderMain } from "../../features/HeaderMain";

const autoCorrectedDatePipe = createAutoCorrectedDatePipe('mm/dd/yyyy');
const dolarsMask = createNumberMask({ prefix: '$' });
const dolarsMaskDecimal = createNumberMask({ prefix: '$', allowDecimal: true });
const percentageMask = createNumberMask({ prefix: '', suffix: '%', integerLimit: 3 });
const upperCasePipe = conformedValue => conformedValue.toUpperCase();

const TextMask = () => (
    
        
        <p>
            Text Mask is an input mask library. 
            It can create input masks for <code>phone</code>, 
            <code>date</code>, <code>currency</code>, <code>zip code</code>, <code>percentage</code>, <code>email</code>, and literally anything!
        </p>
github formio / formio.js / src / components / number / Number.js View on Github external
createNumberMask() {
    return createNumberMask({
      prefix: '',
      suffix: '',
      requireDecimal: _.get(this.component, 'requireDecimal', false),
      thousandsSeparatorSymbol: _.get(this.component, 'thousandsSeparator', this.delimiter),
      decimalSymbol: _.get(this.component, 'decimalSymbol', this.decimalSeparator),
      decimalLimit: _.get(this.component, 'decimalLimit', this.decimalLimit),
      allowNegative: _.get(this.component, 'allowNegative', true),
      allowDecimal: _.get(this.component, 'allowDecimal',
        !(this.component.validate && this.component.validate.integer))
    });
  }
github webkom-co / airframe-next / pages / forms / text-mask.js View on Github external
import {
    Row,
    Card,
    CardBody,
    Container,
    Col,
    FormGroup,
    Label,
    Input
} from './../../components';

import { HeaderMain } from "../../features/HeaderMain";

const autoCorrectedDatePipe = createAutoCorrectedDatePipe('mm/dd/yyyy');
const dolarsMask = createNumberMask({ prefix: '$' });
const dolarsMaskDecimal = createNumberMask({ prefix: '$', allowDecimal: true });
const percentageMask = createNumberMask({ prefix: '', suffix: '%', integerLimit: 3 });
const upperCasePipe = conformedValue =&gt; conformedValue.toUpperCase();

const TextMask = () =&gt; (
    
        
        <p>
            Text Mask is an input mask library. 
            It can create input masks for <code>phone</code>, 
            <code>date</code>, <code>currency</code>, <code>zip code</code>, <code>percentage</code>, <code>email</code>, and literally anything!
        </p>
github webkom-co / airframe-next / pages / forms / text-mask.js View on Github external
import {
    Row,
    Card,
    CardBody,
    Container,
    Col,
    FormGroup,
    Label,
    Input
} from './../../components';

import { HeaderMain } from "../../features/HeaderMain";

const autoCorrectedDatePipe = createAutoCorrectedDatePipe('mm/dd/yyyy');
const dolarsMask = createNumberMask({ prefix: '$' });
const dolarsMaskDecimal = createNumberMask({ prefix: '$', allowDecimal: true });
const percentageMask = createNumberMask({ prefix: '', suffix: '%', integerLimit: 3 });
const upperCasePipe = conformedValue =&gt; conformedValue.toUpperCase();

const TextMask = () =&gt; (
    
        
        <p>
            Text Mask is an input mask library. 
            It can create input masks for <code>phone</code>, 
            <code>date</code>, <code>currency</code>, <code>zip code</code>, <code>percentage</code>, <code>email</code>, and literally anything!
        </p>