@nivaro/react 0.3.118 → 0.3.120

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,29 +1,30 @@
1
- import { jsxs as l, jsx as t } from "react/jsx-runtime";
2
- import { useQuery as C, useQueryClient as O, useMutation as A } from "@tanstack/react-query";
3
- import { Plus as j } from "lucide-react";
4
- import { useState as u, useRef as E, useEffect as w, useCallback as I } from "react";
5
- import { useNivaroClient as F, useItemEditAuth as Q } from "../../context.js";
6
- import { get as R, patch as z, post as B, del as G } from "../../lib/commands.js";
7
- import { takeSupportDraft as P } from "../../lib/error-actions.js";
8
- import { useLiveRefresh as H } from "../../lib/live-counts.js";
9
- import { RelationCombobox as J } from "../item-edit/RelationCombobox.js";
10
- import { LiveCount as U } from "../LiveCount.js";
11
- import { SimpleSelect as X } from "../ui/SimpleSelect.js";
12
- import { AssignRulesView as Y } from "./AssignRules.js";
13
- import { RequestList as Z } from "./RequestList.js";
14
- import { SupportAnalytics as ee } from "./SupportAnalytics.js";
15
- import { SupportRequestDialog as te } from "./SupportRequestDialog.js";
16
- import { TicketDetailSheet as re } from "./TicketDetailSheet.js";
17
- function ve({
1
+ import { jsxs as l, jsx as t, Fragment as O } from "react/jsx-runtime";
2
+ import { useQuery as C, useQueryClient as j, useMutation as A } from "@tanstack/react-query";
3
+ import { Plus as I } from "lucide-react";
4
+ import { useState as c, useRef as F, useEffect as w, useCallback as Q } from "react";
5
+ import { useNivaroClient as W, useItemEditAuth as z } from "../../context.js";
6
+ import { get as R, patch as B, post as G, del as P } from "../../lib/commands.js";
7
+ import { takeSupportDraft as H } from "../../lib/error-actions.js";
8
+ import { useLiveRefresh as J } from "../../lib/live-counts.js";
9
+ import { RelationCombobox as U } from "../item-edit/RelationCombobox.js";
10
+ import { LiveCount as X } from "../LiveCount.js";
11
+ import { SimpleSelect as Y } from "../ui/SimpleSelect.js";
12
+ import { AssignRulesView as Z } from "./AssignRules.js";
13
+ import { RequestList as ee } from "./RequestList.js";
14
+ import { SupportAnalytics as te } from "./SupportAnalytics.js";
15
+ import { SupportEmailSwitch as re } from "./SupportEmailSwitch.js";
16
+ import { SupportRequestDialog as ae } from "./SupportRequestDialog.js";
17
+ import { TicketDetailSheet as ne } from "./TicketDetailSheet.js";
18
+ function Ne({
18
19
  initialTicketId: o,
19
20
  onTicketChange: m,
20
- className: c
21
+ className: u
21
22
  }) {
22
- const y = F(), h = Q(), x = !!(h != null && h.isAdmin), [n, i] = u("mine"), f = E(!1), g = (e) => {
23
+ const y = W(), h = z(), x = !!(h != null && h.isAdmin), [n, i] = c("mine"), f = F(!1), g = (e) => {
23
24
  f.current = !0, i(e);
24
- }, [r, a] = u(o ?? null), [d, M] = u(
25
- () => typeof window < "u" && /[?&]new=1\b/.test(window.location.search) ? P() : null
26
- ), [T, D] = u(!!d);
25
+ }, [r, a] = c(o ?? null), [d, M] = c(
26
+ () => typeof window < "u" && /[?&]new=1\b/.test(window.location.search) ? H() : null
27
+ ), [T, D] = c(!!d);
27
28
  w(() => {
28
29
  o != null && a(o);
29
30
  }, [o]);
@@ -31,29 +32,29 @@ function ve({
31
32
  queryKey: ["support-summary"],
32
33
  queryFn: () => y.request(R("/support/summary")).then((e) => e.data)
33
34
  }), L = !!(s != null && s.desk);
34
- H({
35
+ J({
35
36
  topic: "support",
36
37
  keys: [["support-tickets"], ["support-summary"], ["support-ticket"], ["support-workload"]]
37
38
  });
38
- const [_, V] = u(!1);
39
+ const [_, V] = c(!1);
39
40
  w(() => {
40
41
  !_ && s && (s.desk && !f.current && i("desk"), V(!0));
41
42
  }, [s, _]);
42
43
  const N = (e) => {
43
44
  a(e), m == null || m(e);
44
- }, W = [
45
+ }, E = [
45
46
  { key: "mine", label: "My requests", count: s == null ? void 0 : s.mine_open },
46
47
  ...L ? [{ key: "desk", label: "Desk", count: s == null ? void 0 : s.unassigned }] : [],
47
48
  ...L ? [{ key: "analytics", label: "Analytics" }] : [],
48
49
  ...x ? [{ key: "types", label: "Request types" }] : [],
49
50
  ...x ? [{ key: "rules", label: "Assignment rules" }] : []
50
- ], S = E(null), [v, $] = u({ left: !1, right: !1 }), b = I(() => {
51
+ ], S = F(null), [v, $] = c({ left: !1, right: !1 }), b = Q(() => {
51
52
  const e = S.current;
52
53
  if (!e) return;
53
54
  const p = e.scrollLeft > 2, k = e.scrollLeft + e.clientWidth < e.scrollWidth - 2;
54
55
  $((q) => q.left === p && q.right === k ? q : { left: p, right: k });
55
56
  }, []);
56
- w(() => (b(), window.addEventListener("resize", b), () => window.removeEventListener("resize", b)), [b, W.length]), w(() => {
57
+ w(() => (b(), window.addEventListener("resize", b), () => window.removeEventListener("resize", b)), [b, E.length]), w(() => {
57
58
  const e = S.current, p = e == null ? void 0 : e.querySelector(`[data-support-tab="${n}"]`);
58
59
  if (!e || !p || e.scrollWidth <= e.clientWidth) return;
59
60
  const k = p.offsetLeft - (e.clientWidth - p.offsetWidth) / 2;
@@ -63,7 +64,7 @@ function ve({
63
64
  const e = `linear-gradient(to right, ${v.left ? "transparent" : "black"}, black 20px, black calc(100% - 28px), ${v.right ? "transparent" : "black"})`;
64
65
  return { maskImage: e, WebkitMaskImage: e };
65
66
  })() : void 0;
66
- return /* @__PURE__ */ l("div", { className: c, "data-support-view": !0, children: [
67
+ return /* @__PURE__ */ l("div", { className: u, "data-support-view": !0, children: [
67
68
  /* @__PURE__ */ l("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [
68
69
  /* @__PURE__ */ t(
69
70
  "div",
@@ -73,7 +74,7 @@ function ve({
73
74
  className: "relative -mx-1 flex min-w-0 max-w-full items-center gap-1 overflow-x-auto px-1 [scrollbar-width:none]",
74
75
  style: K,
75
76
  role: "tablist",
76
- children: W.map((e) => /* @__PURE__ */ l(
77
+ children: E.map((e) => /* @__PURE__ */ l(
77
78
  "button",
78
79
  {
79
80
  type: "button",
@@ -84,7 +85,7 @@ function ve({
84
85
  className: n === e.key ? "inline-flex h-8 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md bg-nvr-cyan/10 px-3 text-[12.5px] font-medium text-nvr-navy dark:text-nvr-cyan" : "inline-flex h-8 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-md px-3 text-[12.5px] text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-white/5",
85
86
  children: [
86
87
  e.label,
87
- e.count ? /* @__PURE__ */ t("span", { className: "rounded-full bg-slate-200 px-1.5 text-[10.5px] font-semibold tabular-nums text-slate-700 dark:bg-white/10 dark:text-slate-200", children: /* @__PURE__ */ t(U, { value: e.count }) }) : null
88
+ e.count ? /* @__PURE__ */ t("span", { className: "rounded-full bg-slate-200 px-1.5 text-[10.5px] font-semibold tabular-nums text-slate-700 dark:bg-white/10 dark:text-slate-200", children: /* @__PURE__ */ t(X, { value: e.count }) }) : null
88
89
  ]
89
90
  },
90
91
  e.key
@@ -99,15 +100,20 @@ function ve({
99
100
  onClick: () => D(!0),
100
101
  className: "inline-flex h-8 items-center gap-1.5 rounded-md border border-nvr-cyan/60 bg-nvr-cyan/10 px-3 text-[12.5px] font-medium text-nvr-navy hover:bg-nvr-cyan/15 dark:text-nvr-cyan",
101
102
  children: [
102
- /* @__PURE__ */ t(j, { className: "h-3.5 w-3.5" }),
103
+ /* @__PURE__ */ t(I, { className: "h-3.5 w-3.5" }),
103
104
  " Get help"
104
105
  ]
105
106
  }
106
107
  )
107
108
  ] }),
108
- n === "types" ? /* @__PURE__ */ t(ae, {}) : n === "rules" ? /* @__PURE__ */ t(Y, {}) : n === "analytics" ? /* @__PURE__ */ t(ee, {}) : /* @__PURE__ */ t(Z, { tab: n, openId: r, onOpen: (e) => N(e) }, n),
109
+ n === "types" ? /* @__PURE__ */ t(se, {}) : n === "rules" ? /* @__PURE__ */ t(Z, {}) : n === "analytics" ? /* @__PURE__ */ t(te, {}) : /* @__PURE__ */ l(O, { children: [
110
+ n === "mine" && // The requester's own email opt-in (off by default): replies and changes on
111
+ // their requests reach them in the app unless they turn this on.
112
+ /* @__PURE__ */ t("div", { className: "mt-4 rounded-md border border-slate-200 bg-slate-50/60 px-3 py-2 dark:border-border dark:bg-background/40", children: /* @__PURE__ */ t(re, { compact: !0 }) }),
113
+ /* @__PURE__ */ t(ee, { tab: n, openId: r, onOpen: (e) => N(e) }, n)
114
+ ] }),
109
115
  /* @__PURE__ */ t(
110
- te,
116
+ ae,
111
117
  {
112
118
  open: T,
113
119
  onOpenChange: (e) => {
@@ -121,26 +127,26 @@ function ve({
121
127
  }
122
128
  }
123
129
  ),
124
- /* @__PURE__ */ t(re, { ticketId: r, onOpenChange: (e) => !e && N(null) })
130
+ /* @__PURE__ */ t(ne, { ticketId: r, onOpenChange: (e) => !e && N(null) })
125
131
  ] });
126
132
  }
127
- function ae() {
128
- const o = F(), m = O(), [c, y] = u(""), { data: h = [] } = C({
133
+ function se() {
134
+ const o = W(), m = j(), [u, y] = c(""), { data: h = [] } = C({
129
135
  queryKey: ["support-categories", "all"],
130
136
  queryFn: () => o.request(R("/support/categories", { all: "1" })).then((r) => r.data ?? [])
131
137
  }), { data: x = [] } = C({
132
138
  queryKey: ["support-teams"],
133
139
  queryFn: () => o.request(R("/user-groups")).then((r) => r.data ?? []).catch(() => [])
134
140
  }), n = () => void m.invalidateQueries({ queryKey: ["support-categories"] }), i = A({
135
- mutationFn: ({ id: r, body: a }) => o.request(z(`/support/categories/${r}`, a)),
141
+ mutationFn: ({ id: r, body: a }) => o.request(B(`/support/categories/${r}`, a)),
136
142
  onSuccess: n
137
143
  }), f = A({
138
- mutationFn: () => o.request(B("/support/categories", { name: c.trim() })),
144
+ mutationFn: () => o.request(G("/support/categories", { name: u.trim() })),
139
145
  onSuccess: () => {
140
146
  y(""), n();
141
147
  }
142
148
  }), g = A({
143
- mutationFn: (r) => o.request(G(`/support/categories/${r}`)),
149
+ mutationFn: (r) => o.request(P(`/support/categories/${r}`)),
144
150
  onSuccess: n
145
151
  });
146
152
  return /* @__PURE__ */ l("div", { className: "mt-4 space-y-3", "data-support-types-editor": !0, children: [
@@ -175,7 +181,7 @@ function ae() {
175
181
  }
176
182
  ) }),
177
183
  /* @__PURE__ */ t("td", { className: "px-3 py-2", children: /* @__PURE__ */ t(
178
- X,
184
+ Y,
179
185
  {
180
186
  value: r.team_id != null ? String(r.team_id) : "",
181
187
  onChange: (a) => i.mutate({ id: r.id, body: { team_id: a ? Number(a) : null } }),
@@ -187,7 +193,7 @@ function ae() {
187
193
  }
188
194
  ) }),
189
195
  /* @__PURE__ */ t("td", { className: "px-3 py-2", children: /* @__PURE__ */ t(
190
- J,
196
+ U,
191
197
  {
192
198
  collection: "nivaro_users",
193
199
  value: r.default_assignee,
@@ -220,13 +226,13 @@ function ae() {
220
226
  {
221
227
  className: "flex items-center gap-2",
222
228
  onSubmit: (r) => {
223
- r.preventDefault(), c.trim() && f.mutate();
229
+ r.preventDefault(), u.trim() && f.mutate();
224
230
  },
225
231
  children: [
226
232
  /* @__PURE__ */ t(
227
233
  "input",
228
234
  {
229
- value: c,
235
+ value: u,
230
236
  onChange: (r) => y(r.target.value),
231
237
  placeholder: "New type, e.g. Vendor change",
232
238
  "aria-label": "New type name",
@@ -237,7 +243,7 @@ function ae() {
237
243
  "button",
238
244
  {
239
245
  type: "submit",
240
- disabled: !c.trim() || f.isPending,
246
+ disabled: !u.trim() || f.isPending,
241
247
  className: "h-8 rounded-md border border-nvr-cyan/60 bg-nvr-cyan/10 px-3 text-[12.5px] font-medium text-nvr-navy disabled:opacity-50 dark:text-nvr-cyan",
242
248
  children: "Add type"
243
249
  }
@@ -248,5 +254,5 @@ function ae() {
248
254
  ] });
249
255
  }
250
256
  export {
251
- ve as SupportView
257
+ Ne as SupportView
252
258
  };
@@ -1,151 +1,156 @@
1
- const I = "shrink-0 border-y border-slate-200/90 bg-white dark:border-border dark:bg-card", N = "flex items-stretch overflow-hidden pr-4 pl-[29px]", K = "flex min-w-0 flex-1 flex-wrap content-start items-stretch overflow-hidden", S = "[[data-header-dense]_&]:min-h-[34px] [[data-header-dense]_&]:flex-row [[data-header-dense]_&]:items-center [[data-header-dense]_&]:gap-x-2 [[data-header-dense]_&]:pr-3 [[data-header-dense]_&]:pl-4 [[data-header-dense]_&]:pt-[7px] [[data-header-dense]_&]:pb-[7px] [[data-header-dense]_&]:max-w-none", L = "[[data-header-list]_&]:h-8 [[data-header-list]_&]:min-h-0 [[data-header-list]_&]:w-full [[data-header-list]_&]:max-w-none [[data-header-list]_&]:flex-row [[data-header-list]_&]:items-center [[data-header-list]_&]:justify-between [[data-header-list]_&]:gap-x-6 [[data-header-list]_&]:rounded-sm [[data-header-list]_&]:px-2 [[data-header-list]_&]:py-0 [[data-header-list]_&]:shadow-none", H = "[&[data-header-folded]]:pointer-events-none [&[data-header-folded]]:invisible [&[data-header-folded]]:absolute", $ = `group relative flex min-h-[52px] min-w-[96px] max-w-[264px] flex-none flex-col justify-start gap-1 px-4 pt-[9px] pb-2 shadow-[-1px_1px_0_0_#e2e8f0] data-[empty=true]:min-w-0 data-[empty=true]:px-3 data-[empty=true]:opacity-60 dark:shadow-[-1px_1px_0_0_hsl(var(--border))] ${S} ${L} ${H}`, M = "truncate text-[13px] font-semibold leading-tight tabular-nums tracking-[-0.01em] text-slate-900 dark:text-slate-100", U = "truncate text-[10px] font-semibold uppercase leading-none tracking-[0.07em] text-slate-400 dark:text-slate-500 [[data-header-dense]_&]:shrink-0 [[data-header-list]_&]:shrink-0", j = "truncate text-[13px] font-semibold leading-tight tabular-nums text-slate-900 dark:text-slate-100", T = "flex shrink-0 items-stretch self-stretch max-lg:[&[data-header-dock]]:hidden shadow-[-1px_0_0_0_#e2e8f0] dark:shadow-[-1px_0_0_0_hsl(var(--border))]", V = "ml-auto hidden items-center self-center py-1 pr-0 pl-4 max-lg:[&[data-header-tail]]:flex", F = "flex min-h-[40px] items-center gap-3 py-2 pr-4 pl-5", P = "text-[11px] font-medium leading-none tabular-nums text-slate-400 dark:text-slate-500 [[data-header-dense]_&]:hidden", X = "flex h-5 items-end gap-x-1.5 [[data-header-dense]_&]:h-auto [[data-header-dense]_&]:items-center [[data-header-list]_&]:h-auto [[data-header-list]_&]:items-baseline [[data-header-list]_&]:justify-end [[data-header-list]_&]:text-right";
2
- function A(n) {
3
- const r = Array.from(n.children).filter(
1
+ const K = "shrink-0 border-y border-slate-200/90 bg-white dark:border-border dark:bg-card", M = "flex items-stretch overflow-hidden pr-4 pl-[29px]", N = "flex min-w-0 flex-1 flex-wrap content-start items-stretch overflow-hidden", L = "[[data-header-dense]_&]:min-h-[34px] [[data-header-dense]_&]:flex-row [[data-header-dense]_&]:items-center [[data-header-dense]_&]:gap-x-2 [[data-header-dense]_&]:pr-3 [[data-header-dense]_&]:pl-4 [[data-header-dense]_&]:pt-[7px] [[data-header-dense]_&]:pb-[7px] [[data-header-dense]_&]:max-w-none", H = "[[data-header-list]_&]:h-8 [[data-header-list]_&]:min-h-0 [[data-header-list]_&]:w-full [[data-header-list]_&]:max-w-none [[data-header-list]_&]:flex-row [[data-header-list]_&]:items-center [[data-header-list]_&]:justify-between [[data-header-list]_&]:gap-x-6 [[data-header-list]_&]:rounded-sm [[data-header-list]_&]:px-2 [[data-header-list]_&]:py-0 [[data-header-list]_&]:shadow-none", O = "[&[data-header-folded]]:pointer-events-none [&[data-header-folded]]:invisible [&[data-header-folded]]:absolute", U = `group relative flex min-h-[52px] min-w-[96px] max-w-[264px] flex-none flex-col justify-start gap-1 px-4 pt-[9px] pb-2 shadow-[-1px_1px_0_0_#e2e8f0] data-[empty=true]:min-w-0 data-[empty=true]:px-3 data-[empty=true]:opacity-60 dark:shadow-[-1px_1px_0_0_hsl(var(--border))] ${L} ${H} ${O}`, $ = "truncate text-[13px] font-semibold leading-tight tabular-nums tracking-[-0.01em] text-slate-900 dark:text-slate-100", T = "truncate text-[10px] font-semibold uppercase leading-none tracking-[0.07em] text-slate-400 dark:text-slate-500 [[data-header-dense]_&]:shrink-0 [[data-header-list]_&]:shrink-0", V = "truncate text-[13px] font-semibold leading-tight tabular-nums text-slate-900 dark:text-slate-100", j = "flex shrink-0 items-stretch self-stretch max-lg:[&[data-header-dock]]:hidden shadow-[-1px_0_0_0_#e2e8f0] dark:shadow-[-1px_0_0_0_hsl(var(--border))]", F = "ml-auto hidden items-center self-center py-1 pr-0 pl-4 max-lg:[&[data-header-tail]]:flex", P = "flex min-h-[40px] items-center gap-3 py-2 pr-4 pl-5", X = "absolute top-2 right-6 flex empty:hidden [[data-header-dense]_&]:static [[data-header-dense]_&]:order-1 [[data-header-dense]_&]:shrink-0 [[data-header-list]_&]:static [[data-header-list]_&]:order-1 [[data-header-list]_&]:shrink-0 [[data-header-list]_&]:mr-auto [[data-header-list]_&]:-ml-4", Y = "[[data-header-dense]_&]:order-2 [[data-header-list]_&]:order-2", z = "text-[11px] font-medium leading-none tabular-nums text-slate-400 dark:text-slate-500 [[data-header-dense]_&]:hidden", G = "flex h-5 items-end gap-x-1.5 [[data-header-dense]_&]:h-auto [[data-header-dense]_&]:items-center [[data-header-list]_&]:h-auto [[data-header-list]_&]:items-baseline [[data-header-list]_&]:justify-end [[data-header-list]_&]:text-right";
2
+ function b(a) {
3
+ const d = Array.from(a.children).filter(
4
4
  (t) => !t.hasAttribute("data-header-more") && !t.hasAttribute("data-header-tail")
5
- ), o = r.filter((t) => t.hasAttribute("data-header-cell"));
6
- return o.length > 0 ? o : r;
5
+ ), r = d.filter((t) => t.hasAttribute("data-header-cell"));
6
+ return r.length > 0 ? r : d;
7
7
  }
8
- function b(n) {
9
- const r = /* @__PURE__ */ new Set();
10
- return n.map((o, t) => {
11
- let l = o.hasAttribute("data-header-cell") ? o.getAttribute("data-header-cell") ?? t : t;
12
- return r.has(l) && (l = `${l}#${t}`), r.add(l), l;
8
+ function R(a) {
9
+ const d = /* @__PURE__ */ new Set();
10
+ return a.map((r, t) => {
11
+ let l = r.hasAttribute("data-header-cell") ? r.getAttribute("data-header-cell") ?? t : t;
12
+ return d.has(l) && (l = `${l}#${t}`), d.add(l), l;
13
13
  });
14
14
  }
15
- function Y(n, r) {
16
- const o = A(n), t = b(o), l = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
17
- for (const d of r) {
18
- if (d.target === n) continue;
19
- let s = d.target instanceof Element ? d.target : d.target.parentElement;
20
- if (!s || s.closest("[data-header-more]")) continue;
21
- for (; s && s.parentElement !== n; ) s = s.parentElement;
22
- const c = s ? o.indexOf(s) : -1;
23
- !s || c < 0 || (s.hasAttribute("data-header-folded") ? a : l).add(t[c]);
15
+ function J(a, d) {
16
+ const r = b(a), t = R(r), l = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
17
+ for (const s of d) {
18
+ if (s.target === a) continue;
19
+ let o = s.target instanceof Element ? s.target : s.target.parentElement;
20
+ if (!o || o.closest("[data-header-more]")) continue;
21
+ for (; o && o.parentElement !== a; ) o = o.parentElement;
22
+ const c = o ? r.indexOf(o) : -1;
23
+ !o || c < 0 || (o.hasAttribute("data-header-folded") ? n : l).add(t[c]);
24
24
  }
25
- return { shown: [...l], folded: [...a] };
25
+ return { shown: [...l], folded: [...n] };
26
26
  }
27
- function z(n, r, o) {
28
- const t = A(n);
27
+ function Q(a, d, r) {
28
+ const t = b(a);
29
29
  if (t.length === 0) return !1;
30
- const l = b(t), a = n.querySelector(":scope > [data-header-tail]");
31
- let d = 0;
32
- t.forEach((c, _) => {
33
- let i;
34
- r ? i = o.get(l[_]) ?? v(c) : (i = c.getBoundingClientRect().width, o.set(l[_], i)), d += i;
30
+ const l = R(t), n = a.querySelector(":scope > [data-header-tail]");
31
+ let s = 0;
32
+ t.forEach((c, f) => {
33
+ let h;
34
+ d ? h = r.get(l[f]) ?? v(c) : (h = c.getBoundingClientRect().width, r.set(l[f], h)), s += h;
35
35
  });
36
- const s = n.clientWidth - ((a == null ? void 0 : a.getBoundingClientRect().width) ?? 0);
37
- return r ? d > s - 24 : d > s;
36
+ const o = a.clientWidth - ((n == null ? void 0 : n.getBoundingClientRect().width) ?? 0);
37
+ return d ? s > o - 24 : s > o;
38
38
  }
39
- function v(n) {
39
+ function v(a) {
40
40
  var t;
41
- const r = n.querySelectorAll("[data-header-label]");
42
- if (r.length === 0) return n.getBoundingClientRect().width;
43
- let o = 0;
44
- for (const l of r) {
45
- const a = (t = l.parentElement) == null ? void 0 : t.querySelector(":scope > [data-header-value]"), d = l.closest('[data-empty="true"]') != null, s = Math.max(l.scrollWidth, ((a == null ? void 0 : a.scrollWidth) ?? 0) * 1.16 + 40);
46
- o += Math.max(s + (d ? 24 : 32), d ? 0 : 96);
41
+ const d = a.querySelectorAll("[data-header-label]");
42
+ if (d.length === 0) return a.getBoundingClientRect().width;
43
+ let r = 0;
44
+ for (const l of d) {
45
+ const n = (t = l.parentElement) == null ? void 0 : t.querySelector(":scope > [data-header-value]"), s = l.closest('[data-empty="true"]') != null, o = Math.max(l.scrollWidth, ((n == null ? void 0 : n.scrollWidth) ?? 0) * 1.16 + 40);
46
+ r += Math.max(o + (s ? 24 : 32), s ? 0 : 96);
47
47
  }
48
- return o;
48
+ return r;
49
49
  }
50
- const k = 2;
51
- function O(n) {
52
- var a;
53
- const r = n.querySelectorAll("[data-header-label]");
54
- if (r.length === 0) return n.getBoundingClientRect().width;
55
- const o = n.querySelectorAll("[data-header-value]");
50
+ const S = 2;
51
+ function q(a) {
52
+ var n, s;
53
+ const d = a.querySelectorAll("[data-header-label]");
54
+ if (d.length === 0) return a.getBoundingClientRect().width;
55
+ const r = a.querySelectorAll("[data-header-value]");
56
56
  let t = 0, l = 0;
57
- for (const d of r) {
58
- const s = ((a = d.parentElement) == null ? void 0 : a.querySelector(":scope > [data-header-value]")) ?? o[l];
59
- t += d.scrollWidth + ((s == null ? void 0 : s.scrollWidth) ?? 0) + 8 + 28, l++;
57
+ for (const o of d) {
58
+ const c = ((n = o.parentElement) == null ? void 0 : n.querySelector(":scope > [data-header-value]")) ?? r[l], f = (s = o.parentElement) == null ? void 0 : s.querySelector(":scope > [data-header-freshness] > *");
59
+ t += o.scrollWidth + ((c == null ? void 0 : c.scrollWidth) ?? 0) + 8 + 28 + (f ? 20 : 0), l++;
60
60
  }
61
61
  return t;
62
62
  }
63
+ function Z(a) {
64
+ const d = (r) => r.empty ? 2 : r.money ? 0 : 1;
65
+ return [...a].sort((r, t) => d(r) - d(t) || r.index - t.index);
66
+ }
63
67
  const W = "__more__";
64
- function q(n, r, o, t, l) {
65
- const a = [], d = (i, u) => a[i] === r || u <= a[i] + 0.5, s = (i) => {
66
- let u = l ? a.findIndex((E, p) => d(p, i)) : a.length - 1;
67
- return (u < 0 || !d(u, i)) && (a.push(r), u = a.length - 1), a[u] -= i, u;
68
- }, c = n.map((i) => i == null ? -1 : s(i)), _ = n.some((i) => i == null) ? s(o) : -1;
69
- return a.length === 0 && a.push(r), t > 0 && !d(a.length - 1, t) && a.push(r - t), { count: a.length, rowOf: c, chipRow: _ };
68
+ function B(a, d, r, t, l) {
69
+ const n = [], s = (h, _) => n[h] === d || _ <= n[h] + 0.5, o = (h) => {
70
+ let _ = l ? n.findIndex((g, E) => s(E, h)) : n.length - 1;
71
+ return (_ < 0 || !s(_, h)) && (n.push(d), _ = n.length - 1), n[_] -= h, _;
72
+ }, c = a.map((h) => h == null ? -1 : o(h)), f = a.some((h) => h == null) ? o(r) : -1;
73
+ return n.length === 0 && n.push(d), t > 0 && !s(n.length - 1, t) && n.push(d - t), { count: n.length, rowOf: c, chipRow: f };
70
74
  }
71
- function B(n) {
72
- if (n.matches('[data-empty="true"]') || n.querySelector('[data-empty="true"]')) return !0;
73
- const r = n.querySelectorAll("[data-header-value]");
74
- return r.length > 0 && Array.from(r).every((o) => {
75
+ function I(a) {
76
+ if (a.matches('[data-empty="true"]') || a.querySelector('[data-empty="true"]')) return !0;
77
+ const d = a.querySelectorAll("[data-header-value]");
78
+ return d.length > 0 && Array.from(d).every((r) => {
75
79
  var t;
76
- return ((t = o.textContent) == null ? void 0 : t.trim()) === "—";
80
+ return ((t = r.textContent) == null ? void 0 : t.trim()) === "—";
77
81
  });
78
82
  }
79
- function G(n, r, o) {
80
- const t = Array.from(n.children), l = t.find((e) => e.hasAttribute("data-header-more")), a = t.find((e) => e.hasAttribute("data-header-tail")), d = A(n);
81
- if (d.length === 0) return { folded: [], rows: null };
82
- const s = b(d), c = d.map((e, h) => {
83
- const f = s[h];
84
- if (r && !e.hasAttribute("data-header-folded")) {
85
- const g = e.getBoundingClientRect().width;
86
- g > 0 && o.set(f, g);
83
+ function ee(a, d, r) {
84
+ const t = Array.from(a.children), l = t.find((e) => e.hasAttribute("data-header-more")), n = t.find((e) => e.hasAttribute("data-header-tail")), s = b(a);
85
+ if (s.length === 0) return { folded: [], rows: null };
86
+ const o = R(s), c = s.map((e, i) => {
87
+ const u = o[i];
88
+ if (d && !e.hasAttribute("data-header-folded")) {
89
+ const m = e.getBoundingClientRect().width;
90
+ m > 0 && r.set(u, m);
87
91
  }
88
- return o.get(f) ?? O(e);
89
- }), _ = n.clientWidth, i = l ? l.getBoundingClientRect().width : 96, u = (a == null ? void 0 : a.getBoundingClientRect().width) ?? 0, E = (e, h) => q(
90
- c.map((f, g) => e.has(g) ? null : f),
92
+ return r.get(u) ?? q(e);
93
+ }), f = a.clientWidth, h = l ? l.getBoundingClientRect().width : 96, _ = (n == null ? void 0 : n.getBoundingClientRect().width) ?? 0, g = (e, i) => B(
94
+ c.map((u, m) => e.has(m) ? null : u),
95
+ f,
96
+ h,
91
97
  _,
92
- i,
93
- u,
94
- h
95
- ), p = /* @__PURE__ */ new Set();
96
- if (E(p, !1).count <= k) return { folded: [], rows: null };
97
- const x = d.map(B), R = d.map(
98
+ i
99
+ ), E = s.map(I), A = s.map(
98
100
  (e) => e.hasAttribute("data-header-money") || e.querySelector("[data-header-money]") != null
99
- ), D = d.map((e) => e.hasAttribute("data-header-pin")), w = (e) => d.map((h, f) => f).filter((h) => !D[h] && e(h)).reverse(), C = [
100
- ...w((e) => x[e]),
101
- ...w((e) => !x[e] && !R[e]),
102
- ...w((e) => !x[e] && R[e])
101
+ ), k = s.map((e) => e.hasAttribute("data-header-pin")), D = (e) => [...e].sort((i, u) => i - u).map((i) => {
102
+ var u, m;
103
+ return {
104
+ index: i,
105
+ key: o[i],
106
+ empty: E[i],
107
+ money: A[i],
108
+ label: ((m = (u = s[i].querySelector("[data-header-label]")) == null ? void 0 : u.textContent) == null ? void 0 : m.trim()) ?? ""
109
+ };
110
+ }), p = new Set(c.flatMap((e, i) => !k[i] && e > f + 0.5 ? [i] : []));
111
+ if (g(p, !1).count <= S) return { folded: D(p), rows: null };
112
+ const y = (e) => s.map((i, u) => u).filter((i) => !k[i] && e(i)).reverse(), C = [
113
+ ...y((e) => E[e]),
114
+ ...y((e) => !E[e] && !A[e]),
115
+ ...y((e) => !E[e] && A[e])
103
116
  ];
104
- let m = E(p, !0);
117
+ let x = g(p, !0);
105
118
  for (const e of C) {
106
- if (m.count <= k) break;
107
- p.add(e), m = E(p, !0);
119
+ if (x.count <= S) break;
120
+ p.has(e) || (p.add(e), x = g(p, !0));
108
121
  }
109
- const y = {};
110
- return m.rowOf.forEach((e, h) => {
111
- e >= 0 && (y[String(s[h])] = e);
112
- }), m.chipRow >= 0 && (y[W] = m.chipRow), {
113
- folded: [...p].sort((e, h) => e - h).map((e) => {
114
- var h, f;
115
- return {
116
- index: e,
117
- key: s[e],
118
- empty: x[e],
119
- label: ((f = (h = d[e].querySelector("[data-header-label]")) == null ? void 0 : h.textContent) == null ? void 0 : f.trim()) ?? ""
120
- };
121
- }),
122
- rows: y
123
- };
122
+ const w = {};
123
+ return x.rowOf.forEach((e, i) => {
124
+ e >= 0 && (w[String(o[i])] = e);
125
+ }), x.chipRow >= 0 && (w[W] = x.chipRow), { folded: D(p), rows: w };
124
126
  }
125
127
  export {
126
- I as HEADER_BAND,
127
- S as HEADER_CELL_DENSE,
128
- H as HEADER_CELL_FOLDED,
129
- L as HEADER_CELL_LIST,
130
- T as HEADER_DOCK,
131
- F as HEADER_DOCK_CELL,
132
- V as HEADER_DOCK_INLINE,
133
- U as HEADER_LABEL,
134
- k as HEADER_MAX_ROWS,
128
+ K as HEADER_BAND,
129
+ L as HEADER_CELL_DENSE,
130
+ O as HEADER_CELL_FOLDED,
131
+ H as HEADER_CELL_LIST,
132
+ j as HEADER_DOCK,
133
+ P as HEADER_DOCK_CELL,
134
+ F as HEADER_DOCK_INLINE,
135
+ T as HEADER_LABEL,
136
+ X as HEADER_MARK,
137
+ S as HEADER_MAX_ROWS,
135
138
  W as HEADER_MORE_ROW_KEY,
136
- N as HEADER_ROW,
137
- P as HEADER_SUB,
138
- $ as HEADER_TILE,
139
- K as HEADER_TILES,
140
- j as HEADER_VALUE,
141
- M as HEADER_VALUE_HERO,
142
- X as HEADER_VALUE_LINE,
143
- B as headerCellIsEmpty,
144
- b as headerCellKeys,
145
- A as headerCells,
146
- Y as headerChangedCells,
147
- O as headerEstimateDenseWidth,
148
- G as headerFoldPlan,
149
- z as headerNeedsDense,
150
- q as headerPackRows
139
+ M as HEADER_ROW,
140
+ z as HEADER_SUB,
141
+ U as HEADER_TILE,
142
+ N as HEADER_TILES,
143
+ V as HEADER_VALUE,
144
+ Y as HEADER_VALUE_AFTER_MARK,
145
+ $ as HEADER_VALUE_HERO,
146
+ G as HEADER_VALUE_LINE,
147
+ Z as foldedListOrder,
148
+ I as headerCellIsEmpty,
149
+ R as headerCellKeys,
150
+ b as headerCells,
151
+ J as headerChangedCells,
152
+ q as headerEstimateDenseWidth,
153
+ ee as headerFoldPlan,
154
+ Q as headerNeedsDense,
155
+ B as headerPackRows
151
156
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.118",
3
+ "version": "0.3.120",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",