Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions goldens/aria/accordion/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@

import * as _angular_cdk_bidi from '@angular/cdk/bidi';
import * as _angular_core from '@angular/core';
import { InjectionToken } from '@angular/core';
import { OnDestroy } from '@angular/core';
import { OnInit } from '@angular/core';
import { Signal } from '@angular/core';

// @public
export const ACCORDION_GROUP: InjectionToken<AccordionGroup>;

// @public
export class AccordionContent {
// (undocumented)
Expand Down
4 changes: 4 additions & 0 deletions goldens/aria/combobox/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ComboboxPattern } from '@angular/aria/private';
import { ComboboxPopupPattern } from '@angular/aria/private';
import { DeferredContentAware } from '@angular/aria/private';
import * as i1 from '@angular/aria/private';
import { InjectionToken } from '@angular/core';
import { OnDestroy } from '@angular/core';
import { OnInit } from '@angular/core';

Expand Down Expand Up @@ -36,6 +37,9 @@ export class Combobox extends DeferredContentAware implements OnInit {
static ɵfac: _angular_core.ɵɵFactoryDeclaration<Combobox, never>;
}

// @public
export const COMBOBOX_POPUP: InjectionToken<ComboboxPopup>;

// @public
export class ComboboxPopup implements OnInit, OnDestroy {
readonly activeDescendant: _angular_core.Signal<string | undefined>;
Expand Down
10 changes: 10 additions & 0 deletions goldens/aria/grid/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
import * as _angular_cdk_bidi from '@angular/cdk/bidi';
import * as _angular_core from '@angular/core';
import { ElementRef } from '@angular/core';
import { InjectionToken } from '@angular/core';
import { OnDestroy } from '@angular/core';
import { OnInit } from '@angular/core';
import { Signal } from '@angular/core';

// @public
export const GRID: InjectionToken<Grid>;

// @public
export class Grid implements OnDestroy {
constructor();
Expand All @@ -37,6 +41,12 @@ export class Grid implements OnDestroy {
static ɵfac: _angular_core.ɵɵFactoryDeclaration<Grid, never>;
}

// @public
export const GRID_CELL: InjectionToken<GridCell>;

// @public
export const GRID_ROW: InjectionToken<GridRow>;

// @public
export class GridCell implements OnInit, OnDestroy {
constructor();
Expand Down
4 changes: 4 additions & 0 deletions goldens/aria/listbox/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@

import * as _angular_cdk_bidi from '@angular/cdk/bidi';
import * as _angular_core from '@angular/core';
import { InjectionToken } from '@angular/core';
import { OnDestroy } from '@angular/core';
import { OnInit } from '@angular/core';
import { Signal } from '@angular/core';

// @public (undocumented)
export const LISTBOX: InjectionToken<Listbox<any>>;

// @public
export class Listbox<V> implements OnDestroy {
constructor();
Expand Down
4 changes: 4 additions & 0 deletions goldens/aria/menu/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import * as _angular_cdk_bidi from '@angular/cdk/bidi';
import * as _angular_core from '@angular/core';
import { InjectionToken } from '@angular/core';
import { OnDestroy } from '@angular/core';
import { OnInit } from '@angular/core';
import { Signal } from '@angular/core';
Expand Down Expand Up @@ -37,6 +38,9 @@ export class Menu<V> implements OnDestroy {
static ɵfac: _angular_core.ɵɵFactoryDeclaration<Menu<any>, never>;
}

// @public
export const MENU_COMPONENT: InjectionToken<Menu<any> | MenuBar<any>>;

// @public
export class MenuBar<V> implements OnDestroy {
constructor();
Expand Down
7 changes: 7 additions & 0 deletions goldens/aria/tabs/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import * as _angular_cdk_bidi from '@angular/cdk/bidi';
import * as _angular_core from '@angular/core';
import { InjectionToken } from '@angular/core';
import { OnDestroy } from '@angular/core';
import { OnInit } from '@angular/core';
import { Signal } from '@angular/core';
Expand All @@ -32,6 +33,9 @@ export class Tab implements HasElement, OnInit, OnDestroy {
static ɵfac: _angular_core.ɵɵFactoryDeclaration<Tab, never>;
}

// @public
export const TAB_LIST: InjectionToken<TabList>;

// @public
export class TabContent {
// (undocumented)
Expand Down Expand Up @@ -87,6 +91,9 @@ export class TabPanel implements OnInit, OnDestroy {
static ɵfac: _angular_core.ɵɵFactoryDeclaration<TabPanel, never>;
}

// @public
export const TABS: InjectionToken<Tabs>;

// @public
export class Tabs implements OnDestroy {
constructor();
Expand Down
4 changes: 4 additions & 0 deletions goldens/aria/toolbar/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import * as _angular_cdk_bidi from '@angular/cdk/bidi';
import * as _angular_core from '@angular/core';
import { InjectionToken } from '@angular/core';
import { OnDestroy } from '@angular/core';
import { OnInit } from '@angular/core';
import { Signal } from '@angular/core';
Expand All @@ -31,6 +32,9 @@ export class Toolbar<V> implements OnDestroy {
static ɵfac: _angular_core.ɵɵFactoryDeclaration<Toolbar<any>, never>;
}

// @public
export const TOOLBAR_WIDGET_GROUP: InjectionToken<ToolbarWidgetGroup<unknown>>;

// @public
export class ToolbarWidget<V> implements OnInit, OnDestroy {
readonly active: _angular_core.Signal<boolean>;
Expand Down
1 change: 1 addition & 0 deletions src/aria/accordion/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export {AccordionPanel} from './accordion-panel';
export {AccordionGroup} from './accordion-group';
export {AccordionTrigger} from './accordion-trigger';
export {AccordionContent} from './accordion-content';
export {ACCORDION_GROUP} from './accordion-tokens';

// This needs to be re-exported, because it's used by the accordion components.
// See: https://github.com/angular/components/issues/30663.
Expand Down
1 change: 1 addition & 0 deletions src/aria/combobox/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
export {Combobox} from './combobox';
export {ComboboxPopup} from './combobox-popup';
export {ComboboxWidget} from './combobox-widget';
export {COMBOBOX_POPUP} from './combobox-tokens';

// This needs to be re-exported, because it's used by the combobox components.
// See: https://github.com/angular/components/issues/30663.
Expand Down
46 changes: 46 additions & 0 deletions src/aria/grid/grid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Grid} from './grid';
import {GridRow} from './grid-row';
import {GridCell} from './grid-cell';
import {GridCellWidget} from './grid-cell-widget';
import {GRID_ROW, GRID_CELL} from './grid-tokens';
import {waitForMicrotasks} from '../private/testing/test-helpers';

interface ModifierKeys {
Expand Down Expand Up @@ -1174,6 +1175,23 @@ describe('Grid directives', () => {
expect(consoleSpy).toHaveBeenCalledWith('ngGridRow must contain at least one ngGridCell.');
});
});

describe('subclassing and custom providers', () => {
it('should support subclassing GridRow and GridCell using exported injection tokens', async () => {
TestBed.resetTestingModule();
TestBed.configureTestingModule({
imports: [SubclassGridTestComponent],
});
const subclassFixture = TestBed.createComponent(SubclassGridTestComponent);
subclassFixture.detectChanges();
await subclassFixture.whenStable();

const cells = subclassFixture.debugElement.queryAll(By.directive(MyCustomCell));
expect(cells.length).toBe(2);
expect(cells[0].nativeElement.getAttribute('role')).toBe('gridcell');
expect(cells[1].nativeElement.getAttribute('role')).toBe('gridcell');
});
});
});

@Component({
Expand Down Expand Up @@ -1261,3 +1279,31 @@ class GridTestComponent {
changeDetection: ChangeDetectionStrategy.Eager,
})
class GridRowWithoutCells {}

@Component({
selector: 'my-custom-cell',
template: `<ng-content></ng-content>`,
providers: [{provide: GRID_CELL, useExisting: MyCustomCell}],
})
class MyCustomCell extends GridCell {}

@Component({
selector: 'my-custom-row',
template: `<ng-content></ng-content>`,
providers: [{provide: GRID_ROW, useExisting: MyCustomRow}],
})
class MyCustomRow extends GridRow {}

@Component({
template: `
<table ngGrid>
<my-custom-row>
<my-custom-cell>Cell 1</my-custom-cell>
<my-custom-cell>Cell 2</my-custom-cell>
</my-custom-row>
</table>
`,
imports: [Grid, MyCustomRow, MyCustomCell],
changeDetection: ChangeDetectionStrategy.Eager,
})
class SubclassGridTestComponent {}
1 change: 1 addition & 0 deletions src/aria/grid/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export {Grid} from './grid';
export {GridCell} from './grid-cell';
export {GridRow} from './grid-row';
export {GridCellWidget} from './grid-cell-widget';
export {GRID, GRID_ROW, GRID_CELL} from './grid-tokens';
1 change: 1 addition & 0 deletions src/aria/listbox/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@

export {Listbox} from './listbox';
export {Option} from './option';
export {LISTBOX} from './tokens';
1 change: 1 addition & 0 deletions src/aria/menu/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export {Menu} from './menu';
export {MenuBar} from './menu-bar';
export {MenuItem} from './menu-item';
export {MenuContent} from './menu-content';
export {MENU_COMPONENT} from './menu-tokens';

// This needs to be re-exported, because it's used by the menu components.
// See: https://github.com/angular/components/issues/30663.
Expand Down
1 change: 1 addition & 0 deletions src/aria/tabs/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export {TabList} from './tab-list';
export {Tab} from './tab';
export {TabPanel} from './tab-panel';
export {TabContent} from './tab-content';
export {TABS, TAB_LIST} from './tab-tokens';

// This needs to be re-exported, because it's used by the tab components.
// See: https://github.com/angular/components/issues/30663.
Expand Down
1 change: 1 addition & 0 deletions src/aria/toolbar/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
export {Toolbar} from './toolbar';
export {ToolbarWidget} from './toolbar-widget';
export {ToolbarWidgetGroup} from './toolbar-widget-group';
export {TOOLBAR_WIDGET_GROUP} from './toolbar-tokens';
Loading