From dd79cf8624e705c36e52ce865333a75a6157d5e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=9D=B0?= Date: Wed, 6 Mar 2024 10:24:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=B9=E7=AA=97Modal=E7=9A=84?= =?UTF-8?q?=E5=87=A0=E4=B8=AA=E6=96=B9=E6=B3=95=E7=9A=84title=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E6=94=AF=E6=8C=81=E4=BC=A0=E5=85=A5=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/cool-melons-grab.md | 5 +++++ .../react-native/src/modal/alert/AlertContainer.tsx | 10 +++++++--- .../src/modal/confirm/ConfirmContainer.tsx | 10 +++++++--- .../react-native/src/modal/prompt/PromptContainer.tsx | 10 +++++++--- packages/react-native/src/modal/tip/TipContainer.tsx | 10 +++++++--- packages/react-native/src/modal/type.ts | 2 +- 6 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 .changeset/cool-melons-grab.md diff --git a/.changeset/cool-melons-grab.md b/.changeset/cool-melons-grab.md new file mode 100644 index 0000000000..6edae26e9d --- /dev/null +++ b/.changeset/cool-melons-grab.md @@ -0,0 +1,5 @@ +--- +'@td-design/react-native': patch +--- + +feat: Modal的几个方法的title属性支持传入自定义组件 diff --git a/packages/react-native/src/modal/alert/AlertContainer.tsx b/packages/react-native/src/modal/alert/AlertContainer.tsx index ef03ccf501..19bc867384 100644 --- a/packages/react-native/src/modal/alert/AlertContainer.tsx +++ b/packages/react-native/src/modal/alert/AlertContainer.tsx @@ -69,9 +69,13 @@ const AlertContainer: FC< {!!icon && {icon}} {!!title && ( - - {title} - + {typeof title === 'string' ? ( + + {title} + + ) : ( + title + )} )} {typeof content === 'string' ? ( diff --git a/packages/react-native/src/modal/confirm/ConfirmContainer.tsx b/packages/react-native/src/modal/confirm/ConfirmContainer.tsx index cd87cdeb6b..9b8f05f569 100644 --- a/packages/react-native/src/modal/confirm/ConfirmContainer.tsx +++ b/packages/react-native/src/modal/confirm/ConfirmContainer.tsx @@ -39,9 +39,13 @@ const ConfirmContainer: FC< {!!icon && {icon}} - - {title} - + {typeof title === 'string' ? ( + + {title} + + ) : ( + title + )} {typeof content === 'string' ? ( diff --git a/packages/react-native/src/modal/prompt/PromptContainer.tsx b/packages/react-native/src/modal/prompt/PromptContainer.tsx index f01c980100..72f71b5363 100644 --- a/packages/react-native/src/modal/prompt/PromptContainer.tsx +++ b/packages/react-native/src/modal/prompt/PromptContainer.tsx @@ -46,9 +46,13 @@ const PromptContainer: FC< - - {title} - + {typeof title === 'string' ? ( + + {title} + + ) : ( + title + )} {typeof content === 'string' ? ( diff --git a/packages/react-native/src/modal/tip/TipContainer.tsx b/packages/react-native/src/modal/tip/TipContainer.tsx index 1ef71effd4..c0bc76cfa3 100644 --- a/packages/react-native/src/modal/tip/TipContainer.tsx +++ b/packages/react-native/src/modal/tip/TipContainer.tsx @@ -57,9 +57,13 @@ const TipContainer: FC< {!!title && ( - - {title} - + {typeof title === 'string' ? ( + + {title} + + ) : ( + title + )} )} {typeof content === 'string' ? ( diff --git a/packages/react-native/src/modal/type.ts b/packages/react-native/src/modal/type.ts index d82f2e8dce..7be2a1b65d 100644 --- a/packages/react-native/src/modal/type.ts +++ b/packages/react-native/src/modal/type.ts @@ -34,7 +34,7 @@ export interface AlertProps { /** 警示性图标 */ icon?: ReactNode; /** 标题 */ - title: string; + title: ReactNode; /** 内容 */ content?: ReactNode; /** 按钮文本 */