From 284fce48710ef32d920ac68a21be359c3080d514 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Tue, 1 Apr 2025 07:50:38 +0800 Subject: [PATCH] site: add componentName for SemanticPreview (#53362) * site: add componentName for SemanticPreview * site: add componentName for SemanticPreview * chore: fix --- components/alert/demo/_semantic.tsx | 1 + components/anchor/demo/_semantic.tsx | 4 +++- components/auto-complete/demo/_semantic.tsx | 1 + components/badge/demo/_semantic_ribbon.tsx | 4 +++- components/breadcrumb/demo/_semantic.tsx | 4 +++- components/calendar/demo/_semantic.tsx | 1 + components/card/demo/_semantic_meta.tsx | 2 +- components/cascader/demo/_semantic.tsx | 13 ++++++------ components/checkbox/demo/_semantic.tsx | 1 + .../color-picker/__tests__/index.test.tsx | 4 ++-- components/color-picker/demo/_semantic.tsx | 4 +++- components/descriptions/demo/_semantic.tsx | 20 +++++++++---------- components/form/__tests__/index.test.tsx | 7 +++++-- components/form/demo/_semantic.tsx | 2 +- components/image/demo/_semantic.tsx | 1 + components/masonry/demo/_semantic.tsx | 1 + components/mentions/demo/_semantic.tsx | 1 + components/message/demo/_semantic.tsx | 1 + components/notification/demo/_semantic.tsx | 1 + components/pagination/demo/_semantic.tsx | 1 + components/popconfirm/demo/_semantic.tsx | 16 ++++++++------- components/popover/demo/_semantic.tsx | 15 ++++++++------ components/radio/demo/_semantic.tsx | 1 + components/result/demo/_semantic.tsx | 1 + components/segmented/demo/_semantic.tsx | 1 + components/select/demo/_semantic.tsx | 1 + components/skeleton/demo/_semantic.tsx | 1 + .../skeleton/demo/_semantic_element.tsx | 1 + components/spin/demo/_semantic.tsx | 4 +++- components/spin/demo/_semantic_fullscreen.tsx | 9 ++++----- components/splitter/demo/_semantic.tsx | 6 +++--- components/statistic/demo/_semantic.tsx | 5 +++-- components/switch/demo/_semantic.tsx | 1 + components/tabs/demo/_semantic.tsx | 5 ++++- components/tag/demo/_semantic.tsx | 1 + components/tag/demo/_semantic_group.tsx | 1 + components/timeline/demo/_semantic.tsx | 1 + components/tooltip/demo/_semantic.tsx | 15 ++++++++------ components/tour/demo/_semantic.tsx | 18 +++++++---------- components/tree-select/demo/_semantic.tsx | 8 +++++--- components/tree/demo/_semantic.tsx | 1 + components/upload/demo/_semantic.tsx | 4 +++- 42 files changed, 117 insertions(+), 73 deletions(-) diff --git a/components/alert/demo/_semantic.tsx b/components/alert/demo/_semantic.tsx index 930015e394..d637194400 100644 --- a/components/alert/demo/_semantic.tsx +++ b/components/alert/demo/_semantic.tsx @@ -27,6 +27,7 @@ const App: React.FC = () => { const [locale] = useLocale(locales); return ( { +const Block: React.FC> = (props) => { return ( { const [locale] = useLocale(locales); return ( { return ( { +const BlockList: React.FC> = (props) => { return (
@@ -33,6 +34,7 @@ const App: React.FC = () => { const [locale] = useLocale(locales); return ( { +const Block: React.FC> = (props) => { return ( { const [locale] = useLocale(locales); return ( { const [locale] = useLocale(locales); return ( = (props) => { const divRef = React.useRef(null); - return (
@@ -44,6 +43,7 @@ const App: React.FC = () => { const [locale] = useLocale(locales); return ( { +const Block: React.FC>> = (props) => { const divRef = React.useRef(null); const [value, setValue] = React.useState(['contributors', 'aojunhao123']); - const onChange = (newValue: string[]) => { - setValue(newValue); - }; return (
{ height: 70, }, }} - getPopupContainer={() => divRef.current} + getPopupContainer={() => divRef.current!} value={value} - onChange={onChange} + onChange={setValue} options={options} placement="bottomLeft" />
); }; + const App: React.FC = () => { const [locale] = useLocale(locales); - return ( { const [locale] = useLocale(locales); return ( { }); it('Controlled string value should work with allowClear correctly', async () => { - const Demo = (props: any) => { + const Demo: React.FC> = (props) => { const [color, setColor] = useState(generateColor('#FF0000')); useEffect(() => { @@ -737,7 +737,7 @@ describe('ColorPicker', () => { }); it('Controlled value should work with allowClear correctly', async () => { - const Demo = (props: any) => { + const Demo: React.FC> = (props) => { const [color, setColor] = useState(generateColor('red')); useEffect(() => { diff --git a/components/color-picker/demo/_semantic.tsx b/components/color-picker/demo/_semantic.tsx index ef1b2318b2..7d58d1a3f4 100644 --- a/components/color-picker/demo/_semantic.tsx +++ b/components/color-picker/demo/_semantic.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import type { ColorPickerProps } from 'antd'; import { ColorPicker } from 'antd'; import SemanticPreview from '../../../.dumi/components/SemanticPreview'; @@ -15,7 +16,7 @@ const locales = { }, }; -const Block: React.FC = (props: any) => { +const Block: React.FC> = (props) => { const divRef = React.useRef(null); return (
@@ -34,6 +35,7 @@ const App: React.FC = () => { const [locale] = useLocale(locales); return ( = (props: any) => { +const BlockList: React.FC> = (props) => { + const { children, ...rest } = props; const divRef = React.useRef(null); const [bordered, setBordered] = React.useState(false); - - const handleBorderChange = (checked: boolean) => { - setBordered(checked); - }; - return (
- Toggle Border + + Toggle Border Edit} bordered={bordered} - {...props} - /> + {...rest} + > + {children} +
); }; diff --git a/components/form/__tests__/index.test.tsx b/components/form/__tests__/index.test.tsx index efb0602cee..232647ce57 100644 --- a/components/form/__tests__/index.test.tsx +++ b/components/form/__tests__/index.test.tsx @@ -19,6 +19,7 @@ import ConfigProvider from '../../config-provider'; import DatePicker from '../../date-picker'; import Drawer from '../../drawer'; import Input from '../../input'; +import type { InputProps } from '../../input'; import InputNumber from '../../input-number'; import zhCN from '../../locale/zh_CN'; import Modal from '../../modal'; @@ -565,7 +566,9 @@ describe('Form', () => { return ; }); - const NormalInput = (props: any) => ; + const NormalInput: React.FC>> = (props) => ( + + ); const { getByRole, getAllByRole } = render(
@@ -2249,7 +2252,7 @@ describe('Form', () => { it('validate status should be change in order', async () => { const onChange = jest.fn(); - const CustomInput = (props: any) => { + const CustomInput: React.FC> = (props) => { const { status } = Form.Item.useStatus(); useEffect(() => { onChange(status); diff --git a/components/form/demo/_semantic.tsx b/components/form/demo/_semantic.tsx index 93990ddbab..dc9c308b87 100644 --- a/components/form/demo/_semantic.tsx +++ b/components/form/demo/_semantic.tsx @@ -21,6 +21,7 @@ const App: React.FC = () => { const [locale] = useLocale(locales); return ( { > - { const [locale] = useLocale(locales); return ( { const [locale] = useLocale(locales); return ( { const [locale] = useLocale(locales); return ( { const [locale] = useLocale(locales); return ( { const [locale] = useLocale(locales); return ( { const [locale] = useLocale(locales); return ( = (props: any) => { +const BlockList: React.FC> = (props) => { + const { children, ...rest } = props; const divRef = React.useRef(null); - return (
divRef.current} - {...props} - /> + getPopupContainer={() => divRef.current!} + {...rest} + > + {children} +
); }; @@ -42,7 +44,7 @@ const App: React.FC = () => { { name: 'body', desc: locale.body, version: '5.23.0' }, ]} > - +
); }; diff --git a/components/popover/demo/_semantic.tsx b/components/popover/demo/_semantic.tsx index 6b9c5a2188..a19b152216 100644 --- a/components/popover/demo/_semantic.tsx +++ b/components/popover/demo/_semantic.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { Popover } from 'antd'; +import type { PopoverProps } from 'antd'; import SemanticPreview from '../../../.dumi/components/SemanticPreview'; import useLocale from '../../../.dumi/hooks/useLocale'; @@ -15,19 +16,21 @@ const locales = { }, }; -const BlockList: React.FC = (props: any) => { +const BlockList: React.FC> = (props) => { + const { children, ...rest } = props; const divRef = React.useRef(null); - return (
divRef.current} - {...props} - /> + getPopupContainer={() => divRef.current!} + {...rest} + > + {children} +
); }; diff --git a/components/radio/demo/_semantic.tsx b/components/radio/demo/_semantic.tsx index a6612ab7a0..0d0fd2f294 100644 --- a/components/radio/demo/_semantic.tsx +++ b/components/radio/demo/_semantic.tsx @@ -21,6 +21,7 @@ const App: React.FC = () => { const [locale] = useLocale(locales); return ( { const [locale] = useLocale(locales); return ( { const [locale] = useLocale(locales); return ( { return ( { const [locale] = useLocale(locales); return ( { return ( { +const SpinBlock: React.FC> = (props) => { return (
{ return ( { +const SpinBlock: React.FC> = (props) => { return (
@@ -34,9 +33,9 @@ const SpinBlock = (props: any) => { const App: React.FC = () => { const [locale] = useLocale(locales); - return ( { +const Block: React.FC> = (props) => { return ( { - @@ -38,9 +38,9 @@ const Block: React.FC = (props: any) => { const App: React.FC = () => { const [locale] = useLocale(locales); - return ( = (props: any) => { +const BlockList: React.FC> = (props) => { const divRef = React.useRef(null); - return (
{ const [locale] = useLocale(locales); return ( { const [locale] = useLocale(locales); return ( { + +const Block: React.FC> = (props) => { return ( { const [locale] = useLocale(locales); return ( { const [locale] = useLocale(locales); return ( { const [locale] = useLocale(locales); return ( { const [locale] = useLocale(locales); return ( = (props: any) => { +const BlockList: React.FC> = (props) => { + const { children, ...rest } = props; const divRef = React.useRef(null); - return (
divRef.current} - {...props} - /> + getPopupContainer={() => divRef.current!} + {...rest} + > + {children} +
); }; diff --git a/components/tour/demo/_semantic.tsx b/components/tour/demo/_semantic.tsx index 59ed941165..1b961498c6 100644 --- a/components/tour/demo/_semantic.tsx +++ b/components/tour/demo/_semantic.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { Button, Tour } from 'antd'; +import type { TourProps } from 'antd'; import SemanticPreview from '../../../.dumi/components/SemanticPreview'; import useLocale from '../../../.dumi/hooks/useLocale'; @@ -33,7 +34,7 @@ const locales = { }, }; -const BlockList: React.FC = (props: any) => { +const BlockList: React.FC> = (props) => { const [open, setOpen] = React.useState(true); const createBtnRef = React.useRef(null); return ( @@ -48,12 +49,7 @@ const BlockList: React.FC = (props: any) => { overflow: 'hidden', }} > - = (props: any) => { zIndex={1} open={open} defaultCurrent={0} - getPopupContainer={false} + getPopupContainer={false as unknown as TourProps['getPopupContainer']} onClose={() => setOpen(false)} steps={[ { @@ -73,13 +69,13 @@ const BlockList: React.FC = (props: any) => { src="https://user-images.githubusercontent.com/5378891/197385811-55df8480-7ff4-44bd-9d43-a7dade598d70.png" /> ), - target: () => createBtnRef.current, + target: () => createBtnRef.current!, mask: true, }, { title: 'Save', description: 'Save your changes.', - target: () => createBtnRef.current, + target: () => createBtnRef.current!, }, ]} /> @@ -89,9 +85,9 @@ const BlockList: React.FC = (props: any) => { const App: React.FC = () => { const [locale] = useLocale(locales); - return ( { +const Block: React.FC> = (props) => { const divRef = React.useRef(null); const [value, setValue] = React.useState(); const onChange = (newValue: string) => { @@ -53,7 +54,7 @@ const Block = (props: any) => {
divRef.current} + getPopupContainer={() => divRef.current!} showSearch placement="bottomLeft" prefix="Prefix" @@ -77,11 +78,12 @@ const Block = (props: any) => {
); }; + const App: React.FC = () => { const [locale] = useLocale(locales); - return ( { const [locale] = useLocale(locales); return ( ( +const Block: React.FC>> = (props) => ( ); + const App: React.FC = () => { const [locale] = useLocale(locales); return (