chore: prettier formatting

This commit is contained in:
Sean Perkins
2024-01-19 20:48:58 -05:00
parent a65bce2ce5
commit 0ddd5d51a4
7 changed files with 44 additions and 25 deletions

View File

@@ -28,13 +28,13 @@ export type TitleSelectedDatesFormatter = (selectedDates: string[]) => string;
export type DatetimeHighlightStyle =
| {
textColor: string;
backgroundColor?: string;
}
textColor: string;
backgroundColor?: string;
}
| {
textColor?: string;
backgroundColor: string;
};
textColor?: string;
backgroundColor: string;
};
export type DatetimeHighlight = { date: string } & DatetimeHighlightStyle;
@@ -42,7 +42,7 @@ export type DatetimeHighlightCallback = (dateIsoString: string) => DatetimeHighl
export type DatetimeHourCycle = 'h11' | 'h12' | 'h23' | 'h24';
export type DatetimeRangeValue = { start: string, end: string };
export type DatetimeRangeValue = { start: string; end: string };
export type DatetimeMultipleValue = string[];

View File

@@ -329,10 +329,12 @@
&.calendar-day-range-start:not(.calendar-day-range-end)::after,
&.calendar-day-range-end:not(.calendar-day-range-start)::before {
position: absolute;
width: 50%;
height: 100%;
content: " ";
position: absolute;
.calendar-day {
background: var(--ion-color-base);
@@ -342,13 +344,13 @@
}
&.calendar-day-range-start::after {
right: 0;
@include position(null, 0, null, null);
background: current-color(base, 0.1);
}
&.calendar-day-range-end::before {
left: 0;
@include position(null, null, null, 0);
background: current-color(base, 0.1);
}

View File

@@ -179,19 +179,21 @@
&.calendar-day-range-start:not(.calendar-day-range-end)::after,
&.calendar-day-range-end:not(.calendar-day-range-start)::before {
width: 50%;
height: 100%;
content: " ";
position: absolute;
width: 50%;
height: 100%;
background: current-color(base, 0.1);
content: " ";
}
&.calendar-day-range-start::after {
right: 0;
@include position(null, 0, null, null);
}
&.calendar-day-range-end::before {
left: 0;
@include position(null, null, null, 0);
}
}

View File

@@ -368,4 +368,4 @@ export const activePartsToArray = (activeParts: DatetimeParts | DatetimeRangePar
return [activeParts.start, activeParts.end];
}
return [activeParts];
}
};

View File

@@ -1,4 +1,9 @@
import type { DatetimeMultipleValue, DatetimeParts, DatetimeRangeParts, DatetimeRangeValue } from '../datetime-interface';
import type {
DatetimeMultipleValue,
DatetimeParts,
DatetimeRangeParts,
DatetimeRangeValue,
} from '../datetime-interface';
import { isAfter, isBefore, isSameDay } from './comparison';
import { getNumDaysInMonth } from './helpers';
@@ -15,8 +20,12 @@ const fourDigit = (val: number | undefined): string => {
export function convertDataToISO(data: DatetimeParts): string;
export function convertDataToISO(data: DatetimeRangeParts): DatetimeRangeValue;
export function convertDataToISO(data: DatetimeParts[]): DatetimeMultipleValue;
export function convertDataToISO(data: DatetimeParts | DatetimeRangeParts | DatetimeParts[]): string | DatetimeMultipleValue;
export function convertDataToISO(data: DatetimeParts | DatetimeRangeParts | DatetimeParts[]): string | DatetimeMultipleValue | DatetimeRangeValue {
export function convertDataToISO(
data: DatetimeParts | DatetimeRangeParts | DatetimeParts[]
): string | DatetimeMultipleValue;
export function convertDataToISO(
data: DatetimeParts | DatetimeRangeParts | DatetimeParts[]
): string | DatetimeMultipleValue | DatetimeRangeValue {
// Multiple selection
if (Array.isArray(data)) {
return data.map((parts) => convertDataToISO(parts));

View File

@@ -63,8 +63,12 @@ export function parseDate(val: DatetimeMultipleValue): DatetimeParts[] | undefin
export function parseDate(val: DatetimeRangeValue): DatetimeParts[] | undefined;
export function parseDate(val: undefined | null): undefined;
export function parseDate(val: string | DatetimeMultipleValue): DatetimeParts | DatetimeParts[] | undefined;
export function parseDate(val: string | DatetimeMultipleValue | DatetimeRangeValue | undefined | null): DatetimeParts | DatetimeParts[] | undefined;
export function parseDate(val: string | DatetimeMultipleValue | DatetimeRangeValue | undefined | null): DatetimeParts | DatetimeParts[] | undefined {
export function parseDate(
val: string | DatetimeMultipleValue | DatetimeRangeValue | undefined | null
): DatetimeParts | DatetimeParts[] | undefined;
export function parseDate(
val: string | DatetimeMultipleValue | DatetimeRangeValue | undefined | null
): DatetimeParts | DatetimeParts[] | undefined {
if (Array.isArray(val)) {
const parsedArray: DatetimeParts[] = [];
for (const valStr of val) {

View File

@@ -226,7 +226,7 @@ export const isDateRangeStart = (referenceParts: DatetimeParts, activeParts: Dat
return startDate !== undefined && isSameDay(referenceParts, startDate);
}
return false;
}
};
export const isDateRangeEnd = (referenceParts: DatetimeParts, activeParts: DatetimeRangeParts) => {
if (activeParts !== undefined && Array.isArray(activeParts)) {
@@ -234,14 +234,16 @@ export const isDateRangeEnd = (referenceParts: DatetimeParts, activeParts: Datet
return endDate !== undefined && isSameDay(referenceParts, endDate);
}
return false;
}
};
export const isDateInRange = (referenceParts: DatetimeParts, activeParts: DatetimeRangeParts) => {
if (activeParts !== undefined && Array.isArray(activeParts)) {
const startDate = activeParts[0];
const endDate = activeParts[1];
const isAfterStart = startDate !== undefined && (isAfter(referenceParts, startDate) || isSameDay(referenceParts, startDate));
const isBeforeEnd = endDate !== undefined && (isBefore(referenceParts, endDate) || isSameDay(referenceParts, endDate));
const isAfterStart =
startDate !== undefined && (isAfter(referenceParts, startDate) || isSameDay(referenceParts, startDate));
const isBeforeEnd =
endDate !== undefined && (isBefore(referenceParts, endDate) || isSameDay(referenceParts, endDate));
return isAfterStart && isBeforeEnd;
}
return false;