From 16e05aca70f690a129e6261d4225d14fe2ac0e4a Mon Sep 17 00:00:00 2001
From: MadCcc <1075746765@qq.com>
Date: Tue, 22 Nov 2022 16:56:27 +0800
Subject: [PATCH 01/70] feat: qrcode
---
.../__test__/__snapshots__/demo.test.ts.snap | 44 +++++
components/qr-code/__test__/demo.test.ts | 3 +
components/qr-code/constants.ts | 3 +
components/qr-code/demos/download.tsx | 28 +++
components/qr-code/demos/errorlevel.tsx | 28 +++
components/qr-code/demos/logo.tsx | 14 ++
components/qr-code/demos/outdated.tsx | 11 ++
components/qr-code/demos/popover.tsx | 16 ++
components/qr-code/demos/refresh.tsx | 53 ++++++
components/qr-code/demos/rendermode.tsx | 17 ++
components/qr-code/demos/service.ts | 42 +++++
components/qr-code/demos/withoutlogo.tsx | 9 +
components/qr-code/index.md | 123 ++++++++++++
components/qr-code/index.tsx | 178 ++++++++++++++++++
components/qr-code/style/index.ts | 48 +++++
package.json | 1 +
16 files changed, 618 insertions(+)
create mode 100644 components/qr-code/__test__/__snapshots__/demo.test.ts.snap
create mode 100644 components/qr-code/__test__/demo.test.ts
create mode 100644 components/qr-code/constants.ts
create mode 100644 components/qr-code/demos/download.tsx
create mode 100644 components/qr-code/demos/errorlevel.tsx
create mode 100644 components/qr-code/demos/logo.tsx
create mode 100644 components/qr-code/demos/outdated.tsx
create mode 100644 components/qr-code/demos/popover.tsx
create mode 100644 components/qr-code/demos/refresh.tsx
create mode 100644 components/qr-code/demos/rendermode.tsx
create mode 100644 components/qr-code/demos/service.ts
create mode 100644 components/qr-code/demos/withoutlogo.tsx
create mode 100644 components/qr-code/index.md
create mode 100644 components/qr-code/index.tsx
create mode 100644 components/qr-code/style/index.ts
diff --git a/components/qr-code/__test__/__snapshots__/demo.test.ts.snap b/components/qr-code/__test__/__snapshots__/demo.test.ts.snap
new file mode 100644
index 000000000000..867d17bb94c8
--- /dev/null
+++ b/components/qr-code/__test__/__snapshots__/demo.test.ts.snap
@@ -0,0 +1,44 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`
+
+### 渲染为 svg
+
+
+
+### 过期状态
+
+
+
+### 带 logo 例子
+
+
+
+### popover 带 logo 例子
+
+
+
+### 轮询 & 过期刷新
+
+轮询二维码过期状态,并进行刷新的实际业务例子。
+
+
+
+### 下载二维码
+
+很多场景下会有下载二维码的需求,这里提供一种实现。
+
+
+
+### 二维码纠错比例
+
+手动调整二维码的纠错比例。
+
+
+
+## API
+
+| 参数 | 说明 | 类型 | 默认值 |
+| :--------- | :--------------------------------------- | :-------------------------- | :--------- |
+| mode | 最终渲染出来的结构 | `'svg' \| 'canvas'` | `'canvas'` |
+| value | 扫描后的地址 | string | - |
+| logo | 二维码中图片的地址(目前只支持图片地址) | string | - |
+| size | 二维码图片大小 | number | 128 |
+| logoSize | 二维码中 logo 大小 | number | 32 |
+| bgColor | 二维码背景颜色 | string | '#FFFFFF' |
+| fgColor | 二维码前景的颜色 | string | '#000000' |
+| popover | 是否展现气泡卡片 | boolean | false |
+| expired | 是否过期 | boolean | false |
+| onRefresh | 点击点击刷新的回调 | () => void | noop |
+| errorLevel | 纠错码的登记 | `'L' \| 'M' \| 'Q' \| 'H' ` | `'L'` |
+
+## Contributors(2)
+
+Ordered by date of first contribution
+
+
+
+
+
+---
diff --git a/components/qr-code/index.tsx b/components/qr-code/index.tsx
new file mode 100644
index 000000000000..01a524b14d61
--- /dev/null
+++ b/components/qr-code/index.tsx
@@ -0,0 +1,178 @@
+import type { CSSProperties, FC } from 'react';
+import { useEffect, useState } from 'react';
+import React from 'react';
+import { QRCodeCanvas, QRCodeSVG } from 'qrcode.react';
+import { ReloadOutlined } from '@ant-design/icons';
+import { Popover } from 'antd';
+import { noop } from 'lodash';
+import classNames from 'classnames';
+
+import { QRCODE, CLICK_REFRESH } from './constants';
+import useStyle from './style/index';
+import getPrefixCls from '../_util/getPrefixCls';
+
+/**
+ * 统计数据组件的基础 props 类型定义
+ */
+export interface QrCodeBaseProps {
+ /**
+ * @description 附加样式
+ * @ignore
+ */
+ style?: CSSProperties;
+ /**
+ * @description 类名
+ * @ignore
+ */
+ className?: string;
+ /**
+ * @description 自定义 CSS classname 前缀
+ * @ignore
+ */
+ prefixCls?: string;
+}
+
+/**
+ * 统计数据组件列表的 props 类型定义
+ */
+export interface QrCodeProps extends QrCodeBaseProps {
+ /**
+ * @title 渲染模式
+ * @description 二维码渲染模式
+ * @default "svg"
+ */
+ mode?: 'canvas' | 'svg' | string;
+ /**
+ * @title 二维码地址
+ * @description 扫描后的地址
+ */
+ value: string;
+ /**
+ * @title 二维码图片大小
+ * @description 二维码图片大小
+ * @default "128"
+ */
+ size?: number;
+ /**
+ * @title 背景颜色
+ * @description 二维码背景颜色
+ * @default "#FFFFFF"
+ */
+ bgColor?: string;
+ /**
+ * @title 前景颜色
+ * @description 二维码前景颜色
+ * @default "#000000"
+ */
+ fgColor?: string;
+ /**
+ * @title Logo 图片地址
+ * @description 二维码中图片的地址(目前只支持图片地址)
+ */
+ logo?: string;
+ /**
+ * @title Logo 图片大小
+ * @description 二维码中 logo 大小
+ * @default "32"
+ */
+ logoSize?: number;
+ /**
+ * @title 展现气泡卡片
+ * @description 是否展现气泡卡片
+ * @default false
+ */
+ popover?: boolean;
+ /**
+ * @title 点击刷新的回调
+ * @description 点击刷新的回调
+ */
+ onRefresh?: React.MouseEventHandlerbase
+With Icon
+Download QrCode
+Error Level
+
+## API
+
+| 参数 | 说明 | 类型 | 默认值 |
+| :--------- | :--------------------------------------- | :-------------------------- | :----- |
+| value | 扫描后的地址 | string | - |
+| size | 二维码图片大小 | number | 128 |
+| icon | 二维码中图片的地址(目前只支持图片地址) | string | - |
+| iconSize | 二维码中图片的大小 | number | 32 |
+| bgColor | 二维码背景颜色 | string | `#fff` |
+| fgColor | 二维码前景的颜色 | string | `#000` |
+| errorLevel | 纠错码的等级 | `'L' \| 'M' \| 'Q' \| 'H' ` | `L` |
diff --git a/components/qr-code/index.md b/components/qr-code/index.md
deleted file mode 100644
index e06fbfa7e543..000000000000
--- a/components/qr-code/index.md
+++ /dev/null
@@ -1,76 +0,0 @@
----
-uuid: ba1833a0
-title: QrCode 二维码
-legacy: /QrCode
-nav:
- title: 组件
- path: /components
----
-
-# QrCode 二维码
-
-
-
-### 渲染为 svg
-
-
-
-### 过期状态
-
-
-
-### 带 logo 例子
-
-
-
-### popover 带 logo 例子
-
-
-
-### 轮询 & 过期刷新
-
-轮询二维码过期状态,并进行刷新的实际业务例子。
-
-
-
-### 下载二维码
-
-很多场景下会有下载二维码的需求,这里提供一种实现。
-
-
-
-### 二维码纠错比例
-
-手动调整二维码的纠错比例。
-
-
-
-## API
-
-| 参数 | 说明 | 类型 | 默认值 |
-| :--------- | :--------------------------------------- | :-------------------------- | :--------- |
-| mode | 最终渲染出来的结构 | `'svg' \| 'canvas'` | `'canvas'` |
-| value | 扫描后的地址 | string | - |
-| logo | 二维码中图片的地址(目前只支持图片地址) | string | - |
-| size | 二维码图片大小 | number | 128 |
-| logoSize | 二维码中 logo 大小 | number | 32 |
-| bgColor | 二维码背景颜色 | string | '#FFFFFF' |
-| fgColor | 二维码前景的颜色 | string | '#000000' |
-| popover | 是否展现气泡卡片 | boolean | false |
-| expired | 是否过期 | boolean | false |
-| onRefresh | 点击点击刷新的回调 | () => void | noop |
-| errorLevel | 纠错码的登记 | `'L' \| 'M' \| 'Q' \| 'H' ` | `'L'` |
diff --git a/components/qr-code/index.tsx b/components/qr-code/index.tsx
index 01a524b14d61..f3a2e0e6dfa6 100644
--- a/components/qr-code/index.tsx
+++ b/components/qr-code/index.tsx
@@ -1,178 +1,59 @@
-import type { CSSProperties, FC } from 'react';
-import { useEffect, useState } from 'react';
-import React from 'react';
-import { QRCodeCanvas, QRCodeSVG } from 'qrcode.react';
-import { ReloadOutlined } from '@ant-design/icons';
-import { Popover } from 'antd';
-import { noop } from 'lodash';
+import React, { useMemo, useContext } from 'react';
+import { QRCodeCanvas } from 'qrcode.react';
import classNames from 'classnames';
-
-import { QRCODE, CLICK_REFRESH } from './constants';
+import { ConfigContext } from '../config-provider';
+import type { ConfigConsumerProps } from '../config-provider';
+import type { QrCodeProps, QRPropsCanvas } from './interface';
import useStyle from './style/index';
-import getPrefixCls from '../_util/getPrefixCls';
-
-/**
- * 统计数据组件的基础 props 类型定义
- */
-export interface QrCodeBaseProps {
- /**
- * @description 附加样式
- * @ignore
- */
- style?: CSSProperties;
- /**
- * @description 类名
- * @ignore
- */
- className?: string;
- /**
- * @description 自定义 CSS classname 前缀
- * @ignore
- */
- prefixCls?: string;
-}
-
-/**
- * 统计数据组件列表的 props 类型定义
- */
-export interface QrCodeProps extends QrCodeBaseProps {
- /**
- * @title 渲染模式
- * @description 二维码渲染模式
- * @default "svg"
- */
- mode?: 'canvas' | 'svg' | string;
- /**
- * @title 二维码地址
- * @description 扫描后的地址
- */
- value: string;
- /**
- * @title 二维码图片大小
- * @description 二维码图片大小
- * @default "128"
- */
- size?: number;
- /**
- * @title 背景颜色
- * @description 二维码背景颜色
- * @default "#FFFFFF"
- */
- bgColor?: string;
- /**
- * @title 前景颜色
- * @description 二维码前景颜色
- * @default "#000000"
- */
- fgColor?: string;
- /**
- * @title Logo 图片地址
- * @description 二维码中图片的地址(目前只支持图片地址)
- */
- logo?: string;
- /**
- * @title Logo 图片大小
- * @description 二维码中 logo 大小
- * @default "32"
- */
- logoSize?: number;
- /**
- * @title 展现气泡卡片
- * @description 是否展现气泡卡片
- * @default false
- */
- popover?: boolean;
- /**
- * @title 点击刷新的回调
- * @description 点击刷新的回调
- */
- onRefresh?: React.MouseEventHandler基本使用
+带 logo 的例子
+下载二维码
+纠错比例
+
+## API
+
+| 参数 | 说明 | 类型 | 默认值 |
+| :--------- | :--------------------------------------- | :-------------------------- | :----- |
+| value | 扫描后的地址 | string | - |
+| size | 二维码图片大小 | number | 128 |
+| icon | 二维码中图片的地址(目前只支持图片地址) | string | - |
+| iconSize | 二维码中图片的大小 | number | 32 |
+| bgColor | 二维码背景颜色 | string | `#fff` |
+| fgColor | 二维码前景的颜色 | string | `#000` |
+| errorLevel | 纠错码的等级 | `'L' \| 'M' \| 'Q' \| 'H' ` | `L` |
diff --git a/components/qr-code/interface.ts b/components/qr-code/interface.ts
new file mode 100644
index 000000000000..bb63a0112808
--- /dev/null
+++ b/components/qr-code/interface.ts
@@ -0,0 +1,31 @@
+import type { CSSProperties } from 'react';
+
+interface ImageSettings {
+ src: string;
+ height: number;
+ width: number;
+ excavate: boolean;
+ x?: number;
+ y?: number;
+}
+
+interface QRProps {
+ value: string;
+ size?: number;
+ level?: string;
+ bgColor?: string;
+ fgColor?: string;
+ style?: CSSProperties;
+ includeMargin?: boolean;
+ imageSettings?: ImageSettings;
+}
+
+export type QRPropsCanvas = QRProps & React.CanvasHTMLAttributesbase
@@ -29,12 +29,12 @@ group:
## API
-| 参数 | 说明 | 类型 | 默认值 |
-| :--------- | :--------------------------------------- | :-------------------------- | :----- |
-| value | 扫描后的地址 | string | - |
-| size | 二维码图片大小 | number | 128 |
-| icon | 二维码中图片的地址(目前只支持图片地址) | string | - |
-| iconSize | 二维码中图片的大小 | number | 32 |
-| bgColor | 二维码背景颜色 | string | `#fff` |
-| fgColor | 二维码前景的颜色 | string | `#000` |
-| errorLevel | 纠错码的等级 | `'L' \| 'M' \| 'Q' \| 'H' ` | `L` |
+| Property | Description | Type | Default |
+| :--------- | :------------------------------------------ | :-------------------------- | :------ |
+| value | scanned link | string | - |
+| size | QrCode size | number | 128 |
+| icon | include image url (only link are supported) | string | - |
+| iconSize | include image size | number | 32 |
+| bgColor | QrCode Background Color | string | `#fff` |
+| fgColor | QrCode Foreground Color | string | `#000` |
+| errorLevel | Error Code Level | `'L' \| 'M' \| 'Q' \| 'H' ` | `L` |
From 93e7ae77617843c7a4cc8e4fca0857893693408c Mon Sep 17 00:00:00 2001
From: MadCcc <1075746765@qq.com>
Date: Thu, 24 Nov 2022 17:11:52 +0800
Subject: [PATCH 07/70] refactor: rename tests dir
---
.../__snapshots__/demo-extend.test.ts.snap | 0
.../{__test__ => __tests__}/__snapshots__/demo.test.ts.snap | 0
.../{__test__ => __tests__}/__snapshots__/index.test.tsx.snap | 0
components/qr-code/{__test__ => __tests__}/demo-extend.test.ts | 0
components/qr-code/{__test__ => __tests__}/demo.test.ts | 0
components/qr-code/{__test__ => __tests__}/image.test.ts | 0
components/qr-code/{__test__ => __tests__}/index.test.tsx | 0
7 files changed, 0 insertions(+), 0 deletions(-)
rename components/qr-code/{__test__ => __tests__}/__snapshots__/demo-extend.test.ts.snap (100%)
rename components/qr-code/{__test__ => __tests__}/__snapshots__/demo.test.ts.snap (100%)
rename components/qr-code/{__test__ => __tests__}/__snapshots__/index.test.tsx.snap (100%)
rename components/qr-code/{__test__ => __tests__}/demo-extend.test.ts (100%)
rename components/qr-code/{__test__ => __tests__}/demo.test.ts (100%)
rename components/qr-code/{__test__ => __tests__}/image.test.ts (100%)
rename components/qr-code/{__test__ => __tests__}/index.test.tsx (100%)
diff --git a/components/qr-code/__test__/__snapshots__/demo-extend.test.ts.snap b/components/qr-code/__tests__/__snapshots__/demo-extend.test.ts.snap
similarity index 100%
rename from components/qr-code/__test__/__snapshots__/demo-extend.test.ts.snap
rename to components/qr-code/__tests__/__snapshots__/demo-extend.test.ts.snap
diff --git a/components/qr-code/__test__/__snapshots__/demo.test.ts.snap b/components/qr-code/__tests__/__snapshots__/demo.test.ts.snap
similarity index 100%
rename from components/qr-code/__test__/__snapshots__/demo.test.ts.snap
rename to components/qr-code/__tests__/__snapshots__/demo.test.ts.snap
diff --git a/components/qr-code/__test__/__snapshots__/index.test.tsx.snap b/components/qr-code/__tests__/__snapshots__/index.test.tsx.snap
similarity index 100%
rename from components/qr-code/__test__/__snapshots__/index.test.tsx.snap
rename to components/qr-code/__tests__/__snapshots__/index.test.tsx.snap
diff --git a/components/qr-code/__test__/demo-extend.test.ts b/components/qr-code/__tests__/demo-extend.test.ts
similarity index 100%
rename from components/qr-code/__test__/demo-extend.test.ts
rename to components/qr-code/__tests__/demo-extend.test.ts
diff --git a/components/qr-code/__test__/demo.test.ts b/components/qr-code/__tests__/demo.test.ts
similarity index 100%
rename from components/qr-code/__test__/demo.test.ts
rename to components/qr-code/__tests__/demo.test.ts
diff --git a/components/qr-code/__test__/image.test.ts b/components/qr-code/__tests__/image.test.ts
similarity index 100%
rename from components/qr-code/__test__/image.test.ts
rename to components/qr-code/__tests__/image.test.ts
diff --git a/components/qr-code/__test__/index.test.tsx b/components/qr-code/__tests__/index.test.tsx
similarity index 100%
rename from components/qr-code/__test__/index.test.tsx
rename to components/qr-code/__tests__/index.test.tsx
From 60ad00a5902ab0a809283a3009557c593644c9fb Mon Sep 17 00:00:00 2001
From: lijianan <574980606@qq.com>
Date: Thu, 24 Nov 2022 22:38:27 +0800
Subject: [PATCH 08/70] Update components/qr-code/demo/base.md
Co-authored-by: MadCcc <1075746765@qq.com>
---
components/qr-code/demo/base.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/qr-code/demo/base.md b/components/qr-code/demo/base.md
index cdbb62b914cd..f90e126d54f3 100644
--- a/components/qr-code/demo/base.md
+++ b/components/qr-code/demo/base.md
@@ -1,6 +1,6 @@
## zh-CN
-基本使用
+基本用法。
## en-US
From 2d391b5a51727f154c7be15aed485981c0436331 Mon Sep 17 00:00:00 2001
From: lijianan <574980606@qq.com>
Date: Thu, 24 Nov 2022 22:38:38 +0800
Subject: [PATCH 09/70] Update components/qr-code/demo/base.md
Co-authored-by: MadCcc <1075746765@qq.com>
---
components/qr-code/demo/base.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/qr-code/demo/base.md b/components/qr-code/demo/base.md
index f90e126d54f3..d7c5bd3ef03d 100644
--- a/components/qr-code/demo/base.md
+++ b/components/qr-code/demo/base.md
@@ -4,4 +4,4 @@
## en-US
-base
+Basic Usage.
From fbdc1f7594267093dfdd6f78f6ff15d42ca010fe Mon Sep 17 00:00:00 2001
From: lijianan <574980606@qq.com>
Date: Thu, 24 Nov 2022 22:38:47 +0800
Subject: [PATCH 10/70] Update components/qr-code/demo/download.md
Co-authored-by: MadCcc <1075746765@qq.com>
---
components/qr-code/demo/download.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/qr-code/demo/download.md b/components/qr-code/demo/download.md
index d0f1cef4d3fa..e67ea20ef7d1 100644
--- a/components/qr-code/demo/download.md
+++ b/components/qr-code/demo/download.md
@@ -1,6 +1,6 @@
## zh-CN
-下载二维码
+下载二维码的简单实现。
## en-US
From 6b678cd797e13c3dfba7c364b44ffd1226897612 Mon Sep 17 00:00:00 2001
From: lijianan <574980606@qq.com>
Date: Thu, 24 Nov 2022 22:38:55 +0800
Subject: [PATCH 11/70] Update components/qr-code/demo/download.md
Co-authored-by: MadCcc <1075746765@qq.com>
---
components/qr-code/demo/download.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/qr-code/demo/download.md b/components/qr-code/demo/download.md
index e67ea20ef7d1..e961df09fec3 100644
--- a/components/qr-code/demo/download.md
+++ b/components/qr-code/demo/download.md
@@ -4,4 +4,4 @@
## en-US
-Download QrCode
+A way to download QrCode.
From bc02ee42a45268e5082d15b2e4763c5bdeb6a8fb Mon Sep 17 00:00:00 2001
From: lijianan <574980606@qq.com>
Date: Thu, 24 Nov 2022 22:39:14 +0800
Subject: [PATCH 12/70] Update components/qr-code/demo/download.tsx
Co-authored-by: MadCcc <1075746765@qq.com>
---
components/qr-code/demo/download.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/qr-code/demo/download.tsx b/components/qr-code/demo/download.tsx
index e805af0acd82..1d44909208b5 100644
--- a/components/qr-code/demo/download.tsx
+++ b/components/qr-code/demo/download.tsx
@@ -18,7 +18,7 @@ const App: React.FC = () => (
base
+With Icon
+Download QRCode
+Error Level
+
+## API
+
+| Property | Description | Type | Default |
+| :-- | :-- | :-- | :-- |
+| value | scanned link | string | - |
+| size | QRCode size | number | 128 |
+| icon | include image url (only image link are supported) | string | - |
+| iconSize | include image size | number | 32 |
+| bgColor | QRCode Background Color | string | `#fff` |
+| fgColor | QRCode Foreground Color | string | `#000` |
+| errorLevel | Error Code Level | `'L' \| 'M' \| 'Q' \| 'H' ` | `L` |
diff --git a/components/qr-code/index.tsx b/components/QRCode/index.tsx
similarity index 87%
rename from components/qr-code/index.tsx
rename to components/QRCode/index.tsx
index 8ae8a720bdd9..03bc62d3dcf5 100644
--- a/components/qr-code/index.tsx
+++ b/components/QRCode/index.tsx
@@ -3,10 +3,10 @@ import { QRCodeCanvas } from 'qrcode.react';
import classNames from 'classnames';
import { ConfigContext } from '../config-provider';
import type { ConfigConsumerProps } from '../config-provider';
-import type { QrCodeProps, QRPropsCanvas } from './interface';
+import type { QRCodeProps, QRPropsCanvas } from './interface';
import useStyle from './style/index';
-const QrCode: React.FC基本使用
-带 logo 的例子
+带 Icon 的例子
下载二维码
纠错比例
diff --git a/components/qr-code/interface.ts b/components/QRCode/interface.ts
similarity index 92%
rename from components/qr-code/interface.ts
rename to components/QRCode/interface.ts
index bb63a0112808..20c48d5c2614 100644
--- a/components/qr-code/interface.ts
+++ b/components/QRCode/interface.ts
@@ -22,7 +22,7 @@ interface QRProps {
export type QRPropsCanvas = QRProps & React.CanvasHTMLAttributesbase
-With Icon
-Download QrCode
-Error Level
-
-## API
-
-| Property | Description | Type | Default |
-| :--------- | :------------------------------------------ | :-------------------------- | :------ |
-| value | scanned link | string | - |
-| size | QrCode size | number | 128 |
-| icon | include image url (only link are supported) | string | - |
-| iconSize | include image size | number | 32 |
-| bgColor | QrCode Background Color | string | `#fff` |
-| fgColor | QrCode Foreground Color | string | `#000` |
-| errorLevel | Error Code Level | `'L' \| 'M' \| 'Q' \| 'H' ` | `L` |
diff --git a/components/theme/interface.ts b/components/theme/interface.ts
index 5e1ee09827f9..a819c8125e67 100644
--- a/components/theme/interface.ts
+++ b/components/theme/interface.ts
@@ -135,7 +135,7 @@ export interface ComponentTokenMap {
Space?: SpaceComponentToken;
Progress?: ProgressComponentToken;
Tour?: TourComponentToken;
- QrCode?: {};
+ QRCode?: {};
}
export type OverrideToken = {
diff --git a/package.json b/package.json
index ddfbc14fff80..79a4327d0bfa 100644
--- a/package.json
+++ b/package.json
@@ -86,8 +86,8 @@
"site": "dumi build && cp .surgeignore _site",
"sort": "npx sort-package-json",
"sort-api": "antd-tools run sort-api-table",
- "start": "PORT=8001 dumi dev",
- "test": "jest --config .jest.js --cache=false",
+ "start": "dumi dev",
+ "test": "jest --config .jest.js --cache=false tests/index.test.ts",
"test:update": "jest --config .jest.js --cache=false -u",
"test-all": "sh -e ./scripts/test-all.sh",
"test-node": "npm run version && jest --config .jest.node.js --cache=false",
diff --git a/tests/__snapshots__/index.test.ts.snap b/tests/__snapshots__/index.test.ts.snap
index 65ad7c74a68a..6d5e6564cf6e 100644
--- a/tests/__snapshots__/index.test.ts.snap
+++ b/tests/__snapshots__/index.test.ts.snap
@@ -40,7 +40,7 @@ exports[`antd dist files exports modules correctly 1`] = `
"Popconfirm",
"Popover",
"Progress",
- "QrCode",
+ "QRCode",
"Radio",
"Rate",
"Result",
From 6a9a5e2ce625b256103232c0a8c97661c1626804 Mon Sep 17 00:00:00 2001
From: lijianan <574980606@qq.com>
Date: Thu, 24 Nov 2022 23:14:34 +0800
Subject: [PATCH 19/70] fix
---
package.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/package.json b/package.json
index 79a4327d0bfa..ddfbc14fff80 100644
--- a/package.json
+++ b/package.json
@@ -86,8 +86,8 @@
"site": "dumi build && cp .surgeignore _site",
"sort": "npx sort-package-json",
"sort-api": "antd-tools run sort-api-table",
- "start": "dumi dev",
- "test": "jest --config .jest.js --cache=false tests/index.test.ts",
+ "start": "PORT=8001 dumi dev",
+ "test": "jest --config .jest.js --cache=false",
"test:update": "jest --config .jest.js --cache=false -u",
"test-all": "sh -e ./scripts/test-all.sh",
"test-node": "npm run version && jest --config .jest.node.js --cache=false",
From 6e79cb89dc2cb776a13f477602a90dc8d2144d2b Mon Sep 17 00:00:00 2001
From: lijianan <574980606@qq.com>
Date: Thu, 24 Nov 2022 23:38:48 +0800
Subject: [PATCH 20/70] adjust text
---
components/QRCode/demo/errorlevel.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/components/QRCode/demo/errorlevel.md b/components/QRCode/demo/errorlevel.md
index 42928cc614ad..fd93bbb7a69b 100644
--- a/components/QRCode/demo/errorlevel.md
+++ b/components/QRCode/demo/errorlevel.md
@@ -1,7 +1,7 @@
## zh-CN
-纠错比例
+纠错比例。
## en-US
-Error Level
+Error Level.
From e0c1b4229cce959aae95f2f5bf913614140cf19c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com>
Date: Fri, 25 Nov 2022 18:06:14 +0800
Subject: [PATCH 21/70] rename
---
components/QRCode/__tests__/demo-extend.test.ts | 2 +-
components/QRCode/__tests__/demo.test.ts | 2 +-
components/QRCode/__tests__/image.test.ts | 2 +-
components/QRCode/demo/icon.tsx | 2 +-
components/index.tsx | 4 ++--
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/components/QRCode/__tests__/demo-extend.test.ts b/components/QRCode/__tests__/demo-extend.test.ts
index 0420f1f77339..79dea1e4faf5 100644
--- a/components/QRCode/__tests__/demo-extend.test.ts
+++ b/components/QRCode/__tests__/demo-extend.test.ts
@@ -1,3 +1,3 @@
import { extendTest } from '../../../tests/shared/demoTest';
-extendTest('QRCode');
+extendTest('qrcode');
diff --git a/components/QRCode/__tests__/demo.test.ts b/components/QRCode/__tests__/demo.test.ts
index 1929bbef5413..1cb1d77dd4fd 100644
--- a/components/QRCode/__tests__/demo.test.ts
+++ b/components/QRCode/__tests__/demo.test.ts
@@ -1,3 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';
-demoTest('QRCode');
+demoTest('qrcode');
diff --git a/components/QRCode/__tests__/image.test.ts b/components/QRCode/__tests__/image.test.ts
index 96aa383bf011..df82d405e561 100644
--- a/components/QRCode/__tests__/image.test.ts
+++ b/components/QRCode/__tests__/image.test.ts
@@ -1,5 +1,5 @@
import { imageDemoTest } from '../../../tests/shared/imageTest';
describe('QRCode image', () => {
- imageDemoTest('QRCode');
+ imageDemoTest('qrcode');
});
diff --git a/components/QRCode/demo/icon.tsx b/components/QRCode/demo/icon.tsx
index 1ac92453c7ea..77a62185921e 100644
--- a/components/QRCode/demo/icon.tsx
+++ b/components/QRCode/demo/icon.tsx
@@ -4,7 +4,7 @@ import { QRCode } from 'antd';
const App: React.FC = () => (
base
With Icon
+Custom Size
+Custom Color
Download QRCode
Error Level
diff --git a/components/qrcode/index.zh-CN.md b/components/qrcode/index.zh-CN.md
index 4c9c81a27a7c..82529ff76843 100644
--- a/components/qrcode/index.zh-CN.md
+++ b/components/qrcode/index.zh-CN.md
@@ -23,6 +23,8 @@ group:
基本使用
带 Icon 的例子
+自定义尺寸
+自定义颜色
下载二维码
纠错比例
@@ -35,5 +37,5 @@ group:
| size | 二维码图片大小 | number | 128 |
| iconSize | 二维码中图片的大小 | number | 32 |
| bgColor | 二维码背景颜色 | string | `#fff` |
-| fgColor | 二维码前景的颜色 | string | `#000` |
+| fgColor | 二维码前景颜色 | string | `#000` |
| errorLevel | 纠错码的等级 | `'L' \| 'M' \| 'Q' \| 'H' ` | `L` |
From a08f61139ade5d8870b52e2b223e664294e3ce78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com>
Date: Sun, 27 Nov 2022 16:58:54 +0800
Subject: [PATCH 31/70] add docs
---
components/qrcode/index.en-US.md | 4 +++-
components/qrcode/index.zh-CN.md | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/components/qrcode/index.en-US.md b/components/qrcode/index.en-US.md
index bd734e71b076..439bac78a319 100644
--- a/components/qrcode/index.en-US.md
+++ b/components/qrcode/index.en-US.md
@@ -9,7 +9,7 @@ group:
order: 5
---
-Components that can convert links into QR codes, and support custom color and logo.
+Components that can convert links into QR codes, and support custom color and logo. Available since `antd@5.1.0`.
Custom Size
Custom Color
Download QRCode
+Advanced Usage
Error Level
## API
diff --git a/components/qrcode/index.zh-CN.md b/components/qrcode/index.zh-CN.md
index b1e134428b57..ac49af4b3d27 100644
--- a/components/qrcode/index.zh-CN.md
+++ b/components/qrcode/index.zh-CN.md
@@ -26,6 +26,7 @@ group:
自定义尺寸
自定义颜色
下载二维码
+高级用法
纠错比例
## API
From dd3bfd957e803c590bd6a791c7611ee743fead97 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com>
Date: Mon, 28 Nov 2022 19:21:49 +0800
Subject: [PATCH 35/70] bundlesize
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index f2b8da8d7c2f..69b3ea3c2104 100644
--- a/package.json
+++ b/package.json
@@ -323,7 +323,7 @@
"bundlesize": [
{
"path": "./dist/antd.min.js",
- "maxSize": "380 kB"
+ "maxSize": "380.5 kB"
}
],
"tnpm": {
From f0dcb20a9522945e95046e0a6922b1f096432ae4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com>
Date: Wed, 30 Nov 2022 14:04:23 +0800
Subject: [PATCH 36/70] update test case
---
.../__snapshots__/index.test.tsx.snap | 24 +++++++++++--------
components/qrcode/__tests__/index.test.tsx | 23 ++++++++++++++----
2 files changed, 32 insertions(+), 15 deletions(-)
diff --git a/components/qrcode/__tests__/__snapshots__/index.test.tsx.snap b/components/qrcode/__tests__/__snapshots__/index.test.tsx.snap
index 158576899cbc..b95fdf20a2e5 100644
--- a/components/qrcode/__tests__/__snapshots__/index.test.tsx.snap
+++ b/components/qrcode/__tests__/__snapshots__/index.test.tsx.snap
@@ -2,15 +2,19 @@
exports[`QRCode test rtl render component should be rendered correctly in RTL direction 1`] = `null`;
-exports[`QRCode test should correct render 1`] = `
-+ 二维码过期 +
++ 二维码过期 +
+base
With Icon
+other statu
Custom Size
Custom Color
Download QRCode
@@ -38,9 +39,10 @@ Used when the link needs to be converted into a QR Code.
| icon | include image url (only image link are supported) | string | - |
| size | QRCode size | number | 128 |
| iconSize | include image size | number | 32 |
-| bgColor | QRCode Background Color | string | `#fff` |
-| fgColor | QRCode Foreground Color | string | `#000` |
+| color | QRCode Color | string | `#000` |
| errorLevel | Error Code Level | `'L' \| 'M' \| 'Q' \| 'H' ` | `M` |
+| status | QRCode statu | `active \| expired \| loading ` | `active` |
+| onRefresh | callback | `() => void` | - |
## FAQ
diff --git a/components/qrcode/index.tsx b/components/qrcode/index.tsx
index 174edc2bb69b..3e9847593214 100644
--- a/components/qrcode/index.tsx
+++ b/components/qrcode/index.tsx
@@ -1,21 +1,25 @@
import React, { useMemo, useContext } from 'react';
import { QRCodeCanvas } from 'qrcode.react';
import classNames from 'classnames';
+import { ReloadOutlined } from '@ant-design/icons';
import { ConfigContext } from '../config-provider';
import type { ConfigConsumerProps } from '../config-provider';
import type { QRCodeProps, QRPropsCanvas } from './interface';
import warning from '../_util/warning';
import useStyle from './style/index';
+import Spin from '../spin';
+import Button from '../button';
const QRCode: React.FC二维码过期
+ {typeof onRefresh === 'function' && ( +基本使用
带 Icon 的例子
+不同的状态
自定义尺寸
自定义颜色
下载二维码
@@ -33,15 +34,16 @@ group:
> 自 `antd@5.1.0` 版本开始提供该组件。
-| 参数 | 说明 | 类型 | 默认值 |
-| :--------- | :--------------------------------------- | :-------------------------- | :----- |
-| value | 扫描后的地址 | string | - |
-| icon | 二维码中图片的地址(目前只支持图片地址) | string | - |
-| size | 二维码图片大小 | number | 128 |
-| iconSize | 二维码中图片的大小 | number | 32 |
-| bgColor | 二维码背景颜色 | string | `#fff` |
-| fgColor | 二维码前景颜色 | string | `#000` |
-| errorLevel | 二维码的纠错等级 | `'L' \| 'M' \| 'Q' \| 'H' ` | `M` |
+| 参数 | 说明 | 类型 | 默认值 |
+| :-- | :-- | :-- | :-- |
+| value | 扫描后的地址 | string | - |
+| icon | 二维码中图片的地址(目前只支持图片地址) | string | - |
+| size | 二维码大小 | number | 160 |
+| iconSize | 二维码中图片的大小 | number | 40 |
+| color | 二维码颜色 | string | `#000` |
+| errorLevel | 二维码纠错等级 | `'L' \| 'M' \| 'Q' \| 'H' ` | `M` |
+| status | 二维码状态 | `active \| expired \| loading ` | `active` |
+| onRefresh | 点击"点击刷新"的回调 | `() => void` | - |
## FAQ
diff --git a/components/qrcode/interface.ts b/components/qrcode/interface.ts
index 20c48d5c2614..0e7fcfcc93f5 100644
--- a/components/qrcode/interface.ts
+++ b/components/qrcode/interface.ts
@@ -13,8 +13,7 @@ interface QRProps {
value: string;
size?: number;
level?: string;
- bgColor?: string;
- fgColor?: string;
+ color?: string;
style?: CSSProperties;
includeMargin?: boolean;
imageSettings?: ImageSettings;
@@ -28,4 +27,10 @@ export interface QRCodeProps extends QRProps {
icon?: string;
iconSize?: number;
errorLevel?: 'L' | 'M' | 'Q' | 'H';
+ status?: 'active' | 'expired' | 'loading';
+ onRefresh?: () => void;
+ // statusRender?: (
+ // status: QRCodeProps['status'],
+ // onRefresh: QRCodeProps['onRefresh'],
+ // ) => React.ReactNode;
}
diff --git a/components/qrcode/style/index.ts b/components/qrcode/style/index.ts
index 277807c7f334..d8086a02297d 100644
--- a/components/qrcode/style/index.ts
+++ b/components/qrcode/style/index.ts
@@ -9,9 +9,30 @@ const genQRCodeStyle: GenerateStyle二维码过期
- {typeof onRefresh === 'function' && ( -{locale.expired}
+ {typeof onRefresh === 'function' && ( +- 二维码过期 + QRCode is expired
- 二维码过期 + QRCode is expired
QRCode is expired diff --git a/components/qrcode/__tests__/__snapshots__/demo.test.ts.snap b/components/qrcode/__tests__/__snapshots__/demo.test.ts.snap index 85fea44c0fb1..238e5e018fb8 100644 --- a/components/qrcode/__tests__/__snapshots__/demo.test.ts.snap +++ b/components/qrcode/__tests__/__snapshots__/demo.test.ts.snap @@ -265,7 +265,7 @@ exports[`renders ./components/qrcode/demo/status.tsx correctly 1`] = ` style="width:160px;height:160px" >
QRCode is expired
From 92bbcbfa4d45003b8e8bac651d4fc14deb1a1f7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com>
Date: Thu, 1 Dec 2022 14:44:18 +0800
Subject: [PATCH 45/70] fix demo
---
components/qrcode/index.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/qrcode/index.tsx b/components/qrcode/index.tsx
index 63a5907871e8..dba1fb444356 100644
--- a/components/qrcode/index.tsx
+++ b/components/qrcode/index.tsx
@@ -63,7 +63,7 @@ const QRCode: React.FC