@ichaingo/copy-button 1.4.10 → 1.4.12
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/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -11
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
interface CopyButtonProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
2
2
|
content: string;
|
|
3
|
-
|
|
3
|
+
iconClassName?: string;
|
|
4
|
+
}
|
|
5
|
+
declare const CopyButton: ({ content, className, iconClassName }: CopyButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
6
|
export default CopyButton;
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAIA,UAAU,eAAgB,SAAQ,KAAK,CAAC,cAAc,CAAC,eAAe,CAAC;IACnE,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AACD,QAAA,MAAM,UAAU,GAAI,uCAAyD,eAAe,4CAqB3F,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as e } from "react/jsx-runtime";
|
|
3
|
-
import { useState as
|
|
4
|
-
import { Check as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { useState as n } from "react";
|
|
4
|
+
import { Check as l, Copy as p } from "lucide-react";
|
|
5
|
+
import { twMerge as m } from "tailwind-merge";
|
|
6
|
+
const d = ({ content: r, className: s, iconClassName: t = "text-subtitle" }) => {
|
|
7
|
+
const [a, o] = n(!1), i = async () => {
|
|
8
8
|
try {
|
|
9
|
-
await navigator.clipboard.writeText(
|
|
10
|
-
|
|
9
|
+
await navigator.clipboard.writeText(r), o(!0), setTimeout(() => {
|
|
10
|
+
o(!1);
|
|
11
11
|
}, 1e3);
|
|
12
|
-
} catch (
|
|
13
|
-
console.error("复制失败:",
|
|
12
|
+
} catch (c) {
|
|
13
|
+
console.error("复制失败:", c);
|
|
14
14
|
}
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
|
+
return /* @__PURE__ */ e("span", { className: m("inline-block w-4 cursor-pointer", s), onClick: i, children: a ? /* @__PURE__ */ e(l, { size: 16, className: t }) : /* @__PURE__ */ e(p, { size: 16, className: t }) });
|
|
16
17
|
};
|
|
17
18
|
export {
|
|
18
|
-
|
|
19
|
+
d as default
|
|
19
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ichaingo/copy-button",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"lucide-react": "^0.490.0"
|
|
17
|
+
"lucide-react": "^0.490.0",
|
|
18
|
+
"tailwind-merge": "^2.5.5"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"rollup-plugin-preserve-use-client": "^3.0.1"
|