@cloudtower/eagle 0.35.8 → 0.35.9

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.
@@ -0,0 +1,34 @@
1
+ import Button from '../../core/Button/index.js';
2
+ import useParrotTranslation from '../../hooks/useParrotTranslation.js';
3
+ import React__default, { useState } from 'react';
4
+ import CopyTooltip from './CopyTooltip.js';
5
+
6
+ const CopyButton = ({
7
+ text,
8
+ buttonText,
9
+ tooltipText
10
+ }) => {
11
+ const { t } = useParrotTranslation();
12
+ const [tooltipVisible, setTooltipVisible] = useState(false);
13
+ const handleCopy = async () => {
14
+ try {
15
+ setTooltipVisible(true);
16
+ setTimeout(() => {
17
+ setTooltipVisible(false);
18
+ }, 1e3);
19
+ } catch (err) {
20
+ }
21
+ };
22
+ return /* @__PURE__ */ React__default.createElement(
23
+ CopyTooltip,
24
+ {
25
+ tooltipProps: { visible: tooltipVisible },
26
+ text,
27
+ afterTooltip: tooltipText ? tooltipText : t("common.has_copied_to_clipboard")
28
+ },
29
+ /* @__PURE__ */ React__default.createElement(Button, { onClick: handleCopy }, buttonText ? buttonText : t("common.copy"))
30
+ );
31
+ };
32
+ var CopyButton$1 = CopyButton;
33
+
34
+ export { CopyButton$1 as default };
@@ -0,0 +1,59 @@
1
+ import { ClipboardCopy16GradientGrayIcon } from '@cloudtower/icons-react';
2
+ import Icon from '../../core/Icon/index.js';
3
+ import Tooltip from '../../core/Tooltip/index.js';
4
+ import useParrotTranslation from '../../hooks/useParrotTranslation.js';
5
+ import React__default, { useState } from 'react';
6
+ import CopyToClipboard from 'react-copy-to-clipboard';
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __defProps = Object.defineProperties;
10
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
11
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
14
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
+ var __spreadValues = (a, b) => {
16
+ for (var prop in b || (b = {}))
17
+ if (__hasOwnProp.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ if (__getOwnPropSymbols)
20
+ for (var prop of __getOwnPropSymbols(b)) {
21
+ if (__propIsEnum.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
23
+ }
24
+ return a;
25
+ };
26
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
+ const CopyTooltip = React__default.forwardRef(
28
+ (props, ref) => {
29
+ const { t } = useParrotTranslation();
30
+ const {
31
+ text,
32
+ beforeTooltip = t("common.click_to_copy"),
33
+ afterTooltip = t("common.copy_done"),
34
+ children = /* @__PURE__ */ React__default.createElement(Icon, { src: ClipboardCopy16GradientGrayIcon }),
35
+ tooltipProps,
36
+ className
37
+ } = props;
38
+ const [tooltipText, setTooltipText] = useState(beforeTooltip);
39
+ return /* @__PURE__ */ React__default.createElement(
40
+ "span",
41
+ {
42
+ ref,
43
+ onMouseEnter: () => setTooltipText(beforeTooltip),
44
+ className
45
+ },
46
+ /* @__PURE__ */ React__default.createElement(Tooltip, __spreadProps(__spreadValues({}, tooltipProps), { title: tooltipText }), /* @__PURE__ */ React__default.createElement(
47
+ CopyToClipboard,
48
+ {
49
+ text,
50
+ onCopy: () => setTooltipText(afterTooltip)
51
+ },
52
+ children
53
+ ))
54
+ );
55
+ }
56
+ );
57
+ var CopyTooltip$1 = CopyTooltip;
58
+
59
+ export { CopyTooltip$1 as default };
package/dist/esm/index.js CHANGED
@@ -132,6 +132,8 @@ export { default as BarChart, getWidth } from './coreX/BarChart/index.js';
132
132
  export { default as BatchOperation, renderBatchOperationMenuItem } from './coreX/BatchOperation/index.js';
133
133
  export { default as ChartWithTooltip, ChartWithUnit } from './coreX/ChartWithTooltip/index.js';
134
134
  export { default as CircleLoading } from './coreX/CircleLoading/index.js';
135
+ export { default as CopyButton } from './coreX/Copy/CopyButton.js';
136
+ export { default as CopyTooltip } from './coreX/Copy/CopyTooltip.js';
135
137
  export { default as Counting } from './coreX/Counting/index.js';
136
138
  export { default as CronCalendar } from './coreX/CronCalendar/index.js';
137
139
  export { default as CronPlan, stringifyPlan } from './coreX/CronPlan/index.js';