@glodon-aiot/react-components
Version:
aiot react components
45 lines (44 loc) • 1.13 kB
JavaScript
import { jsx as o } from "react/jsx-runtime";
import { useState as r, useEffect as c } from "react";
import { Iconfont as l } from "../../Iconfont/index.mjs";
import { copyToClipboard as m } from "../../utils/clipboard.mjs";
import "./style.less.mjs";
import { CheckOutlined as p, CloseOutlined as n } from "@ant-design/icons";
import { Tooltip as f } from "antd";
const b = ({
text: i
}) => {
const [e, t] = r();
return c(() => {
e && setTimeout(() => t(void 0), 2e3);
}, [e]), e ? /* @__PURE__ */ o("div", {
className: "copy-tip",
children: e === "success" ? /* @__PURE__ */ o(p, {
style: {
color: "rgba(48, 191, 19, 1)"
}
}) : /* @__PURE__ */ o(n, {
style: {
color: "#dc4446"
}
})
}) : /* @__PURE__ */ o(f, {
title: "复制",
children: /* @__PURE__ */ o("div", {
className: "copy-btn",
onClick: () => {
m({
value: i
}).then((s) => {
t(s ? "success" : "failed");
});
},
children: /* @__PURE__ */ o(l, {
type: "icon-fuzhi"
})
})
});
};
export {
b as Copy
};