@declarion/react 0.446.0 → 0.517.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 (43) hide show
  1. package/dist-lib/components/agents/AgentChatPanel.impl.js +349 -332
  2. package/dist-lib/components/detail-layout/DetailAuditStrip.js +1 -1
  3. package/dist-lib/components/detail-layout/EvidenceBlock.js +36 -24
  4. package/dist-lib/components/detail-layout/FieldRow.js +56 -60
  5. package/dist-lib/components/detail-layout/FieldsBlock.js +48 -47
  6. package/dist-lib/components/detail-layout/PropertiesBlock.js +42 -41
  7. package/dist-lib/components/detail-layout/labelLayout.js +35 -0
  8. package/dist-lib/components/fields/JsonField.js +128 -125
  9. package/dist-lib/components/fields/StringField.js +10 -25
  10. package/dist-lib/components/fields/StructureField.js +125 -167
  11. package/dist-lib/components/fields/ValueRows.js +114 -0
  12. package/dist-lib/components/fields/cells/factories/id.js +10 -0
  13. package/dist-lib/components/fields/cells/factories/nextRun.js +18 -27
  14. package/dist-lib/components/fields/cells/factories/refLink.js +15 -41
  15. package/dist-lib/components/fields/cells/registry.js +25 -23
  16. package/dist-lib/components/file-widgets/DocumentCard.js +142 -142
  17. package/dist-lib/components/file-widgets/helpers.js +32 -19
  18. package/dist-lib/components/file-widgets/host.js +4 -1
  19. package/dist-lib/components/list/PeekFieldCell.js +57 -55
  20. package/dist-lib/components/list/QuickPeek.js +109 -121
  21. package/dist-lib/components/pages/SmartDetailPage.impl.js +403 -400
  22. package/dist-lib/components/pages/SmartListPage.impl.js +260 -260
  23. package/dist-lib/components/pages/list/ListCardRow.js +101 -100
  24. package/dist-lib/components/pages/list/cardProjection.js +117 -112
  25. package/dist-lib/components/pages/list/useListQuery.js +1 -1
  26. package/dist-lib/components/pages/list/useListRowInteraction.js +68 -65
  27. package/dist-lib/components/primitives/IdBadge.js +27 -0
  28. package/dist-lib/components/primitives/RowField.js +11 -43
  29. package/dist-lib/components/shared/CopyButton.js +13 -18
  30. package/dist-lib/components/shared/RefChip.js +33 -0
  31. package/dist-lib/declarion-react.css +1 -1
  32. package/dist-lib/hooks/useAgentConversation.js +134 -110
  33. package/dist-lib/hooks/useCopy.js +18 -0
  34. package/dist-lib/index.d.ts +55 -20
  35. package/dist-lib/index.js +116 -111
  36. package/dist-lib/lib/realtime-reconcile.js +70 -59
  37. package/dist-lib/lib/reference.js +52 -34
  38. package/dist-lib/lib/short-id.js +12 -0
  39. package/dist-lib/testing.d.ts +1 -1
  40. package/dist-lib/types/schema.js +84 -80
  41. package/dist-lib/{useResponsiveMode-3hOLBkey.d.ts → useResponsiveMode-BObVfNyN.d.ts} +7 -2
  42. package/package.json +6 -1
  43. package/dist-lib/components/primitives/RecordIdBadge.js +0 -25
@@ -1,4 +1,4 @@
1
- import { B as Refs, M as ListMeta, Mt as TextFn, P as ListResponse, ct as LocalizedString, d as ActionExecuteResponse, k as DataResponse, mt as Schema, o as ResponsiveViewport, u as ActionExecuteRequest } from "./useResponsiveMode-3hOLBkey.js";
1
+ import { B as Refs, M as ListMeta, Mt as TextFn, P as ListResponse, ct as LocalizedString, d as ActionExecuteResponse, k as DataResponse, mt as Schema, o as ResponsiveViewport, u as ActionExecuteRequest } from "./useResponsiveMode-BObVfNyN.js";
2
2
  import { ReactElement, ReactNode } from "react";
3
3
  import { QueryClient } from "@tanstack/react-query";
4
4
  import { RenderResult } from "@testing-library/react";
