@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,5 +1,5 @@
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-BA2lb-d7.js";
2
- import { wt as c } from "./registry-DXNFRlbB.js";
1
+ import { Fn as e, Kt as t, Tn as n, it as r, mn as i, mt as a, qt as o, xt as s } from "./useCurrentScreen-C33VZcNn.js";
2
+ import { ut as c } from "./registry-DbZX1hy8.js";
3
3
  import { useEffect as l, useLayoutEffect as u, useMemo as d } from "react";
4
4
  import { useSearchParams as f } from "react-router-dom";
5
5
  import { useInfiniteQuery as p, useMutation as m, useQueryClient as h } from "@tanstack/react-query";
@@ -47,18 +47,18 @@ var x = class {
47
47
  this.entity = e, this.refs = t ?? new y();
48
48
  }
49
49
  async get(e) {
50
- let t = new URLSearchParams(typeof e == "string" ? { id: e } : e);
51
- return v((await a(`/api/data/${this.entity}?${t.toString()}`)).data);
50
+ let n = new URLSearchParams(typeof e == "string" ? { id: e } : e);
51
+ return v((await t(`/api/data/${this.entity}?${n.toString()}`)).data);
52
52
  }
53
53
  async list(e = {}) {
54
54
  let n, r = !1;
55
55
  try {
56
- n = await a(b(this.entity, e));
57
- } catch (i) {
58
- if (e.after && t(i)) {
59
- let { after: t, ...i } = e;
60
- n = await a(b(this.entity, i)), r = !0;
61
- } else throw i;
56
+ n = await t(b(this.entity, e));
57
+ } catch (a) {
58
+ if (e.after && i(a)) {
59
+ let { after: i, ...a } = e;
60
+ n = await t(b(this.entity, a)), r = !0;
61
+ } else throw a;
62
62
  }
63
63
  return this.refs.merge(n.$refs), {
64
64
  data: n.data.map((e) => v(e)),
@@ -72,7 +72,7 @@ var x = class {
72
72
  }
73
73
  async createMany(e) {
74
74
  if (e.length === 0) return [];
75
- let t = await n("system.batch", {
75
+ let t = await o("system.batch", {
76
76
  actions: e.map((e) => ({
77
77
  action: `${this.entity}.__create`,
78
78
  params: {
@@ -92,7 +92,7 @@ var x = class {
92
92
  }
93
93
  async updateMany(e) {
94
94
  if (e.length === 0) return [];
95
- let t = await n("system.batch", {
95
+ let t = await o("system.batch", {
96
96
  actions: e.map(({ id: e, ...t }) => ({
97
97
  action: `${this.entity}.__update`,
98
98
  params: {
@@ -109,7 +109,7 @@ var x = class {
109
109
  await this.deleteMany([e]);
110
110
  }
111
111
  async deleteMany(e) {
112
- return e.length === 0 ? { count: 0 } : { count: (await o(`${this.entity}.__delete`, {
112
+ return e.length === 0 ? { count: 0 } : { count: (await s(`${this.entity}.__delete`, {
113
113
  object_ids: e,
114
114
  entity: this.entity
115
115
  })).object_count ?? e.length };
@@ -118,7 +118,7 @@ var x = class {
118
118
  await this.restoreMany([e]);
119
119
  }
120
120
  async restoreMany(e) {
121
- return e.length === 0 ? { count: 0 } : { count: (await o(`${this.entity}.__restore`, {
121
+ return e.length === 0 ? { count: 0 } : { count: (await s(`${this.entity}.__restore`, {
122
122
  object_ids: e,
123
123
  entity: this.entity
124
124
  })).object_count ?? e.length };
@@ -128,7 +128,7 @@ var x = class {
128
128
  }
129
129
  async upsertMany(e, t) {
130
130
  if (e.length === 0) return [];
131
- let r = await n("system.batch", {
131
+ let n = await o("system.batch", {
132
132
  actions: e.map((e) => ({
133
133
  action: `${this.entity}.__upsert`,
134
134
  params: {
@@ -139,7 +139,7 @@ var x = class {
139
139
  })),
140
140
  atomic: !0
141
141
  });
142
- return S(r, `${this.entity}.__upsert`), r.results.map((e) => v(w(e)));
142
+ return S(n, `${this.entity}.__upsert`), n.results.map((e) => v(w(e)));
143
143
  }
144
144
  };
145
145
  function S(e, t) {
@@ -232,40 +232,40 @@ function k(e, t, n) {
232
232
  }
233
233
  //#endregion
234
234
  //#region src/hooks/useTabSearchMirror.ts
235
- function A(t) {
236
- let n = e(), [r] = f();
235
+ function A(e) {
236
+ let t = a(), [n] = f();
237
237
  u(() => {
238
- if (!t || n.enabled) return;
239
- let e = c.getState(), i = e.findTabByPathname(t);
240
- i && e.updateTabSearch(i.id, r.toString());
238
+ if (!e || t.enabled) return;
239
+ let r = c.getState(), i = r.findTabByPathname(e);
240
+ i && r.updateTabSearch(i.id, n.toString());
241
241
  }, [
242
- r,
243
- t,
244
- n.enabled
242
+ n,
243
+ e,
244
+ t.enabled
245
245
  ]);
246
246
  }
247
247
  //#endregion
248
248
  //#region src/hooks/useRegisterScreenTab.ts
249
- function j(t, n, r, i) {
250
- let a = e();
249
+ function j(e, t, n, r) {
250
+ let i = a();
251
251
  l(() => {
252
- !t || a.enabled || c.getState().openTab({
253
- pathname: t,
254
- search: i,
255
- title: n,
256
- icon: r,
252
+ !e || i.enabled || c.getState().openTab({
253
+ pathname: e,
254
+ search: r,
255
+ title: t,
256
+ icon: n,
257
257
  closable: !0
258
258
  });
259
259
  }, [
260
+ e,
260
261
  t,
261
262
  n,
262
- r,
263
- a.enabled
263
+ i.enabled
264
264
  ]);
265
265
  }
266
- function M(e, t, 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
- j(t ? r : void 0, i, a, n);
266
+ function M(e, t, r) {
267
+ let i = e?.route, a = t ? n(e?.display?.name) || n(t.display.name_plural) : "", o = e?.display?.icon || t?.display.icon;
268
+ j(t ? i : void 0, a, o, r);
269
269
  }
270
270
  //#endregion
271
271
  //#region src/lib/filters.ts
@@ -279,7 +279,7 @@ var N = /* @__PURE__ */ new Set([
279
279
  "last_30_days",
280
280
  "last_hour",
281
281
  "last_24_hours"
282
- ]), P = {
282
+ ]), P = /* @__PURE__ */ new Set(["in", "not_in"]), F = {
283
283
  eq: "is",
284
284
  not_eq: "is not",
285
285
  gt: ">",
@@ -301,7 +301,7 @@ var N = /* @__PURE__ */ new Set([
301
301
  last_hour: "last hour",
302
302
  last_24_hours: "last 24 hours"
303
303
  };
304
- function F(e) {
304
+ function I(e) {
305
305
  let t = e.get("filters");
306
306
  if (!t) return [];
307
307
  try {
@@ -311,48 +311,48 @@ function F(e) {
311
311
  return [];
312
312
  }
313
313
  }
314
- function I(e, t) {
314
+ function L(e, t) {
315
315
  e.length === 0 ? t.delete("filters") : t.set("filters", JSON.stringify(e));
316
316
  }
317
- function L(e) {
317
+ function R(e) {
318
318
  return e.some((e) => e.or != null);
319
319
  }
320
- function R(e) {
320
+ function z(e) {
321
321
  let t = [];
322
322
  for (let n of e) if (!(!n || typeof n != "object")) {
323
- if (n.field && n.op && t.push(n), n.or) for (let e of n.or) t.push(...R(e));
324
- n.and && t.push(...R(n.and));
323
+ if (n.field && n.op && t.push(n), n.or) for (let e of n.or) t.push(...z(e));
324
+ n.and && t.push(...z(n.and));
325
325
  }
326
326
  return t;
327
327
  }
328
- function z(e) {
329
- return R(e).length;
328
+ function B(e) {
329
+ return z(e).length;
330
330
  }
331
- function B(e, t) {
332
- if (!e.field || !e.op) return "";
333
- let n = P[e.op] || e.op;
334
- if (N.has(e.op)) return `${n}`;
335
- let r = e.field, a = (e) => {
336
- if (t) {
337
- let n = t(r, e);
338
- return n.label != null && (n.status === "special" || n.status === "resolved") ? n.label : n.raw;
331
+ function V(t, n) {
332
+ if (!t.field || !t.op) return "";
333
+ let r = F[t.op] || t.op;
334
+ if (N.has(t.op)) return `${r}`;
335
+ let i = t.field, a = (t) => {
336
+ if (n) {
337
+ let e = n(i, t);
338
+ return e.label != null && (e.status === "special" || e.status === "resolved") ? e.label : e.raw;
339
339
  }
340
- return i(e);
340
+ return e(t);
341
341
  };
342
- return `${n} ${Array.isArray(e.value) ? e.value.map(a).join(", ") : a(e.value)}`;
342
+ return `${r} ${Array.isArray(t.value) ? t.value.map(a).join(", ") : a(t.value)}`;
343
343
  }
344
- function V(e, t) {
344
+ function H(e, t) {
345
345
  return {
346
346
  field: e,
347
347
  op: "eq",
348
348
  value: t
349
349
  };
350
350
  }
351
- function H(e, t) {
351
+ function U(e, t) {
352
352
  let n = [];
353
353
  for (let r of e) if (r.field !== t) {
354
354
  if (r.or) {
355
- let e = r.or.map((e) => H(e, t)).filter((e) => e.length > 0);
355
+ let e = r.or.map((e) => U(e, t)).filter((e) => e.length > 0);
356
356
  e.length > 0 && n.push({
357
357
  ...r,
358
358
  or: e
@@ -360,7 +360,7 @@ function H(e, t) {
360
360
  continue;
361
361
  }
362
362
  if (r.and) {
363
- let e = H(r.and, t);
363
+ let e = U(r.and, t);
364
364
  e.length > 0 && n.push({
365
365
  ...r,
366
366
  and: e
@@ -373,25 +373,25 @@ function H(e, t) {
373
373
  }
374
374
  //#endregion
375
375
  //#region src/api/status.ts
376
- async function U(e, t, n, r, i) {
376
+ async function W(e, t, n, r, i) {
377
377
  let a = {
378
378
  status_group_code: n,
379
379
  status_code: r
380
380
  };
381
381
  i != null && (a.note = i);
382
- let s = (await o(`${e}.__update`, {
382
+ let o = (await s(`${e}.__update`, {
383
383
  object_ids: [t],
384
384
  entity: e,
385
385
  fields: { $statuses: [a] }
386
386
  })).result?.rows?.[0]?.$statuses ?? [];
387
- return s.find((e) => e.group_code === n) ?? s[0];
387
+ return o.find((e) => e.group_code === n) ?? o[0];
388
388
  }
389
389
  //#endregion
390
390
  //#region src/hooks/useObjectStatus.ts
391
- function W(e, t) {
391
+ function G(e, t) {
392
392
  let n = h();
393
393
  return m({
394
- mutationFn: ({ groupCode: n, statusCode: r, note: i }) => U(e, t, n, r, i),
394
+ mutationFn: ({ groupCode: n, statusCode: r, note: i }) => W(e, t, n, r, i),
395
395
  onSuccess: () => {
396
396
  n.invalidateQueries({ queryKey: ["entity-item", e] });
397
397
  },
@@ -402,8 +402,8 @@ function W(e, t) {
402
402
  }
403
403
  //#endregion
404
404
  //#region src/api/properties.ts
405
- async function G(e, t, n, r) {
406
- let i = (await o(`${e}.__update`, {
405
+ async function K(e, t, n, r) {
406
+ let i = (await s(`${e}.__update`, {
407
407
  object_ids: [t],
408
408
  entity: e,
409
409
  fields: { $properties: [{
@@ -413,8 +413,8 @@ async function G(e, t, n, r) {
413
413
  })).result?.rows?.[0]?.$properties ?? [];
414
414
  return i.find((e) => e.property_code === n) ?? i[0];
415
415
  }
416
- async function K(e, t, n) {
417
- await o(`${e}.__update`, {
416
+ async function q(e, t, n) {
417
+ await s(`${e}.__update`, {
418
418
  object_ids: [t],
419
419
  entity: e,
420
420
  fields: { $properties: [{
@@ -425,10 +425,10 @@ async function K(e, t, n) {
425
425
  }
426
426
  //#endregion
427
427
  //#region src/hooks/useProperties.ts
428
- function q(e, t) {
428
+ function J(e, t) {
429
429
  let n = h();
430
430
  return m({
431
- mutationFn: ({ propertyCode: n, value: r }) => G(e, t, n, r),
431
+ mutationFn: ({ propertyCode: n, value: r }) => K(e, t, n, r),
432
432
  onSuccess: () => {
433
433
  n.invalidateQueries({ queryKey: ["entity-item", e] });
434
434
  },
@@ -437,10 +437,10 @@ function q(e, t) {
437
437
  }
438
438
  });
439
439
  }
440
- function J(e, t) {
440
+ function Y(e, t) {
441
441
  let n = h();
442
442
  return m({
443
- mutationFn: (n) => K(e, t, n),
443
+ mutationFn: (n) => q(e, t, n),
444
444
  onSuccess: () => {
445
445
  n.invalidateQueries({ queryKey: ["entity-item", e] });
446
446
  },
@@ -450,4 +450,4 @@ function J(e, t) {
450
450
  });
451
451
  }
452
452
  //#endregion
453
- export { T as C, y as S, E as _, P as a, k as b, R as c, F as d, H as f, A as g, j as h, N as i, B as l, M as m, q as n, z as o, I as p, W as r, V as s, J as t, L as u, O as v, x, D as y };
453
+ export { y as C, x as S, A as _, N as a, D as b, H as c, R as d, I as f, j as g, M as h, P as i, z as l, L as m, J as n, F as o, U as p, G as r, B as s, Y as t, V as u, E as v, T as w, k as x, O as y };
@@ -1,4 +1,4 @@
1
- import { Bt as e, Ut as t, zt as n } from "./useCurrentScreen-BA2lb-d7.js";
1
+ import { en as e, in as t, tn as n } from "./useCurrentScreen-C33VZcNn.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";
@@ -30,10 +30,10 @@ function f(e) {
30
30
  return `${e}${e.includes("?") ? "&" : "?"}disposition=attachment`;
31
31
  }
32
32
  async function p(t, r) {
33
- let i = await n(), a = await fetch(t, d(i, r));
33
+ let i = await e(), a = await fetch(t, d(i, r));
34
34
  if (a.status !== 401) return a;
35
- e();
36
- let o = await n();
35
+ n();
36
+ let o = await e();
37
37
  return fetch(t, d(o, r));
38
38
  }
39
39
  async function m(e, n, r) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@declarion/react",
3
- "version": "0.39.0",
3
+ "version": "0.40.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "React SDK for Declarion, the schema-driven business apps platform.",