Skip to content

Commit ae8f9dd

Browse files
authored
fix(cdk-experimental/ui-patterns): fix lint and build config (#30877)
1 parent a5aade2 commit ae8f9dd

File tree

9 files changed

+96
-119
lines changed

9 files changed

+96
-119
lines changed

src/cdk-experimental/config.bzl

+2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
CDK_EXPERIMENTAL_ENTRYPOINTS = [
33
"column-resize",
44
"combobox",
5+
"deferred-content",
56
"listbox",
67
"popover-edit",
78
"scrolling",
89
"selection",
10+
"tabs",
911
"table-scroll-container",
1012
"ui-patterns",
1113
]

src/cdk-experimental/deferred-content/deferred-content.ts

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import {
10-
computed,
1110
Directive,
1211
effect,
1312
inject,

src/cdk-experimental/tabs/tabs.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9+
import {DeferredContent, DeferredContentAware} from '@angular/cdk-experimental/deferred-content';
10+
import {_IdGenerator} from '@angular/cdk/a11y';
11+
import {Directionality} from '@angular/cdk/bidi';
912
import {
1013
booleanAttribute,
1114
computed,
@@ -16,16 +19,11 @@ import {
1619
ElementRef,
1720
inject,
1821
input,
19-
signal,
2022
model,
23+
signal,
2124
} from '@angular/core';
22-
import {Directionality} from '@angular/cdk/bidi';
23-
import {DeferredContent, DeferredContentAware} from '@angular/cdk-experimental/deferred-content';
24-
import {TabPattern} from '@angular/cdk-experimental/ui-patterns/tabs/tab';
25-
import {TabListPattern} from '@angular/cdk-experimental/ui-patterns/tabs/tablist';
26-
import {TabPanelPattern} from '@angular/cdk-experimental/ui-patterns/tabs/tabpanel';
2725
import {toSignal} from '@angular/core/rxjs-interop';
28-
import {_IdGenerator} from '@angular/cdk/a11y';
26+
import {TabListPattern, TabPanelPattern, TabPattern} from '../ui-patterns';
2927

3028
/**
3129
* A Tabs container.

src/cdk-experimental/ui-patterns/public-api.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@
99
export * from './listbox/listbox';
1010
export * from './listbox/option';
1111
export * from './behaviors/signal-like/signal-like';
12-
export * from './tabs/tab';
13-
export * from './tabs/tablist';
14-
export * from './tabs/tabpanel';
12+
export * from './tabs/tabs';

src/cdk-experimental/ui-patterns/tabs/BUILD.bazel

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ package(default_visibility = ["//visibility:public"])
55
ts_project(
66
name = "tabs",
77
srcs = [
8-
"tab.ts",
9-
"tablist.ts",
10-
"tabpanel.ts",
8+
"tabs.ts",
119
],
1210
deps = [
1311
"//:node_modules/@angular/core",

src/cdk-experimental/ui-patterns/tabs/tab.ts

-60
This file was deleted.

src/cdk-experimental/ui-patterns/tabs/tabpanel.ts

-39
This file was deleted.

src/cdk-experimental/ui-patterns/tabs/tablist.ts renamed to src/cdk-experimental/ui-patterns/tabs/tabs.ts

+86-5
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,68 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9+
import {computed, signal} from '@angular/core';
10+
911
import {KeyboardEventManager} from '../behaviors/event-manager/keyboard-event-manager';
1012
import {PointerEventManager} from '../behaviors/event-manager/pointer-event-manager';
11-
import {TabPattern} from './tab';
12-
import {ListSelection, ListSelectionInputs} from '../behaviors/list-selection/list-selection';
13-
import {ListNavigation, ListNavigationInputs} from '../behaviors/list-navigation/list-navigation';
14-
import {ListFocus, ListFocusInputs} from '../behaviors/list-focus/list-focus';
15-
import {computed, signal} from '@angular/core';
13+
import {ListFocus, ListFocusInputs, ListFocusItem} from '../behaviors/list-focus/list-focus';
14+
import {
15+
ListNavigation,
16+
ListNavigationInputs,
17+
ListNavigationItem,
18+
} from '../behaviors/list-navigation/list-navigation';
19+
import {
20+
ListSelection,
21+
ListSelectionInputs,
22+
ListSelectionItem,
23+
} from '../behaviors/list-selection/list-selection';
1624
import {SignalLike} from '../behaviors/signal-like/signal-like';
1725

26+
/** The required inputs to tabs. */
27+
export interface TabInputs extends ListNavigationItem, ListSelectionItem<string>, ListFocusItem {
28+
tablist: SignalLike<TabListPattern>;
29+
tabpanel: SignalLike<TabPanelPattern | undefined>;
30+
}
31+
32+
/** A tab in a tablist. */
33+
export class TabPattern {
34+
/** A global unique identifier for the tab. */
35+
id: SignalLike<string>;
36+
37+
/** A local unique identifier for the tab. */
38+
value: SignalLike<string>;
39+
40+
/** Whether the tab is selected. */
41+
selected = computed(() => this.tablist().selection.inputs.value().includes(this.value()));
42+
43+
/** A Tabpanel Id controlled by the tab. */
44+
controls = computed(() => this.tabpanel()?.id());
45+
46+
/** Whether the tab is disabled. */
47+
disabled: SignalLike<boolean>;
48+
49+
/** A reference to the parent tablist. */
50+
tablist: SignalLike<TabListPattern>;
51+
52+
/** A reference to the corresponding tabpanel. */
53+
tabpanel: SignalLike<TabPanelPattern | undefined>;
54+
55+
/** The tabindex of the tab. */
56+
tabindex = computed(() => this.tablist().focusManager.getItemTabindex(this));
57+
58+
/** The html element that should receive focus. */
59+
element: SignalLike<HTMLElement>;
60+
61+
constructor(inputs: TabInputs) {
62+
this.id = inputs.id;
63+
this.value = inputs.value;
64+
this.tablist = inputs.tablist;
65+
this.tabpanel = inputs.tabpanel;
66+
this.element = inputs.element;
67+
this.disabled = inputs.disabled;
68+
}
69+
}
70+
1871
/** The selection operations that the tablist can perform. */
1972
interface SelectOptions {
2073
select?: boolean;
@@ -30,6 +83,34 @@ export type TabListInputs = ListNavigationInputs<TabPattern> &
3083
disabled: SignalLike<boolean>;
3184
};
3285

86+
/** The required inputs for the tabpanel. */
87+
export interface TabPanelInputs {
88+
id: SignalLike<string>;
89+
tab: SignalLike<TabPattern | undefined>;
90+
value: SignalLike<string>;
91+
}
92+
93+
/** A tabpanel associated with a tab. */
94+
export class TabPanelPattern {
95+
/** A global unique identifier for the tabpanel. */
96+
id: SignalLike<string>;
97+
98+
/** A local unique identifier for the tabpanel. */
99+
value: SignalLike<string>;
100+
101+
/** A reference to the corresponding tab. */
102+
tab: SignalLike<TabPattern | undefined>;
103+
104+
/** Whether the tabpanel is hidden. */
105+
hidden = computed(() => !this.tab()?.selected());
106+
107+
constructor(inputs: TabPanelInputs) {
108+
this.id = inputs.id;
109+
this.value = inputs.value;
110+
this.tab = inputs.tab;
111+
}
112+
}
113+
33114
/** Controls the state of a tablist. */
34115
export class TabListPattern {
35116
/** Controls navigation for the tablist. */

src/components-examples/cdk-experimental/tabs/cdk-tabs/cdk-tabs-example.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@
7373

7474
.example-tabpanel[inert] {
7575
display: none;
76-
}
76+
}

0 commit comments

Comments
 (0)