@farhansyah/imask-svelte

7.0.0-alpha.2-0 • Public • Published

Svelte IMask Plugin

@imask/svelte

npm version License: MIT

Install

npm install @imask/svelte

Mask Action Example

<input
  {value}
  use:imask={options}
  on:accept={accept}
  on:complete={complete}
>

<script>
  import { imask } from '@imask/svelte';

  const options = {
    mask: '{8}000000',
    lazy: false
  };

  let value = '';

  function accept({ detail: maskRef }) {
    console.log('accept', maskRef.value);
    value = maskRef.value;
  }

  function complete({ detail: maskRef }) {
    console.log('complete', maskRef.unmaskedValue);
  }
</script>

More options see in a guide.

Input Mask Component

Currently plugin does not have component for input with 2-way binding support because it is not possible to pass all event listeners to child (issue).

Workaround is here: https://svelte.dev/repl/b590cddb69f4452b8f7704bd1e721e76?version=3.16.7

Package Sidebar

Install

npm i @farhansyah/imask-svelte

Weekly Downloads

4

Version

7.0.0-alpha.2-0

License

MIT

Unpacked Size

8.21 kB

Total Files

7

Last publish

Collaborators

  • farhansyah