@declarion/react 0.80.0 → 0.82.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 (28) hide show
  1. package/dist-lib/components/actions/ObjectActionBar.js +56 -54
  2. package/dist-lib/components/actions/PropertyGridEditor.js +56 -53
  3. package/dist-lib/components/actions/RowActionsKebab.js +51 -49
  4. package/dist-lib/components/detail-layout/AssociatedBlock.js +385 -383
  5. package/dist-lib/components/list/QuickPeek.js +77 -75
  6. package/dist-lib/components/pages/SmartDetailPage.impl.js +484 -458
  7. package/dist-lib/components/pages/SmartRecordListPage.impl.js +207 -206
  8. package/dist-lib/components/pages/list/DataCell.js +15 -15
  9. package/dist-lib/components/pages/list/ListFloatbar.js +55 -53
  10. package/dist-lib/components/pages/list/ListHeader.js +54 -52
  11. package/dist-lib/components/pages/list/ListTable.js +64 -64
  12. package/dist-lib/components/pages/list/cardProjection.js +85 -80
  13. package/dist-lib/components/pages/list/column-sizing.js +11 -1
  14. package/dist-lib/components/pages/list/use-filter-value-labels.js +29 -78
  15. package/dist-lib/components/pages/list/useListRowInteraction.js +78 -76
  16. package/dist-lib/components/pages/list/useRowMenu.js +60 -58
  17. package/dist-lib/components/pages/tenant-params/TenantParamsPage.impl.js +341 -262
  18. package/dist-lib/components/params/ParamsBlock.js +59 -59
  19. package/dist-lib/components/params/param-editors.js +114 -99
  20. package/dist-lib/components/shared/ConfirmDialog.js +33 -66
  21. package/dist-lib/components/shared/ModalFrame.js +53 -0
  22. package/dist-lib/hooks/useRefRecords.js +73 -0
  23. package/dist-lib/hooks/useRowTenant.js +12 -0
  24. package/dist-lib/index.d.ts +4 -3
  25. package/dist-lib/lib/actions.js +105 -89
  26. package/dist-lib/lib/mass-edit.js +13 -13
  27. package/dist-lib/types/schema.js +29 -22
  28. package/package.json +1 -1
@@ -1,120 +1,122 @@
1
1
  import { coerceDisplayString as e } from "../../../lib/display-value.js";
2
- import { buildEntityDetailHref as t, extractPkValues as n, fieldDisplayName as r, getDisplayValue as i, pkValuesToDetailId as a } from "../../../types/schema.js";
3
- import { useText as o } from "../../../hooks/useText.js";
4
- import { buildActionBody as s, executeAction as c } from "../../../api/data.js";
5
- import { resolveSchemaFieldLabel as l } from "../../file-widgets/host.js";
6
- import { effectiveScreenForRecord as u } from "../../../lib/variants.js";
7
- import { setPeekDraft as d } from "../../list/peekDraftStore.js";
8
- import { resolveQuickPeekFieldNames as f } from "./cardProjection.js";
9
- import { rowSelectionKey as p } from "./useListSelection.js";
10
- import { classifyRowClick as m, isInteractiveRowTarget as h } from "../../../lib/rowClickGesture.js";
11
- import { useLongPress as g } from "../../../hooks/useLongPress.js";
12
- import { useCallback as _, useEffect as v, useMemo as y, useRef as b, useState as x } from "react";
2
+ import { buildEntityDetailHref as t, extractPkValues as n, fieldDisplayName as r, getDisplayValue as i, pkValuesToDetailId as a, rowSetInTenant as o } from "../../../types/schema.js";
3
+ import { useText as s } from "../../../hooks/useText.js";
4
+ import { buildActionBody as c, executeAction as l } from "../../../api/data.js";
5
+ import { resolveSchemaFieldLabel as u } from "../../file-widgets/host.js";
6
+ import { useRowTenant as d } from "../../../hooks/useRowTenant.js";
7
+ import { effectiveScreenForRecord as f } from "../../../lib/variants.js";
8
+ import { setPeekDraft as p } from "../../list/peekDraftStore.js";
9
+ import { resolveQuickPeekFieldNames as m } from "./cardProjection.js";
10
+ import { rowSelectionKey as h } from "./useListSelection.js";
11
+ import { classifyRowClick as g, isInteractiveRowTarget as _ } from "../../../lib/rowClickGesture.js";
12
+ import { useLongPress as v } from "../../../hooks/useLongPress.js";
13
+ import { useCallback as y, useEffect as b, useMemo as x, useRef as S, useState as C } from "react";
13
14
  //#region src/components/pages/list/useListRowInteraction.ts
