@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
@@ -1,69 +1,71 @@
1
1
  import { formatOffsetTimestamp as e } from "../../../lib/timestamp.js";
2
2
  import { failureTitle as t } from "../../../lib/failure.js";
3
3
  import { useText as n } from "../../../hooks/useText.js";
4
- import { useTabNavigate as r } from "../../../hooks/useTabNavigate.js";
5
- import { useEntityData as i } from "../../../hooks/useEntityData.js";
6
- import { useEffect as a, useMemo as o, useState as s } from "react";
7
- import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
4
+ import { RetryButton as r } from "../../primitives/RetryButton.js";
5
+ import { readDisplayState as i } from "../../../lib/read-display-state.js";
6
+ import { useTabNavigate as a } from "../../../hooks/useTabNavigate.js";
7
+ import { useEntityData as o } from "../../../hooks/useEntityData.js";
8
+ import { useEffect as s, useMemo as c, useState as l } from "react";
9
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
8
10
  //#region src/components/detail-layout/widgets/EntityScorecardWidget.tsx
9
- function d(e) {
11
+ function p(e) {
10
12
  return e && typeof e == "object" && !Array.isArray(e) ? e : void 0;
11
13
  }
12
- function f(e) {
13
- let t = d(e);
14
+ function m(e) {
15
+ let t = p(e);
14
16
  if (!t) return;
15
17
  let n = Object.entries(t).filter((e) => typeof e[1] == "string");
16
18
  return n.length > 0 ? Object.fromEntries(n) : void 0;
17
19
  }
18
- function p(e) {
20
+ function h(e) {
19
21
  return Array.isArray(e) ? e.flatMap((e) => {
20
- let t = d(e);
22
+ let t = p(e);
21
23
  return !t || typeof t.field != "string" ? [] : [{
22
24
  field: t.field,
23
- label: f(t.label),
25
+ label: m(t.label),
24
26
  format: t.format
25
27
  }];
26
28
  }) : [];
27
29
  }
28
- function m(e) {
30
+ function g(e) {
29
31
  if (!e || typeof e.entity != "string" || typeof e.scope_field != "string" || typeof e.window_field != "string") return;
30
32
  let t = Array.isArray(e.windows) ? e.windows.flatMap((e) => {
31
- let t = d(e);
33
+ let t = p(e);
32
34
  return t && typeof t.code == "string" ? [{
33
35
  code: t.code,
34
- label: f(t.label)
36
+ label: m(t.label)
35
37
  }] : [];
36
38
  }) : [], n = Array.isArray(e.metrics) ? e.metrics.flatMap((e) => {
37
- let t = d(e);
39
+ let t = p(e);
38
40
  if (!t || typeof t.field != "string") return [];
39
- let n = d(t.filtered);
41
+ let n = p(t.filtered);
40
42
  return [{
41
43
  field: t.field,
42
- label: f(t.label),
43
- help: f(t.help),
44
+ label: m(t.label),
45
+ help: m(t.help),
44
46
  format: t.format,
45
47
  attention: t.attention === !0,
46
48
  drillthrough_value: typeof t.drillthrough_value == "string" ? t.drillthrough_value : void 0,
47
49
  drillthrough_filter: t.drillthrough_filter !== !1,
48
50
  filtered: n && typeof n.field == "string" ? {
49
51
  field: n.field,
50
- where: d(n.where)
52
+ where: p(n.where)
51
53
  } : void 0
52
54
  }];
53
55
  }) : [];
54
56
  if (t.length === 0 || n.length === 0) return;
55
- let r = d(e.breakdown), i = r && typeof r.entity == "string" && typeof r.scope_field == "string" && typeof r.window_field == "string" ? {
57
+ let r = p(e.breakdown), i = r && typeof r.entity == "string" && typeof r.scope_field == "string" && typeof r.window_field == "string" ? {
56
58
  entity: r.entity,
57
59
  scope_field: r.scope_field,
58
60
  window_field: r.window_field,
59
61
  filter_field: typeof r.filter_field == "string" ? r.filter_field : void 0,
60
- filter_label: f(r.filter_label),
61
- all_label: f(r.all_label),
62
- empty_label: f(r.empty_label),
63
- columns: p(r.columns),
62
+ filter_label: m(r.filter_label),
63
+ all_label: m(r.all_label),
64
+ empty_label: m(r.empty_label),
65
+ columns: h(r.columns),
64
66
  sort: typeof r.sort == "string" ? r.sort : void 0,
65
67
  limit: typeof r.limit == "number" ? Math.min(500, Math.max(1, r.limit)) : 200
66
- } : void 0, a = d(e.drillthrough), o = a && typeof a.route == "string" && typeof a.scope_field == "string" && typeof a.window_field == "string" ? {
68
+ } : void 0, a = p(e.drillthrough), o = a && typeof a.route == "string" && typeof a.scope_field == "string" && typeof a.window_field == "string" ? {
67
69
  route: a.route,
68
70
  scope_field: a.scope_field,
69
71
  window_field: a.window_field,
@@ -77,15 +79,15 @@ function m(e) {
77
79
  windows: t,
78
80
  default_window: typeof e.default_window == "string" ? e.default_window : void 0,
79
81
  metrics: n,
80
- title: f(e.title),
81
- description: f(e.description),
82
- intended_note: f(e.intended_note),
83
- empty_label: f(e.empty_label),
82
+ title: m(e.title),
83
+ description: m(e.description),
84
+ intended_note: m(e.intended_note),
85
+ empty_label: m(e.empty_label),
84
86
  breakdown: i,
85
87
  drillthrough: o
86
88
  };
87
89
  }
88
- function h(e, t) {
90
+ function _(e, t) {
89
91
  let n = (e, n) => new Intl.NumberFormat(t, {
90
92
  style: "unit",
91
93
  unit: e,
@@ -93,7 +95,7 @@ function h(e, t) {
93
95
  }).format(n);
94
96
  return e >= 86400 ? n("day", Math.floor(e / 86400)) : e >= 3600 ? n("hour", Math.floor(e / 3600)) : e >= 60 ? n("minute", Math.floor(e / 60)) : n("second", Math.max(0, Math.floor(e)));
95
97
  }
96
- function g(t, n, r) {
98
+ function v(t, n, r) {
97
99
  let i = t("record.scorecard.not_available", "N/A"), a = t.language;
98
100
  if (n == null || n === "") return i;
99
101
  if (r === "number") return new Intl.NumberFormat(a).format(Number(n));
@@ -103,7 +105,7 @@ function g(t, n, r) {
103
105
  }).format(Number(n));
104
106
  if (r === "duration_seconds") {
105
107
  let e = Number(n);
106
- return Number.isFinite(e) ? h(e, a) : i;
108
+ return Number.isFinite(e) ? _(e, a) : i;
107
109
  }
108
110
  if (r === "timestamp") {
109
111
  if (typeof n != "string" && typeof n != "number" && !(n instanceof Date)) return i;
@@ -112,116 +114,116 @@ function g(t, n, r) {
112
114
  }
113
115
  return typeof n == "string" ? n : typeof n == "number" || typeof n == "bigint" || typeof n == "boolean" ? String(n) : i;
114
116
  }
115
- function _(e, t) {
117
+ function y(e, t) {
116
118
  return typeof e.id == "string" || typeof e.id == "number" ? String(e.id) : `row-${t}`;
117
119
  }
118
- function v(e, t) {
120
+ function b(e, t) {
119
121
  return !t || Object.entries(t).every(([t, n]) => e[t] === n);
120
122
  }
121
- function y({ values: e, options: d }) {
122
- let f = n(), p = n("errors"), h = o(() => m(d), [d]), y = r(), b = e.scope, x = h?.windows.some((e) => e.code === h.default_window) ? h.default_window : h?.windows[0]?.code ?? "", [S, C] = s(x), [w, T] = s("");
123
- a(() => {
124
- C(x);
125
- }, [x]), a(() => {
126
- T("");
127
- }, [S]);
128
- let E = h ? [{
129
- field: h.scope_field,
123
+ function x({ values: e, options: p }) {
124
+ let m = n(), h = n("errors"), _ = c(() => g(p), [p]), x = a(), S = e.scope, C = _?.windows.some((e) => e.code === _.default_window) ? _.default_window : _?.windows[0]?.code ?? "", [w, T] = l(C), [E, D] = l("");
125
+ s(() => {
126
+ T(C);
127
+ }, [C]), s(() => {
128
+ D("");
129
+ }, [w]);
130
+ let O = _ ? [{
131
+ field: _.scope_field,
130
132
  op: "eq",
131
- value: b
133
+ value: S
132
134
  }, {
133
- field: h.window_field,
135
+ field: _.window_field,
134
136
  op: "eq",
135
- value: S
136
- }] : [], D = i(h?.entity, {
137
+ value: w
138
+ }] : [], k = o(_?.entity, {
137
139
  per_page: 1,
138
- filters: E
139
- }, !!(h && b && S)), O = h?.breakdown, k = O ? [{
140
- field: O.scope_field,
140
+ filters: O
141
+ }, !!(_ && S && w)), A = _?.breakdown, j = A ? [{
142
+ field: A.scope_field,
141
143
  op: "eq",
142
- value: b
144
+ value: S
143
145
  }, {
144
- field: O.window_field,
146
+ field: A.window_field,
145
147
  op: "eq",
146
- value: S
147
- }] : [], A = i(O?.entity, {
148
- per_page: O?.limit ?? 200,
149
- sort: O?.sort,
150
- filters: k
151
- }, !!(O && b && S));
152
- if (!h || !b) return /* @__PURE__ */ l("div", {
148
+ value: w
149
+ }] : [], M = o(A?.entity, {
150
+ per_page: A?.limit ?? 200,
151
+ sort: A?.sort,
152
+ filters: j
153
+ }, !!(A && S && w));
154
+ if (!_ || !S) return /* @__PURE__ */ d("div", {
153
155
  role: "alert",
154
156
  className: "rounded border border-destructive p-3 text-sm text-destructive",
155
- children: p("record.scorecard_config_invalid", "Invalid entity_scorecard configuration.")
157
+ children: h("record.scorecard_config_invalid", "Invalid entity_scorecard configuration.")
156
158
  });
157
- let j = D.data?.data?.[0], M = A.data?.data ?? [], N = O?.filter_field ? Array.from(new Set(M.map((e) => e[O.filter_field]).filter((e) => typeof e == "string" && e !== ""))).sort() : [], P = w && O?.filter_field ? M.filter((e) => e[O.filter_field] === w) : M, F = (e) => !w || !e.filtered || !O?.filter_field ? j?.[e.field] : M.find((t) => t[O.filter_field] === w && v(t, e.filtered?.where))?.[e.filtered.field], I = (e) => {
158
- let t = h.drillthrough;
159
+ let N = k.data?.data?.[0], P = M.data?.data ?? [], F = A?.filter_field ? Array.from(new Set(P.map((e) => e[A.filter_field]).filter((e) => typeof e == "string" && e !== ""))).sort() : [], I = E && A?.filter_field ? P.filter((e) => e[A.filter_field] === E) : P, L = (e) => !E || !e.filtered || !A?.filter_field ? N?.[e.field] : P.find((t) => t[A.filter_field] === E && b(t, e.filtered?.where))?.[e.filtered.field], R = (e) => {
160
+ let t = _.drillthrough;
159
161
  if (!t || !e.drillthrough_value) return;
160
162
  let n = [{
161
163
  field: t.scope_field,
162
164
  op: "eq",
163
- value: b
165
+ value: S
164
166
  }, {
165
167
  field: t.window_field,
166
168
  op: "eq",
167
- value: S
169
+ value: w
168
170
  }];
169
- t.filter_field && w && e.drillthrough_filter !== !1 && n.push({
171
+ t.filter_field && E && e.drillthrough_filter !== !1 && n.push({
170
172
  field: t.filter_field,
171
173
  op: "eq",
172
- value: w
174
+ value: E
173
175
  }), t.metric_field && n.push({
174
176
  field: t.metric_field,
175
177
  op: "eq",
176
178
  value: e.drillthrough_value
177
- }), y(t.route, { search: new URLSearchParams({ filters: JSON.stringify(n) }).toString() });
178
- }, L = D.error ?? A.error, R = f(O?.filter_label) || f("record.scorecard.filter", "Filter");
179
- return /* @__PURE__ */ u("div", {
179
+ }), x(t.route, { search: new URLSearchParams({ filters: JSON.stringify(n) }).toString() });
180
+ }, z = i(k), B = i(M), V = z.error === null ? B.error === null ? null : B : z, H = V?.error, U = m(A?.filter_label) || m("record.scorecard.filter", "Filter");
181
+ return /* @__PURE__ */ f("div", {
180
182
  className: "flex min-w-0 flex-col gap-4",
181
- "aria-label": f(h.title) || f("record.scorecard.title", "Scorecard"),
183
+ "aria-label": m(_.title) || m("record.scorecard.title", "Scorecard"),
182
184
  children: [
183
- /* @__PURE__ */ u("div", {
185
+ /* @__PURE__ */ f("div", {
184
186
  className: "flex flex-wrap items-start justify-between gap-3",
185
- children: [/* @__PURE__ */ u("div", {
187
+ children: [/* @__PURE__ */ f("div", {
186
188
  className: "min-w-0",
187
189
  children: [
188
- h.title && /* @__PURE__ */ l("h3", {
190
+ _.title && /* @__PURE__ */ d("h3", {
189
191
  className: "text-base font-semibold text-foreground",
190
- children: f(h.title)
192
+ children: m(_.title)
191
193
  }),
192
- h.description && /* @__PURE__ */ l("p", {
194
+ _.description && /* @__PURE__ */ d("p", {
193
195
  className: "mt-1 text-sm text-muted-foreground",
194
- children: f(h.description)
196
+ children: m(_.description)
195
197
  }),
196
- h.intended_note && /* @__PURE__ */ l("p", {
198
+ _.intended_note && /* @__PURE__ */ d("p", {
197
199
  className: "mt-1 text-xs text-muted-foreground",
198
- children: f(h.intended_note)
200
+ children: m(_.intended_note)
199
201
  })
200
202
  ]
201
- }), /* @__PURE__ */ u("div", {
203
+ }), /* @__PURE__ */ f("div", {
202
204
  className: "flex flex-wrap items-center gap-2",
203
- children: [/* @__PURE__ */ l("div", {
205
+ children: [/* @__PURE__ */ d("div", {
204
206
  role: "group",
205
- "aria-label": f("record.scorecard.window", "Scorecard window"),
207
+ "aria-label": m("record.scorecard.window", "Scorecard window"),
206
208
  className: "inline-flex rounded border border-border p-1",
207
- children: h.windows.map((e) => /* @__PURE__ */ l("button", {
209
+ children: _.windows.map((e) => /* @__PURE__ */ d("button", {
208
210
  type: "button",
209
- "aria-pressed": S === e.code,
210
- onClick: () => C(e.code),
211
- className: `rounded px-3 py-1.5 text-xs font-medium ${S === e.code ? "bg-accent text-accent-foreground" : "text-muted-foreground"}`,
212
- children: f(e.label) || e.code
211
+ "aria-pressed": w === e.code,
212
+ onClick: () => T(e.code),
213
+ className: `rounded px-3 py-1.5 text-xs font-medium ${w === e.code ? "bg-accent text-accent-foreground" : "text-muted-foreground"}`,
214
+ children: m(e.label) || e.code
213
215
  }, e.code))
214
- }), O?.filter_field && /* @__PURE__ */ u("label", {
216
+ }), A?.filter_field && /* @__PURE__ */ f("label", {
215
217
  className: "flex items-center gap-2 text-xs text-muted-foreground",
216
- children: [R, /* @__PURE__ */ u("select", {
217
- "aria-label": R,
218
- value: w,
219
- onChange: (e) => T(e.target.value),
218
+ children: [U, /* @__PURE__ */ f("select", {
219
+ "aria-label": U,
220
+ value: E,
221
+ onChange: (e) => D(e.target.value),
220
222
  className: "rounded border border-border bg-background px-2 py-1.5 text-foreground",
221
- children: [/* @__PURE__ */ l("option", {
223
+ children: [/* @__PURE__ */ d("option", {
222
224
  value: "",
223
- children: f(O.all_label) || f("record.scorecard.all", "All")
224
- }), N.map((e) => /* @__PURE__ */ l("option", {
225
+ children: m(A.all_label) || m("record.scorecard.all", "All")
226
+ }), F.map((e) => /* @__PURE__ */ d("option", {
225
227
  value: e,
226
228
  children: e
227
229
  }, e))]
@@ -229,63 +231,67 @@ function y({ values: e, options: d }) {
229
231
  })]
230
232
  })]
231
233
  }),
232
- L && /* @__PURE__ */ l("div", {
234
+ V && /* @__PURE__ */ f("div", {
233
235
  role: "alert",
234
236
  className: "rounded border border-destructive p-3 text-sm text-destructive",
235
- children: t(p, L)
237
+ children: [
238
+ t(h, H),
239
+ " ",
240
+ /* @__PURE__ */ d(r, { onRetry: V.retry })
241
+ ]
236
242
  }),
237
- !L && !D.isLoading && !j && /* @__PURE__ */ l("div", {
243
+ !V && !z.loading && !N && /* @__PURE__ */ d("div", {
238
244
  className: "rounded border border-border p-6 text-center text-sm text-muted-foreground",
239
- children: f(h.empty_label) || f("record.scorecard.empty", "No scorecard data.")
245
+ children: m(_.empty_label) || m("record.scorecard.empty", "No scorecard data.")
240
246
  }),
241
- j && /* @__PURE__ */ l("div", {
247
+ N && /* @__PURE__ */ d("div", {
242
248
  className: "grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4",
243
- children: h.metrics.map((e) => {
244
- let t = F(e), n = !!(h.drillthrough && e.drillthrough_value), r = /* @__PURE__ */ u(c, { children: [
245
- /* @__PURE__ */ l("span", {
249
+ children: _.metrics.map((e) => {
250
+ let t = L(e), n = !!(_.drillthrough && e.drillthrough_value), r = /* @__PURE__ */ f(u, { children: [
251
+ /* @__PURE__ */ d("span", {
246
252
  className: "text-xs font-medium text-muted-foreground",
247
- children: f(e.label) || e.field
253
+ children: m(e.label) || e.field
248
254
  }),
249
- /* @__PURE__ */ l("strong", {
255
+ /* @__PURE__ */ d("strong", {
250
256
  className: `mt-2 block text-2xl font-semibold ${e.attention && Number(t) > 0 ? "text-destructive" : "text-foreground"}`,
251
- children: g(f, t, e.format)
257
+ children: v(m, t, e.format)
252
258
  }),
253
- e.help && /* @__PURE__ */ l("span", {
259
+ e.help && /* @__PURE__ */ d("span", {
254
260
  className: "mt-1 block text-xs text-muted-foreground",
255
- children: f(e.help)
261
+ children: m(e.help)
256
262
  })
257
263
  ] });
258
- return n ? /* @__PURE__ */ l("button", {
264
+ return n ? /* @__PURE__ */ d("button", {
259
265
  type: "button",
260
- onClick: () => I(e),
266
+ onClick: () => R(e),
261
267
  className: "rounded border border-border bg-card p-3 text-left hover:bg-surface",
262
268
  children: r
263
- }, e.field) : /* @__PURE__ */ l("article", {
269
+ }, e.field) : /* @__PURE__ */ d("article", {
264
270
  className: "rounded border border-border bg-card p-3",
265
271
  children: r
266
272
  }, e.field);
267
273
  })
268
274
  }),
269
- O && /* @__PURE__ */ l("div", {
275
+ A && /* @__PURE__ */ d("div", {
270
276
  className: "min-w-0 overflow-x-auto rounded border border-border",
271
- children: /* @__PURE__ */ u("table", {
277
+ children: /* @__PURE__ */ f("table", {
272
278
  className: "w-full border-collapse text-sm",
273
- children: [/* @__PURE__ */ l("thead", {
279
+ children: [/* @__PURE__ */ d("thead", {
274
280
  className: "bg-surface text-left text-xs text-muted-foreground",
275
- children: /* @__PURE__ */ l("tr", { children: O.columns.map((e) => /* @__PURE__ */ l("th", {
281
+ children: /* @__PURE__ */ d("tr", { children: A.columns.map((e) => /* @__PURE__ */ d("th", {
276
282
  className: "border-b border-divider px-3 py-2 font-medium",
277
- children: f(e.label) || e.field
283
+ children: m(e.label) || e.field
278
284
  }, e.field)) })
279
- }), /* @__PURE__ */ u("tbody", { children: [P.map((e, t) => /* @__PURE__ */ l("tr", {
285
+ }), /* @__PURE__ */ f("tbody", { children: [I.map((e, t) => /* @__PURE__ */ d("tr", {
280
286
  className: "border-b border-divider last:border-0",
281
- children: O.columns.map((t) => /* @__PURE__ */ l("td", {
287
+ children: A.columns.map((t) => /* @__PURE__ */ d("td", {
282
288
  className: "px-3 py-2 text-foreground",
283
- children: g(f, e[t.field], t.format)
289
+ children: v(m, e[t.field], t.format)
284
290
  }, t.field))
285
- }, _(e, t))), !A.isLoading && P.length === 0 && /* @__PURE__ */ l("tr", { children: /* @__PURE__ */ l("td", {
286
- colSpan: Math.max(1, O.columns.length),
291
+ }, y(e, t))), !B.loading && I.length === 0 && /* @__PURE__ */ d("tr", { children: /* @__PURE__ */ d("td", {
292
+ colSpan: Math.max(1, A.columns.length),
287
293
  className: "px-3 py-6 text-center text-muted-foreground",
288
- children: f(O.empty_label) || f("record.scorecard.breakdown_empty", "No breakdown rows.")
294
+ children: m(A.empty_label) || m("record.scorecard.breakdown_empty", "No breakdown rows.")
289
295
  }) })] })]
290
296
  })
291
297
  })
@@ -293,4 +299,4 @@ function y({ values: e, options: d }) {
293
299
  });
294
300
  }
295
301
  //#endregion
296
- export { y as EntityScorecardWidget };
302
+ export { x as EntityScorecardWidget };
@@ -1,75 +1,77 @@
1
1
  import { coerceDisplayString as e } from "../../lib/display-value.js";
2
2
  import { getPrimaryKeyFields as t, resolveRefRecordLabel as n } from "../../types/schema.js";
3
3
  import { useText as r } from "../../hooks/useText.js";
4
- import { Select as i } from "../primitives/Fields.js";
5
- import { useEntityData as a } from "../../hooks/useEntityData.js";
6
- import { useEntity as o } from "../../hooks/useEntity.js";
7
- import { readableFilters as s, readableSort as c } from "../../lib/field-classification.js";
8
- import { useDebounce as l } from "../../hooks/useDebounce.js";
9
- import { refChoicesEntity as u } from "../../lib/ref-choices.js";
4
+ import { RetryButton as i } from "../primitives/RetryButton.js";
5
+ import { Select as a } from "../primitives/Fields.js";
6
+ import { readDisplayState as ee } from "../../lib/read-display-state.js";
7
+ import { useEntityData as o } from "../../hooks/useEntityData.js";
8
+ import { useEntity as s } from "../../hooks/useEntity.js";
9
+ import { readableFilters as c, readableSort as l } from "../../lib/field-classification.js";
10
+ import { useDebounce as u } from "../../hooks/useDebounce.js";
11
+ import { refChoicesEntity as te } from "../../lib/ref-choices.js";
10
12
  import { useMemo as d, useRef as f, useState as p } from "react";
11
- import { jsx as m } from "react/jsx-runtime";
13
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
12
14
  //#region src/components/fields/RefCombobox.tsx
13
- var h = 200;
14
- function g({ ref: g, value: _, onChange: v, refs: y, displayFieldOverride: b, id: x, labelId: S, ariaLabel: C, required: w, placeholder: T, specialValues: E }) {
15
- let D = r(), O = r("errors"), k = g?.entity, A = u(k), j = o(A), M = b ?? g?.display?.field ?? (j?.display?.display_template ? "$display" : j?.display?.display_field) ?? "$display", N = M === "$display" ? j?.display?.display_field : M, P = d(() => j ? t(j)[0] ?? "id" : "id", [j]), F = g?.field || P, [I, L] = p(""), R = l(I, 300), { data: z, isLoading: B, isError: V } = a(A, {
16
- per_page: h,
17
- sort: c(j, N ? `${N}:asc` : void 0),
15
+ var g = 200;
16
+ function _({ ref: _, value: v, onChange: y, refs: b, displayFieldOverride: ne, id: x, labelId: S, ariaLabel: C, required: w, placeholder: T, specialValues: E }) {
17
+ let D = r(), O = r("errors"), k = _?.entity, A = te(k), j = s(A), M = ne ?? _?.display?.field ?? (j?.display?.display_template ? "$display" : j?.display?.display_field) ?? "$display", N = M === "$display" ? j?.display?.display_field : M, P = d(() => j ? t(j)[0] ?? "id" : "id", [j]), F = _?.field || P, [I, L] = p(""), R = u(I, 300), z = o(A, {
18
+ per_page: g,
19
+ sort: l(j, N ? `${N}:asc` : void 0),
18
20
  search: R || void 0,
19
- filters: g?.options_filter && s(j, g.options_filter)
20
- }), H = d(() => z?.data ?? [], [z?.data]), U = V ? O("record.ref_choices_unreadable", "The choices could not be loaded.") : T ?? D("field.select_placeholder", "Select…"), W = _ == null ? "" : e(_), G = d(() => H.some((e) => String(e[F]) === W), [
21
- H,
21
+ filters: _?.options_filter && c(j, _.options_filter)
22
+ }), B = z.data, V = ee(z), H = V.loading, U = V.error !== null, W = d(() => B?.data ?? [], [B?.data]), G = U ? O("record.ref_choices_unreadable", "The choices could not be loaded.") : T ?? D("field.select_placeholder", "Select…"), K = v == null ? "" : e(v), q = d(() => W.some((e) => String(e[F]) === K), [
23
+ W,
22
24
  F,
23
- W
24
- ]), K = y && k ? y[k]?.[W] : void 0, q = !!E?.some((e) => e.code === W), { data: J } = a(W && !G && !q && !K && !B ? A : void 0, {
25
+ K
26
+ ]), J = b && k ? b[k]?.[K] : void 0, Y = !!E?.some((e) => e.code === K), { data: X } = o(K && !q && !Y && !J && !H ? A : void 0, {
25
27
  per_page: 1,
26
28
  filters: [{
27
29
  field: F,
28
30
  op: "eq",
29
- value: W
31
+ value: K
30
32
  }]
31
- }), Y = f(null), X = d(() => {
32
- if (!W) return "";
33
+ }), Z = f(null), Q = d(() => {
34
+ if (!K) return "";
33
35
  let e;
34
- if (K) e = n(D, K, M, W);
36
+ if (J) e = n(D, J, M, K);
35
37
  else {
36
- let t = H.find((e) => String(e[F]) === W);
37
- if (t) e = n(D, t, M, W);
38
+ let t = W.find((e) => String(e[F]) === K);
39
+ if (t) e = n(D, t, M, K);
38
40
  else {
39
- let t = J?.data?.find((e) => String(e[F]) === W);
40
- t && (e = n(D, t, M, W));
41
+ let t = X?.data?.find((e) => String(e[F]) === K);
42
+ t && (e = n(D, t, M, K));
41
43
  }
42
44
  }
43
- return e === void 0 ? Y.current?.value === W ? Y.current.label : W : (Y.current = {
44
- value: W,
45
+ return e === void 0 ? Z.current?.value === K ? Z.current.label : K : (Z.current = {
46
+ value: K,
45
47
  label: e
46
48
  }, e);
47
49
  }, [
48
50
  D,
49
- W,
50
51
  K,
51
- H,
52
+ J,
53
+ W,
52
54
  F,
53
55
  M,
54
- J
55
- ]), Z = d(() => {
56
+ X
57
+ ]), re = d(() => {
56
58
  let t = (E ?? []).map((e) => ({
57
59
  value: e.code,
58
60
  label: D(e.label) || e.code
59
- })), r = H.map((t) => {
61
+ })), r = W.map((t) => {
60
62
  let r = e(t[F]);
61
63
  return {
62
64
  value: r,
63
65
  label: n(D, t, M, r)
64
66
  };
65
- }), i = W && !G && !q ? [{
66
- value: W,
67
- label: X
67
+ }), i = K && !q && !Y ? [{
68
+ value: K,
69
+ label: Q
68
70
  }] : [], a = r.length > 0 || i.length > 0;
69
71
  return [
70
72
  {
71
73
  value: "",
72
- label: U
74
+ label: G
73
75
  },
74
76
  ...t.length > 0 ? [{
75
77
  value: "",
@@ -86,27 +88,30 @@ function g({ ref: g, value: _, onChange: v, refs: y, displayFieldOverride: b, id
86
88
  ];
87
89
  }, [
88
90
  D,
89
- U,
90
- E,
91
- W,
92
91
  G,
92
+ E,
93
+ K,
93
94
  q,
94
- X,
95
- H,
95
+ Y,
96
+ Q,
97
+ W,
96
98
  F,
97
99
  M
98
- ]);
99
- return /* @__PURE__ */ m(i, {
100
+ ]), $ = /* @__PURE__ */ m(a, {
100
101
  id: x,
101
102
  "aria-label": C,
102
103
  "aria-labelledby": S,
103
104
  "aria-required": w || void 0,
104
- value: W,
105
- options: Z,
106
- onChange: (e) => v(e || null),
105
+ value: K,
106
+ options: re,
107
+ onChange: (e) => y(e || null),
107
108
  onSearchChange: L,
108
- placeholder: U
109
+ placeholder: G
109
110
  });
111
+ return U ? /* @__PURE__ */ h("span", {
112
+ className: "inline-flex items-center gap-2",
113
+ children: [$, /* @__PURE__ */ m(i, { onRetry: V.retry })]
114
+ }) : $;
110
115
  }
111
116
  //#endregion
112
- export { g as RefCombobox };
117
+ export { _ as RefCombobox };
@@ -42,6 +42,7 @@ var w = {
42
42
  bytes: t,
43
43
  ref: u,
44
44
  file_ref: b,
45
+ folder_ref: t,
45
46
  json: d,
46
47
  tags: t,
47
48
  string_array: _,