Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pickers refactoring #9160

Merged
merged 94 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
b67f6af
feat(*): add PickersBaseDirective
jackofdiamond5 Jan 25, 2021
03d0e3e
Merge branch 'karma-coverage-master' of https://github.com/IgniteUI/i…
jackofdiamond5 Jan 25, 2021
0324abb
Merge branch 'master' into bpenkov/pickers-base-parent
jackofdiamond5 Jan 28, 2021
40c3aae
Merge branch 'master' into bpenkov/pickers-base-parent
kdinev Feb 2, 2021
39513dc
feat(date-time-editor): handling for wheel events
jackofdiamond5 Feb 9, 2021
8d7a38d
feat(types): add new enum HeaderOrientation
jackofdiamond5 Feb 9, 2021
88320ef
feat(date-time-editor): add preventSpeenOnWheel input
jackofdiamond5 Feb 9, 2021
4e14e07
feat(date-time-editor): can be set to suppress focus
jackofdiamond5 Feb 9, 2021
6efffd2
feat(DatePickerUtils): add method for min/max validation
jackofdiamond5 Feb 10, 2021
d0422ee
Merge branch 'master' into bpenkov/pickers-base-parent
kdinev Feb 11, 2021
a6a5ecf
refactor(CalendarContainer): move to date-utils
jackofdiamond5 Feb 11, 2021
67630b6
chore(date-picker): fix imports to calendar container
jackofdiamond5 Feb 15, 2021
e628eb5
feat(PickersBaseDirective): implements EditorProvider
jackofdiamond5 Feb 15, 2021
1cf27be
Merge remote-tracking branch 'remotes/origin/bpenkov/pickers-base-par…
jackofdiamond5 Feb 15, 2021
bfb4582
chore(calendar-container): update click handler names
jackofdiamond5 Feb 16, 2021
d6fb8d3
fix(date-time-editor): clear method updates mask properly
jackofdiamond5 Feb 26, 2021
12ac3ef
refactor(picker-icons): move picker icon components to date-common
jackofdiamond5 Feb 26, 2021
9926d39
Merge branch 'master' into bpenkov/pickers-base-parent
jackofdiamond5 Mar 1, 2021
1312e8f
Merge remote-tracking branch 'remotes/origin/bpenkov/pickers-base-par…
jackofdiamond5 Mar 1, 2021
49c4e88
refactor(*): update comments & code clean up
jackofdiamond5 Mar 8, 2021
ea18284
fix(igx-input): add support for disabled attr without value
jackofdiamond5 Mar 9, 2021
8e2ef17
fix(igxMask): prevent focus if input is readonly
jackofdiamond5 Mar 9, 2021
48506ff
feat(date-time-editor): add option to set spin delta per part #7169 (…
jackofdiamond5 Mar 11, 2021
a3538d7
refactor(date-range): pickers base, overlay service, template buttons…
jackofdiamond5 Mar 16, 2021
f99d888
refactor(DateTimeUtil): rename and move to date-common, clean up, add…
jackofdiamond5 Mar 19, 2021
cd9c387
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
jackofdiamond5 Apr 5, 2021
4e88243
refactor(date-picker): simplify templating, integrate date-time direc…
jackofdiamond5 Apr 6, 2021
ace673d
refactor(date-editor): make date part deltas optional
jackofdiamond5 Apr 6, 2021
ddcc0dd
refactor(date-editor): rename isSpinLoop to spinLoop
jackofdiamond5 Apr 6, 2021
0edc8d8
feat(date-editor): adjust input format based on locale if not set
jackofdiamond5 Apr 6, 2021
905edfc
fix(date-editor): don't apply mask if readonly, displayValuePipe
jackofdiamond5 Apr 6, 2021
7f767f7
fix(date-picker): properly set required, coerce cal date focus to val…
jackofdiamond5 Apr 7, 2021
5d947c2
Merge pull request #8939 from IgniteUI/bpenkov/date-picker-refactoring
Lipata Apr 7, 2021
ff2e233
feat(date-time-editor, date-range-picker, date-picker): ISO 8601 supp…
jackofdiamond5 Apr 8, 2021
05e6626
feat(date-picker): add readonly prop, close on escape
jackofdiamond5 Apr 12, 2021
2c4bd07
fix(date-time-editor): ignore keydown if editor is readonly
jackofdiamond5 Apr 12, 2021
6cfa990
refactor(advanced-filtering): update date picker template
jackofdiamond5 Apr 12, 2021
70f7bdd
refactor(filtering-row): update date picker template
jackofdiamond5 Apr 12, 2021
641a108
refactor(excel-style-date-expr): update date picker template
jackofdiamond5 Apr 14, 2021
ceed7fe
refactor(samples): update date picker template
jackofdiamond5 Apr 14, 2021
01766b7
test(grid-filtering): update ui tests for date picker
jackofdiamond5 Apr 14, 2021
62cbf77
refactor(input-directive): set disabled using hostbinding
jackofdiamond5 Apr 15, 2021
a0fe3dd
Merge remote-tracking branch 'remotes/origin/master' into pickers-ref…
jackofdiamond5 Apr 15, 2021
5a7d9c3
Merge remote-tracking branch 'remotes/origin/pickers-refactoring' int…
jackofdiamond5 Apr 15, 2021
bf675c6
fix(advanced-filtering): bind disabled to igxInput in input group
jackofdiamond5 Apr 15, 2021
1f664d9
Merge pull request #9322 from IgniteUI/bpenkov/date-picker-template-g…
damyanpetev Apr 15, 2021
3af552f
Merge branch 'master' into pickers-refactoring
Lipata Apr 16, 2021
d4f448a
test(date-picker): add platform to constructor
jackofdiamond5 Apr 16, 2021
16b942d
Merge branch 'master' into pickers-refactoring
Lipata Apr 16, 2021
6ce03c5
Merge remote-tracking branch 'remotes/origin/master' into pickers-ref…
jackofdiamond5 Apr 19, 2021
d91158a
Merge branch 'master' into pickers-refactoring
kdinev Apr 19, 2021
b2b1758
feat(igx-time-picker): refactoring #6482 (#8947)
PlamenaMiteva Apr 19, 2021
63a54eb
feat(date-time-editor, pickers): add migrations, changelog, readme #6…
Lipata Apr 19, 2021
13367e1
Merge remote-tracking branch 'remotes/origin/master' into pickers-ref…
jackofdiamond5 Apr 19, 2021
cf38e58
test(calendar-mulit-view): close calendar with method
Lipata Apr 19, 2021
2166ee8
test(calendar-mulit-view): close calendar with method
Lipata Apr 19, 2021
de16797
test(time-picker): fix failing tests #6482
PlamenaMiteva Apr 20, 2021
900400f
Merge branch 'pickers-refactoring' of https://github.com/IgniteUI/ign…
PlamenaMiteva Apr 20, 2021
9370ece
test(time-picker): fix failing test #6482
PlamenaMiteva Apr 20, 2021
2746270
docs(date-date-editor, pickers): update changelog
Lipata Apr 20, 2021
5043115
refactor(date-range,date-time-editor): fix tests, include detach
jackofdiamond5 Apr 20, 2021
cad6ff4
Merge branch 'pickers-refactoring' of https://github.com/IgniteUI/ign…
jackofdiamond5 Apr 20, 2021
1152f28
test(select): detectChanges after disabled is host-binded
Lipata Apr 20, 2021
aaf06d8
Merge branch 'master' into pickers-refactoring
kdinev Apr 20, 2021
c69f116
fix(date-picker): fix format migration
Lipata Apr 20, 2021
4749996
refactor(time-column): update time picker expandable edit template
damyanpetev Apr 20, 2021
97925b0
test(*): update test scenarios
jackofdiamond5 Apr 20, 2021
c0c084f
Merge remote-tracking branch 'origin/master' into pickers-refactoring
damyanpetev Apr 20, 2021
f5f2777
refactor(filtering): update handling of date/time pickers
damyanpetev Apr 20, 2021
97eb921
refactor(date-picker): properly detach overlay during ondestroy
jackofdiamond5 Apr 20, 2021
9f4eeeb
Merge branch 'master' into pickers-refactoring
Lipata Apr 20, 2021
2988e2a
fix(migrations): add InteractioMode rename
Lipata Apr 20, 2021
7a9d55c
fix(migrations): do not add label when there is already
Lipata Apr 21, 2021
f6322a4
refactor(time-column): update time picker tree cell edit template
damyanpetev Apr 21, 2021
b3b9ed3
test(date-picker): Test canceling opening and closing events
dafo Apr 21, 2021
595485f
Merge branch 'pickers-refactoring' of https://github.com/IgniteUI/ign…
dafo Apr 21, 2021
ee09f34
test(date-picker): Adding a template to the spec
dafo Apr 21, 2021
0c7e9f9
chore(date-picker): temporary xit tests
jackofdiamond5 Apr 21, 2021
691568e
test(excel-filter): restore date custom formatter checks
damyanpetev Apr 21, 2021
e38861e
test(date-picker): Add kbrd navigation tests
Apr 21, 2021
fd61877
Merge branch 'pickers-refactoring' of https://github.com/IgniteUI/ign…
Apr 21, 2021
033d5ad
chore(date-picker): Comment out TODOs
Apr 21, 2021
2e85dfb
test(date-picker): refactor date-picker API Unit tests,reorder sectio…
ViktorSlavov Apr 21, 2021
6ccd884
refactor(time-picker): selectedDate to fall back to the closest possi…
PlamenaMiteva Apr 21, 2021
e2e75b2
Merge branch 'pickers-refactoring' of https://github.com/IgniteUI/ign…
PlamenaMiteva Apr 21, 2021
62c5d32
chore(pickers): fix lint errors
PlamenaMiteva Apr 21, 2021
119df8c
fix(picker-base): remove default box type
damyanpetev Apr 21, 2021
5c15eaa
fix(input): update input group focused state if disabled
damyanpetev Apr 21, 2021
fa29f6b
docs(pickers): update changelog
Lipata Apr 21, 2021
64eb4b5
Merge branch 'master' into pickers-refactoring
Lipata Apr 21, 2021
2359621
test(date-picker): move ngControlValueAccessor tests to integration s…
ViktorSlavov Apr 21, 2021
dc3ad3e
docs(pickers): update changelog
Lipata Apr 21, 2021
5f59f3c
test(filtering): query dom for date picker
jackofdiamond5 Apr 21, 2021
46b0082
fix(advanced-filtering): focus input or pickers
jackofdiamond5 Apr 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ All notable changes for each version of this project will be documented in this
- `onDataPreLoad` -> `dataPreLoad`

