@twobirds/microcomponents 0.0.67 → 0.0.68

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 (164) hide show
  1. package/.vscode/settings.json +1 -1
  2. package/README.md +3 -3
  3. package/assets/documentation/formvalues.md +26 -0
  4. package/assets/test/MicroComponents.svg +15 -0
  5. package/assets/test/test.html +5 -5
  6. package/dist/microcomponents.d.ts +0 -1
  7. package/dist/microcomponents.d.ts.map +1 -1
  8. package/dist/microcomponents.min.js +1 -0
  9. package/dist/microcomponents.ts +1 -1
  10. package/package.json +6 -5
  11. package/public/MC.d.ts +36 -0
  12. package/public/MC.d.ts.map +1 -0
  13. package/public/MC.ts +605 -0
  14. package/public/McEvent.d.ts +15 -0
  15. package/public/McEvent.d.ts.map +1 -0
  16. package/public/McEvent.ts +96 -0
  17. package/public/documentation/formvalues.md +26 -0
  18. package/public/elements.d.ts +5 -0
  19. package/public/elements.d.ts.map +1 -0
  20. package/public/elements.ts +76 -0
  21. package/public/formValues.d.ts +3 -0
  22. package/public/formValues.d.ts.map +1 -0
  23. package/public/formValues.ts +233 -0
  24. package/public/helpers.d.ts +14 -0
  25. package/public/helpers.d.ts.map +1 -0
  26. package/public/helpers.ts +149 -0
  27. package/public/microcomponents.d.ts +7 -0
  28. package/public/microcomponents.d.ts.map +1 -0
  29. package/public/microcomponents.es3.d.ts +2 -0
  30. package/public/microcomponents.es3.d.ts.map +1 -0
  31. package/public/microcomponents.js +0 -1
  32. package/public/microcomponents.js.map +1 -1
  33. package/public/microcomponents.min.js +1 -0
  34. package/public/microcomponents.ts +8 -0
  35. package/public/observables.d.ts +10 -0
  36. package/public/observables.d.ts.map +1 -0
  37. package/public/observables.ts +401 -0
  38. package/public/selectors.d.ts +108 -0
  39. package/public/selectors.d.ts.map +1 -0
  40. package/public/selectors.ts +1634 -0
  41. package/public/src/microcomponents.ts +1 -1
  42. package/public/test/MC.d.ts +36 -0
  43. package/public/test/MC.d.ts.map +1 -0
  44. package/public/test/MC.js +378 -0
  45. package/public/test/MC.js.map +1 -0
  46. package/public/test/MC.ts +605 -0
  47. package/public/test/McEvent.d.ts +15 -0
  48. package/public/test/McEvent.d.ts.map +1 -0
  49. package/public/test/McEvent.js +71 -0
  50. package/public/test/McEvent.js.map +1 -0
  51. package/public/test/McEvent.ts +96 -0
  52. package/public/test/MicroComponents.svg +15 -0
  53. package/public/test/elements.d.ts +5 -0
  54. package/public/test/elements.d.ts.map +1 -0
  55. package/public/test/elements.js +48 -0
  56. package/public/test/elements.js.map +1 -0
  57. package/public/test/elements.ts +76 -0
  58. package/public/test/formValues.d.ts +3 -0
  59. package/public/test/formValues.d.ts.map +1 -0
  60. package/public/test/formValues.js +168 -0
  61. package/public/test/formValues.js.map +1 -0
  62. package/public/test/formValues.ts +233 -0
  63. package/public/test/helpers.d.ts +14 -0
  64. package/public/test/helpers.d.ts.map +1 -0
  65. package/public/test/helpers.js +113 -0
  66. package/public/test/helpers.js.map +1 -0
  67. package/public/test/helpers.ts +149 -0
  68. package/public/test/microcomponents.d.ts +7 -0
  69. package/public/test/microcomponents.d.ts.map +1 -0
  70. package/public/test/microcomponents.es3.d.ts +2 -0
  71. package/public/test/microcomponents.es3.d.ts.map +1 -0
  72. package/public/test/microcomponents.es3.js +303 -0
  73. package/public/test/microcomponents.es3.js.map +1 -0
  74. package/public/test/microcomponents.js +8 -0
  75. package/public/test/microcomponents.js.map +1 -0
  76. package/public/test/microcomponents.min.js +1 -0
  77. package/public/test/microcomponents.ts +8 -0
  78. package/public/test/observables.d.ts +10 -0
  79. package/public/test/observables.d.ts.map +1 -0
  80. package/public/test/observables.js +250 -0
  81. package/public/test/observables.js.map +1 -0
  82. package/public/test/observables.ts +401 -0
  83. package/public/test/selectors.d.ts +108 -0
  84. package/public/test/selectors.d.ts.map +1 -0
  85. package/public/test/selectors.js +971 -0
  86. package/public/test/selectors.js.map +1 -0
  87. package/public/test/selectors.ts +1634 -0
  88. package/public/test/test/child.d.ts +2 -0
  89. package/public/test/test/child.d.ts.map +1 -0
  90. package/public/test/{child.js → test/child.js} +1 -1
  91. package/public/test/test/child.js.map +1 -0
  92. package/public/test/test/grandchild.d.ts +2 -0
  93. package/public/test/test/grandchild.d.ts.map +1 -0
  94. package/public/test/{grandchild.js → test/grandchild.js} +1 -1
  95. package/public/test/test/grandchild.js.map +1 -0
  96. package/public/test/test/grandparent.d.ts +2 -0
  97. package/public/test/test/grandparent.d.ts.map +1 -0
  98. package/public/test/test/grandparent.js.map +1 -0
  99. package/public/test/test/greatgrandchild.d.ts +2 -0
  100. package/public/test/test/greatgrandchild.d.ts.map +1 -0
  101. package/public/test/{greatgrandchild.js → test/greatgrandchild.js} +1 -1
  102. package/public/test/test/greatgrandchild.js.map +1 -0
  103. package/public/test/test/parent.d.ts +2 -0
  104. package/public/test/test/parent.d.ts.map +1 -0
  105. package/public/test/{parent.js → test/parent.js} +1 -1
  106. package/public/test/test/parent.js.map +1 -0
  107. package/public/test/test/testform.d.ts +2 -0
  108. package/public/test/test/testform.d.ts.map +1 -0
  109. package/public/test/test/testform.js.map +1 -0
  110. package/public/test/test/testmc.d.ts +6 -0
  111. package/public/test/test/testmc.d.ts.map +1 -0
  112. package/public/test/{testmc.js → test/testmc.js} +1 -1
  113. package/public/test/test/testmc.js.map +1 -0
  114. package/public/test/test.d.ts +2 -0
  115. package/public/test/test.d.ts.map +1 -0
  116. package/public/test/test.html +5 -5
  117. package/public/test/test.ts +193 -0
  118. package/public/typedoc/classes/MC.DC.html +2 -2
  119. package/public/typedoc/classes/MC.MC.html +2 -2
  120. package/public/typedoc/classes/MC.McBase.html +2 -2
  121. package/public/typedoc/classes/MC.McEvent.html +2 -2
  122. package/public/typedoc/functions/MC.addListener.html +1 -1
  123. package/public/typedoc/functions/MC.autoload.html +1 -1
  124. package/public/typedoc/functions/MC.removeListener.html +1 -1
  125. package/public/typedoc/functions/elements.defineCE.html +1 -1
  126. package/public/typedoc/functions/elements.getCE.html +1 -1
  127. package/public/typedoc/functions/formValues.formValues.html +1 -1
  128. package/public/typedoc/functions/observables.observe.html +1 -1
  129. package/public/typedoc/functions/selectors._d.html +1 -1
  130. package/public/typedoc/functions/selectors._t.html +1 -1
  131. package/public/typedoc/index.html +3 -3
  132. package/public/typedoc/interfaces/MC.HTMLMcElement.html +2 -2
  133. package/public/typedoc/interfaces/selectors.DSelector.html +2 -2
  134. package/public/typedoc/interfaces/selectors.TSelector.html +2 -2
  135. package/public/typedoc/modules/MC.html +1 -1
  136. package/public/typedoc/modules/elements.html +1 -1
  137. package/public/typedoc/modules/formValues.html +1 -1
  138. package/public/typedoc/modules/observables.html +1 -1
  139. package/public/typedoc/modules/selectors.html +1 -1
  140. package/public/typedoc/types/observables.Observable.html +1 -1
  141. package/public/typedoc/types/selectors.selection.html +1 -1
  142. package/public/typedoc/types/selectors.singleSelector.html +1 -1
  143. package/src/microcomponents.ts +1 -1
  144. package/src/test/{child.ts → test/child.ts} +1 -1
  145. package/src/test/{grandchild.ts → test/grandchild.ts} +1 -1
  146. package/src/test/{grandparent.ts → test/grandparent.ts} +1 -1
  147. package/src/test/{greatgrandchild.ts → test/greatgrandchild.ts} +1 -1
  148. package/src/test/{parent.ts → test/parent.ts} +1 -1
  149. package/src/test/{testform.ts → test/testform.ts} +1 -1
  150. package/src/test/{testmc.ts → test/testmc.ts} +1 -1
  151. package/tsconfig.json +2 -2
  152. package/webpack.config.js +5 -5
  153. package/dist/microcomponents.js +0 -1
  154. package/public/test/child.js.map +0 -1
  155. package/public/test/grandchild.js.map +0 -1
  156. package/public/test/grandparent.js.map +0 -1
  157. package/public/test/greatgrandchild.js.map +0 -1
  158. package/public/test/parent.js.map +0 -1
  159. package/public/test/testform.js.map +0 -1
  160. package/public/test/testmc.js.map +0 -1
  161. /package/public/test/{grandparent.js → test/grandparent.js} +0 -0
  162. /package/public/test/{testform.js → test/testform.js} +0 -0
  163. /package/public/{test.js → test/test.js} +0 -0
  164. /package/public/{test.js.map → test/test.js.map} +0 -0
