@omnigrid/selection-plugin 0.1.7 → 0.1.8

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/index.d.ts CHANGED
@@ -69,7 +69,7 @@ export declare class SelectionPlugin<T> implements GridPlugin<T> {
69
69
  ctrlKey?: boolean;
70
70
  }): void;
71
71
  /** Returns selection-related CSS classes for a row. */
72
- getRowClass({ id, index, data }: RowRenderParams<T>): string | undefined;
72
+ getRowClass(params: RowRenderParams<T>): string | undefined;
73
73
  private handleRowClick;
74
74
  private toggleStableRow;
75
75
  private getRowByStableId;
package/dist/index.js CHANGED
@@ -131,7 +131,9 @@ export class SelectionPlugin {
131
131
  this.applySelection(rowId, index, modifiers);
132
132
  }
133
133
  /** Returns selection-related CSS classes for a row. */
134
- getRowClass({ id, index, data }) {
134
+ getRowClass(params) {
135
+ const { id, index } = params;
136
+ const data = params.rowType === "leaf" ? params.data : undefined;
135
137
  const checkboxState = this.getCheckboxState(id, index, data);
136
138
  const classes = [];
137
139
  if (checkboxState.group) {
@@ -145,7 +147,7 @@ export class SelectionPlugin {
145
147
  else {
146
148
  if (this.selectedRowIds.has(id))
147
149
  classes.push(SELECTED_ROW_CLASS);
148
- if (!this.isRowSelectable(data, index))
150
+ if (data !== undefined && !this.isRowSelectable(data, index))
149
151
  classes.push(UNSELECTABLE_ROW_CLASS);
150
152
  }
151
153
  return classes.length > 0 ? classes.join(" ") : undefined;
@@ -205,7 +207,7 @@ export class SelectionPlugin {
205
207
  const allDescendants = hierarchy?.getLeafRowIds(rowId, "all");
206
208
  const isGroup = allDescendants !== undefined;
207
209
  if (!isGroup) {
208
- const row = hierarchy ? this.getRowByStableId(rowId) : { data, index };
210
+ const row = hierarchy ? this.getRowByStableId(rowId) : data !== undefined ? { data, index } : undefined;
209
211
  const selectable = row !== undefined && this.isRowSelectable(row.data, row.index);
210
212
  return {
211
213
  checked: this.selectedRowIds.has(rowId),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnigrid/selection-plugin",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Headless row selection plugin for OmniGrid",
5
5
  "keywords": [
6
6
  "omnigrid",