|
1 | 1 | import { h, ref, render, toRef, watch } from 'vue';
|
2 |
| -import { type DatepickerInputRef, type DatepickerMenuRef, OpenPosition } from '@/interfaces'; |
| 2 | +import { |
| 3 | + type DatepickerInputRef, |
| 4 | + type DatepickerMenuRef, |
| 5 | + type InlineOptions, |
| 6 | + type VueEmit, |
| 7 | + OpenPosition, |
| 8 | + type MaybeElementRef, |
| 9 | +} from '@/interfaces'; |
3 | 10 |
|
4 | 11 | import { unrefElement } from '@/utils/util';
|
5 | 12 | import { MenuPlacement } from '@/constants';
|
6 | 13 |
|
7 | 14 | import type { Component, ComputedRef, Ref, Slots } from 'vue';
|
8 |
| -import type { InlineOptions, VueEmit } from '@/interfaces'; |
9 | 15 | import type { AllPropsType } from '@/props';
|
10 | 16 |
|
11 | 17 | /**
|
@@ -95,7 +101,7 @@ export const usePosition = ({
|
95 | 101 | };
|
96 | 102 |
|
97 | 103 | const customAltPosition = () => {
|
98 |
| - const el = unrefElement(inputRef); |
| 104 | + const el = unrefElement(inputRef as MaybeElementRef); |
99 | 105 | const { top, left, transform } = props.altPosition(el);
|
100 | 106 | menuStyle.value = { top: `${top}px`, left: `${left}px`, transform: transform ?? '' };
|
101 | 107 | };
|
@@ -172,7 +178,7 @@ export const usePosition = ({
|
172 | 178 | };
|
173 | 179 |
|
174 | 180 | const getMenuPlacement = (): MenuPlacement => {
|
175 |
| - const inputEl = unrefElement(inputRef); |
| 181 | + const inputEl = unrefElement(inputRef as MaybeElementRef); |
176 | 182 | if (inputEl) {
|
177 | 183 | const { height: menuHeight } = menuRect.value;
|
178 | 184 | const { top: inputTop, height: inputHeight } = inputEl.getBoundingClientRect();
|
@@ -201,7 +207,7 @@ export const usePosition = ({
|
201 | 207 |
|
202 | 208 | // Parent function that will perform check on which calculation function to invoke
|
203 | 209 | const calculateMenuPosition = () => {
|
204 |
| - const inputEl = unrefElement(inputRef); |
| 210 | + const inputEl = unrefElement(inputRef as MaybeElementRef); |
205 | 211 | if (inputEl) {
|
206 | 212 | if (props.autoPosition) {
|
207 | 213 | return setAutoPosition(inputEl);
|
@@ -245,7 +251,7 @@ export const usePosition = ({
|
245 | 251 | // Renders invisible menu on open to determine the menu dimensions
|
246 | 252 | const shadowRender = (DPMenu: Component, props: AllPropsType) => {
|
247 | 253 | const container = document.createElement('div');
|
248 |
| - const input = unrefElement(inputRef)?.getBoundingClientRect(); |
| 254 | + const input = unrefElement(inputRef as MaybeElementRef)?.getBoundingClientRect(); |
249 | 255 | container.setAttribute('id', 'dp--temp-container');
|
250 | 256 | const wrap = pickerWrapperRef.value?.clientWidth ? pickerWrapperRef.value : document.body;
|
251 | 257 | wrap.append(container);
|
|
0 commit comments