Skip to content

Commit

Permalink
feat(calendar): 添加calendar组件点击遮罩关闭事件和点击关闭图标事件 (nutui-uniapp#273)
Browse files Browse the repository at this point in the history
* feat: 添加calendar组件点击遮罩关闭事件和点击关闭图标事件

* docs(calendar): 统一事件名描述

---------

Co-authored-by: 小何同学 <[email protected]>
  • Loading branch information
North-al and xiaohe0601 authored Apr 3, 2024
1 parent 92e058b commit e70e654
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/components/dentry/calendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,8 @@ export default {
| choose | 选择之后或是点击确认按钮触发,日期数组(包含年月日和星期) | `(string \| string[])[]` |
| close | 关闭时触发 | - |
| select | 点击/选择后触发 | `(string \| string[])[]` |
| click-close-icon | 点击关闭图标后触发 | - |
| click-overlay | 点击遮罩关闭后触发 | - |

### Slots

Expand Down
2 changes: 2 additions & 0 deletions packages/nutui/components/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ export const calendarEmits = {
[CLOSE_EVENT]: () => true,
[UPDATE_VISIBLE_EVENT]: (val: boolean) => isBoolean(val),
[SELECT_EVENT]: (val: any) => val,
clickCloseIcon: () => true,
clickOverlay: () => true,
}

export type CalendarEmits = typeof calendarEmits
10 changes: 10 additions & 0 deletions packages/nutui/components/calendar/calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ function select(param: string) {
// close();
emit(SELECT_EVENT, param)
}
function onClickCloseIcon() {
emit('clickCloseIcon')
}
function onClickOverlay() {
emit('clickOverlay')
}
</script>

<script lang="ts">
Expand All @@ -102,6 +110,8 @@ export default defineComponent({
:custom-style="{ height: '85vh' }"
:destroy-on-close="false"
@opened="opened"
@click-close-icon="onClickCloseIcon"
@click-overlay="onClickOverlay"
>
<NutCalendarItem
ref="calendarRef"
Expand Down

0 comments on commit e70e654

Please sign in to comment.