@taocompany/magic-grid 0.11.3 → 0.11.5

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
@@ -7392,41 +7392,17 @@ var rh = {
7392
7392
  function ih(e, t) {
7393
7393
  return e.key ?? e.prop ?? `col_${t}`;
7394
7394
  }
7395
- function ah(e, t, n) {
7396
- let r = new Map(t.map((e) => [e.colId, e])), i = [], a = /* @__PURE__ */ new Set();
7395
+ function ah(e, t) {
7396
+ let n = new Map(t.map((e) => [e.colId, e])), r = [], i = /* @__PURE__ */ new Set();
7397
7397
  for (let t of e) {
7398
- let e = r.get(t);
7399
- e && (i.push(e), a.add(t));
7400
- }
7401
- for (let e = 0; e < t.length; e++) {
7402
- let r = t[e];
7403
- if (a.has(r.colId)) continue;
7404
- let o = n.get(r.colId), s;
7405
- if (o !== void 0) s = Math.min(o, i.length), n.delete(r.colId);
7406
- else {
7407
- s = i.length;
7408
- for (let n = e - 1; n >= 0; n--) {
7409
- let e = t[n].colId, r = i.findIndex((t) => t.colId === e);
7410
- if (r >= 0) {
7411
- s = r + 1;
7412
- break;
7413
- }
7414
- }
7415
- if (s === i.length) for (let n = e + 1; n < t.length; n++) {
7416
- let e = t[n].colId, r = i.findIndex((t) => t.colId === e);
7417
- if (r >= 0) {
7418
- s = r;
7419
- break;
7420
- }
7421
- }
7422
- }
7423
- i.splice(s, 0, r), a.add(r.colId);
7398
+ let e = n.get(t);
7399
+ e && (r.push(e), i.add(t));
7424
7400
  }
7425
- return i;
7401
+ for (let e of t) i.has(e.colId) || (r.push(e), i.add(e.colId));
7402
+ return r;
7426
7403
  }
7427
7404
  var oh = class {
7428
7405
  columns = [];
7429
- unavailableColumnOrder = /* @__PURE__ */ new Map();
7430
7406
  totalWidth = 0;
7431
7407
  fixedGroups = rh;
7432
7408
  leftFixedWidth = 0;
@@ -7451,16 +7427,11 @@ var oh = class {
7451
7427
  this.columnMovableDefault = e.columnMovable, this.allowCrossLaneColumnMove = e.allowCrossLaneColumnMove;
7452
7428
  }
7453
7429
  a !== void 0 && (this.gridResizableDefault = $m(a).resizable), o !== void 0 && (this.gridSortableDefault = Da(o).sortable), s !== void 0 && (this.gridFilterableDefault = La(s).filterable);
7454
- let c = It(e), l = this.columns.map((e) => e.colId), u = new Map(this.columns.map((e) => [e.colId, e])), d = new Set(c.map((e, t) => ih(e, t)));
7455
- for (let e = 0; e < l.length; e++) {
7456
- let t = l[e];
7457
- d.has(t) || this.unavailableColumnOrder.set(t, e);
7458
- }
7459
- let f = c.map((e, r) => {
7430
+ let c = It(e), l = this.columns.map((e) => e.colId), u = new Map(this.columns.map((e) => [e.colId, e])), d = new Set(c.map((e, t) => ih(e, t))), f = c.map((e, r) => {
7460
7431
  let i = this.parseColumn(e, r, t, n), a = u.get(i.colId);
7461
7432
  return a && (a.defHidden === i.defHidden && (i.hidden = a.hidden), a.defWidth === i.defWidth && a.defFlex === i.defFlex && (i.width = a.width, i.flex = a.flex), a.defFixed === i.defFixed && (i.fixed = a.fixed)), i;
7462
- });
7463
- this.columns = l.length === 0 ? f : ah(l, f, this.unavailableColumnOrder), this.rebuildDisplayedLayout();
7433
+ }), p = l.length > 0 && (d.size !== l.length || l.some((e) => !d.has(e)));
7434
+ this.columns = l.length === 0 || p ? f : ah(l, f), this.rebuildDisplayedLayout();
7464
7435
  }
7465
7436
  setColumnsHidden(e, t) {
7466
7437
  let n = [];