@declarion/react 0.66.1 → 0.81.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 (66) hide show
  1. package/README.md +1 -1
  2. package/dist-lib/api/auth.js +24 -14
  3. package/dist-lib/app.js +28 -23
  4. package/dist-lib/components/chrome/AssociationTabs.js +35 -38
  5. package/dist-lib/components/chrome/HighlightsStrip.js +2 -1
  6. package/dist-lib/components/chrome/RecordHeader.js +33 -38
  7. package/dist-lib/components/detail-layout/AssociatedBlock.js +10 -21
  8. package/dist-lib/components/detail-layout/ChildrenBlock.js +1 -8
  9. package/dist-lib/components/detail-layout/ChildrenCards.js +1 -8
  10. package/dist-lib/components/detail-layout/ChildrenList.js +1 -8
  11. package/dist-lib/components/detail-layout/ChildrenTable.js +1 -8
  12. package/dist-lib/components/detail-layout/ChildrenTimeline.js +1 -8
  13. package/dist-lib/components/detail-layout/DetailAuditStrip.js +33 -29
  14. package/dist-lib/components/detail-layout/DetailHighlights.js +7 -2
  15. package/dist-lib/components/detail-layout/FieldsBlock.js +12 -9
  16. package/dist-lib/components/detail-layout/LayoutRenderer.js +10 -10
  17. package/dist-lib/components/detail-layout/LayoutTabs.js +49 -48
  18. package/dist-lib/components/detail-layout/SectionBlock.js +20 -28
  19. package/dist-lib/components/detail-layout/visibility.js +28 -0
  20. package/dist-lib/components/fields/IntArrayField.js +37 -33
  21. package/dist-lib/components/fields/NumberField.js +28 -55
  22. package/dist-lib/components/fields/RichTextField.js +1 -1
  23. package/dist-lib/components/fields/TimestampField.js +50 -89
  24. package/dist-lib/components/fields/cells/factories/date.js +13 -14
  25. package/dist-lib/components/fields/cells/factories/money.js +1 -1
  26. package/dist-lib/components/fields/cells/factories/number.js +4 -4
  27. package/dist-lib/components/file-widgets/DocumentCard.js +1 -1
  28. package/dist-lib/components/file-widgets/Grid.js +153 -152
  29. package/dist-lib/components/file-widgets/ImageWidget.js +90 -91
  30. package/dist-lib/components/file-widgets/LabeledSlots.js +1 -0
  31. package/dist-lib/components/file-widgets/helpers.js +15 -19
  32. package/dist-lib/components/file-widgets/host.js +33 -32
  33. package/dist-lib/components/file-widgets/upload.js +10 -6
  34. package/dist-lib/components/layout/Layout.js +125 -123
  35. package/dist-lib/components/pages/NoScreensPage.impl.js +14 -0
  36. package/dist-lib/components/pages/NoScreensPage.js +12 -0
  37. package/dist-lib/components/pages/SmartDetailPage.impl.js +451 -451
  38. package/dist-lib/components/pages/auth/AuthShell.js +62 -61
  39. package/dist-lib/components/pages/auth/CodeInput.js +63 -0
  40. package/dist-lib/components/pages/auth/SignIn.js +12 -4
  41. package/dist-lib/components/pages/auth/SignUp.impl.js +80 -103
  42. package/dist-lib/components/pages/auth/SignUpCode.js +122 -0
  43. package/dist-lib/components/pages/auth/TwoFA.impl.js +9 -55
  44. package/dist-lib/components/pages/list/cardProjection.js +135 -122
  45. package/dist-lib/components/pages/list/columns.js +58 -43
  46. package/dist-lib/components/pages/profile/Profile.impl.js +87 -104
  47. package/dist-lib/components/pages/tenant-params/TenantParamsPage.impl.js +1 -1
  48. package/dist-lib/components/params/ParamsBlock.js +6 -17
  49. package/dist-lib/components/params/param-editors.js +14 -10
  50. package/dist-lib/components/primitives/Fields.js +314 -236
  51. package/dist-lib/components/shared/MarkdownRenderer.js +44 -43
  52. package/dist-lib/declarion-react.css +1 -1
  53. package/dist-lib/hooks/useActiveTabFollowsRoute.js +49 -0
  54. package/dist-lib/hooks/useAuth.js +44 -37
  55. package/dist-lib/hooks/useDocumentTitle.js +20 -0
  56. package/dist-lib/hooks/useFollowAgentOpen.js +1 -0
  57. package/dist-lib/hooks/useTabTitle.js +1 -1
  58. package/dist-lib/index.d.ts +21 -7
  59. package/dist-lib/lib/date-text.js +57 -0
  60. package/dist-lib/lib/number-text.js +9 -0
  61. package/dist-lib/lib/timestamp.js +29 -29
  62. package/dist-lib/stores/tabs.js +7 -5
  63. package/dist-lib/testing.d.ts +1 -1
  64. package/dist-lib/testing.js +1 -0
  65. package/dist-lib/{useResponsiveMode-DmrpMbZX.d.ts → useResponsiveMode-D3SKz5z4.d.ts} +20 -9
  66. package/package.json +11 -11
