@sincpro/web-framework 3.3.0 → 3.5.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.
@@ -69,6 +69,8 @@ export type FrameworkCopy = {
69
69
  archive: string;
70
70
  /** Out of the trash (`Restore`): read again. */
71
71
  restore: string;
72
+ /** The record's main card in web-ui's «settings» form style, beside its other sections. */
73
+ general: string;
72
74
  };
73
75
  picker: {
74
76
  /** The button beside a many2one that opens the chooser over the whole set. */
package/dist/core/copy.js CHANGED
@@ -36,6 +36,7 @@ export const ENGLISH_FRAMEWORK_COPY = {
36
36
  delete: "Delete",
37
37
  archive: "Move to the trash",
38
38
  restore: "Restore",
39
+ general: "General",
39
40
  },
40
41
  picker: {
41
42
  browse: "Search all",
@@ -125,6 +126,7 @@ export const SPANISH_FRAMEWORK_COPY = {
125
126
  delete: "Eliminar",
126
127
  archive: "Mover a la papelera",
127
128
  restore: "Restaurar",
129
+ general: "Datos generales",
128
130
  },
129
131
  picker: {
130
132
  browse: "Buscar en todos",
@@ -15,7 +15,7 @@ export { type FormLayout, formOf } from "./form.js";
15
15
  export { areGroups, NotGrouped } from "./groups.js";
16
16
  export { FACT_TONES, type FactTone, type HistoryEntry, historyOf, toneOfFact, } from "./history.js";
17
17
  export { addingOf, type AddingRule, blankLine, type Declared, editableLines, isReference, type LineAdding, lineFields, lineKey, linesAnswered, moved, sameLine, writtenInCell, } from "./lines.js";
18
- export { defineList, type GroupLevel, isList, type ListDefinition, type ListSpec, type NamedFilter, scopeOf, trashOf, } from "./list.js";
18
+ export { defineList, type GroupLevel, isList, type ListDefinition, listingAsk, type ListingQuestion, type ListSpec, type NamedFilter, readListing, scopeOf, trashOf, } from "./list.js";
19
19
  export { lookupOf, type LookupOption } from "./lookup.js";
20
20
  export { detailOf, measuresOf, sumsOf, type Total, totalOf, } from "./measure.js";
21
21
  export { BOOKKEEPING, currencyNow, type DateStyle, dateStyleNow, dayTextOf, defaultFields, fieldAt, fieldMetaOf, type FieldView, installCurrency, installDateStyle, instantTextOf, moneyTextOf, numberTextOf, sortKeyOf, STAMPS, textOf, valueAt, viewOf, } from "./present.js";
@@ -15,7 +15,7 @@ export { formOf } from "./form.js";
15
15
  export { areGroups, NotGrouped } from "./groups.js";
16
16
  export { FACT_TONES, historyOf, toneOfFact, } from "./history.js";
17
17
  export { addingOf, blankLine, editableLines, isReference, lineFields, lineKey, linesAnswered, moved, sameLine, writtenInCell, } from "./lines.js";
18
- export { defineList, isList, scopeOf, trashOf, } from "./list.js";
18
+ export { defineList, isList, listingAsk, readListing, scopeOf, trashOf, } from "./list.js";
19
19
  export { lookupOf } from "./lookup.js";
20
20
  export { detailOf, measuresOf, sumsOf, totalOf, } from "./measure.js";
21
21
  export { BOOKKEEPING, currencyNow, dateStyleNow, dayTextOf, defaultFields, fieldAt, fieldMetaOf, installCurrency, installDateStyle, instantTextOf, moneyTextOf, numberTextOf, sortKeyOf, STAMPS, textOf, valueAt, viewOf, } from "./present.js";
@@ -1,5 +1,5 @@
1
- import { type Entity, type ResourceRef } from "@sincpro/client-framework";
2
- import type { AnyRecord, Criteria, Expression, Grain, Sort } from "@sincpro/criteria";
1
+ import { type Entity, type ResourceRef, type Transport } from "@sincpro/client-framework";
2
+ import { type AnyRecord, type Criteria, type Expression, type Grain, type Page, type Sort } from "@sincpro/criteria";
3
3
  /**
4
4
  * A named way of looking at an entity: «Por cobrar», «Borradores», «Mis tickets».
5
5
  *
@@ -70,6 +70,43 @@ export declare function defineList<T extends AnyRecord>(entity: Entity<T>, spec:
70
70
  export declare function isList<T extends AnyRecord>(given: Entity<T> | ListDefinition<T>): given is ListDefinition<T>;
71
71
  /** The criteria a definition always asks: its scope, in its order. */
72
72
  export declare function scopeOf<T extends AnyRecord>(list: ListDefinition<T>): Criteria<T>;
73
+ /** What a listing's first page depends on, besides the entity or the named list. */
74
+ export type ListingQuestion<T> = {
75
+ /** The route's own parameters: `{ tenant_id: "acme" }` → `/projects?tenant_id=acme`. */
76
+ params?: Readonly<Record<string, string>>;
77
+ /** What the listing always asks — a scope. Search, filter and order AND it. */
78
+ criteria?: Criteria<T>;
79
+ /** Rows per page. 50 by default; the server's own default too. */
80
+ pageSize?: number;
81
+ };
82
+ /**
83
+ * The route and the criteria of a listing's first page: the named list's scope, a screen's cut
84
+ * and the caller's criteria ANDed, the page size set.
85
+ *
86
+ * listingAsk(porCobrar, { pageSize: 25 })
87
+ * → { route: "/facturas", criteria: { selection: state = posted, pagination: { limit: 25 } } }
88
+ *
89
+ * Context: `useListing` asks it on mount and `readListing` asks it on a server, so a page read
90
+ * there is the very page the screen would have asked for, and hydrating it reads nothing twice.
91
+ */
92
+ export declare function listingAsk<T extends AnyRecord>(given: Entity<T> | ListDefinition<T>, own?: ListingQuestion<T>, cut?: Expression<T>): {
93
+ route: string;
94
+ criteria: Criteria<T>;
95
+ };
96
+ /**
97
+ * A listing's first page, read outside React — on the server that renders the screen, in a
98
+ * route's loader —, through the same transport the `FrameworkProvider` is given. Handed to
99
+ * `useListing(list, { ...own, page })`, the screen starts from it and asks nothing on mount.
100
+ *
101
+ * // the loader, on the server
102
+ * const page = await readListing(transport, misPagos, { criteria: delColegiado });
103
+ * // the screen, rendered there and hydrated in the browser
104
+ * const listing = useListing(misPagos, { criteria: delColegiado, page });
105
+ *
106
+ * A chooser's cut (`ListScopeProvider`) lives in the screen and is not read here: a listing
107
+ * under one is asked with it by the screen, as a SPA does.
108
+ */
109
+ export declare function readListing<T extends AnyRecord>(transport: Transport, given: Entity<T> | ListDefinition<T>, own?: ListingQuestion<T>, signal?: AbortSignal): Promise<Page<T>>;
73
110
  /**
74
111
  * An entity's trash, as a named list: its archived records (sincpro_framework's `Archive`,
75
112
  * `ArchivableMixin`), each row offering «Restore» when the entity declares `restore`.
package/dist/core/list.js CHANGED
@@ -1,4 +1,5 @@
1
- import {} from "@sincpro/client-framework";
1
+ import { listRoute, screensTransport, } from "@sincpro/client-framework";
2
+ import { merge, } from "@sincpro/criteria";
2
3
  import { frameworkCopy } from "./copy.js";
3
4
  export function defineList(entity, spec) {
4
5
  if (!/^[a-z0-9][a-z0-9-]*$/.test(spec.id))
@@ -22,6 +23,48 @@ export function scopeOf(list) {
22
23
  ...(list.order === undefined ? {} : { order: [list.order] }),
23
24
  };
24
25
  }
26
+ /**
27
+ * The route and the criteria of a listing's first page: the named list's scope, a screen's cut
28
+ * and the caller's criteria ANDed, the page size set.
29
+ *
30
+ * listingAsk(porCobrar, { pageSize: 25 })
31
+ * → { route: "/facturas", criteria: { selection: state = posted, pagination: { limit: 25 } } }
32
+ *
33
+ * Context: `useListing` asks it on mount and `readListing` asks it on a server, so a page read
34
+ * there is the very page the screen would have asked for, and hydrating it reads nothing twice.
35
+ */
36
+ export function listingAsk(given, own = {}, cut) {
37
+ const definition = isList(given) ? given : undefined;
38
+ const entity = definition?.entity ?? given;
39
+ const parts = [
40
+ ...(definition === undefined ? [] : [scopeOf(definition)]),
41
+ ...(cut === undefined ? [] : [{ selection: cut }]),
42
+ ...(own.criteria === undefined ? [] : [own.criteria]),
43
+ ];
44
+ const asked = parts.length === 0 ? undefined : parts.reduce((all, one) => merge(all, one));
45
+ const size = own.pageSize ?? asked?.pagination?.limit ?? 50;
46
+ return {
47
+ route: listRoute(entity.list, own.params),
48
+ criteria: { ...asked, pagination: { ...asked?.pagination, limit: size } },
49
+ };
50
+ }
51
+ /**
52
+ * A listing's first page, read outside React — on the server that renders the screen, in a
53
+ * route's loader —, through the same transport the `FrameworkProvider` is given. Handed to
54
+ * `useListing(list, { ...own, page })`, the screen starts from it and asks nothing on mount.
55
+ *
56
+ * // the loader, on the server
57
+ * const page = await readListing(transport, misPagos, { criteria: delColegiado });
58
+ * // the screen, rendered there and hydrated in the browser
59
+ * const listing = useListing(misPagos, { criteria: delColegiado, page });
60
+ *
61
+ * A chooser's cut (`ListScopeProvider`) lives in the screen and is not read here: a listing
62
+ * under one is asked with it by the screen, as a SPA does.
63
+ */
64
+ export function readListing(transport, given, own = {}, signal) {
65
+ const { route, criteria } = listingAsk(given, own);
66
+ return screensTransport(transport).list(route, criteria, signal);
67
+ }
25
68
  /**
26
69
  * An entity's trash, as a named list: its archived records (sincpro_framework's `Archive`,
27
70
  * `ArchivableMixin`), each row offering «Restore» when the entity declares `restore`.
@@ -1,5 +1,5 @@
1
1
  import { type CommandBodies, type Entity } from "@sincpro/client-framework";
2
- import { type AnyRecord, type Count, type Criteria, type Dropped, type Expression, type Meta, type ReadingStatus, type Sort } from "@sincpro/criteria";
2
+ import { type AnyRecord, type Count, type Criteria, type Dropped, type Expression, type Meta, type Page, type ReadingStatus, type Sort } from "@sincpro/criteria";
3
3
  import { type ListDefinition } from "../core/list.js";
4
4
  /**
5
5
  * N records of an entity, live: what a list draws and the gestures that drive it.
@@ -94,5 +94,11 @@ export type ListingOptions<T> = {
94
94
  pageSize?: number;
95
95
  /** `more` mode: the most rows ever on screen. 500 by default. */
96
96
  maxRows?: number;
97
+ /**
98
+ * The first page already read — on the server, by `readListing` with this same list and
99
+ * these same options. The listing starts `ready` with it, renders its rows there, and in the
100
+ * browser keeps it instead of asking again. Without it, the listing reads on mount (a SPA).
101
+ */
102
+ page?: Page<T>;
97
103
  };
98
104
  export declare function useListing<T extends AnyRecord, C extends CommandBodies = CommandBodies>(given: Entity<T, C> | ListDefinition<T>, own?: ListingOptions<T>): Listing<T, C>;
@@ -1,8 +1,8 @@
1
1
  "use client";
2
- import { listRoute } from "@sincpro/client-framework";
2
+ import {} from "@sincpro/client-framework";
3
3
  import { merge, resource, resumingFrom, searchOver, } from "@sincpro/criteria";
4
4
  import { useReading } from "@sincpro/criteria-react";
5
- import { isList, scopeOf } from "../core/list.js";
5
+ import { isList, listingAsk } from "../core/list.js";
6
6
  import { useFramework } from "./context.js";
7
7
  import { useListScope } from "./scope.js";
8
8
  import { useWrites } from "./useWrites.js";
@@ -17,30 +17,18 @@ export function useListing(given, own = {}) {
17
17
  const entity = (definition?.entity ?? given);
18
18
  // The screen's cut for this entity (a chooser's, `ListScopeProvider`) ANDs like a scope.
19
19
  const cut = useListScope(entity.key);
20
- const scopes = [
21
- ...(definition === undefined ? [] : [scopeOf(definition)]),
22
- ...(cut === undefined ? [] : [{ selection: cut }]),
23
- ];
24
- const options = scopes.length === 0
25
- ? own
26
- : {
27
- ...own,
28
- criteria: [...scopes, ...(own.criteria === undefined ? [] : [own.criteria])].reduce((all, one) => merge(all, one)),
29
- };
30
- const route = listRoute(entity.list, options.params);
20
+ // The first page's question — the list's scope, the cut, the caller's criteria, the page
21
+ // size —: the same `readListing` asks on a server, so a page read there is this one.
22
+ const { route, criteria: asked } = listingAsk(given, own, cut);
31
23
  const source = useMemo(() => resource((criteria, signal) => transport.list(route, criteria, signal)), [transport, route]);
32
24
  // A definition already known draws the columns before the first page arrives; the one the
33
25
  // transport reads from the discovery document comes with it.
34
26
  const [preloaded] = useState(() => metas.get(entity.key));
35
- const paging = options.paging ?? "pages";
36
- const size = options.pageSize ?? options.criteria?.pagination?.limit ?? 50;
37
- const maxRows = options.maxRows ?? 500;
38
- const asked = {
39
- ...options.criteria,
40
- pagination: { ...options.criteria?.pagination, limit: size },
41
- };
27
+ const paging = own.paging ?? "pages";
28
+ const size = asked.pagination?.limit ?? 50;
29
+ const maxRows = own.maxRows ?? 500;
42
30
  const base = asked;
43
- const reading = useReading(source, base);
31
+ const reading = useReading(source, base, own.page === undefined ? {} : { page: own.page });
44
32
  // `pages` mode: the cursor that opens each page walked so far — page 0 opens with none.
45
33
  const [cursors, setCursors] = useState([null]);
46
34
  // The definition is kept across refinements: a refine in flight must not blank the columns.
@@ -28,8 +28,16 @@ type UseCase<A extends unknown[], R> = (...args: A) => R | Promise<R>;
28
28
  * screen until the new one lands. The last question wins: an answer to arguments no longer on
29
29
  * screen is dropped. The use case is the latest the screen gave (a bounded context answers a new
30
30
  * function per `scoped(…)`); its trace and report are the service's, never this hook's.
31
+ *
32
+ * `initial` is the answer to these same arguments already read — on the server that renders the
33
+ * screen, in a route's loader, by calling the same use case. The reading starts `ready` with it,
34
+ * renders it there, and in the browser keeps it on mount instead of reading again; a change of
35
+ * arguments, a followed write or `reload()` read as always.
36
+ *
37
+ * const portada = useServiceReading(sitio.portada, [], { initial: loaderData.portada });
31
38
  */
32
39
  export declare function useServiceReading<A extends unknown[], R>(useCase: UseCase<A, R>, args: A, options?: {
33
40
  follows?: readonly Entity[];
41
+ initial?: Awaited<R>;
34
42
  }): ServiceReading<Awaited<R>>;
35
43
  export {};
@@ -30,13 +30,24 @@ function routeOf(entity) {
30
30
  * screen until the new one lands. The last question wins: an answer to arguments no longer on
31
31
  * screen is dropped. The use case is the latest the screen gave (a bounded context answers a new
32
32
  * function per `scoped(…)`); its trace and report are the service's, never this hook's.
33
+ *
34
+ * `initial` is the answer to these same arguments already read — on the server that renders the
35
+ * screen, in a route's loader, by calling the same use case. The reading starts `ready` with it,
36
+ * renders it there, and in the browser keeps it on mount instead of reading again; a change of
37
+ * arguments, a followed write or `reload()` read as always.
38
+ *
39
+ * const portada = useServiceReading(sitio.portada, [], { initial: loaderData.portada });
33
40
  */
34
41
  export function useServiceReading(useCase, args, options = {}) {
35
42
  const { context, changes, entities } = useFramework();
36
43
  const key = JSON.stringify(args);
37
44
  const latest = useRef({ useCase, args });
38
45
  latest.current = { useCase, args };
39
- const [answered, setAnswered] = useState(null);
46
+ const [answered, setAnswered] = useState(() => options.initial === undefined
47
+ ? null
48
+ : { key, status: "ready", answer: options.initial, error: null });
49
+ // Born answered: the first read on mount is the one the server already made.
50
+ const seeded = useRef(options.initial !== undefined);
40
51
  const [again, setAgain] = useState(0);
41
52
  // A write anyone sends — a save, another use case, a panel beside — to what it follows.
42
53
  const followed = (options.follows ?? [])
@@ -53,6 +64,10 @@ export function useServiceReading(useCase, args, options = {}) {
53
64
  });
54
65
  }, [changes, entities, followed]);
55
66
  useEffect(() => {
67
+ if (seeded.current) {
68
+ seeded.current = false;
69
+ return;
70
+ }
56
71
  let current = true;
57
72
  const { useCase: read, args: now } = latest.current;
58
73
  // Through the promise: a use case that throws before it answers is a failure like any other.
@@ -24,11 +24,15 @@ export type FieldControl = {
24
24
  * note, so every application passed `as` for each long text. Only the framework's own names are
25
25
  * read here: a name an application registers is drawn with `as`, never looked up in a registry
26
26
  * of strings.
27
+ *
28
+ * `segmented`: the form asks for a short choice to be a segmented control — web-ui's «settings»
29
+ * form style, for a REQUIRED choice (a segmented control cannot be emptied). It still is a select
30
+ * in a cell, and with more than three options or a label that would not fit beside the others.
27
31
  */
28
32
  export declare function controlFor(control: FieldControl, type: string, exact: boolean, choices: {
29
33
  value: unknown;
30
34
  label: string;
31
- }[], widget?: string): ReactNode;
35
+ }[], widget?: string, segmented?: boolean): ReactNode;
32
36
  /**
33
37
  * A many2one's control: the picker of the entity it points at — the server's literal search,
34
38
  * the first ten, «Buscar más…» — opening the chosen one where the view says.
@@ -2,7 +2,11 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { dayOf, instantOf, timeZoneNow, wallTimeOf, } from "@sincpro/client-framework";
4
4
  import { EntityPicker } from "./EntityPicker.js";
5
- import { Checkbox, CheckList, DatePicker, DateTimePicker, NumberInput, Select, TagsField, TextArea, TextInput, } from "@sincpro/web-ui";
5
+ import { Checkbox, CheckList, DatePicker, DateTimePicker, NumberInput, SegmentedControl, Select, TagsField, TextArea, TextInput, } from "@sincpro/web-ui";
6
+ /** A choice answered with one press — a segmented control — instead of a select: up to three
7
+ * options that fit side by side. */
8
+ const FEW_CHOICES = 3;
9
+ const SHORT_LABEL = 24;
6
10
  /**
7
11
  * The control a field's TYPE asks for — a choice, several of a choice (checks), a number, a
8
12
  * date, a date and time, a yes/no, a list of words, a text — or the one its `widget` names when the model names one of the
@@ -15,14 +19,24 @@ import { Checkbox, CheckList, DatePicker, DateTimePicker, NumberInput, Select, T
15
19
  * note, so every application passed `as` for each long text. Only the framework's own names are
16
20
  * read here: a name an application registers is drawn with `as`, never looked up in a registry
17
21
  * of strings.
22
+ *
23
+ * `segmented`: the form asks for a short choice to be a segmented control — web-ui's «settings»
24
+ * form style, for a REQUIRED choice (a segmented control cannot be emptied). It still is a select
25
+ * in a cell, and with more than three options or a label that would not fit beside the others.
18
26
  */
19
- export function controlFor(control, type, exact, choices, widget) {
27
+ export function controlFor(control, type, exact, choices, widget, segmented = false) {
20
28
  const { value, set } = control;
21
29
  const named = control.standalone === true ? { "aria-label": control.label } : {};
22
30
  // Several of the values at once — a list whose values are a choice: each one a check, the
23
31
  // list's label above them.
24
32
  if (choices.length > 0 && type.endsWith("[]"))
25
33
  return (_jsx(CheckList, { label: control.label, items: choices.map((one) => ({ value: String(one.value), label: one.label })), value: Array.isArray(value) ? value.map(String) : [], onChange: set }));
34
+ if (segmented &&
35
+ control.standalone !== true &&
36
+ choices.length > 0 &&
37
+ choices.length <= FEW_CHOICES &&
38
+ choices.every((one) => one.label.length <= SHORT_LABEL))
39
+ return (_jsx(SegmentedControl, { value: value === null || value === undefined ? "" : String(value), options: choices.map((one) => ({ value: String(one.value), label: one.label })), onChange: set }));
26
40
  if (choices.length > 0)
27
41
  return (_jsx(Select, { value: value === null || value === undefined ? "" : String(value), options: choices.map((one) => ({ value: String(one.value), label: one.label })), onChange: set, ...named }));
28
42
  switch (type) {
@@ -14,7 +14,7 @@ import { RecordLinesEditor } from "./lines.js";
14
14
  import { useRecordOpening } from "./opening.js";
15
15
  import { RecordLines } from "./record.js";
16
16
  import { RelatedList } from "./RelatedList.js";
17
- import { Checkbox, Field, FormSection, ReadValue, RelationValue, } from "@sincpro/web-ui";
17
+ import { Checkbox, Field, FormSection, ReadValue, RelationValue, useFormStyle, } from "@sincpro/web-ui";
18
18
  /** `value` with `path` (`numero`, or `emisor.nit`) set to `next` — a new object, the rest kept. */
19
19
  function setAt(value, path, next) {
20
20
  const base = typeof value === "object" && value !== null ? value : {};
@@ -79,6 +79,7 @@ export function RecordField({ record, name, as, bare = false, lines: look, list:
79
79
  const target = useEntityFor(relation?.target);
80
80
  const opening = useRecordOpening();
81
81
  const { metas } = useFramework();
82
+ const settings = useFormStyle() === "settings";
82
83
  if (!state.visible)
83
84
  return null;
84
85
  // A one2many is a BLOCK, named by a section — never a `Field`: web-ui's controls read the
@@ -191,7 +192,9 @@ export function RecordField({ record, name, as, bare = false, lines: look, list:
191
192
  return controlFor(control, view.type, false, choices, field?.widget);
192
193
  if (view.type === "boolean" && as === undefined)
193
194
  return (_jsx(Checkbox, { checked: value === true, onChange: control.set, label: view.label, disabled: state.readonly }));
194
- return (_jsx(Field, { label: view.label, required: state.required && !state.readonly, ...(view.help === undefined ? {} : { hint: view.help }), ...(error === undefined ? {} : { error }), children: as !== undefined ? (as(control)) : relation !== undefined && !relation.many && target !== undefined ? (manyToOne()) : state.readonly ? (_jsx(ReadValue, { value: textOf(meta, name, value, locale) ?? "—" })) : (controlFor(control, view.type, field?.exact === true, choices, field?.widget)) }));
195
+ return (_jsx(Field, { label: view.label, required: state.required && !state.readonly,
196
+ // Said only in web-ui's «settings» form style: a field that may stay empty, and is typed in.
197
+ optional: !state.required && !state.readonly, ...(view.help === undefined ? {} : { hint: view.help }), ...(error === undefined ? {} : { error }), children: as !== undefined ? (as(control)) : relation !== undefined && !relation.many && target !== undefined ? (manyToOne()) : state.readonly ? (_jsx(ReadValue, { value: textOf(meta, name, value, locale) ?? "—" })) : (controlFor(control, view.type, field?.exact === true, choices, field?.widget, settings && state.required)) }));
195
198
  }
196
199
  /**
197
200
  * The record's «save / discard», for `<Record dirty={…}>`: present only while something changed,
@@ -50,7 +50,7 @@ export declare function useRecordScreen<T extends AnyRecord>(entity: Entity<T>,
50
50
  record: {
51
51
  error?: string | undefined;
52
52
  dirty?: import("@sincpro/web-ui").DirtyState | undefined;
53
- placement: "card" | "page";
53
+ placement: "page" | "card";
54
54
  identity: {
55
55
  tag?: {
56
56
  tone?: import("@sincpro/web-ui").Tone | undefined;
@@ -17,7 +17,7 @@ import { dirtyOf, RecordField } from "../record/edit.js";
17
17
  import { RecordLifecycle } from "../record/RecordLifecycle.js";
18
18
  import { Refused } from "../Refused.js";
19
19
  import { useRecordInWorkspace } from "./workspace.js";
20
- import { Button, Callout, FormSection, Record, Skeleton } from "@sincpro/web-ui";
20
+ import { Button, Callout, FormSection, Record, Skeleton, useFormStyle, } from "@sincpro/web-ui";
21
21
  import { useState } from "react";
22
22
  /**
23
23
  * The record of an entity, drawn from its model — the screen `entityView` opens when the
@@ -158,6 +158,7 @@ export function EntityRecord({ api, resource, entity, fields, pages, actions, ti
158
158
  // On a phone a form is one column, its label over its value: two side by side at 400 px
159
159
  // squeezed a text area beside its word (web-ui's grid does not narrow by itself).
160
160
  const phone = usePhone(api);
161
+ const settings = useFormStyle() === "settings";
161
162
  if (reading.status === "loading")
162
163
  return _jsx(Skeleton, { rows: 6, label: copy.loading });
163
164
  if (reading.status === "failed")
@@ -180,7 +181,9 @@ export function EntityRecord({ api, resource, entity, fields, pages, actions, ti
180
181
  const own = actions?.(reading) ?? null;
181
182
  const ownActions = own === null && lifecycle === null ? null : (_jsxs(_Fragment, { children: [own, lifecycle] }));
182
183
  const tabs = pages ?? layout.pages;
183
- 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, children: shown.map((name) => (_jsx(RecordField, { record: reading, name: name }, name))) }), fields !== undefined
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
184
187
  ? null
185
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
186
189
  .filter((one) => (one.path?.length ?? 0) <= 1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sincpro/web-framework",
3
- "version": "3.3.0",
3
+ "version": "3.5.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",
@@ -41,10 +41,10 @@
41
41
  "@opentelemetry/sdk-trace": "^3.1.0",
42
42
  "@sentry/browser": "^11.11.0",
43
43
  "@sincpro/client-framework": "^2.2.0",
44
- "@sincpro/criteria": "^2.2.2",
45
- "@sincpro/criteria-react": "^2.1.0",
44
+ "@sincpro/criteria": "^2.3.0",
45
+ "@sincpro/criteria-react": "^2.3.0",
46
46
  "@sincpro/web-composer": "^1.7.0",
47
- "@sincpro/web-ui": "^2.1.0",
47
+ "@sincpro/web-ui": "^2.5.0",
48
48
  "react": ">=19",
49
49
  "react-dom": ">=19"
50
50
  },
@@ -73,10 +73,10 @@
73
73
  "@opentelemetry/sdk-trace": "3.1.0",
74
74
  "@sentry/browser": "11.11.0",
75
75
  "@sincpro/client-framework": "^2.2.0",
76
- "@sincpro/criteria": "^2.2.2",
77
- "@sincpro/criteria-react": "^2.1.0",
76
+ "@sincpro/criteria": "^2.3.0",
77
+ "@sincpro/criteria-react": "^2.3.0",
78
78
  "@sincpro/web-composer": "^1.8.0",
79
- "@sincpro/web-ui": "^2.4.0",
79
+ "@sincpro/web-ui": "^2.5.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",