@twobirds/microcomponents 0.0.45 → 0.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MC.min.js +7 -56
- package/dist/microcomponents.min.js +1 -1
- package/dist/observables.d.ts.map +1 -1
- package/dist/observables.min.js +1 -1
- package/dist/observables.ts +7 -16
- package/dist/test.ts +0 -4
- package/package.json +1 -1
- package/public/MC.js +7 -52
- package/public/MC.js.map +1 -1
- package/public/MC.min.js +7 -56
- package/public/McEvent.js +0 -4
- package/public/McEvent.js.map +1 -1
- package/public/assets/search.js +1 -1
- package/public/autoloader.js +1 -6
- package/public/autoloader.js.map +1 -1
- package/public/classes/MC.DC.html +18 -23
- package/public/classes/MC.MC.html +12 -17
- package/public/classes/MC.McBase.html +4 -4
- package/public/classes/MC.McEvent.html +13 -13
- package/public/formValues.js +3 -19
- package/public/formValues.js.map +1 -1
- package/public/functions/MC.addListener.html +1 -1
- package/public/functions/MC.removeListener.html +1 -1
- package/public/functions/elements.defineCE.html +1 -1
- package/public/functions/elements.getCE.html +1 -1
- package/public/functions/formValues.formValues.html +1 -1
- package/public/functions/observables.observe.html +1 -1
- package/public/functions/selectors._d.html +1 -1
- package/public/functions/selectors._t.html +1 -1
- package/public/helpers.js +4 -5
- package/public/helpers.js.map +1 -1
- package/public/interfaces/MC.HTMLMcElement.html +2 -2
- package/public/interfaces/selectors.DSelector.html +55 -55
- package/public/interfaces/selectors.TSelector.html +37 -37
- package/public/microcomponents.es3.js +15 -61
- package/public/microcomponents.es3.js.map +1 -1
- package/public/microcomponents.min.js +1 -1
- package/public/modules/MC.html +1 -1
- package/public/modules/elements.html +1 -1
- package/public/modules/formValues.html +1 -1
- package/public/modules/observables.html +1 -1
- package/public/modules/selectors.html +1 -1
- package/public/observables.js +12 -56
- package/public/observables.js.map +1 -1
- package/public/observables.min.js +1 -1
- package/public/selectors.js +7 -125
- package/public/selectors.js.map +1 -1
- package/public/src/observables.ts +7 -16
- package/public/src/test.ts +0 -4
- package/public/test.js +6 -30
- package/public/test.js.map +1 -1
- package/public/types/observables.Observable.html +1 -1
- package/public/types/selectors.selection.html +1 -1
- package/public/types/selectors.singleSelector.html +1 -1
- package/src/observables.ts +7 -16
- package/src/test.ts +0 -4
- package/tsconfig.json +97 -101
package/dist/MC.min.js
CHANGED
|
@@ -61,7 +61,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
61
61
|
|
|
62
62
|
var isBrowser = new Function("try {return this===window;}catch(e){ return false;}");
|
|
63
63
|
let nativeEventNames = new Set();
|
|
64
|
-
// HTMLElement native event names
|
|
65
64
|
if (isBrowser()) {
|
|
66
65
|
Object.keys(HTMLElement.prototype).filter(key => /^on/.test(key)).forEach(eventName => nativeEventNames.add(eventName));
|
|
67
66
|
}
|
|
@@ -73,7 +72,6 @@ class McEvent {
|
|
|
73
72
|
#stopped = false;
|
|
74
73
|
#immediateStopped = false;
|
|
75
74
|
constructor(type, data = {}, bubble = 'l') {
|
|
76
|
-
// bubble standard = local only, options = any combination of'uld' characters: up to root, local, down
|
|
77
75
|
this.#type = type;
|
|
78
76
|
this.data = data;
|
|
79
77
|
this.bubble = bubble;
|
|
@@ -95,7 +93,6 @@ class McEvent {
|
|
|
95
93
|
this.#immediateStopped = true;
|
|
96
94
|
}
|
|
97
95
|
}
|
|
98
|
-
// get all microcomponents from a list of HTMLElements
|
|
99
96
|
function getMicroComponents(elements, search) {
|
|
100
97
|
let mcValues = [];
|
|
101
98
|
elements.forEach(e => {
|
|
@@ -113,7 +110,6 @@ function getMicroComponents(elements, search) {
|
|
|
113
110
|
});
|
|
114
111
|
return mcValues;
|
|
115
112
|
}
|
|
116
|
-
// get all ancestor DOM nodes up to the document root
|
|
117
113
|
function traverseNodes(node, search, firstonly = true) {
|
|
118
114
|
let mcValues = [];
|
|
119
115
|
while (node) {
|
|
@@ -138,13 +134,11 @@ function traverseNodes(node, search, firstonly = true) {
|
|
|
138
134
|
|
|
139
135
|
var MC_isBrowser = new Function('try {return this===window;}catch(e){ return false;}');
|
|
140
136
|
let MC_nativeEventNames = new Set();
|
|
141
|
-
// HTMLElement native event names
|
|
142
137
|
if (MC_isBrowser()) {
|
|
143
138
|
Object.keys(HTMLElement.prototype)
|
|
144
139
|
.filter((key) => /^on/.test(key))
|
|
145
140
|
.forEach((eventName) => MC_nativeEventNames.add(eventName));
|
|
146
141
|
}
|
|
147
|
-
// get all microcomponents from a list of HTMLElements
|
|
148
142
|
function MC_getMicroComponents(elements, search) {
|
|
149
143
|
let mcValues = [];
|
|
150
144
|
elements.forEach((e) => {
|
|
@@ -162,7 +156,6 @@ function MC_getMicroComponents(elements, search) {
|
|
|
162
156
|
});
|
|
163
157
|
return mcValues;
|
|
164
158
|
}
|
|
165
|
-
// get all ancestor DOM nodes up to the document root
|
|
166
159
|
function MC_traverseNodes(node, search, firstonly = true) {
|
|
167
160
|
let mcValues = [];
|
|
168
161
|
while (node) {
|
|
@@ -191,44 +184,36 @@ function addListener(domNode, eventName, handler, capture = false, once = false)
|
|
|
191
184
|
if (once) {
|
|
192
185
|
options.once = once;
|
|
193
186
|
}
|
|
194
|
-
//console.log( 'addEventListener', eventName, ( handler as Function ).name, options );
|
|
195
187
|
domNode.addEventListener(eventName, handler, options);
|
|
196
188
|
}
|
|
197
189
|
function removeListener(domNode, eventName, handler) {
|
|
198
190
|
domNode.removeEventListener(eventName, handler);
|
|
199
191
|
}
|
|
200
|
-
// add a microcomponent to a target DOM node
|
|
201
192
|
function add(target, key, element = {}) {
|
|
202
193
|
let node = target;
|
|
203
|
-
// create the _mc property if necessary
|
|
204
194
|
if (!node._mc) {
|
|
205
195
|
let debug = DC?.debug;
|
|
206
196
|
DC.debug = false;
|
|
207
197
|
node._mc = new DC(target);
|
|
208
198
|
DC.debug = debug;
|
|
209
|
-
delete node._mc._mc;
|
|
199
|
+
delete node._mc._mc;
|
|
210
200
|
}
|
|
211
201
|
const _mc = node._mc;
|
|
212
|
-
// add the element with the given property key to the _mc property
|
|
213
202
|
if (key.length && !_mc[key]) {
|
|
214
203
|
_mc[key] = element;
|
|
215
|
-
// add attribute if HTMLElement
|
|
216
204
|
if (target instanceof HTMLElement) {
|
|
217
205
|
target.setAttribute('_mc', '');
|
|
218
206
|
}
|
|
219
207
|
}
|
|
220
208
|
return element;
|
|
221
209
|
}
|
|
222
|
-
// remove a micro component from the DOM
|
|
223
210
|
function remove(target, key) {
|
|
224
211
|
if (!key)
|
|
225
|
-
return;
|
|
212
|
+
return;
|
|
226
213
|
const _mc = target?._mc || {};
|
|
227
|
-
// delete the property from the HTMLElement _mc collection
|
|
228
214
|
if (_mc && _mc[key]) {
|
|
229
215
|
delete _mc[key];
|
|
230
216
|
}
|
|
231
|
-
// remove the _mc attribute if the DOM collection is empty
|
|
232
217
|
if (!Object.keys(_mc).length &&
|
|
233
218
|
target instanceof HTMLElement &&
|
|
234
219
|
target.hasAttribute('_mc')) {
|
|
@@ -236,7 +221,6 @@ function remove(target, key) {
|
|
|
236
221
|
}
|
|
237
222
|
return;
|
|
238
223
|
}
|
|
239
|
-
// trigger an event
|
|
240
224
|
function trigger(target, ev, data = {}, bubble = 'l') {
|
|
241
225
|
let _mc = target?._mc;
|
|
242
226
|
if (!_mc)
|
|
@@ -245,7 +229,6 @@ function trigger(target, ev, data = {}, bubble = 'l') {
|
|
|
245
229
|
? new McEvent(ev.type, ev.data, 'l')
|
|
246
230
|
: new McEvent(ev, data, 'l'), mcEvent = typeof ev !== 'string' ? ev : new McEvent(ev, data, bubble);
|
|
247
231
|
[...Object.values(_mc)].forEach((mc) => {
|
|
248
|
-
//console.log( 'mc [', mc.constructor.name, ']', mc.constructor.prototype?.oneInit );
|
|
249
232
|
if (mc?.trigger && typeof mc?.trigger === 'function') {
|
|
250
233
|
mc?.trigger(event);
|
|
251
234
|
}
|
|
@@ -255,25 +238,11 @@ function trigger(target, ev, data = {}, bubble = 'l') {
|
|
|
255
238
|
}
|
|
256
239
|
return;
|
|
257
240
|
}
|
|
258
|
-
// run the "init" lifecycle event on the complete _mc structure
|
|
259
241
|
function init(element) {
|
|
260
242
|
if (element.constructor === DC)
|
|
261
243
|
return;
|
|
262
244
|
setTimeout(() => {
|
|
263
245
|
element.trigger('Init');
|
|
264
|
-
/*
|
|
265
|
-
let keys = Object.keys( ( element as any)?._mc );
|
|
266
|
-
if ( keys.length ){
|
|
267
|
-
//console.log( 'inner Inits on [', mc.constructor.name, ']', keys );
|
|
268
|
-
keys?.forEach( (key: string) => {
|
|
269
|
-
let mc = ( element as any)?._mc?.[key];
|
|
270
|
-
//console.log( key, typeof mc?.oneInit, mc );
|
|
271
|
-
if ( ( mc as any )['oneInit'] && typeof ( mc as any ).oneInit == 'function' ){
|
|
272
|
-
( mc as any ).oneInit( new McEvent('Init') );
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
};
|
|
276
|
-
*/
|
|
277
246
|
}, 0);
|
|
278
247
|
}
|
|
279
248
|
function autoAttachListeners(element) {
|
|
@@ -286,46 +255,36 @@ function autoAttachListeners(element) {
|
|
|
286
255
|
.filter((key) => /^on[A-Z]|one[A-Z]/.test(key) &&
|
|
287
256
|
typeof that.constructor.prototype[key] === 'function')
|
|
288
257
|
.forEach((key) => {
|
|
289
|
-
let once = /^one/.test(key), withoutOnOne = key.replace(/^on[e]{0,1}/, ''),
|
|
290
|
-
nativeEventName = withoutOnOne.toLowerCase(), listener = (ev) => {
|
|
258
|
+
let once = /^one/.test(key), withoutOnOne = key.replace(/^on[e]{0,1}/, ''), nativeEventName = withoutOnOne.toLowerCase(), listener = (ev) => {
|
|
291
259
|
that.trigger(withoutOnOne, ev);
|
|
292
260
|
};
|
|
293
261
|
if (once) {
|
|
294
|
-
// console.log( '...is only called once', that.constructor.prototype[key] );
|
|
295
262
|
Object.defineProperty(element, 'on' + withoutOnOne, {
|
|
296
263
|
configurable: true,
|
|
297
264
|
enumerable: false,
|
|
298
265
|
writable: true,
|
|
299
266
|
value: (ev) => {
|
|
300
|
-
// console.log( 'onceHandler execute:', that.constructor.prototype[key] );
|
|
301
267
|
that.constructor.prototype[key].bind(that)(ev);
|
|
302
268
|
},
|
|
303
269
|
});
|
|
304
270
|
}
|
|
305
271
|
if (MC_nativeEventNames.has('on' + nativeEventName)) {
|
|
306
|
-
// native event defined in HTMLElement
|
|
307
|
-
// console.log('added as native listener', target, nativeEventName );
|
|
308
272
|
addListener(target, nativeEventName, listener, false, once);
|
|
309
273
|
}
|
|
310
274
|
});
|
|
311
275
|
}
|
|
312
276
|
}
|
|
313
277
|
function bubbleEvent(target, ev) {
|
|
314
|
-
// at this point, either 'u' or 'd' bubbling should be indicated
|
|
315
|
-
// mcEvent bubbling is asynchronous, and the order of target MC execution in case of multiple matches is not guaranteed!
|
|
316
278
|
if (/[ud]/.test(ev.bubble)) {
|
|
317
279
|
setTimeout(() => {
|
|
318
|
-
// bubbling must include 'l' for local, or else no handlers are executed'
|
|
319
280
|
if (ev.bubble.indexOf('l') === -1) {
|
|
320
281
|
ev.bubble += 'l';
|
|
321
282
|
}
|
|
322
|
-
// bubble up towards root
|
|
323
283
|
if (ev.bubble.indexOf('u') > -1) {
|
|
324
284
|
let parent = MC_traverseNodes(target, '', true)?.[0].target;
|
|
325
285
|
if (parent)
|
|
326
286
|
DC.trigger(parent, ev);
|
|
327
287
|
}
|
|
328
|
-
// bubble down
|
|
329
288
|
if (ev.bubble.indexOf('d') > -1) {
|
|
330
289
|
let targets = new Set(target._mc
|
|
331
290
|
.children()
|
|
@@ -339,11 +298,11 @@ function bubbleEvent(target, ev) {
|
|
|
339
298
|
}
|
|
340
299
|
}
|
|
341
300
|
class McBase {
|
|
342
|
-
#target;
|
|
301
|
+
#target;
|
|
343
302
|
constructor(target, debug = false) {
|
|
344
303
|
let that = this, element = that;
|
|
345
304
|
this.#target = new WeakRef(target || {});
|
|
346
|
-
init(element);
|
|
305
|
+
init(element);
|
|
347
306
|
autoAttachListeners(element);
|
|
348
307
|
}
|
|
349
308
|
get target() {
|
|
@@ -358,8 +317,6 @@ class MC extends McBase {
|
|
|
358
317
|
static trigger = trigger;
|
|
359
318
|
trigger(ev, data = {}, bubble = 'l') {
|
|
360
319
|
let that = this;
|
|
361
|
-
//console.log( that, '.trigger(', ev, data, bubble, ')' );
|
|
362
|
-
// run all triggers
|
|
363
320
|
if (that.constructor === MC || that.constructor === DC) {
|
|
364
321
|
let event = ev instanceof McEvent
|
|
365
322
|
? new McEvent(ev.type, ev.data, 'l')
|
|
@@ -375,30 +332,24 @@ class MC extends McBase {
|
|
|
375
332
|
if (/[ud]/.test(mcEvent.bubble)) {
|
|
376
333
|
bubbleEvent(that.target, mcEvent);
|
|
377
334
|
}
|
|
378
|
-
return;
|
|
335
|
+
return;
|
|
379
336
|
}
|
|
380
|
-
// only this instance
|
|
381
337
|
if (that instanceof MC || that instanceof DC) {
|
|
382
338
|
const that = this, mcEvent = typeof ev !== 'string'
|
|
383
339
|
? ev
|
|
384
340
|
: new McEvent(ev, data, bubble), handlerName = 'on' + mcEvent.type[0].toUpperCase() + mcEvent.type.slice(1);
|
|
385
|
-
// console.log('trigger', handlerName, mcEvent, data, bubble );
|
|
386
341
|
if (mcEvent.bubble.indexOf('l') > -1) {
|
|
387
342
|
if (!mcEvent.immediateStopped &&
|
|
388
343
|
typeof that[handlerName] === 'function') {
|
|
389
|
-
// console.log( 'execute handler:', handlerName );
|
|
390
344
|
that[handlerName](mcEvent);
|
|
391
345
|
if (that.hasOwnProperty(handlerName)) {
|
|
392
|
-
|
|
393
|
-
delete that[handlerName]; // remove after first execution
|
|
346
|
+
delete that[handlerName];
|
|
394
347
|
}
|
|
395
348
|
}
|
|
396
349
|
}
|
|
397
|
-
// if event stopped or local only, handling is cancelled
|
|
398
350
|
if (mcEvent.stopped || mcEvent.bubble === 'l') {
|
|
399
351
|
return that;
|
|
400
352
|
}
|
|
401
|
-
//console.log('bubble', mcEvent);
|
|
402
353
|
if (/[ud]/.test(mcEvent.bubble)) {
|
|
403
354
|
bubbleEvent(that.target, mcEvent);
|
|
404
355
|
}
|
|
@@ -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 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)}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:()=>o,observe:()=>P,parse:()=>c,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"),o="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(o.bubble)&&A(e,o)}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}/,""),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)&&E(t,o,(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.oldDisplay=e.style.display,M.includes(e.constructor)||(e.style.display="none"),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 o=a;n.forEach((e=>{o=o.replace(e,s[e.replace(/[\{\}]/g,"")])})),Object.keys(s).some((e=>!!s[e]))&&(t.style.display=e.oldDisplay,delete e.oldDisplay),r.nodeValue=o}))}))}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 o=class extends r{constructor(e){super(e),this.constructor.callbacks=[],C(e)&&(this.constructor.bound=[],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)})),C(e.valueOf())&&e.constructor.bound.forEach((e=>{e(t)})),this}},c=new o(n);Object.defineProperty(e,t,{enumerable:!0,get(){if(C(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(C(c.valueOf())&&c.valueOf()instanceof Array==0){let t=structuredClone(Object.assign({},c));e=structuredClone(Object.assign({},e));let r=c.constructor?.hasFormHandler??!1,n=c.constructor.callbacks,a=c.constructor.bound;c=new o(structuredClone(Object.assign({},e))),c.constructor.callbacks=r,c.constructor.callbacks=n,c.constructor.bound=a,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=>{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;#o;constructor(e,t){super(e),this.#s=e,this.#e=e.type,this.#o=t}get val(){let e,t=this;switch(t.#e){case"radio":const r=J(`input[type="radio"][name="${this.#s.getAttribute("name")}"]`,this.#o).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.#o);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;#c=!1;constructor(e){super(e),this.#s=e,this.#c="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.#c?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 o(){o.cb.apply(a,Array.from(arguments))}return o.cb=t,a.forEach((e=>{s.forEach((function(t){E(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){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,o={bubbles:r,cancelable:n,composed:a},c=e.indexOf(" ")>-1?e.split(" "):[e];return this.#i.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=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;#o;constructor(e,t){super(e),this.#s=e,this.#e=e.type,this.#o=t}get val(){let e,t=this;switch(t.#e){case"radio":const r=[...(this.#o||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.#o||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;#c=!1;constructor(e){super(e),this.#s=e,this.#c="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.#c?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 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 +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;
|
|
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"}
|
package/dist/observables.min.js
CHANGED
|
@@ -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
|
|
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})()));
|
package/dist/observables.ts
CHANGED
|
@@ -70,10 +70,6 @@ class Placeholders extends DC {
|
|
|
70
70
|
let that = this;
|
|
71
71
|
getPlaceholders(target).forEach((property) => (that.data[property] = ''));
|
|
72
72
|
observe(that);
|
|
73
|
-
that.oldDisplay = target.style.display;
|
|
74
|
-
if (!inputs.includes((target as any).constructor)) {
|
|
75
|
-
target.style.display = 'none';
|
|
76
|
-
}
|
|
77
73
|
that.#attachCallbacks();
|
|
78
74
|
delete that._mc; // cleanup, not needed
|
|
79
75
|
}
|
|
@@ -145,6 +141,12 @@ class Placeholders extends DC {
|
|
|
145
141
|
childNode.nodeValue = result;
|
|
146
142
|
})(childNode.nodeValue)
|
|
147
143
|
);
|
|
144
|
+
|
|
145
|
+
// hide for now
|
|
146
|
+
that.oldDisplay = target.getAttribute('style)') || '';
|
|
147
|
+
if (!inputs.includes((target as any).constructor)) {
|
|
148
|
+
target.style.display = 'none';
|
|
149
|
+
}
|
|
148
150
|
});
|
|
149
151
|
}
|
|
150
152
|
|
|
@@ -226,7 +228,6 @@ export const observe = (target: LooseObject, propertyName?: string) => {
|
|
|
226
228
|
(this.constructor as LooseObject).callbacks = [];
|
|
227
229
|
if (isObservableObject(val)) {
|
|
228
230
|
// you cannot bind native values to the dom
|
|
229
|
-
(this.constructor as LooseObject).bound = [];
|
|
230
231
|
Object.getOwnPropertyNames(val).forEach((key) => {
|
|
231
232
|
this[key] = val[key];
|
|
232
233
|
});
|
|
@@ -274,18 +275,10 @@ export const observe = (target: LooseObject, propertyName?: string) => {
|
|
|
274
275
|
that.valueOf() instanceof Array === false
|
|
275
276
|
? structuredClone(Object.assign({}, that))
|
|
276
277
|
: that.valueOf();
|
|
277
|
-
// console.log('notify', that.constructor, (that.constructor as any).callbacks.length, (that.constructor as any)?.bound?.length, data );
|
|
278
278
|
(that.constructor as any).callbacks.forEach((f: Function) => {
|
|
279
279
|
// console.log( 'callback', f, data);
|
|
280
280
|
f(data);
|
|
281
281
|
});
|
|
282
|
-
if (isObservableObject(that.valueOf())) {
|
|
283
|
-
// console.log('bound', this.constructor);
|
|
284
|
-
(that.constructor as any).bound.forEach((f: Function) => {
|
|
285
|
-
// console.log( 'bound', f, data);
|
|
286
|
-
f(data);
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
282
|
return this;
|
|
290
283
|
}
|
|
291
284
|
};
|
|
@@ -326,14 +319,12 @@ export const observe = (target: LooseObject, propertyName?: string) => {
|
|
|
326
319
|
|
|
327
320
|
let hasFormHandler =
|
|
328
321
|
(o.constructor as LooseObject)?.hasFormHandler ?? false,
|
|
329
|
-
callbacks = (o.constructor as LooseObject).callbacks
|
|
330
|
-
bound = (o.constructor as LooseObject).bound;
|
|
322
|
+
callbacks = (o.constructor as LooseObject).callbacks;
|
|
331
323
|
o = new Observable(structuredClone(Object.assign({}, val)));
|
|
332
324
|
|
|
333
325
|
//console.log('after set o=', o, 'check', old);
|
|
334
326
|
(o.constructor as LooseObject).callbacks = hasFormHandler;
|
|
335
327
|
(o.constructor as LooseObject).callbacks = callbacks;
|
|
336
|
-
(o.constructor as LooseObject).bound = bound;
|
|
337
328
|
|
|
338
329
|
setTimeout(
|
|
339
330
|
// check for changes
|
package/dist/test.ts
CHANGED
|
@@ -110,10 +110,6 @@ defineCE(
|
|
|
110
110
|
(that.Dom as Observable).bind(that.target);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
onAttributeChanged(ev: McEvent) {
|
|
114
|
-
this.target._mc.translator.Language = ev.data.newValue;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
113
|
onClick(ev: McEvent) {
|
|
118
114
|
const that = this,
|
|
119
115
|
c = this.Dom.counter++;
|