@optionfactory/ful 0.65.0 → 0.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ful.iife.js +50 -23
- package/dist/ful.iife.js.map +1 -1
- package/dist/ful.iife.min.js +1 -1
- package/dist/ful.iife.min.js.map +1 -1
- package/dist/ful.min.mjs +1 -1
- package/dist/ful.min.mjs.map +1 -1
- package/dist/ful.mjs +50 -24
- package/dist/ful.mjs.map +1 -1
- package/package.json +1 -1
package/dist/ful.iife.js
CHANGED
|
@@ -560,14 +560,28 @@ var ful = (function (exports) {
|
|
|
560
560
|
}
|
|
561
561
|
};
|
|
562
562
|
|
|
563
|
+
class Deferred {
|
|
564
|
+
constructor() {
|
|
565
|
+
this.promise = new Promise((resolve, reject) => {
|
|
566
|
+
this.reject = reject;
|
|
567
|
+
this.resolve = resolve;
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
563
572
|
// SyncEvent.on($0, 'asd', async e => { await ful.timing.sleep(10_000); return 3; })
|
|
564
|
-
// const
|
|
573
|
+
// const success = await new SyncEvent("asd").dispatchTo($0);
|
|
565
574
|
class SyncEvent extends CustomEvent {
|
|
575
|
+
#promises;
|
|
566
576
|
#results;
|
|
567
577
|
constructor(type, options) {
|
|
568
578
|
super(type, {...options, cancelable: true});
|
|
579
|
+
this.#promises = [];
|
|
569
580
|
this.#results = [];
|
|
570
581
|
}
|
|
582
|
+
get results(){
|
|
583
|
+
return this.#results;
|
|
584
|
+
}
|
|
571
585
|
|
|
572
586
|
async dispatchTo(el) {
|
|
573
587
|
// unlike "native" events, which are fired by the browser and invoke
|
|
@@ -577,14 +591,14 @@ var ful = (function (exports) {
|
|
|
577
591
|
el.dispatchEvent(this);
|
|
578
592
|
//we ignore the result of dispatchEvent and use defaultPrevented instead
|
|
579
593
|
//because handlers can be async
|
|
580
|
-
|
|
581
|
-
return
|
|
594
|
+
this.#results = await Promise.all(this.#promises);
|
|
595
|
+
return !this.defaultPrevented;
|
|
582
596
|
}
|
|
583
597
|
|
|
584
598
|
static on(el, type, h, useCapture) {
|
|
585
599
|
el.addEventListener(type, e => {
|
|
586
600
|
//e *must* be an async event
|
|
587
|
-
e.#
|
|
601
|
+
e.#promises.push(h(e));
|
|
588
602
|
}, useCapture);
|
|
589
603
|
}
|
|
590
604
|
}
|
|
@@ -675,6 +689,19 @@ var ful = (function (exports) {
|
|
|
675
689
|
to.setAttribute(target, from.getAttribute(a));
|
|
676
690
|
});
|
|
677
691
|
}
|
|
692
|
+
/**
|
|
693
|
+
*
|
|
694
|
+
* @param {HTMLElement} el
|
|
695
|
+
* @param {stirng} attr
|
|
696
|
+
* @param {boolean} value
|
|
697
|
+
*/
|
|
698
|
+
static toggle(el, attr, value) {
|
|
699
|
+
if (value) {
|
|
700
|
+
el.setAttribute(attr, '');
|
|
701
|
+
} else {
|
|
702
|
+
el.removeAttribute(attr);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
678
705
|
}
|
|
679
706
|
|
|
680
707
|
class LightSlots {
|
|
@@ -711,7 +738,7 @@ var ful = (function (exports) {
|
|
|
711
738
|
}
|
|
712
739
|
|
|
713
740
|
class Events {
|
|
714
|
-
static dispatchChange(el, value){
|
|
741
|
+
static dispatchChange(el, value) {
|
|
715
742
|
return el.dispatchEvent(new CustomEvent("change", {
|
|
716
743
|
bubbles: true,
|
|
717
744
|
cancelable: true,
|
|
@@ -847,6 +874,7 @@ var ful = (function (exports) {
|
|
|
847
874
|
}
|
|
848
875
|
#parsed;
|
|
849
876
|
#initialized;
|
|
877
|
+
#reflecting;
|
|
850
878
|
#internals;
|
|
851
879
|
constructor(...args) {
|
|
852
880
|
super(...args);
|
|
@@ -883,9 +911,20 @@ var ful = (function (exports) {
|
|
|
883
911
|
if (!this.#parsed || oldValue === newValue) {
|
|
884
912
|
return;
|
|
885
913
|
}
|
|
914
|
+
if (this.#reflecting) {
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
886
917
|
const mapper = attrToMapper[attr];
|
|
887
918
|
this[attr] = mapper(newValue);
|
|
888
919
|
}
|
|
920
|
+
reflect(fn) {
|
|
921
|
+
this.#reflecting = true;
|
|
922
|
+
try {
|
|
923
|
+
fn();
|
|
924
|
+
} finally {
|
|
925
|
+
this.#reflecting = false;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
889
928
|
async upgrade() {
|
|
890
929
|
if (this.#parsed) {
|
|
891
930
|
return;
|
|
@@ -910,29 +949,16 @@ var ful = (function (exports) {
|
|
|
910
949
|
return this.internals.states.has(`--${attr}`);
|
|
911
950
|
},
|
|
912
951
|
set(value) {
|
|
913
|
-
const
|
|
914
|
-
const before = new SyncEvent(`${attr}:${
|
|
915
|
-
|
|
916
|
-
target: this,
|
|
917
|
-
value: value
|
|
918
|
-
}
|
|
919
|
-
});
|
|
920
|
-
const eta = this.initialized ? 'changed' : 'inited';
|
|
921
|
-
const after = new SyncEvent(`${attr}:${eta}`, {
|
|
922
|
-
detail: {
|
|
923
|
-
target: this,
|
|
924
|
-
value: value
|
|
925
|
-
}
|
|
926
|
-
});
|
|
927
|
-
|
|
952
|
+
const detail = { target: this, value };
|
|
953
|
+
const before = new SyncEvent(`${attr}:${this.initialized ? 'change' : 'init'}`, { detail });
|
|
954
|
+
const after = new SyncEvent(`${attr}:${this.initialized ? 'changed' : 'inited'}`, { detail });
|
|
928
955
|
(async () => {
|
|
929
|
-
|
|
930
|
-
if (!success) {
|
|
956
|
+
if (!await before.dispatchTo(this)) {
|
|
931
957
|
return;
|
|
932
958
|
}
|
|
933
959
|
//see https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet#using_double_dash_prefixed_idents
|
|
934
960
|
this.internals.states[value ? 'add' : 'delete'](`--${attr}`);
|
|
935
|
-
|
|
961
|
+
this.reflect(() => Attributes.toggle(this, attr, value));
|
|
936
962
|
await after.dispatchTo(this);
|
|
937
963
|
})();
|
|
938
964
|
}
|
|
@@ -1421,6 +1447,7 @@ var ful = (function (exports) {
|
|
|
1421
1447
|
exports.AuthorizationCodeFlowInterceptor = AuthorizationCodeFlowInterceptor;
|
|
1422
1448
|
exports.AuthorizationCodeFlowSession = AuthorizationCodeFlowSession;
|
|
1423
1449
|
exports.Base64 = Base64;
|
|
1450
|
+
exports.Deferred = Deferred;
|
|
1424
1451
|
exports.ElementsRegistry = ElementsRegistry;
|
|
1425
1452
|
exports.Failure = Failure;
|
|
1426
1453
|
exports.Form = Form;
|