|
@@ -38,11 +38,32 @@ import {
|
|
|
import moment from "moment";
|
|
import moment from "moment";
|
|
|
import Text from "../text";
|
|
import Text from "../text";
|
|
|
|
|
|
|
|
|
|
+const YEAR_LINES = [
|
|
|
|
|
+ [
|
|
|
|
|
+ 0,
|
|
|
|
|
+ 1,
|
|
|
|
|
+ 2
|
|
|
|
|
+ ],
|
|
|
|
|
+ [
|
|
|
|
|
+ 3,
|
|
|
|
|
+ 4,
|
|
|
|
|
+ 5
|
|
|
|
|
+ ],
|
|
|
|
|
+ [
|
|
|
|
|
+ 6,
|
|
|
|
|
+ 7,
|
|
|
|
|
+ 8
|
|
|
|
|
+ ],
|
|
|
|
|
+ [
|
|
|
|
|
+ 9,
|
|
|
|
|
+ 10,
|
|
|
|
|
+ 11
|
|
|
|
|
+ ]
|
|
|
|
|
+];
|
|
|
|
|
+
|
|
|
const YearSelector = ({
|
|
const YearSelector = ({
|
|
|
multipleSelectMinimumRequiredDayCount,
|
|
multipleSelectMinimumRequiredDayCount,
|
|
|
isShowTodayIndicator = true,
|
|
isShowTodayIndicator = true,
|
|
|
- localeBasedFirstDayOfWeek,
|
|
|
|
|
- yearLengthType = "long",
|
|
|
|
|
viewDate: viewDateProp,
|
|
viewDate: viewDateProp,
|
|
|
multipleSelectDayLimit,
|
|
multipleSelectDayLimit,
|
|
|
setIsSheetContentReady,
|
|
setIsSheetContentReady,
|
|
@@ -77,17 +98,16 @@ const YearSelector = ({
|
|
|
] = useState(viewDateProp ? viewDateProp : selectDate);
|
|
] = useState(viewDateProp ? viewDateProp : selectDate);
|
|
|
|
|
|
|
|
const [
|
|
const [
|
|
|
- monthDays,
|
|
|
|
|
- setMonthDays
|
|
|
|
|
|
|
+ years,
|
|
|
|
|
+ setYears
|
|
|
] = useState<Array<CalendarYear>>([]);
|
|
] = useState<Array<CalendarYear>>([]);
|
|
|
|
|
|
|
|
- const allSelectedDays = useRef<Array<Date>>([]);
|
|
|
|
|
|
|
+ const allSelectedYears = useRef<Array<Date>>([]);
|
|
|
|
|
|
|
|
const {
|
|
const {
|
|
|
nextPrevToolChevronButton: nextPrevToolChevronButtonDynamicStyle,
|
|
nextPrevToolChevronButton: nextPrevToolChevronButtonDynamicStyle,
|
|
|
nextPrevToolContainer: nextPrevToolContainerDynamicStyle,
|
|
nextPrevToolContainer: nextPrevToolContainerDynamicStyle,
|
|
|
todayIndicator: todayIndicatorDynamicStyle,
|
|
todayIndicator: todayIndicatorDynamicStyle,
|
|
|
- dayOfWeek: dayOfWeekDynamicStyle,
|
|
|
|
|
day: dayDynamicStyle
|
|
day: dayDynamicStyle
|
|
|
} = useStyles({
|
|
} = useStyles({
|
|
|
radiuses,
|
|
radiuses,
|
|
@@ -97,11 +117,11 @@ const YearSelector = ({
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
- const allDays = getDaysOfViewMonth({
|
|
|
|
|
|
|
+ const allYears = getViewYears({
|
|
|
tDate: viewDate
|
|
tDate: viewDate
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- setMonthDays(allDays);
|
|
|
|
|
|
|
+ setYears(allYears);
|
|
|
}, [
|
|
}, [
|
|
|
dateRange,
|
|
dateRange,
|
|
|
viewDate,
|
|
viewDate,
|
|
@@ -109,9 +129,9 @@ const YearSelector = ({
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
useLayoutEffect(() => {
|
|
useLayoutEffect(() => {
|
|
|
- if(monthDays) setIsSheetContentReady(true);
|
|
|
|
|
|
|
+ if(years && years.length) setIsSheetContentReady(true);
|
|
|
}, [
|
|
}, [
|
|
|
- monthDays
|
|
|
|
|
|
|
+ years
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
@@ -130,42 +150,41 @@ const YearSelector = ({
|
|
|
[]
|
|
[]
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- const getDaysOfViewMonth = ({
|
|
|
|
|
|
|
+ const getViewYears = ({
|
|
|
tDate
|
|
tDate
|
|
|
}: {
|
|
}: {
|
|
|
tDate: Date
|
|
tDate: Date
|
|
|
}): Array<CalendarYear> => {
|
|
}): Array<CalendarYear> => {
|
|
|
- allSelectedDays.current = [];
|
|
|
|
|
|
|
+ allSelectedYears.current = [];
|
|
|
|
|
|
|
|
const targetDate = moment(new Date(tDate));
|
|
const targetDate = moment(new Date(tDate));
|
|
|
|
|
|
|
|
- const startOfCalendar = targetDate.clone().startOf("month").startOf("week");
|
|
|
|
|
- const endOfCalendar = targetDate.clone().endOf("month").endOf("week");
|
|
|
|
|
|
|
+ const startOfCalendar = targetDate.clone().subtract(5, "years").startOf("year");
|
|
|
|
|
|
|
|
- const totalDays = endOfCalendar.diff(startOfCalendar, "days") + 1;
|
|
|
|
|
|
|
+ const totalYears = 12;
|
|
|
|
|
|
|
|
- const allDays = Array.from({
|
|
|
|
|
- length: totalDays
|
|
|
|
|
|
|
+ const allYears = Array.from({
|
|
|
|
|
+ length: totalYears
|
|
|
}).map((_, index) => {
|
|
}).map((_, index) => {
|
|
|
- const currentDay = startOfCalendar.clone().add(index, "days");
|
|
|
|
|
|
|
+ const currentYear = startOfCalendar.clone().add(index, "years");
|
|
|
|
|
|
|
|
let isSelected = false;
|
|
let isSelected = false;
|
|
|
|
|
|
|
|
if(variant === "single" && date) {
|
|
if(variant === "single" && date) {
|
|
|
- allSelectedDays.current = [date];
|
|
|
|
|
|
|
+ allSelectedYears.current = [date];
|
|
|
|
|
|
|
|
- if(moment(currentDay).isSame(date, "day")) isSelected = true;
|
|
|
|
|
|
|
+ if(moment(currentYear).isSame(date, "year")) isSelected = true;
|
|
|
} else if(variant === "range" && dateRange && dateRange.start) {
|
|
} else if(variant === "range" && dateRange && dateRange.start) {
|
|
|
if(dateRange.end) {
|
|
if(dateRange.end) {
|
|
|
- allSelectedDays.current = Array.from({
|
|
|
|
|
- length: moment(dateRange.end).diff(dateRange.start, "days") + 1
|
|
|
|
|
|
|
+ allSelectedYears.current = Array.from({
|
|
|
|
|
+ length: moment(dateRange.end).diff(dateRange.start, "years") + 1
|
|
|
}, (_, i) =>
|
|
}, (_, i) =>
|
|
|
- moment(dateRange.start).clone().add(i, "days").toDate()
|
|
|
|
|
|
|
+ moment(dateRange.start).clone().add(i, "years").toDate()
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- if(moment(currentDay).isBetween(dateRange.start, dateRange.end, "day", "[]")) isSelected = true;
|
|
|
|
|
- } else if(moment(currentDay).isSame(dateRange.start)) {
|
|
|
|
|
- allSelectedDays.current = [dateRange.start];
|
|
|
|
|
|
|
+ if(moment(currentYear).isBetween(dateRange.start, dateRange.end, "year", "[]")) isSelected = true;
|
|
|
|
|
+ } else if(moment(currentYear).isSame(dateRange.start, "year")) {
|
|
|
|
|
+ allSelectedYears.current = [dateRange.start];
|
|
|
|
|
|
|
|
isSelected = true;
|
|
isSelected = true;
|
|
|
}
|
|
}
|
|
@@ -173,47 +192,47 @@ const YearSelector = ({
|
|
|
|
|
|
|
|
let isDisabled = false;
|
|
let isDisabled = false;
|
|
|
|
|
|
|
|
- if(minDate && moment(currentDay).isBefore(minDate)) {
|
|
|
|
|
|
|
+ if(minDate && moment(currentYear).isBefore(moment(minDate).startOf("year"))) {
|
|
|
isDisabled = true;
|
|
isDisabled = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(maxDate && moment(currentDay).isAfter(maxDate)) {
|
|
|
|
|
|
|
+ if(maxDate && moment(currentYear).isAfter(moment(maxDate).endOf("year"))) {
|
|
|
isDisabled = true;
|
|
isDisabled = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ const currentYearNumber = currentYear.year();
|
|
|
|
|
+
|
|
|
return {
|
|
return {
|
|
|
- originalIndex: allSelectedDays.current.findIndex((day) => moment(currentDay).isSame(day, "day")),
|
|
|
|
|
- isCurrentView: currentDay.isSame(targetDate, "month"),
|
|
|
|
|
- isToday: currentDay.isSame(moment(), "day"),
|
|
|
|
|
- dayOfWeek: currentDay.weekday(),
|
|
|
|
|
- dayNumber: currentDay.date(),
|
|
|
|
|
- date: currentDay,
|
|
|
|
|
|
|
+ originalIndex: allSelectedYears.current.findIndex((day) => moment(currentYear).isSame(day, "year")),
|
|
|
|
|
+ isToday: currentYear.isSame(moment(), "year"),
|
|
|
|
|
+ title: String(currentYearNumber),
|
|
|
|
|
+ yearNumber: currentYearNumber,
|
|
|
|
|
+ year: currentYearNumber,
|
|
|
|
|
+ date: currentYear,
|
|
|
isDisabled,
|
|
isDisabled,
|
|
|
isSelected
|
|
isSelected
|
|
|
};
|
|
};
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- return allDays;
|
|
|
|
|
|
|
+ return allYears;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const renderDay = ({
|
|
const renderDay = ({
|
|
|
- weekIndex,
|
|
|
|
|
- dayIndex,
|
|
|
|
|
- dayItem
|
|
|
|
|
|
|
+ yearIndex,
|
|
|
|
|
+ yearItem
|
|
|
}: {
|
|
}: {
|
|
|
- dayItem: CalendarYear;
|
|
|
|
|
- weekIndex: number;
|
|
|
|
|
- dayIndex: number;
|
|
|
|
|
|
|
+ yearItem: CalendarYear;
|
|
|
|
|
+ yearIndex: number;
|
|
|
}) => {
|
|
}) => {
|
|
|
- const isLastItemSelected = dayItem.isSelected && dayItem.originalIndex === allSelectedDays.current.length - 1;
|
|
|
|
|
- const isFirstItemSelected = dayItem.isSelected && dayItem.originalIndex === 0;
|
|
|
|
|
|
|
+ const isLastItemSelected = yearItem.isSelected && yearItem.originalIndex === allSelectedYears.current.length - 1;
|
|
|
|
|
+ const isFirstItemSelected = yearItem.isSelected && yearItem.originalIndex === 0;
|
|
|
|
|
|
|
|
const selectionStyle: Array<Mutable<ViewStyle> | null> = [
|
|
const selectionStyle: Array<Mutable<ViewStyle> | null> = [
|
|
|
- isFirstItemSelected && allSelectedDays.current.length > 1 ? {
|
|
|
|
|
|
|
+ isFirstItemSelected && allSelectedYears.current.length > 1 ? {
|
|
|
borderBottomRightRadius: 0,
|
|
borderBottomRightRadius: 0,
|
|
|
borderTopRightRadius: 0
|
|
borderTopRightRadius: 0
|
|
|
} : null,
|
|
} : null,
|
|
|
- isLastItemSelected && allSelectedDays.current.length > 1 ? {
|
|
|
|
|
|
|
+ isLastItemSelected && allSelectedYears.current.length > 1 ? {
|
|
|
borderBottomLeftRadius: 0,
|
|
borderBottomLeftRadius: 0,
|
|
|
borderTopLeftRadius: 0
|
|
borderTopLeftRadius: 0
|
|
|
} : null
|
|
} : null
|
|
@@ -221,7 +240,7 @@ const YearSelector = ({
|
|
|
|
|
|
|
|
let dayTitleColor: keyof NCoreUIKit.TextContentColors = "mid";
|
|
let dayTitleColor: keyof NCoreUIKit.TextContentColors = "mid";
|
|
|
|
|
|
|
|
- if(dayItem.isSelected && !isLastItemSelected && !isFirstItemSelected) {
|
|
|
|
|
|
|
+ if(yearItem.isSelected && !isLastItemSelected && !isFirstItemSelected) {
|
|
|
dayTitleColor = "emphasized";
|
|
dayTitleColor = "emphasized";
|
|
|
|
|
|
|
|
selectionStyle.push({
|
|
selectionStyle.push({
|
|
@@ -230,34 +249,34 @@ const YearSelector = ({
|
|
|
borderTopRightRadius: 0,
|
|
borderTopRightRadius: 0,
|
|
|
borderTopLeftRadius: 0
|
|
borderTopLeftRadius: 0
|
|
|
});
|
|
});
|
|
|
- } else if(dayItem.isSelected) {
|
|
|
|
|
|
|
+ } else if(yearItem.isSelected) {
|
|
|
dayTitleColor = "onPrimary";
|
|
dayTitleColor = "onPrimary";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(!dayItem.isCurrentView || dayItem.isDisabled) {
|
|
|
|
|
|
|
+ if(yearItem.isDisabled) {
|
|
|
dayTitleColor = "disabled";
|
|
dayTitleColor = "disabled";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return <TouchableOpacity
|
|
return <TouchableOpacity
|
|
|
- disabled={!dayItem.isCurrentView || dayItem.isDisabled}
|
|
|
|
|
- key={`day-${weekIndex}-${dayIndex}`}
|
|
|
|
|
|
|
+ disabled={yearItem.isDisabled}
|
|
|
|
|
+ key={`year-${yearIndex}`}
|
|
|
onPress={() => {
|
|
onPress={() => {
|
|
|
- if(!dayItem.isCurrentView) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
if(variant === "single") {
|
|
if(variant === "single") {
|
|
|
- selectObject(dayItem.date.toDate());
|
|
|
|
|
|
|
+ const newDate = date as Date;
|
|
|
|
|
+
|
|
|
|
|
+ newDate.setFullYear(yearItem.date.toDate().getFullYear());
|
|
|
|
|
+
|
|
|
|
|
+ selectObject(newDate);
|
|
|
} else if(variant === "range") {
|
|
} else if(variant === "range") {
|
|
|
if(!dateRange || !dateRange.start) {
|
|
if(!dateRange || !dateRange.start) {
|
|
|
selectMultipleObject({
|
|
selectMultipleObject({
|
|
|
- start: new Date(dayItem.date.toDate().setHours(0, 0, 0)),
|
|
|
|
|
|
|
+ start: new Date(yearItem.date.toDate().setHours(0, 0, 0)),
|
|
|
end: undefined
|
|
end: undefined
|
|
|
});
|
|
});
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(dateRange && moment(dateRange.start).isSame(dayItem.date, "day")) {
|
|
|
|
|
|
|
+ if(dateRange && moment(dateRange.start).isSame(yearItem.date, "year")) {
|
|
|
selectMultipleObject({
|
|
selectMultipleObject({
|
|
|
start: undefined,
|
|
start: undefined,
|
|
|
end: undefined
|
|
end: undefined
|
|
@@ -266,28 +285,28 @@ const YearSelector = ({
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(dateRange && !dateRange.end) {
|
|
if(dateRange && !dateRange.end) {
|
|
|
- if(multipleSelectDayLimit && moment(dayItem.date).diff(dateRange.start, "days") >= multipleSelectDayLimit) {
|
|
|
|
|
|
|
+ if(multipleSelectDayLimit && moment(yearItem.date).diff(dateRange.start, "days") >= multipleSelectDayLimit) {
|
|
|
NCoreUIKitToast.open({
|
|
NCoreUIKitToast.open({
|
|
|
title: localize("maximum-selection-number-of-days-limit-exceeds")
|
|
title: localize("maximum-selection-number-of-days-limit-exceeds")
|
|
|
});
|
|
});
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(multipleSelectMinimumRequiredDayCount && moment(dayItem.date).diff(dateRange.start, "days") + 1 < multipleSelectMinimumRequiredDayCount) {
|
|
|
|
|
|
|
+ if(multipleSelectMinimumRequiredDayCount && moment(yearItem.date).diff(dateRange.start, "days") + 1 < multipleSelectMinimumRequiredDayCount) {
|
|
|
NCoreUIKitToast.open({
|
|
NCoreUIKitToast.open({
|
|
|
title: localize("minimum-selection-number-of-days-required-not-provided")
|
|
title: localize("minimum-selection-number-of-days-required-not-provided")
|
|
|
});
|
|
});
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(moment(dayItem.date).isBefore(dateRange.start)) {
|
|
|
|
|
|
|
+ if(moment(yearItem.date).isBefore(dateRange.start)) {
|
|
|
selectMultipleObject({
|
|
selectMultipleObject({
|
|
|
- start: new Date(dayItem.date.toDate().setHours(0, 0, 0)),
|
|
|
|
|
|
|
+ start: new Date(yearItem.date.toDate().setHours(0, 0, 0)),
|
|
|
end: undefined
|
|
end: undefined
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
selectMultipleObject({
|
|
selectMultipleObject({
|
|
|
- end: new Date(dayItem.date.toDate().setHours(23, 59, 59)),
|
|
|
|
|
|
|
+ end: new Date(yearItem.date.toDate().setHours(23, 59, 59)),
|
|
|
start: dateRange?.start
|
|
start: dateRange?.start
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -295,7 +314,7 @@ const YearSelector = ({
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
selectMultipleObject({
|
|
selectMultipleObject({
|
|
|
- start: dayItem.date.toDate(),
|
|
|
|
|
|
|
+ start: yearItem.date.toDate(),
|
|
|
end: undefined
|
|
end: undefined
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -303,15 +322,15 @@ const YearSelector = ({
|
|
|
style={[
|
|
style={[
|
|
|
stylesheet.day,
|
|
stylesheet.day,
|
|
|
dayDynamicStyle,
|
|
dayDynamicStyle,
|
|
|
- dayItem.isSelected ? {
|
|
|
|
|
|
|
+ yearItem.isSelected ? {
|
|
|
backgroundColor: colors.content.container.primary,
|
|
backgroundColor: colors.content.container.primary,
|
|
|
borderColor: colors.content.container.primary
|
|
borderColor: colors.content.container.primary
|
|
|
} : null,
|
|
} : null,
|
|
|
- dayItem.isSelected && !isLastItemSelected && !isFirstItemSelected ? {
|
|
|
|
|
|
|
+ yearItem.isSelected && !isLastItemSelected && !isFirstItemSelected ? {
|
|
|
backgroundColor: colors.content.container.emphasized,
|
|
backgroundColor: colors.content.container.emphasized,
|
|
|
borderColor: colors.content.container.emphasized
|
|
borderColor: colors.content.container.emphasized
|
|
|
} : null,
|
|
} : null,
|
|
|
- dayItem.isSelected && (dayItem.isDisabled || !dayItem.isCurrentView) ? {
|
|
|
|
|
|
|
+ yearItem.isSelected && (yearItem.isDisabled) ? {
|
|
|
opacity: 0.33
|
|
opacity: 0.33
|
|
|
} : null,
|
|
} : null,
|
|
|
...selectionStyle
|
|
...selectionStyle
|
|
@@ -321,14 +340,14 @@ const YearSelector = ({
|
|
|
variant="labelLargeSize"
|
|
variant="labelLargeSize"
|
|
|
color={dayTitleColor}
|
|
color={dayTitleColor}
|
|
|
>
|
|
>
|
|
|
- {dayItem.dayNumber}
|
|
|
|
|
|
|
+ {yearItem.title}
|
|
|
</Text>
|
|
</Text>
|
|
|
- {isShowTodayIndicator && dayItem.isToday ? <View
|
|
|
|
|
|
|
+ {isShowTodayIndicator && yearItem.isToday ? <View
|
|
|
style={[
|
|
style={[
|
|
|
stylesheet.todayIndicator,
|
|
stylesheet.todayIndicator,
|
|
|
selectionStyle,
|
|
selectionStyle,
|
|
|
todayIndicatorDynamicStyle,
|
|
todayIndicatorDynamicStyle,
|
|
|
- dayItem.isSelected ? {
|
|
|
|
|
|
|
+ yearItem.isSelected ? {
|
|
|
borderColor: colors.content.border.subtle
|
|
borderColor: colors.content.border.subtle
|
|
|
} : null
|
|
} : null
|
|
|
]}
|
|
]}
|
|
@@ -345,7 +364,7 @@ const YearSelector = ({
|
|
|
>
|
|
>
|
|
|
<TouchableOpacity
|
|
<TouchableOpacity
|
|
|
onPress={() => {
|
|
onPress={() => {
|
|
|
- const prevViewDate = moment(viewDate).clone().subtract(1, "months");
|
|
|
|
|
|
|
+ const prevViewDate = moment(viewDate).clone().subtract(12, "years");
|
|
|
setViewDate(prevViewDate.toDate());
|
|
setViewDate(prevViewDate.toDate());
|
|
|
}}
|
|
}}
|
|
|
style={[
|
|
style={[
|
|
@@ -361,11 +380,16 @@ const YearSelector = ({
|
|
|
variant="labelLargeSize"
|
|
variant="labelLargeSize"
|
|
|
color="high"
|
|
color="high"
|
|
|
>
|
|
>
|
|
|
- {moment(viewDate).format("MMMM YYYY")}
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ years && years.length ?
|
|
|
|
|
+ `${moment(years[0]?.date.toDate()).format("YYYY")} - ${moment(years[years.length - 1]?.date.toDate()).format("YYYY")}`
|
|
|
|
|
+ :
|
|
|
|
|
+ null
|
|
|
|
|
+ }
|
|
|
</Text>
|
|
</Text>
|
|
|
<TouchableOpacity
|
|
<TouchableOpacity
|
|
|
onPress={() => {
|
|
onPress={() => {
|
|
|
- const nextViewDate = moment(viewDate).clone().add(1, "months");
|
|
|
|
|
|
|
+ const nextViewDate = moment(viewDate).clone().add(12, "years");
|
|
|
setViewDate(nextViewDate.toDate());
|
|
setViewDate(nextViewDate.toDate());
|
|
|
}}
|
|
}}
|
|
|
style={[
|
|
style={[
|
|
@@ -380,14 +404,6 @@ const YearSelector = ({
|
|
|
</View>;
|
|
</View>;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- let weekDays = moment.weekdays(localeBasedFirstDayOfWeek ? true : false);
|
|
|
|
|
-
|
|
|
|
|
- if(yearLengthType === "short") {
|
|
|
|
|
- weekDays = moment.weekdaysShort(localeBasedFirstDayOfWeek ? true : false);
|
|
|
|
|
- } else if(yearLengthType === "very-short") {
|
|
|
|
|
- weekDays = moment.weekdaysMin(localeBasedFirstDayOfWeek ? true : false);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
return <View
|
|
return <View
|
|
|
style={[
|
|
style={[
|
|
|
stylesheet.container
|
|
stylesheet.container
|
|
@@ -401,34 +417,23 @@ const YearSelector = ({
|
|
|
stylesheet.contentContainer
|
|
stylesheet.contentContainer
|
|
|
]}
|
|
]}
|
|
|
>
|
|
>
|
|
|
- {weekDays.map((weekItem, weekIndex) => {
|
|
|
|
|
- const days = monthDays.filter((dayItem) => dayItem.dayOfWeek === weekIndex);
|
|
|
|
|
|
|
+ {years && years.length ? YEAR_LINES.map((yItem, yIndex) => {
|
|
|
|
|
+ const currentYears = yItem.map(yI => years[yI]);
|
|
|
|
|
|
|
|
return <View
|
|
return <View
|
|
|
- key={`day-column-${weekIndex}`}
|
|
|
|
|
|
|
+ key={`year-row-${yIndex}`}
|
|
|
style={[
|
|
style={[
|
|
|
- stylesheet.columnContainer
|
|
|
|
|
|
|
+ stylesheet.rowContainer
|
|
|
]}
|
|
]}
|
|
|
>
|
|
>
|
|
|
- <Text
|
|
|
|
|
- variant="labelMediumSize"
|
|
|
|
|
- numberOfLines={1}
|
|
|
|
|
- color="low"
|
|
|
|
|
- style={{
|
|
|
|
|
- ...dayOfWeekDynamicStyle
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
- {weekItem}
|
|
|
|
|
- </Text>
|
|
|
|
|
- {days.map((dayItem, dayIndex) => {
|
|
|
|
|
|
|
+ {currentYears.map((yearItem, yearIndex) => {
|
|
|
return renderDay({
|
|
return renderDay({
|
|
|
- weekIndex,
|
|
|
|
|
- dayIndex,
|
|
|
|
|
- dayItem
|
|
|
|
|
|
|
+ yearItem: yearItem as CalendarYear,
|
|
|
|
|
+ yearIndex
|
|
|
});
|
|
});
|
|
|
})}
|
|
})}
|
|
|
</View>;
|
|
</View>;
|
|
|
- })}
|
|
|
|
|
|
|
+ }) : null}
|
|
|
</View>
|
|
</View>
|
|
|
</View>;
|
|
</View>;
|
|
|
};
|
|
};
|