@sheetxl/grid-react 0.7.28-beta.2 → 0.7.28-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/cjs/index.cjs +2 -2
- package/browser/esm/index.mjs +766 -727
- package/node/esm/index.mjs +368 -329
- package/package.json +3 -3
- package/types/src/range/DragHandle.d.ts +8 -0
- package/types/src/range/Draggable.d.ts +12 -0
- package/types/src/range/FillHandle.d.ts +7 -0
- package/types/src/range/useDoubleClick.d.ts +19 -0
- package/types/src/selection/SelectionLayer.d.ts +17 -1
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.28-beta.
|
|
4
|
+
"version": "0.7.28-beta.3",
|
|
5
5
|
"license": "SEE LICENSE IN <LICENSE>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@floating-ui/react-dom": "^2.1.9",
|
|
45
|
-
"@sheetxl/utils": "^0.7.28-beta.
|
|
46
|
-
"@sheetxl/utils-react": "^0.7.28-beta.
|
|
45
|
+
"@sheetxl/utils": "^0.7.28-beta.3",
|
|
46
|
+
"@sheetxl/utils-react": "^0.7.28-beta.3",
|
|
47
47
|
"clsx": "^2.1.1",
|
|
48
48
|
"react-merge-refs": "^3.0.2",
|
|
49
49
|
"react-use": "^17.6.1",
|
|
@@ -23,6 +23,7 @@ export interface DragHandleRenderProps {
|
|
|
23
23
|
*/
|
|
24
24
|
handleProps: {
|
|
25
25
|
onPointerDown: (e: React.PointerEvent) => void;
|
|
26
|
+
onDoubleClick?: (e: React.MouseEvent) => void;
|
|
26
27
|
onPointerEnter?: (e: React.PointerEvent) => void;
|
|
27
28
|
onPointerLeave?: (e: React.PointerEvent) => void;
|
|
28
29
|
style: React.CSSProperties;
|
|
@@ -64,6 +65,13 @@ export interface DragHandleProps {
|
|
|
64
65
|
* applying it. Event-less — an Escape abort has no pointer event.
|
|
65
66
|
*/
|
|
66
67
|
onDragCancel?: () => void;
|
|
68
|
+
/**
|
|
69
|
+
* The handle was **double-clicked** — fired on the second press of the pair, which starts no drag.
|
|
70
|
+
*
|
|
71
|
+
* Timed from pointer-down, and the `dblclick` it leaves behind is suppressed — both by
|
|
72
|
+
* {@link useDoubleClick}, which explains why neither can come from the browser directly.
|
|
73
|
+
*/
|
|
74
|
+
onDoubleClick?: (e: React.MouseEvent) => void;
|
|
67
75
|
/** The pointer entered (`true`) / left (`false`) the handle — for a hover affordance on the host. */
|
|
68
76
|
onHoverChange?: (hovered: boolean) => void;
|
|
69
77
|
/**
|
|
@@ -64,7 +64,19 @@ export interface DraggableProps {
|
|
|
64
64
|
* so dragging a range doesn't blur the formula editor's textarea. @defaultValue false
|
|
65
65
|
*/
|
|
66
66
|
preserveFocus?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* A border of the range was **double-clicked**, reported with the edge that was hit. Excel's
|
|
69
|
+
* jump-to-the-end-of-the-data: the consumer decides where that edge leads (`getExtended`), since
|
|
70
|
+
* this layer holds no model.
|
|
71
|
+
*
|
|
72
|
+
* The double-click is consumed — the second press starts no move drag. Only meaningful with
|
|
73
|
+
* `grip: 'edges'`; with `grip: 'entire'` the whole rectangle is the grip and there is no edge to
|
|
74
|
+
* name, so the nearest one is still reported but rarely means anything.
|
|
75
|
+
*/
|
|
76
|
+
onEdgeDoubleClick?: (range: RangeCoords, edge: RangeEdge, e: React.PointerEvent) => void;
|
|
67
77
|
}
|
|
78
|
+
/** Which border of a range a gesture landed on. */
|
|
79
|
+
export type RangeEdge = 'top' | 'bottom' | 'left' | 'right';
|
|
68
80
|
/**
|
|
69
81
|
* A **"make draggable" wrapper**: it makes its `children` movable (translate — same size, new location)
|
|
70
82
|
* and reports the translated range via `onDrag*`. It owns ONLY the gesture (pointer-capture +
|
|
@@ -36,6 +36,13 @@ export interface FillHandleProps extends VisualSVGProps {
|
|
|
36
36
|
* Escape abort, hence the optional event.
|
|
37
37
|
*/
|
|
38
38
|
onDragDone?: (e?: React.PointerEvent) => void;
|
|
39
|
+
/**
|
|
40
|
+
* The handle was **double-clicked** — Excel's "ride the rails" fill, where the destination comes
|
|
41
|
+
* from the data flanking the template rather than from a drag. Reported as the template only: the
|
|
42
|
+
* destination is the consumer's to work out (`ICellRange.getExtended` with `basis: 'adjacent'`), since it is a question
|
|
43
|
+
* about the sheet's content and this layer holds no model.
|
|
44
|
+
*/
|
|
45
|
+
onDoubleClick?: (range: RangeCoords, e: React.MouseEvent) => void;
|
|
39
46
|
/**
|
|
40
47
|
* Render the fill handle **element** yourself (headless) — forwarded to {@link DragHandle.renderHandle}.
|
|
41
48
|
* Replaces the default dot. Use it for a custom fill mark (e.g. the Excel fill square).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Double-click detection for a grid gesture element, timed from its own `pointerdown`.
|
|
3
|
+
*
|
|
4
|
+
* The browser cannot simply be asked. `PointerEvent.detail` is always 0 — only `click`/`dblclick`
|
|
5
|
+
* carry a click count — and the compat `dblclick` never reaches the element either: the Stage offers
|
|
6
|
+
* that to the layers ABOVE it (the cell editor among them, by design) on the native capture phase,
|
|
7
|
+
* before the native dispatch reaches the element's own subtree. Pointer-down is the element's own
|
|
8
|
+
* event and arrives whatever sits over it.
|
|
9
|
+
*
|
|
10
|
+
* So the pair is timed here, and the `dblclick` it goes on to produce is swallowed on the `window`'s
|
|
11
|
+
* capture phase — which runs ahead of the Stage's — so the layers above do not act on it as well.
|
|
12
|
+
*
|
|
13
|
+
* @param enabled Whether to detect at all; `false` makes the filter a no-op (there is no consumer,
|
|
14
|
+
* so a pair should stay two ordinary presses).
|
|
15
|
+
* @returns A `pointerdown` filter. `true` means the press completed a pair and has been consumed —
|
|
16
|
+
* the caller must not start its drag; `false` means carry on as normal.
|
|
17
|
+
*/
|
|
18
|
+
export declare const useDoubleClick: (enabled: boolean) => ((e: React.PointerEvent) => boolean);
|
|
19
|
+
//# sourceMappingURL=useDoubleClick.d.ts.map
|
|
@@ -2,6 +2,7 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { CellCoords, RangeCoords } from '@sheetxl/utils';
|
|
3
3
|
import { LayerProps, GridPlacement } from '../layer';
|
|
4
4
|
import { VisualSVGProps } from '../svg';
|
|
5
|
+
import { RangeEdge } from '../range';
|
|
5
6
|
import { ISelection } from './ISelection';
|
|
6
7
|
import { SelectionNavigation } from './Types';
|
|
7
8
|
import { SelectionRangeStyle } from './SelectionStyle';
|
|
@@ -112,7 +113,7 @@ export interface SelectionLayerProps extends LayerProps {
|
|
|
112
113
|
* the filled range (which includes the template). The selection extends to `destination` automatically;
|
|
113
114
|
* use this for the data side-effect (the actual fill).
|
|
114
115
|
*/
|
|
115
|
-
onFill?: (template: RangeCoords, destination: RangeCoords, e: React.
|
|
116
|
+
onFill?: (template: RangeCoords, destination: RangeCoords, e: React.MouseEvent) => void;
|
|
116
117
|
/**
|
|
117
118
|
* Adjust the raw fill destination before it drives the preview + fill callbacks — e.g. snap the fill
|
|
118
119
|
* edge to a merged-cell boundary so the dashed preview and the committed fill agree and never land on
|
|
@@ -132,6 +133,21 @@ export interface SelectionLayerProps extends LayerProps {
|
|
|
132
133
|
* anything {@link SelectionLayerProps.onFillPreview} set (e.g. closing the preview tooltip).
|
|
133
134
|
*/
|
|
134
135
|
onFillEnd?: () => void;
|
|
136
|
+
/**
|
|
137
|
+
* Resolve the destination for a **double-clicked** fill handle — Excel's "ride the rails" fill,
|
|
138
|
+
* whose extent comes from the data flanking the template rather than from a drag. Return the
|
|
139
|
+
* destination (which must include the template) or `null` for no fill; omit to leave double-click
|
|
140
|
+
* inert. Injected rather than computed here because it is a question about the sheet's content
|
|
141
|
+
* and this layer holds no model — `ICellRange.getExtended` with `basis: 'adjacent'` answers it. The result then takes
|
|
142
|
+
* the same path a drag release does, {@link SelectionLayerProps.onFill} included.
|
|
143
|
+
*/
|
|
144
|
+
resolveFillExtent?: (template: RangeCoords) => RangeCoords | null;
|
|
145
|
+
/**
|
|
146
|
+
* A border of the selection was **double-clicked**, reported with the edge that was hit — Excel's
|
|
147
|
+
* jump to the end of the data in that direction. Where it lands is the consumer's to decide
|
|
148
|
+
* (`ICellRange.getExtended`), as this layer holds no model; omit to leave the gesture inert.
|
|
149
|
+
*/
|
|
150
|
+
onEdgeDoubleClick?: (range: RangeCoords, edge: RangeEdge, e: React.PointerEvent) => void;
|
|
135
151
|
/**
|
|
136
152
|
* Fired when a selection pointer interaction ends (click/drag settled) — "act on the just-selected
|
|
137
153
|
* range" (e.g. the format painter applies the copied format to the new selection). See
|