@sincpro/web-ui 1.7.2 → 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/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
|
+
}
|
|
@@ -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",
|