@sincpro/web-framework 0.2.0 → 0.4.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 (70) hide show
  1. package/README.md +56 -19
  2. package/dist/core/copy.d.ts +2 -0
  3. package/dist/core/copy.js +2 -0
  4. package/dist/core/edit.d.ts +35 -3
  5. package/dist/core/edit.js +49 -5
  6. package/dist/core/entity.d.ts +14 -2
  7. package/dist/core/entity.js +33 -1
  8. package/dist/core/index.d.ts +4 -2
  9. package/dist/core/index.js +4 -2
  10. package/dist/core/lines.d.ts +52 -0
  11. package/dist/core/lines.js +120 -0
  12. package/dist/core/list.d.ts +1 -1
  13. package/dist/core/lookup.d.ts +2 -0
  14. package/dist/core/lookup.js +3 -1
  15. package/dist/core/present.js +7 -2
  16. package/dist/core/rest.d.ts +5 -9
  17. package/dist/core/rest.js +14 -6
  18. package/dist/core/transport.d.ts +9 -1
  19. package/dist/core/zone.d.ts +27 -0
  20. package/dist/core/zone.js +75 -0
  21. package/dist/react/context.d.ts +13 -1
  22. package/dist/react/context.js +10 -2
  23. package/dist/react/index.d.ts +2 -1
  24. package/dist/react/index.js +1 -0
  25. package/dist/react/useGroups.d.ts +13 -1
  26. package/dist/react/useGroups.js +48 -7
  27. package/dist/react/useListing.d.ts +8 -4
  28. package/dist/react/useListing.js +11 -5
  29. package/dist/react/usePivot.d.ts +33 -0
  30. package/dist/react/usePivot.js +59 -0
  31. package/dist/react/useRecord.d.ts +13 -9
  32. package/dist/react/useRecord.js +55 -13
  33. package/dist/web/index.d.ts +7 -1
  34. package/dist/web/index.js +7 -1
  35. package/dist/web/list/EntityList.d.ts +46 -7
  36. package/dist/web/list/EntityList.js +132 -21
  37. package/dist/web/list/EntitySearchBar.js +19 -1
  38. package/dist/web/list/columns.d.ts +0 -13
  39. package/dist/web/list/columns.js +20 -1
  40. package/dist/web/list/groups.d.ts +3 -1
  41. package/dist/web/list/groups.js +8 -1
  42. package/dist/web/list/openIn.d.ts +41 -0
  43. package/dist/web/list/openIn.js +55 -0
  44. package/dist/web/list/pivot.d.ts +23 -0
  45. package/dist/web/list/pivot.js +64 -0
  46. package/dist/web/list/presentation.d.ts +51 -0
  47. package/dist/web/list/presentation.js +20 -0
  48. package/dist/web/record/EntityPicker.d.ts +3 -1
  49. package/dist/web/record/EntityPicker.js +15 -5
  50. package/dist/web/record/EntityTags.js +16 -5
  51. package/dist/web/record/RelatedList.d.ts +6 -0
  52. package/dist/web/record/RelatedList.js +26 -2
  53. package/dist/web/record/control.d.ts +43 -0
  54. package/dist/web/record/control.js +67 -0
  55. package/dist/web/record/edit.d.ts +16 -8
  56. package/dist/web/record/edit.js +57 -49
  57. package/dist/web/record/lines.d.ts +84 -0
  58. package/dist/web/record/lines.js +190 -0
  59. package/dist/web/record/opening.d.ts +8 -0
  60. package/dist/web/record/summary.js +14 -6
  61. package/dist/web/workspace/SincproApp.d.ts +4 -1
  62. package/dist/web/workspace/SincproApp.js +2 -2
  63. package/dist/web/workspace/composer.d.ts +2 -1
  64. package/dist/web/workspace/composer.js +27 -16
  65. package/dist/web/workspace/open.d.ts +2 -14
  66. package/dist/web/workspace/open.js +2 -13
  67. package/dist/web/workspace/record.js +6 -3
  68. package/dist/web/workspace/workspace.d.ts +4 -2
  69. package/dist/web/workspace/workspace.js +10 -4
  70. package/package.json +9 -9
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useSummaryOf } from "../../react/useSummary.js";
4
+ import { openOptions, targetsFor } from "../list/openIn.js";
4
5
  import { relationOf } from "../record/summary.js";
5
6
  import { RelationValue } from "@sincpro/web-ui";
6
7
  /**
@@ -19,19 +20,7 @@ import { RelationValue } from "@sincpro/web-ui";
19
20
  *
20
21
  * The phone is composer's: a modal becomes a sheet, a side panel the page. No view asks.
21
22
  */
