@nivaro/react 0.3.46 → 0.3.47

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 (57) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +248 -16
  4. package/dist/index.js +679 -659
  5. package/dist/shared/components/CollectionBrowserView.js +813 -826
  6. package/dist/shared/components/ErrorNotice.js +169 -0
  7. package/dist/shared/components/ErrorSurface.js +23 -17
  8. package/dist/shared/components/ListLoadError.js +8 -29
  9. package/dist/shared/components/LoadErrorNote.js +38 -21
  10. package/dist/shared/components/QueryErrorState.js +8 -11
  11. package/dist/shared/components/ReportView.js +1320 -1291
  12. package/dist/shared/components/chat/ChannelArchive.js +60 -60
  13. package/dist/shared/components/chat/ChannelExtras.js +74 -74
  14. package/dist/shared/components/chat/ChatPanel.js +368 -367
  15. package/dist/shared/components/command-center/PeekPanel.js +33 -32
  16. package/dist/shared/components/command-center/panels/BoardSettings.js +41 -40
  17. package/dist/shared/components/command-center/panels/PeoplePanel.js +32 -31
  18. package/dist/shared/components/help-videos/editor/ClipsPanel.js +49 -48
  19. package/dist/shared/components/help-videos/editor/PublishButton.js +37 -36
  20. package/dist/shared/components/help-videos/editor/StatsTab.js +45 -44
  21. package/dist/shared/components/help-videos/editor/VersionsTab.js +29 -28
  22. package/dist/shared/components/help-videos/library/AuthorRolesButton.js +19 -18
  23. package/dist/shared/components/help-videos/library/HelpVideoLibrary.js +132 -129
  24. package/dist/shared/components/help-videos/library/LearningPathsPanel.js +42 -41
  25. package/dist/shared/components/help-videos/settings/HouseStyleButton.js +21 -20
  26. package/dist/shared/components/help-videos/settings/RenderSettingsButton.js +22 -21
  27. package/dist/shared/components/import/DocumentAutofillButton.js +24 -20
  28. package/dist/shared/components/import/ImportFromFileButton.js +61 -60
  29. package/dist/shared/components/imports/ImportStalenessControl.js +20 -21
  30. package/dist/shared/components/imports/NewImportDialog.js +29 -28
  31. package/dist/shared/components/imports/RunDetailSheet.js +63 -63
  32. package/dist/shared/components/item-edit/FieldRow.js +329 -329
  33. package/dist/shared/components/item-edit/InlineTableField.js +898 -898
  34. package/dist/shared/components/item-edit/PersonalDefaultControl.js +57 -56
  35. package/dist/shared/components/item-edit/PlanGrid.js +220 -221
  36. package/dist/shared/components/item-edit/RecordGrantTools.js +49 -48
  37. package/dist/shared/components/item-edit/placement-behaviour.js +68 -67
  38. package/dist/shared/components/layout-editor/inspector/ColumnFit.js +24 -23
  39. package/dist/shared/components/layout-editor/inspector/PickerPreview.js +17 -16
  40. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +41 -41
  41. package/dist/shared/components/layout-editor/outputs/output-api.js +33 -31
  42. package/dist/shared/components/layout-editor/overview/overview-api.js +84 -83
  43. package/dist/shared/components/layout-editor/useLayoutDraft.js +47 -42
  44. package/dist/shared/components/monitoring/InactiveUserLinksView.js +10 -9
  45. package/dist/shared/components/panels/SlaClock.js +35 -36
  46. package/dist/shared/components/pipeline/PipelineEditorView.js +311 -312
  47. package/dist/shared/components/pipeline/TeamSuggestions.js +31 -30
  48. package/dist/shared/components/profile/AgentsPanel.js +73 -72
  49. package/dist/shared/components/profile/MailSuppressedPill.js +22 -21
  50. package/dist/shared/components/support/SupportRequestDialog.js +85 -81
  51. package/dist/shared/components/support/SupportView.js +94 -87
  52. package/dist/shared/lib/autofill-poll.js +21 -18
  53. package/dist/shared/lib/error-actions.js +85 -0
  54. package/dist/shared/lib/error-message.js +223 -82
  55. package/dist/shared/lib/error-toast.js +71 -13
  56. package/dist/shared/lib/safe-error.js +136 -38
  57. package/package.json +1 -1
@@ -1,48 +1,49 @@
1
1
  import { jsxs as n, jsx as t } from "react/jsx-runtime";
2
2
  import { useQueryClient as D, useQuery as I, useMutation as q } from "@tanstack/react-query";
3
3
  import { Loader2 as K, EyeOff as L, CalendarClock as Q, ChevronsUpDown as j, Check as H } from "lucide-react";
4
- import { useState as m, useId as A, useMemo as B } from "react";
5
- import { toast as x } from "sonner";
4
+ import { useState as m, useId as M, useMemo as A } from "react";
5
+ import { toast as g } from "sonner";
6
6
  import { useNivaroClient as F } from "../../context.js";
