@declarion/react 0.48.2 → 0.50.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 (88) hide show
  1. package/dist-lib/Check-DAfMbQIw.js +38 -0
  2. package/dist-lib/{DraggableChildrenTable-p2ZSdwzj.js → DraggableChildrenTable-Dar8C-Z9.js} +31 -31
  3. package/dist-lib/DynamicIcon-DW5krHuX.js +280 -0
  4. package/dist-lib/{Grid-CjLFAKMZ.js → Grid-BkHtfsty.js} +2 -2
  5. package/dist-lib/{LayoutRenderer-DCscqXsv.js → LayoutRenderer-Cic7IAop.js} +601 -598
  6. package/dist-lib/ListCardsBody-Dko91bLv.js +287 -0
  7. package/dist-lib/{MarkdownRenderer-Sb7zcvj0.js → MarkdownRenderer-CJrVG5HZ.js} +1 -1
  8. package/dist-lib/RefreshControl-BS8WWL8i.js +430 -0
  9. package/dist-lib/{SmartDetailPage.impl-BAW-Tx_H.js → SmartDetailPage.impl-DxRDo0p2.js} +521 -516
  10. package/dist-lib/SmartListPage.impl-CNdq5Vts.js +2849 -0
  11. package/dist-lib/{SmartRecordListPage.impl-DtSSlGrI.js → SmartRecordListPage.impl-3ct7f4rT.js} +244 -241
  12. package/dist-lib/SortHeaderMenu-NgjkW8QZ.js +106 -0
  13. package/dist-lib/action-dispatch-hVrm3Hrg.js +1984 -0
  14. package/dist-lib/api/batch.d.ts +5 -2
  15. package/dist-lib/api/data.d.ts +35 -4
  16. package/dist-lib/api/entities.d.ts +3 -3
  17. package/dist-lib/cardProjection-BR-fXPvJ.js +757 -0
  18. package/dist-lib/components/{shared → actions}/ObjectActionBar.d.ts +1 -1
  19. package/dist-lib/components/{shared → actions}/ResponsiveActionBar.d.ts +1 -1
  20. package/dist-lib/components/fields/cells/factories/date.d.ts +2 -0
  21. package/dist-lib/components/file-widgets/upload.d.ts +6 -1
  22. package/dist-lib/components/layout/Layout.d.ts +1 -1
  23. package/dist-lib/components/layout/TopBar.d.ts +1 -1
  24. package/dist-lib/components/pages/SmartListPage.d.ts +2 -12
  25. package/dist-lib/components/pages/SmartListPage.impl.d.ts +4 -0
  26. package/dist-lib/components/pages/list/ListCardRow.d.ts +40 -0
  27. package/dist-lib/components/pages/list/ListCardsBody.d.ts +34 -0
  28. package/dist-lib/components/pages/list/ListFloatbar.d.ts +1 -1
  29. package/dist-lib/components/pages/list/ListFooter.d.ts +26 -0
  30. package/dist-lib/components/pages/list/ListHeader.d.ts +1 -1
  31. package/dist-lib/components/pages/list/ListNoRows.d.ts +32 -0
  32. package/dist-lib/components/pages/list/ListTable.d.ts +34 -0
  33. package/dist-lib/components/pages/list/ListTableRow.d.ts +18 -0
  34. package/dist-lib/components/pages/list/ListToolbar.d.ts +43 -0
  35. package/dist-lib/components/pages/list/SortHeaderMenu.d.ts +14 -0
  36. package/dist-lib/components/pages/list/page-size.d.ts +3 -0
  37. package/dist-lib/components/pages/list/sortable-header.d.ts +2 -0
  38. package/dist-lib/components/pages/list/useListColumnLayout.d.ts +37 -0
  39. package/dist-lib/components/pages/list/useListQuery.d.ts +66 -0
  40. package/dist-lib/components/pages/list/useListRowInteraction.d.ts +61 -0
  41. package/dist-lib/components/pages/list/useListSelection.d.ts +31 -0
  42. package/dist-lib/components/pages/list/useListSort.d.ts +45 -0
  43. package/dist-lib/components/pages/list/useListViews.d.ts +46 -0
  44. package/dist-lib/components/pages/list/useRowMenu.d.ts +1 -1
  45. package/dist-lib/components/primitives/Icons.d.ts +5 -0
  46. package/dist-lib/components/shared/RefreshControl.d.ts +17 -4
  47. package/dist-lib/field-classification-Bm0mgbwA.js +1134 -0
  48. package/dist-lib/format-count-BfRGwx2v.js +1551 -0
  49. package/dist-lib/hooks/useBrandingChrome.d.ts +17 -1
  50. package/dist-lib/hooks/useText.d.ts +3 -0
  51. package/dist-lib/hooks/useViews.d.ts +1 -1
  52. package/dist-lib/icons.js +1 -1
  53. package/dist-lib/index.d.ts +17 -15
  54. package/dist-lib/index.js +1784 -6288
  55. package/dist-lib/lib/messages.d.ts +7 -1
  56. package/dist-lib/lib/rowClickGesture.d.ts +12 -0
  57. package/dist-lib/lib/timestamp.d.ts +8 -3
  58. package/dist-lib/peekDraftStore-bb4WroTA.js +194 -0
  59. package/dist-lib/record-documents-key-8fdm7C10.js +27 -0
  60. package/dist-lib/registry-CgeGoWpW.js +1768 -0
  61. package/dist-lib/testing.d.ts +17 -2
  62. package/dist-lib/testing.js +72 -58
  63. package/dist-lib/types/api.d.ts +54 -12
  64. package/dist-lib/types/schema.d.ts +22 -6
  65. package/dist-lib/{useCurrentScreen-BshVTPVq.js → useCurrentScreen-D3XH5ptA.js} +1127 -1070
  66. package/dist-lib/useListQuery-CfuINl-0.js +87 -0
  67. package/dist-lib/useProperties-DNocaxBX.js +81 -0
  68. package/dist-lib/{useProperties-DrHFr0A1.js → useTabSearchMirror-d0BAUIcQ.js} +116 -194
  69. package/dist-lib/{value-B1O6QikE.js → value-D71J0sJq.js} +69 -69
  70. package/package.json +1 -1
  71. package/dist-lib/DynamicIcon-Dc2j-rg_.js +0 -275
  72. package/dist-lib/RefreshControl-Cnl9nE0x.js +0 -945
  73. package/dist-lib/registry-CCxnZW2b.js +0 -5281
  74. /package/dist-lib/components/{shared → actions}/ActionButton.d.ts +0 -0
  75. /package/dist-lib/components/{shared → actions}/ActionDialog.d.ts +0 -0
  76. /package/dist-lib/components/{shared → actions}/ActionResultDialog.d.ts +0 -0
  77. /package/dist-lib/components/{shared → actions}/ActionRunner.d.ts +0 -0
  78. /package/dist-lib/components/{mass-edit → actions}/PropertyGridEditor.d.ts +0 -0
  79. /package/dist-lib/components/{shared → actions}/RowActionsKebab.d.ts +0 -0
  80. /package/dist-lib/components/{shared → chrome}/AssociationTabs.d.ts +0 -0
  81. /package/dist-lib/components/{shared → chrome}/AuditMetaStrip.d.ts +0 -0
  82. /package/dist-lib/components/{shared → chrome}/Breadcrumbs.d.ts +0 -0
  83. /package/dist-lib/components/{shared → chrome}/HighlightsStrip.d.ts +0 -0
  84. /package/dist-lib/components/{shared → chrome}/PageHeader.d.ts +0 -0
  85. /package/dist-lib/components/{shared → chrome}/RecordHeader.d.ts +0 -0
  86. /package/dist-lib/components/{shell → layout}/CommandPalette.d.ts +0 -0
  87. /package/dist-lib/components/{columns → list}/ColumnPicker.d.ts +0 -0
  88. /package/dist-lib/components/{views → list}/ViewSwitcher.d.ts +0 -0
