ku4web-components 6.4.50 → 6.4.51

Sign up to get free protection for your applications and to get access to all the features.
@@ -57,7 +57,15 @@ let Ku4Form = class {
57
57
  */
58
58
  async write(data) {
59
59
  index$2.index.write(this.form, data);
60
- Object.keys(data).forEach(name => this.form.querySelector(`[name="${name}"]`).dispatchEvent(new Event('change')));
60
+ Object.keys(data).forEach((name) => {
61
+ try {
62
+ this.form.querySelector(`[name="${name}"]`)
63
+ .dispatchEvent(new Event('change'));
64
+ }
65
+ catch (e) {
66
+ /* Fail silently */
67
+ }
68
+ });
61
69
  return this;
62
70
  }
63
71
  get form() {
@@ -296,7 +296,7 @@ let Ku4Mask = class {
296
296
  this.input.addEventListener('blur', this.handleBlur);
297
297
  this.input.addEventListener('keydown', this.handleKeyDown);
298
298
  this.input.addEventListener('input', this.handleInput);
299
- this.input.addEventListener('touchstart', this.handleTouchStart);
299
+ this.input.addEventListener('touchstart', this.handleTouchStart, { passive: true });
300
300
  }
301
301
  else {
302
302
  // eslint-disable-next-line no-console
@@ -53,7 +53,15 @@ let Ku4Form = class {
53
53
  */
54
54
  async write(data) {
55
55
  index.write(this.form, data);
56
- Object.keys(data).forEach(name => this.form.querySelector(`[name="${name}"]`).dispatchEvent(new Event('change')));
56
+ Object.keys(data).forEach((name) => {
57
+ try {
58
+ this.form.querySelector(`[name="${name}"]`)
59
+ .dispatchEvent(new Event('change'));
60
+ }
61
+ catch (e) {
62
+ /* Fail silently */
63
+ }
64
+ });
57
65
  return this;
58
66
  }
59
67
  get form() {
@@ -292,7 +292,7 @@ let Ku4Mask = class {
292
292
  this.input.addEventListener('blur', this.handleBlur);
293
293
  this.input.addEventListener('keydown', this.handleKeyDown);
294
294
  this.input.addEventListener('input', this.handleInput);
295
- this.input.addEventListener('touchstart', this.handleTouchStart);
295
+ this.input.addEventListener('touchstart', this.handleTouchStart, { passive: true });
296
296
  }
297
297
  else {
298
298
  // eslint-disable-next-line no-console
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function a(t){try{u(r.next(t))}catch(e){o(e)}}function s(t){try{u(r["throw"](t))}catch(e){o(e)}}function u(t){t.done?n(t.value):i(t.value).then(a,s)}u((r=r.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(t){return function(e){return u([t,e])}}function u(a){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,i&&(o=a[0]&2?i["return"]:a[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;i=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1];o=a;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(a);break}if(o[2])n.ops.pop();n.trys.pop();continue}a=e.call(t,n)}catch(s){a=[6,s];i=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,h,g as getElement}from"./index-fe3424be.js";import{t}from"./index-20c3926d.js";import{i as index}from"./index-a39e08fb.js";var Ku4Form=function(){function e(t){registerInstance(this,t);this.validate=this.validate.bind(this);this.handleReset=this.handleReset.bind(this)}e.prototype.validate=function(){return __awaiter(this,void 0,void 0,(function(){var t,e,n;return __generator(this,(function(r){switch(r.label){case 0:t=this.fields;e=t.map((function(t){return t.validate()}));n=this;return[4,Promise.all(e).then((function(t){return!t.some((function(t){return t===false}))}))];case 1:n.isValid=r.sent();this.invalid=!this.isValid;return[2,this.isValid]}}))}))};e.prototype.invalidate=function(e){return __awaiter(this,void 0,void 0,(function(){var n;var r=this;return __generator(this,(function(i){if(t.isArray(e)){e.forEach((function(t){var e=r.fields.find((function(e){return e.for===t}));if(e){e.invalid=true}}))}else{n=this.fields.find((function(t){return t.for===e}));if(n){n.invalid=true}}this.invalid=true;return[2,this]}))}))};e.prototype.read=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,index.read(this.form)]}))}))};e.prototype.write=function(t){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(n){index.write(this.form,t);Object.keys(t).forEach((function(t){return e.form.querySelector('[name="'+t+'"]').dispatchEvent(new Event("change"))}));return[2,this]}))}))};Object.defineProperty(e.prototype,"form",{get:function(){return this.host.querySelector("form")},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"fields",{get:function(){return[].slice.call(this.form.querySelectorAll("ku4-validation"))},enumerable:false,configurable:true});e.prototype.handleReset=function(){this.isValid=true;this.invalid=!this.isValid};e.prototype.componentWillLoad=function(){var e=this;var n=this.form;if(t.exists(n)){var r=n.onsubmit||function(){};n.onsubmit=function(i){i.preventDefault();e.validate().then((function(t){return t&&r.call(n,i)})).then((function(e){return!t.isFalse(e)&&n.submit()}));return false};n.addEventListener("reset",this.handleReset);this.fields.forEach((function(t){return t.addEventListener("validated",e.validate)}))}};e.prototype.disconnectedCallback=function(){var e=this;var n=this.form;if(t.exists(n)){n.removeEventListener("reset",this.handleReset);this.fields.forEach((function(t){return t.removeEventListener("validated",e.validate)}))}};e.prototype.render=function(){return h("slot",null)};Object.defineProperty(e.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();export{Ku4Form as ku4_form};
1
+ var __awaiter=this&&this.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function a(t){try{u(r.next(t))}catch(e){o(e)}}function s(t){try{u(r["throw"](t))}catch(e){o(e)}}function u(t){t.done?n(t.value):i(t.value).then(a,s)}u((r=r.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(t){return function(e){return u([t,e])}}function u(a){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,i&&(o=a[0]&2?i["return"]:a[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;i=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1];o=a;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(a);break}if(o[2])n.ops.pop();n.trys.pop();continue}a=e.call(t,n)}catch(s){a=[6,s];i=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,h,g as getElement}from"./index-fe3424be.js";import{t}from"./index-20c3926d.js";import{i as index}from"./index-a39e08fb.js";var Ku4Form=function(){function e(t){registerInstance(this,t);this.validate=this.validate.bind(this);this.handleReset=this.handleReset.bind(this)}e.prototype.validate=function(){return __awaiter(this,void 0,void 0,(function(){var t,e,n;return __generator(this,(function(r){switch(r.label){case 0:t=this.fields;e=t.map((function(t){return t.validate()}));n=this;return[4,Promise.all(e).then((function(t){return!t.some((function(t){return t===false}))}))];case 1:n.isValid=r.sent();this.invalid=!this.isValid;return[2,this.isValid]}}))}))};e.prototype.invalidate=function(e){return __awaiter(this,void 0,void 0,(function(){var n;var r=this;return __generator(this,(function(i){if(t.isArray(e)){e.forEach((function(t){var e=r.fields.find((function(e){return e.for===t}));if(e){e.invalid=true}}))}else{n=this.fields.find((function(t){return t.for===e}));if(n){n.invalid=true}}this.invalid=true;return[2,this]}))}))};e.prototype.read=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,index.read(this.form)]}))}))};e.prototype.write=function(t){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(n){index.write(this.form,t);Object.keys(t).forEach((function(t){try{e.form.querySelector('[name="'+t+'"]').dispatchEvent(new Event("change"))}catch(n){}}));return[2,this]}))}))};Object.defineProperty(e.prototype,"form",{get:function(){return this.host.querySelector("form")},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"fields",{get:function(){return[].slice.call(this.form.querySelectorAll("ku4-validation"))},enumerable:false,configurable:true});e.prototype.handleReset=function(){this.isValid=true;this.invalid=!this.isValid};e.prototype.componentWillLoad=function(){var e=this;var n=this.form;if(t.exists(n)){var r=n.onsubmit||function(){};n.onsubmit=function(i){i.preventDefault();e.validate().then((function(t){return t&&r.call(n,i)})).then((function(e){return!t.isFalse(e)&&n.submit()}));return false};n.addEventListener("reset",this.handleReset);this.fields.forEach((function(t){return t.addEventListener("validated",e.validate)}))}};e.prototype.disconnectedCallback=function(){var e=this;var n=this.form;if(t.exists(n)){n.removeEventListener("reset",this.handleReset);this.fields.forEach((function(t){return t.removeEventListener("validated",e.validate)}))}};e.prototype.render=function(){return h("slot",null)};Object.defineProperty(e.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();export{Ku4Form as ku4_form};
@@ -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-fe3424be.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"&&e.inputType!=="deleteByCut"&&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"||e.inputType==="deleteByCut"){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 T=o;if(d<c){var L=g.find((function(t){return t<=d-1}));var B=g.find((function(t){return t<=c-1}));var k=f.findIndex((function(t){return t===L}));var b=f.findIndex((function(t){return t===B}));var V=a.unmask(o,s,u);var I=V.substring(0,k+1)+V.substring(b+1,o.length);T=a.mask(I,s,u)}var F=f.find((function(t){return t>=d}));var w=f.findIndex((function(t){return t===F}));var x=a.unmask(T,s,u);T=x.substring(0,w)+e.data+x.substring(w,o.length);var M=f.find((function(t){return t>F}));this.value=a.mask(T,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
+ 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-fe3424be.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"&&e.inputType!=="deleteByCut"&&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"||e.inputType==="deleteByCut"){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 T=o;if(d<c){var L=g.find((function(t){return t<=d-1}));var B=g.find((function(t){return t<=c-1}));var k=f.findIndex((function(t){return t===L}));var b=f.findIndex((function(t){return t===B}));var V=a.unmask(o,s,u);var I=V.substring(0,k+1)+V.substring(b+1,o.length);T=a.mask(I,s,u)}var F=f.find((function(t){return t>=d}));var w=f.findIndex((function(t){return t===F}));var x=a.unmask(T,s,u);T=x.substring(0,w)+e.data+x.substring(w,o.length);var M=f.find((function(t){return t>F}));this.value=a.mask(T,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,{passive:true})}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-c4cf99d8.js";(()=>{const o=Array.from(e.querySelectorAll("script")).find((e=>new RegExp(`/${t}(\\.esm)?\\.js($|\\?|#)`).test(e.src)||e.getAttribute("data-stencil-namespace")===t)),d={};return"onbeforeload"in o&&!history.scrollRestoration?{then(){}}:(d.resourcesUrl=new URL(".",new URL(o.getAttribute("data-resources-url")||o.src,s.location.href)).href,a(d))})().then((e=>o([["p-c5027727",[[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-ed89c024",[[1,"ku4-carousel-controls",{for:[1]}]]],["p-ef15df08",[[1,"ku4-carousel-slide",{active:[32],classList:[32],slideIn:[64],slideOut:[64],activate:[64],deactivate:[64]}]]],["p-7d8bdc7c",[[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-427c9b42",[[1,"ku4-drawer",{bottom:[516],left:[516],right:[516],top:[516],size:[1],open:[1540],toggle:[64]}]]],["p-1159d944",[[1,"ku4-feature",{on:[4],policy:[1],enabled:[32]}]]],["p-d587f83c",[[1,"ku4-focus-trap",{active:[1540],include:[1],exclude:[1],excludeShadow:[1,"exclude-shadow"],initial:[1],return:[1],activate:[64],deactivate:[64]}]]],["p-49cffed7",[[4,"ku4-form",{invalid:[1540],validate:[64],invalidate:[64],read:[64],write:[64]}]]],["p-67b6fa5d",[[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-877dcd7e",[[1,"ku4-label",{for:[1],value:[1],empty:[32]}]]],["p-0097c412",[[1,"ku4-mask",{for:[1],template:[1],ban:[1],pattern:[1],char:[1],hidden:[4]}]]],["p-439260fd",[[1,"ku4-modal",{visible:[1540],focusTrap:[1,"focus-trap"],display:[64],dismiss:[64]},[[8,"keyup","handleKeyUp"]]]]],["p-672c7fcf",[[1,"ku4-panel",{open:[1540],maxHeight:[32],toggle:[64],close:[64]},[[0,"transitionend","handleTransitionEnd"]]]]],["p-9d5ed8ad",[[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-71e8a6a7",[[1,"ku4-tab",{selected:[1540],panel:[32],select:[64],deselect:[64],connect:[64]},[[0,"click","handleClick"],[0,"keyup","handleKeyUp"]]]]],["p-499c1d7b",[[1,"ku4-tab-list",{open:[64]},[[0,"ku4TabClick","handleHpTabClick"],[0,"ku4TabKeyup","handleHpTabKeyUp"]]]]],["p-70416bfc",[[1,"ku4-tab-panel",{selected:[1540],maxHeight:[32],tab:[32],select:[64],deselect:[64],connect:[64]},[[0,"transitionend","handleTransitionEnd"]]]]],["p-9def145d",[[4,"ku4-table",{stackXs:[1537,"stack-xs"],stackSm:[1537,"stack-sm"]}]]],["p-d92776d8",[[1,"ku4-tooltip",{element:[1],top:[4],left:[4],bottom:[4],right:[4],debug:[4],show:[64],hide:[64]}]]],["p-6ac96851",[[1,"ku4-validation",{for:[1],element:[1],pattern:[1],flags:[1],values:[1],checked:[4],method:[1],invalid:[1540],disabled:[1540],hidden:[1540],isValid:[32],validate:[64]}]]]],e)));
1
+ import{d as e,N as t,w as s,p as a,b as o}from"./p-c4cf99d8.js";(()=>{const o=Array.from(e.querySelectorAll("script")).find((e=>new RegExp(`/${t}(\\.esm)?\\.js($|\\?|#)`).test(e.src)||e.getAttribute("data-stencil-namespace")===t)),d={};return"onbeforeload"in o&&!history.scrollRestoration?{then(){}}:(d.resourcesUrl=new URL(".",new URL(o.getAttribute("data-resources-url")||o.src,s.location.href)).href,a(d))})().then((e=>o([["p-c5027727",[[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-ed89c024",[[1,"ku4-carousel-controls",{for:[1]}]]],["p-ef15df08",[[1,"ku4-carousel-slide",{active:[32],classList:[32],slideIn:[64],slideOut:[64],activate:[64],deactivate:[64]}]]],["p-7d8bdc7c",[[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-427c9b42",[[1,"ku4-drawer",{bottom:[516],left:[516],right:[516],top:[516],size:[1],open:[1540],toggle:[64]}]]],["p-1159d944",[[1,"ku4-feature",{on:[4],policy:[1],enabled:[32]}]]],["p-d587f83c",[[1,"ku4-focus-trap",{active:[1540],include:[1],exclude:[1],excludeShadow:[1,"exclude-shadow"],initial:[1],return:[1],activate:[64],deactivate:[64]}]]],["p-b80b774e",[[4,"ku4-form",{invalid:[1540],validate:[64],invalidate:[64],read:[64],write:[64]}]]],["p-67b6fa5d",[[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-877dcd7e",[[1,"ku4-label",{for:[1],value:[1],empty:[32]}]]],["p-4f874efa",[[1,"ku4-mask",{for:[1],template:[1],ban:[1],pattern:[1],char:[1],hidden:[4]}]]],["p-439260fd",[[1,"ku4-modal",{visible:[1540],focusTrap:[1,"focus-trap"],display:[64],dismiss:[64]},[[8,"keyup","handleKeyUp"]]]]],["p-672c7fcf",[[1,"ku4-panel",{open:[1540],maxHeight:[32],toggle:[64],close:[64]},[[0,"transitionend","handleTransitionEnd"]]]]],["p-9d5ed8ad",[[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-71e8a6a7",[[1,"ku4-tab",{selected:[1540],panel:[32],select:[64],deselect:[64],connect:[64]},[[0,"click","handleClick"],[0,"keyup","handleKeyUp"]]]]],["p-499c1d7b",[[1,"ku4-tab-list",{open:[64]},[[0,"ku4TabClick","handleHpTabClick"],[0,"ku4TabKeyup","handleHpTabKeyUp"]]]]],["p-70416bfc",[[1,"ku4-tab-panel",{selected:[1540],maxHeight:[32],tab:[32],select:[64],deselect:[64],connect:[64]},[[0,"transitionend","handleTransitionEnd"]]]]],["p-9def145d",[[4,"ku4-table",{stackXs:[1537,"stack-xs"],stackSm:[1537,"stack-sm"]}]]],["p-d92776d8",[[1,"ku4-tooltip",{element:[1],top:[4],left:[4],bottom:[4],right:[4],debug:[4],show:[64],hide:[64]}]]],["p-6ac96851",[[1,"ku4-validation",{for:[1],element:[1],pattern:[1],flags:[1],values:[1],checked:[4],method:[1],invalid:[1540],disabled:[1540],hidden:[1540],isValid:[32],validate:[64]}]]]],e)));
@@ -1 +1 @@
1
- import{r as t,h as s}from"./p-c4cf99d8.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.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: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}))}handleBlur(){const{template:t,char:s}=this;h.isEmpty(i.unmask(this.value,t,s))&&(this.value="")}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||"deleteByCut"===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&&"deleteByCut"!==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("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}
1
+ import{r as t,h as s}from"./p-c4cf99d8.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.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: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}))}handleBlur(){const{template:t,char:s}=this;h.isEmpty(i.unmask(this.value,t,s))&&(this.value="")}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||"deleteByCut"===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&&"deleteByCut"!==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("blur",this.handleBlur),this.input.addEventListener("keydown",this.handleKeyDown),this.input.addEventListener("input",this.handleInput),this.input.addEventListener("touchstart",this.handleTouchStart,{passive:!0})):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}
@@ -1 +1 @@
1
- System.register(["./p-0207cb44.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-361a6c0c.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-276972a6.system",[[1,"ku4-carousel-controls",{for:[1]}]]],["p-b498029c.system",[[1,"ku4-carousel-slide",{active:[32],classList:[32],slideIn:[64],slideOut:[64],activate:[64],deactivate:[64]}]]],["p-65c78087.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-47373702.system",[[1,"ku4-drawer",{bottom:[516],left:[516],right:[516],top:[516],size:[1],open:[1540],toggle:[64]}]]],["p-0eaea039.system",[[1,"ku4-feature",{on:[4],policy:[1],enabled:[32]}]]],["p-9100e5d3.system",[[1,"ku4-focus-trap",{active:[1540],include:[1],exclude:[1],excludeShadow:[1,"exclude-shadow"],initial:[1],return:[1],activate:[64],deactivate:[64]}]]],["p-93972ad5.system",[[4,"ku4-form",{invalid:[1540],validate:[64],invalidate:[64],read:[64],write:[64]}]]],["p-a76949aa.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-d8a87f87.system",[[1,"ku4-label",{for:[1],value:[1],empty:[32]}]]],["p-0d977a97.system",[[1,"ku4-mask",{for:[1],template:[1],ban:[1],pattern:[1],char:[1],hidden:[4]}]]],["p-8480fc4b.system",[[1,"ku4-modal",{visible:[1540],focusTrap:[1,"focus-trap"],display:[64],dismiss:[64]},[[8,"keyup","handleKeyUp"]]]]],["p-b5dd0acc.system",[[1,"ku4-panel",{open:[1540],maxHeight:[32],toggle:[64],close:[64]},[[0,"transitionend","handleTransitionEnd"]]]]],["p-ff344008.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-87f49411.system",[[1,"ku4-tab",{selected:[1540],panel:[32],select:[64],deselect:[64],connect:[64]},[[0,"click","handleClick"],[0,"keyup","handleKeyUp"]]]]],["p-4eba8303.system",[[1,"ku4-tab-list",{open:[64]},[[0,"ku4TabClick","handleHpTabClick"],[0,"ku4TabKeyup","handleHpTabKeyUp"]]]]],["p-9ab5c68b.system",[[1,"ku4-tab-panel",{selected:[1540],maxHeight:[32],tab:[32],select:[64],deselect:[64],connect:[64]},[[0,"transitionend","handleTransitionEnd"]]]]],["p-9c0e57e7.system",[[4,"ku4-table",{stackXs:[1537,"stack-xs"],stackSm:[1537,"stack-sm"]}]]],["p-6baef622.system",[[1,"ku4-tooltip",{element:[1],top:[4],left:[4],bottom:[4],right:[4],debug:[4],show:[64],hide:[64]}]]],["p-9d2053c8.system",[[1,"ku4-validation",{for:[1],element:[1],pattern:[1],flags:[1],values:[1],checked:[4],method:[1],invalid:[1540],disabled:[1540],hidden:[1540],isValid:[32],validate:[64]}]]]],e)}))}}}));
1
+ System.register(["./p-0207cb44.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-361a6c0c.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-276972a6.system",[[1,"ku4-carousel-controls",{for:[1]}]]],["p-b498029c.system",[[1,"ku4-carousel-slide",{active:[32],classList:[32],slideIn:[64],slideOut:[64],activate:[64],deactivate:[64]}]]],["p-65c78087.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-47373702.system",[[1,"ku4-drawer",{bottom:[516],left:[516],right:[516],top:[516],size:[1],open:[1540],toggle:[64]}]]],["p-0eaea039.system",[[1,"ku4-feature",{on:[4],policy:[1],enabled:[32]}]]],["p-9100e5d3.system",[[1,"ku4-focus-trap",{active:[1540],include:[1],exclude:[1],excludeShadow:[1,"exclude-shadow"],initial:[1],return:[1],activate:[64],deactivate:[64]}]]],["p-bbd1ecb4.system",[[4,"ku4-form",{invalid:[1540],validate:[64],invalidate:[64],read:[64],write:[64]}]]],["p-a76949aa.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-d8a87f87.system",[[1,"ku4-label",{for:[1],value:[1],empty:[32]}]]],["p-8c56e4b4.system",[[1,"ku4-mask",{for:[1],template:[1],ban:[1],pattern:[1],char:[1],hidden:[4]}]]],["p-8480fc4b.system",[[1,"ku4-modal",{visible:[1540],focusTrap:[1,"focus-trap"],display:[64],dismiss:[64]},[[8,"keyup","handleKeyUp"]]]]],["p-b5dd0acc.system",[[1,"ku4-panel",{open:[1540],maxHeight:[32],toggle:[64],close:[64]},[[0,"transitionend","handleTransitionEnd"]]]]],["p-ff344008.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-87f49411.system",[[1,"ku4-tab",{selected:[1540],panel:[32],select:[64],deselect:[64],connect:[64]},[[0,"click","handleClick"],[0,"keyup","handleKeyUp"]]]]],["p-4eba8303.system",[[1,"ku4-tab-list",{open:[64]},[[0,"ku4TabClick","handleHpTabClick"],[0,"ku4TabKeyup","handleHpTabKeyUp"]]]]],["p-9ab5c68b.system",[[1,"ku4-tab-panel",{selected:[1540],maxHeight:[32],tab:[32],select:[64],deselect:[64],connect:[64]},[[0,"transitionend","handleTransitionEnd"]]]]],["p-9c0e57e7.system",[[4,"ku4-table",{stackXs:[1537,"stack-xs"],stackSm:[1537,"stack-sm"]}]]],["p-6baef622.system",[[1,"ku4-tooltip",{element:[1],top:[4],left:[4],bottom:[4],right:[4],debug:[4],show:[64],hide:[64]}]]],["p-9d2053c8.system",[[1,"ku4-validation",{for:[1],element:[1],pattern:[1],flags:[1],values:[1],checked:[4],method:[1],invalid:[1540],disabled:[1540],hidden:[1540],isValid:[32],validate:[64]}]]]],e)}))}}}));
@@ -1 +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-0207cb44.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"&&t.inputType!=="deleteByCut"&&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"||t.inputType==="deleteByCut"){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 T=C<0?f.length-1:C-1;this.validate(t.data,p[T])}else{var L=o;if(c<d){var K=g.find((function(t){return t<=c-1}));var B=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===B}));var V=r.unmask(o,s,u);var S=V.substring(0,b+1)+V.substring(k+1,o.length);L=r.mask(S,s,u)}var F=f.find((function(t){return t>=c}));var w=f.findIndex((function(t){return t===F}));var x=r.unmask(L,s,u);L=x.substring(0,w)+t.data+x.substring(w,o.length);var _=f.find((function(t){return t>F}));this.value=r.mask(L,s,u);i.setSelectionRange(_,_);var C=f.findIndex((function(t){return t>=_}));var T=C<0?f.length-1:C-1;this.validate(t.data,p[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("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
+ 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-0207cb44.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"&&t.inputType!=="deleteByCut"&&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"||t.inputType==="deleteByCut"){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 T=C<0?f.length-1:C-1;this.validate(t.data,p[T])}else{var L=o;if(c<d){var K=g.find((function(t){return t<=c-1}));var B=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===B}));var V=r.unmask(o,s,u);var S=V.substring(0,b+1)+V.substring(k+1,o.length);L=r.mask(S,s,u)}var F=f.find((function(t){return t>=c}));var w=f.findIndex((function(t){return t===F}));var x=r.unmask(L,s,u);L=x.substring(0,w)+t.data+x.substring(w,o.length);var _=f.find((function(t){return t>F}));this.value=r.mask(L,s,u);i.setSelectionRange(_,_);var C=f.findIndex((function(t){return t>=_}));var T=C<0?f.length-1:C-1;this.validate(t.data,p[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("blur",this.handleBlur);this.input.addEventListener("keydown",this.handleKeyDown);this.input.addEventListener("input",this.handleInput);this.input.addEventListener("touchstart",this.handleTouchStart,{passive:true})}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}}}));
@@ -0,0 +1 @@
1
+ import{r as t,h as s,g as i}from"./p-c4cf99d8.js";import{t as e}from"./p-c1068ffa.js";import{i as h}from"./p-08ec498e.js";let r=class{constructor(s){t(this,s),this.validate=this.validate.bind(this),this.handleReset=this.handleReset.bind(this)}async validate(){const{fields:t}=this,s=t.map((t=>t.validate()));return this.isValid=await Promise.all(s).then((t=>!t.some((t=>!1===t)))),this.invalid=!this.isValid,this.isValid}async invalidate(t){if(e.isArray(t))t.forEach((t=>{const s=this.fields.find((s=>s.for===t));s&&(s.invalid=!0)}));else{const s=this.fields.find((s=>s.for===t));s&&(s.invalid=!0)}return this.invalid=!0,this}async read(){return h.read(this.form)}async write(t){return h.write(this.form,t),Object.keys(t).forEach((t=>{try{this.form.querySelector(`[name="${t}"]`).dispatchEvent(new Event("change"))}catch(s){}})),this}get form(){return this.host.querySelector("form")}get fields(){return[].slice.call(this.form.querySelectorAll("ku4-validation"))}handleReset(){this.isValid=!0,this.invalid=!this.isValid}componentWillLoad(){const{form:t}=this;if(e.exists(t)){const s=t.onsubmit||(()=>{});t.onsubmit=i=>(i.preventDefault(),this.validate().then((e=>e&&s.call(t,i))).then((s=>!e.isFalse(s)&&t.submit())),!1),t.addEventListener("reset",this.handleReset),this.fields.forEach((t=>t.addEventListener("validated",this.validate)))}}disconnectedCallback(){const{form:t}=this;e.exists(t)&&(t.removeEventListener("reset",this.handleReset),this.fields.forEach((t=>t.removeEventListener("validated",this.validate))))}render(){return s("slot",null)}get host(){return i(this)}};export{r as ku4_form}
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function a(t){try{s(r.next(t))}catch(e){o(e)}}function u(t){try{s(r["throw"](t))}catch(e){o(e)}}function s(t){t.done?n(t.value):i(t.value).then(a,u)}s((r=r.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(t){return function(e){return s([t,e])}}function s(a){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,i&&(o=a[0]&2?i["return"]:a[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;i=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1];o=a;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(a);break}if(o[2])n.ops.pop();n.trys.pop();continue}a=e.call(t,n)}catch(u){a=[6,u];i=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./p-0207cb44.system.js","./p-0785fc39.system.js","./p-52147373.system.js"],(function(t){"use strict";var e,n,r,i,o;return{setters:[function(t){e=t.r;n=t.h;r=t.g},function(t){i=t.t},function(t){o=t.i}],execute:function(){var a=t("ku4_form",function(){function t(t){e(this,t);this.validate=this.validate.bind(this);this.handleReset=this.handleReset.bind(this)}t.prototype.validate=function(){return __awaiter(this,void 0,void 0,(function(){var t,e,n;return __generator(this,(function(r){switch(r.label){case 0:t=this.fields;e=t.map((function(t){return t.validate()}));n=this;return[4,Promise.all(e).then((function(t){return!t.some((function(t){return t===false}))}))];case 1:n.isValid=r.sent();this.invalid=!this.isValid;return[2,this.isValid]}}))}))};t.prototype.invalidate=function(t){return __awaiter(this,void 0,void 0,(function(){var e;var n=this;return __generator(this,(function(r){if(i.isArray(t)){t.forEach((function(t){var e=n.fields.find((function(e){return e.for===t}));if(e){e.invalid=true}}))}else{e=this.fields.find((function(e){return e.for===t}));if(e){e.invalid=true}}this.invalid=true;return[2,this]}))}))};t.prototype.read=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,o.read(this.form)]}))}))};t.prototype.write=function(t){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(n){o.write(this.form,t);Object.keys(t).forEach((function(t){return e.form.querySelector('[name="'+t+'"]').dispatchEvent(new Event("change"))}));return[2,this]}))}))};Object.defineProperty(t.prototype,"form",{get:function(){return this.host.querySelector("form")},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"fields",{get:function(){return[].slice.call(this.form.querySelectorAll("ku4-validation"))},enumerable:false,configurable:true});t.prototype.handleReset=function(){this.isValid=true;this.invalid=!this.isValid};t.prototype.componentWillLoad=function(){var t=this;var e=this.form;if(i.exists(e)){var n=e.onsubmit||function(){};e.onsubmit=function(r){r.preventDefault();t.validate().then((function(t){return t&&n.call(e,r)})).then((function(t){return!i.isFalse(t)&&e.submit()}));return false};e.addEventListener("reset",this.handleReset);this.fields.forEach((function(e){return e.addEventListener("validated",t.validate)}))}};t.prototype.disconnectedCallback=function(){var t=this;var e=this.form;if(i.exists(e)){e.removeEventListener("reset",this.handleReset);this.fields.forEach((function(e){return e.removeEventListener("validated",t.validate)}))}};t.prototype.render=function(){return n("slot",null)};Object.defineProperty(t.prototype,"host",{get:function(){return r(this)},enumerable:false,configurable:true});return t}())}}}));
1
+ var __awaiter=this&&this.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function a(t){try{u(r.next(t))}catch(e){o(e)}}function s(t){try{u(r["throw"](t))}catch(e){o(e)}}function u(t){t.done?n(t.value):i(t.value).then(a,s)}u((r=r.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(t){return function(e){return u([t,e])}}function u(a){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,i&&(o=a[0]&2?i["return"]:a[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;i=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1];o=a;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(a);break}if(o[2])n.ops.pop();n.trys.pop();continue}a=e.call(t,n)}catch(s){a=[6,s];i=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./p-0207cb44.system.js","./p-0785fc39.system.js","./p-52147373.system.js"],(function(t){"use strict";var e,n,r,i,o;return{setters:[function(t){e=t.r;n=t.h;r=t.g},function(t){i=t.t},function(t){o=t.i}],execute:function(){var a=t("ku4_form",function(){function t(t){e(this,t);this.validate=this.validate.bind(this);this.handleReset=this.handleReset.bind(this)}t.prototype.validate=function(){return __awaiter(this,void 0,void 0,(function(){var t,e,n;return __generator(this,(function(r){switch(r.label){case 0:t=this.fields;e=t.map((function(t){return t.validate()}));n=this;return[4,Promise.all(e).then((function(t){return!t.some((function(t){return t===false}))}))];case 1:n.isValid=r.sent();this.invalid=!this.isValid;return[2,this.isValid]}}))}))};t.prototype.invalidate=function(t){return __awaiter(this,void 0,void 0,(function(){var e;var n=this;return __generator(this,(function(r){if(i.isArray(t)){t.forEach((function(t){var e=n.fields.find((function(e){return e.for===t}));if(e){e.invalid=true}}))}else{e=this.fields.find((function(e){return e.for===t}));if(e){e.invalid=true}}this.invalid=true;return[2,this]}))}))};t.prototype.read=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,o.read(this.form)]}))}))};t.prototype.write=function(t){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(n){o.write(this.form,t);Object.keys(t).forEach((function(t){try{e.form.querySelector('[name="'+t+'"]').dispatchEvent(new Event("change"))}catch(n){}}));return[2,this]}))}))};Object.defineProperty(t.prototype,"form",{get:function(){return this.host.querySelector("form")},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"fields",{get:function(){return[].slice.call(this.form.querySelectorAll("ku4-validation"))},enumerable:false,configurable:true});t.prototype.handleReset=function(){this.isValid=true;this.invalid=!this.isValid};t.prototype.componentWillLoad=function(){var t=this;var e=this.form;if(i.exists(e)){var n=e.onsubmit||function(){};e.onsubmit=function(r){r.preventDefault();t.validate().then((function(t){return t&&n.call(e,r)})).then((function(t){return!i.isFalse(t)&&e.submit()}));return false};e.addEventListener("reset",this.handleReset);this.fields.forEach((function(e){return e.addEventListener("validated",t.validate)}))}};t.prototype.disconnectedCallback=function(){var t=this;var e=this.form;if(i.exists(e)){e.removeEventListener("reset",this.handleReset);this.fields.forEach((function(e){return e.removeEventListener("validated",t.validate)}))}};t.prototype.render=function(){return n("slot",null)};Object.defineProperty(t.prototype,"host",{get:function(){return r(this)},enumerable:false,configurable:true});return t}())}}}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ku4web-components",
3
- "version": "6.4.50",
3
+ "version": "6.4.51",
4
4
  "description": "kodmunki™ Web Components",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.js",
@@ -54,28 +54,28 @@
54
54
  ],
55
55
  "devDependencies": {
56
56
  "@babel/core": "^7.13.10",
57
- "@jest/core": "^27.4.5",
57
+ "@jest/core": "^27.4.7",
58
58
  "@rollup/plugin-babel": "^5.3.0",
59
59
  "@rollup/plugin-commonjs": "^21.0.1",
60
- "@rollup/plugin-node-resolve": "^13.1.2",
60
+ "@rollup/plugin-node-resolve": "^13.1.3",
61
61
  "@stencil/core": "^2.12.1",
62
62
  "@stencil/eslint-plugin": "^0.4.0",
63
63
  "@stencil/sass": "^1.4.0",
64
- "@storybook/addon-actions": "^6.1.21",
65
- "@storybook/addon-docs": "^6.1.21",
64
+ "@storybook/addon-actions": "^6.4.13",
65
+ "@storybook/addon-docs": "^6.4.13",
66
66
  "@storybook/addon-google-analytics": "^6.1.21",
67
67
  "@storybook/addon-knobs": "^6.1.21",
68
- "@storybook/addon-links": "^6.1.21",
69
- "@storybook/addon-storyshots": "^6.1.21",
70
- "@storybook/addon-viewport": "^6.1.21",
71
- "@storybook/addons": "^6.1.21",
72
- "@storybook/react": "^6.1.21",
73
- "@storybook/theming": "^6.1.21",
74
- "@storybook/web-components": "^6.1.21",
68
+ "@storybook/addon-links": "^6.4.13",
69
+ "@storybook/addon-storyshots": "^6.4.13",
70
+ "@storybook/addon-viewport": "^6.4.13",
71
+ "@storybook/addons": "^6.4.13",
72
+ "@storybook/react": "^6.4.13",
73
+ "@storybook/theming": "^6.4.13",
74
+ "@storybook/web-components": "^6.4.13",
75
75
  "@types/node": "^17.0.7",
76
76
  "@types/puppeteer": "^5.4.3",
77
- "@typescript-eslint/eslint-plugin": "^5.9.0",
78
- "@typescript-eslint/parser": "^5.9.0",
77
+ "@typescript-eslint/eslint-plugin": "^5.9.1",
78
+ "@typescript-eslint/parser": "^5.9.1",
79
79
  "acorn": "^8.1.0",
80
80
  "babel-loader": "^8.2.1",
81
81
  "bufferutil": "^4.0.3",
@@ -86,8 +86,8 @@
86
86
  "eslint-plugin-react": "^7.21.5",
87
87
  "fibers": "^5.0.0",
88
88
  "html-to-react": "^1.4.7",
89
- "jest": "^27.4.5",
90
- "jest-cli": "^27.4.5",
89
+ "jest": "^27.4.7",
90
+ "jest-cli": "^27.4.7",
91
91
  "ku4es-kernel": "^8.3.11",
92
92
  "ku4es-ui-data": "^3.1.7",
93
93
  "ku4es-ui-kernel": "^8.0.1",
@@ -95,11 +95,11 @@
95
95
  "node-sass": "^5.0.0",
96
96
  "pre-commit": "^1.2.2",
97
97
  "puppeteer": "^13.0.1",
98
- "rollup": "^2.42.3",
98
+ "rollup": "^2.64.0",
99
99
  "rollup-plugin-cleanup": "^3.2.1",
100
100
  "rollup-plugin-terser": "^7.0.2",
101
- "sass": "^1.32.8",
102
- "sass-loader": "^10.1.1",
101
+ "sass": "^1.48.0",
102
+ "sass-loader": "^10.2.1",
103
103
  "style-loader": "^2.0.0",
104
104
  "ts-dedent": "^2.0.0",
105
105
  "typescript": "^4.2.3",
@@ -1 +0,0 @@
1
- import{r as t,h as s,g as i}from"./p-c4cf99d8.js";import{t as e}from"./p-c1068ffa.js";import{i as h}from"./p-08ec498e.js";let r=class{constructor(s){t(this,s),this.validate=this.validate.bind(this),this.handleReset=this.handleReset.bind(this)}async validate(){const{fields:t}=this,s=t.map((t=>t.validate()));return this.isValid=await Promise.all(s).then((t=>!t.some((t=>!1===t)))),this.invalid=!this.isValid,this.isValid}async invalidate(t){if(e.isArray(t))t.forEach((t=>{const s=this.fields.find((s=>s.for===t));s&&(s.invalid=!0)}));else{const s=this.fields.find((s=>s.for===t));s&&(s.invalid=!0)}return this.invalid=!0,this}async read(){return h.read(this.form)}async write(t){return h.write(this.form,t),Object.keys(t).forEach((t=>this.form.querySelector(`[name="${t}"]`).dispatchEvent(new Event("change")))),this}get form(){return this.host.querySelector("form")}get fields(){return[].slice.call(this.form.querySelectorAll("ku4-validation"))}handleReset(){this.isValid=!0,this.invalid=!this.isValid}componentWillLoad(){const{form:t}=this;if(e.exists(t)){const s=t.onsubmit||(()=>{});t.onsubmit=i=>(i.preventDefault(),this.validate().then((e=>e&&s.call(t,i))).then((s=>!e.isFalse(s)&&t.submit())),!1),t.addEventListener("reset",this.handleReset),this.fields.forEach((t=>t.addEventListener("validated",this.validate)))}}disconnectedCallback(){const{form:t}=this;e.exists(t)&&(t.removeEventListener("reset",this.handleReset),this.fields.forEach((t=>t.removeEventListener("validated",this.validate))))}render(){return s("slot",null)}get host(){return i(this)}};export{r as ku4_form}