@zuccadev-labs/zuix-zout 0.3.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 +59 -0
- package/README.md +11 -3
- 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 +1 -0
- package/dist/esm/dom/index.js +45 -3
- 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.js +1 -1
- package/dist/esm/dom/site.js.map +1 -1
- package/dist/esm/edges.d.ts +1 -1
- package/dist/esm/edges.js +4 -4
- package/dist/esm/edges.js.map +1 -1
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.js +11 -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/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/FloatingPanel.js +3 -1
- package/dist/esm/layouts/FloatingPanel.js.map +1 -1
- 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.js +2 -1
- package/dist/esm/layouts/Navbar.js.map +1 -1
- package/dist/esm/layouts/NavigationMenu.js +2 -1
- package/dist/esm/layouts/NavigationMenu.js.map +1 -1
- package/dist/esm/layouts/Page.d.ts +13 -4
- package/dist/esm/layouts/Page.js +4 -3
- package/dist/esm/layouts/Page.js.map +1 -1
- 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/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/logic.d.ts +17 -1
- package/dist/esm/logic.js +35 -1
- 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.js +6 -12
- package/dist/esm/site.js.map +1 -1
- package/dist/zout.compat.css +4196 -0
- package/dist/zout.css +1202 -66
- package/dist/zout.dom.js +1 -1
- package/html.json +261 -3
- package/manifest.json +1212 -184
- package/package.json +9 -7
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,65 @@ versión en toda la suite ([Versionado](https://github.com/zuccadev-labs/zuix/bl
|
|
|
5
5
|
|
|
6
6
|
## [Sin publicar]
|
|
7
7
|
|
|
8
|
+
## [0.4.0] - 2026-11-23
|
|
9
|
+
|
|
10
|
+
### Añadido
|
|
11
|
+
|
|
12
|
+
- React 18: los layouts funcionan con React 18.2 o posterior además de con React 19 (peers
|
|
13
|
+
`^18.2.0 || ^19.0.0`). `Shell` escribe `inert=""` y `Navbar` y `NavigationMenu`, `popovertarget` en minúsculas con
|
|
14
|
+
React 18, que no conoce esas props. `Shell` y `FloatingPanel` usan `useEffect` en el servidor, donde React 18 avisa
|
|
15
|
+
de cada `useLayoutEffect`.
|
|
16
|
+
- Sin Popover API, `Shell` ya no lanza al pulsar Escape con un cajón abierto, y `Navbar` y `NavigationMenu` abren
|
|
17
|
+
sus paneles con la misma comprobación que el modo sin framework (y con el polyfill, por él).
|
|
18
|
+
- Modo compat: `styles.compat.css` (`dist/zout.compat.css`), la hoja de layouts para Chromium 109, Firefox 115 y
|
|
19
|
+
Safari 15.4. Va con `tokens.compat.css` y `zui.compat.css`
|
|
20
|
+
([Compatibilidad](https://github.com/zuccadev-labs/zuix/blob/main/docs/users/10-compatibilidad.md#modo-compat)).
|
|
21
|
+
- `Container`: tamaños `sm`, `md`, `lg` y `xl` (tokens `container-*`) y `gutter` (`fluid`, `stage` o `none`). El
|
|
22
|
+
margen fluido crece con el ancho del contenedor de consulta entre 16 y 40 px; el ancho máximo suma los dos
|
|
23
|
+
márgenes, así que la columna de texto mide lo mismo con cualquiera. El marcado sin `data-gutter` se ve como antes.
|
|
24
|
+
Tiene manifiesto propio (antes iba dentro del de `Page`). `Stack`, `Inline` (con `wrap` y `gap`) y `Grid` cubren
|
|
25
|
+
el resto de la maquetación, así que no añado un `Flex` aparte.
|
|
26
|
+
- `Shell`: `railBreakpoint` (600 px por defecto; `data-rail-breakpoint` en `/dom`). Por debajo, con la sidebar en
|
|
27
|
+
cajón, el rail deja su columna y se muestra dentro del cajón, a su lado. En un teléfono una columna de iconos fija
|
|
28
|
+
se comía una quinta parte del ancho.
|
|
29
|
+
- `ChatLayout`: lista de conversaciones, conversación y detalles. Tres columnas en pantalla ancha, detalles encima en
|
|
30
|
+
media y una pila (lista → conversación → detalles) en estrecha, decidido por consultas de contenedor sobre el propio
|
|
31
|
+
layout. Con `history`, la pila se sincroniza con el historial del navegador; F6 salta entre paneles; `variant="widget"`
|
|
32
|
+
es un asistente flotante (botón y panel de cristal). En `/dom`: `data-view`, `[data-z-chat-view]`, `data-history`,
|
|
33
|
+
`setChatView` y `setChatWidgetOpen`.
|
|
34
|
+
- `AppBar`: barra de aplicación superior pequeña, mediana o grande; la grande pliega el título a la fila superior al
|
|
35
|
+
desplazar (animación ligada al desplazamiento, con respaldo en `/dom` y en React donde no la hay) y gana sombra con
|
|
36
|
+
algo desplazado.
|
|
37
|
+
- Layouts de página, todos con consultas de contenedor (responden a su hueco, no al viewport):
|
|
38
|
+
- `DashboardLayout`: cabecera, barra de filtros fija, contenido y panel lateral; navegación propia opcional.
|
|
39
|
+
- `SettingsLayout`: navegación con anclas, secciones y barra de guardar fija cuando hay cambios sin guardar.
|
|
40
|
+
- `AuthLayout`: acceso en una tarjeta de cristal centrada o dividido con un lado de imagen.
|
|
41
|
+
- `ProfileLayout`: cabecera de perfil, pestañas, contenido y columna lateral.
|
|
42
|
+
- `DocsLayout`: navegación, artículo, índice con la sección que se lee marcada (`aria-current`) y paginación;
|
|
43
|
+
en estrecho el índice es un `<details>` sobre el artículo.
|
|
44
|
+
- `LandingLayout` con `LandingHero` y `LandingSection` (rejilla de funciones, banda de llamada y bloque tenue).
|
|
45
|
+
- `KanbanLayout` y `MailLayout` (carpetas, lista y lectura; en estrecho, una sola vista según `view`).
|
|
46
|
+
- `appBarProgress` y `activeSection` en la lógica compartida; en `/dom`, `.z-appbar[data-collapse]` y
|
|
47
|
+
`.z-docs-layout__toc` se conectan solos.
|
|
48
|
+
|
|
49
|
+
### Corregido
|
|
50
|
+
|
|
51
|
+
- Contrato HTML: el ejemplo «Con filtros y panel» de `DashboardLayout` fija `locale="en-US"` en sus métricas, y
|
|
52
|
+
`html.json` ya no cambia con la configuración regional de la máquina que lo genera.
|
|
53
|
+
- `/dom`: abrir un panel o un menú del sitio que ya había salido del documento lanzaba «Element is not connected» en
|
|
54
|
+
WebKit. `showPopover` comprueba `isConnected` y no hace nada si el elemento ya no está.
|
|
55
|
+
- `/dom` sin Popover API: Escape en un cajón y el submenú plegado de la Sidebar lanzaban (`:popover-open` no es un
|
|
56
|
+
selector válido ahí). Ahora comprueba antes.
|
|
57
|
+
- `Navbar`: plegada y aun así sin sitio (una columna estrecha), las acciones bajan a otra línea en vez de salirse de la
|
|
58
|
+
cabecera.
|
|
59
|
+
- `SettingsLayout`: en estrecho, la tira de secciones difumina el borde con secciones ocultas (`data-scroll-edges`,
|
|
60
|
+
también en `/dom`) en lugar de cortar la última en seco.
|
|
61
|
+
- `Sidebar`: una lista más alta que la barra difumina el borde con filas ocultas (arriba, abajo o los dos) en vez de
|
|
62
|
+
cortar la última fila a media altura, donde parecía un elemento roto. Solo con algo por ese lado; en un navegador sin
|
|
63
|
+
animaciones ligadas al desplazamiento, la lista se corta como antes.
|
|
64
|
+
- Manifiestos: `Shell` documenta `titlebar`, `header` y `overlays`, y `SplitPane`, `dividerLabel` (por defecto
|
|
65
|
+
«Resize panes»). Existían en los tipos y no salían en el catálogo ni en `manifest.json`.
|
|
66
|
+
|
|
8
67
|
## [0.3.0] - 2026-11-21
|
|
9
68
|
|
|
10
69
|
### Añadido
|
package/README.md
CHANGED
|
@@ -9,9 +9,9 @@ tabs, grids, site navigation) and draws no content. Measures and material come f
|
|
|
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` is a required peer. `react` and `react-dom` 19 are optional
|
|
13
|
-
binding needs them (`pnpm add react react-dom`). The suite packages are installed and upgraded
|
|
14
|
-
the same version. Requires Node 22.12 or later.
|
|
12
|
+
`@zuccadev-labs/zuix-zicon` is a required peer. `react` and `react-dom` (18.2 or later, or 19) are optional
|
|
13
|
+
peers: only the binding needs them (`pnpm add react react-dom`). The suite packages are installed and upgraded
|
|
14
|
+
together, at the same version. Requires Node 22.12 or later.
|
|
15
15
|
|
|
16
16
|
To install everything with a single dependency: [`@zuccadev-labs/zuix`](https://www.npmjs.com/package/@zuccadev-labs/zuix).
|
|
17
17
|
|
|
@@ -37,6 +37,13 @@ To install everything with a single dependency: [`@zuccadev-labs/zuix`](https://
|
|
|
37
37
|
| `BottomNavigation` | Mobile navigation: three to five destinations with icon and label |
|
|
38
38
|
| `SiteFooter` | Site footer: brand, link columns, social links and legal strip |
|
|
39
39
|
| `SkipLink` | Skip-to-content link that moves focus to the target even if it is not focusable |
|
|
40
|
+
| `AppBar` | Top app bar (small, medium, large); the large title folds into the top row on scroll |
|
|
41
|
+
| `DashboardLayout`, `SettingsLayout`, `ProfileLayout`, `KanbanLayout` | Page layouts for a dashboard (sticky filters), settings (anchored navigation and a save bar), a profile and a board |
|
|
42
|
+
| `AuthLayout` | Sign-in page: a glass card on the canvas, or split with an image side |
|
|
43
|
+
| `DocsLayout` | Documentation page: navigation, article, table of contents that tracks the section being read, pager |
|
|
44
|
+
| `LandingLayout`, `LandingHero`, `LandingSection` | Landing page with a hero, feature grid, call to action and footer |
|
|
45
|
+
| `MailLayout` | Folders, message list and reader; one view at a time on narrow screens |
|
|
46
|
+
| `ChatLayout` | Conversation list, conversation and details; a stack on narrow screens that can follow the browser history. `variant="widget"` is a floating assistant |
|
|
40
47
|
|
|
41
48
|
## With React
|
|
42
49
|
|
|
@@ -110,6 +117,7 @@ The `Shell` measures its own width, not the screen:
|
|
|
110
117
|
| `@zuccadev-labs/zuix-zout` | React layouts and their types |
|
|
111
118
|
| `@zuccadev-labs/zuix-zout/dom` | Framework-free behavior: `init`, `hydrate`, `dispose`, `setPanelOpen`, `setSplitSizes`, `addWorkTab`… |
|
|
112
119
|
| `@zuccadev-labs/zuix-zout/styles.css` | Styles |
|
|
120
|
+
| `@zuccadev-labs/zuix-zout/styles.compat.css` | The same styles for Chromium 109, Firefox 115 and Safari 15.4 ([compat mode](https://github.com/zuccadev-labs/zuix/blob/main/docs/users/10-compatibilidad.md#modo-compat)) |
|
|
113
121
|
| `@zuccadev-labs/zuix-zout/manifest.json`, `@zuccadev-labs/zuix-zout/html.json` | Props, classes and markup, for tools and agents |
|
|
114
122
|
| `@zuccadev-labs/zuix-zout/dist/zout.css`, `@zuccadev-labs/zuix-zout/dist/zout.dom.js` | Bundles to link without a bundler |
|
|
115
123
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type ChatView = "list" | "conversation" | "details";
|
|
2
|
+
export declare const CHAT_VIEWS: readonly ChatView[];
|
|
3
|
+
/** Anchos del layout (px) a partir de los que caben dos y tres columnas. */
|
|
4
|
+
export declare const CHAT_TWO_COLUMNS = 720;
|
|
5
|
+
export declare const CHAT_THREE_COLUMNS = 1100;
|
|
6
|
+
export declare const isChatView: (v: unknown) => v is ChatView;
|
|
7
|
+
/** Profundidad de una vista en la pila (lista 0, conversación 1, detalles 2). */
|
|
8
|
+
export declare const viewDepth: (view: ChatView) => number;
|
|
9
|
+
/** Vista a la que vuelve el botón de atrás (o `null` desde la lista). */
|
|
10
|
+
export declare function backView(view: ChatView): ChatView | null;
|
|
11
|
+
/** Columnas que caben: 1 (pila), 2 (lista y conversación; detalles encima) o 3. */
|
|
12
|
+
export declare function chatColumns(width: number | null): 1 | 2 | 3;
|
|
13
|
+
/** Paneles que se ven con ese número de columnas y esa vista. */
|
|
14
|
+
export declare function visiblePanes(columns: 1 | 2 | 3, view: ChatView, details: boolean): ChatView[];
|
|
15
|
+
/** Siguiente panel con F6 (anterior con Mayús+F6), dando la vuelta. */
|
|
16
|
+
export declare function nextPane(panes: readonly ChatView[], current: ChatView | null, backwards?: boolean): ChatView | null;
|
|
17
|
+
/** Al cambiar de vista con el historial sincronizado: `push` si se baja en la pila, `back` si se sube, nada si igual. */
|
|
18
|
+
export declare function historyStep(from: ChatView, to: ChatView): "push" | "back" | null;
|
|
19
|
+
export interface ChatLayoutLabels {
|
|
20
|
+
list: string;
|
|
21
|
+
conversation: string;
|
|
22
|
+
details: string;
|
|
23
|
+
/** Botón flotante del asistente (`variant="widget"`). */
|
|
24
|
+
launcher: string;
|
|
25
|
+
close: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const CHAT_LAYOUT_LABELS: ChatLayoutLabels;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Lógica pura de ChatLayout, sin React ni DOM: las vistas de la pila en pantallas estrechas (lista → conversación →
|
|
2
|
+
// detalles), a cuál vuelve cada una, cuántas columnas caben en un ancho y el panel siguiente con F6. La comparten el
|
|
3
|
+
// binding de React (layouts/ChatLayout.tsx) y @zuccadev-labs/zuix-zout/dom.
|
|
4
|
+
export const CHAT_VIEWS = ["list", "conversation", "details"];
|
|
5
|
+
/** Anchos del layout (px) a partir de los que caben dos y tres columnas. */
|
|
6
|
+
export const CHAT_TWO_COLUMNS = 720;
|
|
7
|
+
export const CHAT_THREE_COLUMNS = 1100;
|
|
8
|
+
export const isChatView = (v) => typeof v === "string" && CHAT_VIEWS.includes(v);
|
|
9
|
+
/** Profundidad de una vista en la pila (lista 0, conversación 1, detalles 2). */
|
|
10
|
+
export const viewDepth = (view) => CHAT_VIEWS.indexOf(view);
|
|
11
|
+
/** Vista a la que vuelve el botón de atrás (o `null` desde la lista). */
|
|
12
|
+
export function backView(view) {
|
|
13
|
+
return view === "details" ? "conversation" : view === "conversation" ? "list" : null;
|
|
14
|
+
}
|
|
15
|
+
/** Columnas que caben: 1 (pila), 2 (lista y conversación; detalles encima) o 3. */
|
|
16
|
+
export function chatColumns(width) {
|
|
17
|
+
if (width === null)
|
|
18
|
+
return 3;
|
|
19
|
+
if (width >= CHAT_THREE_COLUMNS)
|
|
20
|
+
return 3;
|
|
21
|
+
return width >= CHAT_TWO_COLUMNS ? 2 : 1;
|
|
22
|
+
}
|
|
23
|
+
/** Paneles que se ven con ese número de columnas y esa vista. */
|
|
24
|
+
export function visiblePanes(columns, view, details) {
|
|
25
|
+
if (columns === 1)
|
|
26
|
+
return [view === "details" && !details ? "conversation" : view];
|
|
27
|
+
if (columns === 2)
|
|
28
|
+
return details && view === "details" ? ["list", "conversation", "details"] : ["list", "conversation"];
|
|
29
|
+
return details ? ["list", "conversation", "details"] : ["list", "conversation"];
|
|
30
|
+
}
|
|
31
|
+
/** Siguiente panel con F6 (anterior con Mayús+F6), dando la vuelta. */
|
|
32
|
+
export function nextPane(panes, current, backwards = false) {
|
|
33
|
+
if (!panes.length)
|
|
34
|
+
return null;
|
|
35
|
+
const i = current ? panes.indexOf(current) : -1;
|
|
36
|
+
if (i < 0)
|
|
37
|
+
return panes[backwards ? panes.length - 1 : 0];
|
|
38
|
+
return panes[(i + (backwards ? -1 : 1) + panes.length) % panes.length];
|
|
39
|
+
}
|
|
40
|
+
/** Al cambiar de vista con el historial sincronizado: `push` si se baja en la pila, `back` si se sube, nada si igual. */
|
|
41
|
+
export function historyStep(from, to) {
|
|
42
|
+
const d = viewDepth(to) - viewDepth(from);
|
|
43
|
+
return d > 0 ? "push" : d < 0 ? "back" : null;
|
|
44
|
+
}
|
|
45
|
+
export const CHAT_LAYOUT_LABELS = {
|
|
46
|
+
list: "Chats",
|
|
47
|
+
conversation: "Conversation",
|
|
48
|
+
details: "Details",
|
|
49
|
+
launcher: "Open chat",
|
|
50
|
+
close: "Close chat",
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=chat-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-layout.js","sourceRoot":"","sources":["../../src/chat-layout.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,qHAAqH;AACrH,4EAA4E;AAG5E,MAAM,CAAC,MAAM,UAAU,GAAwB,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;AAEnF,4EAA4E;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEvC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAU,EAAiB,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAK,UAAgC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAEhI,iFAAiF;AACjF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAc,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAEtE,yEAAyE;AACzE,MAAM,UAAU,QAAQ,CAAC,IAAc;IACrC,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACvF,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,WAAW,CAAC,KAAoB;IAC9C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IAC7B,IAAI,KAAK,IAAI,kBAAkB;QAAE,OAAO,CAAC,CAAC;IAC1C,OAAO,KAAK,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,YAAY,CAAC,OAA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SAAS,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAChD,CAAC;AAWD,MAAM,CAAC,MAAM,kBAAkB,GAAqB;IAClD,IAAI,EAAE,OAAO;IACb,YAAY,EAAE,cAAc;IAC5B,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,WAAW;IACrB,KAAK,EAAE,YAAY;CACpB,CAAC","sourcesContent":["// Lógica pura de ChatLayout, sin React ni DOM: las vistas de la pila en pantallas estrechas (lista → conversación →\n// detalles), a cuál vuelve cada una, cuántas columnas caben en un ancho y el panel siguiente con F6. La comparten el\n// binding de React (layouts/ChatLayout.tsx) y @zuccadev-labs/zuix-zout/dom.\n\nexport type ChatView = \"list\" | \"conversation\" | \"details\";\nexport const CHAT_VIEWS: readonly ChatView[] = [\"list\", \"conversation\", \"details\"];\n\n/** Anchos del layout (px) a partir de los que caben dos y tres columnas. */\nexport const CHAT_TWO_COLUMNS = 720;\nexport const CHAT_THREE_COLUMNS = 1100;\n\nexport const isChatView = (v: unknown): v is ChatView => typeof v === \"string\" && (CHAT_VIEWS as readonly string[]).includes(v);\n\n/** Profundidad de una vista en la pila (lista 0, conversación 1, detalles 2). */\nexport const viewDepth = (view: ChatView) => CHAT_VIEWS.indexOf(view);\n\n/** Vista a la que vuelve el botón de atrás (o `null` desde la lista). */\nexport function backView(view: ChatView): ChatView | null {\n return view === \"details\" ? \"conversation\" : view === \"conversation\" ? \"list\" : null;\n}\n\n/** Columnas que caben: 1 (pila), 2 (lista y conversación; detalles encima) o 3. */\nexport function chatColumns(width: number | null): 1 | 2 | 3 {\n if (width === null) return 3;\n if (width >= CHAT_THREE_COLUMNS) return 3;\n return width >= CHAT_TWO_COLUMNS ? 2 : 1;\n}\n\n/** Paneles que se ven con ese número de columnas y esa vista. */\nexport function visiblePanes(columns: 1 | 2 | 3, view: ChatView, details: boolean): ChatView[] {\n if (columns === 1) return [view === \"details\" && !details ? \"conversation\" : view];\n if (columns === 2) return details && view === \"details\" ? [\"list\", \"conversation\", \"details\"] : [\"list\", \"conversation\"];\n return details ? [\"list\", \"conversation\", \"details\"] : [\"list\", \"conversation\"];\n}\n\n/** Siguiente panel con F6 (anterior con Mayús+F6), dando la vuelta. */\nexport function nextPane(panes: readonly ChatView[], current: ChatView | null, backwards = false): ChatView | null {\n if (!panes.length) return null;\n const i = current ? panes.indexOf(current) : -1;\n if (i < 0) return panes[backwards ? panes.length - 1 : 0]!;\n return panes[(i + (backwards ? -1 : 1) + panes.length) % panes.length]!;\n}\n\n/** Al cambiar de vista con el historial sincronizado: `push` si se baja en la pila, `back` si se sube, nada si igual. */\nexport function historyStep(from: ChatView, to: ChatView): \"push\" | \"back\" | null {\n const d = viewDepth(to) - viewDepth(from);\n return d > 0 ? \"push\" : d < 0 ? \"back\" : null;\n}\n\nexport interface ChatLayoutLabels {\n list: string;\n conversation: string;\n details: string;\n /** Botón flotante del asistente (`variant=\"widget\"`). */\n launcher: string;\n close: string;\n}\n\nexport const CHAT_LAYOUT_LABELS: ChatLayoutLabels = {\n list: \"Chats\",\n conversation: \"Conversation\",\n details: \"Details\",\n launcher: \"Open chat\",\n close: \"Close chat\",\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ChatView } from "../chat-layout.js";
|
|
2
|
+
/** Cambia la vista de un ChatLayout (y del historial si lo sincroniza). Devuelve `false` si se canceló. */
|
|
3
|
+
export declare function setChatView(layout: HTMLElement, view: ChatView, fromHistory?: boolean): boolean;
|
|
4
|
+
/** Abre o cierra el widget flotante. */
|
|
5
|
+
export declare function setChatWidgetOpen(layout: HTMLElement, open: boolean): void;
|
|
6
|
+
export declare function onChatClick(event: MouseEvent): void;
|
|
7
|
+
export declare function onChatKeydown(event: KeyboardEvent): boolean;
|
|
8
|
+
/** Atrás del navegador: cada layout con historial vuelve a la vista guardada (o a la lista). */
|
|
9
|
+
export declare function onChatPopState(event: PopStateEvent): void;
|
|
10
|
+
/** El widget empieza cerrado salvo que diga lo contrario. */
|
|
11
|
+
export declare function hydrateChat(root: ParentNode): void;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// ChatLayout sin framework: la pila de vistas en pantalla estrecha, F6 entre paneles, el historial y el widget flotante.
|
|
2
|
+
// .z-chat-layout[data-view] vista en pantalla estrecha: list | conversation | details
|
|
3
|
+
// [data-z-chat-view="conversation"] dentro del layout: pasa a esa vista (z:viewchange { view }, cancelable)
|
|
4
|
+
// data-history en .z-chat-layout: bajar en la pila añade una entrada al historial
|
|
5
|
+
// .z-chat-layout[data-variant="widget"] .z-chat-layout__launcher abre y cierra .z-chat-layout__panel; Escape cierra
|
|
6
|
+
import { historyStep, isChatView, nextPane } from "../chat-layout.js";
|
|
7
|
+
const inDom = (el) => el.closest("[data-z-dom]") !== null;
|
|
8
|
+
const PANES = ".z-chat-layout__list, .z-chat-layout__main, .z-chat-layout__details";
|
|
9
|
+
const viewOf = (el) => el.matches(".z-chat-layout__list") ? "list" : el.matches(".z-chat-layout__details") ? "details" : "conversation";
|
|
10
|
+
function emit(el, name, detail) {
|
|
11
|
+
return el.dispatchEvent(new CustomEvent(`z:${name}`, { detail, bubbles: true, cancelable: true }));
|
|
12
|
+
}
|
|
13
|
+
/** Cambia la vista de un ChatLayout (y del historial si lo sincroniza). Devuelve `false` si se canceló. */
|
|
14
|
+
export function setChatView(layout, view, fromHistory = false) {
|
|
15
|
+
const from = isChatView(layout.dataset.view) ? layout.dataset.view : "conversation";
|
|
16
|
+
if (from === view)
|
|
17
|
+
return true;
|
|
18
|
+
if (!emit(layout, "viewchange", { view }))
|
|
19
|
+
return false;
|
|
20
|
+
layout.dataset.view = view;
|
|
21
|
+
if (layout.hasAttribute("data-history") && !fromHistory && historyStep(from, view) === "push")
|
|
22
|
+
window.history.pushState({ ...(window.history.state ?? {}), zChatView: view }, "");
|
|
23
|
+
const pane = [...layout.querySelectorAll(PANES)].find((p) => viewOf(p) === view);
|
|
24
|
+
if (pane?.getClientRects().length)
|
|
25
|
+
(pane.querySelector("h1, h2, h3, [tabindex='0']") ?? pane).focus?.({ preventScroll: true });
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
/** Abre o cierra el widget flotante. */
|
|
29
|
+
export function setChatWidgetOpen(layout, open) {
|
|
30
|
+
const panel = layout.querySelector(".z-chat-layout__panel");
|
|
31
|
+
const launcher = layout.querySelector(".z-chat-layout__launcher");
|
|
32
|
+
if (!panel)
|
|
33
|
+
return;
|
|
34
|
+
panel.hidden = !open;
|
|
35
|
+
layout.toggleAttribute("data-open", open);
|
|
36
|
+
launcher?.setAttribute("aria-expanded", String(open));
|
|
37
|
+
if (!emit(layout, open ? "open" : "close", {}))
|
|
38
|
+
return;
|
|
39
|
+
if (open)
|
|
40
|
+
(panel.querySelector("textarea, input, button") ?? panel).focus?.();
|
|
41
|
+
else
|
|
42
|
+
launcher?.focus();
|
|
43
|
+
}
|
|
44
|
+
function cycle(layout, backwards) {
|
|
45
|
+
const panes = [...layout.querySelectorAll(PANES)].filter((p) => p.closest(".z-chat-layout") === layout && p.getClientRects().length > 0);
|
|
46
|
+
const current = panes.find((p) => p.contains(document.activeElement));
|
|
47
|
+
const next = nextPane(panes.map(viewOf), current ? viewOf(current) : null, backwards);
|
|
48
|
+
const pane = panes.find((p) => viewOf(p) === next);
|
|
49
|
+
if (!pane)
|
|
50
|
+
return false;
|
|
51
|
+
const target = [...pane.querySelectorAll('[tabindex="0"], input, textarea, button:not([disabled]), a[href]')].find((el) => el.getClientRects().length > 0);
|
|
52
|
+
// Un panel sin nada enfocable recibe el foco él mismo (programático, fuera del orden de Tab).
|
|
53
|
+
if (!target && !pane.hasAttribute("tabindex"))
|
|
54
|
+
pane.tabIndex = -1;
|
|
55
|
+
(target ?? pane).focus();
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
export function onChatClick(event) {
|
|
59
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
60
|
+
const layout = target?.closest(".z-chat-layout");
|
|
61
|
+
if (!target || !layout || !inDom(layout))
|
|
62
|
+
return;
|
|
63
|
+
const launcher = target.closest(".z-chat-layout__launcher");
|
|
64
|
+
if (launcher) {
|
|
65
|
+
setChatWidgetOpen(layout, !layout.hasAttribute("data-open"));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const to = target.closest("[data-z-chat-view]")?.dataset.zChatView;
|
|
69
|
+
if (isChatView(to))
|
|
70
|
+
setChatView(layout, to);
|
|
71
|
+
}
|
|
72
|
+
export function onChatKeydown(event) {
|
|
73
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
74
|
+
const layout = target?.closest(".z-chat-layout");
|
|
75
|
+
if (!layout || !inDom(layout))
|
|
76
|
+
return false;
|
|
77
|
+
if (event.key === "F6" && cycle(layout, event.shiftKey)) {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
if (event.key === "Escape" && layout.dataset.variant === "widget" && layout.hasAttribute("data-open") && !event.defaultPrevented) {
|
|
82
|
+
setChatWidgetOpen(layout, false);
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
/** Atrás del navegador: cada layout con historial vuelve a la vista guardada (o a la lista). */
|
|
88
|
+
export function onChatPopState(event) {
|
|
89
|
+
const saved = event.state?.zChatView;
|
|
90
|
+
for (const layout of document.querySelectorAll(".z-chat-layout[data-history]"))
|
|
91
|
+
if (inDom(layout))
|
|
92
|
+
setChatView(layout, isChatView(saved) ? saved : "list", true);
|
|
93
|
+
}
|
|
94
|
+
/** El widget empieza cerrado salvo que diga lo contrario. */
|
|
95
|
+
export function hydrateChat(root) {
|
|
96
|
+
const found = [...root.querySelectorAll('.z-chat-layout[data-variant="widget"]')];
|
|
97
|
+
for (const layout of found) {
|
|
98
|
+
if (!inDom(layout))
|
|
99
|
+
continue;
|
|
100
|
+
const panel = layout.querySelector(".z-chat-layout__panel");
|
|
101
|
+
if (panel)
|
|
102
|
+
panel.hidden = !layout.hasAttribute("data-open");
|
|
103
|
+
layout.querySelector(".z-chat-layout__launcher")?.setAttribute("aria-expanded", String(layout.hasAttribute("data-open")));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../../src/dom/chat.ts"],"names":[],"mappings":"AAAA,yHAAyH;AACzH,sGAAsG;AACtG,oHAAoH;AACpH,+GAA+G;AAC/G,wHAAwH;AACxH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAiB,MAAM,gBAAgB,CAAC;AAElF,MAAM,KAAK,GAAG,CAAC,EAAW,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;AACnE,MAAM,KAAK,GAAG,qEAAqE,CAAC;AACpF,MAAM,MAAM,GAAG,CAAC,EAAW,EAAY,EAAE,CACvC,EAAE,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC;AAEnH,SAAS,IAAI,CAAC,EAAe,EAAE,IAAY,EAAE,MAAe;IAC1D,OAAO,EAAE,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,KAAK,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACrG,CAAC;AAED,2GAA2G;AAC3G,MAAM,UAAU,WAAW,CAAC,MAAmB,EAAE,IAAc,EAAE,WAAW,GAAG,KAAK;IAClF,MAAM,IAAI,GAA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Ac,uCAAuC,CAAC,CAAC,CAAC;IAC/F,KAAK,MAAM,MAAM,IAAI,KAAK,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;YAAE,SAAS;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,aAAa,CAAc,uBAAuB,CAAC,CAAC;QACzE,IAAI,KAAK;YAAE,KAAK,CAAC,MAAM,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QAC5D,MAAM,CAAC,aAAa,CAAC,0BAA0B,CAAC,EAAE,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAC5H,CAAC;AACH,CAAC","sourcesContent":["// ChatLayout sin framework: la pila de vistas en pantalla estrecha, F6 entre paneles, el historial y el widget flotante.\n// .z-chat-layout[data-view] vista en pantalla estrecha: list | conversation | details\n// [data-z-chat-view=\"conversation\"] dentro del layout: pasa a esa vista (z:viewchange { view }, cancelable)\n// data-history en .z-chat-layout: bajar en la pila añade una entrada al historial\n// .z-chat-layout[data-variant=\"widget\"] .z-chat-layout__launcher abre y cierra .z-chat-layout__panel; Escape cierra\nimport { historyStep, isChatView, nextPane, type ChatView } from \"../chat-layout\";\n\nconst inDom = (el: Element) => el.closest(\"[data-z-dom]\") !== null;\nconst PANES = \".z-chat-layout__list, .z-chat-layout__main, .z-chat-layout__details\";\nconst viewOf = (el: Element): ChatView =>\n el.matches(\".z-chat-layout__list\") ? \"list\" : el.matches(\".z-chat-layout__details\") ? \"details\" : \"conversation\";\n\nfunction emit(el: HTMLElement, name: string, detail: unknown): boolean {\n return el.dispatchEvent(new CustomEvent(`z:${name}`, { detail, bubbles: true, cancelable: true }));\n}\n\n/** Cambia la vista de un ChatLayout (y del historial si lo sincroniza). Devuelve `false` si se canceló. */\nexport function setChatView(layout: HTMLElement, view: ChatView, fromHistory = false): boolean {\n const from = isChatView(layout.dataset.view) ? layout.dataset.view : \"conversation\";\n if (from === view) return true;\n if (!emit(layout, \"viewchange\", { view })) return false;\n layout.dataset.view = view;\n if (layout.hasAttribute(\"data-history\") && !fromHistory && historyStep(from, view) === \"push\")\n window.history.pushState({ ...(window.history.state ?? {}), zChatView: view }, \"\");\n const pane = [...layout.querySelectorAll<HTMLElement>(PANES)].find((p) => viewOf(p) === view);\n if (pane?.getClientRects().length)\n (pane.querySelector<HTMLElement>(\"h1, h2, h3, [tabindex='0']\") ?? pane).focus?.({ preventScroll: true });\n return true;\n}\n\n/** Abre o cierra el widget flotante. */\nexport function setChatWidgetOpen(layout: HTMLElement, open: boolean): void {\n const panel = layout.querySelector<HTMLElement>(\".z-chat-layout__panel\");\n const launcher = layout.querySelector<HTMLButtonElement>(\".z-chat-layout__launcher\");\n if (!panel) return;\n panel.hidden = !open;\n layout.toggleAttribute(\"data-open\", open);\n launcher?.setAttribute(\"aria-expanded\", String(open));\n if (!emit(layout, open ? \"open\" : \"close\", {})) return;\n if (open) (panel.querySelector<HTMLElement>(\"textarea, input, button\") ?? panel).focus?.();\n else launcher?.focus();\n}\n\nfunction cycle(layout: HTMLElement, backwards: boolean): boolean {\n const panes = [...layout.querySelectorAll<HTMLElement>(PANES)].filter(\n (p) => p.closest(\".z-chat-layout\") === layout && p.getClientRects().length > 0,\n );\n const current = panes.find((p) => p.contains(document.activeElement));\n const next = nextPane(panes.map(viewOf), current ? viewOf(current) : null, backwards);\n const pane = panes.find((p) => viewOf(p) === next);\n if (!pane) return false;\n const target = [...pane.querySelectorAll<HTMLElement>('[tabindex=\"0\"], input, textarea, button:not([disabled]), a[href]')].find(\n (el) => el.getClientRects().length > 0,\n );\n // Un panel sin nada enfocable recibe el foco él mismo (programático, fuera del orden de Tab).\n if (!target && !pane.hasAttribute(\"tabindex\")) pane.tabIndex = -1;\n (target ?? pane).focus();\n return true;\n}\n\nexport function onChatClick(event: MouseEvent): void {\n const target = event.target instanceof Element ? event.target : null;\n const layout = target?.closest<HTMLElement>(\".z-chat-layout\");\n if (!target || !layout || !inDom(layout)) return;\n const launcher = target.closest(\".z-chat-layout__launcher\");\n if (launcher) {\n setChatWidgetOpen(layout, !layout.hasAttribute(\"data-open\"));\n return;\n }\n const to = target.closest<HTMLElement>(\"[data-z-chat-view]\")?.dataset.zChatView;\n if (isChatView(to)) setChatView(layout, to);\n}\n\nexport function onChatKeydown(event: KeyboardEvent): boolean {\n const target = event.target instanceof Element ? event.target : null;\n const layout = target?.closest<HTMLElement>(\".z-chat-layout\");\n if (!layout || !inDom(layout)) return false;\n if (event.key === \"F6\" && cycle(layout, event.shiftKey)) {\n event.preventDefault();\n return true;\n }\n if (event.key === \"Escape\" && layout.dataset.variant === \"widget\" && layout.hasAttribute(\"data-open\") && !event.defaultPrevented) {\n setChatWidgetOpen(layout, false);\n return true;\n }\n return false;\n}\n\n/** Atrás del navegador: cada layout con historial vuelve a la vista guardada (o a la lista). */\nexport function onChatPopState(event: PopStateEvent): void {\n const saved = (event.state as { zChatView?: unknown } | null)?.zChatView;\n for (const layout of document.querySelectorAll<HTMLElement>(\".z-chat-layout[data-history]\"))\n if (inDom(layout)) setChatView(layout, isChatView(saved) ? saved : \"list\", true);\n}\n\n/** El widget empieza cerrado salvo que diga lo contrario. */\nexport function hydrateChat(root: ParentNode): void {\n const found = [...root.querySelectorAll<HTMLElement>('.z-chat-layout[data-variant=\"widget\"]')];\n for (const layout of found) {\n if (!inDom(layout)) continue;\n const panel = layout.querySelector<HTMLElement>(\".z-chat-layout__panel\");\n if (panel) panel.hidden = !layout.hasAttribute(\"data-open\");\n layout.querySelector(\".z-chat-layout__launcher\")?.setAttribute(\"aria-expanded\", String(layout.hasAttribute(\"data-open\")));\n }\n}\n"]}
|
package/dist/esm/dom/index.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ export declare function getPaneLayout(layout: HTMLElement): PaneNode | null;
|
|
|
70
70
|
export declare function setPaneLayout(layout: HTMLElement, tree: PaneNode, extra?: HTMLElement[]): void;
|
|
71
71
|
/** Divide el panel `id` y pone `pane` (un `.z-panelayout__pane[data-pane-id]` nuevo) a su lado. */
|
|
72
72
|
export declare function splitLayoutPane(layout: HTMLElement, id: string, pane: HTMLElement, direction: "row" | "column"): void;
|
|
73
|
+
export { setChatView, setChatWidgetOpen } from "./chat.js";
|
|
73
74
|
/** Prepara el marcado bajo `[data-z-dom]`: mide los shells, completa divisores y pestañas. Repetible. */
|
|
74
75
|
export declare function hydrate(root?: ParentNode): void;
|
|
75
76
|
/**
|
package/dist/esm/dom/index.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// data-z-shell-toggle="sidebar|inspector" botón que abre o cierra ese panel (data-z-shell="#id" si está fuera del shell)
|
|
15
15
|
// data-z-close dentro de un cajón del shell: lo cierra
|
|
16
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
|
|
17
18
|
// data-panel-mode="auto|docked|overlay" en el <aside>: preferencia de modo (auto por defecto)
|
|
18
19
|
// hidden en el <aside>: panel cerrado
|
|
19
20
|
// data-close-label en .z-shell: nombre accesible del velo
|
|
@@ -39,20 +40,40 @@
|
|
|
39
40
|
// .z-sidebar__trigger[aria-controls] botón que pliega y despliega la sidebar; data-shortcut: Ctrl/⌘+B
|
|
40
41
|
// La sidebar plegada usa del modo sin framework de zui el tooltip (`data-z-tooltip`) y el popover anclado
|
|
41
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)
|
|
42
46
|
// .z-navbar / .z-navmenu navegación de sitio (./site): fila o cajón medido sin punto de corte fijo y
|
|
43
47
|
// grupos de disclosure con panel; .z-skiplink; .z-bottomnav con botones
|
|
44
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
|
|
45
52
|
// Tras insertar marcado nuevo: hydrate(contenedor).
|
|
46
53
|
// Eventos (burbujean y se pueden cancelar): z:modechange, z:open, z:close, z:resize, z:select, z:add, z:change.
|
|
47
54
|
import { iconElement, registerIcons } from "@zuccadev-labs/zuix-zicon/dom";
|
|
48
55
|
import { edgeMargin, trackScrollEdges } from "../edges.js";
|
|
56
|
+
import { disposePages, hydratePages } from "./pages.js";
|
|
49
57
|
import { disposeSite, hydrateSite, onSiteClick } from "./site.js";
|
|
58
|
+
import { hydrateChat, onChatClick, onChatKeydown, onChatPopState } from "./chat.js";
|
|
50
59
|
import { chevronDoubleLeft } from "@zuccadev-labs/zuix-zicon/icons/chevron-double-left";
|
|
51
60
|
import { chevronDoubleRight } from "@zuccadev-labs/zuix-zicon/icons/chevron-double-right";
|
|
52
61
|
import { chevronDownSmall } from "@zuccadev-labs/zuix-zicon/icons/chevron-down-small";
|
|
53
62
|
import { chevronRightSmall } from "@zuccadev-labs/zuix-zicon/icons/chevron-right-small";
|
|
54
63
|
import { xMark } from "@zuccadev-labs/zuix-zicon/icons/x-mark";
|
|
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";
|
|
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
|
+
}
|
|
56
77
|
// Iconos que este módulo dibuja por su cuenta cuando el marcado no usa <z-icon>.
|
|
57
78
|
registerIcons([xMark, chevronDownSmall, chevronRightSmall, chevronDoubleLeft, chevronDoubleRight]);
|
|
58
79
|
const isBrowser = typeof document !== "undefined";
|
|
@@ -128,6 +149,20 @@ function syncShell(shell) {
|
|
|
128
149
|
// Con un cajón abierto, el panel que siga acoplado queda bajo el velo.
|
|
129
150
|
el.inert = drawerOpen && mode === "docked";
|
|
130
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
|
+
}
|
|
131
166
|
for (const zone of body.querySelectorAll(":scope > .z-shell__rail, :scope > .z-shell__main"))
|
|
132
167
|
zone.inert = drawerOpen;
|
|
133
168
|
let scrim = body.querySelector(":scope > .z-shell__scrim");
|
|
@@ -709,7 +744,7 @@ export function setSidebarCollapsed(sidebar, collapsed, silent = false) {
|
|
|
709
744
|
link.setAttribute("aria-expanded", "false");
|
|
710
745
|
}
|
|
711
746
|
else {
|
|
712
|
-
if (sub
|
|
747
|
+
if (inOpenLayer(sub, false))
|
|
713
748
|
sub.hidePopover();
|
|
714
749
|
sub.removeAttribute("popover");
|
|
715
750
|
sub.classList.remove("z-liquid");
|
|
@@ -1047,7 +1082,7 @@ function onKeydown(event) {
|
|
|
1047
1082
|
return;
|
|
1048
1083
|
// Escape cierra el cajón abierto, salvo que lo haya gestionado otro (un diálogo o un menú por encima).
|
|
1049
1084
|
if (event.key === "Escape") {
|
|
1050
|
-
if (event.defaultPrevented || target.closest("dialog[open]
|
|
1085
|
+
if (event.defaultPrevented || target.closest("dialog[open]") || inOpenLayer(target))
|
|
1051
1086
|
return;
|
|
1052
1087
|
const panel = target.closest(".z-floatpanel");
|
|
1053
1088
|
if (panel && inDom(panel) && panel.querySelector(".z-floatpanel__close")) {
|
|
@@ -1267,6 +1302,7 @@ function onDoubleClick(event) {
|
|
|
1267
1302
|
if (defaultSize !== undefined)
|
|
1268
1303
|
resizeTo(handle, defaultSize);
|
|
1269
1304
|
}
|
|
1305
|
+
export { setChatView, setChatWidgetOpen } from "./chat.js";
|
|
1270
1306
|
/** Prepara el marcado bajo `[data-z-dom]`: mide los shells, completa divisores y pestañas. Repetible. */
|
|
1271
1307
|
export function hydrate(root = document) {
|
|
1272
1308
|
if (!isBrowser)
|
|
@@ -1285,6 +1321,8 @@ export function hydrate(root = document) {
|
|
|
1285
1321
|
for (const layout of all(root, ".z-panelayout"))
|
|
1286
1322
|
syncPaneFocus(layout);
|
|
1287
1323
|
hydrateSite(root);
|
|
1324
|
+
hydrateChat(root);
|
|
1325
|
+
hydratePages(root);
|
|
1288
1326
|
for (const handle of all(root, ".z-resize")) {
|
|
1289
1327
|
// Un tirador escrito solo con su clase recibe el rol y los atributos del patrón «window splitter».
|
|
1290
1328
|
if (!handle.hasAttribute("role"))
|
|
@@ -1311,6 +1349,7 @@ export function dispose(root = document) {
|
|
|
1311
1349
|
if (!isBrowser)
|
|
1312
1350
|
return;
|
|
1313
1351
|
disposeSite(root);
|
|
1352
|
+
disposePages(root);
|
|
1314
1353
|
for (const shell of all(root, ".z-shell")) {
|
|
1315
1354
|
shellObserver?.unobserve(shell);
|
|
1316
1355
|
shells.delete(shell);
|
|
@@ -1331,7 +1370,10 @@ export function init() {
|
|
|
1331
1370
|
wired = true;
|
|
1332
1371
|
document.addEventListener("click", onClick);
|
|
1333
1372
|
document.addEventListener("click", onSiteClick);
|
|
1373
|
+
document.addEventListener("click", onChatClick);
|
|
1374
|
+
document.addEventListener("keydown", onChatKeydown);
|
|
1334
1375
|
document.addEventListener("keydown", onKeydown);
|
|
1376
|
+
window.addEventListener("popstate", onChatPopState);
|
|
1335
1377
|
document.addEventListener("dblclick", onDoubleClick);
|
|
1336
1378
|
document.addEventListener("pointerdown", onPointerDown);
|
|
1337
1379
|
document.addEventListener("pointermove", (event) => {
|