From 0f95fa62214a0ccef42a958e362196559b6c52ea Mon Sep 17 00:00:00 2001 From: Meetacoo <37367461+Meetacoo@users.noreply.github.com> Date: Tue, 11 Feb 2025 10:24:59 +0800 Subject: [PATCH 1/4] feat: Update Dialog.types.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加是否展示取消按钮的参数 --- packages/bui-core/src/Dialog/Dialog.types.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/bui-core/src/Dialog/Dialog.types.ts b/packages/bui-core/src/Dialog/Dialog.types.ts index aec16f25..60a3769d 100644 --- a/packages/bui-core/src/Dialog/Dialog.types.ts +++ b/packages/bui-core/src/Dialog/Dialog.types.ts @@ -42,6 +42,10 @@ export interface DialogProps extends ModalProps { * 取消文本内容 */ cancelText?: ReactNode; + /** + * 是否展示取消按钮 + */ + showCancel?: boolean; /** * theme 主题定制 */ From 5e5dc72738ea5f187fbe085747bd122122c11944 Mon Sep 17 00:00:00 2001 From: Meetacoo <37367461+Meetacoo@users.noreply.github.com> Date: Tue, 11 Feb 2025 18:06:27 +0800 Subject: [PATCH 2/4] Update Dialog.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit showCancel为false时不展示取消按钮 --- packages/bui-core/src/Dialog/Dialog.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/bui-core/src/Dialog/Dialog.tsx b/packages/bui-core/src/Dialog/Dialog.tsx index 2bd57bcd..ce763e5d 100644 --- a/packages/bui-core/src/Dialog/Dialog.tsx +++ b/packages/bui-core/src/Dialog/Dialog.tsx @@ -20,6 +20,7 @@ const Dialog = React.forwardRef((props, ref) => { type, confirmText, cancelText, + showCancel = true, placeholder, InputProps, className, @@ -40,13 +41,15 @@ const Dialog = React.forwardRef((props, ref) => { }); const footerNode = (
- + {showCancel ? ( + + ) : null} + ); }; @@ -69,10 +73,11 @@ export default () => { const theme = useTheme(); const [dialog, contextHolder] = Dialog.useDialog(); - const handleClickConfirm = async () => { + const handleClickConfirm = async (showCancel) => { const res = await dialog({ header: '标题', message: '这是描述内容', + showCancel, }); if (res) { Toast({ message: '点击了确认', position: 'bottom' }); @@ -97,6 +102,9 @@ export default () => { confirm + ); @@ -218,6 +226,16 @@ export default () => { > 自定义确认按钮文本 + ); @@ -278,14 +296,15 @@ export default () => { #### DialogOptions -| 属性 | 说明 | 类型 | 默认值 | -| ----------- | ------------ | ------------------------------------------ | ------ | -| header | 自定义页头 | `React.ReactNode` | - | -| message | 自定义消息 | `React.ReactNode` | - | -| confirmText | 确认按钮文案 | `React.ReactNode` | 确认 | -| cancelText | 取消按钮文案 | `React.ReactNode` | 取消 | -| onConfirm | 确定按钮回调 | `(val?: string) => void \| Promise;` | - | -| onCancel | 取消按钮回调 | `() =>void \| Promise` | - | +| 属性 | 说明 | 类型 | 默认值 | +| ----------- | ---------------- | ------------------------------------------ | ------ | +| header | 自定义页头 | `React.ReactNode` | - | +| message | 自定义消息 | `React.ReactNode` | - | +| confirmText | 确认按钮文案 | `React.ReactNode` | 确认 | +| cancelText | 取消按钮文案 | `React.ReactNode` | 取消 | +| onConfirm | 确定按钮回调 | `(val?: string) => void \| Promise;` | - | +| onCancel | 取消按钮回调 | `() =>void \| Promise` | - | +| showCancel | 是否展示取消按钮 | boolean | true | `ConfirmOptions`的取值同`DialogOptions` From b1ce82152856c0cb5896df3e974a9fcb42b3b59e Mon Sep 17 00:00:00 2001 From: Meetacoo <37367461+Meetacoo@users.noreply.github.com> Date: Tue, 11 Feb 2025 18:07:25 +0800 Subject: [PATCH 4/4] Update index.en-US.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加英文示例 --- packages/bui-core/src/Dialog/index.en-US.md | 37 +++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/packages/bui-core/src/Dialog/index.en-US.md b/packages/bui-core/src/Dialog/index.en-US.md index 76eee815..af427aa0 100644 --- a/packages/bui-core/src/Dialog/index.en-US.md +++ b/packages/bui-core/src/Dialog/index.en-US.md @@ -21,7 +21,7 @@ import { Stack, Button, Dialog, Toast } from '@bifrostui/react'; import React from 'react'; export default () => { - const handleClickConfirm = async () => { + const handleClickConfirm = async (showCancel) => { const res = await Dialog({ header: '标题', message: '这是描述内容', @@ -47,6 +47,9 @@ export default () => { confirm + ); }; @@ -69,7 +72,7 @@ export default () => { const theme = useTheme(); const [dialog, contextHolder] = Dialog.useDialog(); - const handleClickConfirm = async () => { + const handleClickConfirm = async (showCancel) => { const res = await dialog({ header: '标题', message: '这是描述内容', @@ -97,6 +100,9 @@ export default () => { confirm + ); @@ -218,6 +224,16 @@ export default () => { > 自定义确认按钮文本 + ); @@ -278,14 +294,15 @@ export default () => { #### DialogOptions -| attribute | explain | type | Default value | -| ----------- | ----------------------- | ----------------------------------------- | ------------- | -| header | custom header | `React.ReactNode` | - | -| message | Custom message | `React.ReactNode` | - | -| confirmText | Confirm button copy | `React.ReactNode` | confirm | -| cancelText | Cancel button text | `React.ReactNode` | cancel | -| onConfirm | Confirm button callback | `(val?: string) => void \|Promise;` | - | -| onCancel | Cancel button callback | `() =>void \|Promise` | - | +| attribute | explain | type | Default value | +| ----------- | ------------------------------------ | ----------------------------------------- | ------------- | +| header | custom header | `React.ReactNode` | - | +| message | Custom message | `React.ReactNode` | - | +| confirmText | Confirm button copy | `React.ReactNode` | confirm | +| cancelText | Cancel button text | `React.ReactNode` | cancel | +| onConfirm | Confirm button callback | `(val?: string) => void \|Promise;` | - | +| onCancel | Cancel button callback | `() =>void \|Promise` | - | +| showCancel | Whether to display the cancel button | boolean | true | The value of ConfirmOptions is the same as that of DialogOptions