How to use text-mask-core - 7 common examples

To help you get started, we’ve selected a few text-mask-core 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 mariohmol / ng-brazil / ng-brazil / src / angular2TextMask.ts View on Github external
_setupMask(create = false) {
    if (!this.inputElement) {
      if (this._elementRef.nativeElement.tagName.toUpperCase() === 'INPUT') {
        // `textMask` directive is used directly on an input element
        this.inputElement = this._elementRef.nativeElement
      } else {
        // `textMask` directive is used on an abstracted input element, `md-input-container`, etc
        this.inputElement = this._elementRef.nativeElement.getElementsByTagName('INPUT')[0]
      }
    }

    if (this.inputElement && create) {
      this.textMaskInputElement = createTextMaskInputElement(
        Object.assign({ inputElement: this.inputElement }, this.textMaskConfig)
      )
    }

  }
github GetTerminus / terminus-ui / terminus-ui / input / src / input.component.ts View on Github external
private setUpMask(): void {
    // istanbul ignore else
    if (this.inputElement) {
      // tslint:disable-next-line no-any
      const maskOptions: {[key: string]: any} = {
        inputElement: this.inputElement.nativeElement,
        ...this.textMaskConfig,
      };

      // Initialize the mask
      this.textMaskInputElement = createTextMaskInputElement(maskOptions);
    }
  }
github GetTerminus / terminus-ui / terminus-ui / src / mask / mask.directive.ts View on Github external
private setupMask(create?: boolean): void {
    // istanbul ignore else
    if (!this.inputElement) {
      this.inputElement = this.elementRef.nativeElement;
    }

    // istanbul ignore else
    if (this.inputElement && create) {
      const maskOptions = Object.assign({inputElement: this.inputElement}, this.textMaskConfig);
      // Initialize the mask
      this.textMaskInputElement = createTextMaskInputElement(maskOptions);
    }
  }
github dsuryd / dotNetify-Elements / DevApp / src / dotnetify-elements / _internal / VMInput.js View on Github external
'9': /[0-9]/,
            U: /[A-Z]/,
            A: /[a-zA-Z]/,
            '*': /[0-9a-zA-Z]/
         };
         let { type, ...inputMask } = utils.toCamelCase(this.attrs.mask);
         if (type === 'NumberMask') {
            if (inputMask.includeThousandsSeparator) {
               const regex = new RegExp(inputMask.thousandsSeparatorSymbol, 'g');
               this._unmask = value => (typeof value == 'string' ? value.replace(regex, '') : value);
            }
            inputMask = createNumberMask(inputMask);
         }
         else inputMask = inputMask.mask.split('').map(c => (maskMap.hasOwnProperty(c) ? maskMap[c] : c));

         this._textMask = createTextMaskInputElement({ inputElement: this._inputElement, mask: inputMask });
         this._textMask.update(this.value || '');
      }
   }
github mehmet-erim / ngx-performance-ui / projects / core / src / lib / utils / common-utils.ts View on Github external
export function transformByRegex(value: string | number, mask: Mask.Config): string {
  if (typeof value === 'number') value = String(value);

  const inputElement = document.createElement('input');
  inputElement.type = 'text';

  const textMaskInputElement = createTextMaskInputElement({ ...mask, inputElement });
  textMaskInputElement.update(value);

  return inputElement.value;
}
github atanasster / grommet-nextjs / components / grommet / MaskedInput / MaskedInput.js View on Github external
initTextMask() {
    const { props, props: { value } } = this;
    if (props.mask && this.inputControlRef) {
      this.textMaskInputElement = createTextMaskInputElement({
        inputElement: this.inputControlRef,
        ...props,
      });
      this.textMaskInputElement.update(value);
    }
  }
github atanasster / grommet-nextjs / components / grommet / MaskedInput / utils.js View on Github external
}
  let conformedValue = value;
  const {
    guide, placeholderChar, placeholder, currentCaretPosition,
    showMask, keepCharPositions,
  } = props;

  const conformToMaskConfig = {
    previousPlaceholder: placeholder,
    guide,
    placeholderChar,
    pipe,
    currentCaretPosition,
    keepCharPositions,
  };
  const conformed = conformToMask(safeValue, mask, conformToMaskConfig);
  if (conformed) {
    ({ conformedValue } = conformed);
  }
  if (typeof pipe === 'function') {
    const pipeResults = pipe(conformedValue, { rawValue: safeValue, ...conformToMaskConfig });
    if (typeof pipeResults === 'string') {
      conformedValue = pipeResults;
    }
  }
  if (conformedValue === placeholder) {
    conformedValue = showMask ? placeholder : '';
  }
  return conformedValue;
};

text-mask-core

Core of https://github.com/text-mask/text-mask

Unlicense
Latest version published 6 years ago

Package Health Score

62 / 100
Full package analysis