@sincpro/web-ui 1.8.0 → 1.10.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 (57) hide show
  1. package/dist/components/canvas/Canvas.d.ts +14 -0
  2. package/dist/components/canvas/Canvas.js +9 -0
  3. package/dist/components/canvas/canvas.css +19 -0
  4. package/dist/components/canvas/index.d.ts +1 -0
  5. package/dist/components/canvas/index.js +2 -0
  6. package/dist/components/chat/ChatComposer.d.ts +10 -0
  7. package/dist/components/chat/ChatComposer.js +29 -0
  8. package/dist/components/chat/ChatThread.d.ts +13 -0
  9. package/dist/components/chat/ChatThread.js +76 -0
  10. package/dist/components/chat/ConversationList.d.ts +22 -0
  11. package/dist/components/chat/ConversationList.js +22 -0
  12. package/dist/components/chat/index.d.ts +4 -0
  13. package/dist/components/chat/index.js +5 -0
  14. package/dist/components/chat/model.d.ts +30 -0
  15. package/dist/components/chat/model.js +53 -0
  16. package/dist/components/index.d.ts +3 -0
  17. package/dist/components/index.js +3 -0
  18. package/dist/components/listing/ColumnsMenu.d.ts +7 -1
  19. package/dist/components/listing/ColumnsMenu.js +16 -5
  20. package/dist/components/listing/GroupingLevels.d.ts +5 -1
  21. package/dist/components/listing/GroupingLevels.js +7 -4
  22. package/dist/components/listing/ListingBar.js +2 -2
  23. package/dist/components/preview/FilePreview.d.ts +19 -0
  24. package/dist/components/preview/FilePreview.js +112 -0
  25. package/dist/components/preview/PdfPreview.d.ts +7 -0
  26. package/dist/components/preview/PdfPreview.js +47 -0
  27. package/dist/components/preview/index.d.ts +1 -0
  28. package/dist/components/preview/index.js +2 -0
  29. package/dist/components/record/RecordAudit.d.ts +26 -5
  30. package/dist/components/record/RecordAudit.js +54 -13
  31. package/dist/components/record/SmartButtons.js +1 -1
  32. package/dist/components/search/FieldPath.d.ts +54 -0
  33. package/dist/components/search/FieldPath.js +159 -0
  34. package/dist/components/search/FilterBuilder.d.ts +38 -5
  35. package/dist/components/search/FilterBuilder.js +129 -25
  36. package/dist/components/search/SearchBar.js +7 -2
  37. package/dist/components/search/criteria.d.ts +23 -1
  38. package/dist/components/search/index.d.ts +4 -2
  39. package/dist/components/search/index.js +4 -0
  40. package/dist/components/search/paths.d.ts +49 -0
  41. package/dist/components/search/paths.js +75 -0
  42. package/dist/components/shell/TopBar.js +1 -1
  43. package/dist/foundations/copy.d.ts +88 -1
  44. package/dist/foundations/copy.es.js +65 -2
  45. package/dist/foundations/copy.js +59 -2
  46. package/dist/primitives/field/Field.js +2 -1
  47. package/dist/primitives/notice/Callout.d.ts +4 -1
  48. package/dist/primitives/notice/Callout.js +12 -2
  49. package/dist/primitives/notice/Notice.d.ts +26 -2
  50. package/dist/primitives/notice/Notice.js +64 -4
  51. package/dist/primitives/notice/Toast.js +10 -1
  52. package/dist/primitives/value/Markdown.d.ts +9 -0
  53. package/dist/primitives/value/Markdown.js +18 -0
  54. package/dist/primitives/value/index.d.ts +1 -0
  55. package/dist/primitives/value/index.js +1 -0
  56. package/dist/tokens.css +28 -0
  57. package/package.json +4 -1
