@ackplus/react-tanstack-data-table 1.1.11 → 1.1.12
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/lib/components/toolbar/data-table-toolbar.d.ts.map +1 -1
- package/dist/lib/components/toolbar/data-table-toolbar.js +5 -2
- package/dist/lib/components/toolbar/table-refresh-control.d.ts +15 -0
- package/dist/lib/components/toolbar/table-refresh-control.d.ts.map +1 -0
- package/dist/lib/components/toolbar/table-refresh-control.js +61 -0
- package/dist/lib/data-table.d.ts.map +1 -1
- package/dist/lib/data-table.js +749 -916
- package/dist/lib/types/data-table-api.d.ts +1 -0
- package/dist/lib/types/data-table-api.d.ts.map +1 -1
- package/dist/lib/types/data-table.types.d.ts +1 -0
- package/dist/lib/types/data-table.types.d.ts.map +1 -1
- package/dist/lib/types/slots.types.d.ts +9 -0
- package/dist/lib/types/slots.types.d.ts.map +1 -1
- package/dist/lib/utils/slot-helpers.d.ts +1 -1
- package/dist/lib/utils/slot-helpers.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/lib/components/toolbar/data-table-toolbar.tsx +15 -1
- package/src/lib/components/toolbar/table-refresh-control.tsx +58 -0
- package/src/lib/data-table.tsx +773 -904
- package/src/lib/types/data-table-api.ts +4 -0
- package/src/lib/types/data-table.types.ts +1 -0
- package/src/lib/types/slots.types.ts +8 -0
- package/src/lib/utils/slot-helpers.tsx +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-toolbar.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/toolbar/data-table-toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKH,YAAY,EACZ,OAAO,EACV,MAAM,eAAe,CAAC;AACvB,OAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"data-table-toolbar.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/toolbar/data-table-toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKH,YAAY,EACZ,OAAO,EACV,MAAM,eAAe,CAAC;AACvB,OAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAavD,MAAM,WAAW,qBAAsB,SAAQ,YAAY;IACvD,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,GAAE,qBAA0B,GAAG,YAAY,CAwMhF"}
|
|
@@ -15,9 +15,10 @@ const table_export_control_1 = require("./table-export-control");
|
|
|
15
15
|
const table_search_control_1 = require("./table-search-control");
|
|
16
16
|
const table_size_control_1 = require("./table-size-control");
|
|
17
17
|
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
18
|
+
const table_refresh_control_1 = require("./table-refresh-control");
|
|
18
19
|
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
19
20
|
function DataTableToolbar(props = {}) {
|
|
20
|
-
const { extraFilter = null, enableGlobalFilter = true, title, subtitle, enableColumnVisibility = true, enableExport = true, enableReset = true, enableColumnFilter = true, enableTableSizeControl = true, enableColumnPinning = true, titleSx, subtitleSx, containerSx, leftSectionSx, rightSectionSx, ...otherProps } = props;
|
|
21
|
+
const { extraFilter = null, enableGlobalFilter = true, title, subtitle, enableColumnVisibility = true, enableExport = true, enableReset = true, enableRefresh = false, enableColumnFilter = true, enableTableSizeControl = true, enableColumnPinning = true, titleSx, subtitleSx, containerSx, leftSectionSx, rightSectionSx, ...otherProps } = props;
|
|
21
22
|
const { table, slots, slotProps = {} } = (0, data_table_context_1.useDataTableContext)();
|
|
22
23
|
// Extract slot-specific props with enhanced merging
|
|
23
24
|
const toolbarSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'toolbar');
|
|
@@ -28,6 +29,7 @@ function DataTableToolbar(props = {}) {
|
|
|
28
29
|
const columnVisibilityControlSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'columnVisibilityControl');
|
|
29
30
|
const resetButtonSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'resetButton');
|
|
30
31
|
const exportButtonSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'exportButton');
|
|
32
|
+
const refreshButtonSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'refreshButton');
|
|
31
33
|
const ToolbarSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'toolbar', material_1.Toolbar);
|
|
32
34
|
const TableSearchControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'searchInput', table_search_control_1.TableSearchControl);
|
|
33
35
|
const TableSizeControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'tableSizeControl', table_size_control_1.TableSizeControl);
|
|
@@ -36,6 +38,7 @@ function DataTableToolbar(props = {}) {
|
|
|
36
38
|
const ColumnVisibilityControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'columnVisibilityControl', column_visibility_control_1.ColumnVisibilityControl);
|
|
37
39
|
const ColumnResetControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'resetButton', column_reset_control_1.ColumnResetControl);
|
|
38
40
|
const TableExportControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'exportButton', table_export_control_1.TableExportControl);
|
|
41
|
+
const TableRefreshControlSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'refreshButton', table_refresh_control_1.TableRefreshControl);
|
|
39
42
|
// Merge all props for maximum flexibility
|
|
40
43
|
const mergedToolbarProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
41
44
|
// Default toolbar props
|
|
@@ -48,5 +51,5 @@ function DataTableToolbar(props = {}) {
|
|
|
48
51
|
}, children: [(title || subtitle) ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mb: 2 }, children: [title ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", component: "div", sx: titleSx, children: title })) : null, subtitle ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", color: "text.secondary", sx: subtitleSx, children: subtitle })) : null] })) : null, (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 2, justifyContent: "space-between", alignItems: "center", children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", spacing: 0.5, alignItems: "center", sx: {
|
|
49
52
|
flex: 1,
|
|
50
53
|
...leftSectionSx,
|
|
51
|
-
}, children: [enableTableSizeControl ? ((0, jsx_runtime_1.jsx)(TableSizeControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, tableSizeControlSlotProps, props.tableSizeControlProps || {}) })) : null, enableColumnFilter ? ((0, jsx_runtime_1.jsx)(ColumnCustomFilterControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, columnCustomFilterControlSlotProps, props.columnFilterProps || {}) })) : null, enableColumnPinning ? ((0, jsx_runtime_1.jsx)(ColumnPinningControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, columnPinningControlSlotProps, props.columnPinningProps || {}) })) : null, enableColumnVisibility ? ((0, jsx_runtime_1.jsx)(ColumnVisibilityControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, columnVisibilityControlSlotProps, props.columnVisibilityProps || {}) })) : null, enableReset ? ((0, jsx_runtime_1.jsx)(ColumnResetControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, resetButtonSlotProps, props.resetButtonProps || {}) })) : null, enableExport ? ((0, jsx_runtime_1.jsx)(TableExportControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, exportButtonSlotProps, props.exportButtonProps || {}) })) : null, enableGlobalFilter ? ((0, jsx_runtime_1.jsx)(TableSearchControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, searchInputSlotProps, props.searchInputProps || {}) })) : null] }), (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", spacing: 1, alignItems: "center", sx: rightSectionSx, children: extraFilter })] })] }) }));
|
|
54
|
+
}, children: [enableTableSizeControl ? ((0, jsx_runtime_1.jsx)(TableSizeControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, tableSizeControlSlotProps, props.tableSizeControlProps || {}) })) : null, enableColumnFilter ? ((0, jsx_runtime_1.jsx)(ColumnCustomFilterControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, columnCustomFilterControlSlotProps, props.columnFilterProps || {}) })) : null, enableColumnPinning ? ((0, jsx_runtime_1.jsx)(ColumnPinningControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, columnPinningControlSlotProps, props.columnPinningProps || {}) })) : null, enableColumnVisibility ? ((0, jsx_runtime_1.jsx)(ColumnVisibilityControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, columnVisibilityControlSlotProps, props.columnVisibilityProps || {}) })) : null, enableReset ? ((0, jsx_runtime_1.jsx)(ColumnResetControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, resetButtonSlotProps, props.resetButtonProps || {}) })) : null, enableExport ? ((0, jsx_runtime_1.jsx)(TableExportControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, exportButtonSlotProps, props.exportButtonProps || {}) })) : null, enableGlobalFilter ? ((0, jsx_runtime_1.jsx)(TableSearchControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, searchInputSlotProps, props.searchInputProps || {}) })) : null, enableRefresh ? ((0, jsx_runtime_1.jsx)(TableRefreshControlSlot, { ...(0, slot_helpers_1.mergeSlotProps)({}, refreshButtonSlotProps, props.refreshButtonProps || {}) })) : null] }), (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", spacing: 1, alignItems: "center", sx: rightSectionSx, children: extraFilter })] })] }) }));
|
|
52
55
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { IconButtonProps } from '@mui/material';
|
|
3
|
+
export interface TableRefreshControlProps {
|
|
4
|
+
iconButtonProps?: IconButtonProps;
|
|
5
|
+
tooltipProps?: any;
|
|
6
|
+
/** optional override */
|
|
7
|
+
onRefresh?: () => void | Promise<void>;
|
|
8
|
+
/** disable + show spinner if true */
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
/** use spinner instead of icon while loading */
|
|
11
|
+
showSpinnerWhileLoading?: boolean;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
14
|
+
export declare function TableRefreshControl(props?: TableRefreshControlProps): ReactElement;
|
|
15
|
+
//# sourceMappingURL=table-refresh-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-refresh-control.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/toolbar/table-refresh-control.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,YAAY,EAAe,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAuB,eAAe,EAAoB,MAAM,eAAe,CAAC;AAKvF,MAAM,WAAW,wBAAwB;IACrC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,YAAY,CAAC,EAAE,GAAG,CAAC;IAEnB,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvC,qCAAqC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,gDAAgD;IAChD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,GAAE,wBAA6B,GAAG,YAAY,CAkCtF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.TableRefreshControl = TableRefreshControl;
|
|
37
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
40
|
+
const material_1 = require("@mui/material");
|
|
41
|
+
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
42
|
+
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
43
|
+
function TableRefreshControl(props = {}) {
|
|
44
|
+
const { apiRef, slots, slotProps } = (0, data_table_context_1.useDataTableContext)();
|
|
45
|
+
const refreshIconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'refreshIcon');
|
|
46
|
+
const RefreshIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'refreshIcon', icons_material_1.Refresh);
|
|
47
|
+
const handleRefresh = (0, react_1.useCallback)(() => {
|
|
48
|
+
var _a, _b, _c;
|
|
49
|
+
if (props.onRefresh)
|
|
50
|
+
return props.onRefresh();
|
|
51
|
+
// Default: use internal api
|
|
52
|
+
(_c = (_b = (_a = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.reload) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
53
|
+
}, [props, apiRef]);
|
|
54
|
+
const mergedIconButtonProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
55
|
+
size: 'small',
|
|
56
|
+
onClick: handleRefresh,
|
|
57
|
+
disabled: !!props.loading,
|
|
58
|
+
sx: { flexShrink: 0 },
|
|
59
|
+
}, refreshIconSlotProps, props.iconButtonProps || {});
|
|
60
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: "Refresh data", ...props.tooltipProps, children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { ...mergedIconButtonProps, children: props.loading && props.showSpinnerWhileLoading ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 16 })) : ((0, jsx_runtime_1.jsx)(RefreshIconSlot, { ...refreshIconSlotProps })) }) }));
|
|
61
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table.d.ts","sourceRoot":"","sources":["../../src/lib/data-table.tsx"],"names":[],"mappings":"AA8EA;;GAEG;AACH,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"data-table.d.ts","sourceRoot":"","sources":["../../src/lib/data-table.tsx"],"names":[],"mappings":"AA8EA;;GAEG;AACH,eAAO,MAAM,SAAS,KAmrDpB,CAAC"}
|