@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
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { LooseObject } from './helpers.js';
|
|
4
|
-
import { isObject, parse, debounce, deepEqual } from './helpers.js';
|
|
5
|
-
|
|
6
|
-
export const observe = ( target: LooseObject, propertyName?: string ) => {
|
|
7
|
-
|
|
8
|
-
let keys = !propertyName ? [ ...Object.getOwnPropertyNames(target) ] : [ propertyName ];
|
|
9
|
-
|
|
10
|
-
keys.forEach( (key) => {
|
|
11
|
-
// console.log( 'co propname', key, typeof target[key], target[key] );
|
|
12
|
-
if ( key[0] === '_' || target?.[key] === undefined ) return;
|
|
13
|
-
let
|
|
14
|
-
val: any = target[key],
|
|
15
|
-
Constructor: any
|
|
16
|
-
;
|
|
17
|
-
|
|
18
|
-
if ( !val.prototype ){
|
|
19
|
-
switch ( typeof val ){
|
|
20
|
-
case "string":
|
|
21
|
-
Constructor = String;
|
|
22
|
-
break;
|
|
23
|
-
case "number":
|
|
24
|
-
Constructor = Number;
|
|
25
|
-
break;
|
|
26
|
-
case "boolean":
|
|
27
|
-
Constructor = Boolean;
|
|
28
|
-
break;
|
|
29
|
-
case "object":
|
|
30
|
-
if ( val instanceof Array){
|
|
31
|
-
Constructor = Array;
|
|
32
|
-
} else {
|
|
33
|
-
Constructor = Object;
|
|
34
|
-
}
|
|
35
|
-
break;
|
|
36
|
-
default:
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
let Observable = class extends Constructor{
|
|
43
|
-
|
|
44
|
-
constructor( val: any ){
|
|
45
|
-
super( val );
|
|
46
|
-
(this.constructor as LooseObject).callbacks = [];
|
|
47
|
-
if ( isObject(val) ){ // you cannot bind native values to the dom
|
|
48
|
-
(this.constructor as LooseObject).bound = [];
|
|
49
|
-
Object.getOwnPropertyNames( val ).forEach( (key) => {
|
|
50
|
-
this[key] = val[key];
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
observe( f: Function ){
|
|
56
|
-
//console.log('observe');
|
|
57
|
-
(this.constructor as any).callbacks.push( f );
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
bind( target: HTMLElement | ShadowRoot ){
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
that = this,
|
|
65
|
-
iso = isObject( that.valueOf() ),
|
|
66
|
-
bound = (that.constructor as any).bound
|
|
67
|
-
;
|
|
68
|
-
|
|
69
|
-
//console.log('bind', iso, target);
|
|
70
|
-
|
|
71
|
-
if ( iso ){
|
|
72
|
-
// console.log('bind...', that.valueOf(), target );
|
|
73
|
-
|
|
74
|
-
function walk( element: Node ){
|
|
75
|
-
//console.log('-walk:', element, element.childNodes );
|
|
76
|
-
|
|
77
|
-
if ( !!element['nodeType'] && element.nodeType === 3 ){ // text node
|
|
78
|
-
//console.log('--type: textNode(3)');
|
|
79
|
-
|
|
80
|
-
var placeholders = Array.from( element.nodeValue && element.nodeValue.match( /\{[^\{\}]*\}/g ) || []);
|
|
81
|
-
|
|
82
|
-
if ( placeholders.length > 0 ){
|
|
83
|
-
//console.log('--placeholders:', placeholders);
|
|
84
|
-
var f=(function( template: string ){
|
|
85
|
-
//console.log('template', template);
|
|
86
|
-
return function( values: any ){
|
|
87
|
-
var t,
|
|
88
|
-
changed = false;
|
|
89
|
-
|
|
90
|
-
//console.log( 'placeholders:', placeholders, 'values:', values);
|
|
91
|
-
if ( placeholders ){
|
|
92
|
-
if ( iso ){
|
|
93
|
-
placeholders.forEach(function(placeholder){
|
|
94
|
-
if ( ( f as LooseObject).values[placeholder] !== values[placeholder] ){
|
|
95
|
-
(f as LooseObject).values[placeholder] = values[placeholder];
|
|
96
|
-
changed = true;
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
} else { // it is a simple value
|
|
100
|
-
(f as LooseObject).values = values;
|
|
101
|
-
changed = true;
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
if (changed){ // only reflow if changed
|
|
105
|
-
t = template;
|
|
106
|
-
//console.log('--template parse', t, (f as LooseObject).values );
|
|
107
|
-
if ( iso ){
|
|
108
|
-
element.nodeValue = parse(
|
|
109
|
-
t,
|
|
110
|
-
(f as LooseObject).values
|
|
111
|
-
);
|
|
112
|
-
} else { // it is a simple value -> replace every placeholder whatever the name wi
|
|
113
|
-
element.nodeValue = t.replace( /\{.*\}/g ,(f as LooseObject).values );
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
return values;
|
|
117
|
-
};
|
|
118
|
-
})( element.nodeValue || '' );
|
|
119
|
-
|
|
120
|
-
(f as LooseObject).values = iso ? {} : undefined;
|
|
121
|
-
placeholders = Array.from( placeholders ).map((pKey) => pKey.replace(/[\{\}]/g, '').trim());
|
|
122
|
-
|
|
123
|
-
let initial: any = iso ? {} : undefined;
|
|
124
|
-
placeholders.forEach(function(pKey){
|
|
125
|
-
if ( iso ){
|
|
126
|
-
initial[pKey] = "";
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
bound.push(f);
|
|
131
|
-
// console.log( `--bound textNode`, placeholders, f );
|
|
132
|
-
//(observableFunction as Function)(initial);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
//console.log('--childNodes:', element.childNodes );
|
|
136
|
-
Array.from( element.childNodes )
|
|
137
|
-
.forEach(function( childNode ){
|
|
138
|
-
walk( childNode );
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
that.notify();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if ( !!element['nodeType'] && element.nodeType === 1 ){ // HTML element
|
|
145
|
-
//console.log('--type: HTMLElement(1)');
|
|
146
|
-
Array.from( (element as HTMLElement).attributes )
|
|
147
|
-
.forEach(
|
|
148
|
-
function( attributeNode ){
|
|
149
|
-
var placeholders = Array.from( attributeNode.value && attributeNode.value.match( /\{[^\{\}]*\}/g ) || []);
|
|
150
|
-
|
|
151
|
-
if ( placeholders.length > 0 ){
|
|
152
|
-
//console.log( `--[${attributeNode.value}] placeholders:`, placeholders );
|
|
153
|
-
|
|
154
|
-
var f=(function( template: string ){
|
|
155
|
-
return function( values: any ){
|
|
156
|
-
var t,
|
|
157
|
-
changed = false;
|
|
158
|
-
|
|
159
|
-
//console.log( 'placeholders:', placeholders, 'values:', values);
|
|
160
|
-
if ( placeholders ){
|
|
161
|
-
placeholders.forEach(function(pKey){
|
|
162
|
-
if ( ( f as LooseObject).values[pKey] !== values[pKey] ){
|
|
163
|
-
(f as LooseObject).values[pKey] = values[pKey];
|
|
164
|
-
changed = true;
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
if (changed){ // only reflow if changed
|
|
169
|
-
t = template;
|
|
170
|
-
element.nodeValue = parse(
|
|
171
|
-
t,
|
|
172
|
-
(f as LooseObject).values
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
return values;
|
|
176
|
-
};
|
|
177
|
-
})( attributeNode.value || '' );
|
|
178
|
-
|
|
179
|
-
(f as LooseObject).values = {};
|
|
180
|
-
placeholders = Array.from( placeholders ).map((pKey) => pKey.replace(/[\{\}]/g, '').trim());
|
|
181
|
-
let initial: LooseObject = {};
|
|
182
|
-
placeholders.forEach(function(pKey){
|
|
183
|
-
initial[pKey] = "";
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
bound.push(f);
|
|
187
|
-
// console.log( `--bound element attribute`, placeholders, f );
|
|
188
|
-
// console.log( `--bound`, observableFunction.bound );
|
|
189
|
-
//(observableFunction as Function)(initial);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
//console.log('--childNodes:', element.childNodes );
|
|
195
|
-
Array.from( element.childNodes )
|
|
196
|
-
.forEach(function( childNode ){
|
|
197
|
-
walk( childNode );
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
that.notify();
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if ( !!element['nodeType'] && element.nodeType === 11 ){ // shadowRoot node
|
|
205
|
-
// console.log( element, element.childNodes );
|
|
206
|
-
Array.from( element.childNodes )
|
|
207
|
-
.forEach(function( childNode ){
|
|
208
|
-
walk( childNode );
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
walk( target );
|
|
214
|
-
|
|
215
|
-
if ( bound.length > 0 ){
|
|
216
|
-
that.notify();
|
|
217
|
-
}
|
|
218
|
-
} else {
|
|
219
|
-
console.warn( 'IGNORED - cannot bind a non-Object to the dom, IS:', typeof that.valueOf() );
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return this;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
notify(){
|
|
226
|
-
let
|
|
227
|
-
that = this,
|
|
228
|
-
data = isObject( that.valueOf() ) && ( that.valueOf() instanceof Array ) === false
|
|
229
|
-
? structuredClone( Object.assign({}, that) )
|
|
230
|
-
: that.valueOf()
|
|
231
|
-
;
|
|
232
|
-
|
|
233
|
-
// console.log('notify', that.constructor, (that.constructor as any).callbacks.length, (that.constructor as any)?.bound?.length, data );
|
|
234
|
-
(that.constructor as any).callbacks.forEach( (f: Function) => {
|
|
235
|
-
// console.log( 'callback', f, data);
|
|
236
|
-
f( data );
|
|
237
|
-
});
|
|
238
|
-
if ( isObject( that.valueOf() ) ){
|
|
239
|
-
// console.log('bound', this.constructor);
|
|
240
|
-
(that.constructor as any).bound.forEach( (f: Function) => {
|
|
241
|
-
// console.log( 'bound', f, data);
|
|
242
|
-
f( data );
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
return this;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
//(Observable.constructor as LooseObject).callbacks = [];
|
|
250
|
-
let o = new Observable( val );
|
|
251
|
-
|
|
252
|
-
Object.defineProperty(
|
|
253
|
-
target,
|
|
254
|
-
key,
|
|
255
|
-
{
|
|
256
|
-
enumerable: true,
|
|
257
|
-
get(){
|
|
258
|
-
if ( isObject( o.valueOf() ) ){
|
|
259
|
-
let check = structuredClone( Object.assign( {}, o ) );
|
|
260
|
-
setTimeout(
|
|
261
|
-
debounce(
|
|
262
|
-
function checkChanges(){
|
|
263
|
-
let state = structuredClone( Object.assign( {}, o ) );
|
|
264
|
-
//console.log( 'check changes', state, check );
|
|
265
|
-
if ( !deepEqual( state, check ) ){
|
|
266
|
-
//console.log( '-> not equal!' );
|
|
267
|
-
o.notify();
|
|
268
|
-
}
|
|
269
|
-
},
|
|
270
|
-
0
|
|
271
|
-
),
|
|
272
|
-
0
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
return o;
|
|
276
|
-
},
|
|
277
|
-
set( val: any ){
|
|
278
|
-
//console.log( 'SET:', isObject( val.valueOf() ), 'set:', val, 'to', isObject( o.valueOf() ), o, );
|
|
279
|
-
if ( typeof val === typeof o.valueOf() ){
|
|
280
|
-
|
|
281
|
-
let iso = isObject( o.valueOf() ) && ( o.valueOf() instanceof Array ) === false;
|
|
282
|
-
//let iso = o.constructor.prototype.__proto__.constructor === Object;
|
|
283
|
-
//console.log('target iso:', iso);
|
|
284
|
-
if ( iso ){
|
|
285
|
-
let
|
|
286
|
-
old = structuredClone( Object.assign( {}, o ) )
|
|
287
|
-
;
|
|
288
|
-
|
|
289
|
-
val = structuredClone( Object.assign( {}, val ) );
|
|
290
|
-
|
|
291
|
-
let
|
|
292
|
-
hasFormHandler = (o.constructor as LooseObject)?.hasFormHandler ?? false,
|
|
293
|
-
callbacks = (o.constructor as LooseObject).callbacks,
|
|
294
|
-
bound = (o.constructor as LooseObject).bound
|
|
295
|
-
;
|
|
296
|
-
|
|
297
|
-
o = new Observable( structuredClone( Object.assign( {}, val ) ) );
|
|
298
|
-
|
|
299
|
-
//console.log('after set o=', o, 'check', old);
|
|
300
|
-
(o.constructor as LooseObject).callbacks = hasFormHandler;
|
|
301
|
-
(o.constructor as LooseObject).callbacks = callbacks;
|
|
302
|
-
(o.constructor as LooseObject).bound = bound;
|
|
303
|
-
|
|
304
|
-
setTimeout( // check for changes
|
|
305
|
-
debounce(
|
|
306
|
-
function checkChanges(){
|
|
307
|
-
let state = structuredClone( Object.assign( {}, o ) );
|
|
308
|
-
//console.log( 'check changes', state, check );
|
|
309
|
-
if ( !deepEqual( state, old ) ){
|
|
310
|
-
//console.log( '-> not equal!' );
|
|
311
|
-
o.notify();
|
|
312
|
-
}
|
|
313
|
-
},
|
|
314
|
-
0
|
|
315
|
-
),
|
|
316
|
-
0
|
|
317
|
-
);
|
|
318
|
-
} else { // simple native var
|
|
319
|
-
let
|
|
320
|
-
old = o.valueOf(),
|
|
321
|
-
callbacks = (o.constructor as LooseObject).callbacks
|
|
322
|
-
;
|
|
323
|
-
o = new Observable( val );
|
|
324
|
-
(o.constructor as LooseObject).callbacks = callbacks;
|
|
325
|
-
if ( val !== old ){
|
|
326
|
-
o.notify();
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
} else {
|
|
330
|
-
console.warn( 'IGNORED - cannot change observable types, IS:', typeof o.valueOf(), '- CANNOT BECOME:', typeof val );
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
);
|
|
335
|
-
|
|
336
|
-
target[key] = val;
|
|
337
|
-
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
type Callback = ( value: any ) => void;
|
|
343
|
-
|
|
344
|
-
export type Observable = {
|
|
345
|
-
observe: (cb: Callback) => void;
|
|
346
|
-
notify: () => void;
|
|
347
|
-
bind: (target: HTMLElement | ShadowRoot) => void;
|
|
348
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customSelectors.d.ts","sourceRoot":"","sources":["../src/customSelectors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,EAAE,EAA8C,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAqR3C,cAAM,WAAW;;IAIhB,IAAW,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAEjC;IAED,IAAW,KAAK,IAAI,WAAW,EAAE,CAEhC;IAED,IAAW,GAAG,CAAE,GAAG,EAAE,GAAG,CAAC,WAAW,CAAC,EAGpC;IAED,IAAW,MAAM,IAAI,MAAM,CAE1B;gBAEY,SAAS,CAAC,EAAE,SAAS,EAAE,OAAO,GAAE,GAAmB;IA8BhE,EAAE,CAAE,SAAS,CAAC,EAAE,MAAM,GAAI,SAAS;IAoBnC,GAAG,CAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,WAAW,GAAI,SAAS;IAa5D,QAAQ,CAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAI,SAAS;IAa3C,KAAK,CAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,WAAW,GAAI,SAAS;IAoB9D,MAAM,CAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,WAAW,GAAI,SAAS;IAiB/D,QAAQ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I,SAAS;IAI/C,IAAI,CAAE,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,OAAO,EAAE,OAAO,CAAC,EAAE,GAAG,GAAI,OAAO;IAI/F,MAAM,CAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,GAAI,SAAS;CAWpE;AAED,MAAM,WAAW,SAAU,SAAQ,UAAU;CAAE;AAE/C,eAAO,MAAM,EAAE,cAAgB,SAAS,YAAW,GAAG,KAAe,SAgBpE,CAAA;AAED,eAAO,MAAM,EAAE,eAAiB,SAAS,YAAW,GAAG,KAAe,SAErE,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,EAAE,GAAG,cAAc,GAAG,QAAQ,GAAG,SAAS,GAAG,EAAE,GAAG,EAAE,GAAG,SAAS,GAAG,SAAS,CAAC;AAEzJ,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,cAAc,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.customSelectors=t():e.customSelectors=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{$d:()=>E,$t:()=>m});var r=new Function("try {return this===window;}catch(e){ return false;}");let n=new Set;r()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>n.add(e)));var a=new Function("try {return this===window;}catch(e){ return false;}");let s=new Set;function i(e,t,r,n=!1,a=!1){let s={once:!1};n&&(s.capture=n),a&&(s.once=a),e.addEventListener(t,r,s)}function o(e,t,r){e.removeEventListener(t,r)}a()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>s.add(e)));const c=e=>{let t=new Set;return e.forEach((e=>{(e=e.trim()).split(" ").forEach((e=>{""!==e&&t.add(e)}))})),Array.from(t)},l=e=>{let t=E("input,select,textarea",e).array,r={};return t.forEach((t=>{const n=t.getAttribute("name")||"undefined";if(n){let a;switch((e=>e instanceof HTMLInputElement?"input":e instanceof HTMLSelectElement?"select":e instanceof HTMLTextAreaElement?"textarea":"")(t)){case"input":a=new f(t,e),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"select":a=new u(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;case"textarea":a=new d(t),Object.defineProperty(r,n,{enumerable:!0,configurable:!0,get:()=>a.val,set:e=>{a.val=e}});break;default:console.warn("handler missing:",n,"for",t)}}})),r};class h{constructor(e){}}class f extends h{#e;#t;#r;constructor(e,t){super(e),this.#e=e,this.#t=e.type,this.#r=t}get val(){let e,t=this;switch(t.#t){case"radio":const r=E(`input[type="radio"][name="${this.#e.getAttribute("name")}"]`,this.#r).filter((e=>e.checked));return r.length?(e=r.array[0],e.value):"";case"checkbox":return t.#e.checked;default:return t.#e.value}return""}set val(e){let t=this;switch(t.#t){case"radio":const r=`input[type="radio"][name="${this.#e.getAttribute("name")}"]`,n=E(r,this.#r);if(!n.length)return;if(""===e)return void n.forEach((e=>{e.checked&&(e.checked=!1)}));const a=n.filter((t=>t.getAttribute("value")===e));if(!a.length)return;return void(a.array[0].checked=!0);case"checkbox":t.#e.checked=e;break;default:t.#e.value=e}}}class u extends h{#e;#n=!1;constructor(e){super(e),this.#e=e,this.#n="select-multiple"===e.type}get val(){const e=[];return E(this.#e.querySelectorAll("option")).filter((e=>e.selected)).forEach((t=>{t.selected&&e.push(t.value)})),this.#n?e:e.length?e[0]:""}set val(e){e="string"==typeof e?[e]:e,E(this.#e.querySelectorAll("option")).forEach((t=>{e.indexOf(t.value)>-1?(t.setAttribute("selected",!0),t.selected=!0):(t.removeAttribute("selected"),t.selected=!1)}))}}class d extends h{#e;constructor(e){super(e),this.#e=e}get val(){return this.#e.value}set val(e){this.#e.value=e}}class p{#a=new Set;get set(){return this.#a}get array(){return Array.from(this.#a)}set set(e){this.#a=e}get length(){return this.#a.size}constructor(e,t=document.body){if(new Set,!e)return this}$t(e){let t=new y;return this.#a.forEach((e=>{e._mc&&Object.values(e._mc).forEach((e=>{t.set.add(e)}))})),e&&t.filter((t=>t.nameSpace===e)),t}add(e,t){let r=this;return E(e,t).forEach((e=>{r.#a.add(e)})),r}addClass(...e){return e=c(e),this.forEach((t=>{t.classList.add(...e)})),this}after(e,t){let r=this,n=E(e,t);return n.length?(n.first().forEach((e=>{r.array.reverse().forEach((t=>{t.after(e)}))})),r):r}append(e,t){let r=this.array[0],n=E(e,t);return r&&n.forEach((e=>{r.append(e)})),this}appendTo(e,t){let r=E(e,t).array[0];return r&&this.forEach((e=>{r.append(e)})),this}attr(e,t){let r=this,n={};return r.length?arguments.length?"string"==typeof e?void 0===t?[...r.set][0].getAttribute(e):null===t?([...r.set].forEach((t=>{t.removeAttribute(e)})),r):("object"==typeof t&&(t=JSON.stringify(t)),[...r.set].forEach((r=>{r.setAttribute(e,t)})),r):"object"==typeof e?([...r.set].forEach((t=>{Object.keys(e).forEach((r=>{E(t).attr(r,e.key)}))})),r):r:(Array.from([...r.set][0].attributes).forEach((e=>{n[e.name]=e.value})),n):r}before(e,t){let r=this,n=E(e,t);return n.length?(n.first().forEach((e=>{r.forEach((t=>{t.before(e)}))})),r):r}children(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{Array.from(e.children).forEach((e=>{n.add(e)}))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}descendants(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{e.querySelectorAll("*").forEach((e=>{n.add(e)}))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}empty(){return this.filter((e=>!1))}first(e,t){let r=this,n=new Set,a=!1;return e&&(a=E(e,t)),r.#a.forEach((e=>{e.parentNode&&n.add(e.parentNode.children[0])})),r=E([...n]),e&&r.filter((e=>a.has(e))),r}has(e){return this.#a.has(e)}hasClass(...e){return e=c(e),this.every((e=>Array.from(e.classList).every((t=>e.contains(t)))))}html(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerHTML=e:(()=>{console.warn("Cannot access the .innerHTML of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerHTML}last(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;t&&n.add(Array.from(t).at(-1))})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}next(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)+1;a<r.length&&n.add(r.at(a))}})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}normalize(){return this.#a.forEach((e=>{e.normalize()})),this}off(e,t){let r=e.indexOf(" ")>-1?e.split(" "):[e];return this.array.forEach((e=>{r.forEach((function(r){o(e,r,t)}))})),this}on(e,t,r=!1,n=!1){let a=this,s=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function o(){o.cb.apply(a,Array.from(arguments))}return o.cb=t,a.forEach((e=>{s.forEach((function(t){i(e,t,o,r,n)}))})),o}one(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){i(e,t,s,r,!0)}))})),s}parent(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{e.parentNode&&"HTML"!==e.parentNode.tagName&&n.add(e.parentNode)})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}parents(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e;for(;t.parentNode&&"HTML"!==t.parentNode.tagName;)t=t.parentNode,n.add(t)})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}prepend(e,t){let r=this.array[0],n=E(e,t);return r&&n.forEach((e=>{r.prepend(e)})),this}prev(e,t){let r=this,n=new Set;if(r.#a.forEach((e=>{let t=e.parentNode?.children;if(t){let r=Array.from(t),a=r.indexOf(e)-1;a>-1&&n.add(r.at(a))}})),r=E([...n]),e){let n=E(e,t);r.filter((e=>n.has(e)))}return r}removeClass(...e){return e=c(e),this.forEach((t=>{t.classList.remove(...e)})),this}text(e){let t=this;return e?(t.forEach((t=>{t.parentNode?t.innerText=e:(()=>{console.warn("Cannot access the .textContent of a HTMLElement that hasnt been inserted yet",t),console.trace(t,this),console.info("If you called this from inside a Web Component constructor, consider using the %c[connected] event callback!","color: blue;")})()})),t):t.array[0].innerText??""}toggleClass(...e){return e=c(e),this.forEach((t=>{t.classList.toggle(...e)})),this}trigger(e,t={},r=!1,n=!1,a=!1){let s,i={bubbles:r,cancelable:n,composed:a},o=e.indexOf(" ")>-1?e.split(" "):[e];return this.#a.forEach((e=>{o.forEach((function(r){s=new Event(r,i),s.data=t,e.dispatchEvent(s)}))})),this}val(e,t){if(!this.length)return this;const r=this;let n,a=l(r.array[0]);var s;return e?null!=(s=e)&&"object"==typeof s?(Object.assign(a,e),n=r):"string"==typeof e&&(void 0===t?n=a[e]:(a[e]=t,n=r)):n=Object.assign({},a),n}values(e){const t=this;let r={};if(!t.length)return console.warn("no dom selection to search inputs in"),{};let n=l(t.array[0]);return Object.keys(n).forEach((e=>{r[e]=n[e]})),0===Object.keys(r).length&&console.warn("no inputs in this dom selection",t.array[0],r),e&&Object.keys(e).forEach((t=>{n.hasOwnProperty(t)&&(console.log("key found",t),n[t]=e[t])})),structuredClone(Object.assign(n))}at(e){return E(this.array.at(e))}concat(e){let t=this;return(e instanceof p?e.array:e).forEach((e=>{t.#a.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return this.#a=new Set(this.array.filter(e,t)),this}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e,0)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){return this.array.pop()}push(...e){return e.forEach((e=>{this.#a.add(e)})),this}shift(){let e=this,t=e.#a.size?e.array[0]:void 0;return t&&e.#a.delete(t),t}slice(e,t){return E(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array;return n.splice(e,t,...r),E(n)}}class y{#a=new Set;get set(){return this.#a}get array(){return Array.from(this.#a)}set set(e){this.#a=e}get length(){return this.#a.size}set length(e){}constructor(e,t=document.body){if(!e)return this;E(e,t).forEach((e=>{m(e).forEach((e=>{this.#a.add(e)}))}))}$d(e,t=document.body){let r=new p,n=new Set,a=!!e||!1,s=new Set;return a&&(s=E(e,t).set),this.#a.forEach((e=>{a&&!s.has(e._tg)||n.add(e._tg)})),r.set=n,r}children(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.children(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}descendants(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.descendants(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}first(e){let t=this,r=new Set;return t.#a.forEach((e=>{e.parent().children().$d().first().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}has(e){return this.#a.has(e)}last(e){let t=this,r=new Set;return t.#a.forEach((e=>{e.parent().children().$d().last().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}next(e){let t=this,r=new Set;return t.#a.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.nextElementSibling;)t=t.nextElementSibling,n.add(t);m([...n]).$d().first().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}ns(e){return this.filter((t=>t.nameSpace===e))}off(e,t){let r=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];return this.$d().array.forEach((e=>{r.forEach((function(r){o(e,`[TB]${r}`,t)}))})),this}on(e,t,r=!1){let n=this,a=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function s(){s.cb.apply(n,Array.from(arguments))}return s.cb=t,n.forEach((e=>{a.forEach((function(t){i(e._tg,`[TB]${t}`,s,!1,r)}))})),s}one(e,t){let r=this,n=e.indexOf(" ")>-1?e.split(" ").filter((e=>""!==e)):[e];function a(){a.cb.apply(r,Array.from(arguments))}return a.cb=t,r.forEach((e=>{n.forEach((function(t){i(e._tg,`[TB]${t}`,a,!1,!0)}))})),a}parent(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.parent(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}parents(e){let t=this,r=new Set;return t.#a.forEach((t=>{t.parents(e).forEach((e=>{r.add(e)}))})),t.#a=r,t}prev(e){let t=this,r=new Set;return t.#a.forEach((e=>{let t,n=new Set;for(t=e._tg;null!==t.previousElementSibling;)t=t.previousElementSibling,n.add(t);m([...n]).$d().last().$t().forEach((e=>{r.add(e)}))})),t.#a=r,e&&t.filter((t=>t.nameSpace=e)),t}trigger(e,t={},r="l"){return this.forEach((n=>{n.trigger(e,t,r)})),this}at(e){return m(this.array.at(e))}concat(e){let t=this;return e.forEach((e=>{t.#a.add(e)})),t}entries(){return this.array.entries()}every(e,t){return this.array.every(e,t)}filter(e,t){return m(this.array.filter(e,t))}forEach(e,t){return this.array.forEach(e,t),this}includes(e){return-1!==this.array.indexOf(e)}indexOf(e,t){return this.array.indexOf(e,t)}map(e,t){return this.array.map(e,t)}pop(){let e=this.array,t=e.pop();return this.#a=new Set(e),t}push(e){return this.#a.add(e),this}shift(){let e=this.array.shift();return this.#a.delete(e),e}slice(e,t){return m(this.array.slice(e,t))}some(e,t){return this.array.some(e,t)}splice(e,t,...r){let n=this.array.splice(e,t,...r);return m(n)}}const E=(e,t=document)=>{let r=new Set;return e instanceof Array?(e.forEach((e=>{E(e,t).forEach((e=>{r.add(e)}))})),new p([...r])):new p(e,t)},m=(e,t=document)=>E(e,t).$t();return t})()));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customElements.js","sourceRoot":"","sources":["../src/customElements.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,WAAY,SAAQ,WAAW;IACpC;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAED,iBAAiB;QACf,EAAU,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACxC,CAAC;IAED,oBAAoB;QAClB,EAAU,CAAC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAC3C,CAAC;IAED,eAAe;QACb,EAAU,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtC,CAAC;IAED,wBAAwB,CAAC,IAAY,EAAE,QAAa,EAAE,QAAa;QACjE,EAAU,CAAC,OAAO,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC7E,CAAC;CACD;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,SAAwC;IAC/E,OAAO,MAAM,CAAC,cAAc,CAAE,SAAS,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,QAAQ,CAAE,OAAe,EAAE,eAA8C,EAAE,qBAA+B,EAAE;IAC3H,IAAI,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,4BAA4B,OAAO,uBAAuB,CAAC,CAAC;QACzE,OAAO;IACR,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;IACzF,CAAC;IAED,IAAI,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAElC,cAAc,CAAC,MAAM,CACpB,OAAO,EACP,gBAAgB,CACf,IAAI,EACJ,KAAM,SAAQ,WAAW;QACxB,QAAQ,CAAM;QAEd,YAAa,IAAU;YACtB,KAAK,EAAE,CAAC;YACR,IAAI,QAAQ,GAAG,IAAI,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC7C,EAAW,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAE,CAAC;QAC1C,CAAC;QAED,MAAM,KAAK,kBAAkB;YAC5B,OAAO,kBAAkB,CAAC;QAC3B,CAAC;KACD,CACD,CACD,CAAC;AACH,CAAC;AAAA,CAAC;AAEF,MAAM,UAAU,KAAK,CAAC,OAAe;IACpC,OAAO,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.customElements=t():e.customElements=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{defineCE:()=>h,getCE:()=>y});var r=new Function("try {return this===window;}catch(e){ return false;}");let n=new Set;r()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>n.add(e)));class o{#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 i=new Function("try {return this===window;}catch(e){ return false;}");let c=new Set;function s(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 a(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 u(e){return e&&e instanceof HTMLElement}function l(e,t,r={}){let n=e;if(!n._mc){let t=g?.debug;g.debug=!1,n._mc=new g(e),g.debug=t,delete n._mc._mc}const o=n._mc;return t.length&&!o[t]&&(o[t]=r,e instanceof HTMLElement&&e.setAttribute("_mc","")),r}function d(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 p(e,t,r={}){let n=e?._mc;n&&[...Object.values(n)].forEach((e=>{e?.trigger&&"function"==typeof e?.trigger&&e?.trigger(t,r)}))}i()&&Object.keys(HTMLElement.prototype).filter((e=>/^on/.test(e))).forEach((e=>c.add(e)));class f{#n;constructor(e){var t;this.#n=new WeakRef(e||{}),(t=this).constructor!==g&&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 o("Init"))}))}),0)}),0),function(e){if(!i()||e.constructor===g)return;const t=e.target;if(t instanceof HTMLElement){let r=e;Object.getOwnPropertyNames(r.constructor.prototype).filter((e=>/^on[A-Z]|one[A-Z]/.test(e)&&"function"==typeof r.constructor.prototype[e])).forEach((n=>{let o=/^one/.test(n),i=n.replace(/^on[e]{0,1}/,""),s=i.toLowerCase();o&&Object.defineProperty(e,"on"+i,{configurable:!0,enumerable:!1,writable:!0,value:e=>{r.constructor.prototype[n].bind(r)(e)}}),c.has("on"+s)&&function(e,t,r,n=!1,o=!1){let i={once:!1};n&&(i.capture=n),o&&(i.once=o),e.addEventListener(t,r,i)}(t,s,(e=>{r.trigger(i,e)}),!1,o)}))}}(this)}get target(){return this.#n.deref()}}class m extends f{_mc={};constructor(e){super(e)}static trigger=p;trigger(e,t={},r){let n=this;if(r=r||"l",n.constructor!==m&&n.constructor!==g){if(n instanceof m||n instanceof g){const n=this,c="string"!=typeof e?e:new o(e,t,r),s="on"+c.type[0].toUpperCase()+c.type.slice(1);if(c.bubble.indexOf("l")>-1&&(c.immediateStopped||"function"!=typeof n[s]||(n[s](c),n.hasOwnProperty(s)&&delete n[s])),c.stopped||"l"===c.bubble)return n;i()&&/[ud]/.test(c.bubble)&&n instanceof m&&setTimeout((()=>{-1===c.bubble.indexOf("l")&&(c.bubble+="l"),c.bubble.indexOf("u")>-1&&n.parent().forEach((e=>{e instanceof m&&e.trigger(c)})),c.bubble.indexOf("d")>-1&&n.children().forEach((e=>{e instanceof m&&e.trigger(c)}))}),0)}}else[...Object.getOwnPropertyNames(n)].forEach((o=>{n[o]?.trigger&&"function"==typeof n[o]?.trigger&&n[o]?.trigger(e,t,r)}))}}class g extends f{_mc={};constructor(e){super(e)}static debug=!1;static add=l;static remove=d;static trigger=p;trigger(e,t={},r){m.prototype.trigger.call(this,e,t,r)}parent(e=""){let t=this.target;return u(t)?a(t.parentNode,e,!0):[]}ancestors(e=""){let t=this?.target;return u(t)?a(this.target.parentNode,e,!1):[]}children(e=""){let t=this?.target;if(!u(t))return[];const r=Math.random().toString().replace(".",""),n='[_mc]:not([temp_id="'+r+'"] [_mc] [_mc])';t.setAttribute("temp_id",r);const o=s([...t.querySelectorAll(n)],e);return t.removeAttribute("temp_id"),o}descendants(e=""){let t=this?.target;return u(t)?s([...t.querySelectorAll("*[_mc]")],e):[]}}class b extends HTMLElement{constructor(){super()}connectedCallback(){g.trigger(this,"Connected")}disconnectedCallback(){g.trigger(this,"Disconnected")}adoptedCallback(){g.trigger(this,"Adopted")}attributeChangedCallback(e,t,r){g.trigger(this,"AttributeChanged",{name:e,oldValue:t,newValue:r})}}function h(e,t,r=[]){if(customElements.get(e))return void console.warn(`IGNORED: Custom element "${e}" is already defined!`);if(!e.includes("-"))throw new Error('createCustomElement: tagName must contain at least one hyphen ("-").');let n=e.split("-").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join("");customElements.define(e,function(e,t){return Object.defineProperty(t,"name",{value:e})}(n,class extends b{instance;constructor(e){super();let r=new t(this,e);g.add(this,n,r)}static get observedAttributes(){return r}}))}function y(e){return customElements.get(e)}return t})()));
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
import { isObject, parse, debounce, deepEqual } from './helpers.js';
|
|
3
|
-
export const observe = (target, propertyName) => {
|
|
4
|
-
let keys = !propertyName ? [...Object.getOwnPropertyNames(target)] : [propertyName];
|
|
5
|
-
keys.forEach((key) => {
|
|
6
|
-
// console.log( 'co propname', key, typeof target[key], target[key] );
|
|
7
|
-
if (key[0] === '_' || target?.[key] === undefined)
|
|
8
|
-
return;
|
|
9
|
-
let val = target[key], Constructor;
|
|
10
|
-
if (!val.prototype) {
|
|
11
|
-
switch (typeof val) {
|
|
12
|
-
case "string":
|
|
13
|
-
Constructor = String;
|
|
14
|
-
break;
|
|
15
|
-
case "number":
|
|
16
|
-
Constructor = Number;
|
|
17
|
-
break;
|
|
18
|
-
case "boolean":
|
|
19
|
-
Constructor = Boolean;
|
|
20
|
-
break;
|
|
21
|
-
case "object":
|
|
22
|
-
if (val instanceof Array) {
|
|
23
|
-
Constructor = Array;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
Constructor = Object;
|
|
27
|
-
}
|
|
28
|
-
break;
|
|
29
|
-
default:
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
let Observable = class extends Constructor {
|
|
34
|
-
constructor(val) {
|
|
35
|
-
super(val);
|
|
36
|
-
this.constructor.callbacks = [];
|
|
37
|
-
if (isObject(val)) { // you cannot bind native values to the dom
|
|
38
|
-
this.constructor.bound = [];
|
|
39
|
-
Object.getOwnPropertyNames(val).forEach((key) => {
|
|
40
|
-
this[key] = val[key];
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
observe(f) {
|
|
45
|
-
//console.log('observe');
|
|
46
|
-
this.constructor.callbacks.push(f);
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
bind(target) {
|
|
50
|
-
const that = this, iso = isObject(that.valueOf()), bound = that.constructor.bound;
|
|
51
|
-
//console.log('bind', iso, target);
|
|
52
|
-
if (iso) {
|
|
53
|
-
// console.log('bind...', that.valueOf(), target );
|
|
54
|
-
function walk(element) {
|
|
55
|
-
//console.log('-walk:', element, element.childNodes );
|
|
56
|
-
if (!!element['nodeType'] && element.nodeType === 3) { // text node
|
|
57
|
-
//console.log('--type: textNode(3)');
|
|
58
|
-
var placeholders = Array.from(element.nodeValue && element.nodeValue.match(/\{[^\{\}]*\}/g) || []);
|
|
59
|
-
if (placeholders.length > 0) {
|
|
60
|
-
//console.log('--placeholders:', placeholders);
|
|
61
|
-
var f = (function (template) {
|
|
62
|
-
//console.log('template', template);
|
|
63
|
-
return function (values) {
|
|
64
|
-
var t, changed = false;
|
|
65
|
-
//console.log( 'placeholders:', placeholders, 'values:', values);
|
|
66
|
-
if (placeholders) {
|
|
67
|
-
if (iso) {
|
|
68
|
-
placeholders.forEach(function (placeholder) {
|
|
69
|
-
if (f.values[placeholder] !== values[placeholder]) {
|
|
70
|
-
f.values[placeholder] = values[placeholder];
|
|
71
|
-
changed = true;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
else { // it is a simple value
|
|
76
|
-
f.values = values;
|
|
77
|
-
changed = true;
|
|
78
|
-
}
|
|
79
|
-
;
|
|
80
|
-
}
|
|
81
|
-
if (changed) { // only reflow if changed
|
|
82
|
-
t = template;
|
|
83
|
-
//console.log('--template parse', t, (f as LooseObject).values );
|
|
84
|
-
if (iso) {
|
|
85
|
-
element.nodeValue = parse(t, f.values);
|
|
86
|
-
}
|
|
87
|
-
else { // it is a simple value -> replace every placeholder whatever the name wi
|
|
88
|
-
element.nodeValue = t.replace(/\{.*\}/g, f.values);
|
|
89
|
-
}
|
|
90
|
-
;
|
|
91
|
-
}
|
|
92
|
-
return values;
|
|
93
|
-
};
|
|
94
|
-
})(element.nodeValue || '');
|
|
95
|
-
f.values = iso ? {} : undefined;
|
|
96
|
-
placeholders = Array.from(placeholders).map((pKey) => pKey.replace(/[\{\}]/g, '').trim());
|
|
97
|
-
let initial = iso ? {} : undefined;
|
|
98
|
-
placeholders.forEach(function (pKey) {
|
|
99
|
-
if (iso) {
|
|
100
|
-
initial[pKey] = "";
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
bound.push(f);
|
|
104
|
-
// console.log( `--bound textNode`, placeholders, f );
|
|
105
|
-
//(observableFunction as Function)(initial);
|
|
106
|
-
}
|
|
107
|
-
//console.log('--childNodes:', element.childNodes );
|
|
108
|
-
Array.from(element.childNodes)
|
|
109
|
-
.forEach(function (childNode) {
|
|
110
|
-
walk(childNode);
|
|
111
|
-
});
|
|
112
|
-
that.notify();
|
|
113
|
-
}
|
|
114
|
-
if (!!element['nodeType'] && element.nodeType === 1) { // HTML element
|
|
115
|
-
//console.log('--type: HTMLElement(1)');
|
|
116
|
-
Array.from(element.attributes)
|
|
117
|
-
.forEach(function (attributeNode) {
|
|
118
|
-
var placeholders = Array.from(attributeNode.value && attributeNode.value.match(/\{[^\{\}]*\}/g) || []);
|
|
119
|
-
if (placeholders.length > 0) {
|
|
120
|
-
//console.log( `--[${attributeNode.value}] placeholders:`, placeholders );
|
|
121
|
-
var f = (function (template) {
|
|
122
|
-
return function (values) {
|
|
123
|
-
var t, changed = false;
|
|
124
|
-
//console.log( 'placeholders:', placeholders, 'values:', values);
|
|
125
|
-
if (placeholders) {
|
|
126
|
-
placeholders.forEach(function (pKey) {
|
|
127
|
-
if (f.values[pKey] !== values[pKey]) {
|
|
128
|
-
f.values[pKey] = values[pKey];
|
|
129
|
-
changed = true;
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
if (changed) { // only reflow if changed
|
|
134
|
-
t = template;
|
|
135
|
-
element.nodeValue = parse(t, f.values);
|
|
136
|
-
}
|
|
137
|
-
return values;
|
|
138
|
-
};
|
|
139
|
-
})(attributeNode.value || '');
|
|
140
|
-
f.values = {};
|
|
141
|
-
placeholders = Array.from(placeholders).map((pKey) => pKey.replace(/[\{\}]/g, '').trim());
|
|
142
|
-
let initial = {};
|
|
143
|
-
placeholders.forEach(function (pKey) {
|
|
144
|
-
initial[pKey] = "";
|
|
145
|
-
});
|
|
146
|
-
bound.push(f);
|
|
147
|
-
// console.log( `--bound element attribute`, placeholders, f );
|
|
148
|
-
// console.log( `--bound`, observableFunction.bound );
|
|
149
|
-
//(observableFunction as Function)(initial);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
//console.log('--childNodes:', element.childNodes );
|
|
153
|
-
Array.from(element.childNodes)
|
|
154
|
-
.forEach(function (childNode) {
|
|
155
|
-
walk(childNode);
|
|
156
|
-
});
|
|
157
|
-
that.notify();
|
|
158
|
-
}
|
|
159
|
-
if (!!element['nodeType'] && element.nodeType === 11) { // shadowRoot node
|
|
160
|
-
// console.log( element, element.childNodes );
|
|
161
|
-
Array.from(element.childNodes)
|
|
162
|
-
.forEach(function (childNode) {
|
|
163
|
-
walk(childNode);
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
walk(target);
|
|
168
|
-
if (bound.length > 0) {
|
|
169
|
-
that.notify();
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
console.warn('IGNORED - cannot bind a non-Object to the dom, IS:', typeof that.valueOf());
|
|
174
|
-
}
|
|
175
|
-
return this;
|
|
176
|
-
}
|
|
177
|
-
notify() {
|
|
178
|
-
let that = this, data = isObject(that.valueOf()) && (that.valueOf() instanceof Array) === false
|
|
179
|
-
? structuredClone(Object.assign({}, that))
|
|
180
|
-
: that.valueOf();
|
|
181
|
-
// console.log('notify', that.constructor, (that.constructor as any).callbacks.length, (that.constructor as any)?.bound?.length, data );
|
|
182
|
-
that.constructor.callbacks.forEach((f) => {
|
|
183
|
-
// console.log( 'callback', f, data);
|
|
184
|
-
f(data);
|
|
185
|
-
});
|
|
186
|
-
if (isObject(that.valueOf())) {
|
|
187
|
-
// console.log('bound', this.constructor);
|
|
188
|
-
that.constructor.bound.forEach((f) => {
|
|
189
|
-
// console.log( 'bound', f, data);
|
|
190
|
-
f(data);
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
return this;
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
//(Observable.constructor as LooseObject).callbacks = [];
|
|
197
|
-
let o = new Observable(val);
|
|
198
|
-
Object.defineProperty(target, key, {
|
|
199
|
-
enumerable: true,
|
|
200
|
-
get() {
|
|
201
|
-
if (isObject(o.valueOf())) {
|
|
202
|
-
let check = structuredClone(Object.assign({}, o));
|
|
203
|
-
setTimeout(debounce(function checkChanges() {
|
|
204
|
-
let state = structuredClone(Object.assign({}, o));
|
|
205
|
-
//console.log( 'check changes', state, check );
|
|
206
|
-
if (!deepEqual(state, check)) {
|
|
207
|
-
//console.log( '-> not equal!' );
|
|
208
|
-
o.notify();
|
|
209
|
-
}
|
|
210
|
-
}, 0), 0);
|
|
211
|
-
}
|
|
212
|
-
return o;
|
|
213
|
-
},
|
|
214
|
-
set(val) {
|
|
215
|
-
//console.log( 'SET:', isObject( val.valueOf() ), 'set:', val, 'to', isObject( o.valueOf() ), o, );
|
|
216
|
-
if (typeof val === typeof o.valueOf()) {
|
|
217
|
-
let iso = isObject(o.valueOf()) && (o.valueOf() instanceof Array) === false;
|
|
218
|
-
//let iso = o.constructor.prototype.__proto__.constructor === Object;
|
|
219
|
-
//console.log('target iso:', iso);
|
|
220
|
-
if (iso) {
|
|
221
|
-
let old = structuredClone(Object.assign({}, o));
|
|
222
|
-
val = structuredClone(Object.assign({}, val));
|
|
223
|
-
let hasFormHandler = o.constructor?.hasFormHandler ?? false, callbacks = o.constructor.callbacks, bound = o.constructor.bound;
|
|
224
|
-
o = new Observable(structuredClone(Object.assign({}, val)));
|
|
225
|
-
//console.log('after set o=', o, 'check', old);
|
|
226
|
-
o.constructor.callbacks = hasFormHandler;
|
|
227
|
-
o.constructor.callbacks = callbacks;
|
|
228
|
-
o.constructor.bound = bound;
|
|
229
|
-
setTimeout(// check for changes
|
|
230
|
-
debounce(function checkChanges() {
|
|
231
|
-
let state = structuredClone(Object.assign({}, o));
|
|
232
|
-
//console.log( 'check changes', state, check );
|
|
233
|
-
if (!deepEqual(state, old)) {
|
|
234
|
-
//console.log( '-> not equal!' );
|
|
235
|
-
o.notify();
|
|
236
|
-
}
|
|
237
|
-
}, 0), 0);
|
|
238
|
-
}
|
|
239
|
-
else { // simple native var
|
|
240
|
-
let old = o.valueOf(), callbacks = o.constructor.callbacks;
|
|
241
|
-
o = new Observable(val);
|
|
242
|
-
o.constructor.callbacks = callbacks;
|
|
243
|
-
if (val !== old) {
|
|
244
|
-
o.notify();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
console.warn('IGNORED - cannot change observable types, IS:', typeof o.valueOf(), '- CANNOT BECOME:', typeof val);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
target[key] = val;
|
|
254
|
-
});
|
|
255
|
-
};
|
|
256
|
-
//# sourceMappingURL=customObservables.js.map
|