@@ -0,0 +1,14 @@
1
+ import "@sincpro/web-ui/components/canvas/canvas.css";
2
+ import { type Connection, type Edge, type EdgeChange, type Node, type NodeChange } from "@xyflow/react";
3
+ export type CanvasProps<N extends Node = Node, E extends Edge = Edge> = {
4
+ nodes: N[];
5
+ edges: E[];
6
+ onNodesChange?: (changes: NodeChange<N>[]) => void;
7
+ onEdgesChange?: (changes: EdgeChange<E>[]) => void;
8
+ onConnect?: (connection: Connection) => void;
9
+ /** Shown, not edited: no dragging, no connecting, no selecting what is not there. */
10
+ readOnly?: boolean;
11
+ /** The accessible name of the region. «Lienzo» by default. */
12
+ label?: string;
13
+ };
14
+ export declare function Canvas<N extends Node = Node, E extends Edge = Edge>({ nodes, edges, onNodesChange, onEdgesChange, onConnect, readOnly, label, }: CanvasProps<N, E>): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import "@sincpro/web-ui/components/canvas/canvas.css";
4
+ import { useUiCopy } from "../../foundations/copy.js";
5
+ import { Background, Controls, ReactFlow, } from "@xyflow/react";
6
+ export function Canvas({ nodes, edges, onNodesChange, onEdgesChange, onConnect, readOnly = false, label, }) {
7
+ const copy = useUiCopy();
8
+ return (_jsxs("div", { role: "region", "aria-label": label ?? copy.canvas.label, className: "relative h-96 min-h-0 w-full overflow-hidden rounded-control border border-line bg-ground", children: [_jsxs(ReactFlow, { nodes: nodes, edges: edges, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onConnect: onConnect, nodesDraggable: !readOnly, nodesConnectable: !readOnly, elementsSelectable: !readOnly, fitView: true, "aria-label": label ?? copy.canvas.label, children: [_jsx(Background, {}), _jsx(Controls, { showInteractive: !readOnly })] }), readOnly ? (_jsx("span", { className: "pointer-events-none absolute top-3 left-3 rounded-control border border-line bg-surface px-2 py-0.5 text-micro font-medium text-muted", children: copy.canvas.readOnly })) : null] }));
9
+ }
@@ -0,0 +1,19 @@
1
+ /* React Flow's own stylesheet, then the product's tokens on top of it. Its variables
2
+ are the only hook the library offers for colour, so the canvas reads as the same
3
+ paper and ink as the rest of the screen, in light and dark alike. */
4
+ @import "@xyflow/react/dist/style.css";
5
+
6
+ .react-flow {
7
+ --xy-background-color: var(--color-ground);
8
+ --xy-node-background-color-default: var(--color-surface);
9
+ --xy-node-border-default: 1px solid var(--color-line-strong);
10
+ --xy-node-boxshadow-selected: 0 0 0 2px var(--color-primary);
11
+ --xy-edge-stroke-default: var(--color-muted);
12
+ --xy-edge-stroke-selected-default: var(--color-primary);
13
+ --xy-controls-button-background-color-default: var(--color-surface);
14
+ --xy-controls-button-border-color-default: var(--color-line);
15
+ --xy-controls-button-color-default: var(--color-ink);
16
+ --xy-minimap-background-color-default: var(--color-surface);
17
+ --xy-minimap-mask-background-color-default: var(--color-scrim);
18
+ --xy-handle-background-color-default: var(--color-primary);
19
+ }
@@ -0,0 +1 @@
1
+ export { Canvas, type CanvasProps } from "./Canvas.js";
@@ -0,0 +1,2 @@
1
+ /* A canvas of nodes and connections, controlled by the application. */
2
+ export { Canvas } from "./Canvas.js";
@@ -0,0 +1,10 @@
1
+ export type ChatComposerProps = {
2
+ /** The text, trimmed, when it is sent. */
3
+ onSend: (text: string) => void;
4
+ /** The conversation is closed, or the application is not connected. */
5
+ disabled?: boolean;
6
+ /** The accessible name of the box. «Mensaje» by default. */
7
+ label?: string;
8
+ placeholder?: string;
9
+ };
10
+ export declare function ChatComposer({ onSend, disabled, label, placeholder, }: ChatComposerProps): import("react").JSX.Element;
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useUiCopy } from "../../foundations/copy.js";
4
+ import { Button } from "../../primitives/button/Button.js";
5
+ import { TextArea } from "../../primitives/field/Field.js";
6
+ import { Send } from "lucide-react";
7
+ import { useState } from "react";
8
+ export function ChatComposer({ onSend, disabled = false, label, placeholder, }) {
9
+ const copy = useUiCopy();
10
+ const [text, setText] = useState("");
11
+ const body = text.trim();
12
+ const blocked = disabled || body === "";
13
+ function send() {
14
+ if (blocked)
15
+ return;
16
+ onSend(body);
17
+ setText("");
18
+ }
19
+ function onKeyDown(event) {
20
+ if (event.key !== "Enter" || event.shiftKey || event.nativeEvent.isComposing)
21
+ return;
22
+ event.preventDefault();
23
+ send();
24
+ }
25
+ return (_jsxs("div", { onKeyDown: onKeyDown,
26
+ /* A container, so the send button follows the width of the COMPOSER, not of the
27
+ screen: in a narrow side panel on a desk it is as tight as on a phone. */
28
+ className: "@container flex items-end gap-3 border-t border-line bg-surface px-5 py-4", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(TextArea, { value: text, onChange: setText, rows: 2, disabled: disabled, "aria-label": label ?? copy.chat.composer, placeholder: placeholder ?? copy.chat.placeholder }) }), _jsx(Button, { role: "secondary", icon: Send, disabled: blocked, onClick: send, children: _jsx("span", { className: "sr-only @xs:not-sr-only", children: copy.chat.send }) })] }));
29
+ }
@@ -0,0 +1,13 @@
1
+ import { type ChatMessage } from "./model.js";
2
+ export type ChatThreadProps = {
3
+ messages: readonly ChatMessage[];
4
+ /** Present = the top draws «Cargar mensajes anteriores». */
5
+ onLoadOlder?: () => void;
6
+ /** The application is fetching the earlier page right now. */
7
+ loadingOlder?: boolean;
8
+ /** The accessible name of the log. «Conversación» by default. */
9
+ label?: string;
10
+ /** The «now» the day names are relative to. */
11
+ now?: Date;
12
+ };
13
+ export declare function ChatThread({ messages, onLoadOlder, loadingOlder, label, now, }: ChatThreadProps): import("react").JSX.Element;
@@ -0,0 +1,76 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { dayLabel, groupByDay, startsRun, } from "./model.js";
4
+ import { useUiCopy } from "../../foundations/copy.js";
5
+ import { Button } from "../../primitives/button/Button.js";
6
+ import { Empty } from "../../primitives/notice/Notice.js";
7
+ import { useLayoutEffect, useRef, useState } from "react";
8
+ /* ==================================================================== *
9
+ * THE THREAD — a conversation read from the first message to the last.
10
+ *
11
+ * Context: the chat of a CRM or a help desk is read like WhatsApp or Telegram:
12
+ * the newest message is at the bottom, the older ones are above, and the
13
+ * reading starts where it ended. So the thread OPENS at the bottom, STAYS
14
+ * there while new messages arrive IF the person is already there, and does
15
+ * not drag them down when they are reading something above.
16
+ *
17
+ * ── Reading up is never interrupted ─────────────────────────────────
18
+ *
19
+ * Scrolled up, a new message does not move the view; a button «Ir al último
20
+ * mensaje» brings them back. Scrolled to the bottom, the thread follows.
21
+ *
22
+ * ── Older messages are asked for, not poured in ─────────────────────
23
+ *
24
+ * `onLoadOlder` draws a button at the top. The application fetches the
25
+ * earlier page and prepends it; the thread keeps the reading where it was by
26
+ * the application's own paging, not by a scroll guess here.
27
+ *
28
+ * ── Days and runs ───────────────────────────────────────────────────
29
+ *
30
+ * A separator names each day («Hoy», «Ayer», the date written out). Messages
31
+ * from the same author in a row share one name above them: the eye reads
32
+ * the run as one voice.
33
+ * ==================================================================== */
34
+ /** How close to the bottom still counts as «at the bottom», in pixels. */
35
+ const AT_BOTTOM = 48;
36
+ export function ChatThread({ messages, onLoadOlder, loadingOlder = false, label, now, }) {
37
+ const copy = useUiCopy();
38
+ const scroller = useRef(null);
39
+ /* A ref, not state: the scroll handler writes it on every frame and nothing
40
+ draws from it, so it must not cause a render. */
41
+ const pinned = useRef(true);
42
+ const [showJump, setShowJump] = useState(false);
43
+ const clock = now ?? new Date();
44
+ /* Runs after the messages change and before the paint: the thread moves to the
45
+ newest message in the same frame, so nobody sees it open at the top. */
46
+ useLayoutEffect(() => {
47
+ const el = scroller.current;
48
+ if (el === null || !pinned.current)
49
+ return;
50
+ el.scrollTop = el.scrollHeight;
51
+ }, [messages]);
52
+ function onScroll(event) {
53
+ const el = event.currentTarget;
54
+ const distance = el.scrollHeight - el.scrollTop - el.clientHeight;
55
+ pinned.current = distance < AT_BOTTOM;
56
+ setShowJump(!pinned.current);
57
+ }
58
+ function toLatest() {
59
+ const el = scroller.current;
60
+ if (el === null)
61
+ return;
62
+ el.scrollTo({ top: el.scrollHeight, behavior: "smooth" });
63
+ pinned.current = true;
64
+ setShowJump(false);
65
+ }
66
+ const groups = groupByDay(messages);
67
+ const words = { today: copy.chat.today, yesterday: copy.chat.yesterday };
68
+ return (_jsxs("div", { className: "relative flex min-h-0 flex-1 flex-col", children: [_jsxs("div", { ref: scroller, role: "log",
69
+ /* A scrollable region is reachable by keyboard (axe): the arrows scroll it. */
70
+ tabIndex: 0, "aria-label": label ?? copy.chat.thread, "aria-live": "polite", onScroll: onScroll, className: "flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto px-5 py-4", children: [onLoadOlder === undefined ? null : (_jsx("div", { className: "flex justify-center pb-3", children: _jsx(Button, { role: "ghost", size: "sm", disabled: loadingOlder, onClick: onLoadOlder, children: loadingOlder ? copy.chat.loadingOlder : copy.chat.loadOlder }) })), messages.length === 0 ? _jsx(Empty, { sentence: copy.chat.empty }) : null, groups.map((group) => (_jsxs("section", { className: "flex flex-col gap-1", children: [_jsx("div", { className: "my-3 flex justify-center", children: _jsx("span", { className: "rounded-control border border-line bg-surface px-3 py-0.5 text-micro font-medium text-muted", children: dayLabel(group.day, clock, words, copy.locale) }) }), group.messages.map((message, index) => (_jsx(Bubble, { message: message, first: startsRun(group.messages, index), locale: copy.locale }, message.id)))] }, group.key)))] }), showJump ? (_jsx("div", { className: "pointer-events-none absolute inset-x-0 bottom-3 flex justify-center", children: _jsx("div", { className: "pointer-events-auto", children: _jsx(Button, { role: "secondary", size: "sm", onClick: toLatest, children: copy.chat.jumpLatest }) }) })) : null] }));
71
+ }
72
+ function Bubble({ message, first, locale, }) {
73
+ const copy = useUiCopy();
74
+ const time = new Intl.DateTimeFormat(locale, { hour: "2-digit", minute: "2-digit" }).format(message.at);
75
+ return (_jsx("div", { className: `flex ${message.mine ? "justify-end" : "justify-start"} ${first ? "mt-2" : ""}`, children: _jsxs("div", { className: `max-w-prose rounded-control border px-3 py-2 ${message.mine ? "border-primary/30 bg-primary/10" : "border-line bg-surface"} ${message.pending === true ? "opacity-70" : ""}`, children: [first && !message.mine ? (_jsx("p", { className: "text-meta font-medium text-muted", children: message.author })) : null, _jsx("p", { className: "text-body break-words whitespace-pre-wrap text-ink", children: message.body }), _jsxs("p", { className: "mt-1 text-micro text-muted", children: [_jsx("time", { dateTime: message.at.toISOString(), children: time }), message.pending === true ? ` · ${copy.chat.sending}` : null] })] }) }));
76
+ }
@@ -0,0 +1,22 @@
1
+ export type Conversation = {
2
+ id: string;
3
+ /** Who, or what, the conversation is with. */
4
+ title: string;
5
+ /** The last message, cut to one line by the row. */
6
+ preview?: string;
7
+ /** When the last message was written. */
8
+ at?: Date;
9
+ /** Messages nobody has read yet in this conversation. */
10
+ unread?: number;
11
+ };
12
+ export type ConversationListProps = {
13
+ conversations: readonly Conversation[];
14
+ /** The conversation open in the thread. */
15
+ selectedId?: string;
16
+ onSelect: (id: string) => void;
17
+ /** The accessible name of the list. «Conversaciones» by default. */
18
+ label?: string;
19
+ /** The «now» the times are relative to. */
20
+ now?: Date;
21
+ };
22
+ export declare function ConversationList({ conversations, selectedId, onSelect, label, now, }: ConversationListProps): import("react").JSX.Element;
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { dayLabel } from "./model.js";
4
+ import { fillCopy, useUiCopy } from "../../foundations/copy.js";
5
+ import { Empty } from "../../primitives/notice/Notice.js";
6
+ import { ListBox, ListBoxItem } from "react-aria-components";
7
+ export function ConversationList({ conversations, selectedId, onSelect, label, now, }) {
8
+ const copy = useUiCopy();
9
+ const clock = now ?? new Date();
10
+ const words = { today: copy.chat.today, yesterday: copy.chat.yesterday };
11
+ if (conversations.length === 0)
12
+ return _jsx(Empty, { sentence: copy.chat.empty });
13
+ return (_jsx(ListBox, { "aria-label": label ?? copy.chat.conversations, selectionMode: "single", disallowEmptySelection: true, selectedKeys: selectedId === undefined ? [] : [selectedId], onSelectionChange: (keys) => {
14
+ if (keys === "all")
15
+ return;
16
+ const [first] = keys;
17
+ if (first !== undefined)
18
+ onSelect(String(first));
19
+ }, className: "flex min-h-0 flex-col gap-1 overflow-y-auto p-2 outline-none", children: conversations.map((conversation) => (_jsxs(ListBoxItem, { id: conversation.id, textValue: conversation.title, className: ({ isSelected, isFocusVisible }) => `cursor-pointer rounded-control border px-3 py-2.5 outline-none ${isSelected
20
+ ? "border-primary/40 bg-primary/10"
21
+ : "border-transparent hover:bg-ink/4"} ${isFocusVisible ? "outline-2 outline-offset-1 outline-primary" : ""}`, children: [_jsxs("div", { className: "flex min-w-0 items-baseline gap-2", children: [_jsx("span", { className: "min-w-0 flex-1 truncate text-body font-medium text-ink", children: conversation.title }), conversation.at === undefined ? null : (_jsx("span", { className: "shrink-0 text-micro text-muted", children: dayLabel(conversation.at, clock, words, copy.locale) }))] }), _jsxs("div", { className: "mt-0.5 flex min-w-0 items-center gap-2", children: [_jsx("span", { className: "min-w-0 flex-1 truncate text-meta text-muted", children: conversation.preview ?? "" }), conversation.unread === undefined || conversation.unread === 0 ? null : (_jsxs("span", { className: "shrink-0 rounded-control bg-ink px-2 text-micro font-semibold text-surface tabular-nums", children: [conversation.unread, _jsx("span", { className: "sr-only", children: fillCopy(copy.chat.unread, { count: String(conversation.unread) }) })] }))] })] }, conversation.id))) }));
22
+ }
@@ -0,0 +1,4 @@
1
+ export { ChatComposer, type ChatComposerProps, } from "./ChatComposer.js";
2
+ export { ChatThread, type ChatThreadProps } from "./ChatThread.js";
3
+ export { type Conversation, ConversationList, type ConversationListProps, } from "./ConversationList.js";
4
+ export { type ChatMessage, type DayGroup, dayKey, dayLabel, groupByDay, startsRun, } from "./model.js";
@@ -0,0 +1,5 @@
1
+ /* A conversation: the thread, the composer and the list of conversations. */
2
+ export { ChatComposer, } from "./ChatComposer.js";
3
+ export { ChatThread } from "./ChatThread.js";
4
+ export { ConversationList, } from "./ConversationList.js";
5
+ export { dayKey, dayLabel, groupByDay, startsRun, } from "./model.js";
@@ -0,0 +1,30 @@
1
+ export type ChatMessage = {
2
+ id: string;
3
+ /** Who wrote it, as the screen names them: «Ana Ruiz». */
4
+ author: string;
5
+ /** The text. Plain: a message is not a page of its own. */
6
+ body: string;
7
+ at: Date;
8
+ /** Written by the person looking at the thread. Drawn on the other side. */
9
+ mine?: boolean;
10
+ /** Sent but not yet confirmed by the server. Said, never a silent success. */
11
+ pending?: boolean;
12
+ };
13
+ export type DayGroup = {
14
+ /** `YYYY-MM-DD` in local time: a stable key, and the day's identity. */
15
+ key: string;
16
+ day: Date;
17
+ messages: ChatMessage[];
18
+ };
19
+ /** The local calendar day of a date, as `YYYY-MM-DD`. */
20
+ export declare function dayKey(date: Date): string;
21
+ /** Messages in the order they were written, cut into the days they were written on.
22
+ * The input may come unsorted (a reconnect delivers out of order); the output never is. */
23
+ export declare function groupByDay(messages: readonly ChatMessage[]): DayGroup[];
24
+ /** A day's name for the separator: «Hoy», «Ayer», or the date written out. */
25
+ export declare function dayLabel(day: Date, now: Date, words: {
26
+ today: string;
27
+ yesterday: string;
28
+ }, locale: string): string;
29
+ /** Whether a message opens a new run from its author: the name is drawn only then. */
30
+ export declare function startsRun(messages: readonly ChatMessage[], index: number): boolean;
@@ -0,0 +1,53 @@
1
+ /* ==================================================================== *
2
+ * THE CHAT MODEL — the shapes a conversation is made of, and the pure rules
3
+ * that turn them into a thread: which day a message belongs to, what the day
4
+ * is called. No React here, so the rules are tested in Node.
5
+ * ==================================================================== */
6
+ /** The local calendar day of a date, as `YYYY-MM-DD`. */
7
+ export function dayKey(date) {
8
+ const y = date.getFullYear();
9
+ const m = String(date.getMonth() + 1).padStart(2, "0");
10
+ const d = String(date.getDate()).padStart(2, "0");
11
+ return `${y}-${m}-${d}`;
12
+ }
13
+ /** Messages in the order they were written, cut into the days they were written on.
14
+ * The input may come unsorted (a reconnect delivers out of order); the output never is. */
15
+ export function groupByDay(messages) {
16
+ const ordered = [...messages].sort((a, b) => a.at.getTime() - b.at.getTime());
17
+ const groups = [];
18
+ for (const message of ordered) {
19
+ const key = dayKey(message.at);
20
+ const last = groups[groups.length - 1];
21
+ if (last !== undefined && last.key === key) {
22
+ last.messages.push(message);
23
+ }
24
+ else {
25
+ const day = new Date(message.at.getFullYear(), message.at.getMonth(), message.at.getDate());
26
+ groups.push({ key, day, messages: [message] });
27
+ }
28
+ }
29
+ return groups;
30
+ }
31
+ /** A day's name for the separator: «Hoy», «Ayer», or the date written out. */
32
+ export function dayLabel(day, now, words, locale) {
33
+ const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
34
+ if (dayKey(day) === dayKey(now))
35
+ return words.today;
36
+ if (dayKey(day) === dayKey(yesterday))
37
+ return words.yesterday;
38
+ return new Intl.DateTimeFormat(locale, {
39
+ weekday: "long",
40
+ day: "numeric",
41
+ month: "long",
42
+ }).format(day);
43
+ }
44
+ /** Whether a message opens a new run from its author: the name is drawn only then. */
45
+ export function startsRun(messages, index) {
46
+ if (index === 0)
47
+ return true;
48
+ const previous = messages[index - 1];
49
+ const current = messages[index];
50
+ if (previous === undefined || current === undefined)
51
+ return true;
52
+ return previous.author !== current.author || previous.mine !== current.mine;
53
+ }
@@ -2,6 +2,8 @@ export * from "./activity/index.js";
2
2
  export * from "./assist/index.js";
