@linzjs/windows 10.1.1 → 10.1.2

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.
@@ -1,7 +1,7 @@
1
1
  import '../index.scss';
2
2
 
3
3
  import clsx from 'clsx';
4
- import { CSSProperties, ReactElement, useEffect, useRef, useState } from 'react';
4
+ import { CSSProperties, MouseEvent, ReactElement, useEffect, useRef, useState } from 'react';
5
5
 
6
6
  export interface CopyableTextProps {
7
7
  dataTestId?: string;
@@ -16,8 +16,9 @@ export const CopyableText = (props: CopyableTextProps): ReactElement => {
16
16
  const { dataTestId, style, className, text } = props;
17
17
  const timeoutRefDisplay = useRef<ReturnType<typeof setTimeout> | null>(null);
18
18
 
19
- const copy = () => {
20
- window.navigator.clipboard.writeText(String(text)).then(
19
+ const copy = (event: MouseEvent<HTMLSpanElement>) => {
20
+ const win = event.currentTarget.ownerDocument.defaultView ?? window;
21
+ win.navigator.clipboard.writeText(String(text)).then(
21
22
  () => {
22
23
  setCopied(true);
23
24
  timeoutRefDisplay.current = setTimeout(() => void setCopied(false), 3000);
@@ -45,7 +46,7 @@ export const CopyableText = (props: CopyableTextProps): ReactElement => {
45
46
  className={clsx('windows_tooltip', className)}
46
47
  onClick={(event) => {
47
48
  event.stopPropagation();
48
- copy();
49
+ copy(event);
49
50
  }}
50
51
  >
51
52
  <span className="windows_tooltiptext" style={{ width: copied ? '62px' : '47px' }}>
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "popout"
14
14
  ],
15
15
  "main": "./dist/index.ts",
16
- "version": "10.1.1",
16
+ "version": "10.1.2",
17
17
  "peerDependencies": {
18
18
  "@linzjs/lui": ">=23",
19
19
  "react": ">=18",