@declarion/react 0.106.0 → 0.109.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 (34) hide show
  1. package/dist-lib/api/agents.js +8 -7
  2. package/dist-lib/api/client.js +48 -49
  3. package/dist-lib/components/agents/AgentChatPanel.impl.js +362 -301
  4. package/dist-lib/components/agents/ChatAttachments.js +144 -0
  5. package/dist-lib/components/agents/transcript-runs.js +1 -1
  6. package/dist-lib/components/chrome/AssociationTabs.js +89 -75
  7. package/dist-lib/components/detail-layout/AssociatedBlock.js +243 -235
  8. package/dist-lib/components/detail-layout/ChildrenCards.js +57 -55
  9. package/dist-lib/components/detail-layout/ChildrenList.js +45 -43
  10. package/dist-lib/components/detail-layout/ChildrenTable.js +93 -91
  11. package/dist-lib/components/detail-layout/ChildrenTimeline.js +160 -155
  12. package/dist-lib/components/detail-layout/widgets/EntityScorecardWidget.js +127 -121
  13. package/dist-lib/components/fields/RefCombobox.js +53 -48
  14. package/dist-lib/components/fields/index.js +1 -0
  15. package/dist-lib/components/file-widgets/useFileSelection.js +152 -0
  16. package/dist-lib/components/pages/SmartDetailPage.impl.js +506 -482
  17. package/dist-lib/components/pages/SmartRecordListPage.impl.js +335 -300
  18. package/dist-lib/components/pages/tenant-params/TenantParamsPage.impl.js +112 -109
  19. package/dist-lib/components/params/ParamsBlock.js +18 -15
  20. package/dist-lib/components/params/param-editors.js +60 -54
  21. package/dist-lib/components/primitives/RetryButton.js +14 -0
  22. package/dist-lib/components/primitives/StatTile.js +42 -34
  23. package/dist-lib/hooks/useAgentConversation.js +18 -13
  24. package/dist-lib/hooks/useParams.js +54 -52
  25. package/dist-lib/hooks/useSchema.js +5 -2
  26. package/dist-lib/hooks/useTimelineData.js +26 -24
  27. package/dist-lib/index.d.ts +89 -5
  28. package/dist-lib/index.js +95 -93
  29. package/dist-lib/lib/read-display-state.js +19 -0
  30. package/dist-lib/stores/auth.js +1 -0
  31. package/dist-lib/testing.d.ts +1 -1
  32. package/dist-lib/types/fieldType.js +1 -1
  33. package/dist-lib/{useResponsiveMode-ECv1AEhv.d.ts → useResponsiveMode-DODbtSrY.d.ts} +3 -0
  34. package/package.json +1 -1
