@synerise/ds-copy-icon 1.0.1

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 ADDED
@@ -0,0 +1,8 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 1.0.1 (2025-11-28)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-copy-icon
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Synerise
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ ---
2
+ id: copy-icon
3
+ title: CopyIcon
4
+ ---
5
+
6
+ CopyIcon UI Component
7
+
8
+ ## Installation
9
+ ```
10
+ npm i @synerise/ds-copy-icon
11
+ or
12
+ yarn add @synerise/ds-copy-icon
13
+ ```
14
+
15
+ ## Usage
16
+ ```
17
+ import CopyButton from '@synerise/ds-copy-icon'
18
+
19
+ <CopyIcon />
20
+
21
+ ```
22
+
23
+ ## Demo
24
+
25
+ <iframe src="/storybook-static/iframe.html?id=components-copy-icon--default"></iframe>
26
+
27
+ ## API
28
+
29
+ Property | Description | Type | Default |
30
+ | --------- | ------------------------------------------------------ | ------------------------ | ------- |
31
+ | texts | Group of texts before copy and after | CopyTooltipTexts | - |
32
+ | icon | custom icon to render | ReactNode | - |
33
+ | copyValue | Value to copy after click on icon | string | - |
34
+ | placement | prop to set tooltip where need to be | TooltipPlacement | - |
35
+ | onCopy | An extra function to invoke on copy button event | () => void | - |
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { type CopyIconProps } from './CopyIcon.types';
3
+ declare const CopyIcon: ({ copyValue, texts, onMouseEnter, onMouseLeave, icon, placement, onCopy, ...rest }: CopyIconProps) => React.JSX.Element;
4
+ export default CopyIcon;
@@ -0,0 +1,78 @@
1
+ var _excluded = ["copyValue", "texts", "onMouseEnter", "onMouseLeave", "icon", "placement", "onCopy"];
2
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
+ import copy from 'copy-to-clipboard';
5
+ import React, { useCallback, useMemo, useState } from 'react';
6
+ import { useIntl } from 'react-intl';
7
+ import Icon, { CopyClipboardM } from '@synerise/ds-icon';
8
+ import Tooltip from '@synerise/ds-tooltip';
9
+ import * as S from './CopyIcon.styles';
10
+ var CopyIcon = function CopyIcon(_ref) {
11
+ var copyValue = _ref.copyValue,
12
+ texts = _ref.texts,
13
+ onMouseEnter = _ref.onMouseEnter,
14
+ onMouseLeave = _ref.onMouseLeave,
15
+ icon = _ref.icon,
16
+ placement = _ref.placement,
17
+ onCopy = _ref.onCopy,
18
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
19
+ var _useIntl = useIntl(),
20
+ formatMessage = _useIntl.formatMessage;
21
+ var textsObj = useMemo(function () {
22
+ return _extends({
23
+ copiedTooltip: formatMessage({
24
+ id: 'DS.COPY-ICON.COPIED',
25
+ defaultMessage: 'Copied!'
26
+ }),
27
+ copyTooltip: formatMessage({
28
+ id: 'DS.COPY-ICON.COPY-VALUE',
29
+ defaultMessage: 'Copy'
30
+ })
31
+ }, texts);
32
+ }, [texts, formatMessage]);
33
+ var _useState = useState(textsObj.copyTooltip),
34
+ tooltipTitle = _useState[0],
35
+ setTooltipTitle = _useState[1];
36
+ var _useState2 = useState(false),
37
+ isCopiedBlock = _useState2[0],
38
+ setIsCopiedBlock = _useState2[1];
39
+ var handleCopy = useCallback(function (event) {
40
+ if (copyValue && copy(copyValue)) {
41
+ setTooltipTitle(textsObj.copiedTooltip);
42
+ setIsCopiedBlock(true);
43
+ setTimeout(function () {
44
+ setIsCopiedBlock(false);
45
+ setTooltipTitle(textsObj.copyTooltip);
46
+ }, 2000);
47
+ onCopy && onCopy();
48
+ }
49
+ if (rest != null && rest.onClick) {
50
+ rest.onClick(event);
51
+ }
52
+ }, [copyValue, textsObj.copiedTooltip, onCopy, rest]);
53
+ var handleMouseEnter = useCallback(function (event) {
54
+ event.stopPropagation();
55
+ if (!isCopiedBlock) {
56
+ setTooltipTitle(textsObj.copyTooltip);
57
+ }
58
+ onMouseEnter && onMouseEnter(event);
59
+ }, [isCopiedBlock, textsObj, onMouseEnter]);
60
+ var handleMouseLeave = useCallback(function (event) {
61
+ event.stopPropagation();
62
+ onMouseLeave && onMouseLeave(event);
63
+ }, [onMouseLeave]);
64
+ return /*#__PURE__*/React.createElement(Tooltip, {
65
+ placement: placement,
66
+ title: tooltipTitle
67
+ }, /*#__PURE__*/React.createElement(S.CopyIcon, _extends({
68
+ "data-testid": "ds-copy-icon",
69
+ onMouseEnter: handleMouseEnter,
70
+ onMouseLeave: handleMouseLeave
71
+ }, rest, {
72
+ onClick: handleCopy
73
+ }), icon || /*#__PURE__*/React.createElement(Icon, {
74
+ component: /*#__PURE__*/React.createElement(CopyClipboardM, null),
75
+ size: 24
76
+ })));
77
+ };
78
+ export default CopyIcon;
@@ -0,0 +1 @@
1
+ export declare const CopyIcon: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,9 @@
1
+ import styled from 'styled-components';
2
+ export var CopyIcon = styled.div.withConfig({
3
+ displayName: "CopyIconstyles__CopyIcon",
4
+ componentId: "sc-1xzoy5o-0"
5
+ })(["cursor:pointer;color:", ";&:hover{color:", ";}"], function (props) {
6
+ return props.theme.palette['grey-600'];
7
+ }, function (props) {
8
+ return props.theme.palette['blue-600'];
9
+ });
@@ -0,0 +1,14 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type WithHTMLAttributes } from '@synerise/ds-utils';
3
+ export type CopyTooltipTexts = {
4
+ copyTooltip: ReactNode;
5
+ copiedTooltip: ReactNode;
6
+ };
7
+ export type TooltipPlacement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
8
+ export type CopyIconProps = WithHTMLAttributes<HTMLDivElement, {
9
+ copyValue: string;
10
+ texts?: Partial<CopyTooltipTexts>;
11
+ icon?: ReactNode;
12
+ placement?: TooltipPlacement;
13
+ onCopy?: () => void;
14
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default } from './CopyIcon';
2
+ export type { CopyIconProps } from './CopyIcon.types';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default } from './CopyIcon';
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@synerise/ds-copy-icon",
3
+ "version": "1.0.1",
4
+ "description": "CopyIcon UI Component for the Synerise Design System",
5
+ "license": "ISC",
6
+ "repository": "Synerise/synerise-design",
7
+ "main": "dist/index.js",
8
+ "files": [
9
+ "/dist",
10
+ "CHANGELOG.md",
11
+ "README.md",
12
+ "package.json",
13
+ "LICENSE.md"
14
+ ],
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "scripts": {
19
+ "build": "npm run build:js && npm run build:css && npm run defs",
20
+ "build:css": "node ../../../scripts/style/less.js",
21
+ "build:js": "babel --delete-dir-on-start --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
22
+ "build:watch": "npm run build:js -- --watch",
23
+ "defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
24
+ "prepublish": "npm run build",
25
+ "types": "tsc --noEmit",
26
+ "pack:ci": "npm pack --pack-destination ../../storybook/storybook-static/static",
27
+ "test": "jest",
28
+ "test:watch": "npm run test -- --watchAll",
29
+ "check:circular-dependencies": "madge --circular --extensions ts,tsx,js,jsx --ts-config tsconfig.json src/ --exclude '/dist/'",
30
+ "upgrade:ds": "ncu -f \"@synerise/ds-*\" -u"
31
+ },
32
+ "sideEffects": [
33
+ "dist/style/*",
34
+ "*.less"
35
+ ],
36
+ "types": "dist/index.d.ts",
37
+ "dependencies": {
38
+ "@synerise/ds-icon": "^1.9.0",
39
+ "@synerise/ds-tooltip": "^1.3.1"
40
+ },
41
+ "devDependencies": {
42
+ "@synerise/ds-utils": "^1.5.0"
43
+ },
44
+ "peerDependencies": {
45
+ "@synerise/ds-core": "*",
46
+ "copy-to-clipboard": "^3.3.1",
47
+ "react": ">=16.9.0 <= 18.3.1",
48
+ "react-intl": ">=3.12.0 <= 6.8",
49
+ "styled-components": "^5.3.3"
50
+ },
51
+ "gitHead": "d5bd7fbc9d840ac30e2b79b36c451b486e178445"
52
+ }