@sincpro/web-framework 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +31 -28
  2. package/dist/core/edit.d.ts +19 -0
  3. package/dist/core/edit.js +46 -0
  4. package/dist/core/index.d.ts +3 -3
  5. package/dist/core/index.js +3 -3
  6. package/dist/core/list.d.ts +20 -0
  7. package/dist/core/list.js +32 -1
  8. package/dist/core/present.d.ts +22 -0
  9. package/dist/core/present.js +51 -19
  10. package/dist/react/index.d.ts +3 -0
  11. package/dist/react/index.js +3 -0
  12. package/dist/react/useCount.d.ts +18 -0
  13. package/dist/react/useCount.js +23 -0
  14. package/dist/react/useRecord.d.ts +4 -4
  15. package/dist/react/useRecord.js +10 -7
  16. package/dist/react/useService.d.ts +5 -1
  17. package/dist/react/useServiceReading.d.ts +35 -0
  18. package/dist/react/useServiceReading.js +75 -0
  19. package/dist/react/useTextOf.d.ts +16 -0
  20. package/dist/react/useTextOf.js +21 -0
  21. package/dist/web/list/EntityList.d.ts +4 -1
  22. package/dist/web/list/EntityList.js +6 -3
  23. package/dist/web/list/EntitySearchBar.d.ts +4 -1
  24. package/dist/web/list/EntitySearchBar.js +2 -2
  25. package/dist/web/list/groups.d.ts +13 -3
  26. package/dist/web/list/groups.js +21 -8
  27. package/dist/web/list/openIn.d.ts +4 -2
  28. package/dist/web/list/openIn.js +9 -2
  29. package/dist/web/record/control.d.ts +9 -3
  30. package/dist/web/record/control.js +13 -4
  31. package/dist/web/record/edit.js +1 -1
  32. package/dist/web/record/lines.js +1 -1
  33. package/dist/web/record/record.js +36 -3
  34. package/dist/web/workspace/composer.d.ts +6 -2
  35. package/dist/web/workspace/composer.js +31 -12
  36. package/dist/web/workspace/open.d.ts +1 -1
  37. package/dist/web/workspace/open.js +7 -1
  38. package/dist/web/workspace/record.d.ts +6 -2
  39. package/dist/web/workspace/record.js +6 -5
  40. package/dist/web/workspace/workspace.d.ts +7 -1
  41. package/dist/web/workspace/workspace.js +13 -4
  42. package/package.json +4 -4
@@ -35,7 +35,9 @@ export type Stamp = {
35
35
  * `Record.Rail`), and a region wrapped in one of ours is not found. Before it, forge's console
36
36
  * carried these 150 lines itself (`shared/record_screen.tsx`).
37
37
  */
