@sheetxl/grid-react 0.1.98

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.
@@ -0,0 +1,1487 @@
1
+ import { AnchorLocation } from '@sheetxl/utils';
2
+ import { AxisOrientationFlags } from '@sheetxl/utils';
3
+ import { Bounds } from '@sheetxl/utils';
4
+ import { CellCoords } from '@sheetxl/utils';
5
+ import { CellFinder } from '@sheetxl/utils-react';
6
+ import { CellLayout } from '@sheetxl/utils-react';
7
+ import { default as default_2 } from 'react';
8
+ import { Dimensions } from '@sheetxl/utils';
9
+ import { Direction } from '@sheetxl/utils';
10
+ import { HiddenHeadersAt } from '@sheetxl/utils-react';
11
+ import { HorizontalAlignment } from '@sheetxl/utils-react';
12
+ import { ICommands } from '@sheetxl/utils-react';
13
+ import { IScrollPaneElement } from '@sheetxl/utils-react';
14
+ import { ItemSizer } from '@sheetxl/utils-react';
15
+ import { JSX } from 'react/jsx-runtime';
16
+ import { PaintableText } from '@sheetxl/utils';
17
+ import { Point } from '@sheetxl/utils';
18
+ import { PointerHandlerOptions } from '@sheetxl/utils-react';
19
+ import { PointerModifiers } from '@sheetxl/utils-react';
20
+ import { RangeCoords } from '@sheetxl/utils';
21
+ import { RangeOrientation } from '@sheetxl/utils';
22
+ import { Rectangle } from '@sheetxl/utils';
23
+ import { ScrollableViewport } from '@sheetxl/utils-react';
24
+ import { ScrollPaneProps } from '@sheetxl/utils-react';
25
+ import { SelectionCoords } from '@sheetxl/utils';
26
+ import { TopLeft } from '@sheetxl/utils';
27
+
28
+ export declare interface AnimatedStrokeProps {
29
+ /**
30
+ * The named of the animation
31
+ */
32
+ name?: string;
33
+ dashGap: number;
34
+ speed: number;
35
+ dashLength: number;
36
+ }
37
+
38
+ /**
39
+ * Data grid component for rendering cells onto a virtual panel.
40
+ * This component coordinates between CellLayout and CellRenderer.
41
+ * This component expects a width and height to be passed to it.
42
+ *
43
+ * * To support dynamic width/height based on div sizing wrap this is @see <Grid>
44
+ * * To support scrolling wrap use @see <ScrollableGrid> (which wraps @see <Grid>)
45
+ *
46
+ * @see GridProps
47
+ */
48
+ export declare const BaseGrid: default_2.FC<GridProps & GridRefAttribute>;
49
+
50
+ export declare type CellEditorAttributes = {
51
+ /**
52
+ * When editor is loaded, this will be called. Note this should not use the autoFocus property. here
53
+ * If this is set the editor focus will be called as appropriate.
54
+ */
55
+ startEdit?(event: StartEditEvent): void;
56
+ submitEdit(): boolean;
57
+ cancelEdit(): void;
58
+ /**
59
+ * Called if the StartEditEvent event has autoFocus set.
60
+ * @param selector A selector string (or empty means 'default' focus)
61
+ */
62
+ autoFocus(selector?: string): void;
63
+ /**
64
+ * Returns the default line height.
65
+ */
66
+ getLineHeight: () => number;
67
+ };
68
+
69
+ export declare interface CellEditorProps<CT, DT> extends default_2.HTMLAttributes<HTMLElement>, default_2.Attributes {
70
+ /**
71
+ * editState of the cell
72
+ */
73
+ editState?: EditState<CT, DT> | null;
74
+ /**
75
+ * Styling for the textfield
76
+ */
77
+ defaultTextStyle?: TextStyle;
78
+ /**
79
+ * Override defaultText styling with cellStyling?
80
+ */
81
+ useRichStyling?: boolean;
82
+ /**
83
+ * Callback when a value has changed.
84
+ */
85
+ onStartEdit?(editState: EditState<CT, DT>): void;
86
+ /**
87
+ * Callback when a value has changed.
88
+ */
89
+ onChangeEdit?(editState: EditState<CT, DT>): void;
90
+ /**
91
+ * Callback to submit the value back to data store
92
+ */
93
+ onSubmitEdit?(editState: EditState<CT, DT>): void;
94
+ /**
95
+ * On Cancel callbacks. Hides the editor
96
+ */
97
+ onCancelEdit?(): void;
98
+ /**
99
+ * Called when either the cancel or submit is called.
100
+ */
101
+ onDoneEdit?(): void;
102
+ /**
103
+ * Position of editor, x, y, width and height
104
+ */
105
+ containerBounds?: Bounds;
106
+ disabled?: boolean;
107
+ setNaturalDimensions?(dim: Dimensions): void;
108
+ /**
109
+ * Callback to enable navigation after submit
110
+ * @param direction
111
+ */
112
+ onNavigate?(direction: Direction): void;
113
+ zoom?: number;
114
+ }
115
+
116
+ export declare type CellEditorRefAttribute = {
117
+ ref?: default_2.Ref<ICellEditorElement>;
118
+ };
119
+
120
+ export declare interface CellRendererProps<T = any> extends React.HTMLAttributes<HTMLElement>, React.Attributes {
121
+ /**
122
+ * A value to render
123
+ */
124
+ value: T;
125
+ /**
126
+ * The range bounds relative to the current viewport and zoom
127
+ */
128
+ bounds: Bounds;
129
+ /**
130
+ * The Coords that is being rendered.
131
+ */
132
+ coords: CellCoords;
133
+ /**
134
+ * The view that is rendering a collection of cells
135
+ */
136
+ view: GridView;
137
+ /**
138
+ * The RangeCoords that is being rendering.
139
+ * @remarks
140
+ * For non most cells this is the same as the coords. This will only be different for spanning cells
141
+ * @defaultValue The sames as the coords
142
+ */
143
+ range?: RangeCoords;
144
+ /**
145
+ * If there is a zoom scale.
146
+ * @defaultValue 1
147
+ */
148
+ zoom?: number;
149
+ }
150
+
151
+ export declare interface CoordOffset {
152
+ index: number;
153
+ offset: number;
154
+ }
155
+
156
+ /**
157
+ * Default cell editor
158
+ * @param props
159
+ */
160
+ export declare const DefaultCellEditor: default_2.FC<StringCellEditorProps & CellEditorRefAttribute>;
161
+
162
+ /**
163
+ * Default cell component capable of rendering a value
164
+ * @param props
165
+ */
166
+ export declare const DefaultCellRenderer: default_2.FC<CellRendererProps>;
167
+
168
+ export declare const DefaultHeaderDivider: default_2.FC<HeaderDividerRendererProps & {
169
+ ref?: default_2.Ref<IHeaderDividerElement>;
170
+ }>;
171
+
172
+ export declare const defaultSelectionRenderer: (props: SelectionProps) => JSX.Element;
173
+
174
+ export declare interface EditorOverlayResults {
175
+ /**
176
+ * Editor component to be injected.
177
+ */
178
+ overlay: <T>(view: GridView, ref: default_2.Ref<T>) => default_2.ReactNode;
179
+ /**
180
+ * Bind to keyboard event
181
+ */
182
+ onKeyboardEvent: (e: default_2.KeyboardEvent<HTMLDivElement>) => void;
183
+ onKeyboardEventNative: (e: globalThis.KeyboardEvent) => void;
184
+ /**
185
+ * Bind to pointer event
186
+ */
187
+ onPointerEvent(e: default_2.PointerEvent<HTMLDivElement>): void;
188
+ onPointerEventNative(e: globalThis.PointerEvent): void;
189
+ /**
190
+ * Make a cell editable
191
+ *
192
+ * @param event an option StartEditEvent
193
+ */
194
+ startEdit(event?: StartEditEvent): void;
195
+ /**
196
+ * Imperatively trigger submit
197
+ */
198
+ submitEdit(): void;
199
+ /**
200
+ * Cancels an edit
201
+ */
202
+ cancelEdit(): void;
203
+ /**
204
+ * indicates if the editor is active
205
+ */
206
+ isEditing: boolean;
207
+ /**
208
+ * OnScroll listener to align the editor
209
+ */
210
+ onScroll?: (scrollPoint: TopLeft) => void;
211
+ }
212
+
213
+ export declare interface EditState<CT, DT> {
214
+ clean: CT;
215
+ dirty?: DT | undefined;
216
+ editMode?: boolean;
217
+ }
218
+
219
+ /**
220
+ * Fill handle component
221
+ */
222
+ export declare const FillHandle: default_2.FC<FillHandleProps & FillHandleRefAttribute>;
223
+
224
+ export declare interface FillHandleAttributes {
225
+ }
226
+
227
+ export declare interface FillHandleProps extends default_2.HTMLAttributes<HTMLDivElement> {
228
+ corner?: string;
229
+ x?: number;
230
+ y?: number;
231
+ size?: number;
232
+ borderWidth?: number;
233
+ borderStroke?: string;
234
+ background?: string;
235
+ }
236
+
237
+ export declare type FillHandleRefAttribute = {
238
+ ref?: default_2.Ref<FillHandleAttributes>;
239
+ };
240
+
241
+ export declare interface FrozenEdge {
242
+ /**
243
+ * The boundaries for the edge
244
+ */
245
+ index: number;
246
+ /**
247
+ * If specified then the edge has a scrollOffset
248
+ */
249
+ scrollOffset?: number;
250
+ }
251
+
252
+ export declare const getDefaultStringEditState: (clean?: string) => EditState<string, string> | undefined;
253
+
254
+ export declare const Grid: default_2.FC<GridProps & GridRefAttribute>;
255
+
256
+ export declare interface GridAttributes {
257
+ /**
258
+ * The stage element for the cells
259
+ */
260
+ readonly stage: HTMLDivElement | null;
261
+ /**
262
+ * The rowCount provided by the properties
263
+ */
264
+ readonly rowCount: number;
265
+ /**
266
+ * The columnCount provided by the properties
267
+ */
268
+ readonly columnCount: number;
269
+ /**
270
+ * Invalidate either a cell or a range of cells. If no arguments are provided then the entire grid is invalidated.
271
+ * @param coords
272
+ */
273
+ invalidate: (coords?: CellCoords | RangeCoords) => void;
274
+ handleWheel: (event: globalThis.WheelEvent) => void;
275
+ getScrollPosition: () => TopLeft;
276
+ getViewport: () => RangeCoords;
277
+ getDimensions: () => {
278
+ containerWidth: number;
279
+ containerHeight: number;
280
+ totalWidth: number;
281
+ totalHeight: number;
282
+ };
283
+ /**
284
+ * Scroll the cell into view. If the coord does not have an index it will only scroll in a single direction.
285
+ */
286
+ scrollCellCoordsIntoView: (coords: Partial<CellCoords>, options?: globalThis.ScrollIntoViewOptions | boolean) => Promise<Partial<TopLeft>>;
287
+ /**
288
+ * The grid coordinates relative to the containing div (includes any padding, margins)
289
+ */
290
+ getRelativePointFromClient: (x: number, y: number) => Point | null;
291
+ /**
292
+ * Returns the view for the given point. If point is
293
+ * over a frozen pane it will return the frozen pane otherwise
294
+ * it will return the center view.
295
+ */
296
+ getViewFromClient: (x: number, y: number) => GridView;
297
+ /**
298
+ * Returns the view for the given coords. If coord is
299
+ * over a frozen pane it will return the frozen pane otherwise
300
+ * it will return the center view.
301
+ */
302
+ getViewFromCellCoords: (coords: CellCoords) => GridView;
303
+ /**
304
+ * Returns null if the view does not exist.
305
+ */
306
+ getViewFromLocation: (anchor: AnchorLocation) => GridView | null;
307
+ /**
308
+ * Called when the view has been changed.
309
+ * @remarks
310
+ * This is only called once.
311
+ */
312
+ onViewChangeOnce: (callback: () => void) => void;
313
+ }
314
+
315
+ export declare interface GridHeaderStyle extends GridSurfaceStyle {
316
+ strokeFillShadow?: string;
317
+ edgeStrokeFill?: string;
318
+ dividerStrokeFill?: string;
319
+ edgeStrokeWidth?: number;
320
+ }
321
+
322
+ export declare interface GridProps extends default_2.HTMLAttributes<HTMLDivElement> {
323
+ /**
324
+ * Width of the grid container
325
+ */
326
+ width?: number;
327
+ /**
328
+ * Height of the grid container
329
+ */
330
+ height?: number;
331
+ /**
332
+ * Number of columns in the grid
333
+ */
334
+ columnCount: number;
335
+ /**
336
+ * Number of rows in the grid
337
+ */
338
+ rowCount: number;
339
+ /**
340
+ * Passed through to @see useCellLayoutHook. If cellLayout property is provided this is ignored
341
+ */
342
+ defaultColumnWidth?: number;
343
+ /**
344
+ * Passed through to @see useCellLayoutHook. If cellLayout property is provided this is ignored
345
+ */
346
+ defaultRowHeight?: number;
347
+ /**
348
+ * Passed through to @see useCellLayoutHook. If cellLayout property is provided this is ignored
349
+ */
350
+ getRowHeight?: ItemSizer;
351
+ /**
352
+ * Passed through to @see useCellLayoutHook. If cellLayout property is provided this is ignored
353
+ */
354
+ getColumnWidth?: ItemSizer;
355
+ /**
356
+ * The layout for the cells
357
+ */
358
+ layout?: CellLayout;
359
+ /**
360
+ * Called on scroll, subject to debouncing. Used for programmatic changes. Called even on load
361
+ */
362
+ onViewportScroll?: (scrollPoint: Partial<TopLeft>) => void;
363
+ /**
364
+ * Called immediately on scroll. Used for programmatic changes. Called even on load
365
+ */
366
+ onImmediateScroll?: (scrollPoint: Partial<TopLeft>) => void;
367
+ /**
368
+ * Fired when the view port changes.
369
+ * This is in pixel coordinates and is slightly different than viewable cells because off screen location range could change
370
+ */
371
+ onViewportChange?: (viewport: ScrollableViewport) => void;
372
+ /**
373
+ * Enable dragging active cell and selections
374
+ */
375
+ enableMouseWheel?: boolean;
376
+ /**
377
+ * When wheel mouse is called. If return false then wheelMouse will not be processed
378
+ */
379
+ onWheelScroll?: (event: globalThis.WheelEvent) => boolean | void;
380
+ /**
381
+ * The location of the top left scroll corner
382
+ */
383
+ scrollPoint?: Partial<TopLeft>;
384
+ /**
385
+ * Number of frozen left
386
+ */
387
+ freezeLeft?: number | FrozenEdge;
388
+ /**
389
+ * Number of frozen top
390
+ */
391
+ freezeTop?: number | FrozenEdge;
392
+ /**
393
+ * Allow for customization of freezeTopDivider
394
+ */
395
+ freezeLeftProps?: Partial<LineProps>;
396
+ /**
397
+ * Allow for customization of freezeTopDivider
398
+ */
399
+ freezeTopProps?: Partial<LineProps>;
400
+ /**
401
+ * Called right before a row is being rendered.
402
+ * Will be called for frozen cells and merged cells
403
+ * @remarks Not implement.
404
+ */
405
+ /**
406
+ * Call only once when the renders for the first time.
407
+ */
408
+ onFirstRender?: (grid: IGridElement) => void;
409
+ /**
410
+ * Returns the actual element to render.
411
+ *
412
+ * @remarks
413
+ * There can be many cells so care should be taken
414
+ * to ensure these are as performant as possible. By default
415
+ * the pointerEvents are set to none. To enable interaction this should be
416
+ * overwritten.
417
+ */
418
+ cellRenderer?: (props: CellRendererProps) => default_2.ReactNode;
419
+ /**
420
+ * Allow for cells to be inset. This is a way to account for borders. By default this is 1, 1, 1,x.
421
+ */
422
+ cellInsets?: Rectangle;
423
+ /**
424
+ * Render elements for the view. This will be called whenever the viewport changes.
425
+ */
426
+ overlays?: ((view: GridView) => default_2.ReactNode)[];
427
+ /**
428
+ * Props passed to all overlayRenderers
429
+ */
430
+ overlaysProps?: default_2.HTMLAttributes<HTMLDivElement>;
431
+ /**
432
+ * Used for rendering overlays. Similar to cell render but covers the entire area.
433
+ * @param props
434
+ * @returns
435
+ */
436
+ overlayRenderer?: <T = any>(props: OverlayRendererProps, ref: default_2.Ref<T>) => default_2.ReactNode;
437
+ overlayProps?: default_2.HTMLAttributes<HTMLDivElement>;
438
+ /**
439
+ * Overlays are generally clipped to fit in the viewport but
440
+ * this allows for the properties to be overridden.
441
+ */
442
+ allowOverlaysOverflow?: boolean;
443
+ /**
444
+ * Allows users to Wrap stage children in Top level Context
445
+ */
446
+ stageWrapper?: (children: default_2.ReactNode) => default_2.ReactNode;
447
+ /**
448
+ * Props that can be injected to stage
449
+ */
450
+ stageProps?: default_2.HTMLAttributes<HTMLDivElement>;
451
+ /**
452
+ * Show grid lines.
453
+ * Useful for spreadsheets
454
+ * NOTE - should we just allow gridline renderers to be null?
455
+ */
456
+ showGridLines?: boolean | Partial<AxisOrientationFlags>;
457
+ /**
458
+ * Customize grid line color.
459
+ * @remarks
460
+ * This is overwritten by gridlinePropsVertical and gridlinePropsHorizontal
461
+ */
462
+ gridLineColor?: string;
463
+ /**
464
+ * Gridline props for rows.
465
+ */
466
+ gridLineRowsProps?: default_2.SVGProps<SVGPathElement>;
467
+ /**
468
+ * Gridline props for columns.
469
+ */
470
+ gridLineColumnsProps?: default_2.SVGProps<SVGPathElement>;
471
+ /**
472
+ * Will skip rendering for this row and the adjacent rows in the given direction.
473
+ */
474
+ hiddenRowsAt?: (rowIndex: number, forward: boolean) => number;
475
+ /**
476
+ * Will skip rendering for this columns and the adjacent columns in the given direction.
477
+ */
478
+ hiddenColumnsAt?: (colIndex: number, forward: boolean) => number;
479
+ /**
480
+ * Indicates the cell is hidden and should not be rendered.
481
+ *
482
+ * @remarks
483
+ * * Superseded by hiddenRowsAt and hiddenColumnsAt.
484
+ * * If getVisibleCells is define this is ignored
485
+ * This is typically used for cells that have nothing to render.
486
+ */
487
+ hiddenCellAt?: (coords: CellCoords) => boolean;
488
+ /**
489
+ * Allows for optimization of rendering.
490
+ *
491
+ * @param view
492
+ * @returns Either a CellCoord that should be rendered or an object with a coord and value. Note - the value is passed to the cell renderer
493
+ *
494
+ * @remarks
495
+ * * Allows for quick skipping of cells that have nothing to render.
496
+ * * If not specified then all cells within the visible range will be
497
+ * iterated and if hiddenCellAt does not return false then cellRender will be
498
+ * called.
499
+ */
500
+ getVisibleCells?: (view: GridView) => ({
501
+ coords: CellCoords;
502
+ value?: any;
503
+ range?: RangeCoords;
504
+ } | CellCoords)[];
505
+ /**
506
+ * Returns the cell as a range. If this cell is merged this will be reflected.
507
+ *
508
+ * @remarks
509
+ * Slightly more sophisticated than rowSpan and colSpan because it allows for queries that are not on the top/left.
510
+ */
511
+ getCellCoordsAsRangeCoords?: (coords: CellCoords) => RangeCoords;
512
+ /**
513
+ * Zoom. `1` indicates no zoom.
514
+ *
515
+ * @defaultValue 1 or none.
516
+ */
517
+ zoom?: number;
518
+ /**
519
+ * Cursor used for grid.
520
+ */
521
+ cursor?: string;
522
+ /**
523
+ * Clip overflow of cells unless explicitly provided.
524
+ */
525
+ clipCells?: boolean;
526
+ }
527
+
528
+ export declare type GridRefAttribute = {
529
+ ref?: default_2.Ref<IGridElement>;
530
+ };
531
+
532
+ export declare interface GridRefProps extends GridProps {
533
+ ref?: default_2.Ref<HTMLDivElement>;
534
+ }
535
+
536
+ export declare interface GridStyle extends GridSurfaceStyle {
537
+ body?: GridSurfaceStyle;
538
+ selection?: SelectionStyle;
539
+ selectionRemove?: SelectionStyle;
540
+ selectionInactive?: SelectionStyle;
541
+ header?: GridHeaderStyle;
542
+ headerSelect?: GridHeaderStyle;
543
+ headerSelectAll?: GridHeaderStyle;
544
+ headerHover?: GridHeaderStyle | ((style: GridHeaderStyle) => GridHeaderStyle);
545
+ headerSelection?: SelectionStyle;
546
+ headerSelectionInactive?: SelectionStyle;
547
+ colorShadow?: string;
548
+ colorGrey?: string;
549
+ filterDarkInvert?: string;
550
+ buttonSurface?: GridHeaderStyle;
551
+ }
552
+
553
+ export declare interface GridSurfaceStyle extends PaintStyle {
554
+ text?: TextStyle;
555
+ /**
556
+ * Indicates to the renderers that the colors being rendered are for dark mode.
557
+ * @remarks
558
+ * Renderers should invert colors if the colors being used are not specifically for dark mode.
559
+ */
560
+ darkMode?: boolean;
561
+ }
562
+
563
+ /**
564
+ * Describes the view of a grid.
565
+ *
566
+ * @remarks
567
+ * Useful for overlay rendering.
568
+ */
569
+ export declare interface GridView {
570
+ /**
571
+ * Returns the underlying stage element for the view.
572
+ *
573
+ * @remarks
574
+ * Useful for capturing stage events.
575
+ */
576
+ getStage(): HTMLDivElement | null;
577
+ /**
578
+ * The anchor for the view.
579
+ */
580
+ getAnchor(): AnchorLocation;
581
+ /**
582
+ * Allow for dimensions to be determined for various cells.
583
+ * The cellLayout is inclusive of the zoom
584
+ */
585
+ getLayout(): CellLayout;
586
+ /**
587
+ * Useful for internal rendering.
588
+ *
589
+ * @remarks
590
+ * The cell layout will account for zoom factors already.
591
+ */
592
+ getZoom(): number;
593
+ /**
594
+ * This captures the total viewable range.
595
+ *
596
+ * @remarks
597
+ * Will have the sames values as {@link getVisibleRows} and {@link getVisibleColumns}.
598
+ */
599
+ getVisibleRangeCoords(): RangeCoords;
600
+ /**
601
+ * Useful for scanning. Contains a list of row offsets that are visible.
602
+ * Guaranteed to be non-null but may be zero length if no rows are visible.
603
+ */
604
+ getVisibleRows(): number[];
605
+ /**
606
+ * Useful for scanning. Contains a list of column offsets that are visible.
607
+ * Guaranteed to be non-null but may be zero length if no column are visible.
608
+ */
609
+ getVisibleColumns(): number[];
610
+ /**
611
+ * Returns the SizedOffsets for columns.
612
+ */
613
+ getVisibleColumnOffsets(): SizedOffset;
614
+ /**
615
+ * Returns the SizedOffsets for rows.
616
+ */
617
+ getVisibleRowOffsets(): SizedOffset;
618
+ /**
619
+ * Returns the range coords that captures the entire view.
620
+ */
621
+ getTotalRangeCoords(): RangeCoords;
622
+ /**
623
+ * Clip a rectangle against the viewport.
624
+ *
625
+ * @remarks
626
+ * * A negative inset will extend outside of the viewport;
627
+ * * Useful when elements should visually 'flow' off of the viewport. (i.e. selection with borders)
628
+ */
629
+ toClipBounds(bounds?: Bounds, insets?: number | Bounds): Bounds;
630
+ /**
631
+ * Returns the viewport bounds for an absolute bounds.
632
+ */
633
+ toViewBounds(bounds: Bounds): Bounds;
634
+ /**
635
+ * Returns the absolute bounds for a viewport bounds.
636
+ */
637
+ toAbsoluteBounds(bounds: Bounds): Bounds;
638
+ /**
639
+ * The bounds of the the overlay relative to the total view.
640
+ */
641
+ getBounds(): Bounds;
642
+ /**
643
+ * Additional inside padding.
644
+ */
645
+ getInsets(): Rectangle;
646
+ /**
647
+ * Returns the cell as a range. If this cell is merged this will be reflected.
648
+ * Note - This is slightly more sophisticated than rowSpan and colSpan
649
+ * because it allows for queries that are not on the top/left.
650
+ */
651
+ getCellCoordsAsRangeCoords(coords: CellCoords): RangeCoords;
652
+ /**
653
+ * Returns a bounds for a given range.
654
+ * If not specified then will return for the cellRange.
655
+ *
656
+ * @param adjustment This allows you to adjust the rect. Note - This is not like insets
657
+ *
658
+ * @remarks
659
+ * The bounds are relative to the view.
660
+ */
661
+ getRangeCoordsBounds(range?: RangeCoords, adjustment?: Partial<Rectangle>): Bounds;
662
+ /**
663
+ * Scroll the cell coords into view.
664
+ * If the coord does not have an index it will only scroll in a single direction.
665
+ */
666
+ scrollCellCoordsIntoView(coords: Partial<CellCoords>, options?: globalThis.ScrollIntoViewOptions | boolean): Promise<Partial<TopLeft>>;
667
+ /**
668
+ * Returns the coords at the offset.
669
+ * @param x - The x offset relative to the view
670
+ * @param y - The y offset relative to the view
671
+ * @param actualCell - Don't return the topLeft of a merge. Default value `false`.
672
+ */
673
+ getCellCoordsFromClient(x: number, y: number, actualCell?: boolean): CellCoords | null;
674
+ /**
675
+ * Indicate the allowable scroll directions.
676
+ */
677
+ getScrollOrientation(): AxisOrientationFlags;
678
+ getScrollTopLeft(): TopLeft;
679
+ getFreezeTopLeft(): TopLeft;
680
+ /**
681
+ * Returns the total size of all rendered values in pixels.
682
+ */
683
+ getTotalSize(): Dimensions;
684
+ /**
685
+ * This is the size for all views (but not including the headers)
686
+ */
687
+ getViewportSize(): Dimensions;
688
+ /**
689
+ * Allows for access to all current views.
690
+ */
691
+ allViews(): Partial<Record<AnchorLocation, GridView>>;
692
+ /**
693
+ * Returns a point relative to the view.
694
+ */
695
+ getRelativePointFromClient(x: number, y: number): Point | null;
696
+ }
697
+
698
+ /**
699
+ * A divider placed between headers to provider a visual cue for various actions.
700
+ * Resize, hide/unhide, etc.
701
+ */
702
+ export declare const HeaderDivider: default_2.FC<HeaderDividerAnchorProps & {
703
+ ref?: default_2.Ref<IHeaderDividerElement>;
704
+ }>;
705
+
706
+ export declare interface HeaderDividerAnchorProps extends HeaderDividerProps {
707
+ dividerRenderer?: (props: HeaderDividerRendererProps, refForward?: default_2.Ref<IHeaderDividerElement>) => default_2.ReactNode;
708
+ /**
709
+ * The number of pixels to mouse before resizing starts.
710
+ * If this number is less than 1 then it will be 1.
711
+ */
712
+ resizeThreshold?: number;
713
+ /**
714
+ * Called when the mouse is pressed down.
715
+ * @param index the index of the divider.
716
+ * @param size the size of the header during callback.
717
+ */
718
+ onDividerMouseDown?: (index: number, size: number) => void;
719
+ /**
720
+ * Called after the mouse has dragged beyond the threshold
721
+ *
722
+ * @param index the index of the divider
723
+ * @param prevSize the size of the header on DividerResizeStart (not last resize call)
724
+ */
725
+ onDividerResizeStart?: (index: number, prevSize: number) => void;
726
+ /**
727
+ * Called during resize.
728
+ * @param index the index of the divider
729
+ * @param size the size of the header during callback
730
+ * @param prevSize the size of the header on resizeStart (not last resize call)
731
+ */
732
+ onDividerResize?: (index: number, size: number, prevSize: number) => void;
733
+ /**
734
+ * Called after the mouse has been released but only if the mouse onDividerResizeStart was called.
735
+ *
736
+ * @param index The index of the divider
737
+ * @param size the size of the header during callback
738
+ * @param prevSize In pixel the previous size of the divider
739
+ */
740
+ onDividerResizeEnd?: (index: number, size: number, prevSize: number) => void;
741
+ /**
742
+ * Called when the mouse is released (regardless of resize).
743
+ *
744
+ * @param index
745
+ */
746
+ onDividerMouseUp?: (index: number) => void;
747
+ /**
748
+ * Called when the mouse autoFit has been initiated (usually a double-click).
749
+ *
750
+ * @param index
751
+ */
752
+ onDividerAutoFit?: (index: number) => void;
753
+ }
754
+
755
+ export declare interface HeaderDividerAttributes {
756
+ }
757
+
758
+ /**
759
+ * HeaderDividers follow the header
760
+ * // TODO - allow negative resizing (before the current) (easy to do I think)
761
+ */
762
+ export declare interface HeaderDividerProps extends default_2.HTMLAttributes<HTMLDivElement> {
763
+ orientation: RangeOrientation;
764
+ view: GridView;
765
+ index: number;
766
+ /**
767
+ * This should disable interaction. This should also
768
+ * provide a visual cue that the divider is disabled.
769
+ */
770
+ disabled?: boolean;
771
+ /**
772
+ * If the divider does not allow resize.
773
+ * @remarks
774
+ * We create a faux divider on the left of the first header and we mark it as disabledResize.
775
+ */
776
+ disabledResize?: boolean;
777
+ /**
778
+ * If the next header is hidden.
779
+ * This allows the divider to shift location
780
+ */
781
+ isNextHidden?: boolean;
782
+ /**
783
+ * If the current header is hidden.
784
+ * This allows the divider to shift location
785
+ */
786
+ isHidden?: boolean;
787
+ /**
788
+ * If the header associated with this divider is selected.
789
+ */
790
+ isSelected?: boolean;
791
+ /**
792
+ * If the header associated with this divider is selected.
793
+ */
794
+ isSelectedAll?: boolean;
795
+ /**
796
+ * If the divider is the last one in view. Useful for touch divider that only show the last one.
797
+ */
798
+ showTouchDivider?: boolean;
799
+ headerStyle: GridHeaderStyle;
800
+ headerStyleSelect: GridHeaderStyle;
801
+ headerStyleSelectAll: GridHeaderStyle;
802
+ headerStyleHover?: GridHeaderStyle | ((style: GridHeaderStyle) => GridHeaderStyle);
803
+ }
804
+
805
+ export declare interface HeaderDividerRendererProps extends HeaderDividerProps {
806
+ bounds: Bounds;
807
+ /**
808
+ * Handle mouse down and all dragging
809
+ */
810
+ onPointerDown: default_2.PointerEventHandler<HTMLDivElement>;
811
+ onAutoFit: () => void;
812
+ }
813
+
814
+ export declare const HeaderRenderer: default_2.FC<HeaderRendererCellProps>;
815
+
816
+ export declare interface HeaderRendererCellProps extends CellRendererProps {
817
+ orientation: RangeOrientation;
818
+ index: number;
819
+ headerStyle: GridHeaderStyle;
820
+ headerStyleSelect: GridHeaderStyle;
821
+ headerStyleSelectAll: GridHeaderStyle;
822
+ headerStyleHover?: GridHeaderStyle | ((style: GridHeaderStyle) => GridHeaderStyle);
823
+ verticalPadding?: number;
824
+ horizontalPadding?: number;
825
+ headerText?: (index: number) => string;
826
+ isSelected?: (index: number) => boolean;
827
+ isSelectedAll?: (index: number) => boolean;
828
+ /**
829
+ * This is not the default grid zoom this is just for rendering.
830
+ * @defaultValue 100
831
+ */
832
+ zoomScale?: number;
833
+ }
834
+
835
+ export declare interface HeaderSelectionResults {
836
+ /**
837
+ * Handler for pointerdown
838
+ */
839
+ onPointerDown: (e: default_2.PointerEvent<HTMLElement>) => void;
840
+ getCellCoordsFromClient: (x: number, y: number) => CellCoords;
841
+ }
842
+
843
+ export declare interface ICellEditorElement extends HTMLDivElement, CellEditorAttributes {
844
+ }
845
+
846
+ /**
847
+ * Type returned via ref property
848
+ */
849
+ export declare interface IGridElement extends HTMLDivElement, GridAttributes {
850
+ }
851
+
852
+ export declare interface IHeaderDividerElement extends HTMLDivElement, HeaderDividerAttributes {
853
+ }
854
+
855
+ export declare interface LineProps extends default_2.SVGProps<SVGSVGElement> {
856
+ linePoints: number[];
857
+ bounds: Bounds;
858
+ pathProps?: default_2.SVGProps<SVGPathElement>;
859
+ }
860
+
861
+ export declare type NewHeaderSelectionMode = "clear" | "modify" | "append";
862
+
863
+ export declare type NewSelectionMode = "clear" | "modify" | "append";
864
+
865
+ export declare interface OverlayRendererProps extends React.HTMLAttributes<HTMLElement>, React.Attributes {
866
+ /**
867
+ * The view that is rendering a collection of cells
868
+ */
869
+ view: GridView;
870
+ onStageKeyDown?: (e: React.KeyboardEvent<Element>) => void;
871
+ onStagePointerDown?: (e: React.PointerEvent<Element>) => void;
872
+ onStageDoubleClick?: (e: React.PointerEvent<Element>) => void;
873
+ }
874
+
875
+ export declare interface PaintStyle {
876
+ fill?: string;
877
+ strokeFill?: string;
878
+ strokeWidth?: number;
879
+ }
880
+
881
+ export declare const RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL = 150;
882
+
883
+ export declare const safeSelectionCoords: (prev?: SelectionCoords) => SelectionCoords;
884
+
885
+ /**
886
+ * ScrollableGrid. This wraps BaseGrid and manages bounds to create consistent css behavior for consumers
887
+ */
888
+ export declare const ScrollableGrid: default_2.FC<ScrollableGridProps & ScrollableRefAttribute>;
889
+
890
+ export declare interface ScrollableGridProps extends GridProps, ScrollPaneProps {
891
+ /**
892
+ * Callback for detecting a change in the ScrollPane.
893
+ * @param scrollPoint
894
+ */
895
+ onScrollViewport?: (scrollPoint: Partial<TopLeft>) => void;
896
+ }
897
+
898
+ export declare type ScrollableRefAttribute = {
899
+ ref?: default_2.Ref<IGridElement | IScrollPaneElement>;
900
+ };
901
+
902
+ declare const Selection_2: default_2.FC<SelectionProps>;
903
+ export { Selection_2 as Selection }
904
+
905
+ export declare const SELECTION_CLIP_INSETS = -10;
906
+
907
+ export declare interface SelectionPointerHandlerOptions extends Omit<PointerHandlerOptions, "onPointerDown" | "onPointerMoveOrWait"> {
908
+ onSelectionPointerDown: (event: default_2.PointerEvent<Element>, modifiers: PointerModifiers, view?: GridView, coords?: CellCoords, pivotCoords?: CellCoords, extendSelection?: boolean, scrollToAnchor?: boolean, resetCellAnchor?: boolean) => boolean | void;
909
+ onSelectionPointerMoveOrWait?: (event: globalThis.PointerEvent, modifiers: PointerModifiers, originalEvent: default_2.PointerEvent<Element>, view?: GridView, coords?: CellCoords, pivotCoords?: CellCoords, scrollToAnchor?: boolean, resetCellAnchor?: boolean) => void;
910
+ }
911
+
912
+ export declare type SelectionPolicy = "single" | "range" | "multiple";
913
+
914
+ export declare interface SelectionProps extends SVGRectProps {
915
+ /**
916
+ * @defaultValue false unless props are set
917
+ */
918
+ isAnimatedStroke?: boolean;
919
+ animatedStrokeProps?: AnimatedStrokeProps;
920
+ range: RangeCoords;
921
+ /**
922
+ * An area may or may not contain an anchor cell.
923
+ */
924
+ cell?: CellCoords;
925
+ }
926
+
927
+ export declare interface SelectionResults {
928
+ /**
929
+ * The current selection.
930
+ */
931
+ selection: SelectionCoords;
932
+ /**
933
+ * Set the currently active cell.
934
+ */
935
+ setSelectionCell: (coords: CellCoords | null, shouldScroll?: boolean) => void;
936
+ /**
937
+ * Use this to update selections without clearing old selection.
938
+ */
939
+ setSelectionRanges: (ranges: RangeCoords[] | ((ranges: RangeCoords[]) => RangeCoords[])) => void;
940
+ /**
941
+ * Handler for pointerdown, use to set activeCoords
942
+ */
943
+ onPointerDown: (e: default_2.PointerEvent<HTMLDivElement>) => void;
944
+ /**
945
+ * Returns a flag indicating if the entire range is selected
946
+ */
947
+ isEntire: boolean;
948
+ /**
949
+ * Preferred global cursor if set
950
+ */
951
+ cursor?: string;
952
+ /**
953
+ * Array of functions that return components to overlay
954
+ * // TODO - make this a function that takes props and received onMouse, onKeyboard
955
+ * (we can then make selection overlays a function that doesn't rerender the table (or sheet on move))
956
+ */
957
+ overlay: (view: GridView) => default_2.ReactNode;
958
+ /**
959
+ * Navigate left/right/up/down
960
+ * @param direction The direction to navigate.
961
+ * @param select A flag indicating if we should select the new cell.
962
+ * @param contentFul A flag indicating if we should navigate to the next contentful cell.
963
+ * @param incrementAmount Use instead of contentful. Allows for navigating distances (useful for pageUp/pageDown).
964
+ */
965
+ navigate?: (direction: Direction, select?: boolean, contentFul?: boolean, incrementAmount?: number) => void;
966
+ /**
967
+ * Navigate with the selections (unless there is no active selection)
968
+ */
969
+ navigateSelection: (direction: Direction) => void;
970
+ /**
971
+ * Use this to invoke a new selection. All old selections will be cleared
972
+ */
973
+ newSelection: (coordsStart: Partial<CellCoords>, coordsEnd?: Partial<CellCoords>, anchor?: Partial<CellCoords>) => void;
974
+ /**
975
+ * Modify selection. If the coordsPivot is not provided then the current anchor will be used.
976
+ */
977
+ modifySelection: (coords: CellCoords, coordsPivot?: CellCoords) => void;
978
+ /**
979
+ * Add a new selection
980
+ */
981
+ appendSelection: (start: CellCoords, end: CellCoords, anchor?: Partial<CellCoords>) => void;
982
+ /**
983
+ * Clear all current ranges. Leaves the anchor intact
984
+ */
985
+ clearSelections: () => void;
986
+ /**
987
+ * Clears the last selection
988
+ */
989
+ clearLastSelection: () => void;
990
+ }
991
+
992
+ export declare interface SelectionStyle extends PaintStyle {
993
+ }
994
+
995
+ export declare type SizedOffset = Record<number, {
996
+ offset: number;
997
+ size: number;
998
+ spanIndex: number;
999
+ }>;
1000
+
1001
+ /**
1002
+ * A set of standard characters that are used for starting a CellEditor.
1003
+ */
1004
+ export declare const STANDARD_KEY_CHARS: string;
1005
+
1006
+ export declare interface StartEditEvent {
1007
+ /**
1008
+ * Edit text. If this is null or undefined then this will not replace the text.
1009
+ *
1010
+ * @defaultValue null
1011
+ *
1012
+ * @remarks
1013
+ * * A '' will clear the text.
1014
+ */
1015
+ text?: string;
1016
+ /**
1017
+ * Is editor starting in edit mode.
1018
+ *
1019
+ * @defaultValue false
1020
+ */
1021
+ editMode?: boolean;
1022
+ /**
1023
+ * Allows the initial selection position to be overridden. By default it's at the end
1024
+ */
1025
+ initialSelection?: {
1026
+ start: number;
1027
+ end: number;
1028
+ direction?: "forward" | "backward" | "none";
1029
+ };
1030
+ /**
1031
+ * Should editor start editing with focus. If a string is passed this will use a querySelector to a nest element to focus.
1032
+ *
1033
+ * @defaultValue true
1034
+ */
1035
+ autoFocus?: boolean | string;
1036
+ /**
1037
+ * The cell that should be edited
1038
+ */
1039
+ cell?: CellCoords;
1040
+ }
1041
+
1042
+ export declare interface StringCellEditorProps extends CellEditorProps<string, string> {
1043
+ textProperties?: PaintableText;
1044
+ }
1045
+
1046
+ export declare const SVGLine: (props: LineProps) => JSX.Element;
1047
+
1048
+ declare const SVGRect_2: (props: SVGRectProps) => JSX.Element;
1049
+ export { SVGRect_2 as SVGRect }
1050
+
1051
+ export declare interface SVGRectProps extends default_2.SVGProps<SVGSVGElement> {
1052
+ pathBounds?: Bounds;
1053
+ pathProps?: default_2.SVGProps<SVGPathElement>;
1054
+ }
1055
+
1056
+ export declare interface TextStyle extends PaintStyle {
1057
+ fontFamily?: string;
1058
+ fontSize?: number;
1059
+ fontWeight?: string | number;
1060
+ fontStyle?: string;
1061
+ }
1062
+
1063
+ /**
1064
+ * TouchSelectHandle component
1065
+ */
1066
+ export declare const TouchSelectHandle: default_2.FC<TouchSelectHandleRefProps>;
1067
+
1068
+ export declare interface TouchSelectHandleAttributes {
1069
+ }
1070
+
1071
+ export declare interface TouchSelectHandleElement extends HTMLDivElement, TouchSelectHandleAttributes {
1072
+ }
1073
+
1074
+ export declare interface TouchSelectHandleProps extends default_2.HTMLAttributes<HTMLDivElement> {
1075
+ /**
1076
+ * Possible anchors are. If 'l', 't', 'r', or 'b', then it will center along view the view.
1077
+ *
1078
+ * @remarks
1079
+ * Determines not only the position but the event that is fired.
1080
+ */
1081
+ anchor: 'tl' | 'br' | 'l' | 't' | 'r' | 'b';
1082
+ range: RangeCoords;
1083
+ view: GridView;
1084
+ size?: number;
1085
+ borderWidth?: number;
1086
+ borderStroke?: string;
1087
+ background?: string;
1088
+ selectionTouchPointerHandler: SelectionPointerHandlerOptions;
1089
+ onTouchSelectStart?: (anchor: string) => void;
1090
+ onTouchSelectEnd?: (anchor: string) => void;
1091
+ /**
1092
+ * Indicate that a touch handling is being used
1093
+ */
1094
+ currentTouchAnchor?: string;
1095
+ /**
1096
+ * If provided then touch control will walk the parent hierarchy
1097
+ * to find the absolute scroll position
1098
+ */
1099
+ scrollableElement?: HTMLElement;
1100
+ /**
1101
+ * Use to add create the portal
1102
+ * @defaultValue document.body
1103
+ */
1104
+ scrollableRoot?: HTMLElement;
1105
+ }
1106
+
1107
+ export declare type TouchSelectHandleRefAttribute = {
1108
+ ref?: default_2.Ref<TouchSelectHandleElement>;
1109
+ };
1110
+
1111
+ export declare interface TouchSelectHandleRefProps extends TouchSelectHandleProps, TouchSelectHandleRefAttribute {
1112
+ }
1113
+
1114
+ export declare const useCellLayout: (props: UseCellLayoutProps | null) => CellLayout;
1115
+
1116
+ export declare interface UseCellLayoutProps {
1117
+ /**
1118
+ * Number of columns in the grid
1119
+ */
1120
+ columnCount: number;
1121
+ /**
1122
+ * Number of rows in the grid
1123
+ */
1124
+ rowCount: number;
1125
+ /**
1126
+ * Performance - Helps in lazy grid width calculation
1127
+ */
1128
+ defaultColumnWidth?: number;
1129
+ /**
1130
+ * Performance - Helps in lazy grid height calculation
1131
+ */
1132
+ defaultRowHeight?: number;
1133
+ /**
1134
+ * Should return height of a row at an index
1135
+ */
1136
+ getRowHeight?: ItemSizer;
1137
+ /**
1138
+ * Should return width of a column at an index
1139
+ */
1140
+ getColumnWidth?: ItemSizer;
1141
+ }
1142
+
1143
+ /**
1144
+ * Hook to enable selection in grid
1145
+ */
1146
+ export declare const useHeaderSelection: ({ gridRef, gridMainRef, orientation, headerCount: propHeaderCount, selectionPolicy, newSelectionMode, alwaysScrollToActiveCoords, onDragStart: propOnDragStart, onDragEnd: propOnDragEnd, pointerDownInterceptor, pointerMoveInterceptor, onPointerUp, newSelection: propNewSelection, modifySelection: propModifySelection, appendSelection: propAppendSelection, clearSelections: propClearSelections, }: UseHeaderSelectionOptions) => HeaderSelectionResults;
1147
+
1148
+ /**
1149
+ * Hook for managing the header selections.
1150
+ *
1151
+ * TODO - When dragging a selection that already exist it should drag for reorder. (Not supported yet)
1152
+ */
1153
+ export declare interface UseHeaderSelectionOptions {
1154
+ /**
1155
+ * Access grid functions
1156
+ */
1157
+ gridMainRef: default_2.RefObject<IGridElement | null>;
1158
+ /**
1159
+ * Access grid functions
1160
+ */
1161
+ gridRef: default_2.RefObject<IGridElement | null>;
1162
+ /**
1163
+ * The orientation of the header.
1164
+ */
1165
+ orientation?: RangeOrientation;
1166
+ /**
1167
+ * No of headers in the grid
1168
+ */
1169
+ headerCount?: number;
1170
+ /**
1171
+ * scroll to active cell when
1172
+ */
1173
+ alwaysScrollToActiveCoords?: boolean;
1174
+ /**
1175
+ * Pointerdown Interceptor
1176
+ */
1177
+ pointerDownInterceptor?: (e: default_2.PointerEvent<Element>, coords: CellCoords) => boolean | undefined;
1178
+ /**
1179
+ * Pointer Move Interceptor
1180
+ */
1181
+ pointerMoveInterceptor?: (e: globalThis.PointerEvent, coords: CellCoords) => boolean | undefined;
1182
+ /**
1183
+ * Pointer Up Listener
1184
+ */
1185
+ onPointerUp?: (e: globalThis.PointerEvent) => void;
1186
+ /**
1187
+ * Returns true if the coordinate span can overlap merged ranges.
1188
+ * @param start
1189
+ * @param end
1190
+ * @returns A flag indicating if the selection will span over (ignore) merged cells.
1191
+ */
1192
+ canSelectionSpanMergedCells?: (start: CellCoords, end: CellCoords) => boolean;
1193
+ /**
1194
+ * Selection policy
1195
+ */
1196
+ selectionPolicy?: SelectionPolicy;
1197
+ /**
1198
+ * New selection mode
1199
+ */
1200
+ newSelectionMode?: NewHeaderSelectionMode;
1201
+ /**
1202
+ * Callback when drag starts
1203
+ */
1204
+ onDragStart?: () => void;
1205
+ /**
1206
+ * Callback when drag ends
1207
+ */
1208
+ onDragEnd?: () => void;
1209
+ /**
1210
+ * Use this to invoke a new selection. All old selections will be cleared
1211
+ */
1212
+ newSelection: (coordsStart: Partial<CellCoords>, coordsEnd?: Partial<CellCoords>, anchor?: Partial<CellCoords>) => void;
1213
+ /**
1214
+ * Modify selection. If the coordsPivot is not provided then the current anchor will be used.
1215
+ */
1216
+ modifySelection: (coords: CellCoords, coordsPivot?: CellCoords) => void;
1217
+ /**
1218
+ * Add a new selection
1219
+ */
1220
+ appendSelection: (start: CellCoords, end: CellCoords, anchor?: Partial<CellCoords>) => void;
1221
+ /**
1222
+ * Clear all current ranges. Leaves the anchor intact
1223
+ */
1224
+ clearSelections: () => void;
1225
+ }
1226
+
1227
+ /**
1228
+ * Hook to make enable inline 'keyboard editing'. Simple editing like checkboxes can be implemented as renderers
1229
+ *
1230
+ * @param props
1231
+ *
1232
+ * @remarks
1233
+ * For creating a CellOverlay that routes keyboard (and pointer) events.
1234
+ */
1235
+ export declare const useKeyboardEditorOverlay: (props: useKeyboardEditorOverlayOptions) => EditorOverlayResults;
1236
+
1237
+ /**
1238
+ * This enables custom editors to be injected in place of a renderer.
1239
+ * Note sometimes is makes more sense to just allow the renderer to edit in place.
1240
+ * Some examples are when a formula is being entered or if the cell is empty
1241
+ *
1242
+ * TODO - should the editor extend the render interface?
1243
+ */
1244
+ export declare interface useKeyboardEditorOverlayOptions {
1245
+ /**
1246
+ * If provided and it doesn't return null then the editor will be aligned to the range.
1247
+ */
1248
+ getRangeCoords?: (coord: CellCoords) => RangeCoords;
1249
+ /**
1250
+ * The view that is being used for rendering
1251
+ */
1252
+ view: GridView;
1253
+ /**
1254
+ * Active selected cell. This is required to enable
1255
+ * the editor to activate when a key is pressed
1256
+ */
1257
+ activeCoords: CellCoords | null;
1258
+ /**
1259
+ * Inject custom editors based on a cell.
1260
+ * This should not return null but rather can canEdit.
1261
+ * This is called during placement after scrolling and other bookkeeping has occurred
1262
+ */
1263
+ getCellEditor: (props: CellEditorProps<any, any> & CellEditorRefAttribute, coords: CellCoords) => default_2.ReactElement<CellEditorProps<any, any> & CellEditorRefAttribute>;
1264
+ /**
1265
+ * Callback fired before editing. Can be used to prevent editing.
1266
+ */
1267
+ canEdit?(coords: CellCoords): boolean;
1268
+ /**
1269
+ * Callback when a start has been initialed. This is called before the editor is mounted.
1270
+ */
1271
+ onBeforeStartEdit?: (coords: CellCoords) => void;
1272
+ /**
1273
+ * Callback when user start editing
1274
+ */
1275
+ onStartEdit?: (coords: CellCoords) => void;
1276
+ /**
1277
+ * Callback when user submits a value. Use this to update state
1278
+ */
1279
+ onSubmitEdit?: (coords: CellCoords) => void;
1280
+ /**
1281
+ * Callback when user cancels editing
1282
+ */
1283
+ onCancelEdit?: (coords: CellCoords) => void;
1284
+ /**
1285
+ * Callback when user is done editing, either a submit or a cancel
1286
+ */
1287
+ onDoneEdit?: (coords: CellCoords) => void;
1288
+ onNavigate?: (direction: Direction) => void;
1289
+ /**
1290
+ * Test if the key event should start the editor
1291
+ */
1292
+ isEditorStartKeyEvent?: (e: KeyboardEvent, coords: CellCoords) => boolean | StartEditEvent;
1293
+ /**
1294
+ * Test if the mouse event should start the editor. If this returns an event this will be dispatched to the editor.
1295
+ *
1296
+ * @param e - The pointer event
1297
+ *
1298
+ * @returns Either `true` or an `StartEditEvent`
1299
+ */
1300
+ isEditorStartPointerEvent?: (e: PointerEvent, coords: CellCoords) => boolean | StartEditEvent;
1301
+ containerProps?: default_2.HTMLAttributes<HTMLDivElement>;
1302
+ borderStrokeFill?: string;
1303
+ borderStrokeWidth?: number;
1304
+ /**
1305
+ * The editor alignment. Used for expanding on overflow
1306
+ */
1307
+ alignment?: HorizontalAlignment;
1308
+ }
1309
+
1310
+ export declare const useSelection: ({ gridRef, commands, layout, selection: propSelection, onSelectionChange: propOnSelectionChange, onSelectionDragStart: propOnSelectionDragStart, onSelectionDragEnd: propOnSelectionDragEnd, selectionPolicy, newSelectionMode, allowDeselectSelection, onFillPreview: propOnFillPreview, onFillCancel: propOnFillCancel, onFillDone: propOnFillDone, onFill: propOnFill, disableFillDrag, fillHandleBorderColor, hiddenRowsAt: propHiddenRowsAt, hiddenColumnsAt: propHiddenColumnsAt, isContentfulCell: propsIsContentfulCell, contentfulCellFinder: propContentfulCellFinder, getDataCoords, alwaysScrollToActiveCoords, selectionBounds: propSelectionBounds, pointerDownInterceptor, pointerMoveInterceptor, mergedRanges, canSelectionSpanMergedCells, onMoveDragStart: propOnMoveDragStart, onMoveDragUpdate: propOnMoveDragUpdate, onMoveDragEnd: propOnMoveDragEnd, onMoveDragDone: propOnMoveDragDone, selectionRenderer: propSelectionRenderer, disableMoveDrag, getCellCoordsAsRangeCoords, moveDragHitSize, moveDragOutlineSize, selectionBackgroundColor, selectionBorderColor, selectionRemoveBorderColor, selectionRemoveBackgroundColor, disableTouchSelection, touchSelectHandleProps, }: UseSelectionOptions) => SelectionResults;
1311
+
1312
+ export declare interface UseSelectionOptions {
1313
+ /**
1314
+ * Access grid functions.
1315
+ */
1316
+ gridRef: default_2.RefObject<IGridElement | null>;
1317
+ commands?: ICommands.IGroup;
1318
+ /**
1319
+ * This is used for pageUp/pageDown and getHiddenAuto.
1320
+ */
1321
+ layout?: CellLayout;
1322
+ /**
1323
+ * selections
1324
+ */
1325
+ selection?: SelectionCoords;
1326
+ /**
1327
+ * Callback when a value has changed.
1328
+ */
1329
+ onSelectionChange?: (selection: SelectionCoords) => void;
1330
+ /**
1331
+ * Callback at the start of selection change driven by the pointer.
1332
+ */
1333
+ onSelectionDragStart?: (selection: SelectionCoords, e: globalThis.PointerEvent) => void;
1334
+ /**
1335
+ * Callback at the end of selection change driven by the pointer.
1336
+ */
1337
+ onSelectionDragEnd?: (selection: SelectionCoords, e: globalThis.PointerEvent) => void;
1338
+ /**
1339
+ * Allow deselect a selected area
1340
+ */
1341
+ allowDeselectSelection?: boolean;
1342
+ /**
1343
+ * Hidden rows
1344
+ */
1345
+ hiddenRowsAt?: HiddenHeadersAt;
1346
+ /**
1347
+ * Hidden columns
1348
+ */
1349
+ hiddenColumnsAt?: HiddenHeadersAt;
1350
+ /**
1351
+ * If there is no value. Note - This is slightly different than isEmpty because it may still have logical render (like fill, border, etc)
1352
+ */
1353
+ isContentfulCell?: (coords: CellCoords) => boolean;
1354
+ /**
1355
+ * Allows for selection to navigate intelligently between cells based on if they have data.
1356
+ * If this is note specified a default implementation will be used that uses hiddenRowsAt/hiddenColumnsAt/hiddenCellAt.
1357
+ * If no intelligently navigation is desired then this can be set explicitly to null.
1358
+ */
1359
+ contentfulCellFinder?: CellFinder;
1360
+ /**
1361
+ * Performance - important performance consideration.
1362
+ * This allows functions (like copy and scan to not operate on the entire sheet.)
1363
+ * If this is not set or returns `undefined` then a scan of all the rows/columns will
1364
+ * be done when needed to determine. (For example select all in a large sheet and copy to clipboard)
1365
+ */
1366
+ getDataCoords?: () => RangeCoords;
1367
+ /**
1368
+ * Always scroll to active cell
1369
+ */
1370
+ alwaysScrollToActiveCoords?: boolean;
1371
+ /**
1372
+ * bound of selection
1373
+ */
1374
+ selectionBounds?: Rectangle;
1375
+ /**
1376
+ * pointerDownInterceptor
1377
+ */
1378
+ pointerDownInterceptor?: (e: default_2.PointerEvent<Element>, coords: CellCoords, selection: SelectionCoords) => boolean | undefined;
1379
+ pointerMoveInterceptor?: (e: globalThis.PointerEvent, coords: CellCoords, selection: SelectionCoords) => boolean | undefined;
1380
+ /**
1381
+ * Is the current selection able to intersect merged cells.
1382
+ */
1383
+ canSelectionSpanMergedCells?: (range: RangeCoords) => boolean;
1384
+ /**
1385
+ * Selection policy
1386
+ */
1387
+ selectionPolicy?: SelectionPolicy;
1388
+ /**
1389
+ * New selection mode
1390
+ */
1391
+ newSelectionMode?: NewSelectionMode;
1392
+ /**
1393
+ * Disable move drag
1394
+ * @defaultValue if the onMoveDragDone is provided
1395
+ */
1396
+ disableMoveDrag?: boolean;
1397
+ /**
1398
+ * The size of the move hit stroke.
1399
+ * @defaultValue 5
1400
+ */
1401
+ moveDragHitSize?: number;
1402
+ /**
1403
+ * The size of the move outline.
1404
+ * @defaultValue 3
1405
+ */
1406
+ moveDragOutlineSize?: number;
1407
+ /**
1408
+ * Callback at the start of selection change driven by the pointer.
1409
+ */
1410
+ onMoveDragStart?: (from: RangeCoords, e: globalThis.PointerEvent, modifiers: PointerModifiers) => void;
1411
+ /**
1412
+ * Callback at the start of selection change driven by the pointer.
1413
+ */
1414
+ onMoveDragUpdate?: (from: RangeCoords, e: globalThis.PointerEvent, modifiers: PointerModifiers) => void;
1415
+ /**
1416
+ * Callback at the end of selection change driven by the pointer.
1417
+ */
1418
+ onMoveDragEnd?: (from: RangeCoords, e: globalThis.PointerEvent, modifiers: PointerModifiers) => void;
1419
+ /**
1420
+ * When selection is moved.
1421
+ */
1422
+ onMoveDragDone?: (from: RangeCoords, to: RangeCoords, event: globalThis.PointerEvent, modifiers: PointerModifiers) => Promise<void>;
1423
+ /**
1424
+ * Disable fill drag.
1425
+ * @defaultValue to a value based on if onFill is provided.
1426
+ */
1427
+ disableFillDrag?: boolean;
1428
+ /**
1429
+ * Called to actually perform the fill.
1430
+ */
1431
+ onFill?: (template: RangeCoords, destination: RangeCoords, direction: Direction) => void;
1432
+ /**
1433
+ * Called when dragging to fill.
1434
+ */
1435
+ onFillPreview?: (template: RangeCoords, destination: RangeCoords, direction: Direction) => void;
1436
+ /**
1437
+ * Called when a cancel is started but not completed by dragging to original rect.
1438
+ */
1439
+ onFillCancel?: () => void;
1440
+ /**
1441
+ * Called when fill gesture is complete; either onFill or onFillCancel'
1442
+ */
1443
+ onFillDone?: () => void;
1444
+ /**
1445
+ * Border color of fill handle.
1446
+ */
1447
+ fillHandleBorderColor?: string;
1448
+ /**
1449
+ * Disable touch selection If false then the touch selection handles are not set
1450
+ * @defaultValue true
1451
+ */
1452
+ disableTouchSelection?: boolean;
1453
+ /**
1454
+ * If touch is enabled.
1455
+ */
1456
+ touchSelectHandleProps?: TouchSelectHandleProps;
1457
+ /**
1458
+ * Allow users to customize selected cells design
1459
+ */
1460
+ selectionRenderer?: (props: SelectionProps) => default_2.ReactNode;
1461
+ /**
1462
+ * Border color of selected area
1463
+ */
1464
+ selectionBorderColor?: string;
1465
+ /**
1466
+ * Background of selection
1467
+ */
1468
+ selectionBackgroundColor?: string;
1469
+ selectionRemoveBorderColor?: string;
1470
+ /**
1471
+ * Background of selection for removal
1472
+ */
1473
+ selectionRemoveBackgroundColor?: string;
1474
+ /**
1475
+ * Is either an array of merged cells or a RangeCoordsLookup
1476
+ */
1477
+ mergedRanges?: RangeCoords[] | ((range: RangeCoords) => RangeCoords[]);
1478
+ /**
1479
+ * Returns the cell as a range. If this cell is merged this will be reflected.
1480
+ * @remarks
1481
+ * This is slightly more sophisticated than rowSpan and colSpan
1482
+ * because it allows for queries that are not on the top/left.
1483
+ */
1484
+ getCellCoordsAsRangeCoords?: (coords: CellCoords) => RangeCoords;
1485
+ }
1486
+
1487
+ export { }