@sage-bionetworks/react-datasheet-grid 4.11.5-sage.11 → 4.11.5-sage.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.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +433 -410
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -64,11 +64,11 @@ var b = (e, t) => {
|
|
|
64
64
|
};
|
|
65
65
|
if (/^ *\d+(\.\d*)? *$/.exec(e)) return {
|
|
66
66
|
basis: 0,
|
|
67
|
-
grow: parseFloat(e.trim()),
|
|
67
|
+
grow: Number.parseFloat(e.trim()),
|
|
68
68
|
shrink: 1
|
|
69
69
|
};
|
|
70
70
|
if (/^ *\d+(\.\d*)? *px *$/.exec(e)) return {
|
|
71
|
-
basis: parseFloat(e.trim()),
|
|
71
|
+
basis: Number.parseFloat(e.trim()),
|
|
72
72
|
grow: 1,
|
|
73
73
|
shrink: 1
|
|
74
74
|
};
|
|
@@ -76,24 +76,24 @@ var b = (e, t) => {
|
|
|
76
76
|
let [t, n] = e.trim().split(" ");
|
|
77
77
|
return {
|
|
78
78
|
basis: 0,
|
|
79
|
-
grow: parseFloat(t),
|
|
80
|
-
shrink: parseFloat(n)
|
|
79
|
+
grow: Number.parseFloat(t),
|
|
80
|
+
shrink: Number.parseFloat(n)
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
if (/^ *\d+(\.\d*)? \d+(\.\d*)? *px *$/.exec(e)) {
|
|
84
84
|
let [t, n] = e.trim().split(" ");
|
|
85
85
|
return {
|
|
86
|
-
basis: parseFloat(n),
|
|
87
|
-
grow: parseFloat(t),
|
|
86
|
+
basis: Number.parseFloat(n),
|
|
87
|
+
grow: Number.parseFloat(t),
|
|
88
88
|
shrink: 1
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
if (/^ *\d+(\.\d*)? \d+(\.\d*)? \d+(\.\d*)? *px *$/.exec(e)) {
|
|
92
92
|
let [t, n, r] = e.trim().split(" ");
|
|
93
93
|
return {
|
|
94
|
-
basis: parseFloat(r),
|
|
95
|
-
grow: parseFloat(t),
|
|
96
|
-
shrink: parseFloat(n)
|
|
94
|
+
basis: Number.parseFloat(r),
|
|
95
|
+
grow: Number.parseFloat(t),
|
|
96
|
+
shrink: Number.parseFloat(n)
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
return {
|
|
@@ -165,7 +165,7 @@ var b = (e, t) => {
|
|
|
165
165
|
return m(n, t) ? t : n;
|
|
166
166
|
});
|
|
167
167
|
}, [r])];
|
|
168
|
-
},
|
|
168
|
+
}, te = (e, t, r) => {
|
|
169
169
|
let [i, a] = A({
|
|
170
170
|
top: !0,
|
|
171
171
|
right: !0,
|
|
@@ -190,7 +190,7 @@ var b = (e, t) => {
|
|
|
190
190
|
e,
|
|
191
191
|
a
|
|
192
192
|
]), i;
|
|
193
|
-
},
|
|
193
|
+
}, j = (e, t) => {
|
|
194
194
|
n(() => {
|
|
195
195
|
let n = (...e) => {
|
|
196
196
|
t(...e);
|
|
@@ -199,12 +199,12 @@ var b = (e, t) => {
|
|
|
199
199
|
document.removeEventListener(e, n);
|
|
200
200
|
};
|
|
201
201
|
}, [t, e]);
|
|
202
|
-
},
|
|
202
|
+
}, M = (e, n = 200) => {
|
|
203
203
|
let r = o(null), i = a(() => p(n, !0, () => {
|
|
204
204
|
setTimeout(() => r.current = e.current?.getBoundingClientRect() || null, 0);
|
|
205
205
|
}), [e, n]);
|
|
206
206
|
return t((t = !1) => (t ? r.current = e.current?.getBoundingClientRect() || null : i(), r.current), [e, i]);
|
|
207
|
-
},
|
|
207
|
+
}, N = (e = {}) => ({ addRows: t }) => {
|
|
208
208
|
let [n, r] = s(1), [i, a] = s(String(n));
|
|
209
209
|
return /* @__PURE__ */ d("div", {
|
|
210
210
|
className: "dsg-add-row",
|
|
@@ -233,15 +233,15 @@ var b = (e, t) => {
|
|
|
233
233
|
e.unit ?? "rows"
|
|
234
234
|
]
|
|
235
235
|
});
|
|
236
|
-
},
|
|
237
|
-
|
|
236
|
+
}, ne = N();
|
|
237
|
+
ne.displayName = "AddRows";
|
|
238
238
|
// src/hooks/useDebounceState.ts
|
|
239
|
-
var
|
|
239
|
+
var re = (e, t) => {
|
|
240
240
|
let [r, i] = s(e), c = o(void 0);
|
|
241
241
|
return n(() => () => c.current?.cancel(), []), [r, a(() => c.current = f(t, (e) => {
|
|
242
242
|
i(e);
|
|
243
243
|
}), [t])];
|
|
244
|
-
},
|
|
244
|
+
}, P = (e) => e.type === "CUT" ? /* @__PURE__ */ u(l, { children: "Cut" }) : e.type === "COPY" ? /* @__PURE__ */ u(l, { children: "Copy" }) : e.type === "PASTE" ? /* @__PURE__ */ u(l, { children: "Paste" }) : e.type === "DELETE_ROW" ? /* @__PURE__ */ u(l, { children: "Delete row" }) : e.type === "DELETE_ROWS" ? /* @__PURE__ */ d(l, { children: [
|
|
245
245
|
"Delete rows ",
|
|
246
246
|
/* @__PURE__ */ u("b", { children: e.fromRow }),
|
|
247
247
|
" to ",
|
|
@@ -251,9 +251,9 @@ var ie = (e, t) => {
|
|
|
251
251
|
/* @__PURE__ */ u("b", { children: e.fromRow }),
|
|
252
252
|
" to ",
|
|
253
253
|
/* @__PURE__ */ u("b", { children: e.toRow })
|
|
254
|
-
] }) : e.type,
|
|
254
|
+
] }) : e.type, F = (e = P) => ({ clientX: n, clientY: r, items: i, close: a }) => {
|
|
255
255
|
let s = o(null);
|
|
256
|
-
return
|
|
256
|
+
return j("mousedown", t((e) => {
|
|
257
257
|
s.current?.contains(e.target) || a();
|
|
258
258
|
}, [a])), /* @__PURE__ */ u("div", {
|
|
259
259
|
className: "dsg-context-menu",
|
|
@@ -268,11 +268,11 @@ var ie = (e, t) => {
|
|
|
268
268
|
children: e(t)
|
|
269
269
|
}, t.type))
|
|
270
270
|
});
|
|
271
|
-
},
|
|
272
|
-
|
|
271
|
+
}, ie = F(P);
|
|
272
|
+
ie.displayName = "ContextMenu";
|
|
273
273
|
// src/utils/domParser.ts
|
|
274
|
-
var
|
|
275
|
-
let t =
|
|
274
|
+
var ae = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => null }, oe = (e) => ae.parseFromString(h.sanitize(e, { FORBID_TAGS: ["style"] }), "text/html"), se = (e) => {
|
|
275
|
+
let t = oe(e.replaceAll(/<br\/?>/g, "\n")), n = t.getElementsByTagName("table")[0];
|
|
276
276
|
if (n) {
|
|
277
277
|
let e = [];
|
|
278
278
|
for (let t of Array.from(n.rows)) {
|
|
@@ -284,7 +284,7 @@ var oe = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
284
284
|
}
|
|
285
285
|
let r = t.getElementsByTagName("span")[0];
|
|
286
286
|
return r ? [[r.textContent ?? ""]] : [[""]];
|
|
287
|
-
},
|
|
287
|
+
}, ce = (e) => {
|
|
288
288
|
let t = e.replaceAll(/\r|\n$/g, ""), n = [[]], r = 0, i = 0, a = !1, o = 0, s = () => {
|
|
289
289
|
let e = t.slice(i, r);
|
|
290
290
|
e.startsWith("\"") && e.at(-1) === "\"" && (a = !0), a && e.at(-1) === "\"" && e.includes("\n") && (e = e.slice(1, -1).replaceAll("\"\"", "\""), a = !1), a && e.at(-1) !== "\"" ? e.split("\n").forEach((e, t, { length: r }) => {
|
|
@@ -297,7 +297,7 @@ var oe = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
297
297
|
"\""
|
|
298
298
|
].includes(t[r + 1]) && (a = !1), a && t[r] === "\"" && t[r + 1] === "\"" && r++, r === i && t[r] === "\"" && (a = !0), t[r] === " " && (s(), i = r + 1, a = !1), t[r] === "\n" && !a && (s(), n.push([]), i = r + 1, o++), r++;
|
|
299
299
|
return s(), n;
|
|
300
|
-
},
|
|
300
|
+
}, le = (e) => /[\t\n\r"]/.test(e) ? `"${e.replaceAll("\"", "\"\"")}"` : e, ue = (e) => e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'"), de = (e) => /^[^\x00-\x20\x7F-\x9F]$/.exec(e) !== null, fe = (e, t, n, r) => {
|
|
301
301
|
if (e === null || !t || !n) return null;
|
|
302
302
|
if (typeof e != "object") throw TypeError("Value must be an object or null");
|
|
303
303
|
let i = r.findIndex((t) => t.id === e.col), a = {
|
|
@@ -306,182 +306,184 @@ var oe = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
306
306
|
};
|
|
307
307
|
if (isNaN(a.col) || isNaN(a.row)) throw TypeError("col or cell are not valid positive numbers");
|
|
308
308
|
return a;
|
|
309
|
-
},
|
|
309
|
+
}, pe = (e, t) => e ? {
|
|
310
310
|
col: e.col,
|
|
311
311
|
row: e.row,
|
|
312
312
|
colId: t[e.col + 1]?.id
|
|
313
|
-
} : null,
|
|
313
|
+
} : null, me = (e, t, n, r) => {
|
|
314
314
|
if (e === null || !t || !n) return null;
|
|
315
315
|
if (typeof e != "object") throw TypeError("Value must be an object or null");
|
|
316
316
|
let i = {
|
|
317
|
-
min:
|
|
318
|
-
max:
|
|
317
|
+
min: fe(e.min, t, n, r),
|
|
318
|
+
max: fe(e.max, t, n, r)
|
|
319
319
|
};
|
|
320
320
|
if (!i.min || !i.max) throw Error("min and max must be defined");
|
|
321
321
|
return i;
|
|
322
|
-
},
|
|
323
|
-
min:
|
|
324
|
-
max:
|
|
325
|
-
} : null,
|
|
322
|
+
}, he = (e, t) => e ? {
|
|
323
|
+
min: pe(e.min, t),
|
|
324
|
+
max: pe(e.max, t)
|
|
325
|
+
} : null, ge = () => Array.from(document.querySelectorAll("*")).filter((e) => e instanceof HTMLElement && typeof e.tabIndex == "number" && e.tabIndex >= 0 && !e.disabled && (!(e instanceof HTMLAnchorElement) || !!e.href || e.getAttribute("tabIndex") !== null) && getComputedStyle(e).visibility !== "collapse"), _e = (e, t) => e.key?.toLowerCase() === t, ve = (e) => (e.ctrlKey || e.metaKey) && !e.shiftKey && !e.altKey && _e(e, "z"), ye = (e) => !e.altKey && (e.ctrlKey && !e.shiftKey && _e(e, "y") || (e.ctrlKey || e.metaKey) && e.shiftKey && _e(e, "z")), be = ({ children: e, gutter: t, stickyRight: n, stickyLeft: r, active: i, disabled: a, className: o, width: s, left: c }) => /* @__PURE__ */ u("div", {
|
|
326
326
|
className: v("dsg-cell", t && "dsg-cell-gutter", a && "dsg-cell-disabled", t && i && "dsg-cell-gutter-active", n && "dsg-cell-sticky-right", r && "dsg-cell-sticky-left", o),
|
|
327
327
|
style: {
|
|
328
328
|
width: s,
|
|
329
329
|
left: n ? void 0 : c
|
|
330
330
|
},
|
|
331
331
|
children: e
|
|
332
|
-
}),
|
|
332
|
+
}), xe = (e, t) => a(() => {
|
|
333
333
|
let n = /* @__PURE__ */ new Map();
|
|
334
334
|
return (r) => (n.has(r) || n.set(r, (...n) => {
|
|
335
335
|
e(r, ...n.slice(0, t));
|
|
336
336
|
}), n.get(r));
|
|
337
|
-
}, [t, e]),
|
|
338
|
-
let
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
rowIndex: t
|
|
349
|
-
});
|
|
350
|
-
if (typeof p == "string" && n instanceof Object && p in n) {
|
|
351
|
-
let e = n[p];
|
|
352
|
-
if (typeof e == "string" || typeof e == "number") return e;
|
|
353
|
-
}
|
|
337
|
+
}, [t, e]), Se = ({ data: e, columns: r, outerRef: i, innerRef: a, columnWidths: o, hasStickyRightColumn: s, pinFirstColumn: c, displayHeight: l, headerRowHeight: f, rowHeight: p, getRowSize: m, rowKey: h, fullWidth: y, selection: b, activeCell: x, rowClassName: S, cellClassName: C, children: w, editing: T, getContextMenuItems: E, setRowData: D, deleteRows: O, duplicateRows: ee, insertRowAfter: k, stopEditing: A, onScroll: te }) => {
|
|
338
|
+
let j = t((t) => {
|
|
339
|
+
if (h && t > 0) {
|
|
340
|
+
let n = e[t - 1];
|
|
341
|
+
if (typeof h == "function") return h({
|
|
342
|
+
rowData: n,
|
|
343
|
+
rowIndex: t
|
|
344
|
+
});
|
|
345
|
+
if (typeof h == "string" && n instanceof Object && h in n) {
|
|
346
|
+
let e = n[h];
|
|
347
|
+
if (typeof e == "string" || typeof e == "number") return e;
|
|
354
348
|
}
|
|
355
|
-
|
|
356
|
-
|
|
349
|
+
}
|
|
350
|
+
return t;
|
|
351
|
+
}, [e, h]), M = _({
|
|
352
|
+
count: e.length,
|
|
353
|
+
getScrollElement: () => i.current,
|
|
354
|
+
paddingStart: f,
|
|
355
|
+
estimateSize: (e) => m(e).height,
|
|
356
|
+
getItemKey: j,
|
|
357
357
|
overscan: 5
|
|
358
|
-
}),
|
|
359
|
-
count:
|
|
360
|
-
getScrollElement: () =>
|
|
361
|
-
estimateSize: (e) =>
|
|
358
|
+
}), N = _({
|
|
359
|
+
count: r.length,
|
|
360
|
+
getScrollElement: () => i.current,
|
|
361
|
+
estimateSize: (e) => o?.[e] ?? 100,
|
|
362
362
|
horizontal: !0,
|
|
363
|
-
getItemKey: (e) =>
|
|
363
|
+
getItemKey: (e) => r[e].id ?? e,
|
|
364
364
|
overscan: 1,
|
|
365
365
|
rangeExtractor: (e) => {
|
|
366
|
-
let
|
|
367
|
-
if (
|
|
368
|
-
let e =
|
|
369
|
-
e === -1 ?
|
|
366
|
+
let t = g(e);
|
|
367
|
+
if (t[0] !== 0 && t.unshift(0), (c || r[1]?.stickyLeft) && r.length > 1 && !t.includes(1)) {
|
|
368
|
+
let e = t.findIndex((e) => e > 1);
|
|
369
|
+
e === -1 ? t.push(1) : t.splice(e, 0, 1);
|
|
370
370
|
}
|
|
371
|
-
return
|
|
371
|
+
return s && t.at(-1) !== r.length - 1 && t.push(r.length - 1), t;
|
|
372
372
|
}
|
|
373
373
|
});
|
|
374
374
|
n(() => {
|
|
375
|
-
|
|
376
|
-
}, [
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
375
|
+
N.measure();
|
|
376
|
+
}, [N, o]), n(() => {
|
|
377
|
+
M.measure();
|
|
378
|
+
}, [M, p]);
|
|
379
|
+
let ne = xe(D, 1), re = xe(O, 0), P = xe(ee, 0), F = xe(k, 0), ie = (e) => {
|
|
380
|
+
if (!r[e].stickyLeft) return 0;
|
|
381
|
+
if (!o?.length) {
|
|
382
|
+
let t = N.getOffsetForIndex(e);
|
|
381
383
|
return typeof t == "number" ? t : 0;
|
|
382
384
|
}
|
|
383
|
-
let
|
|
384
|
-
for (let
|
|
385
|
-
return
|
|
386
|
-
},
|
|
385
|
+
let t = 0;
|
|
386
|
+
for (let n = 0; n < e; n++) t += o[n];
|
|
387
|
+
return t;
|
|
388
|
+
}, ae = b?.min.col ?? x?.col, oe = b?.max.col ?? x?.col, se = b?.min.row ?? x?.row, ce = b?.max.row ?? x?.row;
|
|
387
389
|
return /* @__PURE__ */ u("div", {
|
|
388
|
-
ref:
|
|
390
|
+
ref: i,
|
|
389
391
|
className: "dsg-container",
|
|
390
|
-
onScroll:
|
|
391
|
-
style: { height:
|
|
392
|
+
onScroll: te,
|
|
393
|
+
style: { height: l },
|
|
392
394
|
children: /* @__PURE__ */ d("div", {
|
|
393
|
-
ref:
|
|
395
|
+
ref: a,
|
|
394
396
|
style: {
|
|
395
|
-
width:
|
|
396
|
-
height:
|
|
397
|
+
width: y ? "100%" : N.getTotalSize(),
|
|
398
|
+
height: M.getTotalSize()
|
|
397
399
|
},
|
|
398
400
|
children: [
|
|
399
|
-
|
|
401
|
+
f > 0 && /* @__PURE__ */ u("div", {
|
|
400
402
|
className: v("dsg-row", "dsg-row-header"),
|
|
401
403
|
style: {
|
|
402
|
-
width:
|
|
403
|
-
height:
|
|
404
|
+
width: y ? "100%" : N.getTotalSize(),
|
|
405
|
+
height: f
|
|
404
406
|
},
|
|
405
|
-
children:
|
|
406
|
-
let
|
|
407
|
-
return /* @__PURE__ */ u(
|
|
407
|
+
children: N.getVirtualItems().map((e) => {
|
|
408
|
+
let t = !!r[e.index].stickyLeft;
|
|
409
|
+
return /* @__PURE__ */ u(be, {
|
|
408
410
|
gutter: e.index === 0,
|
|
409
|
-
stickyRight:
|
|
410
|
-
stickyLeft:
|
|
411
|
+
stickyRight: s && e.index === r.length - 1,
|
|
412
|
+
stickyLeft: t,
|
|
411
413
|
width: e.size,
|
|
412
|
-
left:
|
|
413
|
-
className: v("dsg-cell-header",
|
|
414
|
+
left: t ? ie(e.index) : e.start,
|
|
415
|
+
className: v("dsg-cell-header", ae !== void 0 && oe !== void 0 && ae <= e.index - 1 && oe >= e.index - 1 && "dsg-cell-header-active", r[e.index].headerClassName),
|
|
414
416
|
children: /* @__PURE__ */ u("div", {
|
|
415
417
|
className: "dsg-cell-header-container",
|
|
416
|
-
children:
|
|
418
|
+
children: r[e.index].title
|
|
417
419
|
})
|
|
418
420
|
}, e.key);
|
|
419
421
|
})
|
|
420
422
|
}),
|
|
421
|
-
|
|
422
|
-
let
|
|
423
|
+
M.getVirtualItems().map((t) => {
|
|
424
|
+
let n = t.index >= (se ?? Infinity) && t.index <= (ce ?? -Infinity);
|
|
423
425
|
return /* @__PURE__ */ u("div", {
|
|
424
|
-
className: v("dsg-row", typeof
|
|
425
|
-
rowData: e[
|
|
426
|
-
rowIndex:
|
|
426
|
+
className: v("dsg-row", typeof S == "string" ? S : null, typeof S == "function" ? S({
|
|
427
|
+
rowData: e[t.index],
|
|
428
|
+
rowIndex: t.index
|
|
427
429
|
}) : null),
|
|
428
430
|
style: {
|
|
429
|
-
height:
|
|
430
|
-
top:
|
|
431
|
-
width:
|
|
431
|
+
height: t.size,
|
|
432
|
+
top: t.start,
|
|
433
|
+
width: y ? "100%" : N.getTotalSize()
|
|
432
434
|
},
|
|
433
|
-
children:
|
|
434
|
-
let a =
|
|
435
|
-
rowData: e[
|
|
436
|
-
rowIndex:
|
|
437
|
-
}), d =
|
|
438
|
-
return /* @__PURE__ */ u(
|
|
435
|
+
children: N.getVirtualItems().map((i) => {
|
|
436
|
+
let a = r[i.index].cellClassName, o = r[i.index].disabled, c = r[i.index].component, l = o === !0 || typeof o == "function" && o({
|
|
437
|
+
rowData: e[t.index],
|
|
438
|
+
rowIndex: t.index
|
|
439
|
+
}), d = x?.row === t.index && x.col === i.index - 1, f = !!r[i.index].stickyLeft;
|
|
440
|
+
return /* @__PURE__ */ u(be, {
|
|
439
441
|
gutter: i.index === 0,
|
|
440
|
-
stickyRight:
|
|
442
|
+
stickyRight: s && i.index === r.length - 1,
|
|
441
443
|
stickyLeft: f,
|
|
442
|
-
active: i.index === 0 &&
|
|
444
|
+
active: i.index === 0 && n,
|
|
443
445
|
disabled: l,
|
|
444
446
|
className: v(typeof a == "function" ? a({
|
|
445
|
-
rowData: e[
|
|
446
|
-
rowIndex:
|
|
447
|
-
columnId:
|
|
448
|
-
}) : a, typeof
|
|
449
|
-
rowData: e[
|
|
450
|
-
rowIndex:
|
|
451
|
-
columnId:
|
|
452
|
-
}) :
|
|
447
|
+
rowData: e[t.index],
|
|
448
|
+
rowIndex: t.index,
|
|
449
|
+
columnId: r[i.index].id
|
|
450
|
+
}) : a, typeof C == "function" ? C({
|
|
451
|
+
rowData: e[t.index],
|
|
452
|
+
rowIndex: t.index,
|
|
453
|
+
columnId: r[i.index].id
|
|
454
|
+
}) : C),
|
|
453
455
|
width: i.size,
|
|
454
456
|
left: f ? ie(i.index) : i.start,
|
|
455
457
|
children: /* @__PURE__ */ u(c, {
|
|
456
|
-
rowData: e[
|
|
457
|
-
getContextMenuItems:
|
|
458
|
+
rowData: e[t.index],
|
|
459
|
+
getContextMenuItems: E,
|
|
458
460
|
disabled: l,
|
|
459
461
|
active: d,
|
|
460
462
|
columnIndex: i.index - 1,
|
|
461
|
-
rowIndex:
|
|
462
|
-
focus: d &&
|
|
463
|
-
deleteRow:
|
|
464
|
-
duplicateRow:
|
|
465
|
-
stopEditing:
|
|
466
|
-
insertRowBelow:
|
|
467
|
-
setRowData:
|
|
468
|
-
columnData:
|
|
463
|
+
rowIndex: t.index,
|
|
464
|
+
focus: d && T,
|
|
465
|
+
deleteRow: re(t.index),
|
|
466
|
+
duplicateRow: P(t.index),
|
|
467
|
+
stopEditing: A,
|
|
468
|
+
insertRowBelow: F(t.index),
|
|
469
|
+
setRowData: ne(t.index),
|
|
470
|
+
columnData: r[i.index].columnData
|
|
469
471
|
})
|
|
470
472
|
}, i.key);
|
|
471
473
|
})
|
|
472
|
-
},
|
|
474
|
+
}, t.key);
|
|
473
475
|
}),
|
|
474
|
-
|
|
476
|
+
w
|
|
475
477
|
]
|
|
476
478
|
})
|
|
477
479
|
});
|
|
478
|
-
},
|
|
480
|
+
}, Ce = (e, t, n, r) => [
|
|
479
481
|
[r, e],
|
|
480
482
|
[t, e],
|
|
481
483
|
[t, n],
|
|
482
484
|
[r, n],
|
|
483
485
|
[r, e]
|
|
484
|
-
],
|
|
486
|
+
], we = (e, t, n, r) => `polygon(evenodd, ${[...Ce(0, "100%", "100%", 0), ...Ce(e, t, n, r)].map((e) => e.map((e) => typeof e == "number" && e !== 0 ? e + "px" : e).join(" ")).join(",")})`, Te = e.memo(({ columnWidths: e, columnRights: t, headerRowHeight: n, selection: r, rowHeight: i, activeCell: o, hasStickyRightColumn: s, dataLength: c, viewWidth: f, viewHeight: p, contentWidth: m, edges: h, isCellDisabled: g, editing: _, expandSelection: y, stickyLeftColumns: b, getStickyLeftOffset: x }) => {
|
|
485
487
|
let S = o ? g(o) : !1, C = a(() => {
|
|
486
488
|
if (!r) return S;
|
|
487
489
|
for (let e = r.min.col; e <= r.max.col; ++e) for (let t = r.min.row; t <= r.max.row; ++t) if (!g({
|
|
@@ -508,16 +510,16 @@ var oe = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
508
510
|
}, O = o && b && x && b[o.col], ee = O && x ? x(o.col + 1) : 0, k = r && b && x && (() => {
|
|
509
511
|
for (let e = r.min.col; e <= r.max.col; e++) if (!b[e]) return !1;
|
|
510
512
|
return !0;
|
|
511
|
-
})(), A = k && r && x ? x(r.min.col + 1) : 0,
|
|
512
|
-
left: t[
|
|
513
|
-
top: i(
|
|
514
|
-
transform: `translate(-${
|
|
515
|
-
},
|
|
516
|
-
width: e.slice(
|
|
517
|
-
height: i(
|
|
518
|
-
left: t[
|
|
519
|
-
top: i(
|
|
520
|
-
},
|
|
513
|
+
})(), A = k && r && x ? x(r.min.col + 1) : 0, te = r?.min || o, j = r?.max || o, M = j && b && x && b[j.col], N = M && j && x ? x(j.col + 1) + e[j.col + 1] : 0, ne = r && b?.[r.min.col] || o && b?.[o.col], re = ne && x ? x((r?.min.col ?? o?.col ?? 0) + 1) : 0, P = j && y !== null && {
|
|
514
|
+
left: t[j.col] + e[j.col + 1],
|
|
515
|
+
top: i(j.row).top + i(j.row).height + n,
|
|
516
|
+
transform: `translate(-${j.col < e.length - (s ? 3 : 2) ? 50 : 100}%, -${j.row < c - 1 ? 50 : 100}%)`
|
|
517
|
+
}, F = te && j && y !== null && {
|
|
518
|
+
width: e.slice(te.col + 1, j.col + 2).reduce((e, t) => e + t) + T(j.col),
|
|
519
|
+
height: i(j.row + y).top + i(j.row + y).height - i(j.row + 1).top + w(j.row + y) - 1,
|
|
520
|
+
left: t[te.col],
|
|
521
|
+
top: i(j.row).top + i(j.row).height + n + 1
|
|
522
|
+
}, ie = s ? e.at(-1) : 0;
|
|
521
523
|
return /* @__PURE__ */ d(l, { children: [
|
|
522
524
|
/* @__PURE__ */ u("div", {
|
|
523
525
|
className: "dsg-scrollable-view-container",
|
|
@@ -537,11 +539,11 @@ var oe = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
537
539
|
top: n,
|
|
538
540
|
left: e[0],
|
|
539
541
|
height: p ? p - n : 0,
|
|
540
|
-
width: m && f ? f - e[0] -
|
|
542
|
+
width: m && f ? f - e[0] - ie : `calc(100% - ${e[0] + ie}px)`
|
|
541
543
|
}
|
|
542
544
|
})
|
|
543
545
|
}),
|
|
544
|
-
(D || E) && !
|
|
546
|
+
(D || E) && !ne && /* @__PURE__ */ u("div", {
|
|
545
547
|
className: "dsg-selection-col-marker-container",
|
|
546
548
|
style: {
|
|
547
549
|
left: D?.left ?? E?.left,
|
|
@@ -553,11 +555,11 @@ var oe = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
553
555
|
style: { top: n }
|
|
554
556
|
})
|
|
555
557
|
}),
|
|
556
|
-
(D || E) &&
|
|
558
|
+
(D || E) && ne && /* @__PURE__ */ u("div", {
|
|
557
559
|
className: v("dsg-selection-col-marker-container", "dsg-selection-col-marker-container-sticky"),
|
|
558
560
|
style: {
|
|
559
561
|
position: "sticky",
|
|
560
|
-
left:
|
|
562
|
+
left: re,
|
|
561
563
|
top: "auto",
|
|
562
564
|
width: D?.width ?? E?.width,
|
|
563
565
|
height: i(c - 1).top + i(c - 1).height + n
|
|
@@ -613,7 +615,7 @@ var oe = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
613
615
|
className: v("dsg-selection-rect", C && "dsg-selection-rect-disabled"),
|
|
614
616
|
style: {
|
|
615
617
|
...D,
|
|
616
|
-
clipPath:
|
|
618
|
+
clipPath: we(E.top - D.top, E.left - D.left, E.top + E.height - D.top, E.left + E.width - D.left)
|
|
617
619
|
}
|
|
618
620
|
}),
|
|
619
621
|
D && E && k && /* @__PURE__ */ u("div", {
|
|
@@ -633,21 +635,21 @@ var oe = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
633
635
|
width: D.width,
|
|
634
636
|
height: "100%",
|
|
635
637
|
background: "var(--dsg-selection-background-color)",
|
|
636
|
-
clipPath:
|
|
638
|
+
clipPath: we(E.top - D.top, ee - A, E.top + E.height - D.top, ee + E.width - A)
|
|
637
639
|
}
|
|
638
640
|
})
|
|
639
641
|
}),
|
|
640
|
-
|
|
642
|
+
F && !k && /* @__PURE__ */ u("div", {
|
|
641
643
|
className: "dsg-expand-rows-rect",
|
|
642
|
-
style:
|
|
644
|
+
style: F
|
|
643
645
|
}),
|
|
644
|
-
|
|
646
|
+
F && k && /* @__PURE__ */ u("div", {
|
|
645
647
|
style: {
|
|
646
648
|
position: "absolute",
|
|
647
|
-
top:
|
|
649
|
+
top: F.top,
|
|
648
650
|
left: 0,
|
|
649
651
|
right: 0,
|
|
650
|
-
height:
|
|
652
|
+
height: F.height,
|
|
651
653
|
pointerEvents: "none"
|
|
652
654
|
},
|
|
653
655
|
children: /* @__PURE__ */ u("div", {
|
|
@@ -655,19 +657,19 @@ var oe = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
655
657
|
style: {
|
|
656
658
|
position: "sticky",
|
|
657
659
|
left: A,
|
|
658
|
-
width:
|
|
660
|
+
width: F.width,
|
|
659
661
|
height: "100%"
|
|
660
662
|
}
|
|
661
663
|
})
|
|
662
664
|
}),
|
|
663
|
-
|
|
665
|
+
P && !M && /* @__PURE__ */ u("div", {
|
|
664
666
|
className: v("dsg-expand-rows-indicator", C && "dsg-expand-rows-indicator-disabled"),
|
|
665
|
-
style:
|
|
667
|
+
style: P
|
|
666
668
|
}),
|
|
667
|
-
|
|
669
|
+
P && M && /* @__PURE__ */ u("div", {
|
|
668
670
|
style: {
|
|
669
671
|
position: "absolute",
|
|
670
|
-
top:
|
|
672
|
+
top: P.top,
|
|
671
673
|
left: 0,
|
|
672
674
|
right: 0,
|
|
673
675
|
height: 0,
|
|
@@ -677,17 +679,17 @@ var oe = typeof DOMParser < "u" ? new DOMParser() : { parseFromString: () => nul
|
|
|
677
679
|
className: v("dsg-expand-rows-indicator", C && "dsg-expand-rows-indicator-disabled", "dsg-expand-rows-indicator-sticky"),
|
|
678
680
|
style: {
|
|
679
681
|
position: "sticky",
|
|
680
|
-
left:
|
|
681
|
-
transform:
|
|
682
|
+
left: N,
|
|
683
|
+
transform: P.transform,
|
|
682
684
|
pointerEvents: "auto"
|
|
683
685
|
}
|
|
684
686
|
})
|
|
685
687
|
})
|
|
686
688
|
] });
|
|
687
689
|
});
|
|
688
|
-
|
|
690
|
+
Te.displayName = "SelectionRect";
|
|
689
691
|
// src/hooks/useRowHeights.ts
|
|
690
|
-
var
|
|
692
|
+
var Ee = ({ value: e, rowHeight: t }) => {
|
|
691
693
|
let n = o([]), [, r] = s(0);
|
|
692
694
|
return a(() => {
|
|
693
695
|
let i = (r) => {
|
|
@@ -750,27 +752,27 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
750
752
|
}
|
|
751
753
|
};
|
|
752
754
|
}, [t, e]);
|
|
753
|
-
},
|
|
754
|
-
let
|
|
755
|
+
}, De = [], Oe = [], ke = () => ({}), Ae = () => null, je = ({ rowData: e }) => ({ ...e }), Me = e.memo(e.forwardRef(({ value: e = De, className: i, style: l, height: f = 400, onChange: p = Ae, columns: h = Oe, rowHeight: g = 40, headerRowHeight: _ = typeof g == "number" ? g : 40, gutterColumn: v, stickyRightColumn: y, rowKey: b, addRowsComponent: S = ne, createRow: C = ke, autoAddRow: w = !1, lockRows: T = !1, disableExpandSelection: E = !1, disableSmartDelete: D = !1, duplicateRow: O = je, contextMenuComponent: ee = ie, disableContextMenu: N = !1, onFocus: P = Ae, onBlur: F = Ae, onActiveCellChange: ae = Ae, onSelectionChange: oe = Ae, rowClassName: _e, cellClassName: be, onScroll: xe, pinFirstColumn: Ce = !1, onUndo: we, onRedo: Me }, Ne) => {
|
|
756
|
+
let Pe = o(null), Fe = N || T, I = k(h, v, y, Ce), L = !!y, Ie = Ce || !!I[1]?.stickyLeft, Le = o(null), R = o(null), Re = o(null), ze = o(null), [Be, Ve] = re(1, 100), { getRowSize: He, totalSize: Ue, getRowIndex: We } = Ee({
|
|
755
757
|
value: e,
|
|
756
758
|
rowHeight: g
|
|
757
|
-
}),
|
|
758
|
-
targetRef:
|
|
759
|
+
}), Ge = Math.min(f, _ + Ue(f) + Be), { width: Ke, height: qe } = c({
|
|
760
|
+
targetRef: R,
|
|
759
761
|
refreshMode: "throttle",
|
|
760
762
|
refreshRate: 100
|
|
761
763
|
});
|
|
762
|
-
|
|
763
|
-
let
|
|
764
|
-
if (!
|
|
764
|
+
Ve(qe ? Ge - qe : 0);
|
|
765
|
+
let Je = te(R, Ke, qe), { fullWidth: Ye, totalWidth: Xe, columnWidths: z, columnRights: B } = x(I, Ke), Ze = a(() => I.slice(1).map((e) => !!e.stickyLeft), [I]), Qe = t((e) => {
|
|
766
|
+
if (!I[e]?.stickyLeft) return 0;
|
|
765
767
|
if (!z?.length) {
|
|
766
768
|
let t = 0;
|
|
767
|
-
for (let n = 0; n < e; n++) (
|
|
769
|
+
for (let n = 0; n < e; n++) (I[n].stickyLeft || n === 0) && (t += I[n].basis || I[n].minWidth || 100);
|
|
768
770
|
return t;
|
|
769
771
|
}
|
|
770
772
|
let t = 0;
|
|
771
|
-
for (let n = 0; n < e; n++) (
|
|
773
|
+
for (let n = 0; n < e; n++) (I[n].stickyLeft || n === 0) && (t += z[n]);
|
|
772
774
|
return t;
|
|
773
|
-
}, [
|
|
775
|
+
}, [I, z]), [$e, V] = s(null), [et, tt] = s([]), [H, U] = s(!1), [nt, rt] = s(0), [it, at] = s(null), [W, G] = A(null), [K, q] = A(null), J = a(() => W && K && {
|
|
774
776
|
min: {
|
|
775
777
|
col: Math.min(W.col, K.col),
|
|
776
778
|
row: Math.min(W.row, K.row)
|
|
@@ -779,21 +781,21 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
779
781
|
col: Math.max(W.col, K.col),
|
|
780
782
|
row: Math.max(W.row, K.row)
|
|
781
783
|
}
|
|
782
|
-
}, [W, K]), [Y,
|
|
784
|
+
}, [W, K]), [Y, ot] = A({
|
|
783
785
|
columns: !1,
|
|
784
786
|
rows: !1,
|
|
785
787
|
active: !1
|
|
786
|
-
}),
|
|
788
|
+
}), st = E || H || Y.active || W?.row === e?.length - 1 || J?.max.row === e?.length - 1 || W && I.slice((J?.min.col ?? W.col) + 1, (J?.max.col ?? W.col) + 2).every((e) => e.disabled === !0) ? null : nt, ct = M(Le), lt = M(R);
|
|
787
789
|
n(() => {
|
|
788
790
|
W !== null && (document.activeElement.blur(), window.getSelection()?.removeAllRanges());
|
|
789
791
|
}, [W !== null]);
|
|
790
|
-
let
|
|
791
|
-
let r =
|
|
792
|
+
let ut = t((e, t = !1, n = !1) => {
|
|
793
|
+
let r = ct(t), i = n && lt(t);
|
|
792
794
|
if (r && B && z) {
|
|
793
795
|
let t = e.clientX - r.left, n = e.clientY - r.top;
|
|
794
|
-
return i && (e.clientY - i.top <= _ && (n = 0), e.clientX - i.left <= z[0] && (t = 0),
|
|
796
|
+
return i && (e.clientY - i.top <= _ && (n = 0), e.clientX - i.left <= z[0] && (t = 0), Ie && e.clientX - i.left <= z[0] + z[1] && (t = B[0] + 1), L && i.right - e.clientX <= z.at(-1) && (t = B.at(-2) + 1)), {
|
|
795
797
|
col: B.findIndex((e) => t < e) - 1,
|
|
796
|
-
row:
|
|
798
|
+
row: We(n - _)
|
|
797
799
|
};
|
|
798
800
|
}
|
|
799
801
|
return null;
|
|
@@ -801,21 +803,21 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
801
803
|
B,
|
|
802
804
|
z,
|
|
803
805
|
e.length,
|
|
804
|
-
|
|
805
|
-
|
|
806
|
+
ct,
|
|
807
|
+
lt,
|
|
806
808
|
_,
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
809
|
+
L,
|
|
810
|
+
Ie,
|
|
811
|
+
We
|
|
810
812
|
]), X = o(e);
|
|
811
813
|
X.current = e;
|
|
812
814
|
let Z = t((e) => {
|
|
813
|
-
let t =
|
|
815
|
+
let t = I[e.col + 1].disabled;
|
|
814
816
|
return !!(typeof t == "function" ? t({
|
|
815
817
|
rowData: X.current[e.row],
|
|
816
818
|
rowIndex: e.row
|
|
817
819
|
}) : t);
|
|
818
|
-
}, [
|
|
820
|
+
}, [I]), Q = t((e, t = 1) => {
|
|
819
821
|
T || (q(null), U(!1), p([
|
|
820
822
|
...X.current.slice(0, e + 1),
|
|
821
823
|
...Array(t).fill(0).map(C),
|
|
@@ -835,7 +837,7 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
835
837
|
p,
|
|
836
838
|
G,
|
|
837
839
|
q
|
|
838
|
-
]),
|
|
840
|
+
]), dt = t((e, t = e) => {
|
|
839
841
|
T || (p([
|
|
840
842
|
...X.current.slice(0, t + 1),
|
|
841
843
|
...X.current.slice(e, t + 1).map((t, n) => O({
|
|
@@ -852,44 +854,44 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
852
854
|
row: t + 1,
|
|
853
855
|
doNotScrollX: !0
|
|
854
856
|
}), q({
|
|
855
|
-
col:
|
|
857
|
+
col: I.length - (L ? 3 : 2),
|
|
856
858
|
row: 2 * t - e + 1,
|
|
857
859
|
doNotScrollX: !0
|
|
858
860
|
}), U(!1));
|
|
859
861
|
}, [
|
|
860
|
-
|
|
862
|
+
I.length,
|
|
861
863
|
O,
|
|
862
864
|
T,
|
|
863
865
|
p,
|
|
864
866
|
G,
|
|
865
867
|
q,
|
|
866
|
-
|
|
868
|
+
L
|
|
867
869
|
]), $ = t((e) => {
|
|
868
|
-
if (
|
|
870
|
+
if (qe && Ke) {
|
|
869
871
|
if (!e.doNotScrollY) {
|
|
870
|
-
let t =
|
|
871
|
-
r > t ?
|
|
872
|
+
let t = He(e.row).top, n = He(e.row).top + He(e.row).height + _ - qe + 1, r = R.current.scrollTop;
|
|
873
|
+
r > t ? R.current.scrollTop = t : r < n && (R.current.scrollTop = n);
|
|
872
874
|
}
|
|
873
|
-
if (B && z &&
|
|
874
|
-
let t = B[e.col] - B[0], n = B[e.col] + z[e.col + 1] + (
|
|
875
|
-
r > t ?
|
|
875
|
+
if (B && z && R.current && !e.doNotScrollX) {
|
|
876
|
+
let t = B[e.col] - B[0], n = B[e.col] + z[e.col + 1] + (L ? z.at(-1) : 0) - Ke + 1, r = R.current.scrollLeft;
|
|
877
|
+
r > t ? R.current.scrollLeft = t : r < n && (R.current.scrollLeft = n);
|
|
876
878
|
}
|
|
877
879
|
}
|
|
878
880
|
}, [
|
|
879
|
-
|
|
880
|
-
|
|
881
|
+
qe,
|
|
882
|
+
Ke,
|
|
881
883
|
_,
|
|
882
884
|
B,
|
|
883
885
|
z,
|
|
884
|
-
|
|
885
|
-
|
|
886
|
+
He,
|
|
887
|
+
L
|
|
886
888
|
]);
|
|
887
889
|
n(() => {
|
|
888
890
|
K && $(K);
|
|
889
891
|
}, [K, $]), n(() => {
|
|
890
892
|
W && $(W);
|
|
891
893
|
}, [W, $]);
|
|
892
|
-
let
|
|
894
|
+
let ft = t((e, t) => {
|
|
893
895
|
p([
|
|
894
896
|
...X.current.slice(0, e),
|
|
895
897
|
t,
|
|
@@ -899,7 +901,7 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
899
901
|
fromRowIndex: e,
|
|
900
902
|
toRowIndex: e + 1
|
|
901
903
|
}]);
|
|
902
|
-
}, [p]),
|
|
904
|
+
}, [p]), pt = t((e, t = e) => {
|
|
903
905
|
T || (U(!1), G((n) => {
|
|
904
906
|
let r = Math.min(X.current.length - 2 - t + e, e);
|
|
905
907
|
return r < 0 ? null : n && {
|
|
@@ -916,15 +918,15 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
916
918
|
p,
|
|
917
919
|
G,
|
|
918
920
|
q
|
|
919
|
-
]),
|
|
921
|
+
]), mt = t((t = !0) => {
|
|
920
922
|
let n = t && !D;
|
|
921
923
|
if (!W) return;
|
|
922
924
|
let r = J?.min || W, i = J?.max || W;
|
|
923
|
-
if (e.slice(r.row, i.row + 1).every((e, t) =>
|
|
925
|
+
if (e.slice(r.row, i.row + 1).every((e, t) => I.every((n) => n.isCellEmpty({
|
|
924
926
|
rowData: e,
|
|
925
927
|
rowIndex: t + r.row
|
|
926
928
|
})))) {
|
|
927
|
-
n &&
|
|
929
|
+
n && pt(r.row, i.row);
|
|
928
930
|
return;
|
|
929
931
|
}
|
|
930
932
|
let a = [...e];
|
|
@@ -932,7 +934,7 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
932
934
|
col: t,
|
|
933
935
|
row: e
|
|
934
936
|
})) {
|
|
935
|
-
let { deleteValue: n = ({ rowData: e }) => e } =
|
|
937
|
+
let { deleteValue: n = ({ rowData: e }) => e } = I[t + 1];
|
|
936
938
|
a[e] = n({
|
|
937
939
|
rowData: a[e],
|
|
938
940
|
rowIndex: e
|
|
@@ -943,7 +945,7 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
943
945
|
row: r.row,
|
|
944
946
|
doNotScrollX: !0
|
|
945
947
|
}), q({
|
|
946
|
-
col:
|
|
948
|
+
col: I.length - (L ? 3 : 2),
|
|
947
949
|
row: i.row,
|
|
948
950
|
doNotScrollX: !0
|
|
949
951
|
})) : p(a, [{
|
|
@@ -953,17 +955,17 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
953
955
|
}]);
|
|
954
956
|
}, [
|
|
955
957
|
W,
|
|
956
|
-
|
|
958
|
+
I,
|
|
957
959
|
e,
|
|
958
|
-
|
|
960
|
+
pt,
|
|
959
961
|
Z,
|
|
960
962
|
p,
|
|
961
963
|
J?.max,
|
|
962
964
|
J?.min,
|
|
963
965
|
G,
|
|
964
966
|
q,
|
|
965
|
-
|
|
966
|
-
]),
|
|
967
|
+
L
|
|
968
|
+
]), ht = t(({ nextRow: e = !0 } = {}) => {
|
|
967
969
|
W?.row === X.current.length - 1 ? e && w ? Q(W.row) : U(!1) : (U(!1), e && G((e) => e && {
|
|
968
970
|
col: e.col,
|
|
969
971
|
row: e.row + 1
|
|
@@ -973,20 +975,20 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
973
975
|
w,
|
|
974
976
|
Q,
|
|
975
977
|
G
|
|
976
|
-
]),
|
|
978
|
+
]), gt = t(async (t) => {
|
|
977
979
|
if (!H && W) {
|
|
978
980
|
let n = [], r = J?.min || W, i = J?.max || W;
|
|
979
981
|
for (let t = r.row; t <= i.row; ++t) {
|
|
980
982
|
n.push([]);
|
|
981
983
|
for (let a = r.col; a <= i.col; ++a) {
|
|
982
|
-
let { copyValue: i = () => null } =
|
|
984
|
+
let { copyValue: i = () => null } = I[a + 1];
|
|
983
985
|
n[t - r.row].push(i({
|
|
984
986
|
rowData: e[t],
|
|
985
987
|
rowIndex: t
|
|
986
988
|
}));
|
|
987
989
|
}
|
|
988
990
|
}
|
|
989
|
-
let a = n.map((e) => e.map((e) =>
|
|
991
|
+
let a = n.map((e) => e.map((e) => le(String(e ?? ""))).join(" ")).join("\n"), o = `<table>${n.map((e) => `<tr>${e.map((e) => `<td>${ue(String(e ?? "")).replaceAll("\n", "<br/>")}</td>`).join("")}</tr>`).join("")}</table>`;
|
|
990
992
|
if (t !== void 0) {
|
|
991
993
|
t.clipboardData?.setData("text/plain", a), t.clipboardData?.setData("text/html", o), t.preventDefault();
|
|
992
994
|
return;
|
|
@@ -1007,31 +1009,31 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1007
1009
|
}
|
|
1008
1010
|
}, [
|
|
1009
1011
|
W,
|
|
1010
|
-
|
|
1012
|
+
I,
|
|
1011
1013
|
e,
|
|
1012
1014
|
H,
|
|
1013
1015
|
J
|
|
1014
1016
|
]);
|
|
1015
|
-
|
|
1016
|
-
let
|
|
1017
|
-
!H && W && (
|
|
1017
|
+
j("copy", gt);
|
|
1018
|
+
let _t = t((e) => {
|
|
1019
|
+
!H && W && (gt(e), mt(!1));
|
|
1018
1020
|
}, [
|
|
1019
1021
|
W,
|
|
1020
|
-
|
|
1022
|
+
mt,
|
|
1021
1023
|
H,
|
|
1022
|
-
|
|
1024
|
+
gt
|
|
1023
1025
|
]);
|
|
1024
|
-
|
|
1025
|
-
let
|
|
1026
|
+
j("cut", _t);
|
|
1027
|
+
let vt = t(async (t) => {
|
|
1026
1028
|
if (!H && W) {
|
|
1027
1029
|
let n = J?.min || W, r = J?.max || W, i = await Promise.all(t[0].map((e, r) => {
|
|
1028
|
-
let i =
|
|
1030
|
+
let i = I[n.col + r + 1]?.prePasteValues, a = t.map((e) => e[r]);
|
|
1029
1031
|
return Promise.resolve(i?.(a) ?? a);
|
|
1030
1032
|
}));
|
|
1031
1033
|
if (t = t.map((e, t) => i.map((e) => e[t])), t.length === 1) {
|
|
1032
1034
|
let i = [...e];
|
|
1033
1035
|
for (let e = 0; e < t[0].length; e++) {
|
|
1034
|
-
let a =
|
|
1036
|
+
let a = I[n.col + e + 1]?.pasteValue;
|
|
1035
1037
|
if (a) for (let o = n.row; o <= r.row; o++) Z({
|
|
1036
1038
|
col: e + n.col,
|
|
1037
1039
|
row: o
|
|
@@ -1049,14 +1051,14 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1049
1051
|
col: n.col,
|
|
1050
1052
|
row: n.row
|
|
1051
1053
|
}), q({
|
|
1052
|
-
col: Math.min(n.col + t[0].length - 1,
|
|
1054
|
+
col: Math.min(n.col + t[0].length - 1, I.length - (L ? 3 : 2)),
|
|
1053
1055
|
row: r.row
|
|
1054
1056
|
});
|
|
1055
1057
|
} else {
|
|
1056
1058
|
let r = [...e], i = n.row + t.length - e.length;
|
|
1057
1059
|
i > 0 && (T ? t.splice(t.length - i, i) : r = [...r, ...Array(i).fill(0).map(() => C())]);
|
|
1058
|
-
for (let e = 0; e < t[0].length && n.col + e <
|
|
1059
|
-
let i =
|
|
1060
|
+
for (let e = 0; e < t[0].length && n.col + e < I.length - (L ? 2 : 1); e++) {
|
|
1061
|
+
let i = I[n.col + e + 1]?.pasteValue;
|
|
1060
1062
|
if (i) for (let a = 0; a < t.length; a++) Z({
|
|
1061
1063
|
col: n.col + e,
|
|
1062
1064
|
row: n.row + a
|
|
@@ -1079,18 +1081,18 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1079
1081
|
col: n.col,
|
|
1080
1082
|
row: n.row
|
|
1081
1083
|
}), q({
|
|
1082
|
-
col: Math.min(n.col + t[0].length - 1,
|
|
1084
|
+
col: Math.min(n.col + t[0].length - 1, I.length - (L ? 3 : 2)),
|
|
1083
1085
|
row: n.row + t.length - 1
|
|
1084
1086
|
});
|
|
1085
1087
|
}
|
|
1086
1088
|
}
|
|
1087
1089
|
}, [
|
|
1088
1090
|
W,
|
|
1089
|
-
|
|
1091
|
+
I,
|
|
1090
1092
|
C,
|
|
1091
1093
|
e,
|
|
1092
1094
|
H,
|
|
1093
|
-
|
|
1095
|
+
L,
|
|
1094
1096
|
Z,
|
|
1095
1097
|
T,
|
|
1096
1098
|
p,
|
|
@@ -1099,27 +1101,27 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1099
1101
|
G,
|
|
1100
1102
|
q
|
|
1101
1103
|
]);
|
|
1102
|
-
|
|
1104
|
+
j("paste", t((e) => {
|
|
1103
1105
|
if (W && !H) {
|
|
1104
1106
|
let t = [[""]];
|
|
1105
|
-
e.clipboardData?.types.includes("text/html") ? t =
|
|
1107
|
+
e.clipboardData?.types.includes("text/html") ? t = se(e.clipboardData?.getData("text/html")) : e.clipboardData?.types.includes("text/plain") ? t = ce(e.clipboardData?.getData("text/plain")) : e.clipboardData?.types.includes("text") && (t = ce(e.clipboardData?.getData("text"))), vt(t), e.preventDefault();
|
|
1106
1108
|
}
|
|
1107
1109
|
}, [
|
|
1108
1110
|
W,
|
|
1109
|
-
|
|
1111
|
+
vt,
|
|
1110
1112
|
H
|
|
1111
|
-
])),
|
|
1112
|
-
if (
|
|
1113
|
-
let n = t.button === 2 || t.button === 0 && t.ctrlKey, r =
|
|
1114
|
-
if (!r && H && W &&
|
|
1113
|
+
])), j("mousedown", t((t) => {
|
|
1114
|
+
if ($e && et.length) return;
|
|
1115
|
+
let n = t.button === 2 || t.button === 0 && t.ctrlKey, r = Le.current?.contains(t.target) || !1, i = r ? ut(t, !0, !0) : null;
|
|
1116
|
+
if (!r && H && W && I[W.col + 1].keepFocus) return;
|
|
1115
1117
|
if (t.target instanceof HTMLElement && t.target.className.includes("dsg-expand-rows-indicator")) {
|
|
1116
|
-
|
|
1118
|
+
at(Math.max(W?.row ?? 0, J?.max.row ?? 0));
|
|
1117
1119
|
return;
|
|
1118
1120
|
}
|
|
1119
1121
|
let a = i && W && W.col === i.col && W.row === i.row && !Z(W), o = H && t.target instanceof HTMLElement && t.target.classList.contains("dsg-input");
|
|
1120
1122
|
if ((a || o) && H) return;
|
|
1121
|
-
let s = i?.col ===
|
|
1122
|
-
if (n && !
|
|
1123
|
+
let s = i?.col === I.length - 2 && L, c = n && J && i && i.row >= J.min.row && i.row <= J.max.row && i.col >= J.min.col && i.col <= J.max.col, l = n && J && i?.row === -1 && i.col >= J.min.col && i.col <= J.max.col, u = n && J && i && i.row >= J.min.row && i.row <= J.max.row && i.col === -1, d = s && J && i && i.row >= J.min.row && i.row <= J.max.row;
|
|
1124
|
+
if (n && !Fe && V({
|
|
1123
1125
|
x: t.clientX,
|
|
1124
1126
|
y: t.clientY,
|
|
1125
1127
|
cursorIndex: i
|
|
@@ -1128,7 +1130,7 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1128
1130
|
row: (c || u || d) && W ? W.row : Math.max(0, i.row),
|
|
1129
1131
|
doNotScrollX: !!(c && W || s || i.col === -1),
|
|
1130
1132
|
doNotScrollY: !!(c && W || i.row === -1)
|
|
1131
|
-
}), a && !n && (
|
|
1133
|
+
}), a && !n && (Pe.current = W), U(!(!a || n)), ot(i && !n ? {
|
|
1132
1134
|
columns: i.col !== -1 && !s || !!(t.shiftKey && W),
|
|
1133
1135
|
rows: i.row !== -1 || !!(t.shiftKey && W),
|
|
1134
1136
|
active: !0
|
|
@@ -1143,7 +1145,7 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1143
1145
|
else if (!c) {
|
|
1144
1146
|
if (i && (i?.col === -1 || i?.row === -1 || s)) {
|
|
1145
1147
|
let t = i.col, n = i.row, r = !1, a = !1;
|
|
1146
|
-
(i.col === -1 || s) && (t =
|
|
1148
|
+
(i.col === -1 || s) && (t = I.length - (L ? 3 : 2), r = !0), i.row === -1 && (n = e.length - 1, a = !0), l && K && (t = K.col, a = !0), (u || d) && K && (n = K.row, r = !0), q({
|
|
1147
1149
|
col: t,
|
|
1148
1150
|
row: n,
|
|
1149
1151
|
doNotScrollX: r,
|
|
@@ -1153,29 +1155,29 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1153
1155
|
r && t.preventDefault();
|
|
1154
1156
|
}
|
|
1155
1157
|
}, [
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1158
|
+
$e,
|
|
1159
|
+
et.length,
|
|
1160
|
+
ut,
|
|
1159
1161
|
H,
|
|
1160
1162
|
W,
|
|
1161
|
-
|
|
1163
|
+
I,
|
|
1162
1164
|
Z,
|
|
1163
1165
|
J,
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1166
|
+
L,
|
|
1167
|
+
Fe,
|
|
1168
|
+
ot,
|
|
1167
1169
|
G,
|
|
1168
1170
|
q,
|
|
1169
1171
|
K,
|
|
1170
1172
|
e.length
|
|
1171
|
-
])),
|
|
1172
|
-
if (
|
|
1173
|
-
if (
|
|
1173
|
+
])), j("mouseup", t(() => {
|
|
1174
|
+
if (it !== null) {
|
|
1175
|
+
if (nt > 0 && W) {
|
|
1174
1176
|
let t = [], n = J?.min || W, r = J?.max || W;
|
|
1175
1177
|
for (let i = n.row; i <= r.row; ++i) {
|
|
1176
1178
|
t.push([]);
|
|
1177
1179
|
for (let a = n.col; a <= r.col; ++a) {
|
|
1178
|
-
let { copyValue: r = () => null } =
|
|
1180
|
+
let { copyValue: r = () => null } = I[a + 1];
|
|
1179
1181
|
t[i - n.row].push(String(r({
|
|
1180
1182
|
rowData: e[i],
|
|
1181
1183
|
rowIndex: i
|
|
@@ -1183,14 +1185,14 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1183
1185
|
}
|
|
1184
1186
|
}
|
|
1185
1187
|
Promise.all(t[0].map((e, r) => {
|
|
1186
|
-
let i =
|
|
1188
|
+
let i = I[n.col + r + 1]?.prePasteValues, a = t.map((e) => e[r]);
|
|
1187
1189
|
return Promise.resolve(i?.(a) ?? a);
|
|
1188
1190
|
})).then((i) => {
|
|
1189
1191
|
t = t.map((e, t) => i.map((e) => e[t]));
|
|
1190
1192
|
let a = [...e];
|
|
1191
1193
|
for (let e = 0; e < t[0].length; e++) {
|
|
1192
|
-
let i =
|
|
1193
|
-
if (i) for (let o = r.row + 1; o <= r.row +
|
|
1194
|
+
let i = I[n.col + e + 1]?.pasteValue;
|
|
1195
|
+
if (i) for (let o = r.row + 1; o <= r.row + nt; o++) Z({
|
|
1194
1196
|
col: e + n.col,
|
|
1195
1197
|
row: o
|
|
1196
1198
|
}) || (a[o] = i({
|
|
@@ -1202,29 +1204,29 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1202
1204
|
p(a, [{
|
|
1203
1205
|
type: "UPDATE",
|
|
1204
1206
|
fromRowIndex: r.row + 1,
|
|
1205
|
-
toRowIndex: r.row + 1 +
|
|
1207
|
+
toRowIndex: r.row + 1 + nt
|
|
1206
1208
|
}]);
|
|
1207
|
-
}),
|
|
1209
|
+
}), rt(0), G({
|
|
1208
1210
|
col: Math.min(W?.col ?? Infinity, J?.min.col ?? Infinity),
|
|
1209
1211
|
row: Math.min(W?.row ?? Infinity, J?.min.row ?? Infinity),
|
|
1210
1212
|
doNotScrollX: !0,
|
|
1211
1213
|
doNotScrollY: !0
|
|
1212
1214
|
}), q({
|
|
1213
1215
|
col: Math.max(W?.col ?? 0, J?.max.col ?? 0),
|
|
1214
|
-
row: Math.max(W?.row ?? 0, J?.max.row ?? 0) +
|
|
1216
|
+
row: Math.max(W?.row ?? 0, J?.max.row ?? 0) + nt
|
|
1215
1217
|
});
|
|
1216
1218
|
}
|
|
1217
|
-
|
|
1219
|
+
at(null);
|
|
1218
1220
|
}
|
|
1219
|
-
|
|
1221
|
+
ot({
|
|
1220
1222
|
columns: !1,
|
|
1221
1223
|
rows: !1,
|
|
1222
1224
|
active: !1
|
|
1223
1225
|
});
|
|
1224
1226
|
}, [
|
|
1225
|
-
|
|
1227
|
+
it,
|
|
1228
|
+
ot,
|
|
1226
1229
|
nt,
|
|
1227
|
-
Qe,
|
|
1228
1230
|
W,
|
|
1229
1231
|
J?.min,
|
|
1230
1232
|
J?.max,
|
|
@@ -1232,18 +1234,18 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1232
1234
|
p,
|
|
1233
1235
|
G,
|
|
1234
1236
|
q,
|
|
1235
|
-
|
|
1237
|
+
I,
|
|
1236
1238
|
Z
|
|
1237
|
-
])),
|
|
1238
|
-
if (
|
|
1239
|
-
let e =
|
|
1240
|
-
e && (
|
|
1239
|
+
])), j("mousemove", t((t) => {
|
|
1240
|
+
if (it !== null) {
|
|
1241
|
+
let e = ut(t);
|
|
1242
|
+
e && (rt(Math.max(0, e.row - it)), $({
|
|
1241
1243
|
col: e.col,
|
|
1242
|
-
row: Math.max(e.row,
|
|
1244
|
+
row: Math.max(e.row, it)
|
|
1243
1245
|
}));
|
|
1244
1246
|
}
|
|
1245
1247
|
if (Y.active) {
|
|
1246
|
-
let n =
|
|
1248
|
+
let n = ut(t), r = I.length - (L ? 3 : 2);
|
|
1247
1249
|
q(n && {
|
|
1248
1250
|
col: Y.columns ? Math.max(0, Math.min(r, n.col)) : r,
|
|
1249
1251
|
row: Y.rows ? Math.max(0, n.row) : e.length - 1,
|
|
@@ -1256,20 +1258,20 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1256
1258
|
Y.active,
|
|
1257
1259
|
Y.columns,
|
|
1258
1260
|
Y.rows,
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1261
|
+
ut,
|
|
1262
|
+
I.length,
|
|
1263
|
+
L,
|
|
1262
1264
|
q,
|
|
1263
1265
|
e.length,
|
|
1264
|
-
|
|
1265
|
-
])),
|
|
1266
|
+
it
|
|
1267
|
+
])), j("keydown", t((t) => {
|
|
1266
1268
|
if (W && !t.isComposing) {
|
|
1267
|
-
if (t.key === "Tab" && !t.shiftKey && W.col ===
|
|
1269
|
+
if (t.key === "Tab" && !t.shiftKey && W.col === I.length - (L ? 3 : 2) && !I[W.col + 1].disableKeys) {
|
|
1268
1270
|
if (W.row === e.length - 1) {
|
|
1269
|
-
if (
|
|
1271
|
+
if (ze.current) {
|
|
1270
1272
|
t.preventDefault(), G(null), q(null), U(!1);
|
|
1271
|
-
let e =
|
|
1272
|
-
e[(e.indexOf(
|
|
1273
|
+
let e = ge();
|
|
1274
|
+
e[(e.indexOf(ze.current) + 1) % e.length].focus();
|
|
1273
1275
|
return;
|
|
1274
1276
|
}
|
|
1275
1277
|
} else {
|
|
@@ -1280,26 +1282,26 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1280
1282
|
return;
|
|
1281
1283
|
}
|
|
1282
1284
|
}
|
|
1283
|
-
if (t.key === "Tab" && t.shiftKey && W.col === 0 && !
|
|
1285
|
+
if (t.key === "Tab" && t.shiftKey && W.col === 0 && !I[W.col + 1].disableKeys) {
|
|
1284
1286
|
if (W.row === 0) {
|
|
1285
|
-
if (
|
|
1287
|
+
if (Re.current) {
|
|
1286
1288
|
t.preventDefault(), G(null), q(null), U(!1);
|
|
1287
|
-
let e =
|
|
1288
|
-
e[(e.indexOf(
|
|
1289
|
+
let e = ge();
|
|
1290
|
+
e[(e.indexOf(Re.current) - 1 + e.length) % e.length].focus();
|
|
1289
1291
|
return;
|
|
1290
1292
|
}
|
|
1291
1293
|
} else {
|
|
1292
1294
|
G((e) => ({
|
|
1293
|
-
col:
|
|
1295
|
+
col: I.length - (L ? 3 : 2),
|
|
1294
1296
|
row: (e?.row ?? 1) - 1
|
|
1295
1297
|
})), q(null), U(!1), t.preventDefault();
|
|
1296
1298
|
return;
|
|
1297
1299
|
}
|
|
1298
1300
|
}
|
|
1299
1301
|
if (t.key?.startsWith("Arrow") || t.key === "Tab") {
|
|
1300
|
-
if (H &&
|
|
1302
|
+
if (H && I[W.col + 1].disableKeys || H && ["ArrowLeft", "ArrowRight"].includes(t.key)) return;
|
|
1301
1303
|
let n = ([t, n], r) => r && {
|
|
1302
|
-
col: Math.max(0, Math.min(
|
|
1304
|
+
col: Math.max(0, Math.min(I.length - (L ? 3 : 2), r.col + t)),
|
|
1303
1305
|
row: Math.max(0, Math.min(e.length - 1, r.row + n))
|
|
1304
1306
|
};
|
|
1305
1307
|
if (t.key === "Tab" && t.shiftKey) G((e) => n([-1, 0], e)), q(null);
|
|
@@ -1311,16 +1313,23 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1311
1313
|
ArrowRight: [1, 0],
|
|
1312
1314
|
Tab: [1, 0]
|
|
1313
1315
|
}[t.key];
|
|
1314
|
-
(t.ctrlKey || t.metaKey) && (r[0] *=
|
|
1316
|
+
(t.ctrlKey || t.metaKey) && (r[0] *= I.length, r[1] *= e.length), t.shiftKey ? q((e) => n(r, e || W)) : (G((e) => n(r, e)), q(null));
|
|
1315
1317
|
}
|
|
1316
1318
|
U(!1), t.preventDefault();
|
|
1317
|
-
} else t.key === "Escape"
|
|
1319
|
+
} else if (t.key === "Escape") !H && !K && G(null), q(null), U(!1);
|
|
1320
|
+
else if ((t.key === "Enter" || t.key === "F2") && !t.ctrlKey && !t.metaKey && !t.altKey && !t.shiftKey) q(null), H ? I[W.col + 1].disableKeys || (ht(), t.preventDefault()) : Z(W) || (Pe.current = W, U(!0), $(W), t.preventDefault());
|
|
1321
|
+
else if (t.key === "Enter" && !t.ctrlKey && !t.metaKey && !t.altKey && t.shiftKey && !H) Q(J?.max.row || W.row);
|
|
1322
|
+
else if (t.key === "d" && (t.ctrlKey || t.metaKey) && !t.altKey && !t.shiftKey) dt(J?.min.row || W.row, J?.max.row), t.preventDefault();
|
|
1323
|
+
else if (ve(t) || ye(t)) {
|
|
1324
|
+
let e = ve(t) ? we : Me;
|
|
1325
|
+
!H && e && (e(), t.preventDefault());
|
|
1326
|
+
} else (de(t.key) || /Key[A-Z]$/.exec(t.code)) && !t.ctrlKey && !t.metaKey && !t.altKey ? !H && !Z(W) && (Pe.current = W, q(null), U(!0), $(W)) : ["Backspace", "Delete"].includes(t.key) ? H || (mt(), t.preventDefault()) : t.key === "a" && (t.ctrlKey || t.metaKey) && (H || (G({
|
|
1318
1327
|
col: 0,
|
|
1319
1328
|
row: 0,
|
|
1320
1329
|
doNotScrollY: !0,
|
|
1321
1330
|
doNotScrollX: !0
|
|
1322
1331
|
}), q({
|
|
1323
|
-
col:
|
|
1332
|
+
col: I.length - (L ? 3 : 2),
|
|
1324
1333
|
row: e.length - 1,
|
|
1325
1334
|
doNotScrollY: !0,
|
|
1326
1335
|
doNotScrollX: !0
|
|
@@ -1328,10 +1337,10 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1328
1337
|
}
|
|
1329
1338
|
}, [
|
|
1330
1339
|
W,
|
|
1331
|
-
|
|
1340
|
+
I,
|
|
1332
1341
|
e.length,
|
|
1333
|
-
|
|
1334
|
-
|
|
1342
|
+
mt,
|
|
1343
|
+
dt,
|
|
1335
1344
|
H,
|
|
1336
1345
|
Q,
|
|
1337
1346
|
Z,
|
|
@@ -1341,13 +1350,23 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1341
1350
|
K,
|
|
1342
1351
|
G,
|
|
1343
1352
|
q,
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1353
|
+
ht,
|
|
1354
|
+
L,
|
|
1355
|
+
we,
|
|
1356
|
+
Me
|
|
1357
|
+
]));
|
|
1358
|
+
let yt = o(null);
|
|
1359
|
+
j("focusin", t((e) => {
|
|
1360
|
+
W && e !== yt.current && (G(null), q(null), U(!1));
|
|
1361
|
+
}, [
|
|
1362
|
+
W,
|
|
1363
|
+
G,
|
|
1364
|
+
q
|
|
1365
|
+
])), j("contextmenu", t((e) => {
|
|
1366
|
+
let t = Le.current?.contains(e.target) || !1, n = t ? ut(e, !0, !0) : null, r = n && W && W.col === n.col && W.row === n.row && H;
|
|
1348
1367
|
t && !r && e.preventDefault();
|
|
1349
1368
|
}, [
|
|
1350
|
-
|
|
1369
|
+
ut,
|
|
1351
1370
|
W,
|
|
1352
1371
|
H
|
|
1353
1372
|
])), n(() => {
|
|
@@ -1355,12 +1374,12 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1355
1374
|
W?.row !== void 0 && e.push({
|
|
1356
1375
|
type: "COPY",
|
|
1357
1376
|
action: () => {
|
|
1358
|
-
|
|
1377
|
+
gt(), V(null);
|
|
1359
1378
|
}
|
|
1360
1379
|
}, {
|
|
1361
1380
|
type: "CUT",
|
|
1362
1381
|
action: () => {
|
|
1363
|
-
|
|
1382
|
+
_t(), V(null);
|
|
1364
1383
|
}
|
|
1365
1384
|
}, {
|
|
1366
1385
|
type: "PASTE",
|
|
@@ -1370,11 +1389,11 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1370
1389
|
let e = await navigator.clipboard.read();
|
|
1371
1390
|
for (let t of e) {
|
|
1372
1391
|
let e = [[""]];
|
|
1373
|
-
t.types.includes("text/html") ? e =
|
|
1392
|
+
t.types.includes("text/html") ? e = se(await (await t.getType("text/html")).text()) : t.types.includes("text/plain") ? e = ce(await (await t.getType("text/plain")).text()) : t.types.includes("text") && (e = se(await (await t.getType("text")).text())), await vt(e);
|
|
1374
1393
|
}
|
|
1375
1394
|
} else if (navigator.clipboard.readText !== void 0) {
|
|
1376
1395
|
let e = await navigator.clipboard.readText();
|
|
1377
|
-
await
|
|
1396
|
+
await vt(ce(e));
|
|
1378
1397
|
} else alert("This action is unavailable in your browser, but you can still use Ctrl+V for paste");
|
|
1379
1398
|
V(null);
|
|
1380
1399
|
})();
|
|
@@ -1394,81 +1413,81 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1394
1413
|
fromRow: J.min.row + 1,
|
|
1395
1414
|
toRow: J.max.row + 1,
|
|
1396
1415
|
action: () => {
|
|
1397
|
-
V(null),
|
|
1416
|
+
V(null), dt(J.min.row, J.max.row);
|
|
1398
1417
|
}
|
|
1399
1418
|
}) : W?.row !== void 0 && e.push({
|
|
1400
1419
|
type: "DUPLICATE_ROW",
|
|
1401
1420
|
action: () => {
|
|
1402
|
-
V(null),
|
|
1421
|
+
V(null), dt(W.row);
|
|
1403
1422
|
}
|
|
1404
1423
|
}), J?.min.row !== void 0 && J.min.row !== J.max.row ? e.push({
|
|
1405
1424
|
type: "DELETE_ROWS",
|
|
1406
1425
|
fromRow: J.min.row + 1,
|
|
1407
1426
|
toRow: J.max.row + 1,
|
|
1408
1427
|
action: () => {
|
|
1409
|
-
V(null),
|
|
1428
|
+
V(null), pt(J.min.row, J.max.row);
|
|
1410
1429
|
}
|
|
1411
1430
|
}) : W?.row !== void 0 && e.push({
|
|
1412
1431
|
type: "DELETE_ROW",
|
|
1413
1432
|
action: () => {
|
|
1414
|
-
V(null),
|
|
1433
|
+
V(null), pt(W.row);
|
|
1415
1434
|
}
|
|
1416
|
-
}),
|
|
1435
|
+
}), tt(e), e.length || V(null);
|
|
1417
1436
|
}, [
|
|
1418
1437
|
J,
|
|
1419
1438
|
W,
|
|
1420
|
-
lt,
|
|
1421
|
-
st,
|
|
1422
|
-
Q,
|
|
1423
1439
|
pt,
|
|
1424
|
-
|
|
1425
|
-
|
|
1440
|
+
dt,
|
|
1441
|
+
Q,
|
|
1442
|
+
_t,
|
|
1443
|
+
gt,
|
|
1444
|
+
vt
|
|
1426
1445
|
]);
|
|
1427
|
-
let
|
|
1428
|
-
|
|
1429
|
-
let
|
|
1430
|
-
r(
|
|
1431
|
-
activeCell:
|
|
1432
|
-
selection:
|
|
1446
|
+
let bt = o(et);
|
|
1447
|
+
bt.current = et;
|
|
1448
|
+
let xt = t(() => bt.current, []);
|
|
1449
|
+
r(Ne, () => ({
|
|
1450
|
+
activeCell: pe(W, I),
|
|
1451
|
+
selection: he(J ?? (W ? {
|
|
1433
1452
|
min: W,
|
|
1434
1453
|
max: W
|
|
1435
|
-
} : null),
|
|
1454
|
+
} : null), I),
|
|
1436
1455
|
setSelection: (t) => {
|
|
1437
|
-
let n =
|
|
1438
|
-
G(n?.min || null), U(!1),
|
|
1456
|
+
let n = me(t, I.length - (L ? 2 : 1), e.length, I);
|
|
1457
|
+
G(n?.min || null), U(!1), ot({
|
|
1439
1458
|
columns: !1,
|
|
1440
1459
|
active: !1,
|
|
1441
1460
|
rows: !1
|
|
1442
1461
|
}), q(n?.max || null);
|
|
1443
1462
|
},
|
|
1444
1463
|
setActiveCell: (t) => {
|
|
1445
|
-
let n =
|
|
1446
|
-
G(n), U(!1),
|
|
1464
|
+
let n = fe(t, I.length - (L ? 2 : 1), e.length, I);
|
|
1465
|
+
G(n), U(!1), ot({
|
|
1447
1466
|
columns: !1,
|
|
1448
1467
|
active: !1,
|
|
1449
1468
|
rows: !1
|
|
1450
1469
|
}), q(null);
|
|
1451
1470
|
}
|
|
1452
1471
|
}));
|
|
1453
|
-
let
|
|
1454
|
-
onFocus:
|
|
1455
|
-
onBlur:
|
|
1456
|
-
onActiveCellChange:
|
|
1457
|
-
onSelectionChange:
|
|
1472
|
+
let St = o({
|
|
1473
|
+
onFocus: P,
|
|
1474
|
+
onBlur: F,
|
|
1475
|
+
onActiveCellChange: ae,
|
|
1476
|
+
onSelectionChange: oe
|
|
1458
1477
|
});
|
|
1459
|
-
return
|
|
1460
|
-
|
|
1461
|
-
}, [H,
|
|
1462
|
-
|
|
1478
|
+
return St.current.onFocus = P, St.current.onBlur = F, St.current.onActiveCellChange = ae, St.current.onSelectionChange = oe, n(() => {
|
|
1479
|
+
Pe.current && (H ? St.current.onFocus({ cell: pe(Pe.current, I) }) : St.current.onBlur({ cell: pe(Pe.current, I) }));
|
|
1480
|
+
}, [H, I]), n(() => {
|
|
1481
|
+
St.current.onActiveCellChange({ cell: pe(W, I) });
|
|
1463
1482
|
}, [
|
|
1464
1483
|
W?.col,
|
|
1465
1484
|
W?.row,
|
|
1466
|
-
|
|
1485
|
+
I
|
|
1467
1486
|
]), n(() => {
|
|
1468
|
-
|
|
1487
|
+
St.current.onSelectionChange({ selection: he(J ?? (W ? {
|
|
1469
1488
|
min: W,
|
|
1470
1489
|
max: W
|
|
1471
|
-
} : null),
|
|
1490
|
+
} : null), I) });
|
|
1472
1491
|
}, [
|
|
1473
1492
|
J?.min.col ?? W?.col,
|
|
1474
1493
|
J?.min.row ?? W?.row,
|
|
@@ -1476,13 +1495,16 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1476
1495
|
J?.max.row ?? W?.row,
|
|
1477
1496
|
W?.col,
|
|
1478
1497
|
W?.row,
|
|
1479
|
-
|
|
1498
|
+
I
|
|
1480
1499
|
]), /* @__PURE__ */ d("div", {
|
|
1481
1500
|
className: i,
|
|
1482
1501
|
style: l,
|
|
1502
|
+
onFocus: (e) => {
|
|
1503
|
+
yt.current = e.nativeEvent;
|
|
1504
|
+
},
|
|
1483
1505
|
children: [
|
|
1484
1506
|
/* @__PURE__ */ u("div", {
|
|
1485
|
-
ref:
|
|
1507
|
+
ref: Re,
|
|
1486
1508
|
tabIndex: h.length && e.length ? 0 : void 0,
|
|
1487
1509
|
onFocus: (e) => {
|
|
1488
1510
|
e.target.blur(), G({
|
|
@@ -1491,81 +1513,82 @@ var we = ({ value: e, rowHeight: t }) => {
|
|
|
1491
1513
|
});
|
|
1492
1514
|
}
|
|
1493
1515
|
}),
|
|
1494
|
-
/* @__PURE__ */ u(
|
|
1495
|
-
columns:
|
|
1496
|
-
outerRef:
|
|
1516
|
+
/* @__PURE__ */ u(Se, {
|
|
1517
|
+
columns: I,
|
|
1518
|
+
outerRef: R,
|
|
1497
1519
|
columnWidths: z,
|
|
1498
|
-
hasStickyRightColumn:
|
|
1499
|
-
pinFirstColumn:
|
|
1500
|
-
displayHeight:
|
|
1520
|
+
hasStickyRightColumn: L,
|
|
1521
|
+
pinFirstColumn: Ce,
|
|
1522
|
+
displayHeight: Ge,
|
|
1501
1523
|
data: e,
|
|
1502
|
-
fullWidth:
|
|
1524
|
+
fullWidth: Ye,
|
|
1503
1525
|
headerRowHeight: _,
|
|
1504
1526
|
activeCell: W,
|
|
1505
|
-
innerRef:
|
|
1506
|
-
rowHeight:
|
|
1527
|
+
innerRef: Le,
|
|
1528
|
+
rowHeight: g,
|
|
1529
|
+
getRowSize: He,
|
|
1507
1530
|
rowKey: b,
|
|
1508
1531
|
selection: J,
|
|
1509
|
-
rowClassName:
|
|
1532
|
+
rowClassName: _e,
|
|
1510
1533
|
editing: H,
|
|
1511
|
-
getContextMenuItems:
|
|
1512
|
-
setRowData:
|
|
1513
|
-
deleteRows:
|
|
1534
|
+
getContextMenuItems: xt,
|
|
1535
|
+
setRowData: ft,
|
|
1536
|
+
deleteRows: pt,
|
|
1514
1537
|
insertRowAfter: Q,
|
|
1515
|
-
duplicateRows:
|
|
1516
|
-
stopEditing:
|
|
1517
|
-
cellClassName:
|
|
1538
|
+
duplicateRows: dt,
|
|
1539
|
+
stopEditing: ht,
|
|
1540
|
+
cellClassName: be,
|
|
1518
1541
|
onScroll: xe,
|
|
1519
|
-
children: /* @__PURE__ */ u(
|
|
1542
|
+
children: /* @__PURE__ */ u(Te, {
|
|
1520
1543
|
columnRights: B,
|
|
1521
1544
|
columnWidths: z,
|
|
1522
1545
|
activeCell: W,
|
|
1523
1546
|
selection: J,
|
|
1524
1547
|
headerRowHeight: _,
|
|
1525
|
-
rowHeight:
|
|
1526
|
-
hasStickyRightColumn:
|
|
1548
|
+
rowHeight: He,
|
|
1549
|
+
hasStickyRightColumn: L,
|
|
1527
1550
|
dataLength: e.length,
|
|
1528
|
-
viewHeight:
|
|
1529
|
-
viewWidth:
|
|
1530
|
-
contentWidth:
|
|
1531
|
-
edges:
|
|
1551
|
+
viewHeight: qe,
|
|
1552
|
+
viewWidth: Ke,
|
|
1553
|
+
contentWidth: Ye ? void 0 : Xe,
|
|
1554
|
+
edges: Je,
|
|
1532
1555
|
editing: H,
|
|
1533
1556
|
isCellDisabled: Z,
|
|
1534
|
-
expandSelection:
|
|
1535
|
-
stickyLeftColumns:
|
|
1536
|
-
getStickyLeftOffset:
|
|
1557
|
+
expandSelection: st,
|
|
1558
|
+
stickyLeftColumns: Ze,
|
|
1559
|
+
getStickyLeftOffset: Qe
|
|
1537
1560
|
})
|
|
1538
1561
|
}),
|
|
1539
1562
|
/* @__PURE__ */ u("div", {
|
|
1540
|
-
ref:
|
|
1563
|
+
ref: ze,
|
|
1541
1564
|
tabIndex: h.length && e.length ? 0 : void 0,
|
|
1542
1565
|
onFocus: (t) => {
|
|
1543
1566
|
t.target.blur(), G({
|
|
1544
|
-
col:
|
|
1567
|
+
col: I.length - (L ? 3 : 2),
|
|
1545
1568
|
row: e.length - 1
|
|
1546
1569
|
});
|
|
1547
1570
|
}
|
|
1548
1571
|
}),
|
|
1549
1572
|
!T && S && /* @__PURE__ */ u(S, { addRows: (t) => Q(e.length - 1, t) }),
|
|
1550
|
-
|
|
1551
|
-
clientX:
|
|
1552
|
-
clientY:
|
|
1553
|
-
cursorIndex:
|
|
1554
|
-
items:
|
|
1573
|
+
$e && et.length > 0 && /* @__PURE__ */ u(ee, {
|
|
1574
|
+
clientX: $e.x,
|
|
1575
|
+
clientY: $e.y,
|
|
1576
|
+
cursorIndex: $e.cursorIndex,
|
|
1577
|
+
items: et,
|
|
1555
1578
|
close: () => V(null)
|
|
1556
1579
|
})
|
|
1557
1580
|
]
|
|
1558
1581
|
});
|
|
1559
1582
|
}));
|
|
1560
|
-
|
|
1583
|
+
Me.displayName = "DataSheetGrid";
|
|
1561
1584
|
// src/hooks/useConstant.ts
|
|
1562
|
-
function
|
|
1585
|
+
function Ne(e) {
|
|
1563
1586
|
let [t] = s(e);
|
|
1564
1587
|
return t;
|
|
1565
1588
|
}
|
|
1566
1589
|
// src/components/StaticDataSheetGrid.tsx
|
|
1567
|
-
var
|
|
1568
|
-
let _ =
|
|
1590
|
+
var Pe = e.forwardRef(({ columns: e, gutterColumn: t, stickyRightColumn: n, addRowsComponent: r, createRow: i, duplicateRow: a, style: o, rowKey: s, onFocus: c, onBlur: l, onActiveCellChange: d, onSelectionChange: f, rowClassName: p, rowHeight: m, ...h }, g) => {
|
|
1591
|
+
let _ = Ne(() => ({
|
|
1569
1592
|
columns: e,
|
|
1570
1593
|
gutterColumn: t,
|
|
1571
1594
|
stickyRightColumn: n,
|
|
@@ -1581,17 +1604,17 @@ var Me = e.forwardRef(({ columns: e, gutterColumn: t, stickyRightColumn: n, addR
|
|
|
1581
1604
|
rowClassName: p,
|
|
1582
1605
|
rowHeight: m
|
|
1583
1606
|
}));
|
|
1584
|
-
return /* @__PURE__ */ u(
|
|
1607
|
+
return /* @__PURE__ */ u(Me, {
|
|
1585
1608
|
..._,
|
|
1586
1609
|
...h,
|
|
1587
1610
|
rowHeight: typeof m == "number" ? m : _.rowHeight,
|
|
1588
1611
|
ref: g
|
|
1589
1612
|
});
|
|
1590
|
-
}),
|
|
1613
|
+
}), Fe = () => {
|
|
1591
1614
|
let e = o(!0), t = e.current;
|
|
1592
1615
|
return e.current = !1, t;
|
|
1593
|
-
}, I = ".dsg-cell-sticky-left, .dsg-cell-gutter",
|
|
1594
|
-
function
|
|
1616
|
+
}, I = ".dsg-cell-sticky-left, .dsg-cell-gutter", L = ".dsg-cell-sticky-right", Ie = 1;
|
|
1617
|
+
function Le(e, t) {
|
|
1595
1618
|
let { top: n, left: r } = e.getBoundingClientRect(), i = {
|
|
1596
1619
|
top: n,
|
|
1597
1620
|
left: r,
|
|
@@ -1600,32 +1623,32 @@ function L(e, t) {
|
|
|
1600
1623
|
}, a = e.querySelector(".dsg-row-header");
|
|
1601
1624
|
return a && (i.top = Math.max(i.top, a.getBoundingClientRect().bottom), t?.matches(I) || Array.from(a.querySelectorAll(I)).forEach((e) => {
|
|
1602
1625
|
i.left = Math.max(i.left, e.getBoundingClientRect().right);
|
|
1603
|
-
}), t?.matches(
|
|
1626
|
+
}), t?.matches(L) || Array.from(a.querySelectorAll(L)).forEach((e) => {
|
|
1604
1627
|
i.right = Math.min(i.right, e.getBoundingClientRect().left);
|
|
1605
1628
|
})), i;
|
|
1606
1629
|
}
|
|
1607
|
-
function
|
|
1608
|
-
return e.top >= t.top -
|
|
1630
|
+
function R(e, t) {
|
|
1631
|
+
return e.top >= t.top - Ie && e.top <= t.bottom + Ie && e.left >= t.left - Ie && e.left <= t.right + Ie;
|
|
1609
1632
|
}
|
|
1610
1633
|
// src/columns/textColumn.tsx
|
|
1611
|
-
var
|
|
1612
|
-
let _ = o(null), b =
|
|
1634
|
+
var Re = (e, t) => e !== null && e.top === t.top && e.left === t.left && e.width === t.width && e.height === t.height && e.maxWidth === t.maxWidth && e.maxHeight === t.maxHeight && e.anchorVisible === t.anchorVisible, ze = 480, Be = 300, Ve = (e, t, n, r, i) => Math.max(0, Math.min(Math.max(e, n), r - t - i)), He = e.memo(({ active: e, focus: t, rowData: r, setRowData: a, columnData: { placeholder: c, alignRight: f, formatInputOnFocus: p, formatBlurredInput: m, parseUserInput: h, continuousUpdates: g } }) => {
|
|
1635
|
+
let _ = o(null), b = Fe(), [x, S] = s(null), [C, w] = s(null);
|
|
1613
1636
|
i(() => {
|
|
1614
1637
|
if (!e || !x) {
|
|
1615
1638
|
w(null);
|
|
1616
1639
|
return;
|
|
1617
1640
|
}
|
|
1618
|
-
let t = getComputedStyle(document.documentElement), n = parseFloat(t.getPropertyValue("--dsg-cell-expanded-max-width")) ||
|
|
1619
|
-
let e = x.getBoundingClientRect(), t =
|
|
1641
|
+
let t = getComputedStyle(document.documentElement), n = parseFloat(t.getPropertyValue("--dsg-cell-expanded-max-width")) || ze, r = parseFloat(t.getPropertyValue("--dsg-cell-expanded-max-height")) || Be, i = x.closest(".dsg-container"), a = x.closest(".dsg-cell"), o, s = () => {
|
|
1642
|
+
let e = x.getBoundingClientRect(), t = Ve(e.width, e.left, n, window.innerWidth, 8), c = Ve(e.height, e.top, r, window.innerHeight, 8), l = {
|
|
1620
1643
|
top: e.top,
|
|
1621
1644
|
left: e.left,
|
|
1622
1645
|
width: e.width,
|
|
1623
1646
|
height: e.height,
|
|
1624
1647
|
maxWidth: t,
|
|
1625
1648
|
maxHeight: c,
|
|
1626
|
-
anchorVisible: !i ||
|
|
1649
|
+
anchorVisible: !i || R(e, Le(i, a))
|
|
1627
1650
|
};
|
|
1628
|
-
w((e) =>
|
|
1651
|
+
w((e) => Re(e, l) ? e : l), o = requestAnimationFrame(s);
|
|
1629
1652
|
};
|
|
1630
1653
|
return s(), () => cancelAnimationFrame(o);
|
|
1631
1654
|
}, [e, x]);
|
|
@@ -1689,7 +1712,7 @@ var Ie = (e, t) => e !== null && e.top === t.top && e.left === t.left && e.width
|
|
|
1689
1712
|
onKeyDown: (e) => {
|
|
1690
1713
|
e.key === "Escape" && (T.current.escPressed = !0), e.key === "Enter" && !e.shiftKey && e.preventDefault();
|
|
1691
1714
|
}
|
|
1692
|
-
}),
|
|
1715
|
+
}), te = C && /* @__PURE__ */ u("div", {
|
|
1693
1716
|
className: v(t && "dsg-input-floating-wrapper"),
|
|
1694
1717
|
style: {
|
|
1695
1718
|
position: "fixed",
|
|
@@ -1707,13 +1730,13 @@ var Ie = (e, t) => e !== null && e.top === t.top && e.left === t.left && e.width
|
|
|
1707
1730
|
return /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("div", {
|
|
1708
1731
|
ref: S,
|
|
1709
1732
|
className: "dsg-input-anchor"
|
|
1710
|
-
}), x && y(D ?
|
|
1733
|
+
}), x && y(D ? te : A, D ? document.body : x)] });
|
|
1711
1734
|
});
|
|
1712
|
-
|
|
1713
|
-
var
|
|
1714
|
-
function
|
|
1735
|
+
He.displayName = "TextComponent";
|
|
1736
|
+
var Ue = We();
|
|
1737
|
+
function We({ placeholder: e, alignRight: t = !1, continuousUpdates: n = !0, deletedValue: r = null, parseUserInput: i = (e) => e.trim() || null, formatBlurredInput: a = (e) => String(e ?? ""), formatInputOnFocus: o = (e) => String(e ?? ""), formatForCopy: s = (e) => String(e ?? ""), parsePastedValue: c = (e) => e.trim() || null } = {}) {
|
|
1715
1738
|
return {
|
|
1716
|
-
component:
|
|
1739
|
+
component: He,
|
|
1717
1740
|
columnData: {
|
|
1718
1741
|
placeholder: e,
|
|
1719
1742
|
alignRight: t,
|
|
@@ -1729,7 +1752,7 @@ function He({ placeholder: e, alignRight: t = !1, continuousUpdates: n = !0, del
|
|
|
1729
1752
|
};
|
|
1730
1753
|
}
|
|
1731
1754
|
// src/columns/checkboxColumn.tsx
|
|
1732
|
-
var
|
|
1755
|
+
var Ge = /* @__PURE__ */ new Set([
|
|
1733
1756
|
"",
|
|
1734
1757
|
"false",
|
|
1735
1758
|
"no",
|
|
@@ -1743,7 +1766,7 @@ var Ue = /* @__PURE__ */ new Set([
|
|
|
1743
1766
|
"null",
|
|
1744
1767
|
"wrong",
|
|
1745
1768
|
"negative"
|
|
1746
|
-
]),
|
|
1769
|
+
]), Ke = e.memo(({ focus: e, rowData: t, setRowData: n, active: r, stopEditing: a, disabled: s }) => {
|
|
1747
1770
|
let c = o(null);
|
|
1748
1771
|
return i(() => {
|
|
1749
1772
|
e && (n(!t), a({ nextRow: !1 }));
|
|
@@ -1758,14 +1781,14 @@ var Ue = /* @__PURE__ */ new Set([
|
|
|
1758
1781
|
onChange: () => null
|
|
1759
1782
|
});
|
|
1760
1783
|
});
|
|
1761
|
-
|
|
1762
|
-
var
|
|
1763
|
-
component:
|
|
1784
|
+
Ke.displayName = "CheckboxComponent";
|
|
1785
|
+
var qe = {
|
|
1786
|
+
component: Ke,
|
|
1764
1787
|
deleteValue: () => !1,
|
|
1765
1788
|
copyValue: ({ rowData: e }) => e ? "YES" : "NO",
|
|
1766
|
-
pasteValue: ({ value: e }) => !
|
|
1789
|
+
pasteValue: ({ value: e }) => !Ge.has(e.toLowerCase()),
|
|
1767
1790
|
isCellEmpty: ({ rowData: e }) => !e
|
|
1768
|
-
},
|
|
1791
|
+
}, Je = We({
|
|
1769
1792
|
alignRight: !0,
|
|
1770
1793
|
formatBlurredInput: (e) => typeof e == "number" ? new Intl.NumberFormat().format(e) : "",
|
|
1771
1794
|
parseUserInput: (e) => {
|
|
@@ -1776,7 +1799,7 @@ var We = {
|
|
|
1776
1799
|
let t = parseFloat(e);
|
|
1777
1800
|
return isNaN(t) ? null : t;
|
|
1778
1801
|
}
|
|
1779
|
-
}),
|
|
1802
|
+
}), Ye = We({
|
|
1780
1803
|
alignRight: !0,
|
|
1781
1804
|
formatBlurredInput: (e) => typeof e == "number" ? new Intl.NumberFormat().format(e) : "",
|
|
1782
1805
|
parseUserInput: (e) => {
|
|
@@ -1787,10 +1810,10 @@ var We = {
|
|
|
1787
1810
|
let t = parseFloat(e);
|
|
1788
1811
|
return isNaN(t) ? null : Math.round(t);
|
|
1789
1812
|
}
|
|
1790
|
-
}),
|
|
1813
|
+
}), Xe = 0xe8d4a51000, z = 1e10, B = We({
|
|
1791
1814
|
alignRight: !0,
|
|
1792
1815
|
formatBlurredInput: (e) => typeof e == "number" ? new Intl.NumberFormat(void 0, { style: "percent" }).format(e) : "",
|
|
1793
|
-
formatInputOnFocus: (e) => typeof e == "number" && !isNaN(e) ? String(Math.round(e *
|
|
1816
|
+
formatInputOnFocus: (e) => typeof e == "number" && !isNaN(e) ? String(Math.round(e * Xe) / z) : "",
|
|
1794
1817
|
parseUserInput: (e) => {
|
|
1795
1818
|
let t = parseFloat(e);
|
|
1796
1819
|
return isNaN(t) ? null : t / 100;
|
|
@@ -1799,7 +1822,7 @@ var We = {
|
|
|
1799
1822
|
let t = parseFloat(e);
|
|
1800
1823
|
return isNaN(t) ? null : t;
|
|
1801
1824
|
}
|
|
1802
|
-
}),
|
|
1825
|
+
}), Ze = e.memo(({ focus: e, active: t, rowData: n, setRowData: r }) => {
|
|
1803
1826
|
let a = o(null);
|
|
1804
1827
|
return i(() => {
|
|
1805
1828
|
e ? a.current?.select() : a.current?.blur();
|
|
@@ -1820,9 +1843,9 @@ var We = {
|
|
|
1820
1843
|
}
|
|
1821
1844
|
});
|
|
1822
1845
|
});
|
|
1823
|
-
|
|
1824
|
-
var
|
|
1825
|
-
component:
|
|
1846
|
+
Ze.displayName = "DateComponent";
|
|
1847
|
+
var Qe = {
|
|
1848
|
+
component: Ze,
|
|
1826
1849
|
deleteValue: () => null,
|
|
1827
1850
|
copyValue: ({ rowData: e }) => e ? e.toISOString().substr(0, 10) : null,
|
|
1828
1851
|
pasteValue: ({ value: e }) => {
|
|
@@ -1831,7 +1854,7 @@ var Ye = {
|
|
|
1831
1854
|
},
|
|
1832
1855
|
minWidth: 170,
|
|
1833
1856
|
isCellEmpty: ({ rowData: e }) => !e
|
|
1834
|
-
},
|
|
1857
|
+
}, $e = e.memo(({ focus: e, active: t, rowData: n, setRowData: r }) => {
|
|
1835
1858
|
let a = o(null);
|
|
1836
1859
|
return i(() => {
|
|
1837
1860
|
e ? a.current?.select() : a.current?.blur();
|
|
@@ -1852,9 +1875,9 @@ var Ye = {
|
|
|
1852
1875
|
}
|
|
1853
1876
|
});
|
|
1854
1877
|
});
|
|
1855
|
-
|
|
1856
|
-
var
|
|
1857
|
-
component:
|
|
1878
|
+
$e.displayName = "IsoDateComponent";
|
|
1879
|
+
var V = {
|
|
1880
|
+
component: $e,
|
|
1858
1881
|
deleteValue: () => null,
|
|
1859
1882
|
copyValue: ({ rowData: e }) => e,
|
|
1860
1883
|
pasteValue: ({ value: e }) => {
|
|
@@ -1863,7 +1886,7 @@ var Xe = {
|
|
|
1863
1886
|
},
|
|
1864
1887
|
minWidth: 170,
|
|
1865
1888
|
isCellEmpty: ({ rowData: e }) => !e
|
|
1866
|
-
},
|
|
1889
|
+
}, et = ({ columnData: { key: e, original: n }, rowData: r, setRowData: i, ...a }) => {
|
|
1867
1890
|
let s = o(r);
|
|
1868
1891
|
s.current = r;
|
|
1869
1892
|
let c = t((t) => {
|
|
@@ -1880,14 +1903,14 @@ var Xe = {
|
|
|
1880
1903
|
rowData: r[e],
|
|
1881
1904
|
...a
|
|
1882
1905
|
});
|
|
1883
|
-
},
|
|
1906
|
+
}, tt = (e, t) => ({
|
|
1884
1907
|
id: e,
|
|
1885
1908
|
...t,
|
|
1886
1909
|
columnData: {
|
|
1887
1910
|
key: e,
|
|
1888
1911
|
original: t
|
|
1889
1912
|
},
|
|
1890
|
-
component:
|
|
1913
|
+
component: et,
|
|
1891
1914
|
copyValue: ({ rowData: n, rowIndex: r }) => t.copyValue?.({
|
|
1892
1915
|
rowData: n[e],
|
|
1893
1916
|
rowIndex: r
|
|
@@ -1920,7 +1943,7 @@ var Xe = {
|
|
|
1920
1943
|
rowData: n[e],
|
|
1921
1944
|
rowIndex: r
|
|
1922
1945
|
}) ?? !1
|
|
1923
|
-
}),
|
|
1924
|
-
export {
|
|
1946
|
+
}), H = Me, U = Pe;
|
|
1947
|
+
export { U as DataSheetGrid, H as DynamicDataSheetGrid, qe as checkboxColumn, N as createAddRowsComponent, F as createContextMenuComponent, We as createTextColumn, Qe as dateColumn, Je as floatColumn, Ye as intColumn, V as isoDateColumn, tt as keyColumn, B as percentColumn, P as renderContextMenuItem, Ue as textColumn };
|
|
1925
1948
|
|
|
1926
1949
|
//# sourceMappingURL=index.js.map
|