@sheetxl/grid-react 0.7.27 → 0.7.28-beta.2

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