import type Calendar from "./Calendar.js";
import Icon from "./Icon.js";
import slimArowLeft from "@ui5/webcomponents-icons/dist/slim-arrow-left.js";
import slimArowRight from "@ui5/webcomponents-icons/dist/slim-arrow-right.js";
interface CalendarHeaderOptions {
headerText?: {
monthText: string;
yearText: string;
secondMonthText?: string;
secondYearText?: string;
};
isFirst?: boolean;
isLast?: boolean;
isMultiple?: boolean;
}
export default function CalendarHeaderTemplate(this: Calendar, options?: CalendarHeaderOptions) {
const headerText = options?.headerText;
const isFirst = options?.isFirst ?? true;
const isLast = options?.isLast ?? true;
const isMultiple = options?.isMultiple ?? false;
const monthText = headerText?.monthText ?? this._headerMonthButtonText;
const yearText = headerText?.yearText ?? this._headerYearButtonText;
const secondMonthText = headerText?.secondMonthText ?? this.secondMonthButtonText;
const secondYearText = headerText?.secondYearText ?? this._headerYearButtonTextSecType;
return (
{renderPrevButton.call(this, isFirst, isMultiple)}
{renderMiddleButtons.call(this, {
monthText: monthText || "",
yearText: yearText || "",
secondMonthText: secondMonthText || "",
secondYearText: secondYearText || "",
})}
{renderNextButton.call(this, isFirst, isLast, isMultiple)}
);
}
function renderPrevButton(this: Calendar, isFirst: boolean, isMultiple: boolean) {
if (!isFirst && isMultiple) {
return ;
}
return (
);
}
function renderMiddleButtons(
this: Calendar,
headerText: {
monthText: string;
yearText: string;
secondMonthText?: string;
secondYearText?: string;
}
) {
return (
);
}
function renderNextButton(this: Calendar, isFirst: boolean, isLast: boolean, isMultiple: boolean) {
// In portrait or compact mode, show next button only on first calendar
// In landscape mode, show next button only on last calendar
const isVertical = this._portraitView || this._isCompactMode;
const shouldShowNextButton = !isMultiple || (isVertical ? isFirst : isLast);
const shouldShowSpacer = isMultiple && (isVertical ? isLast : !isLast);
if (shouldShowNextButton) {
return (
);
}
if (shouldShowSpacer) {
return ;
}
return null;
}