@@ -0,0 +1,144 @@
1
+ import { Icon as e } from "../primitives/Icons.js";
2
+ import { IconBtn as t } from "../primitives/IconBtn.js";
3
+ import { useText as n } from "../../hooks/useText.js";
4
+ import { formatBytes as r } from "../file-widgets/upload.js";
5
+ import { UploadFailureText as i } from "../file-widgets/UploadFailureText.js";
6
+ import { downloadFileURL as a } from "../file-widgets/helpers.js";
7
+ import { useEmbedFileOpener as o } from "../file-widgets/useEmbedFileSrc.js";
8
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
9
+ //#region src/components/agents/ChatAttachments.tsx
10
+ var l = {
11
+ display: "flex",
12
+ alignItems: "center",
13
+ gap: 6,
14
+ padding: "4px 6px 4px 8px",
15
+ fontSize: 11.5,
16
+ background: "var(--surface)",
17
+ border: "1px solid var(--border)",
18
+ borderRadius: "var(--radius-md)",
19
+ color: "var(--text)",
20
+ maxWidth: "100%"
21
+ };
22
+ function u({ selections: r, onCancel: i, onRemove: a }) {
23
+ let o = n();
24
+ return r.length === 0 ? null : /* @__PURE__ */ s("ul", {
25
+ "aria-label": o("agent.panel.selected_files", "Selected files"),
26
+ style: {
27
+ listStyle: "none",
28
+ margin: 0,
29
+ padding: "0 0 6px",
30
+ display: "flex",
31
+ flexDirection: "column",
32
+ gap: 4
33
+ },
34
+ children: r.map((n) => /* @__PURE__ */ c("li", {
35
+ "data-selection-state": n.state,
36
+ style: {
37
+ ...l,
38
+ borderColor: n.state === "failed" ? "var(--destructive)" : "var(--border)"
39
+ },
40
+ children: [
41
+ /* @__PURE__ */ s(e.paperclip, { size: 11 }),
42
+ /* @__PURE__ */ s("span", {
43
+ style: {
44
+ flex: 1,
45
+ minWidth: 0,
46
+ overflow: "hidden",
47
+ textOverflow: "ellipsis",
48
+ whiteSpace: "nowrap"
49
+ },
50
+ title: n.filename,
51
+ children: n.filename
52
+ }),
53
+ /* @__PURE__ */ s(d, { selection: n }),
54
+ n.state === "uploading" ? /* @__PURE__ */ s(t, {
55
+ size: 20,
56
+ icon: /* @__PURE__ */ s(e.x, { size: 11 }),
57
+ onClick: () => i(n.localId),
58
+ title: o("file.upload.cancel", "Cancel")
59
+ }) : /* @__PURE__ */ s(t, {
60
+ size: 20,
61
+ icon: /* @__PURE__ */ s(e.x, { size: 11 }),
62
+ onClick: () => a(n.localId),
63
+ title: o("file.remove", "Remove")
64
+ })
65
+ ]
66
+ }, n.localId))
67
+ });
68
+ }
69
+ function d({ selection: e }) {
70
+ let t = n();
71
+ switch (e.state) {
72
+ case "uploading": {
73
+ let n = e.progress?.pct ?? 0;
74
+ return /* @__PURE__ */ s("span", {
75
+ role: "progressbar",
76
+ "aria-valuenow": n,
77
+ "aria-valuemin": 0,
78
+ "aria-valuemax": 100,
79
+ style: { color: "var(--text-3)" },
80
+ children: t("file.upload.progress", "Uploading {pct}%", { pct: n })
81
+ });
82
+ }
83
+ case "failed": return /* @__PURE__ */ s("span", {
84
+ role: "alert",
85
+ style: { color: "var(--destructive)" },
86
+ children: e.failure ? /* @__PURE__ */ s(i, { failure: e.failure }) : t("file.selection.failed", "Failed")
87
+ });
88
+ case "cancelled": return /* @__PURE__ */ s("span", {
89
+ style: { color: "var(--text-3)" },
90
+ children: t("file.selection.cancelled", "Cancelled")
91
+ });
92
+ case "ready": return /* @__PURE__ */ s("span", {
93
+ style: { color: "var(--text-3)" },
94
+ children: r(e.sizeBytes)
95
+ });
96
+ }
97
+ }
98
+ function f(e, t) {
99
+ return e.role !== "assistant" || t.some((t) => t.id === e.turn_id && t.status === "completed");
100
+ }
101
+ function p({ files: i, align: u }) {
102
+ let d = n(), { open: f } = o();
103
+ return !i || i.length === 0 ? null : /* @__PURE__ */ s("ul", {
104
+ "aria-label": d("agent.panel.message_files", "Files"),
105
+ style: {
106
+ listStyle: "none",
107
+ margin: "4px 0 0",
108
+ padding: 0,
109
+ display: "flex",
110
+ flexDirection: "column",
111
+ gap: 4,
112
+ alignItems: u === "end" ? "flex-end" : "flex-start"
113
+ },
114
+ children: i.map((n, i) => /* @__PURE__ */ c("li", {
115
+ "data-file-id": n.id,
116
+ style: l,
117
+ children: [
118
+ /* @__PURE__ */ s(e.paperclip, { size: 11 }),
119
+ /* @__PURE__ */ s("span", {
120
+ style: {
121
+ minWidth: 0,
122
+ overflow: "hidden",
123
+ textOverflow: "ellipsis",
124
+ whiteSpace: "nowrap"
125
+ },
126
+ title: n.filename,
127
+ children: n.filename
128
+ }),
129
+ /* @__PURE__ */ s("span", {
130
+ style: { color: "var(--text-3)" },
131
+ children: r(n.size_bytes)
132
+ }),
133
+ /* @__PURE__ */ s(t, {
134
+ size: 20,
135
+ icon: /* @__PURE__ */ s(e.download, { size: 11 }),
136
+ onClick: () => f(n.id, "download", a(n)),
137
+ title: d("file.download", "Download")
138
+ })
139
+ ]
140
+ }, `${i}:${n.id}`))
141
+ });
142
+ }
143
+ //#endregion
144
+ export { u as ComposerAttachments, p as MessageAttachments, f as replyFilesVisible };
@@ -52,7 +52,7 @@ function a(e) {
52
52
  };
