@declarion/react 0.39.0 → 0.40.1

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.
@@ -1,4 +1,4 @@
1
- import { D as e } from "./useCurrentScreen-BA2lb-d7.js";
1
+ import { H as e } from "./useCurrentScreen-C33VZcNn.js";
2
2
  import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
3
  import r, { defaultUrlTransform as i } from "react-markdown";
4
4
  import a from "remark-breaks";
@@ -1,5 +1,5 @@
1
1
  import { s as e } from "./DynamicIcon-DeRpAaXm.js";
2
- import { $ as t, Gn as n, Hn as r, Kn as i, Nn as a, Pn as o, Wn as s, _t as c, ct as l, et as u, i as d, jt as f, ot as p, un as m, xn as h } from "./useCurrentScreen-BA2lb-d7.js";
2
+ import { Ct as t, In as n, Kt as r, Mt as i, Tn as a, Xn as o, Yn as s, cr as c, ht as l, i as u, ir as d, mt as f, or as p, sr as m, xt as h } from "./useCurrentScreen-C33VZcNn.js";
3
3
  import { useCallback as g, useEffect as _, useId as v, useMemo as y, useRef as b, useState as x } from "react";
4
4
  import { useLocation as S } from "react-router-dom";
5
5
  import { useQuery as C, useQueryClient as w } from "@tanstack/react-query";
@@ -182,7 +182,7 @@ function le(e) {
182
182
  //#endregion
183
183
  //#region src/api/params.ts
184
184
  async function ue() {
185
- let e = (await f("/api/params/public")).data;
185
+ let e = (await r("/api/params/public")).data;
186
186
  if (Array.isArray(e)) return { parameters: e };
187
187
  let t = e ?? {};
188
188
  return {
@@ -193,59 +193,59 @@ async function ue() {
193
193
  };
194
194
  }
195
195
  async function z(e) {
196
- return (await f(`/api/params/${encodeURIComponent(e)}`)).data;
196
+ return (await r(`/api/params/${encodeURIComponent(e)}`)).data;
197
197
  }
198
198
  async function de(e) {
199
- return (await f(`/api/params${e === "tenant" ? "?resolution=tenant" : ""}`)).data ?? [];
199
+ return (await r(`/api/params${e === "tenant" ? "?resolution=tenant" : ""}`)).data ?? [];
200
200
  }
201
201
  //#endregion
202
202
  //#region src/hooks/useParams.ts
203
203
  var B = "$params";
204
- function fe({ carrierEntityCode: e, rowId: t, enabled: n = !0, onWritten: r }) {
205
- let i = w(), [a, o] = x(null), s = C({
204
+ function fe({ carrierEntityCode: e, rowId: n, enabled: r = !0, onWritten: i }) {
205
+ let a = w(), [o, s] = x(null), c = C({
206
206
  queryKey: [
207
207
  "params-carrier-detail",
208
208
  e,
209
- t
209
+ n
210
210
  ],
211
- queryFn: () => l(e, t),
212
- enabled: n && !!t,
211
+ queryFn: () => t(e, n),
212
+ enabled: r && !!n,
213
213
  staleTime: 30 * 1e3
214
- }), c = s.data?.data, u = !!c && !("$params" in c), d = y(() => Array.isArray(c?.$params) ? c[B] : [], [c]), f = y(() => new Map(d.map((e) => [e.param_code, e])), [d]), m = g(async (n) => {
215
- o(null);
214
+ }), l = c.data?.data, u = !!l && !("$params" in l), d = y(() => Array.isArray(l?.$params) ? l[B] : [], [l]), f = y(() => new Map(d.map((e) => [e.param_code, e])), [d]), p = g(async (t) => {
215
+ s(null);
216
216
  try {
217
- await p(`${e}.__update`, {
218
- object_ids: [t],
217
+ await h(`${e}.__update`, {
218
+ object_ids: [n],
219
219
  entity: e,
220
- fields: { [B]: n }
221
- }), await i.invalidateQueries({ queryKey: ["params-all"] }), await i.invalidateQueries({ queryKey: [
220
+ fields: { [B]: t }
221
+ }), await a.invalidateQueries({ queryKey: ["params-all"] }), await a.invalidateQueries({ queryKey: [
222
222
  "params-carrier-detail",
223
223
  e,
224
- t
225
- ] }), r?.();
224
+ n
225
+ ] }), i?.();
226
226
  } catch (e) {
227
- o(e instanceof Error ? e.message : "Failed to save parameter.");
227
+ s(e instanceof Error ? e.message : "Failed to save parameter.");
228
228
  }
229
229
  }, [
230
230
  e,
231
- t,
232
- i,
233
- r
234
- ]), h = g((e, t) => {
231
+ n,
232
+ a,
233
+ i
234
+ ]), m = g((e, t) => {
235
235
  let n = d.filter((t) => t.param_code !== e.code);
236
236
  return n.push({
237
237
  param_code: e.code,
238
238
  value: t
239
- }), m(n);
240
- }, [d, m]), _ = g((e) => m(d.filter((t) => t.param_code !== e.code)), [d, m]), v = g(() => o(null), []);
239
+ }), p(n);
240
+ }, [d, p]), _ = g((e) => p(d.filter((t) => t.param_code !== e.code)), [d, p]), v = g(() => s(null), []);
241
241
  return {
242
242
  overrides: d,
243
243
  overrideByCode: f,
244
244
  missingParams: u,
245
- isLoading: s.isLoading,
246
- error: a,
245
+ isLoading: c.isLoading,
246
+ error: o,
247
247
  clearError: v,
248
- save: h,
248
+ save: m,
249
249
  reset: _
250
250
  };
251
251
  }
@@ -273,7 +273,7 @@ function me(e, t = {}) {
273
273
  });
