react-smart-copy 1.8.0 → 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 +133 -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 +49 -5
package/dist/index.cjs
CHANGED
|
@@ -408,6 +408,17 @@ function createOperations() {
|
|
|
408
408
|
};
|
|
409
409
|
}
|
|
410
410
|
//#endregion
|
|
411
|
+
//#region src/core/source-error.ts
|
|
412
|
+
/**
|
|
413
|
+
* The error for a user-supplied source (copy source, drag source, copy transform)
|
|
414
|
+
* that threw. A thrown `CopyFailure` keeps its classification, so a helper such as
|
|
415
|
+
* `tablePayload()` can report `too-large` instead of a generic `invalid-payload`.
|
|
416
|
+
* Internal: not part of the public API.
|
|
417
|
+
*/
|
|
418
|
+
function sourceError(cause, message) {
|
|
419
|
+
return isCopyFailure(cause) ? cause.copyError : createCopyError("invalid-payload", message, cause);
|
|
420
|
+
}
|
|
421
|
+
//#endregion
|
|
411
422
|
//#region src/core/copy-machine.ts
|
|
412
423
|
const DEFAULT_RESET_AFTER_MS = 2e3;
|
|
413
424
|
const IDLE_STATE = /* @__PURE__ */ Object.freeze({ status: "idle" });
|
|
@@ -510,7 +521,7 @@ function createCopyMachine(options = {}) {
|
|
|
510
521
|
}
|
|
511
522
|
payload = normalizePayload(resolved);
|
|
512
523
|
} catch (cause) {
|
|
513
|
-
const error =
|
|
524
|
+
const error = sourceError(cause, "The copy source function threw.");
|
|
514
525
|
settleError(error, null, retryCount);
|
|
515
526
|
return Promise.resolve({
|
|
516
527
|
status: "error",
|
|
@@ -800,7 +811,7 @@ function interceptCopyEvent(event, options) {
|
|
|
800
811
|
try {
|
|
801
812
|
decision = options.transform(selection);
|
|
802
813
|
} catch (cause) {
|
|
803
|
-
return fail(
|
|
814
|
+
return fail(sourceError(cause, "The copy transform threw."));
|
|
804
815
|
}
|
|
805
816
|
if (decision === null || decision === void 0) return {
|
|
806
817
|
status: "passed",
|
|
@@ -1007,7 +1018,7 @@ function applyDragCopy(event, options) {
|
|
|
1007
1018
|
} catch (cause) {
|
|
1008
1019
|
return {
|
|
1009
1020
|
status: "failed",
|
|
1010
|
-
error:
|
|
1021
|
+
error: sourceError(cause, "The drag source threw.")
|
|
1011
1022
|
};
|
|
1012
1023
|
}
|
|
1013
1024
|
if (decision === null || decision === void 0) return {
|