react-glide-table 2.3.4 → 2.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/compound.cjs CHANGED
@@ -3040,15 +3040,41 @@ function serializeSelectionToTSV(visibleRows, bounds, mode = "visible", options)
3040
3040
  options
3041
3041
  );
3042
3042
  }
3043
+ function writeTextWithExecCommand(text) {
3044
+ if (typeof document === "undefined") return false;
3045
+ const textarea = document.createElement("textarea");
3046
+ textarea.value = text;
3047
+ textarea.setAttribute("readonly", "");
3048
+ textarea.style.position = "fixed";
3049
+ textarea.style.top = "0";
3050
+ textarea.style.left = "0";
3051
+ textarea.style.opacity = "0";
3052
+ textarea.style.pointerEvents = "none";
3053
+ document.body.appendChild(textarea);
3054
+ const previouslyFocused = document.activeElement;
3055
+ try {
3056
+ textarea.focus();
3057
+ textarea.select();
3058
+ return document.execCommand("copy");
3059
+ } catch {
3060
+ return false;
3061
+ } finally {
3062
+ document.body.removeChild(textarea);
3063
+ previouslyFocused?.focus?.();
3064
+ }
3065
+ }
3043
3066
  async function writeSelectionToClipboard(visibleRows, bounds, mode = "visible", options) {
3044
3067
  const text = serializeSelectionToTSV(visibleRows, bounds, mode, options);
3045
3068
  if (!text) return false;
3069
+ if (typeof navigator === "undefined" || !navigator.clipboard?.writeText) {
3070
+ return writeTextWithExecCommand(text);
3071
+ }
3046
3072
  try {
3047
3073
  await navigator.clipboard.writeText(text);
3074
+ return true;
3048
3075
  } catch {
3049
3076
  return false;
3050
3077
  }
3051
- return true;
3052
3078
  }
3053
3079
 
3054
3080
  // src/components/ui/table/features/cell-selection/fillData.ts
@@ -3554,8 +3580,12 @@ function handleEscape(event) {
3554
3580
  if (isOverlayDismissIgnoreTarget(event.target) || isOverlayDismissIgnoreTarget(document.activeElement)) {
3555
3581
  return;
3556
3582
  }
3557
- for (const clearAllSelections of clearAllByOwner.values()) {
3558
- clearAllSelections();
3583
+ for (const clearAllSelections of [...clearAllByOwner.values()]) {
3584
+ try {
3585
+ clearAllSelections();
3586
+ } catch (error) {
3587
+ console.error("[react-glide-table] escape-dismiss callback failed", error);
3588
+ }
3559
3589
  }
3560
3590
  }
3561
3591
  function registerEscapeDismiss(owner, clearAllSelections) {
package/dist/compound.js CHANGED
@@ -3028,15 +3028,41 @@ function serializeSelectionToTSV(visibleRows, bounds, mode = "visible", options)
3028
3028
  options
3029
3029
  );
3030
3030
  }
3031
+ function writeTextWithExecCommand(text) {
3032
+ if (typeof document === "undefined") return false;
3033
+ const textarea = document.createElement("textarea");
3034
+ textarea.value = text;
3035
+ textarea.setAttribute("readonly", "");
3036
+ textarea.style.position = "fixed";
3037
+ textarea.style.top = "0";
3038
+ textarea.style.left = "0";
3039
+ textarea.style.opacity = "0";
3040
+ textarea.style.pointerEvents = "none";
3041
+ document.body.appendChild(textarea);
3042
+ const previouslyFocused = document.activeElement;
3043
+ try {
3044
+ textarea.focus();
3045
+ textarea.select();
3046
+ return document.execCommand("copy");
3047
+ } catch {
3048
+ return false;
3049
+ } finally {
3050
+ document.body.removeChild(textarea);
3051
+ previouslyFocused?.focus?.();
3052
+ }
3053
+ }
3031
3054
  async function writeSelectionToClipboard(visibleRows, bounds, mode = "visible", options) {
3032
3055
  const text = serializeSelectionToTSV(visibleRows, bounds, mode, options);
3033
3056
  if (!text) return false;
3057
+ if (typeof navigator === "undefined" || !navigator.clipboard?.writeText) {
3058
+ return writeTextWithExecCommand(text);
3059
+ }
3034
3060
  try {
3035
3061
  await navigator.clipboard.writeText(text);
3062
+ return true;
3036
3063
  } catch {
3037
3064
  return false;
3038
3065
  }
3039
- return true;
3040
3066
  }
