tycho-components 0.2.14 → 0.2.15

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,12 @@
1
+ import './styles.scss';
2
+ export declare const TitlePositions: readonly ["top", "right"];
3
+ type TitlePosition = (typeof TitlePositions)[number];
4
+ export type Props = {
5
+ className?: string;
6
+ title?: string;
7
+ content: string;
8
+ titlePosition?: TitlePosition;
9
+ hideTitle?: boolean;
10
+ };
11
+ export default function AppCopyText({ className, title, content, titlePosition, hideTitle, }: Props): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import cx from 'classnames';
4
+ import './styles.scss';
5
+ import { Icon, Tooltip } from 'tycho-storybook';
6
+ import { useTranslation } from 'react-i18next';
7
+ export const TitlePositions = ['top', 'right'];
8
+ export default function AppCopyText({ className, title, content, titlePosition = 'right', hideTitle = true, }) {
9
+ const [copied, setCopied] = useState(false);
10
+ const [isHovered, setIsHovered] = useState(false);
11
+ const { t } = useTranslation('common');
12
+ const getClassNames = cx('ds-copy-text', className, {
13
+ 'title-top': titlePosition === 'top' && !hideTitle,
14
+ 'title-right': titlePosition === 'right' && !hideTitle,
15
+ 'no-title': hideTitle,
16
+ });
17
+ const handleClipboard = () => {
18
+ navigator.clipboard
19
+ .writeText(content)
20
+ .then(() => {
21
+ setCopied(true);
22
+ setTimeout(() => {
23
+ setCopied(false);
24
+ }, 2000);
25
+ })
26
+ .catch((err) => {
27
+ console.error('Failed to copy text:', err);
28
+ });
29
+ };
30
+ const tooltipTitle = copied ? t('tooltip.copied') : t('tooltip.copy');
31
+ const iconName = copied ? 'check' : 'content_copy';
32
+ const iconFilled = isHovered && !copied;
33
+ const contentElement = (_jsxs("div", { className: getClassNames, onClick: handleClipboard, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), children: [!hideTitle && title && (_jsx("span", { className: "ds-copy-text__title", children: title })), !hideTitle && title && titlePosition === 'right' && (_jsx("span", { className: "ds-copy-text__separator", children: "|" })), _jsxs("div", { className: "group-content", children: [_jsx("span", { className: "ds-copy-text__content", children: content }), _jsx(Icon, { name: iconName, size: "small", className: "ds-copy-text__icon", filled: iconFilled })] })] }));
34
+ return (_jsx(Tooltip, { title: tooltipTitle, placement: "top", mode: "simple", triggerOpen: copied ? true : undefined, children: contentElement }));
35
+ }
@@ -0,0 +1,2 @@
1
+ import AppCopyText from './AppCopyText';
2
+ export default AppCopyText;
@@ -0,0 +1,2 @@
1
+ import AppCopyText from './AppCopyText';
2
+ export default AppCopyText;
@@ -0,0 +1,54 @@
1
+ .ds-copy-text {
2
+ display: flex;
3
+ align-items: center;
4
+ gap: 4px;
5
+ cursor: pointer;
6
+
7
+ &__title {
8
+ @include helper-small-1;
9
+ color: var(--text-secondary);
10
+ }
11
+
12
+ &__separator {
13
+ color: var(--text-secondary);
14
+ }
15
+
16
+ &__content {
17
+ color: var(--text-primary);
18
+ font-size: var(--font-size-body-medium, 14px);
19
+ }
20
+
21
+ &__icon {
22
+ color: var(--icon-accent);
23
+ transition: all 0.2s ease;
24
+ }
25
+
26
+ &:hover {
27
+ .ds-copy-text__icon {
28
+ color: var(--text-primary);
29
+ background-color: var(--button-secondary-default);
30
+ }
31
+ }
32
+
33
+ .group-content {
34
+ display: flex;
35
+ align-items: center;
36
+ gap: 4px;
37
+ }
38
+
39
+ &.title-top {
40
+ flex-direction: column;
41
+ align-items: flex-start;
42
+ gap: var(--spacing-50, 4px);
43
+ }
44
+
45
+ &.title-right {
46
+ flex-direction: row;
47
+ }
48
+
49
+ &.no-title {
50
+ .ds-copy-text__separator {
51
+ display: none;
52
+ }
53
+ }
54
+ }
@@ -71,6 +71,8 @@ export declare const commonResources: {
71
71
  'table.label.rows-page': string;
72
72
  'table.label.pages': string;
73
73
  'table.label.items': string;
74
+ 'tooltip.copy': string;
75
+ 'tooltip.copied': string;
74
76
  };
