@shamar/wire 1.0.15 → 1.0.17
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/client/wire.js +38 -0
- package/package.json +1 -1
package/client/wire.js
CHANGED
|
@@ -639,6 +639,43 @@
|
|
|
639
639
|
return updated;
|
|
640
640
|
}
|
|
641
641
|
|
|
642
|
+
/**
|
|
643
|
+
* Layout flags live on body / sidebar chrome outside data-wire-sync islands
|
|
644
|
+
* (e.g. APP_INVERSE sidebarOffcanvas). Sync them so desktop show/hide and
|
|
645
|
+
* topbar brand visibility match a full reload without remounting the shell.
|
|
646
|
+
*/
|
|
647
|
+
function syncShellLayout(nextDoc) {
|
|
648
|
+
const nextBody = nextDoc.body;
|
|
649
|
+
if (!(nextBody instanceof HTMLElement)) return;
|
|
650
|
+
|
|
651
|
+
const layoutAttrs = ['data-shamar-sidebar-offcanvas'];
|
|
652
|
+
for (const name of layoutAttrs) {
|
|
653
|
+
if (nextBody.hasAttribute(name)) {
|
|
654
|
+
document.body.setAttribute(name, nextBody.getAttribute(name) || '');
|
|
655
|
+
} else {
|
|
656
|
+
document.body.removeAttribute(name);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
const currentSidebar = document.querySelector('.shamar-sidebar');
|
|
661
|
+
const nextSidebar = nextDoc.querySelector('.shamar-sidebar');
|
|
662
|
+
if (currentSidebar instanceof HTMLElement && nextSidebar instanceof HTMLElement) {
|
|
663
|
+
currentSidebar.classList.toggle(
|
|
664
|
+
'shamar-sidebar--offcanvas',
|
|
665
|
+
nextSidebar.classList.contains('shamar-sidebar--offcanvas'),
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
const currentBrand = document.querySelector('.shamar-topbar__brand');
|
|
670
|
+
const nextBrand = nextDoc.querySelector('.shamar-topbar__brand');
|
|
671
|
+
if (currentBrand instanceof HTMLElement && nextBrand instanceof HTMLElement) {
|
|
672
|
+
currentBrand.classList.toggle(
|
|
673
|
+
'shamar-topbar__brand--always',
|
|
674
|
+
nextBrand.classList.contains('shamar-topbar__brand--always'),
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
642
679
|
function reviveAlpine(roots) {
|
|
643
680
|
if (!window.Alpine?.initTree) return;
|
|
644
681
|
for (const root of roots) {
|
|
@@ -714,6 +751,7 @@
|
|
|
714
751
|
}
|
|
715
752
|
mergeHead(doc);
|
|
716
753
|
const synced = syncNavigateRegions(doc);
|
|
754
|
+
syncShellLayout(doc);
|
|
717
755
|
const region = sharedRoot(doc);
|
|
718
756
|
const from = region ? region.current : document.body;
|
|
719
757
|
const to = region ? region.next : doc.body;
|