@memobit/libs 3.18.0 → 3.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,441 +1,334 @@
1
1
  import './DataView.css';
2
- import { Icon as O } from "../Icon/Icon2.js";
2
+ import { Icon as ut } from "../Icon/Icon2.js";
3
3
  import { Button as ft } from "../Button/Button2.js";
4
- import { Tooltip as Ee } from "../Tooltip/Tooltip2.js";
5
- import { Checkbox as re } from "../Checkbox/Checkbox2.js";
6
- import { Dropdown as pt } from "../Dropdown/Dropdown2.js";
4
+ import { Tooltip as mt } from "../Tooltip/Tooltip2.js";
5
+ import { Checkbox as pt } from "../Checkbox/Checkbox2.js";
6
+ import { Dropdown as ht } from "../Dropdown/Dropdown2.js";
7
7
  import { useBreakpoint as vt } from "../../hooks/useBreakpoint.js";
8
- import { getResultsCount as _t } from "../../helpers/Pagination.js";
9
- import { EmptyState as oe } from "../EmptyState/EmptyState2.js";
10
- import { Pagination as Ge } from "../Pagination/Pagination2.js";
11
- import { calculateTimelineMarkers as wt } from "../TimelineMarkers/calculateTimelineMarkers.js";
12
- import { TimelineMarkerDot as gt } from "../TimelineMarkers/TimelineMarkers2.js";
13
- import { DEFAULT_PAGE_SIZES as Le, getColumnLabel as bt, renderCellContent as kt, renderColumnLabel as yt } from "./DataView.helpers.js";
14
- import { CardView as Ct } from "./DataView.CardView.js";
15
- import { DataViewColumnSelector as Nt } from "./DataView.ColumnSelector.js";
16
- import { DataViewMiniSort as St } from "./DataView.MiniSort.js";
8
+ import { getResultsCount as gt } from "../../helpers/Pagination.js";
9
+ import { useListMotion as wt } from "../../hooks/useListMotion/useListMotion.js";
10
+ import { EmptyState as bt } from "../EmptyState/EmptyState2.js";
11
+ import { Pagination as St } from "../Pagination/Pagination2.js";
12
+ import { calculateTimelineMarkers as yt } from "../TimelineMarkers/calculateTimelineMarkers.js";
13
+ import { DEFAULT_PAGE_SIZES as Ee, getColumnLabel as Ct } from "./DataView.helpers.js";
14
+ import { CardView as _t } from "./DataView.CardView.js";
15
+ import { DataViewColumnSelector as kt } from "./DataView.ColumnSelector.js";
16
+ import { DataViewMiniSort as Mt } from "./DataView.MiniSort.js";
17
+ import { TableView as Nt } from "./DataView.TableView.js";
17
18
  /* empty css */
