@twobirds/microcomponents 0.0.72 → 0.0.75
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 +35 -24
- package/assets/documentation/MC.md +2 -2
- package/assets/documentation/MicroComponents.svg +15 -0
- package/assets/documentation/elements.md +18 -16
- package/assets/documentation/formvalues.md +5 -26
- package/assets/documentation/observables.md +18 -24
- package/assets/test/test.html +5 -4
- package/assets/test/testform.json +27 -0
- package/dist/MC.d.ts +2 -2
- package/dist/MC.d.ts.map +1 -1
- package/dist/MC.min.js +2 -1
- package/dist/MC.ts +6 -3
- package/dist/elements.min.js +1 -1
- package/dist/formValues.d.ts.map +1 -1
- package/dist/formValues.ts +0 -14
- package/dist/formvValues.min.js +1 -1
- package/dist/microcomponents.min.js +1 -1
- package/dist/observables.d.ts.map +1 -1
- package/dist/observables.min.js +1 -1
- package/dist/observables.ts +177 -169
- package/dist/selectors.min.js +1 -1
- package/package.json +1 -1
- package/public/MC.d.ts +2 -2
- package/public/MC.d.ts.map +1 -1
- package/public/MC.js +4 -3
- package/public/MC.js.map +1 -1
- package/public/MC.min.js +2 -1
- package/public/MC.ts +6 -3
- package/public/documentation/MC.md +2 -2
- package/public/documentation/MicroComponents.svg +15 -0
- package/public/documentation/elements.md +18 -16
- package/public/documentation/formvalues.md +5 -26
- package/public/documentation/klemmstein.png +0 -0
- package/public/documentation/observables.md +18 -24
- package/public/elements.min.js +1 -1
- package/public/formValues.d.ts.map +1 -1
- package/public/formValues.js.map +1 -1
- package/public/formValues.ts +0 -14
- package/public/formvValues.min.js +1 -1
- package/public/microcomponents.min.js +1 -1
- package/public/observables.d.ts.map +1 -1
- package/public/observables.js +111 -118
- package/public/observables.js.map +1 -1
- package/public/observables.min.js +1 -1
- package/public/observables.ts +177 -169
- package/public/selectors.min.js +1 -1
- package/public/src/MC.ts +6 -3
- package/public/src/formValues.ts +0 -14
- package/public/src/observables.ts +177 -169
- package/public/test/MC.d.ts +2 -2
- package/public/test/MC.d.ts.map +1 -1
- package/public/test/MC.js +4 -3
- package/public/test/MC.js.map +1 -1
- package/public/test/MC.ts +6 -3
- package/public/test/formValues.d.ts.map +1 -1
- package/public/test/formValues.js.map +1 -1
- package/public/test/formValues.ts +0 -14
- package/public/test/microcomponents.min.js +1 -1
- package/public/test/observables.d.ts.map +1 -1
- package/public/test/observables.js +111 -118
- package/public/test/observables.js.map +1 -1
- package/public/test/observables.ts +177 -169
- package/public/test/test/grandparent.js +1 -1
- package/public/test/test/testform.js +1 -1
- package/public/test/test/testform.js.map +1 -1
- package/public/test/test.d.ts.map +1 -1
- package/public/test/test.html +5 -4
- package/public/test/test.js +5 -6
- package/public/test/test.js.map +1 -1
- package/public/test/testform.json +27 -0
- package/public/typedoc/assets/navigation.js +1 -1
- package/public/typedoc/assets/search.js +1 -1
- package/public/typedoc/classes/MC.DC.html +2 -2
- package/public/typedoc/classes/MC.MC.html +2 -2
- package/public/typedoc/classes/MC.McBase.html +2 -2
- package/public/typedoc/classes/MC.McEvent.html +2 -2
- package/public/typedoc/functions/MC.addListener.html +1 -1
- package/public/typedoc/functions/MC.autoload.html +1 -1
- package/public/typedoc/functions/MC.removeListener.html +1 -1
- package/public/typedoc/functions/elements.defineCE.html +1 -1
- package/public/typedoc/functions/elements.getCE.html +1 -1
- package/public/typedoc/functions/formValues.formValues.html +1 -1
- package/public/typedoc/functions/observables.observe.html +1 -1
- package/public/typedoc/index.html +40 -23
- package/public/typedoc/interfaces/MC.HTMLMcElement.html +2 -2
- package/public/typedoc/modules/MC.html +1 -1
- package/public/typedoc/modules/elements.html +1 -1
- package/public/typedoc/modules/formValues.html +1 -1
- package/public/typedoc/modules/observables.html +1 -1
- package/public/typedoc/modules.html +0 -1
- package/public/typedoc/types/observables.Observable.html +1 -1
- package/src/MC.ts +6 -3
- package/src/formValues.ts +0 -14
- package/src/observables.ts +177 -169
- package/src/test/test/testform.ts +10 -2
- package/src/{test.ts → test/test.ts} +32 -26
- package/tsconfig.json +2 -2
- package/typedoc.json +1 -1
- package/checklist.md +0 -93
- package/dist/microcomponents.es3.d.ts +0 -2
- package/dist/microcomponents.es3.d.ts.map +0 -1
- package/dist/test.d.ts +0 -2
- package/dist/test.d.ts.map +0 -1
- package/dist/test.ts +0 -194
- package/public/microcomponents.es3.d.ts +0 -2
- package/public/microcomponents.es3.d.ts.map +0 -1
- package/public/microcomponents.es3.js +0 -303
- package/public/microcomponents.es3.js.map +0 -1
- package/public/src/test.ts +0 -194
- package/public/test/microcomponents.es3.d.ts +0 -2
- package/public/test/microcomponents.es3.d.ts.map +0 -1
- package/public/test/microcomponents.es3.js +0 -303
- package/public/test/microcomponents.es3.js.map +0 -1
- package/public/test/test.ts +0 -194
- package/public/typedoc/functions/selectors._d.html +0 -1
- package/public/typedoc/functions/selectors._t.html +0 -1
- package/public/typedoc/interfaces/selectors.DSelector.html +0 -50
- package/public/typedoc/interfaces/selectors.TSelector.html +0 -34
- package/public/typedoc/modules/selectors.html +0 -7
- package/public/typedoc/types/selectors.selection.html +0 -1
- package/public/typedoc/types/selectors.singleSelector.html +0 -1
- package/src/microcomponents.es3.js +0 -377
- /package/{klemmstein.png → assets/documentation/klemmstein.png} +0 -0
package/src/observables.ts
CHANGED
|
@@ -194,207 +194,215 @@ function makePlaceholders(
|
|
|
194
194
|
export type Observable = {
|
|
195
195
|
observe: (cb: Callback) => void;
|
|
196
196
|
notify: () => void;
|
|
197
|
-
bind: (target: HTMLElement | DocumentFragment | ShadowRoot) => void;
|
|
197
|
+
bind: (target: HTMLElement | DocumentFragment | ShadowRoot ) => void;
|
|
198
198
|
};
|
|
199
199
|
|
|
200
|
-
|
|
201
|
-
target: LooseObject,
|
|
202
|
-
propertyName?: string
|
|
203
|
-
): LooseObject => {
|
|
204
|
-
let keys = !propertyName
|
|
205
|
-
? [...Object.getOwnPropertyNames(target)]
|
|
206
|
-
: [propertyName];
|
|
200
|
+
type Class<T> = new (...args: any[]) => T;
|
|
207
201
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
Constructor = Object;
|
|
230
|
-
}
|
|
231
|
-
break;
|
|
232
|
-
default:
|
|
233
|
-
return;
|
|
202
|
+
// repository for observable class wrappers
|
|
203
|
+
const classRepo: LooseObject = {};
|
|
204
|
+
|
|
205
|
+
// creates a new observable class wrapper
|
|
206
|
+
function makeObservable(val: any): Class<typeof val>{
|
|
207
|
+
|
|
208
|
+
const Constructor = val.constructor,
|
|
209
|
+
ConstructorName: string = Constructor.name;
|
|
210
|
+
|
|
211
|
+
let ObservableClass = class extends Constructor {
|
|
212
|
+
#notify: boolean = true;
|
|
213
|
+
#callbacks: Array<Function> = [];
|
|
214
|
+
|
|
215
|
+
constructor(val: any) {
|
|
216
|
+
super(val);
|
|
217
|
+
(this.constructor as LooseObject).callbacks = [];
|
|
218
|
+
if (isObservableObject(val)) {
|
|
219
|
+
// you cannot bind native values to the dom
|
|
220
|
+
Object.getOwnPropertyNames(val).forEach((key) => {
|
|
221
|
+
this[key] = val[key];
|
|
222
|
+
});
|
|
234
223
|
}
|
|
235
224
|
}
|
|
236
225
|
|
|
237
|
-
|
|
238
|
-
|
|
226
|
+
observe(f: Function) {
|
|
227
|
+
//console.log('observe');
|
|
228
|
+
this.#callbacks.push(f);
|
|
229
|
+
return this;
|
|
230
|
+
}
|
|
239
231
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
232
|
+
bind(target: HTMLElement | DocumentFragment | ShadowRoot) {
|
|
233
|
+
const that = this,
|
|
234
|
+
iso = isObservableObject(that.valueOf());
|
|
235
|
+
//console.log('bind', iso, target);
|
|
236
|
+
|
|
237
|
+
if (iso) {
|
|
238
|
+
makePlaceholders(target);
|
|
239
|
+
const placeholders: unknown = [
|
|
240
|
+
...target.querySelectorAll('[_mc]'),
|
|
241
|
+
].filter((e) => !!(e as LooseObject)?._mc?._placeholders);
|
|
242
|
+
//console.log('placeholders:', target, placeholders);
|
|
243
|
+
const func = function callback(data: LooseObject) {
|
|
244
|
+
// avoid bubbling for speed
|
|
245
|
+
let d = flattenObject(data);
|
|
246
|
+
//console.log('inside callback', target, d);
|
|
247
|
+
(placeholders as DC[]).forEach((e) => {
|
|
248
|
+
// console.log('trigger callback', e);
|
|
249
|
+
if (!e) return;
|
|
250
|
+
(e as any)._mc.trigger('data', d);
|
|
247
251
|
});
|
|
248
|
-
}
|
|
252
|
+
};
|
|
253
|
+
(that as any).#callbacks.push(func);
|
|
254
|
+
that.notify();
|
|
255
|
+
} else {
|
|
256
|
+
console.warn(
|
|
257
|
+
'IGNORED - cannot bind a non-Object to the dom, IS:',
|
|
258
|
+
typeof that.valueOf(),
|
|
259
|
+
that
|
|
260
|
+
);
|
|
249
261
|
}
|
|
250
262
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
263
|
+
return this;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
notify(notify?: boolean) {
|
|
267
|
+
let that = this,
|
|
268
|
+
data =
|
|
269
|
+
isObservableObject(that.valueOf()) &&
|
|
270
|
+
that.valueOf() instanceof Array === false
|
|
271
|
+
? structuredClone(Object.assign({}, that))
|
|
272
|
+
: that.valueOf();
|
|
273
|
+
|
|
274
|
+
if (notify !== undefined) {
|
|
275
|
+
that.#notify = notify;
|
|
276
|
+
// return;
|
|
255
277
|
}
|
|
256
278
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
//
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
//console.log('placeholders:', target, placeholders);
|
|
268
|
-
const func = function callback(data: LooseObject) {
|
|
269
|
-
// avoid bubbling for speed
|
|
270
|
-
let d = flattenObject(data);
|
|
271
|
-
//console.log('inside callback', target, d);
|
|
272
|
-
(placeholders as DC[]).forEach((e) => {
|
|
273
|
-
// console.log('trigger callback', e);
|
|
274
|
-
if (!e) return;
|
|
275
|
-
(e as any)._mc.trigger('data', d);
|
|
276
|
-
});
|
|
277
|
-
};
|
|
278
|
-
(that.constructor as any).callbacks.push(func);
|
|
279
|
-
that.notify();
|
|
280
|
-
} else {
|
|
281
|
-
console.warn(
|
|
282
|
-
'IGNORED - cannot bind a non-Object to the dom, IS:',
|
|
283
|
-
typeof that.valueOf(),
|
|
284
|
-
that
|
|
285
|
-
);
|
|
286
|
-
}
|
|
279
|
+
//if (that.#notify) console.log('notify', this, data);
|
|
280
|
+
(that as any).#callbacks.forEach((f: Function) => {
|
|
281
|
+
// console.log(
|
|
282
|
+
// (this.constructor as any).callbacks,
|
|
283
|
+
// 'notify: exec callback',
|
|
284
|
+
// f,
|
|
285
|
+
// data
|
|
286
|
+
// );
|
|
287
|
+
f(data);
|
|
288
|
+
});
|
|
287
289
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
+
return that;
|
|
291
|
+
}
|
|
292
|
+
};
|
|
290
293
|
|
|
291
|
-
|
|
292
|
-
let that = this,
|
|
293
|
-
data =
|
|
294
|
-
isObservableObject(that.valueOf()) &&
|
|
295
|
-
that.valueOf() instanceof Array === false
|
|
296
|
-
? structuredClone(Object.assign({}, that))
|
|
297
|
-
: that.valueOf();
|
|
298
|
-
|
|
299
|
-
if (notify !== undefined) {
|
|
300
|
-
that.#notify = notify;
|
|
301
|
-
// return;
|
|
302
|
-
}
|
|
294
|
+
(classRepo as any)[ConstructorName] = ObservableClass;
|
|
303
295
|
|
|
304
|
-
|
|
305
|
-
(that.constructor as any).callbacks.forEach((f: Function) => {
|
|
306
|
-
// console.log(
|
|
307
|
-
// (this.constructor as any).callbacks,
|
|
308
|
-
// 'notify: exec callback',
|
|
309
|
-
// f,
|
|
310
|
-
// data
|
|
311
|
-
// );
|
|
312
|
-
f(data);
|
|
313
|
-
});
|
|
296
|
+
// console.log( 'classRepo:', classRepo );
|
|
314
297
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
};
|
|
298
|
+
return ObservableClass;
|
|
299
|
+
}
|
|
318
300
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
get() {
|
|
324
|
-
if (isObservableObject(o.valueOf())) {
|
|
325
|
-
let check = structuredClone(Object.assign({}, o));
|
|
326
|
-
setTimeout(
|
|
327
|
-
debounce(function checkChanges() {
|
|
328
|
-
let state = structuredClone(Object.assign({}, o));
|
|
329
|
-
//console.log( 'check changes', state, check );
|
|
330
|
-
if (!deepEqual(state, check)) {
|
|
331
|
-
//console.log( '-> not equal!' );
|
|
332
|
-
o.notify();
|
|
333
|
-
}
|
|
334
|
-
}, 0),
|
|
335
|
-
0
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
|
-
return o;
|
|
339
|
-
},
|
|
340
|
-
set(val: any) {
|
|
341
|
-
//console.log( 'SET:', isObservableObject( val.valueOf() ), 'set:', val, 'to', isObservableObject( o.valueOf() ), o, );
|
|
342
|
-
if (typeof val === typeof o.valueOf()) {
|
|
343
|
-
let iso =
|
|
344
|
-
isObservableObject(o.valueOf()) &&
|
|
345
|
-
o.valueOf() instanceof Array === false;
|
|
346
|
-
//console.log('target iso:', iso);
|
|
347
|
-
if (iso) {
|
|
348
|
-
let old = structuredClone(Object.assign({}, o));
|
|
349
|
-
//val = structuredClone(Object.assign({}, val));
|
|
350
|
-
|
|
351
|
-
//let callbacks = (o.constructor as LooseObject).callbacks;
|
|
352
|
-
if (o instanceof Observable === false) {
|
|
353
|
-
o = new Observable(structuredClone(Object.assign({}, val)));
|
|
354
|
-
copyGettersSetters(val, o);
|
|
355
|
-
o.seal();
|
|
356
|
-
}
|
|
357
|
-
Object.assign(o, val);
|
|
301
|
+
function getConstructor( val: any ): Class<typeof val> {
|
|
302
|
+
let key: string = val.constructor.name;
|
|
303
|
+
return classRepo[key] || makeObservable( val );
|
|
304
|
+
}
|
|
358
305
|
|
|
359
|
-
|
|
360
|
-
|
|
306
|
+
export const observe = (
|
|
307
|
+
target: LooseObject,
|
|
308
|
+
propertyName?: string
|
|
309
|
+
): LooseObject => {
|
|
310
|
+
let keys = !propertyName
|
|
311
|
+
? [...Object.getOwnPropertyNames(target)]
|
|
312
|
+
: [propertyName];
|
|
361
313
|
|
|
314
|
+
keys.forEach((key) => {
|
|
315
|
+
if (
|
|
316
|
+
target.hasOwnProperty(key)
|
|
317
|
+
&& typeof target[key] !== 'function'
|
|
318
|
+
&& !target?.[key]?.constructor?.prototype?.observe
|
|
319
|
+
) {
|
|
320
|
+
|
|
321
|
+
// console.log( 'co propname', key, typeof target[key], target[key] );
|
|
322
|
+
if (key[0] === '_' || target?.[key] === undefined) return target;
|
|
323
|
+
let val: any = target[key];
|
|
324
|
+
|
|
325
|
+
let o = new ( getConstructor(val) as Class<typeof val> )( val );
|
|
326
|
+
|
|
327
|
+
Object.defineProperty(target, key, {
|
|
328
|
+
enumerable: true,
|
|
329
|
+
get() {
|
|
330
|
+
if (isObservableObject(o.valueOf())) {
|
|
331
|
+
let check = structuredClone(Object.assign({}, o));
|
|
362
332
|
setTimeout(
|
|
363
|
-
// check for changes
|
|
364
333
|
debounce(function checkChanges() {
|
|
365
334
|
let state = structuredClone(Object.assign({}, o));
|
|
366
335
|
//console.log( 'check changes', state, check );
|
|
367
|
-
if (!deepEqual(state,
|
|
336
|
+
if (!deepEqual(state, check)) {
|
|
368
337
|
//console.log( '-> not equal!' );
|
|
369
338
|
o.notify();
|
|
370
339
|
}
|
|
371
340
|
}, 0),
|
|
372
341
|
0
|
|
373
342
|
);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
o.
|
|
343
|
+
}
|
|
344
|
+
return o;
|
|
345
|
+
},
|
|
346
|
+
set(val: any) {
|
|
347
|
+
//console.log( 'SET:', isObservableObject( val.valueOf() ), 'set:', val, 'to', isObservableObject( o.valueOf() ), o, );
|
|
348
|
+
if (typeof val === typeof o.valueOf()) {
|
|
349
|
+
let iso =
|
|
350
|
+
isObservableObject(o.valueOf()) &&
|
|
351
|
+
o.valueOf() instanceof Array === false;
|
|
352
|
+
//console.log('target iso:', iso);
|
|
353
|
+
if (iso) {
|
|
354
|
+
let old = structuredClone(Object.assign({}, o));
|
|
355
|
+
//val = structuredClone(Object.assign({}, val));
|
|
356
|
+
|
|
357
|
+
//let callbacks = (o.constructor as LooseObject).callbacks;
|
|
358
|
+
if (o?.constructor?.prototype?.observe === undefined ) {
|
|
359
|
+
o = new ( getConstructor(val) as Class<typeof val> )( structuredClone(Object.assign({}, val)) );
|
|
360
|
+
copyGettersSetters(val, o);
|
|
361
|
+
o.seal();
|
|
362
|
+
}
|
|
363
|
+
Object.assign(o, val);
|
|
364
|
+
|
|
365
|
+
// console.log('after set o=', o, 'check', old);
|
|
366
|
+
// (o.constructor as LooseObject).callbacks = callbacks;
|
|
367
|
+
|
|
368
|
+
setTimeout(
|
|
369
|
+
// check for changes
|
|
370
|
+
debounce(function checkChanges() {
|
|
371
|
+
let state = structuredClone(Object.assign({}, o));
|
|
372
|
+
//console.log( 'check changes', state, check );
|
|
373
|
+
if (!deepEqual(state, old)) {
|
|
374
|
+
//console.log( '-> not equal!' );
|
|
375
|
+
o.notify();
|
|
376
|
+
}
|
|
377
|
+
}, 0),
|
|
378
|
+
0
|
|
379
|
+
);
|
|
380
|
+
} else {
|
|
381
|
+
// simple native var
|
|
382
|
+
let old = o.valueOf(),
|
|
383
|
+
callbacks = (o.constructor as LooseObject).callbacks;
|
|
384
|
+
o = o = new ( getConstructor(val) as Class<typeof val> )( val );
|
|
385
|
+
(o.constructor as LooseObject).callbacks = callbacks;
|
|
386
|
+
if (val !== old) {
|
|
387
|
+
o.notify();
|
|
388
|
+
}
|
|
382
389
|
}
|
|
390
|
+
} else {
|
|
391
|
+
console.warn(
|
|
392
|
+
'IGNORED - cannot change observable types, IS:',
|
|
393
|
+
typeof o.valueOf(),
|
|
394
|
+
o,
|
|
395
|
+
'- CANNOT BECOME:',
|
|
396
|
+
typeof val
|
|
397
|
+
);
|
|
383
398
|
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
typeof val
|
|
391
|
-
);
|
|
392
|
-
}
|
|
393
|
-
},
|
|
394
|
-
});
|
|
399
|
+
},
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
// replace old property with proxy (observable)
|
|
403
|
+
target[key] = val;
|
|
404
|
+
};
|
|
395
405
|
|
|
396
|
-
// replace old property with proxy (observable)
|
|
397
|
-
target[key] = val;
|
|
398
406
|
});
|
|
399
407
|
|
|
400
408
|
return target;
|
|
@@ -4,7 +4,7 @@ import { DC, defineCE, Observable, formValues, LooseObject } from './../../micro
|
|
|
4
4
|
defineCE(
|
|
5
5
|
'test-testform',
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class TestForm extends DC {
|
|
8
8
|
data: unknown;
|
|
9
9
|
|
|
10
10
|
constructor(target: HTMLElement) {
|
|
@@ -20,6 +20,14 @@ defineCE(
|
|
|
20
20
|
formValues(that, 'data', shadow); // create this.data formdata observable
|
|
21
21
|
|
|
22
22
|
(that.data as Observable).bind(shadow); // 1 way bind formdata to the form DOM
|
|
23
|
+
|
|
24
|
+
// load and display data
|
|
25
|
+
fetch('./testform.json')
|
|
26
|
+
.then( res => res.json())
|
|
27
|
+
.then( data => {
|
|
28
|
+
that.data = data;
|
|
29
|
+
});
|
|
30
|
+
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
get template() {
|
|
@@ -124,7 +132,7 @@ form textarea {
|
|
|
124
132
|
}
|
|
125
133
|
|
|
126
134
|
input[type="radio"],
|
|
127
|
-
input[type="checkbox"]
|
|
135
|
+
input[type="checkbox"] {
|
|
128
136
|
margin-top: 1.3em;
|
|
129
137
|
}
|
|
130
138
|
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
// 'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
let mc: unknown;
|
|
5
|
+
import('../microcomponents.js').then( res => mc = res );
|
|
6
|
+
const { LooseObject, DC, McEvent, defineCE, getCE, observe, Observable } = mc as any;
|
|
7
|
+
*/
|
|
2
8
|
|
|
3
9
|
import {
|
|
4
10
|
LooseObject,
|
|
@@ -8,7 +14,7 @@ import {
|
|
|
8
14
|
getCE,
|
|
9
15
|
observe,
|
|
10
16
|
Observable,
|
|
11
|
-
} from '
|
|
17
|
+
} from '../microcomponents.js';
|
|
12
18
|
|
|
13
19
|
class Translator extends DC {
|
|
14
20
|
#translations: LooseObject = {};
|
|
@@ -84,6 +90,12 @@ defineCE(
|
|
|
84
90
|
// render
|
|
85
91
|
target.innerHTML = this.#template;
|
|
86
92
|
|
|
93
|
+
// state
|
|
94
|
+
that.Dom = { counter: 0 };
|
|
95
|
+
|
|
96
|
+
// state: convert all props defined so far into observables
|
|
97
|
+
observe(that);
|
|
98
|
+
|
|
87
99
|
// add translator
|
|
88
100
|
DC.add(
|
|
89
101
|
target,
|
|
@@ -97,12 +109,6 @@ defineCE(
|
|
|
97
109
|
oneInit(ev: McEvent) {
|
|
98
110
|
let that = this;
|
|
99
111
|
|
|
100
|
-
// state
|
|
101
|
-
that.Dom = { counter: 0 };
|
|
102
|
-
|
|
103
|
-
// state: convert all props defined so far into observables
|
|
104
|
-
observe(that);
|
|
105
|
-
|
|
106
112
|
// bind Dom to target
|
|
107
113
|
(that.Dom as Observable).bind(that.target);
|
|
108
114
|
}
|
|
@@ -154,7 +160,7 @@ setTimeout(() => {
|
|
|
154
160
|
'font-weight: bold; color: black;',
|
|
155
161
|
'font-weight: normal;',
|
|
156
162
|
max,
|
|
157
|
-
max *
|
|
163
|
+
max * 2,
|
|
158
164
|
'font-weight: bold; color: blue;',
|
|
159
165
|
end - start
|
|
160
166
|
);
|
|
@@ -172,23 +178,23 @@ setTimeout(() => {
|
|
|
172
178
|
'\n\nLook up code in the debugger: test.js\n'
|
|
173
179
|
);
|
|
174
180
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
181
|
+
let form = ( document.querySelector('test-testform') as any);
|
|
182
|
+
let formInstance = form._mc.TestTestform;
|
|
183
|
+
|
|
184
|
+
(window as any).form = formInstance;
|
|
185
|
+
console.log(
|
|
186
|
+
"\n\n%cAttached a global variable 'form':%c \n\n %O %c %s %c %s %c %s",
|
|
187
|
+
'font-weight: bold;',
|
|
188
|
+
'font-weight: normal;',
|
|
189
|
+
formInstance,
|
|
190
|
+
'font-weight: bold;',
|
|
191
|
+
'\n\nYou can use it to change input values, e.g. \n\n',
|
|
192
|
+
'font-weight: normal;',
|
|
193
|
+
' form.data.textInput="other value"',
|
|
194
|
+
'font-weight: bold;',
|
|
195
|
+
'\n\nChanges will be reflected in the form contents, same as vice versa.\n'
|
|
196
|
+
);
|
|
191
197
|
|
|
192
198
|
// will trigger the event on all micro components contained in <my-tag>
|
|
193
199
|
DC.trigger(element, 'doSomething');
|
|
194
|
-
},
|
|
200
|
+
}, 1000);
|
package/tsconfig.json
CHANGED
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
// "module": "commonjs", /* Specify what module code is generated. */
|
|
30
30
|
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
31
31
|
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
32
|
-
"baseUrl": "/src",
|
|
33
|
-
|
|
32
|
+
"baseUrl": "/src", /* Specify the base directory to resolve non-relative module names. */
|
|
33
|
+
"paths": { "@/": ["/*"] }, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
34
34
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
35
35
|
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
36
36
|
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
package/typedoc.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"entryPoints": ["src/MC.ts","src/elements.ts","src/observables.ts","src/formValues.ts"
|
|
2
|
+
"entryPoints": ["src/MC.ts","src/elements.ts","src/observables.ts","src/formValues.ts"],
|
|
3
3
|
"out": "./public/typedoc",
|
|
4
4
|
"readme": "README.md",
|
|
5
5
|
"name": "Micro Components",
|
package/checklist.md
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
# MicroComponents
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Getting started
|
|
6
|
-
|
|
7
|
-
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
-
|
|
9
|
-
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
-
|
|
11
|
-
## Add your files
|
|
12
|
-
|
|
13
|
-
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
14
|
-
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
cd existing_repo
|
|
18
|
-
git remote add origin https://gitlab.com/twoBirds/microcomponents.git
|
|
19
|
-
git branch -M main
|
|
20
|
-
git push -uf origin main
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Integrate with your tools
|
|
24
|
-
|
|
25
|
-
- [ ] [Set up project integrations](https://gitlab.com/twoBirds/microcomponents/-/settings/integrations)
|
|
26
|
-
|
|
27
|
-
## Collaborate with your team
|
|
28
|
-
|
|
29
|
-
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
30
|
-
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
31
|
-
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
-
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
-
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
|
34
|
-
|
|
35
|
-
## Test and Deploy
|
|
36
|
-
|
|
37
|
-
Use the built-in continuous integration in GitLab.
|
|
38
|
-
|
|
39
|
-
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
|
40
|
-
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
41
|
-
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
42
|
-
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
43
|
-
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
44
|
-
|
|
45
|
-
***
|
|
46
|
-
|
|
47
|
-
# Editing this README
|
|
48
|
-
|
|
49
|
-
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
-
|
|
51
|
-
## Suggestions for a good README
|
|
52
|
-
|
|
53
|
-
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
54
|
-
|
|
55
|
-
## Name
|
|
56
|
-
Choose a self-explaining name for your project.
|
|
57
|
-
|
|
58
|
-
## Description
|
|
59
|
-
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
60
|
-
|
|
61
|
-
## Badges
|
|
62
|
-
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
63
|
-
|
|
64
|
-
## Visuals
|
|
65
|
-
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
66
|
-
|
|
67
|
-
## Installation
|
|
68
|
-
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
69
|
-
|
|
70
|
-
## Usage
|
|
71
|
-
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
72
|
-
|
|
73
|
-
## Support
|
|
74
|
-
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
75
|
-
|
|
76
|
-
## Roadmap
|
|
77
|
-
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
78
|
-
|
|
79
|
-
## Contributing
|
|
80
|
-
State if you are open to contributions and what your requirements are for accepting them.
|
|
81
|
-
|
|
82
|
-
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
83
|
-
|
|
84
|
-
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
85
|
-
|
|
86
|
-
## Authors and acknowledgment
|
|
87
|
-
Show your appreciation to those who have contributed to the project.
|
|
88
|
-
|
|
89
|
-
## License
|
|
90
|
-
For open source projects, say how it is licensed.
|
|
91
|
-
|
|
92
|
-
## Project status
|
|
93
|
-
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"microcomponents.es3.d.ts","sourceRoot":"","sources":["../src/microcomponents.es3.js"],"names":[],"mappings":"AAgWA,mFAwBC"}
|
package/dist/test.d.ts
DELETED
package/dist/test.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":""}
|