Skip to content

Commit c65a8dd

Browse files
committed
refactor(multiple): add utils to aria/private and consolidate sortDirectives usage
1 parent 8d5a896 commit c65a8dd

File tree

16 files changed

+22
-39
lines changed

16 files changed

+22
-39
lines changed

src/aria/private/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ ts_project(
2020
"//src/aria/private/tabs",
2121
"//src/aria/private/toolbar",
2222
"//src/aria/private/tree",
23+
"//src/aria/private/utils",
2324
],
2425
)

src/aria/private/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ export * from './grid/row';
2525
export * from './grid/cell';
2626
export * from './grid/widget';
2727
export * from './deferred-content';
28+
export * from './utils/element';

src/aria/private/utils/BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
load("//tools:defaults.bzl", "ts_project")
2+
3+
package(default_visibility = ["//visibility:public"])
4+
5+
ts_project(
6+
name = "utils",
7+
srcs = ["element.ts"],
8+
)

src/aria/tabs/tab-list.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import {
2020
OnInit,
2121
OnDestroy,
2222
} from '@angular/core';
23-
import {TabListPattern, TabPattern} from '../private';
24-
import {sortDirectives, TABS} from './utils';
23+
import {TabListPattern, TabPattern, sortDirectives} from '../private';
24+
import {TABS} from './tab-tokens';
2525
import type {Tab} from './tab';
2626

2727
/**

src/aria/tabs/tab-panel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
OnDestroy,
1919
} from '@angular/core';
2020
import {TabPanelPattern, DeferredContentAware} from '../private';
21-
import {TABS} from './utils';
21+
import {TABS} from './tab-tokens';
2222

2323
/**
2424
* A TabPanel container for the resources of layered content associated with a tab.
Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,3 @@ import type {Tabs} from './tabs';
1111

1212
/** Token used to expose the `Tabs` directive to child directives. */
1313
export const TABS = new InjectionToken<Tabs>('TABS');
14-
15-
export interface HasElement {
16-
element: HTMLElement;
17-
}
18-
19-
/**
20-
* Sort directives by their document order.
21-
*/
22-
export function sortDirectives(a: HasElement, b: HasElement) {
23-
return (a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_PRECEDING) > 0
24-
? 1
25-
: -1;
26-
}

src/aria/tabs/tab.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import {
1818
OnInit,
1919
OnDestroy,
2020
} from '@angular/core';
21-
import {TabPattern} from '../private';
21+
import {TabPattern, HasElement} from '../private';
2222
import {TabList} from './tab-list';
23-
import {HasElement, TABS} from './utils';
23+
import {TABS} from './tab-tokens';
2424

2525
/**
2626
* A selectable tab in a TabList.

src/aria/tabs/tabs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import {computed, Directive, ElementRef, inject, signal} from '@angular/core';
1010
import {TabList} from './tab-list';
1111
import {TabPanel} from './tab-panel';
12-
import {TABS} from './utils';
12+
import {TABS} from './tab-tokens';
1313
import {TabPanelPattern, TabPattern} from '../private';
1414

1515
/**
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,3 @@ import type {ToolbarWidgetGroup} from './toolbar-widget-group';
1313
export const TOOLBAR_WIDGET_GROUP = new InjectionToken<ToolbarWidgetGroup<unknown>>(
1414
'TOOLBAR_WIDGET_GROUP',
1515
);
16-
17-
interface HasElement {
18-
element: HTMLElement;
19-
}
20-
21-
export function sortDirectives(a: HasElement, b: HasElement) {
22-
return (a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_PRECEDING) > 0
23-
? 1
24-
: -1;
25-
}

0 commit comments

Comments
 (0)