22
- /** A record's form fits; a short task (register a payment) passes its own size. */
23
- export const RECORD_SIZE = { w: 760, h: 560 };
24
- const IN_PLACE = ["modal", "peek", "side", "page"];
25
- const FROM_A_MODAL = ["side", "peek", "page"];
26
- /** Where a related record may open from this view, the default first. */
27
- export function targetsFor(api) {
28
- return api.over === null ? IN_PLACE : FROM_A_MODAL;
29
- }
30
- /** web-ui's target as composer's options. Destinations share their names, so only the size is
31
- * added — to the two that have one. */
32
- export function openOptions(to, size = RECORD_SIZE) {
33
- return to === "modal" || to === "window" ? { to, size } : { to };
34
- }
23
+ export { openOptions, RECORD_SIZE, targetsFor } from "../list/openIn.js";
35
24
  /**
36
25
  * Open a record where it was asked, or where it belongs from here.
37
26
  *
@@ -13,7 +13,7 @@ import { useSummaryOf } from "../../react/useSummary.js";
13
13
  import { dirtyOf, RecordField } from "../record/edit.js";
14
14
  import { Refused } from "../Refused.js";
15
15
  import { useRecordInWorkspace } from "./workspace.js";
16
- import { Button, Callout, Record, Skeleton } from "@sincpro/web-ui";
16
+ import { Button, Callout, FormSection, Record, Skeleton } from "@sincpro/web-ui";
17
17
  import { useState } from "react";
18
18
  /**
19
19
  * The record of an entity, drawn from its model — the screen `entityView` opens when the
@@ -32,7 +32,7 @@ import { useState } from "react";
32
32
  * actions={(invoice) => <CommandButton entity={invoices} command="post" … />} /> })
33
33
  */
34
34
  export function EntityRecord({ api, resource, entity, fields, pages, actions, }) {
35
- const reading = useRecord(entity, resource.id ?? "");
35
+ const reading = useRecord(entity, resource);
36
36
  const crumbs = useCrumbs(api);
37
37
  useRecordInWorkspace(api, reading);
38
38
  const history = useHistory(entity, reading.isNew ? "" : reading.id, [reading.record]);
@@ -62,6 +62,7 @@ export function EntityRecord({ api, resource, entity, fields, pages, actions, })
62
62
  const { meta, locale, edit } = reading;
63
63
  const layout = formOf(meta, entity.summary);
64
64
  const shown = fields ?? layout.fields;
65
+ const ownActions = actions?.(reading) ?? null;
65
66
  const tabs = pages ?? layout.pages;
66
67
  const summary = reading.isNew ? undefined : summarize(reading.record, meta);
67
68
  const dirty = dirtyOf(reading);
@@ -76,5 +77,7 @@ export function EntityRecord({ api, resource, entity, fields, pages, actions, })
76
77
  title: summary?.name ?? copy.creating(nameOf(meta, locale) || ""),
77
78
  ...(summary?.type == null ? {} : { subtitle: summary.type }),
78
79
  ...(summary?.state == null ? {} : { tag: { label: summary.state } }),
79
- }, ...(dirty === undefined ? {} : { dirty }), ...(edit.failure === null ? {} : { error: String(edit.failure.message) }), children: [_jsxs(Record.Rail, { children: [crumbs.length === 0 ? null : _jsx(Record.Crumbs, { crumbs: crumbs }), place === null ? null : (_jsx(Record.Pager, { index: place.index, total: place.total, onPrev: go(-1), onNext: go(1) })), _jsx(Record.Actions, { children: actions?.(reading) ?? null })] }), _jsxs(Record.Paper, { layout: "horizontal", children: [_jsxs("div", { className: "flex flex-col gap-3 p-4", 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, shown.map((name) => (_jsx(RecordField, { record: reading, name: name }, name))), edit.advice.map((one) => (_jsx(Callout, { tone: "info", title: one.text, children: null }, one.text)))] }), 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))) })), createdStamp === undefined && updatedStamp === undefined ? null : (_jsx(Record.Audit, { ...(createdStamp === undefined ? {} : { created: createdStamp }), ...(updatedStamp === undefined ? {} : { updated: updatedStamp }) }))] }), history === undefined ? null : _jsx(Record.Activity, { events: history })] }));
80
+ }, ...(dirty === undefined ? {} : { dirty }), ...(edit.failure === null ? {} : { error: String(edit.failure.message) }), children: [crumbs.length === 0 && place === null && ownActions === null ? null : (_jsxs(Record.Rail, { children: [crumbs.length === 0 ? null : _jsx(Record.Crumbs, { crumbs: crumbs }), place === null ? null : (_jsx(Record.Pager, { index: place.index, total: place.total, onPrev: go(-1), onNext: go(1) })), ownActions === null ? null : _jsx(Record.Actions, { children: ownActions })] })), _jsxs(Record.Paper, { layout: "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: api.surface === "page" || api.surface === "modal" ? 2 : 1, children: shown.map((name) => (_jsx(RecordField, { record: reading, name: name }, name))) }), edit.advice
81
+ .filter((one) => (one.path?.length ?? 0) <= 1)
82
+ .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))) })), createdStamp === undefined && updatedStamp === undefined ? null : (_jsx(Record.Audit, { ...(createdStamp === undefined ? {} : { created: createdStamp }), ...(updatedStamp === undefined ? {} : { updated: updatedStamp }) }))] }), history === undefined ? null : _jsx(Record.Activity, { events: history })] }));
80
83
  }
