@zuccadev-labs/zuix-zout 0.2.0 → 0.3.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 +75 -0
- package/README.md +11 -3
- package/dist/esm/dom/index.d.ts +30 -1
- package/dist/esm/dom/index.js +639 -10
- package/dist/esm/dom/index.js.map +1 -1
- package/dist/esm/dom/site.d.ts +3 -0
- package/dist/esm/dom/site.js +57 -0
- package/dist/esm/dom/site.js.map +1 -0
- package/dist/esm/edges.d.ts +6 -0
- package/dist/esm/edges.js +47 -0
- package/dist/esm/edges.js.map +1 -0
- package/dist/esm/index.d.ts +13 -2
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/layouts/BottomNavigation.d.ts +30 -0
- package/dist/esm/layouts/BottomNavigation.js +13 -0
- package/dist/esm/layouts/BottomNavigation.js.map +1 -0
- package/dist/esm/layouts/Float.d.ts +18 -0
- package/dist/esm/layouts/Float.js +11 -0
- package/dist/esm/layouts/Float.js.map +1 -0
- package/dist/esm/layouts/FloatingPanel.d.ts +51 -0
- package/dist/esm/layouts/FloatingPanel.js +138 -0
- package/dist/esm/layouts/FloatingPanel.js.map +1 -0
- package/dist/esm/layouts/Navbar.d.ts +28 -0
- package/dist/esm/layouts/Navbar.js +22 -0
- package/dist/esm/layouts/Navbar.js.map +1 -0
- package/dist/esm/layouts/NavigationMenu.d.ts +41 -0
- package/dist/esm/layouts/NavigationMenu.js +37 -0
- package/dist/esm/layouts/NavigationMenu.js.map +1 -0
- package/dist/esm/layouts/Page.d.ts +6 -1
- package/dist/esm/layouts/Page.js +2 -2
- package/dist/esm/layouts/Page.js.map +1 -1
- package/dist/esm/layouts/PaneHeader.d.ts +25 -0
- package/dist/esm/layouts/PaneHeader.js +12 -0
- package/dist/esm/layouts/PaneHeader.js.map +1 -0
- package/dist/esm/layouts/PaneLayout.d.ts +46 -0
- package/dist/esm/layouts/PaneLayout.js +154 -0
- package/dist/esm/layouts/PaneLayout.js.map +1 -0
- package/dist/esm/layouts/SidePanel.d.ts +11 -3
- package/dist/esm/layouts/SidePanel.js +4 -3
- package/dist/esm/layouts/SidePanel.js.map +1 -1
- package/dist/esm/layouts/SidebarItem.d.ts +44 -0
- package/dist/esm/layouts/SidebarItem.js +76 -0
- package/dist/esm/layouts/SidebarItem.js.map +1 -0
- package/dist/esm/layouts/SiteFooter.d.ts +43 -0
- package/dist/esm/layouts/SiteFooter.js +11 -0
- package/dist/esm/layouts/SiteFooter.js.map +1 -0
- package/dist/esm/layouts/SkipLink.d.ts +11 -0
- package/dist/esm/layouts/SkipLink.js +16 -0
- package/dist/esm/layouts/SkipLink.js.map +1 -0
- package/dist/esm/layouts/TabStrip.d.ts +32 -2
- package/dist/esm/layouts/TabStrip.js +124 -15
- package/dist/esm/layouts/TabStrip.js.map +1 -1
- package/dist/esm/layouts/navbar-context.d.ts +4 -0
- package/dist/esm/layouts/navbar-context.js +5 -0
- package/dist/esm/layouts/navbar-context.js.map +1 -0
- package/dist/esm/layouts/sidebar-context.d.ts +6 -0
- package/dist/esm/layouts/sidebar-context.js +6 -0
- package/dist/esm/layouts/sidebar-context.js.map +1 -0
- package/dist/esm/logic.d.ts +130 -2
- package/dist/esm/logic.js +256 -6
- package/dist/esm/logic.js.map +1 -1
- package/dist/esm/site.d.ts +26 -0
- package/dist/esm/site.js +287 -0
- package/dist/esm/site.js.map +1 -0
- package/dist/zout.css +2012 -433
- package/dist/zout.dom.js +1 -1
- package/html.json +236 -7
- package/manifest.json +1197 -61
- package/package.json +5 -5
package/dist/esm/dom/index.js
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
//
|
|
5
5
|
// Uso declarativo: import { init } from "@zuccadev-labs/zuix-zout/dom"; init();
|
|
6
6
|
// Uso imperativo: setPanelOpen, togglePanel, closeDrawers, getShellModes, resizeTo, getSplitSizes, setSplitSizes,
|
|
7
|
-
// selectWorkTab, closeWorkTab, addWorkTab, setSectionOpen,
|
|
7
|
+
// selectWorkTab, closeWorkTab, addWorkTab, setSectionOpen, setSidebarCollapsed,
|
|
8
|
+
// setSidebarItemOpen, moveWorkTab, setTabGroupCollapsed, openFloatingPanel,
|
|
9
|
+
// closeFloatingPanel, setFloatingPanelRect, getPaneLayout, setPaneLayout,
|
|
10
|
+
// splitLayoutPane, dispose
|
|
8
11
|
//
|
|
9
12
|
// Todo se activa dentro de un contenedor [data-z-dom], para no chocar con React en la misma página.
|
|
10
13
|
// Atributos:
|
|
@@ -17,15 +20,41 @@
|
|
|
17
20
|
// data-default-size, data-step, data-var, data-z-resize="#id" en .z-resize (data-side: left|right|top|bottom, o start|end, que siguen la dirección de escritura)
|
|
18
21
|
// data-min-fraction en .z-split
|
|
19
22
|
// data-new-title="Untitled" en .z-tabstrip__add: crea la pestaña sin código de la aplicación
|
|
23
|
+
// data-reorderable en .z-tabstrip: arrastrar pestañas y Ctrl+Mayús+flechas (z:reorder { ids });
|
|
24
|
+
// .z-tabstrip__status[role=status] recibe el anuncio (data-moved-label con
|
|
25
|
+
// {title}, {position} y {total})
|
|
26
|
+
// .z-tabstrip__chip chip de grupo: pliega sus pestañas ([data-group]) y emite z:grouptoggle
|
|
27
|
+
// .z-floatpanel[role=dialog] panel flotante: se arrastra por .z-floatpanel__header (o con flechas en
|
|
28
|
+
// .z-floatpanel__handle) y se redimensiona por .z-floatpanel__resize;
|
|
29
|
+
// data-strategy="absolute" lo acota a su contenedor; data-min-width/height;
|
|
30
|
+
// .z-floatpanel__close o Escape lo ocultan (z:close). data-z-panel="#id" en
|
|
31
|
+
// un botón lo abre y recibe el foco al cerrarlo. z:change { x, y, width, height }
|
|
32
|
+
// .z-panelayout mosaico: .z-split anidados y .z-panelayout__pane[data-pane-id]; arrastrar
|
|
33
|
+
// .z-panelayout__grab sobre otro panel lo deja en ese borde (o lo
|
|
34
|
+
// intercambia en el centro); items de menú [data-pane-action=move-left|
|
|
35
|
+
// move-right|move-up|move-down|close|split-right|split-down]. z:layout
|
|
36
|
+
// { layout } tras cada cambio; z:split { id, direction } para dividir
|
|
37
|
+
// (la aplicación llama a splitLayoutPane con el panel nuevo)
|
|
38
|
+
// data-collapsed en .z-sidebar: plegada a iconos (setSidebarCollapsed la alterna)
|
|
39
|
+
// .z-sidebar__trigger[aria-controls] botón que pliega y despliega la sidebar; data-shortcut: Ctrl/⌘+B
|
|
40
|
+
// La sidebar plegada usa del modo sin framework de zui el tooltip (`data-z-tooltip`) y el popover anclado
|
|
41
|
+
// (`data-z-open`) para el submenú: cargar también @zuccadev-labs/zuix-zui/dom.
|
|
42
|
+
// .z-navbar / .z-navmenu navegación de sitio (./site): fila o cajón medido sin punto de corte fijo y
|
|
43
|
+
// grupos de disclosure con panel; .z-skiplink; .z-bottomnav con botones
|
|
44
|
+
// (aria-current y z:select { value })
|
|
20
45
|
// Tras insertar marcado nuevo: hydrate(contenedor).
|
|
21
46
|
// Eventos (burbujean y se pueden cancelar): z:modechange, z:open, z:close, z:resize, z:select, z:add, z:change.
|
|
22
47
|
import { iconElement, registerIcons } from "@zuccadev-labs/zuix-zicon/dom";
|
|
48
|
+
import { edgeMargin, trackScrollEdges } from "../edges.js";
|
|
49
|
+
import { disposeSite, hydrateSite, onSiteClick } from "./site.js";
|
|
50
|
+
import { chevronDoubleLeft } from "@zuccadev-labs/zuix-zicon/icons/chevron-double-left";
|
|
51
|
+
import { chevronDoubleRight } from "@zuccadev-labs/zuix-zicon/icons/chevron-double-right";
|
|
23
52
|
import { chevronDownSmall } from "@zuccadev-labs/zuix-zicon/icons/chevron-down-small";
|
|
24
53
|
import { chevronRightSmall } from "@zuccadev-labs/zuix-zicon/icons/chevron-right-small";
|
|
25
54
|
import { xMark } from "@zuccadev-labs/zuix-zicon/icons/x-mark";
|
|
26
|
-
import { INSPECTOR_BREAKPOINT, RESIZE_MAX, RESIZE_MIN, RESIZE_STEP, SIDEBAR_BREAKPOINT, SPLIT_MIN_FRACTION, clamp, dividerKeyDelta, evenFractions, isHorizontal, moveDivider, panelMode, physicalSide, resizeByKey, resizeSign, revealOffset, tabKeyIndex, } from "../logic.js";
|
|
55
|
+
import { INSPECTOR_BREAKPOINT, RESIZE_MAX, RESIZE_MIN, RESIZE_STEP, SIDEBAR_BREAKPOINT, SPLIT_MIN_FRACTION, clamp, dividerKeyDelta, evenFractions, isHorizontal, moveDivider, panelMode, physicalSide, resizeByKey, resizeSign, beforeFor, clampRect, dropEdge as paneDropEdge, movePane, neighborPane, removePane, splitPane, dropIndex, FLOAT_STEP, moveDelta, resizeDelta, resizeRect, finalIndex, revealOffset, tabKeyIndex, tabMoveIndex, } from "../logic.js";
|
|
27
56
|
// Iconos que este módulo dibuja por su cuenta cuando el marcado no usa <z-icon>.
|
|
28
|
-
registerIcons([xMark, chevronDownSmall, chevronRightSmall]);
|
|
57
|
+
registerIcons([xMark, chevronDownSmall, chevronRightSmall, chevronDoubleLeft, chevronDoubleRight]);
|
|
29
58
|
const isBrowser = typeof document !== "undefined";
|
|
30
59
|
const inDom = (el) => el.closest("[data-z-dom]") !== null;
|
|
31
60
|
function emit(el, name, detail) {
|
|
@@ -339,7 +368,7 @@ function reveal(strip) {
|
|
|
339
368
|
const tab = activeTab(strip)?.parentElement;
|
|
340
369
|
if (!list || !tab)
|
|
341
370
|
return;
|
|
342
|
-
const offset = revealOffset(tab.getBoundingClientRect(), list.getBoundingClientRect());
|
|
371
|
+
const offset = revealOffset(tab.getBoundingClientRect(), list.getBoundingClientRect(), edgeMargin(list));
|
|
343
372
|
if (offset)
|
|
344
373
|
list.scrollLeft += offset;
|
|
345
374
|
}
|
|
@@ -443,6 +472,121 @@ export function addWorkTab(strip, { id, title, icon, closable = true, closeLabel
|
|
|
443
472
|
selectWorkTab(strip, id);
|
|
444
473
|
return button;
|
|
445
474
|
}
|
|
475
|
+
const shownSelects = (strip) => selects(strip).filter((s) => !s.parentElement?.hidden);
|
|
476
|
+
/** Deja el chip de cada grupo delante de la primera pestaña del grupo (tras mover pestañas). */
|
|
477
|
+
function placeChips(strip) {
|
|
478
|
+
for (const chip of strip.querySelectorAll(".z-tabstrip__group")) {
|
|
479
|
+
const id = chip.dataset.groupId;
|
|
480
|
+
const first = id ? strip.querySelector(`.z-tabstrip__tab[data-group="${CSS.escape(id)}"]`) : null;
|
|
481
|
+
if (first && first.previousElementSibling !== chip)
|
|
482
|
+
first.before(chip);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Mueve la pestaña `id` delante de la pestaña `before` (al final con null). Emite `z:reorder` { ids } (cancelable) y
|
|
487
|
+
* devuelve si la movió.
|
|
488
|
+
*/
|
|
489
|
+
export function moveWorkTab(strip, id, before) {
|
|
490
|
+
const tab = findTab(strip, id)?.parentElement;
|
|
491
|
+
if (!tab)
|
|
492
|
+
return false;
|
|
493
|
+
const ref = before === null ? null : findTab(strip, before)?.parentElement;
|
|
494
|
+
const ids = selects(strip).map((s) => s.dataset.tabId ?? "");
|
|
495
|
+
const rest = ids.filter((x) => x !== id);
|
|
496
|
+
const at = before === null ? rest.length : rest.indexOf(before);
|
|
497
|
+
rest.splice(at < 0 ? rest.length : at, 0, id);
|
|
498
|
+
if (rest.join("\u0000") === ids.join("\u0000") || !emit(strip, "reorder", { ids: rest }))
|
|
499
|
+
return false;
|
|
500
|
+
const hadFocus = tab.contains(document.activeElement);
|
|
501
|
+
if (ref)
|
|
502
|
+
ref.before(tab);
|
|
503
|
+
else
|
|
504
|
+
selects(strip).at(-1)?.parentElement?.after(tab);
|
|
505
|
+
placeChips(strip);
|
|
506
|
+
if (hadFocus)
|
|
507
|
+
findTab(strip, id)?.focus();
|
|
508
|
+
return true;
|
|
509
|
+
}
|
|
510
|
+
/** Pliega o despliega un grupo de pestañas: sus pestañas se ocultan, salvo la activa. Emite `z:grouptoggle`. */
|
|
511
|
+
export function setTabGroupCollapsed(strip, group, collapsed) {
|
|
512
|
+
for (const tab of strip.querySelectorAll(`.z-tabstrip__tab[data-group="${CSS.escape(group)}"]`))
|
|
513
|
+
tab.hidden = collapsed && !tab.hasAttribute("data-selected");
|
|
514
|
+
strip
|
|
515
|
+
.querySelector(`.z-tabstrip__group[data-group-id="${CSS.escape(group)}"] .z-tabstrip__chip`)
|
|
516
|
+
?.setAttribute("aria-expanded", String(!collapsed));
|
|
517
|
+
emit(strip, "grouptoggle", { id: group, collapsed });
|
|
518
|
+
}
|
|
519
|
+
function announceMove(strip, id) {
|
|
520
|
+
const status = strip.querySelector(".z-tabstrip__status");
|
|
521
|
+
const shown = shownSelects(strip);
|
|
522
|
+
const select = findTab(strip, id);
|
|
523
|
+
if (!status || !select)
|
|
524
|
+
return;
|
|
525
|
+
const template = status.dataset.movedLabel ?? "{title} moved to position {position} of {total}";
|
|
526
|
+
status.textContent = template
|
|
527
|
+
.replace("{title}", select.querySelector(".z-tabstrip__title")?.textContent ?? id)
|
|
528
|
+
.replace("{position}", String(shown.indexOf(select) + 1))
|
|
529
|
+
.replace("{total}", String(shown.length));
|
|
530
|
+
}
|
|
531
|
+
// Arrastre de una pestaña: la marca de soltar va en el canto de la vecina; el orden cambia al soltar.
|
|
532
|
+
// Los tramos de las pestañas se miden al empezar: durante el arrastre nada cambia de sitio salvo la propia pestaña.
|
|
533
|
+
let tabDrag = null;
|
|
534
|
+
let swallowTabClick = false;
|
|
535
|
+
function tabDragMove(event) {
|
|
536
|
+
const d = tabDrag;
|
|
537
|
+
if (!d || event.pointerId !== d.pointerId)
|
|
538
|
+
return;
|
|
539
|
+
const dx = event.clientX - d.x;
|
|
540
|
+
if (!d.active) {
|
|
541
|
+
if (Math.abs(dx) < 4)
|
|
542
|
+
return;
|
|
543
|
+
d.active = true;
|
|
544
|
+
d.spans = shownSelects(d.strip).map((s) => {
|
|
545
|
+
const r = s.parentElement.getBoundingClientRect();
|
|
546
|
+
return { start: r.left, end: r.right };
|
|
547
|
+
});
|
|
548
|
+
d.select.parentElement.dataset.dragging = "";
|
|
549
|
+
try {
|
|
550
|
+
d.select.setPointerCapture(event.pointerId);
|
|
551
|
+
}
|
|
552
|
+
catch {
|
|
553
|
+
/* puntero ya liberado */
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
d.select.parentElement.style.setProperty("--z-tab-drag", `${dx}px`);
|
|
557
|
+
const shown = shownSelects(d.strip);
|
|
558
|
+
d.gap = dropIndex(event.clientX, d.spans, isRtl(d.strip));
|
|
559
|
+
const from = shown.indexOf(d.select);
|
|
560
|
+
for (const tab of d.strip.querySelectorAll(".z-tabstrip__tab[data-drop]"))
|
|
561
|
+
delete tab.dataset.drop;
|
|
562
|
+
if (d.gap === from || d.gap === from + 1)
|
|
563
|
+
return;
|
|
564
|
+
const target = shown[d.gap] ?? shown[shown.length - 1];
|
|
565
|
+
if (target?.parentElement)
|
|
566
|
+
target.parentElement.dataset.drop = d.gap < shown.length ? "before" : "after";
|
|
567
|
+
}
|
|
568
|
+
function tabDragEnd(event, cancelled) {
|
|
569
|
+
const d = tabDrag;
|
|
570
|
+
if (!d || event.pointerId !== d.pointerId)
|
|
571
|
+
return;
|
|
572
|
+
tabDrag = null;
|
|
573
|
+
const tab = d.select.parentElement;
|
|
574
|
+
tab.style.removeProperty("--z-tab-drag");
|
|
575
|
+
delete tab.dataset.dragging;
|
|
576
|
+
for (const t of d.strip.querySelectorAll(".z-tabstrip__tab[data-drop]"))
|
|
577
|
+
delete t.dataset.drop;
|
|
578
|
+
if (!d.active)
|
|
579
|
+
return;
|
|
580
|
+
swallowTabClick = true;
|
|
581
|
+
setTimeout(() => {
|
|
582
|
+
swallowTabClick = false;
|
|
583
|
+
});
|
|
584
|
+
if (cancelled || d.gap < 0)
|
|
585
|
+
return;
|
|
586
|
+
const shown = shownSelects(d.strip).map((s) => s.dataset.tabId ?? "");
|
|
587
|
+
const id = d.select.dataset.tabId ?? "";
|
|
588
|
+
moveWorkTab(d.strip, id, beforeFor(shown, id, finalIndex(shown.indexOf(id), d.gap)));
|
|
589
|
+
}
|
|
446
590
|
let created = 0;
|
|
447
591
|
/** Botón de alta: emite `z:add`. Si nadie lo cancela y el botón trae `data-new-title`, crea aquí la pestaña. */
|
|
448
592
|
function addRequested(strip, button) {
|
|
@@ -457,7 +601,14 @@ function addRequested(strip, button) {
|
|
|
457
601
|
}
|
|
458
602
|
let stripObserver;
|
|
459
603
|
const observedLists = new WeakSet();
|
|
604
|
+
const edgeLists = new WeakSet();
|
|
460
605
|
function hydrateStrip(strip) {
|
|
606
|
+
// Borde difuminado del lado con pestañas ocultas (data-scroll-edges; la hoja pone la máscara).
|
|
607
|
+
const tabList = strip.querySelector(".z-tabstrip__list");
|
|
608
|
+
if (tabList && !edgeLists.has(tabList)) {
|
|
609
|
+
edgeLists.add(tabList);
|
|
610
|
+
trackScrollEdges(tabList);
|
|
611
|
+
}
|
|
461
612
|
const active = activeTab(strip) ?? selects(strip)[0];
|
|
462
613
|
if (active?.dataset.tabId !== undefined)
|
|
463
614
|
applyTab(strip, active.dataset.tabId);
|
|
@@ -478,6 +629,9 @@ function hydrateStrip(strip) {
|
|
|
478
629
|
}
|
|
479
630
|
});
|
|
480
631
|
stripObserver.observe(list);
|
|
632
|
+
// El ancho de una pestaña cambia (carga de la fuente, título nuevo) sin que cambie el de la tira.
|
|
633
|
+
for (const tab of list.children)
|
|
634
|
+
stripObserver.observe(tab);
|
|
481
635
|
observedLists.add(list);
|
|
482
636
|
}
|
|
483
637
|
/* ---------- Sidebar en acordeón ---------- */
|
|
@@ -503,6 +657,299 @@ export function setSectionOpen(section, open) {
|
|
|
503
657
|
else
|
|
504
658
|
icon.replaceWith(iconElement(name, { size: icon.getAttribute("width") ?? 12 }));
|
|
505
659
|
}
|
|
660
|
+
/* ---------- Sidebar plegable a iconos ---------- */
|
|
661
|
+
const subOf = (link) => {
|
|
662
|
+
const id = link.getAttribute("aria-controls");
|
|
663
|
+
return id ? document.getElementById(id) : null;
|
|
664
|
+
};
|
|
665
|
+
const topLinks = (sidebar) => [...sidebar.querySelectorAll(".z-sidebar__link")].filter((link) => !link.closest(".z-sidebar__sub"));
|
|
666
|
+
/** Abre o pliega el submenú de un item de sidebar (`.z-sidebar__link[aria-controls]`), desplegada la sidebar. */
|
|
667
|
+
export function setSidebarItemOpen(link, open) {
|
|
668
|
+
const sub = subOf(link);
|
|
669
|
+
if (!sub || sub.hasAttribute("popover"))
|
|
670
|
+
return;
|
|
671
|
+
link.setAttribute("aria-expanded", String(open));
|
|
672
|
+
sub.hidden = !open;
|
|
673
|
+
const item = link.closest(".z-sidebar__item");
|
|
674
|
+
if (item) {
|
|
675
|
+
if (open)
|
|
676
|
+
item.dataset.open = "true";
|
|
677
|
+
else
|
|
678
|
+
delete item.dataset.open;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Pliega la sidebar a iconos o la despliega. Plegada, cada item muestra su nombre en un tooltip y un submenú pasa a
|
|
683
|
+
* ser un popover anclado al item; desplegada, vuelve a abrirse en su sitio. Emite `z:change` { collapsed }.
|
|
684
|
+
*/
|
|
685
|
+
export function setSidebarCollapsed(sidebar, collapsed, silent = false) {
|
|
686
|
+
if (collapsed)
|
|
687
|
+
sidebar.dataset.collapsed = "true";
|
|
688
|
+
else
|
|
689
|
+
delete sidebar.dataset.collapsed;
|
|
690
|
+
for (const link of topLinks(sidebar)) {
|
|
691
|
+
const sub = subOf(link);
|
|
692
|
+
const label = link.querySelector(".z-sidebar__label")?.textContent ?? "";
|
|
693
|
+
if (!sub) {
|
|
694
|
+
if (collapsed)
|
|
695
|
+
link.setAttribute("data-z-tooltip", label);
|
|
696
|
+
else
|
|
697
|
+
link.removeAttribute("data-z-tooltip");
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
if (collapsed) {
|
|
701
|
+
if (!sub.hasAttribute("popover"))
|
|
702
|
+
sub.dataset.wasOpen = String(!sub.hidden);
|
|
703
|
+
sub.hidden = false;
|
|
704
|
+
sub.setAttribute("popover", "auto");
|
|
705
|
+
sub.classList.add("z-liquid");
|
|
706
|
+
link.setAttribute("data-z-open", `#${sub.id}`);
|
|
707
|
+
link.setAttribute("data-z-placement", "right-start");
|
|
708
|
+
link.setAttribute("aria-haspopup", "true");
|
|
709
|
+
link.setAttribute("aria-expanded", "false");
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
if (sub.matches(":popover-open"))
|
|
713
|
+
sub.hidePopover();
|
|
714
|
+
sub.removeAttribute("popover");
|
|
715
|
+
sub.classList.remove("z-liquid");
|
|
716
|
+
sub.removeAttribute("style");
|
|
717
|
+
link.removeAttribute("data-z-open");
|
|
718
|
+
link.removeAttribute("data-z-placement");
|
|
719
|
+
link.removeAttribute("aria-haspopup");
|
|
720
|
+
sub.hidden = false;
|
|
721
|
+
setSidebarItemOpen(link, sub.dataset.wasOpen === "true");
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
for (const trigger of document.querySelectorAll(".z-sidebar__trigger")) {
|
|
725
|
+
if (sidebar.id && trigger.getAttribute("aria-controls") === sidebar.id) {
|
|
726
|
+
trigger.setAttribute("aria-expanded", String(!collapsed));
|
|
727
|
+
if (collapsed)
|
|
728
|
+
trigger.dataset.collapsed = "true";
|
|
729
|
+
else
|
|
730
|
+
delete trigger.dataset.collapsed;
|
|
731
|
+
const name = collapsed ? "chevron-double-right" : "chevron-double-left";
|
|
732
|
+
const icon = trigger.querySelector(":scope > z-icon, :scope > svg.z-icon");
|
|
733
|
+
if (icon?.localName === "z-icon")
|
|
734
|
+
icon.setAttribute("name", name);
|
|
735
|
+
else
|
|
736
|
+
icon?.replaceWith(iconElement(name, { size: 16 }));
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
if (!silent)
|
|
740
|
+
emit(sidebar, "change", { collapsed });
|
|
741
|
+
}
|
|
742
|
+
/* ---------- Panel flotante ---------- */
|
|
743
|
+
const panelRect = (panel) => ({
|
|
744
|
+
x: panel.offsetLeft,
|
|
745
|
+
y: panel.offsetTop,
|
|
746
|
+
width: panel.offsetWidth,
|
|
747
|
+
height: panel.offsetHeight,
|
|
748
|
+
});
|
|
749
|
+
const panelBounds = (panel) => {
|
|
750
|
+
const parent = panel.dataset.strategy === "absolute" ? panel.offsetParent : null;
|
|
751
|
+
return parent
|
|
752
|
+
? { width: parent.clientWidth, height: parent.clientHeight }
|
|
753
|
+
: { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight };
|
|
754
|
+
};
|
|
755
|
+
const panelMin = (panel) => ({ width: num(panel.dataset.minWidth, 200), height: num(panel.dataset.minHeight, 120) });
|
|
756
|
+
// Botón que abrió cada panel: recibe el foco al cerrarlo.
|
|
757
|
+
const panelOpeners = new WeakMap();
|
|
758
|
+
/** Coloca y dimensiona un panel flotante (acotado a su área). Emite `z:change` con el rectángulo final. */
|
|
759
|
+
export function setFloatingPanelRect(panel, rect, silent = false) {
|
|
760
|
+
const next = clampRect(rect, panelBounds(panel), panelMin(panel));
|
|
761
|
+
panel.style.left = `${next.x}px`;
|
|
762
|
+
panel.style.top = `${next.y}px`;
|
|
763
|
+
panel.style.width = `${next.width}px`;
|
|
764
|
+
panel.style.height = `${next.height}px`;
|
|
765
|
+
if (!silent)
|
|
766
|
+
emit(panel, "change", next);
|
|
767
|
+
return next;
|
|
768
|
+
}
|
|
769
|
+
function resizePanel(panel, start, dw, dh) {
|
|
770
|
+
const next = resizeRect(start, dw, dh, panelBounds(panel), panelMin(panel), isRtl(panel));
|
|
771
|
+
setFloatingPanelRect(panel, next);
|
|
772
|
+
}
|
|
773
|
+
/** Muestra un panel flotante y le lleva el foco. `opener` lo recibe de vuelta al cerrarlo. */
|
|
774
|
+
export function openFloatingPanel(panel, opener) {
|
|
775
|
+
panel.hidden = false;
|
|
776
|
+
if (opener)
|
|
777
|
+
panelOpeners.set(panel, opener);
|
|
778
|
+
setFloatingPanelRect(panel, panelRect(panel), true);
|
|
779
|
+
panel.focus({ preventScroll: true });
|
|
780
|
+
emit(panel, "open");
|
|
781
|
+
}
|
|
782
|
+
/** Oculta un panel flotante (emite `z:close`, cancelable). El foco vuelve a quien lo abrió. */
|
|
783
|
+
export function closeFloatingPanel(panel) {
|
|
784
|
+
if (!emit(panel, "close"))
|
|
785
|
+
return;
|
|
786
|
+
const hadFocus = panel.contains(document.activeElement);
|
|
787
|
+
panel.hidden = true;
|
|
788
|
+
if (hadFocus)
|
|
789
|
+
panelOpeners.get(panel)?.focus({ preventScroll: true });
|
|
790
|
+
}
|
|
791
|
+
/* ---------- Mosaico de paneles ---------- */
|
|
792
|
+
const paneSections = (layout) => [...layout.querySelectorAll(".z-panelayout__pane[data-pane-id]")];
|
|
793
|
+
function readNode(el) {
|
|
794
|
+
if (el.classList.contains("z-panelayout__pane"))
|
|
795
|
+
return { type: "pane", id: el.dataset.paneId ?? "" };
|
|
796
|
+
if (!el.classList.contains("z-split"))
|
|
797
|
+
return null;
|
|
798
|
+
const cells = parts(el, "z-split__pane");
|
|
799
|
+
const children = cells.map((cell) => (cell.firstElementChild ? readNode(cell.firstElementChild) : null)).filter(Boolean);
|
|
800
|
+
return { type: "split", direction: directionOf(el), sizes: getSplitSizes(el), children };
|
|
801
|
+
}
|
|
802
|
+
/** Árbol del mosaico leído del marcado. */
|
|
803
|
+
export function getPaneLayout(layout) {
|
|
804
|
+
const top = [...layout.children].find((c) => c.classList.contains("z-split") || c.classList.contains("z-panelayout__pane"));
|
|
805
|
+
return top ? readNode(top) : null;
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Rehace el marcado del mosaico con el árbol `tree`, moviendo los paneles existentes (conservan su contenido y su
|
|
809
|
+
* estado). Un panel nuevo debe estar ya en el mosaico o pasarse en `extra`. Emite `z:layout` { layout }.
|
|
810
|
+
*/
|
|
811
|
+
export function setPaneLayout(layout, tree, extra = []) {
|
|
812
|
+
const byId = new Map([...paneSections(layout), ...extra].map((el) => [el.dataset.paneId ?? "", el]));
|
|
813
|
+
const label = layout.dataset.dividerLabel ?? "Resize panes";
|
|
814
|
+
let count = 0;
|
|
815
|
+
const build = (node) => {
|
|
816
|
+
if (node.type === "pane")
|
|
817
|
+
return byId.get(node.id) ?? null;
|
|
818
|
+
const split = document.createElement("div");
|
|
819
|
+
split.className = "z-split";
|
|
820
|
+
split.dataset.direction = node.direction;
|
|
821
|
+
node.children.forEach((child, i) => {
|
|
822
|
+
const built = build(child);
|
|
823
|
+
if (!built)
|
|
824
|
+
return;
|
|
825
|
+
if (i > 0) {
|
|
826
|
+
const divider = document.createElement("div");
|
|
827
|
+
divider.className = "z-split__divider";
|
|
828
|
+
divider.setAttribute("aria-label", label);
|
|
829
|
+
split.append(divider);
|
|
830
|
+
}
|
|
831
|
+
const cell = document.createElement("div");
|
|
832
|
+
cell.className = "z-split__pane";
|
|
833
|
+
cell.id = `${layout.id || "panelayout"}-cell-${++count}`;
|
|
834
|
+
cell.append(built);
|
|
835
|
+
split.append(cell);
|
|
836
|
+
});
|
|
837
|
+
setSplitSizes(split, node.sizes);
|
|
838
|
+
return split;
|
|
839
|
+
};
|
|
840
|
+
const top = build(tree);
|
|
841
|
+
const status = layout.querySelector(":scope > .z-panelayout__status");
|
|
842
|
+
layout.replaceChildren(...(top ? [top] : []), ...(status ? [status] : []));
|
|
843
|
+
for (const split of layout.querySelectorAll(".z-split"))
|
|
844
|
+
hydrateSplit(split);
|
|
845
|
+
syncPaneFocus(layout);
|
|
846
|
+
emit(layout, "layout", { layout: tree });
|
|
847
|
+
}
|
|
848
|
+
/** Divide el panel `id` y pone `pane` (un `.z-panelayout__pane[data-pane-id]` nuevo) a su lado. */
|
|
849
|
+
export function splitLayoutPane(layout, id, pane, direction) {
|
|
850
|
+
const tree = getPaneLayout(layout);
|
|
851
|
+
if (!tree || !pane.dataset.paneId)
|
|
852
|
+
return;
|
|
853
|
+
setPaneLayout(layout, splitPane(tree, id, pane.dataset.paneId, direction), [pane]);
|
|
854
|
+
}
|
|
855
|
+
/** Marca el panel con el foco (el pulsado o enfocado) y atenúa el resto. */
|
|
856
|
+
function syncPaneFocus(layout, focused) {
|
|
857
|
+
const sections = paneSections(layout);
|
|
858
|
+
const current = focused ?? layout.dataset.focused ?? sections[0]?.dataset.paneId;
|
|
859
|
+
if (current)
|
|
860
|
+
layout.dataset.focused = current;
|
|
861
|
+
for (const section of sections) {
|
|
862
|
+
const on = String(section.dataset.paneId === current);
|
|
863
|
+
if (sections.length < 2) {
|
|
864
|
+
section.querySelector(".z-pane")?.removeAttribute("data-focused");
|
|
865
|
+
section.querySelector(".z-paneheader")?.removeAttribute("data-focused");
|
|
866
|
+
continue;
|
|
867
|
+
}
|
|
868
|
+
section.querySelector(".z-pane")?.setAttribute("data-focused", on);
|
|
869
|
+
section.querySelector(".z-paneheader")?.setAttribute("data-focused", on);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
function announcePane(layout, id) {
|
|
873
|
+
const status = layout.querySelector(":scope > .z-panelayout__status");
|
|
874
|
+
const title = layout.querySelector(`[data-pane-id="${CSS.escape(id)}"] .z-paneheader__title`)?.textContent ?? id;
|
|
875
|
+
if (status)
|
|
876
|
+
status.textContent = (status.dataset.movedLabel ?? "{title} moved").replace("{title}", title);
|
|
877
|
+
}
|
|
878
|
+
function paneAction(item) {
|
|
879
|
+
const action = item.dataset.paneAction ?? "";
|
|
880
|
+
const section = document.querySelector(`[data-pane-id="${CSS.escape(item.dataset.paneFor ?? "")}"]`);
|
|
881
|
+
const layout = section?.closest(".z-panelayout");
|
|
882
|
+
const id = section?.dataset.paneId;
|
|
883
|
+
const tree = layout ? getPaneLayout(layout) : null;
|
|
884
|
+
if (!layout || !id || !tree)
|
|
885
|
+
return;
|
|
886
|
+
if (action === "close") {
|
|
887
|
+
const next = removePane(tree, id);
|
|
888
|
+
if (next && emit(layout, "close", { id }))
|
|
889
|
+
setPaneLayout(layout, next);
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
if (action === "split-right" || action === "split-down") {
|
|
893
|
+
emit(layout, "split", { id, direction: action === "split-right" ? "row" : "column" });
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
const direction = { "move-left": "left", "move-right": "right", "move-up": "up", "move-down": "down" }[action];
|
|
897
|
+
if (!direction)
|
|
898
|
+
return;
|
|
899
|
+
const rects = paneSections(layout).map((el) => ({ id: el.dataset.paneId ?? "", rect: el.getBoundingClientRect() }));
|
|
900
|
+
const other = neighborPane(rects, id, direction);
|
|
901
|
+
if (!other)
|
|
902
|
+
return;
|
|
903
|
+
setPaneLayout(layout, movePane(tree, id, other, "center"));
|
|
904
|
+
announcePane(layout, id);
|
|
905
|
+
// El foco vuelve al menú del panel movido (zui/dom lo devuelve a su disparador, que sigue siendo el mismo botón).
|
|
906
|
+
}
|
|
907
|
+
// Arrastre de un panel por su cabecera.
|
|
908
|
+
let paneDrag = null;
|
|
909
|
+
function paneDragMove(event) {
|
|
910
|
+
const d = paneDrag;
|
|
911
|
+
if (!d || event.pointerId !== d.pointerId)
|
|
912
|
+
return;
|
|
913
|
+
if (!d.active) {
|
|
914
|
+
if (Math.hypot(event.clientX - d.x, event.clientY - d.y) < 6)
|
|
915
|
+
return;
|
|
916
|
+
d.active = true;
|
|
917
|
+
d.layout.dataset.dragging = "";
|
|
918
|
+
d.layout.querySelector(`[data-pane-id="${CSS.escape(d.id)}"]`)?.setAttribute("data-dragging", "");
|
|
919
|
+
}
|
|
920
|
+
d.layout.querySelector(".z-panelayout__drop")?.remove();
|
|
921
|
+
d.drop = null;
|
|
922
|
+
const hit = paneSections(d.layout).find((el) => {
|
|
923
|
+
const r = el.getBoundingClientRect();
|
|
924
|
+
return event.clientX >= r.left && event.clientX <= r.right && event.clientY >= r.top && event.clientY <= r.bottom;
|
|
925
|
+
});
|
|
926
|
+
if (!hit || hit.dataset.paneId === d.id)
|
|
927
|
+
return;
|
|
928
|
+
const edge = paneDropEdge(hit.getBoundingClientRect(), { x: event.clientX, y: event.clientY }, isRtl(d.layout));
|
|
929
|
+
d.drop = { target: hit.dataset.paneId ?? "", edge };
|
|
930
|
+
const overlay = document.createElement("div");
|
|
931
|
+
overlay.className = "z-panelayout__drop";
|
|
932
|
+
overlay.dataset.edge = edge;
|
|
933
|
+
overlay.setAttribute("aria-hidden", "true");
|
|
934
|
+
hit.append(overlay);
|
|
935
|
+
}
|
|
936
|
+
function paneDragEnd(event, cancelled) {
|
|
937
|
+
const d = paneDrag;
|
|
938
|
+
if (!d || event.pointerId !== d.pointerId)
|
|
939
|
+
return;
|
|
940
|
+
paneDrag = null;
|
|
941
|
+
d.layout.querySelector(".z-panelayout__drop")?.remove();
|
|
942
|
+
delete d.layout.dataset.dragging;
|
|
943
|
+
d.layout.querySelector(`[data-pane-id="${CSS.escape(d.id)}"]`)?.removeAttribute("data-dragging");
|
|
944
|
+
const tree = getPaneLayout(d.layout);
|
|
945
|
+
if (!d.active || cancelled || !d.drop || !tree)
|
|
946
|
+
return;
|
|
947
|
+
const next = movePane(tree, d.id, d.drop.target, d.drop.edge);
|
|
948
|
+
if (next === tree)
|
|
949
|
+
return;
|
|
950
|
+
setPaneLayout(d.layout, next);
|
|
951
|
+
announcePane(d.layout, d.id);
|
|
952
|
+
}
|
|
506
953
|
/* ---------- Delegación de eventos ---------- */
|
|
507
954
|
function onClick(event) {
|
|
508
955
|
const target = event.target;
|
|
@@ -537,6 +984,14 @@ function onClick(event) {
|
|
|
537
984
|
}
|
|
538
985
|
const strip = target.closest(".z-tabstrip");
|
|
539
986
|
if (strip) {
|
|
987
|
+
const chip = target.closest(".z-tabstrip__chip");
|
|
988
|
+
const groupId = chip?.closest(".z-tabstrip__group")?.dataset.groupId;
|
|
989
|
+
if (chip && groupId) {
|
|
990
|
+
setTabGroupCollapsed(strip, groupId, chip.getAttribute("aria-expanded") !== "false");
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
if (swallowTabClick)
|
|
994
|
+
return;
|
|
540
995
|
const id = target.closest(".z-tabstrip__tab")?.querySelector(".z-tabstrip__select")?.dataset.tabId;
|
|
541
996
|
if (id !== undefined && target.closest(".z-tabstrip__close"))
|
|
542
997
|
closeWorkTab(strip, id);
|
|
@@ -546,6 +1001,38 @@ function onClick(event) {
|
|
|
546
1001
|
addRequested(strip, target.closest(".z-tabstrip__add"));
|
|
547
1002
|
return;
|
|
548
1003
|
}
|
|
1004
|
+
const panelOpener = target.closest("[data-z-panel]");
|
|
1005
|
+
if (panelOpener) {
|
|
1006
|
+
const panel = document.getElementById((panelOpener.getAttribute("data-z-panel") ?? "").replace(/^#/, ""));
|
|
1007
|
+
if (panel?.classList.contains("z-floatpanel")) {
|
|
1008
|
+
if (panel.hidden)
|
|
1009
|
+
openFloatingPanel(panel, panelOpener);
|
|
1010
|
+
else
|
|
1011
|
+
closeFloatingPanel(panel);
|
|
1012
|
+
}
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
const panelClose = target.closest(".z-floatpanel__close");
|
|
1016
|
+
if (panelClose) {
|
|
1017
|
+
const panel = panelClose.closest(".z-floatpanel");
|
|
1018
|
+
if (panel)
|
|
1019
|
+
closeFloatingPanel(panel);
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
const trigger = target.closest(".z-sidebar__trigger");
|
|
1023
|
+
if (trigger) {
|
|
1024
|
+
const sidebar = document.getElementById(trigger.getAttribute("aria-controls") ?? "");
|
|
1025
|
+
if (sidebar?.classList.contains("z-sidebar"))
|
|
1026
|
+
setSidebarCollapsed(sidebar, !sidebar.hasAttribute("data-collapsed"));
|
|
1027
|
+
return;
|
|
1028
|
+
}
|
|
1029
|
+
const sidebarLink = target.closest(".z-sidebar__link[aria-controls]");
|
|
1030
|
+
if (sidebarLink && !sidebarLink.hasAttribute("data-z-open") && !sidebarLink.disabled) {
|
|
1031
|
+
const open = sidebarLink.getAttribute("aria-expanded") !== "true";
|
|
1032
|
+
setSidebarItemOpen(sidebarLink, open);
|
|
1033
|
+
emit(sidebarLink.closest(".z-sidebar__item") ?? sidebarLink, "change", { open });
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
549
1036
|
const fold = target.closest(".z-sidebar__fold");
|
|
550
1037
|
const section = fold?.closest(".z-sidebar__section");
|
|
551
1038
|
if (section) {
|
|
@@ -562,6 +1049,12 @@ function onKeydown(event) {
|
|
|
562
1049
|
if (event.key === "Escape") {
|
|
563
1050
|
if (event.defaultPrevented || target.closest("dialog[open], :popover-open"))
|
|
564
1051
|
return;
|
|
1052
|
+
const panel = target.closest(".z-floatpanel");
|
|
1053
|
+
if (panel && inDom(panel) && panel.querySelector(".z-floatpanel__close")) {
|
|
1054
|
+
event.preventDefault();
|
|
1055
|
+
closeFloatingPanel(panel);
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
565
1058
|
for (const drawer of document.querySelectorAll(".z-shell__drawer")) {
|
|
566
1059
|
const shell = drawer.closest(".z-shell");
|
|
567
1060
|
if (shell && shells.has(shell))
|
|
@@ -569,8 +1062,37 @@ function onKeydown(event) {
|
|
|
569
1062
|
}
|
|
570
1063
|
return;
|
|
571
1064
|
}
|
|
1065
|
+
if (event.key.toLowerCase?.() === "b" && !event.altKey && !event.shiftKey && (event.ctrlKey || event.metaKey)) {
|
|
1066
|
+
const trigger = document.querySelector("[data-z-dom] .z-sidebar__trigger[data-shortcut]");
|
|
1067
|
+
if (trigger) {
|
|
1068
|
+
event.preventDefault();
|
|
1069
|
+
trigger.click();
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
572
1073
|
if (!inDom(target))
|
|
573
1074
|
return;
|
|
1075
|
+
const floatKey = target.closest(".z-floatpanel__handle, .z-floatpanel__resize");
|
|
1076
|
+
const floating = floatKey?.closest(".z-floatpanel");
|
|
1077
|
+
if (floatKey && floating) {
|
|
1078
|
+
const step = event.shiftKey ? FLOAT_STEP * 10 : FLOAT_STEP;
|
|
1079
|
+
const start = panelRect(floating);
|
|
1080
|
+
if (floatKey.classList.contains("z-floatpanel__handle")) {
|
|
1081
|
+
const d = moveDelta(event.key, step);
|
|
1082
|
+
if (!d)
|
|
1083
|
+
return;
|
|
1084
|
+
event.preventDefault();
|
|
1085
|
+
setFloatingPanelRect(floating, { ...start, x: start.x + d.dx, y: start.y + d.dy });
|
|
1086
|
+
}
|
|
1087
|
+
else {
|
|
1088
|
+
const d = resizeDelta(event.key, step);
|
|
1089
|
+
if (!d)
|
|
1090
|
+
return;
|
|
1091
|
+
event.preventDefault();
|
|
1092
|
+
resizePanel(floating, start, d.dw, d.dh);
|
|
1093
|
+
}
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
574
1096
|
const handle = target.closest(".z-resize");
|
|
575
1097
|
if (handle) {
|
|
576
1098
|
const options = resizeOptions(handle);
|
|
@@ -596,7 +1118,6 @@ function onKeydown(event) {
|
|
|
596
1118
|
const list = target.closest(".z-tabstrip__list");
|
|
597
1119
|
const strip = list?.closest(".z-tabstrip");
|
|
598
1120
|
if (list && strip) {
|
|
599
|
-
const tabs = selects(strip);
|
|
600
1121
|
const current = activeTab(strip);
|
|
601
1122
|
// Supr cierra la pestaña activa si tiene cierre (misma vía de teclado que el binding de React).
|
|
602
1123
|
if (event.key === "Delete" && current?.parentElement?.querySelector(".z-tabstrip__close")) {
|
|
@@ -605,7 +1126,19 @@ function onKeydown(event) {
|
|
|
605
1126
|
activeTab(strip)?.focus();
|
|
606
1127
|
return;
|
|
607
1128
|
}
|
|
608
|
-
const
|
|
1129
|
+
const shown = shownSelects(strip);
|
|
1130
|
+
if (current && strip.hasAttribute("data-reorderable") && event.ctrlKey && event.shiftKey && !event.altKey) {
|
|
1131
|
+
const to = tabMoveIndex(event.key, shown.indexOf(current), shown.length, isRtl(list));
|
|
1132
|
+
if (to < 0)
|
|
1133
|
+
return;
|
|
1134
|
+
event.preventDefault();
|
|
1135
|
+
const ids = shown.map((x) => x.dataset.tabId ?? "");
|
|
1136
|
+
const id = current.dataset.tabId ?? "";
|
|
1137
|
+
if (moveWorkTab(strip, id, beforeFor(ids, id, to)))
|
|
1138
|
+
announceMove(strip, id);
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
const next = shown[tabKeyIndex(event.key, shown.indexOf(activeTab(strip)), shown.length, isRtl(list))];
|
|
609
1142
|
if (!next)
|
|
610
1143
|
return;
|
|
611
1144
|
event.preventDefault();
|
|
@@ -619,6 +1152,57 @@ function onPointerDown(event) {
|
|
|
619
1152
|
const target = event.target;
|
|
620
1153
|
if (!(target instanceof Element) || event.button !== 0 || !inDom(target))
|
|
621
1154
|
return;
|
|
1155
|
+
const tabSelect = target.closest(".z-tabstrip[data-reorderable] .z-tabstrip__select");
|
|
1156
|
+
if (tabSelect) {
|
|
1157
|
+
tabDrag = {
|
|
1158
|
+
strip: tabSelect.closest(".z-tabstrip"),
|
|
1159
|
+
select: tabSelect,
|
|
1160
|
+
pointerId: event.pointerId,
|
|
1161
|
+
x: event.clientX,
|
|
1162
|
+
active: false,
|
|
1163
|
+
gap: -1,
|
|
1164
|
+
spans: [],
|
|
1165
|
+
};
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
const grab = target.closest(".z-panelayout__grab");
|
|
1169
|
+
const grabLayout = grab?.closest(".z-panelayout");
|
|
1170
|
+
if (grab && grabLayout && !target.closest("button, a, input, select, textarea") && paneSections(grabLayout).length > 1) {
|
|
1171
|
+
const id = grab.closest(".z-panelayout__pane")?.dataset.paneId;
|
|
1172
|
+
if (id)
|
|
1173
|
+
paneDrag = { layout: grabLayout, id, pointerId: event.pointerId, x: event.clientX, y: event.clientY, active: false, drop: null };
|
|
1174
|
+
try {
|
|
1175
|
+
grab.setPointerCapture(event.pointerId);
|
|
1176
|
+
}
|
|
1177
|
+
catch {
|
|
1178
|
+
/* puntero ya liberado */
|
|
1179
|
+
}
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
const grip = target.closest(".z-floatpanel__header, .z-floatpanel__resize");
|
|
1183
|
+
const gripPanel = grip?.closest(".z-floatpanel");
|
|
1184
|
+
if (grip && gripPanel) {
|
|
1185
|
+
const control = target.closest("button, a, input, select, textarea");
|
|
1186
|
+
if (control && control !== grip && !control.classList.contains("z-floatpanel__handle"))
|
|
1187
|
+
return;
|
|
1188
|
+
const start = panelRect(gripPanel);
|
|
1189
|
+
const [x, y] = [event.clientX, event.clientY];
|
|
1190
|
+
const resizing = grip.classList.contains("z-floatpanel__resize");
|
|
1191
|
+
grip.dataset.dragging = "";
|
|
1192
|
+
drag = {
|
|
1193
|
+
el: grip,
|
|
1194
|
+
move: (e) => resizing
|
|
1195
|
+
? resizePanel(gripPanel, start, e.clientX - x, e.clientY - y)
|
|
1196
|
+
: setFloatingPanelRect(gripPanel, { ...start, x: start.x + e.clientX - x, y: start.y + e.clientY - y }),
|
|
1197
|
+
};
|
|
1198
|
+
try {
|
|
1199
|
+
grip.setPointerCapture(event.pointerId);
|
|
1200
|
+
}
|
|
1201
|
+
catch {
|
|
1202
|
+
/* puntero ya liberado */
|
|
1203
|
+
}
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
622
1206
|
let move;
|
|
623
1207
|
const el = target.closest(".z-resize, .z-split__divider");
|
|
624
1208
|
if (!el)
|
|
@@ -656,7 +1240,11 @@ function onPointerDown(event) {
|
|
|
656
1240
|
/* puntero ya liberado */
|
|
657
1241
|
}
|
|
658
1242
|
}
|
|
659
|
-
function onPointerEnd() {
|
|
1243
|
+
function onPointerEnd(event) {
|
|
1244
|
+
// El último pointermove puede no llegar antes de soltar (Firefox los agrupa con la página ocupada): la posición
|
|
1245
|
+
// final es la del pointerup.
|
|
1246
|
+
if (drag && event)
|
|
1247
|
+
drag.move(event);
|
|
660
1248
|
if (drag)
|
|
661
1249
|
delete drag.el.dataset.dragging;
|
|
662
1250
|
drag = null;
|
|
@@ -689,6 +1277,14 @@ export function hydrate(root = document) {
|
|
|
689
1277
|
hydrateSplit(split);
|
|
690
1278
|
for (const strip of all(root, ".z-tabstrip"))
|
|
691
1279
|
hydrateStrip(strip);
|
|
1280
|
+
for (const sidebar of all(root, ".z-sidebar[data-collapsed]"))
|
|
1281
|
+
setSidebarCollapsed(sidebar, true, true);
|
|
1282
|
+
for (const panel of all(root, ".z-floatpanel"))
|
|
1283
|
+
if (!panel.hidden)
|
|
1284
|
+
setFloatingPanelRect(panel, panelRect(panel), true);
|
|
1285
|
+
for (const layout of all(root, ".z-panelayout"))
|
|
1286
|
+
syncPaneFocus(layout);
|
|
1287
|
+
hydrateSite(root);
|
|
692
1288
|
for (const handle of all(root, ".z-resize")) {
|
|
693
1289
|
// Un tirador escrito solo con su clase recibe el rol y los atributos del patrón «window splitter».
|
|
694
1290
|
if (!handle.hasAttribute("role"))
|
|
@@ -714,6 +1310,7 @@ export function hydrate(root = document) {
|
|
|
714
1310
|
export function dispose(root = document) {
|
|
715
1311
|
if (!isBrowser)
|
|
716
1312
|
return;
|
|
1313
|
+
disposeSite(root);
|
|
717
1314
|
for (const shell of all(root, ".z-shell")) {
|
|
718
1315
|
shellObserver?.unobserve(shell);
|
|
719
1316
|
shells.delete(shell);
|
|
@@ -733,12 +1330,44 @@ export function init() {
|
|
|
733
1330
|
return;
|
|
734
1331
|
wired = true;
|
|
735
1332
|
document.addEventListener("click", onClick);
|
|
1333
|
+
document.addEventListener("click", onSiteClick);
|
|
736
1334
|
document.addEventListener("keydown", onKeydown);
|
|
737
1335
|
document.addEventListener("dblclick", onDoubleClick);
|
|
738
1336
|
document.addEventListener("pointerdown", onPointerDown);
|
|
739
|
-
document.addEventListener("pointermove", (event) =>
|
|
740
|
-
|
|
741
|
-
|
|
1337
|
+
document.addEventListener("pointermove", (event) => {
|
|
1338
|
+
drag?.move(event);
|
|
1339
|
+
tabDragMove(event);
|
|
1340
|
+
paneDragMove(event);
|
|
1341
|
+
});
|
|
1342
|
+
document.addEventListener("pointerup", (event) => {
|
|
1343
|
+
onPointerEnd(event);
|
|
1344
|
+
tabDragEnd(event, false);
|
|
1345
|
+
paneDragEnd(event, false);
|
|
1346
|
+
});
|
|
1347
|
+
document.addEventListener("pointercancel", (event) => {
|
|
1348
|
+
onPointerEnd();
|
|
1349
|
+
tabDragEnd(event, true);
|
|
1350
|
+
paneDragEnd(event, true);
|
|
1351
|
+
});
|
|
1352
|
+
// Elegir una acción del menú de un panel (los menús los mueve @zuccadev-labs/zuix-zui/dom, que emite z:select).
|
|
1353
|
+
document.addEventListener("z:select", (event) => {
|
|
1354
|
+
const item = event.target instanceof Element ? event.target.closest("[data-pane-action]") : null;
|
|
1355
|
+
if (item)
|
|
1356
|
+
paneAction(item);
|
|
1357
|
+
});
|
|
1358
|
+
// El panel pulsado o enfocado pasa a ser el del foco.
|
|
1359
|
+
const markPane = (event) => {
|
|
1360
|
+
const section = event.target instanceof Element ? event.target.closest(".z-panelayout__pane") : null;
|
|
1361
|
+
const layout = section?.closest(".z-panelayout");
|
|
1362
|
+
if (section && layout && inDom(layout) && layout.dataset.focused !== section.dataset.paneId)
|
|
1363
|
+
syncPaneFocus(layout, section.dataset.paneId);
|
|
1364
|
+
};
|
|
1365
|
+
document.addEventListener("pointerdown", markPane, true);
|
|
1366
|
+
document.addEventListener("focusin", markPane);
|
|
1367
|
+
document.addEventListener("dragstart", (event) => {
|
|
1368
|
+
if (event.target instanceof Element && event.target.closest(".z-tabstrip[data-reorderable] .z-tabstrip__select"))
|
|
1369
|
+
event.preventDefault();
|
|
1370
|
+
});
|
|
742
1371
|
if (document.readyState === "loading")
|
|
743
1372
|
document.addEventListener("DOMContentLoaded", () => hydrate());
|
|
744
1373
|
else
|