@ethanhann/mantine-dataview 0.3.0 → 0.4.1

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.
package/README.md CHANGED
@@ -50,7 +50,8 @@ tree in a provider:
50
50
  ```tsx
51
51
  import "@mantine/core/styles.css";
52
52
  import "@mantine/dates/styles.css";
53
- import {MantineProvider} from "@mantine/core";
53
+ import "@ethanhann/mantine-dataview/styles.css"; // required for row animations
54
+ import { MantineProvider } from "@mantine/core";
54
55
 
55
56
  <MantineProvider>{/* ... */}</MantineProvider>;
56
57
  ```
@@ -61,7 +62,7 @@ The easiest path is `useDataViewFetcher`, which owns the fetch lifecycle for you
61
62
 
62
63
  ```tsx
63
64
  import {
64
- DataView,
65
+ DataViewer,
65
66
  useDataViewFetcher,
66
67
  createColumnHelper,
67
68
  type DataColumnDef,
@@ -104,11 +105,11 @@ function Users() {
104
105
  },
105
106
  });
106
107
 
107
- return <DataView view={view}/>;
108
+ return <DataViewer view={view}/>;
108
109
  }
109
110
  ```
110
111
 
111
- `<DataView view={view} />` renders the toolbar, the active presentation, and pagination.
112
+ `<DataViewer view={view} />` renders the toolbar, the active presentation, and pagination.
112
113
 
113
114
  ## Column builder
114
115
 
@@ -156,12 +157,12 @@ or object to merge), `format`, `align`, `cell`, `enableSorting`.
156
157
  Compose your own layout by passing children:
157
158
 
158
159
  ```tsx
159
- <DataView view={view}>
160
- <DataView.Toolbar/>
161
- <DataView.BulkActions/>
162
- <DataView.Body/>
163
- <DataView.Pagination/>
164
- </DataView>
160
+ <DataViewer view={view}>
161
+ <DataViewer.Toolbar/>
162
+ <DataViewer.BulkActions/>
163
+ <DataViewer.Body/>
164
+ <DataViewer.Pagination/>
165
+ </DataViewer>
165
166
  ```
166
167
 
167
168
  Or use the standalone components directly for full control:
@@ -178,14 +179,14 @@ Inject controls into the toolbar without rebuilding it from scratch using `leftS
178
179
  and `rightSection`:
179
180
 
180
181
  ```tsx
181
- <DataView.Toolbar
182
- leftSection={<Text fw={600}>Users</Text>}
183
- rightSection={
184
- <Group gap="xs">
185
- <Button size="xs" onClick={() => view.exportCsv()}>Export</Button>
186
- <Button size="xs" onClick={() => view.refetch()}>Refresh</Button>
187
- </Group>
188
- }
182
+ <DataViewer.Toolbar
183
+ leftSection={<Text fw={600}>Users</Text>}
184
+ rightSection={
185
+ <Group gap="xs">
186
+ <Button size="xs" onClick={() => view.exportCsv()}>Export</Button>
187
+ <Button size="xs" onClick={() => view.refetch()}>Refresh</Button>
188
+ </Group>
189
+ }
189
190
  />
190
191
  ```
191
192
 
@@ -199,14 +200,14 @@ Both sections are disabled during loading along with the other toolbar controls.
199
200
  The `ViewSwitcher` is exported for standalone use with customizable labels:
200
201
 
201
202
  ```tsx
202
- import { ViewSwitcher } from "@ethanhann/mantine-dataview";
203
+ import {ViewSwitcher} from "@ethanhann/mantine-dataview";
203
204
 
204
205
  // Default
205
- <ViewSwitcher view={view} />
206
+ <ViewSwitcher view={view}/>
206
207
 
207
208
  // Custom labels (text or icons)
208
- <ViewSwitcher view={view} tableLabel="List" cardsLabel="Grid" />
209
- <ViewSwitcher view={view} tableLabel={<IconList />} cardsLabel={<IconGrid />} />
209
+ <ViewSwitcher view={view} tableLabel="List" cardsLabel="Grid"/>
210
+ <ViewSwitcher view={view} tableLabel={<IconList/>} cardsLabel={<IconGrid/>}/>
210
211
  ```
211
212
 
212
213
  Or drive the view programmatically:
@@ -541,14 +542,14 @@ col.accessor("location", {
541
542
  ```tsx
542
543
  import {FilterControl} from "@ethanhann/mantine-dataview";
543
544
 
544
- <DataView view={view}>
545
+ <DataViewer view={view}>
545
546
  {view.table.getColumn("inStock") && (
546
547
  <FilterControl column={view.table.getColumn("inStock")!}/>
547
548
  )}
548
- <DataView.Toolbar/>
549
- <DataView.Body/>
550
- <DataView.Pagination/>
551
- </DataView>
549
+ <DataViewer.Toolbar/>
550
+ <DataViewer.Body/>
551
+ <DataViewer.Pagination/>
552
+ </DataViewer>
552
553
  ```
553
554
 
554
555
  ### Programmatic filter control
@@ -579,42 +580,42 @@ dynamic counts, disable zero-result options, and render clickable range buckets.
579
580
 
580
581
  ```tsx
581
582
  fetcher: async (request) => {
582
- const res = await api.list(request);
583
- return {
584
- rows: res.items,
585
- rowCount: res.total,
586
- facets: {
587
- size: {
588
- type: "values",
589
- values: [
590
- { value: "S", label: "Small", count: 12 },
591
- { value: "M", label: "Medium", count: 34 },
592
- { value: "L", label: "Large", count: 0 },
593
- ],
594
- },
595
- price: {
596
- type: "ranges",
597
- ranges: [
598
- { label: "Under $25", from: 0, to: 25, count: 15 },
599
- { label: "$25-$50", from: 25, to: 50, count: 28 },
600
- { label: "$50+", from: 50, to: 999, count: 7 },
601
- ],
602
- min: 5,
603
- max: 249,
604
- },
605
- },
606
- };
583
+ const res = await api.list(request);
584
+ return {
585
+ rows: res.items,
586
+ rowCount: res.total,
587
+ facets: {
588
+ size: {
589
+ type: "values",
590
+ values: [
591
+ {value: "S", label: "Small", count: 12},
592
+ {value: "M", label: "Medium", count: 34},
593
+ {value: "L", label: "Large", count: 0},
594
+ ],
595
+ },
596
+ price: {
597
+ type: "ranges",
598
+ ranges: [
599
+ {label: "Under $25", from: 0, to: 25, count: 15},
600
+ {label: "$25-$50", from: 25, to: 50, count: 28},
601
+ {label: "$50+", from: 50, to: 999, count: 7},
602
+ ],
603
+ min: 5,
604
+ max: 249,
605
+ },
606
+ },
607
+ };
607
608
  };
608
609
  ```
609
610
 
610
611
  ### How controls adapt
611
612
 
612
- | Filter type | Without facets | With value facets | With range facets |
613
- |------------|---------------|-------------------|-------------------|
614
- | Select | Static options | Options with counts, zero-count dimmed | - |
615
- | Boolean | All / Yes / No | All / Yes (12) / No (3) | - |
616
- | Number range | Slider or inputs | Slider (bounds from facet) | Clickable range buckets + slider |
617
- | Date range | Date picker | Date picker | Clickable range buckets + picker |
613
+ | Filter type | Without facets | With value facets | With range facets |
614
+ |--------------|------------------|----------------------------------------|----------------------------------|
615
+ | Select | Static options | Options with counts, zero-count dimmed | - |
616
+ | Boolean | All / Yes / No | All / Yes (12) / No (3) | - |
617
+ | Number range | Slider or inputs | Slider (bounds from facet) | Clickable range buckets + slider |
618
+ | Date range | Date picker | Date picker | Clickable range buckets + picker |
618
619
 
619
620
  Facets are optional and backward compatible. Facet data updates on every fetch, creating the
620
621
  classic faceted search loop where filtering one dimension updates counts on all others.
@@ -624,16 +625,16 @@ classic faceted search loop where filtering one dimension updates counts on all
624
625
  ```ts
625
626
  // Discrete values - for select, multiselect, boolean filters
626
627
  type ValueFacet = {
627
- type: "values";
628
- values: { value: string; label?: string; count: number }[];
628
+ type: "values";
629
+ values: { value: string; label?: string; count: number }[];
629
630
  };
630
631
 
631
632
  // Bucketed ranges - for numberRange, dateRange filters
632
633
  type RangeFacet = {
633
- type: "ranges";
634
- ranges: { label: string; from: number | string; to: number | string; count: number }[];
635
- min?: number | string;
636
- max?: number | string;
634
+ type: "ranges";
635
+ ranges: { label: string; from: number | string; to: number | string; count: number }[];
636
+ min?: number | string;
637
+ max?: number | string;
637
638
  };
638
639
  ```
639
640
 
@@ -658,7 +659,7 @@ role group, columns are ordered by `meta.card.order`.
658
659
  For full control over card content, use `renderCard`:
659
660
 
660
661
  ```tsx
661
- <DataView
662
+ <DataViewer
662
663
  view={view}
