mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Update type definitions for "react-copy-to-clipboard" (#38565)
* add required property children to Props * name function arguments for onCopy * put required props before optional * make all Options attributes optional and add format * extend and add tests * indicate lib version for these types and add contributor
This commit is contained in:
parent
a618db32ef
commit
9ae12bafb1
11
types/react-copy-to-clipboard/index.d.ts
vendored
11
types/react-copy-to-clipboard/index.d.ts
vendored
@ -1,7 +1,8 @@
|
||||
// Type definitions for react-copy-to-clipboard 4.2
|
||||
// Type definitions for react-copy-to-clipboard 4.3
|
||||
// Project: https://github.com/nkbt/react-copy-to-clipboard
|
||||
// Definitions by: Meno Abels <https://github.com/mabels>
|
||||
// Bernabe <https://github.com/BernabeFelix>
|
||||
// Ward Delabastita <https://github.com/wdlb>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@ -13,13 +14,15 @@ export = CopyToClipboard;
|
||||
|
||||
declare namespace CopyToClipboard {
|
||||
interface Options {
|
||||
debug: boolean;
|
||||
message: string;
|
||||
debug?: boolean;
|
||||
format?: "text/html" | "text/plain";
|
||||
message?: string;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
children: React.ReactNode;
|
||||
text: string;
|
||||
onCopy?(a: string, b: boolean): void;
|
||||
onCopy?(text: string, result: boolean): void;
|
||||
options?: Options;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,22 @@
|
||||
import * as React from "react";
|
||||
import CopyToClipboard = require("react-copy-to-clipboard");
|
||||
|
||||
export class Test extends React.Component {
|
||||
export class OnlyRequiredProps extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<CopyToClipboard text={"Hello World"}>
|
||||
<button>Copy to clipboard with button</button>
|
||||
</CopyToClipboard>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class AllProps extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<CopyToClipboard text={"Hello World"}
|
||||
onCopy={() => {}}>
|
||||
onCopy={() => {}}
|
||||
options={{debug: true, message: "message", format: "text/plain"}}>
|
||||
<span>Copy to clipboard with span</span>
|
||||
</CopyToClipboard>
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user