@taocompany/magic-grid 0.6.2 → 0.6.4

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.es.js CHANGED
@@ -355,7 +355,10 @@ function Ie(e) {
355
355
  clearCellValidation: (t) => e.clearCellValidation(t),
356
356
  toggleRowSelection: (t, n, r) => e.toggleRowSelection(t, n, r),
357
357
  toggleAllSelection: (t) => e.toggleAllSelection(t),
358
- setIndexFocus: (t) => e.setIndexFocus(t),
358
+ clearRowSelection: (t) => e.clearRowSelection(t),
359
+ getSelectedRowIds: () => e.getSelectedRowIds(),
360
+ getIndexFocusedRowIds: () => e.getIndexFocusedRowIds(),
361
+ setIndexFocus: (t, n) => e.setIndexFocus(t, n),
359
362
  destroy: () => e.destroy(),
360
363
  on: (t, n) => e.on(t, n)
361
364
  };
@@ -20046,22 +20049,34 @@ var GC = class {
20046
20049
  });
20047
20050
  WC(t, n), this.deps.selectionService.replaceWithRowIds([...n], r.length > 0 ? r[r.length - 1].rowIndex : -1);
20048
20051
  }
20049
- setIndexFocus(e) {
20052
+ setIndexFocus(e, t = {}) {
20050
20053
  if (!this.deps.indexFocusService) return;
20051
- let t = Cu(e).map((e) => {
20054
+ let n = Cu(e).map((e) => {
20052
20055
  let t = this.deps.rowModel.getRowIndexById(e);
20053
20056
  return t >= 0 ? {
20054
20057
  id: e,
20055
20058
  rowIndex: t
20056
20059
  } : null;
20057
- }).filter((e) => e != null), n = !1;
20058
- t.length === 0 ? (n = this.deps.indexFocusService.getFocusedRowIds().length > 0, n && this.deps.indexFocusService.clear()) : n = this.deps.indexFocusService.isMultiple() ? this.deps.indexFocusService.replaceWithRowIds(t.map((e) => e.id), t[0].rowIndex) : this.deps.indexFocusService.replaceWithRowIds([t[0].id], t[0].rowIndex), n && (this.applyIndexFocusVisuals({ syncToSelectionColumn: !1 }), this.deps.eventBus.emit("indexFocusChanged", { focusedRowIds: this.deps.indexFocusService.getFocusedRowIds() }));
20060
+ }).filter((e) => e != null), r = !1;
20061
+ if (n.length === 0 ? (r = this.deps.indexFocusService.getFocusedRowIds().length > 0, r && this.deps.indexFocusService.clear()) : r = this.deps.indexFocusService.isMultiple() ? this.deps.indexFocusService.replaceWithRowIds(n.map((e) => e.id), n[0].rowIndex) : this.deps.indexFocusService.replaceWithRowIds([n[0].id], n[0].rowIndex), !r) return;
20062
+ let i = (t.mode ?? "default") === "manual" ? { syncToSelectionColumn: t.syncToSelectionColumn ?? !1 } : {};
20063
+ this.applyIndexFocusVisuals(i), this.deps.eventBus.emit("indexFocusChanged", { focusedRowIds: this.deps.indexFocusService.getFocusedRowIds() });
20059
20064
  }
20060
20065
  toggleAllSelection(e) {
20061
20066
  if (!this.deps.selectionService) return;
20062
20067
  let t = this.deps.rowModel.getRowCount(), n = (e) => this.getSelectableRowIdAt(e), r = !1;
20063
20068
  r = e === void 0 ? this.deps.selectionService.toggleSelectAllVisibleRows(t, n) : e ? this.deps.selectionService.selectAllVisibleRows(t, n) : this.deps.selectionService.deselectAllVisibleRows(t, n), r && (this.syncTreeSelectionCascade(), this.applySelectionVisuals(), this.deps.eventBus.emit("selectionChanged", { selectedRowIds: this.deps.selectionService.getSelectedRowIds() }));
20064
20069
  }
20070
+ clearRowSelection(e = {}) {
20071
+ if (!this.deps.selectionService) return;
20072
+ let t = e.scope ?? "all", n = !1;
20073
+ if (t === "all") n = this.deps.selectionService.getSelectedRowIds().length > 0, n && this.deps.selectionService.clear();
20074
+ else {
20075
+ let e = new Set(this.deps.rowModel.rowsToDisplay.map((e) => e.id)), t = this.deps.selectionService.getSelectedRowIds().filter((t) => e.has(t));
20076
+ t.length > 0 && (n = this.deps.selectionService.removeRowIds(t));
20077
+ }
20078
+ n && (this.syncTreeSelectionCascade(), this.applySelectionVisuals(), this.deps.eventBus.emit("selectionChanged", { selectedRowIds: this.deps.selectionService.getSelectedRowIds() }));
20079
+ }
20065
20080
  isRowNodeSelectable(e) {
20066
20081
  return hn(e) || ir(e) ? !1 : Ki(this.selectableFn, e, this.deps.rowKey);
20067
20082
  }
@@ -20085,7 +20100,7 @@ var GC = class {
20085
20100
  applyIndexFocusVisuals(e = {}) {
20086
20101
  if (!this.deps.indexFocusService) return;
20087
20102
  let t = new Set(this.deps.indexFocusService.getFocusedRowIds());
20088
- this.deps.rowRenderer.refreshIndexFocus(t), e.syncToSelectionColumn !== !1 && this.maybeSyncIndexFocusToSelection();
20103
+ this.deps.rowRenderer.refreshIndexFocus(t), this.shouldSyncIndexFocusToSelection(e) && this.syncIndexFocusToSelection();
20089
20104
  }
20090
20105
  onRowsRemoved(e) {
20091
20106
  this.deps.selectionService?.removeRowIds(e) && (this.applySelectionVisuals(), this.deps.eventBus.emit("selectionChanged", { selectedRowIds: this.deps.selectionService.getSelectedRowIds() })), this.deps.indexFocusService?.removeRowIds(e) && (this.applyIndexFocusVisuals({ syncToSelectionColumn: !1 }), this.deps.eventBus.emit("indexFocusChanged", { focusedRowIds: this.deps.indexFocusService.getFocusedRowIds() }));
@@ -20101,8 +20116,11 @@ var GC = class {
20101
20116
  }
20102
20117
  return n;
20103
20118
  }
20104
- maybeSyncIndexFocusToSelection() {
20105
- if (!this.deps.indexColumnOptions.indexColumn.syncToSelectionColumn || !this.deps.indexFocusService || !this.deps.selectionService) return;
20119
+ shouldSyncIndexFocusToSelection(e) {
20120
+ return e.syncToSelectionColumn === !1 ? !1 : e.syncToSelectionColumn === !0 || this.deps.indexColumnOptions.indexColumn.syncToSelectionColumn;
20121
+ }
20122
+ syncIndexFocusToSelection() {
20123
+ if (!this.deps.indexFocusService || !this.deps.selectionService) return;
20106
20124
  let e = this.deps.indexColumnOptions.indexColumn.focusMode, t = this.deps.selectionColumnOptions.mode;
20107
20125
  if (!Ji(e, t)) return;
20108
20126
  let n = this.deps.indexFocusService.getFocusedRowIds();
@@ -21410,12 +21428,21 @@ var mw = class {
21410
21428
  toggleRowSelection(e, t, n) {
21411
21429
  this.selectionOps.toggleRowSelection(e, t, n);
21412
21430
  }
21413
- setIndexFocus(e) {
21414
- this.selectionOps.setIndexFocus(e), this.cellSelectionOptions.enabled && this.indexColumnOptions.showIndexColumn && this.interaction.syncCellRangeFromIndexFocus();
21431
+ setIndexFocus(e, t) {
21432
+ this.selectionOps.setIndexFocus(e, t), this.cellSelectionOptions.enabled && this.indexColumnOptions.showIndexColumn && this.interaction.syncCellRangeFromIndexFocus();
21415
21433
  }
21416
21434
  toggleAllSelection(e) {
21417
21435
  this.selectionOps.toggleAllSelection(e);
21418
21436
  }
21437
+ clearRowSelection(e) {
21438
+ this.selectionOps.clearRowSelection(e);
21439
+ }
21440
+ getSelectedRowIds() {
21441
+ return this.selectionService ? Ni(this.selectionService.getSelectedRowIds(), this.businessRowIdCtx) : [];
21442
+ }
21443
+ getIndexFocusedRowIds() {
21444
+ return this.indexFocusService ? Ni(this.indexFocusService.getFocusedRowIds(), this.businessRowIdCtx) : [];
21445
+ }
21419
21446
  isRowNodeSelectable(e) {
21420
21447
  return this.selectionOps.isRowNodeSelectable(e);
21421
21448
  }