@ethanhann/mantine-dataview 0.1.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.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +640 -0
  3. package/dist/components/DataBulkActions/DataBulkActions.d.ts +9 -0
  4. package/dist/components/DataBulkActions/index.d.ts +1 -0
  5. package/dist/components/DataCards/DataCards.d.ts +24 -0
  6. package/dist/components/DataCards/index.d.ts +1 -0
  7. package/dist/components/DataPagination/DataPagination.d.ts +13 -0
  8. package/dist/components/DataPagination/index.d.ts +1 -0
  9. package/dist/components/DataTable/DataTable.d.ts +13 -0
  10. package/dist/components/DataTable/index.d.ts +1 -0
  11. package/dist/components/DataToolbar/DataToolbar.d.ts +16 -0
  12. package/dist/components/DataToolbar/FacetBuckets.d.ts +6 -0
  13. package/dist/components/DataToolbar/FilterControl.d.ts +6 -0
  14. package/dist/components/DataToolbar/FilterControls.d.ts +5 -0
  15. package/dist/components/DataToolbar/SortControl.d.ts +4 -0
  16. package/dist/components/DataToolbar/ViewSwitcher.d.ts +5 -0
  17. package/dist/components/DataToolbar/VisibilityMenu.d.ts +4 -0
  18. package/dist/components/DataToolbar/index.d.ts +2 -0
  19. package/dist/components/DataView/DataView.d.ts +36 -0
  20. package/dist/components/DataView/context.d.ts +13 -0
  21. package/dist/components/DataView/index.d.ts +2 -0
  22. package/dist/components/StateMessage.d.ts +12 -0
  23. package/dist/components/icons.d.ts +14 -0
  24. package/dist/components/types.d.ts +43 -0
  25. package/dist/core/cardComposition.d.ts +34 -0
  26. package/dist/core/exportCsv.d.ts +10 -0
  27. package/dist/core/formatValue.d.ts +4 -0
  28. package/dist/core/resolveStatus.d.ts +11 -0
  29. package/dist/core/useDataView.d.ts +2 -0
  30. package/dist/core/useDataViewFetcher.d.ts +7 -0
  31. package/dist/core/useForceCards.d.ts +8 -0
  32. package/dist/index.cjs +4 -0
  33. package/dist/index.cjs.map +1 -0
  34. package/dist/index.d.ts +19 -0
  35. package/dist/index.js +1395 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/serializer-CGmBq-Jz.cjs +2 -0
  38. package/dist/serializer-CGmBq-Jz.cjs.map +1 -0
  39. package/dist/serializer-u2zq_sU7.js +117 -0
  40. package/dist/serializer-u2zq_sU7.js.map +1 -0
  41. package/dist/stories/data.d.ts +14 -0
  42. package/dist/types/column.d.ts +74 -0
  43. package/dist/types/facets.d.ts +27 -0
  44. package/dist/types/options.d.ts +95 -0
  45. package/dist/types/request.d.ts +18 -0
  46. package/dist/types/state.d.ts +57 -0
  47. package/dist/url/index.cjs +2 -0
  48. package/dist/url/index.cjs.map +1 -0
  49. package/dist/url/index.d.ts +5 -0
  50. package/dist/url/index.js +20 -0
  51. package/dist/url/index.js.map +1 -0
  52. package/dist/url/serializer.d.ts +33 -0
  53. package/dist/url/types.d.ts +23 -0
  54. package/dist/url/useUrlSync.d.ts +23 -0
  55. package/package.json +90 -0