53
53
  }
54
54
  function o(e) {
55
- return (e.content ?? []).some((e) => !i.has(e.type));
55
+ return (e.attachments?.length ?? 0) > 0 || (e.content ?? []).some((e) => !i.has(e.type));
56
56
  }
57
57
  //#endregion
58
58
  export { t as fold };
@@ -4,21 +4,23 @@ import { Icon as r } from "../primitives/Icons.js";
4
4
  import { Btn as i } from "../primitives/Btn.js";
5
5
  import { useText as a } from "../../hooks/useText.js";
6
6
  import { SectionCard as o } from "../primitives/SectionCard.js";
7
- import { DynamicIcon as s } from "../shared/DynamicIcon.js";
8
- import { useTabNavigate as c } from "../../hooks/useTabNavigate.js";
9
- import { findListScreenForEntity as l } from "../../lib/actions.js";
10
- import { renderField as u } from "../fields/index.js";
11
- import { dataTableCellStyle as d, dataTableHeadCellStyle as f, dataTableStyle as p } from "../primitives/dataTableStyles.js";
12
- import { useMemo as m, useState as h } from "react";
13
- import { useQuery as g } from "@tanstack/react-query";
14
- import { jsx as _, jsxs as v } from "react/jsx-runtime";
7
+ import { RetryButton as s } from "../primitives/RetryButton.js";
8
+ import { readDisplayState as c } from "../../lib/read-display-state.js";
9
+ import { DynamicIcon as l } from "../shared/DynamicIcon.js";
10
+ import { useTabNavigate as u } from "../../hooks/useTabNavigate.js";
11
+ import { findListScreenForEntity as d } from "../../lib/actions.js";
12
+ import { renderField as f } from "../fields/index.js";
13
+ import { dataTableCellStyle as p, dataTableHeadCellStyle as m, dataTableStyle as h } from "../primitives/dataTableStyles.js";
14
+ import { useMemo as g, useState as _ } from "react";
15
+ import { useQuery as v } from "@tanstack/react-query";
16
+ import { jsx as y, jsxs as b } from "react/jsx-runtime";
15
17
  //#region src/components/chrome/AssociationTabs.tsx
