@schukai/monster 4.122.2 → 4.123.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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.
|
|
1
|
+
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.123.0"}
|
|
@@ -124,6 +124,9 @@ class HtmlTreeMenu extends CustomElement {
|
|
|
124
124
|
onlazyloaded: null,
|
|
125
125
|
onlazyerror: null,
|
|
126
126
|
},
|
|
127
|
+
updater: {
|
|
128
|
+
batchUpdates: true,
|
|
129
|
+
},
|
|
127
130
|
entries: [],
|
|
128
131
|
});
|
|
129
132
|
}
|
|
@@ -687,50 +690,46 @@ function applyEntryState(index, state, event) {
|
|
|
687
690
|
event,
|
|
688
691
|
});
|
|
689
692
|
|
|
690
|
-
this.
|
|
691
|
-
const
|
|
693
|
+
const entries = this.getOption("entries", []);
|
|
694
|
+
const nextEntries = [...entries];
|
|
695
|
+
let changed = false;
|
|
692
696
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
);
|
|
697
|
+
nextEntries[index] = Object.assign({}, entry, {
|
|
698
|
+
state,
|
|
699
|
+
});
|
|
700
|
+
changed = true;
|
|
701
|
+
const newVisibility = state === "open" ? "visible" : "hidden";
|
|
702
|
+
const targetIntend = entry.intend;
|
|
703
|
+
const end = getSubtreeEndIndex(entries, index);
|
|
704
|
+
const childIntend = targetIntend + 1;
|
|
696
705
|
|
|
697
|
-
|
|
698
|
-
const
|
|
699
|
-
let ref = entryNode.nextElementSibling;
|
|
700
|
-
const childIntend = parseInt(intend) + 1;
|
|
706
|
+
for (let i = index + 1; i < end; i += 1) {
|
|
707
|
+
const childEntry = entries[i];
|
|
701
708
|
|
|
702
|
-
|
|
703
|
-
if (
|
|
704
|
-
|
|
709
|
+
if (state === "open") {
|
|
710
|
+
if (childEntry.intend !== childIntend) {
|
|
711
|
+
continue;
|
|
705
712
|
}
|
|
706
|
-
|
|
707
|
-
return a >= b;
|
|
708
|
-
};
|
|
709
|
-
|
|
710
|
-
while (ref?.hasAttribute(ATTRIBUTE_INTEND)) {
|
|
711
|
-
const refIntend = ref.getAttribute(ATTRIBUTE_INTEND);
|
|
712
|
-
|
|
713
|
-
if (!cmp(Number.parseInt(refIntend), childIntend)) {
|
|
714
|
-
if (refIntend === intend) {
|
|
715
|
-
break;
|
|
716
|
-
}
|
|
717
|
-
ref = ref.nextElementSibling;
|
|
713
|
+
if (childEntry.visibility === newVisibility) {
|
|
718
714
|
continue;
|
|
719
715
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
.split("-")
|
|
724
|
-
.pop();
|
|
725
|
-
|
|
726
|
-
this.setOption("entries." + refIndex + ".visibility", newVisibility);
|
|
727
|
-
|
|
728
|
-
if (state === "close") {
|
|
729
|
-
this.setOption("entries." + refIndex + ".state", "close");
|
|
716
|
+
} else {
|
|
717
|
+
if (childEntry.visibility === newVisibility) {
|
|
718
|
+
continue;
|
|
730
719
|
}
|
|
720
|
+
}
|
|
731
721
|
|
|
732
|
-
|
|
722
|
+
const updates = { visibility: newVisibility };
|
|
723
|
+
if (state === "close" && childEntry["has-children"]) {
|
|
724
|
+
updates.state = "close";
|
|
733
725
|
}
|
|
726
|
+
|
|
727
|
+
nextEntries[i] = Object.assign({}, childEntry, updates);
|
|
728
|
+
changed = true;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
if (changed === true) {
|
|
732
|
+
this.setOption("entries", nextEntries);
|
|
734
733
|
}
|
|
735
734
|
}
|
|
736
735
|
|
|
@@ -751,16 +750,29 @@ function setEntryVisibility(value, visibility) {
|
|
|
751
750
|
return;
|
|
752
751
|
}
|
|
753
752
|
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
}
|
|
753
|
+
const nextEntries = [...entries];
|
|
754
|
+
let changed = false;
|
|
755
|
+
if (target.visibility !== visibility) {
|
|
756
|
+
nextEntries[index] = Object.assign({}, target, {
|
|
757
|
+
visibility,
|
|
758
|
+
});
|
|
759
|
+
changed = true;
|
|
760
|
+
}
|
|
761
|
+
const end = getSubtreeEndIndex(entries, index);
|
|
762
|
+
for (let i = index + 1; i < end; i += 1) {
|
|
760
763
|
if (visibility === "hidden") {
|
|
761
|
-
|
|
764
|
+
if (entries[i].visibility !== "hidden") {
|
|
765
|
+
nextEntries[i] = Object.assign({}, entries[i], {
|
|
766
|
+
visibility: "hidden",
|
|
767
|
+
});
|
|
768
|
+
changed = true;
|
|
769
|
+
}
|
|
762
770
|
}
|
|
763
771
|
}
|
|
772
|
+
|
|
773
|
+
if (changed === true) {
|
|
774
|
+
this.setOption("entries", nextEntries);
|
|
775
|
+
}
|
|
764
776
|
}
|
|
765
777
|
|
|
766
778
|
/**
|
|
@@ -804,6 +816,9 @@ function collapseEntry(value) {
|
|
|
804
816
|
if (!entry || entry["has-children"] === false) {
|
|
805
817
|
return;
|
|
806
818
|
}
|
|
819
|
+
if (entry.state === "close") {
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
807
822
|
|
|
808
823
|
const doAction = getAction.call(this, ["oncollapse", "close"]);
|
|
809
824
|
if (isFunction(doAction)) {
|
|
@@ -814,15 +829,38 @@ function collapseEntry(value) {
|
|
|
814
829
|
index,
|
|
815
830
|
});
|
|
816
831
|
|
|
817
|
-
this.setOption("entries." + index + ".state", "close");
|
|
818
|
-
|
|
819
832
|
const entries = this.getOption("entries", []);
|
|
833
|
+
const nextEntries = [...entries];
|
|
834
|
+
let changed = false;
|
|
835
|
+
nextEntries[index] = Object.assign({}, entries[index], {
|
|
836
|
+
state: "close",
|
|
837
|
+
});
|
|
838
|
+
changed = true;
|
|
820
839
|
const end = getSubtreeEndIndex(entries, index);
|
|
821
840
|
for (let i = index + 1; i < end; i += 1) {
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
841
|
+
const childEntry = entries[i];
|
|
842
|
+
const hasChildren = childEntry["has-children"] === true;
|
|
843
|
+
if (
|
|
844
|
+
childEntry.visibility === "hidden" &&
|
|
845
|
+
(!hasChildren || childEntry.state === "close")
|
|
846
|
+
) {
|
|
847
|
+
continue;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
const updates = {
|
|
851
|
+
visibility: "hidden",
|
|
852
|
+
};
|
|
853
|
+
if (hasChildren && childEntry.state !== "close") {
|
|
854
|
+
updates.state = "close";
|
|
825
855
|
}
|
|
856
|
+
|
|
857
|
+
const updatedChild = Object.assign({}, childEntry, updates);
|
|
858
|
+
nextEntries[i] = updatedChild;
|
|
859
|
+
changed = true;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
if (changed === true) {
|
|
863
|
+
this.setOption("entries", nextEntries);
|
|
826
864
|
}
|
|
827
865
|
}
|
|
828
866
|
|
|
@@ -990,16 +1028,37 @@ function expandEntryByIndex(index) {
|
|
|
990
1028
|
index,
|
|
991
1029
|
});
|
|
992
1030
|
|
|
993
|
-
this.setOption("entries." + index + ".state", "open");
|
|
994
|
-
this.setOption("entries." + index + ".visibility", "visible");
|
|
995
|
-
|
|
996
1031
|
const entries = this.getOption("entries", []);
|
|
1032
|
+
const nextEntries = [...entries];
|
|
1033
|
+
let changed = false;
|
|
1034
|
+
nextEntries[index] = Object.assign({}, entry, {
|
|
1035
|
+
state: "open",
|
|
1036
|
+
visibility: "visible",
|
|
1037
|
+
});
|
|
1038
|
+
changed = true;
|
|
997
1039
|
const end = getSubtreeEndIndex(entries, index);
|
|
998
1040
|
for (let i = index + 1; i < end; i += 1) {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1041
|
+
const childEntry = entries[i];
|
|
1042
|
+
const changedVisibility = childEntry.visibility !== "visible";
|
|
1043
|
+
const changedState =
|
|
1044
|
+
childEntry["has-children"] && childEntry.state !== "open";
|
|
1045
|
+
|
|
1046
|
+
if (!changedVisibility && !changedState) {
|
|
1047
|
+
continue;
|
|
1002
1048
|
}
|
|
1049
|
+
|
|
1050
|
+
const updatedChild = Object.assign({}, childEntry, {
|
|
1051
|
+
visibility: "visible",
|
|
1052
|
+
});
|
|
1053
|
+
if (childEntry["has-children"]) {
|
|
1054
|
+
updatedChild.state = "open";
|
|
1055
|
+
}
|
|
1056
|
+
nextEntries[i] = updatedChild;
|
|
1057
|
+
changed = true;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
if (changed === true) {
|
|
1061
|
+
this.setOption("entries", nextEntries);
|
|
1003
1062
|
}
|
|
1004
1063
|
}
|
|
1005
1064
|
|
|
@@ -173,6 +173,10 @@ class TreeMenu extends CustomElement {
|
|
|
173
173
|
},
|
|
174
174
|
},
|
|
175
175
|
|
|
176
|
+
updater: {
|
|
177
|
+
batchUpdates: true,
|
|
178
|
+
},
|
|
179
|
+
|
|
176
180
|
data: [],
|
|
177
181
|
entries: [],
|
|
178
182
|
});
|
|
@@ -387,7 +391,14 @@ function initEventHandler() {
|
|
|
387
391
|
doAction.call(this, this.getOption("entries." + index), index);
|
|
388
392
|
}
|
|
389
393
|
|
|
390
|
-
this.
|
|
394
|
+
const entries = this.getOption("entries", []);
|
|
395
|
+
const nextEntries = [...entries];
|
|
396
|
+
let changed = false;
|
|
397
|
+
|
|
398
|
+
nextEntries[index] = Object.assign({}, currentEntry, {
|
|
399
|
+
state: newState,
|
|
400
|
+
});
|
|
401
|
+
changed = true;
|
|
391
402
|
const newVisibility = newState === "open" ? "visible" : "hidden";
|
|
392
403
|
|
|
393
404
|
if (container.hasAttribute(ATTRIBUTE_INTEND)) {
|
|
@@ -418,16 +429,25 @@ function initEventHandler() {
|
|
|
418
429
|
.getAttribute(ATTRIBUTE_UPDATER_INSERT_REFERENCE)
|
|
419
430
|
.split("-")
|
|
420
431
|
.pop();
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
432
|
+
const childIndex = Number.parseInt(refIndex);
|
|
433
|
+
const childEntry = entries[childIndex];
|
|
434
|
+
if (!childEntry) {
|
|
435
|
+
ref = ref.nextElementSibling;
|
|
436
|
+
continue;
|
|
426
437
|
}
|
|
427
438
|
|
|
439
|
+
nextEntries[childIndex] = Object.assign({}, childEntry, {
|
|
440
|
+
visibility: newVisibility,
|
|
441
|
+
...(newState === "close" ? { state: "close" } : {}),
|
|
442
|
+
});
|
|
443
|
+
changed = true;
|
|
428
444
|
ref = ref.nextElementSibling;
|
|
429
445
|
}
|
|
430
446
|
}
|
|
447
|
+
|
|
448
|
+
if (changed === true) {
|
|
449
|
+
this.setOption("entries", nextEntries);
|
|
450
|
+
}
|
|
431
451
|
};
|
|
432
452
|
|
|
433
453
|
const types = this.getOption("toggleEventType", ["click"]);
|