From 488a52f76003228861459049defd0c690ad41553 Mon Sep 17 00:00:00 2001 From: Alexander Shabunevich Date: Wed, 12 Jun 2024 17:52:55 +0300 Subject: [PATCH] feat: simple mode for mask directive Allow string passing to set a mask without data-maska attribute --- demo/alpine.html | 38 ++++++++++++----------- docs/v3/alpine.md | 21 +++++++++---- docs/v3/install.md | 26 +++++++++------- docs/v3/svelte.md | 20 ++++++++----- docs/v3/upgrade.md | 4 +-- docs/v3/vue.md | 24 ++++++++------- src/alpine/index.ts | 15 ++++++---- src/svelte/index.ts | 14 +++++++-- src/vue/index.ts | 9 ++++-- test/alpine.test.ts | 6 ++++ test/svelte/DataAttr.svelte | 7 +++++ test/svelte/Demo.svelte | 2 ++ test/svelte/Options.svelte | 2 +- test/svelte/Simple.svelte | 2 +- test/vue/Simple.vue | 2 +- test/vue/Sink.vue | 60 ++++++++++++++++--------------------- 16 files changed, 150 insertions(+), 102 deletions(-) create mode 100644 test/svelte/DataAttr.svelte diff --git a/demo/alpine.html b/demo/alpine.html index 6e14ce4..91c7119 100644 --- a/demo/alpine.html +++ b/demo/alpine.html @@ -24,38 +24,42 @@
-
- -
-
masked value:
-
unmasked value:
+
+
+
masked value:
unmasked value:
- +
- + ``` ### **Vue** @@ -47,11 +51,11 @@ And then use it in your `.vue` component: ```js ``` @@ -118,7 +122,7 @@ For modern browsers you can use ES modules build with (optional) [import maps](h } @@ -154,7 +158,7 @@ For modern browsers you can use ES modules build with (optional) [import maps](h } diff --git a/docs/v3/svelte.md b/docs/v3/svelte.md index 3491784..a704a19 100644 --- a/docs/v3/svelte.md +++ b/docs/v3/svelte.md @@ -3,34 +3,38 @@ Maska provides simple Svelte action for use with input: ```html - + ``` -- `options` is object with default options +- `value` could be one of: + - `string` for the mask value (should be enclosed in additional quotation marks: `{'#-#'}`) + - `object` with a default options ## Minimal example -Apply `maska` action to the input along with `data-maska` attribite: +Apply `maska` action to the input: ```svelte - + ``` +?> Please note that the mask value is enclosed in additional quotation marks: `"'#-#'"`. ## Set mask options To set default [options](/options) for the mask, pass options via **directive value**: ```svelte - ``` @@ -42,11 +44,12 @@ Import `vMaska` directive and apply it to the input along with `data-maska` attr ``` +?> Please note that the mask value is enclosed in additional quotation marks: `"'#-#'"`. ## Set mask options @@ -56,12 +59,13 @@ To set default [options](/options) for the mask, pass options via **directive va ### **Composition API** ```vue -