@sheetxl/grid-react 0.8.0-beta.10 → 0.8.0-beta.11

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/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.10",
4
+ "version": "0.8.0-beta.11",
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.10",
44
- "@sheetxl/utils-react": "^0.8.0-beta.10",
43
+ "@sheetxl/utils": "^0.8.0-beta.11",
44
+ "@sheetxl/utils-react": "^0.8.0-beta.11",
45
45
  "clsx": "^2.1.1",
46
46
  "react-merge-refs": "^3.0.2"
47
47
  },
@@ -1,5 +1,6 @@
1
1
  import { default as React } from 'react';
2
- import { OrientationFlags } from '@sheetxl/utils';
2
+ import { RangeCoords, OrientationFlags } from '@sheetxl/utils';
3
+ import { IGridPane } from '../surface';
3
4
  import { LayerProps } from '../layer';
4
5
  import { CellModelOptions } from './_CellModel';
5
6
  /**
@@ -28,6 +29,43 @@ export interface GridlineLayerProps extends Omit<LayerProps, 'children'>, CellMo
28
29
  /** Per-`<path>` props for the vertical (column) lines. */
29
30
  propsColumns?: React.SVGProps<SVGPathElement>;
30
31
  }
32
+ /**
33
+ * Options for {@link buildGridlinePath}.
34
+ */
35
+ export interface GridlinePathOptions {
36
+ /**
37
+ * Stroke width in device pixels; decides how each line center snaps.
38
+ *
39
+ * @defaultValue 1
40
+ */
41
+ width?: number;
42
+ /**
43
+ * CSS px added to each line's cross-axis position before it snaps (an even-width stroke that
44
+ * grows toward the trailing side).
45
+ *
46
+ * @defaultValue 0
47
+ */
48
+ shift?: number;
49
+ /**
50
+ * More gaps for one line, as view-relative `[start0, end0, start1, end1, ...]` along the line,
51
+ * sorted by start. `trailIndex` is the row (horizontal) or column (vertical) whose trailing edge
52
+ * the line is.
53
+ */
54
+ breaksAt?: (trailIndex: number) => readonly number[] | undefined;
55
+ }
56
+ /**
57
+ * Build a single SVG path `d` for one orientation's gridlines — each line broken around the merged
58
+ * ranges that straddle it. ONE path with many `M…L…` subpaths (vs one `<path>` per segment) keeps the
59
+ * DOM to a single node per axis; the segment count changes every scroll tick, so per-segment elements
60
+ * would thrash the DOM. Device snapping is baked into each subpath's coordinates and the stroke width
61
+ * is uniform, so a single path renders identically to N separate paths at any dpr.
62
+ *
63
+ * @param pane The pane to draw for.
64
+ * @param isHorizontal `true` for the row lines, `false` for the column lines.
65
+ * @param ranges Index-space ranges the lines break around (merges, overflow).
66
+ * @param options See {@link GridlinePathOptions}.
67
+ */
68
+ export declare const buildGridlinePath: (pane: IGridPane, isHorizontal: boolean, ranges: readonly RangeCoords[], options?: GridlinePathOptions) => string;
31
69
  /**
32
70
  * A **layer** (pane-aware): paints the gridlines for its pane, broken around merged cells, inside a
33
71
  * single full-pane {@link Layer} host box. Sources the merge spans from the merges-only
@@ -10,7 +10,7 @@ import { EditSession, StartEditOptions, EditModel } from './EditSession';
10
10
  * @remarks
11
11
  * An implementation detail of {@link DefaultEditable}, not part of the layer-facing contract. Collapses
12
12
  * the former `getClean` + `canEdit` + `commit` (`null` ⇒ "not editable"). A story closes over a values
13
- * map; the real app reads an `ISheet` (and returns `null` for a protected cell).
13
+ * map; the real app reads an `IWorksheet` (and returns `null` for a protected cell).
14
14
  *
15
15
  * @typeParam C - clean type. @typeParam D - dirty type. @typeParam A - commit args.
16
16
  */
