diff --git a/components/_util/type.ts b/components/_util/type.ts index 266c85398..86b366fe4 100644 --- a/components/_util/type.ts +++ b/components/_util/type.ts @@ -51,8 +51,8 @@ export function objectType(defaultVal?: any) { return { type: Object as PropType, default: defaultVal as T }; } -export function booleanType(defaultVal?: any) { - return { type: Boolean as PropType, default: defaultVal as T }; +export function booleanType(defaultVal?: any) { + return { type: Boolean, default: defaultVal as boolean }; } export function someType(types: any[], defaultVal?: any) { diff --git a/components/dropdown/dropdown-button.tsx b/components/dropdown/dropdown-button.tsx index fbfae9745..baa418647 100644 --- a/components/dropdown/dropdown-button.tsx +++ b/components/dropdown/dropdown-button.tsx @@ -1,12 +1,13 @@ import type { ExtractPropTypes, HTMLAttributes } from 'vue'; -import { defineComponent } from 'vue'; +import { computed, defineComponent } from 'vue'; import Button from '../button'; -import classNames from '../_util/classNames'; import Dropdown from './dropdown'; +import classNames from '../_util/classNames'; import { initDefaultProps } from '../_util/props-util'; import { dropdownButtonProps } from './props'; import EllipsisOutlined from '@ant-design/icons-vue/EllipsisOutlined'; import useConfigInject from '../config-provider/hooks/useConfigInject'; +import useStyle from './style'; const ButtonGroup = Button.Group; export type DropdownButtonProps = Partial>>; @@ -27,20 +28,25 @@ export default defineComponent({ const handleVisibleChange = (val: boolean) => { emit('update:visible', val); emit('visibleChange', val); + emit('update:open', val); + emit('openChange', val); }; - const { prefixCls, direction, getPopupContainer } = useConfigInject('dropdown-button', props); - + const { prefixCls, direction, getPopupContainer } = useConfigInject('dropdown', props); + const buttonPrefixCls = computed(() => `${prefixCls.value}-button`); + const [wrapSSR, hashId] = useStyle(prefixCls); return () => { const { type = 'default', disabled, + danger, loading, htmlType, class: className = '', overlay = slots.overlay?.(), trigger, align, + open, visible, onVisibleChange: _onVisibleChange, placement = direction.value === 'rtl' ? 'bottomLeft' : 'bottomRight', @@ -53,7 +59,7 @@ export default defineComponent({ overlayStyle, destroyPopupOnHide, onClick, - 'onUpdate:visible': _updateVisible, + 'onUpdate:open': _updateVisible, ...restProps } = { ...props, ...attrs } as DropdownButtonProps & HTMLAttributes; @@ -63,10 +69,10 @@ export default defineComponent({ trigger: disabled ? [] : trigger, placement, getPopupContainer: getPopupContainer?.value, - onVisibleChange: handleVisibleChange, + onOpenChange: handleVisibleChange, mouseEnterDelay, mouseLeaveDelay, - visible, + open: open ?? visible, overlayClassName, overlayStyle, destroyPopupOnHide, @@ -74,6 +80,7 @@ export default defineComponent({ const leftButton = ( ); - const rightButton =