react-smart-copy 1.8.1 → 1.9.0
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/README.md +121 -2
- package/dist/core.cjs +14 -3
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +14 -3
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +14 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/table.cjs +855 -0
- package/dist/table.cjs.map +1 -0
- package/dist/table.d.cts +380 -0
- package/dist/table.d.ts +380 -0
- package/dist/table.js +838 -0
- package/dist/table.js.map +1 -0
- package/package.json +45 -4
package/dist/core.js
CHANGED
|
@@ -404,6 +404,17 @@ function createOperations() {
|
|
|
404
404
|
};
|
|
405
405
|
}
|
|
406
406
|
//#endregion
|
|
407
|
+
//#region src/core/source-error.ts
|
|
408
|
+
/**
|
|
409
|
+
* The error for a user-supplied source (copy source, drag source, copy transform)
|
|
410
|
+
* that threw. A thrown `CopyFailure` keeps its classification, so a helper such as
|
|
411
|
+
* `tablePayload()` can report `too-large` instead of a generic `invalid-payload`.
|
|
412
|
+
* Internal: not part of the public API.
|
|
413
|
+
*/
|
|
414
|
+
function sourceError(cause, message) {
|
|
415
|
+
return isCopyFailure(cause) ? cause.copyError : createCopyError("invalid-payload", message, cause);
|
|
416
|
+
}
|
|
417
|
+
//#endregion
|
|
407
418
|
//#region src/core/copy-machine.ts
|
|
408
419
|
const DEFAULT_RESET_AFTER_MS = 2e3;
|
|
409
420
|
const IDLE_STATE = /* @__PURE__ */ Object.freeze({ status: "idle" });
|
|
@@ -506,7 +517,7 @@ function createCopyMachine(options = {}) {
|
|
|
506
517
|
}
|
|
507
518
|
payload = normalizePayload(resolved);
|
|
508
519
|
} catch (cause) {
|
|
509
|
-
const error =
|
|
520
|
+
const error = sourceError(cause, "The copy source function threw.");
|
|
510
521
|
settleError(error, null, retryCount);
|
|
511
522
|
return Promise.resolve({
|
|
512
523
|
status: "error",
|
|
@@ -796,7 +807,7 @@ function interceptCopyEvent(event, options) {
|
|
|
796
807
|
try {
|
|
797
808
|
decision = options.transform(selection);
|
|
798
809
|
} catch (cause) {
|
|
799
|
-
return fail(
|
|
810
|
+
return fail(sourceError(cause, "The copy transform threw."));
|
|
800
811
|
}
|
|
801
812
|
if (decision === null || decision === void 0) return {
|
|
802
813
|
status: "passed",
|
|
@@ -1003,7 +1014,7 @@ function applyDragCopy(event, options) {
|
|
|
1003
1014
|
} catch (cause) {
|
|
1004
1015
|
return {
|
|
1005
1016
|
status: "failed",
|
|
1006
|
-
error:
|
|
1017
|
+
error: sourceError(cause, "The drag source threw.")
|
|
1007
1018
|
};
|
|
1008
1019
|
}
|
|
1009
1020
|
if (decision === null || decision === void 0) return {
|