@nivaro/react 0.3.67 → 0.3.69

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 (32) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +7 -0
  4. package/dist/index.js +836 -835
  5. package/dist/shared/components/ConformanceView.js +34 -34
  6. package/dist/shared/components/ReportView.js +196 -196
  7. package/dist/shared/components/SlaRulesView.js +36 -36
  8. package/dist/shared/components/chat/ChatPanel.js +484 -487
  9. package/dist/shared/components/chat/ChatViews.js +66 -66
  10. package/dist/shared/components/chat/RoomParts.js +159 -157
  11. package/dist/shared/components/help-videos/editor/StatsTab.js +48 -47
  12. package/dist/shared/components/help-videos/editor/VersionsTab.js +17 -16
  13. package/dist/shared/components/imports/CollectionImportPanel.js +72 -72
  14. package/dist/shared/components/item-edit/FieldRenderer.js +186 -182
  15. package/dist/shared/components/item-edit/FieldRow.js +87 -87
  16. package/dist/shared/components/item-edit/FileDownloadCount.js +94 -0
  17. package/dist/shared/components/item-edit/FilePickerField.js +350 -349
  18. package/dist/shared/components/item-edit/RecordInsights.js +90 -91
  19. package/dist/shared/components/item-edit/SummaryPanel.js +31 -31
  20. package/dist/shared/components/layout-editor/assist/ExplainDiff.js +12 -12
  21. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +175 -138
  22. package/dist/shared/components/layout-editor/inspector/RulesTab.js +53 -52
  23. package/dist/shared/components/panels/AddendumPanel.js +409 -411
  24. package/dist/shared/components/panels/CommentPanel.js +169 -162
  25. package/dist/shared/components/panels/PipelinePanel.js +75 -75
  26. package/dist/shared/components/panels/RevisionsPanel.js +103 -103
  27. package/dist/shared/components/queue/QueueWorklist.js +142 -141
  28. package/dist/shared/lib/activity-sentence.js +154 -144
  29. package/dist/shared/lib/format-value.js +15 -15
  30. package/dist/shared/lib/placement-behaviour.js +39 -31
  31. package/dist/shared/lib/utils.js +58 -53
  32. package/package.json +1 -1
