@angular/aria 21.0.3 → 21.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/_accordion-chunk.mjs +108 -0
- package/fesm2022/_accordion-chunk.mjs.map +1 -0
- package/fesm2022/_combobox-chunk.mjs +2 -2
- package/fesm2022/_combobox-chunk.mjs.map +1 -1
- package/fesm2022/_combobox-listbox-chunk.mjs +4 -286
- package/fesm2022/_combobox-listbox-chunk.mjs.map +1 -1
- package/fesm2022/_combobox-tree-chunk.mjs +331 -0
- package/fesm2022/_combobox-tree-chunk.mjs.map +1 -0
- package/fesm2022/_deferred-content-chunk.mjs +124 -0
- package/fesm2022/_deferred-content-chunk.mjs.map +1 -0
- package/fesm2022/_expansion-chunk.mjs +41 -0
- package/fesm2022/_expansion-chunk.mjs.map +1 -0
- package/fesm2022/_list-chunk.mjs +287 -0
- package/fesm2022/_list-chunk.mjs.map +1 -0
- package/fesm2022/_list-navigation-chunk.mjs +1 -1
- package/fesm2022/_list-navigation-chunk.mjs.map +1 -1
- package/fesm2022/_menu-chunk.mjs +515 -0
- package/fesm2022/_menu-chunk.mjs.map +1 -0
- package/fesm2022/_pointer-event-manager-chunk.mjs +2 -82
- package/fesm2022/_pointer-event-manager-chunk.mjs.map +1 -1
- package/fesm2022/_signal-like-chunk.mjs +118 -0
- package/fesm2022/_signal-like-chunk.mjs.map +1 -0
- package/fesm2022/_tabs-chunk.mjs +159 -0
- package/fesm2022/_tabs-chunk.mjs.map +1 -0
- package/fesm2022/_toolbar-widget-group-chunk.mjs +148 -0
- package/fesm2022/_toolbar-widget-group-chunk.mjs.map +1 -0
- package/fesm2022/_widget-chunk.mjs +3 -2
- package/fesm2022/_widget-chunk.mjs.map +1 -1
- package/fesm2022/accordion.mjs +57 -52
- package/fesm2022/accordion.mjs.map +1 -1
- package/fesm2022/aria.mjs +1 -1
- package/fesm2022/aria.mjs.map +1 -1
- package/fesm2022/combobox.mjs +77 -40
- package/fesm2022/combobox.mjs.map +1 -1
- package/fesm2022/grid.mjs +70 -68
- package/fesm2022/grid.mjs.map +1 -1
- package/fesm2022/listbox.mjs +49 -47
- package/fesm2022/listbox.mjs.map +1 -1
- package/fesm2022/menu.mjs +69 -65
- package/fesm2022/menu.mjs.map +1 -1
- package/fesm2022/private.mjs +13 -1402
- package/fesm2022/private.mjs.map +1 -1
- package/fesm2022/tabs.mjs +49 -41
- package/fesm2022/tabs.mjs.map +1 -1
- package/fesm2022/toolbar.mjs +49 -45
- package/fesm2022/toolbar.mjs.map +1 -1
- package/fesm2022/tree.mjs +52 -44
- package/fesm2022/tree.mjs.map +1 -1
- package/package.json +2 -2
- package/types/_accordion-chunk.d.ts +100 -0
- package/types/_combobox-chunk.d.ts +187 -91
- package/types/_deferred-content-chunk.d.ts +42 -0
- package/types/_expansion-chunk.d.ts +40 -0
- package/types/_grid-chunk.d.ts +41 -41
- package/types/_keyboard-event-manager-chunk.d.ts +68 -0
- package/types/_list-chunk.d.ts +8 -9
- package/types/_list-navigation-chunk.d.ts +8 -101
- package/types/_listbox-chunk.d.ts +17 -16
- package/types/_menu-chunk.d.ts +267 -0
- package/types/_pointer-event-manager-chunk.d.ts +34 -0
- package/types/_tabs-chunk.d.ts +153 -0
- package/types/_toolbar-chunk.d.ts +124 -0
- package/types/_tree-chunk.d.ts +185 -0
- package/types/accordion.d.ts +13 -5
- package/types/aria.d.ts +1 -1
- package/types/combobox.d.ts +122 -6
- package/types/grid.d.ts +10 -0
- package/types/listbox.d.ts +17 -5
- package/types/menu.d.ts +23 -5
- package/types/private.d.ts +25 -885
- package/types/tabs.d.ts +24 -8
- package/types/toolbar.d.ts +12 -4
- package/types/tree.d.ts +16 -5
- package/fesm2022/_combobox-popup-chunk.mjs +0 -46
- package/fesm2022/_combobox-popup-chunk.mjs.map +0 -1
- package/types/_combobox-chunk.d2.ts +0 -193
|
@@ -1,98 +1,194 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import { KeyboardEventManager } from './_keyboard-event-manager-chunk.js';
|
|
2
|
+
import { PointerEventManager } from './_pointer-event-manager-chunk.js';
|
|
3
|
+
import { SignalLike, WritableSignalLike } from './_list-navigation-chunk.js';
|
|
4
|
+
import { ListItem } from './_list-chunk.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readonly _controls: _angular_core.WritableSignal<ComboboxListboxControls<any, V> | ComboboxTreeControls<any, V> | ComboboxDialogPattern | undefined>;
|
|
21
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ComboboxPopup<any>, never>;
|
|
22
|
-
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<ComboboxPopup<any>, "[ngComboboxPopup]", ["ngComboboxPopup"], {}, {}, never, never, true, never>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* The container element that wraps a combobox input and popup, and orchestrates its behavior.
|
|
27
|
-
*
|
|
28
|
-
* The `ngCombobox` directive is the main entry point for creating a combobox and customizing its
|
|
29
|
-
* behavior. It coordinates the interactions between the `ngComboboxInput` and the popup, which
|
|
30
|
-
* is defined by a `ng-template` with the `ngComboboxPopupContainer` directive. If using the
|
|
31
|
-
* `CdkOverlay`, the `cdkConnectedOverlay` directive takes the place of `ngComboboxPopupContainer`.
|
|
32
|
-
*
|
|
33
|
-
* ```html
|
|
34
|
-
* <div ngCombobox filterMode="highlight">
|
|
35
|
-
* <input
|
|
36
|
-
* ngComboboxInput
|
|
37
|
-
* placeholder="Search for a state..."
|
|
38
|
-
* [(value)]="searchString"
|
|
39
|
-
* />
|
|
40
|
-
*
|
|
41
|
-
* <ng-template ngComboboxPopupContainer>
|
|
42
|
-
* <div ngListbox [(value)]="selectedValue">
|
|
43
|
-
* @for (option of filteredOptions(); track option) {
|
|
44
|
-
* <div ngOption [value]="option" [label]="option">
|
|
45
|
-
* <span>{{option}}</span>
|
|
46
|
-
* </div>
|
|
47
|
-
* }
|
|
48
|
-
* </div>
|
|
49
|
-
* </ng-template>
|
|
50
|
-
* </div>
|
|
51
|
-
* ```
|
|
52
|
-
*
|
|
53
|
-
* @developerPreview 21.0
|
|
54
|
-
*/
|
|
55
|
-
declare class Combobox<V> {
|
|
56
|
-
/** The directionality (LTR / RTL) context for the application (or a subtree of it). */
|
|
57
|
-
private readonly _directionality;
|
|
58
|
-
/** A signal wrapper for directionality. */
|
|
59
|
-
protected textDirection: _angular_core.Signal<_angular_cdk_bidi.Direction>;
|
|
60
|
-
/** The element that the combobox is attached to. */
|
|
61
|
-
private readonly _elementRef;
|
|
62
|
-
/** A reference to the combobox element. */
|
|
63
|
-
readonly element: HTMLElement;
|
|
64
|
-
/** The DeferredContentAware host directive. */
|
|
65
|
-
private readonly _deferredContentAware;
|
|
66
|
-
/** The combobox popup. */
|
|
67
|
-
readonly popup: _angular_core.Signal<ComboboxPopup<V> | undefined>;
|
|
68
|
-
/**
|
|
69
|
-
* The filter mode for the combobox.
|
|
70
|
-
* - `manual`: The consumer is responsible for filtering the options.
|
|
71
|
-
* - `auto-select`: The combobox automatically selects the first matching option.
|
|
72
|
-
* - `highlight`: The combobox highlights matching text in the options without changing selection.
|
|
73
|
-
*/
|
|
74
|
-
filterMode: _angular_core.InputSignal<"manual" | "auto-select" | "highlight">;
|
|
6
|
+
/** Represents the required inputs for a combobox. */
|
|
7
|
+
interface ComboboxInputs<T extends ListItem<V>, V> {
|
|
8
|
+
/** The controls for the popup associated with the combobox. */
|
|
9
|
+
popupControls: SignalLike<ComboboxListboxControls<T, V> | ComboboxTreeControls<T, V> | ComboboxDialogPattern | undefined>;
|
|
10
|
+
/** The HTML input element that serves as the combobox input. */
|
|
11
|
+
inputEl: SignalLike<HTMLInputElement | undefined>;
|
|
12
|
+
/** The HTML element that serves as the combobox container. */
|
|
13
|
+
containerEl: SignalLike<HTMLElement | undefined>;
|
|
14
|
+
/** The filtering mode for the combobox. */
|
|
15
|
+
filterMode: SignalLike<'manual' | 'auto-select' | 'highlight'>;
|
|
16
|
+
/** The current value of the combobox. */
|
|
17
|
+
inputValue?: WritableSignalLike<string>;
|
|
18
|
+
/** The value of the first matching item in the popup. */
|
|
19
|
+
firstMatch: SignalLike<V | undefined>;
|
|
75
20
|
/** Whether the combobox is disabled. */
|
|
76
|
-
|
|
21
|
+
disabled: SignalLike<boolean>;
|
|
77
22
|
/** Whether the combobox is read-only. */
|
|
78
|
-
readonly
|
|
79
|
-
/**
|
|
80
|
-
|
|
23
|
+
readonly: SignalLike<boolean>;
|
|
24
|
+
/** Whether the combobox is in a right-to-left context. */
|
|
25
|
+
textDirection: SignalLike<'rtl' | 'ltr'>;
|
|
26
|
+
/** Whether the combobox is always expanded. */
|
|
27
|
+
alwaysExpanded: SignalLike<boolean>;
|
|
28
|
+
}
|
|
29
|
+
/** An interface that allows combobox popups to expose the necessary controls for the combobox. */
|
|
30
|
+
interface ComboboxListboxControls<T extends ListItem<V>, V> {
|
|
31
|
+
/** A unique identifier for the popup. */
|
|
32
|
+
id: () => string;
|
|
33
|
+
/** The ARIA role for the popup. */
|
|
34
|
+
role: SignalLike<'listbox' | 'tree' | 'grid'>;
|
|
35
|
+
/** Whether multiple items in the popup can be selected at once. */
|
|
36
|
+
multi: SignalLike<boolean>;
|
|
37
|
+
/** The ID of the active item in the popup. */
|
|
38
|
+
activeId: SignalLike<string | undefined>;
|
|
39
|
+
/** The list of items in the popup. */
|
|
40
|
+
items: SignalLike<T[]>;
|
|
41
|
+
/** Navigates to the given item in the popup. */
|
|
42
|
+
focus: (item: T, opts?: {
|
|
43
|
+
focusElement?: boolean;
|
|
44
|
+
}) => void;
|
|
45
|
+
/** Navigates to the next item in the popup. */
|
|
46
|
+
next: () => void;
|
|
47
|
+
/** Navigates to the previous item in the popup. */
|
|
48
|
+
prev: () => void;
|
|
49
|
+
/** Navigates to the first item in the popup. */
|
|
50
|
+
first: () => void;
|
|
51
|
+
/** Navigates to the last item in the popup. */
|
|
52
|
+
last: () => void;
|
|
53
|
+
/** Selects the current item in the popup. */
|
|
54
|
+
select: (item?: T) => void;
|
|
55
|
+
/** Toggles the selection state of the given item in the popup. */
|
|
56
|
+
toggle: (item?: T) => void;
|
|
57
|
+
/** Clears the selection state of the popup. */
|
|
58
|
+
clearSelection: () => void;
|
|
59
|
+
/** Removes focus from any item in the popup. */
|
|
60
|
+
unfocus: () => void;
|
|
61
|
+
/** Returns the item corresponding to the given event. */
|
|
62
|
+
getItem: (e: PointerEvent) => T | undefined;
|
|
63
|
+
/** Returns the currently active (focused) item in the popup. */
|
|
64
|
+
getActiveItem: () => T | undefined;
|
|
65
|
+
/** Returns the currently selected items in the popup. */
|
|
66
|
+
getSelectedItems: () => T[];
|
|
67
|
+
/** Sets the value of the combobox based on the selected item. */
|
|
68
|
+
setValue: (value: V | undefined) => void;
|
|
69
|
+
}
|
|
70
|
+
interface ComboboxTreeControls<T extends ListItem<V>, V> extends ComboboxListboxControls<T, V> {
|
|
71
|
+
/** Whether the currently active item in the popup is collapsible. */
|
|
72
|
+
isItemCollapsible: () => boolean;
|
|
73
|
+
/** Expands the currently active item in the popup. */
|
|
74
|
+
expandItem: () => void;
|
|
75
|
+
/** Collapses the currently active item in the popup. */
|
|
76
|
+
collapseItem: () => void;
|
|
77
|
+
/** Checks if the currently active item in the popup is expandable. */
|
|
78
|
+
isItemExpandable: (item?: T) => boolean;
|
|
79
|
+
/** Expands all nodes in the tree. */
|
|
80
|
+
expandAll: () => void;
|
|
81
|
+
/** Collapses all nodes in the tree. */
|
|
82
|
+
collapseAll: () => void;
|
|
83
|
+
/** Toggles the expansion state of the currently active item in the popup. */
|
|
84
|
+
toggleExpansion: (item?: T) => void;
|
|
85
|
+
/** Whether the current active item is selectable. */
|
|
86
|
+
isItemSelectable: (item?: T) => boolean;
|
|
87
|
+
}
|
|
88
|
+
/** Controls the state of a combobox. */
|
|
89
|
+
declare class ComboboxPattern<T extends ListItem<V>, V> {
|
|
90
|
+
readonly inputs: ComboboxInputs<T, V>;
|
|
81
91
|
/** Whether the combobox is expanded. */
|
|
82
|
-
|
|
83
|
-
/** Whether the combobox
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
/** The
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
expanded: WritableSignalLike<boolean>;
|
|
93
|
+
/** Whether the combobox is disabled. */
|
|
94
|
+
disabled: () => boolean;
|
|
95
|
+
/** The ID of the active item in the combobox. */
|
|
96
|
+
activeDescendant: SignalLike<string | null>;
|
|
97
|
+
/** The currently highlighted item in the combobox. */
|
|
98
|
+
highlightedItem: WritableSignalLike<T | undefined>;
|
|
99
|
+
/** Whether the most recent input event was a deletion. */
|
|
100
|
+
isDeleting: boolean;
|
|
101
|
+
/** Whether the combobox is focused. */
|
|
102
|
+
isFocused: WritableSignalLike<boolean>;
|
|
103
|
+
/** Whether the combobox has ever been focused. */
|
|
104
|
+
hasBeenFocused: WritableSignalLike<boolean>;
|
|
105
|
+
/** The key used to navigate to the previous item in the list. */
|
|
106
|
+
expandKey: SignalLike<"ArrowLeft" | "ArrowRight">;
|
|
107
|
+
/** The key used to navigate to the next item in the list. */
|
|
108
|
+
collapseKey: SignalLike<"ArrowLeft" | "ArrowRight">;
|
|
109
|
+
/** The ID of the popup associated with the combobox. */
|
|
110
|
+
popupId: SignalLike<string | null>;
|
|
111
|
+
/** The autocomplete behavior of the combobox. */
|
|
112
|
+
autocomplete: SignalLike<"both" | "list">;
|
|
113
|
+
/** The ARIA role of the popup associated with the combobox. */
|
|
114
|
+
hasPopup: SignalLike<"listbox" | "tree" | "grid" | "dialog" | null>;
|
|
115
|
+
/** Whether the combobox is read-only. */
|
|
116
|
+
readonly: SignalLike<true | null>;
|
|
117
|
+
/** Returns the listbox controls for the combobox. */
|
|
118
|
+
listControls: () => ComboboxListboxControls<T, V> | null | undefined;
|
|
119
|
+
/** Returns the tree controls for the combobox. */
|
|
120
|
+
treeControls: () => ComboboxTreeControls<T, V> | null;
|
|
121
|
+
/** The keydown event manager for the combobox. */
|
|
122
|
+
keydown: SignalLike<KeyboardEventManager<KeyboardEvent>>;
|
|
123
|
+
/** The click event manager for the combobox. */
|
|
124
|
+
click: SignalLike<PointerEventManager<PointerEvent>>;
|
|
125
|
+
constructor(inputs: ComboboxInputs<T, V>);
|
|
126
|
+
/** Handles keydown events for the combobox. */
|
|
127
|
+
onKeydown(event: KeyboardEvent): void;
|
|
128
|
+
/** Handles click events for the combobox. */
|
|
129
|
+
onClick(event: MouseEvent): void;
|
|
130
|
+
/** Handles input events for the combobox. */
|
|
131
|
+
onInput(event: Event): void;
|
|
132
|
+
/** Handles focus in events for the combobox. */
|
|
133
|
+
onFocusIn(): void;
|
|
134
|
+
/** Handles focus out events for the combobox. */
|
|
135
|
+
onFocusOut(event: FocusEvent): void;
|
|
136
|
+
/** The first matching item in the combobox. */
|
|
137
|
+
firstMatch: SignalLike<T | undefined>;
|
|
138
|
+
/** Handles filtering logic for the combobox. */
|
|
139
|
+
onFilter(): void;
|
|
140
|
+
/** Highlights the currently selected item in the combobox. */
|
|
141
|
+
highlight(): void;
|
|
92
142
|
/** Closes the combobox. */
|
|
93
|
-
close(
|
|
94
|
-
|
|
95
|
-
|
|
143
|
+
close(opts?: {
|
|
144
|
+
reset: boolean;
|
|
145
|
+
}): void;
|
|
146
|
+
/** Opens the combobox. */
|
|
147
|
+
open(nav?: {
|
|
148
|
+
first?: boolean;
|
|
149
|
+
last?: boolean;
|
|
150
|
+
selected?: boolean;
|
|
151
|
+
}): void;
|
|
152
|
+
/** Navigates to the next focusable item in the combobox popup. */
|
|
153
|
+
next(): void;
|
|
154
|
+
/** Navigates to the previous focusable item in the combobox popup. */
|
|
155
|
+
prev(): void;
|
|
156
|
+
/** Navigates to the first focusable item in the combobox popup. */
|
|
157
|
+
first(): void;
|
|
158
|
+
/** Navigates to the last focusable item in the combobox popup. */
|
|
159
|
+
last(): void;
|
|
160
|
+
/** Collapses the currently focused item in the combobox. */
|
|
161
|
+
collapseItem(): void;
|
|
162
|
+
/** Expands the currently focused item in the combobox. */
|
|
163
|
+
expandItem(): void;
|
|
164
|
+
/** Selects an item in the combobox popup. */
|
|
165
|
+
select(opts?: {
|
|
166
|
+
item?: T;
|
|
167
|
+
commit?: boolean;
|
|
168
|
+
close?: boolean;
|
|
169
|
+
}): void;
|
|
170
|
+
/** Updates the value of the input based on the currently selected item. */
|
|
171
|
+
commit(): void;
|
|
172
|
+
/** Navigates and handles additional actions based on filter mode. */
|
|
173
|
+
private _navigate;
|
|
174
|
+
}
|
|
175
|
+
declare class ComboboxDialogPattern {
|
|
176
|
+
readonly inputs: {
|
|
177
|
+
combobox: ComboboxPattern<any, any>;
|
|
178
|
+
element: SignalLike<HTMLDialogElement>;
|
|
179
|
+
id: SignalLike<string>;
|
|
180
|
+
};
|
|
181
|
+
id: () => string;
|
|
182
|
+
role: () => "dialog";
|
|
183
|
+
keydown: SignalLike<KeyboardEventManager<KeyboardEvent>>;
|
|
184
|
+
constructor(inputs: {
|
|
185
|
+
combobox: ComboboxPattern<any, any>;
|
|
186
|
+
element: SignalLike<HTMLDialogElement>;
|
|
187
|
+
id: SignalLike<string>;
|
|
188
|
+
});
|
|
189
|
+
onKeydown(event: KeyboardEvent): void;
|
|
190
|
+
onClick(event: MouseEvent): void;
|
|
96
191
|
}
|
|
97
192
|
|
|
98
|
-
export {
|
|
193
|
+
export { ComboboxDialogPattern, ComboboxPattern };
|
|
194
|
+
export type { ComboboxInputs, ComboboxListboxControls, ComboboxTreeControls };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { OnDestroy } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A container directive controls the visibility of its content.
|
|
6
|
+
*/
|
|
7
|
+
declare class DeferredContentAware {
|
|
8
|
+
readonly contentVisible: _angular_core.WritableSignal<boolean>;
|
|
9
|
+
readonly preserveContent: _angular_core.ModelSignal<boolean>;
|
|
10
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<DeferredContentAware, never>;
|
|
11
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<DeferredContentAware, never, never, { "preserveContent": { "alias": "preserveContent"; "required": false; "isSignal": true; }; }, { "preserveContent": "preserveContentChange"; }, never, never, true, never>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* DeferredContent loads/unloads the content based on the visibility.
|
|
15
|
+
* The visibilty signal is sent from a parent directive implements
|
|
16
|
+
* DeferredContentAware.
|
|
17
|
+
*
|
|
18
|
+
* Use this directive as a host directive. For example:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* @Directive({
|
|
22
|
+
* selector: 'ng-template[AccordionContent]',
|
|
23
|
+
* hostDirectives: [DeferredContent],
|
|
24
|
+
* })
|
|
25
|
+
* class AccordionContent {}
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
declare class DeferredContent implements OnDestroy {
|
|
29
|
+
private readonly _deferredContentAware;
|
|
30
|
+
private readonly _templateRef;
|
|
31
|
+
private readonly _viewContainerRef;
|
|
32
|
+
private _currentViewRef;
|
|
33
|
+
private _isRendered;
|
|
34
|
+
readonly deferredContentAware: _angular_core.WritableSignal<DeferredContentAware | null>;
|
|
35
|
+
constructor();
|
|
36
|
+
ngOnDestroy(): void;
|
|
37
|
+
private _destroyContent;
|
|
38
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<DeferredContent, never>;
|
|
39
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<DeferredContent, never, never, {}, {}, never, never, true, never>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { DeferredContent, DeferredContentAware };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SignalLike, WritableSignalLike } from './_list-navigation-chunk.js';
|
|
2
|
+
|
|
3
|
+
/** Represents an item that can be expanded or collapsed. */
|
|
4
|
+
interface ExpansionItem {
|
|
5
|
+
/** Whether the item is expandable. */
|
|
6
|
+
expandable: SignalLike<boolean>;
|
|
7
|
+
/** Whether the item is expanded. */
|
|
8
|
+
expanded: WritableSignalLike<boolean>;
|
|
9
|
+
/** Whether the expansion is disabled. */
|
|
10
|
+
disabled: SignalLike<boolean>;
|
|
11
|
+
}
|
|
12
|
+
/** Represents the required inputs for an expansion behavior. */
|
|
13
|
+
interface ListExpansionInputs {
|
|
14
|
+
/** Whether multiple items can be expanded at once. */
|
|
15
|
+
multiExpandable: SignalLike<boolean>;
|
|
16
|
+
/** An array of expansion items. */
|
|
17
|
+
items: SignalLike<ExpansionItem[]>;
|
|
18
|
+
/** Whether all expansions are disabled. */
|
|
19
|
+
disabled: SignalLike<boolean>;
|
|
20
|
+
}
|
|
21
|
+
/** Manages the expansion state of a list of items. */
|
|
22
|
+
declare class ListExpansion {
|
|
23
|
+
readonly inputs: ListExpansionInputs;
|
|
24
|
+
constructor(inputs: ListExpansionInputs);
|
|
25
|
+
/** Opens the specified item. */
|
|
26
|
+
open(item: ExpansionItem): boolean;
|
|
27
|
+
/** Closes the specified item. */
|
|
28
|
+
close(item: ExpansionItem): boolean;
|
|
29
|
+
/** Toggles the expansion state of the specified item. */
|
|
30
|
+
toggle(item: ExpansionItem): boolean;
|
|
31
|
+
/** Opens all focusable items in the list. */
|
|
32
|
+
openAll(): void;
|
|
33
|
+
/** Closes all focusable items in the list. */
|
|
34
|
+
closeAll(): void;
|
|
35
|
+
/** Checks whether the specified item is expandable / collapsible. */
|
|
36
|
+
isExpandable(item: ExpansionItem): boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { ListExpansion };
|
|
40
|
+
export type { ExpansionItem, ListExpansionInputs };
|
package/types/_grid-chunk.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { SignalLike, WritableSignalLike, ListNavigationItem, ListNavigationInputs, ListFocus, ListNavigation } from './_list-navigation-chunk.js';
|
|
2
|
+
import { KeyboardEventManager } from './_keyboard-event-manager-chunk.js';
|
|
3
|
+
import { PointerEventManager } from './_pointer-event-manager-chunk.js';
|
|
4
4
|
|
|
5
5
|
/** Represents coordinates in a grid. */
|
|
6
6
|
interface RowCol {
|
|
@@ -27,9 +27,9 @@ declare class GridData<T extends BaseGridCell> {
|
|
|
27
27
|
/** The two-dimensional array of cells that represents the grid. */
|
|
28
28
|
readonly cells: SignalLike<T[][]>;
|
|
29
29
|
/** The maximum number of rows in the grid, accounting for row spans. */
|
|
30
|
-
readonly maxRowCount:
|
|
30
|
+
readonly maxRowCount: SignalLike<number>;
|
|
31
31
|
/** The maximum number of columns in the grid, accounting for column spans. */
|
|
32
|
-
readonly maxColCount:
|
|
32
|
+
readonly maxColCount: SignalLike<number>;
|
|
33
33
|
/** A map from a cell to its primary and spanned coordinates. */
|
|
34
34
|
private readonly _coordsMap;
|
|
35
35
|
/** A map from a coordinate string to the cell at that coordinate. */
|
|
@@ -80,11 +80,11 @@ interface GridFocusDeps<T extends GridFocusCell> {
|
|
|
80
80
|
declare class GridFocus<T extends GridFocusCell> {
|
|
81
81
|
readonly inputs: GridFocusInputs & GridFocusDeps<T>;
|
|
82
82
|
/** The current active cell. */
|
|
83
|
-
readonly activeCell:
|
|
83
|
+
readonly activeCell: WritableSignalLike<T | undefined>;
|
|
84
84
|
/** The current active cell coordinates. */
|
|
85
|
-
readonly activeCoords:
|
|
85
|
+
readonly activeCoords: WritableSignalLike<RowCol>;
|
|
86
86
|
/** Whether the grid active state is empty (no active cell or coordinates). */
|
|
87
|
-
readonly stateEmpty:
|
|
87
|
+
readonly stateEmpty: SignalLike<boolean>;
|
|
88
88
|
/**
|
|
89
89
|
* Whether the grid focus state is stale.
|
|
90
90
|
*
|
|
@@ -92,13 +92,13 @@ declare class GridFocus<T extends GridFocusCell> {
|
|
|
92
92
|
* current grid data, for example if the underlying cells have changed.
|
|
93
93
|
* A stale state should be re-initialized.
|
|
94
94
|
*/
|
|
95
|
-
readonly stateStale:
|
|
95
|
+
readonly stateStale: SignalLike<boolean>;
|
|
96
96
|
/** The id of the current active cell, for ARIA activedescendant. */
|
|
97
|
-
readonly activeDescendant:
|
|
97
|
+
readonly activeDescendant: SignalLike<string | undefined>;
|
|
98
98
|
/** Whether the grid is in a disabled state. */
|
|
99
|
-
readonly gridDisabled:
|
|
99
|
+
readonly gridDisabled: SignalLike<boolean>;
|
|
100
100
|
/** The tab index for the grid container. */
|
|
101
|
-
readonly gridTabIndex:
|
|
101
|
+
readonly gridTabIndex: SignalLike<0 | -1>;
|
|
102
102
|
constructor(inputs: GridFocusInputs & GridFocusDeps<T>);
|
|
103
103
|
/** Returns the tab index for the given grid cell cell. */
|
|
104
104
|
getCellTabIndex(cell: T): -1 | 0;
|
|
@@ -263,11 +263,11 @@ declare class Grid<T extends GridCell> {
|
|
|
263
263
|
/** Controls selection for the grid. */
|
|
264
264
|
readonly selectionBehavior: GridSelection<T>;
|
|
265
265
|
/** The anchor point for range selection, linked to the active coordinates. */
|
|
266
|
-
readonly selectionAnchor:
|
|
266
|
+
readonly selectionAnchor: WritableSignalLike<RowCol>;
|
|
267
267
|
/** The cell at the selection anchor. */
|
|
268
|
-
readonly selectionAnchorCell:
|
|
268
|
+
readonly selectionAnchorCell: SignalLike<T | undefined>;
|
|
269
269
|
/** Whether a range selection has settled. */
|
|
270
|
-
readonly selectionStabled:
|
|
270
|
+
readonly selectionStabled: WritableSignalLike<boolean>;
|
|
271
271
|
/** Whether all selectable cells are selected. */
|
|
272
272
|
readonly allSelected: SignalLike<boolean>;
|
|
273
273
|
/** The tab index for the grid container. */
|
|
@@ -353,23 +353,23 @@ declare class GridCellWidgetPattern implements ListNavigationItem {
|
|
|
353
353
|
/** The html element that should receive focus. */
|
|
354
354
|
readonly element: SignalLike<HTMLElement>;
|
|
355
355
|
/** The element that should receive focus. */
|
|
356
|
-
readonly widgetHost:
|
|
356
|
+
readonly widgetHost: SignalLike<HTMLElement>;
|
|
357
357
|
/** The index of the widget within the cell. */
|
|
358
|
-
readonly index:
|
|
358
|
+
readonly index: SignalLike<number>;
|
|
359
359
|
/** Whether the widget is disabled. */
|
|
360
|
-
readonly disabled:
|
|
360
|
+
readonly disabled: SignalLike<boolean>;
|
|
361
361
|
/** The tab index for the widget. */
|
|
362
|
-
readonly tabIndex:
|
|
362
|
+
readonly tabIndex: SignalLike<-1 | 0>;
|
|
363
363
|
/** Whether the widget is the active item in the widget list. */
|
|
364
|
-
readonly active:
|
|
364
|
+
readonly active: SignalLike<boolean>;
|
|
365
365
|
/** Whether the widget is currently activated. */
|
|
366
|
-
readonly isActivated:
|
|
366
|
+
readonly isActivated: WritableSignalLike<boolean>;
|
|
367
367
|
/** The last event that caused the widget to be activated. */
|
|
368
|
-
readonly lastActivateEvent:
|
|
368
|
+
readonly lastActivateEvent: WritableSignalLike<KeyboardEvent | FocusEvent | undefined>;
|
|
369
369
|
/** The last event that caused the widget to be deactivated. */
|
|
370
|
-
readonly lastDeactivateEvent:
|
|
370
|
+
readonly lastDeactivateEvent: WritableSignalLike<KeyboardEvent | FocusEvent | undefined>;
|
|
371
371
|
/** The keyboard event manager for the widget. */
|
|
372
|
-
readonly keydown:
|
|
372
|
+
readonly keydown: SignalLike<KeyboardEventManager<KeyboardEvent>>;
|
|
373
373
|
constructor(inputs: GridCellWidgetInputs);
|
|
374
374
|
/** Handles keydown events for the widget. */
|
|
375
375
|
onKeydown(event: KeyboardEvent): void;
|
|
@@ -408,7 +408,7 @@ declare class GridCellPattern implements GridCell {
|
|
|
408
408
|
/** The html element that should receive focus. */
|
|
409
409
|
readonly element: SignalLike<HTMLElement>;
|
|
410
410
|
/** Whether the cell has focus. */
|
|
411
|
-
readonly isFocused:
|
|
411
|
+
readonly isFocused: WritableSignalLike<boolean>;
|
|
412
412
|
/** Whether the cell is selected. */
|
|
413
413
|
readonly selected: WritableSignalLike<boolean>;
|
|
414
414
|
/** Whether the cell is selectable. */
|
|
@@ -452,11 +452,11 @@ declare class GridCellPattern implements GridCell {
|
|
|
452
452
|
/** Whether the cell or widget inside the cell is activated. */
|
|
453
453
|
readonly isActivated: SignalLike<boolean>;
|
|
454
454
|
/** The key used to navigate to the previous widget. */
|
|
455
|
-
readonly prevKey:
|
|
455
|
+
readonly prevKey: SignalLike<"ArrowUp" | "ArrowRight" | "ArrowLeft">;
|
|
456
456
|
/** The key used to navigate to the next widget. */
|
|
457
|
-
readonly nextKey:
|
|
457
|
+
readonly nextKey: SignalLike<"ArrowRight" | "ArrowLeft" | "ArrowDown">;
|
|
458
458
|
/** The keyboard event manager for the cell. */
|
|
459
|
-
readonly keydown:
|
|
459
|
+
readonly keydown: SignalLike<KeyboardEventManager<KeyboardEvent>>;
|
|
460
460
|
constructor(inputs: GridCellInputs);
|
|
461
461
|
/** Handles keydown events for the cell. */
|
|
462
462
|
onKeydown(event: KeyboardEvent): void;
|
|
@@ -518,35 +518,35 @@ declare class GridPattern {
|
|
|
518
518
|
/** The underlying grid behavior that this pattern is built on. */
|
|
519
519
|
readonly gridBehavior: Grid<GridCellPattern>;
|
|
520
520
|
/** The cells in the grid. */
|
|
521
|
-
readonly cells:
|
|
521
|
+
readonly cells: SignalLike<GridCellPattern[][]>;
|
|
522
522
|
/** The tab index for the grid. */
|
|
523
|
-
readonly tabIndex:
|
|
523
|
+
readonly tabIndex: SignalLike<0 | -1>;
|
|
524
524
|
/** Whether the grid is disabled. */
|
|
525
|
-
readonly disabled:
|
|
525
|
+
readonly disabled: SignalLike<boolean>;
|
|
526
526
|
/** The ID of the currently active descendant cell. */
|
|
527
|
-
readonly activeDescendant:
|
|
527
|
+
readonly activeDescendant: SignalLike<string | undefined>;
|
|
528
528
|
/** The currently active cell. */
|
|
529
|
-
readonly activeCell:
|
|
529
|
+
readonly activeCell: SignalLike<GridCellPattern | undefined>;
|
|
530
530
|
/** The current selection anchor cell. */
|
|
531
531
|
readonly anchorCell: SignalLike<GridCellPattern | undefined>;
|
|
532
532
|
/** Whether to pause grid navigation and give the keyboard control to cell or widget. */
|
|
533
533
|
readonly pauseNavigation: SignalLike<boolean>;
|
|
534
534
|
/** Whether the focus is in the grid. */
|
|
535
|
-
readonly isFocused:
|
|
535
|
+
readonly isFocused: WritableSignalLike<boolean>;
|
|
536
536
|
/** Whether the grid has been focused once. */
|
|
537
|
-
readonly hasBeenFocused:
|
|
537
|
+
readonly hasBeenFocused: WritableSignalLike<boolean>;
|
|
538
538
|
/** Whether the user is currently dragging to select a range of cells. */
|
|
539
|
-
readonly dragging:
|
|
539
|
+
readonly dragging: WritableSignalLike<boolean>;
|
|
540
540
|
/** The key for navigating to the previous column. */
|
|
541
|
-
readonly prevColKey:
|
|
541
|
+
readonly prevColKey: SignalLike<"ArrowRight" | "ArrowLeft">;
|
|
542
542
|
/** The key for navigating to the next column. */
|
|
543
|
-
readonly nextColKey:
|
|
543
|
+
readonly nextColKey: SignalLike<"ArrowRight" | "ArrowLeft">;
|
|
544
544
|
/** The keydown event manager for the grid. */
|
|
545
|
-
readonly keydown:
|
|
545
|
+
readonly keydown: SignalLike<KeyboardEventManager<KeyboardEvent>>;
|
|
546
546
|
/** The pointerdown event manager for the grid. */
|
|
547
|
-
readonly pointerdown:
|
|
547
|
+
readonly pointerdown: SignalLike<PointerEventManager<PointerEvent>>;
|
|
548
548
|
/** The pointerup event manager for the grid. */
|
|
549
|
-
readonly pointerup:
|
|
549
|
+
readonly pointerup: SignalLike<PointerEventManager<PointerEvent>>;
|
|
550
550
|
/** Indicates maybe the losing focus is caused by row/cell deletion. */
|
|
551
551
|
private readonly _maybeDeletion;
|
|
552
552
|
/** Indicates the losing focus is certainly caused by row/cell deletion. */
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { SignalLike } from './_list-navigation-chunk.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Options that are applicable to all event handlers.
|
|
5
|
+
*
|
|
6
|
+
* This library has not yet had a need for stopPropagationImmediate.
|
|
7
|
+
*/
|
|
8
|
+
interface EventHandlerOptions {
|
|
9
|
+
stopPropagation: boolean;
|
|
10
|
+
preventDefault: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** A basic event handler. */
|
|
13
|
+
type EventHandler<T extends Event> = (event: T) => void;
|
|
14
|
+
/** A function that determines whether an event is to be handled. */
|
|
15
|
+
type EventMatcher<T extends Event> = (event: T) => boolean;
|
|
16
|
+
/** A config that specifies how to handle a particular event. */
|
|
17
|
+
interface EventHandlerConfig<T extends Event> extends EventHandlerOptions {
|
|
18
|
+
matcher: EventMatcher<T>;
|
|
19
|
+
handler: EventHandler<T>;
|
|
20
|
+
}
|
|
21
|
+
/** Bit flag representation of the possible modifier keys that can be present on an event. */
|
|
22
|
+
declare enum Modifier {
|
|
23
|
+
None = 0,
|
|
24
|
+
Ctrl = 1,
|
|
25
|
+
Shift = 2,
|
|
26
|
+
Alt = 4,
|
|
27
|
+
Meta = 8,
|
|
28
|
+
Any = "Any"
|
|
29
|
+
}
|
|
30
|
+
type ModifierInputs = Modifier | Modifier[];
|
|
31
|
+
/**
|
|
32
|
+
* Abstract base class for all event managers.
|
|
33
|
+
*
|
|
34
|
+
* Event managers are designed to normalize how event handlers are authored and create a safety net
|
|
35
|
+
* for common event handling gotchas like remembering to call preventDefault or stopPropagation.
|
|
36
|
+
*/
|
|
37
|
+
declare abstract class EventManager<T extends Event> {
|
|
38
|
+
protected configs: EventHandlerConfig<T>[];
|
|
39
|
+
abstract options: EventHandlerOptions;
|
|
40
|
+
/** Runs the handlers that match with the given event. */
|
|
41
|
+
handle(event: T): void;
|
|
42
|
+
/** Configures the event manager to handle specific events. (See subclasses for more). */
|
|
43
|
+
abstract on(...args: [...unknown[]]): this;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Used to represent a keycode.
|
|
48
|
+
*
|
|
49
|
+
* This is used to match whether an events keycode should be handled. The ability to match using a
|
|
50
|
+
* string, SignalLike, or Regexp gives us more flexibility when authoring event handlers.
|
|
51
|
+
*/
|
|
52
|
+
type KeyCode = string | SignalLike<string> | RegExp;
|
|
53
|
+
/**
|
|
54
|
+
* An event manager that is specialized for handling keyboard events. By default this manager stops
|
|
55
|
+
* propagation and prevents default on all events it handles.
|
|
56
|
+
*/
|
|
57
|
+
declare class KeyboardEventManager<T extends KeyboardEvent> extends EventManager<T> {
|
|
58
|
+
options: EventHandlerOptions;
|
|
59
|
+
/** Configures this event manager to handle events with a specific key and no modifiers. */
|
|
60
|
+
on(key: KeyCode, handler: EventHandler<T>, options?: Partial<EventHandlerOptions>): this;
|
|
61
|
+
/** Configures this event manager to handle events with a specific modifer and key combination. */
|
|
62
|
+
on(modifiers: ModifierInputs, key: KeyCode, handler: EventHandler<T>, options?: Partial<EventHandlerOptions>): this;
|
|
63
|
+
private _normalizeInputs;
|
|
64
|
+
private _isMatch;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { EventManager, KeyboardEventManager };
|
|
68
|
+
export type { EventHandler, EventHandlerOptions, ModifierInputs };
|