@declarion/react 0.445.0 → 0.516.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/components/agents/AgentChatPanel.impl.js +349 -332
- package/dist-lib/components/detail-layout/DetailAuditStrip.js +1 -1
- package/dist-lib/components/detail-layout/EvidenceBlock.js +36 -24
- package/dist-lib/components/detail-layout/FieldRow.js +56 -60
- package/dist-lib/components/detail-layout/FieldsBlock.js +48 -47
- package/dist-lib/components/detail-layout/PropertiesBlock.js +42 -41
- package/dist-lib/components/detail-layout/labelLayout.js +35 -0
- package/dist-lib/components/fields/JsonField.js +128 -125
- package/dist-lib/components/fields/StringField.js +10 -25
- package/dist-lib/components/fields/StructureField.js +125 -167
- package/dist-lib/components/fields/ValueRows.js +114 -0
- package/dist-lib/components/fields/cells/factories/id.js +10 -0
- package/dist-lib/components/fields/cells/factories/nextRun.js +18 -27
- package/dist-lib/components/fields/cells/factories/refLink.js +15 -41
- package/dist-lib/components/fields/cells/registry.js +25 -23
- package/dist-lib/components/file-widgets/DocumentCard.js +142 -142
- package/dist-lib/components/file-widgets/helpers.js +32 -19
- package/dist-lib/components/file-widgets/host.js +4 -1
- package/dist-lib/components/list/PeekFieldCell.js +57 -55
- package/dist-lib/components/list/QuickPeek.js +109 -121
- package/dist-lib/components/pages/SmartDetailPage.impl.js +403 -400
- package/dist-lib/components/pages/SmartListPage.impl.js +260 -260
- package/dist-lib/components/pages/list/ListCardRow.js +101 -100
- package/dist-lib/components/pages/list/cardProjection.js +117 -112
- package/dist-lib/components/pages/list/useListQuery.js +1 -1
- package/dist-lib/components/pages/list/useListRowInteraction.js +68 -65
- package/dist-lib/components/primitives/IdBadge.js +27 -0
- package/dist-lib/components/primitives/RowField.js +11 -43
- package/dist-lib/components/shared/CopyButton.js +13 -18
- package/dist-lib/components/shared/RefChip.js +33 -0
- package/dist-lib/declarion-react.css +1 -1
- package/dist-lib/hooks/useAgentConversation.js +134 -110
- package/dist-lib/hooks/useCopy.js +18 -0
- package/dist-lib/index.d.ts +55 -20
- package/dist-lib/index.js +116 -111
- package/dist-lib/lib/realtime-reconcile.js +70 -59
- package/dist-lib/lib/reference.js +52 -34
- package/dist-lib/lib/short-id.js +12 -0
- package/dist-lib/testing.d.ts +1 -1
- package/dist-lib/types/schema.js +84 -80
- package/dist-lib/{useResponsiveMode-3hOLBkey.d.ts → useResponsiveMode-BObVfNyN.d.ts} +7 -2
- package/package.json +1 -1
- package/dist-lib/components/primitives/RecordIdBadge.js +0 -25
|
@@ -14,17 +14,18 @@ import { emailFactory as m } from "./factories/email.js";
|
|
|
14
14
|
import { phoneFactory as h } from "./factories/phone.js";
|
|
15
15
|
import { numberFactory as g } from "./factories/number.js";
|
|
16
16
|
import { codeFactory as _ } from "./factories/code.js";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
17
|
+
import { idFactory as v } from "./factories/id.js";
|
|
18
|
+
import { linkFactory as y } from "./factories/link.js";
|
|
19
|
+
import { jsonFactory as b } from "./factories/json.js";
|
|
20
|
+
import { markdownFactory as x } from "./factories/markdown.js";
|
|
21
|
+
import { passwordMaskFactory as S } from "./factories/passwordMask.js";
|
|
22
|
+
import { richTextPreviewFactory as C } from "./factories/richTextPreview.js";
|
|
23
|
+
import { multilangInlineFactory as w } from "./factories/multilangInline.js";
|
|
24
|
+
import { fileReferenceFactory as T } from "./factories/fileReference.js";
|
|
25
|
+
import { errorFactory as E } from "./factories/errorTitle.js";
|
|
26
|
+
import { messageFactory as D } from "./factories/message.js";
|
|
26
27
|
// src/components/fields/cells/registry.ts
|
|
27
|
-
var
|
|
28
|
+
var O = {
|
|
28
29
|
text: e,
|
|
29
30
|
bool_pill: t,
|
|
30
31
|
badge: n,
|
|
@@ -38,26 +39,27 @@ var D = {
|
|
|
38
39
|
money: u,
|
|
39
40
|
duration: d,
|
|
40
41
|
ref_link: f,
|
|
41
|
-
file_ref:
|
|
42
|
+
file_ref: T,
|
|
42
43
|
url: p,
|
|
43
44
|
email: m,
|
|
44
45
|
phone: h,
|
|
45
46
|
number: g,
|
|
46
47
|
percent: g,
|
|
47
48
|
code: _,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
id: v,
|
|
50
|
+
link: y,
|
|
51
|
+
json: b,
|
|
52
|
+
markdown: x,
|
|
53
|
+
password_mask: S,
|
|
54
|
+
rich_text_preview: C,
|
|
55
|
+
multilang_inline: w,
|
|
56
|
+
error: E,
|
|
57
|
+
message: D
|
|
56
58
|
};
|
|
57
|
-
Object.keys(
|
|
58
|
-
function
|
|
59
|
-
let t = e.field.display?.widget ?? "text", n =
|
|
59
|
+
Object.keys(O).sort();
|
|
60
|
+
function k(e) {
|
|
61
|
+
let t = e.field.display?.widget ?? "text", n = O[t];
|
|
60
62
|
if (!n) throw Error(`resolveCellRenderer: no factory registered for widget "${t}" (field "${e.fieldName}"). The engine must stamp a smart default at YAML-load time; an unknown widget here indicates an out-of-sync allow-list.`);
|
|
61
63
|
return n(e);
|
|
62
64
|
}
|
|
63
|
-
export {
|
|
65
|
+
export { k as resolveCellRenderer };
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { UploadError as e, discardFile as t, formatBytes as n, uploadCheckFailure as r, uploadFailure as
|
|
1
|
+
import { UploadError as e, discardFile as t, formatBytes as n, uploadCheckFailure as r, uploadFailure as ee, uploadFile as i, validateClientSide as te } from "./upload.js";
|
|
2
2
|
import { UploadFailureText as a } from "./UploadFailureText.js";
|
|
3
3
|
import { useText as o } from "../../hooks/useText.js";
|
|
4
|
-
import { pluralText as
|
|
5
|
-
import { useDraftRegistration as
|
|
6
|
-
import { canPreviewFile as
|
|
7
|
-
import { useEmbedFileOpener as
|
|
8
|
-
import { singleFileFromValue as
|
|
9
|
-
import { displayDay as
|
|
10
|
-
import { formatCivilDateText as
|
|
11
|
-
import { useCallback as
|
|
12
|
-
import { Fragment as
|
|
4
|
+
import { pluralText as ne } from "../../lib/language.js";
|
|
5
|
+
import { useDraftRegistration as re } from "./draft-scope.js";
|
|
6
|
+
import { attachmentReferenceLabel as ie, canPreviewFile as s, downloadFileURL as ae, previewFileURL as oe } from "./helpers.js";
|
|
7
|
+
import { useEmbedFileOpener as se } from "./useEmbedFileSrc.js";
|
|
8
|
+
import { singleFileFromValue as c } from "./value.js";
|
|
9
|
+
import { displayDay as l } from "../../lib/timestamp.js";
|
|
10
|
+
import { formatCivilDateText as u } from "../../lib/date-text.js";
|
|
11
|
+
import { useCallback as d, useEffect as f, useRef as p, useState as m } from "react";
|
|
12
|
+
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
13
13
|
// src/components/file-widgets/DocumentCard.tsx
|
|
14
|
-
function
|
|
14
|
+
function v({ contentType: e }) {
|
|
15
15
|
let t = o(), n = 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() ?? t("file.document.type_other", "FILE") : t("file.document.type_other", "FILE");
|
|
16
|
-
return /* @__PURE__ */
|
|
16
|
+
return /* @__PURE__ */ g("div", {
|
|
17
17
|
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",
|
|
18
18
|
children: n
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
let { field:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}, []),
|
|
26
|
-
|
|
27
|
-
}, [
|
|
28
|
-
let q = (
|
|
29
|
-
let a = te(n,
|
|
21
|
+
function y(l) {
|
|
22
|
+
let { field: u, fieldName: y, value: x, onChange: S, mode: ce, disabled: C, uploadFieldCode: w, uploadSlotCode: T } = l, E = c(x), [D, O] = m("idle"), [k, A] = m(null), [j, M] = m(null), [N, P] = m(!1), [F, I] = m(E?.filename ?? ""), L = p(null), R = p(!1), z = p(null), { register: B, unregister: V, isDraft: H } = re(), U = o(), W = o("errors"), G = ie(U, l, "uploaded_by", E?.uploaded_by), { open: K } = se();
|
|
23
|
+
f(() => () => {
|
|
24
|
+
L.current && L.current.abort();
|
|
25
|
+
}, []), f(() => {
|
|
26
|
+
I(E?.filename ?? "");
|
|
27
|
+
}, [E?.filename]);
|
|
28
|
+
let q = (u.accepts ?? []).join(","), J = d(async (n) => {
|
|
29
|
+
let a = te(n, u.accepts, u.max_size_bytes);
|
|
30
30
|
if (a) {
|
|
31
|
-
|
|
31
|
+
M(r(U, W, a)), O("error");
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
M(null), R.current = !1, O("uploading"), A({
|
|
35
35
|
loaded: 0,
|
|
36
36
|
total: n.size,
|
|
37
37
|
pct: 0
|
|
38
38
|
});
|
|
39
39
|
let o = new AbortController();
|
|
40
|
-
|
|
40
|
+
L.current = o;
|
|
41
41
|
try {
|
|
42
|
-
let e = await
|
|
42
|
+
let e = await i({
|
|
43
43
|
file: n,
|
|
44
|
-
entityCode:
|
|
45
|
-
fieldCode:
|
|
46
|
-
slotCode:
|
|
44
|
+
entityCode: l.entityCode,
|
|
45
|
+
fieldCode: w ?? y,
|
|
46
|
+
slotCode: T,
|
|
47
47
|
signal: o.signal,
|
|
48
|
-
onProgress:
|
|
48
|
+
onProgress: A
|
|
49
49
|
});
|
|
50
|
-
if (
|
|
51
|
-
t(e.id).catch(() => {}),
|
|
50
|
+
if (R.current) {
|
|
51
|
+
t(e.id).catch(() => {}), V(e.id);
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
E && H(E.id) && (t(E.id).catch(() => {}), V(E.id)), B(e.id, () => t(e.id)), O("idle"), A(null);
|
|
55
55
|
let r = {
|
|
56
56
|
id: e.id,
|
|
57
57
|
filename: e.filename,
|
|
@@ -63,216 +63,216 @@ function x(d) {
|
|
|
63
63
|
url: e.url,
|
|
64
64
|
metadata: e.metadata
|
|
65
65
|
};
|
|
66
|
-
|
|
66
|
+
S?.(u.mode === "array" ? [r] : r);
|
|
67
67
|
} catch (t) {
|
|
68
68
|
if (t instanceof e && t.code === "ABORTED") return;
|
|
69
|
-
|
|
69
|
+
M(ee(U, W, t)), O("error"), A(null);
|
|
70
70
|
}
|
|
71
71
|
}, [
|
|
72
|
-
G,
|
|
73
72
|
W,
|
|
74
|
-
f.accepts,
|
|
75
|
-
f.max_size_bytes,
|
|
76
|
-
f.mode,
|
|
77
|
-
x,
|
|
78
|
-
D,
|
|
79
73
|
U,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
u.accepts,
|
|
75
|
+
u.max_size_bytes,
|
|
76
|
+
u.mode,
|
|
77
|
+
y,
|
|
78
|
+
E,
|
|
83
79
|
H,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
S,
|
|
81
|
+
l.entityCode,
|
|
82
|
+
B,
|
|
83
|
+
V,
|
|
84
|
+
w,
|
|
85
|
+
T
|
|
86
|
+
]), Y = d(() => {
|
|
87
|
+
C || z.current?.click();
|
|
88
|
+
}, [C]), X = d((e) => {
|
|
89
89
|
let t = e.target.files?.[0];
|
|
90
90
|
e.target.value = "", t && J(t);
|
|
91
|
-
}, [J]),
|
|
92
|
-
|
|
91
|
+
}, [J]), le = d(() => {
|
|
92
|
+
E && H(E.id) && (t(E.id).catch(() => {}), V(E.id)), S?.(u.mode === "array" ? [] : null);
|
|
93
93
|
}, [
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
]),
|
|
100
|
-
|
|
101
|
-
}, [
|
|
102
|
-
|
|
103
|
-
}, [
|
|
104
|
-
|
|
105
|
-
}, [
|
|
106
|
-
if (!
|
|
107
|
-
|
|
94
|
+
E,
|
|
95
|
+
u.mode,
|
|
96
|
+
H,
|
|
97
|
+
S,
|
|
98
|
+
V
|
|
99
|
+
]), ue = d(() => {
|
|
100
|
+
D === "uploading" && L.current && (R.current = !0, L.current.abort(), L.current = null, O("idle"), A(null));
|
|
101
|
+
}, [D]), de = d(() => {
|
|
102
|
+
E && K(E.id, "download", ae(E));
|
|
103
|
+
}, [E, K]), Z = E ? s(E) : !1, fe = d(() => {
|
|
104
|
+
E && s(E) && K(E.id, "preview", oe(E));
|
|
105
|
+
}, [E, K]), Q = d(() => {
|
|
106
|
+
if (!E) {
|
|
107
|
+
P(!1);
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
let e =
|
|
111
|
-
if (
|
|
112
|
-
|
|
110
|
+
let e = F.trim();
|
|
111
|
+
if (P(!1), !e || e === E.filename) {
|
|
112
|
+
I(E.filename);
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
115
|
let t = {
|
|
116
|
-
...
|
|
116
|
+
...E,
|
|
117
117
|
filename: e
|
|
118
118
|
};
|
|
119
|
-
|
|
119
|
+
S?.(u.mode === "array" ? [t] : t);
|
|
120
120
|
}, [
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
]), $ =
|
|
126
|
-
return !
|
|
127
|
-
"data-testid": `file-widget-${
|
|
121
|
+
F,
|
|
122
|
+
E,
|
|
123
|
+
S,
|
|
124
|
+
u.mode
|
|
125
|
+
]), $ = ce === "display";
|
|
126
|
+
return !E && D !== "uploading" ? /* @__PURE__ */ _("div", {
|
|
127
|
+
"data-testid": `file-widget-${y}`,
|
|
128
128
|
className: $ ? "flex items-center gap-3" : "flex items-center gap-3 rounded-md border border-dashed border-border bg-surface p-3",
|
|
129
129
|
children: [
|
|
130
|
-
/* @__PURE__ */ v
|
|
131
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ g(v, {}),
|
|
131
|
+
/* @__PURE__ */ _("div", {
|
|
132
132
|
className: "flex flex-col gap-1",
|
|
133
|
-
children: [/* @__PURE__ */
|
|
133
|
+
children: [/* @__PURE__ */ g("span", {
|
|
134
134
|
className: "text-sm text-foreground",
|
|
135
|
-
children:
|
|
136
|
-
}), !$ && /* @__PURE__ */
|
|
135
|
+
children: U(u.display?.placeholder) || U("file.document.empty", "No document attached")
|
|
136
|
+
}), !$ && /* @__PURE__ */ g("button", {
|
|
137
137
|
type: "button",
|
|
138
138
|
className: "self-start rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
|
|
139
139
|
onClick: Y,
|
|
140
|
-
disabled:
|
|
140
|
+
disabled: C,
|
|
141
141
|
"data-testid": "upload",
|
|
142
|
-
children:
|
|
142
|
+
children: U("file.document.upload", "Upload")
|
|
143
143
|
})]
|
|
144
144
|
}),
|
|
145
|
-
!$ && /* @__PURE__ */
|
|
146
|
-
ref:
|
|
145
|
+
!$ && /* @__PURE__ */ g("input", {
|
|
146
|
+
ref: z,
|
|
147
147
|
type: "file",
|
|
148
148
|
accept: q || void 0,
|
|
149
149
|
onChange: X,
|
|
150
150
|
style: { display: "none" },
|
|
151
|
-
"data-testid": `file-input-${
|
|
151
|
+
"data-testid": `file-input-${y}`
|
|
152
152
|
}),
|
|
153
|
-
|
|
153
|
+
D === "error" && j && /* @__PURE__ */ g("div", {
|
|
154
154
|
className: "ml-auto text-xs text-destructive",
|
|
155
155
|
role: "alert",
|
|
156
|
-
children: /* @__PURE__ */
|
|
156
|
+
children: /* @__PURE__ */ g(a, { failure: j })
|
|
157
157
|
})
|
|
158
158
|
]
|
|
159
|
-
}) : /* @__PURE__ */
|
|
160
|
-
"data-testid": `file-widget-${
|
|
159
|
+
}) : /* @__PURE__ */ _("div", {
|
|
160
|
+
"data-testid": `file-widget-${y}`,
|
|
161
161
|
className: "flex items-center gap-3 rounded-md border border-border bg-surface p-3",
|
|
162
|
-
"aria-busy":
|
|
163
|
-
"aria-invalid":
|
|
162
|
+
"aria-busy": D === "uploading" || void 0,
|
|
163
|
+
"aria-invalid": D === "error" || void 0,
|
|
164
164
|
children: [
|
|
165
|
-
/* @__PURE__ */ v
|
|
166
|
-
/* @__PURE__ */
|
|
165
|
+
/* @__PURE__ */ g(v, { contentType: E?.content_type }),
|
|
166
|
+
/* @__PURE__ */ _("div", {
|
|
167
167
|
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
168
168
|
children: [
|
|
169
|
-
|
|
169
|
+
N && E ? /* @__PURE__ */ g("input", {
|
|
170
170
|
type: "text",
|
|
171
171
|
className: "rounded-sm border border-border bg-card px-1 py-0.5 text-sm text-foreground",
|
|
172
|
-
value:
|
|
172
|
+
value: F,
|
|
173
173
|
autoFocus: !0,
|
|
174
|
-
onChange: (e) =>
|
|
174
|
+
onChange: (e) => I(e.target.value),
|
|
175
175
|
onBlur: Q,
|
|
176
176
|
onKeyDown: (e) => {
|
|
177
|
-
e.key === "Enter" ? Q() : e.key === "Escape" && (
|
|
177
|
+
e.key === "Enter" ? Q() : e.key === "Escape" && (P(!1), I(E.filename));
|
|
178
178
|
},
|
|
179
179
|
"data-testid": "filename-input"
|
|
180
|
-
}) : /* @__PURE__ */
|
|
180
|
+
}) : /* @__PURE__ */ g("button", {
|
|
181
181
|
type: "button",
|
|
182
|
-
className: "
|
|
183
|
-
onClick: () => !$ &&
|
|
184
|
-
disabled: $ ||
|
|
185
|
-
title:
|
|
182
|
+
className: "break-all text-left text-sm font-medium text-foreground hover:underline",
|
|
183
|
+
onClick: () => !$ && E && P(!0),
|
|
184
|
+
disabled: $ || C || !E,
|
|
185
|
+
title: E?.filename,
|
|
186
186
|
"data-testid": "filename",
|
|
187
|
-
children:
|
|
187
|
+
children: E?.filename ?? U("file.document.uploading", "Uploading…")
|
|
188
188
|
}),
|
|
189
|
-
/* @__PURE__ */
|
|
189
|
+
/* @__PURE__ */ _("div", {
|
|
190
190
|
className: "flex flex-wrap gap-2 text-xs text-muted-foreground",
|
|
191
191
|
children: [
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
E && /* @__PURE__ */ g("span", { children: n(E.size_bytes, U.language) }),
|
|
193
|
+
E?.page_count != null && /* @__PURE__ */ g("span", { children: ne(U, "file.document.pages", E.page_count, {
|
|
194
194
|
one: "{count} page",
|
|
195
195
|
other: "{count} pages"
|
|
196
196
|
}) }),
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
E?.uploaded_at && /* @__PURE__ */ g("span", { children: b(E.uploaded_at, U.timeZone) }),
|
|
198
|
+
G && /* @__PURE__ */ g("span", { children: U("file.document.uploaded_by", "by {user}", { user: G }) }),
|
|
199
|
+
E?.version?.number != null && /* @__PURE__ */ g("span", {
|
|
200
200
|
"data-testid": "version-badge",
|
|
201
|
-
children:
|
|
201
|
+
children: U("file.document.version", "v{number}", { number: E.version.number })
|
|
202
202
|
})
|
|
203
203
|
]
|
|
204
204
|
}),
|
|
205
|
-
|
|
205
|
+
D === "uploading" && /* @__PURE__ */ g("div", {
|
|
206
206
|
className: "text-xs text-muted-foreground",
|
|
207
207
|
role: "progressbar",
|
|
208
|
-
"aria-valuenow":
|
|
208
|
+
"aria-valuenow": k?.pct ?? 0,
|
|
209
209
|
"aria-valuemin": 0,
|
|
210
210
|
"aria-valuemax": 100,
|
|
211
211
|
"data-testid": "upload-progress",
|
|
212
|
-
children:
|
|
212
|
+
children: U("file.upload.progress", "Uploading {pct}%", { pct: k?.pct ?? 0 })
|
|
213
213
|
}),
|
|
214
|
-
|
|
214
|
+
D === "error" && j && /* @__PURE__ */ g("div", {
|
|
215
215
|
className: "text-xs text-destructive",
|
|
216
216
|
role: "alert",
|
|
217
|
-
children: /* @__PURE__ */
|
|
217
|
+
children: /* @__PURE__ */ g(a, { failure: j })
|
|
218
218
|
})
|
|
219
219
|
]
|
|
220
220
|
}),
|
|
221
|
-
/* @__PURE__ */
|
|
221
|
+
/* @__PURE__ */ _("div", {
|
|
222
222
|
className: "flex flex-none items-center gap-1",
|
|
223
|
-
children: [
|
|
224
|
-
/* @__PURE__ */
|
|
223
|
+
children: [E && D !== "uploading" && /* @__PURE__ */ _(h, { children: [
|
|
224
|
+
/* @__PURE__ */ g("button", {
|
|
225
225
|
type: "button",
|
|
226
226
|
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
|
|
227
|
-
onClick:
|
|
227
|
+
onClick: de,
|
|
228
228
|
"data-testid": "download",
|
|
229
|
-
children:
|
|
229
|
+
children: U("file.download", "Download")
|
|
230
230
|
}),
|
|
231
|
-
/* @__PURE__ */
|
|
231
|
+
/* @__PURE__ */ g("button", {
|
|
232
232
|
type: "button",
|
|
233
233
|
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",
|
|
234
|
-
onClick:
|
|
234
|
+
onClick: fe,
|
|
235
235
|
disabled: !Z,
|
|
236
|
-
title: Z ? void 0 :
|
|
236
|
+
title: Z ? void 0 : U("file.document.preview_images_only", "Preview is available only for images and PDFs"),
|
|
237
237
|
"data-testid": "preview",
|
|
238
|
-
children:
|
|
238
|
+
children: U("file.document.preview", "Preview")
|
|
239
239
|
}),
|
|
240
|
-
!$ && /* @__PURE__ */
|
|
240
|
+
!$ && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("button", {
|
|
241
241
|
type: "button",
|
|
242
242
|
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
|
|
243
243
|
onClick: Y,
|
|
244
|
-
disabled:
|
|
244
|
+
disabled: C,
|
|
245
245
|
"data-testid": "replace",
|
|
246
|
-
children:
|
|
247
|
-
}), /* @__PURE__ */
|
|
246
|
+
children: U("file.document.replace", "Replace")
|
|
247
|
+
}), /* @__PURE__ */ g("button", {
|
|
248
248
|
type: "button",
|
|
249
249
|
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-destructive hover:bg-surface-2",
|
|
250
|
-
onClick:
|
|
251
|
-
disabled:
|
|
250
|
+
onClick: le,
|
|
251
|
+
disabled: C,
|
|
252
252
|
"data-testid": "remove",
|
|
253
|
-
children:
|
|
253
|
+
children: U("file.remove", "Remove")
|
|
254
254
|
})] })
|
|
255
|
-
] }),
|
|
255
|
+
] }), D === "uploading" && /* @__PURE__ */ g("button", {
|
|
256
256
|
type: "button",
|
|
257
257
|
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs",
|
|
258
|
-
onClick:
|
|
258
|
+
onClick: ue,
|
|
259
259
|
"data-testid": "cancel-upload",
|
|
260
|
-
children:
|
|
260
|
+
children: U("file.upload.cancel", "Cancel")
|
|
261
261
|
})]
|
|
262
262
|
}),
|
|
263
|
-
!$ && /* @__PURE__ */
|
|
264
|
-
ref:
|
|
263
|
+
!$ && /* @__PURE__ */ g("input", {
|
|
264
|
+
ref: z,
|
|
265
265
|
type: "file",
|
|
266
266
|
accept: q || void 0,
|
|
267
267
|
onChange: X,
|
|
268
268
|
style: { display: "none" },
|
|
269
|
-
"data-testid": `file-input-${
|
|
269
|
+
"data-testid": `file-input-${y}`
|
|
270
270
|
})
|
|
271
271
|
]
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
|
-
function
|
|
275
|
-
let n =
|
|
276
|
-
return n ?
|
|
274
|
+
function b(e, t) {
|
|
275
|
+
let n = l(e, { zone: t });
|
|
276
|
+
return n ? u(n) ?? n : e;
|
|
277
277
|
}
|
|
278
|
-
export {
|
|
278
|
+
export { y as DocumentCard };
|
|
@@ -1,20 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { referenceResolver as e } from "../../lib/reference.js";
|
|
2
|
+
import { pickLocalized as t } from "../../lib/language.js";
|
|
2
3
|
// src/components/file-widgets/helpers.ts
|
|
3
|
-
var
|
|
4
|
-
function
|
|
4
|
+
var n = ["thumb_200", "thumb_300"];
|
|
5
|
+
function r(t, n, r, i) {
|
|
6
|
+
let a = n.field.attachment_fields?.[r];
|
|
7
|
+
if (!a || !i) return;
|
|
8
|
+
let { label: o, labelled: s } = e({
|
|
9
|
+
field: a,
|
|
10
|
+
fieldName: r,
|
|
11
|
+
entities: n.entities,
|
|
12
|
+
screens: n.screens,
|
|
13
|
+
t
|
|
14
|
+
})(i, {}, n.refs);
|
|
15
|
+
return s ? o : void 0;
|
|
16
|
+
}
|
|
17
|
+
function i(e, t, n) {
|
|
5
18
|
return e(t.display?.name) || n;
|
|
6
19
|
}
|
|
7
|
-
function
|
|
20
|
+
function a(e, n, r, i, a) {
|
|
8
21
|
if (n) return n;
|
|
9
|
-
let o =
|
|
22
|
+
let o = e?.metadata?.alt_text;
|
|
10
23
|
if (typeof o == "string" && o.length > 0) return o;
|
|
11
24
|
if (o && typeof o == "object" && !Array.isArray(o)) {
|
|
12
|
-
let
|
|
25
|
+
let e = Object.fromEntries(Object.entries(o).filter((e) => e[0].length > 0 && typeof e[1] == "string")), n = t(e, i, a);
|
|
13
26
|
if (n) return n;
|
|
14
27
|
}
|
|
15
28
|
return r;
|
|
16
29
|
}
|
|
17
|
-
var
|
|
30
|
+
var o = /* @__PURE__ */ new Set([
|
|
18
31
|
"image/png",
|
|
19
32
|
"image/jpeg",
|
|
20
33
|
"image/webp",
|
|
@@ -22,23 +35,23 @@ var i = /* @__PURE__ */ new Set([
|
|
|
22
35
|
"image/avif",
|
|
23
36
|
"application/pdf"
|
|
24
37
|
]);
|
|
25
|
-
function
|
|
38
|
+
function s(e) {
|
|
26
39
|
let t = e.content_type?.toLowerCase().split(";")[0]?.trim() ?? "";
|
|
27
|
-
return
|
|
40
|
+
return o.has(t);
|
|
28
41
|
}
|
|
29
|
-
function
|
|
42
|
+
function c(e) {
|
|
30
43
|
return e.url;
|
|
31
44
|
}
|
|
32
|
-
function
|
|
33
|
-
return
|
|
45
|
+
function l(e) {
|
|
46
|
+
return d(e.url, "attachment");
|
|
34
47
|
}
|
|
35
|
-
function
|
|
48
|
+
function u(e, t) {
|
|
36
49
|
if (!e) return;
|
|
37
50
|
let r = e.derivations ?? {};
|
|
38
|
-
for (let e of [
|
|
51
|
+
for (let e of [t, ...n]) if (e && r[e]) return r[e];
|
|
39
52
|
return e;
|
|
40
53
|
}
|
|
41
|
-
function
|
|
54
|
+
function d(e, t) {
|
|
42
55
|
try {
|
|
43
56
|
let n = new URL(e, typeof window < "u" ? window.location.origin : "http://localhost");
|
|
44
57
|
return n.searchParams.set("disposition", t), /^https?:\/\//i.test(e) ? n.toString() : `${n.pathname}${n.search}${n.hash}`;
|
|
@@ -46,7 +59,7 @@ function l(e, t) {
|
|
|
46
59
|
return `${e}${e.includes("?") ? "&" : "?"}disposition=${t}`;
|
|
47
60
|
}
|
|
48
61
|
}
|
|
49
|
-
function
|
|
62
|
+
function f(e) {
|
|
50
63
|
let t = e?.metadata?.focal_point;
|
|
51
64
|
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
52
65
|
let n = t, r = typeof n.x == "number" ? n.x : NaN, i = typeof n.y == "number" ? n.y : NaN;
|
|
@@ -55,10 +68,10 @@ function u(e) {
|
|
|
55
68
|
y: i
|
|
56
69
|
};
|
|
57
70
|
}
|
|
58
|
-
function
|
|
71
|
+
function p(e) {
|
|
59
72
|
if (e) return `${e.x * 100}% ${e.y * 100}%`;
|
|
60
73
|
}
|
|
61
|
-
function
|
|
74
|
+
function m(e, t) {
|
|
62
75
|
return {
|
|
63
76
|
...e,
|
|
64
77
|
metadata: {
|
|
@@ -67,4 +80,4 @@ function f(e, t) {
|
|
|
67
80
|
}
|
|
68
81
|
};
|
|
69
82
|
}
|
|
70
|
-
export {
|
|
83
|
+
export { r as attachmentReferenceLabel, s as canPreviewFile, l as downloadFileURL, i as fileFieldLabel, p as focalPointObjectPosition, u as preferredListThumbnail, c as previewFileURL, f as readFocalPoint, a as resolveFileAltText, m as withFocalPoint };
|