diff --git a/.storybook/stories/datepicker/datepicker.stories.ts b/.storybook/stories/datepicker/datepicker.stories.ts index 8eea1ec894..a0a92c6498 100644 --- a/.storybook/stories/datepicker/datepicker.stories.ts +++ b/.storybook/stories/datepicker/datepicker.stories.ts @@ -36,19 +36,14 @@ export default { getDateString: { control: { disable: true }, table: { disable: true } }, }, args: { + // inputs disabled: false, placeholder: '', id: '', // outputs clrDateChange: action('clrDateChange'), // story helpers - getDateObject: date => { - try { - return date && new Date(date).toISOString(); - } catch { - return undefined; - } - }, + getDateObject: date => new Date(date), getDateString: date => date && new Date(date).toISOString().split('T')[0], }, }; @@ -61,7 +56,7 @@ const DatePickerTemplate: StoryFn = args => ({ #date type="date" [id]="id" - [clrDate]="getDateObject(date.value || clrDate)" + [clrDate]="getDateObject(clrDate || date.value)" [min]="getDateString(min)" [max]="getDateString(max)" [disabled]="disabled" diff --git a/.storybook/stories/datepicker/daterangepicker.stories.ts b/.storybook/stories/datepicker/daterangepicker.stories.ts deleted file mode 100644 index fa4c288b04..0000000000 --- a/.storybook/stories/datepicker/daterangepicker.stories.ts +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2016-2024 Broadcom. All Rights Reserved. - * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. - * This software is released under MIT license. - * The full license information can be found in LICENSE in the root directory of this project. - */ - -import { ClrDatepickerModule, ClrDateRangeEndInput, ClrDateRangeStartInput, ClrFormsModule } from '@clr/angular'; -import { action } from '@storybook/addon-actions'; -import { moduleMetadata, StoryFn, StoryObj } from '@storybook/angular'; -import { CommonModules } from 'helpers/common'; - -export default { - title: 'Datepicker/DateRangepicker', - component: ClrDateRangeStartInput, - subcomponents: { ClrDateRangeEndInput }, - decorators: [ - moduleMetadata({ - imports: [...CommonModules, ClrFormsModule, ClrDatepickerModule], - }), - ], - argTypes: { - // inputs - clrRangeStartDate: { control: { type: 'date' } }, - clrRangeEndDate: { control: { type: 'date' } }, - max: { control: { type: 'date' } }, - min: { control: { type: 'date' } }, - disabled: { control: { type: 'boolean' } }, - // outputs - clrRangeStartDateChange: { control: { disable: true } }, - clrRangeEndDateChange: { control: { disable: true } }, - // methods - onValueChange: { control: { disable: true }, table: { disable: true } }, - setFocusStates: { control: { disable: true }, table: { disable: true } }, - triggerValidation: { control: { disable: true }, table: { disable: true } }, - getProviderFromContainer: { control: { disable: true }, table: { disable: true } }, - // story helpers - getDateObject: { control: { disable: true }, table: { disable: true } }, - getDateString: { control: { disable: true }, table: { disable: true } }, - }, - args: { - disabled: false, - placeholder: '', - id: '', - // outputs - clrRangeStartDateChange: action('clrRangeStartDateChange'), - clrRangeEndDateChange: action('clrRangeEndDateChange'), - // story helpers - getDateObject: date => { - try { - return date && new Date(date).toISOString(); - } catch { - return undefined; - } - }, - getDateString: date => date && new Date(date).toISOString().split('T')[0], - }, -}; - -const DateRangePickerTemplate: StoryFn = args => ({ - template: ` - - - - - - `, - props: { ...args }, -}); - -export const DateRangePicker: StoryObj = { - render: DateRangePickerTemplate, -}; - -export const DefaultDate: StoryObj = { - render: DateRangePickerTemplate, - args: { - clrRangeStartDate: '2024-06-22 00:00:00.000', - clrRangeEndDate: '2024-08-21 00:00:00.000', - }, -}; - -export const Disabled: StoryObj = { - render: DateRangePickerTemplate, - args: { - disabled: true, - }, -}; - -export const MinDate: StoryObj = { - render: DateRangePickerTemplate, - args: { - min: Date.now() - 2592000000, - }, -}; - -export const MaxDate: StoryObj = { - render: DateRangePickerTemplate, - args: { - max: Date.now() + 2592000000, - }, -}; diff --git a/projects/angular/clarity.api.md b/projects/angular/clarity.api.md index 8b2112e60d..0077c45e41 100644 --- a/projects/angular/clarity.api.md +++ b/projects/angular/clarity.api.md @@ -98,8 +98,8 @@ export class ClarityModule { // Warning: (ae-forgotten-export) The symbol "i7_6" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i8_6" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i9_2" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "i10_5" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "i11_5" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "i10_4" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "i11_4" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i12_3" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i13_3" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i14_2" needs to be exported by the entry point index.d.ts @@ -109,7 +109,7 @@ export class ClarityModule { // Warning: (ae-forgotten-export) The symbol "i18_2" needs to be exported by the entry point index.d.ts // // (undocumented) - static ɵmod: i0.ɵɵNgModuleDeclaration; + static ɵmod: i0.ɵɵNgModuleDeclaration; } // @public (undocumented) @@ -186,8 +186,6 @@ export abstract class ClrAbstractContainer implements DynamicWrapper, OnDestroy, // (undocumented) addGrid(): boolean; // (undocumented) - additionalControls: NgControl[]; - // (undocumented) control: NgControl; // (undocumented) controlClass(): string; @@ -680,8 +678,6 @@ export class ClrCalendar implements OnDestroy { // (undocumented) get selectedDay(): DayModel; // (undocumented) - get selectedEndDay(): DayModel; - // (undocumented) get today(): DayModel; // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; @@ -1990,16 +1986,12 @@ export class ClrDateContainer extends ClrAbstractContainer implements AfterViewI // Warning: (ae-forgotten-export) The symbol "DatepickerEnabledService" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "DateFormControlService" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ViewManagerService" needs to be exported by the entry point index.d.ts - constructor(renderer: Renderer2, elem: ElementRef, toggleService: ClrPopoverToggleService, dateNavigationService: DateNavigationService, datepickerEnabledService: DatepickerEnabledService, dateFormControlService: DateFormControlService, dateIOService: DateIOService, commonStrings: ClrCommonStringsService, focusService: FocusService_2, viewManagerService: ViewManagerService, controlClassService: ControlClassService, layoutService: LayoutService, ngControlService: NgControlService, ifControlStateService: IfControlStateService); + constructor(renderer: Renderer2, toggleService: ClrPopoverToggleService, dateNavigationService: DateNavigationService, datepickerEnabledService: DatepickerEnabledService, dateFormControlService: DateFormControlService, dateIOService: DateIOService, commonStrings: ClrCommonStringsService, focusService: FocusService_2, viewManagerService: ViewManagerService, controlClassService: ControlClassService, layoutService: LayoutService, ngControlService: NgControlService, ifControlStateService: IfControlStateService); // (undocumented) set actionButton(button: ElementRef); // (undocumented) set clrPosition(position: string); // (undocumented) - clrRangeEndEl: ClrDateRangeEndInput; - // (undocumented) - clrRangeStartEl: ClrDateRangeStartInput; - // (undocumented) commonStrings: ClrCommonStringsService; // (undocumented) protected controlClassService: ControlClassService; @@ -2012,10 +2004,6 @@ export class ClrDateContainer extends ClrAbstractContainer implements AfterViewI // (undocumented) protected layoutService: LayoutService; // (undocumented) - set max(dateString: string); - // (undocumented) - set min(dateString: string); - // (undocumented) ngAfterViewInit(): void; // (undocumented) protected ngControlService: NgControlService; @@ -2024,58 +2012,28 @@ export class ClrDateContainer extends ClrAbstractContainer implements AfterViewI // (undocumented) get popoverPosition(): ClrPopoverPosition; // (undocumented) - set rangeOptions(rangeOptions: any); - // (undocumented) protected renderer: Renderer2; // (undocumented) - static ɵcmp: i0.ɵɵComponentDeclaration; - // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; -} - -// @public (undocumented) -export class ClrDateInput extends ClrDateInputBase implements AfterViewInit { - // (undocumented) - set date(date: Date | string); - // (undocumented) - dateChange: EventEmitter; - // (undocumented) - ngAfterViewInit(): void; - // (undocumented) - ngOnInit(): void; - // (undocumented) - onValueChange(target: HTMLInputElement): void; - // (undocumented) - protected updateDate(value: Date, setByUserInteraction?: boolean, fieldName?: string): void; + static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵdir: i0.ɵɵDirectiveDeclaration; - // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public (undocumented) -export class ClrDateInputBase extends WrappedFormControl implements OnInit, AfterViewInit, OnDestroy { - constructor(viewContainerRef: ViewContainerRef, injector: Injector, el: ElementRef, renderer: Renderer2, document: any, control: NgControl, container: ClrDateContainer, dateIOService: DateIOService, dateNavigationService: DateNavigationService, datepickerEnabledService: DatepickerEnabledService, dateFormControlService: DateFormControlService, platformId: any, focusService: FocusService_2, datepickerFocusService: DatepickerFocusService); +export class ClrDateInput extends WrappedFormControl implements OnInit, AfterViewInit, OnDestroy { + constructor(viewContainerRef: ViewContainerRef, injector: Injector, el: ElementRef, renderer: Renderer2, control: NgControl, container: ClrDateContainer, dateIOService: DateIOService, dateNavigationService: DateNavigationService, datepickerEnabledService: DatepickerEnabledService, dateFormControlService: DateFormControlService, platformId: any, focusService: FocusService_2, datepickerFocusService: DatepickerFocusService); // (undocumented) protected control: NgControl; // (undocumented) - protected dateIOService: DateIOService; - // (undocumented) - protected dateNavigationService: DateNavigationService; - // (undocumented) - protected datepickerFocusService: DatepickerFocusService; + set date(date: Date | string); // (undocumented) - protected datepickerHasFormControl(): boolean; + dateChange: EventEmitter; // (undocumented) get disabled(): boolean | string; set disabled(value: boolean | string); // (undocumented) - protected document: any; - // (undocumented) protected el: ElementRef; // (undocumented) - protected getValidDateValueFromDate(date: Date): Date; - // (undocumented) protected index: number; // (undocumented) get inputType(): string; @@ -2090,6 +2048,8 @@ export class ClrDateInputBase extends WrappedFormControl imple // (undocumented) ngOnInit(): void; // (undocumented) + onValueChange(target: HTMLInputElement): void; + // (undocumented) placeholder: string; // (undocumented) get placeholderText(): string; @@ -2100,16 +2060,9 @@ export class ClrDateInputBase extends WrappedFormControl imple // (undocumented) triggerValidation(): void; // (undocumented) - protected updateInput(date: Date): void; - // (undocumented) - protected usingClarityDatepicker(): boolean; - // (undocumented) - protected usingNativeDatepicker(): boolean; - protected validateDateRange(): void; + static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) - static ɵdir: i0.ɵɵDirectiveDeclaration; - // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public (undocumented) @@ -2118,7 +2071,7 @@ export class ClrDateInputValidator implements Validator { // (undocumented) validate(control: AbstractControl): ValidationErrors; // (undocumented) - static ɵdir: i0.ɵɵDirectiveDeclaration; + static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) static ɵfac: i0.ɵɵFactoryDeclaration; } @@ -2139,122 +2092,33 @@ export class ClrDatepickerModule { // Warning: (ae-forgotten-export) The symbol "i7_4" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i8_4" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i9_4" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "i10_3" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "i11_2" needs to be exported by the entry point index.d.ts // // (undocumented) - static ɵmod: i0.ɵɵNgModuleDeclaration; + static ɵmod: i0.ɵɵNgModuleDeclaration; } // @public (undocumented) export class ClrDatepickerViewManager { - // Warning: (ae-forgotten-export) The symbol "DatePickerHelperService" needs to be exported by the entry point index.d.ts - constructor(commonStrings: ClrCommonStringsService, viewManagerService: ViewManagerService, dateIOService: DateIOService, datePickerHelperService: DatePickerHelperService, dateNavigationService: DateNavigationService); + constructor(commonStrings: ClrCommonStringsService, viewManagerService: ViewManagerService); // (undocumented) commonStrings: ClrCommonStringsService; - // (undocumented) - dateRangeOptions: any; - // (undocumented) - get hasRangeOptions(): any; get isDayView(): boolean; get isMonthView(): boolean; get isYearView(): boolean; // (undocumented) - onRangeOptionSelect(selectedRange: any): void; - // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; -} - -// @public (undocumented) -export class ClrDateRangeEndInput extends ClrDateInputBase implements AfterViewInit { - // (undocumented) - set date(date: Date | string); - // (undocumented) - dateChange: EventEmitter; - // (undocumented) - get inputSize(): number; - // (undocumented) - inputWidth: number; - // (undocumented) - ngAfterViewInit(): void; - // (undocumented) - ngOnInit(): void; - // (undocumented) - onValueChange(target: HTMLInputElement): void; - // (undocumented) - triggerControlInputValidation(): void; - // (undocumented) - protected updateDate(value: Date, setByUserInteraction?: boolean): void; - // (undocumented) - static ɵdir: i0.ɵɵDirectiveDeclaration; - // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; -} - -// @public (undocumented) -export class ClrDateRangeEndInputValidator implements Validator { - constructor(dateIOService: DateIOService, dateNavigationService: DateNavigationService); - // (undocumented) - validate(control: AbstractControl): ValidationErrors; - // (undocumented) - static ɵdir: i0.ɵɵDirectiveDeclaration; - // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; -} - -// @public (undocumented) -export class ClrDateRangeStartInput extends ClrDateInputBase implements AfterViewInit { - // (undocumented) - set date(date: Date | string); - // (undocumented) - dateChange: EventEmitter; - // (undocumented) - get inputSize(): number; - // (undocumented) - inputWidth: number; - // (undocumented) - ngAfterViewInit(): void; - // (undocumented) - ngOnInit(): void; - // (undocumented) - onValueChange(target: HTMLInputElement): void; - // (undocumented) - triggerControlInputValidation(): void; - // (undocumented) - protected updateDate(value: Date, setByUserInteraction?: boolean): void; - // (undocumented) - static ɵdir: i0.ɵɵDirectiveDeclaration; - // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; -} - -// @public (undocumented) -export class ClrDateRangeStartInputValidator implements Validator { - constructor(dateIOService: DateIOService, dateNavigationService: DateNavigationService); - // (undocumented) - validate(control: AbstractControl): ValidationErrors; - // (undocumented) - static ɵdir: i0.ɵɵDirectiveDeclaration; - // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public (undocumented) export class ClrDay { - constructor(_dateNavigationService: DateNavigationService, _datePickerHelperService: DatePickerHelperService, commonStrings: ClrCommonStringsService); + constructor(_dateNavigationService: DateNavigationService, _toggleService: ClrPopoverToggleService, dateFormControlService: DateFormControlService, commonStrings: ClrCommonStringsService); // (undocumented) get dayString(): string; // Warning: (ae-forgotten-export) The symbol "DayViewModel" needs to be exported by the entry point index.d.ts get dayView(): DayViewModel; set dayView(day: DayViewModel); - hoverListener(): void; - isInRange(): boolean; - // (undocumented) - get isRangeEndDay(): boolean; - // (undocumented) - get isRangeStartDay(): boolean; onDayViewFocus(): void; selectDay(): void; // (undocumented) @@ -2580,13 +2444,13 @@ export class ClrFormsModule { // Warning: (ae-forgotten-export) The symbol "i6_7" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i8_5" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i9_5" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "i10_4" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "i11_3" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "i10_3" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "i11_2" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i12_2" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i13_2" needs to be exported by the entry point index.d.ts // // (undocumented) - static ɵmod: i0.ɵɵNgModuleDeclaration; + static ɵmod: i0.ɵɵNgModuleDeclaration; } // @public (undocumented) @@ -3021,8 +2885,7 @@ export class ClrModalModule { // @public (undocumented) export class ClrMonthpicker implements AfterViewInit { - constructor(_localeHelperService: LocaleHelperService, _dateNavigationService: DateNavigationService, _datepickerFocusService: DatepickerFocusService, _elRef: ElementRef, _viewManagerService: ViewManagerService, commonStrings: ClrCommonStringsService); - get calendarEndMonthIndex(): number; + constructor(_viewManagerService: ViewManagerService, _localeHelperService: LocaleHelperService, _dateNavigationService: DateNavigationService, _datepickerFocusService: DatepickerFocusService, _elRef: ElementRef, commonStrings: ClrCommonStringsService); get calendarMonthIndex(): number; get calendarYear(): number; changeMonth(monthIndex: number): void; @@ -3034,18 +2897,12 @@ export class ClrMonthpicker implements AfterViewInit { // (undocumented) get currentCalendarYear(): number; currentYear(): void; - // (undocumented) - getIsRangeEndMonth(monthIndex: number): boolean; - // (undocumented) - getIsRangeStartMonth(monthIndex: number): boolean; getTabIndex(monthIndex: number): number; - isInRange(monthIndex: number): boolean; // (undocumented) isSelected(monthIndex: number): boolean; get monthNames(): ReadonlyArray; nextYear(): void; ngAfterViewInit(): void; - onHover(monthIndex: number): void; onKeyDown(event: KeyboardEvent): void; previousYear(): void; // (undocumented) @@ -4248,10 +4105,10 @@ export class ClrTabsModule { // Warning: (ae-forgotten-export) The symbol "i5_11" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i6_8" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i7_7" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "i11_4" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "i11_3" needs to be exported by the entry point index.d.ts // // (undocumented) - static ɵmod: i0.ɵɵNgModuleDeclaration; + static ɵmod: i0.ɵɵNgModuleDeclaration; } // @public (undocumented) @@ -4842,11 +4699,11 @@ export class ClrWizardModule { // Warning: (ae-forgotten-export) The symbol "i7_8" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i8_7" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "i9_6" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "i10_6" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "i11_6" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "i10_5" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "i11_5" needs to be exported by the entry point index.d.ts // // (undocumented) - static ɵmod: i0.ɵɵNgModuleDeclaration; + static ɵmod: i0.ɵɵNgModuleDeclaration; } // @public @@ -5012,7 +4869,6 @@ export class ClrWizardTitle { // @public (undocumented) export class ClrYearpicker implements AfterViewInit { constructor(_dateNavigationService: DateNavigationService, _viewManagerService: ViewManagerService, _datepickerFocusService: DatepickerFocusService, _elRef: ElementRef, commonStrings: ClrCommonStringsService); - get calendarEndYear(): number; get calendarYear(): number; changeYear(year: number): void; // (undocumented) @@ -5020,15 +4876,9 @@ export class ClrYearpicker implements AfterViewInit { // (undocumented) get currentCalendarYear(): number; currentDecade(): void; - // (undocumented) - getIsRangeEndYear(year: number): boolean; - // (undocumented) - getIsRangeStartYear(year: number): boolean; getTabIndex(year: number): number; - isInRange(year: number): boolean; nextDecade(): void; ngAfterViewInit(): void; - onHover(year: number): void; onKeyDown(event: KeyboardEvent): void; previousDecade(): void; // Warning: (ae-forgotten-export) The symbol "YearRangeModel" needs to be exported by the entry point index.d.ts @@ -5228,7 +5078,7 @@ export function ToggleServiceFactory(): BehaviorSubject; // @public (undocumented) export class WrappedFormControl implements OnInit, DoCheck, OnDestroy { - constructor(vcr: ViewContainerRef, wrapperType: Type, injector: Injector, _ngControl: NgControl | null, renderer: Renderer2, el: ElementRef); + constructor(vcr: ViewContainerRef, wrapperType: Type, injector: Injector, ngControl: NgControl | null, renderer: Renderer2, el: ElementRef); // (undocumented) protected controlIdService: ControlIdService; // (undocumented) diff --git a/projects/angular/src/forms/common/abstract-container.ts b/projects/angular/src/forms/common/abstract-container.ts index 06396deab6..162e4268b2 100644 --- a/projects/angular/src/forms/common/abstract-container.ts +++ b/projects/angular/src/forms/common/abstract-container.ts @@ -27,7 +27,6 @@ export abstract class ClrAbstractContainer implements DynamicWrapper, OnDestroy, @ContentChild(ClrControlHelper) controlHelperComponent: ClrControlHelper; control: NgControl; - additionalControls: NgControl[]; _dynamic = false; protected subscriptions: Subscription[] = []; @@ -53,9 +52,6 @@ export abstract class ClrAbstractContainer implements DynamicWrapper, OnDestroy, this.subscriptions.push( this.ngControlService.controlChanges.subscribe(control => { this.control = control; - }), - this.ngControlService.additionalControlChanges.subscribe(controls => { - this.additionalControls = controls; }) ); } @@ -94,7 +90,7 @@ export abstract class ClrAbstractContainer implements DynamicWrapper, OnDestroy, } private get touched() { - return !!(this.control?.touched || this.additionalControls?.some(control => control.touched)); + return this.control?.touched; } ngAfterContentInit() { diff --git a/projects/angular/src/forms/common/if-control-state/abstract-if-state.ts b/projects/angular/src/forms/common/if-control-state/abstract-if-state.ts index 7880666898..8f4026be58 100644 --- a/projects/angular/src/forms/common/if-control-state/abstract-if-state.ts +++ b/projects/angular/src/forms/common/if-control-state/abstract-if-state.ts @@ -17,7 +17,6 @@ export abstract class AbstractIfState { protected subscriptions: Subscription[] = []; protected displayedContent = false; protected control: NgControl; - protected additionalControls: NgControl[]; constructor( @Optional() protected ifControlStateService: IfControlStateService, @@ -27,9 +26,6 @@ export abstract class AbstractIfState { this.subscriptions.push( this.ngControlService.controlChanges.subscribe(control => { this.control = control; - }), - this.ngControlService.additionalControlChanges.subscribe(controls => { - this.additionalControls = controls; }) ); } diff --git a/projects/angular/src/forms/common/if-control-state/if-control-state.service.ts b/projects/angular/src/forms/common/if-control-state/if-control-state.service.ts index 6b223a4c62..164aff5960 100644 --- a/projects/angular/src/forms/common/if-control-state/if-control-state.service.ts +++ b/projects/angular/src/forms/common/if-control-state/if-control-state.service.ts @@ -7,7 +7,7 @@ import { Injectable, OnDestroy } from '@angular/core'; import { NgControl } from '@angular/forms'; -import { BehaviorSubject, Observable, Subject, Subscription, takeUntil } from 'rxjs'; +import { BehaviorSubject, Observable, Subscription } from 'rxjs'; import { NgControlService } from '../providers/ng-control.service'; @@ -21,8 +21,6 @@ export enum CONTROL_STATE { export class IfControlStateService implements OnDestroy { private subscriptions: Subscription[] = []; private control: NgControl; - private additionalControls: NgControl[]; - private unSubscribeAdditionalControls: Subject = new Subject(); // Implement our own status changes observable, since Angular controls don't private _statusChanges = new BehaviorSubject(CONTROL_STATE.NONE); @@ -36,25 +34,11 @@ export class IfControlStateService implements OnDestroy { // Subscribe to the status change events, only after touched // and emit the control this.subscriptions.push( - this.control.statusChanges?.subscribe(() => { + this.control.statusChanges.subscribe(() => { this.triggerStatusChange(); }) ); } - }), - - this.ngControlService.additionalControlChanges.subscribe((controls: NgControl[]) => { - if (controls) { - this.additionalControls = controls; - this.unSubscribeAdditionalControls.next(true); - // Subscribe to the status change events, only after touched - // and emit the control - this.additionalControls?.forEach((control: NgControl) => { - control?.statusChanges?.pipe(takeUntil(this.unSubscribeAdditionalControls)).subscribe(() => { - this.triggerStatusChange(); - }); - }); - } }) ); } @@ -65,7 +49,6 @@ export class IfControlStateService implements OnDestroy { ngOnDestroy() { this.subscriptions.forEach(subscription => subscription.unsubscribe()); - this.unSubscribeAdditionalControls.next(true); } triggerStatusChange() { @@ -73,15 +56,8 @@ export class IfControlStateService implements OnDestroy { if (this.control) { // These status values are mutually exclusive, so a control // cannot be both valid AND invalid or invalid AND disabled. - let finalStatus = CONTROL_STATE.NONE; - const additionalControlsStatus = this.additionalControls?.map(control => control.status) || []; - const combinedStatus = [this.control.status, ...additionalControlsStatus]; - if (combinedStatus.includes(CONTROL_STATE.INVALID)) { - finalStatus = CONTROL_STATE.INVALID; - } else if (combinedStatus.includes(CONTROL_STATE.VALID)) { - finalStatus = CONTROL_STATE.VALID; - } - this._statusChanges.next(finalStatus); + const status = CONTROL_STATE[this.control.status]; + this._statusChanges.next(['VALID', 'INVALID'].includes(status) ? status : CONTROL_STATE.NONE); } } } diff --git a/projects/angular/src/forms/common/if-control-state/if-error.ts b/projects/angular/src/forms/common/if-control-state/if-error.ts index ec79f3fcd0..1581383416 100644 --- a/projects/angular/src/forms/common/if-control-state/if-error.ts +++ b/projects/angular/src/forms/common/if-control-state/if-error.ts @@ -35,17 +35,14 @@ export class ClrIfError extends AbstractIfState { * @param state CONTROL_STATE */ protected override handleState(state: CONTROL_STATE) { - if (this.error && this.control && !!this.control.invalid) { + if (this.error && this.control) { this.displayError(this.control.hasError(this.error)); - } else if (this.error && !!this.additionalControls?.length) { - const invalidControl = this.additionalControls?.filter(control => control.hasError(this.error))[0]; - this.displayError(!!invalidControl, invalidControl); } else { this.displayError(CONTROL_STATE.INVALID === state); } } - private displayError(invalid: boolean, control = this.control) { + private displayError(invalid: boolean) { /* if no container do nothing */ if (!this.container) { return; @@ -53,12 +50,12 @@ export class ClrIfError extends AbstractIfState { if (invalid) { if (this.displayedContent === false) { this.embeddedViewRef = this.container.createEmbeddedView(this.template, { - error: control.getError(this.error), + error: this.control.getError(this.error), }); this.displayedContent = true; } else if (this.embeddedViewRef && this.embeddedViewRef.context) { // if view is already rendered, update the error object to keep it in sync - this.embeddedViewRef.context.error = control.getError(this.error); + this.embeddedViewRef.context.error = this.control.getError(this.error); } } else { this.container.clear(); diff --git a/projects/angular/src/forms/common/providers/ng-control.service.ts b/projects/angular/src/forms/common/providers/ng-control.service.ts index 892ae12572..c901213f31 100644 --- a/projects/angular/src/forms/common/providers/ng-control.service.ts +++ b/projects/angular/src/forms/common/providers/ng-control.service.ts @@ -19,10 +19,7 @@ export interface Helpers { @Injectable() export class NgControlService { // Observable to subscribe to the control, since its not available immediately for projected content - private _control: NgControl; private _controlChanges = new Subject(); - private _additionalControls: NgControl[] = []; - private _additionalControlChanges = new Subject(); private _helpers = new Subject(); @@ -34,33 +31,11 @@ export class NgControlService { return this._helpers.asObservable(); } - get additionalControlChanges(): Observable { - return this._additionalControlChanges.asObservable(); - } - - get hasAdditionalControls() { - return !!this._additionalControls?.length; - } - setControl(control: NgControl) { - this._control = control; this._controlChanges.next(control); } setHelpers(state: Helpers) { this._helpers.next(state); } - - addAdditionalControl(control: NgControl) { - this._additionalControls.push(control); - this._additionalControlChanges.next(this._additionalControls); - } - - getControl() { - return this._control; - } - - getAdditionalControls() { - return this._additionalControls; - } } diff --git a/projects/angular/src/forms/common/wrapped-control.ts b/projects/angular/src/forms/common/wrapped-control.ts index d83260dfde..23fe0426d5 100644 --- a/projects/angular/src/forms/common/wrapped-control.ts +++ b/projects/angular/src/forms/common/wrapped-control.ts @@ -58,8 +58,6 @@ export class WrappedFormControl implements OnInit, DoC private _containerInjector: Injector; private differs: KeyValueDiffers; private differ: KeyValueDiffer; - private additionalDiffer = new Map>(); - private ngControl: NgControl | null; // I lost way too much time trying to make this work without injecting the ViewContainerRef and the Injector, // I'm giving up. So we have to inject these two manually for now. @@ -67,7 +65,7 @@ export class WrappedFormControl implements OnInit, DoC protected vcr: ViewContainerRef, protected wrapperType: Type, injector: Injector, - private _ngControl: NgControl | null, + private ngControl: NgControl | null, renderer: Renderer2, el: ElementRef ) { @@ -100,6 +98,10 @@ export class WrappedFormControl implements OnInit, DoC }) ); } + + if (ngControl) { + this.differ = this.differs.find(ngControl).create(); + } } @Input() @@ -114,10 +116,6 @@ export class WrappedFormControl implements OnInit, DoC } } - private get hasAdditionalControls() { - return this.additionalDiffer.size > 0; - } - ngOnInit() { this._containerInjector = new HostWrapper(this.wrapperType, this.vcr, this.index); this.controlIdService = this._containerInjector.get(ControlIdService); @@ -133,24 +131,23 @@ export class WrappedFormControl implements OnInit, DoC this._id = this.controlIdService.id; } - if (this.ngControlService && this._ngControl) { - if (!this.ngControlService.getControl()) { - this.ngControl = this._ngControl; - this.ngControlService.setControl(this.ngControl); - this.differ = this.differs.find(this._ngControl).create(); - } else { - this.ngControl = this.ngControlService.getControl(); - this.ngControlService.addAdditionalControl(this._ngControl); - this.additionalDiffer.set(this._ngControl, this.differs.find(this._ngControl).create()); - } + if (this.ngControlService && this.ngControl) { + this.ngControlService.setControl(this.ngControl); } } ngDoCheck() { - this.triggerDoCheck(this.differ, this.ngControl); - if (this.hasAdditionalControls) { - for (const [ngControl, differ] of this.additionalDiffer) { - this.triggerDoCheck(differ, ngControl); + if (this.differ) { + const changes = this.differ.diff(this.ngControl); + if (changes) { + changes.forEachChangedItem(change => { + if ( + (change.key === CHANGE_KEYS.FORM || change.key === CHANGE_KEYS.MODEL) && + change.currentValue !== change.previousValue + ) { + this.triggerValidation(); + } + }); } } } @@ -178,33 +175,11 @@ export class WrappedFormControl implements OnInit, DoC } } - private triggerDoCheck(differ, ngControl) { - if (differ) { - const changes = differ.diff(ngControl); - if (changes) { - changes.forEachChangedItem(change => { - if ( - (change.key === CHANGE_KEYS.FORM || change.key === CHANGE_KEYS.MODEL) && - change.currentValue !== change.previousValue - ) { - this.triggerValidation(); - } - }); - } - } - } - private markAsTouched(): void { if (this.ngControl) { this.ngControl.control.markAsTouched(); this.ngControl.control.updateValueAndValidity(); } - if (this.ngControlService && this.ngControlService.hasAdditionalControls) { - this.ngControlService.getAdditionalControls()?.forEach((ngControl: NgControl) => { - ngControl.control.markAsTouched(); - ngControl.control.updateValueAndValidity(); - }); - } } private setAriaDescribedBy(helpers: Helpers) { diff --git a/projects/angular/src/forms/datepicker/_datepicker.clarity.scss b/projects/angular/src/forms/datepicker/_datepicker.clarity.scss index eb7d4bed35..75edbc22a1 100644 --- a/projects/angular/src/forms/datepicker/_datepicker.clarity.scss +++ b/projects/angular/src/forms/datepicker/_datepicker.clarity.scss @@ -34,15 +34,8 @@ &:hover { background: datepicker-variables.$clr-calendar-btn-hover-color; } - &.in-range { - &:not(.is-today) { - border-radius: 0; - } - background: datepicker-variables.$clr-calendar-in-range-cell-border-color; - } &:focus { outline: tokens.$cds-alias-object-interaction-outline; - outline-color: -webkit-focus-ring-color; outline-offset: calc(-1 * tokens.$cds-global-space-2); } &:active { @@ -59,24 +52,13 @@ } @mixin generate-selected-date-style() { - &.is-selected, - &.is-start-range, - &.is-end-range { + &.is-selected { background: datepicker-variables.$clr-calendar-active-cell-background-color; color: datepicker-variables.$clr-calendar-active-cell-color; border: none; - } - &.is-start-range { - border-top-right-radius: 0; - border-bottom-right-radius: 0; - } - &.is-end-range { - border-top-left-radius: 0; - border-bottom-left-radius: 0; - } - - &.is-selected:focus { - background: datepicker-variables.$clr-calendar-active-focus-cell-background-color; + &:focus { + background: datepicker-variables.$clr-calendar-active-focus-cell-background-color; + } } } @@ -93,48 +75,21 @@ @include mixins.exports('datepicker.clarity') { .datepicker { display: flex; - flex-direction: row; - margin-top: tokens.$cds-global-space-4; + flex-direction: column; + + //Dimensions + margin-top: datepicker-variables.$clr-calendar-margin-top; + padding: datepicker-variables.$clr-calendar-padding; width: datepicker-variables.$clr-calendar-width; height: datepicker-variables.$clr-calendar-height; + + //Other Props background: datepicker-variables.$clr-calendar-background-color; border: tokens.$cds-alias-object-border-width-100 solid datepicker-variables.$clr-calendar-border-color; border-radius: tokens.$cds-alias-object-border-radius-100; box-shadow: tokens.$cds-alias-object-shadow-100; + overflow: hidden; z-index: map.get(variables.$clr-layers, dropdown-menu); - .datepicker-view-manager { - padding: tokens.$cds-global-space-7; - } - &.has-range-option { - width: calc(datepicker-variables.$clr-calendar-width + datepicker-variables.$clr-calendar-options-width); - } - } - .options-wrapper { - width: datepicker-variables.$clr-calendar-options-width; - padding: tokens.$cds-global-space-3 0; - flex-shrink: 0; - border-top-left-radius: tokens.$cds-alias-object-border-radius-100; - border-bottom-left-radius: tokens.$cds-alias-object-border-radius-100; - .range-option { - padding: tokens.$cds-global-space-5; - padding-left: tokens.$cds-global-space-7; - color: datepicker-variables.$clr-calendar-option-text-color; - cursor: pointer; - &.active { - border-left: mixins.baselinePx(3) solid datepicker-variables.$clr-calendar-active-option-border-color; - color: datepicker-variables.$clr-calendar-options-active-text-color; - background-color: datepicker-variables.$clr-calendar-options-active-background-color; - } - + .range-option { - margin: tokens.$cds-global-space-5 0; - } - &:hover, - &:focus { - background-color: datepicker-variables.$clr-calendar-option-hover-background-color; - outline: none; - } - } - background-color: datepicker-variables.$clr-calendar-options-background-color; } .calendar-header { @@ -296,12 +251,6 @@ .months { flex-wrap: wrap; flex-direction: row; - - &.enlarged { - .month { - height: datepicker-variables.$clr-calendar-month-enlarged-cell-height; - } - } } .month, diff --git a/projects/angular/src/forms/datepicker/_properties.datepicker.scss b/projects/angular/src/forms/datepicker/_properties.datepicker.scss index bc156368a0..a801089326 100644 --- a/projects/angular/src/forms/datepicker/_properties.datepicker.scss +++ b/projects/angular/src/forms/datepicker/_properties.datepicker.scss @@ -13,9 +13,6 @@ --clr-calendar-background-color: #{tokens.$cds-alias-object-container-background}; --clr-calendar-border-color: #{tokens.$cds-alias-object-border-color-shade}; - --clr-calendar-option-text-color: #{tokens.$cds-alias-object-interaction-color}; - --clr-calendar-active-option-border-color: #{tokens.$cds-alias-object-interaction-background-highlight}; - --clr-calendar-btn-color: #{tokens.$cds-alias-object-interaction-color}; --clr-calendar-today-date-cell-color: #{tokens.$cds-alias-typography-color-400}; diff --git a/projects/angular/src/forms/datepicker/_variables.datepicker.scss b/projects/angular/src/forms/datepicker/_variables.datepicker.scss index a189c79cdc..4df2a58228 100644 --- a/projects/angular/src/forms/datepicker/_variables.datepicker.scss +++ b/projects/angular/src/forms/datepicker/_variables.datepicker.scss @@ -6,7 +6,6 @@ */ @use '@cds/core/tokens/tokens.scss'; -@use '../../utils/mixins'; $clr-calendar-click-target: #{tokens.$cds-global-space-11}; $clr-calendar-background-color: var(--clr-calendar-background-color) !default; @@ -19,7 +18,6 @@ $clr-calendar-width: calc( calc(7 * #{tokens.$cds-global-space-11}) + calc(2 * #{tokens.$cds-global-space-7}) + calc(2 * #{tokens.$cds-alias-object-border-width-100}) ); -$clr-calendar-options-width: mixins.baselinePx(150); //(8 = 6 date rows + 1 row for day heading + 1 row for calendar switches and month/year pickers) + 2 * 16px padding + 2px for border $clr-calendar-height: calc( @@ -38,8 +36,8 @@ $clr-calendar-btn-padding: 0; $clr-calendar-year-cell-height: #{tokens.$cds-global-space-12}; $clr-calendar-month-cell-height: #{tokens.$cds-global-space-11}; -$clr-calendar-month-enlarged-cell-height: #{tokens.$cds-global-space-12}; $clr-calendar-month-cell-padding: #{tokens.$cds-global-space-6}; + $clr-calendar-picker-btn-font-size: var(--clr-calendar-picker-btn-font-size); $clr-calendar-picker-btn-font-weight: var(--clr-calendar-picker-btn-font-weight); @@ -60,12 +58,4 @@ $clr-month-year-btn-width: calc( 0.5 * #{$clr-calendar-width} - #{tokens.$cds-global-space-7} - #{tokens.$cds-alias-object-border-width-100} ); -$clr-calendar-option-text-color: var(--clr-calendar-option-text-color) !default; -$clr-calendar-option-hover-background-color: var(--clr-calendar-btn-hover-color); -$clr-calendar-options-background-color: var(--clr-vertical-nav-bg-color); -$clr-calendar-active-option-border-color: var(--clr-calendar-active-option-border-color); -$clr-calendar-in-range-cell-border-color: var(--clr-calendar-btn-hover-color); $clr-calendar-today-date-cell-border-color: var(--clr-calendar-today-date-cell-border-color); - -$clr-calendar-options-active-text-color: var(--clr-vertical-nav-item-active-color); -$clr-calendar-options-active-background-color: var(--clr-vertical-nav-selected-bg-color); diff --git a/projects/angular/src/forms/datepicker/all.spec.ts b/projects/angular/src/forms/datepicker/all.spec.ts index 74195135f0..4b7b44b050 100644 --- a/projects/angular/src/forms/datepicker/all.spec.ts +++ b/projects/angular/src/forms/datepicker/all.spec.ts @@ -8,7 +8,7 @@ import { addHelpers } from '../../data/datagrid/helpers.spec'; import CalendarSpecs from './calendar.spec'; import DateContainerSpecs from './date-container.spec'; -import DateInputSpecs from './date-input-base.spec'; +import DateInputSpecs from './date-input.spec'; import DateInputValidatorSpecs from './date-input.validator.spec'; import DatepickerViewManagerSpecs from './datepicker-view-manager.spec'; import DayComponentSpecs from './day.spec'; diff --git a/projects/angular/src/forms/datepicker/calendar.spec.ts b/projects/angular/src/forms/datepicker/calendar.spec.ts index 6d2aee30f4..7b8123262b 100644 --- a/projects/angular/src/forms/datepicker/calendar.spec.ts +++ b/projects/angular/src/forms/datepicker/calendar.spec.ts @@ -16,7 +16,6 @@ import { DateFormControlService } from './providers/date-form-control.service'; import { DateIOService } from './providers/date-io.service'; import { DateNavigationService } from './providers/date-navigation.service'; import { DatepickerFocusService } from './providers/datepicker-focus.service'; -import { DatePickerHelperService } from './providers/datepicker-helper.service'; import { LocaleHelperService } from './providers/locale-helper.service'; import { ViewManagerService } from './providers/view-manager.service'; @@ -39,7 +38,6 @@ export default function () { LocaleHelperService, DatepickerFocusService, DateFormControlService, - DatePickerHelperService, ]); }); diff --git a/projects/angular/src/forms/datepicker/calendar.ts b/projects/angular/src/forms/datepicker/calendar.ts index 6fdac98fd5..2902b2262f 100644 --- a/projects/angular/src/forms/datepicker/calendar.ts +++ b/projects/angular/src/forms/datepicker/calendar.ts @@ -58,10 +58,6 @@ export class ClrCalendar implements OnDestroy { return this._dateNavigationService.selectedDay; } - get selectedEndDay(): DayModel { - return this._dateNavigationService.selectedEndDay; - } - get focusedDay(): DayModel { return this._dateNavigationService.focusedDay; } @@ -132,18 +128,6 @@ export class ClrCalendar implements OnDestroy { }) ); - this._subs.push( - this._dateNavigationService.selectedDayChange.subscribe((selectedDay: DayModel) => { - this.calendarViewModel.updateSelectedDay(selectedDay); - }) - ); - - this._subs.push( - this._dateNavigationService.selectedEndDayChange.subscribe((selectedDay: DayModel) => { - this.calendarViewModel.updateSelectedEndDay(selectedDay); - }) - ); - this._subs.push( this._dateNavigationService.focusOnCalendarChange.subscribe(() => { this._datepickerFocusService.focusCell(this._elRef); @@ -158,7 +142,6 @@ export class ClrCalendar implements OnDestroy { this.calendarViewModel = new CalendarViewModel( this.calendar, this.selectedDay, - this.selectedEndDay, this.focusedDay, this.today, this._localeHelperService.firstDayOfWeek, diff --git a/projects/angular/src/forms/datepicker/date-container.spec.ts b/projects/angular/src/forms/datepicker/date-container.spec.ts index 8620ab2f95..f37a727989 100644 --- a/projects/angular/src/forms/datepicker/date-container.spec.ts +++ b/projects/angular/src/forms/datepicker/date-container.spec.ts @@ -29,7 +29,6 @@ import { DateIOService } from './providers/date-io.service'; import { DateNavigationService } from './providers/date-navigation.service'; import { DatepickerEnabledService } from './providers/datepicker-enabled.service'; import { MockDatepickerEnabledService } from './providers/datepicker-enabled.service.mock'; -import { DatePickerHelperService } from './providers/datepicker-helper.service'; import { LocaleHelperService } from './providers/locale-helper.service'; import { ViewManagerService } from './providers/view-manager.service'; @@ -45,7 +44,6 @@ const DATEPICKER_PROVIDERS: any[] = [ DateIOService, ControlIdService, DateFormControlService, - DatePickerHelperService, ]; export default function () { diff --git a/projects/angular/src/forms/datepicker/date-container.ts b/projects/angular/src/forms/datepicker/date-container.ts index 8cc25d6e06..9337e53c74 100644 --- a/projects/angular/src/forms/datepicker/date-container.ts +++ b/projects/angular/src/forms/datepicker/date-container.ts @@ -5,16 +5,7 @@ * The full license information can be found in LICENSE in the root directory of this project. */ -import { - AfterViewInit, - Component, - ContentChild, - ElementRef, - Input, - Optional, - Renderer2, - ViewChild, -} from '@angular/core'; +import { AfterViewInit, Component, ElementRef, Input, Optional, Renderer2, ViewChild } from '@angular/core'; import { startWith } from 'rxjs/operators'; import { ClrCommonStringsService } from '../../utils/i18n/common-strings.service'; @@ -29,19 +20,16 @@ import { ControlIdService } from '../common/providers/control-id.service'; import { FocusService } from '../common/providers/focus.service'; import { LayoutService } from '../common/providers/layout.service'; import { NgControlService } from '../common/providers/ng-control.service'; -import { ClrDateRangeEndInput } from './date-range-end-input'; -import { ClrDateRangeStartInput } from './date-range-start-input'; import { DayModel } from './model/day.model'; import { DateFormControlService } from './providers/date-form-control.service'; import { DateIOService } from './providers/date-io.service'; import { DateNavigationService } from './providers/date-navigation.service'; import { DatepickerEnabledService } from './providers/datepicker-enabled.service'; -import { DatePickerHelperService } from './providers/datepicker-helper.service'; import { LocaleHelperService } from './providers/locale-helper.service'; import { ViewManagerService } from './providers/view-manager.service'; @Component({ - selector: 'clr-date-container, clr-date-range-container', + selector: 'clr-date-container', template: ` @@ -49,8 +37,6 @@ import { ViewManagerService } from './providers/view-manager.service';
- - @@ -87,11 +83,11 @@ export class ClrMonthpicker implements AfterViewInit { private _focusedMonthIndex: number; constructor( + private _viewManagerService: ViewManagerService, private _localeHelperService: LocaleHelperService, private _dateNavigationService: DateNavigationService, private _datepickerFocusService: DatepickerFocusService, private _elRef: ElementRef, - private _viewManagerService: ViewManagerService, public commonStrings: ClrCommonStringsService ) { this._focusedMonthIndex = this.calendarMonthIndex; @@ -112,13 +108,6 @@ export class ClrMonthpicker implements AfterViewInit { return this._dateNavigationService.displayedCalendar.month; } - /** - * Gets the year which the user is currently on. - */ - get calendarEndMonthIndex(): number { - return this._dateNavigationService.selectedEndDay?.month; - } - get yearAttrString(): string { return this.commonStrings.parse(this.commonStrings.keys.datepickerSelectYearText, { CALENDAR_YEAR: this.calendarYear.toString(), @@ -140,22 +129,6 @@ export class ClrMonthpicker implements AfterViewInit { return new Date().getMonth(); } - getIsRangeStartMonth(monthIndex: number): boolean { - return ( - this._dateNavigationService.isRangePicker && - this.calendarYear === this._dateNavigationService.selectedDay?.year && - monthIndex === this._dateNavigationService.selectedDay?.month - ); - } - - getIsRangeEndMonth(monthIndex: number): boolean { - return ( - this._dateNavigationService.isRangePicker && - this.calendarYear === this._dateNavigationService.selectedEndDay?.year && - monthIndex === this._dateNavigationService.selectedEndDay?.month - ); - } - /** * Calls the ViewManagerService to change to the yearpicker view. */ @@ -164,7 +137,7 @@ export class ClrMonthpicker implements AfterViewInit { } /** - * Focuses on the current calendar month when the view is initialized. + * Focuses on the current calendar month when the View is initialized. */ ngAfterViewInit() { this._datepickerFocusService.focusCell(this._elRef); @@ -202,19 +175,11 @@ export class ClrMonthpicker implements AfterViewInit { isSelected(monthIndex: number): boolean { return ( - (this._dateNavigationService.selectedDay?.year === this.calendarYear && - monthIndex === this._dateNavigationService.selectedDay?.month) || - (this._dateNavigationService.selectedEndDay?.year === this.calendarYear && - monthIndex === this.calendarEndMonthIndex) + this._dateNavigationService.selectedDay?.year === this.calendarYear && + monthIndex === this._dateNavigationService.selectedDay?.month ); } - /** - * Calls the DateNavigationService to update the hovered month value of the calendar - */ - onHover(monthIndex: number): void { - this._dateNavigationService.hoveredMonth = monthIndex; - } /** * Calls the DateNavigationService to update the month value of the calendar. * Also changes the view to the daypicker. @@ -251,40 +216,4 @@ export class ClrMonthpicker implements AfterViewInit { currentYear(): void { this._dateNavigationService.moveToCurrentMonth(); } - - /** - * Applicable only to date range picker - * Compares the month passed is in between the start and end date range - */ - isInRange(monthIndex: number): boolean { - if (!this._dateNavigationService.isRangePicker) { - return false; - } - if (this._dateNavigationService.selectedDay && this._dateNavigationService.selectedEndDay) { - return ( - (this.calendarYear === this._dateNavigationService.selectedDay.year && - monthIndex > this._dateNavigationService.selectedDay.month && - this.calendarYear === this._dateNavigationService.selectedEndDay.year && - monthIndex < this._dateNavigationService.selectedEndDay.month) || - (this._dateNavigationService.selectedDay.year !== this._dateNavigationService.selectedEndDay.year && - this.calendarYear === this._dateNavigationService.selectedDay.year && - monthIndex > this._dateNavigationService.selectedDay.month) || - (this._dateNavigationService.selectedDay.year !== this._dateNavigationService.selectedEndDay.year && - this.calendarYear === this._dateNavigationService.selectedEndDay.year && - monthIndex < this._dateNavigationService.selectedEndDay.month) || - (this.calendarYear > this._dateNavigationService.selectedDay.year && - this.calendarYear < this._dateNavigationService.selectedEndDay.year) - ); - } else if (this._dateNavigationService.selectedDay && !this._dateNavigationService.selectedEndDay) { - return ( - (this.calendarYear === this._dateNavigationService.selectedDay.year && - monthIndex > this._dateNavigationService.selectedDay.month && - monthIndex < this._dateNavigationService.hoveredMonth) || - (this.calendarYear > this._dateNavigationService.selectedDay.year && - monthIndex < this._dateNavigationService.hoveredMonth) - ); - } else { - return false; - } - } } diff --git a/projects/angular/src/forms/datepicker/providers/date-io.service.ts b/projects/angular/src/forms/datepicker/providers/date-io.service.ts index a04f90e37e..e6cd4320ff 100644 --- a/projects/angular/src/forms/datepicker/providers/date-io.service.ts +++ b/projects/angular/src/forms/datepicker/providers/date-io.service.ts @@ -7,7 +7,7 @@ import { Injectable } from '@angular/core'; -import { DateRange, DateRangeOption } from '../interfaces/date-range.interface'; +import { DateRange } from '../interfaces/date-range.interface'; import { DayModel } from '../model/day.model'; import { BIG_ENDIAN, @@ -33,10 +33,9 @@ export class DateIOService { minDate: new DayModel(0, 0, 1), maxDate: new DayModel(9999, 11, 31), }; - isDateRangePicker = false; + cldrLocaleDateFormat: string = DEFAULT_LOCALE_FORMAT; - private dateRangeOptions; private localeDisplayFormat: InputDateDisplayFormat = LITTLE_ENDIAN; private delimiters: [string, string] = ['/', '/']; @@ -74,25 +73,6 @@ export class DateIOService { } } - setIsDateRangePicker(flag: boolean) { - this.isDateRangePicker = flag; - } - - setRangeOptions(rangeOptions: DateRangeOption[]) { - let validatedRangeOption = this.validateDateRangeOptions(rangeOptions); - const hasCustomRangeOption = validatedRangeOption.findIndex(rangeOption => !!rangeOption.isCustomRange); - if (validatedRangeOption.length) { - if (hasCustomRangeOption === -1) { - validatedRangeOption = [...validatedRangeOption, { label: 'Custom Range', value: [], isCustomRange: true }]; - } - this.dateRangeOptions = validatedRangeOption; - } - } - - getRangeOptions() { - return this.dateRangeOptions; - } - toLocaleDisplayFormatString(date: Date): string { if (date) { if (isNaN(date.getTime())) { @@ -208,21 +188,4 @@ export class DateIOService { const result: number = parseToFourDigitYear(y); return result !== -1 ? new Date(result, m, d) : null; } - - private validateDateRangeOptions(rangeOptions: DateRangeOption[]): DateRangeOption[] { - const validOptions = []; - rangeOptions?.forEach((rangeOption: DateRangeOption) => { - if ( - !rangeOption.isCustomRange && - (!rangeOption.value?.length || - rangeOption.value?.length !== 2 || - Object.prototype.toString.call(rangeOption?.value[0]) !== '[object Date]' || - Object.prototype.toString.call(rangeOption?.value[1]) !== '[object Date]') - ) { - return; - } - validOptions.push(rangeOption); - }); - return validOptions; - } } diff --git a/projects/angular/src/forms/datepicker/providers/date-navigation.service.ts b/projects/angular/src/forms/datepicker/providers/date-navigation.service.ts index 0b172d6a14..4e656eb13b 100644 --- a/projects/angular/src/forms/datepicker/providers/date-navigation.service.ts +++ b/projects/angular/src/forms/datepicker/providers/date-navigation.service.ts @@ -8,7 +8,6 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { Subject } from 'rxjs'; -import { tap } from 'rxjs/operators'; import { CalendarModel } from '../model/calendar.model'; import { DayModel } from '../model/day.model'; @@ -22,18 +21,12 @@ import { DayModel } from '../model/day.model'; @Injectable() export class DateNavigationService { selectedDay: DayModel; - selectedEndDay: DayModel; focusedDay: DayModel; - hoveredDay: DayModel; - hoveredMonth: number; - hoveredYear: number; - isRangePicker = false; private _displayedCalendar: CalendarModel; private _todaysFullDate: Date = new Date(); private _today: DayModel; private _selectedDayChange = new Subject(); - private _selectedEndDayChange = new Subject(); private _displayedCalendarChange = new Subject(); private _focusOnCalendarChange = new Subject(); private _focusedDayChange = new Subject(); @@ -50,10 +43,6 @@ export class DateNavigationService { return this._selectedDayChange.asObservable(); } - get selectedEndDayChange(): Observable { - return this._selectedEndDayChange.asObservable(); - } - /** * This observable lets the subscriber know that the displayed calendar has changed. */ @@ -72,7 +61,7 @@ export class DateNavigationService { * This observable lets the subscriber know that the focused day in the displayed calendar has changed. */ get focusedDayChange(): Observable { - return this._focusedDayChange.asObservable().pipe(tap((day: DayModel) => (this.focusedDay = day))); + return this._focusedDayChange.asObservable(); } /** @@ -80,23 +69,8 @@ export class DateNavigationService { * Note: Only to be called from day.ts */ notifySelectedDayChanged(dayModel: DayModel) { - if (this.isRangePicker) { - if ( - !this.selectedDay || - (!!this.selectedDay && !!this.selectedEndDay) || - (!!this.selectedDay && dayModel?.isBefore(this.selectedDay)) - ) { - if (this.selectedEndDay) { - this.hoveredDay = this.hoveredMonth = this.hoveredYear = undefined; - this.setSelectedEndDay(undefined); - } - this.setSelectedDay(dayModel); - } else { - this.setSelectedEndDay(dayModel); - } - } else { - this.setSelectedDay(dayModel); - } + this.selectedDay = dayModel; + this._selectedDayChange.next(dayModel); } /** @@ -168,35 +142,6 @@ export class DateNavigationService { this._focusOnCalendarChange.next(); } - setSelectedDay(dayModel: DayModel | undefined): void { - this.selectedDay = dayModel; - this.updateDisplayedCalendarOnDaySelection(dayModel); - this._selectedDayChange.next(dayModel); - } - - setSelectedEndDay(dayModel: DayModel | undefined): void { - this.selectedEndDay = dayModel; - this.updateDisplayedCalendarOnDaySelection(dayModel); - this._selectedEndDayChange.next(dayModel); - } - - updateDisplayedCalendarOnDaySelection(day: DayModel | undefined): void { - if (day && this._displayedCalendar && !this._displayedCalendar.isDayInCalendar(day)) { - this.setDisplayedCalendar(new CalendarModel(day.year, day.month)); - } - } - - validateDateRange() { - if (!this.selectedDay || !this.selectedEndDay) { - if (this.selectedDay) { - this.setSelectedDay(undefined); - } - if (this.selectedEndDay) { - this.setSelectedEndDay(undefined); - } - } - } - // not a setter because i want this to remain private private setDisplayedCalendar(value: CalendarModel) { if (!this._displayedCalendar.isEqual(value)) { diff --git a/projects/angular/src/forms/datepicker/providers/datepicker-helper.service.ts b/projects/angular/src/forms/datepicker/providers/datepicker-helper.service.ts deleted file mode 100644 index fca8005de7..0000000000 --- a/projects/angular/src/forms/datepicker/providers/datepicker-helper.service.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2016-2024 Broadcom. All Rights Reserved. - * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. - * This software is released under MIT license. - * The full license information can be found in LICENSE in the root directory of this project. - */ - -import { Injectable } from '@angular/core'; - -import { ClrPopoverToggleService } from '../../../utils/popover/providers/popover-toggle.service'; -import { DayModel } from '../model/day.model'; -import { DateFormControlService } from './date-form-control.service'; -import { DateIOService } from './date-io.service'; -import { DateNavigationService } from './date-navigation.service'; -import { ViewManagerService } from './view-manager.service'; - -@Injectable() -export class DatePickerHelperService { - disabled: boolean; - - constructor( - private _dateNavigationService: DateNavigationService, - private _dateIOService: DateIOService, - private _toggleService: ClrPopoverToggleService, - private _viewManagerService: ViewManagerService, - private _dateFormControlService: DateFormControlService - ) {} - - selectDay(day: DayModel): void { - this.updateSelectedDate(day); - } - - updateSelectedDate(day: DayModel): void { - this._dateNavigationService.notifySelectedDayChanged(day); - this._dateFormControlService.markAsDirty(); - this.toggleDatepickerVisibility(); - this._dateNavigationService.hoveredDay = undefined; - } - - toggleDatepickerVisibility(): void { - if ( - this._dateNavigationService.isRangePicker && - !!this._dateNavigationService.selectedDay && - !!this._dateNavigationService.selectedEndDay - ) { - this._toggleService.open = false; - } else if (!this._dateNavigationService.isRangePicker && !!this._dateNavigationService.selectedDay) { - this._toggleService.open = false; - } - } - - convertDateToDayModel(date: Date): DayModel { - return new DayModel(date.getFullYear(), date.getMonth(), date.getDate()); - } - - convertStringDateToDayModel(year: number, month: number, day: number): DayModel { - return new DayModel(year, month, day); - } -} diff --git a/projects/angular/src/forms/datepicker/utils/test-utils.ts b/projects/angular/src/forms/datepicker/utils/test-utils.ts index 1d02f26370..a377df86f8 100644 --- a/projects/angular/src/forms/datepicker/utils/test-utils.ts +++ b/projects/angular/src/forms/datepicker/utils/test-utils.ts @@ -6,13 +6,9 @@ */ export function assertEqualDates(date1: Date, date2: Date): boolean { - if (date1 instanceof Date && date2 instanceof Date) { - return ( - date1.getFullYear() === date2.getFullYear() && - date1.getMonth() === date2.getMonth() && - date1.getDate() === date2.getDate() - ); - } else { - return false; - } + return ( + date1.getFullYear() === date2.getFullYear() && + date1.getMonth() === date2.getMonth() && + date1.getDate() === date2.getDate() + ); } diff --git a/projects/angular/src/forms/datepicker/yearpicker.spec.ts b/projects/angular/src/forms/datepicker/yearpicker.spec.ts index 242d4ae265..53f2374272 100644 --- a/projects/angular/src/forms/datepicker/yearpicker.spec.ts +++ b/projects/angular/src/forms/datepicker/yearpicker.spec.ts @@ -12,11 +12,8 @@ import { TestContext } from '../../data/datagrid/helpers.spec'; import { Keys } from '../../utils/enums/keys.enum'; import { ClrCommonStringsService } from '../../utils/i18n/common-strings.service'; import { ClrPopoverToggleService } from '../../utils/popover/providers/popover-toggle.service'; -import { DateFormControlService } from './providers/date-form-control.service'; -import { DateIOService } from './providers/date-io.service'; import { DateNavigationService } from './providers/date-navigation.service'; import { DatepickerFocusService } from './providers/datepicker-focus.service'; -import { DatePickerHelperService } from './providers/datepicker-helper.service'; import { LocaleHelperService } from './providers/locale-helper.service'; import { ViewManagerService } from './providers/view-manager.service'; import { ClrYearpicker } from './yearpicker'; @@ -44,9 +41,6 @@ export default function () { { provide: DateNavigationService, useValue: dateNavigationService }, LocaleHelperService, ClrCommonStringsService, - DatePickerHelperService, - DateIOService, - DateFormControlService, ]); }); @@ -183,9 +177,6 @@ export default function () { { provide: DateNavigationService, useValue: dateNavigationService }, LocaleHelperService, ClrCommonStringsService, - DatePickerHelperService, - DateIOService, - DateFormControlService, ]); }); @@ -260,7 +251,7 @@ export default function () { context.clarityDirective.changeYear(2015); expect(viewManagerService.isYearView).toBe(false); - expect(viewManagerService.isMonthView).toBe(true); + expect(viewManagerService.isDayView).toBe(true); }); it('updates year value in the date navigation service', () => { @@ -292,9 +283,6 @@ export default function () { { provide: DateNavigationService, useValue: dateNavigationService }, LocaleHelperService, ClrCommonStringsService, - DatePickerHelperService, - DateIOService, - DateFormControlService, ]); } diff --git a/projects/angular/src/forms/datepicker/yearpicker.ts b/projects/angular/src/forms/datepicker/yearpicker.ts index 1cbf1397d2..d42ca82d05 100644 --- a/projects/angular/src/forms/datepicker/yearpicker.ts +++ b/projects/angular/src/forms/datepicker/yearpicker.ts @@ -50,13 +50,9 @@ import { ViewManagerService } from './providers/view-manager.service'; type="button" class="calendar-btn year" [attr.tabindex]="getTabIndex(year)" - [class.is-selected]="year === calendarYear || year === calendarEndYear" - [class.is-start-range]="getIsRangeStartYear(year)" - [class.is-end-range]="getIsRangeEndYear(year)" - [class.in-range]="isInRange(year)" + [class.is-selected]="year === calendarYear" [class.is-today]="year === currentCalendarYear" (click)="changeYear(year)" - (mouseenter)="onHover(year)" > {{ year }} @@ -98,25 +94,10 @@ export class ClrYearpicker implements AfterViewInit { : this._dateNavigationService.displayedCalendar.year; } - /** - * Gets the year which the user is currently on. - */ - get calendarEndYear(): number { - return this._dateNavigationService.selectedEndDay?.year; - } - get currentCalendarYear(): number { return new Date().getFullYear(); } - getIsRangeStartYear(year: number): boolean { - return this._dateNavigationService.isRangePicker && year === this._dateNavigationService.selectedDay?.year; - } - - getIsRangeEndYear(year: number): boolean { - return this._dateNavigationService.isRangePicker && year === this._dateNavigationService.selectedEndDay?.year; - } - /** * Focuses on the current calendar year when the View is initialized. */ @@ -156,14 +137,7 @@ export class ClrYearpicker implements AfterViewInit { */ changeYear(year: number): void { this._dateNavigationService.changeYear(year); - this._viewManagerService.changeToMonthView(); - } - - /** - * Calls the DateNavigationService to update the hovered year value of the calendar - */ - onHover(year: number): void { - this._dateNavigationService.hoveredYear = year; + this._viewManagerService.changeToDayView(); } /** @@ -201,8 +175,6 @@ export class ClrYearpicker implements AfterViewInit { if (!this.yearRangeModel.inRange(this._focusedYear)) { if (this.yearRangeModel.inRange(this.calendarYear)) { this._focusedYear = this.calendarYear; - } else if (this.yearRangeModel.inRange(this.calendarEndYear)) { - this._focusedYear = this.calendarEndYear; } else { this._focusedYear = this.yearRangeModel.middleYear; } @@ -210,22 +182,6 @@ export class ClrYearpicker implements AfterViewInit { return this._focusedYear === year ? 0 : -1; } - /** - * Applicable only to date range picker - * Compares the year passed is in between the start and end date range - */ - isInRange(year: number): boolean { - if (!this._dateNavigationService.isRangePicker) { - return false; - } - if (this._dateNavigationService.selectedDay?.year && this.calendarEndYear) { - return year > this.calendarYear && year < this.calendarEndYear; - } else if (this._dateNavigationService.selectedDay?.year && !this.calendarEndYear) { - return year > this.calendarYear && year < this._dateNavigationService.hoveredYear; - } else { - return false; - } - } /** * Increments the focus year by the value passed. Updates the YearRangeModel if the * new value is not in the current decade. diff --git a/projects/angular/src/forms/tests/container.spec.ts b/projects/angular/src/forms/tests/container.spec.ts index 7db19df82c..0530f5b067 100644 --- a/projects/angular/src/forms/tests/container.spec.ts +++ b/projects/angular/src/forms/tests/container.spec.ts @@ -221,15 +221,14 @@ function fullSpec(description, testContainer, directives: any | any[], testCompo test.disabled = true; fixture.detectChanges(); // Have to wait for the whole control to settle or it doesn't track - await fixture.whenStable(); expect(containerEl.className).not.toContain('clr-form-control-disabled'); if (test.form) { // Handle setting disabled based on reactive form test.form.get('model').reset({ value: '', disabled: true }); - fixture.detectChanges(); - expect(containerEl.className).toContain('clr-form-control-disabled', containerEl.className); } + fixture.detectChanges(); + expect(containerEl.className).toContain('clr-form-control-disabled'); }); it('implements ngOnDestroy', () => { diff --git a/projects/demo/src/app/datepicker/datepicker.demo.html b/projects/demo/src/app/datepicker/datepicker.demo.html index bb7231ab57..78a2c03f8c 100644 --- a/projects/demo/src/app/datepicker/datepicker.demo.html +++ b/projects/demo/src/app/datepicker/datepicker.demo.html @@ -23,12 +23,6 @@

Datepicker

  • Reactive Forms
  • CSS Regression
  • Locale Data
  • -
  • - Date Range Picker - New - -
  • diff --git a/projects/demo/src/app/datepicker/datepicker.demo.module.ts b/projects/demo/src/app/datepicker/datepicker.demo.module.ts index a93be4dc95..9548137ed8 100644 --- a/projects/demo/src/app/datepicker/datepicker.demo.module.ts +++ b/projects/demo/src/app/datepicker/datepicker.demo.module.ts @@ -25,7 +25,6 @@ import { DatepickerLocaleData } from './datepicker-locale-data'; import { DatepickerMinMaxDemo } from './datepicker-min-max'; import { DatepickerDemo } from './datepicker.demo'; import { ROUTING } from './datepicker.demo.routing'; -import { DateRangePickerDemo } from './daterangepicker'; import { DisabledDemo } from './disabled'; import { DatepickerLayoutDemo } from './layout'; import { NgModelAutoWrappedDatepickerDemo } from './ngmodel-auto-wrapped'; @@ -52,7 +51,6 @@ import { NgModelExplicitWrapperDemo } from './ngmodel-wrapper-explicit-wrapper'; DisabledDemo, DatepickerLayoutDemo, DatepickerMinMaxDemo, - DateRangePickerDemo, ], exports: [ DatepickerDemo, @@ -73,7 +71,6 @@ import { NgModelExplicitWrapperDemo } from './ngmodel-wrapper-explicit-wrapper'; DisabledDemo, DatepickerLayoutDemo, DatepickerMinMaxDemo, - DateRangePickerDemo, ], }) export class DatepickerDemoModule {} diff --git a/projects/demo/src/app/datepicker/datepicker.demo.routing.ts b/projects/demo/src/app/datepicker/datepicker.demo.routing.ts index a8a6fa3290..490a65a9a8 100644 --- a/projects/demo/src/app/datepicker/datepicker.demo.routing.ts +++ b/projects/demo/src/app/datepicker/datepicker.demo.routing.ts @@ -22,7 +22,6 @@ import { DatepickerKKJDemo } from './datepicker-KKJ'; import { DatepickerLocaleData } from './datepicker-locale-data'; import { DatepickerMinMaxDemo } from './datepicker-min-max'; import { DatepickerDemo } from './datepicker.demo'; -import { DateRangePickerDemo } from './daterangepicker'; import { DisabledDemo } from './disabled'; import { DatepickerLayoutDemo } from './layout'; import { NgModelAutoWrappedDatepickerDemo } from './ngmodel-auto-wrapped'; @@ -44,7 +43,6 @@ const ROUTES: Routes = [ { path: 'disabled', component: DisabledDemo }, { path: 'layout', component: DatepickerLayoutDemo }, { path: 'datepicker-min-max', component: DatepickerMinMaxDemo }, - { path: 'date-range-picker', component: DateRangePickerDemo }, { path: 'locale-data', component: DatepickerLocaleData, diff --git a/projects/demo/src/app/datepicker/datepicker.demo.scss b/projects/demo/src/app/datepicker/datepicker.demo.scss index 43779f03bf..03a3744afa 100644 --- a/projects/demo/src/app/datepicker/datepicker.demo.scss +++ b/projects/demo/src/app/datepicker/datepicker.demo.scss @@ -22,59 +22,3 @@ .clr-example-input { display: inline-block; } - -.date-range-section { - margin: 0 20px; - .flex-section { - display: flex; - flex-wrap: wrap; - justify-content: center; - margin-bottom: 20px; - } - .card { - flex-basis: 47%; - margin: 25px 15px; - display: flex; - flex-wrap: wrap; - &::before { - content: attr(data-heading); - position: absolute; - top: -12px; - left: 12px; - background: var(--clr-global-app-background); - padding: 0 10px; - border: 0; - font-weight: 400; - font-size: 18px; - } - } - .clr-form-control { - margin: 0 !important; - } - .clr-form-horizontal .clr-form-control > .clr-control-label { - width: unset; - } - .card-content { - padding: 35px var(--cds-global-space-7); - display: flex; - justify-content: center; - width: 100%; - &::after { - margin-bottom: 6px; - display: block; - content: ''; - } - } - - .card-validations { - position: relative; - padding: var(--cds-global-space-7); - border-top: var(--clr-card-border-width) solid var(--clr-card-border-color); - width: 100%; - - .form-input-wrapper { - display: flex; - justify-content: space-evenly; - } - } -} diff --git a/projects/demo/src/app/datepicker/daterangepicker.html b/projects/demo/src/app/datepicker/daterangepicker.html deleted file mode 100644 index 2199c516af..0000000000 --- a/projects/demo/src/app/datepicker/daterangepicker.html +++ /dev/null @@ -1,113 +0,0 @@ - - -

    Date Range Picker

    - -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - Minimum date should be {{dateForm.get(startDtFc).errors?.min?.min || dateForm.get(endDtFc).errors?.min?.min}} - - - - - Maximum date should be {{dateForm.get(startDtFc).errors?.max?.max || dateForm.get(endDtFc).errors?.max?.max}} - - - - - Start date must be less than End date - - - - - diff --git a/projects/demo/src/app/datepicker/daterangepicker.ts b/projects/demo/src/app/datepicker/daterangepicker.ts deleted file mode 100644 index a9b2464dec..0000000000 --- a/projects/demo/src/app/datepicker/daterangepicker.ts +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2016-2024 Broadcom. All Rights Reserved. - * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. - * This software is released under MIT license. - * The full license information can be found in LICENSE in the root directory of this project. - */ - -import { Component, OnInit } from '@angular/core'; -import { FormControl, FormGroup } from '@angular/forms'; - -@Component({ - selector: 'clr-daterangepicker-demo', - styleUrls: ['./datepicker.demo.scss'], - templateUrl: './daterangepicker.html', -}) -export class DateRangePickerDemo implements OnInit { - dateForm = new FormGroup({ - startDateV1: new FormControl(), - endDateV1: new FormControl(), - minDateV1: new FormControl('2024-02-01'), - maxDateV1: new FormControl('2024-12-31'), - - startDateWithOptionV1: new FormControl(), - endDateWithOptionV1: new FormControl(), - minDateWithOptionV1: new FormControl('2024-02-01'), - maxDateWithOptionV1: new FormControl('2024-12-31'), - }); - - dateRangeOptions = [ - { label: 'Today', value: [new Date(), new Date()] }, - { label: 'Last 7 Days', value: [this.addDays(new Date(), -7), new Date()] }, - { label: 'Last 14 Days', value: [this.addDays(new Date(), -14), new Date()] }, - { label: 'Last 30 Days', value: [this.addDays(new Date(), -30), new Date()] }, - { label: 'Last 90 Days', value: [this.addDays(new Date(), -90), new Date()] }, - ]; - - monthRangeOptions = [ - { - label: 'This Month', - value: [ - new Date(new Date().getFullYear(), new Date().getMonth(), 1), - new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0), - ], - }, - { - label: 'Last Month', - value: [ - new Date(new Date().getFullYear(), new Date().getMonth() - 1, 1), - new Date(new Date().getFullYear(), new Date().getMonth(), 0), - ], - }, - { - label: 'Last 2 Months', - value: [ - new Date(new Date().getFullYear(), new Date().getMonth() - 2, 1), - new Date(new Date().getFullYear(), new Date().getMonth(), 0), - ], - }, - { - label: 'Last 6 Months', - value: [ - new Date(new Date().getFullYear(), new Date().getMonth() - 6, 1), - new Date(new Date().getFullYear(), new Date().getMonth(), 0), - ], - }, - { - label: 'Last 12 Months', - value: [ - new Date(new Date().getFullYear(), new Date().getMonth() - 12, 1), - new Date(new Date().getFullYear(), new Date().getMonth(), 0), - ], - }, - { label: 'Custom Range', value: [], isCustomRange: true }, - ]; - - yearRangeOptions = [ - { - label: 'This year', - value: [new Date(new Date().getFullYear(), 1, 1), new Date(new Date().getFullYear() + 1, 0, 0)], - }, - { - label: 'Last year', - value: [new Date(new Date().getFullYear() - 1, 1, 1), new Date(new Date().getFullYear(), 0, 0)], - }, - { - label: 'Last 2 Years', - value: [new Date(new Date().getFullYear() - 2, 1, 1), new Date(new Date().getFullYear(), 0, 0)], - }, - { - label: 'Last 5 Years', - value: [new Date(new Date().getFullYear() - 5, 1, 1), new Date(new Date().getFullYear(), 0, 0)], - }, - { label: 'Custom Range', value: [], isCustomRange: true }, - ]; - - ngOnInit(): void { - this.dateForm.get('startDateV1').statusChanges.subscribe(status => { - console.log('🚀 ~ DateRangePickerDemo ~ startDateV1 ~ status:', status); - }); - this.dateForm.get('endDateV1').statusChanges.subscribe(status => { - console.log('🚀 ~ DateRangePickerDemo ~ endDateV1 ~ status:', status); - }); - } - stDateChanged(date: Date) { - console.log(date); - } - - endDateChanged(date: Date) { - console.log(date); - } - - addDays(date = new Date(), days) { - return new Date(date.getTime() + 86400000 * days); - } -} diff --git a/tests/snapshots/chromium/datepicker/daterangepicker--date-range-picker-core-dark.png b/tests/snapshots/chromium/datepicker/daterangepicker--date-range-picker-core-dark.png deleted file mode 100644 index 48903561c0..0000000000 Binary files a/tests/snapshots/chromium/datepicker/daterangepicker--date-range-picker-core-dark.png and /dev/null differ diff --git a/tests/snapshots/chromium/datepicker/daterangepicker--date-range-picker-core-light.png b/tests/snapshots/chromium/datepicker/daterangepicker--date-range-picker-core-light.png deleted file mode 100644 index 25ba9f0ace..0000000000 Binary files a/tests/snapshots/chromium/datepicker/daterangepicker--date-range-picker-core-light.png and /dev/null differ diff --git a/tests/snapshots/chromium/datepicker/daterangepicker--default-date-core-dark.png b/tests/snapshots/chromium/datepicker/daterangepicker--default-date-core-dark.png deleted file mode 100644 index d8ee08f31e..0000000000 Binary files a/tests/snapshots/chromium/datepicker/daterangepicker--default-date-core-dark.png and /dev/null differ diff --git a/tests/snapshots/chromium/datepicker/daterangepicker--default-date-core-light.png b/tests/snapshots/chromium/datepicker/daterangepicker--default-date-core-light.png deleted file mode 100644 index 88163befc7..0000000000 Binary files a/tests/snapshots/chromium/datepicker/daterangepicker--default-date-core-light.png and /dev/null differ diff --git a/tests/snapshots/chromium/datepicker/daterangepicker--disabled-core-dark.png b/tests/snapshots/chromium/datepicker/daterangepicker--disabled-core-dark.png deleted file mode 100644 index c32b9387f2..0000000000 Binary files a/tests/snapshots/chromium/datepicker/daterangepicker--disabled-core-dark.png and /dev/null differ diff --git a/tests/snapshots/chromium/datepicker/daterangepicker--disabled-core-light.png b/tests/snapshots/chromium/datepicker/daterangepicker--disabled-core-light.png deleted file mode 100644 index 9754d2114e..0000000000 Binary files a/tests/snapshots/chromium/datepicker/daterangepicker--disabled-core-light.png and /dev/null differ diff --git a/tests/snapshots/chromium/datepicker/daterangepicker--max-date-core-dark.png b/tests/snapshots/chromium/datepicker/daterangepicker--max-date-core-dark.png deleted file mode 100644 index 48903561c0..0000000000 Binary files a/tests/snapshots/chromium/datepicker/daterangepicker--max-date-core-dark.png and /dev/null differ diff --git a/tests/snapshots/chromium/datepicker/daterangepicker--max-date-core-light.png b/tests/snapshots/chromium/datepicker/daterangepicker--max-date-core-light.png deleted file mode 100644 index 25ba9f0ace..0000000000 Binary files a/tests/snapshots/chromium/datepicker/daterangepicker--max-date-core-light.png and /dev/null differ diff --git a/tests/snapshots/chromium/datepicker/daterangepicker--min-date-core-dark.png b/tests/snapshots/chromium/datepicker/daterangepicker--min-date-core-dark.png deleted file mode 100644 index 48903561c0..0000000000 Binary files a/tests/snapshots/chromium/datepicker/daterangepicker--min-date-core-dark.png and /dev/null differ diff --git a/tests/snapshots/chromium/datepicker/daterangepicker--min-date-core-light.png b/tests/snapshots/chromium/datepicker/daterangepicker--min-date-core-light.png deleted file mode 100644 index 25ba9f0ace..0000000000 Binary files a/tests/snapshots/chromium/datepicker/daterangepicker--min-date-core-light.png and /dev/null differ diff --git a/tests/snapshots/firefox/datepicker/daterangepicker--date-range-picker-core-dark.png b/tests/snapshots/firefox/datepicker/daterangepicker--date-range-picker-core-dark.png deleted file mode 100644 index 80e4b045ce..0000000000 Binary files a/tests/snapshots/firefox/datepicker/daterangepicker--date-range-picker-core-dark.png and /dev/null differ diff --git a/tests/snapshots/firefox/datepicker/daterangepicker--date-range-picker-core-light.png b/tests/snapshots/firefox/datepicker/daterangepicker--date-range-picker-core-light.png deleted file mode 100644 index c3076a9151..0000000000 Binary files a/tests/snapshots/firefox/datepicker/daterangepicker--date-range-picker-core-light.png and /dev/null differ diff --git a/tests/snapshots/firefox/datepicker/daterangepicker--default-date-core-dark.png b/tests/snapshots/firefox/datepicker/daterangepicker--default-date-core-dark.png deleted file mode 100644 index 07741b3757..0000000000 Binary files a/tests/snapshots/firefox/datepicker/daterangepicker--default-date-core-dark.png and /dev/null differ diff --git a/tests/snapshots/firefox/datepicker/daterangepicker--default-date-core-light.png b/tests/snapshots/firefox/datepicker/daterangepicker--default-date-core-light.png deleted file mode 100644 index 176fd51df4..0000000000 Binary files a/tests/snapshots/firefox/datepicker/daterangepicker--default-date-core-light.png and /dev/null differ diff --git a/tests/snapshots/firefox/datepicker/daterangepicker--disabled-core-dark.png b/tests/snapshots/firefox/datepicker/daterangepicker--disabled-core-dark.png deleted file mode 100644 index 219884d553..0000000000 Binary files a/tests/snapshots/firefox/datepicker/daterangepicker--disabled-core-dark.png and /dev/null differ diff --git a/tests/snapshots/firefox/datepicker/daterangepicker--disabled-core-light.png b/tests/snapshots/firefox/datepicker/daterangepicker--disabled-core-light.png deleted file mode 100644 index f7d348fa42..0000000000 Binary files a/tests/snapshots/firefox/datepicker/daterangepicker--disabled-core-light.png and /dev/null differ diff --git a/tests/snapshots/firefox/datepicker/daterangepicker--max-date-core-dark.png b/tests/snapshots/firefox/datepicker/daterangepicker--max-date-core-dark.png deleted file mode 100644 index 80e4b045ce..0000000000 Binary files a/tests/snapshots/firefox/datepicker/daterangepicker--max-date-core-dark.png and /dev/null differ diff --git a/tests/snapshots/firefox/datepicker/daterangepicker--max-date-core-light.png b/tests/snapshots/firefox/datepicker/daterangepicker--max-date-core-light.png deleted file mode 100644 index c3076a9151..0000000000 Binary files a/tests/snapshots/firefox/datepicker/daterangepicker--max-date-core-light.png and /dev/null differ diff --git a/tests/snapshots/firefox/datepicker/daterangepicker--min-date-core-dark.png b/tests/snapshots/firefox/datepicker/daterangepicker--min-date-core-dark.png deleted file mode 100644 index 80e4b045ce..0000000000 Binary files a/tests/snapshots/firefox/datepicker/daterangepicker--min-date-core-dark.png and /dev/null differ diff --git a/tests/snapshots/firefox/datepicker/daterangepicker--min-date-core-light.png b/tests/snapshots/firefox/datepicker/daterangepicker--min-date-core-light.png deleted file mode 100644 index c3076a9151..0000000000 Binary files a/tests/snapshots/firefox/datepicker/daterangepicker--min-date-core-light.png and /dev/null differ