UNPKG

@progress/kendo-angular-dateinputs

Version:

Kendo UI for Angular Date Inputs Package - Everything you need to add date selection functionality to apps (DatePicker, TimePicker, DateInput, DateRangePicker, DateTimePicker, Calendar, and MultiViewCalendar).

61 lines (60 loc) 2.6 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Injectable } from '@angular/core'; import { Action } from '../models/navigation-action.enum'; import { BusViewService } from '../services/bus-view.service'; import { normalizeKeys } from '@progress/kendo-angular-common'; import * as i0 from "@angular/core"; import * as i1 from "../services/bus-view.service"; const KEY_TO_ACTION = { 'PageUp': Action.PrevView, 'PageDown': Action.NextView, 'End': Action.LastInView, 'Home': Action.FirstInView, 'ArrowLeft': Action.Left, 'ArrowUp': Action.Up, 'ArrowRight': Action.Right, 'ArrowDown': Action.Down, 'meta+ArrowUp': Action.UpperView, 'meta+ArrowDown': Action.LowerView }; /** * @hidden */ export class NavigationService { bus; constructor(bus) { this.bus = bus; } action(event) { // on some keyboards arrow keys, PageUp/Down, and Home/End are mapped to Numpad keys const code = normalizeKeys(event); const action = `${event.ctrlKey || event.metaKey ? 'meta+' : ''}${code}`; return KEY_TO_ACTION[action]; } move(value, action, activeView) { const service = this.bus.service(activeView); if (!service) { return value; } if (action === Action.UpperView && this.bus.canMoveUp(activeView)) { this.bus.moveUp(activeView); return value; } if (action === Action.LowerView && this.bus.canMoveDown(activeView)) { this.bus.moveDown(activeView); return value; } return service.move(value, action); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: NavigationService, deps: [{ token: i1.BusViewService }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: NavigationService, providedIn: 'root' }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: NavigationService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: () => [{ type: i1.BusViewService }] });