@tint-ui/data-table 0.3.8 → 0.3.9
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/cjs/use-data-table.js +13 -13
- package/package.json +1 -1
- package/types.d.ts +5 -2
- package/use-data-table.js +12 -11
package/cjs/use-data-table.js
CHANGED
|
@@ -200,7 +200,7 @@ const useDataTable = function (props) {
|
|
|
200
200
|
onRowClick,
|
|
201
201
|
toolbar: toolbarProp,
|
|
202
202
|
navbar: navbarProp,
|
|
203
|
-
options
|
|
203
|
+
options = null
|
|
204
204
|
} = props;
|
|
205
205
|
const {
|
|
206
206
|
name,
|
|
@@ -706,17 +706,8 @@ const useDataTable = function (props) {
|
|
|
706
706
|
const {
|
|
707
707
|
pagination
|
|
708
708
|
} = state;
|
|
709
|
-
const tableCtx = (0, _reactTable.useReactTable)(Object.assign({
|
|
710
|
-
data,
|
|
711
|
-
columns,
|
|
709
|
+
const tableCtx = (0, _reactTable.useReactTable)(Object.assign({}, options, {
|
|
712
710
|
pageCount: manual ? state.pageCount : undefined,
|
|
713
|
-
state: {
|
|
714
|
-
columnVisibility,
|
|
715
|
-
sorting: state.sorting,
|
|
716
|
-
globalFilter: state.globalFilter,
|
|
717
|
-
columnFilters: state.columnFilters,
|
|
718
|
-
pagination
|
|
719
|
-
},
|
|
720
711
|
getCoreRowModel: (0, _reactTable.getCoreRowModel)(),
|
|
721
712
|
getPaginationRowModel: (0, _reactTable.getPaginationRowModel)(),
|
|
722
713
|
getFilteredRowModel: (0, _reactTable.getFilteredRowModel)(),
|
|
@@ -729,8 +720,17 @@ const useDataTable = function (props) {
|
|
|
729
720
|
onPaginationChange,
|
|
730
721
|
manualFiltering: manual,
|
|
731
722
|
manualSorting: manual,
|
|
732
|
-
manualPagination: manual
|
|
733
|
-
|
|
723
|
+
manualPagination: manual,
|
|
724
|
+
state: Object.assign({}, options?.state || null, {
|
|
725
|
+
columnVisibility,
|
|
726
|
+
sorting: state.sorting,
|
|
727
|
+
globalFilter: state.globalFilter,
|
|
728
|
+
columnFilters: state.columnFilters,
|
|
729
|
+
pagination
|
|
730
|
+
}),
|
|
731
|
+
data,
|
|
732
|
+
columns
|
|
733
|
+
}));
|
|
734
734
|
|
|
735
735
|
// lexicon page config
|
|
736
736
|
const limit = pagination.pageSize;
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import type { Table, TableOptions } from "@tanstack/react-table";
|
|
2
|
+
import type { Table, TableOptions, TableState } from "@tanstack/react-table";
|
|
3
3
|
import type { InputSelectOption } from "@tint-ui/tools";
|
|
4
4
|
import type { TriggerProp } from "@tint-ui/trigger";
|
|
5
5
|
interface FilterRangeType {
|
|
@@ -32,6 +32,9 @@ export type SelectedOption<TData> = OptionTrigger<TData> & {
|
|
|
32
32
|
};
|
|
33
33
|
export type DataTableToolbarSize = "sm" | "md" | "lg";
|
|
34
34
|
export type DataTableNavbarSize = "sm" | "md" | "lg";
|
|
35
|
+
export interface DataTableOptions<TData> extends Partial<Omit<TableOptions<TData>, "pageCount" | "getCoreRowModel" | "getPaginationRowModel" | "getFilteredRowModel" | "getSortedRowModel" | "globalFilterFn" | "onColumnFiltersChange" | "onGlobalFilterChange" | "onColumnVisibilityChange" | "onSortingChange" | "onPaginationChange" | "manualFiltering" | "manualSorting" | "manualPagination" | "data" | "columns" | "state">> {
|
|
36
|
+
state?: Partial<Omit<TableState, "columnVisibility" | "sorting" | "globalFilter" | "columnFilters" | "pagination">>;
|
|
37
|
+
}
|
|
35
38
|
export interface DataTableCoreProps<TData> extends FilterType<TData> {
|
|
36
39
|
table: DataTableType<TData>;
|
|
37
40
|
data: TData[] | DataTableCallbackType<TData>;
|
|
@@ -47,7 +50,7 @@ export interface DataTableCoreProps<TData> extends FilterType<TData> {
|
|
|
47
50
|
navbar?: Partial<Omit<NavbarConfig, "onPageSizeChange">> | null;
|
|
48
51
|
compact?: boolean;
|
|
49
52
|
cacheable?: boolean;
|
|
50
|
-
options?:
|
|
53
|
+
options?: DataTableOptions<TData>;
|
|
51
54
|
}
|
|
52
55
|
export type StringOrFn = string | (() => string);
|
|
53
56
|
export interface DataTableLexicon {
|
package/use-data-table.js
CHANGED
|
@@ -190,7 +190,7 @@ const useDataTable = function (props) {
|
|
|
190
190
|
onRowClick,
|
|
191
191
|
toolbar: toolbarProp,
|
|
192
192
|
navbar: navbarProp,
|
|
193
|
-
options
|
|
193
|
+
options = null
|
|
194
194
|
} = props;
|
|
195
195
|
const {
|
|
196
196
|
name,
|
|
@@ -705,16 +705,8 @@ const useDataTable = function (props) {
|
|
|
705
705
|
pagination
|
|
706
706
|
} = state;
|
|
707
707
|
const tableCtx = useReactTable({
|
|
708
|
-
|
|
709
|
-
columns,
|
|
708
|
+
...options,
|
|
710
709
|
pageCount: manual ? state.pageCount : undefined,
|
|
711
|
-
state: {
|
|
712
|
-
columnVisibility,
|
|
713
|
-
sorting: state.sorting,
|
|
714
|
-
globalFilter: state.globalFilter,
|
|
715
|
-
columnFilters: state.columnFilters,
|
|
716
|
-
pagination
|
|
717
|
-
},
|
|
718
710
|
getCoreRowModel: getCoreRowModel(),
|
|
719
711
|
getPaginationRowModel: getPaginationRowModel(),
|
|
720
712
|
getFilteredRowModel: getFilteredRowModel(),
|
|
@@ -728,7 +720,16 @@ const useDataTable = function (props) {
|
|
|
728
720
|
manualFiltering: manual,
|
|
729
721
|
manualSorting: manual,
|
|
730
722
|
manualPagination: manual,
|
|
731
|
-
|
|
723
|
+
state: {
|
|
724
|
+
...(options?.state || null),
|
|
725
|
+
columnVisibility,
|
|
726
|
+
sorting: state.sorting,
|
|
727
|
+
globalFilter: state.globalFilter,
|
|
728
|
+
columnFilters: state.columnFilters,
|
|
729
|
+
pagination
|
|
730
|
+
},
|
|
731
|
+
data,
|
|
732
|
+
columns
|
|
732
733
|
});
|
|
733
734
|
|
|
734
735
|
// lexicon page config
|