Skip to content

Commit

Permalink
fix(modal): add dragging and resizing into slot params
Browse files Browse the repository at this point in the history
  • Loading branch information
qmhc committed Oct 10, 2023
1 parent e486c10 commit a81c4f7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
20 changes: 12 additions & 8 deletions components/modal/modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Button } from '@/components/button'
import { Icon } from '@/components/icon'
import { Masker } from '@/components/masker'
import { computed, nextTick, reactive, ref, toRef, watch } from 'vue'
import { computed, nextTick, reactive, ref, shallowReadonly, toRef, watch } from 'vue'
import {
createSizeProp,
Expand Down Expand Up @@ -282,12 +282,16 @@ defineExpose({
handleClose
})
const slotParams = {
handleResize,
handleConfirm,
handleCancel,
handleClose
}
const slotParams = shallowReadonly(
reactive({
dragging,
resizing,
handleResize,
handleConfirm,
handleCancel,
handleClose
})
)
function setActive(active: boolean) {
if (currentActive.value === active) return
Expand Down Expand Up @@ -380,7 +384,7 @@ function handleCancel() {
emitEvent(props.onCancel)
}
async function handleClose(isConfirm: boolean) {
async function handleClose(isConfirm = false) {
let result: unknown = true
if (typeof props.onBeforeClose === 'function') {
Expand Down
4 changes: 3 additions & 1 deletion components/modal/symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ export interface SizePayload {
}

export interface ModalSlotParams {
dragging: boolean,
resizing: boolean,
handleResize: () => void,
handleConfirm: () => void,
handleCancel: () => void,
handleClose: (isConfirm: boolean) => Promise<void>
handleClose: (isConfirm?: boolean) => Promise<void>
}

export type ModalCommonSLot = (params: ModalSlotParams) => any
Expand Down
4 changes: 3 additions & 1 deletion docs/en-US/component/modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,12 @@ Or you can directly import `useModal` and use it as in the example.

```ts
interface ModalSlotParams {
dragging: boolean,
resizing: boolean,
handleResize: () => void,
handleConfirm: () => void,
handleCancel: () => void,
handleClose: (isConfirm: boolean) => Promise<void>
handleClose: (isConfirm?: boolean) => Promise<void>
}
```

Expand Down
4 changes: 3 additions & 1 deletion docs/zh-CN/component/modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,12 @@ Modal 组件提供了一个静态的 `open` 方法,可以直接创建一个一

```ts
interface ModalSlotParams {
dragging: boolean,
resizing: boolean,
handleResize: () => void,
handleConfirm: () => void,
handleCancel: () => void,
handleClose: (isConfirm: boolean) => Promise<void>
handleClose: (isConfirm?: boolean) => Promise<void>
}
```

Expand Down

0 comments on commit a81c4f7

Please sign in to comment.