diff --git a/packages/varlet-ui/src/menu-option/props.ts b/packages/varlet-ui/src/menu-option/props.ts index cb48b0b57be..59c32a1e10b 100644 --- a/packages/varlet-ui/src/menu-option/props.ts +++ b/packages/varlet-ui/src/menu-option/props.ts @@ -2,6 +2,8 @@ import { PropType } from 'vue' import { MenuSelectOption } from '../menu-select/props' import { defineListenerProp } from '../utils/components' +export type MenuOptionKeyArrowX = 'ArrowLeft' | 'ArrowRight' + export const props = { label: {}, value: {}, @@ -10,9 +12,10 @@ export const props = { type: Boolean, default: true, }, - // internal + // internal start option: Object as PropType, childrenTrigger: Boolean, highlight: Boolean, - onKeyArrowX: defineListenerProp<(trigger: 'ArrowLeft' | 'ArrowRight') => void>(), + onKeyArrowX: defineListenerProp<(key: MenuOptionKeyArrowX) => void>(), + // internal end } diff --git a/packages/varlet-ui/src/menu-select/MenuChildren.vue b/packages/varlet-ui/src/menu-select/MenuChildren.vue index de77f5f270e..d2daa801924 100644 --- a/packages/varlet-ui/src/menu-select/MenuChildren.vue +++ b/packages/varlet-ui/src/menu-select/MenuChildren.vue @@ -63,6 +63,7 @@ import { createNamespace, defineListenerProp, pickProps } from '../utils/compone import { type MenuSelectOption, props as menuSelectProps } from './props' import { focusChildElementByKey } from '../utils/elements' import { call, raf } from '@varlet/shared' +import { type MenuOptionKeyArrowX } from '../menu-option/props' const { name, n } = createNamespace('menu-children') @@ -102,7 +103,7 @@ export default defineComponent({ { immediate: true } ) - async function handleArrowRight(key: 'ArrowRight' | 'ArrowLeft') { + async function handleArrowRight(key: MenuOptionKeyArrowX) { call(props.onKeyArrowX, key) if (key !== 'ArrowRight') { @@ -115,7 +116,7 @@ export default defineComponent({ focusChildElementByKey(menu.value!.$el, menuOptions.value!, 'ArrowDown') } - function handleArrowLeft(key: 'ArrowRight' | 'ArrowLeft') { + function handleArrowLeft(key: MenuOptionKeyArrowX) { if (key !== 'ArrowLeft') { return } diff --git a/packages/varlet-ui/types/checkboxGroup.d.ts b/packages/varlet-ui/types/checkboxGroup.d.ts index 684e091c811..d70bf260596 100644 --- a/packages/varlet-ui/types/checkboxGroup.d.ts +++ b/packages/varlet-ui/types/checkboxGroup.d.ts @@ -29,9 +29,9 @@ export interface CheckboxGroupProps extends BasicAttributes { max?: string | number labelKey?: string valueKey?: string - options?: Array + options?: CheckboxGroupOption[] direction?: CheckboxGroupDirection - validateTrigger?: Array + validateTrigger?: CheckboxGroupValidateTrigger[] rules?: CheckboxGroupRules onChange?: ListenerProp<(value: Array) => void> 'onUpdate:modelValue'?: ListenerProp<(value: Array) => void> diff --git a/packages/varlet-ui/types/menuSelect.d.ts b/packages/varlet-ui/types/menuSelect.d.ts index f756d57f767..7908e7ec5c6 100644 --- a/packages/varlet-ui/types/menuSelect.d.ts +++ b/packages/varlet-ui/types/menuSelect.d.ts @@ -30,13 +30,17 @@ export type MenuSelectOptionLabelRender = (option: MenuSelectOption, checked: bo export interface MenuSelectOption { label?: string | VNode | MenuSelectOptionLabelRender - disabled?: boolean value?: any + disabled?: boolean ripple?: boolean + children?: MenuSelectOption[] + + [key: PropertyKey]: any } export interface MenuSelectProps extends BasicAttributes { modelValue?: any + options?: MenuSelectOption[] size?: MenuSelectSize multiple?: boolean scrollable?: boolean @@ -47,6 +51,9 @@ export interface MenuSelectProps extends BasicAttributes { reference?: MenuSelectReference placement?: MenuSelectPlacement strategy?: MenuSelectStrategy + labelKey?: string + valueKey?: string + childrenKey?: string offsetX?: string | number offsetY?: string | number teleport?: TeleportProps['to'] | false @@ -58,6 +65,7 @@ export interface MenuSelectProps extends BasicAttributes { onOpened?: ListenerProp<() => void> onClose?: ListenerProp<() => void> onClosed?: ListenerProp<() => void> + onSelect?: ListenerProp<(value: any) => void> 'onUpdate:modelValue'?: ListenerProp<(value: any) => void> 'onUpdate:show'?: ListenerProp<(show: boolean) => void> } diff --git a/packages/varlet-ui/types/radioGroup.d.ts b/packages/varlet-ui/types/radioGroup.d.ts index 8fc5b381f19..f3ab544c358 100644 --- a/packages/varlet-ui/types/radioGroup.d.ts +++ b/packages/varlet-ui/types/radioGroup.d.ts @@ -27,10 +27,10 @@ export { RadioGroupDirection } export interface RadioGroupProps extends BasicAttributes { modelValue?: any direction?: RadioGroupDirection - options?: Array + options?: RadioGroupOption[] labelKey?: string valueKey?: string - validateTrigger?: Array + validateTrigger?: RadioGroupValidateTrigger[] rules?: RadioGroupRules onChange?: ListenerProp<(value: any) => void> 'onUpdate:modelValue'?: ListenerProp<(value: any) => void> diff --git a/packages/varlet-ui/types/select.d.ts b/packages/varlet-ui/types/select.d.ts index 7863b536237..ae9e3dc0632 100644 --- a/packages/varlet-ui/types/select.d.ts +++ b/packages/varlet-ui/types/select.d.ts @@ -30,7 +30,7 @@ export interface SelectOption { export interface SelectProps extends BasicAttributes { modelValue?: any - options?: Array + options?: SelectOption[] labelKey?: string valueKey?: string variant?: SelectVariant