@declarion/react 0.36.3 → 0.36.5

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.
@@ -33,6 +33,14 @@ export interface RenderWithDeclarionOptions {
33
33
  actionResults?: Record<string, ActionResult>;
34
34
  /** Initial path for the memory router (e.g. "/replay/abc/compare"). Default "/". */
35
35
  route?: string;
36
+ /**
37
+ * The screen code the rendered component is standing in for, as the router would
38
+ * mount it. Custom screens read their own declaration through `useCurrentScreen()` -
39
+ * `<PageHeader />` takes its title and description from it - so a harness that does
40
+ * not supply it renders a screen with no name, which is not what production does.
41
+ * Pass the same code the schema declares.
42
+ */
43
+ screenCode?: string;
36
44
  /** Optional responsive viewport seam for component tests that assert phone/tablet behavior. */
37
45
  viewport?: ResponsiveViewport;
38
46
  }
@@ -1,12 +1,12 @@
1
- import { Fn as e, dt as t, ft as n, ht as r, rt as i, t as a, ut as o } from "./ActionRunner-BrXXs8ga.js";
2
- import { useState as s } from "react";
3
- import { MemoryRouter as c } from "react-router-dom";
4
- import { QueryClient as l, QueryClientProvider as u } from "@tanstack/react-query";
5
- import { Toaster as d } from "sonner";
6
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
7
- import { render as m } from "@testing-library/react";
1
+ import { Ln as e, _t as t, at as n, ft as r, mt as i, pt as a, r as o, t as s } from "./useCurrentScreen-Bgp6_vne.js";
2
+ import { useState as c } from "react";
3
+ import { MemoryRouter as l } from "react-router-dom";
4
+ import { QueryClient as u, QueryClientProvider as d } from "@tanstack/react-query";
5
+ import { Toaster as f } from "sonner";
6
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
7
+ import { render as h } from "@testing-library/react";
8
8
  //#region src/testing.tsx
