Skip to content

Commit 07bf55f

Browse files
Merge branch 'master' into ganastasov/fix-skills-date-range-picker
2 parents dd3dc3f + c2c1b8b commit 07bf55f

23 files changed

Lines changed: 1316 additions & 180 deletions

File tree

package-lock.json

Lines changed: 166 additions & 162 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/igniteui-angular-elements/src/app/custom-strategy.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
8282
// set componentRef to non-null to prevent DOM moves from re-initializing
8383
// TODO: Fail handling or cancellation needed?
8484
(this as any).componentRef = {};
85+
const contentChildrenTags = Array.from(element.children).filter(x => this._componentFactory.ngContentSelectors.some(sel => x.matches(sel))).map(x => x.tagName.toLocaleLowerCase());
8586

8687
// const toBeOrphanedChildren = Array.from(element.children).filter(x => !this._componentFactory.ngContentSelectors.some(sel => x.matches(sel)));
8788
// for (const iterator of toBeOrphanedChildren) {
@@ -166,6 +167,15 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
166167
// TODO(D.P.): Temporary maintain pre-check for ngAfterViewInit handling on _init flag w/ ngDoCheck interaction of row island
167168
(this as any).componentRef.changeDetectorRef.detectChanges();
168169

170+
// check if there are any content children associated with a content query collection.
171+
// if no, then just emit the event, otherwise we wait for the collection to be updated in updateQuery.
172+
const contentChildrenTypes = this.config.filter(x => contentChildrenTags.indexOf(x.selector) !== -1).map(x => x.provideAs ?? x.component);
173+
const contentQueryChildrenCollection = componentConfig.contentQueries.filter(x => contentChildrenTypes.includes(x.childType));
174+
if (contentQueryChildrenCollection.length === 0) {
175+
// no content children, emit event immediately, since there's nothing to be attached.
176+
(this as any).componentRef?.instance?.childrenResolved?.emit();
177+
}
178+
169179
if (parentAnchor && parentInjector) {
170180
// attempt to attach the newly created ViewRef to the parents's instead of the App global
171181
const parentViewRef = parentInjector.get<ViewContainerRef>(ViewContainerRef);
@@ -331,6 +341,10 @@ class IgxCustomNgElementStrategy extends ComponentNgElementStrategy {
331341
list.reset(childRefs);
332342
list.notifyOnChanges();
333343
}
344+
if (this.schedule.size === 0) {
345+
// children are attached and collections are updated, emit event.
346+
(this as any).componentRef?.instance?.childrenResolved?.emit();
347+
}
334348
}
335349

