@aic-kits/react 0.35.1 → 0.35.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Button/StyledButton.d.ts +15 -10
- package/dist/components/DatePicker/hooks.d.ts +1 -1
- package/dist/components/Grid/StyledGrid.d.ts +13 -4
- package/dist/components/Grid/__tests__/index.test.d.ts +1 -0
- package/dist/components/Grid/__tests__/utils.test.d.ts +1 -0
- package/dist/components/Grid/types.d.ts +2 -1
- package/dist/components/Grid/utils.d.ts +2 -1
- package/dist/components/Input/StyledInput.d.ts +2 -1
- package/dist/components/Input/types.d.ts +6 -1
- package/dist/components/Radio/Radio.d.ts +3 -0
- package/dist/components/Radio/RadioButton.d.ts +3 -0
- package/dist/components/Radio/RadioContext.d.ts +3 -0
- package/dist/components/Radio/RadioGroup.d.ts +3 -0
- package/dist/components/Radio/index.d.ts +10 -0
- package/dist/components/Radio/types.d.ts +147 -0
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/components/Select/types.d.ts +10 -1
- package/dist/components/Switch/StyledSwitch.d.ts +6 -0
- package/dist/components/Switch/Switch.d.ts +3 -0
- package/dist/components/Switch/__tests__/index.test.d.ts +1 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Switch/types.d.ts +44 -0
- package/dist/components/Table/AccordionRow.d.ts +5 -0
- package/dist/components/Table/AccordionRowContent.d.ts +20 -0
- package/dist/components/Table/AccordionRowHeader.d.ts +16 -0
- package/dist/components/Table/AddForm.d.ts +5 -0
- package/dist/components/Table/DeleteDialog.d.ts +3 -0
- package/dist/components/Table/Filters.d.ts +3 -0
- package/dist/components/Table/FormFields.d.ts +24 -0
- package/dist/components/Table/InlineMultiSelect.d.ts +3 -0
- package/dist/components/Table/InlinePairSelect.d.ts +3 -0
- package/dist/components/Table/StyledTable.d.ts +29 -0
- package/dist/components/Table/Table.d.ts +5 -0
- package/dist/components/Table/TableHeaderRow.d.ts +10 -0
- package/dist/components/Table/TablePagination.d.ts +11 -0
- package/dist/components/Table/ValidationDialog.d.ts +7 -0
- package/dist/components/Table/hooks.d.ts +34 -0
- package/dist/components/Table/index.d.ts +12 -0
- package/dist/components/Table/types.d.ts +372 -0
- package/dist/components/Table/utils.d.ts +83 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/index.cjs +470 -370
- package/dist/index.js +13150 -9572
- package/dist/theme/components/index.d.ts +10 -1
- package/dist/theme/components/radio.d.ts +42 -0
- package/dist/theme/components/switch.d.ts +27 -0
- package/dist/theme/components/table.d.ts +34 -0
- package/package.json +2 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TableStateAdapter, UseTableReturn, UseLocalStateAdapterConfig, UseTableStateProps, UseTableStateReturn } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook for managing table UI state (pagination, sorting, filtering)
|
|
4
|
+
* Uses adapter pattern to work with different state backends
|
|
5
|
+
*
|
|
6
|
+
* @param adapter - State adapter for reading/writing table state
|
|
7
|
+
* @returns Current state values and handlers
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // With local state adapter
|
|
11
|
+
* const adapter = useLocalStateAdapter({ defaultPageSize: 10 })
|
|
12
|
+
* const table = useTable(adapter)
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // With custom URL state adapter
|
|
16
|
+
* const adapter = useUrlStateAdapter(config)
|
|
17
|
+
* const table = useTable(adapter)
|
|
18
|
+
*/
|
|
19
|
+
export declare function useTable<T = unknown>(adapter: TableStateAdapter<T>): UseTableReturn<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Local state adapter for useTable hook
|
|
22
|
+
* Uses React useState for state management (no URL dependency)
|
|
23
|
+
*
|
|
24
|
+
* @param config - Optional configuration for default values
|
|
25
|
+
* @returns TableStateAdapter that uses local state
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* const adapter = useLocalStateAdapter({ defaultPageSize: 10 });
|
|
29
|
+
* const { currentPage, filters, onPaginationChange } = useTable(adapter);
|
|
30
|
+
*/
|
|
31
|
+
export declare function useLocalStateAdapter<T = unknown>(config?: UseLocalStateAdapterConfig): TableStateAdapter<T>;
|
|
32
|
+
export declare function useTableState<T extends {
|
|
33
|
+
id: string | number;
|
|
34
|
+
}>({ data, columns: allColumns, currentPage, pageSize, total, sortBy, sortDirection, onPaginationChange, onAdd, onEdit, onDelete, onView, onSelectedItemChange, onFieldChange, renderExpandedRow, }: UseTableStateProps<T>): UseTableStateReturn<T>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { Table } from './Table';
|
|
2
|
+
export { AccordionRow } from './AccordionRow';
|
|
3
|
+
export { AddForm } from './AddForm';
|
|
4
|
+
export { DeleteDialog } from './DeleteDialog';
|
|
5
|
+
export { FormFields } from './FormFields';
|
|
6
|
+
export { Filters } from './Filters';
|
|
7
|
+
export { InlineMultiSelect } from './InlineMultiSelect';
|
|
8
|
+
export { InlinePairSelect } from './InlinePairSelect';
|
|
9
|
+
export { useTable, useLocalStateAdapter } from './hooks';
|
|
10
|
+
export { applyFilters, PAGINATION_PARAMS, createNonFilterParams, filtersToSearchParams, parseFiltersFromParams, } from './utils';
|
|
11
|
+
export type { FormFieldsProps } from './FormFields';
|
|
12
|
+
export type { RecordWithId, FilterOperator, FilterCondition, FilterFn, InlinePairSelectOption, InlinePairSelectValue, InlinePairSelectConfig, InlineMultiSelectOption, InlineMultiSelectGroupOption, ColumnType, FilterType, Column, PaginationParams, PaginatedResponse, TableProps, AccordionRowProps, AddFormProps, FiltersProps, DeleteDialogProps, InlineMultiSelectProps, InlinePairSelectProps, UseTableConfig, TableStateAdapter, UseTableReturn, UseLocalStateAdapterConfig, } from './types';
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Color, Radius } from '../../theme';
|
|
3
|
+
/**
|
|
4
|
+
* Base type for records with an id field
|
|
5
|
+
*/
|
|
6
|
+
export type RecordWithId = {
|
|
7
|
+
id: string | number;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Filter operators for table filtering
|
|
12
|
+
*/
|
|
13
|
+
export type FilterOperator = 'equals' | 'contains' | 'starts_with' | 'ends_with' | 'greater_than' | 'less_than' | 'greater_equal' | 'less_equal' | 'not_equals' | 'is_empty' | 'is_not_empty';
|
|
14
|
+
/**
|
|
15
|
+
* Filter condition for a column
|
|
16
|
+
*/
|
|
17
|
+
export interface FilterCondition<T> {
|
|
18
|
+
id: string;
|
|
19
|
+
column: keyof T;
|
|
20
|
+
operator: FilterOperator;
|
|
21
|
+
value: string;
|
|
22
|
+
valueEnd?: string;
|
|
23
|
+
relation?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Custom filter function type
|
|
27
|
+
*/
|
|
28
|
+
export type FilterFn<T> = (data: T[], filters: FilterCondition<T>[]) => T[];
|
|
29
|
+
/**
|
|
30
|
+
* Option for inline pair select
|
|
31
|
+
*/
|
|
32
|
+
export interface InlinePairSelectOption {
|
|
33
|
+
value: string;
|
|
34
|
+
label: string;
|
|
35
|
+
icon?: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Value type for inline pair select
|
|
39
|
+
*/
|
|
40
|
+
export type InlinePairSelectValue = Record<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* Configuration for inline pair select
|
|
43
|
+
*/
|
|
44
|
+
export interface InlinePairSelectConfig {
|
|
45
|
+
primaryLabel?: string;
|
|
46
|
+
secondaryLabel?: string;
|
|
47
|
+
primaryPlaceholder?: string;
|
|
48
|
+
secondaryPlaceholder?: string;
|
|
49
|
+
emptyStateText?: string;
|
|
50
|
+
valueKeys?: {
|
|
51
|
+
primary: string;
|
|
52
|
+
secondary: string;
|
|
53
|
+
};
|
|
54
|
+
primaryOptions: InlinePairSelectOption[];
|
|
55
|
+
secondaryOptions: InlinePairSelectOption[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Option for inline multi select
|
|
59
|
+
*/
|
|
60
|
+
export interface InlineMultiSelectOption {
|
|
61
|
+
value: string;
|
|
62
|
+
label: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Group option for inline multi select
|
|
66
|
+
*/
|
|
67
|
+
export interface InlineMultiSelectGroupOption {
|
|
68
|
+
values: string[];
|
|
69
|
+
label: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Column type definitions
|
|
73
|
+
*/
|
|
74
|
+
export type ColumnType = 'text' | 'number' | 'email' | 'date' | 'select' | 'link' | 'checkboxes' | 'inlinemultiselect' | 'inlinepairselect' | 'boolean';
|
|
75
|
+
/**
|
|
76
|
+
* Filter type definitions
|
|
77
|
+
*/
|
|
78
|
+
export type FilterType = 'text' | 'number' | 'date' | 'select' | 'checkboxes' | 'boolean' | 'none' | 'inlinemultiselect' | 'inlinepairselect';
|
|
79
|
+
/**
|
|
80
|
+
* Column definition for table
|
|
81
|
+
*/
|
|
82
|
+
export interface Column<T> {
|
|
83
|
+
key: keyof T | 'select';
|
|
84
|
+
header: string;
|
|
85
|
+
sortable?: boolean;
|
|
86
|
+
render?: (value: unknown, item: T) => ReactNode;
|
|
87
|
+
renderEditField?: (value: unknown, item: T, onChange: (value: unknown) => void) => ReactNode;
|
|
88
|
+
editable?: boolean;
|
|
89
|
+
required?: boolean;
|
|
90
|
+
multiline?: boolean;
|
|
91
|
+
type?: ColumnType;
|
|
92
|
+
filterType?: FilterType;
|
|
93
|
+
/** For inlinemultiselect filter: 'option' filters by individual options, 'group' filters by groupOptions */
|
|
94
|
+
filterBy?: 'option' | 'group';
|
|
95
|
+
options?: {
|
|
96
|
+
value: string;
|
|
97
|
+
label: string;
|
|
98
|
+
}[];
|
|
99
|
+
filterOptions?: {
|
|
100
|
+
value: string;
|
|
101
|
+
label: string;
|
|
102
|
+
}[];
|
|
103
|
+
groupOptions?: {
|
|
104
|
+
values: string[];
|
|
105
|
+
label: string;
|
|
106
|
+
}[];
|
|
107
|
+
pairOptions?: InlinePairSelectConfig;
|
|
108
|
+
flex?: number | string;
|
|
109
|
+
truncate?: boolean;
|
|
110
|
+
href?: (item: T) => string;
|
|
111
|
+
hiddenInHeader?: boolean;
|
|
112
|
+
hiddenInContent?: boolean;
|
|
113
|
+
headerEditable?: boolean;
|
|
114
|
+
filterKey?: string;
|
|
115
|
+
filterRelation?: string;
|
|
116
|
+
tagColor?: Color;
|
|
117
|
+
defaultValue?: unknown;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Pagination parameters
|
|
121
|
+
*/
|
|
122
|
+
export interface PaginationParams {
|
|
123
|
+
page: number;
|
|
124
|
+
pageSize: number;
|
|
125
|
+
sortBy?: string;
|
|
126
|
+
sortDirection?: 'asc' | 'desc';
|
|
127
|
+
search?: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Paginated response type
|
|
131
|
+
*/
|
|
132
|
+
export interface PaginatedResponse<T> {
|
|
133
|
+
data: T[];
|
|
134
|
+
total: number;
|
|
135
|
+
page: number;
|
|
136
|
+
pageSize: number;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Table component props
|
|
140
|
+
*/
|
|
141
|
+
export interface TableProps<T extends {
|
|
142
|
+
id: string | number;
|
|
143
|
+
}> {
|
|
144
|
+
data: T[];
|
|
145
|
+
columns: Column<T>[];
|
|
146
|
+
onAdd?: (item: Omit<T, 'id'>) => void | Promise<void>;
|
|
147
|
+
onEdit?: (id: string | number, item: Partial<T>) => void | Promise<void>;
|
|
148
|
+
onDelete?: (id: string | number) => void | Promise<void>;
|
|
149
|
+
onView?: (id: string | number) => Promise<unknown>;
|
|
150
|
+
renderExpandedRow?: (item: T, detailedData: unknown) => ReactNode;
|
|
151
|
+
onSelectedItemChange?: (item: T | null) => void | Promise<void>;
|
|
152
|
+
title?: string;
|
|
153
|
+
addButtonText?: string;
|
|
154
|
+
editButtonText?: string;
|
|
155
|
+
deleteButtonText?: string;
|
|
156
|
+
viewButtonText?: string;
|
|
157
|
+
confirmDeleteMessage?: string;
|
|
158
|
+
noDataMessage?: string;
|
|
159
|
+
total: number;
|
|
160
|
+
currentPage: number;
|
|
161
|
+
pageSize: number;
|
|
162
|
+
pageSizeOptions?: number[];
|
|
163
|
+
sortBy?: string;
|
|
164
|
+
sortDirection?: 'asc' | 'desc';
|
|
165
|
+
onPaginationChange: (params: PaginationParams) => void;
|
|
166
|
+
isLoading?: boolean;
|
|
167
|
+
filters?: FilterCondition<T>[];
|
|
168
|
+
onFiltersChange?: (filters: FilterCondition<T>[]) => void;
|
|
169
|
+
showFilterBuilder?: boolean;
|
|
170
|
+
onFieldChange?: (updates: Partial<T>, key: keyof T, value: unknown) => Partial<T>;
|
|
171
|
+
expandable?: boolean;
|
|
172
|
+
/** Error message displayed as a banner above the table */
|
|
173
|
+
error?: string | null;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* AccordionRow component props
|
|
177
|
+
*/
|
|
178
|
+
export interface AccordionRowProps<T extends {
|
|
179
|
+
id: string | number;
|
|
180
|
+
}> {
|
|
181
|
+
item: T;
|
|
182
|
+
columns: Column<T>[];
|
|
183
|
+
allColumns: Column<T>[];
|
|
184
|
+
expandedRows: Set<string | number>;
|
|
185
|
+
editFormData: Record<string | number, Partial<T>>;
|
|
186
|
+
loadingDetails: Set<string | number>;
|
|
187
|
+
isFormLoading: boolean;
|
|
188
|
+
isEditable?: boolean;
|
|
189
|
+
isExpandAccordion?: boolean;
|
|
190
|
+
isSelected?: boolean;
|
|
191
|
+
onToggleExpanded: (item: T) => void;
|
|
192
|
+
onEditFormChange: (itemId: string | number, key: keyof T, value: unknown) => void;
|
|
193
|
+
onSave: (item: T) => void;
|
|
194
|
+
onDelete?: (item: T) => void;
|
|
195
|
+
onQuickEdit?: (item: T, key: keyof T, value: unknown) => void;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* AddForm component props
|
|
199
|
+
*/
|
|
200
|
+
export interface AddFormProps<T extends {
|
|
201
|
+
id: string | number;
|
|
202
|
+
}> {
|
|
203
|
+
columns: Column<T>[];
|
|
204
|
+
formData: Partial<T>;
|
|
205
|
+
isLoading: boolean;
|
|
206
|
+
onInputChange: (key: keyof T, value: unknown) => void;
|
|
207
|
+
onSubmit: () => void;
|
|
208
|
+
onCancel: () => void;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Filters component props
|
|
212
|
+
*/
|
|
213
|
+
export interface FiltersProps<T> {
|
|
214
|
+
columns: Column<T>[];
|
|
215
|
+
filters: FilterCondition<T>[];
|
|
216
|
+
onFiltersChange: (filters: FilterCondition<T>[]) => void;
|
|
217
|
+
/**
|
|
218
|
+
* Border radius for Input, Select, and DatePicker components
|
|
219
|
+
* @default 'md'
|
|
220
|
+
*/
|
|
221
|
+
borderRadius?: Radius;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* DeleteDialog component props
|
|
225
|
+
*/
|
|
226
|
+
export interface DeleteDialogProps {
|
|
227
|
+
open: boolean;
|
|
228
|
+
onOpenChange: (open: boolean) => void;
|
|
229
|
+
onConfirm: () => void;
|
|
230
|
+
isLoading?: boolean;
|
|
231
|
+
message?: string;
|
|
232
|
+
deleteButtonText?: string;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* InlineMultiSelect component props
|
|
236
|
+
*/
|
|
237
|
+
export interface InlineMultiSelectProps {
|
|
238
|
+
options: InlineMultiSelectOption[];
|
|
239
|
+
groupOptions: InlineMultiSelectGroupOption[];
|
|
240
|
+
value: string[];
|
|
241
|
+
onChange: (next: string[]) => void;
|
|
242
|
+
placeholder?: string;
|
|
243
|
+
max?: number;
|
|
244
|
+
limit?: number;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* InlinePairSelect component props
|
|
248
|
+
*/
|
|
249
|
+
export interface InlinePairSelectProps {
|
|
250
|
+
primaryOptions: InlinePairSelectOption[];
|
|
251
|
+
secondaryOptions: InlinePairSelectOption[];
|
|
252
|
+
value: InlinePairSelectValue[];
|
|
253
|
+
onChange: (next: InlinePairSelectValue[]) => void;
|
|
254
|
+
primaryLabel?: string;
|
|
255
|
+
secondaryLabel?: string;
|
|
256
|
+
primaryPlaceholder?: string;
|
|
257
|
+
secondaryPlaceholder?: string;
|
|
258
|
+
emptyStateText?: string;
|
|
259
|
+
valueKeys?: {
|
|
260
|
+
primary: string;
|
|
261
|
+
secondary: string;
|
|
262
|
+
};
|
|
263
|
+
disabled?: boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Border radius for Select components
|
|
266
|
+
* @default 'md'
|
|
267
|
+
*/
|
|
268
|
+
borderRadius?: Radius;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Configuration for useTable hook defaults
|
|
272
|
+
*/
|
|
273
|
+
export interface UseTableConfig {
|
|
274
|
+
defaultPageSize: number;
|
|
275
|
+
defaultSortBy: string;
|
|
276
|
+
defaultSortDirection: 'asc' | 'desc';
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Adapter interface for reading and writing table UI state
|
|
280
|
+
* Enables useTable to work with different state backends (URL params, local state, etc.)
|
|
281
|
+
*/
|
|
282
|
+
export interface TableStateAdapter<T = unknown> {
|
|
283
|
+
getCurrentPage: () => number;
|
|
284
|
+
getPageSize: () => number;
|
|
285
|
+
getSortBy: () => string;
|
|
286
|
+
getSortDirection: () => 'asc' | 'desc';
|
|
287
|
+
getFilters: () => FilterCondition<T>[];
|
|
288
|
+
setPagination: (params: PaginationParams) => void;
|
|
289
|
+
setFilters: (filters: FilterCondition<T>[]) => void;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Return type for useTable hook
|
|
293
|
+
*/
|
|
294
|
+
export interface UseTableReturn<T = unknown> {
|
|
295
|
+
currentPage: number;
|
|
296
|
+
pageSize: number;
|
|
297
|
+
sortBy: string;
|
|
298
|
+
sortDirection: 'asc' | 'desc';
|
|
299
|
+
filters: FilterCondition<T>[];
|
|
300
|
+
onPaginationChange: (params: PaginationParams) => void;
|
|
301
|
+
onFiltersChange: (filters: FilterCondition<T>[]) => void;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Configuration for useLocalStateAdapter hook
|
|
305
|
+
*/
|
|
306
|
+
export interface UseLocalStateAdapterConfig {
|
|
307
|
+
defaultPageSize?: number;
|
|
308
|
+
defaultSortBy?: string;
|
|
309
|
+
defaultSortDirection?: 'asc' | 'desc';
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Props for useTableState hook
|
|
313
|
+
*/
|
|
314
|
+
export interface UseTableStateProps<T extends {
|
|
315
|
+
id: string | number;
|
|
316
|
+
}> {
|
|
317
|
+
data: T[];
|
|
318
|
+
columns: Column<T>[];
|
|
319
|
+
currentPage: number;
|
|
320
|
+
pageSize: number;
|
|
321
|
+
total: number;
|
|
322
|
+
sortBy?: string;
|
|
323
|
+
sortDirection: 'asc' | 'desc';
|
|
324
|
+
onPaginationChange: (params: PaginationParams) => void;
|
|
325
|
+
onAdd?: (item: Omit<T, 'id'>) => void | Promise<void>;
|
|
326
|
+
onEdit?: (id: string | number, item: Partial<T>) => void | Promise<void>;
|
|
327
|
+
onDelete?: (id: string | number) => void | Promise<void>;
|
|
328
|
+
onView?: (id: string | number) => Promise<unknown>;
|
|
329
|
+
onSelectedItemChange?: (item: T | null) => void | Promise<void>;
|
|
330
|
+
onFieldChange?: (formData: Partial<T>, changedKey: keyof T, newValue: unknown) => Partial<T>;
|
|
331
|
+
renderExpandedRow?: (item: T, detailedData: unknown) => ReactNode;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Return type for useTableState hook
|
|
335
|
+
*/
|
|
336
|
+
export interface UseTableStateReturn<T extends {
|
|
337
|
+
id: string | number;
|
|
338
|
+
}> {
|
|
339
|
+
visibleColumns: Column<T>[];
|
|
340
|
+
displayData: T[];
|
|
341
|
+
totalPages: number;
|
|
342
|
+
totalFlex: number;
|
|
343
|
+
defaults: Partial<T>;
|
|
344
|
+
isAddFormOpen: boolean;
|
|
345
|
+
setIsAddFormOpen: (open: boolean) => void;
|
|
346
|
+
isDeleteDialogOpen: boolean;
|
|
347
|
+
setIsDeleteDialogOpen: (open: boolean) => void;
|
|
348
|
+
validationErrors: string[];
|
|
349
|
+
setValidationErrors: (errors: string[]) => void;
|
|
350
|
+
isFilterBuilderOpen: boolean;
|
|
351
|
+
setIsFilterBuilderOpen: (open: boolean) => void;
|
|
352
|
+
isFormLoading: boolean;
|
|
353
|
+
selectedItem: T | null;
|
|
354
|
+
setSelectedItem: (item: T | null) => void;
|
|
355
|
+
addFormData: Partial<T>;
|
|
356
|
+
setAddFormData: (data: Partial<T>) => void;
|
|
357
|
+
editFormData: Record<string | number, Partial<T>>;
|
|
358
|
+
expandedRows: Set<string | number>;
|
|
359
|
+
loadingDetails: Set<string | number>;
|
|
360
|
+
detailedData: Record<string | number, unknown>;
|
|
361
|
+
handleSort: (key: keyof T) => void;
|
|
362
|
+
handlePageChange: (page: number) => void;
|
|
363
|
+
handlePageSizeChange: (newPageSize: number) => void;
|
|
364
|
+
handleAddFormInputChange: (key: keyof T, value: unknown) => void;
|
|
365
|
+
handleAdd: () => Promise<void>;
|
|
366
|
+
handleDelete: () => Promise<void>;
|
|
367
|
+
openDeleteDialog: (item: T) => void;
|
|
368
|
+
toggleExpandedRow: (item: T) => Promise<void>;
|
|
369
|
+
handleInlineEditFormChange: (itemId: string | number, key: keyof T, value: unknown) => void;
|
|
370
|
+
handleInlineSave: (item: T) => void;
|
|
371
|
+
handleQuickEdit: (row: T, key: keyof T, value: unknown) => void;
|
|
372
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { FilterCondition } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Format a date value for display in table cells.
|
|
4
|
+
* Uses DD/MM/YYYY format to match editable inputs (Filters, AddForm, AccordionRow).
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatCellDate(value: unknown): string;
|
|
7
|
+
/**
|
|
8
|
+
* Format a cell value for display, handling complex types like arrays and objects.
|
|
9
|
+
* Resolves labels from column options for select/multiselect/pairselect types.
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatCellValue(value: unknown, column: {
|
|
12
|
+
type?: string;
|
|
13
|
+
options?: {
|
|
14
|
+
value: string;
|
|
15
|
+
label: string;
|
|
16
|
+
}[];
|
|
17
|
+
pairOptions?: {
|
|
18
|
+
primaryOptions: {
|
|
19
|
+
value: string;
|
|
20
|
+
label: string;
|
|
21
|
+
}[];
|
|
22
|
+
secondaryOptions: {
|
|
23
|
+
value: string;
|
|
24
|
+
label: string;
|
|
25
|
+
}[];
|
|
26
|
+
valueKeys?: {
|
|
27
|
+
primary: string;
|
|
28
|
+
secondary: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}): string;
|
|
32
|
+
/**
|
|
33
|
+
* Common pagination and sorting parameters that should NOT be treated as filters
|
|
34
|
+
*/
|
|
35
|
+
export declare const PAGINATION_PARAMS: Set<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Create a set of known non-filter params by combining pagination params with custom params
|
|
38
|
+
*
|
|
39
|
+
* @param additionalParams - Additional parameter names to exclude from filtering
|
|
40
|
+
* @returns Set of all non-filter parameter names
|
|
41
|
+
*/
|
|
42
|
+
export declare function createNonFilterParams(...additionalParams: string[]): Set<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Convert filter conditions to URL search params
|
|
45
|
+
*
|
|
46
|
+
* Converts FilterCondition objects into individual URL parameters with optional table prefix:
|
|
47
|
+
* - Simple filters: { column: 'name', value: 'john' } → ?name=john or ?experts_name=john
|
|
48
|
+
* - Range filters: { column: 'count', value: '5', valueEnd: '10' } → ?count_min=5&count_max=10
|
|
49
|
+
*
|
|
50
|
+
* @param searchParams - Current URLSearchParams to update
|
|
51
|
+
* @param filters - Array of FilterCondition objects to convert
|
|
52
|
+
* @param knownNonFilterParams - Set of parameter names that should NOT be removed
|
|
53
|
+
* @param pageParam - Name of the page parameter to reset (e.g., 'page', 'staffPage')
|
|
54
|
+
* @param tablePrefix - Optional prefix for filter params (e.g., 'experts') to avoid conflicts between tables
|
|
55
|
+
* @returns Updated URLSearchParams with filter parameters
|
|
56
|
+
*/
|
|
57
|
+
export declare function filtersToSearchParams<T>(searchParams: URLSearchParams, filters: FilterCondition<T>[], knownNonFilterParams: Set<string>, pageParam?: string, tablePrefix?: string): URLSearchParams;
|
|
58
|
+
/**
|
|
59
|
+
* Parse filter conditions from URL search params
|
|
60
|
+
*
|
|
61
|
+
* Converts individual URL parameters into FilterCondition objects:
|
|
62
|
+
* - Simple filters: ?name=john → { column: 'name', operator: 'contains', value: 'john' }
|
|
63
|
+
* - Range filters: ?count_min=5&count_max=10 → { column: 'count', operator: 'greater_equal', value: '5', valueEnd: '10' }
|
|
64
|
+
*
|
|
65
|
+
* The operator for simple filters is derived from `columnTypes` when provided:
|
|
66
|
+
* - 'boolean' | 'select' | 'checkboxes' → 'equals'
|
|
67
|
+
* - 'number' | 'date' → 'greater_equal'
|
|
68
|
+
* - default (text etc.) → 'contains'
|
|
69
|
+
*
|
|
70
|
+
* @param searchParams - URLSearchParams to parse
|
|
71
|
+
* @param knownNonFilterParams - Set of parameter names that should NOT be treated as filters
|
|
72
|
+
* @param tablePrefix - Optional prefix for filter params (e.g., 'experts') to only parse this table's filters
|
|
73
|
+
* @param columnTypes - Optional map of column name → filter type for correct operator inference
|
|
74
|
+
* @returns Array of FilterCondition objects
|
|
75
|
+
*/
|
|
76
|
+
export declare function parseFiltersFromParams<T>(searchParams: URLSearchParams, knownNonFilterParams: Set<string>, tablePrefix?: string, columnTypes?: Record<string, string>): FilterCondition<T>[];
|
|
77
|
+
/**
|
|
78
|
+
* Apply filters to data array based on filter conditions.
|
|
79
|
+
* Handles all filter operators including range filters with valueEnd.
|
|
80
|
+
*/
|
|
81
|
+
export declare function applyFilters<T extends {
|
|
82
|
+
id: string | number;
|
|
83
|
+
}>(data: T[], filters: FilterCondition<T>[]): T[];
|
|
@@ -16,11 +16,14 @@ export * from './Carousel';
|
|
|
16
16
|
export * from './Accordion';
|
|
17
17
|
export * from './Tag';
|
|
18
18
|
export * from './Checkbox';
|
|
19
|
+
export * from './Radio';
|
|
19
20
|
export * from './Select';
|
|
21
|
+
export * from './Switch';
|
|
20
22
|
export * from './Grid';
|
|
21
23
|
export * from './Pagination';
|
|
22
24
|
export * from './Progress';
|
|
23
25
|
export * from './Modal';
|
|
26
|
+
export * from './Table';
|
|
24
27
|
export * from './Tooltip';
|
|
25
28
|
export * from './BarChart';
|
|
26
29
|
export * from './PieChart';
|