3041
3067
 
3042
3068
  // src/components/ui/table/features/cell-selection/fillData.ts
@@ -3542,8 +3568,12 @@ function handleEscape(event) {
3542
3568
  if (isOverlayDismissIgnoreTarget(event.target) || isOverlayDismissIgnoreTarget(document.activeElement)) {
3543
3569
  return;
3544
3570
  }
3545
- for (const clearAllSelections of clearAllByOwner.values()) {
3546
- clearAllSelections();
3571
+ for (const clearAllSelections of [...clearAllByOwner.values()]) {
3572
+ try {
3573
+ clearAllSelections();
3574
+ } catch (error) {
3575
+ console.error("[react-glide-table] escape-dismiss callback failed", error);
3576
+ }
3547
3577
  }
3548
3578
  }
3549
3579
  function registerEscapeDismiss(owner, clearAllSelections) {
package/dist/core.cjs CHANGED
@@ -1232,15 +1232,41 @@ function serializeSelectionToTSV(visibleRows, bounds, mode = "visible", options)
1232
1232
  options
1233
1233
  );
1234
1234
  }
1235
+ function writeTextWithExecCommand(text) {
1236
+ if (typeof document === "undefined") return false;
1237
+ const textarea = document.createElement("textarea");
1238
+ textarea.value = text;
1239
+ textarea.setAttribute("readonly", "");
1240
+ textarea.style.position = "fixed";
1241
+ textarea.style.top = "0";
1242
+ textarea.style.left = "0";
1243
+ textarea.style.opacity = "0";
1244
+ textarea.style.pointerEvents = "none";
1245
+ document.body.appendChild(textarea);
1246
+ const previouslyFocused = document.activeElement;
1247
+ try {
1248
+ textarea.focus();
1249
+ textarea.select();
1250
+ return document.execCommand("copy");
1251
+ } catch {
1252
+ return false;
1253
+ } finally {
1254
+ document.body.removeChild(textarea);
1255
+ previouslyFocused?.focus?.();
1256
+ }
1257
+ }
1235
1258
  async function writeSelectionToClipboard(visibleRows, bounds, mode = "visible", options) {
1236
1259
  const text = serializeSelectionToTSV(visibleRows, bounds, mode, options);
1237
1260
  if (!text) return false;
1261
+ if (typeof navigator === "undefined" || !navigator.clipboard?.writeText) {
1262
+ return writeTextWithExecCommand(text);
1263
+ }
1238
1264
  try {
1239
1265
  await navigator.clipboard.writeText(text);
1266
+ return true;
1240
1267
  } catch {
1241
1268
  return false;
1242
1269
  }
1243
- return true;
1244
1270
  }
1245
1271
 
1246
1272
  // src/components/ui/table/features/cell-selection/fillData.ts
@@ -1749,8 +1775,12 @@ function handleEscape(event) {
1749
1775
  if (isOverlayDismissIgnoreTarget(event.target) || isOverlayDismissIgnoreTarget(document.activeElement)) {
1750
1776
  return;
1751
1777
  }
1752
- for (const clearAllSelections of clearAllByOwner.values()) {
1753
- clearAllSelections();
1778
+ for (const clearAllSelections of [...clearAllByOwner.values()]) {
1779
+ try {
1780
+ clearAllSelections();
1781
+ } catch (error) {
1782
+ console.error("[react-glide-table] escape-dismiss callback failed", error);
1783
+ }
1754
1784
  }
1755
1785
  }
1756
1786
  function registerEscapeDismiss(owner, clearAllSelections) {
package/dist/core.js CHANGED
@@ -1138,15 +1138,41 @@ function serializeSelectionToTSV(visibleRows, bounds, mode = "visible", options)
1138
1138
  options
1139
1139
  );
1140
1140
  }
