ku4web-components 6.4.34 → 6.4.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-fabdc7d0.js → index-38fe0039.js} +1 -1
- package/dist/cjs/ku4-carousel-controls.cjs.entry.js +3 -3
- package/dist/cjs/ku4-carousel-slide.cjs.entry.js +2 -2
- package/dist/cjs/ku4-carousel.cjs.entry.js +15 -9
- package/dist/cjs/ku4-col.cjs.entry.js +2 -2
- package/dist/cjs/ku4-drawer.cjs.entry.js +2 -2
- package/dist/cjs/ku4-feature.cjs.entry.js +3 -3
- package/dist/cjs/ku4-focus-trap.cjs.entry.js +27 -27
- package/dist/cjs/ku4-form.cjs.entry.js +4 -4
- package/dist/cjs/ku4-grid.cjs.entry.js +2 -2
- package/dist/cjs/ku4-label.cjs.entry.js +3 -3
- package/dist/cjs/ku4-mask.cjs.entry.js +3 -3
- package/dist/cjs/ku4-modal.cjs.entry.js +4 -4
- package/dist/cjs/ku4-panel.cjs.entry.js +2 -2
- package/dist/cjs/ku4-preview.cjs.entry.js +15 -44
- package/dist/cjs/ku4-tab-list.cjs.entry.js +5 -5
- package/dist/cjs/ku4-tab-panel.cjs.entry.js +4 -4
- package/dist/cjs/ku4-tab.cjs.entry.js +4 -4
- package/dist/cjs/ku4-table.cjs.entry.js +2 -2
- package/dist/cjs/ku4-tooltip.cjs.entry.js +3 -3
- package/dist/cjs/ku4-validation.cjs.entry.js +4 -4
- package/dist/cjs/ku4web-components.cjs.js +8 -99
- package/dist/cjs/loader.cjs.js +3 -19
- package/dist/cjs/{shadow-css-4bfd7bfa.js → shadow-css-d8ee70b1.js} +1 -1
- package/dist/esm/{index-d14f31b2.js → index-52020db7.js} +1 -1
- package/dist/esm/ku4-carousel-controls.entry.js +3 -3
- package/dist/esm/ku4-carousel-slide.entry.js +2 -2
- package/dist/esm/ku4-carousel.entry.js +15 -9
- package/dist/esm/ku4-col.entry.js +2 -2
- package/dist/esm/ku4-drawer.entry.js +2 -2
- package/dist/esm/ku4-feature.entry.js +3 -3
- package/dist/esm/ku4-focus-trap.entry.js +4 -4
- package/dist/esm/ku4-form.entry.js +4 -4
- package/dist/esm/ku4-grid.entry.js +2 -2
- package/dist/esm/ku4-label.entry.js +3 -3
- package/dist/esm/ku4-mask.entry.js +3 -3
- package/dist/esm/ku4-modal.entry.js +4 -4
- package/dist/esm/ku4-panel.entry.js +2 -2
- package/dist/esm/ku4-preview.entry.js +6 -35
- package/dist/esm/ku4-tab-list.entry.js +5 -5
- package/dist/esm/ku4-tab-panel.entry.js +4 -4
- package/dist/esm/ku4-tab.entry.js +4 -4
- package/dist/esm/ku4-table.entry.js +2 -2
- package/dist/esm/ku4-tooltip.entry.js +3 -3
- package/dist/esm/ku4-validation.entry.js +4 -4
- package/dist/esm/ku4web-components.js +8 -99
- package/dist/esm/loader.js +3 -19
- package/dist/{ku4web-components/shadow-css-bc14d9fd.js → esm/shadow-css-c1fdfa9f.js} +1 -1
- package/dist/esm-es5/{index-d14f31b2.js → index-52020db7.js} +1 -1
- package/dist/esm-es5/ku4-carousel-controls.entry.js +1 -1
- package/dist/esm-es5/ku4-carousel-slide.entry.js +1 -1
- package/dist/esm-es5/ku4-carousel.entry.js +1 -1
- package/dist/esm-es5/ku4-col.entry.js +1 -1
- package/dist/esm-es5/ku4-drawer.entry.js +1 -1
- package/dist/esm-es5/ku4-feature.entry.js +1 -1
- package/dist/esm-es5/ku4-focus-trap.entry.js +1 -1
- package/dist/esm-es5/ku4-form.entry.js +1 -1
- package/dist/esm-es5/ku4-grid.entry.js +1 -1
- package/dist/esm-es5/ku4-label.entry.js +1 -1
- package/dist/esm-es5/ku4-mask.entry.js +1 -1
- package/dist/esm-es5/ku4-modal.entry.js +1 -1
- package/dist/esm-es5/ku4-panel.entry.js +1 -1
- package/dist/esm-es5/ku4-preview.entry.js +1 -1
- package/dist/esm-es5/ku4-tab-list.entry.js +1 -1
- package/dist/esm-es5/ku4-tab-panel.entry.js +1 -1
- package/dist/esm-es5/ku4-tab.entry.js +1 -1
- package/dist/esm-es5/ku4-table.entry.js +1 -1
- package/dist/esm-es5/ku4-tooltip.entry.js +1 -1
- package/dist/esm-es5/ku4-validation.entry.js +1 -1
- package/dist/esm-es5/ku4web-components.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/{shadow-css-bc14d9fd.js → shadow-css-c1fdfa9f.js} +0 -0
- package/dist/index.js +1 -1
- package/dist/ku4web-components/index.esm.js +0 -1
- package/dist/ku4web-components/ku4web-components.css +1 -283
- package/dist/ku4web-components/ku4web-components.esm.js +1 -125
- package/dist/ku4web-components/ku4web-components.js +1 -1
- package/dist/ku4web-components/{p-967f8f4b.system.entry.js → p-19147286.system.entry.js} +1 -1
- package/dist/ku4web-components/p-1fb8966a.entry.js +1 -0
- package/dist/ku4web-components/{p-c72b3ced.system.entry.js → p-2bbea5f3.system.entry.js} +1 -1
- package/dist/ku4web-components/p-4986dc9a.entry.js +1 -0
- package/dist/ku4web-components/{p-176273d5.system.js → p-4de687d8.system.js} +1 -1
- package/dist/ku4web-components/p-5848719e.system.js +1 -0
- package/dist/ku4web-components/p-5ad4d525.entry.js +1 -0
- package/dist/ku4web-components/{p-e0558b2b.system.entry.js → p-60512677.system.entry.js} +1 -1
- package/dist/ku4web-components/{p-cb0f32a7.js → p-670d415c.js} +1 -1
- package/dist/ku4web-components/{p-c3c31235.system.entry.js → p-67b90b07.system.entry.js} +1 -1
- package/dist/ku4web-components/{p-435478fa.system.entry.js → p-6a6ebdd6.system.entry.js} +1 -1
- package/dist/ku4web-components/p-6f56d780.entry.js +1 -0
- package/dist/ku4web-components/p-7587e933.entry.js +1 -0
- package/dist/ku4web-components/{p-3ad57422.system.entry.js → p-769237d3.system.entry.js} +1 -1
- package/dist/ku4web-components/p-7a5e62fd.entry.js +1 -0
- package/dist/ku4web-components/{p-46d73124.system.entry.js → p-8645d86f.system.entry.js} +1 -1
- package/dist/ku4web-components/{p-cb6b67f2.entry.js → p-867d74d6.entry.js} +1 -1
- package/dist/ku4web-components/p-911a6cc5.entry.js +1 -0
- package/dist/ku4web-components/{p-7bbd50d6.system.entry.js → p-93417cb8.system.entry.js} +1 -1
- package/dist/ku4web-components/p-98548901.system.entry.js +1 -0
- package/dist/ku4web-components/{p-44f9a1a9.system.entry.js → p-9b9fb5a2.system.entry.js} +1 -1
- package/dist/ku4web-components/p-9e2c3988.entry.js +1 -0
- package/dist/ku4web-components/{p-64f6379d.system.entry.js → p-ac86618a.system.entry.js} +1 -1
- package/dist/ku4web-components/p-af5d8c77.system.entry.js +1 -0
- package/dist/ku4web-components/p-b2db2c0b.entry.js +1 -0
- package/dist/ku4web-components/p-b9cf48d6.entry.js +1 -0
- package/dist/ku4web-components/p-bfd8c04e.entry.js +1 -0
- package/dist/ku4web-components/p-c11d7118.entry.js +1 -0
- package/dist/ku4web-components/p-c194ee9c.entry.js +1 -0
- package/dist/ku4web-components/{p-c2285d3c.system.entry.js → p-c48ff8d2.system.entry.js} +1 -1
- package/dist/ku4web-components/p-cdaa80f7.entry.js +1 -0
- package/dist/ku4web-components/{ku4-col.entry.js → p-d0579e6f.entry.js} +1 -75
- package/dist/ku4web-components/p-d248862c.entry.js +1 -0
- package/dist/ku4web-components/{p-9f159c4b.system.entry.js → p-d312c8ae.system.entry.js} +1 -1
- package/dist/ku4web-components/{p-110de527.system.entry.js → p-d3dad5b5.system.entry.js} +1 -1
- package/dist/ku4web-components/{p-d3379ca9.system.entry.js → p-dda45242.system.entry.js} +1 -1
- package/dist/ku4web-components/p-e63f2453.entry.js +1 -0
- package/dist/ku4web-components/{p-4e89d6bc.system.entry.js → p-e89bc35d.system.entry.js} +1 -1
- package/dist/ku4web-components/{p-308941a0.system.entry.js → p-e9c1a470.system.entry.js} +1 -1
- package/dist/ku4web-components/p-ebc49910.entry.js +1 -0
- package/dist/ku4web-components/{p-a025c941.system.js → p-f4d979bb.system.js} +0 -0
- package/dist/ku4web-components/{p-3fb7c6ff.js → p-f566887e.js} +0 -0
- package/dist/ku4web-components/{p-7a3a3b7f.system.entry.js → p-faef0a79.system.entry.js} +1 -1
- package/dist/ku4web-components/p-fbba3322.entry.js +1 -0
- package/dist/ku4web-components/{p-d8836783.system.entry.js → p-ff4c04f5.system.entry.js} +1 -1
- package/dist/types/components/ku4-carousel/ku4-carousel.d.ts +4 -0
- package/dist/types/components/ku4-validation/ku4-validation.d.ts +5 -0
- package/dist/types/components.d.ts +16 -0
- package/loader/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/cjs/app-globals-3a1e7e63.js +0 -5
- package/dist/cjs/css-shim-a6998297.js +0 -6
- package/dist/cjs/dom-66f79778.js +0 -75
- package/dist/cjs/index-51b7a610.js +0 -14
- package/dist/cjs/index-c52d450b.js +0 -10
- package/dist/cjs/index-ff13b651.js +0 -3046
- package/dist/cjs/uid-3dd31175.js +0 -11
- package/dist/collection/capabilities/a11y/aria.js +0 -26
- package/dist/collection/capabilities/angular/index.js +0 -24
- package/dist/collection/capabilities/decorators/deprecated.js +0 -20
- package/dist/collection/capabilities/decorators/index.js +0 -3
- package/dist/collection/capabilities/decorators/memoize.js +0 -7
- package/dist/collection/capabilities/dom/isFocusable.js +0 -7
- package/dist/collection/capabilities/dom/queryFocusable.js +0 -2
- package/dist/collection/capabilities/identity/uid.js +0 -6
- package/dist/collection/capabilities/mask/index.js +0 -5
- package/dist/collection/capabilities/mask/patterns/date.js +0 -40
- package/dist/collection/capabilities/mask/patterns/index.js +0 -7
- package/dist/collection/capabilities/react/index.js +0 -25
- package/dist/collection/capabilities/testing/html.js +0 -14
- package/dist/collection/capabilities/testing/styles.js +0 -14
- package/dist/collection/capabilities/vue/index.js +0 -28
- package/dist/collection/capabilities/vue3/index.js +0 -26
- package/dist/collection/collection-manifest.json +0 -31
- package/dist/collection/components/ku4-carousel/ku4-carousel.css +0 -215
- package/dist/collection/components/ku4-carousel/ku4-carousel.js +0 -335
- package/dist/collection/components/ku4-carousel-controls/ku4-carousel-controls.css +0 -32
- package/dist/collection/components/ku4-carousel-controls/ku4-carousel-controls.js +0 -93
- package/dist/collection/components/ku4-carousel-slide/ku4-carousel-slide.css +0 -3
- package/dist/collection/components/ku4-carousel-slide/ku4-carousel-slide.js +0 -140
- package/dist/collection/components/ku4-col/ku4-col.css +0 -601
- package/dist/collection/components/ku4-col/ku4-col.js +0 -288
- package/dist/collection/components/ku4-drawer/ku4-drawer.css +0 -56
- package/dist/collection/components/ku4-drawer/ku4-drawer.js +0 -163
- package/dist/collection/components/ku4-feature/ku4-feature.js +0 -70
- package/dist/collection/components/ku4-focus-trap/ku4-focus-trap.css +0 -3
- package/dist/collection/components/ku4-focus-trap/ku4-focus-trap.js +0 -441
- package/dist/collection/components/ku4-form/ku4-form.js +0 -194
- package/dist/collection/components/ku4-grid/ku4-grid.css +0 -751
- package/dist/collection/components/ku4-grid/ku4-grid.js +0 -408
- package/dist/collection/components/ku4-label/ku4-label.css +0 -36
- package/dist/collection/components/ku4-label/ku4-label.js +0 -115
- package/dist/collection/components/ku4-mask/ku4-mask.css +0 -3
- package/dist/collection/components/ku4-mask/ku4-mask.js +0 -427
- package/dist/collection/components/ku4-modal/ku4-modal.css +0 -85
- package/dist/collection/components/ku4-modal/ku4-modal.js +0 -186
- package/dist/collection/components/ku4-panel/ku4-panel.css +0 -14
- package/dist/collection/components/ku4-panel/ku4-panel.js +0 -119
- package/dist/collection/components/ku4-preview/ku4-preview.css +0 -23
- package/dist/collection/components/ku4-preview/ku4-preview.js +0 -249
- package/dist/collection/components/ku4-tab/ku4-tab.css +0 -82
- package/dist/collection/components/ku4-tab/ku4-tab.js +0 -191
- package/dist/collection/components/ku4-tab-list/ku4-tab-list.css +0 -6
- package/dist/collection/components/ku4-tab-list/ku4-tab-list.js +0 -118
- package/dist/collection/components/ku4-tab-panel/ku4-tab-panel.css +0 -26
- package/dist/collection/components/ku4-tab-panel/ku4-tab-panel.js +0 -166
- package/dist/collection/components/ku4-table/ku4-table.css +0 -116
- package/dist/collection/components/ku4-table/ku4-table.js +0 -120
- package/dist/collection/components/ku4-tooltip/ku4-tooltip.css +0 -56
- package/dist/collection/components/ku4-tooltip/ku4-tooltip.js +0 -274
- package/dist/collection/components/ku4-validation/ku4-validation.css +0 -7
- package/dist/collection/components/ku4-validation/ku4-validation.js +0 -309
- package/dist/collection/components/ku4-validation/validate.js +0 -14
- package/dist/collection/index.js +0 -1
- package/dist/collection/security.js +0 -27
- package/dist/esm/app-globals-0f993ce5.js +0 -3
- package/dist/esm/css-shim-a64b8820.js +0 -4
- package/dist/esm/dom-d08ba8aa.js +0 -73
- package/dist/esm/index-4693d116.js +0 -3
- package/dist/esm/index-88e7b9d4.js +0 -3010
- package/dist/esm/index-89916128.js +0 -3
- package/dist/esm/shadow-css-bc14d9fd.js +0 -389
- package/dist/esm/uid-5355229f.js +0 -9
- package/dist/ku4web-components/app-globals-0f993ce5.js +0 -3
- package/dist/ku4web-components/app-globals-497eb362.system.js +0 -1
- package/dist/ku4web-components/css-shim-00dc76e5.system.js +0 -1
- package/dist/ku4web-components/css-shim-a64b8820.js +0 -4
- package/dist/ku4web-components/dom-59f9ee66.system.js +0 -21
- package/dist/ku4web-components/dom-d08ba8aa.js +0 -73
- package/dist/ku4web-components/index-3127d7f7.system.js +0 -1
- package/dist/ku4web-components/index-4693d116.js +0 -3
- package/dist/ku4web-components/index-7624f416.system.js +0 -1
- package/dist/ku4web-components/index-88e7b9d4.js +0 -3010
- package/dist/ku4web-components/index-89916128.js +0 -3
- package/dist/ku4web-components/index-aea7f048.system.js +0 -1
- package/dist/ku4web-components/index.system.js +0 -1
- package/dist/ku4web-components/ku4-carousel-controls.entry.js +0 -70
- package/dist/ku4web-components/ku4-carousel-controls.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-carousel-slide.entry.js +0 -47
- package/dist/ku4web-components/ku4-carousel-slide.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-carousel.entry.js +0 -159
- package/dist/ku4web-components/ku4-carousel.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-col.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-drawer.entry.js +0 -35
- package/dist/ku4web-components/ku4-drawer.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-feature.entry.js +0 -29
- package/dist/ku4web-components/ku4-feature.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-focus-trap.entry.js +0 -323
- package/dist/ku4web-components/ku4-focus-trap.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-form.entry.js +0 -97
- package/dist/ku4web-components/ku4-form.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-grid.entry.js +0 -108
- package/dist/ku4web-components/ku4-grid.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-label.entry.js +0 -70
- package/dist/ku4web-components/ku4-label.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-mask.entry.js +0 -311
- package/dist/ku4web-components/ku4-mask.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-modal.entry.js +0 -71
- package/dist/ku4web-components/ku4-modal.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-panel.entry.js +0 -49
- package/dist/ku4web-components/ku4-panel.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-preview.entry.js +0 -128
- package/dist/ku4web-components/ku4-preview.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-tab-list.entry.js +0 -76
- package/dist/ku4web-components/ku4-tab-list.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-tab-panel.entry.js +0 -72
- package/dist/ku4web-components/ku4-tab-panel.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-tab.entry.js +0 -63
- package/dist/ku4web-components/ku4-tab.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-table.entry.js +0 -79
- package/dist/ku4web-components/ku4-table.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-tooltip.entry.js +0 -120
- package/dist/ku4web-components/ku4-tooltip.system.entry.js +0 -1
- package/dist/ku4web-components/ku4-validation.entry.js +0 -158
- package/dist/ku4web-components/ku4-validation.system.entry.js +0 -1
- package/dist/ku4web-components/ku4web-components.system.js +0 -1
- package/dist/ku4web-components/p-026e04d8.entry.js +0 -1
- package/dist/ku4web-components/p-0a7ce92f.entry.js +0 -1
- package/dist/ku4web-components/p-10a643bb.system.js +0 -1
- package/dist/ku4web-components/p-288c6e27.entry.js +0 -1
- package/dist/ku4web-components/p-417f04e9.entry.js +0 -1
- package/dist/ku4web-components/p-4c117404.entry.js +0 -1
- package/dist/ku4web-components/p-5299172c.entry.js +0 -1
- package/dist/ku4web-components/p-6b080fd7.entry.js +0 -1
- package/dist/ku4web-components/p-731d15d8.entry.js +0 -1
- package/dist/ku4web-components/p-7760e8b4.entry.js +0 -1
- package/dist/ku4web-components/p-7764c6f2.entry.js +0 -1
- package/dist/ku4web-components/p-7ffb5116.entry.js +0 -1
- package/dist/ku4web-components/p-8063491d.entry.js +0 -1
- package/dist/ku4web-components/p-8b7e72eb.entry.js +0 -1
- package/dist/ku4web-components/p-92ddb4be.entry.js +0 -1
- package/dist/ku4web-components/p-c7dc83c3.entry.js +0 -1
- package/dist/ku4web-components/p-cb142835.system.entry.js +0 -1
- package/dist/ku4web-components/p-cb746d07.entry.js +0 -1
- package/dist/ku4web-components/p-da065955.entry.js +0 -1
- package/dist/ku4web-components/p-e7698568.system.entry.js +0 -1
- package/dist/ku4web-components/p-e8367ca4.entry.js +0 -1
- package/dist/ku4web-components/p-fb68de75.entry.js +0 -1
- package/dist/ku4web-components/shadow-css-c015bba2.system.js +0 -13
- package/dist/ku4web-components/uid-5355229f.js +0 -9
- package/dist/ku4web-components/uid-93975202.system.js +0 -1
@@ -1,427 +0,0 @@
|
|
1
|
-
import { Component, Prop, Watch, h } from '@stencil/core';
|
2
|
-
import { Assert, string, wait } from 'ku4es-kernel';
|
3
|
-
/**
|
4
|
-
* @description ku4-mask
|
5
|
-
*/
|
6
|
-
export class Ku4Mask {
|
7
|
-
constructor() {
|
8
|
-
this.charIndexes = [];
|
9
|
-
this.reverseCharIndexes = [];
|
10
|
-
this.previousValue = '';
|
11
|
-
this.currentValue = '';
|
12
|
-
this.touchStart = false;
|
13
|
-
/**
|
14
|
-
* Mask template
|
15
|
-
*/
|
16
|
-
this.template = '';
|
17
|
-
/**
|
18
|
-
* A regex of characters to ban from
|
19
|
-
* entry. A user will not be able to input
|
20
|
-
* any character in this set of characters.
|
21
|
-
* E.g. ban="[()-]" will not allow a user to
|
22
|
-
* input (, ), or - into the target input.
|
23
|
-
*/
|
24
|
-
this.ban = '';
|
25
|
-
/**
|
26
|
-
* A test pattern for the mask to allow or
|
27
|
-
* disallow characters at targeted points
|
28
|
-
* in the input. The pattern is a character
|
29
|
-
* separated value of regular expressions
|
30
|
-
* where the first character denotes the
|
31
|
-
* character separator at each subsequent
|
32
|
-
* value is a regular expression for the
|
33
|
-
* character at that indicated index.
|
34
|
-
* E.g. `pattern=",[345],,,[^abc]"` would mean
|
35
|
-
* that "," is the separator and that the
|
36
|
-
* first character must be a 3, 4, or 5, and
|
37
|
-
* the fourth character cannot be an a, b or c.
|
38
|
-
*/
|
39
|
-
this.pattern = '';
|
40
|
-
/**
|
41
|
-
* Mask Character
|
42
|
-
*/
|
43
|
-
this.char = '_';
|
44
|
-
/**
|
45
|
-
* Hide mask
|
46
|
-
*/
|
47
|
-
this.hidden = false;
|
48
|
-
this.handleFocus = this.handleFocus.bind(this);
|
49
|
-
this.handleKeyDown = this.handleKeyDown.bind(this);
|
50
|
-
this.handleInput = this.handleInput.bind(this);
|
51
|
-
this.handleTouchStart = this.handleTouchStart.bind(this);
|
52
|
-
this.init();
|
53
|
-
}
|
54
|
-
init() {
|
55
|
-
this.chars = this.char && new RegExp(this.char);
|
56
|
-
this.banned = this.ban && new RegExp(this.ban);
|
57
|
-
const pattern = this.pattern.replace(/[\s\n]/gm, '');
|
58
|
-
this.patterns = pattern.substr(1).split(pattern[0]).map((v) => {
|
59
|
-
try {
|
60
|
-
return v && new RegExp(v) || null;
|
61
|
-
}
|
62
|
-
catch (e) {
|
63
|
-
/**
|
64
|
-
* TODO: Remove try/catch when Safari supports lookbehinds.
|
65
|
-
* Safari does not support lookbehinds and blows up everything
|
66
|
-
* because of this. This try catch allows all masking behaviour
|
67
|
-
* to continue to work except for patterns that include lookbehinds.
|
68
|
-
*/
|
69
|
-
}
|
70
|
-
});
|
71
|
-
this.charIndexes = this.template.split('')
|
72
|
-
.reduce((acc, char, i) => {
|
73
|
-
if (this.chars.test(char)) {
|
74
|
-
acc.push(i);
|
75
|
-
}
|
76
|
-
return acc;
|
77
|
-
}, []);
|
78
|
-
this.reverseCharIndexes = [...this.charIndexes].reverse();
|
79
|
-
return this;
|
80
|
-
}
|
81
|
-
templateHandler(newTemplate, oldTemplate) {
|
82
|
-
const { input, previousCharIndex, previousValue, currentValue, value, char } = this;
|
83
|
-
const previousLength = string.unmask(previousValue, oldTemplate, char).length;
|
84
|
-
const currentLength = string.unmask(currentValue, oldTemplate, char).length;
|
85
|
-
const nextIndex = previousLength < currentLength ? previousCharIndex + 1 : previousCharIndex;
|
86
|
-
this.init().value = string.mask(string.unmask(value, oldTemplate, char), newTemplate, char);
|
87
|
-
input.setSelectionRange(nextIndex, nextIndex);
|
88
|
-
}
|
89
|
-
charHandler(newChar, oldChar) {
|
90
|
-
const { value, template } = this;
|
91
|
-
this.init().value = string.mask(string.unmask(value, template, oldChar), template, newChar);
|
92
|
-
}
|
93
|
-
get previousCharIndex() {
|
94
|
-
return this.reverseCharIndexes.find(i => this.selectionStart > i) || this.charIndexes[0];
|
95
|
-
}
|
96
|
-
get value() {
|
97
|
-
return this.currentValue;
|
98
|
-
}
|
99
|
-
set value(value) {
|
100
|
-
const { chars, hidden, input } = this;
|
101
|
-
const indexOfChar = value.search(chars);
|
102
|
-
this.currentValue = value;
|
103
|
-
input.value = hidden && indexOfChar > -1 ? value.substring(0, indexOfChar) : value;
|
104
|
-
}
|
105
|
-
handleTouchStart() {
|
106
|
-
this.touchStart = true;
|
107
|
-
}
|
108
|
-
handleFocus() {
|
109
|
-
// Abort if the browser is IE11
|
110
|
-
// @ts-ignore - Leveraging documentMode to determine unsupported browser
|
111
|
-
if (window.document.documentMode) {
|
112
|
-
return;
|
113
|
-
}
|
114
|
-
const { input, template, char, chars, touchStart } = this;
|
115
|
-
this.value = string.mask(string.unmask(this.value, template, char), template, char);
|
116
|
-
wait(0).then(() => {
|
117
|
-
const index = input.value.search(chars);
|
118
|
-
const selection = index < 0 ? input.value.length : index;
|
119
|
-
this.input.setSelectionRange(index < 0 && !touchStart ? 0 : selection, selection);
|
120
|
-
this.touchStart = false;
|
121
|
-
});
|
122
|
-
}
|
123
|
-
handleKeyDown(e) {
|
124
|
-
// Abort if the browser is IE11
|
125
|
-
// @ts-ignore - Leveraging documentMode to determine unsupported browser
|
126
|
-
if (window.document.documentMode) {
|
127
|
-
return;
|
128
|
-
}
|
129
|
-
const { banned, hidden, template, char } = this;
|
130
|
-
if (e.key &&
|
131
|
-
e.key.length === 1 &&
|
132
|
-
banned &&
|
133
|
-
(banned.test(e.key) &&
|
134
|
-
!(e.altKey || e.ctrlKey || e.metaKey))) {
|
135
|
-
e.preventDefault();
|
136
|
-
}
|
137
|
-
this.previousValue = hidden ? string.mask(string.unmask(e.target.value, template, char), template, char) : e.target.value;
|
138
|
-
this.selectionStart = e.target.selectionStart;
|
139
|
-
this.selectionEnd = e.target.selectionEnd;
|
140
|
-
}
|
141
|
-
handleInput(e) {
|
142
|
-
// Abort if the browser is IE11
|
143
|
-
// @ts-ignore - Leveraging documentMode to determine unsupported browser
|
144
|
-
if (window.document.documentMode) {
|
145
|
-
return;
|
146
|
-
}
|
147
|
-
const { input, template, char, chars, previousValue, banned, selectionStart, selectionEnd, previousCharIndex, patterns, charIndexes, reverseCharIndexes } = this;
|
148
|
-
if (!chars.test(this.previousValue) &&
|
149
|
-
e.inputType !== 'insertFromPaste' &&
|
150
|
-
e.inputType !== 'deleteContentBackward' &&
|
151
|
-
e.inputType !== 'deleteContentForward' &&
|
152
|
-
selectionStart === selectionEnd) {
|
153
|
-
this.value = previousValue;
|
154
|
-
return;
|
155
|
-
}
|
156
|
-
if (e.inputType === 'insertFromPaste') {
|
157
|
-
try {
|
158
|
-
navigator.clipboard.readText()
|
159
|
-
.then((rawData) => {
|
160
|
-
const data = rawData.replace(new RegExp(banned, 'g'), '');
|
161
|
-
if (Assert.isNullOrEmpty(data)) {
|
162
|
-
this.value = previousValue;
|
163
|
-
input.setSelectionRange(selectionStart, selectionStart);
|
164
|
-
return;
|
165
|
-
}
|
166
|
-
if (!banned || !banned.test(data)) {
|
167
|
-
let nextValue = previousValue;
|
168
|
-
if (selectionStart < selectionEnd) {
|
169
|
-
const startValue = reverseCharIndexes.find(v => v <= selectionStart - 1);
|
170
|
-
const endValue = reverseCharIndexes.find(v => v <= selectionEnd - 1);
|
171
|
-
const startInsertIndex = charIndexes.findIndex(v => v === startValue);
|
172
|
-
const endInsertIndex = charIndexes.findIndex(v => v === endValue);
|
173
|
-
const unmasked = string.unmask(previousValue, template, char);
|
174
|
-
const newValue = unmasked.substring(0, startInsertIndex + 1) + unmasked.substring(endInsertIndex + 1, previousValue.length);
|
175
|
-
nextValue = string.mask(newValue, template, char);
|
176
|
-
}
|
177
|
-
const charIndex = charIndexes.find(v => v >= selectionStart);
|
178
|
-
const insertIndex = charIndexes.findIndex(v => v === charIndex);
|
179
|
-
const unmasked = string.unmask(nextValue, template, char);
|
180
|
-
nextValue = unmasked.substring(0, insertIndex) + data + unmasked.substring(insertIndex, previousValue.length);
|
181
|
-
this.value = string.mask(nextValue, template, char);
|
182
|
-
const index = charIndexes[insertIndex + data.length] || this.value.search(chars) || this.value.length;
|
183
|
-
input.setSelectionRange(index, index);
|
184
|
-
}
|
185
|
-
});
|
186
|
-
this.value = previousValue;
|
187
|
-
input.setSelectionRange(selectionStart, selectionStart);
|
188
|
-
return;
|
189
|
-
}
|
190
|
-
catch (e) {
|
191
|
-
this.value = previousValue;
|
192
|
-
input.setSelectionRange(selectionStart, selectionStart);
|
193
|
-
return;
|
194
|
-
}
|
195
|
-
}
|
196
|
-
if (e.inputType === 'deleteContentBackward') {
|
197
|
-
const startValue = reverseCharIndexes.find(v => v <= selectionStart - 1);
|
198
|
-
const endValue = reverseCharIndexes.find(v => v <= selectionEnd - 1);
|
199
|
-
const startInsertIndex = charIndexes.findIndex(v => v === startValue);
|
200
|
-
const endInsertIndex = charIndexes.findIndex(v => v === endValue);
|
201
|
-
const unmasked = string.unmask(previousValue, template, char);
|
202
|
-
if (startInsertIndex < endInsertIndex) {
|
203
|
-
const newValue = unmasked.substring(0, startInsertIndex + 1) + unmasked.substring(endInsertIndex + 1, previousValue.length);
|
204
|
-
this.value = string.mask(newValue, template, char);
|
205
|
-
newValue && startInsertIndex > -1
|
206
|
-
? input.setSelectionRange(previousCharIndex + 1, previousCharIndex + 1)
|
207
|
-
: input.setSelectionRange(previousCharIndex, previousCharIndex);
|
208
|
-
}
|
209
|
-
else {
|
210
|
-
const newValue = unmasked.substring(0, startInsertIndex) + unmasked.substring(endInsertIndex + 1, previousValue.length);
|
211
|
-
this.value = string.mask(newValue, template, char);
|
212
|
-
input.setSelectionRange(previousCharIndex, previousCharIndex);
|
213
|
-
}
|
214
|
-
return;
|
215
|
-
}
|
216
|
-
if (e.inputType === 'deleteContentForward') {
|
217
|
-
const charIndex = charIndexes.find(v => v >= selectionStart);
|
218
|
-
const insertIndex = charIndexes.findIndex(v => v === charIndex);
|
219
|
-
const unmasked = string.unmask(previousValue, template, char);
|
220
|
-
const newValue = unmasked.substring(0, insertIndex) + unmasked.substring(insertIndex + 1, previousValue.length);
|
221
|
-
this.value = string.mask(newValue, template, char);
|
222
|
-
input.setSelectionRange(selectionStart, selectionStart);
|
223
|
-
return;
|
224
|
-
}
|
225
|
-
//Abort if auxiliary key is pressed.
|
226
|
-
if (e.altKey || e.ctrlKey || e.metaKey) {
|
227
|
-
return;
|
228
|
-
}
|
229
|
-
//Abort if disallowed character
|
230
|
-
if (!e.data) {
|
231
|
-
this.value = previousValue;
|
232
|
-
input.setSelectionRange(selectionStart, selectionStart);
|
233
|
-
return;
|
234
|
-
}
|
235
|
-
//Append
|
236
|
-
if (chars.test(previousValue.charAt(selectionStart)) ||
|
237
|
-
selectionStart === template.length) {
|
238
|
-
const unmasked = string.unmask(previousValue, template, char);
|
239
|
-
this.value = string.mask(unmasked + e.data, template, char);
|
240
|
-
const charIndex = this.value.search(chars);
|
241
|
-
const index = charIndex < 0 ? template.length : charIndex;
|
242
|
-
input.setSelectionRange(index, index);
|
243
|
-
const patternIndex = charIndexes.findIndex(v => v >= index);
|
244
|
-
const validationIndex = patternIndex < 0 ? charIndexes.length - 1 : patternIndex - 1;
|
245
|
-
this.validate(e.data, patterns[validationIndex]);
|
246
|
-
}
|
247
|
-
//Insert
|
248
|
-
else {
|
249
|
-
let nextValue = previousValue;
|
250
|
-
if (selectionStart < selectionEnd) {
|
251
|
-
const startValue = reverseCharIndexes.find(v => v <= selectionStart - 1);
|
252
|
-
const endValue = reverseCharIndexes.find(v => v <= selectionEnd - 1);
|
253
|
-
const startInsertIndex = charIndexes.findIndex(v => v === startValue);
|
254
|
-
const endInsertIndex = charIndexes.findIndex(v => v === endValue);
|
255
|
-
const unmasked = string.unmask(previousValue, template, char);
|
256
|
-
const newValue = unmasked.substring(0, startInsertIndex + 1) + unmasked.substring(endInsertIndex + 1, previousValue.length);
|
257
|
-
nextValue = string.mask(newValue, template, char);
|
258
|
-
}
|
259
|
-
const charIndex = charIndexes.find(v => v >= selectionStart);
|
260
|
-
const insertIndex = charIndexes.findIndex(v => v === charIndex);
|
261
|
-
const unmasked = string.unmask(nextValue, template, char);
|
262
|
-
nextValue = unmasked.substring(0, insertIndex) + e.data + unmasked.substring(insertIndex, previousValue.length);
|
263
|
-
const index = charIndexes.find(v => v > charIndex);
|
264
|
-
this.value = string.mask(nextValue, template, char);
|
265
|
-
input.setSelectionRange(index, index);
|
266
|
-
const patternIndex = charIndexes.findIndex(v => v >= index);
|
267
|
-
const validationIndex = patternIndex < 0 ? charIndexes.length - 1 : patternIndex - 1;
|
268
|
-
this.validate(e.data, patterns[validationIndex]);
|
269
|
-
}
|
270
|
-
}
|
271
|
-
validate(data, pattern) {
|
272
|
-
const { previousValue, input, value, selectionStart } = this;
|
273
|
-
if (Assert.exists(pattern) &&
|
274
|
-
!(pattern.test(data) || (/\(\?[!<=]/.test(pattern.toString()) && pattern.test(value)))) {
|
275
|
-
this.value = previousValue;
|
276
|
-
input.setSelectionRange(selectionStart, selectionStart);
|
277
|
-
}
|
278
|
-
}
|
279
|
-
componentWillLoad() {
|
280
|
-
this.input = document.getElementById(this.for);
|
281
|
-
if (Assert.exists(this.input)) {
|
282
|
-
this.input.addEventListener('focus', this.handleFocus);
|
283
|
-
this.input.addEventListener('keydown', this.handleKeyDown);
|
284
|
-
this.input.addEventListener('input', this.handleInput);
|
285
|
-
this.input.addEventListener('touchstart', this.handleTouchStart);
|
286
|
-
}
|
287
|
-
else {
|
288
|
-
// eslint-disable-next-line no-console
|
289
|
-
console.error('ku4-mask must have a valid `for` referencing target field `id`.');
|
290
|
-
}
|
291
|
-
}
|
292
|
-
disconnectedCallback() {
|
293
|
-
if (this.input && this.input.removeEventListener) {
|
294
|
-
this.input.removeEventListener('focus', this.handleFocus);
|
295
|
-
this.input.removeEventListener('keydown', this.handleKeyDown);
|
296
|
-
this.input.removeEventListener('input', this.handleInput);
|
297
|
-
this.input.removeEventListener('touchstart', this.handleTouchStart);
|
298
|
-
}
|
299
|
-
}
|
300
|
-
render() {
|
301
|
-
return h("slot", null);
|
302
|
-
}
|
303
|
-
static get is() { return "ku4-mask"; }
|
304
|
-
static get encapsulation() { return "shadow"; }
|
305
|
-
static get originalStyleUrls() { return {
|
306
|
-
"$": ["ku4-mask.scss"]
|
307
|
-
}; }
|
308
|
-
static get styleUrls() { return {
|
309
|
-
"$": ["ku4-mask.css"]
|
310
|
-
}; }
|
311
|
-
static get properties() { return {
|
312
|
-
"for": {
|
313
|
-
"type": "string",
|
314
|
-
"mutable": false,
|
315
|
-
"complexType": {
|
316
|
-
"original": "string",
|
317
|
-
"resolved": "string",
|
318
|
-
"references": {}
|
319
|
-
},
|
320
|
-
"required": false,
|
321
|
-
"optional": false,
|
322
|
-
"docs": {
|
323
|
-
"tags": [],
|
324
|
-
"text": "Mask for input having id of value"
|
325
|
-
},
|
326
|
-
"attribute": "for",
|
327
|
-
"reflect": false
|
328
|
-
},
|
329
|
-
"template": {
|
330
|
-
"type": "string",
|
331
|
-
"mutable": false,
|
332
|
-
"complexType": {
|
333
|
-
"original": "string",
|
334
|
-
"resolved": "string",
|
335
|
-
"references": {}
|
336
|
-
},
|
337
|
-
"required": false,
|
338
|
-
"optional": false,
|
339
|
-
"docs": {
|
340
|
-
"tags": [],
|
341
|
-
"text": "Mask template"
|
342
|
-
},
|
343
|
-
"attribute": "template",
|
344
|
-
"reflect": false,
|
345
|
-
"defaultValue": "''"
|
346
|
-
},
|
347
|
-
"ban": {
|
348
|
-
"type": "string",
|
349
|
-
"mutable": false,
|
350
|
-
"complexType": {
|
351
|
-
"original": "string",
|
352
|
-
"resolved": "string",
|
353
|
-
"references": {}
|
354
|
-
},
|
355
|
-
"required": false,
|
356
|
-
"optional": false,
|
357
|
-
"docs": {
|
358
|
-
"tags": [],
|
359
|
-
"text": "A regex of characters to ban from\nentry. A user will not be able to input\nany character in this set of characters.\nE.g. ban=\"[()-]\" will not allow a user to\ninput (, ), or - into the target input."
|
360
|
-
},
|
361
|
-
"attribute": "ban",
|
362
|
-
"reflect": false,
|
363
|
-
"defaultValue": "''"
|
364
|
-
},
|
365
|
-
"pattern": {
|
366
|
-
"type": "string",
|
367
|
-
"mutable": false,
|
368
|
-
"complexType": {
|
369
|
-
"original": "string",
|
370
|
-
"resolved": "string",
|
371
|
-
"references": {}
|
372
|
-
},
|
373
|
-
"required": false,
|
374
|
-
"optional": false,
|
375
|
-
"docs": {
|
376
|
-
"tags": [],
|
377
|
-
"text": "A test pattern for the mask to allow or\ndisallow characters at targeted points\nin the input. The pattern is a character\nseparated value of regular expressions\nwhere the first character denotes the\ncharacter separator at each subsequent\nvalue is a regular expression for the\ncharacter at that indicated index.\nE.g. `pattern=\",[345],,,[^abc]\"` would mean\nthat \",\" is the separator and that the\nfirst character must be a 3, 4, or 5, and\nthe fourth character cannot be an a, b or c."
|
378
|
-
},
|
379
|
-
"attribute": "pattern",
|
380
|
-
"reflect": false,
|
381
|
-
"defaultValue": "''"
|
382
|
-
},
|
383
|
-
"char": {
|
384
|
-
"type": "string",
|
385
|
-
"mutable": false,
|
386
|
-
"complexType": {
|
387
|
-
"original": "string",
|
388
|
-
"resolved": "string",
|
389
|
-
"references": {}
|
390
|
-
},
|
391
|
-
"required": false,
|
392
|
-
"optional": false,
|
393
|
-
"docs": {
|
394
|
-
"tags": [],
|
395
|
-
"text": "Mask Character"
|
396
|
-
},
|
397
|
-
"attribute": "char",
|
398
|
-
"reflect": false,
|
399
|
-
"defaultValue": "'_'"
|
400
|
-
},
|
401
|
-
"hidden": {
|
402
|
-
"type": "boolean",
|
403
|
-
"mutable": false,
|
404
|
-
"complexType": {
|
405
|
-
"original": "boolean",
|
406
|
-
"resolved": "boolean",
|
407
|
-
"references": {}
|
408
|
-
},
|
409
|
-
"required": false,
|
410
|
-
"optional": false,
|
411
|
-
"docs": {
|
412
|
-
"tags": [],
|
413
|
-
"text": "Hide mask"
|
414
|
-
},
|
415
|
-
"attribute": "hidden",
|
416
|
-
"reflect": false,
|
417
|
-
"defaultValue": "false"
|
418
|
-
}
|
419
|
-
}; }
|
420
|
-
static get watchers() { return [{
|
421
|
-
"propName": "template",
|
422
|
-
"methodName": "templateHandler"
|
423
|
-
}, {
|
424
|
-
"propName": "char",
|
425
|
-
"methodName": "charHandler"
|
426
|
-
}]; }
|
427
|
-
}
|
@@ -1,85 +0,0 @@
|
|
1
|
-
@keyframes ku4-modal-content-enter {
|
2
|
-
0% {
|
3
|
-
transform: var(--ku4-modal-content-animation-start-transform, scale(0.5));
|
4
|
-
opacity: var(--ku4-modal-content-animation-start-opacity, 0);
|
5
|
-
}
|
6
|
-
50% {
|
7
|
-
transform: var(--ku4-modal-content-animation-mid-transform, scale(1.2));
|
8
|
-
opacity: var(--ku4-modal-content-animation-mid-opacity, 0.8);
|
9
|
-
}
|
10
|
-
100% {
|
11
|
-
transform: var(--ku4-modal-content-animation-end-transform, scale(1));
|
12
|
-
opacity: var(--ku4-modal-content-animation-end-opacity, 1);
|
13
|
-
}
|
14
|
-
}
|
15
|
-
@keyframes ku4-modal-overlay-enter {
|
16
|
-
0% {
|
17
|
-
transform: var(--ku4-modal-overlay-animation-start-transform, none);
|
18
|
-
opacity: var(--ku4-modal-overlay-animation-start-opacity, 0);
|
19
|
-
}
|
20
|
-
50% {
|
21
|
-
transform: var(--ku4-modal-overlay-animation-mid-transform, none);
|
22
|
-
opacity: var(--ku4-modal-overlay-animation-mid-opacity, 0.35);
|
23
|
-
}
|
24
|
-
100% {
|
25
|
-
transform: var(--ku4-modal-overlay-animation-end-transform, none);
|
26
|
-
opacity: var(--ku4-modal-overlay-animation-end-opacity, 0.4);
|
27
|
-
}
|
28
|
-
}
|
29
|
-
:host {
|
30
|
-
position: fixed;
|
31
|
-
display: none;
|
32
|
-
top: 0;
|
33
|
-
left: 0;
|
34
|
-
width: 100vw;
|
35
|
-
height: 100vh;
|
36
|
-
justify-content: center;
|
37
|
-
align-items: center;
|
38
|
-
background: transparent;
|
39
|
-
overflow: auto;
|
40
|
-
transform-style: var(--ku4-modal-transform-style, initial);
|
41
|
-
}
|
42
|
-
|
43
|
-
.ku4-modal-content {
|
44
|
-
position: relative;
|
45
|
-
top: 0;
|
46
|
-
left: 0;
|
47
|
-
}
|
48
|
-
|
49
|
-
.ku4-modal-overlay {
|
50
|
-
position: fixed;
|
51
|
-
display: flex;
|
52
|
-
top: 0;
|
53
|
-
left: 0;
|
54
|
-
width: 100%;
|
55
|
-
height: 100%;
|
56
|
-
opacity: 0;
|
57
|
-
background: var(--ku4-modal-overlay-background, #000);
|
58
|
-
}
|
59
|
-
|
60
|
-
:host([visible]) {
|
61
|
-
display: flex;
|
62
|
-
z-index: var(--ku4-modal-z-index, 5);
|
63
|
-
}
|
64
|
-
|
65
|
-
:host([visible]) .ku4-modal-content {
|
66
|
-
animation-name: ku4-modal-content-enter;
|
67
|
-
animation-duration: var(--ku4-modal-content-animation-duration, 0.4s);
|
68
|
-
animation-timing-function: var(--ku4-modal-content-animation-timing-function, ease);
|
69
|
-
transform: var(--ku4-modal-content-transform, none);
|
70
|
-
opacity: var(--ku4-modal-content-opacity, 1);
|
71
|
-
z-index: calc(var(--ku4-modal-z-index, 5) + 1);
|
72
|
-
}
|
73
|
-
|
74
|
-
:host([visible]) .ku4-modal-overlay {
|
75
|
-
animation-name: ku4-modal-overlay-enter;
|
76
|
-
animation-duration: var(--ku4-modal-overlay-animation-duration, 0.4s);
|
77
|
-
animation-timing-function: var(--ku4-modal-overlay-animation-timing-function, ease);
|
78
|
-
transform: var(--ku4-modal-overlay-transform, none);
|
79
|
-
opacity: var(--ku4-modal-overlay-opacity, 0.4);
|
80
|
-
z-index: calc(var(--ku4-modal-z-index, 5));
|
81
|
-
}
|
82
|
-
|
83
|
-
:host([visible=false]) {
|
84
|
-
display: none;
|
85
|
-
}
|
@@ -1,186 +0,0 @@
|
|
1
|
-
import { Component, Prop, Host, Watch, Listen, Method, Event, Element, h } from '@stencil/core';
|
2
|
-
import { Assert } from 'ku4es-kernel';
|
3
|
-
import { Document, Key } from 'ku4es-ui-kernel';
|
4
|
-
/**
|
5
|
-
* @description ku4-modal
|
6
|
-
*/
|
7
|
-
export class Ku4Modal {
|
8
|
-
constructor() {
|
9
|
-
/**
|
10
|
-
* Visible when true
|
11
|
-
*/
|
12
|
-
// eslint-disable-next-line @stencil/strict-mutable
|
13
|
-
this.visible = false;
|
14
|
-
}
|
15
|
-
handleVisibility(value) {
|
16
|
-
if (value) {
|
17
|
-
Document.preventScroll();
|
18
|
-
if (Assert.exists(this.trap)) {
|
19
|
-
this.trap.activate();
|
20
|
-
}
|
21
|
-
}
|
22
|
-
else {
|
23
|
-
Document.resumeScroll();
|
24
|
-
if (Assert.exists(this.trap)) {
|
25
|
-
this.trap.deactivate();
|
26
|
-
}
|
27
|
-
}
|
28
|
-
}
|
29
|
-
handleKeyUp(e) {
|
30
|
-
if (this.visible && Key.esc.didFire(e)) {
|
31
|
-
this.dismiss();
|
32
|
-
}
|
33
|
-
}
|
34
|
-
/**
|
35
|
-
* Display modal
|
36
|
-
*/
|
37
|
-
async display() {
|
38
|
-
this.visible = true;
|
39
|
-
this.didDisplay.emit(this);
|
40
|
-
}
|
41
|
-
/**
|
42
|
-
* Dismiss modal
|
43
|
-
*/
|
44
|
-
async dismiss() {
|
45
|
-
this.visible = false;
|
46
|
-
this.didDismiss.emit(this);
|
47
|
-
}
|
48
|
-
componentDidLoad() {
|
49
|
-
try {
|
50
|
-
this.trap = this.host.querySelector('ku4-focus-trap') ||
|
51
|
-
(document.querySelector(this.focusTrap));
|
52
|
-
this.handleVisibility(this.visible);
|
53
|
-
}
|
54
|
-
catch (e) {
|
55
|
-
throw new Error(`Cannot connect ku4-focus-trap: ${e.messsage}`);
|
56
|
-
}
|
57
|
-
}
|
58
|
-
render() {
|
59
|
-
return (h(Host, { role: "dialog", "aria-modal": "true" },
|
60
|
-
h("section", { class: "ku4-modal-content" },
|
61
|
-
h("slot", null)),
|
62
|
-
h("section", { class: "ku4-modal-overlay", onClick: () => this.dismiss(), "aria-hidden": "true" })));
|
63
|
-
}
|
64
|
-
static get is() { return "ku4-modal"; }
|
65
|
-
static get encapsulation() { return "shadow"; }
|
66
|
-
static get originalStyleUrls() { return {
|
67
|
-
"$": ["ku4-modal.scss"]
|
68
|
-
}; }
|
69
|
-
static get styleUrls() { return {
|
70
|
-
"$": ["ku4-modal.css"]
|
71
|
-
}; }
|
72
|
-
static get properties() { return {
|
73
|
-
"visible": {
|
74
|
-
"type": "boolean",
|
75
|
-
"mutable": true,
|
76
|
-
"complexType": {
|
77
|
-
"original": "boolean",
|
78
|
-
"resolved": "boolean",
|
79
|
-
"references": {}
|
80
|
-
},
|
81
|
-
"required": false,
|
82
|
-
"optional": false,
|
83
|
-
"docs": {
|
84
|
-
"tags": [],
|
85
|
-
"text": "Visible when true"
|
86
|
-
},
|
87
|
-
"attribute": "visible",
|
88
|
-
"reflect": true,
|
89
|
-
"defaultValue": "false"
|
90
|
-
},
|
91
|
-
"focusTrap": {
|
92
|
-
"type": "string",
|
93
|
-
"mutable": false,
|
94
|
-
"complexType": {
|
95
|
-
"original": "string",
|
96
|
-
"resolved": "string",
|
97
|
-
"references": {}
|
98
|
-
},
|
99
|
-
"required": false,
|
100
|
-
"optional": false,
|
101
|
-
"docs": {
|
102
|
-
"tags": [],
|
103
|
-
"text": "An optional querySelector of an associated ku4-focus-trap that should\nbe activated when this ku4-modal is display and deactivated when\nthis ku4-modal is didDismiss."
|
104
|
-
},
|
105
|
-
"attribute": "focus-trap",
|
106
|
-
"reflect": false
|
107
|
-
}
|
108
|
-
}; }
|
109
|
-
static get events() { return [{
|
110
|
-
"method": "didDisplay",
|
111
|
-
"name": "display",
|
112
|
-
"bubbles": true,
|
113
|
-
"cancelable": true,
|
114
|
-
"composed": true,
|
115
|
-
"docs": {
|
116
|
-
"tags": [],
|
117
|
-
"text": "Event fired when modal is displayed"
|
118
|
-
},
|
119
|
-
"complexType": {
|
120
|
-
"original": "any",
|
121
|
-
"resolved": "any",
|
122
|
-
"references": {}
|
123
|
-
}
|
124
|
-
}, {
|
125
|
-
"method": "didDismiss",
|
126
|
-
"name": "dismiss",
|
127
|
-
"bubbles": true,
|
128
|
-
"cancelable": true,
|
129
|
-
"composed": true,
|
130
|
-
"docs": {
|
131
|
-
"tags": [],
|
132
|
-
"text": "Event fired when modal is dismissed"
|
133
|
-
},
|
134
|
-
"complexType": {
|
135
|
-
"original": "any",
|
136
|
-
"resolved": "any",
|
137
|
-
"references": {}
|
138
|
-
}
|
139
|
-
}]; }
|
140
|
-
static get methods() { return {
|
141
|
-
"display": {
|
142
|
-
"complexType": {
|
143
|
-
"signature": "() => Promise<void>",
|
144
|
-
"parameters": [],
|
145
|
-
"references": {
|
146
|
-
"Promise": {
|
147
|
-
"location": "global"
|
148
|
-
}
|
149
|
-
},
|
150
|
-
"return": "Promise<void>"
|
151
|
-
},
|
152
|
-
"docs": {
|
153
|
-
"text": "Display modal",
|
154
|
-
"tags": []
|
155
|
-
}
|
156
|
-
},
|
157
|
-
"dismiss": {
|
158
|
-
"complexType": {
|
159
|
-
"signature": "() => Promise<void>",
|
160
|
-
"parameters": [],
|
161
|
-
"references": {
|
162
|
-
"Promise": {
|
163
|
-
"location": "global"
|
164
|
-
}
|
165
|
-
},
|
166
|
-
"return": "Promise<void>"
|
167
|
-
},
|
168
|
-
"docs": {
|
169
|
-
"text": "Dismiss modal",
|
170
|
-
"tags": []
|
171
|
-
}
|
172
|
-
}
|
173
|
-
}; }
|
174
|
-
static get elementRef() { return "host"; }
|
175
|
-
static get watchers() { return [{
|
176
|
-
"propName": "visible",
|
177
|
-
"methodName": "handleVisibility"
|
178
|
-
}]; }
|
179
|
-
static get listeners() { return [{
|
180
|
-
"name": "keyup",
|
181
|
-
"method": "handleKeyUp",
|
182
|
-
"target": "window",
|
183
|
-
"capture": false,
|
184
|
-
"passive": false
|
185
|
-
}]; }
|
186
|
-
}
|