336350
private runQueryInDOM(element: HTMLElement, query: ContentQueryMeta): IgcNgElement[] {

projects/igniteui-angular-elements/src/index.html

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ <h3 class="ig-typography__h6">Flat Grid (MRL column layout)</h3>
143143

144144
grid1.data = northwindProducts;
145145
grid2.data = northwindProducts;
146+
grid1.addEventListener('childrenResolved', () => {
147+
console.log("Ready!");
148+
restoreState();
149+
});
146150
const categories = Array.from(new Set(northwindProducts.map(x => x.CategoryName)));
147151

148152
let groupingExpression1 = [];
@@ -289,6 +293,41 @@ <h3 class="ig-typography__h6">Flat Grid (MRL column layout)</h3>
289293
</igc-action-strip>
290294
</igc-tree-grid>
291295

296+
<igc-hierarchical-grid id="hgrid1" primary-key="ProjectId" moving="true" allow-filtering="true" filter-mode="excelStyleFilter" display-density="compact">
297+
<igc-grid-state id="state2"></igc-grid-state>
298+
<igc-column field="ProjectId" data-type="number" header="Project Id" sortable="true" selectable="false"></igc-column>
299+
<igc-column field="Name" data-type="string" header="Name" sortable="true" selectable="false"></igc-column>
300+
<igc-column field="StartDate" data-type="date" header="Start Date" sortable="true" selectable="false"></igc-column>
301+
<igc-column field="EndDate" data-type="date" header="End Date" sortable="true" selectable="false"></igc-column>
302+
<igc-column field="IsPostponed" data-type="boolean" header="Postponed" sortable="true" selectable="false"></igc-column>
303+
304+
<igc-row-island id="DevelopersRowIsland" key="Developers">
305+
<igc-column field="Name" header="Name" sortable="true"></igc-column>
306+
<igc-column-group header="Position Information">
307+
<igc-column-group header="Position Details" collapsible>
308+
<igc-column field="Position" header="Position" sortable="true" visible-when-collapsed></igc-column>
309+
<igc-column field="Salary" header="Salary" sortable="true" visible-when-collapsed="false"></igc-column>
310+
</igc-column-group>
311+
<igc-column field="HireDate" header="HireDate" data-type="date" sortable="true"></igc-column>
312+
</igc-column-group>
313+
<igc-action-strip>
314+
<igc-grid-pinning-actions></igc-grid-pinning-actions>
315+
<igc-grid-editing-actions add-row="true"></igc-grid-editing-actions>
316+
</igc-action-strip>
317+
<igc-row-island auto-generate id="VirtualMachinesRowIsland" key="VirtualMachines"></igc-row-island>
318+
</igc-row-island>
319+
<igc-paginator per-page="10"></igc-paginator>
320+
<igc-action-strip>
321+
<igc-grid-pinning-actions></igc-grid-pinning-actions>
322+
<igc-grid-editing-actions add-row="true"></igc-grid-editing-actions>
323+
</igc-action-strip>
324+
<igc-grid-state id="hgridState"></igc-grid-state>
325+
</igc-hierarchical-grid>
326+
<div class="hgrid1-actions">
327+
<button id="saveStateHierarchical">Save state</button>
328+
<button id="restoreStateHierarchical">Restore</button>
329+
</div>
330+
292331
<script src="assets/data/tree-grid-ds.js"></script>
293332
<script>
294333
treegrid1.data = treeGridDS;
@@ -444,9 +483,27 @@ <h3 class="ig-typography__h6">Flat Grid (MRL column layout)</h3>
444483
import { html } from "/lit-html.js";
445484
// jump around vite import analysis with dynamic import url
446485
const hgridData = (await import(`/assets/${'data'}/projects-hgrid.js`)).default;
486+
function saveStateHierarchical() {
487+
const stateComponent = document.getElementById('hgridState');
488+
const stringData = stateComponent.getStateAsString();
489+
window.localStorage.setItem(`hgrid1-state`, stringData);
490+
}
491+
492+
function restoreStateHierarchical() {
493+
const stateComponent = document.getElementById('hgridState');
494+
const stateData = window.localStorage.getItem(`hgrid1-state`);
495+
if (stateData) {
496+
const obj = JSON.parse(stateData);
497+
stateComponent.applyState(obj);
498+
}
499+
}
447500
let hgrid = document.getElementById('hgrid1');
501+
hgrid.addEventListener('childrenResolved', () => {
502+
restoreStateHierarchical();
503+
});
448504
hgrid.data = hgridData;
449-
505+
document.getElementById("saveStateHierarchical").addEventListener("click", saveStateHierarchical);
506+
document.getElementById("restoreStateHierarchical").addEventListener("click", restoreStateHierarchical);
450507
let developersRowIsland = document.getElementById('DevelopersRowIsland');
451508
let virtualMachinesRowIsland = document.getElementById('VirtualMachinesRowIsland');
452509
virtualMachinesRowIsland.paginatorTemplate = (ctx) => html`

projects/igniteui-angular/calendar/src/calendar/month-picker/month-picker.component.spec.ts

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,183 @@ describe('IgxMonthPicker', () => {
552552
currentValue: new Date(2019, 1, 1)
553553
});
554554
});
555+
556+
it('should return the correct next and previous years via getNextYear/getPreviousYear', () => {
557+
const fixture = TestBed.createComponent(IgxMonthPickerSampleComponent);
558+
fixture.detectChanges();
559+
const monthPicker = fixture.componentInstance.monthPicker;
560+
// viewDate is 2019
561+
expect(monthPicker.getNextYear()).toBe(2020);
562+
expect(monthPicker.getPreviousYear()).toBe(2018);
563+
});
564+
565+
it('should navigate forward one year via PageDown in default (year) view', () => {
566+
const fixture = TestBed.createComponent(IgxMonthPickerSampleComponent);
567+
fixture.detectChanges();
568+
const monthPicker = fixture.componentInstance.monthPicker;
569+
const wrapper = fixture.debugElement.query(By.css('.igx-calendar__wrapper'));
570+
wrapper.nativeElement.focus();
571+
fixture.detectChanges();
572+
573+
const initialYear = monthPicker.viewDate.getFullYear();
574+
UIInteractions.triggerKeyDownEvtUponElem('PageDown', document.activeElement);
575+
fixture.detectChanges();
576+
577+
expect(monthPicker.viewDate.getFullYear()).toBe(initialYear + 1);
578+
});
579+
580+
it('should navigate backward one year via PageUp in default (year) view', () => {
581+
const fixture = TestBed.createComponent(IgxMonthPickerSampleComponent);
582+
fixture.detectChanges();
583+
const monthPicker = fixture.componentInstance.monthPicker;
584+
const wrapper = fixture.debugElement.query(By.css('.igx-calendar__wrapper'));
585+
wrapper.nativeElement.focus();
586+
fixture.detectChanges();
587+
588+
const initialYear = monthPicker.viewDate.getFullYear();
589+
UIInteractions.triggerKeyDownEvtUponElem('PageUp', document.activeElement);
590+
fixture.detectChanges();
591+
592+
expect(monthPicker.viewDate.getFullYear()).toBe(initialYear - 1);
593+
});
594+
595+
it('should navigate forward one year via PageDown in default (year) view', () => {
596+
const fixture = TestBed.createComponent(IgxMonthPickerSampleComponent);
597+
fixture.detectChanges();
598+
const monthPicker = fixture.componentInstance.monthPicker;
599+
const wrapper = fixture.debugElement.query(By.css('.igx-calendar__wrapper'));
600+
wrapper.nativeElement.focus();
601+
fixture.detectChanges();
602+
603+
const initialYear = monthPicker.viewDate.getFullYear();
604+
UIInteractions.triggerKeyDownEvtUponElem('PageDown', document.activeElement);
605+
fixture.detectChanges();
606+
607+
expect(monthPicker.viewDate.getFullYear()).toBe(initialYear + 1);
608+
});
609+
610+
it('should navigate backward one page via PageUp in decade (years) view', () => {
611+
const fixture = TestBed.createComponent(IgxMonthPickerSampleComponent);
612+
fixture.detectChanges();
613+
const monthPicker = fixture.componentInstance.monthPicker;
614+
// Switch to decade view
615+
monthPicker.activeView = IgxCalendarView.Decade;
616+
fixture.detectChanges();
617+
618+
const wrapper = fixture.debugElement.query(By.css('.igx-calendar__wrapper'));
619+
wrapper.nativeElement.focus();
620+
fixture.detectChanges();
621+
622+
const initialYear = monthPicker.viewDate.getFullYear();
623+
UIInteractions.triggerKeyDownEvtUponElem('PageUp', document.activeElement);
624+
fixture.detectChanges();
625+
626+
// In decade view, PageUp calls previousPage which moves back 15 years
627+
expect(monthPicker.viewDate.getFullYear()).toBe(initialYear - 15);
628+
});
629+
630+
it('should navigate forward one page via PageDown in decade (years) view', () => {
631+
const fixture = TestBed.createComponent(IgxMonthPickerSampleComponent);
632+
fixture.detectChanges();
633+
const monthPicker = fixture.componentInstance.monthPicker;
634+
monthPicker.activeView = IgxCalendarView.Decade;
635+
fixture.detectChanges();
636+
637+
const wrapper = fixture.debugElement.query(By.css('.igx-calendar__wrapper'));
638+
wrapper.nativeElement.focus();
639+
fixture.detectChanges();
640+
641+
const initialYear = monthPicker.viewDate.getFullYear();
642+
UIInteractions.triggerKeyDownEvtUponElem('PageDown', document.activeElement);
643+
fixture.detectChanges();
644+
645+
// In decade view, PageDown calls nextPage which moves forward 15 years
646+
expect(monthPicker.viewDate.getFullYear()).toBe(initialYear + 15);
647+
});
648+
649+
it('should navigate to January via Home key in default (year) view', () => {
650+
const fixture = TestBed.createComponent(IgxMonthPickerSampleComponent);
651+
fixture.detectChanges();
652+
const wrapper = fixture.debugElement.query(By.css('.igx-calendar__wrapper'));
653+
wrapper.nativeElement.focus();
654+
fixture.detectChanges();
655+
656+
UIInteractions.triggerKeyDownEvtUponElem('Home', document.activeElement);
657+
fixture.detectChanges();
658+
659+
const dom = fixture.debugElement;
660+
const selected = dom.query(By.css('.igx-calendar-view__item--selected'));
661+
expect(selected.nativeElement.textContent.trim()).toMatch('Jan');
662+
});
663+
664+
it('should navigate to December via End key in default (year) view', () => {
665+
const fixture = TestBed.createComponent(IgxMonthPickerSampleComponent);
666+
fixture.detectChanges();
667+
const wrapper = fixture.debugElement.query(By.css('.igx-calendar__wrapper'));
668+
wrapper.nativeElement.focus();
669+
fixture.detectChanges();
670+
671+
UIInteractions.triggerKeyDownEvtUponElem('End', document.activeElement);
672+
fixture.detectChanges();
673+
674+
const dom = fixture.debugElement;
675+
const selected = dom.query(By.css('.igx-calendar-view__item--selected'));
676+
expect(selected.nativeElement.textContent.trim()).toMatch('Dec');
677+
});
678+
679+
it('should navigate to first year in view via Home key in decade (years) view', () => {
680+
const fixture = TestBed.createComponent(IgxMonthPickerSampleComponent);
681+
fixture.detectChanges();
682+
const monthPicker = fixture.componentInstance.monthPicker;
683+
monthPicker.activeView = IgxCalendarView.Decade;
684+
fixture.detectChanges();
685+
686+
const wrapper = fixture.debugElement.query(By.css('.igx-calendar__wrapper'));
687+
wrapper.nativeElement.focus();
688+
fixture.detectChanges();
689+
690+
UIInteractions.triggerKeyDownEvtUponElem('Home', document.activeElement);
691+
fixture.detectChanges();
692+
693+
const dom = fixture.debugElement;
694+
const years = dom.queryAll(By.css('.igx-calendar-view__item'));
695+
const selected = dom.query(By.css('.igx-calendar-view__item--selected'));
696+
expect(selected.nativeElement).toBe(years[0].nativeElement);
697+
});
698+
699+
it('should navigate to last year in view via End key in decade (years) view', () => {
700+
const fixture = TestBed.createComponent(IgxMonthPickerSampleComponent);
701+
fixture.detectChanges();
702+
const monthPicker = fixture.componentInstance.monthPicker;
703+
monthPicker.activeView = IgxCalendarView.Decade;
704+
fixture.detectChanges();
705+
706+
const wrapper = fixture.debugElement.query(By.css('.igx-calendar__wrapper'));
707+
wrapper.nativeElement.focus();
708+
fixture.detectChanges();
709+
710+
UIInteractions.triggerKeyDownEvtUponElem('End', document.activeElement);
711+
fixture.detectChanges();
712+
713+
const dom = fixture.debugElement;
714+
const years = dom.queryAll(By.css('.igx-calendar-view__item'));
715+
const selected = dom.query(By.css('.igx-calendar-view__item--selected'));
716+
expect(selected.nativeElement).toBe(years[years.length - 1].nativeElement);
717+
});
718+
719+
it('should change the active view to decade via activeViewDecade and focus the years view', () => {
720+
const fixture = TestBed.createComponent(IgxMonthPickerSampleComponent);
721+
fixture.detectChanges();
722+
const monthPicker = fixture.componentInstance.monthPicker;
723+
724+
expect(monthPicker.activeView).toBe(IgxCalendarView.Year);
725+
726+
const yearBtn = fixture.debugElement.query(By.css('.igx-calendar-picker__date'));
727+
UIInteractions.simulateMouseDownEvent(yearBtn.nativeElement);
728+
fixture.detectChanges();
729+
730+
expect(monthPicker.activeView).toBe(IgxCalendarView.Decade);
731+
});
555732
});
556733

557734
@Component({

projects/igniteui-angular/core/src/core/styles/components/grid/_grid-theme.scss

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@
306306
%filtering-row-input-overrides {
307307
igx-input-group {
308308
width: 100%;
309-
max-width: rem(200px);
309+
max-width: rem(240px);
310310
min-width: rem(140px);
311311

312312
@if $variant != 'fluent' {
@@ -2482,6 +2482,16 @@
24822482
margin: rem(4px);
24832483
}
24842484
}
2485+
2486+
.igx-grid__filtering-row-percent-hint {
2487+
display: inline-block;
2488+
max-width: rem(56px);
2489+
overflow: hidden;
2490+
text-overflow: ellipsis;
2491+
white-space: nowrap;
2492+
vertical-align: middle;
2493+
flex-shrink: 1;
2494+
}
24852495
}
24862496

24872497
%igx-grid__filtering-dropdown-items {

0 commit comments

Comments
 (0)