@apia/table 4.0.1 → 4.0.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.
package/dist/index.d.ts CHANGED
@@ -676,7 +676,7 @@ declare class Controller2 {
676
676
  setRef: (el: HTMLElement) => void;
677
677
  handleClickEvent: (ev: MouseEvent) => void;
678
678
  handleKeyDownEvent: (ev: KeyboardEvent) => void;
679
- handleDoubleClickEvent: () => void;
679
+ handleDoubleClickEvent: (ev: MouseEvent) => void;
680
680
  /**
681
681
  * Returns a copy of the current state object
682
682
  */
package/dist/index.js CHANGED
@@ -3342,14 +3342,28 @@ class Controller2 {
3342
3342
  });
3343
3343
  __publicField(this, "handleClickEvent");
3344
3344
  __publicField(this, "handleKeyDownEvent");
3345
- __publicField(this, "handleDoubleClickEvent", () => {
3346
- this.events.onSelectRows?.(
3347
- this.getSelection().map((index) => ({
3348
- index,
3349
- row: this.getState().rows[index]
3350
- })),
3351
- this.getState().focusedRow
3352
- );
3345
+ __publicField(this, "handleDoubleClickEvent", (ev) => {
3346
+ const target = ev.target;
3347
+ if (target instanceof HTMLElement) {
3348
+ const row = target.closest("tr");
3349
+ const table = target.closest("table");
3350
+ const selectedRows = this.getSelection().reduce((acc, index) => {
3351
+ if (index >= 0) {
3352
+ acc.push({
3353
+ index,
3354
+ row: this.getState().rows[index]
3355
+ });
3356
+ }
3357
+ return acc;
3358
+ }, []);
3359
+ const rowIndex = noNaN(row?.dataset.rowindex || "a", -1);
3360
+ if (row && table && selectedRows.length > 0 && rowIndex >= 0) {
3361
+ this.events.onSelectRows?.(
3362
+ selectedRows,
3363
+ this.getState().focusedRow
3364
+ );
3365
+ }
3366
+ }
3353
3367
  });
3354
3368
  this.handleClickEvent = handleMouseDownEvent.bind(this);
3355
3369
  this.handleKeyDownEvent = handleKeyDownEvent.bind(this);