@zuccadev-labs/zuix-zout 0.2.0 → 0.4.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 +134 -0
- package/README.md +22 -6
- package/dist/esm/chat-layout.d.ts +27 -0
- package/dist/esm/chat-layout.js +52 -0
- package/dist/esm/chat-layout.js.map +1 -0
- package/dist/esm/dom/chat.d.ts +11 -0
- package/dist/esm/dom/chat.js +106 -0
- package/dist/esm/dom/chat.js.map +1 -0
- package/dist/esm/dom/index.d.ts +31 -1
- package/dist/esm/dom/index.js +682 -11
- package/dist/esm/dom/index.js.map +1 -1
- package/dist/esm/dom/pages.d.ts +2 -0
- package/dist/esm/dom/pages.js +32 -0
- package/dist/esm/dom/pages.js.map +1 -0
- 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 +24 -2
- package/dist/esm/index.js +21 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/layouts/AppBar.d.ts +30 -0
- package/dist/esm/layouts/AppBar.js +18 -0
- package/dist/esm/layouts/AppBar.js.map +1 -0
- package/dist/esm/layouts/AuthLayout.d.ts +23 -0
- package/dist/esm/layouts/AuthLayout.js +10 -0
- package/dist/esm/layouts/AuthLayout.js.map +1 -0
- 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/ChatLayout.d.ts +34 -0
- package/dist/esm/layouts/ChatLayout.js +82 -0
- package/dist/esm/layouts/ChatLayout.js.map +1 -0
- package/dist/esm/layouts/DashboardLayout.d.ts +27 -0
- package/dist/esm/layouts/DashboardLayout.js +11 -0
- package/dist/esm/layouts/DashboardLayout.js.map +1 -0
- package/dist/esm/layouts/DocsLayout.d.ts +39 -0
- package/dist/esm/layouts/DocsLayout.js +26 -0
- package/dist/esm/layouts/DocsLayout.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 +140 -0
- package/dist/esm/layouts/FloatingPanel.js.map +1 -0
- package/dist/esm/layouts/KanbanLayout.d.ts +17 -0
- package/dist/esm/layouts/KanbanLayout.js +10 -0
- package/dist/esm/layouts/KanbanLayout.js.map +1 -0
- package/dist/esm/layouts/LandingLayout.d.ts +43 -0
- package/dist/esm/layouts/LandingLayout.js +16 -0
- package/dist/esm/layouts/LandingLayout.js.map +1 -0
- package/dist/esm/layouts/MailLayout.d.ts +20 -0
- package/dist/esm/layouts/MailLayout.js +10 -0
- package/dist/esm/layouts/MailLayout.js.map +1 -0
- package/dist/esm/layouts/Navbar.d.ts +28 -0
- package/dist/esm/layouts/Navbar.js +23 -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 +38 -0
- package/dist/esm/layouts/NavigationMenu.js.map +1 -0
- package/dist/esm/layouts/Page.d.ts +19 -5
- package/dist/esm/layouts/Page.js +6 -5
- 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/ProfileLayout.d.ts +15 -0
- package/dist/esm/layouts/ProfileLayout.js +7 -0
- package/dist/esm/layouts/ProfileLayout.js.map +1 -0
- package/dist/esm/layouts/SettingsLayout.d.ts +31 -0
- package/dist/esm/layouts/SettingsLayout.js +12 -0
- package/dist/esm/layouts/SettingsLayout.js.map +1 -0
- package/dist/esm/layouts/Shell.d.ts +6 -1
- package/dist/esm/layouts/Shell.js +13 -8
- package/dist/esm/layouts/Shell.js.map +1 -1
- 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/edges.internal.d.ts +8 -0
- package/dist/esm/layouts/edges.internal.js +14 -0
- package/dist/esm/layouts/edges.internal.js.map +1 -0
- 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 +146 -2
- package/dist/esm/logic.js +290 -6
- package/dist/esm/logic.js.map +1 -1
- package/dist/esm/pages.d.ts +7 -0
- package/dist/esm/pages.js +91 -0
- package/dist/esm/pages.js.map +1 -0
- package/dist/esm/popover.d.ts +9 -0
- package/dist/esm/popover.js +40 -0
- package/dist/esm/popover.js.map +1 -0
- package/dist/esm/react-compat.d.ts +4 -0
- package/dist/esm/react-compat.js +18 -0
- package/dist/esm/react-compat.js.map +1 -0
- package/dist/esm/site.d.ts +26 -0
- package/dist/esm/site.js +281 -0
- package/dist/esm/site.js.map +1 -0
- package/dist/zout.compat.css +4196 -0
- package/dist/zout.css +2824 -109
- package/dist/zout.dom.js +1 -1
- package/html.json +496 -9
- package/manifest.json +2283 -119
- package/package.json +9 -7
package/dist/esm/dom/index.js
CHANGED
|
@@ -4,28 +4,78 @@
|
|
|
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:
|
|
11
14
|
// data-z-shell-toggle="sidebar|inspector" botón que abre o cierra ese panel (data-z-shell="#id" si está fuera del shell)
|
|
12
15
|
// data-z-close dentro de un cajón del shell: lo cierra
|
|
13
16
|
// data-sidebar-breakpoint, data-inspector-breakpoint en .z-shell: cortes en px (880 y 1180 por defecto)
|
|
17
|
+
// data-rail-breakpoint en .z-shell: bajo este ancho (600 por defecto) el rail va dentro del cajón de la sidebar
|
|
14
18
|
// data-panel-mode="auto|docked|overlay" en el <aside>: preferencia de modo (auto por defecto)
|
|
15
19
|
// hidden en el <aside>: panel cerrado
|
|
16
20
|
// data-close-label en .z-shell: nombre accesible del velo
|
|
17
21
|
// 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
22
|
// data-min-fraction en .z-split
|
|
19
23
|
// data-new-title="Untitled" en .z-tabstrip__add: crea la pestaña sin código de la aplicación
|
|
24
|
+
// data-reorderable en .z-tabstrip: arrastrar pestañas y Ctrl+Mayús+flechas (z:reorder { ids });
|
|
25
|
+
// .z-tabstrip__status[role=status] recibe el anuncio (data-moved-label con
|
|
26
|
+
// {title}, {position} y {total})
|
|
27
|
+
// .z-tabstrip__chip chip de grupo: pliega sus pestañas ([data-group]) y emite z:grouptoggle
|
|
28
|
+
// .z-floatpanel[role=dialog] panel flotante: se arrastra por .z-floatpanel__header (o con flechas en
|
|
29
|
+
// .z-floatpanel__handle) y se redimensiona por .z-floatpanel__resize;
|
|
30
|
+
// data-strategy="absolute" lo acota a su contenedor; data-min-width/height;
|
|
31
|
+
// .z-floatpanel__close o Escape lo ocultan (z:close). data-z-panel="#id" en
|
|
32
|
+
// un botón lo abre y recibe el foco al cerrarlo. z:change { x, y, width, height }
|
|
33
|
+
// .z-panelayout mosaico: .z-split anidados y .z-panelayout__pane[data-pane-id]; arrastrar
|
|
34
|
+
// .z-panelayout__grab sobre otro panel lo deja en ese borde (o lo
|
|
35
|
+
// intercambia en el centro); items de menú [data-pane-action=move-left|
|
|
36
|
+
// move-right|move-up|move-down|close|split-right|split-down]. z:layout
|
|
37
|
+
// { layout } tras cada cambio; z:split { id, direction } para dividir
|
|
38
|
+
// (la aplicación llama a splitLayoutPane con el panel nuevo)
|
|
39
|
+
// data-collapsed en .z-sidebar: plegada a iconos (setSidebarCollapsed la alterna)
|
|
40
|
+
// .z-sidebar__trigger[aria-controls] botón que pliega y despliega la sidebar; data-shortcut: Ctrl/⌘+B
|
|
41
|
+
// La sidebar plegada usa del modo sin framework de zui el tooltip (`data-z-tooltip`) y el popover anclado
|
|
42
|
+
// (`data-z-open`) para el submenú: cargar también @zuccadev-labs/zuix-zui/dom.
|
|
43
|
+
// .z-chat-layout ChatLayout (./chat): data-view en estrecho, [data-z-chat-view] cambia de vista
|
|
44
|
+
// (z:viewchange), data-history sincroniza la pila, F6 entre paneles y
|
|
45
|
+
// variante widget con .z-chat-layout__launcher (z:open, z:close)
|
|
46
|
+
// .z-navbar / .z-navmenu navegación de sitio (./site): fila o cajón medido sin punto de corte fijo y
|
|
47
|
+
// grupos de disclosure con panel; .z-skiplink; .z-bottomnav con botones
|
|
48
|
+
// (aria-current y z:select { value })
|
|
49
|
+
// .z-appbar[data-collapse] barra que se pliega al desplazar (respaldo sin animaciones ligadas al
|
|
50
|
+
// desplazamiento) y data-scrolled con algo desplazado (./pages)
|
|
51
|
+
// .z-docs-layout__toc índice con la sección que se lee marcada con aria-current
|
|
20
52
|
// Tras insertar marcado nuevo: hydrate(contenedor).
|
|
21
53
|
// Eventos (burbujean y se pueden cancelar): z:modechange, z:open, z:close, z:resize, z:select, z:add, z:change.
|
|
22
54
|
import { iconElement, registerIcons } from "@zuccadev-labs/zuix-zicon/dom";
|
|
55
|
+
import { edgeMargin, trackScrollEdges } from "../edges.js";
|
|
56
|
+
import { disposePages, hydratePages } from "./pages.js";
|
|
57
|
+
import { disposeSite, hydrateSite, onSiteClick } from "./site.js";
|
|
58
|
+
import { hydrateChat, onChatClick, onChatKeydown, onChatPopState } from "./chat.js";
|
|
59
|
+
import { chevronDoubleLeft } from "@zuccadev-labs/zuix-zicon/icons/chevron-double-left";
|
|
60
|
+
import { chevronDoubleRight } from "@zuccadev-labs/zuix-zicon/icons/chevron-double-right";
|
|
23
61
|
import { chevronDownSmall } from "@zuccadev-labs/zuix-zicon/icons/chevron-down-small";
|
|
24
62
|
import { chevronRightSmall } from "@zuccadev-labs/zuix-zicon/icons/chevron-right-small";
|
|
25
63
|
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";
|
|
64
|
+
import { INSPECTOR_BREAKPOINT, RESIZE_MAX, RESIZE_MIN, RESIZE_STEP, RAIL_BREAKPOINT, SIDEBAR_BREAKPOINT, SPLIT_MIN_FRACTION, clamp, dividerKeyDelta, evenFractions, isHorizontal, moveDivider, panelMode, railInDrawer, 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";
|
|
65
|
+
/**
|
|
66
|
+
* ¿`el` está dentro de una capa `[popover]` abierta (con `within: false`, ¿es una)? Sin Popover API, `:popover-open` no es un
|
|
67
|
+
* selector válido y `matches()`/`closest()` lanzarían; con @oddbird/popover-polyfill la capa lleva la clase `:popover-open`.
|
|
68
|
+
*/
|
|
69
|
+
function inOpenLayer(el, within = true) {
|
|
70
|
+
try {
|
|
71
|
+
return within ? el.closest(":popover-open") !== null : el.matches(":popover-open");
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return within ? el.closest(".\\:popover-open") !== null : el.classList.contains(":popover-open");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
27
77
|
// Iconos que este módulo dibuja por su cuenta cuando el marcado no usa <z-icon>.
|
|
28
|
-
registerIcons([xMark, chevronDownSmall, chevronRightSmall]);
|
|
78
|
+
registerIcons([xMark, chevronDownSmall, chevronRightSmall, chevronDoubleLeft, chevronDoubleRight]);
|
|
29
79
|
const isBrowser = typeof document !== "undefined";
|
|
30
80
|
const inDom = (el) => el.closest("[data-z-dom]") !== null;
|
|
31
81
|
function emit(el, name, detail) {
|
|
@@ -99,6 +149,20 @@ function syncShell(shell) {
|
|
|
99
149
|
// Con un cajón abierto, el panel que siga acoplado queda bajo el velo.
|
|
100
150
|
el.inert = drawerOpen && mode === "docked";
|
|
101
151
|
}
|
|
152
|
+
// Estrecho: el rail no ocupa columna; con el cajón de la sidebar abierto entra en él (y vuelve al cuerpo al cerrarse).
|
|
153
|
+
const rail = shell.querySelector(":scope > .z-shell__body > .z-shell__rail, :scope > .z-shell__body > .z-shell__side > .z-shell__rail");
|
|
154
|
+
const side = panels[0]?.el;
|
|
155
|
+
if (rail) {
|
|
156
|
+
const toDrawer = Boolean(side) && railInDrawer(state.width, num(shell.getAttribute("data-rail-breakpoint"), RAIL_BREAKPOINT), auto.sidebar);
|
|
157
|
+
const inDrawer = toDrawer && side && panels[0]?.mode === "overlay";
|
|
158
|
+
if (inDrawer && rail.parentElement !== side)
|
|
159
|
+
side.prepend(rail);
|
|
160
|
+
else if (!inDrawer && rail.parentElement !== body)
|
|
161
|
+
body.prepend(rail);
|
|
162
|
+
rail.hidden = toDrawer && !inDrawer;
|
|
163
|
+
if (inDrawer)
|
|
164
|
+
rail.inert = false;
|
|
165
|
+
}
|
|
102
166
|
for (const zone of body.querySelectorAll(":scope > .z-shell__rail, :scope > .z-shell__main"))
|
|
103
167
|
zone.inert = drawerOpen;
|
|
104
168
|
let scrim = body.querySelector(":scope > .z-shell__scrim");
|
|
@@ -339,7 +403,7 @@ function reveal(strip) {
|
|
|
339
403
|
const tab = activeTab(strip)?.parentElement;
|
|
340
404
|
if (!list || !tab)
|
|
341
405
|
return;
|
|
342
|
-
const offset = revealOffset(tab.getBoundingClientRect(), list.getBoundingClientRect());
|
|
406
|
+
const offset = revealOffset(tab.getBoundingClientRect(), list.getBoundingClientRect(), edgeMargin(list));
|
|
343
407
|
if (offset)
|
|
344
408
|
list.scrollLeft += offset;
|
|
345
409
|
}
|
|
@@ -443,6 +507,121 @@ export function addWorkTab(strip, { id, title, icon, closable = true, closeLabel
|
|
|
443
507
|
selectWorkTab(strip, id);
|
|
444
508
|
return button;
|
|
445
509
|
}
|
|
510
|
+
const shownSelects = (strip) => selects(strip).filter((s) => !s.parentElement?.hidden);
|
|
511
|
+
/** Deja el chip de cada grupo delante de la primera pestaña del grupo (tras mover pestañas). */
|
|
512
|
+
function placeChips(strip) {
|
|
513
|
+
for (const chip of strip.querySelectorAll(".z-tabstrip__group")) {
|
|
514
|
+
const id = chip.dataset.groupId;
|
|
515
|
+
const first = id ? strip.querySelector(`.z-tabstrip__tab[data-group="${CSS.escape(id)}"]`) : null;
|
|
516
|
+
if (first && first.previousElementSibling !== chip)
|
|
517
|
+
first.before(chip);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Mueve la pestaña `id` delante de la pestaña `before` (al final con null). Emite `z:reorder` { ids } (cancelable) y
|
|
522
|
+
* devuelve si la movió.
|
|
523
|
+
*/
|
|
524
|
+
export function moveWorkTab(strip, id, before) {
|
|
525
|
+
const tab = findTab(strip, id)?.parentElement;
|
|
526
|
+
if (!tab)
|
|
527
|
+
return false;
|
|
528
|
+
const ref = before === null ? null : findTab(strip, before)?.parentElement;
|
|
529
|
+
const ids = selects(strip).map((s) => s.dataset.tabId ?? "");
|
|
530
|
+
const rest = ids.filter((x) => x !== id);
|
|
531
|
+
const at = before === null ? rest.length : rest.indexOf(before);
|
|
532
|
+
rest.splice(at < 0 ? rest.length : at, 0, id);
|
|
533
|
+
if (rest.join("\u0000") === ids.join("\u0000") || !emit(strip, "reorder", { ids: rest }))
|
|
534
|
+
return false;
|
|
535
|
+
const hadFocus = tab.contains(document.activeElement);
|
|
536
|
+
if (ref)
|
|
537
|
+
ref.before(tab);
|
|
538
|
+
else
|
|
539
|
+
selects(strip).at(-1)?.parentElement?.after(tab);
|
|
540
|
+
placeChips(strip);
|
|
541
|
+
if (hadFocus)
|
|
542
|
+
findTab(strip, id)?.focus();
|
|
543
|
+
return true;
|
|
544
|
+
}
|
|
545
|
+
/** Pliega o despliega un grupo de pestañas: sus pestañas se ocultan, salvo la activa. Emite `z:grouptoggle`. */
|
|
546
|
+
export function setTabGroupCollapsed(strip, group, collapsed) {
|
|
547
|
+
for (const tab of strip.querySelectorAll(`.z-tabstrip__tab[data-group="${CSS.escape(group)}"]`))
|
|
548
|
+
tab.hidden = collapsed && !tab.hasAttribute("data-selected");
|
|
549
|
+
strip
|
|
550
|
+
.querySelector(`.z-tabstrip__group[data-group-id="${CSS.escape(group)}"] .z-tabstrip__chip`)
|
|
551
|
+
?.setAttribute("aria-expanded", String(!collapsed));
|
|
552
|
+
emit(strip, "grouptoggle", { id: group, collapsed });
|
|
553
|
+
}
|
|
554
|
+
function announceMove(strip, id) {
|
|
555
|
+
const status = strip.querySelector(".z-tabstrip__status");
|
|
556
|
+
const shown = shownSelects(strip);
|
|
557
|
+
const select = findTab(strip, id);
|
|
558
|
+
if (!status || !select)
|
|
559
|
+
return;
|
|
560
|
+
const template = status.dataset.movedLabel ?? "{title} moved to position {position} of {total}";
|
|
561
|
+
status.textContent = template
|
|
562
|
+
.replace("{title}", select.querySelector(".z-tabstrip__title")?.textContent ?? id)
|
|
563
|
+
.replace("{position}", String(shown.indexOf(select) + 1))
|
|
564
|
+
.replace("{total}", String(shown.length));
|
|
565
|
+
}
|
|
566
|
+
// Arrastre de una pestaña: la marca de soltar va en el canto de la vecina; el orden cambia al soltar.
|
|
567
|
+
// Los tramos de las pestañas se miden al empezar: durante el arrastre nada cambia de sitio salvo la propia pestaña.
|
|
568
|
+
let tabDrag = null;
|
|
569
|
+
let swallowTabClick = false;
|
|
570
|
+
function tabDragMove(event) {
|
|
571
|
+
const d = tabDrag;
|
|
572
|
+
if (!d || event.pointerId !== d.pointerId)
|
|
573
|
+
return;
|
|
574
|
+
const dx = event.clientX - d.x;
|
|
575
|
+
if (!d.active) {
|
|
576
|
+
if (Math.abs(dx) < 4)
|
|
577
|
+
return;
|
|
578
|
+
d.active = true;
|
|
579
|
+
d.spans = shownSelects(d.strip).map((s) => {
|
|
580
|
+
const r = s.parentElement.getBoundingClientRect();
|
|
581
|
+
return { start: r.left, end: r.right };
|
|
582
|
+
});
|
|
583
|
+
d.select.parentElement.dataset.dragging = "";
|
|
584
|
+
try {
|
|
585
|
+
d.select.setPointerCapture(event.pointerId);
|
|
586
|
+
}
|
|
587
|
+
catch {
|
|
588
|
+
/* puntero ya liberado */
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
d.select.parentElement.style.setProperty("--z-tab-drag", `${dx}px`);
|
|
592
|
+
const shown = shownSelects(d.strip);
|
|
593
|
+
d.gap = dropIndex(event.clientX, d.spans, isRtl(d.strip));
|
|
594
|
+
const from = shown.indexOf(d.select);
|
|
595
|
+
for (const tab of d.strip.querySelectorAll(".z-tabstrip__tab[data-drop]"))
|
|
596
|
+
delete tab.dataset.drop;
|
|
597
|
+
if (d.gap === from || d.gap === from + 1)
|
|
598
|
+
return;
|
|
599
|
+
const target = shown[d.gap] ?? shown[shown.length - 1];
|
|
600
|
+
if (target?.parentElement)
|
|
601
|
+
target.parentElement.dataset.drop = d.gap < shown.length ? "before" : "after";
|
|
602
|
+
}
|
|
603
|
+
function tabDragEnd(event, cancelled) {
|
|
604
|
+
const d = tabDrag;
|
|
605
|
+
if (!d || event.pointerId !== d.pointerId)
|
|
606
|
+
return;
|
|
607
|
+
tabDrag = null;
|
|
608
|
+
const tab = d.select.parentElement;
|
|
609
|
+
tab.style.removeProperty("--z-tab-drag");
|
|
610
|
+
delete tab.dataset.dragging;
|
|
611
|
+
for (const t of d.strip.querySelectorAll(".z-tabstrip__tab[data-drop]"))
|
|
612
|
+
delete t.dataset.drop;
|
|
613
|
+
if (!d.active)
|
|
614
|
+
return;
|
|
615
|
+
swallowTabClick = true;
|
|
616
|
+
setTimeout(() => {
|
|
617
|
+
swallowTabClick = false;
|
|
618
|
+
});
|
|
619
|
+
if (cancelled || d.gap < 0)
|
|
620
|
+
return;
|
|
621
|
+
const shown = shownSelects(d.strip).map((s) => s.dataset.tabId ?? "");
|
|
622
|
+
const id = d.select.dataset.tabId ?? "";
|
|
623
|
+
moveWorkTab(d.strip, id, beforeFor(shown, id, finalIndex(shown.indexOf(id), d.gap)));
|
|
624
|
+
}
|
|
446
625
|
let created = 0;
|
|
447
626
|
/** 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
627
|
function addRequested(strip, button) {
|
|
@@ -457,7 +636,14 @@ function addRequested(strip, button) {
|
|
|
457
636
|
}
|
|
458
637
|
let stripObserver;
|
|
459
638
|
const observedLists = new WeakSet();
|
|
639
|
+
const edgeLists = new WeakSet();
|
|
460
640
|
function hydrateStrip(strip) {
|
|
641
|
+
// Borde difuminado del lado con pestañas ocultas (data-scroll-edges; la hoja pone la máscara).
|
|
642
|
+
const tabList = strip.querySelector(".z-tabstrip__list");
|
|
643
|
+
if (tabList && !edgeLists.has(tabList)) {
|
|
644
|
+
edgeLists.add(tabList);
|
|
645
|
+
trackScrollEdges(tabList);
|
|
646
|
+
}
|
|
461
647
|
const active = activeTab(strip) ?? selects(strip)[0];
|
|
462
648
|
if (active?.dataset.tabId !== undefined)
|
|
463
649
|
applyTab(strip, active.dataset.tabId);
|
|
@@ -478,6 +664,9 @@ function hydrateStrip(strip) {
|
|
|
478
664
|
}
|
|
479
665
|
});
|
|
480
666
|
stripObserver.observe(list);
|
|
667
|
+
// El ancho de una pestaña cambia (carga de la fuente, título nuevo) sin que cambie el de la tira.
|
|
668
|
+
for (const tab of list.children)
|
|
669
|
+
stripObserver.observe(tab);
|
|
481
670
|
observedLists.add(list);
|
|
482
671
|
}
|
|
483
672
|
/* ---------- Sidebar en acordeón ---------- */
|
|
@@ -503,6 +692,299 @@ export function setSectionOpen(section, open) {
|
|
|
503
692
|
else
|
|
504
693
|
icon.replaceWith(iconElement(name, { size: icon.getAttribute("width") ?? 12 }));
|
|
505
694
|
}
|
|
695
|
+
/* ---------- Sidebar plegable a iconos ---------- */
|
|
696
|
+
const subOf = (link) => {
|
|
697
|
+
const id = link.getAttribute("aria-controls");
|
|
698
|
+
return id ? document.getElementById(id) : null;
|
|
699
|
+
};
|
|
700
|
+
const topLinks = (sidebar) => [...sidebar.querySelectorAll(".z-sidebar__link")].filter((link) => !link.closest(".z-sidebar__sub"));
|
|
701
|
+
/** Abre o pliega el submenú de un item de sidebar (`.z-sidebar__link[aria-controls]`), desplegada la sidebar. */
|
|
702
|
+
export function setSidebarItemOpen(link, open) {
|
|
703
|
+
const sub = subOf(link);
|
|
704
|
+
if (!sub || sub.hasAttribute("popover"))
|
|
705
|
+
return;
|
|
706
|
+
link.setAttribute("aria-expanded", String(open));
|
|
707
|
+
sub.hidden = !open;
|
|
708
|
+
const item = link.closest(".z-sidebar__item");
|
|
709
|
+
if (item) {
|
|
710
|
+
if (open)
|
|
711
|
+
item.dataset.open = "true";
|
|
712
|
+
else
|
|
713
|
+
delete item.dataset.open;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Pliega la sidebar a iconos o la despliega. Plegada, cada item muestra su nombre en un tooltip y un submenú pasa a
|
|
718
|
+
* ser un popover anclado al item; desplegada, vuelve a abrirse en su sitio. Emite `z:change` { collapsed }.
|
|
719
|
+
*/
|
|
720
|
+
export function setSidebarCollapsed(sidebar, collapsed, silent = false) {
|
|
721
|
+
if (collapsed)
|
|
722
|
+
sidebar.dataset.collapsed = "true";
|
|
723
|
+
else
|
|
724
|
+
delete sidebar.dataset.collapsed;
|
|
725
|
+
for (const link of topLinks(sidebar)) {
|
|
726
|
+
const sub = subOf(link);
|
|
727
|
+
const label = link.querySelector(".z-sidebar__label")?.textContent ?? "";
|
|
728
|
+
if (!sub) {
|
|
729
|
+
if (collapsed)
|
|
730
|
+
link.setAttribute("data-z-tooltip", label);
|
|
731
|
+
else
|
|
732
|
+
link.removeAttribute("data-z-tooltip");
|
|
733
|
+
continue;
|
|
734
|
+
}
|
|
735
|
+
if (collapsed) {
|
|
736
|
+
if (!sub.hasAttribute("popover"))
|
|
737
|
+
sub.dataset.wasOpen = String(!sub.hidden);
|
|
738
|
+
sub.hidden = false;
|
|
739
|
+
sub.setAttribute("popover", "auto");
|
|
740
|
+
sub.classList.add("z-liquid");
|
|
741
|
+
link.setAttribute("data-z-open", `#${sub.id}`);
|
|
742
|
+
link.setAttribute("data-z-placement", "right-start");
|
|
743
|
+
link.setAttribute("aria-haspopup", "true");
|
|
744
|
+
link.setAttribute("aria-expanded", "false");
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
if (inOpenLayer(sub, false))
|
|
748
|
+
sub.hidePopover();
|
|
749
|
+
sub.removeAttribute("popover");
|
|
750
|
+
sub.classList.remove("z-liquid");
|
|
751
|
+
sub.removeAttribute("style");
|
|
752
|
+
link.removeAttribute("data-z-open");
|
|
753
|
+
link.removeAttribute("data-z-placement");
|
|
754
|
+
link.removeAttribute("aria-haspopup");
|
|
755
|
+
sub.hidden = false;
|
|
756
|
+
setSidebarItemOpen(link, sub.dataset.wasOpen === "true");
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
for (const trigger of document.querySelectorAll(".z-sidebar__trigger")) {
|
|
760
|
+
if (sidebar.id && trigger.getAttribute("aria-controls") === sidebar.id) {
|
|
761
|
+
trigger.setAttribute("aria-expanded", String(!collapsed));
|
|
762
|
+
if (collapsed)
|
|
763
|
+
trigger.dataset.collapsed = "true";
|
|
764
|
+
else
|
|
765
|
+
delete trigger.dataset.collapsed;
|
|
766
|
+
const name = collapsed ? "chevron-double-right" : "chevron-double-left";
|
|
767
|
+
const icon = trigger.querySelector(":scope > z-icon, :scope > svg.z-icon");
|
|
768
|
+
if (icon?.localName === "z-icon")
|
|
769
|
+
icon.setAttribute("name", name);
|
|
770
|
+
else
|
|
771
|
+
icon?.replaceWith(iconElement(name, { size: 16 }));
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
if (!silent)
|
|
775
|
+
emit(sidebar, "change", { collapsed });
|
|
776
|
+
}
|
|
777
|
+
/* ---------- Panel flotante ---------- */
|
|
778
|
+
const panelRect = (panel) => ({
|
|
779
|
+
x: panel.offsetLeft,
|
|
780
|
+
y: panel.offsetTop,
|
|
781
|
+
width: panel.offsetWidth,
|
|
782
|
+
height: panel.offsetHeight,
|
|
783
|
+
});
|
|
784
|
+
const panelBounds = (panel) => {
|
|
785
|
+
const parent = panel.dataset.strategy === "absolute" ? panel.offsetParent : null;
|
|
786
|
+
return parent
|
|
787
|
+
? { width: parent.clientWidth, height: parent.clientHeight }
|
|
788
|
+
: { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight };
|
|
789
|
+
};
|
|
790
|
+
const panelMin = (panel) => ({ width: num(panel.dataset.minWidth, 200), height: num(panel.dataset.minHeight, 120) });
|
|
791
|
+
// Botón que abrió cada panel: recibe el foco al cerrarlo.
|
|
792
|
+
const panelOpeners = new WeakMap();
|
|
793
|
+
/** Coloca y dimensiona un panel flotante (acotado a su área). Emite `z:change` con el rectángulo final. */
|
|
794
|
+
export function setFloatingPanelRect(panel, rect, silent = false) {
|
|
795
|
+
const next = clampRect(rect, panelBounds(panel), panelMin(panel));
|
|
796
|
+
panel.style.left = `${next.x}px`;
|
|
797
|
+
panel.style.top = `${next.y}px`;
|
|
798
|
+
panel.style.width = `${next.width}px`;
|
|
799
|
+
panel.style.height = `${next.height}px`;
|
|
800
|
+
if (!silent)
|
|
801
|
+
emit(panel, "change", next);
|
|
802
|
+
return next;
|
|
803
|
+
}
|
|
804
|
+
function resizePanel(panel, start, dw, dh) {
|
|
805
|
+
const next = resizeRect(start, dw, dh, panelBounds(panel), panelMin(panel), isRtl(panel));
|
|
806
|
+
setFloatingPanelRect(panel, next);
|
|
807
|
+
}
|
|
808
|
+
/** Muestra un panel flotante y le lleva el foco. `opener` lo recibe de vuelta al cerrarlo. */
|
|
809
|
+
export function openFloatingPanel(panel, opener) {
|
|
810
|
+
panel.hidden = false;
|
|
811
|
+
if (opener)
|
|
812
|
+
panelOpeners.set(panel, opener);
|
|
813
|
+
setFloatingPanelRect(panel, panelRect(panel), true);
|
|
814
|
+
panel.focus({ preventScroll: true });
|
|
815
|
+
emit(panel, "open");
|
|
816
|
+
}
|
|
817
|
+
/** Oculta un panel flotante (emite `z:close`, cancelable). El foco vuelve a quien lo abrió. */
|
|
818
|
+
export function closeFloatingPanel(panel) {
|
|
819
|
+
if (!emit(panel, "close"))
|
|
820
|
+
return;
|
|
821
|
+
const hadFocus = panel.contains(document.activeElement);
|
|
822
|
+
panel.hidden = true;
|
|
823
|
+
if (hadFocus)
|
|
824
|
+
panelOpeners.get(panel)?.focus({ preventScroll: true });
|
|
825
|
+
}
|
|
826
|
+
/* ---------- Mosaico de paneles ---------- */
|
|
827
|
+
const paneSections = (layout) => [...layout.querySelectorAll(".z-panelayout__pane[data-pane-id]")];
|
|
828
|
+
function readNode(el) {
|
|
829
|
+
if (el.classList.contains("z-panelayout__pane"))
|
|
830
|
+
return { type: "pane", id: el.dataset.paneId ?? "" };
|
|
831
|
+
if (!el.classList.contains("z-split"))
|
|
832
|
+
return null;
|
|
833
|
+
const cells = parts(el, "z-split__pane");
|
|
834
|
+
const children = cells.map((cell) => (cell.firstElementChild ? readNode(cell.firstElementChild) : null)).filter(Boolean);
|
|
835
|
+
return { type: "split", direction: directionOf(el), sizes: getSplitSizes(el), children };
|
|
836
|
+
}
|
|
837
|
+
/** Árbol del mosaico leído del marcado. */
|
|
838
|
+
export function getPaneLayout(layout) {
|
|
839
|
+
const top = [...layout.children].find((c) => c.classList.contains("z-split") || c.classList.contains("z-panelayout__pane"));
|
|
840
|
+
return top ? readNode(top) : null;
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Rehace el marcado del mosaico con el árbol `tree`, moviendo los paneles existentes (conservan su contenido y su
|
|
844
|
+
* estado). Un panel nuevo debe estar ya en el mosaico o pasarse en `extra`. Emite `z:layout` { layout }.
|
|
845
|
+
*/
|
|
846
|
+
export function setPaneLayout(layout, tree, extra = []) {
|
|
847
|
+
const byId = new Map([...paneSections(layout), ...extra].map((el) => [el.dataset.paneId ?? "", el]));
|
|
848
|
+
const label = layout.dataset.dividerLabel ?? "Resize panes";
|
|
849
|
+
let count = 0;
|
|
850
|
+
const build = (node) => {
|
|
851
|
+
if (node.type === "pane")
|
|
852
|
+
return byId.get(node.id) ?? null;
|
|
853
|
+
const split = document.createElement("div");
|
|
854
|
+
split.className = "z-split";
|
|
855
|
+
split.dataset.direction = node.direction;
|
|
856
|
+
node.children.forEach((child, i) => {
|
|
857
|
+
const built = build(child);
|
|
858
|
+
if (!built)
|
|
859
|
+
return;
|
|
860
|
+
if (i > 0) {
|
|
861
|
+
const divider = document.createElement("div");
|
|
862
|
+
divider.className = "z-split__divider";
|
|
863
|
+
divider.setAttribute("aria-label", label);
|
|
864
|
+
split.append(divider);
|
|
865
|
+
}
|
|
866
|
+
const cell = document.createElement("div");
|
|
867
|
+
cell.className = "z-split__pane";
|
|
868
|
+
cell.id = `${layout.id || "panelayout"}-cell-${++count}`;
|
|
869
|
+
cell.append(built);
|
|
870
|
+
split.append(cell);
|
|
871
|
+
});
|
|
872
|
+
setSplitSizes(split, node.sizes);
|
|
873
|
+
return split;
|
|
874
|
+
};
|
|
875
|
+
const top = build(tree);
|
|
876
|
+
const status = layout.querySelector(":scope > .z-panelayout__status");
|
|
877
|
+
layout.replaceChildren(...(top ? [top] : []), ...(status ? [status] : []));
|
|
878
|
+
for (const split of layout.querySelectorAll(".z-split"))
|
|
879
|
+
hydrateSplit(split);
|
|
880
|
+
syncPaneFocus(layout);
|
|
881
|
+
emit(layout, "layout", { layout: tree });
|
|
882
|
+
}
|
|
883
|
+
/** Divide el panel `id` y pone `pane` (un `.z-panelayout__pane[data-pane-id]` nuevo) a su lado. */
|
|
884
|
+
export function splitLayoutPane(layout, id, pane, direction) {
|
|
885
|
+
const tree = getPaneLayout(layout);
|
|
886
|
+
if (!tree || !pane.dataset.paneId)
|
|
887
|
+
return;
|
|
888
|
+
setPaneLayout(layout, splitPane(tree, id, pane.dataset.paneId, direction), [pane]);
|
|
889
|
+
}
|
|
890
|
+
/** Marca el panel con el foco (el pulsado o enfocado) y atenúa el resto. */
|
|
891
|
+
function syncPaneFocus(layout, focused) {
|
|
892
|
+
const sections = paneSections(layout);
|
|
893
|
+
const current = focused ?? layout.dataset.focused ?? sections[0]?.dataset.paneId;
|
|
894
|
+
if (current)
|
|
895
|
+
layout.dataset.focused = current;
|
|
896
|
+
for (const section of sections) {
|
|
897
|
+
const on = String(section.dataset.paneId === current);
|
|
898
|
+
if (sections.length < 2) {
|
|
899
|
+
section.querySelector(".z-pane")?.removeAttribute("data-focused");
|
|
900
|
+
section.querySelector(".z-paneheader")?.removeAttribute("data-focused");
|
|
901
|
+
continue;
|
|
902
|
+
}
|
|
903
|
+
section.querySelector(".z-pane")?.setAttribute("data-focused", on);
|
|
904
|
+
section.querySelector(".z-paneheader")?.setAttribute("data-focused", on);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
function announcePane(layout, id) {
|
|
908
|
+
const status = layout.querySelector(":scope > .z-panelayout__status");
|
|
909
|
+
const title = layout.querySelector(`[data-pane-id="${CSS.escape(id)}"] .z-paneheader__title`)?.textContent ?? id;
|
|
910
|
+
if (status)
|
|
911
|
+
status.textContent = (status.dataset.movedLabel ?? "{title} moved").replace("{title}", title);
|
|
912
|
+
}
|
|
913
|
+
function paneAction(item) {
|
|
914
|
+
const action = item.dataset.paneAction ?? "";
|
|
915
|
+
const section = document.querySelector(`[data-pane-id="${CSS.escape(item.dataset.paneFor ?? "")}"]`);
|
|
916
|
+
const layout = section?.closest(".z-panelayout");
|
|
917
|
+
const id = section?.dataset.paneId;
|
|
918
|
+
const tree = layout ? getPaneLayout(layout) : null;
|
|
919
|
+
if (!layout || !id || !tree)
|
|
920
|
+
return;
|
|
921
|
+
if (action === "close") {
|
|
922
|
+
const next = removePane(tree, id);
|
|
923
|
+
if (next && emit(layout, "close", { id }))
|
|
924
|
+
setPaneLayout(layout, next);
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
if (action === "split-right" || action === "split-down") {
|
|
928
|
+
emit(layout, "split", { id, direction: action === "split-right" ? "row" : "column" });
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
const direction = { "move-left": "left", "move-right": "right", "move-up": "up", "move-down": "down" }[action];
|
|
932
|
+
if (!direction)
|
|
933
|
+
return;
|
|
934
|
+
const rects = paneSections(layout).map((el) => ({ id: el.dataset.paneId ?? "", rect: el.getBoundingClientRect() }));
|
|
935
|
+
const other = neighborPane(rects, id, direction);
|
|
936
|
+
if (!other)
|
|
937
|
+
return;
|
|
938
|
+
setPaneLayout(layout, movePane(tree, id, other, "center"));
|
|
939
|
+
announcePane(layout, id);
|
|
940
|
+
// El foco vuelve al menú del panel movido (zui/dom lo devuelve a su disparador, que sigue siendo el mismo botón).
|
|
941
|
+
}
|
|
942
|
+
// Arrastre de un panel por su cabecera.
|
|
943
|
+
let paneDrag = null;
|
|
944
|
+
function paneDragMove(event) {
|
|
945
|
+
const d = paneDrag;
|
|
946
|
+
if (!d || event.pointerId !== d.pointerId)
|
|
947
|
+
return;
|
|
948
|
+
if (!d.active) {
|
|
949
|
+
if (Math.hypot(event.clientX - d.x, event.clientY - d.y) < 6)
|
|
950
|
+
return;
|
|
951
|
+
d.active = true;
|
|
952
|
+
d.layout.dataset.dragging = "";
|
|
953
|
+
d.layout.querySelector(`[data-pane-id="${CSS.escape(d.id)}"]`)?.setAttribute("data-dragging", "");
|
|
954
|
+
}
|
|
955
|
+
d.layout.querySelector(".z-panelayout__drop")?.remove();
|
|
956
|
+
d.drop = null;
|
|
957
|
+
const hit = paneSections(d.layout).find((el) => {
|
|
958
|
+
const r = el.getBoundingClientRect();
|
|
959
|
+
return event.clientX >= r.left && event.clientX <= r.right && event.clientY >= r.top && event.clientY <= r.bottom;
|
|
960
|
+
});
|
|
961
|
+
if (!hit || hit.dataset.paneId === d.id)
|
|
962
|
+
return;
|
|
963
|
+
const edge = paneDropEdge(hit.getBoundingClientRect(), { x: event.clientX, y: event.clientY }, isRtl(d.layout));
|
|
964
|
+
d.drop = { target: hit.dataset.paneId ?? "", edge };
|
|
965
|
+
const overlay = document.createElement("div");
|
|
966
|
+
overlay.className = "z-panelayout__drop";
|
|
967
|
+
overlay.dataset.edge = edge;
|
|
968
|
+
overlay.setAttribute("aria-hidden", "true");
|
|
969
|
+
hit.append(overlay);
|
|
970
|
+
}
|
|
971
|
+
function paneDragEnd(event, cancelled) {
|
|
972
|
+
const d = paneDrag;
|
|
973
|
+
if (!d || event.pointerId !== d.pointerId)
|
|
974
|
+
return;
|
|
975
|
+
paneDrag = null;
|
|
976
|
+
d.layout.querySelector(".z-panelayout__drop")?.remove();
|
|
977
|
+
delete d.layout.dataset.dragging;
|
|
978
|
+
d.layout.querySelector(`[data-pane-id="${CSS.escape(d.id)}"]`)?.removeAttribute("data-dragging");
|
|
979
|
+
const tree = getPaneLayout(d.layout);
|
|
980
|
+
if (!d.active || cancelled || !d.drop || !tree)
|
|
981
|
+
return;
|
|
982
|
+
const next = movePane(tree, d.id, d.drop.target, d.drop.edge);
|
|
983
|
+
if (next === tree)
|
|
984
|
+
return;
|
|
985
|
+
setPaneLayout(d.layout, next);
|
|
986
|
+
announcePane(d.layout, d.id);
|
|
987
|
+
}
|
|
506
988
|
/* ---------- Delegación de eventos ---------- */
|
|
507
989
|
function onClick(event) {
|
|
508
990
|
const target = event.target;
|
|
@@ -537,6 +1019,14 @@ function onClick(event) {
|
|
|
537
1019
|
}
|
|
538
1020
|
const strip = target.closest(".z-tabstrip");
|
|
539
1021
|
if (strip) {
|
|
1022
|
+
const chip = target.closest(".z-tabstrip__chip");
|
|
1023
|
+
const groupId = chip?.closest(".z-tabstrip__group")?.dataset.groupId;
|
|
1024
|
+
if (chip && groupId) {
|
|
1025
|
+
setTabGroupCollapsed(strip, groupId, chip.getAttribute("aria-expanded") !== "false");
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
if (swallowTabClick)
|
|
1029
|
+
return;
|
|
540
1030
|
const id = target.closest(".z-tabstrip__tab")?.querySelector(".z-tabstrip__select")?.dataset.tabId;
|
|
541
1031
|
if (id !== undefined && target.closest(".z-tabstrip__close"))
|
|
542
1032
|
closeWorkTab(strip, id);
|
|
@@ -546,6 +1036,38 @@ function onClick(event) {
|
|
|
546
1036
|
addRequested(strip, target.closest(".z-tabstrip__add"));
|
|
547
1037
|
return;
|
|
548
1038
|
}
|
|
1039
|
+
const panelOpener = target.closest("[data-z-panel]");
|
|
1040
|
+
if (panelOpener) {
|
|
1041
|
+
const panel = document.getElementById((panelOpener.getAttribute("data-z-panel") ?? "").replace(/^#/, ""));
|
|
1042
|
+
if (panel?.classList.contains("z-floatpanel")) {
|
|
1043
|
+
if (panel.hidden)
|
|
1044
|
+
openFloatingPanel(panel, panelOpener);
|
|
1045
|
+
else
|
|
1046
|
+
closeFloatingPanel(panel);
|
|
1047
|
+
}
|
|
1048
|
+
return;
|
|
1049
|
+
}
|
|
1050
|
+
const panelClose = target.closest(".z-floatpanel__close");
|
|
1051
|
+
if (panelClose) {
|
|
1052
|
+
const panel = panelClose.closest(".z-floatpanel");
|
|
1053
|
+
if (panel)
|
|
1054
|
+
closeFloatingPanel(panel);
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
const trigger = target.closest(".z-sidebar__trigger");
|
|
1058
|
+
if (trigger) {
|
|
1059
|
+
const sidebar = document.getElementById(trigger.getAttribute("aria-controls") ?? "");
|
|
1060
|
+
if (sidebar?.classList.contains("z-sidebar"))
|
|
1061
|
+
setSidebarCollapsed(sidebar, !sidebar.hasAttribute("data-collapsed"));
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
const sidebarLink = target.closest(".z-sidebar__link[aria-controls]");
|
|
1065
|
+
if (sidebarLink && !sidebarLink.hasAttribute("data-z-open") && !sidebarLink.disabled) {
|
|
1066
|
+
const open = sidebarLink.getAttribute("aria-expanded") !== "true";
|
|
1067
|
+
setSidebarItemOpen(sidebarLink, open);
|
|
1068
|
+
emit(sidebarLink.closest(".z-sidebar__item") ?? sidebarLink, "change", { open });
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
549
1071
|
const fold = target.closest(".z-sidebar__fold");
|
|
550
1072
|
const section = fold?.closest(".z-sidebar__section");
|
|
551
1073
|
if (section) {
|
|
@@ -560,8 +1082,14 @@ function onKeydown(event) {
|
|
|
560
1082
|
return;
|
|
561
1083
|
// Escape cierra el cajón abierto, salvo que lo haya gestionado otro (un diálogo o un menú por encima).
|
|
562
1084
|
if (event.key === "Escape") {
|
|
563
|
-
if (event.defaultPrevented || target.closest("dialog[open]
|
|
1085
|
+
if (event.defaultPrevented || target.closest("dialog[open]") || inOpenLayer(target))
|
|
1086
|
+
return;
|
|
1087
|
+
const panel = target.closest(".z-floatpanel");
|
|
1088
|
+
if (panel && inDom(panel) && panel.querySelector(".z-floatpanel__close")) {
|
|
1089
|
+
event.preventDefault();
|
|
1090
|
+
closeFloatingPanel(panel);
|
|
564
1091
|
return;
|
|
1092
|
+
}
|
|
565
1093
|
for (const drawer of document.querySelectorAll(".z-shell__drawer")) {
|
|
566
1094
|
const shell = drawer.closest(".z-shell");
|
|
567
1095
|
if (shell && shells.has(shell))
|
|
@@ -569,8 +1097,37 @@ function onKeydown(event) {
|
|
|
569
1097
|
}
|
|
570
1098
|
return;
|
|
571
1099
|
}
|
|
1100
|
+
if (event.key.toLowerCase?.() === "b" && !event.altKey && !event.shiftKey && (event.ctrlKey || event.metaKey)) {
|
|
1101
|
+
const trigger = document.querySelector("[data-z-dom] .z-sidebar__trigger[data-shortcut]");
|
|
1102
|
+
if (trigger) {
|
|
1103
|
+
event.preventDefault();
|
|
1104
|
+
trigger.click();
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
572
1108
|
if (!inDom(target))
|
|
573
1109
|
return;
|
|
1110
|
+
const floatKey = target.closest(".z-floatpanel__handle, .z-floatpanel__resize");
|
|
1111
|
+
const floating = floatKey?.closest(".z-floatpanel");
|
|
1112
|
+
if (floatKey && floating) {
|
|
1113
|
+
const step = event.shiftKey ? FLOAT_STEP * 10 : FLOAT_STEP;
|
|
1114
|
+
const start = panelRect(floating);
|
|
1115
|
+
if (floatKey.classList.contains("z-floatpanel__handle")) {
|
|
1116
|
+
const d = moveDelta(event.key, step);
|
|
1117
|
+
if (!d)
|
|
1118
|
+
return;
|
|
1119
|
+
event.preventDefault();
|
|
1120
|
+
setFloatingPanelRect(floating, { ...start, x: start.x + d.dx, y: start.y + d.dy });
|
|
1121
|
+
}
|
|
1122
|
+
else {
|
|
1123
|
+
const d = resizeDelta(event.key, step);
|
|
1124
|
+
if (!d)
|
|
1125
|
+
return;
|
|
1126
|
+
event.preventDefault();
|
|
1127
|
+
resizePanel(floating, start, d.dw, d.dh);
|
|
1128
|
+
}
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
574
1131
|
const handle = target.closest(".z-resize");
|
|
575
1132
|
if (handle) {
|
|
576
1133
|
const options = resizeOptions(handle);
|
|
@@ -596,7 +1153,6 @@ function onKeydown(event) {
|
|
|
596
1153
|
const list = target.closest(".z-tabstrip__list");
|
|
597
1154
|
const strip = list?.closest(".z-tabstrip");
|
|
598
1155
|
if (list && strip) {
|
|
599
|
-
const tabs = selects(strip);
|
|
600
1156
|
const current = activeTab(strip);
|
|
601
1157
|
// Supr cierra la pestaña activa si tiene cierre (misma vía de teclado que el binding de React).
|
|
602
1158
|
if (event.key === "Delete" && current?.parentElement?.querySelector(".z-tabstrip__close")) {
|
|
@@ -605,7 +1161,19 @@ function onKeydown(event) {
|
|
|
605
1161
|
activeTab(strip)?.focus();
|
|
606
1162
|
return;
|
|
607
1163
|
}
|
|
608
|
-
const
|
|
1164
|
+
const shown = shownSelects(strip);
|
|
1165
|
+
if (current && strip.hasAttribute("data-reorderable") && event.ctrlKey && event.shiftKey && !event.altKey) {
|
|
1166
|
+
const to = tabMoveIndex(event.key, shown.indexOf(current), shown.length, isRtl(list));
|
|
1167
|
+
if (to < 0)
|
|
1168
|
+
return;
|
|
1169
|
+
event.preventDefault();
|
|
1170
|
+
const ids = shown.map((x) => x.dataset.tabId ?? "");
|
|
1171
|
+
const id = current.dataset.tabId ?? "";
|
|
1172
|
+
if (moveWorkTab(strip, id, beforeFor(ids, id, to)))
|
|
1173
|
+
announceMove(strip, id);
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
const next = shown[tabKeyIndex(event.key, shown.indexOf(activeTab(strip)), shown.length, isRtl(list))];
|
|
609
1177
|
if (!next)
|
|
610
1178
|
return;
|
|
611
1179
|
event.preventDefault();
|
|
@@ -619,6 +1187,57 @@ function onPointerDown(event) {
|
|
|
619
1187
|
const target = event.target;
|
|
620
1188
|
if (!(target instanceof Element) || event.button !== 0 || !inDom(target))
|
|
621
1189
|
return;
|
|
1190
|
+
const tabSelect = target.closest(".z-tabstrip[data-reorderable] .z-tabstrip__select");
|
|
1191
|
+
if (tabSelect) {
|
|
1192
|
+
tabDrag = {
|
|
1193
|
+
strip: tabSelect.closest(".z-tabstrip"),
|
|
1194
|
+
select: tabSelect,
|
|
1195
|
+
pointerId: event.pointerId,
|
|
1196
|
+
x: event.clientX,
|
|
1197
|
+
active: false,
|
|
1198
|
+
gap: -1,
|
|
1199
|
+
spans: [],
|
|
1200
|
+
};
|
|
1201
|
+
return;
|
|
1202
|
+
}
|
|
1203
|
+
const grab = target.closest(".z-panelayout__grab");
|
|
1204
|
+
const grabLayout = grab?.closest(".z-panelayout");
|
|
1205
|
+
if (grab && grabLayout && !target.closest("button, a, input, select, textarea") && paneSections(grabLayout).length > 1) {
|
|
1206
|
+
const id = grab.closest(".z-panelayout__pane")?.dataset.paneId;
|
|
1207
|
+
if (id)
|
|
1208
|
+
paneDrag = { layout: grabLayout, id, pointerId: event.pointerId, x: event.clientX, y: event.clientY, active: false, drop: null };
|
|
1209
|
+
try {
|
|
1210
|
+
grab.setPointerCapture(event.pointerId);
|
|
1211
|
+
}
|
|
1212
|
+
catch {
|
|
1213
|
+
/* puntero ya liberado */
|
|
1214
|
+
}
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
const grip = target.closest(".z-floatpanel__header, .z-floatpanel__resize");
|
|
1218
|
+
const gripPanel = grip?.closest(".z-floatpanel");
|
|
1219
|
+
if (grip && gripPanel) {
|
|
1220
|
+
const control = target.closest("button, a, input, select, textarea");
|
|
1221
|
+
if (control && control !== grip && !control.classList.contains("z-floatpanel__handle"))
|
|
1222
|
+
return;
|
|
1223
|
+
const start = panelRect(gripPanel);
|
|
1224
|
+
const [x, y] = [event.clientX, event.clientY];
|
|
1225
|
+
const resizing = grip.classList.contains("z-floatpanel__resize");
|
|
1226
|
+
grip.dataset.dragging = "";
|
|
1227
|
+
drag = {
|
|
1228
|
+
el: grip,
|
|
1229
|
+
move: (e) => resizing
|
|
1230
|
+
? resizePanel(gripPanel, start, e.clientX - x, e.clientY - y)
|
|
1231
|
+
: setFloatingPanelRect(gripPanel, { ...start, x: start.x + e.clientX - x, y: start.y + e.clientY - y }),
|
|
1232
|
+
};
|
|
1233
|
+
try {
|
|
1234
|
+
grip.setPointerCapture(event.pointerId);
|
|
1235
|
+
}
|
|
1236
|
+
catch {
|
|
1237
|
+
/* puntero ya liberado */
|
|
1238
|
+
}
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
622
1241
|
let move;
|
|
623
1242
|
const el = target.closest(".z-resize, .z-split__divider");
|
|
624
1243
|
if (!el)
|
|
@@ -656,7 +1275,11 @@ function onPointerDown(event) {
|
|
|
656
1275
|
/* puntero ya liberado */
|
|
657
1276
|
}
|
|
658
1277
|
}
|
|
659
|
-
function onPointerEnd() {
|
|
1278
|
+
function onPointerEnd(event) {
|
|
1279
|
+
// El último pointermove puede no llegar antes de soltar (Firefox los agrupa con la página ocupada): la posición
|
|
1280
|
+
// final es la del pointerup.
|
|
1281
|
+
if (drag && event)
|
|
1282
|
+
drag.move(event);
|
|
660
1283
|
if (drag)
|
|
661
1284
|
delete drag.el.dataset.dragging;
|
|
662
1285
|
drag = null;
|
|
@@ -679,6 +1302,7 @@ function onDoubleClick(event) {
|
|
|
679
1302
|
if (defaultSize !== undefined)
|
|
680
1303
|
resizeTo(handle, defaultSize);
|
|
681
1304
|
}
|
|
1305
|
+
export { setChatView, setChatWidgetOpen } from "./chat.js";
|
|
682
1306
|
/** Prepara el marcado bajo `[data-z-dom]`: mide los shells, completa divisores y pestañas. Repetible. */
|
|
683
1307
|
export function hydrate(root = document) {
|
|
684
1308
|
if (!isBrowser)
|
|
@@ -689,6 +1313,16 @@ export function hydrate(root = document) {
|
|
|
689
1313
|
hydrateSplit(split);
|
|
690
1314
|
for (const strip of all(root, ".z-tabstrip"))
|
|
691
1315
|
hydrateStrip(strip);
|
|
1316
|
+
for (const sidebar of all(root, ".z-sidebar[data-collapsed]"))
|
|
1317
|
+
setSidebarCollapsed(sidebar, true, true);
|
|
1318
|
+
for (const panel of all(root, ".z-floatpanel"))
|
|
1319
|
+
if (!panel.hidden)
|
|
1320
|
+
setFloatingPanelRect(panel, panelRect(panel), true);
|
|
1321
|
+
for (const layout of all(root, ".z-panelayout"))
|
|
1322
|
+
syncPaneFocus(layout);
|
|
1323
|
+
hydrateSite(root);
|
|
1324
|
+
hydrateChat(root);
|
|
1325
|
+
hydratePages(root);
|
|
692
1326
|
for (const handle of all(root, ".z-resize")) {
|
|
693
1327
|
// Un tirador escrito solo con su clase recibe el rol y los atributos del patrón «window splitter».
|
|
694
1328
|
if (!handle.hasAttribute("role"))
|
|
@@ -714,6 +1348,8 @@ export function hydrate(root = document) {
|
|
|
714
1348
|
export function dispose(root = document) {
|
|
715
1349
|
if (!isBrowser)
|
|
716
1350
|
return;
|
|
1351
|
+
disposeSite(root);
|
|
1352
|
+
disposePages(root);
|
|
717
1353
|
for (const shell of all(root, ".z-shell")) {
|
|
718
1354
|
shellObserver?.unobserve(shell);
|
|
719
1355
|
shells.delete(shell);
|
|
@@ -733,12 +1369,47 @@ export function init() {
|
|
|
733
1369
|
return;
|
|
734
1370
|
wired = true;
|
|
735
1371
|
document.addEventListener("click", onClick);
|
|
1372
|
+
document.addEventListener("click", onSiteClick);
|
|
1373
|
+
document.addEventListener("click", onChatClick);
|
|
1374
|
+
document.addEventListener("keydown", onChatKeydown);
|
|
736
1375
|
document.addEventListener("keydown", onKeydown);
|
|
1376
|
+
window.addEventListener("popstate", onChatPopState);
|
|
737
1377
|
document.addEventListener("dblclick", onDoubleClick);
|
|
738
1378
|
document.addEventListener("pointerdown", onPointerDown);
|
|
739
|
-
document.addEventListener("pointermove", (event) =>
|
|
740
|
-
|
|
741
|
-
|
|
1379
|
+
document.addEventListener("pointermove", (event) => {
|
|
1380
|
+
drag?.move(event);
|
|
1381
|
+
tabDragMove(event);
|
|
1382
|
+
paneDragMove(event);
|
|
1383
|
+
});
|
|
1384
|
+
document.addEventListener("pointerup", (event) => {
|
|
1385
|
+
onPointerEnd(event);
|
|
1386
|
+
tabDragEnd(event, false);
|
|
1387
|
+
paneDragEnd(event, false);
|
|
1388
|
+
});
|
|
1389
|
+
document.addEventListener("pointercancel", (event) => {
|
|
1390
|
+
onPointerEnd();
|
|
1391
|
+
tabDragEnd(event, true);
|
|
1392
|
+
paneDragEnd(event, true);
|
|
1393
|
+
});
|
|
1394
|
+
// Elegir una acción del menú de un panel (los menús los mueve @zuccadev-labs/zuix-zui/dom, que emite z:select).
|
|
1395
|
+
document.addEventListener("z:select", (event) => {
|
|
1396
|
+
const item = event.target instanceof Element ? event.target.closest("[data-pane-action]") : null;
|
|
1397
|
+
if (item)
|
|
1398
|
+
paneAction(item);
|
|
1399
|
+
});
|
|
1400
|
+
// El panel pulsado o enfocado pasa a ser el del foco.
|
|
1401
|
+
const markPane = (event) => {
|
|
1402
|
+
const section = event.target instanceof Element ? event.target.closest(".z-panelayout__pane") : null;
|
|
1403
|
+
const layout = section?.closest(".z-panelayout");
|
|
1404
|
+
if (section && layout && inDom(layout) && layout.dataset.focused !== section.dataset.paneId)
|
|
1405
|
+
syncPaneFocus(layout, section.dataset.paneId);
|
|
1406
|
+
};
|
|
1407
|
+
document.addEventListener("pointerdown", markPane, true);
|
|
1408
|
+
document.addEventListener("focusin", markPane);
|
|
1409
|
+
document.addEventListener("dragstart", (event) => {
|
|
1410
|
+
if (event.target instanceof Element && event.target.closest(".z-tabstrip[data-reorderable] .z-tabstrip__select"))
|
|
1411
|
+
event.preventDefault();
|
|
1412
|
+
});
|
|
742
1413
|
if (document.readyState === "loading")
|
|
743
1414
|
document.addEventListener("DOMContentLoaded", () => hydrate());
|
|
744
1415
|
else
|