@@ -3,32 +3,31 @@ import { useText as n } from "../../hooks/useText.js";
3
3
  import { UploadError as r, discardFile as i, uploadCheckFailure as ee, uploadFailure as te, uploadFile as ne, validateClientSide as re } from "./upload.js";
4
4
  import { UploadFailureText as a } from "./UploadFailureText.js";
5
5
  import { getImageCropper as ie } from "./cropper.js";
6
- import { focalPointObjectPosition as o, preferredListThumbnailURL as s, preferredThumbnailVariant as ae, readFocalPoint as oe, resolveFileAltText as se, withFocalPoint as ce } from "./helpers.js";
7
- import { useDraftRegistration as le } from "./draft-scope.js";
8
- import { useEmbedFileSrc as ue } from "./useEmbedFileSrc.js";
9
- import { singleFileFromValue as de } from "./value.js";
10
- import { useCallback as c, useEffect as fe, useMemo as pe, useRef as l, useState as u } from "react";
11
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
6
+ import { fileFieldLabel as ae, focalPointObjectPosition as o, preferredListThumbnail as oe, previewFileURL as se, readFocalPoint as ce, resolveFileAltText as le, withFocalPoint as ue } from "./helpers.js";
7
+ import { useDraftRegistration as de } from "./draft-scope.js";
8
+ import { useEmbedFileSrc as fe } from "./useEmbedFileSrc.js";
9
+ import { singleFileFromValue as pe } from "./value.js";
10
+ import { useCallback as s, useEffect as me, useMemo as he, useRef as c, useState as l } from "react";
11
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
12
12
  //#region src/components/file-widgets/ImageWidget.tsx
