@zuccadev-labs/zuix-zout 0.1.0 → 0.2.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +62 -47
  3. package/dist/esm/dom/index.d.ts +6 -0
  4. package/dist/esm/dom/index.js +115 -26
  5. package/dist/esm/dom/index.js.map +1 -1
  6. package/dist/esm/index.js.map +1 -1
  7. package/dist/esm/layouts/Page.d.ts +6 -2
  8. package/dist/esm/layouts/Page.js +10 -8
  9. package/dist/esm/layouts/Page.js.map +1 -1
  10. package/dist/esm/layouts/Rail.js +1 -3
  11. package/dist/esm/layouts/Rail.js.map +1 -1
  12. package/dist/esm/layouts/ResizeHandle.d.ts +9 -3
  13. package/dist/esm/layouts/ResizeHandle.js +19 -9
  14. package/dist/esm/layouts/ResizeHandle.js.map +1 -1
  15. package/dist/esm/layouts/Shell.d.ts +13 -1
  16. package/dist/esm/layouts/Shell.js +27 -11
  17. package/dist/esm/layouts/Shell.js.map +1 -1
  18. package/dist/esm/layouts/SidePanel.d.ts +1 -1
  19. package/dist/esm/layouts/SidePanel.js +7 -3
  20. package/dist/esm/layouts/SidePanel.js.map +1 -1
  21. package/dist/esm/layouts/SplitPane.d.ts +1 -1
  22. package/dist/esm/layouts/SplitPane.js +39 -12
  23. package/dist/esm/layouts/SplitPane.js.map +1 -1
  24. package/dist/esm/layouts/TabStrip.d.ts +4 -2
  25. package/dist/esm/layouts/TabStrip.js +4 -3
  26. package/dist/esm/layouts/TabStrip.js.map +1 -1
  27. package/dist/esm/layouts/TitleBar.d.ts +7 -1
  28. package/dist/esm/layouts/TitleBar.js +2 -2
  29. package/dist/esm/layouts/TitleBar.js.map +1 -1
  30. package/dist/esm/logic.d.ts +24 -9
  31. package/dist/esm/logic.js +32 -9
  32. package/dist/esm/logic.js.map +1 -1
  33. package/dist/zout.css +124 -33
  34. package/dist/zout.dom.js +1 -1
  35. package/html.json +2 -2
  36. package/manifest.json +60 -12
  37. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -5,6 +5,51 @@ versión en toda la suite ([Versionado](https://github.com/zuccadev-labs/zuix/bl
5
5
 
6
6
  ## [Sin publicar]
7
7
 
8
+ ## [0.2.0] - 2026-11-18
9
+
10
+ Qué hay que tocar en una aplicación está en la [guía de actualización](https://github.com/zuccadev-labs/zuix/blob/main/docs/users/08-actualizar-de-0-1-a-0-2.md).
11
+
12
+ ### Cambios incompatibles
13
+
14
+ - Node 22.12 o posterior (antes, 20). Node 20 terminó su soporte el 2026-04-30.
15
+ - `TitleBar` es un `<header>` (región `banner`) en lugar de un `<div>`. Las clases no cambian; `as="div"`
16
+ recupera el elemento anterior.
17
+ - El tirador de los paneles del `Shell` usa `data-side="end"` (sidebar) y `"start"` (inspector) en lugar de
18
+ `right` y `left`. Afecta a quien escribió el marcado a mano o tiene selectores sobre ese atributo.
19
+ - `.z-shell` es un contenedor de consultas (`container: z-shell / inline-size`). Antes de medirse (HTML de
20
+ servidor, o antes de `init()`), un panel `auto` que no cabe no se muestra: una ventana estrecha ya no
21
+ enseña un instante los paneles acoplados.
22
+ - El botón de cierre de una pestaña mide 24 × 24 px (antes 18): el mínimo de WCAG 2.5.8.
23
+ - El eyebrow de `PageHeader` usa `--z-accent-text` y el contador del rail `--z-danger-solid`, para llegar a
24
+ 4.5:1. Cambia su tono.
25
+
26
+ ### Añadido
27
+
28
+ - `Shell`: `skipLinkLabel` (enlace para saltar al contenido, WCAG 2.4.1), `mainAs` (`main`, `div` o
29
+ `section`, para shells anidados o varios en una página) y `resizeLabel` en cada panel.
30
+ - `ResizeHandle`: lados lógicos `start` y `end`, que siguen la dirección de escritura, y `controls`
31
+ (`aria-controls`). En HTML: `data-side="start|end"`.
32
+ - `SplitPane`: Inicio y Fin llevan el divisor a su mínimo y a su máximo; doble clic reparte a partes iguales
33
+ los dos paneles; cada divisor lleva `aria-controls`.
34
+ - `TabStrip`: `controls` en cada pestaña (`aria-controls` del panel).
35
+ - `TitleBar`: prop `as` (`header` o `div`). `PageHeader` y `PageSection`: `headingLevel`.
36
+ - `@zuccadev-labs/zuix-zout/dom`: `dispose(root)` suelta los observadores de un bloque de marcado;
37
+ `hydrate()` completa un `.z-resize` escrito solo con su clase (rol, orientación, límites).
38
+ - Colores forzados (contraste alto de Windows): foco, elemento activo del rail, pestaña seleccionada,
39
+ divisores y cajones se distinguen con contornos y colores del sistema.
40
+
41
+ ### Corregido
42
+
43
+ - RTL: los cajones, el tirador, el arrastre y las flechas de `SplitPane`, y las flechas de `TabStrip`,
44
+ siguen la dirección de escritura; la hoja usa propiedades lógicas.
45
+ - `Shell` (React): Escape no cierra el cajón si lo gestiona un `<dialog>` o un popover abierto por encima.
46
+ - `ResizeHandle` y `SplitPane` (React): solo arrastra el botón principal; el arrastre termina si se pierde
47
+ la captura del puntero.
48
+ - `@zuccadev-labs/zuix-zout/dom`: un selector inválido en `data-z-shell` o `data-z-resize` ya no lanza una
49
+ excepción; un shell retirado del documento deja de observarse; los iconos se crean con el DOM (compatible
50
+ con Trusted Types); `data-z-shell="#id"` manda sobre el shell que contiene al botón.
51
+ - El foco de los controles de layout sigue visible con colores forzados.
52
+
8
53
  ## [0.1.0] - 2026-11-14
9
54
 
10
55
  Primera versión publicada.
package/README.md CHANGED
@@ -1,42 +1,42 @@
1
1
  # @zuccadev-labs/zuix-zout
2
2
 
3
- Layouts y ventanas dinámicas de la suite zuix. Resuelve la estructura de la pantalla (shell, paneles,
4
- pestañas de trabajo, rejillas) y no dibuja contenido. Las medidas y el material salen de los tokens.
3
+ Layouts and dynamic windows for the zuix suite. It solves the structure of the screen (shell, panels, work
4
+ tabs, grids) and draws no content. Measures and material come from the tokens.
5
5
 
6
- ## Instalación
6
+ ## Install
7
7
 
8
8
  ```
9
9
  pnpm add @zuccadev-labs/zuix-zout @zuccadev-labs/zuix-zui @zuccadev-labs/zuix-tokens @zuccadev-labs/zuix-zicon
10
10
  ```
11
11
 
12
- `@zuccadev-labs/zuix-zicon` es un peer obligatorio. `react` y `react-dom` 19 son peers opcionales: solo los
13
- necesita el binding (`pnpm add react react-dom`). Los paquetes de la suite se instalan y se actualizan
14
- juntos, en la misma versión.
12
+ `@zuccadev-labs/zuix-zicon` is a required peer. `react` and `react-dom` 19 are optional peers: only the
13
+ binding needs them (`pnpm add react react-dom`). The suite packages are installed and upgraded together, at
14
+ the same version. Requires Node 22.12 or later.
15
15
 
16
- Para instalarlo todo con una sola dependencia: [`@zuccadev-labs/zuix`](https://www.npmjs.com/package/@zuccadev-labs/zuix).
16
+ To install everything with a single dependency: [`@zuccadev-labs/zuix`](https://www.npmjs.com/package/@zuccadev-labs/zuix).
17
17
 
18
- ## Piezas
18
+ ## Pieces
19
19
 
20
- | Pieza | Qué hace |
20
+ | Piece | What it does |
21
21
  |---|---|
22
- | `Shell` | Estructura general: barra de título, rail, sidebar, área principal, inspector |
23
- | `Rail`, `RailItem` | Barra estrecha de navegación principal |
24
- | `Sidebar`, `SidebarSection` | Navegación secundaria en acordeón |
25
- | `SidePanel` | Panel con título, cuerpo con desplazamiento y pie |
26
- | `SplitPane`, `Pane` | Paneles divididos con divisores arrastrables |
27
- | `TabStrip` | Pestañas de trabajo con cierre y alta |
28
- | `TitleBar` | Cabecera para ventanas sin marco |
29
- | `ResizeHandle` | Tirador de redimensionado |
30
- | `Page`, `PageHeader`, `PageSection`, `Container` | Página con cabecera y secciones |
31
- | `Grid`, `Stack`, `Inline` | Rejilla intrínseca, pila y fila |
32
-
33
- ## Uso con React
22
+ | `Shell` | The overall structure: title bar, rail, sidebar, main area, inspector |
23
+ | `Rail`, `RailItem` | Narrow bar for primary navigation |
24
+ | `Sidebar`, `SidebarSection` | Secondary navigation as an accordion |
25
+ | `SidePanel` | Panel with a title, a scrolling body and a footer |
26
+ | `SplitPane`, `Pane` | Split panes with draggable dividers |
27
+ | `TabStrip` | Work tabs with close and add |
28
+ | `TitleBar` | Header for frameless windows. It is a `<header>` |
29
+ | `ResizeHandle` | Resize handle |
30
+ | `Page`, `PageHeader`, `PageSection`, `Container` | Page with a header and sections |
31
+ | `Grid`, `Stack`, `Inline` | Intrinsic grid, stack and row |
32
+
33
+ ## With React
34
34
 
35
35
  ```tsx
36
36
  import "@zuccadev-labs/zuix-tokens/tokens.css";
37
37
  import "@zuccadev-labs/zuix-zui/styles.css";
38
38
  import "@zuccadev-labs/zuix-zout/styles.css";
39
- import "@zuccadev-labs/zuix-zicon/all"; // registra los iconos
39
+ import "@zuccadev-labs/zuix-zicon/all"; // registers the icons
40
40
  import { useState } from "react";
41
41
  import { Shell, Sidebar, SidebarSection, Page, PageHeader, Grid } from "@zuccadev-labs/zuix-zout";
42
42
 
@@ -57,12 +57,13 @@ export function App() {
57
57
  }
58
58
  ```
59
59
 
60
- El `Shell` necesita un contenedor con alto definido.
60
+ The `Shell` needs a container with a defined height. `skipLinkLabel` adds a "skip to content" link, and
61
+ `mainAs` lets a nested shell avoid a second `<main>`.
61
62
 
62
- ## Uso sin React
63
+ ## Without React
63
64
 
64
- El marcado de cada layout está en `@zuccadev-labs/zuix-zout/html.json`. El comportamiento (cajones del shell,
65
- divisores, pestañas de trabajo) lo pone `@zuccadev-labs/zuix-zout/dom`:
65
+ The markup of every layout is in `@zuccadev-labs/zuix-zout/html.json`. The behavior (shell drawers, dividers,
66
+ work tabs) comes from `@zuccadev-labs/zuix-zout/dom`:
66
67
 
67
68
  ```js
68
69
  import "@zuccadev-labs/zuix-tokens/tokens.css";
@@ -73,37 +74,51 @@ import { init } from "@zuccadev-labs/zuix-zout/dom";
73
74
  init();
74
75
  ```
75
76
 
76
- Sin bundler se enlazan `dist/zout.css` y `dist/zout.dom.js`, incluidos en el paquete.
77
+ Without a bundler, link `dist/zout.css` and `dist/zout.dom.js`, both included in the package.
77
78
 
78
- ## Comportamiento responsive
79
+ ## Responsive behavior
79
80
 
80
- El `Shell` mide su propio ancho, no el de la pantalla:
81
+ The `Shell` measures its own width, not the screen:
81
82
 
82
- | Ancho del shell | Sidebar | Inspector |
83
+ | Shell width | Sidebar | Inspector |
83
84
  |---|---|---|
84
- | 1180 px o más | Acoplada | Acoplado |
85
- | De 880 a 1179 px | Acoplada | Cajón |
86
- | Menos de 880 px | Cajón | Cajón |
85
+ | 1180 px or more | Docked | Docked |
86
+ | 880 to 1179 px | Docked | Drawer |
87
+ | Less than 880 px | Drawer | Drawer |
87
88
 
88
- Los divisores de `SplitPane` y los `ResizeHandle` se mueven con las flechas; `TabStrip` cambia de
89
- pestaña con flechas, Inicio y Fin.
89
+ ## Keyboard, pointer and direction
90
90
 
91
- ## Entradas
91
+ - `SplitPane` dividers and `ResizeHandle` move with the arrow keys; Home and End take them to their minimum
92
+ and maximum. Double-click resets a handle or splits two panes evenly.
93
+ - `TabStrip` switches tabs with the arrow keys, Home and End, and closes the active tab with Delete.
94
+ - With `dir="rtl"`, drawers, handles and arrow keys follow the writing direction. Handle sides are named
95
+ `start` and `end`.
96
+ - With a coarse pointer, the grab area of handles and dividers grows to 40 px.
92
97
 
93
- | Entrada | Contenido |
98
+ ## Entry points
99
+
100
+ | Entry | Contents |
94
101
  |---|---|
95
- | `@zuccadev-labs/zuix-zout` | Layouts de React y sus tipos |
96
- | `@zuccadev-labs/zuix-zout/dom` | Comportamiento sin framework: `init`, `hydrate`, `setPanelOpen`, `setSplitSizes`, `addWorkTab`… |
97
- | `@zuccadev-labs/zuix-zout/styles.css` | Estilos |
98
- | `@zuccadev-labs/zuix-zout/manifest.json`, `@zuccadev-labs/zuix-zout/html.json` | Props, clases y marcado, para herramientas y agentes |
99
- | `@zuccadev-labs/zuix-zout/dist/zout.css`, `@zuccadev-labs/zuix-zout/dist/zout.dom.js` | Bundles para enlazar sin bundler |
102
+ | `@zuccadev-labs/zuix-zout` | React layouts and their types |
103
+ | `@zuccadev-labs/zuix-zout/dom` | Framework-free behavior: `init`, `hydrate`, `dispose`, `setPanelOpen`, `setSplitSizes`, `addWorkTab`… |
104
+ | `@zuccadev-labs/zuix-zout/styles.css` | Styles |
105
+ | `@zuccadev-labs/zuix-zout/manifest.json`, `@zuccadev-labs/zuix-zout/html.json` | Props, classes and markup, for tools and agents |
106
+ | `@zuccadev-labs/zuix-zout/dist/zout.css`, `@zuccadev-labs/zuix-zout/dist/zout.dom.js` | Bundles to link without a bundler |
107
+
108
+ ## Documentation
109
+
110
+ The guides are written in Spanish.
111
+
112
+ - [Layouts guide](https://github.com/zuccadev-labs/zuix/blob/main/docs/users/04-zout.md)
113
+ - [Using zuix with other frameworks, or with none](https://github.com/zuccadev-labs/zuix/blob/main/docs/users/06-frameworks.md)
114
+ - [Upgrading from 0.1 to 0.2](https://github.com/zuccadev-labs/zuix/blob/main/docs/users/08-actualizar-de-0-1-a-0-2.md)
115
+ - [Changelog](https://github.com/zuccadev-labs/zuix/blob/main/zout/CHANGELOG.md)
100
116
 
101
- ## Documentación
117
+ ## Español
102
118
 
103
- - [Guía de layouts](https://github.com/zuccadev-labs/zuix/blob/main/docs/users/04-zout.md)
104
- - [Uso con otros frameworks o sin ninguno](https://github.com/zuccadev-labs/zuix/blob/main/docs/users/06-frameworks.md)
105
- - [Cambios](https://github.com/zuccadev-labs/zuix/blob/main/zout/CHANGELOG.md)
119
+ Layouts y ventanas dinámicas de la suite zuix. La guía está en español en
120
+ [`docs/users/04-zout.md`](https://github.com/zuccadev-labs/zuix/blob/main/docs/users/04-zout.md).
106
121
 
107
- ## Licencia
122
+ ## License
108
123
 
109
124
  [MIT](https://github.com/zuccadev-labs/zuix/blob/main/LICENSE).
@@ -43,5 +43,11 @@ export declare function addWorkTab(strip: HTMLElement, { id, title, icon, closab
43
43
  export declare function setSectionOpen(section: HTMLElement, open: boolean): void;
44
44
  /** Prepara el marcado bajo `[data-z-dom]`: mide los shells, completa divisores y pestañas. Repetible. */
45
45
  export declare function hydrate(root?: ParentNode): void;
46
+ /**
47
+ * Suelta lo que este módulo guarda de los layouts de `root` (observadores de tamaño y estado de shells): se llama
48
+ * antes de retirar del documento un bloque de marcado en una aplicación que monta y desmonta vistas. Los
49
+ * manejadores de eventos son del documento y no dependen de ningún elemento: no hay nada más que soltar.
50
+ */
51
+ export declare function dispose(root?: ParentNode): void;
46
52
  /** Conecta el comportamiento. Idempotente; llamar una vez al cargar. */
47
53
  export declare function init(): void;
@@ -4,7 +4,7 @@
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, dispose
8
8
  //
9
9
  // Todo se activa dentro de un contenedor [data-z-dom], para no chocar con React en la misma página.
10
10
  // Atributos:
@@ -14,16 +14,16 @@
14
14
  // data-panel-mode="auto|docked|overlay" en el <aside>: preferencia de modo (auto por defecto)
15
15
  // hidden en el <aside>: panel cerrado
16
16
  // data-close-label en .z-shell: nombre accesible del velo
17
- // data-default-size, data-step, data-var, data-z-resize="#id" en .z-resize
17
+ // 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
18
  // data-min-fraction en .z-split
19
19
  // data-new-title="Untitled" en .z-tabstrip__add: crea la pestaña sin código de la aplicación
20
20
  // Tras insertar marcado nuevo: hydrate(contenedor).
21
21
  // Eventos (burbujean y se pueden cancelar): z:modechange, z:open, z:close, z:resize, z:select, z:add, z:change.
22
- import { iconSvg, registerIcons } from "@zuccadev-labs/zuix-zicon/dom";
22
+ import { iconElement, registerIcons } from "@zuccadev-labs/zuix-zicon/dom";
23
23
  import { chevronDownSmall } from "@zuccadev-labs/zuix-zicon/icons/chevron-down-small";
24
24
  import { chevronRightSmall } from "@zuccadev-labs/zuix-zicon/icons/chevron-right-small";
25
25
  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, resizeByKey, resizeSign, revealOffset, tabKeyIndex, } from "../logic.js";
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";
27
27
  // Iconos que este módulo dibuja por su cuenta cuando el marcado no usa <z-icon>.
28
28
  registerIcons([xMark, chevronDownSmall, chevronRightSmall]);
29
29
  const isBrowser = typeof document !== "undefined";
@@ -38,10 +38,23 @@ function all(root, selector) {
38
38
  list.unshift(root);
39
39
  return list.filter(inDom);
40
40
  }
41
- const num = (value, fallback) => (value != null && value !== "" && Number.isFinite(Number(value)) ? Number(value) : fallback);
41
+ const isRtl = (el) => getComputedStyle(el).direction === "rtl";
42
+ /** `document.querySelector` con un selector que viene de un atributo del marcado: uno inválido no rompe el manejador. */
43
+ function query(selector) {
44
+ try {
45
+ return document.querySelector(selector);
46
+ }
47
+ catch {
48
+ return null;
49
+ }
50
+ }
51
+ const num = (value, fallback) => value != null && value !== "" && Number.isFinite(Number(value)) ? Number(value) : fallback;
42
52
  /* ---------- Shell ---------- */
43
53
  const SIDES = ["sidebar", "inspector"];
44
- const PANEL = { sidebar: ":scope > .z-shell__body > .z-shell__side", inspector: ":scope > .z-shell__body > .z-shell__inspector" };
54
+ const PANEL = {
55
+ sidebar: ":scope > .z-shell__body > .z-shell__side",
56
+ inspector: ":scope > .z-shell__body > .z-shell__inspector",
57
+ };
45
58
  const shells = new WeakMap();
46
59
  const panelOf = (shell, side) => shell.querySelector(PANEL[side]);
47
60
  function autoModes(shell, state) {
@@ -49,7 +62,9 @@ function autoModes(shell, state) {
49
62
  return { sidebar: mode("sidebar", SIDEBAR_BREAKPOINT), inspector: mode("inspector", INSPECTOR_BREAKPOINT) };
50
63
  }
51
64
  function shellOf(el) {
52
- const shell = el.closest(".z-shell") ?? document.querySelector(el.getAttribute("data-z-shell") ?? "[data-z-dom] .z-shell, .z-shell[data-z-dom]");
65
+ // Un botón con `data-z-shell="#id"` apunta a ese shell aunque esté dentro de otro (shells anidados).
66
+ const named = el.getAttribute("data-z-shell");
67
+ const shell = (named ? query(named) : null) ?? el.closest(".z-shell") ?? query("[data-z-dom] .z-shell, .z-shell[data-z-dom]");
53
68
  return shell && shells.has(shell) ? shell : null;
54
69
  }
55
70
  /** Lleva al DOM el estado del shell: clases y roles de cajón, velo, zonas inertes, foco y botones. */
@@ -70,6 +85,7 @@ function syncShell(shell) {
70
85
  const overlay = mode === "overlay";
71
86
  el.classList.toggle("z-shell__drawer", overlay);
72
87
  el.dataset.mode = auto[side];
88
+ el.dataset.panelMode ??= "auto";
73
89
  el.dataset.side ??= side === "sidebar" ? "left" : "right";
74
90
  if (overlay) {
75
91
  el.setAttribute("role", "dialog");
@@ -136,6 +152,7 @@ function measure(shell, width) {
136
152
  if (!state)
137
153
  return;
138
154
  state.width = width;
155
+ shell.dataset.measured = "";
139
156
  const next = autoModes(shell, state);
140
157
  const prev = state.modes;
141
158
  if (!prev || prev.sidebar !== next.sidebar || prev.inspector !== next.inspector) {
@@ -161,8 +178,10 @@ function measure(shell, width) {
161
178
  }
162
179
  let shellObserver;
163
180
  function hydrateShell(shell) {
164
- if (shells.has(shell))
165
- return syncShell(shell);
181
+ if (shells.has(shell)) {
182
+ syncShell(shell);
183
+ return;
184
+ }
166
185
  const panel = () => ({ overlay: false, previous: null, dockedOpen: true });
167
186
  shells.set(shell, { width: null, modes: null, panels: { sidebar: panel(), inspector: panel() } });
168
187
  // Se mide antes del primer pintado para que un shell estrecho no muestre un instante los paneles acoplados.
@@ -170,8 +189,16 @@ function hydrateShell(shell) {
170
189
  if (typeof ResizeObserver === "undefined")
171
190
  return;
172
191
  shellObserver ??= new ResizeObserver((entries) => {
173
- for (const entry of entries)
174
- measure(entry.target, entry.contentRect.width);
192
+ for (const entry of entries) {
193
+ const target = entry.target;
194
+ // Un shell retirado del documento deja de observarse: el observador no lo retiene y vuelve a activarse con hydrate().
195
+ if (!target.isConnected) {
196
+ shellObserver?.unobserve(target);
197
+ shells.delete(target);
198
+ continue;
199
+ }
200
+ measure(target, entry.contentRect.width);
201
+ }
175
202
  });
176
203
  shellObserver.observe(shell);
177
204
  }
@@ -196,8 +223,9 @@ export function setPanelOpen(shell, side, open) {
196
223
  }
197
224
  export function togglePanel(shell, side) {
198
225
  const el = panelOf(shell, side);
226
+ // `hidden` no es solo booleano: "until-found" también es un panel oculto, y alternarlo es abrirlo.
199
227
  if (el)
200
- setPanelOpen(shell, side, el.hidden);
228
+ setPanelOpen(shell, side, el.hidden !== false);
201
229
  }
202
230
  /** Cierra el cajón abierto (lo que hacen Escape y el velo). Devuelve si había alguno. */
203
231
  export function closeDrawers(shell) {
@@ -216,11 +244,11 @@ export function closeDrawers(shell) {
216
244
  }
217
245
  /* ---------- ResizeHandle ---------- */
218
246
  function resizeOptions(handle) {
219
- const side = (handle.dataset.side ?? "right");
247
+ const side = physicalSide((handle.dataset.side ?? "right"), isRtl(handle));
220
248
  const sel = handle.getAttribute("data-z-resize");
221
249
  return {
222
250
  side,
223
- target: sel ? document.querySelector(sel) : handle.parentElement,
251
+ target: sel ? query(sel) : handle.parentElement,
224
252
  min: num(handle.getAttribute("aria-valuemin"), RESIZE_MIN),
225
253
  max: num(handle.getAttribute("aria-valuemax"), RESIZE_MAX),
226
254
  step: num(handle.dataset.step, RESIZE_STEP),
@@ -265,8 +293,12 @@ export function getSplitSizes(split) {
265
293
  }
266
294
  /** Fija el reparto sin emitir `z:resize`. */
267
295
  export function setSplitSizes(split, sizes) {
268
- parts(split, "z-split__pane").forEach((pane, i) => { pane.style.flexGrow = String(sizes[i] ?? 0); });
269
- parts(split, "z-split__divider").forEach((divider, i) => divider.setAttribute("aria-valuenow", String(Math.round((sizes[i] ?? 0) * 100))));
296
+ parts(split, "z-split__pane").forEach((pane, i) => {
297
+ pane.style.flexGrow = String(sizes[i] ?? 0);
298
+ });
299
+ parts(split, "z-split__divider").forEach((divider, i) => {
300
+ divider.setAttribute("aria-valuenow", String(Math.round((sizes[i] ?? 0) * 100)));
301
+ });
270
302
  }
271
303
  function minFraction(split) {
272
304
  const fromDivider = num(split.querySelector(":scope > .z-split__divider")?.getAttribute("aria-valuemin"), SPLIT_MIN_FRACTION * 100) / 100;
@@ -290,13 +322,17 @@ function hydrateSplit(split) {
290
322
  divider.setAttribute("aria-valuemin", String(min));
291
323
  if (!divider.hasAttribute("aria-valuemax"))
292
324
  divider.setAttribute("aria-valuemax", String(100 - min));
325
+ // El divisor controla el panel que tiene delante (patrón «window splitter»).
326
+ const primary = divider.previousElementSibling;
327
+ if (!divider.hasAttribute("aria-controls") && primary?.id)
328
+ divider.setAttribute("aria-controls", primary.id);
293
329
  }
294
330
  setSplitSizes(split, getSplitSizes(split));
295
331
  }
296
332
  const selects = (strip) => [...strip.querySelectorAll(".z-tabstrip__select")];
297
333
  const findTab = (strip, id) => selects(strip).find((s) => s.dataset.tabId === id);
298
334
  const activeTab = (strip) => selects(strip).find((s) => s.getAttribute("aria-selected") === "true");
299
- const panelFor = (select) => (select.getAttribute("aria-controls") ? document.getElementById(select.getAttribute("aria-controls")) : null);
335
+ const panelFor = (select) => select.getAttribute("aria-controls") ? document.getElementById(select.getAttribute("aria-controls")) : null;
300
336
  /** Desplaza la tira para que la pestaña activa quede a la vista. */
301
337
  function reveal(strip) {
302
338
  const list = strip.querySelector(".z-tabstrip__list");
@@ -399,7 +435,7 @@ export function addWorkTab(strip, { id, title, icon, closable = true, closeLabel
399
435
  close.setAttribute("aria-hidden", "true");
400
436
  close.tabIndex = -1;
401
437
  button.setAttribute("aria-keyshortcuts", "Delete");
402
- close.innerHTML = iconSvg("x-mark", { size: 12 });
438
+ close.append(iconElement("x-mark", { size: 12 }));
403
439
  tab.append(close);
404
440
  }
405
441
  list.append(tab);
@@ -431,6 +467,11 @@ function hydrateStrip(strip) {
431
467
  // Al estrecharse la tira, la pestaña activa sigue a la vista.
432
468
  stripObserver ??= new ResizeObserver((entries) => {
433
469
  for (const entry of entries) {
470
+ if (!entry.target.isConnected) {
471
+ stripObserver?.unobserve(entry.target);
472
+ observedLists.delete(entry.target);
473
+ continue;
474
+ }
434
475
  const owner = entry.target.closest(".z-tabstrip");
435
476
  if (owner)
436
477
  reveal(owner);
@@ -460,7 +501,7 @@ export function setSectionOpen(section, open) {
460
501
  if (attr === "name")
461
502
  icon.setAttribute("name", name);
462
503
  else
463
- icon.outerHTML = iconSvg(name, { size: icon.getAttribute("width") ?? 12 });
504
+ icon.replaceWith(iconElement(name, { size: icon.getAttribute("width") ?? 12 }));
464
505
  }
465
506
  /* ---------- Delegación de eventos ---------- */
466
507
  function onClick(event) {
@@ -475,7 +516,8 @@ function onClick(event) {
475
516
  // El foco queda en el botón (hay navegadores que no enfocan al hacer clic): ahí vuelve al cerrar el cajón.
476
517
  if (document.activeElement !== toggle)
477
518
  toggle.focus({ preventScroll: true });
478
- return togglePanel(shell, toggle.getAttribute("data-z-shell-toggle"));
519
+ togglePanel(shell, toggle.getAttribute("data-z-shell-toggle"));
520
+ return;
479
521
  }
480
522
  const scrim = target.closest(".z-shell__scrim");
481
523
  if (scrim) {
@@ -536,18 +578,20 @@ function onKeydown(event) {
536
578
  if (next === undefined)
537
579
  return;
538
580
  event.preventDefault();
539
- return resizeTo(handle, next);
581
+ resizeTo(handle, next);
582
+ return;
540
583
  }
541
584
  const divider = target.closest(".z-split__divider");
542
585
  const split = divider?.parentElement;
543
586
  if (divider && split?.classList.contains("z-split")) {
544
- const delta = dividerKeyDelta(event.key, directionOf(split));
587
+ const delta = dividerKeyDelta(event.key, directionOf(split), isRtl(split));
545
588
  if (!delta)
546
589
  return;
547
590
  event.preventDefault();
548
591
  const index = parts(split, "z-split__divider").indexOf(divider);
549
592
  const sizes = getSplitSizes(split);
550
- return moveSplit(split, index, sizes[index] ?? 0, sizes[index + 1] ?? 0, delta);
593
+ moveSplit(split, index, sizes[index] ?? 0, sizes[index + 1] ?? 0, delta);
594
+ return;
551
595
  }
552
596
  const list = target.closest(".z-tabstrip__list");
553
597
  const strip = list?.closest(".z-tabstrip");
@@ -561,7 +605,7 @@ function onKeydown(event) {
561
605
  activeTab(strip)?.focus();
562
606
  return;
563
607
  }
564
- const next = tabs[tabKeyIndex(event.key, tabs.indexOf(activeTab(strip)), tabs.length)];
608
+ const next = tabs[tabKeyIndex(event.key, tabs.indexOf(activeTab(strip)), tabs.length, isRtl(list))];
565
609
  if (!next)
566
610
  return;
567
611
  event.preventDefault();
@@ -599,14 +643,18 @@ function onPointerDown(event) {
599
643
  const sizes = getSplitSizes(split);
600
644
  const [a, b] = [sizes[index] ?? 0, sizes[index + 1] ?? 0];
601
645
  const pos = row ? event.clientX : event.clientY;
602
- move = (e) => moveSplit(split, index, a, b, ((row ? e.clientX : e.clientY) - pos) / total);
646
+ // En una fila RTL el primer panel queda a la derecha: arrastrar a la derecha lo encoge.
647
+ const sign = row && isRtl(split) ? -1 : 1;
648
+ move = (e) => moveSplit(split, index, a, b, (sign * ((row ? e.clientX : e.clientY) - pos)) / total);
603
649
  el.dataset.dragging = "";
604
650
  }
605
651
  drag = { el, move };
606
652
  try {
607
653
  el.setPointerCapture(event.pointerId);
608
654
  }
609
- catch { /* puntero ya liberado */ }
655
+ catch {
656
+ /* puntero ya liberado */
657
+ }
610
658
  }
611
659
  function onPointerEnd() {
612
660
  if (drag)
@@ -614,6 +662,16 @@ function onPointerEnd() {
614
662
  drag = null;
615
663
  }
616
664
  function onDoubleClick(event) {
665
+ // Divisor: los dos paneles que separa se reparten su espacio a partes iguales.
666
+ const divider = event.target instanceof Element ? event.target.closest(".z-split__divider") : null;
667
+ const split = divider?.parentElement;
668
+ if (divider && split?.classList.contains("z-split") && inDom(divider)) {
669
+ const index = parts(split, "z-split__divider").indexOf(divider);
670
+ const sizes = getSplitSizes(split);
671
+ const half = ((sizes[index] ?? 0) + (sizes[index + 1] ?? 0)) / 2;
672
+ moveSplit(split, index, half, half, 0);
673
+ return;
674
+ }
617
675
  const handle = event.target instanceof Element ? event.target.closest(".z-resize") : null;
618
676
  if (!handle || !inDom(handle))
619
677
  return;
@@ -632,11 +690,42 @@ export function hydrate(root = document) {
632
690
  for (const strip of all(root, ".z-tabstrip"))
633
691
  hydrateStrip(strip);
634
692
  for (const handle of all(root, ".z-resize")) {
693
+ // Un tirador escrito solo con su clase recibe el rol y los atributos del patrón «window splitter».
694
+ if (!handle.hasAttribute("role"))
695
+ handle.setAttribute("role", "separator");
696
+ if (!handle.hasAttribute("tabindex"))
697
+ handle.tabIndex = 0;
698
+ if (!handle.hasAttribute("aria-orientation"))
699
+ handle.setAttribute("aria-orientation", isHorizontal((handle.dataset.side ?? "right")) ? "vertical" : "horizontal");
700
+ if (!handle.hasAttribute("aria-valuemin"))
701
+ handle.setAttribute("aria-valuemin", String(RESIZE_MIN));
702
+ if (!handle.hasAttribute("aria-valuemax"))
703
+ handle.setAttribute("aria-valuemax", String(RESIZE_MAX));
635
704
  const options = resizeOptions(handle);
636
705
  if (options.target && !handle.closest("[hidden]"))
637
706
  handle.setAttribute("aria-valuenow", String(Math.round(currentSize(handle, options))));
638
707
  }
639
708
  }
709
+ /**
710
+ * Suelta lo que este módulo guarda de los layouts de `root` (observadores de tamaño y estado de shells): se llama
711
+ * antes de retirar del documento un bloque de marcado en una aplicación que monta y desmonta vistas. Los
712
+ * manejadores de eventos son del documento y no dependen de ningún elemento: no hay nada más que soltar.
713
+ */
714
+ export function dispose(root = document) {
715
+ if (!isBrowser)
716
+ return;
717
+ for (const shell of all(root, ".z-shell")) {
718
+ shellObserver?.unobserve(shell);
719
+ shells.delete(shell);
720
+ }
721
+ for (const strip of all(root, ".z-tabstrip")) {
722
+ const list = strip.querySelector(".z-tabstrip__list");
723
+ if (list) {
724
+ stripObserver?.unobserve(list);
725
+ observedLists.delete(list);
726
+ }
727
+ }
728
+ }
640
729
  let wired = false;
641
730
  /** Conecta el comportamiento. Idempotente; llamar una vez al cargar. */
642
731
  export function init() {