@schukai/monster 4.96.0 → 4.97.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.97.0"}
|
|
@@ -35,6 +35,7 @@ export { MessageStateButton };
|
|
|
35
35
|
* @type {symbol}
|
|
36
36
|
*/
|
|
37
37
|
const buttonElementSymbol = Symbol("buttonElement");
|
|
38
|
+
const innerDisabledObserverSymbol = Symbol("innerDisabledObserver");
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
* A specialized button component that combines state management with message display capabilities.
|
|
@@ -407,17 +408,44 @@ function initControlReferences() {
|
|
|
407
408
|
*/
|
|
408
409
|
function initDisabledSync() {
|
|
409
410
|
const self = this;
|
|
411
|
+
const attachInnerObserver = (button) => {
|
|
412
|
+
if (!button || !isFunction(button.attachObserver)) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const existing = self[innerDisabledObserverSymbol];
|
|
417
|
+
if (existing?.button === button) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
if (
|
|
422
|
+
existing?.button &&
|
|
423
|
+
isFunction(existing.button.detachObserver) &&
|
|
424
|
+
existing.observer
|
|
425
|
+
) {
|
|
426
|
+
existing.button.detachObserver(existing.observer);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
const observer = new Observer(syncDisabled);
|
|
430
|
+
button.attachObserver(observer);
|
|
431
|
+
self[innerDisabledObserverSymbol] = { button, observer };
|
|
432
|
+
};
|
|
433
|
+
|
|
410
434
|
const syncDisabled = () => {
|
|
411
435
|
const disabled = self.getOption("disabled", false);
|
|
412
436
|
if (self.getOption("features.disableButton", false) !== disabled) {
|
|
413
437
|
self.setOption("features.disableButton", disabled);
|
|
414
438
|
}
|
|
415
439
|
|
|
416
|
-
const button =
|
|
440
|
+
const button =
|
|
441
|
+
self.shadowRoot?.querySelector(`[${ATTRIBUTE_ROLE}=button]`) ??
|
|
442
|
+
self[buttonElementSymbol];
|
|
417
443
|
if (!button) {
|
|
418
444
|
return;
|
|
419
445
|
}
|
|
420
446
|
|
|
447
|
+
self[buttonElementSymbol] = button;
|
|
448
|
+
|
|
421
449
|
if (disabled) {
|
|
422
450
|
button.setAttribute(ATTRIBUTE_DISABLED, "");
|
|
423
451
|
} else {
|
|
@@ -427,6 +455,8 @@ function initDisabledSync() {
|
|
|
427
455
|
if (isFunction(button.setOption)) {
|
|
428
456
|
button.setOption("disabled", disabled);
|
|
429
457
|
}
|
|
458
|
+
|
|
459
|
+
attachInnerObserver(button);
|
|
430
460
|
};
|
|
431
461
|
|
|
432
462
|
syncDisabled();
|