Skip to content

Commit e1a048d

Browse files
committed
chore: update demo and docs
1 parent 796c594 commit e1a048d

File tree

6 files changed

+48
-25
lines changed

6 files changed

+48
-25
lines changed

packages/components/dialog/_example/modal.tsx

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,46 @@ import React, { useState } from 'react';
22
import { Button, Dialog, Space } from 'tdesign-react';
33

44
export default function NotModalExample() {
5-
const [modelessAndDraggable, setModelessAndDraggable] = useState(false);
6-
const [modeless, setModeless] = useState(false);
75
const [modal, setModal] = useState(false);
6+
const [draggableModal, setDraggableModal] = useState(false);
7+
const [draggableModeless, setDraggableModeless] = useState(false);
8+
const [modeless, setModeless] = useState(false);
89

910
return (
1011
<>
1112
<Space>
12-
<Button theme="primary" variant="outline" onClick={() => setModelessAndDraggable(true)}>
13-
非模态对话框(可拖拽)
13+
<Button theme="primary" onClick={() => setModal(true)}>
14+
普通对话框(不可拖拽)
15+
</Button>
16+
<Button theme="primary" variant="outline" onClick={() => setDraggableModal(true)}>
17+
普通对话框(可拖拽)
1418
</Button>
1519
<Button theme="primary" onClick={() => setModeless(true)}>
1620
非模态对话框(不可拖拽)
1721
</Button>
18-
<Button theme="primary" onClick={() => setModal(true)}>
19-
普通对话框(不可拖拽
22+
<Button theme="primary" variant="outline" onClick={() => setDraggableModeless(true)}>
23+
非模态对话框(可拖拽
2024
</Button>
2125
</Space>
2226

23-
<Dialog
24-
mode="modeless"
25-
header="非模态对话框(可拖拽)"
26-
draggable
27-
visible={modelessAndDraggable}
28-
onClose={() => setModelessAndDraggable(false)}
29-
>
27+
<Dialog header="普通对话框(不可拖拽)" visible={modal} onClose={() => setModal(false)}>
28+
<p>This is a dialog</p>
29+
</Dialog>
30+
31+
<Dialog header="普通对话框(可拖拽)" draggable visible={draggableModal} onClose={() => setDraggableModal(false)}>
3032
<p>This is a dialog</p>
3133
</Dialog>
34+
3235
<Dialog mode="modeless" header="非模态对话框(不可拖拽)" visible={modeless} onClose={() => setModeless(false)}>
3336
<p>This is a dialog</p>
3437
</Dialog>
35-
<Dialog header="普通对话框(不可拖拽)" visible={modal} onClose={() => setModal(false)}>
38+
<Dialog
39+
mode="modeless"
40+
header="非模态对话框(可拖拽)"
41+
draggable
42+
visible={draggableModeless}
43+
onClose={() => setDraggableModeless(false)}
44+
>
3645
<p>This is a dialog</p>
3746
</Dialog>
3847
</>

packages/components/dialog/dialog.en-US.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
:: BASE_DOC ::
22

33
## API
4+
45
### DialogCard Props
56

67
name | type | default | description | required
@@ -28,9 +29,8 @@ confirmLoading | Boolean | undefined | confirm button loading status | N
2829
confirmOnEnter | Boolean | - | confirm on enter | N
2930
destroyOnClose | Boolean | false | \- | N
3031
dialogClassName | String | - | \- | N
31-
draggable | Boolean | false | \- | N
32+
draggable | Boolean | false | not effective in `full-screen` mode | N
3233
footer | TNode | true | Typescript: `boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
33-
forceRender | Boolean | false | to force render Dialog, deprecated, please use `lazy` compatibility support | N
3434
header | TNode | true | Typescript: `string \| boolean \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
3535
lazy | Boolean | true | Enable Dialog lazy loading, the contents of the dialog box are not rendered when enable | N
3636
mode | String | modal | options: modal/modeless/full-screen | N
@@ -79,7 +79,7 @@ name | params | default | description
7979
-- | -- | -- | --
8080
options | \- | - | Typescript: `DialogOptions`
8181

82-
插件返回值:`DialogInstance`
82+
Return value: `DialogInstance`
8383

8484
### dialog.confirm 或 DialogPlugin.confirm
8585

packages/components/dialog/dialog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
{{ plugin }}
2424
## API
25+
2526
### DialogCard Props
2627

2728
名称 | 类型 | 默认值 | 描述 | 必传
@@ -49,9 +50,8 @@ confirmLoading | Boolean | undefined | 确认按钮加载状态 | N
4950
confirmOnEnter | Boolean | - | 是否在按下回车键时,触发确认事件 | N
5051
destroyOnClose | Boolean | false | 是否在关闭弹框的时候销毁子元素 | N
5152
dialogClassName | String | - | 弹框元素类名,示例:'t-class-dialog-first t-class-dialog-second' | N
52-
draggable | Boolean | false | 对话框是否可以拖拽(仅在非模态对话框时有效) | N
53+
draggable | Boolean | false | 是否可以拖拽(对全屏对话框无效) | N
5354
footer | TNode | true | 底部操作栏,默认会有“确认”和“取消”两个按钮。值为 true 显示默认操作按钮,值为 false 不显示任何内容,值类型为 Function 表示自定义底部内容。TS 类型:`boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
54-
forceRender | Boolean | false | 是否强制渲染Dialog,已废弃,请更为使用 `lazy` 兼容支持 | N
5555
header | TNode | true | 头部内容。值为 true 显示空白头部,值为 false 不显示任何内容,值类型为 string 则直接显示值,值类型为 Function 表示自定义头部内容。TS 类型:`string \| boolean \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N
5656
lazy | Boolean | true | 是否启用对话框懒加载,启用时对话框内的内容不渲染 | N
5757
mode | String | modal | 对话框类型,有 3 种:模态对话框、非模态对话框、全屏对话框。弹出「模态对话框」时,只能操作对话框里面的内容,不能操作其他内容。弹出「非模态对话框」时,则可以操作页面内所有内容。「普通对话框」是指没有脱离文档流的对话框,可以在这个基础上开发更多的插件。可选项:modal/modeless/full-screen | N

packages/components/dialog/type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface TdDialogProps {
6161
*/
6262
dialogClassName?: string;
6363
/**
64-
* 对话框是否可以拖拽(仅在非模态对话框时有效
64+
* 是否可以拖拽(对全屏对话框无效
6565
* @default false
6666
*/
6767
draggable?: boolean;

test/snap/__snapshots__/csr.test.jsx.snap

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43614,6 +43614,20 @@ exports[`csr snapshot test > csr test packages/components/dialog/_example/modal.
4361443614
class="t-space t-space-horizontal"
4361543615
style="gap: 16px;"
4361643616
>
43617+
<div
43618+
class="t-space-item"
43619+
>
43620+
<button
43621+
class="t-button t-button--theme-primary t-button--variant-base"
43622+
type="button"
43623+
>
43624+
<span
43625+
class="t-button__text"
43626+
>
43627+
普通对话框(不可拖拽)
43628+
</span>
43629+
</button>
43630+
</div>
4361743631
<div
4361843632
class="t-space-item"
4361943633
>
@@ -43624,7 +43638,7 @@ exports[`csr snapshot test > csr test packages/components/dialog/_example/modal.
4362443638
<span
4362543639
class="t-button__text"
4362643640
>
43627-
非模态对话框(可拖拽)
43641+
普通对话框(可拖拽)
4362843642
</span>
4362943643
</button>
4363043644
</div>
@@ -43646,13 +43660,13 @@ exports[`csr snapshot test > csr test packages/components/dialog/_example/modal.
4364643660
class="t-space-item"
4364743661
>
4364843662
<button
43649-
class="t-button t-button--theme-primary t-button--variant-base"
43663+
class="t-button t-button--theme-primary t-button--variant-outline"
4365043664
type="button"
4365143665
>
4365243666
<span
4365343667
class="t-button__text"
4365443668
>
43655-
普通对话框(不可拖拽
43669+
非模态对话框(可拖拽
4365643670
</span>
4365743671
</button>
4365843672
</div>
@@ -149861,7 +149875,7 @@ exports[`ssr snapshot test > ssr test packages/components/dialog/_example/custom
149861149875

149862149876
exports[`ssr snapshot test > ssr test packages/components/dialog/_example/icon.tsx 1`] = `"<button type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">Open Modal</span></button>"`;
149863149877

149864-
exports[`ssr snapshot test > ssr test packages/components/dialog/_example/modal.tsx 1`] = `"<div style="gap:16px" class="t-space t-space-horizontal"><div class="t-space-item"><button type="button" class="t-button t-button--theme-primary t-button--variant-outline"><span class="t-button__text">非模态对话框(可拖拽)</span></button></div><div class="t-space-item"><button type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">非模态对话框(不可拖拽)</span></button></div><div class="t-space-item"><button type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">普通对话框(不可拖拽)</span></button></div></div>"`;
149878+
exports[`ssr snapshot test > ssr test packages/components/dialog/_example/modal.tsx 1`] = `"<div style="gap:16px" class="t-space t-space-horizontal"><div class="t-space-item"><button type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">普通对话框(不可拖拽)</span></button></div><div class="t-space-item"><button type="button" class="t-button t-button--theme-primary t-button--variant-outline"><span class="t-button__text">普通对话框(可拖拽)</span></button></div><div class="t-space-item"><button type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">非模态对话框(不可拖拽)</span></button></div><div class="t-space-item"><button type="button" class="t-button t-button--theme-primary t-button--variant-outline"><span class="t-button__text">非模态对话框(可拖拽)</span></button></div></div>"`;
149865149879

149866149880
exports[`ssr snapshot test > ssr test packages/components/dialog/_example/plugin.tsx 1`] = `"<div style="gap:16px" class="t-space t-space-vertical"><div class="t-space-item"><p>函数调用方式一:DialogPlugin(options)</p></div><div class="t-space-item"><p>函数调用方式二:DialogPlugin.confirm(options)</p></div><div class="t-space-item"><p>函数调用方式三:DialogPlugin.alert(options)</p></div><div class="t-space-item"><div><button style="margin-right:16px" type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">dialog</span></button><button style="margin-right:16px" type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">handleDialogNode</span></button><button style="margin-right:16px" type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">confirm</span></button><button style="margin-right:16px" type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">alert</span></button><button style="margin-right:16px" type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">DialogPlugin.confirm</span></button></div></div></div>"`;
149867149881

test/snap/__snapshots__/ssr.test.jsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ exports[`ssr snapshot test > ssr test packages/components/dialog/_example/custom
340340

341341
exports[`ssr snapshot test > ssr test packages/components/dialog/_example/icon.tsx 1`] = `"<button type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">Open Modal</span></button>"`;
342342

343-
exports[`ssr snapshot test > ssr test packages/components/dialog/_example/modal.tsx 1`] = `"<div style="gap:16px" class="t-space t-space-horizontal"><div class="t-space-item"><button type="button" class="t-button t-button--theme-primary t-button--variant-outline"><span class="t-button__text">非模态对话框(可拖拽)</span></button></div><div class="t-space-item"><button type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">非模态对话框(不可拖拽)</span></button></div><div class="t-space-item"><button type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">普通对话框(不可拖拽)</span></button></div></div>"`;
343+
exports[`ssr snapshot test > ssr test packages/components/dialog/_example/modal.tsx 1`] = `"<div style="gap:16px" class="t-space t-space-horizontal"><div class="t-space-item"><button type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">普通对话框(不可拖拽)</span></button></div><div class="t-space-item"><button type="button" class="t-button t-button--theme-primary t-button--variant-outline"><span class="t-button__text">普通对话框(可拖拽)</span></button></div><div class="t-space-item"><button type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">非模态对话框(不可拖拽)</span></button></div><div class="t-space-item"><button type="button" class="t-button t-button--theme-primary t-button--variant-outline"><span class="t-button__text">非模态对话框(可拖拽)</span></button></div></div>"`;
344344

345345
exports[`ssr snapshot test > ssr test packages/components/dialog/_example/plugin.tsx 1`] = `"<div style="gap:16px" class="t-space t-space-vertical"><div class="t-space-item"><p>函数调用方式一:DialogPlugin(options)</p></div><div class="t-space-item"><p>函数调用方式二:DialogPlugin.confirm(options)</p></div><div class="t-space-item"><p>函数调用方式三:DialogPlugin.alert(options)</p></div><div class="t-space-item"><div><button style="margin-right:16px" type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">dialog</span></button><button style="margin-right:16px" type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">handleDialogNode</span></button><button style="margin-right:16px" type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">confirm</span></button><button style="margin-right:16px" type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">alert</span></button><button style="margin-right:16px" type="button" class="t-button t-button--theme-primary t-button--variant-base"><span class="t-button__text">DialogPlugin.confirm</span></button></div></div></div>"`;
346346

0 commit comments

Comments
 (0)