|
8 | 8 | reactive,
|
9 | 9 | toRefs,
|
10 | 10 | watch,
|
| 11 | + PropType, |
11 | 12 | } from 'vue'
|
12 |
| -import { createPopper } from '@popperjs/core' |
| 13 | +import { createPopper, Placement } from '@popperjs/core' |
13 | 14 |
|
14 | 15 | const CDropdown = defineComponent({
|
15 | 16 | name: 'CDropdown',
|
@@ -92,29 +93,9 @@ const CDropdown = defineComponent({
|
92 | 93 | * @default 'bottom-start'
|
93 | 94 | */
|
94 | 95 | placement: {
|
95 |
| - type: String, |
| 96 | + type: String as PropType<Placement>, |
96 | 97 | default: 'bottom-start',
|
97 | 98 | required: false,
|
98 |
| - validator: (value: string) => { |
99 |
| - // The value must match one of these strings |
100 |
| - return [ |
101 |
| - 'auto', |
102 |
| - 'auto-start', |
103 |
| - 'auto-end', |
104 |
| - 'top-end', |
105 |
| - 'top', |
106 |
| - 'top-start', |
107 |
| - 'bottom-end', |
108 |
| - 'bottom', |
109 |
| - 'bottom-start', |
110 |
| - 'right-start', |
111 |
| - 'right', |
112 |
| - 'right-end', |
113 |
| - 'left-start', |
114 |
| - 'left', |
115 |
| - 'left-end', |
116 |
| - ].includes(value) |
117 |
| - }, |
118 | 99 | },
|
119 | 100 | /**
|
120 | 101 | * If you want to disable dynamic positioning set this property to `true`.
|
@@ -154,11 +135,10 @@ const CDropdown = defineComponent({
|
154 | 135 | },
|
155 | 136 | },
|
156 | 137 | setup(props, { slots }) {
|
157 |
| - const dropdownRef = ref(null) |
158 |
| - const dropdownMenuRef = ref(null) |
| 138 | + const dropdownRef = ref() |
| 139 | + const dropdownMenuRef = ref() |
159 | 140 | const placement = ref(props.placement)
|
160 | 141 | const popper = ref()
|
161 |
| - // const visible = ref() |
162 | 142 |
|
163 | 143 | const config = reactive({
|
164 | 144 | alignment: props.alignment,
|
@@ -196,7 +176,6 @@ const CDropdown = defineComponent({
|
196 | 176 | }
|
197 | 177 |
|
198 | 178 | if (dropdownRef.value) {
|
199 |
| - // @ts-expect-error TODO: find solution |
200 | 179 | popper.value = createPopper(dropdownRef.value, dropdownMenuRef.value, {
|
201 | 180 | placement: placement.value,
|
202 | 181 | })
|
@@ -233,13 +212,11 @@ const CDropdown = defineComponent({
|
233 | 212 | }
|
234 | 213 |
|
235 | 214 | const handleKeyup = (event: Event) => {
|
236 |
| - // @ts-expect-error TODO: find solution |
237 | 215 | if (dropdownRef.value && !dropdownRef.value.contains(event.target as HTMLElement)) {
|
238 | 216 | hideMenu()
|
239 | 217 | }
|
240 | 218 | }
|
241 | 219 | const handleClickOutside = (event: Event) => {
|
242 |
| - // @ts-expect-error TODO: find solution |
243 | 220 | if (dropdownRef.value && !dropdownRef.value.contains(event.target as HTMLElement)) {
|
244 | 221 | hideMenu()
|
245 | 222 | }
|
|
0 commit comments