7
- import { get as M, post as O } from "../../lib/commands.js";
8
- import { titleCase as U, cn as V } from "../../lib/utils.js";
9
- import { PICKER_EXCLUSIONS_PAGE_KEY as W } from "../PickerExcludedRows.js";
7
+ import { get as B, post as O } from "../../lib/commands.js";
8
+ import { userErrorMessage as U } from "../../lib/safe-error.js";
9
+ import { titleCase as V, cn as W } from "../../lib/utils.js";
10
+ import { PICKER_EXCLUSIONS_PAGE_KEY as z } from "../PickerExcludedRows.js";
10
11
  import { Button as S } from "../ui/button.js";
11
- import { Command as z, CommandInput as G, CommandList as R, CommandEmpty as X, CommandItem as Y } from "../ui/command.js";
12
+ import { Command as G, CommandInput as R, CommandList as X, CommandEmpty as Y, CommandItem as J } from "../ui/command.js";
12
13
  import { Input as w } from "../ui/input.js";
13
14
  import { Popover as E, PopoverTrigger as _, PopoverContent as P } from "../ui/popover.js";
14
- function $(a, r) {
15
- return a instanceof Error && a.message ? a.message : r;
15
+ function $(i, l) {
16
+ return U(i, l);
16
17
  }
17
- function J(a, r, l = {}) {
18
- const o = F(), s = D(), h = ["picker-exclusion", a, r], { data: c, isLoading: p } = I({
18
+ function Z(i, l, r = {}) {
19
+ const o = F(), s = D(), h = ["picker-exclusion", i, l], { data: c, isLoading: p } = I({
19
20
  queryKey: h,
20
21
  queryFn: () => o.request(
21
- M(`/picker-exclusions/status/${a}/${r}`)
22
- ).then((i) => i.data),
23
- enabled: l.enabled ?? !0,
22
+ B(`/picker-exclusions/status/${i}/${l}`)
23
+ ).then((a) => a.data),
24
+ enabled: r.enabled ?? !0,
24
25
  staleTime: 6e4
25
26
  }), d = (c == null ? void 0 : c.excluded) ?? !1, u = q({
26
27
  mutationFn: () => {
27
- const i = { collection: a, item_id: r, layout: l.layoutSlug ?? null };
28
+ const a = { collection: i, item_id: l, layout: r.layoutSlug ?? null };
28
29
  return o.request(
29
- d ? { _method: "DELETE", _path: "/picker-exclusions", _body: i } : O("/picker-exclusions", i)
30
+ d ? { _method: "DELETE", _path: "/picker-exclusions", _body: a } : O("/picker-exclusions", a)
30
31
  );
31
32
  },
32
33
  onSuccess: () => {
33
- var i;
34
- s.invalidateQueries({ queryKey: h }), s.invalidateQueries({ queryKey: [W, a] }), x.success(d ? "Shown in pickers again" : "Hidden from pickers"), (i = l.onDone) == null || i.call(l);
34
+ var a;
35
+ s.invalidateQueries({ queryKey: h }), s.invalidateQueries({ queryKey: [z, i] }), g.success(d ? "Shown in pickers again" : "Hidden from pickers"), (a = r.onDone) == null || a.call(r);
35
36
  },
36
- onError: (i) => x.error($(i, "Could not change picker visibility"))
37
+ onError: (a) => g.error($(a, "Could not change picker visibility"))
37
38
  });
38
39
  return { excluded: d, isLoading: p, toggle: u };
39
40
  }
40
- function me({
41
- collection: a,
42
- itemId: r,
43
- layoutSlug: l
41
+ function pe({
42
+ collection: i,
43
+ itemId: l,
44
+ layoutSlug: r
44
45
  }) {
45
- const { excluded: o, toggle: s } = J(a, r, { layoutSlug: l });
46
+ const { excluded: o, toggle: s } = Z(i, l, { layoutSlug: r });
46
47
  return /* @__PURE__ */ n(
47
48
  "button",
48
49
  {
@@ -60,20 +61,20 @@ function me({
60
61
  }
61
62
  );
62
63
  }
63
- function he({
64
- collection: a,
65
- itemId: r,
66
- fields: l,
64
+ function fe({
65
+ collection: i,
66
+ itemId: l,
67
+ fields: r,
67
68
  layoutSlug: o
68
69
  }) {
69
- const s = F(), [h, c] = m(!1), [p, d] = m(!1), [u, i] = m(""), [b, N] = m(""), [f, C] = m(""), g = A(), k = B(
70
- () => l.filter((e) => !e.field.startsWith("__") && !e.field.includes(".")).map((e) => ({ field: e.field, label: e.label || U(e.field) })),
71
- [l]
70
+ const s = F(), [h, c] = m(!1), [p, d] = m(!1), [u, a] = m(""), [b, N] = m(""), [f, C] = m(""), x = M(), k = A(
71
+ () => r.filter((e) => !e.field.startsWith("__") && !e.field.includes(".")).map((e) => ({ field: e.field, label: e.label || V(e.field) })),
72
+ [r]
72
73
  ), y = k.find((e) => e.field === u), v = q({
73
74
  mutationFn: () => s.request(
74
75
  O("/scheduled-changes", {
75
- collection: a,
76
- item_id: r,
76
+ collection: i,
77
+ item_id: l,
77
78
  change_type: "field_update",
78
79
  changes: { [u]: b },
79
80
  // datetime-local is the viewer's local time; the API stores UTC.
@@ -82,9 +83,9 @@ function he({
82
83
  })
83
84
  ),
84
85
  onSuccess: () => {
85
- c(!1), i(""), N(""), C(""), x.success("Change scheduled");
86
+ c(!1), a(""), N(""), C(""), g.success("Change scheduled");
86
87
  },
87
- onError: (e) => x.error($(e, "Could not schedule the change"))
88
+ onError: (e) => g.error($(e, "Could not schedule the change"))
88
89
  }), T = f !== "" && !Number.isNaN(new Date(f).getTime());
89
90
  return /* @__PURE__ */ n(E, { open: h, onOpenChange: c, children: [
90
91
  /* @__PURE__ */ t(_, { asChild: !0, children: /* @__PURE__ */ n(
@@ -121,23 +122,23 @@ function he({
121
122
  ]
122
123
  }
123
124
  ) }),
124
- /* @__PURE__ */ t(P, { className: "w-[--radix-popover-trigger-width] p-0", align: "start", children: /* @__PURE__ */ n(z, { children: [
125
- /* @__PURE__ */ t(G, { placeholder: "Search fields…", className: "h-8 text-[12px]" }),
126
- /* @__PURE__ */ n(R, { children: [
127
- /* @__PURE__ */ t(X, { className: "py-3 text-center text-[12px] text-muted-foreground", children: "No field matches" }),
125
+ /* @__PURE__ */ t(P, { className: "w-[--radix-popover-trigger-width] p-0", align: "start", children: /* @__PURE__ */ n(G, { children: [
126
+ /* @__PURE__ */ t(R, { placeholder: "Search fields…", className: "h-8 text-[12px]" }),
127
+ /* @__PURE__ */ n(X, { children: [
128
+ /* @__PURE__ */ t(Y, { className: "py-3 text-center text-[12px] text-muted-foreground", children: "No field matches" }),
128
129
  k.map((e) => /* @__PURE__ */ n(
129
- Y,
130
+ J,
130
131
  {
131
132
  value: `${e.label} ${e.field}`,
132
133
  onSelect: () => {
133
- i(e.field), d(!1);
134
+ a(e.field), d(!1);
134
135
  },
135
136
  className: "text-[12px]",
136
137
  children: [
137
138
  /* @__PURE__ */ t(
138
139
  H,
139
140
  {
140
- className: V(
141
+ className: W(
141
142
  "mr-2 h-3.5 w-3.5",
142
143
  u === e.field ? "opacity-100" : "opacity-0"
143
144
  )
@@ -157,7 +158,7 @@ function he({
157
158
  /* @__PURE__ */ t(
158
159
  "label",
159
160
  {
160
- htmlFor: `${g}-value`,
161
+ htmlFor: `${x}-value`,
161
162
  className: "mb-1 block text-[11px] font-medium text-muted-foreground",
162
163
  children: "New value"
163
164
  }
@@ -165,7 +166,7 @@ function he({
165
166
  /* @__PURE__ */ t(
166
167
  w,
167
168
  {
168
- id: `${g}-value`,
169
+ id: `${x}-value`,
169
170
  value: b,
170
171
  onChange: (e) => N(e.target.value),
171
172
  className: "h-8 text-[12px]"
@@ -176,7 +177,7 @@ function he({
176
177
  /* @__PURE__ */ t(
177
178
  "label",
178
179
  {
179
- htmlFor: `${g}-at`,
180
+ htmlFor: `${x}-at`,
180
181
  className: "mb-1 block text-[11px] font-medium text-muted-foreground",
181
182
  children: "When"
182
183
  }
@@ -184,7 +185,7 @@ function he({
184
185
  /* @__PURE__ */ t(
185
186
  w,
186
187
  {
187
- id: `${g}-at`,
188
+ id: `${x}-at`,
188
189
  type: "datetime-local",
189
190
  value: f,
190
191
  onChange: (e) => C(e.target.value),
@@ -208,7 +209,7 @@ function he({
208
209
  ] });
209
210
  }
210
211
  export {
211
- me as PickerExclusionToggle,
212
- he as ScheduleChangeButton,
213
- J as usePickerExclusion
212
+ pe as PickerExclusionToggle,
213
+ fe as ScheduleChangeButton,
214
+ Z as usePickerExclusion
214
215
  };
@@ -1,19 +1,20 @@
1
- import { jsx as s, jsxs as d } from "react/jsx-runtime";
1
+ import { jsx as s, jsxs as u } from "react/jsx-runtime";
2
2
  import { Loader2 as y, Repeat2 as v, Sigma as b } from "lucide-react";
3
3
  import { useContext as h, createContext as g, useState as k, useMemo as _ } from "react";
4
- import { toast as u } from "sonner";
4
+ import { toast as m } from "sonner";
5
5
  import { useNivaroClient as w } from "../../context.js";
6
6
  import { get as C } from "../../lib/commands.js";
7
- import { parseExpression as N, readPath as F, evaluateExpression as R } from "../../lib/expression.js";
8
- import { textRulesOf as $, isRecommended as T, resolvePlacementText as j, counterError as D, confirmChangeApplies as E, isEmptyValue as f, isDisplayFormulaField as S, counterOf as A, displayFormulaOf as c, formatDisplayValue as L, countValue as P, counterState as V } from "../../lib/placement-behaviour.js";
9
- import { cn as p, formatRelative as B } from "../../lib/utils.js";
10
- import { useFieldAffordances as O } from "./FieldAffordances.js";
11
- const q = g(null);
12
- function I() {
13
- const e = O(), o = h(q);
7
+ import { toastError as N } from "../../lib/error-toast.js";
8
+ import { parseExpression as F, readPath as R, evaluateExpression as $ } from "../../lib/expression.js";
9
+ import { textRulesOf as E, isRecommended as T, resolvePlacementText as j, counterError as D, confirmChangeApplies as S, isEmptyValue as f, isDisplayFormulaField as A, counterOf as L, displayFormulaOf as c, formatDisplayValue as P, countValue as V, counterState as B } from "../../lib/placement-behaviour.js";
10
+ import { cn as p, formatRelative as O } from "../../lib/utils.js";
11
+ import { useFieldAffordances as q } from "./FieldAffordances.js";
12
+ const M = g(null);
13
+ function te() {
14
+ const e = q(), o = h(M);
14
15
  return (e == null ? void 0 : e.placementText) ?? o;
15
16
  }
16
- function ee(e, o) {
17
+ function re(e, o) {
17
18
  const r = { label: e.label, note: e.note };
18
19
  if (!o || !e._overrides) return r;
19
20
  const t = j(e._overrides, o);
@@ -23,31 +24,31 @@ function ee(e, o) {
23
24
  note: t.note ?? r.note
24
25
  };
25
26
  }
26
- function te(e) {
27
+ function oe(e) {
27
28
  let o = !1, r = !1;
28
29
  for (const t of e) {
29
30
  if (!t._overrides) continue;
30
- for (const l of $(t._overrides))
31
- l.type === "role" ? o = !0 : r = !0;
31
+ for (const n of E(t._overrides))
32
+ n.type === "role" ? o = !0 : r = !0;
32
33
  const a = t._overrides.confirm_change;
33
34
  if (a && typeof a == "object" && Array.isArray(a.state_keys) && a.state_keys.length && (r = !0), o && r) break;
34
35
  }
35
36
  return { role: o, state: r };
36
37
  }
37
- const M = (e) => !e.required && T(e._overrides);
38
- function re(e, o, r, t) {
39
- return e.filter((a) => M(a) && !a.hidden && !a.readonly && r(a)).filter((a) => f(o[a.field])).map(t);
38
+ const z = (e) => !e.required && T(e._overrides);
39
+ function ae(e, o, r, t) {
40
+ return e.filter((a) => z(a) && !a.hidden && !a.readonly && r(a)).filter((a) => f(o[a.field])).map(t);
40
41
  }
41
- function oe(e, o, r) {
42
- return e.filter((t) => o.has(t.field) && E(t._overrides, r)).map((t) => t.field);
42
+ function ne(e, o, r) {
43
+ return e.filter((t) => o.has(t.field) && S(t._overrides, r)).map((t) => t.field);
43
44
  }
44
- function ae(e, o, r) {
45
+ function le(e, o, r) {
45
46
  return e._overrides ? D(o, e._overrides, r) : null;
46
47
  }
47
- function ne(e) {
48
- return e.interface === "display-formula" || S(e.field);
48
+ function ie(e) {
49
+ return e.interface === "display-formula" || A(e.field);
49
50
  }
50
- function le() {
51
+ function se() {
51
52
  return /* @__PURE__ */ s(
52
53
  "span",
53
54
  {
@@ -59,56 +60,56 @@ function le() {
59
60
  }
60
61
  );
61
62
  }
62
- function ie({
63
+ function ue({
63
64
  collection: e,
64
65
  itemId: o,
65
66
  field: r,
66
67
  label: t,
67
68
  onFill: a
68
69
  }) {
69
- const l = w(), [i, m] = k(!1), x = async () => {
70
- m(!0);
70
+ const n = w(), [l, d] = k(!1), x = async () => {
71
+ d(!0);
71
72
  try {
72
- const n = await l.request(
73
+ const i = await n.request(
73
74
  C("/revisions/my-last-value", {
74
75
  collection: e,
75
76
  field: r,
76
77
  ...o && o !== "new" ? { exclude: o } : {}
77
78
  })
78
79
  );
79
- if (!n.data) {
80
- u.info(`Nothing to repeat — you have not filled ${t} on another record yet`);
80
+ if (!i.data) {
81
+ m.info(`Nothing to repeat — you have not filled ${t} on another record yet`);
81
82
  return;
82
83
  }
83
- a(n.data.value), u.success(
84
- `Filled ${t} from your last record${n.data.at ? ` (${B(n.data.at)})` : ""}`
84
+ a(i.data.value), m.success(
85
+ `Filled ${t} from your last record${i.data.at ? ` (${O(i.data.at)})` : ""}`
85
86
  );
86
- } catch (n) {
87
- u.error((n == null ? void 0 : n.message) || "Could not read your last value");
87
+ } catch (i) {
88
+ N(i, "Could not read your last value");
88
89
  } finally {
89
- m(!1);
90
+ d(!1);
90
91
  }
91
92
  };
92
- return /* @__PURE__ */ d(
93
+ return /* @__PURE__ */ u(
93
94
  "button",
94
95
  {
95
96
  type: "button",
96
97
  onClick: () => void x(),
97
- disabled: i,
98
+ disabled: l,
98
99
  "data-repeat-last": r,
99
100
  "aria-label": `Repeat the last ${t} you entered`,
100
101
  "data-tip": "Fill in what you entered on your previous record",
101
102
  className: "inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10.5px] font-medium text-slate-500 transition-colors hover:bg-muted hover:text-slate-800 disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground",
102
103
  children: [
103
- i ? /* @__PURE__ */ s(y, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ s(v, { className: "h-3 w-3" }),
104
+ l ? /* @__PURE__ */ s(y, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ s(v, { className: "h-3 w-3" }),
104
105
  "Repeat last"
105
106
  ]
106
107
  }
107
108
  );
108
109
  }
109
- function se({ value: e, config: o }) {
110
- const r = P(e, o.unit), t = V(r, o.limit), a = o.unit === "words" ? r === 1 ? "word" : "words" : "characters";
111
- return /* @__PURE__ */ d(
110
+ function de({ value: e, config: o }) {
111
+ const r = V(e, o.unit), t = B(r, o.limit), a = o.unit === "words" ? r === 1 ? "word" : "words" : "characters";
112
+ return /* @__PURE__ */ u(
112
113
  "p",
113
114
  {
114
115
  "data-field-counter": t,
@@ -127,27 +128,27 @@ function se({ value: e, config: o }) {
127
128
  }
128
129
  );
129
130
  }
130
- function ue(e) {
131
- return e._overrides ? A(e._overrides) : null;
131
+ function me(e) {
132
+ return e._overrides ? L(e._overrides) : null;
132
133
  }
133
- function z(e, o) {
134
+ function G(e, o) {
134
135
  if (!e.trim()) return { value: null, error: "No formula yet" };
135
- const r = N(e);
136
+ const r = F(e);
136
137
  if (!r.ok) return { value: null, error: r.error };
137
- if (r.tokens.length && r.tokens.every((a) => f(F(o, a))))
138
+ if (r.tokens.length && r.tokens.every((a) => f(R(o, a))))
138
139
  return { value: null, error: null };
139
- const t = R(e, o);
140
+ const t = $(e, o);
140
141
  return typeof t == "boolean" ? { value: t ? 1 : 0, error: null } : { value: typeof t == "number" && Number.isFinite(t) ? t : null, error: null };
141
142
  }
142
- function de({
143
+ function ce({
143
144
  field: e,
144
145
  values: o
145
146
  }) {
146
147
  const r = _(() => {
147
- const i = e.options && typeof e.options == "object" ? e.options : null;
148
- return c(e._overrides) ?? c({ display_formula: i == null ? void 0 : i.display_formula });
149
- }, [e._overrides, e.options]), t = (r == null ? void 0 : r.expr) ?? "", { value: a, error: l } = z(t, o);
150
- return /* @__PURE__ */ d(
148
+ const l = e.options && typeof e.options == "object" ? e.options : null;
149
+ return c(e._overrides) ?? c({ display_formula: l == null ? void 0 : l.display_formula });
150
+ }, [e._overrides, e.options]), t = (r == null ? void 0 : r.expr) ?? "", { value: a, error: n } = G(t, o);
151
+ return /* @__PURE__ */ u(
151
152
  "div",
152
153
  {
153
154
  "data-display-formula": e.field,
@@ -158,9 +159,9 @@ function de({
158
159
  {
159
160
  className: p(
160
161
  "min-w-0 truncate text-sm tabular-nums",
161
- l ? "text-[12px] text-amber-700 dark:text-amber-300" : "font-medium text-slate-900 dark:text-foreground"
162
+ n ? "text-[12px] text-amber-700 dark:text-amber-300" : "font-medium text-slate-900 dark:text-foreground"
162
163
  ),
163
- children: l ? t.trim() ? "This formula needs fixing" : "No formula yet" : L(a, r ?? { format: "", currency: null })
164
+ children: n ? t.trim() ? "This formula needs fixing" : "No formula yet" : P(a, r ?? { format: "", currency: null })
164
165
  }
165
166
  ),
166
167
  t.trim() && /* @__PURE__ */ s(
@@ -178,19 +179,19 @@ function de({
178
179
  );
179
180
  }
180
181
  export {
181
- de as DisplayFormulaValue,
182
- se as FieldCounter,
183
- q as PlacementTextContext,
184
- le as RecommendedMarker,
185
- ie as RepeatLastButton,
186
- oe as confirmChangeFields,
187
- z as evaluateDisplayFormula,
188
- ue as fieldCounterConfig,
189
- ae as fieldCounterError,
190
- M as fieldIsRecommended,
191
- ne as isDisplayFormulaRow,
192
- re as missingRecommended,
193
- te as placementBehaviourNeeds,
194
- ee as placementFieldText,
195
- I as usePlacementTextContext
182
+ ce as DisplayFormulaValue,
183
+ de as FieldCounter,
184
+ M as PlacementTextContext,
185
+ se as RecommendedMarker,
186
+ ue as RepeatLastButton,
187
+ ne as confirmChangeFields,
188
+ G as evaluateDisplayFormula,
189
+ me as fieldCounterConfig,
190
+ le as fieldCounterError,
191
+ z as fieldIsRecommended,
192
+ ie as isDisplayFormulaRow,
193
+ ae as missingRecommended,
194
+ oe as placementBehaviourNeeds,
195
+ re as placementFieldText,
196
+ te as usePlacementTextContext
196
197
  };
@@ -1,32 +1,33 @@
1
- import { jsxs as s, jsx as l, Fragment as j } from "react/jsx-runtime";
2
- import { AlertTriangle as F, Ruler as R } from "lucide-react";
3
- import { useContext as A, useState as L } from "react";
1
+ import { jsxs as s, jsx as l, Fragment as W } from "react/jsx-runtime";
2
+ import { AlertTriangle as j, Ruler as F } from "lucide-react";
3
+ import { useContext as R, useState as A } from "react";
4
+ import { userErrorMessage as L } from "../../../lib/safe-error.js";
4
5
  import { cn as O } from "../../../lib/utils.js";
5
- import { useColumnFacts as V, columnOf as $, useValueLengths as P } from "../inspect/inspect-api.js";
6
- import { fitWarnings as U, widthCheckApplies as D, widthVerdict as E, typeWords as G, SPAN_WORDS as i, capacityChars as q } from "../inspect/width-fit.js";
7
- import { labelText as z, effectText as c, tintCard as B } from "../panel-style.js";
8
- import { useFieldCtx as H } from "./field-context.js";
9
- import { GlobalWriterContext as I } from "./kit.js";
10
- import { asObject as J } from "./model.js";
6
+ import { useColumnFacts as V, columnOf as $, useValueLengths as E } from "../inspect/inspect-api.js";
7
+ import { fitWarnings as P, widthCheckApplies as U, widthVerdict as D, typeWords as G, SPAN_WORDS as i, capacityChars as M } from "../inspect/width-fit.js";
8
+ import { labelText as q, effectText as c, tintCard as z } from "../panel-style.js";
9
+ import { useFieldCtx as B } from "./field-context.js";
10
+ import { GlobalWriterContext as H } from "./kit.js";
11
+ import { asObject as I } from "./model.js";
11
12
  const p = (d) => d.toLocaleString();
12
- function le() {
13
- var w, N;
14
- const d = H(), { info: h, row: o, ov: m, env: r, globalOptions: v } = d, { data: C } = V(r.collection), a = $(C, o.field), f = (w = A(I)) == null ? void 0 : w.draft.options, T = String((f == null ? void 0 : f.input_mask) ?? v.input_mask ?? ""), b = J(r.bundle.layout.default_values), _ = typeof m.label == "string" && m.label ? m.label : h.label, S = r.layoutType !== "table", y = U({
13
+ function ne() {
14
+ var w;
15
+ const d = B(), { info: h, row: o, ov: m, env: r, globalOptions: N } = d, { data: v } = V(r.collection), a = $(v, o.field), f = (w = R(H)) == null ? void 0 : w.draft.options, C = String((f == null ? void 0 : f.input_mask) ?? N.input_mask ?? ""), b = I(r.bundle.layout.default_values), T = typeof m.label == "string" && m.label ? m.label : h.label, _ = r.layoutType !== "table", y = P({
15
16
  column: a,
16
- mask: T || null,
17
+ mask: C || null,
17
18
  defaultValue: o.field in b ? b[o.field] : void 0,
18
- label: m.label === "" ? null : _,
19
+ label: m.label === "" ? null : T,
19
20
  span: o.col_span,
20
21
  layoutType: r.layoutType
21
- }), g = S && !!a && D(h), [x, W] = L(!1), t = P(r.collection, o.field, x && g);
22
+ }), g = _ && !!a && U(h), [x, S] = A(!1), t = E(r.collection, o.field, x && g);
22
23
  if (!a && !y.length) return null;
23
- const u = o.col_span ?? 12, e = t.data ? E(u, t.data.p95) : null, k = (n) => d.setPlacement(
24
+ const u = o.col_span ?? 12, e = t.data ? D(u, t.data.p95) : null, k = (n) => d.setPlacement(
24
25
  { col_span: n === 12 ? null : n },
25
26
  `Set the width of ${h.label} to ${i[n]}`
26
27
  );
27
28
  return /* @__PURE__ */ s("div", { "data-setting": "field.column_fit", className: "space-y-1.5", children: [
28
29
  /* @__PURE__ */ s("div", { className: "flex min-h-5 items-center justify-between gap-3", children: [
29
- /* @__PURE__ */ l("span", { className: z, children: "Stored as" }),
30
+ /* @__PURE__ */ l("span", { className: q, children: "Stored as" }),
30
31
  a && /* @__PURE__ */ l("span", { className: "font-mono text-[12px] text-slate-700 dark:text-foreground", children: G(a) })
31
32
  ] }),
32
33
  /* @__PURE__ */ l("p", { "data-effect": "", className: c, children: (a == null ? void 0 : a.max_length) != null ? `The database keeps up to ${p(a.max_length)} characters.` : a ? "What the database column holds." : "This field has no column of its own." }),
@@ -36,7 +37,7 @@ function le() {
36
37
  "data-fit-warning": n.key,
37
38
  className: "flex items-start gap-1.5 text-[12px] leading-snug text-amber-700 dark:text-amber-300",
38
39
  children: [
39
- /* @__PURE__ */ l(F, { className: "mt-[2px] h-3 w-3 shrink-0" }),
40
+ /* @__PURE__ */ l(j, { className: "mt-[2px] h-3 w-3 shrink-0" }),
40
41
  n.text
41
42
  ]
42
43
  },
@@ -47,15 +48,15 @@ function le() {
47
48
  {
48
49
  type: "button",
49
50
  "data-width-check": "",
50
- onClick: () => W(!0),
51
+ onClick: () => S(!0),
51
52
  className: "inline-flex items-center gap-1.5 text-[12px] font-medium text-sky-700 hover:underline dark:text-nvr-cyan",
52
53
  children: [
53
- /* @__PURE__ */ l(R, { className: "h-3.5 w-3.5" }),
54
+ /* @__PURE__ */ l(F, { className: "h-3.5 w-3.5" }),
54
55
  "Check the width against stored values"
55
56
  ]
56
57
  }
57
58
  ),
58
- g && x && /* @__PURE__ */ l("div", { "data-width-result": "", className: O(B, "space-y-1.5 p-2.5"), children: t.isLoading ? /* @__PURE__ */ l("p", { className: c, children: "Reading the newest stored values…" }) : t.isError ? /* @__PURE__ */ l("p", { className: "text-[12px] text-red-700 dark:text-red-300", children: ((N = t.error) == null ? void 0 : N.message) || "The stored values could not be read." }) : !t.data || t.data.filled === 0 ? /* @__PURE__ */ l("p", { className: c, children: "No stored values to measure yet." }) : /* @__PURE__ */ s(j, { children: [
59
+ g && x && /* @__PURE__ */ l("div", { "data-width-result": "", className: O(z, "space-y-1.5 p-2.5"), children: t.isLoading ? /* @__PURE__ */ l("p", { className: c, children: "Reading the newest stored values…" }) : t.isError ? /* @__PURE__ */ l("p", { className: "text-[12px] text-red-700 dark:text-red-300", children: L(t.error, "The stored values could not be read.") }) : !t.data || t.data.filled === 0 ? /* @__PURE__ */ l("p", { className: c, children: "No stored values to measure yet." }) : /* @__PURE__ */ s(W, { children: [
59
60
  /* @__PURE__ */ s("p", { className: "text-[12px] leading-snug text-slate-700 dark:text-foreground", children: [
60
61
  "95% of ",
61
62
  p(t.data.filled),
@@ -67,7 +68,7 @@ function le() {
67
68
  "). ",
68
69
  i[u] ?? u,
69
70
  " width shows about ",
70
- q(u),
71
+ M(u),
71
72
  "."
72
73
  ] }),
73
74
  e != null && e.cut ? /* @__PURE__ */ s("p", { className: "text-[12px] leading-snug text-amber-700 dark:text-amber-300", children: [
@@ -108,5 +109,5 @@ function le() {
108
109
  ] });
109
110
  }
110
111
  export {
111
- le as ColumnFit
112
+ ne as ColumnFit
112
113
  };
@@ -1,20 +1,21 @@
1
1
  import { jsxs as i, jsx as r, Fragment as $ } from "react/jsx-runtime";
2
2
  import { useQuery as A } from "@tanstack/react-query";
3
- import { AlertTriangle as J } from "lucide-react";
4
- import { useState as K } from "react";
5
- import { useNivaroClient as L } from "../../../context.js";
6
- import { get as F, post as R } from "../../../lib/commands.js";
3
+ import { AlertTriangle as E } from "lucide-react";
4
+ import { useState as J } from "react";
5
+ import { useNivaroClient as K } from "../../../context.js";
6
+ import { get as F, post as L } from "../../../lib/commands.js";
7
+ import { userErrorMessage as R } from "../../../lib/safe-error.js";
7
8
  import { cn as W } from "../../../lib/utils.js";
8
9
  import { extractTemplateFields as B, renderDisplayTemplate as D } from "../../pipeline/relations.js";
9
- import { useCollectionBody as E } from "../collection-meta.js";
10
- import { m2mParents as Q, previewNarrowing as z } from "../inspect/picker-preview.js";
11
- import { labelText as G, effectText as u, tintCard as H } from "../panel-style.js";
10
+ import { useCollectionBody as Q } from "../collection-meta.js";
11
+ import { m2mParents as z, previewNarrowing as G } from "../inspect/picker-preview.js";
12
+ import { labelText as H, effectText as u, tintCard as M } from "../panel-style.js";
12
13
  import { RelationPicker as U } from "../pickers/relation-picker.js";
13
14
  import { useFieldCtx as V } from "./field-context.js";
14
15
  import { asObject as X, describeField as j } from "./model.js";
15
16
  const l = (c) => c.toLocaleString();
16
- function pe({ rules: c }) {
17
- const n = V(), { info: k, env: d, opts: p, globalOptions: T } = n, w = L(), a = k.relatedCollection, [s, S] = K(null), { data: h } = E(a), m = a === "nivaro_users" ? "{{first_name}} {{last_name}}" : (h == null ? void 0 : h.display_template) ?? null, y = X(p.option_filter ?? T.option_filter), b = typeof p.option_sort == "string" && p.option_sort && !/^-?label$/.test(p.option_sort) ? p.option_sort : void 0, C = JSON.stringify([c, y, b, m]), x = A({
17
+ function fe({ rules: c }) {
18
+ const n = V(), { info: k, env: d, opts: p, globalOptions: T } = n, w = K(), a = k.relatedCollection, [s, S] = J(null), { data: h } = Q(a), m = a === "nivaro_users" ? "{{first_name}} {{last_name}}" : (h == null ? void 0 : h.display_template) ?? null, y = X(p.option_filter ?? T.option_filter), b = typeof p.option_sort == "string" && p.option_sort && !/^-?label$/.test(p.option_sort) ? p.option_sort : void 0, C = JSON.stringify([c, y, b, m]), x = A({
18
19
  queryKey: ["layout-editor", "picker-preview", d.collection, k.field, s, C],
19
20
  enabled: !!s && !!a,
20
21
  retry: !1,
@@ -23,7 +24,7 @@ function pe({ rules: c }) {
23
24
  const t = (await w.request(
24
25
  F(`/items/${d.collection}/${s}`, { fields: "*" })
25
26
  )).data ?? {}, v = {};
26
- for (const o of Q(c, d.collection, n.relations)) {
27
+ for (const o of z(c, d.collection, n.relations)) {
27
28
  const g = (await w.request(
28
29
  F(`/items/${o.junction}`, {
29
30
  filter: JSON.stringify({ [o.parentFk]: { _eq: s } }),
@@ -33,7 +34,7 @@ function pe({ rules: c }) {
33
34
  )).data ?? [];
34
35
  v[o.parent] = g.map((f) => f[o.targetFk]).filter((f) => f != null && typeof f != "object");
35
36
  }
36
- const _ = z({
37
+ const _ = G({
37
38
  target: a,
38
39
  rules: c,
39
40
  optionFilter: y,
@@ -47,7 +48,7 @@ function pe({ rules: c }) {
47
48
  d.bundle.placements.find((g) => g.field === o) ?? null
48
49
  ).label
49
50
  }), q = B(m).filter((o) => o !== "*" && o !== "id"), I = await w.request(
50
- R("/layout-inspect/picker-preview", {
51
+ L("/layout-inspect/picker-preview", {
51
52
  collection: a,
52
53
  steps: _.steps,
53
54
  fields: q,
@@ -60,7 +61,7 @@ function pe({ rules: c }) {
60
61
  if (!a) return null;
61
62
  const e = x.data, N = x.error, O = (e == null ? void 0 : e.answer.steps) ?? [], P = (t) => (m ? D(m, t) : "") || String(t.id ?? "");
62
63
  return /* @__PURE__ */ i("div", { "data-setting": "field.picker_preview", className: "space-y-2", children: [
63
- /* @__PURE__ */ r("div", { className: "flex min-h-5 items-center justify-between gap-3", children: /* @__PURE__ */ r("span", { className: G, children: "Options for a record" }) }),
64
+ /* @__PURE__ */ r("div", { className: "flex min-h-5 items-center justify-between gap-3", children: /* @__PURE__ */ r("span", { className: H, children: "Options for a record" }) }),
64
65
  /* @__PURE__ */ r(
65
66
  U,
66
67
  {
@@ -71,7 +72,7 @@ function pe({ rules: c }) {
71
72
  }
72
73
  ),
73
74
  /* @__PURE__ */ r("p", { "data-effect": "", className: u, children: "What this picker offers on the record you pick, after its cascade filters, option filter and picker exclusions." }),
74
- s && /* @__PURE__ */ r("div", { "data-picker-preview": "", className: W(H, "space-y-2 p-2.5"), children: x.isLoading ? /* @__PURE__ */ r("p", { className: u, children: "Working out the options…" }) : N ? /* @__PURE__ */ r("p", { className: "text-[12px] text-red-700 dark:text-red-300", children: N.message || "The options could not be worked out." }) : e ? /* @__PURE__ */ i($, { children: [
75
+ s && /* @__PURE__ */ r("div", { "data-picker-preview": "", className: W(M, "space-y-2 p-2.5"), children: x.isLoading ? /* @__PURE__ */ r("p", { className: u, children: "Working out the options…" }) : N ? /* @__PURE__ */ r("p", { className: "text-[12px] text-red-700 dark:text-red-300", children: R(N, "The options could not be worked out.") }) : e ? /* @__PURE__ */ i($, { children: [
75
76
  /* @__PURE__ */ r(
76
77
  "p",
77
78
  {
@@ -81,7 +82,7 @@ function pe({ rules: c }) {
81
82
  }
82
83
  ),
83
84
  e.narrowing.waitsFor && /* @__PURE__ */ i("p", { className: "flex items-start gap-1.5 text-[12px] leading-snug text-amber-700 dark:text-amber-300", children: [
84
- /* @__PURE__ */ r(J, { className: "mt-[2px] h-3 w-3 shrink-0" }),
85
+ /* @__PURE__ */ r(E, { className: "mt-[2px] h-3 w-3 shrink-0" }),
85
86
  "The picker stays disabled on this record until",
86
87
  " ",
87
88
  j(e.narrowing.waitsFor, n.globals, n.relations, null).label,
@@ -130,5 +131,5 @@ function pe({ rules: c }) {
130
131
  ] });
131
132
  }
132
133
  export {
133
- pe as PickerPreview
134
+ fe as PickerPreview
134
135
  };