@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.
- package/LICENSE +21 -0
- package/README.md +640 -0
- package/dist/components/DataBulkActions/DataBulkActions.d.ts +9 -0
- package/dist/components/DataBulkActions/index.d.ts +1 -0
- package/dist/components/DataCards/DataCards.d.ts +24 -0
- package/dist/components/DataCards/index.d.ts +1 -0
- package/dist/components/DataPagination/DataPagination.d.ts +13 -0
- package/dist/components/DataPagination/index.d.ts +1 -0
- package/dist/components/DataTable/DataTable.d.ts +13 -0
- package/dist/components/DataTable/index.d.ts +1 -0
- package/dist/components/DataToolbar/DataToolbar.d.ts +16 -0
- package/dist/components/DataToolbar/FacetBuckets.d.ts +6 -0
- package/dist/components/DataToolbar/FilterControl.d.ts +6 -0
- package/dist/components/DataToolbar/FilterControls.d.ts +5 -0
- package/dist/components/DataToolbar/SortControl.d.ts +4 -0
- package/dist/components/DataToolbar/ViewSwitcher.d.ts +5 -0
- package/dist/components/DataToolbar/VisibilityMenu.d.ts +4 -0
- package/dist/components/DataToolbar/index.d.ts +2 -0
- package/dist/components/DataView/DataView.d.ts +36 -0
- package/dist/components/DataView/context.d.ts +13 -0
- package/dist/components/DataView/index.d.ts +2 -0
- package/dist/components/StateMessage.d.ts +12 -0
- package/dist/components/icons.d.ts +14 -0
- package/dist/components/types.d.ts +43 -0
- package/dist/core/cardComposition.d.ts +34 -0
- package/dist/core/exportCsv.d.ts +10 -0
- package/dist/core/formatValue.d.ts +4 -0
- package/dist/core/resolveStatus.d.ts +11 -0
- package/dist/core/useDataView.d.ts +2 -0
- package/dist/core/useDataViewFetcher.d.ts +7 -0
- package/dist/core/useForceCards.d.ts +8 -0
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +1395 -0
- package/dist/index.js.map +1 -0
- package/dist/serializer-CGmBq-Jz.cjs +2 -0
- package/dist/serializer-CGmBq-Jz.cjs.map +1 -0
- package/dist/serializer-u2zq_sU7.js +117 -0
- package/dist/serializer-u2zq_sU7.js.map +1 -0
- package/dist/stories/data.d.ts +14 -0
- package/dist/types/column.d.ts +74 -0
- package/dist/types/facets.d.ts +27 -0
- package/dist/types/options.d.ts +95 -0
- package/dist/types/request.d.ts +18 -0
- package/dist/types/state.d.ts +57 -0
- package/dist/url/index.cjs +2 -0
- package/dist/url/index.cjs.map +1 -0
- package/dist/url/index.d.ts +5 -0
- package/dist/url/index.js +20 -0
- package/dist/url/index.js.map +1 -0
- package/dist/url/serializer.d.ts +33 -0
- package/dist/url/types.d.ts +23 -0
- package/dist/url/useUrlSync.d.ts +23 -0
- package/package.json +90 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GroupProps } from '@mantine/core';
|
|
2
|
+
import { UseDataViewReturn } from '../../types/options';
|
|
3
|
+
export interface DataPaginationProps<TData> extends Omit<GroupProps, "children"> {
|
|
4
|
+
/** The `useDataView` instance to project. */
|
|
5
|
+
view: UseDataViewReturn<TData>;
|
|
6
|
+
/** Override the page size choices. It defaults to the core's `pageSizeOptions`. */
|
|
7
|
+
pageSizeOptions?: number[];
|
|
8
|
+
showPageSize?: boolean;
|
|
9
|
+
/** Show the range summary, such as "1 to 10 of 42". It defaults to true. */
|
|
10
|
+
showRange?: boolean;
|
|
11
|
+
pageSizeLabel?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function DataPagination<TData>({ view, pageSizeOptions, showPageSize, showRange, pageSizeLabel, ...groupProps }: DataPaginationProps<TData>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataPagination, type DataPaginationProps } from './DataPagination';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TableProps } from '@mantine/core';
|
|
2
|
+
import { UseDataViewReturn } from '../../types/options';
|
|
3
|
+
import { DataViewSlots } from '../types';
|
|
4
|
+
export interface DataTableProps<TData> extends Omit<TableProps, "data" | "children"> {
|
|
5
|
+
/** The `useDataView` instance to project. */
|
|
6
|
+
view: UseDataViewReturn<TData>;
|
|
7
|
+
slots?: DataViewSlots<TData>;
|
|
8
|
+
/** Whether to render the leading selection checkbox column. It defaults to the core setting. */
|
|
9
|
+
enableSelection?: boolean;
|
|
10
|
+
/** Skeleton rows shown while loading. It defaults to the current page size, capped at 8. */
|
|
11
|
+
loadingRowCount?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function DataTable<TData>({ view, slots, enableSelection, loadingRowCount, ...tableProps }: DataTableProps<TData>): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataTable, type DataTableProps } from './DataTable';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GroupProps } from '@mantine/core';
|
|
2
|
+
import { UseDataViewReturn } from '../../types/options';
|
|
3
|
+
export interface DataToolbarProps<TData> extends Omit<GroupProps, "children"> {
|
|
4
|
+
/** The `useDataView` instance to drive. */
|
|
5
|
+
view: UseDataViewReturn<TData>;
|
|
6
|
+
searchPlaceholder?: string;
|
|
7
|
+
/** Filterable columns up to this count render inline. More than that collapse into a popover. */
|
|
8
|
+
filterInlineThreshold?: number;
|
|
9
|
+
lockSwitcherOnMobile?: boolean;
|
|
10
|
+
showSearch?: boolean;
|
|
11
|
+
showFilters?: boolean;
|
|
12
|
+
showSort?: boolean;
|
|
13
|
+
showVisibility?: boolean;
|
|
14
|
+
showViewSwitcher?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function DataToolbar<TData>({ view, searchPlaceholder, filterInlineThreshold, lockSwitcherOnMobile, showSearch, showFilters, showSort, showVisibility, showViewSwitcher, ...groupProps }: DataToolbarProps<TData>): import("react").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { StackProps } from '@mantine/core';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { UseDataViewReturn } from '../../types/options';
|
|
4
|
+
import { DataBulkActionsProps } from '../DataBulkActions';
|
|
5
|
+
import { DataCardsProps } from '../DataCards';
|
|
6
|
+
import { DataPaginationProps } from '../DataPagination';
|
|
7
|
+
import { DataTableProps } from '../DataTable';
|
|
8
|
+
import { DataToolbarProps } from '../DataToolbar';
|
|
9
|
+
import { DataViewSlots } from '../types';
|
|
10
|
+
export interface DataViewProps<TData> extends Omit<StackProps, "children"> {
|
|
11
|
+
/** The `useDataView` instance to project. */
|
|
12
|
+
view: UseDataViewReturn<TData>;
|
|
13
|
+
slots?: DataViewSlots<TData>;
|
|
14
|
+
renderCard?: DataCardsProps<TData>["renderCard"];
|
|
15
|
+
fallbackRole?: DataCardsProps<TData>["fallbackRole"];
|
|
16
|
+
lockSwitcherOnMobile?: boolean;
|
|
17
|
+
/** Custom composition. It defaults to Toolbar, BulkActions, Body, and Pagination. */
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export declare function DataView<TData>({ view, slots, renderCard, fallbackRole, lockSwitcherOnMobile, children, ...stackProps }: DataViewProps<TData>): import("react").JSX.Element;
|
|
21
|
+
export declare namespace DataView {
|
|
22
|
+
var Toolbar: typeof DataViewToolbar;
|
|
23
|
+
var BulkActions: typeof DataViewBulkActions;
|
|
24
|
+
var Body: typeof DataViewBody;
|
|
25
|
+
var Pagination: typeof DataViewPagination;
|
|
26
|
+
}
|
|
27
|
+
export type DataViewToolbarProps<TData> = Omit<DataToolbarProps<TData>, "view">;
|
|
28
|
+
declare function DataViewToolbar<TData>(props: DataViewToolbarProps<TData>): import("react").JSX.Element;
|
|
29
|
+
export interface DataViewBodyProps<TData> {
|
|
30
|
+
tableProps?: Omit<DataTableProps<TData>, "view" | "slots">;
|
|
31
|
+
cardsProps?: Omit<DataCardsProps<TData>, "view" | "slots" | "renderCard" | "fallbackRole">;
|
|
32
|
+
}
|
|
33
|
+
declare function DataViewBody<TData>({ tableProps, cardsProps, }: DataViewBodyProps<TData>): import("react").JSX.Element;
|
|
34
|
+
declare function DataViewPagination<TData>(props: Omit<DataPaginationProps<TData>, "view">): import("react").JSX.Element;
|
|
35
|
+
declare function DataViewBulkActions<TData>(props: Omit<DataBulkActionsProps<TData>, "view" | "slots">): import("react").JSX.Element;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComposeCardOptions } from '../../core/cardComposition';
|
|
2
|
+
import { UseDataViewReturn } from '../../types/options';
|
|
3
|
+
import { DataCardsProps } from '../DataCards';
|
|
4
|
+
import { DataViewSlots } from '../types';
|
|
5
|
+
export interface DataViewContextValue<TData> {
|
|
6
|
+
view: UseDataViewReturn<TData>;
|
|
7
|
+
slots?: DataViewSlots<TData>;
|
|
8
|
+
renderCard?: DataCardsProps<TData>["renderCard"];
|
|
9
|
+
fallbackRole?: ComposeCardOptions["fallbackRole"];
|
|
10
|
+
lockSwitcherOnMobile?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const DataViewProvider: import('react').Provider<DataViewContextValue<unknown> | null>;
|
|
13
|
+
export declare function useDataViewContext<TData>(): DataViewContextValue<TData>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Table } from '@tanstack/react-table';
|
|
2
|
+
import { UseDataViewReturn } from '../types/options';
|
|
3
|
+
import { DataViewSlots } from './types';
|
|
4
|
+
/** Resets all column filters and the global search. This is the clear action for filtered empty. */
|
|
5
|
+
export declare function clearAllFilters<TData>(table: Table<TData>): void;
|
|
6
|
+
interface StateProps<TData> {
|
|
7
|
+
view: UseDataViewReturn<TData>;
|
|
8
|
+
slots?: DataViewSlots<TData>;
|
|
9
|
+
}
|
|
10
|
+
export declare function ErrorContent<TData>({ view, slots }: StateProps<TData>): import("react").JSX.Element;
|
|
11
|
+
export declare function EmptyContent<TData>({ view, slots }: StateProps<TData>): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SortDirection } from '@tanstack/react-table';
|
|
2
|
+
/**
|
|
3
|
+
* Sort indicator. It highlights the up or down chevron when active and dims both when unsorted.
|
|
4
|
+
* It is decorative. The accessible sort state is conveyed by `aria-sort` on the header cell.
|
|
5
|
+
*/
|
|
6
|
+
export declare function SortIcon({ direction }: {
|
|
7
|
+
direction: SortDirection | false;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
export declare function SearchIcon(): import("react").JSX.Element;
|
|
10
|
+
export declare function FilterIcon(): import("react").JSX.Element;
|
|
11
|
+
export declare function ChevronDownIcon(): import("react").JSX.Element;
|
|
12
|
+
export declare function CloseIcon(): import("react").JSX.Element;
|
|
13
|
+
export declare function PinLeftIcon(): import("react").JSX.Element;
|
|
14
|
+
export declare function PinRightIcon(): import("react").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Row } from '@tanstack/react-table';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { DataViewSelection } from '../types/options';
|
|
4
|
+
export interface EmptySlotContext {
|
|
5
|
+
/** True when the empty result comes from active filters or search. */
|
|
6
|
+
filtered: boolean;
|
|
7
|
+
/** Clears all column filters and global search, returning to the unfiltered query. */
|
|
8
|
+
clearFilters: () => void;
|
|
9
|
+
}
|
|
10
|
+
export interface ErrorSlotContext {
|
|
11
|
+
error: unknown;
|
|
12
|
+
/** Emits the current request again. */
|
|
13
|
+
retry: () => void;
|
|
14
|
+
}
|
|
15
|
+
export interface RowSlotContext<TData> {
|
|
16
|
+
row: Row<TData>;
|
|
17
|
+
/** The cells for this row that the library renders by default, both selection and data. */
|
|
18
|
+
cells: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
/** Full per card escape hatch. It bypasses the default composition entirely. */
|
|
21
|
+
export interface RenderCardContext<TData> {
|
|
22
|
+
row: Row<TData>;
|
|
23
|
+
data: TData;
|
|
24
|
+
selected: boolean;
|
|
25
|
+
toggleSelected: () => void;
|
|
26
|
+
}
|
|
27
|
+
/** Card slot. It wraps the default composed content rather than replacing it. */
|
|
28
|
+
export interface CardSlotContext<TData> extends RenderCardContext<TData> {
|
|
29
|
+
/** The card body composed by default, including the selection overlay and role slots. */
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
}
|
|
32
|
+
/** Customization slots shared by the presentations. */
|
|
33
|
+
export interface DataViewSlots<TData> {
|
|
34
|
+
/** Empty and filtered empty states share one slot, told apart by `filtered`. */
|
|
35
|
+
Empty?: (ctx: EmptySlotContext) => ReactNode;
|
|
36
|
+
ErrorState?: (ctx: ErrorSlotContext) => ReactNode;
|
|
37
|
+
LoadingTable?: () => ReactNode;
|
|
38
|
+
LoadingCards?: () => ReactNode;
|
|
39
|
+
Row?: (ctx: RowSlotContext<TData>) => ReactNode;
|
|
40
|
+
Card?: (ctx: CardSlotContext<TData>) => ReactNode;
|
|
41
|
+
/** Consumer actions for the bulk bar. It receives the current selection. */
|
|
42
|
+
BulkActions?: (selection: DataViewSelection<TData>) => ReactNode;
|
|
43
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Column, Table } from '@tanstack/react-table';
|
|
2
|
+
import { CardRole } from '../types/column';
|
|
3
|
+
/** Roles that produce a rendered slot; `hidden` columns are dropped from the layout. */
|
|
4
|
+
export type CardLayoutRole = Exclude<CardRole, "hidden">;
|
|
5
|
+
export interface CardField<TData> {
|
|
6
|
+
id: string;
|
|
7
|
+
column: Column<TData>;
|
|
8
|
+
/** Resolved display label. It prefers meta.label, then a string header, then the column id. */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Whether to render the label beside the value as a pair. */
|
|
11
|
+
showLabel: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface CardLayout<TData> {
|
|
14
|
+
title: CardField<TData>[];
|
|
15
|
+
subtitle: CardField<TData>[];
|
|
16
|
+
media: CardField<TData>[];
|
|
17
|
+
badge: CardField<TData>[];
|
|
18
|
+
meta: CardField<TData>[];
|
|
19
|
+
}
|
|
20
|
+
export interface ComposeCardOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Role for visible accessor columns that declare no `card.role`. The default is `'meta'`.
|
|
23
|
+
* Set it to `'hidden'` to make card fields opt in. Display columns have no accessor, such as
|
|
24
|
+
* an actions column, and are always hidden unless they declare an explicit role.
|
|
25
|
+
*/
|
|
26
|
+
fallbackRole?: CardLayoutRole | "hidden";
|
|
27
|
+
}
|
|
28
|
+
/** The label used by card fields, the sort control, and toolbar filters. It is the one source. */
|
|
29
|
+
export declare function resolveColumnLabel<TData>(column: Column<TData>): string;
|
|
30
|
+
/**
|
|
31
|
+
* Builds the card layout from the columns that are currently visible. Within each role group the
|
|
32
|
+
* fields are ordered by `meta.card.order`, falling back to the column's declared position.
|
|
33
|
+
*/
|
|
34
|
+
export declare function composeCardLayout<TData>(table: Table<TData>, options?: ComposeCardOptions): CardLayout<TData>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Table } from '@tanstack/react-table';
|
|
2
|
+
import { ColumnDataType, ColumnFormatOption } from '../types/column';
|
|
3
|
+
export interface ExportCsvOptions {
|
|
4
|
+
filename?: string;
|
|
5
|
+
separator?: string;
|
|
6
|
+
/** When true, applies column dataType formatters to exported values. Default: false (raw values). */
|
|
7
|
+
formatted?: boolean;
|
|
8
|
+
formatDefaults?: Partial<Record<ColumnDataType, ColumnFormatOption>>;
|
|
9
|
+
}
|
|
10
|
+
export declare function exportCsv<TData>(table: Table<TData>, options?: ExportCsvOptions): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ColumnDataType, ColumnFormatOption } from '../types/column';
|
|
2
|
+
type Formatter = (value: unknown) => string;
|
|
3
|
+
export declare function resolveFormatter(dataType: ColumnDataType, columnFormat: ColumnFormatOption | undefined, tableDefaults: Partial<Record<ColumnDataType, ColumnFormatOption>> | undefined): Formatter;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DataViewState, DataViewStatus, Status } from '../types/state';
|
|
2
|
+
export declare function isFiltered(state: DataViewState): boolean;
|
|
3
|
+
interface ResolveArgs {
|
|
4
|
+
status: Status;
|
|
5
|
+
error: unknown;
|
|
6
|
+
/** Number of rows on the current page after a successful fetch. */
|
|
7
|
+
pageRowCount: number;
|
|
8
|
+
state: DataViewState;
|
|
9
|
+
}
|
|
10
|
+
export declare function resolveDataViewStatus({ status, error, pageRowCount, state, }: ResolveArgs): DataViewStatus;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UseDataViewOptions, UseDataViewReturn } from '../types/options';
|
|
2
|
+
import { DataViewRequest, DataViewResponse } from '../types/request';
|
|
3
|
+
export interface UseDataViewFetcherOptions<TData> extends Omit<UseDataViewOptions<TData>, "rows" | "rowCount" | "status" | "error" | "onRequestChange"> {
|
|
4
|
+
/** Maps a request to a response, using any transport or data layer. */
|
|
5
|
+
fetcher: (request: DataViewRequest) => Promise<DataViewResponse<NoInfer<TData>>>;
|
|
6
|
+
}
|
|
7
|
+
export declare function useDataViewFetcher<TData>({ fetcher, ...options }: UseDataViewFetcherOptions<TData>): UseDataViewReturn<TData>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ResponsiveOptions } from '../types/options';
|
|
2
|
+
/**
|
|
3
|
+
* Builds a query meaning "strictly narrower than this breakpoint". The small epsilon keeps the
|
|
4
|
+
* boundary from overlapping a minimum width query at the same breakpoint. That matches the
|
|
5
|
+
* convention Mantine itself uses.
|
|
6
|
+
*/
|
|
7
|
+
export declare function belowBreakpointQuery(value: string): string;
|
|
8
|
+
export declare function useForceCards(responsive: ResponsiveOptions | undefined): boolean;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +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){e.resetColumnFilters(),e.setGlobalFilter(``)}function f({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 p({view:e,slots:t}){let i=e.renderStatus.phase===`empty-filtered`,a=()=>d(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 m={base:1,sm:2,lg:3};function h({view:e,slots:t,renderCard:i,fallbackRole:a,enableSelection:o,loadingCardCount:s,cols:c=m,...l}){let{table:d,renderStatus:h}=e,v=o??d.options.enableRowSelection!==!1,y=s??Math.min(e.state.pagination.pageSize,6),b={cols:c,...l};switch(h.phase){case`loading`:return t?.LoadingCards?t.LoadingCards():(0,r.jsx)(n.SimpleGrid,{...b,children:Array.from({length:y},(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)(f,{view:e,slots:t})});case`empty`:case`empty-filtered`:return(0,r.jsx)(n.Center,{p:`xl`,children:(0,r.jsx)(p,{view:e,slots:t})});default:{let e=u(d,{fallbackRole:a});return(0,r.jsx)(n.SimpleGrid,{...b,children:d.getRowModel().rows.map(a=>{let o=a.getIsSelected(),s={row:a,data:a.original,selected:o,toggleSelected:()=>a.toggleSelected()};if(i)return(0,r.jsx)(g,{children:i(s)},a.id);let c=(0,r.jsx)(_,{row:a,layout:e,selectionEnabled:v});return t?.Card?(0,r.jsx)(g,{children:t.Card({...s,children:c})},a.id):(0,r.jsx)(n.Card,{withBorder:!0,padding:`lg`,pos:`relative`,"data-selected":o||void 0,children:c},a.id)})})}}}function g({children:e}){return(0,r.jsx)(r.Fragment,{children:e})}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 E(){return(0,r.jsx)(b,{title:`pin right`,d:`M20 4v16M7 8h8M9 12h6M7 16h8`})}function D(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 O({view:e,slots:i,enableSelection:a,loadingRowCount:o,...s}){let{table:c,renderStatus:l}=e,u=c.getVisibleLeafColumns(),d=a??c.options.enableRowSelection!==!1,m=u.length+ +!!d,h=o??Math.min(e.state.pagination.pageSize,8),g=()=>{switch(l.phase){case`loading`:return i?.LoadingTable?i.LoadingTable():(0,r.jsx)(n.Table.Tbody,{children:Array.from({length:h},(e,t)=>(0,r.jsxs)(n.Table.Tr,{children:[d&&(0,r.jsx)(n.Table.Td,{children:(0,r.jsx)(n.Skeleton,{height:16,width:16})}),u.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)(A,{colSpan:m,children:(0,r.jsx)(f,{view:e,slots:i})});case`empty`:case`empty-filtered`:return(0,r.jsx)(A,{colSpan:m,children:(0,r.jsx)(p,{view:e,slots:i})});default:return(0,r.jsx)(n.Table.Tbody,{children:c.getRowModel().rows.map(e=>{let a=(0,r.jsxs)(r.Fragment,{children:[d&&(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:{...D(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)(k,{children:i.Row({row:e,cells:a})},e.id):(0,r.jsx)(n.Table.Tr,{"data-selected":e.getIsSelected()||void 0,children:a},e.id)})})}};return(0,r.jsx)(`div`,{style:c.getIsSomeColumnsPinned()?{overflowX:`auto`}:void 0,children:(0,r.jsxs)(n.Table,{layout:`fixed`,...s,children:[(0,r.jsx)(n.Table.Thead,{children:c.getHeaderGroups().map(e=>(0,r.jsxs)(n.Table.Tr,{children:[d&&(0,r.jsx)(n.Table.Th,{style:{width:40},children:(0,r.jsx)(n.Checkbox,{"aria-label":`Select all rows on this page`,checked:c.getIsAllPageRowsSelected(),indeterminate:c.getIsSomePageRowsSelected()&&!c.getIsAllPageRowsSelected(),onChange:c.getToggleAllPageRowsSelectedHandler()})}),e.headers.map(e=>(0,r.jsx)(j,{header:e},e.id))]},e.id))}),g()]})})}function k({children:e}){return(0,r.jsx)(r.Fragment,{children:e})}function A({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 j({header:e}){let{column:i}=e,a=i.columnDef.meta?.align,o=i.getIsSorted(),s=i.getSortIndex(),c=s>0,l=e.isPlaceholder?null:(0,t.flexRender)(i.columnDef.header,e.getContext());return(0,r.jsx)(n.Table.Th,{style:{...D(i),...a?{textAlign:a}:void 0},"aria-sort":o===`asc`?`ascending`:o===`desc`?`descending`:void 0,children:i.getCanSort()?(0,r.jsxs)(n.UnstyledButton,{onClick:i.getToggleSortingHandler(),style:{display:`inline-flex`,alignItems:`center`,gap:4,font:`inherit`},children:[l,(0,r.jsx)(y,{direction:o}),c&&(0,r.jsx)(`span`,{role:`note`,style:{fontSize:`0.7em`,opacity:.6},"aria-label":`Sort priority ${s+1}`,children:s+1})]}):l})}var M=`(max-width: 0px)`;function N(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 ee(e){let t=(0,n.useMantineTheme)(),r=e?.forceCardsBelow,i=r?t.breakpoints[r]:void 0,o=(0,a.useMediaQuery)(i?N(i):M,!1);return!!i&&!!o}var P={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 F(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 P[e]}function I(e,t,n){let r=t??n?.[e];return r?typeof r==`function`?r:F(e,r):P[e]}function L({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 R({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 z(e){return e?typeof e==`string`?e:e.toISOString().split(`T`)[0]??null:null}function B(e){return Array.isArray(e)?[e[0],e[1]]:[null,null]}function V(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 H({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?V(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?V(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]=B(l),s=i.min??f?.min,c=i.max??f?.max,d=s!=null&&c!=null,p=l!=null,m=f?(0,r.jsx)(L,{facet:f,value:l,onChange:u}):null,h=p?(0,r.jsx)(R,{label:a,onClear:()=>u(void 0)}):a;if(d){let l=[t??s,o??c],d=e.columnDef.meta?.dataType,f=d?I(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(z(e)??void 0)});case`dateRange`:{let[e,t]=B(l),i=[e?new Date(e):null,t?new Date(t):null],c=l==null?a:(0,r.jsx)(R,{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)(L,{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=z(e),r=z(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 U({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 W(e){return e>0?`Filters (${e})`:`Filters`}function G({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)(U,{view:e})})]})}function te({view:e,inlineThreshold:t}){let i=e.filterableColumns,o=(0,a.useMediaQuery)(N((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)(H,{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:W(d)}),(0,r.jsx)(n.Drawer,{opened:s,onClose:l,title:`Filters`,position:`bottom`,size:`auto`,children:(0,r.jsx)(G,{view:e,controls:u})})]}):i.length<=t?(0,r.jsxs)(r.Fragment,{children:[u,(0,r.jsx)(U,{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:W(d)})}),(0,r.jsx)(n.Popover.Dropdown,{children:(0,r.jsx)(G,{view:e,controls:u})})]})}function ne({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 re({view:e,lockSwitcherOnMobile:t}){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:`Table`},{value:`cards`,label:`Cards`}]})}function K({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)(E,{})})]})}function q({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)(K,{column:e})]},e.id))})})]})}function J({view:e,searchPlaceholder:t=`Search…`,filterInlineThreshold:i=3,lockSwitcherOnMobile:a,showSearch:o,showFilters:s,showSort:c,showVisibility:l,showViewSwitcher:u,...d}){let{table:f,state:p}=e,m=o??f.options.enableGlobalFilter!==!1,h=s??e.filterableColumns.length>0,g=c??e.sortableColumns.length>0,_=l??!0,v=u??!0;return(0,r.jsxs)(n.Group,{justify:`space-between`,wrap:`wrap`,gap:`sm`,...d,children:[(0,r.jsxs)(n.Group,{wrap:`wrap`,gap:`sm`,children:[m&&(0,r.jsx)(n.TextInput,{"aria-label":`Search`,placeholder:t,leftSection:(0,r.jsx)(x,{}),value:p.globalFilter,onChange:e=>f.setGlobalFilter(e.currentTarget.value),rightSection:p.globalFilter?(0,r.jsx)(n.CloseButton,{size:`sm`,"aria-label":`Clear search`,onClick:()=>f.setGlobalFilter(``)}):void 0}),h&&(0,r.jsx)(te,{view:e,inlineThreshold:i}),g&&(0,r.jsx)(ne,{view:e})]}),(0,r.jsxs)(n.Group,{wrap:`wrap`,gap:`sm`,children:[_&&(0,r.jsx)(q,{view:e}),v&&(0,r.jsx)(re,{view:e,lockSwitcherOnMobile:a})]})]})}var Y=(0,i.createContext)(null),ie=Y.Provider;function X(){let e=(0,i.useContext)(Y);if(!e)throw Error(`DataView.Toolbar / DataView.Body / DataView.Pagination must be rendered inside <DataView>.`);return e}function Z({view:e,slots:t,renderCard:a,fallbackRole:o,lockSwitcherOnMobile:s,children:c,...l}){return(0,r.jsx)(ie,{value:(0,i.useMemo)(()=>({view:e,slots:t,renderCard:a,fallbackRole:o,lockSwitcherOnMobile:s}),[e,t,a,o,s]),children:(0,r.jsx)(n.Stack,{...l,children:c??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ae,{}),(0,r.jsx)(ce,{}),(0,r.jsx)(oe,{}),(0,r.jsx)(se,{})]})})})}function ae(e){let{view:t,lockSwitcherOnMobile:n}=X();return(0,r.jsx)(J,{view:t,lockSwitcherOnMobile:n,...e})}function oe({tableProps:e,cardsProps:t}){let{view:n,slots:i,renderCard:a,fallbackRole:o}=X();return n.view===`cards`?(0,r.jsx)(h,{view:n,slots:i,renderCard:a,fallbackRole:o,...t}):(0,r.jsx)(O,{view:n,slots:i,...e})}function se(e){let{view:t}=X();return(0,r.jsx)(v,{view:t,...e})}function ce(e){let{view:t,slots:n}=X();return(0,r.jsx)(s,{view:t,slots:n,...e})}Z.Toolbar=ae,Z.BulkActions=ce,Z.Body=oe,Z.Pagination=se;function Q(e){let t=e==null?``:String(e);return t.includes(`,`)||t.includes(`"`)||t.includes(`
|
|
2
|
+
`)?`"${t.replace(/"/g,`""`)}"`:t}function le(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(I(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 ue(t){return t?{adapter:t.adapter,serializer:{...e.t,...t.serialize},include:e.r(t.include)}:null}function de(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 fe({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 pe(e){return e.columnFilters.length>0||e.globalFilter.trim()!==``}function me({status:e,error:t,pageRowCount:n,state:r}){return e===`error`?{phase:`error`,error:t}:e===`loading`||e===`idle`?{phase:`loading`}:n===0?pe(r)?{phase:`empty-filtered`}:{phase:`empty`}:{phase:`ready`}}var $=300,he=[10,25,50,100],ge=10;function _e(e){return e==null?{globalFilter:$,columnFilters:$}:typeof e==`number`?{globalFilter:e,columnFilters:e}:{globalFilter:e.globalFilter??$,columnFilters:e.columnFilters??$}}function ve(e){if(e.id)return e.id;if(`accessorKey`in e&&e.accessorKey!=null)return String(e.accessorKey)}function ye(e){let t=new Map;for(let n of e){let e=ve(n),r=n.meta?.filter;e&&r&&t.set(e,r)}return e=>t.get(e)}function be(e){return{pagination:{pageIndex:0,pageSize:e.pageSizeOptions?.[0]??ge},sorting:[],columnFilters:[],globalFilter:``,rowSelection:{},columnVisibility:{},columnPinning:{left:[],right:[]},view:e.defaultView??`table`,...e.initialState}}function xe(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:_}=e,v=_??{},y=(0,i.useMemo)(()=>n.map(e=>{let t=e.meta?.dataType;if(!t||e.cell)return e;let n=I(t,e.meta?.format,g);return{...e,cell:e=>n(e.getValue())}}),[n,g]),b=(0,i.useMemo)(()=>ye(y),[y]),x=(0,i.useMemo)(()=>ue(e.urlSync),[e.urlSync]),[S,C]=(0,i.useState)(()=>{let t=be(e);return{...t,...de(x,t,b)}}),w=(0,i.useMemo)(()=>({...S,...u}),[S,u]),T=(0,i.useRef)(w);T.current=w;let E=(0,i.useCallback)(e=>{C(t=>({...t,...e})),d?.({...T.current,...e})},[d]);fe({config:x,state:w,applyPatch:E,getFilterMeta:b});let D=(0,i.useCallback)(()=>({...T.current.pagination,pageIndex:0}),[]),O=(0,i.useCallback)(e=>{E({pagination:(0,t.functionalUpdate)(e,T.current.pagination)})},[E]),k=(0,i.useCallback)(e=>{E({sorting:(0,t.functionalUpdate)(e,T.current.sorting),pagination:D()})},[E,D]),A=(0,i.useCallback)(e=>{E({columnFilters:(0,t.functionalUpdate)(e,T.current.columnFilters),pagination:D()})},[E,D]),j=(0,i.useCallback)(e=>{E({globalFilter:(0,t.functionalUpdate)(e,T.current.globalFilter),pagination:D()})},[E,D]),M=(0,i.useCallback)(e=>{E({rowSelection:(0,t.functionalUpdate)(e,T.current.rowSelection)})},[E]),N=(0,i.useCallback)(e=>{E({columnVisibility:(0,t.functionalUpdate)(e,T.current.columnVisibility)})},[E]),P=(0,i.useCallback)(e=>{E({columnPinning:(0,t.functionalUpdate)(e,T.current.columnPinning)})},[E]),F=(0,t.useReactTable)({data:r,columns:y,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:w.pagination,sorting:w.sorting,columnFilters:w.columnFilters,globalFilter:w.globalFilter,rowSelection:w.rowSelection,columnVisibility:w.columnVisibility,columnPinning:w.columnPinning},onPaginationChange:O,onSortingChange:k,onColumnFiltersChange:A,onGlobalFilterChange:j,onRowSelectionChange:M,onColumnVisibilityChange:N,onColumnPinningChange:P}),L=(0,i.useMemo)(()=>({pagination:w.pagination,sorting:w.sorting,filters:w.columnFilters,globalFilter:w.globalFilter}),[w.pagination,w.sorting,w.columnFilters,w.globalFilter]),R=(0,i.useRef)(l);R.current=l;let z=(0,i.useRef)(_e(m));z.current=_e(m);let B=(0,i.useRef)(null),V=(0,i.useRef)(void 0);(0,i.useEffect)(()=>{let e=B.current,t=e===null,n=!e||e.globalFilter!==L.globalFilter,r=!e||e.filters!==L.filters,i=()=>{B.current=L,R.current?.(L)},a=0;n&&(a=Math.max(a,z.current.globalFilter)),r&&(a=Math.max(a,z.current.columnFilters));let o=!t&&(n||r)&&a>0;return clearTimeout(V.current),o?V.current=setTimeout(i,a):i(),()=>clearTimeout(V.current)},[L]);let H=(0,i.useRef)(L);H.current=L;let U=(0,i.useCallback)(()=>{R.current?.(H.current)},[]),W=(0,i.useMemo)(()=>me({status:o,error:s,pageRowCount:r.length,state:w}),[o,s,r.length,w]),G=ee(h),te=G?`cards`:w.view,ne=(0,i.useCallback)(e=>E({view:e}),[E]),re=e.pageSizeOptions??he,K=F.getAllColumns(),q=K.filter(e=>e.getCanSort()),J=K.filter(e=>e.columnDef.meta?.filter!=null),Y=(0,i.useCallback)(()=>E({rowSelection:{}}),[E]);return{table:F,request:L,state:w,view:te,setView:ne,isMobileForced:G,status:o,error:s,renderStatus:W,refetch:U,pageSizeOptions:re,sortableColumns:q,filterableColumns:J,selection:(0,i.useMemo)(()=>{let e=w.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:Y}},[w.rowSelection,r,c,Y]),exportCsv:(0,i.useCallback)(e=>le(F,e),[F]),facets:v}}function Se({fetcher:e,...t}){let[n,r]=(0,i.useState)({rows:[],rowCount:0}),[a,o]=(0,i.useState)(`idle`),[s,c]=(0,i.useState)(void 0),l=(0,i.useRef)(e);l.current=e;let u=(0,i.useRef)(0),d=(0,i.useCallback)(async e=>{let t=++u.current;o(`loading`);try{let n=await l.current(e);t===u.current&&(r(n),c(void 0),o(`success`))}catch(e){t===u.current&&(c(e),o(`error`))}},[]);return xe({...t,rows:n.rows,rowCount:n.rowCount,facets:n.facets,status:a,error:s,onRequestChange:d})}exports.DataBulkActions=s,exports.DataCards=h,exports.DataPagination=v,exports.DataTable=O,exports.DataToolbar=J,exports.DataView=Z,exports.FilterControl=H,exports.composeCardLayout=u,Object.defineProperty(exports,"createColumnHelper",{enumerable:!0,get:function(){return t.createColumnHelper}}),exports.exportCsv=le,exports.resolveColumnLabel=c,exports.useDataView=xe,exports.useDataViewContext=X,exports.useDataViewFetcher=Se;
|
|
4
|
+
//# sourceMappingURL=index.cjs.map
|