@sincpro/web-framework 3.6.0 → 3.7.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.
@@ -2,7 +2,7 @@ import { type Entity } from "@sincpro/client-framework";
2
2
  import type { AnyRecord } from "@sincpro/criteria";
3
3
  import { type ViewProps } from "@sincpro/web-composer";
4
4
  import { type RecordReading } from "../../react/useRecord.js";
5
- import { type ReactNode } from "react";
5
+ import { type ScreenActions } from "../list/dock.js";
6
6
  /** Who made a record, or changed it last, and when: `Record.Audit`'s. */
7
7
  export type Stamp = {
8
8
  at: string;
@@ -81,6 +81,11 @@ export declare function EntityRecord<T extends AnyRecord>({ api, resource, entit
81
81
  fields?: readonly string[];
82
82
  /** The one2many shown as pages, in this order. Without it, every one the model has. */
83
83
  pages?: readonly string[];
84
- /** The record's own commands, beside «save / discard». */
85
- actions?: (record: RecordReading<T>) => ReactNode;
84
+ /**
85
+ * The record's own actions, beside «save / discard» and its lifecycle («Eliminar»). As data
86
+ * (`DockAction`s) the application's view style draws them with the lifecycle's: the rail's
87
+ * buttons in `traditional`, one pill floating at the bottom in `modern` (web-ui's
88
+ * `Record.Dock`). A node drawn by hand stays in the rail.
89
+ */
90
+ actions?: (record: RecordReading<T>) => ScreenActions;
86
91
  }): import("react").JSX.Element;
@@ -12,9 +12,10 @@ import { useFramework } from "../../react/context.js";
12
12
  import { useHistory } from "../../react/useHistory.js";
13
13
  import { useRecord } from "../../react/useRecord.js";
14
14
  import { useSummaryOf } from "../../react/useSummary.js";
15
+ import { actionsOf } from "../list/dock.js";
15
16
  import { presentationOf } from "../list/presentation.js";
16
17
  import { dirtyOf, RecordField } from "../record/edit.js";
17
- import { RecordLifecycle } from "../record/RecordLifecycle.js";
18
+ import { LifecycleButtons, useRecordLifecycleActions, } from "../record/RecordLifecycle.js";
18
19
  import { Refused } from "../Refused.js";
19
20
  import { useRecordInWorkspace } from "./workspace.js";
20
21
  import { Button, Callout, FormSection, Record, Skeleton, useFormStyle, } from "@sincpro/web-ui";
@@ -159,6 +160,9 @@ export function EntityRecord({ api, resource, entity, fields, pages, actions, ti
159
160
  // squeezed a text area beside its word (web-ui's grid does not narrow by itself).
160
161
  const phone = usePhone(api);
161
162
  const settings = useFormStyle() === "settings";
163
+ // The record's own lifecycle (its `Delete`, its trash); once it is out of every reading the
164
+ // surface closes — every list that showed it reads again by itself.
165
+ const lifecycle = useRecordLifecycleActions(reading, (done) => done === "restore" ? reading.reload() : api.close());
162
166
  if (reading.status === "loading")
163
167
  return _jsx(Skeleton, { rows: 6, label: copy.loading });
164
168
  if (reading.status === "failed")
@@ -172,20 +176,20 @@ export function EntityRecord({ api, resource, entity, fields, pages, actions, ti
172
176
  const shown = fields ??
173
177
  layout.fields.filter((name) => reading.isNew || !said.has(name) || !edit.state(name).readonly);
174
178
  const columns = phone || (api.surface !== "page" && api.surface !== "modal") ? 1 : 2;
175
- // The record's own lifecycle (its `Delete`, its trash) beside the screen's commands; once it is
176
- // out of every reading the surface closes — every list that showed it reads again by itself.
177
- const lifecycle = reading.isNew ||
178
- (entity.delete === undefined &&
179
- entity.archive === undefined &&
180
- entity.restore === undefined) ? null : (_jsx(RecordLifecycle, { record: reading, onDone: (done) => (done === "restore" ? reading.reload() : api.close()) }));
181
- const own = actions?.(reading) ?? null;
182
- const ownActions = own === null && lifecycle === null ? null : (_jsxs(_Fragment, { children: [own, lifecycle] }));
179
+ // The screen's actions and the lifecycle's. As data they go to the dock, where the view style
180
+ // draws them; drawn by hand, in the rail with the lifecycle's buttons beside them.
181
+ const own = actionsOf(actions?.(reading) ?? null);
182
+ const docked = own.drawn === null ? [...own.dock, ...lifecycle.actions] : [];
183
+ const drawn = own.drawn === null ? null : (_jsxs(_Fragment, { children: [own.drawn, _jsx(LifecycleButtons, { actions: lifecycle.actions })] }));
183
184
  const tabs = pages ?? layout.pages;
184
- return (_jsxs(Record, { ...screen.record, children: [crumbs.length === 0 && pager === undefined && ownActions === null ? null : (_jsxs(Record.Rail, { children: [crumbs.length === 0 ? null : _jsx(Record.Crumbs, { crumbs: crumbs }), pager === undefined ? null : _jsx(Record.Pager, { ...pager }), ownActions === null ? null : _jsx(Record.Actions, { children: ownActions })] })), _jsxs(Record.Paper, { layout: phone ? "stacked" : "horizontal", children: [edit.conflict || edit.restored ? (_jsxs("div", { className: "flex flex-col gap-3", children: [edit.conflict ? (_jsx(Callout, { tone: "warn", title: copy.conflict, children: _jsx(Button, { size: "sm", role: "secondary", onClick: reading.reload, children: copy.reload }) })) : null, edit.restored ? (_jsx(Callout, { tone: "info", title: copy.restored, children: null })) : null] })) : null, _jsx(FormSection, { columns: columns, ...(settings && fields === undefined && layout.sections.length > 0
185
- ? { title: copy.general }
186
- : {}), children: shown.map((name) => (_jsx(RecordField, { record: reading, name: name }, name))) }), fields !== undefined
187
- ? null
188
- : layout.sections.map((name) => (_jsx(FormSection, { title: labelOf(meta, name, locale), columns: columns, children: Object.keys(meta?.fields[name]?.definition?.fields ?? {}).map((part) => (_jsx(RecordField, { record: reading, name: `${name}.${part}` }, part))) }, name))), edit.advice
189
- .filter((one) => (one.path?.length ?? 0) <= 1)
190
- .map((one) => (_jsx(Callout, { tone: "info", title: one.message, children: null }, one.message))), tabs.length === 0 || reading.isNew ? null : (_jsx(Record.Pages, { current: page ?? tabs[0], onChange: setPage, children: tabs.map((name) => (_jsx(Record.Page, { id: name, label: labelOf(meta, name, locale), children: _jsx(RecordField, { record: reading, name: name, bare: true }) }, name))) })), screen.audit === undefined ? null : _jsx(Record.Audit, { ...screen.audit })] }), history === undefined ? null : _jsx(Record.Activity, { events: history })] }));
185
+ return (_jsxs(_Fragment, { children: [_jsxs(Record, { ...screen.record, children: [crumbs.length === 0 &&
186
+ pager === undefined &&
187
+ docked.length === 0 &&
188
+ drawn === null ? null : (_jsxs(Record.Rail, { children: [crumbs.length === 0 ? null : _jsx(Record.Crumbs, { crumbs: crumbs }), pager === undefined ? null : _jsx(Record.Pager, { ...pager }), drawn === null ? null : _jsx(Record.Actions, { children: drawn }), docked.length === 0 ? null : _jsx(Record.Dock, { actions: docked })] })), _jsxs(Record.Paper, { layout: phone ? "stacked" : "horizontal", children: [edit.conflict || edit.restored ? (_jsxs("div", { className: "flex flex-col gap-3", children: [edit.conflict ? (_jsx(Callout, { tone: "warn", title: copy.conflict, children: _jsx(Button, { size: "sm", role: "secondary", onClick: reading.reload, children: copy.reload }) })) : null, edit.restored ? (_jsx(Callout, { tone: "info", title: copy.restored, children: null })) : null] })) : null, _jsx(FormSection, { columns: columns, ...(settings && fields === undefined && layout.sections.length > 0
189
+ ? { title: copy.general }
190
+ : {}), children: shown.map((name) => (_jsx(RecordField, { record: reading, name: name }, name))) }), fields !== undefined
191
+ ? null
192
+ : layout.sections.map((name) => (_jsx(FormSection, { title: labelOf(meta, name, locale), columns: columns, children: Object.keys(meta?.fields[name]?.definition?.fields ?? {}).map((part) => (_jsx(RecordField, { record: reading, name: `${name}.${part}` }, part))) }, name))), edit.advice
193
+ .filter((one) => (one.path?.length ?? 0) <= 1)
194
+ .map((one) => (_jsx(Callout, { tone: "info", title: one.message, children: null }, one.message))), tabs.length === 0 || reading.isNew ? null : (_jsx(Record.Pages, { current: page ?? tabs[0], onChange: setPage, children: tabs.map((name) => (_jsx(Record.Page, { id: name, label: labelOf(meta, name, locale), children: _jsx(RecordField, { record: reading, name: name, bare: true }) }, name))) })), screen.audit === undefined ? null : _jsx(Record.Audit, { ...screen.audit })] }), history === undefined ? null : _jsx(Record.Activity, { events: history })] }), lifecycle.dialog] }));
191
195
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sincpro/web-framework",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "description": "The web client of sincpro_framework: entities, lists and records bound to the metadata the server publishes, drawn with @sincpro/web-ui and arranged with @sincpro/web-composer.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -44,7 +44,7 @@
44
44
  "@sincpro/criteria": "^2.4.0",
45
45
  "@sincpro/criteria-react": "^2.4.0",
46
46
  "@sincpro/web-composer": "^1.7.0",
47
- "@sincpro/web-ui": "^2.8.0",
47
+ "@sincpro/web-ui": "^2.10.0",
48
48
  "react": ">=19",
49
49
  "react-dom": ">=19"
50
50
  },
@@ -76,7 +76,7 @@
76
76
  "@sincpro/criteria": "^2.4.0",
77
77
  "@sincpro/criteria-react": "^2.4.0",
78
78
  "@sincpro/web-composer": "^1.8.0",
79
- "@sincpro/web-ui": "^2.8.0",
79
+ "@sincpro/web-ui": "^2.10.0",
80
80
  "@storybook/addon-a11y": "10.6.5",
81
81
  "@storybook/addon-docs": "10.6.5",
82
82
  "@storybook/addon-mcp": "10.6.5",