18
- import Ve, { useCallback as Mt, useMemo as L, useState as P } from "react";
19
- import { Fragment as Pt, jsx as t, jsxs as c } from "react/jsx-runtime";
20
- function $t({ state: h }) {
21
- return /* @__PURE__ */ t("span", {
22
- className: `data-view__sort-icon data-view__sort-icon--${h}`,
23
- children: /* @__PURE__ */ t(O, { name: h === "asc" ? "arrow-up" : h === "desc" ? "arrow-down" : "arrow-bidirectional-vertical" })
24
- });
25
- }
26
- function Xt({ columns: h, data: R, rowKey: le, pinnedIds: y, selectable: w = !1, onSelectionChange: xe, selectedIds: ce, pageSizeOptions: de = Le, initialPageSize: Be = Le[1], showPageSize: $ = !0, card: Fe, actions: C, actionsWidth: z, timeline: N, onRowClick: K, rowHref: he, rowClassName: ue, rowDetail: Ie, empty: S, initialSortKey: Re = null, initialSortDirection: ze = "asc", sortKey: X, sortDirection: me, onSortChange: Ke, miniSort: U, showCardSortControls: Ue = !0, desktopView: fe = "table", cardMaxWidth: We, className: D, onPageChange: je, onPageSizeChange: pe, currentPage: ve, totalItems: _e, group: o, showResultsCount: Oe = !0, totalCount: Xe, itemNoun: Ze, columnSelector: Z }) {
27
- const { isMobile: we } = vt(), [qe, Je] = P(Re), [Qe, Ye] = P(ze), [He, et] = P([]), f = ce ?? He, [tt, at] = P(1), nt = ve ?? tt, [T, ge] = P(Be), [M, it] = P(() => h.reduce((e, a) => (a.width && (e[a.key] = a.width), e), {})), [be, st] = P(/* @__PURE__ */ new Set()), ke = (e) => {
28
- st((a) => {
29
- const s = new Set(a);
19
+ import { useCallback as Ge, useEffect as Tt, useMemo as E, useRef as De, useState as C } from "react";
20
+ import { Fragment as Et, jsx as r, jsxs as _ } from "react/jsx-runtime";
21
+ function Ht({ columns: l, data: L, rowKey: F, pinnedIds: p, selectable: G = !1, onSelectionChange: Pe, selectedIds: I, pageSizeOptions: Ve = Ee, initialPageSize: Le = Ee[1], showPageSize: U = !0, card: Re, actions: ee, actionsWidth: xe, timeline: h, onRowClick: te, rowHref: oe, rowClassName: ne, rowDetail: Ae, empty: se, initialSortKey: $e = null, initialSortDirection: Be = "asc", sortKey: W, sortDirection: re, onSortChange: ze, miniSort: R, showCardSortControls: Fe = !0, desktopView: ie = "table", cardMaxWidth: Ue, className: k, onPageChange: ae, onPageSizeChange: We, currentPage: K, totalItems: le, group: i, showResultsCount: Ke = !0, totalCount: Xe, itemNoun: je, columnSelector: X, animateChanges: Oe = !0, highlightIds: v }) {
22
+ const { isMobile: ce } = vt(), x = De(null), A = wt(x, {
23
+ enabled: Oe && F !== void 0,
24
+ highlightKeys: v
25
+ }), [Ze, qe] = C($e), [He, Je] = C(Be), [Qe, Ye] = C([]), f = I ?? Qe, [Ie, et] = C(1), j = K ?? Ie, [g, tt] = C(Le), [de, ot] = C(() => l.reduce((e, t) => (t.width && (e[t.key] = t.width), e), {})), [ue, nt] = C(/* @__PURE__ */ new Set()), fe = (e) => {
26
+ A.forceNext(), nt((t) => {
27
+ const s = new Set(t);
30
28
  return s.has(e) ? s.delete(e) : s.add(e), s;
31
29
  });
32
- }, g = Mt((e, a) => le?.(e, a) ?? a, [le]), V = (e) => {
33
- ve === void 0 && at(e), je?.(e);
34
- }, p = X !== void 0 ? X : qe, v = me ?? Qe, A = (e, a) => {
35
- X === void 0 && Je(e), me === void 0 && Ye(a), Ke?.({
30
+ }, c = Ge((e, t) => F?.(e, t) ?? t, [F]), D = Ge((e) => {
31
+ e !== j && A.skipNext(), K === void 0 && et(e), ae?.(e);
32
+ }, [
33
+ K,
34
+ j,
35
+ A,
36
+ ae
37
+ ]), d = W !== void 0 ? W : Ze, u = re ?? He, M = (e, t) => {
38
+ W === void 0 && qe(e), re === void 0 && Je(t), ze?.({
36
39
  key: e,
37
- direction: a
38
- }), V(1);
39
- }, W = L(() => new Set(y ?? []), [y]), q = L(() => {
40
- let e = R;
41
- if (p) {
42
- const n = h.find((i) => i.key === p);
43
- if (n) {
44
- const i = n.sortAccessor || n.accessor || ((m) => {
45
- const u = m[n.key];
46
- return typeof u == "string" || typeof u == "number" ? u : "";
47
- }), r = [...R].sort((m, u) => {
48
- const _ = i(m), d = i(u);
49
- return typeof _ == "number" && typeof d == "number" ? _ - d : String(_).localeCompare(String(d));
40
+ direction: t
41
+ }), D(1);
42
+ }, $ = E(() => new Set(p ?? []), [p]), O = E(() => {
43
+ let e = L;
44
+ if (d) {
45
+ const o = l.find((n) => n.key === d);
46
+ if (o) {
47
+ const n = o.sortAccessor || o.accessor || ((P) => {
48
+ const S = P[o.key];
49
+ return typeof S == "string" || typeof S == "number" ? S : "";
50
+ }), a = [...L].sort((P, S) => {
51
+ const V = n(P), y = n(S);
52
+ return typeof V == "number" && typeof y == "number" ? V - y : String(V).localeCompare(String(y));
50
53
  });
51
- e = v === "asc" ? r : r.reverse();
54
+ e = u === "asc" ? a : a.reverse();
52
55
  }
53
56
  }
54
- if (W.size === 0) return e;
55
- const a = [], s = [];
56
- if (e.forEach((n, i) => {
57
- W.has(g(n, i)) ? a.push(n) : s.push(n);
58
- }), y && y.length > 1 && a.length > 1) {
59
- const n = new Map(y.map((i, r) => [i, r]));
60
- a.sort((i, r) => (n.get(g(i, 0)) ?? 0) - (n.get(g(r, 0)) ?? 0));
57
+ if ($.size === 0) return e;
58
+ const t = [], s = [];
59
+ if (e.forEach((o, n) => {
60
+ $.has(c(o, n)) ? t.push(o) : s.push(o);
61
+ }), p && p.length > 1 && t.length > 1) {
62
+ const o = new Map(p.map((n, a) => [n, a]));
63
+ t.sort((n, a) => (o.get(c(n, 0)) ?? 0) - (o.get(c(a, 0)) ?? 0));
61
64
  }
62
- return [...a, ...s];
65
+ return [...t, ...s];
63
66
  }, [
64
- h,
65
- R,
66
- v,
67
+ l,
68
+ L,
69
+ u,
70
+ d,
71
+ $,
67
72
  p,
68
- W,
69
- y,
70
- g
71
- ]), j = _e !== void 0, x = L(() => {
72
- if (!o || j) return q;
73
- const e = /* @__PURE__ */ new Map(), a = [];
74
- q.forEach((n) => {
75
- const i = o.groupBy(n), r = e.get(i);
76
- r ? r.push(n) : (e.set(i, [n]), a.push(i));
73
+ c
74
+ ]), N = le !== void 0, w = E(() => {
75
+ if (!i || N) return O;
76
+ const e = /* @__PURE__ */ new Map(), t = [];
77
+ O.forEach((o) => {
78
+ const n = i.groupBy(o), a = e.get(n);
79
+ a ? a.push(o) : (e.set(n, [o]), t.push(n));
77
80
  });
78
- const s = a.map((n) => {
79
- const i = e.get(n);
81
+ const s = t.map((o) => {
82
+ const n = e.get(o);
80
83
  return {
81
- key: n,
82
- label: o.groupLabel(n),
83
- items: i,
84
- totalCount: i.length
84
+ key: o,
85
+ label: i.groupLabel(o),
86
+ items: n,
87
+ totalCount: n.length
85
88
  };
86
89
  });
87
- return o.sortGroups ? s.sort(o.sortGroups) : s.sort((n, i) => n.key === null ? 1 : i.key === null ? -1 : 0), s.flatMap((n) => n.items);
90
+ return i.sortGroups ? s.sort(i.sortGroups) : s.sort((o, n) => o.key === null ? 1 : n.key === null ? -1 : 0), s.flatMap((o) => o.items);
88
91
  }, [
89
- o,
90
- j,
91
- q
92
- ]), B = j ? _e : x.length, J = Math.max(1, Math.ceil(B / T)), F = Math.min(nt, J), b = j ? x : x.slice((F - 1) * T, F * T), Q = Oe ? _t(T, B, Xe ?? B, F, Ze) : null, Y = L(() => {
93
- if (!o) return null;
92
+ i,
93
+ N,
94
+ O
95
+ ]), B = N ? le : w.length, me = Math.max(1, Math.ceil(B / g)), T = Math.min(j, me), b = N ? w : w.slice((T - 1) * g, T * g), pe = De(void 0);
96
+ Tt(() => {
97
+ if (!v || v.length === 0 || N || pe.current === v) return;
98
+ const e = w.findIndex((s, o) => v.includes(c(s, o)));
99
+ if (e === -1) return;
100
+ pe.current = v;
101
+ const t = Math.floor(e / g) + 1;
102
+ t !== T && D(t);
103
+ }, [
104
+ D,
105
+ v,
106
+ N,
107
+ w,
108
+ g,
109
+ c,
110
+ T
111
+ ]);
112
+ const Z = Ke ? gt(g, B, Xe ?? B, T, je) : null, q = E(() => {
113
+ if (!i) return null;
94
114
  const e = /* @__PURE__ */ new Map();
95
- return x.forEach((a) => {
96
- const s = o.groupBy(a);
115
+ return w.forEach((t) => {
116
+ const s = i.groupBy(t);
97
117
  e.set(s, (e.get(s) ?? 0) + 1);
98
118
  }), e;
99
- }, [o, x]), H = L(() => {
100
- if (!o || !Y) return null;
101
- const e = /* @__PURE__ */ new Map(), a = [];
102
- b.forEach((n) => {
103
- const i = o.groupBy(n), r = e.get(i);
104
- r ? r.push(n) : (e.set(i, [n]), a.push(i));
119
+ }, [i, w]), he = E(() => {
120
+ if (!i || !q) return null;
121
+ const e = /* @__PURE__ */ new Map(), t = [];
122
+ b.forEach((o) => {
123
+ const n = i.groupBy(o), a = e.get(n);
124
+ a ? a.push(o) : (e.set(n, [o]), t.push(n));
105
125
  });
106
- const s = a.map((n) => ({
107
- key: n,
108
- label: o.groupLabel(n),
109
- items: e.get(n),
110
- totalCount: Y.get(n) ?? 0
126
+ const s = t.map((o) => ({
127
+ key: o,
128
+ label: i.groupLabel(o),
129
+ items: e.get(o),
130
+ totalCount: q.get(o) ?? 0
111
131
  }));
112
- return o.sortGroups ? s.sort(o.sortGroups) : s.sort((n, i) => n.key === null ? 1 : i.key === null ? -1 : 0), s;
132
+ return i.sortGroups ? s.sort(i.sortGroups) : s.sort((o, n) => o.key === null ? 1 : n.key === null ? -1 : 0), s;
113
133
  }, [
114
- o,
115
- Y,
134
+ i,
135
+ q,
116
136
  b
117
- ]), ye = L(() => {
118
- if (!N) return /* @__PURE__ */ new Map();
119
- const e = b.map((a) => ({
120
- id: N.idAccessor(a),
121
- date: N.dateAccessor(a)
137
+ ]), ve = E(() => {
138
+ if (!h) return /* @__PURE__ */ new Map();
139
+ const e = b.map((t) => ({
140
+ id: h.idAccessor(t),
141
+ date: h.dateAccessor(t)
122
142
  }));
123
- return wt(e, N.granularity);
124
- }, [b, N]), E = (e) => {
125
- ce === void 0 && et(e), xe?.(R.filter((a, s) => e.includes(g(a, s))));
126
- }, rt = (e) => {
127
- e.sortable && (p === e.key ? A(e.key, v === "asc" ? "desc" : "asc") : A(e.key, "asc"));
128
- }, ot = (e, a) => {
143
+ return yt(e, h.granularity);
144
+ }, [b, h]), z = (e) => {
145
+ I === void 0 && Ye(e), Pe?.(L.filter((t, s) => e.includes(c(t, s))));
146
+ }, ge = (e, t) => {
147
+ z(t ? [...f, e] : f.filter((s) => s !== e));
148
+ }, st = (e) => {
149
+ e.sortable && (d === e.key ? M(e.key, u === "asc" ? "desc" : "asc") : M(e.key, "asc"));
150
+ }, rt = (e, t) => {
129
151
  e.preventDefault();
130
- const s = e.clientX, n = M[a] ?? 150, i = (m) => {
131
- const u = m.clientX - s, _ = h.find((d) => d.key === a)?.minWidth ?? 120;
132
- it((d) => ({
133
- ...d,
134
- [a]: Math.max(_, n + u)
152
+ const s = e.clientX, o = de[t] ?? 150, n = (P) => {
153
+ const S = P.clientX - s, V = l.find((y) => y.key === t)?.minWidth ?? 120;
154
+ ot((y) => ({
155
+ ...y,
156
+ [t]: Math.max(V, o + S)
135
157
  }));
136
- }, r = () => {
137
- window.removeEventListener("mousemove", i), window.removeEventListener("mouseup", r);
158
+ }, a = () => {
159
+ window.removeEventListener("mousemove", n), window.removeEventListener("mouseup", a);
138
160
  };
139
- window.addEventListener("mousemove", i), window.addEventListener("mouseup", r);
140
- }, Ce = h.some((e) => e.filter), ee = h.filter((e) => e.sortable), lt = ee.map((e) => ({
141
- label: bt(e),
161
+ window.addEventListener("mousemove", n), window.addEventListener("mouseup", a);
162
+ }, we = l.some((e) => e.filter), H = l.filter((e) => e.sortable), it = H.map((e) => ({
163
+ label: Ct(e),
142
164
  value: e.key
143
- })), ct = ee.length > 0, te = p ? ee.find((e) => e.key === p) : void 0, dt = U?.align ?? "left", Ne = (U?.columns ?? U?.column ?? []).length > 0 ? /* @__PURE__ */ t(St, {
144
- columns: h,
145
- config: U,
146
- sortKey: p,
147
- sortDirection: v,
148
- onSort: A
149
- }) : null, Se = Z && Z.options.length > 0 ? /* @__PURE__ */ t(Nt, { config: Z }) : null, k = b.map(g), ae = k.filter((e) => f.includes(e)).length, ne = !!w && k.length > 0 && ae === k.length, Me = !!w && ae > 0 && ae < k.length, Pe = (e) => {
150
- E(e ? [...f, ...k.filter((a) => !f.includes(a))] : f.filter((a) => !k.includes(a)));
151
- }, ht = w && k.length > 0 ? /* @__PURE__ */ c("label", {
165
+ })), at = H.length > 0, J = d ? H.find((e) => e.key === d) : void 0, lt = R?.align ?? "left", be = (R?.columns ?? R?.column ?? []).length > 0 ? /* @__PURE__ */ r(Mt, {
166
+ columns: l,
167
+ config: R,
168
+ sortKey: d,
169
+ sortDirection: u,
170
+ onSort: M
171
+ }) : null, Se = X && X.options.length > 0 ? /* @__PURE__ */ r(kt, { config: X }) : null, m = b.map(c), Q = m.filter((e) => f.includes(e)).length, Y = !!G && m.length > 0 && Q === m.length, ye = !!G && Q > 0 && Q < m.length, Ce = (e) => {
172
+ z(e ? [...f, ...m.filter((t) => !f.includes(t))] : f.filter((t) => !m.includes(t)));
173
+ }, ct = G && m.length > 0 ? /* @__PURE__ */ _("label", {
152
174
  className: "data-view__select-all",
153
- children: [/* @__PURE__ */ t(re, {
154
- checked: ne,
155
- indeterminate: Me,
156
- onChange: Pe
157
- }), /* @__PURE__ */ t("span", { children: ne ? "Clear selection" : `Select these ${k.length}` })]
158
- }) : null, $e = (e) => Q || Ne || Se || e ? /* @__PURE__ */ c("div", {
159
- className: `data-view__top-row data-view__top-row--mini-${dt}`,
175
+ children: [/* @__PURE__ */ r(pt, {
176
+ checked: Y,
177
+ indeterminate: ye,
178
+ onChange: Ce
179
+ }), /* @__PURE__ */ r("span", { children: Y ? "Clear selection" : `Select these ${m.length}` })]
180
+ }) : null, _e = (e) => Z || be || Se || e ? /* @__PURE__ */ _("div", {
181
+ className: `data-view__top-row data-view__top-row--mini-${lt}`,
160
182
  children: [
161
- Q && /* @__PURE__ */ t("div", {
183
+ Z && /* @__PURE__ */ r("div", {
162
184
  className: "data-view__results-count",
163
- children: Q
185
+ children: Z
164
186
  }),
165
187
  e,
166
- Ne,
188
+ be,
167
189
  Se
168
190
  ]
169
- }) : null, De = $e();
170
- if (fe !== "cards" && h.length === 0) return /* @__PURE__ */ c("div", {
171
- className: `data-view${D ? ` ${D}` : ""}`,
172
- children: [De, /* @__PURE__ */ t("div", {
191
+ }) : null, ke = _e(), Me = /* @__PURE__ */ r(St, {
192
+ currentPage: T,
193
+ totalPages: me,
194
+ totalItems: B,
195
+ onPageChange: D,
196
+ pageSizeOptions: U ? Ve : void 0,
197
+ pageSize: U ? g : void 0,
198
+ onPageSizeChange: U ? (e) => {
199
+ A.skipNext(), tt(e), D(1), We?.(e);
200
+ } : void 0
201
+ });
202
+ if (ie !== "cards" && l.length === 0) return /* @__PURE__ */ _("div", {
203
+ className: `data-view${k ? ` ${k}` : ""}`,
204
+ ref: x,
205
+ children: [ke, /* @__PURE__ */ r("div", {
173
206
  className: "data-view__wrapper data-view__wrapper--empty",
174
- children: /* @__PURE__ */ t(oe, {
207
+ children: /* @__PURE__ */ r(bt, {
175
208
  title: "No columns selected",
176
209
  description: "Use the Columns button above to pick which columns to display."
177
210
  })
178
211
  })]
179
212
  });
180
- if (fe === "cards") return /* @__PURE__ */ c("div", {
181
- className: `data-view data-view--cards${D ? ` ${D}` : ""}`,
213
+ if (ie === "cards") return /* @__PURE__ */ _("div", {
214
+ className: `data-view data-view--cards${k ? ` ${k}` : ""}`,
215
+ ref: x,
182
216
  children: [
183
- $e(ht),
184
- Ue && ct && /* @__PURE__ */ c("div", {
217
+ _e(ct),
218
+ Fe && at && /* @__PURE__ */ _("div", {
185
219
  className: "data-view__card-sort-bar",
186
- children: [/* @__PURE__ */ t("div", {
220
+ children: [/* @__PURE__ */ r("div", {
187
221
  className: "data-view__card-sort-field",
188
- children: /* @__PURE__ */ t(pt, {
222
+ children: /* @__PURE__ */ r(ht, {
189
223
  name: "data-view-card-sort",
190
224
  label: "Sort by",
191
- options: lt,
192
- value: p,
225
+ options: it,
226
+ value: d,
193
227
  placeholder: "Sort by...",
194
228
  searchable: !1,
195
229
  usePortal: !1,
196
230
  onChange: (e) => {
197
231
  if (!e || Array.isArray(e)) {
198
- A(null, v);
232
+ M(null, u);
199
233
  return;
200
234
  }
201
- const a = String(e.value);
202
- A(a, p === a ? v : "asc");
235
+ const t = String(e.value);
236
+ M(t, d === t ? u : "asc");
203
237
  }
204
238
  })
205
- }), /* @__PURE__ */ t(Ee, {
206
- title: v === "asc" ? "Sort descending" : "Sort ascending",
207
- children: /* @__PURE__ */ t(ft, {
239
+ }), /* @__PURE__ */ r(mt, {
240
+ title: u === "asc" ? "Sort descending" : "Sort ascending",
241
+ children: /* @__PURE__ */ r(ft, {
208
242
  className: "data-view__card-sort-direction",
209
- disabled: !te,
243
+ disabled: !J,
210
244
  onClick: () => {
211
- te && A(te.key, v === "asc" ? "desc" : "asc");
245
+ J && M(J.key, u === "asc" ? "desc" : "asc");
212
246
  },
213
247
  variant: "ghost",
214
- children: /* @__PURE__ */ t(O, { name: v === "asc" ? "arrow-up" : "arrow-down" })
248
+ children: /* @__PURE__ */ r(ut, { name: u === "asc" ? "arrow-up" : "arrow-down" })
215
249
  })
216
250
  })]
217
251
  }),
218
- Ce && /* @__PURE__ */ t("div", {
252
+ we && /* @__PURE__ */ r("div", {
219
253
  className: "data-view__filter-bar",
220
- children: h.filter((e) => e.filter).map((e) => /* @__PURE__ */ t("div", {
254
+ children: l.filter((e) => e.filter).map((e) => /* @__PURE__ */ r("div", {
221
255
  className: "data-view__filter-bar-item",
222
256
  children: e.filter
223
257
  }, e.key))
224
258
  }),
225
- /* @__PURE__ */ t(Ct, {
259
+ /* @__PURE__ */ r(_t, {
226
260
  data: b,
227
- columns: h,
228
- rowKey: g,
229
- card: Fe,
230
- actions: C,
231
- timeline: N,
232
- onRowClick: K,
233
- rowHref: he,
234
- rowClassName: ue,
235
- empty: S,
236
- selectable: w,
261
+ columns: l,
262
+ rowKey: c,
263
+ card: Re,
264
+ actions: ee,
265
+ timeline: h,
266
+ onRowClick: te,
267
+ rowHref: oe,
268
+ rowClassName: ne,
269
+ empty: se,
270
+ selectable: G,
237
271
  selectedIds: f,
238
- pinnedIds: y,
239
- cardMaxWidth: We,
240
- isMobile: we,
241
- groups: H ?? void 0,
242
- showGroupCount: o?.showCount !== !1,
243
- collapsible: o?.collapsible,
244
- collapsedGroups: be,
245
- onToggleGroup: ke,
246
- onToggleSelect: (e, a) => {
247
- E(a ? [...f, e] : f.filter((s) => s !== e));
248
- }
272
+ pinnedIds: p,
273
+ cardMaxWidth: Ue,
274
+ isMobile: ce,
275
+ groups: he ?? void 0,
276
+ showGroupCount: i?.showCount !== !1,
277
+ collapsible: i?.collapsible,
278
+ collapsedGroups: ue,
279
+ onToggleGroup: fe,
280
+ onToggleSelect: ge
249
281
  }),
250
- /* @__PURE__ */ t(Ge, {
251
- currentPage: F,
252
- totalPages: J,
253
- totalItems: B,
254
- onPageChange: V,
255
- pageSizeOptions: $ ? de : void 0,
256
- pageSize: $ ? T : void 0,
257
- onPageSizeChange: $ ? (e) => {
258
- ge(e), V(1), pe?.(e);
259
- } : void 0
260
- })
282
+ Me
261
283
  ]
262
284
  });
263
- const I = h.filter((e) => !e.hideInTable && !(we && e.hideInMobile)), G = N && ye.size > 0, Te = /* @__PURE__ */ c(Pt, { children: [
264
- De,
265
- /* @__PURE__ */ t("div", {
285
+ const dt = l.filter((e) => !e.hideInTable && !(ce && e.hideInMobile)), Ne = h && ve.size > 0, Te = /* @__PURE__ */ _(Et, { children: [
286
+ ke,
287
+ /* @__PURE__ */ r("div", {
266
288
  className: "data-view__wrapper",
267
- children: /* @__PURE__ */ c("table", { children: [/* @__PURE__ */ c("thead", { children: [/* @__PURE__ */ c("tr", { children: [
268
- G && /* @__PURE__ */ t("th", { className: "data-view__timeline-cell" }),
269
- w && /* @__PURE__ */ t("th", {
270
- className: "data-view__checkbox",
271
- children: /* @__PURE__ */ t(re, {
272
- checked: ne,
273
- indeterminate: Me,
274
- onChange: Pe
275
- })
276
- }),
277
- I.map((e) => {
278
- const a = {};
279
- return M[e.key] && (a.width = M[e.key]), e.minWidth && (a.minWidth = e.minWidth), /* @__PURE__ */ c("th", {
280
- style: Object.keys(a).length > 0 ? a : void 0,
281
- className: e.sortable ? "is-sortable" : "",
282
- onClick: () => rt(e),
283
- children: [/* @__PURE__ */ c("span", {
284
- className: "data-view__th-content",
285
- children: [yt(e), e.sortable && /* @__PURE__ */ t($t, { state: p === e.key ? v : "unsorted" })]
286
- }), /* @__PURE__ */ t("span", {
287
- className: "data-view__resizer",
288
- onMouseDown: (s) => ot(s, e.key),
289
- onClick: (s) => s.stopPropagation()
290
- })]
291
- }, e.key);
292
- }),
293
- C && /* @__PURE__ */ t("th", {
294
- className: "data-view__actions-header",
295
- style: z ? { width: z } : void 0,
296
- children: "Actions"
297
- })
298
- ] }), Ce && /* @__PURE__ */ c("tr", {
299
- className: "data-view__filter-row",
300
- children: [
301
- G && /* @__PURE__ */ t("td", { className: "data-view__filter-cell data-view__filter-cell--spacer" }),
302
- w && /* @__PURE__ */ t("td", { className: "data-view__filter-cell data-view__filter-cell--spacer" }),
303
- I.map((e) => /* @__PURE__ */ t("td", {
304
- className: "data-view__filter-cell",
305
- style: M[e.key] ? { width: M[e.key] } : void 0,
306
- children: e.filter ?? null
307
- }, e.key)),
308
- C && /* @__PURE__ */ t("td", { className: "data-view__filter-cell data-view__filter-cell--spacer" })
309
- ]
310
- })] }), /* @__PURE__ */ t("tbody", { children: (() => {
311
- if (b.length === 0) return /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", {
312
- colSpan: I.length + (G ? 1 : 0) + (w ? 1 : 0) + (C ? 1 : 0),
313
- className: "data-view__empty",
314
- children: S ? /* @__PURE__ */ t(oe, {
315
- title: S.title,
316
- description: S.description,
317
- icon: S.icon,
318
- primary: S.primary,
319
- secondary: S.secondary
320
- }) : /* @__PURE__ */ t(oe, { title: "No data available" })
321
- }) });
322
- const e = I.length + (G ? 1 : 0) + (w ? 1 : 0) + (C ? 1 : 0), a = o?.showCount !== !1, s = (n, i) => {
323
- const r = g(n, i), m = f.includes(r), u = W.has(r), _ = ye.get(i), d = he?.(n), Ae = !!K || !!d, ut = (l) => {
324
- if (d && (l.metaKey || l.ctrlKey || l.shiftKey)) {
325
- window.open(d, "_blank", "noopener,noreferrer");
326
- return;
327
- }
328
- if (K) {
329
- K(n, l);
330
- return;
331
- }
332
- d && window.location.assign(d);
333
- }, mt = (l) => {
334
- l.button !== 1 || !d || (l.preventDefault(), window.open(d, "_blank", "noopener,noreferrer"));
335
- }, ie = Ie?.(n);
336
- return /* @__PURE__ */ c(Ve.Fragment, { children: [/* @__PURE__ */ c("tr", {
337
- className: `${m ? "is-selected" : ""} ${Ae ? "data-view__row--clickable" : ""} ${u ? "data-view__row--pinned" : ""} ${ue?.(n) || ""}`,
338
- onClick: Ae ? ut : void 0,
339
- onAuxClick: d ? mt : void 0,
340
- children: [
341
- G && /* @__PURE__ */ t("td", {
342
- className: "data-view__timeline-cell",
343
- children: _ && /* @__PURE__ */ t(gt, { marker: _ })
344
- }),
345
- w && /* @__PURE__ */ t("td", {
346
- className: "data-view__checkbox",
347
- onClick: (l) => l.stopPropagation(),
348
- children: /* @__PURE__ */ t(re, {
349
- checked: m,
350
- onChange: (l) => {
351
- E(l ? [...f, r] : f.filter((se) => se !== r));
352
- }
353
- })
354
- }),
355
- I.map((l, se) => /* @__PURE__ */ c("td", {
356
- style: M[l.key] ? { width: M[l.key] } : void 0,
357
- children: [se === 0 && u && /* @__PURE__ */ t(Ee, {
358
- title: "Pinned",
359
- children: /* @__PURE__ */ t(O, {
360
- className: "data-view__pin-indicator",
361
- name: "pin",
362
- size: "sm"
363
- })
364
- }), kt(l, n)]
365
- }, l.key)),
366
- C && /* @__PURE__ */ t("td", {
367
- className: "data-view__actions-cell",
368
- style: z ? { width: z } : void 0,
369
- children: /* @__PURE__ */ t("div", {
370
- className: "data-view__table-actions",
371
- onClick: (l) => l.stopPropagation(),
372
- children: C(n)
373
- })
374
- })
375
- ]
376
- }), ie != null && ie !== !1 && /* @__PURE__ */ t("tr", {
377
- className: "data-view__row-detail",
378
- children: /* @__PURE__ */ t("td", {
379
- colSpan: e,
380
- onClick: (l) => l.stopPropagation(),
381
- children: ie
382
- })
383
- })] }, r);
384
- };
385
- if (H) {
386
- let n = 0;
387
- return H.map((i) => {
388
- const r = n;
389
- n += i.items.length;
390
- const m = o?.collapsible && be.has(i.key);
391
- return /* @__PURE__ */ c(Ve.Fragment, { children: [/* @__PURE__ */ t("tr", {
392
- className: `data-view__group-row${o?.collapsible ? " data-view__group-row--collapsible" : ""}`,
393
- onClick: o?.collapsible ? () => ke(i.key) : void 0,
394
- children: /* @__PURE__ */ c("td", {
395
- colSpan: e,
396
- className: "data-view__group-cell",
397
- children: [
398
- /* @__PURE__ */ t("span", {
399
- className: "data-view__group-label",
400
- children: i.label
401
- }),
402
- a && /* @__PURE__ */ t("span", {
403
- className: "data-view__group-count",
404
- children: i.items.length === i.totalCount ? i.totalCount : `${i.items.length} of ${i.totalCount}`
405
- }),
406
- o?.collapsible && /* @__PURE__ */ t(O, {
407
- className: "data-view__group-chevron",
408
- name: m ? "caret-down" : "caret-up",
409
- size: "sm"
410
- })
411
- ]
412
- })
413
- }), !m && i.items.map((u, _) => s(u, r + _))] }, i.key ?? "__null__");
414
- });
415
- }
416
- return b.map((n, i) => s(n, i));
417
- })() })] })
289
+ children: /* @__PURE__ */ r(Nt, {
290
+ data: b,
291
+ columns: dt,
292
+ rowKey: c,
293
+ columnWidths: de,
294
+ onResizeStart: rt,
295
+ sortKey: d,
296
+ sortDirection: u,
297
+ onToggleSort: st,
298
+ hasFilters: we,
299
+ showTimeline: !!Ne,
300
+ timelineMarkers: ve,
301
+ selectable: G,
302
+ selectedIds: f,
303
+ allVisibleSelected: Y,
304
+ someVisibleSelected: ye,
305
+ onToggleVisibleSelection: Ce,
306
+ onToggleSelect: ge,
307
+ pinnedSet: $,
308
+ actions: ee,
309
+ actionsWidth: xe,
310
+ onRowClick: te,
311
+ rowHref: oe,
312
+ rowClassName: ne,
313
+ rowDetail: Ae,
314
+ empty: se,
315
+ groups: he,
316
+ group: i,
317
+ collapsedGroups: ue,
318
+ onToggleGroup: fe
319
+ })
418
320
  }),
419
- /* @__PURE__ */ t(Ge, {
420
- currentPage: F,
421
- totalPages: J,
422
- totalItems: B,
423
- onPageChange: V,
424
- pageSizeOptions: $ ? de : void 0,
425
- pageSize: $ ? T : void 0,
426
- onPageSizeChange: $ ? (e) => {
427
- ge(e), V(1), pe?.(e);
428
- } : void 0
429
- })
321
+ Me
430
322
  ] });
431
- return /* @__PURE__ */ t("div", {
432
- className: `data-view${D ? ` ${D}` : ""}`,
433
- children: G ? /* @__PURE__ */ c("div", {
323
+ return /* @__PURE__ */ r("div", {
324
+ className: `data-view${k ? ` ${k}` : ""}`,
325
+ ref: x,
326
+ children: Ne ? /* @__PURE__ */ _("div", {
434
327
  className: "timeline-markers",
435
- children: [/* @__PURE__ */ t("div", { className: "timeline-markers__track" }), Te]
328
+ children: [/* @__PURE__ */ r("div", { className: "timeline-markers__track" }), Te]
436
329
  }) : Te
437
330
  });
438
331
  }
439
332
  export {
440
- Xt as DataView
333
+ Ht as DataView
441
334
  };