Skip to content

Commit a18abdd

Browse files
committed
refactor(ant): define global components
1 parent ae77657 commit a18abdd

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

ant/src/components.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
declare module '@vue/runtime-core' {
2+
export interface GlobalComponents {
3+
AButton: (typeof import('ant-design-vue'))['Button']
4+
AMenu: (typeof import('ant-design-vue'))['Menu']
5+
ADropdown: (typeof import('ant-design-vue'))['Dropdown']
6+
AMenuItem: (typeof import('ant-design-vue'))['MenuItem']
7+
}
8+
}
9+
10+
export {}

ant/src/components/select.vue

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</a-button>
88

99
<template #overlay>
10-
<a-menu multiple :selectedKeys="Array.isArray(modelValue) ? modelValue : [modelValue]">
10+
<a-menu multiple :selectedKeys="selectedKeys">
1111
<div class="vcron-a-row" type="flex" v-for="(itemRow, i) in itemRows" :key="i">
1212
<div class="vcron-a-col" :flex="1" v-for="(item, j) in itemRow" :key="j">
1313
<a-menu-item
@@ -34,7 +34,7 @@
3434
import { CloseCircleFilled } from '@ant-design/icons-vue'
3535
import { selectProps, setupSelect } from '@vue-js-cron/core'
3636
import type { ButtonProps, DropdownProps } from 'ant-design-vue'
37-
import { defineComponent, ref, type PropType } from 'vue'
37+
import { computed, defineComponent, ref, type PropType } from 'vue'
3838
3939
export default defineComponent({
4040
inheritAttrs: false,
@@ -43,7 +43,7 @@ export default defineComponent({
4343
},
4444
name: 'CustomSelect',
4545
props: {
46-
...selectProps<any, any>(),
46+
...selectProps<any, string | number>(),
4747
buttonProps: {
4848
type: Object as PropType<ButtonProps>,
4949
default: () => {},
@@ -68,10 +68,19 @@ export default defineComponent({
6868
}
6969
}
7070
71+
const selectedKeys = computed(() => {
72+
const modelValue = props.modelValue
73+
if (!modelValue) {
74+
return []
75+
}
76+
return Array.isArray(modelValue) ? modelValue : [modelValue]
77+
})
78+
7179
return {
7280
...s,
73-
updateVisibility,
7481
visible,
82+
updateVisibility,
83+
selectedKeys,
7584
}
7685
},
7786
})

core/src/components/select.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export interface SelectOptions<T, V> extends SetOptions<T> {
8989
export function selectProps<T, V>() {
9090
return {
9191
modelValue: {
92-
type: [String, Number, Array],
92+
type: [String, Number, Array] as PropType<V | V[]>,
9393
},
9494
selection: {
9595
type: String,

0 commit comments

Comments
 (0)