@imask/svelte
TypeScript icon, indicating that this package has built-in type declarations

7.6.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 @imask/svelte

Weekly Downloads

5,040

Version

7.6.0

License

MIT

Unpacked Size

15.2 kB

Total Files

13

Last publish

Collaborators

  • unmanner