@@ -1,20 +1,21 @@
1
1
  import { OrderedMap as e } from "./ordmap.js";
2
- import { coerceDisplayString as t } from "../lib/display-value.js";
3
- import { formatOffsetTimestamp as n } from "../lib/timestamp.js";
2
+ import { shortId as t } from "../lib/short-id.js";
3
+ import { coerceDisplayString as n } from "../lib/display-value.js";
4
+ import { formatOffsetTimestamp as r } from "../lib/timestamp.js";
4
5
  // src/types/schema.ts
5
- var r = "none", i = "$display";
6
- function a(e, r, a) {
7
- if (!r) return;
8
- let o = r[i];
6
+ var i = "none", a = "$display";
7
+ function o(e, t, i) {
8
+ if (!t) return;
9
+ let o = t[a];
9
10
  if (typeof o == "string" && o !== "") return o;
10
- let s = a?.display?.display_field;
11
+ let s = i?.display?.display_field;
11
12
  if (!s) return;
12
- let c = r[s];
13
+ let c = t[s];
13
14
  if (c == null) return;
14
- let l = a?.fields?.get(s);
15
- if (l?.type === "timestamp" && typeof c == "string" && c !== "") return n(c, {
15
+ let l = i?.fields?.get(s);
16
+ if (l?.type === "timestamp" && typeof c == "string" && c !== "") return r(c, {
16
17
  zone: e.timeZone,
17
- declared: !!(l.timezone || a?.default_timezone)
18
+ declared: !!(l.timezone || i?.default_timezone)
18
19
  });
19
20
  let u = l?.values;
20
21
  if (u && (typeof c == "string" || typeof c == "number")) {
@@ -24,52 +25,52 @@ function a(e, r, a) {
24
25
  if (n) return n;
25
26
  }
26
27
  }
27
- return typeof c == "object" && !Array.isArray(c) ? e(c) || void 0 : t(c);
28
+ return typeof c == "object" && !Array.isArray(c) ? e(c) || void 0 : n(c);
29
+ }
30
+ function s(e, t, r, i) {
31
+ if (!r || !Object.hasOwn(t, r)) return i;
32
+ let a = t[r];
33
+ return a == null ? i : typeof a == "object" && !Array.isArray(a) ? e(a) || i : n(a);
28
34
  }
29
- function o(e, n, r, i) {
30
- if (!r || !Object.hasOwn(n, r)) return i;
31
- let a = n[r];
32
- return a == null ? i : typeof a == "object" && !Array.isArray(a) ? e(a) || i : t(a);
35
+ function c(e, t, n) {
36
+ return s(e, t, n, "").trim() !== "";
33
37
  }
34
- function s(e) {
38
+ function l(e) {
35
39
  let t = e.replace(/\/+$/, "").split("/").map((e) => e.startsWith(":") ? "[^/]+" : e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
36
40
  return RegExp("^" + t.join("/") + "$");
37
41
  }
38
- function c(e) {
39
- let t = (() => {
40
- try {
41
- return decodeURIComponent(e);
42
- } catch {
43
- return e;
44
- }
45
- })().split("-")[0];
46
- return t.length > 8 ? t.slice(0, 8) : t;
47
- }
48
- function l(e, t, n, r) {
49
- if (!n) return;
50
- let i = t.replace(/\/+$/, "") || "/", a;
51
- for (let t of Object.values(n)) {
52
- if (!t.route || !s(t.route).test(i)) continue;
53
- let n = t.route.includes("/:"), o = e(t.display?.name);
54
- if (!o && !n && r && t.entity && (o = e(r[t.entity]?.display?.name_plural)), !o && n && r && t.entity) {
55
- let n = e(r[t.entity]?.display?.name);
56
- if (n) {
57
- let e = i.slice(i.lastIndexOf("/") + 1);
58
- o = e ? `${n} ${c(e)}` : n;
42
+ function u(e) {
43
+ try {
44
+ return decodeURIComponent(e);
45
+ } catch {
46
+ return e;
47
+ }
48
+ }
49
+ function d(e, n, r, i) {
50
+ if (!r) return;
51
+ let a = n.replace(/\/+$/, "") || "/", o;
52
+ for (let n of Object.values(r)) {
53
+ if (!n.route || !l(n.route).test(a)) continue;
54
+ let r = n.route.includes("/:"), s = e(n.display?.name);
55
+ if (!s && !r && i && n.entity && (s = e(i[n.entity]?.display?.name_plural)), !s && r && i && n.entity) {
56
+ let r = e(i[n.entity]?.display?.name);
57
+ if (r) {
58
+ let e = a.slice(a.lastIndexOf("/") + 1);
59
+ s = e ? `${r} ${t(u(e))}` : r;
59
60
  }
60
61
  }
61
- if (!o) continue;
62
- let l = {
63
- title: o,
64
- icon: t.display?.icon,
65
- exact: !n
62
+ if (!s) continue;
63
+ let c = {
64
+ title: s,
65
+ icon: n.display?.icon,
66
+ exact: !r
66
67
  };
67
- if (!n) return l;
68
- a ??= l;
68
+ if (!r) return c;
69
+ o ??= c;
69
70
  }
70
- return a;
71
+ return o;
71
72
  }
72
- function u(e, t, n, r) {
73
+ function f(e, t, n, r) {
73
74
  let i = e(t.display?.name);
74
75
  if (i) return i;
75
76
  if (t.type === "ref" && t.ref?.entity && r) {
@@ -81,18 +82,18 @@ function u(e, t, n, r) {
81
82
  }
82
83
  return n;
83
84
  }
84
- function d(e) {
85
+ function p(e) {
85
86
  if (e != null) return typeof e == "string" ? { entity: e } : e;
86
87
  }
87
- function f(e) {
88
+ function m(e) {
88
89
  return { $special: e };
89
90
  }
90
- function p(e) {
91
+ function h(e) {
91
92
  if (typeof e != "object" || !e || Array.isArray(e)) return null;
92
93
  let t = Object.keys(e), n = e.$special;
93
94
  return t.length === 1 && typeof n == "string" ? n : null;
94
95
  }
95
- function m(e, t) {
96
+ function g(e, t) {
96
97
  let n = e ?? [];
97
98
  if (!t) return n;
98
99
  switch (t.mode ?? "append") {
@@ -101,7 +102,7 @@ function m(e, t) {
101
102
  default: return [...n, ...t.values ?? []];
102
103
  }
103
104
  }
104
- function h(e) {
105
+ function _(e) {
105
106
  let t = e.name, n = e.display ? {
106
107
  ...e.display,
107
108
  name: e.display.name ?? t
@@ -114,46 +115,49 @@ function h(e) {
114
115
  structure: e.structure
115
116
  };
116
117
  }
117
- function g(e) {
118
+ function v(e) {
118
119
  return !e.primary && !e.auto && !e.readonly && !e.source && !e.immutable;
119
120
  }
120
- function _(e, t) {
121
+ function y(e, t) {
121
122
  return !e || e.readonly ? !1 : e.mutations?.[t] ?? !0;
122
123
  }
123
- function v(e, t, n) {
124
+ function b(e, t, n) {
124
125
  let r = e?.tenant_key;
125
126
  return !r || !t || !(r in t) || !!n && String(t[r]).toLowerCase() === n.toLowerCase();
126
127
  }
127
- function y(e, t, n, r) {
128
- return _(e, t) && (t === "create" || v(e, n, r));
128
+ function x(e, t, n, r) {
129
+ return y(e, t) && (t === "create" || b(e, n, r));
129
130
  }
130
- function b(e) {
131
+ function S(e) {
131
132
  return !e?.disable_defaults?.includes("__new");
132
133
  }
133
- function x(e) {
134
+ function C(e) {
135
+ return !e?.disable_defaults?.includes("__edit");
136
+ }
137
+ function w(e) {
134
138
  if (e.primary_key && e.primary_key.length > 0) return e.primary_key;
135
139
  for (let [t, n] of e.fields) if (n.primary) return [t];
136
140
  return ["id"];
137
141
  }
138
- function S(e, n) {
139
- let r = x(e), i = {};
140
- for (let e of r) i[e] = t(n[e]);
142
+ function T(e, t) {
143
+ let r = w(e), i = {};
144
+ for (let e of r) i[e] = n(t[e]);
141
145
  return i;
142
146
  }
143
- function C(e) {
147
+ function E(e) {
144
148
  return e.length === 1 ? e[0] : JSON.stringify(e);
145
149
  }
146
- function w(e) {
147
- return C(Object.values(e));
150
+ function D(e) {
151
+ return E(Object.values(e));
148
152
  }
149
- function T(e, t) {
150
- return C(x(e).map((e) => t[e] ?? ""));
153
+ function O(e, t) {
154
+ return E(w(e).map((e) => t[e] ?? ""));
151
155
  }
152
- function E(e, t) {
153
- let n = x(e);
156
+ function k(e, t) {
157
+ let n = w(e);
154
158
  if (n.length === 1) return { [n[0]]: t };
155
159
  }
156
- function D(e, t) {
160
+ function A(e, t) {
157
161
  if (t <= 1) return [e];
158
162
  try {
159
163
  let n = JSON.parse(e);
@@ -163,23 +167,23 @@ function D(e, t) {
163
167
  }
164
168
  return null;
165
169
  }
166
- function O(e, t, n) {
170
+ function j(e, t, n) {
167
171
  if (e?.detail_screen === "none") return null;
168
172
  let r = e?.detail_screen ?? t?.detail_screen;
169
173
  return r ? n?.[r]?.route ?? null : null;
170
174
  }
171
- function k(e, t, n, r) {
175
+ function M(e, t, n, r) {
172
176
  if (!t) return null;
173
- let i = O(e, n, r);
177
+ let i = j(e, n, r);
174
178
  return i ? i.replace(":id", encodeURIComponent(t)) : null;
175
179
  }
176
- function A(e, t, n, r) {
177
- return !t || x(t).some((e) => !r[e]) ? null : k(e, T(t, r), t, n);
180
+ function N(e, t, n, r) {
181
+ return !t || w(t).some((e) => !r[e]) ? null : M(e, O(t, r), t, n);
178
182
  }
179
- function j(e, t, n, r) {
180
- return t ? A(e, t, n, S(t, r)) : null;
183
+ function P(e, t, n, r) {
184
+ return t ? N(e, t, n, T(t, r)) : null;
181
185
  }
182
- function M(e) {
183
- return x(e).length > 1;
186
+ function F(e) {
187
+ return w(e).length > 1;
184
188
  }
185
- export { r as DETAIL_SCREEN_NONE, i as DISPLAY_KEY, e as OrderedMap, k as buildDetailHrefFromId, A as buildEntityDetailHref, j as buildRowDetailHref, m as effectiveSpecialValues, b as entityAllowsCreateRoute, _ as entityAllowsMutation, S as extractPkValues, u as fieldDisplayName, a as getDisplayValue, x as getPrimaryKeyFields, M as isCompositePk, g as isUserEditableField, d as normalizeRefConfig, C as pkValuePartsToId, D as pkValuesFromId, T as pkValuesToDetailId, w as pkValuesToId, h as propertyToField, O as resolveDetailRoute, o as resolveRefRecordLabel, y as rowAllowsMutation, v as rowSetInTenant, l as screenTitleForPath, E as singlePkValues, f as specialValueMarker, p as specialValueMarkerCode };
189
+ export { i as DETAIL_SCREEN_NONE, a as DISPLAY_KEY, e as OrderedMap, M as buildDetailHrefFromId, N as buildEntityDetailHref, P as buildRowDetailHref, g as effectiveSpecialValues, S as entityAllowsCreateRoute, C as entityAllowsEditForm, y as entityAllowsMutation, T as extractPkValues, f as fieldDisplayName, o as getDisplayValue, w as getPrimaryKeyFields, F as isCompositePk, v as isUserEditableField, p as normalizeRefConfig, E as pkValuePartsToId, A as pkValuesFromId, O as pkValuesToDetailId, D as pkValuesToId, _ as propertyToField, c as refRecordHasLabel, j as resolveDetailRoute, s as resolveRefRecordLabel, x as rowAllowsMutation, b as rowSetInTenant, d as screenTitleForPath, k as singlePkValues, m as specialValueMarker, h as specialValueMarkerCode };
@@ -75,6 +75,9 @@ interface FileFieldDef {
75
75
  required?: boolean;
76
76
  slots?: Record<string, FileNamedSlotDef>;
77
77
  display?: FileFieldDisplay;
78
+ attachment_fields?: {
79
+ uploaded_by?: EntityField;
80
+ };
78
81
  }
79
82
  /** How a client reaches one file row, an original or a derivation: `url` serves its bytes; `presigned_url` answers JSON with where to load them. */
80
83
  interface FileAddress {
@@ -317,6 +320,7 @@ interface EntityField {
317
320
  currency_display?: "symbol" | "narrow_symbol" | "code" | "name";
318
321
  favicon_source?: FaviconSource;
319
322
  fill_from?: string;
323
+ flatten?: boolean;
320
324
  };
321
325
  values?: Array<{
322
326
  code: string;
@@ -788,7 +792,7 @@ interface QuickPeekConfig {
788
792
  * `sections` is consulted; when that's also absent the platform falls back
789
793
  * to all simple scalar fields on the entity (capped at 8).
790
794
  */
791
- fields?: string[];
795
+ fields?: LayoutField[];
792
796
  /** Section names from the detail-layout. Their `fields:` get flattened. */
793
797
  sections?: string[];
794
798
  inline_editable?: boolean;
@@ -1034,6 +1038,7 @@ interface Schema {
1034
1038
  parameters: Record<string, ParameterDef>;
1035
1039
  messages?: Record<string, LocalizedString>;
1036
1040
  errors?: Record<string, LocalizedString>;
1041
+ error_fields?: Record<string, LocalizedString>;
1037
1042
  areas?: AreaDef[];
1038
1043
  accents?: Record<string, AccentDef>;
1039
1044
  classifications?: Record<string, ClassificationTierDef>;
@@ -1270,7 +1275,6 @@ interface BrandingIdentity {
1270
1275
  interface PublicMeta {
1271
1276
  version?: string;
1272
1277
  revision?: string;
1273
- build_time?: string;
1274
1278
  region?: string;
1275
1279
  }
1276
1280
  /** Envelope returned by GET /api/params/public. */
@@ -1381,6 +1385,7 @@ interface EvidenceVerdict {
1381
1385
  seq?: number;
1382
1386
  generation?: number;
1383
1387
  covered: boolean;
1388
+ record_id?: string;
1384
1389
  }
1385
1390
  interface V2ParamInstance {
1386
1391
  param_code: string;
package/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "@declarion/react",
3
- "version": "0.446.0",
3
+ "version": "0.517.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/disciplinedware/factory.git",
7
+ "directory": "projects/declarion/typescript/packages/react"
8
+ },
4
9
  "private": false,
5
10
  "license": "MIT",
6
11
  "description": "React SDK for Declarion, the schema-driven business apps platform.",
@@ -1,25 +0,0 @@
1
- import { Icon as e } from "./Icons.js";
2
- import { useText as t } from "../../hooks/useText.js";
3
- import { isUuid as n } from "../../lib/uuid.js";
4
- import { useCallback as r, useState as i } from "react";
5
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
- // src/components/primitives/RecordIdBadge.tsx
7
- var s = 1200;
8
- function c({ value: c }) {
9
- let l = t(), [u, d] = i(!1), f = n(c) ? `${c.slice(0, 8)}…` : c, p = r(async () => {
10
- try {
11
- await navigator.clipboard.writeText(c), d(!0), window.setTimeout(() => d(!1), s);
12
- } catch {}
13
- }, [c]);
14
- return /* @__PURE__ */ o("button", {
15
- type: "button",
16
- onClick: p,
17
- title: u ? l("control.copied", "Copied") : l("control.copy_value", "Copy {value}", { value: c }),
18
- className: "mono inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] text-text-4 hover:bg-surface-2 hover:text-text-3 transition-colors shrink-0 border border-transparent hover:border-border",
19
- children: [/* @__PURE__ */ a("span", { children: f }), u ? /* @__PURE__ */ a(e.check, { size: 10 }) : /* @__PURE__ */ a(e.copy, {
20
- size: 10,
21
- style: { opacity: .6 }
22
- })]
23
- });
24
- }
25
- export { c as RecordIdBadge };