@declarion/react 0.66.0 → 0.80.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/README.md +1 -1
- package/dist-lib/api/auth.js +24 -14
- package/dist-lib/app.js +28 -23
- package/dist-lib/components/chrome/AssociationTabs.js +35 -38
- package/dist-lib/components/chrome/HighlightsStrip.js +2 -1
- package/dist-lib/components/chrome/RecordHeader.js +33 -38
- package/dist-lib/components/detail-layout/AssociatedBlock.js +10 -21
- package/dist-lib/components/detail-layout/ChildrenBlock.js +1 -8
- package/dist-lib/components/detail-layout/ChildrenCards.js +1 -8
- package/dist-lib/components/detail-layout/ChildrenList.js +1 -8
- package/dist-lib/components/detail-layout/ChildrenTable.js +1 -8
- package/dist-lib/components/detail-layout/ChildrenTimeline.js +1 -8
- package/dist-lib/components/detail-layout/DetailAuditStrip.js +33 -29
- package/dist-lib/components/detail-layout/DetailHighlights.js +7 -2
- package/dist-lib/components/detail-layout/FieldsBlock.js +12 -9
- package/dist-lib/components/detail-layout/LayoutRenderer.js +10 -10
- package/dist-lib/components/detail-layout/LayoutTabs.js +49 -48
- package/dist-lib/components/detail-layout/SectionBlock.js +20 -28
- package/dist-lib/components/detail-layout/visibility.js +28 -0
- package/dist-lib/components/fields/IntArrayField.js +37 -33
- package/dist-lib/components/fields/NumberField.js +28 -55
- package/dist-lib/components/fields/RichTextField.js +1 -1
- package/dist-lib/components/fields/TimestampField.js +50 -89
- package/dist-lib/components/fields/cells/factories/date.js +13 -14
- package/dist-lib/components/fields/cells/factories/money.js +1 -1
- package/dist-lib/components/fields/cells/factories/number.js +4 -4
- package/dist-lib/components/file-widgets/DocumentCard.js +1 -1
- package/dist-lib/components/file-widgets/Grid.js +153 -152
- package/dist-lib/components/file-widgets/ImageWidget.js +90 -91
- package/dist-lib/components/file-widgets/LabeledSlots.js +1 -0
- package/dist-lib/components/file-widgets/helpers.js +15 -19
- package/dist-lib/components/file-widgets/host.js +33 -32
- package/dist-lib/components/file-widgets/upload.js +10 -6
- package/dist-lib/components/layout/Layout.js +125 -123
- package/dist-lib/components/pages/NoScreensPage.impl.js +14 -0
- package/dist-lib/components/pages/NoScreensPage.js +12 -0
- package/dist-lib/components/pages/SmartDetailPage.impl.js +451 -451
- package/dist-lib/components/pages/auth/AuthShell.js +62 -61
- package/dist-lib/components/pages/auth/CodeInput.js +63 -0
- package/dist-lib/components/pages/auth/SignIn.js +12 -4
- package/dist-lib/components/pages/auth/SignUp.impl.js +80 -103
- package/dist-lib/components/pages/auth/SignUpCode.js +122 -0
- package/dist-lib/components/pages/auth/TwoFA.impl.js +9 -55
- package/dist-lib/components/pages/list/cardProjection.js +135 -122
- package/dist-lib/components/pages/list/columns.js +58 -43
- package/dist-lib/components/pages/profile/Profile.impl.js +87 -104
- package/dist-lib/components/pages/tenant-params/TenantParamsPage.impl.js +1 -1
- package/dist-lib/components/params/ParamsBlock.js +6 -17
- package/dist-lib/components/params/param-editors.js +14 -10
- package/dist-lib/components/primitives/Fields.js +314 -236
- package/dist-lib/components/shared/MarkdownRenderer.js +44 -43
- package/dist-lib/declarion-react.css +1 -1
- package/dist-lib/hooks/useActiveTabFollowsRoute.js +49 -0
- package/dist-lib/hooks/useAuth.js +44 -37
- package/dist-lib/hooks/useDocumentTitle.js +20 -0
- package/dist-lib/hooks/useFollowAgentOpen.js +1 -0
- package/dist-lib/hooks/useTabTitle.js +1 -1
- package/dist-lib/index.d.ts +21 -7
- package/dist-lib/lib/date-text.js +57 -0
- package/dist-lib/lib/number-text.js +9 -0
- package/dist-lib/lib/timestamp.js +29 -29
- package/dist-lib/stores/tabs.js +7 -5
- package/dist-lib/testing.d.ts +1 -1
- package/dist-lib/testing.js +1 -0
- package/dist-lib/{useResponsiveMode-DmrpMbZX.d.ts → useResponsiveMode-D3SKz5z4.d.ts} +20 -9
- 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,
|
|
7
|
-
import { useDraftRegistration as
|
|
8
|
-
import { useEmbedFileSrc as
|
|
9
|
-
import { singleFileFromValue as
|
|
10
|
-
import { useCallback as
|
|
11
|
-
import { jsx as
|
|
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
|
|
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
|
|
21
|
-
let { field: p, fieldName:
|
|
22
|
-
|
|
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 =
|
|
22
|
+
let U = t(), W = e(), G = he(() => le(w, y, ae(V, p, _), U, W), [
|
|
26
23
|
y,
|
|
27
|
-
|
|
24
|
+
V,
|
|
25
|
+
p,
|
|
26
|
+
_,
|
|
28
27
|
w,
|
|
29
28
|
U,
|
|
30
29
|
W
|
|
31
|
-
]), K = p.display?.initials ?
|
|
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:
|
|
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:
|
|
62
|
-
fieldCode: S ??
|
|
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
|
-
|
|
95
|
+
_,
|
|
97
96
|
v,
|
|
98
|
-
|
|
97
|
+
f.entityCode,
|
|
99
98
|
R,
|
|
100
99
|
B,
|
|
101
100
|
w,
|
|
102
101
|
z,
|
|
103
102
|
S,
|
|
104
103
|
C
|
|
105
|
-
]),
|
|
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
|
-
]),
|
|
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
|
-
]),
|
|
118
|
+
]), Te = s(() => {
|
|
120
119
|
A(null), E("idle"), L.current?.click();
|
|
121
|
-
}, []), J =
|
|
120
|
+
}, []), J = s(() => {
|
|
122
121
|
b || L.current?.click();
|
|
123
|
-
}, [b]),
|
|
122
|
+
}, [b]), Ee = s((e) => {
|
|
124
123
|
b || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), J());
|
|
125
|
-
}, [b, J]),
|
|
124
|
+
}, [b, J]), De = s((e) => {
|
|
126
125
|
b || (e.preventDefault(), e.dataTransfer.dropEffect = "copy");
|
|
127
|
-
}, [b]),
|
|
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]),
|
|
131
|
+
}, [b, q]), ke = s((e) => {
|
|
133
132
|
let t = e.target.files?.[0];
|
|
134
133
|
e.target.value = "", t && q(t);
|
|
135
|
-
}, [q]),
|
|
136
|
-
aspectRatio:
|
|
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
|
-
},
|
|
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 =
|
|
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 =
|
|
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__ */
|
|
154
|
-
className:
|
|
155
|
-
style:
|
|
152
|
+
return je ? /* @__PURE__ */ u("div", {
|
|
153
|
+
className: m(x.shape, !1),
|
|
154
|
+
style: X,
|
|
156
155
|
"aria-label": G,
|
|
157
|
-
children:
|
|
156
|
+
children: Z && $ ? /* @__PURE__ */ u("img", {
|
|
158
157
|
src: $,
|
|
159
158
|
alt: G,
|
|
160
|
-
className:
|
|
161
|
-
style: { objectPosition: o(
|
|
159
|
+
className: h(x.shape),
|
|
160
|
+
style: { objectPosition: o(Y) },
|
|
162
161
|
loading: "lazy"
|
|
163
|
-
}) : /* @__PURE__ */
|
|
162
|
+
}) : /* @__PURE__ */ u(g, {
|
|
164
163
|
shape: x.shape,
|
|
165
164
|
initialsTitle: K
|
|
166
165
|
})
|
|
167
|
-
}) : /* @__PURE__ */
|
|
168
|
-
className:
|
|
169
|
-
style:
|
|
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" && !
|
|
175
|
+
onClick: T === "idle" && !Z ? J : void 0,
|
|
177
176
|
onMouseDown: N ? Ne : void 0,
|
|
178
|
-
onKeyDown:
|
|
179
|
-
onDragOver:
|
|
180
|
-
onDrop:
|
|
181
|
-
"data-testid": N ? "focal-point-target" : `file-widget-${
|
|
177
|
+
onKeyDown: Ee,
|
|
178
|
+
onDragOver: De,
|
|
179
|
+
onDrop: Oe,
|
|
180
|
+
"data-testid": N ? "focal-point-target" : `file-widget-${_}`,
|
|
182
181
|
children: [
|
|
183
|
-
/* @__PURE__ */
|
|
182
|
+
/* @__PURE__ */ u("input", {
|
|
184
183
|
ref: L,
|
|
185
184
|
type: "file",
|
|
186
|
-
accept:
|
|
187
|
-
onChange:
|
|
185
|
+
accept: Se,
|
|
186
|
+
onChange: ke,
|
|
188
187
|
style: { display: "none" },
|
|
189
|
-
"data-testid": `file-input-${
|
|
188
|
+
"data-testid": `file-input-${_}`
|
|
190
189
|
}),
|
|
191
|
-
|
|
190
|
+
Z && $ ? /* @__PURE__ */ u("img", {
|
|
192
191
|
src: $,
|
|
193
192
|
alt: G,
|
|
194
|
-
className:
|
|
195
|
-
style: { objectPosition: o(
|
|
193
|
+
className: h(x.shape),
|
|
194
|
+
style: { objectPosition: o(Y) },
|
|
196
195
|
loading: "lazy"
|
|
197
|
-
}) : T === "uploading" ? null : /* @__PURE__ */
|
|
196
|
+
}) : T === "uploading" ? null : /* @__PURE__ */ u(g, {
|
|
198
197
|
shape: x.shape,
|
|
199
198
|
initialsTitle: K
|
|
200
199
|
}),
|
|
201
|
-
T === "uploading" && /* @__PURE__ */
|
|
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__ */
|
|
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
|
-
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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(),
|
|
231
|
+
e.stopPropagation(), we();
|
|
233
232
|
},
|
|
234
233
|
children: V("file.remove", "Remove")
|
|
235
234
|
})
|
|
236
235
|
]
|
|
237
236
|
}),
|
|
238
|
-
|
|
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: `${
|
|
242
|
-
top: `${
|
|
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__ */
|
|
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(),
|
|
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__ */
|
|
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__ */
|
|
257
|
+
children: [/* @__PURE__ */ u("span", {
|
|
259
258
|
className: "truncate",
|
|
260
259
|
title: k.message,
|
|
261
|
-
children: /* @__PURE__ */
|
|
262
|
-
}), /* @__PURE__ */
|
|
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(),
|
|
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
|
|
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
|
|
281
|
+
function h(e) {
|
|
283
282
|
return "h-full w-full object-cover";
|
|
284
283
|
}
|
|
285
|
-
function
|
|
284
|
+
function ge(e, t) {
|
|
286
285
|
return t ? t.replace(":", " / ") : e === "wide" ? "16 / 9" : "1 / 1";
|
|
287
286
|
}
|
|
288
|
-
function
|
|
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
|
|
294
|
+
function g({ shape: e, initialsTitle: t }) {
|
|
296
295
|
let r = n();
|
|
297
|
-
return t ? /* @__PURE__ */
|
|
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__ */
|
|
298
|
+
children: /* @__PURE__ */ u("span", {
|
|
300
299
|
className: e === "circle" ? "text-lg font-medium" : "text-base font-medium",
|
|
301
|
-
children:
|
|
300
|
+
children: f(t)
|
|
302
301
|
})
|
|
303
|
-
}) : /* @__PURE__ */
|
|
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__ */
|
|
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
|
|
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__ */
|
|
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__ */
|
|
320
|
+
children: [/* @__PURE__ */ d("svg", {
|
|
322
321
|
width: "48",
|
|
323
322
|
height: "48",
|
|
324
323
|
viewBox: "0 0 48 48",
|
|
325
|
-
children: [/* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
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 {
|
|
353
|
+
export { p as ImageWidget };
|
|
@@ -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
|
|
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
|
|
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
|
-
|
|
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
|
|
30
|
+
return e.url;
|
|
31
31
|
}
|
|
32
|
-
function s(e
|
|
33
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
for (let e of t) if (r[e]) return
|
|
43
|
-
return
|
|
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 {
|
|
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 {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
-
|
|
10
|
-
function
|
|
10
|
+
s();
|
|
11
|
+
function u(e, t) {
|
|
11
12
|
return e.files?.get(t);
|
|
12
13
|
}
|
|
13
|
-
function
|
|
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
|
|
17
|
-
if (
|
|
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],
|
|
20
|
+
return i?.type === "rich_text" && i.files?.mode === "rich_text_inline" ? n(t[r], d(t, r)) : t[r];
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
let r =
|
|
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
|
|
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
|
|
30
|
-
let
|
|
31
|
-
if (
|
|
32
|
-
let
|
|
33
|
-
return
|
|
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
|
|
36
|
-
let { entity: n, entityCode: r, fieldName:
|
|
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 ?? "",
|
|
39
|
-
return
|
|
39
|
+
let e = T.display?.widget ?? "", c = i(e);
|
|
40
|
+
return c ? /* @__PURE__ */ l(c, {
|
|
40
41
|
field: T,
|
|
41
|
-
fieldName:
|
|
42
|
+
fieldName: a,
|
|
42
43
|
entityCode: r,
|
|
43
|
-
value:
|
|
44
|
-
recordTitle: t(b,
|
|
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__ */
|
|
50
|
+
}) : /* @__PURE__ */ l(o, { widgetCode: e });
|
|
50
51
|
}
|
|
51
|
-
let E = n.fields.get(
|
|
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 ?
|
|
56
|
+
return D ? c({
|
|
56
57
|
field: D,
|
|
57
58
|
entityCode: r,
|
|
58
|
-
fieldName:
|
|
59
|
-
value:
|
|
59
|
+
fieldName: a,
|
|
60
|
+
value: f(n, s, a),
|
|
60
61
|
mode: p,
|
|
61
62
|
onChange: m,
|
|
62
|
-
record:
|
|
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 {
|
|
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)
|
|
101
|
+
return _(e) && _(e.file) ? g(e.file) : null;
|
|
102
102
|
}
|
|
103
103
|
function g(e) {
|
|
104
|
-
let t = v(e.file_id);
|
|
105
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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("
|
|
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) {
|