@nivaro/react 0.3.3 → 0.3.5

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,28 +1,29 @@
1
1
  import { jsx as r, jsxs as u, Fragment as he } from "react/jsx-runtime";
2
2
  import { useQuery as V, useQueryClient as qt } from "@tanstack/react-query";
3
- import { Pencil as Tt, ChevronDown as Ct } from "lucide-react";
3
+ import { Pencil as Ct, ChevronDown as Tt } from "lucide-react";
4
4
  import { useMemo as ge, useRef as Ot, useState as Z, useEffect as be, useCallback as st, Fragment as At } from "react";
5
- import { DrilldownContext as Rt, useNivaroClient as Ce, useApiFetchConfig as Dt, useDrilldown as ct } from "../context.js";
5
+ import { DrilldownContext as Rt, useNivaroClient as Te, useApiFetchConfig as Dt, useDrilldown as ct } from "../context.js";
6
6
  import { useDebounced as Lt } from "../hooks/useDebounced.js";
7
+ import { parseAllowedCollections as Pt } from "../lib/allowed-collections.js";
7
8
  import { get as G } from "../lib/commands.js";
8
- import { readGroupStructure as Pt, isFolded as Kt, isEmptyValue as Be, planFieldGrid as jt } from "../lib/form-structure.js";
9
- import { useLiveRecord as Et } from "../lib/live.js";
10
- import { isDisplayFormulaField as qe, resolvePlacementText as It, displayFormulaOf as Wt, formatDisplayValue as Mt } from "../lib/placement-behaviour.js";
11
- import { useRecordReader as Ut } from "../lib/record-loader.js";
12
- import { sanitizeHtml as Vt } from "../lib/sanitize-html.js";
13
- import { titleCase as Ge, formatRelative as Te } from "../lib/utils.js";
14
- import { InboundRequestPopover as Bt } from "./integrations/InboundRequest.js";
15
- import { FileM2MField as Gt } from "./item-edit/FilePickerField.js";
16
- import { useFieldTouches as Jt } from "./item-edit/HeaderFreshness.js";
17
- import { richTextToPlain as Ht } from "./item-edit/helpers.js";
18
- import { usePlacementTextContext as Qt, evaluateDisplayFormula as zt } from "./item-edit/placement-behaviour.js";
9
+ import { readGroupStructure as Kt, isFolded as jt, isEmptyValue as Be, planFieldGrid as Et } from "../lib/form-structure.js";
10
+ import { useLiveRecord as It } from "../lib/live.js";
11
+ import { isDisplayFormulaField as qe, resolvePlacementText as Wt, displayFormulaOf as Mt, formatDisplayValue as Ut } from "../lib/placement-behaviour.js";
12
+ import { useRecordReader as Vt } from "../lib/record-loader.js";
13
+ import { sanitizeHtml as Bt } from "../lib/sanitize-html.js";
14
+ import { titleCase as Ge, formatRelative as Ce } from "../lib/utils.js";
15
+ import { InboundRequestPopover as Gt } from "./integrations/InboundRequest.js";
16
+ import { FileM2MField as Jt } from "./item-edit/FilePickerField.js";
17
+ import { useFieldTouches as Ht } from "./item-edit/HeaderFreshness.js";
18
+ import { richTextToPlain as Qt } from "./item-edit/helpers.js";
19
+ import { usePlacementTextContext as zt, evaluateDisplayFormula as Yt } from "./item-edit/placement-behaviour.js";
19
20
  import { UserChip as ut } from "./item-edit/UserChip.js";
20
- import { DesignNode as Yt } from "./layout-editor/DesignNode.js";
21
- import { DesignCanvas as Xt } from "./layout-editor/design-canvas.js";
22
- import { revealGroupKey as Zt } from "./layout-editor/design-context.js";
23
- import { useRecordIntegrity as el, integrityByField as tl } from "./panels/RecordIntegrityBanner.js";
21
+ import { DesignNode as Xt } from "./layout-editor/DesignNode.js";
22
+ import { DesignCanvas as Zt } from "./layout-editor/design-canvas.js";
23
+ import { revealGroupKey as el } from "./layout-editor/design-context.js";
24
+ import { useRecordIntegrity as tl, integrityByField as ll } from "./panels/RecordIntegrityBanner.js";
24
25
  import { SimpleSelectXs as dt } from "./ui/SimpleSelect.js";