13
- function me(e, t) {
14
- return s(e, t);
15
- }
16
- function p(e) {
13
+ function f(e) {
17
14
  let t = e.trim().split(/\s+/).filter(Boolean);
18
15
  return t.length === 1 ? t[0].slice(0, 2).toUpperCase() : (t[0][0] + t[1][0]).toUpperCase();
19
16
  }
20
- function m(s) {
21
- let { field: p, fieldName: m, value: ve, onChange: v, mode: ye, alt: y, recordTitle: be, disabled: b, visual: x, uploadFieldCode: S, uploadSlotCode: C } = s, w = de(ve), [T, E] = u("idle"), [D, O] = u(null), [k, A] = u(null), [j, M] = u(null), [N, P] = u(!1), F = l(null), I = l(!1), L = l(null), { register: R, unregister: z, isDraft: B } = le(), V = n(), H = n("errors");
22
- fe(() => () => {
17
+ function p(f) {
18
+ let { field: p, fieldName: _, value: ye, onChange: v, mode: be, alt: y, recordTitle: xe, disabled: b, visual: x, uploadFieldCode: S, uploadSlotCode: C } = f, w = pe(ye), [T, E] = l("idle"), [D, O] = l(null), [k, A] = l(null), [j, M] = l(null), [N, P] = l(!1), F = c(null), I = c(!1), L = c(null), { register: R, unregister: z, isDraft: B } = de(), V = n(), H = n("errors");
19
+ me(() => () => {
23
20
  F.current && F.current.abort();
24
21
  }, []);
25
- let U = t(), W = e(), G = pe(() => se(w, y, m, U, W), [
22
+ let U = t(), W = e(), G = he(() => le(w, y, ae(V, p, _), U, W), [
26
23
  y,
27
- m,
24
+ V,
25
+ p,
26
+ _,
28
27
  w,
29
28
  U,
30
29
  W
31
- ]), K = p.display?.initials ? be?.trim() : void 0, xe = (p.accepts ?? ["image/*"]).join(","), q = c(async (e) => {
30
+ ]), K = p.display?.initials ? xe?.trim() : void 0, Se = (p.accepts ?? ["image/*"]).join(","), q = s(async (e) => {
32
31
  let t = re(e, p.accepts, p.max_size_bytes);
33
32
  if (t) {
34
33
  A(ee(V, H, t)), E("error");
@@ -38,7 +37,7 @@ function m(s) {
38
37
  if (p.display?.crop_on_upload) try {
39
38
  let { blob: t, filename: r } = await ie()({
40
39
  file: e,
41
- aspectRatio: ge(p.display.aspect_ratio)
40
+ aspectRatio: _e(p.display.aspect_ratio)
42
41
  });
43
42
  n = new File([t], r, { type: t.type || e.type });
44
43
  } catch {
@@ -58,8 +57,8 @@ function m(s) {
58
57
  try {
59
58
  let e = await ne({
60
59
  file: n,
61
- entityCode: s.entityCode,
62
- fieldCode: S ?? m,
60
+ entityCode: f.entityCode,
61
+ fieldCode: S ?? _,
63
62
  slotCode: C,
64
63
  signal: a.signal,
65
64
  onProgress: O
@@ -93,22 +92,22 @@ function m(s) {
93
92
  p.display?.crop_on_upload,
94
93
  p.display?.aspect_ratio,
95
94
  p.mode,
96
- m,
95
+ _,
97
96
  v,
98
- s.entityCode,
97
+ f.entityCode,
99
98
  R,
100
99
  B,
101
100
  w,
102
101
  z,
103
102
  S,
104
103
  C
105
- ]), Se = c(() => {
104
+ ]), Ce = s(() => {
106
105
  T === "uploading" && F.current && (I.current = !0, F.current.abort(), F.current = null, E("idle"), O(null)), j && (i(j).catch(() => {}), z(j), M(null));
107
106
  }, [
108
107
  T,
109
108
  j,
110
109
  z
111
- ]), Ce = c(() => {
110
+ ]), we = s(() => {
112
111
  w && B(w.id) && (i(w.id).catch(() => {}), z(w.id), M(null)), v?.(p.mode === "array" ? [] : null);
113
112
  }, [
114
113
  w,
@@ -116,30 +115,30 @@ function m(s) {
116
115
  B,
117
116
  v,
118
117
  z
119
- ]), we = c(() => {
118
+ ]), Te = s(() => {
120
119
  A(null), E("idle"), L.current?.click();
121
- }, []), J = c(() => {
120
+ }, []), J = s(() => {
122
121
  b || L.current?.click();
123
- }, [b]), Te = c((e) => {
122
+ }, [b]), Ee = s((e) => {
124
123
  b || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), J());
125
- }, [b, J]), Ee = c((e) => {
124
+ }, [b, J]), De = s((e) => {
126
125
  b || (e.preventDefault(), e.dataTransfer.dropEffect = "copy");
127
- }, [b]), Y = c((e) => {
126
+ }, [b]), Oe = s((e) => {
128
127
  if (b) return;
129
128
  e.preventDefault();
130
129
  let t = e.dataTransfer.files?.[0];
131
130
  t && q(t);
132
- }, [b, q]), De = c((e) => {
131
+ }, [b, q]), ke = s((e) => {
133
132
  let t = e.target.files?.[0];
134
133
  e.target.value = "", t && q(t);
135
- }, [q]), Oe = x.aspectRatio ?? he(x.shape, p.display?.aspect_ratio), X = oe(w), Z = {
136
- aspectRatio: Oe,
134
+ }, [q]), Ae = x.aspectRatio ?? ge(x.shape, p.display?.aspect_ratio), Y = ce(w), X = {
135
+ aspectRatio: Ae,
137
136
  width: x.width ?? (x.shape === "wide" ? "100%" : "120px")
138
- }, Q = !!w, ke = me(w, p.display?.listable_thumbnail), Ae = ae(w, p.display?.listable_thumbnail), $ = ue(w?.id, Ae, ke), je = ye === "display", Me = c((e) => {
137
+ }, Z = !!w, Q = oe(w, p.display?.listable_thumbnail), $ = fe(Q?.id, "preview", Q && se(Q)), je = be === "display", Me = s((e) => {
139
138
  e.stopPropagation(), P((e) => !e);
140
- }, []), Ne = c((e) => {
139
+ }, []), Ne = s((e) => {
141
140
  if (!w || !N) return;
142
- let t = e.currentTarget.getBoundingClientRect(), n = t.width > 0 ? (e.clientX - t.left) / t.width : .5, r = t.height > 0 ? (e.clientY - t.top) / t.height : .5, i = ce(w, {
141
+ let t = e.currentTarget.getBoundingClientRect(), n = t.width > 0 ? (e.clientX - t.left) / t.width : .5, r = t.height > 0 ? (e.clientY - t.top) / t.height : .5, i = ue(w, {
143
142
  x: Math.max(0, Math.min(1, n)),
144
143
  y: Math.max(0, Math.min(1, r))
145
144
  });
@@ -150,74 +149,74 @@ function m(s) {
150
149
  N,
151
150
  v
152
151
  ]);
153
- return je ? /* @__PURE__ */ d("div", {
154
- className: h(x.shape, !1),
155
- style: Z,
152
+ return je ? /* @__PURE__ */ u("div", {
153
+ className: m(x.shape, !1),
154
+ style: X,
156
155
  "aria-label": G,
157
- children: Q && $ ? /* @__PURE__ */ d("img", {
156
+ children: Z && $ ? /* @__PURE__ */ u("img", {
158
157
  src: $,
159
158
  alt: G,
160
- className: g(x.shape),
161
- style: { objectPosition: o(X) },
159
+ className: h(x.shape),
160
+ style: { objectPosition: o(Y) },
162
161
  loading: "lazy"
163
- }) : /* @__PURE__ */ d(_, {
162
+ }) : /* @__PURE__ */ u(g, {
164
163
  shape: x.shape,
165
164
  initialsTitle: K
166
165
  })
167
- }) : /* @__PURE__ */ f("div", {
168
- className: h(x.shape, !b),
169
- style: Z,
166
+ }) : /* @__PURE__ */ d("div", {
167
+ className: m(x.shape, !b),
168
+ style: X,
170
169
  tabIndex: b ? -1 : 0,
171
170
  role: "button",
172
171
  "aria-label": G,
173
172
  "aria-disabled": b || void 0,
174
173
  "aria-busy": T === "uploading" || void 0,
175
174
  "aria-invalid": T === "error" || void 0,
176
- onClick: T === "idle" && !Q ? J : void 0,
175
+ onClick: T === "idle" && !Z ? J : void 0,
177
176
  onMouseDown: N ? Ne : void 0,
178
- onKeyDown: Te,
179
- onDragOver: Ee,
180
- onDrop: Y,
181
- "data-testid": N ? "focal-point-target" : `file-widget-${m}`,
177
+ onKeyDown: Ee,
178
+ onDragOver: De,
179
+ onDrop: Oe,
180
+ "data-testid": N ? "focal-point-target" : `file-widget-${_}`,
182
181
  children: [
183
- /* @__PURE__ */ d("input", {
182
+ /* @__PURE__ */ u("input", {
184
183
  ref: L,
185
184
  type: "file",
186
- accept: xe,
187
- onChange: De,
185
+ accept: Se,
186
+ onChange: ke,
188
187
  style: { display: "none" },
189
- "data-testid": `file-input-${m}`
188
+ "data-testid": `file-input-${_}`
190
189
  }),
191
- Q && $ ? /* @__PURE__ */ d("img", {
190
+ Z && $ ? /* @__PURE__ */ u("img", {
192
191
  src: $,
193
192
  alt: G,
194
- className: g(x.shape),
195
- style: { objectPosition: o(X) },
193
+ className: h(x.shape),
194
+ style: { objectPosition: o(Y) },
196
195
  loading: "lazy"
197
- }) : T === "uploading" ? null : /* @__PURE__ */ d(_, {
196
+ }) : T === "uploading" ? null : /* @__PURE__ */ u(g, {
198
197
  shape: x.shape,
199
198
  initialsTitle: K
200
199
  }),
201
- T === "uploading" && /* @__PURE__ */ d(_e, {
200
+ T === "uploading" && /* @__PURE__ */ u(ve, {
202
201
  pct: D?.pct ?? 0,
203
202
  label: V("file.upload.progress", "Uploading {pct}%", { pct: Math.round(D?.pct ?? 0) })
204
203
  }),
205
- j && /* @__PURE__ */ d("span", {
204
+ j && /* @__PURE__ */ u("span", {
206
205
  className: "absolute right-1 top-1 h-2 w-2 rounded-full bg-warning",
207
206
  "aria-hidden": "true",
208
207
  "data-testid": "draft-indicator"
209
208
  }),
210
- Q && T === "idle" && !b && /* @__PURE__ */ f("div", {
209
+ Z && T === "idle" && !b && /* @__PURE__ */ d("div", {
211
210
  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",
212
211
  children: [
213
- p.display?.focal_point && /* @__PURE__ */ d("button", {
212
+ p.display?.focal_point && /* @__PURE__ */ u("button", {
214
213
  type: "button",
215
214
  className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
216
215
  onClick: Me,
217
216
  "data-testid": "focal-point-toggle",
218
217
  children: N ? V("file.image.focus_cancel", "Cancel focus") : V("file.image.focus_set", "Set focus")
219
218
  }),
220
- /* @__PURE__ */ d("button", {
219
+ /* @__PURE__ */ u("button", {
221
220
  type: "button",
222
221
  className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
223
222
  onClick: (e) => {
@@ -225,45 +224,45 @@ function m(s) {
225
224
  },
226
225
  children: V("file.image.change", "Change")
227
226
  }),
228
- /* @__PURE__ */ d("button", {
227
+ /* @__PURE__ */ u("button", {
229
228
  type: "button",
230
229
  className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-destructive hover:bg-surface-2",
231
230
  onClick: (e) => {
232
- e.stopPropagation(), Ce();
231
+ e.stopPropagation(), we();
233
232
  },
234
233
  children: V("file.remove", "Remove")
235
234
  })
236
235
  ]
237
236
  }),
238
- X && Q && /* @__PURE__ */ d("span", {
237
+ Y && Z && /* @__PURE__ */ u("span", {
239
238
  className: "absolute h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full border border-white bg-black/70",
240
239
  style: {
241
- left: `${X.x * 100}%`,
242
- top: `${X.y * 100}%`
240
+ left: `${Y.x * 100}%`,
241
+ top: `${Y.y * 100}%`
243
242
  },
244
243
  "data-testid": "focal-point-marker"
245
244
  }),
246
- T === "uploading" && /* @__PURE__ */ d("button", {
245
+ T === "uploading" && /* @__PURE__ */ u("button", {
247
246
  type: "button",
248
247
  className: "absolute bottom-1 right-1 rounded-sm border border-border bg-card px-2 py-0.5 text-xs",
249
248
  onClick: (e) => {
250
- e.stopPropagation(), Se();
249
+ e.stopPropagation(), Ce();
251
250
  },
252
251
  "data-testid": "cancel-upload",
253
252
  children: V("file.upload.cancel", "Cancel")
254
253
  }),
255
- T === "error" && k && /* @__PURE__ */ f("div", {
254
+ T === "error" && k && /* @__PURE__ */ d("div", {
256
255
  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",
257
256
  role: "alert",
258
- children: [/* @__PURE__ */ d("span", {
257
+ children: [/* @__PURE__ */ u("span", {
259
258
  className: "truncate",
260
259
  title: k.message,
261
- children: /* @__PURE__ */ d(a, { failure: k })
262
- }), /* @__PURE__ */ d("button", {
260
+ children: /* @__PURE__ */ u(a, { failure: k })
261
+ }), /* @__PURE__ */ u("button", {
263
262
  type: "button",
264
263
  className: "underline",
265
264
  onClick: (e) => {
266
- e.stopPropagation(), we();
265
+ e.stopPropagation(), Te();
267
266
  },
268
267
  "data-testid": "retry-upload",
269
268
  children: V("file.upload.retry", "Retry")
@@ -272,45 +271,45 @@ function m(s) {
272
271
  ]
273
272
  });
274
273
  }
275
- function h(e, t) {
274
+ function m(e, t) {
276
275
  return [
277
276
  "relative overflow-hidden border border-border bg-surface-2",
278
277
  e === "circle" ? "rounded-full" : "rounded-md",
279
278
  t ? "cursor-pointer focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent" : ""
280
279
  ].filter(Boolean).join(" ");
281
280
  }
282
- function g(e) {
281
+ function h(e) {
283
282
  return "h-full w-full object-cover";
284
283
  }
285
- function he(e, t) {
284
+ function ge(e, t) {
286
285
  return t ? t.replace(":", " / ") : e === "wide" ? "16 / 9" : "1 / 1";
287
286
  }
288
- function ge(e) {
287
+ function _e(e) {
289
288
  if (!e) return;
290
289
  let t = e.replace(/\s/g, "").match(/^(\d+(?:\.\d+)?)[:/](\d+(?:\.\d+)?)$/);
291
290
  if (!t) return;
292
291
  let n = Number(t[1]), r = Number(t[2]);
293
292
  if (n && r) return n / r;
294
293
  }
295
- function _({ shape: e, initialsTitle: t }) {
294
+ function g({ shape: e, initialsTitle: t }) {
296
295
  let r = n();
297
- return t ? /* @__PURE__ */ d("div", {
296
+ return t ? /* @__PURE__ */ u("div", {
298
297
  className: "flex h-full w-full items-center justify-center bg-surface-3 text-text-3",
299
- children: /* @__PURE__ */ d("span", {
298
+ children: /* @__PURE__ */ u("span", {
300
299
  className: e === "circle" ? "text-lg font-medium" : "text-base font-medium",
301
- children: p(t)
300
+ children: f(t)
302
301
  })
303
- }) : /* @__PURE__ */ d("div", {
302
+ }) : /* @__PURE__ */ u("div", {
304
303
  className: "flex h-full w-full items-center justify-center bg-surface-3 text-text-4",
305
- children: /* @__PURE__ */ d("span", {
304
+ children: /* @__PURE__ */ u("span", {
306
305
  className: "text-xs",
307
306
  children: e === "wide" ? r("file.image.drop", "Drop image here") : "+"
308
307
  })
309
308
  });
310
309
  }
311
- function _e({ pct: e, label: t }) {
310
+ function ve({ pct: e, label: t }) {
312
311
  let n = 2 * Math.PI * 18, r = n - Math.max(0, Math.min(100, e)) / 100 * n;
313
- return /* @__PURE__ */ f("div", {
312
+ return /* @__PURE__ */ d("div", {
314
313
  className: "absolute inset-0 flex items-center justify-center bg-black/30",
315
314
  "data-testid": "upload-progress",
316
315
  "aria-label": t,
@@ -318,11 +317,11 @@ function _e({ pct: e, label: t }) {
318
317
  "aria-valuenow": Math.round(e),
319
318
  "aria-valuemin": 0,
320
319
  "aria-valuemax": 100,
321
- children: [/* @__PURE__ */ f("svg", {
320
+ children: [/* @__PURE__ */ d("svg", {
322
321
  width: "48",
323
322
  height: "48",
324
323
  viewBox: "0 0 48 48",
325
- children: [/* @__PURE__ */ d("circle", {
324
+ children: [/* @__PURE__ */ u("circle", {
326
325
  cx: "24",
327
326
  cy: "24",
328
327
  r: 18,
@@ -331,7 +330,7 @@ function _e({ pct: e, label: t }) {
331
330
  strokeWidth: "4",
332
331
  fill: "none",
333
332
  className: "text-foreground"
334
- }), /* @__PURE__ */ d("circle", {
333
+ }), /* @__PURE__ */ u("circle", {
335
334
  cx: "24",
336
335
  cy: "24",
337
336
  r: 18,
@@ -344,11 +343,11 @@ function _e({ pct: e, label: t }) {
344
343
  className: "text-accent",
345
344
  transform: "rotate(-90 24 24)"
346
345
  })]
347
- }), /* @__PURE__ */ f("span", {
346
+ }), /* @__PURE__ */ d("span", {
348
347
  className: "absolute text-xs text-foreground",
349
348
  children: [Math.round(e), "%"]
350
349
  })]
351
350
  });
352
351
  }
353
352
  //#endregion
354
- export { m as ImageWidget };
353
+ export { p as ImageWidget };
@@ -19,6 +19,7 @@ function s(e, t, n, r) {
19
19
  slots: void 0,
20
20
  display: {
21
21
  ...e.display ?? { widget: "document_card" },
22
+ name: n.name,
22
23
  widget: o(n, r) ? "square_image" : "document_card",
23
24
  aspect_ratio: n.aspect_ratio ?? e.display?.aspect_ratio
24
25
  }
@@ -1,7 +1,10 @@
1
1
  import { pickLocalized as e } from "../../lib/language.js";
2
2
  //#region src/components/file-widgets/helpers.ts
3
3
  var t = ["thumb_200", "thumb_300"];
4
- function n(t, n, r, i, a) {
4
+ function n(e, t, n) {
5
+ return e(t.display?.name) || n;
6
+ }
7
+ function r(t, n, r, i, a) {
5
8
  if (n) return n;
6
9
  let o = t?.metadata?.alt_text;
7
10
  if (typeof o == "string" && o.length > 0) return o;
@@ -11,7 +14,7 @@ function n(t, n, r, i, a) {
11
14
  }
12
15
  return r;
13
16
  }
14
- var r = /* @__PURE__ */ new Set([
17
+ var i = /* @__PURE__ */ new Set([
15
18
  "image/png",
16
19
  "image/jpeg",
17
20
  "image/webp",
@@ -19,28 +22,21 @@ var r = /* @__PURE__ */ new Set([
19
22
  "image/avif",
20
23
  "application/pdf"
21
24
  ]);
22
- function i(e) {
23
- let t = e.content_type?.toLowerCase().split(";")[0]?.trim() ?? "";
24
- return r.has(t);
25
- }
26
25
  function a(e) {
27
- return e.url ?? e.presigned_url;
26
+ let t = e.content_type?.toLowerCase().split(";")[0]?.trim() ?? "";
27
+ return i.has(t);
28
28
  }
29
29
  function o(e) {
30
- return e.url ? l(e.url, "attachment") : e.presigned_url;
30
+ return e.url;
31
31
  }
32
- function s(e, n) {
33
- if (!e) return;
34
- let r = e.derivations ?? {};
35
- if (n && r[n]) return r[n];
36
- for (let e of t) if (r[e]) return r[e];
37
- return e.url ?? e.presigned_url;
32
+ function s(e) {
33
+ return l(e.url, "attachment");
38
34
  }
39
35
  function c(e, n) {
40
- let r = e?.derivations ?? {};
41
- if (n && r[n]) return { derivation: n };
42
- for (let e of t) if (r[e]) return { derivation: e };
43
- return "preview";
36
+ if (!e) return;
37
+ let r = e.derivations ?? {};
38
+ for (let e of [n, ...t]) if (e && r[e]) return r[e];
39
+ return e;
44
40
  }
45
41
  function l(e, t) {
46
42
  try {
@@ -72,4 +68,4 @@ function f(e, t) {
72
68
  };
73
69
  }
74
70
  //#endregion
75
- export { i as canPreviewFile, o as downloadFileURL, d as focalPointObjectPosition, s as preferredListThumbnailURL, c as preferredThumbnailVariant, a as previewFileURL, u as readFocalPoint, n as resolveFileAltText, f as withFocalPoint };
71
+ 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 };
@@ -1,65 +1,66 @@
1
1
  import { fieldDisplayName as e, getDisplayValue as t } from "../../types/schema.js";
2
2
  import { createRichTextValue as n, richTextMarkdown as r } from "../../lib/rich-text.js";
3
3
  import { getFileWidget as i } from "./registry.js";
4
- import { UnknownFileWidget as a } from "./UnknownFileWidget.js";
5
- import { registerBuiltinFileWidgets as o } from "./builtins.js";
6
- import { renderField as s } from "../fields/index.js";
7
- import { jsx as c } from "react/jsx-runtime";
4
+ import { fileFieldLabel as a } from "./helpers.js";
5
+ import { UnknownFileWidget as o } from "./UnknownFileWidget.js";
6
+ import { registerBuiltinFileWidgets as s } from "./builtins.js";
7
+ import { renderField as c } from "../fields/index.js";
8
+ import { jsx as l } from "react/jsx-runtime";
8
9
  //#region src/components/file-widgets/host.tsx
9
- o();
10
- function l(e, t) {
10
+ s();
11
+ function u(e, t) {
11
12
  return e.files?.get(t);
12
13
  }
13
- function u(e, t) {
14
+ function d(e, t) {
14
15
  return Object.prototype.hasOwnProperty.call(e, t) ? e[t] ?? null : e.$files?.[t] ?? null;
15
16
  }
16
- function d(e, t, r) {
17
- if (l(e, r)) return u(t, r);
17
+ function f(e, t, r) {
18
+ if (u(e, r)) return d(t, r);
18
19
  let i = e.fields.get(r);
19
- return i?.type === "rich_text" && i.files?.mode === "rich_text_inline" ? n(t[r], u(t, r)) : t[r];
20
+ return i?.type === "rich_text" && i.files?.mode === "rich_text_inline" ? n(t[r], d(t, r)) : t[r];
20
21
  }
21
- function f(e, t, n) {
22
- let r = d(e, t, n);
22
+ function p(e, t, n) {
23
+ let r = f(e, t, n);
23
24
  return r == null || r === "" ? !1 : Array.isArray(r) ? r.length > 0 : typeof r != "object" || Object.keys(r).length > 0;
24
25
  }
25
- function p(e, t, n) {
26
+ function m(e, t, n) {
26
27
  let i = e.fields.get(t);
27
28
  return i?.type === "rich_text" && i.files?.mode === "rich_text_inline" ? r(n) : n;
28
29
  }
29
- function m(t, n, r, i) {
30
- let a = l(n, r);
31
- if (a) return a.name || r;
32
- let o = n.fields.get(r);
33
- return o ? e(t, o, r, i) : r;
30
+ function h(t, n, r, i) {
31
+ let o = u(n, r);
32
+ if (o) return a(t, o, r);
33
+ let s = n.fields.get(r);
34
+ return s ? e(t, s, r, i) : r;
34
35
  }
35
- function h(e) {
36
- let { entity: n, entityCode: r, fieldName: o, record: f, mode: p, onChange: m, refs: h, disabled: g, surface: _, entities: v, screens: y, t: b, fieldId: x, labelId: S, structure: C, detailScreen: w } = e, T = l(n, o);
36
+ function g(e) {
37
+ let { entity: n, entityCode: r, fieldName: a, record: s, mode: p, onChange: m, refs: h, disabled: g, surface: _, entities: v, screens: y, t: b, fieldId: x, labelId: S, structure: C, detailScreen: w } = e, T = u(n, a);
37
38
  if (T) {
38
- let e = T.display?.widget ?? "", s = i(e);
39
- return s ? /* @__PURE__ */ c(s, {
39
+ let e = T.display?.widget ?? "", c = i(e);
40
+ return c ? /* @__PURE__ */ l(c, {
40
41
  field: T,
41
- fieldName: o,
42
+ fieldName: a,
42
43
  entityCode: r,
43
- value: u(f, o),
44
- recordTitle: t(b, f, n),
44
+ value: d(s, a),
45
+ recordTitle: t(b, s, n),
45
46
  mode: p,
46
47
  onChange: m,
47
48
  disabled: g,
48
49
  fieldId: x
49
- }) : /* @__PURE__ */ c(a, { widgetCode: e });
50
+ }) : /* @__PURE__ */ l(o, { widgetCode: e });
50
51
  }
51
- let E = n.fields.get(o), D = C && p === "display" && E ? {
52
+ let E = n.fields.get(a), D = C && p === "display" && E ? {
52
53
  ...E,
53
54
  structure: C
54
55
  } : E;
55
- return D ? s({
56
+ return D ? c({
56
57
  field: D,
57
58
  entityCode: r,
58
- fieldName: o,
59
- value: d(n, f, o),
59
+ fieldName: a,
60
+ value: f(n, s, a),
60
61
  mode: p,
61
62
  onChange: m,
62
- record: f,
63
+ record: s,
63
64
  refs: h,
64
65
  surface: _,
65
66
  entity: r && v ? v[r] : void 0,
@@ -72,4 +73,4 @@ function h(e) {
72
73
  }) : null;
73
74
  }
74
75
  //#endregion
75
- export { l as getEntityFileField, u as getFileFieldValue, d as getSchemaFieldValue, h as renderSchemaField, m as resolveSchemaFieldLabel, f as schemaFieldHasValue, p as serializeSchemaFieldValue };
76
+ export { u as getEntityFileField, d as getFileFieldValue, f as getSchemaFieldValue, g as renderSchemaField, h as resolveSchemaFieldLabel, p as schemaFieldHasValue, m as serializeSchemaFieldValue };
@@ -98,18 +98,22 @@ function m(e, t, n) {
98
98
  return i ? `/api/files/upload?${i}` : "/api/files/upload";
99
99
  }
100
100
  function h(e) {
101
- return _(e) ? _(e.result) ? h(e.result) : _(e.file) ? g(e.file) : typeof e.id == "string" ? e : null : null;
101
+ return _(e) && _(e.file) ? g(e.file) : null;
102
102
  }
103
103
  function g(e) {
104
- let t = v(e.file_id);
105
- return t ? {
104
+ let t = v(e.file_id), n = v(e.url);
105
+ if (!t || !n) return null;
106
+ let r = v(e.filename_original) ?? v(e.filename_normalized) ?? t;
107
+ return {
106
108
  id: t,
107
- filename: v(e.filename_original) ?? v(e.filename_normalized) ?? t,
109
+ url: n,
110
+ presigned_url: v(e.presigned_url),
111
+ filename: r,
108
112
  content_type: v(e.content_type) ?? "application/octet-stream",
109
113
  size_bytes: y(e.size_bytes) ?? 0,
110
114
  sha256: v(e.sha256) ?? "",
111
115
  dedup: b(e.dedup)
112
- } : null;
116
+ };
113
117
  }
114
118
  function _(e) {
115
119
  return typeof e == "object" && !!e;
@@ -124,7 +128,7 @@ function b(e) {
124
128
  return typeof e == "boolean" ? e : void 0;
125
129
  }
126
130
  async function x(e) {
127
- await a("files.discard", { file_id: e });
131
+ await a("file.discard", { file_id: e });
128
132
  }
129
133
  var S = "This file is larger than the deployment allows.", C = "This file does not satisfy the field it was attached to.";
130
134
  function w(e, t, n) {