@declarion/react 0.446.0 → 0.516.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 +1 -1
  43. package/dist-lib/components/primitives/RecordIdBadge.js +0 -25
@@ -1,37 +1,38 @@
1
1
  import { IconBtn as e } from "../primitives/IconBtn.js";
2
2
  import { Icon as t } from "../primitives/Icons.js";
3
- import { useSchema as n } from "../../hooks/useSchema.js";
4
- import { useText as r } from "../../hooks/useText.js";
5
- import { coerceDisplayString as i } from "../../lib/display-value.js";
6
- import { Suspense as a, lazy as o, useState as s } from "react";
7
- import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
3
+ import { IdBadge as n } from "../primitives/IdBadge.js";
4
+ import { useSchema as r } from "../../hooks/useSchema.js";
5
+ import { useText as i } from "../../hooks/useText.js";
6
+ import { coerceDisplayString as a } from "../../lib/display-value.js";
7
+ import { shortId as o } from "../../lib/short-id.js";
8
+ import { ValueRows as s, keySegment as c } from "./ValueRows.js";
9
+ import { EMPTY_CELL as l } from "./cells/factories/emptyCell.js";
10
+ import { Suspense as u, lazy as d, useState as f } from "react";
11
+ import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
8
12
  // src/components/fields/JsonField.tsx
