feat(modal): show-mask prop

This commit is contained in:
07akioni 2021-03-17 01:13:02 +08:00
parent 85687ed7e3
commit 10f9226965
7 changed files with 29 additions and 21 deletions

View File

@ -4,7 +4,8 @@
### Feat ### Feat
- `n-layout-sider` Add `default-collapsed` prop. - `n-layout-sider` add `default-collapsed` prop.
- `n-modal` add `show-mask` prop.
### Fixes ### Fixes

View File

@ -5,6 +5,7 @@
### Feat ### Feat
- `n-layout-sider` 新增 `default-collapsed` 属性 - `n-layout-sider` 新增 `default-collapsed` 属性
- `n-modal` 新增 `show-mask` 属性
### Fixed ### Fixed

View File

@ -23,6 +23,7 @@ preset-confirm-slot
| mask-closable | `boolean` | `true` | Whether to emit `hide` event when click mask. | | mask-closable | `boolean` | `true` | Whether to emit `hide` event when click mask. |
| preset | `'card' \| 'confirm'` | `undefined` | | | preset | `'card' \| 'confirm'` | `undefined` | |
| show | `boolean` | `false` | Whether to show modal. | | show | `boolean` | `false` | Whether to show modal. |
| show-mask | `boolean` | `true` | Whether to show mask of the modal. |
| on-update:show | `(value: boolean) => any` | `undefined` | Callback when modal's display status is changed. | | on-update:show | `(value: boolean) => any` | `undefined` | Callback when modal's display status is changed. |
### Modal with Preset Card ### Modal with Preset Card

View File

@ -10,7 +10,6 @@ Use `mask-closable=false` to make modal not emit the event which may close the m
preset="confirm" preset="confirm"
title="Dialog" title="Dialog"
content="Are you sure?" content="Are you sure?"
:closable="false"
positive-text="Confirm" positive-text="Confirm"
@positive-click="submitCallback" @positive-click="submitCallback"
@negative-click="cancelCallback" @negative-click="cancelCallback"

View File

@ -28,6 +28,7 @@ drawer-debug
| mask-closable | `boolean` | `true` | 点击遮罩时是否发出 `update:show` 事件 | | mask-closable | `boolean` | `true` | 点击遮罩时是否发出 `update:show` 事件 |
| preset | `'card' \| 'dialog'` | `undefined` | 模态框使用何种预设 | | preset | `'card' \| 'dialog'` | `undefined` | 模态框使用何种预设 |
| show | `boolean` | `false` | 是否展示 Modal | | show | `boolean` | `false` | 是否展示 Modal |
| show-mask | `boolean` | `true` | 是否展示 Modal 的遮罩 |
| on-update:show | `(value: boolean) => any` | `undefined` | 模态框更新是否展示状态的回调 | | on-update:show | `(value: boolean) => any` | `undefined` | 模态框更新是否展示状态的回调 |
### ModalCard 预设) ### ModalCard 预设)

View File

@ -5,12 +5,11 @@
```html ```html
<n-button @click="showModal = true"> 来吧 </n-button> <n-button @click="showModal = true"> 来吧 </n-button>
<n-modal <n-modal
:show="showModal" v-model:show="showModal"
:mask-closable="false" :mask-closable="false"
preset="confirm" preset="confirm"
title="确认" title="确认"
content="你确认" content="你确认"
:closable="false"
positive-text="确认" positive-text="确认"
@positive-click="onPositiveClick" @positive-click="onPositiveClick"
@negative-click="onNegativeClick" @negative-click="onNegativeClick"

View File

@ -45,6 +45,10 @@ export default defineComponent({
type: Boolean, type: Boolean,
default: false default: false
}, },
showMask: {
type: Boolean,
default: true
},
maskClosable: { maskClosable: {
type: Boolean, type: Boolean,
default: true default: true
@ -258,24 +262,26 @@ export default defineComponent({
style: this.cssVars as CSSProperties style: this.cssVars as CSSProperties
}, },
[ [
h( this.showMask
Transition, ? h(
{ Transition,
name: 'n-fade-in-transition', {
key: 'mask', name: 'n-fade-in-transition',
appear: this.appear ?? this.isMounted key: 'mask',
}, appear: this.appear ?? this.isMounted
{ },
default: () => { {
return this.show default: () => {
? h('div', { return this.show
ref: 'containerRef', ? h('div', {
class: 'n-modal-mask' ref: 'containerRef',
}) class: 'n-modal-mask'
: null })
: null
}
} }
} )
), : null,
h( h(
NModalBodyWrapper, NModalBodyWrapper,
{ {