source: trip-planner-front/node_modules/@angular/material/esm2015/datepicker/date-range-selection-strategy.js@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 8.6 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { Injectable, InjectionToken, Optional, SkipSelf } from '@angular/core';
9import { DateAdapter } from '@angular/material/core';
10import { DateRange } from './date-selection-model';
11/** Injection token used to customize the date range selection behavior. */
12export const MAT_DATE_RANGE_SELECTION_STRATEGY = new InjectionToken('MAT_DATE_RANGE_SELECTION_STRATEGY');
13/** Provides the default date range selection behavior. */
14export class DefaultMatCalendarRangeStrategy {
15 constructor(_dateAdapter) {
16 this._dateAdapter = _dateAdapter;
17 }
18 selectionFinished(date, currentRange) {
19 let { start, end } = currentRange;
20 if (start == null) {
21 start = date;
22 }
23 else if (end == null && date && this._dateAdapter.compareDate(date, start) >= 0) {
24 end = date;
25 }
26 else {
27 start = date;
28 end = null;
29 }
30 return new DateRange(start, end);
31 }
32 createPreview(activeDate, currentRange) {
33 let start = null;
34 let end = null;
35 if (currentRange.start && !currentRange.end && activeDate) {
36 start = currentRange.start;
37 end = activeDate;
38 }
39 return new DateRange(start, end);
40 }
41}
42DefaultMatCalendarRangeStrategy.decorators = [
43 { type: Injectable }
44];
45DefaultMatCalendarRangeStrategy.ctorParameters = () => [
46 { type: DateAdapter }
47];
48/** @docs-private */
49export function MAT_CALENDAR_RANGE_STRATEGY_PROVIDER_FACTORY(parent, adapter) {
50 return parent || new DefaultMatCalendarRangeStrategy(adapter);
51}
52/** @docs-private */
53export const MAT_CALENDAR_RANGE_STRATEGY_PROVIDER = {
54 provide: MAT_DATE_RANGE_SELECTION_STRATEGY,
55 deps: [[new Optional(), new SkipSelf(), MAT_DATE_RANGE_SELECTION_STRATEGY], DateAdapter],
56 useFactory: MAT_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