1141
+ function writeTextWithExecCommand(text) {
1142
+ if (typeof document === "undefined") return false;
1143
+ const textarea = document.createElement("textarea");
1144
+ textarea.value = text;
1145
+ textarea.setAttribute("readonly", "");
1146
+ textarea.style.position = "fixed";
1147
+ textarea.style.top = "0";
1148
+ textarea.style.left = "0";
1149
+ textarea.style.opacity = "0";
1150
+ textarea.style.pointerEvents = "none";
1151
+ document.body.appendChild(textarea);
1152
+ const previouslyFocused = document.activeElement;
1153
+ try {
1154
+ textarea.focus();
1155
+ textarea.select();
1156
+ return document.execCommand("copy");
1157
+ } catch {
1158
+ return false;
1159
+ } finally {
1160
+ document.body.removeChild(textarea);
1161
+ previouslyFocused?.focus?.();
1162
+ }
1163
+ }
1141
1164
  async function writeSelectionToClipboard(visibleRows, bounds, mode = "visible", options) {
1142
1165
  const text = serializeSelectionToTSV(visibleRows, bounds, mode, options);
1143
1166
  if (!text) return false;
1167
+ if (typeof navigator === "undefined" || !navigator.clipboard?.writeText) {
1168
+ return writeTextWithExecCommand(text);
1169
+ }
1144
1170
  try {
1145
1171
  await navigator.clipboard.writeText(text);
1172
+ return true;
1146
1173
  } catch {
1147
1174
  return false;
1148
1175
  }
1149
- return true;
1150
1176
  }
1151
1177
 
1152
1178
  // src/components/ui/table/features/cell-selection/fillData.ts
@@ -1655,8 +1681,12 @@ function handleEscape(event) {
1655
1681
  if (isOverlayDismissIgnoreTarget(event.target) || isOverlayDismissIgnoreTarget(document.activeElement)) {
1656
1682
  return;
1657
1683
  }
1658
- for (const clearAllSelections of clearAllByOwner.values()) {
1659
- clearAllSelections();
1684
+ for (const clearAllSelections of [...clearAllByOwner.values()]) {
1685
+ try {
1686
+ clearAllSelections();
1687
+ } catch (error) {
1688
+ console.error("[react-glide-table] escape-dismiss callback failed", error);
1689
+ }
1660
1690
  }
1661
1691
  }
1662
1692
  function registerEscapeDismiss(owner, clearAllSelections) {
package/dist/index.cjs CHANGED
@@ -1244,15 +1244,41 @@ function serializeSelectionToTSV(visibleRows, bounds, mode = "visible", options)
1244
1244
  options
1245
1245
  );
1246
1246
  }
1247
+ function writeTextWithExecCommand(text) {
1248
+ if (typeof document === "undefined") return false;
1249
+ const textarea = document.createElement("textarea");
1250
+ textarea.value = text;
1251
+ textarea.setAttribute("readonly", "");
1252
+ textarea.style.position = "fixed";
1253
+ textarea.style.top = "0";
1254
+ textarea.style.left = "0";
1255
+ textarea.style.opacity = "0";
1256
+ textarea.style.pointerEvents = "none";
1257
+ document.body.appendChild(textarea);
1258
+ const previouslyFocused = document.activeElement;
1259
+ try {
1260
+ textarea.focus();
1261
+ textarea.select();
1262
+ return document.execCommand("copy");
1263
+ } catch {
1264
+ return false;
1265
+ } finally {
1266
+ document.body.removeChild(textarea);
1267
+ previouslyFocused?.focus?.();
1268
+ }
1269
+ }
1247
1270
  async function writeSelectionToClipboard(visibleRows, bounds, mode = "visible", options) {
1248
1271
  const text = serializeSelectionToTSV(visibleRows, bounds, mode, options);
1249
1272
  if (!text) return false;
1273
+ if (typeof navigator === "undefined" || !navigator.clipboard?.writeText) {
1274
+ return writeTextWithExecCommand(text);
1275
+ }
1250
1276
  try {
1251
1277
  await navigator.clipboard.writeText(text);
1278
+ return true;
1252
1279
  } catch {
1253
1280
  return false;
1254
1281
  }
1255
- return true;
1256
1282
  }
