@sheetxl/grid-react 0.8.0-beta.11 → 0.8.0-beta.13
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/README.md +4 -2
- package/browser/esm/index.mjs +1383 -1314
- package/node/esm/index.mjs +1491 -1422
- package/package.json +3 -3
- package/types/src/cell/CellRenderer.d.ts +32 -0
- package/types/src/grid/Grid.d.ts +1 -1
- package/types/src/grid/IGrid.d.ts +4 -4
- package/types/src/header/HeaderDividerAnchor.d.ts +7 -1
- package/types/src/layer/RangeFloatLayer.d.ts +6 -1
- package/types/src/layer/RangeTooltip.d.ts +5 -0
- package/types/src/layer/RangeTooltipLayer.d.ts +1 -1
- package/types/src/layer/TooltipProvider.d.ts +10 -7
- package/types/src/layer/_Utils.d.ts +2 -0
- package/types/src/layer/useHoverIntent.d.ts +3 -3
- package/types/src/list/CheckboxList.d.ts +7 -1
- package/types/src/list/PickList.d.ts +6 -1
- package/types/src/range/Draggable.d.ts +7 -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.8.0-beta.
|
|
4
|
+
"version": "0.8.0-beta.13",
|
|
5
5
|
"license": "SEE LICENSE IN <LICENSE>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"table"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@sheetxl/utils": "^0.8.0-beta.
|
|
44
|
-
"@sheetxl/utils-react": "^0.8.0-beta.
|
|
43
|
+
"@sheetxl/utils": "^0.8.0-beta.13",
|
|
44
|
+
"@sheetxl/utils-react": "^0.8.0-beta.13",
|
|
45
45
|
"clsx": "^2.1.1",
|
|
46
46
|
"react-merge-refs": "^3.0.2"
|
|
47
47
|
},
|
|
@@ -50,4 +50,36 @@ export interface CellRendererProps<T = any> extends React.HTMLAttributes<HTMLEle
|
|
|
50
50
|
*/
|
|
51
51
|
'data-rc'?: string;
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* The attribute that marks cell content as **interactive**: an element a rendered cell draws that
|
|
55
|
+
* takes the pointer itself (a checkbox, a button, a slider's thumb). Spread
|
|
56
|
+
* {@link CELL_INTERACTIVE_PROPS} onto that element rather than writing the attribute by hand.
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* A rendered cell is `pointer-events: none`, and the selection layer above the cells starts a
|
|
60
|
+
* gesture on every press, so without this nothing drawn in a cell can take a press. A primary
|
|
61
|
+
* press on a marked element selects its cell and starts no drag; the event then reaches the
|
|
62
|
+
* element's own handlers, which decide what the press does (and stop it, so nothing below acts).
|
|
63
|
+
* A press with a modifier (Shift, Ctrl) is a selection press as usual. Layers above the selection
|
|
64
|
+
* still hear the press first.
|
|
65
|
+
*/
|
|
66
|
+
export declare const CELL_INTERACTIVE_ATTRIBUTE = "data-cell-interactive";
|
|
67
|
+
/**
|
|
68
|
+
* The props that make an element of cell content interactive ({@link CELL_INTERACTIVE_ATTRIBUTE}):
|
|
69
|
+
* spread them onto the element that takes the pointer, then add its handlers (`onPointerDown`,
|
|
70
|
+
* `onPointerMove`, …) as on any element. The cell layer gives it `pointer-events: auto`; a drag
|
|
71
|
+
* captures the pointer on the element itself (`setPointerCapture`), as the Stage honors capture.
|
|
72
|
+
*/
|
|
73
|
+
export declare const CELL_INTERACTIVE_PROPS: Readonly<Record<string, string>>;
|
|
74
|
+
/**
|
|
75
|
+
* Whether `target` is, or is inside, interactive cell content ({@link CELL_INTERACTIVE_ATTRIBUTE}).
|
|
76
|
+
*/
|
|
77
|
+
export declare const isCellInteractiveTarget: (target: EventTarget | null) => boolean;
|
|
78
|
+
/**
|
|
79
|
+
* The cell the interactive content under `target` belongs to, read from the layer's `data-rc`
|
|
80
|
+
* stamp on the content's cell root, or `null` when `target` is not interactive content or the
|
|
81
|
+
* content carries no stamp. Content can reach past its cell (overflowing link text), so a press
|
|
82
|
+
* on it is about the content's cell, not the cell under the pointer.
|
|
83
|
+
*/
|
|
84
|
+
export declare const getCellInteractiveCoords: (target: EventTarget | null) => CellCoords | null;
|
|
53
85
|
//# sourceMappingURL=CellRenderer.d.ts.map
|
package/types/src/grid/Grid.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { GridProps, IGrid } from './IGrid';
|
|
|
3
3
|
/**
|
|
4
4
|
* A virtualized grid: a thin wrapper around {@link GridSurface} that re-adds the cell + gridline
|
|
5
5
|
* rendering the surface itself is agnostic to. It composes a `CellLayer` (cells), a `GridlineLayer`
|
|
6
|
-
* (gridlines) and an optional `
|
|
6
|
+
* (gridlines) and an optional `borderLayers` slot as ordinary layers — in the conventional z-order
|
|
7
7
|
* (gridlines → borders → below-layers → cells → above-layers) — and owns the content cache token the
|
|
8
8
|
* cells bust on. Everything else is forwarded to the surface.
|
|
9
9
|
*
|
|
@@ -36,13 +36,13 @@ export interface GridProps extends GridSurfaceProps {
|
|
|
36
36
|
* Layer(s) rendered BELOW the cells/borders (but above the gridlines) — the place for fills and
|
|
37
37
|
* highlights. The `children` are the layers ABOVE the cells/borders.
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
layersBelow?: LayerNode;
|
|
40
40
|
/**
|
|
41
|
-
* Optional border layer(s), rendered just below the cells (above {@link GridProps.
|
|
42
|
-
* gridlines)
|
|
41
|
+
* Optional border layer(s), rendered just below the cells (above {@link GridProps.layersBelow} /
|
|
42
|
+
* gridlines), for a custom border treatment — distinct from the light
|
|
43
43
|
* {@link GridProps.showGridLines} gridlines.
|
|
44
44
|
*/
|
|
45
|
-
|
|
45
|
+
borderLayers?: LayerNode;
|
|
46
46
|
/**
|
|
47
47
|
* Show grid lines. Useful for spreadsheets.
|
|
48
48
|
*/
|
|
@@ -56,6 +56,8 @@ export interface IHeaderDividerAttributes {
|
|
|
56
56
|
export interface IHeaderDividerElement extends HTMLDivElement, IHeaderDividerAttributes {
|
|
57
57
|
}
|
|
58
58
|
export interface HeaderDividerRendererProps extends HeaderDividerProps {
|
|
59
|
+
/** The pane the divider is drawn in. */
|
|
60
|
+
pane: IGridPane;
|
|
59
61
|
/**
|
|
60
62
|
* The divider's line in pane coordinates — zero-width for a column divider, zero-height for a row —
|
|
61
63
|
* snapped to the device pixel the gridline paints. The renderer positions its element (hit area and
|
|
@@ -76,7 +78,7 @@ export interface HeaderDividerRendererProps extends HeaderDividerProps {
|
|
|
76
78
|
isActive?: boolean;
|
|
77
79
|
}
|
|
78
80
|
export interface HeaderDividerAnchorProps extends HeaderDividerProps {
|
|
79
|
-
renderDivider?: (props: HeaderDividerRendererProps
|
|
81
|
+
renderDivider?: (props: HeaderDividerRendererProps) => React.ReactNode;
|
|
80
82
|
/**
|
|
81
83
|
* The clipped bounds of the pane's visible headers, from {@link getHeaderDividerBounds}. Computed when
|
|
82
84
|
* omitted; pass it when rendering a pane's worth of dividers so it is computed once.
|
|
@@ -135,6 +137,10 @@ export interface HeaderDividerAnchorProps extends HeaderDividerProps {
|
|
|
135
137
|
*/
|
|
136
138
|
onDividerUnhide?: (index: number) => void;
|
|
137
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* The class on the default divider's root element, for styling and for finding dividers in the DOM.
|
|
142
|
+
*/
|
|
143
|
+
export declare const HEADER_DIVIDER_CLASS = "header-divider";
|
|
138
144
|
export declare const DefaultHeaderDivider: import('react').NamedExoticComponent<Omit<HeaderDividerRendererProps, "ref"> & import('react').RefAttributes<IHeaderDividerElement>>;
|
|
139
145
|
/**
|
|
140
146
|
* A divider placed between headers to provider a visual cue for various actions.
|
|
@@ -108,7 +108,7 @@ export interface RangeFloatOptions<T = unknown> {
|
|
|
108
108
|
/** Grace (ms) before a hovered float hides (bridges the gap to the float). @defaultValue the group's `leaveDelay` (400) */
|
|
109
109
|
closeDelay?: number;
|
|
110
110
|
/**
|
|
111
|
-
* A hovered float joins the grid's tooltip group (one tip at a time, closed by
|
|
111
|
+
* A hovered float joins the grid's tooltip group (one tip at a time, closed by a press outside it or Escape).
|
|
112
112
|
* `false` for a hover-opened float that is not a tooltip — a toolbar — which must survive a tip
|
|
113
113
|
* opening beside it and a press on its own buttons.
|
|
114
114
|
* @defaultValue true
|
|
@@ -202,6 +202,11 @@ export interface RangeFloatLayerProps<T = unknown> extends Omit<LayerProps, 'chi
|
|
|
202
202
|
* selection — the layer only ever reads the active cell and subscribes to it.
|
|
203
203
|
*/
|
|
204
204
|
selection?: ICellAnchor;
|
|
205
|
+
/**
|
|
206
|
+
* What the pointer is over that the cells cannot tell the tap: something drawn above them, which
|
|
207
|
+
* takes the pointer first. Wins over the probed cell while it is set.
|
|
208
|
+
*/
|
|
209
|
+
hoveredOver?: RangeFloatTarget<T> | null;
|
|
205
210
|
}
|
|
206
211
|
/**
|
|
207
212
|
* The **range float layer**: a {@link VirtualRangeFloat} as a layer of its own, whose tap probes the
|
|
@@ -113,6 +113,11 @@ export declare const RangeTooltipProvider: React.FC<RangeTooltipProviderProps>;
|
|
|
113
113
|
export declare const RangeTooltip: (props: RangeTooltipProps) => null;
|
|
114
114
|
export interface RangeTooltipHostProps extends Omit<LayerProps, 'children'> {
|
|
115
115
|
className?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Close the open tip and open no other while this holds, for whatever reason the host's owner has
|
|
118
|
+
* (the cell under the pointer is being edited, say).
|
|
119
|
+
*/
|
|
120
|
+
dismiss?: boolean;
|
|
116
121
|
}
|
|
117
122
|
/**
|
|
118
123
|
* The layer that draws the {@link RangeTooltip}s of the nearest {@link RangeTooltipProvider}: one tap,
|
|
@@ -42,7 +42,7 @@ export interface RangeTooltipLayerProps<T = unknown> extends Omit<RangeFloatLaye
|
|
|
42
42
|
* The **tooltip kind** of range float: transient, opened by hovering a cell the probe recognizes, one
|
|
43
43
|
* at a time grid-wide. A preset of {@link RangeFloatLayer} (`activateOn: 'hover'`) whose hover intent is
|
|
44
44
|
* the tooltip group's client — so it inherits the group's timing, single-open rule, armed re-open, and
|
|
45
|
-
* closes on
|
|
45
|
+
* closes on a press outside it or Escape — drawn in the group's bubble, under any menu.
|
|
46
46
|
*
|
|
47
47
|
* @remarks
|
|
48
48
|
* Reach for `RangeFloatLayer` directly when the float is activated by the selection, driven by a
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { RenderSlotFn } from '@sheetxl/utils-react';
|
|
2
3
|
import { GridPlacement } from './useGridAnchor';
|
|
3
4
|
import { HoverTipProps } from './useHoverIntent';
|
|
4
5
|
/**
|
|
@@ -29,7 +30,7 @@ export interface TooltipRenderProps {
|
|
|
29
30
|
style?: React.CSSProperties;
|
|
30
31
|
}
|
|
31
32
|
/** The bubble around a tip's content — the host's chrome, arrow and theme. */
|
|
32
|
-
export type RenderTooltip =
|
|
33
|
+
export type RenderTooltip = RenderSlotFn<TooltipRenderProps>;
|
|
33
34
|
/**
|
|
34
35
|
* A tip registered with its {@link TooltipGroup}. One per `useHoverIntent`; the per-pane copies of a
|
|
35
36
|
* layer share a `key`, so they count as one tip.
|
|
@@ -39,19 +40,21 @@ export interface TooltipClient {
|
|
|
39
40
|
readonly key: string;
|
|
40
41
|
/**
|
|
41
42
|
* A gesture tip holds the group: hover tips may not open while it is up. It is not closed by a press
|
|
42
|
-
* or
|
|
43
|
+
* or Escape, and its close does not arm the group.
|
|
43
44
|
*/
|
|
44
45
|
readonly gesture: boolean;
|
|
45
46
|
/** The tip's element once mounted — a pointerdown inside it does not close it. */
|
|
46
47
|
getElement(): Element | null;
|
|
47
|
-
/** Close now, no grace (the group took the slot, or the user pressed
|
|
48
|
+
/** Close now, no grace (the group took the slot, or the user pressed elsewhere or hit Escape). */
|
|
48
49
|
forceClose(): void;
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
52
|
* The single-open coordinator: at most one tip (by key) is up at a time, the next open is fast for
|
|
52
|
-
* {@link TooltipTiming.armedFor} after a close, a gesture tip preempts hover, and
|
|
53
|
-
*
|
|
54
|
-
*
|
|
53
|
+
* {@link TooltipTiming.armedFor} after a close, a gesture tip preempts hover, and a pointerdown outside
|
|
54
|
+
* an open hover tip or Escape closes it (a gesture tip closes with its gesture). No other key and no
|
|
55
|
+
* selection change closes a tip; a layer's owner closes one for its own reasons through `dismiss`. Owned
|
|
56
|
+
* by the top {@link TooltipProvider} (or one that `isolate`s); a built-in default serves a tree with no
|
|
57
|
+
* provider.
|
|
55
58
|
*/
|
|
56
59
|
export interface TooltipGroup {
|
|
57
60
|
/** `client` is opening: every client open on another key closes first, with no grace. */
|
|
@@ -97,5 +100,5 @@ export interface TooltipProviderProps {
|
|
|
97
100
|
*/
|
|
98
101
|
export declare const TooltipProvider: React.FC<TooltipProviderProps>;
|
|
99
102
|
/** The grid's default bubble — used when no provider supplies `renderTooltip`. */
|
|
100
|
-
export declare const
|
|
103
|
+
export declare const defaultRenderTooltip: RenderTooltip;
|
|
101
104
|
//# sourceMappingURL=TooltipProvider.d.ts.map
|
|
@@ -2,6 +2,8 @@ import { RangeCoords } from '@sheetxl/utils';
|
|
|
2
2
|
import { LayerNode } from './LayerTypes';
|
|
3
3
|
/** Content key for a range — stable across object identity (dedupe / memo / hover-target keys). */
|
|
4
4
|
export declare const rangeKey: (r: RangeCoords) => string;
|
|
5
|
+
/** Where a cell's hover tip stacks: over the grid's other floats, and under any menu. */
|
|
6
|
+
export declare const GRID_TIP_Z_INDEX: string;
|
|
5
7
|
/**
|
|
6
8
|
* A layer's **derived stacking order** — its index in the normalized layer list, i.e. the react list
|
|
7
9
|
* order with explicit-`zIndex` overrides already folded in (see {@link normalizeLayers}). This is the
|
|
@@ -13,8 +13,8 @@ export interface UseHoverIntentOptions {
|
|
|
13
13
|
*/
|
|
14
14
|
closeDelay?: number;
|
|
15
15
|
/**
|
|
16
|
-
* Join the grid's tooltip group: one tip open at a time, a fast re-open while armed, closed by
|
|
17
|
-
* pointerdown or
|
|
16
|
+
* Join the grid's tooltip group: one tip open at a time, a fast re-open while armed, closed by a
|
|
17
|
+
* pointerdown outside it or Escape, refused while a gesture tip or a popup is up. `false` for a hover-opened float that is not
|
|
18
18
|
* a tooltip — a table toolbar, a note's box — which must survive a tip opening beside it.
|
|
19
19
|
* @defaultValue true
|
|
20
20
|
*/
|
|
@@ -65,7 +65,7 @@ export interface UseHoverIntentResult {
|
|
|
65
65
|
/**
|
|
66
66
|
* The **hover-intent state machine** behind a tip — the per-tip client of the grid's tooltip group
|
|
67
67
|
* ({@link TooltipProvider}): dwell / grace timing, keep-open-on-tip-hover, and the group's rules
|
|
68
|
-
* (single open, armed re-open, gesture
|
|
68
|
+
* (single open, armed re-open, gesture and popup preempt hover, closed by a press outside it or Escape). It does NO
|
|
69
69
|
* hit-testing: feed it a target key via {@link UseHoverIntentResult.setTarget} (`null` = nothing) and
|
|
70
70
|
* spread {@link UseHoverIntentResult.tipProps} on the float.
|
|
71
71
|
*
|
|
@@ -15,6 +15,12 @@ export interface ICheckboxListElement extends HTMLDivElement, CheckboxListAttrib
|
|
|
15
15
|
/**
|
|
16
16
|
* Props for {@link CheckboxList}.
|
|
17
17
|
*/
|
|
18
|
+
/** What {@link CheckboxListProps.renderCheckbox} is handed. */
|
|
19
|
+
export interface CheckboxRenderProps {
|
|
20
|
+
checked: boolean;
|
|
21
|
+
/** Set for the `(Select All)` tri-state when only some rows are checked. */
|
|
22
|
+
indeterminate?: boolean;
|
|
23
|
+
}
|
|
18
24
|
export interface CheckboxListProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
19
25
|
/** Number of rows. */
|
|
20
26
|
itemCount: number;
|
|
@@ -37,7 +43,7 @@ export interface CheckboxListProps extends React.HTMLAttributes<HTMLDivElement>
|
|
|
37
43
|
* `pointerEvents:none`). `indeterminate` is set for the `(Select All)` tri-state. Override to use a
|
|
38
44
|
* styled control (MUI etc.). @defaultValue a native checkbox.
|
|
39
45
|
*/
|
|
40
|
-
renderCheckbox?: (
|
|
46
|
+
renderCheckbox?: (props: CheckboxRenderProps) => React.ReactNode;
|
|
41
47
|
/**
|
|
42
48
|
* Render a divider between the `(Select All)` header and the list, or elsewhere as needed.
|
|
43
49
|
*/
|
|
@@ -5,6 +5,11 @@ export interface PickListItem {
|
|
|
5
5
|
/** The row's text. */
|
|
6
6
|
text: string;
|
|
7
7
|
}
|
|
8
|
+
/** What {@link PickListProps.renderItem} is handed. */
|
|
9
|
+
export interface PickListItemRenderProps {
|
|
10
|
+
item: PickListItem;
|
|
11
|
+
index: number;
|
|
12
|
+
}
|
|
8
13
|
export interface PickListAttributes {
|
|
9
14
|
isPickList: () => true;
|
|
10
15
|
/** The highlighted row, or `-1` when the list is empty. */
|
|
@@ -47,7 +52,7 @@ export interface PickListProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
47
52
|
*/
|
|
48
53
|
measureText?: (text: string) => number;
|
|
49
54
|
/** Render a row's content. @defaultValue the text, clipped with an ellipsis. */
|
|
50
|
-
renderItem?: (
|
|
55
|
+
renderItem?: (props: PickListItemRenderProps) => React.ReactNode;
|
|
51
56
|
/** Take focus on mount, so the Arrow keys work without a click first. @defaultValue false */
|
|
52
57
|
autoFocus?: boolean;
|
|
53
58
|
/** The scroll state, when the caller owns it (see `ListSurfaceProps.viewport`). */
|
|
@@ -29,6 +29,12 @@ export interface DragInsert {
|
|
|
29
29
|
* the drop will DO, and no pointer event carries that. Read the modifiers from here, never off the
|
|
30
30
|
* event handed to the same callback (which is the last one the *pointer* fired).
|
|
31
31
|
*/
|
|
32
|
+
/** What {@link DraggableProps.renderMove} is handed. */
|
|
33
|
+
export interface DragMoveRenderProps {
|
|
34
|
+
/** The in-flight range. */
|
|
35
|
+
range: RangeCoords;
|
|
36
|
+
info: DragMoveInfo;
|
|
37
|
+
}
|
|
32
38
|
export interface DragMoveInfo {
|
|
33
39
|
/** The live Ctrl / Shift / Alt / Meta state (Excel: Ctrl = copy, Shift = insert). */
|
|
34
40
|
mods: DragModifiers;
|
|
@@ -169,7 +175,7 @@ export interface DraggableProps {
|
|
|
169
175
|
* `info` re-renders the preview on a modifier change, so the ghost can become an insert I-beam the
|
|
170
176
|
* moment Shift goes down.
|
|
171
177
|
*/
|
|
172
|
-
renderMove?: (
|
|
178
|
+
renderMove?: (props: DragMoveRenderProps) => React.ReactNode;
|
|
173
179
|
/**
|
|
174
180
|
* The cursor painted for the duration of the drag. The grip's element is pointer-captured, so ITS
|
|
175
181
|
* cursor is the one the browser shows once a drag is in flight — pass a mode-derived cursor (`copy`
|