Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 1 addition & 2 deletions src/aria/private/behaviors/grid/grid-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

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

Expand Down
2 changes: 0 additions & 2 deletions src/aria/private/behaviors/label/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ ts_project(
"label.ts",
],
deps = [
"//:node_modules/@angular/core",
"//src/aria/private/behaviors/signal-like",
],
)
Expand All @@ -21,7 +20,6 @@ ng_project(
],
deps = [
":label",
"//:node_modules/@angular/core",
"//src/aria/private/behaviors/signal-like",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* found in the LICENSE file at https://angular.dev/license
*/

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

type TestItem = ListNavigationItem & {
disabled: WritableSignal<boolean>;
disabled: WritableSignalLike<boolean>;
};
type TestInputs = Partial<ListNavigationInputs<ListNavigationItem>> & {
numItems?: number;
Expand Down
3 changes: 3 additions & 0 deletions src/aria/private/behaviors/signal-like/signal-like.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,20 @@ export function computed<T>(computation: () => T): SignalLike<T> {
const computed = createComputed(computation);
// TODO: Remove the `toString` after https://github.com/angular/angular/pull/65948 is merged.
computed.toString = () => `[Computed: ${computed()}]`;
computed[SIGNAL].debugName = '';
return computed;
}

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

export function linkedSignal<T>(sourceFn: () => T): WritableSignalLike<T> {
const getter = createLinkedSignal(sourceFn, s => s);
getter[SIGNAL].debugName = '';
// tslint:disable-next-line:ban Have to use `Object.assign` to preserve the getter function.
return Object.assign(getter, {
set: (v: T) => linkedSignalSetFn(getter[SIGNAL], v),
Expand Down
14 changes: 9 additions & 5 deletions src/aria/private/grid/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {computed, signal, linkedSignal, WritableSignal} from '@angular/core';
import {KeyboardEventManager} from '../behaviors/event-manager';
import {ListFocus} from '../behaviors/list-focus/list-focus';
import {ListNavigation, ListNavigationInputs} from '../behaviors/list-navigation/list-navigation';
import {SignalLike, WritableSignalLike} from '../behaviors/signal-like/signal-like';
import {
computed,
signal,
linkedSignal,
SignalLike,
WritableSignalLike,
} from '../behaviors/signal-like/signal-like';
import {GridCell} from '../behaviors/grid';
import type {GridPattern} from './grid';
import type {GridRowPattern} from './row';
import {GridCellWidgetPattern} from './widget';

/** The inputs for the `GridCellPattern`. */
export interface GridCellInputs
extends
GridCell,
extends GridCell,
Omit<
ListNavigationInputs<GridCellWidgetPattern>,
'focusMode' | 'items' | 'activeItem' | 'softDisabled' | 'element'
Expand Down Expand Up @@ -52,7 +56,7 @@ export class GridCellPattern implements GridCell {
readonly element: SignalLike<HTMLElement> = () => this.inputs.element();

/** Whether the cell has focus. */
readonly isFocused: WritableSignal<boolean> = signal(false);
readonly isFocused: WritableSignalLike<boolean> = signal(false);

/** Whether the cell is selected. */
readonly selected: WritableSignalLike<boolean>;
Expand Down
3 changes: 1 addition & 2 deletions src/aria/private/listbox/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

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

/**
Expand Down
Loading