@declarion/react 0.446.0 → 0.517.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist-lib/components/agents/AgentChatPanel.impl.js +349 -332
  2. package/dist-lib/components/detail-layout/DetailAuditStrip.js +1 -1
  3. package/dist-lib/components/detail-layout/EvidenceBlock.js +36 -24
  4. package/dist-lib/components/detail-layout/FieldRow.js +56 -60
  5. package/dist-lib/components/detail-layout/FieldsBlock.js +48 -47
  6. package/dist-lib/components/detail-layout/PropertiesBlock.js +42 -41
  7. package/dist-lib/components/detail-layout/labelLayout.js +35 -0
  8. package/dist-lib/components/fields/JsonField.js +128 -125
  9. package/dist-lib/components/fields/StringField.js +10 -25
  10. package/dist-lib/components/fields/StructureField.js +125 -167
  11. package/dist-lib/components/fields/ValueRows.js +114 -0
  12. package/dist-lib/components/fields/cells/factories/id.js +10 -0
  13. package/dist-lib/components/fields/cells/factories/nextRun.js +18 -27
  14. package/dist-lib/components/fields/cells/factories/refLink.js +15 -41
  15. package/dist-lib/components/fields/cells/registry.js +25 -23
  16. package/dist-lib/components/file-widgets/DocumentCard.js +142 -142
  17. package/dist-lib/components/file-widgets/helpers.js +32 -19
  18. package/dist-lib/components/file-widgets/host.js +4 -1
  19. package/dist-lib/components/list/PeekFieldCell.js +57 -55
  20. package/dist-lib/components/list/QuickPeek.js +109 -121
  21. package/dist-lib/components/pages/SmartDetailPage.impl.js +403 -400
  22. package/dist-lib/components/pages/SmartListPage.impl.js +260 -260
  23. package/dist-lib/components/pages/list/ListCardRow.js +101 -100
  24. package/dist-lib/components/pages/list/cardProjection.js +117 -112
  25. package/dist-lib/components/pages/list/useListQuery.js +1 -1
  26. package/dist-lib/components/pages/list/useListRowInteraction.js +68 -65
  27. package/dist-lib/components/primitives/IdBadge.js +27 -0
  28. package/dist-lib/components/primitives/RowField.js +11 -43
  29. package/dist-lib/components/shared/CopyButton.js +13 -18
  30. package/dist-lib/components/shared/RefChip.js +33 -0
  31. package/dist-lib/declarion-react.css +1 -1
  32. package/dist-lib/hooks/useAgentConversation.js +134 -110
  33. package/dist-lib/hooks/useCopy.js +18 -0
  34. package/dist-lib/index.d.ts +55 -20
  35. package/dist-lib/index.js +116 -111
  36. package/dist-lib/lib/realtime-reconcile.js +70 -59
  37. package/dist-lib/lib/reference.js +52 -34
  38. package/dist-lib/lib/short-id.js +12 -0
  39. package/dist-lib/testing.d.ts +1 -1
  40. package/dist-lib/types/schema.js +84 -80
  41. package/dist-lib/{useResponsiveMode-3hOLBkey.d.ts → useResponsiveMode-BObVfNyN.d.ts} +7 -2
  42. package/package.json +6 -1
  43. 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 { linkFactory as v } from "./factories/link.js";