274
274
  }
275
275
  function H(e) {
276
- let t = c((e) => e.isAuthenticated), n = V(), r = me(e, { enabled: t }), i = he(n.data?.parameters, e);
276
+ let t = i((e) => e.isAuthenticated), n = V(), r = me(e, { enabled: t }), a = he(n.data?.parameters, e);
277
277
  if (t && r.data?.found) return {
278
278
  value: r.data.value,
279
279
  found: !0,
@@ -281,11 +281,11 @@ function H(e) {
281
281
  loading: !1,
282
282
  error: null
283
283
  };
284
- let a = i !== void 0;
284
+ let o = a !== void 0;
285
285
  return {
286
- value: i?.value,
287
- found: a,
288
- source: a ? "public" : void 0,
286
+ value: a?.value,
287
+ found: o,
288
+ source: o ? "public" : void 0,
289
289
  loading: n.isLoading || t && r.isLoading && !r.data && !r.error,
290
290
  error: r.error ?? n.error ?? null
291
291
  };
@@ -454,7 +454,7 @@ function ye(e) {
454
454
  }
455
455
  function Q(e) {
456
456
  let t = ye(e.pathname), n = e.search ?? "", r = n.startsWith("?") ? n.slice(1) : n, i = new URLSearchParams(r);
457
- for (let e of u) i.delete(e);
457
+ for (let e of l) i.delete(e);
458
458
  i.sort();
459
459
  let a = i.toString();
460
460
  return a ? `${t}?${a}` : t;
@@ -512,20 +512,20 @@ var Oe = "record-documents";
512
512
  //#endregion
513
513
  //#region src/hooks/useBrandingChrome.ts
514
514
  function ke() {
515
- let e = t(), n = G();
516
- return (e.enabled ? n?.embed?.viewport : n?.full?.viewport) ?? "auto";
515
+ let e = f(), t = G();
516
+ return (e.enabled ? t?.embed?.viewport : t?.full?.viewport) ?? "auto";
517
517
  }
518
518
  function Ae(e) {
519
- let n = t(), r = G();
519
+ let t = f(), n = G();
520
520
  return y(() => {
521
- let t = { ...n.enabled ? r?.embed?.surfaces?.[e] : r?.full?.surfaces?.[e] };
521
+ let r = { ...t.enabled ? n?.embed?.surfaces?.[e] : n?.full?.surfaces?.[e] };
522
522
  return {
523
- ...t,
524
- isVisible: (e) => t[e] !== !1
523
+ ...r,
524
+ isVisible: (e) => r[e] !== !1
525
525
  };
526
526
  }, [
527
- r,
528
- n.enabled,
527
+ n,
528
+ t.enabled,
529
529
  e
530
530
  ]);
531
531
  }
@@ -558,10 +558,10 @@ function Pe(e, t) {
558
558
  //#endregion
559
559
  //#region src/components/pages/DocumentsMenu.tsx
560
560
  var Fe = "document-templates-available";
561
- function Ie({ entityCode: t, scope: n, objectIds: a = [], viewState: s, selectedIds: c = [], capability: l, canManageTemplates: u = !1 }) {
562
- let { run: f } = d(), h = b(null), [g, _] = x(!1), v = n === "detail" ? !!l?.generate_one : !!l?.generate_many, S = u && !v, { data: w, isLoading: ee, error: O } = C({
561
+ function Ie({ entityCode: t, scope: n, objectIds: r = [], viewState: i, selectedIds: s = [], capability: l, canManageTemplates: f = !1 }) {
562
+ let { run: p } = u(), m = b(null), [g, _] = x(!1), v = n === "detail" ? !!l?.generate_one : !!l?.generate_many, S = f && !v, { data: w, isLoading: ee, error: O } = C({
563
563
  queryKey: [Fe, t],
564
- queryFn: async () => (await p("document.templates.available", { entity: t })).result?.templates ?? [],
564
+ queryFn: async () => (await h("document.templates.available", { entity: t })).result?.templates ?? [],
565
565
  enabled: g || S,
566
566
  staleTime: 6e4
567
567
  }), k = ee, A = y(() => (w ?? []).filter((e) => n === "detail" ? e.input_mode === "one" || e.input_mode === "global" : e.input_mode === "many" || e.input_mode === "global"), [n, w]), j = S && A.length > 0, M = v || j;
@@ -570,25 +570,25 @@ function Ie({ entityCode: t, scope: n, objectIds: a = [], viewState: s, selected
570
570
  }
571
571
  function P(e) {
572
572
  if (e.input_mode === "global") return [{ kind: "global" }];
573
- if (n === "detail") return e.input_mode === "one" && a.length === 1 ? [{
573
+ if (n === "detail") return e.input_mode === "one" && r.length === 1 ? [{
574
574
  kind: "one",
575
- objectIds: a
575
+ objectIds: r
576
576
  }] : [];
577
577
  if (e.input_mode === "many") {
578
578
  let e = [];
579
- return s && e.push({
579
+ return i && e.push({
580
580
  kind: "current_view",
581
- query: Ne(s)
582
- }), c.length > 0 && e.push({
581
+ query: Ne(i)
582
+ }), s.length > 0 && e.push({
583
583
  kind: "selected",
584
- objectIds: c
584
+ objectIds: s
585
585
  }), e;
586
586
  }
587
587
  return [];
588
588
  }
589
589
  function F(e, t, n) {
590
- let r = Le(e), i = m(e.name) || e.code;
591
- _(!1), f({
590
+ let r = Le(e), i = a(e.name) || e.code;
591
+ _(!1), p({
592
592
  action: r,
593
593
  title: i,
594
594
  execute: (r) => {
@@ -600,21 +600,21 @@ function Ie({ entityCode: t, scope: n, objectIds: a = [], viewState: s, selected
600
600
  return Object.keys(r).length > 0 && (i.params = r), "objectIds" in t && (i.object_ids = t.objectIds), "query" in t && (i.query = {
601
601
  scope: "current_view",
602
602
  query: t.query
603
- }), p("document.generate", i);
603
+ }), h("document.generate", i);
604
604
  }
605
605
  });
606
606
  }
607
- return M ? /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E(i, {
608
- ref: h,
607
+ return M ? /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E(c, {
608
+ ref: m,
609
609
  kind: "ghost",
610
610
  size: "sm",
611
611
  icon: E(k ? e.loader : e.filePlus, { size: 12 }),
612
612
  onClick: N,
613
613
  disabled: k,
614
614
  children: "Generate"
615
- }), /* @__PURE__ */ D(r, {
615
+ }), /* @__PURE__ */ D(d, {
616
616
  open: g,
617
- anchor: h.current,
617
+ anchor: m.current,
618
618
  onClose: () => _(!1),
619
619
  align: "end",
620
620
  width: 300,
@@ -639,7 +639,7 @@ function Ie({ entityCode: t, scope: n, objectIds: a = [], viewState: s, selected
639
639
  return n.length === 0 ? null : Re(t).flatMap((r) => n.map((n) => r.available ? /* @__PURE__ */ E(o, {
640
640
  icon: /* @__PURE__ */ E(e.file, { size: 12 }),
641
641
  onClick: () => F(t, n, r.format),
642
- title: m(t.description),
642
+ title: a(t.description),
643
643
  children: ze(t, n, r.format)
644
644
  }, `${t.source}:${t.code}:${n.kind}:${r.format}`) : /* @__PURE__ */ D(o, {
645
645
  disabled: !0,
@@ -656,7 +656,7 @@ function Ie({ entityCode: t, scope: n, objectIds: a = [], viewState: s, selected
656
656
  })] }) : null;
657
657
  }
658
658
  function Le(e) {
659
- let t = new h((e.params ?? []).map((e) => ({
659
+ let t = new n((e.params ?? []).map((e) => ({
660
660
  ...e,
661
661
  name: e.name ?? ""
662
662
  })));
@@ -677,7 +677,7 @@ function Re(e) {
677
677
  }));
678
678
  }
679
679
  function ze(e, t, n) {
680
- let r = m(e.name) || e.code, i = n ? ` (${n.toUpperCase()})` : "";
680
+ let r = a(e.name) || e.code, i = n ? ` (${n.toUpperCase()})` : "";
681
681
  switch (t.kind) {
682
682
  case "one": return `${r}${i}`;
683
683
  case "selected": return `${r}${i} - selected rows`;
@@ -883,28 +883,28 @@ function at(e) {
883
883
  }
884
884
  //#endregion
885
885
  //#region src/components/shared/RefreshControl.tsx
886
- function ot({ liveObject: t, realtime: r = !0 }) {
886
+ function ot({ liveObject: t, realtime: n = !0 }) {
887
887
  return /* @__PURE__ */ D("span", {
888
888
  style: {
889
889
  display: "inline-flex",
890
890
  alignItems: "center",
891
891
  gap: 8
892
892
  },
893
- children: [/* @__PURE__ */ E(n, {
893
+ children: [/* @__PURE__ */ E(m, {
894
894
  icon: t.isFetching ? /* @__PURE__ */ E("span", {
895
895
  "data-testid": "refresh-spinner",
896
896
  style: { display: "inline-flex" },
897
- children: /* @__PURE__ */ E(a, { size: 14 })
897
+ children: /* @__PURE__ */ E(s, { size: 14 })
898
898
  }) : /* @__PURE__ */ E(e.refresh, { size: 14 }),
899
899
  title: "Refresh",
900
900
  disabled: t.isLoading || t.isFetching,
901
901
  onClick: () => {
902
902
  t.refetch();
903
903
  }
904
- }), r && /* @__PURE__ */ E("span", {
904
+ }), n && /* @__PURE__ */ E("span", {
905
905
  "data-testid": "live-indicator",
906
906
  title: t.isLive ? "This view updates automatically in realtime." : "Realtime updates are paused. Refresh manually to load the latest data.",
907
- children: /* @__PURE__ */ E(s, {
907
+ children: /* @__PURE__ */ E(p, {
908
908
  tone: t.isLive ? "emerald" : "amber",
909
909
  size: "xs",
910
910
  dot: !0,