@sincpro/web-ui 1.7.1 → 1.8.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/dist/components/record/RecordHeader.d.ts +5 -1
- package/dist/components/record/RecordHeader.js +9 -3
- package/dist/components/search/CriteriaBuilder.js +2 -2
- package/dist/components/search/FilterBuilder.js +2 -2
- package/dist/components/search/LazyJsonEditor.d.ts +5 -0
- package/dist/components/search/LazyJsonEditor.js +14 -0
- package/dist/components/search/SearchBar.js +44 -21
- package/dist/views/list/ListView.js +12 -4
- package/dist/views/record/Record.d.ts +15 -1
- package/dist/views/record/Record.js +6 -2
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import type { Surface, Tone } from "../../foundations/types.js";
|
|
|
4
4
|
import type { LucideIcon } from "lucide-react";
|
|
5
5
|
import { type ReactNode } from "react";
|
|
6
6
|
export type { Surface };
|
|
7
|
-
export declare function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Icon, title, subtitle, tag, figure, railSurface, smart, aspects, dirty, activity, activityLayout, width, ribbon, blocking, indicator, children, }: {
|
|
7
|
+
export declare function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Icon, title, subtitle, tag, figure, railSurface, smart, aspects, dirty, activity, activityLayout, width, ribbon, blocking, indicator, paper: onPaper, children, }: {
|
|
8
8
|
crumbs?: readonly Crumb[];
|
|
9
9
|
pager?: ReactNode;
|
|
10
10
|
/** The action buttons. At most three visible + a `Menu` with `iconOnly`, and
|
|
@@ -75,6 +75,10 @@ export declare function RecordHeader({ crumbs, pager, actions, status, kicker, i
|
|
|
75
75
|
/** The rest of the record's notices, as one indicator — `RecordNoticeIndicator`. In the
|
|
76
76
|
* rail next to the counters; without a rail, first in the record, next to them. */
|
|
77
77
|
indicator?: ReactNode;
|
|
78
|
+
/** Whether the record sits on paper — a fact of WHERE it is mounted (`Record`'s
|
|
79
|
+
* `placement`). Only in comfortable: compact (the peek) is always one surface. Omitted, it
|
|
80
|
+
* is guessed from the rail: crumbs, pager or actions mean a page. */
|
|
81
|
+
paper?: boolean;
|
|
78
82
|
/** The record body. It sits IN the paper with the title, so groups, tabs
|
|
79
83
|
* and the page are one white sheet on the ground — Odoo's `<sheet>`. */
|
|
80
84
|
children?: ReactNode;
|
|
@@ -8,7 +8,7 @@ import { SurfaceProvider } from "../../foundations/surface.js";
|
|
|
8
8
|
import { Line } from "../../primitives/block/Line.js";
|
|
9
9
|
import { Tag } from "../../primitives/tag/Tag.js";
|
|
10
10
|
import { useEffect, useRef } from "react";
|
|
11
|
-
export function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Icon, title, subtitle, tag, figure, railSurface = "canvas", smart, aspects, dirty, activity, activityLayout = "auto", width = "reading", ribbon, blocking, indicator, children, }) {
|
|
11
|
+
export function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Icon, title, subtitle, tag, figure, railSurface = "canvas", smart, aspects, dirty, activity, activityLayout = "auto", width = "reading", ribbon, blocking, indicator, paper: onPaper, children, }) {
|
|
12
12
|
const d = useDensity();
|
|
13
13
|
/* «Guardado» is said where Save was; a record whose rail exists only while it has changes
|
|
14
14
|
keeps it for that moment, or the answer would leave with the question. */
|
|
@@ -62,8 +62,14 @@ export function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Ico
|
|
|
62
62
|
is mounted, and that does not change while someone types; `dirty` does, with the first
|
|
63
63
|
letter. Deciding by it swapped the whole tree under the paper at that letter — the field
|
|
64
64
|
being written was unmounted and lost the focus. Save and Discard still appear: in the
|
|
65
|
-
rail, which is a sibling and moves nothing.
|
|
66
|
-
|
|
65
|
+
rail, which is a sibling and moves nothing.
|
|
66
|
+
|
|
67
|
+
Crumbs, pager and actions are only the GUESS for when the mount is not said: they can
|
|
68
|
+
arrive late (loaded, allowed) and the guess flips with them. `paper`, when given, is the
|
|
69
|
+
answer — the rail's contents no longer decide it. */
|
|
70
|
+
const paper = onPaper === undefined
|
|
71
|
+
? withRail && (crumbs !== undefined || pager !== undefined || actions !== undefined)
|
|
72
|
+
: onPaper && d === "comfortable";
|
|
67
73
|
/* ONE column for the rail and the page: the rail used to span the screen while the sheet
|
|
68
74
|
stopped at 72rem, so on a wide desk the buttons sat 250 px left of the paper they act on
|
|
69
75
|
and the record read as two things. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { blankGroup, ExpressionView, treeFromFilter, treeToFilter, WhereTree, } from "./FilterBuilder.js";
|
|
4
|
-
import {
|
|
4
|
+
import { LazyJsonEditor } from "./LazyJsonEditor.js";
|
|
5
5
|
import { filterableNames, } from "./model.js";
|
|
6
6
|
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
7
7
|
import { GRAIN_ORDER } from "../../foundations/grouping.js";
|
|
@@ -274,5 +274,5 @@ export function CriteriaBuilder({ model, initial, focus, onApply, onCancel, }) {
|
|
|
274
274
|
return (_jsx("button", { type: "button", onClick: () => push({
|
|
275
275
|
fields: chosen ? fields.filter((one) => one !== name) : [...fields, name],
|
|
276
276
|
}), className: `rounded-pill border px-2 py-0.5 text-micro ${chosen ? "border-accent/40 bg-accent/18 text-ink" : `text-muted ${box}`}`, children: name }, name));
|
|
277
|
-
}) })] }), _jsx(
|
|
277
|
+
}) })] }), _jsx(LazyJsonEditor, { value: rawText, onChange: updateRaw, error: rawError, height: "14rem", label: copy.builder.json }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { role: "primary", disabled: rawError !== null, onClick: () => onApply(rawText.trim() === "" ? undefined : JSON.parse(rawText)), children: copy.builder.apply }), onCancel === undefined ? null : (_jsx(Button, { role: "ghost", onClick: onCancel, children: copy.builder.cancel }))] })] }));
|
|
278
278
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { JoinWord } from "./JoinWord.js";
|
|
4
|
-
import {
|
|
4
|
+
import { LazyJsonEditor } from "./LazyJsonEditor.js";
|
|
5
5
|
import { fieldLabel, filterableNames, } from "./model.js";
|
|
6
6
|
import { opLabel, sayCondition } from "./query.js";
|
|
7
7
|
import { currentCopy, fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
@@ -417,5 +417,5 @@ export function FilterBuilder({ model, initial, onApply, onCancel, }) {
|
|
|
417
417
|
setLockedView(parsed);
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
|
-
return (_jsxs("div", { className: "flex min-w-0 flex-col gap-3 p-3", children: [_jsx("div", { className: "max-h-80 min-w-0 overflow-auto", children: lockedView !== null ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "text-meta text-muted", children: copy.search.unreadable }), _jsx(ExpressionView, { node: lockedView, model: model })] })) : (_jsx(WhereTree, { model: model, group: tree, onChange: updateTree })) }), _jsx(
|
|
420
|
+
return (_jsxs("div", { className: "flex min-w-0 flex-col gap-3 p-3", children: [_jsx("div", { className: "max-h-80 min-w-0 overflow-auto", children: lockedView !== null ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "text-meta text-muted", children: copy.search.unreadable }), _jsx(ExpressionView, { node: lockedView, model: model })] })) : (_jsx(WhereTree, { model: model, group: tree, onChange: updateTree })) }), _jsx(LazyJsonEditor, { value: rawText, onChange: updateRaw, error: rawError, label: copy.builder.jsonFilter }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { role: "primary", disabled: rawError !== null, onClick: () => onApply(rawText.trim() === "" ? undefined : JSON.parse(rawText)), children: copy.builder.add }), onCancel === undefined ? null : (_jsx(Button, { role: "ghost", onClick: onCancel, children: copy.builder.cancel }))] })] }));
|
|
421
421
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { JsonEditor } from "./JsonEditor.js";
|
|
2
|
+
import { type ComponentProps } from "react";
|
|
3
|
+
/** `JsonEditor`, loaded when it is drawn. Until it arrives, a box of the editor's size holds
|
|
4
|
+
* the place so the dialog does not jump. */
|
|
5
|
+
export declare function LazyJsonEditor(props: ComponentProps<typeof JsonEditor>): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { lazy, Suspense } from "react";
|
|
4
|
+
/* CodeMirror (≈420 KB minified) is its own chunk: fetched the first time a builder is
|
|
5
|
+
OPENED, never by a screen that only has a search bar. The builders are dialogs nobody
|
|
6
|
+
opens on most visits, and they were paying for the editor on every one. */
|
|
7
|
+
const Editor = lazy(() => import("./JsonEditor.js").then((module) => ({
|
|
8
|
+
default: module.JsonEditor,
|
|
9
|
+
})));
|
|
10
|
+
/** `JsonEditor`, loaded when it is drawn. Until it arrives, a box of the editor's size holds
|
|
11
|
+
* the place so the dialog does not jump. */
|
|
12
|
+
export function LazyJsonEditor(props) {
|
|
13
|
+
return (_jsx(Suspense, { fallback: _jsx("div", { "aria-busy": "true", className: "h-64 w-full min-w-0 animate-reveal-late rounded-control border border-line-strong bg-ground" }), children: _jsx(Editor, { ...props }) }));
|
|
14
|
+
}
|
|
@@ -8,6 +8,7 @@ import { bySurface, useSurface } from "../../foundations/surface.js";
|
|
|
8
8
|
import { Tags } from "../../primitives/tag/Tags.js";
|
|
9
9
|
import { ChevronRight, CornerDownRight, ListFilter, Search, SlidersHorizontal, X, } from "lucide-react";
|
|
10
10
|
import { Fragment, useEffect, useId, useRef, useState } from "react";
|
|
11
|
+
import { useOverlay } from "react-aria";
|
|
11
12
|
function Option({ o, onSelect }) {
|
|
12
13
|
const Icon = o.icon;
|
|
13
14
|
return (_jsxs("button", { type: "button", disabled: o.disabled, onClick: () => onSelect?.(o.id), className: `flex w-full items-start gap-2 rounded-control px-1.5 py-1 text-left transition-colors duration-(--duration-instant) disabled:pointer-events-none disabled:opacity-45 hover:bg-primary/8 ${o.checked === true ? "bg-primary/6" : ""}`, children: [_jsx("span", { className: "mt-0.5 flex size-(--size-icon-sm) shrink-0 items-center justify-center", children: o.checked === true ? (_jsx("span", { className: "size-1.5 rounded-pill bg-primary" })) : Icon !== undefined ? (_jsx(Icon, { className: "size-(--size-icon-sm) text-muted", strokeWidth: 2 })) : (_jsx("span", { className: "size-3 rounded-pill border border-line-strong" })) }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: `truncate text-meta ${o.checked === true ? "font-medium text-ink" : "text-ink"}`, children: o.label }), o.badge === undefined ? null : (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-warn/30 bg-warn/10 px-2 py-0.5 text-micro text-warn", children: o.badge }))] }), o.hint === undefined ? null : (_jsx("span", { className: "mt-0.5 block truncate text-micro text-muted", children: o.hint }))] })] }));
|
|
@@ -73,6 +74,8 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
|
|
|
73
74
|
const puestos = criteria.length;
|
|
74
75
|
const input = useRef(null);
|
|
75
76
|
const box = useRef(null);
|
|
77
|
+
const toolsButton = useRef(null);
|
|
78
|
+
const panelBox = useRef(null);
|
|
76
79
|
const id = useId();
|
|
77
80
|
/* The suggestions are the input's popup (the ARIA combobox pattern): the input keeps the
|
|
78
81
|
focus and says which list it controls and which option is the active one, so a screen
|
|
@@ -134,25 +137,41 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
|
|
|
134
137
|
? []
|
|
135
138
|
: [{ title: copy.search.favorites, groups: favorites, onSelect: onFavoriteSelect }]),
|
|
136
139
|
];
|
|
137
|
-
|
|
138
|
-
|
|
140
|
+
/* THE PANEL IS A LAYER, and Escape closes the layer on top — only that one.
|
|
141
|
+
|
|
142
|
+
It listened for Escape and for a click outside on `document`, without stopping either.
|
|
143
|
+
Inside a dialog —the «Buscar más…» chooser, a composer modal— the dialog (React Aria's
|
|
144
|
+
`ModalOverlay`, which answers inside the React tree) closed FIRST, then the panel: whoever
|
|
145
|
+
pressed Escape to put the panel away lost the chooser. React Aria did not know the panel
|
|
146
|
+
sat on top of the dialog. Now it does: `useOverlay` puts the panel on React Aria's stack
|
|
147
|
+
of layers, the same one a `Select` or a `Picker` popover is on, so Escape and a press
|
|
148
|
+
outside close the top layer and leave the dialog open. A press inside the bar is not
|
|
149
|
+
«outside» (the button toggles, the input keeps typing). */
|
|
150
|
+
const closePanel = () => {
|
|
151
|
+
/* The focus goes back to the button that opened it — but only if it was inside the panel
|
|
152
|
+
(Escape): a press elsewhere already put it where the person wanted. */
|
|
153
|
+
const hadFocus = panelBox.current?.contains(document.activeElement) === true;
|
|
154
|
+
setPanel(false);
|
|
155
|
+
if (hadFocus)
|
|
156
|
+
toolsButton.current?.focus();
|
|
157
|
+
};
|
|
158
|
+
const { overlayProps } = useOverlay({
|
|
159
|
+
isOpen: panel,
|
|
160
|
+
onClose: closePanel,
|
|
161
|
+
isDismissable: true,
|
|
162
|
+
shouldCloseOnInteractOutside: (element) => box.current?.contains(element) !== true,
|
|
163
|
+
}, panelBox);
|
|
164
|
+
/* With the focus still in the bar (the input, the button) and the panel open, Escape is
|
|
165
|
+
the panel's too — used up the same way, so it does not reach the dialog either. With the
|
|
166
|
+
panel closed, Escape is not the bar's and goes on to whoever owns it. */
|
|
167
|
+
const closePanelOnEscape = (e) => {
|
|
168
|
+
if (e.key !== "Escape" || !panel || e.defaultPrevented)
|
|
139
169
|
return;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
function onEscape(e) {
|
|
146
|
-
if (e.key === "Escape")
|
|
147
|
-
setPanel(false);
|
|
148
|
-
}
|
|
149
|
-
document.addEventListener("mousedown", outside);
|
|
150
|
-
document.addEventListener("keydown", onEscape);
|
|
151
|
-
return () => {
|
|
152
|
-
document.removeEventListener("mousedown", outside);
|
|
153
|
-
document.removeEventListener("keydown", onEscape);
|
|
154
|
-
};
|
|
155
|
-
}, [panel]);
|
|
170
|
+
e.preventDefault();
|
|
171
|
+
e.stopPropagation();
|
|
172
|
+
setPanel(false);
|
|
173
|
+
toolsButton.current?.focus();
|
|
174
|
+
};
|
|
156
175
|
/**
|
|
157
176
|
* UNA PREGUNTA ENTERA entra como instancia, y la barra vuelve al principio.
|
|
158
177
|
*
|
|
@@ -222,7 +241,7 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
|
|
|
222
241
|
? one
|
|
223
242
|
: { ...node, of: [...node.of, one] };
|
|
224
243
|
}
|
|
225
|
-
return (_jsxs("div", { ref: box, className: "relative flex min-w-0 items-center gap-2", children: [_jsxs("div", { className: `@container/bar flex min-h-(--size-control-md) w-full min-w-0 items-start rounded-box border transition-colors duration-(--duration-instant) ${bySurface(sup, "border-line-strong bg-surface focus-within:border-primary/60",
|
|
244
|
+
return (_jsxs("div", { ref: box, onKeyDown: closePanelOnEscape, className: "relative flex min-w-0 items-center gap-2", children: [_jsxs("div", { className: `@container/bar flex min-h-(--size-control-md) w-full min-w-0 items-start rounded-box border transition-colors duration-(--duration-instant) ${bySurface(sup, "border-line-strong bg-surface focus-within:border-primary/60",
|
|
226
245
|
/* Sobre el cromo lo que define al campo es el BORDE, no el relleno. El
|
|
227
246
|
azul ya es casi negro, así que hundirlo no da contraste (1,05:1) y
|
|
228
247
|
levantarlo da 1,21:1 — en los dos casos el campo no se lee como un
|
|
@@ -345,16 +364,19 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
|
|
|
345
364
|
if (e.key === "Escape") {
|
|
346
365
|
if (text !== "") {
|
|
347
366
|
e.preventDefault();
|
|
367
|
+
e.stopPropagation();
|
|
348
368
|
setText("");
|
|
349
369
|
return;
|
|
350
370
|
}
|
|
351
371
|
if (step.op !== undefined) {
|
|
352
372
|
e.preventDefault();
|
|
373
|
+
e.stopPropagation();
|
|
353
374
|
setStep({ field: step.field });
|
|
354
375
|
return;
|
|
355
376
|
}
|
|
356
377
|
if (step.field !== undefined) {
|
|
357
378
|
e.preventDefault();
|
|
379
|
+
e.stopPropagation();
|
|
358
380
|
setStep({});
|
|
359
381
|
return;
|
|
360
382
|
}
|
|
@@ -362,6 +384,7 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
|
|
|
362
384
|
se deshace. */
|
|
363
385
|
if (openGroup !== null) {
|
|
364
386
|
e.preventDefault();
|
|
387
|
+
e.stopPropagation();
|
|
365
388
|
closeGroup();
|
|
366
389
|
}
|
|
367
390
|
return;
|
|
@@ -388,7 +411,7 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
|
|
|
388
411
|
onCriteriaChange([]);
|
|
389
412
|
setOpenGroup(null);
|
|
390
413
|
input.current?.focus();
|
|
391
|
-
}, "aria-label": copy.search.clearAll, title: copy.search.clearAll, className: `my-0.5 inline-flex h-(--size-control-sm) shrink-0 items-center rounded-control px-1.5 transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${bySurface(sup, "text-muted hover:bg-ink/5 hover:text-ink", "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink")}`, children: _jsx(X, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true }) })), columns.length === 0 && onOpenBuilder === undefined ? null : (_jsxs("button", { type: "button", onClick: () => setPanel((v) => !v), "aria-expanded": panel, "aria-controls": panel ? id : undefined, "aria-label": puestos === 0
|
|
414
|
+
}, "aria-label": copy.search.clearAll, title: copy.search.clearAll, className: `my-0.5 inline-flex h-(--size-control-sm) shrink-0 items-center rounded-control px-1.5 transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${bySurface(sup, "text-muted hover:bg-ink/5 hover:text-ink", "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink")}`, children: _jsx(X, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true }) })), columns.length === 0 && onOpenBuilder === undefined ? null : (_jsxs("button", { ref: toolsButton, type: "button", onClick: () => setPanel((v) => !v), "aria-expanded": panel, "aria-controls": panel ? id : undefined, "aria-label": puestos === 0
|
|
392
415
|
? copy.search.tools
|
|
393
416
|
: fillCopy(puestos === 1 ? copy.search.toolsSetOne : copy.search.toolsSetMany, {
|
|
394
417
|
label: copy.search.tools,
|
|
@@ -411,7 +434,7 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
|
|
|
411
434
|
onSelect: () => pick(one),
|
|
412
435
|
})) }) })) : (_jsx("div", { id: listId, role: "listbox", "aria-label": copy.search.suggestions, className: "p-1", children: suggestions.map((one, at) => (_jsxs("div", { id: optionId(at), role: "option", "aria-selected": at === active,
|
|
413
436
|
/* The input keeps the focus: pressing an option must not take it. */
|
|
414
|
-
onMouseDown: (event) => event.preventDefault(), onClick: () => pick(one), onMouseEnter: () => setActive(at), className: `flex w-full cursor-pointer items-baseline gap-1.5 rounded-control px-2 py-1.5 text-left text-meta transition-colors duration-(--duration-instant) ${at === active ? "bg-primary/8" : "hover:bg-ink/4"}`, children: [_jsx("span", { className: "shrink-0 font-medium text-ink", children: one.label }), one.kind === "condition" || one.kind === "literal" ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "shrink-0 text-muted", children: ":" }), _jsx("span", { className: "min-w-0 truncate font-mono text-micro text-ink", children: one.hint })] })) : one.kind === "field" && one.hint !== undefined ? (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-line-strong bg-ink/5 px-2 py-0.5 text-micro text-muted", children: one.hint })) : null] }, one.id))) }))] })) : null, panel && (columns.length > 0 || onOpenBuilder !== undefined) ? (_jsxs("div", { id: id, className: "absolute top-full right-0 z-30 mt-1 flex w-max max-w-full flex-wrap overflow-hidden rounded-panel border border-line-strong bg-surface shadow-float", children: [columns.map((c, i) => (_jsxs("div", { className: `flex min-w-48 flex-1 flex-col ${i === 0 ? "" : "border-t border-line sm:border-t-0 sm:border-l"}`, children: [_jsx("div", { className: "border-b border-line px-2.5 py-1.5 text-micro font-medium text-muted", children: c.title }), _jsx("div", { className: "flex flex-col gap-0.5 p-1", children: c.content ??
|
|
437
|
+
onMouseDown: (event) => event.preventDefault(), onClick: () => pick(one), onMouseEnter: () => setActive(at), className: `flex w-full cursor-pointer items-baseline gap-1.5 rounded-control px-2 py-1.5 text-left text-meta transition-colors duration-(--duration-instant) ${at === active ? "bg-primary/8" : "hover:bg-ink/4"}`, children: [_jsx("span", { className: "shrink-0 font-medium text-ink", children: one.label }), one.kind === "condition" || one.kind === "literal" ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "shrink-0 text-muted", children: ":" }), _jsx("span", { className: "min-w-0 truncate font-mono text-micro text-ink", children: one.hint })] })) : one.kind === "field" && one.hint !== undefined ? (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-line-strong bg-ink/5 px-2 py-0.5 text-micro text-muted", children: one.hint })) : null] }, one.id))) }))] })) : null, panel && (columns.length > 0 || onOpenBuilder !== undefined) ? (_jsxs("div", { ...overlayProps, ref: panelBox, id: id, className: "absolute top-full right-0 z-30 mt-1 flex w-max max-w-full flex-wrap overflow-hidden rounded-panel border border-line-strong bg-surface shadow-float", children: [columns.map((c, i) => (_jsxs("div", { className: `flex min-w-48 flex-1 flex-col ${i === 0 ? "" : "border-t border-line sm:border-t-0 sm:border-l"}`, children: [_jsx("div", { className: "border-b border-line px-2.5 py-1.5 text-micro font-medium text-muted", children: c.title }), _jsx("div", { className: "flex flex-col gap-0.5 p-1", children: c.content ??
|
|
415
438
|
c.groups?.map((g, gi) => (_jsx(Group, { group: g, first: gi === 0, onSelect: c.onSelect }, g.label ?? gi))) })] }, c.title))), onOpenBuilder === undefined ? null : (_jsx("div", { className: "w-full border-t border-line p-1", children: _jsxs("button", { type: "button", onClick: () => {
|
|
416
439
|
onOpenBuilder();
|
|
417
440
|
setPanel(false);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { RecordCalendar } from "../../components/calendar/RecordCalendar.js";
|
|
4
|
-
import { RecordGantt } from "../../components/gantt/RecordGantt.js";
|
|
5
3
|
import { BoardColumns } from "../../components/listing/BoardColumns.js";
|
|
6
4
|
import { useColumnControl, visibleColumns } from "../../components/listing/columns.js";
|
|
7
5
|
import { ColumnsMenu, specsFromColumns, } from "../../components/listing/ColumnsMenu.js";
|
|
@@ -28,7 +26,17 @@ import { groupLevelsOf, reportColumnsOf, reportRowsOf, sheetFromColumns, sheetRo
|
|
|
28
26
|
import { SheetPresentation, TablePresentation, } from "./presentations.js";
|
|
29
27
|
import { useNarrowList } from "./useNarrowList.js";
|
|
30
28
|
import { CalendarDays, CalendarRange, ChartGantt, Grid3x3, LayoutGrid, List, Sheet, Sigma, Table2, } from "lucide-react";
|
|
31
|
-
import { Fragment, useCallback, useMemo } from "react";
|
|
29
|
+
import { Fragment, lazy, Suspense, useCallback, useMemo } from "react";
|
|
30
|
+
/* The calendar (FullCalendar) and the gantt (SVAR) are each about a third of a list's weight,
|
|
31
|
+
and most lists never show either face. Each is its own chunk, fetched the first time its
|
|
32
|
+
face is SHOWN. `lazy` erases the generic, so the eager signature is put back: the props
|
|
33
|
+
are checked exactly as before. */
|
|
34
|
+
const RecordCalendar = lazy(() => import("../../components/calendar/RecordCalendar.js").then((module) => ({
|
|
35
|
+
default: module.RecordCalendar,
|
|
36
|
+
})));
|
|
37
|
+
const RecordGantt = lazy(() => import("../../components/gantt/RecordGantt.js").then((module) => ({
|
|
38
|
+
default: module.RecordGantt,
|
|
39
|
+
})));
|
|
32
40
|
/**
|
|
33
41
|
* EL DIBUJO de una lista. **La puerta es `List`**, que se escribe como árbol y
|
|
34
42
|
* traduce las ranuras a esto — acá todo entra como props porque acá ya se
|
|
@@ -324,7 +332,7 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
324
332
|
orden —cada eje viene en el orden de sus claves— y no hay menú de
|
|
325
333
|
columnas, porque las columnas son un eje y no una lista de campos que
|
|
326
334
|
se puedan esconder de a uno. */
|
|
327
|
-
_jsx(PivotTable, { pivot: pivotShown, ...(pivot?.onCell === undefined ? {} : { onCell: pivot.onCell }), ...(pivot?.height === undefined ? {} : { height: pivot.height }) })) : present === "calendar" && calendar !== undefined ? (_jsx("div", { className: "p-3", children: _jsx(RecordCalendar, { ...calendar, items: ordered, keyOf: keyOf, ...(press === undefined ? {} : { onOpen: press }) }) })) : present === "gantt" && gantt !== undefined ? (_jsx("div", { className: "p-3", children: _jsx(RecordGantt, { ...gantt, items: ordered, keyOf: keyOf, ...(press === undefined ? {} : { onOpen: press }) }) })) : present === "timeline" && timeline !== undefined ? (_jsx("div", { className: "p-3", children: _jsx(RecordTimeline, { ...timeline, items: ordered, keyOf: keyOf, ...(press === undefined ? {} : { onOpen: press }) }) })) : present === "board" && boardStages !== undefined ? (_jsx(BoardColumns, { items: ordered, keyOf: keyOf, stages: boardStages, card: renderCard })) : present === "board" ? (_jsx("div", { className: "flex flex-col", children: wrapGroups((inside) => (_jsx("div", { className: "grid gap-3 p-3 @2xl:grid-cols-2 @5xl:grid-cols-3", children: inside.map(renderCard) }))) })) : (
|
|
335
|
+
_jsx(PivotTable, { pivot: pivotShown, ...(pivot?.onCell === undefined ? {} : { onCell: pivot.onCell }), ...(pivot?.height === undefined ? {} : { height: pivot.height }) })) : present === "calendar" && calendar !== undefined ? (_jsx("div", { className: "p-3", children: _jsx(Suspense, { fallback: _jsx(Skeleton, { label: copy.failed.loading }), children: _jsx(RecordCalendar, { ...calendar, items: ordered, keyOf: keyOf, ...(press === undefined ? {} : { onOpen: press }) }) }) })) : present === "gantt" && gantt !== undefined ? (_jsx("div", { className: "p-3", children: _jsx(Suspense, { fallback: _jsx(Skeleton, { label: copy.failed.loading }), children: _jsx(RecordGantt, { ...gantt, items: ordered, keyOf: keyOf, ...(press === undefined ? {} : { onOpen: press }) }) }) })) : present === "timeline" && timeline !== undefined ? (_jsx("div", { className: "p-3", children: _jsx(RecordTimeline, { ...timeline, items: ordered, keyOf: keyOf, ...(press === undefined ? {} : { onOpen: press }) }) })) : present === "board" && boardStages !== undefined ? (_jsx(BoardColumns, { items: ordered, keyOf: keyOf, stages: boardStages, card: renderCard })) : present === "board" ? (_jsx("div", { className: "flex flex-col", children: wrapGroups((inside) => (_jsx("div", { className: "grid gap-3 p-3 @2xl:grid-cols-2 @5xl:grid-cols-3", children: inside.map(renderCard) }))) })) : (
|
|
328
336
|
/* El encabezado va ANTES de los montones y no adentro de cada uno:
|
|
329
337
|
rotula la fila, y la fila es la misma en los cinco montones. */
|
|
330
338
|
_jsxs(_Fragment, { children: [rowHeader === undefined || items.length === 0 ? null : (_jsx(RowHeader, { name: rowHeader.name, ...(rowHeader.meta === undefined ? {} : { meta: rowHeader.meta }), ...(rowHeader.tags === undefined ? {} : { tags: rowHeader.tags }), withSelection: selection !== undefined,
|
|
@@ -131,9 +131,23 @@ export type RecordProps = {
|
|
|
131
131
|
/** Hay cambios sin guardar. Su presencia REEMPLAZA los botones de acción por
|
|
132
132
|
* guardar y descartar — ver la nota en `RecordHeader`. */
|
|
133
133
|
dirty?: DirtyState;
|
|
134
|
+
/**
|
|
135
|
+
* Where the record is mounted — and so whether it sits on paper.
|
|
136
|
+
*
|
|
137
|
+
* page on the ground, on a white sheet (Odoo's `<sheet>`): the record owns the
|
|
138
|
+
* screen, the workspace's page or a panel.
|
|
139
|
+
* card one surface, no ground: the record is already inside a card — a modal, a
|
|
140
|
+
* window. In compact density (the peek) it is always this.
|
|
141
|
+
*
|
|
142
|
+
* Say it whenever the mount is known (in the composer, `api.surface`): it is a fact of
|
|
143
|
+
* WHERE the record is, and it does not change while the record is on screen. Omitted, the
|
|
144
|
+
* sheet is guessed from the rail — crumbs, pager or actions mean a page — which flips the
|
|
145
|
+
* whole tree under the paper the moment one of them appears or goes away.
|
|
146
|
+
*/
|
|
147
|
+
placement?: "page" | "card";
|
|
134
148
|
children?: ReactNode;
|
|
135
149
|
};
|
|
136
|
-
export declare function Record({ identity, error, dirty, children }: RecordProps): import("react").JSX.Element;
|
|
150
|
+
export declare function Record({ identity, error, dirty, placement, children }: RecordProps): import("react").JSX.Element;
|
|
137
151
|
export declare namespace Record {
|
|
138
152
|
var Skeleton: typeof RecordSkeleton;
|
|
139
153
|
var Rail: ((props: RailProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"rail">;
|
|
@@ -72,7 +72,7 @@ const Page = slot("page", (_props) => null);
|
|
|
72
72
|
function NotebookScope({ tabs, children }) {
|
|
73
73
|
return tabs ? _jsx(TabsScope, { children: children }) : children;
|
|
74
74
|
}
|
|
75
|
-
export function Record({ identity, error = null, dirty, children }) {
|
|
75
|
+
export function Record({ identity, error = null, dirty, placement, children }) {
|
|
76
76
|
const d = useDensity();
|
|
77
77
|
const copy = useUiCopy();
|
|
78
78
|
const top = flatten(children);
|
|
@@ -90,9 +90,13 @@ export function Record({ identity, error = null, dirty, children }) {
|
|
|
90
90
|
const status = propsOf(pick(rail, "status"));
|
|
91
91
|
/* Las dos preguntas del estado, con la superficie ya resuelta: «¿dónde
|
|
92
92
|
está?» y «¿qué pasó para llegar acá?». */
|
|
93
|
+
/* The same question `RecordHeader` asks to draw the rail (`status` included): asked
|
|
94
|
+
differently here, a record with only a status drew a `chrome` rail light until the first
|
|
95
|
+
keystroke, and dark from then on. */
|
|
93
96
|
const onTheRail = crumbs !== undefined ||
|
|
94
97
|
pager !== undefined ||
|
|
95
98
|
actions !== undefined ||
|
|
99
|
+
status !== undefined ||
|
|
96
100
|
dirty !== undefined;
|
|
97
101
|
const railSurface = propsOf(railNode)?.surface ?? "canvas";
|
|
98
102
|
const surface = onTheRail && d === "comfortable" ? railSurface : "canvas";
|
|
@@ -170,7 +174,7 @@ export function Record({ identity, error = null, dirty, children }) {
|
|
|
170
174
|
shorter than the screen. The extra height has no paint of its own: on a desk
|
|
171
175
|
nothing changes. */
|
|
172
176
|
/* The record knows the notes of its fields and rows: their cards register here. */
|
|
173
|
-
_jsx(NoteRegistryContext, { value: registry, children: _jsx("article", { className: "flex min-w-0 flex-1 flex-col", children: _jsx(NotebookScope, { tabs: tabs.length > 0, children: _jsx(RecordHeader, { railSurface: surface, ...(ribbon === undefined
|
|
177
|
+
_jsx(NoteRegistryContext, { value: registry, children: _jsx("article", { className: "flex min-w-0 flex-1 flex-col", children: _jsx(NotebookScope, { tabs: tabs.length > 0, children: _jsx(RecordHeader, { railSurface: surface, ...(placement === undefined ? {} : { paper: placement === "page" }), ...(ribbon === undefined
|
|
174
178
|
? {}
|
|
175
179
|
: {
|
|
176
180
|
ribbon: (_jsx(RecordRibbon, { label: ribbon.label, ...(ribbon.tone === undefined ? {} : { tone: ribbon.tone }) })),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "An enterprise web design system for business software — ERPs, back offices, management tools — in React and Tailwind: tokens, primitives, components and the two views every management screen is made of.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|