### New Features
- `IgxDateTimeEditor`
- `spinDelta` input property which allows a user to provide different delta values that will be used for spinning. All parts default to `1`.
- `increment` and `decrement` methods now accept an optional `delta` parameter which targets the currently spun date portion. It takes precedence over the values set in `spinDelta`.
- `IgxForOf`, `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
- **Behavioral Change** - Virtual containers now scroll smoothly when using the mouse wheel(s) to scroll them horizontally or vertically. This behavior more closely resembles the scrolling behavior of non-virtualized containers in most modern browsers.
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { configureTestSuite } from '../test-utils/configure-suite';
import { UIInteractions, wait } from '../test-utils/ui-interactions.spec';
import { IgxCalendarComponent, IgxCalendarModule } from './public_api';
import { IgxDatePickerComponent, IgxDatePickerModule } from '../date-picker/date-picker.component';
import { IgxDatePickerComponent, IgxDatePickerModule } from '../date-picker/public_api';
import { DateRangeType } from '../core/dates';
import { HelperTestFunctions } from './calendar-helper-utils';

Expand Down Expand Up @@ -1284,7 +1284,7 @@ describe('Multi-View Calendar - ', () => {
fixture.detectChanges();

datePicker.mode = 'dropdown';
datePicker.monthsViewNumber = 2;
datePicker.displayMonthsCount = 2;
tick();
fixture.detectChanges();

Expand Down Expand Up @@ -1346,7 +1346,7 @@ export class MultiViewCalendarSampleComponent {

@Component({
template: `
<igx-date-picker [value]="date" [monthsViewNumber]="monthViews" [hideOutsideDays]="true"></igx-date-picker>
<igx-date-picker [value]="date" [displayMonthsCount]="monthViews" [hideOutsideDays]="true"></igx-date-picker>
`
})
export class MultiViewDatePickerSampleComponent {
Expand Down
10 changes: 0 additions & 10 deletions projects/igniteui-angular/src/lib/core/enums.ts

This file was deleted.

2 changes: 1 addition & 1 deletion projects/igniteui-angular/src/lib/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export const isObject = (value: any): boolean => value && value.toString() === '
* @returns true if provided variable is Date
* @hidden
*/
export const isDate = (value: any): boolean => value instanceof Date;
export const isDate = (value: any): value is Date => value instanceof Date;

/**
* Checks if the two passed arguments are equal
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<ng-template #defaultPickerActions>
<div *ngIf="this.closeButtonLabel || this.todayButtonLabel" class="igx-date-picker__buttons">
<button #closeButton *ngIf="this.closeButtonLabel" igxButton="flat" igxRipple
(click)="this.calendarClose.emit()">
{{ this.closeButtonLabel }}
</button>
<button #todayButton *ngIf="this.todayButtonLabel" igxButton="flat" igxRipple
(click)="this.todaySelection.emit()">
{{ this.todayButtonLabel }}
</button>
</div>
</ng-template>

<igx-calendar></igx-calendar>
<ng-container *ngTemplateOutlet="this.pickerActions
? this.pickerActions.template
: defaultPickerActions">
</ng-container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { CommonModule } from '@angular/common';
import { NgModule, Component, ViewChild, Output, EventEmitter, HostListener, HostBinding } from '@angular/core';
import { IgxCalendarComponent, IgxCalendarModule } from '../../calendar/public_api';
import { PickerInteractionMode } from '../../date-common/types';
import { IgxButtonModule } from '../../directives/button/button.directive';
import { IgxRippleModule } from '../../directives/ripple/ripple.directive';
import { IgxPickerActionsDirective } from '../picker-icons.common';

/** @hidden */
@Component({
selector: 'igx-calendar-container',
styles: [':host {display: block;}'],
templateUrl: 'calendar-container.component.html'
})
export class IgxCalendarContainerComponent {
@ViewChild(IgxCalendarComponent, { static: true })
public calendar: IgxCalendarComponent;

@Output()
public calendarClose = new EventEmitter();

@Output()
public todaySelection = new EventEmitter();

@HostBinding('class.igx-date-picker')
public styleClass = 'igx-date-picker';

@HostBinding('class.igx-date-picker--dropdown')
public get dropdownCSS(): boolean {
return this.mode === PickerInteractionMode.DropDown;
}

@HostBinding('class.igx-date-picker--vertical')
public get verticalCSS(): boolean {
return this.vertical && this.mode === PickerInteractionMode.Dialog;
}

public vertical = false;
public closeButtonLabel: string;
public todayButtonLabel: string;
public mode = PickerInteractionMode.DropDown;
public pickerActions: IgxPickerActionsDirective;

@HostListener('keydown.alt.arrowup', ['$event'])
public onEscape(event) {
event.preventDefault();
this.calendarClose.emit();
}

public get isReadonly() {
return this.mode === PickerInteractionMode.Dialog;
}
}

/** @hidden */
@NgModule({
declarations: [IgxCalendarContainerComponent],
entryComponents: [IgxCalendarContainerComponent],
imports: [
CommonModule,
IgxButtonModule,
IgxRippleModule,
IgxCalendarModule
],
exports: [IgxCalendarContainerComponent]
})
export class IgxCalendarContainerModule { }
233 changes: 233 additions & 0 deletions projects/igniteui-angular/src/lib/date-common/picker-base.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
import { ElementRef, EventEmitter, Inject, LOCALE_ID, Optional, Input, Directive, Output } from '@angular/core';
import { DisplayDensityBase, DisplayDensityToken, IDisplayDensityOptions } from '../core/density';
import { EditorProvider } from '../core/edit-provider';
import { PickerInteractionMode } from './types';
import { IToggleView } from '../core/navigation';
import { IBaseCancelableBrowserEventArgs, IBaseEventArgs } from '../core/utils';
import { DateRange } from '../date-range-picker/public_api';
import { IgxOverlayOutletDirective } from '../directives/toggle/toggle.directive';
import { IgxInputGroupType, IGX_INPUT_GROUP_TYPE } from '../input-group/public_api';
import { OverlaySettings } from '../services/overlay/utilities';

@Directive()
export abstract class PickerBaseDirective extends DisplayDensityBase implements IToggleView, EditorProvider {
/**
* The editor's input mask.
*
* @remarks
* Also used as a placeholder when none is provided.
* Default is `"'MM/dd/yyyy'"`
*
* @example
* ```html
* <igx-date-picker inputFormat="dd/MM/yy"></igx-date-picker>
* ```
*/
@Input()
public inputFormat: string;

/**
* The format used to display the picker's value when it's not being edited.
*
* @remarks
* Uses Angular's DatePipe.
*
* @example
* ```html
* <igx-date-picker displayFormat="EE/M/yy"></igx-date-picker>
* ```
*
*/
@Input()
public displayFormat: string;

/**
* Sets the `placeholder` of the picker's input.
*
* @example
* ```html
* <igx-date-picker [placeholder]="'Choose your date'"></igx-date-picker>
* ```
*/
@Input()
public placeholder = '';

/**
* Can be `dropdown` with editable input field or `dialog` with readonly input field.
*
* @remarks
* Default mode is `dropdown`
*
* @example
* ```html
* <igx-date-picker mode="dialog"></igx-date-picker>
* ```
*/
@Input()
public mode: PickerInteractionMode = PickerInteractionMode.DropDown;

/**
* Overlay settings used to display the pop-up element.
*
* @example
* ```html
* <igx-date-picker [overlaySettings]="customOverlaySettings"></igx-date-picker>
* ```
*/
@Input()
public overlaySettings: OverlaySettings;

/**
* Enables or disables the picker.
*
* @example
* ```html
* <igx-date-picker [disabled]="'true'"></igx-date-picker>
* ```
*/
@Input()
public disabled = false;

/**
* Locale settings used for value formatting and calendar or time spinner.
*
* @remarks
* Uses Angular's `LOCALE_ID` by default. Affects both input mask and display format if those are not set.
* If a `locale` is set, it must be registered via `registerLocaleData`.
* Please refer to https://angular.io/guide/i18n#i18n-pipes.
* If it is not registered, `Intl` will be used for formatting.
*
* @example
* ```html
* <igx-date-picker locale="jp"></igx-date-picker>
* ```
*/
@Input()
public locale: string;

/**
* The container used for the pop-up element.
*
* @example
* ```html
* <div igxOverlayOutlet #outlet="overlay-outlet"></div>
* <!-- ... -->
* <igx-date-picker [outlet]="outlet"></igx-date-picker>
* <!-- ... -->
* ```
*/
@Input()
public outlet: IgxOverlayOutletDirective | ElementRef;

/**
* Determines how the picker's input will be styled.
*
* @remarks
* Default is `box`.
*
* @example
* ```html
* <igx-date-picker [type]="'line'"></igx-date-picker>
* ```
*/
@Input()
public set type(val: IgxInputGroupType) {
this._type = val;
}
public get type(): IgxInputGroupType {
return this._type || this._inputGroupType || 'box';
}

/**
* Gets/Sets the default template editor's tabindex.
*
* @example
* ```html
* <igx-date-picker [tabIndex]="1"></igx-date-picker>
* ```
*/
@Input()
public tabIndex: number | string;

/**
* Emitted when the calendar has started opening, cancelable.
*
* @example
* ```html
* <igx-date-picker (opening)="handleOpening($event)"></igx-date-picker>
* ```
*/
@Output()
public opening = new EventEmitter<IBaseCancelableBrowserEventArgs>();

/**
* Emitted after the calendar has opened.
*
* @example
* ```html
* <igx-date-picker (opened)="handleOpened($event)"></igx-date-picker>
* ```
*/
@Output()
public opened = new EventEmitter<IBaseEventArgs>();

/**
* Emitted when the calendar has started closing, cancelable.
*
* @example
* ```html
* <igx-date-picker (closing)="handleClosing($event)"></igx-date-picker>
* ```
*/
@Output()
public closing = new EventEmitter<IBaseCancelableBrowserEventArgs>();

/**
* Emitted after the calendar has closed.
*
* @example
* ```html
* <igx-date-picker (closed)="handleClosed($event)"></igx-date-picker>
* ```
*/
@Output()
public closed = new EventEmitter<IBaseEventArgs>();

protected _collapsed = true;
protected _type: IgxInputGroupType;
protected _minValue: Date | string;
protected _maxValue: Date | string;

/**
* Gets the picker's pop-up state.
*
* @example
* ```typescript
* const state = this.picker.collapsed;
* ```
*/
public get collapsed(): boolean {
return this._collapsed;
}

/** @hidden @internal */
public get isDropdown(): boolean {
return this.mode === PickerInteractionMode.DropDown;
}

public abstract valueChange: EventEmitter<string | Date | DateRange | null>;

constructor(public element: ElementRef,
@Inject(LOCALE_ID) protected _localeId: string,
@Optional() @Inject(DisplayDensityToken) protected _displayDensityOptions?: IDisplayDensityOptions,
@Optional() @Inject(IGX_INPUT_GROUP_TYPE) protected _inputGroupType?: IgxInputGroupType) {
super(_displayDensityOptions || { displayDensity: 'comfortable' });
this.locale = this.locale || this._localeId;
}

public abstract select(value: Date | DateRange): void;
public abstract open(settings?: OverlaySettings): void;
public abstract toggle(settings?: OverlaySettings): void;
public abstract close(): void;
public abstract getEditElement(): HTMLInputElement;
}
Loading