@@ -4,35 +4,35 @@ import { Info as Ft, Loader2 as Ct, Sparkles as Rt, Lock as Lt, SlidersHorizonta
4
4
  import { memo as Et, useState as ke, useRef as L, useId as Pt, useEffect as ae, useCallback as Ge } from "react";
5
5
  import { toast as oe } from "sonner";
6
6
  import { useParentDraft as jt, useNivaroClient as ie } from "../../context.js";
7
- import { showsAiButton as Bt, AUTOFILL_CHECK_KEY as Mt, readAiFill as Dt } from "../../lib/ai-fill.js";
7
+ import { showsAiButton as Bt, AUTOFILL_CHECK_KEY as Dt, readAiFill as Mt } from "../../lib/ai-fill.js";
8
8
  import { get as H, del as Ot, post as ve } from "../../lib/commands.js";
9
9
  import { toastError as Kt } from "../../lib/error-toast.js";
10
- import { titleCase as U, cn as M, formatDateTime as we } from "../../lib/utils.js";
10
+ import { titleCase as U, cn as D, formatDateTime as we, toLocalDateString as Ut } from "../../lib/utils.js";
11
11
  import { requiredByRules as Qe } from "../../lib/validation-rules.js";
12
12
  import { GlossaryLabel as Ye } from "../ai/GlossaryText.js";
13
- import { useFieldSource as Ut, FieldSourceInfo as Ht } from "../ConfigReadBack.js";
14
- import { Label as Wt } from "../ui/label.js";
13
+ import { useFieldSource as Ht, FieldSourceInfo as Wt } from "../ConfigReadBack.js";
14
+ import { Label as Vt } from "../ui/label.js";
15
15
  import { TooltipProvider as ee, Tooltip as te, TooltipTrigger as ne, TooltipContent as re } from "../ui/tooltip.js";
16
- import { useAddendumFields as Vt } from "./AddendumFieldContext.js";
17
- import { AutoIdPreviewField as zt } from "./AutoIdPreviewField.js";
18
- import { useCascadeClearNotifier as Gt } from "./cascade-clear-notice.js";
16
+ import { useAddendumFields as zt } from "./AddendumFieldContext.js";
17
+ import { AutoIdPreviewField as Gt } from "./AutoIdPreviewField.js";
18
+ import { useCascadeClearNotifier as Qt } from "./cascade-clear-notice.js";
19
19
  import { FOCUSABLE as Je } from "./entry/entry-keys.js";
20
- import { useFieldAffordances as Qt, useFieldContextMenu as Yt, usePresenceSoftLock as Jt, LockReasonBadge as Xt, PresenceSoftLockStrip as Zt, RemoteChangeGhost as It } from "./FieldAffordances.js";
21
- import { FieldCommentButton as en } from "./FieldComments.js";
22
- import { FieldRenderer as tn } from "./FieldRenderer.js";
23
- import { FormHelpVideoButton as nn } from "./FormHelpVideoButton.js";
24
- import { primaryControl as rn, applyFieldA11y as ln } from "./field-a11y.js";
25
- import { getCascadeFilters as an, SYSTEM_FIELDS as on, parseJson as sn, buildCascadeFilter as dn, CascadeEffectController as cn } from "./helpers.js";
26
- import { isDerivedForRecord as un } from "./live-rollups.js";
27
- import { useM2MStaging as mn } from "./M2MStagingContext.js";
28
- import { personalDefaultSlotFor as pn, PersonalDefaultSlot as hn } from "./PersonalDefaultControl.js";
29
- import { PersonalDefaultHint as fn } from "./PersonalDefaultPill.js";
30
- import { isDisplayFormulaRow as Xe, usePlacementTextContext as xn, placementFieldText as yn, fieldCounterConfig as bn, fieldIsRecommended as gn, RecommendedMarker as vn, RepeatLastButton as wn, DisplayFormulaValue as kn, FieldCounter as _n } from "./placement-behaviour.js";
31
- import { keepIfEqual as Nn, jsonEqual as Fn } from "./render-stability.js";
32
- import { softRuleWarning as Cn } from "./soft-rules.js";
33
- import { usePersonalDefaultsApi as Rn } from "./usePersonalDefaults.js";
34
- import { resolveOptionFilterTokens as Ln } from "../../lib/option-filter-tokens.js";
35
- const Ze = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger", "number"]), Sn = /* @__PURE__ */ new Set(["string", "text", "richtext", "textarea", "markdown", "json", "csv"]), $n = /* @__PURE__ */ new Set([
20
+ import { useFieldAffordances as Yt, useFieldContextMenu as Jt, usePresenceSoftLock as Xt, LockReasonBadge as Zt, PresenceSoftLockStrip as It, RemoteChangeGhost as en } from "./FieldAffordances.js";
21
+ import { FieldCommentButton as tn } from "./FieldComments.js";
22
+ import { FieldRenderer as nn } from "./FieldRenderer.js";
23
+ import { FormHelpVideoButton as rn } from "./FormHelpVideoButton.js";
24
+ import { primaryControl as ln, applyFieldA11y as an } from "./field-a11y.js";
25
+ import { getCascadeFilters as on, SYSTEM_FIELDS as sn, parseJson as dn, buildCascadeFilter as cn, CascadeEffectController as un } from "./helpers.js";
26
+ import { isDerivedForRecord as mn } from "./live-rollups.js";
27
+ import { useM2MStaging as pn } from "./M2MStagingContext.js";
28
+ import { personalDefaultSlotFor as hn, PersonalDefaultSlot as fn } from "./PersonalDefaultControl.js";
29
+ import { PersonalDefaultHint as xn } from "./PersonalDefaultPill.js";
30
+ import { isDisplayFormulaRow as Xe, usePlacementTextContext as yn, placementFieldText as bn, fieldCounterConfig as gn, fieldIsRecommended as vn, RecommendedMarker as wn, RepeatLastButton as kn, DisplayFormulaValue as _n, FieldCounter as Nn } from "./placement-behaviour.js";
31
+ import { keepIfEqual as Fn, jsonEqual as Cn } from "./render-stability.js";
32
+ import { softRuleWarning as Rn } from "./soft-rules.js";
33
+ import { usePersonalDefaultsApi as Ln } from "./usePersonalDefaults.js";
34
+ import { resolveOptionFilterTokens as Sn } from "../../lib/option-filter-tokens.js";
35
+ const Ze = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger", "number"]), $n = /* @__PURE__ */ new Set(["string", "text", "richtext", "textarea", "markdown", "json", "csv"]), qn = /* @__PURE__ */ new Set([
36
36
  "input",
37
37
  "textarea",
38
38
  "wysiwyg",
@@ -40,7 +40,7 @@ const Ze = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger",
40
40
  "input-rich-text-html",
41
41
  "rich_text",
42
42
  "extension-editorjs"
43
- ]), qn = /* @__PURE__ */ new Set([
43
+ ]), An = /* @__PURE__ */ new Set([
44
44
  "relation-m2o",
45
45
  "relation-m2m",
46
46
  "select-multiple-m2m",
@@ -51,15 +51,15 @@ const Ze = /* @__PURE__ */ new Set(["integer", "float", "decimal", "bigInteger",
51
51
  "file",
52
52
  "files",
53
53
  "image"
54
- ]), An = /* @__PURE__ */ new Set(["file", "file-image", "files-m2m", "files", "image"]);
55
- function Tn(m) {
54
+ ]), Tn = /* @__PURE__ */ new Set(["file", "file-image", "files-m2m", "files", "image"]);
55
+ function En(m) {
56
56
  const e = m.interface ?? "";
57
- return qn.has(e) || e.startsWith("relation-") || e.endsWith("-m2o") || e.endsWith("-m2m") || Ze.has(m.type ?? "") ? !1 : !!(Sn.has(m.type ?? "") || $n.has(e) || !e && m.type && !Ze.has(m.type));
57
+ return An.has(e) || e.startsWith("relation-") || e.endsWith("-m2o") || e.endsWith("-m2m") || Ze.has(m.type ?? "") ? !1 : !!($n.has(m.type ?? "") || qn.has(e) || !e && m.type && !Ze.has(m.type));
58
58
  }
59
- function En(m, e, i) {
59
+ function Pn(m, e, i) {
60
60
  return m.filter((h) => (i == null ? void 0 : i(h)) !== e);
61
61
  }
62
- function Pn(m, e, i, h) {
62
+ function jn(m, e, i, h) {
63
63
  const x = ie();
64
64
  return le({
65
65
  queryKey: ["field-lineage", m, e, i],
@@ -70,7 +70,7 @@ function Pn(m, e, i, h) {
70
70
  staleTime: 3e4
71
71
  });
72
72
  }
73
- function gr(m, e = "rows") {
73
+ function vr(m, e = "rows") {
74
74
  var l, w, g;
75
75
  if (m && (m.kind === "write" || m.kind === "read") && m.formula) {
76
76
  const p = (b) => typeof b == "number" ? b.toLocaleString(void 0, { maximumFractionDigits: 2 }) : b == null || b === "" ? "0" : String(b);
@@ -91,12 +91,12 @@ function gr(m, e = "rows") {
91
91
  `${h} excluded${x ? ` (${x.replace(/^does not match: /, "")})` : ""}`
92
92
  ), s.join(" · ");
93
93
  }
94
- function jn({
94
+ function Bn({
95
95
  collection: m,
96
96
  itemId: e,
97
97
  field: i
98
98
  }) {
99
- const [h, x] = ke(!1), s = L(null), { data: l, isLoading: w } = Pn(m, e, i, h);
99
+ const [h, x] = ke(!1), s = L(null), { data: l, isLoading: w } = jn(m, e, i, h);
100
100
  ae(() => {
101
101
  if (!h) return;
102
102
  const o = (b) => {
@@ -113,7 +113,7 @@ function jn({
113
113
  type: "button",
114
114
  onClick: () => x((o) => !o),
115
115
  title: "Where does this number come from?",
116
- className: M(
116
+ className: D(
117
117
  "inline-flex items-center rounded p-0.5 transition-opacity",
118
118
  h ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
119
119
  ),
@@ -209,7 +209,7 @@ function jn({
209
209
  ] })
210
210
  ] });
211
211
  }
212
- function Bn({
212
+ function Dn({
213
213
  collection: m,
214
214
  itemId: e,
215
215
  field: i,
@@ -230,7 +230,7 @@ function Bn({
230
230
  };
231
231
  return window.addEventListener("mousedown", a), () => window.removeEventListener("mousedown", a);
232
232
  }, [l]);
233
- const b = (a, f) => f || (a == null || a === "" ? "—" : h ? h(a) : typeof a == "boolean" || a === "true" || a === "false" ? a === !0 || a === "true" ? "Yes" : "No" : typeof a == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(a) ? we(a) : typeof a == "object" ? JSON.stringify(a).slice(0, 60) : String(a).slice(0, 80));
233
+ const b = (a, f) => f || (a == null || a === "" ? "—" : h ? h(a) : typeof a == "boolean" || a === "true" || a === "false" ? a === !0 || a === "true" ? "Yes" : "No" : typeof a == "string" && /^\d{4}-\d{2}-\d{2}$/.test(a) ? Ut(a) : typeof a == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(a) ? we(a) : typeof a == "object" ? JSON.stringify(a).slice(0, 60) : String(a).slice(0, 80));
234
234
  return /* @__PURE__ */ u("div", { ref: g, className: "relative inline-flex", children: [
235
235
  /* @__PURE__ */ n(
236
236
  "button",
@@ -238,7 +238,7 @@ function Bn({
238
238
  type: "button",
239
239
  onClick: () => w((a) => !a),
240
240
  title: "Value history",
241
- className: M(
241
+ className: D(
242
242
  "inline-flex items-center rounded p-0.5 transition-opacity",
243
243
  l ? "text-nvr-cyan opacity-100" : "text-slate-400 hover:text-nvr-cyan dark:text-slate-300 dark:hover:text-nvr-cyan"
244
244
  ),
@@ -330,7 +330,7 @@ function Mn({
330
330
  }
331
331
  ) : null;
332
332
  }
333
- const vr = Et(function({
333
+ const wr = Et(function({
334
334
  field: e,
335
335
  draft: i,
336
336
  onChange: h,
@@ -349,13 +349,13 @@ const vr = Et(function({
349
349
  autoFillTick: se
350
350
  }) {
351
351
  var Ue, He, We, Ve;
352
- const V = An.has(e.interface ?? ""), N = jt(), y = mn(), _e = Ie(), de = ie(), [Ne, z] = ke(!1), d = Qt(), ce = Gt(), Fe = Ut(e.field), G = L(null), P = Pt(), ue = L(null), Ce = L(!1), Re = L({
352
+ const V = Tn.has(e.interface ?? ""), N = jt(), y = pn(), _e = Ie(), de = ie(), [Ne, z] = ke(!1), d = Yt(), ce = Qt(), Fe = Ht(e.field), G = L(null), P = Pt(), ue = L(null), Ce = L(!1), Re = L({
353
353
  required: !1,
354
354
  hasError: !1
355
355
  });
356
356
  ae(() => {
357
- const t = Ce.current ? rn(ue.current) : null;
358
- if (!t || (ln(t, { ...Re.current, errorId: `${P}-error` }), t.hasAttribute("aria-label"))) return;
357
+ const t = Ce.current ? ln(ue.current) : null;
358
+ if (!t || (an(t, { ...Re.current, errorId: `${P}-error` }), t.hasAttribute("aria-label"))) return;
359
359
  t.id || (t.id = `${P}-control`);
360
360
  const r = t.tagName === "BUTTON" ? `${P} ${t.id}` : P;
361
361
  t.getAttribute("aria-labelledby") !== r && t.setAttribute("aria-labelledby", r);
@@ -385,7 +385,7 @@ const vr = Et(function({
385
385
  menu: at,
386
386
  confirmSaveFrom: ot,
387
387
  openedBy: me
388
- } = Yt({
388
+ } = Jt({
389
389
  wrapperRef: G,
390
390
  field: e,
391
391
  value: i[e.field],
@@ -394,10 +394,10 @@ const vr = Et(function({
394
394
  itemId: l,
395
395
  openRelated: d == null ? void 0 : d.openRelated,
396
396
  editable: Te
397
- }), j = Jt(G), it = xn(), Ee = d == null ? void 0 : d.remoteChanges[e.field], D = d == null ? void 0 : d.lockReasons[e.field], T = d == null ? void 0 : d.applyToLines[e.field], R = Rn(), st = (R == null ? void 0 : R.applied(e.field)) ?? !1, Pe = (R == null ? void 0 : R.hintFor(e.field)) ?? null, pe = pn(R, e.field, Te), he = () => {
397
+ }), j = Xt(G), it = yn(), Ee = d == null ? void 0 : d.remoteChanges[e.field], M = d == null ? void 0 : d.lockReasons[e.field], T = d == null ? void 0 : d.applyToLines[e.field], R = Ln(), st = (R == null ? void 0 : R.applied(e.field)) ?? !1, Pe = (R == null ? void 0 : R.hintFor(e.field)) ?? null, pe = hn(R, e.field, Te), he = () => {
398
398
  var t, r;
399
399
  return ((t = ue.current) == null ? void 0 : t.querySelector(Je)) ?? ((r = G.current) == null ? void 0 : r.querySelector(Je));
400
- }, Y = Bt(e._overrides, o, Tn(e)), fe = !!(d != null && d.fromAutofill) && !!e._overrides && e._overrides[Mt] === !0;
400
+ }, Y = Bt(e._overrides, o, En(e)), fe = !!(d != null && d.fromAutofill) && !!e._overrides && e._overrides[Dt] === !0;
401
401
  async function dt() {
402
402
  var t;
403
403
  if (Y.perField) return ct();
@@ -419,7 +419,7 @@ const vr = Et(function({
419
419
  async function ct() {
420
420
  var r, c, k, S;
421
421
  const t = {};
422
- for (const _ of ((r = Dt(e._overrides)) == null ? void 0 : r.tokens) ?? []) _ in i && (t[_] = i[_]);
422
+ for (const _ of ((r = Mt(e._overrides)) == null ? void 0 : r.tokens) ?? []) _ in i && (t[_] = i[_]);
423
423
  z(!0);
424
424
  try {
425
425
  const _ = await de.request(
@@ -438,7 +438,7 @@ const vr = Et(function({
438
438
  z(!1);
439
439
  }
440
440
  }
441
- const E = an(e.dependency_config), je = E.flatMap((t) => {
441
+ const E = on(e.dependency_config), je = E.flatMap((t) => {
442
442
  const r = x.find(
443
443
  (k) => k.one_collection === s && k.one_field === t.parent_field
444
444
  );
@@ -470,15 +470,15 @@ const vr = Et(function({
470
470
  (((_ = ut[c]) == null ? void 0 : _.data) ?? []).filter((F) => !S.has(F.id)).map((F) => F[r.junction_field])
471
471
  ];
472
472
  })
473
- ), J = Vt()[e.field] ?? [];
474
- if (!et && (!g || !e.layout_assigned && (e.hidden || on.has(e.field))))
473
+ ), J = zt()[e.field] ?? [];
474
+ if (!et && (!g || !e.layout_assigned && (e.hidden || sn.has(e.field))))
475
475
  return null;
476
- const xe = i[e.field] ?? null, X = yn(e, it), C = X.label ?? U(e.field);
476
+ const xe = i[e.field] ?? null, X = bn(e, it), C = X.label ?? U(e.field);
477
477
  Ce.current = C !== "", Re.current = {
478
478
  required: !!(e.required || Qe(e.validation_rules, i)),
479
479
  hasError: !!w
480
480
  };
481
- const q = Xe(e), Be = q ? null : bn(e), Me = q || !(l === "new" || !l || (Ue = N == null ? void 0 : N.dirtyFields) != null && Ue.has(e.field)) ? null : Cn(e, i), pt = !q && !p && !e.readonly && ((He = e._overrides) == null ? void 0 : He.repeat_last) === !0, ht = un(e, i), ft = (Ve = (We = sn(e.options)) == null ? void 0 : We.auto_id) == null ? void 0 : Ve.pattern, v = (() => {
481
+ const q = Xe(e), Be = q ? null : gn(e), De = q || !(l === "new" || !l || (Ue = N == null ? void 0 : N.dirtyFields) != null && Ue.has(e.field)) ? null : Rn(e, i), pt = !q && !p && !e.readonly && ((He = e._overrides) == null ? void 0 : He.repeat_last) === !0, ht = mn(e, i), ft = (Ve = (We = dn(e.options)) == null ? void 0 : We.auto_id) == null ? void 0 : Ve.pattern, v = (() => {
482
482
  const t = x.find(
483
483
  (c) => c.one_collection === s && c.one_field === e.field
484
484
  );
@@ -490,15 +490,15 @@ const vr = Et(function({
490
490
  return r ? { ...t, junction_field: r.many_field } : null;
491
491
  })(), ye = v ? null : x.find((t) => t.many_collection === s && t.many_field === e.field) ?? null, be = v ? x.find(
492
492
  (t) => t.many_collection === v.many_collection && t.many_field === v.junction_field && t.id !== v.id
493
- ) ?? null : null, B = v ? v.one_field ?? `${v.many_collection}.${v.junction_field}` : null, De = B ? (y == null ? void 0 : y.getStagedLinks(B)) ?? [] : [], xt = v ? (_e.getQueryData([
493
+ ) ?? null : null, B = v ? v.one_field ?? `${v.many_collection}.${v.junction_field}` : null, Me = B ? (y == null ? void 0 : y.getStagedLinks(B)) ?? [] : [], xt = v ? (_e.getQueryData([
494
494
  "m2m-items",
495
495
  v.many_collection,
496
496
  v.many_field,
497
497
  l
498
- ]) ?? []).map((t) => t[v.junction_field]) : [], Oe = v ? De[0] ?? xt[0] ?? null : xe, yt = (be == null ? void 0 : be.one_collection) ?? (ye == null ? void 0 : ye.one_collection) ?? void 0, Z = (t) => {
498
+ ]) ?? []).map((t) => t[v.junction_field]) : [], Oe = v ? Me[0] ?? xt[0] ?? null : xe, yt = (be == null ? void 0 : be.one_collection) ?? (ye == null ? void 0 : ye.one_collection) ?? void 0, Z = (t) => {
499
499
  var r;
500
500
  return ((N == null ? void 0 : N.collection) === s ? (r = N == null ? void 0 : N.fieldLabels) == null ? void 0 : r[t] : void 0) ?? U(String(t));
501
- }, A = dn({
501
+ }, A = cn({
502
502
  rules: E,
503
503
  // A parent whose value THIS field's own pick derived must not narrow this
504
504
  // field's options — otherwise picking a region locks the region picker
@@ -526,9 +526,9 @@ const vr = Et(function({
526
526
  parentOptionFilter: (t) => {
527
527
  var c;
528
528
  const r = (N == null ? void 0 : N.collection) === s ? (c = N.fieldOptionFilters) == null ? void 0 : c[t] : void 0;
529
- return r ? Ln(r, i, l) : void 0;
529
+ return r ? Sn(r, i, l) : void 0;
530
530
  }
531
- }), O = A.filter ? Nn(nt, A.filter, Fn) : A.filter, K = A.satisfiedParents.map(Z), I = A.satisfiedParents, bt = A.unsatisfiedParents.length ? Z(A.unsatisfiedParents[0]) : null, ge = A.missingRequiredParents, Ke = ge.length ? Z(ge[0]) : null;
531
+ }), O = A.filter ? Fn(nt, A.filter, Cn) : A.filter, K = A.satisfiedParents.map(Z), I = A.satisfiedParents, bt = A.unsatisfiedParents.length ? Z(A.unsatisfiedParents[0]) : null, ge = A.missingRequiredParents, Ke = ge.length ? Z(ge[0]) : null;
532
532
  function gt() {
533
533
  const t = Ae.current;
534
534
  if (t && t.src === e) return t.value;
@@ -536,7 +536,7 @@ const vr = Et(function({
536
536
  return Ae.current = { src: e, value: r }, r;
537
537
  }
538
538
  function vt() {
539
- const t = En(
539
+ const t = Pn(
540
540
  I,
541
541
  e.field,
542
542
  y == null ? void 0 : y.getDerivedOrigin
@@ -569,7 +569,7 @@ const vr = Et(function({
569
569
  label: C || U(e.field),
570
570
  parents: E.map((r) => r.parent_field).filter(Boolean)
571
571
  })), v && B) {
572
- for (const c of De) y == null || y.unstageLink(B, c);
572
+ for (const c of Me) y == null || y.unstageLink(B, c);
573
573
  const r = _e.getQueryData([
574
574
  "m2m-items",
575
575
  v.many_collection,
@@ -590,7 +590,7 @@ const vr = Et(function({
590
590
  "data-field-collection": s,
591
591
  "data-field-interface": e.interface ?? void 0,
592
592
  "data-autofill-check": fe ? "" : void 0,
593
- className: M(
593
+ className: D(
594
594
  "group/fieldrow space-y-1.5",
595
595
  fe && "rounded-md bg-amber-50/60 p-1.5 ring-1 ring-amber-300 dark:bg-amber-500/10 dark:ring-amber-500/40"
596
596
  ),
@@ -600,7 +600,7 @@ const vr = Et(function({
600
600
  children: [
601
601
  at,
602
602
  E.length > 0 && /* @__PURE__ */ n(
603
- cn,
603
+ un,
604
604
  {
605
605
  cascadeRules: E,
606
606
  cascadeFilter: O,
@@ -616,18 +616,18 @@ const vr = Et(function({
616
616
  className: "flex flex-wrap items-center gap-1.5 min-h-[1.5rem]",
617
617
  "data-pd-row": pe ? "" : void 0,
618
618
  children: [
619
- C !== "" && /* @__PURE__ */ u(Wt, { id: P, "data-field-label": !0, className: "text-sm font-medium", children: [
619
+ C !== "" && /* @__PURE__ */ u(Vt, { id: P, "data-field-label": !0, className: "text-sm font-medium", children: [
620
620
  /* @__PURE__ */ n(Ye, { text: C, collection: s }),
621
621
  (e.required || Qe(e.validation_rules, i)) && /* @__PURE__ */ n("span", { className: "ml-0.5 text-destructive", children: "*" }),
622
- gn(e) && /* @__PURE__ */ n(vn, {})
622
+ vn(e) && /* @__PURE__ */ n(wn, {})
623
623
  ] }),
624
624
  X.note && /* @__PURE__ */ n(ee, { delayDuration: 100, children: /* @__PURE__ */ u(te, { children: [
625
625
  /* @__PURE__ */ n(ne, { asChild: !0, children: /* @__PURE__ */ n(Ft, { className: "h-3.5 w-3.5 shrink-0 cursor-help text-slate-400 hover:text-slate-600" }) }),
626
626
  /* @__PURE__ */ n(re, { side: "top", className: "max-w-[240px] text-[12px]", children: (d == null ? void 0 : d.glossaryHelp) === !1 ? X.note : /* @__PURE__ */ n(Ye, { text: X.note, collection: s }) })
627
627
  ] }) }),
628
- Fe && /* @__PURE__ */ n(Ht, { source: Fe, label: C }),
628
+ Fe && /* @__PURE__ */ n(Wt, { source: Fe, label: C }),
629
629
  !q && l && l !== "new" && /* @__PURE__ */ n(
630
- Bn,
630
+ Dn,
631
631
  {
632
632
  collection: s,
633
633
  itemId: l,
@@ -636,10 +636,10 @@ const vr = Et(function({
636
636
  }
637
637
  ),
638
638
  !q && l && l !== "new" && /* @__PURE__ */ n(Mn, { collection: s, itemId: l, field: e.field }),
639
- !q && l && l !== "new" && /* @__PURE__ */ n(en, { field: e.field, label: C || U(e.field) }),
640
- l && l !== "new" && ht && /* @__PURE__ */ n(jn, { collection: s, itemId: l, field: e.field }),
639
+ !q && l && l !== "new" && /* @__PURE__ */ n(tn, { field: e.field, label: C || U(e.field) }),
640
+ l && l !== "new" && ht && /* @__PURE__ */ n(Bn, { collection: s, itemId: l, field: e.field }),
641
641
  pt && /* @__PURE__ */ n(
642
- wn,
642
+ kn,
643
643
  {
644
644
  collection: s,
645
645
  itemId: l,
@@ -710,7 +710,7 @@ const vr = Et(function({
710
710
  ] })
711
711
  ] }) }),
712
712
  /* @__PURE__ */ n(
713
- nn,
713
+ rn,
714
714
  {
715
715
  collection: s,
716
716
  kind: "field",
@@ -718,7 +718,7 @@ const vr = Et(function({
718
718
  label: C
719
719
  }
720
720
  ),
721
- (p || e.readonly) && D ? /* @__PURE__ */ n(Xt, { reason: D, onHover: d == null ? void 0 : d.onLockHover }) : p ? /* @__PURE__ */ n(ee, { delayDuration: 200, children: /* @__PURE__ */ u(te, { children: [
721
+ (p || e.readonly) && M ? /* @__PURE__ */ n(Zt, { reason: M, onHover: d == null ? void 0 : d.onLockHover }) : p ? /* @__PURE__ */ n(ee, { delayDuration: 200, children: /* @__PURE__ */ u(te, { children: [
722
722
  /* @__PURE__ */ n(ne, { asChild: !0, children: /* @__PURE__ */ n("span", { className: "inline-flex items-center text-amber-400 dark:text-amber-500", children: /* @__PURE__ */ n(Lt, { className: "h-3 w-3" }) }) }),
723
723
  /* @__PURE__ */ n(re, { side: "top", className: "text-[12px]", children: "This field is locked" })
724
724
  ] }) }) : null,
@@ -733,7 +733,7 @@ const vr = Et(function({
733
733
  type: "button",
734
734
  "aria-label": `Show the fields that narrow ${C || "this list"}`,
735
735
  onClick: wt,
736
- className: M(
736
+ className: D(
737
737
  "inline-flex items-center transition-colors",
738
738
  t ? "text-nvr-cyan hover:text-nvr-cyan" : "text-slate-300 hover:text-nvr-cyan dark:text-slate-600 dark:hover:text-nvr-cyan"
739
739
  ),
@@ -748,7 +748,7 @@ const vr = Et(function({
748
748
  // Shift+F10 still open the field menu). The slot keeps one box whatever it shows,
749
749
  // so nothing to its left moves.
750
750
  /* @__PURE__ */ n("span", { className: "ml-auto inline-flex shrink-0 items-center gap-1", children: /* @__PURE__ */ n(
751
- hn,
751
+ fn,
752
752
  {
753
753
  field: e.field,
754
754
  label: C,
@@ -777,7 +777,7 @@ const vr = Et(function({
777
777
  }
778
778
  ),
779
779
  j.editor && !p && /* @__PURE__ */ n(
780
- Zt,
780
+ It,
781
781
  {
782
782
  editor: j.editor,
783
783
  confirming: j.confirming,
@@ -789,14 +789,14 @@ const vr = Et(function({
789
789
  "div",
790
790
  {
791
791
  ref: ue,
792
- className: M(p && !V && "cursor-not-allowed"),
793
- "data-tip": (p || e.readonly) && D ? D : void 0,
794
- onPointerEnter: (p || e.readonly) && D ? d == null ? void 0 : d.onLockHover : void 0,
792
+ className: D(p && !V && "cursor-not-allowed"),
793
+ "data-tip": (p || e.readonly) && M ? M : void 0,
794
+ onPointerEnter: (p || e.readonly) && M ? d == null ? void 0 : d.onLockHover : void 0,
795
795
  children: /* @__PURE__ */ n(
796
796
  "div",
797
797
  {
798
798
  ref: Se,
799
- className: M(
799
+ className: D(
800
800
  // A locked FILE field stays interactive: its chips keep the
801
801
  // download link and preview click (the component itself hides
802
802
  // upload/replace/remove when readonly) — blocking pointer events
@@ -808,8 +808,8 @@ const vr = Et(function({
808
808
  w && "nvr-shake ring-1 ring-red-400 rounded-md",
809
809
  se && "nvr-autofill-glow"
810
810
  ),
811
- children: q ? /* @__PURE__ */ n(kn, { field: e, values: i }) : ft ? /* @__PURE__ */ n(
812
- zt,
811
+ children: q ? /* @__PURE__ */ n(_n, { field: e, values: i }) : ft ? /* @__PURE__ */ n(
812
+ Gt,
813
813
  {
814
814
  collection: s,
815
815
  field: e,
@@ -828,7 +828,7 @@ const vr = Et(function({
828
828
  unsatisfiedParentLabel: bt,
829
829
  requiredParentLabel: Ke
830
830
  }) : /* @__PURE__ */ n(
831
- tn,
831
+ nn,
832
832
  {
833
833
  field: p && V ? gt() : e,
834
834
  value: xe,
@@ -847,7 +847,7 @@ const vr = Et(function({
847
847
  )
848
848
  }
849
849
  ),
850
- Be && /* @__PURE__ */ n(_n, { value: i[e.field], config: Be }),
850
+ Be && /* @__PURE__ */ n(Nn, { value: i[e.field], config: Be }),
851
851
  w && // The message under the field: a red border alone never said WHY (Service End before
852
852
  // Start, b01-N5). The form's summary at the top lists it too — and is
853
853
  // the ONE live announcement (army11 f3: ten role=alert regions fired at
@@ -861,18 +861,18 @@ const vr = Et(function({
861
861
  children: w
862
862
  }
863
863
  ),
864
- !w && Me && // A soft (warning-only) rule the value breaks: said here, never blocks the save.
864
+ !w && De && // A soft (warning-only) rule the value breaks: said here, never blocks the save.
865
865
  /* @__PURE__ */ n(
866
866
  "p",
867
867
  {
868
868
  "data-field-warning": e.field,
869
869
  className: "text-[11.5px] leading-snug text-amber-700 dark:text-amber-400",
870
- children: Me
870
+ children: De
871
871
  }
872
872
  ),
873
- Pe && !st && /* @__PURE__ */ n(fn, { field: e.field, text: Pe }),
873
+ Pe && !st && /* @__PURE__ */ n(xn, { field: e.field, text: Pe }),
874
874
  Ee && /* @__PURE__ */ n(
875
- It,
875
+ en,
876
876
  {
877
877
  change: Ee,
878
878
  onDismiss: () => d == null ? void 0 : d.dismissRemoteChange(e.field),
@@ -888,9 +888,9 @@ const vr = Et(function({
888
888
  );
889
889
  });
890
890
  export {
891
- vr as FieldRow,
892
- En as clearableParents,
893
- Tn as isAiEligible,
894
- gr as lineageSummary,
895
- Pn as useFieldLineage
891
+ wr as FieldRow,
892
+ Pn as clearableParents,
893
+ En as isAiEligible,
894
+ vr as lineageSummary,
895
+ jn as useFieldLineage
896
896
  };
@@ -0,0 +1,94 @@
1
+ import { jsxs as i, jsx as r } from "react/jsx-runtime";
2
+ import { useQuery as u } from "@tanstack/react-query";
3
+ import { Users as p } from "lucide-react";
4
+ import { useId as h } from "react";
5
+ import { useNivaroClient as x, useItemEditAuth as f } from "../../context.js";
6
+ import { get as w } from "../../lib/commands.js";
7
+ import { formatRelative as g, formatDateTime as b } from "../../lib/utils.js";
8
+ import { Popover as $, PopoverTrigger as k, PopoverContent as y } from "../ui/popover.js";
9
+ function S(t, o, l, n) {
10
+ const a = x(), { isAdmin: e } = f(), d = [...new Set(l.filter(Boolean))].sort(), s = o != null ? String(o) : "", m = e && n && !!t && !!s && s !== "new" && d.length > 0;
11
+ return u({
12
+ queryKey: ["file-download-stats", t, s, ...d],
13
+ queryFn: () => a.request(
14
+ w("/file-downloads/on-record", { collection: t, item: s, ids: d.join(",") })
15
+ ).then((c) => c.data ?? {}),
16
+ enabled: m,
17
+ staleTime: 6e4,
18
+ retry: !1
19
+ });
20
+ }
21
+ function N(t) {
22
+ if (!t || t.count === 0) return "Not downloaded from this record yet";
23
+ const o = `Downloaded ${t.count} time${t.count === 1 ? "" : "s"}`, l = t.people.slice(0, 4).map((a) => `${a.name} (${a.count})`), n = t.people.length > 4 ? `, +${t.people.length - 4} more` : "";
24
+ return `${o}: ${l.join(", ")}${n}`;
25
+ }
26
+ function A({
27
+ fileId: t,
28
+ stat: o
29
+ }) {
30
+ const l = h(), n = (o == null ? void 0 : o.count) ?? 0;
31
+ if (n === 0) return null;
32
+ const a = N(o);
33
+ return /* @__PURE__ */ i($, { children: [
34
+ /* @__PURE__ */ r(k, { asChild: !0, children: /* @__PURE__ */ i(
35
+ "button",
36
+ {
37
+ type: "button",
38
+ "data-file-downloads-open": t,
39
+ "data-tip": a,
40
+ "aria-label": `${n} download${n === 1 ? "" : "s"}: ${a}`,
41
+ onClick: (e) => e.stopPropagation(),
42
+ className: "inline-flex h-6 shrink-0 items-center gap-1 rounded px-1.5 text-[11px] tabular-nums text-slate-600 transition-colors hover:bg-slate-500/10 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white",
43
+ children: [
44
+ /* @__PURE__ */ r(p, { className: "h-3 w-3", "aria-hidden": "true" }),
45
+ /* @__PURE__ */ r("span", { "data-file-downloads-count": n, children: n })
46
+ ]
47
+ }
48
+ ) }),
49
+ /* @__PURE__ */ i(
50
+ y,
51
+ {
52
+ align: "end",
53
+ "aria-labelledby": l,
54
+ className: "w-[300px] p-2 text-[12px]",
55
+ onClick: (e) => e.stopPropagation(),
56
+ children: [
57
+ /* @__PURE__ */ r(
58
+ "p",
59
+ {
60
+ id: l,
61
+ className: "mb-1 px-1 text-[11px] font-medium text-slate-600 dark:text-slate-300",
62
+ children: "Downloaded from this record"
63
+ }
64
+ ),
65
+ /* @__PURE__ */ r("ul", { className: "max-h-72 space-y-0.5 overflow-y-auto", children: o.people.map((e) => /* @__PURE__ */ i(
66
+ "li",
67
+ {
68
+ "data-file-download-person": e.user,
69
+ className: "flex items-baseline gap-2 rounded px-1 py-1 hover:bg-muted",
70
+ children: [
71
+ /* @__PURE__ */ r("span", { className: "min-w-0 flex-1 truncate text-slate-800 dark:text-foreground", children: e.name }),
72
+ /* @__PURE__ */ r("span", { className: "shrink-0 tabular-nums text-slate-600 dark:text-slate-300", children: e.count === 1 ? "once" : `${e.count} times` }),
73
+ /* @__PURE__ */ r(
74
+ "span",
75
+ {
76
+ className: "shrink-0 text-[11px] text-slate-600 dark:text-slate-300",
77
+ "data-tip": b(e.last),
78
+ children: g(e.last)
79
+ }
80
+ )
81
+ ]
82
+ },
83
+ e.user || e.name
84
+ )) })
85
+ ]
86
+ }
87
+ )
88
+ ] });
89
+ }
90
+ export {
91
+ A as FileDownloadCount,
92
+ N as downloadTip,
93
+ S as useFileDownloadStats
94
+ };