@twobirds/microcomponents 0.0.33 → 0.0.37
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/README.md +40 -27
- package/assets/documentation/{MicroComponents.md → MC.md} +17 -17
- package/assets/documentation/comparision.md +0 -0
- package/assets/documentation/elements.md +276 -0
- package/assets/documentation/magic.md +10 -68
- package/dist/MC.d.ts +2 -3
- package/dist/MC.d.ts.map +1 -1
- package/dist/MC.min.js +45 -43
- package/dist/MC.ts +173 -175
- package/dist/autoloader.ts +1 -1
- package/dist/{customElements.d.ts → elements.d.ts} +1 -1
- package/dist/elements.d.ts.map +1 -0
- package/dist/elements.min.js +1 -0
- package/dist/{customElements.ts → elements.ts} +23 -14
- package/dist/helpers.d.ts +6 -4
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.ts +95 -128
- package/dist/microcomponents.d.ts +3 -3
- package/dist/microcomponents.d.ts.map +1 -1
- package/dist/microcomponents.min.js +1 -1
- package/dist/microcomponents.ts +3 -3
- package/dist/{customObservables.d.ts → observables.d.ts} +3 -3
- package/dist/observables.d.ts.map +1 -0
- package/dist/observables.min.js +1 -0
- package/dist/observables.ts +354 -0
- package/dist/{customSelectors.d.ts → selectors.d.ts} +1 -1
- package/dist/selectors.d.ts.map +1 -0
- package/dist/selectors.min.js +1 -0
- package/dist/test.ts +133 -157
- package/klemmstein.png +0 -0
- package/package.json +52 -52
- package/public/MC.js +46 -44
- package/public/MC.js.map +1 -1
- package/public/MC.min.js +45 -43
- package/public/assets/search.js +1 -1
- package/public/autoloader.js +1 -1
- package/public/autoloader.js.map +1 -1
- package/public/classes/{DC.html → MC.DC.html} +60 -59
- package/public/classes/{MC.html → MC.MC.html} +41 -35
- package/public/classes/{McBase.html → MC.McBase.html} +28 -20
- package/public/classes/{McEvent.html → MC.McEvent.html} +48 -42
- package/public/documentation/{MicroComponents.md → MC.md} +17 -17
- package/public/documentation/comparision.md +0 -0
- package/public/documentation/elements.md +276 -0
- package/public/documentation/magic.md +10 -68
- package/public/{customElements.js → elements.js} +9 -10
- package/public/elements.js.map +1 -0
- package/public/elements.min.js +1 -0
- package/public/functions/{addListener.html → MC.addListener.html} +18 -12
- package/public/functions/{removeListener.html → MC.removeListener.html} +18 -12
- package/public/functions/elements.defineCE.html +78 -0
- package/public/functions/elements.getCE.html +63 -0
- package/public/functions/formValues.formValues.html +68 -0
- package/public/functions/observables.observe.html +65 -0
- package/public/functions/selectors._d.html +69 -0
- package/public/functions/selectors._t.html +69 -0
- package/public/helpers.js +66 -89
- package/public/helpers.js.map +1 -1
- package/public/index.html +48 -33
- package/public/interfaces/{HTMLMcElement.html → MC.HTMLMcElement.html} +601 -595
- package/public/interfaces/selectors.DSelector.html +1013 -0
- package/public/interfaces/selectors.TSelector.html +712 -0
- package/public/microcomponents.js +3 -3
- package/public/microcomponents.js.map +1 -1
- package/public/microcomponents.min.js +1 -1
- package/public/modules/MC.html +78 -0
- package/public/modules/elements.html +62 -0
- package/public/modules/formValues.html +60 -0
- package/public/modules/observables.html +65 -0
- package/public/modules/selectors.html +76 -0
- package/public/modules.html +11 -23
- package/public/observables.js +255 -0
- package/public/observables.js.map +1 -0
- package/public/observables.min.js +1 -0
- package/public/{customSelectors.js → selectors.js} +1 -1
- package/public/selectors.js.map +1 -0
- package/public/selectors.min.js +1 -0
- package/public/src/MC.ts +376 -0
- package/public/src/McEvent.ts +96 -0
- package/public/src/autoloader.ts +98 -0
- package/{src/customElements.ts → public/src/elements.ts} +23 -14
- package/public/src/formValues.ts +275 -0
- package/public/src/helpers.ts +140 -0
- package/public/src/microcomponents.ts +8 -0
- package/public/src/observables.ts +354 -0
- package/public/src/test.ts +187 -0
- package/public/test.js +99 -115
- package/public/test.js.map +1 -1
- package/public/types/observables.Observable.html +91 -0
- package/public/types/selectors.selection.html +58 -0
- package/public/types/selectors.singleSelector.html +58 -0
- package/src/MC.ts +173 -175
- package/src/autoloader.ts +1 -1
- package/src/elements.ts +76 -0
- package/src/helpers.ts +95 -128
- package/src/microcomponents.ts +3 -3
- package/src/observables.ts +354 -0
- package/src/selectors.ts +1634 -0
- package/src/test.ts +133 -157
- package/typedoc.json +1 -1
- package/webpack.config.js +9 -9
- package/dist/customElements.d.ts.map +0 -1
- package/dist/customElements.min.js +0 -1
- package/dist/customObservables.d.ts.map +0 -1
- package/dist/customObservables.min.js +0 -1
- package/dist/customObservables.ts +0 -348
- package/dist/customSelectors.d.ts.map +0 -1
- package/dist/customSelectors.min.js +0 -1
- package/public/customElements.js.map +0 -1
- package/public/customElements.min.js +0 -1
- package/public/customObservables.js +0 -256
- package/public/customObservables.js.map +0 -1
- package/public/customObservables.min.js +0 -1
- package/public/customSelectors.js.map +0 -1
- package/public/customSelectors.min.js +0 -1
- package/src/customObservables.ts +0 -348
- /package/dist/{customSelectors.ts → selectors.ts} +0 -0
- /package/{src/customSelectors.ts → public/src/selectors.ts} +0 -0
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;CAC5B;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAElD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,WAAW,GAAG,WAAW,CAatD;AAED,wBAAgB,aAAa,CAC5B,CAAC,EAAE,WAAW,EACd,MAAM,GAAE,OAAc,GACpB,WAAW,CAmBb;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,GAAG,OAAO,CAInE;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,GAAE,WAAgB,GAAG,GAAG,CAW3E;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,EAAE,EAAE,SAAS,EAAE,MAAM,OAyCrE;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,UAKxC;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,QAAQ,CASvE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAU1D"}
|
package/dist/helpers.ts
CHANGED
|
@@ -1,173 +1,140 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export function isObject( value: any ): boolean {
|
|
4
|
-
return value != null && typeof value === 'object';
|
|
5
|
-
}
|
|
1
|
+
'use strict';
|
|
6
2
|
|
|
7
3
|
export interface LooseObject {
|
|
8
4
|
[key: string | symbol]: any;
|
|
9
5
|
}
|
|
10
6
|
|
|
11
|
-
export function
|
|
12
|
-
return
|
|
13
|
-
.split('-') // Split by hyphens
|
|
14
|
-
.map(word => word.charAt(0).toUpperCase() + word.slice(1)) // Capitalize each part
|
|
15
|
-
.join(''); // Join without spaces
|
|
7
|
+
export function isNativeObject(value: any): boolean {
|
|
8
|
+
return value && value['constructor'] && value.constructor === Object;
|
|
16
9
|
}
|
|
17
10
|
|
|
18
|
-
export function
|
|
19
|
-
let
|
|
20
|
-
|
|
11
|
+
export function sortObject(o: LooseObject): LooseObject {
|
|
12
|
+
let result: LooseObject = {},
|
|
13
|
+
keys = [...Object.keys(o)].sort();
|
|
21
14
|
|
|
22
|
-
|
|
15
|
+
keys.forEach((key) => {
|
|
16
|
+
if (isNativeObject(o[key])) {
|
|
17
|
+
result[key] = sortObject(o[key]);
|
|
18
|
+
} else {
|
|
19
|
+
result[key] = o[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
func( ...arguments );
|
|
27
|
-
},
|
|
28
|
-
milliseconds
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
};
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
32
25
|
|
|
33
|
-
export function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
v1 = o1[key],
|
|
42
|
-
v2 = o2[key],
|
|
43
|
-
recurse = isObject(v1) && isObject(v2);
|
|
44
|
-
;
|
|
26
|
+
export function flattenObject(
|
|
27
|
+
o: LooseObject,
|
|
28
|
+
doSort: boolean = true
|
|
29
|
+
): LooseObject {
|
|
30
|
+
let result: LooseObject = {};
|
|
31
|
+
|
|
32
|
+
[...Object.getOwnPropertyNames(o)].forEach((propName) => {
|
|
45
33
|
if (
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
o[propName] &&
|
|
35
|
+
o[propName]['constructor'] &&
|
|
36
|
+
o[propName].constructor === Object
|
|
48
37
|
) {
|
|
49
|
-
|
|
38
|
+
const temp = flattenObject(o[propName], false);
|
|
39
|
+
for (const j in temp) {
|
|
40
|
+
result[propName + '.' + j] = temp[j];
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
result[propName] = o[propName];
|
|
50
44
|
}
|
|
51
|
-
}
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function nameSpace( ns: string, obj: LooseObject, val: any = null, orig?: any ): any {
|
|
56
|
-
let leftOver: Array<any> = ns.split('.');
|
|
57
|
-
|
|
58
|
-
if ( !orig ){
|
|
59
|
-
orig = obj;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// console.log( 'start', ns, obj, val, leftOver );
|
|
45
|
+
});
|
|
63
46
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
lns: string = leftOver.join('.') // the leftover namespace
|
|
67
|
-
;
|
|
68
|
-
|
|
69
|
-
if ( val !== null && last.length && obj[last] === undefined ){ // extend if val given and ns leftover...
|
|
70
|
-
// console.log( 'add prop', last );
|
|
71
|
-
obj[last] = {};
|
|
72
|
-
}
|
|
47
|
+
return doSort ? sortObject(result) : result;
|
|
48
|
+
}
|
|
73
49
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
50
|
+
export function deepEqual(o1: LooseObject, o2: LooseObject): boolean {
|
|
51
|
+
return (
|
|
52
|
+
JSON.stringify(flattenObject(o1)) === JSON.stringify(flattenObject(o2))
|
|
53
|
+
);
|
|
54
|
+
}
|
|
77
55
|
|
|
78
|
-
|
|
56
|
+
export function nameSpace(ns: string | string[], obj: LooseObject = {}): any {
|
|
57
|
+
let nsa = ns.constructor === String ? ns.split('.') : ns;
|
|
79
58
|
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return orig;
|
|
84
|
-
}
|
|
85
|
-
return obj[last];
|
|
59
|
+
if (!obj || !nsa[0] || !obj[nsa[0]]) {
|
|
60
|
+
console.warn('ns', nsa[0], 'not in', obj);
|
|
61
|
+
return;
|
|
86
62
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return nameSpace( lns, obj[last], val, orig );
|
|
90
|
-
} else {
|
|
91
|
-
if (val){
|
|
92
|
-
return orig;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return lob[last];
|
|
63
|
+
if (obj[nsa[0]].constructor === Object && nsa.length > 1) {
|
|
64
|
+
return nameSpace((nsa as string[]).splice(1), obj[nsa[0]]);
|
|
96
65
|
}
|
|
97
|
-
|
|
66
|
+
return obj[nsa[0]];
|
|
98
67
|
}
|
|
99
68
|
|
|
100
|
-
export function parse(
|
|
69
|
+
export function parse(what: string | Object | any[], parseThis: Object) {
|
|
101
70
|
var args = Array.from(arguments);
|
|
102
71
|
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (args.length === 1){
|
|
109
|
-
return args[1];
|
|
110
|
-
} else if (args.length > 2) {
|
|
111
|
-
while (args.length > 1){
|
|
112
|
-
args[0] = parse( args[0], args[1]);
|
|
72
|
+
if (args.length > 2) {
|
|
73
|
+
while (args.length > 1) {
|
|
74
|
+
args[0] = parse(args[0], args[1]);
|
|
113
75
|
args.splice(1, 1);
|
|
114
76
|
}
|
|
115
77
|
return args[0];
|
|
116
78
|
}
|
|
117
79
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if ( typeof value !== 'undefined' ){
|
|
130
|
-
what = (what as string).replace( pPropname, value );
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
} else if ( isObject(what) ){
|
|
136
|
-
switch ( what.constructor ){
|
|
80
|
+
if (typeof what === 'string') {
|
|
81
|
+
what.match(/\{[^\{\}]*\}/g)?.forEach(function (pPropname) {
|
|
82
|
+
var propname = pPropname.substring(1, pPropname.length - 1),
|
|
83
|
+
value = nameSpace(propname, parseThis);
|
|
84
|
+
//console.log(propname, value);
|
|
85
|
+
if (typeof value !== 'undefined') {
|
|
86
|
+
what = (what as string).replace(pPropname, value);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
} else if (isNativeObject(what)) {
|
|
90
|
+
switch (what.constructor) {
|
|
137
91
|
case Object:
|
|
138
|
-
Object
|
|
139
|
-
.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
);
|
|
92
|
+
Object.keys(what).forEach(function (pKey) {
|
|
93
|
+
if (what.hasOwnProperty(pKey)) {
|
|
94
|
+
(what as LooseObject)[pKey] = parse(
|
|
95
|
+
(what as LooseObject)[pKey],
|
|
96
|
+
parseThis
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
147
100
|
break;
|
|
148
101
|
case Array:
|
|
149
|
-
(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
original[ pKey ] = parse( (what as any)[ pKey ], parseThis );
|
|
153
|
-
}
|
|
154
|
-
);
|
|
102
|
+
(what as Array<any>).forEach(function (pValue, pKey, original) {
|
|
103
|
+
original[pKey] = parse((what as any)[pKey], parseThis);
|
|
104
|
+
});
|
|
155
105
|
break;
|
|
156
106
|
}
|
|
157
107
|
}
|
|
158
108
|
|
|
159
109
|
return what;
|
|
160
|
-
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function kebabToPascal(str: string) {
|
|
113
|
+
return str
|
|
114
|
+
.split('-') // Split by hyphens
|
|
115
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1)) // Capitalize each part
|
|
116
|
+
.join(''); // Join without spaces
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function debounce(func: Function, milliseconds: number): Function {
|
|
120
|
+
let timeout: any;
|
|
121
|
+
return () => {
|
|
122
|
+
clearTimeout(timeout);
|
|
123
|
+
|
|
124
|
+
timeout = setTimeout(function () {
|
|
125
|
+
func(...arguments);
|
|
126
|
+
}, milliseconds);
|
|
127
|
+
};
|
|
128
|
+
}
|
|
161
129
|
|
|
162
|
-
export function htmlToElements(
|
|
130
|
+
export function htmlToElements(html: string): HTMLElement[] {
|
|
163
131
|
let template = document.createElement('template');
|
|
164
132
|
|
|
165
|
-
html = html
|
|
166
|
-
.replace( /<([A-Za-z0-9\-]*)([^>\/]*)(\/>)/gi, "<$1$2></$1>"); // replace XHTML closing tags by full closing tags
|
|
133
|
+
html = html.replace(/<([A-Za-z0-9\-]*)([^>\/]*)(\/>)/gi, '<$1$2></$1>'); // replace XHTML closing tags by full closing tags
|
|
167
134
|
|
|
168
135
|
template.innerHTML = html;
|
|
169
136
|
|
|
170
137
|
template.content.normalize();
|
|
171
138
|
|
|
172
|
-
return
|
|
139
|
+
return Array.from(template.content.childNodes) as HTMLElement[];
|
|
173
140
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export * from './helpers.js';
|
|
2
2
|
export * from './MC.js';
|
|
3
3
|
export * from './McEvent.js';
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
4
|
+
export * from './elements.js';
|
|
5
|
+
export * from './observables.js';
|
|
6
|
+
export * from './selectors.js';
|
|
7
7
|
export * from './formValues.js';
|
|
8
8
|
//# sourceMappingURL=microcomponents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"microcomponents.d.ts","sourceRoot":"","sources":["../src/microcomponents.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,
|
|
1
|
+
{"version":3,"file":"microcomponents.d.ts","sourceRoot":"","sources":["../src/microcomponents.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
|
|
@@ -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 null!=e&&"object"==typeof e}function n(e){return e.split("-").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join("")}function s(e,t){let r;return()=>{clearTimeout(r),r=setTimeout((function(){e(...arguments)}),t)}}function a(e,t){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(const s of n){const n=e[s],o=t[s],c=r(n)&&r(o);if(c&&!a(n,o)||!c&&n!==o)return!1}return!0}function o(e,t,n=null,s){let a=e.split(".");s||(s=t);let c=a.shift(),i=a.join(".");null!==n&&c.length&&void 0===t[c]&&(t[c]={});let l=t[c];return 0===i.length?null!==n?(t[c]=n,s):t[c]:r(t[c])?o(i,t[c],n,s):n?s:l[c]}function c(e,t){var n=Array.from(arguments);if(n.length){if(1===n.length)return n[1];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){var s=e.match(/\{[^\{\}]*\}/g);s&&s.forEach((function(r){var n=o(r.substr(1,r.length-2),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,s){s[n]=c(e[n],t)}))}return e}console.error("no arguments give to parse")}function i(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:()=>I,$t:()=>B,DC:()=>S,MC:()=>A,McBase:()=>w,McEvent:()=>f,addListener:()=>b,debounce:()=>s,deepEqual:()=>a,defineCE:()=>k,formValues:()=>F,getCE:()=>x,htmlToElements:()=>i,isObject:()=>r,kebabToPascal:()=>n,nameSpace:()=>o,observe:()=>T,parse:()=>c,removeListener:()=>g});var l=new Function("try {return this===window;}catch(e){ return false;}");let u=new Set;l()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>u.add(e)));class f{#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 h=new Function("try {return this===window;}catch(e){ return false;}");let d=new Set;function p(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 b(e,t,r,n=!1,s=!1){let a={once:!1};n&&(a.capture=n),s&&(a.once=s),e.addEventListener(t,r,a)}function g(e,t,r){e.removeEventListener(t,r)}function E(e,t,r={}){let n=e;if(!n._mc){let t=S?.debug;S.debug=!1,n._mc=new S(e),S.debug=t,delete n._mc._mc}const s=n._mc;return t.length&&!s[t]&&(s[t]=r,e instanceof HTMLElement&&e.setAttribute("_mc","")),r}function v(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 O(e,t,r={}){let n=e?._mc;n&&[...Object.values(n)].forEach((e=>{e?.trigger&&"function"==typeof e?.trigger&&e?.trigger(t,r)}))}h()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>d.add(e)));class w{#n;constructor(e){var t;this.#n=new WeakRef(e||{}),(t=this).constructor!==S&&setTimeout((()=>{t.trigger("Init"),setTimeout((()=>{let e=Object.keys(t?._mc);e.length&&e?.forEach((e=>{let r=t?._mc?.[e];r.oneInit&&"function"==typeof r.oneInit&&r.oneInit(new f("Init"))}))}),0)}),0),function(e){if(!h()||e.constructor===S)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 s=/^one/.test(n),a=n.replace(/^on[e]{0,1}/,""),o=a.toLowerCase();s&&Object.defineProperty(e,"on"+a,{configurable:!0,enumerable:!1,writable:!0,value:e=>{r.constructor.prototype[n].bind(r)(e)}}),d.has("on"+o)&&b(t,o,(e=>{r.trigger(a,e)}),!1,s)}))}}(this)}get target(){return this.#n.deref()}}class A extends w{_mc={};constructor(e){super(e)}static trigger=O;trigger(e,t={},r){let n=this;if(r=r||"l",n.constructor!==A&&n.constructor!==S){if(n instanceof A||n instanceof S){const n=this,s="string"!=typeof e?e:new f(e,t,r),a="on"+s.type[0].toUpperCase()+s.type.slice(1);if(s.bubble.indexOf("l")>-1&&(s.immediateStopped||"function"!=typeof n[a]||(n[a](s),n.hasOwnProperty(a)&&delete n[a])),s.stopped||"l"===s.bubble)return n;h()&&/[ud]/.test(s.bubble)&&n instanceof A&&setTimeout((()=>{-1===s.bubble.indexOf("l")&&(s.bubble+="l"),s.bubble.indexOf("u")>-1&&n.parent().forEach((e=>{e instanceof A&&e.trigger(s)})),s.bubble.indexOf("d")>-1&&n.children().forEach((e=>{e instanceof A&&e.trigger(s)}))}),0)}}else[...Object.getOwnPropertyNames(n)].forEach((s=>{n[s]?.trigger&&"function"==typeof n[s]?.trigger&&n[s]?.trigger(e,t,r)}))}}class S extends w{_mc={};constructor(e){super(e)}static debug=!1;static add=E;static remove=v;static trigger=O;trigger(e,t={},r){A.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 s=p([...t.querySelectorAll(n)],e);return t.removeAttribute("temp_id"),s}descendants(e=""){let t=this?.target;return y(t)?p([...t.querySelectorAll("*[_mc]")],e):[]}}class j extends HTMLElement{constructor(){super()}connectedCallback(){S.trigger(this,"Connected")}disconnectedCallback(){S.trigger(this,"Disconnected")}adoptedCallback(){S.trigger(this,"Adopted")}attributeChangedCallback(e,t,r){S.trigger(this,"AttributeChanged",{name:e,oldValue:t,newValue:r})}}function k(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 s=n(e);customElements.define(e,function(e,t){return Object.defineProperty(t,"name",{value:e})}(s,class extends j{instance;constructor(e){super();let r=new t(this,e);S.add(this,s,r)}static get observedAttributes(){return r}}))}function x(e){return customElements.get(e)}const T=(e,t)=>{(t?[t]:[...Object.getOwnPropertyNames(e)]).forEach((t=>{if("_"===t[0]||void 0===e?.[t])return;let n,o=e[t];if(!o.prototype)switch(typeof o){case"string":n=String;break;case"number":n=Number;break;case"boolean":n=Boolean;break;case"object":n=o instanceof Array?Array:Object;break;default:return}let i=class extends n{constructor(e){super(e),this.constructor.callbacks=[],r(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,n=r(t.valueOf()),s=t.constructor.bound;if(n){function a(e){if(e.nodeType&&3===e.nodeType){var r=Array.from(e.nodeValue&&e.nodeValue.match(/\{[^\{\}]*\}/g)||[]);if(r.length>0){var o=(i=e.nodeValue||"",function(t){var s,a=!1;return r&&(n?r.forEach((function(e){o.values[e]!==t[e]&&(o.values[e]=t[e],a=!0)})):(o.values=t,a=!0)),a&&(s=i,e.nodeValue=n?c(s,o.values):s.replace(/\{.*\}/g,o.values)),t});o.values=n?{}:void 0,r=Array.from(r).map((e=>e.replace(/[\{\}]/g,"").trim()));let t=n?{}:void 0;r.forEach((function(e){n&&(t[e]="")})),s.push(o)}Array.from(e.childNodes).forEach((function(e){a(e)})),t.notify()}var i;e.nodeType&&1===e.nodeType&&(Array.from(e.attributes).forEach((function(t){var r=Array.from(t.value&&t.value.match(/\{[^\{\}]*\}/g)||[]);if(r.length>0){var n=function(t){return function(s){var a,o=!1;return r&&r.forEach((function(e){n.values[e]!==s[e]&&(n.values[e]=s[e],o=!0)})),o&&(a=t,e.nodeValue=c(a,n.values)),s}}(t.value||"");n.values={},r=Array.from(r).map((e=>e.replace(/[\{\}]/g,"").trim()));let a={};r.forEach((function(e){a[e]=""})),s.push(n)}})),Array.from(e.childNodes).forEach((function(e){a(e)})),t.notify()),e.nodeType&&11===e.nodeType&&Array.from(e.childNodes).forEach((function(e){a(e)}))}a(e),s.length>0&&t.notify()}else console.warn("IGNORED - cannot bind a non-Object to the dom, IS:",typeof t.valueOf());return this}notify(){let e=this,t=r(e.valueOf())&&e.valueOf()instanceof Array==0?structuredClone(Object.assign({},e)):e.valueOf();return e.constructor.callbacks.forEach((e=>{e(t)})),r(e.valueOf())&&e.constructor.bound.forEach((e=>{e(t)})),this}},l=new i(o);Object.defineProperty(e,t,{enumerable:!0,get(){if(r(l.valueOf())){let e=structuredClone(Object.assign({},l));setTimeout(s((function(){a(structuredClone(Object.assign({},l)),e)||l.notify()}),0),0)}return l},set(e){if(typeof e==typeof l.valueOf())if(r(l.valueOf())&&l.valueOf()instanceof Array==0){let t=structuredClone(Object.assign({},l));e=structuredClone(Object.assign({},e));let r=l.constructor?.hasFormHandler??!1,n=l.constructor.callbacks,o=l.constructor.bound;l=new i(structuredClone(Object.assign({},e))),l.constructor.callbacks=r,l.constructor.callbacks=n,l.constructor.bound=o,setTimeout(s((function(){a(structuredClone(Object.assign({},l)),t)||l.notify()}),0),0)}else{let t=l.valueOf(),r=l.constructor.callbacks;l=new i(e),l.constructor.callbacks=r,e!==t&&l.notify()}else console.warn("IGNORED - cannot change observable types, IS:",typeof l.valueOf(),"- CANNOT BECOME:",typeof e)}}),e[t]=o}))},C=e=>{let t=new Set;return e.forEach((e=>{(e=e.trim()).split(" ").forEach((e=>{""!==e&&t.add(e)}))})),Array.from(t)},_=e=>{let t=I("input,select,textarea",e).array,r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let s;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":s=new L(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;case"select":s=new M(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;case"textarea":s=new H(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r};class N{constructor(e){}}class L extends N{#s;#e;#a;constructor(e,t){super(e),this.#s=e,this.#e=e.type,this.#a=t}get val(){let e,t=this;switch(t.#e){case"radio":const r=I(`input[type="radio"][name="${this.#s.getAttribute("name")}"]`,this.#a).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=I(r,this.#a);if(!n.length)return;if(""===e)return void n.forEach((e=>{e.checked&&(e.checked=!1)}));const s=n.filter((t=>t.getAttribute("value")===e));if(!s.length)return;return void(s.array[0].checked=!0);case"checkbox":t.#s.checked=e;break;default:t.#s.value=e}}}class M extends N{#s;#o=!1;constructor(e){super(e),this.#s=e,this.#o="select-multiple"===e.type}get val(){const e=[];return I(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,I(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 H extends N{#s;constructor(e){super(e),this.#s=e}get val(){return this.#s.value}set val(e){this.#s.value=e}}class P{#c=new Set;get set(){return this.#c}get array(){return Array.from(this.#c)}set set(e){this.#c=e}get length(){return this.#c.size}constructor(e,t=document.body){if(new Set,!e)return this}$t(e){let t=new $;return this.#c.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 I(e,t).forEach((e=>{r.#c.add(e)})),r}addClass(...e){return e=C(e),this.forEach((t=>{t.classList.add(...e)})),this}after(e,t){let r=this,n=I(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=I(e,t);return r&&n.forEach((e=>{r.append(e)})),this}appendTo(e,t){let r=I(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=>{I(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=I(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.#c.forEach((e=>{Array.from(e.children).forEach((e=>{n.add(e)}))})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}descendants(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{e.querySelectorAll("*").forEach((e=>{n.add(e)}))})),r=I([...n]),e){let n=I(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,s=!1;return e&&(s=I(e,t)),r.#c.forEach((e=>{e.parentNode&&n.add(e.parentNode.children[0])})),r=I([...n]),e&&r.filter((e=>s.has(e))),r}has(e){return this.#c.has(e)}hasClass(...e){return e=C(e),this.every((e=>Array.from(e.classList).every((t=>e.contains(t)))))}html(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerHTML=e:(()=>{console.warn("Cannot access the .innerHTML of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerHTML}last(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{let t=e.parentNode?.children;t&&n.add(Array.from(t).at(-1))})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}next(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),s=r.indexOf(e)+1;s<r.length&&n.add(r.at(s))}})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}normalize(){return this.#c.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){g(e,r,t)}))})),this}on(e,t,r=!1,n=!1){let s=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function o(){o.cb.apply(s,Array.from(arguments))}return o.cb=t,s.forEach((e=>{a.forEach((function(t){b(e,t,o,r,n)}))})),o}one(e,t,r=!1){let n=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(n,Array.from(arguments))}return a.cb=t,n.forEach((e=>{s.forEach((function(t){b(e,t,a,r,!0)}))})),a}parent(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{e.parentNode&&"HTML"!==e.parentNode.tagName&&n.add(e.parentNode)})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}parents(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{let t=e;for(;t.parentNode&&"HTML"!==t.parentNode.tagName;)t=t.parentNode,n.add(t)})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}prepend(e,t){let r=this.array[0],n=I(e,t);return r&&n.forEach((e=>{r.prepend(e)})),this}prev(e,t){let r=this,n=new Set;if(r.#c.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),s=r.indexOf(e)-1;s>-1&&n.add(r.at(s))}})),r=I([...n]),e){let n=I(e,t);r.filter((e=>n.has(e)))}return r}removeClass(...e){return e=C(e),this.forEach((t=>{t.classList.remove(...e)})),this}text(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerText=e:(()=>{console.warn("Cannot access the .textContent of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerText??""}toggleClass(...e){return e=C(e),this.forEach((t=>{t.classList.toggle(...e)})),this}trigger(e,t={},r=!1,n=!1,s=!1){let a,o={bubbles:r,cancelable:n,composed:s},c=e.indexOf(" ")>-1?e.split(" "):[e];return this.#c.forEach((e=>{c.forEach((function(r){a=new Event(r,o),a.data=t,e.dispatchEvent(a)}))})),this}val(e,t){if(!this.length)return this;const r=this;let n,s=_(r.array[0]);var a;return e?null!=(a=e)&&"object"==typeof a?(Object.assign(s,e),n=r):"string"==typeof e&&(void 0===t?n=s[e]:(s[e]=t,n=r)):n=Object.assign({},s),n}values(e){const t=this;let r={};if(!t.length)return console.warn("no dom selection to search inputs in"),{};let n=_(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 I(this.array.at(e))}concat(e){let t=this;return(e instanceof P?e.array:e).forEach((e=>{t.#c.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return this.#c=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.#c.add(e)})),this}shift(){let e=this,t=e.#c.size?e.array[0]:void 0;return t&&e.#c.delete(t),t}slice(e,t){return I(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),I(n)}}class ${#c=new Set;get set(){return this.#c}get array(){return Array.from(this.#c)}set set(e){this.#c=e}get length(){return this.#c.size}set length(e){}constructor(e,t=document.body){if(!e)return this;I(e,t).forEach((e=>{B(e).forEach((e=>{this.#c.add(e)}))}))}$d(e,t=document.body){let r=new P,n=new Set,s=!!e||!1,a=new Set;return s&&(a=I(e,t).set),this.#c.forEach((e=>{s&&!a.has(e._tg)||n.add(e._tg)})),r.set=n,r}children(e){let t=this,r=new Set;return t.#c.forEach((t=>{t.children(e).forEach((e=>{r.add(e)}))})),t.#c=r,t}descendants(e){let t=this,r=new Set;return t.#c.forEach((t=>{t.descendants(e).forEach((e=>{r.add(e)}))})),t.#c=r,t}first(e){let t=this,r=new Set;return t.#c.forEach((e=>{e.parent().children().$d().first().$t().forEach((e=>{r.add(e)}))})),t.#c=r,e&&t.filter((t=>t.nameSpace=e)),t}has(e){return this.#c.has(e)}last(e){let t=this,r=new Set;return t.#c.forEach((e=>{e.parent().children().$d().last().$t().forEach((e=>{r.add(e)}))})),t.#c=r,e&&t.filter((t=>t.nameSpace=e)),t}next(e){let t=this,r=new Set;return t.#c.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.nextElementSibling;)t=t.nextElementSibling,n.add(t);B([...n]).$d().first().$t().forEach((e=>{r.add(e)}))})),t.#c=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){g(e,`[TB]${r}`,t)}))})),this}on(e,t,r=!1){let n=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(n,Array.from(arguments))}return a.cb=t,n.forEach((e=>{s.forEach((function(t){b(e._tg,`[TB]${t}`,a,!1,r)}))})),a}one(e,t){let r=this,n=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(r,Array.from(arguments))}return s.cb=t,r.forEach((e=>{n.forEach((function(t){b(e._tg,`[TB]${t}`,s,!1,!0)}))})),s}parent(e){let t=this,r=new Set;return t.#c.forEach((t=>{t.parent(e).forEach((e=>{r.add(e)}))})),t.#c=r,t}parents(e){let t=this,r=new Set;return t.#c.forEach((t=>{t.parents(e).forEach((e=>{r.add(e)}))})),t.#c=r,t}prev(e){let t=this,r=new Set;return t.#c.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.previousElementSibling;)t=t.previousElementSibling,n.add(t);B([...n]).$d().last().$t().forEach((e=>{r.add(e)}))})),t.#c=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 B(this.array.at(e))}concat(e){let t=this;return e.forEach((e=>{t.#c.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return B(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.#c=new Set(e),t}push(e){return this.#c.add(e),this}shift(){let e=this.array.shift();return this.#c.delete(e),e}slice(e,t){return B(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 B(n)}}const I=(e,t=document)=>{let r=new Set;return e instanceof Array?(e.forEach((e=>{I(e,t).forEach((e=>{r.add(e)}))})),new P([...r])):new P(e,t)},B=(e,t=document)=>I(e,t).$t();class q{constructor(e){}}class V extends q{#s;#e;#a;constructor(e,t){super(e),this.#s=e,this.#e=e.type,this.#a=t}get val(){let e,t=this;switch(t.#e){case"radio":const r=[...(this.#a||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.#a||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 q{#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 D extends q{#s;constructor(e){super(e),this.#s=e}get val(){return this.#s.value}set val(e){this.#s.value=e}}const F=(e,t={},r,n)=>{let s=(e=>{let t=[...(e||document).querySelectorAll("input,select,textarea")],r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let s;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":s=new V(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;case"select":s=new z(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;case"textarea":s=new D(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>s.val,set:e=>{s.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r})(e);function a(e){Object.keys(e).forEach((t=>{s.hasOwnProperty(t)&&e.hasOwnProperty(t)&&(s[t]=e[t])}))}if(Object.keys(t).length>0&&a(t),void 0!==n){let t=r[n];t.constructor?.hasFormHandler||(t.constructor.hasFormHandler=!0,t.observe(a)),r[n].observe((()=>{})),[...e.querySelectorAll("input, textarea, select")].forEach((e=>{b(e,"keyup",(()=>{r[n]=structuredClone(Object.assign(s))})),b(e,"change",(()=>{r[n]=structuredClone(Object.assign(s))})),e instanceof HTMLSelectElement&&b(e,"select",(()=>{r[n]=structuredClone(Object.assign(s))}))}))}return n?r[n]:Object.assign({},s)};return t})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.microcomponents=t():e.microcomponents=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){return e&&e.constructor&&e.constructor===Object}function n(e){let t={};return[...Object.keys(e)].sort().forEach((a=>{r(e[a])?t[a]=n(e[a]):t[a]=e[a]})),t}function a(e,t=!0){let r={};return[...Object.getOwnPropertyNames(e)].forEach((t=>{if(e[t]&&e[t].constructor&&e[t].constructor===Object){const n=a(e[t],!1);for(const e in n)r[t+"."+e]=n[e]}else r[t]=e[t]})),t?n(r):r}function s(e,t){return JSON.stringify(a(e))===JSON.stringify(a(t))}function o(e,t={}){let r=e.constructor===String?e.split("."):e;if(t&&r[0]&&t[r[0]])return t[r[0]].constructor===Object&&r.length>1?o(r.splice(1),t[r[0]]):t[r[0]];console.warn("ns",r[0],"not in",t)}function c(e,t){var n=Array.from(arguments);if(n.length>2){for(;n.length>1;)n[0]=c(n[0],n[1]),n.splice(1,1);return n[0]}if("string"==typeof e)e.match(/\{[^\{\}]*\}/g)?.forEach((function(r){var n=o(r.substring(1,r.length-1),t);void 0!==n&&(e=e.replace(r,n))}));else if(r(e))switch(e.constructor){case Object:Object.keys(e).forEach((function(r){e.hasOwnProperty(r)&&(e[r]=c(e[r],t))}));break;case Array:e.forEach((function(r,n,a){a[n]=c(e[n],t)}))}return e}function i(e){return e.split("-").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join("")}function l(e,t){let r;return()=>{clearTimeout(r),r=setTimeout((function(){e(...arguments)}),t)}}function u(e){let t=document.createElement("template");return e=e.replace(/<([A-Za-z0-9\-]*)([^>\/]*)(\/>)/gi,"<$1$2></$1>"),t.innerHTML=e,t.content.normalize(),Array.from(t.content.childNodes)}e.r(t),e.d(t,{$d:()=>D,$t:()=>F,DC:()=>k,MC:()=>j,McBase:()=>A,McEvent:()=>d,addListener:()=>E,debounce:()=>l,deepEqual:()=>s,defineCE:()=>T,flattenObject:()=>a,formValues:()=>Z,getCE:()=>N,htmlToElements:()=>u,isNativeObject:()=>r,kebabToPascal:()=>i,nameSpace:()=>o,observe:()=>M,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=k?.debug;k.debug=!1,n._mc=new k(e),k.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={}){let n=e?._mc;n&&[...Object.values(n)].forEach((e=>{e?.trigger&&"function"==typeof e?.trigger&&e?.trigger(t,r)}))}p()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>b.add(e)));class A{#n;constructor(e,t=!1){var r;this.#n=new WeakRef(e||{}),(r=this).constructor!==k&&setTimeout((()=>{r.trigger("Init")}),0),function(e){if(!p()||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 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 j extends A{_mc={};constructor(e){super(e)}static trigger=S;trigger(e,t={},r){let n=this;if(r=r||"l",n.constructor!==j&&n.constructor!==k){if(n instanceof j||n instanceof k){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;p()&&/[ud]/.test(a.bubble)&&n instanceof j&&setTimeout((()=>{-1===a.bubble.indexOf("l")&&(a.bubble+="l"),a.bubble.indexOf("u")>-1&&n.parent().forEach((e=>{e instanceof j&&e.trigger(a)})),a.bubble.indexOf("d")>-1&&n.children().forEach((e=>{e instanceof j&&e.trigger(a)}))}),0)}}else[...Object.getOwnPropertyNames(n)].forEach((a=>{n[a]?.trigger&&"function"==typeof n[a]?.trigger&&n[a]?.trigger(e,t,r)}))}}class k extends A{_mc={};constructor(e,t=!1){super(e)}static add=O;static remove=w;static trigger=S;trigger(e,t={},r){j.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 x 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 T(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 x{instance;constructor(e){super();let r=new t(this,e);k.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 _(e){let t=new Set;return e.getAttributeNames().filter((t=>e.getAttribute(t)?.match(/\{[^\{\}]*\}/g))).forEach((r=>{new Set(e.getAttribute(r)?.match(/\{[^\{\}]*\}/g)).forEach((e=>t.add(e.replace(/[\{\}]/g,""))))})),[...e.childNodes].filter((e=>3===e.nodeType&&(e.nodeValue||"").match(/\{[^\{\}]*\}/g))).forEach((e=>{(e.nodeValue||"").match(/\{[^\{\}]*\}/g).forEach((e=>{t.add(e.replace(/[\{\}]/g,""))}))})),[...t].map((e=>e.replace(/[\{\}]/g,""))),[...t]}class L extends k{data={};placeholders=[];constructor(e){super(e);let t=this;_(e).forEach((e=>t.data[e]="")),M(t),t.#a()}#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((t=>{let r=new Set(t.nodeValue.match(/\{[^\{\}]*\}/g));var n;e.data.observe((n=t.nodeValue,e=>{let a=n;r.forEach((t=>{a=a.replace(t,e[t.replace(/[\{\}]/g,"")])})),t.nodeValue=a}))}))}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 M=(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,r=C(t.valueOf());return t.constructor.bound,r?(function(e){var t;(t=e,[t].concat([...t.querySelectorAll("*")]).filter((e=>!!_(e).length))).forEach((e=>k.add(e,"_placeholders",new L(e))))}(e),this.constructor.callbacks.push((t=>{k.trigger(e,"data",a(t),"ld")})),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}))},P=e=>{let t=new Set;return e.forEach((e=>{(e=e.trim()).split(" ").forEach((e=>{""!==e&&t.add(e)}))})),Array.from(t)},H=e=>{let t=D("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 B(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"select":a=new q(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"textarea":a=new I(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 ${constructor(e){}}class B extends ${#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=D(`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=D(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 q extends ${#s;#c=!1;constructor(e){super(e),this.#s=e,this.#c="select-multiple"===e.type}get val(){const e=[];return D(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,D(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 I extends ${#s;constructor(e){super(e),this.#s=e}get val(){return this.#s.value}set val(e){this.#s.value=e}}class V{#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 z;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 D(e,t).forEach((e=>{r.#i.add(e)})),r}addClass(...e){return e=P(e),this.forEach((t=>{t.classList.add(...e)})),this}after(e,t){let r=this,n=D(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=D(e,t);return r&&n.forEach((e=>{r.append(e)})),this}appendTo(e,t){let r=D(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=>{D(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=D(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=D([...n]),e){let n=D(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=D([...n]),e){let n=D(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=D(e,t)),r.#i.forEach((e=>{e.parentNode&&n.add(e.parentNode.children[0])})),r=D([...n]),e&&r.filter((e=>a.has(e))),r}has(e){return this.#i.has(e)}hasClass(...e){return e=P(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=D([...n]),e){let n=D(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=D([...n]),e){let n=D(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=D([...n]),e){let n=D(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=D([...n]),e){let n=D(e,t);r.filter((e=>n.has(e)))}return r}prepend(e,t){let r=this.array[0],n=D(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=D([...n]),e){let n=D(e,t);r.filter((e=>n.has(e)))}return r}removeClass(...e){return e=P(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=P(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=H(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=H(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 D(this.array.at(e))}concat(e){let t=this;return(e instanceof V?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 D(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),D(n)}}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}set length(e){}constructor(e,t=document.body){if(!e)return this;D(e,t).forEach((e=>{F(e).forEach((e=>{this.#i.add(e)}))}))}$d(e,t=document.body){let r=new V,n=new Set,a=!!e||!1,s=new Set;return a&&(s=D(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);F([...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);F([...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 F(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 F(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 F(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 F(n)}}const D=(e,t=document)=>{let r=new Set;return e instanceof Array?(e.forEach((e=>{D(e,t).forEach((e=>{r.add(e)}))})),new V([...r])):new V(e,t)},F=(e,t=document)=>D(e,t).$t();class J{constructor(e){}}class R extends J{#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 G extends J{#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 W extends J{#s;constructor(e){super(e),this.#s=e}get val(){return this.#s.value}set val(e){this.#s.value=e}}const Z=(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 R(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"select":a=new G(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"textarea":a=new W(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})()));
|
package/dist/microcomponents.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export * from './helpers.js';
|
|
3
3
|
export * from './MC.js';
|
|
4
4
|
export * from './McEvent.js';
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
5
|
+
export * from './elements.js';
|
|
6
|
+
export * from './observables.js';
|
|
7
|
+
export * from './selectors.js';
|
|
8
8
|
export * from './formValues.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LooseObject } from './helpers.js';
|
|
2
|
-
export declare const observe: (target: LooseObject, propertyName?: string) => void;
|
|
3
2
|
type Callback = (value: any) => void;
|
|
4
3
|
export type Observable = {
|
|
5
4
|
observe: (cb: Callback) => void;
|
|
6
5
|
notify: () => void;
|
|
7
|
-
bind: (target: HTMLElement | ShadowRoot) => void;
|
|
6
|
+
bind: (target: HTMLElement | DocumentFragment | ShadowRoot) => void;
|
|
8
7
|
};
|
|
8
|
+
export declare const observe: (target: LooseObject, propertyName?: string) => void;
|
|
9
9
|
export {};
|
|
10
|
-
//# sourceMappingURL=
|
|
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,EAMX,MAAM,cAAc,CAAC;AAQtB,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;AAqJrC,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,SAqLjE,CAAC"}
|
|
@@ -0,0 +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 o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},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((o=>{var n;(n=t[o])&&n.constructor&&n.constructor===Object?e[o]=r(t[o]):e[o]=t[o]})),e}function o(t,e=!0){let n={};return[...Object.getOwnPropertyNames(t)].forEach((e=>{if(t[e]&&t[e].constructor&&t[e].constructor===Object){const r=o(t[e],!1);for(const t in r)n[e+"."+t]=r[t]}else n[e]=t[e]})),e?r(n):n}function n(t,e){return JSON.stringify(o(t))===JSON.stringify(o(e))}function c(t,e){let r;return()=>{clearTimeout(r),r=setTimeout((function(){t(...arguments)}),e)}}t.r(e),t.d(e,{observe:()=>w});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 u=new Function("try {return this===window;}catch(e){ return false;}");let l=new Set;function f(t,e){let r=[];return t.forEach((t=>{if(t&&t instanceof HTMLElement){const o=t?._mc;!e&&o?r=r.concat(Object.values(t._mc)):e&&o&&o[e]&&r.push(o[e])}})),r}function d(t,e,r=!0){let o=[];for(;t;){if(t._mc&&(e?e&&t._mc[e]&&o.push(t._mc[e]):o=o.concat(Object.values(t._mc)),r))return o;t=t.parentNode}return o}function b(t){return t&&t instanceof HTMLElement}function p(t,e,r={}){let o=t;if(!o._mc){let e=O?.debug;O.debug=!1,o._mc=new O(t),O.debug=e,delete o._mc._mc}const n=o._mc;return e.length&&!n[e]&&(n[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={}){let o=t?._mc;o&&[...Object.values(o)].forEach((t=>{t?.trigger&&"function"==typeof t?.trigger&&t?.trigger(e,r)}))}u()&&Object.keys(HTMLElement.prototype).filter((t=>/^on/.test(t))).forEach((t=>l.add(t)));class m{#o;constructor(t,e=!1){var r;this.#o=new WeakRef(t||{}),(r=this).constructor!==O&&setTimeout((()=>{r.trigger("Init")}),0),function(t){if(!u()||t.constructor===O)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((o=>{let n=/^one/.test(o),c=o.replace(/^on[e]{0,1}/,""),a=c.toLowerCase();n&&Object.defineProperty(t,"on"+c,{configurable:!0,enumerable:!1,writable:!0,value:t=>{r.constructor.prototype[o].bind(r)(t)}}),l.has("on"+a)&&function(t,e,r,o=!1,n=!1){let c={once:!1};o&&(c.capture=o),n&&(c.once=n),t.addEventListener(e,r,c)}(e,a,(t=>{r.trigger(c,t)}),!1,n)}))}}(this)}get target(){return this.#o.deref()}}class y extends m{_mc={};constructor(t){super(t)}static trigger=h;trigger(t,e={},r){let o=this;if(r=r||"l",o.constructor!==y&&o.constructor!==O){if(o instanceof y||o instanceof O){const o=this,n="string"!=typeof t?t:new i(t,e,r),c="on"+n.type[0].toUpperCase()+n.type.slice(1);if(n.bubble.indexOf("l")>-1&&(n.immediateStopped||"function"!=typeof o[c]||(o[c](n),o.hasOwnProperty(c)&&delete o[c])),n.stopped||"l"===n.bubble)return o;u()&&/[ud]/.test(n.bubble)&&o instanceof y&&setTimeout((()=>{-1===n.bubble.indexOf("l")&&(n.bubble+="l"),n.bubble.indexOf("u")>-1&&o.parent().forEach((t=>{t instanceof y&&t.trigger(n)})),n.bubble.indexOf("d")>-1&&o.children().forEach((t=>{t instanceof y&&t.trigger(n)}))}),0)}}else[...Object.getOwnPropertyNames(o)].forEach((n=>{o[n]?.trigger&&"function"==typeof o[n]?.trigger&&o[n]?.trigger(t,e,r)}))}}class O extends m{_mc={};constructor(t,e=!1){super(t)}static add=p;static remove=g;static trigger=h;trigger(t,e={},r){y.prototype.trigger.call(this,t,e,r)}parent(t=""){let e=this.target;return b(e)?d(e.parentNode,t,!0):[]}ancestors(t=""){let e=this?.target;return b(e)?d(this.target.parentNode,t,!1):[]}children(t=""){let e=this?.target;if(!b(e))return[];const r=Math.random().toString().replace(".",""),o='[_mc]:not([temp_id="'+r+'"] [_mc] [_mc])';e.setAttribute("temp_id",r);const n=f([...e.querySelectorAll(o)],t);return e.removeAttribute("temp_id"),n}descendants(t=""){let e=this?.target;return b(e)?f([...e.querySelectorAll("*[_mc]")],t):[]}}function v(t){return null!=t&&"object"==typeof t}function E(t){let e=new Set;return t.getAttributeNames().filter((e=>t.getAttribute(e)?.match(/\{[^\{\}]*\}/g))).forEach((r=>{new Set(t.getAttribute(r)?.match(/\{[^\{\}]*\}/g)).forEach((t=>e.add(t.replace(/[\{\}]/g,""))))})),[...t.childNodes].filter((t=>3===t.nodeType&&(t.nodeValue||"").match(/\{[^\{\}]*\}/g))).forEach((t=>{(t.nodeValue||"").match(/\{[^\{\}]*\}/g).forEach((t=>{e.add(t.replace(/[\{\}]/g,""))}))})),[...e].map((t=>t.replace(/[\{\}]/g,""))),[...e]}class j extends O{data={};placeholders=[];constructor(t){super(t);let e=this;E(t).forEach((t=>e.data[t]="")),w(e),e.#n()}#n(){let t=this,e=t.target;e.getAttributeNames().filter((t=>e.getAttribute(t)?.match(/\{[^\{\}]*\}/g))).forEach((r=>{let o=new Set(e.getAttribute(r)?.match(/\{[^\{\}]*\}/g));var n;t.data.observe((n=e.getAttribute(r),t=>{let c=n;o.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((e=>{let r=new Set(e.nodeValue.match(/\{[^\{\}]*\}/g));var o;t.data.observe((o=e.nodeValue,t=>{let n=o;r.forEach((e=>{n=n.replace(e,t[e.replace(/[\{\}]/g,"")])})),e.nodeValue=n}))}))}onData(t){let e=this,r={};Object.keys(t.data).forEach((o=>{e.data.hasOwnProperty(o)&&(r[o]=t.data[o])})),JSON.stringify(r)!==JSON.stringify(e.data)&&Object.assign(e.data,r)}}const w=(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=[],v(t)&&(this.constructor.bound=[],Object.getOwnPropertyNames(t).forEach((e=>{this[e]=t[e]})))}observe(t){return this.constructor.callbacks.push(t),this}bind(t){const e=this,r=v(e.valueOf());return e.constructor.bound,r?(function(t){var e;(e=t,[e].concat([...e.querySelectorAll("*")]).filter((t=>!!E(t).length))).forEach((t=>O.add(t,"_placeholders",new j(t))))}(t),this.constructor.callbacks.push((e=>{O.trigger(t,"data",o(e),"ld")})),e.notify()):console.warn("IGNORED - cannot bind a non-Object to the dom, IS:",typeof e.valueOf(),e),this}notify(){let t=this,e=v(t.valueOf())&&t.valueOf()instanceof Array==0?structuredClone(Object.assign({},t)):t.valueOf();return t.constructor.callbacks.forEach((t=>{t(e)})),v(t.valueOf())&&t.constructor.bound.forEach((t=>{t(e)})),this}},i=new s(a);Object.defineProperty(t,e,{enumerable:!0,get(){if(v(i.valueOf())){let t=structuredClone(Object.assign({},i));setTimeout(c((function(){n(structuredClone(Object.assign({},i)),t)||i.notify()}),0),0)}return i},set(t){if(typeof t==typeof i.valueOf())if(v(i.valueOf())&&i.valueOf()instanceof Array==0){let e=structuredClone(Object.assign({},i));t=structuredClone(Object.assign({},t));let r=i.constructor?.hasFormHandler??!1,o=i.constructor.callbacks,a=i.constructor.bound;i=new s(structuredClone(Object.assign({},t))),i.constructor.callbacks=r,i.constructor.callbacks=o,i.constructor.bound=a,setTimeout(c((function(){n(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})()));
|