@nexgrid/react 0.1.0 → 0.2.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/README.md +41 -37
- package/dist/index.cjs +857 -303
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +93 -30
- package/dist/index.d.ts +93 -30
- package/dist/index.js +863 -306
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/styles.css +1555 -411
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { ClientQueryOptions, DEFAULT_LOCALE, DEFAULT_PAGE_SIZE, Density, ExcelBadgeRule, NexGridCellContext, NexGridColumn, NexGridColumnMeta, NexGridLocale, PAGE_SIZES, PageSize, PagedResponse, QueryState, SortDir, SortSpec, buildODataUrl, buildQueryUrl, defaultQuery, fromODataResponse, isPageSize, parseQuery, primarySort, queryClientData, resolveLocale, serializeQuery, toODataParams, totalPagesFor, withFilter, withPage, withPageSize, withSearch, withSort, withToggledSort } from '@nexgrid/core';
|
|
3
|
+
import { TableXColumn, QueryState, Density, ExcelBadgeRule, TableXLocale, ClientQueryOptions } from '@nexgrid/core';
|
|
4
|
+
export { ClientQueryOptions, DEFAULT_LOCALE, DEFAULT_PAGE_SIZE, Density, ExcelBadgeRule, NexGridCellContext, NexGridColumn, NexGridColumnMeta, NexGridLocale, PAGE_SIZES, PageSize, PagedResponse, QueryState, SortDir, SortSpec, TableXCellContext, TableXColumn, TableXColumnMeta, TableXLocale, buildODataUrl, buildQueryUrl, defaultQuery, fromODataResponse, isPageSize, parseQuery, primarySort, queryClientData, resolveLocale, serializeQuery, toODataParams, totalPagesFor, withFilter, withPage, withPageSize, withSearch, withSort, withToggledMultiSort, withToggledSort } from '@nexgrid/core';
|
|
5
5
|
|
|
6
6
|
/** A column definition bound to React's render type. */
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
type TableXReactColumn<TData> = TableXColumn<TData, ReactNode>;
|
|
8
|
+
type NexGridReactColumn<TData> = TableXReactColumn<TData>;
|
|
9
|
+
/** Severity of a {@link TableXNotice}. */
|
|
10
|
+
type TableXNoticeType = "info" | "success" | "error";
|
|
11
|
+
type NexGridNoticeType = TableXNoticeType;
|
|
10
12
|
/**
|
|
11
13
|
* A message the grid wants surfaced to the user.
|
|
12
14
|
*
|
|
@@ -14,23 +16,25 @@ type NexGridNoticeType = "info" | "success" | "error";
|
|
|
14
16
|
* design system, and two competing toast stacks in one page is a worse bug
|
|
15
17
|
* than no toast at all. Everything it would want to say arrives here instead.
|
|
16
18
|
*/
|
|
17
|
-
interface
|
|
18
|
-
type:
|
|
19
|
+
interface TableXNotice {
|
|
20
|
+
type: TableXNoticeType;
|
|
19
21
|
message: string;
|
|
20
22
|
}
|
|
23
|
+
type NexGridNotice = TableXNotice;
|
|
21
24
|
/** Color scheme applied to the grid root. */
|
|
22
|
-
type
|
|
25
|
+
type TableXTheme = "light" | "dark" | "auto";
|
|
26
|
+
type NexGridTheme = TableXTheme;
|
|
23
27
|
/**
|
|
24
|
-
* Props for {@link
|
|
28
|
+
* Props for {@link TableX}.
|
|
25
29
|
*
|
|
26
30
|
* `data` / `total` / `query` / `onQueryChange` are **controlled**: the grid
|
|
27
31
|
* renders exactly the page it is handed and reports intent back through
|
|
28
32
|
* `onQueryChange`. It never fetches on its own (the one exception is the
|
|
29
33
|
* export-everything path, which needs rows the current page does not have).
|
|
30
34
|
*/
|
|
31
|
-
interface
|
|
35
|
+
interface TableXProps<TData> {
|
|
32
36
|
/** Column definitions, in display order. */
|
|
33
|
-
columns:
|
|
37
|
+
columns: TableXReactColumn<TData>[];
|
|
34
38
|
/** The CURRENT page of rows only — never the full dataset. */
|
|
35
39
|
data: TData[];
|
|
36
40
|
/** Total filtered row count from the server; drives the pager. */
|
|
@@ -51,6 +55,12 @@ interface NexGridProps<TData> {
|
|
|
51
55
|
onRetry?: () => void;
|
|
52
56
|
/** Render selection checkboxes. Default `false`. */
|
|
53
57
|
enableSelection?: boolean;
|
|
58
|
+
/** Selection mode: `"multi"` (default) or `"single"`. */
|
|
59
|
+
selectionMode?: "multi" | "single";
|
|
60
|
+
/** Enable column-level filter menus on column headers. Default `false` (or per-column). */
|
|
61
|
+
enableColumnFilters?: boolean;
|
|
62
|
+
/** Enable dragging column borders to resize columns. Default `true`. */
|
|
63
|
+
enableColumnResize?: boolean;
|
|
54
64
|
/**
|
|
55
65
|
* Called with every selected row id after each change.
|
|
56
66
|
* `allAcrossSelected` is reserved for a future "select all matching rows"
|
|
@@ -61,6 +71,55 @@ interface NexGridProps<TData> {
|
|
|
61
71
|
enableSearch?: boolean;
|
|
62
72
|
/** Overrides `locale.searchPlaceholder`. */
|
|
63
73
|
searchPlaceholder?: string;
|
|
74
|
+
/** Show the columns toggle dropdown menu button. Default `true`. */
|
|
75
|
+
enableColumns?: boolean;
|
|
76
|
+
/** Alias for enableColumns. */
|
|
77
|
+
showColumnsButton?: boolean;
|
|
78
|
+
/** Show the density dropdown menu button. Default `true`. */
|
|
79
|
+
enableDensity?: boolean;
|
|
80
|
+
/** Alias for enableDensity. */
|
|
81
|
+
showDensityButton?: boolean;
|
|
82
|
+
/** Show the export menu. Default `true`. */
|
|
83
|
+
enableExport?: boolean;
|
|
84
|
+
/** Alias for enableExport. */
|
|
85
|
+
showExportButton?: boolean;
|
|
86
|
+
/** Enable sorting across all columns. Default `true`. */
|
|
87
|
+
enableSorting?: boolean;
|
|
88
|
+
/** Show the footer pagination controls. Default `true`. */
|
|
89
|
+
enablePagination?: boolean;
|
|
90
|
+
/** Alias for enablePagination. */
|
|
91
|
+
showPagination?: boolean;
|
|
92
|
+
/** Show the rows-per-page dropdown in the footer. Default `true`. */
|
|
93
|
+
enableRowsPerPage?: boolean;
|
|
94
|
+
/** Alias for enableRowsPerPage. */
|
|
95
|
+
showRowsPerPage?: boolean;
|
|
96
|
+
/** Show the jump to page input in the footer. Default `true`. */
|
|
97
|
+
enableJumpToPage?: boolean;
|
|
98
|
+
/** Alias for enableJumpToPage. */
|
|
99
|
+
showJumpToPage?: boolean;
|
|
100
|
+
/** Show the entire toolbar area. Default `true`. */
|
|
101
|
+
showToolbar?: boolean;
|
|
102
|
+
/** Show the entire footer area. Default `true`. */
|
|
103
|
+
showFooter?: boolean;
|
|
104
|
+
/** Custom renderer for expanded accordion sub-rows. */
|
|
105
|
+
renderExpandedRow?: (row: TData) => ReactNode;
|
|
106
|
+
/** Enable floating bulk actions bar when rows are selected. Default `true`. */
|
|
107
|
+
enableBulkActions?: boolean;
|
|
108
|
+
/** Custom bulk actions renderer receiving selected IDs. */
|
|
109
|
+
bulkActions?: (selectedIds: string[], deselectAll: () => void) => ReactNode;
|
|
110
|
+
/** Enable summary / aggregation footer row. Default auto (true if any column defines meta.aggregation). */
|
|
111
|
+
enableSummaryRow?: boolean;
|
|
112
|
+
/** Enable drag-and-drop column header reordering. Default `false`. */
|
|
113
|
+
enableColumnReorder?: boolean;
|
|
114
|
+
/** Called when column order changes via drag-and-drop reordering. */
|
|
115
|
+
onColumnOrderChange?: (newOrder: string[]) => void;
|
|
116
|
+
/** Called when a cell's value is committed via inline cell editing. */
|
|
117
|
+
onCellEdit?: (edit: {
|
|
118
|
+
row: TData;
|
|
119
|
+
columnId: string;
|
|
120
|
+
oldValue: unknown;
|
|
121
|
+
newValue: unknown;
|
|
122
|
+
}) => void;
|
|
64
123
|
/** Rendered at the end of the toolbar, after the export menu. */
|
|
65
124
|
toolbarActions?: ReactNode;
|
|
66
125
|
/** Clicking a row (or a card) invokes this. Adds a pointer cursor. */
|
|
@@ -71,26 +130,27 @@ interface NexGridProps<TData> {
|
|
|
71
130
|
className?: string;
|
|
72
131
|
/** Show the automatic `S.No.` column. Default `true`. */
|
|
73
132
|
showSerialNumber?: boolean;
|
|
74
|
-
/** Show the export menu. Default `true`. */
|
|
75
|
-
enableExport?: boolean;
|
|
76
133
|
/** File name prefix, without extension. Default: the caption, lower-cased and underscored. */
|
|
77
134
|
exportFileName?: string;
|
|
78
135
|
/** Take over exporting entirely; when set, the grid's own export flow never runs. */
|
|
79
136
|
onExportAll?: () => void | Promise<void>;
|
|
80
137
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
138
|
+
* Endpoint used to fetch the full filtered dataset for export when the current
|
|
139
|
+
* page is only part of it.
|
|
83
140
|
*/
|
|
84
141
|
fetchEndpoint?: string;
|
|
85
|
-
/**
|
|
142
|
+
/** Extra fetch options (headers, etc.) forwarded when calling {@link fetchEndpoint}. */
|
|
143
|
+
fetchOptions?: RequestInit;
|
|
144
|
+
/** Value-based badge styling rules for Excel export. */
|
|
86
145
|
badgeRules?: readonly ExcelBadgeRule[];
|
|
87
|
-
/** Overrides for any user-facing string. */
|
|
88
|
-
locale?: Partial<
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
|
|
146
|
+
/** Overrides for any user-facing string in the grid. */
|
|
147
|
+
locale?: Partial<TableXLocale>;
|
|
148
|
+
/** Visual theme. Default `"light"`. */
|
|
149
|
+
theme?: TableXTheme;
|
|
150
|
+
/** Receives notices (export progress, failures). Default: no-op. */
|
|
151
|
+
onNotify?: (notice: TableXNotice) => void;
|
|
93
152
|
}
|
|
153
|
+
type NexGridProps<TData> = TableXProps<TData>;
|
|
94
154
|
|
|
95
155
|
/**
|
|
96
156
|
* A server-driven data grid: search, sorting, column visibility, density,
|
|
@@ -98,7 +158,7 @@ interface NexGridProps<TData> {
|
|
|
98
158
|
*
|
|
99
159
|
* `data`, `total`, `query` and `onQueryChange` are controlled by the host — the
|
|
100
160
|
* grid renders the page it is given and never fetches on its own (the one
|
|
101
|
-
* exception being {@link
|
|
161
|
+
* exception being {@link TableXProps.fetchEndpoint}, used to page in the rest
|
|
102
162
|
* of the dataset for an export).
|
|
103
163
|
*
|
|
104
164
|
* @example
|
|
@@ -114,13 +174,15 @@ interface NexGridProps<TData> {
|
|
|
114
174
|
* />
|
|
115
175
|
* ```
|
|
116
176
|
*/
|
|
117
|
-
declare function
|
|
177
|
+
declare function TableX<TData>(props: TableXProps<TData>): react.JSX.Element;
|
|
178
|
+
declare const NexGrid: typeof TableX;
|
|
118
179
|
|
|
119
|
-
/** Options for {@link
|
|
120
|
-
interface
|
|
180
|
+
/** Options for {@link useClientTableX}. */
|
|
181
|
+
interface UseClientTableXOptions<TData> extends ClientQueryOptions<TData> {
|
|
121
182
|
/** Optional initial query state overrides. */
|
|
122
183
|
initialQuery?: Partial<QueryState>;
|
|
123
184
|
}
|
|
185
|
+
type UseClientNexGridOptions<TData> = UseClientTableXOptions<TData>;
|
|
124
186
|
/**
|
|
125
187
|
* React hook for effortless in-memory client-side grid operations.
|
|
126
188
|
*
|
|
@@ -130,10 +192,10 @@ interface UseClientNexGridOptions<TData> extends ClientQueryOptions<TData> {
|
|
|
130
192
|
* @example
|
|
131
193
|
* ```tsx
|
|
132
194
|
* export function StudentsGrid({ allStudents }: { allStudents: Student[] }) {
|
|
133
|
-
* const grid =
|
|
195
|
+
* const grid = useClientTableX(allStudents);
|
|
134
196
|
*
|
|
135
197
|
* return (
|
|
136
|
-
* <
|
|
198
|
+
* <TableX
|
|
137
199
|
* caption="Students"
|
|
138
200
|
* columns={columns}
|
|
139
201
|
* {...grid}
|
|
@@ -142,7 +204,7 @@ interface UseClientNexGridOptions<TData> extends ClientQueryOptions<TData> {
|
|
|
142
204
|
* }
|
|
143
205
|
* ```
|
|
144
206
|
*/
|
|
145
|
-
declare function
|
|
207
|
+
declare function useClientTableX<TData>(allData: readonly TData[], options?: UseClientTableXOptions<TData>): {
|
|
146
208
|
data: TData[];
|
|
147
209
|
total: number;
|
|
148
210
|
query: QueryState;
|
|
@@ -152,5 +214,6 @@ declare function useClientNexGrid<TData>(allData: readonly TData[], options?: Us
|
|
|
152
214
|
totalPages: number;
|
|
153
215
|
setQuery: react.Dispatch<react.SetStateAction<QueryState>>;
|
|
154
216
|
};
|
|
217
|
+
declare const useClientNexGrid: typeof useClientTableX;
|
|
155
218
|
|
|
156
|
-
export { NexGrid, type NexGridNotice, type NexGridNoticeType, type NexGridProps, type NexGridReactColumn, type NexGridTheme, type UseClientNexGridOptions, useClientNexGrid };
|
|
219
|
+
export { NexGrid, type NexGridNotice, type NexGridNoticeType, type NexGridProps, type NexGridReactColumn, type NexGridTheme, TableX, type TableXNotice, type TableXNoticeType, type TableXProps, type TableXReactColumn, type TableXTheme, type UseClientNexGridOptions, type UseClientTableXOptions, useClientNexGrid, useClientTableX };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { ClientQueryOptions, DEFAULT_LOCALE, DEFAULT_PAGE_SIZE, Density, ExcelBadgeRule, NexGridCellContext, NexGridColumn, NexGridColumnMeta, NexGridLocale, PAGE_SIZES, PageSize, PagedResponse, QueryState, SortDir, SortSpec, buildODataUrl, buildQueryUrl, defaultQuery, fromODataResponse, isPageSize, parseQuery, primarySort, queryClientData, resolveLocale, serializeQuery, toODataParams, totalPagesFor, withFilter, withPage, withPageSize, withSearch, withSort, withToggledSort } from '@nexgrid/core';
|
|
3
|
+
import { TableXColumn, QueryState, Density, ExcelBadgeRule, TableXLocale, ClientQueryOptions } from '@nexgrid/core';
|
|
4
|
+
export { ClientQueryOptions, DEFAULT_LOCALE, DEFAULT_PAGE_SIZE, Density, ExcelBadgeRule, NexGridCellContext, NexGridColumn, NexGridColumnMeta, NexGridLocale, PAGE_SIZES, PageSize, PagedResponse, QueryState, SortDir, SortSpec, TableXCellContext, TableXColumn, TableXColumnMeta, TableXLocale, buildODataUrl, buildQueryUrl, defaultQuery, fromODataResponse, isPageSize, parseQuery, primarySort, queryClientData, resolveLocale, serializeQuery, toODataParams, totalPagesFor, withFilter, withPage, withPageSize, withSearch, withSort, withToggledMultiSort, withToggledSort } from '@nexgrid/core';
|
|
5
5
|
|
|
6
6
|
/** A column definition bound to React's render type. */
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
type TableXReactColumn<TData> = TableXColumn<TData, ReactNode>;
|
|
8
|
+
type NexGridReactColumn<TData> = TableXReactColumn<TData>;
|
|
9
|
+
/** Severity of a {@link TableXNotice}. */
|
|
10
|
+
type TableXNoticeType = "info" | "success" | "error";
|
|
11
|
+
type NexGridNoticeType = TableXNoticeType;
|
|
10
12
|
/**
|
|
11
13
|
* A message the grid wants surfaced to the user.
|
|
12
14
|
*
|
|
@@ -14,23 +16,25 @@ type NexGridNoticeType = "info" | "success" | "error";
|
|
|
14
16
|
* design system, and two competing toast stacks in one page is a worse bug
|
|
15
17
|
* than no toast at all. Everything it would want to say arrives here instead.
|
|
16
18
|
*/
|
|
17
|
-
interface
|
|
18
|
-
type:
|
|
19
|
+
interface TableXNotice {
|
|
20
|
+
type: TableXNoticeType;
|
|
19
21
|
message: string;
|
|
20
22
|
}
|
|
23
|
+
type NexGridNotice = TableXNotice;
|
|
21
24
|
/** Color scheme applied to the grid root. */
|
|
22
|
-
type
|
|
25
|
+
type TableXTheme = "light" | "dark" | "auto";
|
|
26
|
+
type NexGridTheme = TableXTheme;
|
|
23
27
|
/**
|
|
24
|
-
* Props for {@link
|
|
28
|
+
* Props for {@link TableX}.
|
|
25
29
|
*
|
|
26
30
|
* `data` / `total` / `query` / `onQueryChange` are **controlled**: the grid
|
|
27
31
|
* renders exactly the page it is handed and reports intent back through
|
|
28
32
|
* `onQueryChange`. It never fetches on its own (the one exception is the
|
|
29
33
|
* export-everything path, which needs rows the current page does not have).
|
|
30
34
|
*/
|
|
31
|
-
interface
|
|
35
|
+
interface TableXProps<TData> {
|
|
32
36
|
/** Column definitions, in display order. */
|
|
33
|
-
columns:
|
|
37
|
+
columns: TableXReactColumn<TData>[];
|
|
34
38
|
/** The CURRENT page of rows only — never the full dataset. */
|
|
35
39
|
data: TData[];
|
|
36
40
|
/** Total filtered row count from the server; drives the pager. */
|
|
@@ -51,6 +55,12 @@ interface NexGridProps<TData> {
|
|
|
51
55
|
onRetry?: () => void;
|
|
52
56
|
/** Render selection checkboxes. Default `false`. */
|
|
53
57
|
enableSelection?: boolean;
|
|
58
|
+
/** Selection mode: `"multi"` (default) or `"single"`. */
|
|
59
|
+
selectionMode?: "multi" | "single";
|
|
60
|
+
/** Enable column-level filter menus on column headers. Default `false` (or per-column). */
|
|
61
|
+
enableColumnFilters?: boolean;
|
|
62
|
+
/** Enable dragging column borders to resize columns. Default `true`. */
|
|
63
|
+
enableColumnResize?: boolean;
|
|
54
64
|
/**
|
|
55
65
|
* Called with every selected row id after each change.
|
|
56
66
|
* `allAcrossSelected` is reserved for a future "select all matching rows"
|
|
@@ -61,6 +71,55 @@ interface NexGridProps<TData> {
|
|
|
61
71
|
enableSearch?: boolean;
|
|
62
72
|
/** Overrides `locale.searchPlaceholder`. */
|
|
63
73
|
searchPlaceholder?: string;
|
|
74
|
+
/** Show the columns toggle dropdown menu button. Default `true`. */
|
|
75
|
+
enableColumns?: boolean;
|
|
76
|
+
/** Alias for enableColumns. */
|
|
77
|
+
showColumnsButton?: boolean;
|
|
78
|
+
/** Show the density dropdown menu button. Default `true`. */
|
|
79
|
+
enableDensity?: boolean;
|
|
80
|
+
/** Alias for enableDensity. */
|
|
81
|
+
showDensityButton?: boolean;
|
|
82
|
+
/** Show the export menu. Default `true`. */
|
|
83
|
+
enableExport?: boolean;
|
|
84
|
+
/** Alias for enableExport. */
|
|
85
|
+
showExportButton?: boolean;
|
|
86
|
+
/** Enable sorting across all columns. Default `true`. */
|
|
87
|
+
enableSorting?: boolean;
|
|
88
|
+
/** Show the footer pagination controls. Default `true`. */
|
|
89
|
+
enablePagination?: boolean;
|
|
90
|
+
/** Alias for enablePagination. */
|
|
91
|
+
showPagination?: boolean;
|
|
92
|
+
/** Show the rows-per-page dropdown in the footer. Default `true`. */
|
|
93
|
+
enableRowsPerPage?: boolean;
|
|
94
|
+
/** Alias for enableRowsPerPage. */
|
|
95
|
+
showRowsPerPage?: boolean;
|
|
96
|
+
/** Show the jump to page input in the footer. Default `true`. */
|
|
97
|
+
enableJumpToPage?: boolean;
|
|
98
|
+
/** Alias for enableJumpToPage. */
|
|
99
|
+
showJumpToPage?: boolean;
|
|
100
|
+
/** Show the entire toolbar area. Default `true`. */
|
|
101
|
+
showToolbar?: boolean;
|
|
102
|
+
/** Show the entire footer area. Default `true`. */
|
|
103
|
+
showFooter?: boolean;
|
|
104
|
+
/** Custom renderer for expanded accordion sub-rows. */
|
|
105
|
+
renderExpandedRow?: (row: TData) => ReactNode;
|
|
106
|
+
/** Enable floating bulk actions bar when rows are selected. Default `true`. */
|
|
107
|
+
enableBulkActions?: boolean;
|
|
108
|
+
/** Custom bulk actions renderer receiving selected IDs. */
|
|
109
|
+
bulkActions?: (selectedIds: string[], deselectAll: () => void) => ReactNode;
|
|
110
|
+
/** Enable summary / aggregation footer row. Default auto (true if any column defines meta.aggregation). */
|
|
111
|
+
enableSummaryRow?: boolean;
|
|
112
|
+
/** Enable drag-and-drop column header reordering. Default `false`. */
|
|
113
|
+
enableColumnReorder?: boolean;
|
|
114
|
+
/** Called when column order changes via drag-and-drop reordering. */
|
|
115
|
+
onColumnOrderChange?: (newOrder: string[]) => void;
|
|
116
|
+
/** Called when a cell's value is committed via inline cell editing. */
|
|
117
|
+
onCellEdit?: (edit: {
|
|
118
|
+
row: TData;
|
|
119
|
+
columnId: string;
|
|
120
|
+
oldValue: unknown;
|
|
121
|
+
newValue: unknown;
|
|
122
|
+
}) => void;
|
|
64
123
|
/** Rendered at the end of the toolbar, after the export menu. */
|
|
65
124
|
toolbarActions?: ReactNode;
|
|
66
125
|
/** Clicking a row (or a card) invokes this. Adds a pointer cursor. */
|
|
@@ -71,26 +130,27 @@ interface NexGridProps<TData> {
|
|
|
71
130
|
className?: string;
|
|
72
131
|
/** Show the automatic `S.No.` column. Default `true`. */
|
|
73
132
|
showSerialNumber?: boolean;
|
|
74
|
-
/** Show the export menu. Default `true`. */
|
|
75
|
-
enableExport?: boolean;
|
|
76
133
|
/** File name prefix, without extension. Default: the caption, lower-cased and underscored. */
|
|
77
134
|
exportFileName?: string;
|
|
78
135
|
/** Take over exporting entirely; when set, the grid's own export flow never runs. */
|
|
79
136
|
onExportAll?: () => void | Promise<void>;
|
|
80
137
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
138
|
+
* Endpoint used to fetch the full filtered dataset for export when the current
|
|
139
|
+
* page is only part of it.
|
|
83
140
|
*/
|
|
84
141
|
fetchEndpoint?: string;
|
|
85
|
-
/**
|
|
142
|
+
/** Extra fetch options (headers, etc.) forwarded when calling {@link fetchEndpoint}. */
|
|
143
|
+
fetchOptions?: RequestInit;
|
|
144
|
+
/** Value-based badge styling rules for Excel export. */
|
|
86
145
|
badgeRules?: readonly ExcelBadgeRule[];
|
|
87
|
-
/** Overrides for any user-facing string. */
|
|
88
|
-
locale?: Partial<
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
|
|
146
|
+
/** Overrides for any user-facing string in the grid. */
|
|
147
|
+
locale?: Partial<TableXLocale>;
|
|
148
|
+
/** Visual theme. Default `"light"`. */
|
|
149
|
+
theme?: TableXTheme;
|
|
150
|
+
/** Receives notices (export progress, failures). Default: no-op. */
|
|
151
|
+
onNotify?: (notice: TableXNotice) => void;
|
|
93
152
|
}
|
|
153
|
+
type NexGridProps<TData> = TableXProps<TData>;
|
|
94
154
|
|
|
95
155
|
/**
|
|
96
156
|
* A server-driven data grid: search, sorting, column visibility, density,
|
|
@@ -98,7 +158,7 @@ interface NexGridProps<TData> {
|
|
|
98
158
|
*
|
|
99
159
|
* `data`, `total`, `query` and `onQueryChange` are controlled by the host — the
|
|
100
160
|
* grid renders the page it is given and never fetches on its own (the one
|
|
101
|
-
* exception being {@link
|
|
161
|
+
* exception being {@link TableXProps.fetchEndpoint}, used to page in the rest
|
|
102
162
|
* of the dataset for an export).
|
|
103
163
|
*
|
|
104
164
|
* @example
|
|
@@ -114,13 +174,15 @@ interface NexGridProps<TData> {
|
|
|
114
174
|
* />
|
|
115
175
|
* ```
|
|
116
176
|
*/
|
|
117
|
-
declare function
|
|
177
|
+
declare function TableX<TData>(props: TableXProps<TData>): react.JSX.Element;
|
|
178
|
+
declare const NexGrid: typeof TableX;
|
|
118
179
|
|
|
119
|
-
/** Options for {@link
|
|
120
|
-
interface
|
|
180
|
+
/** Options for {@link useClientTableX}. */
|
|
181
|
+
interface UseClientTableXOptions<TData> extends ClientQueryOptions<TData> {
|
|
121
182
|
/** Optional initial query state overrides. */
|
|
122
183
|
initialQuery?: Partial<QueryState>;
|
|
123
184
|
}
|
|
185
|
+
type UseClientNexGridOptions<TData> = UseClientTableXOptions<TData>;
|
|
124
186
|
/**
|
|
125
187
|
* React hook for effortless in-memory client-side grid operations.
|
|
126
188
|
*
|
|
@@ -130,10 +192,10 @@ interface UseClientNexGridOptions<TData> extends ClientQueryOptions<TData> {
|
|
|
130
192
|
* @example
|
|
131
193
|
* ```tsx
|
|
132
194
|
* export function StudentsGrid({ allStudents }: { allStudents: Student[] }) {
|
|
133
|
-
* const grid =
|
|
195
|
+
* const grid = useClientTableX(allStudents);
|
|
134
196
|
*
|
|
135
197
|
* return (
|
|
136
|
-
* <
|
|
198
|
+
* <TableX
|
|
137
199
|
* caption="Students"
|
|
138
200
|
* columns={columns}
|
|
139
201
|
* {...grid}
|
|
@@ -142,7 +204,7 @@ interface UseClientNexGridOptions<TData> extends ClientQueryOptions<TData> {
|
|
|
142
204
|
* }
|
|
143
205
|
* ```
|
|
144
206
|
*/
|
|
145
|
-
declare function
|
|
207
|
+
declare function useClientTableX<TData>(allData: readonly TData[], options?: UseClientTableXOptions<TData>): {
|
|
146
208
|
data: TData[];
|
|
147
209
|
total: number;
|
|
148
210
|
query: QueryState;
|
|
@@ -152,5 +214,6 @@ declare function useClientNexGrid<TData>(allData: readonly TData[], options?: Us
|
|
|
152
214
|
totalPages: number;
|
|
153
215
|
setQuery: react.Dispatch<react.SetStateAction<QueryState>>;
|
|
154
216
|
};
|
|
217
|
+
declare const useClientNexGrid: typeof useClientTableX;
|
|
155
218
|
|
|
156
|
-
export { NexGrid, type NexGridNotice, type NexGridNoticeType, type NexGridProps, type NexGridReactColumn, type NexGridTheme, type UseClientNexGridOptions, useClientNexGrid };
|
|
219
|
+
export { NexGrid, type NexGridNotice, type NexGridNoticeType, type NexGridProps, type NexGridReactColumn, type NexGridTheme, TableX, type TableXNotice, type TableXNoticeType, type TableXProps, type TableXReactColumn, type TableXTheme, type UseClientNexGridOptions, type UseClientTableXOptions, useClientNexGrid, useClientTableX };
|