@@ -0,0 +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((o=>{r(e[o])?t[o]=n(e[o]):t[o]=e[o]})),t}function o(e,t=!0){let r={};return[...Object.getOwnPropertyNames(e)].forEach((t=>{if(e[t]&&e[t].constructor&&e[t].constructor===Object){const n=o(e[t],!1);for(const e in n)r[t+"."+e]=n[e]}else r[t]=e[t]})),t?n(r):r}function c(e,t){return JSON.stringify(o(e))===JSON.stringify(o(t))}function s(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?s(r.splice(1),t[r[0]]):t[r[0]];console.warn("ns",r[0],"not in",t)}function a(e,t){var n=Array.from(arguments);if(n.length>2){for(;n.length>1;)n[0]=a(n[0],n[1]),n.splice(1,1);return n[0]}if("string"==typeof e)e.match(/\{[^\{\}]*\}/g)?.forEach((function(r){var n=s(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]=a(e[r],t))}));break;case Array:e.forEach((function(r,n,o){o[n]=a(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 d(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,{DC:()=>k,MC:()=>C,McBase:()=>S,McEvent:()=>p,addListener:()=>E,autoload:()=>D,copyGettersSetters:()=>d,debounce:()=>l,deepEqual:()=>c,defineCE:()=>q,flattenObject:()=>o,formValues:()=>K,getCE:()=>$,htmlToElements:()=>u,isNativeObject:()=>r,kebabToPascal:()=>i,nameSpace:()=>s,observe:()=>J,parse:()=>a,removeListener:()=>v,sortObject:()=>n});var f=new Function("try {return this===window;}catch(e){ return false;}");let m=new Set;f()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>m.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 b=new Function("try {return this===window;}catch(e){ return false;}");let g=new Set;function h(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 O(e){return e&&e instanceof HTMLElement}function E(e,t,r,n=!1,o=!1){let c={once:!1};n&&(c.capture=n),o&&(c.once=o),e.addEventListener(t,r,c)}function v(e,t,r){e.removeEventListener(t,r)}function w(e,t,r={}){let n=e;if(!n._mc){let t=k?.debug;k.debug=!1,n._mc=new k(e),k.debug=t,delete n._mc._mc}const o=n._mc;return t.length&&!o[t]&&(o[t]=r,e instanceof HTMLElement&&!e.getAttribute("_mc")&&e.setAttribute("_mc","")),r}function A(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 j(e,t,r={},n="l"){let o=e?._mc;if(!o)return;let c=t instanceof p?new p(t.type,t.data,"l"):new p(t,r,"l"),s="string"!=typeof t?t:new p(t,r,n);[...Object.values(o)].forEach((e=>{e?.trigger&&"function"==typeof e?.trigger&&e?.trigger(c)})),/[ud]/.test(s.bubble)&&_(e,s)}function _(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&&k.trigger(r,t)}t.bubble.indexOf("d")>-1&&new Set(e._mc.children().map((e=>e?.target))).forEach((e=>{e&&k.trigger(e,t)}))}),0)}b()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>g.add(e)));class S{#n;constructor(e,t=!1){var r;this.#n=new WeakRef(e||{}),(r=this).constructor!==k&&setTimeout((()=>{r.trigger("Init")}),0),function(e){if(!b()||e.constructor===k)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}/,""),s=c.toLowerCase();o&&Object.defineProperty(e,"on"+c,{configurable:!0,enumerable:!1,writable:!0,value:e=>{r.constructor.prototype[n].bind(r)(e)}}),g.has("on"+s)&&E(t,s,(e=>{r.trigger(c,e)}),!1,o)}))}}(this)}get target(){return this.#n.deref()}}class C extends S{_mc={};constructor(e){super(e)}static trigger=j;trigger(e,t={},r="l"){let n=this;if(n.constructor===C||n.constructor===k){let o=e instanceof p?new p(e.type,e.data,"l"):new p(e,t,"l"),c="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(o)})),void(/[ud]/.test(c.bubble)&&_(n.target,c))}if(n instanceof C||n instanceof k){const n=this,o="string"!=typeof e?e:new p(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)&&_(n.target,o)}}}class k extends S{_mc={};constructor(e,t=!1){super(e)}static add=w;static remove=A;static trigger=j;trigger(e,t={},r){C.prototype.trigger.call(this,e,t,r)}parent(e=""){let t=this.target;return O(t)?y(t.parentNode,e,!0):[]}ancestors(e=""){let t=this?.target;return O(t)?y(this.target.parentNode,e,!1):[]}children(e=""){let t=this?.target;if(!O(t))return[];const r=Math.random().toString().replace(".",""),n='[_mc]:not([temp_id="'+r+'"] [_mc] [_mc])';t.setAttribute("temp_id",r);const o=h([...t.querySelectorAll(n)],e);return t.removeAttribute("temp_id"),o}descendants(e=""){let t=this?.target;return O(t)?h([...t.querySelectorAll("*[_mc]")],e):[]}}const T=new Map,N=new Map;function L(e){const t="./"+e.split("-").join("/")+".js",r=document.createElement("script");return r.setAttribute("src",t),r.setAttribute("blocking","render"),r.async=!0,r.setAttribute("type","module"),r.setAttribute("name",e),r.setAttribute("loading",""),E(r,"load",(e=>{r.removeAttribute("loading"),r.setAttribute("loaded","")})),E(r,"error",(e=>{console.error("could not load Custom Element code from",t)})),r}function M(){[...document.querySelectorAll(":not(:defined)")].filter((e=>!!e&&!customElements.get(e.tagName.toLowerCase())&&!T.has(e.tagName.toLowerCase()))).forEach((e=>{const t=e.tagName.toLowerCase(),r=(t.split("-").join("/"),L(t));E(r,"load",(()=>{T.set(t,customElements.get(e.tagName.toLowerCase()))})),T.set(t,"loading"),document.head.append(r)})),[...document.querySelectorAll('[_mc]:not([_mc=""]')].filter((e=>!!e)).forEach((e=>{const t=e.getAttribute("_mc")?.split(" ").filter((e=>!!e))||[],r=t.filter((e=>!N.has(e)));r?.forEach((e=>{const t=L(e);E(t,"load",(()=>{return t=document.head.querySelector(`script[name="${e}"]`),void setTimeout((function(){const e=t.getAttribute("src"),r=t.getAttribute("name"),n=document.createElement("script");n.async=!0,n.setAttribute("type","module");const o=`\n\n\t\t\timport _ from "${e}";\n\t\t\timport {DC} from "./microcomponents.js";\n\n\t\t\tconst elements = Array.from(document.querySelectorAll('[_mc*="${r}"]')).filter( element => element instanceof HTMLElement );\n\n\t\t\telements.forEach((element) => {\n\t\t\t\t// add class to MCs repository\n\t\t\t\tautoload.state.MCs.set( '${r}', _ );\n\t\t\t\t// add instance to HTMLElement \n\t\t\t\tDC.add(element, _.name, new _(element));\n\t\t\t\t// remove instance name from elements "_mc" attribute\n\t\t\t\telement.setAttribute('_mc', element.getAttribute('_mc').replace('${r}', '').replace( /ww/g, ' ').trim()); \n\t\t\t});\n\n\t\t\tsetTimeout( () => {\n\t\t\t\tdocument.body.querySelector('script[name="${r}]"')?.remove();\n\t\t\t},0);\n\n\t\t`;n.innerHTML=o,document.body.append(n)}),0);var t})),N.set(e,"loading"),document.head.append(t)}));const n=t.filter((e=>N.has(e)&&!N.get(e).length));n?.forEach((t=>{setTimeout((()=>{k.add(e,t,new(D.state.MCs.get(t))(e)),e.getAttribute("_mc").replace("${elementName}","").replace(/\w\w/g," ").trim(),e.setAttribute("_mc")}),5)}))}))}let x=!1,P=null;function D(e=!0){return e?(x=e,P=new MutationObserver(M),setTimeout((()=>{P.observe(document.body,{childList:!0,subtree:!0}),M()}),5),x):(P?.disconnect(),P=null,x)}D.state={CEs:T,MCs:N};class H extends HTMLElement{constructor(){super()}connectedCallback(){k.trigger(this,"Connected")}disconnectedCallback(){k.trigger(this,"Disconnected")}adoptedCallback(){k.trigger(this,"Adopted")}attributeChangedCallback(e,t,r){k.trigger(this,"AttributeChanged",{name:e,oldValue:t,newValue:r})}}function q(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 H{instance;constructor(e){super();let r=new t(this,e);k.add(this,n,r)}static get observedAttributes(){return r}}))}function $(e){return customElements.get(e)}function I(e){return null!=e&&"object"==typeof e}function V(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,"")))}const F=[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement];class G extends k{data={};oldDisplay="";constructor(e){super(e);let t=this;V(e).forEach((e=>t.data[e]="")),J(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 s=c;o.forEach((e=>{s=s.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=s})),e.oldDisplay=t.getAttribute("style)")||"",r&&!F.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 J=(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 s=class extends r{#c=!0;constructor(e){super(e),this.constructor.callbacks=[],I(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(I(t.valueOf())){!function(e){var t;(t=e,(t instanceof HTMLElement?[t]:[]).concat([...t.querySelectorAll("*")]).filter((e=>!!V(e).length)).filter((e=>"STYLE"!==e.tagName))).forEach((e=>{e?._mc?._placeholders||k.add(e,"_placeholders",new G(e))}))}(e);const r=[...e.querySelectorAll("[_mc]")].filter((e=>!!e?._mc?._placeholders)),n=function(e){let t=o(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=I(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}},a=new s(n);Object.defineProperty(e,t,{enumerable:!0,get(){if(I(a.valueOf())){let e=structuredClone(Object.assign({},a));setTimeout(l((function(){c(structuredClone(Object.assign({},a)),e)||a.notify()}),0),0)}return a},set(e){if(typeof e==typeof a.valueOf())if(I(a.valueOf())&&a.valueOf()instanceof Array==0){let t=structuredClone(Object.assign({},a));a instanceof s==0&&(a=new s(structuredClone(Object.assign({},e))),d(e,a),a.seal()),Object.assign(a,e),setTimeout(l((function(){c(structuredClone(Object.assign({},a)),t)||a.notify()}),0),0)}else{let t=a.valueOf(),r=a.constructor.callbacks;a=new s(e),a.constructor.callbacks=r,e!==t&&a.notify()}else console.warn("IGNORED - cannot change observable types, IS:",typeof a.valueOf(),a,"- CANNOT BECOME:",typeof e)}}),e[t]=n})),e);class R{constructor(e){}}class B extends R{#s;constructor(e){super(e),this.#s=e}get val(){return new FormData(this.#s.form).get(this.#s.name)}set val(e){[...this.#s.form.querySelectorAll(`input[type="radio"][name="${this.#s.name}"]`)].filter((t=>t.getAttribute("value")===e)).shift().checked=!0}}class Z extends R{#s;constructor(e){super(e),this.#s=e}get val(){return this.#s.checked}set val(e){this.#s.checked=e}}class z extends R{#s;constructor(e){super(e),this.#s=e}get val(){return this.#s.value}set val(e){this.#s.value=e}}class U extends R{#s;#a=!1;constructor(e){super(e),this.#s=e,this.#a=e.multiple}get val(){const e=[];return[...this.#s.querySelectorAll("option")].filter((e=>e.selected)).forEach((t=>{e.push(t.value)})),this.#a?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.selected=!0:t.selected=!1}))}}class W extends R{#s;constructor(e){super(e),this.#s=e}get val(){return this.#s.value||""}set val(e){this.#s.value=e}}const Y=e=>{let t=[...(e||document).querySelectorAll("input,select,textarea")],r={};return t.forEach((e=>{const t=e.getAttribute("name");if(t){let n=!1;switch((e=>e.tagName.toLowerCase())(e)){case"input":switch(e.type){case"radio":n=new B(e);break;case"checkbox":n=new Z(e);break;default:n=new z(e)}break;case"select":n=new U(e);break;case"textarea":n=new W(e);break;default:console.warn("handler missing:",t,"for",e.tagName.toLowerCase(),e)}n&&(k.add(e,t,n),Object.defineProperty(r,t,{enumerable:!0,configurable:!0,get:()=>n.val,set:e=>{n.val!==e&&(n.val=e)}}))}})),r};function K(e,t,r){let n=Y(r);e[t]=Object.assign({},n),J(e,t),d(n,e[t]),[...r.querySelectorAll("input, textarea, select")].forEach((r=>{E(r,"keyup",(r=>{e[t].notify()})),E(r,"change",(r=>{e[t].notify()})),E(r,"select",(r=>{e[t].notify()}))}))}return t})()));
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ export * from './helpers.js';
3
+ export * from './MC.js';
4
+ export * from './McEvent.js';
5
+ export * from './elements.js';
6
+ export * from './observables.js';
7
+ //export * from './selectors.js';
8
+ export * from './formValues.js';
@@ -0,0 +1,10 @@
1
+ import { LooseObject } from './helpers.js';
2
+ type Callback = (value: any) => void;
3
+ export type Observable = {
4
+ observe: (cb: Callback) => void;
5
+ notify: () => void;
6
+ bind: (target: HTMLElement | DocumentFragment | ShadowRoot) => void;
7
+ };
8
+ export declare const observe: (target: LooseObject, propertyName?: string) => LooseObject;
9
+ export {};
10
+ //# sourceMappingURL=observables.d.ts.map
@@ -0,0 +1 @@
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;AAiLrC,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"}
@@ -0,0 +1,401 @@
1
+ 'use strict';
2
+
3
+ import {
4
+ LooseObject,
5
+ debounce,
6
+ deepEqual,
7
+ flattenObject,
8
+ copyGettersSetters,
9
+ } from './helpers.js';
10
+
11
+ import { DC, HTMLMcElement, McEvent } from './MC.js';
12
+
13
+ function isObservableObject(value: any): boolean {
14
+ return value != null && typeof value === 'object';
15
+ }
16
+
17
+ type Callback = (value: any) => void;
18
+
19
+ function getPlaceholders(target: HTMLElement): string[] {
20
+ let placeholders: Set<string> = new Set(),
21
+ regEx = /\{[^\{\}]*\}/g;
22
+
23
+ // scan attributes
24
+ target
25
+ .getAttributeNames()
26
+ .filter((attr) => target.getAttribute(attr)?.match(regEx)) // extract placeholder(s)
27
+ .forEach((attr) => {
28
+ let phs: Set<string> = new Set(target.getAttribute(attr)?.match(regEx));
29
+ phs.forEach((placeholder) =>
30
+ placeholders.add(placeholder.replace(/[\{\}]/g, ''))
31
+ );
32
+ });
33
+
34
+ // scan children text nodes
35
+ [...target.childNodes]
36
+ .filter((childNode) => {
37
+ return (
38
+ // is text node and has placeholders
39
+ childNode.nodeType === 3 &&
40
+ ((childNode as any).nodeValue || '').match(regEx)
41
+ );
42
+ })
43
+ .forEach((childNode) => {
44
+ ((childNode as any).nodeValue || '')
45
+ .match(regEx)
46
+ .forEach((placeholder: string) => {
47
+ placeholders.add(placeholder.replace(/[\{\}]/g, ''));
48
+ });
49
+ });
50
+
51
+ // extract {} and return result
52
+ return [...placeholders].map((placeholder) =>
53
+ placeholder.replace(/[\{\}]/g, '')
54
+ );
55
+ }
56
+
57
+ const inputs = [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement];
58
+
59
+ class Placeholders extends DC {
60
+ data: LooseObject = {};
61
+ oldDisplay?: string = '';
62
+
63
+ constructor(target: HTMLElement) {
64
+ super(target);
65
+ let that = this;
66
+ getPlaceholders(target).forEach((property) => (that.data[property] = ''));
67
+ observe(that);
68
+ that.#attachCallbacks();
69
+ delete that._mc; // cleanup, not needed
70
+ }
71
+
72
+ #attachCallbacks() {
73
+ let that = this,
74
+ target = that.target,
75
+ hide: boolean = false;
76
+
77
+ //console.log('attachCallbacks', that.target);
78
+
79
+ // scan attributes
80
+ target
81
+ .getAttributeNames()
82
+ .filter((attr: string) =>
83
+ target.getAttribute(attr)?.match(/\{[^\{\}]*\}/g)
84
+ ) // extract placeholder(s)
85
+ .forEach((attr: string) => {
86
+ let phs: Set<string> = new Set(
87
+ target.getAttribute(attr)?.match(/\{[^\{\}]*\}/g)
88
+ );
89
+ // attach callback
90
+ that.data.observe(
91
+ ((template: string) => (data: LooseObject) => {
92
+ let result: string = template;
93
+ phs.forEach((placeholder) => {
94
+ result = result.replace(
95
+ placeholder,
96
+ data[placeholder.replace(/[\{\}]/g, '')]
97
+ );
98
+ });
99
+ target.setAttribute(attr, result);
100
+ //console.log('cb setAttribute()', data, template, attr, result);
101
+ })(target.getAttribute(attr))
102
+ );
103
+ });
104
+
105
+ // scan children text nodes
106
+ [...target.childNodes]
107
+ .filter((childNode) => {
108
+ return (
109
+ // is text node and has placeholders
110
+ childNode.nodeType === 3 &&
111
+ ((childNode as any).nodeValue || '').match(/\{[^\{\}]*\}/g)
112
+ );
113
+ })
114
+ .forEach((childNode) => {
115
+ hide = true;
116
+ let phs: Set<string> = new Set(
117
+ childNode.nodeValue.match(/\{[^\{\}]*\}/g)
118
+ );
119
+
120
+ // attach callback
121
+ that.data.observe(
122
+ ((template: string) => (data: LooseObject) => {
123
+ let result: string = template;
124
+ //console.log('text node "', template, '" callbach data:', data);
125
+ phs.forEach((placeholder) => {
126
+ result = result.replace(
127
+ placeholder,
128
+ data[placeholder.replace(/[\{\}]/g, '')]
129
+ );
130
+ });
131
+ if (
132
+ Object.keys(data).some((key) => {
133
+ return !!data[key];
134
+ })
135
+ ) {
136
+ if (!!that.oldDisplay) {
137
+ target.style = that.oldDisplay;
138
+ } else {
139
+ target.removeAttribute('style');
140
+ }
141
+ delete that.oldDisplay;
142
+ }
143
+ childNode.nodeValue = result;
144
+ })(childNode.nodeValue)
145
+ );
146
+
147
+ // hide for now
148
+ that.oldDisplay = target.getAttribute('style)') || '';
149
+ if (
150
+ hide &&
151
+ !inputs.includes((target as any).constructor) &&
152
+ target.tagName !== 'FIELDSET'
153
+ ) {
154
+ target.style.display = 'none';
155
+ }
156
+ });
157
+ }
158
+
159
+ onData(ev: McEvent) {
160
+ let that = this,
161
+ data: LooseObject = {};
162
+ Object.keys(ev.data).forEach((key) => {
163
+ if (that.data.hasOwnProperty(key)) data[key] = ev.data[key];
164
+ });
165
+ //console.log('onData()', ev, data, that.data);
166
+ if (JSON.stringify(data) !== JSON.stringify(that.data))
167
+ Object.assign(that.data, data); // will trigger callbacks
168
+ }
169
+ }
170
+
171
+ function getPlaceholderElements(
172
+ target: HTMLElement | DocumentFragment | ShadowRoot
173
+ ): HTMLElement[] {
174
+ let elements: Array<HTMLElement> = (
175
+ target instanceof HTMLElement ? [target] : []
176
+ )
177
+ .concat([...(target.querySelectorAll('*') as unknown as HTMLElement[])])
178
+ .filter((e) => !!getPlaceholders(e as HTMLElement).length)
179
+ .filter((e) => e.tagName !== 'STYLE');
180
+ //console.log('getPlaceholderElements', elements);
181
+ return elements as HTMLElement[];
182
+ }
183
+
184
+ function makePlaceholders(
185
+ element: HTMLElement | DocumentFragment | ShadowRoot
186
+ ): void {
187
+ //console.log('makePlaceholders', element);
188
+ getPlaceholderElements(element).forEach((e: HTMLElement) => {
189
+ if ((e as HTMLMcElement)?._mc?._placeholders) return;
190
+ DC.add(e, '_placeholders', new Placeholders(e));
191
+ });
192
+ }
193
+
194
+ export type Observable = {
195
+ observe: (cb: Callback) => void;
196
+ notify: () => void;
197
+ bind: (target: HTMLElement | DocumentFragment | ShadowRoot) => void;
198
+ };
199
+
200
+ export const observe = (
201
+ target: LooseObject,
202
+ propertyName?: string
203
+ ): LooseObject => {
204
+ let keys = !propertyName
205
+ ? [...Object.getOwnPropertyNames(target)]
206
+ : [propertyName];
207
+
208
+ keys.forEach((key) => {
209
+ // console.log( 'co propname', key, typeof target[key], target[key] );
210
+ if (key[0] === '_' || target?.[key] === undefined) return target;
211
+ let val: any = target[key],
212
+ Constructor: any;
213
+
214
+ if (!val.prototype) {
215
+ switch (typeof val) {
216
+ case 'string':
217
+ Constructor = String;
218
+ break;
219
+ case 'number':
220
+ Constructor = Number;
221
+ break;
222
+ case 'boolean':
223
+ Constructor = Boolean;
224
+ break;
225
+ case 'object':
226
+ if (val instanceof Array) {
227
+ Constructor = Array;
228
+ } else {
229
+ Constructor = Object;
230
+ }
231
+ break;
232
+ default:
233
+ return;
234
+ }
235
+ }
236
+
237
+ let Observable = class extends Constructor {
238
+ #notify: boolean = true;
239
+
240
+ constructor(val: any) {
241
+ super(val);
242
+ (this.constructor as LooseObject).callbacks = [];
243
+ if (isObservableObject(val)) {
244
+ // you cannot bind native values to the dom
245
+ Object.getOwnPropertyNames(val).forEach((key) => {
246
+ this[key] = val[key];
247
+ });
248
+ }
249
+ }
250
+
251
+ observe(f: Function) {
252
+ //console.log('observe');
253
+ (this.constructor as any).callbacks.push(f);
254
+ return this;
255
+ }
256
+
257
+ bind(target: HTMLElement | DocumentFragment | ShadowRoot) {
258
+ const that = this,
259
+ iso = isObservableObject(that.valueOf());
260
+ //console.log('bind', iso, target);
261
+
262
+ if (iso) {
263
+ makePlaceholders(target);
264
+ const placeholders: unknown = [
265
+ ...target.querySelectorAll('[_mc]'),
266
+ ].filter((e) => !!(e as LooseObject)?._mc?._placeholders);
267
+ //console.log('placeholders:', target, placeholders);
268
+ const func = function callback(data: LooseObject) {
269
+ // avoid bubbling for speed
270
+ let d = flattenObject(data);
271
+ //console.log('inside callback', target, d);
272
+ (placeholders as DC[]).forEach((e) => {
273
+ // console.log('trigger callback', e);
274
+ if (!e) return;
275
+ (e as any)._mc.trigger('data', d);
276
+ });
277
+ };
278
+ (that.constructor as any).callbacks.push(func);
279
+ that.notify();
280
+ } else {
281
+ console.warn(
282
+ 'IGNORED - cannot bind a non-Object to the dom, IS:',
283
+ typeof that.valueOf(),
284
+ that
285
+ );
286
+ }
287
+
288
+ return this;
289
+ }
290
+
291
+ notify(notify?: boolean) {
292
+ let that = this,
293
+ data =
294
+ isObservableObject(that.valueOf()) &&
295
+ that.valueOf() instanceof Array === false
296
+ ? structuredClone(Object.assign({}, that))
297
+ : that.valueOf();
298
+
299
+ if (notify !== undefined) {
300
+ that.#notify = notify;
301
+ // return;
302
+ }
303
+
304
+ //if (that.#notify) console.log('notify', this, data);
305
+ (that.constructor as any).callbacks.forEach((f: Function) => {
306
+ // console.log(
307
+ // (this.constructor as any).callbacks,
308
+ // 'notify: exec callback',
309
+ // f,
310
+ // data
311
+ // );
312
+ f(data);
313
+ });
314
+
315
+ return that;
316
+ }
317
+ };
318
+
319
+ let o = new Observable(val);
320
+
321
+ Object.defineProperty(target, key, {
322
+ enumerable: true,
323
+ get() {
324
+ if (isObservableObject(o.valueOf())) {
325
+ let check = structuredClone(Object.assign({}, o));
326
+ setTimeout(
327
+ debounce(function checkChanges() {
328
+ let state = structuredClone(Object.assign({}, o));
329
+ //console.log( 'check changes', state, check );
330
+ if (!deepEqual(state, check)) {
331
+ //console.log( '-> not equal!' );
332
+ o.notify();
333
+ }
334
+ }, 0),
335
+ 0
336
+ );
337
+ }
338
+ return o;
339
+ },
340
+ set(val: any) {
341
+ //console.log( 'SET:', isObservableObject( val.valueOf() ), 'set:', val, 'to', isObservableObject( o.valueOf() ), o, );
342
+ if (typeof val === typeof o.valueOf()) {
343
+ let iso =
344
+ isObservableObject(o.valueOf()) &&
345
+ o.valueOf() instanceof Array === false;
346
+ //console.log('target iso:', iso);
347
+ if (iso) {
348
+ let old = structuredClone(Object.assign({}, o));
349
+ //val = structuredClone(Object.assign({}, val));
350
+
351
+ //let callbacks = (o.constructor as LooseObject).callbacks;
352
+ if (o instanceof Observable === false) {
353
+ o = new Observable(structuredClone(Object.assign({}, val)));
354
+ copyGettersSetters(val, o);
355
+ o.seal();
356
+ }
357
+ Object.assign(o, val);
358
+
359
+ // console.log('after set o=', o, 'check', old);
360
+ // (o.constructor as LooseObject).callbacks = callbacks;
361
+
362
+ setTimeout(
363
+ // check for changes
364
+ debounce(function checkChanges() {
365
+ let state = structuredClone(Object.assign({}, o));
366
+ //console.log( 'check changes', state, check );
367
+ if (!deepEqual(state, old)) {
368
+ //console.log( '-> not equal!' );
369
+ o.notify();
370
+ }
371
+ }, 0),
372
+ 0
373
+ );
374
+ } else {
375
+ // simple native var
376
+ let old = o.valueOf(),
377
+ callbacks = (o.constructor as LooseObject).callbacks;
378
+ o = new Observable(val);
379
+ (o.constructor as LooseObject).callbacks = callbacks;
380
+ if (val !== old) {
381
+ o.notify();
382
+ }
383
+ }
384
+ } else {
385
+ console.warn(
386
+ 'IGNORED - cannot change observable types, IS:',
387
+ typeof o.valueOf(),
388
+ o,
389
+ '- CANNOT BECOME:',
390
+ typeof val
391
+ );
392
+ }
393
+ },
394
+ });
395
+
396
+ // replace old property with proxy (observable)
397
+ target[key] = val;
398
+ });
399
+
400
+ return target;
401
+ };
@@ -0,0 +1,108 @@
1
+ import { MC, DC } from './MC.js';
2
+ import { LooseObject } from './helpers.js';
3
+ declare class DomSelector {
4
+ #private;
5
+ get set(): Set<HTMLElement>;
6
+ get array(): HTMLElement[];
7
+ set set(set: Set<HTMLElement>);
8
+ get length(): number;
9
+ constructor(selection?: selection, element?: any);
10
+ $t(nameSpace?: string): TSelector;
11
+ add(selection: selection, target?: HTMLElement): DSelector;
12
+ addClass(...classes: string[]): DSelector;
13
+ after(selection: selection, target?: HTMLElement): DSelector;
14
+ append(selection: selection, target?: HTMLElement): DSelector;
15
+ appendTo(selection: selection, target?: HTMLElement): DSelector;
16
+ attr(): LooseObject;
17
+ attr(obj: LooseObject): DSelector;
18
+ attr(name: string): string | null;
19
+ attr(first?: string | LooseObject, second?: string | object | null): DSelector;
20
+ before(selection: selection, target?: HTMLElement): DSelector;
21
+ children(selection?: selection, rootNode?: HTMLElement): DSelector;
22
+ descendants(selection?: selection, rootNode?: HTMLElement): DSelector;
23
+ empty(): DSelector;
24
+ first(selection?: selection, rootNode?: HTMLElement): DSelector;
25
+ has(element: HTMLElement): boolean;
26
+ hasClass(...classes: string[]): boolean;
27
+ html(html?: string): string | DSelector;
28
+ last(selection?: selection, rootNode?: HTMLElement): DSelector;
29
+ next(selection?: selection, rootNode?: HTMLElement): DSelector;
30
+ normalize(): DSelector;
31
+ off(eventName: string, cb: Function): DSelector;
32
+ on(eventName: string, cb: Function, capture?: boolean, once?: boolean): Function;
33
+ one(eventName: string, cb: Function, capture?: boolean): Function;
34
+ parent(selection?: selection, rootNode?: HTMLElement): DSelector;
35
+ parents(selection?: selection, rootNode?: HTMLElement): DSelector;
36
+ prepend(selection: selection, target?: HTMLElement): DSelector;
37
+ prev(selection?: selection, rootNode?: HTMLElement): DSelector;
38
+ removeClass(...classes: string[]): DSelector;
39
+ text(text?: string): string | DSelector;
40
+ toggleClass(...classes: string[]): DSelector;
41
+ trigger(eventName: string, data?: any, bubbles?: boolean, cancelable?: boolean, composed?: boolean): DSelector;
42
+ val(p1?: any, p2?: any): any;
43
+ values(values?: LooseObject): LooseObject;
44
+ at(index: number): DSelector;
45
+ concat(items: DSelector | any[]): DSelector;
46
+ entries(): IterableIterator<[number, any]>;
47
+ every(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
48
+ filter(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): DSelector;
49
+ forEach(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): DSelector;
50
+ includes(item: HTMLElement): boolean;
51
+ indexOf(item: HTMLElement, start?: number): number;
52
+ map(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): Array<any>;
53
+ pop(): HTMLElement;
54
+ push(...items: HTMLElement[]): DSelector;
55
+ shift(): HTMLElement | undefined;
56
+ slice(start: number, end?: number): DSelector;
57
+ some(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
58
+ splice(start: number, deleteCount?: number | undefined): DSelector;
59
+ }
60
+ export interface DSelector extends DomSelector {
61
+ }
62
+ declare class TbSelector {
63
+ #private;
64
+ get set(): Set<any>;
65
+ get array(): any[];
66
+ set set(set: Set<any>);
67
+ get length(): number;
68
+ set length(value: number);
69
+ constructor(selection?: selection, element?: HTMLElement);
70
+ $d(selection?: selection, element?: HTMLElement): DSelector;
71
+ children(nameSpace?: string): TSelector;
72
+ descendants(nameSpace?: string): TSelector;
73
+ first(nameSpace?: string): TSelector;
74
+ has(element: any): boolean;
75
+ last(nameSpace?: string): TSelector;
76
+ next(nameSpace?: string): TSelector;
77
+ ns(nameSpace: string): TSelector;
78
+ off(name: string, cb: Function): TSelector;
79
+ on(name: string, cb: Function, once?: boolean): Function;
80
+ one(name: string, cb: Function): Function;
81
+ parent(nameSpace?: string): TSelector;
82
+ parents(nameSpace?: string): TSelector;
83
+ prev(nameSpace?: string): TSelector;
84
+ trigger(ev: string, data?: any, bubble?: string): TSelector;
85
+ at(index: number): TSelector;
86
+ concat(items: TSelector): TSelector;
87
+ entries(): IterableIterator<[number, any]>;
88
+ every(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
89
+ filter(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): TSelector;
90
+ forEach(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): TSelector;
91
+ includes(item: any): boolean;
92
+ indexOf(item: any, start?: number): number;
93
+ map(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): Array<any>;
94
+ pop(): any;
95
+ push(item: any): TSelector;
96
+ shift(): any | undefined;
97
+ slice(start: number, end?: number): TSelector;
98
+ some(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
99
+ splice(start: number, deleteCount?: number | undefined): TSelector;
100
+ }
101
+ export interface TSelector extends TbSelector {
102
+ }
103
+ export declare const $d: (selection: selection, element?: any) => DSelector;
104
+ export declare const $t: (selection?: selection, element?: any) => TSelector;
105
+ export type singleSelector = string | ShadowRoot | HTMLElement | HTMLElement[] | HTMLCollection | NodeList | DSelector | MC | DC | TSelector | undefined;
106
+ export type selection = singleSelector | singleSelector[];
107
+ export {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