@sheetxl/grid-react 0.7.19 → 0.7.20

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.7.19
2
+ * @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.7.20
3
3
  *
4
4
  * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
@@ -554,23 +554,23 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
554
554
  });
555
555
  we.displayName = "Selection";
556
556
  const xe = C(I((t2, n2) => {
557
- const { x: o2 = 0, y: r2 = 0, borderWidth: l2 = 1, size: i2 = 6, borderStroke: c2, corner: s2, style: a2, className: d2, background: u2, ...h2 } = t2;
557
+ const { x: o2 = 0, y: r2 = 0, borderWidth: l2 = 1, size: i2 = 6, borderStroke: c2, corner: s2, style: a2, className: d2, background: u2, ref: h2, ...g2 } = t2;
558
558
  if (0 === o2 || 0 === r2) return null;
559
- let g2 = true, f2 = true, w2 = true, x2 = true;
559
+ let f2 = true, w2 = true, x2 = true, p2 = true;
560
560
  switch (s2) {
561
561
  case "tl":
562
- g2 = false, f2 = false;
562
+ f2 = false, w2 = false;
563
563
  break;
564
564
  case "bl":
565
- g2 = false, x2 = false;
565
+ f2 = false, p2 = false;
566
566
  break;
567
567
  case "br":
568
- w2 = false, x2 = false;
568
+ x2 = false, p2 = false;
569
569
  break;
570
570
  case "tr":
571
- f2 = false, w2 = false;
571
+ w2 = false, x2 = false;
572
572
  }
573
- return e("div", { className: k("fill-handle", d2), style: { position: "absolute", left: o2 - (i2 + (g2 ? l2 : 0)) / 2, top: r2 - (i2 + (f2 ? l2 : 0)) / 2, width: i2, height: i2, borderLeft: g2 ? `${l2}px ${c2}` : void 0, borderTop: f2 ? `${l2}px ${c2}` : void 0, borderRight: w2 ? `${l2}px ${c2}` : void 0, borderBottom: x2 ? `${l2}px ${c2}` : void 0, background: u2, cursor: "crosshair", pointerEvents: "all", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top", willChange: "left, top", ...a2 }, tabIndex: -1, ...h2 });
573
+ return e("div", { className: k("fill-handle", d2), style: { position: "absolute", left: o2 - (i2 + (f2 ? l2 : 0)) / 2, top: r2 - (i2 + (w2 ? l2 : 0)) / 2, width: i2, height: i2, borderLeft: f2 ? `${l2}px ${c2}` : void 0, borderTop: w2 ? `${l2}px ${c2}` : void 0, borderRight: x2 ? `${l2}px ${c2}` : void 0, borderBottom: p2 ? `${l2}px ${c2}` : void 0, background: u2, cursor: "crosshair", pointerEvents: "all", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top", willChange: "left, top", ...a2 }, tabIndex: -1, ...g2 });
574
574
  }));
575
575
  xe.displayName = "FillHandle";
576
576
  const pe = i.detectIt().supportsTouchEvents, me = C(I((r2, l2) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sheetxl/grid-react",
3
3
  "description": "Grid React - Advanced grid component for React",
4
- "version": "0.7.19",
4
+ "version": "0.7.20",
5
5
  "license": "SEE LICENSE IN <LICENSE>",
6
6
  "type": "module",
7
7
  "exports": {
@@ -41,8 +41,8 @@
41
41
  "table"
42
42
  ],
43
43
  "dependencies": {
44
- "@sheetxl/utils": "^0.7.19",
45
- "@sheetxl/utils-react": "^0.7.19",
44
+ "@sheetxl/utils": "^0.7.20",
45
+ "@sheetxl/utils-react": "^0.7.20",
46
46
  "clsx": "^2.1.1",
47
47
  "react-merge-refs": "^3.0.2",
48
48
  "react-use": "^17.6.0",
package/types/index.d.ts CHANGED
@@ -45,26 +45,7 @@ export declare interface AnimatedStrokeProps {
45
45
  *
46
46
  * @see GridProps
47
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
- };
48
+ export declare const BaseGrid: default_2.NamedExoticComponent<GridProps & default_2.RefAttributes<IGridElement>>;
68
49
 
69
50
  export declare interface CellEditorProps<CT, DT> extends default_2.HTMLAttributes<HTMLElement>, default_2.Attributes {
70
51
  /**
@@ -111,11 +92,11 @@ export declare interface CellEditorProps<CT, DT> extends default_2.HTMLAttribute
111
92
  */
112
93
  onNavigate?(direction: Direction): void;
113
94
  zoom?: number;
114
- }
115
-
116
- export declare type CellEditorRefAttribute = {
95
+ /**
96
+ * Reference to the underlying element
97
+ */
117
98
  ref?: default_2.Ref<ICellEditorElement>;
118
- };
99
+ }
119
100
 
120
101
  export declare interface CellRendererProps<T = any> extends React.HTMLAttributes<HTMLElement>, React.Attributes {
121
102
  /**
@@ -155,19 +136,18 @@ export declare interface CoordOffset {
155
136
 
156
137
  /**
157
138
  * Default cell editor
139
+ *
158
140
  * @param props
159
141
  */
160
- export declare const DefaultCellEditor: default_2.FC<StringCellEditorProps & CellEditorRefAttribute>;
142
+ export declare const DefaultCellEditor: default_2.NamedExoticComponent<Omit<StringCellEditorProps, "ref"> & default_2.RefAttributes<ICellEditorElement>>;
161
143
 
162
144
  /**
163
145
  * Default cell component capable of rendering a value
164
146
  * @param props
165
147
  */
166
- export declare const DefaultCellRenderer: default_2.FC<CellRendererProps>;
148
+ export declare const DefaultCellRenderer: default_2.MemoExoticComponent<(props: CellRendererProps) => JSX.Element>;
167
149
 
168
- export declare const DefaultHeaderDivider: default_2.FC<HeaderDividerRendererProps & {
169
- ref?: default_2.Ref<IHeaderDividerElement>;
170
- }>;
150
+ export declare const DefaultHeaderDivider: default_2.NamedExoticComponent<Omit<HeaderDividerRendererProps, "ref"> & default_2.RefAttributes<IHeaderDividerElement>>;
171
151
 
172
152
  export declare const defaultSelectionRenderer: (props: SelectionProps) => JSX.Element;
173
153
 
@@ -219,11 +199,14 @@ export declare interface EditState<CT, DT> {
219
199
  /**
220
200
  * Fill handle component
221
201
  */
222
- export declare const FillHandle: default_2.FC<FillHandleProps & FillHandleRefAttribute>;
202
+ export declare const FillHandle: default_2.NamedExoticComponent<Omit<FillHandleProps, "ref"> & default_2.RefAttributes<FillHandleElement>>;
223
203
 
224
204
  export declare interface FillHandleAttributes {
225
205
  }
226
206
 
207
+ export declare interface FillHandleElement extends HTMLDivElement, FillHandleAttributes {
208
+ }
209
+
227
210
  export declare interface FillHandleProps extends default_2.HTMLAttributes<HTMLDivElement> {
228
211
  corner?: string;
229
212
  x?: number;
@@ -232,11 +215,11 @@ export declare interface FillHandleProps extends default_2.HTMLAttributes<HTMLDi
232
215
  borderWidth?: number;
233
216
  borderStroke?: string;
234
217
  background?: string;
235
- }
236
-
237
- export declare type FillHandleRefAttribute = {
218
+ /**
219
+ * Underlying element reference
220
+ */
238
221
  ref?: default_2.Ref<FillHandleAttributes>;
239
- };
222
+ }
240
223
 
241
224
  export declare interface FrozenEdge {
242
225
  /**
@@ -251,66 +234,7 @@ export declare interface FrozenEdge {
251
234
 
252
235
  export declare const getDefaultStringEditState: (clean?: string) => EditState<string, string> | undefined;
253
236
 
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
- }
237
+ export declare const Grid: default_2.NamedExoticComponent<GridProps & default_2.RefAttributes<IGridElement>>;
314
238
 
315
239
  export declare interface GridHeaderStyle extends GridSurfaceStyle {
316
240
  strokeFillShadow?: string;
@@ -525,14 +449,6 @@ export declare interface GridProps extends default_2.HTMLAttributes<HTMLDivEleme
525
449
  clipCells?: boolean;
526
450
  }
527
451
 
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
452
  export declare interface GridStyle extends GridSurfaceStyle {
537
453
  body?: GridSurfaceStyle;
538
454
  selection?: SelectionStyle;
@@ -752,9 +668,6 @@ export declare interface HeaderDividerAnchorProps extends HeaderDividerProps {
752
668
  onDividerAutoFit?: (index: number) => void;
753
669
  }
754
670
 
755
- export declare interface HeaderDividerAttributes {
756
- }
757
-
758
671
  /**
759
672
  * HeaderDividers follow the header
760
673
  * // TODO - allow negative resizing (before the current) (easy to do I think)
@@ -800,6 +713,10 @@ export declare interface HeaderDividerProps extends default_2.HTMLAttributes<HTM
800
713
  headerStyleSelect: GridHeaderStyle;
801
714
  headerStyleSelectAll: GridHeaderStyle;
802
715
  headerStyleHover?: GridHeaderStyle | ((style: GridHeaderStyle) => GridHeaderStyle);
716
+ /**
717
+ * The reference to the element.
718
+ */
719
+ ref?: default_2.Ref<IHeaderDividerElement>;
803
720
  }
804
721
 
805
722
  export declare interface HeaderDividerRendererProps extends HeaderDividerProps {
@@ -811,7 +728,7 @@ export declare interface HeaderDividerRendererProps extends HeaderDividerProps {
811
728
  onAutoFit: () => void;
812
729
  }
813
730
 
814
- export declare const HeaderRenderer: default_2.FC<HeaderRendererCellProps>;
731
+ export declare const HeaderRenderer: default_2.MemoExoticComponent<(props: HeaderRendererCellProps) => JSX.Element>;
815
732
 
816
733
  export declare interface HeaderRendererCellProps extends CellRendererProps {
817
734
  orientation: RangeOrientation;
@@ -840,16 +757,101 @@ export declare interface HeaderSelectionResults {
840
757
  getCellCoordsFromClient: (x: number, y: number) => CellCoords;
841
758
  }
842
759
 
843
- export declare interface ICellEditorElement extends HTMLDivElement, CellEditorAttributes {
760
+ export declare type ICellEditorAttributes = {
761
+ /**
762
+ * When editor is loaded, this will be called. Note this should not use the autoFocus property. here
763
+ * If this is set the editor focus will be called as appropriate.
764
+ */
765
+ startEdit?(event: StartEditEvent): void;
766
+ submitEdit(): boolean;
767
+ cancelEdit(): void;
768
+ /**
769
+ * Called if the StartEditEvent event has autoFocus set.
770
+ * @param selector A selector string (or empty means 'default' focus)
771
+ */
772
+ autoFocus(selector?: string): void;
773
+ /**
774
+ * Returns the default line height.
775
+ */
776
+ getLineHeight: () => number;
777
+ };
778
+
779
+ export declare interface ICellEditorElement extends HTMLDivElement, ICellEditorAttributes {
780
+ }
781
+
782
+ export declare interface IGridAttributes {
783
+ /**
784
+ * The stage element for the cells
785
+ */
786
+ readonly stage: HTMLDivElement | null;
787
+ /**
788
+ * The rowCount provided by the properties
789
+ */
790
+ readonly rowCount: number;
791
+ /**
792
+ * The columnCount provided by the properties
793
+ */
794
+ readonly columnCount: number;
795
+ /**
796
+ * Invalidate either a cell or a range of cells. If no arguments are provided then the entire grid is invalidated.
797
+ * @param coords
798
+ */
799
+ invalidate: (coords?: CellCoords | RangeCoords) => void;
800
+ handleWheel: (event: globalThis.WheelEvent) => void;
801
+ getScrollPosition: () => TopLeft;
802
+ getViewport: () => RangeCoords;
803
+ getDimensions: () => {
804
+ containerWidth: number;
805
+ containerHeight: number;
806
+ totalWidth: number;
807
+ totalHeight: number;
808
+ };
809
+ /**
810
+ * Scroll the cell into view. If the coord does not have an index it will only scroll in a single direction.
811
+ */
812
+ scrollCellCoordsIntoView: (coords: Partial<CellCoords>, options?: globalThis.ScrollIntoViewOptions | boolean) => Promise<Partial<TopLeft>>;
813
+ /**
814
+ * The grid coordinates relative to the containing div (includes any padding, margins)
815
+ */
816
+ getRelativePointFromClient: (x: number, y: number) => Point | null;
817
+ /**
818
+ * Returns the view for the given point. If point is
819
+ * over a frozen pane it will return the frozen pane otherwise
820
+ * it will return the center view.
821
+ */
822
+ getViewFromClient: (x: number, y: number) => GridView;
823
+ /**
824
+ * Returns the view for the given coords. If coord is
825
+ * over a frozen pane it will return the frozen pane otherwise
826
+ * it will return the center view.
827
+ */
828
+ getViewFromCellCoords: (coords: CellCoords) => GridView;
829
+ /**
830
+ * Returns null if the view does not exist.
831
+ */
832
+ getViewFromLocation: (anchor: AnchorLocation) => GridView | null;
833
+ /**
834
+ * Called when the view has been changed.
835
+ * @remarks
836
+ * This is only called once.
837
+ */
838
+ onViewChangeOnce: (callback: () => void) => void;
839
+ /**
840
+ * Reference to the underlying element
841
+ */
842
+ ref?: default_2.Ref<HTMLDivElement>;
844
843
  }
845
844
 
846
845
  /**
847
846
  * Type returned via ref property
848
847
  */
849
- export declare interface IGridElement extends HTMLDivElement, GridAttributes {
848
+ export declare interface IGridElement extends HTMLDivElement, IGridAttributes {
849
+ }
850
+
851
+ export declare interface IHeaderDividerAttributes {
850
852
  }
851
853
 
852
- export declare interface IHeaderDividerElement extends HTMLDivElement, HeaderDividerAttributes {
854
+ export declare interface IHeaderDividerElement extends HTMLDivElement, IHeaderDividerAttributes {
853
855
  }
854
856
 
855
857
  export declare interface LineProps extends default_2.SVGProps<SVGSVGElement> {
@@ -885,7 +887,7 @@ export declare const safeSelectionCoords: (prev?: SelectionCoords) => SelectionC
885
887
  /**
886
888
  * ScrollableGrid. This wraps BaseGrid and manages bounds to create consistent css behavior for consumers
887
889
  */
888
- export declare const ScrollableGrid: default_2.FC<ScrollableGridProps & ScrollableRefAttribute>;
890
+ export declare const ScrollableGrid: default_2.NamedExoticComponent<Omit<ScrollableGridProps, "ref"> & default_2.RefAttributes<IGridElement>>;
889
891
 
890
892
  export declare interface ScrollableGridProps extends GridProps, ScrollPaneProps {
891
893
  /**
@@ -893,12 +895,12 @@ export declare interface ScrollableGridProps extends GridProps, ScrollPaneProps
893
895
  * @param scrollPoint
894
896
  */
895
897
  onScrollViewport?: (scrollPoint: Partial<TopLeft>) => void;
898
+ /**
899
+ * Ref for the HTMLDivElement
900
+ */
901
+ ref?: default_2.Ref<IGridElement | IScrollPaneElement | any>;
896
902
  }
897
903
 
898
- export declare type ScrollableRefAttribute = {
899
- ref?: default_2.Ref<IGridElement | IScrollPaneElement>;
900
- };
901
-
902
904
  declare const Selection_2: default_2.FC<SelectionProps>;
903
905
  export { Selection_2 as Selection }
904
906
 
@@ -1063,7 +1065,7 @@ export declare interface TextStyle extends PaintStyle {
1063
1065
  /**
1064
1066
  * TouchSelectHandle component
1065
1067
  */
1066
- export declare const TouchSelectHandle: default_2.NamedExoticComponent<TouchSelectHandleProps & default_2.RefAttributes<TouchSelectHandleElement>>;
1068
+ export declare const TouchSelectHandle: default_2.NamedExoticComponent<Omit<TouchSelectHandleProps, "ref"> & default_2.RefAttributes<TouchSelectHandleElement>>;
1067
1069
 
1068
1070
  export declare interface TouchSelectHandleAttributes {
1069
1071
  }
@@ -1102,15 +1104,15 @@ export declare interface TouchSelectHandleProps extends default_2.HTMLAttributes
1102
1104
  * @defaultValue document.body
1103
1105
  */
1104
1106
  scrollableRoot?: HTMLElement;
1105
- }
1106
-
1107
- export declare type TouchSelectHandleRefAttribute = {
1107
+ /**
1108
+ * Reference to the underling element
1109
+ */
1108
1110
  ref?: default_2.Ref<TouchSelectHandleElement>;
1109
- };
1110
-
1111
- export declare interface TouchSelectHandleRefProps extends TouchSelectHandleProps, TouchSelectHandleRefAttribute {
1112
1111
  }
1113
1112
 
1113
+ /**
1114
+ * Hook to manage cell layout
1115
+ */
1114
1116
  export declare const useCellLayout: (props: UseCellLayoutProps | null) => CellLayout;
1115
1117
 
1116
1118
  export declare interface UseCellLayoutProps {
@@ -1260,7 +1262,7 @@ export declare interface useKeyboardEditorOverlayOptions {
1260
1262
  * This should not return null but rather can canEdit.
1261
1263
  * This is called during placement after scrolling and other bookkeeping has occurred
1262
1264
  */
1263
- getCellEditor: (props: CellEditorProps<any, any> & CellEditorRefAttribute, coords: CellCoords) => default_2.ReactElement<CellEditorProps<any, any> & CellEditorRefAttribute>;
1265
+ getCellEditor: (props: CellEditorProps<any, any>, coords: CellCoords) => default_2.ReactElement<CellEditorProps<any, any>>;
1264
1266
  /**
1265
1267
  * Callback fired before editing. Can be used to prevent editing.
1266
1268
  */
@@ -1307,6 +1309,9 @@ export declare interface useKeyboardEditorOverlayOptions {
1307
1309
  alignment?: HorizontalAlignment;
1308
1310
  }
1309
1311
 
1312
+ /**
1313
+ * Hook to enable selection in grid
1314
+ */
1310
1315
  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
1316
 
1312
1317
  export declare interface UseSelectionOptions {