@cloud-ru/uikit-product-copy-line 0.7.63 → 0.7.65
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/CHANGELOG.md +21 -0
- package/dist/cjs/components/CopyButton/CopyButton.d.ts +8 -0
- package/dist/cjs/components/CopyButton/CopyButton.js +39 -0
- package/dist/cjs/components/CopyButton/index.d.ts +1 -0
- package/dist/cjs/components/CopyButton/index.js +17 -0
- package/dist/cjs/components/CopyLine/CopyLine.d.ts +11 -0
- package/dist/cjs/components/CopyLine/CopyLine.js +49 -0
- package/dist/cjs/components/CopyLine/constants.d.ts +4 -0
- package/dist/cjs/components/CopyLine/constants.js +7 -0
- package/dist/cjs/components/CopyLine/index.d.ts +1 -0
- package/dist/cjs/components/CopyLine/index.js +17 -0
- package/dist/cjs/components/CopyLine/styles.module.css +24 -0
- package/dist/cjs/components/CopyLine/types.d.ts +3 -0
- package/dist/cjs/components/CopyLine/types.js +2 -0
- package/dist/cjs/components/CopyLine/utils.d.ts +2 -0
- package/dist/cjs/components/CopyLine/utils.js +6 -0
- package/dist/cjs/components/index.d.ts +2 -0
- package/dist/cjs/components/index.js +18 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +17 -0
- package/dist/esm/components/CopyButton/CopyButton.d.ts +8 -0
- package/dist/esm/components/CopyButton/CopyButton.js +36 -0
- package/dist/esm/components/CopyButton/index.d.ts +1 -0
- package/dist/esm/components/CopyButton/index.js +1 -0
- package/dist/esm/components/CopyLine/CopyLine.d.ts +11 -0
- package/dist/esm/components/CopyLine/CopyLine.js +43 -0
- package/dist/esm/components/CopyLine/constants.d.ts +4 -0
- package/dist/esm/components/CopyLine/constants.js +4 -0
- package/dist/esm/components/CopyLine/index.d.ts +1 -0
- package/dist/esm/components/CopyLine/index.js +1 -0
- package/dist/esm/components/CopyLine/styles.module.css +24 -0
- package/dist/esm/components/CopyLine/types.d.ts +3 -0
- package/dist/esm/components/CopyLine/types.js +1 -0
- package/dist/esm/components/CopyLine/utils.d.ts +2 -0
- package/dist/esm/components/CopyLine/utils.js +3 -0
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/index.js +2 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 0.7.65 (2025-11-13)
|
|
7
|
+
|
|
8
|
+
### Only dependencies have been changed
|
|
9
|
+
* [@cloud-ru/uikit-product-icons@15.1.3](https://gitverse.ru/cloud-ru-tech/uikit-product/-/blob/master/packages/icons/CHANGELOG.md)
|
|
10
|
+
* [@cloud-ru/uikit-product-utils@7.0.2](https://gitverse.ru/cloud-ru-tech/uikit-product/-/blob/master/packages/utils/CHANGELOG.md)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## 0.7.64 (2025-11-12)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* **PD-3377:** contributors update to publish all packages ([719fd3e](https://gitverse.ru/cloud-ru-tech/uikit-product/commits/719fd3e1249e247443b125c47ea408d92c8395c3))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
6
27
|
## 0.7.63 (2025-11-12)
|
|
7
28
|
|
|
8
29
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WithSupportProps } from '@sbercloud/uikit-product-utils';
|
|
2
|
+
import { ButtonFunctionProps } from '@snack-uikit/button';
|
|
3
|
+
export type CopyButtonProps = WithSupportProps<{
|
|
4
|
+
valueToCopy: string | number;
|
|
5
|
+
size?: ButtonFunctionProps['size'];
|
|
6
|
+
className?: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function CopyButton({ valueToCopy, size, className, ...rest }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.CopyButton = CopyButton;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const ft_copy_to_clipboard_1 = require("@cloud-ru/ft-copy-to-clipboard");
|
|
17
|
+
const react_1 = require("react");
|
|
18
|
+
const uikit_product_icons_1 = require("@sbercloud/uikit-product-icons");
|
|
19
|
+
const uikit_product_utils_1 = require("@sbercloud/uikit-product-utils");
|
|
20
|
+
const button_1 = require("@snack-uikit/button");
|
|
21
|
+
function CopyButton(_a) {
|
|
22
|
+
var { valueToCopy, size = 'xs', className } = _a, rest = __rest(_a, ["valueToCopy", "size", "className"]);
|
|
23
|
+
const [isChecked, setIsCheckedOpen] = (0, react_1.useState)(false);
|
|
24
|
+
const timerId = (0, react_1.useRef)();
|
|
25
|
+
const openChecked = () => setIsCheckedOpen(true);
|
|
26
|
+
const closeChecked = () => setIsCheckedOpen(false);
|
|
27
|
+
const handleClick = event => {
|
|
28
|
+
event.stopPropagation();
|
|
29
|
+
valueToCopy && (0, ft_copy_to_clipboard_1.copyToClipboard)(String(valueToCopy));
|
|
30
|
+
openChecked();
|
|
31
|
+
clearTimeout(timerId.current);
|
|
32
|
+
timerId.current = setTimeout(closeChecked, 1000);
|
|
33
|
+
};
|
|
34
|
+
(0, react_1.useEffect)(() => () => {
|
|
35
|
+
closeChecked();
|
|
36
|
+
clearTimeout(timerId.current);
|
|
37
|
+
}, []);
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)(button_1.ButtonFunction, Object.assign({}, (0, uikit_product_utils_1.extractSupportProps)(rest), { onClick: handleClick, className: className, "data-test-id": 'button-copy-value', type: 'button', icon: isChecked ? (0, jsx_runtime_1.jsx)(uikit_product_icons_1.CheckSVG, {}) : (0, jsx_runtime_1.jsx)(uikit_product_icons_1.CopySVG, {}), size: size })));
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CopyButton';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./CopyButton"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
import { WithSupportProps } from '@sbercloud/uikit-product-utils';
|
|
3
|
+
import { CopyButtonHideStrategy } from './types';
|
|
4
|
+
export type CopyLineProps = WithSupportProps<{
|
|
5
|
+
content: ReactNode;
|
|
6
|
+
valueToCopy?: string | number;
|
|
7
|
+
className?: string;
|
|
8
|
+
onClick?: MouseEventHandler;
|
|
9
|
+
copyButtonHideStrategy?: CopyButtonHideStrategy;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function CopyLine({ content, className, valueToCopy: valueToCopyProp, onClick, copyButtonHideStrategy, ...rest }: CopyLineProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.CopyLine = CopyLine;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const ft_copy_to_clipboard_1 = require("@cloud-ru/ft-copy-to-clipboard");
|
|
20
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
21
|
+
const react_1 = require("react");
|
|
22
|
+
const uikit_product_icons_1 = require("@sbercloud/uikit-product-icons");
|
|
23
|
+
const uikit_product_utils_1 = require("@sbercloud/uikit-product-utils");
|
|
24
|
+
const button_1 = require("@snack-uikit/button");
|
|
25
|
+
const truncate_string_1 = require("@snack-uikit/truncate-string");
|
|
26
|
+
const constants_1 = require("./constants");
|
|
27
|
+
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
28
|
+
const utils_1 = require("./utils");
|
|
29
|
+
function CopyLine(_a) {
|
|
30
|
+
var { content, className, valueToCopy: valueToCopyProp, onClick, copyButtonHideStrategy = constants_1.COPY_BUTTON_HIDE_STRATEGY.Hover } = _a, rest = __rest(_a, ["content", "className", "valueToCopy", "onClick", "copyButtonHideStrategy"]);
|
|
31
|
+
const valueToCopy = valueToCopyProp !== null && valueToCopyProp !== void 0 ? valueToCopyProp : ((0, utils_1.isStringOrNumber)(content) ? String(content) : '');
|
|
32
|
+
const [isChecked, setIsCheckedOpen] = (0, react_1.useState)(false);
|
|
33
|
+
const timerId = (0, react_1.useRef)();
|
|
34
|
+
const openChecked = () => setIsCheckedOpen(true);
|
|
35
|
+
const closeChecked = () => setIsCheckedOpen(false);
|
|
36
|
+
const handleClick = event => {
|
|
37
|
+
event.stopPropagation();
|
|
38
|
+
valueToCopy && (0, ft_copy_to_clipboard_1.copyToClipboard)(String(valueToCopy));
|
|
39
|
+
openChecked();
|
|
40
|
+
clearTimeout(timerId.current);
|
|
41
|
+
timerId.current = setTimeout(closeChecked, 1000);
|
|
42
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
43
|
+
};
|
|
44
|
+
(0, react_1.useEffect)(() => () => {
|
|
45
|
+
closeChecked();
|
|
46
|
+
clearTimeout(timerId.current);
|
|
47
|
+
}, []);
|
|
48
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, classnames_1.default)(styles_module_scss_1.default.copyLine, className), onClick: handleClick, role: 'presentation', "data-copy-button-hide-strategy": copyButtonHideStrategy }, (0, uikit_product_utils_1.extractSupportProps)(rest), { children: [(0, utils_1.isStringOrNumber)(content) ? (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: String(content), maxLines: 1 }) : content, (0, jsx_runtime_1.jsx)(button_1.ButtonFunction, { "data-test-id": 'button-copy-value', type: 'button', icon: isChecked ? (0, jsx_runtime_1.jsx)(uikit_product_icons_1.CheckSVG, {}) : (0, jsx_runtime_1.jsx)(uikit_product_icons_1.CopySVG, {}), size: 'xs', className: (0, classnames_1.default)(styles_module_scss_1.default.copyButton, className) })] })));
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CopyLine';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./CopyLine"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.copyLine{
|
|
2
|
+
font-family:var(--sans-body-m-font-family, SB Sans Interface);
|
|
3
|
+
font-weight:var(--sans-body-m-font-weight, Regular);
|
|
4
|
+
line-height:var(--sans-body-m-line-height, 20px);
|
|
5
|
+
font-size:var(--sans-body-m-font-size, 14px);
|
|
6
|
+
letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
|
|
7
|
+
paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
|
|
8
|
+
display:inline-flex;
|
|
9
|
+
flex-shrink:0;
|
|
10
|
+
gap:8px;
|
|
11
|
+
align-items:center;
|
|
12
|
+
cursor:pointer;
|
|
13
|
+
box-sizing:border-box;
|
|
14
|
+
min-width:0;
|
|
15
|
+
max-width:100%;
|
|
16
|
+
min-height:32px;
|
|
17
|
+
color:var(--sys-neutral-text-main, #41424e);
|
|
18
|
+
}
|
|
19
|
+
.copyLine[data-copy-button-hide-strategy=hover] .copyButton{
|
|
20
|
+
display:none;
|
|
21
|
+
}
|
|
22
|
+
.copyLine[data-copy-button-hide-strategy=hover]:hover .copyButton{
|
|
23
|
+
display:inline-flex;
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./CopyButton"), exports);
|
|
18
|
+
__exportStar(require("./CopyLine"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./components"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WithSupportProps } from '@sbercloud/uikit-product-utils';
|
|
2
|
+
import { ButtonFunctionProps } from '@snack-uikit/button';
|
|
3
|
+
export type CopyButtonProps = WithSupportProps<{
|
|
4
|
+
valueToCopy: string | number;
|
|
5
|
+
size?: ButtonFunctionProps['size'];
|
|
6
|
+
className?: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function CopyButton({ valueToCopy, size, className, ...rest }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { copyToClipboard } from '@cloud-ru/ft-copy-to-clipboard';
|
|
14
|
+
import { useEffect, useRef, useState } from 'react';
|
|
15
|
+
import { CheckSVG, CopySVG } from '@sbercloud/uikit-product-icons';
|
|
16
|
+
import { extractSupportProps } from '@sbercloud/uikit-product-utils';
|
|
17
|
+
import { ButtonFunction } from '@snack-uikit/button';
|
|
18
|
+
export function CopyButton(_a) {
|
|
19
|
+
var { valueToCopy, size = 'xs', className } = _a, rest = __rest(_a, ["valueToCopy", "size", "className"]);
|
|
20
|
+
const [isChecked, setIsCheckedOpen] = useState(false);
|
|
21
|
+
const timerId = useRef();
|
|
22
|
+
const openChecked = () => setIsCheckedOpen(true);
|
|
23
|
+
const closeChecked = () => setIsCheckedOpen(false);
|
|
24
|
+
const handleClick = event => {
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
valueToCopy && copyToClipboard(String(valueToCopy));
|
|
27
|
+
openChecked();
|
|
28
|
+
clearTimeout(timerId.current);
|
|
29
|
+
timerId.current = setTimeout(closeChecked, 1000);
|
|
30
|
+
};
|
|
31
|
+
useEffect(() => () => {
|
|
32
|
+
closeChecked();
|
|
33
|
+
clearTimeout(timerId.current);
|
|
34
|
+
}, []);
|
|
35
|
+
return (_jsx(ButtonFunction, Object.assign({}, extractSupportProps(rest), { onClick: handleClick, className: className, "data-test-id": 'button-copy-value', type: 'button', icon: isChecked ? _jsx(CheckSVG, {}) : _jsx(CopySVG, {}), size: size })));
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CopyButton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CopyButton';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
import { WithSupportProps } from '@sbercloud/uikit-product-utils';
|
|
3
|
+
import { CopyButtonHideStrategy } from './types';
|
|
4
|
+
export type CopyLineProps = WithSupportProps<{
|
|
5
|
+
content: ReactNode;
|
|
6
|
+
valueToCopy?: string | number;
|
|
7
|
+
className?: string;
|
|
8
|
+
onClick?: MouseEventHandler;
|
|
9
|
+
copyButtonHideStrategy?: CopyButtonHideStrategy;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function CopyLine({ content, className, valueToCopy: valueToCopyProp, onClick, copyButtonHideStrategy, ...rest }: CopyLineProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { copyToClipboard } from '@cloud-ru/ft-copy-to-clipboard';
|
|
14
|
+
import cn from 'classnames';
|
|
15
|
+
import { useEffect, useRef, useState } from 'react';
|
|
16
|
+
import { CheckSVG, CopySVG } from '@sbercloud/uikit-product-icons';
|
|
17
|
+
import { extractSupportProps } from '@sbercloud/uikit-product-utils';
|
|
18
|
+
import { ButtonFunction } from '@snack-uikit/button';
|
|
19
|
+
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
20
|
+
import { COPY_BUTTON_HIDE_STRATEGY } from './constants';
|
|
21
|
+
import styles from './styles.module.css';
|
|
22
|
+
import { isStringOrNumber } from './utils';
|
|
23
|
+
export function CopyLine(_a) {
|
|
24
|
+
var { content, className, valueToCopy: valueToCopyProp, onClick, copyButtonHideStrategy = COPY_BUTTON_HIDE_STRATEGY.Hover } = _a, rest = __rest(_a, ["content", "className", "valueToCopy", "onClick", "copyButtonHideStrategy"]);
|
|
25
|
+
const valueToCopy = valueToCopyProp !== null && valueToCopyProp !== void 0 ? valueToCopyProp : (isStringOrNumber(content) ? String(content) : '');
|
|
26
|
+
const [isChecked, setIsCheckedOpen] = useState(false);
|
|
27
|
+
const timerId = useRef();
|
|
28
|
+
const openChecked = () => setIsCheckedOpen(true);
|
|
29
|
+
const closeChecked = () => setIsCheckedOpen(false);
|
|
30
|
+
const handleClick = event => {
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
valueToCopy && copyToClipboard(String(valueToCopy));
|
|
33
|
+
openChecked();
|
|
34
|
+
clearTimeout(timerId.current);
|
|
35
|
+
timerId.current = setTimeout(closeChecked, 1000);
|
|
36
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
37
|
+
};
|
|
38
|
+
useEffect(() => () => {
|
|
39
|
+
closeChecked();
|
|
40
|
+
clearTimeout(timerId.current);
|
|
41
|
+
}, []);
|
|
42
|
+
return (_jsxs("div", Object.assign({ className: cn(styles.copyLine, className), onClick: handleClick, role: 'presentation', "data-copy-button-hide-strategy": copyButtonHideStrategy }, extractSupportProps(rest), { children: [isStringOrNumber(content) ? _jsx(TruncateString, { text: String(content), maxLines: 1 }) : content, _jsx(ButtonFunction, { "data-test-id": 'button-copy-value', type: 'button', icon: isChecked ? _jsx(CheckSVG, {}) : _jsx(CopySVG, {}), size: 'xs', className: cn(styles.copyButton, className) })] })));
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CopyLine';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CopyLine';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.copyLine{
|
|
2
|
+
font-family:var(--sans-body-m-font-family, SB Sans Interface);
|
|
3
|
+
font-weight:var(--sans-body-m-font-weight, Regular);
|
|
4
|
+
line-height:var(--sans-body-m-line-height, 20px);
|
|
5
|
+
font-size:var(--sans-body-m-font-size, 14px);
|
|
6
|
+
letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
|
|
7
|
+
paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
|
|
8
|
+
display:inline-flex;
|
|
9
|
+
flex-shrink:0;
|
|
10
|
+
gap:8px;
|
|
11
|
+
align-items:center;
|
|
12
|
+
cursor:pointer;
|
|
13
|
+
box-sizing:border-box;
|
|
14
|
+
min-width:0;
|
|
15
|
+
max-width:100%;
|
|
16
|
+
min-height:32px;
|
|
17
|
+
color:var(--sys-neutral-text-main, #41424e);
|
|
18
|
+
}
|
|
19
|
+
.copyLine[data-copy-button-hide-strategy=hover] .copyButton{
|
|
20
|
+
display:none;
|
|
21
|
+
}
|
|
22
|
+
.copyLine[data-copy-button-hide-strategy=hover]:hover .copyButton{
|
|
23
|
+
display:inline-flex;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-ru/uikit-product-copy-line",
|
|
3
3
|
"title": "Copy Line",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.65",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css",
|
|
7
7
|
"*.woff",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"name": "Akhremenko Grigorii",
|
|
31
31
|
"url": "https://github.com/AGrigorii"
|
|
32
32
|
},
|
|
33
|
+
"contributors": [],
|
|
33
34
|
"license": "Apache-2.0",
|
|
34
35
|
"publishConfig": {
|
|
35
36
|
"access": "public"
|
|
@@ -37,12 +38,12 @@
|
|
|
37
38
|
"scripts": {},
|
|
38
39
|
"dependencies": {
|
|
39
40
|
"@cloud-ru/ft-copy-to-clipboard": "0.1.0",
|
|
40
|
-
"@cloud-ru/uikit-product-icons": "15.1.
|
|
41
|
-
"@cloud-ru/uikit-product-utils": "7.0.
|
|
41
|
+
"@cloud-ru/uikit-product-icons": "15.1.3",
|
|
42
|
+
"@cloud-ru/uikit-product-utils": "7.0.2",
|
|
42
43
|
"@snack-uikit/button": "0.19.7",
|
|
43
44
|
"@snack-uikit/truncate-string": "0.6.9",
|
|
44
45
|
"@snack-uikit/utils": "3.7.0",
|
|
45
46
|
"classnames": "2.5.1"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "bf479ecf7238ef20b78f20acaef439efa535d1a1"
|
|
48
49
|
}
|