@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.
Files changed (90) hide show
  1. package/dist-lib/app.js +28 -28
  2. package/dist-lib/components/actions/ActionButton.js +86 -85
  3. package/dist-lib/components/actions/ActionResultDialog.impl.js +47 -47
  4. package/dist-lib/components/actions/ActionRunner.js +47 -47
  5. package/dist-lib/components/actions/ObjectActionBar.js +9 -9
  6. package/dist-lib/components/actions/RowActionsKebab.js +19 -19
  7. package/dist-lib/components/agents/AgentChatPanel.impl.js +53 -53
  8. package/dist-lib/components/chrome/AssociationTabs.js +21 -21
  9. package/dist-lib/components/chrome/RecordHeader.js +33 -40
  10. package/dist-lib/components/detail-layout/AssociatedBlock.js +387 -381
  11. package/dist-lib/components/detail-layout/ChildrenBlock.js +12 -13
  12. package/dist-lib/components/detail-layout/ChildrenTimeline.js +198 -198
  13. package/dist-lib/components/detail-layout/DraggableChildrenTable.js +114 -114
  14. package/dist-lib/components/detail-layout/EditableChildrenTable.js +160 -160
  15. package/dist-lib/components/detail-layout/EvidenceBlock.js +20 -21
  16. package/dist-lib/components/detail-layout/PropertiesBlock.js +45 -39
  17. package/dist-lib/components/detail-layout/QuickAddForm.js +9 -9
  18. package/dist-lib/components/detail-layout/TimelineComposer.js +87 -89
  19. package/dist-lib/components/detail-layout/widgets/EntityScorecardWidget.js +100 -99
  20. package/dist-lib/components/fields/FileReferenceField.js +9 -9
  21. package/dist-lib/components/fields/StructureField.js +57 -47
  22. package/dist-lib/components/fields/TimestampField.js +59 -54
  23. package/dist-lib/components/fields/cells/factories/money.js +14 -23
  24. package/dist-lib/components/fields/cells/factories/nextRun.js +1 -1
  25. package/dist-lib/components/fields/cells/factories/text.js +18 -3
  26. package/dist-lib/components/fields/cells/factories/timestamp.js +24 -12
  27. package/dist-lib/components/file-widgets/DocumentCard.js +108 -106
  28. package/dist-lib/components/layout/Layout.js +306 -361
  29. package/dist-lib/components/layout/Rail.js +42 -41
  30. package/dist-lib/components/layout/Sidebar.js +132 -117
  31. package/dist-lib/components/layout/TabStrip.js +116 -115
  32. package/dist-lib/components/layout/TenantChip.js +47 -54
  33. package/dist-lib/components/layout/TopBar.js +108 -105
  34. package/dist-lib/components/list/InlineEditCell.js +23 -23
  35. package/dist-lib/components/list/QuickPeek.js +65 -66
  36. package/dist-lib/components/pages/DocumentsMenu.js +42 -42
  37. package/dist-lib/components/pages/ExportMenu.js +25 -25
  38. package/dist-lib/components/pages/RecordDocumentsPanel.js +35 -35
  39. package/dist-lib/components/pages/RecordNotesPanel.js +94 -93
  40. package/dist-lib/components/pages/SmartDetailPage.impl.js +421 -417
  41. package/dist-lib/components/pages/SmartListPage.impl.js +293 -295
  42. package/dist-lib/components/pages/SmartRecordListPage.impl.js +310 -310
  43. package/dist-lib/components/pages/auth/AuthShell.js +73 -73
  44. package/dist-lib/components/pages/auth/SignIn.js +32 -32
  45. package/dist-lib/components/pages/auth/SignUp.impl.js +3 -3
  46. package/dist-lib/components/pages/auth/SignUpCode.js +9 -9
  47. package/dist-lib/components/pages/list/ListFloatbar.js +12 -12
  48. package/dist-lib/components/pages/list/ListHeader.js +19 -19
  49. package/dist-lib/components/pages/list/ListNoRows.js +15 -15
  50. package/dist-lib/components/pages/list/ListToolbar.js +145 -145
  51. package/dist-lib/components/pages/list/useActiveView.js +14 -5
  52. package/dist-lib/components/pages/list/useListQuery.js +121 -81
  53. package/dist-lib/components/pages/list/useListRowInteraction.js +70 -70
  54. package/dist-lib/components/pages/list/useRowMenu.js +7 -7
  55. package/dist-lib/components/pages/profile/Preferences.impl.js +81 -78
  56. package/dist-lib/components/pages/profile/Profile.impl.js +191 -189
  57. package/dist-lib/components/pages/tenant-params/TenantParamsPage.impl.js +166 -158
  58. package/dist-lib/components/shared/ChangePasswordDialog.impl.js +23 -23
  59. package/dist-lib/components/shared/MarkdownRenderer.js +9 -9
  60. package/dist-lib/hooks/useAuth.js +11 -11
  61. package/dist-lib/hooks/useBranding.js +4 -4
  62. package/dist-lib/hooks/useDisplayTimeZone.js +8 -0
  63. package/dist-lib/hooks/useFollowAgentOpen.js +24 -24
  64. package/dist-lib/hooks/useImpersonation.js +6 -6
  65. package/dist-lib/hooks/useMutations.js +23 -23
  66. package/dist-lib/hooks/useObjectStatus.js +5 -5
  67. package/dist-lib/hooks/useParams.js +59 -51
  68. package/dist-lib/hooks/useProperties.js +8 -8
  69. package/dist-lib/hooks/useRowTenant.js +18 -6
  70. package/dist-lib/hooks/useText.js +9 -7
  71. package/dist-lib/hooks/useUiPreferences.js +71 -0
  72. package/dist-lib/index.d.ts +22 -6
  73. package/dist-lib/index.js +127 -126
  74. package/dist-lib/lib/actions.js +116 -84
  75. package/dist-lib/lib/child-config.js +10 -1
  76. package/dist-lib/lib/format-count.js +16 -1
  77. package/dist-lib/lib/language.js +23 -21
  78. package/dist-lib/lib/money-text.js +29 -0
  79. package/dist-lib/lib/profile.js +4 -0
  80. package/dist-lib/lib/role-label.js +8 -0
  81. package/dist-lib/lib/schema-routing.js +34 -14
  82. package/dist-lib/lib/shortcut.js +10 -0
  83. package/dist-lib/lib/timestamp.js +93 -31
  84. package/dist-lib/stores/auth.js +9 -8
  85. package/dist-lib/stores/preferences.js +56 -17
  86. package/dist-lib/testing.d.ts +1 -1
  87. package/dist-lib/testing.js +25 -28
  88. package/dist-lib/types/schema.js +33 -27
  89. package/dist-lib/{useResponsiveMode-D3SKz5z4.d.ts → useResponsiveMode-9_eJT18k.d.ts} +5 -5
  90. 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, formatWireDateTime as n } from "../../lib/timestamp.js";
