@deephaven/grid 1.27.5-alpha-nodehttp2-config2.276eddc.0 → 1.29.0
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/dist/Grid.d.ts +102 -43
- package/dist/Grid.d.ts.map +1 -1
- package/dist/Grid.js +442 -390
- package/dist/Grid.js.map +1 -1
- package/dist/GridA11yFallback.d.ts +26 -0
- package/dist/GridA11yFallback.d.ts.map +1 -0
- package/dist/GridA11yFallback.js +115 -0
- package/dist/GridA11yFallback.js.map +1 -0
- package/dist/GridA11yUtils.d.ts +89 -0
- package/dist/GridA11yUtils.d.ts.map +1 -0
- package/dist/GridA11yUtils.js +321 -0
- package/dist/GridA11yUtils.js.map +1 -0
- package/dist/GridRenderer.d.ts +9 -0
- package/dist/GridRenderer.d.ts.map +1 -1
- package/dist/GridRenderer.js +187 -39
- package/dist/GridRenderer.js.map +1 -1
- package/dist/GridRendererTypes.d.ts +3 -4
- package/dist/GridRendererTypes.d.ts.map +1 -1
- package/dist/GridRendererTypes.js.map +1 -1
- package/dist/GridSelectionUtils.d.ts +98 -0
- package/dist/GridSelectionUtils.d.ts.map +1 -0
- package/dist/GridSelectionUtils.js +180 -0
- package/dist/GridSelectionUtils.js.map +1 -0
- package/dist/RangedSelection.d.ts +120 -0
- package/dist/RangedSelection.d.ts.map +1 -0
- package/dist/RangedSelection.js +375 -0
- package/dist/RangedSelection.js.map +1 -0
- package/dist/Selection.d.ts +221 -0
- package/dist/Selection.d.ts.map +1 -0
- package/dist/Selection.js +71 -0
- package/dist/Selection.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/key-handlers/EditKeyHandler.js +3 -3
- package/dist/key-handlers/EditKeyHandler.js.map +1 -1
- package/dist/key-handlers/SelectionKeyHandler.d.ts +1 -0
- package/dist/key-handlers/SelectionKeyHandler.d.ts.map +1 -1
- package/dist/key-handlers/SelectionKeyHandler.js +144 -138
- package/dist/key-handlers/SelectionKeyHandler.js.map +1 -1
- package/dist/key-handlers/TreeKeyHandler.d.ts.map +1 -1
- package/dist/key-handlers/TreeKeyHandler.js +6 -3
- package/dist/key-handlers/TreeKeyHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowTreeMouseHandler.d.ts +1 -0
- package/dist/mouse-handlers/GridRowTreeMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js +7 -0
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSelectionMouseHandler.d.ts +0 -9
- package/dist/mouse-handlers/GridSelectionMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridSelectionMouseHandler.js +41 -39
- package/dist/mouse-handlers/GridSelectionMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridTokenMouseHandler.js +4 -1
- package/dist/mouse-handlers/GridTokenMouseHandler.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** Provides current model data to Selection instances without holding a stale reference. */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Immutable value object representing the current selection state of the grid.
|
|
5
|
+
* Mutations return new instances; Grid stores the result in React state.
|
|
6
|
+
*
|
|
7
|
+
* Composed from five sub-interfaces:
|
|
8
|
+
* - `SelectionQueries` — read-only inspection.
|
|
9
|
+
* - `SelectionTransforms` — immutable transforms with no external dependencies.
|
|
10
|
+
* - `ProgrammaticSelection` — programmatic write path (`Grid.setSelectedRanges`).
|
|
11
|
+
* - `MouseSelection` — mouse-driven gestures (click, shift-click, drag).
|
|
12
|
+
* - `KeyboardSelection` — keyboard-driven queries (Tab/Enter advance, cursor
|
|
13
|
+
* landing after commit).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** Read-only inspection of a `Selection`. Every method is side-effect-free. */
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Optional capability implemented by selections that can project onto
|
|
20
|
+
* scrollbar tick marks. Ranges are returned sorted by start and merged so
|
|
21
|
+
* consumers can iterate directly without re-normalizing per frame.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export function isTickRangeSelection(selection) {
|
|
25
|
+
return typeof selection.getColumnTickRanges === 'function' && typeof selection.getRowTickRanges === 'function';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Immutable transformations of a `Selection` that need no external context.
|
|
30
|
+
* Each method returns a new `Selection`; the receiver is never modified.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Programmatic write path: install a caller-supplied set of ranges as the
|
|
35
|
+
* committed selection. Used by `Grid.setSelectedRanges`, `setFocusRow`, and
|
|
36
|
+
* `moveCursorInDirection`. Distinct from gesture-driven writes, which are
|
|
37
|
+
* being reworked in the `MouseSelection` / `KeyboardSelection` interfaces.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Modifier-key-derived mode for a mouse gesture:
|
|
42
|
+
* - `replace` — plain click: clear the current selection and install a
|
|
43
|
+
* single cell at the cursor.
|
|
44
|
+
* - `add` — ctrl/meta click: keep the current selection and add a single
|
|
45
|
+
* cell at the cursor.
|
|
46
|
+
* - `extend` — shift click / drag: trim to the last range and extend it
|
|
47
|
+
* from the gesture anchor to the cursor.
|
|
48
|
+
* - `maximize` — ctrl+shift click: keep all ranges, grow the last range
|
|
49
|
+
* to include the cursor.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/** Options for `MouseSelection.withGestureExtend`. */
|
|
53
|
+
|
|
54
|
+
/** Options for `MouseSelection.commitGesture`. */
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Mouse-driven selection updates. Both `withGestureExtend` and
|
|
58
|
+
* `commitGesture` are called by `Grid`'s mouse handlers.
|
|
59
|
+
*
|
|
60
|
+
* A gesture starts on mouse-down, may extend across drag frames, and settles
|
|
61
|
+
* on mouse-up. Each drag frame calls `withGestureExtend` to update the
|
|
62
|
+
* transient overlay; `commitGesture` folds the overlay into the committed
|
|
63
|
+
* selection.
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Keyboard-driven selection queries. Grid's key handlers use these to advance
|
|
68
|
+
* the cursor within the current selection (Tab/Enter) and to place the cursor
|
|
69
|
+
* after a commit or programmatic install.
|
|
70
|
+
*/
|
|
71
|
+
//# sourceMappingURL=Selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Selection.js","names":["isTickRangeSelection","selection","getColumnTickRanges","getRowTickRanges"],"sources":["../src/Selection.ts"],"sourcesContent":["import type GridRange from './GridRange';\nimport type { GridRangeIndex, SELECTION_DIRECTION } from './GridRange';\nimport type GridModel from './GridModel';\nimport type { VisibleIndex } from './GridMetrics';\nimport type { BoundedAxisRange } from './GridAxisRange';\n\n/** Provides current model data to Selection instances without holding a stale reference. */\nexport type GetModel = () => GridModel;\n\n/**\n * Immutable value object representing the current selection state of the grid.\n * Mutations return new instances; Grid stores the result in React state.\n *\n * Composed from five sub-interfaces:\n * - `SelectionQueries` — read-only inspection.\n * - `SelectionTransforms` — immutable transforms with no external dependencies.\n * - `ProgrammaticSelection` — programmatic write path (`Grid.setSelectedRanges`).\n * - `MouseSelection` — mouse-driven gestures (click, shift-click, drag).\n * - `KeyboardSelection` — keyboard-driven queries (Tab/Enter advance, cursor\n * landing after commit).\n */\nexport interface Selection\n extends SelectionQueries,\n SelectionTransforms,\n ProgrammaticSelection,\n MouseSelection,\n KeyboardSelection {}\n\n/** Read-only inspection of a `Selection`. Every method is side-effect-free. */\nexport interface SelectionQueries {\n /** True when the selection contains no cells and no in-progress gesture. */\n isEmpty: () => boolean;\n /** True when `(column, row)` is part of the selection. */\n isCellSelected: (column: VisibleIndex, row: VisibleIndex) => boolean;\n /** True when the entire row is part of the selection. */\n isRowSelected: (row: VisibleIndex) => boolean;\n /** True when the entire column is part of the selection. */\n isColumnSelected: (column: VisibleIndex) => boolean;\n /** The focus cell's row, or `null` when there is no cursor set. */\n readonly cursorRow: VisibleIndex | null;\n /** The focus cell's column, or `null` when there is no cursor set. */\n readonly cursorColumn: VisibleIndex | null;\n /** Row of the last shift/drag endpoint, or `null` when unset. */\n readonly selectionEndRow: VisibleIndex | null;\n /** Column of the last shift/drag endpoint, or `null` when unset. */\n readonly selectionEndColumn: VisibleIndex | null;\n /** Brief human-readable summary of the selection. Used for a11y status. */\n describe: () => string;\n}\n\n/**\n * Optional capability implemented by selections that can project onto\n * scrollbar tick marks. Ranges are returned sorted by start and merged so\n * consumers can iterate directly without re-normalizing per frame.\n */\nexport interface TickRangeSelection {\n /**\n * Sorted, non-overlapping column `[start, end]` pairs for scrollbar tick\n * rendering.\n */\n getColumnTickRanges: () => readonly BoundedAxisRange[];\n /**\n * Sorted, non-overlapping row `[start, end]` pairs for scrollbar tick\n * rendering.\n */\n getRowTickRanges: () => readonly BoundedAxisRange[];\n}\n\nexport function isTickRangeSelection(\n selection: Selection\n): selection is Selection & TickRangeSelection {\n return (\n typeof (selection as Partial<TickRangeSelection>).getColumnTickRanges ===\n 'function' &&\n typeof (selection as Partial<TickRangeSelection>).getRowTickRanges ===\n 'function'\n );\n}\n\n/**\n * Immutable transformations of a `Selection` that need no external context.\n * Each method returns a new `Selection`; the receiver is never modified.\n */\nexport interface SelectionTransforms {\n /** A fresh empty selection with no committed state, overlay, or anchor. */\n clear: () => Selection;\n /**\n * A new selection keeping only the last committed range (for\n * `RangedSelection`) or clearing committed keys (for `KeyedSelection`).\n * Called by `Grid.trimSelectedRanges` immediately before shift-based\n * extend so the anchor is preserved.\n */\n trimmed: () => Selection;\n /** A new selection covering the entire grid. */\n selectAll: () => Selection;\n /** A new selection containing at most `maxRows` rows. */\n truncate: (maxRows: number) => Selection;\n}\n\n/**\n * Programmatic write path: install a caller-supplied set of ranges as the\n * committed selection. Used by `Grid.setSelectedRanges`, `setFocusRow`, and\n * `moveCursorInDirection`. Distinct from gesture-driven writes, which are\n * being reworked in the `MouseSelection` / `KeyboardSelection` interfaces.\n */\nexport interface ProgrammaticSelection {\n /**\n * Replaces the committed selection with the given ranges and clears any\n * transient overlay state. When `anchor` is provided, sets the gesture\n * anchor (extend-from position for shift-click and keyboard extend) to\n * the given cell; otherwise clears it.\n */\n withCommittedRanges: (\n ranges: readonly GridRange[],\n anchor?: { row: GridRangeIndex; column: GridRangeIndex }\n ) => Selection;\n}\n\n/**\n * Modifier-key-derived mode for a mouse gesture:\n * - `replace` — plain click: clear the current selection and install a\n * single cell at the cursor.\n * - `add` — ctrl/meta click: keep the current selection and add a single\n * cell at the cursor.\n * - `extend` — shift click / drag: trim to the last range and extend it\n * from the gesture anchor to the cursor.\n * - `maximize` — ctrl+shift click: keep all ranges, grow the last range\n * to include the cursor.\n */\nexport type GestureMode = 'replace' | 'add' | 'extend' | 'maximize';\n\n/** Options for `MouseSelection.withGestureExtend`. */\nexport type GestureExtendOptions = {\n /** How the current selection should be combined with the incoming cursor. */\n mode: GestureMode;\n /** Full-row selection mode (theme `autoSelectRow`). */\n autoSelectRow: boolean;\n /** Full-column selection mode (theme `autoSelectColumn`). */\n autoSelectColumn: boolean;\n};\n\n/** Options for `MouseSelection.commitGesture`. */\nexport type CommitGestureOptions = {\n /**\n * When true, a single-row commit that repeats the previous single-row\n * selection is treated as a deselect. Matches the `autoSelectRow` theme\n * flag semantic.\n */\n autoSelectRow: boolean;\n /**\n * Post-commit cursor position. When `settled` is non-empty and this\n * cursor falls outside it, `commitGesture` substitutes a landing cell\n * from the pre-commit selection. When `settled` is empty, this cursor\n * is preserved on the returned selection (matches Escape semantics).\n * Omit for no-op commits that shouldn't touch cursor.\n */\n cursor?: { row: GridRangeIndex; column: GridRangeIndex };\n /**\n * When true (default), a commit whose settled ranges match the previous\n * single-row / single-cell committed selection is treated as a deselect.\n * This is the mouse click-to-deselect affordance. Keyboard callers pass\n * `false` so arrowing onto an already-selected cell just moves the cursor\n * instead of clearing the selection.\n */\n allowDeselect?: boolean;\n /**\n * When true (default), the commit finalizes the gesture: deselect check,\n * hole-punch on overlap, and range consolidation all run. Pass `false`\n * from mouse-down so those steps defer to mouse-up; between them the\n * drag can grow the last range without eagerly fragmenting the prior\n * selection.\n */\n settle?: boolean;\n};\n\n/**\n * Mouse-driven selection updates. Both `withGestureExtend` and\n * `commitGesture` are called by `Grid`'s mouse handlers.\n *\n * A gesture starts on mouse-down, may extend across drag frames, and settles\n * on mouse-up. Each drag frame calls `withGestureExtend` to update the\n * transient overlay; `commitGesture` folds the overlay into the committed\n * selection.\n */\nexport interface MouseSelection {\n /**\n * Applies a mouse gesture that moves the selection to `cursor` per `opts`.\n * `mode` chooses replace / add / extend / maximize semantics based on the\n * modifier keys the caller observed.\n *\n * Returns a transient overlay-updated selection. Caller controls when to\n * `commitGesture` — mouse handlers commit on mouse-up only; a plain click\n * commits immediately.\n */\n withGestureExtend: (\n cursor: { row: GridRangeIndex; column: GridRangeIndex },\n opts: GestureExtendOptions\n ) => Selection;\n\n /**\n * Settles the current transient overlay into the committed selection.\n * Handles consolidation, deselect-on-reclick, and subtract logic. Returns\n * identity (`this`) when there is nothing to commit.\n *\n * `lastCommitted` is the selection state as it was BEFORE the current\n * gesture began. Grid pins this in state at gesture-start so the\n * deselect-on-reclick comparison stays stable across drag frames.\n */\n commitGesture: (\n lastCommitted: Selection,\n opts: CommitGestureOptions\n ) => Selection;\n}\n\n/**\n * Keyboard-driven selection queries. Grid's key handlers use these to advance\n * the cursor within the current selection (Tab/Enter) and to place the cursor\n * after a commit or programmatic install.\n */\nexport interface KeyboardSelection {\n /**\n * Returns the next cursor cell in `direction` starting from `current`.\n * When the selection is empty or has exactly one cell, walks the whole\n * grid (wrapping at edges) so a lone Tab still moves the cursor.\n * Otherwise cycles through the currently selected ranges.\n */\n getNextCursorInDirection: (\n current: { row: GridRangeIndex; column: GridRangeIndex },\n direction: SELECTION_DIRECTION\n ) => { row: GridRangeIndex; column: GridRangeIndex } | null;\n\n /**\n * A new selection with the cursor set to `(column, row)`. Passing `null`\n * for both clears the cursor. Non-cursor state (ranges, keys, anchor,\n * selection endpoint) is preserved.\n */\n withCursor: (\n row: VisibleIndex | null,\n column: VisibleIndex | null\n ) => Selection;\n\n /**\n * A new selection with the shift/drag endpoint set to `(column, row)`.\n * Passing `null` for both clears the endpoint. Non-endpoint state\n * (ranges, keys, anchor, cursor) is preserved.\n */\n withSelectionEnd: (\n row: VisibleIndex | null,\n column: VisibleIndex | null\n ) => Selection;\n}\n"],"mappings":"AAMA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;;AAsBA;AACA;AACA;AACA;AACA;;AAcA,OAAO,SAASA,oBAAoBA,CAClCC,SAAoB,EACyB;EAC7C,OACE,OAAQA,SAAS,CAAiCC,mBAAmB,KACnE,UAAU,IACZ,OAAQD,SAAS,CAAiCE,gBAAgB,KAChE,UAAU;AAEhB;;AAEA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;;AAUA;;AAkCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA+BA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ export * from './ExpandableGridModel';
|
|
|
8
8
|
export * from './ExpandableColumnGridModel';
|
|
9
9
|
export { default as Grid } from './Grid';
|
|
10
10
|
export * from './Grid';
|
|
11
|
+
export * from './GridA11yUtils';
|
|
12
|
+
export { default as GridA11yFallback } from './GridA11yFallback';
|
|
13
|
+
export * from './GridA11yFallback';
|
|
11
14
|
export * from './GridMetricCalculator';
|
|
12
15
|
export * from './GridMetrics';
|
|
13
16
|
export { default as GridModel } from './GridModel';
|
|
@@ -30,6 +33,9 @@ export { default as ViewportDataGridModel } from './ViewportDataGridModel';
|
|
|
30
33
|
export { default as MockDataBarGridModel } from './MockDataBarGridModel';
|
|
31
34
|
export * from './key-handlers';
|
|
32
35
|
export * from './mouse-handlers';
|
|
36
|
+
export * from './Selection';
|
|
37
|
+
export * from './GridSelectionUtils';
|
|
38
|
+
export { RangedSelection, isRangedSelection, assertIsRangedSelection, selectionToRanges, } from './RangedSelection';
|
|
33
39
|
export * from './errors';
|
|
34
40
|
export * from './EventHandlerResult';
|
|
35
41
|
export * from './ThemeContext';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,cAAc,QAAQ,CAAC;AACvB,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9D,cAAc,aAAa,CAAC;AAC5B,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wBAAwB,CAAC;AACzE,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,9 @@ export * from "./ExpandableGridModel.js";
|
|
|
8
8
|
export * from "./ExpandableColumnGridModel.js";
|
|
9
9
|
export { default as Grid } from "./Grid.js";
|
|
10
10
|
export * from "./Grid.js";
|
|
11
|
+
export * from "./GridA11yUtils.js";
|
|
12
|
+
export { default as GridA11yFallback } from "./GridA11yFallback.js";
|
|
13
|
+
export * from "./GridA11yFallback.js";
|
|
11
14
|
export * from "./GridMetricCalculator.js";
|
|
12
15
|
export * from "./GridMetrics.js";
|
|
13
16
|
export { default as GridModel } from "./GridModel.js";
|
|
@@ -29,6 +32,9 @@ export { default as ViewportDataGridModel } from "./ViewportDataGridModel.js";
|
|
|
29
32
|
export { default as MockDataBarGridModel } from "./MockDataBarGridModel.js";
|
|
30
33
|
export * from "./key-handlers/index.js";
|
|
31
34
|
export * from "./mouse-handlers/index.js";
|
|
35
|
+
export * from "./Selection.js";
|
|
36
|
+
export * from "./GridSelectionUtils.js";
|
|
37
|
+
export { RangedSelection, isRangedSelection, assertIsRangedSelection, selectionToRanges } from "./RangedSelection.js";
|
|
32
38
|
export * from "./errors/index.js";
|
|
33
39
|
export * from "./EventHandlerResult.js";
|
|
34
40
|
export * from "./ThemeContext.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","CellInputField","Grid","GridModel","GridTestUtils","GridTheme","KeyHandler","MockGridModel","MockTreeGridModel","memoizeClear","StaticDataGridModel","ViewportDataGridModel","MockDataBarGridModel","CellRenderer","TextCellRenderer","DataBarCellRenderer","GridColorUtils"],"sources":["../src/index.ts"],"sourcesContent":["export { default as CellInputField } from './CellInputField';\nexport * from './CellInputField';\nexport * from './GridRendererTypes';\nexport * from './ColumnHeaderGroup';\nexport * from './EditableGridModel';\nexport * from './DeletableGridModel';\nexport * from './ExpandableGridModel';\nexport * from './ExpandableColumnGridModel';\nexport { default as Grid } from './Grid';\nexport * from './Grid';\nexport * from './GridMetricCalculator';\nexport * from './GridMetrics';\nexport { default as GridModel } from './GridModel';\nexport * from './GridModel';\nexport * from './GridMouseHandler';\nexport * from './GridRange';\nexport * from './GridAxisRange';\nexport * from './GridRenderer';\nexport { default as GridTestUtils } from './GridTestUtils';\nexport * from './GridTheme';\nexport { default as GridTheme } from './GridTheme';\nexport type { GridTheme as GridThemeType } from './GridTheme';\nexport * from './GridUtils';\nexport { default as KeyHandler } from './KeyHandler';\nexport { default as MockGridModel } from './MockGridModel';\nexport { default as MockTreeGridModel } from './MockTreeGridModel';\nexport { default as memoizeClear } from './memoizeClear';\nexport { default as StaticDataGridModel } from './StaticDataGridModel';\nexport { default as ViewportDataGridModel } from './ViewportDataGridModel';\nexport { default as MockDataBarGridModel } from './MockDataBarGridModel';\nexport * from './key-handlers';\nexport * from './mouse-handlers';\nexport * from './errors';\nexport * from './EventHandlerResult';\nexport * from './ThemeContext';\nexport { default as CellRenderer } from './CellRenderer';\nexport type { CellRenderType } from './CellRenderer';\nexport { default as TextCellRenderer } from './TextCellRenderer';\nexport { default as DataBarCellRenderer } from './DataBarCellRenderer';\nexport * from './TokenBoxCellRenderer';\nexport * from './GridRendererTypes';\nexport * from './DataBarGridModel';\nexport { default as GridColorUtils } from './GridColorUtils';\nexport type { RGB, Oklab } from './GridColorUtils';\n"],"mappings":"SAASA,OAAO,IAAIC,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAQzBD,OAAO,IAAIE,IAAI;AAAA;AAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","CellInputField","Grid","GridA11yFallback","GridModel","GridTestUtils","GridTheme","KeyHandler","MockGridModel","MockTreeGridModel","memoizeClear","StaticDataGridModel","ViewportDataGridModel","MockDataBarGridModel","RangedSelection","isRangedSelection","assertIsRangedSelection","selectionToRanges","CellRenderer","TextCellRenderer","DataBarCellRenderer","GridColorUtils"],"sources":["../src/index.ts"],"sourcesContent":["export { default as CellInputField } from './CellInputField';\nexport * from './CellInputField';\nexport * from './GridRendererTypes';\nexport * from './ColumnHeaderGroup';\nexport * from './EditableGridModel';\nexport * from './DeletableGridModel';\nexport * from './ExpandableGridModel';\nexport * from './ExpandableColumnGridModel';\nexport { default as Grid } from './Grid';\nexport * from './Grid';\nexport * from './GridA11yUtils';\nexport { default as GridA11yFallback } from './GridA11yFallback';\nexport * from './GridA11yFallback';\nexport * from './GridMetricCalculator';\nexport * from './GridMetrics';\nexport { default as GridModel } from './GridModel';\nexport * from './GridModel';\nexport * from './GridMouseHandler';\nexport * from './GridRange';\nexport * from './GridAxisRange';\nexport * from './GridRenderer';\nexport { default as GridTestUtils } from './GridTestUtils';\nexport * from './GridTheme';\nexport { default as GridTheme } from './GridTheme';\nexport type { GridTheme as GridThemeType } from './GridTheme';\nexport * from './GridUtils';\nexport { default as KeyHandler } from './KeyHandler';\nexport { default as MockGridModel } from './MockGridModel';\nexport { default as MockTreeGridModel } from './MockTreeGridModel';\nexport { default as memoizeClear } from './memoizeClear';\nexport { default as StaticDataGridModel } from './StaticDataGridModel';\nexport { default as ViewportDataGridModel } from './ViewportDataGridModel';\nexport { default as MockDataBarGridModel } from './MockDataBarGridModel';\nexport * from './key-handlers';\nexport * from './mouse-handlers';\nexport * from './Selection';\nexport * from './GridSelectionUtils';\nexport {\n RangedSelection,\n isRangedSelection,\n assertIsRangedSelection,\n selectionToRanges,\n} from './RangedSelection';\nexport * from './errors';\nexport * from './EventHandlerResult';\nexport * from './ThemeContext';\nexport { default as CellRenderer } from './CellRenderer';\nexport type { CellRenderType } from './CellRenderer';\nexport { default as TextCellRenderer } from './TextCellRenderer';\nexport { default as DataBarCellRenderer } from './DataBarCellRenderer';\nexport * from './TokenBoxCellRenderer';\nexport * from './GridRendererTypes';\nexport * from './DataBarGridModel';\nexport { default as GridColorUtils } from './GridColorUtils';\nexport type { RGB, Oklab } from './GridColorUtils';\n"],"mappings":"SAASA,OAAO,IAAIC,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAQzBD,OAAO,IAAIE,IAAI;AAAA;AAAA;AAAA,SAGfF,OAAO,IAAIG,gBAAgB;AAAA;AAAA;AAAA;AAAA,SAI3BH,OAAO,IAAII,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAMpBJ,OAAO,IAAIK,aAAa;AAAA;AAAA,SAExBL,OAAO,IAAIM,SAAS;AAAA;AAAA,SAGpBN,OAAO,IAAIO,UAAU;AAAA,SACrBP,OAAO,IAAIQ,aAAa;AAAA,SACxBR,OAAO,IAAIS,iBAAiB;AAAA,SAC5BT,OAAO,IAAIU,YAAY;AAAA,SACvBV,OAAO,IAAIW,mBAAmB;AAAA,SAC9BX,OAAO,IAAIY,qBAAqB;AAAA,SAChCZ,OAAO,IAAIa,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA,SAMtCC,eAAe,EACfC,iBAAiB,EACjBC,uBAAuB,EACvBC,iBAAiB;AAAA;AAAA;AAAA;AAAA,SAKVjB,OAAO,IAAIkB,YAAY;AAAA,SAEvBlB,OAAO,IAAImB,gBAAgB;AAAA,SAC3BnB,OAAO,IAAIoB,mBAAmB;AAAA;AAAA;AAAA;AAAA,SAI9BpB,OAAO,IAAIqB,cAAc","ignoreList":[]}
|
|
@@ -9,9 +9,9 @@ class EditKeyHandler extends KeyHandler {
|
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
11
11
|
var model = grid.props.model;
|
|
12
|
-
var _grid$state = grid.state,
|
|
13
|
-
cursorColumn = _grid$state.cursorColumn,
|
|
14
|
-
cursorRow = _grid$state.cursorRow;
|
|
12
|
+
var _grid$state$selection = grid.state.selection,
|
|
13
|
+
cursorColumn = _grid$state$selection.cursorColumn,
|
|
14
|
+
cursorRow = _grid$state$selection.cursorRow;
|
|
15
15
|
if (cursorColumn == null || cursorRow == null || !isEditableGridModel(model)) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditKeyHandler.js","names":["GridUtils","GridRange","KeyHandler","isEditableGridModel","EditKeyHandler","onDown","event","grid","isModifierKeyDown","model","props","_grid$state","state","cursorColumn","cursorRow","modelColumn","modelRow","getModelColumn","getModelRow","_unused","isEditableRange","makeCell","key","length","cellInputRendererRegistry","restrictions","getColumnRestrictions","renderer","get","type","preservesExistingValue","startEditing","undefined","setValueForCell"],"sources":["../../src/key-handlers/EditKeyHandler.ts"],"sourcesContent":["/* eslint class-methods-use-this: \"off\" */\nimport GridUtils from '../GridUtils';\nimport type Grid from '../Grid';\nimport GridRange from '../GridRange';\nimport KeyHandler, { type GridKeyboardEvent } from '../KeyHandler';\nimport { isEditableGridModel } from '../EditableGridModel';\nimport { type EventHandlerResult } from '../EventHandlerResult';\n\nclass EditKeyHandler extends KeyHandler {\n onDown(event: GridKeyboardEvent, grid: Grid): EventHandlerResult {\n if (GridUtils.isModifierKeyDown(event)) {\n return false;\n }\n\n const { model } = grid.props;\n const { cursorColumn, cursorRow } = grid.state;\n if (\n cursorColumn == null ||\n cursorRow == null ||\n !isEditableGridModel(model)\n ) {\n return false;\n }\n\n let modelColumn: number;\n let modelRow: number;\n try {\n modelColumn = grid.getModelColumn(cursorColumn);\n modelRow = grid.getModelRow(cursorRow);\n } catch {\n return false;\n }\n\n if (!model.isEditableRange(GridRange.makeCell(modelColumn, modelRow))) {\n return false;\n }\n\n if (event.key.length === 1) {\n // If the renderer for this cell's restriction type preserves the existing\n // value on keystroke (e.g. a dropdown), open the editor without replacing.\n const { cellInputRendererRegistry } = grid.props;\n const restrictions = model.getColumnRestrictions(modelColumn);\n if (restrictions.length === 1) {\n const renderer = cellInputRendererRegistry?.get(restrictions[0].type);\n if (renderer?.preservesExistingValue === true) {\n grid.startEditing(cursorColumn, cursorRow);\n return true;\n }\n }\n grid.startEditing(cursorColumn, cursorRow, true, [1, 1], event.key);\n return true;\n }\n\n if (event.key === 'F2') {\n grid.startEditing(cursorColumn, cursorRow);\n return true;\n }\n\n if (event.key === 'Enter') {\n grid.startEditing(cursorColumn, cursorRow);\n return true;\n }\n\n if (event.key === 'Backspace') {\n grid.startEditing(cursorColumn, cursorRow, true, undefined, '');\n return true;\n }\n\n if (event.key === 'Delete') {\n grid.setValueForCell(cursorColumn, cursorRow, '');\n return true;\n }\n return false;\n }\n}\n\nexport default EditKeyHandler;\n"],"mappings":"AAAA;AAAA,OACOA,SAAS;AAAA,OAETC,SAAS;AAAA,OACTC,UAAU;AAAA,SACRC,mBAAmB;AAG5B,MAAMC,cAAc,SAASF,UAAU,CAAC;EACtCG,MAAMA,CAACC,KAAwB,EAAEC,IAAU,EAAsB;IAC/D,IAAIP,SAAS,CAACQ,iBAAiB,CAACF,KAAK,CAAC,EAAE;MACtC,OAAO,KAAK;IACd;IAEA,IAAQG,KAAK,GAAKF,IAAI,CAACG,KAAK,CAApBD,KAAK;IACb,IAAAE,
|
|
1
|
+
{"version":3,"file":"EditKeyHandler.js","names":["GridUtils","GridRange","KeyHandler","isEditableGridModel","EditKeyHandler","onDown","event","grid","isModifierKeyDown","model","props","_grid$state$selection","state","selection","cursorColumn","cursorRow","modelColumn","modelRow","getModelColumn","getModelRow","_unused","isEditableRange","makeCell","key","length","cellInputRendererRegistry","restrictions","getColumnRestrictions","renderer","get","type","preservesExistingValue","startEditing","undefined","setValueForCell"],"sources":["../../src/key-handlers/EditKeyHandler.ts"],"sourcesContent":["/* eslint class-methods-use-this: \"off\" */\nimport GridUtils from '../GridUtils';\nimport type Grid from '../Grid';\nimport GridRange from '../GridRange';\nimport KeyHandler, { type GridKeyboardEvent } from '../KeyHandler';\nimport { isEditableGridModel } from '../EditableGridModel';\nimport { type EventHandlerResult } from '../EventHandlerResult';\n\nclass EditKeyHandler extends KeyHandler {\n onDown(event: GridKeyboardEvent, grid: Grid): EventHandlerResult {\n if (GridUtils.isModifierKeyDown(event)) {\n return false;\n }\n\n const { model } = grid.props;\n const { cursorColumn, cursorRow } = grid.state.selection;\n if (\n cursorColumn == null ||\n cursorRow == null ||\n !isEditableGridModel(model)\n ) {\n return false;\n }\n\n let modelColumn: number;\n let modelRow: number;\n try {\n modelColumn = grid.getModelColumn(cursorColumn);\n modelRow = grid.getModelRow(cursorRow);\n } catch {\n return false;\n }\n\n if (!model.isEditableRange(GridRange.makeCell(modelColumn, modelRow))) {\n return false;\n }\n\n if (event.key.length === 1) {\n // If the renderer for this cell's restriction type preserves the existing\n // value on keystroke (e.g. a dropdown), open the editor without replacing.\n const { cellInputRendererRegistry } = grid.props;\n const restrictions = model.getColumnRestrictions(modelColumn);\n if (restrictions.length === 1) {\n const renderer = cellInputRendererRegistry?.get(restrictions[0].type);\n if (renderer?.preservesExistingValue === true) {\n grid.startEditing(cursorColumn, cursorRow);\n return true;\n }\n }\n grid.startEditing(cursorColumn, cursorRow, true, [1, 1], event.key);\n return true;\n }\n\n if (event.key === 'F2') {\n grid.startEditing(cursorColumn, cursorRow);\n return true;\n }\n\n if (event.key === 'Enter') {\n grid.startEditing(cursorColumn, cursorRow);\n return true;\n }\n\n if (event.key === 'Backspace') {\n grid.startEditing(cursorColumn, cursorRow, true, undefined, '');\n return true;\n }\n\n if (event.key === 'Delete') {\n grid.setValueForCell(cursorColumn, cursorRow, '');\n return true;\n }\n return false;\n }\n}\n\nexport default EditKeyHandler;\n"],"mappings":"AAAA;AAAA,OACOA,SAAS;AAAA,OAETC,SAAS;AAAA,OACTC,UAAU;AAAA,SACRC,mBAAmB;AAG5B,MAAMC,cAAc,SAASF,UAAU,CAAC;EACtCG,MAAMA,CAACC,KAAwB,EAAEC,IAAU,EAAsB;IAC/D,IAAIP,SAAS,CAACQ,iBAAiB,CAACF,KAAK,CAAC,EAAE;MACtC,OAAO,KAAK;IACd;IAEA,IAAQG,KAAK,GAAKF,IAAI,CAACG,KAAK,CAApBD,KAAK;IACb,IAAAE,qBAAA,GAAoCJ,IAAI,CAACK,KAAK,CAACC,SAAS;MAAhDC,YAAY,GAAAH,qBAAA,CAAZG,YAAY;MAAEC,SAAS,GAAAJ,qBAAA,CAATI,SAAS;IAC/B,IACED,YAAY,IAAI,IAAI,IACpBC,SAAS,IAAI,IAAI,IACjB,CAACZ,mBAAmB,CAACM,KAAK,CAAC,EAC3B;MACA,OAAO,KAAK;IACd;IAEA,IAAIO,WAAmB;IACvB,IAAIC,QAAgB;IACpB,IAAI;MACFD,WAAW,GAAGT,IAAI,CAACW,cAAc,CAACJ,YAAY,CAAC;MAC/CG,QAAQ,GAAGV,IAAI,CAACY,WAAW,CAACJ,SAAS,CAAC;IACxC,CAAC,CAAC,OAAAK,OAAA,EAAM;MACN,OAAO,KAAK;IACd;IAEA,IAAI,CAACX,KAAK,CAACY,eAAe,CAACpB,SAAS,CAACqB,QAAQ,CAACN,WAAW,EAAEC,QAAQ,CAAC,CAAC,EAAE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AAQ,EAAE;MAC1BhB,IAAI,CAAC2B,eAAe,CAACpB,YAAY,EAAEC,SAAS,EAAE,EAAE,CAAC;MACjD,OAAO,IAAI;IACb;IACA,OAAO,KAAK;EACd;AACF;AAEA,eAAeX,cAAc","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ import KeyHandler, { type GridKeyboardEvent } from '../KeyHandler';
|
|
|
4
4
|
declare class SelectionKeyHandler extends KeyHandler {
|
|
5
5
|
onDown(event: GridKeyboardEvent, grid: Grid): EventHandlerResult;
|
|
6
6
|
handleArrowMove(deltaColumn: number, deltaRow: number, event: GridKeyboardEvent, grid: Grid): boolean;
|
|
7
|
+
handleRowEdge(targetColumn: number, event: GridKeyboardEvent, grid: Grid): boolean;
|
|
7
8
|
handlePageUp(e: GridKeyboardEvent, grid: Grid): boolean;
|
|
8
9
|
handlePageDown(e: GridKeyboardEvent, grid: Grid): boolean;
|
|
9
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionKeyHandler.d.ts","sourceRoot":"","sources":["../../src/key-handlers/SelectionKeyHandler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"SelectionKeyHandler.d.ts","sourceRoot":"","sources":["../../src/key-handlers/SelectionKeyHandler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAKhC,OAAO,UAAU,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEnE,cAAM,mBAAoB,SAAQ,UAAU;IAC1C,MAAM,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,GAAG,kBAAkB;IAkHhE,eAAe,CACb,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,iBAAiB,EACxB,IAAI,EAAE,IAAI,GACT,OAAO;IA+EV,aAAa,CACX,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,iBAAiB,EACxB,IAAI,EAAE,IAAI,GACT,OAAO;IAWV,YAAY,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO;IASvD,cAAc,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO;CAQ1D;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
import clamp from 'lodash.clamp';
|
|
3
3
|
import GridRange from "../GridRange.js";
|
|
4
4
|
import GridUtils from "../GridUtils.js";
|
|
5
|
+
import { gestureModeFromModifiers } from "../GridSelectionUtils.js";
|
|
5
6
|
import KeyHandler from "../KeyHandler.js";
|
|
6
7
|
class SelectionKeyHandler extends KeyHandler {
|
|
7
8
|
onDown(event, grid) {
|
|
9
|
+
var isShiftKey = event.shiftKey;
|
|
10
|
+
var isModifierKey = GridUtils.isModifierKeyDown(event);
|
|
8
11
|
switch (event.key) {
|
|
9
12
|
case 'a':
|
|
10
|
-
if (
|
|
13
|
+
if (isModifierKey) {
|
|
11
14
|
grid.selectAll();
|
|
12
15
|
return true;
|
|
13
16
|
}
|
|
@@ -28,55 +31,65 @@ class SelectionKeyHandler extends KeyHandler {
|
|
|
28
31
|
*/
|
|
29
32
|
case 'k':
|
|
30
33
|
case 'K':
|
|
31
|
-
if (
|
|
34
|
+
if (isModifierKey) return false;
|
|
32
35
|
return this.handlePageUp(event, grid);
|
|
33
36
|
case 'j':
|
|
34
37
|
case 'J':
|
|
35
|
-
if (
|
|
38
|
+
if (isModifierKey) return false;
|
|
36
39
|
return this.handlePageDown(event, grid);
|
|
37
40
|
case 'h':
|
|
38
41
|
case 'H':
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
grid.moveCursorToPosition(0, grid.state.cursorRow, event.shiftKey);
|
|
44
|
-
return true;
|
|
42
|
+
if (isModifierKey) return false;
|
|
43
|
+
// In row-selection mode, column-edge movement is meaningless.
|
|
44
|
+
if (grid.props.theme.autoSelectRow === true) return true;
|
|
45
|
+
return this.handleRowEdge(0, event, grid);
|
|
45
46
|
case 'l':
|
|
46
47
|
case 'L':
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var columnCount = model.columnCount;
|
|
51
|
-
if (!event.shiftKey) {
|
|
52
|
-
grid.clearSelectedRanges();
|
|
53
|
-
}
|
|
54
|
-
grid.moveCursorToPosition(columnCount - 1, grid.state.cursorRow, event.shiftKey);
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
48
|
+
if (isModifierKey) return false;
|
|
49
|
+
if (grid.props.theme.autoSelectRow === true) return true;
|
|
50
|
+
return this.handleRowEdge(grid.props.model.columnCount - 1, event, grid);
|
|
57
51
|
case 'PageDown':
|
|
58
52
|
return this.handlePageDown(event, grid);
|
|
59
53
|
case 'PageUp':
|
|
60
54
|
return this.handlePageUp(event, grid);
|
|
61
55
|
case 'Home':
|
|
62
|
-
if (!event.shiftKey) {
|
|
63
|
-
grid.clearSelectedRanges();
|
|
64
|
-
}
|
|
65
|
-
grid.moveCursorToPosition(GridUtils.isModifierKeyDown(event) ? grid.state.cursorColumn : 0, GridUtils.isModifierKeyDown(event) ? 0 : grid.state.cursorRow, event.shiftKey, true, true);
|
|
66
|
-
return true;
|
|
67
56
|
case 'End':
|
|
68
57
|
{
|
|
69
|
-
var
|
|
70
|
-
var
|
|
71
|
-
rowCount =
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
var model = grid.props.model;
|
|
59
|
+
var columnCount = model.columnCount,
|
|
60
|
+
rowCount = model.rowCount;
|
|
61
|
+
var _grid$state$selection = grid.state.selection,
|
|
62
|
+
cursorColumn = _grid$state$selection.cursorColumn,
|
|
63
|
+
cursorRow = _grid$state$selection.cursorRow;
|
|
64
|
+
var toEnd = event.key === 'End';
|
|
65
|
+
// In row-selection mode, plain / Shift Home/End would only move the
|
|
66
|
+
// cursor between columns and (via commit) toggle the row selection.
|
|
67
|
+
// Ctrl+Home/End still jumps to top/bottom row, which is meaningful.
|
|
68
|
+
if (grid.props.theme.autoSelectRow === true && !isModifierKey) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
// Ctrl/Meta pins the column and jumps to the row edge; without it
|
|
72
|
+
// Home/End jumps to the column edge on the current row.
|
|
73
|
+
var targetColumn;
|
|
74
|
+
var targetRow;
|
|
75
|
+
if (isModifierKey) {
|
|
76
|
+
targetColumn = cursorColumn;
|
|
77
|
+
targetRow = toEnd ? rowCount - 1 : 0;
|
|
78
|
+
} else {
|
|
79
|
+
targetColumn = toEnd ? columnCount - 1 : 0;
|
|
80
|
+
targetRow = cursorRow;
|
|
74
81
|
}
|
|
75
|
-
|
|
82
|
+
if (targetColumn == null || targetRow == null) return false;
|
|
83
|
+
// Shift extends via maximize (grow the last range's furthest edge)
|
|
84
|
+
// to preserve pre-refactor Shift+Home followed by Shift+End behavior.
|
|
85
|
+
grid.handleKeySelectAt({
|
|
86
|
+
column: targetColumn,
|
|
87
|
+
row: targetRow
|
|
88
|
+
}, isShiftKey ? 'maximize' : 'replace');
|
|
76
89
|
return true;
|
|
77
90
|
}
|
|
78
91
|
case 'Escape':
|
|
79
|
-
if (grid.state.
|
|
92
|
+
if (grid.state.selection.isEmpty()) return false;
|
|
80
93
|
grid.clearSelectedRanges();
|
|
81
94
|
// consume the event, and stop propagation only if there were selected ranges to clear
|
|
82
95
|
return {
|
|
@@ -84,14 +97,14 @@ class SelectionKeyHandler extends KeyHandler {
|
|
|
84
97
|
stopPropagation: true
|
|
85
98
|
};
|
|
86
99
|
case 'Enter':
|
|
87
|
-
if (grid.state.
|
|
88
|
-
grid.
|
|
100
|
+
if (!grid.state.selection.isEmpty()) {
|
|
101
|
+
grid.handleKeyAdvanceCursor(isShiftKey ? GridRange.SELECTION_DIRECTION.UP : GridRange.SELECTION_DIRECTION.DOWN);
|
|
89
102
|
return true;
|
|
90
103
|
}
|
|
91
104
|
break;
|
|
92
105
|
case 'Tab':
|
|
93
|
-
if (grid.state.
|
|
94
|
-
grid.
|
|
106
|
+
if (!grid.state.selection.isEmpty()) {
|
|
107
|
+
grid.handleKeyAdvanceCursor(isShiftKey ? GridRange.SELECTION_DIRECTION.LEFT : GridRange.SELECTION_DIRECTION.RIGHT);
|
|
95
108
|
return true;
|
|
96
109
|
}
|
|
97
110
|
break;
|
|
@@ -103,137 +116,130 @@ class SelectionKeyHandler extends KeyHandler {
|
|
|
103
116
|
handleArrowMove(deltaColumn, deltaRow, event, grid) {
|
|
104
117
|
var isShiftKey = event.shiftKey;
|
|
105
118
|
var isModifierKey = GridUtils.isModifierKeyDown(event);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
var _grid$state = grid.state,
|
|
112
|
-
cursorRow = _grid$state.cursorRow,
|
|
113
|
-
cursorColumn = _grid$state.cursorColumn,
|
|
114
|
-
selectionEndColumn = _grid$state.selectionEndColumn,
|
|
115
|
-
selectionEndRow = _grid$state.selectionEndRow;
|
|
119
|
+
var _grid$state$selection2 = grid.state.selection,
|
|
120
|
+
cursorRow = _grid$state$selection2.cursorRow,
|
|
121
|
+
cursorColumn = _grid$state$selection2.cursorColumn,
|
|
122
|
+
selectionEndColumn = _grid$state$selection2.selectionEndColumn,
|
|
123
|
+
selectionEndRow = _grid$state$selection2.selectionEndRow;
|
|
116
124
|
var column = isShiftKey ? selectionEndColumn : cursorColumn;
|
|
117
125
|
var row = isShiftKey ? selectionEndRow : cursorRow;
|
|
126
|
+
|
|
127
|
+
// Ctrl+Arrow is an exception to the mode returned by gestureModeFromModifiers
|
|
128
|
+
// It jumps to the edge of the grid in the arrow direction, and replaces the selection.
|
|
118
129
|
if (isModifierKey) {
|
|
119
|
-
var
|
|
120
|
-
var
|
|
121
|
-
|
|
122
|
-
var maximizePreviousRange = isModifierKey && isShiftKey;
|
|
130
|
+
var _model = grid.props.model;
|
|
131
|
+
var _columnCount = _model.columnCount,
|
|
132
|
+
_rowCount = _model.rowCount;
|
|
123
133
|
var moveToColumn = null;
|
|
124
134
|
var moveToRow = null;
|
|
125
135
|
if (deltaColumn < 0) {
|
|
126
136
|
moveToColumn = 0;
|
|
127
137
|
moveToRow = row;
|
|
128
138
|
} else if (deltaColumn > 0) {
|
|
129
|
-
moveToColumn =
|
|
139
|
+
moveToColumn = _columnCount - 1;
|
|
130
140
|
moveToRow = row;
|
|
131
141
|
} else if (deltaRow < 0) {
|
|
132
142
|
moveToColumn = column;
|
|
133
143
|
moveToRow = 0;
|
|
134
144
|
} else if (deltaRow > 0) {
|
|
135
145
|
moveToColumn = column;
|
|
136
|
-
moveToRow =
|
|
146
|
+
moveToRow = _rowCount - 1;
|
|
137
147
|
}
|
|
138
148
|
if (moveToColumn != null && moveToRow != null) {
|
|
139
|
-
grid.
|
|
149
|
+
grid.handleKeySelectAt({
|
|
150
|
+
column: moveToColumn,
|
|
151
|
+
row: moveToRow
|
|
152
|
+
}, isShiftKey ? 'maximize' : 'replace');
|
|
140
153
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
grid.moveCursorToPosition(top, cursorColumn, isShiftKey, false);
|
|
161
|
-
grid.setViewState({
|
|
162
|
-
top
|
|
163
|
-
});
|
|
164
|
-
} else {
|
|
165
|
-
grid.moveCursor(deltaColumn, deltaRow, isShiftKey);
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
if (!grid.metrics) throw new Error('grid.metrics are not set');
|
|
157
|
+
|
|
158
|
+
// Plain / Shift arrows: mode is derived from Shift alone here since `isModifierKey` was short-circuited above.
|
|
159
|
+
var mode = gestureModeFromModifiers({
|
|
160
|
+
isShiftKey,
|
|
161
|
+
isModifierKey: false
|
|
162
|
+
});
|
|
163
|
+
var theme = grid.props.theme;
|
|
164
|
+
var _theme$autoSelectRow = theme.autoSelectRow,
|
|
165
|
+
autoSelectRow = _theme$autoSelectRow === void 0 ? false : _theme$autoSelectRow,
|
|
166
|
+
_theme$autoSelectColu = theme.autoSelectColumn,
|
|
167
|
+
autoSelectColumn = _theme$autoSelectColu === void 0 ? false : _theme$autoSelectColu;
|
|
168
|
+
if (autoSelectRow && deltaColumn !== 0) {
|
|
169
|
+
var lastLeft = grid.metrics.lastLeft;
|
|
170
|
+
var left = clamp(grid.state.left + deltaColumn, 0, lastLeft);
|
|
171
|
+
if (cursorRow != null) {
|
|
172
|
+
grid.handleKeyMoveCursor(left, cursorRow);
|
|
166
173
|
}
|
|
174
|
+
grid.setViewState({
|
|
175
|
+
left
|
|
176
|
+
});
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
if (autoSelectColumn && deltaRow !== 0) {
|
|
180
|
+
var lastTop = grid.metrics.lastTop;
|
|
181
|
+
var top = clamp(grid.state.top + deltaRow, 0, lastTop);
|
|
182
|
+
// Preserves the (arguably surprising) original behavior of using `top`
|
|
183
|
+
// as the column argument; kept identical to pre-refactor code paths.
|
|
184
|
+
grid.handleKeySelectAt({
|
|
185
|
+
column: top,
|
|
186
|
+
row: cursorColumn
|
|
187
|
+
}, mode, {
|
|
188
|
+
keepCursorInView: false
|
|
189
|
+
});
|
|
190
|
+
grid.setViewState({
|
|
191
|
+
top
|
|
192
|
+
});
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
if (row === null || column === null) {
|
|
196
|
+
var _grid$state = grid.state,
|
|
197
|
+
_left = _grid$state.left,
|
|
198
|
+
_top = _grid$state.top;
|
|
199
|
+
grid.handleKeySelectAt({
|
|
200
|
+
column: _left,
|
|
201
|
+
row: _top
|
|
202
|
+
}, mode);
|
|
203
|
+
return true;
|
|
167
204
|
}
|
|
205
|
+
var model = grid.props.model;
|
|
206
|
+
var columnCount = model.columnCount,
|
|
207
|
+
rowCount = model.rowCount;
|
|
208
|
+
var targetColumn = clamp(column + deltaColumn, 0, columnCount - 1);
|
|
209
|
+
var targetRow = clamp(row + deltaRow, 0, rowCount - 1);
|
|
210
|
+
grid.handleKeySelectAt({
|
|
211
|
+
column: targetColumn,
|
|
212
|
+
row: targetRow
|
|
213
|
+
}, mode);
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
handleRowEdge(targetColumn, event, grid) {
|
|
217
|
+
var isShiftKey = event.shiftKey;
|
|
218
|
+
var cursorRow = grid.state.selection.cursorRow;
|
|
219
|
+
if (cursorRow == null) return false;
|
|
220
|
+
grid.handleKeySelectAt({
|
|
221
|
+
column: targetColumn,
|
|
222
|
+
row: cursorRow
|
|
223
|
+
}, gestureModeFromModifiers({
|
|
224
|
+
isShiftKey,
|
|
225
|
+
isModifierKey: false
|
|
226
|
+
}));
|
|
168
227
|
return true;
|
|
169
228
|
}
|
|
170
229
|
handlePageUp(e, grid) {
|
|
171
|
-
var
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
} else {
|
|
175
|
-
grid.clearSelectedRanges();
|
|
176
|
-
}
|
|
177
|
-
var _grid$state2 = grid.state,
|
|
178
|
-
cursorColumn = _grid$state2.cursorColumn,
|
|
179
|
-
selectionEndRow = _grid$state2.selectionEndRow;
|
|
180
|
-
var row = selectionEndRow;
|
|
181
|
-
var column = cursorColumn;
|
|
182
|
-
if (row == null) {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
var metricState = grid.getMetricState();
|
|
186
|
-
var metricCalculator = grid.metricCalculator;
|
|
187
|
-
var _metricCalculator$get = metricCalculator.getMetrics(metricState),
|
|
188
|
-
bottomVisible = _metricCalculator$get.bottomVisible,
|
|
189
|
-
topVisible = _metricCalculator$get.topVisible,
|
|
190
|
-
hasHorizontalBar = _metricCalculator$get.hasHorizontalBar;
|
|
191
|
-
var selectRangeEndPosition = row - (bottomVisible - topVisible);
|
|
192
|
-
selectRangeEndPosition -= hasHorizontalBar ? 0 : 1;
|
|
193
|
-
|
|
194
|
-
// Don't move beyond the top table row.
|
|
195
|
-
selectRangeEndPosition = Math.max(selectRangeEndPosition, 0);
|
|
196
|
-
var viewportPosition = Math.max(selectRangeEndPosition - (row - topVisible), 0);
|
|
197
|
-
grid.moveCursorToPosition(column, selectRangeEndPosition, isShiftKey, false);
|
|
198
|
-
grid.setViewState({
|
|
199
|
-
top: viewportPosition
|
|
230
|
+
var mode = gestureModeFromModifiers({
|
|
231
|
+
isShiftKey: e.shiftKey,
|
|
232
|
+
isModifierKey: false
|
|
200
233
|
});
|
|
234
|
+
grid.handleKeyPageUp(mode);
|
|
201
235
|
return true;
|
|
202
236
|
}
|
|
203
237
|
handlePageDown(e, grid) {
|
|
204
|
-
var
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
} else {
|
|
208
|
-
grid.clearSelectedRanges();
|
|
209
|
-
}
|
|
210
|
-
var _grid$state3 = grid.state,
|
|
211
|
-
selectionEndRow = _grid$state3.selectionEndRow,
|
|
212
|
-
cursorColumn = _grid$state3.cursorColumn;
|
|
213
|
-
var row = selectionEndRow;
|
|
214
|
-
var column = cursorColumn;
|
|
215
|
-
if (row === null) {
|
|
216
|
-
return false;
|
|
217
|
-
}
|
|
218
|
-
var metricState = grid.getMetricState();
|
|
219
|
-
var metricCalculator = grid.metricCalculator;
|
|
220
|
-
var _metricCalculator$get2 = metricCalculator.getMetrics(metricState),
|
|
221
|
-
bottomVisible = _metricCalculator$get2.bottomVisible,
|
|
222
|
-
topVisible = _metricCalculator$get2.topVisible,
|
|
223
|
-
hasHorizontalBar = _metricCalculator$get2.hasHorizontalBar,
|
|
224
|
-
rowCount = _metricCalculator$get2.rowCount,
|
|
225
|
-
lastTop = _metricCalculator$get2.lastTop;
|
|
226
|
-
var lastRowIndex = rowCount - 1;
|
|
227
|
-
var selectRangeEndPosition = bottomVisible - topVisible + row;
|
|
228
|
-
selectRangeEndPosition += hasHorizontalBar ? 0 : 1;
|
|
229
|
-
|
|
230
|
-
// Don't move beyond the bottom table row.
|
|
231
|
-
selectRangeEndPosition = Math.min(selectRangeEndPosition, lastRowIndex);
|
|
232
|
-
var viewportPosition = Math.min(lastTop, selectRangeEndPosition - (row - topVisible));
|
|
233
|
-
grid.moveCursorToPosition(column, selectRangeEndPosition, isShiftKey, false);
|
|
234
|
-
grid.setViewState({
|
|
235
|
-
top: viewportPosition
|
|
238
|
+
var mode = gestureModeFromModifiers({
|
|
239
|
+
isShiftKey: e.shiftKey,
|
|
240
|
+
isModifierKey: false
|
|
236
241
|
});
|
|
242
|
+
grid.handleKeyPageDown(mode);
|
|
237
243
|
return true;
|
|
238
244
|
}
|
|
239
245
|
}
|