3
3
  export * from "./attachments/index.js";
4
4
  export * from "./calendar/index.js";
5
+ export * from "./canvas/index.js";
6
+ export * from "./chat/index.js";
5
7
  export * from "./flow/index.js";
6
8
  export * from "./form/index.js";
7
9
  export * from "./frame/index.js";
@@ -9,6 +11,7 @@ export * from "./gantt/index.js";
9
11
  export * from "./lines/index.js";
10
12
  export * from "./listing/index.js";
11
13
  export * from "./navigation/index.js";
14
+ export * from "./preview/index.js";
12
15
  export * from "./record/index.js";
13
16
  export * from "./search/index.js";
14
17
  export * from "./shell/index.js";
@@ -3,6 +3,8 @@ export * from "./activity/index.js";
3
3
  export * from "./assist/index.js";
4
4
  export * from "./attachments/index.js";
5
5
  export * from "./calendar/index.js";
6
+ export * from "./canvas/index.js";
7
+ export * from "./chat/index.js";
6
8
  export * from "./flow/index.js";
7
9
  export * from "./form/index.js";
8
10
  export * from "./frame/index.js";
@@ -10,6 +12,7 @@ export * from "./gantt/index.js";
10
12
  export * from "./lines/index.js";
11
13
  export * from "./listing/index.js";
