Skip to content

fix(cdk-experimental/ui-patterns): fix lint and build config #30877

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

Merged
merged 1 commit into from
Apr 16, 2025
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
2 changes: 2 additions & 0 deletions src/cdk-experimental/config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
CDK_EXPERIMENTAL_ENTRYPOINTS = [
"column-resize",
"combobox",
"deferred-content",
"listbox",
"popover-edit",
"scrolling",
"selection",
"tabs",
"table-scroll-container",
"ui-patterns",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import {
computed,
Directive,
effect,
inject,
Expand Down
12 changes: 5 additions & 7 deletions src/cdk-experimental/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {DeferredContent, DeferredContentAware} from '@angular/cdk-experimental/deferred-content';
import {_IdGenerator} from '@angular/cdk/a11y';
import {Directionality} from '@angular/cdk/bidi';
import {
booleanAttribute,
computed,
Expand All @@ -16,16 +19,11 @@ import {
ElementRef,
inject,
input,
signal,
model,
signal,
} from '@angular/core';
import {Directionality} from '@angular/cdk/bidi';
import {DeferredContent, DeferredContentAware} from '@angular/cdk-experimental/deferred-content';
import {TabPattern} from '@angular/cdk-experimental/ui-patterns/tabs/tab';
import {TabListPattern} from '@angular/cdk-experimental/ui-patterns/tabs/tablist';
import {TabPanelPattern} from '@angular/cdk-experimental/ui-patterns/tabs/tabpanel';
import {toSignal} from '@angular/core/rxjs-interop';
import {_IdGenerator} from '@angular/cdk/a11y';
import {TabListPattern, TabPanelPattern, TabPattern} from '../ui-patterns';

/**
* A Tabs container.
Expand Down
4 changes: 1 addition & 3 deletions src/cdk-experimental/ui-patterns/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@
export * from './listbox/listbox';
export * from './listbox/option';
export * from './behaviors/signal-like/signal-like';
export * from './tabs/tab';
export * from './tabs/tablist';
export * from './tabs/tabpanel';
export * from './tabs/tabs';
4 changes: 1 addition & 3 deletions src/cdk-experimental/ui-patterns/tabs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ package(default_visibility = ["//visibility:public"])
ts_project(
name = "tabs",
srcs = [
"tab.ts",
"tablist.ts",
"tabpanel.ts",
"tabs.ts",
],
deps = [
"//:node_modules/@angular/core",
Expand Down
60 changes: 0 additions & 60 deletions src/cdk-experimental/ui-patterns/tabs/tab.ts

This file was deleted.

39 changes: 0 additions & 39 deletions src/cdk-experimental/ui-patterns/tabs/tabpanel.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,68 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {computed, signal} from '@angular/core';

import {KeyboardEventManager} from '../behaviors/event-manager/keyboard-event-manager';
import {PointerEventManager} from '../behaviors/event-manager/pointer-event-manager';
import {TabPattern} from './tab';
import {ListSelection, ListSelectionInputs} from '../behaviors/list-selection/list-selection';
import {ListNavigation, ListNavigationInputs} from '../behaviors/list-navigation/list-navigation';
import {ListFocus, ListFocusInputs} from '../behaviors/list-focus/list-focus';
import {computed, signal} from '@angular/core';
import {ListFocus, ListFocusInputs, ListFocusItem} from '../behaviors/list-focus/list-focus';
import {
ListNavigation,
ListNavigationInputs,
ListNavigationItem,
} from '../behaviors/list-navigation/list-navigation';
import {
ListSelection,
ListSelectionInputs,
ListSelectionItem,
} from '../behaviors/list-selection/list-selection';
import {SignalLike} from '../behaviors/signal-like/signal-like';

/** The required inputs to tabs. */
export interface TabInputs extends ListNavigationItem, ListSelectionItem<string>, ListFocusItem {
tablist: SignalLike<TabListPattern>;
tabpanel: SignalLike<TabPanelPattern | undefined>;
}

/** A tab in a tablist. */
export class TabPattern {
/** A global unique identifier for the tab. */
id: SignalLike<string>;

/** A local unique identifier for the tab. */
value: SignalLike<string>;

/** Whether the tab is selected. */
selected = computed(() => this.tablist().selection.inputs.value().includes(this.value()));

/** A Tabpanel Id controlled by the tab. */
controls = computed(() => this.tabpanel()?.id());

/** Whether the tab is disabled. */
disabled: SignalLike<boolean>;

/** A reference to the parent tablist. */
tablist: SignalLike<TabListPattern>;

/** A reference to the corresponding tabpanel. */
tabpanel: SignalLike<TabPanelPattern | undefined>;

/** The tabindex of the tab. */
tabindex = computed(() => this.tablist().focusManager.getItemTabindex(this));

/** The html element that should receive focus. */
element: SignalLike<HTMLElement>;

constructor(inputs: TabInputs) {
this.id = inputs.id;
this.value = inputs.value;
this.tablist = inputs.tablist;
this.tabpanel = inputs.tabpanel;
this.element = inputs.element;
this.disabled = inputs.disabled;
}
}

/** The selection operations that the tablist can perform. */
interface SelectOptions {
select?: boolean;
Expand All @@ -30,6 +83,34 @@ export type TabListInputs = ListNavigationInputs<TabPattern> &
disabled: SignalLike<boolean>;
};

/** The required inputs for the tabpanel. */
export interface TabPanelInputs {
id: SignalLike<string>;
tab: SignalLike<TabPattern | undefined>;
value: SignalLike<string>;
}

/** A tabpanel associated with a tab. */
export class TabPanelPattern {
/** A global unique identifier for the tabpanel. */
id: SignalLike<string>;

/** A local unique identifier for the tabpanel. */
value: SignalLike<string>;

/** A reference to the corresponding tab. */
tab: SignalLike<TabPattern | undefined>;

/** Whether the tabpanel is hidden. */
hidden = computed(() => !this.tab()?.selected());

constructor(inputs: TabPanelInputs) {
this.id = inputs.id;
this.value = inputs.value;
this.tab = inputs.tab;
}
}

/** Controls the state of a tablist. */
export class TabListPattern {
/** Controls navigation for the tablist. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@

.example-tabpanel[inert] {
display: none;
}
}
Loading