3
- import { specialValueMarker as r, specialValueMarkerCode as i } from "../../types/schema.js";
4
- import { Btn as a } from "../primitives/Btn.js";
5
- import { DateInput as o, TextInput as s } from "../primitives/Fields.js";
6
- import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
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 h({ field: d, fieldName: h, value: g, onChange: _, fieldId: v, t: y }) {
33
- let b = !!d.timezone, x = i(g), S = d.special_values ?? [], C = g && x === null ? e(g) : "", w = S.length > 0 && /* @__PURE__ */ l("div", {
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": h,
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: S.map((e) => /* @__PURE__ */ l(a, {
25
+ children: C.map((e) => /* @__PURE__ */ d(s, {
43
26
  size: "xs",
44
- active: x === e.code,
45
- "aria-pressed": x === e.code,
46
- onClick: () => _?.(x === e.code ? null : r(e.code)),
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 (d.type === "time") return /* @__PURE__ */ u(c, { children: [w, /* @__PURE__ */ l(s, {
51
- id: v,
52
- name: h,
53
- "aria-required": d.required || void 0,
54
- type: "time",
55
- value: C ? m(C) : "",
56
- onChange: (e) => _?.(e || null)
57
- })] });
58
- let T = d.type === "date" ? "date" : "datetime", E = C ? T === "date" ? t(C) ? C : "" : b ? f(C) : p(C) : null;
59
- return /* @__PURE__ */ u(c, { children: [w, /* @__PURE__ */ l(o, {
60
- kind: T,
61
- id: v,
62
- name: h,
63
- ariaRequired: d.required,
64
- value: E,
65
- onChange: (e, t) => {
66
- e === null ? _?.(t.trim() === "" ? null : t) : _?.(T === "date" || b ? e : n(new Date(e)));
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 { h as TimestampField };
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 t = (t) => {
4
- let { field: a, t: o } = t, s = a.display?.currency || "USD", c = a.display?.currency_field, l = r(a.display?.currency_display), u = i(typeof a.scale == "number" ? a.scale : 2, 0, 6), d = /* @__PURE__ */ new Map();
5
- return (t, r = {}) => {
6
- if (t == null || t === "") return "—";
7
- let i = typeof t == "number" ? t : Number(t);
8
- if (!Number.isFinite(i)) return e(t);
9
- let a = c ? r[c] : void 0, f = typeof a == "string" && a !== "" ? a : s, p = `${o.language}:${f}:${l}:${u}`, m = d.get(p);
10
- return m || (m = new Intl.NumberFormat(o.language, {
11
- style: "currency",
12
- currency: f,
13
- currencyDisplay: l,
14
- maximumFractionDigits: Math.max(u, n(o.language, f))
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 { t as moneyFactory };
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
- //#region src/components/fields/cells/factories/text.ts
3
- var t = () => (t) => t == null || t === "" ? "—" : e(t);
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 { t as textFactory };
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
- var i = ({ t }) => (i) => {
6
- if (i == null || i === "") return "—";
7
- let a = typeof i == "string" ? i : e(i), { text: o, absolute: s } = n(t.language, a);
8
- return /* @__PURE__ */ r("span", {
9
- title: s,
10
- children: o
11
- });
12
- }, a = () => (n) => {
13
- if (n == null || n === "") return "—";
14
- let r = typeof n == "string" ? n : e(n);
15
- return t(r);
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 { i as timeAgoFactory, a as timestampFullFactory };
30
+ export { a as timeAgoFactory, o as timestampFullFactory };
@@ -1,106 +1,108 @@
1
- import { pluralText as e } from "../../lib/language.js";
2
- import { useText as t } from "../../hooks/useText.js";
3
- import { UploadError as n, discardFile as r, formatBytes as i, uploadCheckFailure as a, uploadFailure as ee, uploadFile as te, validateClientSide as ne } from "./upload.js";
4
- import { UploadFailureText as o } from "./UploadFailureText.js";
5
- import { canPreviewFile as s, downloadFileURL as re, previewFileURL as c } from "./helpers.js";
6
- import { useDraftRegistration as ie } from "./draft-scope.js";
7
- import { useEmbedFileOpener as ae } from "./useEmbedFileSrc.js";
8
- import { singleFileFromValue as l } from "./value.js";
9
- import { useCallback as u, useEffect as d, useRef as f, useState as p } from "react";
10
- import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
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 _({ contentType: e }) {
13
- let n = t(), r = 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() ?? n("file.document.type_other", "FILE") : n("file.document.type_other", "FILE");
14
- return /* @__PURE__ */ h("div", {
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: r
18
+ children: n
17
19
  });
18
20
  }
19
- function v(v) {
20
- let { field: y, fieldName: b, value: x, onChange: S, mode: C, disabled: w, uploadFieldCode: T, uploadSlotCode: E } = v, D = l(x), [O, k] = p("idle"), [A, j] = p(null), [M, N] = p(null), [P, F] = p(!1), [I, L] = p(D?.filename ?? ""), R = f(null), z = f(!1), B = f(null), { register: V, unregister: H, isDraft: U } = ie(), W = t(), G = t("errors"), { open: K } = ae();
21
- d(() => () => {
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
- }, []), d(() => {
25
+ }, []), h(() => {
24
26
  L(D?.filename ?? "");
25
27
  }, [D?.filename]);
26
- let q = (y.accepts ?? []).join(","), J = u(async (e) => {
27
- let t = ne(e, y.accepts, y.max_size_bytes);
28
- if (t) {
29
- N(a(W, G, t)), k("error");
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: e.size,
36
+ total: n.size,
35
37
  pct: 0
36
38
  });
37
- let i = new AbortController();
38
- R.current = i;
39
+ let o = new AbortController();
40
+ R.current = o;
39
41
  try {
40
- let t = await te({
41
- file: e,
42
- entityCode: v.entityCode,
43
- fieldCode: T ?? b,
42
+ let r = await te({
43
+ file: n,
44
+ entityCode: e.entityCode,
45
+ fieldCode: T ?? S,
44
46
  slotCode: E,
45
- signal: i.signal,
47
+ signal: o.signal,
46
48
  onProgress: j
47
49
  });
48
50
  if (z.current) {
49
- r(t.id).catch(() => {}), H(t.id);
51
+ a(r.id).catch(() => {}), H(r.id);
50
52
  return;
51
53
  }
52
- D && U(D.id) && (r(D.id).catch(() => {}), H(D.id)), V(t.id, () => r(t.id)), k("idle"), j(null);
53
- let n = {
54
- id: t.id,
55
- filename: t.filename,
56
- content_type: t.content_type,
57
- size_bytes: t.size_bytes,
58
- sha256: t.sha256,
59
- width: t.width,
60
- height: t.height,
61
- url: t.url,
62
- metadata: t.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
- S?.(y.mode === "array" ? [n] : n);
66
+ C?.(t.mode === "array" ? [i] : i);
65
67
  } catch (e) {
66
- if (e instanceof n && e.code === "ABORTED") return;
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
- y.accepts,
73
- y.max_size_bytes,
74
- y.mode,
75
- b,
74
+ t.accepts,
75
+ t.max_size_bytes,
76
+ t.mode,
77
+ S,
76
78
  D,
77
79
  U,
78
- S,
79
- v.entityCode,
80
+ C,
81
+ e.entityCode,
80
82
  V,
81
83
  H,
82
84
  T,
83
85
  E
84
- ]), Y = u(() => {
86
+ ]), Y = m(() => {
85
87
  w || B.current?.click();
86
- }, [w]), X = u((e) => {
88
+ }, [w]), X = m((e) => {
87
89
  let t = e.target.files?.[0];
88
90
  e.target.value = "", t && J(t);
89
- }, [J]), se = u(() => {
90
- D && U(D.id) && (r(D.id).catch(() => {}), H(D.id)), S?.(y.mode === "array" ? [] : null);
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
- y.mode,
95
+ t.mode,
94
96
  U,
95
- S,
97
+ C,
96
98
  H
97
- ]), ce = u(() => {
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 = u(() => {
100
- D && K(D.id, "download", re(D));
101
- }, [D, K]), Z = D ? s(D) : !1, ue = u(() => {
102
- D && s(D) && K(D.id, "preview", c(D));
103
- }, [D, K]), Q = u(() => {
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 t = {
115
+ let n = {
114
116
  ...D,
115
117
  filename: e
116
118
  };
117
- S?.(y.mode === "array" ? [t] : t);
119
+ C?.(t.mode === "array" ? [n] : n);
118
120
  }, [
119
121
  I,
120
122
  D,
121
- S,
122
- y.mode
123
- ]), $ = C === "display";
124
- return !D && O !== "uploading" ? /* @__PURE__ */ g("div", {
125
- "data-testid": `file-widget-${b}`,
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__ */ h(_, {}),
129
- /* @__PURE__ */ g("div", {
130
+ /* @__PURE__ */ y(x, {}),
131
+ /* @__PURE__ */ b("div", {
130
132
  className: "flex flex-col gap-1",
131
- children: [/* @__PURE__ */ h("span", {
133
+ children: [/* @__PURE__ */ y("span", {
132
134
  className: "text-sm text-foreground",
133
- children: W(y.display?.placeholder) || W("file.document.empty", "No document attached")
134
- }), !$ && /* @__PURE__ */ h("button", {
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__ */ h("input", {
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-${b}`
151
+ "data-testid": `file-input-${S}`
150
152
  }),
151
- O === "error" && M && /* @__PURE__ */ h("div", {
153
+ O === "error" && M && /* @__PURE__ */ y("div", {
152
154
  className: "ml-auto text-xs text-destructive",
153
155
  role: "alert",
154
- children: /* @__PURE__ */ h(o, { failure: M })
156
+ children: /* @__PURE__ */ y(c, { failure: M })
155
157
  })
156
158
  ]
157
- }) : /* @__PURE__ */ g("div", {
158
- "data-testid": `file-widget-${b}`,
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__ */ h(_, { contentType: D?.content_type }),
164
- /* @__PURE__ */ g("div", {
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__ */ h("input", {
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__ */ h("button", {
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__ */ g("div", {
189
+ /* @__PURE__ */ b("div", {
188
190
  className: "flex flex-wrap gap-2 text-xs text-muted-foreground",
189
191
  children: [
190
- D && /* @__PURE__ */ h("span", { children: i(D.size_bytes) }),
191
- D?.page_count != null && /* @__PURE__ */ h("span", { children: e(W, "file.document.pages", D.page_count, {
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__ */ h("span", { children: oe(D.uploaded_at) }),
196
- D?.uploaded_by && /* @__PURE__ */ h("span", { children: W("file.document.uploaded_by", "by {user}", { user: D.uploaded_by }) }),
197
- D?.version?.number != null && /* @__PURE__ */ h("span", {
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__ */ h("div", {
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__ */ h("div", {
214
+ O === "error" && M && /* @__PURE__ */ y("div", {
213
215
  className: "text-xs text-destructive",
214
216
  role: "alert",
215
- children: /* @__PURE__ */ h(o, { failure: M })
217
+ children: /* @__PURE__ */ y(c, { failure: M })
216
218
  })
217
219
  ]
218
220
  }),
219
- /* @__PURE__ */ g("div", {
221
+ /* @__PURE__ */ b("div", {
220
222
  className: "flex flex-none items-center gap-1",
221
- children: [D && O !== "uploading" && /* @__PURE__ */ g(m, { children: [
222
- /* @__PURE__ */ h("button", {
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__ */ h("button", {
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__ */ g(m, { children: [/* @__PURE__ */ h("button", {
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__ */ h("button", {
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__ */ h("button", {
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__ */ h("input", {
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-${b}`
269
+ "data-testid": `file-input-${S}`
268
270
  })
269
271
  ]
270
272
  });
271
273
  }
272
- function oe(e) {
273
- let t = new Date(e);
274
- return isNaN(t.getTime()) ? e : t.toISOString().slice(0, 10);
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 { v as DocumentCard };
279
+ export { S as DocumentCard };