@bsol-oss/react-datatable5 2.0.0 → 2.0.2
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/dist/index.d.ts +33 -1
- package/dist/index.js +48 -1
- package/dist/index.mjs +48 -2
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -281,6 +281,38 @@ interface useDataFromUrlProps<T> {
|
|
|
281
281
|
}
|
|
282
282
|
declare const useDataFromUrl: <T>({ url, params, disableFirstFetch, onFetchSuccess, defaultData, }: useDataFromUrlProps<T>) => useDataFromUrlReturn<T>;
|
|
283
283
|
|
|
284
|
+
interface UseDataTableProps {
|
|
285
|
+
default: {
|
|
286
|
+
sorting?: SortingState;
|
|
287
|
+
columnFilters?: ColumnFiltersState;
|
|
288
|
+
pagination?: PaginationState;
|
|
289
|
+
rowSelection?: RowSelectionState;
|
|
290
|
+
columnOrder?: ColumnOrderState;
|
|
291
|
+
globalFilter?: GlobalFilterTableState;
|
|
292
|
+
columnVisibility?: VisibilityState;
|
|
293
|
+
density?: DensityState;
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
interface UseDataTableReturn {
|
|
297
|
+
sorting: SortingState;
|
|
298
|
+
columnFilters: ColumnFiltersState;
|
|
299
|
+
pagination: PaginationState;
|
|
300
|
+
rowSelection: RowSelectionState;
|
|
301
|
+
columnOrder: ColumnOrderState;
|
|
302
|
+
globalFilter: GlobalFilterTableState;
|
|
303
|
+
columnVisibility: VisibilityState;
|
|
304
|
+
density: DensityState;
|
|
305
|
+
setPagination: OnChangeFn<PaginationState>;
|
|
306
|
+
setSorting: OnChangeFn<SortingState>;
|
|
307
|
+
setColumnFilters: OnChangeFn<ColumnFiltersState>;
|
|
308
|
+
setRowSelection: OnChangeFn<RowSelectionState>;
|
|
309
|
+
setGlobalFilter: OnChangeFn<GlobalFilterTableState>;
|
|
310
|
+
setColumnOrder: OnChangeFn<ColumnOrderState>;
|
|
311
|
+
setDensity: OnChangeFn<DensityState>;
|
|
312
|
+
setColumnVisibility: OnChangeFn<VisibilityState>;
|
|
313
|
+
}
|
|
314
|
+
declare const useDataTable: ({ default: { sorting: defaultSorting, pagination: defaultPagination, rowSelection: defaultRowSelection, columnFilters: defaultColumnFilters, columnOrder: defaultColumnOrder, columnVisibility: defaultColumnVisibility, globalFilter: defaultGlobalFilter, density: defaultDensity, }, }?: UseDataTableProps) => UseDataTableReturn;
|
|
315
|
+
|
|
284
316
|
declare const useDataTableContext: () => {
|
|
285
317
|
table: _tanstack_table_core.Table<any>;
|
|
286
318
|
refreshData: () => void;
|
|
@@ -351,4 +383,4 @@ declare module "@tanstack/react-table" {
|
|
|
351
383
|
}
|
|
352
384
|
}
|
|
353
385
|
|
|
354
|
-
export { type DataResponse, DataTable, type DataTableProps, DataTableServer, type DataTableServerProps, DefaultTable, type DefaultTableProps, DensityToggleButton, type DensityToggleButtonProps, EditFilterButton, type EditFilterButtonProps, EditOrderButton, type EditOrderButtonProps, EditSortingButton, type EditSortingButtonProps, EditViewButton, type EditViewButtonProps, FilterOptions, type FilterOptionsProps, GlobalFilter, PageSizeControl, type PageSizeControlProps, type PaginationProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, type ResetFilteringButtonProps, ResetSelectionButton, type ResetSelectionButtonProps, ResetSortingButton, type ResetSortingButtonProps, type Result, RowCountText, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableFilter, TableFilterTags, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, TableLoadingComponent, type TableLoadingComponentProps, TableOrderer, TablePagination, type TableProps, type TableRendererProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, TextCell, type TextCellProps, useDataFromUrl, type useDataFromUrlProps, type useDataFromUrlReturn, useDataTableContext };
|
|
386
|
+
export { type DataResponse, DataTable, type DataTableProps, DataTableServer, type DataTableServerProps, DefaultTable, type DefaultTableProps, DensityToggleButton, type DensityToggleButtonProps, EditFilterButton, type EditFilterButtonProps, EditOrderButton, type EditOrderButtonProps, EditSortingButton, type EditSortingButtonProps, EditViewButton, type EditViewButtonProps, FilterOptions, type FilterOptionsProps, GlobalFilter, PageSizeControl, type PageSizeControlProps, type PaginationProps, ReloadButton, type ReloadButtonProps, ResetFilteringButton, type ResetFilteringButtonProps, ResetSelectionButton, type ResetSelectionButtonProps, ResetSortingButton, type ResetSortingButtonProps, type Result, RowCountText, Table, TableBody, type TableBodyProps, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableComponent, TableControls, type TableControlsProps, TableFilter, TableFilterTags, TableFooter, type TableFooterProps, TableHeader, type TableHeaderProps, TableLoadingComponent, type TableLoadingComponentProps, TableOrderer, TablePagination, type TableProps, type TableRendererProps, type TableRowSelectorProps, TableSelector, TableSorter, TableViewer, TextCell, type TextCellProps, type UseDataTableProps, type UseDataTableReturn, useDataFromUrl, type useDataFromUrlProps, type useDataFromUrlReturn, useDataTable, useDataTableContext };
|
package/dist/index.js
CHANGED
|
@@ -838,6 +838,52 @@ const TextCell = ({ label, noOfLines = [1], padding = "0rem", children, tooltipP
|
|
|
838
838
|
return (jsxRuntime.jsx(react.Flex, { alignItems: "center", height: "100%", padding: padding, children: jsxRuntime.jsx(react.Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all", noOfLines: noOfLines, ...props, children: children }) }));
|
|
839
839
|
};
|
|
840
840
|
|
|
841
|
+
const useDataTable = ({ default: { sorting: defaultSorting = [], pagination: defaultPagination = {
|
|
842
|
+
pageIndex: 0, //initial page index
|
|
843
|
+
pageSize: 10, //default page size
|
|
844
|
+
}, rowSelection: defaultRowSelection = {}, columnFilters: defaultColumnFilters = [], columnOrder: defaultColumnOrder = [], columnVisibility: defaultColumnVisibility = {}, globalFilter: defaultGlobalFilter = { globalFilter: "" }, density: defaultDensity = "sm", }, } = {
|
|
845
|
+
default: {
|
|
846
|
+
sorting: [],
|
|
847
|
+
pagination: {
|
|
848
|
+
pageIndex: 0, //initial page index
|
|
849
|
+
pageSize: 10, //age size
|
|
850
|
+
},
|
|
851
|
+
rowSelection: {},
|
|
852
|
+
columnFilters: [],
|
|
853
|
+
columnOrder: [],
|
|
854
|
+
columnVisibility: {},
|
|
855
|
+
globalFilter: { globalFilter: "" },
|
|
856
|
+
density: "sm",
|
|
857
|
+
},
|
|
858
|
+
}) => {
|
|
859
|
+
const [sorting, setSorting] = react$1.useState(defaultSorting);
|
|
860
|
+
const [columnFilters, setColumnFilters] = react$1.useState(defaultColumnFilters); // can set initial column filter state here
|
|
861
|
+
const [pagination, setPagination] = react$1.useState(defaultPagination);
|
|
862
|
+
const [rowSelection, setRowSelection] = react$1.useState(defaultRowSelection);
|
|
863
|
+
const [columnOrder, setColumnOrder] = react$1.useState(defaultColumnOrder);
|
|
864
|
+
const [globalFilter, setGlobalFilter] = react$1.useState(defaultGlobalFilter);
|
|
865
|
+
const [density, setDensity] = react$1.useState(defaultDensity);
|
|
866
|
+
const [columnVisibility, setColumnVisibility] = react$1.useState(defaultColumnVisibility);
|
|
867
|
+
return {
|
|
868
|
+
sorting,
|
|
869
|
+
setSorting,
|
|
870
|
+
columnFilters,
|
|
871
|
+
setColumnFilters,
|
|
872
|
+
pagination,
|
|
873
|
+
setPagination,
|
|
874
|
+
rowSelection,
|
|
875
|
+
setRowSelection,
|
|
876
|
+
columnOrder,
|
|
877
|
+
setColumnOrder,
|
|
878
|
+
globalFilter,
|
|
879
|
+
setGlobalFilter,
|
|
880
|
+
density,
|
|
881
|
+
setDensity,
|
|
882
|
+
columnVisibility,
|
|
883
|
+
setColumnVisibility,
|
|
884
|
+
};
|
|
885
|
+
};
|
|
886
|
+
|
|
841
887
|
const FilterOptions = ({ column }) => {
|
|
842
888
|
const { table } = useDataTableContext();
|
|
843
889
|
const tableColumn = table.getColumn(column);
|
|
@@ -861,7 +907,7 @@ const FilterOptions = ({ column }) => {
|
|
|
861
907
|
const GlobalFilter = ({ icon = md.MdSearch }) => {
|
|
862
908
|
const { table } = useDataTableContext();
|
|
863
909
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(react.Box, { children: jsxRuntime.jsxs(react.InputGroup, { children: [jsxRuntime.jsx(react.InputLeftElement, { pointerEvents: "none", children: jsxRuntime.jsx(react.Icon, { as: icon, color: "gray.300" }) }), jsxRuntime.jsx(react.Input, { value: table.getState().globalFilter.globalFilter, onChange: (e) => {
|
|
864
|
-
table.setGlobalFilter(e.target.value);
|
|
910
|
+
table.setGlobalFilter({ "globalFilter": e.target.value });
|
|
865
911
|
} })] }) }) }));
|
|
866
912
|
};
|
|
867
913
|
|
|
@@ -899,4 +945,5 @@ exports.TableSorter = TableSorter;
|
|
|
899
945
|
exports.TableViewer = TableViewer;
|
|
900
946
|
exports.TextCell = TextCell;
|
|
901
947
|
exports.useDataFromUrl = useDataFromUrl;
|
|
948
|
+
exports.useDataTable = useDataTable;
|
|
902
949
|
exports.useDataTableContext = useDataTableContext;
|
package/dist/index.mjs
CHANGED
|
@@ -836,6 +836,52 @@ const TextCell = ({ label, noOfLines = [1], padding = "0rem", children, tooltipP
|
|
|
836
836
|
return (jsx(Flex, { alignItems: "center", height: "100%", padding: padding, children: jsx(Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", wordBreak: "break-all", noOfLines: noOfLines, ...props, children: children }) }));
|
|
837
837
|
};
|
|
838
838
|
|
|
839
|
+
const useDataTable = ({ default: { sorting: defaultSorting = [], pagination: defaultPagination = {
|
|
840
|
+
pageIndex: 0, //initial page index
|
|
841
|
+
pageSize: 10, //default page size
|
|
842
|
+
}, rowSelection: defaultRowSelection = {}, columnFilters: defaultColumnFilters = [], columnOrder: defaultColumnOrder = [], columnVisibility: defaultColumnVisibility = {}, globalFilter: defaultGlobalFilter = { globalFilter: "" }, density: defaultDensity = "sm", }, } = {
|
|
843
|
+
default: {
|
|
844
|
+
sorting: [],
|
|
845
|
+
pagination: {
|
|
846
|
+
pageIndex: 0, //initial page index
|
|
847
|
+
pageSize: 10, //age size
|
|
848
|
+
},
|
|
849
|
+
rowSelection: {},
|
|
850
|
+
columnFilters: [],
|
|
851
|
+
columnOrder: [],
|
|
852
|
+
columnVisibility: {},
|
|
853
|
+
globalFilter: { globalFilter: "" },
|
|
854
|
+
density: "sm",
|
|
855
|
+
},
|
|
856
|
+
}) => {
|
|
857
|
+
const [sorting, setSorting] = useState(defaultSorting);
|
|
858
|
+
const [columnFilters, setColumnFilters] = useState(defaultColumnFilters); // can set initial column filter state here
|
|
859
|
+
const [pagination, setPagination] = useState(defaultPagination);
|
|
860
|
+
const [rowSelection, setRowSelection] = useState(defaultRowSelection);
|
|
861
|
+
const [columnOrder, setColumnOrder] = useState(defaultColumnOrder);
|
|
862
|
+
const [globalFilter, setGlobalFilter] = useState(defaultGlobalFilter);
|
|
863
|
+
const [density, setDensity] = useState(defaultDensity);
|
|
864
|
+
const [columnVisibility, setColumnVisibility] = useState(defaultColumnVisibility);
|
|
865
|
+
return {
|
|
866
|
+
sorting,
|
|
867
|
+
setSorting,
|
|
868
|
+
columnFilters,
|
|
869
|
+
setColumnFilters,
|
|
870
|
+
pagination,
|
|
871
|
+
setPagination,
|
|
872
|
+
rowSelection,
|
|
873
|
+
setRowSelection,
|
|
874
|
+
columnOrder,
|
|
875
|
+
setColumnOrder,
|
|
876
|
+
globalFilter,
|
|
877
|
+
setGlobalFilter,
|
|
878
|
+
density,
|
|
879
|
+
setDensity,
|
|
880
|
+
columnVisibility,
|
|
881
|
+
setColumnVisibility,
|
|
882
|
+
};
|
|
883
|
+
};
|
|
884
|
+
|
|
839
885
|
const FilterOptions = ({ column }) => {
|
|
840
886
|
const { table } = useDataTableContext();
|
|
841
887
|
const tableColumn = table.getColumn(column);
|
|
@@ -859,8 +905,8 @@ const FilterOptions = ({ column }) => {
|
|
|
859
905
|
const GlobalFilter = ({ icon = MdSearch }) => {
|
|
860
906
|
const { table } = useDataTableContext();
|
|
861
907
|
return (jsx(Fragment, { children: jsx(Box, { children: jsxs(InputGroup, { children: [jsx(InputLeftElement, { pointerEvents: "none", children: jsx(Icon, { as: icon, color: "gray.300" }) }), jsx(Input, { value: table.getState().globalFilter.globalFilter, onChange: (e) => {
|
|
862
|
-
table.setGlobalFilter(e.target.value);
|
|
908
|
+
table.setGlobalFilter({ "globalFilter": e.target.value });
|
|
863
909
|
} })] }) }) }));
|
|
864
910
|
};
|
|
865
911
|
|
|
866
|
-
export { DataTable, DataTableServer, DefaultTable, DensityToggleButton, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, FilterOptions, GlobalFilter, PageSizeControl, ReloadButton, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, RowCountText, Table, TableBody, TableCardContainer, TableCards, TableComponent, TableControls, TableFilter, TableFilterTags, TableFooter, TableHeader, TableLoadingComponent, TableOrderer, TablePagination, TableSelector, TableSorter, TableViewer, TextCell, useDataFromUrl, useDataTableContext };
|
|
912
|
+
export { DataTable, DataTableServer, DefaultTable, DensityToggleButton, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, FilterOptions, GlobalFilter, PageSizeControl, ReloadButton, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, RowCountText, Table, TableBody, TableCardContainer, TableCards, TableComponent, TableControls, TableFilter, TableFilterTags, TableFooter, TableHeader, TableLoadingComponent, TableOrderer, TablePagination, TableSelector, TableSorter, TableViewer, TextCell, useDataFromUrl, useDataTable, useDataTableContext };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -83,6 +83,7 @@ export * from "./components/DataTable/TableSorter";
|
|
|
83
83
|
export * from "./components/DataTable/TableViewer";
|
|
84
84
|
export * from "./components/DataTable/TextCell";
|
|
85
85
|
export * from "./components/DataTable/useDataFromUrl";
|
|
86
|
+
export * from "./components/DataTable/useDataTable";
|
|
86
87
|
export * from "./components/DataTable/useDataTableContext";
|
|
87
88
|
export * from "./components/Filter/FilterOptions";
|
|
88
89
|
export * from "./components/Filter/GlobalFilter";
|