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

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
@@ -0,0 +1,114 @@
1
+ import { Bounds } from '@sheetxl/utils';
2
+ import { AnimatedStrokeProps, ShapeProps } from './Types';
3
+ /**
4
+ * CSS keys that the SVG paths paint via **attributes**, not the wrapper's CSS. They are excluded from
5
+ * {@link VisualSVGProps.style} so `style={{ stroke }}` is a compile error (it would silently no-op) —
6
+ * set them via the dedicated `stroke`/`fill`/`strokeWidth`/`strokeDasharray` props instead.
7
+ */
8
+ type PaintCSSKey = 'stroke' | 'fill' | 'strokeWidth' | 'strokeDasharray' | 'strokeDashoffset';
9
+ /**
10
+ * The visual props shared by {@link RectangleSVG} and {@link RangeRect} — a curated surface, NOT the
11
+ * full SVG element props. Paint with the dedicated props (`stroke`/`fill`/`strokeWidth`/…); `style` is
12
+ * the wrapper's CSS for *effects* only (opacity/filter/transition). For raw `<svg>` attributes or
13
+ * handlers, use {@link RectangleSVGProps.propsRoot}.
14
+ */
15
+ export interface VisualSVGProps {
16
+ /**
17
+ * Fill color. Omit for an outline-only shape.
18
+ */
19
+ fill?: string;
20
+ /**
21
+ * Set properties for the fill path.
22
+ */
23
+ propsFillPath?: React.SVGProps<SVGPathElement>;
24
+ /**
25
+ * Stroke color. Omit for a fill-only shape.
26
+ */
27
+ stroke?: string;
28
+ /**
29
+ * Set properties for the stroke path.
30
+ */
31
+ propsStrokePath?: React.SVGProps<SVGPathElement>;
32
+ /**
33
+ * Dash the stroke, e.g. `"3 2"` for a dashed marquee.
34
+ */
35
+ strokeDasharray?: string | number;
36
+ /**
37
+ * Starting dash offset of the stroke (the marching-ants phase).
38
+ */
39
+ strokeDashoffset?: string | number;
40
+ /**
41
+ * The stroke width — both **painted** and used for device **alignment** (the crisp-snapping parity:
42
+ * even widths center on a whole device px, odd on a half). In DEVICE px when aligned (the default) —
43
+ * so 1/2/3 stay crisp at any dpr, like the gridline; in user/CSS units when {@link disableAlign} is
44
+ * set. Stacked rectangles that share an `alignWidth` snap to the SAME grid, so they stay locked
45
+ * together while scrolling (no per-layer "shimmy") — e.g. a two-tone selection border draws its inner
46
+ * ring at the same `alignWidth`, `inset` inward, *under* the outer so only a sliver shows.
47
+ *
48
+ * @defaultValue 1
49
+ */
50
+ alignWidth?: number;
51
+ /**
52
+ * Skip device alignment: the stroke centerline (½-width + parity) and the fill/hole
53
+ * edges. Turn ON for a raw, unaligned rect (e.g. an invisible hit target).
54
+ *
55
+ * @defaultValue false
56
+ */
57
+ disableAlign?: boolean;
58
+ /**
59
+ * Disable edge-aware stroke placement. When edge-aware (the default), leading edges (top/left) sit
60
+ * before the divider, trailing (bottom/right) after — so the outline lines up with cell
61
+ * borders/gridlines; turn ON to center the stroke on the boundary instead. Ignored when
62
+ * {@link disableAlign} is set. Negated to read alongside {@link disableAlign}.
63
+ *
64
+ * @defaultValue false
65
+ */
66
+ disableEdgeAware?: boolean;
67
+ /**
68
+ * Push the rectangle inward by this many DEVICE px on every side before placement
69
+ * (still device-aligned) — for an inner ring layered inside an outer outline.
70
+ *
71
+ * @defaultValue 0
72
+ */
73
+ inset?: number;
74
+ /**
75
+ * Marching-ants animation on the stroke (e.g. the copy/cut marquee). `true` uses
76
+ * defaults; pass {@link AnimatedStrokeProps} to tune the dash/speed.
77
+ */
78
+ animatedStroke?: boolean | AnimatedStrokeProps;
79
+ /**
80
+ * Transition the path `d` so the shape glides when its bounds change (move-drag).
81
+ */
82
+ animatedTransition?: boolean;
83
+ /** Class on the root `<svg>`. */
84
+ className?: string;
85
+ /**
86
+ * CSS on the root `<svg>` for *effects* — `opacity`, `filter`, `transition`, etc. NOT
87
+ * for paint: `stroke`/`fill`/`strokeWidth`/`strokeDasharray` are excluded here (the paths paint via
88
+ * attributes, so CSS paint would silently no-op) — use the dedicated props for those.
89
+ */
90
+ style?: Omit<React.CSSProperties, PaintCSSKey>;
91
+ }
92
+ export interface RectangleSVGProps extends VisualSVGProps, ShapeProps {
93
+ /**
94
+ * RAW bounds of an evenodd cut-out of the FILL (e.g. the active cell inside a
95
+ * selection). Area-snapped (`snapDeviceEdge`), not stroke-snapped. Ignored for the stroke.
96
+ */
97
+ hole?: Bounds;
98
+ /**
99
+ * Escape hatch: props spread onto the root `<svg>` element (raw attributes, event handlers). Rare —
100
+ * the wrapper is `pointerEvents: 'none'` by default and overlays seldom need it. Prefer the dedicated
101
+ * paint props, `style`, `propsStrokePath`, and `propsFillPath`.
102
+ */
103
+ propsRoot?: React.SVGProps<SVGSVGElement>;
104
+ }
105
+ /**
106
+ * A **shape**: a single device-pixel-aligned SVG rectangle (stroke and/or fill, with an optional
107
+ * evenodd hole). It owns ALL painting and ALL snapping of its sub-shapes — stroke centerline via
108
+ * `edgeCenter`, fill/hole edges via `snapDeviceEdge` — from the RAW `bounds` it is handed. It knows
109
+ * nothing about ranges or the pane: a **layer** ({@link RangeRect}) resolves a range to bounds and
110
+ * places it. (Shapes take bounds and paint; layers are pane-aware and compose into `renderLayers`.)
111
+ */
112
+ export declare const RectangleSVG: import('react').MemoExoticComponent<(props: RectangleSVGProps) => import("react").JSX.Element | null>;
113
+ export {};
114
+ //# sourceMappingURL=RectangleSVG.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { Bounds } from '@sheetxl/utils';
2
+ /**
3
+ * The RAW (pre-snap) bounds a shape leaf ({@link RectangleSVG} / {@link LineSVG}) draws at, provided
4
+ * by its container {@link Layer} — already expressed RELATIVE to the layer box's **device-aligned**
5
+ * origin. The shape still does its own `edgeCenter` / `snapDeviceEdge` snapping; because the origin is
6
+ * a whole number of device pixels, snapping these box-relative bounds lands on the identical device
7
+ * pixel as snapping absolute, just offset into the box (which carries the absolute translate).
8
+ *
9
+ * `null` when a shape is used standalone (not inside a `Layer`) — it then needs an explicit `bounds`
10
+ * prop, which always wins over this context.
11
+ */
12
+ export declare const ShapeBoundsContext: import('react').Context<Bounds | null>;
13
+ /** The container layer's box-relative bounds for a shape; the shape prefers its own `bounds` prop. */
14
+ export declare const useShapeBounds: () => Bounds | null;
15
+ //# sourceMappingURL=ShapeBounds.d.ts.map
@@ -0,0 +1,37 @@
1
+ import { Bounds } from '@sheetxl/utils';
2
+ /**
3
+ * The **shape contract**: a shape paints at the device `bounds` it is handed. `bounds` is OPTIONAL
4
+ * because a container {@link Layer} provides it via context ({@link useShapeBounds}) — author shapes
5
+ * without it inside a `Layer`, or pass it directly when standalone. A `Layer` *positions a box*; HTML
6
+ * children fill it and shape children paint at the box-relative bounds it provides.
7
+ */
8
+ export interface ShapeProps {
9
+ /**
10
+ * The RAW (pre-snap) bounds to paint at. When a shape is inside a {@link Layer} it reads these from
11
+ * context (box-relative); otherwise pass it directly (absolute). The shape device-snaps it itself.
12
+ */
13
+ bounds?: Bounds;
14
+ }
15
+ /**
16
+ * Props for animated stroke
17
+ */
18
+ export interface AnimatedStrokeProps {
19
+ /**
20
+ * The named of the animation
21
+ */
22
+ name?: string;
23
+ dashGap: number;
24
+ speed: number;
25
+ dashLength: number;
26
+ /**
27
+ * Color painted in the dash **gaps** — a solid under-stroke drawn beneath the animated dashes so the
28
+ * gaps reveal THIS color instead of whatever sits under the outline. Defaults to the grid background
29
+ * (`--sxl-color-base-100`), which keeps the marching ants legible even when the stroke runs directly
30
+ * over a same-colored fill (e.g. a reference border over the blue selection). Set explicitly to match
31
+ * a different backdrop.
32
+ *
33
+ * @defaultValue `var(--sxl-color-base-100, #fff)`
34
+ */
35
+ gapColor?: string;
36
+ }
37
+ //# sourceMappingURL=Types.d.ts.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * **Shapes**: low-level SVG painters. They take resolved `bounds` and paint — no pane, no range. A
3
+ * **layer** ({@link VirtualDiv} / {@link RangeRect}) resolves a range to bounds and places them.
4
+ */
5
+ export * from './Types';
6
+ export * from './ShapeBounds';
7
+ export * from './LineSVG';
8
+ export * from './RectangleSVG';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,56 @@
1
+ import { CSSProperties } from 'react';
2
+ import { TokenTheme, ThemeMode } from '@sheetxl/utils-react';
3
+ /**
4
+ * grid-react's own **surfaces** — the `grid` (paper + gridlines) and `header` (elevated) token overrides,
5
+ * layered over the generic app baseline (utils-react `defaultTheme`). Headers have no non-sheet consumers, so
6
+ * they belong here, not in the shared util. First-pass values (tune against the storybook diff); a later
7
+ * step can DERIVE these from the app baseline (the `createGridStyleFromMUITheme` elevate/divider math)
8
+ * instead of authoring them.
9
+ *
10
+ * A "surface" is just a partial {@link TokenTheme} merged over the baseline — see utils-react `themeVars`.
11
+ */
12
+ export declare const GRID_SURFACE: Record<ThemeMode, Partial<TokenTheme>>;
13
+ /**
14
+ * @remarks
15
+ * States `color-base-100` in both modes rather than letting it fall through to the app desktop
16
+ * ({@link buildGridThemeCSS}): with the neutral `defaultTheme`, the dark desktop and the dark grid paper are
17
+ * both `#1e1e1e`, so an unstated header would equal the cell fill and erase the row/column gutters.
18
+ *
19
+ * Header *hover* is `color-base-hover`, not `color-base-200`. `base-100/200/300` is a depth ramp — paper →
20
+ * recessed ground → border — and a pointer state is not a step on it. Parking hover on `base-200` gave one
21
+ * ramp token two unrelated meanings (the desktop on the app surface, a hover here); the header now simply
22
+ * doesn't restate `base-200` and inherits the app's desktop, like every other surface.
23
+ */
24
+ export declare const HEADER_SURFACE: Record<ThemeMode, Partial<TokenTheme>>;
25
+ /** The grid-surface `--sxl-*` var block for a mode (baseline + grid overrides + any client tweaks). */
26
+ export declare const gridThemeVars: (mode: ThemeMode, ...overrides: Array<Partial<TokenTheme> | undefined>) => CSSProperties;
27
+ /** The header-surface `--sxl-*` var block for a mode (baseline + header overrides + any client tweaks). */
28
+ export declare const headerThemeVars: (mode: ThemeMode, ...overrides: Array<Partial<TokenTheme> | undefined>) => CSSProperties;
29
+ export interface GridThemeCSSOptions {
30
+ /** App baseline per mode. @defaultValue utils-react `defaultTheme` (via `buildThemeCSS`). */
31
+ app?: Record<ThemeMode, TokenTheme>;
32
+ /** `grid` surface overrides per mode. @defaultValue {@link GRID_SURFACE}. */
33
+ grid?: Record<ThemeMode, Partial<TokenTheme>>;
34
+ /**
35
+ * `header` surface overrides per mode. A cell that omits `color-base-100` defaults to the app's
36
+ * `color-base-200` — the desktop — resolved to a value at emission time (THEMING-DESIGN §4).
37
+ * @defaultValue {@link HEADER_SURFACE}.
38
+ */
39
+ header?: Record<ThemeMode, Partial<TokenTheme>>;
40
+ /** @defaultValue `'sxl-defaults'` */
41
+ layer?: string;
42
+ /**
43
+ * Scope selector (e.g. `.sheetxl-sheet-<id>`) to emit a per-instance theme. Omit for global (interim).
44
+ * @defaultValue undefined
45
+ */
46
+ scope?: string;
47
+ }
48
+ /**
49
+ * grid-react's theme stylesheet — the app baseline (utils-react `defaultTheme`, or a passed one) + the
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
52
+ * themed), and by studio-mui with MUI-derived values into `sxl-app` on top; clients override in
53
+ * `sxl-overrides`. Consumers just set `data-sxl-theme-*` attributes.
54
+ */
55
+ export declare const buildGridThemeCSS: ({ app, grid, header, layer, scope }?: GridThemeCSSOptions) => string;
56
+ //# sourceMappingURL=GridTheme.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './GridTheme';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- ._sheetxl-grid_h9wwa_7{position:relative;box-sizing:border-box;user-select:none}._sheetxl-grid_h9wwa_7 *{box-sizing:border-box!important}._sheetxl-grid_h9wwa_7 *:focus{outline:none}._sheetxl-grid_h9wwa_7 .cell-container{position:absolute;overflow:visible;white-space:pre}._sheetxl-grid_h9wwa_7 .cell-container>*{inset:0;position:absolute}._sheetxl-grid_h9wwa_7 .sheetxl-stage{contain:strict}._sheetxl-grid_h9wwa_7 .sheetxl-stage>*{contain:strict}