@angular/cdk-experimental 20.0.0-next.0 → 20.0.0-next.1

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.
@@ -1,391 +1,2 @@
1
- import { Signal } from '@angular/core';
2
- import { WritableSignal } from '@angular/core';
3
-
4
- /** A basic event handler. */
5
- declare type EventHandler<T extends Event> = (event: T) => void;
6
-
7
- /** A config that specifies how to handle a particular event. */
8
- declare interface EventHandlerConfig<T extends Event> extends EventHandlerOptions {
9
- matcher: EventMatcher<T>;
10
- handler: EventHandler<T>;
11
- }
12
-
13
- /**
14
- * Options that are applicable to all event handlers.
15
- *
16
- * This library has not yet had a need for stopPropagationImmediate.
17
- */
18
- declare interface EventHandlerOptions {
19
- stopPropagation: boolean;
20
- preventDefault: boolean;
21
- }
22
-
23
- /**
24
- * Abstract base class for all event managers.
25
- *
26
- * Event managers are designed to normalize how event handlers are authored and create a safety net
27
- * for common event handling gotchas like remembering to call preventDefault or stopPropagation.
28
- */
29
- declare abstract class EventManager<T extends Event> {
30
- protected configs: EventHandlerConfig<T>[];
31
- abstract options: EventHandlerOptions;
32
- /** Runs the handlers that match with the given event. */
33
- handle(event: T): void;
34
- /** Configures the event manager to handle specific events. (See subclasses for more). */
35
- abstract on(...args: [...unknown[]]): this;
36
- }
37
-
38
- /** A function that determines whether an event is to be handled. */
39
- declare type EventMatcher<T extends Event> = (event: T) => boolean;
40
-
41
- /**
42
- * An event manager that is specialized for handling keyboard events. By default this manager stops
43
- * propagation and prevents default on all events it handles.
44
- */
45
- declare class KeyboardEventManager<T extends KeyboardEvent> extends EventManager<T> {
46
- options: EventHandlerOptions;
47
- /** Configures this event manager to handle events with a specific key and no modifiers. */
48
- on(key: KeyCode, handler: EventHandler<T>): this;
49
- /** Configures this event manager to handle events with a specific modifer and key combination. */
50
- on(modifiers: ModifierInputs, key: KeyCode, handler: EventHandler<T>): this;
51
- private _normalizeInputs;
52
- private _isMatch;
53
- }
54
-
55
- /**
56
- * Used to represent a keycode.
57
- *
58
- * This is used to match whether an events keycode should be handled. The ability to match using a
59
- * string, Signal, or Regexp gives us more flexibility when authoring event handlers.
60
- */
61
- declare type KeyCode = string | Signal<string> | RegExp;
62
-
63
- /** Represents the required inputs for a listbox. */
64
- export declare type ListboxInputs = ListNavigationInputs<OptionPattern> & ListSelectionInputs<OptionPattern> & ListTypeaheadInputs & ListFocusInputs<OptionPattern> & {
65
- disabled: Signal<boolean>;
66
- };
67
-
68
- /** Controls the state of a listbox. */
69
- export declare class ListboxPattern {
70
- readonly inputs: ListboxInputs;
71
- /** Controls navigation for the listbox. */
72
- navigation: ListNavigation<OptionPattern>;
73
- /** Controls selection for the listbox. */
74
- selection: ListSelection<OptionPattern>;
75
- /** Controls typeahead for the listbox. */
76
- typeahead: ListTypeahead<OptionPattern>;
77
- /** Controls focus for the listbox. */
78
- focusManager: ListFocus<OptionPattern>;
79
- /** Whether the list is vertically or horizontally oriented. */
80
- orientation: Signal<'vertical' | 'horizontal'>;
81
- /** Whether the listbox is disabled. */
82
- disabled: Signal<boolean>;
83
- /** The tabindex of the listbox. */
84
- tabindex: Signal<0 | -1>;
85
- /** The id of the current active item. */
86
- activedescendant: Signal<String | undefined>;
87
- /** Whether multiple items in the list can be selected at once. */
88
- multiselectable: Signal<boolean>;
89
- /** The number of items in the listbox. */
90
- setsize: Signal<number>;
91
- /** Whether the listbox selection follows focus. */
92
- followFocus: Signal<boolean>;
93
- /** The key used to navigate to the previous item in the list. */
94
- prevKey: Signal<"ArrowUp" | "ArrowRight" | "ArrowLeft">;
95
- /** The key used to navigate to the next item in the list. */
96
- nextKey: Signal<"ArrowRight" | "ArrowLeft" | "ArrowDown">;
97
- /** The regexp used to decide if a key should trigger typeahead. */
98
- typeaheadRegexp: RegExp;
99
- /** The keydown event manager for the listbox. */
100
- keydown: Signal<KeyboardEventManager<KeyboardEvent>>;
101
- /** The pointerdown event manager for the listbox. */
102
- pointerdown: Signal<PointerEventManager<PointerEvent>>;
103
- constructor(inputs: ListboxInputs);
104
- /** Handles keydown events for the listbox. */
105
- onKeydown(event: KeyboardEvent): void;
106
- onPointerdown(event: PointerEvent): void;
107
- /** Navigates to the first option in the listbox. */
108
- first(opts?: SelectOptions): void;
109
- /** Navigates to the last option in the listbox. */
110
- last(opts?: SelectOptions): void;
111
- /** Navigates to the next option in the listbox. */
112
- next(opts?: SelectOptions): void;
113
- /** Navigates to the previous option in the listbox. */
114
- prev(opts?: SelectOptions): void;
115
- /** Navigates to the given item in the listbox. */
116
- goto(event: PointerEvent, opts?: SelectOptions): void;
117
- /** Handles typeahead search navigation for the listbox. */
118
- search(char: string, opts?: SelectOptions): void;
119
- /** Handles updating selection for the listbox. */
120
- private _updateSelection;
121
- private _getItem;
122
- }
123
-
124
- /**
125
- * Represents the properties exposed by a listbox that need to be accessed by an option.
126
- * This exists to avoid circular dependency errors between the listbox and option.
127
- */
128
- declare interface ListboxPattern_2 {
129
- focusManager: ListFocus<OptionPattern>;
130
- selection: ListSelection<OptionPattern>;
131
- navigation: ListNavigation<OptionPattern>;
132
- }
133
-
134
- /** Controls focus for a list of items. */
135
- declare class ListFocus<T extends ListFocusItem> {
136
- readonly inputs: ListFocusInputs<T> & {
137
- navigation: ListNavigation<T>;
138
- };
139
- /** The navigation controller of the parent list. */
140
- navigation: ListNavigation<ListFocusItem>;
141
- constructor(inputs: ListFocusInputs<T> & {
142
- navigation: ListNavigation<T>;
143
- });
144
- /** The id of the current active item. */
145
- getActiveDescendant(): String | undefined;
146
- /** The tabindex for the list. */
147
- getListTabindex(): -1 | 0;
148
- /** Returns the tabindex for the given item. */
149
- getItemTabindex(item: T): -1 | 0;
150
- /** Focuses the current active item. */
151
- focus(): void;
152
- }
153
-
154
- /** Represents the required inputs for a collection that contains focusable items. */
155
- declare interface ListFocusInputs<T extends ListFocusItem> {
156
- /** The focus strategy used by the list. */
157
- focusMode: Signal<'roving' | 'activedescendant'>;
158
- }
159
-
160
- /** Represents an item in a collection, such as a listbox option, than may receive focus. */
161
- declare interface ListFocusItem extends ListNavigationItem {
162
- /** A unique identifier for the item. */
163
- id: Signal<string>;
164
- /** The html element that should receive focus. */
165
- element: Signal<HTMLElement>;
166
- }
167
-
168
- /** Controls navigation for a list of items. */
169
- declare class ListNavigation<T extends ListNavigationItem> {
170
- readonly inputs: ListNavigationInputs<T>;
171
- /** The last index that was active. */
172
- prevActiveIndex: WritableSignal<number>;
173
- constructor(inputs: ListNavigationInputs<T>);
174
- /** Navigates to the given item. */
175
- goto(item: T): void;
176
- /** Navigates to the next item in the list. */
177
- next(): void;
178
- /** Navigates to the previous item in the list. */
179
- prev(): void;
180
- /** Navigates to the first item in the list. */
181
- first(): void;
182
- /** Navigates to the last item in the list. */
183
- last(): void;
184
- /** Returns true if the given item can be navigated to. */
185
- isFocusable(item: T): boolean;
186
- /** Advances to the next or previous focusable item in the list based on the given delta. */
187
- private _advance;
188
- }
189
-
190
- /** Represents the required inputs for a collection that has navigable items. */
191
- declare interface ListNavigationInputs<T extends ListNavigationItem> {
192
- /** Whether focus should wrap when navigating. */
193
- wrap: Signal<boolean>;
194
- /** The items in the list. */
195
- items: Signal<T[]>;
196
- /** Whether disabled items in the list should be skipped when navigating. */
197
- skipDisabled: Signal<boolean>;
198
- /** The current index that has been navigated to. */
199
- activeIndex: WritableSignal<number>;
200
- /** Whether the list is vertically or horizontally oriented. */
201
- orientation: Signal<'vertical' | 'horizontal'>;
202
- /** The direction that text is read based on the users locale. */
203
- textDirection: Signal<'rtl' | 'ltr'>;
204
- }
205
-
206
- /** Represents an item in a collection, such as a listbox option, than can be navigated to. */
207
- declare interface ListNavigationItem {
208
- /** Whether an item is disabled. */
209
- disabled: Signal<boolean>;
210
- }
211
-
212
- /** Controls selection for a list of items. */
213
- declare class ListSelection<T extends ListSelectionItem> {
214
- readonly inputs: ListSelectionInputs<T> & {
215
- navigation: ListNavigation<T>;
216
- };
217
- /** The id of the most recently selected item. */
218
- previousSelectedId: WritableSignal<string | undefined>;
219
- /** The navigation controller of the parent list. */
220
- navigation: ListNavigation<T>;
221
- constructor(inputs: ListSelectionInputs<T> & {
222
- navigation: ListNavigation<T>;
223
- });
224
- /** Selects the item at the current active index. */
225
- select(item?: T): void;
226
- /** Deselects the item at the current active index. */
227
- deselect(item?: T): void;
228
- /** Toggles the item at the current active index. */
229
- toggle(): void;
230
- /** Toggles only the item at the current active index. */
231
- toggleOne(): void;
232
- /** Selects all items in the list. */
233
- selectAll(): void;
234
- /** Deselects all items in the list. */
235
- deselectAll(): void;
236
- /** Selects the items in the list starting at the last selected item. */
237
- selectFromPrevSelectedItem(): void;
238
- /** Selects the items in the list starting at the last active item. */
239
- selectFromActive(): void;
240
- /** Selects the items in the list starting at the given index. */
241
- private _selectFromIndex;
242
- /** Sets the selection to only the current active item. */
243
- selectOne(): void;
244
- /** Sets the anchor to the current active index. */
245
- private _anchor;
246
- }
247
-
248
- /** Represents the required inputs for a collection that contains selectable items. */
249
- declare interface ListSelectionInputs<T extends ListSelectionItem> {
250
- /** The items in the list. */
251
- items: Signal<T[]>;
252
- /** Whether multiple items in the list can be selected at once. */
253
- multiselectable: Signal<boolean>;
254
- /** The ids of the current selected items. */
255
- selectedIds: WritableSignal<string[]>;
256
- /** The selection strategy used by the list. */
257
- selectionMode: Signal<'follow' | 'explicit'>;
258
- }
259
-
260
- /** Represents an item in a collection, such as a listbox option, than can be selected. */
261
- declare interface ListSelectionItem extends ListNavigationItem {
262
- /** A unique identifier for the item. */
263
- id: Signal<string>;
264
- /** Whether an item is disabled. */
265
- disabled: Signal<boolean>;
266
- }
267
-
268
- /** Controls typeahead for a list of items. */
269
- declare class ListTypeahead<T extends ListTypeaheadItem> {
270
- readonly inputs: ListTypeaheadInputs & {
271
- navigation: ListNavigation<T>;
272
- };
273
- /** A reference to the timeout for resetting the typeahead search. */
274
- timeout?: ReturnType<typeof setTimeout> | undefined;
275
- /** The navigation controller of the parent list. */
276
- navigation: ListNavigation<T>;
277
- /** Keeps track of the characters that typeahead search is being called with. */
278
- private _query;
279
- /** The index where that the typeahead search was initiated from. */
280
- private _startIndex;
281
- constructor(inputs: ListTypeaheadInputs & {
282
- navigation: ListNavigation<T>;
283
- });
284
- /** Performs a typeahead search, appending the given character to the search string. */
285
- search(char: string): void;
286
- /**
287
- * Returns the first item whose search term matches the
288
- * current query starting from the the current anchor index.
289
- */
290
- private _getItem;
291
- }
292
-
293
- /**
294
- * Represents the required inputs for a collection that contains items that can be navigated to by
295
- * typeahead.
296
- */
297
- declare interface ListTypeaheadInputs {
298
- /** The amount of time before the typeahead search is reset. */
299
- typeaheadDelay: Signal<number>;
300
- }
301
-
302
- /**
303
- * Represents an item in a collection, such as a listbox option, than can be navigated to by
304
- * typeahead.
305
- */
306
- declare interface ListTypeaheadItem extends ListNavigationItem {
307
- /** The text used by the typeahead search. */
308
- searchTerm: Signal<string>;
309
- }
310
-
311
- declare type ModifierInputs = ModifierKey | ModifierKey[];
312
-
313
- /** Bit flag representation of the possible modifier keys that can be present on an event. */
314
- declare enum ModifierKey {
315
- None = 0,
316
- Ctrl = 1,
317
- Shift = 2,
318
- Alt = 4,
319
- Meta = 8
320
- }
321
-
322
- /**
323
- * The different mouse buttons that may appear on a pointer event.
324
- */
325
- declare enum MouseButton {
326
- Main = 0,
327
- Auxiliary = 1,
328
- Secondary = 2
329
- }
330
-
331
- /** Represents the required inputs for an option in a listbox. */
332
- export declare interface OptionInputs extends ListNavigationItem, ListSelectionItem, ListTypeaheadItem, ListFocusItem {
333
- listbox: Signal<ListboxPattern_2>;
334
- }
335
-
336
- /** Represents an option in a listbox. */
337
- export declare class OptionPattern {
338
- /** A unique identifier for the option. */
339
- id: Signal<string>;
340
- /** The position of the option in the list. */
341
- index: Signal<number>;
342
- /** Whether the option is selected. */
343
- selected: Signal<boolean>;
344
- /** Whether the option is disabled. */
345
- disabled: Signal<boolean>;
346
- /** The text used by the typeahead search. */
347
- searchTerm: Signal<string>;
348
- /** A reference to the parent listbox. */
349
- listbox: Signal<ListboxPattern_2>;
350
- /** The tabindex of the option. */
351
- tabindex: Signal<0 | -1>;
352
- /** The html element that should receive focus. */
353
- element: Signal<HTMLElement>;
354
- constructor(args: OptionInputs);
355
- }
356
-
357
- /** An event manager that is specialized for handling pointer events. */
358
- declare class PointerEventManager<T extends PointerEvent> extends EventManager<T> {
359
- options: EventHandlerOptions;
360
- /**
361
- * Configures this event manager to handle events with a specific modifer and mouse button
362
- * combination.
363
- */
364
- on(button: MouseButton, modifiers: ModifierInputs, handler: EventHandler<T>): this;
365
- /**
366
- * Configures this event manager to handle events with a specific mouse button and no modifiers.
367
- */
368
- on(modifiers: ModifierInputs, handler: EventHandler<T>): this;
369
- /**
370
- * Configures this event manager to handle events with the main mouse button and no modifiers.
371
- *
372
- * @param handler The handler function
373
- * @param options Options for whether to stop propagation or prevent default.
374
- */
375
- on(handler: EventHandler<T>): this;
376
- private _normalizeInputs;
377
- _isMatch(event: PointerEvent, button: MouseButton, modifiers: ModifierInputs): boolean;
378
- }
379
-
380
- /** The selection operations that the listbox can perform. */
381
- declare interface SelectOptions {
382
- select?: boolean;
383
- toggle?: boolean;
384
- toggleOne?: boolean;
385
- selectOne?: boolean;
386
- selectAll?: boolean;
387
- selectFromAnchor?: boolean;
388
- selectFromActive?: boolean;
389
- }
390
-
391
- export { }
1
+ export { a as ListboxInputs, L as ListboxPattern, b as OptionInputs, O as OptionPattern } from '../listbox.d-8e28229b.js';
2
+ import '@angular/core';