@declarion/react 0.87.0 → 0.89.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/app.js +28 -28
- package/dist-lib/components/actions/ActionButton.js +86 -85
- package/dist-lib/components/actions/ActionResultDialog.impl.js +47 -47
- package/dist-lib/components/actions/ActionRunner.js +47 -47
- package/dist-lib/components/actions/ObjectActionBar.js +9 -9
- package/dist-lib/components/actions/RowActionsKebab.js +19 -19
- package/dist-lib/components/agents/AgentChatPanel.impl.js +53 -53
- package/dist-lib/components/chrome/AssociationTabs.js +21 -21
- package/dist-lib/components/chrome/RecordHeader.js +33 -40
- package/dist-lib/components/detail-layout/AssociatedBlock.js +387 -381
- package/dist-lib/components/detail-layout/ChildrenBlock.js +12 -13
- package/dist-lib/components/detail-layout/ChildrenTimeline.js +198 -198
- package/dist-lib/components/detail-layout/DraggableChildrenTable.js +114 -114
- package/dist-lib/components/detail-layout/EditableChildrenTable.js +160 -160
- package/dist-lib/components/detail-layout/EvidenceBlock.js +20 -21
- package/dist-lib/components/detail-layout/PropertiesBlock.js +45 -39
- package/dist-lib/components/detail-layout/QuickAddForm.js +9 -9
- package/dist-lib/components/detail-layout/TimelineComposer.js +87 -89
- package/dist-lib/components/detail-layout/widgets/EntityScorecardWidget.js +100 -99
- package/dist-lib/components/fields/FileReferenceField.js +9 -9
- package/dist-lib/components/fields/StructureField.js +57 -47
- package/dist-lib/components/fields/TimestampField.js +59 -54
- package/dist-lib/components/fields/cells/factories/money.js +14 -23
- package/dist-lib/components/fields/cells/factories/nextRun.js +1 -1
- package/dist-lib/components/fields/cells/factories/text.js +18 -3
- package/dist-lib/components/fields/cells/factories/timestamp.js +24 -12
- package/dist-lib/components/file-widgets/DocumentCard.js +108 -106
- package/dist-lib/components/layout/Layout.js +306 -361
- package/dist-lib/components/layout/Rail.js +42 -41
- package/dist-lib/components/layout/Sidebar.js +132 -117
- package/dist-lib/components/layout/TabStrip.js +116 -115
- package/dist-lib/components/layout/TenantChip.js +47 -54
- package/dist-lib/components/layout/TopBar.js +108 -105
- package/dist-lib/components/list/InlineEditCell.js +23 -23
- package/dist-lib/components/list/QuickPeek.js +65 -66
- package/dist-lib/components/pages/DocumentsMenu.js +42 -42
- package/dist-lib/components/pages/ExportMenu.js +25 -25
- package/dist-lib/components/pages/RecordDocumentsPanel.js +35 -35
- package/dist-lib/components/pages/RecordNotesPanel.js +94 -93
- package/dist-lib/components/pages/SmartDetailPage.impl.js +421 -417
- package/dist-lib/components/pages/SmartListPage.impl.js +293 -295
- package/dist-lib/components/pages/SmartRecordListPage.impl.js +310 -310
- package/dist-lib/components/pages/auth/AuthShell.js +73 -73
- package/dist-lib/components/pages/auth/SignIn.js +32 -32
- package/dist-lib/components/pages/auth/SignUp.impl.js +3 -3
- package/dist-lib/components/pages/auth/SignUpCode.js +9 -9
- package/dist-lib/components/pages/list/ListFloatbar.js +12 -12
- package/dist-lib/components/pages/list/ListHeader.js +19 -19
- package/dist-lib/components/pages/list/ListNoRows.js +15 -15
- package/dist-lib/components/pages/list/ListToolbar.js +145 -145
- package/dist-lib/components/pages/list/useActiveView.js +14 -5
- package/dist-lib/components/pages/list/useListQuery.js +121 -81
- package/dist-lib/components/pages/list/useListRowInteraction.js +70 -70
- package/dist-lib/components/pages/list/useRowMenu.js +7 -7
- package/dist-lib/components/pages/profile/Preferences.impl.js +81 -78
- package/dist-lib/components/pages/profile/Profile.impl.js +191 -189
- package/dist-lib/components/pages/tenant-params/TenantParamsPage.impl.js +166 -158
- package/dist-lib/components/shared/ChangePasswordDialog.impl.js +23 -23
- package/dist-lib/components/shared/MarkdownRenderer.js +9 -9
- package/dist-lib/hooks/useAuth.js +11 -11
- package/dist-lib/hooks/useBranding.js +4 -4
- package/dist-lib/hooks/useDisplayTimeZone.js +8 -0
- package/dist-lib/hooks/useFollowAgentOpen.js +24 -24
- package/dist-lib/hooks/useImpersonation.js +6 -6
- package/dist-lib/hooks/useMutations.js +23 -23
- package/dist-lib/hooks/useObjectStatus.js +5 -5
- package/dist-lib/hooks/useParams.js +59 -51
- package/dist-lib/hooks/useProperties.js +8 -8
- package/dist-lib/hooks/useRowTenant.js +18 -6
- package/dist-lib/hooks/useText.js +9 -7
- package/dist-lib/hooks/useUiPreferences.js +71 -0
- package/dist-lib/index.d.ts +22 -6
- package/dist-lib/index.js +127 -126
- package/dist-lib/lib/actions.js +116 -84
- package/dist-lib/lib/child-config.js +10 -1
- package/dist-lib/lib/format-count.js +16 -1
- package/dist-lib/lib/language.js +23 -21
- package/dist-lib/lib/money-text.js +29 -0
- package/dist-lib/lib/profile.js +4 -0
- package/dist-lib/lib/role-label.js +8 -0
- package/dist-lib/lib/schema-routing.js +34 -14
- package/dist-lib/lib/shortcut.js +10 -0
- package/dist-lib/lib/timestamp.js +93 -31
- package/dist-lib/stores/auth.js +9 -8
- package/dist-lib/stores/preferences.js +56 -17
- package/dist-lib/testing.d.ts +1 -1
- package/dist-lib/testing.js +25 -28
- package/dist-lib/types/schema.js +33 -27
- package/dist-lib/{useResponsiveMode-D3SKz5z4.d.ts → useResponsiveMode-9_eJT18k.d.ts} +5 -5
- package/package.json +1 -1
|
@@ -1,71 +1,76 @@
|
|
|
1
1
|
import { coerceDisplayString as e } from "../../lib/display-value.js";
|
|
2
|
-
import { civilDateAsLocal as t,
|
|
3
|
-
import { specialValueMarker as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { civilDateAsLocal as t, editorWallClock as n, editorWireValue as r } from "../../lib/timestamp.js";
|
|
3
|
+
import { specialValueMarker as i, specialValueMarkerCode as a } from "../../types/schema.js";
|
|
4
|
+
import { useSchema as o } from "../../hooks/useSchema.js";
|
|
5
|
+
import { Btn as s } from "../primitives/Btn.js";
|
|
6
|
+
import { DateInput as c, TextInput as l } from "../primitives/Fields.js";
|
|
7
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
7
8
|
//#region src/components/fields/TimestampField.tsx
|
|
8
|
-
var d = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/;
|
|
9
|
-
function f(e) {
|
|
10
|
-
if (!d.test(e)) return "";
|
|
11
|
-
let t = e.match(/([+-]\d{2}:\d{2})$/), n = new Date(e);
|
|
12
|
-
if (isNaN(n.getTime())) return "";
|
|
13
|
-
if (!t && !e.endsWith("Z")) return e.slice(0, 16).replace(" ", "T");
|
|
14
|
-
let r = 0;
|
|
15
|
-
if (t) {
|
|
16
|
-
let e = t[1].charAt(0) === "+" ? 1 : -1, n = parseInt(t[1].substring(1, 3), 10), i = parseInt(t[1].substring(4, 6), 10);
|
|
17
|
-
r = e * (n * 60 + i) * 60 * 1e3;
|
|
18
|
-
}
|
|
19
|
-
return new Date(n.getTime() + r).toISOString().slice(0, 16);
|
|
20
|
-
}
|
|
21
9
|
function p(e) {
|
|
22
|
-
if (!d.test(e)) return "";
|
|
23
|
-
let t = new Date(e);
|
|
24
|
-
if (isNaN(t.getTime())) return "";
|
|
25
|
-
let n = (e) => String(e).padStart(2, "0");
|
|
26
|
-
return `${t.getFullYear()}-${n(t.getMonth() + 1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`;
|
|
27
|
-
}
|
|
28
|
-
function m(e) {
|
|
29
10
|
let t = /^(\d{2}:\d{2})(?::(\d{2}))?/.exec(e);
|
|
30
11
|
return t ? t[2] && t[2] !== "00" ? `${t[1]}:${t[2]}` : t[1] : "";
|
|
31
12
|
}
|
|
32
|
-
function
|
|
33
|
-
let
|
|
13
|
+
function m({ field: u, fieldName: f, entityCode: m, value: g, onChange: _, fieldId: v, t: y }) {
|
|
14
|
+
let { data: b } = o(), x = {
|
|
15
|
+
zone: y.timeZone,
|
|
16
|
+
declared: !!(u.timezone || m && b?.entities[m]?.default_timezone)
|
|
17
|
+
}, S = a(g), C = u.special_values ?? [], w = g && S === null ? e(g) : "", T = C.length > 0 && /* @__PURE__ */ d("div", {
|
|
34
18
|
role: "group",
|
|
35
|
-
"aria-label":
|
|
19
|
+
"aria-label": f,
|
|
36
20
|
style: {
|
|
37
21
|
display: "flex",
|
|
38
22
|
flexWrap: "wrap",
|
|
39
|
-
gap: 6
|
|
40
|
-
marginBottom: 6
|
|
23
|
+
gap: 6
|
|
41
24
|
},
|
|
42
|
-
children:
|
|
25
|
+
children: C.map((e) => /* @__PURE__ */ d(s, {
|
|
43
26
|
size: "xs",
|
|
44
|
-
active:
|
|
45
|
-
"aria-pressed":
|
|
46
|
-
onClick: () => _?.(
|
|
27
|
+
active: S === e.code,
|
|
28
|
+
"aria-pressed": S === e.code,
|
|
29
|
+
onClick: () => _?.(S === e.code ? null : i(e.code)),
|
|
47
30
|
children: y(e.label) || e.code
|
|
48
31
|
}, e.code))
|
|
49
32
|
});
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
33
|
+
if (u.type === "time") return /* @__PURE__ */ d(h, {
|
|
34
|
+
buttons: T,
|
|
35
|
+
children: /* @__PURE__ */ d(l, {
|
|
36
|
+
id: v,
|
|
37
|
+
name: f,
|
|
38
|
+
"aria-required": u.required || void 0,
|
|
39
|
+
type: "time",
|
|
40
|
+
value: w ? p(w) : "",
|
|
41
|
+
onChange: (e) => _?.(e || null)
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
let E = u.type === "date" ? "date" : "datetime", D = w ? E === "date" ? t(w) ? w : "" : n(w, x) : null;
|
|
45
|
+
return /* @__PURE__ */ d(h, {
|
|
46
|
+
buttons: T,
|
|
47
|
+
children: /* @__PURE__ */ d(c, {
|
|
48
|
+
kind: E,
|
|
49
|
+
id: v,
|
|
50
|
+
name: f,
|
|
51
|
+
ariaRequired: u.required,
|
|
52
|
+
value: D,
|
|
53
|
+
onChange: (e, t) => {
|
|
54
|
+
e === null ? _?.(t.trim() === "" ? null : t) : _?.(E === "date" ? e : r(e, x));
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function h({ buttons: e, children: t }) {
|
|
60
|
+
return e ? /* @__PURE__ */ f("div", {
|
|
61
|
+
style: {
|
|
62
|
+
display: "flex",
|
|
63
|
+
alignItems: "center",
|
|
64
|
+
gap: 6
|
|
65
|
+
},
|
|
66
|
+
children: [/* @__PURE__ */ d("div", {
|
|
67
|
+
style: {
|
|
68
|
+
flex: 1,
|
|
69
|
+
minWidth: 0
|
|
70
|
+
},
|
|
71
|
+
children: t
|
|
72
|
+
}), e]
|
|
73
|
+
}) : /* @__PURE__ */ d(u, { children: t });
|
|
69
74
|
}
|
|
70
75
|
//#endregion
|
|
71
|
-
export {
|
|
76
|
+
export { m as TimestampField };
|
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import { coerceDisplayString as e } from "../../../../lib/display-value.js";
|
|
2
|
+
import { formatMoneyText as t } from "../../../../lib/money-text.js";
|
|
2
3
|
//#region src/components/fields/cells/factories/money.ts
|
|
3
|
-
var
|
|
4
|
-
let { field:
|
|
5
|
-
return (
|
|
6
|
-
if (
|
|
7
|
-
let i = typeof
|
|
8
|
-
if (!Number.isFinite(i)) return e(
|
|
9
|
-
let
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
currency:
|
|
13
|
-
currencyDisplay:
|
|
14
|
-
|
|
15
|
-
}), d.set(p, m)), m.format(i);
|
|
4
|
+
var n = (n) => {
|
|
5
|
+
let { field: i, t: a } = n, o = i.display?.currency || "USD", s = i.display?.currency_field, c = r(i.display?.currency_display);
|
|
6
|
+
return (n, r = {}) => {
|
|
7
|
+
if (n == null || n === "") return "—";
|
|
8
|
+
let i = typeof n == "number" ? n : Number(n);
|
|
9
|
+
if (!Number.isFinite(i)) return e(n);
|
|
10
|
+
let l = s ? r[s] : void 0, u = typeof l == "string" && l !== "" ? l : o;
|
|
11
|
+
return t(typeof n == "string" ? n : i, {
|
|
12
|
+
language: a.language,
|
|
13
|
+
currency: u,
|
|
14
|
+
currencyDisplay: c
|
|
15
|
+
});
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
function n(e, t) {
|
|
19
|
-
return new Intl.NumberFormat(e, {
|
|
20
|
-
style: "currency",
|
|
21
|
-
currency: t
|
|
22
|
-
}).resolvedOptions().maximumFractionDigits ?? 2;
|
|
23
|
-
}
|
|
24
18
|
function r(e) {
|
|
25
19
|
switch (e) {
|
|
26
20
|
case "narrow_symbol": return "narrowSymbol";
|
|
@@ -30,8 +24,5 @@ function r(e) {
|
|
|
30
24
|
default: return "code";
|
|
31
25
|
}
|
|
32
26
|
}
|
|
33
|
-
function i(e, t, n) {
|
|
34
|
-
return e < t ? t : e > n ? n : e;
|
|
35
|
-
}
|
|
36
27
|
//#endregion
|
|
37
|
-
export {
|
|
28
|
+
export { n as moneyFactory };
|
|
@@ -16,7 +16,7 @@ var u = ({ t: o }) => (s) => {
|
|
|
16
16
|
if (s == null || s === "") return "—";
|
|
17
17
|
let c = typeof s == "string" ? s : e(s), u = new Date(c);
|
|
18
18
|
if (isNaN(u.getTime())) return c;
|
|
19
|
-
let d = t(c), f = Date.now() - u.getTime();
|
|
19
|
+
let d = t(c, { zone: o.timeZone }), f = Date.now() - u.getTime();
|
|
20
20
|
if (f <= 0) {
|
|
21
21
|
let e = l(f, o.language);
|
|
22
22
|
return /* @__PURE__ */ r("span", {
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { coerceDisplayString as e } from "../../../../lib/display-value.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/fields/cells/factories/text.tsx
|
|
4
|
+
var n = {
|
|
5
|
+
whiteSpace: "pre-wrap",
|
|
6
|
+
overflowWrap: "anywhere",
|
|
7
|
+
margin: 0
|
|
8
|
+
}, r = (r) => {
|
|
9
|
+
let i = r.field?.type === "text" && r.surface !== "list";
|
|
10
|
+
return (r) => {
|
|
11
|
+
if (r == null || r === "") return "—";
|
|
12
|
+
let a = e(r);
|
|
13
|
+
return i && a.includes("\n") ? /* @__PURE__ */ t("p", {
|
|
14
|
+
style: n,
|
|
15
|
+
children: a
|
|
16
|
+
}) : a;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
4
19
|
//#endregion
|
|
5
|
-
export {
|
|
20
|
+
export { r as textFactory };
|
|
@@ -2,17 +2,29 @@ import { coerceDisplayString as e } from "../../../../lib/display-value.js";
|
|
|
2
2
|
import { formatOffsetTimestamp as t, formatRelativeOrAbsolute as n } from "../../../../lib/timestamp.js";
|
|
3
3
|
import { jsx as r } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/fields/cells/factories/timestamp.tsx
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
function i({ field: e, entity: t, t: n }) {
|
|
6
|
+
return {
|
|
7
|
+
zone: n.timeZone,
|
|
8
|
+
declared: !!(e.timezone || t?.default_timezone)
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
var a = (t) => {
|
|
12
|
+
let a = i(t);
|
|
13
|
+
return (i) => {
|
|
14
|
+
if (i == null || i === "") return "—";
|
|
15
|
+
let o = typeof i == "string" ? i : e(i), { text: s, absolute: c } = n(t.t.language, o, void 0, a);
|
|
16
|
+
return /* @__PURE__ */ r("span", {
|
|
17
|
+
title: c,
|
|
18
|
+
children: s
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
}, o = (n) => {
|
|
22
|
+
let r = i(n);
|
|
23
|
+
return (n) => {
|
|
24
|
+
if (n == null || n === "") return "—";
|
|
25
|
+
let i = typeof n == "string" ? n : e(n);
|
|
26
|
+
return t(i, r);
|
|
27
|
+
};
|
|
16
28
|
};
|
|
17
29
|
//#endregion
|
|
18
|
-
export {
|
|
30
|
+
export { a as timeAgoFactory, o as timestampFullFactory };
|
|
@@ -1,106 +1,108 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
1
|
+
import { formatCivilDateText as e } from "../../lib/date-text.js";
|
|
2
|
+
import { displayDay as t } from "../../lib/timestamp.js";
|
|
3
|
+
import { pluralText as n } from "../../lib/language.js";
|
|
4
|
+
import { useText as r } from "../../hooks/useText.js";
|
|
5
|
+
import { UploadError as i, discardFile as a, formatBytes as o, uploadCheckFailure as s, uploadFailure as ee, uploadFile as te, validateClientSide as ne } from "./upload.js";
|
|
6
|
+
import { UploadFailureText as c } from "./UploadFailureText.js";
|
|
7
|
+
import { canPreviewFile as l, downloadFileURL as u, previewFileURL as d } from "./helpers.js";
|
|
8
|
+
import { useDraftRegistration as f } from "./draft-scope.js";
|
|
9
|
+
import { useEmbedFileOpener as p } from "./useEmbedFileSrc.js";
|
|
10
|
+
import { singleFileFromValue as re } from "./value.js";
|
|
11
|
+
import { useCallback as m, useEffect as h, useRef as g, useState as _ } from "react";
|
|
12
|
+
import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
11
13
|
//#region src/components/file-widgets/DocumentCard.tsx
|
|
12
|
-
function
|
|
13
|
-
let
|
|
14
|
-
return /* @__PURE__ */
|
|
14
|
+
function x({ contentType: e }) {
|
|
15
|
+
let t = r(), 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__ */ y("div", {
|
|
15
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",
|
|
16
|
-
children:
|
|
18
|
+
children: n
|
|
17
19
|
});
|
|
18
20
|
}
|
|
19
|
-
function
|
|
20
|
-
let { field:
|
|
21
|
-
|
|
21
|
+
function S(e) {
|
|
22
|
+
let { field: t, fieldName: S, value: ae, onChange: C, mode: oe, disabled: w, uploadFieldCode: T, uploadSlotCode: E } = e, D = re(ae), [O, k] = _("idle"), [A, j] = _(null), [M, N] = _(null), [P, F] = _(!1), [I, L] = _(D?.filename ?? ""), R = g(null), z = g(!1), B = g(null), { register: V, unregister: H, isDraft: U } = f(), W = r(), G = r("errors"), { open: K } = p();
|
|
23
|
+
h(() => () => {
|
|
22
24
|
R.current && R.current.abort();
|
|
23
|
-
}, []),
|
|
25
|
+
}, []), h(() => {
|
|
24
26
|
L(D?.filename ?? "");
|
|
25
27
|
}, [D?.filename]);
|
|
26
|
-
let q = (
|
|
27
|
-
let
|
|
28
|
-
if (
|
|
29
|
-
N(
|
|
28
|
+
let q = (t.accepts ?? []).join(","), J = m(async (n) => {
|
|
29
|
+
let r = ne(n, t.accepts, t.max_size_bytes);
|
|
30
|
+
if (r) {
|
|
31
|
+
N(s(W, G, r)), k("error");
|
|
30
32
|
return;
|
|
31
33
|
}
|
|
32
34
|
N(null), z.current = !1, k("uploading"), j({
|
|
33
35
|
loaded: 0,
|
|
34
|
-
total:
|
|
36
|
+
total: n.size,
|
|
35
37
|
pct: 0
|
|
36
38
|
});
|
|
37
|
-
let
|
|
38
|
-
R.current =
|
|
39
|
+
let o = new AbortController();
|
|
40
|
+
R.current = o;
|
|
39
41
|
try {
|
|
40
|
-
let
|
|
41
|
-
file:
|
|
42
|
-
entityCode:
|
|
43
|
-
fieldCode: T ??
|
|
42
|
+
let r = await te({
|
|
43
|
+
file: n,
|
|
44
|
+
entityCode: e.entityCode,
|
|
45
|
+
fieldCode: T ?? S,
|
|
44
46
|
slotCode: E,
|
|
45
|
-
signal:
|
|
47
|
+
signal: o.signal,
|
|
46
48
|
onProgress: j
|
|
47
49
|
});
|
|
48
50
|
if (z.current) {
|
|
49
|
-
r
|
|
51
|
+
a(r.id).catch(() => {}), H(r.id);
|
|
50
52
|
return;
|
|
51
53
|
}
|
|
52
|
-
D && U(D.id) && (
|
|
53
|
-
let
|
|
54
|
-
id:
|
|
55
|
-
filename:
|
|
56
|
-
content_type:
|
|
57
|
-
size_bytes:
|
|
58
|
-
sha256:
|
|
59
|
-
width:
|
|
60
|
-
height:
|
|
61
|
-
url:
|
|
62
|
-
metadata:
|
|
54
|
+
D && U(D.id) && (a(D.id).catch(() => {}), H(D.id)), V(r.id, () => a(r.id)), k("idle"), j(null);
|
|
55
|
+
let i = {
|
|
56
|
+
id: r.id,
|
|
57
|
+
filename: r.filename,
|
|
58
|
+
content_type: r.content_type,
|
|
59
|
+
size_bytes: r.size_bytes,
|
|
60
|
+
sha256: r.sha256,
|
|
61
|
+
width: r.width,
|
|
62
|
+
height: r.height,
|
|
63
|
+
url: r.url,
|
|
64
|
+
metadata: r.metadata
|
|
63
65
|
};
|
|
64
|
-
|
|
66
|
+
C?.(t.mode === "array" ? [i] : i);
|
|
65
67
|
} catch (e) {
|
|
66
|
-
if (e instanceof
|
|
68
|
+
if (e instanceof i && e.code === "ABORTED") return;
|
|
67
69
|
N(ee(W, G, e)), k("error"), j(null);
|
|
68
70
|
}
|
|
69
71
|
}, [
|
|
70
72
|
G,
|
|
71
73
|
W,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
t.accepts,
|
|
75
|
+
t.max_size_bytes,
|
|
76
|
+
t.mode,
|
|
77
|
+
S,
|
|
76
78
|
D,
|
|
77
79
|
U,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
C,
|
|
81
|
+
e.entityCode,
|
|
80
82
|
V,
|
|
81
83
|
H,
|
|
82
84
|
T,
|
|
83
85
|
E
|
|
84
|
-
]), Y =
|
|
86
|
+
]), Y = m(() => {
|
|
85
87
|
w || B.current?.click();
|
|
86
|
-
}, [w]), X =
|
|
88
|
+
}, [w]), X = m((e) => {
|
|
87
89
|
let t = e.target.files?.[0];
|
|
88
90
|
e.target.value = "", t && J(t);
|
|
89
|
-
}, [J]), se =
|
|
90
|
-
D && U(D.id) && (
|
|
91
|
+
}, [J]), se = m(() => {
|
|
92
|
+
D && U(D.id) && (a(D.id).catch(() => {}), H(D.id)), C?.(t.mode === "array" ? [] : null);
|
|
91
93
|
}, [
|
|
92
94
|
D,
|
|
93
|
-
|
|
95
|
+
t.mode,
|
|
94
96
|
U,
|
|
95
|
-
|
|
97
|
+
C,
|
|
96
98
|
H
|
|
97
|
-
]), ce =
|
|
99
|
+
]), ce = m(() => {
|
|
98
100
|
O === "uploading" && R.current && (z.current = !0, R.current.abort(), R.current = null, k("idle"), j(null));
|
|
99
|
-
}, [O]), le =
|
|
100
|
-
D && K(D.id, "download",
|
|
101
|
-
}, [D, K]), Z = D ?
|
|
102
|
-
D &&
|
|
103
|
-
}, [D, K]), Q =
|
|
101
|
+
}, [O]), le = m(() => {
|
|
102
|
+
D && K(D.id, "download", u(D));
|
|
103
|
+
}, [D, K]), Z = D ? l(D) : !1, ue = m(() => {
|
|
104
|
+
D && l(D) && K(D.id, "preview", d(D));
|
|
105
|
+
}, [D, K]), Q = m(() => {
|
|
104
106
|
if (!D) {
|
|
105
107
|
F(!1);
|
|
106
108
|
return;
|
|
@@ -110,28 +112,28 @@ function v(v) {
|
|
|
110
112
|
L(D.filename);
|
|
111
113
|
return;
|
|
112
114
|
}
|
|
113
|
-
let
|
|
115
|
+
let n = {
|
|
114
116
|
...D,
|
|
115
117
|
filename: e
|
|
116
118
|
};
|
|
117
|
-
|
|
119
|
+
C?.(t.mode === "array" ? [n] : n);
|
|
118
120
|
}, [
|
|
119
121
|
I,
|
|
120
122
|
D,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
]), $ =
|
|
124
|
-
return !D && O !== "uploading" ? /* @__PURE__ */
|
|
125
|
-
"data-testid": `file-widget-${
|
|
123
|
+
C,
|
|
124
|
+
t.mode
|
|
125
|
+
]), $ = oe === "display";
|
|
126
|
+
return !D && O !== "uploading" ? /* @__PURE__ */ b("div", {
|
|
127
|
+
"data-testid": `file-widget-${S}`,
|
|
126
128
|
className: $ ? "flex items-center gap-3" : "flex items-center gap-3 rounded-md border border-dashed border-border bg-surface p-3",
|
|
127
129
|
children: [
|
|
128
|
-
/* @__PURE__ */
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ y(x, {}),
|
|
131
|
+
/* @__PURE__ */ b("div", {
|
|
130
132
|
className: "flex flex-col gap-1",
|
|
131
|
-
children: [/* @__PURE__ */
|
|
133
|
+
children: [/* @__PURE__ */ y("span", {
|
|
132
134
|
className: "text-sm text-foreground",
|
|
133
|
-
children: W(
|
|
134
|
-
}), !$ && /* @__PURE__ */
|
|
135
|
+
children: W(t.display?.placeholder) || W("file.document.empty", "No document attached")
|
|
136
|
+
}), !$ && /* @__PURE__ */ y("button", {
|
|
135
137
|
type: "button",
|
|
136
138
|
className: "self-start rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
|
|
137
139
|
onClick: Y,
|
|
@@ -140,31 +142,31 @@ function v(v) {
|
|
|
140
142
|
children: W("file.document.upload", "Upload")
|
|
141
143
|
})]
|
|
142
144
|
}),
|
|
143
|
-
!$ && /* @__PURE__ */
|
|
145
|
+
!$ && /* @__PURE__ */ y("input", {
|
|
144
146
|
ref: B,
|
|
145
147
|
type: "file",
|
|
146
148
|
accept: q || void 0,
|
|
147
149
|
onChange: X,
|
|
148
150
|
style: { display: "none" },
|
|
149
|
-
"data-testid": `file-input-${
|
|
151
|
+
"data-testid": `file-input-${S}`
|
|
150
152
|
}),
|
|
151
|
-
O === "error" && M && /* @__PURE__ */
|
|
153
|
+
O === "error" && M && /* @__PURE__ */ y("div", {
|
|
152
154
|
className: "ml-auto text-xs text-destructive",
|
|
153
155
|
role: "alert",
|
|
154
|
-
children: /* @__PURE__ */
|
|
156
|
+
children: /* @__PURE__ */ y(c, { failure: M })
|
|
155
157
|
})
|
|
156
158
|
]
|
|
157
|
-
}) : /* @__PURE__ */
|
|
158
|
-
"data-testid": `file-widget-${
|
|
159
|
+
}) : /* @__PURE__ */ b("div", {
|
|
160
|
+
"data-testid": `file-widget-${S}`,
|
|
159
161
|
className: "flex items-center gap-3 rounded-md border border-border bg-surface p-3",
|
|
160
162
|
"aria-busy": O === "uploading" || void 0,
|
|
161
163
|
"aria-invalid": O === "error" || void 0,
|
|
162
164
|
children: [
|
|
163
|
-
/* @__PURE__ */
|
|
164
|
-
/* @__PURE__ */
|
|
165
|
+
/* @__PURE__ */ y(x, { contentType: D?.content_type }),
|
|
166
|
+
/* @__PURE__ */ b("div", {
|
|
165
167
|
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
166
168
|
children: [
|
|
167
|
-
P && D ? /* @__PURE__ */
|
|
169
|
+
P && D ? /* @__PURE__ */ y("input", {
|
|
168
170
|
type: "text",
|
|
169
171
|
className: "rounded-sm border border-border bg-card px-1 py-0.5 text-sm text-foreground",
|
|
170
172
|
value: I,
|
|
@@ -175,7 +177,7 @@ function v(v) {
|
|
|
175
177
|
e.key === "Enter" ? Q() : e.key === "Escape" && (F(!1), L(D.filename));
|
|
176
178
|
},
|
|
177
179
|
"data-testid": "filename-input"
|
|
178
|
-
}) : /* @__PURE__ */
|
|
180
|
+
}) : /* @__PURE__ */ y("button", {
|
|
179
181
|
type: "button",
|
|
180
182
|
className: "truncate text-left text-sm font-medium text-foreground hover:underline",
|
|
181
183
|
onClick: () => !$ && D && F(!0),
|
|
@@ -184,23 +186,23 @@ function v(v) {
|
|
|
184
186
|
"data-testid": "filename",
|
|
185
187
|
children: D?.filename ?? W("file.document.uploading", "Uploading…")
|
|
186
188
|
}),
|
|
187
|
-
/* @__PURE__ */
|
|
189
|
+
/* @__PURE__ */ b("div", {
|
|
188
190
|
className: "flex flex-wrap gap-2 text-xs text-muted-foreground",
|
|
189
191
|
children: [
|
|
190
|
-
D && /* @__PURE__ */
|
|
191
|
-
D?.page_count != null && /* @__PURE__ */
|
|
192
|
+
D && /* @__PURE__ */ y("span", { children: o(D.size_bytes) }),
|
|
193
|
+
D?.page_count != null && /* @__PURE__ */ y("span", { children: n(W, "file.document.pages", D.page_count, {
|
|
192
194
|
one: "{count} page",
|
|
193
195
|
other: "{count} pages"
|
|
194
196
|
}) }),
|
|
195
|
-
D?.uploaded_at && /* @__PURE__ */
|
|
196
|
-
D?.uploaded_by && /* @__PURE__ */
|
|
197
|
-
D?.version?.number != null && /* @__PURE__ */
|
|
197
|
+
D?.uploaded_at && /* @__PURE__ */ y("span", { children: ie(D.uploaded_at, W.timeZone) }),
|
|
198
|
+
D?.uploaded_by && /* @__PURE__ */ y("span", { children: W("file.document.uploaded_by", "by {user}", { user: D.uploaded_by }) }),
|
|
199
|
+
D?.version?.number != null && /* @__PURE__ */ y("span", {
|
|
198
200
|
"data-testid": "version-badge",
|
|
199
201
|
children: W("file.document.version", "v{number}", { number: D.version.number })
|
|
200
202
|
})
|
|
201
203
|
]
|
|
202
204
|
}),
|
|
203
|
-
O === "uploading" && /* @__PURE__ */
|
|
205
|
+
O === "uploading" && /* @__PURE__ */ y("div", {
|
|
204
206
|
className: "text-xs text-muted-foreground",
|
|
205
207
|
role: "progressbar",
|
|
206
208
|
"aria-valuenow": A?.pct ?? 0,
|
|
@@ -209,24 +211,24 @@ function v(v) {
|
|
|
209
211
|
"data-testid": "upload-progress",
|
|
210
212
|
children: W("file.upload.progress", "Uploading {pct}%", { pct: A?.pct ?? 0 })
|
|
211
213
|
}),
|
|
212
|
-
O === "error" && M && /* @__PURE__ */
|
|
214
|
+
O === "error" && M && /* @__PURE__ */ y("div", {
|
|
213
215
|
className: "text-xs text-destructive",
|
|
214
216
|
role: "alert",
|
|
215
|
-
children: /* @__PURE__ */
|
|
217
|
+
children: /* @__PURE__ */ y(c, { failure: M })
|
|
216
218
|
})
|
|
217
219
|
]
|
|
218
220
|
}),
|
|
219
|
-
/* @__PURE__ */
|
|
221
|
+
/* @__PURE__ */ b("div", {
|
|
220
222
|
className: "flex flex-none items-center gap-1",
|
|
221
|
-
children: [D && O !== "uploading" && /* @__PURE__ */
|
|
222
|
-
/* @__PURE__ */
|
|
223
|
+
children: [D && O !== "uploading" && /* @__PURE__ */ b(v, { children: [
|
|
224
|
+
/* @__PURE__ */ y("button", {
|
|
223
225
|
type: "button",
|
|
224
226
|
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
|
|
225
227
|
onClick: le,
|
|
226
228
|
"data-testid": "download",
|
|
227
229
|
children: W("file.download", "Download")
|
|
228
230
|
}),
|
|
229
|
-
/* @__PURE__ */
|
|
231
|
+
/* @__PURE__ */ y("button", {
|
|
230
232
|
type: "button",
|
|
231
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",
|
|
232
234
|
onClick: ue,
|
|
@@ -235,14 +237,14 @@ function v(v) {
|
|
|
235
237
|
"data-testid": "preview",
|
|
236
238
|
children: W("file.document.preview", "Preview")
|
|
237
239
|
}),
|
|
238
|
-
!$ && /* @__PURE__ */
|
|
240
|
+
!$ && /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y("button", {
|
|
239
241
|
type: "button",
|
|
240
242
|
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-foreground hover:bg-surface-2",
|
|
241
243
|
onClick: Y,
|
|
242
244
|
disabled: w,
|
|
243
245
|
"data-testid": "replace",
|
|
244
246
|
children: W("file.document.replace", "Replace")
|
|
245
|
-
}), /* @__PURE__ */
|
|
247
|
+
}), /* @__PURE__ */ y("button", {
|
|
246
248
|
type: "button",
|
|
247
249
|
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs text-destructive hover:bg-surface-2",
|
|
248
250
|
onClick: se,
|
|
@@ -250,7 +252,7 @@ function v(v) {
|
|
|
250
252
|
"data-testid": "remove",
|
|
251
253
|
children: W("file.remove", "Remove")
|
|
252
254
|
})] })
|
|
253
|
-
] }), O === "uploading" && /* @__PURE__ */
|
|
255
|
+
] }), O === "uploading" && /* @__PURE__ */ y("button", {
|
|
254
256
|
type: "button",
|
|
255
257
|
className: "rounded-sm border border-border bg-card px-2 py-1 text-xs",
|
|
256
258
|
onClick: ce,
|
|
@@ -258,20 +260,20 @@ function v(v) {
|
|
|
258
260
|
children: W("file.upload.cancel", "Cancel")
|
|
259
261
|
})]
|
|
260
262
|
}),
|
|
261
|
-
!$ && /* @__PURE__ */
|
|
263
|
+
!$ && /* @__PURE__ */ y("input", {
|
|
262
264
|
ref: B,
|
|
263
265
|
type: "file",
|
|
264
266
|
accept: q || void 0,
|
|
265
267
|
onChange: X,
|
|
266
268
|
style: { display: "none" },
|
|
267
|
-
"data-testid": `file-input-${
|
|
269
|
+
"data-testid": `file-input-${S}`
|
|
268
270
|
})
|
|
269
271
|
]
|
|
270
272
|
});
|
|
271
273
|
}
|
|
272
|
-
function
|
|
273
|
-
let
|
|
274
|
-
return
|
|
274
|
+
function ie(n, r) {
|
|
275
|
+
let i = t(n, { zone: r });
|
|
276
|
+
return i ? e(i) ?? i : n;
|
|
275
277
|
}
|
|
276
278
|
//#endregion
|
|
277
|
-
export {
|
|
279
|
+
export { S as DocumentCard };
|