@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
@@ -0,0 +1,53 @@
1
+ import { useEffect as e, useRef as t } from "react";
2
+ import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
3
+ import { createPortal as a } from "react-dom";
4
+ //#region src/components/shared/ModalFrame.tsx
5
+ function o({ label: o, maxWidth: s, onClose: c, children: l, testId: u }) {
6
+ let d = t(null);
7
+ return e(() => {
8
+ d.current?.focus();
9
+ }, []), a(/* @__PURE__ */ i(n, { children: [/* @__PURE__ */ r("div", {
10
+ onClick: c,
11
+ style: {
12
+ position: "fixed",
13
+ inset: 0,
14
+ background: "var(--scrim)",
15
+ zIndex: 60,
16
+ backdropFilter: "blur(2px)"
17
+ }
18
+ }), /* @__PURE__ */ r("div", {
19
+ ref: d,
20
+ role: "dialog",
21
+ "aria-modal": "true",
22
+ "aria-label": o,
23
+ tabIndex: -1,
24
+ "data-testid": u,
25
+ onKeyDown: (e) => {
26
+ e.key === "Escape" && c();
27
+ },
28
+ style: {
29
+ position: "fixed",
30
+ top: "50%",
31
+ left: "50%",
32
+ transform: "translate(-50%, -50%)",
33
+ zIndex: 61,
34
+ width: "calc(100vw - 24px)",
35
+ maxWidth: s,
36
+ maxHeight: "calc(var(--app-height) - var(--safe-area-top) - var(--safe-area-bottom) - 16px)",
37
+ background: "var(--surface)",
38
+ borderRadius: "var(--radius-lg)",
39
+ boxShadow: "var(--shadow-lg)",
40
+ border: "1px solid var(--border)",
41
+ overflow: "hidden",
42
+ display: "flex",
43
+ flexDirection: "column",
44
+ outline: "none",
45
+ whiteSpace: "normal",
46
+ overflowWrap: "anywhere",
47
+ textAlign: "left"
48
+ },
49
+ children: l
50
+ })] }), document.body);
51
+ }
52
+ //#endregion
53
+ export { o as ModalFrame };
@@ -0,0 +1,73 @@
1
+ import { coerceDisplayString as e } from "../lib/display-value.js";
2
+ import { getPrimaryKeyFields as t, resolveRefRecordLabel as n } from "../types/schema.js";
3
+ import { listEntities as r } from "../api/data.js";
4
+ import { useQueries as i } from "@tanstack/react-query";
5
+ //#region src/hooks/useRefRecords.ts
6
+ var a = 200;
7
+ function o(e, n) {
8
+ let r = n?.[e.entity];
9
+ return e.field || (r ? t(r)[0] : "id") || "id";
10
+ }
11
+ function s(t, r, i, a, o) {
12
+ let s = e(a), c = r[i.entity]?.[s];
13
+ if (!c) return;
14
+ let l = i.display?.field ?? o?.[i.entity]?.display?.display_field;
15
+ return n(t, c, l, s);
16
+ }
17
+ function c(t, n, s) {
18
+ let c = /* @__PURE__ */ new Map();
19
+ for (let { ref: r, value: i } of t) {
20
+ let t = e(i);
21
+ if (!t || n?.[r.entity]?.[t]) continue;
22
+ let a = o(r, s), l = `${r.entity}::${a}`, u = c.get(l);
23
+ u || (u = {
24
+ key: l,
25
+ entity: r.entity,
26
+ lookupField: a,
27
+ values: []
28
+ }, c.set(l, u)), u.values.includes(t) || u.values.push(t);
29
+ }
30
+ let l = [...c.values()];
31
+ for (let e of l) e.values.sort();
32
+ l.sort((e, t) => e.key.localeCompare(t.key));
33
+ let u = i({ queries: l.map((e) => {
34
+ let t = {
35
+ per_page: a,
36
+ filters: [{
37
+ field: e.lookupField,
38
+ op: "in",
39
+ value: e.values
40
+ }],
41
+ count: "window"
42
+ };
43
+ return {
44
+ queryKey: [
45
+ "entity-data",
46
+ e.entity,
47
+ t
48
+ ],
49
+ queryFn: ({ signal: n }) => r(e.entity, t, { signal: n }),
50
+ staleTime: 6e4
51
+ };
52
+ }) }), d = {};
53
+ if (n) for (let [e, t] of Object.entries(n)) d[e] = { ...t };
54
+ let f = /* @__PURE__ */ new Set();
55
+ return u.forEach((t, n) => {
56
+ let r = l[n];
57
+ if (!r) return;
58
+ let i = t.data?.data;
59
+ if (i) {
60
+ let t = d[r.entity] ??= {};
61
+ for (let n of i) {
62
+ let i = e(n[r.lookupField]);
63
+ i && (t[i] = n);
64
+ }
65
+ }
66
+ if (t.isLoading) for (let e of r.values) d[r.entity]?.[e] || f.add(`${r.entity}::${e}`);
67
+ }), {
68
+ refs: d,
69
+ isLoading: (e, t) => f.has(`${e}::${t}`)
70
+ };
71
+ }
72
+ //#endregion
73
+ export { s as refLabel, c as useRefRecords };
@@ -0,0 +1,12 @@
1
+ import { useAuthStore as e } from "../stores/auth.js";
2
+ import { useMemo as t } from "react";
3
+ //#region src/hooks/useRowTenant.ts
4
+ function n(n) {
5
+ let r = e((e) => e.activeTenant?.id);
6
+ return t(() => ({
7
+ entity: n,
8
+ tenantId: r
9
+ }), [n, r]);
10
+ }
11
+ //#endregion
12
+ export { n as useRowTenant };
@@ -1363,7 +1363,7 @@ interface QuickPeekFileFieldSpec {
1363
1363
  }
