UNPKG

@progress/kendo-angular-scheduler

Version:

Kendo UI Scheduler Angular - Outlook or Google-style angular scheduler calendar. Full-featured and customizable embedded scheduling from the creator developers trust for professional UI components.

167 lines (166 loc) 7.43 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Component, Input } from '@angular/core'; import { ToolbarService } from './toolbar.service'; import { LocalizationService } from '@progress/kendo-angular-l10n'; import { ButtonComponent } from '@progress/kendo-angular-buttons'; import { FocusableDirective } from '../navigation/focusable.directive'; import { NgIf, NgFor } from '@angular/common'; import * as i0 from "@angular/core"; import * as i1 from "./toolbar.service"; import * as i2 from "@progress/kendo-angular-l10n"; /** * A toolbar component which contains the controls for switching the views * ([see example]({% slug toolbar_scheduler %}#toc-including-the-built-in-components)). * * To render the view-selection buttons, include the component in the * [toolbar template]({% slug api_scheduler_toolbartemplatedirective %}). */ export class ToolbarViewSelectorComponent { service; localization; /** * Specifies the current width of the Toolbar (in pixels) so the responsive calculations can be made. * The ([schedulerResize]({% slug api_scheduler_schedulercomponent %}#toc-schedulerresize)) event can be used in order to obtain the Toolbar width. */ toolbarWidth; /** * Specifies the Toolbar width (in pixels) at which the responsive behavior should be enabled. * The responsive behavior means that the ButtonGroup with the views will be replaced by a `select` element. * * @default 1024 */ responsiveBreakpoint = 1024; /** * @hidden */ get ctx() { return this.service.context; } /** * @hidden */ get selectView() { return this.localization.get('selectView'); } detachDomEvents; constructor(service, localization) { this.service = service; this.localization = localization; } ngOnDestroy() { if (this.detachDomEvents) { this.detachDomEvents(); } } /** * @hidden */ select(view) { if (this.ctx.selectedView !== view) { this.service.navigate({ type: 'view-change', view: view }); } } /** * @hidden */ onChange(e) { const view = this.ctx.views.find(view => view.name === e.target.value); if (view) { this.select(view); } } /** * @hidden */ isSelected(view) { return this.ctx.selectedView === view; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ToolbarViewSelectorComponent, deps: [{ token: i1.ToolbarService }, { token: i2.LocalizationService }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ToolbarViewSelectorComponent, isStandalone: true, selector: "[kendoSchedulerToolbarViewSelector]", inputs: { toolbarWidth: "toolbarWidth", responsiveBreakpoint: "responsiveBreakpoint" }, ngImport: i0, template: ` <select *ngIf="ctx.views?.length > 1 && toolbarWidth <= responsiveBreakpoint" (change)="onChange($event)" class="k-views-dropdown k-picker-md k-rounded-md k-picker-solid k-dropdownlist k-picker" [attr.aria-label]="selectView" [kendoSchedulerFocusIndex]="0" containerType="toolbar"> <option *ngFor="let view of ctx.views" [selected]="isSelected(view) === true" [value]="view.name" > {{ view.title }} </option> </select> <span *ngIf="toolbarWidth > responsiveBreakpoint" class="k-toolbar-button-group k-scheduler-views k-button-group k-button-group-solid" role="group" > <button kendoButton type="button" *ngFor="let view of ctx.views" [selected]="isSelected(view)" [attr.aria-pressed]="isSelected(view)" (click)="select(view)" [kendoSchedulerFocusIndex]="0" containerType="toolbar"> <span class="k-button-text"> {{ view.title }} </span> </button> </span> `, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: FocusableDirective, selector: "[kendoSchedulerFocusIndex]", inputs: ["kendoSchedulerFocusIndex", "containerType"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: ButtonComponent, selector: "button[kendoButton]", inputs: ["arrowIcon", "toggleable", "togglable", "selected", "tabIndex", "imageUrl", "iconClass", "icon", "disabled", "size", "rounded", "fillMode", "themeColor", "svgIcon", "primary", "look"], outputs: ["selectedChange", "click"], exportAs: ["kendoButton"] }] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ToolbarViewSelectorComponent, decorators: [{ type: Component, args: [{ // eslint-disable-next-line @angular-eslint/component-selector selector: '[kendoSchedulerToolbarViewSelector]', template: ` <select *ngIf="ctx.views?.length > 1 && toolbarWidth <= responsiveBreakpoint" (change)="onChange($event)" class="k-views-dropdown k-picker-md k-rounded-md k-picker-solid k-dropdownlist k-picker" [attr.aria-label]="selectView" [kendoSchedulerFocusIndex]="0" containerType="toolbar"> <option *ngFor="let view of ctx.views" [selected]="isSelected(view) === true" [value]="view.name" > {{ view.title }} </option> </select> <span *ngIf="toolbarWidth > responsiveBreakpoint" class="k-toolbar-button-group k-scheduler-views k-button-group k-button-group-solid" role="group" > <button kendoButton type="button" *ngFor="let view of ctx.views" [selected]="isSelected(view)" [attr.aria-pressed]="isSelected(view)" (click)="select(view)" [kendoSchedulerFocusIndex]="0" containerType="toolbar"> <span class="k-button-text"> {{ view.title }} </span> </button> </span> `, standalone: true, imports: [NgIf, FocusableDirective, NgFor, ButtonComponent] }] }], ctorParameters: function () { return [{ type: i1.ToolbarService }, { type: i2.LocalizationService }]; }, propDecorators: { toolbarWidth: [{ type: Input }], responsiveBreakpoint: [{ type: Input }] } });