twico-ui 1.37.1 → 1.37.2
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/CHANGELOG.md +8 -0
- package/dist/index.cjs +69 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +69 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -10646,8 +10646,10 @@ function Datatable({
|
|
|
10646
10646
|
return;
|
|
10647
10647
|
}
|
|
10648
10648
|
if (k === "v") {
|
|
10649
|
-
|
|
10650
|
-
|
|
10649
|
+
if (typeof navigator !== "undefined" && navigator.clipboard && navigator.clipboard.readText) {
|
|
10650
|
+
e.preventDefault();
|
|
10651
|
+
pasteSelection();
|
|
10652
|
+
}
|
|
10651
10653
|
return;
|
|
10652
10654
|
}
|
|
10653
10655
|
}
|
|
@@ -10867,19 +10869,19 @@ function Datatable({
|
|
|
10867
10869
|
const copyTypeOf = (col) => col && col.copyType != null ? col.copyType : col && col.type === "number" ? "number" : "text";
|
|
10868
10870
|
const writeClipboard = (text) => {
|
|
10869
10871
|
const execFallback = () => {
|
|
10872
|
+
if (typeof document === "undefined") return;
|
|
10873
|
+
const ta = document.createElement("textarea");
|
|
10874
|
+
ta.value = text;
|
|
10875
|
+
ta.style.position = "fixed";
|
|
10876
|
+
ta.style.opacity = "0";
|
|
10877
|
+
document.body.appendChild(ta);
|
|
10878
|
+
ta.focus();
|
|
10879
|
+
ta.select();
|
|
10870
10880
|
try {
|
|
10871
|
-
|
|
10872
|
-
const ta = document.createElement("textarea");
|
|
10873
|
-
ta.value = text;
|
|
10874
|
-
ta.style.position = "fixed";
|
|
10875
|
-
ta.style.opacity = "0";
|
|
10876
|
-
document.body.appendChild(ta);
|
|
10877
|
-
ta.focus();
|
|
10878
|
-
ta.select();
|
|
10879
|
-
document.execCommand("copy");
|
|
10880
|
-
document.body.removeChild(ta);
|
|
10881
|
-
}
|
|
10881
|
+
document.execCommand("copy");
|
|
10882
10882
|
} catch {
|
|
10883
|
+
} finally {
|
|
10884
|
+
if (ta.parentNode) ta.parentNode.removeChild(ta);
|
|
10883
10885
|
}
|
|
10884
10886
|
};
|
|
10885
10887
|
try {
|
|
@@ -10950,19 +10952,8 @@ function Datatable({
|
|
|
10950
10952
|
announceClip(`Copied ${n} cell${n === 1 ? "" : "s"}`, cellRect);
|
|
10951
10953
|
}
|
|
10952
10954
|
};
|
|
10953
|
-
const
|
|
10954
|
-
if (!cellRect) return;
|
|
10955
|
-
let text = null;
|
|
10956
|
-
try {
|
|
10957
|
-
if (typeof navigator !== "undefined" && navigator.clipboard && navigator.clipboard.readText) text = await navigator.clipboard.readText();
|
|
10958
|
-
} catch {
|
|
10959
|
-
setClipboardMsg("Paste unavailable \u2014 clipboard permission denied");
|
|
10960
|
-
return;
|
|
10961
|
-
}
|
|
10962
|
-
if (text == null) {
|
|
10963
|
-
setClipboardMsg("Nothing to paste");
|
|
10964
|
-
return;
|
|
10965
|
-
}
|
|
10955
|
+
const applyPastedText = (text) => {
|
|
10956
|
+
if (text == null || !cellRect) return;
|
|
10966
10957
|
const inApp = clipboardRef.current && clipboardRef.current.tsv === text ? clipboardRef.current : null;
|
|
10967
10958
|
let matrix;
|
|
10968
10959
|
if (inApp) matrix = inApp.matrix;
|
|
@@ -11007,6 +10998,31 @@ function Datatable({
|
|
|
11007
10998
|
const pasteRect = written ? { r0: cellRect.r0, c0: cellRect.c0, r1: Math.min(cellRect.r0 + matrix.length - 1, leafRows.length - 1), c1: Math.min(cellRect.c0 + maxCols - 1, ordered.length - 1) } : null;
|
|
11008
10999
|
announceClip(`Pasted ${written} cell${written === 1 ? "" : "s"}${skipped ? `, ${skipped} skipped (incompatible column)` : ""}`, pasteRect);
|
|
11009
11000
|
};
|
|
11001
|
+
const pasteSelection = async () => {
|
|
11002
|
+
if (!cellRect) return;
|
|
11003
|
+
let text = null;
|
|
11004
|
+
try {
|
|
11005
|
+
if (typeof navigator !== "undefined" && navigator.clipboard && navigator.clipboard.readText) text = await navigator.clipboard.readText();
|
|
11006
|
+
} catch {
|
|
11007
|
+
setClipboardMsg("Paste unavailable \u2014 clipboard permission denied");
|
|
11008
|
+
return;
|
|
11009
|
+
}
|
|
11010
|
+
if (text == null) {
|
|
11011
|
+
setClipboardMsg("Nothing to paste");
|
|
11012
|
+
return;
|
|
11013
|
+
}
|
|
11014
|
+
applyPastedText(text);
|
|
11015
|
+
};
|
|
11016
|
+
const onGridPaste = (e) => {
|
|
11017
|
+
if (e.target.closest("input, textarea, select, [contenteditable='true']") || editing) return;
|
|
11018
|
+
if (!e.target.closest(".twc-dt__td[data-r]")) return;
|
|
11019
|
+
if (!(enableClipboard && selectionMode === "cell") || !cellRect) return;
|
|
11020
|
+
if (typeof navigator !== "undefined" && navigator.clipboard && navigator.clipboard.readText) return;
|
|
11021
|
+
const text = e.clipboardData ? e.clipboardData.getData("text/plain") : null;
|
|
11022
|
+
if (text == null || text === "") return;
|
|
11023
|
+
e.preventDefault();
|
|
11024
|
+
applyPastedText(text);
|
|
11025
|
+
};
|
|
11010
11026
|
React51__default.useEffect(() => {
|
|
11011
11027
|
if (!editing) return;
|
|
11012
11028
|
const onDown = (e) => {
|
|
@@ -12022,6 +12038,7 @@ function Datatable({
|
|
|
12022
12038
|
"aria-activedescendant": activeCellId,
|
|
12023
12039
|
"aria-busy": loading || void 0,
|
|
12024
12040
|
onKeyDown: onGridKeyDown,
|
|
12041
|
+
onPaste: onGridPaste,
|
|
12025
12042
|
children: [
|
|
12026
12043
|
/* @__PURE__ */ jsx("thead", { ref: theadRef, children: /* @__PURE__ */ jsxs("tr", { role: "row", "aria-rowindex": 1, children: [
|
|
12027
12044
|
hasExpandCol ? /* @__PURE__ */ jsx("th", { className: "twc-dt__th twc-dt__expand-cell", role: "columnheader", "aria-label": "Expand", "data-pin": "left", "data-pin-edge": checkboxSelection || showRowNum || visLeft.length ? void 0 : "left", style: { insetInlineStart: 0, width: EXP_W, minWidth: EXP_W } }) : null,
|
|
@@ -19096,14 +19113,36 @@ function Code({
|
|
|
19096
19113
|
const timerRef = React51__default.useRef(null);
|
|
19097
19114
|
React51__default.useEffect(() => () => clearTimeout(timerRef.current), []);
|
|
19098
19115
|
const doCopy = () => {
|
|
19099
|
-
if (typeof navigator === "undefined" || !navigator.clipboard) return;
|
|
19100
19116
|
const text = typeof children === "string" ? children : rootRef.current?.textContent ?? "";
|
|
19101
|
-
|
|
19117
|
+
const flash = () => {
|
|
19102
19118
|
setCopied(true);
|
|
19103
19119
|
clearTimeout(timerRef.current);
|
|
19104
19120
|
timerRef.current = setTimeout(() => setCopied(false), 2e3);
|
|
19105
|
-
}
|
|
19106
|
-
|
|
19121
|
+
};
|
|
19122
|
+
const execFallback = () => {
|
|
19123
|
+
if (typeof document === "undefined") return;
|
|
19124
|
+
const ta = document.createElement("textarea");
|
|
19125
|
+
ta.value = text;
|
|
19126
|
+
ta.style.position = "fixed";
|
|
19127
|
+
ta.style.opacity = "0";
|
|
19128
|
+
document.body.appendChild(ta);
|
|
19129
|
+
ta.focus();
|
|
19130
|
+
ta.select();
|
|
19131
|
+
try {
|
|
19132
|
+
if (document.execCommand("copy")) flash();
|
|
19133
|
+
} catch {
|
|
19134
|
+
} finally {
|
|
19135
|
+
if (ta.parentNode) ta.parentNode.removeChild(ta);
|
|
19136
|
+
}
|
|
19137
|
+
};
|
|
19138
|
+
try {
|
|
19139
|
+
if (typeof navigator !== "undefined" && navigator.clipboard && navigator.clipboard.writeText) {
|
|
19140
|
+
navigator.clipboard.writeText(text).then(flash).catch(execFallback);
|
|
19141
|
+
return;
|
|
19142
|
+
}
|
|
19143
|
+
} catch {
|
|
19144
|
+
}
|
|
19145
|
+
execFallback();
|
|
19107
19146
|
};
|
|
19108
19147
|
return /* @__PURE__ */ jsxs(Tag2, { ref: rootRef, className: `twc-code ${className}`.trim(), "data-block": block || void 0, ...rest, children: [
|
|
19109
19148
|
__twcStyles,
|