Skip to content

Commit

Permalink
refactor: Convert usePosition params to object param
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasenkoo committed Sep 1, 2023
1 parent 740ba37 commit 9675bbb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/VueDatePicker/VueDatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,16 @@
{ deep: true },
);
const { openOnTop, menuStyle, xCorrect, setMenuPosition, getScrollableParent, shadowRender } = usePosition(
dpWrapMenuRef,
dpMenuRef,
const { openOnTop, menuStyle, xCorrect, setMenuPosition, getScrollableParent, shadowRender } = usePosition({
menuRef: dpWrapMenuRef,
menuRefInner: dpMenuRef,
inputRef,
pickerWrapperRef,
defaultedInline,
inline: defaultedInline,
emit,
props,
slots,
);
});
const {
inputValue,
Expand Down
30 changes: 20 additions & 10 deletions src/VueDatePicker/composables/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,26 @@ import type { AllPropsType } from '@/props';
/**
* Extracted code from the main component, used for calculating the position of the menu
*/
export const usePosition = (
menuRef: Ref<HTMLElement | null>,
menuRefInner: Ref<ComponentPublicInstance | null>,
inputRef: ComponentRef,
pickerWrapperRef: Ref<HTMLElement | null>,
inline: ComputedRef<InlineOptions>,
emit: VueEmit,
props: AllPropsType,
slots: Slots,
) => {
interface Params {
menuRef: Ref<HTMLElement | null>;
menuRefInner: Ref<ComponentPublicInstance | null>;
inputRef: ComponentRef;
pickerWrapperRef: Ref<HTMLElement | null>;
inline: ComputedRef<InlineOptions>;
emit: VueEmit;
props: AllPropsType;
slots: Slots;
}
export const usePosition = ({
menuRef,
menuRefInner,
inputRef,
pickerWrapperRef,
inline,
emit,
props,
slots,
}: Params) => {
const menuRect = ref<DOMRect>({} as DOMRect);
const xCorrect = ref(false);

Expand Down

0 comments on commit 9675bbb

Please sign in to comment.