1257
1283
 
1258
1284
  // src/components/ui/table/features/cell-selection/fillData.ts
@@ -1761,8 +1787,12 @@ function handleEscape(event) {
1761
1787
  if (isOverlayDismissIgnoreTarget(event.target) || isOverlayDismissIgnoreTarget(document.activeElement)) {
1762
1788
  return;
1763
1789
  }
1764
- for (const clearAllSelections of clearAllByOwner.values()) {
1765
- clearAllSelections();
1790
+ for (const clearAllSelections of [...clearAllByOwner.values()]) {
1791
+ try {
1792
+ clearAllSelections();
1793
+ } catch (error) {
1794
+ console.error("[react-glide-table] escape-dismiss callback failed", error);
1795
+ }
1766
1796
  }
1767
1797
  }
1768
1798
  function registerEscapeDismiss(owner, clearAllSelections) {
package/dist/index.js CHANGED
@@ -1147,15 +1147,41 @@ function serializeSelectionToTSV(visibleRows, bounds, mode = "visible", options)
1147
1147
  options
1148
1148
  );
1149
1149
  }
1150
+ function writeTextWithExecCommand(text) {
1151
+ if (typeof document === "undefined") return false;
1152
+ const textarea = document.createElement("textarea");
1153
+ textarea.value = text;
1154
+ textarea.setAttribute("readonly", "");
1155
+ textarea.style.position = "fixed";
1156
+ textarea.style.top = "0";
1157
+ textarea.style.left = "0";
1158
+ textarea.style.opacity = "0";
1159
+ textarea.style.pointerEvents = "none";
1160
+ document.body.appendChild(textarea);
1161
+ const previouslyFocused = document.activeElement;
1162
+ try {
1163
+ textarea.focus();
1164
+ textarea.select();
1165
+ return document.execCommand("copy");
1166
+ } catch {
1167
+ return false;
1168
+ } finally {
1169
+ document.body.removeChild(textarea);
1170
+ previouslyFocused?.focus?.();
1171
+ }
1172
+ }
1150
1173
  async function writeSelectionToClipboard(visibleRows, bounds, mode = "visible", options) {
1151
1174
  const text = serializeSelectionToTSV(visibleRows, bounds, mode, options);
1152
1175
  if (!text) return false;
1176
+ if (typeof navigator === "undefined" || !navigator.clipboard?.writeText) {
1177
+ return writeTextWithExecCommand(text);
1178
+ }
1153
1179
  try {
1154
1180
  await navigator.clipboard.writeText(text);
1181
+ return true;
1155
1182
  } catch {
1156
1183
  return false;
1157
1184
  }
1158
- return true;
1159
1185
  }
1160
1186
 
1161
1187
  // src/components/ui/table/features/cell-selection/fillData.ts
@@ -1664,8 +1690,12 @@ function handleEscape(event) {
1664
1690
  if (isOverlayDismissIgnoreTarget(event.target) || isOverlayDismissIgnoreTarget(document.activeElement)) {
1665
1691
  return;
1666
1692
  }
1667
- for (const clearAllSelections of clearAllByOwner.values()) {
1668
- clearAllSelections();
1693
+ for (const clearAllSelections of [...clearAllByOwner.values()]) {
1694
+ try {
1695
+ clearAllSelections();
1696
+ } catch (error) {
1697
+ console.error("[react-glide-table] escape-dismiss callback failed", error);
1698
+ }
1669
1699
  }
1670
1700
  }
1671
1701
  function registerEscapeDismiss(owner, clearAllSelections) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-glide-table",
3
- "version": "2.3.4",
3
+ "version": "2.3.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/zpxlffjrm/react-glide-table.git"