ku4web-components 6.4.39 → 6.4.40
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/ku4-mask.cjs.entry.js +9 -0
- package/dist/esm/ku4-mask.entry.js +9 -0
- package/dist/esm-es5/ku4-mask.entry.js +1 -1
- package/dist/ku4web-components/ku4web-components.esm.js +1 -1
- package/dist/ku4web-components/p-320ed193.system.entry.js +1 -0
- package/dist/ku4web-components/p-5848719e.system.js +1 -1
- package/dist/ku4web-components/p-9c815607.entry.js +1 -0
- package/dist/types/components/ku4-mask/ku4-mask.d.ts +1 -0
- package/package.json +1 -1
- package/dist/ku4web-components/p-67b90b07.system.entry.js +0 -1
- package/dist/ku4web-components/p-bfd8c04e.entry.js +0 -1
@@ -51,6 +51,7 @@ let Ku4Mask = class {
|
|
51
51
|
*/
|
52
52
|
this.hidden = false;
|
53
53
|
this.handleFocus = this.handleFocus.bind(this);
|
54
|
+
this.handleBlur = this.handleBlur.bind(this);
|
54
55
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
55
56
|
this.handleInput = this.handleInput.bind(this);
|
56
57
|
this.handleTouchStart = this.handleTouchStart.bind(this);
|
@@ -125,6 +126,12 @@ let Ku4Mask = class {
|
|
125
126
|
this.touchStart = false;
|
126
127
|
});
|
127
128
|
}
|
129
|
+
handleBlur() {
|
130
|
+
const { template, char } = this;
|
131
|
+
if (index$1.t.isEmpty(index$1.a.unmask(this.value, template, char))) {
|
132
|
+
this.value = '';
|
133
|
+
}
|
134
|
+
}
|
128
135
|
handleKeyDown(e) {
|
129
136
|
// Abort if the browser is IE11
|
130
137
|
// @ts-ignore - Leveraging documentMode to determine unsupported browser
|
@@ -285,6 +292,7 @@ let Ku4Mask = class {
|
|
285
292
|
this.input = document.getElementById(this.for);
|
286
293
|
if (index$1.t.exists(this.input)) {
|
287
294
|
this.input.addEventListener('focus', this.handleFocus);
|
295
|
+
this.input.addEventListener('blur', this.handleBlur);
|
288
296
|
this.input.addEventListener('keydown', this.handleKeyDown);
|
289
297
|
this.input.addEventListener('input', this.handleInput);
|
290
298
|
this.input.addEventListener('touchstart', this.handleTouchStart);
|
@@ -297,6 +305,7 @@ let Ku4Mask = class {
|
|
297
305
|
disconnectedCallback() {
|
298
306
|
if (this.input && this.input.removeEventListener) {
|
299
307
|
this.input.removeEventListener('focus', this.handleFocus);
|
308
|
+
this.input.removeEventListener('blur', this.handleBlur);
|
300
309
|
this.input.removeEventListener('keydown', this.handleKeyDown);
|
301
310
|
this.input.removeEventListener('input', this.handleInput);
|
302
311
|
this.input.removeEventListener('touchstart', this.handleTouchStart);
|
@@ -47,6 +47,7 @@ let Ku4Mask = class {
|
|
47
47
|
*/
|
48
48
|
this.hidden = false;
|
49
49
|
this.handleFocus = this.handleFocus.bind(this);
|
50
|
+
this.handleBlur = this.handleBlur.bind(this);
|
50
51
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
51
52
|
this.handleInput = this.handleInput.bind(this);
|
52
53
|
this.handleTouchStart = this.handleTouchStart.bind(this);
|
@@ -121,6 +122,12 @@ let Ku4Mask = class {
|
|
121
122
|
this.touchStart = false;
|
122
123
|
});
|
123
124
|
}
|
125
|
+
handleBlur() {
|
126
|
+
const { template, char } = this;
|
127
|
+
if (t.isEmpty(a.unmask(this.value, template, char))) {
|
128
|
+
this.value = '';
|
129
|
+
}
|
130
|
+
}
|
124
131
|
handleKeyDown(e) {
|
125
132
|
// Abort if the browser is IE11
|
126
133
|
// @ts-ignore - Leveraging documentMode to determine unsupported browser
|
@@ -281,6 +288,7 @@ let Ku4Mask = class {
|
|
281
288
|
this.input = document.getElementById(this.for);
|
282
289
|
if (t.exists(this.input)) {
|
283
290
|
this.input.addEventListener('focus', this.handleFocus);
|
291
|
+
this.input.addEventListener('blur', this.handleBlur);
|
284
292
|
this.input.addEventListener('keydown', this.handleKeyDown);
|
285
293
|
this.input.addEventListener('input', this.handleInput);
|
286
294
|
this.input.addEventListener('touchstart', this.handleTouchStart);
|
@@ -293,6 +301,7 @@ let Ku4Mask = class {
|
|
293
301
|
disconnectedCallback() {
|
294
302
|
if (this.input && this.input.removeEventListener) {
|
295
303
|
this.input.removeEventListener('focus', this.handleFocus);
|
304
|
+
this.input.removeEventListener('blur', this.handleBlur);
|
296
305
|
this.input.removeEventListener('keydown', this.handleKeyDown);
|
297
306
|
this.input.removeEventListener('input', this.handleInput);
|
298
307
|
this.input.removeEventListener('touchstart', this.handleTouchStart);
|
@@ -1 +1 @@
|
|
1
|
-
var __spreadArray=this&&this.__spreadArray||function(t,e){for(var n=0,r=e.length,a=t.length;n<r;n++,a++)t[a]=e[n];return t};import{r as registerInstance,h}from"./index-52020db7.js";import{a,Y,t}from"./index-20c3926d.js";var ku4MaskCss=":host{display:none}";var Ku4Mask=function(){function e(t){registerInstance(this,t);this.charIndexes=[];this.reverseCharIndexes=[];this.previousValue="";this.currentValue="";this.touchStart=false;this.template="";this.ban="";this.pattern="";this.char="_";this.hidden=false;this.handleFocus=this.handleFocus.bind(this);this.handleKeyDown=this.handleKeyDown.bind(this);this.handleInput=this.handleInput.bind(this);this.handleTouchStart=this.handleTouchStart.bind(this);this.init()}e.prototype.init=function(){var t=this;this.chars=this.char&&new RegExp(this.char);this.banned=this.ban&&new RegExp(this.ban);var e=this.pattern.replace(/[\s\n]/gm,"");this.patterns=e.substr(1).split(e[0]).map((function(t){try{return t&&new RegExp(t)||null}catch(e){}}));this.charIndexes=this.template.split("").reduce((function(e,n,r){if(t.chars.test(n)){e.push(r)}return e}),[]);this.reverseCharIndexes=__spreadArray([],this.charIndexes).reverse();return this};e.prototype.templateHandler=function(t,e){var n=this,r=n.input,i=n.previousCharIndex,s=n.previousValue,u=n.currentValue,h=n.value,o=n.char;var l=a.unmask(s,e,o).length;var
|
1
|
+
var __spreadArray=this&&this.__spreadArray||function(t,e){for(var n=0,r=e.length,a=t.length;n<r;n++,a++)t[a]=e[n];return t};import{r as registerInstance,h}from"./index-52020db7.js";import{a,Y,t}from"./index-20c3926d.js";var ku4MaskCss=":host{display:none}";var Ku4Mask=function(){function e(t){registerInstance(this,t);this.charIndexes=[];this.reverseCharIndexes=[];this.previousValue="";this.currentValue="";this.touchStart=false;this.template="";this.ban="";this.pattern="";this.char="_";this.hidden=false;this.handleFocus=this.handleFocus.bind(this);this.handleBlur=this.handleBlur.bind(this);this.handleKeyDown=this.handleKeyDown.bind(this);this.handleInput=this.handleInput.bind(this);this.handleTouchStart=this.handleTouchStart.bind(this);this.init()}e.prototype.init=function(){var t=this;this.chars=this.char&&new RegExp(this.char);this.banned=this.ban&&new RegExp(this.ban);var e=this.pattern.replace(/[\s\n]/gm,"");this.patterns=e.substr(1).split(e[0]).map((function(t){try{return t&&new RegExp(t)||null}catch(e){}}));this.charIndexes=this.template.split("").reduce((function(e,n,r){if(t.chars.test(n)){e.push(r)}return e}),[]);this.reverseCharIndexes=__spreadArray([],this.charIndexes).reverse();return this};e.prototype.templateHandler=function(t,e){var n=this,r=n.input,i=n.previousCharIndex,s=n.previousValue,u=n.currentValue,h=n.value,o=n.char;var l=a.unmask(s,e,o).length;var d=a.unmask(u,e,o).length;var c=l<d?i+1:i;this.init().value=a.mask(a.unmask(h,e,o),t,o);r.setSelectionRange(c,c)};e.prototype.charHandler=function(t,e){var n=this,r=n.value,i=n.template;this.init().value=a.mask(a.unmask(r,i,e),i,t)};Object.defineProperty(e.prototype,"previousCharIndex",{get:function(){var t=this;return this.reverseCharIndexes.find((function(e){return t.selectionStart>e}))||this.charIndexes[0]},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"value",{get:function(){return this.currentValue},set:function(t){var e=this,n=e.chars,r=e.hidden,a=e.input;var i=t.search(n);this.currentValue=t;a.value=r&&i>-1?t.substring(0,i):t},enumerable:false,configurable:true});e.prototype.handleTouchStart=function(){this.touchStart=true};e.prototype.handleFocus=function(){var t=this;if(window.document.documentMode){return}var e=this,n=e.input,r=e.template,i=e.char,s=e.chars,u=e.touchStart;this.value=a.mask(a.unmask(this.value,r,i),r,i);Y(0).then((function(){var e=n.value.search(s);var r=e<0?n.value.length:e;t.input.setSelectionRange(e<0&&!u?0:r,r);t.touchStart=false}))};e.prototype.handleBlur=function(){var e=this,n=e.template,r=e.char;if(t.isEmpty(a.unmask(this.value,n,r))){this.value=""}};e.prototype.handleKeyDown=function(t){if(window.document.documentMode){return}var e=this,n=e.banned,r=e.hidden,i=e.template,s=e.char;if(t.key&&t.key.length===1&&n&&(n.test(t.key)&&!(t.altKey||t.ctrlKey||t.metaKey))){t.preventDefault()}this.previousValue=r?a.mask(a.unmask(t.target.value,i,s),i,s):t.target.value;this.selectionStart=t.target.selectionStart;this.selectionEnd=t.target.selectionEnd};e.prototype.handleInput=function(e){var n=this;if(window.document.documentMode){return}var r=this,i=r.input,s=r.template,u=r.char,h=r.chars,o=r.previousValue,l=r.banned,d=r.selectionStart,c=r.selectionEnd,v=r.previousCharIndex,p=r.patterns,f=r.charIndexes,g=r.reverseCharIndexes;if(!h.test(this.previousValue)&&e.inputType!=="insertFromPaste"&&e.inputType!=="deleteContentBackward"&&e.inputType!=="deleteContentForward"&&d===c){this.value=o;return}if(e.inputType==="insertFromPaste"){try{navigator.clipboard.readText().then((function(e){var r=e.replace(new RegExp(l,"g"),"");if(t.isNullOrEmpty(r)){n.value=o;i.setSelectionRange(d,d);return}if(!l||!l.test(r)){var v=o;if(d<c){var p=g.find((function(t){return t<=d-1}));var m=g.find((function(t){return t<=c-1}));var y=f.findIndex((function(t){return t===p}));var k=f.findIndex((function(t){return t===m}));var b=a.unmask(o,s,u);var x=b.substring(0,y+1)+b.substring(k+1,o.length);v=a.mask(x,s,u)}var I=f.find((function(t){return t>=d}));var S=f.findIndex((function(t){return t===I}));var w=a.unmask(v,s,u);v=w.substring(0,S)+r+w.substring(S,o.length);n.value=a.mask(v,s,u);var E=f[S+r.length]||n.value.search(h)||n.value.length;i.setSelectionRange(E,E)}}));this.value=o;i.setSelectionRange(d,d);return}catch(e){this.value=o;i.setSelectionRange(d,d);return}}if(e.inputType==="deleteContentBackward"){var m=g.find((function(t){return t<=d-1}));var y=g.find((function(t){return t<=c-1}));var k=f.findIndex((function(t){return t===m}));var b=f.findIndex((function(t){return t===y}));var x=a.unmask(o,s,u);if(k<b){var I=x.substring(0,k+1)+x.substring(b+1,o.length);this.value=a.mask(I,s,u);I&&k>-1?i.setSelectionRange(v+1,v+1):i.setSelectionRange(v,v)}else{var I=x.substring(0,k)+x.substring(b+1,o.length);this.value=a.mask(I,s,u);i.setSelectionRange(v,v)}return}if(e.inputType==="deleteContentForward"){var S=f.find((function(t){return t>=d}));var w=f.findIndex((function(t){return t===S}));var x=a.unmask(o,s,u);var I=x.substring(0,w)+x.substring(w+1,o.length);this.value=a.mask(I,s,u);i.setSelectionRange(d,d);return}if(e.altKey||e.ctrlKey||e.metaKey){return}if(!e.data){this.value=o;i.setSelectionRange(d,d);return}if(h.test(o.charAt(d))||d===s.length){var x=a.unmask(o,s,u);this.value=a.mask(x+e.data,s,u);var E=this.value.search(h);var R=E<0?s.length:E;i.setSelectionRange(R,R);var C=f.findIndex((function(t){return t>=R}));var K=C<0?f.length-1:C-1;this.validate(e.data,p[K])}else{var L=o;if(d<c){var T=g.find((function(t){return t<=d-1}));var V=g.find((function(t){return t<=c-1}));var k=f.findIndex((function(t){return t===T}));var b=f.findIndex((function(t){return t===V}));var F=a.unmask(o,s,u);var I=F.substring(0,k+1)+F.substring(b+1,o.length);L=a.mask(I,s,u)}var B=f.find((function(t){return t>=d}));var w=f.findIndex((function(t){return t===B}));var x=a.unmask(L,s,u);L=x.substring(0,w)+e.data+x.substring(w,o.length);var M=f.find((function(t){return t>B}));this.value=a.mask(L,s,u);i.setSelectionRange(M,M);var C=f.findIndex((function(t){return t>=M}));var K=C<0?f.length-1:C-1;this.validate(e.data,p[K])}};e.prototype.validate=function(e,n){var r=this,a=r.previousValue,i=r.input,s=r.value,u=r.selectionStart;if(t.exists(n)&&!(n.test(e)||/\(\?[!<=]/.test(n.toString())&&n.test(s))){this.value=a;i.setSelectionRange(u,u)}};e.prototype.componentWillLoad=function(){this.input=document.getElementById(this.for);if(t.exists(this.input)){this.input.addEventListener("focus",this.handleFocus);this.input.addEventListener("blur",this.handleBlur);this.input.addEventListener("keydown",this.handleKeyDown);this.input.addEventListener("input",this.handleInput);this.input.addEventListener("touchstart",this.handleTouchStart)}else{console.error("ku4-mask must have a valid `for` referencing target field `id`.")}};e.prototype.disconnectedCallback=function(){if(this.input&&this.input.removeEventListener){this.input.removeEventListener("focus",this.handleFocus);this.input.removeEventListener("blur",this.handleBlur);this.input.removeEventListener("keydown",this.handleKeyDown);this.input.removeEventListener("input",this.handleInput);this.input.removeEventListener("touchstart",this.handleTouchStart)}};e.prototype.render=function(){return h("slot",null)};Object.defineProperty(e,"watchers",{get:function(){return{template:["templateHandler"],char:["charHandler"]}},enumerable:false,configurable:true});return e}();Ku4Mask.style=ku4MaskCss;export{Ku4Mask as ku4_mask};
|
@@ -1 +1 @@
|
|
1
|
-
import{d as e,N as t,w as s,p as a,b as o}from"./p-670d415c.js";(()=>{const o=Array.from(e.querySelectorAll("script")).find((e=>new RegExp(`/${t}(\\.esm)?\\.js($|\\?|#)`).test(e.src)||e.getAttribute("data-stencil-namespace")===t)),l={};return"onbeforeload"in o&&!history.scrollRestoration?{then(){}}:(l.resourcesUrl=new URL(".",new URL(o.getAttribute("data-resources-url")||o.src,s.location.href)).href,a(l))})().then((e=>o([["p-ebc49910",[[1,"ku4-carousel",{swipeTolerance:[2,"swipe-tolerance"],auto:[4],noSwipe:[4,"no-swipe"],delay:[2],slideState:[32],next:[64],previous:[64],slideTo:[64],pause:[64],play:[64]}]]],["p-6f56d780",[[1,"ku4-carousel-controls",{for:[1]}]]],["p-9e2c3988",[[1,"ku4-carousel-slide",{active:[32],classList:[32],slideIn:[64],slideOut:[64],activate:[64],deactivate:[64]}]]],["p-d0579e6f",[[1,"ku4-col",{startXs:[2,"start-xs"],startSm:[2,"start-sm"],startMd:[2,"start-md"],startLg:[2,"start-lg"],spanXs:[2,"span-xs"],spanSm:[2,"span-sm"],spanMd:[2,"span-md"],spanLg:[2,"span-lg"],orderXs:[2,"order-xs"],orderSm:[2,"order-sm"],orderMd:[2,"order-md"],orderLg:[2,"order-lg"]}]]],["p-7a5e62fd",[[1,"ku4-drawer",{bottom:[516],left:[516],right:[516],top:[516],size:[1],open:[1540],toggle:[64]}]]],["p-c11d7118",[[1,"ku4-feature",{on:[4],policy:[1],enabled:[32]}]]],["p-4986dc9a",[[1,"ku4-focus-trap",{active:[1540],include:[1],exclude:[1],excludeShadow:[1,"exclude-shadow"],initial:[1],return:[1],activate:[64],deactivate:[64]}]]],["p-d248862c",[[4,"ku4-form",{invalid:[1540],validate:[64],invalidate:[64],read:[64],write:[64]}]]],["p-b2db2c0b",[[1,"ku4-grid",{columnsXs:[2,"columns-xs"],columnsSm:[2,"columns-sm"],columnsMd:[2,"columns-md"],columnsLg:[2,"columns-lg"],offsetLeftXs:[2,"offset-left-xs"],offsetLeftSm:[2,"offset-left-sm"],offsetLeftMd:[2,"offset-left-md"],offsetLeftLg:[2,"offset-left-lg"],offsetRight:[2,"offset-right"],offsetRightXs:[2,"offset-right-xs"],offsetRightSm:[2,"offset-right-sm"],offsetRightMd:[2,"offset-right-md"],offsetRightLg:[2,"offset-right-lg"],offsetXs:[2,"offset-xs"],offsetSm:[2,"offset-sm"],offsetMd:[2,"offset-md"],offsetLg:[2,"offset-lg"]}]]],["p-1fb8966a",[[1,"ku4-label",{for:[1],value:[1],empty:[32]}]]],["p-
|
1
|
+
import{d as e,N as t,w as s,p as a,b as o}from"./p-670d415c.js";(()=>{const o=Array.from(e.querySelectorAll("script")).find((e=>new RegExp(`/${t}(\\.esm)?\\.js($|\\?|#)`).test(e.src)||e.getAttribute("data-stencil-namespace")===t)),l={};return"onbeforeload"in o&&!history.scrollRestoration?{then(){}}:(l.resourcesUrl=new URL(".",new URL(o.getAttribute("data-resources-url")||o.src,s.location.href)).href,a(l))})().then((e=>o([["p-ebc49910",[[1,"ku4-carousel",{swipeTolerance:[2,"swipe-tolerance"],auto:[4],noSwipe:[4,"no-swipe"],delay:[2],slideState:[32],next:[64],previous:[64],slideTo:[64],pause:[64],play:[64]}]]],["p-6f56d780",[[1,"ku4-carousel-controls",{for:[1]}]]],["p-9e2c3988",[[1,"ku4-carousel-slide",{active:[32],classList:[32],slideIn:[64],slideOut:[64],activate:[64],deactivate:[64]}]]],["p-d0579e6f",[[1,"ku4-col",{startXs:[2,"start-xs"],startSm:[2,"start-sm"],startMd:[2,"start-md"],startLg:[2,"start-lg"],spanXs:[2,"span-xs"],spanSm:[2,"span-sm"],spanMd:[2,"span-md"],spanLg:[2,"span-lg"],orderXs:[2,"order-xs"],orderSm:[2,"order-sm"],orderMd:[2,"order-md"],orderLg:[2,"order-lg"]}]]],["p-7a5e62fd",[[1,"ku4-drawer",{bottom:[516],left:[516],right:[516],top:[516],size:[1],open:[1540],toggle:[64]}]]],["p-c11d7118",[[1,"ku4-feature",{on:[4],policy:[1],enabled:[32]}]]],["p-4986dc9a",[[1,"ku4-focus-trap",{active:[1540],include:[1],exclude:[1],excludeShadow:[1,"exclude-shadow"],initial:[1],return:[1],activate:[64],deactivate:[64]}]]],["p-d248862c",[[4,"ku4-form",{invalid:[1540],validate:[64],invalidate:[64],read:[64],write:[64]}]]],["p-b2db2c0b",[[1,"ku4-grid",{columnsXs:[2,"columns-xs"],columnsSm:[2,"columns-sm"],columnsMd:[2,"columns-md"],columnsLg:[2,"columns-lg"],offsetLeftXs:[2,"offset-left-xs"],offsetLeftSm:[2,"offset-left-sm"],offsetLeftMd:[2,"offset-left-md"],offsetLeftLg:[2,"offset-left-lg"],offsetRight:[2,"offset-right"],offsetRightXs:[2,"offset-right-xs"],offsetRightSm:[2,"offset-right-sm"],offsetRightMd:[2,"offset-right-md"],offsetRightLg:[2,"offset-right-lg"],offsetXs:[2,"offset-xs"],offsetSm:[2,"offset-sm"],offsetMd:[2,"offset-md"],offsetLg:[2,"offset-lg"]}]]],["p-1fb8966a",[[1,"ku4-label",{for:[1],value:[1],empty:[32]}]]],["p-9c815607",[[1,"ku4-mask",{for:[1],template:[1],ban:[1],pattern:[1],char:[1],hidden:[4]}]]],["p-7587e933",[[1,"ku4-modal",{visible:[1540],focusTrap:[1,"focus-trap"],display:[64],dismiss:[64]},[[8,"keyup","handleKeyUp"]]]]],["p-c194ee9c",[[1,"ku4-panel",{open:[1540],maxHeight:[32],toggle:[64],close:[64]},[[0,"transitionend","handleTransitionEnd"]]]]],["p-867d74d6",[[1,"ku4-preview",{for:[1],src:[1],orientation:[2],resolutionX:[2,"resolution-x"],resolutionY:[2,"resolution-y"],capture:[1],status:[1537],alt:[1],currentSrc:[32],read:[64]}]]],["p-911a6cc5",[[1,"ku4-tab",{selected:[1540],panel:[32],select:[64],deselect:[64],connect:[64]},[[0,"click","handleClick"],[0,"keyup","handleKeyUp"]]]]],["p-cdaa80f7",[[1,"ku4-tab-list",{open:[64]},[[0,"ku4TabClick","handleHpTabClick"],[0,"ku4TabKeyup","handleHpTabKeyUp"]]]]],["p-b9cf48d6",[[1,"ku4-tab-panel",{selected:[1540],maxHeight:[32],tab:[32],select:[64],deselect:[64],connect:[64]},[[0,"transitionend","handleTransitionEnd"]]]]],["p-e63f2453",[[4,"ku4-table",{stackXs:[1537,"stack-xs"],stackSm:[1537,"stack-sm"]}]]],["p-5ad4d525",[[1,"ku4-tooltip",{element:[1],top:[4],left:[4],bottom:[4],right:[4],debug:[4],show:[64],hide:[64]}]]],["p-a4660bb2",[[1,"ku4-validation",{for:[1],element:[1],pattern:[1],flags:[1],values:[1],method:[1],invalid:[1540],disabled:[1540],isValid:[32],validate:[64]}]]]],e)));
|
@@ -0,0 +1 @@
|
|
1
|
+
var __spreadArray=this&&this.__spreadArray||function(t,e){for(var n=0,r=e.length,i=t.length;n<r;n++,i++)t[i]=e[n];return t};System.register(["./p-4de687d8.system.js","./p-0785fc39.system.js"],(function(t){"use strict";var e,n,r,i,a;return{setters:[function(t){e=t.r;n=t.h},function(t){r=t.a;i=t.Y;a=t.t}],execute:function(){var s=":host{display:none}";var u=t("ku4_mask",function(){function t(t){e(this,t);this.charIndexes=[];this.reverseCharIndexes=[];this.previousValue="";this.currentValue="";this.touchStart=false;this.template="";this.ban="";this.pattern="";this.char="_";this.hidden=false;this.handleFocus=this.handleFocus.bind(this);this.handleBlur=this.handleBlur.bind(this);this.handleKeyDown=this.handleKeyDown.bind(this);this.handleInput=this.handleInput.bind(this);this.handleTouchStart=this.handleTouchStart.bind(this);this.init()}t.prototype.init=function(){var t=this;this.chars=this.char&&new RegExp(this.char);this.banned=this.ban&&new RegExp(this.ban);var e=this.pattern.replace(/[\s\n]/gm,"");this.patterns=e.substr(1).split(e[0]).map((function(t){try{return t&&new RegExp(t)||null}catch(e){}}));this.charIndexes=this.template.split("").reduce((function(e,n,r){if(t.chars.test(n)){e.push(r)}return e}),[]);this.reverseCharIndexes=__spreadArray([],this.charIndexes).reverse();return this};t.prototype.templateHandler=function(t,e){var n=this,i=n.input,a=n.previousCharIndex,s=n.previousValue,u=n.currentValue,h=n.value,o=n.char;var l=r.unmask(s,e,o).length;var c=r.unmask(u,e,o).length;var d=l<c?a+1:a;this.init().value=r.mask(r.unmask(h,e,o),t,o);i.setSelectionRange(d,d)};t.prototype.charHandler=function(t,e){var n=this,i=n.value,a=n.template;this.init().value=r.mask(r.unmask(i,a,e),a,t)};Object.defineProperty(t.prototype,"previousCharIndex",{get:function(){var t=this;return this.reverseCharIndexes.find((function(e){return t.selectionStart>e}))||this.charIndexes[0]},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"value",{get:function(){return this.currentValue},set:function(t){var e=this,n=e.chars,r=e.hidden,i=e.input;var a=t.search(n);this.currentValue=t;i.value=r&&a>-1?t.substring(0,a):t},enumerable:false,configurable:true});t.prototype.handleTouchStart=function(){this.touchStart=true};t.prototype.handleFocus=function(){var t=this;if(window.document.documentMode){return}var e=this,n=e.input,a=e.template,s=e.char,u=e.chars,h=e.touchStart;this.value=r.mask(r.unmask(this.value,a,s),a,s);i(0).then((function(){var e=n.value.search(u);var r=e<0?n.value.length:e;t.input.setSelectionRange(e<0&&!h?0:r,r);t.touchStart=false}))};t.prototype.handleBlur=function(){var t=this,e=t.template,n=t.char;if(a.isEmpty(r.unmask(this.value,e,n))){this.value=""}};t.prototype.handleKeyDown=function(t){if(window.document.documentMode){return}var e=this,n=e.banned,i=e.hidden,a=e.template,s=e.char;if(t.key&&t.key.length===1&&n&&(n.test(t.key)&&!(t.altKey||t.ctrlKey||t.metaKey))){t.preventDefault()}this.previousValue=i?r.mask(r.unmask(t.target.value,a,s),a,s):t.target.value;this.selectionStart=t.target.selectionStart;this.selectionEnd=t.target.selectionEnd};t.prototype.handleInput=function(t){var e=this;if(window.document.documentMode){return}var n=this,i=n.input,s=n.template,u=n.char,h=n.chars,o=n.previousValue,l=n.banned,c=n.selectionStart,d=n.selectionEnd,v=n.previousCharIndex,p=n.patterns,f=n.charIndexes,g=n.reverseCharIndexes;if(!h.test(this.previousValue)&&t.inputType!=="insertFromPaste"&&t.inputType!=="deleteContentBackward"&&t.inputType!=="deleteContentForward"&&c===d){this.value=o;return}if(t.inputType==="insertFromPaste"){try{navigator.clipboard.readText().then((function(t){var n=t.replace(new RegExp(l,"g"),"");if(a.isNullOrEmpty(n)){e.value=o;i.setSelectionRange(c,c);return}if(!l||!l.test(n)){var v=o;if(c<d){var p=g.find((function(t){return t<=c-1}));var m=g.find((function(t){return t<=d-1}));var y=f.findIndex((function(t){return t===p}));var b=f.findIndex((function(t){return t===m}));var k=r.unmask(o,s,u);var x=k.substring(0,y+1)+k.substring(b+1,o.length);v=r.mask(x,s,u)}var S=f.find((function(t){return t>=c}));var I=f.findIndex((function(t){return t===S}));var w=r.unmask(v,s,u);v=w.substring(0,I)+n+w.substring(I,o.length);e.value=r.mask(v,s,u);var E=f[I+n.length]||e.value.search(h)||e.value.length;i.setSelectionRange(E,E)}}));this.value=o;i.setSelectionRange(c,c);return}catch(t){this.value=o;i.setSelectionRange(c,c);return}}if(t.inputType==="deleteContentBackward"){var m=g.find((function(t){return t<=c-1}));var y=g.find((function(t){return t<=d-1}));var b=f.findIndex((function(t){return t===m}));var k=f.findIndex((function(t){return t===y}));var x=r.unmask(o,s,u);if(b<k){var S=x.substring(0,b+1)+x.substring(k+1,o.length);this.value=r.mask(S,s,u);S&&b>-1?i.setSelectionRange(v+1,v+1):i.setSelectionRange(v,v)}else{var S=x.substring(0,b)+x.substring(k+1,o.length);this.value=r.mask(S,s,u);i.setSelectionRange(v,v)}return}if(t.inputType==="deleteContentForward"){var I=f.find((function(t){return t>=c}));var w=f.findIndex((function(t){return t===I}));var x=r.unmask(o,s,u);var S=x.substring(0,w)+x.substring(w+1,o.length);this.value=r.mask(S,s,u);i.setSelectionRange(c,c);return}if(t.altKey||t.ctrlKey||t.metaKey){return}if(!t.data){this.value=o;i.setSelectionRange(c,c);return}if(h.test(o.charAt(c))||c===s.length){var x=r.unmask(o,s,u);this.value=r.mask(x+t.data,s,u);var E=this.value.search(h);var R=E<0?s.length:E;i.setSelectionRange(R,R);var C=f.findIndex((function(t){return t>=R}));var L=C<0?f.length-1:C-1;this.validate(t.data,p[L])}else{var T=o;if(c<d){var K=g.find((function(t){return t<=c-1}));var V=g.find((function(t){return t<=d-1}));var b=f.findIndex((function(t){return t===K}));var k=f.findIndex((function(t){return t===V}));var F=r.unmask(o,s,u);var S=F.substring(0,b+1)+F.substring(k+1,o.length);T=r.mask(S,s,u)}var B=f.find((function(t){return t>=c}));var w=f.findIndex((function(t){return t===B}));var x=r.unmask(T,s,u);T=x.substring(0,w)+t.data+x.substring(w,o.length);var _=f.find((function(t){return t>B}));this.value=r.mask(T,s,u);i.setSelectionRange(_,_);var C=f.findIndex((function(t){return t>=_}));var L=C<0?f.length-1:C-1;this.validate(t.data,p[L])}};t.prototype.validate=function(t,e){var n=this,r=n.previousValue,i=n.input,s=n.value,u=n.selectionStart;if(a.exists(e)&&!(e.test(t)||/\(\?[!<=]/.test(e.toString())&&e.test(s))){this.value=r;i.setSelectionRange(u,u)}};t.prototype.componentWillLoad=function(){this.input=document.getElementById(this.for);if(a.exists(this.input)){this.input.addEventListener("focus",this.handleFocus);this.input.addEventListener("blur",this.handleBlur);this.input.addEventListener("keydown",this.handleKeyDown);this.input.addEventListener("input",this.handleInput);this.input.addEventListener("touchstart",this.handleTouchStart)}else{console.error("ku4-mask must have a valid `for` referencing target field `id`.")}};t.prototype.disconnectedCallback=function(){if(this.input&&this.input.removeEventListener){this.input.removeEventListener("focus",this.handleFocus);this.input.removeEventListener("blur",this.handleBlur);this.input.removeEventListener("keydown",this.handleKeyDown);this.input.removeEventListener("input",this.handleInput);this.input.removeEventListener("touchstart",this.handleTouchStart)}};t.prototype.render=function(){return n("slot",null)};Object.defineProperty(t,"watchers",{get:function(){return{template:["templateHandler"],char:["charHandler"]}},enumerable:false,configurable:true});return t}());u.style=s}}}));
|
@@ -1 +1 @@
|
|
1
|
-
System.register(["./p-4de687d8.system.js"],(function(){"use strict";var e,t,s,a,o;return{setters:[function(r){e=r.d;t=r.N;s=r.w;a=r.p;o=r.b}],execute:function(){var r=function(){var o=Array.from(e.querySelectorAll("script")).find((function(e){return new RegExp("/"+t+"(\\.esm)?\\.js($|\\?|#)").test(e.src)||e.getAttribute("data-stencil-namespace")===t}));var r={};if("onbeforeload"in o&&!history.scrollRestoration){return{then:function(){}}}{r.resourcesUrl=new URL(".",new URL(o.getAttribute("data-resources-url")||o.src,s.location.href)).href}return a(r)};r().then((function(e){return o([["p-af5d8c77.system",[[1,"ku4-carousel",{swipeTolerance:[2,"swipe-tolerance"],auto:[4],noSwipe:[4,"no-swipe"],delay:[2],slideState:[32],next:[64],previous:[64],slideTo:[64],pause:[64],play:[64]}]]],["p-d312c8ae.system",[[1,"ku4-carousel-controls",{for:[1]}]]],["p-d3dad5b5.system",[[1,"ku4-carousel-slide",{active:[32],classList:[32],slideIn:[64],slideOut:[64],activate:[64],deactivate:[64]}]]],["p-e9c1a470.system",[[1,"ku4-col",{startXs:[2,"start-xs"],startSm:[2,"start-sm"],startMd:[2,"start-md"],startLg:[2,"start-lg"],spanXs:[2,"span-xs"],spanSm:[2,"span-sm"],spanMd:[2,"span-md"],spanLg:[2,"span-lg"],orderXs:[2,"order-xs"],orderSm:[2,"order-sm"],orderMd:[2,"order-md"],orderLg:[2,"order-lg"]}]]],["p-ff4c04f5.system",[[1,"ku4-drawer",{bottom:[516],left:[516],right:[516],top:[516],size:[1],open:[1540],toggle:[64]}]]],["p-ac86618a.system",[[1,"ku4-feature",{on:[4],policy:[1],enabled:[32]}]]],["p-6a6ebdd6.system",[[1,"ku4-focus-trap",{active:[1540],include:[1],exclude:[1],excludeShadow:[1,"exclude-shadow"],initial:[1],return:[1],activate:[64],deactivate:[64]}]]],["p-c48ff8d2.system",[[4,"ku4-form",{invalid:[1540],validate:[64],invalidate:[64],read:[64],write:[64]}]]],["p-93417cb8.system",[[1,"ku4-grid",{columnsXs:[2,"columns-xs"],columnsSm:[2,"columns-sm"],columnsMd:[2,"columns-md"],columnsLg:[2,"columns-lg"],offsetLeftXs:[2,"offset-left-xs"],offsetLeftSm:[2,"offset-left-sm"],offsetLeftMd:[2,"offset-left-md"],offsetLeftLg:[2,"offset-left-lg"],offsetRight:[2,"offset-right"],offsetRightXs:[2,"offset-right-xs"],offsetRightSm:[2,"offset-right-sm"],offsetRightMd:[2,"offset-right-md"],offsetRightLg:[2,"offset-right-lg"],offsetXs:[2,"offset-xs"],offsetSm:[2,"offset-sm"],offsetMd:[2,"offset-md"],offsetLg:[2,"offset-lg"]}]]],["p-faef0a79.system",[[1,"ku4-label",{for:[1],value:[1],empty:[32]}]]],["p-
|
1
|
+
System.register(["./p-4de687d8.system.js"],(function(){"use strict";var e,t,s,a,o;return{setters:[function(r){e=r.d;t=r.N;s=r.w;a=r.p;o=r.b}],execute:function(){var r=function(){var o=Array.from(e.querySelectorAll("script")).find((function(e){return new RegExp("/"+t+"(\\.esm)?\\.js($|\\?|#)").test(e.src)||e.getAttribute("data-stencil-namespace")===t}));var r={};if("onbeforeload"in o&&!history.scrollRestoration){return{then:function(){}}}{r.resourcesUrl=new URL(".",new URL(o.getAttribute("data-resources-url")||o.src,s.location.href)).href}return a(r)};r().then((function(e){return o([["p-af5d8c77.system",[[1,"ku4-carousel",{swipeTolerance:[2,"swipe-tolerance"],auto:[4],noSwipe:[4,"no-swipe"],delay:[2],slideState:[32],next:[64],previous:[64],slideTo:[64],pause:[64],play:[64]}]]],["p-d312c8ae.system",[[1,"ku4-carousel-controls",{for:[1]}]]],["p-d3dad5b5.system",[[1,"ku4-carousel-slide",{active:[32],classList:[32],slideIn:[64],slideOut:[64],activate:[64],deactivate:[64]}]]],["p-e9c1a470.system",[[1,"ku4-col",{startXs:[2,"start-xs"],startSm:[2,"start-sm"],startMd:[2,"start-md"],startLg:[2,"start-lg"],spanXs:[2,"span-xs"],spanSm:[2,"span-sm"],spanMd:[2,"span-md"],spanLg:[2,"span-lg"],orderXs:[2,"order-xs"],orderSm:[2,"order-sm"],orderMd:[2,"order-md"],orderLg:[2,"order-lg"]}]]],["p-ff4c04f5.system",[[1,"ku4-drawer",{bottom:[516],left:[516],right:[516],top:[516],size:[1],open:[1540],toggle:[64]}]]],["p-ac86618a.system",[[1,"ku4-feature",{on:[4],policy:[1],enabled:[32]}]]],["p-6a6ebdd6.system",[[1,"ku4-focus-trap",{active:[1540],include:[1],exclude:[1],excludeShadow:[1,"exclude-shadow"],initial:[1],return:[1],activate:[64],deactivate:[64]}]]],["p-c48ff8d2.system",[[4,"ku4-form",{invalid:[1540],validate:[64],invalidate:[64],read:[64],write:[64]}]]],["p-93417cb8.system",[[1,"ku4-grid",{columnsXs:[2,"columns-xs"],columnsSm:[2,"columns-sm"],columnsMd:[2,"columns-md"],columnsLg:[2,"columns-lg"],offsetLeftXs:[2,"offset-left-xs"],offsetLeftSm:[2,"offset-left-sm"],offsetLeftMd:[2,"offset-left-md"],offsetLeftLg:[2,"offset-left-lg"],offsetRight:[2,"offset-right"],offsetRightXs:[2,"offset-right-xs"],offsetRightSm:[2,"offset-right-sm"],offsetRightMd:[2,"offset-right-md"],offsetRightLg:[2,"offset-right-lg"],offsetXs:[2,"offset-xs"],offsetSm:[2,"offset-sm"],offsetMd:[2,"offset-md"],offsetLg:[2,"offset-lg"]}]]],["p-faef0a79.system",[[1,"ku4-label",{for:[1],value:[1],empty:[32]}]]],["p-320ed193.system",[[1,"ku4-mask",{for:[1],template:[1],ban:[1],pattern:[1],char:[1],hidden:[4]}]]],["p-19147286.system",[[1,"ku4-modal",{visible:[1540],focusTrap:[1,"focus-trap"],display:[64],dismiss:[64]},[[8,"keyup","handleKeyUp"]]]]],["p-9b9fb5a2.system",[[1,"ku4-panel",{open:[1540],maxHeight:[32],toggle:[64],close:[64]},[[0,"transitionend","handleTransitionEnd"]]]]],["p-2bbea5f3.system",[[1,"ku4-preview",{for:[1],src:[1],orientation:[2],resolutionX:[2,"resolution-x"],resolutionY:[2,"resolution-y"],capture:[1],status:[1537],alt:[1],currentSrc:[32],read:[64]}]]],["p-60512677.system",[[1,"ku4-tab",{selected:[1540],panel:[32],select:[64],deselect:[64],connect:[64]},[[0,"click","handleClick"],[0,"keyup","handleKeyUp"]]]]],["p-e89bc35d.system",[[1,"ku4-tab-list",{open:[64]},[[0,"ku4TabClick","handleHpTabClick"],[0,"ku4TabKeyup","handleHpTabKeyUp"]]]]],["p-769237d3.system",[[1,"ku4-tab-panel",{selected:[1540],maxHeight:[32],tab:[32],select:[64],deselect:[64],connect:[64]},[[0,"transitionend","handleTransitionEnd"]]]]],["p-8645d86f.system",[[4,"ku4-table",{stackXs:[1537,"stack-xs"],stackSm:[1537,"stack-sm"]}]]],["p-dda45242.system",[[1,"ku4-tooltip",{element:[1],top:[4],left:[4],bottom:[4],right:[4],debug:[4],show:[64],hide:[64]}]]],["p-cf26f490.system",[[1,"ku4-validation",{for:[1],element:[1],pattern:[1],flags:[1],values:[1],method:[1],invalid:[1540],disabled:[1540],isValid:[32],validate:[64]}]]]],e)}))}}}));
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,h as s}from"./p-670d415c.js";import{a as i,Y as h,t as e}from"./p-c1068ffa.js";let n=class{constructor(s){t(this,s),this.charIndexes=[],this.reverseCharIndexes=[],this.previousValue="",this.currentValue="",this.touchStart=!1,this.template="",this.ban="",this.pattern="",this.char="_",this.hidden=!1,this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleInput=this.handleInput.bind(this),this.handleTouchStart=this.handleTouchStart.bind(this),this.init()}init(){this.chars=this.char&&new RegExp(this.char),this.banned=this.ban&&new RegExp(this.ban);const t=this.pattern.replace(/[\s\n]/gm,"");return this.patterns=t.substr(1).split(t[0]).map((t=>{try{return t&&new RegExp(t)||null}catch(s){}})),this.charIndexes=this.template.split("").reduce(((t,s,i)=>(this.chars.test(s)&&t.push(i),t)),[]),this.reverseCharIndexes=[...this.charIndexes].reverse(),this}templateHandler(t,s){const{input:h,previousCharIndex:e,previousValue:n,currentValue:r,value:a,char:o}=this,c=i.unmask(n,s,o).length<i.unmask(r,s,o).length?e+1:e;this.init().value=i.mask(i.unmask(a,s,o),t,o),h.setSelectionRange(c,c)}charHandler(t,s){const{value:h,template:e}=this;this.init().value=i.mask(i.unmask(h,e,s),e,t)}get previousCharIndex(){return this.reverseCharIndexes.find((t=>this.selectionStart>t))||this.charIndexes[0]}get value(){return this.currentValue}set value(t){const{chars:s,hidden:i,input:h}=this,e=t.search(s);this.currentValue=t,h.value=i&&e>-1?t.substring(0,e):t}handleTouchStart(){this.touchStart=!0}handleFocus(){if(window.document.documentMode)return;const{input:t,template:s,char:e,chars:n,touchStart:r}=this;this.value=i.mask(i.unmask(this.value,s,e),s,e),h(0).then((()=>{const s=t.value.search(n),i=s<0?t.value.length:s;this.input.setSelectionRange(s<0&&!r?0:i,i),this.touchStart=!1}))}handleBlur(){const{template:t,char:s}=this;e.isEmpty(i.unmask(this.value,t,s))&&(this.value="")}handleKeyDown(t){if(window.document.documentMode)return;const{banned:s,hidden:h,template:e,char:n}=this;t.key&&1===t.key.length&&s&&s.test(t.key)&&!(t.altKey||t.ctrlKey||t.metaKey)&&t.preventDefault(),this.previousValue=h?i.mask(i.unmask(t.target.value,e,n),e,n):t.target.value,this.selectionStart=t.target.selectionStart,this.selectionEnd=t.target.selectionEnd}handleInput(t){if(window.document.documentMode)return;const{input:s,template:h,char:n,chars:r,previousValue:a,banned:o,selectionStart:c,selectionEnd:l,previousCharIndex:u,patterns:d,charIndexes:p,reverseCharIndexes:f}=this;if(r.test(this.previousValue)||"insertFromPaste"===t.inputType||"deleteContentBackward"===t.inputType||"deleteContentForward"===t.inputType||c!==l){if("insertFromPaste"===t.inputType)try{return navigator.clipboard.readText().then((t=>{const u=t.replace(new RegExp(o,"g"),"");if(e.isNullOrEmpty(u))return this.value=a,void s.setSelectionRange(c,c);if(!o||!o.test(u)){let t=a;if(c<l){const s=f.find((t=>t<=c-1)),e=f.find((t=>t<=l-1)),r=p.findIndex((t=>t===s)),o=p.findIndex((t=>t===e)),u=i.unmask(a,h,n),d=u.substring(0,r+1)+u.substring(o+1,a.length);t=i.mask(d,h,n)}const e=p.find((t=>t>=c)),o=p.findIndex((t=>t===e)),d=i.unmask(t,h,n);t=d.substring(0,o)+u+d.substring(o,a.length),this.value=i.mask(t,h,n);const v=p[o+u.length]||this.value.search(r)||this.value.length;s.setSelectionRange(v,v)}})),this.value=a,void s.setSelectionRange(c,c)}catch(t){return this.value=a,void s.setSelectionRange(c,c)}if("deleteContentBackward"!==t.inputType){if("deleteContentForward"===t.inputType){const t=p.find((t=>t>=c)),e=p.findIndex((s=>s===t)),r=i.unmask(a,h,n),o=r.substring(0,e)+r.substring(e+1,a.length);return this.value=i.mask(o,h,n),void s.setSelectionRange(c,c)}if(!(t.altKey||t.ctrlKey||t.metaKey)){if(!t.data)return this.value=a,void s.setSelectionRange(c,c);if(r.test(a.charAt(c))||c===h.length){const e=i.unmask(a,h,n);this.value=i.mask(e+t.data,h,n);const o=this.value.search(r),c=o<0?h.length:o;s.setSelectionRange(c,c);const l=p.findIndex((t=>t>=c));this.validate(t.data,d[l<0?p.length-1:l-1])}else{let e=a;if(c<l){const t=f.find((t=>t<=c-1)),s=f.find((t=>t<=l-1)),r=p.findIndex((s=>s===t)),o=p.findIndex((t=>t===s)),u=i.unmask(a,h,n),d=u.substring(0,r+1)+u.substring(o+1,a.length);e=i.mask(d,h,n)}const r=p.find((t=>t>=c)),o=p.findIndex((t=>t===r)),u=i.unmask(e,h,n);e=u.substring(0,o)+t.data+u.substring(o,a.length);const v=p.find((t=>t>r));this.value=i.mask(e,h,n),s.setSelectionRange(v,v);const m=p.findIndex((t=>t>=v));this.validate(t.data,d[m<0?p.length-1:m-1])}}}else{const t=f.find((t=>t<=c-1)),e=f.find((t=>t<=l-1)),r=p.findIndex((s=>s===t)),o=p.findIndex((t=>t===e)),d=i.unmask(a,h,n);if(r<o){const t=d.substring(0,r+1)+d.substring(o+1,a.length);this.value=i.mask(t,h,n),t&&r>-1?s.setSelectionRange(u+1,u+1):s.setSelectionRange(u,u)}else{const t=d.substring(0,r)+d.substring(o+1,a.length);this.value=i.mask(t,h,n),s.setSelectionRange(u,u)}}}else this.value=a}validate(t,s){const{previousValue:i,input:h,value:n,selectionStart:r}=this;e.exists(s)&&!(s.test(t)||/\(\?[!<=]/.test(s.toString())&&s.test(n))&&(this.value=i,h.setSelectionRange(r,r))}componentWillLoad(){this.input=document.getElementById(this.for),e.exists(this.input)?(this.input.addEventListener("focus",this.handleFocus),this.input.addEventListener("blur",this.handleBlur),this.input.addEventListener("keydown",this.handleKeyDown),this.input.addEventListener("input",this.handleInput),this.input.addEventListener("touchstart",this.handleTouchStart)):console.error("ku4-mask must have a valid `for` referencing target field `id`.")}disconnectedCallback(){this.input&&this.input.removeEventListener&&(this.input.removeEventListener("focus",this.handleFocus),this.input.removeEventListener("blur",this.handleBlur),this.input.removeEventListener("keydown",this.handleKeyDown),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("touchstart",this.handleTouchStart))}render(){return s("slot",null)}static get watchers(){return{template:["templateHandler"],char:["charHandler"]}}};n.style=":host{display:none}";export{n as ku4_mask}
|
package/package.json
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
var __spreadArray=this&&this.__spreadArray||function(t,e){for(var n=0,r=e.length,i=t.length;n<r;n++,i++)t[i]=e[n];return t};System.register(["./p-4de687d8.system.js","./p-0785fc39.system.js"],(function(t){"use strict";var e,n,r,i,a;return{setters:[function(t){e=t.r;n=t.h},function(t){r=t.a;i=t.Y;a=t.t}],execute:function(){var s=":host{display:none}";var u=t("ku4_mask",function(){function t(t){e(this,t);this.charIndexes=[];this.reverseCharIndexes=[];this.previousValue="";this.currentValue="";this.touchStart=false;this.template="";this.ban="";this.pattern="";this.char="_";this.hidden=false;this.handleFocus=this.handleFocus.bind(this);this.handleKeyDown=this.handleKeyDown.bind(this);this.handleInput=this.handleInput.bind(this);this.handleTouchStart=this.handleTouchStart.bind(this);this.init()}t.prototype.init=function(){var t=this;this.chars=this.char&&new RegExp(this.char);this.banned=this.ban&&new RegExp(this.ban);var e=this.pattern.replace(/[\s\n]/gm,"");this.patterns=e.substr(1).split(e[0]).map((function(t){try{return t&&new RegExp(t)||null}catch(e){}}));this.charIndexes=this.template.split("").reduce((function(e,n,r){if(t.chars.test(n)){e.push(r)}return e}),[]);this.reverseCharIndexes=__spreadArray([],this.charIndexes).reverse();return this};t.prototype.templateHandler=function(t,e){var n=this,i=n.input,a=n.previousCharIndex,s=n.previousValue,u=n.currentValue,h=n.value,o=n.char;var l=r.unmask(s,e,o).length;var c=r.unmask(u,e,o).length;var d=l<c?a+1:a;this.init().value=r.mask(r.unmask(h,e,o),t,o);i.setSelectionRange(d,d)};t.prototype.charHandler=function(t,e){var n=this,i=n.value,a=n.template;this.init().value=r.mask(r.unmask(i,a,e),a,t)};Object.defineProperty(t.prototype,"previousCharIndex",{get:function(){var t=this;return this.reverseCharIndexes.find((function(e){return t.selectionStart>e}))||this.charIndexes[0]},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"value",{get:function(){return this.currentValue},set:function(t){var e=this,n=e.chars,r=e.hidden,i=e.input;var a=t.search(n);this.currentValue=t;i.value=r&&a>-1?t.substring(0,a):t},enumerable:false,configurable:true});t.prototype.handleTouchStart=function(){this.touchStart=true};t.prototype.handleFocus=function(){var t=this;if(window.document.documentMode){return}var e=this,n=e.input,a=e.template,s=e.char,u=e.chars,h=e.touchStart;this.value=r.mask(r.unmask(this.value,a,s),a,s);i(0).then((function(){var e=n.value.search(u);var r=e<0?n.value.length:e;t.input.setSelectionRange(e<0&&!h?0:r,r);t.touchStart=false}))};t.prototype.handleKeyDown=function(t){if(window.document.documentMode){return}var e=this,n=e.banned,i=e.hidden,a=e.template,s=e.char;if(t.key&&t.key.length===1&&n&&(n.test(t.key)&&!(t.altKey||t.ctrlKey||t.metaKey))){t.preventDefault()}this.previousValue=i?r.mask(r.unmask(t.target.value,a,s),a,s):t.target.value;this.selectionStart=t.target.selectionStart;this.selectionEnd=t.target.selectionEnd};t.prototype.handleInput=function(t){var e=this;if(window.document.documentMode){return}var n=this,i=n.input,s=n.template,u=n.char,h=n.chars,o=n.previousValue,l=n.banned,c=n.selectionStart,d=n.selectionEnd,v=n.previousCharIndex,f=n.patterns,p=n.charIndexes,g=n.reverseCharIndexes;if(!h.test(this.previousValue)&&t.inputType!=="insertFromPaste"&&t.inputType!=="deleteContentBackward"&&t.inputType!=="deleteContentForward"&&c===d){this.value=o;return}if(t.inputType==="insertFromPaste"){try{navigator.clipboard.readText().then((function(t){var n=t.replace(new RegExp(l,"g"),"");if(a.isNullOrEmpty(n)){e.value=o;i.setSelectionRange(c,c);return}if(!l||!l.test(n)){var v=o;if(c<d){var f=g.find((function(t){return t<=c-1}));var m=g.find((function(t){return t<=d-1}));var y=p.findIndex((function(t){return t===f}));var b=p.findIndex((function(t){return t===m}));var k=r.unmask(o,s,u);var x=k.substring(0,y+1)+k.substring(b+1,o.length);v=r.mask(x,s,u)}var S=p.find((function(t){return t>=c}));var I=p.findIndex((function(t){return t===S}));var w=r.unmask(v,s,u);v=w.substring(0,I)+n+w.substring(I,o.length);e.value=r.mask(v,s,u);var E=p[I+n.length]||e.value.search(h)||e.value.length;i.setSelectionRange(E,E)}}));this.value=o;i.setSelectionRange(c,c);return}catch(t){this.value=o;i.setSelectionRange(c,c);return}}if(t.inputType==="deleteContentBackward"){var m=g.find((function(t){return t<=c-1}));var y=g.find((function(t){return t<=d-1}));var b=p.findIndex((function(t){return t===m}));var k=p.findIndex((function(t){return t===y}));var x=r.unmask(o,s,u);if(b<k){var S=x.substring(0,b+1)+x.substring(k+1,o.length);this.value=r.mask(S,s,u);S&&b>-1?i.setSelectionRange(v+1,v+1):i.setSelectionRange(v,v)}else{var S=x.substring(0,b)+x.substring(k+1,o.length);this.value=r.mask(S,s,u);i.setSelectionRange(v,v)}return}if(t.inputType==="deleteContentForward"){var I=p.find((function(t){return t>=c}));var w=p.findIndex((function(t){return t===I}));var x=r.unmask(o,s,u);var S=x.substring(0,w)+x.substring(w+1,o.length);this.value=r.mask(S,s,u);i.setSelectionRange(c,c);return}if(t.altKey||t.ctrlKey||t.metaKey){return}if(!t.data){this.value=o;i.setSelectionRange(c,c);return}if(h.test(o.charAt(c))||c===s.length){var x=r.unmask(o,s,u);this.value=r.mask(x+t.data,s,u);var E=this.value.search(h);var R=E<0?s.length:E;i.setSelectionRange(R,R);var C=p.findIndex((function(t){return t>=R}));var T=C<0?p.length-1:C-1;this.validate(t.data,f[T])}else{var K=o;if(c<d){var L=g.find((function(t){return t<=c-1}));var V=g.find((function(t){return t<=d-1}));var b=p.findIndex((function(t){return t===L}));var k=p.findIndex((function(t){return t===V}));var F=r.unmask(o,s,u);var S=F.substring(0,b+1)+F.substring(k+1,o.length);K=r.mask(S,s,u)}var _=p.find((function(t){return t>=c}));var w=p.findIndex((function(t){return t===_}));var x=r.unmask(K,s,u);K=x.substring(0,w)+t.data+x.substring(w,o.length);var D=p.find((function(t){return t>_}));this.value=r.mask(K,s,u);i.setSelectionRange(D,D);var C=p.findIndex((function(t){return t>=D}));var T=C<0?p.length-1:C-1;this.validate(t.data,f[T])}};t.prototype.validate=function(t,e){var n=this,r=n.previousValue,i=n.input,s=n.value,u=n.selectionStart;if(a.exists(e)&&!(e.test(t)||/\(\?[!<=]/.test(e.toString())&&e.test(s))){this.value=r;i.setSelectionRange(u,u)}};t.prototype.componentWillLoad=function(){this.input=document.getElementById(this.for);if(a.exists(this.input)){this.input.addEventListener("focus",this.handleFocus);this.input.addEventListener("keydown",this.handleKeyDown);this.input.addEventListener("input",this.handleInput);this.input.addEventListener("touchstart",this.handleTouchStart)}else{console.error("ku4-mask must have a valid `for` referencing target field `id`.")}};t.prototype.disconnectedCallback=function(){if(this.input&&this.input.removeEventListener){this.input.removeEventListener("focus",this.handleFocus);this.input.removeEventListener("keydown",this.handleKeyDown);this.input.removeEventListener("input",this.handleInput);this.input.removeEventListener("touchstart",this.handleTouchStart)}};t.prototype.render=function(){return n("slot",null)};Object.defineProperty(t,"watchers",{get:function(){return{template:["templateHandler"],char:["charHandler"]}},enumerable:false,configurable:true});return t}());u.style=s}}}));
|
@@ -1 +0,0 @@
|
|
1
|
-
import{r as t,h as s}from"./p-670d415c.js";import{a as i,Y as e,t as h}from"./p-c1068ffa.js";let n=class{constructor(s){t(this,s),this.charIndexes=[],this.reverseCharIndexes=[],this.previousValue="",this.currentValue="",this.touchStart=!1,this.template="",this.ban="",this.pattern="",this.char="_",this.hidden=!1,this.handleFocus=this.handleFocus.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleInput=this.handleInput.bind(this),this.handleTouchStart=this.handleTouchStart.bind(this),this.init()}init(){this.chars=this.char&&new RegExp(this.char),this.banned=this.ban&&new RegExp(this.ban);const t=this.pattern.replace(/[\s\n]/gm,"");return this.patterns=t.substr(1).split(t[0]).map((t=>{try{return t&&new RegExp(t)||null}catch(s){}})),this.charIndexes=this.template.split("").reduce(((t,s,i)=>(this.chars.test(s)&&t.push(i),t)),[]),this.reverseCharIndexes=[...this.charIndexes].reverse(),this}templateHandler(t,s){const{input:e,previousCharIndex:h,previousValue:n,currentValue:r,value:a,char:o}=this,c=i.unmask(n,s,o).length<i.unmask(r,s,o).length?h+1:h;this.init().value=i.mask(i.unmask(a,s,o),t,o),e.setSelectionRange(c,c)}charHandler(t,s){const{value:e,template:h}=this;this.init().value=i.mask(i.unmask(e,h,s),h,t)}get previousCharIndex(){return this.reverseCharIndexes.find((t=>this.selectionStart>t))||this.charIndexes[0]}get value(){return this.currentValue}set value(t){const{chars:s,hidden:i,input:e}=this,h=t.search(s);this.currentValue=t,e.value=i&&h>-1?t.substring(0,h):t}handleTouchStart(){this.touchStart=!0}handleFocus(){if(window.document.documentMode)return;const{input:t,template:s,char:h,chars:n,touchStart:r}=this;this.value=i.mask(i.unmask(this.value,s,h),s,h),e(0).then((()=>{const s=t.value.search(n),i=s<0?t.value.length:s;this.input.setSelectionRange(s<0&&!r?0:i,i),this.touchStart=!1}))}handleKeyDown(t){if(window.document.documentMode)return;const{banned:s,hidden:e,template:h,char:n}=this;t.key&&1===t.key.length&&s&&s.test(t.key)&&!(t.altKey||t.ctrlKey||t.metaKey)&&t.preventDefault(),this.previousValue=e?i.mask(i.unmask(t.target.value,h,n),h,n):t.target.value,this.selectionStart=t.target.selectionStart,this.selectionEnd=t.target.selectionEnd}handleInput(t){if(window.document.documentMode)return;const{input:s,template:e,char:n,chars:r,previousValue:a,banned:o,selectionStart:c,selectionEnd:l,previousCharIndex:u,patterns:d,charIndexes:p,reverseCharIndexes:f}=this;if(r.test(this.previousValue)||"insertFromPaste"===t.inputType||"deleteContentBackward"===t.inputType||"deleteContentForward"===t.inputType||c!==l){if("insertFromPaste"===t.inputType)try{return navigator.clipboard.readText().then((t=>{const u=t.replace(new RegExp(o,"g"),"");if(h.isNullOrEmpty(u))return this.value=a,void s.setSelectionRange(c,c);if(!o||!o.test(u)){let t=a;if(c<l){const s=f.find((t=>t<=c-1)),h=f.find((t=>t<=l-1)),r=p.findIndex((t=>t===s)),o=p.findIndex((t=>t===h)),u=i.unmask(a,e,n),d=u.substring(0,r+1)+u.substring(o+1,a.length);t=i.mask(d,e,n)}const h=p.find((t=>t>=c)),o=p.findIndex((t=>t===h)),d=i.unmask(t,e,n);t=d.substring(0,o)+u+d.substring(o,a.length),this.value=i.mask(t,e,n);const v=p[o+u.length]||this.value.search(r)||this.value.length;s.setSelectionRange(v,v)}})),this.value=a,void s.setSelectionRange(c,c)}catch(t){return this.value=a,void s.setSelectionRange(c,c)}if("deleteContentBackward"!==t.inputType){if("deleteContentForward"===t.inputType){const t=p.find((t=>t>=c)),h=p.findIndex((s=>s===t)),r=i.unmask(a,e,n),o=r.substring(0,h)+r.substring(h+1,a.length);return this.value=i.mask(o,e,n),void s.setSelectionRange(c,c)}if(!(t.altKey||t.ctrlKey||t.metaKey)){if(!t.data)return this.value=a,void s.setSelectionRange(c,c);if(r.test(a.charAt(c))||c===e.length){const h=i.unmask(a,e,n);this.value=i.mask(h+t.data,e,n);const o=this.value.search(r),c=o<0?e.length:o;s.setSelectionRange(c,c);const l=p.findIndex((t=>t>=c));this.validate(t.data,d[l<0?p.length-1:l-1])}else{let h=a;if(c<l){const t=f.find((t=>t<=c-1)),s=f.find((t=>t<=l-1)),r=p.findIndex((s=>s===t)),o=p.findIndex((t=>t===s)),u=i.unmask(a,e,n),d=u.substring(0,r+1)+u.substring(o+1,a.length);h=i.mask(d,e,n)}const r=p.find((t=>t>=c)),o=p.findIndex((t=>t===r)),u=i.unmask(h,e,n);h=u.substring(0,o)+t.data+u.substring(o,a.length);const v=p.find((t=>t>r));this.value=i.mask(h,e,n),s.setSelectionRange(v,v);const m=p.findIndex((t=>t>=v));this.validate(t.data,d[m<0?p.length-1:m-1])}}}else{const t=f.find((t=>t<=c-1)),h=f.find((t=>t<=l-1)),r=p.findIndex((s=>s===t)),o=p.findIndex((t=>t===h)),d=i.unmask(a,e,n);if(r<o){const t=d.substring(0,r+1)+d.substring(o+1,a.length);this.value=i.mask(t,e,n),t&&r>-1?s.setSelectionRange(u+1,u+1):s.setSelectionRange(u,u)}else{const t=d.substring(0,r)+d.substring(o+1,a.length);this.value=i.mask(t,e,n),s.setSelectionRange(u,u)}}}else this.value=a}validate(t,s){const{previousValue:i,input:e,value:n,selectionStart:r}=this;h.exists(s)&&!(s.test(t)||/\(\?[!<=]/.test(s.toString())&&s.test(n))&&(this.value=i,e.setSelectionRange(r,r))}componentWillLoad(){this.input=document.getElementById(this.for),h.exists(this.input)?(this.input.addEventListener("focus",this.handleFocus),this.input.addEventListener("keydown",this.handleKeyDown),this.input.addEventListener("input",this.handleInput),this.input.addEventListener("touchstart",this.handleTouchStart)):console.error("ku4-mask must have a valid `for` referencing target field `id`.")}disconnectedCallback(){this.input&&this.input.removeEventListener&&(this.input.removeEventListener("focus",this.handleFocus),this.input.removeEventListener("keydown",this.handleKeyDown),this.input.removeEventListener("input",this.handleInput),this.input.removeEventListener("touchstart",this.handleTouchStart))}render(){return s("slot",null)}static get watchers(){return{template:["templateHandler"],char:["charHandler"]}}};n.style=":host{display:none}";export{n as ku4_mask}
|