663
664
  renderCard={({data, selected, toggleSelected}) => (
664
665
  <Card withBorder padding="md" onClick={toggleSelected}>
@@ -673,7 +674,7 @@ For full control over card content, use `renderCard`:
673
674
  To keep the default composition but wrap it in a custom card shell, use the `Card` slot:
674
675
 
675
676
  ```tsx
676
- <DataView
677
+ <DataViewer
677
678
  view={view}
678
679
  slots={{
679
680
  Card: ({data, selected, children}) => (
@@ -694,7 +695,7 @@ To keep the default composition but wrap it in a custom card shell, use the `Car
694
695
  Provide a `BulkActions` slot to add actions when rows are selected:
695
696
 
696
697
  ```tsx
697
- <DataView
698
+ <DataViewer
698
699
  view={view}
699
700
  slots={{
700
701
  BulkActions: (selection) => (
@@ -721,7 +722,7 @@ The `selection` object provides `count`, `ids` (all selected row IDs across page
721
722
  Override loading, empty, and error states:
722
723
 
723
724
  ```tsx
724
- <DataView
725
+ <DataViewer
725
726
  view={view}
726
727
  slots={{
727
728
  Empty: () => <Text>No users found.</Text>,
@@ -833,7 +834,7 @@ const view = useDataViewFetcher<User>({
833
834
  responsive: {forceCardsBelow: "sm", lockSwitcherOnMobile: true},
834
835
  });
835
836
 
836
- <DataView view={view} lockSwitcherOnMobile/>;
837
+ <DataViewer view={view} lockSwitcherOnMobile/>;
837
838
  ```
838
839
 
839
840
  When `forceCardsBelow` is set and the viewport is below that breakpoint:
@@ -853,8 +854,8 @@ typing during debounced search.
853
854
  Opt out per component:
854
855
 
855
856
  ```tsx
856
- <DataTable view={view} disableWhileLoading={false} />
857
- <DataToolbar view={view} disableWhileLoading={false} />
857
+ <DataTable view={view} disableWhileLoading={false}/>
858
+ <DataToolbar view={view} disableWhileLoading={false}/>
858
859
  ```
859
860
 
860
861
  ### Animated row transitions
@@ -863,10 +864,17 @@ Instead of skeleton loading, rows can animate in and out with CSS transitions. N
863
864
  fade and slide in, removed rows fade out, and unchanged rows stay in place:
864
865
 
865
866
  ```tsx
866
- <DataView view={view} animateRows />
867
+ <DataViewer view={view} animateRows/>
868
+ ```
869
+
870
+ Be sure the CSS file from the package is included alongside Mantine's CSS:
871
+
872
+ ```tsx
873
+ import "@ethanhann/mantine-dataview/styles.css";
867
874
  ```
868
875
 
869
876
  When `animateRows` is enabled:
877
+
870
878
  - Previous rows stay visible while new data loads (no skeleton flash).
871
879
  - New rows enter with a slide-down fade-in animation (200ms).
872
880
  - Removed rows fade out (150ms) before being removed from the DOM.
@@ -876,23 +884,23 @@ This is opt-in. The default behavior (skeleton loading) is unchanged.
876
884
 
877
885
  ## API overview
878
886
 
879
- | Export | Purpose |
880
- |----------------------------------------------------------------------|-----------------------------------------------|
881
- | `useDataView` | Headless core, owns all feature state |
882
- | `useDataViewFetcher` | Convenience wrapper that manages the fetch |
883
- | `DataView` (+ `.Toolbar` / `.BulkActions` / `.Body` / `.Pagination`) | Orchestrator + compound parts |
884
- | `DataTable`, `DataCards` | The two presentations (usable standalone) |
885
- | `DataToolbar`, `DataPagination`, `DataBulkActions` | Standalone affordances |
886
- | `FilterControl` | Individual filter control (place anywhere) |
887
- | `ViewSwitcher` | Table/Cards toggle (customizable labels) |
888
- | `exportCsv` | Standalone CSV export utility |
889
- | `col` | Fluent column builder factory |
890
- | `createColumnHelper`, `composeCardLayout`, `resolveColumnLabel` | Column helpers |
891
- | `@ethanhann/mantine-dataview/url` | `windowHistoryAdapter` + serializer utilities |
887
+ | Export | Purpose |
888
+ |------------------------------------------------------------------------|-----------------------------------------------|
889
+ | `useDataView` | Headless core, owns all feature state |
890
+ | `useDataViewFetcher` | Convenience wrapper that manages the fetch |
891
+ | `DataViewer` (+ `.Toolbar` / `.BulkActions` / `.Body` / `.Pagination`) | Orchestrator + compound parts |
892
+ | `DataTable`, `DataCards` | The two presentations (usable standalone) |
893
+ | `DataToolbar`, `DataPagination`, `DataBulkActions` | Standalone affordances |
894
+ | `FilterControl` | Individual filter control (place anywhere) |
895
+ | `ViewSwitcher` | Table/Cards toggle (customizable labels) |
896
+ | `exportCsv` | Standalone CSV export utility |
897
+ | `col` | Fluent column builder factory |
898
+ | `createColumnHelper`, `composeCardLayout`, `resolveColumnLabel` | Column helpers |
899
+ | `@ethanhann/mantine-dataview/url` | `windowHistoryAdapter` + serializer utilities |
892
900
 
893
901
  ### Customization slots
894
902
 
895
- Passed via the `slots` prop on `DataView` or the presentation components:
903
+ Passed via the `slots` prop on `DataViewer` or the presentation components:
896
904
 
897
905
  | Slot | Receives | Purpose |
898
906
  |----------------|-------------------------------------|----------------------------|
@@ -904,24 +912,6 @@ Passed via the `slots` prop on `DataView` or the presentation components:
904
912
  | `Card` | `{ row, data, selected, children }` | Wrap each card |
905
913
  | `BulkActions` | `{ count, ids, rows, clear }` | Bulk action bar content |
906
914
 
907
- ## Known issues
908
-
909
- ### `DataView` name shadows the JS global
910
-
911
- The `DataView` component shares its name with the JavaScript `DataView` global (typed arrays).
912
- Linters like Biome's `noShadowRestrictedNames` will flag the import. Suppress it with:
913
-
914
- ```tsx
915
- // biome-ignore lint/suspicious/noShadowRestrictedNames: component name
916
- import {DataView} from "@ethanhann/mantine-dataview";
917
- ```
918
-
919
- Or import with an alias:
920
-
921
- ```tsx
922
- import {DataView as MantineDataView} from "@ethanhann/mantine-dataview";
923
- ```
924
-
925
915
  ## Development
926
916
 
927
917
  ```sh
@@ -7,7 +7,7 @@ import { DataPaginationProps } from '../DataPagination';
7
7
  import { DataTableProps } from '../DataTable';
8
8
  import { DataToolbarProps } from '../DataToolbar';
9
9
  import { DataViewSlots } from '../types';
10
- export interface DataViewProps<TData> extends Omit<StackProps, "children"> {
10
+ export interface DataViewerProps<TData> extends Omit<StackProps, "children"> {
11
11
  /** The `useDataView` instance to project. */
12
12
  view: UseDataViewReturn<TData>;
13
13
  slots?: DataViewSlots<TData>;
@@ -19,20 +19,20 @@ export interface DataViewProps<TData> extends Omit<StackProps, "children"> {
19
19
  /** Custom composition. It defaults to Toolbar, BulkActions, Body, and Pagination. */
20
20
  children?: ReactNode;
21
21
  }
22
- export declare function DataView<TData>({ view, slots, renderCard, fallbackRole, lockSwitcherOnMobile, animateRows, children, ...stackProps }: DataViewProps<TData>): import("react").JSX.Element;
23
- export declare namespace DataView {
22
+ export declare function DataViewer<TData>({ view, slots, renderCard, fallbackRole, lockSwitcherOnMobile, animateRows, children, ...stackProps }: DataViewerProps<TData>): import("react").JSX.Element;
23
+ export declare namespace DataViewer {
24
24
  var Toolbar: typeof DataViewToolbar;
25
25
  var BulkActions: typeof DataViewBulkActions;
26
26
  var Body: typeof DataViewBody;
27
27
  var Pagination: typeof DataViewPagination;
28
28
  }
29
- export type DataViewToolbarProps<TData> = Omit<DataToolbarProps<TData>, "view">;
30
- declare function DataViewToolbar<TData>(props: DataViewToolbarProps<TData>): import("react").JSX.Element;
31
- export interface DataViewBodyProps<TData> {
29
+ export type DataViewerToolbarProps<TData> = Omit<DataToolbarProps<TData>, "view">;
30
+ declare function DataViewToolbar<TData>(props: DataViewerToolbarProps<TData>): import("react").JSX.Element;
31
+ export interface DataViewerBodyProps<TData> {
32
32
  tableProps?: Omit<DataTableProps<TData>, "view" | "slots">;
33
33
  cardsProps?: Omit<DataCardsProps<TData>, "view" | "slots" | "renderCard" | "fallbackRole">;
34
34
  }
35
- declare function DataViewBody<TData>({ tableProps, cardsProps, }: DataViewBodyProps<TData>): import("react").JSX.Element;
35
+ declare function DataViewBody<TData>({ tableProps, cardsProps, }: DataViewerBodyProps<TData>): import("react").JSX.Element;
36
36
  declare function DataViewPagination<TData>(props: Omit<DataPaginationProps<TData>, "view">): import("react").JSX.Element;
37
37
  declare function DataViewBulkActions<TData>(props: Omit<DataBulkActionsProps<TData>, "view" | "slots">): import("react").JSX.Element;
38
38
  export {};
@@ -0,0 +1,2 @@
1
+ export { type DataViewContextValue, useDataViewContext, } from './context';
2
+ export { DataViewer, type DataViewerBodyProps, type DataViewerProps, type DataViewerToolbarProps, } from './DataViewer';
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./serializer-CGmBq-Jz.cjs");let t=require("@tanstack/react-table"),n=require("@mantine/core"),r=require("react/jsx-runtime"),i=require("react"),a=require("@mantine/hooks"),o=require("@mantine/dates");require("@mantine/dates/styles.css");function s({view:e,slots:t,...i}){let{selection:a}=e;return a.count===0?null:(0,r.jsx)(n.Paper,{withBorder:!0,p:`xs`,radius:`sm`,role:`region`,"aria-label":`Bulk actions`,...i,children:(0,r.jsxs)(n.Group,{justify:`space-between`,wrap:`wrap`,gap:`sm`,children:[(0,r.jsxs)(n.Group,{gap:`sm`,children:[(0,r.jsxs)(n.Text,{size:`sm`,fw:500,children:[a.count,` selected`]}),(0,r.jsx)(n.Button,{variant:`subtle`,size:`xs`,onClick:a.clear,children:`Clear`})]}),t?.BulkActions&&(0,r.jsx)(n.Group,{gap:`xs`,children:t.BulkActions(a)})]})})}function c(e){let{meta:t,header:n}=e.columnDef;return t?.label?t.label:typeof n==`string`?n:e.id}function l(e,t,n){return t?t===`hidden`?null:t:e.accessorFn==null||n===`hidden`?null:n}function u(e,t={}){let n=t.fallbackRole??`meta`,r={title:[],subtitle:[],media:[],badge:[],meta:[]};e.getVisibleLeafColumns().forEach((e,t)=>{let i=e.columnDef.meta?.card,a=l(e,i?.role,n);a&&r[a].push({order:i?.order??t,index:t,field:{id:e.id,column:e,label:c(e),showLabel:i?.showLabel??a===`meta`}})});let i=e=>e.sort((e,t)=>e.order-t.order||e.index-t.index).map(e=>e.field);return{title:i(r.title),subtitle:i(r.subtitle),media:i(r.media),badge:i(r.badge),meta:i(r.meta)}}function d(e,t){let n=(0,i.useRef)([]),r=(0,i.useRef)(!1),a=(0,i.useRef)(0),o=e.map(e=>e.id),s=new Set;if(t&&r.current){let e=n.current,t=new Set(e);if(o.length!==e.length||o.some((t,n)=>t!==e[n]))if(a.current++,o.length===e.length&&o.every(e=>t.has(e)))for(let e of o)s.add(e);else for(let e of o)t.has(e)||s.add(e)}return n.current=o,r.current=!0,{rows:e,entering:s,generation:a.current}}function f(e){e.resetColumnFilters(),e.setGlobalFilter(``)}function p({view:e,slots:t}){return t?.ErrorState?(0,r.jsx)(r.Fragment,{children:t.ErrorState({error:e.error,retry:e.refetch})}):(0,r.jsxs)(n.Stack,{align:`center`,gap:`xs`,children:[(0,r.jsx)(n.Text,{c:`red`,children:`Something went wrong.`}),(0,r.jsx)(n.Button,{variant:`light`,size:`xs`,onClick:e.refetch,children:`Retry`})]})}function m({view:e,slots:t}){let i=e.renderStatus.phase===`empty-filtered`,a=()=>f(e.table);return t?.Empty?(0,r.jsx)(r.Fragment,{children:t.Empty({filtered:i,clearFilters:a})}):i?(0,r.jsxs)(n.Stack,{align:`center`,gap:`xs`,children:[(0,r.jsx)(n.Text,{c:`dimmed`,children:`No matches.`}),(0,r.jsx)(n.Button,{variant:`subtle`,size:`xs`,onClick:a,children:`Clear filters`})]}):(0,r.jsx)(n.Text,{c:`dimmed`,children:`No results.`})}var h={base:1,sm:2,lg:3};function g({view:e,slots:t,renderCard:i,fallbackRole:a,enableSelection:o,loadingCardCount:s,animateRows:c=!1,cols:l=h,...f}){let{table:g,renderStatus:v}=e,y=o??g.options.enableRowSelection!==!1,b=s??Math.min(e.state.pagination.pageSize,6),x={cols:l,...f},S=d(g.getRowModel().rows,c),C=e=>{let o=u(g,{fallbackRole:a});return(0,r.jsx)(n.SimpleGrid,{"data-changed":c||void 0,...x,children:e.map(e=>{let a=e.getIsSelected(),s={row:e,data:e.original,selected:a,toggleSelected:()=>e.toggleSelected()},c=S.entering.has(e.id)||void 0;if(i)return(0,r.jsx)(`div`,{"data-entering":c,children:i(s)},e.id);let l=(0,r.jsx)(_,{row:e,layout:o,selectionEnabled:y});return t?.Card?(0,r.jsx)(`div`,{"data-entering":c,children:t.Card({...s,children:l})},e.id):(0,r.jsx)(n.Card,{withBorder:!0,padding:`lg`,pos:`relative`,"data-selected":a||void 0,"data-entering":c,children:l},e.id)})},S.generation)};if(c&&v.phase===`loading`&&S.rows.length>0)return C(S.rows);switch(v.phase){case`loading`:return t?.LoadingCards?t.LoadingCards():(0,r.jsx)(n.SimpleGrid,{...x,children:Array.from({length:b},(e,t)=>(0,r.jsx)(n.Card,{withBorder:!0,padding:`md`,children:(0,r.jsxs)(n.Stack,{gap:`xs`,children:[(0,r.jsx)(n.Skeleton,{height:20,width:`60%`}),(0,r.jsx)(n.Skeleton,{height:12,width:`40%`}),(0,r.jsx)(n.Skeleton,{height:12})]})},t))});case`error`:return(0,r.jsx)(n.Center,{p:`xl`,children:(0,r.jsx)(p,{view:e,slots:t})});case`empty`:case`empty-filtered`:return(0,r.jsx)(n.Center,{p:`xl`,children:(0,r.jsx)(m,{view:e,slots:t})});default:return C(S.rows)}}function _({row:e,layout:a,selectionEnabled:o}){let s=new Map(e.getAllCells().map(e=>[e.column.id,e])),c=e=>{let n=s.get(e.id);return n?(0,t.flexRender)(n.column.columnDef.cell,n.getContext()):null};return(0,r.jsxs)(r.Fragment,{children:[o&&(0,r.jsx)(n.Checkbox,{"aria-label":`Select card`,checked:e.getIsSelected(),disabled:!e.getCanSelect(),onChange:e.getToggleSelectedHandler(),style:{position:`absolute`,top:8,right:8,zIndex:1}}),a.media.length>0&&(0,r.jsx)(n.Card.Section,{mb:`xs`,children:a.media.map(e=>(0,r.jsx)(n.Box,{children:c(e)},e.id))}),(0,r.jsxs)(n.Stack,{gap:`md`,children:[(a.title.length>0||a.subtitle.length>0)&&(0,r.jsxs)(n.Stack,{gap:4,children:[a.title.map(e=>(0,r.jsx)(n.Text,{fw:600,size:`lg`,lh:1.2,pr:o?28:0,children:c(e)},e.id)),a.subtitle.map(e=>(0,r.jsx)(n.Text,{size:`sm`,c:`dimmed`,children:c(e)},e.id))]}),a.badge.length>0&&(0,r.jsx)(n.Group,{gap:`xs`,children:a.badge.map(e=>(0,r.jsx)(i.Fragment,{children:c(e)},e.id))}),a.meta.length>0&&(0,r.jsx)(n.Stack,{gap:4,children:a.meta.map(e=>(0,r.jsxs)(n.Group,{justify:`space-between`,gap:`xs`,wrap:`nowrap`,children:[e.showLabel&&(0,r.jsx)(n.Text,{size:`sm`,c:`dimmed`,children:e.label}),(0,r.jsx)(n.Text,{size:`sm`,children:c(e)})]},e.id))})]})]})}function v({view:e,pageSizeOptions:t,showPageSize:i=!0,showRange:a=!0,pageSizeLabel:o=`Rows per page`,...s}){let{table:c}=e,{pageIndex:l,pageSize:u}=e.state.pagination,d=c.getRowCount(),f=c.getPageCount(),p=t??e.pageSizeOptions,m=d===0?0:l*u+1,h=Math.min((l+1)*u,d);return(0,r.jsxs)(n.Group,{justify:`space-between`,wrap:`wrap`,gap:`sm`,...s,children:[(0,r.jsxs)(n.Group,{gap:`sm`,wrap:`wrap`,children:[i&&(0,r.jsx)(n.Select,{"aria-label":o,data:p.map(String),value:String(u),onChange:e=>e&&c.setPageSize(Number(e)),w:80,comboboxProps:{withinPortal:!0}}),a&&(0,r.jsxs)(n.Text,{size:`sm`,c:`dimmed`,children:[m,`–`,h,` of `,d]})]}),(0,r.jsx)(n.Pagination,{value:l+1,total:Math.max(f,1),onChange:e=>c.setPageIndex(e-1),getControlProps:e=>({"aria-label":`${e} page`})})]})}function y({direction:e}){return(0,r.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,focusable:`false`,style:{flexShrink:0},children:[(0,r.jsx)(`title`,{children:`sort`}),(0,r.jsx)(`path`,{d:`M8 10l4-4 4 4`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,opacity:e===`asc`?1:.35}),(0,r.jsx)(`path`,{d:`M8 14l4 4 4-4`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,opacity:e===`desc`?1:.35})]})}function b({d:e,title:t}){return(0,r.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,style:{flexShrink:0},children:[(0,r.jsx)(`title`,{children:t}),(0,r.jsx)(`path`,{d:e})]})}function x(){return(0,r.jsx)(b,{title:`search`,d:`M21 21l-4.3-4.3M11 19a8 8 0 110-16 8 8 0 010 16z`})}function S(){return(0,r.jsx)(b,{title:`filter`,d:`M3 5h18M7 12h10M10 19h4`})}function C(){return(0,r.jsx)(b,{title:`open`,d:`M6 9l6 6 6-6`})}function w(){return(0,r.jsx)(b,{title:`close`,d:`M18 6L6 18M6 6l12 12`})}function T(){return(0,r.jsx)(b,{title:`pin left`,d:`M4 4v16M9 8h8M9 12h6M9 16h8`})}function ee(){return(0,r.jsx)(b,{title:`pin right`,d:`M20 4v16M7 8h8M9 12h6M7 16h8`})}function E(e){let t=e.getIsPinned();if(t)return{position:`sticky`,[t]:t===`left`?e.getStart(`left`):e.getAfter(`right`),zIndex:1,backgroundColor:`var(--mantine-color-body)`}}function D({view:e,slots:i,enableSelection:a,loadingRowCount:o,disableWhileLoading:s=!0,animateRows:c=!1,...l}){let{table:u,renderStatus:f}=e,h=s&&e.status===`loading`,g=d(u.getRowModel().rows,c),_=u.getVisibleLeafColumns(),v=a??u.options.enableRowSelection!==!1,y=_.length+ +!!v,b=o??Math.min(e.state.pagination.pageSize,8),x=e=>(0,r.jsx)(n.Table.Tbody,{"data-changed":c||void 0,children:e.map(e=>{let a=g.entering.has(e.id)||void 0,o=(0,r.jsxs)(r.Fragment,{children:[v&&(0,r.jsx)(n.Table.Td,{children:(0,r.jsx)(n.Checkbox,{"aria-label":`Select row`,checked:e.getIsSelected(),disabled:!e.getCanSelect(),indeterminate:e.getIsSomeSelected(),onChange:e.getToggleSelectedHandler()})}),e.getVisibleCells().map(e=>{let i=e.column.columnDef.meta?.align;return(0,r.jsx)(n.Table.Td,{style:{...E(e.column),...i?{textAlign:i}:void 0},children:(0,t.flexRender)(e.column.columnDef.cell,e.getContext())},e.id)})]});return i?.Row?(0,r.jsx)(O,{children:i.Row({row:e,cells:o})},e.id):(0,r.jsx)(n.Table.Tr,{"data-selected":e.getIsSelected()||void 0,"data-entering":a,children:o},e.id)})},g.generation),S=()=>{if(c&&f.phase===`loading`&&g.rows.length>0)return x(g.rows);switch(f.phase){case`loading`:return i?.LoadingTable?i.LoadingTable():(0,r.jsx)(n.Table.Tbody,{children:Array.from({length:b},(e,t)=>(0,r.jsxs)(n.Table.Tr,{children:[v&&(0,r.jsx)(n.Table.Td,{children:(0,r.jsx)(n.Skeleton,{height:16,width:16})}),_.map(e=>(0,r.jsx)(n.Table.Td,{children:(0,r.jsx)(n.Skeleton,{height:12})},e.id))]},t))});case`error`:return(0,r.jsx)(k,{colSpan:y,children:(0,r.jsx)(p,{view:e,slots:i})});case`empty`:case`empty-filtered`:return(0,r.jsx)(k,{colSpan:y,children:(0,r.jsx)(m,{view:e,slots:i})});default:return x(g.rows)}};return(0,r.jsx)(`div`,{style:u.getIsSomeColumnsPinned()?{overflowX:`auto`}:void 0,children:(0,r.jsxs)(n.Table,{layout:`fixed`,...l,children:[(0,r.jsx)(n.Table.Thead,{children:u.getHeaderGroups().map(e=>(0,r.jsxs)(n.Table.Tr,{children:[v&&(0,r.jsx)(n.Table.Th,{style:{width:40},children:(0,r.jsx)(n.Checkbox,{"aria-label":`Select all rows on this page`,checked:u.getIsAllPageRowsSelected(),indeterminate:u.getIsSomePageRowsSelected()&&!u.getIsAllPageRowsSelected(),onChange:u.getToggleAllPageRowsSelectedHandler()})}),e.headers.map(e=>(0,r.jsx)(A,{header:e,disabled:h},e.id))]},e.id))}),S()]})})}function O({children:e}){return(0,r.jsx)(r.Fragment,{children:e})}function k({colSpan:e,children:t}){return(0,r.jsx)(n.Table.Tbody,{children:(0,r.jsx)(n.Table.Tr,{children:(0,r.jsx)(n.Table.Td,{colSpan:e,children:(0,r.jsx)(n.Center,{p:`xl`,children:t})})})})}function A({header:e,disabled:i}){let{column:a}=e,o=a.columnDef.meta?.align,s=a.getIsSorted(),c=a.getSortIndex(),l=c>0,u=e.isPlaceholder?null:(0,t.flexRender)(a.columnDef.header,e.getContext()),d=a.getCanSort()&&!i;return(0,r.jsx)(n.Table.Th,{style:{...E(a),...o?{textAlign:o}:void 0},"aria-sort":s===`asc`?`ascending`:s===`desc`?`descending`:void 0,children:d?(0,r.jsxs)(n.UnstyledButton,{onClick:a.getToggleSortingHandler(),style:{display:`inline-flex`,alignItems:`center`,gap:4,font:`inherit`},children:[u,(0,r.jsx)(y,{direction:s}),l&&(0,r.jsx)(`span`,{role:`note`,style:{fontSize:`0.7em`,opacity:.6},"aria-label":`Sort priority ${c+1}`,children:c+1})]}):(0,r.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4,...i?{opacity:.5}:{}},children:[u,s&&(0,r.jsx)(y,{direction:s})]})})}var te=`(max-width: 0px)`;function j(e){let t=/^([\d.]+)(\D*)$/.exec(e.trim());if(!t)return`(max-width: ${e})`;let n=Number(t[1]),r=t[2]||`px`;return`(max-width: ${n-(r===`em`||r===`rem`?.01:.1)}${r})`}function ne(e){let t=(0,n.useMantineTheme)(),r=e?.forceCardsBelow,i=r?t.breakpoints[r]:void 0,o=(0,a.useMediaQuery)(i?j(i):te,!1);return!!i&&!!o}var M={text:e=>e==null?``:String(e),number:e=>e==null?``:new Intl.NumberFormat().format(Number(e)),currency:e=>e==null?``:new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`}).format(Number(e)),date:e=>{if(e==null)return``;let t=e instanceof Date?e:new Date(String(e));return Number.isNaN(t.getTime())?String(e):new Intl.DateTimeFormat().format(t)},boolean:e=>e==null?``:e?`Yes`:`No`};function re(e,t){if(e===`number`||e===`currency`){let n=new Intl.NumberFormat(void 0,e===`currency`?{style:`currency`,...t}:t);return e=>e==null?``:n.format(Number(e))}if(e===`date`){let e=new Intl.DateTimeFormat(void 0,t);return t=>{if(t==null)return``;let n=t instanceof Date?t:new Date(String(t));return Number.isNaN(n.getTime())?String(t):e.format(n)}}return M[e]}function N(e,t,n){let r=t??n?.[e];return r?typeof r==`function`?r:re(e,r):M[e]}function P({facet:e,value:t,onChange:i}){let a=Array.isArray(t)?t:null;return(0,r.jsx)(n.Stack,{gap:4,children:e.ranges.map(e=>{let t=a!=null&&a[0]===e.from&&a[1]===e.to;return(0,r.jsx)(n.UnstyledButton,{onClick:()=>i(t?void 0:[e.from,e.to]),style:{padding:`4px 8px`,borderRadius:4,background:t?`var(--mantine-color-blue-light)`:void 0},children:(0,r.jsxs)(n.Group,{gap:`xs`,justify:`space-between`,wrap:`nowrap`,children:[(0,r.jsx)(n.Text,{size:`sm`,children:e.label}),(0,r.jsx)(n.Badge,{size:`sm`,variant:`light`,color:e.count===0?`gray`:`blue`,children:e.count})]})},e.label)})})}function F({label:e,onClear:t}){return(0,r.jsxs)(n.Group,{justify:`space-between`,wrap:`nowrap`,children:[(0,r.jsx)(n.Text,{size:`sm`,fw:500,children:e}),(0,r.jsx)(n.Anchor,{component:`button`,type:`button`,size:`xs`,c:`dimmed`,onClick:t,children:`clear`})]})}function I(e){return e?typeof e==`string`?e:e.toISOString().split(`T`)[0]??null:null}function L(e){return Array.isArray(e)?[e[0],e[1]]:[null,null]}function R(e,t){return e.values.length>0?e.values.map(e=>({value:e.value,label:`${e.label??e.value} (${e.count})`,disabled:e.count===0})):t??[]}function z({column:e,facet:t}){let i=e.columnDef.meta?.filter;if(!i)return null;let a=c(e),s=i.placeholder??a,l=e.getFilterValue(),u=t=>e.setFilterValue(t);if(i.component){let t=i.component;return(0,r.jsx)(n.Input.Wrapper,{label:a,children:(0,r.jsx)(t,{value:l,onChange:u,column:e})})}let d=t?.type===`values`?t:void 0,f=t?.type===`ranges`?t:void 0;switch(i.variant){case`select`:return(0,r.jsx)(n.Select,{label:a,placeholder:s,clearable:!0,data:d?R(d,i.options):i.options??[],value:l??null,onChange:e=>u(e??void 0)});case`multiselect`:return(0,r.jsx)(n.MultiSelect,{label:a,placeholder:s,data:d?R(d,i.options):i.options??[],value:l??[],onChange:e=>u(e.length>0?e:void 0)});case`boolean`:{let e=l==null?`all`:l?`yes`:`no`,t=d?.values.find(e=>e.value===`true`),i=d?.values.find(e=>e.value===`false`),o=t?`Yes (${t.count})`:`Yes`,s=i?`No (${i.count})`:`No`;return(0,r.jsx)(n.Input.Wrapper,{label:a,children:(0,r.jsx)(n.SegmentedControl,{fullWidth:!0,size:`xs`,data:[{value:`all`,label:`All`},{value:`yes`,label:o},{value:`no`,label:s}],value:e,onChange:e=>{u(e===`all`?void 0:e===`yes`)}})})}case`numberRange`:{let[t,o]=L(l),s=i.min??f?.min,c=i.max??f?.max,d=s!=null&&c!=null,p=l!=null,m=f?(0,r.jsx)(P,{facet:f,value:l,onChange:u}):null,h=p?(0,r.jsx)(F,{label:a,onClear:()=>u(void 0)}):a;if(d){let l=[t??s,o??c],d=e.columnDef.meta?.dataType,f=d?N(d,e.columnDef.meta?.format,void 0):e=>String(e);return(0,r.jsx)(n.Input.Wrapper,{label:h,children:(0,r.jsxs)(n.Stack,{gap:`xs`,children:[m,(0,r.jsx)(n.RangeSlider,{min:s,max:c,step:i.step??1,value:l,onChange:([e,t])=>{u(e===s&&t===c?void 0:[e,t])},label:e=>f(e),minRange:i.step??1,"aria-label":a})]})})}if(m)return(0,r.jsx)(n.Input.Wrapper,{label:h,children:m});let g=e=>u(e[0]==null&&e[1]==null?void 0:e),_=e=>e===``||e==null?null:Number(e);return(0,r.jsx)(n.Input.Wrapper,{label:a,children:(0,r.jsxs)(n.Group,{gap:4,wrap:`nowrap`,children:[(0,r.jsx)(n.NumberInput,{"aria-label":`${a} minimum`,placeholder:`Min`,value:t??``,onChange:e=>g([_(e),o]),w:90}),(0,r.jsx)(n.NumberInput,{"aria-label":`${a} maximum`,placeholder:`Max`,value:o??``,onChange:e=>g([t,_(e)]),w:90})]})})}case`date`:return(0,r.jsx)(o.DatePickerInput,{label:a,placeholder:s,clearable:!0,popoverProps:{withinPortal:!1},value:l?new Date(l):null,onChange:e=>u(I(e)??void 0)});case`dateRange`:{let[e,t]=L(l),i=[e?new Date(e):null,t?new Date(t):null],c=l==null?a:(0,r.jsx)(F,{label:a,onClear:()=>u(void 0)});return(0,r.jsx)(n.Input.Wrapper,{label:c,children:(0,r.jsxs)(n.Stack,{gap:`xs`,children:[f&&(0,r.jsx)(P,{facet:f,value:l,onChange:u}),(0,r.jsx)(o.DatePickerInput,{type:`range`,popoverProps:{withinPortal:!1},placeholder:s,clearable:!0,value:i,onChange:([e,t])=>{let n=I(e),r=I(t);u(n==null&&r==null?void 0:[n,r])}})]})})}default:return(0,r.jsx)(n.TextInput,{label:a,placeholder:s,value:l??``,onChange:e=>u(e.currentTarget.value||void 0)})}}function B({view:e}){return e.state.columnFilters.length>0?(0,r.jsx)(n.Button,{variant:`subtle`,size:`compact-sm`,color:`gray`,leftSection:(0,r.jsx)(w,{}),onClick:()=>e.table.resetColumnFilters(),children:`Reset filters`}):null}function V(e){return e>0?`Filters (${e})`:`Filters`}function H({view:e,controls:t}){return(0,r.jsxs)(n.Stack,{gap:`sm`,style:{minWidth:240},children:[t,(0,r.jsx)(n.Group,{justify:`flex-end`,children:(0,r.jsx)(B,{view:e})})]})}function U({view:e,inlineThreshold:t}){let i=e.filterableColumns,o=(0,a.useMediaQuery)(j((0,n.useMantineTheme)().breakpoints.sm),!1),[s,{open:c,close:l}]=(0,a.useDisclosure)(!1);if(i.length===0)return null;let u=i.map(t=>(0,r.jsx)(z,{column:t,facet:e.facets[t.id]},t.id)),d=e.state.columnFilters.length;return o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Button,{variant:`default`,leftSection:(0,r.jsx)(S,{}),onClick:c,children:V(d)}),(0,r.jsx)(n.Drawer,{opened:s,onClose:l,title:`Filters`,position:`bottom`,size:`auto`,children:(0,r.jsx)(H,{view:e,controls:u})})]}):i.length<=t?(0,r.jsxs)(r.Fragment,{children:[u,(0,r.jsx)(B,{view:e})]}):(0,r.jsxs)(n.Popover,{position:`bottom-start`,closeOnClickOutside:!1,children:[(0,r.jsx)(n.Popover.Target,{children:(0,r.jsx)(n.Button,{variant:`default`,leftSection:(0,r.jsx)(S,{}),children:V(d)})}),(0,r.jsx)(n.Popover.Dropdown,{children:(0,r.jsx)(H,{view:e,controls:u})})]})}function ie({view:e}){let{sortableColumns:t,state:i,table:a}=e,o=i.sorting[0];return(0,r.jsxs)(n.Group,{gap:4,wrap:`nowrap`,children:[(0,r.jsx)(n.Select,{"aria-label":`Sort by`,placeholder:`Sort by`,clearable:!0,data:t.map(e=>({value:e.id,label:c(e)})),value:o?.id??null,onChange:e=>a.setSorting(e?[{id:e,desc:o?.desc??!1}]:[])}),(0,r.jsx)(n.ActionIcon,{"aria-label":`Toggle sort direction`,variant:`default`,size:`lg`,disabled:!o,onClick:()=>o&&a.setSorting([{id:o.id,desc:!o.desc}]),children:(0,r.jsx)(y,{direction:o?o.desc?`desc`:`asc`:!1})})]})}function W({view:e,lockSwitcherOnMobile:t,tableLabel:i=`Table`,cardsLabel:a=`Cards`}){return e.isMobileForced&&t?null:(0,r.jsx)(n.SegmentedControl,{"aria-label":`View`,value:e.view,disabled:e.isMobileForced,onChange:t=>{(t===`table`||t===`cards`)&&e.setView(t)},data:[{value:`table`,label:i},{value:`cards`,label:a}]})}function G({column:e}){if(!e.getCanPin())return null;let t=e.getIsPinned();return(0,r.jsxs)(n.Group,{gap:2,children:[(0,r.jsx)(n.ActionIcon,{size:`xs`,variant:t===`left`?`filled`:`subtle`,color:t===`left`?`blue`:`gray`,"aria-label":`Pin ${c(e)} left`,onClick:()=>e.pin(t===`left`?!1:`left`),children:(0,r.jsx)(T,{})}),(0,r.jsx)(n.ActionIcon,{size:`xs`,variant:t===`right`?`filled`:`subtle`,color:t===`right`?`blue`:`gray`,"aria-label":`Pin ${c(e)} right`,onClick:()=>e.pin(t===`right`?!1:`right`),children:(0,r.jsx)(ee,{})})]})}function ae({view:e}){let t=e.table.getAllLeafColumns().filter(e=>e.getCanHide());return t.length===0?null:(0,r.jsxs)(n.Menu,{closeOnItemClick:!1,withinPortal:!0,position:`bottom-end`,children:[(0,r.jsx)(n.Menu.Target,{children:(0,r.jsx)(n.Button,{variant:`default`,rightSection:(0,r.jsx)(C,{}),children:`Columns`})}),(0,r.jsx)(n.Menu.Dropdown,{children:(0,r.jsx)(n.Stack,{gap:`xs`,p:`xs`,children:t.map(e=>(0,r.jsxs)(n.Group,{gap:`xs`,justify:`space-between`,wrap:`nowrap`,children:[(0,r.jsx)(n.Checkbox,{label:c(e),checked:e.getIsVisible(),onChange:t=>e.toggleVisibility(t.currentTarget.checked)}),(0,r.jsx)(G,{column:e})]},e.id))})})]})}function K({view:e,searchPlaceholder:t=`Search…`,filterInlineThreshold:i=3,lockSwitcherOnMobile:a,showSearch:o,showFilters:s,showSort:c,showVisibility:l,showViewSwitcher:u,disableWhileLoading:d=!0,leftSection:f,rightSection:p,...m}){let{table:h,state:g}=e,_=d&&e.status===`loading`,v=o??h.options.enableGlobalFilter!==!1,y=s??e.filterableColumns.length>0,b=c??e.sortableColumns.length>0,S=l??!0,C=u??!0;return(0,r.jsxs)(n.Group,{justify:`space-between`,wrap:`wrap`,gap:`sm`,...m,children:[(0,r.jsxs)(n.Group,{wrap:`wrap`,gap:`sm`,children:[f,v&&(0,r.jsx)(n.TextInput,{"aria-label":`Search`,placeholder:t,leftSection:(0,r.jsx)(x,{}),value:g.globalFilter,onChange:e=>h.setGlobalFilter(e.currentTarget.value),rightSection:g.globalFilter?(0,r.jsx)(n.CloseButton,{size:`sm`,"aria-label":`Clear search`,onClick:()=>h.setGlobalFilter(``)}):void 0}),(0,r.jsxs)(`fieldset`,{disabled:_,style:{display:`contents`,border:`none`,padding:0,margin:0},children:[y&&(0,r.jsx)(U,{view:e,inlineThreshold:i}),b&&(0,r.jsx)(ie,{view:e})]})]}),(0,r.jsx)(`fieldset`,{disabled:_,style:{display:`contents`,border:`none`,padding:0,margin:0},children:(0,r.jsxs)(n.Group,{wrap:`wrap`,gap:`sm`,children:[S&&(0,r.jsx)(ae,{view:e}),C&&(0,r.jsx)(W,{view:e,lockSwitcherOnMobile:a}),p]})})]})}var q=(0,i.createContext)(null),J=q.Provider;function Y(){let e=(0,i.useContext)(q);if(!e)throw Error(`DataView.Toolbar / DataView.Body / DataView.Pagination must be rendered inside <DataView>.`);return e}function X({view:e,slots:t,renderCard:a,fallbackRole:o,lockSwitcherOnMobile:s,animateRows:c,children:l,...u}){return(0,r.jsx)(J,{value:(0,i.useMemo)(()=>({view:e,slots:t,renderCard:a,fallbackRole:o,lockSwitcherOnMobile:s,animateRows:c}),[e,t,a,o,s,c]),children:(0,r.jsx)(n.Stack,{...u,children:l??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Z,{}),(0,r.jsx)(ce,{}),(0,r.jsx)(oe,{}),(0,r.jsx)(se,{})]})})})}function Z(e){let{view:t,lockSwitcherOnMobile:n}=Y();return(0,r.jsx)(K,{view:t,lockSwitcherOnMobile:n,...e})}function oe({tableProps:e,cardsProps:t}){let{view:n,slots:i,renderCard:a,fallbackRole:o,animateRows:s}=Y();return n.view===`cards`?(0,r.jsx)(g,{view:n,slots:i,renderCard:a,fallbackRole:o,animateRows:s,...t}):(0,r.jsx)(D,{view:n,slots:i,animateRows:s,...e})}function se(e){let{view:t}=Y();return(0,r.jsx)(v,{view:t,...e})}function ce(e){let{view:t,slots:n}=Y();return(0,r.jsx)(s,{view:t,slots:n,...e})}X.Toolbar=Z,X.BulkActions=ce,X.Body=oe,X.Pagination=se;function le(e){return e.replace(/_/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/\b\w/g,e=>e.toUpperCase())}var ue={text:{dataType:`text`,filterVariant:`text`},number:{dataType:`number`,filterVariant:`numberRange`,align:`right`},currency:{dataType:`currency`,filterVariant:`numberRange`,align:`right`},date:{dataType:`date`,filterVariant:`dateRange`},boolean:{dataType:`boolean`,filterVariant:`boolean`},select:{filterVariant:`select`},multiselect:{filterVariant:`multiselect`}},de=class{cols=[];helper=(0,t.createColumnHelper)();add(e,t,n){let r=ue[e];if(!r)throw Error(`Unknown preset: ${e}`);let i=n?.header??le(t),a=n?.align??r.align,o;if(n?.filter===!1)o=void 0;else{let e={variant:r.filterVariant,...n?.options?{options:n.options}:{}};o=n?.filter?{...e,...n.filter}:e}let s=this.helper.accessor(t,{header:i,...n?.cell?{cell:n.cell}:{},...n?.enableSorting===!1?{enableSorting:!1}:{},meta:{label:i,...r.dataType?{dataType:r.dataType}:{},...a?{align:a}:{},...o?{filter:o}:{},...n?.format?{format:n.format}:{},...n?.card?{card:{role:n.card,...n.cardOrder==null?{}:{order:n.cardOrder}}}:{}}});return this.cols.push(s),this}text(e,t){return this.add(`text`,e,t)}number(e,t){return this.add(`number`,e,t)}currency(e,t){return this.add(`currency`,e,t)}date(e,t){return this.add(`date`,e,t)}boolean(e,t){return this.add(`boolean`,e,t)}select(e,t){return this.add(`select`,e,t)}multiselect(e,t){return this.add(`multiselect`,e,t)}custom(e){return this.cols.push(e),this}build(){return this.cols}};function fe(){return new de}function Q(e){let t=e==null?``:String(e);return t.includes(`,`)||t.includes(`"`)||t.includes(`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./serializer-CGmBq-Jz.cjs");let t=require("@tanstack/react-table"),n=require("@mantine/core"),r=require("react/jsx-runtime"),i=require("react"),a=require("@mantine/hooks"),o=require("@mantine/dates");require("@mantine/dates/styles.css");function s({view:e,slots:t,...i}){let{selection:a}=e;return a.count===0?null:(0,r.jsx)(n.Paper,{withBorder:!0,p:`xs`,radius:`sm`,role:`region`,"aria-label":`Bulk actions`,...i,children:(0,r.jsxs)(n.Group,{justify:`space-between`,wrap:`wrap`,gap:`sm`,children:[(0,r.jsxs)(n.Group,{gap:`sm`,children:[(0,r.jsxs)(n.Text,{size:`sm`,fw:500,children:[a.count,` selected`]}),(0,r.jsx)(n.Button,{variant:`subtle`,size:`xs`,onClick:a.clear,children:`Clear`})]}),t?.BulkActions&&(0,r.jsx)(n.Group,{gap:`xs`,children:t.BulkActions(a)})]})})}function c(e){let{meta:t,header:n}=e.columnDef;return t?.label?t.label:typeof n==`string`?n:e.id}function l(e,t,n){return t?t===`hidden`?null:t:e.accessorFn==null||n===`hidden`?null:n}function u(e,t={}){let n=t.fallbackRole??`meta`,r={title:[],subtitle:[],media:[],badge:[],meta:[]};e.getVisibleLeafColumns().forEach((e,t)=>{let i=e.columnDef.meta?.card,a=l(e,i?.role,n);a&&r[a].push({order:i?.order??t,index:t,field:{id:e.id,column:e,label:c(e),showLabel:i?.showLabel??a===`meta`}})});let i=e=>e.sort((e,t)=>e.order-t.order||e.index-t.index).map(e=>e.field);return{title:i(r.title),subtitle:i(r.subtitle),media:i(r.media),badge:i(r.badge),meta:i(r.meta)}}function d(e,t){let n=(0,i.useRef)([]),r=(0,i.useRef)(!1),a=(0,i.useRef)(0),o=(0,i.useRef)(!1);(0,i.useEffect)(()=>{t&&!o.current&&typeof document<`u`&&process.env.NODE_ENV!==`production`&&(Array.from(document.styleSheets).some(e=>{try{return Array.from(e.cssRules).some(e=>e instanceof CSSKeyframesRule&&e.name===`dataview-row-enter`)}catch{return!1}})||console.warn(`[@ethanhann/mantine-dataview] animateRows is enabled but the CSS keyframes are missing. Import "@ethanhann/mantine-dataview/styles.css" in your app entry.`),o.current=!0)},[t]);let s=e.map(e=>e.id),c=new Set;if(t&&r.current){let e=n.current,t=new Set(e);if(s.length!==e.length||s.some((t,n)=>t!==e[n]))if(a.current++,s.length===e.length&&s.every(e=>t.has(e)))for(let e of s)c.add(e);else for(let e of s)t.has(e)||c.add(e)}return n.current=s,r.current=!0,{rows:e,entering:c,generation:a.current}}function f(e){e.resetColumnFilters(),e.setGlobalFilter(``)}function p({view:e,slots:t}){return t?.ErrorState?(0,r.jsx)(r.Fragment,{children:t.ErrorState({error:e.error,retry:e.refetch})}):(0,r.jsxs)(n.Stack,{align:`center`,gap:`xs`,children:[(0,r.jsx)(n.Text,{c:`red`,children:`Something went wrong.`}),(0,r.jsx)(n.Button,{variant:`light`,size:`xs`,onClick:e.refetch,children:`Retry`})]})}function m({view:e,slots:t}){let i=e.renderStatus.phase===`empty-filtered`,a=()=>f(e.table);return t?.Empty?(0,r.jsx)(r.Fragment,{children:t.Empty({filtered:i,clearFilters:a})}):i?(0,r.jsxs)(n.Stack,{align:`center`,gap:`xs`,children:[(0,r.jsx)(n.Text,{c:`dimmed`,children:`No matches.`}),(0,r.jsx)(n.Button,{variant:`subtle`,size:`xs`,onClick:a,children:`Clear filters`})]}):(0,r.jsx)(n.Text,{c:`dimmed`,children:`No results.`})}var h={base:1,sm:2,lg:3};function g({view:e,slots:t,renderCard:i,fallbackRole:a,enableSelection:o,loadingCardCount:s,animateRows:c=!1,cols:l=h,...f}){let{table:g,renderStatus:v}=e,y=o??g.options.enableRowSelection!==!1,b=s??Math.min(e.state.pagination.pageSize,6),x={cols:l,...f},S=d(g.getRowModel().rows,c),C=e=>{let o=u(g,{fallbackRole:a});return(0,r.jsx)(n.SimpleGrid,{"data-changed":c||void 0,...x,children:e.map(e=>{let a=e.getIsSelected(),s={row:e,data:e.original,selected:a,toggleSelected:()=>e.toggleSelected()},c=S.entering.has(e.id)||void 0;if(i)return(0,r.jsx)(`div`,{"data-entering":c,children:i(s)},e.id);let l=(0,r.jsx)(_,{row:e,layout:o,selectionEnabled:y});return t?.Card?(0,r.jsx)(`div`,{"data-entering":c,children:t.Card({...s,children:l})},e.id):(0,r.jsx)(n.Card,{withBorder:!0,padding:`lg`,pos:`relative`,"data-selected":a||void 0,"data-entering":c,children:l},e.id)})},S.generation)};if(c&&v.phase===`loading`&&S.rows.length>0)return C(S.rows);switch(v.phase){case`loading`:return t?.LoadingCards?t.LoadingCards():(0,r.jsx)(n.SimpleGrid,{...x,children:Array.from({length:b},(e,t)=>(0,r.jsx)(n.Card,{withBorder:!0,padding:`md`,children:(0,r.jsxs)(n.Stack,{gap:`xs`,children:[(0,r.jsx)(n.Skeleton,{height:20,width:`60%`}),(0,r.jsx)(n.Skeleton,{height:12,width:`40%`}),(0,r.jsx)(n.Skeleton,{height:12})]})},t))});case`error`:return(0,r.jsx)(n.Center,{p:`xl`,children:(0,r.jsx)(p,{view:e,slots:t})});case`empty`:case`empty-filtered`:return(0,r.jsx)(n.Center,{p:`xl`,children:(0,r.jsx)(m,{view:e,slots:t})});default:return C(S.rows)}}function _({row:e,layout:a,selectionEnabled:o}){let s=new Map(e.getAllCells().map(e=>[e.column.id,e])),c=e=>{let n=s.get(e.id);return n?(0,t.flexRender)(n.column.columnDef.cell,n.getContext()):null};return(0,r.jsxs)(r.Fragment,{children:[o&&(0,r.jsx)(n.Checkbox,{"aria-label":`Select card`,checked:e.getIsSelected(),disabled:!e.getCanSelect(),onChange:e.getToggleSelectedHandler(),style:{position:`absolute`,top:8,right:8,zIndex:1}}),a.media.length>0&&(0,r.jsx)(n.Card.Section,{mb:`xs`,children:a.media.map(e=>(0,r.jsx)(n.Box,{children:c(e)},e.id))}),(0,r.jsxs)(n.Stack,{gap:`md`,children:[(a.title.length>0||a.subtitle.length>0)&&(0,r.jsxs)(n.Stack,{gap:4,children:[a.title.map(e=>(0,r.jsx)(n.Text,{fw:600,size:`lg`,lh:1.2,pr:o?28:0,children:c(e)},e.id)),a.subtitle.map(e=>(0,r.jsx)(n.Text,{size:`sm`,c:`dimmed`,children:c(e)},e.id))]}),a.badge.length>0&&(0,r.jsx)(n.Group,{gap:`xs`,children:a.badge.map(e=>(0,r.jsx)(i.Fragment,{children:c(e)},e.id))}),a.meta.length>0&&(0,r.jsx)(n.Stack,{gap:4,children:a.meta.map(e=>(0,r.jsxs)(n.Group,{justify:`space-between`,gap:`xs`,wrap:`nowrap`,children:[e.showLabel&&(0,r.jsx)(n.Text,{size:`sm`,c:`dimmed`,children:e.label}),(0,r.jsx)(n.Text,{size:`sm`,children:c(e)})]},e.id))})]})]})}function v({view:e,pageSizeOptions:t,showPageSize:i=!0,showRange:a=!0,pageSizeLabel:o=`Rows per page`,...s}){let{table:c}=e,{pageIndex:l,pageSize:u}=e.state.pagination,d=c.getRowCount(),f=c.getPageCount(),p=t??e.pageSizeOptions,m=d===0?0:l*u+1,h=Math.min((l+1)*u,d);return(0,r.jsxs)(n.Group,{justify:`space-between`,wrap:`wrap`,gap:`sm`,...s,children:[(0,r.jsxs)(n.Group,{gap:`sm`,wrap:`wrap`,children:[i&&(0,r.jsx)(n.Select,{"aria-label":o,data:p.map(String),value:String(u),onChange:e=>e&&c.setPageSize(Number(e)),w:80,comboboxProps:{withinPortal:!0}}),a&&(0,r.jsxs)(n.Text,{size:`sm`,c:`dimmed`,children:[m,`–`,h,` of `,d]})]}),(0,r.jsx)(n.Pagination,{value:l+1,total:Math.max(f,1),onChange:e=>c.setPageIndex(e-1),getControlProps:e=>({"aria-label":`${e} page`})})]})}function y({direction:e}){return(0,r.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,focusable:`false`,style:{flexShrink:0},children:[(0,r.jsx)(`title`,{children:`sort`}),(0,r.jsx)(`path`,{d:`M8 10l4-4 4 4`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,opacity:e===`asc`?1:.35}),(0,r.jsx)(`path`,{d:`M8 14l4 4 4-4`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,opacity:e===`desc`?1:.35})]})}function b({d:e,title:t}){return(0,r.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,style:{flexShrink:0},children:[(0,r.jsx)(`title`,{children:t}),(0,r.jsx)(`path`,{d:e})]})}function x(){return(0,r.jsx)(b,{title:`search`,d:`M21 21l-4.3-4.3M11 19a8 8 0 110-16 8 8 0 010 16z`})}function S(){return(0,r.jsx)(b,{title:`filter`,d:`M3 5h18M7 12h10M10 19h4`})}function C(){return(0,r.jsx)(b,{title:`open`,d:`M6 9l6 6 6-6`})}function w(){return(0,r.jsx)(b,{title:`close`,d:`M18 6L6 18M6 6l12 12`})}function T(){return(0,r.jsx)(b,{title:`pin left`,d:`M4 4v16M9 8h8M9 12h6M9 16h8`})}function ee(){return(0,r.jsx)(b,{title:`pin right`,d:`M20 4v16M7 8h8M9 12h6M7 16h8`})}function E(e){let t=e.getIsPinned();if(t)return{position:`sticky`,[t]:t===`left`?e.getStart(`left`):e.getAfter(`right`),zIndex:1,backgroundColor:`var(--mantine-color-body)`}}function D({view:e,slots:i,enableSelection:a,loadingRowCount:o,disableWhileLoading:s=!0,animateRows:c=!1,...l}){let{table:u,renderStatus:f}=e,h=s&&e.status===`loading`,g=d(u.getRowModel().rows,c),_=u.getVisibleLeafColumns(),v=a??u.options.enableRowSelection!==!1,y=_.length+ +!!v,b=o??Math.min(e.state.pagination.pageSize,8),x=e=>(0,r.jsx)(n.Table.Tbody,{"data-changed":c||void 0,children:e.map(e=>{let a=g.entering.has(e.id)||void 0,o=(0,r.jsxs)(r.Fragment,{children:[v&&(0,r.jsx)(n.Table.Td,{children:(0,r.jsx)(n.Checkbox,{"aria-label":`Select row`,checked:e.getIsSelected(),disabled:!e.getCanSelect(),indeterminate:e.getIsSomeSelected(),onChange:e.getToggleSelectedHandler()})}),e.getVisibleCells().map(e=>{let i=e.column.columnDef.meta?.align;return(0,r.jsx)(n.Table.Td,{style:{...E(e.column),...i?{textAlign:i}:void 0},children:(0,t.flexRender)(e.column.columnDef.cell,e.getContext())},e.id)})]});return i?.Row?(0,r.jsx)(O,{children:i.Row({row:e,cells:o})},e.id):(0,r.jsx)(n.Table.Tr,{"data-selected":e.getIsSelected()||void 0,"data-entering":a,children:o},e.id)})},g.generation),S=()=>{if(c&&f.phase===`loading`&&g.rows.length>0)return x(g.rows);switch(f.phase){case`loading`:return i?.LoadingTable?i.LoadingTable():(0,r.jsx)(n.Table.Tbody,{children:Array.from({length:b},(e,t)=>(0,r.jsxs)(n.Table.Tr,{children:[v&&(0,r.jsx)(n.Table.Td,{children:(0,r.jsx)(n.Skeleton,{height:16,width:16})}),_.map(e=>(0,r.jsx)(n.Table.Td,{children:(0,r.jsx)(n.Skeleton,{height:12})},e.id))]},t))});case`error`:return(0,r.jsx)(k,{colSpan:y,children:(0,r.jsx)(p,{view:e,slots:i})});case`empty`:case`empty-filtered`:return(0,r.jsx)(k,{colSpan:y,children:(0,r.jsx)(m,{view:e,slots:i})});default:return x(g.rows)}};return(0,r.jsx)(`div`,{style:u.getIsSomeColumnsPinned()?{overflowX:`auto`}:void 0,children:(0,r.jsxs)(n.Table,{layout:`fixed`,...l,children:[(0,r.jsx)(n.Table.Thead,{children:u.getHeaderGroups().map(e=>(0,r.jsxs)(n.Table.Tr,{children:[v&&(0,r.jsx)(n.Table.Th,{style:{width:40},children:(0,r.jsx)(n.Checkbox,{"aria-label":`Select all rows on this page`,checked:u.getIsAllPageRowsSelected(),indeterminate:u.getIsSomePageRowsSelected()&&!u.getIsAllPageRowsSelected(),onChange:u.getToggleAllPageRowsSelectedHandler()})}),e.headers.map(e=>(0,r.jsx)(A,{header:e,disabled:h},e.id))]},e.id))}),S()]})})}function O({children:e}){return(0,r.jsx)(r.Fragment,{children:e})}function k({colSpan:e,children:t}){return(0,r.jsx)(n.Table.Tbody,{children:(0,r.jsx)(n.Table.Tr,{children:(0,r.jsx)(n.Table.Td,{colSpan:e,children:(0,r.jsx)(n.Center,{p:`xl`,children:t})})})})}function A({header:e,disabled:i}){let{column:a}=e,o=a.columnDef.meta?.align,s=a.getIsSorted(),c=a.getSortIndex(),l=c>0,u=e.isPlaceholder?null:(0,t.flexRender)(a.columnDef.header,e.getContext()),d=a.getCanSort()&&!i;return(0,r.jsx)(n.Table.Th,{style:{...E(a),...o?{textAlign:o}:void 0},"aria-sort":s===`asc`?`ascending`:s===`desc`?`descending`:void 0,children:d?(0,r.jsxs)(n.UnstyledButton,{onClick:a.getToggleSortingHandler(),style:{display:`inline-flex`,alignItems:`center`,gap:4,font:`inherit`},children:[u,(0,r.jsx)(y,{direction:s}),l&&(0,r.jsx)(`span`,{role:`note`,style:{fontSize:`0.7em`,opacity:.6},"aria-label":`Sort priority ${c+1}`,children:c+1})]}):(0,r.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4,...i?{opacity:.5}:{}},children:[u,s&&(0,r.jsx)(y,{direction:s})]})})}var te=`(max-width: 0px)`;function j(e){let t=/^([\d.]+)(\D*)$/.exec(e.trim());if(!t)return`(max-width: ${e})`;let n=Number(t[1]),r=t[2]||`px`;return`(max-width: ${n-(r===`em`||r===`rem`?.01:.1)}${r})`}function ne(e){let t=(0,n.useMantineTheme)(),r=e?.forceCardsBelow,i=r?t.breakpoints[r]:void 0,o=(0,a.useMediaQuery)(i?j(i):te,!1);return!!i&&!!o}var M={text:e=>e==null?``:String(e),number:e=>e==null?``:new Intl.NumberFormat().format(Number(e)),currency:e=>e==null?``:new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`}).format(Number(e)),date:e=>{if(e==null)return``;let t=e instanceof Date?e:new Date(String(e));return Number.isNaN(t.getTime())?String(e):new Intl.DateTimeFormat().format(t)},boolean:e=>e==null?``:e?`Yes`:`No`};function re(e,t){if(e===`number`||e===`currency`){let n=new Intl.NumberFormat(void 0,e===`currency`?{style:`currency`,...t}:t);return e=>e==null?``:n.format(Number(e))}if(e===`date`){let e=new Intl.DateTimeFormat(void 0,t);return t=>{if(t==null)return``;let n=t instanceof Date?t:new Date(String(t));return Number.isNaN(n.getTime())?String(t):e.format(n)}}return M[e]}function N(e,t,n){let r=t??n?.[e];return r?typeof r==`function`?r:re(e,r):M[e]}function P({facet:e,value:t,onChange:i}){let a=Array.isArray(t)?t:null;return(0,r.jsx)(n.Stack,{gap:4,children:e.ranges.map(e=>{let t=a!=null&&a[0]===e.from&&a[1]===e.to;return(0,r.jsx)(n.UnstyledButton,{onClick:()=>i(t?void 0:[e.from,e.to]),style:{padding:`4px 8px`,borderRadius:4,background:t?`var(--mantine-color-blue-light)`:void 0},children:(0,r.jsxs)(n.Group,{gap:`xs`,justify:`space-between`,wrap:`nowrap`,children:[(0,r.jsx)(n.Text,{size:`sm`,children:e.label}),(0,r.jsx)(n.Badge,{size:`sm`,variant:`light`,color:e.count===0?`gray`:`blue`,children:e.count})]})},e.label)})})}function F({label:e,onClear:t}){return(0,r.jsxs)(n.Group,{justify:`space-between`,wrap:`nowrap`,children:[(0,r.jsx)(n.Text,{size:`sm`,fw:500,children:e}),(0,r.jsx)(n.Anchor,{component:`button`,type:`button`,size:`xs`,c:`dimmed`,onClick:t,children:`clear`})]})}function I(e){return e?typeof e==`string`?e:e.toISOString().split(`T`)[0]??null:null}function L(e){return Array.isArray(e)?[e[0],e[1]]:[null,null]}function R(e,t){return e.values.length>0?e.values.map(e=>({value:e.value,label:`${e.label??e.value} (${e.count})`,disabled:e.count===0})):t??[]}function z({column:e,facet:t}){let i=e.columnDef.meta?.filter;if(!i)return null;let a=c(e),s=i.placeholder??a,l=e.getFilterValue(),u=t=>e.setFilterValue(t);if(i.component){let t=i.component;return(0,r.jsx)(n.Input.Wrapper,{label:a,children:(0,r.jsx)(t,{value:l,onChange:u,column:e})})}let d=t?.type===`values`?t:void 0,f=t?.type===`ranges`?t:void 0;switch(i.variant){case`select`:return(0,r.jsx)(n.Select,{label:a,placeholder:s,clearable:!0,data:d?R(d,i.options):i.options??[],value:l??null,onChange:e=>u(e??void 0)});case`multiselect`:return(0,r.jsx)(n.MultiSelect,{label:a,placeholder:s,data:d?R(d,i.options):i.options??[],value:l??[],onChange:e=>u(e.length>0?e:void 0)});case`boolean`:{let e=l==null?`all`:l?`yes`:`no`,t=d?.values.find(e=>e.value===`true`),i=d?.values.find(e=>e.value===`false`),o=t?`Yes (${t.count})`:`Yes`,s=i?`No (${i.count})`:`No`;return(0,r.jsx)(n.Input.Wrapper,{label:a,children:(0,r.jsx)(n.SegmentedControl,{fullWidth:!0,size:`xs`,data:[{value:`all`,label:`All`},{value:`yes`,label:o},{value:`no`,label:s}],value:e,onChange:e=>{u(e===`all`?void 0:e===`yes`)}})})}case`numberRange`:{let[t,o]=L(l),s=i.min??f?.min,c=i.max??f?.max,d=s!=null&&c!=null,p=l!=null,m=f?(0,r.jsx)(P,{facet:f,value:l,onChange:u}):null,h=p?(0,r.jsx)(F,{label:a,onClear:()=>u(void 0)}):a;if(d){let l=[t??s,o??c],d=e.columnDef.meta?.dataType,f=d?N(d,e.columnDef.meta?.format,void 0):e=>String(e);return(0,r.jsx)(n.Input.Wrapper,{label:h,children:(0,r.jsxs)(n.Stack,{gap:`xs`,children:[m,(0,r.jsx)(n.RangeSlider,{min:s,max:c,step:i.step??1,value:l,onChange:([e,t])=>{u(e===s&&t===c?void 0:[e,t])},label:e=>f(e),minRange:i.step??1,"aria-label":a})]})})}if(m)return(0,r.jsx)(n.Input.Wrapper,{label:h,children:m});let g=e=>u(e[0]==null&&e[1]==null?void 0:e),_=e=>e===``||e==null?null:Number(e);return(0,r.jsx)(n.Input.Wrapper,{label:a,children:(0,r.jsxs)(n.Group,{gap:4,wrap:`nowrap`,children:[(0,r.jsx)(n.NumberInput,{"aria-label":`${a} minimum`,placeholder:`Min`,value:t??``,onChange:e=>g([_(e),o]),w:90}),(0,r.jsx)(n.NumberInput,{"aria-label":`${a} maximum`,placeholder:`Max`,value:o??``,onChange:e=>g([t,_(e)]),w:90})]})})}case`date`:return(0,r.jsx)(o.DatePickerInput,{label:a,placeholder:s,clearable:!0,popoverProps:{withinPortal:!1},value:l?new Date(l):null,onChange:e=>u(I(e)??void 0)});case`dateRange`:{let[e,t]=L(l),i=[e?new Date(e):null,t?new Date(t):null],c=l==null?a:(0,r.jsx)(F,{label:a,onClear:()=>u(void 0)});return(0,r.jsx)(n.Input.Wrapper,{label:c,children:(0,r.jsxs)(n.Stack,{gap:`xs`,children:[f&&(0,r.jsx)(P,{facet:f,value:l,onChange:u}),(0,r.jsx)(o.DatePickerInput,{type:`range`,popoverProps:{withinPortal:!1},placeholder:s,clearable:!0,value:i,onChange:([e,t])=>{let n=I(e),r=I(t);u(n==null&&r==null?void 0:[n,r])}})]})})}default:return(0,r.jsx)(n.TextInput,{label:a,placeholder:s,value:l??``,onChange:e=>u(e.currentTarget.value||void 0)})}}function B({view:e}){return e.state.columnFilters.length>0?(0,r.jsx)(n.Button,{variant:`subtle`,size:`compact-sm`,color:`gray`,leftSection:(0,r.jsx)(w,{}),onClick:()=>e.table.resetColumnFilters(),children:`Reset filters`}):null}function V(e){return e>0?`Filters (${e})`:`Filters`}function H({view:e,controls:t}){return(0,r.jsxs)(n.Stack,{gap:`sm`,style:{minWidth:240},children:[t,(0,r.jsx)(n.Group,{justify:`flex-end`,children:(0,r.jsx)(B,{view:e})})]})}function U({view:e,inlineThreshold:t}){let i=e.filterableColumns,o=(0,a.useMediaQuery)(j((0,n.useMantineTheme)().breakpoints.sm),!1),[s,{open:c,close:l}]=(0,a.useDisclosure)(!1);if(i.length===0)return null;let u=i.map(t=>(0,r.jsx)(z,{column:t,facet:e.facets[t.id]},t.id)),d=e.state.columnFilters.length;return o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Button,{variant:`default`,leftSection:(0,r.jsx)(S,{}),onClick:c,children:V(d)}),(0,r.jsx)(n.Drawer,{opened:s,onClose:l,title:`Filters`,position:`bottom`,size:`auto`,children:(0,r.jsx)(H,{view:e,controls:u})})]}):i.length<=t?(0,r.jsxs)(r.Fragment,{children:[u,(0,r.jsx)(B,{view:e})]}):(0,r.jsxs)(n.Popover,{position:`bottom-start`,closeOnClickOutside:!1,children:[(0,r.jsx)(n.Popover.Target,{children:(0,r.jsx)(n.Button,{variant:`default`,leftSection:(0,r.jsx)(S,{}),children:V(d)})}),(0,r.jsx)(n.Popover.Dropdown,{children:(0,r.jsx)(H,{view:e,controls:u})})]})}function ie({view:e}){let{sortableColumns:t,state:i,table:a}=e,o=i.sorting[0];return(0,r.jsxs)(n.Group,{gap:4,wrap:`nowrap`,children:[(0,r.jsx)(n.Select,{"aria-label":`Sort by`,placeholder:`Sort by`,clearable:!0,data:t.map(e=>({value:e.id,label:c(e)})),value:o?.id??null,onChange:e=>a.setSorting(e?[{id:e,desc:o?.desc??!1}]:[])}),(0,r.jsx)(n.ActionIcon,{"aria-label":`Toggle sort direction`,variant:`default`,size:`lg`,disabled:!o,onClick:()=>o&&a.setSorting([{id:o.id,desc:!o.desc}]),children:(0,r.jsx)(y,{direction:o?o.desc?`desc`:`asc`:!1})})]})}function W({view:e,lockSwitcherOnMobile:t,tableLabel:i=`Table`,cardsLabel:a=`Cards`}){return e.isMobileForced&&t?null:(0,r.jsx)(n.SegmentedControl,{"aria-label":`View`,value:e.view,disabled:e.isMobileForced,onChange:t=>{(t===`table`||t===`cards`)&&e.setView(t)},data:[{value:`table`,label:i},{value:`cards`,label:a}]})}function G({column:e}){if(!e.getCanPin())return null;let t=e.getIsPinned();return(0,r.jsxs)(n.Group,{gap:2,children:[(0,r.jsx)(n.ActionIcon,{size:`xs`,variant:t===`left`?`filled`:`subtle`,color:t===`left`?`blue`:`gray`,"aria-label":`Pin ${c(e)} left`,onClick:()=>e.pin(t===`left`?!1:`left`),children:(0,r.jsx)(T,{})}),(0,r.jsx)(n.ActionIcon,{size:`xs`,variant:t===`right`?`filled`:`subtle`,color:t===`right`?`blue`:`gray`,"aria-label":`Pin ${c(e)} right`,onClick:()=>e.pin(t===`right`?!1:`right`),children:(0,r.jsx)(ee,{})})]})}function ae({view:e}){let t=e.table.getAllLeafColumns().filter(e=>e.getCanHide());return t.length===0?null:(0,r.jsxs)(n.Menu,{closeOnItemClick:!1,withinPortal:!0,position:`bottom-end`,children:[(0,r.jsx)(n.Menu.Target,{children:(0,r.jsx)(n.Button,{variant:`default`,rightSection:(0,r.jsx)(C,{}),children:`Columns`})}),(0,r.jsx)(n.Menu.Dropdown,{children:(0,r.jsx)(n.Stack,{gap:`xs`,p:`xs`,children:t.map(e=>(0,r.jsxs)(n.Group,{gap:`xs`,justify:`space-between`,wrap:`nowrap`,children:[(0,r.jsx)(n.Checkbox,{label:c(e),checked:e.getIsVisible(),onChange:t=>e.toggleVisibility(t.currentTarget.checked)}),(0,r.jsx)(G,{column:e})]},e.id))})})]})}function K({view:e,searchPlaceholder:t=`Search…`,filterInlineThreshold:i=3,lockSwitcherOnMobile:a,showSearch:o,showFilters:s,showSort:c,showVisibility:l,showViewSwitcher:u,disableWhileLoading:d=!0,leftSection:f,rightSection:p,...m}){let{table:h,state:g}=e,_=d&&e.status===`loading`,v=o??h.options.enableGlobalFilter!==!1,y=s??e.filterableColumns.length>0,b=c??e.sortableColumns.length>0,S=l??!0,C=u??!0;return(0,r.jsxs)(n.Group,{justify:`space-between`,wrap:`wrap`,gap:`sm`,...m,children:[(0,r.jsxs)(n.Group,{wrap:`wrap`,gap:`sm`,children:[f,v&&(0,r.jsx)(n.TextInput,{"aria-label":`Search`,placeholder:t,leftSection:(0,r.jsx)(x,{}),value:g.globalFilter,onChange:e=>h.setGlobalFilter(e.currentTarget.value),rightSection:g.globalFilter?(0,r.jsx)(n.CloseButton,{size:`sm`,"aria-label":`Clear search`,onClick:()=>h.setGlobalFilter(``)}):void 0}),(0,r.jsxs)(`fieldset`,{disabled:_,style:{display:`contents`,border:`none`,padding:0,margin:0},children:[y&&(0,r.jsx)(U,{view:e,inlineThreshold:i}),b&&(0,r.jsx)(ie,{view:e})]})]}),(0,r.jsx)(`fieldset`,{disabled:_,style:{display:`contents`,border:`none`,padding:0,margin:0},children:(0,r.jsxs)(n.Group,{wrap:`wrap`,gap:`sm`,children:[S&&(0,r.jsx)(ae,{view:e}),C&&(0,r.jsx)(W,{view:e,lockSwitcherOnMobile:a}),p]})})]})}var q=(0,i.createContext)(null),J=q.Provider;function Y(){let e=(0,i.useContext)(q);if(!e)throw Error(`DataViewer.Toolbar / DataViewer.Body / DataViewer.Pagination must be rendered inside <DataViewer>.`);return e}function X({view:e,slots:t,renderCard:a,fallbackRole:o,lockSwitcherOnMobile:s,animateRows:c,children:l,...u}){return(0,r.jsx)(J,{value:(0,i.useMemo)(()=>({view:e,slots:t,renderCard:a,fallbackRole:o,lockSwitcherOnMobile:s,animateRows:c}),[e,t,a,o,s,c]),children:(0,r.jsx)(n.Stack,{...u,children:l??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Z,{}),(0,r.jsx)(ce,{}),(0,r.jsx)(oe,{}),(0,r.jsx)(se,{})]})})})}function Z(e){let{view:t,lockSwitcherOnMobile:n}=Y();return(0,r.jsx)(K,{view:t,lockSwitcherOnMobile:n,...e})}function oe({tableProps:e,cardsProps:t}){let{view:n,slots:i,renderCard:a,fallbackRole:o,animateRows:s}=Y();return n.view===`cards`?(0,r.jsx)(g,{view:n,slots:i,renderCard:a,fallbackRole:o,animateRows:s,...t}):(0,r.jsx)(D,{view:n,slots:i,animateRows:s,...e})}function se(e){let{view:t}=Y();return(0,r.jsx)(v,{view:t,...e})}function ce(e){let{view:t,slots:n}=Y();return(0,r.jsx)(s,{view:t,slots:n,...e})}X.Toolbar=Z,X.BulkActions=ce,X.Body=oe,X.Pagination=se;function le(e){return e.replace(/_/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/\b\w/g,e=>e.toUpperCase())}var ue={text:{dataType:`text`,filterVariant:`text`},number:{dataType:`number`,filterVariant:`numberRange`,align:`right`},currency:{dataType:`currency`,filterVariant:`numberRange`,align:`right`},date:{dataType:`date`,filterVariant:`dateRange`},boolean:{dataType:`boolean`,filterVariant:`boolean`},select:{filterVariant:`select`},multiselect:{filterVariant:`multiselect`}},de=class{cols=[];helper=(0,t.createColumnHelper)();add(e,t,n){let r=ue[e];if(!r)throw Error(`Unknown preset: ${e}`);let i=n?.header??le(t),a=n?.align??r.align,o;if(n?.filter===!1)o=void 0;else{let e={variant:r.filterVariant,...n?.options?{options:n.options}:{}};o=n?.filter?{...e,...n.filter}:e}let s=this.helper.accessor(t,{header:i,...n?.cell?{cell:n.cell}:{},...n?.enableSorting===!1?{enableSorting:!1}:{},meta:{label:i,...r.dataType?{dataType:r.dataType}:{},...a?{align:a}:{},...o?{filter:o}:{},...n?.format?{format:n.format}:{},...n?.card?{card:{role:n.card,...n.cardOrder==null?{}:{order:n.cardOrder}}}:{}}});return this.cols.push(s),this}text(e,t){return this.add(`text`,e,t)}number(e,t){return this.add(`number`,e,t)}currency(e,t){return this.add(`currency`,e,t)}date(e,t){return this.add(`date`,e,t)}boolean(e,t){return this.add(`boolean`,e,t)}select(e,t){return this.add(`select`,e,t)}multiselect(e,t){return this.add(`multiselect`,e,t)}custom(e){return this.cols.push(e),this}build(){return this.cols}};function fe(){return new de}function Q(e){let t=e==null?``:String(e);return t.includes(`,`)||t.includes(`"`)||t.includes(`
2
2
  `)?`"${t.replace(/"/g,`""`)}"`:t}function pe(e,t){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=>Q(c(e))),...e.getRowModel().rows.map(e=>o.map(t=>{let n=e.getAllCells().find(e=>e.column.id===t.id)?.getValue();return i&&t.columnDef.meta?.dataType?Q(N(t.columnDef.meta.dataType,t.columnDef.meta.format,a)(n)):Q(n)}))].map(e=>e.join(r)).join(`
3
- `),l=new Blob([s],{type:`text/csv;charset=utf-8;`}),u=URL.createObjectURL(l),d=document.createElement(`a`);d.href=u,d.download=n,d.click(),URL.revokeObjectURL(u)}function me(t){return t?{adapter:t.adapter,serializer:{...e.t,...t.serialize},include:e.r(t.include)}:null}function he(t,n,r){if(!t)return{};try{return e.n(t.adapter.read(),{serializer:t.serializer,include:t.include,getFilterMeta:r,current:n})}catch{return{}}}function ge({config:t,state:n,applyPatch:r,getFilterMeta:a}){let o=(0,i.useRef)(n);o.current=n;let s=(0,i.useRef)(r);s.current=r;let c=(0,i.useRef)(a);c.current=a;let l=(0,i.useRef)(t);l.current=t;let u=t?e.i(n,{serializer:t.serializer,include:t.include,getFilterMeta:a}):null;(0,i.useEffect)(()=>{let t=l.current;if(!t||!u)return;let n=e.a(t.adapter.read(),t.serializer,t.include);t.adapter.write({...n,...u},{replace:!0})},[u?JSON.stringify(u):``]),(0,i.useEffect)(()=>{if(!t)return;let{adapter:n,serializer:r,include:i}=t;return n.subscribe?.(()=>{let t=e.n(n.read(),{serializer:r,include:i,getFilterMeta:c.current,current:o.current});s.current(t)})},[t])}function _e(e){return e.columnFilters.length>0||e.globalFilter.trim()!==``}function ve({status:e,error:t,pageRowCount:n,state:r}){return e===`error`?{phase:`error`,error:t}:e===`loading`||e===`idle`?{phase:`loading`}:n===0?_e(r)?{phase:`empty-filtered`}:{phase:`empty`}:{phase:`ready`}}var $=300,ye=[10,25,50,100],be=10;function xe(e){return e==null?{globalFilter:$,columnFilters:$}:typeof e==`number`?{globalFilter:e,columnFilters:e}:{globalFilter:e.globalFilter??$,columnFilters:e.columnFilters??$}}function Se(e){if(e.id)return e.id;if(`accessorKey`in e&&e.accessorKey!=null)return String(e.accessorKey)}function Ce(e){let t=new Map;for(let n of e){let e=Se(n),r=n.meta?.filter;e&&r&&t.set(e,r)}return e=>t.get(e)}function we(e){return{pagination:{pageIndex:0,pageSize:e.pageSizeOptions?.[0]??be},sorting:[],columnFilters:[],globalFilter:``,rowSelection:{},columnVisibility:{},columnPinning:{left:[],right:[]},view:e.defaultView??`table`,...e.initialState}}function Te(e){let{columns:n,rows:r,rowCount:a,status:o,error:s,getRowId:c,onRequestChange:l,state:u,onStateChange:d,enableRowSelection:f,enableGlobalFilter:p=!0,debounce:m,responsive:h,formatDefaults:g,facets:_,params:v}=e,y=_??{},b=v?JSON.stringify(v):``,x=v??{},S=(0,i.useMemo)(()=>n.map(e=>{let t=e.meta?.dataType;if(!t||e.cell)return e;let n=N(t,e.meta?.format,g);return{...e,cell:e=>n(e.getValue())}}),[n,g]),C=(0,i.useMemo)(()=>Ce(S),[S]),w=(0,i.useMemo)(()=>me(e.urlSync),[e.urlSync]),[T,ee]=(0,i.useState)(()=>{let t=we(e);return{...t,...he(w,t,C)}}),E=(0,i.useMemo)(()=>({...T,...u}),[T,u]),D=(0,i.useRef)(E);D.current=E;let O=(0,i.useCallback)(e=>{ee(t=>({...t,...e})),d?.({...D.current,...e})},[d]);ge({config:w,state:E,applyPatch:O,getFilterMeta:C});let k=(0,i.useCallback)(()=>({...D.current.pagination,pageIndex:0}),[]),A=(0,i.useRef)(b);(0,i.useEffect)(()=>{A.current!==b&&(A.current=b,O({pagination:k()}))});let te=(0,i.useCallback)(e=>{O({pagination:(0,t.functionalUpdate)(e,D.current.pagination)})},[O]),j=(0,i.useCallback)(e=>{O({sorting:(0,t.functionalUpdate)(e,D.current.sorting),pagination:k()})},[O,k]),M=(0,i.useCallback)(e=>{O({columnFilters:(0,t.functionalUpdate)(e,D.current.columnFilters),pagination:k()})},[O,k]),re=(0,i.useCallback)(e=>{O({globalFilter:(0,t.functionalUpdate)(e,D.current.globalFilter),pagination:k()})},[O,k]),P=(0,i.useCallback)(e=>{O({rowSelection:(0,t.functionalUpdate)(e,D.current.rowSelection)})},[O]),F=(0,i.useCallback)(e=>{O({columnVisibility:(0,t.functionalUpdate)(e,D.current.columnVisibility)})},[O]),I=(0,i.useCallback)(e=>{O({columnPinning:(0,t.functionalUpdate)(e,D.current.columnPinning)})},[O]),L=(0,t.useReactTable)({data:r,columns:S,getCoreRowModel:(0,t.getCoreRowModel)(),manualPagination:!0,manualSorting:!0,manualFiltering:!0,autoResetPageIndex:!1,rowCount:a,getRowId:e=>c(e),enableRowSelection:typeof f==`function`?e=>f(e.original):f??!0,enableGlobalFilter:p,state:{pagination:E.pagination,sorting:E.sorting,columnFilters:E.columnFilters,globalFilter:E.globalFilter,rowSelection:E.rowSelection,columnVisibility:E.columnVisibility,columnPinning:E.columnPinning},onPaginationChange:te,onSortingChange:j,onColumnFiltersChange:M,onGlobalFilterChange:re,onRowSelectionChange:P,onColumnVisibilityChange:F,onColumnPinningChange:I}),R=(0,i.useMemo)(()=>({pagination:E.pagination,sorting:E.sorting,filters:E.columnFilters,globalFilter:E.globalFilter,params:x}),[E.pagination,E.sorting,E.columnFilters,E.globalFilter,b]),z=(0,i.useRef)(l);z.current=l;let B=(0,i.useRef)(xe(m));B.current=xe(m);let V=(0,i.useRef)(null),H=(0,i.useRef)(void 0);(0,i.useEffect)(()=>{let e=V.current,t=e===null,n=!e||e.globalFilter!==R.globalFilter,r=!e||e.filters!==R.filters,i=()=>{V.current=R,z.current?.(R)},a=0;n&&(a=Math.max(a,B.current.globalFilter)),r&&(a=Math.max(a,B.current.columnFilters));let o=!t&&(n||r)&&a>0;return clearTimeout(H.current),o?H.current=setTimeout(i,a):i(),()=>clearTimeout(H.current)},[R]);let U=(0,i.useRef)(R);U.current=R;let ie=(0,i.useCallback)(()=>{z.current?.(U.current)},[]),W=(0,i.useMemo)(()=>ve({status:o,error:s,pageRowCount:r.length,state:E}),[o,s,r.length,E]),G=ne(h),ae=G?`cards`:E.view,K=(0,i.useCallback)(e=>O({view:e}),[O]),q=e.pageSizeOptions??ye,J=L.getAllColumns(),Y=J.filter(e=>e.getCanSort()),X=J.filter(e=>e.columnDef.meta?.filter!=null),Z=(0,i.useCallback)(()=>O({rowSelection:{}}),[O]);return{table:L,request:R,state:E,view:ae,setView:K,isMobileForced:G,status:o,error:s,renderStatus:W,refetch:ie,pageSizeOptions:q,sortableColumns:Y,filterableColumns:X,selection:(0,i.useMemo)(()=>{let e=E.rowSelection,t=Object.keys(e).filter(t=>e[t]),n=r.filter(t=>e[c(t)]===!0);return{count:t.length,ids:t,rows:n,clear:Z}},[E.rowSelection,r,c,Z]),exportCsv:(0,i.useCallback)(e=>pe(L,e),[L]),facets:y,resetFilter:(0,i.useCallback)(e=>L.getColumn(e)?.setFilterValue(void 0),[L]),resetAllFilters:(0,i.useCallback)(()=>L.resetColumnFilters(),[L])}}function Ee({fetcher:e,deps:t,...n}){let[r,a]=(0,i.useState)({rows:[],rowCount:0}),[o,s]=(0,i.useState)(`idle`),[c,l]=(0,i.useState)(void 0),u=(0,i.useRef)(e);u.current=e;let d=(0,i.useRef)(0),f=(0,i.useRef)(null),p=(0,i.useCallback)(async e=>{f.current=e;let t=++d.current;s(`loading`);try{let n=await u.current(e);t===d.current&&(a(n),l(void 0),s(`success`))}catch(e){t===d.current&&(l(e),s(`error`))}},[]),m=t?JSON.stringify(t):``,h=(0,i.useRef)(m);return(0,i.useEffect)(()=>{h.current!==m&&(h.current=m,f.current&&p(f.current))}),Te({...n,rows:r.rows,rowCount:r.rowCount,facets:r.facets,status:o,error:c,onRequestChange:p})}exports.ColumnBuilder=de,exports.DataBulkActions=s,exports.DataCards=g,exports.DataPagination=v,exports.DataTable=D,exports.DataToolbar=K,exports.DataView=X,exports.FilterControl=z,exports.ViewSwitcher=W,exports.col=fe,exports.composeCardLayout=u,Object.defineProperty(exports,"createColumnHelper",{enumerable:!0,get:function(){return t.createColumnHelper}}),exports.exportCsv=pe,exports.resolveColumnLabel=c,exports.useDataView=Te,exports.useDataViewContext=Y,exports.useDataViewFetcher=Ee;
3
+ `),l=new Blob([s],{type:`text/csv;charset=utf-8;`}),u=URL.createObjectURL(l),d=document.createElement(`a`);d.href=u,d.download=n,d.click(),URL.revokeObjectURL(u)}function me(t){return t?{adapter:t.adapter,serializer:{...e.t,...t.serialize},include:e.r(t.include)}:null}function he(t,n,r){if(!t)return{};try{return e.n(t.adapter.read(),{serializer:t.serializer,include:t.include,getFilterMeta:r,current:n})}catch{return{}}}function ge({config:t,state:n,applyPatch:r,getFilterMeta:a}){let o=(0,i.useRef)(n);o.current=n;let s=(0,i.useRef)(r);s.current=r;let c=(0,i.useRef)(a);c.current=a;let l=(0,i.useRef)(t);l.current=t;let u=t?e.i(n,{serializer:t.serializer,include:t.include,getFilterMeta:a}):null;(0,i.useEffect)(()=>{let t=l.current;if(!t||!u)return;let n=e.a(t.adapter.read(),t.serializer,t.include);t.adapter.write({...n,...u},{replace:!0})},[u?JSON.stringify(u):``]),(0,i.useEffect)(()=>{if(!t)return;let{adapter:n,serializer:r,include:i}=t;return n.subscribe?.(()=>{let t=e.n(n.read(),{serializer:r,include:i,getFilterMeta:c.current,current:o.current});s.current(t)})},[t])}function _e(e){return e.columnFilters.length>0||e.globalFilter.trim()!==``}function ve({status:e,error:t,pageRowCount:n,state:r}){return e===`error`?{phase:`error`,error:t}:e===`loading`||e===`idle`?{phase:`loading`}:n===0?_e(r)?{phase:`empty-filtered`}:{phase:`empty`}:{phase:`ready`}}var $=300,ye=[10,25,50,100],be=10;function xe(e){return e==null?{globalFilter:$,columnFilters:$}:typeof e==`number`?{globalFilter:e,columnFilters:e}:{globalFilter:e.globalFilter??$,columnFilters:e.columnFilters??$}}function Se(e){if(e.id)return e.id;if(`accessorKey`in e&&e.accessorKey!=null)return String(e.accessorKey)}function Ce(e){let t=new Map;for(let n of e){let e=Se(n),r=n.meta?.filter;e&&r&&t.set(e,r)}return e=>t.get(e)}function we(e){return{pagination:{pageIndex:0,pageSize:e.pageSizeOptions?.[0]??be},sorting:[],columnFilters:[],globalFilter:``,rowSelection:{},columnVisibility:{},columnPinning:{left:[],right:[]},view:e.defaultView??`table`,...e.initialState}}function Te(e){let{columns:n,rows:r,rowCount:a,status:o,error:s,getRowId:c,onRequestChange:l,state:u,onStateChange:d,enableRowSelection:f,enableGlobalFilter:p=!0,debounce:m,responsive:h,formatDefaults:g,facets:_,params:v}=e,y=_??{},b=v?JSON.stringify(v):``,x=v??{},S=(0,i.useMemo)(()=>n.map(e=>{let t=e.meta?.dataType;if(!t||e.cell)return e;let n=N(t,e.meta?.format,g);return{...e,cell:e=>n(e.getValue())}}),[n,g]),C=(0,i.useMemo)(()=>Ce(S),[S]),w=(0,i.useMemo)(()=>me(e.urlSync),[e.urlSync]),[T,ee]=(0,i.useState)(()=>{let t=we(e);return{...t,...he(w,t,C)}}),E=(0,i.useMemo)(()=>({...T,...u}),[T,u]),D=(0,i.useRef)(E);D.current=E;let O=(0,i.useCallback)(e=>{ee(t=>({...t,...e})),d?.({...D.current,...e})},[d]);ge({config:w,state:E,applyPatch:O,getFilterMeta:C});let k=(0,i.useCallback)(()=>({...D.current.pagination,pageIndex:0}),[]),A=(0,i.useRef)(b);(0,i.useEffect)(()=>{A.current!==b&&(A.current=b,O({pagination:k()}))});let te=(0,i.useCallback)(e=>{O({pagination:(0,t.functionalUpdate)(e,D.current.pagination)})},[O]),j=(0,i.useCallback)(e=>{O({sorting:(0,t.functionalUpdate)(e,D.current.sorting),pagination:k()})},[O,k]),M=(0,i.useCallback)(e=>{O({columnFilters:(0,t.functionalUpdate)(e,D.current.columnFilters),pagination:k()})},[O,k]),re=(0,i.useCallback)(e=>{O({globalFilter:(0,t.functionalUpdate)(e,D.current.globalFilter),pagination:k()})},[O,k]),P=(0,i.useCallback)(e=>{O({rowSelection:(0,t.functionalUpdate)(e,D.current.rowSelection)})},[O]),F=(0,i.useCallback)(e=>{O({columnVisibility:(0,t.functionalUpdate)(e,D.current.columnVisibility)})},[O]),I=(0,i.useCallback)(e=>{O({columnPinning:(0,t.functionalUpdate)(e,D.current.columnPinning)})},[O]),L=(0,t.useReactTable)({data:r,columns:S,getCoreRowModel:(0,t.getCoreRowModel)(),manualPagination:!0,manualSorting:!0,manualFiltering:!0,autoResetPageIndex:!1,rowCount:a,getRowId:e=>c(e),enableRowSelection:typeof f==`function`?e=>f(e.original):f??!0,enableGlobalFilter:p,state:{pagination:E.pagination,sorting:E.sorting,columnFilters:E.columnFilters,globalFilter:E.globalFilter,rowSelection:E.rowSelection,columnVisibility:E.columnVisibility,columnPinning:E.columnPinning},onPaginationChange:te,onSortingChange:j,onColumnFiltersChange:M,onGlobalFilterChange:re,onRowSelectionChange:P,onColumnVisibilityChange:F,onColumnPinningChange:I}),R=(0,i.useMemo)(()=>({pagination:E.pagination,sorting:E.sorting,filters:E.columnFilters,globalFilter:E.globalFilter,params:x}),[E.pagination,E.sorting,E.columnFilters,E.globalFilter,b]),z=(0,i.useRef)(l);z.current=l;let B=(0,i.useRef)(xe(m));B.current=xe(m);let V=(0,i.useRef)(null),H=(0,i.useRef)(void 0);(0,i.useEffect)(()=>{let e=V.current,t=e===null,n=!e||e.globalFilter!==R.globalFilter,r=!e||e.filters!==R.filters,i=()=>{V.current=R,z.current?.(R)},a=0;n&&(a=Math.max(a,B.current.globalFilter)),r&&(a=Math.max(a,B.current.columnFilters));let o=!t&&(n||r)&&a>0;return clearTimeout(H.current),o?H.current=setTimeout(i,a):i(),()=>clearTimeout(H.current)},[R]);let U=(0,i.useRef)(R);U.current=R;let ie=(0,i.useCallback)(()=>{z.current?.(U.current)},[]),W=(0,i.useMemo)(()=>ve({status:o,error:s,pageRowCount:r.length,state:E}),[o,s,r.length,E]),G=ne(h),ae=G?`cards`:E.view,K=(0,i.useCallback)(e=>O({view:e}),[O]),q=e.pageSizeOptions??ye,J=L.getAllColumns(),Y=J.filter(e=>e.getCanSort()),X=J.filter(e=>e.columnDef.meta?.filter!=null),Z=(0,i.useCallback)(()=>O({rowSelection:{}}),[O]);return{table:L,request:R,state:E,view:ae,setView:K,isMobileForced:G,status:o,error:s,renderStatus:W,refetch:ie,pageSizeOptions:q,sortableColumns:Y,filterableColumns:X,selection:(0,i.useMemo)(()=>{let e=E.rowSelection,t=Object.keys(e).filter(t=>e[t]),n=r.filter(t=>e[c(t)]===!0);return{count:t.length,ids:t,rows:n,clear:Z}},[E.rowSelection,r,c,Z]),exportCsv:(0,i.useCallback)(e=>pe(L,e),[L]),facets:y,resetFilter:(0,i.useCallback)(e=>L.getColumn(e)?.setFilterValue(void 0),[L]),resetAllFilters:(0,i.useCallback)(()=>L.resetColumnFilters(),[L])}}function Ee({fetcher:e,deps:t,...n}){let[r,a]=(0,i.useState)({rows:[],rowCount:0}),[o,s]=(0,i.useState)(`idle`),[c,l]=(0,i.useState)(void 0),u=(0,i.useRef)(e);u.current=e;let d=(0,i.useRef)(0),f=(0,i.useRef)(null),p=(0,i.useCallback)(async e=>{f.current=e;let t=++d.current;s(`loading`);try{let n=await u.current(e);t===d.current&&(a(n),l(void 0),s(`success`))}catch(e){t===d.current&&(l(e),s(`error`))}},[]),m=t?JSON.stringify(t):``,h=(0,i.useRef)(m);return(0,i.useEffect)(()=>{h.current!==m&&(h.current=m,f.current&&p(f.current))}),Te({...n,rows:r.rows,rowCount:r.rowCount,facets:r.facets,status:o,error:c,onRequestChange:p})}exports.ColumnBuilder=de,exports.DataBulkActions=s,exports.DataCards=g,exports.DataPagination=v,exports.DataTable=D,exports.DataToolbar=K,exports.DataViewer=X,exports.FilterControl=z,exports.ViewSwitcher=W,exports.col=fe,exports.composeCardLayout=u,Object.defineProperty(exports,"createColumnHelper",{enumerable:!0,get:function(){return t.createColumnHelper}}),exports.exportCsv=pe,exports.resolveColumnLabel=c,exports.useDataView=Te,exports.useDataViewContext=Y,exports.useDataViewFetcher=Ee;
4
4
  //# sourceMappingURL=index.cjs.map