@twobirds/microcomponents 0.0.46 → 0.0.50

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.
Files changed (100) hide show
  1. package/assets/Grandparent.css +13 -0
  2. package/assets/documentation/MC.md +380 -166
  3. package/assets/test.html +5 -1
  4. package/dist/MC.d.ts +1 -0
  5. package/dist/MC.d.ts.map +1 -1
  6. package/dist/MC.min.js +44 -0
  7. package/dist/MC.ts +65 -0
  8. package/dist/elements.min.js +1 -1
  9. package/dist/elements.ts +10 -10
  10. package/dist/formValues.d.ts +3 -2
  11. package/dist/formValues.d.ts.map +1 -1
  12. package/dist/formValues.ts +206 -203
  13. package/dist/formvValues.min.js +1 -1
  14. package/dist/helpers.d.ts +1 -0
  15. package/dist/helpers.d.ts.map +1 -1
  16. package/dist/helpers.ts +9 -0
  17. package/dist/microcomponents.min.js +1 -1
  18. package/dist/observables.d.ts +1 -1
  19. package/dist/observables.d.ts.map +1 -1
  20. package/dist/observables.min.js +1 -1
  21. package/dist/observables.ts +72 -33
  22. package/dist/selectors.min.js +1 -1
  23. package/dist/test.ts +14 -14
  24. package/package.json +1 -1
  25. package/public/Grandparent.css +13 -0
  26. package/public/Grandparent.js +338 -0
  27. package/public/MC.js +43 -0
  28. package/public/MC.js.map +1 -1
  29. package/public/MC.min.js +44 -0
  30. package/public/TestForm.css +47 -0
  31. package/public/TestForm.html +56 -0
  32. package/public/TestForm.js +56 -0
  33. package/public/TestForm.json +27 -0
  34. package/public/Testform.js +149 -0
  35. package/public/classes/MC.DC.html +13 -13
  36. package/public/classes/MC.MC.html +7 -7
  37. package/public/classes/MC.McBase.html +4 -4
  38. package/public/classes/MC.McEvent.html +13 -13
  39. package/public/documentation/MC.md +380 -166
  40. package/public/documentation/observe.md +317 -0
  41. package/public/elements.js +9 -9
  42. package/public/elements.js.map +1 -1
  43. package/public/elements.min.js +1 -1
  44. package/public/formValues.js +142 -133
  45. package/public/formValues.js.map +1 -1
  46. package/public/formvValues.min.js +1 -1
  47. package/public/functions/MC.addListener.html +1 -1
  48. package/public/functions/MC.removeListener.html +1 -1
  49. package/public/functions/elements.defineCE.html +1 -1
  50. package/public/functions/elements.getCE.html +1 -1
  51. package/public/functions/formValues.formValues.html +1 -1
  52. package/public/functions/observables.observe.html +1 -1
  53. package/public/functions/selectors._d.html +1 -1
  54. package/public/functions/selectors._t.html +1 -1
  55. package/public/helpers.js +8 -0
  56. package/public/helpers.js.map +1 -1
  57. package/public/interfaces/MC.HTMLMcElement.html +2 -2
  58. package/public/interfaces/selectors.DSelector.html +55 -55
  59. package/public/interfaces/selectors.TSelector.html +37 -37
  60. package/public/microcomponents.min.js +1 -1
  61. package/public/modules/MC.html +1 -1
  62. package/public/modules/elements.html +1 -1
  63. package/public/modules/formValues.html +1 -1
  64. package/public/modules/observables.html +1 -1
  65. package/public/modules/selectors.html +1 -1
  66. package/public/observables.js +39 -21
  67. package/public/observables.js.map +1 -1
  68. package/public/observables.min.js +1 -1
  69. package/public/selectors.min.js +1 -1
  70. package/public/src/MC.ts +65 -0
  71. package/public/src/elements.ts +10 -10
  72. package/public/src/formValues.ts +206 -203
  73. package/public/src/helpers.ts +9 -0
  74. package/public/src/observables.ts +72 -33
  75. package/public/src/test.ts +14 -14
  76. package/public/test/Grandparent.js +1 -0
  77. package/public/test/Testform.js +1 -0
  78. package/public/test.html +5 -1
  79. package/public/test.js +9 -11
  80. package/public/test.js.map +1 -1
  81. package/public/types/observables.Observable.html +1 -1
  82. package/public/types/selectors.selection.html +1 -1
  83. package/public/types/selectors.singleSelector.html +1 -1
  84. package/src/MC.ts +65 -0
  85. package/src/elements.ts +10 -10
  86. package/src/formValues.ts +206 -203
  87. package/src/helpers.ts +9 -0
  88. package/src/observables.ts +72 -33
  89. package/src/test/Child.ts +21 -0
  90. package/src/test/Grandchild.ts +21 -0
  91. package/src/test/Grandparent.css +11 -0
  92. package/src/test/Grandparent.ts +21 -0
  93. package/src/test/Greatgrandchild.ts +42 -0
  94. package/src/test/Parent.ts +21 -0
  95. package/src/test/Testform.css +47 -0
  96. package/src/test/Testform.html +56 -0
  97. package/src/test/Testform.json +27 -0
  98. package/src/test/Testform.ts +159 -0
  99. package/src/test.ts +14 -14
  100. package/webpack.config.js +135 -61
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.microcomponents=t():e.microcomponents=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return e&&e.constructor&&e.constructor===Object}function n(e){let t={};return[...Object.keys(e)].sort().forEach((a=>{r(e[a])?t[a]=n(e[a]):t[a]=e[a]})),t}function a(e,t=!0){let r={};return[...Object.getOwnPropertyNames(e)].forEach((t=>{if(e[t]&&e[t].constructor&&e[t].constructor===Object){const n=a(e[t],!1);for(const e in n)r[t+"."+e]=n[e]}else r[t]=e[t]})),t?n(r):r}function s(e,t){return JSON.stringify(a(e))===JSON.stringify(a(t))}function c(e,t={}){let r=e.constructor===String?e.split("."):e;if(t&&r[0]&&t[r[0]])return t[r[0]].constructor===Object&&r.length>1?c(r.splice(1),t[r[0]]):t[r[0]];console.warn("ns",r[0],"not in",t)}function o(e,t){var n=Array.from(arguments);if(n.length>2){for(;n.length>1;)n[0]=o(n[0],n[1]),n.splice(1,1);return n[0]}if("string"==typeof e)e.match(/\{[^\{\}]*\}/g)?.forEach((function(r){var n=c(r.substring(1,r.length-1),t);void 0!==n&&(e=e.replace(r,n))}));else if(r(e))switch(e.constructor){case Object:Object.keys(e).forEach((function(r){e.hasOwnProperty(r)&&(e[r]=o(e[r],t))}));break;case Array:e.forEach((function(r,n,a){a[n]=o(e[n],t)}))}return e}function i(e){return e.split("-").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join("")}function l(e,t){let r;return()=>{clearTimeout(r),r=setTimeout((function(){e(...arguments)}),t)}}function u(e){let t=document.createElement("template");return e=e.replace(/<([A-Za-z0-9\-]*)([^>\/]*)(\/>)/gi,"<$1$2></$1>"),t.innerHTML=e,t.content.normalize(),Array.from(t.content.childNodes)}e.r(t),e.d(t,{$d:()=>J,$t:()=>R,DC:()=>x,MC:()=>k,McBase:()=>j,McEvent:()=>d,addListener:()=>E,debounce:()=>l,deepEqual:()=>s,defineCE:()=>_,flattenObject:()=>a,formValues:()=>K,getCE:()=>N,htmlToElements:()=>u,isNativeObject:()=>r,kebabToPascal:()=>i,nameSpace:()=>c,observe:()=>P,parse:()=>o,removeListener:()=>v,sortObject:()=>n});var h=new Function("try {return this===window;}catch(e){ return false;}");let f=new Set;h()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>f.add(e)));class d{#e;#t=!1;#r=!1;constructor(e,t={},r="l"){this.#e=e,this.data=t,this.bubble=r}get type(){return this.#e}get stopped(){return this.#t}get immediateStopped(){return this.#r}stopPropagation(){this.#t=!0}stopImmediatePropagation(){this.stopPropagation(),this.#r=!0}}var p=new Function("try {return this===window;}catch(e){ return false;}");let b=new Set;function g(e,t){let r=[];return e.forEach((e=>{if(e&&e instanceof HTMLElement){const n=e?._mc;!t&&n?r=r.concat(Object.values(e._mc)):t&&n&&n[t]&&r.push(n[t])}})),r}function m(e,t,r=!0){let n=[];for(;e;){if(e._mc&&(t?t&&e._mc[t]&&n.push(e._mc[t]):n=n.concat(Object.values(e._mc)),r))return n;e=e.parentNode}return n}function y(e){return e&&e instanceof HTMLElement}function E(e,t,r,n=!1,a=!1){let s={once:!1};n&&(s.capture=n),a&&(s.once=a),e.addEventListener(t,r,s)}function v(e,t,r){e.removeEventListener(t,r)}function O(e,t,r={}){let n=e;if(!n._mc){let t=x?.debug;x.debug=!1,n._mc=new x(e),x.debug=t,delete n._mc._mc}const a=n._mc;return t.length&&!a[t]&&(a[t]=r,e instanceof HTMLElement&&e.setAttribute("_mc","")),r}function w(e,t){if(!t)return;const r=e?._mc||{};r&&r[t]&&delete r[t],!Object.keys(r).length&&e instanceof HTMLElement&&e.hasAttribute("_mc")&&e.removeAttribute("_mc")}function S(e,t,r={},n="l"){let a=e?._mc;if(!a)return;let s=t instanceof d?new d(t.type,t.data,"l"):new d(t,r,"l"),c="string"!=typeof t?t:new d(t,r,n);[...Object.values(a)].forEach((e=>{e?.trigger&&"function"==typeof e?.trigger&&e?.trigger(s)})),/[ud]/.test(c.bubble)&&A(e,c)}function A(e,t){/[ud]/.test(t.bubble)&&setTimeout((()=>{if(-1===t.bubble.indexOf("l")&&(t.bubble+="l"),t.bubble.indexOf("u")>-1){let r=m(e,"",!0)?.[0].target;r&&x.trigger(r,t)}t.bubble.indexOf("d")>-1&&new Set(e._mc.children().map((e=>e?.target))).forEach((e=>{e&&x.trigger(e,t)}))}),0)}p()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>b.add(e)));class j{#n;constructor(e,t=!1){var r;this.#n=new WeakRef(e||{}),(r=this).constructor!==x&&setTimeout((()=>{r.trigger("Init")}),0),function(e){if(!p()||e.constructor===x)return;const t=e.target;if(t instanceof HTMLElement){let r=e;Object.getOwnPropertyNames(r.constructor.prototype).filter((e=>/^on[A-Z]|one[A-Z]/.test(e)&&"function"==typeof r.constructor.prototype[e])).forEach((n=>{let a=/^one/.test(n),s=n.replace(/^on[e]{0,1}/,""),c=s.toLowerCase();a&&Object.defineProperty(e,"on"+s,{configurable:!0,enumerable:!1,writable:!0,value:e=>{r.constructor.prototype[n].bind(r)(e)}}),b.has("on"+c)&&E(t,c,(e=>{r.trigger(s,e)}),!1,a)}))}}(this)}get target(){return this.#n.deref()}}class k extends j{_mc={};constructor(e){super(e)}static trigger=S;trigger(e,t={},r="l"){let n=this;if(n.constructor===k||n.constructor===x){let a=e instanceof d?new d(e.type,e.data,"l"):new d(e,t,"l"),s="string"!=typeof e?e:new d(e,t,r);return[...Object.getOwnPropertyNames(n)].forEach((e=>{n[e]?.trigger&&"function"==typeof n[e]?.trigger&&n[e]?.trigger(a)})),void(/[ud]/.test(s.bubble)&&A(n.target,s))}if(n instanceof k||n instanceof x){const n=this,a="string"!=typeof e?e:new d(e,t,r),s="on"+a.type[0].toUpperCase()+a.type.slice(1);if(a.bubble.indexOf("l")>-1&&(a.immediateStopped||"function"!=typeof n[s]||(n[s](a),n.hasOwnProperty(s)&&delete n[s])),a.stopped||"l"===a.bubble)return n;/[ud]/.test(a.bubble)&&A(n.target,a)}}}class x extends j{_mc={};constructor(e,t=!1){super(e)}static add=O;static remove=w;static trigger=S;trigger(e,t={},r){k.prototype.trigger.call(this,e,t,r)}parent(e=""){let t=this.target;return y(t)?m(t.parentNode,e,!0):[]}ancestors(e=""){let t=this?.target;return y(t)?m(this.target.parentNode,e,!1):[]}children(e=""){let t=this?.target;if(!y(t))return[];const r=Math.random().toString().replace(".",""),n='[_mc]:not([temp_id="'+r+'"] [_mc] [_mc])';t.setAttribute("temp_id",r);const a=g([...t.querySelectorAll(n)],e);return t.removeAttribute("temp_id"),a}descendants(e=""){let t=this?.target;return y(t)?g([...t.querySelectorAll("*[_mc]")],e):[]}}class T extends HTMLElement{constructor(){super()}connectedCallback(){x.trigger(this,"Connected")}disconnectedCallback(){x.trigger(this,"Disconnected")}adoptedCallback(){x.trigger(this,"Adopted")}attributeChangedCallback(e,t,r){x.trigger(this,"AttributeChanged",{name:e,oldValue:t,newValue:r})}}function _(e,t,r=[]){if(customElements.get(e))return void console.warn(`IGNORED: Custom element "${e}" is already defined!`);if(!e.includes("-"))throw new Error('createCustomElement: tagName must contain at least one hyphen ("-").');let n=i(e);customElements.define(e,function(e,t){return Object.defineProperty(t,"name",{value:e})}(n,class extends T{instance;constructor(e){super();let r=new t(this,e);x.add(this,n,r)}static get observedAttributes(){return r}}))}function N(e){return customElements.get(e)}function C(e){return null!=e&&"object"==typeof e}function L(e){let t=new Set,r=/\{[^\{\}]*\}/g;return e.getAttributeNames().filter((t=>e.getAttribute(t)?.match(r))).forEach((n=>{new Set(e.getAttribute(n)?.match(r)).forEach((e=>t.add(e.replace(/[\{\}]/g,""))))})),[...e.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(r))).forEach((e=>{(e.nodeValue||"").match(r).forEach((e=>{t.add(e.replace(/[\{\}]/g,""))}))})),[...t].map((e=>e.replace(/[\{\}]/g,""))),[...t]}const M=[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement];class H extends x{data={};oldDisplay="";constructor(e){super(e);let t=this;L(e).forEach((e=>t.data[e]="")),P(t),t.#a(),delete t._mc}#a(){let e=this,t=e.target;t.getAttributeNames().filter((e=>t.getAttribute(e)?.match(/\{[^\{\}]*\}/g))).forEach((r=>{let n=new Set(t.getAttribute(r)?.match(/\{[^\{\}]*\}/g));var a;e.data.observe((a=t.getAttribute(r),e=>{let s=a;n.forEach((t=>{s=s.replace(t,e[t.replace(/[\{\}]/g,"")])})),t.setAttribute(r,s)}))})),[...t.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(/\{[^\{\}]*\}/g))).forEach((r=>{let n=new Set(r.nodeValue.match(/\{[^\{\}]*\}/g));var a;e.data.observe((a=r.nodeValue,s=>{let c=a;n.forEach((e=>{c=c.replace(e,s[e.replace(/[\{\}]/g,"")])})),Object.keys(s).some((e=>!!s[e]))&&(t.style.display=e.oldDisplay,delete e.oldDisplay),r.nodeValue=c})),e.oldDisplay=t.getAttribute("style)")||"",M.includes(t.constructor)||(t.style.display="none")}))}onData(e){let t=this,r={};Object.keys(e.data).forEach((n=>{t.data.hasOwnProperty(n)&&(r[n]=e.data[n])})),JSON.stringify(r)!==JSON.stringify(t.data)&&Object.assign(t.data,r)}}const P=(e,t)=>{(t?[t]:[...Object.getOwnPropertyNames(e)]).forEach((t=>{if("_"===t[0]||void 0===e?.[t])return;let r,n=e[t];if(!n.prototype)switch(typeof n){case"string":r=String;break;case"number":r=Number;break;case"boolean":r=Boolean;break;case"object":r=n instanceof Array?Array:Object;break;default:return}let c=class extends r{constructor(e){super(e),this.constructor.callbacks=[],C(e)&&Object.getOwnPropertyNames(e).forEach((t=>{this[t]=e[t]}))}observe(e){return this.constructor.callbacks.push(e),this}bind(e){const t=this;return C(t.valueOf())?(function(e){var t;(t=e,(t instanceof HTMLElement?[t]:[]).concat([...t.querySelectorAll("*")]).filter((e=>!!L(e).length))).forEach((e=>{e?._mc?._placeholders||x.add(e,"_placeholders",new H(e))}))}(e),this.constructor.callbacks.push((t=>{new x(e).descendants("_placeholders").forEach((e=>{e&&e.trigger("data",a(t))}))})),t.notify()):console.warn("IGNORED - cannot bind a non-Object to the dom, IS:",typeof t.valueOf(),t),this}notify(){let e=this,t=C(e.valueOf())&&e.valueOf()instanceof Array==0?structuredClone(Object.assign({},e)):e.valueOf();return e.constructor.callbacks.forEach((e=>{e(t)})),this}},o=new c(n);Object.defineProperty(e,t,{enumerable:!0,get(){if(C(o.valueOf())){let e=structuredClone(Object.assign({},o));setTimeout(l((function(){s(structuredClone(Object.assign({},o)),e)||o.notify()}),0),0)}return o},set(e){if(typeof e==typeof o.valueOf())if(C(o.valueOf())&&o.valueOf()instanceof Array==0){let t=structuredClone(Object.assign({},o));e=structuredClone(Object.assign({},e));let r=o.constructor?.hasFormHandler??!1,n=o.constructor.callbacks;o=new c(structuredClone(Object.assign({},e))),o.constructor.callbacks=r,o.constructor.callbacks=n,setTimeout(l((function(){s(structuredClone(Object.assign({},o)),t)||o.notify()}),0),0)}else{let t=o.valueOf(),r=o.constructor.callbacks;o=new c(e),o.constructor.callbacks=r,e!==t&&o.notify()}else console.warn("IGNORED - cannot change observable types, IS:",typeof o.valueOf(),o,"- CANNOT BECOME:",typeof e)}}),e[t]=n}))},$=e=>{let t=new Set;return e.forEach((e=>{(e=e.trim()).split(" ").forEach((e=>{""!==e&&t.add(e)}))})),Array.from(t)},B=e=>{let t=J("input,select,textarea",e).array,r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let a;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":a=new I(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"select":a=new D(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"textarea":a=new V(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r};class q{constructor(e){}}class I extends q{#s;#e;#c;constructor(e,t){super(e),this.#s=e,this.#e=e.type,this.#c=t}get val(){let e,t=this;switch(t.#e){case"radio":const r=J(`input[type="radio"][name="${this.#s.getAttribute("name")}"]`,this.#c).filter((e=>e.checked));return r.length?(e=r.array[0],e.value):"";case"checkbox":return t.#s.checked;default:return t.#s.value}return""}set val(e){let t=this;switch(t.#e){case"radio":const r=`input[type="radio"][name="${this.#s.getAttribute("name")}"]`,n=J(r,this.#c);if(!n.length)return;if(""===e)return void n.forEach((e=>{e.checked&&(e.checked=!1)}));const a=n.filter((t=>t.getAttribute("value")===e));if(!a.length)return;return void(a.array[0].checked=!0);case"checkbox":t.#s.checked=e;break;default:t.#s.value=e}}}class D extends q{#s;#o=!1;constructor(e){super(e),this.#s=e,this.#o="select-multiple"===e.type}get val(){const e=[];return J(this.#s.querySelectorAll("option")).filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#o?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,J(this.#s.querySelectorAll("option")).forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected",!0),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class V extends q{#s;constructor(e){super(e),this.#s=e}get val(){return this.#s.value}set val(e){this.#s.value=e}}class z{#i=new Set;get set(){return this.#i}get array(){return Array.from(this.#i)}set set(e){this.#i=e}get length(){return this.#i.size}constructor(e,t=document.body){if(new Set,!e)return this}$t(e){let t=new F;return this.#i.forEach((e=>{e._mc&&Object.values(e._mc).forEach((e=>{t.set.add(e)}))})),e&&t.filter((t=>t.nameSpace===e)),t}add(e,t){let r=this;return J(e,t).forEach((e=>{r.#i.add(e)})),r}addClass(...e){return e=$(e),this.forEach((t=>{t.classList.add(...e)})),this}after(e,t){let r=this,n=J(e,t);return n.length?(n.first().forEach((e=>{r.array.reverse().forEach((t=>{t.after(e)}))})),r):r}append(e,t){let r=this.array[0],n=J(e,t);return r&&n.forEach((e=>{r.append(e)})),this}appendTo(e,t){let r=J(e,t).array[0];return r&&this.forEach((e=>{r.append(e)})),this}attr(e,t){let r=this,n={};return r.length?arguments.length?"string"==typeof e?void 0===t?[...r.set][0].getAttribute(e):null===t?([...r.set].forEach((t=>{t.removeAttribute(e)})),r):("object"==typeof t&&(t=JSON.stringify(t)),[...r.set].forEach((r=>{r.setAttribute(e,t)})),r):"object"==typeof e?([...r.set].forEach((t=>{Object.keys(e).forEach((r=>{J(t).attr(r,e.key)}))})),r):r:(Array.from([...r.set][0].attributes).forEach((e=>{n[e.name]=e.value})),n):r}before(e,t){let r=this,n=J(e,t);return n.length?(n.first().forEach((e=>{r.forEach((t=>{t.before(e)}))})),r):r}children(e,t){let r=this,n=new Set;if(r.#i.forEach((e=>{Array.from(e.children).forEach((e=>{n.add(e)}))})),r=J([...n]),e){let n=J(e,t);r.filter((e=>n.has(e)))}return r}descendants(e,t){let r=this,n=new Set;if(r.#i.forEach((e=>{e.querySelectorAll("*").forEach((e=>{n.add(e)}))})),r=J([...n]),e){let n=J(e,t);r.filter((e=>n.has(e)))}return r}empty(){return this.filter((e=>!1))}first(e,t){let r=this,n=new Set,a=!1;return e&&(a=J(e,t)),r.#i.forEach((e=>{e.parentNode&&n.add(e.parentNode.children[0])})),r=J([...n]),e&&r.filter((e=>a.has(e))),r}has(e){return this.#i.has(e)}hasClass(...e){return e=$(e),this.every((e=>Array.from(e.classList).every((t=>e.contains(t)))))}html(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerHTML=e:(()=>{console.warn("Cannot access the .innerHTML of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerHTML}last(e,t){let r=this,n=new Set;if(r.#i.forEach((e=>{let t=e.parentNode?.children;t&&n.add(Array.from(t).at(-1))})),r=J([...n]),e){let n=J(e,t);r.filter((e=>n.has(e)))}return r}next(e,t){let r=this,n=new Set;if(r.#i.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)+1;a<r.length&&n.add(r.at(a))}})),r=J([...n]),e){let n=J(e,t);r.filter((e=>n.has(e)))}return r}normalize(){return this.#i.forEach((e=>{e.normalize()})),this}off(e,t){let r=e.indexOf(" ")>-1?e.split(" "):[e];return this.array.forEach((e=>{r.forEach((function(r){v(e,r,t)}))})),this}on(e,t,r=!1,n=!1){let a=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function c(){c.cb.apply(a,Array.from(arguments))}return c.cb=t,a.forEach((e=>{s.forEach((function(t){E(e,t,c,r,n)}))})),c}one(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){E(e,t,s,r,!0)}))})),s}parent(e,t){let r=this,n=new Set;if(r.#i.forEach((e=>{e.parentNode&&"HTML"!==e.parentNode.tagName&&n.add(e.parentNode)})),r=J([...n]),e){let n=J(e,t);r.filter((e=>n.has(e)))}return r}parents(e,t){let r=this,n=new Set;if(r.#i.forEach((e=>{let t=e;for(;t.parentNode&&"HTML"!==t.parentNode.tagName;)t=t.parentNode,n.add(t)})),r=J([...n]),e){let n=J(e,t);r.filter((e=>n.has(e)))}return r}prepend(e,t){let r=this.array[0],n=J(e,t);return r&&n.forEach((e=>{r.prepend(e)})),this}prev(e,t){let r=this,n=new Set;if(r.#i.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)-1;a>-1&&n.add(r.at(a))}})),r=J([...n]),e){let n=J(e,t);r.filter((e=>n.has(e)))}return r}removeClass(...e){return e=$(e),this.forEach((t=>{t.classList.remove(...e)})),this}text(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerText=e:(()=>{console.warn("Cannot access the .textContent of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerText??""}toggleClass(...e){return e=$(e),this.forEach((t=>{t.classList.toggle(...e)})),this}trigger(e,t={},r=!1,n=!1,a=!1){let s,c={bubbles:r,cancelable:n,composed:a},o=e.indexOf(" ")>-1?e.split(" "):[e];return this.#i.forEach((e=>{o.forEach((function(r){s=new Event(r,c),s.data=t,e.dispatchEvent(s)}))})),this}val(e,t){if(!this.length)return this;const r=this;let n,a=B(r.array[0]);var s;return e?null!=(s=e)&&"object"==typeof s?(Object.assign(a,e),n=r):"string"==typeof e&&(void 0===t?n=a[e]:(a[e]=t,n=r)):n=Object.assign({},a),n}values(e){const t=this;let r={};if(!t.length)return console.warn("no dom selection to search inputs in"),{};let n=B(t.array[0]);return Object.keys(n).forEach((e=>{r[e]=n[e]})),0===Object.keys(r).length&&console.warn("no inputs in this dom selection",t.array[0],r),e&&Object.keys(e).forEach((t=>{n.hasOwnProperty(t)&&(console.log("key found",t),n[t]=e[t])})),structuredClone(Object.assign(n))}at(e){return J(this.array.at(e))}concat(e){let t=this;return(e instanceof z?e.array:e).forEach((e=>{t.#i.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return this.#i=new Set(this.array.filter(e,t)),this}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e,0)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){return this.array.pop()}push(...e){return e.forEach((e=>{this.#i.add(e)})),this}shift(){let e=this,t=e.#i.size?e.array[0]:void 0;return t&&e.#i.delete(t),t}slice(e,t){return J(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array;return n.splice(e,t,...r),J(n)}}class F{#i=new Set;get set(){return this.#i}get array(){return Array.from(this.#i)}set set(e){this.#i=e}get length(){return this.#i.size}set length(e){}constructor(e,t=document.body){if(!e)return this;J(e,t).forEach((e=>{R(e).forEach((e=>{this.#i.add(e)}))}))}$d(e,t=document.body){let r=new z,n=new Set,a=!!e||!1,s=new Set;return a&&(s=J(e,t).set),this.#i.forEach((e=>{a&&!s.has(e._tg)||n.add(e._tg)})),r.set=n,r}children(e){let t=this,r=new Set;return t.#i.forEach((t=>{t.children(e).forEach((e=>{r.add(e)}))})),t.#i=r,t}descendants(e){let t=this,r=new Set;return t.#i.forEach((t=>{t.descendants(e).forEach((e=>{r.add(e)}))})),t.#i=r,t}first(e){let t=this,r=new Set;return t.#i.forEach((e=>{e.parent().children().$d().first().$t().forEach((e=>{r.add(e)}))})),t.#i=r,e&&t.filter((t=>t.nameSpace=e)),t}has(e){return this.#i.has(e)}last(e){let t=this,r=new Set;return t.#i.forEach((e=>{e.parent().children().$d().last().$t().forEach((e=>{r.add(e)}))})),t.#i=r,e&&t.filter((t=>t.nameSpace=e)),t}next(e){let t=this,r=new Set;return t.#i.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.nextElementSibling;)t=t.nextElementSibling,n.add(t);R([...n]).$d().first().$t().forEach((e=>{r.add(e)}))})),t.#i=r,e&&t.filter((t=>t.nameSpace=e)),t}ns(e){return this.filter((t=>t.nameSpace===e))}off(e,t){let r=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];return this.$d().array.forEach((e=>{r.forEach((function(r){v(e,`[TB]${r}`,t)}))})),this}on(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){E(e._tg,`[TB]${t}`,s,!1,r)}))})),s}one(e,t){let r=this,n=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(r,Array.from(arguments))}return a.cb=t,r.forEach((e=>{n.forEach((function(t){E(e._tg,`[TB]${t}`,a,!1,!0)}))})),a}parent(e){let t=this,r=new Set;return t.#i.forEach((t=>{t.parent(e).forEach((e=>{r.add(e)}))})),t.#i=r,t}parents(e){let t=this,r=new Set;return t.#i.forEach((t=>{t.parents(e).forEach((e=>{r.add(e)}))})),t.#i=r,t}prev(e){let t=this,r=new Set;return t.#i.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.previousElementSibling;)t=t.previousElementSibling,n.add(t);R([...n]).$d().last().$t().forEach((e=>{r.add(e)}))})),t.#i=r,e&&t.filter((t=>t.nameSpace=e)),t}trigger(e,t={},r="l"){return this.forEach((n=>{n.trigger(e,t,r)})),this}at(e){return R(this.array.at(e))}concat(e){let t=this;return e.forEach((e=>{t.#i.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return R(this.array.filter(e,t))}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){let e=this.array,t=e.pop();return this.#i=new Set(e),t}push(e){return this.#i.add(e),this}shift(){let e=this.array.shift();return this.#i.delete(e),e}slice(e,t){return R(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array.splice(e,t,...r);return R(n)}}const J=(e,t=document)=>{let r=new Set;return e instanceof Array?(e.forEach((e=>{J(e,t).forEach((e=>{r.add(e)}))})),new z([...r])):new z(e,t)},R=(e,t=document)=>J(e,t).$t();class G{constructor(e){}}class W extends G{#s;#e;#c;constructor(e,t){super(e),this.#s=e,this.#e=e.type,this.#c=t}get val(){let e,t=this;switch(t.#e){case"radio":const r=[...(this.#c||document).querySelectorAll(`input[type="radio"][name="${this.#s.getAttribute("name")}"]`)].filter((e=>e.checked));return r.length?(e=r?.[0],e.value):"";case"checkbox":return t.#s.checked;default:return t.#s.value}return""}set val(e){let t=this;switch(t.#e){case"radio":const r=[...(this.#c||document).querySelectorAll(`input[type="radio"][name="${this.#s.getAttribute("name")}"]`)];if(!r.length)return;if(""===e)return void r.forEach((e=>{e.checked&&(e.checked=!1)}));const n=r.filter((t=>t.getAttribute("value")===e));if(!n.length)return;return void((n?.[0]).checked=!0);case"checkbox":t.#s.checked=e;break;default:t.#s.value=e}}}class Z extends G{#s;#o=!1;constructor(e){super(e),this.#s=e,this.#o="select-multiple"===e.type}get val(){const e=[];return[...this.#s.querySelectorAll("option")].filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#o?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,[...this.#s.querySelectorAll("option")].forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected","selected"),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class U extends G{#s;constructor(e){super(e),this.#s=e}get val(){return this.#s.value}set val(e){this.#s.value=e}}const K=(e,t={},r,n)=>{let a=(e=>{let t=[...(e||document).querySelectorAll("input,select,textarea")],r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let a;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":a=new W(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"select":a=new Z(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"textarea":a=new U(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r})(e);function s(e){Object.keys(e).forEach((t=>{a.hasOwnProperty(t)&&e.hasOwnProperty(t)&&(a[t]=e[t])}))}if(Object.keys(t).length>0&&s(t),void 0!==n){let t=r[n];t.constructor?.hasFormHandler||(t.constructor.hasFormHandler=!0,t.observe(s)),r[n].observe((()=>{})),[...e.querySelectorAll("input, textarea, select")].forEach((e=>{E(e,"keyup",(()=>{r[n]=structuredClone(Object.assign(a))})),E(e,"change",(()=>{r[n]=structuredClone(Object.assign(a))})),e instanceof HTMLSelectElement&&E(e,"select",(()=>{r[n]=structuredClone(Object.assign(a))}))}))}return n?r[n]:Object.assign({},a)};return t})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.microcomponents=t():e.microcomponents=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return e&&e.constructor&&e.constructor===Object}function n(e){let t={};return[...Object.keys(e)].sort().forEach((a=>{r(e[a])?t[a]=n(e[a]):t[a]=e[a]})),t}function a(e,t=!0){let r={};return[...Object.getOwnPropertyNames(e)].forEach((t=>{if(e[t]&&e[t].constructor&&e[t].constructor===Object){const n=a(e[t],!1);for(const e in n)r[t+"."+e]=n[e]}else r[t]=e[t]})),t?n(r):r}function s(e,t){return JSON.stringify(a(e))===JSON.stringify(a(t))}function o(e,t={}){let r=e.constructor===String?e.split("."):e;if(t&&r[0]&&t[r[0]])return t[r[0]].constructor===Object&&r.length>1?o(r.splice(1),t[r[0]]):t[r[0]];console.warn("ns",r[0],"not in",t)}function c(e,t){var n=Array.from(arguments);if(n.length>2){for(;n.length>1;)n[0]=c(n[0],n[1]),n.splice(1,1);return n[0]}if("string"==typeof e)e.match(/\{[^\{\}]*\}/g)?.forEach((function(r){var n=o(r.substring(1,r.length-1),t);void 0!==n&&(e=e.replace(r,n))}));else if(r(e))switch(e.constructor){case Object:Object.keys(e).forEach((function(r){e.hasOwnProperty(r)&&(e[r]=c(e[r],t))}));break;case Array:e.forEach((function(r,n,a){a[n]=c(e[n],t)}))}return e}function i(e){return e.split("-").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join("")}function l(e,t){let r;return()=>{clearTimeout(r),r=setTimeout((function(){e(...arguments)}),t)}}function u(e){let t=document.createElement("template");return e=e.replace(/<([A-Za-z0-9\-]*)([^>\/]*)(\/>)/gi,"<$1$2></$1>"),t.innerHTML=e,t.content.normalize(),Array.from(t.content.childNodes)}function f(e,t){const r=Object.getOwnPropertyDescriptors(e);for(const[e,n]of Object.entries(r))("get"in n||"set"in n)&&Object.defineProperty(t,e,n)}e.r(t),e.d(t,{$d:()=>Y,$t:()=>K,DC:()=>N,FormValues:()=>ae,MC:()=>k,McBase:()=>x,McEvent:()=>p,addListener:()=>v,autoload:()=>M,copyGettersSetters:()=>f,debounce:()=>l,deepEqual:()=>s,defineCE:()=>H,flattenObject:()=>a,getCE:()=>$,htmlToElements:()=>u,isNativeObject:()=>r,kebabToPascal:()=>i,nameSpace:()=>o,observe:()=>V,parse:()=>c,removeListener:()=>O,sortObject:()=>n});var h=new Function("try {return this===window;}catch(e){ return false;}");let d=new Set;h()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>d.add(e)));class p{#e;#t=!1;#r=!1;constructor(e,t={},r="l"){this.#e=e,this.data=t,this.bubble=r}get type(){return this.#e}get stopped(){return this.#t}get immediateStopped(){return this.#r}stopPropagation(){this.#t=!0}stopImmediatePropagation(){this.stopPropagation(),this.#r=!0}}var m=new Function("try {return this===window;}catch(e){ return false;}");let b=new Set;function g(e,t){let r=[];return e.forEach((e=>{if(e&&e instanceof HTMLElement){const n=e?._mc;!t&&n?r=r.concat(Object.values(e._mc)):t&&n&&n[t]&&r.push(n[t])}})),r}function y(e,t,r=!0){let n=[];for(;e;){if(e._mc&&(t?t&&e._mc[t]&&n.push(e._mc[t]):n=n.concat(Object.values(e._mc)),r))return n;e=e.parentNode}return n}function E(e){return e&&e instanceof HTMLElement}function v(e,t,r,n=!1,a=!1){let s={once:!1};n&&(s.capture=n),a&&(s.once=a),e.addEventListener(t,r,s)}function O(e,t,r){e.removeEventListener(t,r)}function w(e,t,r={}){let n=e;if(!n._mc){let t=N?.debug;N.debug=!1,n._mc=new N(e),N.debug=t,delete n._mc._mc}const a=n._mc;return t.length&&!a[t]&&(a[t]=r,e instanceof HTMLElement&&e.setAttribute("_mc","")),r}function S(e,t){if(!t)return;const r=e?._mc||{};r&&r[t]&&delete r[t],!Object.keys(r).length&&e instanceof HTMLElement&&e.hasAttribute("_mc")&&e.removeAttribute("_mc")}function A(e,t,r={},n="l"){let a=e?._mc;if(!a)return;let s=t instanceof p?new p(t.type,t.data,"l"):new p(t,r,"l"),o="string"!=typeof t?t:new p(t,r,n);[...Object.values(a)].forEach((e=>{e?.trigger&&"function"==typeof e?.trigger&&e?.trigger(s)})),/[ud]/.test(o.bubble)&&j(e,o)}function j(e,t){/[ud]/.test(t.bubble)&&setTimeout((()=>{if(-1===t.bubble.indexOf("l")&&(t.bubble+="l"),t.bubble.indexOf("u")>-1){let r=y(e,"",!0)?.[0].target;r&&N.trigger(r,t)}t.bubble.indexOf("d")>-1&&new Set(e._mc.children().map((e=>e?.target))).forEach((e=>{e&&N.trigger(e,t)}))}),0)}m()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>b.add(e)));class x{#n;constructor(e,t=!1){var r;this.#n=new WeakRef(e||{}),(r=this).constructor!==N&&setTimeout((()=>{r.trigger("Init")}),0),function(e){if(!m()||e.constructor===N)return;const t=e.target;if(t instanceof HTMLElement){let r=e;Object.getOwnPropertyNames(r.constructor.prototype).filter((e=>/^on[A-Z]|one[A-Z]/.test(e)&&"function"==typeof r.constructor.prototype[e])).forEach((n=>{let a=/^one/.test(n),s=n.replace(/^on[e]{0,1}/,""),o=s.toLowerCase();a&&Object.defineProperty(e,"on"+s,{configurable:!0,enumerable:!1,writable:!0,value:e=>{r.constructor.prototype[n].bind(r)(e)}}),b.has("on"+o)&&v(t,o,(e=>{r.trigger(s,e)}),!1,a)}))}}(this)}get target(){return this.#n.deref()}}class k extends x{_mc={};constructor(e){super(e)}static trigger=A;trigger(e,t={},r="l"){let n=this;if(n.constructor===k||n.constructor===N){let a=e instanceof p?new p(e.type,e.data,"l"):new p(e,t,"l"),s="string"!=typeof e?e:new p(e,t,r);return[...Object.getOwnPropertyNames(n)].forEach((e=>{n[e]?.trigger&&"function"==typeof n[e]?.trigger&&n[e]?.trigger(a)})),void(/[ud]/.test(s.bubble)&&j(n.target,s))}if(n instanceof k||n instanceof N){const n=this,a="string"!=typeof e?e:new p(e,t,r),s="on"+a.type[0].toUpperCase()+a.type.slice(1);if(a.bubble.indexOf("l")>-1&&(a.immediateStopped||"function"!=typeof n[s]||(n[s](a),n.hasOwnProperty(s)&&delete n[s])),a.stopped||"l"===a.bubble)return n;/[ud]/.test(a.bubble)&&j(n.target,a)}}}class N extends x{_mc={};constructor(e,t=!1){super(e)}static add=w;static remove=S;static trigger=A;trigger(e,t={},r){k.prototype.trigger.call(this,e,t,r)}parent(e=""){let t=this.target;return E(t)?y(t.parentNode,e,!0):[]}ancestors(e=""){let t=this?.target;return E(t)?y(this.target.parentNode,e,!1):[]}children(e=""){let t=this?.target;if(!E(t))return[];const r=Math.random().toString().replace(".",""),n='[_mc]:not([temp_id="'+r+'"] [_mc] [_mc])';t.setAttribute("temp_id",r);const a=g([...t.querySelectorAll(n)],e);return t.removeAttribute("temp_id"),a}descendants(e=""){let t=this?.target;return E(t)?g([...t.querySelectorAll("*[_mc]")],e):[]}}let T=null;const _=new Map;function C(){document.querySelectorAll(':not(:defined),[_mc]:not([_mc=""])').forEach((e=>{(e.tagName.includes("-")?[e.tagName.toLowerCase()]:e.getAttribute("_mc").trim().split(" ")).forEach((t=>{let r=t.toLowerCase().split("-"),n=r[r.length-1],a=n[0].toUpperCase()+n.slice(1);if(r[r.length-1]=a,r=r.join("/")+".js",e.tagName.includes("-")&&!_.has(e.tagName.toLowerCase())){const e=document.createElement("script");_.set(t,r),e.setAttribute("src",r),e.setAttribute("blocking","render"),e.setAttribute("type","module"),e.onload=()=>{_.delete(t)},document.head.append(e)}}))}))}let L=!1;function M(e=!0){return e?(L=e,T=new MutationObserver(C),setTimeout((()=>{T.observe(document.body,{childList:!0,subtree:!0}),C()}),5),L):(T?.disconnect(),T=null,L)}class P extends HTMLElement{constructor(){super()}connectedCallback(){N.trigger(this,"Connected")}disconnectedCallback(){N.trigger(this,"Disconnected")}adoptedCallback(){N.trigger(this,"Adopted")}attributeChangedCallback(e,t,r){N.trigger(this,"AttributeChanged",{name:e,oldValue:t,newValue:r})}}function H(e,t,r=[]){if(customElements.get(e))return void console.warn(`IGNORED: Custom element "${e}" is already defined!`);if(!e.includes("-"))throw new Error('createCustomElement: tagName must contain at least one hyphen ("-").');let n=i(e);customElements.define(e,function(e,t){return Object.defineProperty(t,"name",{value:e})}(n,class extends P{instance;constructor(e){super();let r=new t(this,e);N.add(this,n,r)}static get observedAttributes(){return r}}))}function $(e){return customElements.get(e)}function q(e){return null!=e&&"object"==typeof e}function D(e){let t=new Set,r=/\{[^\{\}]*\}/g;return e.getAttributeNames().filter((t=>e.getAttribute(t)?.match(r))).forEach((n=>{new Set(e.getAttribute(n)?.match(r)).forEach((e=>t.add(e.replace(/[\{\}]/g,""))))})),[...e.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(r))).forEach((e=>{(e.nodeValue||"").match(r).forEach((e=>{t.add(e.replace(/[\{\}]/g,""))}))})),[...t].map((e=>e.replace(/[\{\}]/g,""))),[...t]}const I=[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement];class B extends N{data={};oldDisplay="";constructor(e){super(e);let t=this;D(e).forEach((e=>t.data[e]="")),V(t),t.#a(),delete t._mc}#a(){let e=this,t=e.target,r=!1;t.getAttributeNames().filter((e=>t.getAttribute(e)?.match(/\{[^\{\}]*\}/g))).forEach((r=>{let n=new Set(t.getAttribute(r)?.match(/\{[^\{\}]*\}/g));var a;e.data.observe((a=t.getAttribute(r),e=>{let s=a;n.forEach((t=>{s=s.replace(t,e[t.replace(/[\{\}]/g,"")])})),t.setAttribute(r,s)}))})),[...t.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(/\{[^\{\}]*\}/g))).forEach((n=>{r=!0;let a=new Set(n.nodeValue.match(/\{[^\{\}]*\}/g));var s;e.data.observe((s=n.nodeValue,r=>{let o=s;a.forEach((e=>{o=o.replace(e,r[e.replace(/[\{\}]/g,"")])})),Object.keys(r).some((e=>!!r[e]))&&(e.oldDisplay?t.style=e.oldDisplay:t.removeAttribute("style"),delete e.oldDisplay),n.nodeValue=o})),e.oldDisplay=t.getAttribute("style)")||"",r&&!I.includes(t.constructor)&&"FIELDSET"!==t.tagName&&(t.style.display="none")}))}onData(e){let t=this,r={};Object.keys(e.data).forEach((n=>{t.data.hasOwnProperty(n)&&(r[n]=e.data[n])})),JSON.stringify(r)!==JSON.stringify(t.data)&&Object.assign(t.data,r)}}const V=(e,t)=>((t?[t]:[...Object.getOwnPropertyNames(e)]).forEach((t=>{if("_"===t[0]||void 0===e?.[t])return e;let r,n=e[t];if(!n.prototype)switch(typeof n){case"string":r=String;break;case"number":r=Number;break;case"boolean":r=Boolean;break;case"object":r=n instanceof Array?Array:Object;break;default:return}let o=class extends r{#s=!0;constructor(e){super(e),this.constructor.callbacks=[],q(e)&&Object.getOwnPropertyNames(e).forEach((t=>{this[t]=e[t]}))}observe(e){return this.constructor.callbacks.push(e),this}bind(e){const t=this;if(q(t.valueOf())){!function(e){var t;(t=e,(t instanceof HTMLElement?[t]:[]).concat([...t.querySelectorAll("*")]).filter((e=>!!D(e).length)).filter((e=>"STYLE"!==e.tagName))).forEach((e=>{e?._mc?._placeholders||N.add(e,"_placeholders",new B(e))}))}(e);const r=[...e.querySelectorAll("[_mc]")].filter((e=>!!e?._mc?._placeholders)),n=function(e){let t=a(e);r.forEach((e=>{e&&e._mc.trigger("data",t)}))};t.constructor.callbacks.push(n),t.notify()}else console.warn("IGNORED - cannot bind a non-Object to the dom, IS:",typeof t.valueOf(),t);return this}notify(e){let t=this,r=q(t.valueOf())&&t.valueOf()instanceof Array==0?structuredClone(Object.assign({},t)):t.valueOf();return void 0!==e&&(t.#s=e),t.constructor.callbacks.forEach((e=>{e(r)})),t}},c=new o(n);Object.defineProperty(e,t,{enumerable:!0,get(){if(q(c.valueOf())){let e=structuredClone(Object.assign({},c));setTimeout(l((function(){s(structuredClone(Object.assign({},c)),e)||c.notify()}),0),0)}return c},set(e){if(typeof e==typeof c.valueOf())if(q(c.valueOf())&&c.valueOf()instanceof Array==0){let t=structuredClone(Object.assign({},c));c instanceof o==0&&(c=new o(structuredClone(Object.assign({},e))),f(e,c),c.seal()),Object.assign(c,e),setTimeout(l((function(){s(structuredClone(Object.assign({},c)),t)||c.notify()}),0),0)}else{let t=c.valueOf(),r=c.constructor.callbacks;c=new o(e),c.constructor.callbacks=r,e!==t&&c.notify()}else console.warn("IGNORED - cannot change observable types, IS:",typeof c.valueOf(),c,"- CANNOT BECOME:",typeof e)}}),e[t]=n})),e),z=e=>{let t=new Set;return e.forEach((e=>{(e=e.trim()).split(" ").forEach((e=>{""!==e&&t.add(e)}))})),Array.from(t)},F=e=>{let t=Y("input,select,textarea",e).array,r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let a;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":a=new G(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"select":a=new R(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"textarea":a=new U(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r};class J{constructor(e){}}class G extends J{#o;#e;#c;constructor(e,t){super(e),this.#o=e,this.#e=e.type,this.#c=t}get val(){let e,t=this;switch(t.#e){case"radio":const r=Y(`input[type="radio"][name="${this.#o.getAttribute("name")}"]`,this.#c).filter((e=>e.checked));return r.length?(e=r.array[0],e.value):"";case"checkbox":return t.#o.checked;default:return t.#o.value}return""}set val(e){let t=this;switch(t.#e){case"radio":const r=`input[type="radio"][name="${this.#o.getAttribute("name")}"]`,n=Y(r,this.#c);if(!n.length)return;if(""===e)return void n.forEach((e=>{e.checked&&(e.checked=!1)}));const a=n.filter((t=>t.getAttribute("value")===e));if(!a.length)return;return void(a.array[0].checked=!0);case"checkbox":t.#o.checked=e;break;default:t.#o.value=e}}}class R extends J{#o;#i=!1;constructor(e){super(e),this.#o=e,this.#i="select-multiple"===e.type}get val(){const e=[];return Y(this.#o.querySelectorAll("option")).filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#i?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,Y(this.#o.querySelectorAll("option")).forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected",!0),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class U extends J{#o;constructor(e){super(e),this.#o=e}get val(){return this.#o.value}set val(e){this.#o.value=e}}class W{#l=new Set;get set(){return this.#l}get array(){return Array.from(this.#l)}set set(e){this.#l=e}get length(){return this.#l.size}constructor(e,t=document.body){if(new Set,!e)return this}$t(e){let t=new Z;return this.#l.forEach((e=>{e._mc&&Object.values(e._mc).forEach((e=>{t.set.add(e)}))})),e&&t.filter((t=>t.nameSpace===e)),t}add(e,t){let r=this;return Y(e,t).forEach((e=>{r.#l.add(e)})),r}addClass(...e){return e=z(e),this.forEach((t=>{t.classList.add(...e)})),this}after(e,t){let r=this,n=Y(e,t);return n.length?(n.first().forEach((e=>{r.array.reverse().forEach((t=>{t.after(e)}))})),r):r}append(e,t){let r=this.array[0],n=Y(e,t);return r&&n.forEach((e=>{r.append(e)})),this}appendTo(e,t){let r=Y(e,t).array[0];return r&&this.forEach((e=>{r.append(e)})),this}attr(e,t){let r=this,n={};return r.length?arguments.length?"string"==typeof e?void 0===t?[...r.set][0].getAttribute(e):null===t?([...r.set].forEach((t=>{t.removeAttribute(e)})),r):("object"==typeof t&&(t=JSON.stringify(t)),[...r.set].forEach((r=>{r.setAttribute(e,t)})),r):"object"==typeof e?([...r.set].forEach((t=>{Object.keys(e).forEach((r=>{Y(t).attr(r,e.key)}))})),r):r:(Array.from([...r.set][0].attributes).forEach((e=>{n[e.name]=e.value})),n):r}before(e,t){let r=this,n=Y(e,t);return n.length?(n.first().forEach((e=>{r.forEach((t=>{t.before(e)}))})),r):r}children(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{Array.from(e.children).forEach((e=>{n.add(e)}))})),r=Y([...n]),e){let n=Y(e,t);r.filter((e=>n.has(e)))}return r}descendants(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{e.querySelectorAll("*").forEach((e=>{n.add(e)}))})),r=Y([...n]),e){let n=Y(e,t);r.filter((e=>n.has(e)))}return r}empty(){return this.filter((e=>!1))}first(e,t){let r=this,n=new Set,a=!1;return e&&(a=Y(e,t)),r.#l.forEach((e=>{e.parentNode&&n.add(e.parentNode.children[0])})),r=Y([...n]),e&&r.filter((e=>a.has(e))),r}has(e){return this.#l.has(e)}hasClass(...e){return e=z(e),this.every((e=>Array.from(e.classList).every((t=>e.contains(t)))))}html(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerHTML=e:(()=>{console.warn("Cannot access the .innerHTML of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerHTML}last(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{let t=e.parentNode?.children;t&&n.add(Array.from(t).at(-1))})),r=Y([...n]),e){let n=Y(e,t);r.filter((e=>n.has(e)))}return r}next(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)+1;a<r.length&&n.add(r.at(a))}})),r=Y([...n]),e){let n=Y(e,t);r.filter((e=>n.has(e)))}return r}normalize(){return this.#l.forEach((e=>{e.normalize()})),this}off(e,t){let r=e.indexOf(" ")>-1?e.split(" "):[e];return this.array.forEach((e=>{r.forEach((function(r){O(e,r,t)}))})),this}on(e,t,r=!1,n=!1){let a=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function o(){o.cb.apply(a,Array.from(arguments))}return o.cb=t,a.forEach((e=>{s.forEach((function(t){v(e,t,o,r,n)}))})),o}one(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){v(e,t,s,r,!0)}))})),s}parent(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{e.parentNode&&"HTML"!==e.parentNode.tagName&&n.add(e.parentNode)})),r=Y([...n]),e){let n=Y(e,t);r.filter((e=>n.has(e)))}return r}parents(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{let t=e;for(;t.parentNode&&"HTML"!==t.parentNode.tagName;)t=t.parentNode,n.add(t)})),r=Y([...n]),e){let n=Y(e,t);r.filter((e=>n.has(e)))}return r}prepend(e,t){let r=this.array[0],n=Y(e,t);return r&&n.forEach((e=>{r.prepend(e)})),this}prev(e,t){let r=this,n=new Set;if(r.#l.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)-1;a>-1&&n.add(r.at(a))}})),r=Y([...n]),e){let n=Y(e,t);r.filter((e=>n.has(e)))}return r}removeClass(...e){return e=z(e),this.forEach((t=>{t.classList.remove(...e)})),this}text(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerText=e:(()=>{console.warn("Cannot access the .textContent of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerText??""}toggleClass(...e){return e=z(e),this.forEach((t=>{t.classList.toggle(...e)})),this}trigger(e,t={},r=!1,n=!1,a=!1){let s,o={bubbles:r,cancelable:n,composed:a},c=e.indexOf(" ")>-1?e.split(" "):[e];return this.#l.forEach((e=>{c.forEach((function(r){s=new Event(r,o),s.data=t,e.dispatchEvent(s)}))})),this}val(e,t){if(!this.length)return this;const r=this;let n,a=F(r.array[0]);var s;return e?null!=(s=e)&&"object"==typeof s?(Object.assign(a,e),n=r):"string"==typeof e&&(void 0===t?n=a[e]:(a[e]=t,n=r)):n=Object.assign({},a),n}values(e){const t=this;let r={};if(!t.length)return console.warn("no dom selection to search inputs in"),{};let n=F(t.array[0]);return Object.keys(n).forEach((e=>{r[e]=n[e]})),0===Object.keys(r).length&&console.warn("no inputs in this dom selection",t.array[0],r),e&&Object.keys(e).forEach((t=>{n.hasOwnProperty(t)&&(console.log("key found",t),n[t]=e[t])})),structuredClone(Object.assign(n))}at(e){return Y(this.array.at(e))}concat(e){let t=this;return(e instanceof W?e.array:e).forEach((e=>{t.#l.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return this.#l=new Set(this.array.filter(e,t)),this}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e,0)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){return this.array.pop()}push(...e){return e.forEach((e=>{this.#l.add(e)})),this}shift(){let e=this,t=e.#l.size?e.array[0]:void 0;return t&&e.#l.delete(t),t}slice(e,t){return Y(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array;return n.splice(e,t,...r),Y(n)}}class Z{#l=new Set;get set(){return this.#l}get array(){return Array.from(this.#l)}set set(e){this.#l=e}get length(){return this.#l.size}set length(e){}constructor(e,t=document.body){if(!e)return this;Y(e,t).forEach((e=>{K(e).forEach((e=>{this.#l.add(e)}))}))}$d(e,t=document.body){let r=new W,n=new Set,a=!!e||!1,s=new Set;return a&&(s=Y(e,t).set),this.#l.forEach((e=>{a&&!s.has(e._tg)||n.add(e._tg)})),r.set=n,r}children(e){let t=this,r=new Set;return t.#l.forEach((t=>{t.children(e).forEach((e=>{r.add(e)}))})),t.#l=r,t}descendants(e){let t=this,r=new Set;return t.#l.forEach((t=>{t.descendants(e).forEach((e=>{r.add(e)}))})),t.#l=r,t}first(e){let t=this,r=new Set;return t.#l.forEach((e=>{e.parent().children().$d().first().$t().forEach((e=>{r.add(e)}))})),t.#l=r,e&&t.filter((t=>t.nameSpace=e)),t}has(e){return this.#l.has(e)}last(e){let t=this,r=new Set;return t.#l.forEach((e=>{e.parent().children().$d().last().$t().forEach((e=>{r.add(e)}))})),t.#l=r,e&&t.filter((t=>t.nameSpace=e)),t}next(e){let t=this,r=new Set;return t.#l.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.nextElementSibling;)t=t.nextElementSibling,n.add(t);K([...n]).$d().first().$t().forEach((e=>{r.add(e)}))})),t.#l=r,e&&t.filter((t=>t.nameSpace=e)),t}ns(e){return this.filter((t=>t.nameSpace===e))}off(e,t){let r=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];return this.$d().array.forEach((e=>{r.forEach((function(r){O(e,`[TB]${r}`,t)}))})),this}on(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){v(e._tg,`[TB]${t}`,s,!1,r)}))})),s}one(e,t){let r=this,n=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(r,Array.from(arguments))}return a.cb=t,r.forEach((e=>{n.forEach((function(t){v(e._tg,`[TB]${t}`,a,!1,!0)}))})),a}parent(e){let t=this,r=new Set;return t.#l.forEach((t=>{t.parent(e).forEach((e=>{r.add(e)}))})),t.#l=r,t}parents(e){let t=this,r=new Set;return t.#l.forEach((t=>{t.parents(e).forEach((e=>{r.add(e)}))})),t.#l=r,t}prev(e){let t=this,r=new Set;return t.#l.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.previousElementSibling;)t=t.previousElementSibling,n.add(t);K([...n]).$d().last().$t().forEach((e=>{r.add(e)}))})),t.#l=r,e&&t.filter((t=>t.nameSpace=e)),t}trigger(e,t={},r="l"){return this.forEach((n=>{n.trigger(e,t,r)})),this}at(e){return K(this.array.at(e))}concat(e){let t=this;return e.forEach((e=>{t.#l.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return K(this.array.filter(e,t))}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){let e=this.array,t=e.pop();return this.#l=new Set(e),t}push(e){return this.#l.add(e),this}shift(){let e=this.array.shift();return this.#l.delete(e),e}slice(e,t){return K(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array.splice(e,t,...r);return K(n)}}const Y=(e,t=document)=>{let r=new Set;return e instanceof Array?(e.forEach((e=>{Y(e,t).forEach((e=>{r.add(e)}))})),new W([...r])):new W(e,t)},K=(e,t=document)=>Y(e,t).$t();class Q{constructor(e){}}class X extends Q{#o;#u;constructor(e,t){super(e),this.#o=e,this.#u=t}get val(){return new FormData(this.#u).get(this.#o.name)}set val(e){[...this.#u.querySelectorAll(`input[type="radio][name="${this.#o.name}"]`)].filter((t=>t.getAttribute("value")===e)).shift().checked=!0}}class ee extends Q{#o;constructor(e){super(e),this.#o=e}get val(){return this.#o.checked}set val(e){this.#o.checked=e}}class te extends Q{#o;constructor(e){super(e),this.#o=e}get val(){return this.#o.value}set val(e){this.#o.value=e}}class re extends Q{#o;#i=!1;constructor(e){super(e),this.#o=e,this.#i=e.multiple}get val(){const e=[];return[...this.#o.querySelectorAll("option")].filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#i?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,[...this.#o.querySelectorAll("option")].forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected","selected"),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class ne extends Q{#o;constructor(e){super(e),this.#o=e}get val(){return this.#o.value||""}set val(e){this.#o.value=e}}class ae{constructor(e,t,r){let n=(e=>{let t=[...(e||document).querySelectorAll("input,select,textarea")],r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let a,s,o=t.type;switch((e=>e.tagName.toLowerCase())(t)){case"input":switch(o){case"radio":a=new X(t,e.constructor===HTMLFormElement?e:e.querySelector("form")),s=N.add(t,n,a);break;case"checkbox":a=new ee(t),s=N.add(t,n,a);break;default:a=new te(t),s=N.add(t,n,a)}Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val!==e&&(s.val=e)}});break;case"select":a=new re(t),s=N.add(t,n,a),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val!==e&&(s.val=e)}});break;case"textarea":a=new ne(t),s=N.add(t,n,a),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val!==e&&(s.val=e)}});break;default:console.warn("handler missing:",n,"for",t.tagName.toLowerCase(),t)}}})),r})(r);e[t]=Object.assign({},n),V(e,t),f(n,e[t]),[...r.querySelectorAll("input, textarea, select")].forEach((r=>{v(r,"keyup",(r=>{e[t].notify()})),v(r,"change",(r=>{e[t].notify()})),v(r,"select",(r=>{e[t].notify()}))}))}}return t})()));
@@ -5,6 +5,6 @@ export type Observable = {
5
5
  notify: () => void;
6
6
  bind: (target: HTMLElement | DocumentFragment | ShadowRoot) => void;
7
7
  };
8
- export declare const observe: (target: LooseObject, propertyName?: string) => void;
8
+ export declare const observe: (target: LooseObject, propertyName?: string) => LooseObject;
9
9
  export {};
10
10
  //# sourceMappingURL=observables.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"observables.d.ts","sourceRoot":"","sources":["../src/observables.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,WAAW,EAMX,MAAM,cAAc,CAAC;AAQtB,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;AAuKrC,MAAM,MAAM,UAAU,GAAG;IACxB,OAAO,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,IAAI,CAAC;IAChC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,GAAG,gBAAgB,GAAG,UAAU,KAAK,IAAI,CAAC;CACpE,CAAC;AAEF,eAAO,MAAM,OAAO,WAAY,WAAW,iBAAiB,MAAM,SA+KjE,CAAC"}
1
+ {"version":3,"file":"observables.d.ts","sourceRoot":"","sources":["../src/observables.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,WAAW,EAKX,MAAM,cAAc,CAAC;AAQtB,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;AAqLrC,MAAM,MAAM,UAAU,GAAG;IACxB,OAAO,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,IAAI,CAAC;IAChC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,GAAG,gBAAgB,GAAG,UAAU,KAAK,IAAI,CAAC;CACpE,CAAC;AAEF,eAAO,MAAM,OAAO,WACX,WAAW,iBACJ,MAAM,KACnB,WAsMF,CAAC"}
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.observables=e():t.observables=e()}(this,(()=>(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function r(t){let e={};return[...Object.keys(t)].sort().forEach((n=>{var o;(o=t[n])&&o.constructor&&o.constructor===Object?e[n]=r(t[n]):e[n]=t[n]})),e}function n(t,e=!0){let o={};return[...Object.getOwnPropertyNames(t)].forEach((e=>{if(t[e]&&t[e].constructor&&t[e].constructor===Object){const r=n(t[e],!1);for(const t in r)o[e+"."+t]=r[t]}else o[e]=t[e]})),e?r(o):o}function o(t,e){return JSON.stringify(n(t))===JSON.stringify(n(e))}function c(t,e){let r;return()=>{clearTimeout(r),r=setTimeout((function(){t(...arguments)}),e)}}t.r(e),t.d(e,{observe:()=>S});var a=new Function("try {return this===window;}catch(e){ return false;}");let s=new Set;a()&&Object.keys(HTMLElement.prototype).filter((t=>/^on/.test(t))).forEach((t=>s.add(t)));class i{#t;#e=!1;#r=!1;constructor(t,e={},r="l"){this.#t=t,this.data=e,this.bubble=r}get type(){return this.#t}get stopped(){return this.#e}get immediateStopped(){return this.#r}stopPropagation(){this.#e=!0}stopImmediatePropagation(){this.stopPropagation(),this.#r=!0}}var l=new Function("try {return this===window;}catch(e){ return false;}");let u=new Set;function f(t,e){let r=[];return t.forEach((t=>{if(t&&t instanceof HTMLElement){const n=t?._mc;!e&&n?r=r.concat(Object.values(t._mc)):e&&n&&n[e]&&r.push(n[e])}})),r}function d(t,e,r=!0){let n=[];for(;t;){if(t._mc&&(e?e&&t._mc[e]&&n.push(t._mc[e]):n=n.concat(Object.values(t._mc)),r))return n;t=t.parentNode}return n}function p(t){return t&&t instanceof HTMLElement}function b(t,e,r={}){let n=t;if(!n._mc){let e=w?.debug;w.debug=!1,n._mc=new w(t),w.debug=e,delete n._mc._mc}const o=n._mc;return e.length&&!o[e]&&(o[e]=r,t instanceof HTMLElement&&t.setAttribute("_mc","")),r}function g(t,e){if(!e)return;const r=t?._mc||{};r&&r[e]&&delete r[e],!Object.keys(r).length&&t instanceof HTMLElement&&t.hasAttribute("_mc")&&t.removeAttribute("_mc")}function h(t,e,r={},n="l"){let o=t?._mc;if(!o)return;let c=e instanceof i?new i(e.type,e.data,"l"):new i(e,r,"l"),a="string"!=typeof e?e:new i(e,r,n);[...Object.values(o)].forEach((t=>{t?.trigger&&"function"==typeof t?.trigger&&t?.trigger(c)})),/[ud]/.test(a.bubble)&&m(t,a)}function m(t,e){/[ud]/.test(e.bubble)&&setTimeout((()=>{if(-1===e.bubble.indexOf("l")&&(e.bubble+="l"),e.bubble.indexOf("u")>-1){let r=d(t,"",!0)?.[0].target;r&&w.trigger(r,e)}e.bubble.indexOf("d")>-1&&new Set(t._mc.children().map((t=>t?.target))).forEach((t=>{t&&w.trigger(t,e)}))}),0)}l()&&Object.keys(HTMLElement.prototype).filter((t=>/^on/.test(t))).forEach((t=>u.add(t)));class y{#n;constructor(t,e=!1){var r;this.#n=new WeakRef(t||{}),(r=this).constructor!==w&&setTimeout((()=>{r.trigger("Init")}),0),function(t){if(!l()||t.constructor===w)return;const e=t.target;if(e instanceof HTMLElement){let r=t;Object.getOwnPropertyNames(r.constructor.prototype).filter((t=>/^on[A-Z]|one[A-Z]/.test(t)&&"function"==typeof r.constructor.prototype[t])).forEach((n=>{let o=/^one/.test(n),c=n.replace(/^on[e]{0,1}/,""),a=c.toLowerCase();o&&Object.defineProperty(t,"on"+c,{configurable:!0,enumerable:!1,writable:!0,value:t=>{r.constructor.prototype[n].bind(r)(t)}}),u.has("on"+a)&&function(t,e,r,n=!1,o=!1){let c={once:!1};n&&(c.capture=n),o&&(c.once=o),t.addEventListener(e,r,c)}(e,a,(t=>{r.trigger(c,t)}),!1,o)}))}}(this)}get target(){return this.#n.deref()}}class O extends y{_mc={};constructor(t){super(t)}static trigger=h;trigger(t,e={},r="l"){let n=this;if(n.constructor===O||n.constructor===w){let o=t instanceof i?new i(t.type,t.data,"l"):new i(t,e,"l"),c="string"!=typeof t?t:new i(t,e,r);return[...Object.getOwnPropertyNames(n)].forEach((t=>{n[t]?.trigger&&"function"==typeof n[t]?.trigger&&n[t]?.trigger(o)})),void(/[ud]/.test(c.bubble)&&m(n.target,c))}if(n instanceof O||n instanceof w){const n=this,o="string"!=typeof t?t:new i(t,e,r),c="on"+o.type[0].toUpperCase()+o.type.slice(1);if(o.bubble.indexOf("l")>-1&&(o.immediateStopped||"function"!=typeof n[c]||(n[c](o),n.hasOwnProperty(c)&&delete n[c])),o.stopped||"l"===o.bubble)return n;/[ud]/.test(o.bubble)&&m(n.target,o)}}}class w extends y{_mc={};constructor(t,e=!1){super(t)}static add=b;static remove=g;static trigger=h;trigger(t,e={},r){O.prototype.trigger.call(this,t,e,r)}parent(t=""){let e=this.target;return p(e)?d(e.parentNode,t,!0):[]}ancestors(t=""){let e=this?.target;return p(e)?d(this.target.parentNode,t,!1):[]}children(t=""){let e=this?.target;if(!p(e))return[];const r=Math.random().toString().replace(".",""),n='[_mc]:not([temp_id="'+r+'"] [_mc] [_mc])';e.setAttribute("temp_id",r);const o=f([...e.querySelectorAll(n)],t);return e.removeAttribute("temp_id"),o}descendants(t=""){let e=this?.target;return p(e)?f([...e.querySelectorAll("*[_mc]")],t):[]}}function E(t){return null!=t&&"object"==typeof t}function v(t){let e=new Set,r=/\{[^\{\}]*\}/g;return t.getAttributeNames().filter((e=>t.getAttribute(e)?.match(r))).forEach((n=>{new Set(t.getAttribute(n)?.match(r)).forEach((t=>e.add(t.replace(/[\{\}]/g,""))))})),[...t.childNodes].filter((t=>3===t.nodeType&&(t.nodeValue||"").match(r))).forEach((t=>{(t.nodeValue||"").match(r).forEach((t=>{e.add(t.replace(/[\{\}]/g,""))}))})),[...e].map((t=>t.replace(/[\{\}]/g,""))),[...e]}const j=[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement];class _ extends w{data={};oldDisplay="";constructor(t){super(t);let e=this;v(t).forEach((t=>e.data[t]="")),S(e),e.#o(),delete e._mc}#o(){let t=this,e=t.target;e.getAttributeNames().filter((t=>e.getAttribute(t)?.match(/\{[^\{\}]*\}/g))).forEach((r=>{let n=new Set(e.getAttribute(r)?.match(/\{[^\{\}]*\}/g));var o;t.data.observe((o=e.getAttribute(r),t=>{let c=o;n.forEach((e=>{c=c.replace(e,t[e.replace(/[\{\}]/g,"")])})),e.setAttribute(r,c)}))})),[...e.childNodes].filter((t=>3===t.nodeType&&(t.nodeValue||"").match(/\{[^\{\}]*\}/g))).forEach((r=>{let n=new Set(r.nodeValue.match(/\{[^\{\}]*\}/g));var o;t.data.observe((o=r.nodeValue,c=>{let a=o;n.forEach((t=>{a=a.replace(t,c[t.replace(/[\{\}]/g,"")])})),Object.keys(c).some((t=>!!c[t]))&&(e.style.display=t.oldDisplay,delete t.oldDisplay),r.nodeValue=a})),t.oldDisplay=e.getAttribute("style)")||"",j.includes(e.constructor)||(e.style.display="none")}))}onData(t){let e=this,r={};Object.keys(t.data).forEach((n=>{e.data.hasOwnProperty(n)&&(r[n]=t.data[n])})),JSON.stringify(r)!==JSON.stringify(e.data)&&Object.assign(e.data,r)}}const S=(t,e)=>{(e?[e]:[...Object.getOwnPropertyNames(t)]).forEach((e=>{if("_"===e[0]||void 0===t?.[e])return;let r,a=t[e];if(!a.prototype)switch(typeof a){case"string":r=String;break;case"number":r=Number;break;case"boolean":r=Boolean;break;case"object":r=a instanceof Array?Array:Object;break;default:return}let s=class extends r{constructor(t){super(t),this.constructor.callbacks=[],E(t)&&Object.getOwnPropertyNames(t).forEach((e=>{this[e]=t[e]}))}observe(t){return this.constructor.callbacks.push(t),this}bind(t){const e=this;return E(e.valueOf())?(function(t){var e;(e=t,(e instanceof HTMLElement?[e]:[]).concat([...e.querySelectorAll("*")]).filter((t=>!!v(t).length))).forEach((t=>{t?._mc?._placeholders||w.add(t,"_placeholders",new _(t))}))}(t),this.constructor.callbacks.push((e=>{new w(t).descendants("_placeholders").forEach((t=>{t&&t.trigger("data",n(e))}))})),e.notify()):console.warn("IGNORED - cannot bind a non-Object to the dom, IS:",typeof e.valueOf(),e),this}notify(){let t=this,e=E(t.valueOf())&&t.valueOf()instanceof Array==0?structuredClone(Object.assign({},t)):t.valueOf();return t.constructor.callbacks.forEach((t=>{t(e)})),this}},i=new s(a);Object.defineProperty(t,e,{enumerable:!0,get(){if(E(i.valueOf())){let t=structuredClone(Object.assign({},i));setTimeout(c((function(){o(structuredClone(Object.assign({},i)),t)||i.notify()}),0),0)}return i},set(t){if(typeof t==typeof i.valueOf())if(E(i.valueOf())&&i.valueOf()instanceof Array==0){let e=structuredClone(Object.assign({},i));t=structuredClone(Object.assign({},t));let r=i.constructor?.hasFormHandler??!1,n=i.constructor.callbacks;i=new s(structuredClone(Object.assign({},t))),i.constructor.callbacks=r,i.constructor.callbacks=n,setTimeout(c((function(){o(structuredClone(Object.assign({},i)),e)||i.notify()}),0),0)}else{let e=i.valueOf(),r=i.constructor.callbacks;i=new s(t),i.constructor.callbacks=r,t!==e&&i.notify()}else console.warn("IGNORED - cannot change observable types, IS:",typeof i.valueOf(),i,"- CANNOT BECOME:",typeof t)}}),t[e]=a}))};return e})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.observables=t():e.observables=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){let t={};return[...Object.keys(e)].sort().forEach((n=>{var o;(o=e[n])&&o.constructor&&o.constructor===Object?t[n]=r(e[n]):t[n]=e[n]})),t}function n(e,t=!0){let o={};return[...Object.getOwnPropertyNames(e)].forEach((t=>{if(e[t]&&e[t].constructor&&e[t].constructor===Object){const r=n(e[t],!1);for(const e in r)o[t+"."+e]=r[e]}else o[t]=e[t]})),t?r(o):o}function o(e,t){return JSON.stringify(n(e))===JSON.stringify(n(t))}function c(e,t){let r;return()=>{clearTimeout(r),r=setTimeout((function(){e(...arguments)}),t)}}e.r(t),e.d(t,{observe:()=>S});var a=new Function("try {return this===window;}catch(e){ return false;}");let s=new Set;a()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>s.add(e)));class i{#e;#t=!1;#r=!1;constructor(e,t={},r="l"){this.#e=e,this.data=t,this.bubble=r}get type(){return this.#e}get stopped(){return this.#t}get immediateStopped(){return this.#r}stopPropagation(){this.#t=!0}stopImmediatePropagation(){this.stopPropagation(),this.#r=!0}}var l=new Function("try {return this===window;}catch(e){ return false;}");let u=new Set;function f(e,t){let r=[];return e.forEach((e=>{if(e&&e instanceof HTMLElement){const n=e?._mc;!t&&n?r=r.concat(Object.values(e._mc)):t&&n&&n[t]&&r.push(n[t])}})),r}function d(e,t,r=!0){let n=[];for(;e;){if(e._mc&&(t?t&&e._mc[t]&&n.push(e._mc[t]):n=n.concat(Object.values(e._mc)),r))return n;e=e.parentNode}return n}function p(e){return e&&e instanceof HTMLElement}function b(e,t,r={}){let n=e;if(!n._mc){let t=E?.debug;E.debug=!1,n._mc=new E(e),E.debug=t,delete n._mc._mc}const o=n._mc;return t.length&&!o[t]&&(o[t]=r,e instanceof HTMLElement&&e.setAttribute("_mc","")),r}function g(e,t){if(!t)return;const r=e?._mc||{};r&&r[t]&&delete r[t],!Object.keys(r).length&&e instanceof HTMLElement&&e.hasAttribute("_mc")&&e.removeAttribute("_mc")}function m(e,t,r={},n="l"){let o=e?._mc;if(!o)return;let c=t instanceof i?new i(t.type,t.data,"l"):new i(t,r,"l"),a="string"!=typeof t?t:new i(t,r,n);[...Object.values(o)].forEach((e=>{e?.trigger&&"function"==typeof e?.trigger&&e?.trigger(c)})),/[ud]/.test(a.bubble)&&h(e,a)}function h(e,t){/[ud]/.test(t.bubble)&&setTimeout((()=>{if(-1===t.bubble.indexOf("l")&&(t.bubble+="l"),t.bubble.indexOf("u")>-1){let r=d(e,"",!0)?.[0].target;r&&E.trigger(r,t)}t.bubble.indexOf("d")>-1&&new Set(e._mc.children().map((e=>e?.target))).forEach((e=>{e&&E.trigger(e,t)}))}),0)}l()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>u.add(e)));class y{#n;constructor(e,t=!1){var r;this.#n=new WeakRef(e||{}),(r=this).constructor!==E&&setTimeout((()=>{r.trigger("Init")}),0),function(e){if(!l()||e.constructor===E)return;const t=e.target;if(t instanceof HTMLElement){let r=e;Object.getOwnPropertyNames(r.constructor.prototype).filter((e=>/^on[A-Z]|one[A-Z]/.test(e)&&"function"==typeof r.constructor.prototype[e])).forEach((n=>{let o=/^one/.test(n),c=n.replace(/^on[e]{0,1}/,""),a=c.toLowerCase();o&&Object.defineProperty(e,"on"+c,{configurable:!0,enumerable:!1,writable:!0,value:e=>{r.constructor.prototype[n].bind(r)(e)}}),u.has("on"+a)&&function(e,t,r,n=!1,o=!1){let c={once:!1};n&&(c.capture=n),o&&(c.once=o),e.addEventListener(t,r,c)}(t,a,(e=>{r.trigger(c,e)}),!1,o)}))}}(this)}get target(){return this.#n.deref()}}class O extends y{_mc={};constructor(e){super(e)}static trigger=m;trigger(e,t={},r="l"){let n=this;if(n.constructor===O||n.constructor===E){let o=e instanceof i?new i(e.type,e.data,"l"):new i(e,t,"l"),c="string"!=typeof e?e:new i(e,t,r);return[...Object.getOwnPropertyNames(n)].forEach((e=>{n[e]?.trigger&&"function"==typeof n[e]?.trigger&&n[e]?.trigger(o)})),void(/[ud]/.test(c.bubble)&&h(n.target,c))}if(n instanceof O||n instanceof E){const n=this,o="string"!=typeof e?e:new i(e,t,r),c="on"+o.type[0].toUpperCase()+o.type.slice(1);if(o.bubble.indexOf("l")>-1&&(o.immediateStopped||"function"!=typeof n[c]||(n[c](o),n.hasOwnProperty(c)&&delete n[c])),o.stopped||"l"===o.bubble)return n;/[ud]/.test(o.bubble)&&h(n.target,o)}}}class E extends y{_mc={};constructor(e,t=!1){super(e)}static add=b;static remove=g;static trigger=m;trigger(e,t={},r){O.prototype.trigger.call(this,e,t,r)}parent(e=""){let t=this.target;return p(t)?d(t.parentNode,e,!0):[]}ancestors(e=""){let t=this?.target;return p(t)?d(this.target.parentNode,e,!1):[]}children(e=""){let t=this?.target;if(!p(t))return[];const r=Math.random().toString().replace(".",""),n='[_mc]:not([temp_id="'+r+'"] [_mc] [_mc])';t.setAttribute("temp_id",r);const o=f([...t.querySelectorAll(n)],e);return t.removeAttribute("temp_id"),o}descendants(e=""){let t=this?.target;return p(t)?f([...t.querySelectorAll("*[_mc]")],e):[]}}function v(e){return null!=e&&"object"==typeof e}function w(e){let t=new Set,r=/\{[^\{\}]*\}/g;return e.getAttributeNames().filter((t=>e.getAttribute(t)?.match(r))).forEach((n=>{new Set(e.getAttribute(n)?.match(r)).forEach((e=>t.add(e.replace(/[\{\}]/g,""))))})),[...e.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(r))).forEach((e=>{(e.nodeValue||"").match(r).forEach((e=>{t.add(e.replace(/[\{\}]/g,""))}))})),[...t].map((e=>e.replace(/[\{\}]/g,""))),[...t]}new Map;const j=[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement];class _ extends E{data={};oldDisplay="";constructor(e){super(e);let t=this;w(e).forEach((e=>t.data[e]="")),S(t),t.#o(),delete t._mc}#o(){let e=this,t=e.target,r=!1;t.getAttributeNames().filter((e=>t.getAttribute(e)?.match(/\{[^\{\}]*\}/g))).forEach((r=>{let n=new Set(t.getAttribute(r)?.match(/\{[^\{\}]*\}/g));var o;e.data.observe((o=t.getAttribute(r),e=>{let c=o;n.forEach((t=>{c=c.replace(t,e[t.replace(/[\{\}]/g,"")])})),t.setAttribute(r,c)}))})),[...t.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(/\{[^\{\}]*\}/g))).forEach((n=>{r=!0;let o=new Set(n.nodeValue.match(/\{[^\{\}]*\}/g));var c;e.data.observe((c=n.nodeValue,r=>{let a=c;o.forEach((e=>{a=a.replace(e,r[e.replace(/[\{\}]/g,"")])})),Object.keys(r).some((e=>!!r[e]))&&(e.oldDisplay?t.style=e.oldDisplay:t.removeAttribute("style"),delete e.oldDisplay),n.nodeValue=a})),e.oldDisplay=t.getAttribute("style)")||"",r&&!j.includes(t.constructor)&&"FIELDSET"!==t.tagName&&(t.style.display="none")}))}onData(e){let t=this,r={};Object.keys(e.data).forEach((n=>{t.data.hasOwnProperty(n)&&(r[n]=e.data[n])})),JSON.stringify(r)!==JSON.stringify(t.data)&&Object.assign(t.data,r)}}const S=(e,t)=>((t?[t]:[...Object.getOwnPropertyNames(e)]).forEach((t=>{if("_"===t[0]||void 0===e?.[t])return e;let r,a=e[t];if(!a.prototype)switch(typeof a){case"string":r=String;break;case"number":r=Number;break;case"boolean":r=Boolean;break;case"object":r=a instanceof Array?Array:Object;break;default:return}let s=class extends r{#c=!0;constructor(e){super(e),this.constructor.callbacks=[],v(e)&&Object.getOwnPropertyNames(e).forEach((t=>{this[t]=e[t]}))}observe(e){return this.constructor.callbacks.push(e),this}bind(e){const t=this;if(v(t.valueOf())){!function(e){var t;(t=e,(t instanceof HTMLElement?[t]:[]).concat([...t.querySelectorAll("*")]).filter((e=>!!w(e).length)).filter((e=>"STYLE"!==e.tagName))).forEach((e=>{e?._mc?._placeholders||E.add(e,"_placeholders",new _(e))}))}(e);const r=[...e.querySelectorAll("[_mc]")].filter((e=>!!e?._mc?._placeholders)),o=function(e){let t=n(e);r.forEach((e=>{e&&e._mc.trigger("data",t)}))};t.constructor.callbacks.push(o),t.notify()}else console.warn("IGNORED - cannot bind a non-Object to the dom, IS:",typeof t.valueOf(),t);return this}notify(e){let t=this,r=v(t.valueOf())&&t.valueOf()instanceof Array==0?structuredClone(Object.assign({},t)):t.valueOf();return void 0!==e&&(t.#c=e),t.constructor.callbacks.forEach((e=>{e(r)})),t}},i=new s(a);Object.defineProperty(e,t,{enumerable:!0,get(){if(v(i.valueOf())){let e=structuredClone(Object.assign({},i));setTimeout(c((function(){o(structuredClone(Object.assign({},i)),e)||i.notify()}),0),0)}return i},set(e){if(typeof e==typeof i.valueOf())if(v(i.valueOf())&&i.valueOf()instanceof Array==0){let t=structuredClone(Object.assign({},i));i instanceof s==0&&(i=new s(structuredClone(Object.assign({},e))),function(e,t){const r=Object.getOwnPropertyDescriptors(e);for(const[e,n]of Object.entries(r))("get"in n||"set"in n)&&Object.defineProperty(t,e,n)}(e,i),i.seal()),Object.assign(i,e),setTimeout(c((function(){o(structuredClone(Object.assign({},i)),t)||i.notify()}),0),0)}else{let t=i.valueOf(),r=i.constructor.callbacks;i=new s(e),i.constructor.callbacks=r,e!==t&&i.notify()}else console.warn("IGNORED - cannot change observable types, IS:",typeof i.valueOf(),i,"- CANNOT BECOME:",typeof e)}}),e[t]=a})),e);return t})()));
@@ -2,11 +2,10 @@
2
2
 
3
3
  import {
4
4
  LooseObject,
5
- parse,
6
5
  debounce,
7
6
  deepEqual,
8
- nameSpace,
9
7
  flattenObject,
8
+ copyGettersSetters,
10
9
  } from './helpers.js';
11
10
 
12
11
  import { DC, HTMLMcElement, McEvent } from './MC.js';
@@ -76,9 +75,10 @@ class Placeholders extends DC {
76
75
 
77
76
  #attachCallbacks() {
78
77
  let that = this,
79
- target = that.target;
78
+ target = that.target,
79
+ hide: boolean = false;
80
80
 
81
- // console.log('attachCallbacks', that.target);
81
+ //console.log('attachCallbacks', that.target);
82
82
 
83
83
  // scan attributes
84
84
  target
@@ -116,6 +116,7 @@ class Placeholders extends DC {
116
116
  );
117
117
  })
118
118
  .forEach((childNode) => {
119
+ hide = true;
119
120
  let phs: Set<string> = new Set(
120
121
  childNode.nodeValue.match(/\{[^\{\}]*\}/g)
121
122
  );
@@ -124,6 +125,7 @@ class Placeholders extends DC {
124
125
  that.data.observe(
125
126
  ((template: string) => (data: LooseObject) => {
126
127
  let result: string = template;
128
+ //console.log('text node "', template, '" callbach data:', data);
127
129
  phs.forEach((placeholder) => {
128
130
  result = result.replace(
129
131
  placeholder,
@@ -135,7 +137,11 @@ class Placeholders extends DC {
135
137
  return !!data[key];
136
138
  })
137
139
  ) {
138
- target.style.display = that.oldDisplay;
140
+ if (!!that.oldDisplay) {
141
+ target.style = that.oldDisplay;
142
+ } else {
143
+ target.removeAttribute('style');
144
+ }
139
145
  delete that.oldDisplay;
140
146
  }
141
147
  childNode.nodeValue = result;
@@ -144,7 +150,11 @@ class Placeholders extends DC {
144
150
 
145
151
  // hide for now
146
152
  that.oldDisplay = target.getAttribute('style)') || '';
147
- if (!inputs.includes((target as any).constructor)) {
153
+ if (
154
+ hide &&
155
+ !inputs.includes((target as any).constructor) &&
156
+ target.tagName !== 'FIELDSET'
157
+ ) {
148
158
  target.style.display = 'none';
149
159
  }
150
160
  });
@@ -156,7 +166,7 @@ class Placeholders extends DC {
156
166
  Object.keys(ev.data).forEach((key) => {
157
167
  if (that.data.hasOwnProperty(key)) data[key] = ev.data[key];
158
168
  });
159
- // console.log('onData()', ev, data, that.data);
169
+ //console.log('onData()', ev, data, that.data);
160
170
  if (JSON.stringify(data) !== JSON.stringify(that.data))
161
171
  Object.assign(that.data, data); // will trigger callbacks
162
172
  }
@@ -169,13 +179,16 @@ function getPlaceholderElements(
169
179
  target instanceof HTMLElement ? [target] : []
170
180
  )
171
181
  .concat([...(target.querySelectorAll('*') as unknown as HTMLElement[])])
172
- .filter((e) => !!getPlaceholders(e as HTMLElement).length);
182
+ .filter((e) => !!getPlaceholders(e as HTMLElement).length)
183
+ .filter((e) => e.tagName !== 'STYLE');
184
+ //console.log('getPlaceholderElements', elements);
173
185
  return elements as HTMLElement[];
174
186
  }
175
187
 
176
- function makePlaceHolders(
188
+ function makePlaceholders(
177
189
  element: HTMLElement | DocumentFragment | ShadowRoot
178
190
  ): void {
191
+ //console.log('makePlaceholders', element);
179
192
  getPlaceholderElements(element).forEach((e: HTMLElement) => {
180
193
  if ((e as HTMLMcElement)?._mc?._placeholders) return;
181
194
  DC.add(e, '_placeholders', new Placeholders(e));
@@ -188,14 +201,17 @@ export type Observable = {
188
201
  bind: (target: HTMLElement | DocumentFragment | ShadowRoot) => void;
189
202
  };
190
203
 
191
- export const observe = (target: LooseObject, propertyName?: string) => {
204
+ export const observe = (
205
+ target: LooseObject,
206
+ propertyName?: string
207
+ ): LooseObject => {
192
208
  let keys = !propertyName
193
209
  ? [...Object.getOwnPropertyNames(target)]
194
210
  : [propertyName];
195
211
 
196
212
  keys.forEach((key) => {
197
213
  // console.log( 'co propname', key, typeof target[key], target[key] );
198
- if (key[0] === '_' || target?.[key] === undefined) return;
214
+ if (key[0] === '_' || target?.[key] === undefined) return target;
199
215
  let val: any = target[key],
200
216
  Constructor: any;
201
217
 
@@ -223,6 +239,8 @@ export const observe = (target: LooseObject, propertyName?: string) => {
223
239
  }
224
240
 
225
241
  let Observable = class extends Constructor {
242
+ #notify: boolean = true;
243
+
226
244
  constructor(val: any) {
227
245
  super(val);
228
246
  (this.constructor as LooseObject).callbacks = [];
@@ -246,16 +264,22 @@ export const observe = (target: LooseObject, propertyName?: string) => {
246
264
  //console.log('bind', iso, target);
247
265
 
248
266
  if (iso) {
249
- makePlaceHolders(target);
250
- (this.constructor as any).callbacks.push((data: LooseObject) => {
267
+ makePlaceholders(target);
268
+ const placeholders: unknown = [
269
+ ...target.querySelectorAll('[_mc]'),
270
+ ].filter((e) => !!(e as LooseObject)?._mc?._placeholders);
271
+ //console.log('placeholders:', target, placeholders);
272
+ const func = function callback(data: LooseObject) {
251
273
  // avoid bubbling for speed
252
- new DC(target as HTMLMcElement)
253
- .descendants('_placeholders')
254
- .forEach((e) => {
255
- if (!e) return;
256
- e.trigger('data', flattenObject(data));
257
- });
258
- });
274
+ let d = flattenObject(data);
275
+ //console.log('inside callback', target, d);
276
+ (placeholders as DC[]).forEach((e) => {
277
+ // console.log('trigger callback', e);
278
+ if (!e) return;
279
+ (e as any)._mc.trigger('data', d);
280
+ });
281
+ };
282
+ (that.constructor as any).callbacks.push(func);
259
283
  that.notify();
260
284
  } else {
261
285
  console.warn(
@@ -268,22 +292,34 @@ export const observe = (target: LooseObject, propertyName?: string) => {
268
292
  return this;
269
293
  }
270
294
 
271
- notify() {
295
+ notify(notify?: boolean) {
272
296
  let that = this,
273
297
  data =
274
298
  isObservableObject(that.valueOf()) &&
275
299
  that.valueOf() instanceof Array === false
276
300
  ? structuredClone(Object.assign({}, that))
277
301
  : that.valueOf();
302
+
303
+ if (notify !== undefined) {
304
+ that.#notify = notify;
305
+ // return;
306
+ }
307
+
308
+ //if (that.#notify) console.log('notify', this, data);
278
309
  (that.constructor as any).callbacks.forEach((f: Function) => {
279
- // console.log( 'callback', f, data);
310
+ // console.log(
311
+ // (this.constructor as any).callbacks,
312
+ // 'notify: exec callback',
313
+ // f,
314
+ // data
315
+ // );
280
316
  f(data);
281
317
  });
282
- return this;
318
+
319
+ return that;
283
320
  }
284
321
  };
285
322
 
286
- //(Observable.constructor as LooseObject).callbacks = [];
287
323
  let o = new Observable(val);
288
324
 
289
325
  Object.defineProperty(target, key, {
@@ -311,20 +347,21 @@ export const observe = (target: LooseObject, propertyName?: string) => {
311
347
  let iso =
312
348
  isObservableObject(o.valueOf()) &&
313
349
  o.valueOf() instanceof Array === false;
314
- //let iso = o.constructor.prototype.__proto__.constructor === Object;
315
350
  //console.log('target iso:', iso);
316
351
  if (iso) {
317
352
  let old = structuredClone(Object.assign({}, o));
318
- val = structuredClone(Object.assign({}, val));
353
+ //val = structuredClone(Object.assign({}, val));
319
354
 
320
- let hasFormHandler =
321
- (o.constructor as LooseObject)?.hasFormHandler ?? false,
322
- callbacks = (o.constructor as LooseObject).callbacks;
323
- o = new Observable(structuredClone(Object.assign({}, val)));
355
+ //let callbacks = (o.constructor as LooseObject).callbacks;
356
+ if (o instanceof Observable === false) {
357
+ o = new Observable(structuredClone(Object.assign({}, val)));
358
+ copyGettersSetters(val, o);
359
+ o.seal();
360
+ }
361
+ Object.assign(o, val);
324
362
 
325
- //console.log('after set o=', o, 'check', old);
326
- (o.constructor as LooseObject).callbacks = hasFormHandler;
327
- (o.constructor as LooseObject).callbacks = callbacks;
363
+ // console.log('after set o=', o, 'check', old);
364
+ // (o.constructor as LooseObject).callbacks = callbacks;
328
365
 
329
366
  setTimeout(
330
367
  // check for changes
@@ -363,4 +400,6 @@ export const observe = (target: LooseObject, propertyName?: string) => {
363
400
  // replace old property with proxy (observable)
364
401
  target[key] = val;
365
402
  });
403
+
404
+ return target;
366
405
  };
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.selectors=t():e.selectors=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{$d:()=>E,$t:()=>m});var r=new Function("try {return this===window;}catch(e){ return false;}");let n=new Set;r()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>n.add(e)));var a=new Function("try {return this===window;}catch(e){ return false;}");let s=new Set;function i(e,t,r,n=!1,a=!1){let s={once:!1};n&&(s.capture=n),a&&(s.once=a),e.addEventListener(t,r,s)}function o(e,t,r){e.removeEventListener(t,r)}a()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>s.add(e)));const c=e=>{let t=new Set;return e.forEach((e=>{(e=e.trim()).split(" ").forEach((e=>{""!==e&&t.add(e)}))})),Array.from(t)},l=e=>{let t=E("input,select,textarea",e).array,r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let a;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":a=new f(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"select":a=new u(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"textarea":a=new d(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r};class h{constructor(e){}}class f extends h{#e;#t;#r;constructor(e,t){super(e),this.#e=e,this.#t=e.type,this.#r=t}get val(){let e,t=this;switch(t.#t){case"radio":const r=E(`input[type="radio"][name="${this.#e.getAttribute("name")}"]`,this.#r).filter((e=>e.checked));return r.length?(e=r.array[0],e.value):"";case"checkbox":return t.#e.checked;default:return t.#e.value}return""}set val(e){let t=this;switch(t.#t){case"radio":const r=`input[type="radio"][name="${this.#e.getAttribute("name")}"]`,n=E(r,this.#r);if(!n.length)return;if(""===e)return void n.forEach((e=>{e.checked&&(e.checked=!1)}));const a=n.filter((t=>t.getAttribute("value")===e));if(!a.length)return;return void(a.array[0].checked=!0);case"checkbox":t.#e.checked=e;break;default:t.#e.value=e}}}class u extends h{#e;#n=!1;constructor(e){super(e),this.#e=e,this.#n="select-multiple"===e.type}get val(){const e=[];return E(this.#e.querySelectorAll("option")).filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#n?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,E(this.#e.querySelectorAll("option")).forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected",!0),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class d extends h{#e;constructor(e){super(e),this.#e=e}get val(){return this.#e.value}set val(e){this.#e.value=e}}class p{#a=new Set;get set(){return this.#a}get array(){return Array.from(this.#a)}set set(e){this.#a=e}get length(){return this.#a.size}constructor(e,t=document.body){if(new Set,!e)return this}$t(e){let t=new y;return this.#a.forEach((e=>{e._mc&&Object.values(e._mc).forEach((e=>{t.set.add(e)}))})),e&&t.filter((t=>t.nameSpace===e)),t}add(e,t){let r=this;return E(e,t).forEach((e=>{r.#a.add(e)})),r}addClass(...e){return e=c(e),this.forEach((t=>{t.classList.add(...e)})),this}after(e,t){let r=this,n=E(e,t);return n.length?(n.first().forEach((e=>{r.array.reverse().forEach((t=>{t.after(e)}))})),r):r}append(e,t){let r=this.array[0],n=E(e,t);return r&&n.forEach((e=>{r.append(e)})),this}appendTo(e,t){let r=E(e,t).array[0];return r&&this.forEach((e=>{r.append(e)})),this}attr(e,t){let r=this,n={};return r.length?arguments.length?"string"==typeof e?void 0===t?[...r.set][0].getAttribute(e):null===t?([...r.set].forEach((t=>{t.removeAttribute(e)})),r):("object"==typeof t&&(t=JSON.stringify(t)),[...r.set].forEach((r=>{r.setAttribute(e,t)})),r):"object"==typeof e?([...r.set].forEach((t=>{Object.keys(e).forEach((r=>{E(t).attr(r,e.key)}))})),r):r:(Array.from([...r.set][0].attributes).forEach((e=>{n[e.name]=e.value})),n):r}before(e,t){let r=this,n=E(e,t);return n.length?(n.first().forEach((e=>{r.forEach((t=>{t.before(e)}))})),r):r}children(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{Array.from(e.children).forEach((e=>{n.add(e)}))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}descendants(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{e.querySelectorAll("*").forEach((e=>{n.add(e)}))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}empty(){return this.filter((e=>!1))}first(e,t){let r=this,n=new Set,a=!1;return e&&(a=E(e,t)),r.#a.forEach((e=>{e.parentNode&&n.add(e.parentNode.children[0])})),r=E([...n]),e&&r.filter((e=>a.has(e))),r}has(e){return this.#a.has(e)}hasClass(...e){return e=c(e),this.every((e=>Array.from(e.classList).every((t=>e.contains(t)))))}html(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerHTML=e:(()=>{console.warn("Cannot access the .innerHTML of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerHTML}last(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;t&&n.add(Array.from(t).at(-1))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}next(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)+1;a<r.length&&n.add(r.at(a))}})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}normalize(){return this.#a.forEach((e=>{e.normalize()})),this}off(e,t){let r=e.indexOf(" ")>-1?e.split(" "):[e];return this.array.forEach((e=>{r.forEach((function(r){o(e,r,t)}))})),this}on(e,t,r=!1,n=!1){let a=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function o(){o.cb.apply(a,Array.from(arguments))}return o.cb=t,a.forEach((e=>{s.forEach((function(t){i(e,t,o,r,n)}))})),o}one(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){i(e,t,s,r,!0)}))})),s}parent(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{e.parentNode&&"HTML"!==e.parentNode.tagName&&n.add(e.parentNode)})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}parents(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e;for(;t.parentNode&&"HTML"!==t.parentNode.tagName;)t=t.parentNode,n.add(t)})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}prepend(e,t){let r=this.array[0],n=E(e,t);return r&&n.forEach((e=>{r.prepend(e)})),this}prev(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)-1;a>-1&&n.add(r.at(a))}})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}removeClass(...e){return e=c(e),this.forEach((t=>{t.classList.remove(...e)})),this}text(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerText=e:(()=>{console.warn("Cannot access the .textContent of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerText??""}toggleClass(...e){return e=c(e),this.forEach((t=>{t.classList.toggle(...e)})),this}trigger(e,t={},r=!1,n=!1,a=!1){let s,i={bubbles:r,cancelable:n,composed:a},o=e.indexOf(" ")>-1?e.split(" "):[e];return this.#a.forEach((e=>{o.forEach((function(r){s=new Event(r,i),s.data=t,e.dispatchEvent(s)}))})),this}val(e,t){if(!this.length)return this;const r=this;let n,a=l(r.array[0]);var s;return e?null!=(s=e)&&"object"==typeof s?(Object.assign(a,e),n=r):"string"==typeof e&&(void 0===t?n=a[e]:(a[e]=t,n=r)):n=Object.assign({},a),n}values(e){const t=this;let r={};if(!t.length)return console.warn("no dom selection to search inputs in"),{};let n=l(t.array[0]);return Object.keys(n).forEach((e=>{r[e]=n[e]})),0===Object.keys(r).length&&console.warn("no inputs in this dom selection",t.array[0],r),e&&Object.keys(e).forEach((t=>{n.hasOwnProperty(t)&&(console.log("key found",t),n[t]=e[t])})),structuredClone(Object.assign(n))}at(e){return E(this.array.at(e))}concat(e){let t=this;return(e instanceof p?e.array:e).forEach((e=>{t.#a.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return this.#a=new Set(this.array.filter(e,t)),this}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e,0)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){return this.array.pop()}push(...e){return e.forEach((e=>{this.#a.add(e)})),this}shift(){let e=this,t=e.#a.size?e.array[0]:void 0;return t&&e.#a.delete(t),t}slice(e,t){return E(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array;return n.splice(e,t,...r),E(n)}}class y{#a=new Set;get set(){return this.#a}get array(){return Array.from(this.#a)}set set(e){this.#a=e}get length(){return this.#a.size}set length(e){}constructor(e,t=document.body){if(!e)return this;E(e,t).forEach((e=>{m(e).forEach((e=>{this.#a.add(e)}))}))}$d(e,t=document.body){let r=new p,n=new Set,a=!!e||!1,s=new Set;return a&&(s=E(e,t).set),this.#a.forEach((e=>{a&&!s.has(e._tg)||n.add(e._tg)})),r.set=n,r}children(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.children(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}descendants(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.descendants(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}first(e){let t=this,r=new Set;return t.#a.forEach((e=>{e.parent().children().$d().first().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}has(e){return this.#a.has(e)}last(e){let t=this,r=new Set;return t.#a.forEach((e=>{e.parent().children().$d().last().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}next(e){let t=this,r=new Set;return t.#a.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.nextElementSibling;)t=t.nextElementSibling,n.add(t);m([...n]).$d().first().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}ns(e){return this.filter((t=>t.nameSpace===e))}off(e,t){let r=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];return this.$d().array.forEach((e=>{r.forEach((function(r){o(e,`[TB]${r}`,t)}))})),this}on(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){i(e._tg,`[TB]${t}`,s,!1,r)}))})),s}one(e,t){let r=this,n=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(r,Array.from(arguments))}return a.cb=t,r.forEach((e=>{n.forEach((function(t){i(e._tg,`[TB]${t}`,a,!1,!0)}))})),a}parent(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.parent(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}parents(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.parents(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}prev(e){let t=this,r=new Set;return t.#a.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.previousElementSibling;)t=t.previousElementSibling,n.add(t);m([...n]).$d().last().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}trigger(e,t={},r="l"){return this.forEach((n=>{n.trigger(e,t,r)})),this}at(e){return m(this.array.at(e))}concat(e){let t=this;return e.forEach((e=>{t.#a.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return m(this.array.filter(e,t))}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){let e=this.array,t=e.pop();return this.#a=new Set(e),t}push(e){return this.#a.add(e),this}shift(){let e=this.array.shift();return this.#a.delete(e),e}slice(e,t){return m(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array.splice(e,t,...r);return m(n)}}const E=(e,t=document)=>{let r=new Set;return e instanceof Array?(e.forEach((e=>{E(e,t).forEach((e=>{r.add(e)}))})),new p([...r])):new p(e,t)},m=(e,t=document)=>E(e,t).$t();return t})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.selectors=t():e.selectors=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{$d:()=>E,$t:()=>m});var r=new Function("try {return this===window;}catch(e){ return false;}");let n=new Set;r()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>n.add(e)));var a=new Function("try {return this===window;}catch(e){ return false;}");let s=new Set;function i(e,t,r,n=!1,a=!1){let s={once:!1};n&&(s.capture=n),a&&(s.once=a),e.addEventListener(t,r,s)}function o(e,t,r){e.removeEventListener(t,r)}a()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>s.add(e))),new Map;const c=e=>{let t=new Set;return e.forEach((e=>{(e=e.trim()).split(" ").forEach((e=>{""!==e&&t.add(e)}))})),Array.from(t)},l=e=>{let t=E("input,select,textarea",e).array,r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let a;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":a=new f(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"select":a=new u(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"textarea":a=new d(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r};class h{constructor(e){}}class f extends h{#e;#t;#r;constructor(e,t){super(e),this.#e=e,this.#t=e.type,this.#r=t}get val(){let e,t=this;switch(t.#t){case"radio":const r=E(`input[type="radio"][name="${this.#e.getAttribute("name")}"]`,this.#r).filter((e=>e.checked));return r.length?(e=r.array[0],e.value):"";case"checkbox":return t.#e.checked;default:return t.#e.value}return""}set val(e){let t=this;switch(t.#t){case"radio":const r=`input[type="radio"][name="${this.#e.getAttribute("name")}"]`,n=E(r,this.#r);if(!n.length)return;if(""===e)return void n.forEach((e=>{e.checked&&(e.checked=!1)}));const a=n.filter((t=>t.getAttribute("value")===e));if(!a.length)return;return void(a.array[0].checked=!0);case"checkbox":t.#e.checked=e;break;default:t.#e.value=e}}}class u extends h{#e;#n=!1;constructor(e){super(e),this.#e=e,this.#n="select-multiple"===e.type}get val(){const e=[];return E(this.#e.querySelectorAll("option")).filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#n?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,E(this.#e.querySelectorAll("option")).forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected",!0),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class d extends h{#e;constructor(e){super(e),this.#e=e}get val(){return this.#e.value}set val(e){this.#e.value=e}}class p{#a=new Set;get set(){return this.#a}get array(){return Array.from(this.#a)}set set(e){this.#a=e}get length(){return this.#a.size}constructor(e,t=document.body){if(new Set,!e)return this}$t(e){let t=new y;return this.#a.forEach((e=>{e._mc&&Object.values(e._mc).forEach((e=>{t.set.add(e)}))})),e&&t.filter((t=>t.nameSpace===e)),t}add(e,t){let r=this;return E(e,t).forEach((e=>{r.#a.add(e)})),r}addClass(...e){return e=c(e),this.forEach((t=>{t.classList.add(...e)})),this}after(e,t){let r=this,n=E(e,t);return n.length?(n.first().forEach((e=>{r.array.reverse().forEach((t=>{t.after(e)}))})),r):r}append(e,t){let r=this.array[0],n=E(e,t);return r&&n.forEach((e=>{r.append(e)})),this}appendTo(e,t){let r=E(e,t).array[0];return r&&this.forEach((e=>{r.append(e)})),this}attr(e,t){let r=this,n={};return r.length?arguments.length?"string"==typeof e?void 0===t?[...r.set][0].getAttribute(e):null===t?([...r.set].forEach((t=>{t.removeAttribute(e)})),r):("object"==typeof t&&(t=JSON.stringify(t)),[...r.set].forEach((r=>{r.setAttribute(e,t)})),r):"object"==typeof e?([...r.set].forEach((t=>{Object.keys(e).forEach((r=>{E(t).attr(r,e.key)}))})),r):r:(Array.from([...r.set][0].attributes).forEach((e=>{n[e.name]=e.value})),n):r}before(e,t){let r=this,n=E(e,t);return n.length?(n.first().forEach((e=>{r.forEach((t=>{t.before(e)}))})),r):r}children(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{Array.from(e.children).forEach((e=>{n.add(e)}))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}descendants(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{e.querySelectorAll("*").forEach((e=>{n.add(e)}))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}empty(){return this.filter((e=>!1))}first(e,t){let r=this,n=new Set,a=!1;return e&&(a=E(e,t)),r.#a.forEach((e=>{e.parentNode&&n.add(e.parentNode.children[0])})),r=E([...n]),e&&r.filter((e=>a.has(e))),r}has(e){return this.#a.has(e)}hasClass(...e){return e=c(e),this.every((e=>Array.from(e.classList).every((t=>e.contains(t)))))}html(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerHTML=e:(()=>{console.warn("Cannot access the .innerHTML of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerHTML}last(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;t&&n.add(Array.from(t).at(-1))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}next(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)+1;a<r.length&&n.add(r.at(a))}})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}normalize(){return this.#a.forEach((e=>{e.normalize()})),this}off(e,t){let r=e.indexOf(" ")>-1?e.split(" "):[e];return this.array.forEach((e=>{r.forEach((function(r){o(e,r,t)}))})),this}on(e,t,r=!1,n=!1){let a=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function o(){o.cb.apply(a,Array.from(arguments))}return o.cb=t,a.forEach((e=>{s.forEach((function(t){i(e,t,o,r,n)}))})),o}one(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){i(e,t,s,r,!0)}))})),s}parent(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{e.parentNode&&"HTML"!==e.parentNode.tagName&&n.add(e.parentNode)})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}parents(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e;for(;t.parentNode&&"HTML"!==t.parentNode.tagName;)t=t.parentNode,n.add(t)})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}prepend(e,t){let r=this.array[0],n=E(e,t);return r&&n.forEach((e=>{r.prepend(e)})),this}prev(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)-1;a>-1&&n.add(r.at(a))}})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}removeClass(...e){return e=c(e),this.forEach((t=>{t.classList.remove(...e)})),this}text(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerText=e:(()=>{console.warn("Cannot access the .textContent of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerText??""}toggleClass(...e){return e=c(e),this.forEach((t=>{t.classList.toggle(...e)})),this}trigger(e,t={},r=!1,n=!1,a=!1){let s,i={bubbles:r,cancelable:n,composed:a},o=e.indexOf(" ")>-1?e.split(" "):[e];return this.#a.forEach((e=>{o.forEach((function(r){s=new Event(r,i),s.data=t,e.dispatchEvent(s)}))})),this}val(e,t){if(!this.length)return this;const r=this;let n,a=l(r.array[0]);var s;return e?null!=(s=e)&&"object"==typeof s?(Object.assign(a,e),n=r):"string"==typeof e&&(void 0===t?n=a[e]:(a[e]=t,n=r)):n=Object.assign({},a),n}values(e){const t=this;let r={};if(!t.length)return console.warn("no dom selection to search inputs in"),{};let n=l(t.array[0]);return Object.keys(n).forEach((e=>{r[e]=n[e]})),0===Object.keys(r).length&&console.warn("no inputs in this dom selection",t.array[0],r),e&&Object.keys(e).forEach((t=>{n.hasOwnProperty(t)&&(console.log("key found",t),n[t]=e[t])})),structuredClone(Object.assign(n))}at(e){return E(this.array.at(e))}concat(e){let t=this;return(e instanceof p?e.array:e).forEach((e=>{t.#a.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return this.#a=new Set(this.array.filter(e,t)),this}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e,0)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){return this.array.pop()}push(...e){return e.forEach((e=>{this.#a.add(e)})),this}shift(){let e=this,t=e.#a.size?e.array[0]:void 0;return t&&e.#a.delete(t),t}slice(e,t){return E(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array;return n.splice(e,t,...r),E(n)}}class y{#a=new Set;get set(){return this.#a}get array(){return Array.from(this.#a)}set set(e){this.#a=e}get length(){return this.#a.size}set length(e){}constructor(e,t=document.body){if(!e)return this;E(e,t).forEach((e=>{m(e).forEach((e=>{this.#a.add(e)}))}))}$d(e,t=document.body){let r=new p,n=new Set,a=!!e||!1,s=new Set;return a&&(s=E(e,t).set),this.#a.forEach((e=>{a&&!s.has(e._tg)||n.add(e._tg)})),r.set=n,r}children(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.children(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}descendants(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.descendants(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}first(e){let t=this,r=new Set;return t.#a.forEach((e=>{e.parent().children().$d().first().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}has(e){return this.#a.has(e)}last(e){let t=this,r=new Set;return t.#a.forEach((e=>{e.parent().children().$d().last().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}next(e){let t=this,r=new Set;return t.#a.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.nextElementSibling;)t=t.nextElementSibling,n.add(t);m([...n]).$d().first().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}ns(e){return this.filter((t=>t.nameSpace===e))}off(e,t){let r=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];return this.$d().array.forEach((e=>{r.forEach((function(r){o(e,`[TB]${r}`,t)}))})),this}on(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){i(e._tg,`[TB]${t}`,s,!1,r)}))})),s}one(e,t){let r=this,n=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(r,Array.from(arguments))}return a.cb=t,r.forEach((e=>{n.forEach((function(t){i(e._tg,`[TB]${t}`,a,!1,!0)}))})),a}parent(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.parent(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}parents(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.parents(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}prev(e){let t=this,r=new Set;return t.#a.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.previousElementSibling;)t=t.previousElementSibling,n.add(t);m([...n]).$d().last().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}trigger(e,t={},r="l"){return this.forEach((n=>{n.trigger(e,t,r)})),this}at(e){return m(this.array.at(e))}concat(e){let t=this;return e.forEach((e=>{t.#a.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return m(this.array.filter(e,t))}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){let e=this.array,t=e.pop();return this.#a=new Set(e),t}push(e){return this.#a.add(e),this}shift(){let e=this.array.shift();return this.#a.delete(e),e}slice(e,t){return m(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array.splice(e,t,...r);return m(n)}}const E=(e,t=document)=>{let r=new Set;return e instanceof Array?(e.forEach((e=>{E(e,t).forEach((e=>{r.add(e)}))})),new p([...r])):new p(e,t)},m=(e,t=document)=>E(e,t).$t();return t})()));
package/dist/test.ts CHANGED
@@ -42,21 +42,18 @@ class Translator extends DC {
42
42
 
43
43
  (that.Translation as Observable).bind(translationTargetObject);
44
44
 
45
- this.target.setAttribute('language', 'en');
45
+ that.target.setAttribute('language', 'en');
46
46
 
47
- (this.Language as Observable).notify();
47
+ (that.Language as Observable).notify();
48
48
 
49
49
  delete that._mc; // cleanup, not needed
50
50
  }
51
51
 
52
52
  onAttributeChanged(ev: McEvent) {
53
53
  if (!ev.data.newValue) return;
54
-
55
- let that = this;
56
-
57
54
  switch (ev.data.name) {
58
55
  case 'language':
59
- that.Language = ev.data.newValue;
56
+ this.Language = ev.data.newValue;
60
57
  break;
61
58
  }
62
59
  }
@@ -112,10 +109,10 @@ defineCE(
112
109
 
113
110
  onClick(ev: McEvent) {
114
111
  const that = this,
115
- c = this.Dom.counter++;
112
+ c = that.Dom.counter++;
116
113
  (ev.data as PointerEvent).stopPropagation();
117
- (this.target as HTMLElement).classList.remove('clicked');
118
- (this.target as HTMLElement).classList.add(
114
+ (that.target as HTMLElement).classList.remove('clicked');
115
+ (that.target as HTMLElement).classList.add(
119
116
  that.Dom.counter > 9 ? 'overClicked' : 'clicked'
120
117
  );
121
118
  }
@@ -130,10 +127,11 @@ let MyTag: CustomElementConstructor = getCE('my-tag')!,
130
127
  stress test
131
128
  */
132
129
 
133
- let start = new Date().getTime();
130
+ let start = new Date().getTime(),
131
+ max = 100;
134
132
 
135
- // create 100 elements
136
- for (let x = 0; x < 1000; x++) {
133
+ // create 1000 elements
134
+ for (let x = 0; x < max; x++) {
137
135
  fragment.append(new MyTag());
138
136
  }
139
137
 
@@ -152,14 +150,16 @@ setTimeout(() => {
152
150
  // console.clear();
153
151
 
154
152
  console.log(
155
- '%c \n\nStress Test:\n\n %cInstancing 1000 web components (3000 classes): %c %s ms.',
153
+ '%c \n\nStress Test:\n\n %cInstancing %s web components (%s classes): %c %s ms.',
156
154
  'font-weight: bold; color: black;',
157
155
  'font-weight: normal;',
156
+ max,
157
+ max * 3,
158
158
  'font-weight: bold; color: blue;',
159
159
  end - start
160
160
  );
161
161
 
162
- document.body.appendChild(new MyTag());
162
+ //document.body.appendChild(new MyTag());
163
163
 
164
164
  let element = document.querySelector('my-tag');
165
165
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twobirds/microcomponents",
3
- "version": "0.0.46",
3
+ "version": "0.0.50",
4
4
  "description": "Micro Components Organization Class",
5
5
  "main": "./dist/microcomponents.ts",
6
6
  "types": "./dist/microcomponents.d.ts",
@@ -0,0 +1,13 @@
1
+ test-grandparent,
2
+ test-parent,
3
+ test-child,
4
+ test-grandchild,
5
+ test-greatgrandchild {
6
+ display: inline-block;
7
+ padding: 2px;
8
+ margin: 1px;
9
+ border: 1px solid darkslategray;
10
+ border-radius: 2px;
11
+ }
12
+
13
+ /*# sourceMappingURL=GrandParent.css.map */