25
- import { WidgetSlot as ll } from "./WidgetSlot.js";
26
+ import { WidgetSlot as rl } from "./WidgetSlot.js";
26
27
  const pe = (n) => {
27
28
  if (!n) return {};
28
29
  if (typeof n == "object") return n;
@@ -40,7 +41,7 @@ const pe = (n) => {
40
41
  }, Ie = (n) => {
41
42
  const m = Number(n);
42
43
  return Number.isNaN(m) ? String(n) : m.toLocaleString("en-US");
43
- }, Ee = "text-[11.5px] font-medium text-slate-500 dark:text-slate-400", ee = () => /* @__PURE__ */ r("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }), rl = `
44
+ }, Ee = "text-[11.5px] font-medium text-slate-500 dark:text-slate-400", ee = () => /* @__PURE__ */ r("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }), nl = `
44
45
  [data-read-board]{grid-template-columns:minmax(0,1fr)}
45
46
  [data-read-dl]{grid-template-columns:repeat(2,minmax(0,1fr))}
46
47
  @media (min-width:640px){[data-read-dl="full"]{grid-template-columns:repeat(3,minmax(0,1fr))}}
@@ -68,8 +69,8 @@ function ft({
68
69
  }
69
70
  );
70
71
  }
71
- function nl({ collection: n, id: m }) {
72
- const N = Ce(), c = Ut(), P = ct(), { data: w } = V({
72
+ function al({ collection: n, id: m }) {
73
+ const N = Te(), c = Vt(), P = ct(), { data: w } = V({
73
74
  queryKey: ["cbv-collection-meta", n],
74
75
  queryFn: () => N.request(
75
76
  G(`/collections/${n}`)
@@ -93,7 +94,7 @@ function nl({ collection: n, id: m }) {
93
94
  let v = "";
94
95
  const h = w == null ? void 0 : w.display_template;
95
96
  if (h && (v = h.replace(/\{\{\s*([^}]+?)\s*\}\}/g, (q, K) => {
96
- const M = K.split(".").reduce((S, y) => S == null ? void 0 : S[y], $);
97
+ const M = K.split(".").reduce((S, x) => S == null ? void 0 : S[x], $);
97
98
  return M == null ? "" : String(M);
98
99
  }).trim()), !v) {
99
100
  for (const q of [
@@ -121,8 +122,8 @@ function nl({ collection: n, id: m }) {
121
122
  }
122
123
  ) : /* @__PURE__ */ r(he, { children: v });
123
124
  }
124
- function al({ id: n }) {
125
- const m = Ce(), { apiBase: N } = Dt(), { data: c, isPending: P } = V({
125
+ function il({ id: n }) {
126
+ const m = Te(), { apiBase: N } = Dt(), { data: c, isPending: P } = V({
126
127
  queryKey: ["rrv-file-meta", String(n)],
127
128
  queryFn: () => m.request(
128
129
  G(`/files/${n}/meta`)
@@ -146,8 +147,8 @@ function al({ id: n }) {
146
147
  }
147
148
  );
148
149
  }
149
- const He = ({ collection: n, id: m }) => n === "nivaro_files" ? /* @__PURE__ */ r(al, { id: m }) : /* @__PURE__ */ r(nl, { collection: n, id: m });
150
- function il({
150
+ const He = ({ collection: n, id: m }) => n === "nivaro_files" ? /* @__PURE__ */ r(il, { id: m }) : /* @__PURE__ */ r(al, { collection: n, id: m });
151
+ function sl({
151
152
  junction: n,
152
153
  parentFk: m,
153
154
  junctionField: N,
@@ -157,14 +158,14 @@ function il({
157
158
  relation: $
158
159
  }) {
159
160
  var j;
160
- const W = Ce(), { data: v } = V({
161
+ const W = Te(), { data: v } = V({
161
162
  queryKey: ["cbv-collection-meta", n],
162
- queryFn: () => W.request(G(`/collections/${n}`)).then((b) => b.data),
163
+ queryFn: () => W.request(G(`/collections/${n}`)).then((y) => y.data),
163
164
  staleTime: 10 * 6e4,
164
165
  retry: !1
165
166
  }), h = ((v == null ? void 0 : v.relations) ?? []).find(
166
- (b) => b.many_collection === n && b.many_field === N
167
- ), q = String((h == null ? void 0 : h.one_allowed_collections) ?? "").split(",").map((b) => b.trim()).filter(Boolean), K = !!h && !h.one_collection && (q.length > 0 || !!h.one_collection_field), M = (h == null ? void 0 : h.one_collection_field) ?? "collection", S = (b) => b ? b === "directus_users" ? "nivaro_users" : b : null, y = (h == null ? void 0 : h.one_collection) ?? (K ? q.some((b) => b === "directus_users" || b === "nivaro_users") ? "nivaro_users" : S(q[0]) : null), { data: g } = V({
167
+ (y) => y.many_collection === n && y.many_field === N
168
+ ), q = Pt(h == null ? void 0 : h.one_allowed_collections), K = !!h && !h.one_collection && (q.length > 0 || !!h.one_collection_field), M = (h == null ? void 0 : h.one_collection_field) ?? "collection", S = (y) => y ? y === "directus_users" ? "nivaro_users" : y : null, x = (h == null ? void 0 : h.one_collection) ?? (K ? q.some((y) => y === "directus_users" || y === "nivaro_users") ? "nivaro_users" : S(q[0]) : null), { data: g } = V({
168
169
  queryKey: ["rrv-m2m", n, m, c, N, K ? M : ""],
169
170
  queryFn: () => W.request(
170
171
  G(`/items/${n}`, {
@@ -173,7 +174,7 @@ function il({
173
174
  limit: 200
174
175
  })
175
176
  ).then(
176
- (b) => (b.data ?? []).filter((k) => k[N] != null).map((k) => {
177
+ (y) => (y.data ?? []).filter((k) => k[N] != null).map((k) => {
177
178
  const F = k[N];
178
179
  return {
179
180
  id: String(typeof F == "object" ? F.id : F),
@@ -185,32 +186,32 @@ function il({
185
186
  enabled: !!v,
186
187
  staleTime: 3e4,
187
188
  retry: !1
188
- }), C = g == null ? void 0 : g.map((b) => b.id), _ = y ?? (K ? ((j = g == null ? void 0 : g.find((b) => b.collection)) == null ? void 0 : j.collection) ?? null : null), O = C == null ? void 0 : C.length;
189
+ }), T = g == null ? void 0 : g.map((y) => y.id), _ = x ?? (K ? ((j = g == null ? void 0 : g.find((y) => y.collection)) == null ? void 0 : j.collection) ?? null : null), O = T == null ? void 0 : T.length;
189
190
  return be(() => {
190
191
  O !== void 0 && (P == null || P(O));
191
192
  }, [O, P]), be(() => {
192
193
  _ && (w == null || w(_));
193
- }, [_, w]), v && !_ && (!K || g) ? /* @__PURE__ */ r(ee, {}) : !C || !_ ? /* @__PURE__ */ r("span", { className: "inline-block h-3.5 w-20 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }) : C.length === 0 ? /* @__PURE__ */ r(ee, {}) : _ === "nivaro_files" && $ ? /* @__PURE__ */ r("div", { className: "mt-1", children: /* @__PURE__ */ r(
194
- Gt,
194
+ }, [_, w]), v && !_ && (!K || g) ? /* @__PURE__ */ r(ee, {}) : !T || !_ ? /* @__PURE__ */ r("span", { className: "inline-block h-3.5 w-20 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }) : T.length === 0 ? /* @__PURE__ */ r(ee, {}) : _ === "nivaro_files" && $ ? /* @__PURE__ */ r("div", { className: "mt-1", children: /* @__PURE__ */ r(
195
+ Jt,
195
196
  {
196
197
  relation: $,
197
198
  parentId: c,
198
199
  allRelations: [],
199
200
  disabled: !0
200
201
  }
201
- ) }) : /* @__PURE__ */ r("span", { className: "flex flex-wrap gap-x-1.5 gap-y-0.5", children: (g ?? []).map(({ id: b, collection: k }, F) => /* @__PURE__ */ u(
202
+ ) }) : /* @__PURE__ */ r("span", { className: "flex flex-wrap gap-x-1.5 gap-y-0.5", children: (g ?? []).map(({ id: y, collection: k }, F) => /* @__PURE__ */ u(
202
203
  "span",
203
204
  {
204
205
  className: "inline-flex items-center whitespace-nowrap",
205
206
  children: [
206
- /* @__PURE__ */ r(He, { collection: k ?? _, id: b }),
207
- F < C.length - 1 && /* @__PURE__ */ r("span", { className: "text-slate-300 dark:text-slate-600", children: "," })
207
+ /* @__PURE__ */ r(He, { collection: k ?? _, id: y }),
208
+ F < T.length - 1 && /* @__PURE__ */ r("span", { className: "text-slate-300 dark:text-slate-600", children: "," })
208
209
  ]
209
210
  },
210
- `${k ?? _}:${b}`
211
+ `${k ?? _}:${y}`
211
212
  )) });
212
213
  }
213
- function sl({
214
+ function dl({
214
215
  collection: n,
215
216
  fkField: m,
216
217
  parentId: N,
@@ -219,7 +220,7 @@ function sl({
219
220
  defaultPreset: w,
220
221
  onCount: $
221
222
  }) {
222
- const W = Ce(), v = ct(), h = (P ?? []).filter((t) => t && Array.isArray(t.columns)), [q, K] = Z(
223
+ const W = Te(), v = ct(), h = (P ?? []).filter((t) => t && Array.isArray(t.columns)), [q, K] = Z(
223
224
  () => {
224
225
  var t;
225
226
  return h.length >= 2 ? ((t = h.find((i) => i.name === w)) == null ? void 0 : t.name) ?? h[0].name : "__all__";
@@ -234,7 +235,7 @@ function sl({
234
235
  return ((i = ((M == null ? void 0 : M.relations) ?? []).find(
235
236
  (o) => o.many_collection === n && o.many_field === t && o.one_collection
236
237
  )) == null ? void 0 : i.one_collection) ?? null;
237
- }, { data: y } = V({
238
+ }, { data: x } = V({
238
239
  queryKey: ["rrv-cols", n, c ?? null],
239
240
  queryFn: () => W.request(
240
241
  G(`/field-config/${n}`, c ? { layout_id: c } : {})
@@ -254,21 +255,21 @@ function sl({
254
255
  "timestamp",
255
256
  "uuid"
256
257
  ].includes(i.type ?? ""))
257
- ).filter((i, o, f) => f.findIndex((T) => T.field === i.field) === o)
258
+ ).filter((i, o, f) => f.findIndex((C) => C.field === i.field) === o)
258
259
  })),
259
260
  staleTime: 5 * 6e4,
260
261
  retry: !1
261
- }), g = (y == null ? void 0 : y.cols) ?? [], C = !!(y != null && y.lineNo), _ = q !== "__all__" ? h.find((t) => t.name === q) : null, O = ge(() => {
262
+ }), g = (x == null ? void 0 : x.cols) ?? [], T = !!(x != null && x.lineNo), _ = q !== "__all__" ? h.find((t) => t.name === q) : null, O = ge(() => {
262
263
  if (!_) return g;
263
264
  const t = new Set(_.columns), i = g.filter((o) => t.has(o.field));
264
265
  return i.length > 0 ? i : g;
265
- }, [g, _]), [j, b] = Z(""), [k, F] = Z(1), [ne, J] = Z({}), Y = Lt(ne, 350), Oe = ge(() => {
266
+ }, [g, _]), [j, y] = Z(""), [k, F] = Z(1), [ne, J] = Z({}), Y = Lt(ne, 350), Oe = ge(() => {
266
267
  const t = [
267
268
  { path: [m], op: "_eq", value: N }
268
269
  ];
269
270
  for (const [i, o] of Object.entries(Y)) {
270
271
  if (!(o != null && o.value.trim())) continue;
271
- const f = o.value.trim(), T = Number(f), D = o.op === "_contains" ? f : f === "true" || f === "false" ? f === "true" : Number.isNaN(T) ? f : T;
272
+ const f = o.value.trim(), C = Number(f), D = o.op === "_contains" ? f : f === "true" || f === "false" ? f === "true" : Number.isNaN(C) ? f : C;
272
273
  t.push({ path: [i], op: o.op, value: D });
273
274
  }
274
275
  return JSON.stringify(t);
@@ -277,12 +278,12 @@ function sl({
277
278
  isLoading: oe,
278
279
  isFetching: Ae
279
280
  } = V({
280
- queryKey: ["rrv-rows", n, m, N, j, C, k, Oe],
281
+ queryKey: ["rrv-rows", n, m, N, j, T, k, Oe],
281
282
  queryFn: () => W.request(
282
283
  G(`/items/${n}`, {
283
284
  limit: p,
284
285
  page: k,
285
- ...j ? { sort: j } : C ? { sort: "line_number" } : {},
286
+ ...j ? { sort: j } : T ? { sort: "line_number" } : {},
286
287
  conditions: Oe
287
288
  })
288
289
  ),
@@ -308,13 +309,13 @@ function sl({
308
309
  ).then((t) => t.data ?? { rows: {}, targets: {} }).catch(() => ({ rows: {}, targets: {} })),
309
310
  enabled: ce.length > 0 && ue.length > 0,
310
311
  staleTime: 3e4
311
- }), R = C && A.some((t) => t.line_number != null), xe = Math.max(1, Math.ceil(X / p)), ae = (t, i, o) => {
312
+ }), R = T && A.some((t) => t.line_number != null), xe = Math.max(1, Math.ceil(X / p)), ae = (t, i, o) => {
312
313
  F(1), J((f) => {
313
- const T = { ...f };
314
- return o ? T[t] = { op: i, value: o } : delete T[t], T;
314
+ const C = { ...f };
315
+ return o ? C[t] = { op: i, value: o } : delete C[t], C;
315
316
  });
316
317
  }, We = (t) => {
317
- F(1), b((i) => i === t ? `-${t}` : i === `-${t}` ? "" : t);
318
+ F(1), y((i) => i === t ? `-${t}` : i === `-${t}` ? "" : t);
318
319
  };
319
320
  if (oe)
320
321
  return /* @__PURE__ */ r("div", { className: "space-y-1.5 py-2", children: [0, 1, 2].map((t) => /* @__PURE__ */ r(
@@ -356,8 +357,8 @@ function sl({
356
357
  if (i.type === "decimal" || i.type === "float") return Je(o);
357
358
  if (i.type === "integer") return Ie(o);
358
359
  if (i.type === "date" || i.type === "datetime" || i.type === "timestamp") return mt(o);
359
- const T = String(o);
360
- return T.length > 48 ? `${T.slice(0, 48)}…` : T;
360
+ const C = String(o);
361
+ return C.length > 48 ? `${C.slice(0, 48)}…` : C;
361
362
  }, ie = (t) => ["decimal", "float", "integer"].includes(t.type ?? "") && !S(t.field) && !t.field.includes("."), Re = (t) => {
362
363
  const i = t.options;
363
364
  if (!i) return {};
@@ -377,8 +378,8 @@ function sl({
377
378
  const o = A.map((D) => Number(D[t.field])).filter((D) => !Number.isNaN(D));
378
379
  let f = null;
379
380
  if (i === "count" ? f = A.length : o.length > 0 && (i === "sum" ? f = o.reduce((D, te) => D + te, 0) : i === "avg" ? f = o.reduce((D, te) => D + te, 0) / o.length : i === "min" ? f = Math.min(...o) : i === "max" && (f = Math.max(...o))), f === null) return "—";
380
- const T = Re(t).format;
381
- return i === "count" || T === "int" ? Ie(Math.round(f)) : T === "currency" || t.type === "decimal" || t.type === "float" ? Je(f) : i === "avg" ? f.toFixed(2) : Ie(f);
381
+ const C = Re(t).format;
382
+ return i === "count" || C === "int" ? Ie(Math.round(f)) : C === "currency" || t.type === "decimal" || t.type === "float" ? Je(f) : i === "avg" ? f.toFixed(2) : Ie(f);
382
383
  }, _e = (t) => !S(t.field) && !t.field.includes("."), Le = (t) => S(t.field) || t.field.includes(".") ? null : t.type === "boolean" ? "bool" : ["integer", "decimal", "float"].includes(t.type ?? "") ? "num" : ["string", "text"].includes(t.type ?? "") ? "text" : null, ke = O.some((t) => Le(t) != null);
383
384
  return /* @__PURE__ */ u("div", { children: [
384
385
  h.length >= 2 && /* @__PURE__ */ r("div", { className: "mb-1.5 flex flex-wrap items-center gap-1", "data-read-presets": !0, children: [
@@ -585,48 +586,48 @@ function ot({
585
586
  gridCounts: h
586
587
  }) {
587
588
  var et;
588
- const q = Ce(), K = Qt(), M = c ? c.record ?? {} : null, S = !!(c != null && c.context.showHidden), y = c ? String(((et = c.record) == null ? void 0 : et.id) ?? "") : m ?? "", g = ge(
589
+ const q = Te(), K = zt(), M = c ? c.record ?? {} : null, S = !!(c != null && c.context.showHidden), x = c ? String(((et = c.record) == null ? void 0 : et.id) ?? "") : m ?? "", g = ge(
589
590
  () => c ? {
590
591
  ...c.layout,
591
592
  layout: c.layout.layout ?? { id: 0, name: "" }
592
593
  } : N,
593
594
  [c, N]
594
- ), C = (e) => ({
595
+ ), T = (e) => ({
595
596
  kind: qe(e.field) ? "slot" : "field",
596
597
  field: e.field,
597
598
  group_key: e.group_key ?? null
598
- }), _ = (e, l, s = !1) => c ? /* @__PURE__ */ r(Yt, { target: e, children: s ? /* @__PURE__ */ r("div", { "data-design-hidden": !0, className: "opacity-40", children: l }) : l }) : l, O = ge(
599
+ }), _ = (e, l, s = !1) => c ? /* @__PURE__ */ r(Xt, { target: e, children: s ? /* @__PURE__ */ r("div", { "data-design-hidden": !0, className: "opacity-40", children: l }) : l }) : l, O = ge(
599
600
  () => [
600
601
  ...new Set(
601
602
  (c ? [] : (g == null ? void 0 : g.assignments) ?? []).map((e) => e.field).filter((e) => e && !e.startsWith("__") && !e.includes("."))
602
603
  )
603
604
  ].sort(),
604
605
  [g, c]
605
- ), { data: j } = Jt(n, y, O), b = (e) => {
606
+ ), { data: j } = Ht(n, x, O), y = (e) => {
606
607
  const l = j == null ? void 0 : j[e];
607
608
  if (!l) return null;
608
609
  const s = l.via !== "user";
609
610
  return l.caller && l.activity_id ? /* @__PURE__ */ r(
610
- Bt,
611
+ Gt,
611
612
  {
612
613
  activityId: l.activity_id,
613
614
  callerName: l.caller.name,
614
615
  collection: n,
615
- itemId: y,
616
+ itemId: x,
616
617
  children: /* @__PURE__ */ u(
617
618
  "button",
618
619
  {
619
620
  type: "button",
620
621
  "data-field-touch": e,
621
622
  "data-field-touch-caller": l.caller.key,
622
- "data-tip": `Changed ${Te(l.at)} by ${l.caller.name} (through the API) — click for the request`,
623
- "aria-label": `Changed ${Te(l.at)} by ${l.caller.name} through the API`,
623
+ "data-tip": `Changed ${Ce(l.at)} by ${l.caller.name} (through the API) — click for the request`,
624
+ "aria-label": `Changed ${Ce(l.at)} by ${l.caller.name} through the API`,
624
625
  className: "ml-1 inline-flex items-center gap-1 rounded-full bg-amber-50 px-1.5 align-middle text-[9.5px] font-medium leading-4 text-amber-800 hover:bg-amber-100 dark:bg-amber-400/10 dark:text-amber-300 dark:hover:bg-amber-400/20",
625
626
  children: [
626
627
  /* @__PURE__ */ r("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400", "aria-hidden": !0 }),
627
628
  l.caller.name,
628
629
  " · ",
629
- Te(l.at)
630
+ Ce(l.at)
630
631
  ]
631
632
  }
632
633
  )
@@ -635,14 +636,14 @@ function ot({
635
636
  "span",
636
637
  {
637
638
  "data-field-touch": e,
638
- "data-tip": `Changed ${Te(l.at)} by ${l.who}${s ? ` · ${l.via}` : ""}`,
639
+ "data-tip": `Changed ${Ce(l.at)} by ${l.who}${s ? ` · ${l.via}` : ""}`,
639
640
  role: "img",
640
- "aria-label": `Changed ${Te(l.at)} by ${l.who}`,
641
+ "aria-label": `Changed ${Ce(l.at)} by ${l.who}`,
641
642
  className: `ml-1 inline-block h-1.5 w-1.5 rounded-full align-middle ${s ? "bg-amber-400" : "bg-slate-300 dark:bg-slate-600"}`
642
643
  }
643
644
  );
644
- }, { data: k } = el(n, y, !!$ && !c), F = ge(
645
- () => $ && (k != null && k.enabled) ? tl(k.findings) : null,
645
+ }, { data: k } = tl(n, x, !!$ && !c), F = ge(
646
+ () => $ && (k != null && k.enabled) ? ll(k.findings) : null,
646
647
  [$, k]
647
648
  ), ne = ({ field: e }) => {
648
649
  const l = F == null ? void 0 : F.get(e);
@@ -668,19 +669,19 @@ function ot({
668
669
  staleTime: 10 * 6e4,
669
670
  retry: !1
670
671
  }), Y = qt(), { data: Oe } = V({
671
- queryKey: ["rrv-record", n, y],
672
+ queryKey: ["rrv-record", n, x],
672
673
  enabled: !c,
673
- queryFn: () => q.request(G(`/items/${n}/${y}`)).then((e) => e.data),
674
- initialData: () => Y.getQueryData(["item", n, y]) ?? void 0,
674
+ queryFn: () => q.request(G(`/items/${n}/${x}`)).then((e) => e.data),
675
+ initialData: () => Y.getQueryData(["item", n, x]) ?? void 0,
675
676
  initialDataUpdatedAt: () => {
676
677
  var e;
677
- return (e = Y.getQueryState(["item", n, y])) == null ? void 0 : e.dataUpdatedAt;
678
+ return (e = Y.getQueryState(["item", n, x])) == null ? void 0 : e.dataUpdatedAt;
678
679
  },
679
680
  staleTime: 3e4,
680
681
  retry: !1
681
682
  }), p = M ?? Oe;
682
- Et(n, c ? null : y, (e) => {
683
- e.aspectsOnly || e.deleted || (Y.invalidateQueries({ queryKey: ["rrv-record", n, y] }), Y.invalidateQueries({ queryKey: ["field-touch", n, y] }));
683
+ It(n, c ? null : x, (e) => {
684
+ e.aspectsOnly || e.deleted || (Y.invalidateQueries({ queryKey: ["rrv-record", n, x] }), Y.invalidateQueries({ queryKey: ["field-touch", n, x] }));
684
685
  });
685
686
  const B = Ot(null), [oe, Ae] = Z(() => /* @__PURE__ */ new Set());
686
687
  be(() => {
@@ -749,17 +750,17 @@ function ot({
749
750
  }, [_e, Le] = Z({}), ke = (e) => S || _e[e] === !0, [t, i] = Z({}), o = st(
750
751
  (e) => (l) => i((s) => s[e] === l ? s : { ...s, [e]: l }),
751
752
  []
752
- ), [f, T] = Z({}), D = st(
753
- (e) => (l) => T((s) => s[e] === l ? s : { ...s, [e]: l }),
753
+ ), [f, C] = Z({}), D = st(
754
+ (e) => (l) => C((s) => s[e] === l ? s : { ...s, [e]: l }),
754
755
  []
755
756
  ), te = (e) => {
756
- const l = ae.filter((d) => d.group_key === e).sort((d, x) => d.sort - x.sort);
757
+ const l = ae.filter((d) => d.group_key === e).sort((d, b) => d.sort - b.sort);
757
758
  if (l.length === 0) return null;
758
759
  const s = l.some((d) => ke(d.field));
759
760
  return /* @__PURE__ */ r("div", { className: s ? "mt-3 space-y-4" : "hidden", "data-read-widgets": !0, children: l.map((d) => /* @__PURE__ */ r("div", { hidden: !ke(d.field), children: _(
760
761
  { kind: "slot", field: d.field, group_key: d.group_key ?? null },
761
762
  /* @__PURE__ */ r(
762
- ll,
763
+ rl,
763
764
  {
764
765
  widgetId: d.widget_id,
765
766
  inputBindings: We(d),
@@ -768,8 +769,8 @@ function ot({
768
769
  ready: !!p,
769
770
  label: d.label_override ?? void 0,
770
771
  defaultExpanded: d.default_expanded == null ? !0 : !!d.default_expanded,
771
- onContentChange: (x) => Le(
772
- (E) => E[d.field] === x ? E : { ...E, [d.field]: x }
772
+ onContentChange: (b) => Le(
773
+ (E) => E[d.field] === b ? E : { ...E, [d.field]: b }
773
774
  )
774
775
  }
775
776
  ),
@@ -782,7 +783,7 @@ function ot({
782
783
  be(() => {
783
784
  Ne && me(Ne.open ? new Set(g.groups.map((e) => e.key)) : /* @__PURE__ */ new Set());
784
785
  }, [Ne == null ? void 0 : Ne.seq]), be(() => {
785
- const e = we ? Zt(we.target) : null;
786
+ const e = we ? el(we.target) : null;
786
787
  e && me((l) => l.has(e) ? l : new Set(l).add(e));
787
788
  }, [we == null ? void 0 : we.seq]);
788
789
  const Ue = [];
@@ -806,50 +807,50 @@ function ot({
806
807
  }, Ke = (e) => {
807
808
  const l = H.get(e.field), s = pe(e.overrides);
808
809
  if (qe(e.field)) {
809
- const L = Wt(s), de = zt((L == null ? void 0 : L.expr) ?? "", p ?? {});
810
- return /* @__PURE__ */ r("span", { "data-display-formula": e.field, className: "tabular-nums", children: de.error ? "—" : Mt(de.value, L ?? { format: "", currency: null }) });
810
+ const L = Mt(s), de = Yt((L == null ? void 0 : L.expr) ?? "", p ?? {});
811
+ return /* @__PURE__ */ r("span", { "data-display-formula": e.field, className: "tabular-nums", children: de.error ? "—" : Ut(de.value, L ?? { format: "", currency: null }) });
811
812
  }
812
813
  const d = Q(e.field);
813
- if (c && !y && (d != null && d.junction_field)) return /* @__PURE__ */ r(ee, {});
814
+ if (c && !x && (d != null && d.junction_field)) return /* @__PURE__ */ r(ee, {});
814
815
  if (d != null && d.junction_field && d.many_collection && d.many_field)
815
816
  return /* @__PURE__ */ r(
816
- il,
817
+ sl,
817
818
  {
818
819
  junction: d.many_collection,
819
820
  parentFk: d.many_field,
820
821
  junctionField: d.junction_field,
821
- parentId: y,
822
+ parentId: x,
822
823
  onCount: o(e.field),
823
824
  onTarget: D(e.field),
824
825
  relation: d
825
826
  }
826
827
  );
827
- const x = p == null ? void 0 : p[e.field], E = ue(e.field);
828
- if (E === "nivaro_users" && x != null)
829
- return /* @__PURE__ */ r("span", { className: "inline-block", children: /* @__PURE__ */ r(ut, { userId: String(x), size: "compact" }) });
830
- if (E) return /* @__PURE__ */ r(He, { collection: E, id: x });
831
- if (x == null || x === "") return /* @__PURE__ */ r(ee, {});
828
+ const b = p == null ? void 0 : p[e.field], E = ue(e.field);
829
+ if (E === "nivaro_users" && b != null)
830
+ return /* @__PURE__ */ r("span", { className: "inline-block", children: /* @__PURE__ */ r(ut, { userId: String(b), size: "compact" }) });
831
+ if (E) return /* @__PURE__ */ r(He, { collection: E, id: b });
832
+ if (b == null || b === "") return /* @__PURE__ */ r(ee, {});
832
833
  if ((l == null ? void 0 : l.type) === "boolean")
833
834
  return /* @__PURE__ */ r(
834
835
  ft,
835
836
  {
836
- value: x,
837
+ value: b,
837
838
  trueTone: (s.options ?? {}).trueTone ?? "positive"
838
839
  }
839
840
  );
840
841
  const z = s.options ?? {};
841
- return Qe(e) && typeof x == "string" ? /^\s*\{/.test(x) ? /* @__PURE__ */ r("div", { className: "whitespace-pre-wrap font-normal", children: Ht(x) }) : /* @__PURE__ */ r(
842
+ return Qe(e) && typeof b == "string" ? /^\s*\{/.test(b) ? /* @__PURE__ */ r("div", { className: "whitespace-pre-wrap font-normal", children: Qt(b) }) : /* @__PURE__ */ r(
842
843
  "div",
843
844
  {
844
845
  className: "rrv-prose font-normal leading-relaxed [&_a]:underline [&_h1]:text-[15px] [&_h1]:font-semibold [&_h2]:text-[14px] [&_h2]:font-semibold [&_h3]:font-semibold [&_li]:ml-4 [&_ol]:list-decimal [&_p]:my-1 [&_ul]:list-disc",
845
- dangerouslySetInnerHTML: { __html: Vt(x) }
846
+ dangerouslySetInnerHTML: { __html: Bt(b) }
846
847
  }
847
- ) : z.format === "currency" ? /* @__PURE__ */ r("span", { className: "tabular-nums", children: Je(x) }) : (l == null ? void 0 : l.type) === "decimal" || (l == null ? void 0 : l.type) === "float" ? /* @__PURE__ */ r("span", { className: "tabular-nums", children: Ie(x) }) : (l == null ? void 0 : l.type) === "date" || (l == null ? void 0 : l.type) === "datetime" || (l == null ? void 0 : l.type) === "timestamp" ? mt(x) : String(x);
848
+ ) : z.format === "currency" ? /* @__PURE__ */ r("span", { className: "tabular-nums", children: Je(b) }) : (l == null ? void 0 : l.type) === "decimal" || (l == null ? void 0 : l.type) === "float" ? /* @__PURE__ */ r("span", { className: "tabular-nums", children: Ie(b) }) : (l == null ? void 0 : l.type) === "date" || (l == null ? void 0 : l.type) === "datetime" || (l == null ? void 0 : l.type) === "timestamp" ? mt(b) : String(b);
848
849
  }, ht = (e) => {
849
850
  const l = pe(e.overrides), s = Q(e.field);
850
851
  if (!(s != null && s.many_collection) || !s.many_field) return null;
851
- if (c && !y) return /* @__PURE__ */ r("p", { className: "py-3 text-[12px] text-slate-400", children: "No records" });
852
- const d = l.options ?? {}, x = (() => {
852
+ if (c && !x) return /* @__PURE__ */ r("p", { className: "py-3 text-[12px] text-slate-400", children: "No records" });
853
+ const d = l.options ?? {}, b = (() => {
853
854
  var L;
854
855
  const z = (L = H.get(e.field)) == null ? void 0 : L.options;
855
856
  if (!z) return {};
@@ -862,14 +863,14 @@ function ot({
862
863
  return z;
863
864
  })(), E = d.layout_id ?? null;
864
865
  return /* @__PURE__ */ r(
865
- sl,
866
+ dl,
866
867
  {
867
868
  collection: s.many_collection,
868
869
  fkField: s.many_field,
869
- parentId: y,
870
+ parentId: x,
870
871
  layoutId: E,
871
- presets: d.column_presets ?? x.column_presets,
872
- defaultPreset: d.default_preset ?? x.default_preset ?? null,
872
+ presets: d.column_presets ?? b.column_presets,
873
+ defaultPreset: d.default_preset ?? b.default_preset ?? null,
873
874
  onCount: o(e.field)
874
875
  },
875
876
  e.field
@@ -880,12 +881,12 @@ function ot({
880
881
  return l == null || l === "" || Array.isArray(l) && l.length === 0;
881
882
  }, yt = (e) => xe.find((l) => l.field === e), $e = (e) => {
882
883
  var d;
883
- const l = pe(e.overrides).label, s = K ? It(e.overrides, K).label : void 0;
884
+ const l = pe(e.overrides).label, s = K ? Wt(e.overrides, K).label : void 0;
884
885
  return s !== void 0 ? s : qe(e.field) ? typeof l == "string" && l.trim() ? l : "Formula" : typeof l == "string" && l.trim() ? l : e.label_override || ((d = H.get(e.field)) == null ? void 0 : d.label) || Ge(e.field);
885
886
  }, vt = (e) => {
886
- const l = Pt(e.swap_config), s = xe.filter((a) => a.group_key === e.key && !bt.has(a.field)).filter((a) => S || !p || !Kt(a.overrides) || !Be(p[a.field])).sort((a, I) => a.sort - I.sort), d = ae.filter((a) => a.group_key === e.key), x = De(e.key), E = s.length === 0 && d.length === 0 && x.length === 0;
887
+ const l = Kt(e.swap_config), s = xe.filter((a) => a.group_key === e.key && !bt.has(a.field)).filter((a) => S || !p || !jt(a.overrides) || !Be(p[a.field])).sort((a, I) => a.sort - I.sort), d = ae.filter((a) => a.group_key === e.key), b = De(e.key), E = s.length === 0 && d.length === 0 && b.length === 0;
887
888
  if (E && !c) return null;
888
- const z = (a) => gt && !S && (Se(a) || se(a)) && ((h == null ? void 0 : h[a.field]) ?? t[a.field]) === 0, L = s.filter((a) => !Se(a)), de = s.filter(Se), tt = d.filter((a) => ke(a.field)), kt = s.filter((a) => !z(a)), Nt = !E && kt.length === 0 && x.length === 0 && tt.length === 0, wt = (a) => (h == null ? void 0 : h[a.field]) ?? t[a.field], Ve = !!l.emptyText && !!p && !c && x.length === 0 && tt.length === 0 && s.every((a) => Se(a) || se(a) ? wt(a) === 0 : Be(p[a.field])), St = jt(L, { rows: l.rows }).units, lt = e.read_width === "full" || e.read_width === "half" || e.read_width === "third" ? e.read_width : de.length > 0 || d.length > 0 || x.length > 0 || L.length > 4 ? "full" : "half", $t = (a) => {
889
+ const z = (a) => gt && !S && (Se(a) || se(a)) && ((h == null ? void 0 : h[a.field]) ?? t[a.field]) === 0, L = s.filter((a) => !Se(a)), de = s.filter(Se), tt = d.filter((a) => ke(a.field)), kt = s.filter((a) => !z(a)), Nt = !E && kt.length === 0 && b.length === 0 && tt.length === 0, wt = (a) => (h == null ? void 0 : h[a.field]) ?? t[a.field], Ve = !!l.emptyText && !!p && !c && b.length === 0 && tt.length === 0 && s.every((a) => Se(a) || se(a) ? wt(a) === 0 : Be(p[a.field])), St = Et(L, { rows: l.rows }).units, lt = e.read_width === "full" || e.read_width === "half" || e.read_width === "third" ? e.read_width : de.length > 0 || d.length > 0 || b.length > 0 || L.length > 4 ? "full" : "half", $t = (a) => {
889
890
  var nt, at, it;
890
891
  if (z(a)) return null;
891
892
  const Fe = !!(pe(a.overrides).options ?? {}).emphasis, U = Qe(a) || !!((at = (nt = H.get(a.field)) == null ? void 0 : nt.interface) != null && at.includes("rich-text")), je = p == null ? void 0 : p[a.field], rt = !U && !se(a) && !ue(a.field) && (String(((it = H.get(a.field)) == null ? void 0 : it.interface) ?? "").includes("textarea") || typeof je == "string" && je.length > 36);
@@ -894,12 +895,12 @@ function ot({
894
895
  {
895
896
  className: `min-w-0 ${U || se(a) && (f[a.field] === "nivaro_files" || (t[a.field] ?? 0) > 3) ? "col-span-full" : Fe || rt ? "col-span-2" : ""}`,
896
897
  children: _(
897
- C(a),
898
+ T(a),
898
899
  /* @__PURE__ */ u(he, { children: [
899
900
  /* @__PURE__ */ u("dt", { className: Ee, children: [
900
901
  $e(a),
901
902
  /* @__PURE__ */ r(ne, { field: a.field }),
902
- b(a.field)
903
+ y(a.field)
903
904
  ] }),
904
905
  /* @__PURE__ */ r(
905
906
  "dd",
@@ -929,7 +930,7 @@ function ot({
929
930
  /* @__PURE__ */ r("dd", { className: "mt-1 flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-[13px] font-medium text-slate-800 dark:text-slate-100", children: p ? Fe.length === 0 ? /* @__PURE__ */ r(ee, {}) : Fe.map((U, je) => /* @__PURE__ */ u(At, { children: [
930
931
  je > 0 && /* @__PURE__ */ r("span", { "aria-hidden": !0, className: "text-slate-300 dark:text-slate-600", children: "·" }),
931
932
  _(
932
- C(U),
933
+ T(U),
933
934
  /* @__PURE__ */ r(
934
935
  "span",
935
936
  {
@@ -984,11 +985,11 @@ function ot({
984
985
  title: `Edit ${e.label}`,
985
986
  "aria-label": `Edit ${e.label}`,
986
987
  className: "relative -my-1 rounded p-1 text-slate-400 opacity-0 transition-opacity hover:bg-slate-100 hover:text-slate-700 focus-visible:opacity-100 group-hover/rs:opacity-100 dark:hover:bg-white/5 dark:hover:text-slate-200 motion-reduce:transition-none",
987
- children: /* @__PURE__ */ r(Tt, { className: "h-3 w-3" })
988
+ children: /* @__PURE__ */ r(Ct, { className: "h-3 w-3" })
988
989
  }
989
990
  ),
990
991
  e.is_collapsed && /* @__PURE__ */ r(
991
- Ct,
992
+ Tt,
992
993
  {
993
994
  "aria-hidden": "true",
994
995
  className: `pointer-events-none h-3.5 w-3.5 shrink-0 transition-transform group-hover/rs:text-slate-700 dark:group-hover/rs:text-slate-200 ${fe(e) ? "" : "-rotate-90"}`
@@ -1020,7 +1021,7 @@ function ot({
1020
1021
  className: L.length > 0 ? "mt-3" : "",
1021
1022
  hidden: z(a) || Ve,
1022
1023
  children: _(
1023
- C(a),
1024
+ T(a),
1024
1025
  /* @__PURE__ */ u(he, { children: [
1025
1026
  (I = F == null ? void 0 : F.get(a.field)) != null && I.length ? /* @__PURE__ */ u("div", { className: "mb-1.5 flex items-center gap-1.5 text-[11px] font-medium text-amber-700 dark:text-amber-300", children: [
1026
1027
  /* @__PURE__ */ r("span", { children: $e(a) }),
@@ -1096,7 +1097,7 @@ function ot({
1096
1097
  /* @__PURE__ */ u("dt", { className: Ee, children: [
1097
1098
  $e(e),
1098
1099
  /* @__PURE__ */ r(ne, { field: e.field }),
1099
- b(e.field)
1100
+ y(e.field)
1100
1101
  ] }),
1101
1102
  /* @__PURE__ */ r(
1102
1103
  "dd",
@@ -1114,7 +1115,7 @@ function ot({
1114
1115
  ]
1115
1116
  }
1116
1117
  ),
1117
- /* @__PURE__ */ r("style", { children: rl }),
1118
+ /* @__PURE__ */ r("style", { children: nl }),
1118
1119
  J ? /* @__PURE__ */ r("div", { className: "grid items-stretch gap-4", "data-read-board": !0, children: Ue.map(vt) }) : /* @__PURE__ */ u("div", { className: "flex flex-col gap-4", "data-read-board-pending": !0, children: [
1119
1120
  /* @__PURE__ */ r("div", { className: "h-32 animate-pulse rounded-xl bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }),
1120
1121
  /* @__PURE__ */ r("div", { className: "h-32 animate-pulse rounded-xl bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }),
@@ -1125,9 +1126,9 @@ function ot({
1125
1126
  }
1126
1127
  );
1127
1128
  }
1128
- function Ll(n) {
1129
- return n.design ? /* @__PURE__ */ r(Xt, { design: n.design.context, onRefusedWrite: n.design.onRefusedWrite, children: /* @__PURE__ */ r(Rt.Provider, { value: null, children: /* @__PURE__ */ r(ot, { ...n }) }) }) : /* @__PURE__ */ r(ot, { ...n });
1129
+ function Kl(n) {
1130
+ return n.design ? /* @__PURE__ */ r(Zt, { design: n.design.context, onRefusedWrite: n.design.onRefusedWrite, children: /* @__PURE__ */ r(Rt.Provider, { value: null, children: /* @__PURE__ */ r(ot, { ...n }) }) }) : /* @__PURE__ */ r(ot, { ...n });
1130
1131
  }
1131
1132
  export {
1132
- Ll as RecordReadView
1133
+ Kl as RecordReadView
1133
1134
  };