Skip to content
This repository has been archived by the owner on Apr 17, 2022. It is now read-only.

Commit

Permalink
feat: Add option to reverse years order (resolves #113)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasenkoo committed Mar 5, 2022
1 parent d41da66 commit 793bcef
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ interface Vue3DatePicker {
fixedEnd?: boolean;
utc?: boolean;
multiDatesLimit?: number | string;
reverseYears?: boolean;
}

interface PublicMethods extends MethodOptions {
Expand Down
2 changes: 2 additions & 0 deletions src/Vue3DatePicker/Vue3DatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
fixedStart,
fixedEnd,
multiDatesLimit,
reverseYears,
}"
v-model:internalModelValue="internalModelValue"
@close-picker="closeMenu"
Expand Down Expand Up @@ -289,6 +290,7 @@
fixedEnd: { type: Boolean as PropType<boolean>, default: false },
utc: { type: Boolean as PropType<boolean>, default: false },
multiDatesLimit: { type: [Number, String] as PropType<number | string>, default: null },
reverseYears: { type: Boolean as PropType<boolean>, default: false },
});
const slots = useSlots();
const isOpen = ref(false);
Expand Down
2 changes: 2 additions & 0 deletions src/Vue3DatePicker/components/DatepickerMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
preventMinMaxNavigation,
internalModelValue,
range,
reverseYears,
}"
@mount="childMount('monthYearInput')"
@reset-flow="resetFlow"
Expand Down Expand Up @@ -296,6 +297,7 @@
fixedStart: { type: Boolean as PropType<boolean>, default: false },
fixedEnd: { type: Boolean as PropType<boolean>, default: false },
multiDatesLimit: { type: [Number, String] as PropType<number | string>, default: null },
reverseYears: { type: Boolean as PropType<boolean>, default: false },
});
const slots = useSlots();
const calendarWrapperRef = ref(null);
Expand Down
7 changes: 5 additions & 2 deletions src/Vue3DatePicker/components/MonthYearInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
preventMinMaxNavigation: { type: Boolean as PropType<boolean>, default: false },
internalModelValue: { type: [Date, Array] as PropType<InternalModuleValue>, default: null },
range: { type: Boolean as PropType<boolean>, default: false },
reverseYears: { type: Boolean as PropType<boolean>, default: false },
});
const { transitionName, showTransition } = useTransitions();
Expand Down Expand Up @@ -255,7 +256,8 @@
const list = [];
for (let i = 0; i < items.length; i += 3) {
list.push([items[i], items[i + 1], items[i + 2]]);
const listItems = [items[i], items[i + 1], items[i + 2]];
list.push(props.reverseYears ? listItems.reverse() : listItems);
}
return list;
};
Expand All @@ -271,7 +273,8 @@
});
const groupedYears = computed((): IDefaultSelect[][] => {
return getGroupedList(props.years);
const list = getGroupedList(props.years);
return props.reverseYears ? list.reverse() : list;
});
const showLeftIcon = computed(() => {
Expand Down

0 comments on commit 793bcef

Please sign in to comment.