@@ -13,9 +13,11 @@ import type { RecordReading } from "../../react/useRecord.js";
13
13
  *
14
14
  * A NEW record (opened with `entity.newRef()`) reads «Facturas · nuevo» until it exists; the
15
15
  * moment its create answers, the surface is REPLACED by the record it became (`api.replace`):
16
- * no crumb leads back to an empty form, and the window, peek or page it was in stays.
16
+ * no crumb leads back to an empty form, and the window, peek or page it was in stays. Opened
17
+ * to ANSWER (`api.pick(entity.newRef(…))` — «Agregar» on a record's one2many), it answers the
18
+ * record it became instead, and the surface closes: whoever asked reads it again.
17
19
  *
18
- * const invoice = useRecord(invoices, resource.id ?? "");
20
+ * const invoice = useRecord(invoices, resource);
19
21
  * useRecordInWorkspace(api, invoice);
20
22
  */
21
23
  export declare function useRecordInWorkspace<T extends AnyRecord>(api: WorkspaceApi, record: RecordReading<T>): void;
@@ -15,9 +15,11 @@ import { useEffect } from "react";
15
15
  *
16
16
  * A NEW record (opened with `entity.newRef()`) reads «Facturas · nuevo» until it exists; the
17
17
  * moment its create answers, the surface is REPLACED by the record it became (`api.replace`):
18
- * no crumb leads back to an empty form, and the window, peek or page it was in stays.
18
+ * no crumb leads back to an empty form, and the window, peek or page it was in stays. Opened
19
+ * to ANSWER (`api.pick(entity.newRef(…))` — «Agregar» on a record's one2many), it answers the
20
+ * record it became instead, and the surface closes: whoever asked reads it again.
19
21
  *
20
- * const invoice = useRecord(invoices, resource.id ?? "");
22
+ * const invoice = useRecord(invoices, resource);
21
23
  * useRecordInWorkspace(api, invoice);
22
24
  */
23
25
  export function useRecordInWorkspace(api, record) {
@@ -30,10 +32,14 @@ export function useRecordInWorkspace(api, record) {
30
32
  const dirty = record.edit.dirty;
31
33
  const opened = api.self.id ?? "";
32
34
  const { entity, id } = record;
33
- // Created here: show what it became, in place of the form.
35
+ // Created here: show what it became in place of the form — or hand it to whoever asked.
34
36
  useEffect(() => {
35
- if (opened === "" && id !== "")
37
+ if (opened !== "" || id === "")
38
+ return;
39
+ if (api.choosing === null)
36
40
  api.replace(entity.ref(id));
41
+ else
42
+ api.answer(entity.ref(id));
37
43
  }, [api, opened, entity, id]);
38
44
  useEffect(() => {
39
45
  api.setTitle(title);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sincpro/web-framework",
3
- "version": "0.2.0",
3
+ "version": "0.4.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",
@@ -23,19 +23,19 @@
23
23
  "printWidth": 94
24
24
  },
25
25
  "peerDependencies": {
26
- "@sincpro/criteria": "^0.3.0",
27
- "@sincpro/criteria-react": "^0.3.0",
28
- "@sincpro/web-composer": "^1.4.0",
29
- "@sincpro/web-ui": "^1.1.0",
26
+ "@sincpro/criteria": "^0.3.1",
27
+ "@sincpro/criteria-react": "^0.3.1",
28
+ "@sincpro/web-composer": "^1.5.0",
29
+ "@sincpro/web-ui": "^1.7.2",
30
30
  "react": ">=19",
31
31
  "react-dom": ">=19"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@eslint/js": "^10.0.1",
35
- "@sincpro/criteria": "^0.3.0",
36
- "@sincpro/criteria-react": "^0.3.0",
37
- "@sincpro/web-composer": "^1.4.0",
38
- "@sincpro/web-ui": "^1.1.0",
35
+ "@sincpro/criteria": "^0.3.1",
36
+ "@sincpro/criteria-react": "^0.3.1",
37
+ "@sincpro/web-composer": "^1.5.0",
38
+ "@sincpro/web-ui": "^1.7.2",
39
39
  "@storybook/addon-a11y": "10.6.5",
40
40
  "@storybook/addon-docs": "10.6.5",
41
41
  "@storybook/addon-mcp": "10.6.5",