diff --git a/components/qr-code/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/qr-code/__tests__/__snapshots__/demo-extend.test.ts.snap index 860731978c..7e656afc73 100644 --- a/components/qr-code/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/qr-code/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -35,6 +35,7 @@ Array [ > @@ -60,6 +61,7 @@ exports[`renders components/qr-code/demo/base.tsx extend context correctly 1`] = > @@ -93,6 +95,7 @@ exports[`renders components/qr-code/demo/customColor.tsx extend context correctl > @@ -106,6 +109,7 @@ exports[`renders components/qr-code/demo/customColor.tsx extend context correctl > @@ -193,9 +197,11 @@ Array [ > @@ -215,8 +221,14 @@ exports[`renders components/qr-code/demo/download.tsx extend context correctly 1 > + , @@ -319,9 +332,11 @@ exports[`renders components/qr-code/demo/icon.tsx extend context correctly 1`] = > @@ -370,6 +385,7 @@ exports[`renders components/qr-code/demo/status.tsx extend context correctly 1`] @@ -419,6 +435,7 @@ exports[`renders components/qr-code/demo/status.tsx extend context correctly 1`] @@ -437,6 +454,7 @@ exports[`renders components/qr-code/demo/status.tsx extend context correctly 1`] @@ -458,6 +476,7 @@ exports[`renders components/qr-code/demo/type.tsx extend context correctly 1`] = > @@ -471,6 +490,7 @@ exports[`renders components/qr-code/demo/type.tsx extend context correctly 1`] = > diff --git a/components/qr-code/__tests__/__snapshots__/demo.test.ts.snap b/components/qr-code/__tests__/__snapshots__/demo.test.ts.snap index 1d343a46e0..d9707ddc10 100644 --- a/components/qr-code/__tests__/__snapshots__/demo.test.ts.snap +++ b/components/qr-code/__tests__/__snapshots__/demo.test.ts.snap @@ -24,6 +24,7 @@ exports[`renders components/qr-code/demo/base.tsx correctly 1`] = ` > @@ -55,6 +56,7 @@ exports[`renders components/qr-code/demo/customColor.tsx correctly 1`] = ` > @@ -68,6 +70,7 @@ exports[`renders components/qr-code/demo/customColor.tsx correctly 1`] = ` > @@ -153,9 +156,11 @@ Array [ > @@ -173,8 +178,14 @@ exports[`renders components/qr-code/demo/download.tsx correctly 1`] = ` > + , @@ -273,9 +285,11 @@ exports[`renders components/qr-code/demo/icon.tsx correctly 1`] = ` > @@ -322,6 +336,7 @@ exports[`renders components/qr-code/demo/status.tsx correctly 1`] = ` @@ -371,6 +386,7 @@ exports[`renders components/qr-code/demo/status.tsx correctly 1`] = ` @@ -389,6 +405,7 @@ exports[`renders components/qr-code/demo/status.tsx correctly 1`] = ` @@ -408,6 +425,7 @@ exports[`renders components/qr-code/demo/type.tsx correctly 1`] = ` > @@ -421,6 +439,7 @@ exports[`renders components/qr-code/demo/type.tsx correctly 1`] = ` > diff --git a/components/qr-code/__tests__/__snapshots__/index.test.tsx.snap b/components/qr-code/__tests__/__snapshots__/index.test.tsx.snap index 395f0a8557..78c826503d 100644 --- a/components/qr-code/__tests__/__snapshots__/index.test.tsx.snap +++ b/components/qr-code/__tests__/__snapshots__/index.test.tsx.snap @@ -10,6 +10,7 @@ exports[`QRCode test should correct render 1`] = ` > diff --git a/components/qr-code/demo/download.tsx b/components/qr-code/demo/download.tsx index c860ca6e6f..9ecbb8c983 100644 --- a/components/qr-code/demo/download.tsx +++ b/components/qr-code/demo/download.tsx @@ -16,7 +16,12 @@ const downloadQRCode = () => { const App: React.FC = () => ( - + Download diff --git a/components/qr-code/index.tsx b/components/qr-code/index.tsx index f53725d908..cd9aad5b3e 100644 --- a/components/qr-code/index.tsx +++ b/components/qr-code/index.tsx @@ -1,7 +1,7 @@ import React, { useContext } from 'react'; import ReloadOutlined from '@ant-design/icons/ReloadOutlined'; import classNames from 'classnames'; -import { QRCodeCanvas, QRCodeSVG } from 'qrcode.react'; +import { QRCodeCanvas, QRCodeSVG } from '@rc-component/qrcode'; import { devUseWarning } from '../_util/warning'; import Button from '../button'; @@ -45,6 +45,7 @@ const QRCode: React.FC = (props) => { height: typeof iconSize === 'number' ? iconSize : iconSize?.height ?? 40, width: typeof iconSize === 'number' ? iconSize : iconSize?.width ?? 40, excavate: true, + crossOrigin: 'anonymous', }; const qrCodeProps = { diff --git a/components/qr-code/interface.ts b/components/qr-code/interface.ts index 34c635afba..6664dbe8b5 100644 --- a/components/qr-code/interface.ts +++ b/components/qr-code/interface.ts @@ -1,30 +1,15 @@ -import type { CSSProperties } from 'react'; +import type { QRProps } from '@rc-component/qrcode'; -interface ImageSettings { - src: string; - height: number; - width: number; - excavate: boolean; - x?: number; - y?: number; -} +type ImageSettings = QRProps['imageSettings']; -export interface QRProps { - value: string; - type?: 'canvas' | 'svg'; - size?: number; - color?: string; - style?: CSSProperties; - includeMargin?: boolean; - imageSettings?: ImageSettings; - bgColor?: string; -} +export type { QRProps, ImageSettings }; export type QRPropsCanvas = QRProps & React.CanvasHTMLAttributes; export type QRPropsSvg = QRProps & React.SVGAttributes; export interface QRCodeProps extends QRProps, React.HTMLAttributes { + type?: 'canvas' | 'svg'; className?: string; rootClassName?: string; prefixCls?: string; diff --git a/package.json b/package.json index 8140cdd5db..c860f5ab83 100644 --- a/package.json +++ b/package.json @@ -124,12 +124,12 @@ "@ctrl/tinycolor": "^3.6.1", "@rc-component/color-picker": "~1.5.3", "@rc-component/mutate-observer": "^1.1.0", + "@rc-component/qrcode": "~1.0.0", "@rc-component/tour": "~1.15.0", "@rc-component/trigger": "^2.2.0", "classnames": "^2.5.1", "copy-to-clipboard": "^3.3.3", "dayjs": "^1.11.11", - "qrcode.react": "^3.1.0", "rc-cascader": "~3.27.0", "rc-checkbox": "~3.3.0", "rc-collapse": "~3.7.3",