Skip to content

Commit

Permalink
feat(comp:alert): add onAfterClose (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
danranVm authored Jul 11, 2022
1 parent ce081ba commit 2c0e301
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
strict-peer-dependencies=false
1 change: 1 addition & 0 deletions packages/components/alert/docs/Index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ subtitle: 警告提示
| `title` | 信息提示内容 | `string \| string[] \| #default` | - | - |- |
| `onBeforeClose` | 关闭提示前会触发的回调函数 | `() => boolean \| Promise<boolean>` | - | - | - |
| `onClose` | 关闭提示会触发的回调函数 | `() => void` | - | - | - |
| `onAfterClose` | 关闭提示后触发的回调函数 | `() => void` | - | - | 动画结束 |

```ts
export interface AlertPagination {
Expand Down
6 changes: 4 additions & 2 deletions packages/components/alert/src/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Transition, computed, defineComponent, normalizeClass, watchEffect } fr

import { isNil, isObject } from 'lodash-es'

import { convertArray, flattenNode, useState } from '@idux/cdk/utils'
import { callEmit, convertArray, flattenNode, useState } from '@idux/cdk/utils'
import { useGlobalConfig } from '@idux/components/config'
import { IxIcon } from '@idux/components/icon'
import { IxPagination } from '@idux/components/pagination'
Expand Down Expand Up @@ -56,6 +56,8 @@ export default defineComponent({
})
})

const handleAfterLeave = () => callEmit(props.onAfterClose)

return () => {
const { title, pagination } = props

Expand All @@ -69,7 +71,7 @@ export default defineComponent({

const prefixCls = mergedPrefixCls.value
return (
<Transition name={prefixCls}>
<Transition name={prefixCls} onAfterLeave={handleAfterLeave}>
{visible.value && (
<div class={classes.value}>
{iconNode && <span class={`${prefixCls}-icon`}>{iconNode}</span>}
Expand Down
1 change: 1 addition & 0 deletions packages/components/alert/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const alertProps = {
type: String as PropType<AlertType>,
default: 'info',
},
onAfterClose: [Function, Array] as PropType<MaybeArray<() => void>>,
onBeforeClose: [Function, Array] as PropType<MaybeArray<() => void | boolean | Promise<boolean>>>,
onClose: [Function, Array] as PropType<MaybeArray<() => void>>,
} as const
Expand Down
14 changes: 4 additions & 10 deletions packages/components/input-number/src/InputNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,14 @@ export default defineComponent({
elementRef.value = inputRef.value!.getInputElement()
})

const handleFocusAtClick = () => {
if (!isDisabled.value) {
focus()
}
}

const handleIncrease = () => {
const handleIncrease = (evt: MouseEvent) => {
evt.stopPropagation()
handleInc()
handleFocusAtClick()
}

const handleDecrease = () => {
const handleDecrease = (evt: MouseEvent) => {
evt.stopPropagation()
handleDec()
handleFocusAtClick()
}

return () => {
Expand Down

0 comments on commit 2c0e301

Please sign in to comment.