1364
1364
  type QuickPeekFieldSpec = QuickPeekRegularFieldSpec | QuickPeekFileFieldSpec;
1365
1365
  interface QuickPeekProps<R extends Record<string, unknown> = Record<string, unknown>> {
1366
- entity: Pick<Entity, "fields" | "files" | "variants">;
1366
+ entity: Pick<Entity, "fields" | "files" | "variants" | "tenant_key">;
1367
1367
  entityCode?: string;
1368
1368
  record: R;
1369
1369
  title: string;
@@ -2473,9 +2473,10 @@ export declare function parseTargetFilter(raw: string | undefined): string[];
2473
2473
  * status groups and properties (when not composite PK). Matches the
2474
2474
  * engine-side BuildMassEditTargets contract.
2475
2475
  * - entities without generic update globally hide every target (UI mirrors
2476
- * the server gate; the dispatcher still enforces permissions).
2476
+ * the server gate; the dispatcher still enforces permissions), and so does
2477
+ * a selection holding a row set in another tenant.
2477
2478
  */
2478
- export declare function buildMassEditTargets(t: TextFn, entity: Entity | undefined, whitelistRaw?: string | string[]): MassEditTarget[];
2479
+ export declare function buildMassEditTargets(t: TextFn, entity: Entity | undefined, whitelistRaw: string | string[] | undefined, selectedRows: ReadonlyArray<Record<string, unknown>>, tenantId: string | undefined): MassEditTarget[];
2479
2480
  //#endregion
2480
2481
  //#region src/components/actions/PropertyGridEditor.d.ts
2481
2482
  /** Raw patch shape: field codes + optional $statuses / $properties subresource arrays. */
@@ -1,16 +1,16 @@
1
1
  import { coerceDisplayString as e } from "./display-value.js";
2
- import { entityAllowsMutation as t, extractPkValues as n, pkValuesToDetailId as r } from "../types/schema.js";
2
+ import { entityAllowsMutation as t, extractPkValues as n, pkValuesToDetailId as r, rowSetInTenant as i } from "../types/schema.js";
3
3
  //#region src/lib/actions.ts
