@omnigrid/selection-plugin 0.1.7 → 0.1.9

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
@@ -25,7 +25,7 @@ export class SelectionPlugin {
25
25
  this.checkboxRenderer = options.checkboxRenderer ?? defaultCheckboxRenderer;
26
26
  this.onSelectionChange = options.onSelectionChange;
27
27
  this.selectionColumnId = options.selectionColumnId ?? CHECKBOX_COLUMN_DEFAULT_ID;
28
- this.selectionColumnWidth = options.selectionColumnWidth ?? 44;
28
+ this.selectionColumnWidth = options.selectionColumnWidth ?? 36;
29
29
  }
30
30
  register(api) {
31
31
  this.api = api;
@@ -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),
@@ -310,6 +312,7 @@ export class SelectionPlugin {
310
312
  width: this.selectionColumnWidth,
311
313
  minWidth: this.selectionColumnWidth,
312
314
  maxWidth: this.selectionColumnWidth,
315
+ align: "center",
313
316
  sortable: false,
314
317
  stopHeaderClick: true,
315
318
  stopRowClick: true,
package/dist/types.d.ts CHANGED
@@ -40,7 +40,7 @@ export interface SelectionPluginOptions<T> {
40
40
  onSelectionChange?: (state: SelectionState<T>) => void;
41
41
  /** ID for the automatically inserted checkbox column. @default "__omnigrid_selection__" */
42
42
  selectionColumnId?: string;
43
- /** Width in pixels of the automatically inserted checkbox column. @default 44 */
43
+ /** Width in pixels of the automatically inserted checkbox column. @default 36 */
44
44
  selectionColumnWidth?: number;
45
45
  }
46
46
  /** Selected row identifiers and their corresponding row data. */
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.9",
4
4
  "description": "Headless row selection plugin for OmniGrid",
5
5
  "keywords": [
6
6
  "omnigrid",