pixelize-design-library 2.2.193 → 2.2.194
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/package.json +1 -1
- package/.claude/settings.local.json +0 -15
- package/coverage/clover.xml +0 -638
- package/coverage/coverage-final.json +0 -20
- package/coverage/lcov-report/Table/CompactSelect.tsx.html +0 -379
- package/coverage/lcov-report/Table/Components/ActiveFilters.tsx.html +0 -514
- package/coverage/lcov-report/Table/Components/HeaderActions.tsx.html +0 -373
- package/coverage/lcov-report/Table/Components/Pagination.tsx.html +0 -574
- package/coverage/lcov-report/Table/Components/TableActions.tsx.html +0 -574
- package/coverage/lcov-report/Table/Components/TableBody.tsx.html +0 -1027
- package/coverage/lcov-report/Table/Components/TableFilters.tsx.html +0 -397
- package/coverage/lcov-report/Table/Components/TableHeader.tsx.html +0 -1060
- package/coverage/lcov-report/Table/Components/TableLoading.tsx.html +0 -361
- package/coverage/lcov-report/Table/Components/TableSearch.tsx.html +0 -337
- package/coverage/lcov-report/Table/Components/index.html +0 -266
- package/coverage/lcov-report/Table/Components/useDebounce.ts.html +0 -178
- package/coverage/lcov-report/Table/Components/useTable.ts.html +0 -778
- package/coverage/lcov-report/Table/LeftFilterPane.tsx.html +0 -1810
- package/coverage/lcov-report/Table/SelectOperationControls.tsx.html +0 -178
- package/coverage/lcov-report/Table/Table.tsx.html +0 -1567
- package/coverage/lcov-report/Table/TableProps.tsx.html +0 -658
- package/coverage/lcov-report/Table/TableSettings/ManageColumns.tsx.html +0 -619
- package/coverage/lcov-report/Table/TableSettings/TableFilters.tsx.html +0 -229
- package/coverage/lcov-report/Table/TableSettings/TableSettings.tsx.html +0 -532
- package/coverage/lcov-report/Table/TableSettings/index.html +0 -146
- package/coverage/lcov-report/Table/TableToDo.tsx.html +0 -973
- package/coverage/lcov-report/Table/TextOperationControls.tsx.html +0 -271
- package/coverage/lcov-report/Table/filterTypes.ts.html +0 -97
- package/coverage/lcov-report/Table/index.html +0 -176
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -146
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov.info +0 -1836
- package/dist/Assets/defaultLogo.tsx +0 -31
- package/dist/Theme/Dark/palette.d.ts +0 -370
- package/dist/Theme/Dark/palette.js +0 -372
- package/dist/components-v2/AlertDialog/AlertDialog.d.ts +0 -23
- package/dist/components-v2/AlertDialog/AlertDialog.js +0 -98
- package/dist/components-v2/Breadcrumbs/Breadcrumbs.d.ts +0 -14
- package/dist/components-v2/Breadcrumbs/Breadcrumbs.js +0 -66
- package/dist/components-v2/Charts/AreaChart.d.ts +0 -23
- package/dist/components-v2/Charts/AreaChart.js +0 -63
- package/dist/components-v2/Charts/BarChart.d.ts +0 -25
- package/dist/components-v2/Charts/BarChart.js +0 -57
- package/dist/components-v2/Charts/LineChart.d.ts +0 -23
- package/dist/components-v2/Charts/LineChart.js +0 -55
- package/dist/components-v2/Charts/PieChart.d.ts +0 -15
- package/dist/components-v2/Charts/PieChart.js +0 -54
- package/dist/components-v2/Charts/PolarChart.d.ts +0 -14
- package/dist/components-v2/Charts/PolarChart.js +0 -54
- package/dist/components-v2/Charts/chartOptions.d.ts +0 -7
- package/dist/components-v2/Charts/chartOptions.js +0 -41
- package/dist/components-v2/Charts/useChartTheme.d.ts +0 -22
- package/dist/components-v2/Charts/useChartTheme.js +0 -106
- package/dist/components-v2/ContactForm/ContactForm.d.ts +0 -25
- package/dist/components-v2/ContactForm/ContactForm.js +0 -116
- package/dist/components-v2/DatePicker/Calendar.d.ts +0 -19
- package/dist/components-v2/DatePicker/Calendar.js +0 -212
- package/dist/components-v2/DatePicker/DatePicker.d.ts +0 -46
- package/dist/components-v2/DatePicker/DatePicker.js +0 -189
- package/dist/components-v2/DatePicker/TimePicker.d.ts +0 -12
- package/dist/components-v2/DatePicker/TimePicker.js +0 -105
- package/dist/components-v2/DatePicker/utils.d.ts +0 -31
- package/dist/components-v2/DatePicker/utils.js +0 -109
- package/dist/components-v2/Drawer/Drawer.d.ts +0 -27
- package/dist/components-v2/Drawer/Drawer.js +0 -132
- package/dist/components-v2/FeedbackForm/FeedbackForm.d.ts +0 -26
- package/dist/components-v2/FeedbackForm/FeedbackForm.js +0 -112
- package/dist/components-v2/FileUploader/FileUploader.d.ts +0 -28
- package/dist/components-v2/FileUploader/FileUploader.js +0 -127
- package/dist/components-v2/Input/TextInput.d.ts +0 -41
- package/dist/components-v2/Input/TextInput.js +0 -169
- package/dist/components-v2/KanbanBoard/KanbanBoard.d.ts +0 -39
- package/dist/components-v2/KanbanBoard/KanbanBoard.js +0 -101
- package/dist/components-v2/Layout/AppLayout.d.ts +0 -22
- package/dist/components-v2/Layout/AppLayout.js +0 -53
- package/dist/components-v2/Loading/Loading.d.ts +0 -19
- package/dist/components-v2/Loading/Loading.js +0 -55
- package/dist/components-v2/Modal/Modal.d.ts +0 -30
- package/dist/components-v2/Modal/Modal.js +0 -82
- package/dist/components-v2/NavigationBar/NavigationBar.d.ts +0 -47
- package/dist/components-v2/NavigationBar/NavigationBar.js +0 -148
- package/dist/components-v2/Notification/Notification.d.ts +0 -22
- package/dist/components-v2/Notification/Notification.js +0 -113
- package/dist/components-v2/NumberInput/NumberInput.d.ts +0 -37
- package/dist/components-v2/NumberInput/NumberInput.js +0 -210
- package/dist/components-v2/PinInput/PinInput.d.ts +0 -26
- package/dist/components-v2/PinInput/PinInput.js +0 -138
- package/dist/components-v2/ProfilePhotoViewer/ProfilePhotoViewer.d.ts +0 -18
- package/dist/components-v2/ProfilePhotoViewer/ProfilePhotoViewer.js +0 -91
- package/dist/components-v2/Select/Select.d.ts +0 -41
- package/dist/components-v2/Select/Select.js +0 -284
- package/dist/components-v2/Sidebar/Sidebar.d.ts +0 -41
- package/dist/components-v2/Sidebar/Sidebar.js +0 -182
- package/dist/components-v2/Slider/Slider.d.ts +0 -18
- package/dist/components-v2/Slider/Slider.js +0 -101
- package/dist/components-v2/Table/Table.d.ts +0 -7
- package/dist/components-v2/Table/Table.js +0 -172
- package/dist/components-v2/Table/TableProps.d.ts +0 -139
- package/dist/components-v2/Table/TableProps.js +0 -9
- package/dist/components-v2/Table/components/ActiveFilters.d.ts +0 -10
- package/dist/components-v2/Table/components/ActiveFilters.js +0 -70
- package/dist/components-v2/Table/components/BulkActionBar.d.ts +0 -11
- package/dist/components-v2/Table/components/BulkActionBar.js +0 -92
- package/dist/components-v2/Table/components/ColumnResizeHandle.d.ts +0 -7
- package/dist/components-v2/Table/components/ColumnResizeHandle.js +0 -41
- package/dist/components-v2/Table/components/Pagination.d.ts +0 -11
- package/dist/components-v2/Table/components/Pagination.js +0 -92
- package/dist/components-v2/Table/components/TableBody.d.ts +0 -23
- package/dist/components-v2/Table/components/TableBody.js +0 -69
- package/dist/components-v2/Table/components/TableCell.d.ts +0 -14
- package/dist/components-v2/Table/components/TableCell.js +0 -63
- package/dist/components-v2/Table/components/TableEmptyState.d.ts +0 -12
- package/dist/components-v2/Table/components/TableEmptyState.js +0 -55
- package/dist/components-v2/Table/components/TableErrorState.d.ts +0 -6
- package/dist/components-v2/Table/components/TableErrorState.js +0 -52
- package/dist/components-v2/Table/components/TableHeader.d.ts +0 -21
- package/dist/components-v2/Table/components/TableHeader.js +0 -94
- package/dist/components-v2/Table/components/TableRow.d.ts +0 -20
- package/dist/components-v2/Table/components/TableRow.js +0 -64
- package/dist/components-v2/Table/components/TableSearch.d.ts +0 -8
- package/dist/components-v2/Table/components/TableSearch.js +0 -47
- package/dist/components-v2/Table/filters/FilterChips.d.ts +0 -6
- package/dist/components-v2/Table/filters/FilterChips.js +0 -9
- package/dist/components-v2/Table/filters/LeftFilterPane.d.ts +0 -17
- package/dist/components-v2/Table/filters/LeftFilterPane.js +0 -105
- package/dist/components-v2/Table/filters/TableFilters.d.ts +0 -12
- package/dist/components-v2/Table/filters/TableFilters.js +0 -127
- package/dist/components-v2/Table/hooks/useColumnResize.d.ts +0 -15
- package/dist/components-v2/Table/hooks/useColumnResize.js +0 -104
- package/dist/components-v2/Table/hooks/useTable.d.ts +0 -58
- package/dist/components-v2/Table/hooks/useTable.js +0 -254
- package/dist/components-v2/Table/hooks/useTableKeyboard.d.ts +0 -25
- package/dist/components-v2/Table/hooks/useTableKeyboard.js +0 -112
- package/dist/components-v2/Table/hooks/useVirtualScroll.d.ts +0 -29
- package/dist/components-v2/Table/hooks/useVirtualScroll.js +0 -83
- package/dist/components-v2/Table/settings/ManageColumns.d.ts +0 -12
- package/dist/components-v2/Table/settings/ManageColumns.js +0 -59
- package/dist/components-v2/Table/settings/TableSettings.d.ts +0 -12
- package/dist/components-v2/Table/settings/TableSettings.js +0 -57
- package/dist/components-v2/Table/utils/filterUtils.d.ts +0 -7
- package/dist/components-v2/Table/utils/filterUtils.js +0 -149
- package/dist/components-v2/Table/utils/sortUtils.d.ts +0 -6
- package/dist/components-v2/Table/utils/sortUtils.js +0 -65
- package/dist/components-v2/Tag/Tag.d.ts +0 -15
- package/dist/components-v2/Tag/Tag.js +0 -87
- package/dist/components-v2/Timeline/Timeline.d.ts +0 -18
- package/dist/components-v2/Timeline/Timeline.js +0 -76
- package/dist/components-v2/Toaster/Toaster.d.ts +0 -61
- package/dist/components-v2/Toaster/Toaster.js +0 -63
- package/dist/components-v2/Toggle/Toggle.d.ts +0 -28
- package/dist/components-v2/Toggle/Toggle.js +0 -90
- package/dist/components-v2/ui/accordion.d.ts +0 -12
- package/dist/components-v2/ui/accordion.js +0 -104
- package/dist/components-v2/ui/alert.d.ts +0 -18
- package/dist/components-v2/ui/alert.js +0 -99
- package/dist/components-v2/ui/avatar.d.ts +0 -12
- package/dist/components-v2/ui/avatar.js +0 -80
- package/dist/components-v2/ui/badge.d.ts +0 -10
- package/dist/components-v2/ui/badge.js +0 -76
- package/dist/components-v2/ui/button.d.ts +0 -18
- package/dist/components-v2/ui/button.js +0 -97
- package/dist/components-v2/ui/checkbox.d.ts +0 -15
- package/dist/components-v2/ui/checkbox.js +0 -86
- package/dist/components-v2/ui/dialog.d.ts +0 -30
- package/dist/components-v2/ui/dialog.js +0 -115
- package/dist/components-v2/ui/dropdown-menu.d.ts +0 -26
- package/dist/components-v2/ui/dropdown-menu.js +0 -121
- package/dist/components-v2/ui/field.d.ts +0 -32
- package/dist/components-v2/ui/field.js +0 -62
- package/dist/components-v2/ui/form-field.d.ts +0 -25
- package/dist/components-v2/ui/form-field.js +0 -96
- package/dist/components-v2/ui/input.d.ts +0 -9
- package/dist/components-v2/ui/input.js +0 -73
- package/dist/components-v2/ui/label.d.ts +0 -10
- package/dist/components-v2/ui/label.js +0 -70
- package/dist/components-v2/ui/popover.d.ts +0 -9
- package/dist/components-v2/ui/popover.js +0 -60
- package/dist/components-v2/ui/progress.d.ts +0 -12
- package/dist/components-v2/ui/progress.js +0 -75
- package/dist/components-v2/ui/radio-group.d.ts +0 -17
- package/dist/components-v2/ui/radio-group.js +0 -91
- package/dist/components-v2/ui/select.d.ts +0 -24
- package/dist/components-v2/ui/select.js +0 -122
- package/dist/components-v2/ui/separator.d.ts +0 -5
- package/dist/components-v2/ui/separator.js +0 -55
- package/dist/components-v2/ui/skeleton.d.ts +0 -9
- package/dist/components-v2/ui/skeleton.js +0 -68
- package/dist/components-v2/ui/spinner.d.ts +0 -16
- package/dist/components-v2/ui/spinner.js +0 -64
- package/dist/components-v2/ui/switch.d.ts +0 -10
- package/dist/components-v2/ui/switch.js +0 -81
- package/dist/components-v2/ui/tabs.d.ts +0 -13
- package/dist/components-v2/ui/tabs.js +0 -95
- package/dist/components-v2/ui/textarea.d.ts +0 -10
- package/dist/components-v2/ui/textarea.js +0 -96
- package/dist/components-v2/ui/tooltip.d.ts +0 -17
- package/dist/components-v2/ui/tooltip.js +0 -75
- package/dist/lib/utils.d.ts +0 -2
- package/dist/lib/utils.js +0 -8
- package/dist/theme-v2/ThemeProvider.d.ts +0 -19
- package/dist/theme-v2/ThemeProvider.js +0 -149
- package/dist/theme-v2/dark.css +0 -47
- package/dist/theme-v2/tokens.css +0 -72
|
@@ -1,104 +0,0 @@
|
|
|
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.useColumnResize = useColumnResize;
|
|
37
|
-
const React = __importStar(require("react"));
|
|
38
|
-
const ABSOLUTE_MIN = 60;
|
|
39
|
-
function useColumnResize({ columns, columnWidths, setColumnWidth, enabled, }) {
|
|
40
|
-
const [resizingColumnId, setResizingColumnId] = React.useState(null);
|
|
41
|
-
const stateRef = React.useRef(null);
|
|
42
|
-
const getWidth = React.useCallback((columnId) => {
|
|
43
|
-
if (columnWidths[columnId] !== undefined)
|
|
44
|
-
return columnWidths[columnId];
|
|
45
|
-
const definition = columns.find((c) => c.id === columnId);
|
|
46
|
-
return definition === null || definition === void 0 ? void 0 : definition.width;
|
|
47
|
-
}, [columnWidths, columns]);
|
|
48
|
-
const handlePointerDown = React.useCallback((columnId, event) => {
|
|
49
|
-
var _a, _b, _c, _d, _e;
|
|
50
|
-
if (!enabled)
|
|
51
|
-
return;
|
|
52
|
-
const column = columns.find((c) => c.id === columnId);
|
|
53
|
-
if (!column)
|
|
54
|
-
return;
|
|
55
|
-
if (column.enableResizing === false)
|
|
56
|
-
return;
|
|
57
|
-
event.preventDefault();
|
|
58
|
-
event.stopPropagation();
|
|
59
|
-
const headerCell = (_a = event.currentTarget.parentElement) !== null && _a !== void 0 ? _a : null;
|
|
60
|
-
const startWidth = (_c = (_b = getWidth(columnId)) !== null && _b !== void 0 ? _b : headerCell === null || headerCell === void 0 ? void 0 : headerCell.offsetWidth) !== null && _c !== void 0 ? _c : 150;
|
|
61
|
-
stateRef.current = {
|
|
62
|
-
columnId,
|
|
63
|
-
startX: event.clientX,
|
|
64
|
-
startWidth,
|
|
65
|
-
minWidth: Math.max(ABSOLUTE_MIN, (_d = column.minWidth) !== null && _d !== void 0 ? _d : ABSOLUTE_MIN),
|
|
66
|
-
maxWidth: (_e = column.maxWidth) !== null && _e !== void 0 ? _e : Number.POSITIVE_INFINITY,
|
|
67
|
-
};
|
|
68
|
-
setResizingColumnId(columnId);
|
|
69
|
-
try {
|
|
70
|
-
event.currentTarget.setPointerCapture(event.pointerId);
|
|
71
|
-
}
|
|
72
|
-
catch (_f) {
|
|
73
|
-
/* not supported */
|
|
74
|
-
}
|
|
75
|
-
document.body.style.cursor = "col-resize";
|
|
76
|
-
document.body.style.userSelect = "none";
|
|
77
|
-
const handleMove = (moveEvent) => {
|
|
78
|
-
const state = stateRef.current;
|
|
79
|
-
if (!state)
|
|
80
|
-
return;
|
|
81
|
-
const delta = moveEvent.clientX - state.startX;
|
|
82
|
-
const nextWidth = Math.min(state.maxWidth, Math.max(state.minWidth, state.startWidth + delta));
|
|
83
|
-
setColumnWidth(state.columnId, nextWidth);
|
|
84
|
-
};
|
|
85
|
-
const handleUp = () => {
|
|
86
|
-
stateRef.current = null;
|
|
87
|
-
setResizingColumnId(null);
|
|
88
|
-
document.body.style.cursor = "";
|
|
89
|
-
document.body.style.userSelect = "";
|
|
90
|
-
window.removeEventListener("pointermove", handleMove);
|
|
91
|
-
window.removeEventListener("pointerup", handleUp);
|
|
92
|
-
window.removeEventListener("pointercancel", handleUp);
|
|
93
|
-
};
|
|
94
|
-
window.addEventListener("pointermove", handleMove);
|
|
95
|
-
window.addEventListener("pointerup", handleUp);
|
|
96
|
-
window.addEventListener("pointercancel", handleUp);
|
|
97
|
-
}, [enabled, columns, setColumnWidth, getWidth]);
|
|
98
|
-
return {
|
|
99
|
-
handlePointerDown,
|
|
100
|
-
isResizing: resizingColumnId !== null,
|
|
101
|
-
resizingColumnId,
|
|
102
|
-
getWidth,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import type { ActiveFilter, ColumnDef, Density, RowKey, SortState, TablePreferences } from "../TableProps";
|
|
3
|
-
export interface UseTableOptions<T> {
|
|
4
|
-
data: T[];
|
|
5
|
-
columns: ColumnDef<T>[];
|
|
6
|
-
rowKey: RowKey<T>;
|
|
7
|
-
selectable: boolean;
|
|
8
|
-
selectionMode: "single" | "multi";
|
|
9
|
-
selectedRows?: (string | number)[];
|
|
10
|
-
onSelectionChange?: (selectedKeys: (string | number)[]) => void;
|
|
11
|
-
sortable: boolean;
|
|
12
|
-
defaultSort?: SortState;
|
|
13
|
-
onSortChange?: (sort: SortState | null) => void;
|
|
14
|
-
filterable: boolean;
|
|
15
|
-
defaultFilters?: ActiveFilter[];
|
|
16
|
-
onFilterChange?: (filters: ActiveFilter[]) => void;
|
|
17
|
-
searchable: boolean;
|
|
18
|
-
onSearchChange?: (query: string) => void;
|
|
19
|
-
isServerSearch: boolean;
|
|
20
|
-
pagination: boolean;
|
|
21
|
-
paginationMode: "client" | "server";
|
|
22
|
-
defaultPageSize: number;
|
|
23
|
-
totalCount?: number;
|
|
24
|
-
onPageChange?: (page: number, pageSize: number) => void;
|
|
25
|
-
defaultHiddenColumns: string[];
|
|
26
|
-
density: Density;
|
|
27
|
-
preferences?: TablePreferences;
|
|
28
|
-
}
|
|
29
|
-
export declare function useTable<T>(options: UseTableOptions<T>): {
|
|
30
|
-
pageData: T[];
|
|
31
|
-
processed: T[];
|
|
32
|
-
pageCount: number;
|
|
33
|
-
visibleColumns: ColumnDef<T>[];
|
|
34
|
-
columnVisibility: Record<string, boolean>;
|
|
35
|
-
setColumnHidden: (id: string, hidden: boolean) => void;
|
|
36
|
-
columnWidths: Record<string, number>;
|
|
37
|
-
setColumnWidth: (id: string, width: number) => void;
|
|
38
|
-
density: Density;
|
|
39
|
-
setDensity: React.Dispatch<React.SetStateAction<Density>>;
|
|
40
|
-
sort: SortState | null;
|
|
41
|
-
setSort: (next: SortState | null) => void;
|
|
42
|
-
filters: ActiveFilter[];
|
|
43
|
-
setFilters: (next: ActiveFilter[] | ((prev: ActiveFilter[]) => ActiveFilter[])) => void;
|
|
44
|
-
searchQuery: string;
|
|
45
|
-
setSearchQuery: (query: string) => void;
|
|
46
|
-
selection: (string | number)[];
|
|
47
|
-
toggleRow: (key: string | number) => void;
|
|
48
|
-
toggleAll: () => void;
|
|
49
|
-
clearSelection: () => void;
|
|
50
|
-
isAllSelected: boolean;
|
|
51
|
-
isSomeSelected: boolean;
|
|
52
|
-
pageIndex: number;
|
|
53
|
-
pageSize: number;
|
|
54
|
-
setPage: (page: number, size?: number) => void;
|
|
55
|
-
setPageSize: (size: number) => void;
|
|
56
|
-
allRowKeys: (string | number)[];
|
|
57
|
-
};
|
|
58
|
-
export type UseTableReturn<T> = ReturnType<typeof useTable<T>>;
|
|
@@ -1,254 +0,0 @@
|
|
|
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.useTable = useTable;
|
|
37
|
-
const React = __importStar(require("react"));
|
|
38
|
-
const filterUtils_1 = require("../utils/filterUtils");
|
|
39
|
-
const sortUtils_1 = require("../utils/sortUtils");
|
|
40
|
-
const STORAGE_VERSION = 1;
|
|
41
|
-
function readPersisted(storageKey) {
|
|
42
|
-
if (!storageKey || typeof window === "undefined")
|
|
43
|
-
return null;
|
|
44
|
-
try {
|
|
45
|
-
const raw = window.localStorage.getItem(`px-table:${STORAGE_VERSION}:${storageKey}`);
|
|
46
|
-
if (!raw)
|
|
47
|
-
return null;
|
|
48
|
-
return JSON.parse(raw);
|
|
49
|
-
}
|
|
50
|
-
catch (_a) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function writePersisted(storageKey, state) {
|
|
55
|
-
if (!storageKey || typeof window === "undefined")
|
|
56
|
-
return;
|
|
57
|
-
try {
|
|
58
|
-
window.localStorage.setItem(`px-table:${STORAGE_VERSION}:${storageKey}`, JSON.stringify(state));
|
|
59
|
-
}
|
|
60
|
-
catch (_a) {
|
|
61
|
-
/* ignore quota */
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function useTable(options) {
|
|
65
|
-
var _a;
|
|
66
|
-
const { data, columns, rowKey, selectable, selectionMode, selectedRows: controlledSelection, onSelectionChange, sortable, defaultSort, onSortChange, filterable, defaultFilters, onFilterChange, searchable, onSearchChange, isServerSearch, pagination, paginationMode, defaultPageSize, totalCount, onPageChange, defaultHiddenColumns, density: densityProp, preferences, } = options;
|
|
67
|
-
const persisted = React.useMemo(() => readPersisted(preferences === null || preferences === void 0 ? void 0 : preferences.storageKey), [preferences === null || preferences === void 0 ? void 0 : preferences.storageKey]);
|
|
68
|
-
/* ───── Column visibility / widths / order / density ───── */
|
|
69
|
-
const [columnVisibility, setColumnVisibility] = React.useState(() => {
|
|
70
|
-
if (persisted === null || persisted === void 0 ? void 0 : persisted.columnVisibility)
|
|
71
|
-
return persisted.columnVisibility;
|
|
72
|
-
const initial = {};
|
|
73
|
-
for (const c of columns) {
|
|
74
|
-
initial[c.id] = c.hidden ? false : !defaultHiddenColumns.includes(c.id);
|
|
75
|
-
}
|
|
76
|
-
return initial;
|
|
77
|
-
});
|
|
78
|
-
const [columnWidths, setColumnWidths] = React.useState(() => { var _a; return (_a = persisted === null || persisted === void 0 ? void 0 : persisted.columnWidths) !== null && _a !== void 0 ? _a : {}; });
|
|
79
|
-
const [density, setDensity] = React.useState(() => { var _a; return (_a = persisted === null || persisted === void 0 ? void 0 : persisted.density) !== null && _a !== void 0 ? _a : densityProp; });
|
|
80
|
-
/* ───── Sort ───── */
|
|
81
|
-
const isSortControlled = !!onSortChange && defaultSort !== undefined;
|
|
82
|
-
const [internalSort, setInternalSort] = React.useState(defaultSort !== null && defaultSort !== void 0 ? defaultSort : null);
|
|
83
|
-
const sort = isSortControlled ? defaultSort !== null && defaultSort !== void 0 ? defaultSort : null : internalSort;
|
|
84
|
-
const setSort = React.useCallback((next) => {
|
|
85
|
-
if (!isSortControlled)
|
|
86
|
-
setInternalSort(next);
|
|
87
|
-
onSortChange === null || onSortChange === void 0 ? void 0 : onSortChange(next);
|
|
88
|
-
}, [isSortControlled, onSortChange]);
|
|
89
|
-
/* ───── Filters ───── */
|
|
90
|
-
const [internalFilters, setInternalFilters] = React.useState(defaultFilters !== null && defaultFilters !== void 0 ? defaultFilters : []);
|
|
91
|
-
const filters = internalFilters;
|
|
92
|
-
const setFilters = React.useCallback((next) => {
|
|
93
|
-
setInternalFilters((prev) => {
|
|
94
|
-
const value = typeof next === "function" ? next(prev) : next;
|
|
95
|
-
onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(value);
|
|
96
|
-
return value;
|
|
97
|
-
});
|
|
98
|
-
}, [onFilterChange]);
|
|
99
|
-
/* ───── Search ───── */
|
|
100
|
-
const [searchQuery, setSearchQueryState] = React.useState("");
|
|
101
|
-
const setSearchQuery = React.useCallback((query) => {
|
|
102
|
-
setSearchQueryState(query);
|
|
103
|
-
onSearchChange === null || onSearchChange === void 0 ? void 0 : onSearchChange(query);
|
|
104
|
-
}, [onSearchChange]);
|
|
105
|
-
/* ───── Selection ───── */
|
|
106
|
-
const isSelectionControlled = controlledSelection !== undefined;
|
|
107
|
-
const [internalSelection, setInternalSelection] = React.useState(controlledSelection !== null && controlledSelection !== void 0 ? controlledSelection : []);
|
|
108
|
-
const selection = isSelectionControlled
|
|
109
|
-
? controlledSelection
|
|
110
|
-
: internalSelection;
|
|
111
|
-
const setSelection = React.useCallback((next) => {
|
|
112
|
-
if (!isSelectionControlled)
|
|
113
|
-
setInternalSelection(next);
|
|
114
|
-
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(next);
|
|
115
|
-
}, [isSelectionControlled, onSelectionChange]);
|
|
116
|
-
const toggleRow = React.useCallback((key) => {
|
|
117
|
-
if (selectionMode === "single") {
|
|
118
|
-
setSelection(selection[0] === key ? [] : [key]);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const set = new Set(selection);
|
|
122
|
-
if (set.has(key))
|
|
123
|
-
set.delete(key);
|
|
124
|
-
else
|
|
125
|
-
set.add(key);
|
|
126
|
-
setSelection(Array.from(set));
|
|
127
|
-
}, [selection, selectionMode, setSelection]);
|
|
128
|
-
const allRowKeys = React.useMemo(() => data.map((row) => (0, sortUtils_1.resolveRowKey)(row, rowKey)), [data, rowKey]);
|
|
129
|
-
const toggleAll = React.useCallback(() => {
|
|
130
|
-
if (selectionMode === "single")
|
|
131
|
-
return;
|
|
132
|
-
const allSelected = selection.length === allRowKeys.length && allRowKeys.length > 0;
|
|
133
|
-
setSelection(allSelected ? [] : allRowKeys);
|
|
134
|
-
}, [allRowKeys, selection, selectionMode, setSelection]);
|
|
135
|
-
const clearSelection = React.useCallback(() => setSelection([]), [setSelection]);
|
|
136
|
-
/* ───── Pagination ───── */
|
|
137
|
-
const [pageIndex, setPageIndex] = React.useState(0);
|
|
138
|
-
const [pageSize, setPageSize] = React.useState((_a = persisted === null || persisted === void 0 ? void 0 : persisted.pageSize) !== null && _a !== void 0 ? _a : defaultPageSize);
|
|
139
|
-
const setPage = React.useCallback((page, size) => {
|
|
140
|
-
const effectiveSize = size !== null && size !== void 0 ? size : pageSize;
|
|
141
|
-
setPageIndex(page);
|
|
142
|
-
if (size !== undefined)
|
|
143
|
-
setPageSize(size);
|
|
144
|
-
onPageChange === null || onPageChange === void 0 ? void 0 : onPageChange(page, effectiveSize);
|
|
145
|
-
}, [onPageChange, pageSize]);
|
|
146
|
-
React.useEffect(() => {
|
|
147
|
-
if (paginationMode === "server")
|
|
148
|
-
return;
|
|
149
|
-
const maxPage = Math.max(0, Math.ceil(data.length / pageSize) - 1);
|
|
150
|
-
if (pageIndex > maxPage)
|
|
151
|
-
setPageIndex(maxPage);
|
|
152
|
-
}, [data.length, pageSize, pageIndex, paginationMode]);
|
|
153
|
-
/* ───── Derived: filter → search → sort → paginate ───── */
|
|
154
|
-
const processed = React.useMemo(() => {
|
|
155
|
-
if (paginationMode === "server") {
|
|
156
|
-
return data;
|
|
157
|
-
}
|
|
158
|
-
let result = filterable ? (0, filterUtils_1.filterData)(data, filters, columns) : data;
|
|
159
|
-
if (searchable && !isServerSearch) {
|
|
160
|
-
result = (0, filterUtils_1.searchData)(result, searchQuery, columns);
|
|
161
|
-
}
|
|
162
|
-
if (sortable)
|
|
163
|
-
result = (0, sortUtils_1.sortData)(result, sort, columns);
|
|
164
|
-
return result;
|
|
165
|
-
}, [
|
|
166
|
-
data,
|
|
167
|
-
columns,
|
|
168
|
-
filterable,
|
|
169
|
-
filters,
|
|
170
|
-
searchable,
|
|
171
|
-
isServerSearch,
|
|
172
|
-
searchQuery,
|
|
173
|
-
sortable,
|
|
174
|
-
sort,
|
|
175
|
-
paginationMode,
|
|
176
|
-
]);
|
|
177
|
-
const pageCount = React.useMemo(() => {
|
|
178
|
-
if (paginationMode === "server") {
|
|
179
|
-
return Math.max(1, Math.ceil((totalCount !== null && totalCount !== void 0 ? totalCount : 0) / pageSize));
|
|
180
|
-
}
|
|
181
|
-
if (!pagination)
|
|
182
|
-
return 1;
|
|
183
|
-
return Math.max(1, Math.ceil(processed.length / pageSize));
|
|
184
|
-
}, [paginationMode, totalCount, pageSize, pagination, processed.length]);
|
|
185
|
-
const pageData = React.useMemo(() => {
|
|
186
|
-
if (paginationMode === "server" || !pagination)
|
|
187
|
-
return processed;
|
|
188
|
-
const start = pageIndex * pageSize;
|
|
189
|
-
return processed.slice(start, start + pageSize);
|
|
190
|
-
}, [processed, pagination, paginationMode, pageIndex, pageSize]);
|
|
191
|
-
/* ───── Helpers ───── */
|
|
192
|
-
const isAllSelected = allRowKeys.length > 0 && selection.length === allRowKeys.length;
|
|
193
|
-
const isSomeSelected = selection.length > 0 && selection.length < allRowKeys.length;
|
|
194
|
-
const visibleColumns = React.useMemo(() => columns.filter((c) => columnVisibility[c.id] !== false), [columns, columnVisibility]);
|
|
195
|
-
const setColumnHidden = React.useCallback((id, hidden) => {
|
|
196
|
-
setColumnVisibility((prev) => (Object.assign(Object.assign({}, prev), { [id]: !hidden })));
|
|
197
|
-
}, []);
|
|
198
|
-
const setColumnWidth = React.useCallback((id, width) => {
|
|
199
|
-
setColumnWidths((prev) => (Object.assign(Object.assign({}, prev), { [id]: width })));
|
|
200
|
-
}, []);
|
|
201
|
-
React.useEffect(() => {
|
|
202
|
-
if (!(preferences === null || preferences === void 0 ? void 0 : preferences.storageKey))
|
|
203
|
-
return;
|
|
204
|
-
writePersisted(preferences.storageKey, {
|
|
205
|
-
columnVisibility,
|
|
206
|
-
columnWidths,
|
|
207
|
-
density,
|
|
208
|
-
pageSize,
|
|
209
|
-
});
|
|
210
|
-
}, [
|
|
211
|
-
preferences === null || preferences === void 0 ? void 0 : preferences.storageKey,
|
|
212
|
-
columnVisibility,
|
|
213
|
-
columnWidths,
|
|
214
|
-
density,
|
|
215
|
-
pageSize,
|
|
216
|
-
]);
|
|
217
|
-
React.useEffect(() => {
|
|
218
|
-
if (!(persisted === null || persisted === void 0 ? void 0 : persisted.density))
|
|
219
|
-
setDensity(densityProp);
|
|
220
|
-
}, [densityProp, persisted === null || persisted === void 0 ? void 0 : persisted.density]);
|
|
221
|
-
return {
|
|
222
|
-
pageData,
|
|
223
|
-
processed,
|
|
224
|
-
pageCount,
|
|
225
|
-
visibleColumns,
|
|
226
|
-
columnVisibility,
|
|
227
|
-
setColumnHidden,
|
|
228
|
-
columnWidths,
|
|
229
|
-
setColumnWidth,
|
|
230
|
-
density,
|
|
231
|
-
setDensity,
|
|
232
|
-
sort,
|
|
233
|
-
setSort,
|
|
234
|
-
filters,
|
|
235
|
-
setFilters,
|
|
236
|
-
searchQuery,
|
|
237
|
-
setSearchQuery,
|
|
238
|
-
selection,
|
|
239
|
-
toggleRow,
|
|
240
|
-
toggleAll,
|
|
241
|
-
clearSelection,
|
|
242
|
-
isAllSelected,
|
|
243
|
-
isSomeSelected,
|
|
244
|
-
pageIndex,
|
|
245
|
-
pageSize,
|
|
246
|
-
setPage,
|
|
247
|
-
setPageSize: (size) => {
|
|
248
|
-
setPageSize(size);
|
|
249
|
-
setPageIndex(0);
|
|
250
|
-
onPageChange === null || onPageChange === void 0 ? void 0 : onPageChange(0, size);
|
|
251
|
-
},
|
|
252
|
-
allRowKeys,
|
|
253
|
-
};
|
|
254
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
export interface UseTableKeyboardOptions {
|
|
3
|
-
/** Row count currently rendered. */
|
|
4
|
-
rowCount: number;
|
|
5
|
-
/** Visible column count (excluding selection column). */
|
|
6
|
-
columnCount: number;
|
|
7
|
-
/** Total interactive columns including selection column at index 0. */
|
|
8
|
-
hasSelectionColumn: boolean;
|
|
9
|
-
onActivateRow: (rowIndex: number) => void;
|
|
10
|
-
onToggleRow: (rowIndex: number) => void;
|
|
11
|
-
onClearSelection: () => void;
|
|
12
|
-
}
|
|
13
|
-
export interface KeyboardCellPos {
|
|
14
|
-
row: number;
|
|
15
|
-
col: number;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Manages a single tab-focused active cell with arrow / Home / End / Ctrl+Home /
|
|
19
|
-
* Ctrl+End / Space / Enter / Escape semantics for grid navigation.
|
|
20
|
-
*/
|
|
21
|
-
export declare function useTableKeyboard({ rowCount, columnCount, hasSelectionColumn, onActivateRow, onToggleRow, onClearSelection, }: UseTableKeyboardOptions): {
|
|
22
|
-
active: KeyboardCellPos;
|
|
23
|
-
setActive: React.Dispatch<React.SetStateAction<KeyboardCellPos>>;
|
|
24
|
-
handleKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
|
|
25
|
-
};
|
|
@@ -1,112 +0,0 @@
|
|
|
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.useTableKeyboard = useTableKeyboard;
|
|
37
|
-
const React = __importStar(require("react"));
|
|
38
|
-
/**
|
|
39
|
-
* Manages a single tab-focused active cell with arrow / Home / End / Ctrl+Home /
|
|
40
|
-
* Ctrl+End / Space / Enter / Escape semantics for grid navigation.
|
|
41
|
-
*/
|
|
42
|
-
function useTableKeyboard({ rowCount, columnCount, hasSelectionColumn, onActivateRow, onToggleRow, onClearSelection, }) {
|
|
43
|
-
const [active, setActive] = React.useState({ row: 0, col: 0 });
|
|
44
|
-
const totalCols = columnCount + (hasSelectionColumn ? 1 : 0);
|
|
45
|
-
React.useEffect(() => {
|
|
46
|
-
setActive((prev) => ({
|
|
47
|
-
row: Math.min(Math.max(prev.row, -1), Math.max(rowCount - 1, 0)),
|
|
48
|
-
col: Math.min(Math.max(prev.col, 0), Math.max(totalCols - 1, 0)),
|
|
49
|
-
}));
|
|
50
|
-
}, [rowCount, totalCols]);
|
|
51
|
-
const handleKeyDown = React.useCallback((event) => {
|
|
52
|
-
const { row, col } = active;
|
|
53
|
-
const target = event.target;
|
|
54
|
-
const isFromInput = target.tagName === "INPUT" ||
|
|
55
|
-
target.tagName === "TEXTAREA" ||
|
|
56
|
-
target.tagName === "SELECT" ||
|
|
57
|
-
target.isContentEditable;
|
|
58
|
-
switch (event.key) {
|
|
59
|
-
case "ArrowLeft":
|
|
60
|
-
event.preventDefault();
|
|
61
|
-
setActive({ row, col: Math.max(0, col - 1) });
|
|
62
|
-
return;
|
|
63
|
-
case "ArrowRight":
|
|
64
|
-
event.preventDefault();
|
|
65
|
-
setActive({ row, col: Math.min(totalCols - 1, col + 1) });
|
|
66
|
-
return;
|
|
67
|
-
case "ArrowUp":
|
|
68
|
-
event.preventDefault();
|
|
69
|
-
setActive({ row: Math.max(-1, row - 1), col });
|
|
70
|
-
return;
|
|
71
|
-
case "ArrowDown":
|
|
72
|
-
event.preventDefault();
|
|
73
|
-
setActive({ row: Math.min(rowCount - 1, row + 1), col });
|
|
74
|
-
return;
|
|
75
|
-
case "Home":
|
|
76
|
-
event.preventDefault();
|
|
77
|
-
setActive(event.ctrlKey || event.metaKey
|
|
78
|
-
? { row: 0, col: 0 }
|
|
79
|
-
: { row, col: 0 });
|
|
80
|
-
return;
|
|
81
|
-
case "End":
|
|
82
|
-
event.preventDefault();
|
|
83
|
-
setActive(event.ctrlKey || event.metaKey
|
|
84
|
-
? { row: rowCount - 1, col: totalCols - 1 }
|
|
85
|
-
: { row, col: totalCols - 1 });
|
|
86
|
-
return;
|
|
87
|
-
case " ":
|
|
88
|
-
if (isFromInput)
|
|
89
|
-
return;
|
|
90
|
-
if (row >= 0) {
|
|
91
|
-
event.preventDefault();
|
|
92
|
-
onToggleRow(row);
|
|
93
|
-
}
|
|
94
|
-
return;
|
|
95
|
-
case "Enter":
|
|
96
|
-
if (isFromInput)
|
|
97
|
-
return;
|
|
98
|
-
if (row >= 0) {
|
|
99
|
-
event.preventDefault();
|
|
100
|
-
onActivateRow(row);
|
|
101
|
-
}
|
|
102
|
-
return;
|
|
103
|
-
case "Escape":
|
|
104
|
-
event.preventDefault();
|
|
105
|
-
onClearSelection();
|
|
106
|
-
return;
|
|
107
|
-
default:
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
}, [active, totalCols, rowCount, onActivateRow, onToggleRow, onClearSelection]);
|
|
111
|
-
return { active, setActive, handleKeyDown };
|
|
112
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
export interface UseVirtualScrollOptions {
|
|
3
|
-
rowCount: number;
|
|
4
|
-
rowHeight: number;
|
|
5
|
-
/** Force virtualization on/off; otherwise auto-enable above threshold. */
|
|
6
|
-
enabled?: boolean;
|
|
7
|
-
threshold?: number;
|
|
8
|
-
/** Extra rows rendered above/below the viewport. */
|
|
9
|
-
overscan?: number;
|
|
10
|
-
/** Viewport element. */
|
|
11
|
-
scrollContainerRef: React.RefObject<HTMLElement>;
|
|
12
|
-
}
|
|
13
|
-
export interface VirtualWindow {
|
|
14
|
-
/** Index of first row to render (inclusive). */
|
|
15
|
-
startIndex: number;
|
|
16
|
-
/** Index of last row to render (exclusive). */
|
|
17
|
-
endIndex: number;
|
|
18
|
-
/** Spacer height before the rendered slice. */
|
|
19
|
-
paddingTop: number;
|
|
20
|
-
/** Spacer height after the rendered slice. */
|
|
21
|
-
paddingBottom: number;
|
|
22
|
-
/** Whether virtualization is currently active. */
|
|
23
|
-
active: boolean;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Lightweight fixed-row-height virtual scroller. Avoids pulling in the full
|
|
27
|
-
* react-window dependency for the common case.
|
|
28
|
-
*/
|
|
29
|
-
export declare function useVirtualScroll({ rowCount, rowHeight, enabled, threshold, overscan, scrollContainerRef, }: UseVirtualScrollOptions): VirtualWindow;
|
|
@@ -1,83 +0,0 @@
|
|
|
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.useVirtualScroll = useVirtualScroll;
|
|
37
|
-
const React = __importStar(require("react"));
|
|
38
|
-
/**
|
|
39
|
-
* Lightweight fixed-row-height virtual scroller. Avoids pulling in the full
|
|
40
|
-
* react-window dependency for the common case.
|
|
41
|
-
*/
|
|
42
|
-
function useVirtualScroll({ rowCount, rowHeight, enabled, threshold = 500, overscan = 8, scrollContainerRef, }) {
|
|
43
|
-
const active = enabled !== null && enabled !== void 0 ? enabled : rowCount > threshold;
|
|
44
|
-
const [scrollTop, setScrollTop] = React.useState(0);
|
|
45
|
-
const [viewportHeight, setViewportHeight] = React.useState(600);
|
|
46
|
-
React.useEffect(() => {
|
|
47
|
-
if (!active)
|
|
48
|
-
return;
|
|
49
|
-
const node = scrollContainerRef.current;
|
|
50
|
-
if (!node)
|
|
51
|
-
return;
|
|
52
|
-
const onScroll = () => setScrollTop(node.scrollTop);
|
|
53
|
-
const onResize = () => setViewportHeight(node.clientHeight);
|
|
54
|
-
onResize();
|
|
55
|
-
node.addEventListener("scroll", onScroll, { passive: true });
|
|
56
|
-
const ro = new ResizeObserver(onResize);
|
|
57
|
-
ro.observe(node);
|
|
58
|
-
return () => {
|
|
59
|
-
node.removeEventListener("scroll", onScroll);
|
|
60
|
-
ro.disconnect();
|
|
61
|
-
};
|
|
62
|
-
}, [active, scrollContainerRef]);
|
|
63
|
-
if (!active) {
|
|
64
|
-
return {
|
|
65
|
-
startIndex: 0,
|
|
66
|
-
endIndex: rowCount,
|
|
67
|
-
paddingTop: 0,
|
|
68
|
-
paddingBottom: 0,
|
|
69
|
-
active: false,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
const firstVisible = Math.floor(scrollTop / rowHeight);
|
|
73
|
-
const visibleCount = Math.ceil(viewportHeight / rowHeight);
|
|
74
|
-
const startIndex = Math.max(0, firstVisible - overscan);
|
|
75
|
-
const endIndex = Math.min(rowCount, firstVisible + visibleCount + overscan);
|
|
76
|
-
return {
|
|
77
|
-
startIndex,
|
|
78
|
-
endIndex,
|
|
79
|
-
paddingTop: startIndex * rowHeight,
|
|
80
|
-
paddingBottom: Math.max(0, (rowCount - endIndex) * rowHeight),
|
|
81
|
-
active: true,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import type { ColumnDef } from "../TableProps";
|
|
3
|
-
export interface ManageColumnsProps<T> {
|
|
4
|
-
columns: ColumnDef<T>[];
|
|
5
|
-
columnVisibility: Record<string, boolean>;
|
|
6
|
-
onChange: (id: string, hidden: boolean) => void;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Toolbar dropdown for toggling column visibility. Columns with
|
|
10
|
-
* `enableHiding === false` are non-toggleable.
|
|
11
|
-
*/
|
|
12
|
-
export declare function ManageColumns<T>({ columns, columnVisibility, onChange, }: ManageColumnsProps<T>): React.ReactElement;
|