react-smart-copy 1.7.1 → 1.8.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 +131 -1
- package/dist/core.cjs +221 -25
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +127 -2
- package/dist/core.d.ts +127 -2
- package/dist/core.js +220 -26
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +324 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +171 -2
- package/dist/index.d.ts +171 -2
- package/dist/index.js +322 -26
- package/dist/index.js.map +1 -1
- package/package.json +8 -2
package/dist/index.d.cts
CHANGED
|
@@ -73,7 +73,7 @@ interface DataTransferItemLike {
|
|
|
73
73
|
readonly type: string;
|
|
74
74
|
}
|
|
75
75
|
/** Structural view of `DataTransfer` (paste and drop events). */
|
|
76
|
-
interface DataTransferLike {
|
|
76
|
+
export interface DataTransferLike {
|
|
77
77
|
readonly types: ArrayLike<string>;
|
|
78
78
|
getData(format: string): string;
|
|
79
79
|
readonly files?: ArrayLike<File> | null;
|
|
@@ -561,6 +561,131 @@ export interface CopyInterceptorOptions extends CopyInterceptOptions {
|
|
|
561
561
|
*/
|
|
562
562
|
export declare function registerCopyInterceptor(root: Element, options: CopyInterceptorOptions | (() => CopyInterceptorOptions)): () => void;
|
|
563
563
|
//#endregion
|
|
564
|
+
//#region src/core/drag-copy.d.ts
|
|
565
|
+
/**
|
|
566
|
+
* The `effectAllowed` a drag operation advertises. Controls which cursor the
|
|
567
|
+
* browser shows and which `dropEffect` the drop target may request.
|
|
568
|
+
*
|
|
569
|
+
* - `'copy'` (default): dragging produces a copy of the data.
|
|
570
|
+
* - `'move'`: dragging removes the source after a drop (the app must do this).
|
|
571
|
+
* - `'link'`: dragging creates a link/reference.
|
|
572
|
+
* - `'copyMove'` / `'copyLink'` / `'linkMove'` / `'all'`: combinations.
|
|
573
|
+
* - `'none'`: the drag is not droppable anywhere.
|
|
574
|
+
* - `'uninitialized'`: browser default (same as `'all'` in most cases).
|
|
575
|
+
*/
|
|
576
|
+
export type DragEffectAllowed = 'copy' | 'move' | 'link' | 'copyMove' | 'copyLink' | 'linkMove' | 'all' | 'none' | 'uninitialized';
|
|
577
|
+
/** What is put into `DataTransfer` when a drag starts. */
|
|
578
|
+
export interface DragCopyItem {
|
|
579
|
+
readonly mimeType: string;
|
|
580
|
+
readonly data: string;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* A multi-format drag payload — strings only (DataTransfer only accepts strings).
|
|
584
|
+
* Mirrors `SyncCopyPayload` from copy-interceptor but scoped to drag.
|
|
585
|
+
*/
|
|
586
|
+
export type DragCopyPayload = TextPayload | HtmlPayload | JsonPayload | DragMultiPayload;
|
|
587
|
+
export interface DragMultiPayload {
|
|
588
|
+
readonly kind: 'multi';
|
|
589
|
+
readonly items: readonly DragCopyItem[];
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* What the source getter returns:
|
|
593
|
+
* - a string: written as `text/plain`.
|
|
594
|
+
* - a `DragCopyPayload`: written according to its `kind`.
|
|
595
|
+
* - `false`: cancels the drag (`preventDefault()` on `dragstart`).
|
|
596
|
+
* - `null` / `undefined`: leaves the browser's default drag data untouched.
|
|
597
|
+
*/
|
|
598
|
+
export type DragCopyDecision = string | DragCopyPayload | false | null | undefined;
|
|
599
|
+
/** Called once when the user begins dragging the element. Must be synchronous. */
|
|
600
|
+
export type DragCopySource = (event: DragStartEventLike) => DragCopyDecision;
|
|
601
|
+
/** Structural `DragEvent`: DOM and React drag events both satisfy it. */
|
|
602
|
+
export interface DragStartEventLike {
|
|
603
|
+
readonly type: string;
|
|
604
|
+
readonly dataTransfer: DataTransferLike$1 | null;
|
|
605
|
+
readonly defaultPrevented: boolean;
|
|
606
|
+
preventDefault(): void;
|
|
607
|
+
}
|
|
608
|
+
/** The writable face of `DataTransfer`. */
|
|
609
|
+
interface DataTransferLike$1 {
|
|
610
|
+
effectAllowed: string;
|
|
611
|
+
setData(format: string, data: string): void;
|
|
612
|
+
clearData?(format?: string): void;
|
|
613
|
+
}
|
|
614
|
+
export type DragCopyStatus =
|
|
615
|
+
/** No drag has started yet, or it was cancelled / never had source data. */
|
|
616
|
+
'idle' |
|
|
617
|
+
/** The element is being dragged and data is on the DataTransfer. */
|
|
618
|
+
'dragging' |
|
|
619
|
+
/** The drag ended (dropped or abandoned). */
|
|
620
|
+
'done';
|
|
621
|
+
export type DragCopyPassReason =
|
|
622
|
+
/** Source returned `null`/`undefined`. */
|
|
623
|
+
'declined' |
|
|
624
|
+
/** `DataTransfer` is not present on this event. */
|
|
625
|
+
'no-transfer' |
|
|
626
|
+
/** Source returned `false`. */
|
|
627
|
+
'cancelled';
|
|
628
|
+
export type DragCopyOutcome = {
|
|
629
|
+
readonly status: 'written';
|
|
630
|
+
readonly payload: DragCopyPayload;
|
|
631
|
+
} | {
|
|
632
|
+
readonly status: 'passed';
|
|
633
|
+
readonly reason: DragCopyPassReason;
|
|
634
|
+
} | {
|
|
635
|
+
readonly status: 'failed';
|
|
636
|
+
readonly error: CopyError;
|
|
637
|
+
};
|
|
638
|
+
export interface DragCopyState {
|
|
639
|
+
readonly status: DragCopyStatus;
|
|
640
|
+
/** The last `dragstart` outcome; `null` before the first drag. */
|
|
641
|
+
readonly outcome: DragCopyOutcome | null;
|
|
642
|
+
}
|
|
643
|
+
export interface DragCopyOptions {
|
|
644
|
+
/**
|
|
645
|
+
* Returns the data to put in the drag. Called synchronously on `dragstart`.
|
|
646
|
+
* Return a string (shorthand for `{ kind: 'text' }`), a payload object,
|
|
647
|
+
* `false` to cancel the drag, or `null`/`undefined` to pass through.
|
|
648
|
+
*/
|
|
649
|
+
readonly source: DragCopySource;
|
|
650
|
+
/**
|
|
651
|
+
* `effectAllowed` advertised on the drag. Default `'copy'`.
|
|
652
|
+
* Setting `'move'` signals to drop targets that the source will be removed.
|
|
653
|
+
*/
|
|
654
|
+
readonly effectAllowed?: DragEffectAllowed;
|
|
655
|
+
/**
|
|
656
|
+
* Called each time a drag starts or ends, with the latest outcome and status.
|
|
657
|
+
* Stable across re-renders when written as a class method or via `useRef`.
|
|
658
|
+
*/
|
|
659
|
+
readonly onDrag?: (state: DragCopyState) => void;
|
|
660
|
+
/** Called when preparing the drag payload fails. */
|
|
661
|
+
readonly onError?: (error: CopyError) => void;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Populates a `dragstart` event's `DataTransfer` with the given payload.
|
|
665
|
+
* Use this from a raw `dragstart` handler or a React `onDragStart` prop.
|
|
666
|
+
* Returns the outcome so you can inspect what happened.
|
|
667
|
+
*/
|
|
668
|
+
export declare function applyDragCopy(event: DragStartEventLike, options: DragCopyOptions): DragCopyOutcome;
|
|
669
|
+
export interface RegisterDragCopyResult {
|
|
670
|
+
/** Unsubscribes all listeners. Idempotent. */
|
|
671
|
+
readonly unsubscribe: () => void;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Attaches `dragstart` and `dragend` listeners to `element`, calling
|
|
675
|
+
* `applyDragCopy` on every drag start. Returns an object with an
|
|
676
|
+
* `unsubscribe` function.
|
|
677
|
+
*
|
|
678
|
+
* Pass an options getter so the latest options are always used without
|
|
679
|
+
* re-registering — safe to pass an inline object from a React render.
|
|
680
|
+
*
|
|
681
|
+
* ```ts
|
|
682
|
+
* const { unsubscribe } = registerDragCopy(el, () => ({
|
|
683
|
+
* source: () => `${title}\n${url}`,
|
|
684
|
+
* }));
|
|
685
|
+
* ```
|
|
686
|
+
*/
|
|
687
|
+
export declare function registerDragCopy(element: HTMLElement, options: DragCopyOptions | (() => DragCopyOptions)): RegisterDragCopyResult;
|
|
688
|
+
//#endregion
|
|
564
689
|
//#region src/core/paste-adapter.d.ts
|
|
565
690
|
/** Minimal structural view of `navigator.clipboard` for reading. */
|
|
566
691
|
interface PasteClipboardLike {
|
|
@@ -1137,5 +1262,49 @@ export declare const PasteField: {
|
|
|
1137
1262
|
readonly Preview: import("react").ForwardRefExoticComponent<PasteFieldPreviewProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
1138
1263
|
};
|
|
1139
1264
|
//#endregion
|
|
1140
|
-
|
|
1265
|
+
//#region src/react/useDragCopy.d.ts
|
|
1266
|
+
interface UseDragCopyOptions extends Omit<DragCopyOptions, 'onDrag'> {
|
|
1267
|
+
/**
|
|
1268
|
+
* Set `false` to disable drag without unmounting. Removes the `draggable`
|
|
1269
|
+
* attribute and listener while `false`. Default `true`.
|
|
1270
|
+
*/
|
|
1271
|
+
readonly enabled?: boolean;
|
|
1272
|
+
/** Called each time a drag starts or ends. */
|
|
1273
|
+
readonly onDrag?: (state: DragCopyState) => void;
|
|
1274
|
+
}
|
|
1275
|
+
interface UseDragCopyResult<T extends HTMLElement = HTMLElement> {
|
|
1276
|
+
/**
|
|
1277
|
+
* Attach to any element you want to make draggable. The hook sets
|
|
1278
|
+
* `draggable="true"` automatically while `enabled` is `true`.
|
|
1279
|
+
*/
|
|
1280
|
+
readonly ref: RefCallback<T>;
|
|
1281
|
+
/** `'idle' | 'dragging' | 'done'` — the current drag status. */
|
|
1282
|
+
readonly status: DragCopyStatus;
|
|
1283
|
+
/** The last `dragstart` outcome; `null` before the first drag. */
|
|
1284
|
+
readonly outcome: DragCopyOutcome | null;
|
|
1285
|
+
/**
|
|
1286
|
+
* For use in React's `onDragStart` prop if you need to wire it imperatively
|
|
1287
|
+
* (e.g. inside a render-prop component). The `ref` alone is sufficient for
|
|
1288
|
+
* native HTML elements: the hook attaches its own listener.
|
|
1289
|
+
*/
|
|
1290
|
+
readonly onDragStart: (event: DragStartEventLike) => void;
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* Makes an element draggable and populates its `DataTransfer` with your data.
|
|
1294
|
+
*
|
|
1295
|
+
* ```tsx
|
|
1296
|
+
* const { ref } = useDragCopy({
|
|
1297
|
+
* source: () => ({ kind: 'html', html: '<b>Hello</b>', text: 'Hello' }),
|
|
1298
|
+
* });
|
|
1299
|
+
* return <div ref={ref}>Drag me</div>;
|
|
1300
|
+
* ```
|
|
1301
|
+
*
|
|
1302
|
+
* - No Clipboard API needed — works in every browser supporting HTML5 drag-and-drop.
|
|
1303
|
+
* - The `source` callback always reads the latest props/state, never stale closures.
|
|
1304
|
+
* - `enabled={false}` removes `draggable` and the listener without unmounting.
|
|
1305
|
+
* - SSR-safe: no DOM access during server rendering.
|
|
1306
|
+
*/
|
|
1307
|
+
export declare function useDragCopy<T extends HTMLElement = HTMLElement>(options: UseDragCopyOptions): UseDragCopyResult<T>;
|
|
1308
|
+
//#endregion
|
|
1309
|
+
export type { BrowserPasteAdapterOptions, ClipboardItemLike, CopyFieldContextValue, CopyFieldLabelProps, CopyFieldMessages, CopyFieldRootProps, CopyFieldTriggerProps, CopyFieldTriggerRenderProps, CopyFieldValueProps, CopyGroupProps, DataTransferItemLike, LiveRegionProps, OperationContext, PasteAccept, PasteAcceptShorthand, PasteAdapter, PasteClipboardLike, PasteDropTargetProps, PasteEnvironment, PasteFieldContextValue, PasteFieldLabelProps, PasteFieldMessages, PasteFieldPreviewProps, PasteFieldPreviewRenderProps, PasteFieldRootProps, PasteFieldStatusProps, PasteFieldTriggerProps, PasteFieldTriggerRenderProps, PasteFieldZoneProps, PasteItem, PasteLimits, PasteReadOptions, PasteReadResult, PasteResult, PasteSource, PasteTargetProps, ResolvedPasteReadOptions, RevealReason, RevealTargetProps, UseCopyInterceptorOptions, UseCopyInterceptorResult, UseCopyOptions, UseCopyResult, UseDisplayStatusOptions, UseDragCopyOptions, UseDragCopyResult, UsePasteDisplayStatusOptions, UsePasteOptions, UsePasteResult, UseRevealOnInteractionOptions, UseRevealOnInteractionResult };
|
|
1141
1310
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ interface DataTransferItemLike {
|
|
|
73
73
|
readonly type: string;
|
|
74
74
|
}
|
|
75
75
|
/** Structural view of `DataTransfer` (paste and drop events). */
|
|
76
|
-
interface DataTransferLike {
|
|
76
|
+
export interface DataTransferLike {
|
|
77
77
|
readonly types: ArrayLike<string>;
|
|
78
78
|
getData(format: string): string;
|
|
79
79
|
readonly files?: ArrayLike<File> | null;
|
|
@@ -561,6 +561,131 @@ export interface CopyInterceptorOptions extends CopyInterceptOptions {
|
|
|
561
561
|
*/
|
|
562
562
|
export declare function registerCopyInterceptor(root: Element, options: CopyInterceptorOptions | (() => CopyInterceptorOptions)): () => void;
|
|
563
563
|
//#endregion
|
|
564
|
+
//#region src/core/drag-copy.d.ts
|
|
565
|
+
/**
|
|
566
|
+
* The `effectAllowed` a drag operation advertises. Controls which cursor the
|
|
567
|
+
* browser shows and which `dropEffect` the drop target may request.
|
|
568
|
+
*
|
|
569
|
+
* - `'copy'` (default): dragging produces a copy of the data.
|
|
570
|
+
* - `'move'`: dragging removes the source after a drop (the app must do this).
|
|
571
|
+
* - `'link'`: dragging creates a link/reference.
|
|
572
|
+
* - `'copyMove'` / `'copyLink'` / `'linkMove'` / `'all'`: combinations.
|
|
573
|
+
* - `'none'`: the drag is not droppable anywhere.
|
|
574
|
+
* - `'uninitialized'`: browser default (same as `'all'` in most cases).
|
|
575
|
+
*/
|
|
576
|
+
export type DragEffectAllowed = 'copy' | 'move' | 'link' | 'copyMove' | 'copyLink' | 'linkMove' | 'all' | 'none' | 'uninitialized';
|
|
577
|
+
/** What is put into `DataTransfer` when a drag starts. */
|
|
578
|
+
export interface DragCopyItem {
|
|
579
|
+
readonly mimeType: string;
|
|
580
|
+
readonly data: string;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* A multi-format drag payload — strings only (DataTransfer only accepts strings).
|
|
584
|
+
* Mirrors `SyncCopyPayload` from copy-interceptor but scoped to drag.
|
|
585
|
+
*/
|
|
586
|
+
export type DragCopyPayload = TextPayload | HtmlPayload | JsonPayload | DragMultiPayload;
|
|
587
|
+
export interface DragMultiPayload {
|
|
588
|
+
readonly kind: 'multi';
|
|
589
|
+
readonly items: readonly DragCopyItem[];
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* What the source getter returns:
|
|
593
|
+
* - a string: written as `text/plain`.
|
|
594
|
+
* - a `DragCopyPayload`: written according to its `kind`.
|
|
595
|
+
* - `false`: cancels the drag (`preventDefault()` on `dragstart`).
|
|
596
|
+
* - `null` / `undefined`: leaves the browser's default drag data untouched.
|
|
597
|
+
*/
|
|
598
|
+
export type DragCopyDecision = string | DragCopyPayload | false | null | undefined;
|
|
599
|
+
/** Called once when the user begins dragging the element. Must be synchronous. */
|
|
600
|
+
export type DragCopySource = (event: DragStartEventLike) => DragCopyDecision;
|
|
601
|
+
/** Structural `DragEvent`: DOM and React drag events both satisfy it. */
|
|
602
|
+
export interface DragStartEventLike {
|
|
603
|
+
readonly type: string;
|
|
604
|
+
readonly dataTransfer: DataTransferLike$1 | null;
|
|
605
|
+
readonly defaultPrevented: boolean;
|
|
606
|
+
preventDefault(): void;
|
|
607
|
+
}
|
|
608
|
+
/** The writable face of `DataTransfer`. */
|
|
609
|
+
interface DataTransferLike$1 {
|
|
610
|
+
effectAllowed: string;
|
|
611
|
+
setData(format: string, data: string): void;
|
|
612
|
+
clearData?(format?: string): void;
|
|
613
|
+
}
|
|
614
|
+
export type DragCopyStatus =
|
|
615
|
+
/** No drag has started yet, or it was cancelled / never had source data. */
|
|
616
|
+
'idle' |
|
|
617
|
+
/** The element is being dragged and data is on the DataTransfer. */
|
|
618
|
+
'dragging' |
|
|
619
|
+
/** The drag ended (dropped or abandoned). */
|
|
620
|
+
'done';
|
|
621
|
+
export type DragCopyPassReason =
|
|
622
|
+
/** Source returned `null`/`undefined`. */
|
|
623
|
+
'declined' |
|
|
624
|
+
/** `DataTransfer` is not present on this event. */
|
|
625
|
+
'no-transfer' |
|
|
626
|
+
/** Source returned `false`. */
|
|
627
|
+
'cancelled';
|
|
628
|
+
export type DragCopyOutcome = {
|
|
629
|
+
readonly status: 'written';
|
|
630
|
+
readonly payload: DragCopyPayload;
|
|
631
|
+
} | {
|
|
632
|
+
readonly status: 'passed';
|
|
633
|
+
readonly reason: DragCopyPassReason;
|
|
634
|
+
} | {
|
|
635
|
+
readonly status: 'failed';
|
|
636
|
+
readonly error: CopyError;
|
|
637
|
+
};
|
|
638
|
+
export interface DragCopyState {
|
|
639
|
+
readonly status: DragCopyStatus;
|
|
640
|
+
/** The last `dragstart` outcome; `null` before the first drag. */
|
|
641
|
+
readonly outcome: DragCopyOutcome | null;
|
|
642
|
+
}
|
|
643
|
+
export interface DragCopyOptions {
|
|
644
|
+
/**
|
|
645
|
+
* Returns the data to put in the drag. Called synchronously on `dragstart`.
|
|
646
|
+
* Return a string (shorthand for `{ kind: 'text' }`), a payload object,
|
|
647
|
+
* `false` to cancel the drag, or `null`/`undefined` to pass through.
|
|
648
|
+
*/
|
|
649
|
+
readonly source: DragCopySource;
|
|
650
|
+
/**
|
|
651
|
+
* `effectAllowed` advertised on the drag. Default `'copy'`.
|
|
652
|
+
* Setting `'move'` signals to drop targets that the source will be removed.
|
|
653
|
+
*/
|
|
654
|
+
readonly effectAllowed?: DragEffectAllowed;
|
|
655
|
+
/**
|
|
656
|
+
* Called each time a drag starts or ends, with the latest outcome and status.
|
|
657
|
+
* Stable across re-renders when written as a class method or via `useRef`.
|
|
658
|
+
*/
|
|
659
|
+
readonly onDrag?: (state: DragCopyState) => void;
|
|
660
|
+
/** Called when preparing the drag payload fails. */
|
|
661
|
+
readonly onError?: (error: CopyError) => void;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Populates a `dragstart` event's `DataTransfer` with the given payload.
|
|
665
|
+
* Use this from a raw `dragstart` handler or a React `onDragStart` prop.
|
|
666
|
+
* Returns the outcome so you can inspect what happened.
|
|
667
|
+
*/
|
|
668
|
+
export declare function applyDragCopy(event: DragStartEventLike, options: DragCopyOptions): DragCopyOutcome;
|
|
669
|
+
export interface RegisterDragCopyResult {
|
|
670
|
+
/** Unsubscribes all listeners. Idempotent. */
|
|
671
|
+
readonly unsubscribe: () => void;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Attaches `dragstart` and `dragend` listeners to `element`, calling
|
|
675
|
+
* `applyDragCopy` on every drag start. Returns an object with an
|
|
676
|
+
* `unsubscribe` function.
|
|
677
|
+
*
|
|
678
|
+
* Pass an options getter so the latest options are always used without
|
|
679
|
+
* re-registering — safe to pass an inline object from a React render.
|
|
680
|
+
*
|
|
681
|
+
* ```ts
|
|
682
|
+
* const { unsubscribe } = registerDragCopy(el, () => ({
|
|
683
|
+
* source: () => `${title}\n${url}`,
|
|
684
|
+
* }));
|
|
685
|
+
* ```
|
|
686
|
+
*/
|
|
687
|
+
export declare function registerDragCopy(element: HTMLElement, options: DragCopyOptions | (() => DragCopyOptions)): RegisterDragCopyResult;
|
|
688
|
+
//#endregion
|
|
564
689
|
//#region src/core/paste-adapter.d.ts
|
|
565
690
|
/** Minimal structural view of `navigator.clipboard` for reading. */
|
|
566
691
|
interface PasteClipboardLike {
|
|
@@ -1137,5 +1262,49 @@ export declare const PasteField: {
|
|
|
1137
1262
|
readonly Preview: import("react").ForwardRefExoticComponent<PasteFieldPreviewProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
1138
1263
|
};
|
|
1139
1264
|
//#endregion
|
|
1140
|
-
|
|
1265
|
+
//#region src/react/useDragCopy.d.ts
|
|
1266
|
+
interface UseDragCopyOptions extends Omit<DragCopyOptions, 'onDrag'> {
|
|
1267
|
+
/**
|
|
1268
|
+
* Set `false` to disable drag without unmounting. Removes the `draggable`
|
|
1269
|
+
* attribute and listener while `false`. Default `true`.
|
|
1270
|
+
*/
|
|
1271
|
+
readonly enabled?: boolean;
|
|
1272
|
+
/** Called each time a drag starts or ends. */
|
|
1273
|
+
readonly onDrag?: (state: DragCopyState) => void;
|
|
1274
|
+
}
|
|
1275
|
+
interface UseDragCopyResult<T extends HTMLElement = HTMLElement> {
|
|
1276
|
+
/**
|
|
1277
|
+
* Attach to any element you want to make draggable. The hook sets
|
|
1278
|
+
* `draggable="true"` automatically while `enabled` is `true`.
|
|
1279
|
+
*/
|
|
1280
|
+
readonly ref: RefCallback<T>;
|
|
1281
|
+
/** `'idle' | 'dragging' | 'done'` — the current drag status. */
|
|
1282
|
+
readonly status: DragCopyStatus;
|
|
1283
|
+
/** The last `dragstart` outcome; `null` before the first drag. */
|
|
1284
|
+
readonly outcome: DragCopyOutcome | null;
|
|
1285
|
+
/**
|
|
1286
|
+
* For use in React's `onDragStart` prop if you need to wire it imperatively
|
|
1287
|
+
* (e.g. inside a render-prop component). The `ref` alone is sufficient for
|
|
1288
|
+
* native HTML elements: the hook attaches its own listener.
|
|
1289
|
+
*/
|
|
1290
|
+
readonly onDragStart: (event: DragStartEventLike) => void;
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* Makes an element draggable and populates its `DataTransfer` with your data.
|
|
1294
|
+
*
|
|
1295
|
+
* ```tsx
|
|
1296
|
+
* const { ref } = useDragCopy({
|
|
1297
|
+
* source: () => ({ kind: 'html', html: '<b>Hello</b>', text: 'Hello' }),
|
|
1298
|
+
* });
|
|
1299
|
+
* return <div ref={ref}>Drag me</div>;
|
|
1300
|
+
* ```
|
|
1301
|
+
*
|
|
1302
|
+
* - No Clipboard API needed — works in every browser supporting HTML5 drag-and-drop.
|
|
1303
|
+
* - The `source` callback always reads the latest props/state, never stale closures.
|
|
1304
|
+
* - `enabled={false}` removes `draggable` and the listener without unmounting.
|
|
1305
|
+
* - SSR-safe: no DOM access during server rendering.
|
|
1306
|
+
*/
|
|
1307
|
+
export declare function useDragCopy<T extends HTMLElement = HTMLElement>(options: UseDragCopyOptions): UseDragCopyResult<T>;
|
|
1308
|
+
//#endregion
|
|
1309
|
+
export type { BrowserPasteAdapterOptions, ClipboardItemLike, CopyFieldContextValue, CopyFieldLabelProps, CopyFieldMessages, CopyFieldRootProps, CopyFieldTriggerProps, CopyFieldTriggerRenderProps, CopyFieldValueProps, CopyGroupProps, DataTransferItemLike, LiveRegionProps, OperationContext, PasteAccept, PasteAcceptShorthand, PasteAdapter, PasteClipboardLike, PasteDropTargetProps, PasteEnvironment, PasteFieldContextValue, PasteFieldLabelProps, PasteFieldMessages, PasteFieldPreviewProps, PasteFieldPreviewRenderProps, PasteFieldRootProps, PasteFieldStatusProps, PasteFieldTriggerProps, PasteFieldTriggerRenderProps, PasteFieldZoneProps, PasteItem, PasteLimits, PasteReadOptions, PasteReadResult, PasteResult, PasteSource, PasteTargetProps, ResolvedPasteReadOptions, RevealReason, RevealTargetProps, UseCopyInterceptorOptions, UseCopyInterceptorResult, UseCopyOptions, UseCopyResult, UseDisplayStatusOptions, UseDragCopyOptions, UseDragCopyResult, UsePasteDisplayStatusOptions, UsePasteOptions, UsePasteResult, UseRevealOnInteractionOptions, UseRevealOnInteractionResult };
|
|
1141
1310
|
//# sourceMappingURL=index.d.ts.map
|