4
- var i = {
4
+ var a = {
5
5
  __create: "create",
6
6
  __edit: "update",
7
7
  __delete: "delete",
8
8
  __restore: "restore"
9
- }, a = "__peek", o = "__open", s = "__edit";
10
- function c(e) {
9
+ }, o = "__peek", s = "__open", c = "__edit";
10
+ function l(e) {
11
11
  return e === "__peek" || e === "__open";
12
12
  }
13
- function l(t, i) {
13
+ function u(t, i) {
14
14
  if (!t) return "";
15
15
  if (i) try {
16
16
  return r(i, n(i, t));
@@ -18,30 +18,30 @@ function l(t, i) {
18
18
  let a = t.id;
19
19
  return typeof a == "string" ? a : a == null ? "" : e(a);
20
20
  }
21
- function u(e, t) {
21
+ function d(e, t) {
22
22
  if (!e || e.length === 0) return !0;
23
23
  for (let n of e) {
24
24
  if (n.status && n.status.length > 0) {
25
25
  let e = t.status;
26
26
  if (typeof e != "string" || !n.status.includes(e)) return !1;
27
27
  }
28
- if (n.field && !f(n, t)) return !1;
28
+ if (n.field && !p(n, t)) return !1;
29
29
  }
30
30
  return !0;
31
31
  }
32
- function d(e, t) {
32
+ function f(e, t) {
33
33
  return t.startsWith("$status.") ? !Array.isArray(e.$statuses) : t.startsWith("$property.") ? !Array.isArray(e.$properties) : !1;
34
34
  }
35
- function f(t, n) {
36
- if (d(n, t.field)) return !1;
37
- let r = p(n, t.field), i = t.op || "eq";
35
+ function p(t, n) {
36
+ if (f(n, t.field)) return !1;
37
+ let r = m(n, t.field), i = t.op || "eq";
38
38
  if (i === "in" || i === "not_in") {
39
39
  let n = Array.isArray(t.value) ? t.value : [t.value], a = e(r), o = n.some((t) => e(t) === a);
40
40
  return i === "in" ? o : !o;
41
41
  }
42
- return typeof t.value == "boolean" && i === "eq" ? h(r) === t.value : typeof r == "number" && typeof t.value == "number" ? g(r, t.value, i) : g(e(r), e(t.value), i);
42
+ return typeof t.value == "boolean" && i === "eq" ? g(r) === t.value : typeof r == "number" && typeof t.value == "number" ? _(r, t.value, i) : _(e(r), e(t.value), i);
43
43
  }
44
- function p(e, t) {
44
+ function m(e, t) {
45
45
  if (Object.prototype.hasOwnProperty.call(e, t)) return e[t];
46
46
  if (t.startsWith("$status.")) {
47
47
  let n = t.slice(8), r = e.$statuses;
@@ -52,27 +52,27 @@ function p(e, t) {
52
52
  return Array.isArray(r) ? r.find((e) => !e || typeof e != "object" ? !1 : e.property_code === n)?.value : void 0;
53
53
  }
54
54
  }
55
- function m(e) {
55
+ function h(e) {
56
56
  let t = null, n = (n, r) => {
57
57
  Object.prototype.hasOwnProperty.call(e, n) || (t === null && (t = { ...e }), t[n] = r);
58
58
  }, r = e.$statuses;
59
59
  if (Array.isArray(r)) for (let t of r) {
60
60
  if (!t || typeof t != "object") continue;
61
61
  let r = t.group_code;
62
- typeof r == "string" && n(`$status.${r}`, p(e, `$status.${r}`));
62
+ typeof r == "string" && n(`$status.${r}`, m(e, `$status.${r}`));
63
63
  }
64
64
  let i = e.$properties;
65
65
  if (Array.isArray(i)) for (let t of i) {
66
66
  if (!t || typeof t != "object") continue;
67
67
  let r = t.property_code;
68
- typeof r == "string" && n(`$property.${r}`, p(e, `$property.${r}`));
68
+ typeof r == "string" && n(`$property.${r}`, m(e, `$property.${r}`));
69
69
  }
70
70
  return t ?? e;
71
71
  }
72
- function h(e) {
72
+ function g(e) {
73
73
  return e == null ? !1 : typeof e == "boolean" ? e : typeof e == "string" ? e !== "" : typeof e != "number" || e !== 0;
74
74
  }
75
- function g(e, t, n) {
75
+ function _(e, t, n) {
76
76
  switch (n) {
77
77
  case "eq": return e === t;
78
78
  case "ne": return e !== t;
@@ -85,14 +85,14 @@ function g(e, t, n) {
85
85
  default: return !1;
86
86
  }
87
87
  }
88
- function _(e, t) {
88
+ function v(e, t) {
89
89
  return e ? Object.entries(e).filter(([, e]) => e.visibility?.includes(t)).map(([e, t]) => ({
90
90
  code: e,
91
91
  action: t
92
92
  })) : [];
93
93
  }
94
- function v(e, t, n, r) {
95
- return !e && !r ? [] : t === void 0 ? _(e, n) : t.map((t) => {
94
+ function y(e, t, n, r) {
95
+ return !e && !r ? [] : t === void 0 ? v(e, n) : t.map((t) => {
96
96
  let n = e?.[t] ?? r?.[t];
97
97
  return n ? {
98
98
  code: t,
@@ -100,30 +100,34 @@ function v(e, t, n, r) {
100
100
  } : null;
101
101
  }).filter((e) => e !== null);
102
102
  }
103
- function y(e, n) {
103
+ function b(e, t) {
104
+ let n = a[e];
105
+ return !n || n === "create" ? () => !0 : (e) => i(t.entity, e, t.tenantId);
106
+ }
107
+ function x(e, n) {
104
108
  return e.filter(({ code: e }) => {
105
- let r = i[e];
109
+ let r = a[e];
106
110
  return !r || t(n, r);
107
111
  });
108
112
  }
109
- function b(e) {
113
+ function S(e) {
110
114
  return !!e?.confirmation && Object.keys(e.confirmation).length > 0;
111
115
  }
112
- function x(e, t) {
113
- return b(t) ? e(t.confirmation) : t?.destructive ? e("action.confirm.destructive", "This action cannot be undone.") : null;
116
+ function C(e, t) {
117
+ return S(t) ? e(t.confirmation) : t?.destructive ? e("action.confirm.destructive", "This action cannot be undone.") : null;
114
118
  }
115
- function S(e) {
116
- return b(e) || !!e?.destructive;
119
+ function w(e) {
120
+ return S(e) || !!e?.destructive;
117
121
  }
118
- function C(e, t, n, r, i, a = !1) {
122
+ function T(e, t, n, r, i, a = !1) {
119
123
  if (r && i) return i;
120
124
  let o = e(t?.display?.description);
121
125
  return o ? a || t?.display?.icon_only === !0 ? `${n}\n${o}` : o : n;
122
126
  }
123
- function w(e) {
127
+ function E(e) {
124
128
  return !!e.association;
125
129
  }
126
- function T(e, t) {
130
+ function D(e, t) {
127
131
  if (e) {
128
132
  for (let n of Object.values(e.screens)) if (n.entity === t && n.type === "list") {
129
133
  let r = e.entities[t];
@@ -134,82 +138,94 @@ function T(e, t) {
134
138
  }
135
139
  }
136
140
  }
137
- function E(e, t, n, r, i, a, o) {
138
- let s = [];
139
- for (let c of t) {
140
- let t = D(e, c, n, r, i, a, o);
141
- t !== null && s.push(t);
141
+ function O(e, t, n, r, i, a, o, s) {
142
+ let c = [];
143
+ for (let l of t) {
144
+ let t = k(e, l, n, r, i, a, o, s);
145
+ t !== null && c.push(t);
142
146
  }
143
- return s;
147
+ return c;
144
148
  }
145
- function D(e, t, n, r, i, a, o) {
146
- return t.kind === "group" ? O(e, t, n, r, i, a, o) : k(e, t, n, r, i, a, o);
149
+ function k(e, t, n, r, i, a, o, s) {
150
+ return t.kind === "group" ? A(e, t, n, r, i, a, o, s) : j(e, t, n, r, i, a, o, s);
147
151
  }
148
- function O(e, t, n, r, i, a, o) {
149
- let s = [];
150
- for (let c of t.items) {
151
- let t = D(e, c, n, r, i, a, o);
152
- t !== null && s.push(t);
152
+ function A(e, t, n, r, i, a, o, s) {
153
+ let c = [];
154
+ for (let l of t.items) {
155
+ let t = k(e, l, n, r, i, a, o, s);
156
+ t !== null && c.push(t);
153
157
  }
154
- return s.length === 0 ? null : {
158
+ return c.length === 0 ? null : {
155
159
  ...t,
156
- items: s
160
+ items: c
157
161
  };
158
162
  }
159
- function k(e, t, n, r, i, a, o) {
160
- if (o && !t.code.startsWith("__") && !o.has(t.code)) return null;
161
- let s = M(t.code, n, r);
162
- if (!s) return null;
163
+ function j(e, t, n, r, i, a, o, s) {
164
+ if (s && !t.code.startsWith("__") && !s.has(t.code)) return null;
165
+ let c = P(t.code, n, r);
166
+ if (!c) return null;
167
+ let l = b(t.code, o);
163
168
  if (a.length > 0) {
164
- let n = A(e, s, a);
169
+ let n = M(e, c, a, l);
165
170
  return n.visible ? {
166
171
  ...t,
167
172
  enabled: n.enabled,
168
173
  reason: n.reason
169
174
  } : null;
170
175
  }
171
- if (!u(s.conditions, i) || !u(N(s.visible_if), i)) return null;
172
- let { enabled: c, reason: l } = j(e, s, i);
176
+ if (!l(i) || !d(c.conditions, i) || !d(F(c.visible_if), i)) return null;
177
+ let { enabled: u, reason: f } = N(e, c, i);
173
178
  return {
174
179
  ...t,
175
- enabled: c,
176
- reason: l
180
+ enabled: u,
181
+ reason: f
177
182
  };
178
183
  }
179
- function A(e, t, n) {
180
- let r = N(t.visible_if), i = N(t.enabled_if), a = t.conditions, o = 0, s = 0;
184
+ function M(e, t, n, r) {
185
+ let i = F(t.visible_if), a = F(t.enabled_if), o = t.conditions, s = 0, c = 0, l = 0;
181
186
  for (let e of n) {
182
- let t = u(r, e) && u(a, e);
183
- t && o++;
184
- let n = u(i, e);
185
- (!t || !n) && s++;
187
+ let t = r(e);
188
+ t || l++;
189
+ let n = d(i, e) && d(o, e);
190
+ n && s++;
191
+ let u = t && d(a, e);
192
+ (!n || !u) && c++;
186
193
  }
187
- if (o === 0) return {
194
+ if (s === 0) return {
188
195
  visible: !1,
189
196
  enabled: !1,
190
197
  reason: null
191
198
  };
192
- if (s === 0) return {
199
+ if (c === 0) return {
193
200
  visible: !0,
194
201
  enabled: !0,
195
202
  reason: null
196
203
  };
197
- let c = {
198
- failing: s,
199
- total: n.length
200
- }, l = e(t.enabled_if_reason);
204
+ let u = n.length;
205
+ if (l > 0) return {
206
+ visible: !0,
207
+ enabled: !1,
208
+ reason: e("action.bulk.rows_other_tenant", "{failing} of {total} selected rows are set in another tenant; change them from that tenant.", {
209
+ failing: l,
210
+ total: u
211
+ })
212
+ };
213
+ let f = {
214
+ failing: c,
215
+ total: u
216
+ }, p = e(t.enabled_if_reason);
201
217
  return {
202
218
  visible: !0,
203
219
  enabled: !1,
204
- reason: l ? e("action.bulk.reason_rows_fail", "{reason} ({failing} of {total} rows fail)", {
205
- reason: l,
206
- ...c
207
- }) : e("action.bulk.rows_fail", "({failing} of {total} rows fail)", c)
220
+ reason: p ? e("action.bulk.reason_rows_fail", "{reason} ({failing} of {total} rows fail)", {
221
+ reason: p,
222
+ ...f
223
+ }) : e("action.bulk.rows_fail", "({failing} of {total} rows fail)", f)
208
224
  };
209
225
  }
210
- function j(e, t, n) {
211
- let r = N(t.enabled_if);
212
- return !r || r.length === 0 || u(r, n) ? {
226
+ function N(e, t, n) {
227
+ let r = F(t.enabled_if);
228
+ return !r || r.length === 0 || d(r, n) ? {
213
229
  enabled: !0,
214
230
  reason: null
215
231
  } : {
@@ -217,46 +233,46 @@ function j(e, t, n) {
217
233
  reason: e(t.enabled_if_reason) || null
218
234
  };
219
235
  }
220
- function M(e, t, n) {
236
+ function P(e, t, n) {
221
237
  if (t && e in t) return t[e];
222
238
  if (n && e in n) return n[e];
223
239
  }
224
- function N(e) {
240
+ function F(e) {
225
241
  return e;
226
242
  }
227
- function P(e, t, n, r, i) {
243
+ function I(e, t, n, r, i) {
228
244
  let a = [];
229
245
  for (let o of e) {
230
246
  if (o.kind === "group") {
231
- let e = P(o.items, t, n, r, i);
247
+ let e = I(o.items, t, n, r, i);
232
248
  e.length > 0 && a.push({
233
249
  ...o,
234
250
  items: e
235
251
  });
236
252
  continue;
237
253
  }
238
- let e = M(o.code, t, n);
254
+ let e = P(o.code, t, n);
239
255
  e && e.visibility?.includes(r) && (i?.bulkRequired === void 0 || (i.bulkRequiredPredicate ? i.bulkRequiredPredicate(e) : !1) === i.bulkRequired) && (i?.excludeIf && i.excludeIf(e) || a.push(o));
240
256
  }
241
257
  return a;
242
258
  }
243
- function F(e, t, n, r, i, a) {
259
+ function L(e, t, n, r, i, a) {
244
260
  let o = e ?? t;
245
- return o ? P(o, n, r, i, a) : z(n, i);
261
+ return o ? I(o, n, r, i, a) : V(n, i);
246
262
  }
247
- function I(e) {
248
- return e.requires_selection === void 0 ? L(e) : e.requires_selection;
263
+ function R(e) {
264
+ return e.requires_selection === void 0 ? z(e) : e.requires_selection;
249
265
  }
250
- function L(e) {
266
+ function z(e) {
251
267
  return e.visibility?.includes("list_floatbar") ?? !1;
252
268
  }
253
- function R(e, t, n, r, i) {
269
+ function B(e, t, n, r, i) {
254
270
  return e.map((e) => {
255
271
  if (e.kind === "group") return {
256
272
  ...e,
257
- items: R(e.items, t, n, r, i)
273
+ items: B(e.items, t, n, r, i)
258
274
  };
259
- let a = M(e.code, t, n);
275
+ let a = P(e.code, t, n);
260
276
  return a && r(a) ? {
261
277
  ...e,
262
278
  enabled: !1,
@@ -264,7 +280,7 @@ function R(e, t, n, r, i) {
264
280
  } : e;
265
281
  });
266
282
  }
267
- function z(e, t) {
283
+ function V(e, t) {
268
284
  return e ? Object.entries(e).filter(([, e]) => e.visibility?.includes(t)).sort(([e, t], [n, r]) => {
269
285
  let i = t.position ?? 0, a = r.position ?? 0;
270
286
  return i === a ? e < n ? -1 : +(e > n) : i - a;
@@ -276,4 +292,4 @@ function z(e, t) {
276
292
  })) : [];
277
293
  }
278
294
  //#endregion
279
- export { s as EDIT_ACTION_CODE, o as OPEN_ACTION_CODE, a as PEEK_ACTION_CODE, p as actionConditionFieldValue, x as actionConfirmMessage, L as actionInFloatbarSlot, S as actionNeedsConfirm, I as actionRequiresSelection, C as actionTooltip, E as applyRowState, z as defaultFlatForSlot, R as disableLeavesWhere, u as evaluateConditions, P as filterLayoutForSlot, y as filterUnavailableMutationActions, T as findListScreenForEntity, _ as getActionsByVisibility, v as getScreenActions, w as isAssociationAction, c as isNavDefaultCode, F as resolveActionLayoutForSlot, l as rowDetailId, m as withActionConditionFields };
295
+ export { c as EDIT_ACTION_CODE, s as OPEN_ACTION_CODE, o as PEEK_ACTION_CODE, m as actionConditionFieldValue, C as actionConfirmMessage, z as actionInFloatbarSlot, w as actionNeedsConfirm, R as actionRequiresSelection, T as actionTooltip, O as applyRowState, V as defaultFlatForSlot, B as disableLeavesWhere, d as evaluateConditions, I as filterLayoutForSlot, x as filterUnavailableMutationActions, D as findListScreenForEntity, v as getActionsByVisibility, y as getScreenActions, E as isAssociationAction, l as isNavDefaultCode, L as resolveActionLayoutForSlot, u as rowDetailId, h as withActionConditionFields };
@@ -1,6 +1,6 @@
1
- import { entityAllowsMutation as e, getPrimaryKeyFields as t, isCompositePk as n } from "../types/schema.js";
1
+ import { entityAllowsMutation as e, getPrimaryKeyFields as t, isCompositePk as n, rowSetInTenant as r } from "../types/schema.js";
2
2
  //#region src/lib/mass-edit.ts
3
- function r(e) {
3
+ function i(e) {
4
4
  if (!e) return [];
5
5
  let t = /* @__PURE__ */ new Set(), n = [];
6
6
  for (let r of e.split(",")) {
@@ -9,17 +9,17 @@ function r(e) {
9
9
  }
10
10
  return n;
11
11
  }
12
- function i(i, s, c) {
13
- if (!s || !e(s, "update")) return [];
14
- let l = Array.isArray(c) ? c : r(c), u = l.length > 0 ? new Set(l) : null, d = n(s), f = new Set(t(s)), p = u ? l : a(s, d, f), m = [];
15
- for (let e of p) {
16
- if (u && !u.has(e)) continue;
17
- let t = o(i, s, e, d, f);
18
- t && m.push(t);
12
+ function a(a, c, l, u, d) {
13
+ if (!c || !e(c, "update") || !u.every((e) => r(c, e, d))) return [];
14
+ let f = Array.isArray(l) ? l : i(l), p = f.length > 0 ? new Set(f) : null, m = n(c), h = new Set(t(c)), g = p ? f : o(c, m, h), _ = [];
15
+ for (let e of g) {
16
+ if (p && !p.has(e)) continue;
17
+ let t = s(a, c, e, m, h);
18
+ t && _.push(t);
19
19
  }
20
- return m;
20
+ return _;
21
21
  }
22
- function a(e, t, n) {
22
+ function o(e, t, n) {
23
23
  let r = [];
24
24
  for (let [t, i] of e.fields) n.has(t) || i.auto || r.push(t);
25
25
  if (!t) {
@@ -28,7 +28,7 @@ function a(e, t, n) {
28
28
  }
29
29
  return r;
30
30
  }
31
- function o(e, t, n, r, i) {
31
+ function s(e, t, n, r, i) {
32
32
  if (n.startsWith("$status.")) {
33
33
  if (r) return null;
34
34
  let i = n.slice(8), a = t.status_groups?.[i];
@@ -62,4 +62,4 @@ function o(e, t, n, r, i) {
62
62
  };
63
63
  }
64
64
  //#endregion
65
- export { i as buildMassEditTargets, r as parseTargetFilter };
65
+ export { a as buildMassEditTargets, i as parseTargetFilter };
@@ -114,33 +114,40 @@ function h(e) {
114
114
  function g(e, t) {
115
115
  return !e || e.readonly ? !1 : e.mutations?.[t] ?? !0;
116
116
  }
117
- function _(e) {
117
+ function _(e, t, n) {
118
+ let r = e?.tenant_key;
119
+ return !r || !t || !(r in t) || !!n && String(t[r]).toLowerCase() === n.toLowerCase();
120
+ }
121
+ function v(e, t, n, r) {
122
+ return g(e, t) && (t === "create" || _(e, n, r));
123
+ }
124
+ function y(e) {
118
125
  return !e?.disable_defaults?.includes("__new");
119
126
  }
120
- function v(e) {
127
+ function b(e) {
121
128
  if (e.primary_key && e.primary_key.length > 0) return e.primary_key;
122
129
  for (let [t, n] of e.fields) if (n.primary) return [t];
123
130
  return ["id"];
124
131
  }
125
- function y(e, n) {
126
- let r = v(e), i = {};
132
+ function x(e, n) {
133
+ let r = b(e), i = {};
127
134
  for (let e of r) i[e] = t(n[e]);
128
135
  return i;
129
136
  }
130
- function b(e) {
137
+ function S(e) {
131
138
  return e.length === 1 ? e[0] : JSON.stringify(e);
132
139
  }
133
- function x(e) {
134
- return b(Object.values(e));
140
+ function C(e) {
141
+ return S(Object.values(e));
135
142
  }
136
- function S(e, t) {
137
- return b(v(e).map((e) => t[e] ?? ""));
143
+ function w(e, t) {
144
+ return S(b(e).map((e) => t[e] ?? ""));
138
145
  }
139
- function C(e, t) {
140
- let n = v(e);
146
+ function T(e, t) {
147
+ let n = b(e);
141
148
  if (n.length === 1) return { [n[0]]: t };
142
149
  }
143
- function w(e, t) {
150
+ function E(e, t) {
144
151
  if (t <= 1) return [e];
145
152
  try {
146
153
  let n = JSON.parse(e);
@@ -150,24 +157,24 @@ function w(e, t) {
150
157
  }
151
158
  return null;
152
159
  }
153
- function T(e, t, n) {
160
+ function D(e, t, n) {
154
161
  if (e?.detail_screen === "none") return null;
155
162
  let r = e?.detail_screen ?? t?.detail_screen;
156
163
  return r ? n?.[r]?.route ?? null : null;
157
164
  }
158
- function E(e, t, n, r) {
165
+ function O(e, t, n, r) {
159
166
  if (!t) return null;
160
- let i = T(e, n, r);
167
+ let i = D(e, n, r);
161
168
  return i ? i.replace(":id", encodeURIComponent(t)) : null;
162
169
  }
163
- function D(e, t, n, r) {
164
- return !t || v(t).some((e) => !r[e]) ? null : E(e, S(t, r), t, n);
170
+ function k(e, t, n, r) {
171
+ return !t || b(t).some((e) => !r[e]) ? null : O(e, w(t, r), t, n);
165
172
  }
166
- function O(e, t, n, r) {
167
- return t ? D(e, t, n, y(t, r)) : null;
173
+ function A(e, t, n, r) {
174
+ return t ? k(e, t, n, x(t, r)) : null;
168
175
  }
169
- function k(e) {
170
- return v(e).length > 1;
176
+ function j(e) {
177
+ return b(e).length > 1;
171
178
  }
172
179
  //#endregion
173
- export { r as DETAIL_SCREEN_NONE, i as DISPLAY_KEY, e as OrderedMap, E as buildDetailHrefFromId, D as buildEntityDetailHref, O as buildRowDetailHref, m as effectiveSpecialValues, _ as entityAllowsCreateRoute, g as entityAllowsMutation, y as extractPkValues, u as fieldDisplayName, a as getDisplayValue, v as getPrimaryKeyFields, k as isCompositePk, d as normalizeRefConfig, b as pkValuePartsToId, w as pkValuesFromId, S as pkValuesToDetailId, x as pkValuesToId, h as propertyToField, T as resolveDetailRoute, o as resolveRefRecordLabel, l as screenTitleForPath, C as singlePkValues, f as specialValueMarker, p as specialValueMarkerCode };
180
+ export { r as DETAIL_SCREEN_NONE, i as DISPLAY_KEY, e as OrderedMap, O as buildDetailHrefFromId, k as buildEntityDetailHref, A as buildRowDetailHref, m as effectiveSpecialValues, y as entityAllowsCreateRoute, g as entityAllowsMutation, x as extractPkValues, u as fieldDisplayName, a as getDisplayValue, b as getPrimaryKeyFields, j as isCompositePk, d as normalizeRefConfig, S as pkValuePartsToId, E as pkValuesFromId, w as pkValuesToDetailId, C as pkValuesToId, h as propertyToField, D as resolveDetailRoute, o as resolveRefRecordLabel, v as rowAllowsMutation, _ as rowSetInTenant, l as screenTitleForPath, T as singlePkValues, f as specialValueMarker, p as specialValueMarkerCode };