75
77
  header: {
76
78
  'label.platform': string;
@@ -263,6 +265,8 @@ export declare const commonResources: {
263
265
  'table.label.rows-page': string;
264
266
  'table.label.pages': string;
265
267
  'table.label.items': string;
268
+ 'tooltip.copy': string;
269
+ 'tooltip.copied': string;
266
270
  };
267
271
  header: {
268
272
  'label.platform': string;
@@ -453,6 +457,8 @@ export declare const commonResources: {
453
457
  'table.label.rows-page': string;
454
458
  'table.label.pages': string;
455
459
  'table.label.items': string;
460
+ 'tooltip.copy': string;
461
+ 'tooltip.copied': string;
456
462
  };
457
463
  header: {
458
464
  'label.platform': string;
@@ -25,6 +25,8 @@ export declare const CommonTexts: {
25
25
  'table.label.rows-page': string;
26
26
  'table.label.pages': string;
27
27
  'table.label.items': string;
28
+ 'tooltip.copy': string;
29
+ 'tooltip.copied': string;
28
30
  };
29
31
  'pt-BR': {
30
32
  'button.confirm': string;
@@ -52,6 +54,8 @@ export declare const CommonTexts: {
52
54
  'table.label.rows-page': string;
53
55
  'table.label.pages': string;
54
56
  'table.label.items': string;
57
+ 'tooltip.copy': string;
58
+ 'tooltip.copied': string;
55
59
  };
56
60
  it: {
57
61
  'button.confirm': string;
@@ -79,5 +83,7 @@ export declare const CommonTexts: {
79
83
  'table.label.rows-page': string;
80
84
  'table.label.pages': string;
81
85
  'table.label.items': string;
86
+ 'tooltip.copy': string;
87
+ 'tooltip.copied': string;
82
88
  };
83
89
  };
@@ -25,6 +25,8 @@ export const CommonTexts = {
25
25
  'table.label.rows-page': 'Items per page',
26
26
  'table.label.pages': 'of {{value}} pages',
27
27
  'table.label.items': '{{first}} - {{last}} of {{total}} items',
28
+ 'tooltip.copy': 'Copy',
29
+ 'tooltip.copied': 'Copied!',
28
30
  },
29
31
  'pt-BR': {
30
32
  'button.confirm': 'Confirmar',
@@ -52,6 +54,8 @@ export const CommonTexts = {
52
54
  'table.label.rows-page': 'Itens por página',
53
55
  'table.label.pages': 'de {{value}} páginas',
54
56
  'table.label.items': '{{first}} - {{last}} de {{total}} itens',
57
+ 'tooltip.copy': 'Copiar',
58
+ 'tooltip.copied': 'Copiado!',
55
59
  },
56
60
  it: {
57
61
  'button.confirm': 'Conferma',
@@ -79,5 +83,7 @@ export const CommonTexts = {
79
83
  'table.label.rows-page': 'Elementi per pagina',
80
84
  'table.label.pages': 'di {{value}} pagine',
81
85
  'table.label.items': '{{first}} - {{last}} di {{total}} elementi',
86
+ 'tooltip.copy': 'Copia',
87
+ 'tooltip.copied': 'Copiato!',
82
88
  },
83
89
  };
package/dist/index.d.ts CHANGED
@@ -72,3 +72,4 @@ export { default as SyntreesCytoscape } from './TreeView/cytoscape/SyntreesCytos
72
72
  export { default as VirtualKeyboard } from './VirtualKeyboard';
73
73
  export { KeyboardCustomLayouts } from './VirtualKeyboard/KeyboardCustomLayout';
74
74
  export type { KeyboardLayout } from './VirtualKeyboard/KeyboardCustomLayout';
75
+ export { default as AppCopyText } from './AppCopyText';
package/dist/index.js CHANGED
@@ -56,3 +56,4 @@ export { default as CytoscapeTreeConverter } from './TreeView/cytoscape/Cytoscap
56
56
  export { default as SyntreesCytoscape } from './TreeView/cytoscape/SyntreesCytoscape';
57
57
  export { default as VirtualKeyboard } from './VirtualKeyboard';
58
58
  export { KeyboardCustomLayouts } from './VirtualKeyboard/KeyboardCustomLayout';
59
+ export { default as AppCopyText } from './AppCopyText';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.2.14",
4
+ "version": "0.2.15",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -53,7 +53,7 @@
53
53
  "react-hook-form": "^7.45.2",
54
54
  "react-i18next": "^13.0.2",
55
55
  "react-router-dom": "^6.14.2",
56
- "tycho-storybook": "0.1.10",
56
+ "tycho-storybook": "0.1.11",
57
57
  "yup": "^1.2.0"
58
58
  },
59
59
  "devDependencies": {