16
- function y({ entityCode: e, recordId: t, associations: n, schema: r }) {
17
- let i = a(), c = m(() => Object.entries(n).filter(([, e]) => !!r.entities[e.target]), [n, r.entities]), [l, u] = h(0);
18
- if (c.length === 0) return null;
19
- let [d, f] = c[l];
20
- return /* @__PURE__ */ _(o, {
21
- title: /* @__PURE__ */ _("div", {
18
+ function x({ entityCode: e, recordId: t, associations: n, schema: r }) {
19
+ let i = a(), s = g(() => Object.entries(n).filter(([, e]) => !!r.entities[e.target]), [n, r.entities]), [c, u] = _(0);
20
+ if (s.length === 0) return null;
21
+ let [d, f] = s[c];
22
+ return /* @__PURE__ */ y(o, {
23
+ title: /* @__PURE__ */ y("div", {
22
24
  style: {
23
25
  display: "flex",
24
26
  alignItems: "center",
@@ -27,9 +29,9 @@ function y({ entityCode: e, recordId: t, associations: n, schema: r }) {
27
29
  margin: "-10px -14px 0 -14px",
28
30
  padding: "0 14px"
29
31
  },
30
- children: c.map(([e, t], n) => {
31
- let r = n === l;
32
- return /* @__PURE__ */ v("button", {
32
+ children: s.map(([e, t], n) => {
33
+ let r = n === c;
34
+ return /* @__PURE__ */ b("button", {
33
35
  onClick: (e) => {
34
36
  e.stopPropagation(), u(n);
35
37
  },
@@ -47,7 +49,7 @@ function y({ entityCode: e, recordId: t, associations: n, schema: r }) {
47
49
  cursor: "pointer",
48
50
  fontWeight: r ? 600 : 500
49
51
  },
50
- children: [t.display?.icon && /* @__PURE__ */ _(s, {
52
+ children: [t.display?.icon && /* @__PURE__ */ y(l, {
51
53
  name: t.display.icon,
52
54
  size: 13
53
55
  }), i(t.display?.name) || e]
@@ -56,7 +58,7 @@ function y({ entityCode: e, recordId: t, associations: n, schema: r }) {
56
58
  }),
57
59
  collapsible: !1,
58
60
  padding: "0",
59
- children: /* @__PURE__ */ _(b, {
61
+ children: /* @__PURE__ */ y(S, {
60
62
  entityCode: e,
61
63
  recordId: t,
62
64
  assocKey: d,
@@ -65,109 +67,121 @@ function y({ entityCode: e, recordId: t, associations: n, schema: r }) {
65
67
  })
66
68
  });
67
69
  }
68
- function b({ entityCode: o, recordId: s, assocKey: h, association: y, schema: b }) {
69
- let x = a(), S = c(), C = `${o}.${h}`, { data: w, isLoading: T } = g({
70
+ function S({ entityCode: o, recordId: l, assocKey: _, association: x, schema: S }) {
71
+ let C = a(), w = a("errors"), T = u(), E = `${o}.${_}`, D = v({
70
72
  queryKey: [
71
73
  "association",
72
- C,
73
- s
74
+ E,
75
+ l
74
76
  ],
75
- queryFn: () => n(C, [s])
76
- }), E = w?.target_entity ?? y.target, D = b.entities[E], O = m(() => w?.ids ?? [], [w?.ids]), k = m(() => D?.fields.names().find((e) => D.fields.get(e)?.primary) ?? "id", [D]), A = m(() => O.slice(0, 50), [O]), { data: j, isLoading: M } = g({
77
+ queryFn: () => n(E, [l])
78
+ }), O = D.data, k = c(D), A = O?.target_entity ?? x.target, j = S.entities[A], M = g(() => O?.ids ?? [], [O?.ids]), N = g(() => j?.fields.names().find((e) => j.fields.get(e)?.primary) ?? "id", [j]), P = g(() => M.slice(0, 50), [M]), F = v({
77
79
  queryKey: [
78
80
  "association-records",
79
- E,
80
- A
81
+ A,
82
+ P
81
83
  ],
82
- queryFn: () => t(E, {
84
+ queryFn: () => t(A, {
83
85
  per_page: 50,
84
86
  filters: [{
85
- field: k,
87
+ field: N,
86
88
  op: "in",
87
- value: A
89
+ value: P
88
90
  }]
89
91
  }),
90
- enabled: A.length > 0 && !!D
91
- }), N = j?.data ?? [], P = j?.$refs, F = m(() => D ? D.fields.names().filter((e) => {
92
- let t = D.fields.get(e);
92
+ enabled: P.length > 0 && !!j
93
+ }), I = F.data, L = c(F), R = I?.data ?? [], z = I?.$refs, B = g(() => j ? j.fields.names().filter((e) => {
94
+ let t = j.fields.get(e);
93
95
  return t && !t.primary && !t.auto && t.display?.is_listable !== !1;
94
- }).slice(0, 6) : [], [D]), I = () => {
95
- let e = l(b, E);
96
+ }).slice(0, 6) : [], [j]), V = () => {
97
+ let e = d(S, A);
96
98
  if (!e) return;
97
- let t = x(y.display?.name) || h, n = new URLSearchParams();
99
+ let t = C(x.display?.name) || _, n = new URLSearchParams();
98
100
  n.set("filters", JSON.stringify([{
99
- field: k,
101
+ field: N,
100
102
  op: "in",
101
- value: O
102
- }])), S(e.route, {
103
+ value: M
104
+ }])), T(e.route, {
103
105
  title: t,
104
- icon: y.display?.icon || e.icon,
106
+ icon: x.display?.icon || e.icon,
105
107
  search: n.toString()
106
108
  });
107
- }, L = {
109
+ }, H = {
108
110
  fontSize: 12.5,
109
111
  color: "var(--text-3)",
110
112
  padding: "14px 16px"
111
- };
112
- if (T || M) return /* @__PURE__ */ _("div", {
113
- style: L,
114
- children: x("shell.loading", "Loading…")
113
+ }, U = k.error === null ? L.error === null ? null : L : k;
114
+ if (U) return /* @__PURE__ */ b("div", {
115
+ role: "alert",
116
+ style: {
117
+ ...H,
118
+ color: "var(--danger)"
119
+ },
120
+ children: [
121
+ w("record.related_rows_unreadable", "The related records could not be loaded."),
122
+ " ",
123
+ /* @__PURE__ */ y(s, { onRetry: U.retry })
124
+ ]
125
+ });
126
+ if (k.loading || L.loading) return /* @__PURE__ */ y("div", {
127
+ style: H,
128
+ children: C("shell.loading", "Loading…")
115
129
  });
116
- if (!D) return null;
117
- if (O.length === 0) return /* @__PURE__ */ _("div", {
118
- style: L,
119
- children: x("shell.association.empty", "No related records.")
130
+ if (!j) return null;
131
+ if (M.length === 0) return /* @__PURE__ */ y("div", {
132
+ style: H,
133
+ children: C("shell.association.empty", "No related records.")
120
134
  });
121
- let R = l(b, E);
122
- return /* @__PURE__ */ v("div", {
135
+ let W = d(S, A);
136
+ return /* @__PURE__ */ b("div", {
123
137
  style: { padding: "8px 0" },
124
138
  children: [
125
- /* @__PURE__ */ v("table", {
126
- style: p,
127
- children: [/* @__PURE__ */ _("thead", { children: /* @__PURE__ */ _("tr", { children: F.map((t) => /* @__PURE__ */ _("th", {
128
- style: f,
129
- children: e(x, D.fields.get(t), t, b.entities)
130
- }, t)) }) }), /* @__PURE__ */ _("tbody", { children: N.map((e, t) => /* @__PURE__ */ _("tr", { children: F.map((t) => {
131
- let n = D.fields.get(t);
132
- return n ? /* @__PURE__ */ _("td", {
133
- style: d,
134
- children: u({
139
+ /* @__PURE__ */ b("table", {
140
+ style: h,
141
+ children: [/* @__PURE__ */ y("thead", { children: /* @__PURE__ */ y("tr", { children: B.map((t) => /* @__PURE__ */ y("th", {
142
+ style: m,
143
+ children: e(C, j.fields.get(t), t, S.entities)
144
+ }, t)) }) }), /* @__PURE__ */ y("tbody", { children: R.map((e, t) => /* @__PURE__ */ y("tr", { children: B.map((t) => {
145
+ let n = j.fields.get(t);
146
+ return n ? /* @__PURE__ */ y("td", {
147
+ style: p,
148
+ children: f({
135
149
  field: n,
136
150
  fieldName: t,
137
151
  value: e[t],
138
152
  mode: "display",
139
153
  record: e,
140
- refs: P,
141
- t: x
154
+ refs: z,
155
+ t: C
142
156
  })
143
- }, t) : /* @__PURE__ */ _("td", {}, t);
157
+ }, t) : /* @__PURE__ */ y("td", {}, t);
144
158
  }) }, t)) })]
145
159
  }),
146
- R && w && w.count > N.length && /* @__PURE__ */ _("div", {
160
+ W && O && O.count > R.length && /* @__PURE__ */ y("div", {
147
161
  style: {
148
162
  padding: "10px 16px",
149
163
  textAlign: "center"
150
164
  },
151
- children: /* @__PURE__ */ _(i, {
152
- icon: /* @__PURE__ */ _(r.external, { size: 12 }),
153
- onClick: I,
154
- children: x("shell.association.view_all", "View all {count} records", { count: w.count })
165
+ children: /* @__PURE__ */ y(i, {
166
+ icon: /* @__PURE__ */ y(r.external, { size: 12 }),
167
+ onClick: V,
168
+ children: C("shell.association.view_all", "View all {count} records", { count: O.count })
155
169
  })
156
170
  }),
157
- R && N.length > 0 && w && w.count <= N.length && /* @__PURE__ */ _("div", {
171
+ W && R.length > 0 && O && O.count <= R.length && /* @__PURE__ */ y("div", {
158
172
  style: {
159
173
  padding: "10px 16px",
160
174
  textAlign: "center"
161
175
  },
162
- children: /* @__PURE__ */ _(i, {
176
+ children: /* @__PURE__ */ y(i, {
163
177
  kind: "ghost",
164
- icon: /* @__PURE__ */ _(r.external, { size: 12 }),
165
- onClick: I,
166
- children: x("shell.association.open_list", "Open in list view")
178
+ icon: /* @__PURE__ */ y(r.external, { size: 12 }),
179
+ onClick: V,
180
+ children: C("shell.association.open_list", "Open in list view")
167
181
  })
168
182
  })
169
183
  ]
170
184
  });
171
185
  }
172
186
  //#endregion
173
- export { y as AssociationTabs };
187
+ export { x as AssociationTabs };