@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.
182 lines (181 loc) • 7.41 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* 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 * as i0 from "@angular/core";
import * as i1 from "./toolbar.service";
import * as i2 from "@progress/kendo-angular-l10n";
/**
* A toolbar component that contains controls for switching views
* ([see example](slug:toolbar_scheduler#toc-including-the-built-in-components)).
*
* To render the view-selection buttons, include this component in the [toolbar template](slug:api_scheduler_toolbartemplatedirective).
*
* @example
* ```html
* <kendo-scheduler>
* <ng-template kendoSchedulerToolbarTemplate>
* <div kendoSchedulerToolbarViewSelector responsiveBreakpoint]="960"></div>
* </ng-template>
* </kendo-scheduler>
* ```
*/
export class ToolbarViewSelectorComponent {
service;
localization;
/**
* Sets the current width of the Toolbar in pixels for responsive calculations. Use the [`schedulerResize`](slug:api_scheduler_schedulercomponent#toc-schedulerresize) event to get the Toolbar width.
*/
toolbarWidth;
/**
* Sets the Toolbar width in pixels at which responsive behavior is enabled. When enabled, the ButtonGroup with the views is 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: "18.2.14", ngImport: i0, type: ToolbarViewSelectorComponent, deps: [{ token: i1.ToolbarService }, { token: i2.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ToolbarViewSelectorComponent, isStandalone: true, selector: "[kendoSchedulerToolbarViewSelector]", inputs: { toolbarWidth: "toolbarWidth", responsiveBreakpoint: "responsiveBreakpoint" }, ngImport: i0, template: `
(ctx.views?.length > 1 && toolbarWidth <= responsiveBreakpoint) {
<select
(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">
(view of ctx.views; track view) {
<option
[selected]="isSelected(view) === true"
[value]="view.name"
>
{{ view.title }}
</option>
}
</select>
}
(toolbarWidth > responsiveBreakpoint) {
<span
class="k-toolbar-button-group k-scheduler-views k-button-group k-button-group-solid"
role="group"
>
(view of ctx.views; track view) {
<button kendoButton
type="button"
[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: FocusableDirective, selector: "[kendoSchedulerFocusIndex]", inputs: ["kendoSchedulerFocusIndex", "containerType"] }, { 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: "18.2.14", ngImport: i0, type: ToolbarViewSelectorComponent, decorators: [{
type: Component,
args: [{
// eslint-disable-next-line @angular-eslint/component-selector
selector: '[kendoSchedulerToolbarViewSelector]',
template: `
(ctx.views?.length > 1 && toolbarWidth <= responsiveBreakpoint) {
<select
(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">
(view of ctx.views; track view) {
<option
[selected]="isSelected(view) === true"
[value]="view.name"
>
{{ view.title }}
</option>
}
</select>
}
(toolbarWidth > responsiveBreakpoint) {
<span
class="k-toolbar-button-group k-scheduler-views k-button-group k-button-group-solid"
role="group"
>
(view of ctx.views; track view) {
<button kendoButton
type="button"
[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: [FocusableDirective, ButtonComponent]
}]
}], ctorParameters: () => [{ type: i1.ToolbarService }, { type: i2.LocalizationService }], propDecorators: { toolbarWidth: [{
type: Input
}], responsiveBreakpoint: [{
type: Input
}] } });