@true-tech-team/react-components 0.0.5 → 0.0.6
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/index.css +1 -1
- package/index.js +1 -1
- package/index.mjs +14032 -8735
- package/lib/components/display/List/List.d.ts +6 -0
- package/lib/components/display/List/ListContext.d.ts +15 -0
- package/lib/components/display/List/ListEmpty.d.ts +25 -0
- package/lib/components/display/List/ListGroup.d.ts +36 -0
- package/lib/components/display/List/ListHeader.d.ts +62 -0
- package/lib/components/display/List/ListItem.d.ts +19 -0
- package/lib/components/display/List/ListSearch.d.ts +32 -0
- package/lib/components/display/List/ListSkeleton.d.ts +27 -0
- package/lib/components/display/List/hooks/index.d.ts +5 -0
- package/lib/components/display/List/hooks/useListExpand.d.ts +6 -0
- package/lib/components/display/List/hooks/useListFilter.d.ts +6 -0
- package/lib/components/display/List/hooks/useListGroups.d.ts +6 -0
- package/lib/components/display/List/hooks/useListKeyboardNav.d.ts +6 -0
- package/lib/components/display/List/hooks/useListSelection.d.ts +6 -0
- package/lib/components/display/List/index.d.ts +11 -0
- package/lib/components/display/List/types.d.ts +485 -0
- package/lib/components/display/List/utils.d.ts +47 -0
- package/lib/components/display/Table/Table.d.ts +6 -0
- package/lib/components/display/Table/TableBody.d.ts +4 -0
- package/lib/components/display/Table/TableCell.d.ts +12 -0
- package/lib/components/display/Table/TableContext.d.ts +10 -0
- package/lib/components/display/Table/TableHeader.d.ts +4 -0
- package/lib/components/display/Table/TableRow.d.ts +9 -0
- package/lib/components/display/Table/TableSearch.d.ts +32 -0
- package/lib/components/display/Table/TableSkeleton.d.ts +12 -0
- package/lib/components/display/Table/hooks/index.d.ts +10 -0
- package/lib/components/display/Table/hooks/useInfiniteScroll.d.ts +11 -0
- package/lib/components/display/Table/hooks/useTableExpand.d.ts +10 -0
- package/lib/components/display/Table/hooks/useTableFilter.d.ts +22 -0
- package/lib/components/display/Table/hooks/useTableSelection.d.ts +16 -0
- package/lib/components/display/Table/hooks/useTableSort.d.ts +11 -0
- package/lib/components/display/Table/index.d.ts +13 -0
- package/lib/components/display/Table/types.d.ts +295 -0
- package/lib/components/display/Table/utils.d.ts +37 -0
- package/lib/components/display/index.d.ts +1 -0
- package/lib/components/dnd/DndProvider/DndContext.d.ts +91 -0
- package/lib/components/dnd/DndProvider/DndProvider.d.ts +37 -0
- package/lib/components/dnd/DndProvider/index.d.ts +3 -0
- package/lib/components/dnd/DragHandle/DragHandle.d.ts +41 -0
- package/lib/components/dnd/DragHandle/index.d.ts +2 -0
- package/lib/components/dnd/DragOverlay/DragOverlay.d.ts +39 -0
- package/lib/components/dnd/DragOverlay/index.d.ts +2 -0
- package/lib/components/dnd/KanbanBoard/KanbanBoard.d.ts +126 -0
- package/lib/components/dnd/KanbanBoard/KanbanBoardContext.d.ts +62 -0
- package/lib/components/dnd/KanbanBoard/KanbanCard.d.ts +76 -0
- package/lib/components/dnd/KanbanBoard/KanbanColumn.d.ts +43 -0
- package/lib/components/dnd/KanbanBoard/index.d.ts +5 -0
- package/lib/components/dnd/ResizablePanels/ResizablePanel.d.ts +53 -0
- package/lib/components/dnd/ResizablePanels/ResizablePanels.d.ts +43 -0
- package/lib/components/dnd/ResizablePanels/ResizablePanelsContext.d.ts +64 -0
- package/lib/components/dnd/ResizablePanels/ResizeHandle.d.ts +28 -0
- package/lib/components/dnd/ResizablePanels/index.d.ts +5 -0
- package/lib/components/dnd/SortableGrid/SortableGrid.d.ts +76 -0
- package/lib/components/dnd/SortableGrid/SortableGridItem.d.ts +47 -0
- package/lib/components/dnd/SortableGrid/index.d.ts +3 -0
- package/lib/components/dnd/SortableList/SortableItem.d.ts +76 -0
- package/lib/components/dnd/SortableList/SortableList.d.ts +98 -0
- package/lib/components/dnd/SortableList/SortableListContext.d.ts +42 -0
- package/lib/components/dnd/SortableList/index.d.ts +4 -0
- package/lib/components/dnd/hooks/index.d.ts +3 -0
- package/lib/components/dnd/hooks/useDraggable.d.ts +66 -0
- package/lib/components/dnd/hooks/useDroppable.d.ts +73 -0
- package/lib/components/dnd/hooks/useSortable.d.ts +94 -0
- package/lib/components/dnd/index.d.ts +8 -0
- package/lib/components/filters/FilterContext.d.ts +34 -0
- package/lib/components/filters/core/ActiveFilters/ActiveFilters.d.ts +16 -0
- package/lib/components/filters/core/ActiveFilters/index.d.ts +2 -0
- package/lib/components/filters/core/FilterField/FilterField.d.ts +17 -0
- package/lib/components/filters/core/FilterField/index.d.ts +2 -0
- package/lib/components/filters/core/FilterProvider/FilterProvider.d.ts +4 -0
- package/lib/components/filters/core/FilterProvider/index.d.ts +2 -0
- package/lib/components/filters/core/FilterSection/FilterSection.d.ts +16 -0
- package/lib/components/filters/core/FilterSection/index.d.ts +2 -0
- package/lib/components/filters/core/index.d.ts +7 -0
- package/lib/components/filters/fields/CheckboxFilter.d.ts +17 -0
- package/lib/components/filters/fields/DateFilter.d.ts +21 -0
- package/lib/components/filters/fields/DateRangeFilter.d.ts +19 -0
- package/lib/components/filters/fields/ListSelectFilter.d.ts +19 -0
- package/lib/components/filters/fields/MultiSelectFilter.d.ts +19 -0
- package/lib/components/filters/fields/NumberFilter.d.ts +19 -0
- package/lib/components/filters/fields/NumberRangeFilter.d.ts +19 -0
- package/lib/components/filters/fields/RatingFilter.d.ts +19 -0
- package/lib/components/filters/fields/SelectFilter.d.ts +21 -0
- package/lib/components/filters/fields/TextFilter.d.ts +21 -0
- package/lib/components/filters/fields/ToggleFilter.d.ts +17 -0
- package/lib/components/filters/fields/index.d.ts +25 -0
- package/lib/components/filters/hooks/index.d.ts +9 -0
- package/lib/components/filters/hooks/useFilter.d.ts +57 -0
- package/lib/components/filters/hooks/useFilterDependencies.d.ts +40 -0
- package/lib/components/filters/hooks/useFilterOptions.d.ts +70 -0
- package/lib/components/filters/index.d.ts +43 -0
- package/lib/components/filters/layouts/FilterAccordion/FilterAccordion.d.ts +15 -0
- package/lib/components/filters/layouts/FilterAccordion/index.d.ts +2 -0
- package/lib/components/filters/layouts/FilterBar/FilterBar.d.ts +18 -0
- package/lib/components/filters/layouts/FilterBar/index.d.ts +2 -0
- package/lib/components/filters/layouts/FilterModal/FilterModal.d.ts +24 -0
- package/lib/components/filters/layouts/FilterModal/index.d.ts +2 -0
- package/lib/components/filters/layouts/FilterPopover/FilterPopover.d.ts +19 -0
- package/lib/components/filters/layouts/FilterPopover/index.d.ts +2 -0
- package/lib/components/filters/layouts/FilterSidebar/FilterSidebar.d.ts +20 -0
- package/lib/components/filters/layouts/FilterSidebar/index.d.ts +2 -0
- package/lib/components/filters/layouts/index.d.ts +8 -0
- package/lib/components/filters/types.d.ts +937 -0
- package/lib/components/index.d.ts +8 -0
- package/lib/components/inputs/Checkbox/Checkbox.d.ts +2 -2
- package/lib/components/inputs/NumberInput/NumberInput.d.ts +3 -1
- package/package.json +1 -1
- package/README.md +0 -826
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SelectionMode } from '../types';
|
|
2
|
+
export interface UseTableSelectionOptions {
|
|
3
|
+
selectionMode: SelectionMode;
|
|
4
|
+
selectedKeys?: string[];
|
|
5
|
+
defaultSelectedKeys?: string[];
|
|
6
|
+
onSelectionChange?: (keys: string[]) => void;
|
|
7
|
+
allRowKeys: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface UseTableSelectionReturn {
|
|
10
|
+
selectedKeys: Set<string>;
|
|
11
|
+
onSelectRow: (key: string, selected: boolean) => void;
|
|
12
|
+
onSelectAll: (selected: boolean) => void;
|
|
13
|
+
isAllSelected: boolean;
|
|
14
|
+
isIndeterminate: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function useTableSelection({ selectionMode, selectedKeys: controlledKeys, defaultSelectedKeys, onSelectionChange, allRowKeys, }: UseTableSelectionOptions): UseTableSelectionReturn;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SortState } from '../types';
|
|
2
|
+
export interface UseTableSortOptions {
|
|
3
|
+
sort?: SortState;
|
|
4
|
+
defaultSort?: SortState;
|
|
5
|
+
onSortChange?: (sort: SortState) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface UseTableSortReturn {
|
|
8
|
+
sort: SortState;
|
|
9
|
+
onSort: (column: string) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function useTableSort({ sort: controlledSort, defaultSort, onSortChange, }: UseTableSortOptions): UseTableSortReturn;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { Table, default } from './Table';
|
|
2
|
+
export { TableHeader } from './TableHeader';
|
|
3
|
+
export { TableBody } from './TableBody';
|
|
4
|
+
export { TableRow } from './TableRow';
|
|
5
|
+
export { TableCell } from './TableCell';
|
|
6
|
+
export { TableSkeleton } from './TableSkeleton';
|
|
7
|
+
export { TableSearch } from './TableSearch';
|
|
8
|
+
export type { TableSearchProps } from './TableSearch';
|
|
9
|
+
export { TableContext, useTableContext, useTableContextStrict } from './TableContext';
|
|
10
|
+
export type { TableProps, TableContextValue, ColumnConfig, ColumnAlign, SortState, SortDirection, SelectionMode, TablePaginationConfig, TableInfiniteScrollConfig, TableSkeletonConfig, } from './types';
|
|
11
|
+
export { autoGenerateColumns, getCellValue, sortData, formatCellValue } from './utils';
|
|
12
|
+
export { useTableSelection, useTableSort, useTableExpand, useInfiniteScroll, useTableFilter, } from './hooks';
|
|
13
|
+
export type { UseTableSelectionOptions, UseTableSelectionReturn, UseTableSortOptions, UseTableSortReturn, UseTableExpandOptions, UseTableExpandReturn, UseInfiniteScrollOptions, UseInfiniteScrollReturn, UseTableFilterOptions, UseTableFilterReturn, } from './hooks';
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { ReactNode, MouseEvent } from 'react';
|
|
2
|
+
import { BaseComponentProps, ComponentSize } from '../../../types';
|
|
3
|
+
export type ColumnAlign = 'left' | 'center' | 'right';
|
|
4
|
+
export type SortDirection = 'asc' | 'desc' | null;
|
|
5
|
+
export interface ColumnConfig<T = Record<string, unknown>> {
|
|
6
|
+
/**
|
|
7
|
+
* Data key to access row data (supports dot notation for nested properties)
|
|
8
|
+
*/
|
|
9
|
+
key: keyof T | string;
|
|
10
|
+
/**
|
|
11
|
+
* Header content - string or ReactNode
|
|
12
|
+
*/
|
|
13
|
+
header: ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Column width using CSS grid template value
|
|
16
|
+
* @example 'auto', '1fr', '320px', 'minmax(100px, 1fr)'
|
|
17
|
+
* @default 'auto'
|
|
18
|
+
*/
|
|
19
|
+
width?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Content alignment
|
|
22
|
+
* @default auto-detected based on data type (numbers right, text left)
|
|
23
|
+
*/
|
|
24
|
+
align?: ColumnAlign;
|
|
25
|
+
/**
|
|
26
|
+
* Whether column is sortable
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
sortable?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Custom render function for cell content
|
|
32
|
+
*/
|
|
33
|
+
render?: (value: unknown, row: T, rowIndex: number) => ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Whether column is sticky (for horizontal scrolling)
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
sticky?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Custom sort comparison function
|
|
41
|
+
*/
|
|
42
|
+
sortFn?: (a: T, b: T, direction: 'asc' | 'desc') => number;
|
|
43
|
+
}
|
|
44
|
+
export interface SortState {
|
|
45
|
+
column: string | null;
|
|
46
|
+
direction: SortDirection;
|
|
47
|
+
}
|
|
48
|
+
export type SelectionMode = 'none' | 'single' | 'multiple';
|
|
49
|
+
export interface TablePaginationConfig {
|
|
50
|
+
/**
|
|
51
|
+
* Number of items per page
|
|
52
|
+
*/
|
|
53
|
+
pageSize: number;
|
|
54
|
+
/**
|
|
55
|
+
* Current page number (1-indexed)
|
|
56
|
+
*/
|
|
57
|
+
currentPage: number;
|
|
58
|
+
/**
|
|
59
|
+
* Total number of items
|
|
60
|
+
*/
|
|
61
|
+
totalItems: number;
|
|
62
|
+
/**
|
|
63
|
+
* Callback when page changes
|
|
64
|
+
*/
|
|
65
|
+
onPageChange: (page: number) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Available page size options for the select dropdown
|
|
68
|
+
* If provided, shows a page size selector
|
|
69
|
+
* @example [10, 25, 50, 100]
|
|
70
|
+
*/
|
|
71
|
+
pageSizeOptions?: number[];
|
|
72
|
+
/**
|
|
73
|
+
* Callback when page size changes
|
|
74
|
+
*/
|
|
75
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
76
|
+
}
|
|
77
|
+
export interface TableInfiniteScrollConfig {
|
|
78
|
+
/**
|
|
79
|
+
* Callback to load more data
|
|
80
|
+
*/
|
|
81
|
+
onLoadMore: () => void;
|
|
82
|
+
/**
|
|
83
|
+
* Whether there is more data to load
|
|
84
|
+
*/
|
|
85
|
+
hasMore: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Whether currently loading more data
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
90
|
+
loading?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Intersection observer threshold (0-1)
|
|
93
|
+
* @default 0.1
|
|
94
|
+
*/
|
|
95
|
+
threshold?: number;
|
|
96
|
+
}
|
|
97
|
+
export interface TableSkeletonConfig {
|
|
98
|
+
/**
|
|
99
|
+
* Number of skeleton rows to display
|
|
100
|
+
* @default 5
|
|
101
|
+
*/
|
|
102
|
+
rows?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Whether to show skeleton state
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
107
|
+
enabled?: boolean;
|
|
108
|
+
}
|
|
109
|
+
export interface TableProps<T extends Record<string, unknown> = Record<string, unknown>> extends Omit<BaseComponentProps, 'children'> {
|
|
110
|
+
/**
|
|
111
|
+
* Table data array
|
|
112
|
+
*/
|
|
113
|
+
data: T[];
|
|
114
|
+
/**
|
|
115
|
+
* Column configurations
|
|
116
|
+
* If not provided, columns are auto-generated from data keys
|
|
117
|
+
*/
|
|
118
|
+
columns?: Array<ColumnConfig<T>>;
|
|
119
|
+
/**
|
|
120
|
+
* Unique key for each row
|
|
121
|
+
* @default 'id'
|
|
122
|
+
*/
|
|
123
|
+
rowKey?: keyof T | ((row: T, index: number) => string);
|
|
124
|
+
/**
|
|
125
|
+
* Table size variant
|
|
126
|
+
* @default 'md'
|
|
127
|
+
*/
|
|
128
|
+
size?: ComponentSize;
|
|
129
|
+
/**
|
|
130
|
+
* Table visual variant
|
|
131
|
+
* @default 'default'
|
|
132
|
+
*/
|
|
133
|
+
variant?: 'default' | 'striped' | 'bordered';
|
|
134
|
+
/**
|
|
135
|
+
* Current sort state (controlled)
|
|
136
|
+
*/
|
|
137
|
+
sort?: SortState;
|
|
138
|
+
/**
|
|
139
|
+
* Default sort state (uncontrolled)
|
|
140
|
+
*/
|
|
141
|
+
defaultSort?: SortState;
|
|
142
|
+
/**
|
|
143
|
+
* Callback when sort changes
|
|
144
|
+
*/
|
|
145
|
+
onSortChange?: (sort: SortState) => void;
|
|
146
|
+
/**
|
|
147
|
+
* Selection mode
|
|
148
|
+
* @default 'none'
|
|
149
|
+
*/
|
|
150
|
+
selectionMode?: SelectionMode;
|
|
151
|
+
/**
|
|
152
|
+
* Selected row keys (controlled)
|
|
153
|
+
*/
|
|
154
|
+
selectedKeys?: string[];
|
|
155
|
+
/**
|
|
156
|
+
* Default selected keys (uncontrolled)
|
|
157
|
+
*/
|
|
158
|
+
defaultSelectedKeys?: string[];
|
|
159
|
+
/**
|
|
160
|
+
* Callback when selection changes
|
|
161
|
+
*/
|
|
162
|
+
onSelectionChange?: (selectedKeys: string[]) => void;
|
|
163
|
+
/**
|
|
164
|
+
* Whether to show selection controls (checkbox/radio)
|
|
165
|
+
* When false, rows can still be selected by clicking but no visual control is shown
|
|
166
|
+
* @default true
|
|
167
|
+
*/
|
|
168
|
+
showSelectionControls?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Callback when row is clicked
|
|
171
|
+
*/
|
|
172
|
+
onRowClick?: (row: T, index: number, event: MouseEvent) => void;
|
|
173
|
+
/**
|
|
174
|
+
* Render function for expandable content
|
|
175
|
+
* If provided, rows become expandable
|
|
176
|
+
*/
|
|
177
|
+
expandedRowRender?: (row: T, index: number) => ReactNode;
|
|
178
|
+
/**
|
|
179
|
+
* Expanded row keys (controlled)
|
|
180
|
+
*/
|
|
181
|
+
expandedKeys?: string[];
|
|
182
|
+
/**
|
|
183
|
+
* Default expanded keys (uncontrolled)
|
|
184
|
+
*/
|
|
185
|
+
defaultExpandedKeys?: string[];
|
|
186
|
+
/**
|
|
187
|
+
* Callback when expand state changes
|
|
188
|
+
*/
|
|
189
|
+
onExpandChange?: (expandedKeys: string[]) => void;
|
|
190
|
+
/**
|
|
191
|
+
* Pagination configuration
|
|
192
|
+
*/
|
|
193
|
+
pagination?: TablePaginationConfig;
|
|
194
|
+
/**
|
|
195
|
+
* Infinite scroll configuration (mutually exclusive with pagination)
|
|
196
|
+
*/
|
|
197
|
+
infiniteScroll?: TableInfiniteScrollConfig;
|
|
198
|
+
/**
|
|
199
|
+
* Enable built-in search
|
|
200
|
+
* @default false
|
|
201
|
+
*/
|
|
202
|
+
searchable?: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Search placeholder text
|
|
205
|
+
* @default 'Search...'
|
|
206
|
+
*/
|
|
207
|
+
searchPlaceholder?: string;
|
|
208
|
+
/**
|
|
209
|
+
* Fields to search (for default search behavior).
|
|
210
|
+
* If not provided, searches all column keys.
|
|
211
|
+
*/
|
|
212
|
+
searchFields?: Array<keyof T>;
|
|
213
|
+
/**
|
|
214
|
+
* Custom search function
|
|
215
|
+
*/
|
|
216
|
+
searchFn?: (item: T, query: string) => boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Search query (controlled)
|
|
219
|
+
*/
|
|
220
|
+
searchQuery?: string;
|
|
221
|
+
/**
|
|
222
|
+
* Callback when search changes
|
|
223
|
+
*/
|
|
224
|
+
onSearchChange?: (query: string) => void;
|
|
225
|
+
/**
|
|
226
|
+
* Debounce delay for search in milliseconds
|
|
227
|
+
* @default 300
|
|
228
|
+
*/
|
|
229
|
+
searchDebounce?: number;
|
|
230
|
+
/**
|
|
231
|
+
* Enable sticky header
|
|
232
|
+
* @default false
|
|
233
|
+
*/
|
|
234
|
+
stickyHeader?: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Enable sticky first column
|
|
237
|
+
* @default false
|
|
238
|
+
*/
|
|
239
|
+
stickyFirstColumn?: boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Maximum height for scrollable table
|
|
242
|
+
*/
|
|
243
|
+
maxHeight?: string | number;
|
|
244
|
+
/**
|
|
245
|
+
* Empty state content
|
|
246
|
+
* @default 'No data available'
|
|
247
|
+
*/
|
|
248
|
+
emptyContent?: ReactNode;
|
|
249
|
+
/**
|
|
250
|
+
* Loading state
|
|
251
|
+
* @default false
|
|
252
|
+
*/
|
|
253
|
+
loading?: boolean;
|
|
254
|
+
/**
|
|
255
|
+
* Loading indicator content
|
|
256
|
+
*/
|
|
257
|
+
loadingContent?: ReactNode;
|
|
258
|
+
/**
|
|
259
|
+
* Skeleton loader configuration
|
|
260
|
+
* Shows skeleton rows instead of a spinner when loading
|
|
261
|
+
*/
|
|
262
|
+
skeleton?: TableSkeletonConfig;
|
|
263
|
+
/**
|
|
264
|
+
* Caption for the table
|
|
265
|
+
*/
|
|
266
|
+
caption?: string;
|
|
267
|
+
/**
|
|
268
|
+
* Whether caption is visually hidden
|
|
269
|
+
* @default false
|
|
270
|
+
*/
|
|
271
|
+
captionHidden?: boolean;
|
|
272
|
+
}
|
|
273
|
+
export interface TableContextValue<T = Record<string, unknown>> {
|
|
274
|
+
data: T[];
|
|
275
|
+
columns: Array<ColumnConfig<T>>;
|
|
276
|
+
getRowKey: (row: T, index: number) => string;
|
|
277
|
+
size: ComponentSize;
|
|
278
|
+
variant: 'default' | 'striped' | 'bordered';
|
|
279
|
+
sort: SortState;
|
|
280
|
+
onSort: (column: string) => void;
|
|
281
|
+
selectionMode: SelectionMode;
|
|
282
|
+
selectedKeys: Set<string>;
|
|
283
|
+
onSelectRow: (key: string, selected: boolean) => void;
|
|
284
|
+
onSelectAll: (selected: boolean) => void;
|
|
285
|
+
isAllSelected: boolean;
|
|
286
|
+
isIndeterminate: boolean;
|
|
287
|
+
showSelectionControls: boolean;
|
|
288
|
+
expandedKeys: Set<string>;
|
|
289
|
+
onExpand: (key: string, expanded: boolean) => void;
|
|
290
|
+
hasExpandableRows: boolean;
|
|
291
|
+
expandedRowRender?: (row: T, index: number) => ReactNode;
|
|
292
|
+
onRowClick?: (row: T, index: number, event: MouseEvent) => void;
|
|
293
|
+
stickyHeader: boolean;
|
|
294
|
+
stickyFirstColumn: boolean;
|
|
295
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ColumnConfig, ColumnAlign, SortState } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Column width validation rules:
|
|
5
|
+
* 1. All columns must have a minimum width > 0
|
|
6
|
+
* 2. Only one column can have a dynamic width (1fr) to prevent uneven column widths
|
|
7
|
+
* 3. If no width is specified, use the average size of data to calculate width
|
|
8
|
+
*/
|
|
9
|
+
export declare function calculateColumnWidths<T extends Record<string, unknown>>(columns: Array<ColumnConfig<T>>, data: T[]): string[];
|
|
10
|
+
/**
|
|
11
|
+
* Auto-generate columns from the first data item's keys
|
|
12
|
+
*/
|
|
13
|
+
export declare function autoGenerateColumns<T extends Record<string, unknown>>(data: T[]): Array<ColumnConfig<T>>;
|
|
14
|
+
/**
|
|
15
|
+
* Format header text from key (camelCase/snake_case -> Title Case)
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatHeaderFromKey(key: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Detect column alignment based on data type
|
|
20
|
+
*/
|
|
21
|
+
export declare function detectAlignment(value: unknown): ColumnAlign;
|
|
22
|
+
/**
|
|
23
|
+
* Get cell value by column key (supports dot notation for nested properties)
|
|
24
|
+
*/
|
|
25
|
+
export declare function getCellValue<T>(row: T, key: string): unknown;
|
|
26
|
+
/**
|
|
27
|
+
* Default sort comparison function
|
|
28
|
+
*/
|
|
29
|
+
export declare function defaultSortFn<T>(a: T, b: T, column: string, direction: 'asc' | 'desc'): number;
|
|
30
|
+
/**
|
|
31
|
+
* Sort data by column
|
|
32
|
+
*/
|
|
33
|
+
export declare function sortData<T>(data: T[], sort: SortState, columns: Array<ColumnConfig<T>>): T[];
|
|
34
|
+
/**
|
|
35
|
+
* Format cell value for display
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatCellValue(value: unknown): ReactNode;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DnD context for sharing drag state across components
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Data attached to a draggable item
|
|
6
|
+
*/
|
|
7
|
+
export interface DragData {
|
|
8
|
+
/** Unique identifier */
|
|
9
|
+
id: string;
|
|
10
|
+
/** Item type for filtering drop targets */
|
|
11
|
+
type?: string;
|
|
12
|
+
/** Index in list (for sortable) */
|
|
13
|
+
index?: number;
|
|
14
|
+
/** Additional custom data */
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Active drag state
|
|
19
|
+
*/
|
|
20
|
+
export interface ActiveDrag {
|
|
21
|
+
/** ID of the dragged item */
|
|
22
|
+
id: string;
|
|
23
|
+
/** Data attached to the dragged item */
|
|
24
|
+
data: DragData;
|
|
25
|
+
/** Element being dragged */
|
|
26
|
+
element: HTMLElement | null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* DnD context value
|
|
30
|
+
*/
|
|
31
|
+
export interface DndContextValue {
|
|
32
|
+
/** Currently active drag, null if nothing is being dragged */
|
|
33
|
+
active: ActiveDrag | null;
|
|
34
|
+
/** ID of the element currently being dragged over */
|
|
35
|
+
overId: string | null;
|
|
36
|
+
/** Data of the element currently being dragged over */
|
|
37
|
+
overData: DragData | null;
|
|
38
|
+
/** Set active drag state */
|
|
39
|
+
setActive: (active: ActiveDrag | null) => void;
|
|
40
|
+
/** Set over state */
|
|
41
|
+
setOver: (id: string | null, data: DragData | null) => void;
|
|
42
|
+
/** Register a droppable and return unregister function */
|
|
43
|
+
registerDroppable: (id: string, data: DragData) => () => void;
|
|
44
|
+
/** Get all registered droppables */
|
|
45
|
+
getDroppables: () => Map<string, DragData>;
|
|
46
|
+
/** Drag end callback */
|
|
47
|
+
onDragEnd?: (event: DragEndEvent) => void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Event fired when drag ends
|
|
51
|
+
*/
|
|
52
|
+
export interface DragEndEvent {
|
|
53
|
+
/** The dragged item */
|
|
54
|
+
active: ActiveDrag;
|
|
55
|
+
/** The drop target, null if dropped outside */
|
|
56
|
+
over: {
|
|
57
|
+
id: string;
|
|
58
|
+
data: DragData;
|
|
59
|
+
} | null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Event fired when drag starts
|
|
63
|
+
*/
|
|
64
|
+
export interface DragStartEvent {
|
|
65
|
+
/** The dragged item */
|
|
66
|
+
active: ActiveDrag;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Event fired when dragging over a droppable
|
|
70
|
+
*/
|
|
71
|
+
export interface DragOverEvent {
|
|
72
|
+
/** The dragged item */
|
|
73
|
+
active: ActiveDrag;
|
|
74
|
+
/** The element being dragged over */
|
|
75
|
+
over: {
|
|
76
|
+
id: string;
|
|
77
|
+
data: DragData;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* DnD context
|
|
82
|
+
*/
|
|
83
|
+
export declare const DndContext: import('react').Context<DndContextValue | null>;
|
|
84
|
+
/**
|
|
85
|
+
* Hook to access DnD context (throws if not in provider)
|
|
86
|
+
*/
|
|
87
|
+
export declare function useDndContext(): DndContextValue;
|
|
88
|
+
/**
|
|
89
|
+
* Hook to access DnD context (returns null if not in provider)
|
|
90
|
+
*/
|
|
91
|
+
export declare function useDndContextOptional(): DndContextValue | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { DragEndEvent, DragStartEvent, DragOverEvent } from './DndContext';
|
|
3
|
+
import { BaseComponentProps } from '../../../types/component.types';
|
|
4
|
+
export interface DndProviderProps extends Omit<BaseComponentProps, 'children'> {
|
|
5
|
+
/**
|
|
6
|
+
* Children components
|
|
7
|
+
*/
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Callback when drag starts
|
|
11
|
+
*/
|
|
12
|
+
onDragStart?: (event: DragStartEvent) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Callback when dragging over a droppable
|
|
15
|
+
*/
|
|
16
|
+
onDragOver?: (event: DragOverEvent) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Callback when drag ends
|
|
19
|
+
*/
|
|
20
|
+
onDragEnd?: (event: DragEndEvent) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Callback when drag is cancelled
|
|
23
|
+
*/
|
|
24
|
+
onDragCancel?: (event: DragStartEvent) => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* DndProvider component that wraps the application to enable drag and drop
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* <DndProvider onDragEnd={handleDragEnd}>
|
|
32
|
+
* <SortableList items={items} onReorder={setItems} />
|
|
33
|
+
* </DndProvider>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const DndProvider: React.FC<DndProviderProps>;
|
|
37
|
+
export default DndProvider;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { DndProvider, type DndProviderProps } from './DndProvider';
|
|
2
|
+
export { DndContext, useDndContext, useDndContextOptional, type DndContextValue, type ActiveDrag, type DragData, type DragEndEvent, type DragStartEvent, type DragOverEvent, } from './DndContext';
|
|
3
|
+
export { default } from './DndProvider';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { default as React, CSSProperties } from 'react';
|
|
2
|
+
import { BaseComponentProps, ExtendedComponentSize } from '../../../types/component.types';
|
|
3
|
+
export interface DragHandleProps extends Omit<BaseComponentProps, 'children'>, Omit<React.HTMLAttributes<HTMLDivElement>, 'className' | 'style'> {
|
|
4
|
+
/**
|
|
5
|
+
* Size of the handle
|
|
6
|
+
* @default 'md'
|
|
7
|
+
*/
|
|
8
|
+
size?: ExtendedComponentSize;
|
|
9
|
+
/**
|
|
10
|
+
* Visual variant
|
|
11
|
+
* @default 'dots'
|
|
12
|
+
*/
|
|
13
|
+
variant?: 'dots' | 'lines' | 'grip';
|
|
14
|
+
/**
|
|
15
|
+
* Whether handle is disabled
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Accessible label
|
|
21
|
+
* @default 'Drag handle'
|
|
22
|
+
*/
|
|
23
|
+
label?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Custom styles
|
|
26
|
+
*/
|
|
27
|
+
style?: CSSProperties;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* DragHandle component for drag and drop interactions
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* <SortableItem>
|
|
35
|
+
* <DragHandle {...dragHandleProps} />
|
|
36
|
+
* <span>Item content</span>
|
|
37
|
+
* </SortableItem>
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare const DragHandle: React.ForwardRefExoticComponent<DragHandleProps & React.RefAttributes<HTMLDivElement>>;
|
|
41
|
+
export default DragHandle;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { BaseComponentProps } from '../../../types/component.types';
|
|
3
|
+
export interface DragOverlayProps extends Omit<BaseComponentProps, 'children'> {
|
|
4
|
+
/**
|
|
5
|
+
* Content to render in the overlay
|
|
6
|
+
* Can be a render function that receives the active drag data
|
|
7
|
+
*/
|
|
8
|
+
children?: ReactNode | ((activeId: string, activeData: Record<string, unknown>) => ReactNode);
|
|
9
|
+
/**
|
|
10
|
+
* Whether to adjust position with scroll
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
adjustScale?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Drop animation duration in ms (0 to disable)
|
|
16
|
+
* @default 200
|
|
17
|
+
*/
|
|
18
|
+
dropAnimationDuration?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Z-index for the overlay
|
|
21
|
+
* @default 9999
|
|
22
|
+
*/
|
|
23
|
+
zIndex?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* DragOverlay component that renders a visual clone during drag operations
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <DndProvider>
|
|
31
|
+
* <SortableList items={items} />
|
|
32
|
+
* <DragOverlay>
|
|
33
|
+
* {(activeId, data) => <Card>{data.title}</Card>}
|
|
34
|
+
* </DragOverlay>
|
|
35
|
+
* </DndProvider>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare const DragOverlay: React.FC<DragOverlayProps>;
|
|
39
|
+
export default DragOverlay;
|