flikkui 0.2.0-beta.2 → 0.2.0-beta.5
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/README.md +92 -0
- package/dist/components/ai/PromptInput/PromptInput.js +23 -15
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.d.ts +27 -0
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.js +62 -0
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.theme.d.ts +10 -0
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.theme.js +12 -0
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.types.d.ts +53 -0
- package/dist/components/ai/PromptSuggestions/index.d.ts +4 -2
- package/dist/components/ai/index.d.ts +2 -12
- package/dist/components/charts/ActivityRings/ActivityRings.js +70 -58
- package/dist/components/charts/ActivityRings/ActivityRings.theme.js +0 -1
- package/dist/components/charts/ActivityRings/ActivityRings.types.d.ts +17 -0
- package/dist/components/charts/BarChart/BarChart.js +8 -4
- package/dist/components/charts/BarChart/BarChart.types.d.ts +14 -0
- package/dist/components/charts/DonutChart/DonutChart.js +11 -8
- package/dist/components/charts/DonutChart/DonutChart.theme.d.ts +3 -0
- package/dist/components/charts/DonutChart/DonutChart.theme.js +5 -4
- package/dist/components/charts/DonutChart/donut-utils.d.ts +5 -0
- package/dist/components/charts/DonutChart/donut-utils.js +26 -1
- package/dist/components/charts/Heatmap/Heatmap.theme.js +2 -2
- package/dist/components/charts/shared/ChartAxis/XAxis.d.ts +2 -2
- package/dist/components/charts/shared/ChartAxis/XAxis.js +4 -4
- package/dist/components/charts/shared/ChartAxis/YAxis.d.ts +2 -2
- package/dist/components/charts/shared/ChartAxis/YAxis.js +8 -7
- package/dist/components/charts/shared/ChartGrid/HorizontalGrid.d.ts +1 -1
- package/dist/components/charts/shared/ChartGrid/HorizontalGrid.js +2 -2
- package/dist/components/charts/theme/chart.theme.d.ts +1 -1
- package/dist/components/charts/theme/chart.theme.js +39 -39
- package/dist/components/core/Accordion/Accordion.d.ts +1 -1
- package/dist/components/core/Accordion/Accordion.js +2 -2
- package/dist/components/core/Accordion/Accordion.types.d.ts +8 -0
- package/dist/components/core/Badge/Badge.js +11 -15
- package/dist/components/core/Badge/Badge.theme.js +7 -21
- package/dist/components/core/Badge/Badge.types.d.ts +9 -1
- package/dist/components/core/Button/Button.js +2 -2
- package/dist/components/core/Button/Button.theme.js +1 -1
- package/dist/components/core/Button/Button.types.d.ts +8 -0
- package/dist/components/core/Card/Card.js +8 -2
- package/dist/components/core/Card/Card.theme.js +1 -1
- package/dist/components/core/Card/Card.types.d.ts +24 -1
- package/dist/components/core/Drawer/Drawer.d.ts +1 -1
- package/dist/components/core/Drawer/Drawer.js +10 -40
- package/dist/components/core/Drawer/Drawer.theme.js +2 -1
- package/dist/components/core/Drawer/Drawer.types.d.ts +8 -0
- package/dist/components/core/Dropdown/Dropdown.d.ts +1 -1
- package/dist/components/core/Dropdown/Dropdown.js +2 -2
- package/dist/components/core/Dropdown/Dropdown.types.d.ts +8 -0
- package/dist/components/core/Metric/Metric.d.ts +1 -1
- package/dist/components/core/Metric/Metric.js +9 -5
- package/dist/components/core/Metric/Metric.theme.d.ts +1 -1
- package/dist/components/core/Metric/Metric.theme.js +38 -28
- package/dist/components/core/Metric/Metric.types.d.ts +27 -8
- package/dist/components/core/Modal/Modal.d.ts +1 -1
- package/dist/components/core/Modal/Modal.js +17 -40
- package/dist/components/core/Modal/Modal.theme.js +8 -3
- package/dist/components/core/Modal/Modal.types.d.ts +18 -0
- package/dist/components/core/Modal/index.d.ts +1 -1
- package/dist/components/core/Notification/Notification.js +2 -0
- package/dist/components/core/Pill/Pill.d.ts +6 -11
- package/dist/components/core/Pill/Pill.theme.d.ts +2 -2
- package/dist/components/core/Pill/Pill.types.d.ts +9 -22
- package/dist/components/core/Pill/index.d.ts +1 -1
- package/dist/components/core/Popover/Popover.d.ts +1 -1
- package/dist/components/core/Popover/Popover.js +2 -2
- package/dist/components/core/Popover/Popover.types.d.ts +8 -0
- package/dist/components/core/Progress/Progress.d.ts +28 -0
- package/dist/components/core/Progress/Progress.js +114 -0
- package/dist/components/core/Progress/Progress.theme.d.ts +5 -0
- package/dist/components/core/Progress/Progress.theme.js +33 -0
- package/dist/components/core/Progress/Progress.types.d.ts +92 -0
- package/dist/components/core/Progress/index.d.ts +2 -0
- package/dist/components/core/Table/Table.animations.d.ts +5 -16
- package/dist/components/core/Table/Table.animations.js +46 -0
- package/dist/components/core/Table/Table.d.ts +0 -27
- package/dist/components/core/Table/Table.js +58 -156
- package/dist/components/core/Table/Table.theme.js +28 -19
- package/dist/components/core/Table/Table.types.d.ts +95 -8
- package/dist/components/core/Table/Table.utils.d.ts +7 -0
- package/dist/components/core/Table/Table.utils.js +11 -1
- package/dist/components/core/Table/{components/TableActions/TableActions.d.ts → TableActions.d.ts} +3 -3
- package/dist/components/core/Table/{components/TableActions/TableActions.js → TableActions.js} +14 -24
- package/dist/components/core/Table/{components/TableActions/TableActionsMenu.d.ts → TableActionsMenu.d.ts} +1 -1
- package/dist/components/core/Table/{components/TableActions/TableActionsMenu.js → TableActionsMenu.js} +4 -4
- package/dist/components/core/Table/{components/core/TableBody.d.ts → TableBody.d.ts} +1 -1
- package/dist/components/core/Table/{components/core/TableBody.js → TableBody.js} +14 -20
- package/dist/components/core/Table/{components/core/TableCell.d.ts → TableCell.d.ts} +1 -9
- package/dist/components/core/Table/{components/core/TableCell.js → TableCell.js} +5 -13
- package/dist/components/core/Table/TableColumnManager.d.ts +3 -0
- package/dist/components/core/Table/TableColumnManager.js +34 -0
- package/dist/components/core/Table/{components/DeclarativeComponents.d.ts → TableDeclarative.d.ts} +1 -1
- package/dist/components/core/Table/{components/DeclarativeComponents.js → TableDeclarative.js} +6 -56
- package/dist/components/core/Table/TableFilter.d.ts +3 -0
- package/dist/components/core/Table/TableFilter.js +122 -0
- package/dist/components/core/Table/{components/core/TableHeader.d.ts → TableHeader.d.ts} +1 -1
- package/dist/components/core/Table/{components/core/TableHeader.js → TableHeader.js} +15 -29
- package/dist/components/core/Table/TablePagination.d.ts +7 -0
- package/dist/components/core/Table/{components/TablePagination/TablePagination.js → TablePagination.js} +5 -16
- package/dist/components/core/Table/TableRow.d.ts +8 -0
- package/dist/components/core/Table/TableRow.js +45 -0
- package/dist/components/core/Table/TableSelectionHeader.d.ts +7 -0
- package/dist/components/core/Table/{components/TableSelectionHeader/TableSelectionHeader.js → TableSelectionHeader.js} +4 -5
- package/dist/components/core/Table/hooks/index.d.ts +10 -0
- package/dist/components/core/Table/hooks/useTableColumns.d.ts +16 -0
- package/dist/components/core/Table/hooks/useTableColumns.js +67 -0
- package/dist/components/core/Table/hooks/useTableExpansion.d.ts +8 -0
- package/dist/components/core/Table/hooks/useTableExpansion.js +15 -0
- package/dist/components/core/Table/hooks/useTableFilter.d.ts +12 -0
- package/dist/components/core/Table/hooks/useTableFilter.js +37 -0
- package/dist/components/core/Table/hooks/useTablePagination.d.ts +12 -0
- package/dist/components/core/Table/hooks/useTablePagination.js +13 -0
- package/dist/components/core/Table/hooks/useTableSelection.d.ts +17 -0
- package/dist/components/core/Table/hooks/useTableSelection.js +40 -0
- package/dist/components/core/Table/index.d.ts +9 -8
- package/dist/components/core/Table/index.js +7 -5
- package/dist/components/core/Tabs/Tabs.js +2 -2
- package/dist/components/core/Tabs/Tabs.types.d.ts +8 -0
- package/dist/components/core/Tag/Tag.animations.d.ts +3 -0
- package/dist/components/core/Tag/Tag.animations.js +31 -0
- package/dist/components/core/Tag/Tag.d.ts +14 -0
- package/dist/components/core/Tag/Tag.js +45 -0
- package/dist/components/core/Tag/Tag.theme.d.ts +2 -0
- package/dist/components/core/Tag/Tag.theme.js +21 -0
- package/dist/components/core/Tag/Tag.types.d.ts +40 -0
- package/dist/components/core/Tag/index.d.ts +3 -0
- package/dist/components/core/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/core/Tooltip/Tooltip.js +3 -3
- package/dist/components/core/Tooltip/Tooltip.theme.js +1 -1
- package/dist/components/core/Tooltip/Tooltip.types.d.ts +17 -0
- package/dist/components/core/index.d.ts +2 -1
- package/dist/components/core/index.js +12 -5
- package/dist/components/effects/CustomCursor/CustomCursor.d.ts +0 -13
- package/dist/components/effects/CustomCursor/CustomCursor.js +26 -2
- package/dist/components/effects/CustomCursor/CustomCursor.theme.js +12 -1
- package/dist/components/effects/CustomCursor/CustomCursor.types.d.ts +14 -1
- package/dist/components/forms/Combobox/Combobox.d.ts +25 -0
- package/dist/components/forms/Combobox/Combobox.js +412 -0
- package/dist/components/forms/Combobox/Combobox.theme.d.ts +6 -0
- package/dist/components/forms/Combobox/Combobox.theme.js +60 -0
- package/dist/components/forms/Combobox/Combobox.types.d.ts +111 -0
- package/dist/components/forms/Combobox/index.d.ts +3 -0
- package/dist/components/forms/FileUpload/FileUpload.js +2 -0
- package/dist/components/forms/Input/Input.js +25 -28
- package/dist/components/forms/Input/inputMasks.d.ts +15 -0
- package/dist/components/forms/Input/inputMasks.js +72 -1
- package/dist/components/forms/InputTag/InputTag.d.ts +40 -0
- package/dist/components/forms/InputTag/InputTag.js +491 -0
- package/dist/components/forms/InputTag/InputTag.theme.d.ts +2 -0
- package/dist/components/forms/InputTag/InputTag.theme.js +16 -0
- package/dist/components/forms/InputTag/InputTag.types.d.ts +107 -0
- package/dist/components/forms/InputTag/index.d.ts +3 -0
- package/dist/components/forms/Select/Select.d.ts +101 -2
- package/dist/components/forms/Select/Select.js +128 -132
- package/dist/components/forms/Select/Select.theme.js +10 -14
- package/dist/components/forms/Select/Select.types.d.ts +6 -2
- package/dist/components/forms/Select/index.d.ts +7 -4
- package/dist/components/forms/Select/useSelectState.d.ts +66 -0
- package/dist/components/forms/Select/useSelectState.js +134 -0
- package/dist/components/forms/SelectExpand/SelectExpand.animations.d.ts +20 -0
- package/dist/components/forms/SelectExpand/SelectExpand.animations.js +74 -0
- package/dist/components/forms/SelectExpand/SelectExpand.d.ts +9 -0
- package/dist/components/forms/SelectExpand/SelectExpand.js +223 -0
- package/dist/components/forms/SelectExpand/SelectExpand.theme.d.ts +5 -0
- package/dist/components/forms/SelectExpand/SelectExpand.theme.js +74 -0
- package/dist/components/forms/SelectExpand/SelectExpand.types.d.ts +126 -0
- package/dist/components/forms/SelectExpand/index.d.ts +4 -0
- package/dist/components/forms/Switch/Switch.js +3 -3
- package/dist/components/forms/Switch/Switch.theme.d.ts +1 -1
- package/dist/components/forms/Switch/Switch.theme.js +2 -2
- package/dist/components/forms/TimePicker/TimePicker.animations.d.ts +0 -46
- package/dist/components/forms/TimePicker/TimePicker.d.ts +15 -6
- package/dist/components/forms/TimePicker/TimePicker.js +285 -124
- package/dist/components/forms/TimePicker/TimePicker.theme.d.ts +1 -1
- package/dist/components/forms/TimePicker/TimePicker.theme.js +39 -22
- package/dist/components/forms/TimePicker/TimePicker.types.d.ts +88 -34
- package/dist/components/forms/TimePicker/TimePickerContent.d.ts +7 -10
- package/dist/components/forms/TimePicker/TimePickerContent.js +149 -16
- package/dist/components/forms/TimePicker/TimePickerTrigger.d.ts +3 -3
- package/dist/components/forms/TimePicker/TimePickerTrigger.js +22 -19
- package/dist/components/forms/TimePicker/WheelColumn.d.ts +14 -0
- package/dist/components/forms/TimePicker/WheelColumn.js +90 -0
- package/dist/components/forms/TimePicker/index.d.ts +4 -1
- package/dist/components/forms/TimePicker/useWheelPicker.d.ts +37 -0
- package/dist/components/forms/TimePicker/useWheelPicker.js +138 -0
- package/dist/components/forms/forms.theme.d.ts +14 -0
- package/dist/components/forms/forms.theme.js +31 -0
- package/dist/components/forms/index.d.ts +9 -3
- package/dist/components/forms/index.js +73 -2
- package/dist/hooks/index.d.ts +0 -4
- package/dist/icons/Icon.d.ts +7 -0
- package/dist/icons/Icon.js +6 -2
- package/dist/index.js +21 -19
- package/dist/styles.css +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/optimisticErrors.js +1 -70
- package/package.json +1 -1
- package/dist/components/ai/EditingIndicator/EditingIndicator.animations.d.ts +0 -31
- package/dist/components/ai/EditingIndicator/EditingIndicator.animations.js +0 -115
- package/dist/components/ai/EditingIndicator/EditingIndicator.d.ts +0 -35
- package/dist/components/ai/EditingIndicator/EditingIndicator.js +0 -94
- package/dist/components/ai/EditingIndicator/EditingIndicator.theme.d.ts +0 -2
- package/dist/components/ai/EditingIndicator/EditingIndicator.theme.js +0 -13
- package/dist/components/ai/EditingIndicator/EditingIndicator.types.d.ts +0 -54
- package/dist/components/ai/EditingIndicator/index.d.ts +0 -9
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.d.ts +0 -3
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.js +0 -126
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.theme.d.ts +0 -2
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.theme.js +0 -8
- package/dist/components/ai/GenerativeRenderer/GenerativeRenderer.types.d.ts +0 -45
- package/dist/components/ai/GenerativeRenderer/index.d.ts +0 -3
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.animations.d.ts +0 -17
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.animations.js +0 -56
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.d.ts +0 -38
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.js +0 -110
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.theme.d.ts +0 -2
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.theme.js +0 -13
- package/dist/components/ai/PresenceIndicator/PresenceIndicator.types.d.ts +0 -53
- package/dist/components/ai/PresenceIndicator/index.d.ts +0 -8
- package/dist/components/ai/PresenceProvider/PresenceContext.d.ts +0 -24
- package/dist/components/ai/PresenceProvider/PresenceContext.js +0 -34
- package/dist/components/ai/PresenceProvider/PresenceProvider.d.ts +0 -32
- package/dist/components/ai/PresenceProvider/PresenceProvider.js +0 -321
- package/dist/components/ai/PresenceProvider/PresenceProvider.types.d.ts +0 -140
- package/dist/components/ai/PresenceProvider/adapters/MockAdapter.d.ts +0 -102
- package/dist/components/ai/PresenceProvider/adapters/MockAdapter.js +0 -331
- package/dist/components/ai/PresenceProvider/adapters/PresenceAdapter.d.ts +0 -93
- package/dist/components/ai/PresenceProvider/adapters/SupabaseAdapter.d.ts +0 -134
- package/dist/components/ai/PresenceProvider/adapters/WebSocketAdapter.d.ts +0 -149
- package/dist/components/ai/PresenceProvider/adapters/index.d.ts +0 -11
- package/dist/components/ai/PresenceProvider/index.d.ts +0 -10
- package/dist/components/ai/PromptSuggestions/PromptSuggestions.d.ts +0 -27
- package/dist/components/ai/PromptSuggestions/PromptSuggestions.js +0 -61
- package/dist/components/ai/PromptSuggestions/PromptSuggestions.types.d.ts +0 -65
- package/dist/components/ai/VersionSlider/VersionSlider.d.ts +0 -3
- package/dist/components/ai/VersionSlider/VersionSlider.js +0 -97
- package/dist/components/ai/VersionSlider/VersionSlider.theme.d.ts +0 -2
- package/dist/components/ai/VersionSlider/VersionSlider.theme.js +0 -18
- package/dist/components/ai/VersionSlider/VersionSlider.types.d.ts +0 -77
- package/dist/components/ai/VersionSlider/index.d.ts +0 -3
- package/dist/components/core/Pill/Pill.animations.js +0 -25
- package/dist/components/core/Pill/Pill.js +0 -145
- package/dist/components/core/Pill/Pill.theme.js +0 -65
- package/dist/components/core/RetryBoundary/RetryBoundary.d.ts +0 -35
- package/dist/components/core/RetryBoundary/RetryBoundary.js +0 -154
- package/dist/components/core/RetryBoundary/RetryBoundary.theme.d.ts +0 -2
- package/dist/components/core/RetryBoundary/RetryBoundary.theme.js +0 -7
- package/dist/components/core/RetryBoundary/RetryBoundary.types.d.ts +0 -51
- package/dist/components/core/RetryBoundary/index.d.ts +0 -3
- package/dist/components/core/Table/components/TableActions/TableActions.types.d.ts +0 -40
- package/dist/components/core/Table/components/TableActions/index.d.ts +0 -3
- package/dist/components/core/Table/components/TableActionsMenu.d.ts +0 -6
- package/dist/components/core/Table/components/TablePagination/TablePagination.d.ts +0 -17
- package/dist/components/core/Table/components/TablePagination/TablePagination.types.d.ts +0 -21
- package/dist/components/core/Table/components/TablePagination/index.d.ts +0 -2
- package/dist/components/core/Table/components/TableSelectionHeader/TableSelectionHeader.d.ts +0 -15
- package/dist/components/core/Table/components/TableSelectionHeader/index.d.ts +0 -3
- package/dist/components/core/Table/components/core/TableRow.d.ts +0 -3
- package/dist/components/core/Table/components/core/TableRow.js +0 -44
- package/dist/components/core/Table/components/core/index.d.ts +0 -4
- package/dist/components/forms/OptimisticForm/OptimisticForm.d.ts +0 -33
- package/dist/components/forms/OptimisticForm/OptimisticForm.js +0 -87
- package/dist/components/forms/OptimisticForm/OptimisticForm.theme.d.ts +0 -2
- package/dist/components/forms/OptimisticForm/OptimisticForm.theme.js +0 -8
- package/dist/components/forms/OptimisticForm/OptimisticForm.types.d.ts +0 -74
- package/dist/components/forms/OptimisticForm/index.d.ts +0 -3
- package/dist/hooks/useOptimisticMutation.d.ts +0 -109
- package/dist/hooks/useOptimisticMutation.js +0 -171
- package/dist/hooks/usePresence.d.ts +0 -88
- package/dist/utils/presenceUtils.d.ts +0 -66
- package/dist/utils/presenceUtils.js +0 -107
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import React__default, { createContext,
|
|
1
|
+
import React__default, { createContext, useMemo } from 'react';
|
|
2
2
|
import { tableTheme } from './Table.theme.js';
|
|
3
3
|
import { cn } from '../../../utils/cn.js';
|
|
4
|
-
import { TableHeader } from './
|
|
5
|
-
import { TableBody } from './
|
|
6
|
-
import { TableSelectionHeader } from './
|
|
7
|
-
import {
|
|
8
|
-
import '
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { Sortable, SortableItem } from '../Sortable/Sortable.js';
|
|
4
|
+
import { TableHeader } from './TableHeader.js';
|
|
5
|
+
import { TableBody } from './TableBody.js';
|
|
6
|
+
import { TableSelectionHeader } from './TableSelectionHeader.js';
|
|
7
|
+
import { TableColumnManager } from './TableColumnManager.js';
|
|
8
|
+
import { TableFilter } from './TableFilter.js';
|
|
9
|
+
import { useTableColumns } from './hooks/useTableColumns.js';
|
|
10
|
+
import { useTableSelection } from './hooks/useTableSelection.js';
|
|
11
|
+
import { useTablePagination } from './hooks/useTablePagination.js';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Context for sharing table state across all table components
|
|
@@ -34,131 +33,61 @@ const TableContext = createContext({
|
|
|
34
33
|
* - Pagination support
|
|
35
34
|
* - Full accessibility compliance (WCAG 2.1 AA)
|
|
36
35
|
* - Theme customization with className overrides
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* // Data-driven API with stable row keys
|
|
40
|
-
* <Table data={data} columns={columns} rowKey="id" sortable selectable />
|
|
41
|
-
*
|
|
42
|
-
* // Using a function for complex row keys
|
|
43
|
-
* <Table
|
|
44
|
-
* data={data}
|
|
45
|
-
* columns={columns}
|
|
46
|
-
* rowKey={(row, index) => `${row.category}-${row.id}`}
|
|
47
|
-
* sortable
|
|
48
|
-
* selectable
|
|
49
|
-
* />
|
|
50
|
-
*
|
|
51
|
-
* // Declarative API
|
|
52
|
-
* <Table>
|
|
53
|
-
* <Table.Header>
|
|
54
|
-
* <Table.Row>
|
|
55
|
-
* <Table.HeaderCell>Name</Table.HeaderCell>
|
|
56
|
-
* </Table.Row>
|
|
57
|
-
* </Table.Header>
|
|
58
|
-
* <Table.Body>
|
|
59
|
-
* <Table.Row>
|
|
60
|
-
* <Table.Cell>John Doe</Table.Cell>
|
|
61
|
-
* </Table.Row>
|
|
62
|
-
* </Table.Body>
|
|
63
|
-
* </Table>
|
|
64
36
|
*/
|
|
65
37
|
function TableComponent(props) {
|
|
66
38
|
var _a;
|
|
67
|
-
const { data, columns, rowKey, variant = "default", theme: themeOverrides, className = "", freezeHeader = false, freezeFirstColumn = false, freezeLastColumn = false, sortable = false, sortConfig = [], onSortChange, filterable = false, filterConfig = [], onFilterChange, expandable = false, expandedRowRender, expandedRows = [], onExpandedRowsChange, selectable = false, selectionType = "checkbox", selectedRows = [], onSelectionChange, bulkActions = [], visibleColumns: initialVisibleColumns, onVisibleColumnsChange, onColumnReorder, pagination, children, } = props;
|
|
68
|
-
//
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
39
|
+
const { data, columns, rowKey, variant = "default", theme: themeOverrides, className = "", freezeHeader = false, freezeFirstColumn = false, freezeLastColumn = false, sortable = false, sortConfig = [], onSortChange, filterable = false, filterConfig = [], onFilterChange, expandable = false, expandedRowRender, expandedRows = [], onExpandedRowsChange, selectable = false, selectionType = "checkbox", selectedRows = [], onSelectionChange, bulkActions = [], showColumnManager = false, visibleColumns: initialVisibleColumns, onVisibleColumnsChange, onColumnReorder, pagination, children, } = props;
|
|
40
|
+
// Column management hook
|
|
41
|
+
const { visibleColumns, columnOrder, visibleColumnsList, handleToggleColumn, handleColumnReorder, handleResetToDefault, } = useTableColumns({
|
|
42
|
+
columns,
|
|
43
|
+
initialVisibleColumns,
|
|
44
|
+
onVisibleColumnsChange,
|
|
45
|
+
onColumnReorder,
|
|
46
|
+
});
|
|
47
|
+
// Pagination hook
|
|
48
|
+
const { paginatedData } = useTablePagination({
|
|
49
|
+
data,
|
|
50
|
+
pagination,
|
|
51
|
+
});
|
|
52
|
+
// Selection hook (for clear selection in header)
|
|
53
|
+
const { handleClearSelection } = useTableSelection({
|
|
54
|
+
data: paginatedData,
|
|
55
|
+
rowKey,
|
|
56
|
+
selectionType,
|
|
57
|
+
selectedRows,
|
|
58
|
+
onSelectionChange,
|
|
59
|
+
});
|
|
79
60
|
// Determine which API is being used (declarative vs data-driven)
|
|
80
61
|
const isDeclarativeAPI = !!children;
|
|
81
62
|
// Merge global theme with component-specific overrides
|
|
82
|
-
const theme = {
|
|
63
|
+
const theme = useMemo(() => ({
|
|
83
64
|
...tableTheme,
|
|
84
65
|
...(themeOverrides || {}),
|
|
85
|
-
};
|
|
66
|
+
}), [themeOverrides]);
|
|
86
67
|
// Get base classes from theme
|
|
87
68
|
const baseClasses = theme.baseStyle || "";
|
|
88
69
|
const variantClasses = ((_a = theme.variants) === null || _a === void 0 ? void 0 : _a[variant]) || "";
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
* Resets column order back to the original columns order
|
|
111
|
-
*/
|
|
112
|
-
const handleColumnOrderReset = () => {
|
|
113
|
-
if (columns) {
|
|
114
|
-
const originalOrder = columns.map((col) => col.id);
|
|
115
|
-
setColumnOrder(originalOrder);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* Handle clearing all row selections
|
|
120
|
-
*/
|
|
121
|
-
const handleClearSelection = () => {
|
|
122
|
-
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange([]);
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* Handle toggling column visibility
|
|
126
|
-
* Prevents toggling locked columns
|
|
127
|
-
*/
|
|
128
|
-
const handleToggleColumn = (columnId) => {
|
|
129
|
-
const column = columns === null || columns === void 0 ? void 0 : columns.find(col => col.id === columnId);
|
|
130
|
-
if (column === null || column === void 0 ? void 0 : column.locked)
|
|
131
|
-
return; // Prevent toggling locked columns
|
|
132
|
-
const newVisibleColumns = visibleColumns.includes(columnId)
|
|
133
|
-
? visibleColumns.filter((id) => id !== columnId)
|
|
134
|
-
: [...visibleColumns, columnId];
|
|
135
|
-
handleVisibleColumnsChange(newVisibleColumns);
|
|
136
|
-
};
|
|
137
|
-
/**
|
|
138
|
-
* Handle resetting columns to default visibility and order
|
|
139
|
-
*/
|
|
140
|
-
const handleResetToDefault = () => {
|
|
141
|
-
// Get all locked column IDs to ensure they remain visible
|
|
142
|
-
const lockedColumnIds = (columns === null || columns === void 0 ? void 0 : columns.filter(col => col.locked).map(col => col.id)) || [];
|
|
143
|
-
// Combine initial visible columns with locked columns (remove duplicates)
|
|
144
|
-
const resetVisibleColumns = Array.from(new Set([...defaultVisibleColumns, ...lockedColumnIds]));
|
|
145
|
-
// Reset to initial visible columns with locked columns guaranteed to be visible
|
|
146
|
-
handleVisibleColumnsChange(resetVisibleColumns);
|
|
147
|
-
// Reset column order to default
|
|
148
|
-
handleColumnOrderReset();
|
|
149
|
-
};
|
|
150
|
-
// Filter and order columns based on column order and visibility settings
|
|
151
|
-
const visibleColumnsList = columns && columnOrder.length > 0
|
|
152
|
-
? columnOrder
|
|
153
|
-
.map(colId => columns.find(col => col.id === colId))
|
|
154
|
-
.filter((col) => col !== undefined && visibleColumns.includes(col.id))
|
|
155
|
-
: (columns ? columns.filter((col) => visibleColumns.includes(col.id)) : []);
|
|
156
|
-
// Calculate paginated data slice based on current page and page size
|
|
157
|
-
const paginatedData = pagination && data
|
|
158
|
-
? data.slice((pagination.currentPage - 1) * pagination.pageSize, pagination.currentPage * pagination.pageSize)
|
|
159
|
-
: data || [];
|
|
160
|
-
// Create context value with all table configuration and callbacks
|
|
161
|
-
const contextValue = {
|
|
70
|
+
// Memoize context value to prevent unnecessary re-renders in consumers
|
|
71
|
+
const contextValue = useMemo(() => ({
|
|
72
|
+
theme,
|
|
73
|
+
variant,
|
|
74
|
+
freezeHeader,
|
|
75
|
+
freezeFirstColumn,
|
|
76
|
+
freezeLastColumn,
|
|
77
|
+
sortable,
|
|
78
|
+
sortConfig,
|
|
79
|
+
onSortChange,
|
|
80
|
+
filterable,
|
|
81
|
+
filterConfig,
|
|
82
|
+
onFilterChange,
|
|
83
|
+
expandable,
|
|
84
|
+
expandedRows,
|
|
85
|
+
onExpandedRowsChange,
|
|
86
|
+
selectable,
|
|
87
|
+
selectionType,
|
|
88
|
+
selectedRows,
|
|
89
|
+
onSelectionChange,
|
|
90
|
+
}), [
|
|
162
91
|
theme,
|
|
163
92
|
variant,
|
|
164
93
|
freezeHeader,
|
|
@@ -177,47 +106,20 @@ function TableComponent(props) {
|
|
|
177
106
|
selectionType,
|
|
178
107
|
selectedRows,
|
|
179
108
|
onSelectionChange,
|
|
180
|
-
|
|
109
|
+
]);
|
|
181
110
|
return (React__default.createElement(TableContext.Provider, { value: contextValue },
|
|
182
111
|
React__default.createElement("div", { className: "relative" },
|
|
183
|
-
!isDeclarativeAPI && columns && (React__default.createElement("div", { className: theme.columnManagerContainer },
|
|
184
|
-
React__default.createElement(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
React__default.createElement(Cog6ToothIcon, { className: "size-5", "aria-hidden": "true" }),
|
|
188
|
-
"Manage Columns")),
|
|
189
|
-
React__default.createElement(Popover.Content, { className: "p-0" },
|
|
190
|
-
React__default.createElement("div", { className: "w-64 p-3 overflow-hidden bg-white", role: "dialog", "aria-labelledby": "column-manager-title", "aria-describedby": "column-manager-description", "aria-modal": "true" },
|
|
191
|
-
React__default.createElement("div", { id: "column-manager-title", className: "text-xs uppercase font-bold mb-3 text-[var(--color-text-placeholder)]" }, "Manage Columns"),
|
|
192
|
-
React__default.createElement("div", { id: "column-manager-description", className: "sr-only" }, "Use checkboxes to control which columns are visible in the table. Locked columns cannot be hidden."),
|
|
193
|
-
React__default.createElement("div", { className: "space-y-0.5", role: "group", "aria-label": "Column visibility options" }, onColumnReorder ? (React__default.createElement(Sortable, { onReorder: handleColumnReorder, showDragHandle: true, className: "space-y-0.5" }, (columnOrder.length > 0
|
|
194
|
-
? columnOrder.map(colId => columns.find(col => col.id === colId)).filter(Boolean)
|
|
195
|
-
: columns).map((column) => {
|
|
196
|
-
const isVisible = visibleColumns.includes(column.id);
|
|
197
|
-
const isLocked = column.locked === true;
|
|
198
|
-
const displayName = typeof column.header === "string" ? column.header : column.id;
|
|
199
|
-
return (React__default.createElement(SortableItem, { key: column.id, id: column.id, disabled: isLocked, className: `bg-white hover:bg-[var(--color-background-tertiary)] rounded-lg p-1.5 transition-colors ${isLocked ? "bg-gray-50" : ""}` },
|
|
200
|
-
React__default.createElement(Checkbox, { id: `column-checkbox-${column.id}`, name: `column-${column.id}`, value: column.id, checked: isVisible, onChange: () => handleToggleColumn(column.id), "aria-label": `Toggle visibility for ${displayName} column`, label: displayName, state: isLocked ? "disabled" : "default" })));
|
|
201
|
-
}))) : ((columnOrder.length > 0
|
|
202
|
-
? columnOrder.map(colId => columns.find(col => col.id === colId)).filter(Boolean)
|
|
203
|
-
: columns).map((column) => {
|
|
204
|
-
const isVisible = visibleColumns.includes(column.id);
|
|
205
|
-
const isLocked = column.locked === true;
|
|
206
|
-
const displayName = typeof column.header === "string" ? column.header : column.id;
|
|
207
|
-
return (React__default.createElement("div", { key: column.id, className: `bg-white hover:bg-[var(--color-background-tertiary)] rounded-lg p-1.5 transition-colors ${isLocked ? "bg-gray-50" : ""}` },
|
|
208
|
-
React__default.createElement(Checkbox, { id: `column-checkbox-${column.id}`, name: `column-${column.id}`, value: column.id, checked: isVisible, onChange: () => handleToggleColumn(column.id), "aria-label": `Toggle visibility for ${displayName} column`, label: displayName, state: isLocked ? "disabled" : "default" })));
|
|
209
|
-
}))),
|
|
210
|
-
React__default.createElement("div", { className: "mt-3 flex justify-end" },
|
|
211
|
-
React__default.createElement(Button, { color: "neutral", variant: "filled", className: "w-full", onClick: handleResetToDefault }, "Reset to Default"))))))),
|
|
112
|
+
!isDeclarativeAPI && columns && showColumnManager && (React__default.createElement("div", { className: theme.columnManagerContainer },
|
|
113
|
+
React__default.createElement(TableColumnManager, { columns: columns, visibleColumns: visibleColumns, columnOrder: columnOrder, onToggleColumn: handleToggleColumn, onResetToDefault: handleResetToDefault, onColumnReorder: onColumnReorder ? handleColumnReorder : undefined }))),
|
|
114
|
+
!isDeclarativeAPI && filterable && onFilterChange && columns && (React__default.createElement("div", { className: "mb-3" },
|
|
115
|
+
React__default.createElement(TableFilter, { columns: columns, filterConfig: filterConfig, onFilterChange: onFilterChange }))),
|
|
212
116
|
!isDeclarativeAPI && selectable && selectedRows.length > 0 && (React__default.createElement(TableSelectionHeader, { selectedCount: selectedRows.length, totalCount: paginatedData.length, selectedRows: selectedRows, bulkActions: bulkActions, onClearSelection: handleClearSelection })),
|
|
213
117
|
React__default.createElement("div", { className: "overflow-x-auto" },
|
|
214
118
|
React__default.createElement("table", { className: cn(baseClasses, variantClasses, className), role: "table", "aria-label": isDeclarativeAPI ? "Data table" : `Data table with ${paginatedData.length} rows`, "aria-rowcount": pagination ? pagination.totalItems : data === null || data === void 0 ? void 0 : data.length, "aria-colcount": visibleColumnsList.length }, isDeclarativeAPI ? (children) : (React__default.createElement(React__default.Fragment, null,
|
|
215
119
|
React__default.createElement(TableHeader, { columns: visibleColumnsList, sortConfig: sortConfig, onSortChange: onSortChange, filterConfig: filterConfig, onFilterChange: onFilterChange, freezeHeader: freezeHeader, freezeFirstColumn: freezeFirstColumn, freezeLastColumn: freezeLastColumn, expandable: expandable, expandedRowRender: expandedRowRender, selectable: selectable, selectionType: selectionType, selectedRows: selectedRows, onSelectionChange: onSelectionChange, totalRowCount: paginatedData.length, theme: theme, data: paginatedData, rowKey: rowKey }),
|
|
216
120
|
React__default.createElement(TableBody, { data: paginatedData, columns: visibleColumnsList, rowKey: rowKey, expandedRowRender: expandedRowRender, expandedRows: expandedRows, onExpandedRowsChange: onExpandedRowsChange, selectable: selectable, selectionType: selectionType, selectedRows: selectedRows, onSelectionChange: onSelectionChange, freezeFirstColumn: freezeFirstColumn, freezeLastColumn: freezeLastColumn, theme: theme }))))))));
|
|
217
121
|
}
|
|
218
|
-
// Set display name for dev tools and Storybook
|
|
219
122
|
TableComponent.displayName = "Table";
|
|
220
|
-
// Export as default
|
|
221
123
|
const Table = TableComponent;
|
|
222
124
|
|
|
223
125
|
export { Table, TableContext };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
const tableTheme = {
|
|
2
2
|
// Base styles for the table
|
|
3
|
+
// Uses border-separate so sticky cells keep their borders (border-collapse
|
|
4
|
+
// paints borders on the table grid, which sticky cells float above)
|
|
3
5
|
// Light: white background | Dark: neutral-900 background
|
|
4
|
-
baseStyle: "w-full border-
|
|
6
|
+
baseStyle: "w-full border-separate border-spacing-0 text-sm " +
|
|
5
7
|
"bg-white dark:bg-[var(--color-neutral-900)]",
|
|
6
8
|
// Variant styles
|
|
7
9
|
// Each variant gets dark mode border colors and alternate row colors
|
|
@@ -11,8 +13,8 @@ const tableTheme = {
|
|
|
11
13
|
striped: "border-[var(--color-border)] dark:border-[var(--color-neutral-700)] " +
|
|
12
14
|
"[&>tbody>tr:nth-child(odd)]:bg-[var(--color-neutral-50)] dark:[&>tbody>tr:nth-child(odd)]:bg-[var(--color-neutral-800)] " +
|
|
13
15
|
"[&_td]:px-3 [&_td]:py-2.5 [&_th]:px-3 [&_th]:py-2.5",
|
|
14
|
-
bordered: "border border-[var(--color-border)] dark:border-[var(--color-neutral-700)] " +
|
|
15
|
-
"[&_td]:border [&_th]:border " +
|
|
16
|
+
bordered: "border-t border-l border-[var(--color-border)] dark:border-[var(--color-neutral-700)] " +
|
|
17
|
+
"[&_td]:border-b [&_td]:border-r [&_th]:border-b [&_th]:border-r " +
|
|
16
18
|
"[&_td]:border-[var(--color-border)] [&_th]:border-[var(--color-border)] " +
|
|
17
19
|
"dark:[&_td]:border-[var(--color-neutral-700)] dark:[&_th]:border-[var(--color-neutral-700)] " +
|
|
18
20
|
"[&_td]:px-3 [&_td]:py-2.5 [&_th]:px-3 [&_th]:py-2.5",
|
|
@@ -24,29 +26,36 @@ const tableTheme = {
|
|
|
24
26
|
headerStyle: "text-left font-medium sticky top-0 border-b " +
|
|
25
27
|
"text-[var(--color-text-primary)] border-[var(--color-border)] " +
|
|
26
28
|
"dark:text-[var(--color-neutral-200)] dark:border-[var(--color-neutral-700)]",
|
|
27
|
-
// Cell styles
|
|
28
|
-
// Light: primary text
|
|
29
|
-
cellStyle: "border-
|
|
30
|
-
"text-[var(--color-text-primary)]
|
|
31
|
-
"dark:
|
|
32
|
-
// Row styles
|
|
29
|
+
// Cell styles — borders on cells (not rows) so sticky columns keep them
|
|
30
|
+
// Light: primary text | Dark: neutral-300 text
|
|
31
|
+
cellStyle: "border-b border-b-[var(--color-border)] " +
|
|
32
|
+
"text-[var(--color-text-primary)] " +
|
|
33
|
+
"dark:border-b-[var(--color-neutral-700)] dark:text-[var(--color-neutral-300)]",
|
|
34
|
+
// Row styles — hover and layout only (borders moved to cells)
|
|
33
35
|
// Light: neutral-50 hover | Dark: neutral-800 hover
|
|
34
|
-
rowStyle: "transition-all duration-300 relative " +
|
|
35
|
-
"hover:bg-[var(--color-neutral-50)]
|
|
36
|
+
rowStyle: "group transition-all duration-300 relative " +
|
|
37
|
+
"hover:bg-[var(--color-neutral-50)] " +
|
|
38
|
+
"dark:hover:bg-[var(--color-neutral-800)]",
|
|
36
39
|
// Selected row styles
|
|
37
40
|
// Light: primary-50 background | Dark: primary-900/50 background with adjusted shadow
|
|
38
41
|
selectedRowStyle: "shadow-[inset_3px_0_0_0_var(--color-primary)] " +
|
|
39
42
|
"bg-[var(--color-primary-50)]/50 hover:bg-[var(--color-primary-50)] " +
|
|
40
43
|
"dark:bg-[var(--color-primary-900)]/30 dark:hover:bg-[var(--color-primary-900)]/50",
|
|
41
44
|
hoverRowStyle: "cursor-pointer",
|
|
42
|
-
// Frozen column styles
|
|
43
|
-
//
|
|
44
|
-
frozenColumnStyle: "sticky left-0 z-10 backdrop-blur-sm shadow-l-xl
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
"bg-
|
|
49
|
-
"dark:
|
|
45
|
+
// Frozen column styles — borders are on the cell (via cellStyle) so they
|
|
46
|
+
// travel with the sticky element. Only need vertical separator borders here.
|
|
47
|
+
frozenColumnStyle: "sticky left-0 z-10 backdrop-blur-sm shadow-l-xl " +
|
|
48
|
+
"border-r border-r-[var(--color-neutral-200)] " +
|
|
49
|
+
"bg-white/80 " +
|
|
50
|
+
"group-hover:bg-[var(--color-neutral-50)] " +
|
|
51
|
+
"dark:bg-[var(--color-neutral-900)]/80 dark:border-r-[var(--color-neutral-700)] " +
|
|
52
|
+
"dark:group-hover:bg-[var(--color-neutral-800)]",
|
|
53
|
+
lastFrozenColumnStyle: "sticky right-0 z-10 backdrop-blur-sm shadow-r-xl " +
|
|
54
|
+
"border-l border-l-[var(--color-neutral-200)] " +
|
|
55
|
+
"bg-white/80 " +
|
|
56
|
+
"group-hover:bg-[var(--color-neutral-50)] " +
|
|
57
|
+
"dark:bg-[var(--color-neutral-900)]/80 dark:border-l-[var(--color-neutral-700)] " +
|
|
58
|
+
"dark:group-hover:bg-[var(--color-neutral-800)]",
|
|
50
59
|
frozenHeaderStyle: "sticky top-0 z-20 " +
|
|
51
60
|
"shadow-lg shadow-[var(--color-neutral-200)]/50 " +
|
|
52
61
|
"dark:shadow-[var(--color-neutral-900)]/50",
|
|
@@ -22,6 +22,15 @@ export type TableVariant = 'default' | 'striped' | 'bordered' | 'compact';
|
|
|
22
22
|
export type TableAlignment = 'left' | 'center' | 'right';
|
|
23
23
|
/** Selection control types for row selection */
|
|
24
24
|
export type SelectionType = 'checkbox' | 'radio';
|
|
25
|
+
/** Filter operator types for column filtering */
|
|
26
|
+
export type FilterOperator = 'equals' | 'contains' | 'startsWith' | 'endsWith' | 'greaterThan' | 'lessThan';
|
|
27
|
+
/** Filter type for column filter UI */
|
|
28
|
+
export type FilterType = 'text' | 'select' | 'number';
|
|
29
|
+
/** Option for select-type filter columns */
|
|
30
|
+
export interface FilterOption {
|
|
31
|
+
label: string;
|
|
32
|
+
value: string;
|
|
33
|
+
}
|
|
25
34
|
/**
|
|
26
35
|
* Column definition for table data display and behavior
|
|
27
36
|
*/
|
|
@@ -38,6 +47,10 @@ export interface Column<T = any> {
|
|
|
38
47
|
sortable?: boolean;
|
|
39
48
|
/** Enable filtering for this column */
|
|
40
49
|
filterable?: boolean;
|
|
50
|
+
/** Type of filter UI to display */
|
|
51
|
+
filterType?: FilterType;
|
|
52
|
+
/** Options for select-type filter columns */
|
|
53
|
+
filterOptions?: FilterOption[];
|
|
41
54
|
/** Truncate long content with ellipsis */
|
|
42
55
|
ellipsis?: boolean;
|
|
43
56
|
/** Show tooltip on hover - boolean or function returning tooltip text */
|
|
@@ -70,6 +83,8 @@ export interface FilterConfig {
|
|
|
70
83
|
columnId: string;
|
|
71
84
|
/** Filter value - type depends on column data type */
|
|
72
85
|
value: any;
|
|
86
|
+
/** Filter operator for comparison */
|
|
87
|
+
operator?: FilterOperator;
|
|
73
88
|
}
|
|
74
89
|
export interface TableThemeOverrides {
|
|
75
90
|
baseStyle?: string;
|
|
@@ -120,13 +135,6 @@ export interface TableProps<T = any> {
|
|
|
120
135
|
/**
|
|
121
136
|
* Property name or function to extract stable row identifiers for React keys and selection.
|
|
122
137
|
* Provides consistent component identity during row reordering or updates.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* // Using a property name
|
|
126
|
-
* rowKey="id"
|
|
127
|
-
*
|
|
128
|
-
* // Using a function for complex keys
|
|
129
|
-
* rowKey={(row, index) => `${row.category}-${row.id}`}
|
|
130
138
|
*/
|
|
131
139
|
rowKey?: keyof T | ((row: T, index: number) => string | number);
|
|
132
140
|
/** Visual variant for different table styles */
|
|
@@ -228,7 +236,6 @@ export interface InternalTableHeaderProps<T> {
|
|
|
228
236
|
export interface InternalTableBodyProps<T> {
|
|
229
237
|
data: T[];
|
|
230
238
|
columns: Column<T>[];
|
|
231
|
-
/** Row key extractor for stable row identification */
|
|
232
239
|
rowKey?: keyof T | ((row: T, index: number) => string | number);
|
|
233
240
|
expandedRowRender?: (row: T) => ReactNode;
|
|
234
241
|
expandedRows?: string[];
|
|
@@ -266,3 +273,83 @@ export interface InternalTableCellProps<T> {
|
|
|
266
273
|
theme?: TableThemeOverrides;
|
|
267
274
|
children?: ReactNode;
|
|
268
275
|
}
|
|
276
|
+
export type ActionVariant = 'default' | 'danger';
|
|
277
|
+
export type ActionPriority = 'high' | 'normal';
|
|
278
|
+
export interface ActionItem<T = any> {
|
|
279
|
+
/** Unique identifier for the action */
|
|
280
|
+
id: string;
|
|
281
|
+
/** Display label for the action */
|
|
282
|
+
label: string;
|
|
283
|
+
/** Icon component to display */
|
|
284
|
+
icon: React.ComponentType<{
|
|
285
|
+
className?: string;
|
|
286
|
+
}>;
|
|
287
|
+
/** Click handler that receives the row data */
|
|
288
|
+
onClick: (row: T) => void;
|
|
289
|
+
/** Visual variant for styling (default: 'default') */
|
|
290
|
+
variant?: ActionVariant;
|
|
291
|
+
/** Priority level for display ordering (default: 'normal') */
|
|
292
|
+
priority?: ActionPriority;
|
|
293
|
+
/** Function to determine if action should be disabled */
|
|
294
|
+
disabled?: (row: T) => boolean;
|
|
295
|
+
}
|
|
296
|
+
export interface TableActionsProps<T = any> {
|
|
297
|
+
/** Array of action items to display */
|
|
298
|
+
actions: ActionItem<T>[];
|
|
299
|
+
/** Row data to pass to action handlers */
|
|
300
|
+
row: T;
|
|
301
|
+
/** Maximum number of actions to show inline before using menu (default: 2) */
|
|
302
|
+
maxVisibleActions?: number;
|
|
303
|
+
/** Additional CSS class name */
|
|
304
|
+
className?: string;
|
|
305
|
+
}
|
|
306
|
+
export interface TableActionsMenuProps<T = any> {
|
|
307
|
+
/** Array of action items to display in menu */
|
|
308
|
+
actions: ActionItem<T>[];
|
|
309
|
+
/** Row data to pass to action handlers */
|
|
310
|
+
row: T;
|
|
311
|
+
/** Function to close the menu */
|
|
312
|
+
onClose: () => void;
|
|
313
|
+
/** Additional CSS class name */
|
|
314
|
+
className?: string;
|
|
315
|
+
}
|
|
316
|
+
export interface TablePaginationProps {
|
|
317
|
+
/** Current active page number (1-based) */
|
|
318
|
+
currentPage: number;
|
|
319
|
+
/** Total number of items across all pages */
|
|
320
|
+
totalItems: number;
|
|
321
|
+
/** Number of items per page */
|
|
322
|
+
pageSize: number;
|
|
323
|
+
/** Available page size options */
|
|
324
|
+
pageSizeOptions?: number[];
|
|
325
|
+
/** Callback when page changes */
|
|
326
|
+
onPageChange: (page: number) => void;
|
|
327
|
+
/** Callback when page size changes */
|
|
328
|
+
onPageSizeChange: (pageSize: number) => void;
|
|
329
|
+
/** Whether to show the page size selector */
|
|
330
|
+
showPageSizeSelector?: boolean;
|
|
331
|
+
/** Additional CSS classes */
|
|
332
|
+
className?: string;
|
|
333
|
+
}
|
|
334
|
+
export interface TableSelectionHeaderProps {
|
|
335
|
+
selectedCount: number;
|
|
336
|
+
totalCount: number;
|
|
337
|
+
selectedRows: string[];
|
|
338
|
+
bulkActions?: BulkAction[];
|
|
339
|
+
onClearSelection: () => void;
|
|
340
|
+
className?: string;
|
|
341
|
+
}
|
|
342
|
+
export interface TableColumnManagerProps<T = any> {
|
|
343
|
+
columns: Column<T>[];
|
|
344
|
+
visibleColumns: string[];
|
|
345
|
+
columnOrder: string[];
|
|
346
|
+
onToggleColumn: (columnId: string) => void;
|
|
347
|
+
onResetToDefault: () => void;
|
|
348
|
+
onColumnReorder?: (fromIndex: number, toIndex: number) => void;
|
|
349
|
+
}
|
|
350
|
+
export interface TableFilterProps<T = any> {
|
|
351
|
+
columns: Column<T>[];
|
|
352
|
+
filterConfig: FilterConfig[];
|
|
353
|
+
onFilterChange: (filterConfig: FilterConfig[]) => void;
|
|
354
|
+
className?: string;
|
|
355
|
+
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { TableAlignment } from './Table.types';
|
|
2
|
+
/** Constant for the utility column ID used in selection/expansion columns */
|
|
3
|
+
export declare const UTILITY_COLUMN_ID = "utility";
|
|
4
|
+
/** Width value for the utility column (1px + nowrap = shrink-to-content) */
|
|
5
|
+
export declare const UTILITY_COLUMN_WIDTH = 1;
|
|
6
|
+
/** Tailwind JIT-safe alignment class mapping */
|
|
7
|
+
export declare const alignmentClasses: Record<TableAlignment, string>;
|
|
1
8
|
/**
|
|
2
9
|
* Generate a stable row identifier for React keys and row IDs
|
|
3
10
|
* @param row - The data row object
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/** Constant for the utility column ID used in selection/expansion columns */
|
|
2
|
+
const UTILITY_COLUMN_ID = 'utility';
|
|
3
|
+
/** Width value for the utility column (1px + nowrap = shrink-to-content) */
|
|
4
|
+
const UTILITY_COLUMN_WIDTH = 1;
|
|
5
|
+
/** Tailwind JIT-safe alignment class mapping */
|
|
6
|
+
const alignmentClasses = {
|
|
7
|
+
left: 'text-left',
|
|
8
|
+
center: 'text-center',
|
|
9
|
+
right: 'text-right',
|
|
10
|
+
};
|
|
1
11
|
/**
|
|
2
12
|
* Generate a stable row identifier for React keys and row IDs
|
|
3
13
|
* @param row - The data row object
|
|
@@ -27,4 +37,4 @@ function getRowId(row, index, rowKey) {
|
|
|
27
37
|
return `row-${key}`;
|
|
28
38
|
}
|
|
29
39
|
|
|
30
|
-
export { getRowId };
|
|
40
|
+
export { UTILITY_COLUMN_ID, UTILITY_COLUMN_WIDTH, alignmentClasses, getRowId };
|
package/dist/components/core/Table/{components/TableActions/TableActions.d.ts → TableActions.d.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { TableActionsProps } from "./
|
|
2
|
+
import { TableActionsProps } from "./Table.types";
|
|
3
3
|
/**
|
|
4
4
|
* TableActions component with smart display logic
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
5
|
+
* - <=2 actions: Show as individual icon buttons
|
|
6
|
+
* - >=3 actions: Show all actions in overflow menu using Dropdown
|
|
7
7
|
*/
|
|
8
8
|
export declare const TableActions: <T>({ actions, row, maxVisibleActions, className, }: TableActionsProps<T>) => React.JSX.Element;
|
package/dist/components/core/Table/{components/TableActions/TableActions.js → TableActions.js}
RENAMED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import React__default, { useMemo } from 'react';
|
|
2
2
|
import { EllipsisVerticalIcon } from '@heroicons/react/24/outline';
|
|
3
|
-
import { cn } from '
|
|
4
|
-
import { Dropdown } from '
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
8
|
-
import '
|
|
9
|
-
import '
|
|
10
|
-
import { Button } from '
|
|
3
|
+
import { cn } from '../../../utils/cn.js';
|
|
4
|
+
import { Dropdown } from '../Dropdown/Dropdown.js';
|
|
5
|
+
import '../Dropdown/DropdownTrigger.js';
|
|
6
|
+
import '../Dropdown/DropdownMenu.js';
|
|
7
|
+
import '../Dropdown/DropdownItem.js';
|
|
8
|
+
import '../Dropdown/DropdownSection.js';
|
|
9
|
+
import '../Dropdown/DropdownSeparator.js';
|
|
10
|
+
import { Button } from '../Button/Button.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* TableActions component with smart display logic
|
|
14
|
-
* -
|
|
15
|
-
* -
|
|
14
|
+
* - <=2 actions: Show as individual icon buttons
|
|
15
|
+
* - >=3 actions: Show all actions in overflow menu using Dropdown
|
|
16
16
|
*/
|
|
17
17
|
const TableActions = ({ actions, row, maxVisibleActions = 2, className, }) => {
|
|
18
|
-
// Sort actions by priority (high priority first)
|
|
19
18
|
const sortedActions = useMemo(() => {
|
|
20
19
|
return [...actions].sort((a, b) => {
|
|
21
20
|
const priorityOrder = { high: 0, normal: 1 };
|
|
@@ -24,15 +23,12 @@ const TableActions = ({ actions, row, maxVisibleActions = 2, className, }) => {
|
|
|
24
23
|
return aPriority - bPriority;
|
|
25
24
|
});
|
|
26
25
|
}, [actions]);
|
|
27
|
-
// Determine display strategy
|
|
28
26
|
const shouldUseMenu = actions.length > maxVisibleActions;
|
|
29
|
-
// Get disabled keys for Dropdown
|
|
30
27
|
const disabledKeys = useMemo(() => {
|
|
31
28
|
return sortedActions
|
|
32
29
|
.filter((action) => { var _a; return (_a = action.disabled) === null || _a === void 0 ? void 0 : _a.call(action, row); })
|
|
33
30
|
.map((action) => action.id);
|
|
34
31
|
}, [sortedActions, row]);
|
|
35
|
-
// Handle action click from Dropdown
|
|
36
32
|
const handleAction = (key) => {
|
|
37
33
|
var _a;
|
|
38
34
|
const action = sortedActions.find((a) => a.id === key);
|
|
@@ -40,34 +36,28 @@ const TableActions = ({ actions, row, maxVisibleActions = 2, className, }) => {
|
|
|
40
36
|
action.onClick(row);
|
|
41
37
|
}
|
|
42
38
|
};
|
|
43
|
-
// Render individual action buttons
|
|
44
39
|
const renderInlineActions = (actionsToRender) => {
|
|
45
40
|
return actionsToRender.map((action) => {
|
|
46
41
|
var _a;
|
|
47
42
|
const isDisabled = (_a = action.disabled) === null || _a === void 0 ? void 0 : _a.call(action, row);
|
|
48
43
|
const Icon = action.icon;
|
|
49
44
|
return (React__default.createElement(Button, { key: action.id, color: "primary", variant: "link", iconOnly: true, onClick: () => action.onClick(row), disabled: isDisabled, "aria-label": action.label, className: cn(action.variant === "danger"
|
|
50
|
-
? "text-
|
|
51
|
-
: "text-
|
|
45
|
+
? "text-[var(--color-danger-400)] hover:text-[var(--color-danger)] dark:text-[var(--color-danger-400)] dark:hover:text-[var(--color-danger-300)]"
|
|
46
|
+
: "text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)] dark:text-[var(--color-text-muted)] dark:hover:text-[var(--color-text-secondary)]") },
|
|
52
47
|
React__default.createElement(Icon, { className: "size-4" })));
|
|
53
48
|
});
|
|
54
49
|
};
|
|
55
|
-
// Render overflow menu using Dropdown
|
|
56
50
|
const renderOverflowMenu = () => {
|
|
57
51
|
return (React__default.createElement(Dropdown, { placement: "bottom-end", offset: 4, disabledKeys: disabledKeys, onAction: handleAction },
|
|
58
52
|
React__default.createElement(Dropdown.Trigger, null,
|
|
59
|
-
React__default.createElement(Button, { color: "neutral", variant: "
|
|
53
|
+
React__default.createElement(Button, { color: "neutral", variant: "outline", size: "sm", iconOnly: true, "aria-label": "More actions", className: "text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)]" },
|
|
60
54
|
React__default.createElement(EllipsisVerticalIcon, { className: "size-4" }))),
|
|
61
55
|
React__default.createElement(Dropdown.Menu, { "aria-label": "Row actions" }, sortedActions.map((action) => {
|
|
62
56
|
const Icon = action.icon;
|
|
63
57
|
return (React__default.createElement(Dropdown.Item, { key: action.id, itemKey: action.id, isDanger: action.variant === "danger", startContent: React__default.createElement(Icon, { className: "size-4" }) }, action.label));
|
|
64
58
|
}))));
|
|
65
59
|
};
|
|
66
|
-
return (React__default.createElement("div", { className: cn("flex items-center justify-end", className) }, shouldUseMenu
|
|
67
|
-
? // All actions in overflow menu
|
|
68
|
-
renderOverflowMenu()
|
|
69
|
-
: // Show actions inline
|
|
70
|
-
renderInlineActions(sortedActions)));
|
|
60
|
+
return (React__default.createElement("div", { className: cn("flex items-center justify-end", className) }, shouldUseMenu ? renderOverflowMenu() : renderInlineActions(sortedActions)));
|
|
71
61
|
};
|
|
72
62
|
|
|
73
63
|
export { TableActions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import { cn } from '
|
|
2
|
+
import { cn } from '../../../utils/cn.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* TableActionsMenu component for displaying actions in an overflow menu
|
|
@@ -12,12 +12,12 @@ const TableActionsMenu = ({ actions, row, onClose, className, }) => {
|
|
|
12
12
|
action.onClick(row);
|
|
13
13
|
onClose();
|
|
14
14
|
};
|
|
15
|
-
return (React__default.createElement("div", { className: cn("
|
|
15
|
+
return (React__default.createElement("div", { className: cn("min-w-[180px] p-1", className), role: "menu", "aria-label": "Row actions" }, actions.map((action) => {
|
|
16
16
|
var _a;
|
|
17
17
|
const isDisabled = (_a = action.disabled) === null || _a === void 0 ? void 0 : _a.call(action, row);
|
|
18
18
|
const Icon = action.icon;
|
|
19
|
-
return (React__default.createElement("button", { key: action.id, onClick: () => handleActionClick(action), disabled: isDisabled, className: cn("w-full flex items-center gap-3 px-3 py-2 text-sm font-medium text-left transition-all duration-300", "hover:bg-
|
|
20
|
-
? "text-danger
|
|
19
|
+
return (React__default.createElement("button", { key: action.id, onClick: () => handleActionClick(action), disabled: isDisabled, className: cn("w-full flex items-center gap-3 px-3 py-2 text-sm font-medium text-left transition-all duration-300", "hover:bg-[var(--color-background-secondary)] focus:bg-[var(--color-background-secondary)] focus:outline-none rounded-sm cursor-pointer", action.variant === 'danger'
|
|
20
|
+
? "text-[var(--color-danger)] hover:bg-[var(--color-danger-50)] focus:bg-[var(--color-danger-50)]"
|
|
21
21
|
: "text-[var(--color-text-primary)]", isDisabled && "opacity-50 cursor-not-allowed hover:bg-transparent"), role: "menuitem", "aria-label": action.label },
|
|
22
22
|
React__default.createElement(Icon, { className: "size-4 flex-shrink-0" }),
|
|
23
23
|
React__default.createElement("span", null, action.label)));
|