@synerise/ds-copy-icon 1.2.14 → 1.2.16

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 CHANGED
@@ -3,6 +3,14 @@
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
+ ## [1.2.16](https://github.com/Synerise/synerise-design/compare/@synerise/ds-copy-icon@1.2.15...@synerise/ds-copy-icon@1.2.16) (2026-07-23)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-copy-icon
9
+
10
+ ## [1.2.15](https://github.com/Synerise/synerise-design/compare/@synerise/ds-copy-icon@1.2.14...@synerise/ds-copy-icon@1.2.15) (2026-06-17)
11
+
12
+ **Note:** Version bump only for package @synerise/ds-copy-icon
13
+
6
14
  ## [1.2.14](https://github.com/Synerise/synerise-design/compare/@synerise/ds-copy-icon@1.2.13...@synerise/ds-copy-icon@1.2.14) (2026-06-11)
7
15
 
8
16
  **Note:** Version bump only for package @synerise/ds-copy-icon
package/CLAUDE.md ADDED
@@ -0,0 +1,76 @@
1
+ # CopyIcon (`@synerise/ds-copy-icon`)
2
+
3
+ > Clickable icon that copies a string to the clipboard via `copy-to-clipboard`, with a tooltip that temporarily switches from "Copy" to "Copied!" for 2 seconds after a successful copy.
4
+
5
+ ## Package structure
6
+
7
+ ```
8
+ src/
9
+ CopyIcon.tsx — main component
10
+ CopyIcon.types.ts — CopyIconProps, CopyTooltipTexts
11
+ CopyIcon.styles.tsx — single styled div wrapper
12
+ index.ts — public exports
13
+ ```
14
+
15
+ ## Public exports
16
+
17
+ ### `CopyIcon` (default)
18
+
19
+ Accepts all `HTMLDivElement` attributes in addition to its own props (`WithHTMLAttributes<HTMLDivElement, ...>`).
20
+
21
+ | Prop | Type | Default | Description |
22
+ |------|------|---------|-------------|
23
+ | `copyValue` | `string` | _(required)_ | String written to the clipboard on click. |
24
+ | `texts` | `Partial<CopyTooltipTexts>` | `undefined` | Override tooltip labels. Falls back to `useIntl` i18n strings. |
25
+ | `icon` | `ReactNode` | `undefined` | Custom icon to render. Defaults to `CopyClipboardM` at 24px. |
26
+ | `placement` | `TooltipProps['placement']` | `undefined` | Tooltip placement (Ant Design `TooltipPlacement`). |
27
+ | `onCopy` | `() => void` | `undefined` | Extra callback fired after a successful copy. |
28
+ | `onClick` | `MouseEventHandler<HTMLDivElement>` | `undefined` | Also called on every click (copy success or failure). |
29
+ | `onMouseEnter` | `MouseEventHandler<HTMLDivElement>` | `undefined` | Forwarded; resets tooltip to "Copy" text on re-enter if not in copied state. |
30
+ | `onMouseLeave` | `MouseEventHandler<HTMLDivElement>` | `undefined` | Forwarded as-is. |
31
+
32
+ ### `CopyTooltipTexts` (type)
33
+
34
+ | Field | Type | i18n default |
35
+ |-------|------|--------------|
36
+ | `copyTooltip` | `ReactNode` | `'Copy'` |
37
+ | `copiedTooltip` | `ReactNode` | `'Copied!'` |
38
+
39
+ ### `CopyIconProps` (type)
40
+
41
+ Full props interface — exported for typed prop-passing.
42
+
43
+ ## Usage patterns
44
+
45
+ ```tsx
46
+ import CopyIcon from '@synerise/ds-copy-icon';
47
+
48
+ // Minimal
49
+ <CopyIcon copyValue="some-text" />
50
+
51
+ // With custom tooltip labels and callback
52
+ <CopyIcon
53
+ copyValue={apiKey}
54
+ texts={{ copyTooltip: 'Copy API key', copiedTooltip: 'Key copied!' }}
55
+ onCopy={() => analytics.track('api_key_copied')}
56
+ placement="top"
57
+ />
58
+
59
+ // With custom icon
60
+ <CopyIcon copyValue={value} icon={<Icon component={<LinkM />} />} />
61
+ ```
62
+
63
+ ## Key dependencies
64
+
65
+ - `copy-to-clipboard` (peer dep `^3.3.1`) — writes to clipboard; returns `false` if copy fails. The "copied" feedback only triggers when it returns `true`.
66
+ - `react-intl` `useIntl` (peer dep) — default tooltip strings. `IntlProvider` must be present in the tree.
67
+ - `@synerise/ds-tooltip` — wraps the icon with the toggling tooltip.
68
+ - `@synerise/ds-icon` `CopyClipboardM` — default icon.
69
+
70
+ ## Implementation notes
71
+
72
+ - **`useIntl()` is called unconditionally** — an `IntlProvider` must be in the tree even if `texts` is fully provided.
73
+ - **"Copied" lock** — `isCopiedBlock` state prevents the tooltip from resetting back to "Copy" on `mouseEnter` during the 2-second feedback window. The reset uses `setTimeout(..., 2000)` with no cleanup, so if the component unmounts during that window, a no-op state update will be attempted (harmless in React 18 but can produce warnings in older versions).
74
+ - **`onCopy` vs `onClick`** — `onCopy` fires only on a successful copy (when `copy-to-clipboard` returns `true`). `onClick` fires on every click regardless. Both are called within the same handler.
75
+ - **`mouseEnter` stops propagation** — `handleMouseEnter` always calls `event.stopPropagation()` before forwarding to the consumer's `onMouseEnter`. Same for `mouseLeave`.
76
+ - **`CopyTooltipTexts` is not exported from `index.ts`** — only `CopyIconProps` is exported. Import the type directly if needed: `import type { CopyTooltipTexts } from '@synerise/ds-copy-icon/dist/CopyIcon.types'`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-copy-icon",
3
- "version": "1.2.14",
3
+ "version": "1.2.16",
4
4
  "description": "CopyIcon UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -17,6 +17,7 @@
17
17
  "files": [
18
18
  "/dist",
19
19
  "CHANGELOG.md",
20
+ "CLAUDE.md",
20
21
  "README.md",
21
22
  "package.json",
22
23
  "LICENSE.md"
@@ -41,11 +42,11 @@
41
42
  ],
42
43
  "types": "dist/index.d.ts",
43
44
  "dependencies": {
44
- "@synerise/ds-icon": "^1.18.3",
45
- "@synerise/ds-tooltip": "^1.5.2"
45
+ "@synerise/ds-icon": "^1.18.5",
46
+ "@synerise/ds-tooltip": "^1.5.4"
46
47
  },
47
48
  "devDependencies": {
48
- "@synerise/ds-utils": "^1.10.0",
49
+ "@synerise/ds-utils": "^1.10.2",
49
50
  "vitest": "4"
50
51
  },
51
52
  "peerDependencies": {
@@ -55,5 +56,5 @@
55
56
  "react-intl": ">=3.12.0 <= 6.8",
56
57
  "styled-components": "^5.3.3"
57
58
  },
58
- "gitHead": "fe3379f50afdce6d8c61a2222ebbf03324107c95"
59
+ "gitHead": "d0a43cc43d8528a36f105aceea52ab470edb71d9"
59
60
  }