@declarion/react 0.86.0 → 0.88.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
@@ -4,71 +4,133 @@ import { formatISO as n } from "date-fns";
4
4
  function r(e = /* @__PURE__ */ new Date()) {
5
5
  return n(e);
6
6
  }
7
- function i(e, t, n) {
8
- let r = e.match(/([+-]\d{2}:\d{2})$/), i = e.endsWith("Z"), a = new Date(e);
9
- if (isNaN(a.getTime())) return e;
10
- if (r || i) {
7
+ function i(e, t, n, r = a()) {
8
+ let i = e.match(/([+-]\d{2}:\d{2})$/), o = e.endsWith("Z"), s = new Date(e);
9
+ if (isNaN(s.getTime())) return e;
10
+ if (i || o) {
11
11
  let e;
12
- if (i) e = "UTC";
13
- else if (r) {
14
- let t = r[1].charAt(0), n = parseInt(r[1].substring(1, 3), 10);
15
- parseInt(r[1].substring(4, 6), 10) === 0 && (e = n === 0 ? "UTC" : `Etc/GMT${t === "+" ? "-" : "+"}${n}`);
12
+ if (o) e = r;
13
+ else if (i) {
14
+ let t = i[1].charAt(0), n = parseInt(i[1].substring(1, 3), 10);
15
+ parseInt(i[1].substring(4, 6), 10) === 0 && (e = n === 0 ? "UTC" : `Etc/GMT${t === "+" ? "-" : "+"}${n}`);
16
16
  }
17
17
  if (e) try {
18
18
  return new Intl.DateTimeFormat(n, {
19
19
  ...t,
20
20
  timeZone: e
21
- }).format(a);
21
+ }).format(s);
22
22
  } catch {}
23
- if (r) {
24
- let e = r[1].charAt(0) === "+" ? 1 : -1, i = parseInt(r[1].substring(1, 3), 10), o = parseInt(r[1].substring(4, 6), 10), s = e * (i * 60 + o) * 60 * 1e3;
23
+ if (i) {
24
+ let e = i[1].charAt(0) === "+" ? 1 : -1, r = parseInt(i[1].substring(1, 3), 10), a = parseInt(i[1].substring(4, 6), 10), o = e * (r * 60 + a) * 60 * 1e3;
25
25
  return new Intl.DateTimeFormat(n, {
26
26
  ...t,
27
27
  timeZone: "UTC"
28
- }).format(new Date(a.getTime() + s));
28
+ }).format(new Date(s.getTime() + o));
29
29
  }
30
30
  }
31
- return new Intl.DateTimeFormat(n, t).format(a);
31
+ return new Intl.DateTimeFormat(n, t).format(s);
32
32
  }
