@typed/ui 1.0.0-beta.5 → 1.0.0-beta.7
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/dist/Alert.d.ts +35 -41
- package/dist/Alert.d.ts.map +1 -1
- package/dist/Alert.js +23 -20
- package/dist/Button.d.ts +34 -78
- package/dist/Button.d.ts.map +1 -1
- package/dist/Button.js +16 -12
- package/dist/Carousel.d.ts +35 -236
- package/dist/Carousel.d.ts.map +1 -1
- package/dist/Carousel.js +13 -136
- package/dist/Checkbox.d.ts +55 -90
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Checkbox.js +44 -38
- package/dist/Collection.d.ts +15 -15
- package/dist/Collection.js +7 -7
- package/dist/Combobox.d.ts +38 -187
- package/dist/Combobox.d.ts.map +1 -1
- package/dist/Combobox.js +9 -80
- package/dist/Component.d.ts +30 -24
- package/dist/Component.d.ts.map +1 -1
- package/dist/Component.js +23 -12
- package/dist/Composite.d.ts +50 -50
- package/dist/Composite.js +20 -20
- package/dist/Dialog.d.ts +34 -34
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Dialog.js +16 -14
- package/dist/Disclosure.d.ts +15 -15
- package/dist/Disclosure.js +6 -6
- package/dist/Dom/Events.d.ts +4 -4
- package/dist/Dom/Events.js +4 -4
- package/dist/Dom/Props.d.ts +9 -9
- package/dist/Dom/Props.js +4 -4
- package/dist/Dom/Refs.d.ts +2 -2
- package/dist/Dom/Refs.js +1 -1
- package/dist/Dom/Render.d.ts +2 -2
- package/dist/Dom/Render.js +2 -2
- package/dist/Dom/Types.d.ts +33 -33
- package/dist/Dom/index.d.ts +5 -5
- package/dist/Dom/index.d.ts.map +1 -1
- package/dist/Dom/index.js +4 -4
- package/dist/Dom.d.ts +1 -1
- package/dist/Dom.js +1 -1
- package/dist/Focusable.d.ts +5 -5
- package/dist/Focusable.js +1 -1
- package/dist/Form.d.ts +565 -533
- package/dist/Form.d.ts.map +1 -1
- package/dist/Form.js +350 -195
- package/dist/Grid.d.ts +39 -220
- package/dist/Grid.d.ts.map +1 -1
- package/dist/Grid.js +12 -107
- package/dist/Group.d.ts +50 -69
- package/dist/Group.d.ts.map +1 -1
- package/dist/Group.js +33 -25
- package/dist/Heading.d.ts +41 -40
- package/dist/Heading.d.ts.map +1 -1
- package/dist/Heading.js +26 -16
- package/dist/Hovercard.d.ts +18 -18
- package/dist/Hovercard.js +6 -6
- package/dist/HttpRouter.d.ts +3 -3
- package/dist/HttpRouter.js +5 -5
- package/dist/Link.d.ts +17 -21
- package/dist/Link.d.ts.map +1 -1
- package/dist/Link.js +11 -0
- package/dist/Listbox.d.ts +31 -163
- package/dist/Listbox.d.ts.map +1 -1
- package/dist/Listbox.js +9 -80
- package/dist/Menu.d.ts +67 -376
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Menu.js +17 -179
- package/dist/Menubar.d.ts +24 -142
- package/dist/Menubar.d.ts.map +1 -1
- package/dist/Menubar.js +8 -66
- package/dist/Meter.d.ts +72 -132
- package/dist/Meter.d.ts.map +1 -1
- package/dist/Meter.js +35 -42
- package/dist/NativeDetails.d.ts +1 -1
- package/dist/NativeDetails.js +1 -1
- package/dist/NativeDialog.d.ts +7 -5
- package/dist/NativeDialog.d.ts.map +1 -1
- package/dist/NativeDialog.js +42 -4
- package/dist/NativePopover.d.ts +6 -4
- package/dist/NativePopover.d.ts.map +1 -1
- package/dist/NativePopover.js +43 -5
- package/dist/Popover.d.ts +18 -19
- package/dist/Popover.d.ts.map +1 -1
- package/dist/Popover.js +7 -8
- package/dist/RadioGroup.d.ts +86 -188
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RadioGroup.js +55 -105
- package/dist/Role.d.ts +4 -4
- package/dist/Role.js +1 -1
- package/dist/Select.d.ts +109 -220
- package/dist/Select.d.ts.map +1 -1
- package/dist/Select.js +67 -117
- package/dist/Separator.d.ts +30 -26
- package/dist/Separator.d.ts.map +1 -1
- package/dist/Separator.js +16 -10
- package/dist/Slider.d.ts +64 -111
- package/dist/Slider.d.ts.map +1 -1
- package/dist/Slider.js +47 -42
- package/dist/SpinButton.d.ts +64 -111
- package/dist/SpinButton.d.ts.map +1 -1
- package/dist/SpinButton.js +47 -42
- package/dist/Storybook.d.ts +2 -2
- package/dist/Storybook.js +1 -1
- package/dist/Switch.d.ts +52 -91
- package/dist/Switch.d.ts.map +1 -1
- package/dist/Switch.js +30 -36
- package/dist/Tabs.d.ts +44 -224
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/Tabs.js +10 -94
- package/dist/Toolbar.d.ts +24 -142
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar.js +8 -66
- package/dist/Tooltip.d.ts +20 -20
- package/dist/Tooltip.js +6 -6
- package/dist/Tree.d.ts +43 -229
- package/dist/Tree.d.ts.map +1 -1
- package/dist/Tree.js +12 -113
- package/dist/TreeGrid.d.ts +45 -264
- package/dist/TreeGrid.d.ts.map +1 -1
- package/dist/TreeGrid.js +13 -125
- package/dist/VisuallyHidden.d.ts +41 -27
- package/dist/VisuallyHidden.d.ts.map +1 -1
- package/dist/VisuallyHidden.js +27 -10
- package/dist/WindowSplitter.d.ts +68 -108
- package/dist/WindowSplitter.d.ts.map +1 -1
- package/dist/WindowSplitter.js +106 -23
- package/package.json +9 -8
package/dist/Composite.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* events and browser-owned focus.
|
|
10
10
|
*
|
|
11
11
|
* @since 1.0.0
|
|
12
|
-
* @category
|
|
12
|
+
* @category Architecture overview
|
|
13
13
|
* @packageDocumentation
|
|
14
14
|
*/
|
|
15
15
|
import * as Effect from "effect/Effect";
|
|
@@ -35,7 +35,7 @@ import * as Collection from "./Collection.js";
|
|
|
35
35
|
* [Composite.makeState runnable setup](/reference/%40typed%2Fui%2FComposite%23makeState). Choose an
|
|
36
36
|
* axis policy explicitly: `const orientation: Orientation = "horizontal"`.
|
|
37
37
|
* @since 1.0.0
|
|
38
|
-
* @category
|
|
38
|
+
* @category Directional movement
|
|
39
39
|
*/
|
|
40
40
|
export type Orientation = "horizontal" | "vertical" | "both";
|
|
41
41
|
/**
|
|
@@ -57,7 +57,7 @@ export type Orientation = "horizontal" | "vertical" | "both";
|
|
|
57
57
|
* runnable setup](/reference/%40typed%2Fui%2FComposite%23makeState). Choose a supported movement
|
|
58
58
|
* operation explicitly: `const direction: Move = "next"`.
|
|
59
59
|
* @since 1.0.0
|
|
60
|
-
* @category
|
|
60
|
+
* @category Directional movement
|
|
61
61
|
*/
|
|
62
62
|
export type Move = "next" | "previous" | "first" | "last";
|
|
63
63
|
/**
|
|
@@ -80,37 +80,37 @@ export type Move = "next" | "previous" | "first" | "last";
|
|
|
80
80
|
* `const snapshot: State = yield* state` exposes focus, orientation, looping, RTL, and
|
|
81
81
|
* virtual-focus policy.
|
|
82
82
|
* @since 1.0.0
|
|
83
|
-
* @category
|
|
83
|
+
* @category Active item state
|
|
84
84
|
*/
|
|
85
85
|
export interface State {
|
|
86
86
|
/**
|
|
87
87
|
* Id currently active for keyboard navigation; null means no active item.
|
|
88
88
|
* @since 1.0.0
|
|
89
|
-
* @category
|
|
89
|
+
* @category Active item state
|
|
90
90
|
*/
|
|
91
91
|
readonly activeId: string | null;
|
|
92
92
|
/**
|
|
93
93
|
* Axis used to interpret Arrow-key movement.
|
|
94
94
|
* @since 1.0.0
|
|
95
|
-
* @category
|
|
95
|
+
* @category Directional movement
|
|
96
96
|
*/
|
|
97
97
|
readonly orientation: Orientation;
|
|
98
98
|
/**
|
|
99
99
|
* Whether movement wraps between the first and last enabled items.
|
|
100
100
|
* @since 1.0.0
|
|
101
|
-
* @category
|
|
101
|
+
* @category Directional movement
|
|
102
102
|
*/
|
|
103
103
|
readonly loop: boolean;
|
|
104
104
|
/**
|
|
105
105
|
* Whether horizontal Arrow-key meaning is reversed for right-to-left layout.
|
|
106
106
|
* @since 1.0.0
|
|
107
|
-
* @category
|
|
107
|
+
* @category Directional movement
|
|
108
108
|
*/
|
|
109
109
|
readonly rtl: boolean;
|
|
110
110
|
/**
|
|
111
111
|
* Whether DOM focus remains on the root and activeId is exposed via aria-activedescendant.
|
|
112
112
|
* @since 1.0.0
|
|
113
|
-
* @category
|
|
113
|
+
* @category Keyboard focus
|
|
114
114
|
*/
|
|
115
115
|
readonly virtualFocus: boolean;
|
|
116
116
|
}
|
|
@@ -135,37 +135,37 @@ export interface State {
|
|
|
135
135
|
* policy explicitly with
|
|
136
136
|
* `const initial: InitialState = { activeId: null, orientation: "vertical", loop: false, rtl: false, virtualFocus: true }; const state = yield* Composite.makeState(initial)`.
|
|
137
137
|
* @since 1.0.0
|
|
138
|
-
* @category
|
|
138
|
+
* @category Active item state
|
|
139
139
|
*/
|
|
140
140
|
export interface InitialState {
|
|
141
141
|
/**
|
|
142
142
|
* Id currently active for keyboard navigation; null means no active item.
|
|
143
143
|
* @since 1.0.0
|
|
144
|
-
* @category
|
|
144
|
+
* @category Active item state
|
|
145
145
|
*/
|
|
146
146
|
readonly activeId?: string | null;
|
|
147
147
|
/**
|
|
148
148
|
* Axis used to interpret Arrow-key movement.
|
|
149
149
|
* @since 1.0.0
|
|
150
|
-
* @category
|
|
150
|
+
* @category Directional movement
|
|
151
151
|
*/
|
|
152
152
|
readonly orientation?: Orientation;
|
|
153
153
|
/**
|
|
154
154
|
* Whether movement wraps between the first and last enabled items.
|
|
155
155
|
* @since 1.0.0
|
|
156
|
-
* @category
|
|
156
|
+
* @category Directional movement
|
|
157
157
|
*/
|
|
158
158
|
readonly loop?: boolean;
|
|
159
159
|
/**
|
|
160
160
|
* Whether horizontal Arrow-key meaning is reversed for right-to-left layout.
|
|
161
161
|
* @since 1.0.0
|
|
162
|
-
* @category
|
|
162
|
+
* @category Directional movement
|
|
163
163
|
*/
|
|
164
164
|
readonly rtl?: boolean;
|
|
165
165
|
/**
|
|
166
166
|
* Whether DOM focus remains on the root and activeId is exposed via aria-activedescendant.
|
|
167
167
|
* @since 1.0.0
|
|
168
|
-
* @category
|
|
168
|
+
* @category Keyboard focus
|
|
169
169
|
*/
|
|
170
170
|
readonly virtualFocus?: boolean;
|
|
171
171
|
}
|
|
@@ -189,25 +189,25 @@ export interface InitialState {
|
|
|
189
189
|
* the only three inputs with
|
|
190
190
|
* `const options: MoveOptions<string, State> = { state, collection, includeDisabled: false }`.
|
|
191
191
|
* @since 1.0.0
|
|
192
|
-
* @category
|
|
192
|
+
* @category Directional movement
|
|
193
193
|
*/
|
|
194
194
|
export interface MoveOptions<Value = unknown, CompositeState extends State = State, E = never, R = never, E2 = never, R2 = never, Element extends object = globalThis.Element> {
|
|
195
195
|
/**
|
|
196
196
|
* Renderer-independent RefSubject state consumed by this component or operation.
|
|
197
197
|
* @since 1.0.0
|
|
198
|
-
* @category
|
|
198
|
+
* @category State connection
|
|
199
199
|
*/
|
|
200
200
|
readonly state: RefSubject.RefSubject<CompositeState, E, R>;
|
|
201
201
|
/**
|
|
202
202
|
* Item registry used for collection-driven keyboard behavior and mounted ordering.
|
|
203
203
|
* @since 1.0.0
|
|
204
|
-
* @category
|
|
204
|
+
* @category Item registration
|
|
205
205
|
*/
|
|
206
206
|
readonly collection: RefSubject.RefSubject<Collection.State<Value, Element>, E2, R2>;
|
|
207
207
|
/**
|
|
208
208
|
* Whether movement may land on disabled collection items.
|
|
209
209
|
* @since 1.0.0
|
|
210
|
-
* @category
|
|
210
|
+
* @category Availability
|
|
211
211
|
*/
|
|
212
212
|
readonly includeDisabled?: boolean;
|
|
213
213
|
}
|
|
@@ -230,19 +230,19 @@ export interface MoveOptions<Value = unknown, CompositeState extends State = Sta
|
|
|
230
230
|
* [Composite.makeState runnable setup](/reference/%40typed%2Fui%2FComposite%23makeState). A
|
|
231
231
|
* compatible focus state is observable directly: `const active: ActiveIdState = yield* state`.
|
|
232
232
|
* @since 1.0.0
|
|
233
|
-
* @category
|
|
233
|
+
* @category Active item state
|
|
234
234
|
*/
|
|
235
235
|
export interface ActiveIdState {
|
|
236
236
|
/**
|
|
237
237
|
* Id currently active for keyboard navigation; null means no active item.
|
|
238
238
|
* @since 1.0.0
|
|
239
|
-
* @category
|
|
239
|
+
* @category Active item state
|
|
240
240
|
*/
|
|
241
241
|
readonly activeId: string | null;
|
|
242
242
|
/**
|
|
243
243
|
* Whether movement wraps between the first and last enabled items.
|
|
244
244
|
* @since 1.0.0
|
|
245
|
-
* @category
|
|
245
|
+
* @category Directional movement
|
|
246
246
|
*/
|
|
247
247
|
readonly loop: boolean;
|
|
248
248
|
}
|
|
@@ -266,37 +266,37 @@ export interface ActiveIdState {
|
|
|
266
266
|
* keyboard adapters need only the modeled surface:
|
|
267
267
|
* `const event: KeyboardEventLike = { key: "ArrowDown", preventDefault() {} }`.
|
|
268
268
|
* @since 1.0.0
|
|
269
|
-
* @category
|
|
269
|
+
* @category Keyboard navigation
|
|
270
270
|
*/
|
|
271
271
|
export interface KeyboardEventLike {
|
|
272
272
|
/**
|
|
273
273
|
* Native KeyboardEvent key value to interpret.
|
|
274
274
|
* @since 1.0.0
|
|
275
|
-
* @category
|
|
275
|
+
* @category Keyboard navigation
|
|
276
276
|
*/
|
|
277
277
|
readonly key: string;
|
|
278
278
|
/**
|
|
279
279
|
* Whether Alt modified the key event.
|
|
280
280
|
* @since 1.0.0
|
|
281
|
-
* @category
|
|
281
|
+
* @category Keyboard navigation
|
|
282
282
|
*/
|
|
283
283
|
readonly altKey?: boolean;
|
|
284
284
|
/**
|
|
285
285
|
* Whether Control modified the key event.
|
|
286
286
|
* @since 1.0.0
|
|
287
|
-
* @category
|
|
287
|
+
* @category Keyboard navigation
|
|
288
288
|
*/
|
|
289
289
|
readonly ctrlKey?: boolean;
|
|
290
290
|
/**
|
|
291
291
|
* Whether Meta modified the key event.
|
|
292
292
|
* @since 1.0.0
|
|
293
|
-
* @category
|
|
293
|
+
* @category Keyboard navigation
|
|
294
294
|
*/
|
|
295
295
|
readonly metaKey?: boolean;
|
|
296
296
|
/**
|
|
297
297
|
* Optional native-event callback invoked only for an internally handled key.
|
|
298
298
|
* @since 1.0.0
|
|
299
|
-
* @category
|
|
299
|
+
* @category Keyboard navigation
|
|
300
300
|
*/
|
|
301
301
|
preventDefault?: () => void;
|
|
302
302
|
}
|
|
@@ -320,19 +320,19 @@ export interface KeyboardEventLike {
|
|
|
320
320
|
* the exact typed query and timestamp with
|
|
321
321
|
* `const buffer: TypeaheadBuffer = { value: "Ty", updatedAt: 100 }`.
|
|
322
322
|
* @since 1.0.0
|
|
323
|
-
* @category
|
|
323
|
+
* @category Typeahead
|
|
324
324
|
*/
|
|
325
325
|
export interface TypeaheadBuffer {
|
|
326
326
|
/**
|
|
327
327
|
* Buffered typeahead key sequence, preserving the supplied key case.
|
|
328
328
|
* @since 1.0.0
|
|
329
|
-
* @category
|
|
329
|
+
* @category Typeahead
|
|
330
330
|
*/
|
|
331
331
|
readonly value: string;
|
|
332
332
|
/**
|
|
333
333
|
* Timestamp of the last typeahead key, used to decide whether to append or restart.
|
|
334
334
|
* @since 1.0.0
|
|
335
|
-
* @category
|
|
335
|
+
* @category Typeahead
|
|
336
336
|
*/
|
|
337
337
|
readonly updatedAt: number;
|
|
338
338
|
}
|
|
@@ -357,7 +357,7 @@ export interface TypeaheadBuffer {
|
|
|
357
357
|
* const decodeState = Schema.decodeUnknownEffect(Composite.StateSchema);
|
|
358
358
|
* ```
|
|
359
359
|
* @since 1.0.0
|
|
360
|
-
* @category
|
|
360
|
+
* @category Active item state
|
|
361
361
|
*/
|
|
362
362
|
export declare const StateSchema: Schema.Struct<{
|
|
363
363
|
readonly activeId: Schema.NullOr<Schema.String>;
|
|
@@ -396,7 +396,7 @@ export declare const StateSchema: Schema.Struct<{
|
|
|
396
396
|
* );
|
|
397
397
|
* ```
|
|
398
398
|
* @since 1.0.0
|
|
399
|
-
* @category
|
|
399
|
+
* @category Active item state
|
|
400
400
|
*/
|
|
401
401
|
export declare function makeState(initial?: InitialState): Effect.Effect<RefSubject.HydratedRefSubject<{
|
|
402
402
|
readonly activeId: string | null;
|
|
@@ -427,7 +427,7 @@ export declare function makeState(initial?: InitialState): Effect.Effect<RefSubj
|
|
|
427
427
|
* program invoke `yield* move({ state, collection }, "next")`, then read state to observe the next
|
|
428
428
|
* enabled registered id selected under the current loop policy.
|
|
429
429
|
* @since 1.0.0
|
|
430
|
-
* @category
|
|
430
|
+
* @category Directional movement
|
|
431
431
|
*/
|
|
432
432
|
export declare function move<Value, CompositeState extends State, E, R, E2, R2, Element extends object>(options: MoveOptions<Value, CompositeState, E, R, E2, R2, Element>, direction: Move): Effect.Effect<CompositeState, E | E2, R | R2>;
|
|
433
433
|
/**
|
|
@@ -451,7 +451,7 @@ export declare function move<Value, CompositeState extends State, E, R, E2, R2,
|
|
|
451
451
|
* program read `const value = yield* tabIndex(state, "item-2")`; it is `0` only while that item
|
|
452
452
|
* owns roving focus and is `-1` under virtual focus.
|
|
453
453
|
* @since 1.0.0
|
|
454
|
-
* @category
|
|
454
|
+
* @category Keyboard focus
|
|
455
455
|
*/
|
|
456
456
|
export declare function tabIndex<CompositeState extends State, E, R>(state: RefSubject.RefSubject<CompositeState, E, R>, id: string): RefSubject.Computed<0 | -1, E, R>;
|
|
457
457
|
/**
|
|
@@ -475,7 +475,7 @@ export declare function tabIndex<CompositeState extends State, E, R>(state: RefS
|
|
|
475
475
|
* the linked Effect program read `const id = yield* activeDescendant(state)`; it is the active id
|
|
476
476
|
* only under virtual focus and otherwise `undefined`.
|
|
477
477
|
* @since 1.0.0
|
|
478
|
-
* @category
|
|
478
|
+
* @category Keyboard focus
|
|
479
479
|
*/
|
|
480
480
|
export declare function activeDescendant<CompositeState extends State, E, R>(state: RefSubject.RefSubject<CompositeState, E, R>): RefSubject.Computed<string | undefined, E, R>;
|
|
481
481
|
/**
|
|
@@ -499,7 +499,7 @@ export declare function activeDescendant<CompositeState extends State, E, R>(sta
|
|
|
499
499
|
* program read `const value = yield* rootTabIndex(state)`; it is `0` while the root owns focus and
|
|
500
500
|
* `-1` after a roving-focus item becomes active.
|
|
501
501
|
* @since 1.0.0
|
|
502
|
-
* @category
|
|
502
|
+
* @category Keyboard focus
|
|
503
503
|
*/
|
|
504
504
|
export declare function rootTabIndex<CompositeState extends State, E, R>(state: RefSubject.RefSubject<CompositeState, E, R>): RefSubject.Computed<0 | -1, E, R>;
|
|
505
505
|
/**
|
|
@@ -523,7 +523,7 @@ export declare function rootTabIndex<CompositeState extends State, E, R>(state:
|
|
|
523
523
|
* const direction = Composite.keyMove({ key: "ArrowLeft" }, { orientation: "horizontal", rtl: true });
|
|
524
524
|
* ```
|
|
525
525
|
* @since 1.0.0
|
|
526
|
-
* @category
|
|
526
|
+
* @category Keyboard navigation
|
|
527
527
|
*/
|
|
528
528
|
export declare function keyMove(event: Pick<KeyboardEventLike, "key">, options: {
|
|
529
529
|
readonly orientation?: Orientation;
|
|
@@ -550,7 +550,7 @@ export declare function keyMove(event: Pick<KeyboardEventLike, "key">, options:
|
|
|
550
550
|
* program run `yield* moveByKey({ key: "ArrowDown" }, { state, collection })`, then read state to
|
|
551
551
|
* observe the active id selected by the current orientation and RTL policy.
|
|
552
552
|
* @since 1.0.0
|
|
553
|
-
* @category
|
|
553
|
+
* @category Keyboard navigation
|
|
554
554
|
*/
|
|
555
555
|
export declare function moveByKey<Value, CompositeState extends State, E, R, E2, R2, Element extends object>(event: KeyboardEventLike, options: MoveOptions<Value, CompositeState, E, R, E2, R2, Element>): Effect.Effect<boolean, E | E2, R | R2>;
|
|
556
556
|
/**
|
|
@@ -575,7 +575,7 @@ export declare function moveByKey<Value, CompositeState extends State, E, R, E2,
|
|
|
575
575
|
* program run `yield* moveAndFocus({ state, collection }, "next")`; the returned state names the
|
|
576
576
|
* next id and its registered element receives native focus.
|
|
577
577
|
* @since 1.0.0
|
|
578
|
-
* @category
|
|
578
|
+
* @category DOM focus and scrolling
|
|
579
579
|
*/
|
|
580
580
|
export declare function moveAndFocus<Value, CompositeState extends State, E, R, E2, R2, Element extends object>(options: MoveOptions<Value, CompositeState, E, R, E2, R2, Element>, direction: Move): Effect.Effect<CompositeState, E | E2, R | R2>;
|
|
581
581
|
/**
|
|
@@ -599,7 +599,7 @@ export declare function moveAndFocus<Value, CompositeState extends State, E, R,
|
|
|
599
599
|
* program run `yield* focusActive({ state, collection })`; the active registered element receives
|
|
600
600
|
* native focus, with no state transition when no matching element exists.
|
|
601
601
|
* @since 1.0.0
|
|
602
|
-
* @category
|
|
602
|
+
* @category DOM focus and scrolling
|
|
603
603
|
*/
|
|
604
604
|
export declare function focusActive<Value, CompositeState extends State, E, R, E2, R2, Element extends object>(options: MoveOptions<Value, CompositeState, E, R, E2, R2, Element>): Effect.Effect<void, E | E2, R | R2>;
|
|
605
605
|
/**
|
|
@@ -623,7 +623,7 @@ export declare function focusActive<Value, CompositeState extends State, E, R, E
|
|
|
623
623
|
* const focused = Composite.focusElement(document.querySelector("button") ?? undefined);
|
|
624
624
|
* ```
|
|
625
625
|
* @since 1.0.0
|
|
626
|
-
* @category
|
|
626
|
+
* @category DOM focus and scrolling
|
|
627
627
|
*/
|
|
628
628
|
export declare function focusElement(element: object | undefined): Effect.Effect<void>;
|
|
629
629
|
/**
|
|
@@ -647,7 +647,7 @@ export declare function focusElement(element: object | undefined): Effect.Effect
|
|
|
647
647
|
* program run `yield* scrollActive({ state, collection })`; the active registered element receives
|
|
648
648
|
* `scrollIntoView({ block: "nearest", inline: "nearest" })` when that method is available.
|
|
649
649
|
* @since 1.0.0
|
|
650
|
-
* @category
|
|
650
|
+
* @category DOM focus and scrolling
|
|
651
651
|
*/
|
|
652
652
|
export declare function scrollActive<Value, CompositeState extends State, E, R, E2, R2, Element extends object>(options: MoveOptions<Value, CompositeState, E, R, E2, R2, Element>): Effect.Effect<void, E | E2, R | R2>;
|
|
653
653
|
/**
|
|
@@ -671,7 +671,7 @@ export declare function scrollActive<Value, CompositeState extends State, E, R,
|
|
|
671
671
|
* const id = Composite.typeahead([{ id: "alpha", textValue: "Alpha" }], "al");
|
|
672
672
|
* ```
|
|
673
673
|
* @since 1.0.0
|
|
674
|
-
* @category
|
|
674
|
+
* @category Typeahead
|
|
675
675
|
*/
|
|
676
676
|
export declare function typeahead<Item extends Collection.Item<unknown, object>>(items: readonly Item[], search: string, text?: (item: Item) => string, includeDisabled?: boolean): string | null;
|
|
677
677
|
/**
|
|
@@ -695,7 +695,7 @@ export declare function typeahead<Item extends Collection.Item<unknown, object>>
|
|
|
695
695
|
* const id = Composite.typeaheadFrom([{ id: "alpha", textValue: "Alpha" }], "al", null);
|
|
696
696
|
* ```
|
|
697
697
|
* @since 1.0.0
|
|
698
|
-
* @category
|
|
698
|
+
* @category Typeahead
|
|
699
699
|
*/
|
|
700
700
|
export declare function typeaheadFrom<Item extends Collection.Item<unknown, object>>(items: readonly Item[], search: string, activeId: string | null, text?: (item: Item) => string, includeDisabled?: boolean): string | null;
|
|
701
701
|
/**
|
|
@@ -720,7 +720,7 @@ export declare function typeaheadFrom<Item extends Collection.Item<unknown, obje
|
|
|
720
720
|
* const key = Composite.typeaheadKey({ key: "A" });
|
|
721
721
|
* ```
|
|
722
722
|
* @since 1.0.0
|
|
723
|
-
* @category
|
|
723
|
+
* @category Typeahead
|
|
724
724
|
*/
|
|
725
725
|
export declare function typeaheadKey(event: KeyboardEventLike): string | null;
|
|
726
726
|
/**
|
|
@@ -744,7 +744,7 @@ export declare function typeaheadKey(event: KeyboardEventLike): string | null;
|
|
|
744
744
|
* const buffer = Composite.updateTypeaheadBuffer({ value: "a", updatedAt: 100 }, "b", 200);
|
|
745
745
|
* ```
|
|
746
746
|
* @since 1.0.0
|
|
747
|
-
* @category
|
|
747
|
+
* @category Typeahead
|
|
748
748
|
*/
|
|
749
749
|
export declare function updateTypeaheadBuffer(buffer: TypeaheadBuffer, key: string, now: number, timeout?: number): TypeaheadBuffer;
|
|
750
750
|
/**
|
|
@@ -768,7 +768,7 @@ export declare function updateTypeaheadBuffer(buffer: TypeaheadBuffer, key: stri
|
|
|
768
768
|
* const items = Composite.orderedEnabledItems([{ id: "a" }, { id: "b", disabled: true }]);
|
|
769
769
|
* ```
|
|
770
770
|
* @since 1.0.0
|
|
771
|
-
* @category
|
|
771
|
+
* @category Directional movement
|
|
772
772
|
*/
|
|
773
773
|
export declare function orderedEnabledItems<Item extends Collection.Item<unknown, object>>(items: readonly Item[]): readonly Item[];
|
|
774
774
|
/**
|
|
@@ -793,7 +793,7 @@ export declare function orderedEnabledItems<Item extends Collection.Item<unknown
|
|
|
793
793
|
* const id = Composite.moveActiveId([{ id: "a" }, { id: "b" }], { activeId: "a", loop: true }, "next");
|
|
794
794
|
* ```
|
|
795
795
|
* @since 1.0.0
|
|
796
|
-
* @category
|
|
796
|
+
* @category Directional movement
|
|
797
797
|
*/
|
|
798
798
|
export declare function moveActiveId<Item extends Collection.Item<unknown, object>>(items: readonly Item[], state: ActiveIdState, direction: Move, includeDisabled?: boolean): string | null;
|
|
799
799
|
/**
|
|
@@ -817,7 +817,7 @@ export declare function moveActiveId<Item extends Collection.Item<unknown, objec
|
|
|
817
817
|
* const item = Composite.moveActiveItem([{ id: "a" }, { id: "b" }], { activeId: "a", loop: true }, "next");
|
|
818
818
|
* ```
|
|
819
819
|
* @since 1.0.0
|
|
820
|
-
* @category
|
|
820
|
+
* @category Directional movement
|
|
821
821
|
*/
|
|
822
822
|
export declare function moveActiveItem<Item extends Collection.Item<unknown, object>>(items: readonly Item[], state: ActiveIdState, direction: Move, includeDisabled?: boolean): Item | undefined;
|
|
823
823
|
//# sourceMappingURL=Composite.d.ts.map
|
package/dist/Composite.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* events and browser-owned focus.
|
|
10
10
|
*
|
|
11
11
|
* @since 1.0.0
|
|
12
|
-
* @category
|
|
12
|
+
* @category Architecture overview
|
|
13
13
|
* @packageDocumentation
|
|
14
14
|
*/
|
|
15
15
|
import * as Effect from "effect/Effect";
|
|
@@ -37,7 +37,7 @@ import * as Collection from "./Collection.js";
|
|
|
37
37
|
* const decodeState = Schema.decodeUnknownEffect(Composite.StateSchema);
|
|
38
38
|
* ```
|
|
39
39
|
* @since 1.0.0
|
|
40
|
-
* @category
|
|
40
|
+
* @category Active item state
|
|
41
41
|
*/
|
|
42
42
|
export const StateSchema = Schema.Struct({
|
|
43
43
|
activeId: Schema.NullOr(Schema.String),
|
|
@@ -76,7 +76,7 @@ export const StateSchema = Schema.Struct({
|
|
|
76
76
|
* );
|
|
77
77
|
* ```
|
|
78
78
|
* @since 1.0.0
|
|
79
|
-
* @category
|
|
79
|
+
* @category Active item state
|
|
80
80
|
*/
|
|
81
81
|
export function makeState(initial = {}) {
|
|
82
82
|
return RefSubject.hydrate(StateSchema, {
|
|
@@ -109,7 +109,7 @@ export function makeState(initial = {}) {
|
|
|
109
109
|
* program invoke `yield* move({ state, collection }, "next")`, then read state to observe the next
|
|
110
110
|
* enabled registered id selected under the current loop policy.
|
|
111
111
|
* @since 1.0.0
|
|
112
|
-
* @category
|
|
112
|
+
* @category Directional movement
|
|
113
113
|
*/
|
|
114
114
|
export function move(options, direction) {
|
|
115
115
|
return Effect.gen(function* () {
|
|
@@ -139,7 +139,7 @@ export function move(options, direction) {
|
|
|
139
139
|
* program read `const value = yield* tabIndex(state, "item-2")`; it is `0` only while that item
|
|
140
140
|
* owns roving focus and is `-1` under virtual focus.
|
|
141
141
|
* @since 1.0.0
|
|
142
|
-
* @category
|
|
142
|
+
* @category Keyboard focus
|
|
143
143
|
*/
|
|
144
144
|
export function tabIndex(state, id) {
|
|
145
145
|
return RefSubject.map(state, (current) => current.virtualFocus ? -1 : current.activeId === id ? 0 : -1);
|
|
@@ -165,7 +165,7 @@ export function tabIndex(state, id) {
|
|
|
165
165
|
* the linked Effect program read `const id = yield* activeDescendant(state)`; it is the active id
|
|
166
166
|
* only under virtual focus and otherwise `undefined`.
|
|
167
167
|
* @since 1.0.0
|
|
168
|
-
* @category
|
|
168
|
+
* @category Keyboard focus
|
|
169
169
|
*/
|
|
170
170
|
export function activeDescendant(state) {
|
|
171
171
|
return RefSubject.map(state, (current) => current.virtualFocus && current.activeId ? current.activeId : undefined);
|
|
@@ -191,7 +191,7 @@ export function activeDescendant(state) {
|
|
|
191
191
|
* program read `const value = yield* rootTabIndex(state)`; it is `0` while the root owns focus and
|
|
192
192
|
* `-1` after a roving-focus item becomes active.
|
|
193
193
|
* @since 1.0.0
|
|
194
|
-
* @category
|
|
194
|
+
* @category Keyboard focus
|
|
195
195
|
*/
|
|
196
196
|
export function rootTabIndex(state) {
|
|
197
197
|
return RefSubject.map(state, (current) => current.virtualFocus || current.activeId === null ? 0 : -1);
|
|
@@ -217,7 +217,7 @@ export function rootTabIndex(state) {
|
|
|
217
217
|
* const direction = Composite.keyMove({ key: "ArrowLeft" }, { orientation: "horizontal", rtl: true });
|
|
218
218
|
* ```
|
|
219
219
|
* @since 1.0.0
|
|
220
|
-
* @category
|
|
220
|
+
* @category Keyboard navigation
|
|
221
221
|
*/
|
|
222
222
|
export function keyMove(event, options) {
|
|
223
223
|
if (event.key === "Home")
|
|
@@ -257,7 +257,7 @@ export function keyMove(event, options) {
|
|
|
257
257
|
* program run `yield* moveByKey({ key: "ArrowDown" }, { state, collection })`, then read state to
|
|
258
258
|
* observe the active id selected by the current orientation and RTL policy.
|
|
259
259
|
* @since 1.0.0
|
|
260
|
-
* @category
|
|
260
|
+
* @category Keyboard navigation
|
|
261
261
|
*/
|
|
262
262
|
export function moveByKey(event, options) {
|
|
263
263
|
return Effect.gen(function* () {
|
|
@@ -291,7 +291,7 @@ export function moveByKey(event, options) {
|
|
|
291
291
|
* program run `yield* moveAndFocus({ state, collection }, "next")`; the returned state names the
|
|
292
292
|
* next id and its registered element receives native focus.
|
|
293
293
|
* @since 1.0.0
|
|
294
|
-
* @category
|
|
294
|
+
* @category DOM focus and scrolling
|
|
295
295
|
*/
|
|
296
296
|
export function moveAndFocus(options, direction) {
|
|
297
297
|
return Effect.tap(move(options, direction), Effect.andThen(focusActive(options), scrollActive(options)));
|
|
@@ -317,7 +317,7 @@ export function moveAndFocus(options, direction) {
|
|
|
317
317
|
* program run `yield* focusActive({ state, collection })`; the active registered element receives
|
|
318
318
|
* native focus, with no state transition when no matching element exists.
|
|
319
319
|
* @since 1.0.0
|
|
320
|
-
* @category
|
|
320
|
+
* @category DOM focus and scrolling
|
|
321
321
|
*/
|
|
322
322
|
export function focusActive(options) {
|
|
323
323
|
return Effect.gen(function* () {
|
|
@@ -349,7 +349,7 @@ export function focusActive(options) {
|
|
|
349
349
|
* const focused = Composite.focusElement(document.querySelector("button") ?? undefined);
|
|
350
350
|
* ```
|
|
351
351
|
* @since 1.0.0
|
|
352
|
-
* @category
|
|
352
|
+
* @category DOM focus and scrolling
|
|
353
353
|
*/
|
|
354
354
|
export function focusElement(element) {
|
|
355
355
|
return Effect.sync(() => {
|
|
@@ -379,7 +379,7 @@ export function focusElement(element) {
|
|
|
379
379
|
* program run `yield* scrollActive({ state, collection })`; the active registered element receives
|
|
380
380
|
* `scrollIntoView({ block: "nearest", inline: "nearest" })` when that method is available.
|
|
381
381
|
* @since 1.0.0
|
|
382
|
-
* @category
|
|
382
|
+
* @category DOM focus and scrolling
|
|
383
383
|
*/
|
|
384
384
|
export function scrollActive(options) {
|
|
385
385
|
return Effect.gen(function* () {
|
|
@@ -414,7 +414,7 @@ export function scrollActive(options) {
|
|
|
414
414
|
* const id = Composite.typeahead([{ id: "alpha", textValue: "Alpha" }], "al");
|
|
415
415
|
* ```
|
|
416
416
|
* @since 1.0.0
|
|
417
|
-
* @category
|
|
417
|
+
* @category Typeahead
|
|
418
418
|
*/
|
|
419
419
|
export function typeahead(items, search, text = (item) => item.textValue ?? item.id, includeDisabled = false) {
|
|
420
420
|
return typeaheadFrom(items, search, null, text, includeDisabled);
|
|
@@ -440,7 +440,7 @@ export function typeahead(items, search, text = (item) => item.textValue ?? item
|
|
|
440
440
|
* const id = Composite.typeaheadFrom([{ id: "alpha", textValue: "Alpha" }], "al", null);
|
|
441
441
|
* ```
|
|
442
442
|
* @since 1.0.0
|
|
443
|
-
* @category
|
|
443
|
+
* @category Typeahead
|
|
444
444
|
*/
|
|
445
445
|
export function typeaheadFrom(items, search, activeId, text = (item) => item.textValue ?? item.id, includeDisabled = false) {
|
|
446
446
|
const query = search.trim().toLocaleLowerCase();
|
|
@@ -474,7 +474,7 @@ export function typeaheadFrom(items, search, activeId, text = (item) => item.tex
|
|
|
474
474
|
* const key = Composite.typeaheadKey({ key: "A" });
|
|
475
475
|
* ```
|
|
476
476
|
* @since 1.0.0
|
|
477
|
-
* @category
|
|
477
|
+
* @category Typeahead
|
|
478
478
|
*/
|
|
479
479
|
export function typeaheadKey(event) {
|
|
480
480
|
if (event.altKey || event.ctrlKey || event.metaKey)
|
|
@@ -502,7 +502,7 @@ export function typeaheadKey(event) {
|
|
|
502
502
|
* const buffer = Composite.updateTypeaheadBuffer({ value: "a", updatedAt: 100 }, "b", 200);
|
|
503
503
|
* ```
|
|
504
504
|
* @since 1.0.0
|
|
505
|
-
* @category
|
|
505
|
+
* @category Typeahead
|
|
506
506
|
*/
|
|
507
507
|
export function updateTypeaheadBuffer(buffer, key, now, timeout = 500) {
|
|
508
508
|
return {
|
|
@@ -531,7 +531,7 @@ export function updateTypeaheadBuffer(buffer, key, now, timeout = 500) {
|
|
|
531
531
|
* const items = Composite.orderedEnabledItems([{ id: "a" }, { id: "b", disabled: true }]);
|
|
532
532
|
* ```
|
|
533
533
|
* @since 1.0.0
|
|
534
|
-
* @category
|
|
534
|
+
* @category Directional movement
|
|
535
535
|
*/
|
|
536
536
|
export function orderedEnabledItems(items) {
|
|
537
537
|
return Collection.enabledItems(Collection.byDomOrder(items));
|
|
@@ -558,7 +558,7 @@ export function orderedEnabledItems(items) {
|
|
|
558
558
|
* const id = Composite.moveActiveId([{ id: "a" }, { id: "b" }], { activeId: "a", loop: true }, "next");
|
|
559
559
|
* ```
|
|
560
560
|
* @since 1.0.0
|
|
561
|
-
* @category
|
|
561
|
+
* @category Directional movement
|
|
562
562
|
*/
|
|
563
563
|
export function moveActiveId(items, state, direction, includeDisabled = false) {
|
|
564
564
|
return moveActiveItem(items, state, direction, includeDisabled)?.id ?? null;
|
|
@@ -584,7 +584,7 @@ export function moveActiveId(items, state, direction, includeDisabled = false) {
|
|
|
584
584
|
* const item = Composite.moveActiveItem([{ id: "a" }, { id: "b" }], { activeId: "a", loop: true }, "next");
|
|
585
585
|
* ```
|
|
586
586
|
* @since 1.0.0
|
|
587
|
-
* @category
|
|
587
|
+
* @category Directional movement
|
|
588
588
|
*/
|
|
589
589
|
export function moveActiveItem(items, state, direction, includeDisabled = false) {
|
|
590
590
|
const enabled = orderedItems(items, includeDisabled);
|