Skip to content

Commit

Permalink
fix: typings for usePasteUpload hook (#750)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavniran authored Sep 20, 2024
1 parent d97c789 commit f956c10
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/ui/upload-paste/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export interface PasteProps extends UploadOptions, PasteCompProps {}
export type PasteUploadHookResult = { toggle: () => boolean, getIsEnabled: () => boolean};

export const usePasteUpload: (
uploadOptions: UploadOptions,
element: React.RefObject<HTMLHtmlElement>,
onPasteUpload: PasteUploadHandler
uploadOptions?: UploadOptions | null | undefined,
element?: React.RefObject<HTMLHtmlElement> | null | undefined,
onPasteUpload?: PasteUploadHandler
) => PasteUploadHookResult;

export const withPasteUpload: <T>(component: React.ForwardRefExoticComponent<T> | React.ComponentType<T>) => React.FC<PasteProps>;
Expand Down
26 changes: 26 additions & 0 deletions packages/ui/upload-paste/types/index.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,33 @@ const TestPasteUpload: React.FC = () => {
</>;
};

const TestWindowPasteUpload: React.FC = () => {
const { toggle, getIsEnabled } = usePasteUpload();

return (
<div>
paste anywhere on this page
<button onClick={toggle}>Toggle Paste</button>
enabled: {getIsEnabled()}
</div>
);
};

const TestWithJustOptions: React.FC = () => {
const { toggle, getIsEnabled } = usePasteUpload({ autoUpload: false });

return (
<div>
paste anywhere on this page
<button onClick={toggle}>Toggle Paste</button>
enabled: {getIsEnabled()}
</div>
);
};

export {
TestWithPasteUpload,
TestPasteUpload,
TestWindowPasteUpload,
TestWithJustOptions,
};

0 comments on commit f956c10

Please sign in to comment.