38
- export declare function useRecordScreen<T extends AnyRecord>(entity: Entity<T>, { api, resource }: Pick<ViewProps, "api" | "resource">): {
38
+ export declare function useRecordScreen<T extends AnyRecord>(entity: Entity<T>, { api, resource }: Pick<ViewProps, "api" | "resource">, options?: {
39
+ title?: ((record: T) => string | null) | undefined;
40
+ }): {
39
41
  reading: RecordReading<T>;
40
42
  crumbs: readonly import("@sincpro/web-composer").Crumb[];
41
43
  history: import("../../index.js").HistoryEntry[] | undefined;
@@ -66,8 +68,10 @@ export declare function useRecordScreen<T extends AnyRecord>(entity: Entity<T>,
66
68
  created?: Stamp | undefined;
67
69
  } | undefined;
68
70
  };
69
- export declare function EntityRecord<T extends AnyRecord>({ api, resource, entity, fields, pages, actions, }: ViewProps & {
71
+ export declare function EntityRecord<T extends AnyRecord>({ api, resource, entity, fields, pages, actions, title, }: ViewProps & {
70
72
  entity: Entity<T>;
73
+ /** Its name, the screen's way — for a record whose model has no display field. */
74
+ title?: (record: T) => string | null;
71
75
  /** The fields, in this order. Without it, the model's (`formOf`). */
72
76
  fields?: readonly string[];
73
77
  /** The one2many shown as pages, in this order. Without it, every one the model has. */
@@ -64,10 +64,10 @@ function refusalOf(failure) {
64
64
  * `Record.Rail`), and a region wrapped in one of ours is not found. Before it, forge's console
65
65
  * carried these 150 lines itself (`shared/record_screen.tsx`).
66
66
  */
67
- export function useRecordScreen(entity, { api, resource }) {
67
+ export function useRecordScreen(entity, { api, resource }, options = {}) {
68
68
  const reading = useRecord(entity, resource);
69
69
  const crumbs = useCrumbs(api);
70
- useRecordInWorkspace(api, reading);
70
+ useRecordInWorkspace(api, reading, options);
71
71
  const history = useHistory(entity, reading.isNew ? "" : reading.id, [reading.record]);
72
72
  const summarize = useSummaryOf(entity);
73
73
  const copy = frameworkCopy().record;
@@ -112,7 +112,8 @@ export function useRecordScreen(entity, { api, resource }) {
112
112
  placement: api.surface === "modal" ? "card" : "page",
113
113
  identity: {
114
114
  // A new record is «creating»; an existing one has no name until it is read.
115
- title: summary?.name ??
115
+ title: (ready && !reading.isNew ? options.title?.(reading.record) : null) ??
116
+ summary?.name ??
116
117
  (reading.isNew ? copy.creating(nameOf(reading.meta, reading.locale) || "") : ""),
117
118
  ...(summary?.type == null ? {} : { subtitle: summary.type }),
118
119
  ...(summary?.state == null ? {} : { tag: { label: summary.state } }),
@@ -134,8 +135,8 @@ export function useRecordScreen(entity, { api, resource }) {
134
135
  },
135
136
  };
136
137
  }
137
- export function EntityRecord({ api, resource, entity, fields, pages, actions, }) {
138
- const screen = useRecordScreen(entity, { api, resource });
138
+ export function EntityRecord({ api, resource, entity, fields, pages, actions, title, }) {
139
+ const screen = useRecordScreen(entity, { api, resource }, { title });
139
140
  const { reading, crumbs, history, pager } = screen;
140
141
  const [page, setPage] = useState(undefined);
141
142
  const copy = frameworkCopy().record;
@@ -17,10 +17,16 @@ import type { RecordReading } from "../../react/useRecord.js";
17
17
  * to ANSWER (`api.pick(entity.newRef(…))` — «Agregar» on a record's one2many), it answers the
18
18
  * record it became instead, and the surface closes: whoever asked reads it again.
19
19
  *
20
+ * Its name is the model's display field — or the screen's word for it (`title`), for a record
21
+ * whose model has none: a singleton («the institution's texts») would read as its key.
22
+ *
20
23
  * const invoice = useRecord(invoices, resource);
21
24
  * useRecordInWorkspace(api, invoice);
25
+ * useRecordInWorkspace(api, texts, { title: () => "Textos de la institución" });
22
26
  */
23
- export declare function useRecordInWorkspace<T extends AnyRecord>(api: WorkspaceApi, record: RecordReading<T>): void;
27
+ export declare function useRecordInWorkspace<T extends AnyRecord>(api: WorkspaceApi, record: RecordReading<T>, options?: {
28
+ title?: ((record: T) => string | null) | undefined;
29
+ }): void;
24
30
  /**
25
31
  * «Browse everything» as the composer's chooser: the entity's own list opens in a window and
26
32
  * the row clicked there answers the field.
@@ -20,16 +20,25 @@ import { useEffect } from "react";
20
20
  * to ANSWER (`api.pick(entity.newRef(…))` — «Agregar» on a record's one2many), it answers the
21
21
  * record it became instead, and the surface closes: whoever asked reads it again.
22
22
  *
23
+ * Its name is the model's display field — or the screen's word for it (`title`), for a record
24
+ * whose model has none: a singleton («the institution's texts») would read as its key.
25
+ *
23
26
  * const invoice = useRecord(invoices, resource);
24
27
  * useRecordInWorkspace(api, invoice);
28
+ * useRecordInWorkspace(api, texts, { title: () => "Textos de la institución" });
25
29
  */
26
- export function useRecordInWorkspace(api, record) {
30
+ export function useRecordInWorkspace(api, record, options = {}) {
27
31
  const display = record.meta?.display || record.meta?.identity || "";
32
+ const named = record.status === "ready" && options.title !== undefined
33
+ ? options.title(record.record)
34
+ : null;
28
35
  const title = record.isNew
29
36
  ? newTitle(record.meta, record.locale)
30
- : record.status === "ready" && display !== ""
31
- ? textOf(record.meta, display, record.record[display], record.locale)
32
- : null;
37
+ : named !== null
38
+ ? named
39
+ : record.status === "ready" && display !== ""
40
+ ? textOf(record.meta, display, record.record[display], record.locale)
41
+ : null;
33
42
  const dirty = record.edit.dirty;
34
43
  const opened = api.self.id ?? "";
35
44
  const { entity, id } = record;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sincpro/web-framework",
3
- "version": "2.5.0",
3
+ "version": "2.6.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",
@@ -43,7 +43,7 @@
43
43
  "@sincpro/client-framework": "^1.10.0",
44
44
  "@sincpro/criteria": "^2.1.0",
45
45
  "@sincpro/criteria-react": "^2.1.0",
46
- "@sincpro/web-composer": "^1.6.0",
46
+ "@sincpro/web-composer": "^1.7.0",
47
47
  "@sincpro/web-ui": "^2.1.0",
48
48
  "react": ">=19",
49
49
  "react-dom": ">=19"
@@ -75,8 +75,8 @@
75
75
  "@sincpro/client-framework": "^1.10.0",
76
76
  "@sincpro/criteria": "^2.1.0",
77
77
  "@sincpro/criteria-react": "^2.1.0",
78
- "@sincpro/web-composer": "^1.6.0",
79
- "@sincpro/web-ui": "^2.1.0",
78
+ "@sincpro/web-composer": "^1.7.0",
79
+ "@sincpro/web-ui": "^2.2.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",