package/dist/index.js ADDED
@@ -0,0 +1,1395 @@
1
+ import { a as e, i as t, n, r, t as i } from "./serializer-u2zq_sU7.js";
2
+ import { createColumnHelper as a, flexRender as o, functionalUpdate as s, getCoreRowModel as c, useReactTable as l } from "@tanstack/react-table";
3
+ import { ActionIcon as u, Anchor as d, Badge as f, Box as p, Button as m, Card as h, Center as g, Checkbox as _, CloseButton as ee, Drawer as te, Group as v, Input as y, Menu as b, MultiSelect as x, NumberInput as S, Pagination as C, Paper as w, Popover as T, RangeSlider as E, SegmentedControl as D, Select as O, SimpleGrid as ne, Skeleton as k, Stack as A, Table as j, Text as M, TextInput as N, UnstyledButton as P, useMantineTheme as F } from "@mantine/core";
4
+ import { Fragment as I, jsx as L, jsxs as R } from "react/jsx-runtime";
5
+ import { Fragment as re, createContext as ie, useCallback as z, useContext as ae, useEffect as B, useMemo as V, useRef as H, useState as U } from "react";
6
+ import { useDisclosure as W, useMediaQuery as G } from "@mantine/hooks";
7
+ import { DatePickerInput as K } from "@mantine/dates";
8
+ import "@mantine/dates/styles.css";
9
+ //#region src/components/DataBulkActions/DataBulkActions.tsx
10
+ function q({ view: e, slots: t, ...n }) {
11
+ let { selection: r } = e;
12
+ return r.count === 0 ? null : /* @__PURE__ */ L(w, {
13
+ withBorder: !0,
14
+ p: "xs",
15
+ radius: "sm",
16
+ role: "region",
17
+ "aria-label": "Bulk actions",
18
+ ...n,
19
+ children: /* @__PURE__ */ R(v, {
20
+ justify: "space-between",
21
+ wrap: "wrap",
22
+ gap: "sm",
23
+ children: [/* @__PURE__ */ R(v, {
24
+ gap: "sm",
25
+ children: [/* @__PURE__ */ R(M, {
26
+ size: "sm",
27
+ fw: 500,
28
+ children: [r.count, " selected"]
29
+ }), /* @__PURE__ */ L(m, {
30
+ variant: "subtle",
31
+ size: "xs",
32
+ onClick: r.clear,
33
+ children: "Clear"
34
+ })]
35
+ }), t?.BulkActions && /* @__PURE__ */ L(v, {
36
+ gap: "xs",
37
+ children: t.BulkActions(r)
38
+ })]
39
+ })
40
+ });
41
+ }
42
+ //#endregion
43
+ //#region src/core/cardComposition.ts
44
+ function J(e) {
45
+ let { meta: t, header: n } = e.columnDef;
46
+ return t?.label ? t.label : typeof n == "string" ? n : e.id;
47
+ }
48
+ function oe(e, t, n) {
49
+ return t ? t === "hidden" ? null : t : e.accessorFn == null || n === "hidden" ? null : n;
50
+ }
51
+ function Y(e, t = {}) {
52
+ let n = t.fallbackRole ?? "meta", r = {
53
+ title: [],
54
+ subtitle: [],
55
+ media: [],
56
+ badge: [],
57
+ meta: []
58
+ };
59
+ e.getVisibleLeafColumns().forEach((e, t) => {
60
+ let i = e.columnDef.meta?.card, a = oe(e, i?.role, n);
61
+ a && r[a].push({
62
+ order: i?.order ?? t,
63
+ index: t,
64
+ field: {
65
+ id: e.id,
66
+ column: e,
67
+ label: J(e),
68
+ showLabel: i?.showLabel ?? a === "meta"
69
+ }
70
+ });
71
+ });
72
+ let i = (e) => e.sort((e, t) => e.order - t.order || e.index - t.index).map((e) => e.field);
73
+ return {
74
+ title: i(r.title),
75
+ subtitle: i(r.subtitle),
76
+ media: i(r.media),
77
+ badge: i(r.badge),
78
+ meta: i(r.meta)
79
+ };
80
+ }
81
+ //#endregion
82
+ //#region src/components/StateMessage.tsx
83
+ function se(e) {
84
+ e.resetColumnFilters(), e.setGlobalFilter("");
85
+ }
86
+ function ce({ view: e, slots: t }) {
87
+ return t?.ErrorState ? /* @__PURE__ */ L(I, { children: t.ErrorState({
88
+ error: e.error,
89
+ retry: e.refetch
90
+ }) }) : /* @__PURE__ */ R(A, {
91
+ align: "center",
92
+ gap: "xs",
93
+ children: [/* @__PURE__ */ L(M, {
94
+ c: "red",
95
+ children: "Something went wrong."
96
+ }), /* @__PURE__ */ L(m, {
97
+ variant: "light",
98
+ size: "xs",
99
+ onClick: e.refetch,
100
+ children: "Retry"
101
+ })]
102
+ });
103
+ }
104
+ function le({ view: e, slots: t }) {
105
+ let n = e.renderStatus.phase === "empty-filtered", r = () => se(e.table);
106
+ return t?.Empty ? /* @__PURE__ */ L(I, { children: t.Empty({
107
+ filtered: n,
108
+ clearFilters: r
109
+ }) }) : n ? /* @__PURE__ */ R(A, {
110
+ align: "center",
111
+ gap: "xs",
112
+ children: [/* @__PURE__ */ L(M, {
113
+ c: "dimmed",
114
+ children: "No matches."
115
+ }), /* @__PURE__ */ L(m, {
116
+ variant: "subtle",
117
+ size: "xs",
118
+ onClick: r,
119
+ children: "Clear filters"
120
+ })]
121
+ }) : /* @__PURE__ */ L(M, {
122
+ c: "dimmed",
123
+ children: "No results."
124
+ });
125
+ }
126
+ //#endregion
127
+ //#region src/components/DataCards/DataCards.tsx
128
+ var ue = {
129
+ base: 1,
130
+ sm: 2,
131
+ lg: 3
132
+ };
133
+ function de({ view: e, slots: t, renderCard: n, fallbackRole: r, enableSelection: i, loadingCardCount: a, cols: o = ue, ...s }) {
134
+ let { table: c, renderStatus: l } = e, u = i ?? c.options.enableRowSelection !== !1, d = a ?? Math.min(e.state.pagination.pageSize, 6), f = {
135
+ cols: o,
136
+ ...s
137
+ };
138
+ switch (l.phase) {
139
+ case "loading": return t?.LoadingCards ? t.LoadingCards() : /* @__PURE__ */ L(ne, {
140
+ ...f,
141
+ children: Array.from({ length: d }, (e, t) => /* @__PURE__ */ L(h, {
142
+ withBorder: !0,
143
+ padding: "md",
144
+ children: /* @__PURE__ */ R(A, {
145
+ gap: "xs",
146
+ children: [
147
+ /* @__PURE__ */ L(k, {
148
+ height: 20,
149
+ width: "60%"
150
+ }),
151
+ /* @__PURE__ */ L(k, {
152
+ height: 12,
153
+ width: "40%"
154
+ }),
155
+ /* @__PURE__ */ L(k, { height: 12 })
156
+ ]
157
+ })
158
+ }, t))
159
+ });
160
+ case "error": return /* @__PURE__ */ L(g, {
161
+ p: "xl",
162
+ children: /* @__PURE__ */ L(ce, {
163
+ view: e,
164
+ slots: t
165
+ })
166
+ });
167
+ case "empty":
168
+ case "empty-filtered": return /* @__PURE__ */ L(g, {
169
+ p: "xl",
170
+ children: /* @__PURE__ */ L(le, {
171
+ view: e,
172
+ slots: t
173
+ })
174
+ });
175
+ default: {
176
+ let e = Y(c, { fallbackRole: r });
177
+ return /* @__PURE__ */ L(ne, {
178
+ ...f,
179
+ children: c.getRowModel().rows.map((r) => {
180
+ let i = r.getIsSelected(), a = {
181
+ row: r,
182
+ data: r.original,
183
+ selected: i,
184
+ toggleSelected: () => r.toggleSelected()
185
+ };
186
+ if (n) return /* @__PURE__ */ L(fe, { children: n(a) }, r.id);
187
+ let o = /* @__PURE__ */ L(pe, {
188
+ row: r,
189
+ layout: e,
190
+ selectionEnabled: u
191
+ });
192
+ return t?.Card ? /* @__PURE__ */ L(fe, { children: t.Card({
193
+ ...a,
194
+ children: o
195
+ }) }, r.id) : /* @__PURE__ */ L(h, {
196
+ withBorder: !0,
197
+ padding: "lg",
198
+ pos: "relative",
199
+ "data-selected": i || void 0,
200
+ children: o
201
+ }, r.id);
202
+ })
203
+ });
204
+ }
205
+ }
206
+ }
207
+ function fe({ children: e }) {
208
+ return /* @__PURE__ */ L(I, { children: e });
209
+ }
210
+ function pe({ row: e, layout: t, selectionEnabled: n }) {
211
+ let r = new Map(e.getAllCells().map((e) => [e.column.id, e])), i = (e) => {
212
+ let t = r.get(e.id);
213
+ return t ? o(t.column.columnDef.cell, t.getContext()) : null;
214
+ };
215
+ return /* @__PURE__ */ R(I, { children: [
216
+ n && /* @__PURE__ */ L(_, {
217
+ "aria-label": "Select card",
218
+ checked: e.getIsSelected(),
219
+ disabled: !e.getCanSelect(),
220
+ onChange: e.getToggleSelectedHandler(),
221
+ style: {
222
+ position: "absolute",
223
+ top: 8,
224
+ right: 8,
225
+ zIndex: 1
226
+ }
227
+ }),
228
+ t.media.length > 0 && /* @__PURE__ */ L(h.Section, {
229
+ mb: "xs",
230
+ children: t.media.map((e) => /* @__PURE__ */ L(p, { children: i(e) }, e.id))
231
+ }),
232
+ /* @__PURE__ */ R(A, {
233
+ gap: "md",
234
+ children: [
235
+ (t.title.length > 0 || t.subtitle.length > 0) && /* @__PURE__ */ R(A, {
236
+ gap: 4,
237
+ children: [t.title.map((e) => /* @__PURE__ */ L(M, {
238
+ fw: 600,
239
+ size: "lg",
240
+ lh: 1.2,
241
+ pr: n ? 28 : 0,
242
+ children: i(e)
243
+ }, e.id)), t.subtitle.map((e) => /* @__PURE__ */ L(M, {
244
+ size: "sm",
245
+ c: "dimmed",
246
+ children: i(e)
247
+ }, e.id))]
248
+ }),
249
+ t.badge.length > 0 && /* @__PURE__ */ L(v, {
250
+ gap: "xs",
251
+ children: t.badge.map((e) => /* @__PURE__ */ L(re, { children: i(e) }, e.id))
252
+ }),
253
+ t.meta.length > 0 && /* @__PURE__ */ L(A, {
254
+ gap: 4,
255
+ children: t.meta.map((e) => /* @__PURE__ */ R(v, {
256
+ justify: "space-between",
257
+ gap: "xs",
258
+ wrap: "nowrap",
259
+ children: [e.showLabel && /* @__PURE__ */ L(M, {
260
+ size: "sm",
261
+ c: "dimmed",
262
+ children: e.label
263
+ }), /* @__PURE__ */ L(M, {
264
+ size: "sm",
265
+ children: i(e)
266
+ })]
267
+ }, e.id))
268
+ })
269
+ ]
270
+ })
271
+ ] });
272
+ }
273
+ //#endregion
274
+ //#region src/components/DataPagination/DataPagination.tsx
275
+ function me({ view: e, pageSizeOptions: t, showPageSize: n = !0, showRange: r = !0, pageSizeLabel: i = "Rows per page", ...a }) {
276
+ let { table: o } = e, { pageIndex: s, pageSize: c } = e.state.pagination, l = o.getRowCount(), u = o.getPageCount(), d = t ?? e.pageSizeOptions, f = l === 0 ? 0 : s * c + 1, p = Math.min((s + 1) * c, l);
277
+ return /* @__PURE__ */ R(v, {
278
+ justify: "space-between",
279
+ wrap: "wrap",
280
+ gap: "sm",
281
+ ...a,
282
+ children: [/* @__PURE__ */ R(v, {
283
+ gap: "sm",
284
+ wrap: "wrap",
285
+ children: [n && /* @__PURE__ */ L(O, {
286
+ "aria-label": i,
287
+ data: d.map(String),
288
+ value: String(c),
289
+ onChange: (e) => e && o.setPageSize(Number(e)),
290
+ w: 80,
291
+ comboboxProps: { withinPortal: !0 }
292
+ }), r && /* @__PURE__ */ R(M, {
293
+ size: "sm",
294
+ c: "dimmed",
295
+ children: [
296
+ f,
297
+ "–",
298
+ p,
299
+ " of ",
300
+ l
301
+ ]
302
+ })]
303
+ }), /* @__PURE__ */ L(C, {
304
+ value: s + 1,
305
+ total: Math.max(u, 1),
306
+ onChange: (e) => o.setPageIndex(e - 1),
307
+ getControlProps: (e) => ({ "aria-label": `${e} page` })
308
+ })]
309
+ });
310
+ }
311
+ //#endregion
312
+ //#region src/components/icons.tsx
313
+ function he({ direction: e }) {
314
+ return /* @__PURE__ */ R("svg", {
315
+ width: "14",
316
+ height: "14",
317
+ viewBox: "0 0 24 24",
318
+ fill: "none",
319
+ "aria-hidden": "true",
320
+ focusable: "false",
321
+ style: { flexShrink: 0 },
322
+ children: [
323
+ /* @__PURE__ */ L("title", { children: "sort" }),
324
+ /* @__PURE__ */ L("path", {
325
+ d: "M8 10l4-4 4 4",
326
+ stroke: "currentColor",
327
+ strokeWidth: "2",
328
+ strokeLinecap: "round",
329
+ strokeLinejoin: "round",
330
+ opacity: e === "asc" ? 1 : .35
331
+ }),
332
+ /* @__PURE__ */ L("path", {
333
+ d: "M8 14l4 4 4-4",
334
+ stroke: "currentColor",
335
+ strokeWidth: "2",
336
+ strokeLinecap: "round",
337
+ strokeLinejoin: "round",
338
+ opacity: e === "desc" ? 1 : .35
339
+ })
340
+ ]
341
+ });
342
+ }
343
+ function X({ d: e, title: t }) {
344
+ return /* @__PURE__ */ R("svg", {
345
+ width: "16",
346
+ height: "16",
347
+ viewBox: "0 0 24 24",
348
+ fill: "none",
349
+ stroke: "currentColor",
350
+ strokeWidth: "2",
351
+ strokeLinecap: "round",
352
+ strokeLinejoin: "round",
353
+ "aria-hidden": "true",
354
+ focusable: "false",
355
+ style: { flexShrink: 0 },
356
+ children: [/* @__PURE__ */ L("title", { children: t }), /* @__PURE__ */ L("path", { d: e })]
357
+ });
358
+ }
359
+ function ge() {
360
+ return /* @__PURE__ */ L(X, {
361
+ title: "search",
362
+ d: "M21 21l-4.3-4.3M11 19a8 8 0 110-16 8 8 0 010 16z"
363
+ });
364
+ }
365
+ function _e() {
366
+ return /* @__PURE__ */ L(X, {
367
+ title: "filter",
368
+ d: "M3 5h18M7 12h10M10 19h4"
369
+ });
370
+ }
371
+ function ve() {
372
+ return /* @__PURE__ */ L(X, {
373
+ title: "open",
374
+ d: "M6 9l6 6 6-6"
375
+ });
376
+ }
377
+ function ye() {
378
+ return /* @__PURE__ */ L(X, {
379
+ title: "close",
380
+ d: "M18 6L6 18M6 6l12 12"
381
+ });
382
+ }
383
+ function be() {
384
+ return /* @__PURE__ */ L(X, {
385
+ title: "pin left",
386
+ d: "M4 4v16M9 8h8M9 12h6M9 16h8"
387
+ });
388
+ }
389
+ function xe() {
390
+ return /* @__PURE__ */ L(X, {
391
+ title: "pin right",
392
+ d: "M20 4v16M7 8h8M9 12h6M7 16h8"
393
+ });
394
+ }
395
+ //#endregion
396
+ //#region src/components/DataTable/DataTable.tsx
397
+ function Se(e) {
398
+ let t = e.getIsPinned();
399
+ if (t) return {
400
+ position: "sticky",
401
+ [t]: t === "left" ? e.getStart("left") : e.getAfter("right"),
402
+ zIndex: 1,
403
+ backgroundColor: "var(--mantine-color-body)"
404
+ };
405
+ }
406
+ function Ce({ view: e, slots: t, enableSelection: n, loadingRowCount: r, ...i }) {
407
+ let { table: a, renderStatus: s } = e, c = a.getVisibleLeafColumns(), l = n ?? a.options.enableRowSelection !== !1, u = c.length + +!!l, d = r ?? Math.min(e.state.pagination.pageSize, 8), f = () => {
408
+ switch (s.phase) {
409
+ case "loading": return t?.LoadingTable ? t.LoadingTable() : /* @__PURE__ */ L(j.Tbody, { children: Array.from({ length: d }, (e, t) => /* @__PURE__ */ R(j.Tr, { children: [l && /* @__PURE__ */ L(j.Td, { children: /* @__PURE__ */ L(k, {
410
+ height: 16,
411
+ width: 16
412
+ }) }), c.map((e) => /* @__PURE__ */ L(j.Td, { children: /* @__PURE__ */ L(k, { height: 12 }) }, e.id))] }, t)) });
413
+ case "error": return /* @__PURE__ */ L(Te, {
414
+ colSpan: u,
415
+ children: /* @__PURE__ */ L(ce, {
416
+ view: e,
417
+ slots: t
418
+ })
419
+ });
420
+ case "empty":
421
+ case "empty-filtered": return /* @__PURE__ */ L(Te, {
422
+ colSpan: u,
423
+ children: /* @__PURE__ */ L(le, {
424
+ view: e,
425
+ slots: t
426
+ })
427
+ });
428
+ default: return /* @__PURE__ */ L(j.Tbody, { children: a.getRowModel().rows.map((e) => {
429
+ let n = /* @__PURE__ */ R(I, { children: [l && /* @__PURE__ */ L(j.Td, { children: /* @__PURE__ */ L(_, {
430
+ "aria-label": "Select row",
431
+ checked: e.getIsSelected(),
432
+ disabled: !e.getCanSelect(),
433
+ indeterminate: e.getIsSomeSelected(),
434
+ onChange: e.getToggleSelectedHandler()
435
+ }) }), e.getVisibleCells().map((e) => {
436
+ let t = e.column.columnDef.meta?.align;
437
+ return /* @__PURE__ */ L(j.Td, {
438
+ style: {
439
+ ...Se(e.column),
440
+ ...t ? { textAlign: t } : void 0
441
+ },
442
+ children: o(e.column.columnDef.cell, e.getContext())
443
+ }, e.id);
444
+ })] });
445
+ return t?.Row ? /* @__PURE__ */ L(we, { children: t.Row({
446
+ row: e,
447
+ cells: n
448
+ }) }, e.id) : /* @__PURE__ */ L(j.Tr, {
449
+ "data-selected": e.getIsSelected() || void 0,
450
+ children: n
451
+ }, e.id);
452
+ }) });
453
+ }
454
+ };
455
+ return /* @__PURE__ */ L("div", {
456
+ style: a.getIsSomeColumnsPinned() ? { overflowX: "auto" } : void 0,
457
+ children: /* @__PURE__ */ R(j, {
458
+ layout: "fixed",
459
+ ...i,
460
+ children: [/* @__PURE__ */ L(j.Thead, { children: a.getHeaderGroups().map((e) => /* @__PURE__ */ R(j.Tr, { children: [l && /* @__PURE__ */ L(j.Th, {
461
+ style: { width: 40 },
462
+ children: /* @__PURE__ */ L(_, {
463
+ "aria-label": "Select all rows on this page",
464
+ checked: a.getIsAllPageRowsSelected(),
465
+ indeterminate: a.getIsSomePageRowsSelected() && !a.getIsAllPageRowsSelected(),
466
+ onChange: a.getToggleAllPageRowsSelectedHandler()
467
+ })
468
+ }), e.headers.map((e) => /* @__PURE__ */ L(Ee, { header: e }, e.id))] }, e.id)) }), f()]
469
+ })
470
+ });
471
+ }
472
+ function we({ children: e }) {
473
+ return /* @__PURE__ */ L(I, { children: e });
474
+ }
475
+ function Te({ colSpan: e, children: t }) {
476
+ return /* @__PURE__ */ L(j.Tbody, { children: /* @__PURE__ */ L(j.Tr, { children: /* @__PURE__ */ L(j.Td, {
477
+ colSpan: e,
478
+ children: /* @__PURE__ */ L(g, {
479
+ p: "xl",
480
+ children: t
481
+ })
482
+ }) }) });
483
+ }
484
+ function Ee({ header: e }) {
485
+ let { column: t } = e, n = t.columnDef.meta?.align, r = t.getIsSorted(), i = t.getSortIndex(), a = i > 0, s = e.isPlaceholder ? null : o(t.columnDef.header, e.getContext());
486
+ return /* @__PURE__ */ L(j.Th, {
487
+ style: {
488
+ ...Se(t),
489
+ ...n ? { textAlign: n } : void 0
490
+ },
491
+ "aria-sort": r === "asc" ? "ascending" : r === "desc" ? "descending" : void 0,
492
+ children: t.getCanSort() ? /* @__PURE__ */ R(P, {
493
+ onClick: t.getToggleSortingHandler(),
494
+ style: {
495
+ display: "inline-flex",
496
+ alignItems: "center",
497
+ gap: 4,
498
+ font: "inherit"
499
+ },
500
+ children: [
501
+ s,
502
+ /* @__PURE__ */ L(he, { direction: r }),
503
+ a && /* @__PURE__ */ L("span", {
504
+ role: "note",
505
+ style: {
506
+ fontSize: "0.7em",
507
+ opacity: .6
508
+ },
509
+ "aria-label": `Sort priority ${i + 1}`,
510
+ children: i + 1
511
+ })
512
+ ]
513
+ }) : s
514
+ });
515
+ }
516
+ //#endregion
517
+ //#region src/core/useForceCards.ts
518
+ var De = "(max-width: 0px)";
519
+ function Oe(e) {
520
+ let t = /^([\d.]+)(\D*)$/.exec(e.trim());
521
+ if (!t) return `(max-width: ${e})`;
522
+ let n = Number(t[1]), r = t[2] || "px";
523
+ return `(max-width: ${n - (r === "em" || r === "rem" ? .01 : .1)}${r})`;
524
+ }
525
+ function ke(e) {
526
+ let t = F(), n = e?.forceCardsBelow, r = n ? t.breakpoints[n] : void 0, i = G(r ? Oe(r) : De, !1);
527
+ return !!r && !!i;
528
+ }
529
+ //#endregion
530
+ //#region src/core/formatValue.ts
531
+ var Ae = {
532
+ text: (e) => e == null ? "" : String(e),
533
+ number: (e) => e == null ? "" : new Intl.NumberFormat().format(Number(e)),
534
+ currency: (e) => e == null ? "" : new Intl.NumberFormat(void 0, {
535
+ style: "currency",
536
+ currency: "USD"
537
+ }).format(Number(e)),
538
+ date: (e) => {
539
+ if (e == null) return "";
540
+ let t = e instanceof Date ? e : new Date(String(e));
541
+ return Number.isNaN(t.getTime()) ? String(e) : new Intl.DateTimeFormat().format(t);
542
+ },
543
+ boolean: (e) => e == null ? "" : e ? "Yes" : "No"
544
+ };
545
+ function je(e, t) {
546
+ if (e === "number" || e === "currency") {
547
+ let n = new Intl.NumberFormat(void 0, e === "currency" ? {
548
+ style: "currency",
549
+ ...t
550
+ } : t);
551
+ return (e) => e == null ? "" : n.format(Number(e));
552
+ }
553
+ if (e === "date") {
554
+ let e = new Intl.DateTimeFormat(void 0, t);
555
+ return (t) => {
556
+ if (t == null) return "";
557
+ let n = t instanceof Date ? t : new Date(String(t));
558
+ return Number.isNaN(n.getTime()) ? String(t) : e.format(n);
559
+ };
560
+ }
561
+ return Ae[e];
562
+ }
563
+ function Me(e, t, n) {
564
+ let r = t ?? n?.[e];
565
+ return r ? typeof r == "function" ? r : je(e, r) : Ae[e];
566
+ }
567
+ //#endregion
568
+ //#region src/components/DataToolbar/FacetBuckets.tsx
569
+ function Ne({ facet: e, value: t, onChange: n }) {
570
+ let r = Array.isArray(t) ? t : null;
571
+ return /* @__PURE__ */ L(A, {
572
+ gap: 4,
573
+ children: e.ranges.map((e) => {
574
+ let t = r != null && r[0] === e.from && r[1] === e.to;
575
+ return /* @__PURE__ */ L(P, {
576
+ onClick: () => n(t ? void 0 : [e.from, e.to]),
577
+ style: {
578
+ padding: "4px 8px",
579
+ borderRadius: 4,
580
+ background: t ? "var(--mantine-color-blue-light)" : void 0
581
+ },
582
+ children: /* @__PURE__ */ R(v, {
583
+ gap: "xs",
584
+ justify: "space-between",
585
+ wrap: "nowrap",
586
+ children: [/* @__PURE__ */ L(M, {
587
+ size: "sm",
588
+ children: e.label
589
+ }), /* @__PURE__ */ L(f, {
590
+ size: "sm",
591
+ variant: "light",
592
+ color: e.count === 0 ? "gray" : "blue",
593
+ children: e.count
594
+ })]
595
+ })
596
+ }, e.label);
597
+ })
598
+ });
599
+ }
600
+ //#endregion
601
+ //#region src/components/DataToolbar/FilterControl.tsx
602
+ function Pe({ label: e, onClear: t }) {
603
+ return /* @__PURE__ */ R(v, {
604
+ justify: "space-between",
605
+ wrap: "nowrap",
606
+ children: [/* @__PURE__ */ L(M, {
607
+ size: "sm",
608
+ fw: 500,
609
+ children: e
610
+ }), /* @__PURE__ */ L(d, {
611
+ component: "button",
612
+ type: "button",
613
+ size: "xs",
614
+ c: "dimmed",
615
+ onClick: t,
616
+ children: "clear"
617
+ })]
618
+ });
619
+ }
620
+ function Fe(e) {
621
+ return e ? typeof e == "string" ? e : e.toISOString().split("T")[0] ?? null : null;
622
+ }
623
+ function Ie(e) {
624
+ return Array.isArray(e) ? [e[0], e[1]] : [null, null];
625
+ }
626
+ function Le(e, t) {
627
+ return e.values.length > 0 ? e.values.map((e) => ({
628
+ value: e.value,
629
+ label: `${e.label ?? e.value} (${e.count})`,
630
+ disabled: e.count === 0
631
+ })) : t ?? [];
632
+ }
633
+ function Re({ column: e, facet: t }) {
634
+ let n = e.columnDef.meta?.filter;
635
+ if (!n) return null;
636
+ let r = J(e), i = n.placeholder ?? r, a = e.getFilterValue(), o = (t) => e.setFilterValue(t);
637
+ if (n.component) {
638
+ let t = n.component;
639
+ return /* @__PURE__ */ L(y.Wrapper, {
640
+ label: r,
641
+ children: /* @__PURE__ */ L(t, {
642
+ value: a,
643
+ onChange: o,
644
+ column: e
645
+ })
646
+ });
647
+ }
648
+ let s = t?.type === "values" ? t : void 0, c = t?.type === "ranges" ? t : void 0;
649
+ switch (n.variant) {
650
+ case "select": return /* @__PURE__ */ L(O, {
651
+ label: r,
652
+ placeholder: i,
653
+ clearable: !0,
654
+ data: s ? Le(s, n.options) : n.options ?? [],
655
+ value: a ?? null,
656
+ onChange: (e) => o(e ?? void 0)
657
+ });
658
+ case "multiselect": return /* @__PURE__ */ L(x, {
659
+ label: r,
660
+ placeholder: i,
661
+ data: s ? Le(s, n.options) : n.options ?? [],
662
+ value: a ?? [],
663
+ onChange: (e) => o(e.length > 0 ? e : void 0)
664
+ });
665
+ case "boolean": {
666
+ let e = a == null ? "all" : a ? "yes" : "no", t = s?.values.find((e) => e.value === "true"), n = s?.values.find((e) => e.value === "false"), i = t ? `Yes (${t.count})` : "Yes", c = n ? `No (${n.count})` : "No";
667
+ return /* @__PURE__ */ L(y.Wrapper, {
668
+ label: r,
669
+ children: /* @__PURE__ */ L(D, {
670
+ fullWidth: !0,
671
+ size: "xs",
672
+ data: [
673
+ {
674
+ value: "all",
675
+ label: "All"
676
+ },
677
+ {
678
+ value: "yes",
679
+ label: i
680
+ },
681
+ {
682
+ value: "no",
683
+ label: c
684
+ }
685
+ ],
686
+ value: e,
687
+ onChange: (e) => {
688
+ o(e === "all" ? void 0 : e === "yes");
689
+ }
690
+ })
691
+ });
692
+ }
693
+ case "numberRange": {
694
+ let [t, i] = Ie(a), s = n.min ?? c?.min, l = n.max ?? c?.max, u = s != null && l != null, d = a != null, f = c ? /* @__PURE__ */ L(Ne, {
695
+ facet: c,
696
+ value: a,
697
+ onChange: o
698
+ }) : null, p = d ? /* @__PURE__ */ L(Pe, {
699
+ label: r,
700
+ onClear: () => o(void 0)
701
+ }) : r;
702
+ if (u) {
703
+ let a = [t ?? s, i ?? l], c = e.columnDef.meta?.dataType, u = c ? Me(c, e.columnDef.meta?.format, void 0) : (e) => String(e);
704
+ return /* @__PURE__ */ L(y.Wrapper, {
705
+ label: p,
706
+ children: /* @__PURE__ */ R(A, {
707
+ gap: "xs",
708
+ children: [f, /* @__PURE__ */ L(E, {
709
+ min: s,
710
+ max: l,
711
+ step: n.step ?? 1,
712
+ value: a,
713
+ onChange: ([e, t]) => {
714
+ o(e === s && t === l ? void 0 : [e, t]);
715
+ },
716
+ label: (e) => u(e),
717
+ minRange: n.step ?? 1,
718
+ "aria-label": r
719
+ })]
720
+ })
721
+ });
722
+ }
723
+ if (f) return /* @__PURE__ */ L(y.Wrapper, {
724
+ label: p,
725
+ children: f
726
+ });
727
+ let m = (e) => o(e[0] == null && e[1] == null ? void 0 : e), h = (e) => e === "" || e == null ? null : Number(e);
728
+ return /* @__PURE__ */ L(y.Wrapper, {
729
+ label: r,
730
+ children: /* @__PURE__ */ R(v, {
731
+ gap: 4,
732
+ wrap: "nowrap",
733
+ children: [/* @__PURE__ */ L(S, {
734
+ "aria-label": `${r} minimum`,
735
+ placeholder: "Min",
736
+ value: t ?? "",
737
+ onChange: (e) => m([h(e), i]),
738
+ w: 90
739
+ }), /* @__PURE__ */ L(S, {
740
+ "aria-label": `${r} maximum`,
741
+ placeholder: "Max",
742
+ value: i ?? "",
743
+ onChange: (e) => m([t, h(e)]),
744
+ w: 90
745
+ })]
746
+ })
747
+ });
748
+ }
749
+ case "date": return /* @__PURE__ */ L(K, {
750
+ label: r,
751
+ placeholder: i,
752
+ clearable: !0,
753
+ popoverProps: { withinPortal: !1 },
754
+ value: a ? new Date(a) : null,
755
+ onChange: (e) => o(Fe(e) ?? void 0)
756
+ });
757
+ case "dateRange": {
758
+ let [e, t] = Ie(a), n = [e ? new Date(e) : null, t ? new Date(t) : null], s = a == null ? r : /* @__PURE__ */ L(Pe, {
759
+ label: r,
760
+ onClear: () => o(void 0)
761
+ });
762
+ return /* @__PURE__ */ L(y.Wrapper, {
763
+ label: s,
764
+ children: /* @__PURE__ */ R(A, {
765
+ gap: "xs",
766
+ children: [c && /* @__PURE__ */ L(Ne, {
767
+ facet: c,
768
+ value: a,
769
+ onChange: o
770
+ }), /* @__PURE__ */ L(K, {
771
+ type: "range",
772
+ popoverProps: { withinPortal: !1 },
773
+ placeholder: i,
774
+ clearable: !0,
775
+ value: n,
776
+ onChange: ([e, t]) => {
777
+ let n = Fe(e), r = Fe(t);
778
+ o(n == null && r == null ? void 0 : [n, r]);
779
+ }
780
+ })]
781
+ })
782
+ });
783
+ }
784
+ default: return /* @__PURE__ */ L(N, {
785
+ label: r,
786
+ placeholder: i,
787
+ value: a ?? "",
788
+ onChange: (e) => o(e.currentTarget.value || void 0)
789
+ });
790
+ }
791
+ }
792
+ //#endregion
793
+ //#region src/components/DataToolbar/FilterControls.tsx
794
+ function ze({ view: e }) {
795
+ return e.state.columnFilters.length > 0 ? /* @__PURE__ */ L(m, {
796
+ variant: "subtle",
797
+ size: "compact-sm",
798
+ color: "gray",
799
+ leftSection: /* @__PURE__ */ L(ye, {}),
800
+ onClick: () => e.table.resetColumnFilters(),
801
+ children: "Reset filters"
802
+ }) : null;
803
+ }
804
+ function Be(e) {
805
+ return e > 0 ? `Filters (${e})` : "Filters";
806
+ }
807
+ function Ve({ view: e, controls: t }) {
808
+ return /* @__PURE__ */ R(A, {
809
+ gap: "sm",
810
+ style: { minWidth: 240 },
811
+ children: [t, /* @__PURE__ */ L(v, {
812
+ justify: "flex-end",
813
+ children: /* @__PURE__ */ L(ze, { view: e })
814
+ })]
815
+ });
816
+ }
817
+ function He({ view: e, inlineThreshold: t }) {
818
+ let n = e.filterableColumns, r = G(Oe(F().breakpoints.sm), !1), [i, { open: a, close: o }] = W(!1);
819
+ if (n.length === 0) return null;
820
+ let s = n.map((t) => /* @__PURE__ */ L(Re, {
821
+ column: t,
822
+ facet: e.facets[t.id]
823
+ }, t.id)), c = e.state.columnFilters.length;
824
+ return r ? /* @__PURE__ */ R(I, { children: [/* @__PURE__ */ L(m, {
825
+ variant: "default",
826
+ leftSection: /* @__PURE__ */ L(_e, {}),
827
+ onClick: a,
828
+ children: Be(c)
829
+ }), /* @__PURE__ */ L(te, {
830
+ opened: i,
831
+ onClose: o,
832
+ title: "Filters",
833
+ position: "bottom",
834
+ size: "auto",
835
+ children: /* @__PURE__ */ L(Ve, {
836
+ view: e,
837
+ controls: s
838
+ })
839
+ })] }) : n.length <= t ? /* @__PURE__ */ R(I, { children: [s, /* @__PURE__ */ L(ze, { view: e })] }) : /* @__PURE__ */ R(T, {
840
+ position: "bottom-start",
841
+ closeOnClickOutside: !1,
842
+ children: [/* @__PURE__ */ L(T.Target, { children: /* @__PURE__ */ L(m, {
843
+ variant: "default",
844
+ leftSection: /* @__PURE__ */ L(_e, {}),
845
+ children: Be(c)
846
+ }) }), /* @__PURE__ */ L(T.Dropdown, { children: /* @__PURE__ */ L(Ve, {
847
+ view: e,
848
+ controls: s
849
+ }) })]
850
+ });
851
+ }
852
+ //#endregion
853
+ //#region src/components/DataToolbar/SortControl.tsx
854
+ function Ue({ view: e }) {
855
+ let { sortableColumns: t, state: n, table: r } = e, i = n.sorting[0];
856
+ return /* @__PURE__ */ R(v, {
857
+ gap: 4,
858
+ wrap: "nowrap",
859
+ children: [/* @__PURE__ */ L(O, {
860
+ "aria-label": "Sort by",
861
+ placeholder: "Sort by",
862
+ clearable: !0,
863
+ data: t.map((e) => ({
864
+ value: e.id,
865
+ label: J(e)
866
+ })),
867
+ value: i?.id ?? null,
868
+ onChange: (e) => r.setSorting(e ? [{
869
+ id: e,
870
+ desc: i?.desc ?? !1
871
+ }] : [])
872
+ }), /* @__PURE__ */ L(u, {
873
+ "aria-label": "Toggle sort direction",
874
+ variant: "default",
875
+ size: "lg",
876
+ disabled: !i,
877
+ onClick: () => i && r.setSorting([{
878
+ id: i.id,
879
+ desc: !i.desc
880
+ }]),
881
+ children: /* @__PURE__ */ L(he, { direction: i ? i.desc ? "desc" : "asc" : !1 })
882
+ })]
883
+ });
884
+ }
885
+ //#endregion
886
+ //#region src/components/DataToolbar/ViewSwitcher.tsx
887
+ function We({ view: e, lockSwitcherOnMobile: t }) {
888
+ return e.isMobileForced && t ? null : /* @__PURE__ */ L(D, {
889
+ "aria-label": "View",
890
+ value: e.view,
891
+ disabled: e.isMobileForced,
892
+ onChange: (t) => {
893
+ (t === "table" || t === "cards") && e.setView(t);
894
+ },
895
+ data: [{
896
+ value: "table",
897
+ label: "Table"
898
+ }, {
899
+ value: "cards",
900
+ label: "Cards"
901
+ }]
902
+ });
903
+ }
904
+ //#endregion
905
+ //#region src/components/DataToolbar/VisibilityMenu.tsx
906
+ function Ge({ column: e }) {
907
+ if (!e.getCanPin()) return null;
908
+ let t = e.getIsPinned();
909
+ return /* @__PURE__ */ R(v, {
910
+ gap: 2,
911
+ children: [/* @__PURE__ */ L(u, {
912
+ size: "xs",
913
+ variant: t === "left" ? "filled" : "subtle",
914
+ color: t === "left" ? "blue" : "gray",
915
+ "aria-label": `Pin ${J(e)} left`,
916
+ onClick: () => e.pin(t === "left" ? !1 : "left"),
917
+ children: /* @__PURE__ */ L(be, {})
918
+ }), /* @__PURE__ */ L(u, {
919
+ size: "xs",
920
+ variant: t === "right" ? "filled" : "subtle",
921
+ color: t === "right" ? "blue" : "gray",
922
+ "aria-label": `Pin ${J(e)} right`,
923
+ onClick: () => e.pin(t === "right" ? !1 : "right"),
924
+ children: /* @__PURE__ */ L(xe, {})
925
+ })]
926
+ });
927
+ }
928
+ function Ke({ view: e }) {
929
+ let t = e.table.getAllLeafColumns().filter((e) => e.getCanHide());
930
+ return t.length === 0 ? null : /* @__PURE__ */ R(b, {
931
+ closeOnItemClick: !1,
932
+ withinPortal: !0,
933
+ position: "bottom-end",
934
+ children: [/* @__PURE__ */ L(b.Target, { children: /* @__PURE__ */ L(m, {
935
+ variant: "default",
936
+ rightSection: /* @__PURE__ */ L(ve, {}),
937
+ children: "Columns"
938
+ }) }), /* @__PURE__ */ L(b.Dropdown, { children: /* @__PURE__ */ L(A, {
939
+ gap: "xs",
940
+ p: "xs",
941
+ children: t.map((e) => /* @__PURE__ */ R(v, {
942
+ gap: "xs",
943
+ justify: "space-between",
944
+ wrap: "nowrap",
945
+ children: [/* @__PURE__ */ L(_, {
946
+ label: J(e),
947
+ checked: e.getIsVisible(),
948
+ onChange: (t) => e.toggleVisibility(t.currentTarget.checked)
949
+ }), /* @__PURE__ */ L(Ge, { column: e })]
950
+ }, e.id))
951
+ }) })]
952
+ });
953
+ }
954
+ //#endregion
955
+ //#region src/components/DataToolbar/DataToolbar.tsx
956
+ function qe({ view: e, searchPlaceholder: t = "Search…", filterInlineThreshold: n = 3, lockSwitcherOnMobile: r, showSearch: i, showFilters: a, showSort: o, showVisibility: s, showViewSwitcher: c, ...l }) {
957
+ let { table: u, state: d } = e, f = i ?? u.options.enableGlobalFilter !== !1, p = a ?? e.filterableColumns.length > 0, m = o ?? e.sortableColumns.length > 0, h = s ?? !0, g = c ?? !0;
958
+ return /* @__PURE__ */ R(v, {
959
+ justify: "space-between",
960
+ wrap: "wrap",
961
+ gap: "sm",
962
+ ...l,
963
+ children: [/* @__PURE__ */ R(v, {
964
+ wrap: "wrap",
965
+ gap: "sm",
966
+ children: [
967
+ f && /* @__PURE__ */ L(N, {
968
+ "aria-label": "Search",
969
+ placeholder: t,
970
+ leftSection: /* @__PURE__ */ L(ge, {}),
971
+ value: d.globalFilter,
972
+ onChange: (e) => u.setGlobalFilter(e.currentTarget.value),
973
+ rightSection: d.globalFilter ? /* @__PURE__ */ L(ee, {
974
+ size: "sm",
975
+ "aria-label": "Clear search",
976
+ onClick: () => u.setGlobalFilter("")
977
+ }) : void 0
978
+ }),
979
+ p && /* @__PURE__ */ L(He, {
980
+ view: e,
981
+ inlineThreshold: n
982
+ }),
983
+ m && /* @__PURE__ */ L(Ue, { view: e })
984
+ ]
985
+ }), /* @__PURE__ */ R(v, {
986
+ wrap: "wrap",
987
+ gap: "sm",
988
+ children: [h && /* @__PURE__ */ L(Ke, { view: e }), g && /* @__PURE__ */ L(We, {
989
+ view: e,
990
+ lockSwitcherOnMobile: r
991
+ })]
992
+ })]
993
+ });
994
+ }
995
+ //#endregion
996
+ //#region src/components/DataView/context.tsx
997
+ var Je = ie(null), Ye = Je.Provider;
998
+ function Z() {
999
+ let e = ae(Je);
1000
+ if (!e) throw Error("DataView.Toolbar / DataView.Body / DataView.Pagination must be rendered inside <DataView>.");
1001
+ return e;
1002
+ }
1003
+ //#endregion
1004
+ //#region src/components/DataView/DataView.tsx
1005
+ function Q({ view: e, slots: t, renderCard: n, fallbackRole: r, lockSwitcherOnMobile: i, children: a, ...o }) {
1006
+ return /* @__PURE__ */ L(Ye, {
1007
+ value: V(() => ({
1008
+ view: e,
1009
+ slots: t,
1010
+ renderCard: n,
1011
+ fallbackRole: r,
1012
+ lockSwitcherOnMobile: i
1013
+ }), [
1014
+ e,
1015
+ t,
1016
+ n,
1017
+ r,
1018
+ i
1019
+ ]),
1020
+ children: /* @__PURE__ */ L(A, {
1021
+ ...o,
1022
+ children: a ?? /* @__PURE__ */ R(I, { children: [
1023
+ /* @__PURE__ */ L(Xe, {}),
1024
+ /* @__PURE__ */ L($e, {}),
1025
+ /* @__PURE__ */ L(Ze, {}),
1026
+ /* @__PURE__ */ L(Qe, {})
1027
+ ] })
1028
+ })
1029
+ });
1030
+ }
1031
+ function Xe(e) {
1032
+ let { view: t, lockSwitcherOnMobile: n } = Z();
1033
+ return /* @__PURE__ */ L(qe, {
1034
+ view: t,
1035
+ lockSwitcherOnMobile: n,
1036
+ ...e
1037
+ });
1038
+ }
1039
+ function Ze({ tableProps: e, cardsProps: t }) {
1040
+ let { view: n, slots: r, renderCard: i, fallbackRole: a } = Z();
1041
+ return n.view === "cards" ? /* @__PURE__ */ L(de, {
1042
+ view: n,
1043
+ slots: r,
1044
+ renderCard: i,
1045
+ fallbackRole: a,
1046
+ ...t
1047
+ }) : /* @__PURE__ */ L(Ce, {
1048
+ view: n,
1049
+ slots: r,
1050
+ ...e
1051
+ });
1052
+ }
1053
+ function Qe(e) {
1054
+ let { view: t } = Z();
1055
+ return /* @__PURE__ */ L(me, {
1056
+ view: t,
1057
+ ...e
1058
+ });
1059
+ }
1060
+ function $e(e) {
1061
+ let { view: t, slots: n } = Z();
1062
+ return /* @__PURE__ */ L(q, {
1063
+ view: t,
1064
+ slots: n,
1065
+ ...e
1066
+ });
1067
+ }
1068
+ Q.Toolbar = Xe, Q.BulkActions = $e, Q.Body = Ze, Q.Pagination = Qe;
1069
+ //#endregion
1070
+ //#region src/core/exportCsv.ts
1071
+ function et(e) {
1072
+ let t = e == null ? "" : String(e);
1073
+ return t.includes(",") || t.includes("\"") || t.includes("\n") ? `"${t.replace(/"/g, "\"\"")}"` : t;
1074
+ }
1075
+ function tt(e, t) {
1076
+ let { filename: n = "export.csv", separator: r = ",", formatted: i = !1, formatDefaults: a } = t ?? {}, o = e.getVisibleLeafColumns().filter((e) => e.id !== "_select"), s = [o.map((e) => et(J(e))), ...e.getRowModel().rows.map((e) => o.map((t) => {
1077
+ let n = e.getAllCells().find((e) => e.column.id === t.id)?.getValue();
1078
+ return i && t.columnDef.meta?.dataType ? et(Me(t.columnDef.meta.dataType, t.columnDef.meta.format, a)(n)) : et(n);
1079
+ }))].map((e) => e.join(r)).join("\n"), c = new Blob([s], { type: "text/csv;charset=utf-8;" }), l = URL.createObjectURL(c), u = document.createElement("a");
1080
+ u.href = l, u.download = n, u.click(), URL.revokeObjectURL(l);
1081
+ }
1082
+ //#endregion
1083
+ //#region src/url/useUrlSync.ts
1084
+ function nt(e) {
1085
+ return e ? {
1086
+ adapter: e.adapter,
1087
+ serializer: {
1088
+ ...i,
1089
+ ...e.serialize
1090
+ },
1091
+ include: r(e.include)
1092
+ } : null;
1093
+ }
1094
+ function rt(e, t, r) {
1095
+ if (!e) return {};
1096
+ try {
1097
+ return n(e.adapter.read(), {
1098
+ serializer: e.serializer,
1099
+ include: e.include,
1100
+ getFilterMeta: r,
1101
+ current: t
1102
+ });
1103
+ } catch {
1104
+ return {};
1105
+ }
1106
+ }
1107
+ function it({ config: r, state: i, applyPatch: a, getFilterMeta: o }) {
1108
+ let s = H(i);
1109
+ s.current = i;
1110
+ let c = H(a);
1111
+ c.current = a;
1112
+ let l = H(o);
1113
+ l.current = o;
1114
+ let u = H(r);
1115
+ u.current = r;
1116
+ let d = r ? t(i, {
1117
+ serializer: r.serializer,
1118
+ include: r.include,
1119
+ getFilterMeta: o
1120
+ }) : null;
1121
+ B(() => {
1122
+ let t = u.current;
1123
+ if (!t || !d) return;
1124
+ let n = e(t.adapter.read(), t.serializer, t.include);
1125
+ t.adapter.write({
1126
+ ...n,
1127
+ ...d
1128
+ }, { replace: !0 });
1129
+ }, [d ? JSON.stringify(d) : ""]), B(() => {
1130
+ if (!r) return;
1131
+ let { adapter: e, serializer: t, include: i } = r;
1132
+ return e.subscribe?.(() => {
1133
+ let r = n(e.read(), {
1134
+ serializer: t,
1135
+ include: i,
1136
+ getFilterMeta: l.current,
1137
+ current: s.current
1138
+ });
1139
+ c.current(r);
1140
+ });
1141
+ }, [r]);
1142
+ }
1143
+ //#endregion
1144
+ //#region src/core/resolveStatus.ts
1145
+ function at(e) {
1146
+ return e.columnFilters.length > 0 || e.globalFilter.trim() !== "";
1147
+ }
1148
+ function ot({ status: e, error: t, pageRowCount: n, state: r }) {
1149
+ return e === "error" ? {
1150
+ phase: "error",
1151
+ error: t
1152
+ } : e === "loading" || e === "idle" ? { phase: "loading" } : n === 0 ? at(r) ? { phase: "empty-filtered" } : { phase: "empty" } : { phase: "ready" };
1153
+ }
1154
+ //#endregion
1155
+ //#region src/core/useDataView.ts
1156
+ var $ = 300, st = [
1157
+ 10,
1158
+ 25,
1159
+ 50,
1160
+ 100
1161
+ ], ct = 10;
1162
+ function lt(e) {
1163
+ return e == null ? {
1164
+ globalFilter: $,
1165
+ columnFilters: $
1166
+ } : typeof e == "number" ? {
1167
+ globalFilter: e,
1168
+ columnFilters: e
1169
+ } : {
1170
+ globalFilter: e.globalFilter ?? $,
1171
+ columnFilters: e.columnFilters ?? $
1172
+ };
1173
+ }
1174
+ function ut(e) {
1175
+ if (e.id) return e.id;
1176
+ if ("accessorKey" in e && e.accessorKey != null) return String(e.accessorKey);
1177
+ }
1178
+ function dt(e) {
1179
+ let t = /* @__PURE__ */ new Map();
1180
+ for (let n of e) {
1181
+ let e = ut(n), r = n.meta?.filter;
1182
+ e && r && t.set(e, r);
1183
+ }
1184
+ return (e) => t.get(e);
1185
+ }
1186
+ function ft(e) {
1187
+ return {
1188
+ pagination: {
1189
+ pageIndex: 0,
1190
+ pageSize: e.pageSizeOptions?.[0] ?? ct
1191
+ },
1192
+ sorting: [],
1193
+ columnFilters: [],
1194
+ globalFilter: "",
1195
+ rowSelection: {},
1196
+ columnVisibility: {},
1197
+ columnPinning: {
1198
+ left: [],
1199
+ right: []
1200
+ },
1201
+ view: e.defaultView ?? "table",
1202
+ ...e.initialState
1203
+ };
1204
+ }
1205
+ function pt(e) {
1206
+ let { columns: t, rows: n, rowCount: r, status: i, error: a, getRowId: o, onRequestChange: u, state: d, onStateChange: f, enableRowSelection: p, enableGlobalFilter: m = !0, debounce: h, responsive: g, formatDefaults: _, facets: ee } = e, te = ee ?? {}, v = V(() => t.map((e) => {
1207
+ let t = e.meta?.dataType;
1208
+ if (!t || e.cell) return e;
1209
+ let n = Me(t, e.meta?.format, _);
1210
+ return {
1211
+ ...e,
1212
+ cell: (e) => n(e.getValue())
1213
+ };
1214
+ }), [t, _]), y = V(() => dt(v), [v]), b = V(() => nt(e.urlSync), [e.urlSync]), [x, S] = U(() => {
1215
+ let t = ft(e);
1216
+ return {
1217
+ ...t,
1218
+ ...rt(b, t, y)
1219
+ };
1220
+ }), C = V(() => ({
1221
+ ...x,
1222
+ ...d
1223
+ }), [x, d]), w = H(C);
1224
+ w.current = C;
1225
+ let T = z((e) => {
1226
+ S((t) => ({
1227
+ ...t,
1228
+ ...e
1229
+ })), f?.({
1230
+ ...w.current,
1231
+ ...e
1232
+ });
1233
+ }, [f]);
1234
+ it({
1235
+ config: b,
1236
+ state: C,
1237
+ applyPatch: T,
1238
+ getFilterMeta: y
1239
+ });
1240
+ let E = z(() => ({
1241
+ ...w.current.pagination,
1242
+ pageIndex: 0
1243
+ }), []), D = z((e) => {
1244
+ T({ pagination: s(e, w.current.pagination) });
1245
+ }, [T]), O = z((e) => {
1246
+ T({
1247
+ sorting: s(e, w.current.sorting),
1248
+ pagination: E()
1249
+ });
1250
+ }, [T, E]), ne = z((e) => {
1251
+ T({
1252
+ columnFilters: s(e, w.current.columnFilters),
1253
+ pagination: E()
1254
+ });
1255
+ }, [T, E]), k = z((e) => {
1256
+ T({
1257
+ globalFilter: s(e, w.current.globalFilter),
1258
+ pagination: E()
1259
+ });
1260
+ }, [T, E]), A = z((e) => {
1261
+ T({ rowSelection: s(e, w.current.rowSelection) });
1262
+ }, [T]), j = z((e) => {
1263
+ T({ columnVisibility: s(e, w.current.columnVisibility) });
1264
+ }, [T]), M = z((e) => {
1265
+ T({ columnPinning: s(e, w.current.columnPinning) });
1266
+ }, [T]), N = l({
1267
+ data: n,
1268
+ columns: v,
1269
+ getCoreRowModel: c(),
1270
+ manualPagination: !0,
1271
+ manualSorting: !0,
1272
+ manualFiltering: !0,
1273
+ autoResetPageIndex: !1,
1274
+ rowCount: r,
1275
+ getRowId: (e) => o(e),
1276
+ enableRowSelection: typeof p == "function" ? (e) => p(e.original) : p ?? !0,
1277
+ enableGlobalFilter: m,
1278
+ state: {
1279
+ pagination: C.pagination,
1280
+ sorting: C.sorting,
1281
+ columnFilters: C.columnFilters,
1282
+ globalFilter: C.globalFilter,
1283
+ rowSelection: C.rowSelection,
1284
+ columnVisibility: C.columnVisibility,
1285
+ columnPinning: C.columnPinning
1286
+ },
1287
+ onPaginationChange: D,
1288
+ onSortingChange: O,
1289
+ onColumnFiltersChange: ne,
1290
+ onGlobalFilterChange: k,
1291
+ onRowSelectionChange: A,
1292
+ onColumnVisibilityChange: j,
1293
+ onColumnPinningChange: M
1294
+ }), P = V(() => ({
1295
+ pagination: C.pagination,
1296
+ sorting: C.sorting,
1297
+ filters: C.columnFilters,
1298
+ globalFilter: C.globalFilter
1299
+ }), [
1300
+ C.pagination,
1301
+ C.sorting,
1302
+ C.columnFilters,
1303
+ C.globalFilter
1304
+ ]), F = H(u);
1305
+ F.current = u;
1306
+ let I = H(lt(h));
1307
+ I.current = lt(h);
1308
+ let L = H(null), R = H(void 0);
1309
+ B(() => {
1310
+ let e = L.current, t = e === null, n = !e || e.globalFilter !== P.globalFilter, r = !e || e.filters !== P.filters, i = () => {
1311
+ L.current = P, F.current?.(P);
1312
+ }, a = 0;
1313
+ n && (a = Math.max(a, I.current.globalFilter)), r && (a = Math.max(a, I.current.columnFilters));
1314
+ let o = !t && (n || r) && a > 0;
1315
+ return clearTimeout(R.current), o ? R.current = setTimeout(i, a) : i(), () => clearTimeout(R.current);
1316
+ }, [P]);
1317
+ let re = H(P);
1318
+ re.current = P;
1319
+ let ie = z(() => {
1320
+ F.current?.(re.current);
1321
+ }, []), ae = V(() => ot({
1322
+ status: i,
1323
+ error: a,
1324
+ pageRowCount: n.length,
1325
+ state: C
1326
+ }), [
1327
+ i,
1328
+ a,
1329
+ n.length,
1330
+ C
1331
+ ]), W = ke(g), G = W ? "cards" : C.view, K = z((e) => T({ view: e }), [T]), q = e.pageSizeOptions ?? st, J = N.getAllColumns(), oe = J.filter((e) => e.getCanSort()), Y = J.filter((e) => e.columnDef.meta?.filter != null), se = z(() => T({ rowSelection: {} }), [T]);
1332
+ return {
1333
+ table: N,
1334
+ request: P,
1335
+ state: C,
1336
+ view: G,
1337
+ setView: K,
1338
+ isMobileForced: W,
1339
+ status: i,
1340
+ error: a,
1341
+ renderStatus: ae,
1342
+ refetch: ie,
1343
+ pageSizeOptions: q,
1344
+ sortableColumns: oe,
1345
+ filterableColumns: Y,
1346
+ selection: V(() => {
1347
+ let e = C.rowSelection, t = Object.keys(e).filter((t) => e[t]), r = n.filter((t) => e[o(t)] === !0);
1348
+ return {
1349
+ count: t.length,
1350
+ ids: t,
1351
+ rows: r,
1352
+ clear: se
1353
+ };
1354
+ }, [
1355
+ C.rowSelection,
1356
+ n,
1357
+ o,
1358
+ se
1359
+ ]),
1360
+ exportCsv: z((e) => tt(N, e), [N]),
1361
+ facets: te
1362
+ };
1363
+ }
1364
+ //#endregion
1365
+ //#region src/core/useDataViewFetcher.ts
1366
+ function mt({ fetcher: e, ...t }) {
1367
+ let [n, r] = U({
1368
+ rows: [],
1369
+ rowCount: 0
1370
+ }), [i, a] = U("idle"), [o, s] = U(void 0), c = H(e);
1371
+ c.current = e;
1372
+ let l = H(0), u = z(async (e) => {
1373
+ let t = ++l.current;
1374
+ a("loading");
1375
+ try {
1376
+ let n = await c.current(e);
1377
+ t === l.current && (r(n), s(void 0), a("success"));
1378
+ } catch (e) {
1379
+ t === l.current && (s(e), a("error"));
1380
+ }
1381
+ }, []);
1382
+ return pt({
1383
+ ...t,
1384
+ rows: n.rows,
1385
+ rowCount: n.rowCount,
1386
+ facets: n.facets,
1387
+ status: i,
1388
+ error: o,
1389
+ onRequestChange: u
1390
+ });
1391
+ }
1392
+ //#endregion
1393
+ export { q as DataBulkActions, de as DataCards, me as DataPagination, Ce as DataTable, qe as DataToolbar, Q as DataView, Re as FilterControl, Y as composeCardLayout, a as createColumnHelper, tt as exportCsv, J as resolveColumnLabel, pt as useDataView, Z as useDataViewContext, mt as useDataViewFetcher };
1394
+
1395
+ //# sourceMappingURL=index.js.map