@@ -0,0 +1,1768 @@
1
+ import { s as e, t } from "./DynamicIcon-DW5krHuX.js";
2
+ import { $n as n, A as r, At as i, Bn as a, C as o, Cn as s, Dn as c, E as l, En as u, Gt as d, Jn as f, K as p, Nn as m, O as h, Sn as g, St as _, T as v, X as y, Zn as b, _ as x, _t as S, b as C, bt as w, cr as T, d as E, dr as D, er as O, fr as k, gn as A, gt as j, i as M, j as N, kt as P, rr as ee, rt as F, u as I, ur as L, v as R, vt as te, wn as z, wt as B, yt as V, zn as H } from "./useCurrentScreen-D3XH5ptA.js";
3
+ import { g as ne, h as U, j as re } from "./field-classification-Bm0mgbwA.js";
4
+ import { c as ie, l as ae, o as oe, t as se } from "./action-dispatch-hVrm3Hrg.js";
5
+ import { n as ce, r as le, t as W } from "./dataTableStyles-vwD1mVOP.js";
6
+ import { Component as ue, useCallback as G, useEffect as de, useId as K, useMemo as q, useRef as J, useState as Y } from "react";
7
+ import { useInfiniteQuery as fe, useQuery as pe, useQueryClient as X } from "@tanstack/react-query";
8
+ import { Fragment as me, jsx as Z, jsxs as Q } from "react/jsx-runtime";
9
+ import { clsx as he } from "clsx";
10
+ import { twMerge as ge } from "tailwind-merge";
11
+ //#region src/components/primitives/SectionCard.tsx
12
+ var $ = {
13
+ primary: {
14
+ surface: "var(--surface)",
15
+ shadow: "var(--shadow-xs)"
16
+ },
17
+ secondary: {
18
+ surface: "var(--surface-2)",
19
+ shadow: "none"
20
+ }
21
+ };
22
+ function _e({ title: t, subtitle: n, right: r, badge: i, count: a, children: o, footer: s, collapsible: c = !0, defaultOpen: l = !0, icon: u, emphasis: d = "primary", headingLevel: f = 2, padding: p = "16px" }) {
23
+ let [m, h] = Y(l), g = $[d] ?? $.primary;
24
+ return /* @__PURE__ */ Q("div", {
25
+ "data-emphasis": d,
26
+ style: {
27
+ background: g.surface,
28
+ border: "1px solid var(--border)",
29
+ borderRadius: 10,
30
+ overflow: "hidden",
31
+ boxShadow: g.shadow,
32
+ flexShrink: 0
33
+ },
34
+ children: [
35
+ /* @__PURE__ */ Q("div", {
36
+ style: {
37
+ display: "flex",
38
+ alignItems: "center",
39
+ gap: 10,
40
+ padding: "10px 14px",
41
+ borderBottom: m ? "1px solid var(--divider)" : "none",
42
+ minHeight: 40
43
+ },
44
+ children: [
45
+ /* @__PURE__ */ Z("div", {
46
+ role: "heading",
47
+ "aria-level": f,
48
+ style: {
49
+ display: "flex",
50
+ flex: 1,
51
+ minWidth: 0
52
+ },
53
+ children: /* @__PURE__ */ Q("div", {
54
+ role: c ? "button" : void 0,
55
+ tabIndex: c ? 0 : void 0,
56
+ "aria-expanded": c ? m : void 0,
57
+ onClick: c ? () => h((e) => !e) : void 0,
58
+ onKeyDown: c ? (e) => {
59
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), h((e) => !e));
60
+ } : void 0,
61
+ style: {
62
+ display: "flex",
63
+ alignItems: "center",
64
+ gap: 8,
65
+ flex: 1,
66
+ minWidth: 0,
67
+ cursor: c ? "pointer" : "default",
68
+ userSelect: "none"
69
+ },
70
+ children: [
71
+ u && /* @__PURE__ */ Z("span", {
72
+ style: {
73
+ color: "var(--text-3)",
74
+ display: "flex",
75
+ flexShrink: 0
76
+ },
77
+ children: u
78
+ }),
79
+ /* @__PURE__ */ Z("div", {
80
+ style: {
81
+ fontSize: 12.5,
82
+ fontWeight: 600,
83
+ color: "var(--text)",
84
+ letterSpacing: "-0.005em",
85
+ overflow: "hidden",
86
+ textOverflow: "ellipsis",
87
+ whiteSpace: "nowrap",
88
+ minWidth: 0
89
+ },
90
+ children: t
91
+ }),
92
+ a !== void 0 && /* @__PURE__ */ Z("span", {
93
+ className: "num",
94
+ style: {
95
+ fontSize: 11,
96
+ fontWeight: 600,
97
+ color: "var(--text-3)",
98
+ background: "var(--surface-3)",
99
+ borderRadius: 999,
100
+ padding: "1px 7px",
101
+ minWidth: 20,
102
+ textAlign: "center",
103
+ flexShrink: 0
104
+ },
105
+ children: a
106
+ }),
107
+ n && /* @__PURE__ */ Z("div", {
108
+ style: {
109
+ fontSize: 11.5,
110
+ color: "var(--text-3)",
111
+ flexShrink: 0,
112
+ borderLeft: "1px solid var(--divider)",
113
+ paddingLeft: 8,
114
+ marginLeft: 2
115
+ },
116
+ children: n
117
+ })
118
+ ]
119
+ })
120
+ }),
121
+ i && /* @__PURE__ */ Z(L, {
122
+ tone: i.tone ?? "violet",
123
+ size: "xs",
124
+ dot: i.dot,
125
+ children: i.text
126
+ }),
127
+ r,
128
+ c && /* @__PURE__ */ Z(D, {
129
+ size: 24,
130
+ icon: Z(m ? e.up : e.down, { size: 14 }),
131
+ onClick: () => h((e) => !e),
132
+ title: m ? "Collapse" : "Expand"
133
+ })
134
+ ]
135
+ }),
136
+ m && /* @__PURE__ */ Z("div", {
137
+ style: { padding: p },
138
+ children: o
139
+ }),
140
+ s && m && /* @__PURE__ */ Z("div", {
141
+ style: {
142
+ padding: "8px 14px",
143
+ borderTop: "1px solid var(--divider)",
144
+ background: "var(--surface-2)",
145
+ fontSize: 11.5,
146
+ color: "var(--text-3)"
147
+ },
148
+ children: s
149
+ })
150
+ ]
151
+ });
152
+ }
153
+ //#endregion
154
+ //#region src/components/primitives/ClassifiedFieldLocked.tsx
155
+ function ve({ tier: t, tierDef: n, requiredPermission: r, locale: i = "en", variant: a = "value" }) {
156
+ let o = n?.name?.[i] ?? n?.name?.en ?? t, s = r ? `Locked: requires permission "${r}". Ask your administrator to grant it to your role.` : `Locked: ${o} classification — requires explicit grant.`;
157
+ return /* @__PURE__ */ Q("span", {
158
+ title: s,
159
+ "aria-label": s,
160
+ className: `inline-flex items-center gap-1 text-muted-foreground italic select-none ${a === "input" ? "border border-divider rounded-md px-2 py-1 bg-surface" : ""}`,
161
+ children: [/* @__PURE__ */ Z(e.lock, { size: 12 }), /* @__PURE__ */ Z("span", { children: o })]
162
+ });
163
+ }
164
+ //#endregion
165
+ //#region src/lib/utils.ts
166
+ function ye(...e) {
167
+ return ge(he(e));
168
+ }
169
+ function be(e) {
170
+ return e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0;
171
+ }
172
+ //#endregion
173
+ //#region src/hooks/useAssociatedData.ts
174
+ function xe(e, t, n, r, i, a, o, s) {
175
+ let c = s ? JSON.stringify(Object.entries(s).sort()) : void 0;
176
+ return fe({
177
+ queryKey: [
178
+ U,
179
+ e,
180
+ t,
181
+ n,
182
+ i,
183
+ a,
184
+ o,
185
+ c
186
+ ],
187
+ queryFn: ({ pageParam: e }) => {
188
+ let c = new URLSearchParams(), l = [{
189
+ field: r,
190
+ op: "eq",
191
+ value: t
192
+ }];
193
+ if (s) for (let [e, t] of Object.entries(s)) t && t !== "__all__" && l.push({
194
+ field: e,
195
+ op: "eq",
196
+ value: t
197
+ });
198
+ return c.set("filters", JSON.stringify(l)), i && c.set("sort", i), a && c.set("limit", String(a)), o && c.set("search", o), e && c.set("after", e), d(`/api/data/${n}?${c.toString()}`);
199
+ },
200
+ getNextPageParam: (e) => e.meta?.has_more ? e.meta.cursor : void 0,
201
+ initialPageParam: void 0,
202
+ enabled: !!e && !!t && !!n && !!r
203
+ });
204
+ }
205
+ //#endregion
206
+ //#region src/components/actions/ActionButton.tsx
207
+ function Se({ actionCode: n, action: r, entityCode: a, objectIds: s = [], row: l, variant: u = "outline", size: d = "default", onSuccess: f }) {
208
+ let [p, m] = Y(!1), [g, _] = Y(!1), { data: y } = i(), b = re(), { run: x } = M(), S = v(r), T = !l || C(r.conditions, l), O = G(async () => {
209
+ if (!(!r.association || s.length === 0)) {
210
+ m(!0);
211
+ try {
212
+ let e = a ? `${a}.${r.association}` : r.association, t = await B(e, s), n = o(y, t.target_entity);
213
+ if (!n) {
214
+ F.error(`No list screen found for ${t.target_entity}`);
215
+ return;
216
+ }
217
+ let i = y?.entities[t.target_entity], l = c(r.display?.name) || t.target_entity;
218
+ if (t.ids.length === 0) {
219
+ F.info(`No related ${l} found`);
220
+ return;
221
+ }
222
+ let u = i?.fields.names().find((e) => i.fields.get(e)?.primary) ?? "id", d = new URLSearchParams();
223
+ d.set(`filter_${u}`, t.ids.join(",")), b(n.route, {
224
+ title: l,
225
+ icon: r.display?.icon || n.icon,
226
+ search: d.toString()
227
+ }), f?.();
228
+ } catch (e) {
229
+ F.error(e instanceof Error ? e.message : "Failed to resolve association");
230
+ } finally {
231
+ m(!1);
232
+ }
233
+ }
234
+ }, [
235
+ r,
236
+ a,
237
+ s,
238
+ y,
239
+ b,
240
+ f
241
+ ]), A = r.entity ? `${r.entity}.${n}` : n, N = s.length > 0 ? s : void 0, P = G(() => {
242
+ _(!0), x({
243
+ action: r,
244
+ title: c(r.display?.name) || n,
245
+ row: l,
246
+ entity: a,
247
+ execute: (e) => w(A, j(e, N)),
248
+ onSuccess: () => f?.()
249
+ }).finally(() => _(!1));
250
+ }, [
251
+ x,
252
+ r,
253
+ n,
254
+ l,
255
+ a,
256
+ A,
257
+ N,
258
+ f
259
+ ]), ee = G(() => {
260
+ if (E(r)) {
261
+ I(r.ui_steps, { row: l }).then(() => f?.());
262
+ return;
263
+ }
264
+ if (S) {
265
+ O();
266
+ return;
267
+ }
268
+ if (r.href && !r.handler && !r.association) {
269
+ let e = a ? y?.entities[a] : void 0, t = h(l, e), i = r.href;
270
+ a && (i = i.replaceAll("${entity}", a)), t && (i = i.replaceAll("${id}", encodeURIComponent(t))), b(i, {
271
+ title: c(r.display?.name) || n,
272
+ icon: r.display?.icon
273
+ }), f?.();
274
+ return;
275
+ }
276
+ P();
277
+ }, [
278
+ r,
279
+ l,
280
+ a,
281
+ y?.entities,
282
+ n,
283
+ b,
284
+ S,
285
+ O,
286
+ P,
287
+ f
288
+ ]), L = c(r.display?.name), R = r.display?.icon, te = R && e[R], z = te ? /* @__PURE__ */ Z(te, { size: 13 }) : R ? /* @__PURE__ */ Z(t, {
289
+ name: R,
290
+ size: 13
291
+ }) : null, V = !T || g || p;
292
+ return d === "icon" ? /* @__PURE__ */ Z(D, {
293
+ icon: z ?? /* @__PURE__ */ Z(e.bolt, { size: 13 }),
294
+ onClick: ee,
295
+ title: L
296
+ }) : /* @__PURE__ */ Z(k, {
297
+ kind: u === "default" ? "primary" : u === "ghost" ? "ghost" : "default",
298
+ size: "sm",
299
+ icon: z,
300
+ danger: r.destructive,
301
+ onClick: ee,
302
+ disabled: V,
303
+ title: L,
304
+ "aria-label": L,
305
+ children: L
306
+ });
307
+ }
308
+ //#endregion
309
+ //#region src/components/actions/RowActionsKebab.tsx
310
+ function Ce({ actions: t, objectIds: n, row: r, entity: i, onSuccess: a, preMenu: o, divider: s, size: l = 22, align: u = "end" }) {
311
+ let d = J(null), [f, p] = Y(!1), [m, h] = Y(null), { run: g } = M(), _ = q(() => {
312
+ let e = {};
313
+ for (let { code: n, action: r } of t) e[n] = r;
314
+ return e;
315
+ }, [t]), v = q(() => {
316
+ let e = t.map(({ code: e }) => ({
317
+ kind: "action",
318
+ code: e,
319
+ enabled: !0,
320
+ reason: null
321
+ }));
322
+ return r ? x(e, _, void 0, r, [], oe(i, r)) : e;
323
+ }, [
324
+ t,
325
+ _,
326
+ r,
327
+ i
328
+ ]), y = G((e, t) => {
329
+ p(!1);
330
+ let i = t.entity ? `${t.entity}.${e}` : e;
331
+ return g({
332
+ action: t,
333
+ title: c(t.display?.name) || e,
334
+ row: r,
335
+ execute: async (e) => {
336
+ let t = await w(i, j(e, n));
337
+ return a?.(), t;
338
+ }
339
+ });
340
+ }, [
341
+ g,
342
+ r,
343
+ n,
344
+ a
345
+ ]);
346
+ return !o && v.length === 0 ? null : /* @__PURE__ */ Q("div", {
347
+ className: "sl-row-actions",
348
+ "data-open": f ? "true" : void 0,
349
+ style: {
350
+ display: "flex",
351
+ alignItems: "center",
352
+ justifyContent: "flex-end"
353
+ },
354
+ children: [/* @__PURE__ */ Z(D, {
355
+ ref: d,
356
+ size: l,
357
+ icon: /* @__PURE__ */ Z(e.more, { size: Math.round(l * .55) }),
358
+ onClick: () => p((e) => !e),
359
+ title: "Actions"
360
+ }), /* @__PURE__ */ Q(T, {
361
+ open: f,
362
+ anchor: d.current,
363
+ onClose: () => p(!1),
364
+ width: 200,
365
+ align: u,
366
+ children: [
367
+ o,
368
+ o && s && v.length > 0 && /* @__PURE__ */ Z(O, { divider: !0 }),
369
+ /* @__PURE__ */ Z(ae, {
370
+ layout: v,
371
+ entityActions: _,
372
+ onRun: y,
373
+ loading: m,
374
+ onLoadingChange: h,
375
+ row: r
376
+ })
377
+ ]
378
+ })]
379
+ });
380
+ }
381
+ //#endregion
382
+ //#region src/components/detail-layout/AssociatedToolbar.tsx
383
+ function we({ entity: t, searchable: n, filterFields: r, searchValue: i, onSearchChange: a, filters: o, onFilterChange: s, allEntities: l }) {
384
+ let u = n === !0, d = r && r.length > 0;
385
+ return !u && !d ? null : /* @__PURE__ */ Q("div", {
386
+ style: {
387
+ display: "flex",
388
+ alignItems: "center",
389
+ gap: 6,
390
+ marginBottom: 8
391
+ },
392
+ children: [u && /* @__PURE__ */ Z("div", {
393
+ style: {
394
+ flex: 1,
395
+ maxWidth: 220
396
+ },
397
+ children: /* @__PURE__ */ Z(b, {
398
+ value: i,
399
+ onChange: a,
400
+ placeholder: "Search…",
401
+ prefix: /* @__PURE__ */ Z(e.search, { size: 12 })
402
+ })
403
+ }), d && r.map((e) => {
404
+ let n = t.fields.get(e);
405
+ if (!n) return null;
406
+ let r = o[e] ?? "__all__", i = z(n, e, l);
407
+ if (n.type === "ref" && n.ref?.entity) return /* @__PURE__ */ Z(Te, {
408
+ field: n,
409
+ label: i,
410
+ value: r,
411
+ onChange: (t) => s(e, t)
412
+ }, e);
413
+ if (!n.values) return null;
414
+ let a = [{
415
+ value: "__all__",
416
+ label: `All ${i}`
417
+ }, ...n.values.map((e) => ({
418
+ value: e.code,
419
+ label: c(e.name) || e.code
420
+ }))];
421
+ return /* @__PURE__ */ Z("div", {
422
+ style: { width: 160 },
423
+ children: /* @__PURE__ */ Z(f, {
424
+ value: r,
425
+ options: a,
426
+ onChange: (t) => s(e, t),
427
+ placeholder: i
428
+ })
429
+ }, e);
430
+ })]
431
+ });
432
+ }
433
+ function Te({ field: e, label: t, value: n, onChange: r }) {
434
+ let i = p(e.ref?.entity), a = e.display?.ref_display_field ?? i?.display?.display_field, o = q(() => i ? [...i.fields].find(([, e]) => e.primary)?.[0] ?? "id" : "id", [i]), { data: s } = y(e.ref?.entity, {
435
+ per_page: 200,
436
+ sort: a ? `${a}:asc` : void 0
437
+ }), c = s?.data ?? [], l = (e) => {
438
+ if (e == null) return "—";
439
+ if (typeof e == "object" && !Array.isArray(e)) {
440
+ let t = Object.values(e)[0];
441
+ return t == null ? "—" : H(t);
442
+ }
443
+ return H(e);
444
+ }, u = [{
445
+ value: "__all__",
446
+ label: `All ${t}`
447
+ }, ...c.map((e) => {
448
+ let t = String(e[o]), n = e[A];
449
+ return {
450
+ value: t,
451
+ label: typeof n == "string" && n !== "" ? n : a ? l(e[a] ?? t) : t
452
+ };
453
+ })];
454
+ return /* @__PURE__ */ Z("div", {
455
+ style: { width: 160 },
456
+ children: /* @__PURE__ */ Z(f, {
457
+ value: n,
458
+ options: u,
459
+ onChange: r,
460
+ placeholder: t
461
+ })
462
+ });
463
+ }
464
+ //#endregion
465
+ //#region src/components/detail-layout/AssociatedBlock.tsx
466
+ function Ee(e) {
467
+ if (!e) return [];
468
+ let t = [];
469
+ for (let [n, r] of Object.entries(e)) (r.visibility ?? []).includes("list_row") && (r.association || l(n) || t.push({
470
+ code: n,
471
+ action: r
472
+ }));
473
+ return t;
474
+ }
475
+ function De(e, t, n) {
476
+ if (!e) return [];
477
+ let r = [];
478
+ for (let [i, o] of Object.entries(e)) {
479
+ if (!(o.visibility ?? []).includes("list_toolbar") || o.association || i.startsWith("__")) continue;
480
+ let e = {
481
+ ...o,
482
+ resolved_hidden_defaults: {
483
+ ...o.resolved_hidden_defaults ?? {},
484
+ [t]: n
485
+ }
486
+ };
487
+ if (o.resolved_params?.has(t)) {
488
+ let n = o.resolved_params.items().filter((e) => e.name !== t);
489
+ e = {
490
+ ...e,
491
+ resolved_params: new a(n)
492
+ };
493
+ }
494
+ r.push({
495
+ code: i,
496
+ action: e
497
+ });
498
+ }
499
+ return r;
500
+ }
501
+ function Oe(e, t, n) {
502
+ let r = e[n];
503
+ if (!r) return null;
504
+ let i = e[t], a = i?.children?.find((e) => e.entity === n);
505
+ if (a) {
506
+ let e = a.foreign_key;
507
+ if (typeof e == "string") return e;
508
+ if (Array.isArray(e) && e.length === 1) return e[0];
509
+ }
510
+ let o = i?.table;
511
+ for (let [n, i] of r.fields) {
512
+ let r = i.ref?.entity;
513
+ if (r) {
514
+ if (r === t) return n;
515
+ if (o) {
516
+ let t = e[r]?.table;
517
+ if (t && t === o) return n;
518
+ }
519
+ }
520
+ }
521
+ return null;
522
+ }
523
+ function ke(e, t, n) {
524
+ let r = new Set(u(e));
525
+ return new Set(t.filter((t) => {
526
+ if (t === n || r.has(t)) return !1;
527
+ let i = e.fields.get(t);
528
+ return !(!i || i.auto || i.primary || i.source);
529
+ }));
530
+ }
531
+ function Ae(e, t, n) {
532
+ return new Set(t.filter((t) => {
533
+ if (t === n) return !1;
534
+ let r = e.fields.get(t);
535
+ return !(!r || r.auto);
536
+ }));
537
+ }
538
+ function je(e, t, n, r) {
539
+ let i = [];
540
+ for (let a of t) {
541
+ let t = n.fields.get(a);
542
+ if (!t || !t.required || t.auto || t.primary || a === r || n.tenant_key && a === n.tenant_key) continue;
543
+ let o = e[a];
544
+ (o == null || o === "") && i.push(a);
545
+ }
546
+ return i;
547
+ }
548
+ function Me({ node: e, ctx: t }) {
549
+ let n = e.associated;
550
+ if (!n || t.isNew) return null;
551
+ let r = t.schema.entities[n];
552
+ if (!r) return /* @__PURE__ */ Q("div", {
553
+ style: {
554
+ fontSize: 12.5,
555
+ color: "var(--text-3)",
556
+ padding: "8px 0"
557
+ },
558
+ children: ["Entity not found: ", n]
559
+ });
560
+ let i = Oe(t.schema.entities, t.entityCode, n);
561
+ return i ? /* @__PURE__ */ Z(Ne, {
562
+ node: e,
563
+ ctx: t,
564
+ assocCode: n,
565
+ assocEntity: r,
566
+ fkField: i
567
+ }) : /* @__PURE__ */ Q("div", {
568
+ style: {
569
+ fontSize: 12.5,
570
+ color: "var(--text-3)",
571
+ padding: "8px 0"
572
+ },
573
+ children: [
574
+ "No FK found for ",
575
+ n,
576
+ " → ",
577
+ t.entityCode
578
+ ]
579
+ });
580
+ }
581
+ function Ne({ node: n, ctx: i, assocCode: a, assocEntity: o, fkField: s }) {
582
+ let l = n.columns && n.columns.length > 0 ? n.columns.filter((e) => e !== s && !!o.fields.get(e)) : o.fields.names().filter((e) => {
583
+ if (e === s) return !1;
584
+ let t = o.fields.get(e);
585
+ return !(!t || t.primary || t.display?.is_listable === !1);
586
+ }), u = g(o, "update"), d = n.interaction ?? (u ? "navigate" : "readonly"), f = (d === "inline_edit" || d === "row_edit") && u && n.editable !== !1, p = c(o.display?.name_plural) || c(o.display?.name) || a, m = n.searchable === !0 || n.filters && n.filters.length > 0, h = q(() => De(o.actions, s, i.recordId), [
587
+ o.actions,
588
+ s,
589
+ i.recordId
590
+ ]), _ = q(() => {
591
+ let e = {};
592
+ for (let { code: t, action: n } of h) e[t] = n;
593
+ return e;
594
+ }, [h]), v = q(() => {
595
+ let e = o.action_layout ?? null;
596
+ return x(e ?? R(_, "list_toolbar"), _, void 0, {}, []);
597
+ }, [o.action_layout, _]), { run: y } = M(), b = re(), S = r(), C = q(() => ({
598
+ entity: o,
599
+ entityCode: a,
600
+ screenRoute: typeof window < "u" ? window.location.pathname : "",
601
+ selectedRows: [],
602
+ selectedIds: [],
603
+ locale: S,
604
+ tabNavigate: (e, t) => b(e, {
605
+ title: t?.title,
606
+ icon: t?.icon,
607
+ search: t?.search
608
+ }),
609
+ runActionApi: (e, t) => w(e, t)
610
+ }), [
611
+ o,
612
+ a,
613
+ S,
614
+ b
615
+ ]), T = X(), E = G(() => {
616
+ T.invalidateQueries({ predicate: (e) => {
617
+ let t = e.queryKey;
618
+ return t[0] === "entity-children" && t[3] === a;
619
+ } });
620
+ }, [T, a]), D = G((e, t) => {
621
+ let n = se(e, t, {}, a);
622
+ if (n !== null) return y({
623
+ action: t,
624
+ title: c(t.display?.name) || e,
625
+ execute: async (e) => {
626
+ let t = await w(n, j(e, void 0));
627
+ return E(), t;
628
+ }
629
+ });
630
+ }, [
631
+ y,
632
+ a,
633
+ E
634
+ ]), [O, A] = Y(0), N = /* @__PURE__ */ Q("div", {
635
+ style: {
636
+ display: "flex",
637
+ alignItems: "center",
638
+ gap: 6,
639
+ flex: "1 1 auto",
640
+ minWidth: 0,
641
+ justifyContent: "flex-end"
642
+ },
643
+ children: [o.action_layout ? v.length > 0 && /* @__PURE__ */ Z(ie, {
644
+ kind: "toolbar",
645
+ layout: v,
646
+ entityActions: _,
647
+ onRun: D,
648
+ widgetContext: C,
649
+ ariaLabel: `${p} toolbar actions`
650
+ }) : h.map(({ code: e, action: t }) => /* @__PURE__ */ Z(Se, {
651
+ actionCode: e,
652
+ action: t,
653
+ entityCode: a,
654
+ variant: "ghost",
655
+ size: "sm",
656
+ onSuccess: E
657
+ }, e)), f && /* @__PURE__ */ Z(k, {
658
+ kind: "ghost",
659
+ size: "xs",
660
+ icon: /* @__PURE__ */ Z(e.plus, { size: 12 }),
661
+ onClick: () => A((e) => e + 1),
662
+ children: "Add row"
663
+ })]
664
+ }), P = m ? /* @__PURE__ */ Z(Fe, {
665
+ entityCode: a,
666
+ entity: o,
667
+ parentEntity: i.entityCode,
668
+ parentId: i.recordId,
669
+ foreignKey: s,
670
+ columns: l,
671
+ editable: f,
672
+ interaction: d,
673
+ ctx: i,
674
+ searchable: n.searchable,
675
+ filterFields: n.filters,
676
+ sort: n.sort,
677
+ startDraftSignal: O
678
+ }) : /* @__PURE__ */ Z(Pe, {
679
+ entityCode: a,
680
+ entity: o,
681
+ parentEntity: i.entityCode,
682
+ parentId: i.recordId,
683
+ foreignKey: s,
684
+ columns: l,
685
+ editable: f,
686
+ interaction: d,
687
+ ctx: i,
688
+ sort: n.sort,
689
+ startDraftSignal: O
690
+ });
691
+ return i.withinCard ? /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z("div", {
692
+ style: {
693
+ display: "flex",
694
+ justifyContent: "flex-end",
695
+ marginBottom: 8
696
+ },
697
+ children: N
698
+ }), P] }) : /* @__PURE__ */ Z(_e, {
699
+ title: p,
700
+ icon: o.display?.icon ? /* @__PURE__ */ Z(t, {
701
+ name: o.display.icon,
702
+ size: 14
703
+ }) : void 0,
704
+ right: N,
705
+ children: P
706
+ });
707
+ }
708
+ function Pe({ entityCode: e, entity: t, parentEntity: n, parentId: r, foreignKey: i, columns: a, editable: o, interaction: s, ctx: c, sort: l, startDraftSignal: u }) {
709
+ let d = X(), { data: f, isLoading: p, isError: m } = ne(n, r, e, i, l), h = f?.data ?? [], g = f?.$refs, _ = G(() => {
710
+ d.invalidateQueries({ queryKey: [
711
+ U,
712
+ n,
713
+ r,
714
+ e
715
+ ] });
716
+ }, [
717
+ d,
718
+ n,
719
+ r,
720
+ e
721
+ ]);
722
+ return /* @__PURE__ */ Z(Ie, {
723
+ entityCode: e,
724
+ entity: t,
725
+ parentId: r,
726
+ foreignKey: i,
727
+ columns: a,
728
+ editable: o,
729
+ interaction: s,
730
+ ctx: c,
731
+ rows: h,
732
+ refs: g,
733
+ isLoading: p,
734
+ isError: m,
735
+ invalidateQuery: _,
736
+ startDraftSignal: u
737
+ });
738
+ }
739
+ function Fe({ entityCode: e, entity: t, parentEntity: r, parentId: i, foreignKey: a, columns: o, editable: s, interaction: c, ctx: l, searchable: u, filterFields: d, sort: f, startDraftSignal: p }) {
740
+ let m = X(), [h, g] = Y(""), [_, v] = Y(""), [y, b] = Y({}), x = J(void 0);
741
+ de(() => (x.current && clearTimeout(x.current), x.current = setTimeout(() => {
742
+ v(h);
743
+ }, 300), () => {
744
+ x.current && clearTimeout(x.current);
745
+ }), [h]);
746
+ let S = G((e, t) => {
747
+ b((n) => {
748
+ if (t === "__all__") {
749
+ let { [e]: t, ...r } = n;
750
+ return r;
751
+ }
752
+ return {
753
+ ...n,
754
+ [e]: t
755
+ };
756
+ });
757
+ }, []), C = q(() => Object.keys(y).length > 0 ? y : void 0, [y]), { data: w, isLoading: T, isError: E, hasNextPage: D, fetchNextPage: O, isFetchingNextPage: A } = xe(r, i, e, a, f, void 0, _ || void 0, C), { rows: j, refs: M } = q(() => {
758
+ if (!w?.pages) return {
759
+ rows: [],
760
+ refs: void 0
761
+ };
762
+ let e = [], t;
763
+ for (let n of w.pages) if (e.push(...n.data), n.$refs) {
764
+ if (!t) t = { ...n.$refs };
765
+ else for (let [e, r] of Object.entries(n.$refs)) t[e] = {
766
+ ...t[e],
767
+ ...r
768
+ };
769
+ }
770
+ return {
771
+ rows: e,
772
+ refs: t
773
+ };
774
+ }, [w]), N = G(() => {
775
+ m.invalidateQueries({ predicate: (t) => {
776
+ let n = t.queryKey;
777
+ return n[0] === "entity-children" && n[3] === e;
778
+ } });
779
+ }, [m, e]);
780
+ return /* @__PURE__ */ Q("div", { children: [
781
+ /* @__PURE__ */ Z(we, {
782
+ entity: t,
783
+ searchable: u,
784
+ filterFields: d,
785
+ searchValue: h,
786
+ onSearchChange: g,
787
+ filters: y,
788
+ onFilterChange: S,
789
+ allEntities: l.schema.entities
790
+ }),
791
+ /* @__PURE__ */ Z(Ie, {
792
+ entityCode: e,
793
+ entity: t,
794
+ parentId: i,
795
+ foreignKey: a,
796
+ columns: o,
797
+ editable: s,
798
+ interaction: c,
799
+ ctx: l,
800
+ rows: j,
801
+ refs: M,
802
+ isLoading: T,
803
+ isError: E,
804
+ invalidateQuery: N,
805
+ startDraftSignal: p
806
+ }),
807
+ D && /* @__PURE__ */ Z("div", {
808
+ style: { marginTop: 4 },
809
+ children: /* @__PURE__ */ Z(k, {
810
+ kind: "ghost",
811
+ size: "xs",
812
+ icon: A ? /* @__PURE__ */ Z(n, { size: 12 }) : void 0,
813
+ onClick: () => O(),
814
+ disabled: A,
815
+ children: "Load more"
816
+ })
817
+ })
818
+ ] });
819
+ }
820
+ function Ie({ entityCode: e, entity: t, parentId: n, foreignKey: r, columns: i, editable: a, interaction: o, ctx: l, rows: u, refs: d, isLoading: f, isError: p, invalidateQuery: h, startDraftSignal: g }) {
821
+ let _ = ee(), v = _.isPhone && l.relatedRecordsPresentation === "table", y = i.find((e) => e !== r), b = q(() => o === "navigate" ? m(void 0, t, l.schema.screens) : null, [
822
+ o,
823
+ t,
824
+ l.schema.screens
825
+ ]), x = q(() => a ? ke(t, i, r) : /* @__PURE__ */ new Set(), [
826
+ i,
827
+ r,
828
+ t,
829
+ a
830
+ ]), C = q(() => Ae(t, i, r), [
831
+ i,
832
+ r,
833
+ t
834
+ ]), w = q(() => {
835
+ let e = /* @__PURE__ */ new Map();
836
+ for (let n of u) {
837
+ let r = s(t, n);
838
+ e.set(V(r), r);
839
+ }
840
+ return e;
841
+ }, [u, t]), T = q(() => {
842
+ let e = /* @__PURE__ */ new Map();
843
+ for (let n of u) {
844
+ let r = n.$row_version;
845
+ typeof r == "string" && r !== "" && e.set(V(s(t, n)), r);
846
+ }
847
+ return e;
848
+ }, [u, t]), E = q(() => Ee(t.actions), [t.actions]), [D, O] = Y(null), [k, A] = Y(null), [j, N] = Y([]), [F, I] = Y({}), L = J(F);
849
+ L.current = F;
850
+ let R = J({});
851
+ de(() => {
852
+ let e = R.current;
853
+ return () => {
854
+ for (let t of Object.values(e)) clearTimeout(t);
855
+ };
856
+ }, []);
857
+ let [B, H] = Y(null), [ne, U] = Y([]), [re, ie] = Y(!1), { run: ae } = M(), [oe, se] = Y(/* @__PURE__ */ new Set()), W = G(async (t, n, r) => {
858
+ I((e) => ({
859
+ ...e,
860
+ [t]: {
861
+ ...e[t],
862
+ saving: !0,
863
+ error: void 0
864
+ }
865
+ }));
866
+ try {
867
+ let i = T.get(t), a = i ? {
868
+ ...n,
869
+ $row_version: i
870
+ } : n;
871
+ return await P(e, w.get(t) ?? t, a), I((e) => {
872
+ let n = e[t];
873
+ if (!n) return e;
874
+ if (n.ver > r) return {
875
+ ...e,
876
+ [t]: {
877
+ ...n,
878
+ saving: !1
879
+ }
880
+ };
881
+ let { [t]: i, ...a } = e;
882
+ return a;
883
+ }), h(), !0;
884
+ } catch (e) {
885
+ let n = e instanceof Error ? e.message : "Save failed";
886
+ return I((e) => ({
887
+ ...e,
888
+ [t]: {
889
+ ...e[t],
890
+ saving: !1,
891
+ error: n
892
+ }
893
+ })), !1;
894
+ }
895
+ }, [
896
+ e,
897
+ h,
898
+ w,
899
+ T
900
+ ]), ue = G((e, t, n) => {
901
+ I((r) => {
902
+ let i = r[e] ?? {
903
+ buffer: {},
904
+ ver: 0,
905
+ saving: !1
906
+ }, a = i.ver + 1;
907
+ return {
908
+ ...r,
909
+ [e]: {
910
+ ...i,
911
+ buffer: {
912
+ ...i.buffer,
913
+ [t]: n
914
+ },
915
+ ver: a
916
+ }
917
+ };
918
+ }), o === "inline_edit" && (R.current[e] && clearTimeout(R.current[e]), R.current[e] = setTimeout(() => {
919
+ let t = L.current[e];
920
+ t && Object.keys(t.buffer).length > 0 && W(e, { ...t.buffer }, t.ver);
921
+ }, 500));
922
+ }, [W, o]), K = G(() => {
923
+ let e = {};
924
+ e[r] = n;
925
+ for (let n of i) {
926
+ let r = t.fields.get(n);
927
+ r && (r.default === void 0 ? r.type === "bool" && (e[n] = !1) : e[n] = r.default);
928
+ }
929
+ H(e), U([]);
930
+ }, [
931
+ r,
932
+ n,
933
+ i,
934
+ t.fields
935
+ ]), fe = J(g);
936
+ de(() => {
937
+ g !== void 0 && g !== fe.current && (fe.current = g, !B && K());
938
+ }, [
939
+ g,
940
+ B,
941
+ K
942
+ ]);
943
+ let pe = G(async () => {
944
+ if (!B) return;
945
+ let n = je(B, i, t, r);
946
+ if (n.length > 0) {
947
+ U(n);
948
+ return;
949
+ }
950
+ ie(!0);
951
+ try {
952
+ await S(e, B), H(null), U([]), h();
953
+ } catch (e) {
954
+ let t = e instanceof Error ? e.message : "Create failed";
955
+ U([`_error:${t}`]);
956
+ } finally {
957
+ ie(!1);
958
+ }
959
+ }, [
960
+ B,
961
+ i,
962
+ t,
963
+ r,
964
+ e,
965
+ h
966
+ ]), X = G((e) => {
967
+ I({}), N([]), A(e);
968
+ }, []), me = G(async (e) => {
969
+ let n = L.current[e], a = n?.buffer ?? {};
970
+ if (Object.keys(a).length === 0) {
971
+ A(null), N([]);
972
+ return;
973
+ }
974
+ let o = je({
975
+ ...u.find((n) => V(s(t, n)) === e) ?? {},
976
+ ...a
977
+ }, i, t, r);
978
+ if (o.length > 0) {
979
+ N(o);
980
+ return;
981
+ }
982
+ await W(e, { ...a }, n?.ver ?? 0) && (A(null), N([]));
983
+ }, [
984
+ u,
985
+ t,
986
+ i,
987
+ r,
988
+ W
989
+ ]), he = G((e) => {
990
+ I((t) => {
991
+ if (!t[e]) return t;
992
+ let { [e]: n, ...r } = t;
993
+ return r;
994
+ }), N([]), A(null);
995
+ }, []), ge = G((n, r) => {
996
+ let i = w.get(n) ?? n;
997
+ return ae({
998
+ action: t.actions?.__delete,
999
+ destructive: !0,
1000
+ title: c(t.display?.name) || "Delete",
1001
+ row: r,
1002
+ entity: e,
1003
+ execute: async () => {
1004
+ se((e) => new Set(e).add(n));
1005
+ try {
1006
+ return await te(e, i);
1007
+ } finally {
1008
+ se((e) => {
1009
+ let t = new Set(e);
1010
+ return t.delete(n), t;
1011
+ });
1012
+ }
1013
+ },
1014
+ onSuccess: () => h()
1015
+ });
1016
+ }, [
1017
+ ae,
1018
+ t,
1019
+ e,
1020
+ h,
1021
+ w
1022
+ ]);
1023
+ if (p) return /* @__PURE__ */ Z("div", {
1024
+ style: {
1025
+ fontSize: 12.5,
1026
+ color: "var(--danger)",
1027
+ padding: "8px 0"
1028
+ },
1029
+ children: "Failed to load."
1030
+ });
1031
+ if (f) return /* @__PURE__ */ Q("div", {
1032
+ style: {
1033
+ display: "flex",
1034
+ flexDirection: "column",
1035
+ gap: 8,
1036
+ padding: "8px 0"
1037
+ },
1038
+ children: [/* @__PURE__ */ Z("div", { style: {
1039
+ height: 32,
1040
+ background: "var(--surface-3)",
1041
+ borderRadius: 6
1042
+ } }), /* @__PURE__ */ Z("div", { style: {
1043
+ height: 32,
1044
+ background: "var(--surface-3)",
1045
+ borderRadius: 6
1046
+ } })]
1047
+ });
1048
+ let $ = u.length === 0 && !B;
1049
+ return _.isPhone && !v ? /* @__PURE__ */ Q("div", { children: [$ && !a && /* @__PURE__ */ Z("div", {
1050
+ style: {
1051
+ fontSize: 12.5,
1052
+ color: "var(--text-3)",
1053
+ padding: "12px 0"
1054
+ },
1055
+ children: "No records yet."
1056
+ }), (!$ || a) && /* @__PURE__ */ Q("div", {
1057
+ style: {
1058
+ display: "flex",
1059
+ flexDirection: "column",
1060
+ gap: 10
1061
+ },
1062
+ children: [u.map((n) => {
1063
+ let r = V(s(t, n)), c = oe.has(r), u = F[r], f = b && r ? b.replace(/:\w+/, r) : void 0;
1064
+ return /* @__PURE__ */ Z(Le, {
1065
+ rowId: r,
1066
+ row: n,
1067
+ entity: t,
1068
+ entities: l.schema.entities,
1069
+ screens: l.schema.screens,
1070
+ columns: i,
1071
+ editableColumns: x,
1072
+ editable: a,
1073
+ interaction: o,
1074
+ isEditing: k === r,
1075
+ editErrors: j,
1076
+ isDeleting: c,
1077
+ activeCell: D,
1078
+ setActiveCell: O,
1079
+ rowState: u,
1080
+ onCellChange: ue,
1081
+ onDeleteClick: (e) => void ge(e, n),
1082
+ onStartEdit: X,
1083
+ onConfirmEdit: me,
1084
+ onCancelEdit: he,
1085
+ refs: d,
1086
+ identityCol: y,
1087
+ href: f,
1088
+ rowActions: E,
1089
+ entityCode: e,
1090
+ onRowActionSuccess: h
1091
+ }, r);
1092
+ }), B && /* @__PURE__ */ Z(He, {
1093
+ draftRow: B,
1094
+ entity: t,
1095
+ columns: i,
1096
+ editableColumns: C,
1097
+ foreignKey: r,
1098
+ draftErrors: ne,
1099
+ draftSaving: re,
1100
+ onChange: (e, t) => H((n) => n && {
1101
+ ...n,
1102
+ [e]: t
1103
+ }),
1104
+ onConfirm: pe,
1105
+ onCancel: () => {
1106
+ H(null), U([]);
1107
+ },
1108
+ refs: d
1109
+ })]
1110
+ })] }) : /* @__PURE__ */ Q("div", { children: [$ && !a && /* @__PURE__ */ Z("div", {
1111
+ style: {
1112
+ fontSize: 12.5,
1113
+ color: "var(--text-3)",
1114
+ padding: "12px 0"
1115
+ },
1116
+ children: "No records yet."
1117
+ }), (!$ || a) && /* @__PURE__ */ Z("div", {
1118
+ style: { overflowX: "auto" },
1119
+ children: /* @__PURE__ */ Q("table", {
1120
+ style: le,
1121
+ children: [/* @__PURE__ */ Z("thead", { children: /* @__PURE__ */ Q("tr", { children: [
1122
+ i.map((e) => {
1123
+ let n = t.fields.get(e);
1124
+ return /* @__PURE__ */ Z("th", {
1125
+ style: ce,
1126
+ children: n ? z(n, e, l.schema.entities) : e
1127
+ }, e);
1128
+ }),
1129
+ a && /* @__PURE__ */ Z("th", { style: {
1130
+ height: 30,
1131
+ width: 72
1132
+ } }),
1133
+ !a && E.length > 0 && /* @__PURE__ */ Z("th", { style: {
1134
+ height: 30,
1135
+ width: 40
1136
+ } })
1137
+ ] }) }), /* @__PURE__ */ Q("tbody", { children: [u.map((n) => {
1138
+ let r = V(s(t, n)), c = oe.has(r), u = F[r], f = b && r ? b.replace(/:\w+/, r) : void 0;
1139
+ return /* @__PURE__ */ Z(Re, {
1140
+ rowId: r,
1141
+ row: n,
1142
+ entity: t,
1143
+ entities: l.schema.entities,
1144
+ screens: l.schema.screens,
1145
+ columns: i,
1146
+ editableColumns: x,
1147
+ editable: a,
1148
+ interaction: o,
1149
+ isEditing: k === r,
1150
+ editErrors: j,
1151
+ isDeleting: c,
1152
+ activeCell: D,
1153
+ setActiveCell: O,
1154
+ rowState: u,
1155
+ onCellChange: ue,
1156
+ onDeleteClick: (e) => void ge(e, n),
1157
+ onStartEdit: X,
1158
+ onConfirmEdit: me,
1159
+ onCancelEdit: he,
1160
+ refs: d,
1161
+ identityCol: y,
1162
+ href: f,
1163
+ rowActions: E,
1164
+ entityCode: e,
1165
+ onRowActionSuccess: h
1166
+ }, r);
1167
+ }), B && /* @__PURE__ */ Z(Ve, {
1168
+ draftRow: B,
1169
+ entity: t,
1170
+ columns: i,
1171
+ editableColumns: C,
1172
+ foreignKey: r,
1173
+ draftErrors: ne,
1174
+ draftSaving: re,
1175
+ onChange: (e, t) => H((n) => n && {
1176
+ ...n,
1177
+ [e]: t
1178
+ }),
1179
+ onConfirm: pe,
1180
+ onCancel: () => {
1181
+ H(null), U([]);
1182
+ },
1183
+ refs: d
1184
+ })] })]
1185
+ })
1186
+ })] });
1187
+ }
1188
+ function Le({ rowId: t, row: i, entity: a, entities: o, screens: s, columns: c, editableColumns: l, editable: u, interaction: d, isEditing: f, editErrors: p, isDeleting: m, rowState: h, onCellChange: g, onDeleteClick: _, onStartEdit: v, onConfirmEdit: y, onCancelEdit: b, refs: x, identityCol: S, href: C, rowActions: w, onRowActionSuccess: T }) {
1189
+ let E = r(), O = K(), k = q(() => !h || Object.keys(h.buffer).length === 0 ? i : {
1190
+ ...i,
1191
+ ...h.buffer
1192
+ }, [i, h]);
1193
+ if (d === "row_edit" && f) {
1194
+ let e = h?.error ? [...p, `_error:${h.error}`] : p;
1195
+ return /* @__PURE__ */ Z(Be, {
1196
+ values: k,
1197
+ entity: a,
1198
+ columns: c,
1199
+ editableColumns: l,
1200
+ errors: e,
1201
+ saving: h?.saving ?? !1,
1202
+ onChange: (e, n) => g(t, e, n),
1203
+ onConfirm: () => y(t),
1204
+ onCancel: () => b(t),
1205
+ refs: x
1206
+ });
1207
+ }
1208
+ return /* @__PURE__ */ Q("div", {
1209
+ style: {
1210
+ border: "1px solid var(--border)",
1211
+ borderRadius: 8,
1212
+ background: "var(--surface)",
1213
+ opacity: m ? .58 : 1,
1214
+ overflow: "hidden"
1215
+ },
1216
+ children: [/* @__PURE__ */ Z("div", {
1217
+ style: {
1218
+ padding: 10,
1219
+ display: "flex",
1220
+ flexDirection: "column",
1221
+ gap: 12
1222
+ },
1223
+ children: c.map((e) => {
1224
+ let n = a.fields.get(e), r = u && d === "inline_edit" && l.has(e), i = C && e === S, c = n ? z(n, e, o) : e, f = `${O}-${t}-${e}`, p = `${f}-label`, m = {
1225
+ fontSize: 11.5,
1226
+ fontWeight: 600,
1227
+ color: "var(--text-3)"
1228
+ }, h = n ? N({
1229
+ field: n,
1230
+ fieldName: e,
1231
+ value: k[e],
1232
+ mode: r ? "edit" : "display",
1233
+ onChange: r ? (n) => g(t, e, n) : void 0,
1234
+ record: k,
1235
+ refs: x,
1236
+ compact: r,
1237
+ entity: a,
1238
+ entities: o,
1239
+ screens: i ? void 0 : s,
1240
+ fieldId: f,
1241
+ labelId: p,
1242
+ locale: E
1243
+ }) : H(k[e]);
1244
+ return /* @__PURE__ */ Q("div", {
1245
+ style: {
1246
+ display: "flex",
1247
+ flexDirection: "column",
1248
+ gap: 5,
1249
+ minWidth: 0
1250
+ },
1251
+ children: [r && n ? /* @__PURE__ */ Z("label", {
1252
+ id: p,
1253
+ htmlFor: f,
1254
+ style: m,
1255
+ children: c
1256
+ }) : /* @__PURE__ */ Z("div", {
1257
+ id: p,
1258
+ style: m,
1259
+ children: c
1260
+ }), /* @__PURE__ */ Z("div", {
1261
+ style: { minWidth: 0 },
1262
+ children: i && !r ? /* @__PURE__ */ Z("a", {
1263
+ href: C,
1264
+ style: {
1265
+ color: "var(--accent)",
1266
+ textDecoration: "none",
1267
+ fontWeight: 500
1268
+ },
1269
+ children: h
1270
+ }) : h
1271
+ })]
1272
+ }, e);
1273
+ })
1274
+ }), (u || w && w.length > 0) && /* @__PURE__ */ Q("div", {
1275
+ style: {
1276
+ minHeight: 42,
1277
+ padding: "6px 8px",
1278
+ borderTop: "1px solid var(--divider)",
1279
+ display: "flex",
1280
+ alignItems: "center",
1281
+ justifyContent: "flex-end",
1282
+ gap: 6
1283
+ },
1284
+ children: [u && /* @__PURE__ */ Q(me, { children: [
1285
+ h?.saving && /* @__PURE__ */ Z(n, { size: 12 }),
1286
+ h?.error && /* @__PURE__ */ Z("span", {
1287
+ style: {
1288
+ fontSize: 11,
1289
+ color: "var(--danger)"
1290
+ },
1291
+ title: h.error,
1292
+ children: "!"
1293
+ }),
1294
+ d === "row_edit" && /* @__PURE__ */ Z(D, {
1295
+ size: 32,
1296
+ icon: /* @__PURE__ */ Z(e.edit, { size: 14 }),
1297
+ onClick: () => v(t),
1298
+ title: "Edit row"
1299
+ }),
1300
+ /* @__PURE__ */ Z(D, {
1301
+ size: 32,
1302
+ icon: /* @__PURE__ */ Z(e.trash, { size: 14 }),
1303
+ onClick: () => _(t),
1304
+ title: "Delete row"
1305
+ })
1306
+ ] }), !u && w && w.length > 0 && /* @__PURE__ */ Z(Ce, {
1307
+ entity: a,
1308
+ actions: w,
1309
+ objectIds: [t],
1310
+ row: k,
1311
+ onSuccess: T
1312
+ })]
1313
+ })]
1314
+ });
1315
+ }
1316
+ function Re({ rowId: t, row: i, entity: a, entities: o, screens: s, columns: c, editableColumns: l, editable: u, interaction: d, isEditing: f, editErrors: p, isDeleting: m, activeCell: h, setActiveCell: g, rowState: _, onCellChange: v, onDeleteClick: y, onStartEdit: b, onConfirmEdit: x, onCancelEdit: S, refs: C, identityCol: w, href: T, rowActions: E, onRowActionSuccess: O }) {
1317
+ let k = r(), A = q(() => !_ || Object.keys(_.buffer).length === 0 ? i : {
1318
+ ...i,
1319
+ ..._.buffer
1320
+ }, [i, _]);
1321
+ if (d === "row_edit" && f) {
1322
+ let e = _?.error ? [...p, `_error:${_.error}`] : p;
1323
+ return /* @__PURE__ */ Z(ze, {
1324
+ values: A,
1325
+ entity: a,
1326
+ columns: c,
1327
+ editableColumns: l,
1328
+ errors: e,
1329
+ saving: _?.saving ?? !1,
1330
+ onChange: (e, n) => v(t, e, n),
1331
+ onConfirm: () => x(t),
1332
+ onCancel: () => S(t),
1333
+ refs: C
1334
+ });
1335
+ }
1336
+ let j = W, M = {
1337
+ padding: "4px 4px",
1338
+ borderBottom: "1px solid var(--divider)",
1339
+ verticalAlign: "middle"
1340
+ }, P = d === "inline_edit";
1341
+ return /* @__PURE__ */ Q("tr", {
1342
+ style: { opacity: m ? .5 : 1 },
1343
+ children: [
1344
+ c.map((e) => {
1345
+ let n = a.fields.get(e), r = l.has(e);
1346
+ if (P && h?.rowId === t && h?.col === e && r) return /* @__PURE__ */ Z("td", {
1347
+ style: M,
1348
+ children: n ? N({
1349
+ field: n,
1350
+ fieldName: e,
1351
+ value: A[e],
1352
+ mode: "edit",
1353
+ onChange: (n) => v(t, e, n),
1354
+ record: A,
1355
+ refs: C,
1356
+ compact: !0,
1357
+ locale: k
1358
+ }) : H(A[e])
1359
+ }, e);
1360
+ let i = T && e === w, c = n ? N({
1361
+ field: n,
1362
+ fieldName: e,
1363
+ value: A[e],
1364
+ mode: "display",
1365
+ record: A,
1366
+ refs: C,
1367
+ entity: a,
1368
+ entities: o,
1369
+ screens: i ? void 0 : s,
1370
+ locale: k
1371
+ }) : H(A[e]), u = P && r && !m;
1372
+ return /* @__PURE__ */ Z("td", {
1373
+ style: {
1374
+ ...j,
1375
+ cursor: u ? "pointer" : "default"
1376
+ },
1377
+ onClick: u ? () => g({
1378
+ rowId: t,
1379
+ col: e
1380
+ }) : void 0,
1381
+ children: i ? /* @__PURE__ */ Z("a", {
1382
+ href: T,
1383
+ style: {
1384
+ color: "var(--accent)",
1385
+ textDecoration: "none",
1386
+ fontWeight: 500
1387
+ },
1388
+ onMouseEnter: (e) => e.currentTarget.style.textDecoration = "underline",
1389
+ onMouseLeave: (e) => e.currentTarget.style.textDecoration = "none",
1390
+ children: c
1391
+ }) : c
1392
+ }, e);
1393
+ }),
1394
+ u && /* @__PURE__ */ Z("td", {
1395
+ style: {
1396
+ padding: "4px 8px",
1397
+ borderBottom: "1px solid var(--divider)",
1398
+ verticalAlign: "middle"
1399
+ },
1400
+ children: /* @__PURE__ */ Q("div", {
1401
+ style: {
1402
+ display: "flex",
1403
+ alignItems: "center",
1404
+ gap: 4
1405
+ },
1406
+ children: [
1407
+ _?.saving && /* @__PURE__ */ Z(n, { size: 12 }),
1408
+ _?.error && /* @__PURE__ */ Z("span", {
1409
+ style: {
1410
+ fontSize: 11,
1411
+ color: "var(--danger)"
1412
+ },
1413
+ title: _.error,
1414
+ children: "!"
1415
+ }),
1416
+ d === "row_edit" && /* @__PURE__ */ Z(D, {
1417
+ size: 24,
1418
+ icon: /* @__PURE__ */ Z(e.edit, { size: 12 }),
1419
+ onClick: () => b(t),
1420
+ title: "Edit row"
1421
+ }),
1422
+ /* @__PURE__ */ Z(D, {
1423
+ size: 24,
1424
+ icon: /* @__PURE__ */ Z(e.trash, { size: 12 }),
1425
+ onClick: () => y(t),
1426
+ title: "Delete row"
1427
+ })
1428
+ ]
1429
+ })
1430
+ }),
1431
+ !u && E && E.length > 0 && /* @__PURE__ */ Z("td", {
1432
+ style: {
1433
+ padding: "4px 8px",
1434
+ borderBottom: "1px solid var(--divider)",
1435
+ verticalAlign: "middle"
1436
+ },
1437
+ children: /* @__PURE__ */ Z(Ce, {
1438
+ entity: a,
1439
+ actions: E,
1440
+ objectIds: [t],
1441
+ row: A,
1442
+ onSuccess: O
1443
+ })
1444
+ })
1445
+ ]
1446
+ });
1447
+ }
1448
+ function ze({ values: t, entity: i, columns: a, editableColumns: o, errors: s, saving: c, onChange: l, onConfirm: u, onCancel: d, refs: f, accent: p }) {
1449
+ let m = r(), h = s.find((e) => e.startsWith("_error:")), g = new Set(s.filter((e) => !e.startsWith("_error:"))), _ = {
1450
+ padding: "6px 12px",
1451
+ borderBottom: "1px solid var(--divider)",
1452
+ verticalAlign: "middle",
1453
+ height: 40,
1454
+ minWidth: 0
1455
+ }, v = {
1456
+ display: "block",
1457
+ width: "100%",
1458
+ maxWidth: "100%",
1459
+ minWidth: 0
1460
+ };
1461
+ return /* @__PURE__ */ Q("tr", {
1462
+ style: p ? { boxShadow: "inset 3px 0 0 var(--accent)" } : void 0,
1463
+ onKeyDown: (e) => {
1464
+ e.key === "Enter" && !e.shiftKey ? (e.preventDefault(), u()) : e.key === "Escape" && (e.preventDefault(), d());
1465
+ },
1466
+ children: [a.map((e) => {
1467
+ let n = i.fields.get(e), r = o.has(e), a = g.has(e);
1468
+ return r ? /* @__PURE__ */ Z("td", {
1469
+ style: {
1470
+ ..._,
1471
+ outline: a ? "1px solid var(--danger)" : "none",
1472
+ outlineOffset: -1
1473
+ },
1474
+ title: a ? `${e} is required` : void 0,
1475
+ children: /* @__PURE__ */ Z("div", {
1476
+ style: v,
1477
+ children: n ? N({
1478
+ field: n,
1479
+ fieldName: e,
1480
+ value: t[e],
1481
+ mode: "edit",
1482
+ onChange: (t) => l(e, t),
1483
+ record: t,
1484
+ refs: f,
1485
+ compact: !0,
1486
+ locale: m
1487
+ }) : H(t[e])
1488
+ })
1489
+ }, e) : /* @__PURE__ */ Z("td", {
1490
+ style: {
1491
+ ..._,
1492
+ color: "var(--text-3)"
1493
+ },
1494
+ children: n?.auto ? "—" : H(t[e])
1495
+ }, e);
1496
+ }), /* @__PURE__ */ Z("td", {
1497
+ style: _,
1498
+ children: /* @__PURE__ */ Q("div", {
1499
+ style: {
1500
+ display: "flex",
1501
+ alignItems: "center",
1502
+ gap: 4,
1503
+ justifyContent: "flex-end"
1504
+ },
1505
+ children: [
1506
+ h && /* @__PURE__ */ Z("span", {
1507
+ style: {
1508
+ fontSize: 11,
1509
+ color: "var(--danger)"
1510
+ },
1511
+ title: h.slice(7),
1512
+ children: "!"
1513
+ }),
1514
+ /* @__PURE__ */ Z(D, {
1515
+ size: 24,
1516
+ icon: Z(c ? n : e.check, { size: 12 }),
1517
+ onClick: u,
1518
+ title: "Confirm (Enter)"
1519
+ }),
1520
+ /* @__PURE__ */ Z(D, {
1521
+ size: 24,
1522
+ icon: /* @__PURE__ */ Z(e.x, { size: 12 }),
1523
+ onClick: d,
1524
+ title: "Cancel (Esc)"
1525
+ })
1526
+ ]
1527
+ })
1528
+ })]
1529
+ });
1530
+ }
1531
+ function Be({ values: t, entity: i, columns: a, editableColumns: o, errors: s, saving: c, onChange: l, onConfirm: u, onCancel: d, refs: f, accent: p }) {
1532
+ let m = r(), h = K(), g = s.find((e) => e.startsWith("_error:")), _ = new Set(s.filter((e) => !e.startsWith("_error:")));
1533
+ return /* @__PURE__ */ Q("div", {
1534
+ style: {
1535
+ border: "1px solid var(--border)",
1536
+ borderRadius: 8,
1537
+ background: "var(--surface)",
1538
+ overflow: "hidden",
1539
+ boxShadow: p ? "inset 3px 0 0 var(--accent)" : void 0
1540
+ },
1541
+ onKeyDown: (e) => {
1542
+ e.key === "Enter" && !e.shiftKey ? (e.preventDefault(), u()) : e.key === "Escape" && (e.preventDefault(), d());
1543
+ },
1544
+ children: [/* @__PURE__ */ Z("div", {
1545
+ style: {
1546
+ padding: 10,
1547
+ display: "flex",
1548
+ flexDirection: "column",
1549
+ gap: 12
1550
+ },
1551
+ children: a.map((e) => {
1552
+ let n = i.fields.get(e), r = o.has(e), a = _.has(e), s = n ? z(n, e) : e, c = `${h}-${e}`, u = `${c}-label`, d = {
1553
+ fontSize: 11.5,
1554
+ fontWeight: 600,
1555
+ color: "var(--text-3)"
1556
+ };
1557
+ return /* @__PURE__ */ Q("div", {
1558
+ style: {
1559
+ display: "flex",
1560
+ flexDirection: "column",
1561
+ gap: 5,
1562
+ minWidth: 0
1563
+ },
1564
+ children: [r && n ? /* @__PURE__ */ Z("label", {
1565
+ id: u,
1566
+ htmlFor: c,
1567
+ style: d,
1568
+ children: s
1569
+ }) : /* @__PURE__ */ Z("div", {
1570
+ id: u,
1571
+ style: d,
1572
+ children: s
1573
+ }), /* @__PURE__ */ Z("div", {
1574
+ style: {
1575
+ minWidth: 0,
1576
+ outline: a ? "1px solid var(--danger)" : "none",
1577
+ outlineOffset: 3,
1578
+ borderRadius: a ? 5 : 0
1579
+ },
1580
+ title: a ? `${e} is required` : void 0,
1581
+ children: r ? n ? N({
1582
+ field: n,
1583
+ fieldName: e,
1584
+ value: t[e],
1585
+ mode: "edit",
1586
+ onChange: (t) => l(e, t),
1587
+ record: t,
1588
+ refs: f,
1589
+ compact: !0,
1590
+ fieldId: c,
1591
+ labelId: u,
1592
+ locale: m
1593
+ }) : H(t[e]) : n?.auto ? "—" : H(t[e])
1594
+ })]
1595
+ }, e);
1596
+ })
1597
+ }), /* @__PURE__ */ Q("div", {
1598
+ style: {
1599
+ minHeight: 42,
1600
+ padding: "6px 8px",
1601
+ borderTop: "1px solid var(--divider)",
1602
+ display: "flex",
1603
+ alignItems: "center",
1604
+ justifyContent: "flex-end",
1605
+ gap: 6
1606
+ },
1607
+ children: [
1608
+ g && /* @__PURE__ */ Z("span", {
1609
+ style: {
1610
+ fontSize: 11,
1611
+ color: "var(--danger)"
1612
+ },
1613
+ title: g.slice(7),
1614
+ children: "!"
1615
+ }),
1616
+ /* @__PURE__ */ Z(D, {
1617
+ size: 32,
1618
+ icon: Z(c ? n : e.check, { size: 14 }),
1619
+ onClick: u,
1620
+ title: "Confirm (Enter)"
1621
+ }),
1622
+ /* @__PURE__ */ Z(D, {
1623
+ size: 32,
1624
+ icon: /* @__PURE__ */ Z(e.x, { size: 14 }),
1625
+ onClick: d,
1626
+ title: "Cancel (Esc)"
1627
+ })
1628
+ ]
1629
+ })]
1630
+ });
1631
+ }
1632
+ function Ve({ draftRow: e, entity: t, columns: n, editableColumns: r, foreignKey: i, draftErrors: a, draftSaving: o, onChange: s, onConfirm: c, onCancel: l, refs: u }) {
1633
+ let d = q(() => {
1634
+ let e = new Set(r);
1635
+ return e.delete(i), e;
1636
+ }, [r, i]);
1637
+ return /* @__PURE__ */ Z(ze, {
1638
+ values: e,
1639
+ entity: t,
1640
+ columns: n,
1641
+ editableColumns: d,
1642
+ errors: a,
1643
+ saving: o,
1644
+ onChange: s,
1645
+ onConfirm: c,
1646
+ onCancel: l,
1647
+ refs: u,
1648
+ accent: !0
1649
+ });
1650
+ }
1651
+ function He({ draftRow: e, entity: t, columns: n, editableColumns: r, foreignKey: i, draftErrors: a, draftSaving: o, onChange: s, onConfirm: c, onCancel: l, refs: u }) {
1652
+ let d = q(() => {
1653
+ let e = new Set(r);
1654
+ return e.delete(i), e;
1655
+ }, [r, i]);
1656
+ return /* @__PURE__ */ Z(Be, {
1657
+ values: e,
1658
+ entity: t,
1659
+ columns: n,
1660
+ editableColumns: d,
1661
+ errors: a,
1662
+ saving: o,
1663
+ onChange: s,
1664
+ onConfirm: c,
1665
+ onCancel: l,
1666
+ refs: u,
1667
+ accent: !0
1668
+ });
1669
+ }
1670
+ //#endregion
1671
+ //#region src/components/shared/ErrorBoundary.tsx
1672
+ var Ue = class extends ue {
1673
+ constructor(e) {
1674
+ super(e), this.state = {
1675
+ hasError: !1,
1676
+ error: null
1677
+ };
1678
+ }
1679
+ static getDerivedStateFromError(e) {
1680
+ return {
1681
+ hasError: !0,
1682
+ error: e
1683
+ };
1684
+ }
1685
+ componentDidCatch(e, t) {
1686
+ console.error("[ErrorBoundary]", e, t.componentStack);
1687
+ }
1688
+ handleRetry = () => {
1689
+ this.setState({
1690
+ hasError: !1,
1691
+ error: null
1692
+ });
1693
+ };
1694
+ render() {
1695
+ return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ Z("div", {
1696
+ style: {
1697
+ display: "flex",
1698
+ alignItems: "center",
1699
+ justifyContent: "center",
1700
+ minHeight: 200,
1701
+ padding: 32
1702
+ },
1703
+ children: /* @__PURE__ */ Q("div", {
1704
+ style: {
1705
+ textAlign: "center",
1706
+ maxWidth: 420,
1707
+ display: "flex",
1708
+ flexDirection: "column",
1709
+ gap: 10
1710
+ },
1711
+ children: [
1712
+ /* @__PURE__ */ Z("h2", {
1713
+ style: {
1714
+ fontSize: 16,
1715
+ fontWeight: 600,
1716
+ margin: 0,
1717
+ color: "var(--text)"
1718
+ },
1719
+ children: "Something went wrong"
1720
+ }),
1721
+ /* @__PURE__ */ Z("p", {
1722
+ style: {
1723
+ fontSize: 12.5,
1724
+ color: "var(--text-3)",
1725
+ margin: 0
1726
+ },
1727
+ children: this.state.error?.message || "An unexpected error occurred."
1728
+ }),
1729
+ /* @__PURE__ */ Z("div", { children: /* @__PURE__ */ Z(k, {
1730
+ onClick: this.handleRetry,
1731
+ children: "Try again"
1732
+ }) })
1733
+ ]
1734
+ })
1735
+ }) : this.props.children;
1736
+ }
1737
+ };
1738
+ //#endregion
1739
+ //#region src/hooks/useObject.ts
1740
+ function We(e, t) {
1741
+ return [
1742
+ "entity-item",
1743
+ e,
1744
+ t === void 0 || t === "new" ? void 0 : typeof t == "string" ? t : Object.keys(t).sort().map((e) => [e, t[e]])
1745
+ ];
1746
+ }
1747
+ function Ge(e, t) {
1748
+ let n = We(e, t), r = n[2];
1749
+ return pe({
1750
+ queryKey: n,
1751
+ queryFn: () => _(e, t),
1752
+ enabled: !!e && !!t && t !== "new" && r !== void 0
1753
+ });
1754
+ }
1755
+ //#endregion
1756
+ //#region src/components/detail-layout/widgets/registry.ts
1757
+ var Ke = /* @__PURE__ */ new Map();
1758
+ function qe(e, t) {
1759
+ Ke.set(e, t);
1760
+ }
1761
+ function Je(e) {
1762
+ return Ke.get(e);
1763
+ }
1764
+ function Ye(e) {
1765
+ return Ke.has(e);
1766
+ }
1767
+ //#endregion
1768
+ export { Ge as a, Se as c, ve as d, _e as f, We as i, ye as l, Ye as n, Ue as o, qe as r, Me as s, Je as t, be as u };