@omnigrid/selection-plugin 0.1.4 → 0.1.6

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 (3) hide show
  1. package/README.md +54 -54
  2. package/dist/index.js +7 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,54 +1,54 @@
1
- # @omnigrid/selection-plugin
2
-
3
- Headless row/column selection plugin for OmniGrid.
4
-
5
- ## What it provides
6
-
7
- - Row selection (single, multi, range, checkbox toggle)
8
- - Disabled rows marked by `isRowSelectable` with the `omnigrid-row-unselectable` class
9
- - Cell selection with range drag
10
- - Keyboard navigation support (Shift+Click, Ctrl+Click)
11
- - API to read/modify selection state programmatically
12
-
13
- ## Styling
14
-
15
- Selected rows receive the `omnigrid-row-selected` CSS class. The plugin does
16
- **not** set inline colors — the concrete selected-row color is owned by the
17
- active theme (for example, `@omnigrid/default-theme` and `@omnigrid/mint-theme`
18
- define `--omnigrid-cell-selected-background` and `--omnigrid-checkbox-accent`
19
- for light and dark modes). Rows rejected by `isRowSelectable` receive
20
- `omnigrid-row-unselectable` and use theme-provided muted background and text
21
- colors via `--omnigrid-cell-unselectable-background` and
22
- `--omnigrid-cell-unselectable-color`.
23
-
24
- ## Usage
25
-
26
- ```ts
27
- import { SelectionPlugin } from "@omnigrid/selection-plugin";
28
-
29
- const plugin = new SelectionPlugin({
30
- mode: "multiple",
31
- onSelectionChange: ({ selectedRowIds, selectedRows }) => {
32
- console.log("Selected count:", selectedRows.length);
33
- console.log("Selected IDs:", selectedRowIds);
34
- console.log("Selected records:", selectedRows);
35
- },
36
- });
37
-
38
- // Read the current selection at any time:
39
- const selection = plugin.getSelectionState();
40
- ```
41
-
42
- `onSelectionChange` runs when selection changes and receives the current row
43
- IDs and row records. `getSelectedRowIds()`, `getSelectedRows()`, and
44
- `getSelectionState()` provide synchronous access to the current selection.
45
-
46
- ## Links
47
-
48
- - **Source:** https://github.com/KRZK-Apps/omnigrid/tree/main/plugins/base/selection
49
- - **Demo:** https://omnigrid-demo.vercel.app/
50
- - **Issues:** https://github.com/KRZK-Apps/omnigrid/issues
51
-
52
- ## License
53
-
54
- MIT © KRZK Apps
1
+ # @omnigrid/selection-plugin
2
+
3
+ Headless row/column selection plugin for OmniGrid.
4
+
5
+ ## What it provides
6
+
7
+ - Row selection (single, multi, range, checkbox toggle)
8
+ - Disabled rows marked by `isRowSelectable` with the `omnigrid-row-unselectable` class
9
+ - Cell selection with range drag
10
+ - Keyboard navigation support (Shift+Click, Ctrl+Click)
11
+ - API to read/modify selection state programmatically
12
+
13
+ ## Styling
14
+
15
+ Selected rows receive the `omnigrid-row-selected` CSS class. The plugin does
16
+ **not** set inline colors — the concrete selected-row color is owned by the
17
+ active theme (for example, `@omnigrid/default-theme` and `@omnigrid/mint-theme`
18
+ define `--omnigrid-cell-selected-background` and `--omnigrid-checkbox-accent`
19
+ for light and dark modes). Rows rejected by `isRowSelectable` receive
20
+ `omnigrid-row-unselectable` and use theme-provided muted background and text
21
+ colors via `--omnigrid-cell-unselectable-background` and
22
+ `--omnigrid-cell-unselectable-color`.
23
+
24
+ ## Usage
25
+
26
+ ```ts
27
+ import { SelectionPlugin } from "@omnigrid/selection-plugin";
28
+
29
+ const plugin = new SelectionPlugin({
30
+ mode: "multiple",
31
+ onSelectionChange: ({ selectedRowIds, selectedRows }) => {
32
+ console.log("Selected count:", selectedRows.length);
33
+ console.log("Selected IDs:", selectedRowIds);
34
+ console.log("Selected records:", selectedRows);
35
+ },
36
+ });
37
+
38
+ // Read the current selection at any time:
39
+ const selection = plugin.getSelectionState();
40
+ ```
41
+
42
+ `onSelectionChange` runs when selection changes and receives the current row
43
+ IDs and row records. `getSelectedRowIds()`, `getSelectedRows()`, and
44
+ `getSelectionState()` provide synchronous access to the current selection.
45
+
46
+ ## Links
47
+
48
+ - **Source:** https://github.com/KRZK-Apps/omnigrid/tree/main/plugins/base/selection
49
+ - **Demo:** https://omnigrid-demo.vercel.app/
50
+ - **Issues:** https://github.com/KRZK-Apps/omnigrid/issues
51
+
52
+ ## License
53
+
54
+ MIT © KRZK Apps
package/dist/index.js CHANGED
@@ -33,6 +33,12 @@ export class SelectionPlugin {
33
33
  return () => {
34
34
  this.unregisterRowClick?.();
35
35
  this.unregisterRowClick = undefined;
36
+ const api = this.api;
37
+ if (api && !api.isDestroyed()) {
38
+ api.setColumns(api.getState().columns.filter((column) => column.id !== this.selectionColumnId));
39
+ }
40
+ this.selectedRowIds.clear();
41
+ this.anchorIndex = undefined;
36
42
  this.api = undefined;
37
43
  };
38
44
  }
@@ -247,7 +253,7 @@ export class SelectionPlugin {
247
253
  refresh() {
248
254
  if (!this.api || this.api.isDestroyed())
249
255
  return;
250
- this.api.setData(this.api.getState().data);
256
+ this.api.refresh();
251
257
  this.onSelectionChange?.(this.getSelectionState());
252
258
  }
253
259
  validateSelection() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnigrid/selection-plugin",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Headless row selection plugin for OmniGrid",
5
5
  "keywords": [
6
6
  "omnigrid",