@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.
- package/dist-lib/Check-DAfMbQIw.js +38 -0
- package/dist-lib/{DraggableChildrenTable-p2ZSdwzj.js → DraggableChildrenTable-Dar8C-Z9.js} +31 -31
- package/dist-lib/DynamicIcon-DW5krHuX.js +280 -0
- package/dist-lib/{Grid-CjLFAKMZ.js → Grid-BkHtfsty.js} +2 -2
- package/dist-lib/{LayoutRenderer-DCscqXsv.js → LayoutRenderer-Cic7IAop.js} +601 -598
- package/dist-lib/ListCardsBody-Dko91bLv.js +287 -0
- package/dist-lib/{MarkdownRenderer-Sb7zcvj0.js → MarkdownRenderer-CJrVG5HZ.js} +1 -1
- package/dist-lib/RefreshControl-BS8WWL8i.js +430 -0
- package/dist-lib/{SmartDetailPage.impl-BAW-Tx_H.js → SmartDetailPage.impl-DxRDo0p2.js} +521 -516
- package/dist-lib/SmartListPage.impl-CNdq5Vts.js +2849 -0
- package/dist-lib/{SmartRecordListPage.impl-DtSSlGrI.js → SmartRecordListPage.impl-3ct7f4rT.js} +244 -241
- package/dist-lib/SortHeaderMenu-NgjkW8QZ.js +106 -0
- package/dist-lib/action-dispatch-hVrm3Hrg.js +1984 -0
- package/dist-lib/api/batch.d.ts +5 -2
- package/dist-lib/api/data.d.ts +35 -4
- package/dist-lib/api/entities.d.ts +3 -3
- package/dist-lib/cardProjection-BR-fXPvJ.js +757 -0
- package/dist-lib/components/{shared → actions}/ObjectActionBar.d.ts +1 -1
- package/dist-lib/components/{shared → actions}/ResponsiveActionBar.d.ts +1 -1
- package/dist-lib/components/fields/cells/factories/date.d.ts +2 -0
- package/dist-lib/components/file-widgets/upload.d.ts +6 -1
- package/dist-lib/components/layout/Layout.d.ts +1 -1
- package/dist-lib/components/layout/TopBar.d.ts +1 -1
- package/dist-lib/components/pages/SmartListPage.d.ts +2 -12
- package/dist-lib/components/pages/SmartListPage.impl.d.ts +4 -0
- package/dist-lib/components/pages/list/ListCardRow.d.ts +40 -0
- package/dist-lib/components/pages/list/ListCardsBody.d.ts +34 -0
- package/dist-lib/components/pages/list/ListFloatbar.d.ts +1 -1
- package/dist-lib/components/pages/list/ListFooter.d.ts +26 -0
- package/dist-lib/components/pages/list/ListHeader.d.ts +1 -1
- package/dist-lib/components/pages/list/ListNoRows.d.ts +32 -0
- package/dist-lib/components/pages/list/ListTable.d.ts +34 -0
- package/dist-lib/components/pages/list/ListTableRow.d.ts +18 -0
- package/dist-lib/components/pages/list/ListToolbar.d.ts +43 -0
- package/dist-lib/components/pages/list/SortHeaderMenu.d.ts +14 -0
- package/dist-lib/components/pages/list/page-size.d.ts +3 -0
- package/dist-lib/components/pages/list/sortable-header.d.ts +2 -0
- package/dist-lib/components/pages/list/useListColumnLayout.d.ts +37 -0
- package/dist-lib/components/pages/list/useListQuery.d.ts +66 -0
- package/dist-lib/components/pages/list/useListRowInteraction.d.ts +61 -0
- package/dist-lib/components/pages/list/useListSelection.d.ts +31 -0
- package/dist-lib/components/pages/list/useListSort.d.ts +45 -0
- package/dist-lib/components/pages/list/useListViews.d.ts +46 -0
- package/dist-lib/components/pages/list/useRowMenu.d.ts +1 -1
- package/dist-lib/components/primitives/Icons.d.ts +5 -0
- package/dist-lib/components/shared/RefreshControl.d.ts +17 -4
- package/dist-lib/field-classification-Bm0mgbwA.js +1134 -0
- package/dist-lib/format-count-BfRGwx2v.js +1551 -0
- package/dist-lib/hooks/useBrandingChrome.d.ts +17 -1
- package/dist-lib/hooks/useText.d.ts +3 -0
- package/dist-lib/hooks/useViews.d.ts +1 -1
- package/dist-lib/icons.js +1 -1
- package/dist-lib/index.d.ts +17 -15
- package/dist-lib/index.js +1784 -6288
- package/dist-lib/lib/messages.d.ts +7 -1
- package/dist-lib/lib/rowClickGesture.d.ts +12 -0
- package/dist-lib/lib/timestamp.d.ts +8 -3
- package/dist-lib/peekDraftStore-bb4WroTA.js +194 -0
- package/dist-lib/record-documents-key-8fdm7C10.js +27 -0
- package/dist-lib/registry-CgeGoWpW.js +1768 -0
- package/dist-lib/testing.d.ts +17 -2
- package/dist-lib/testing.js +72 -58
- package/dist-lib/types/api.d.ts +54 -12
- package/dist-lib/types/schema.d.ts +22 -6
- package/dist-lib/{useCurrentScreen-BshVTPVq.js → useCurrentScreen-D3XH5ptA.js} +1127 -1070
- package/dist-lib/useListQuery-CfuINl-0.js +87 -0
- package/dist-lib/useProperties-DNocaxBX.js +81 -0
- package/dist-lib/{useProperties-DrHFr0A1.js → useTabSearchMirror-d0BAUIcQ.js} +116 -194
- package/dist-lib/{value-B1O6QikE.js → value-D71J0sJq.js} +69 -69
- package/package.json +1 -1
- package/dist-lib/DynamicIcon-Dc2j-rg_.js +0 -275
- package/dist-lib/RefreshControl-Cnl9nE0x.js +0 -945
- package/dist-lib/registry-CCxnZW2b.js +0 -5281
- /package/dist-lib/components/{shared → actions}/ActionButton.d.ts +0 -0
- /package/dist-lib/components/{shared → actions}/ActionDialog.d.ts +0 -0
- /package/dist-lib/components/{shared → actions}/ActionResultDialog.d.ts +0 -0
- /package/dist-lib/components/{shared → actions}/ActionRunner.d.ts +0 -0
- /package/dist-lib/components/{mass-edit → actions}/PropertyGridEditor.d.ts +0 -0
- /package/dist-lib/components/{shared → actions}/RowActionsKebab.d.ts +0 -0
- /package/dist-lib/components/{shared → chrome}/AssociationTabs.d.ts +0 -0
- /package/dist-lib/components/{shared → chrome}/AuditMetaStrip.d.ts +0 -0
- /package/dist-lib/components/{shared → chrome}/Breadcrumbs.d.ts +0 -0
- /package/dist-lib/components/{shared → chrome}/HighlightsStrip.d.ts +0 -0
- /package/dist-lib/components/{shared → chrome}/PageHeader.d.ts +0 -0
- /package/dist-lib/components/{shared → chrome}/RecordHeader.d.ts +0 -0
- /package/dist-lib/components/{shell → layout}/CommandPalette.d.ts +0 -0
- /package/dist-lib/components/{columns → list}/ColumnPicker.d.ts +0 -0
- /package/dist-lib/components/{views → list}/ViewSwitcher.d.ts +0 -0
|
@@ -0,0 +1,1984 @@
|
|
|
1
|
+
import { s as e, t } from "./DynamicIcon-DW5krHuX.js";
|
|
2
|
+
import { $n as n, B as r, Dn as i, E as a, I as o, L as s, O as c, P as l, R as u, V as d, W as f, cr as p, d as m, dr as h, er as g, fr as _, g as v, j as y, u as b, wn as x, z as S } from "./useCurrentScreen-D3XH5ptA.js";
|
|
3
|
+
import { a as C, c as w, d as T, f as E, i as D, l as O, n as ee, o as k, p as A, r as te, s as j, t as M, u as N } from "./value-D71J0sJq.js";
|
|
4
|
+
import { Fragment as P, Suspense as F, lazy as I, useCallback as L, useEffect as R, useLayoutEffect as z, useMemo as ne, useRef as B, useState as V } from "react";
|
|
5
|
+
import { Fragment as H, jsx as U, jsxs as W } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/file-widgets/registry.ts
|
|
7
|
+
var G = /* @__PURE__ */ new Map();
|
|
8
|
+
function K(e, t) {
|
|
9
|
+
G.set(e, t);
|
|
10
|
+
}
|
|
11
|
+
function q(e) {
|
|
12
|
+
return G.get(e);
|
|
13
|
+
}
|
|
14
|
+
function re(e) {
|
|
15
|
+
return G.has(e);
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/components/file-widgets/cropper.ts
|
|
19
|
+
var ie = ({ file: e }) => Promise.resolve({
|
|
20
|
+
blob: e,
|
|
21
|
+
filename: e.name
|
|
22
|
+
}), J = ie;
|
|
23
|
+
function ae(e) {
|
|
24
|
+
J = e ?? ie;
|
|
25
|
+
}
|
|
26
|
+
function Y() {
|
|
27
|
+
return J;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/components/file-widgets/ImageWidget.tsx
|
|
31
|
+
function oe(e, t) {
|
|
32
|
+
return w(e, t);
|
|
33
|
+
}
|
|
34
|
+
function se(e) {
|
|
35
|
+
let t = e.trim().split(/\s+/).filter(Boolean);
|
|
36
|
+
return t.length === 0 ? "?" : t.length === 1 ? t[0].slice(0, 2).toUpperCase() : (t[0][0] + t[1][0]).toUpperCase();
|
|
37
|
+
}
|
|
38
|
+
function ce(e) {
|
|
39
|
+
let { field: t, fieldName: n, value: i, onChange: a, mode: c, alt: u, disabled: d, visual: f, uploadFieldCode: p, uploadSlotCode: m } = e, h = ee(i), [g, _] = V("idle"), [v, y] = V(null), [b, x] = V(null), [C, w] = V(null), [k, te] = V(!1), M = B(null), N = B(!1), P = B(null), { register: F, unregister: I, isDraft: z } = l();
|
|
40
|
+
R(() => () => {
|
|
41
|
+
M.current && M.current.abort();
|
|
42
|
+
}, []);
|
|
43
|
+
let H = ne(() => E(h, u, t.display?.placeholder || n), [
|
|
44
|
+
u,
|
|
45
|
+
t.display?.placeholder,
|
|
46
|
+
n,
|
|
47
|
+
h
|
|
48
|
+
]), G = (t.accepts ?? ["image/*"]).join(","), K = L(async (i) => {
|
|
49
|
+
let c = r(i, t.accepts, t.max_size_bytes);
|
|
50
|
+
if (c) {
|
|
51
|
+
x(c), _("error");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
let l = i;
|
|
55
|
+
if (t.display?.crop_on_upload) try {
|
|
56
|
+
let { blob: e, filename: n } = await Y()({
|
|
57
|
+
file: i,
|
|
58
|
+
aspectRatio: fe(t.display.aspect_ratio)
|
|
59
|
+
});
|
|
60
|
+
l = new File([e], n, { type: e.type || i.type });
|
|
61
|
+
} catch (e) {
|
|
62
|
+
x({
|
|
63
|
+
code: "CROP_FAILED",
|
|
64
|
+
message: e instanceof Error ? e.message : "Crop failed"
|
|
65
|
+
}), _("error");
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
x(null), N.current = !1, _("uploading"), y({
|
|
69
|
+
loaded: 0,
|
|
70
|
+
total: l.size,
|
|
71
|
+
pct: 0
|
|
72
|
+
});
|
|
73
|
+
let u = new AbortController();
|
|
74
|
+
M.current = u;
|
|
75
|
+
try {
|
|
76
|
+
let r = await S({
|
|
77
|
+
file: l,
|
|
78
|
+
entityCode: e.entityCode,
|
|
79
|
+
fieldCode: p ?? n,
|
|
80
|
+
slotCode: m,
|
|
81
|
+
signal: u.signal,
|
|
82
|
+
onProgress: y
|
|
83
|
+
});
|
|
84
|
+
if (N.current) {
|
|
85
|
+
s(r.id).catch(() => {}), I(r.id);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
h && z(h.id) && (s(h.id).catch(() => {}), I(h.id)), F(r.id, () => s(r.id)), w(r.id), _("idle"), y(null);
|
|
89
|
+
let i = {
|
|
90
|
+
id: r.id,
|
|
91
|
+
filename: r.filename,
|
|
92
|
+
content_type: r.content_type,
|
|
93
|
+
size_bytes: r.size_bytes,
|
|
94
|
+
sha256: r.sha256,
|
|
95
|
+
width: r.width,
|
|
96
|
+
height: r.height,
|
|
97
|
+
url: r.url,
|
|
98
|
+
metadata: r.metadata
|
|
99
|
+
};
|
|
100
|
+
a?.(t.mode === "array" ? [i] : i);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
if (e instanceof o && e.code === "ABORTED") return;
|
|
103
|
+
let t = e instanceof o ? {
|
|
104
|
+
code: e.code,
|
|
105
|
+
message: e.message
|
|
106
|
+
} : {
|
|
107
|
+
code: "UNKNOWN",
|
|
108
|
+
message: e instanceof Error ? e.message : "Upload failed"
|
|
109
|
+
};
|
|
110
|
+
x(t), _("error"), y(null);
|
|
111
|
+
}
|
|
112
|
+
}, [
|
|
113
|
+
t.accepts,
|
|
114
|
+
t.max_size_bytes,
|
|
115
|
+
t.display?.crop_on_upload,
|
|
116
|
+
t.display?.aspect_ratio,
|
|
117
|
+
t.mode,
|
|
118
|
+
n,
|
|
119
|
+
a,
|
|
120
|
+
e.entityCode,
|
|
121
|
+
F,
|
|
122
|
+
z,
|
|
123
|
+
h,
|
|
124
|
+
I,
|
|
125
|
+
p,
|
|
126
|
+
m
|
|
127
|
+
]), q = L(() => {
|
|
128
|
+
g === "uploading" && M.current && (N.current = !0, M.current.abort(), M.current = null, _("idle"), y(null)), C && (s(C).catch(() => {}), I(C), w(null));
|
|
129
|
+
}, [
|
|
130
|
+
g,
|
|
131
|
+
C,
|
|
132
|
+
I
|
|
133
|
+
]), re = L(() => {
|
|
134
|
+
h && z(h.id) && (s(h.id).catch(() => {}), I(h.id), w(null)), a?.(t.mode === "array" ? [] : null);
|
|
135
|
+
}, [
|
|
136
|
+
h,
|
|
137
|
+
t.mode,
|
|
138
|
+
z,
|
|
139
|
+
a,
|
|
140
|
+
I
|
|
141
|
+
]), ie = L(() => {
|
|
142
|
+
x(null), _("idle"), P.current?.click();
|
|
143
|
+
}, []), J = L(() => {
|
|
144
|
+
d || P.current?.click();
|
|
145
|
+
}, [d]), ae = L((e) => {
|
|
146
|
+
d || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), J());
|
|
147
|
+
}, [d, J]), se = L((e) => {
|
|
148
|
+
d || (e.preventDefault(), e.dataTransfer.dropEffect = "copy");
|
|
149
|
+
}, [d]), ce = L((e) => {
|
|
150
|
+
if (d) return;
|
|
151
|
+
e.preventDefault();
|
|
152
|
+
let t = e.dataTransfer.files?.[0];
|
|
153
|
+
t && K(t);
|
|
154
|
+
}, [d, K]), he = L((e) => {
|
|
155
|
+
let t = e.target.files?.[0];
|
|
156
|
+
e.target.value = "", t && K(t);
|
|
157
|
+
}, [K]), ge = f.aspectRatio ?? de(f.shape, t.display?.aspect_ratio), X = T(h), _e = {
|
|
158
|
+
aspectRatio: ge,
|
|
159
|
+
width: f.width ?? (f.shape === "wide" ? "100%" : "120px")
|
|
160
|
+
}, Z = !!h, ve = oe(h, t.display?.listable_thumbnail), ye = O(h, t.display?.listable_thumbnail), be = D(h?.id, ye, ve), xe = c === "display", Se = L((e) => {
|
|
161
|
+
e.stopPropagation(), te((e) => !e);
|
|
162
|
+
}, []), Ce = L((e) => {
|
|
163
|
+
if (!h || !k) return;
|
|
164
|
+
let n = e.currentTarget.getBoundingClientRect(), r = n.width > 0 ? (e.clientX - n.left) / n.width : .5, i = n.height > 0 ? (e.clientY - n.top) / n.height : .5, o = A(h, {
|
|
165
|
+
x: Math.max(0, Math.min(1, r)),
|
|
166
|
+
y: Math.max(0, Math.min(1, i))
|
|
167
|
+
});
|
|
168
|
+
a?.(t.mode === "array" ? [o] : o), te(!1);
|
|
169
|
+
}, [
|
|
170
|
+
t.mode,
|
|
171
|
+
h,
|
|
172
|
+
k,
|
|
173
|
+
a
|
|
174
|
+
]);
|
|
175
|
+
return xe ? /* @__PURE__ */ U("div", {
|
|
176
|
+
className: le(f.shape, !1),
|
|
177
|
+
style: _e,
|
|
178
|
+
"aria-label": H,
|
|
179
|
+
children: Z && be ? /* @__PURE__ */ U("img", {
|
|
180
|
+
src: be,
|
|
181
|
+
alt: H,
|
|
182
|
+
className: ue(f.shape),
|
|
183
|
+
style: { objectPosition: j(X) },
|
|
184
|
+
loading: "lazy"
|
|
185
|
+
}) : /* @__PURE__ */ U(pe, {
|
|
186
|
+
shape: f.shape,
|
|
187
|
+
label: H,
|
|
188
|
+
placeholder: t.display?.placeholder
|
|
189
|
+
})
|
|
190
|
+
}) : /* @__PURE__ */ W("div", {
|
|
191
|
+
className: le(f.shape, !d),
|
|
192
|
+
style: _e,
|
|
193
|
+
tabIndex: d ? -1 : 0,
|
|
194
|
+
role: "button",
|
|
195
|
+
"aria-label": H,
|
|
196
|
+
"aria-disabled": d || void 0,
|
|
197
|
+
"aria-busy": g === "uploading" || void 0,
|
|
198
|
+
"aria-invalid": g === "error" || void 0,
|
|
199
|
+
onClick: g === "idle" && !Z ? J : void 0,
|
|
200
|
+
onMouseDown: k ? Ce : void 0,
|
|
201
|
+
onKeyDown: ae,
|
|
202
|
+
onDragOver: se,
|
|
203
|
+
onDrop: ce,
|
|
204
|
+
"data-testid": k ? "focal-point-target" : `file-widget-${n}`,
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ U("input", {
|
|
207
|
+
ref: P,
|
|
208
|
+
type: "file",
|
|
209
|
+
accept: G,
|
|
210
|
+
onChange: he,
|
|
211
|
+
style: { display: "none" },
|
|
212
|
+
"data-testid": `file-input-${n}`
|
|
213
|
+
}),
|
|
214
|
+
Z && be ? /* @__PURE__ */ U("img", {
|
|
215
|
+
src: be,
|
|
216
|
+
alt: H,
|
|
217
|
+
className: ue(f.shape),
|
|
218
|
+
style: { objectPosition: j(X) },
|
|
219
|
+
loading: "lazy"
|
|
220
|
+
}) : g === "uploading" ? null : /* @__PURE__ */ U(pe, {
|
|
221
|
+
shape: f.shape,
|
|
222
|
+
label: H,
|
|
223
|
+
placeholder: t.display?.placeholder
|
|
224
|
+
}),
|
|
225
|
+
g === "uploading" && /* @__PURE__ */ U(me, { pct: v?.pct ?? 0 }),
|
|
226
|
+
C && /* @__PURE__ */ U("span", {
|
|
227
|
+
className: "absolute right-1 top-1 h-2 w-2 rounded-full bg-warning",
|
|
228
|
+
"aria-hidden": "true",
|
|
229
|
+
"data-testid": "draft-indicator"
|
|
230
|
+
}),
|
|
231
|
+
Z && g === "idle" && !d && /* @__PURE__ */ W("div", {
|
|
232
|
+
className: "absolute inset-0 flex items-center justify-center gap-2 bg-black/40 opacity-0 transition-opacity hover:opacity-100 focus-within:opacity-100",
|
|
233
|
+
children: [
|
|
234
|
+
t.display?.focal_point && /* @__PURE__ */ U("button", {
|
|
235
|
+
type: "button",
|
|
236
|
+
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
|
|
237
|
+
onClick: Se,
|
|
238
|
+
"data-testid": "focal-point-toggle",
|
|
239
|
+
children: k ? "Cancel focus" : "Set focus"
|
|
240
|
+
}),
|
|
241
|
+
/* @__PURE__ */ U("button", {
|
|
242
|
+
type: "button",
|
|
243
|
+
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
|
|
244
|
+
onClick: (e) => {
|
|
245
|
+
e.stopPropagation(), J();
|
|
246
|
+
},
|
|
247
|
+
children: "Change"
|
|
248
|
+
}),
|
|
249
|
+
/* @__PURE__ */ U("button", {
|
|
250
|
+
type: "button",
|
|
251
|
+
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-destructive hover:bg-surface-2",
|
|
252
|
+
onClick: (e) => {
|
|
253
|
+
e.stopPropagation(), re();
|
|
254
|
+
},
|
|
255
|
+
children: "Remove"
|
|
256
|
+
})
|
|
257
|
+
]
|
|
258
|
+
}),
|
|
259
|
+
X && Z && /* @__PURE__ */ U("span", {
|
|
260
|
+
className: "absolute h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full border border-white bg-black/70",
|
|
261
|
+
style: {
|
|
262
|
+
left: `${X.x * 100}%`,
|
|
263
|
+
top: `${X.y * 100}%`
|
|
264
|
+
},
|
|
265
|
+
"data-testid": "focal-point-marker"
|
|
266
|
+
}),
|
|
267
|
+
g === "uploading" && /* @__PURE__ */ U("button", {
|
|
268
|
+
type: "button",
|
|
269
|
+
className: "absolute bottom-1 right-1 rounded-sm border border-border bg-card px-2 py-0.5 text-xs",
|
|
270
|
+
onClick: (e) => {
|
|
271
|
+
e.stopPropagation(), q();
|
|
272
|
+
},
|
|
273
|
+
"data-testid": "cancel-upload",
|
|
274
|
+
children: "Cancel"
|
|
275
|
+
}),
|
|
276
|
+
g === "error" && b && /* @__PURE__ */ W("div", {
|
|
277
|
+
className: "absolute inset-x-0 bottom-0 flex items-center justify-between gap-2 bg-destructive-soft px-2 py-1 text-xs text-destructive",
|
|
278
|
+
role: "alert",
|
|
279
|
+
children: [/* @__PURE__ */ U("span", {
|
|
280
|
+
className: "truncate",
|
|
281
|
+
title: b.message,
|
|
282
|
+
children: b.message
|
|
283
|
+
}), /* @__PURE__ */ U("button", {
|
|
284
|
+
type: "button",
|
|
285
|
+
className: "underline",
|
|
286
|
+
onClick: (e) => {
|
|
287
|
+
e.stopPropagation(), ie();
|
|
288
|
+
},
|
|
289
|
+
"data-testid": "retry-upload",
|
|
290
|
+
children: "Retry"
|
|
291
|
+
})]
|
|
292
|
+
})
|
|
293
|
+
]
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
function le(e, t) {
|
|
297
|
+
return [
|
|
298
|
+
"relative overflow-hidden border border-border bg-surface-2",
|
|
299
|
+
e === "circle" ? "rounded-full" : "rounded-md",
|
|
300
|
+
t ? "cursor-pointer focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent" : ""
|
|
301
|
+
].filter(Boolean).join(" ");
|
|
302
|
+
}
|
|
303
|
+
function ue(e) {
|
|
304
|
+
return "h-full w-full object-cover";
|
|
305
|
+
}
|
|
306
|
+
function de(e, t) {
|
|
307
|
+
return t ? t.replace(":", " / ") : e === "wide" ? "16 / 9" : "1 / 1";
|
|
308
|
+
}
|
|
309
|
+
function fe(e) {
|
|
310
|
+
if (!e) return;
|
|
311
|
+
let t = e.replace(/\s/g, "").match(/^(\d+(?:\.\d+)?)[:/](\d+(?:\.\d+)?)$/);
|
|
312
|
+
if (!t) return;
|
|
313
|
+
let n = Number(t[1]), r = Number(t[2]);
|
|
314
|
+
if (!(!n || !r)) return n / r;
|
|
315
|
+
}
|
|
316
|
+
function pe({ shape: e, label: t, placeholder: n }) {
|
|
317
|
+
return n === "initials" ? /* @__PURE__ */ U("div", {
|
|
318
|
+
className: "flex h-full w-full items-center justify-center bg-surface-3 text-text-3",
|
|
319
|
+
children: /* @__PURE__ */ U("span", {
|
|
320
|
+
className: e === "circle" ? "text-lg font-medium" : "text-base font-medium",
|
|
321
|
+
children: se(t)
|
|
322
|
+
})
|
|
323
|
+
}) : /* @__PURE__ */ U("div", {
|
|
324
|
+
className: "flex h-full w-full items-center justify-center bg-surface-3 text-text-4",
|
|
325
|
+
children: /* @__PURE__ */ U("span", {
|
|
326
|
+
className: "text-xs",
|
|
327
|
+
children: e === "wide" ? "Drop image here" : "+"
|
|
328
|
+
})
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
function me({ pct: e }) {
|
|
332
|
+
let t = 2 * Math.PI * 18, n = t - Math.max(0, Math.min(100, e)) / 100 * t;
|
|
333
|
+
return /* @__PURE__ */ W("div", {
|
|
334
|
+
className: "absolute inset-0 flex items-center justify-center bg-black/30",
|
|
335
|
+
"data-testid": "upload-progress",
|
|
336
|
+
"aria-label": `Uploading ${Math.round(e)}%`,
|
|
337
|
+
role: "progressbar",
|
|
338
|
+
"aria-valuenow": Math.round(e),
|
|
339
|
+
"aria-valuemin": 0,
|
|
340
|
+
"aria-valuemax": 100,
|
|
341
|
+
children: [/* @__PURE__ */ W("svg", {
|
|
342
|
+
width: "48",
|
|
343
|
+
height: "48",
|
|
344
|
+
viewBox: "0 0 48 48",
|
|
345
|
+
children: [/* @__PURE__ */ U("circle", {
|
|
346
|
+
cx: "24",
|
|
347
|
+
cy: "24",
|
|
348
|
+
r: 18,
|
|
349
|
+
stroke: "currentColor",
|
|
350
|
+
strokeOpacity: "0.25",
|
|
351
|
+
strokeWidth: "4",
|
|
352
|
+
fill: "none",
|
|
353
|
+
className: "text-foreground"
|
|
354
|
+
}), /* @__PURE__ */ U("circle", {
|
|
355
|
+
cx: "24",
|
|
356
|
+
cy: "24",
|
|
357
|
+
r: 18,
|
|
358
|
+
stroke: "currentColor",
|
|
359
|
+
strokeWidth: "4",
|
|
360
|
+
fill: "none",
|
|
361
|
+
strokeDasharray: t,
|
|
362
|
+
strokeDashoffset: n,
|
|
363
|
+
strokeLinecap: "round",
|
|
364
|
+
className: "text-accent",
|
|
365
|
+
transform: "rotate(-90 24 24)"
|
|
366
|
+
})]
|
|
367
|
+
}), /* @__PURE__ */ W("span", {
|
|
368
|
+
className: "absolute text-xs text-foreground",
|
|
369
|
+
children: [Math.round(e), "%"]
|
|
370
|
+
})]
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/components/file-widgets/SquareImage.tsx
|
|
375
|
+
function he(e) {
|
|
376
|
+
return /* @__PURE__ */ U(ce, {
|
|
377
|
+
...e,
|
|
378
|
+
visual: { shape: "square" }
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/components/file-widgets/CircleImage.tsx
|
|
383
|
+
function ge(e) {
|
|
384
|
+
return /* @__PURE__ */ U(ce, {
|
|
385
|
+
...e,
|
|
386
|
+
visual: { shape: "circle" }
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
//#endregion
|
|
390
|
+
//#region src/components/file-widgets/WideBanner.tsx
|
|
391
|
+
function X(e) {
|
|
392
|
+
return /* @__PURE__ */ U(ce, {
|
|
393
|
+
...e,
|
|
394
|
+
visual: { shape: "wide" }
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/components/file-widgets/GridLazy.tsx
|
|
399
|
+
var _e = I(() => import("./Grid-BkHtfsty.js").then((e) => ({ default: e.Grid })));
|
|
400
|
+
function Z() {
|
|
401
|
+
return /* @__PURE__ */ U("div", { className: "h-24 w-full rounded-md bg-muted animate-pulse" });
|
|
402
|
+
}
|
|
403
|
+
function ve(e) {
|
|
404
|
+
return /* @__PURE__ */ U(F, {
|
|
405
|
+
fallback: /* @__PURE__ */ U(Z, {}),
|
|
406
|
+
children: /* @__PURE__ */ U(_e, { ...e })
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
//#endregion
|
|
410
|
+
//#region src/components/file-widgets/DocumentCard.tsx
|
|
411
|
+
function ye({ contentType: e }) {
|
|
412
|
+
let t = e ? e.includes("pdf") ? "PDF" : e.includes("word") ? "DOC" : e.includes("sheet") || e.includes("excel") ? "XLS" : e.startsWith("image/") ? "IMG" : e.split("/")[1]?.slice(0, 4).toUpperCase() ?? "FILE" : "FILE";
|
|
413
|
+
return /* @__PURE__ */ U("div", {
|
|
414
|
+
className: "flex h-16 w-16 flex-none items-center justify-center rounded-md border border-border bg-surface-3 text-xs font-medium text-muted-foreground",
|
|
415
|
+
children: t
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
function be(e) {
|
|
419
|
+
let { field: t, fieldName: n, value: i, onChange: a, mode: c, disabled: d, uploadFieldCode: f, uploadSlotCode: p } = e, m = ee(i), [h, g] = V("idle"), [_, v] = V(null), [y, b] = V(null), [x, w] = V(!1), [T, E] = V(m?.filename ?? ""), D = B(null), O = B(!1), A = B(null), { register: j, unregister: M, isDraft: P } = l(), { open: F } = te();
|
|
420
|
+
R(() => () => {
|
|
421
|
+
D.current && D.current.abort();
|
|
422
|
+
}, []), R(() => {
|
|
423
|
+
E(m?.filename ?? "");
|
|
424
|
+
}, [m?.filename]);
|
|
425
|
+
let I = (t.accepts ?? []).join(","), z = L(async (i) => {
|
|
426
|
+
let c = r(i, t.accepts, t.max_size_bytes);
|
|
427
|
+
if (c) {
|
|
428
|
+
b(c), g("error");
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
b(null), O.current = !1, g("uploading"), v({
|
|
432
|
+
loaded: 0,
|
|
433
|
+
total: i.size,
|
|
434
|
+
pct: 0
|
|
435
|
+
});
|
|
436
|
+
let l = new AbortController();
|
|
437
|
+
D.current = l;
|
|
438
|
+
try {
|
|
439
|
+
let r = await S({
|
|
440
|
+
file: i,
|
|
441
|
+
entityCode: e.entityCode,
|
|
442
|
+
fieldCode: f ?? n,
|
|
443
|
+
slotCode: p,
|
|
444
|
+
signal: l.signal,
|
|
445
|
+
onProgress: v
|
|
446
|
+
});
|
|
447
|
+
if (O.current) {
|
|
448
|
+
s(r.id).catch(() => {}), M(r.id);
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
m && P(m.id) && (s(m.id).catch(() => {}), M(m.id)), j(r.id, () => s(r.id)), g("idle"), v(null);
|
|
452
|
+
let o = {
|
|
453
|
+
id: r.id,
|
|
454
|
+
filename: r.filename,
|
|
455
|
+
content_type: r.content_type,
|
|
456
|
+
size_bytes: r.size_bytes,
|
|
457
|
+
sha256: r.sha256,
|
|
458
|
+
width: r.width,
|
|
459
|
+
height: r.height,
|
|
460
|
+
url: r.url,
|
|
461
|
+
metadata: r.metadata
|
|
462
|
+
};
|
|
463
|
+
a?.(t.mode === "array" ? [o] : o);
|
|
464
|
+
} catch (e) {
|
|
465
|
+
if (e instanceof o && e.code === "ABORTED") return;
|
|
466
|
+
let t = e instanceof o ? {
|
|
467
|
+
code: e.code,
|
|
468
|
+
message: e.message
|
|
469
|
+
} : {
|
|
470
|
+
code: "UNKNOWN",
|
|
471
|
+
message: e instanceof Error ? e.message : "Upload failed"
|
|
472
|
+
};
|
|
473
|
+
b(t), g("error"), v(null);
|
|
474
|
+
}
|
|
475
|
+
}, [
|
|
476
|
+
t.accepts,
|
|
477
|
+
t.max_size_bytes,
|
|
478
|
+
t.mode,
|
|
479
|
+
n,
|
|
480
|
+
m,
|
|
481
|
+
P,
|
|
482
|
+
a,
|
|
483
|
+
e.entityCode,
|
|
484
|
+
j,
|
|
485
|
+
M,
|
|
486
|
+
f,
|
|
487
|
+
p
|
|
488
|
+
]), ne = L(() => {
|
|
489
|
+
d || A.current?.click();
|
|
490
|
+
}, [d]), G = L((e) => {
|
|
491
|
+
let t = e.target.files?.[0];
|
|
492
|
+
e.target.value = "", t && z(t);
|
|
493
|
+
}, [z]), K = L(() => {
|
|
494
|
+
m && P(m.id) && (s(m.id).catch(() => {}), M(m.id)), a?.(t.mode === "array" ? [] : null);
|
|
495
|
+
}, [
|
|
496
|
+
m,
|
|
497
|
+
t.mode,
|
|
498
|
+
P,
|
|
499
|
+
a,
|
|
500
|
+
M
|
|
501
|
+
]), q = L(() => {
|
|
502
|
+
h === "uploading" && D.current && (O.current = !0, D.current.abort(), D.current = null, g("idle"), v(null));
|
|
503
|
+
}, [h]), re = L(() => {
|
|
504
|
+
m && F(m.id, "download", k(m));
|
|
505
|
+
}, [m, F]), ie = m ? C(m) : !1, J = L(() => {
|
|
506
|
+
!m || !C(m) || F(m.id, "preview", N(m));
|
|
507
|
+
}, [m, F]), ae = L(() => {
|
|
508
|
+
if (!m) {
|
|
509
|
+
w(!1);
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
let e = T.trim();
|
|
513
|
+
if (w(!1), !e || e === m.filename) {
|
|
514
|
+
E(m.filename);
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
let n = {
|
|
518
|
+
...m,
|
|
519
|
+
filename: e
|
|
520
|
+
};
|
|
521
|
+
a?.(t.mode === "array" ? [n] : n);
|
|
522
|
+
}, [
|
|
523
|
+
T,
|
|
524
|
+
m,
|
|
525
|
+
a,
|
|
526
|
+
t.mode
|
|
527
|
+
]), Y = c === "display";
|
|
528
|
+
return !m && h !== "uploading" ? /* @__PURE__ */ W("div", {
|
|
529
|
+
"data-testid": `file-widget-${n}`,
|
|
530
|
+
className: "flex items-center gap-3 rounded-md border border-dashed border-border bg-surface p-3",
|
|
531
|
+
children: [
|
|
532
|
+
/* @__PURE__ */ U(ye, {}),
|
|
533
|
+
/* @__PURE__ */ W("div", {
|
|
534
|
+
className: "flex flex-col gap-1",
|
|
535
|
+
children: [/* @__PURE__ */ U("span", {
|
|
536
|
+
className: "text-sm text-foreground",
|
|
537
|
+
children: t.display?.placeholder || "No document attached"
|
|
538
|
+
}), !Y && /* @__PURE__ */ U("button", {
|
|
539
|
+
type: "button",
|
|
540
|
+
className: "self-start rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
|
|
541
|
+
onClick: ne,
|
|
542
|
+
disabled: d,
|
|
543
|
+
"data-testid": "upload",
|
|
544
|
+
children: "Upload"
|
|
545
|
+
})]
|
|
546
|
+
}),
|
|
547
|
+
!Y && /* @__PURE__ */ U("input", {
|
|
548
|
+
ref: A,
|
|
549
|
+
type: "file",
|
|
550
|
+
accept: I || void 0,
|
|
551
|
+
onChange: G,
|
|
552
|
+
style: { display: "none" },
|
|
553
|
+
"data-testid": `file-input-${n}`
|
|
554
|
+
}),
|
|
555
|
+
h === "error" && y && /* @__PURE__ */ U("div", {
|
|
556
|
+
className: "ml-auto text-xs text-destructive",
|
|
557
|
+
role: "alert",
|
|
558
|
+
children: y.message
|
|
559
|
+
})
|
|
560
|
+
]
|
|
561
|
+
}) : /* @__PURE__ */ W("div", {
|
|
562
|
+
"data-testid": `file-widget-${n}`,
|
|
563
|
+
className: "flex items-center gap-3 rounded-md border border-border bg-surface p-3",
|
|
564
|
+
"aria-busy": h === "uploading" || void 0,
|
|
565
|
+
"aria-invalid": h === "error" || void 0,
|
|
566
|
+
children: [
|
|
567
|
+
/* @__PURE__ */ U(ye, { contentType: m?.content_type }),
|
|
568
|
+
/* @__PURE__ */ W("div", {
|
|
569
|
+
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
570
|
+
children: [
|
|
571
|
+
x && m ? /* @__PURE__ */ U("input", {
|
|
572
|
+
type: "text",
|
|
573
|
+
className: "rounded-sm border border-border bg-card px-1 py-0.5 text-sm text-foreground",
|
|
574
|
+
value: T,
|
|
575
|
+
autoFocus: !0,
|
|
576
|
+
onChange: (e) => E(e.target.value),
|
|
577
|
+
onBlur: ae,
|
|
578
|
+
onKeyDown: (e) => {
|
|
579
|
+
e.key === "Enter" ? ae() : e.key === "Escape" && (w(!1), E(m.filename));
|
|
580
|
+
},
|
|
581
|
+
"data-testid": "filename-input"
|
|
582
|
+
}) : /* @__PURE__ */ U("button", {
|
|
583
|
+
type: "button",
|
|
584
|
+
className: "truncate text-left text-sm font-medium text-foreground hover:underline",
|
|
585
|
+
onClick: () => !Y && m && w(!0),
|
|
586
|
+
disabled: Y || d || !m,
|
|
587
|
+
title: m?.filename,
|
|
588
|
+
"data-testid": "filename",
|
|
589
|
+
children: m?.filename ?? "Uploading…"
|
|
590
|
+
}),
|
|
591
|
+
/* @__PURE__ */ W("div", {
|
|
592
|
+
className: "flex flex-wrap gap-2 text-xs text-muted-foreground",
|
|
593
|
+
children: [
|
|
594
|
+
m && /* @__PURE__ */ U("span", { children: u(m.size_bytes) }),
|
|
595
|
+
m?.page_count != null && /* @__PURE__ */ W("span", { children: [m.page_count, " pages"] }),
|
|
596
|
+
m?.uploaded_at && /* @__PURE__ */ U("span", { children: xe(m.uploaded_at) }),
|
|
597
|
+
m?.uploaded_by && /* @__PURE__ */ W("span", { children: ["by ", m.uploaded_by] }),
|
|
598
|
+
m?.version?.number != null && /* @__PURE__ */ W("span", {
|
|
599
|
+
"data-testid": "version-badge",
|
|
600
|
+
children: ["v", m.version.number]
|
|
601
|
+
})
|
|
602
|
+
]
|
|
603
|
+
}),
|
|
604
|
+
h === "uploading" && /* @__PURE__ */ W("div", {
|
|
605
|
+
className: "text-xs text-muted-foreground",
|
|
606
|
+
role: "progressbar",
|
|
607
|
+
"aria-valuenow": _?.pct ?? 0,
|
|
608
|
+
"aria-valuemin": 0,
|
|
609
|
+
"aria-valuemax": 100,
|
|
610
|
+
"data-testid": "upload-progress",
|
|
611
|
+
children: [
|
|
612
|
+
"Uploading ",
|
|
613
|
+
_?.pct ?? 0,
|
|
614
|
+
"%"
|
|
615
|
+
]
|
|
616
|
+
}),
|
|
617
|
+
h === "error" && y && /* @__PURE__ */ U("div", {
|
|
618
|
+
className: "text-xs text-destructive",
|
|
619
|
+
role: "alert",
|
|
620
|
+
children: y.message
|
|
621
|
+
})
|
|
622
|
+
]
|
|
623
|
+
}),
|
|
624
|
+
/* @__PURE__ */ W("div", {
|
|
625
|
+
className: "flex flex-none items-center gap-1",
|
|
626
|
+
children: [m && h !== "uploading" && /* @__PURE__ */ W(H, { children: [
|
|
627
|
+
/* @__PURE__ */ U("button", {
|
|
628
|
+
type: "button",
|
|
629
|
+
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
|
|
630
|
+
onClick: re,
|
|
631
|
+
"data-testid": "download",
|
|
632
|
+
children: "Download"
|
|
633
|
+
}),
|
|
634
|
+
/* @__PURE__ */ U("button", {
|
|
635
|
+
type: "button",
|
|
636
|
+
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
637
|
+
onClick: J,
|
|
638
|
+
disabled: !ie,
|
|
639
|
+
title: ie ? void 0 : "Preview is available only for images and PDFs",
|
|
640
|
+
"data-testid": "preview",
|
|
641
|
+
children: "Preview"
|
|
642
|
+
}),
|
|
643
|
+
!Y && /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U("button", {
|
|
644
|
+
type: "button",
|
|
645
|
+
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
|
|
646
|
+
onClick: ne,
|
|
647
|
+
disabled: d,
|
|
648
|
+
"data-testid": "replace",
|
|
649
|
+
children: "Replace"
|
|
650
|
+
}), /* @__PURE__ */ U("button", {
|
|
651
|
+
type: "button",
|
|
652
|
+
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-destructive hover:bg-surface-2",
|
|
653
|
+
onClick: K,
|
|
654
|
+
disabled: d,
|
|
655
|
+
"data-testid": "remove",
|
|
656
|
+
children: "Remove"
|
|
657
|
+
})] })
|
|
658
|
+
] }), h === "uploading" && /* @__PURE__ */ U("button", {
|
|
659
|
+
type: "button",
|
|
660
|
+
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs",
|
|
661
|
+
onClick: q,
|
|
662
|
+
"data-testid": "cancel-upload",
|
|
663
|
+
children: "Cancel"
|
|
664
|
+
})]
|
|
665
|
+
}),
|
|
666
|
+
!Y && /* @__PURE__ */ U("input", {
|
|
667
|
+
ref: A,
|
|
668
|
+
type: "file",
|
|
669
|
+
accept: I || void 0,
|
|
670
|
+
onChange: G,
|
|
671
|
+
style: { display: "none" },
|
|
672
|
+
"data-testid": `file-input-${n}`
|
|
673
|
+
})
|
|
674
|
+
]
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
function xe(e) {
|
|
678
|
+
let t = new Date(e);
|
|
679
|
+
return isNaN(t.getTime()) ? e : t.toISOString().slice(0, 10);
|
|
680
|
+
}
|
|
681
|
+
//#endregion
|
|
682
|
+
//#region src/components/file-widgets/FileList.tsx
|
|
683
|
+
function Se(e) {
|
|
684
|
+
return e ? (e.split("/")[1] ?? e).toUpperCase().slice(0, 6) : "";
|
|
685
|
+
}
|
|
686
|
+
function Ce(e) {
|
|
687
|
+
let { field: t, fieldName: n, value: i, onChange: a, mode: c, disabled: d } = e, f = M(i), [p, m] = V([]), { register: h, unregister: g, isDraft: _ } = l(), v = B(f);
|
|
688
|
+
v.current = f;
|
|
689
|
+
let y = B(null), b = B(/* @__PURE__ */ new Set()), x = B([]);
|
|
690
|
+
x.current = p;
|
|
691
|
+
let { open: C } = te();
|
|
692
|
+
R(() => () => {
|
|
693
|
+
x.current.forEach((e) => e.abort());
|
|
694
|
+
}, []);
|
|
695
|
+
let w = (t.accepts ?? []).join(","), T = c === "display", E = L(async (i) => {
|
|
696
|
+
let c = r(i, t.accepts, t.max_size_bytes), l = `row-${Math.random().toString(36).slice(2)}-${Date.now()}`, u = new AbortController();
|
|
697
|
+
if (c) {
|
|
698
|
+
m((e) => [...e, {
|
|
699
|
+
localId: l,
|
|
700
|
+
filename: i.name,
|
|
701
|
+
progress: null,
|
|
702
|
+
error: c,
|
|
703
|
+
abort: () => {}
|
|
704
|
+
}]);
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
m((e) => [...e, {
|
|
708
|
+
localId: l,
|
|
709
|
+
filename: i.name,
|
|
710
|
+
progress: {
|
|
711
|
+
loaded: 0,
|
|
712
|
+
total: i.size,
|
|
713
|
+
pct: 0
|
|
714
|
+
},
|
|
715
|
+
error: null,
|
|
716
|
+
abort: () => u.abort()
|
|
717
|
+
}]);
|
|
718
|
+
try {
|
|
719
|
+
let t = await S({
|
|
720
|
+
file: i,
|
|
721
|
+
entityCode: e.entityCode,
|
|
722
|
+
fieldCode: n,
|
|
723
|
+
signal: u.signal,
|
|
724
|
+
onProgress: (e) => m((t) => t.map((t) => t.localId === l ? {
|
|
725
|
+
...t,
|
|
726
|
+
progress: e
|
|
727
|
+
} : t))
|
|
728
|
+
});
|
|
729
|
+
if (b.current.delete(l)) {
|
|
730
|
+
s(t.id).catch(() => {}), g(t.id);
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
h(t.id, () => s(t.id));
|
|
734
|
+
let r = {
|
|
735
|
+
id: t.id,
|
|
736
|
+
filename: t.filename,
|
|
737
|
+
content_type: t.content_type,
|
|
738
|
+
size_bytes: t.size_bytes,
|
|
739
|
+
sha256: t.sha256,
|
|
740
|
+
width: t.width,
|
|
741
|
+
height: t.height,
|
|
742
|
+
url: t.url,
|
|
743
|
+
metadata: t.metadata
|
|
744
|
+
}, o = [...v.current, r];
|
|
745
|
+
v.current = o, a?.(o), m((e) => e.filter((e) => e.localId !== l));
|
|
746
|
+
} catch (e) {
|
|
747
|
+
if (e instanceof o && e.code === "ABORTED") {
|
|
748
|
+
m((e) => e.filter((e) => e.localId !== l));
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
let t = e instanceof o ? {
|
|
752
|
+
code: e.code,
|
|
753
|
+
message: e.message
|
|
754
|
+
} : {
|
|
755
|
+
code: "UNKNOWN",
|
|
756
|
+
message: e instanceof Error ? e.message : "Upload failed"
|
|
757
|
+
};
|
|
758
|
+
m((e) => e.map((e) => e.localId === l ? {
|
|
759
|
+
...e,
|
|
760
|
+
error: t,
|
|
761
|
+
progress: null,
|
|
762
|
+
abort: () => {}
|
|
763
|
+
} : e));
|
|
764
|
+
}
|
|
765
|
+
}, [
|
|
766
|
+
t.accepts,
|
|
767
|
+
t.max_size_bytes,
|
|
768
|
+
n,
|
|
769
|
+
a,
|
|
770
|
+
e.entityCode,
|
|
771
|
+
h,
|
|
772
|
+
g
|
|
773
|
+
]), D = L((e) => {
|
|
774
|
+
Array.from(e).forEach((e) => void E(e));
|
|
775
|
+
}, [E]), O = L(() => {
|
|
776
|
+
d || y.current?.click();
|
|
777
|
+
}, [d]), ee = L((e) => {
|
|
778
|
+
let t = e.target.files;
|
|
779
|
+
e.target.value = "", t && t.length > 0 && D(t);
|
|
780
|
+
}, [D]), A = L((e) => {
|
|
781
|
+
_(e) && (s(e).catch(() => {}), g(e)), a?.(f.filter((t) => t.id !== e));
|
|
782
|
+
}, [
|
|
783
|
+
_,
|
|
784
|
+
f,
|
|
785
|
+
a,
|
|
786
|
+
g
|
|
787
|
+
]), j = L((e) => {
|
|
788
|
+
C(e.id, "download", k(e));
|
|
789
|
+
}, [C]);
|
|
790
|
+
return /* @__PURE__ */ W("div", {
|
|
791
|
+
"data-testid": `file-widget-${n}`,
|
|
792
|
+
className: "flex flex-col gap-2",
|
|
793
|
+
children: [/* @__PURE__ */ W("ul", {
|
|
794
|
+
className: "flex flex-col divide-y divide-divider rounded-md border border-border bg-surface",
|
|
795
|
+
children: [
|
|
796
|
+
f.length === 0 && p.length === 0 && /* @__PURE__ */ U("li", {
|
|
797
|
+
className: "px-3 py-4 text-center text-sm text-muted-foreground",
|
|
798
|
+
children: t.display?.placeholder || "No files"
|
|
799
|
+
}),
|
|
800
|
+
f.map((e) => /* @__PURE__ */ W("li", {
|
|
801
|
+
className: "flex items-center gap-3 px-3 py-2",
|
|
802
|
+
"data-testid": `row-${e.id}`,
|
|
803
|
+
children: [
|
|
804
|
+
/* @__PURE__ */ U("span", {
|
|
805
|
+
className: "flex-none rounded-sm border border-border bg-surface-3 px-1.5 py-0.5 text-[10px] text-muted-foreground",
|
|
806
|
+
children: Se(e.content_type)
|
|
807
|
+
}),
|
|
808
|
+
/* @__PURE__ */ U("button", {
|
|
809
|
+
type: "button",
|
|
810
|
+
onClick: () => j(e),
|
|
811
|
+
className: "min-w-0 flex-1 truncate text-left text-sm text-foreground hover:underline",
|
|
812
|
+
title: e.filename,
|
|
813
|
+
children: e.filename
|
|
814
|
+
}),
|
|
815
|
+
/* @__PURE__ */ U("span", {
|
|
816
|
+
className: "flex-none text-xs text-muted-foreground",
|
|
817
|
+
children: u(e.size_bytes)
|
|
818
|
+
}),
|
|
819
|
+
/* @__PURE__ */ U("button", {
|
|
820
|
+
type: "button",
|
|
821
|
+
className: "flex-none rounded-sm border border-border bg-card px-2 py-0.5 text-xs text-foreground hover:bg-surface-2",
|
|
822
|
+
onClick: () => j(e),
|
|
823
|
+
"data-testid": `download-${e.id}`,
|
|
824
|
+
children: "Download"
|
|
825
|
+
}),
|
|
826
|
+
!T && /* @__PURE__ */ U("button", {
|
|
827
|
+
type: "button",
|
|
828
|
+
className: "flex-none rounded-sm border border-border bg-card px-2 py-0.5 text-xs text-destructive hover:bg-surface-2",
|
|
829
|
+
onClick: () => A(e.id),
|
|
830
|
+
disabled: d,
|
|
831
|
+
"data-testid": `remove-${e.id}`,
|
|
832
|
+
children: "Remove"
|
|
833
|
+
})
|
|
834
|
+
]
|
|
835
|
+
}, e.id)),
|
|
836
|
+
p.map((e) => /* @__PURE__ */ W("li", {
|
|
837
|
+
className: "flex items-center gap-3 px-3 py-2",
|
|
838
|
+
"data-testid": `pending-row-${e.localId}`,
|
|
839
|
+
"aria-busy": !e.error,
|
|
840
|
+
"aria-invalid": !!e.error || void 0,
|
|
841
|
+
children: [
|
|
842
|
+
/* @__PURE__ */ U("span", {
|
|
843
|
+
className: "flex-none truncate text-sm text-foreground",
|
|
844
|
+
title: e.filename,
|
|
845
|
+
children: e.filename
|
|
846
|
+
}),
|
|
847
|
+
/* @__PURE__ */ U("span", { className: "flex-1" }),
|
|
848
|
+
e.error ? /* @__PURE__ */ U("span", {
|
|
849
|
+
role: "alert",
|
|
850
|
+
className: "text-xs text-destructive",
|
|
851
|
+
children: e.error.message
|
|
852
|
+
}) : /* @__PURE__ */ W("span", {
|
|
853
|
+
className: "text-xs text-muted-foreground",
|
|
854
|
+
role: "progressbar",
|
|
855
|
+
"aria-valuenow": e.progress?.pct ?? 0,
|
|
856
|
+
"aria-valuemin": 0,
|
|
857
|
+
"aria-valuemax": 100,
|
|
858
|
+
children: [e.progress?.pct ?? 0, "%"]
|
|
859
|
+
}),
|
|
860
|
+
/* @__PURE__ */ U("button", {
|
|
861
|
+
type: "button",
|
|
862
|
+
className: "flex-none rounded-sm border border-border bg-card px-2 py-0.5 text-xs",
|
|
863
|
+
onClick: () => {
|
|
864
|
+
e.abort(), b.current.add(e.localId), m((t) => t.filter((t) => t.localId !== e.localId));
|
|
865
|
+
},
|
|
866
|
+
children: e.error ? "Dismiss" : "Cancel"
|
|
867
|
+
})
|
|
868
|
+
]
|
|
869
|
+
}, e.localId))
|
|
870
|
+
]
|
|
871
|
+
}), !T && /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U("button", {
|
|
872
|
+
type: "button",
|
|
873
|
+
className: "self-start rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
|
|
874
|
+
onClick: O,
|
|
875
|
+
disabled: d,
|
|
876
|
+
"data-testid": "add-files",
|
|
877
|
+
children: "Add files"
|
|
878
|
+
}), /* @__PURE__ */ U("input", {
|
|
879
|
+
ref: y,
|
|
880
|
+
type: "file",
|
|
881
|
+
accept: w || void 0,
|
|
882
|
+
multiple: !0,
|
|
883
|
+
onChange: ee,
|
|
884
|
+
style: { display: "none" },
|
|
885
|
+
"data-testid": `file-input-${n}`
|
|
886
|
+
})] })]
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
//#endregion
|
|
890
|
+
//#region src/components/file-widgets/LabeledSlots.tsx
|
|
891
|
+
function we(e) {
|
|
892
|
+
return !e || Array.isArray(e) || typeof e != "object" ? {} : e;
|
|
893
|
+
}
|
|
894
|
+
function Te(e) {
|
|
895
|
+
return e.split("_").filter(Boolean).map((e) => e.slice(0, 1).toUpperCase() + e.slice(1)).join(" ");
|
|
896
|
+
}
|
|
897
|
+
function Ee(e, t) {
|
|
898
|
+
return t?.content_type?.startsWith("image/") ? !0 : (e?.accepts ?? []).some((e) => e === "image/*" || e.startsWith("image/"));
|
|
899
|
+
}
|
|
900
|
+
function De(e, t, n, r) {
|
|
901
|
+
return {
|
|
902
|
+
...e,
|
|
903
|
+
name: `${e.name}.${t}`,
|
|
904
|
+
mode: "single",
|
|
905
|
+
accepts: n?.accepts ?? e.accepts,
|
|
906
|
+
max_size_bytes: n?.max_size_bytes ?? e.max_size_bytes,
|
|
907
|
+
slots: void 0,
|
|
908
|
+
display: {
|
|
909
|
+
...e.display ?? { widget: "document_card" },
|
|
910
|
+
widget: Ee(n, r) ? "square_image" : "document_card",
|
|
911
|
+
aspect_ratio: n?.aspect_ratio ?? e.display?.aspect_ratio,
|
|
912
|
+
placeholder: e.display?.placeholder ?? Te(t)
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
function Oe(e) {
|
|
917
|
+
let { field: t, fieldName: n, entityCode: r, value: i, onChange: a, mode: o, disabled: s } = e, c = Object.entries(t.slots ?? {}), l = we(i);
|
|
918
|
+
return c.length === 0 ? /* @__PURE__ */ U("span", {
|
|
919
|
+
className: "text-sm text-muted-foreground",
|
|
920
|
+
children: "No slots configured"
|
|
921
|
+
}) : /* @__PURE__ */ U("div", {
|
|
922
|
+
style: {
|
|
923
|
+
display: "grid",
|
|
924
|
+
gap: 12
|
|
925
|
+
},
|
|
926
|
+
children: c.map(([e, i]) => {
|
|
927
|
+
let c = l[e] ?? null, u = De(t, e, i, c), d = u.display?.widget ?? "document_card", f = q(d);
|
|
928
|
+
return f ? /* @__PURE__ */ W("div", {
|
|
929
|
+
style: {
|
|
930
|
+
display: "grid",
|
|
931
|
+
gap: 6
|
|
932
|
+
},
|
|
933
|
+
children: [/* @__PURE__ */ U("div", {
|
|
934
|
+
style: {
|
|
935
|
+
fontSize: 12,
|
|
936
|
+
fontWeight: 600,
|
|
937
|
+
color: "var(--text-2)"
|
|
938
|
+
},
|
|
939
|
+
children: Te(e)
|
|
940
|
+
}), /* @__PURE__ */ U(f, {
|
|
941
|
+
field: u,
|
|
942
|
+
fieldName: e,
|
|
943
|
+
entityCode: r,
|
|
944
|
+
value: c,
|
|
945
|
+
mode: o,
|
|
946
|
+
disabled: s,
|
|
947
|
+
uploadFieldCode: n,
|
|
948
|
+
uploadSlotCode: e,
|
|
949
|
+
onChange: (t) => {
|
|
950
|
+
a && a({
|
|
951
|
+
...l,
|
|
952
|
+
[e]: t ?? null
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
})]
|
|
956
|
+
}, e) : /* @__PURE__ */ W("div", {
|
|
957
|
+
style: {
|
|
958
|
+
display: "grid",
|
|
959
|
+
gap: 6
|
|
960
|
+
},
|
|
961
|
+
children: [/* @__PURE__ */ U("div", {
|
|
962
|
+
style: {
|
|
963
|
+
fontSize: 12,
|
|
964
|
+
fontWeight: 600,
|
|
965
|
+
color: "var(--text-2)"
|
|
966
|
+
},
|
|
967
|
+
children: Te(e)
|
|
968
|
+
}), /* @__PURE__ */ U("span", {
|
|
969
|
+
className: "text-sm text-muted-foreground",
|
|
970
|
+
children: `Unknown file widget: ${d}`
|
|
971
|
+
})]
|
|
972
|
+
}, e);
|
|
973
|
+
})
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
//#endregion
|
|
977
|
+
//#region src/components/file-widgets/builtins.ts
|
|
978
|
+
var ke = !1;
|
|
979
|
+
function Ae() {
|
|
980
|
+
ke ||= (K("square_image", he), K("circle_image", ge), K("wide_banner", X), K("grid", ve), K("document_card", be), K("file_list", Ce), K("labeled_slots", Oe), !0);
|
|
981
|
+
}
|
|
982
|
+
//#endregion
|
|
983
|
+
//#region src/components/file-widgets/host.tsx
|
|
984
|
+
Ae();
|
|
985
|
+
function je(e, t) {
|
|
986
|
+
return e.files?.get(t);
|
|
987
|
+
}
|
|
988
|
+
function Me(e, t) {
|
|
989
|
+
return Object.prototype.hasOwnProperty.call(e, t) ? e[t] ?? null : e.$files?.[t] ?? null;
|
|
990
|
+
}
|
|
991
|
+
function Ne(e, t, n) {
|
|
992
|
+
if (je(e, n)) return Me(t, n);
|
|
993
|
+
let r = e.fields.get(n);
|
|
994
|
+
return r?.type === "rich_text" && r.files?.mode === "rich_text_inline" ? d(t[n], Me(t, n)) : t[n];
|
|
995
|
+
}
|
|
996
|
+
function Pe(e, t, n) {
|
|
997
|
+
let r = e.fields.get(t);
|
|
998
|
+
return r?.type === "rich_text" && r.files?.mode === "rich_text_inline" ? f(n) : n;
|
|
999
|
+
}
|
|
1000
|
+
function Fe(e, t, n) {
|
|
1001
|
+
let r = je(e, t);
|
|
1002
|
+
if (r) return r.name || t;
|
|
1003
|
+
let i = e.fields.get(t);
|
|
1004
|
+
return i ? x(i, t, n) : t;
|
|
1005
|
+
}
|
|
1006
|
+
function Ie(e) {
|
|
1007
|
+
let { entity: t, entityCode: n, fieldName: r, record: i, mode: a, onChange: o, refs: s, disabled: c, surface: l, entities: u, screens: d, locale: f, fieldId: p, labelId: m, structure: h } = e, g = je(t, r);
|
|
1008
|
+
if (g) {
|
|
1009
|
+
let e = g.display?.widget ?? "", t = q(e);
|
|
1010
|
+
return t ? /* @__PURE__ */ U(t, {
|
|
1011
|
+
field: g,
|
|
1012
|
+
fieldName: r,
|
|
1013
|
+
entityCode: n,
|
|
1014
|
+
value: Me(i, r),
|
|
1015
|
+
mode: a,
|
|
1016
|
+
onChange: o,
|
|
1017
|
+
disabled: c,
|
|
1018
|
+
fieldId: p
|
|
1019
|
+
}) : /* @__PURE__ */ U("span", {
|
|
1020
|
+
className: "text-sm text-muted-foreground",
|
|
1021
|
+
children: e ? `Unknown file widget: ${e}` : "Missing file widget"
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
let _ = t.fields.get(r), v = h && a === "display" && _ ? {
|
|
1025
|
+
..._,
|
|
1026
|
+
structure: h
|
|
1027
|
+
} : _;
|
|
1028
|
+
return v ? y({
|
|
1029
|
+
field: v,
|
|
1030
|
+
entityCode: n,
|
|
1031
|
+
fieldName: r,
|
|
1032
|
+
value: Ne(t, i, r),
|
|
1033
|
+
mode: a,
|
|
1034
|
+
onChange: o,
|
|
1035
|
+
record: i,
|
|
1036
|
+
refs: s,
|
|
1037
|
+
surface: l,
|
|
1038
|
+
entity: n && u ? u[n] : void 0,
|
|
1039
|
+
entities: u,
|
|
1040
|
+
screens: d,
|
|
1041
|
+
locale: f,
|
|
1042
|
+
fieldId: p,
|
|
1043
|
+
labelId: m
|
|
1044
|
+
}) : null;
|
|
1045
|
+
}
|
|
1046
|
+
//#endregion
|
|
1047
|
+
//#region src/components/actions/ResponsiveActionBar.tsx
|
|
1048
|
+
function Le(e, t) {
|
|
1049
|
+
return e.replace(/\$\{([^}]+)\}/g, (e, n) => Object.prototype.hasOwnProperty.call(t, n) ? t[n] : e);
|
|
1050
|
+
}
|
|
1051
|
+
function Re(e) {
|
|
1052
|
+
return e.widget ? "widget" : e.href ? "href" : e.handler ? "handler" : e.association ? "association" : e.ui_steps && e.ui_steps.length > 0 ? "ui_steps" : "unknown";
|
|
1053
|
+
}
|
|
1054
|
+
function ze(e, t, n, r, i) {
|
|
1055
|
+
let a = Re(t), o = c(n, r?.entity), s = r?.entityCode ?? "";
|
|
1056
|
+
if (e === "__peek") return i?.({
|
|
1057
|
+
code: e,
|
|
1058
|
+
entity: s,
|
|
1059
|
+
mode: "peek",
|
|
1060
|
+
rowId: o
|
|
1061
|
+
}), r?.openPeek?.(n), !0;
|
|
1062
|
+
if (i?.({
|
|
1063
|
+
code: e,
|
|
1064
|
+
entity: s,
|
|
1065
|
+
mode: a,
|
|
1066
|
+
rowId: o
|
|
1067
|
+
}), a === "widget") return console.warn(`[ResponsiveActionBar] widget "${t.widget}" requested for action "${e}" but the widget registry ships in Phase 2; falling back to onRun.`), !1;
|
|
1068
|
+
if (a === "href" && r) {
|
|
1069
|
+
let e = Le(t.href ?? "", {
|
|
1070
|
+
entity: s,
|
|
1071
|
+
id: encodeURIComponent(o)
|
|
1072
|
+
}), n = e.indexOf("?");
|
|
1073
|
+
return n === -1 ? r.tabNavigate(e) : r.tabNavigate(e.slice(0, n), { search: e.slice(n + 1) }), !0;
|
|
1074
|
+
}
|
|
1075
|
+
return a === "handler" || a === "association" || a === "ui_steps" || a === "unknown" && console.warn(`[ResponsiveActionBar] no dispatch mode set on action "${e}" (none of handler/association/widget/href/ui_steps).`), !1;
|
|
1076
|
+
}
|
|
1077
|
+
function Be(e) {
|
|
1078
|
+
let t = 0;
|
|
1079
|
+
for (let n of e) n.kind === "action" ? t++ : t += Be(n.items);
|
|
1080
|
+
return t;
|
|
1081
|
+
}
|
|
1082
|
+
function Ve(e, t, n) {
|
|
1083
|
+
let r = [], i = [];
|
|
1084
|
+
for (let a of e) a.kind === "action" && Q(a.code, t, n)?.destructive ? i.push(a) : r.push(a);
|
|
1085
|
+
return {
|
|
1086
|
+
normal: r,
|
|
1087
|
+
destructive: i
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
function He(e, t, n) {
|
|
1091
|
+
let r = [], i = [], a = [];
|
|
1092
|
+
for (let o of e) {
|
|
1093
|
+
if (o.kind !== "action") {
|
|
1094
|
+
i.push(o);
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
let e = Q(o.code, t, n), s = e?.destructive === !0, c = e?.display?.primary === !0;
|
|
1098
|
+
if (s && c) {
|
|
1099
|
+
console.warn(`[ResponsiveActionBar] action "${o.code}" declares both primary and destructive; treating as destructive.`), a.push(o);
|
|
1100
|
+
continue;
|
|
1101
|
+
}
|
|
1102
|
+
if (s) {
|
|
1103
|
+
a.push(o);
|
|
1104
|
+
continue;
|
|
1105
|
+
}
|
|
1106
|
+
if (c) {
|
|
1107
|
+
r.push(o);
|
|
1108
|
+
continue;
|
|
1109
|
+
}
|
|
1110
|
+
i.push(o);
|
|
1111
|
+
}
|
|
1112
|
+
return {
|
|
1113
|
+
primary: r,
|
|
1114
|
+
regular: i,
|
|
1115
|
+
destructive: a
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
function Q(e, t, n) {
|
|
1119
|
+
if (t && e in t) return t[e];
|
|
1120
|
+
if (n && e in n) return n[e];
|
|
1121
|
+
}
|
|
1122
|
+
function Ue(e, t, n) {
|
|
1123
|
+
let r = Q(e, t, n);
|
|
1124
|
+
return i(r?.display?.name) || e;
|
|
1125
|
+
}
|
|
1126
|
+
function We(e, t, n) {
|
|
1127
|
+
return Q(e, t, n)?.display?.icon || void 0;
|
|
1128
|
+
}
|
|
1129
|
+
function Ge(e) {
|
|
1130
|
+
return `action-tooltip-${e}`;
|
|
1131
|
+
}
|
|
1132
|
+
function Ke({ leaf: e, entityActions: r, globalActions: i, onRun: a, loading: o, onLoadingChange: s, measureRef: c, style: l, row: u, widgetContext: d, onActionClick: f, iconOnly: p = !1 }) {
|
|
1133
|
+
let m = Q(e.code, r, i), h = Ue(e.code, r, i), g = We(e.code, r, i), y = m?.destructive ?? !1, b = !y && m?.display?.primary === !0, x = !e.enabled, S = x ? Ge(e.code) : void 0, C = L(async () => {
|
|
1134
|
+
if (!(!m || x || o)) {
|
|
1135
|
+
s(!0);
|
|
1136
|
+
try {
|
|
1137
|
+
ze(e.code, m, u, d, f) || await Promise.resolve(a(e.code, m));
|
|
1138
|
+
} finally {
|
|
1139
|
+
s(!1);
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
}, [
|
|
1143
|
+
m,
|
|
1144
|
+
x,
|
|
1145
|
+
o,
|
|
1146
|
+
a,
|
|
1147
|
+
e.code,
|
|
1148
|
+
s,
|
|
1149
|
+
u,
|
|
1150
|
+
d,
|
|
1151
|
+
f
|
|
1152
|
+
]), w = o ? /* @__PURE__ */ U(n, { size: 12 }) : g ? /* @__PURE__ */ U(t, {
|
|
1153
|
+
name: g,
|
|
1154
|
+
size: 12
|
|
1155
|
+
}) : null;
|
|
1156
|
+
return /* @__PURE__ */ W(H, { children: [S && e.reason && /* @__PURE__ */ U("span", {
|
|
1157
|
+
id: S,
|
|
1158
|
+
role: "tooltip",
|
|
1159
|
+
style: {
|
|
1160
|
+
position: "absolute",
|
|
1161
|
+
width: 1,
|
|
1162
|
+
height: 1,
|
|
1163
|
+
overflow: "hidden",
|
|
1164
|
+
clip: "rect(0,0,0,0)"
|
|
1165
|
+
},
|
|
1166
|
+
children: e.reason
|
|
1167
|
+
}), /* @__PURE__ */ U(_, {
|
|
1168
|
+
ref: c,
|
|
1169
|
+
kind: b ? "primary" : "default",
|
|
1170
|
+
danger: y,
|
|
1171
|
+
icon: w,
|
|
1172
|
+
disabled: x || o,
|
|
1173
|
+
"aria-disabled": x ? "true" : void 0,
|
|
1174
|
+
"aria-describedby": S,
|
|
1175
|
+
"aria-label": p ? h : void 0,
|
|
1176
|
+
title: v(m, h, x, e.reason, p),
|
|
1177
|
+
onClick: C,
|
|
1178
|
+
style: l,
|
|
1179
|
+
children: p ? null : h
|
|
1180
|
+
})] });
|
|
1181
|
+
}
|
|
1182
|
+
function qe({ group: r, entityActions: a, globalActions: o, onRun: s, loading: c, onLoadingChange: l, measureRef: u, style: d, row: f, widgetContext: m, onActionClick: h }) {
|
|
1183
|
+
let g = B(null), [v, y] = V(!1), b = r.name ? i(r.name) : "Actions", x = L((e) => {
|
|
1184
|
+
g.current = e, u?.(e);
|
|
1185
|
+
}, [u]), S = L((e, t) => (y(!1), s(e, t)), [s]);
|
|
1186
|
+
return /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U(_, {
|
|
1187
|
+
ref: x,
|
|
1188
|
+
kind: "default",
|
|
1189
|
+
icon: c == null ? r.icon ? /* @__PURE__ */ U(t, {
|
|
1190
|
+
name: r.icon,
|
|
1191
|
+
size: 12
|
|
1192
|
+
}) : void 0 : /* @__PURE__ */ U(n, { size: 12 }),
|
|
1193
|
+
iconRight: /* @__PURE__ */ U(e.down, { size: 10 }),
|
|
1194
|
+
"aria-haspopup": "menu",
|
|
1195
|
+
"aria-expanded": v ? "true" : "false",
|
|
1196
|
+
title: b,
|
|
1197
|
+
onClick: () => y((e) => !e),
|
|
1198
|
+
style: d,
|
|
1199
|
+
children: b
|
|
1200
|
+
}), /* @__PURE__ */ U(p, {
|
|
1201
|
+
open: v,
|
|
1202
|
+
anchor: g.current,
|
|
1203
|
+
onClose: () => y(!1),
|
|
1204
|
+
align: "start",
|
|
1205
|
+
width: 200,
|
|
1206
|
+
children: /* @__PURE__ */ U("div", {
|
|
1207
|
+
role: "menu",
|
|
1208
|
+
"aria-label": b,
|
|
1209
|
+
children: r.items.map((e) => e.kind === "action" ? /* @__PURE__ */ U(Je, {
|
|
1210
|
+
leaf: e,
|
|
1211
|
+
entityActions: a,
|
|
1212
|
+
globalActions: o,
|
|
1213
|
+
onRun: S,
|
|
1214
|
+
loading: c === e.code,
|
|
1215
|
+
onLoadingChange: (t) => l(t ? e.code : null),
|
|
1216
|
+
row: f,
|
|
1217
|
+
widgetContext: m,
|
|
1218
|
+
onActionClick: h
|
|
1219
|
+
}, e.code) : /* @__PURE__ */ U(Ye, {
|
|
1220
|
+
group: e,
|
|
1221
|
+
entityActions: a,
|
|
1222
|
+
globalActions: o,
|
|
1223
|
+
onRun: S,
|
|
1224
|
+
loading: c,
|
|
1225
|
+
onLoadingChange: l,
|
|
1226
|
+
row: f,
|
|
1227
|
+
widgetContext: m,
|
|
1228
|
+
onActionClick: h
|
|
1229
|
+
}, e.items[0]?.kind === "action" ? e.items[0].code : e.icon ?? "group"))
|
|
1230
|
+
})
|
|
1231
|
+
})] });
|
|
1232
|
+
}
|
|
1233
|
+
function Je({ leaf: e, entityActions: r, globalActions: i, onRun: a, loading: o, onLoadingChange: s, row: c, widgetContext: l, onActionClick: u }) {
|
|
1234
|
+
let d = Q(e.code, r, i), f = Ue(e.code, r, i), p = We(e.code, r, i), m = d?.destructive ?? !1, h = !e.enabled, g = h ? Ge(e.code) : void 0, _ = o ? /* @__PURE__ */ U(n, { size: 12 }) : p ? /* @__PURE__ */ U(t, {
|
|
1235
|
+
name: p,
|
|
1236
|
+
size: 12
|
|
1237
|
+
}) : null;
|
|
1238
|
+
return /* @__PURE__ */ W(H, { children: [g && e.reason && /* @__PURE__ */ U("span", {
|
|
1239
|
+
id: g,
|
|
1240
|
+
role: "tooltip",
|
|
1241
|
+
style: {
|
|
1242
|
+
position: "absolute",
|
|
1243
|
+
width: 1,
|
|
1244
|
+
height: 1,
|
|
1245
|
+
overflow: "hidden",
|
|
1246
|
+
clip: "rect(0,0,0,0)"
|
|
1247
|
+
},
|
|
1248
|
+
children: e.reason
|
|
1249
|
+
}), /* @__PURE__ */ W("div", {
|
|
1250
|
+
role: "menuitem",
|
|
1251
|
+
"aria-disabled": h ? "true" : void 0,
|
|
1252
|
+
"aria-describedby": g,
|
|
1253
|
+
title: v(d, f, h, e.reason),
|
|
1254
|
+
onClick: async () => {
|
|
1255
|
+
if (!(!d || h || o)) {
|
|
1256
|
+
s(!0);
|
|
1257
|
+
try {
|
|
1258
|
+
ze(e.code, d, c, l, u) || await Promise.resolve(a(e.code, d));
|
|
1259
|
+
} finally {
|
|
1260
|
+
s(!1);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
},
|
|
1264
|
+
style: {
|
|
1265
|
+
display: "flex",
|
|
1266
|
+
alignItems: "center",
|
|
1267
|
+
gap: 8,
|
|
1268
|
+
padding: "6px 10px",
|
|
1269
|
+
borderRadius: 5,
|
|
1270
|
+
fontSize: 12.5,
|
|
1271
|
+
color: m ? "var(--danger)" : h ? "var(--text-3)" : "var(--text-2)",
|
|
1272
|
+
cursor: h ? "not-allowed" : "pointer",
|
|
1273
|
+
opacity: h ? .6 : 1
|
|
1274
|
+
},
|
|
1275
|
+
onMouseEnter: (e) => {
|
|
1276
|
+
h || (e.currentTarget.style.background = "var(--surface-3)");
|
|
1277
|
+
},
|
|
1278
|
+
onMouseLeave: (e) => {
|
|
1279
|
+
e.currentTarget.style.background = "transparent";
|
|
1280
|
+
},
|
|
1281
|
+
children: [_ && /* @__PURE__ */ U("span", {
|
|
1282
|
+
style: {
|
|
1283
|
+
color: m ? "var(--danger)" : "var(--text-3)",
|
|
1284
|
+
display: "flex"
|
|
1285
|
+
},
|
|
1286
|
+
children: _
|
|
1287
|
+
}), /* @__PURE__ */ U("span", {
|
|
1288
|
+
style: { flex: 1 },
|
|
1289
|
+
children: f
|
|
1290
|
+
})]
|
|
1291
|
+
})] });
|
|
1292
|
+
}
|
|
1293
|
+
function Ye({ group: e, entityActions: t, globalActions: n, onRun: r, loading: a, onLoadingChange: o, row: s, widgetContext: c, onActionClick: l }) {
|
|
1294
|
+
let u = e.name ? i(e.name) : void 0;
|
|
1295
|
+
return /* @__PURE__ */ W(H, { children: [u && /* @__PURE__ */ U("div", {
|
|
1296
|
+
style: {
|
|
1297
|
+
padding: "4px 10px 2px",
|
|
1298
|
+
fontSize: 10.5,
|
|
1299
|
+
fontWeight: 600,
|
|
1300
|
+
color: "var(--text-3)",
|
|
1301
|
+
textTransform: "uppercase",
|
|
1302
|
+
letterSpacing: "0.05em"
|
|
1303
|
+
},
|
|
1304
|
+
children: u
|
|
1305
|
+
}), e.items.map((e) => e.kind === "action" ? /* @__PURE__ */ U(Je, {
|
|
1306
|
+
leaf: e,
|
|
1307
|
+
entityActions: t,
|
|
1308
|
+
globalActions: n,
|
|
1309
|
+
onRun: r,
|
|
1310
|
+
loading: a === e.code,
|
|
1311
|
+
onLoadingChange: (t) => o(t ? e.code : null),
|
|
1312
|
+
row: s,
|
|
1313
|
+
widgetContext: c,
|
|
1314
|
+
onActionClick: l
|
|
1315
|
+
}, e.code) : /* @__PURE__ */ U(Ye, {
|
|
1316
|
+
group: e,
|
|
1317
|
+
entityActions: t,
|
|
1318
|
+
globalActions: n,
|
|
1319
|
+
onRun: r,
|
|
1320
|
+
loading: a,
|
|
1321
|
+
onLoadingChange: o,
|
|
1322
|
+
row: s,
|
|
1323
|
+
widgetContext: c,
|
|
1324
|
+
onActionClick: l
|
|
1325
|
+
}, e.icon ?? "nested"))] });
|
|
1326
|
+
}
|
|
1327
|
+
function Xe({ layout: t, entityActions: r, globalActions: i, onRun: a, row: o, widgetContext: s, onActionClick: c }) {
|
|
1328
|
+
let l = B(null), [u, d] = V(!1), [f, m] = V(null), g = L((e, t) => (d(!1), a(e, t)), [a]);
|
|
1329
|
+
return Be(t) === 0 ? null : /* @__PURE__ */ W("div", {
|
|
1330
|
+
"data-open": u ? "true" : void 0,
|
|
1331
|
+
style: {
|
|
1332
|
+
display: "inline-flex",
|
|
1333
|
+
alignItems: "center"
|
|
1334
|
+
},
|
|
1335
|
+
children: [/* @__PURE__ */ U(h, {
|
|
1336
|
+
ref: l,
|
|
1337
|
+
icon: U(f == null ? e.more : n, { size: 14 }),
|
|
1338
|
+
title: "Actions",
|
|
1339
|
+
size: 28,
|
|
1340
|
+
onClick: () => d((e) => !e)
|
|
1341
|
+
}), /* @__PURE__ */ U(p, {
|
|
1342
|
+
open: u,
|
|
1343
|
+
anchor: l.current,
|
|
1344
|
+
onClose: () => d(!1),
|
|
1345
|
+
align: "end",
|
|
1346
|
+
width: 220,
|
|
1347
|
+
children: /* @__PURE__ */ U(Qe, {
|
|
1348
|
+
layout: t,
|
|
1349
|
+
entityActions: r,
|
|
1350
|
+
globalActions: i,
|
|
1351
|
+
onRun: g,
|
|
1352
|
+
loading: f,
|
|
1353
|
+
onLoadingChange: m,
|
|
1354
|
+
row: o,
|
|
1355
|
+
widgetContext: s,
|
|
1356
|
+
onActionClick: c
|
|
1357
|
+
})
|
|
1358
|
+
})]
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
function Ze(e) {
|
|
1362
|
+
let t = 0;
|
|
1363
|
+
for (let n of e) if (n.kind === "action" && a(n.code)) t++;
|
|
1364
|
+
else break;
|
|
1365
|
+
return t;
|
|
1366
|
+
}
|
|
1367
|
+
function Qe({ layout: e, entityActions: t, globalActions: n, onRun: r, loading: i, onLoadingChange: a, row: o, widgetContext: s, onActionClick: c, ariaLabel: l = "Row actions" }) {
|
|
1368
|
+
let { normal: u, destructive: d } = Ve(e, t, n), f = Ze(u), p = u.slice(0, f), m = u.slice(f), h = d.length > 0, _ = m.length > 0, v = (e) => /* @__PURE__ */ U(Je, {
|
|
1369
|
+
leaf: e,
|
|
1370
|
+
entityActions: t,
|
|
1371
|
+
globalActions: n,
|
|
1372
|
+
onRun: r,
|
|
1373
|
+
loading: i === e.code,
|
|
1374
|
+
onLoadingChange: (t) => a(t ? e.code : null),
|
|
1375
|
+
row: o,
|
|
1376
|
+
widgetContext: s,
|
|
1377
|
+
onActionClick: c
|
|
1378
|
+
}, e.code);
|
|
1379
|
+
return /* @__PURE__ */ W("div", {
|
|
1380
|
+
role: "menu",
|
|
1381
|
+
"aria-label": l,
|
|
1382
|
+
children: [
|
|
1383
|
+
p.map((e) => e.kind === "action" ? v(e) : null),
|
|
1384
|
+
p.length > 0 && _ && /* @__PURE__ */ U(g, { divider: !0 }),
|
|
1385
|
+
m.map((e) => e.kind === "action" ? v(e) : /* @__PURE__ */ U(Ye, {
|
|
1386
|
+
group: e,
|
|
1387
|
+
entityActions: t,
|
|
1388
|
+
globalActions: n,
|
|
1389
|
+
onRun: r,
|
|
1390
|
+
loading: i,
|
|
1391
|
+
onLoadingChange: a,
|
|
1392
|
+
row: o,
|
|
1393
|
+
widgetContext: s,
|
|
1394
|
+
onActionClick: c
|
|
1395
|
+
}, e.icon ?? "group")),
|
|
1396
|
+
h && /* @__PURE__ */ U(g, { divider: !0 }),
|
|
1397
|
+
d.map((e) => v(e))
|
|
1398
|
+
]
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
var $e = "__overflow_trigger__", et = 90, tt = 4, nt = 8;
|
|
1402
|
+
function rt(e) {
|
|
1403
|
+
return `icon:${$(e)}`;
|
|
1404
|
+
}
|
|
1405
|
+
function it() {
|
|
1406
|
+
return nt;
|
|
1407
|
+
}
|
|
1408
|
+
function at(e, t, n) {
|
|
1409
|
+
return [
|
|
1410
|
+
...e,
|
|
1411
|
+
...t,
|
|
1412
|
+
...n
|
|
1413
|
+
];
|
|
1414
|
+
}
|
|
1415
|
+
var ot = () => {}, st = () => Promise.resolve();
|
|
1416
|
+
function ct(e) {
|
|
1417
|
+
return (t) => {
|
|
1418
|
+
t && (t.setAttribute("data-node-key", e), t.setAttribute("tabindex", "-1"));
|
|
1419
|
+
};
|
|
1420
|
+
}
|
|
1421
|
+
function lt(e, t) {
|
|
1422
|
+
if (e.size !== t.size) return !1;
|
|
1423
|
+
for (let [n, r] of t) if (e.get(n) !== r) return !1;
|
|
1424
|
+
return !0;
|
|
1425
|
+
}
|
|
1426
|
+
function ut(e, t) {
|
|
1427
|
+
return t.get($(e)) ?? 0;
|
|
1428
|
+
}
|
|
1429
|
+
function dt(e, t) {
|
|
1430
|
+
return t.get(rt(e));
|
|
1431
|
+
}
|
|
1432
|
+
function ft(e, t, n, r, i, a, o, s, c) {
|
|
1433
|
+
let { primary: l, regular: u, destructive: d } = He(e, i, a), f = tt, p = r.get($e) ?? et, m = t - n, h = at(l, u, d), g = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Set();
|
|
1434
|
+
if (o) for (let e of h) o(e) && g.add($(e));
|
|
1435
|
+
else {
|
|
1436
|
+
let e = (e, t) => t ? dt(e, r) ?? ut(e, r) : ut(e, r), t = (e) => s ? e.filter((e) => !s.has($(e))).length * it() : 0, n = (e, t) => c ? e.slice(0, t).filter((e) => c.has($(e))).length * it() : 0, i = (r, i) => {
|
|
1437
|
+
let a = r.length < h.length ? p + f : 0, o = r.length > 1 ? (r.length - 1) * f : 0;
|
|
1438
|
+
return r.reduce((t, n, r) => t + e(n, r >= i), 0) + o + a + t(r) + n(r, i) <= m;
|
|
1439
|
+
}, a = 0, o = !1;
|
|
1440
|
+
for (let e = h.length; e >= 1 && a === 0; e--) i(h.slice(0, e), 1) ? a = e : i(h.slice(0, e), 0) && (a = e, o = !0);
|
|
1441
|
+
let l = o ? 0 : Math.min(1, a), u = h.slice(0, a);
|
|
1442
|
+
for (; l < a && i(u, l + 1);) l++;
|
|
1443
|
+
u.forEach((e, t) => {
|
|
1444
|
+
let n = $(e);
|
|
1445
|
+
g.add(n), t >= l && _.add(n);
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
let v = (e) => g.has($(e)), y = [
|
|
1449
|
+
...l,
|
|
1450
|
+
...u,
|
|
1451
|
+
...d
|
|
1452
|
+
].filter((e) => !v(e));
|
|
1453
|
+
return {
|
|
1454
|
+
primaryInline: l.filter(v),
|
|
1455
|
+
inline: u.filter(v),
|
|
1456
|
+
overflow: y,
|
|
1457
|
+
destructiveInline: d.filter(v),
|
|
1458
|
+
iconOnly: _
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
function $(e) {
|
|
1462
|
+
return e.kind === "action" ? `action:${e.code}` : `group:${e.name ? i(e.name) : ""}`;
|
|
1463
|
+
}
|
|
1464
|
+
function pt(e) {
|
|
1465
|
+
let t = e.parentElement;
|
|
1466
|
+
for (; t && getComputedStyle(t).display === "contents";) t = t.parentElement;
|
|
1467
|
+
if (!t) return !1;
|
|
1468
|
+
let n = getComputedStyle(t);
|
|
1469
|
+
return !(parseFloat(n.flexGrow) > 0 || n.display === "block" || n.display === "flow-root" || n.width !== "auto" || n.maxWidth !== "none");
|
|
1470
|
+
}
|
|
1471
|
+
function mt({ layout: t, entityActions: n, globalActions: r, onRun: i, reservedRightWidth: a = 0, measurementOverride: o, ariaLabel: s = "Actions", align: c = "trailing", constrain: l = !0, row: u, widgetContext: d, onActionClick: f }) {
|
|
1472
|
+
let m = B(null), h = B(null), [v, y] = V(0), [b, x] = V(/* @__PURE__ */ new Map()), [S, C] = V(!1), [w, T] = V(null), [E, D] = V(() => typeof document < "u" && document.documentElement.dir === "rtl");
|
|
1473
|
+
R(() => {
|
|
1474
|
+
if (typeof MutationObserver > "u") return;
|
|
1475
|
+
let e = new MutationObserver((e) => {
|
|
1476
|
+
for (let t of e) t.attributeName === "dir" && D(document.documentElement.dir === "rtl"), t.attributeName === "lang" && C(!1);
|
|
1477
|
+
});
|
|
1478
|
+
return e.observe(document.documentElement, {
|
|
1479
|
+
attributes: !0,
|
|
1480
|
+
attributeFilter: ["dir", "lang"]
|
|
1481
|
+
}), () => e.disconnect();
|
|
1482
|
+
}, []);
|
|
1483
|
+
let O = B(null), [ee, k] = V(!1), A = L((e, t) => (k(!1), i(e, t)), [i]), te = Be(t), j = !!o, M = L(() => {
|
|
1484
|
+
if (j || !h.current) return;
|
|
1485
|
+
let e = Array.from(h.current.children), t = /* @__PURE__ */ new Map();
|
|
1486
|
+
e.forEach((e) => {
|
|
1487
|
+
let n = e.dataset.nodeKey;
|
|
1488
|
+
n && t.set(n, e.getBoundingClientRect().width || e.offsetWidth);
|
|
1489
|
+
}), x((e) => lt(e, t) ? e : t), C(!0);
|
|
1490
|
+
}, [j]), N = ne(() => JSON.stringify(t.map((e) => $(e))), [t]);
|
|
1491
|
+
R(() => {
|
|
1492
|
+
if (j) return;
|
|
1493
|
+
let e = h.current;
|
|
1494
|
+
if (!e || typeof ResizeObserver > "u") return;
|
|
1495
|
+
let t = new ResizeObserver(() => M());
|
|
1496
|
+
t.observe(e);
|
|
1497
|
+
for (let n of Array.from(e.children)) t.observe(n);
|
|
1498
|
+
return () => t.disconnect();
|
|
1499
|
+
}, [
|
|
1500
|
+
M,
|
|
1501
|
+
j,
|
|
1502
|
+
N
|
|
1503
|
+
]), z(() => {
|
|
1504
|
+
if (j) {
|
|
1505
|
+
C(!0);
|
|
1506
|
+
return;
|
|
1507
|
+
}
|
|
1508
|
+
C(!1);
|
|
1509
|
+
let e = requestAnimationFrame(() => {
|
|
1510
|
+
M();
|
|
1511
|
+
});
|
|
1512
|
+
return () => cancelAnimationFrame(e);
|
|
1513
|
+
}, [
|
|
1514
|
+
N,
|
|
1515
|
+
M,
|
|
1516
|
+
j
|
|
1517
|
+
]), R(() => {
|
|
1518
|
+
if (j || S) return;
|
|
1519
|
+
let e = setTimeout(() => {
|
|
1520
|
+
M(), C(!0);
|
|
1521
|
+
}, 16);
|
|
1522
|
+
return () => clearTimeout(e);
|
|
1523
|
+
}, [
|
|
1524
|
+
S,
|
|
1525
|
+
M,
|
|
1526
|
+
j
|
|
1527
|
+
]), R(() => {
|
|
1528
|
+
if (j || !l || !S || v === 0) return;
|
|
1529
|
+
let e = m.current;
|
|
1530
|
+
if (!e || !pt(e)) return;
|
|
1531
|
+
let t = [...e.children].filter((e) => e.getAttribute("aria-hidden") !== "true"), n = t.length > 1 ? (t.length - 1) * 4 : 0, r = t.reduce((e, t) => e + t.getBoundingClientRect().width, 0) + n;
|
|
1532
|
+
r > 0 && Math.abs(v - r) < 1 && console.error(`[declarion] ResponsiveActionBar is measuring itself: its container is ${Math.round(v)}px, exactly the width of what it just rendered. The slot holding this bar is sized by its own content, so it cannot tell the bar how much room there is. Give that slot \`flex: 1 1 auto; min-width: 0\` (and justify its content to the edge the buttons sit on), or pass \`constrain={false}\` if it genuinely has no row to take space from.`);
|
|
1533
|
+
}, [
|
|
1534
|
+
j,
|
|
1535
|
+
l,
|
|
1536
|
+
S,
|
|
1537
|
+
v,
|
|
1538
|
+
b
|
|
1539
|
+
]), R(() => {
|
|
1540
|
+
if (j) return;
|
|
1541
|
+
let e = m.current;
|
|
1542
|
+
if (!e) return;
|
|
1543
|
+
if (typeof ResizeObserver > "u") {
|
|
1544
|
+
y(e.getBoundingClientRect().width);
|
|
1545
|
+
return;
|
|
1546
|
+
}
|
|
1547
|
+
let t = new ResizeObserver((e) => {
|
|
1548
|
+
let t = e[0];
|
|
1549
|
+
t && y(t.contentRect.width);
|
|
1550
|
+
});
|
|
1551
|
+
return t.observe(e), y(e.getBoundingClientRect().width), () => t.disconnect();
|
|
1552
|
+
}, [j]);
|
|
1553
|
+
let F = B(void 0), I = B(void 0);
|
|
1554
|
+
R(() => {
|
|
1555
|
+
F.current = void 0, I.current = void 0;
|
|
1556
|
+
}, [N]);
|
|
1557
|
+
let G = ne(() => j || !l ? ft(t, 2 ** 53 - 1, a, b, n, r, o) : S ? v === 0 ? ft(t, 2 ** 53 - 1, a, b, n, r, o) : ft(t, v, a, b, n, r, o, F.current, I.current) : {
|
|
1558
|
+
primaryInline: [],
|
|
1559
|
+
inline: [],
|
|
1560
|
+
overflow: [],
|
|
1561
|
+
destructiveInline: [],
|
|
1562
|
+
iconOnly: /* @__PURE__ */ new Set()
|
|
1563
|
+
}, [
|
|
1564
|
+
j,
|
|
1565
|
+
l,
|
|
1566
|
+
S,
|
|
1567
|
+
v,
|
|
1568
|
+
t,
|
|
1569
|
+
a,
|
|
1570
|
+
b,
|
|
1571
|
+
n,
|
|
1572
|
+
r,
|
|
1573
|
+
o
|
|
1574
|
+
]);
|
|
1575
|
+
if (R(() => {
|
|
1576
|
+
!S && !j || (F.current = new Set([
|
|
1577
|
+
...G.primaryInline,
|
|
1578
|
+
...G.inline,
|
|
1579
|
+
...G.destructiveInline
|
|
1580
|
+
].map($)), I.current = new Set(G.iconOnly));
|
|
1581
|
+
}, [
|
|
1582
|
+
G,
|
|
1583
|
+
S,
|
|
1584
|
+
j
|
|
1585
|
+
]), te === 0) return null;
|
|
1586
|
+
let K = G.overflow.length > 0, { normal: q, destructive: re } = Ve(G.overflow, n, r);
|
|
1587
|
+
return /* @__PURE__ */ W("div", {
|
|
1588
|
+
ref: m,
|
|
1589
|
+
role: "toolbar",
|
|
1590
|
+
"aria-label": s,
|
|
1591
|
+
style: {
|
|
1592
|
+
display: "flex",
|
|
1593
|
+
flexDirection: E ? "row-reverse" : "row",
|
|
1594
|
+
alignItems: "center",
|
|
1595
|
+
gap: tt,
|
|
1596
|
+
flexWrap: "wrap",
|
|
1597
|
+
visibility: S || j ? "visible" : "hidden",
|
|
1598
|
+
position: "relative",
|
|
1599
|
+
flex: l ? "1 1 auto" : "0 1 auto",
|
|
1600
|
+
justifyContent: c === "trailing" ? "flex-end" : "flex-start",
|
|
1601
|
+
minWidth: 0,
|
|
1602
|
+
boxSizing: "border-box"
|
|
1603
|
+
},
|
|
1604
|
+
children: [
|
|
1605
|
+
/* @__PURE__ */ W("div", {
|
|
1606
|
+
ref: h,
|
|
1607
|
+
"aria-hidden": "true",
|
|
1608
|
+
inert: !0,
|
|
1609
|
+
style: {
|
|
1610
|
+
position: "absolute",
|
|
1611
|
+
visibility: "hidden",
|
|
1612
|
+
pointerEvents: "none",
|
|
1613
|
+
display: "flex",
|
|
1614
|
+
gap: 4,
|
|
1615
|
+
top: 0,
|
|
1616
|
+
left: 0,
|
|
1617
|
+
width: "max-content",
|
|
1618
|
+
flexWrap: "nowrap"
|
|
1619
|
+
},
|
|
1620
|
+
children: [/* @__PURE__ */ U(_, {
|
|
1621
|
+
"data-node-key": $e,
|
|
1622
|
+
iconRight: /* @__PURE__ */ U(e.down, { size: 10 }),
|
|
1623
|
+
tabIndex: -1,
|
|
1624
|
+
children: "Actions"
|
|
1625
|
+
}, $e), t.map((e) => {
|
|
1626
|
+
let t = $(e);
|
|
1627
|
+
return e.kind === "action" ? /* @__PURE__ */ W(P, { children: [/* @__PURE__ */ U(Ke, {
|
|
1628
|
+
leaf: e,
|
|
1629
|
+
entityActions: n,
|
|
1630
|
+
globalActions: r,
|
|
1631
|
+
onRun: st,
|
|
1632
|
+
loading: !1,
|
|
1633
|
+
onLoadingChange: ot,
|
|
1634
|
+
row: u,
|
|
1635
|
+
widgetContext: d,
|
|
1636
|
+
measureRef: ct(t)
|
|
1637
|
+
}), We(e.code, n, r) && /* @__PURE__ */ U(Ke, {
|
|
1638
|
+
leaf: e,
|
|
1639
|
+
entityActions: n,
|
|
1640
|
+
globalActions: r,
|
|
1641
|
+
onRun: st,
|
|
1642
|
+
loading: !1,
|
|
1643
|
+
onLoadingChange: ot,
|
|
1644
|
+
row: u,
|
|
1645
|
+
widgetContext: d,
|
|
1646
|
+
iconOnly: !0,
|
|
1647
|
+
measureRef: ct(rt(e))
|
|
1648
|
+
})] }, t) : /* @__PURE__ */ U(qe, {
|
|
1649
|
+
group: e,
|
|
1650
|
+
entityActions: n,
|
|
1651
|
+
globalActions: r,
|
|
1652
|
+
onRun: st,
|
|
1653
|
+
loading: null,
|
|
1654
|
+
onLoadingChange: ot,
|
|
1655
|
+
row: u,
|
|
1656
|
+
widgetContext: d,
|
|
1657
|
+
onActionClick: f,
|
|
1658
|
+
measureRef: ct(t)
|
|
1659
|
+
}, t);
|
|
1660
|
+
})]
|
|
1661
|
+
}),
|
|
1662
|
+
G.primaryInline.map((e) => /* @__PURE__ */ U(Ke, {
|
|
1663
|
+
leaf: e,
|
|
1664
|
+
entityActions: n,
|
|
1665
|
+
globalActions: r,
|
|
1666
|
+
onRun: i,
|
|
1667
|
+
loading: w === e.code,
|
|
1668
|
+
onLoadingChange: (t) => T(t ? e.code : null),
|
|
1669
|
+
row: u,
|
|
1670
|
+
widgetContext: d,
|
|
1671
|
+
onActionClick: f,
|
|
1672
|
+
iconOnly: G.iconOnly.has($(e))
|
|
1673
|
+
}, $(e))),
|
|
1674
|
+
G.inline.map((e) => {
|
|
1675
|
+
let t = $(e);
|
|
1676
|
+
return e.kind === "action" ? /* @__PURE__ */ U(Ke, {
|
|
1677
|
+
leaf: e,
|
|
1678
|
+
entityActions: n,
|
|
1679
|
+
globalActions: r,
|
|
1680
|
+
onRun: i,
|
|
1681
|
+
loading: w === e.code,
|
|
1682
|
+
onLoadingChange: (t) => T(t ? e.code : null),
|
|
1683
|
+
row: u,
|
|
1684
|
+
widgetContext: d,
|
|
1685
|
+
onActionClick: f,
|
|
1686
|
+
iconOnly: G.iconOnly.has(t)
|
|
1687
|
+
}, t) : /* @__PURE__ */ U(qe, {
|
|
1688
|
+
group: e,
|
|
1689
|
+
entityActions: n,
|
|
1690
|
+
globalActions: r,
|
|
1691
|
+
onRun: i,
|
|
1692
|
+
loading: w,
|
|
1693
|
+
onLoadingChange: T,
|
|
1694
|
+
row: u,
|
|
1695
|
+
widgetContext: d,
|
|
1696
|
+
onActionClick: f
|
|
1697
|
+
}, t);
|
|
1698
|
+
}),
|
|
1699
|
+
K && /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U(_, {
|
|
1700
|
+
ref: O,
|
|
1701
|
+
kind: "default",
|
|
1702
|
+
iconRight: /* @__PURE__ */ U(e.down, { size: 10 }),
|
|
1703
|
+
"aria-haspopup": "menu",
|
|
1704
|
+
"aria-expanded": ee ? "true" : "false",
|
|
1705
|
+
onClick: () => k((e) => !e),
|
|
1706
|
+
children: "Actions"
|
|
1707
|
+
}), /* @__PURE__ */ U(p, {
|
|
1708
|
+
open: ee,
|
|
1709
|
+
anchor: O.current,
|
|
1710
|
+
onClose: () => k(!1),
|
|
1711
|
+
align: E ? "start" : "end",
|
|
1712
|
+
width: 220,
|
|
1713
|
+
children: /* @__PURE__ */ U("div", {
|
|
1714
|
+
role: "menu",
|
|
1715
|
+
"aria-label": "More actions",
|
|
1716
|
+
children: [
|
|
1717
|
+
...q,
|
|
1718
|
+
...re.length > 0 ? [null] : [],
|
|
1719
|
+
...re
|
|
1720
|
+
].map((e, t) => e === null ? /* @__PURE__ */ U(g, { divider: !0 }, "destructive-divider") : e.kind === "action" ? /* @__PURE__ */ U(Je, {
|
|
1721
|
+
leaf: e,
|
|
1722
|
+
entityActions: n,
|
|
1723
|
+
globalActions: r,
|
|
1724
|
+
onRun: A,
|
|
1725
|
+
loading: w === e.code,
|
|
1726
|
+
onLoadingChange: (t) => T(t ? e.code : null),
|
|
1727
|
+
row: u,
|
|
1728
|
+
widgetContext: d,
|
|
1729
|
+
onActionClick: f
|
|
1730
|
+
}, e.code) : /* @__PURE__ */ U(Ye, {
|
|
1731
|
+
group: e,
|
|
1732
|
+
entityActions: n,
|
|
1733
|
+
globalActions: r,
|
|
1734
|
+
onRun: A,
|
|
1735
|
+
loading: w,
|
|
1736
|
+
onLoadingChange: T,
|
|
1737
|
+
row: u,
|
|
1738
|
+
widgetContext: d,
|
|
1739
|
+
onActionClick: f
|
|
1740
|
+
}, `${$(e)}-${t}`))
|
|
1741
|
+
})
|
|
1742
|
+
})] }),
|
|
1743
|
+
G.destructiveInline.map((e) => /* @__PURE__ */ U(Ke, {
|
|
1744
|
+
leaf: e,
|
|
1745
|
+
entityActions: n,
|
|
1746
|
+
globalActions: r,
|
|
1747
|
+
onRun: i,
|
|
1748
|
+
loading: w === e.code,
|
|
1749
|
+
onLoadingChange: (t) => T(t ? e.code : null),
|
|
1750
|
+
row: u,
|
|
1751
|
+
widgetContext: d,
|
|
1752
|
+
onActionClick: f,
|
|
1753
|
+
iconOnly: G.iconOnly.has($(e))
|
|
1754
|
+
}, $(e)))
|
|
1755
|
+
]
|
|
1756
|
+
});
|
|
1757
|
+
}
|
|
1758
|
+
function ht({ layout: e, rowSelection: t = [], ...n }) {
|
|
1759
|
+
let r = t.length > 0;
|
|
1760
|
+
return /* @__PURE__ */ W("div", {
|
|
1761
|
+
style: {
|
|
1762
|
+
position: "relative",
|
|
1763
|
+
display: "flex",
|
|
1764
|
+
flex: "1 1 auto",
|
|
1765
|
+
minWidth: 0
|
|
1766
|
+
},
|
|
1767
|
+
children: [/* @__PURE__ */ U("div", {
|
|
1768
|
+
"aria-hidden": r ? "true" : void 0,
|
|
1769
|
+
style: {
|
|
1770
|
+
display: r ? "none" : "flex",
|
|
1771
|
+
flex: "1 1 auto",
|
|
1772
|
+
minWidth: 0
|
|
1773
|
+
},
|
|
1774
|
+
children: /* @__PURE__ */ U(mt, {
|
|
1775
|
+
layout: e,
|
|
1776
|
+
rowSelection: [],
|
|
1777
|
+
...n
|
|
1778
|
+
})
|
|
1779
|
+
}), /* @__PURE__ */ U("div", {
|
|
1780
|
+
"aria-hidden": r ? void 0 : "true",
|
|
1781
|
+
style: {
|
|
1782
|
+
display: r ? "flex" : "none",
|
|
1783
|
+
flex: "1 1 auto",
|
|
1784
|
+
minWidth: 0
|
|
1785
|
+
},
|
|
1786
|
+
children: /* @__PURE__ */ U(mt, {
|
|
1787
|
+
layout: e,
|
|
1788
|
+
rowSelection: t,
|
|
1789
|
+
...n
|
|
1790
|
+
})
|
|
1791
|
+
})]
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
function gt({ layout: e, row: t, rowSelection: n, onRun: r, reservedRightWidth: i = 0, kind: a = "toolbar", align: o = "trailing", constrain: s = !0, measurementOverride: c, entityActions: l, globalActions: u, ariaLabel: d = "Actions", widgetContext: f, onActionClick: p }) {
|
|
1795
|
+
let m = Be(e);
|
|
1796
|
+
return a === "row" ? /* @__PURE__ */ U(Xe, {
|
|
1797
|
+
layout: e,
|
|
1798
|
+
entityActions: l,
|
|
1799
|
+
globalActions: u,
|
|
1800
|
+
onRun: r,
|
|
1801
|
+
row: t,
|
|
1802
|
+
widgetContext: f,
|
|
1803
|
+
onActionClick: p
|
|
1804
|
+
}) : m === 0 ? null : U(a === "toolbar" ? ht : mt, {
|
|
1805
|
+
layout: e,
|
|
1806
|
+
row: t,
|
|
1807
|
+
rowSelection: n,
|
|
1808
|
+
onRun: r,
|
|
1809
|
+
reservedRightWidth: i,
|
|
1810
|
+
measurementOverride: c,
|
|
1811
|
+
entityActions: l,
|
|
1812
|
+
globalActions: u,
|
|
1813
|
+
ariaLabel: d,
|
|
1814
|
+
align: o,
|
|
1815
|
+
constrain: s,
|
|
1816
|
+
widgetContext: f,
|
|
1817
|
+
onActionClick: p
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
//#endregion
|
|
1821
|
+
//#region src/lib/filter-evaluator.ts
|
|
1822
|
+
var _t = /* @__PURE__ */ new Set([
|
|
1823
|
+
"string",
|
|
1824
|
+
"text",
|
|
1825
|
+
"rich_text",
|
|
1826
|
+
"email",
|
|
1827
|
+
"url",
|
|
1828
|
+
"phone"
|
|
1829
|
+
]), vt = /* @__PURE__ */ new Set([
|
|
1830
|
+
"int",
|
|
1831
|
+
"float",
|
|
1832
|
+
"decimal"
|
|
1833
|
+
]), yt = /* @__PURE__ */ new Set([
|
|
1834
|
+
"date",
|
|
1835
|
+
"timestamp",
|
|
1836
|
+
"time"
|
|
1837
|
+
]), bt = /^(?:eq|not_eq|contains|starts_with|is_empty|is_not_empty)$/, xt = /^(?:eq|not_eq|in|not_in|is_empty|is_not_empty)$/, St = /^(?:eq|not_eq|gt|gte|lt|lte|between|is_empty|is_not_empty)$/, Ct = {
|
|
1838
|
+
string: bt,
|
|
1839
|
+
text: bt,
|
|
1840
|
+
rich_text: bt,
|
|
1841
|
+
email: bt,
|
|
1842
|
+
url: bt,
|
|
1843
|
+
phone: bt,
|
|
1844
|
+
enum: xt,
|
|
1845
|
+
int: St,
|
|
1846
|
+
float: St,
|
|
1847
|
+
decimal: St,
|
|
1848
|
+
date: St,
|
|
1849
|
+
timestamp: St,
|
|
1850
|
+
time: St,
|
|
1851
|
+
bool: /^(?:eq|is_empty)$/,
|
|
1852
|
+
ref: /^(?:eq|not_eq|is_empty|is_not_empty)$/,
|
|
1853
|
+
uuid: /^(?:eq|not_eq|is_empty|is_not_empty)$/
|
|
1854
|
+
};
|
|
1855
|
+
function wt(e, t, n) {
|
|
1856
|
+
return e.every((e) => Tt(e, t, n));
|
|
1857
|
+
}
|
|
1858
|
+
function Tt(e, t, n) {
|
|
1859
|
+
if (e.and) return e.and.every((e) => Tt(e, t, n));
|
|
1860
|
+
if (e.or) return e.or.some((e) => Tt(e, t, n));
|
|
1861
|
+
if (!e.field || !e.op) return !1;
|
|
1862
|
+
let r = t[e.field];
|
|
1863
|
+
return !r || !Ct[r.type]?.test(e.op) ? !1 : Et(e, r.type, n[e.field]);
|
|
1864
|
+
}
|
|
1865
|
+
function Et(e, t, n) {
|
|
1866
|
+
let r = Dt(n);
|
|
1867
|
+
if (e.op === "is_empty") return r;
|
|
1868
|
+
if (e.op === "is_not_empty") return !r;
|
|
1869
|
+
if (r) return !1;
|
|
1870
|
+
let i = e.value;
|
|
1871
|
+
switch (e.op) {
|
|
1872
|
+
case "eq": return Ot(t, n, i);
|
|
1873
|
+
case "not_eq": return !Ot(t, n, i) && kt(t, n, i);
|
|
1874
|
+
case "in": return Array.isArray(i) && i.some((e) => Ot(t, n, e));
|
|
1875
|
+
case "not_in": return Array.isArray(i) && i.every((e) => kt(t, n, e) && !Ot(t, n, e));
|
|
1876
|
+
case "contains": return typeof n == "string" && typeof i == "string" && n.toLowerCase().includes(i.toLowerCase());
|
|
1877
|
+
case "starts_with": return typeof n == "string" && typeof i == "string" && n.toLowerCase().startsWith(i.toLowerCase());
|
|
1878
|
+
case "gt": return At(t, n, i, (e, t) => e > t);
|
|
1879
|
+
case "gte": return At(t, n, i, (e, t) => e >= t);
|
|
1880
|
+
case "lt": return At(t, n, i, (e, t) => e < t);
|
|
1881
|
+
case "lte": return At(t, n, i, (e, t) => e <= t);
|
|
1882
|
+
case "between": {
|
|
1883
|
+
if (!Array.isArray(i) || i.length !== 2) return !1;
|
|
1884
|
+
let e = jt(t, n, i[0]), r = jt(t, n, i[1]);
|
|
1885
|
+
return e === void 0 || r === void 0 ? !1 : e >= 0 && r <= 0;
|
|
1886
|
+
}
|
|
1887
|
+
default: return !1;
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
function Dt(e) {
|
|
1891
|
+
return e == null || e === "" || Array.isArray(e) && e.length === 0;
|
|
1892
|
+
}
|
|
1893
|
+
function Ot(e, t, n) {
|
|
1894
|
+
return kt(e, t, n) ? yt.has(e) ? jt(e, t, n) === 0 : t === n : !1;
|
|
1895
|
+
}
|
|
1896
|
+
function kt(e, t, n) {
|
|
1897
|
+
return jt(e, t, n) !== void 0;
|
|
1898
|
+
}
|
|
1899
|
+
function At(e, t, n, r) {
|
|
1900
|
+
let i = jt(e, t, n);
|
|
1901
|
+
return i !== void 0 && r(i, 0);
|
|
1902
|
+
}
|
|
1903
|
+
function jt(e, t, n) {
|
|
1904
|
+
if (vt.has(e)) return typeof t != "number" || typeof n != "number" || !Number.isFinite(t) || !Number.isFinite(n) ? void 0 : t === n ? 0 : t < n ? -1 : 1;
|
|
1905
|
+
if (yt.has(e)) return typeof t != "string" || typeof n != "string" || !Mt(e, t) || !Mt(e, n) ? void 0 : t === n ? 0 : t < n ? -1 : 1;
|
|
1906
|
+
if (_t.has(e) || e === "enum" || e === "ref" || e === "uuid") return typeof t != "string" || typeof n != "string" ? void 0 : t === n ? 0 : t < n ? -1 : 1;
|
|
1907
|
+
if (e === "bool") return typeof t != "boolean" || typeof n != "boolean" ? void 0 : t === n ? 0 : t ? 1 : -1;
|
|
1908
|
+
}
|
|
1909
|
+
function Mt(e, t) {
|
|
1910
|
+
switch (e) {
|
|
1911
|
+
case "date": return /^\d{4}-\d{2}-\d{2}$/.test(t);
|
|
1912
|
+
case "time": return /^\d{2}:\d{2}:\d{2}(?:\.\d+)?$/.test(t);
|
|
1913
|
+
case "timestamp": return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/.test(t);
|
|
1914
|
+
default: return !1;
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
//#endregion
|
|
1918
|
+
//#region src/lib/variants.ts
|
|
1919
|
+
function Nt(e, t) {
|
|
1920
|
+
let n = e.variants;
|
|
1921
|
+
if (!n || n.length === 0) return;
|
|
1922
|
+
let r = {};
|
|
1923
|
+
for (let [t, n] of e.fields) r[t] = n;
|
|
1924
|
+
for (let [e, i] of n) if (e !== "default" && i.when && wt(i.when, r, t)) return e;
|
|
1925
|
+
return n.has("default") ? "default" : void 0;
|
|
1926
|
+
}
|
|
1927
|
+
function Pt(e, t) {
|
|
1928
|
+
let n = e?.variants;
|
|
1929
|
+
if (!n || !n.items().some((e) => e.actions !== void 0)) return;
|
|
1930
|
+
let r = Nt(e, t), i = n.get("default"), a = (r ? n.get(r)?.actions : void 0) ?? i?.actions ?? [];
|
|
1931
|
+
return new Set(a);
|
|
1932
|
+
}
|
|
1933
|
+
function Ft(e, t) {
|
|
1934
|
+
if (t.length === 0) return;
|
|
1935
|
+
let n = t.map((t) => Pt(e, t));
|
|
1936
|
+
if (n.every((e) => e === void 0)) return;
|
|
1937
|
+
let r = n[0] ?? /* @__PURE__ */ new Set(), i = new Set(r);
|
|
1938
|
+
for (let e of n.slice(1)) {
|
|
1939
|
+
if (!e) {
|
|
1940
|
+
i.clear();
|
|
1941
|
+
break;
|
|
1942
|
+
}
|
|
1943
|
+
for (let t of i) e.has(t) || i.delete(t);
|
|
1944
|
+
}
|
|
1945
|
+
return i;
|
|
1946
|
+
}
|
|
1947
|
+
function It(e, t, n) {
|
|
1948
|
+
if (!t.variants || t.variants.length === 0) return;
|
|
1949
|
+
if (e.variants) {
|
|
1950
|
+
let r = Nt(e, n) ?? "default";
|
|
1951
|
+
return t.variants.has(r) ? r : "default";
|
|
1952
|
+
}
|
|
1953
|
+
let r = {};
|
|
1954
|
+
for (let [t, n] of e.fields) r[t] = n;
|
|
1955
|
+
for (let [e, i] of t.variants) if (e !== "default" && i.when && wt(i.when, r, n)) return e;
|
|
1956
|
+
return "default";
|
|
1957
|
+
}
|
|
1958
|
+
var Lt = [
|
|
1959
|
+
"items",
|
|
1960
|
+
"sidebar",
|
|
1961
|
+
"sidebar_width",
|
|
1962
|
+
"highlights",
|
|
1963
|
+
"audit",
|
|
1964
|
+
"actions",
|
|
1965
|
+
"row_actions",
|
|
1966
|
+
"action_layout",
|
|
1967
|
+
"card",
|
|
1968
|
+
"quick_peek"
|
|
1969
|
+
];
|
|
1970
|
+
function Rt(e, t, n) {
|
|
1971
|
+
if (!e || !t?.variants) return t;
|
|
1972
|
+
let r = It(e, t, n), i = r ? t.variants.get(r) : void 0;
|
|
1973
|
+
if (!i) return t;
|
|
1974
|
+
let a = { ...t };
|
|
1975
|
+
for (let e of Lt) i[e] !== void 0 && (a[e] = i[e]);
|
|
1976
|
+
return a;
|
|
1977
|
+
}
|
|
1978
|
+
//#endregion
|
|
1979
|
+
//#region src/lib/action-dispatch.ts
|
|
1980
|
+
function zt(e, t, n, r) {
|
|
1981
|
+
return m(t) ? (b(t.ui_steps, n), null) : t.entity ? `${t.entity}.${e}` : r ? `${r}.${e}` : e;
|
|
1982
|
+
}
|
|
1983
|
+
//#endregion
|
|
1984
|
+
export { K as C, re as S, ge as _, It as a, ae as b, gt as c, Me as d, Ne as f, X as g, Pe as h, Nt as i, Qe as l, Fe as m, Ft as n, Pt as o, Ie as p, Rt as r, wt as s, zt as t, je as u, he as v, q as x, Y as y };
|