33
- function a(e) {
34
- return i(e, {
33
+ function a() {
34
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
35
+ }
36
+ function o(e) {
37
+ return e && s(e) ? e : a();
38
+ }
39
+ function s(e) {
40
+ try {
41
+ return new Intl.DateTimeFormat("en-US", { timeZone: e }), !0;
42
+ } catch {
43
+ return !1;
44
+ }
45
+ }
46
+ function c(e) {
47
+ return e.declared ? "UTC" : o(e.zone);
48
+ }
49
+ function l(e, t = {}) {
50
+ let n = c(t), r = i(e, {
35
51
  day: "2-digit",
36
52
  month: "2-digit",
37
53
  year: "numeric",
38
54
  hour: "2-digit",
39
55
  minute: "2-digit",
40
56
  hour12: !1
41
- }, "en-GB").replace(/\//g, "-").replace(",", "");
57
+ }, "en-GB", n).replace(/\//g, "-").replace(",", ""), a = d(e, n);
58
+ return a && r !== e ? `${r} ${a}` : r;
59
+ }
60
+ function u(t, n = {}) {
61
+ if (e.test(t)) return t;
62
+ let r = l(t, n), i = /^(\d{2})-(\d{2})-(\d{4}) /.exec(r);
63
+ return i ? `${i[3]}-${i[2]}-${i[1]}` : null;
64
+ }
65
+ function d(e, t = a()) {
66
+ let n = e.match(/([+-])(\d{2}):(\d{2})$/);
67
+ if (n) return f(n[1], Number(n[2]), Number(n[3]));
68
+ let r = new Date(e);
69
+ if (isNaN(r.getTime()) || e.endsWith("Z") && !s(t)) return "";
70
+ let i = new Intl.DateTimeFormat("en-US", e.endsWith("Z") ? {
71
+ timeZone: t,
72
+ timeZoneName: "longOffset"
73
+ } : { timeZoneName: "longOffset" }).formatToParts(r).find((e) => e.type === "timeZoneName")?.value.match(/^GMT(?:([+-])(\d{2}):(\d{2}))?$/);
74
+ return i ? i[1] ? f(i[1], Number(i[2]), Number(i[3])) : "UTC" : "";
75
+ }
76
+ function f(e, t, n) {
77
+ return t === 0 && n === 0 ? "UTC" : `UTC${e}${t}${n ? `:${String(n).padStart(2, "0")}` : ""}`;
78
+ }
79
+ var p = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/, m = 6e4, h = 864e5;
80
+ function g(e, t) {
81
+ let n = new Intl.DateTimeFormat("en-US", {
82
+ timeZone: t,
83
+ timeZoneName: "longOffset"
84
+ }).formatToParts(new Date(e)).find((e) => e.type === "timeZoneName")?.value ?? "GMT", r = /^GMT([+-])(\d{2}):(\d{2})$/.exec(n);
85
+ return r ? (r[1] === "+" ? 1 : -1) * (Number(r[2]) * 60 + Number(r[3])) : 0;
86
+ }
87
+ function _(e) {
88
+ let t = e < 0 ? "-" : "+", n = Math.abs(e);
89
+ return `${t}${String(Math.floor(n / 60)).padStart(2, "0")}:${String(n % 60).padStart(2, "0")}`;
90
+ }
91
+ function v(e, t = {}) {
92
+ if (!p.test(e)) return "";
93
+ let n = new Date(e);
94
+ if (isNaN(n.getTime())) return "";
95
+ let r = e.match(/([+-])(\d{2}):(\d{2})$/);
96
+ if (!r && !e.endsWith("Z")) return e.slice(0, 16).replace(" ", "T");
97
+ let i = r ? (r[1] === "+" ? 1 : -1) * (Number(r[2]) * 60 + Number(r[3])) : g(n.getTime(), c(t));
98
+ return new Date(n.getTime() + i * m).toISOString().slice(0, 16);
99
+ }
100
+ function y(e, t = {}) {
101
+ if (t.declared) return e;
102
+ let n = c(t), r = e.slice(0, 16), [i, a] = r.split("T"), [o, s, l] = i.split("-").map(Number), [u, d] = a.split(":").map(Number), f = Date.UTC(o, s - 1, l, u, d), p = g(f - h, n), v = [p, g(f + h, n)].filter((e) => g(f - e * m, n) === e);
103
+ return `${r}:00${_(v.length ? v.reduce((e, t) => f - e * m <= f - t * m ? e : t) : p)}`;
42
104
  }
43
- function o(t) {
105
+ function b(t) {
44
106
  let n = e.exec(t);
45
107
  if (!n) return null;
46
108
  let [, r, i, a] = n;
47
109
  return new Date(Number(r), Number(i) - 1, Number(a));
48
110
  }
49
- function s(e, r, i = /* @__PURE__ */ new Date()) {
50
- if (r == null || r === "") return {
111
+ function x(e, n, r = /* @__PURE__ */ new Date(), i = {}) {
112
+ if (n == null || n === "") return {
51
113
  text: "—",
52
114
  absolute: ""
53
115
  };
54
- let s = typeof r == "string" ? o(r) : null, c = r instanceof Date ? r : s ?? new Date(String(r));
55
- if (isNaN(c.getTime())) {
56
- let e = String(r);
116
+ let a = typeof n == "string" ? b(n) : null, o = n instanceof Date ? n : a ?? new Date(String(n));
117
+ if (isNaN(o.getTime())) {
118
+ let e = String(n);
57
119
  return {
58
120
  text: e,
59
121
  absolute: e
60
122
  };
61
123
  }
62
- let l = t(n(c, { representation: "date" })) ?? "", d = s ? l : a(typeof r == "string" ? r : c.toISOString()), f = i.getTime() - c.getTime();
124
+ let s = typeof n == "string" ? n : o.toISOString(), c = t(a ? s : u(s, i) ?? "") ?? "", d = a ? c : l(s, i), f = r.getTime() - o.getTime();
63
125
  return Math.abs(f) > 2592e6 ? {
64
- text: l,
126
+ text: c,
65
127
  absolute: d
66
128
  } : {
67
- text: u(e, c, i),
129
+ text: w(e, o, r),
68
130
  absolute: d
69
131
  };
70
132
  }
71
- var c = [
133
+ var S = [
72
134
  {
73
135
  unit: "second",
74
136
  ms: 1e3,
@@ -84,14 +146,14 @@ var c = [
84
146
  ms: 36e5,
85
147
  limit: 24
86
148
  }
87
- ], l = 864e5;
88
- function u(e, t, n) {
149
+ ], C = 864e5;
150
+ function w(e, t, n) {
89
151
  let r = t.getTime() - n.getTime(), i = new Intl.RelativeTimeFormat(e, { numeric: "always" }), a = (e) => r > 0 ? e : -e;
90
- for (let { unit: e, ms: t, limit: n } of c) {
152
+ for (let { unit: e, ms: t, limit: n } of S) {
91
153
  let o = Math.round(Math.abs(r) / t);
92
154
  if (o < n) return i.format(a(o), e);
93
155
  }
94
- return i.format(a(Math.round(Math.abs(r) / l)), "day");
156
+ return i.format(a(Math.round(Math.abs(r) / C)), "day");
95
157
  }
96
158
  //#endregion
97
- export { o as civilDateAsLocal, i as formatInOffsetZone, a as formatOffsetTimestamp, s as formatRelativeOrAbsolute, r as formatWireDateTime };
159
+ export { a as browserTimeZone, b as civilDateAsLocal, u as displayDay, v as editorWallClock, y as editorWireValue, i as formatInOffsetZone, l as formatOffsetTimestamp, x as formatRelativeOrAbsolute, r as formatWireDateTime, o as resolveTimeZone, d as zoneMark };
@@ -2,9 +2,10 @@ import { startOrderNow as e } from "../api/access-expiry.js";
2
2
  import { cancelProactiveRefresh as t, ensureRefresh as n, publishLanguage as r, scheduleProactiveRefresh as i } from "../api/client.js";
3
3
  import { getMe as a, listTenants as o, logout as s, probeSession as c } from "../api/auth.js";
4
4
  import { warmRoutePages as l } from "../lib/capabilityPrefetch.js";
5
- import { create as u } from "zustand";
5
+ import { usePreferencesStore as u } from "./preferences.js";
6
+ import { create as d } from "zustand";
6
7
  //#region src/stores/auth.ts
7
- async function d(e, t, n) {
8
+ async function f(e, t, n) {
8
9
  try {
9
10
  let r = await n();
10
11
  i(r.access_expires_at), e({
@@ -24,7 +25,7 @@ async function d(e, t, n) {
24
25
  });
25
26
  }
26
27
  }
27
- var f = u((r, i) => ({
28
+ var p = d((r, i) => ({
28
29
  user: null,
29
30
  isAuthenticated: !1,
30
31
  isLoading: !0,
@@ -34,9 +35,9 @@ var f = u((r, i) => ({
34
35
  identitySince: 0,
35
36
  initialize: async () => {
36
37
  let t = e();
37
- t === "refresh-first" && (t = await n().then(() => "first-wave", () => "probe-first")), r({ sessionPresumed: t === "first-wave" }), t === "first-wave" && l(), await d(r, i, c), t === "probe-first" && i().isAuthenticated && l();
38
+ t === "refresh-first" && (t = await n().then(() => "first-wave", () => "probe-first")), r({ sessionPresumed: t === "first-wave" }), t === "first-wave" && l(), await f(r, i, c), t === "probe-first" && i().isAuthenticated && l();
38
39
  },
39
- reloadSession: () => d(r, i, a),
40
+ reloadSession: () => f(r, i, a),
40
41
  refreshMe: async () => {
41
42
  try {
42
43
  let e = await a(), t = i(), n = t.user?.id !== e.id || t.activeTenant?.id !== e.tenant?.id;
@@ -77,8 +78,8 @@ var f = u((r, i) => ({
77
78
  });
78
79
  }
79
80
  }));
80
- f.subscribe((e, t) => {
81
- e.isAuthenticated !== t.isAuthenticated && r(null);
81
+ p.subscribe((e, t) => {
82
+ e.isAuthenticated !== t.isAuthenticated && r(null), e.user?.id !== t.user?.id && u.getState().startIdentity();
82
83
  });
83
84
  //#endregion
84
- export { f as useAuthStore };
85
+ export { p as useAuthStore };
@@ -80,17 +80,38 @@ function m(e) {
80
80
  toastPosition: e.toast_position
81
81
  };
82
82
  }
83
+ function h(e) {
84
+ return {
85
+ color_scheme: e.colorScheme,
86
+ accent: e.accent,
87
+ density: e.density,
88
+ sidebar: e.sidebar,
89
+ tabs_position: e.tabsPosition,
90
+ tabs_max_open: e.tabsMaxOpen,
91
+ tabs_persist: e.tabsPersist,
92
+ radius: e.radius,
93
+ zebra_rows: e.zebra,
94
+ ai_surface: e.aiSurface,
95
+ toast_position: e.toastPosition
96
+ };
97
+ }
98
+ var g = "ui_preferences";
83
99
  f();
84
- var h = /* @__PURE__ */ new Set(), g = { ...t };
85
- typeof window < "u" && p(g);
86
- var _ = e((e, n) => ({
87
- ...g,
100
+ var _ = /* @__PURE__ */ new Set(), v = { ...t }, y = !1, b = null, x = { ...t };
101
+ typeof window < "u" && p(v);
102
+ function S() {
103
+ let e = C.getState(), n = {};
104
+ for (let r of Object.keys(t)) n[r] = e[r];
105
+ return n;
106
+ }
107
+ var C = e((e, n) => ({
108
+ ...v,
88
109
  set: (t, r) => {
89
110
  let i = u({ [t]: r });
90
111
  i[t] !== void 0 && (p({
91
112
  ...n(),
92
113
  ...i
93
- }), h.add(t), e(i));
114
+ }), _.add(t), e(i));
94
115
  },
95
116
  setMany: (t) => {
96
117
  let r = u(t);
@@ -99,28 +120,46 @@ var _ = e((e, n) => ({
99
120
  ...n(),
100
121
  ...r
101
122
  });
102
- for (let e of Object.keys(r)) h.add(e);
123
+ for (let e of Object.keys(r)) _.add(e);
103
124
  e(r);
104
125
  }
105
126
  },
106
- hydrateFromBranding: (t) => {
107
- if (!t) return;
108
- let n = m(t), r = {};
109
- for (let [e, t] of Object.entries(n)) h.has(e) || t !== void 0 && (r[e] = t);
110
- let i = u(r);
111
- Object.keys(i).length && (p({
112
- ..._.getState(),
127
+ hydrateFromParameter: (n, r) => {
128
+ if (!n && !y) return;
129
+ let i = n ? u(m(n)) : {};
130
+ x = {
131
+ ...y ? t : x,
132
+ ...i
133
+ }, r && (b = r);
134
+ let a = y ? {
135
+ ...t,
113
136
  ...i
114
- }), e(i));
137
+ } : i;
138
+ y = !1;
139
+ for (let e of _) delete a[e];
140
+ Object.keys(a).length && (p({
141
+ ...S(),
142
+ ...a
143
+ }), e(a));
115
144
  },
116
145
  resetToDefaults: (n) => {
117
- h.clear(), f();
146
+ _.clear(), f();
118
147
  let r = n ? u(m(n)) : {}, i = {
119
148
  ...t,
120
149
  ...r
121
150
  };
122
- p(i), e(i);
151
+ x = i, p(i), e(i);
152
+ },
153
+ startIdentity: () => {
154
+ _.clear(), y = !0, b = null, x = { ...t };
155
+ },
156
+ holdsRowOf: (e) => e !== "" && b === e,
157
+ markSaved: (e) => {
158
+ x = { ...e };
159
+ },
160
+ revertToSaved: () => {
161
+ _.clear(), p(x), e({ ...x });
123
162
  }
124
163
  }));
125
164
  //#endregion
126
- export { p as applyPreferences, _ as usePreferencesStore };
165
+ export { g as UI_PREFERENCES_PARAM_CODE, p as applyPreferences, S as currentPreferences, h as toParameter, C as usePreferencesStore };
@@ -1,4 +1,4 @@
1
- import { B as Refs, M as ListMeta, P as ListResponse, d as ActionExecuteResponse, jt as TextFn, k as DataResponse, o as ResponsiveViewport, pt as Schema, st as LocalizedString, u as ActionExecuteRequest } from "./useResponsiveMode-D3SKz5z4.js";
1
+ import { B as Refs, M as ListMeta, P as ListResponse, d as ActionExecuteResponse, jt as TextFn, k as DataResponse, o as ResponsiveViewport, pt as Schema, st as LocalizedString, u as ActionExecuteRequest } from "./useResponsiveMode-9_eJT18k.js";
2
2
  import { ReactElement, ReactNode } from "react";
3
3
  import { QueryClient } from "@tanstack/react-query";
4
4
  import { RenderResult } from "@testing-library/react";
@@ -1,8 +1,8 @@
1
1
  import { EmbedProvider as e } from "./embed/EmbedContext.js";
2
2
  import { useAuthStore as t } from "./stores/auth.js";
3
3
  import { makeTextFn as n } from "./lib/language.js";
4
- import { ResponsiveModeProvider as r } from "./hooks/useResponsiveMode.js";
5
- import { encodeObjectId as i, setActionExecutor as a, setGetEntityResolver as o, setListEntitiesResolver as s } from "./api/data.js";
4
+ import { encodeObjectId as r, setActionExecutor as i, setGetEntityResolver as a, setListEntitiesResolver as o } from "./api/data.js";
5
+ import { ResponsiveModeProvider as s } from "./hooks/useResponsiveMode.js";
6
6
  import { ActionRunnerProvider as c } from "./components/actions/ActionRunner.js";
7
7
  import { CurrentScreenProvider as l } from "./hooks/useCurrentScreen.js";
8
8
  import { seedSchemaCache as u } from "./test/seed-schema.js";
@@ -85,19 +85,16 @@ function k() {
85
85
  let e = {
86
86
  id: "test-tenant",
87
87
  code: "test",
88
- name: "Test",
89
- role: "admin"
88
+ name: "Test"
90
89
  }, n = {
91
90
  id: "test-user",
92
91
  email: "test@example.com",
93
92
  display_name: "Test User",
94
93
  is_active: !0,
95
94
  roles: ["admin"],
96
- role_names: { admin: "administrator" },
95
+ role_names: { admin: { en: "administrator" } },
97
96
  permissions: ["*"],
98
- tenant: e,
99
- created_at: "2026-01-01T00:00:00Z",
100
- updated_at: "2026-01-01T00:00:00Z"
97
+ tenant: e
101
98
  };
102
99
  t.getState().setUser(n, e);
103
100
  }
@@ -116,7 +113,7 @@ function A(e) {
116
113
  }
117
114
  function j(e) {
118
115
  let t = e.entityData ?? {};
119
- s((n, r) => {
116
+ o((n, r) => {
120
117
  let i = r;
121
118
  e.onListRequest?.(n, i);
122
119
  let a = t[n], o = typeof a == "function" ? a(i) : a;
@@ -141,24 +138,24 @@ function j(e) {
141
138
  ...s.refs === void 0 ? {} : { $refs: s.refs }
142
139
  };
143
140
  });
144
- let n = e.entityItems ?? {}, r = e.entityItemResponses ?? {};
145
- o((e, t) => {
146
- let a = typeof t == "string" ? t : i(t), o = r[e]?.[a];
141
+ let n = e.entityItems ?? {}, s = e.entityItemResponses ?? {};
142
+ a((e, t) => {
143
+ let i = typeof t == "string" ? t : r(t), a = s[e]?.[i];
144
+ if (a instanceof Error) throw a;
145
+ if (a !== void 0) return a;
146
+ let o = n[e]?.[i];
147
147
  if (o instanceof Error) throw o;
148
- if (o !== void 0) return o;
149
- let s = n[e]?.[a];
150
- if (s instanceof Error) throw s;
151
- return { data: s };
148
+ return { data: o };
152
149
  });
153
150
  let c = e.actionResults ?? {};
154
- a(async (e, t) => {
151
+ i(async (e, t) => {
155
152
  if (!(e in c)) throw Error(`renderWithDeclarion: no action result registered for "${e}" (seed it via actionResults)`);
156
153
  let n = c[e];
157
154
  return D(typeof n == "function" ? await n(t) : n);
158
155
  });
159
156
  }
160
157
  function M() {
161
- s(null), o(null), a(null), t.setState({
158
+ o(null), a(null), i(null), t.setState({
162
159
  user: null,
163
160
  isAuthenticated: !1,
164
161
  activeTenant: null,
@@ -166,30 +163,30 @@ function M() {
166
163
  });
167
164
  }
168
165
  function N(t, n = {}) {
169
- let i = new f({ defaultOptions: { queries: {
166
+ let r = new f({ defaultOptions: { queries: {
170
167
  retry: !1,
171
168
  gcTime: Infinity
172
169
  } } });
173
- k(), u(i, n.schema ?? S()), j(n);
174
- let a = n.screenCode ? /* @__PURE__ */ m(l, {
170
+ k(), u(r, n.schema ?? S()), j(n);
171
+ let i = n.screenCode ? /* @__PURE__ */ m(l, {
175
172
  code: n.screenCode,
176
173
  children: t
177
- }) : t, o = { current: n.route ?? "/" }, s = /* @__PURE__ */ h(p, {
178
- client: i,
174
+ }) : t, a = { current: n.route ?? "/" }, o = /* @__PURE__ */ h(p, {
175
+ client: r,
179
176
  children: [/* @__PURE__ */ h(g, {
180
177
  initialEntries: [n.route ?? "/"],
181
- children: [/* @__PURE__ */ m(O, { into: o }), /* @__PURE__ */ m(c, { children: a })]
178
+ children: [/* @__PURE__ */ m(O, { into: a }), /* @__PURE__ */ m(c, { children: i })]
182
179
  }), /* @__PURE__ */ m(v, {})]
183
180
  }), d = n.embedQuery ? /* @__PURE__ */ m(e, {
184
181
  query: n.embedQuery,
185
- children: s
186
- }) : s, _ = y(n.viewport ? /* @__PURE__ */ m(r, {
182
+ children: o
183
+ }) : o, _ = y(n.viewport ? /* @__PURE__ */ m(s, {
187
184
  viewportOverride: n.viewport,
188
185
  children: d
189
186
  }) : d);
190
187
  return Object.assign(_, {
191
- queryClient: i,
192
- location: () => o.current
188
+ queryClient: r,
189
+ location: () => a.current
193
190
  });
194
191
  }
195
192
  function P({ children: e, authenticated: n = !0, ...r }) {
@@ -12,7 +12,10 @@ function a(e, r, a) {
12
12
  let c = r[s];
13
13
  if (c == null) return;
14
14
  let l = a?.fields?.get(s);
15
- if (l?.type === "timestamp" && typeof c == "string" && c !== "") return n(c);
15
+ if (l?.type === "timestamp" && typeof c == "string" && c !== "") return n(c, {
16
+ zone: e.timeZone,
17
+ declared: !!(l.timezone || a?.default_timezone)
18
+ });
16
19
  let u = l?.values;
17
20
  if (u && (typeof c == "string" || typeof c == "number")) {
18
21
  let t = u.find((e) => e.code === String(c));
@@ -111,43 +114,46 @@ function h(e) {
111
114
  structure: e.structure
112
115
  };
113
116
  }
114
- function g(e, t) {
117
+ function g(e) {
118
+ return !e.primary && !e.auto && !e.readonly && !e.source;
119
+ }
120
+ function _(e, t) {
115
121
  return !e || e.readonly ? !1 : e.mutations?.[t] ?? !0;
116
122
  }
117
- function _(e, t, n) {
123
+ function v(e, t, n) {
118
124
  let r = e?.tenant_key;
119
125
  return !r || !t || !(r in t) || !!n && String(t[r]).toLowerCase() === n.toLowerCase();
120
126
  }
121
- function v(e, t, n, r) {
122
- return g(e, t) && (t === "create" || _(e, n, r));
127
+ function y(e, t, n, r) {
128
+ return _(e, t) && (t === "create" || v(e, n, r));
123
129
  }
124
- function y(e) {
130
+ function b(e) {
125
131
  return !e?.disable_defaults?.includes("__new");
126
132
  }
127
- function b(e) {
133
+ function x(e) {
128
134
  if (e.primary_key && e.primary_key.length > 0) return e.primary_key;
129
135
  for (let [t, n] of e.fields) if (n.primary) return [t];
130
136
  return ["id"];
131
137
  }
132
- function x(e, n) {
133
- let r = b(e), i = {};
138
+ function S(e, n) {
139
+ let r = x(e), i = {};
134
140
  for (let e of r) i[e] = t(n[e]);
135
141
  return i;
136
142
  }
137
- function S(e) {
138
- return e.length === 1 ? e[0] : JSON.stringify(e);
139
- }
140
143
  function C(e) {
141
- return S(Object.values(e));
144
+ return e.length === 1 ? e[0] : JSON.stringify(e);
142
145
  }
143
- function w(e, t) {
144
- return S(b(e).map((e) => t[e] ?? ""));
146
+ function w(e) {
147
+ return C(Object.values(e));
145
148
  }
146
149
  function T(e, t) {
147
- let n = b(e);
148
- if (n.length === 1) return { [n[0]]: t };
150
+ return C(x(e).map((e) => t[e] ?? ""));
149
151
  }
150
152
  function E(e, t) {
153
+ let n = x(e);
154
+ if (n.length === 1) return { [n[0]]: t };
155
+ }
156
+ function D(e, t) {
151
157
  if (t <= 1) return [e];
152
158
  try {
153
159
  let n = JSON.parse(e);
@@ -157,24 +163,24 @@ function E(e, t) {
157
163
  }
158
164
  return null;
159
165
  }
160
- function D(e, t, n) {
166
+ function O(e, t, n) {
161
167
  if (e?.detail_screen === "none") return null;
162
168
  let r = e?.detail_screen ?? t?.detail_screen;
163
169
  return r ? n?.[r]?.route ?? null : null;
164
170
  }
165
- function O(e, t, n, r) {
171
+ function k(e, t, n, r) {
166
172
  if (!t) return null;
167
- let i = D(e, n, r);
173
+ let i = O(e, n, r);
168
174
  return i ? i.replace(":id", encodeURIComponent(t)) : null;
169
175
  }
170
- function k(e, t, n, r) {
171
- return !t || b(t).some((e) => !r[e]) ? null : O(e, w(t, r), t, n);
172
- }
173
176
  function A(e, t, n, r) {
174
- return t ? k(e, t, n, x(t, r)) : null;
177
+ return !t || x(t).some((e) => !r[e]) ? null : k(e, T(t, r), t, n);
178
+ }
179
+ function j(e, t, n, r) {
180
+ return t ? A(e, t, n, S(t, r)) : null;
175
181
  }
176
- function j(e) {
177
- return b(e).length > 1;
182
+ function M(e) {
183
+ return x(e).length > 1;
178
184
  }
179
185
  //#endregion
180
- export { r as DETAIL_SCREEN_NONE, i as DISPLAY_KEY, e as OrderedMap, O as buildDetailHrefFromId, k as buildEntityDetailHref, A as buildRowDetailHref, m as effectiveSpecialValues, y as entityAllowsCreateRoute, g as entityAllowsMutation, x as extractPkValues, u as fieldDisplayName, a as getDisplayValue, b as getPrimaryKeyFields, j as isCompositePk, d as normalizeRefConfig, S as pkValuePartsToId, E as pkValuesFromId, w as pkValuesToDetailId, C as pkValuesToId, h as propertyToField, D as resolveDetailRoute, o as resolveRefRecordLabel, v as rowAllowsMutation, _ as rowSetInTenant, l as screenTitleForPath, T as singlePkValues, f as specialValueMarker, p as specialValueMarkerCode };
186
+ export { r as DETAIL_SCREEN_NONE, i as DISPLAY_KEY, e as OrderedMap, k as buildDetailHrefFromId, A as buildEntityDetailHref, j as buildRowDetailHref, m as effectiveSpecialValues, b as entityAllowsCreateRoute, _ as entityAllowsMutation, S as extractPkValues, u as fieldDisplayName, a as getDisplayValue, x as getPrimaryKeyFields, M as isCompositePk, g as isUserEditableField, d as normalizeRefConfig, C as pkValuePartsToId, D as pkValuesFromId, T as pkValuesToDetailId, w as pkValuesToId, h as propertyToField, O as resolveDetailRoute, o as resolveRefRecordLabel, y as rowAllowsMutation, v as rowSetInTenant, l as screenTitleForPath, E as singlePkValues, f as specialValueMarker, p as specialValueMarkerCode };
@@ -194,8 +194,9 @@ interface TextFn {
194
194
  (value: LocalizedString | null | undefined): string;
195
195
  readonly language: string;
196
196
  readonly deploymentLanguage: string;
197
+ readonly timeZone: string;
197
198
  }
198
- declare function makeTextFn(messages: Record<string, LocalizedString> | undefined, language: string, deploymentLanguage: string): TextFn;
199
+ declare function makeTextFn(messages: Record<string, LocalizedString> | undefined, language: string, deploymentLanguage: string, timeZone?: string): TextFn;
199
200
  declare function pluralText(t: TextFn, code: string, count: number, english: {
200
201
  one: string;
201
202
  other: string;
@@ -1366,7 +1367,6 @@ interface Tenant {
1366
1367
  id: string;
1367
1368
  code: string;
1368
1369
  name: string;
1369
- role: string;
1370
1370
  env?: TenantEnv;
1371
1371
  /**
1372
1372
  * Whether the caller has a `tenant_users` row for this tenant. Always
@@ -1381,15 +1381,15 @@ interface AuthUser {
1381
1381
  email: string;
1382
1382
  display_name: string;
1383
1383
  is_active: boolean;
1384
+ timezone?: string;
1384
1385
  roles: string[];
1385
- role_names?: Record<string, string>;
1386
+ role_names?: Record<string, LocalizedString>;
1386
1387
  permissions?: string[];
1388
+ is_tenant_owner?: boolean;
1387
1389
  tenant?: Tenant;
1388
1390
  /** Populated only when the request is acting under an impersonation session. */
1389
1391
  impersonation?: ImpersonationInfo;
1390
1392
  access_expires_at?: string;
1391
- created_at: string;
1392
- updated_at: string;
1393
1393
  }
1394
1394
  /**
1395
1395
  * ImpersonationInfo is the read-side projection of the active session
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@declarion/react",
3
- "version": "0.86.0",
3
+ "version": "0.88.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "React SDK for Declarion, the schema-driven business apps platform.",