react-restyle-components 0.4.23 → 0.4.24
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/lib/src/core-components/src/components/AlertBanner/AlertBanner.d.ts +4 -0
- package/lib/src/core-components/src/components/AlertBanner/AlertBanner.d.ts.map +1 -0
- package/lib/src/core-components/src/components/AlertBanner/AlertBanner.js +45 -0
- package/lib/src/core-components/src/components/AlertBanner/elements.d.ts +27 -0
- package/lib/src/core-components/src/components/AlertBanner/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/AlertBanner/elements.js +233 -0
- package/lib/src/core-components/src/components/AlertBanner/index.d.ts +3 -0
- package/lib/src/core-components/src/components/AlertBanner/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/AlertBanner/index.js +2 -0
- package/lib/src/core-components/src/components/AlertBanner/types.d.ts +46 -0
- package/lib/src/core-components/src/components/AlertBanner/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/AlertBanner/types.js +10 -0
- package/lib/src/core-components/src/components/AutoComplete/auto-complete-filter-multiple-select-multiple-fields-display/auto-complete-filter-multiple-select-multiple-fields-display.component.d.ts.map +1 -1
- package/lib/src/core-components/src/components/Badge/Badge.d.ts +33 -33
- package/lib/src/core-components/src/components/Breadcrumb/Breadcrumb.d.ts +28 -0
- package/lib/src/core-components/src/components/Breadcrumb/Breadcrumb.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Breadcrumb/Breadcrumb.js +83 -0
- package/lib/src/core-components/src/components/Breadcrumb/elements.d.ts +44 -0
- package/lib/src/core-components/src/components/Breadcrumb/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Breadcrumb/elements.js +370 -0
- package/lib/src/core-components/src/components/Breadcrumb/index.d.ts +4 -0
- package/lib/src/core-components/src/components/Breadcrumb/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Breadcrumb/index.js +3 -0
- package/lib/src/core-components/src/components/Breadcrumb/types.d.ts +14 -0
- package/lib/src/core-components/src/components/Breadcrumb/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Breadcrumb/types.js +3 -0
- package/lib/src/core-components/src/components/Button/Button.spec.js +1 -1
- package/lib/src/core-components/src/components/Button/button.component.js +1 -1
- package/lib/src/core-components/src/components/Chip/Chip.d.ts +5 -0
- package/lib/src/core-components/src/components/Chip/Chip.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Chip/Chip.js +64 -0
- package/lib/src/core-components/src/components/Chip/elements.d.ts +27 -0
- package/lib/src/core-components/src/components/Chip/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Chip/elements.js +253 -0
- package/lib/src/core-components/src/components/Chip/index.d.ts +3 -0
- package/lib/src/core-components/src/components/Chip/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Chip/index.js +2 -0
- package/lib/src/core-components/src/components/Chip/types.d.ts +54 -0
- package/lib/src/core-components/src/components/Chip/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Chip/types.js +4 -0
- package/lib/src/core-components/src/components/Divider/Divider.d.ts +4 -0
- package/lib/src/core-components/src/components/Divider/Divider.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Divider/Divider.js +25 -0
- package/lib/src/core-components/src/components/Divider/elements.d.ts +22 -0
- package/lib/src/core-components/src/components/Divider/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Divider/elements.js +103 -0
- package/lib/src/core-components/src/components/Divider/index.d.ts +3 -0
- package/lib/src/core-components/src/components/Divider/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Divider/index.js +2 -0
- package/lib/src/core-components/src/components/Divider/types.d.ts +30 -0
- package/lib/src/core-components/src/components/Divider/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Divider/types.js +4 -0
- package/lib/src/core-components/src/components/DynamicGrid/DynamicGrid.d.ts +6 -0
- package/lib/src/core-components/src/components/DynamicGrid/DynamicGrid.d.ts.map +1 -0
- package/lib/src/core-components/src/components/DynamicGrid/DynamicGrid.js +147 -0
- package/lib/src/core-components/src/components/DynamicGrid/GridContainer.d.ts +12 -0
- package/lib/src/core-components/src/components/DynamicGrid/GridContainer.d.ts.map +1 -0
- package/lib/src/core-components/src/components/DynamicGrid/GridContainer.js +89 -0
- package/lib/src/core-components/src/components/DynamicGrid/elements.d.ts +49 -0
- package/lib/src/core-components/src/components/DynamicGrid/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/DynamicGrid/elements.js +409 -0
- package/lib/src/core-components/src/components/DynamicGrid/index.d.ts +4 -0
- package/lib/src/core-components/src/components/DynamicGrid/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/DynamicGrid/index.js +3 -0
- package/lib/src/core-components/src/components/DynamicGrid/types.d.ts +173 -0
- package/lib/src/core-components/src/components/DynamicGrid/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/DynamicGrid/types.js +28 -0
- package/lib/src/core-components/src/components/DynamicGrid/utils.d.ts +65 -0
- package/lib/src/core-components/src/components/DynamicGrid/utils.d.ts.map +1 -0
- package/lib/src/core-components/src/components/DynamicGrid/utils.js +193 -0
- package/lib/src/core-components/src/components/FormField/FormField.d.ts +1 -1
- package/lib/src/core-components/src/components/Icon/Icon.js +1 -1
- package/lib/src/core-components/src/components/Masonry/Masonry.d.ts +7 -0
- package/lib/src/core-components/src/components/Masonry/Masonry.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Masonry/Masonry.js +73 -0
- package/lib/src/core-components/src/components/Masonry/elements.d.ts +31 -0
- package/lib/src/core-components/src/components/Masonry/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Masonry/elements.js +122 -0
- package/lib/src/core-components/src/components/Masonry/hooks.d.ts +21 -0
- package/lib/src/core-components/src/components/Masonry/hooks.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Masonry/hooks.js +100 -0
- package/lib/src/core-components/src/components/Masonry/index.d.ts +4 -0
- package/lib/src/core-components/src/components/Masonry/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Masonry/index.js +3 -0
- package/lib/src/core-components/src/components/Masonry/types.d.ts +117 -0
- package/lib/src/core-components/src/components/Masonry/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Masonry/types.js +1 -0
- package/lib/src/core-components/src/components/Picker/color-picker-modal/color-picker-modal.component.js +1 -1
- package/lib/src/core-components/src/components/Skeleton/Skeleton.d.ts +8 -0
- package/lib/src/core-components/src/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Skeleton/Skeleton.js +51 -0
- package/lib/src/core-components/src/components/Skeleton/elements.d.ts +33 -0
- package/lib/src/core-components/src/components/Skeleton/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Skeleton/elements.js +238 -0
- package/lib/src/core-components/src/components/Skeleton/index.d.ts +3 -0
- package/lib/src/core-components/src/components/Skeleton/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Skeleton/index.js +2 -0
- package/lib/src/core-components/src/components/Skeleton/types.d.ts +80 -0
- package/lib/src/core-components/src/components/Skeleton/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Skeleton/types.js +4 -0
- package/lib/src/core-components/src/components/SpeedDial/SpeedDial.d.ts +4 -0
- package/lib/src/core-components/src/components/SpeedDial/SpeedDial.d.ts.map +1 -0
- package/lib/src/core-components/src/components/SpeedDial/SpeedDial.js +128 -0
- package/lib/src/core-components/src/components/SpeedDial/elements.d.ts +57 -0
- package/lib/src/core-components/src/components/SpeedDial/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/SpeedDial/elements.js +299 -0
- package/lib/src/core-components/src/components/SpeedDial/index.d.ts +3 -0
- package/lib/src/core-components/src/components/SpeedDial/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/SpeedDial/index.js +2 -0
- package/lib/src/core-components/src/components/SpeedDial/types.d.ts +149 -0
- package/lib/src/core-components/src/components/SpeedDial/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/SpeedDial/types.js +3 -0
- package/lib/src/core-components/src/components/Switch/Switch.d.ts +4 -0
- package/lib/src/core-components/src/components/Switch/Switch.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Switch/Switch.js +26 -0
- package/lib/src/core-components/src/components/Switch/elements.d.ts +33 -0
- package/lib/src/core-components/src/components/Switch/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Switch/elements.js +167 -0
- package/lib/src/core-components/src/components/Switch/index.d.ts +3 -0
- package/lib/src/core-components/src/components/Switch/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Switch/index.js +2 -0
- package/lib/src/core-components/src/components/Switch/types.d.ts +32 -0
- package/lib/src/core-components/src/components/Switch/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Switch/types.js +3 -0
- package/lib/src/core-components/src/components/Table/Table.d.ts +7 -0
- package/lib/src/core-components/src/components/Table/Table.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Table/Table.js +357 -0
- package/lib/src/core-components/src/components/Table/elements.d.ts +89 -0
- package/lib/src/core-components/src/components/Table/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Table/elements.js +604 -0
- package/lib/src/core-components/src/components/Table/filters.d.ts +23 -0
- package/lib/src/core-components/src/components/Table/filters.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Table/filters.js +181 -0
- package/lib/src/core-components/src/components/Table/hooks.d.ts +107 -0
- package/lib/src/core-components/src/components/Table/hooks.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Table/hooks.js +451 -0
- package/lib/src/core-components/src/components/Table/index.d.ts +5 -0
- package/lib/src/core-components/src/components/Table/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Table/index.js +4 -0
- package/lib/src/core-components/src/components/Table/types.d.ts +358 -0
- package/lib/src/core-components/src/components/Table/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Table/types.js +1 -0
- package/lib/src/core-components/src/components/Toast/Toast.d.ts +5 -0
- package/lib/src/core-components/src/components/Toast/Toast.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Toast/Toast.js +50 -0
- package/lib/src/core-components/src/components/Toast/elements.d.ts +28 -0
- package/lib/src/core-components/src/components/Toast/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Toast/elements.js +272 -0
- package/lib/src/core-components/src/components/Toast/index.d.ts +3 -0
- package/lib/src/core-components/src/components/Toast/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Toast/index.js +2 -0
- package/lib/src/core-components/src/components/Toast/types.d.ts +52 -0
- package/lib/src/core-components/src/components/Toast/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Toast/types.js +9 -0
- package/lib/src/core-components/src/components/Tooltip/Tooltip.d.ts +7 -0
- package/lib/src/core-components/src/components/Tooltip/Tooltip.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Tooltip/Tooltip.js +200 -0
- package/lib/src/core-components/src/components/Tooltip/elements.d.ts +19 -0
- package/lib/src/core-components/src/components/Tooltip/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Tooltip/elements.js +195 -0
- package/lib/src/core-components/src/components/Tooltip/index.d.ts +3 -0
- package/lib/src/core-components/src/components/Tooltip/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Tooltip/index.js +2 -0
- package/lib/src/core-components/src/components/Tooltip/types.d.ts +81 -17
- package/lib/src/core-components/src/components/Tooltip/types.d.ts.map +1 -1
- package/lib/src/core-components/src/components/Tooltip/types.js +17 -1
- package/lib/src/core-components/src/components/Tooltip/utils.d.ts +26 -0
- package/lib/src/core-components/src/components/Tooltip/utils.d.ts.map +1 -0
- package/lib/src/core-components/src/components/Tooltip/utils.js +140 -0
- package/lib/src/core-components/src/components/TreeSelect/TreeSelect.d.ts +5 -0
- package/lib/src/core-components/src/components/TreeSelect/TreeSelect.d.ts.map +1 -0
- package/lib/src/core-components/src/components/TreeSelect/TreeSelect.js +303 -0
- package/lib/src/core-components/src/components/TreeSelect/elements.d.ts +74 -0
- package/lib/src/core-components/src/components/TreeSelect/elements.d.ts.map +1 -0
- package/lib/src/core-components/src/components/TreeSelect/elements.js +494 -0
- package/lib/src/core-components/src/components/TreeSelect/hooks.d.ts +57 -0
- package/lib/src/core-components/src/components/TreeSelect/hooks.d.ts.map +1 -0
- package/lib/src/core-components/src/components/TreeSelect/hooks.js +252 -0
- package/lib/src/core-components/src/components/TreeSelect/index.d.ts +4 -0
- package/lib/src/core-components/src/components/TreeSelect/index.d.ts.map +1 -0
- package/lib/src/core-components/src/components/TreeSelect/index.js +3 -0
- package/lib/src/core-components/src/components/TreeSelect/types.d.ts +205 -0
- package/lib/src/core-components/src/components/TreeSelect/types.d.ts.map +1 -0
- package/lib/src/core-components/src/components/TreeSelect/types.js +1 -0
- package/lib/src/core-components/src/components/index.d.ts +13 -1
- package/lib/src/core-components/src/components/index.d.ts.map +1 -1
- package/lib/src/core-components/src/components/index.js +14 -1
- package/lib/src/core-components/src/core-components/CoreButton/CoreButton.d.ts +2 -2
- package/lib/src/core-components/src/tc.global.css +7 -3
- package/lib/src/core-components/src/tc.module.css +2 -2
- package/package.json +1 -1
- package/lib/src/core-components/src/components/Tooltip/tooltip.component.d.ts +0 -29
- package/lib/src/core-components/src/components/Tooltip/tooltip.component.d.ts.map +0 -1
- package/lib/src/core-components/src/components/Tooltip/tooltip.component.js +0 -10
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { forwardRef, useState, useCallback, useMemo, useRef, } from 'react';
|
|
4
|
+
import { TableRoot, Toolbar, ToolbarGroup, SearchInput, ToolbarButton, TableWrapper, StyledTable, TableHeader, HeaderRow, HeaderCell, SortIcon, FilterRow, FilterCell, TableBody, TableRow, TableCell, Checkbox, ExpandButton, ExpandedRow, ExpandedCell, TableFooter, FooterRow, FooterCell, PaginationWrapper, PaginationInfo, PaginationControls, PageButton, PageSizeSelect, QuickJumper, EmptyState, LoadingOverlay, LoadingSpinner, EditableCell, CellEditor, ColumnTogglePanel, ColumnToggleHeader, ColumnToggleSearch, ColumnToggleList, ColumnToggleItem, } from './elements';
|
|
5
|
+
import { useSortState, useFilterState, usePaginationState, useRowSelection, useRowExpansion, useColumnVisibility, useTableDebounce, sortData, filterData, paginateData, getNestedValue, exportToCSV, } from './hooks';
|
|
6
|
+
import { getFilterComponent } from './filters';
|
|
7
|
+
// Icons
|
|
8
|
+
const SearchIcon = () => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [_jsx("circle", { cx: "11", cy: "11", r: "8" }), _jsx("path", { d: "M21 21l-4.35-4.35", strokeLinecap: "round" })] }));
|
|
9
|
+
const SortUpIcon = () => (_jsx("svg", { viewBox: "0 0 10 10", fill: "currentColor", children: _jsx("path", { d: "M5 0L10 6H0L5 0z" }) }));
|
|
10
|
+
const SortDownIcon = () => (_jsx("svg", { viewBox: "0 0 10 10", fill: "currentColor", children: _jsx("path", { d: "M5 10L0 4h10L5 10z" }) }));
|
|
11
|
+
const ChevronLeftIcon = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: _jsx("path", { d: "M15 18l-6-6 6-6", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
12
|
+
const ChevronRightIcon = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: _jsx("path", { d: "M9 18l6-6-6-6", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
13
|
+
const ChevronsLeftIcon = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: _jsx("path", { d: "M11 17l-5-5 5-5M18 17l-5-5 5-5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
14
|
+
const ChevronsRightIcon = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: _jsx("path", { d: "M13 7l5 5-5 5M6 7l5 5-5 5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
15
|
+
const ExpandIcon = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: _jsx("path", { d: "M9 18l6-6-6-6", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
16
|
+
const CloseIcon = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: _jsx("path", { d: "M18 6L6 18M6 6l12 12", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
17
|
+
const FilterIcon = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: _jsx("path", { d: "M22 3H2l8 9.46V19l4 2v-8.54L22 3z", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
18
|
+
const DownloadIcon = () => (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: _jsx("path", { d: "M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
19
|
+
const ColumnsIcon = () => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [_jsx("rect", { x: "3", y: "3", width: "7", height: "18", rx: "1" }), _jsx("rect", { x: "14", y: "3", width: "7", height: "18", rx: "1" })] }));
|
|
20
|
+
const EmptyIcon = () => (_jsxs("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [_jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }), _jsx("path", { d: "M3 9h18M9 3v18", strokeLinecap: "round" })] }));
|
|
21
|
+
export const Table = forwardRef(function TableComponent(props, ref) {
|
|
22
|
+
const { id, data, columns, keyField = '_id', loading = false, loadingIndicator, pagination = true, paginationConfig, totalSize, remote = false, defaultSort, sort: controlledSort, filterable = false, defaultFilters, filters: controlledFilters, searchable = false, searchPlaceholder = 'Search...', defaultSearchValue = '', searchValue: controlledSearchValue, searchDebounce = 300, rowSelection, expandable, editMode = 'none', onCellEdit, exportable = false, exportFileName = 'table_export', columnToggle = false, bordered = true, striped = false, hover = true, compact = false, stickyHeader = false, maxHeight, rowClassName, rowStyle, classNames = {}, styles = {}, className, style, emptyText = 'No data available', onChange, onPageChange, onSortChange, onFilterChange, onSearch, onRowClick, onRowDoubleClick, onClearFilters, toolbar, hideToolbar = false, showFooter = false, caption, ...rest } = props;
|
|
23
|
+
// Refs
|
|
24
|
+
const tableRef = useRef(null);
|
|
25
|
+
// State
|
|
26
|
+
const [internalSearchValue, setInternalSearchValue] = useState(defaultSearchValue);
|
|
27
|
+
const [columnToggleOpen, setColumnToggleOpen] = useState(false);
|
|
28
|
+
const [columnSearch, setColumnSearch] = useState('');
|
|
29
|
+
const [editingCell, setEditingCell] = useState(null);
|
|
30
|
+
const [editValue, setEditValue] = useState(null);
|
|
31
|
+
const searchValue = controlledSearchValue ?? internalSearchValue;
|
|
32
|
+
const debouncedSearchValue = useTableDebounce(searchValue, searchDebounce);
|
|
33
|
+
// Sort state
|
|
34
|
+
const { sort, handleSort } = useSortState(defaultSort, controlledSort);
|
|
35
|
+
// Filter state
|
|
36
|
+
const { filters, setFilter, clearFilters } = useFilterState(defaultFilters, controlledFilters);
|
|
37
|
+
// Pagination state
|
|
38
|
+
const { page, pageSize, totalPages, goToPage, goToNextPage, goToPrevPage, goToFirstPage, goToLastPage, changePageSize, } = usePaginationState(paginationConfig?.page || 0, paginationConfig?.pageSize || 10, totalSize ?? data.length);
|
|
39
|
+
// Row selection
|
|
40
|
+
const { selectedKeys, isSelected, toggleRow, toggleAll, isAllSelected, isIndeterminate, } = useRowSelection(data, rowSelection?.keyField || keyField, rowSelection?.mode || 'none', rowSelection?.selectedRowKeys, rowSelection?.getCheckboxProps);
|
|
41
|
+
// Row expansion
|
|
42
|
+
const { expandedKeys, isExpanded, toggleExpand } = useRowExpansion(expandable?.keyField || keyField, expandable?.defaultExpandedRowKeys, expandable?.expandedRowKeys, expandable?.accordion);
|
|
43
|
+
// Column visibility
|
|
44
|
+
const { visibleColumns, toggleColumn, isColumnHidden } = useColumnVisibility(columns, id);
|
|
45
|
+
// Process data (filter, sort, paginate)
|
|
46
|
+
const processedData = useMemo(() => {
|
|
47
|
+
if (remote) {
|
|
48
|
+
// Server-side processing - data is already processed
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
51
|
+
let result = [...data];
|
|
52
|
+
// Filter
|
|
53
|
+
result = filterData(result, filters, columns, debouncedSearchValue);
|
|
54
|
+
// Sort
|
|
55
|
+
result = sortData(result, sort, columns);
|
|
56
|
+
// Paginate
|
|
57
|
+
if (pagination) {
|
|
58
|
+
result = paginateData(result, page, pageSize);
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}, [data, filters, sort, page, pageSize, debouncedSearchValue, remote, pagination, columns]);
|
|
62
|
+
// Calculate total for client-side
|
|
63
|
+
const calculatedTotal = useMemo(() => {
|
|
64
|
+
if (remote)
|
|
65
|
+
return totalSize || data.length;
|
|
66
|
+
return filterData(data, filters, columns, debouncedSearchValue).length;
|
|
67
|
+
}, [data, filters, columns, debouncedSearchValue, remote, totalSize]);
|
|
68
|
+
// Handle search
|
|
69
|
+
const handleSearchChange = useCallback((value) => {
|
|
70
|
+
setInternalSearchValue(value);
|
|
71
|
+
onSearch?.(value);
|
|
72
|
+
onChange?.({ type: 'search', search: value });
|
|
73
|
+
}, [onSearch, onChange]);
|
|
74
|
+
// Handle sort
|
|
75
|
+
const handleSortClick = useCallback((column) => {
|
|
76
|
+
if (!column.sort)
|
|
77
|
+
return;
|
|
78
|
+
const newSort = handleSort(column.dataField, sort.order);
|
|
79
|
+
onSortChange?.(newSort);
|
|
80
|
+
onChange?.({ type: 'sort', sort: newSort });
|
|
81
|
+
}, [sort, handleSort, onSortChange, onChange]);
|
|
82
|
+
// Handle filter
|
|
83
|
+
const handleFilterChange = useCallback((field, value) => {
|
|
84
|
+
setFilter(field, value);
|
|
85
|
+
onFilterChange?.({ ...filters, [field]: value });
|
|
86
|
+
onChange?.({ type: 'filter', filters: { ...filters, [field]: value } });
|
|
87
|
+
}, [filters, setFilter, onFilterChange, onChange]);
|
|
88
|
+
// Handle clear all filters
|
|
89
|
+
const handleClearFilters = useCallback(() => {
|
|
90
|
+
clearFilters();
|
|
91
|
+
setInternalSearchValue('');
|
|
92
|
+
onClearFilters?.();
|
|
93
|
+
onFilterChange?.({});
|
|
94
|
+
onChange?.({ type: 'filter', filters: {} });
|
|
95
|
+
}, [clearFilters, onClearFilters, onFilterChange, onChange]);
|
|
96
|
+
// Handle page change
|
|
97
|
+
const handlePageChange = useCallback((newPage) => {
|
|
98
|
+
goToPage(newPage);
|
|
99
|
+
onPageChange?.(newPage, pageSize);
|
|
100
|
+
onChange?.({ type: 'pagination', pagination: { page: newPage, pageSize } });
|
|
101
|
+
}, [goToPage, pageSize, onPageChange, onChange]);
|
|
102
|
+
// Handle page size change
|
|
103
|
+
const handlePageSizeChange = useCallback((newSize) => {
|
|
104
|
+
changePageSize(newSize);
|
|
105
|
+
onPageChange?.(0, newSize);
|
|
106
|
+
onChange?.({ type: 'pagination', pagination: { page: 0, pageSize: newSize } });
|
|
107
|
+
}, [changePageSize, onPageChange, onChange]);
|
|
108
|
+
// Handle row click
|
|
109
|
+
const handleRowClick = useCallback((row, rowIndex, e) => {
|
|
110
|
+
// Selection handling
|
|
111
|
+
if (rowSelection?.mode && rowSelection.mode !== 'none') {
|
|
112
|
+
const result = toggleRow(row);
|
|
113
|
+
if (result) {
|
|
114
|
+
rowSelection.onChange?.(result.selectedKeys, result.selectedRows);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Expand by click
|
|
118
|
+
if (expandable?.expandRowByClick) {
|
|
119
|
+
const result = toggleExpand(row);
|
|
120
|
+
if (result) {
|
|
121
|
+
expandable.onExpandChange?.(result.expandedKeys, result.expanded, row);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
onRowClick?.(row, rowIndex, e);
|
|
125
|
+
}, [rowSelection, expandable, toggleRow, toggleExpand, onRowClick]);
|
|
126
|
+
// Handle cell edit
|
|
127
|
+
const handleCellDoubleClick = useCallback((row, rowIndex, column, e) => {
|
|
128
|
+
if (editMode === 'none' || !column.editable)
|
|
129
|
+
return;
|
|
130
|
+
if (editMode === 'dblclick') {
|
|
131
|
+
setEditingCell({ row: rowIndex, field: column.dataField });
|
|
132
|
+
setEditValue(getNestedValue(row, column.dataField));
|
|
133
|
+
}
|
|
134
|
+
onRowDoubleClick?.(row, rowIndex, e);
|
|
135
|
+
}, [editMode, onRowDoubleClick]);
|
|
136
|
+
const handleCellClick = useCallback((row, rowIndex, column) => {
|
|
137
|
+
if (editMode !== 'click' || !column.editable)
|
|
138
|
+
return;
|
|
139
|
+
setEditingCell({ row: rowIndex, field: column.dataField });
|
|
140
|
+
setEditValue(getNestedValue(row, column.dataField));
|
|
141
|
+
}, [editMode]);
|
|
142
|
+
const handleCellEditComplete = useCallback((row, rowIndex, column) => {
|
|
143
|
+
if (editingCell) {
|
|
144
|
+
// Validate
|
|
145
|
+
if (column.validator) {
|
|
146
|
+
const result = column.validator(editValue, row);
|
|
147
|
+
if (result !== true) {
|
|
148
|
+
alert(typeof result === 'string' ? result : 'Invalid value');
|
|
149
|
+
setEditingCell(null);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
onCellEdit?.(editValue, column.dataField, row, rowIndex);
|
|
154
|
+
}
|
|
155
|
+
setEditingCell(null);
|
|
156
|
+
}, [editingCell, editValue, onCellEdit]);
|
|
157
|
+
// Handle export
|
|
158
|
+
const handleExport = useCallback(() => {
|
|
159
|
+
const exportData = remote ? data : filterData(data, filters, columns, debouncedSearchValue);
|
|
160
|
+
exportToCSV(exportData, visibleColumns, exportFileName);
|
|
161
|
+
}, [data, filters, columns, debouncedSearchValue, visibleColumns, exportFileName, remote]);
|
|
162
|
+
// Handle checkbox change
|
|
163
|
+
const handleCheckboxChange = useCallback((row, e) => {
|
|
164
|
+
e.stopPropagation();
|
|
165
|
+
const result = toggleRow(row);
|
|
166
|
+
if (result) {
|
|
167
|
+
rowSelection?.onChange?.(result.selectedKeys, result.selectedRows);
|
|
168
|
+
}
|
|
169
|
+
}, [toggleRow, rowSelection]);
|
|
170
|
+
// Handle select all
|
|
171
|
+
const handleSelectAllChange = useCallback(() => {
|
|
172
|
+
const result = toggleAll(!isAllSelected);
|
|
173
|
+
if (result) {
|
|
174
|
+
rowSelection?.onChange?.(result.selectedKeys, result.selectedRows);
|
|
175
|
+
}
|
|
176
|
+
}, [toggleAll, isAllSelected, rowSelection]);
|
|
177
|
+
// Handle expand toggle
|
|
178
|
+
const handleExpandClick = useCallback((row, e) => {
|
|
179
|
+
e.stopPropagation();
|
|
180
|
+
const result = toggleExpand(row);
|
|
181
|
+
expandable?.onExpandChange?.(result.expandedKeys, result.expanded, row);
|
|
182
|
+
}, [toggleExpand, expandable]);
|
|
183
|
+
// Filtered column list for toggle panel
|
|
184
|
+
const filteredToggleColumns = useMemo(() => {
|
|
185
|
+
return columns.filter((c) => c.dataField !== keyField &&
|
|
186
|
+
c.text.toLowerCase().includes(columnSearch.toLowerCase()));
|
|
187
|
+
}, [columns, keyField, columnSearch]);
|
|
188
|
+
// Get row key
|
|
189
|
+
const getRowKey = useCallback((row) => row[keyField], [keyField]);
|
|
190
|
+
// Render cell content
|
|
191
|
+
const renderCellContent = useCallback((row, column, rowIndex, colIndex) => {
|
|
192
|
+
const value = getNestedValue(row, column.dataField);
|
|
193
|
+
const isEditing = editingCell?.row === rowIndex && editingCell?.field === column.dataField;
|
|
194
|
+
if (isEditing) {
|
|
195
|
+
return (_jsx(CellEditor, { type: column.editorType === 'number' ? 'number' : 'text', value: editValue ?? '', onChange: (e) => setEditValue(e.target.value), onBlur: () => handleCellEditComplete(row, rowIndex, column), onKeyDown: (e) => {
|
|
196
|
+
if (e.key === 'Enter') {
|
|
197
|
+
handleCellEditComplete(row, rowIndex, column);
|
|
198
|
+
}
|
|
199
|
+
if (e.key === 'Escape') {
|
|
200
|
+
setEditingCell(null);
|
|
201
|
+
}
|
|
202
|
+
}, autoFocus: true }));
|
|
203
|
+
}
|
|
204
|
+
if (column.formatter) {
|
|
205
|
+
return column.formatter(value, row, rowIndex, colIndex);
|
|
206
|
+
}
|
|
207
|
+
if (value === null || value === undefined)
|
|
208
|
+
return '';
|
|
209
|
+
if (typeof value === 'boolean')
|
|
210
|
+
return value ? 'Yes' : 'No';
|
|
211
|
+
if (typeof value === 'object')
|
|
212
|
+
return JSON.stringify(value);
|
|
213
|
+
return String(value);
|
|
214
|
+
}, [editingCell, editValue, handleCellEditComplete]);
|
|
215
|
+
// Render toolbar
|
|
216
|
+
const renderToolbar = () => {
|
|
217
|
+
if (hideToolbar)
|
|
218
|
+
return null;
|
|
219
|
+
if (typeof toolbar === 'function') {
|
|
220
|
+
return toolbar({
|
|
221
|
+
searchValue,
|
|
222
|
+
onSearch: handleSearchChange,
|
|
223
|
+
onClearFilters: handleClearFilters,
|
|
224
|
+
onExport: handleExport,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
if (toolbar)
|
|
228
|
+
return toolbar;
|
|
229
|
+
const hasFilters = Object.keys(filters).length > 0 || searchValue;
|
|
230
|
+
return (_jsxs(Toolbar, { className: classNames.toolbar, style: styles.toolbar, children: [_jsxs(ToolbarGroup, { children: [searchable && (_jsxs(SearchInput, { children: [_jsx(SearchIcon, {}), _jsx("input", { type: "text", value: searchValue, onChange: (e) => handleSearchChange(e.target.value), placeholder: searchPlaceholder })] })), hasFilters && (_jsxs(ToolbarButton, { onClick: handleClearFilters, children: [_jsx(CloseIcon, {}), "Clear Filters"] }))] }), _jsxs(ToolbarGroup, { children: [exportable && (_jsxs(ToolbarButton, { onClick: handleExport, children: [_jsx(DownloadIcon, {}), "Export"] })), columnToggle && (_jsxs("div", { style: { position: 'relative' }, children: [_jsxs(ToolbarButton, { "$active": columnToggleOpen, onClick: () => setColumnToggleOpen(!columnToggleOpen), children: [_jsx(ColumnsIcon, {}), "Columns"] }), columnToggleOpen && (_jsxs(ColumnTogglePanel, { children: [_jsxs(ColumnToggleHeader, { children: [_jsx("span", { children: "Toggle Columns" }), _jsx("button", { onClick: () => setColumnToggleOpen(false), children: _jsx(CloseIcon, {}) })] }), _jsx(ColumnToggleSearch, { children: _jsx("input", { type: "text", value: columnSearch, onChange: (e) => setColumnSearch(e.target.value), placeholder: "Search columns..." }) }), _jsx(ColumnToggleList, { children: filteredToggleColumns.map((column) => (_jsxs(ColumnToggleItem, { children: [_jsx("input", { type: "checkbox", checked: !isColumnHidden(column.dataField), onChange: () => toggleColumn(column.dataField) }), _jsx("span", { children: column.text })] }, column.dataField))) })] }))] }))] })] }));
|
|
231
|
+
};
|
|
232
|
+
// Render pagination
|
|
233
|
+
const renderPagination = () => {
|
|
234
|
+
if (!pagination)
|
|
235
|
+
return null;
|
|
236
|
+
const actualTotalPages = Math.ceil(calculatedTotal / pageSize) || 1;
|
|
237
|
+
const startItem = page * pageSize + 1;
|
|
238
|
+
const endItem = Math.min((page + 1) * pageSize, calculatedTotal);
|
|
239
|
+
const showTotal = paginationConfig?.showTotal === true
|
|
240
|
+
? `Showing ${startItem} to ${endItem} of ${calculatedTotal} Results`
|
|
241
|
+
: typeof paginationConfig?.showTotal === 'function'
|
|
242
|
+
? paginationConfig.showTotal(calculatedTotal, [startItem, endItem])
|
|
243
|
+
: null;
|
|
244
|
+
// Generate page numbers
|
|
245
|
+
const getPageNumbers = () => {
|
|
246
|
+
const pages = [];
|
|
247
|
+
const maxVisible = 5;
|
|
248
|
+
if (actualTotalPages <= maxVisible) {
|
|
249
|
+
for (let i = 0; i < actualTotalPages; i++)
|
|
250
|
+
pages.push(i);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
if (page < 3) {
|
|
254
|
+
for (let i = 0; i < 4; i++)
|
|
255
|
+
pages.push(i);
|
|
256
|
+
pages.push('...');
|
|
257
|
+
pages.push(actualTotalPages - 1);
|
|
258
|
+
}
|
|
259
|
+
else if (page > actualTotalPages - 4) {
|
|
260
|
+
pages.push(0);
|
|
261
|
+
pages.push('...');
|
|
262
|
+
for (let i = actualTotalPages - 4; i < actualTotalPages; i++)
|
|
263
|
+
pages.push(i);
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
pages.push(0);
|
|
267
|
+
pages.push('...');
|
|
268
|
+
for (let i = page - 1; i <= page + 1; i++)
|
|
269
|
+
pages.push(i);
|
|
270
|
+
pages.push('...');
|
|
271
|
+
pages.push(actualTotalPages - 1);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return pages;
|
|
275
|
+
};
|
|
276
|
+
return (_jsxs(PaginationWrapper, { className: classNames.pagination, style: styles.pagination, children: [_jsxs(ToolbarGroup, { children: [rowSelection?.mode === 'checkbox' && selectedKeys.size > 0 && (_jsxs(ToolbarButton, { onClick: () => {
|
|
277
|
+
const selectedRows = data.filter((row) => selectedKeys.has(getRowKey(row)));
|
|
278
|
+
rowSelection.onChange?.(Array.from(selectedKeys), selectedRows);
|
|
279
|
+
}, children: [selectedKeys.size, " Selected"] })), paginationConfig?.showSizeChanger !== false && (_jsx(PageSizeSelect, { value: pageSize, onChange: (e) => handlePageSizeChange(Number(e.target.value)), children: (paginationConfig?.pageSizeOptions || [10, 20, 30, 50]).map((size) => (_jsx("option", { value: size, children: size }, size))) }))] }), _jsxs(PaginationControls, { children: [_jsx(PageButton, { onClick: goToFirstPage, disabled: page === 0, children: _jsx(ChevronsLeftIcon, {}) }), _jsx(PageButton, { onClick: goToPrevPage, disabled: page === 0, children: _jsx(ChevronLeftIcon, {}) }), getPageNumbers().map((p, i) => typeof p === 'string' ? (_jsx("span", { style: { padding: '0 4px', color: 'white' }, children: p }, `ellipsis-${i}`)) : (_jsx(PageButton, { "$active": p === page, onClick: () => handlePageChange(p), children: p + 1 }, p))), _jsx(PageButton, { onClick: goToNextPage, disabled: page >= actualTotalPages - 1, children: _jsx(ChevronRightIcon, {}) }), _jsx(PageButton, { onClick: goToLastPage, disabled: page >= actualTotalPages - 1, children: _jsx(ChevronsRightIcon, {}) })] }), showTotal && _jsx(PaginationInfo, { children: showTotal }), paginationConfig?.showQuickJumper && (_jsxs(QuickJumper, { children: ["Go to", _jsx("input", { type: "number", min: 1, max: actualTotalPages, placeholder: "#", onKeyDown: (e) => {
|
|
280
|
+
if (e.key === 'Enter') {
|
|
281
|
+
const target = e.target;
|
|
282
|
+
const pageNum = parseInt(target.value, 10) - 1;
|
|
283
|
+
if (pageNum >= 0 && pageNum < actualTotalPages) {
|
|
284
|
+
handlePageChange(pageNum);
|
|
285
|
+
target.value = '';
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
} })] }))] }));
|
|
289
|
+
};
|
|
290
|
+
// Has any filter active
|
|
291
|
+
const hasFilters = filterable && columns.some((c) => c.filter !== false);
|
|
292
|
+
return (_jsxs(TableRoot, { ref: ref, "$bordered": bordered, "$compact": compact, className: className || classNames.root, style: { ...styles.root, ...style, position: 'relative' }, "aria-label": rest['aria-label'], "aria-labelledby": rest['aria-labelledby'], children: [loading && (_jsx(LoadingOverlay, { className: classNames.loading, style: styles.loading, children: loadingIndicator || _jsx(LoadingSpinner, {}) })), renderToolbar(), _jsx(TableWrapper, { "$maxHeight": maxHeight, "$stickyHeader": stickyHeader, className: classNames.wrapper, style: styles.wrapper, children: _jsxs(StyledTable, { ref: tableRef, "$striped": striped, "$hover": hover, "$compact": compact, role: "grid", children: [caption && _jsx("caption", { className: "sr-only", children: caption }), _jsxs(TableHeader, { "$sticky": stickyHeader, className: classNames.header, style: styles.header, children: [_jsxs(HeaderRow, { className: classNames.headerRow, style: styles.headerRow, children: [rowSelection?.mode === 'checkbox' && (_jsx(HeaderCell, { "$align": "center", "$sortable": false, "$compact": compact, "$width": rowSelection.columnWidth || 40, children: !rowSelection.hideSelectAll && (_jsx(Checkbox, { checked: isAllSelected, ref: (el) => {
|
|
293
|
+
if (el)
|
|
294
|
+
el.indeterminate = isIndeterminate;
|
|
295
|
+
}, onChange: handleSelectAllChange })) })), expandable && (_jsx(HeaderCell, { "$align": "center", "$sortable": false, "$compact": compact, "$width": expandable.columnWidth || 40 })), visibleColumns.map((column, colIndex) => (_jsxs(HeaderCell, { "$align": column.headerAlign || column.align || 'left', "$sortable": !!column.sort, "$compact": compact, "$width": column.width, "$minWidth": column.minWidth, "$pinned": column.pinned, className: column.headerClasses || classNames.headerCell, style: typeof column.headerStyle === 'function'
|
|
296
|
+
? column.headerStyle(column)
|
|
297
|
+
: column.headerStyle || styles.headerCell, onClick: () => handleSortClick(column), role: "columnheader", "aria-sort": sort.field === column.dataField
|
|
298
|
+
? sort.order === 'asc'
|
|
299
|
+
? 'ascending'
|
|
300
|
+
: sort.order === 'desc'
|
|
301
|
+
? 'descending'
|
|
302
|
+
: 'none'
|
|
303
|
+
: undefined, children: [column.headerFormatter
|
|
304
|
+
? column.headerFormatter(column, colIndex)
|
|
305
|
+
: column.headerText || column.text, column.sort && (_jsxs(SortIcon, { "$active": sort.field === column.dataField, "$direction": sort.field === column.dataField ? sort.order || undefined : undefined, children: [_jsx(SortUpIcon, {}), _jsx(SortDownIcon, {})] }))] }, column.dataField)))] }), hasFilters && (_jsxs(FilterRow, { children: [rowSelection?.mode === 'checkbox' && _jsx(FilterCell, { "$compact": compact }), expandable && _jsx(FilterCell, { "$compact": compact }), visibleColumns.map((column) => {
|
|
306
|
+
const FilterComponent = column.filterComponent ||
|
|
307
|
+
getFilterComponent(column.filterType || 'text');
|
|
308
|
+
return (_jsx(FilterCell, { "$compact": compact, children: column.filter !== false && (_jsx(FilterComponent, { column: column, value: filters[column.dataField], onChange: (value) => handleFilterChange(column.dataField, value), onClear: () => handleFilterChange(column.dataField, null) })) }, column.dataField));
|
|
309
|
+
})] }))] }), _jsx(TableBody, { className: classNames.body, style: styles.body, children: processedData.length === 0 ? (_jsx("tr", { children: _jsx("td", { colSpan: visibleColumns.length +
|
|
310
|
+
(rowSelection?.mode === 'checkbox' ? 1 : 0) +
|
|
311
|
+
(expandable ? 1 : 0), children: _jsxs(EmptyState, { className: classNames.empty, style: styles.empty, children: [_jsx(EmptyIcon, {}), _jsx("span", { children: emptyText })] }) }) })) : (processedData.map((row, rowIndex) => {
|
|
312
|
+
const rowKey = getRowKey(row);
|
|
313
|
+
const rowSelected = isSelected(rowKey);
|
|
314
|
+
const rowExpanded = isExpanded(rowKey);
|
|
315
|
+
const checkboxProps = rowSelection?.getCheckboxProps?.(row);
|
|
316
|
+
const isExpandable = expandable?.rowExpandable?.(row) ?? true;
|
|
317
|
+
const rowClass = typeof rowClassName === 'function'
|
|
318
|
+
? rowClassName(row, rowIndex)
|
|
319
|
+
: rowClassName;
|
|
320
|
+
const rowStyles = typeof rowStyle === 'function'
|
|
321
|
+
? rowStyle(row, rowIndex)
|
|
322
|
+
: rowStyle;
|
|
323
|
+
const selectedStyle = rowSelected
|
|
324
|
+
? typeof rowSelection?.selectedRowStyle === 'function'
|
|
325
|
+
? rowSelection.selectedRowStyle(row)
|
|
326
|
+
: rowSelection?.selectedRowStyle
|
|
327
|
+
: undefined;
|
|
328
|
+
return (_jsxs(React.Fragment, { children: [_jsxs(TableRow, { "$selected": rowSelected, "$clickable": !!onRowClick ||
|
|
329
|
+
rowSelection?.mode === 'single' ||
|
|
330
|
+
expandable?.expandRowByClick === true, "$disabled": !!checkboxProps?.disabled, className: `${classNames.row || ''} ${rowClass || ''} ${rowSelected
|
|
331
|
+
? typeof rowSelection?.selectedRowClassName === 'function'
|
|
332
|
+
? rowSelection.selectedRowClassName(row)
|
|
333
|
+
: rowSelection?.selectedRowClassName || ''
|
|
334
|
+
: ''}`, style: { ...styles.row, ...rowStyles, ...selectedStyle }, onClick: (e) => handleRowClick(row, rowIndex, e), onDoubleClick: (e) => handleCellDoubleClick(row, rowIndex, visibleColumns[0], e), role: "row", "aria-selected": rowSelected, children: [rowSelection?.mode === 'checkbox' && (_jsx(TableCell, { "$align": "center", "$compact": compact, children: _jsx(Checkbox, { checked: rowSelected, disabled: checkboxProps?.disabled, onChange: (e) => handleCheckboxChange(row, e), onClick: (e) => e.stopPropagation() }) })), expandable && (_jsx(TableCell, { "$align": "center", "$compact": compact, children: isExpandable && (_jsx(ExpandButton, { "$expanded": rowExpanded, onClick: (e) => handleExpandClick(row, e), children: expandable.expandIcon ? (expandable.expandIcon({
|
|
335
|
+
expanded: rowExpanded,
|
|
336
|
+
row,
|
|
337
|
+
onExpand: () => toggleExpand(row),
|
|
338
|
+
})) : (_jsx(ExpandIcon, {})) })) })), visibleColumns.map((column, colIndex) => {
|
|
339
|
+
const cellClass = typeof column.classes === 'function'
|
|
340
|
+
? column.classes(getNestedValue(row, column.dataField), row, rowIndex)
|
|
341
|
+
: column.classes;
|
|
342
|
+
const cellStyle = typeof column.style === 'function'
|
|
343
|
+
? column.style(getNestedValue(row, column.dataField), row, rowIndex)
|
|
344
|
+
: column.style;
|
|
345
|
+
return (_jsx(TableCell, { "$align": column.align || 'left', "$compact": compact, "$pinned": column.pinned, className: cellClass || classNames.cell, style: { ...styles.cell, ...cellStyle }, onClick: () => handleCellClick(row, rowIndex, column), onDoubleClick: (e) => handleCellDoubleClick(row, rowIndex, column, e), role: "gridcell", children: column.editable && editMode !== 'none' ? (_jsx(EditableCell, { "$editing": editingCell?.row === rowIndex &&
|
|
346
|
+
editingCell?.field === column.dataField, children: renderCellContent(row, column, rowIndex, colIndex) })) : (renderCellContent(row, column, rowIndex, colIndex)) }, column.dataField));
|
|
347
|
+
})] }), expandable && rowExpanded && isExpandable && (_jsx(ExpandedRow, { children: _jsx(ExpandedCell, { colSpan: visibleColumns.length +
|
|
348
|
+
(rowSelection?.mode === 'checkbox' ? 1 : 0) +
|
|
349
|
+
1, children: expandable.expandedRowRender?.(row, rowIndex, rowExpanded) }) }))] }, rowKey));
|
|
350
|
+
})) }), showFooter && (_jsx(TableFooter, { className: classNames.footer, style: styles.footer, children: _jsxs(FooterRow, { className: classNames.footerRow, style: styles.footerRow, children: [rowSelection?.mode === 'checkbox' && (_jsx(FooterCell, { "$align": "center", "$compact": compact })), expandable && _jsx(FooterCell, { "$align": "center", "$compact": compact }), visibleColumns.map((column) => (_jsx(FooterCell, { "$align": column.align || 'left', "$compact": compact, className: classNames.footerCell, style: styles.footerCell, children: typeof column.footer === 'function'
|
|
351
|
+
? column.footer(column, data)
|
|
352
|
+
: column.footerFormatter
|
|
353
|
+
? column.footerFormatter(column, data)
|
|
354
|
+
: column.footer }, column.dataField)))] }) }))] }) }), renderPagination()] }));
|
|
355
|
+
});
|
|
356
|
+
Table.displayName = 'Table';
|
|
357
|
+
export default Table;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const TableRoot: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
3
|
+
$bordered: boolean;
|
|
4
|
+
$compact: boolean;
|
|
5
|
+
}>> & string;
|
|
6
|
+
export declare const Toolbar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
7
|
+
export declare const ToolbarGroup: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
8
|
+
export declare const SearchInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
9
|
+
export declare const ToolbarButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
10
|
+
$active?: boolean | undefined;
|
|
11
|
+
}>> & string;
|
|
12
|
+
export declare const TableWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
13
|
+
$maxHeight?: string | number | undefined;
|
|
14
|
+
$stickyHeader: boolean;
|
|
15
|
+
}>> & string;
|
|
16
|
+
export declare const StyledTable: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, {
|
|
17
|
+
$striped: boolean;
|
|
18
|
+
$hover: boolean;
|
|
19
|
+
$compact: boolean;
|
|
20
|
+
}>> & string;
|
|
21
|
+
export declare const TableHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, {
|
|
22
|
+
$sticky: boolean;
|
|
23
|
+
}>> & string;
|
|
24
|
+
export declare const HeaderRow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, never>> & string;
|
|
25
|
+
export declare const HeaderCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>, {
|
|
26
|
+
$align: string;
|
|
27
|
+
$sortable: boolean;
|
|
28
|
+
$compact: boolean;
|
|
29
|
+
$width?: string | number | undefined;
|
|
30
|
+
$minWidth?: string | number | undefined;
|
|
31
|
+
$pinned?: false | "left" | "right" | undefined;
|
|
32
|
+
}>> & string;
|
|
33
|
+
export declare const SortIcon: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
|
|
34
|
+
$active: boolean;
|
|
35
|
+
$direction?: string | undefined;
|
|
36
|
+
}>> & string;
|
|
37
|
+
export declare const FilterRow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, never>> & string;
|
|
38
|
+
export declare const FilterCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, {
|
|
39
|
+
$compact: boolean;
|
|
40
|
+
}>> & string;
|
|
41
|
+
export declare const FilterInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>> & string;
|
|
42
|
+
export declare const FilterSelect: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>, never>> & string;
|
|
43
|
+
export declare const TableBody: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, never>> & string;
|
|
44
|
+
export declare const TableRow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, {
|
|
45
|
+
$selected: boolean;
|
|
46
|
+
$clickable: boolean;
|
|
47
|
+
$disabled: boolean;
|
|
48
|
+
}>> & string;
|
|
49
|
+
export declare const TableCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, {
|
|
50
|
+
$align: string;
|
|
51
|
+
$compact: boolean;
|
|
52
|
+
$pinned?: false | "left" | "right" | undefined;
|
|
53
|
+
}>> & string;
|
|
54
|
+
export declare const Checkbox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & {
|
|
55
|
+
ref?: ((instance: HTMLInputElement | null) => void) | import("react").RefObject<HTMLInputElement> | null | undefined;
|
|
56
|
+
}>, never>, never>> & string;
|
|
57
|
+
export declare const ExpandButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
58
|
+
$expanded: boolean;
|
|
59
|
+
}>> & string;
|
|
60
|
+
export declare const ExpandedRow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, never>> & string;
|
|
61
|
+
export declare const ExpandedCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, never>> & string;
|
|
62
|
+
export declare const TableFooter: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, never>> & string;
|
|
63
|
+
export declare const FooterRow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, never>> & string;
|
|
64
|
+
export declare const FooterCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, {
|
|
65
|
+
$align: string;
|
|
66
|
+
$compact: boolean;
|
|
67
|
+
}>> & string;
|
|
68
|
+
export declare const PaginationWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
69
|
+
export declare const PaginationInfo: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
70
|
+
export declare const PaginationControls: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
71
|
+
export declare const PageButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
|
|
72
|
+
$active?: boolean | undefined;
|
|
73
|
+
}>> & string;
|
|
74
|
+
export declare const PageSizeSelect: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>, never>> & string;
|
|
75
|
+
export declare const QuickJumper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
76
|
+
export declare const EmptyState: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
77
|
+
export declare const LoadingOverlay: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
78
|
+
export declare const LoadingSpinner: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
79
|
+
export declare const EditableCell: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
80
|
+
$editing: boolean;
|
|
81
|
+
}>> & string;
|
|
82
|
+
export declare const CellEditor: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>> & string;
|
|
83
|
+
export declare const ColumnTogglePanel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
84
|
+
export declare const ColumnToggleHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
85
|
+
export declare const ColumnToggleSearch: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
86
|
+
export declare const ColumnToggleList: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
87
|
+
export declare const ColumnToggleItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, never>> & string;
|
|
88
|
+
export declare const ResizeHandle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
89
|
+
//# sourceMappingURL=elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../../../../../src/core-components/src/components/Table/elements.tsx"],"names":[],"mappings":";AAmBA,eAAO,MAAM,SAAS;eACT,OAAO;cACR,OAAO;YAelB,CAAC;AAEF,eAAO,MAAM,OAAO,6NAanB,CAAC;AAEF,eAAO,MAAM,YAAY,6NAKxB,CAAC;AAEF,eAAO,MAAM,WAAW,6NAqCvB,CAAC;AAEF,eAAO,MAAM,aAAa;;YA8BzB,CAAC;AAEF,eAAO,MAAM,YAAY;;mBAER,OAAO;YAUvB,CAAC;AAEF,eAAO,MAAM,WAAW;cACZ,OAAO;YACT,OAAO;cACL,OAAO;YAqBlB,CAAC;AAEF,eAAO,MAAM,WAAW;aAA0B,OAAO;YAQxD,CAAC;AAEF,eAAO,MAAM,SAAS,uOAErB,CAAC;AAEF,eAAO,MAAM,UAAU;YACb,MAAM;eACH,OAAO;cACR,OAAO;;;;YA8ClB,CAAC;AAEF,eAAO,MAAM,QAAQ;aAAyB,OAAO;;YAsBpD,CAAC;AAEF,eAAO,MAAM,SAAS,uOAErB,CAAC;AAEF,eAAO,MAAM,UAAU;cAAwB,OAAO;YAGrD,CAAC;AAEF,eAAO,MAAM,WAAW,sOAiBvB,CAAC;AAEF,eAAO,MAAM,YAAY,yOAcxB,CAAC;AAEF,eAAO,MAAM,SAAS,+OAAiB,CAAC;AAExC,eAAO,MAAM,QAAQ;eACR,OAAO;gBACN,OAAO;eACR,OAAO;YAuBnB,CAAC;AAEF,eAAO,MAAM,SAAS;YACZ,MAAM;cACJ,OAAO;;YAgBlB,CAAC;AAEF,eAAO,MAAM,QAAQ;;4BAKpB,CAAC;AAEF,eAAO,MAAM,YAAY;eAA6B,OAAO;YAwB5D,CAAC;AAEF,eAAO,MAAM,WAAW,uOAEvB,CAAC;AAEF,eAAO,MAAM,YAAY,mPAIxB,CAAC;AAEF,eAAO,MAAM,WAAW,+OAEvB,CAAC;AAEF,eAAO,MAAM,SAAS,uOAAc,CAAC;AAErC,eAAO,MAAM,UAAU;YAAsB,MAAM;cAAY,OAAO;YAKrE,CAAC;AAEF,eAAO,MAAM,iBAAiB,6NAe7B,CAAC;AAEF,eAAO,MAAM,cAAc,6NAG1B,CAAC;AAEF,eAAO,MAAM,kBAAkB,6NAI9B,CAAC;AAEF,eAAO,MAAM,UAAU;;YA6BtB,CAAC;AAEF,eAAO,MAAM,cAAc,yOAc1B,CAAC;AAEF,eAAO,MAAM,WAAW,6NA2BvB,CAAC;AAEF,eAAO,MAAM,UAAU,6NAkBtB,CAAC;AAEF,eAAO,MAAM,cAAc,6NAQ1B,CAAC;AAEF,eAAO,MAAM,cAAc,6NAO1B,CAAC;AAEF,eAAO,MAAM,YAAY;cAAyB,OAAO;YAiBxD,CAAC;AAEF,eAAO,MAAM,UAAU,sOAWtB,CAAC;AAEF,eAAO,MAAM,iBAAiB,6NAa7B,CAAC;AAEF,eAAO,MAAM,kBAAkB,6NAuB9B,CAAC;AAEF,eAAO,MAAM,kBAAkB,6NAiB9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,6NAI5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,sOAuB5B,CAAC;AAEF,eAAO,MAAM,YAAY,6NAYxB,CAAC"}
|