@declarion/react 0.52.0 → 0.53.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 (37) hide show
  1. package/dist-lib/{DraggableChildrenTable-CJCjc_cd.js → DraggableChildrenTable-BQZTvZaU.js} +35 -35
  2. package/dist-lib/{Grid-DUjbQg3r.js → Grid-B9Tiytbd.js} +28 -28
  3. package/dist-lib/{LayoutRenderer-DbdxC-Bq.js → LayoutRenderer-D_v9OD_A.js} +920 -922
  4. package/dist-lib/{ListCardsBody-C8ofksQb.js → ListCardsBody-dRnXsQ7A.js} +14 -14
  5. package/dist-lib/{MarkdownRenderer-B9_5fwuE.js → MarkdownRenderer-BCyrsLrd.js} +10 -10
  6. package/dist-lib/{record-documents-key-8fdm7C10.js → RecordIdBadge-CGxPR-8q.js} +1 -4
  7. package/dist-lib/{RefreshControl-C-8UCyau.js → RefreshControl-CV8nGACW.js} +120 -122
  8. package/dist-lib/{SmartDetailPage.impl-DWjNQ052.js → SmartDetailPage.impl-DWprVNMb.js} +376 -377
  9. package/dist-lib/{SmartListPage.impl-yKBK7a8b.js → SmartListPage.impl-BwWURGwa.js} +1098 -1099
  10. package/dist-lib/{SmartRecordListPage.impl-DRpU_DOC.js → SmartRecordListPage.impl-BKKBShAg.js} +183 -183
  11. package/dist-lib/{SortHeaderMenu-CbihbEGd.js → SortHeaderMenu-pgi4sxMs.js} +1 -1
  12. package/dist-lib/{action-dispatch-C28UhXXA.js → action-dispatch-DlHTYag7.js} +382 -382
  13. package/dist-lib/api/events.d.ts +27 -5
  14. package/dist-lib/{cardProjection-Bp_ZPLUE.js → cardProjection-C7Orz841.js} +146 -204
  15. package/dist-lib/components/pages/DocumentsMenu.d.ts +1 -1
  16. package/dist-lib/components/pages/RecordDocumentsPanel.d.ts +2 -2
  17. package/dist-lib/components/pages/list/useListQuery.d.ts +6 -1
  18. package/dist-lib/components/shared/RefreshControl.d.ts +7 -1
  19. package/dist-lib/components/shared/useOwnRefresh.d.ts +9 -0
  20. package/dist-lib/{field-classification-CeYJlsNq.js → field-classification-EY8CFF3P.js} +301 -320
  21. package/dist-lib/{format-count-C3N-WxEy.js → format-count-BHkaDr9V.js} +245 -245
  22. package/dist-lib/hooks/useMutations.d.ts +1 -1
  23. package/dist-lib/hooks/useSSE.d.ts +24 -4
  24. package/dist-lib/index.js +1541 -1832
  25. package/dist-lib/lib/document-templates.d.ts +1 -1
  26. package/dist-lib/lib/realtime-reconcile.d.ts +43 -0
  27. package/dist-lib/{peekDraftStore-D3sowXga.js → peekDraftStore-1pIajluX.js} +36 -36
  28. package/dist-lib/{registry-p6CejATt.js → registry-C5ug25M8.js} +507 -507
  29. package/dist-lib/stores/realtime.d.ts +20 -0
  30. package/dist-lib/testing.js +35 -35
  31. package/dist-lib/{useCurrentScreen-74x5yJNb.js → useCurrentScreen-BdnZq8vZ.js} +2504 -1557
  32. package/dist-lib/{useListQuery-D75bgLLz.js → useListQuery-BxgrPZIB.js} +13 -10
  33. package/dist-lib/{useProperties-C5fZp12D.js → useProperties-Bhi9Wn5O.js} +25 -25
  34. package/dist-lib/useTabSearchMirror-Dl5x0xKu.js +177 -0
  35. package/dist-lib/{value-DKekzcjz.js → value-Rp-5W3o8.js} +25 -25
  36. package/package.json +7 -7
  37. package/dist-lib/useTabSearchMirror-D_wzoYRz.js +0 -406
