1 | import type { Key } from 'react';
|
2 | import type { ReactElement } from 'react';
|
3 | import type { RefAttributes } from 'react';
|
4 |
|
5 | export declare interface CalculatedColumn<TRow, TSummaryRow = unknown> extends Column<TRow, TSummaryRow> {
|
6 | readonly idx: number;
|
7 | readonly resizable: boolean;
|
8 | readonly sortable: boolean;
|
9 | readonly frozen: boolean;
|
10 | readonly isLastFrozenColumn: boolean;
|
11 | readonly rowGroup: boolean;
|
12 | readonly formatter: React.ComponentType<FormatterProps<TRow, TSummaryRow>>;
|
13 | }
|
14 |
|
15 | export declare type CellNavigationMode = 'NONE' | 'CHANGE_ROW' | 'LOOP_OVER_ROW';
|
16 |
|
17 | export declare interface CellRendererProps<TRow, TSummaryRow> extends Pick<RowRendererProps<TRow, TSummaryRow>, 'onRowClick' | 'onRowDoubleClick' | 'selectCell'>, Omit_2<React.HTMLAttributes<HTMLDivElement>, 'style' | 'children'> {
|
18 | column: CalculatedColumn<TRow, TSummaryRow>;
|
19 | colSpan: number | undefined;
|
20 | row: TRow;
|
21 | isCopied: boolean;
|
22 | isDraggedOver: boolean;
|
23 | isCellSelected: boolean;
|
24 | dragHandle: ReactElement<React.HTMLAttributes<HTMLDivElement>> | undefined;
|
25 | onRowChange: (newRow: TRow) => void;
|
26 | }
|
27 |
|
28 | export declare type ColSpanArgs<R, SR> = {
|
29 | type: 'HEADER';
|
30 | } | {
|
31 | type: 'ROW';
|
32 | row: R;
|
33 | } | {
|
34 | type: 'SUMMARY';
|
35 | row: SR;
|
36 | };
|
37 |
|
38 | export declare interface Column<TRow, TSummaryRow = unknown> {
|
39 |
|
40 | readonly name: string | ReactElement;
|
41 |
|
42 | readonly key: string;
|
43 |
|
44 | readonly width?: Maybe<number | string>;
|
45 |
|
46 | readonly minWidth?: Maybe<number>;
|
47 |
|
48 | readonly maxWidth?: Maybe<number>;
|
49 | readonly cellClass?: Maybe<string | ((row: TRow) => Maybe<string>)>;
|
50 | readonly headerCellClass?: Maybe<string>;
|
51 | readonly summaryCellClass?: Maybe<string | ((row: TSummaryRow) => Maybe<string>)>;
|
52 | /** Formatter to be used to render the cell content */
|
53 | readonly formatter?: Maybe<React.ComponentType<FormatterProps<TRow, TSummaryRow>>>;
|
54 | /** Formatter to be used to render the summary cell content */
|
55 | readonly summaryFormatter?: Maybe<React.ComponentType<SummaryFormatterProps<TSummaryRow, TRow>>>;
|
56 | /** Formatter to be used to render the group cell content */
|
57 | readonly groupFormatter?: Maybe<React.ComponentType<GroupFormatterProps<TRow, TSummaryRow>>>;
|
58 | /** Enables cell editing. If set and no editor property specified, then a textinput will be used as the cell editor */
|
59 | readonly editable?: Maybe<boolean | ((row: TRow) => boolean)>;
|
60 | readonly colSpan?: Maybe<(args: ColSpanArgs<TRow, TSummaryRow>) => Maybe<number>>;
|
61 |
|
62 | readonly frozen?: Maybe<boolean>;
|
63 |
|
64 | readonly resizable?: Maybe<boolean>;
|
65 |
|
66 | readonly sortable?: Maybe<boolean>;
|
67 |
|
68 | readonly sortDescendingFirst?: Maybe<boolean>;
|
69 |
|
70 | readonly editor?: Maybe<React.ComponentType<EditorProps<TRow, TSummaryRow>>>;
|
71 | readonly editorOptions?: Maybe<{
|
72 |
|
73 | readonly renderFormatter?: Maybe<boolean>;
|
74 |
|
75 | readonly editOnClick?: Maybe<boolean>;
|
76 |
|
77 | readonly commitOnOutsideClick?: Maybe<boolean>;
|
78 |
|
79 | readonly onCellKeyDown?: Maybe<(event: React.KeyboardEvent<HTMLDivElement>) => void>;
|
80 |
|
81 | readonly onNavigation?: Maybe<(event: React.KeyboardEvent<HTMLDivElement>) => boolean>;
|
82 | }>;
|
83 |
|
84 | readonly headerRenderer?: Maybe<React.ComponentType<HeaderRendererProps<TRow, TSummaryRow>>>;
|
85 | }
|
86 |
|
87 | export declare interface DataGridHandle {
|
88 | element: HTMLDivElement | null;
|
89 | scrollToColumn: (colIdx: number) => void;
|
90 | scrollToRow: (rowIdx: number) => void;
|
91 | selectCell: (position: Position, enableEditor?: Maybe<boolean>) => void;
|
92 | }
|
93 |
|
94 | export declare interface DataGridProps<R, SR = unknown, K extends Key = Key> extends SharedDivProps {
|
95 | |
96 |
|
97 |
|
98 |
|
99 | columns: readonly Column<R, SR>[];
|
100 |
|
101 | rows: readonly R[];
|
102 | |
103 |
|
104 |
|
105 |
|
106 | summaryRows?: Maybe<readonly SR[]>;
|
107 |
|
108 | rowKeyGetter?: Maybe<(row: R) => K>;
|
109 | onRowsChange?: Maybe<(rows: R[], data: RowsChangeData<R, SR>) => void>;
|
110 | |
111 |
|
112 |
|
113 | |
114 |
|
115 |
|
116 |
|
117 | rowHeight?: Maybe<number | ((args: RowHeightArgs<R>) => number)>;
|
118 | /**
|
119 | * The height of the header row in pixels
|
120 | * @default 35
|
121 | */
|
122 | headerRowHeight?: Maybe<number>;
|
123 | /**
|
124 | * The height of each summary row in pixels
|
125 | * @default 35
|
126 | */
|
127 | summaryRowHeight?: Maybe<number>;
|
128 | /**
|
129 | * Feature props
|
130 | */
|
131 | /** Set of selected row keys */
|
132 | selectedRows?: Maybe<ReadonlySet<K>>;
|
133 | /** Function called whenever row selection is changed */
|
134 | onSelectedRowsChange?: Maybe<(selectedRows: Set<K>) => void>;
|
135 |
|
136 | sortColumns?: Maybe<readonly SortColumn[]>;
|
137 | onSortColumnsChange?: Maybe<(sortColumns: SortColumn[]) => void>;
|
138 | defaultColumnOptions?: Maybe<DefaultColumnOptions<R, SR>>;
|
139 | groupBy?: Maybe<readonly string[]>;
|
140 | rowGrouper?: Maybe<(rows: readonly R[], columnKey: string) => Record<string, readonly R[]>>;
|
141 | expandedGroupIds?: Maybe<ReadonlySet<unknown>>;
|
142 | onExpandedGroupIdsChange?: Maybe<(expandedGroupIds: Set<unknown>) => void>;
|
143 | onFill?: Maybe<(event: FillEvent<R>) => R>;
|
144 | onPaste?: Maybe<(event: PasteEvent<R>) => R>;
|
145 | |
146 |
|
147 |
|
148 |
|
149 | onRowClick?: Maybe<(row: R, column: CalculatedColumn<R, SR>) => void>;
|
150 |
|
151 | onRowDoubleClick?: Maybe<(row: R, column: CalculatedColumn<R, SR>) => void>;
|
152 |
|
153 | onScroll?: Maybe<(event: React.UIEvent<HTMLDivElement>) => void>;
|
154 |
|
155 | onColumnResize?: Maybe<(idx: number, width: number) => void>;
|
156 | |
157 |
|
158 |
|
159 |
|
160 | cellNavigationMode?: Maybe<CellNavigationMode>;
|
161 |
|
162 | enableVirtualization?: Maybe<boolean>;
|
163 | |
164 |
|
165 |
|
166 | rowRenderer?: Maybe<React.ComponentType<RowRendererProps<R, SR>>>;
|
167 | noRowsFallback?: React.ReactNode;
|
168 | rowClass?: Maybe<(row: R) => Maybe<string>>;
|
169 | 'data-testid'?: Maybe<string>;
|
170 | }
|
171 |
|
172 | declare const _default: <R, SR = unknown, K extends Key = Key>(props: DataGridProps<R, SR, K> & RefAttributes<DataGridHandle>) => JSX.Element;
|
173 | export default _default;
|
174 |
|
175 | declare type DefaultColumnOptions<R, SR> = Pick<Column<R, SR>, 'formatter' | 'minWidth' | 'resizable' | 'sortable'>;
|
176 |
|
177 | export declare interface EditorProps<TRow, TSummaryRow = unknown> {
|
178 | column: CalculatedColumn<TRow, TSummaryRow>;
|
179 | row: TRow;
|
180 | onRowChange: (row: TRow, commitChanges?: boolean) => void;
|
181 | onClose: (commitChanges?: boolean) => void;
|
182 | }
|
183 |
|
184 | export declare interface FillEvent<TRow> {
|
185 | columnKey: string;
|
186 | sourceRow: TRow;
|
187 | targetRow: TRow;
|
188 | }
|
189 |
|
190 | export declare interface FormatterProps<TRow, TSummaryRow = unknown> {
|
191 | column: CalculatedColumn<TRow, TSummaryRow>;
|
192 | row: TRow;
|
193 | isCellSelected: boolean;
|
194 | onRowChange: (row: TRow) => void;
|
195 | }
|
196 |
|
197 | export declare interface GroupFormatterProps<TRow, TSummaryRow = unknown> {
|
198 | groupKey: unknown;
|
199 | column: CalculatedColumn<TRow, TSummaryRow>;
|
200 | row: GroupRow<TRow>;
|
201 | childRows: readonly TRow[];
|
202 | isExpanded: boolean;
|
203 | isCellSelected: boolean;
|
204 | toggleGroup: () => void;
|
205 | }
|
206 |
|
207 | declare interface GroupRow<TRow> {
|
208 | readonly childRows: readonly TRow[];
|
209 | readonly id: string;
|
210 | readonly parentId: unknown;
|
211 | readonly groupKey: unknown;
|
212 | readonly isExpanded: boolean;
|
213 | readonly level: number;
|
214 | readonly posInSet: number;
|
215 | readonly setSize: number;
|
216 | readonly startRowIndex: number;
|
217 | }
|
218 |
|
219 | export declare interface HeaderRendererProps<TRow, TSummaryRow = unknown> {
|
220 | column: CalculatedColumn<TRow, TSummaryRow>;
|
221 | sortDirection: SortDirection | undefined;
|
222 | priority: number | undefined;
|
223 | onSort: (ctrlClick: boolean) => void;
|
224 | allRowsSelected: boolean;
|
225 | onAllRowsSelectionChange: (checked: boolean) => void;
|
226 | isCellSelected: boolean;
|
227 | }
|
228 |
|
229 | declare type Maybe<T> = T | undefined | null;
|
230 |
|
231 | declare type Omit_2<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
232 |
|
233 | export declare interface PasteEvent<TRow> {
|
234 | sourceColumnKey: string;
|
235 | sourceRow: TRow;
|
236 | targetColumnKey: string;
|
237 | targetRow: TRow;
|
238 | }
|
239 |
|
240 | declare interface Position {
|
241 | readonly idx: number;
|
242 | readonly rowIdx: number;
|
243 | }
|
244 |
|
245 | declare interface Props<R, SR> extends SharedHeaderCellProps<R, SR> {
|
246 | children: React.ReactNode;
|
247 | }
|
248 |
|
249 | export declare const Row: <R, SR>(props: RowRendererProps<R, SR> & RefAttributes<HTMLDivElement>) => JSX.Element;
|
250 |
|
251 | export declare type RowHeightArgs<R> = {
|
252 | type: 'ROW';
|
253 | row: R;
|
254 | } | {
|
255 | type: 'GROUP';
|
256 | row: GroupRow<R>;
|
257 | };
|
258 |
|
259 | export declare interface RowRendererProps<TRow, TSummaryRow = unknown> extends Omit_2<React.HTMLAttributes<HTMLDivElement>, 'style' | 'children'> {
|
260 | viewportColumns: readonly CalculatedColumn<TRow, TSummaryRow>[];
|
261 | row: TRow;
|
262 | rowIdx: number;
|
263 | selectedCellIdx: number | undefined;
|
264 | copiedCellIdx: number | undefined;
|
265 | draggedOverCellIdx: number | undefined;
|
266 | lastFrozenColumnIndex: number;
|
267 | isRowSelected: boolean;
|
268 | top: number;
|
269 | height: number;
|
270 | selectedCellEditor: ReactElement<EditorProps<TRow>> | undefined;
|
271 | selectedCellDragHandle: ReactElement<React.HTMLAttributes<HTMLDivElement>> | undefined;
|
272 | onRowChange: (rowIdx: number, newRow: TRow) => void;
|
273 | onRowClick: Maybe<(row: TRow, column: CalculatedColumn<TRow, TSummaryRow>) => void>;
|
274 | onRowDoubleClick: Maybe<(row: TRow, column: CalculatedColumn<TRow, TSummaryRow>) => void>;
|
275 | rowClass: Maybe<(row: TRow) => Maybe<string>>;
|
276 | setDraggedOverRowIdx: ((overRowIdx: number) => void) | undefined;
|
277 | selectCell: (row: TRow, column: CalculatedColumn<TRow, TSummaryRow>, enableEditor?: Maybe<boolean>) => void;
|
278 | }
|
279 |
|
280 | export declare interface RowsChangeData<R, SR = unknown> {
|
281 | indexes: number[];
|
282 | column: CalculatedColumn<R, SR>;
|
283 | }
|
284 |
|
285 | export declare const SELECT_COLUMN_KEY = "select-row";
|
286 |
|
287 | export declare function SelectCellFormatter({ value, isCellSelected, disabled, onClick, onChange, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy }: SelectCellFormatterProps): JSX.Element;
|
288 |
|
289 | declare interface SelectCellFormatterProps extends SharedInputProps {
|
290 | isCellSelected: boolean;
|
291 | value: boolean;
|
292 | onChange: (value: boolean, isShiftClick: boolean) => void;
|
293 | }
|
294 |
|
295 | export declare const SelectColumn: Column<any, any>;
|
296 |
|
297 | export declare interface SelectRowEvent<TRow> {
|
298 | row: TRow;
|
299 | checked: boolean;
|
300 | isShiftClick: boolean;
|
301 | }
|
302 |
|
303 | declare type SharedDivProps = Pick<React.HTMLAttributes<HTMLDivElement>, 'aria-label' | 'aria-labelledby' | 'aria-describedby' | 'className' | 'style'>;
|
304 |
|
305 | declare type SharedHeaderCellProps<R, SR> = Pick<HeaderRendererProps<R, SR>, 'sortDirection' | 'onSort' | 'priority' | 'isCellSelected'>;
|
306 |
|
307 | declare type SharedInputProps = Pick<React.InputHTMLAttributes<HTMLInputElement>, 'disabled' | 'onClick' | 'aria-label' | 'aria-labelledby'>;
|
308 |
|
309 | export declare function SortableHeaderCell<R, SR>({ onSort, sortDirection, priority, children, isCellSelected }: Props<R, SR>): JSX.Element;
|
310 |
|
311 | export declare interface SortColumn {
|
312 | readonly columnKey: string;
|
313 | readonly direction: SortDirection;
|
314 | }
|
315 |
|
316 | export declare type SortDirection = 'ASC' | 'DESC';
|
317 |
|
318 | export declare interface SummaryFormatterProps<TSummaryRow, TRow = unknown> {
|
319 | column: CalculatedColumn<TRow, TSummaryRow>;
|
320 | row: TSummaryRow;
|
321 | isCellSelected: boolean;
|
322 | }
|
323 |
|
324 | export declare function TextEditor<TRow, TSummaryRow>({ row, column, onRowChange, onClose }: EditorProps<TRow, TSummaryRow>): JSX.Element;
|
325 |
|
326 | export declare function ToggleGroupFormatter<R, SR>({ groupKey, isExpanded, isCellSelected, toggleGroup }: GroupFormatterProps<R, SR>): JSX.Element;
|
327 |
|
328 | export declare function useRowSelection<R>(): [boolean, (selectRowEvent: SelectRowEvent<R>) => void];
|
329 |
|
330 | export declare function ValueFormatter<R, SR>(props: FormatterProps<R, SR>): JSX.Element | null;
|
331 |
|
332 | export { }
|