Skip to content

Commit 5f8fa98

Browse files
author
Andrew Seguin
committed
refactor: cleanup remaining signal primitive usages
1 parent 8b96a84 commit 5f8fa98

6 files changed

Lines changed: 16 additions & 13 deletions

File tree

src/aria/private/behaviors/grid/grid-navigation.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {computed} from '@angular/core';
10-
import {SignalLike} from '../signal-like/signal-like';
9+
import {SignalLike, computed} from '../signal-like/signal-like';
1110
import {GridFocus, GridFocusCell, GridFocusInputs} from './grid-focus';
1211
import {GridData, RowCol} from './grid-data';
1312

src/aria/private/behaviors/label/BUILD

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ ts_project(
88
"label.ts",
99
],
1010
deps = [
11-
"//:node_modules/@angular/core",
1211
"//src/aria/private/behaviors/signal-like",
1312
],
1413
)
@@ -21,7 +20,6 @@ ng_project(
2120
],
2221
deps = [
2322
":label",
24-
"//:node_modules/@angular/core",
2523
"//src/aria/private/behaviors/signal-like",
2624
],
2725
)

src/aria/private/behaviors/list-navigation/list-navigation.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {signal, WritableSignal} from '@angular/core';
9+
import {signal, WritableSignalLike} from '../signal-like/signal-like';
1010
import {ListNavigation, ListNavigationInputs, ListNavigationItem} from './list-navigation';
1111
import {getListFocus} from '../list-focus/list-focus.spec';
1212

1313
type TestItem = ListNavigationItem & {
14-
disabled: WritableSignal<boolean>;
14+
disabled: WritableSignalLike<boolean>;
1515
};
1616
type TestInputs = Partial<ListNavigationInputs<ListNavigationItem>> & {
1717
numItems?: number;

src/aria/private/behaviors/signal-like/signal-like.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,20 @@ export function computed<T>(computation: () => T): SignalLike<T> {
4343
const computed = createComputed(computation);
4444
// TODO: Remove the `toString` after https://github.com/angular/angular/pull/65948 is merged.
4545
computed.toString = () => `[Computed: ${computed()}]`;
46+
computed[SIGNAL].debugName = '';
4647
return computed;
4748
}
4849

4950
export function signal<T>(initialValue: T): WritableSignalLike<T> {
5051
const [get, set, update] = createSignal(initialValue);
52+
get[SIGNAL].debugName = '';
5153
// tslint:disable-next-line:ban Have to use `Object.assign` to preserve the getter function.
5254
return Object.assign(get, {set, update, asReadonly: () => get});
5355
}
5456

5557
export function linkedSignal<T>(sourceFn: () => T): WritableSignalLike<T> {
5658
const getter = createLinkedSignal(sourceFn, s => s);
59+
getter[SIGNAL].debugName = '';
5760
// tslint:disable-next-line:ban Have to use `Object.assign` to preserve the getter function.
5861
return Object.assign(getter, {
5962
set: (v: T) => linkedSignalSetFn(getter[SIGNAL], v),

src/aria/private/grid/cell.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {computed, signal, linkedSignal, WritableSignal} from '@angular/core';
109
import {KeyboardEventManager} from '../behaviors/event-manager';
1110
import {ListFocus} from '../behaviors/list-focus/list-focus';
1211
import {ListNavigation, ListNavigationInputs} from '../behaviors/list-navigation/list-navigation';
13-
import {SignalLike, WritableSignalLike} from '../behaviors/signal-like/signal-like';
12+
import {
13+
computed,
14+
signal,
15+
linkedSignal,
16+
SignalLike,
17+
WritableSignalLike,
18+
} from '../behaviors/signal-like/signal-like';
1419
import {GridCell} from '../behaviors/grid';
1520
import type {GridPattern} from './grid';
1621
import type {GridRowPattern} from './row';
1722
import {GridCellWidgetPattern} from './widget';
1823

1924
/** The inputs for the `GridCellPattern`. */
2025
export interface GridCellInputs
21-
extends
22-
GridCell,
26+
extends GridCell,
2327
Omit<
2428
ListNavigationInputs<GridCellWidgetPattern>,
2529
'focusMode' | 'items' | 'activeItem' | 'softDisabled' | 'element'
@@ -52,7 +56,7 @@ export class GridCellPattern implements GridCell {
5256
readonly element: SignalLike<HTMLElement> = () => this.inputs.element();
5357

5458
/** Whether the cell has focus. */
55-
readonly isFocused: WritableSignal<boolean> = signal(false);
59+
readonly isFocused: WritableSignalLike<boolean> = signal(false);
5660

5761
/** Whether the cell is selected. */
5862
readonly selected: WritableSignalLike<boolean>;

src/aria/private/listbox/option.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {computed} from '@angular/core';
10-
import {SignalLike} from '../behaviors/signal-like/signal-like';
9+
import {computed, SignalLike} from '../behaviors/signal-like/signal-like';
1110
import {List, ListInputs, ListItem} from '../behaviors/list/list';
1211

1312
/**

0 commit comments

Comments
 (0)