14
- function S({ entity: S, screen: C, screens: w, entities: T, searchParams: E, tabNavigate: D, commitScreenTabSearch: O, isPhone: k, canUpdate: A }) {
15
- let j = o(), [M, N] = x(null), [P, F] = x(null), I = b(null), L = b(null);
16
- v(() => () => {
17
- L.current && clearTimeout(L.current.timer);
15
+ function w({ entity: w, screen: T, screens: E, entities: D, searchParams: O, tabNavigate: k, commitScreenTabSearch: A, isPhone: j, canUpdate: M }) {
16
+ let N = s(), P = d(w), [F, I] = C(null), [L, R] = C(null), z = S(null), B = S(null);
17
+ b(() => () => {
18
+ B.current && clearTimeout(B.current.timer);
18
19
  }, []);
19
- let R = C?.on_row_click === "peek" && C.quick_peek?.enabled !== !1 && !k, z = _((e, r) => {
20
- if (!S || !C) return;
21
- let o = n(S, e), s = a(S, o), c = t(C, S, w, o);
20
+ let V = T?.on_row_click === "peek" && T.quick_peek?.enabled !== !1 && !j, H = y((e, r) => {
21
+ if (!w || !T) return;
22
+ let o = n(w, e), s = a(w, o), c = t(T, w, E, o);
22
23
  if (!c) return;
23
24
  if (r?.draft) {
24
- d(s, r.draft);
25
+ p(s, r.draft);
25
26
  let [e, t] = c.split("?", 2), n = new URLSearchParams(t ?? "");
26
27
  n.set("edit", "true"), c = `${e}?${n.toString()}`;
27
28
  }
28
- let l = i(j, e, S) ?? j(S.display.name), u = C.display?.icon || S.display.icon;
29
- O(E.toString()), D(c, {
29
+ let l = i(N, e, w) ?? N(w.display.name), u = T.display?.icon || w.display.icon;
30
+ A(O.toString()), k(c, {
30
31
  title: l,
31
32
  icon: u
32
33
  });
33
34
  }, [
34
- j,
35
- S,
36
- C,
35
+ N,
37
36
  w,
37
+ T,
38
38
  E,
39
- D,
40
- O
41
- ]), B = g(_((e) => {
42
- let t = I.current;
43
- t && F({
39
+ O,
40
+ k,
41
+ A
42
+ ]), U = v(y((e) => {
43
+ let t = z.current;
44
+ t && R({
44
45
  x: e.x,
45
46
  y: e.y,
46
47
  row: t
47
48
  });
48
- }, [])), V = _((e, t) => {
49
- if (B.consumePressFired() || h(e.target)) return;
50
- if (!R || !S) {
51
- z(t);
49
+ }, [])), W = y((e, t) => {
50
+ if (U.consumePressFired() || _(e.target)) return;
51
+ if (!V || !w) {
52
+ H(t);
52
53
  return;
53
54
  }
54
- let n = p(S, t);
55
- if (m(L.current, n) === "double") {
56
- clearTimeout(L.current.timer), L.current = null, N(null), z(t);
55
+ let n = h(w, t);
56
+ if (g(B.current, n) === "double") {
57
+ clearTimeout(B.current.timer), B.current = null, I(null), H(t);
57
58
  return;
58
59
  }
59
- L.current && clearTimeout(L.current.timer);
60
+ B.current && clearTimeout(B.current.timer);
60
61
  let r = setTimeout(() => {
61
- L.current = null, N(t);
62
+ B.current = null, I(t);
62
63
  }, 250);
63
- L.current = {
64
+ B.current = {
64
65
  rowId: n,
65
66
  timer: r
66
67
  };
67
68
  }, [
68
- S,
69
- R,
70
- z,
71
- B
69
+ w,
70
+ V,
71
+ H,
72
+ U
72
73
  ]);
73
74
  return {
74
- peekAllowed: R,
75
- peekRow: M,
76
- setPeekRow: N,
77
- peekFields: y(() => {
78
- if (!R || !S || !M) return [];
79
- let e = u(S, C, M);
80
- return f(S, e, w).map((e) => {
81
- if (S.files?.get(e)) return {
75
+ peekAllowed: V,
76
+ peekRow: F,
77
+ setPeekRow: I,
78
+ peekFields: x(() => {
79
+ if (!V || !w || !F) return [];
80
+ let e = f(w, T, F), t = M && o(w, F, P.tenantId);
81
+ return m(w, e, E).map((e) => {
82
+ if (w.files?.get(e)) return {
82
83
  key: e,
83
- label: l(j, S, e, T),
84
+ label: u(N, w, e, D),
84
85
  kind: "file",
85
- readOnly: !A
86
+ readOnly: !t
86
87
  };
87
- let t = S.fields.get(e), n = A && !t.primary && !t.auto && !t.ref && t.files?.mode !== "rich_text_inline";
88
+ let n = w.fields.get(e), i = t && !n.primary && !n.auto && !n.ref && n.files?.mode !== "rich_text_inline";
88
89
  return {
89
90
  key: e,
90
- label: r(j, t, e, T),
91
+ label: r(N, n, e, D),
91
92
  kind: "field",
92
- field: t,
93
- readOnly: !n
93
+ field: n,
94
+ readOnly: !i
94
95
  };
95
96
  });
96
97
  }, [
97
- j,
98
- R,
99
- M,
100
- S,
101
- C,
102
- T,
98
+ N,
99
+ V,
100
+ F,
103
101
  w,
104
- A
102
+ T,
103
+ D,
104
+ E,
105
+ M,
106
+ P
105
107
  ]),
106
- peekActions: y(() => S?.actions ?? {}, [S?.actions]),
107
- peekExecute: _(async (t, n, r) => {
108
- let i = S?.fields.names().find((e) => S.fields.get(e)?.primary), a = i && M ? [e(M[i])] : void 0, o = n.entity ? `${n.entity}.${t}` : t;
109
- return c(o, s(r, a));
110
- }, [S, M]),
111
- contextMenu: P,
112
- setContextMenu: F,
113
- pressedRow: I,
114
- longPress: B,
115
- onRowClick: V,
116
- navigateToDetail: z
108
+ peekActions: x(() => w?.actions ?? {}, [w?.actions]),
109
+ peekExecute: y(async (t, n, r) => {
110
+ let i = w?.fields.names().find((e) => w.fields.get(e)?.primary), a = i && F ? [e(F[i])] : void 0, o = n.entity ? `${n.entity}.${t}` : t;
111
+ return l(o, c(r, a));
112
+ }, [w, F]),
113
+ contextMenu: L,
114
+ setContextMenu: R,
115
+ pressedRow: z,
116
+ longPress: U,
117
+ onRowClick: W,
118
+ navigateToDetail: H
117
119
  };
118
120
  }
119
121
  //#endregion
120
- export { S as useListRowInteraction };
122
+ export { w as useListRowInteraction };
@@ -5,16 +5,17 @@ import { buildActionBody as r, executeAction as i } from "../../../api/data.js";
5
5
  import { PEEK_ACTION_CODE as a, applyRowState as o, defaultFlatForSlot as s, filterLayoutForSlot as c } from "../../../lib/actions.js";
6
6
  import { useActionRunner as l } from "../../actions/ActionRunner.js";
7
7
  import { dispatchAction as u } from "../../../lib/action-dispatch.js";
8
- import { effectiveScreenForRecord as d, variantActionCodesForRecord as f } from "../../../lib/variants.js";
9
- import { useCallback as p, useMemo as m } from "react";
8
+ import { useRowTenant as d } from "../../../hooks/useRowTenant.js";
9
+ import { effectiveScreenForRecord as f, variantActionCodesForRecord as p } from "../../../lib/variants.js";
10
+ import { useCallback as m, useMemo as h } from "react";
10
11
  //#region src/components/pages/list/useRowMenu.ts
11
- function h(e, t) {
12
+ function g(e, t) {
12
13
  let n = (e) => e === "__peek" && !t.peek || e === "__open" && !t.open, r = [];
13
14
  for (let i of e) if (i.kind === "action") {
14
15
  if (n(i.code)) continue;
15
16
  r.push(i);
16
17
  } else {
17
- let e = h(i.items, t);
18
+ let e = g(i.items, t);
18
19
  e.length > 0 && r.push({
19
20
  ...i,
20
21
  items: e
@@ -22,85 +23,86 @@ function h(e, t) {
22
23
  }
23
24
  return r;
24
25
  }
25
- function g(e, t) {
26
+ function _(e, t) {
26
27
  for (let n of e) if (n.kind === "action") {
27
28
  if (n.code === t) return !0;
28
- } else if (g(n.items, t)) return !0;
29
+ } else if (_(n.items, t)) return !0;
29
30
  return !1;
30
31
  }
31
- function _({ row: _, rowId: v, screen: y, fullScreen: b, entity: x, entityCode: S, rowActions: C, tabNavigate: w, peekAllowed: T, hasDetailTarget: E, onPeek: D }) {
32
- let O = n(), k = n("errors"), { run: A } = l(), { data: j } = t(), M = b.detail_screen === void 0 && y.detail_screen !== void 0 ? {
33
- ...b,
34
- detail_screen: y.detail_screen
35
- } : b, N = d(x, M, _) ?? M, P = m(() => {
36
- let e = {}, t = N.row_actions === void 0 ? void 0 : new Set(N.row_actions);
37
- for (let { code: n, action: r } of C) (!t || t.has(n)) && (e[n] = r);
32
+ function v({ row: v, rowId: y, screen: b, fullScreen: x, entity: S, entityCode: C, rowActions: w, tabNavigate: T, peekAllowed: E, hasDetailTarget: D, onPeek: O }) {
33
+ let k = n(), A = d(S), j = n("errors"), { run: M } = l(), { data: N } = t(), P = x.detail_screen === void 0 && b.detail_screen !== void 0 ? {
34
+ ...x,
35
+ detail_screen: b.detail_screen
36
+ } : x, F = f(S, P, v) ?? P, I = h(() => {
37
+ let e = {}, t = F.row_actions === void 0 ? void 0 : new Set(F.row_actions);
38
+ for (let { code: n, action: r } of w) (!t || t.has(n)) && (e[n] = r);
38
39
  return e;
39
- }, [C, N.row_actions]), F = m(() => ({
40
- entity: x,
41
- entityCode: S ?? "",
42
- screen: N,
43
- screenRoute: N.route,
40
+ }, [w, F.row_actions]), L = h(() => ({
41
+ entity: S,
42
+ entityCode: C ?? "",
43
+ screen: F,
44
+ screenRoute: F.route,
44
45
  selectedRows: [],
45
46
  selectedIds: [],
46
- t: O,
47
- tabNavigate: (e, t) => w(e, {
47
+ t: k,
48
+ tabNavigate: (e, t) => T(e, {
48
49
  title: t?.title,
49
50
  icon: t?.icon,
50
51
  search: t?.search
51
52
  }),
52
53
  runActionApi: (e, t) => i(e, t),
53
- openPeek: (e) => D(e ?? _),
54
- recordHref: (t) => e(N, t, x, j?.screens)
54
+ openPeek: (e) => O(e ?? v),
55
+ recordHref: (t) => e(F, t, S, N?.screens)
55
56
  }), [
56
- x,
57
57
  S,
58
- N,
58
+ C,
59
+ F,
60
+ k,
61
+ T,
59
62
  O,
60
- w,
61
- D,
62
- _,
63
- j?.screens
64
- ]), I = m(() => {
65
- let e = N.action_layout ?? null, t = x.action_layout ?? null, n = e ?? t ?? s(P, "list_row");
66
- return c(n, P, void 0, "list_row");
63
+ v,
64
+ N?.screens
65
+ ]), R = h(() => {
66
+ let e = F.action_layout ?? null, t = S.action_layout ?? null, n = e ?? t ?? s(I, "list_row");
67
+ return c(n, I, void 0, "list_row");
67
68
  }, [
68
- N,
69
- x,
70
- P
71
- ]), L = m(() => h(o(O, I, P, void 0, _, [], f(x, _)), {
72
- peek: T,
73
- open: E
69
+ F,
70
+ S,
71
+ I
72
+ ]), z = h(() => g(o(k, R, I, void 0, v, [], A, p(S, v)), {
73
+ peek: E,
74
+ open: D
74
75
  }), [
75
- O,
76
+ k,
77
+ R,
76
78
  I,
77
- P,
78
- _,
79
- x,
80
- T,
81
- E
79
+ v,
80
+ S,
81
+ E,
82
+ D,
83
+ A
82
84
  ]);
83
85
  return {
84
- layout: L,
85
- entityActions: P,
86
- runRowAction: p((e, t) => {
87
- let n = u(k, e, t, { row: _ });
88
- if (n !== null) return A({
86
+ layout: z,
87
+ entityActions: I,
88
+ runRowAction: m((e, t) => {
89
+ let n = u(j, e, t, { row: v });
90
+ if (n !== null) return M({
89
91
  action: t,
90
- title: O(t.display?.name) || e,
91
- row: _,
92
- execute: (e) => i(n, r(e, [v]))
92
+ title: k(t.display?.name) || e,
93
+ row: v,
94
+ execute: (e) => i(n, r(e, [y]))
93
95
  });
94
96
  }, [
95
- O,
96
97
  k,
97
- A,
98
- v,
99
- _
98
+ j,
99
+ M,
100
+ y,
101
+ v
100
102
  ]),
101
- widgetContext: F,
102
- hasPeek: m(() => g(L, a), [L])
103
+ widgetContext: L,
104
+ hasPeek: h(() => _(z, a), [z])
103
105
  };
104
106
  }
105
107
  //#endregion
106
- export { _ as useRowMenu };
108
+ export { v as useRowMenu };