12
14
  export * from "./navigation/index.js";
15
+ export * from "./preview/index.js";
13
16
  export * from "./record/index.js";
14
17
  export * from "./search/index.js";
15
18
  export * from "./shell/index.js";
@@ -1,4 +1,5 @@
1
1
  import type { ColumnControl, ColumnSpec } from "./columns.js";
2
+ import { type PathPick } from "../search/FieldPath.js";
2
3
  import type { Surface } from "../../foundations/types.js";
3
4
  /**
4
5
  * The Odoo columns submenu: required fields stay checked and cannot be
@@ -7,10 +8,15 @@ import type { Surface } from "../../foundations/types.js";
7
8
  *
8
9
  * Drawn only when the set declared optional columns. A menu of required-only
9
10
  * fields would be a list of things you cannot do.
11
+ *
12
+ * `addPath` adds «Agregar columna» next to it: a `FieldPath` that walks the relations, so a
13
+ * column can be a field of a related record («Cliente > País»). web-ui hands the chosen path
14
+ * back; turning it into a column — and asking the server for it — is the framework's.
10
15
  */
11
- export declare function ColumnsMenu({ control, surface, }: {
16
+ export declare function ColumnsMenu({ control, surface, addPath, }: {
12
17
  control: ColumnControl;
13
18
  surface?: Surface;
19
+ addPath?: PathPick;
14
20
  }): import("react").JSX.Element | null;
15
21
  export declare function specsFromColumns(columns: readonly {
16
22
  id: string;
@@ -1,8 +1,9 @@
1
1
  "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { FieldPath } from "../search/FieldPath.js";
3
4
  import { useUiCopy } from "../../foundations/copy.js";
4
5
  import { Menu } from "../../primitives/menu/Menu.js";
5
- import { Columns3 } from "lucide-react";
6
+ import { Columns3, Plus } from "lucide-react";
6
7
  /**
7
8
  * The Odoo columns submenu: required fields stay checked and cannot be
8
9
  * unchecked; optional fields toggle. It stays open while toggling so hiding
@@ -10,11 +11,20 @@ import { Columns3 } from "lucide-react";
10
11
  *
11
12
  * Drawn only when the set declared optional columns. A menu of required-only
12
13
  * fields would be a list of things you cannot do.
14
+ *
15
+ * `addPath` adds «Agregar columna» next to it: a `FieldPath` that walks the relations, so a
16
+ * column can be a field of a related record («Cliente > País»). web-ui hands the chosen path
17
+ * back; turning it into a column — and asking the server for it — is the framework's.
13
18
  */
14
- export function ColumnsMenu({ control, surface, }) {
19
+ export function ColumnsMenu({ control, surface, addPath, }) {
15
20
  const copy = useUiCopy();
16
- if (!control.hasOptional)
21
+ if (!control.hasOptional && addPath === undefined)
17
22
  return null;
23
+ const picker = addPath === undefined ? null : (_jsx(FieldPath, { look: "button", icon: Plus, model: addPath.model, ...(addPath.loadModel === undefined ? {} : { loadModel: addPath.loadModel }), ...(addPath.filter === undefined ? {} : { filter: addPath.filter }), ...(addPath.followRelations === undefined
24
+ ? {}
25
+ : { followRelations: addPath.followRelations }), value: [], label: copy.fieldPath.addColumn, placeholder: copy.fieldPath.addColumn, onChange: addPath.onPick }));
26
+ if (!control.hasOptional)
27
+ return picker;
18
28
  const requiredOptions = control.required.map((column) => ({
19
29
  id: column.id,
20
30
  label: column.label,
@@ -34,7 +44,8 @@ export function ColumnsMenu({ control, surface, }) {
34
44
  { label: copy.frame.optional, options: optionalOptions },
35
45
  ];
36
46
  const hiddenOptional = control.optional.some((column) => !control.isVisible(column.id));
37
- return (_jsx(Menu, { label: copy.frame.columns, icon: Columns3, groups: groups, onSelect: control.toggle, closeOnSelect: false, active: hiddenOptional, ...(surface === undefined ? {} : { surface }), size: "sm" }));
47
+ const menu = (_jsx(Menu, { label: copy.frame.columns, icon: Columns3, groups: groups, onSelect: control.toggle, closeOnSelect: false, active: hiddenOptional, ...(surface === undefined ? {} : { surface }), size: "sm" }));
48
+ return picker === null ? (menu) : (_jsxs("span", { className: "flex items-center gap-1.5", children: [menu, picker] }));
38
49
  }
39
50
  export function specsFromColumns(columns, fallbackOptional) {
40
51
  return columns.map((column) => ({
@@ -1,4 +1,5 @@
1
1
  import type { GroupingControl } from "./grouping.js";
2
+ import { type PathPick } from "../search/FieldPath.js";
2
3
  import { type GroupableField, type GroupGrain } from "../../foundations/grouping.js";
3
4
  /**
4
5
  * «AGRUPAR POR», adentro del panel de recortes.
@@ -31,5 +32,8 @@ export type GroupingLevelsProps = {
31
32
  /** Cómo se llama cada grano, cuando el producto lo dice con otras palabras.
32
33
  * Sin esto, las de la copia en el idioma activo. */
33
34
  grainLabel?: (grain: GroupGrain) => string;
35
+ /** «Agrupar por otro campo»: un `FieldPath` que recorre relaciones («Cliente > País»).
36
+ * Devuelve el camino; qué nivel se pone con él lo decide quien orquesta la pantalla. */
37
+ addPath?: PathPick;
34
38
  };
35
- export declare function GroupingLevels({ fields, control, grainLabel }: GroupingLevelsProps): import("react").JSX.Element | null;
39
+ export declare function GroupingLevels({ fields, control, grainLabel, addPath, }: GroupingLevelsProps): import("react").JSX.Element | null;
@@ -1,20 +1,21 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { FieldPath } from "../search/FieldPath.js";
3
4
  import { grainName } from "../../foundations/calendar.js";
4
5
  import { useUiCopy } from "../../foundations/copy.js";
5
6
  import { GRAIN_ORDER, levelKey, } from "../../foundations/grouping.js";
6
- import { ChevronDown, ChevronRight, ChevronUp, X } from "lucide-react";
7
+ import { ChevronDown, ChevronRight, ChevronUp, Plus, X } from "lucide-react";
7
8
  import { useState } from "react";
8
9
  function fieldLabel(fields, field) {
9
10
  return fields.find((one) => one.field === field)?.label ?? field;
10
11
  }
11
- export function GroupingLevels({ fields, control, grainLabel }) {
12
+ export function GroupingLevels({ fields, control, grainLabel, addPath, }) {
12
13
  const copy = useUiCopy();
13
14
  /* Qué fechas están desplegadas. Arranca desplegada la que ya tenga algún grano
14
15
  puesto: si no, lo puesto queda escondido detrás de un chevron y hay que
15
16
  adivinar dónde. */
16
17
  const [opened, setOpened] = useState(() => control.levels.filter((one) => one.grain !== undefined).map((one) => one.field));
17
- if (fields.length === 0)
18
+ if (fields.length === 0 && addPath === undefined)
18
19
  return null;
19
20
  const placed = control.levels;
20
21
  const grain = (one) => grainLabel?.(one) ?? grainName(one);
@@ -34,7 +35,9 @@ export function GroupingLevels({ fields, control, grainLabel }) {
34
35
  const on = control.has(one.field, g);
35
36
  return (_jsxs("button", { type: "button", onClick: () => control.toggle(one.field, g), "aria-pressed": on, className: `flex items-center gap-2 rounded-control px-1.5 py-1 text-left transition-colors duration-(--duration-instant) hover:bg-primary/8 ${on ? "bg-primary/6" : ""}`, children: [_jsx(Mark, { on: on }), _jsx("span", { className: `min-w-0 truncate text-meta ${on ? "font-medium text-ink" : "text-muted"}`, children: grain(g) })] }, g));
36
37
  }) }))] }, one.field));
37
- }), placed.length === 0 ? null : (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-1 h-px bg-line", role: "separator" }), _jsx("button", { type: "button", onClick: () => control.clear(), className: "rounded-control px-2 py-1 text-left text-meta text-muted transition-colors duration-(--duration-instant) hover:bg-ink/4 hover:text-ink", children: copy.grouping.clear })] }))] }));
38
+ }), addPath === undefined ? null : (_jsx("div", { className: "px-1 pt-1", children: _jsx(FieldPath, { look: "button", icon: Plus, model: addPath.model, ...(addPath.loadModel === undefined ? {} : { loadModel: addPath.loadModel }), ...(addPath.filter === undefined ? {} : { filter: addPath.filter }), ...(addPath.followRelations === undefined
39
+ ? {}
40
+ : { followRelations: addPath.followRelations }), value: [], label: copy.fieldPath.addLevel, placeholder: copy.fieldPath.addLevel, onChange: addPath.onPick }) })), placed.length === 0 ? null : (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-1 h-px bg-line", role: "separator" }), _jsx("button", { type: "button", onClick: () => control.clear(), className: "rounded-control px-2 py-1 text-left text-meta text-muted transition-colors duration-(--duration-instant) hover:bg-ink/4 hover:text-ink", children: copy.grouping.clear })] }))] }));
38
41
  }
39
42
  /** La marca de tildado. La columna existe SIEMPRE, tildada o no: sin ella,
40
43
  * tildar corre el texto y la lista salta. Apagada se dibuja el aro, la misma
@@ -137,11 +137,11 @@ export function ListingBar({ actions, title, description, counters, selection, s
137
137
  ONE dark band per screen. Without its own band the bar sat flush on the page and its
138
138
  controls had nothing to belong to. */
139
139
  if (!isChrome) {
140
- return (_jsx(SurfaceProvider, { value: "canvas", children: _jsx("div", { className: `flex min-w-0 flex-col border-b border-line bg-surface ${byDensity(d, "px-3.5 py-2.5", "px-2.5 py-2")}`, children: bar }) }));
140
+ return (_jsx(SurfaceProvider, { value: "canvas", children: _jsx("div", { className: `flex min-w-0 flex-col border-b border-line bg-surface ${byDensity(d, "px-5 py-3", "px-2.5 py-2")}`, children: bar }) }));
141
141
  }
142
142
  /* On the chrome the bar IS the band: the background reaches the edges and
143
143
  everything inside inherits the surface, so there is no way to forget to
144
144
  pass it — which is how the status bar ended up with the canvas palette on
145
145
  top of the navy. */
146
- return (_jsx(SurfaceProvider, { value: "chrome", children: _jsx("div", { className: `flex min-w-0 flex-col bg-chrome ${byDensity(d, "px-3.5 py-2.5", "px-2.5 py-2")}`, children: bar }) }));
146
+ return (_jsx(SurfaceProvider, { value: "chrome", children: _jsx("div", { className: `flex min-w-0 flex-col bg-chrome ${byDensity(d, "px-5 py-3", "px-2.5 py-2")}`, children: bar }) }));
147
147
  }
@@ -0,0 +1,19 @@
1
+ export type PreviewKind = "image" | "pdf" | "markdown" | "text" | "other";
2
+ export type PreviewFile = {
3
+ /** The file name as saved: it picks the kind together with `type`. */
4
+ name: string;
5
+ /** Where the file downloads from. */
6
+ url: string;
7
+ /** The MIME type, when the server knows it. */
8
+ type?: string;
9
+ /** In bytes. Written for the locale in the header. */
10
+ size?: number;
11
+ };
12
+ /** The renderer for a file. Pure, so the choice is tested without a browser. */
13
+ export declare function previewKind(name: string, type?: string): PreviewKind;
14
+ export type FilePreviewProps = {
15
+ file: PreviewFile;
16
+ /** The pdf.js worker, when the application serves it itself. */
17
+ pdfWorkerUrl?: string;
18
+ };
19
+ export declare function FilePreview({ file, pdfWorkerUrl }: FilePreviewProps): import("react").JSX.Element;