@@ -25,7 +25,7 @@ export type CreateEdit<C, D = string, A = EditCommitArgs> = (coords: CellCoords)
25
25
  * (`startEdit`/`commit`/`cancel`); an app-side bridge can publish {@link getSession} onto the edit-mode
26
26
  * bus on each `subscribe` notification. It does **not** vend sessions — there is only
27
27
  * ever one active edit, held here. {@link DefaultEditable} is the default implementation; the real app
28
- * supplies its own (or reuses it with an `ISheet`-backed {@link CreateEdit}).
28
+ * supplies its own (or reuses it with an `IWorksheet`-backed {@link CreateEdit}).
29
29
  *
30
30
  * @typeParam C - clean type. @typeParam D - dirty type. @typeParam A - commit args.
31
31
  */
@@ -55,8 +55,9 @@ export interface EditorDivProps<C, D = string, A = EditCommitArgs> {
55
55
  *
56
56
  * @remarks
57
57
  * Unlike the layer, this is **always visible** — while idle it shows {@link EditorDivProps.idleClean}
58
- * (the active cell). It never auto-grabs focus (`autoFocus: false`): the field is focused by the
59
- * user's click, so the in-grid editor and the formula bar don't fight over focus when an edit begins.
58
+ * (the active cell). It does not grab focus for an ordinary edit: the field is focused by the user's
59
+ * click, so the in-grid editor and the formula bar don't fight over focus when an edit begins. An edit
60
+ * whose session names this host as its active editor from the start is the exception: it opens here.
60
61
  */
61
62
  export declare function EditorDiv<C, D = string, A = EditCommitArgs>(props: EditorDivProps<C, D, A>): React.ReactElement;
62
63
  export declare namespace EditorDiv {
@@ -24,9 +24,10 @@ export interface EditorStartLayerProps<C, D = string, A = EditCommitArgs> {
24
24
  * Keys are positionless, so the floor position alone is not enough for them: a focused widget that
25
25
  * does not consume a printable key (it has no use for it, and must let keys through so its own
26
26
  * commands can resolve) would otherwise still reach this tap. The key start therefore acts only when
27
- * the key is aimed at the grid surface itself — the surface is the focused element — which is what
28
- * "the grid is in ready mode" means. A double-click needs no such guard: it has a position, and a
29
- * widget that owns that position consumes it.
27
+ * the key is aimed at the grid surface itself — the surface (or the pane's focus target, which
28
+ * stands in for it) is the focused element — which is what "the grid is in
29
+ * ready mode" means. A double-click needs no such guard: it has a position, and a widget that owns
30
+ * that position consumes it.
30
31
  */
31
32
  export declare function EditorStartLayer<C, D = string, A = EditCommitArgs>(props: EditorStartLayerProps<C, D, A>): React.ReactElement;
32
33
  //# sourceMappingURL=EditorStartLayer.d.ts.map
@@ -35,6 +35,8 @@ export interface GridPaneDef {
35
35
  rowIndex: number;
36
36
  elemStage: React.ReactNode;
37
37
  refStage: IStageElement | null;
38
+ /** See {@link IGridPane.registerFocusTarget}. */
39
+ focusTarget?: (() => HTMLElement | null) | null;
38
40
  scrollOrientation: OrientationFlags;
39
41
  insets: Rectangle;
40
42
  }
@@ -6,9 +6,22 @@ import { IGridMetrics } from '../metrics';
6
6
  */
7
7
  export interface IGridPane {
8
8
  /**
9
- * Sets focus to the view.
9
+ * Sets focus to the view: its surface, or its {@link getFocusTarget | focus target} when there is one.
10
10
  */
11
11
  focus(options?: FocusOptions): void;
12
+ /**
13
+ * Register a focus target: an element inside the pane that takes the pane's focus in place of its
14
+ * surface while `target` returns it. A key aimed at it is a key aimed at the surface. The latest
15
+ * registration wins.
16
+ *
17
+ * @param target Asked each time the pane is focused; `null` lets the surface take focus.
18
+ */
19
+ registerFocusTarget(target: () => HTMLElement | null): RemoveListener;
20
+ /**
21
+ * The element focusing the pane lands on in place of its surface right now, or `null` for the
22
+ * surface itself.
23
+ */
24
+ getFocusTarget(): HTMLElement | null;
12
25
  /**
13
26
  * Set pointer capture to the view.
14
27
  */
@@ -161,7 +174,7 @@ export interface IGridPane {
161
174
  * For the freeze STRUCTURE use {@link getAllPanes} — the `Top` / `Left` / `TopLeft` entries exist only
162
175
  * when frozen — and each frozen pane's {@link getPaneRange} is exactly its frozen cell band, so
163
176
  * `getPaneRange().colEnd + 1` / `.rowEnd + 1` gives the frozen column / row COUNT. The configured
164
- * freeze count as a model value lives on `ISheetView.getFreezePanes().coords`.
177
+ * freeze count as a model value lives on `IWorksheetView.getFreezePanes().coords`.
165
178
  */
166
179
  getFreezeTopLeft(): TopLeft;
167
180
  /**
@@ -36,7 +36,7 @@ export interface SurfaceStateProviderProps {
36
36
  *
37
37
  * 1. an explicit {@link SurfaceStateProviderProps.store} prop (override);
38
38
  * 2. a store **inherited** from an ancestor `SurfaceStateProvider` — so a wider parent (e.g. a
39
- * `SheetElement` wrapping its top-left corner + both header `GridSurface`s + the main `GridSurface`)
39
+ * `WorksheetElement` wrapping its top-left corner + both header `GridSurface`s + the main `GridSurface`)
40
40
  * shares one scope across sibling surfaces, letting a layer keyed the same in a header and in the body
41
41
  * read one cell;
42
42
  * 3. otherwise a **lazily-created own** store (the standalone default).
@@ -0,0 +1,13 @@
1
+ import { AnchorLocation } from '@sheetxl/utils';
2
+ import { IGridPane } from './IGridPane';
3
+ /**
4
+ * The pane to use when no particular pane is called for: the one that owns a once-per-grid job, or
5
+ * takes focus and scrolling with nothing else to go by. The center (scrolling) pane when there is
6
+ * one, else the first frozen pane.
7
+ *
8
+ * @remarks
9
+ * The center pane is not always there: a freeze larger than the view leaves it no room, and the grid
10
+ * builds no pane without room. `null` only while the grid has no panes at all (it has no size).
11
+ */
12
+ export declare const getPrimaryPane: (panes: Readonly<Partial<Record<AnchorLocation, IGridPane>>>) => IGridPane | null;
13
+ //# sourceMappingURL=getPrimaryPane.d.ts.map
@@ -1,4 +1,5 @@
1
1
  export * from './IGridPane';
2
+ export * from './getPrimaryPane';
2
3
  export * from './IGridSurface';
3
4
  export * from './GridSurface';
4
5
  export * from './useGridPane';
@@ -48,7 +48,7 @@ export interface GridThemeCSSOptions {
48
48
  /**
49
49
  * grid-react's theme stylesheet — the app baseline (utils-react `defaultTheme`, or a passed one) + the
50
50
  * `grid` / `header` surface overrides, compiled to the `data-sxl-theme-*` attribute matrix. Called by the
51
- * react `SheetElement` with neutral defaults into `@layer sxl-defaults` (so even a chromeless sheet is
51
+ * react `WorksheetElement` with neutral defaults into `@layer sxl-defaults` (so even a chromeless sheet is
52
52
  * themed), and by studio-mui with MUI-derived values into `sxl-app` on top; clients override in
53
53
  * `sxl-overrides`. Consumers just set `data-sxl-theme-*` attributes.
54
54
  */