Skip to content

Commit

Permalink
version: 2.1.0-beta.1
Browse files Browse the repository at this point in the history
  • Loading branch information
freeshineit committed Oct 29, 2024
1 parent 6ec4a7f commit a15b145
Show file tree
Hide file tree
Showing 9 changed files with 2,180 additions and 492 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# rules follow https://eslint.org/docs/user-guide/configuring#ignoring-files-and-directories

dist/
build/
node_modules/
examples/
2 changes: 1 addition & 1 deletion examples/cra-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"react": "^18.2.0",
"react-clipboardjs-copy": "^2.0.2",
"react-clipboardjs-copy": "^2.1.0-beta.1",
"react-dom": "^18.2.0",
"@skax/react-scripts": "5.0.1-beta.2",
"typescript": "^4.4.2",
Expand Down
9 changes: 5 additions & 4 deletions examples/cra-app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5446,10 +5446,10 @@ react-app-polyfill@^3.0.0:
regenerator-runtime "^0.13.9"
whatwg-fetch "^3.6.2"

react-clipboardjs-copy@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/react-clipboardjs-copy/-/react-clipboardjs-copy-2.0.2.tgz#73a308a5c2e6309aff054b6ac5e08a068d9cc0aa"
integrity sha512-vNCy+bNxwuE2KcrIQKhJ8Ra8jaglZzkJSpWBZ7EKD0Qh8Jdgu/hHRGwRfiH2uuNqCGFf/MubDdxhFsYVNUwcIQ==
react-clipboardjs-copy@^2.1.0-beta.1:
version "2.1.0-beta.1"
resolved "https://registry.yarnpkg.com/react-clipboardjs-copy/-/react-clipboardjs-copy-2.1.0-beta.1.tgz#bc5273ce8c9df9f6b789301baba7661d6698a473"
integrity sha512-OVjQw9oJVH7/4FrlDsyKivs3VPKx8GwRCATv5i8GP2hKtit+VtIvw5RkBWk789D0/cw78w240BPd+Qe4YRclrA==
dependencies:
clipboard "2.0.11"

Expand Down Expand Up @@ -6062,6 +6062,7 @@ statuses@2.0.1:
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
name string-width-cjs
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down
6 changes: 3 additions & 3 deletions examples/with-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "0.1.0",
"author": "shine <xiaoshaoqq@gmail.com>",
"license": "MIT",
"dependencies": {},
"scripts": {
"dev": "vite",
"build": "tsc && vite build"
Expand All @@ -25,9 +24,10 @@
"@types/react": "^18.2.74",
"@types/react-dom": "^18.2.24",
"@vitejs/plugin-react-swc": "^3.6.0",
"postcss-preset-env": "^9.5.14",
"postcss": "^8.4.38",
"postcss-preset-env": "^9.6.0",
"react": "^18.2.0",
"react-clipboardjs-copy": "2.0.2",
"react-clipboardjs-copy": "^2.1.0-beta.1",
"react-dom": "^18.2.0",
"sass": "^1.77.4",
"typescript": "5.3.3",
Expand Down
949 changes: 505 additions & 444 deletions examples/with-vite/yarn.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/copy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-clipboardjs-copy",
"version": "2.0.2",
"version": "2.1.0-beta.1",
"main": "./src/index.ts",
"module": "./src/index.ts",
"types": "./src/index.ts",
Expand All @@ -25,7 +25,7 @@
"prepublish": "exit 0"
},
"engines": {
"react": ">=16.8.0"
"react": ">=16.8"
},
"devDependencies": {
"@babel/core": "^7.24.4",
Expand All @@ -47,7 +47,7 @@
"ts-jest": "^29.1.2"
},
"peerDependencies": {
"react": ">=16.8.0",
"react-dom": ">=16.8.0"
"react": ">=16.8",
"react-dom": ">=16.8"
}
}
8 changes: 4 additions & 4 deletions packages/copy/src/Component.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useRef } from 'react';
import Clipboard from 'clipboard';
import ClipboardJS from 'clipboard';

export type ClipboardJSTarget = string | Element | NodeListOf<Element>;

Expand Down Expand Up @@ -30,18 +30,18 @@ export interface ReactClipboardProps {
onError?: (event?: ClipboardJS.Event) => void; //
}

export { Clipboard };
export { ClipboardJS };

export const ReactClipboard: React.FC<ReactClipboardProps> = (props) => {
const childrenRef = useRef<Element>();
const clipboard = useRef<Clipboard>();
const clipboard = useRef<ClipboardJS>();

useEffect(() => {
// ⚠️: useEffect Run Twice in React v18.0 https://blog.bitsrc.io/react-v18-0-useeffect-bug-why-do-effects-run-twice-39babecede93
// https://reactjs.org/docs/strict-mode.html#ensuring-reusable-state
// https://github.com/facebook/react/issues/24502
if (!clipboard.current && childrenRef.current) {
clipboard.current = new Clipboard(childrenRef.current, {
clipboard.current = new ClipboardJS(childrenRef.current, {
action: typeof props.action === 'function' ? props.action || 'copy' : undefined,
target: typeof props.target === 'function' ? props.target : undefined,
text: typeof props.text === 'function' ? props.text : undefined,
Expand Down
4 changes: 2 additions & 2 deletions packages/copy/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReactClipboard, Clipboard } from './Component';
import { ReactClipboard, ClipboardJS } from './Component';
export type { ReactClipboardProps } from './Component';
export { Clipboard };
export { ClipboardJS };

export default ReactClipboard;
Loading

0 comments on commit a15b145

Please sign in to comment.