18
- import { jsonFactory as y } from "./factories/json.js";
19
- import { markdownFactory as b } from "./factories/markdown.js";
20
- import { passwordMaskFactory as x } from "./factories/passwordMask.js";
21
- import { richTextPreviewFactory as S } from "./factories/richTextPreview.js";
22
- import { multilangInlineFactory as C } from "./factories/multilangInline.js";
23
- import { fileReferenceFactory as w } from "./factories/fileReference.js";
24
- import { errorFactory as T } from "./factories/errorTitle.js";
25
- import { messageFactory as E } from "./factories/message.js";
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 D = {
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: w,
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
- link: v,
49
- json: y,
50
- markdown: b,
51
- password_mask: x,
52
- rich_text_preview: S,
53
- multilang_inline: C,
54
- error: T,
55
- message: E
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(D).sort();
58
- function O(e) {
59
- let t = e.field.display?.widget ?? "text", n = D[t];
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 { O as resolveCellRenderer };
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 i, uploadFile as ee, validateClientSide as te } from "./upload.js";
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 s } from "../../lib/language.js";
5
- import { useDraftRegistration as c } from "./draft-scope.js";
6
- import { canPreviewFile as l, downloadFileURL as ne, previewFileURL as re } from "./helpers.js";
7
- import { useEmbedFileOpener as ie } from "./useEmbedFileSrc.js";
8
- import { singleFileFromValue as u } from "./value.js";
9
- import { displayDay as d } from "../../lib/timestamp.js";
10
- import { formatCivilDateText as f } from "../../lib/date-text.js";
11
- import { useCallback as p, useEffect as m, useRef as h, useState as g } from "react";
12
- import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
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 b({ contentType: e }) {
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__ */ v("div", {
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 x(d) {
22
- let { field: f, fieldName: x, value: ae, onChange: C, mode: oe, disabled: w, uploadFieldCode: T, uploadSlotCode: E } = d, D = u(ae), [O, k] = g("idle"), [A, j] = g(null), [M, N] = g(null), [P, F] = g(!1), [I, L] = g(D?.filename ?? ""), R = h(null), z = h(!1), B = h(null), { register: V, unregister: H, isDraft: U } = c(), W = o(), G = o("errors"), { open: K } = ie();
23
- m(() => () => {
24
- R.current && R.current.abort();
25
- }, []), m(() => {
26
- L(D?.filename ?? "");
27
- }, [D?.filename]);
28
- let q = (f.accepts ?? []).join(","), J = p(async (n) => {
29
- let a = te(n, f.accepts, f.max_size_bytes);
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
- N(r(W, G, a)), k("error");
31
+ M(r(U, W, a)), O("error");
32
32
  return;
33
33
  }
34
- N(null), z.current = !1, k("uploading"), j({
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
- R.current = o;
40
+ L.current = o;
41
41
  try {
42
- let e = await ee({
42
+ let e = await i({
43
43
  file: n,
44
- entityCode: d.entityCode,
45
- fieldCode: T ?? x,
46
- slotCode: E,
44
+ entityCode: l.entityCode,
45
+ fieldCode: w ?? y,
46
+ slotCode: T,
47
47
  signal: o.signal,
48
- onProgress: j
48
+ onProgress: A
49
49
  });
50
- if (z.current) {
51
- t(e.id).catch(() => {}), H(e.id);
50
+ if (R.current) {
51
+ t(e.id).catch(() => {}), V(e.id);
52
52
  return;
53
53
  }
54
- D && U(D.id) && (t(D.id).catch(() => {}), H(D.id)), V(e.id, () => t(e.id)), k("idle"), j(null);
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
- C?.(f.mode === "array" ? [r] : r);
66
+ S?.(u.mode === "array" ? [r] : r);
67
67
  } catch (t) {
68
68
  if (t instanceof e && t.code === "ABORTED") return;
69
- N(i(W, G, t)), k("error"), j(null);
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
- C,
81
- d.entityCode,
82
- V,
74
+ u.accepts,
75
+ u.max_size_bytes,
76
+ u.mode,
77
+ y,
78
+ E,
83
79
  H,
84
- T,
85
- E
86
- ]), Y = p(() => {
87
- w || B.current?.click();
88
- }, [w]), X = p((e) => {
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]), se = p(() => {
92
- D && U(D.id) && (t(D.id).catch(() => {}), H(D.id)), C?.(f.mode === "array" ? [] : null);
91
+ }, [J]), le = d(() => {
92
+ E && H(E.id) && (t(E.id).catch(() => {}), V(E.id)), S?.(u.mode === "array" ? [] : null);
93
93
  }, [
94
- D,
95
- f.mode,
96
- U,
97
- C,
98
- H
99
- ]), ce = p(() => {
100
- O === "uploading" && R.current && (z.current = !0, R.current.abort(), R.current = null, k("idle"), j(null));
101
- }, [O]), le = p(() => {
102
- D && K(D.id, "download", ne(D));
103
- }, [D, K]), Z = D ? l(D) : !1, ue = p(() => {
104
- D && l(D) && K(D.id, "preview", re(D));
105
- }, [D, K]), Q = p(() => {
106
- if (!D) {
107
- F(!1);
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 = I.trim();
111
- if (F(!1), !e || e === D.filename) {
112
- L(D.filename);
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
- ...D,
116
+ ...E,
117
117
  filename: e
118
118
  };
119
- C?.(f.mode === "array" ? [t] : t);
119
+ S?.(u.mode === "array" ? [t] : t);
120
120
  }, [
121
- I,
122
- D,
123
- C,
124
- f.mode
125
- ]), $ = oe === "display";
126
- return !D && O !== "uploading" ? /* @__PURE__ */ y("div", {
127
- "data-testid": `file-widget-${x}`,
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(b, {}),
131
- /* @__PURE__ */ y("div", {
130
+ /* @__PURE__ */ g(v, {}),
131
+ /* @__PURE__ */ _("div", {
132
132
  className: "flex flex-col gap-1",
133
- children: [/* @__PURE__ */ v("span", {
133
+ children: [/* @__PURE__ */ g("span", {
134
134
  className: "text-sm text-foreground",
135
- children: W(f.display?.placeholder) || W("file.document.empty", "No document attached")
136
- }), !$ && /* @__PURE__ */ v("button", {
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: w,
140
+ disabled: C,
141
141
  "data-testid": "upload",
142
- children: W("file.document.upload", "Upload")
142
+ children: U("file.document.upload", "Upload")
143
143
  })]
144
144
  }),
145
- !$ && /* @__PURE__ */ v("input", {
146
- ref: B,
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-${x}`
151
+ "data-testid": `file-input-${y}`
152
152
  }),
153
- O === "error" && M && /* @__PURE__ */ v("div", {
153
+ D === "error" && j && /* @__PURE__ */ g("div", {
154
154
  className: "ml-auto text-xs text-destructive",
155
155
  role: "alert",
156
- children: /* @__PURE__ */ v(a, { failure: M })
156
+ children: /* @__PURE__ */ g(a, { failure: j })
157
157
  })
158
158
  ]
159
- }) : /* @__PURE__ */ y("div", {
160
- "data-testid": `file-widget-${x}`,
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": O === "uploading" || void 0,
163
- "aria-invalid": O === "error" || void 0,
162
+ "aria-busy": D === "uploading" || void 0,
163
+ "aria-invalid": D === "error" || void 0,
164
164
  children: [
165
- /* @__PURE__ */ v(b, { contentType: D?.content_type }),
166
- /* @__PURE__ */ y("div", {
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
- P && D ? /* @__PURE__ */ v("input", {
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: I,
172
+ value: F,
173
173
  autoFocus: !0,
174
- onChange: (e) => L(e.target.value),
174
+ onChange: (e) => I(e.target.value),
175
175
  onBlur: Q,
176
176
  onKeyDown: (e) => {
177
- e.key === "Enter" ? Q() : e.key === "Escape" && (F(!1), L(D.filename));
177
+ e.key === "Enter" ? Q() : e.key === "Escape" && (P(!1), I(E.filename));
178
178
  },
179
179
  "data-testid": "filename-input"
180
- }) : /* @__PURE__ */ v("button", {
180
+ }) : /* @__PURE__ */ g("button", {
181
181
  type: "button",
182
- className: "truncate text-left text-sm font-medium text-foreground hover:underline",
183
- onClick: () => !$ && D && F(!0),
184
- disabled: $ || w || !D,
185
- title: D?.filename,
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: D?.filename ?? W("file.document.uploading", "Uploading…")
187
+ children: E?.filename ?? U("file.document.uploading", "Uploading…")
188
188
  }),
189
- /* @__PURE__ */ y("div", {
189
+ /* @__PURE__ */ _("div", {
190
190
  className: "flex flex-wrap gap-2 text-xs text-muted-foreground",
191
191
  children: [
192
- D && /* @__PURE__ */ v("span", { children: n(D.size_bytes, W.language) }),
193
- D?.page_count != null && /* @__PURE__ */ v("span", { children: s(W, "file.document.pages", D.page_count, {
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
- D?.uploaded_at && /* @__PURE__ */ v("span", { children: S(D.uploaded_at, W.timeZone) }),
198
- D?.uploaded_by && /* @__PURE__ */ v("span", { children: W("file.document.uploaded_by", "by {user}", { user: D.uploaded_by }) }),
199
- D?.version?.number != null && /* @__PURE__ */ v("span", {
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: W("file.document.version", "v{number}", { number: D.version.number })
201
+ children: U("file.document.version", "v{number}", { number: E.version.number })
202
202
  })
203
203
  ]
204
204
  }),
205
- O === "uploading" && /* @__PURE__ */ v("div", {
205
+ D === "uploading" && /* @__PURE__ */ g("div", {
206
206
  className: "text-xs text-muted-foreground",
207
207
  role: "progressbar",
208
- "aria-valuenow": A?.pct ?? 0,
208
+ "aria-valuenow": k?.pct ?? 0,
209
209
  "aria-valuemin": 0,
210
210
  "aria-valuemax": 100,
211
211
  "data-testid": "upload-progress",
212
- children: W("file.upload.progress", "Uploading {pct}%", { pct: A?.pct ?? 0 })
212
+ children: U("file.upload.progress", "Uploading {pct}%", { pct: k?.pct ?? 0 })
213
213
  }),
214
- O === "error" && M && /* @__PURE__ */ v("div", {
214
+ D === "error" && j && /* @__PURE__ */ g("div", {
215
215
  className: "text-xs text-destructive",
216
216
  role: "alert",
217
- children: /* @__PURE__ */ v(a, { failure: M })
217
+ children: /* @__PURE__ */ g(a, { failure: j })
218
218
  })
219
219
  ]
220
220
  }),
221
- /* @__PURE__ */ y("div", {
221
+ /* @__PURE__ */ _("div", {
222
222
  className: "flex flex-none items-center gap-1",
223
- children: [D && O !== "uploading" && /* @__PURE__ */ y(_, { children: [
224
- /* @__PURE__ */ v("button", {
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: le,
227
+ onClick: de,
228
228
  "data-testid": "download",
229
- children: W("file.download", "Download")
229
+ children: U("file.download", "Download")
230
230
  }),
231
- /* @__PURE__ */ v("button", {
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: ue,
234
+ onClick: fe,
235
235
  disabled: !Z,
236
- title: Z ? void 0 : W("file.document.preview_images_only", "Preview is available only for images and PDFs"),
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: W("file.document.preview", "Preview")
238
+ children: U("file.document.preview", "Preview")
239
239
  }),
240
- !$ && /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("button", {
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: w,
244
+ disabled: C,
245
245
  "data-testid": "replace",
246
- children: W("file.document.replace", "Replace")
247
- }), /* @__PURE__ */ v("button", {
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: se,
251
- disabled: w,
250
+ onClick: le,
251
+ disabled: C,
252
252
  "data-testid": "remove",
253
- children: W("file.remove", "Remove")
253
+ children: U("file.remove", "Remove")
254
254
  })] })
255
- ] }), O === "uploading" && /* @__PURE__ */ v("button", {
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: ce,
258
+ onClick: ue,
259
259
  "data-testid": "cancel-upload",
260
- children: W("file.upload.cancel", "Cancel")
260
+ children: U("file.upload.cancel", "Cancel")
261
261
  })]
262
262
  }),
263
- !$ && /* @__PURE__ */ v("input", {
264
- ref: B,
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-${x}`
269
+ "data-testid": `file-input-${y}`
270
270
  })
271
271
  ]
272
272
  });
273
273
  }
274
- function S(e, t) {
275
- let n = d(e, { zone: t });
276
- return n ? f(n) ?? n : e;
274
+ function b(e, t) {
275
+ let n = l(e, { zone: t });
276
+ return n ? u(n) ?? n : e;
277
277
  }
278
- export { x as DocumentCard };
278
+ export { y as DocumentCard };
@@ -1,20 +1,33 @@
1
- import { pickLocalized as e } from "../../lib/language.js";
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 t = ["thumb_200", "thumb_300"];
4
- function n(e, t, n) {
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 r(t, n, r, i, a) {
20
+ function a(e, n, r, i, a) {
8
21
  if (n) return n;
9
- let o = t?.metadata?.alt_text;
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 t = Object.fromEntries(Object.entries(o).filter((e) => e[0].length > 0 && typeof e[1] == "string")), n = e(t, i, a);
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 i = /* @__PURE__ */ new Set([
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 a(e) {
38
+ function s(e) {
26
39
  let t = e.content_type?.toLowerCase().split(";")[0]?.trim() ?? "";
27
- return i.has(t);
40
+ return o.has(t);
28
41
  }
29
- function o(e) {
42
+ function c(e) {
30
43
  return e.url;
31
44
  }
32
- function s(e) {
33
- return l(e.url, "attachment");
45
+ function l(e) {
46
+ return d(e.url, "attachment");
34
47
  }
35
- function c(e, n) {
48
+ function u(e, t) {
36
49
  if (!e) return;
37
50
  let r = e.derivations ?? {};
38
- for (let e of [n, ...t]) if (e && r[e]) return r[e];
51
+ for (let e of [t, ...n]) if (e && r[e]) return r[e];
39
52
  return e;
40
53
  }
41
- function l(e, t) {
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 u(e) {
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 d(e) {
71
+ function p(e) {
59
72
  if (e) return `${e.x * 100}% ${e.y * 100}%`;
60
73
  }
61
- function f(e, t) {
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 { a as canPreviewFile, s as downloadFileURL, n as fileFieldLabel, d as focalPointObjectPosition, c as preferredListThumbnail, o as previewFileURL, u as readFocalPoint, r as resolveFileAltText, f as withFocalPoint };
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 };
@@ -46,7 +46,10 @@ function g(e) {
46
46
  mode: p,
47
47
  onChange: m,
48
48
  disabled: g,
49
- fieldId: x
49
+ fieldId: x,
50
+ refs: h,
51
+ entities: v,
52
+ screens: y
50
53
  }) : /* @__PURE__ */ l(s, { widgetCode: e });
51
54
  }
52
55
  let E = r.fields.get(o), D = C && p === "display" && E ? {