@@ -1,406 +0,0 @@
1
- import { Dn as e, Gt as t, Kt as n, bt as r, mn as i, pn as a, pt as o, zn as s } from "./useCurrentScreen-74x5yJNb.js";
2
- import { F as c } from "./field-classification-CeYJlsNq.js";
3
- import { useEffect as l, useLayoutEffect as u, useMemo as d } from "react";
4
- import { useSearchParams as f } from "react-router";
5
- import { useInfiniteQuery as p, useQueryClient as m } from "@tanstack/react-query";
6
- //#region src/api/entities.ts
7
- function h(e, t) {
8
- return e.$statuses?.find((e) => e.group_code === t);
9
- }
10
- function g(e, t) {
11
- return e.$properties?.find((e) => e.property_code === t);
12
- }
13
- function _(e) {
14
- let t = { ...e };
15
- return t.$status = (e) => h(t, e), t.$property = (e) => g(t, e), t;
16
- }
17
- var v = class {
18
- cache = {};
19
- merge(e) {
20
- if (e) for (let t of Object.keys(e)) {
21
- this.cache[t] || (this.cache[t] = {});
22
- let n = e[t];
23
- for (let e of Object.keys(n)) this.cache[t][e] = {
24
- ...this.cache[t][e],
25
- ...n[e]
26
- };
27
- }
28
- }
29
- all() {
30
- return this.cache;
31
- }
32
- get(e, t) {
33
- return this.cache[e]?.[t];
34
- }
35
- clear() {
36
- this.cache = {};
37
- }
38
- };
39
- function y(e, t) {
40
- let n = new URL(`/api/data/${e}`, window.location.origin);
41
- return t.select && t.select.length > 0 && n.searchParams.set("select", t.select.join(",")), t.expand && t.expand.length > 0 && n.searchParams.set("expand", t.expand.join(",")), t.sort && n.searchParams.set("sort", t.sort), t.search && n.searchParams.set("search", t.search), t.limit && n.searchParams.set("limit", String(t.limit)), t.after && n.searchParams.set("after", t.after), t.count && n.searchParams.set("count", "with"), t.screen && n.searchParams.set("screen", t.screen), t.preview && n.searchParams.set("preview", "true"), t.include_deleted && n.searchParams.set("include_deleted", "true"), t.filters && t.filters.length > 0 && n.searchParams.set("filters", JSON.stringify(t.filters)), n.pathname + n.search;
42
- }
43
- var b = class {
44
- entity;
45
- refs;
46
- constructor(e, t) {
47
- this.entity = e, this.refs = t ?? new v();
48
- }
49
- async get(e) {
50
- let n = new URLSearchParams(typeof e == "string" ? { id: e } : e);
51
- return _((await t(`/api/data/${this.entity}?${n.toString()}`)).data);
52
- }
53
- async list(e = {}) {
54
- let n, r = !1;
55
- try {
56
- n = await t(y(this.entity, e));
57
- } catch (a) {
58
- if (e.after && i(a)) {
59
- let { after: i, ...a } = e;
60
- n = await t(y(this.entity, a)), r = !0;
61
- } else throw a;
62
- }
63
- return this.refs.merge(n.$refs), {
64
- data: n.data.map((e) => _(e)),
65
- meta: n.meta,
66
- $refs: this.refs.all(),
67
- reset: r
68
- };
69
- }
70
- async create(e) {
71
- return (await this.createMany([e]))[0];
72
- }
73
- async createMany(e) {
74
- if (e.length === 0) return [];
75
- let t = e.map((e) => ({
76
- action: `${this.entity}.__create`,
77
- params: {
78
- entity: this.entity,
79
- fields: e
80
- }
81
- })), r = await n("system.batch", {
82
- actions: t,
83
- atomic: !0
84
- });
85
- return x(r, `${this.entity}.__create`), r.results.map((e) => _(S(e)));
86
- }
87
- async update(e, t) {
88
- return (await this.updateMany([{
89
- id: e,
90
- ...t
91
- }]))[0];
92
- }
93
- async updateMany(e) {
94
- if (e.length === 0) return [];
95
- let t = e.map(({ id: e, ...t }) => ({
96
- action: `${this.entity}.__update`,
97
- params: {
98
- object_ids: [e],
99
- entity: this.entity,
100
- fields: t
101
- }
102
- })), r = await n("system.batch", {
103
- actions: t,
104
- atomic: !0
105
- });
106
- return x(r, `${this.entity}.__update`), r.results.map((e) => _(S(e)));
107
- }
108
- async delete(e) {
109
- await this.deleteMany([e]);
110
- }
111
- async deleteMany(e) {
112
- return e.length === 0 ? { count: 0 } : { count: (await r(`${this.entity}.__delete`, {
113
- object_ids: e,
114
- entity: this.entity
115
- })).object_count ?? e.length };
116
- }
117
- async restore(e) {
118
- await this.restoreMany([e]);
119
- }
120
- async restoreMany(e) {
121
- return e.length === 0 ? { count: 0 } : { count: (await r(`${this.entity}.__restore`, {
122
- object_ids: e,
123
- entity: this.entity
124
- })).object_count ?? e.length };
125
- }
126
- async upsert(e, t) {
127
- return (await this.upsertMany([e], t))[0];
128
- }
129
- async upsertMany(e, t) {
130
- if (e.length === 0) return [];
131
- let r = e.map((e) => ({
132
- action: `${this.entity}.__upsert`,
133
- params: {
134
- entity: this.entity,
135
- fields: e,
136
- unique_by: t
137
- }
138
- })), i = await n("system.batch", {
139
- actions: r,
140
- atomic: !0
141
- });
142
- return x(i, `${this.entity}.__upsert`), i.results.map((e) => _(C(e)));
143
- }
144
- };
145
- function x(e, t) {
146
- if (e.committed) return;
147
- let n = e.results.find((e) => !e.ok), r = n?.error ? `${a(n.error.type)}: ${n.error.title}` : "batch did not commit";
148
- throw Error(`${t} batch failed: ${r}`);
149
- }
150
- function S(e) {
151
- let t = e.result ?? {};
152
- return (Array.isArray(t.rows) ? t.rows[0] : void 0) ?? {};
153
- }
154
- function C(e) {
155
- let t = e.result ?? {};
156
- return (Array.isArray(t.rows) ? t.rows[0] : void 0)?.row ?? {};
157
- }
158
- function w(e, t) {
159
- return new b(e, t);
160
- }
161
- //#endregion
162
- //#region src/hooks/useCursorEntityData.ts
163
- var T = "entity-data-cursor";
164
- function E(e) {
165
- return JSON.stringify({
166
- sort: e.sort,
167
- filters: e.filters,
168
- search: e.search,
169
- select: e.select,
170
- expand: e.expand,
171
- includeDeleted: e.includeDeleted,
172
- screen: e.screen,
173
- preview: e.preview,
174
- limit: e.limit
175
- });
176
- }
177
- function D(e, t) {
178
- return [
179
- T,
180
- e,
181
- E(t)
182
- ];
183
- }
184
- function O(e, t, n) {
185
- let r = m(), i = d(() => new b(e ?? ""), [e]), a = d(() => E(t), [t]), o = d(() => [
186
- T,
187
- e,
188
- a
189
- ], [e, a]), s = p({
190
- queryKey: o,
191
- queryFn: ({ pageParam: e }) => i.list({
192
- sort: t.sort,
193
- filters: t.filters,
194
- search: t.search,
195
- select: t.select,
196
- expand: t.expand,
197
- include_deleted: t.includeDeleted || void 0,
198
- screen: t.screen,
199
- preview: t.preview,
200
- limit: t.limit,
201
- after: e ?? void 0,
202
- count: !e || void 0
203
- }),
204
- getNextPageParam: (e) => e.meta?.has_more ? e.meta.cursor : void 0,
205
- initialPageParam: void 0,
206
- enabled: !!e && n,
207
- placeholderData: (t, n) => n?.queryKey?.[1] === e ? t : void 0
208
- }), c = s.data?.pages, u = c && c.length > 1 ? c[c.length - 1]?.reset : !1;
209
- l(() => {
210
- u && r.resetQueries({ queryKey: o });
211
- }, [
212
- u,
213
- r,
214
- o
215
- ]);
216
- let f = d(() => (s.data?.pages ?? []).flatMap((e) => e.data), [s.data?.pages]), h = s.data?.pages?.[0]?.meta;
217
- return {
218
- rows: f,
219
- refs: s.data?.pages?.[s.data.pages.length - 1]?.$refs,
220
- total: h && !h.count_unknown ? h.total : void 0,
221
- countMode: h?.count_mode,
222
- countUnknown: h?.count_unknown ?? !1,
223
- hasMore: s.hasNextPage,
224
- fetchNextPage: s.fetchNextPage,
225
- isFetchingNextPage: s.isFetchingNextPage,
226
- isLoading: s.isLoading,
227
- isFetching: s.isFetching,
228
- isError: s.isError,
229
- error: s.error,
230
- refetch: s.refetch
231
- };
232
- }
233
- //#endregion
234
- //#region src/lib/filters.ts
235
- var k = /* @__PURE__ */ new Set([
236
- "is_empty",
237
- "is_not_empty",
238
- "today",
239
- "this_week",
240
- "this_month",
241
- "last_7_days",
242
- "last_30_days",
243
- "last_hour",
244
- "last_24_hours"
245
- ]), A = /* @__PURE__ */ new Set(["in", "not_in"]), j = {
246
- eq: "is",
247
- not_eq: "is not",
248
- gt: ">",
249
- gte: ">=",
250
- lt: "<",
251
- lte: "<=",
252
- in: "is any of",
253
- not_in: "is none of",
254
- between: "between",
255
- contains: "contains",
256
- starts_with: "starts with",
257
- is_empty: "is empty",
258
- is_not_empty: "is not empty",
259
- today: "today",
260
- this_week: "this week",
261
- this_month: "this month",
262
- last_7_days: "last 7 days",
263
- last_30_days: "last 30 days",
264
- last_hour: "last hour",
265
- last_24_hours: "last 24 hours"
266
- };
267
- function M(e) {
268
- let t = e.get("filters");
269
- if (t == null || t === "") return {
270
- filters: [],
271
- error: null
272
- };
273
- try {
274
- return {
275
- filters: N(e),
276
- error: null
277
- };
278
- } catch (e) {
279
- return {
280
- filters: [],
281
- error: e instanceof Error ? e.message : "The filters URL value is invalid."
282
- };
283
- }
284
- }
285
- function N(e) {
286
- let t = e.get("filters");
287
- if (t == null || t === "") return [];
288
- let n;
289
- try {
290
- n = JSON.parse(t);
291
- } catch {
292
- throw Error("The filters URL value is not valid JSON.");
293
- }
294
- if (!Array.isArray(n) || !n.every(V)) throw Error("The filters URL value is not a valid filter tree.");
295
- return n;
296
- }
297
- function P(e, t) {
298
- e.length === 0 ? t.delete("filters") : t.set("filters", JSON.stringify(e));
299
- }
300
- function F(e) {
301
- return e.some((e) => !e || typeof e != "object" ? !1 : e.or != null || e.and != null && F(e.and));
302
- }
303
- function I(e) {
304
- let t = [];
305
- for (let n of e) !n || typeof n != "object" || (n.field && n.op && t.push(n), n.or && t.push(...I(n.or)), n.and && t.push(...I(n.and)));
306
- return t;
307
- }
308
- function L(e) {
309
- return I(e).length;
310
- }
311
- function R(e, t) {
312
- if (!e.field || !e.op) return "";
313
- let n = j[e.op] || e.op;
314
- if (k.has(e.op)) return `${n}`;
315
- let r = e.field, i = (e) => {
316
- if (t) {
317
- let n = t(r, e);
318
- return n.label != null && (n.status === "special" || n.status === "resolved") ? n.label : n.raw;
319
- }
320
- return s(e);
321
- };
322
- return `${n} ${Array.isArray(e.value) ? e.value.map(i).join(", ") : i(e.value)}`;
323
- }
324
- function z(e, t) {
325
- return {
326
- field: e,
327
- op: "eq",
328
- value: t
329
- };
330
- }
331
- function B(e, t) {
332
- let n = [];
333
- for (let r of e) if (!(!r || typeof r != "object") && r.field !== t) {
334
- if (r.or) {
335
- let e = B(r.or, t);
336
- e.length > 0 && n.push({
337
- ...r,
338
- or: e
339
- });
340
- continue;
341
- }
342
- if (r.and) {
343
- let e = B(r.and, t);
344
- e.length > 0 && n.push({
345
- ...r,
346
- and: e
347
- });
348
- continue;
349
- }
350
- n.push(r);
351
- }
352
- return n;
353
- }
354
- function V(e) {
355
- if (typeof e != "object" || !e || Array.isArray(e)) return !1;
356
- let t = e, n = Object.prototype.hasOwnProperty.call(t, "field"), r = Object.prototype.hasOwnProperty.call(t, "op"), i = Object.prototype.hasOwnProperty.call(t, "value"), a = Object.prototype.hasOwnProperty.call(t, "or"), o = Object.prototype.hasOwnProperty.call(t, "and");
357
- if (a && o) return !1;
358
- if (a || o) {
359
- if (n || r || i) return !1;
360
- let e = a ? t.or : t.and;
361
- return Array.isArray(e) && e.length > 0 && e.every(V);
362
- }
363
- if (!(n && r && typeof t.field == "string" && t.field.length > 0 && typeof t.op == "string" && H.has(t.op))) return !1;
364
- let s = t.op;
365
- return k.has(s) ? !i || t.value === null : i && t.value !== null;
366
- }
367
- var H = new Set(Object.keys(j));
368
- //#endregion
369
- //#region src/hooks/useRegisterScreenTab.ts
370
- function U(e, t, n, r) {
371
- let i = o();
372
- l(() => {
373
- !e || i.enabled || c.getState().openTab({
374
- pathname: e,
375
- search: r,
376
- title: t,
377
- icon: n,
378
- closable: !0
379
- });
380
- }, [
381
- e,
382
- t,
383
- n,
384
- i.enabled
385
- ]);
386
- }
387
- function W(t, n, r) {
388
- let i = t?.route, a = n ? e(t?.display?.name) || e(n.display.name_plural) : "", o = t?.display?.icon || n?.display.icon;
389
- U(n ? i : void 0, a, o, r);
390
- }
391
- //#endregion
392
- //#region src/hooks/useTabSearchMirror.ts
393
- function G(e) {
394
- let t = o(), [n] = f();
395
- u(() => {
396
- if (!e || t.enabled) return;
397
- let r = c.getState(), i = r.findTabByPathname(e);
398
- i && r.updateTabSearch(i.id, n.toString());
399
- }, [
400
- n,
401
- e,
402
- t.enabled
403
- ]);
404
- }
405
- //#endregion
406
- export { w as S, D as _, k as a, b, z as c, F as d, M as f, T as g, P as h, A as i, I as l, B as m, W as n, j as o, N as p, U as r, L as s, G as t, R as u, E as v, v as x, O as y };