9
- function h(e = {}) {
9
+ function g(e = {}) {
10
10
  return {
11
11
  languages: [],
12
12
  structures: {},
@@ -19,7 +19,7 @@ function h(e = {}) {
19
19
  ...e
20
20
  };
21
21
  }
22
- function g(e, t = {}, n) {
22
+ function _(e, t = {}, n) {
23
23
  return {
24
24
  data: e,
25
25
  meta: {
@@ -33,33 +33,33 @@ function g(e, t = {}, n) {
33
33
  ...n === void 0 ? {} : { $refs: n }
34
34
  };
35
35
  }
36
- function _(e) {
36
+ function v(e) {
37
37
  return e;
38
38
  }
39
- var v = Symbol("declarion.testing.actionEnvelope");
40
- function y(e) {
39
+ var y = Symbol("declarion.testing.actionEnvelope");
40
+ function b(e) {
41
41
  return {
42
42
  ...e,
43
- [v]: !0
43
+ [y]: !0
44
44
  };
45
45
  }
46
- function b(e) {
47
- if (e && typeof e == "object" && e[v]) {
46
+ function x(e) {
47
+ if (e && typeof e == "object" && e[y]) {
48
48
  let t = { ...e };
49
- return delete t[v], t;
49
+ return delete t[y], t;
50
50
  }
51
51
  return {
52
52
  status: "success",
53
53
  result: e
54
54
  };
55
55
  }
56
- function x() {
56
+ function S() {
57
57
  let e = {
58
58
  id: "test-tenant",
59
59
  code: "test",
60
60
  name: "Test",
61
61
  role: "admin"
62
- }, t = {
62
+ }, n = {
63
63
  id: "test-user",
64
64
  email: "test@example.com",
65
65
  display_name: "Test User",
@@ -70,9 +70,9 @@ function x() {
70
70
  created_at: "2026-01-01T00:00:00Z",
71
71
  updated_at: "2026-01-01T00:00:00Z"
72
72
  };
73
- r.getState().setUser(t, e);
73
+ t.getState().setUser(n, e);
74
74
  }
75
- function S(e) {
75
+ function C(e) {
76
76
  if (e === void 0) return { rows: [] };
77
77
  if (Array.isArray(e)) return { rows: e };
78
78
  if (Array.isArray(e.data)) {
@@ -85,11 +85,11 @@ function S(e) {
85
85
  }
86
86
  return e;
87
87
  }
88
- function C(e) {
89
- let r = e.entityData ?? {};
90
- n((e, t) => {
91
- let n = r[e], i = S(n), a = i.meta?.per_page ?? 50, o = i.meta?.total ?? i.rows.length;
92
- return t.count === "only" ? {
88
+ function w(e) {
89
+ let t = e.entityData ?? {};
90
+ i((e, n) => {
91
+ let r = t[e], i = C(r), a = i.meta?.per_page ?? 50, o = i.meta?.total ?? i.rows.length;
92
+ return n.count === "only" ? {
93
93
  data: [],
94
94
  meta: {
95
95
  page: 1,
@@ -108,69 +108,72 @@ function C(e) {
108
108
  ...i.refs === void 0 ? {} : { $refs: i.refs }
109
109
  };
110
110
  });
111
- let a = e.entityItems ?? {}, s = e.entityItemResponses ?? {};
112
- t((e, t) => {
113
- let n = typeof t == "string" ? t : i(t), r = s[e]?.[n];
114
- if (r instanceof Error) throw r;
115
- if (r !== void 0) return r;
116
- let o = a[e]?.[n];
117
- if (o instanceof Error) throw o;
118
- return { data: o };
111
+ let o = e.entityItems ?? {}, s = e.entityItemResponses ?? {};
112
+ a((e, t) => {
113
+ let r = typeof t == "string" ? t : n(t), i = s[e]?.[r];
114
+ if (i instanceof Error) throw i;
115
+ if (i !== void 0) return i;
116
+ let a = o[e]?.[r];
117
+ if (a instanceof Error) throw a;
118
+ return { data: a };
119
119
  });
120
120
  let c = e.actionResults ?? {};
121
- o(async (e, t) => {
121
+ r(async (e, t) => {
122
122
  if (!(e in c)) throw Error(`renderWithDeclarion: no action result registered for "${e}" (seed it via actionResults)`);
123
123
  let n = c[e];
124
- return b(typeof n == "function" ? await n(t) : n);
124
+ return x(typeof n == "function" ? await n(t) : n);
125
125
  });
126
126
  }
127
- function w() {
128
- n(null), t(null), o(null), r.setState({
127
+ function T() {
128
+ i(null), a(null), r(null), t.setState({
129
129
  user: null,
130
130
  isAuthenticated: !1,
131
131
  activeTenant: null,
132
132
  tenants: []
133
133
  });
134
134
  }
135
- function T(t, n = {}) {
136
- let r = new l({ defaultOptions: { queries: {
135
+ function E(t, n = {}) {
136
+ let r = new u({ defaultOptions: { queries: {
137
137
  retry: !1,
138
138
  gcTime: Infinity
139
139
  } } });
140
- x(), r.setQueryData(["schema", !0], n.schema ?? h()), C(n);
141
- let i = /* @__PURE__ */ p(u, {
140
+ S(), r.setQueryData(["schema", !0], n.schema ?? g()), w(n);
141
+ let i = n.screenCode ? /* @__PURE__ */ p(s, {
142
+ code: n.screenCode,
143
+ children: t
144
+ }) : t, a = /* @__PURE__ */ m(d, {
142
145
  client: r,
143
- children: [/* @__PURE__ */ f(c, {
146
+ children: [/* @__PURE__ */ p(l, {
144
147
  initialEntries: [n.route ?? "/"],
145
- children: /* @__PURE__ */ f(a, { children: t })
146
- }), /* @__PURE__ */ f(d, {})]
147
- }), o = m(n.viewport ? /* @__PURE__ */ f(e, {
148
+ children: /* @__PURE__ */ p(o, { children: i })
149
+ }), /* @__PURE__ */ p(f, {})]
150
+ }), c = h(n.viewport ? /* @__PURE__ */ p(e, {
148
151
  viewportOverride: n.viewport,
149
- children: i
150
- }) : i);
151
- return Object.assign(o, { queryClient: r });
152
+ children: a
153
+ }) : a);
154
+ return Object.assign(c, { queryClient: r });
152
155
  }
153
- function E({ children: e, authenticated: t = !0, ...n }) {
154
- let [i] = s(() => {
155
- let e = new l({ defaultOptions: { queries: {
156
+ function D({ children: e, authenticated: n = !0, ...r }) {
157
+ let [i] = c(() => {
158
+ let e = new u({ defaultOptions: { queries: {
156
159
  retry: !1,
157
160
  gcTime: Infinity
158
161
  } } });
159
- return t ? (x(), e.setQueryData(["schema", !0], n.schema ?? h())) : r.setState({
162
+ return n ? (S(), e.setQueryData(["schema", !0], r.schema ?? g())) : t.setState({
160
163
  user: null,
161
164
  isAuthenticated: !1,
162
165
  activeTenant: null,
163
166
  tenants: []
164
- }), C(n), e;
167
+ }), w(r), e;
165
168
  });
166
- return /* @__PURE__ */ p(u, {
169
+ return /* @__PURE__ */ m(d, {
167
170
  client: i,
168
- children: [/* @__PURE__ */ f(c, {
169
- initialEntries: [n.route ?? "/"],
170
- children: /* @__PURE__ */ f(a, { children: e })
171
- }), /* @__PURE__ */ f(d, {})]
171
+ children: [/* @__PURE__ */ p(l, {
172
+ initialEntries: [r.route ?? "/"],
173
+ children: /* @__PURE__ */ p(o, { children: e })
174
+ }), /* @__PURE__ */ p(f, {})]
172
175
  });
173
176
  }
174
- typeof afterEach == "function" && afterEach(() => w());
177
+ typeof afterEach == "function" && afterEach(() => T());
175
178
  //#endregion
176
- export { E as PreviewHarness, y as actionEnvelope, _ as actionResults, w as cleanupDeclarion, g as entityDataFixture, T as renderWithDeclarion, h as schemaFixture };
179
+ export { D as PreviewHarness, b as actionEnvelope, v as actionResults, T as cleanupDeclarion, _ as entityDataFixture, E as renderWithDeclarion, g as schemaFixture };
@@ -2755,7 +2755,7 @@ var Z = {
2755
2755
  update: Ur,
2756
2756
  dismiss: (e) => g.dismiss(e),
2757
2757
  dismissAll: () => g.dismiss()
2758
- }, Wr = a(() => import("./MarkdownRenderer-CvURrJCu.js").then((e) => ({ default: e.MarkdownRenderer })));
2758
+ }, Wr = a(() => import("./MarkdownRenderer-14LG1clY.js").then((e) => ({ default: e.MarkdownRenderer })));
2759
2759
  function Gr() {
2760
2760
  return /* @__PURE__ */ v("div", { className: "h-4 w-2/3 rounded bg-muted animate-pulse" });
2761
2761
  }
@@ -6606,4 +6606,20 @@ function cc({ state: t, onClose: n, onExecute: r }) {
6606
6606
  })] });
6607
6607
  }
6608
6608
  //#endregion
6609
- export { Zn as $, tt as $t, Oi as A, Fe as An, J as At, Kr as B, k as Bn, bt as Bt, va as C, je as Cn, Mn as Ct, $i as D, Me as Dn, Nn as Dt, ia as E, F as En, In as Et, li as F, ge as Fn, It as Ft, kr as G, _t as Gt, Ar as H, D as Hn, Tt as Ht, ti as I, de as In, Lt as It, Sr as J, B as Jt, Dr as K, pt as Kt, Qr as L, _e as Ln, Dt as Lt, Di as M, ye as Mn, hn as Mt, Ei as N, ve as Nn, mn as Nt, ji as O, Ce as On, G as Ot, di as P, ce as Pn, Nt as Pt, fr as Q, Re as Qt, Zr as R, N as Rn, Et as Rt, ca as S, Ne as Sn, Fn as St, aa as T, Pe as Tn, An as Tt, Mr as U, E as Un, ht as Ut, Z as V, O as Vn, xt as Vt, jr as W, T as Wn, gt as Wt, br as X, at as Xt, Cr as Y, ot as Yt, xr as Z, st as Zt, wa as _, Qe as _n, On as _t, Ns as a, Ue as an, Xn as at, _a as b, De as bn, Ln as bt, ks as c, L as cn, sr as ct, Ds as d, Ze as dn, ar as dt, nt as en, $n as et, ms as f, Xe as fn, ir as ft, Sa as g, He as gn, Bn as gt, ss as h, R as hn, Vn as ht, Js as i, Je as in, or as it, Ti as j, be as jn, pn as jt, ki as k, P as kn, q as kt, Os as l, Ye as ln, Yn as lt, ls as m, et as mn, Y as mt, rc as n, Ge as nn, qn as nt, Ps as o, ze as on, Wn as ot, fs as p, Ke as pn, Kn as pt, wr as q, ft as qt, Ys as r, qe as rn, Jn as rt, zs as s, z as sn, Un as st, ac as t, rt as tn, Gn as tt, Ss as u, $e as un, tr as ut, Ca as v, I as vn, jn as vt, ea as w, Ie as wn, kn as wt, ba as x, xe as xn, Rn as xt, Q as y, Le as yn, zn as yt, Yr as z, ae as zn, St as zt };
6609
+ //#region src/hooks/useCurrentScreen.tsx
6610
+ var lc = r(void 0);
6611
+ function uc({ code: e, children: t }) {
6612
+ let { data: n } = Y(), r = u(() => ({
6613
+ code: e,
6614
+ screen: n?.screens[e]
6615
+ }), [e, n]);
6616
+ return /* @__PURE__ */ v(lc.Provider, {
6617
+ value: r,
6618
+ children: t
6619
+ });
6620
+ }
6621
+ function dc() {
6622
+ return s(lc);
6623
+ }
6624
+ //#endregion
6625
+ export { xr as $, st as $t, ji as A, Ce as An, G as At, Zr as B, N as Bn, Et as Bt, ba as C, xe as Cn, Rn as Ct, aa as D, Pe as Dn, An as Dt, ea as E, Ie as En, kn as Et, Ei as F, ve as Fn, mn as Ft, Mr as G, E as Gn, ht as Gt, Kr as H, k as Hn, bt as Ht, di as I, ce as In, Nt as It, Dr as J, pt as Jt, jr as K, T as Kn, gt as Kt, li as L, ge as Ln, It as Lt, Oi as M, Fe as Mn, J as Mt, Ti as N, be as Nn, pn as Nt, ia as O, F as On, In as Ot, Di as P, ye as Pn, hn as Pt, br as Q, at as Qt, ti as R, de as Rn, Lt as Rt, _a as S, De as Sn, Ln as St, va as T, je as Tn, Mn as Tt, Z as U, O as Un, xt as Ut, Yr as V, ae as Vn, St as Vt, Ar as W, D as Wn, Tt as Wt, Sr as X, B as Xt, wr as Y, ft as Yt, Cr as Z, ot as Zt, ss as _, R as _n, Vn as _t, Ys as a, qe as an, Jn as at, Ca as b, I as bn, jn as bt, Ps as c, ze as cn, Wn as ct, Os as d, Ye as dn, Yn as dt, Re as en, fr as et, Ss as f, $e as fn, tr as ft, ls as g, et as gn, Y as gt, fs as h, Ke as hn, Kn as ht, rc as i, Ge as in, qn as it, ki as j, P as jn, q as jt, $i as k, Me as kn, Nn as kt, zs as l, z as ln, Un as lt, ms as m, Xe as mn, ir as mt, dc as n, nt as nn, $n as nt, Js as o, Je as on, or as ot, Ds as p, Ze as pn, ar as pt, kr as q, _t as qt, ac as r, rt as rn, Gn as rt, Ns as s, Ue as sn, Xn as st, uc as t, tt as tn, Zn as tt, ks as u, L as un, sr as ut, Sa as v, He as vn, Bn as vt, ca as w, Ne as wn, Fn as wt, Q as x, Le as xn, zn as xt, wa as y, Qe as yn, On as yt, Qr as z, _e as zn, Dt as zt };
@@ -1,5 +1,5 @@
1
- import { At as e, V as t, Z as n, Zt as r, cn as i, it as a, kt as o, vn as s } from "./ActionRunner-BrXXs8ga.js";
2
- import { vt as c } from "./registry-D_zbJrLC.js";
1
+ import { $ as e, $t as t, Mt as n, U as r, bn as i, jt as a, ot as o, un as s } from "./useCurrentScreen-Bgp6_vne.js";
2
+ import { vt as c } from "./registry-KMbQkTF6.js";
3
3
  import { useEffect as l, useMemo as u } from "react";
4
4
  import { useSearchParams as d } from "react-router-dom";
5
5
  import { useInfiniteQuery as f, useMutation as p, useQueryClient as m } from "@tanstack/react-query";
@@ -48,32 +48,32 @@ var b = class {
48
48
  }
49
49
  async get(e) {
50
50
  let t = new URLSearchParams(typeof e == "string" ? { id: e } : e);
51
- return _((await o(`/api/data/${this.entity}?${t.toString()}`)).data);
51
+ return _((await a(`/api/data/${this.entity}?${t.toString()}`)).data);
52
52
  }
53
53
  async list(e = {}) {
54
- let t, n = !1;
54
+ let n, r = !1;
55
55
  try {
56
- t = await o(y(this.entity, e));
56
+ n = await a(y(this.entity, e));
57
57
  } catch (i) {
58
- if (e.after && r(i)) {
59
- let { after: r, ...i } = e;
60
- t = await o(y(this.entity, i)), n = !0;
58
+ if (e.after && t(i)) {
59
+ let { after: t, ...i } = e;
60
+ n = await a(y(this.entity, i)), r = !0;
61
61
  } else throw i;
62
62
  }
63
- return this.refs.merge(t.$refs), {
64
- data: t.data.map((e) => _(e)),
65
- meta: t.meta,
63
+ return this.refs.merge(n.$refs), {
64
+ data: n.data.map((e) => _(e)),
65
+ meta: n.meta,
66
66
  $refs: this.refs.all(),
67
- reset: n
67
+ reset: r
68
68
  };
69
69
  }
70
70
  async create(e) {
71
71
  return (await this.createMany([e]))[0];
72
72
  }
73
- async createMany(t) {
74
- if (t.length === 0) return [];
75
- let n = await e("system.batch", {
76
- actions: t.map((e) => ({
73
+ async createMany(e) {
74
+ if (e.length === 0) return [];
75
+ let t = await n("system.batch", {
76
+ actions: e.map((e) => ({
77
77
  action: `${this.entity}.__create`,
78
78
  params: {
79
79
  entity: this.entity,
@@ -82,7 +82,7 @@ var b = class {
82
82
  })),
83
83
  atomic: !0
84
84
  });
85
- return x(n, `${this.entity}.__create`), n.results.map((e) => _(S(e)));
85
+ return x(t, `${this.entity}.__create`), t.results.map((e) => _(S(e)));
86
86
  }
87
87
  async update(e, t) {
88
88
  return (await this.updateMany([{
@@ -90,10 +90,10 @@ var b = class {
90
90
  ...t
91
91
  }]))[0];
92
92
  }
93
- async updateMany(t) {
94
- if (t.length === 0) return [];
95
- let n = await e("system.batch", {
96
- actions: t.map(({ id: e, ...t }) => ({
93
+ async updateMany(e) {
94
+ if (e.length === 0) return [];
95
+ let t = await n("system.batch", {
96
+ actions: e.map(({ id: e, ...t }) => ({
97
97
  action: `${this.entity}.__update`,
98
98
  params: {
99
99
  object_ids: [e],
@@ -103,13 +103,13 @@ var b = class {
103
103
  })),
104
104
  atomic: !0
105
105
  });
106
- return x(n, `${this.entity}.__update`), n.results.map((e) => _(S(e)));
106
+ return x(t, `${this.entity}.__update`), t.results.map((e) => _(S(e)));
107
107
  }
108
108
  async delete(e) {
109
109
  await this.deleteMany([e]);
110
110
  }
111
111
  async deleteMany(e) {
112
- return e.length === 0 ? { count: 0 } : { count: (await a(`${this.entity}.__delete`, {
112
+ return e.length === 0 ? { count: 0 } : { count: (await o(`${this.entity}.__delete`, {
113
113
  object_ids: e,
114
114
  entity: this.entity
115
115
  })).object_count ?? e.length };
@@ -118,7 +118,7 @@ var b = class {
118
118
  await this.restoreMany([e]);
119
119
  }
120
120
  async restoreMany(e) {
121
- return e.length === 0 ? { count: 0 } : { count: (await a(`${this.entity}.__restore`, {
121
+ return e.length === 0 ? { count: 0 } : { count: (await o(`${this.entity}.__restore`, {
122
122
  object_ids: e,
123
123
  entity: this.entity
124
124
  })).object_count ?? e.length };
@@ -126,15 +126,15 @@ var b = class {
126
126
  async upsert(e, t) {
127
127
  return (await this.upsertMany([e], t))[0];
128
128
  }
129
- async upsertMany(t, n) {
130
- if (t.length === 0) return [];
131
- let r = await e("system.batch", {
132
- actions: t.map((e) => ({
129
+ async upsertMany(e, t) {
130
+ if (e.length === 0) return [];
131
+ let r = await n("system.batch", {
132
+ actions: e.map((e) => ({
133
133
  action: `${this.entity}.__upsert`,
134
134
  params: {
135
135
  entity: this.entity,
136
136
  fields: e,
137
- unique_by: n
137
+ unique_by: t
138
138
  }
139
139
  })),
140
140
  atomic: !0
@@ -232,40 +232,40 @@ function O(e, t, n) {
232
232
  }
233
233
  //#endregion
234
234
  //#region src/hooks/useTabSearchMirror.ts
235
- function k(e) {
236
- let t = n(), [r] = d();
235
+ function k(t) {
236
+ let n = e(), [r] = d();
237
237
  l(() => {
238
- if (!e || t.enabled) return;
239
- let n = c.getState(), i = n.findTabByPathname(e);
240
- i && n.updateTabSearch(i.id, r.toString());
238
+ if (!t || n.enabled) return;
239
+ let e = c.getState(), i = e.findTabByPathname(t);
240
+ i && e.updateTabSearch(i.id, r.toString());
241
241
  }, [
242
242
  r,
243
- e,
244
- t.enabled
243
+ t,
244
+ n.enabled
245
245
  ]);
246
246
  }
247
247
  //#endregion
248
248
  //#region src/hooks/useRegisterScreenTab.ts
249
- function A(e, t, r, i) {
250
- let a = n();
249
+ function A(t, n, r, i) {
250
+ let a = e();
251
251
  l(() => {
252
- !e || a.enabled || c.getState().openTab({
253
- pathname: e,
252
+ !t || a.enabled || c.getState().openTab({
253
+ pathname: t,
254
254
  search: i,
255
- title: t,
255
+ title: n,
256
256
  icon: r,
257
257
  closable: !0
258
258
  });
259
259
  }, [
260
- e,
261
260
  t,
261
+ n,
262
262
  r,
263
263
  a.enabled
264
264
  ]);
265
265
  }
266
266
  function j(e, t, n) {
267
- let r = e?.route, a = t ? i(e?.display?.name) || i(t.display.name_plural) : "", o = e?.display?.icon || t?.display.icon;
268
- A(t ? r : void 0, a, o, n);
267
+ let r = e?.route, i = t ? s(e?.display?.name) || s(t.display.name_plural) : "", a = e?.display?.icon || t?.display.icon;
268
+ A(t ? r : void 0, i, a, n);
269
269
  }
270
270
  //#endregion
271
271
  //#region src/lib/filters.ts
@@ -332,14 +332,14 @@ function z(e, t) {
332
332
  if (!e.field || !e.op) return "";
333
333
  let n = N[e.op] || e.op;
334
334
  if (M.has(e.op)) return `${n}`;
335
- let r = e.field, i = (e) => {
335
+ let r = e.field, a = (e) => {
336
336
  if (t) {
337
337
  let n = t(r, e);
338
338
  return n.label != null && (n.status === "special" || n.status === "resolved") ? n.label : n.raw;
339
339
  }
340
- return s(e);
340
+ return i(e);
341
341
  };
342
- return `${n} ${Array.isArray(e.value) ? e.value.map(i).join(", ") : i(e.value)}`;
342
+ return `${n} ${Array.isArray(e.value) ? e.value.map(a).join(", ") : a(e.value)}`;
343
343
  }
344
344
  function B(e, t) {
345
345
  return {
@@ -374,36 +374,36 @@ function V(e, t) {
374
374
  //#endregion
375
375
  //#region src/api/status.ts
376
376
  async function H(e, t, n, r, i) {
377
- let o = {
377
+ let a = {
378
378
  status_group_code: n,
379
379
  status_code: r
380
380
  };
381
- i != null && (o.note = i);
382
- let s = (await a(`${e}.__update`, {
381
+ i != null && (a.note = i);
382
+ let s = (await o(`${e}.__update`, {
383
383
  object_ids: [t],
384
384
  entity: e,
385
- fields: { $statuses: [o] }
385
+ fields: { $statuses: [a] }
386
386
  })).result?.rows?.[0]?.$statuses ?? [];
387
387
  return s.find((e) => e.group_code === n) ?? s[0];
388
388
  }
389
389
  //#endregion
390
390
  //#region src/hooks/useObjectStatus.ts
391
- function U(e, n) {
392
- let r = m();
391
+ function U(e, t) {
392
+ let n = m();
393
393
  return p({
394
- mutationFn: ({ groupCode: t, statusCode: r, note: i }) => H(e, n, t, r, i),
394
+ mutationFn: ({ groupCode: n, statusCode: r, note: i }) => H(e, t, n, r, i),
395
395
  onSuccess: () => {
396
- r.invalidateQueries({ queryKey: ["entity-item", e] });
396
+ n.invalidateQueries({ queryKey: ["entity-item", e] });
397
397
  },
398
398
  onError: (e) => {
399
- t.error(e.message);
399
+ r.error(e.message);
400
400
  }
401
401
  });
402
402
  }
403
403
  //#endregion
404
404
  //#region src/api/properties.ts
405
405
  async function W(e, t, n, r) {
406
- let i = (await a(`${e}.__update`, {
406
+ let i = (await o(`${e}.__update`, {
407
407
  object_ids: [t],
408
408
  entity: e,
409
409
  fields: { $properties: [{
@@ -414,7 +414,7 @@ async function W(e, t, n, r) {
414
414
  return i.find((e) => e.property_code === n) ?? i[0];
415
415
  }
416
416
  async function G(e, t, n) {
417
- await a(`${e}.__update`, {
417
+ await o(`${e}.__update`, {
418
418
  object_ids: [t],
419
419
  entity: e,
420
420
  fields: { $properties: [{
@@ -425,27 +425,27 @@ async function G(e, t, n) {
425
425
  }
426
426
  //#endregion
427
427
  //#region src/hooks/useProperties.ts
428
- function K(e, n) {
429
- let r = m();
428
+ function K(e, t) {
429
+ let n = m();
430
430
  return p({
431
- mutationFn: ({ propertyCode: t, value: r }) => W(e, n, t, r),
431
+ mutationFn: ({ propertyCode: n, value: r }) => W(e, t, n, r),
432
432
  onSuccess: () => {
433
- r.invalidateQueries({ queryKey: ["entity-item", e] });
433
+ n.invalidateQueries({ queryKey: ["entity-item", e] });
434
434
  },
435
435
  onError: (e) => {
436
- t.error(e.message);
436
+ r.error(e.message);
437
437
  }
438
438
  });
439
439
  }
440
- function q(e, n) {
441
- let r = m();
440
+ function q(e, t) {
441
+ let n = m();
442
442
  return p({
443
- mutationFn: (t) => G(e, n, t),
443
+ mutationFn: (n) => G(e, t, n),
444
444
  onSuccess: () => {
445
- r.invalidateQueries({ queryKey: ["entity-item", e] });
445
+ n.invalidateQueries({ queryKey: ["entity-item", e] });
446
446
  },
447
447
  onError: (e) => {
448
- t.error(e.message);
448
+ r.error(e.message);
449
449
  }
450
450
  });
451
451
  }
@@ -1,4 +1,4 @@
1
- import { Lt as e, Rt as t, Vt as n } from "./ActionRunner-BrXXs8ga.js";
1
+ import { Bt as e, Ut as t, zt as n } from "./useCurrentScreen-Bgp6_vne.js";
2
2
  import { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
3
3
  //#region src/embed/file-src.ts
4
4
  var s = "/api/files";
@@ -29,17 +29,17 @@ function d(e, t) {
29
29
  function f(e) {
30
30
  return `${e}${e.includes("?") ? "&" : "?"}disposition=attachment`;
31
31
  }
32
- async function p(n, r) {
33
- let i = await e(), a = await fetch(n, d(i, r));
32
+ async function p(t, r) {
33
+ let i = await n(), a = await fetch(t, d(i, r));
34
34
  if (a.status !== 401) return a;
35
- t();
36
- let o = await e();
37
- return fetch(n, d(o, r));
38
- }
39
- async function m(e, t, r) {
40
- if (!n()) throw Error("resolveEmbedFileSrc called outside embed token mode");
41
- let i = await p(l(e, t), r);
42
- if (i.status === 202 && typeof t == "object") throw new u(e, t.derivation);
35
+ e();
36
+ let o = await n();
37
+ return fetch(t, d(o, r));
38
+ }
39
+ async function m(e, n, r) {
40
+ if (!t()) throw Error("resolveEmbedFileSrc called outside embed token mode");
41
+ let i = await p(l(e, n), r);
42
+ if (i.status === 202 && typeof n == "object") throw new u(e, n.derivation);
43
43
  if (!i.ok) throw Error(`embed file url request failed: ${i.status} ${i.statusText}`);
44
44
  let a = await i.json();
45
45
  if (!c(a)) throw Error("embed file url response is malformed");
@@ -48,7 +48,7 @@ async function m(e, t, r) {
48
48
  kind: "direct"
49
49
  };
50
50
  if (!a.url.startsWith("/api/files/")) throw Error(`embed file proxy: refusing non-files-route URL ${JSON.stringify(a.url)}`);
51
- let o = await p(t === "download" ? f(a.url) : a.url, r);
51
+ let o = await p(n === "download" ? f(a.url) : a.url, r);
52
52
  if (!o.ok) throw Error(`embed file proxy fetch failed: ${o.status} ${o.statusText}`);
53
53
  let s = await o.blob();
54
54
  return {
@@ -148,23 +148,23 @@ function k(e) {
148
148
  function A(e) {
149
149
  return e.startsWith("derivation:") ? { derivation: e.slice(11) } : e === "download" ? "download" : "preview";
150
150
  }
151
- function j(e, t, r) {
152
- let a = k(t), [s, c] = o(() => n() ? void 0 : r);
151
+ function j(e, n, r) {
152
+ let a = k(n), [s, c] = o(() => t() ? void 0 : r);
153
153
  return i(() => {
154
- n() || c(r);
154
+ t() || c(r);
155
155
  }, [r]), i(() => {
156
- if (!n()) return;
156
+ if (!t()) return;
157
157
  if (!e) {
158
158
  c(void 0);
159
159
  return;
160
160
  }
161
- let t = null, r = !1, i = new AbortController();
161
+ let n = null, r = !1, i = new AbortController();
162
162
  return c(void 0), m(e, A(a), i.signal).then((e) => {
163
163
  if (r) {
164
164
  e.kind === "blob" && URL.revokeObjectURL(e.url);
165
165
  return;
166
166
  }
167
- e.kind === "blob" && (t = e.url), c(e.url);
167
+ e.kind === "blob" && (n = e.url), c(e.url);
168
168
  }).catch((e) => {
169
169
  if (!r) {
170
170
  if (e instanceof u) {
@@ -174,7 +174,7 @@ function j(e, t, r) {
174
174
  e instanceof DOMException && e.name === "AbortError" || (console.error("[declarion-embed] file src resolution failed:", e), c(void 0));
175
175
  }
176
176
  }), () => {
177
- r = !0, i.abort(), t && URL.revokeObjectURL(t);
177
+ r = !0, i.abort(), n && URL.revokeObjectURL(n);
178
178
  };
179
179
  }, [e, a]), s;
180
180
  }
@@ -183,12 +183,12 @@ function M() {
183
183
  return i(() => () => {
184
184
  for (let t of e.current) URL.revokeObjectURL(t);
185
185
  e.current = [];
186
- }, []), { open: r((t, r, i) => {
187
- if (!n()) {
186
+ }, []), { open: r((n, r, i) => {
187
+ if (!t()) {
188
188
  i && window.open(i, "_blank", "noopener");
189
189
  return;
190
190
  }
191
- t && m(t, r).then((t) => {
191
+ n && m(n, r).then((t) => {
192
192
  t.kind === "blob" && e.current.push(t.url), window.open(t.url, "_blank", "noopener");
193
193
  }).catch((e) => {
194
194
  e instanceof u || console.error("[declarion-embed] file open failed:", e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@declarion/react",
3
- "version": "0.36.3",
3
+ "version": "0.36.5",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "React SDK for Declarion, the schema-driven business apps platform.",