Skip to content

Commit

Permalink
feat(number-keyboard): 新增 confirm 事件
Browse files Browse the repository at this point in the history
  • Loading branch information
yang1206 committed May 8, 2024
1 parent 7547ed0 commit 0a6b06c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/components/dentry/numberkeyboard.md
Expand Up @@ -277,6 +277,7 @@ export default{
| input | 点击按键时触发 | 按键内容 |
| delete | 点击删除键时触发 | - |
| close | 点击关闭按钮或非键盘区域时触发 | - |
| confirm `v1.7.9` | 点击确认按钮 | - |

## 主题定制

Expand Down
3 changes: 2 additions & 1 deletion packages/nutui/components/numberkeyboard/numberkeyboard.ts
@@ -1,6 +1,6 @@
import type { ExtractPropTypes } from 'vue'
import { commonProps, isBoolean, isNumber, isString, makeArrayProp, makeNumericProp, makeStringProp } from '../_utils'
import { CLOSE_EVENT, INPUT_EVENT, UPDATE_MODEL_EVENT, UPDATE_VISIBLE_EVENT } from '../_constants'
import { CLOSE_EVENT, CONFIRM_EVENT, INPUT_EVENT, UPDATE_MODEL_EVENT, UPDATE_VISIBLE_EVENT } from '../_constants'

export const numberkeyboardProps = {
...commonProps,
Expand Down Expand Up @@ -57,6 +57,7 @@ export const numberkeyboardEmits = {
[CLOSE_EVENT]: () => true,
[UPDATE_VISIBLE_EVENT]: (visible: boolean) => isBoolean(visible),
[UPDATE_MODEL_EVENT]: (val: string | number) => isString(val) || isNumber(val),
[CONFIRM_EVENT]: () => true,
}

export type NumberKeyBoardEmits = typeof numberkeyboardEmits
5 changes: 4 additions & 1 deletion packages/nutui/components/numberkeyboard/numberkeyboard.vue
Expand Up @@ -113,6 +113,9 @@ function closeBoard() {
emit(CLOSE_EVENT)
emit(UPDATE_VISIBLE_EVENT, false)
}
function onConfirm() {
emit('confirm')
}
</script>

<script lang="ts">
Expand Down Expand Up @@ -198,7 +201,7 @@ export default defineComponent({
/>
</div>
</div>
<div class="nut-key__wrapper nut-key__wrapper--finish" @click="closeBoard()">
<div class="nut-key__wrapper nut-key__wrapper--finish" @click="onConfirm">
<div class="nut-key nut-key--finish " :class="[{ activefinsh: clickKeyIndex === 'finish' }]">
{{ confirmText || translate('done') }}
</div>
Expand Down

0 comments on commit 0a6b06c

Please sign in to comment.