Skip to content

Commit

Permalink
feat: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
haoziqaq committed Dec 25, 2024
1 parent 2531eb0 commit 3e0e239
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
7 changes: 5 additions & 2 deletions packages/varlet-ui/src/menu-option/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand All @@ -10,9 +12,10 @@ export const props = {
type: Boolean,
default: true,
},
// internal
// internal start
option: Object as PropType<MenuSelectOption>,
childrenTrigger: Boolean,
highlight: Boolean,
onKeyArrowX: defineListenerProp<(trigger: 'ArrowLeft' | 'ArrowRight') => void>(),
onKeyArrowX: defineListenerProp<(key: MenuOptionKeyArrowX) => void>(),
// internal end
}
5 changes: 3 additions & 2 deletions packages/varlet-ui/src/menu-select/MenuChildren.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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') {
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions packages/varlet-ui/types/checkboxGroup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export interface CheckboxGroupProps extends BasicAttributes {
max?: string | number
labelKey?: string
valueKey?: string
options?: Array<CheckboxGroupOption>
options?: CheckboxGroupOption[]
direction?: CheckboxGroupDirection
validateTrigger?: Array<CheckboxGroupValidateTrigger>
validateTrigger?: CheckboxGroupValidateTrigger[]
rules?: CheckboxGroupRules
onChange?: ListenerProp<(value: Array<any>) => void>
'onUpdate:modelValue'?: ListenerProp<(value: Array<any>) => void>
Expand Down
10 changes: 9 additions & 1 deletion packages/varlet-ui/types/menuSelect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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>
}
Expand Down
4 changes: 2 additions & 2 deletions packages/varlet-ui/types/radioGroup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export { RadioGroupDirection }
export interface RadioGroupProps extends BasicAttributes {
modelValue?: any
direction?: RadioGroupDirection
options?: Array<RadioGroupOption>
options?: RadioGroupOption[]
labelKey?: string
valueKey?: string
validateTrigger?: Array<RadioGroupValidateTrigger>
validateTrigger?: RadioGroupValidateTrigger[]
rules?: RadioGroupRules
onChange?: ListenerProp<(value: any) => void>
'onUpdate:modelValue'?: ListenerProp<(value: any) => void>
Expand Down
2 changes: 1 addition & 1 deletion packages/varlet-ui/types/select.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface SelectOption {

export interface SelectProps extends BasicAttributes {
modelValue?: any
options?: Array<SelectOption>
options?: SelectOption[]
labelKey?: string
valueKey?: string
variant?: SelectVariant
Expand Down

0 comments on commit 3e0e239

Please sign in to comment.