Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jassmith committed Mar 20, 2022
1 parent 1074d01 commit 7180ad1
Showing 1 changed file with 41 additions and 20 deletions.
61 changes: 41 additions & 20 deletions packages/core/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,21 @@ Most data grids will want to set the majority of these props one way or another.
| [gridSelection](#gridselection) | The current selection active in the data grid. Includes both the selection cell and the selected range. |
| [spanRangeBehavior](#spanrangebehavior) | Determines if the `gridSelection` should allow partial spans or not. |
| [onGridSelectionChange](#gridselection) | Emitted whenever the `gridSelection` should change. |
| [onSelectedColumnsChange](#selectedcolumns) | Emitted whenever the `selectedColumns` should change. |
| [onSelectedRowsChange](#selectedrows) | Emitted whenever the `selectedRows` should change. |
| [onSelectionCleared](#onselectioncleared) | Emitted when the selection is explicitly cleared. |
| [selectedColumns](#selectedcolumns) | The currently selected columns. |
| [selectedRows](#selectedrows) | The currently selected rows. |
| [rangeMultiSelect](#rangemultiselect) | Controls if multiple ranges can be selected at once. |
| [columnMultiSelect](#rangemultiselect) | Controls if multiple columns can be selected at once. |
| [rowMultiSelect](#rangemultiselect) | Controls if multiple rows can be selected at aonce. |
| [rangeSelectionBlending](#rangeselectionblending) | Controls how range selections may be mixed with other selection types. |
| [columnSelectionBlending](#rangeselectionblending) | Controls how column selections may be mixed with other selection types. |
| [rowSelectionBlending](#rangeselectionblending) | Controls how row selections may be mixed with other selection types. |
| [onDelete](#ondelete) | Emitted when the user attempst to delete the current selection. |

## Editing
| Name | Description |
|------------|-----------------------|
| [imageEditorOverride](#imageeditoroverride) | Used to provide an override to the default image editor for the data grid. `provideEditor` may be a better choice for most people. |
| [onCellEdited](#oncelledited) | Emitted whenever a cell edit is completed. |
| [onDeleteRows](#ondeleterows) | Emitted whenever the user has requested the deletion of rows. |
| [onDelete](#ondelete) | Emitted whenever the user has requested the deletion of the selection. |
| [onFinishedEditing](#onfinishedediting) | Emitted when editing has finished, regardless of data changing or not. |
| [onGroupHeaderRenamed](#ongroupheaderrenamed) | Emitted whe the user wishes to rename a group. |
| [onPaste](#onpaste) | Emitted any time data is pasted to the grid. Allows controlling paste behavior. |
Expand Down Expand Up @@ -232,12 +235,19 @@ export type GridColumn = SizedGridColumn | AutoGridColumn;
---
## GridSelection

`GridSelection` is the most basic representation of the selected cells in the data grid. It accounts for the selected cell and the range of cells selected as well. It is the selection which is modified by keyboard and mouse interaction when clicking on the cells themselves.
`GridSelection` is the most basic representation of the selected cells, rows, and columns in the data grid. The `current` property accounts for the selected cell and the range of cells selected as well. It is the selection which is modified by keyboard and mouse interaction when clicking on the cells themselves.

The `rows` and `columns` properties both account for the columns or rows which have been explicitly selected by the user. Selecting a range which encompases the entire set of cells within a column/row does not implicitly set it into this part of the collection. This allows for distinguishing between cases when the user wishes to delete all contents of a row/column and delete the row/column itself.

```ts
interface GridSelection {
readonly cell: readonly [number, number];
readonly range: Readonly<Rectangle>;
readonly current?: {
readonly cell: readonly [number, number];
readonly range: Readonly<Rectangle>;
readonly rangeStack: readonly Readonly<Rectangle>[];
};
readonly columns: CompactSelection;
readonly rows: CompactSelection;
}
```

Expand Down Expand Up @@ -357,7 +367,7 @@ Set to a positive number to freeze columns on the left side of the grid during h
## getCellsForSelection

```ts
getCellsForSelection?: (selection: GridSelection) => readonly (readonly GridCell[])[];
getCellsForSelection?: (selection: Rectangle) => readonly (readonly GridCell[])[];
```

`getCellsForSelection` is called when the user copies a selection to the clipboard or the data editor needs to inspect data which may be outside the curently visible range. It must return a two-dimensional array (an array of rows, where each row is an array of cells) of the cells in the selection's rectangle. Note that the rectangle can include cells that are not currently visible.
Expand Down Expand Up @@ -606,33 +616,44 @@ If set to `default` the `gridSelection` will always be expanded to fully include
If `allowPartial` is set no inflation behavior will be enforced.

---
## selectedColumns
## onSelectionCleared

```ts
readonly selectedColumns?: CompactSelection;
readonly onSelectedColumnsChange?: (newColumns: CompactSelection, trigger: HeaderSelectionTrigger) => void;
onSelectionCleared?: () => void;
```

Controls header selection. If not provided default header selection behavior will be applied.
Emitted when the current selection is cleared, usually when the user presses "Escape". `rowSelection`, `columnSelection`, and `gridSelection` should all be empty when this event is emitted. This event only emits when the user explicitly attempts to clear the selection.

---
## selectedRows
## rangeMultiSelect

```ts
readonly selectedRows?: CompactSelection;
readonly onSelectedRowsChange?: (newRows: CompactSelection) => void;
rangeMultiSelect?: boolean; // default false
columnMultiSelect?: boolean; // default true
rowMultiSelect?: boolean; // default true
```

Controls row selection. If not provided default row selection behavior will be applied.
Controls if multi-selection is allowed. If disabled, shift/ctrl/command clicking will work as if no modifiers are pressed.

---
## onSelectionCleared
## rangeSelectionBlending

```ts
onSelectionCleared?: () => void;
rangeSelectionBlending?: "exclusive" | "mixed"; // default exclusive
columnSelectionBlending?: "exclusive" | "mixed"; // default exclusive
rowSelectionBlending?: "exclusive" | "mixed"; // default exclusive
```

Emitted when the current selection is cleared, usually when the user presses "Escape". `rowSelection`, `columnSelection`, and `gridSelection` should all be empty when this event is emitted. This event only emits when the user explicitly attempts to clear the selection.
Controls which types of selections can exist at the same time in the grid. If selection blending is set to exclusive, the grid will clear other types of selections when the exclusive selection is made. By default row, column, and range selections are exclusive.

---
## onDelete

```ts
onDelete?: (selection: GridSelection) => GridSelection | boolean;
```

`onDelete` is called when the user deletes one or more rows. `gridSelection` is current selection. If the callback returns false, deletion will not happen. If it returns true, all cells inside all selected rows, columns and ranges will be deleted. If the callback returns a GridSelection, the newly returned selection will be deleted instead.

---
## imageEditorOverride
Expand Down

0 comments on commit 7180ad1

Please sign in to comment.