9
- var d = o(() => import("./JsonEditor.js").then((e) => ({ default: e.JsonEditor })));
10
- function f() {
11
- return /* @__PURE__ */ l("div", { className: "h-20 rounded-md border border-border bg-muted animate-pulse" });
13
+ var g = d(() => import("./JsonEditor.js").then((e) => ({ default: e.JsonEditor })));
14
+ function _() {
15
+ return /* @__PURE__ */ m("div", { className: "h-20 rounded-md border border-border bg-muted animate-pulse" });
12
16
  }
13
- function p(e) {
17
+ function v(e) {
14
18
  return e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) ? e.length === 0 : typeof e == "object" && Object.keys(e).length === 0;
15
19
  }
16
- function m(e) {
20
+ function y(e) {
17
21
  return Array.isArray(e) && e.every((e) => [
18
22
  "string",
19
23
  "number",
20
24
  "boolean"
21
25
  ].includes(typeof e));
22
26
  }
23
- function h({ value: e, mode: t, onChange: n, fieldId: r, entityCode: i, fieldName: o }) {
24
- let s = T(i, o);
25
- return t === "display" ? p(e) ? /* @__PURE__ */ l("span", {
26
- style: {
27
- fontSize: 12.5,
28
- color: "var(--text-4)"
29
- },
30
- children: "—"
31
- }) : s && typeof e == "object" && !Array.isArray(e) ? /* @__PURE__ */ l(D, {
32
- value: e,
33
- body: /* @__PURE__ */ l(E, { value: e })
34
- }) : m(e) ? /* @__PURE__ */ l("ul", {
27
+ function b({ field: e, value: t, mode: n, onChange: r, fieldId: i, entityCode: a, fieldName: o }) {
28
+ let s = e.display?.flatten === !0, c = D(a, o);
29
+ return n === "display" ? v(t) ? l : c && typeof t == "object" && !Array.isArray(t) ? /* @__PURE__ */ m(k, {
30
+ value: t,
31
+ body: /* @__PURE__ */ m(O, {
32
+ value: t,
33
+ flat: s
34
+ })
35
+ }) : y(t) ? /* @__PURE__ */ m("ul", {
35
36
  className: "mono",
36
37
  style: {
37
38
  margin: 0,
@@ -40,56 +41,42 @@ function h({ value: e, mode: t, onChange: n, fieldId: r, entityCode: i, fieldNam
40
41
  fontSize: 12.5,
41
42
  lineHeight: 1.7
42
43
  },
43
- children: e.map((e, t) => /* @__PURE__ */ l("li", { children: String(e) }, t))
44
- }) : /* @__PURE__ */ l(D, { value: e }) : /* @__PURE__ */ l(a, {
45
- fallback: /* @__PURE__ */ l(f, {}),
46
- children: /* @__PURE__ */ l(d, {
47
- value: e,
48
- onChange: n,
49
- id: r
44
+ children: t.map((e, t) => /* @__PURE__ */ m("li", { children: String(e) }, t))
45
+ }) : /* @__PURE__ */ m(k, {
46
+ value: t,
47
+ body: /* @__PURE__ */ m(A, {
48
+ value: t,
49
+ flat: s
50
+ })
51
+ }) : /* @__PURE__ */ m(u, {
52
+ fallback: /* @__PURE__ */ m(_, {}),
53
+ children: /* @__PURE__ */ m(g, {
54
+ value: t,
55
+ onChange: r,
56
+ id: i
50
57
  })
51
58
  });
52
59
  }
53
- var g = {
60
+ var x = {
54
61
  display: "flex",
55
- flexDirection: "column",
56
- gap: 6,
57
- border: "1px solid var(--border)",
58
- borderRadius: "var(--radius-md)",
59
- padding: 12,
60
- background: "var(--surface-2)"
61
- }, _ = {
62
+ alignItems: "flex-start",
63
+ gap: 8,
64
+ minWidth: 0
65
+ }, S = {
62
66
  display: "flex",
63
67
  flexDirection: "column",
64
68
  gap: 8
65
- }, v = {
66
- display: "flex",
67
- flexWrap: "wrap",
68
- alignItems: "baseline",
69
- gap: 8
70
- }, y = {
71
- fontSize: 11.5,
72
- fontWeight: 500,
73
- color: "var(--text-3)",
74
- width: 120,
75
- flexShrink: 0,
76
- overflowWrap: "anywhere"
77
- }, b = {
78
- ..._,
79
- paddingLeft: 10,
80
- borderLeft: "2px solid var(--border)"
81
- }, x = {
69
+ }, C = {
82
70
  minWidth: 0,
83
- flex: "1 1 14rem",
84
- fontSize: 12.5,
71
+ fontSize: 13,
85
72
  overflowWrap: "anywhere"
86
- }, S = {
87
- display: "flex",
88
- justifyContent: "flex-end"
89
- }, C = {
73
+ }, w = {
74
+ flex: 1,
75
+ minWidth: 0
76
+ }, T = {
90
77
  fontSize: 12.5,
91
78
  fontWeight: 500
92
- }, w = /* @__PURE__ */ new Set([
79
+ }, E = /* @__PURE__ */ new Set([
93
80
  "type",
94
81
  "status",
95
82
  "title",
@@ -97,86 +84,102 @@ var g = {
97
84
  "instance",
98
85
  "retryable"
99
86
  ]);
100
- function T(e, t) {
101
- let { data: r } = n(), i = e ? r?.entities[e] : void 0;
87
+ function D(e, t) {
88
+ let { data: n } = r(), i = e ? n?.entities[e] : void 0;
102
89
  return i ? [...i.fields].some(([, e]) => e.type === "error" && e.source === `$row.${t}.type`) : !1;
103
90
  }
104
- function E({ value: e }) {
105
- let t = r("errors"), n = typeof e.type == "string" ? e.type : "", i = n.startsWith("/errors/") ? n.slice(8) : n, a = Object.fromEntries(Object.entries(e).filter(([e]) => !w.has(e)));
106
- return /* @__PURE__ */ u("div", {
107
- style: _,
91
+ function O({ value: e, flat: t }) {
92
+ let n = i("errors"), a = i(), { data: o } = r(), c = typeof e.type == "string" ? e.type : "", l = c.startsWith("/errors/") ? c.slice(8) : c, u = Object.fromEntries(Object.entries(e).filter(([e]) => !E.has(e)));
93
+ return /* @__PURE__ */ h("div", {
94
+ style: S,
108
95
  children: [
109
- i ? /* @__PURE__ */ l("span", {
110
- style: C,
111
- children: t(i, i)
96
+ l ? /* @__PURE__ */ m("span", {
97
+ style: T,
98
+ children: n(l, l)
112
99
  }) : null,
113
- typeof e.detail == "string" && e.detail ? /* @__PURE__ */ l("span", {
114
- style: x,
100
+ typeof e.detail == "string" && e.detail ? /* @__PURE__ */ m("span", {
101
+ style: C,
115
102
  children: e.detail
116
103
  }) : null,
117
- Object.keys(a).length > 0 ? /* @__PURE__ */ l(O, { value: a }) : null
104
+ Object.keys(u).length > 0 ? /* @__PURE__ */ m(s, {
105
+ flat: t,
106
+ rows: j(u, (e) => {
107
+ let t = o?.error_fields?.[`${l}.${e}`];
108
+ return t ? a(t) : e;
109
+ })
110
+ }) : null
118
111
  ]
119
112
  });
120
113
  }
121
- function D({ value: n, body: i }) {
122
- let o = r(), [c, p] = s(!1), m = c ? o("field.json.hide_source", "Hide JSON") : o("field.json.show_source", "Show JSON");
123
- return /* @__PURE__ */ u("div", {
124
- style: g,
125
- children: [/* @__PURE__ */ l("div", {
126
- style: S,
127
- children: /* @__PURE__ */ l(e, {
128
- size: 22,
129
- icon: /* @__PURE__ */ l(t.code, { size: 13 }),
130
- onClick: (e) => {
131
- e.stopPropagation(), p((e) => !e);
132
- },
133
- title: m,
134
- "aria-label": m,
135
- "aria-pressed": c
136
- })
137
- }), c ? /* @__PURE__ */ l(a, {
138
- fallback: /* @__PURE__ */ l(f, {}),
139
- children: /* @__PURE__ */ l(d, {
140
- value: n,
141
- readOnly: !0
142
- })
143
- }) : i ?? /* @__PURE__ */ l(k, { value: n })]
114
+ function k({ value: n, body: r }) {
115
+ let a = i(), [o, s] = f(!1), c = o ? a("field.json.hide_source", "Hide JSON") : a("field.json.show_source", "Show JSON");
116
+ return /* @__PURE__ */ h("div", {
117
+ style: x,
118
+ children: [/* @__PURE__ */ m("div", {
119
+ style: w,
120
+ children: o ? /* @__PURE__ */ m(u, {
121
+ fallback: /* @__PURE__ */ m(_, {}),
122
+ children: /* @__PURE__ */ m(g, {
123
+ value: n,
124
+ readOnly: !0
125
+ })
126
+ }) : r
127
+ }), /* @__PURE__ */ m(e, {
128
+ size: 22,
129
+ icon: /* @__PURE__ */ m(t.code, { size: 13 }),
130
+ onClick: (e) => {
131
+ e.stopPropagation(), s((e) => !e);
132
+ },
133
+ title: c,
134
+ "aria-label": c,
135
+ "aria-pressed": o
136
+ })]
137
+ });
138
+ }
139
+ function A({ value: e, flat: t }) {
140
+ let n = M(e) ?? e;
141
+ return typeof n == "object" && n ? /* @__PURE__ */ m(s, {
142
+ flat: t,
143
+ rows: j(n)
144
+ }) : /* @__PURE__ */ m("span", {
145
+ style: C,
146
+ children: /* @__PURE__ */ m(P, { value: e })
144
147
  });
145
148
  }
146
- function O({ value: e, nested: t }) {
147
- let n = Array.isArray(e) ? e.map((e, t) => [String(t + 1), e]) : Object.entries(e);
148
- return /* @__PURE__ */ l("div", {
149
- style: t ? b : _,
150
- children: n.map(([e, t]) => /* @__PURE__ */ u("div", {
151
- style: v,
152
- children: [/* @__PURE__ */ l("span", {
153
- style: y,
154
- children: e
155
- }), /* @__PURE__ */ l("div", {
156
- style: x,
157
- children: /* @__PURE__ */ l(k, {
158
- value: t,
159
- nested: !0
160
- })
161
- })]
162
- }, e))
149
+ function j(e, t = (e) => e) {
150
+ return Array.isArray(e) && e.length === 1 && N(e[0]) ? j(e[0], t) : (Array.isArray(e) ? e.map((e, t) => [String(t + 1), e]) : Object.entries(e)).map(([e, n]) => {
151
+ let r = M(n) ?? n;
152
+ return N(r) ? {
153
+ key: c(e),
154
+ label: t(e),
155
+ rows: j(r)
156
+ } : {
157
+ key: c(e),
158
+ label: t(e),
159
+ value: /* @__PURE__ */ m(P, { value: r })
160
+ };
163
161
  });
164
162
  }
165
- function k({ value: e, nested: t }) {
166
- let n = r();
167
- return p(e) ? /* @__PURE__ */ l("span", {
168
- style: { color: "var(--text-4)" },
169
- children: "—"
170
- }) : m(e) ? /* @__PURE__ */ l(c, { children: e.map((e) => A(e, n.language)).join(", ") }) : typeof e == "object" ? /* @__PURE__ */ l(O, {
171
- value: e,
172
- nested: t
173
- }) : /* @__PURE__ */ l(c, { children: A(e, n.language) });
163
+ function M(e) {
164
+ if (typeof e == "string" && /^\s*[[{]/.test(e)) try {
165
+ let t = JSON.parse(e);
166
+ return typeof t == "object" && t ? t : void 0;
167
+ } catch {
168
+ return;
169
+ }
170
+ }
171
+ function N(e) {
172
+ return typeof e == "object" && !!e && !v(e) && !y(e);
173
+ }
174
+ function P({ value: e }) {
175
+ let t = i();
176
+ return v(e) ? l : typeof e == "boolean" ? /* @__PURE__ */ m(p, { children: e ? t("field.bool.yes", "Yes") : t("field.bool.no", "No") }) : typeof e == "string" && o(e) !== e ? /* @__PURE__ */ m(n, { value: e }) : y(e) ? /* @__PURE__ */ m(p, { children: e.map((e) => F(e, t.language)).join(", ") }) : /* @__PURE__ */ m(p, { children: F(e, t.language) });
174
177
  }
175
- function A(e, t) {
178
+ function F(e, t) {
176
179
  if (typeof e == "number" && Number.isFinite(e) && !Number.isInteger(e)) {
177
180
  let n = Math.abs(e) < 1 ? { maximumSignificantDigits: 4 } : { maximumFractionDigits: 4 };
178
181
  return new Intl.NumberFormat(t, n).format(e);
179
182
  }
180
- return i(e);
183
+ return a(e);
181
184
  }
182
- export { h as JsonField, p as isEmptyJsonValue };
185
+ export { b as JsonField, v as isEmptyJsonValue, N as isNestable, j as jsonRows, M as parseJsonText };
@@ -1,37 +1,22 @@
1
1
  import { TextInput as e } from "../primitives/Fields.js";
2
- import { CopyButton as t } from "../shared/CopyButton.js";
3
- import { coerceDisplayString as n } from "../../lib/display-value.js";
4
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
2
+ import { IdBadge as t } from "../primitives/IdBadge.js";
3
+ import { EMPTY_CELL as n } from "./cells/factories/emptyCell.js";
4
+ import { coerceDisplayString as r } from "../../lib/display-value.js";
5
+ import { jsx as i } from "react/jsx-runtime";
5
6
  // src/components/fields/StringField.tsx
6
7
  function a({ field: a, fieldName: o, value: s, mode: c, onChange: l, fieldId: u }) {
7
8
  if (c === "display") {
8
- let e = n(s);
9
- return a.copyable && e ? /* @__PURE__ */ i("span", {
10
- style: {
11
- display: "inline-flex",
12
- alignItems: "center",
13
- gap: 4
14
- },
15
- children: [/* @__PURE__ */ r("span", {
16
- style: { fontSize: 12.5 },
17
- children: e
18
- }), /* @__PURE__ */ r(t, {
19
- value: e,
20
- size: "sm"
21
- })]
22
- }) : /* @__PURE__ */ r("span", {
9
+ let e = r(s);
10
+ return e ? a.display?.widget === "id" ? /* @__PURE__ */ i(t, { value: e }) : /* @__PURE__ */ i("span", {
23
11
  style: { fontSize: 12.5 },
24
- children: e || /* @__PURE__ */ r("span", {
25
- style: { color: "var(--text-4)" },
26
- children: "—"
27
- })
28
- });
12
+ children: e
13
+ }) : n;
29
14
  }
30
- return /* @__PURE__ */ r(e, {
15
+ return /* @__PURE__ */ i(e, {
31
16
  id: u,
32
17
  name: o,
33
18
  "aria-required": a.required || void 0,
34
- value: n(s),
19
+ value: r(s),
35
20
  onChange: (e) => l?.(e)
36
21
  });
37
22
  }