@hzab/edit-table 0.1.13-alpha.0 → 0.1.13

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.js CHANGED
@@ -2,13 +2,13 @@ import { forwardRef as e, useCallback as t, useEffect as n, useImperativeHandle
2
2
  import { Checkbox as s, DatePicker as c, Empty as l, Input as u, Popover as d, Spin as f, TimePicker as p } from "antd";
3
3
  import { ReactGrid as m, getCellProperty as h, isAlphaNumericKey as g, isNavigationKey as _ } from "@silevis/reactgrid";
4
4
  import { antdComponents as v, customComponents as y } from "@hzab/form-render";
5
- import { InfoCircleOutlined as b, MinusCircleOutlined as x, PlusCircleOutlined as S } from "@ant-design/icons";
6
- import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
7
- import { c as E } from "react/compiler-runtime";
8
- import { getVal as D } from "@hzab/utils/src/formily/field";
5
+ import { InfoCircleOutlined as ee, MinusCircleOutlined as b, PlusCircleOutlined as x } from "@ant-design/icons";
6
+ import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
7
+ import { c as T } from "react/compiler-runtime";
8
+ import { getVal as E } from "@hzab/utils/src/formily/field";
9
9
  import "@silevis/reactgrid/styles.css";
10
10
  //#region src/common/childAntdComponent.ts
11
- var O = {
11
+ var D = {
12
12
  "DatePicker.MonthPicker": c.MonthPicker,
13
13
  "DatePicker.QuarterPicker": c.QuarterPicker,
14
14
  "DatePicker.RangePicker": c.RangePicker,
@@ -19,7 +19,7 @@ var O = {
19
19
  "Input.Search": u.Search,
20
20
  "Input.TextArea": u.TextArea,
21
21
  "TimePicker.RangePicker": p.RangePicker
22
- }, k = [
22
+ }, O = [
23
23
  "DatePicker",
24
24
  "DatePicker.MonthPicker",
25
25
  "DatePicker.QuarterPicker",
@@ -28,7 +28,7 @@ var O = {
28
28
  "DatePicker.WeekPicker",
29
29
  "DatePicker.YearPicker",
30
30
  "TimePicker.RangePicker"
31
- ], A = (e, t = {}) => {
31
+ ], k = (e, t = {}) => {
32
32
  class r {
33
33
  getCompatibleCell(e) {
34
34
  let t;
@@ -61,7 +61,8 @@ var O = {
61
61
  });
62
62
  }
63
63
  getClassName(e, t) {
64
- return "";
64
+ let n = window.gridHighlightRowId;
65
+ return n && e.rowId === n ? "custom-highlights-row" : "";
65
66
  }
66
67
  handleCompositionEnd(e, t) {
67
68
  return {
@@ -71,19 +72,30 @@ var O = {
71
72
  }
72
73
  render(r, s, c) {
73
74
  var l;
74
- let [u, f] = o(!1), [p, m] = o(!1), h = (r == null ? void 0 : r.columnId) + (r == null ? void 0 : r.rowId), [v, y] = o(r == null ? void 0 : r.text), [x, S] = o(!1), C = a(r == null ? void 0 : r.text), E = a(), D = a(null), O = a(null);
75
+ let [u, f] = o(!1), [p, m] = o(!1), h = (r == null ? void 0 : r.columnId) + (r == null ? void 0 : r.rowId), [v, y] = o(r == null ? void 0 : r.text), [b, x] = o(!1), S = a(r == null ? void 0 : r.text), T = a(), E = a(null), D = a(null), k = (e) => {
76
+ let t = Array.from(e.children);
77
+ if (t.length === 0) return e.clientHeight;
78
+ let n = Infinity, r = -Infinity;
79
+ for (let e of t) {
80
+ let t = e.getBoundingClientRect(), i = getComputedStyle(e), a = parseFloat(i.marginTop) || 0, o = parseFloat(i.marginBottom) || 0;
81
+ n = Math.min(n, t.top - a), r = Math.max(r, t.bottom + o);
82
+ }
83
+ return Math.max(0, Math.ceil(r - n));
84
+ };
75
85
  n(() => {
76
- let e = D.current, t = r == null ? void 0 : r.onRowHeightChange;
86
+ let e = E.current, t = r == null ? void 0 : r.onRowHeightChange;
77
87
  if (!e || !t || (r == null ? void 0 : r.rowId) == null || typeof (r == null ? void 0 : r.rowId) == "string" && r.rowId.indexOf("header-") === 0) return;
78
88
  let n = e.firstElementChild, i = n || e;
79
- if (O.current === null) {
89
+ if (D.current === null) {
80
90
  let t = getComputedStyle(e);
81
- O.current = (parseFloat(t.paddingTop) || 0) + (parseFloat(t.paddingBottom) || 0);
91
+ D.current = (parseFloat(t.paddingTop) || 0) + (parseFloat(t.paddingBottom) || 0);
82
92
  }
83
- let a = n ? O.current : 0, o = () => t(r == null ? void 0 : r.rowId, i.scrollHeight + a, r == null ? void 0 : r.columnId);
84
- o();
85
- let s = new ResizeObserver(o);
86
- return s.observe(i), () => s.disconnect();
93
+ let a = n ? D.current : 0, o = new ResizeObserver(() => {
94
+ Array.from(i.children).forEach((e) => o.observe(e));
95
+ let e = k(i) + a;
96
+ t(r == null ? void 0 : r.rowId, e, r == null ? void 0 : r.columnId);
97
+ });
98
+ return o.observe(i), Array.from(i.children).forEach((e) => o.observe(e)), () => o.disconnect();
87
99
  }, [
88
100
  r == null ? void 0 : r.rowId,
89
101
  r == null ? void 0 : r.columnId,
@@ -91,7 +103,7 @@ var O = {
91
103
  u,
92
104
  v
93
105
  ]), n(() => {
94
- y(r == null ? void 0 : r.text), C.current = r == null ? void 0 : r.text;
106
+ y(r == null ? void 0 : r.text), S.current = r == null ? void 0 : r.text;
95
107
  }, [r == null ? void 0 : r.text]), n(() => {
96
108
  function e(e) {
97
109
  window.gridEditId != h && f(!1);
@@ -108,7 +120,7 @@ var O = {
108
120
  t != null && (a = t.pattern) != null && a.test(e) && (n = !0);
109
121
  break;
110
122
  }
111
- i = !n && Array.isArray(r == null ? void 0 : r.validatorList) && (r == null || (t = r.validatorList) == null ? void 0 : t.length) > 0, S(i);
123
+ i = !n && Array.isArray(r == null ? void 0 : r.validatorList) && (r == null || (t = r.validatorList) == null ? void 0 : t.length) > 0, x(i);
112
124
  };
113
125
  n(() => {
114
126
  if (!p) return;
@@ -125,29 +137,29 @@ var O = {
125
137
  return () => clearTimeout(e);
126
138
  }, [p]);
127
139
  let j = () => {
128
- let e = C.current;
140
+ let e = S.current;
129
141
  c(this.getCompatibleCell({
130
142
  ...r,
131
143
  text: e,
132
144
  selectedValue: e
133
145
  }), !0);
134
- }, M = i(() => k != null && k.includes(r == null ? void 0 : r.type) ? {
146
+ }, M = i(() => O != null && O.includes(r == null ? void 0 : r.type) ? {
135
147
  open: p,
136
148
  onOpenChange: (e) => {
137
- E.current && clearTimeout(E.current), E.current = setTimeout(() => {
149
+ T.current && clearTimeout(T.current), T.current = setTimeout(() => {
138
150
  m(e);
139
151
  }, 80);
140
152
  }
141
153
  } : {}, [r]);
142
154
  return n(() => {
143
155
  !u && r.type == "Upload" && window.uploadEdit && window.uploadEdit == h && (window.uploadEdit = null, j());
144
- }, [u, v]), /* @__PURE__ */ T("div", {
145
- ref: D,
156
+ }, [u, v]), /* @__PURE__ */ w("div", {
157
+ ref: E,
146
158
  className: `base-hoc ${u ? "base-hoc-edit" : ""}`,
147
159
  onDoubleClick: (e) => {
148
160
  r != null && r.nonEditable || (r.type === "Upload" && (window.uploadEdit = h), f(!0));
149
161
  },
150
- children: [/* @__PURE__ */ w(e, {
162
+ children: [/* @__PURE__ */ C(e, {
151
163
  ...t,
152
164
  onPointerDown: (e) => e.stopPropagation(),
153
165
  componentProps: {
@@ -161,10 +173,10 @@ var O = {
161
173
  onChange: (e) => {
162
174
  var t, n;
163
175
  let r = (t = e == null || (n = e.target) == null ? void 0 : n.value) == null ? e : t;
164
- y(r), C.current = r, A(r);
176
+ y(r), S.current = r, A(r);
165
177
  },
166
178
  onBlur: (e) => {
167
- j(), k != null && k.includes(r == null ? void 0 : r.type) || f(!1);
179
+ j(), O != null && O.includes(r == null ? void 0 : r.type) || f(!1);
168
180
  },
169
181
  onPointerDown: (e) => {
170
182
  e.stopPropagation();
@@ -177,46 +189,46 @@ var O = {
177
189
  },
178
190
  pattern: u ? "" : "readPretty",
179
191
  cell: r
180
- }), x && /* @__PURE__ */ w(d, {
192
+ }), b && /* @__PURE__ */ C(d, {
181
193
  content: (l = r == null ? void 0 : r.validatorMessage) == null ? "该字段不合法" : l,
182
- children: /* @__PURE__ */ w(b, { className: "validator-icon" })
194
+ children: /* @__PURE__ */ C(ee, { className: "validator-icon" })
183
195
  })]
184
196
  });
185
197
  }
186
198
  }
187
199
  return new r();
188
- }, j = (e) => {
200
+ }, A = (e) => {
189
201
  let { pattern: t, cell: n, componentProps: r, Com: a, cellRender: o } = e, s = i(() => {
190
202
  var e;
191
- if (n != null && n.getField) return D({
203
+ if (n != null && n.getField) return E({
192
204
  ...(n == null ? void 0 : n.getField) && (n == null ? void 0 : n.getField()),
193
205
  enum: (n == null || (e = n.getField()) == null ? void 0 : e.enum) || (n == null ? void 0 : n.values)
194
206
  }, { [(n == null ? void 0 : n.getField) && (n == null ? void 0 : n.getField().name)]: n.text });
195
207
  }, [n]);
196
- return o && o(e) ? /* @__PURE__ */ w(o, { ...e }) : /* @__PURE__ */ w("div", {
208
+ return o && o(e) ? /* @__PURE__ */ C(o, { ...e }) : /* @__PURE__ */ C("div", {
197
209
  className: "base-hoc-inner",
198
- children: t == "readPretty" ? /* @__PURE__ */ w("div", { children: s }) : /* @__PURE__ */ w(a, {
210
+ children: t == "readPretty" ? /* @__PURE__ */ C("div", { children: s }) : /* @__PURE__ */ C(a, {
199
211
  className: "rg-input",
200
212
  ref: (e) => {
201
- e && e.focus();
213
+ e && e.focus({ preventScroll: !0 });
202
214
  },
203
215
  ...r
204
216
  })
205
217
  });
206
- }, M = (e) => {
207
- let t = E(5), n = e == null ? void 0 : e.componentProps, r;
218
+ }, j = (e) => {
219
+ let t = T(5), n = e == null ? void 0 : e.componentProps, r;
208
220
  t[0] === n ? r = t[1] : (r = {
209
221
  ...n,
210
222
  type: "number"
211
223
  }, t[0] = n, t[1] = r);
212
224
  let i;
213
- return t[2] !== e || t[3] !== r ? (i = /* @__PURE__ */ w(j, {
225
+ return t[2] !== e || t[3] !== r ? (i = /* @__PURE__ */ C(A, {
214
226
  ...e,
215
227
  componentProps: r,
216
228
  Com: u
217
229
  }), t[2] = e, t[3] = r, t[4] = i) : i = t[4], i;
218
- }, ee = (e) => {
219
- let t = E(21), { cell: r } = e, { setExpandKeys: i, expandKeys: a, rowKey: s, setNewDataSource: c, record: l } = r, [u, d] = o(!1), f;
230
+ }, M = (e) => {
231
+ let t = T(21), { cell: r } = e, { setExpandKeys: i, expandKeys: a, rowKey: s, setNewDataSource: c, record: l } = r, [u, d] = o(!1), f;
220
232
  t[0] !== l || t[1] !== s || t[2] !== c ? (f = (e) => {
221
233
  c((t) => {
222
234
  var n;
@@ -239,12 +251,12 @@ var O = {
239
251
  i((e) => e != null && e.includes(l == null ? void 0 : l[s]) ? e == null ? void 0 : e.filter((e) => e != (l == null ? void 0 : l[s])) : [...e, l == null ? void 0 : l[s]]), d(!u), p(!u);
240
252
  }, t[11] = u, t[12] = p, t[13] = l, t[14] = s, t[15] = i, t[16] = _) : _ = t[16];
241
253
  let v = _, y;
242
- return t[17] !== u || t[18] !== v || t[19] !== (l == null ? void 0 : l.children) ? (y = /* @__PURE__ */ w("div", {
254
+ return t[17] !== u || t[18] !== v || t[19] !== (l == null ? void 0 : l.children) ? (y = /* @__PURE__ */ C("div", {
243
255
  className: "expandList-template",
244
- children: l != null && l.children ? /* @__PURE__ */ w(C, { children: w(u ? x : S, {
256
+ children: l != null && l.children ? /* @__PURE__ */ C(S, { children: C(u ? b : x, {
245
257
  className: "expandList-template-icon",
246
258
  onClick: v
247
- }) }) : /* @__PURE__ */ w("div", { style: { width: 14 } })
259
+ }) }) : /* @__PURE__ */ C("div", { style: { width: 14 } })
248
260
  }), t[17] = u, t[18] = v, t[19] = l == null ? void 0 : l.children, t[20] = y) : y = t[20], y;
249
261
  };
250
262
  //#endregion
@@ -398,13 +410,101 @@ function ne(e) {
398
410
  return n(e), t;
399
411
  }
400
412
  //#endregion
401
- //#region src/index.tsx
402
- function F(e, c) {
403
- var u;
404
- let { columns: d, dataSource: p, formulaConfig: h, onChange: g, reactGridProps: _ = {}, onEditSubmit: b, headerRowHeight: x = 44, rowHeight: S = 44, reactGridStyle: C, className: E, Slots: D, rowSelection: k, rowKey: P = "id", query: F, loading: I, isExpand: re = !1, getList: L, onRow: R } = e, [z, ie] = o([]), [B, V] = o([]), H = a([]), [U, ae] = o([]), [W, oe] = o([]), [G, K] = o([]), [se, ce] = o([]), [le, ue] = o([]), [de, q] = o([]), J = a(), [Y, fe] = o({}), X = a({}), Z = a(), pe = a(), Q = a(), $ = t(() => {
405
- Z.current = void 0;
406
- let e = X.current;
407
- Object.keys(e).length !== 0 && (X.current = {}, fe((t) => {
413
+ //#region src/common/useDynamicHeight.ts
414
+ var re = (e) => {
415
+ let { wrapRef: r, rowHeight: i, setRows: s } = e, c = a({}), l = a(), u = a({
416
+ top: 0,
417
+ left: 0
418
+ }), d = a(0), f = a([]), [p, m] = o({}), h = t((e = 500) => {
419
+ let t = r.current;
420
+ t && (u.current = {
421
+ top: t.scrollTop,
422
+ left: t.scrollLeft
423
+ }, d.current = Math.max(d.current || 0, Date.now() + e));
424
+ }, []), g = t(() => {
425
+ let e = r.current;
426
+ if (!e) return;
427
+ let { top: t, left: n } = u.current;
428
+ requestAnimationFrame(() => {
429
+ requestAnimationFrame(() => {
430
+ e.scrollTop !== t && (e.scrollTop = t), e.scrollLeft !== n && (e.scrollLeft = n);
431
+ });
432
+ });
433
+ }, []);
434
+ n(() => {
435
+ let e = r.current;
436
+ if (!e) return;
437
+ let t = () => {
438
+ e.querySelectorAll(".rg-hidden-element").forEach((e) => {
439
+ if (e.__focusScrollPatched) return;
440
+ e.__focusScrollPatched = !0;
441
+ let t = e.focus.bind(e);
442
+ e.focus = (e) => t({
443
+ preventScroll: !0,
444
+ ...e || {}
445
+ });
446
+ });
447
+ };
448
+ t();
449
+ let n = new MutationObserver(t);
450
+ return n.observe(e, {
451
+ childList: !0,
452
+ subtree: !0
453
+ }), () => n.disconnect();
454
+ }, []), n(() => {
455
+ let e = r.current;
456
+ if (!e || e.__scrollGuard) return;
457
+ e.__scrollGuard = !0;
458
+ let t = Object.getOwnPropertyDescriptor(Element.prototype, "scrollTop");
459
+ Object.defineProperty(e, "scrollTop", {
460
+ configurable: !0,
461
+ get() {
462
+ return t.get.call(e);
463
+ },
464
+ set(n) {
465
+ let r = Number(n) || 0, i = t.get.call(e), a = r - i;
466
+ a !== 0 && Math.abs(a) <= 3 || (r === 0 && i > 50 && console.warn("[CellEditTable] 检测到程序化滚动回顶部: ", i, "->", r, (/* @__PURE__ */ Error()).stack), t.set.call(e, r));
467
+ }
468
+ });
469
+ let n = e.scrollTo.bind(e);
470
+ e.scrollTo = (r, i) => {
471
+ if (typeof r == "object" && r) {
472
+ if (r.top != null) {
473
+ let n = t.get.call(e), i = Number(r.top) - n;
474
+ if (i !== 0 && Math.abs(i) <= 3) return;
475
+ }
476
+ return n(r);
477
+ }
478
+ if (typeof r == "number" && typeof i == "number") {
479
+ let n = i - t.get.call(e);
480
+ if (n !== 0 && Math.abs(n) <= 3) return;
481
+ }
482
+ return n(r, i);
483
+ };
484
+ let i = e.scrollBy.bind(e);
485
+ e.scrollBy = (e, t) => {
486
+ if (typeof e == "object" && e) return e.top != null && Math.abs(Number(e.top)) <= 3 ? void 0 : i(e);
487
+ if (!(typeof e == "number" && typeof t == "number" && Math.abs(t) <= 3)) return i(e, t);
488
+ };
489
+ }, []), n(() => {
490
+ let e = r.current;
491
+ if (!e) return;
492
+ let t = () => {
493
+ if (Date.now() < d.current && (e.scrollTop === 0 && u.current.top > 50 || e.scrollLeft === 0 && u.current.left > 50)) {
494
+ e.scrollTop = u.current.top, e.scrollLeft = u.current.left;
495
+ return;
496
+ }
497
+ u.current = {
498
+ top: e.scrollTop,
499
+ left: e.scrollLeft
500
+ };
501
+ };
502
+ return e.addEventListener("scroll", t, !0), () => e.removeEventListener("scroll", t, !0);
503
+ }, []);
504
+ let _ = t(() => {
505
+ l.current = void 0;
506
+ let e = c.current;
507
+ Object.keys(e).length !== 0 && (c.current = {}, m((t) => {
408
508
  let n = t;
409
509
  for (let r in e) {
410
510
  let i = { ...n[r] || {} }, a = !1;
@@ -416,38 +516,90 @@ function F(e, c) {
416
516
  }
417
517
  return n === t ? t : n;
418
518
  }));
419
- }, []), me = t((e, t, n) => {
420
- let r = Math.max(Number(t) || 0, S), i = String(e), a = n || "_", o = X.current[i] = X.current[i] || {};
421
- o[a] !== r && (o[a] = r, Z.current || (Z.current = requestAnimationFrame($)));
422
- }, [S, $]);
423
- n(() => () => {
424
- Z.current && cancelAnimationFrame(Z.current);
519
+ }, []), v = t((e, t, n) => {
520
+ let r = Math.max(Number(t) || 0, i), a = String(e), o = n || "_", s = c.current[a] = c.current[a] || {};
521
+ s[o] !== r && (s[o] = r, l.current || (l.current = requestAnimationFrame(_)));
522
+ }, [i, _]);
523
+ return n(() => () => {
524
+ l.current && cancelAnimationFrame(l.current);
425
525
  }, []), n(() => {
426
- V((e) => {
526
+ s((e) => {
427
527
  if (!Array.isArray(e) || e.length === 0) return e;
428
528
  let t = !1, n = e.map((e) => {
429
529
  if (typeof (e == null ? void 0 : e.rowId) == "string" && e.rowId.indexOf("header-") === 0) return e;
430
- let n = Y[e.rowId], r = n && Object.keys(n).length > 0 ? Math.max(S, ...Object.values(n).map(Number)) : S;
530
+ let n = p[e.rowId], r = n && Object.keys(n).length > 0 ? Math.max(i, ...Object.values(n).map(Number)) : i;
431
531
  return e.height === r ? e : (t = !0, {
432
532
  ...e,
433
533
  height: r
434
534
  });
435
- });
436
- return t ? n : e;
535
+ }), r = t ? n : e;
536
+ return f.current = r, r;
437
537
  });
438
- }, [Y, S]), r(c, () => ({ rows: B }));
439
- let he = (e, t = 0) => {
538
+ }, [p, i]), {
539
+ handleRowHeightChange: v,
540
+ armScrollProtect: h,
541
+ restoreScroll: g,
542
+ SCROLL_RESET_GUARD_MS: 3e3,
543
+ rowsRef: f,
544
+ rowHeights: p
545
+ };
546
+ };
547
+ //#endregion
548
+ //#region src/index.tsx
549
+ function ie(e, t, n) {
550
+ if (!Array.isArray(e) || !Array.isArray(t) || t.length === 0) return e;
551
+ let r = /* @__PURE__ */ new Map();
552
+ t.forEach((e) => {
553
+ (e == null ? void 0 : e[n]) != null && r.set(String(e[n]), e), (e == null ? void 0 : e.id) != null && r.set(String(e.id), e);
554
+ });
555
+ let i = (e) => Array.isArray(e) ? e.map((e) => {
556
+ var t;
557
+ let a = r.get(String((t = e == null ? void 0 : e[n]) == null ? e == null ? void 0 : e.id : t)), o = e == null ? void 0 : e.children, s = o && i(o);
558
+ if (!a) return s === o ? e : {
559
+ ...e,
560
+ children: s
561
+ };
562
+ let { children: c, ...l } = a;
563
+ return {
564
+ ...e,
565
+ ...l,
566
+ ...o === void 0 ? {} : { children: s }
567
+ };
568
+ }) : e;
569
+ return i(e);
570
+ }
571
+ function F(e, t) {
572
+ var c;
573
+ let { columns: u, dataSource: d, formulaConfig: p, onChange: h, reactGridProps: g = {}, onEditSubmit: _, headerRowHeight: ee = 48, rowHeight: b = 48, reactGridStyle: x, className: S, Slots: T, rowSelection: E, rowKey: O = "id", query: P, loading: F, isExpand: ae = !1, getList: oe, setList: I, onRow: L } = e, [R, se] = o([]), [z, B] = o([]);
574
+ a([]);
575
+ let [V, ce] = o([]), [H, le] = o([]), [U, W] = o([]), [G, ue] = o([]), [de, fe] = o([]), [pe, K] = o([]), q = a(), me = a(), J = a(null), he = a(), Y = a([]);
576
+ Y.current = G;
577
+ let { handleRowHeightChange: ge, armScrollProtect: X, restoreScroll: Z, SCROLL_RESET_GUARD_MS: _e, rowsRef: Q, rowHeights: ve } = re({
578
+ wrapRef: J,
579
+ rowHeight: b,
580
+ setRows: B
581
+ });
582
+ r(t, () => ({ rows: z }));
583
+ let ye = (e, t = 0) => {
440
584
  e == null || e.forEach((e) => {
441
- e.level = t + 1, e != null && e.children && he(e == null ? void 0 : e.children, e.level);
585
+ e.level = t + 1, e != null && e.children && ye(e == null ? void 0 : e.children, e.level);
442
586
  });
443
587
  };
444
588
  n(() => {
445
- he(p), K(p);
446
- }, [p]), n(() => {
447
- let e = B.map((e) => e.rowId);
448
- e != null && e.includes(J.current) || q([]);
449
- }, [B]);
450
- let ge = (e) => {
589
+ ye(d), W(((e) => {
590
+ let t = [], n = (e) => {
591
+ for (let a of e || []) {
592
+ var r, i;
593
+ t.push(a), a != null && (r = a.children) != null && r.length && (i = Y.current) != null && i.includes(a == null ? void 0 : a[O]) && n(a.children);
594
+ }
595
+ };
596
+ return n(e), t;
597
+ })(d));
598
+ }, [d]), n(() => {
599
+ let e = z.map((e) => e.rowId);
600
+ e != null && e.includes(q.current) || (K([]), window.gridHighlightRowId = null);
601
+ }, [z]);
602
+ let be = (e) => {
451
603
  var t, n;
452
604
  let r = e == null || (t = e.cells) == null || (t = t[0]) == null ? void 0 : t.record, i = ["_$actions", "rowSelection"], a = { id: e == null ? void 0 : e.rowId };
453
605
  return e == null || (n = e.cells) == null || n.forEach((e) => {
@@ -458,54 +610,54 @@ function F(e, c) {
458
610
  };
459
611
  };
460
612
  n(() => {
461
- if (Array.isArray(d) && (d == null ? void 0 : d.length) > 0) {
462
- re && d.unshift({
613
+ if (Array.isArray(u) && (u == null ? void 0 : u.length) > 0) {
614
+ ae && u.unshift({
463
615
  type: "ExpandListTemplate",
464
616
  width: 14,
465
617
  key: "ExpandListTemplate",
466
618
  nonEditable: !0,
467
- style: (k == null ? void 0 : k.style) || { background: "rgba(128, 128, 128, 0.1)" }
468
- }), k && d.unshift({
619
+ style: (E == null ? void 0 : E.style) || { background: "rgba(128, 128, 128, 0.1)" }
620
+ }), E && u.unshift({
469
621
  type: "rowSelection",
470
622
  nonEditable: !0,
471
- width: (k == null ? void 0 : k.width) || 30,
623
+ width: (E == null ? void 0 : E.width) || 30,
472
624
  key: "rowSelection",
473
- style: (k == null ? void 0 : k.style) || {
625
+ style: (E == null ? void 0 : E.style) || {
474
626
  background: "rgba(128, 128, 128, 0.1)",
475
627
  display: "flex",
476
628
  justifyContent: "center"
477
629
  }
478
- }), ie(te(d, x));
479
- let e = ne(d);
480
- ae(e == null ? void 0 : e.map((e, t) => ({
630
+ }), se(te(u, ee));
631
+ let e = ne(u);
632
+ ce(e == null ? void 0 : e.map((e, t) => ({
481
633
  ...e,
482
634
  columnId: (e == null ? void 0 : e.dataIndex) || (e == null ? void 0 : e.key) || (e == null ? void 0 : e.name) || ""
483
635
  })));
484
636
  }
485
- }, [d, k]);
486
- let _e = {}, ve = (e) => {
637
+ }, [u, E]);
638
+ let $ = {}, xe = (e) => {
487
639
  e == null || e.forEach((e) => {
488
640
  if (N(typeof (e == null ? void 0 : e.title) == "function" ? e == null ? void 0 : e.title() : null)) {
489
641
  let t = e == null ? void 0 : e.title;
490
- _e[e == null ? void 0 : e.dataIndex] = A(t);
642
+ $[e == null ? void 0 : e.dataIndex] = k(t);
491
643
  }
492
- e != null && e.children && ve(e == null ? void 0 : e.children);
644
+ e != null && e.children && xe(e == null ? void 0 : e.children);
493
645
  });
494
646
  };
495
647
  n(() => {
496
- ve(d), ue(_e);
497
- }, [d]), n(() => {
498
- let e = U == null ? void 0 : U.map((e) => e == null ? void 0 : e.columnId), t = G == null ? void 0 : G.map((t, n) => {
499
- let r = Y[t[P]], i = r && Object.keys(r).length > 0 ? Math.max(S, ...Object.values(r).map(Number)) : S;
648
+ xe(u), fe($);
649
+ }, [u]), n(() => {
650
+ let e = V == null ? void 0 : V.map((e) => e == null ? void 0 : e.columnId), t = U == null ? void 0 : U.map((t, n) => {
651
+ let r = ve[t[O]], i = r && Object.keys(r).length > 0 ? Math.max(b, ...Object.values(r).map(Number)) : b;
500
652
  return {
501
- rowId: t[P],
653
+ rowId: t[O],
502
654
  height: i,
503
655
  cells: e == null ? void 0 : e.map((e, r) => {
504
656
  var i;
505
- let a = {}, o = U[r], s = t[e], c = (i = o == null ? void 0 : o.type) == null ? "text" : i;
506
- if (h) {
507
- for (let n in h) if (n == e) {
508
- let e = h[n];
657
+ let a = {}, o = V[r], s = t[e], c = (i = o == null ? void 0 : o.type) == null ? "text" : i;
658
+ if (p) {
659
+ for (let n in p) if (n == e) {
660
+ let e = p[n];
509
661
  a = {
510
662
  text: (e == null ? void 0 : e.setCellData) && (e == null ? void 0 : e.setCellData(t)),
511
663
  value: (e == null ? void 0 : e.setCellData) && (e == null ? void 0 : e.setCellData(t)),
@@ -516,7 +668,7 @@ function F(e, c) {
516
668
  return {
517
669
  ...o,
518
670
  record: t,
519
- rowId: t[P] || (o == null ? void 0 : o.type),
671
+ rowId: t[O] || (o == null ? void 0 : o.type),
520
672
  type: c,
521
673
  nonEditable: (o == null ? void 0 : o.pattern) == "readPretty" ? !0 : o == null ? void 0 : o.nonEditable,
522
674
  text: String(s || ""),
@@ -526,153 +678,153 @@ function F(e, c) {
526
678
  display: "flex",
527
679
  justifyContent: "center"
528
680
  } : {},
529
- ...R && R(t, n, r) || {},
681
+ ...L && L(t, n, r) || {},
530
682
  ...(o == null ? void 0 : o.onCell) && (o == null ? void 0 : o.onCell(t, n, r)) || {},
531
683
  ...(o == null ? void 0 : o.cellProps) || {},
532
- setNewDataSource: K,
533
- setExpandKeys: ce,
534
- rowKey: P,
535
- expandKeys: se,
536
- Slots: D,
537
- onRowHeightChange: me,
684
+ setNewDataSource: W,
685
+ setExpandKeys: ue,
686
+ rowKey: O,
687
+ expandKeys: G,
688
+ Slots: T,
689
+ onRowHeightChange: ge,
538
690
  ...a
539
691
  };
540
692
  })
541
693
  };
542
- }), n = [...z, ...t];
543
- V(n);
694
+ }), n = [...R, ...t];
695
+ Q.current = n, X(), B(n), Z();
544
696
  }, [
545
- G,
546
697
  U,
547
- z
548
- ]), n(() => {
549
- if (I) {
550
- var e;
551
- let t = B == null ? void 0 : B.find((e) => {
552
- var t;
553
- return (e == null ? void 0 : e.rowId) == ((t = Q.current) == null ? void 0 : t.rowId);
554
- });
555
- t == null || (e = t.cells) == null || e.find((e) => {
556
- var t;
557
- return (e == null ? void 0 : e.columnId) == ((t = Q.current) == null ? void 0 : t.columnId);
558
- }), { ...Q.current }, H.current = B;
559
- }
560
- }, [I, B]);
561
- let ye = async (e) => {
562
- let t = [];
698
+ V,
699
+ R
700
+ ]);
701
+ let Se = async (e) => {
563
702
  if (!Array.isArray(e) || e.length === 0) return;
564
- let n = !1;
565
- if ((e == null ? void 0 : e.length) > 1 && (n = !0), V((r) => (e.forEach(async (e) => {
566
- let i = r.findIndex((t) => t.rowId == e.rowId), a = U.findIndex((t) => t.columnId == e.columnId);
567
- if (r[i].cells[a] = { ...e.newCell }, Q.current = { ...e.newCell }, t.push(ge(r[i])), h) for (let e in h) {
568
- let t = h[e], n = U.findIndex((t) => t.columnId == e), a = {
569
- ...r[i].cells[n],
570
- text: (t == null ? void 0 : t.setCellData) && (t == null ? void 0 : t.setCellData(r[i])),
571
- value: (t == null ? void 0 : t.setCellData) && (t == null ? void 0 : t.setCellData(r[i])),
572
- style: (t == null ? void 0 : t.setCellStyle) && (t == null ? void 0 : t.setCellStyle((t == null ? void 0 : t.setCellData) && (t == null ? void 0 : t.setCellData(r[i])) || r[i]))
573
- };
574
- r[i].cells[n] = a;
575
- }
576
- if (b && !n) try {
577
- await b(t);
578
- } catch (e) {
579
- L && L();
703
+ let t = [], n = d, r = (Q.current || []).map((e) => ({
704
+ ...e,
705
+ cells: [...e.cells]
706
+ })), i = [];
707
+ if (e.forEach((e) => {
708
+ let n = r.findIndex((t) => t.rowId == e.rowId), a = V.findIndex((t) => t.columnId == e.columnId);
709
+ if (n !== -1 && a !== -1) {
710
+ if (i.push({
711
+ rowId: e.rowId,
712
+ columnId: e.columnId,
713
+ previousCell: e.previousCell
714
+ }), r[n].cells[a] = { ...e.newCell }, he.current = { ...e.newCell }, t.push(be(r[n])), p) for (let e in p) {
715
+ let t = p[e], i = V.findIndex((t) => t.columnId == e);
716
+ if (i === -1) continue;
717
+ let a = {
718
+ ...r[n].cells[i],
719
+ text: (t == null ? void 0 : t.setCellData) && (t == null ? void 0 : t.setCellData(r[n])),
720
+ value: (t == null ? void 0 : t.setCellData) && (t == null ? void 0 : t.setCellData(r[n])),
721
+ style: (t == null ? void 0 : t.setCellStyle) && (t == null ? void 0 : t.setCellStyle((t == null ? void 0 : t.setCellData) && (t == null ? void 0 : t.setCellData(r[n])) || r[n]))
722
+ };
723
+ r[n].cells[i] = a;
724
+ }
725
+ h && h(r[n]);
580
726
  }
581
- g && g(r[i]);
582
- }), [...r])), n) try {
583
- b && await b(t);
727
+ }), Q.current = r, X(_e), B(r), Z(), I && t.length > 0 && I((e) => ie(e, t, O)), _) try {
728
+ await _(t);
584
729
  } catch (e) {
585
- L && L();
730
+ let t = (Q.current || []).map((e) => ({
731
+ ...e,
732
+ cells: [...e.cells]
733
+ }));
734
+ i.forEach(({ rowId: e, columnId: n, previousCell: r }) => {
735
+ let i = t.findIndex((t) => t.rowId == e), a = V.findIndex((e) => e.columnId == n);
736
+ i === -1 || a === -1 || !r || (t[i].cells[a] = { ...r });
737
+ }), Q.current = t, B(t), Z(), I == null || I(n), oe && oe();
586
738
  }
587
- }, be = i(() => {
739
+ }, Ce = i(() => {
588
740
  let t = {
589
741
  ...v || {},
590
742
  ...y || {},
591
- ...O
743
+ ...D
592
744
  }, n = {};
593
- for (let r in t) n[r] = A((n) => /* @__PURE__ */ w(j, {
745
+ for (let r in t) n[r] = k((n) => /* @__PURE__ */ C(A, {
594
746
  ...n,
595
747
  ...e,
596
748
  Com: t[r]
597
749
  }));
598
750
  return n;
599
- }, [v, y]), xe = (e) => {
600
- let t = B == null ? void 0 : B.find((t) => {
751
+ }, [v, y]), we = (e) => {
752
+ let t = z == null ? void 0 : z.find((t) => {
601
753
  var n;
602
754
  return (t == null ? void 0 : t.rowId) == (e == null || (n = e.cell) == null ? void 0 : n.rowId);
603
755
  });
604
- return /* @__PURE__ */ T("div", {
756
+ return /* @__PURE__ */ w("div", {
605
757
  onPointerDown: (e) => e.stopPropagation(),
606
758
  children: [
607
- (D == null ? void 0 : D.tableActionsSlot) && /* @__PURE__ */ w(D.tableActionsSlot, {
759
+ (T == null ? void 0 : T.tableActionsSlot) && /* @__PURE__ */ C(T.tableActionsSlot, {
608
760
  ...e == null ? void 0 : e.cell,
609
761
  rowData: t
610
762
  }),
611
- (D == null ? void 0 : D.actionPrefixSlot) && /* @__PURE__ */ w(D.actionPrefixSlot, {
763
+ (T == null ? void 0 : T.actionPrefixSlot) && /* @__PURE__ */ C(T.actionPrefixSlot, {
612
764
  ...e == null ? void 0 : e.cell,
613
765
  rowData: t
614
766
  }),
615
- (D == null ? void 0 : D.actionCenterSlot) && /* @__PURE__ */ w(D.actionCenterSlot, {
767
+ (T == null ? void 0 : T.actionCenterSlot) && /* @__PURE__ */ C(T.actionCenterSlot, {
616
768
  ...e == null ? void 0 : e.cell,
617
769
  rowData: t
618
770
  }),
619
- (D == null ? void 0 : D.actionSuffixSlot) && /* @__PURE__ */ w(D.actionSuffixSlot, {
771
+ (T == null ? void 0 : T.actionSuffixSlot) && /* @__PURE__ */ C(T.actionSuffixSlot, {
620
772
  ...e == null ? void 0 : e.cell,
621
773
  rowData: t
622
774
  })
623
775
  ]
624
776
  });
625
777
  };
626
- function Se(e) {
778
+ function Te(e) {
627
779
  let t = [];
628
780
  function n(e) {
629
781
  for (let r of e) t.push(r), r.children && r.children.length && n(r.children);
630
782
  }
631
783
  return n(e), t;
632
784
  }
633
- let Ce = (e) => {
785
+ let Ee = (e) => {
634
786
  var t, n, r, i, a, o;
635
- let { record: c, rowId: l } = e == null ? void 0 : e.cell, u = (t = Se(p)) == null ? void 0 : t.filter((e) => {
787
+ let { record: c, rowId: l } = e == null ? void 0 : e.cell, u = (t = Te(d)) == null ? void 0 : t.filter((e) => {
636
788
  var t;
637
- return !(k != null && (t = k.getCheckboxProps) != null && (t = t.call(k, e)) != null && t.disabled);
638
- }), d = typeof (k == null ? void 0 : k.getCheckboxProps) == "function" ? k == null || (n = k.getCheckboxProps) == null ? void 0 : n.call(k, c) : {};
639
- return /* @__PURE__ */ w(s, {
789
+ return !(E != null && (t = E.getCheckboxProps) != null && (t = t.call(E, e)) != null && t.disabled);
790
+ }), f = typeof (E == null ? void 0 : E.getCheckboxProps) == "function" ? E == null || (n = E.getCheckboxProps) == null ? void 0 : n.call(E, c) : {};
791
+ return /* @__PURE__ */ C(s, {
640
792
  ...e == null ? void 0 : e.componentProps,
641
- checked: (k == null || (r = k.selectedRowKeys) == null ? void 0 : r.includes(c && c[P] || "")) || !l && (k == null || (i = k.selectedRowKeys) == null ? void 0 : i.length) == (u == null ? void 0 : u.length) && (u == null ? void 0 : u.length) > 0,
642
- indeterminate: !l && (k == null || (a = k.selectedRowKeys) == null ? void 0 : a.length) > 0 && (k == null || (o = k.selectedRowKeys) == null ? void 0 : o.length) < (u == null ? void 0 : u.length),
793
+ checked: (E == null || (r = E.selectedRowKeys) == null ? void 0 : r.includes(c && c[O] || "")) || !l && (E == null || (i = E.selectedRowKeys) == null ? void 0 : i.length) == (u == null ? void 0 : u.length) && (u == null ? void 0 : u.length) > 0,
794
+ indeterminate: !l && (E == null || (a = E.selectedRowKeys) == null ? void 0 : a.length) > 0 && (E == null || (o = E.selectedRowKeys) == null ? void 0 : o.length) < (u == null ? void 0 : u.length),
643
795
  onChange: (e) => {
644
796
  if (e.target.checked && l) {
645
- let e = [...k == null ? void 0 : k.selectedRowKeys, c[P]], t = u == null ? void 0 : u.filter((t) => e == null ? void 0 : e.includes(t[P]));
646
- k == null || k.onChange(e, t);
797
+ let e = [...E == null ? void 0 : E.selectedRowKeys, c[O]], t = u == null ? void 0 : u.filter((t) => e == null ? void 0 : e.includes(t[O]));
798
+ E == null || E.onChange(e, t);
647
799
  } else if (!e.target.checked && l) {
648
800
  var t, n;
649
- let e = k == null || (t = k.selectedRowKeys) == null ? void 0 : t.filter((e) => e != c[P]), r = u == null ? void 0 : u.filter((t) => e == null ? void 0 : e.includes(t[P]));
650
- k == null || k.onChange(k == null || (n = k.selectedRowKeys) == null ? void 0 : n.filter((e) => e != c[P]), r);
801
+ let e = E == null || (t = E.selectedRowKeys) == null ? void 0 : t.filter((e) => e != c[O]), r = u == null ? void 0 : u.filter((t) => e == null ? void 0 : e.includes(t[O]));
802
+ E == null || E.onChange(E == null || (n = E.selectedRowKeys) == null ? void 0 : n.filter((e) => e != c[O]), r);
651
803
  } else if (e.target.checked && !l) {
652
- let e = u == null ? void 0 : u.map((e) => e[P]), t = u == null ? void 0 : u.filter((t) => e == null ? void 0 : e.includes(t[P]));
653
- k == null || k.onChange(u == null ? void 0 : u.map((e) => e[P]), t);
654
- } else !e.target.checked && !l && (k == null || k.onChange([], []));
804
+ let e = u == null ? void 0 : u.map((e) => e[O]), t = u == null ? void 0 : u.filter((t) => e == null ? void 0 : e.includes(t[O]));
805
+ E == null || E.onChange(u == null ? void 0 : u.map((e) => e[O]), t);
806
+ } else !e.target.checked && !l && (E == null || E.onChange([], []));
655
807
  },
656
- ...d
808
+ ...f
657
809
  });
658
810
  };
659
811
  n(() => {
660
- if (k) {
812
+ if (E) {
661
813
  var e;
662
- let t = (e = Se(p)) == null ? void 0 : e.filter((e) => {
814
+ let t = (e = Te(d)) == null ? void 0 : e.filter((e) => {
663
815
  var t;
664
- return !(k != null && (t = k.getCheckboxProps) != null && (t = t.call(k, e)) != null && t.disabled);
665
- }), n = t == null ? void 0 : t.filter((e) => W == null ? void 0 : W.includes(e[P]));
666
- k == null || k.onChange(W, n);
816
+ return !(E != null && (t = E.getCheckboxProps) != null && (t = t.call(E, e)) != null && t.disabled);
817
+ }), n = t == null ? void 0 : t.filter((e) => H == null ? void 0 : H.includes(e[O]));
818
+ E == null || E.onChange(H, n);
667
819
  }
668
- }, [W, p]), n(() => {
669
- oe([]);
670
- }, [F == null ? void 0 : F.pageNum]);
671
- let we = i(() => {
820
+ }, [H, d]), n(() => {
821
+ le([]);
822
+ }, [P == null ? void 0 : P.pageNum]);
823
+ let De = i(() => {
672
824
  let e = {};
673
- for (let t in _ == null ? void 0 : _.customCellTemplates) e[t] = A(_ == null ? void 0 : _.customCellTemplates[t]);
825
+ for (let t in g == null ? void 0 : g.customCellTemplates) e[t] = k(g == null ? void 0 : g.customCellTemplates[t]);
674
826
  return e;
675
- }, [_ == null ? void 0 : _.customCellTemplates]), Te = (e, t) => {
827
+ }, [g == null ? void 0 : g.customCellTemplates]), Oe = (e, t) => {
676
828
  var n;
677
829
  let r = t == null || (n = t.find((t) => (t == null ? void 0 : t.rowId) == (e == null ? void 0 : e.rowId))) == null || (n = n.cells) == null ? void 0 : n.map((t) => ({
678
830
  columnId: t == null ? void 0 : t.columnId,
@@ -680,50 +832,51 @@ function F(e, c) {
680
832
  className: "custom-highlights-row",
681
833
  borderColor: "transparent"
682
834
  }));
683
- J.current = e == null ? void 0 : e.rowId, q(r);
835
+ q.current = e == null ? void 0 : e.rowId, window.gridHighlightRowId = e == null ? void 0 : e.rowId, K(r);
684
836
  };
685
- return /* @__PURE__ */ w(f, {
686
- spinning: I,
687
- children: /* @__PURE__ */ T("div", {
688
- className: `grid-container ${E}`,
689
- style: C,
690
- children: [/* @__PURE__ */ w(m, {
691
- ref: pe,
692
- rows: I ? H.current : B,
693
- columns: U,
694
- onCellsChanged: ye,
837
+ return /* @__PURE__ */ C(f, {
838
+ spinning: F,
839
+ children: /* @__PURE__ */ w("div", {
840
+ ref: J,
841
+ className: `grid-container ${S}`,
842
+ style: x,
843
+ children: [/* @__PURE__ */ C(m, {
844
+ ref: me,
845
+ rows: z,
846
+ columns: V,
847
+ onCellsChanged: Se,
695
848
  enableFillHandle: !0,
696
849
  enableRangeSelection: !0,
697
850
  horizontalStickyBreakpoint: 120,
698
- ..._,
699
- highlights: (u = _ == null ? void 0 : _.highlights) == null ? de : u,
851
+ ...g,
852
+ highlights: (c = g == null ? void 0 : g.highlights) == null ? pe : c,
700
853
  onFocusLocationChanging: (e) => {
701
854
  var t, n;
702
855
  let r = (e == null ? void 0 : e.columnId) + (e == null ? void 0 : e.rowId);
703
- return window.gridEditId = r, typeof (e == null ? void 0 : e.rowId) == "string" && (e == null || (t = e.rowId) == null ? void 0 : t.indexOf("header-")) > -1 || (_ != null && _.isRowHighlights && e != null && e.columnId && Te(e, B), (n = [
856
+ return window.gridEditId = r, typeof (e == null ? void 0 : e.rowId) == "string" && (e == null || (t = e.rowId) == null ? void 0 : t.indexOf("header-")) > -1 || (g != null && g.isRowHighlights && e != null && e.columnId && Oe(e, z), (n = [
704
857
  "_$actions",
705
858
  "rowSelection",
706
859
  "ExpandListTemplate"
707
- ]) != null && n.includes(e == null ? void 0 : e.columnId)) ? !1 : _ != null && _.onFocusLocationChanging ? _ == null ? void 0 : _.onFocusLocationChanging(e, B) : e;
860
+ ]) != null && n.includes(e == null ? void 0 : e.columnId)) ? !1 : g != null && g.onFocusLocationChanging ? g == null ? void 0 : g.onFocusLocationChanging(e, z) : e;
708
861
  },
709
862
  customCellTemplates: {
710
- ExpandListTemplate: A(ee),
711
- ...be,
712
- ...we,
713
- ...le,
714
- _$actions: A(xe),
715
- rowSelection: A(Ce),
716
- Number: A(M, e)
863
+ ExpandListTemplate: k(M),
864
+ ...Ce,
865
+ ...De,
866
+ ...de,
867
+ _$actions: k(we),
868
+ rowSelection: k(Ee),
869
+ Number: k(j, e)
717
870
  }
718
- }, (p == null ? void 0 : p.length) == 0 ? 0 : 1), (p == null ? void 0 : p.length) <= 0 && /* @__PURE__ */ w("div", {
871
+ }, (d == null ? void 0 : d.length) == 0 ? 0 : 1), (d == null ? void 0 : d.length) <= 0 && /* @__PURE__ */ C("div", {
719
872
  className: "grid-container-empty",
720
- children: /* @__PURE__ */ w(l, { image: l.PRESENTED_IMAGE_SIMPLE })
873
+ children: /* @__PURE__ */ C(l, { image: l.PRESENTED_IMAGE_SIMPLE })
721
874
  })]
722
875
  })
723
876
  });
724
877
  }
725
- var I = e(F);
878
+ var ae = e(F);
726
879
  //#endregion
727
- export { I as default };
880
+ export { ae as default };
728
881
 
729
882
  //# sourceMappingURL=index.js.map