@hzab/edit-table 0.1.8 → 0.1.11

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
@@ -34,13 +34,13 @@ var D = {
34
34
  let t;
35
35
  try {
36
36
  t = m(e, "values", "object");
37
- } catch {
37
+ } catch (e) {
38
38
  t = [];
39
39
  }
40
40
  let n = e.selectedValue ? parseFloat(e.selectedValue) : NaN, r = !0;
41
41
  try {
42
42
  r = m(e, "isDisabled", "boolean");
43
- } catch {
43
+ } catch (e) {
44
44
  r = !1;
45
45
  }
46
46
  let i = e.selectedValue, a = i || "";
@@ -54,7 +54,7 @@ var D = {
54
54
  };
55
55
  }
56
56
  update(e, t) {
57
- let n = e.values.some((e) => e.value == t.text) ? t.text : t?.text || void 0;
57
+ let n = e.values.some((e) => e.value == t.text) ? t.text : (t == null ? void 0 : t.text) || void 0;
58
58
  return this.getCompatibleCell({
59
59
  ...e,
60
60
  selectedValue: n
@@ -70,27 +70,30 @@ var D = {
70
70
  };
71
71
  }
72
72
  render(o, s, c) {
73
- let [l, d] = a(!1), [f, p] = a(!1), m = o?.columnId + o?.rowId, [_, v] = a(o?.text), [b, x] = a(!1), S = i(o?.text), T = i();
73
+ var l;
74
+ let [d, f] = a(!1), [p, m] = a(!1), _ = (o == null ? void 0 : o.columnId) + (o == null ? void 0 : o.rowId), [v, b] = a(o == null ? void 0 : o.text), [x, S] = a(!1), T = i(o == null ? void 0 : o.text), E = i();
74
75
  t(() => {
75
- v(o?.text), S.current = o?.text;
76
- }, [o?.text]), t(() => {
76
+ b(o == null ? void 0 : o.text), T.current = o == null ? void 0 : o.text;
77
+ }, [o == null ? void 0 : o.text]), t(() => {
77
78
  function e(e) {
78
- window.gridEditId != m && d(!1);
79
+ window.gridEditId != _ && f(!1);
79
80
  }
80
81
  return document.addEventListener("click", e), () => {
81
82
  document.removeEventListener("click", e);
82
83
  };
83
84
  }, []);
84
- let E = (e) => {
85
- let t = !1, n = !1;
86
- for (let n of o?.validatorList || []) {
87
- n?.pattern?.test(e) && (t = !0);
85
+ let D = (e) => {
86
+ var t;
87
+ let n = !1, r = !1;
88
+ for (let t of (o == null ? void 0 : o.validatorList) || []) {
89
+ var i;
90
+ t != null && (i = t.pattern) != null && i.test(e) && (n = !0);
88
91
  break;
89
92
  }
90
- n = !t && Array.isArray(o?.validatorList) && o?.validatorList?.length > 0, x(n);
93
+ r = !n && Array.isArray(o == null ? void 0 : o.validatorList) && (o == null || (t = o.validatorList) == null ? void 0 : t.length) > 0, S(r);
91
94
  };
92
95
  t(() => {
93
- if (!f) return;
96
+ if (!p) return;
94
97
  let e = setTimeout(() => {
95
98
  let e = document.querySelector(".ant-picker-dropdown");
96
99
  if (!e) return;
@@ -102,28 +105,28 @@ var D = {
102
105
  };
103
106
  }, 0);
104
107
  return () => clearTimeout(e);
105
- }, [f]);
106
- let D = () => {
107
- let e = S.current;
108
+ }, [p]);
109
+ let k = () => {
110
+ let e = T.current;
108
111
  c(this.getCompatibleCell({
109
112
  ...o,
110
113
  text: e,
111
114
  selectedValue: e
112
115
  }), !0);
113
- }, k = r(() => O?.includes(o?.type) ? {
114
- open: f,
116
+ }, A = r(() => O != null && O.includes(o == null ? void 0 : o.type) ? {
117
+ open: p,
115
118
  onOpenChange: (e) => {
116
- T.current && clearTimeout(T.current), T.current = setTimeout(() => {
117
- p(e);
119
+ E.current && clearTimeout(E.current), E.current = setTimeout(() => {
120
+ m(e);
118
121
  }, 80);
119
122
  }
120
123
  } : {}, [o]);
121
124
  return t(() => {
122
- !l && o.type == "Upload" && window.uploadEdit && window.uploadEdit == m && (window.uploadEdit = null, D());
123
- }, [l, _]), /* @__PURE__ */ w("div", {
124
- className: `base-hoc ${l ? "base-hoc-edit" : ""}`,
125
+ !d && o.type == "Upload" && window.uploadEdit && window.uploadEdit == _ && (window.uploadEdit = null, k());
126
+ }, [d, v]), /* @__PURE__ */ w("div", {
127
+ className: `base-hoc ${d ? "base-hoc-edit" : ""}`,
125
128
  onDoubleClick: (e) => {
126
- o?.nonEditable || (o.type === "Upload" && (window.uploadEdit = m), d(!0));
129
+ o != null && o.nonEditable || (o.type === "Upload" && (window.uploadEdit = _), f(!0));
127
130
  },
128
131
  children: [/* @__PURE__ */ C(e, {
129
132
  ...n,
@@ -134,14 +137,15 @@ var D = {
134
137
  display: "flex",
135
138
  alignItems: "center"
136
139
  },
137
- value: _,
140
+ value: v,
138
141
  options: o.values,
139
142
  onChange: (e) => {
140
- let t = e?.target?.value ?? e;
141
- v(t), S.current = t, E(t);
143
+ var t, n;
144
+ let r = (t = e == null || (n = e.target) == null ? void 0 : n.value) == null ? e : t;
145
+ b(r), T.current = r, D(r);
142
146
  },
143
147
  onBlur: (e) => {
144
- D(), O?.includes(o?.type) || d(!1);
148
+ k(), O != null && O.includes(o == null ? void 0 : o.type) || f(!1);
145
149
  },
146
150
  onPointerDown: (e) => {
147
151
  e.stopPropagation();
@@ -149,13 +153,13 @@ var D = {
149
153
  onKeyDown: (e) => {
150
154
  (h(e.keyCode) || g(e.keyCode)) && e.stopPropagation();
151
155
  },
152
- ...k,
153
- ...o?.getField && o?.getField()["x-component-props"] || {}
156
+ ...A,
157
+ ...(o == null ? void 0 : o.getField) && (o == null ? void 0 : o.getField()["x-component-props"]) || {}
154
158
  },
155
- pattern: l ? "" : "readPretty",
159
+ pattern: d ? "" : "readPretty",
156
160
  cell: o
157
- }), b && /* @__PURE__ */ C(u, {
158
- content: o?.validatorMessage ?? "该字段不合法",
161
+ }), x && /* @__PURE__ */ C(u, {
162
+ content: (l = o == null ? void 0 : o.validatorMessage) == null ? "该字段不合法" : l,
159
163
  children: /* @__PURE__ */ C(y, { className: "validator-icon" })
160
164
  })]
161
165
  });
@@ -164,10 +168,11 @@ var D = {
164
168
  return new o();
165
169
  }, A = (e) => {
166
170
  let { pattern: t, cell: n, componentProps: i, Com: a, cellRender: o } = e, s = r(() => {
167
- if (n?.getField) return E({
168
- ...n?.getField && n?.getField(),
169
- enum: n?.getField()?.enum || n?.values
170
- }, { [n?.getField && n?.getField().name]: n.text });
171
+ var e;
172
+ if (n != null && n.getField) return E({
173
+ ...(n == null ? void 0 : n.getField) && (n == null ? void 0 : n.getField()),
174
+ enum: (n == null || (e = n.getField()) == null ? void 0 : e.enum) || (n == null ? void 0 : n.values)
175
+ }, { [(n == null ? void 0 : n.getField) && (n == null ? void 0 : n.getField().name)]: n.text });
171
176
  }, [n]);
172
177
  return o && o(e) ? /* @__PURE__ */ C(o, { ...e }) : /* @__PURE__ */ C("div", {
173
178
  className: "base-hoc",
@@ -179,8 +184,8 @@ var D = {
179
184
  ...i
180
185
  })
181
186
  });
182
- }, j = (e) => {
183
- let t = T(5), n = e?.componentProps, r;
187
+ }, ee = (e) => {
188
+ let t = T(5), n = e == null ? void 0 : e.componentProps, r;
184
189
  t[0] === n ? r = t[1] : (r = {
185
190
  ...n,
186
191
  type: "number"
@@ -191,57 +196,68 @@ var D = {
191
196
  componentProps: r,
192
197
  Com: l
193
198
  }), t[2] = e, t[3] = r, t[4] = i) : i = t[4], i;
194
- }, ee = (e) => {
199
+ }, te = (e) => {
195
200
  let n = T(21), { cell: r } = e, { setExpandKeys: i, expandKeys: o, rowKey: s, setNewDataSource: c, record: l } = r, [u, d] = a(!1), f;
196
201
  n[0] !== l || n[1] !== s || n[2] !== c ? (f = (e) => {
197
202
  c((t) => {
198
- let n = [...t], r = l?.children?.map((e) => e?.[s]);
203
+ var n;
204
+ let r = [...t], i = l == null || (n = l.children) == null ? void 0 : n.map((e) => e == null ? void 0 : e[s]);
199
205
  if (e) {
200
- let e = t?.findIndex((e) => e?.[s] == l?.[s]);
201
- return (t?.filter((e) => r?.includes(e?.[s])) || [])?.length == 0 && n.splice(e + 1, 0, ...l?.children || []), [...n];
206
+ let e = t == null ? void 0 : t.findIndex((e) => (e == null ? void 0 : e[s]) == (l == null ? void 0 : l[s])), n = (t == null ? void 0 : t.filter((e) => i == null ? void 0 : i.includes(e == null ? void 0 : e[s]))) || [];
207
+ return (n == null ? void 0 : n.length) == 0 && r.splice(e + 1, 0, ...(l == null ? void 0 : l.children) || []), [...r];
202
208
  }
203
- return t?.filter((e) => !r?.includes(e?.[s]));
209
+ return t == null ? void 0 : t.filter((e) => !(i != null && i.includes(e == null ? void 0 : e[s])));
204
210
  });
205
211
  }, n[0] = l, n[1] = s, n[2] = c, n[3] = f) : f = n[3];
206
212
  let p = f, m;
207
213
  n[4] !== o || n[5] !== p || n[6] !== l || n[7] !== s ? (m = () => {
208
- o?.includes(l?.[s]) && (d(!0), p(!0));
214
+ o != null && o.includes(l == null ? void 0 : l[s]) && (d(!0), p(!0));
209
215
  }, n[4] = o, n[5] = p, n[6] = l, n[7] = s, n[8] = m) : m = n[8];
210
- let h = r?.record, g;
216
+ let h = r == null ? void 0 : r.record, g;
211
217
  n[9] === h ? g = n[10] : (g = [h], n[9] = h, n[10] = g), t(m, g);
212
218
  let _;
213
219
  n[11] !== u || n[12] !== p || n[13] !== l || n[14] !== s || n[15] !== i ? (_ = () => {
214
- i((e) => e?.includes(l?.[s]) ? e?.filter((e) => e != l?.[s]) : [...e, l?.[s]]), d(!u), p(!u);
220
+ 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);
215
221
  }, n[11] = u, n[12] = p, n[13] = l, n[14] = s, n[15] = i, n[16] = _) : _ = n[16];
216
222
  let v = _, y;
217
- return n[17] !== u || n[18] !== v || n[19] !== l?.children ? (y = /* @__PURE__ */ C("div", {
223
+ return n[17] !== u || n[18] !== v || n[19] !== (l == null ? void 0 : l.children) ? (y = /* @__PURE__ */ C("div", {
218
224
  className: "expandList-template",
219
- children: l?.children ? /* @__PURE__ */ C(S, { children: C(u ? b : x, {
225
+ children: l != null && l.children ? /* @__PURE__ */ C(S, { children: C(u ? b : x, {
220
226
  className: "expandList-template-icon",
221
227
  onClick: v
222
228
  }) }) : /* @__PURE__ */ C("div", { style: { width: 14 } })
223
- }), n[17] = u, n[18] = v, n[19] = l?.children, n[20] = y) : y = n[20], y;
229
+ }), n[17] = u, n[18] = v, n[19] = l == null ? void 0 : l.children, n[20] = y) : y = n[20], y;
224
230
  };
225
231
  //#endregion
226
232
  //#region src/common/utils.ts
227
- function M(e) {
233
+ function j(e) {
228
234
  return typeof e == "object" && !!e;
229
235
  }
230
- var N = (e) => typeof e?.title == "function" ? M(e?.title()) ? e?.title()?.props.children : String(e?.title()) || "" : String(e?.title) || "";
231
- function te(e, t = 40) {
232
- let n = (e) => e.reduce((e, t) => t.children?.length ? [...e, ...n(t.children)] : [...e, t], []), r = (e, t = 1) => e.reduce((e, n) => n.children?.length ? Math.max(e, r(n.children, t + 1)) : Math.max(e, t), t), i = n(e), a = r(e), o = i.length, s = (e, t = 0) => e.map((e) => {
233
- if (!(e.children?.length > 0)) return {
236
+ var M = (e) => {
237
+ var t;
238
+ return typeof (e == null ? void 0 : e.title) == "function" ? j(e == null ? void 0 : e.title()) ? e == null || (t = e.title()) == null ? void 0 : t.props.children : String(e == null ? void 0 : e.title()) || "" : String(e == null ? void 0 : e.title) || "";
239
+ };
240
+ function ne(e, t = 40) {
241
+ let n = (e) => e.reduce((e, t) => {
242
+ var r;
243
+ return (r = t.children) != null && r.length ? [...e, ...n(t.children)] : [...e, t];
244
+ }, []), r = (e, t = 1) => e.reduce((e, n) => {
245
+ var i;
246
+ return (i = n.children) != null && i.length ? Math.max(e, r(n.children, t + 1)) : Math.max(e, t);
247
+ }, t), i = n(e), a = r(e), o = i.length, s = (e, t = 0) => e.map((e) => {
248
+ var r;
249
+ if (!(((r = e.children) == null ? void 0 : r.length) > 0)) return {
234
250
  ...e,
235
251
  rowspan: a - t,
236
252
  colspan: 1,
237
253
  _depth: t,
238
254
  _isLeaf: !0
239
255
  };
240
- let r = n(e.children).length;
256
+ let i = n(e.children).length;
241
257
  return {
242
258
  ...e,
243
259
  rowspan: 1,
244
- colspan: r,
260
+ colspan: i,
245
261
  _depth: t,
246
262
  _isLeaf: !1,
247
263
  children: s(e.children, t + 1)
@@ -250,17 +266,20 @@ function te(e, t = 40) {
250
266
  rowId: `header-${n}`,
251
267
  height: t,
252
268
  cells: []
253
- })), u = (e) => ["rowSelection", "ExpandListTemplate"].includes(e?.type) ? e?.type : M(typeof e?.title == "function" ? e?.title() : null) ? `${e?.dataIndex}` : "header", d = (e, t = 0) => {
269
+ })), u = (e) => {
270
+ var t;
271
+ return (t = ["rowSelection", "ExpandListTemplate"]) != null && t.includes(e == null ? void 0 : e.type) ? e == null ? void 0 : e.type : j(typeof (e == null ? void 0 : e.title) == "function" ? e == null ? void 0 : e.title() : null) ? `${e == null ? void 0 : e.dataIndex}` : "header";
272
+ }, d = (e, t = 0) => {
254
273
  e.forEach((e) => {
255
274
  if (e._isLeaf) {
256
275
  let n = {
257
276
  ...e,
258
277
  type: u(e),
259
- text: N(e),
278
+ text: M(e),
260
279
  dataIndex: e.dataIndex,
261
280
  width: e.width,
262
281
  rowspan: e.rowspan,
263
- style: e?.style ? e?.style : {
282
+ style: e != null && e.style ? e == null ? void 0 : e.style : {
264
283
  background: "rgba(128, 128, 128, 0.1)",
265
284
  display: "flex",
266
285
  justifyContent: "center"
@@ -270,9 +289,9 @@ function te(e, t = 40) {
270
289
  } else l[t].cells.push({
271
290
  ...e,
272
291
  type: u(e),
273
- text: N(e),
292
+ text: M(e),
274
293
  colspan: e.colspan,
275
- style: e?.style ? e?.style : {
294
+ style: e != null && e.style ? e == null ? void 0 : e.style : {
276
295
  background: "rgba(128, 128, 128, 0.1)",
277
296
  display: "flex",
278
297
  justifyContent: "center"
@@ -289,11 +308,11 @@ function te(e, t = 40) {
289
308
  n.push({
290
309
  ...e,
291
310
  type: u(e),
292
- text: N(e),
311
+ text: M(e),
293
312
  dataIndex: e.dataIndex,
294
313
  width: e.width,
295
314
  rowspan: t === a - 1 ? 1 : void 0,
296
- style: e?.style ? e?.style : {
315
+ style: e != null && e.style ? e == null ? void 0 : e.style : {
297
316
  background: "rgba(128, 128, 128, 0.1)",
298
317
  display: "flex",
299
318
  justifyContent: "center"
@@ -320,11 +339,11 @@ function te(e, t = 40) {
320
339
  n ? p.push(n) : p.push({
321
340
  ...e,
322
341
  type: u(e),
323
- text: N(e),
342
+ text: M(e),
324
343
  dataIndex: e.dataIndex,
325
344
  width: e.width,
326
345
  rowspan: 1,
327
- style: e?.style ? e?.style : {
346
+ style: e != null && e.style ? e == null ? void 0 : e.style : {
328
347
  background: "rgba(128, 128, 128, 0.1)",
329
348
  display: "flex",
330
349
  justifyContent: "center"
@@ -337,7 +356,7 @@ function te(e, t = 40) {
337
356
  });
338
357
  }), l;
339
358
  }
340
- function ne(e) {
359
+ function re(e) {
341
360
  let t = [];
342
361
  function n(e) {
343
362
  e.forEach((e) => {
@@ -361,141 +380,155 @@ function ne(e) {
361
380
  }
362
381
  //#endregion
363
382
  //#region src/index.tsx
364
- function P(e, s) {
365
- let { columns: l, dataSource: u, formulaConfig: f, onChange: m, reactGridProps: h = {}, onEditSubmit: g, headerRowHeight: y = 44, rowHeight: b = 44, reactGridStyle: x, className: S, Slots: T, rowSelection: E, rowKey: O = "id", query: N, loading: P, isExpand: F = !1, getList: I, onRow: L } = e, [R, re] = a([]), [z, B] = a([]), V = i([]), [H, ie] = a([]), [U, ae] = a([]), [W, G] = a([]), [oe, se] = a([]), [ce, le] = a([]), [ue, K] = a([]), q = i(), de = i(), J = i();
366
- n(s, () => ({ rows: z }));
383
+ function N(e, s) {
384
+ var l;
385
+ let { columns: u, dataSource: f, formulaConfig: m, onChange: h, reactGridProps: g = {}, onEditSubmit: y, headerRowHeight: b = 44, rowHeight: x = 44, reactGridStyle: S, className: T, Slots: E, rowSelection: O, rowKey: M = "id", query: N, loading: P, isExpand: ie = !1, getList: F, onRow: I } = e, [L, ae] = a([]), [R, z] = a([]), B = i([]), [V, oe] = a([]), [H, se] = a([]), [U, W] = a([]), [G, ce] = a([]), [le, ue] = a([]), [de, K] = a([]), q = i(), fe = i(), J = i();
386
+ n(s, () => ({ rows: R }));
367
387
  let Y = (e, t = 0) => {
368
- e?.forEach((e) => {
369
- e.level = t + 1, e?.children && Y(e?.children, e.level);
388
+ e == null || e.forEach((e) => {
389
+ e.level = t + 1, e != null && e.children && Y(e == null ? void 0 : e.children, e.level);
370
390
  });
371
391
  };
372
392
  t(() => {
373
- Y(u), G(u);
374
- }, [u]), t(() => {
375
- z.map((e) => e.rowId)?.includes(q.current) || K([]);
376
- }, [z]);
377
- let fe = (e) => {
378
- let t = e?.cells?.[0]?.record, n = ["_$actions", "rowSelection"], r = { id: e?.rowId };
379
- return e?.cells?.forEach((e) => {
380
- e?.columnId && !n?.includes(e?.columnId) && (r[e?.columnId] = e?.text || e?.value || e?.selectedValue || "", e?.type == "Number" && (r[e?.columnId] = e?.value));
393
+ Y(f), W(f);
394
+ }, [f]), t(() => {
395
+ let e = R.map((e) => e.rowId);
396
+ e != null && e.includes(q.current) || K([]);
397
+ }, [R]);
398
+ let pe = (e) => {
399
+ var t, n;
400
+ 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 };
401
+ return e == null || (n = e.cells) == null || n.forEach((e) => {
402
+ e != null && e.columnId && !(i != null && i.includes(e == null ? void 0 : e.columnId)) && (a[e == null ? void 0 : e.columnId] = (e == null ? void 0 : e.text) || (e == null ? void 0 : e.value) || (e == null ? void 0 : e.selectedValue) || "", (e == null ? void 0 : e.type) == "Number" && (a[e == null ? void 0 : e.columnId] = e == null ? void 0 : e.value));
381
403
  }), {
382
- ...t,
383
- ...r
404
+ ...r,
405
+ ...a
384
406
  };
385
407
  };
386
408
  t(() => {
387
- if (Array.isArray(l) && l?.length > 0) {
388
- F && l.unshift({
409
+ if (Array.isArray(u) && (u == null ? void 0 : u.length) > 0) {
410
+ ie && u.unshift({
389
411
  type: "ExpandListTemplate",
390
412
  width: 14,
391
413
  key: "ExpandListTemplate",
392
414
  nonEditable: !0,
393
- style: E?.style || { background: "rgba(128, 128, 128, 0.1)" }
394
- }), E && l.unshift({
415
+ style: (O == null ? void 0 : O.style) || { background: "rgba(128, 128, 128, 0.1)" }
416
+ }), O && u.unshift({
395
417
  type: "rowSelection",
396
418
  nonEditable: !0,
397
- width: E?.width || 30,
419
+ width: (O == null ? void 0 : O.width) || 30,
398
420
  key: "rowSelection",
399
- style: E?.style || {
421
+ style: (O == null ? void 0 : O.style) || {
400
422
  background: "rgba(128, 128, 128, 0.1)",
401
423
  display: "flex",
402
424
  justifyContent: "center"
403
425
  }
404
- }), re(te(l, y));
405
- let e = ne(l);
406
- ie(e?.map((e, t) => ({
426
+ }), ae(ne(u, b));
427
+ let e = re(u);
428
+ oe(e == null ? void 0 : e.map((e, t) => ({
407
429
  ...e,
408
- columnId: e?.dataIndex || e?.key || e?.name || ""
430
+ columnId: (e == null ? void 0 : e.dataIndex) || (e == null ? void 0 : e.key) || (e == null ? void 0 : e.name) || ""
409
431
  })));
410
432
  }
411
- }, [l, E]);
433
+ }, [u, O]);
412
434
  let X = {}, Z = (e) => {
413
- e?.forEach((e) => {
414
- if (M(typeof e?.title == "function" ? e?.title() : null)) {
415
- let t = e?.title;
416
- X[e?.dataIndex] = k(t);
435
+ e == null || e.forEach((e) => {
436
+ if (j(typeof (e == null ? void 0 : e.title) == "function" ? e == null ? void 0 : e.title() : null)) {
437
+ let t = e == null ? void 0 : e.title;
438
+ X[e == null ? void 0 : e.dataIndex] = k(t);
417
439
  }
418
- e?.children && Z(e?.children);
440
+ e != null && e.children && Z(e == null ? void 0 : e.children);
419
441
  });
420
442
  };
421
443
  t(() => {
422
- Z(l), le(X);
423
- }, [l]), t(() => {
424
- let e = H?.map((e) => e?.columnId), t = W?.map((t, n) => ({
425
- rowId: t[O],
426
- height: b,
427
- cells: e?.map((e, r) => {
428
- let i = {}, a = H[r], o = t[e], s = a?.type ?? "text";
429
- if (f) {
430
- for (let n in f) if (n == e) {
431
- let e = f[n];
432
- i = {
433
- text: e?.setCellData && e?.setCellData(t),
434
- value: e?.setCellData && e?.setCellData(t),
435
- style: e?.setCellStyle && e?.setCellStyle(e?.setCellData && e?.setCellData(t) || t)
444
+ Z(u), ue(X);
445
+ }, [u]), t(() => {
446
+ let e = V == null ? void 0 : V.map((e) => e == null ? void 0 : e.columnId), t = U == null ? void 0 : U.map((t, n) => ({
447
+ rowId: t[M],
448
+ height: x,
449
+ cells: e == null ? void 0 : e.map((e, r) => {
450
+ var i;
451
+ let a = {}, o = V[r], s = t[e], c = (i = o == null ? void 0 : o.type) == null ? "text" : i;
452
+ if (m) {
453
+ for (let n in m) if (n == e) {
454
+ let e = m[n];
455
+ a = {
456
+ text: (e == null ? void 0 : e.setCellData) && (e == null ? void 0 : e.setCellData(t)),
457
+ value: (e == null ? void 0 : e.setCellData) && (e == null ? void 0 : e.setCellData(t)),
458
+ style: (e == null ? void 0 : e.setCellStyle) && (e == null ? void 0 : e.setCellStyle((e == null ? void 0 : e.setCellData) && (e == null ? void 0 : e.setCellData(t)) || t))
436
459
  };
437
460
  }
438
461
  }
439
462
  return {
440
- ...a,
463
+ ...o,
441
464
  record: t,
442
- rowId: t[O] || a?.type,
443
- type: s,
444
- nonEditable: a?.nonEditable,
445
- text: String(o || ""),
446
- value: o,
447
- selectedValue: o || "",
448
- style: a?.type == "rowSelection" ? {
465
+ rowId: t[M] || (o == null ? void 0 : o.type),
466
+ type: c,
467
+ nonEditable: o == null ? void 0 : o.nonEditable,
468
+ text: String(s || ""),
469
+ value: s,
470
+ selectedValue: s || "",
471
+ style: (o == null ? void 0 : o.type) == "rowSelection" ? {
449
472
  display: "flex",
450
473
  justifyContent: "center"
451
474
  } : {},
452
- ...L && L(t, n, r) || {},
453
- ...a?.onCell && a?.onCell(t, n, r) || {},
454
- ...a?.cellProps || {},
455
- setNewDataSource: G,
456
- setExpandKeys: se,
457
- rowKey: O,
458
- expandKeys: oe,
459
- Slots: T,
460
- ...i
475
+ ...I && I(t, n, r) || {},
476
+ ...(o == null ? void 0 : o.onCell) && (o == null ? void 0 : o.onCell(t, n, r)) || {},
477
+ ...(o == null ? void 0 : o.cellProps) || {},
478
+ setNewDataSource: W,
479
+ setExpandKeys: ce,
480
+ rowKey: M,
481
+ expandKeys: G,
482
+ Slots: E,
483
+ ...a
461
484
  };
462
485
  })
463
- })), n = [...R, ...t];
464
- B(n);
486
+ })), n = [...L, ...t];
487
+ z(n);
465
488
  }, [
466
- W,
467
- H,
468
- R
489
+ U,
490
+ V,
491
+ L
469
492
  ]), t(() => {
470
- P && ((z?.find((e) => e?.rowId == J.current?.rowId))?.cells?.find((e) => e?.columnId == J.current?.columnId), { ...J.current }, V.current = z);
471
- }, [P, z]);
472
- let pe = async (e) => {
493
+ if (P) {
494
+ var e;
495
+ let t = R == null ? void 0 : R.find((e) => {
496
+ var t;
497
+ return (e == null ? void 0 : e.rowId) == ((t = J.current) == null ? void 0 : t.rowId);
498
+ });
499
+ t == null || (e = t.cells) == null || e.find((e) => {
500
+ var t;
501
+ return (e == null ? void 0 : e.columnId) == ((t = J.current) == null ? void 0 : t.columnId);
502
+ }), { ...J.current }, B.current = R;
503
+ }
504
+ }, [P, R]);
505
+ let me = async (e) => {
473
506
  let t = [];
474
507
  if (!Array.isArray(e) || e.length === 0) return;
475
508
  let n = !1;
476
- if (e?.length > 1 && (n = !0), B((r) => (e.forEach(async (e) => {
477
- let i = r.findIndex((t) => t.rowId == e.rowId), a = H.findIndex((t) => t.columnId == e.columnId);
478
- if (r[i].cells[a] = { ...e.newCell }, J.current = { ...e.newCell }, t.push(fe(r[i])), f) for (let e in f) {
479
- let t = f[e], n = H.findIndex((t) => t.columnId == e), a = {
509
+ if ((e == null ? void 0 : e.length) > 1 && (n = !0), z((r) => (e.forEach(async (e) => {
510
+ let i = r.findIndex((t) => t.rowId == e.rowId), a = V.findIndex((t) => t.columnId == e.columnId);
511
+ if (r[i].cells[a] = { ...e.newCell }, J.current = { ...e.newCell }, t.push(pe(r[i])), m) for (let e in m) {
512
+ let t = m[e], n = V.findIndex((t) => t.columnId == e), a = {
480
513
  ...r[i].cells[n],
481
- text: t?.setCellData && t?.setCellData(r[i]),
482
- value: t?.setCellData && t?.setCellData(r[i]),
483
- style: t?.setCellStyle && t?.setCellStyle(t?.setCellData && t?.setCellData(r[i]) || r[i])
514
+ text: (t == null ? void 0 : t.setCellData) && (t == null ? void 0 : t.setCellData(r[i])),
515
+ value: (t == null ? void 0 : t.setCellData) && (t == null ? void 0 : t.setCellData(r[i])),
516
+ 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]))
484
517
  };
485
518
  r[i].cells[n] = a;
486
519
  }
487
- if (g && !n) try {
488
- await g(t);
489
- } catch {
490
- I && I();
520
+ if (y && !n) try {
521
+ await y(t);
522
+ } catch (e) {
523
+ F && F();
491
524
  }
492
- m && m(r[i]);
525
+ h && h(r[i]);
493
526
  }), [...r])), n) try {
494
- g && await g(t);
495
- } catch {
496
- I && I();
527
+ y && await y(t);
528
+ } catch (e) {
529
+ F && F();
497
530
  }
498
- }, me = r(() => {
531
+ }, Q = r(() => {
499
532
  let t = {
500
533
  ..._ || {},
501
534
  ...v || {},
@@ -507,25 +540,28 @@ function P(e, s) {
507
540
  Com: t[r]
508
541
  }));
509
542
  return n;
510
- }, [_, v]), Q = (e) => {
511
- let t = z?.find((t) => t?.rowId == e?.cell?.rowId);
543
+ }, [_, v]), he = (e) => {
544
+ let t = R == null ? void 0 : R.find((t) => {
545
+ var n;
546
+ return (t == null ? void 0 : t.rowId) == (e == null || (n = e.cell) == null ? void 0 : n.rowId);
547
+ });
512
548
  return /* @__PURE__ */ w("div", {
513
549
  onPointerDown: (e) => e.stopPropagation(),
514
550
  children: [
515
- T?.tableActionsSlot && /* @__PURE__ */ C(T.tableActionsSlot, {
516
- ...e?.cell,
551
+ (E == null ? void 0 : E.tableActionsSlot) && /* @__PURE__ */ C(E.tableActionsSlot, {
552
+ ...e == null ? void 0 : e.cell,
517
553
  rowData: t
518
554
  }),
519
- T?.actionPrefixSlot && /* @__PURE__ */ C(T.actionPrefixSlot, {
520
- ...e?.cell,
555
+ (E == null ? void 0 : E.actionPrefixSlot) && /* @__PURE__ */ C(E.actionPrefixSlot, {
556
+ ...e == null ? void 0 : e.cell,
521
557
  rowData: t
522
558
  }),
523
- T?.actionCenterSlot && /* @__PURE__ */ C(T.actionCenterSlot, {
524
- ...e?.cell,
559
+ (E == null ? void 0 : E.actionCenterSlot) && /* @__PURE__ */ C(E.actionCenterSlot, {
560
+ ...e == null ? void 0 : e.cell,
525
561
  rowData: t
526
562
  }),
527
- T?.actionSuffixSlot && /* @__PURE__ */ C(T.actionSuffixSlot, {
528
- ...e?.cell,
563
+ (E == null ? void 0 : E.actionSuffixSlot) && /* @__PURE__ */ C(E.actionSuffixSlot, {
564
+ ...e == null ? void 0 : e.cell,
529
565
  rowData: t
530
566
  })
531
567
  ]
@@ -538,89 +574,100 @@ function P(e, s) {
538
574
  }
539
575
  return n(e), t;
540
576
  }
541
- let he = (e) => {
542
- let { record: t, rowId: n } = e?.cell, r = $(u);
577
+ let ge = (e) => {
578
+ var t, n, r, i, a, s;
579
+ let { record: c, rowId: l } = e == null ? void 0 : e.cell, u = (t = $(f)) == null ? void 0 : t.filter((e) => {
580
+ var t;
581
+ return !(O != null && (t = O.getCheckboxProps) != null && (t = t.call(O, e)) != null && t.disabled);
582
+ }), d = typeof (O == null ? void 0 : O.getCheckboxProps) == "function" ? O == null || (n = O.getCheckboxProps) == null ? void 0 : n.call(O, c) : {};
543
583
  return /* @__PURE__ */ C(o, {
544
- ...e?.componentProps,
545
- checked: E?.selectedRowKeys?.includes(t && t[O] || "") || E?.selectedRowKeys?.length == r?.length && r?.length > 0,
546
- indeterminate: !n && E?.selectedRowKeys?.length > 0 && E?.selectedRowKeys?.length < r?.length,
584
+ ...e == null ? void 0 : e.componentProps,
585
+ checked: (O == null || (r = O.selectedRowKeys) == null ? void 0 : r.includes(c && c[M] || "")) || !l && (O == null || (i = O.selectedRowKeys) == null ? void 0 : i.length) == (u == null ? void 0 : u.length) && (u == null ? void 0 : u.length) > 0,
586
+ indeterminate: !l && (O == null || (a = O.selectedRowKeys) == null ? void 0 : a.length) > 0 && (O == null || (s = O.selectedRowKeys) == null ? void 0 : s.length) < (u == null ? void 0 : u.length),
547
587
  onChange: (e) => {
548
- if (e.target.checked && n) {
549
- let e = [...E?.selectedRowKeys, t[O]], n = r?.filter((t) => e?.includes(t[O]));
550
- E?.onChange(e, n);
551
- } else if (!e.target.checked && n) {
552
- let e = E?.selectedRowKeys?.filter((e) => e != t[O]), n = r?.filter((t) => e?.includes(t[O]));
553
- E?.onChange(E?.selectedRowKeys?.filter((e) => e != t[O]), n);
554
- } else if (e.target.checked && !n) {
555
- let e = r?.map((e) => e[O]), t = r?.filter((t) => e?.includes(t[O]));
556
- E?.onChange(r?.map((e) => e[O]), t);
557
- } else !e.target.checked && !n && E?.onChange([], []);
558
- }
588
+ if (e.target.checked && l) {
589
+ let e = [...O == null ? void 0 : O.selectedRowKeys, c[M]], t = u == null ? void 0 : u.filter((t) => e == null ? void 0 : e.includes(t[M]));
590
+ O == null || O.onChange(e, t);
591
+ } else if (!e.target.checked && l) {
592
+ var t, n;
593
+ let e = O == null || (t = O.selectedRowKeys) == null ? void 0 : t.filter((e) => e != c[M]), r = u == null ? void 0 : u.filter((t) => e == null ? void 0 : e.includes(t[M]));
594
+ O == null || O.onChange(O == null || (n = O.selectedRowKeys) == null ? void 0 : n.filter((e) => e != c[M]), r);
595
+ } else if (e.target.checked && !l) {
596
+ let e = u == null ? void 0 : u.map((e) => e[M]), t = u == null ? void 0 : u.filter((t) => e == null ? void 0 : e.includes(t[M]));
597
+ O == null || O.onChange(u == null ? void 0 : u.map((e) => e[M]), t);
598
+ } else !e.target.checked && !l && (O == null || O.onChange([], []));
599
+ },
600
+ ...d
559
601
  });
560
602
  };
561
603
  t(() => {
562
- if (E) {
563
- let e = $(u)?.filter((e) => U?.includes(e[O]));
564
- E?.onChange(U, e);
604
+ if (O) {
605
+ var e;
606
+ let t = (e = $(f)) == null ? void 0 : e.filter((e) => {
607
+ var t;
608
+ return !(O != null && (t = O.getCheckboxProps) != null && (t = t.call(O, e)) != null && t.disabled);
609
+ }), n = t == null ? void 0 : t.filter((e) => H == null ? void 0 : H.includes(e[M]));
610
+ O == null || O.onChange(H, n);
565
611
  }
566
- }, [U, u]), t(() => {
567
- ae([]);
568
- }, [N?.pageNum]);
569
- let ge = r(() => {
612
+ }, [H, f]), t(() => {
613
+ se([]);
614
+ }, [N == null ? void 0 : N.pageNum]);
615
+ let _e = r(() => {
570
616
  let e = {};
571
- for (let t in h?.customCellTemplates) {
572
- let n = h?.customCellTemplates[t];
573
- e[t] = k(n);
574
- }
617
+ for (let t in g == null ? void 0 : g.customCellTemplates) e[t] = k(g == null ? void 0 : g.customCellTemplates[t]);
575
618
  return e;
576
- }, [h?.customCellTemplates]), _e = (e, t) => {
577
- let n = t?.find((t) => t?.rowId == e?.rowId)?.cells?.map((t) => ({
578
- columnId: t?.columnId,
579
- rowId: e?.rowId,
619
+ }, [g == null ? void 0 : g.customCellTemplates]), ve = (e, t) => {
620
+ var n;
621
+ 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) => ({
622
+ columnId: t == null ? void 0 : t.columnId,
623
+ rowId: e == null ? void 0 : e.rowId,
580
624
  className: "custom-highlights-row",
581
625
  borderColor: "transparent"
582
626
  }));
583
- q.current = e?.rowId, K(n);
627
+ q.current = e == null ? void 0 : e.rowId, K(r);
584
628
  };
585
629
  return /* @__PURE__ */ C(d, {
586
630
  spinning: P,
587
631
  children: /* @__PURE__ */ w("div", {
588
- className: `grid-container ${S}`,
589
- style: x,
632
+ className: `grid-container ${T}`,
633
+ style: S,
590
634
  children: [/* @__PURE__ */ C(p, {
591
- ref: de,
592
- rows: P ? V.current : z,
593
- columns: H,
594
- onCellsChanged: pe,
635
+ ref: fe,
636
+ rows: P ? B.current : R,
637
+ columns: V,
638
+ onCellsChanged: me,
595
639
  enableFillHandle: !0,
596
640
  enableRangeSelection: !0,
597
641
  horizontalStickyBreakpoint: 120,
598
- ...h,
599
- highlights: h?.highlights ?? ue,
642
+ ...g,
643
+ highlights: (l = g == null ? void 0 : g.highlights) == null ? de : l,
600
644
  onFocusLocationChanging: (e) => {
601
- let t = e?.columnId + e?.rowId;
602
- return window.gridEditId = t, typeof e?.rowId == "string" && e?.rowId?.indexOf("header-") > -1 || (h?.isRowHighlights && e?.columnId && _e(e, z), [
645
+ var t, n;
646
+ let r = (e == null ? void 0 : e.columnId) + (e == null ? void 0 : e.rowId);
647
+ 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 && ve(e, R), (n = [
603
648
  "_$actions",
604
649
  "rowSelection",
605
650
  "ExpandListTemplate"
606
- ].includes(e?.columnId)) ? !1 : h?.onFocusLocationChanging ? h?.onFocusLocationChanging(e, z) : e;
651
+ ]) != null && n.includes(e == null ? void 0 : e.columnId)) ? !1 : g != null && g.onFocusLocationChanging ? g == null ? void 0 : g.onFocusLocationChanging(e, R) : e;
607
652
  },
608
653
  customCellTemplates: {
609
- ExpandListTemplate: k(ee),
610
- ...me,
611
- ...ge,
612
- ...ce,
613
- _$actions: k(Q),
614
- rowSelection: k(he),
615
- Number: k(j, e)
654
+ ExpandListTemplate: k(te),
655
+ ...Q,
656
+ ..._e,
657
+ ...le,
658
+ _$actions: k(he),
659
+ rowSelection: k(ge),
660
+ Number: k(ee, e)
616
661
  }
617
- }, u?.length == 0 ? 0 : 1), u?.length <= 0 && /* @__PURE__ */ C("div", {
662
+ }, (f == null ? void 0 : f.length) == 0 ? 0 : 1), (f == null ? void 0 : f.length) <= 0 && /* @__PURE__ */ C("div", {
618
663
  className: "grid-container-empty",
619
664
  children: /* @__PURE__ */ C(c, { image: c.PRESENTED_IMAGE_SIMPLE })
620
665
  })]
621
666
  })
622
667
  });
623
668
  }
624
- var F = e(P);
669
+ var P = e(N);
625
670
  //#endregion
626
- export { F as default };
671
+ export { P as default };
672
+
673
+ //# sourceMappingURL=index.js.map