@typed/ui 1.0.0-beta.3 → 1.0.0-beta.5
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/README.md +53 -9
- package/dist/Alert.d.ts +78 -0
- package/dist/Alert.d.ts.map +1 -0
- package/dist/Alert.js +37 -0
- package/dist/Button.d.ts +144 -0
- package/dist/Button.d.ts.map +1 -0
- package/dist/Button.js +38 -0
- package/dist/Carousel.d.ts +547 -0
- package/dist/Carousel.d.ts.map +1 -0
- package/dist/Carousel.js +387 -0
- package/dist/Checkbox.d.ts +203 -0
- package/dist/Checkbox.d.ts.map +1 -0
- package/dist/Checkbox.js +140 -0
- package/dist/Collection.d.ts +254 -0
- package/dist/Collection.d.ts.map +1 -0
- package/dist/Collection.js +218 -0
- package/dist/Combobox.d.ts +516 -0
- package/dist/Combobox.d.ts.map +1 -0
- package/dist/Combobox.js +371 -0
- package/dist/Component.d.ts +127 -0
- package/dist/Component.d.ts.map +1 -0
- package/dist/Component.js +60 -0
- package/dist/Composite.d.ts +823 -0
- package/dist/Composite.d.ts.map +1 -0
- package/dist/Composite.js +615 -0
- package/dist/Dialog.d.ts +544 -0
- package/dist/Dialog.d.ts.map +1 -0
- package/dist/Dialog.js +355 -0
- package/dist/Disclosure.d.ts +219 -0
- package/dist/Disclosure.d.ts.map +1 -0
- package/dist/Disclosure.js +128 -0
- package/dist/Dom/Events.d.ts +122 -0
- package/dist/Dom/Events.d.ts.map +1 -0
- package/dist/Dom/Events.js +192 -0
- package/dist/Dom/Props.d.ts +161 -0
- package/dist/Dom/Props.d.ts.map +1 -0
- package/dist/Dom/Props.js +110 -0
- package/dist/Dom/Refs.d.ts +58 -0
- package/dist/Dom/Refs.d.ts.map +1 -0
- package/dist/Dom/Refs.js +61 -0
- package/dist/Dom/Render.d.ts +59 -0
- package/dist/Dom/Render.d.ts.map +1 -0
- package/dist/Dom/Render.js +71 -0
- package/dist/Dom/Types.d.ts +570 -0
- package/dist/Dom/Types.d.ts.map +1 -0
- package/dist/Dom/Types.js +1 -0
- package/dist/Dom/index.d.ts +20 -0
- package/dist/Dom/index.d.ts.map +1 -0
- package/dist/Dom/index.js +8 -0
- package/dist/Dom.d.ts +14 -0
- package/dist/Dom.d.ts.map +1 -0
- package/dist/Dom.js +13 -0
- package/dist/Focusable.d.ts +85 -0
- package/dist/Focusable.d.ts.map +1 -0
- package/dist/Focusable.js +35 -0
- package/dist/Form.d.ts +1695 -0
- package/dist/Form.d.ts.map +1 -0
- package/dist/Form.js +987 -0
- package/dist/Grid.d.ts +569 -0
- package/dist/Grid.d.ts.map +1 -0
- package/dist/Grid.js +379 -0
- package/dist/Group.d.ts +147 -0
- package/dist/Group.d.ts.map +1 -0
- package/dist/Group.js +63 -0
- package/dist/Heading.d.ts +86 -0
- package/dist/Heading.d.ts.map +1 -0
- package/dist/Heading.js +48 -0
- package/dist/Hovercard.d.ts +297 -0
- package/dist/Hovercard.d.ts.map +1 -0
- package/dist/Hovercard.js +188 -0
- package/dist/HttpRouter.d.ts +129 -6
- package/dist/HttpRouter.d.ts.map +1 -1
- package/dist/HttpRouter.js +197 -54
- package/dist/Link.d.ts +67 -28
- package/dist/Link.d.ts.map +1 -1
- package/dist/Link.js +91 -37
- package/dist/Listbox.d.ts +437 -0
- package/dist/Listbox.d.ts.map +1 -0
- package/dist/Listbox.js +316 -0
- package/dist/Menu.d.ts +972 -0
- package/dist/Menu.d.ts.map +1 -0
- package/dist/Menu.js +731 -0
- package/dist/Menubar.d.ts +367 -0
- package/dist/Menubar.d.ts.map +1 -0
- package/dist/Menubar.js +265 -0
- package/dist/Meter.d.ts +217 -0
- package/dist/Meter.d.ts.map +1 -0
- package/dist/Meter.js +94 -0
- package/dist/NativeDetails.d.ts +41 -0
- package/dist/NativeDetails.d.ts.map +1 -0
- package/dist/NativeDetails.js +40 -0
- package/dist/NativeDialog.d.ts +64 -0
- package/dist/NativeDialog.d.ts.map +1 -0
- package/dist/NativeDialog.js +50 -0
- package/dist/NativePopover.d.ts +41 -0
- package/dist/NativePopover.d.ts.map +1 -0
- package/dist/NativePopover.js +46 -0
- package/dist/Popover.d.ts +241 -0
- package/dist/Popover.d.ts.map +1 -0
- package/dist/Popover.js +141 -0
- package/dist/RadioGroup.d.ts +432 -0
- package/dist/RadioGroup.d.ts.map +1 -0
- package/dist/RadioGroup.js +291 -0
- package/dist/Role.d.ts +64 -0
- package/dist/Role.d.ts.map +1 -0
- package/dist/Role.js +27 -0
- package/dist/Select.d.ts +529 -0
- package/dist/Select.d.ts.map +1 -0
- package/dist/Select.js +407 -0
- package/dist/Separator.d.ts +54 -0
- package/dist/Separator.d.ts.map +1 -0
- package/dist/Separator.js +26 -0
- package/dist/Slider.d.ts +188 -0
- package/dist/Slider.d.ts.map +1 -0
- package/dist/Slider.js +96 -0
- package/dist/SpinButton.d.ts +188 -0
- package/dist/SpinButton.d.ts.map +1 -0
- package/dist/SpinButton.js +96 -0
- package/dist/Storybook.d.ts +76 -0
- package/dist/Storybook.d.ts.map +1 -0
- package/dist/Storybook.js +102 -0
- package/dist/Switch.d.ts +187 -0
- package/dist/Switch.d.ts.map +1 -0
- package/dist/Switch.js +116 -0
- package/dist/Tab.d.ts +26 -0
- package/dist/Tab.d.ts.map +1 -0
- package/dist/Tab.js +25 -0
- package/dist/Tabs.d.ts +591 -0
- package/dist/Tabs.d.ts.map +1 -0
- package/dist/Tabs.js +346 -0
- package/dist/Toolbar.d.ts +366 -0
- package/dist/Toolbar.d.ts.map +1 -0
- package/dist/Toolbar.js +245 -0
- package/dist/Tooltip.d.ts +296 -0
- package/dist/Tooltip.d.ts.map +1 -0
- package/dist/Tooltip.js +172 -0
- package/dist/Tree.d.ts +591 -0
- package/dist/Tree.d.ts.map +1 -0
- package/dist/Tree.js +434 -0
- package/dist/TreeGrid.d.ts +645 -0
- package/dist/TreeGrid.d.ts.map +1 -0
- package/dist/TreeGrid.js +420 -0
- package/dist/VisuallyHidden.d.ts +54 -0
- package/dist/VisuallyHidden.d.ts.map +1 -0
- package/dist/VisuallyHidden.js +27 -0
- package/dist/WindowSplitter.d.ts +376 -0
- package/dist/WindowSplitter.d.ts.map +1 -0
- package/dist/WindowSplitter.js +222 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -0
- package/package.json +42 -15
- package/src/HttpRouter.test.ts +0 -294
- package/src/HttpRouter.ts +0 -168
- package/src/Link.test.ts +0 -84
- package/src/Link.ts +0 -107
- package/src/index.ts +0 -2
package/dist/Menu.d.ts
ADDED
|
@@ -0,0 +1,972 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Menu coordinates trigger, manual native popover content, registered items, and nested submenu
|
|
3
|
+
* state. Keyboard handling covers opening, Escape, directional parent/child traversal, roving
|
|
4
|
+
* focus, and typeahead without synthetic events.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* The module keeps policy, state transitions, and DOM rendering separable so applications can use
|
|
8
|
+
* the state and pure operations without mounting UI, or supply custom hosts without replacing native
|
|
9
|
+
* events and browser-owned focus.
|
|
10
|
+
*
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
* @category modules
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
import * as Effect from "effect/Effect";
|
|
16
|
+
import * as Scope from "effect/Scope";
|
|
17
|
+
import * as Schema from "effect/Schema";
|
|
18
|
+
import type { Fx } from "@typed/fx/Fx";
|
|
19
|
+
import { RefSubject } from "@typed/fx";
|
|
20
|
+
import { EventHandler, type Renderable, type RenderEvent, type RenderTemplate } from "@typed/template";
|
|
21
|
+
import * as Collection from "./Collection.js";
|
|
22
|
+
import * as Composite from "./Composite.js";
|
|
23
|
+
import * as Dom from "./Dom.js";
|
|
24
|
+
import type { HostResult } from "./Dom/Types.js";
|
|
25
|
+
/**
|
|
26
|
+
* Complete renderer-independent state for Menu.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* ## Why
|
|
30
|
+
*
|
|
31
|
+
* Applications can inspect, update, and test Menu behavior without mounting or coupling the state
|
|
32
|
+
* to a renderer.
|
|
33
|
+
*
|
|
34
|
+
* ## Ownership and lifetime
|
|
35
|
+
*
|
|
36
|
+
* This declaration is data or schema metadata and acquires no resources.
|
|
37
|
+
*
|
|
38
|
+
* ## Example
|
|
39
|
+
*
|
|
40
|
+
* Import with `import type { State } from "@typed/ui/Menu";` Extend the [Menu.makeState runnable
|
|
41
|
+
* setup](/reference/%40typed%2Fui%2FMenu%23makeState). Inside the linked program,
|
|
42
|
+
* `const snapshot: State = yield* state` exposes popup identity, open state, and active-item focus.
|
|
43
|
+
* @since 1.0.0
|
|
44
|
+
* @category models
|
|
45
|
+
*/
|
|
46
|
+
export interface State extends Omit<Composite.State, "orientation"> {
|
|
47
|
+
/**
|
|
48
|
+
* Axis used to interpret Arrow-key movement.
|
|
49
|
+
* @since 1.0.0
|
|
50
|
+
* @category models
|
|
51
|
+
*/
|
|
52
|
+
readonly orientation: "vertical";
|
|
53
|
+
/**
|
|
54
|
+
* Stable id used for collection identity and ARIA relationships.
|
|
55
|
+
* @since 1.0.0
|
|
56
|
+
* @category models
|
|
57
|
+
*/
|
|
58
|
+
readonly id: string;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the associated native popover is open.
|
|
61
|
+
* @since 1.0.0
|
|
62
|
+
* @category models
|
|
63
|
+
*/
|
|
64
|
+
readonly open: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Initial Menu values. The caller supplies id; open defaults false, activeId null, loop true, and
|
|
68
|
+
* orientation vertical.
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* ## Why
|
|
72
|
+
*
|
|
73
|
+
* Making initialization explicit documents hydration-sensitive defaults and lets servers and
|
|
74
|
+
* clients construct matching state.
|
|
75
|
+
*
|
|
76
|
+
* ## Ownership and lifetime
|
|
77
|
+
*
|
|
78
|
+
* This declaration is data or schema metadata and acquires no resources.
|
|
79
|
+
*
|
|
80
|
+
* ## Example
|
|
81
|
+
*
|
|
82
|
+
* Import with `import type { InitialState } from "@typed/ui/Menu";` Extend the [Menu.makeState
|
|
83
|
+
* runnable setup](/reference/%40typed%2Fui%2FMenu%23makeState). Construct a closed menu with
|
|
84
|
+
* `const initial: InitialState = { id: "file-menu", open: false }; const state = yield* Menu.makeState(initial)`.
|
|
85
|
+
* @since 1.0.0
|
|
86
|
+
* @category models
|
|
87
|
+
*/
|
|
88
|
+
export interface InitialState {
|
|
89
|
+
/**
|
|
90
|
+
* Stable id used for collection identity and ARIA relationships.
|
|
91
|
+
* @since 1.0.0
|
|
92
|
+
* @category models
|
|
93
|
+
*/
|
|
94
|
+
readonly id: string;
|
|
95
|
+
/**
|
|
96
|
+
* Whether the associated native popover is open.
|
|
97
|
+
* @since 1.0.0
|
|
98
|
+
* @category models
|
|
99
|
+
*/
|
|
100
|
+
readonly open?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Id currently active for keyboard navigation; null means no active item.
|
|
103
|
+
* @since 1.0.0
|
|
104
|
+
* @category models
|
|
105
|
+
*/
|
|
106
|
+
readonly activeId?: string | null;
|
|
107
|
+
/**
|
|
108
|
+
* Whether movement wraps between the first and last enabled items.
|
|
109
|
+
* @since 1.0.0
|
|
110
|
+
* @category models
|
|
111
|
+
*/
|
|
112
|
+
readonly loop?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Effect Schema used by makeState to encode, decode, and hydrate Menu state.
|
|
116
|
+
*
|
|
117
|
+
* @remarks
|
|
118
|
+
* ## Why
|
|
119
|
+
*
|
|
120
|
+
* A public schema makes hydration and serialized state use the same runtime validation as direct
|
|
121
|
+
* construction.
|
|
122
|
+
*
|
|
123
|
+
* ## Ownership and lifetime
|
|
124
|
+
*
|
|
125
|
+
* This declaration is data or schema metadata and acquires no resources.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* import * as Schema from "effect/Schema";
|
|
130
|
+
* import * as Menu from "@typed/ui/Menu";
|
|
131
|
+
*
|
|
132
|
+
* const decodeState = Schema.decodeUnknownEffect(Menu.StateSchema);
|
|
133
|
+
* ```
|
|
134
|
+
* @since 1.0.0
|
|
135
|
+
* @category schemas
|
|
136
|
+
*/
|
|
137
|
+
export declare const StateSchema: Schema.Struct<{
|
|
138
|
+
readonly id: Schema.String;
|
|
139
|
+
readonly open: Schema.Boolean;
|
|
140
|
+
readonly activeId: Schema.NullOr<Schema.String>;
|
|
141
|
+
readonly orientation: Schema.Literals<readonly ["vertical"]>;
|
|
142
|
+
readonly loop: Schema.Boolean;
|
|
143
|
+
readonly rtl: Schema.Boolean;
|
|
144
|
+
readonly virtualFocus: Schema.Boolean;
|
|
145
|
+
}>;
|
|
146
|
+
/**
|
|
147
|
+
* Creates hydrated Menu state. The caller supplies id; open defaults false, activeId null, loop
|
|
148
|
+
* true, and orientation vertical.
|
|
149
|
+
*
|
|
150
|
+
* @remarks
|
|
151
|
+
* ## Why
|
|
152
|
+
*
|
|
153
|
+
* State and collection ownership can be composed and tested independently from any renderer.
|
|
154
|
+
*
|
|
155
|
+
* ## Ownership and lifetime
|
|
156
|
+
*
|
|
157
|
+
* The returned Effect creates the RefSubject when run. That state is renderer-independent;
|
|
158
|
+
* collection registrations belong to the separate Scope that runs register or ref, not to state
|
|
159
|
+
* creation.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* import * as Effect from "effect/Effect";
|
|
164
|
+
* import * as Menu from "@typed/ui/Menu";
|
|
165
|
+
*
|
|
166
|
+
* const program = Effect.scoped(
|
|
167
|
+
* Effect.gen(function* () {
|
|
168
|
+
* const state = yield* Menu.makeState({ id: "file-menu" });
|
|
169
|
+
* const collection = yield* Menu.makeCollection();
|
|
170
|
+
* return { state: yield* state, collection: yield* collection };
|
|
171
|
+
* }),
|
|
172
|
+
* );
|
|
173
|
+
* ```
|
|
174
|
+
* @since 1.0.0
|
|
175
|
+
* @category constructors
|
|
176
|
+
*/
|
|
177
|
+
export declare function makeState(initial: InitialState): Effect.Effect<RefSubject.HydratedRefSubject<{
|
|
178
|
+
readonly id: string;
|
|
179
|
+
readonly open: boolean;
|
|
180
|
+
readonly activeId: string | null;
|
|
181
|
+
readonly orientation: "vertical";
|
|
182
|
+
readonly loop: boolean;
|
|
183
|
+
readonly rtl: boolean;
|
|
184
|
+
readonly virtualFocus: boolean;
|
|
185
|
+
}, Schema.SchemaError, never, never>, never, Scope.Scope>;
|
|
186
|
+
/**
|
|
187
|
+
* Creates a scoped Collection for Menu items.
|
|
188
|
+
*
|
|
189
|
+
* @remarks
|
|
190
|
+
* ## Why
|
|
191
|
+
*
|
|
192
|
+
* State and collection ownership can be composed and tested independently from any renderer.
|
|
193
|
+
*
|
|
194
|
+
* ## Ownership and lifetime
|
|
195
|
+
*
|
|
196
|
+
* The returned Effect allocates the RefSubject in the caller's Scope. Each later registration is
|
|
197
|
+
* owned by the Scope that runs register, independently of this construction Effect.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* import * as Effect from "effect/Effect";
|
|
202
|
+
* import * as Menu from "@typed/ui/Menu";
|
|
203
|
+
*
|
|
204
|
+
* const program = Effect.scoped(
|
|
205
|
+
* Effect.gen(function* () {
|
|
206
|
+
* const collection = yield* Menu.makeCollection();
|
|
207
|
+
* return yield* collection;
|
|
208
|
+
* }),
|
|
209
|
+
* );
|
|
210
|
+
* ```
|
|
211
|
+
* @since 1.0.0
|
|
212
|
+
* @category constructors
|
|
213
|
+
*/
|
|
214
|
+
export declare const makeCollection: (initial?: Collection.State<string, Element>) => Effect.Effect<RefSubject.RefSubject<Collection.State<string, Element>, never, never>, never, Scope.Scope>;
|
|
215
|
+
/**
|
|
216
|
+
* Updates only the menu's explicit open state.
|
|
217
|
+
*
|
|
218
|
+
* @remarks
|
|
219
|
+
* ## Why
|
|
220
|
+
*
|
|
221
|
+
* The operation exposes Menu's transition directly so callers can compose it in Effect programs
|
|
222
|
+
* and native event handlers.
|
|
223
|
+
*
|
|
224
|
+
* ## Ownership and lifetime
|
|
225
|
+
*
|
|
226
|
+
* The returned Effect performs the update or DOM side effect only when run, preserves the declared
|
|
227
|
+
* error and service channels, and retains no resources after completion.
|
|
228
|
+
*
|
|
229
|
+
* ## Example
|
|
230
|
+
*
|
|
231
|
+
* Import with `import { setOpen } from "@typed/ui/Menu";` Extend the [Menu.makeState runnable
|
|
232
|
+
* setup](/reference/%40typed%2Fui%2FMenu%23makeState). Inside the linked Effect program invoke
|
|
233
|
+
* `yield* setOpen(state, true)`, then read state to observe `open: true` without changing focus or
|
|
234
|
+
* menu identity.
|
|
235
|
+
* @since 1.0.0
|
|
236
|
+
* @category combinators
|
|
237
|
+
*/
|
|
238
|
+
export declare function setOpen<E, R>(state: RefSubject.RefSubject<State, E, R>, open: boolean): Effect.Effect<State, E, R>;
|
|
239
|
+
/**
|
|
240
|
+
* Inputs accepted by Menu.Trigger in addition to the shared DOM host options.
|
|
241
|
+
*
|
|
242
|
+
* @remarks
|
|
243
|
+
* ## Why
|
|
244
|
+
*
|
|
245
|
+
* Separator orientation is an accessibility announcement only, so it remains independent from the
|
|
246
|
+
* orientation used by menu keyboard navigation.
|
|
247
|
+
*
|
|
248
|
+
* ## Ownership and lifetime
|
|
249
|
+
*
|
|
250
|
+
* This declaration is data or schema metadata and acquires no resources.
|
|
251
|
+
*
|
|
252
|
+
* ## Example
|
|
253
|
+
*
|
|
254
|
+
* Import with `import type { TriggerOptions } from "@typed/ui/Menu";` Extend the [Menu.makeState
|
|
255
|
+
* runnable setup](/reference/%40typed%2Fui%2FMenu%23makeState). A native popover trigger accepts
|
|
256
|
+
* `const options: TriggerOptions = { state, content: "File" }`.
|
|
257
|
+
* @since 1.0.0
|
|
258
|
+
* @category models
|
|
259
|
+
*/
|
|
260
|
+
export interface TriggerOptions extends Dom.HostOptions<HTMLButtonElement> {
|
|
261
|
+
/**
|
|
262
|
+
* Renderer-independent RefSubject state consumed by this component or operation.
|
|
263
|
+
* @since 1.0.0
|
|
264
|
+
* @category models
|
|
265
|
+
*/
|
|
266
|
+
readonly state: RefSubject.HydratedRefSubject<State, Schema.SchemaError>;
|
|
267
|
+
/**
|
|
268
|
+
* Renderable child content for the component host.
|
|
269
|
+
* @since 1.0.0
|
|
270
|
+
* @category models
|
|
271
|
+
*/
|
|
272
|
+
readonly content: Renderable.Any;
|
|
273
|
+
}
|
|
274
|
+
declare function triggerProps<const Options extends TriggerOptions>(options: Options): () => {
|
|
275
|
+
readonly type: "button";
|
|
276
|
+
readonly popovertarget: RefSubject.Computed<string, Schema.SchemaError, never>;
|
|
277
|
+
readonly popovertargetaction: "toggle";
|
|
278
|
+
readonly "aria-haspopup": "menu";
|
|
279
|
+
readonly "aria-expanded": RefSubject.Computed<boolean, Schema.SchemaError, never>;
|
|
280
|
+
readonly onkeydown: EventHandler.EventHandler<KeyboardEvent, never, never>;
|
|
281
|
+
readonly ref: import("./Dom/Refs.js").ComposedRef<RefSubject.HydratedRefSubject<State, Schema.SchemaError, never, never>, (element: globalThis.Element) => Effect.Effect<void, never, Scope.Scope>> | undefined;
|
|
282
|
+
};
|
|
283
|
+
type TriggerProps<Options extends TriggerOptions> = ReturnType<ReturnType<typeof triggerProps<Options>>>;
|
|
284
|
+
/**
|
|
285
|
+
* Renders a native button targeting menu popover content and opens the menu on ArrowDown.
|
|
286
|
+
*
|
|
287
|
+
* @remarks
|
|
288
|
+
* ## Why
|
|
289
|
+
*
|
|
290
|
+
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
291
|
+
* through the shared DOM boundary.
|
|
292
|
+
*
|
|
293
|
+
* ## Ownership and lifetime
|
|
294
|
+
*
|
|
295
|
+
* The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
|
|
296
|
+
* collection registrations only when rendered. The rendering Scope removes those resources;
|
|
297
|
+
* unrelated nodes and attributes remain caller-owned.
|
|
298
|
+
*
|
|
299
|
+
* ## Example
|
|
300
|
+
*
|
|
301
|
+
* Import with `import { Trigger } from "@typed/ui/Menu";` Extend the [Menu.makeState runnable
|
|
302
|
+
* setup](/reference/%40typed%2Fui%2FMenu%23makeState). Replace the linked program's final snapshot
|
|
303
|
+
* read with `Trigger({ state, content: "File" })`; render that Fx before the same Scope closes.
|
|
304
|
+
* @since 1.0.0
|
|
305
|
+
* @category components
|
|
306
|
+
*/
|
|
307
|
+
export declare function Trigger<const Options extends TriggerOptions, const Host extends HostResult = never>(options: Options, host?: Dom.HostOverride<Dom.RenderHostProps<Options, TriggerProps<Options>>, Options["content"], Host>): Fx<RenderEvent, Renderable.Error<Options | Host>, Renderable.Services<Options | Host> | Scope.Scope | RenderTemplate>;
|
|
308
|
+
/**
|
|
309
|
+
* Consumer-facing alias of the canonical Menu component with identical behavior and lifetime.
|
|
310
|
+
*
|
|
311
|
+
* @remarks
|
|
312
|
+
* ## Why
|
|
313
|
+
*
|
|
314
|
+
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
315
|
+
* through the shared DOM boundary.
|
|
316
|
+
*
|
|
317
|
+
* ## Ownership and lifetime
|
|
318
|
+
*
|
|
319
|
+
* The alias acquires nothing. Rendering it has exactly the canonical component's Scope and DOM
|
|
320
|
+
* ownership contract.
|
|
321
|
+
*
|
|
322
|
+
* ## Example
|
|
323
|
+
*
|
|
324
|
+
* Import with `import { Button } from "@typed/ui/Menu";` Extend the [Menu.makeState runnable
|
|
325
|
+
* setup](/reference/%40typed%2Fui%2FMenu%23makeState). Replace the linked program's final snapshot
|
|
326
|
+
* read with `Button({ state, content: "File" })`; render that Fx before the same Scope closes.
|
|
327
|
+
* @since 1.0.0
|
|
328
|
+
* @category components
|
|
329
|
+
*/
|
|
330
|
+
export declare const Button: typeof Trigger;
|
|
331
|
+
/**
|
|
332
|
+
* Inputs accepted by Menu.Content in addition to the shared DOM host options.
|
|
333
|
+
*
|
|
334
|
+
* @remarks
|
|
335
|
+
* ## Why
|
|
336
|
+
*
|
|
337
|
+
* The model makes popup content, optional collection navigation, and optional parent-menu linkage
|
|
338
|
+
* explicit while retaining the shared custom-host boundary.
|
|
339
|
+
*
|
|
340
|
+
* ## Ownership and lifetime
|
|
341
|
+
*
|
|
342
|
+
* This declaration is data or schema metadata and acquires no resources.
|
|
343
|
+
*
|
|
344
|
+
* ## Example
|
|
345
|
+
*
|
|
346
|
+
* Import with `import type { ContentOptions } from "@typed/ui/Menu";` Extend the [Menu.makeState
|
|
347
|
+
* runnable setup](/reference/%40typed%2Fui%2FMenu%23makeState). Enable menu movement with
|
|
348
|
+
* `const options: ContentOptions = { state, collection, label: "File", content: "Commands" }`.
|
|
349
|
+
* @since 1.0.0
|
|
350
|
+
* @category models
|
|
351
|
+
*/
|
|
352
|
+
export interface ContentOptions extends Dom.HostOptions<HTMLDivElement> {
|
|
353
|
+
/**
|
|
354
|
+
* Renderer-independent RefSubject state consumed by this component or operation.
|
|
355
|
+
* @since 1.0.0
|
|
356
|
+
* @category models
|
|
357
|
+
*/
|
|
358
|
+
readonly state: RefSubject.HydratedRefSubject<State, Schema.SchemaError>;
|
|
359
|
+
/**
|
|
360
|
+
* Item registry used for collection-driven keyboard behavior and mounted ordering.
|
|
361
|
+
* @since 1.0.0
|
|
362
|
+
* @category models
|
|
363
|
+
*/
|
|
364
|
+
readonly collection?: RefSubject.RefSubject<Collection.State<string>>;
|
|
365
|
+
/**
|
|
366
|
+
* Parent-menu state and collection used for nested directional navigation and focus return.
|
|
367
|
+
* @since 1.0.0
|
|
368
|
+
* @category models
|
|
369
|
+
*/
|
|
370
|
+
readonly parent?: ParentMenu;
|
|
371
|
+
/**
|
|
372
|
+
* Renderable child content for the component host.
|
|
373
|
+
* @since 1.0.0
|
|
374
|
+
* @category models
|
|
375
|
+
*/
|
|
376
|
+
readonly content: Renderable.Any;
|
|
377
|
+
/**
|
|
378
|
+
* Accessible label rendered through aria-label.
|
|
379
|
+
* @since 1.0.0
|
|
380
|
+
* @category models
|
|
381
|
+
*/
|
|
382
|
+
readonly label?: Renderable.Any<string | null | undefined>;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Public Menu.ParentMenu behavioral model.
|
|
386
|
+
*
|
|
387
|
+
* @remarks
|
|
388
|
+
* ## Why
|
|
389
|
+
*
|
|
390
|
+
* The public model lets custom composites reuse Menu's deterministic policy without copying an
|
|
391
|
+
* internal shape.
|
|
392
|
+
*
|
|
393
|
+
* ## Ownership and lifetime
|
|
394
|
+
*
|
|
395
|
+
* This declaration is data or schema metadata and acquires no resources.
|
|
396
|
+
*
|
|
397
|
+
* ## Example
|
|
398
|
+
*
|
|
399
|
+
* Import with `import type { ParentMenu } from "@typed/ui/Menu";` Extend the [Menu.makeState
|
|
400
|
+
* runnable setup](/reference/%40typed%2Fui%2FMenu%23makeState). Nested menus carry their parent
|
|
401
|
+
* navigation pair explicitly: `const parent: ParentMenu = { state, collection }`.
|
|
402
|
+
* @since 1.0.0
|
|
403
|
+
* @category models
|
|
404
|
+
*/
|
|
405
|
+
export interface ParentMenu {
|
|
406
|
+
/**
|
|
407
|
+
* Renderer-independent RefSubject state consumed by this component or operation.
|
|
408
|
+
* @since 1.0.0
|
|
409
|
+
* @category models
|
|
410
|
+
*/
|
|
411
|
+
readonly state: RefSubject.HydratedRefSubject<State, Schema.SchemaError>;
|
|
412
|
+
/**
|
|
413
|
+
* Item registry used for collection-driven keyboard behavior and mounted ordering.
|
|
414
|
+
* @since 1.0.0
|
|
415
|
+
* @category models
|
|
416
|
+
*/
|
|
417
|
+
readonly collection: RefSubject.RefSubject<Collection.State<string>>;
|
|
418
|
+
/**
|
|
419
|
+
* Id of the trigger that owns this menu and receives focus when the menu closes.
|
|
420
|
+
* @since 1.0.0
|
|
421
|
+
* @category models
|
|
422
|
+
*/
|
|
423
|
+
readonly triggerId: string;
|
|
424
|
+
}
|
|
425
|
+
declare function contentProps<const Options extends ContentOptions>(options: Options): ({ property }: Dom.InternalPropsHelpers<Options>) => {
|
|
426
|
+
readonly id: RefSubject.Computed<string, Schema.SchemaError, never>;
|
|
427
|
+
readonly role: "menu";
|
|
428
|
+
readonly popover: "manual";
|
|
429
|
+
readonly "aria-label": Exclude<Dom.Property<Options, "label">, Dom.Nullish> | undefined;
|
|
430
|
+
readonly onkeydown: EventHandler.EventHandler<KeyboardEvent, Schema.SchemaError, never> | undefined;
|
|
431
|
+
readonly ontoggle: EventHandler.EventHandler<Event, Schema.SchemaError, never>;
|
|
432
|
+
readonly ref: import("./Dom/Refs.js").ComposedRef<RefSubject.HydratedRefSubject<State, Schema.SchemaError, never, never>, (element: HTMLElement) => Effect.Effect<void, Schema.SchemaError, Scope.Scope>> | undefined;
|
|
433
|
+
};
|
|
434
|
+
type ContentProps<Options extends ContentOptions> = ReturnType<ReturnType<typeof contentProps<Options>>>;
|
|
435
|
+
/**
|
|
436
|
+
* Renders manual-popover menu content and coordinates focus, typeahead, Escape, and nested-menu
|
|
437
|
+
* traversal.
|
|
438
|
+
*
|
|
439
|
+
* @remarks
|
|
440
|
+
* ## Why
|
|
441
|
+
*
|
|
442
|
+
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
443
|
+
* through the shared DOM boundary.
|
|
444
|
+
*
|
|
445
|
+
* ## Ownership and lifetime
|
|
446
|
+
*
|
|
447
|
+
* The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
|
|
448
|
+
* collection registrations only when rendered. The rendering Scope removes those resources;
|
|
449
|
+
* unrelated nodes and attributes remain caller-owned.
|
|
450
|
+
*
|
|
451
|
+
* ## Example
|
|
452
|
+
*
|
|
453
|
+
* Import with `import { Content } from "@typed/ui/Menu";` Extend the [Menu.makeState runnable
|
|
454
|
+
* setup](/reference/%40typed%2Fui%2FMenu%23makeState). Replace the linked program's final snapshot
|
|
455
|
+
* read with `Content({ state, label: "File", content: "Commands" })`; render that Fx before the
|
|
456
|
+
* same Scope closes.
|
|
457
|
+
* @since 1.0.0
|
|
458
|
+
* @category components
|
|
459
|
+
*/
|
|
460
|
+
export declare function Content<const Options extends ContentOptions, const Host extends HostResult = never>(options: Options, host?: Dom.HostOverride<Dom.RenderHostProps<Options, ContentProps<Options>>, Options["content"], Host>): Fx<RenderEvent, Renderable.Error<Options | Host>, Renderable.Services<Options | Host> | Scope.Scope | RenderTemplate>;
|
|
461
|
+
/**
|
|
462
|
+
* Consumer-facing alias of the canonical Menu component with identical behavior and lifetime.
|
|
463
|
+
*
|
|
464
|
+
* @remarks
|
|
465
|
+
* ## Why
|
|
466
|
+
*
|
|
467
|
+
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
468
|
+
* through the shared DOM boundary.
|
|
469
|
+
*
|
|
470
|
+
* ## Ownership and lifetime
|
|
471
|
+
*
|
|
472
|
+
* The alias acquires nothing. Rendering it has exactly the canonical component's Scope and DOM
|
|
473
|
+
* ownership contract.
|
|
474
|
+
*
|
|
475
|
+
* ## Example
|
|
476
|
+
*
|
|
477
|
+
* Import with `import { Menu } from "@typed/ui/Menu";` Extend the [Menu.makeState runnable
|
|
478
|
+
* setup](/reference/%40typed%2Fui%2FMenu%23makeState). Replace the linked program's final snapshot
|
|
479
|
+
* read with `Menu({ state, label: "File", content: "Commands" })`; render that Fx before the same
|
|
480
|
+
* Scope closes.
|
|
481
|
+
* @since 1.0.0
|
|
482
|
+
* @category components
|
|
483
|
+
*/
|
|
484
|
+
export declare const Menu: typeof Content;
|
|
485
|
+
/**
|
|
486
|
+
* Inputs accepted by Menu.Item in addition to the shared DOM host options.
|
|
487
|
+
*
|
|
488
|
+
* @remarks
|
|
489
|
+
* ## Why
|
|
490
|
+
*
|
|
491
|
+
* The model makes item identity, content, optional registration metadata, and state ownership
|
|
492
|
+
* explicit before the item is rendered.
|
|
493
|
+
*
|
|
494
|
+
* ## Ownership and lifetime
|
|
495
|
+
*
|
|
496
|
+
* This declaration is data or schema metadata and acquires no resources.
|
|
497
|
+
*
|
|
498
|
+
* ## Example
|
|
499
|
+
*
|
|
500
|
+
* Import with `import type { ItemOptions } from "@typed/ui/Menu";` Extend the [Menu.makeState
|
|
501
|
+
* runnable setup](/reference/%40typed%2Fui%2FMenu%23makeState). A menu command is
|
|
502
|
+
* `const options: ItemOptions = { state, collection, id: "save", content: "Save" }`.
|
|
503
|
+
* @since 1.0.0
|
|
504
|
+
* @category models
|
|
505
|
+
*/
|
|
506
|
+
export interface ItemOptions extends Dom.HostOptions<HTMLDivElement> {
|
|
507
|
+
/**
|
|
508
|
+
* Renderer-independent RefSubject state consumed by this component or operation.
|
|
509
|
+
* @since 1.0.0
|
|
510
|
+
* @category models
|
|
511
|
+
*/
|
|
512
|
+
readonly state: RefSubject.HydratedRefSubject<State, Schema.SchemaError>;
|
|
513
|
+
/**
|
|
514
|
+
* Item registry used for collection-driven keyboard behavior and mounted ordering.
|
|
515
|
+
* @since 1.0.0
|
|
516
|
+
* @category models
|
|
517
|
+
*/
|
|
518
|
+
readonly collection?: RefSubject.RefSubject<Collection.State<string>>;
|
|
519
|
+
/**
|
|
520
|
+
* Stable id used for collection identity and ARIA relationships.
|
|
521
|
+
* @since 1.0.0
|
|
522
|
+
* @category models
|
|
523
|
+
*/
|
|
524
|
+
readonly id: string;
|
|
525
|
+
/**
|
|
526
|
+
* Renderable child content for the component host.
|
|
527
|
+
* @since 1.0.0
|
|
528
|
+
* @category models
|
|
529
|
+
*/
|
|
530
|
+
readonly content: Renderable.Any;
|
|
531
|
+
/**
|
|
532
|
+
* Search text used by typeahead independently of rendered markup.
|
|
533
|
+
* @since 1.0.0
|
|
534
|
+
* @category models
|
|
535
|
+
*/
|
|
536
|
+
readonly textValue?: string;
|
|
537
|
+
/**
|
|
538
|
+
* Flag used by collection movement and widget handlers to skip activation by default.
|
|
539
|
+
* @since 1.0.0
|
|
540
|
+
* @category models
|
|
541
|
+
*/
|
|
542
|
+
readonly disabled?: boolean;
|
|
543
|
+
/**
|
|
544
|
+
* ARIA role emitted by the item variant.
|
|
545
|
+
* @since 1.0.0
|
|
546
|
+
* @category models
|
|
547
|
+
*/
|
|
548
|
+
readonly role?: "menuitem" | "menuitemcheckbox" | "menuitemradio";
|
|
549
|
+
/**
|
|
550
|
+
* Checked state exposed by checkbox and radio menu-item variants.
|
|
551
|
+
* @since 1.0.0
|
|
552
|
+
* @category models
|
|
553
|
+
*/
|
|
554
|
+
readonly checked?: Renderable.Any<boolean | null | undefined>;
|
|
555
|
+
}
|
|
556
|
+
declare function itemProps<const Options extends ItemOptions>(options: Options): () => {
|
|
557
|
+
readonly id: string;
|
|
558
|
+
readonly role: "menuitem" | "menuitemcheckbox" | "menuitemradio";
|
|
559
|
+
readonly "aria-disabled": boolean;
|
|
560
|
+
readonly "aria-checked": boolean | Effect.Effect<boolean | null | undefined, any, any> | Fx<boolean | null | undefined, any, any> | RefSubject.HydrationRef<any, any> | import("@typed/template").Many<unknown, any, any> | readonly Renderable<never, any, any>[] | readonly Renderable<boolean | null | undefined, any, any>[] | import("effect/Stream").Stream<boolean | null | undefined, any, any> | {
|
|
561
|
+
readonly [key: string]: unknown;
|
|
562
|
+
} | undefined;
|
|
563
|
+
readonly tabindex: RefSubject.Computed<-1 | 0, Schema.SchemaError, never>;
|
|
564
|
+
readonly onclick: Effect.Effect<void, never, never> | Effect.Effect<State, Schema.SchemaError, never>;
|
|
565
|
+
readonly onfocus: Effect.Effect<State, Schema.SchemaError, never>;
|
|
566
|
+
readonly onmouseenter: Effect.Effect<State, Schema.SchemaError, never>;
|
|
567
|
+
readonly ref: ((element: Element & HTMLDivElement & RefSubject.HydrationElement) => Effect.Effect<void, any, any>) | undefined;
|
|
568
|
+
};
|
|
569
|
+
type ItemProps<Options extends ItemOptions> = ReturnType<ReturnType<typeof itemProps<Options>>>;
|
|
570
|
+
/**
|
|
571
|
+
* Renders and optionally registers a menu item; disabled items remain announced but do not
|
|
572
|
+
* activate.
|
|
573
|
+
*
|
|
574
|
+
* @remarks
|
|
575
|
+
* ## Why
|
|
576
|
+
*
|
|
577
|
+
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
578
|
+
* through the shared DOM boundary.
|
|
579
|
+
*
|
|
580
|
+
* ## Ownership and lifetime
|
|
581
|
+
*
|
|
582
|
+
* The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
|
|
583
|
+
* collection registrations only when rendered. The rendering Scope removes those resources;
|
|
584
|
+
* unrelated nodes and attributes remain caller-owned.
|
|
585
|
+
*
|
|
586
|
+
* ## Example
|
|
587
|
+
*
|
|
588
|
+
* Import with `import { Item } from "@typed/ui/Menu";` Extend the [Menu.makeState runnable
|
|
589
|
+
* setup](/reference/%40typed%2Fui%2FMenu%23makeState). Replace the linked program's final snapshot
|
|
590
|
+
* read with `Item({ state, id: "save", content: "Save" })`; render that Fx before the same Scope
|
|
591
|
+
* closes.
|
|
592
|
+
* @since 1.0.0
|
|
593
|
+
* @category components
|
|
594
|
+
*/
|
|
595
|
+
export declare function Item<const Options extends ItemOptions, const Host extends HostResult = never>(options: Options, host?: Dom.HostOverride<Dom.RenderHostProps<Options, ItemProps<Options>>, Options["content"], Host>): Fx<RenderEvent, Renderable.Error<Options | Host>, Renderable.Services<Options | Host> | Scope.Scope | RenderTemplate>;
|
|
596
|
+
/**
|
|
597
|
+
* Inputs accepted by Menu.SubmenuTrigger in addition to the shared DOM host options.
|
|
598
|
+
*
|
|
599
|
+
* @remarks
|
|
600
|
+
* ## Why
|
|
601
|
+
*
|
|
602
|
+
* The options type makes required state, content, accessible relationships, and custom-host inputs
|
|
603
|
+
* visible before rendering.
|
|
604
|
+
*
|
|
605
|
+
* ## Ownership and lifetime
|
|
606
|
+
*
|
|
607
|
+
* This declaration is data or schema metadata and acquires no resources.
|
|
608
|
+
*
|
|
609
|
+
* ## Example
|
|
610
|
+
*
|
|
611
|
+
* Import with `import type { SubmenuTriggerOptions } from "@typed/ui/Menu";` Extend the
|
|
612
|
+
* [Menu.makeState runnable setup](/reference/%40typed%2Fui%2FMenu%23makeState). After
|
|
613
|
+
* `const submenu = yield* Menu.makeState({ id: "share-menu" })`, use
|
|
614
|
+
* `const options: SubmenuTriggerOptions<State> = { state, submenu, collection, id: "share", content: "Share" }`.
|
|
615
|
+
* @since 1.0.0
|
|
616
|
+
* @category models
|
|
617
|
+
*/
|
|
618
|
+
export interface SubmenuTriggerOptions<ParentState extends Composite.State> extends Dom.HostOptions<HTMLButtonElement> {
|
|
619
|
+
/**
|
|
620
|
+
* Renderer-independent RefSubject state consumed by this component or operation.
|
|
621
|
+
* @since 1.0.0
|
|
622
|
+
* @category models
|
|
623
|
+
*/
|
|
624
|
+
readonly state: RefSubject.HydratedRefSubject<ParentState, Schema.SchemaError>;
|
|
625
|
+
/**
|
|
626
|
+
* Whether the item participates as a submenu entry.
|
|
627
|
+
* @since 1.0.0
|
|
628
|
+
* @category models
|
|
629
|
+
*/
|
|
630
|
+
readonly submenu: RefSubject.HydratedRefSubject<State, Schema.SchemaError>;
|
|
631
|
+
/**
|
|
632
|
+
* Item registry used for collection-driven keyboard behavior and mounted ordering.
|
|
633
|
+
* @since 1.0.0
|
|
634
|
+
* @category models
|
|
635
|
+
*/
|
|
636
|
+
readonly collection?: RefSubject.RefSubject<Collection.State<string>>;
|
|
637
|
+
/**
|
|
638
|
+
* Stable id used for collection identity and ARIA relationships.
|
|
639
|
+
* @since 1.0.0
|
|
640
|
+
* @category models
|
|
641
|
+
*/
|
|
642
|
+
readonly id: string;
|
|
643
|
+
/**
|
|
644
|
+
* Renderable child content for the component host.
|
|
645
|
+
* @since 1.0.0
|
|
646
|
+
* @category models
|
|
647
|
+
*/
|
|
648
|
+
readonly content: Renderable.Any;
|
|
649
|
+
/**
|
|
650
|
+
* Search text used by typeahead independently of rendered markup.
|
|
651
|
+
* @since 1.0.0
|
|
652
|
+
* @category models
|
|
653
|
+
*/
|
|
654
|
+
readonly textValue?: string;
|
|
655
|
+
/**
|
|
656
|
+
* Flag used by collection movement and widget handlers to skip activation by default.
|
|
657
|
+
* @since 1.0.0
|
|
658
|
+
* @category models
|
|
659
|
+
*/
|
|
660
|
+
readonly disabled?: boolean;
|
|
661
|
+
}
|
|
662
|
+
declare function submenuTriggerProps<ParentState extends Composite.State, const Options extends SubmenuTriggerOptions<ParentState>>(options: Options): () => {
|
|
663
|
+
readonly id: string;
|
|
664
|
+
readonly type: "button";
|
|
665
|
+
readonly role: "menuitem";
|
|
666
|
+
readonly popovertarget: RefSubject.Computed<string, Schema.SchemaError, never>;
|
|
667
|
+
readonly popovertargetaction: "toggle";
|
|
668
|
+
readonly "aria-haspopup": "menu";
|
|
669
|
+
readonly "aria-expanded": RefSubject.Computed<boolean, Schema.SchemaError, never>;
|
|
670
|
+
readonly "aria-disabled": boolean;
|
|
671
|
+
readonly tabindex: RefSubject.Computed<-1 | 0, Schema.SchemaError, never>;
|
|
672
|
+
readonly onclick: Effect.Effect<void, never, never> | Effect.Effect<ParentState, Schema.SchemaError, never>;
|
|
673
|
+
readonly onfocus: Effect.Effect<ParentState, Schema.SchemaError, never>;
|
|
674
|
+
readonly onmouseenter: Effect.Effect<void, never, never> | Effect.Effect<State, Schema.SchemaError, never>;
|
|
675
|
+
readonly ref: ((element: Element & HTMLButtonElement & RefSubject.HydrationElement) => Effect.Effect<void, any, any>) | undefined;
|
|
676
|
+
};
|
|
677
|
+
type SubmenuTriggerProps<ParentState extends Composite.State, Options extends SubmenuTriggerOptions<ParentState>> = ReturnType<ReturnType<typeof submenuTriggerProps<ParentState, Options>>>;
|
|
678
|
+
/**
|
|
679
|
+
* Renders a menuitem that targets nested popover content and coordinates parent/child directional
|
|
680
|
+
* focus.
|
|
681
|
+
*
|
|
682
|
+
* @remarks
|
|
683
|
+
* ## Why
|
|
684
|
+
*
|
|
685
|
+
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
686
|
+
* through the shared DOM boundary.
|
|
687
|
+
*
|
|
688
|
+
* ## Ownership and lifetime
|
|
689
|
+
*
|
|
690
|
+
* The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
|
|
691
|
+
* collection registrations only when rendered. The rendering Scope removes those resources;
|
|
692
|
+
* unrelated nodes and attributes remain caller-owned.
|
|
693
|
+
*
|
|
694
|
+
* ## Example
|
|
695
|
+
*
|
|
696
|
+
* Import with `import { SubmenuTrigger } from "@typed/ui/Menu";` Extend the [Menu.makeState
|
|
697
|
+
* runnable setup](/reference/%40typed%2Fui%2FMenu%23makeState). Replace the linked program's final
|
|
698
|
+
* snapshot read after `const submenu = yield* Menu.makeState({ id: "share-menu" })` with
|
|
699
|
+
* `SubmenuTrigger({ state, submenu, collection, id: "share", content: "Share" })`; render that Fx
|
|
700
|
+
* before the same Scope closes.
|
|
701
|
+
* @since 1.0.0
|
|
702
|
+
* @category components
|
|
703
|
+
*/
|
|
704
|
+
export declare function SubmenuTrigger<ParentState extends Composite.State, const Options extends SubmenuTriggerOptions<NoInfer<ParentState>>, const Host extends HostResult = never>(options: Options & {
|
|
705
|
+
readonly state: RefSubject.HydratedRefSubject<ParentState, Schema.SchemaError>;
|
|
706
|
+
}, host?: Dom.HostOverride<Dom.RenderHostProps<Options, SubmenuTriggerProps<ParentState, Options>>, Options["content"], Host>): Fx<RenderEvent, Renderable.Error<Options | Host>, Renderable.Services<Options | Host> | Scope.Scope | RenderTemplate>;
|
|
707
|
+
/**
|
|
708
|
+
* Inputs accepted by Menu.CheckboxItem in addition to the shared DOM host options.
|
|
709
|
+
*
|
|
710
|
+
* @remarks
|
|
711
|
+
* ## Why
|
|
712
|
+
*
|
|
713
|
+
* The options type makes required state, content, accessible relationships, and custom-host inputs
|
|
714
|
+
* visible before rendering.
|
|
715
|
+
*
|
|
716
|
+
* ## Ownership and lifetime
|
|
717
|
+
*
|
|
718
|
+
* This declaration is data or schema metadata and acquires no resources.
|
|
719
|
+
*
|
|
720
|
+
* ## Example
|
|
721
|
+
*
|
|
722
|
+
* Import with `import type { CheckboxItemOptions } from "@typed/ui/Menu";` Extend the
|
|
723
|
+
* [Menu.makeState runnable setup](/reference/%40typed%2Fui%2FMenu%23makeState). A checked command
|
|
724
|
+
* is
|
|
725
|
+
* `const options: CheckboxItemOptions = { state, collection, id: "autosave", checked: true, content: "Autosave" }`.
|
|
726
|
+
* @since 1.0.0
|
|
727
|
+
* @category models
|
|
728
|
+
*/
|
|
729
|
+
export interface CheckboxItemOptions extends Omit<ItemOptions, "role" | "checked"> {
|
|
730
|
+
/**
|
|
731
|
+
* Checked state exposed by checkbox and radio menu-item variants.
|
|
732
|
+
* @since 1.0.0
|
|
733
|
+
* @category models
|
|
734
|
+
*/
|
|
735
|
+
readonly checked: Renderable.Any<boolean | null | undefined>;
|
|
736
|
+
}
|
|
737
|
+
type CheckboxItemWithRole<Options extends CheckboxItemOptions> = Options & {
|
|
738
|
+
readonly role: "menuitemcheckbox";
|
|
739
|
+
};
|
|
740
|
+
/**
|
|
741
|
+
* Renders Item with menuitemcheckbox semantics and caller-supplied checked state.
|
|
742
|
+
*
|
|
743
|
+
* @remarks
|
|
744
|
+
* ## Why
|
|
745
|
+
*
|
|
746
|
+
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
747
|
+
* through the shared DOM boundary.
|
|
748
|
+
*
|
|
749
|
+
* ## Ownership and lifetime
|
|
750
|
+
*
|
|
751
|
+
* The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
|
|
752
|
+
* collection registrations only when rendered. The rendering Scope removes those resources;
|
|
753
|
+
* unrelated nodes and attributes remain caller-owned.
|
|
754
|
+
*
|
|
755
|
+
* ## Example
|
|
756
|
+
*
|
|
757
|
+
* Import with `import { CheckboxItem } from "@typed/ui/Menu";` Extend the [Menu.makeState runnable
|
|
758
|
+
* setup](/reference/%40typed%2Fui%2FMenu%23makeState). Replace the linked program's final snapshot
|
|
759
|
+
* read with `CheckboxItem({ state, id: "autosave", checked: true, content: "Autosave" })`; render
|
|
760
|
+
* that Fx before the same Scope closes.
|
|
761
|
+
* @since 1.0.0
|
|
762
|
+
* @category components
|
|
763
|
+
*/
|
|
764
|
+
export declare function CheckboxItem<const Options extends CheckboxItemOptions, const Host extends HostResult = never>(options: Options, host?: Dom.HostOverride<Dom.RenderHostProps<CheckboxItemWithRole<Options>, ItemProps<CheckboxItemWithRole<Options>>>, Options["content"], Host>): Fx<RenderEvent, Renderable.Error<Options | Host>, Renderable.Services<Options | Host> | Scope.Scope | RenderTemplate>;
|
|
765
|
+
/**
|
|
766
|
+
* Inputs accepted by Menu.RadioItem in addition to the shared DOM host options.
|
|
767
|
+
*
|
|
768
|
+
* @remarks
|
|
769
|
+
* ## Why
|
|
770
|
+
*
|
|
771
|
+
* The options type makes required state, content, accessible relationships, and custom-host inputs
|
|
772
|
+
* visible before rendering.
|
|
773
|
+
*
|
|
774
|
+
* ## Ownership and lifetime
|
|
775
|
+
*
|
|
776
|
+
* This declaration is data or schema metadata and acquires no resources.
|
|
777
|
+
*
|
|
778
|
+
* ## Example
|
|
779
|
+
*
|
|
780
|
+
* Import with `import type { RadioItemOptions } from "@typed/ui/Menu";` Extend the [Menu.makeState
|
|
781
|
+
* runnable setup](/reference/%40typed%2Fui%2FMenu%23makeState). A radio command is
|
|
782
|
+
* `const options: RadioItemOptions = { state, collection, id: "compact", checked: false, content: "Compact" }`.
|
|
783
|
+
* @since 1.0.0
|
|
784
|
+
* @category models
|
|
785
|
+
*/
|
|
786
|
+
export interface RadioItemOptions extends Omit<ItemOptions, "role" | "checked"> {
|
|
787
|
+
/**
|
|
788
|
+
* Checked state exposed by checkbox and radio menu-item variants.
|
|
789
|
+
* @since 1.0.0
|
|
790
|
+
* @category models
|
|
791
|
+
*/
|
|
792
|
+
readonly checked: Renderable.Any<boolean | null | undefined>;
|
|
793
|
+
}
|
|
794
|
+
type RadioItemWithRole<Options extends RadioItemOptions> = Options & {
|
|
795
|
+
readonly role: "menuitemradio";
|
|
796
|
+
};
|
|
797
|
+
/**
|
|
798
|
+
* Renders Item with menuitemradio semantics and caller-supplied checked state.
|
|
799
|
+
*
|
|
800
|
+
* @remarks
|
|
801
|
+
* ## Why
|
|
802
|
+
*
|
|
803
|
+
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
804
|
+
* through the shared DOM boundary.
|
|
805
|
+
*
|
|
806
|
+
* ## Ownership and lifetime
|
|
807
|
+
*
|
|
808
|
+
* The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
|
|
809
|
+
* collection registrations only when rendered. The rendering Scope removes those resources;
|
|
810
|
+
* unrelated nodes and attributes remain caller-owned.
|
|
811
|
+
*
|
|
812
|
+
* ## Example
|
|
813
|
+
*
|
|
814
|
+
* Import with `import { RadioItem } from "@typed/ui/Menu";` Extend the [Menu.makeState runnable
|
|
815
|
+
* setup](/reference/%40typed%2Fui%2FMenu%23makeState). Replace the linked program's final snapshot
|
|
816
|
+
* read with `RadioItem({ state, id: "compact", checked: false, content: "Compact" })`; render that
|
|
817
|
+
* Fx before the same Scope closes.
|
|
818
|
+
* @since 1.0.0
|
|
819
|
+
* @category components
|
|
820
|
+
*/
|
|
821
|
+
export declare function RadioItem<const Options extends RadioItemOptions, const Host extends HostResult = never>(options: Options, host?: Dom.HostOverride<Dom.RenderHostProps<RadioItemWithRole<Options>, ItemProps<RadioItemWithRole<Options>>>, Options["content"], Host>): Fx<RenderEvent, Renderable.Error<Options | Host>, Renderable.Services<Options | Host> | Scope.Scope | RenderTemplate>;
|
|
822
|
+
/**
|
|
823
|
+
* Inputs accepted by Menu.Group in addition to the shared DOM host options.
|
|
824
|
+
*
|
|
825
|
+
* @remarks
|
|
826
|
+
* ## Why
|
|
827
|
+
*
|
|
828
|
+
* The options type makes required state, content, accessible relationships, and custom-host inputs
|
|
829
|
+
* visible before rendering.
|
|
830
|
+
*
|
|
831
|
+
* ## Ownership and lifetime
|
|
832
|
+
*
|
|
833
|
+
* This declaration is data or schema metadata and acquires no resources.
|
|
834
|
+
*
|
|
835
|
+
* ## Example
|
|
836
|
+
*
|
|
837
|
+
* Import with `import type { GroupOptions } from "@typed/ui/Menu";` Extend the [Menu.makeState
|
|
838
|
+
* runnable setup](/reference/%40typed%2Fui%2FMenu%23makeState). A labeled command group accepts
|
|
839
|
+
* `const options: GroupOptions = { label: "View", content: "Choices" }`.
|
|
840
|
+
* @since 1.0.0
|
|
841
|
+
* @category models
|
|
842
|
+
*/
|
|
843
|
+
export interface GroupOptions extends Dom.HostOptions<HTMLDivElement> {
|
|
844
|
+
/**
|
|
845
|
+
* Renderable child content for the component host.
|
|
846
|
+
* @since 1.0.0
|
|
847
|
+
* @category models
|
|
848
|
+
*/
|
|
849
|
+
readonly content: Renderable.Any;
|
|
850
|
+
/**
|
|
851
|
+
* Accessible label rendered through aria-label.
|
|
852
|
+
* @since 1.0.0
|
|
853
|
+
* @category models
|
|
854
|
+
*/
|
|
855
|
+
readonly label?: Renderable.Any<string | null | undefined>;
|
|
856
|
+
}
|
|
857
|
+
declare function groupProps<const Options extends GroupOptions>(_options: Options): ({ property }: Dom.InternalPropsHelpers<Options>) => {
|
|
858
|
+
readonly role: "group";
|
|
859
|
+
readonly "aria-label": Exclude<Dom.Property<Options, "label">, Dom.Nullish> | undefined;
|
|
860
|
+
};
|
|
861
|
+
type GroupProps<Options extends GroupOptions> = ReturnType<ReturnType<typeof groupProps<Options>>>;
|
|
862
|
+
/**
|
|
863
|
+
* Renders a labelled ARIA group inside menu content.
|
|
864
|
+
*
|
|
865
|
+
* @remarks
|
|
866
|
+
* ## Why
|
|
867
|
+
*
|
|
868
|
+
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
869
|
+
* through the shared DOM boundary.
|
|
870
|
+
*
|
|
871
|
+
* ## Ownership and lifetime
|
|
872
|
+
*
|
|
873
|
+
* The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
|
|
874
|
+
* collection registrations only when rendered. The rendering Scope removes those resources;
|
|
875
|
+
* unrelated nodes and attributes remain caller-owned.
|
|
876
|
+
*
|
|
877
|
+
* @example
|
|
878
|
+
* ```ts
|
|
879
|
+
* import * as Menu from "@typed/ui/Menu";
|
|
880
|
+
*
|
|
881
|
+
* const view = Menu.Group({ label: "View", content: "Choices" });
|
|
882
|
+
* ```
|
|
883
|
+
* @since 1.0.0
|
|
884
|
+
* @category components
|
|
885
|
+
*/
|
|
886
|
+
export declare function Group<const Options extends GroupOptions, const Host extends HostResult = never>(options: Options, host?: Dom.HostOverride<Dom.RenderHostProps<Options, GroupProps<Options>>, Options["content"], Host>): Fx<RenderEvent, Renderable.Error<Options | Host>, Renderable.Services<Options | Host> | Scope.Scope | RenderTemplate>;
|
|
887
|
+
/**
|
|
888
|
+
* Consumer-facing alias of the canonical Menu component with identical behavior and lifetime.
|
|
889
|
+
*
|
|
890
|
+
* @remarks
|
|
891
|
+
* ## Why
|
|
892
|
+
*
|
|
893
|
+
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
894
|
+
* through the shared DOM boundary.
|
|
895
|
+
*
|
|
896
|
+
* ## Ownership and lifetime
|
|
897
|
+
*
|
|
898
|
+
* The alias acquires nothing. Rendering it has exactly the canonical component's Scope and DOM
|
|
899
|
+
* ownership contract.
|
|
900
|
+
*
|
|
901
|
+
* ## Example
|
|
902
|
+
*
|
|
903
|
+
* Import with `import { Dismiss } from "@typed/ui/Menu";` Extend the [Menu.makeState runnable
|
|
904
|
+
* setup](/reference/%40typed%2Fui%2FMenu%23makeState). Replace the linked program's final snapshot
|
|
905
|
+
* read with `Dismiss({ state, id: "close", content: "Close" })`; render that Fx before the same
|
|
906
|
+
* Scope closes.
|
|
907
|
+
* @since 1.0.0
|
|
908
|
+
* @category components
|
|
909
|
+
*/
|
|
910
|
+
export declare const Dismiss: typeof Item;
|
|
911
|
+
/**
|
|
912
|
+
* Inputs accepted by Menu.Separator in addition to the shared DOM host options.
|
|
913
|
+
*
|
|
914
|
+
* @remarks
|
|
915
|
+
* ## Why
|
|
916
|
+
*
|
|
917
|
+
* The model adds separator orientation to the shared host options. Orientation is consumed only
|
|
918
|
+
* by the separator's `aria-orientation` attribute; it does not change menu navigation.
|
|
919
|
+
*
|
|
920
|
+
* ## Ownership and lifetime
|
|
921
|
+
*
|
|
922
|
+
* This declaration is data or schema metadata and acquires no resources.
|
|
923
|
+
*
|
|
924
|
+
* ## Example
|
|
925
|
+
*
|
|
926
|
+
* Import with `import type { SeparatorOptions } from "@typed/ui/Menu";` Extend the [Menu.makeState
|
|
927
|
+
* runnable setup](/reference/%40typed%2Fui%2FMenu%23makeState). Choose only its announced axis:
|
|
928
|
+
* `const options: SeparatorOptions = { orientation: "vertical" }`; this does not alter Arrow-key
|
|
929
|
+
* behavior.
|
|
930
|
+
* @since 1.0.0
|
|
931
|
+
* @category models
|
|
932
|
+
*/
|
|
933
|
+
export interface SeparatorOptions extends Dom.HostOptions<HTMLHRElement> {
|
|
934
|
+
/**
|
|
935
|
+
* Value forwarded only to the separator's aria-orientation attribute.
|
|
936
|
+
* @since 1.0.0
|
|
937
|
+
* @category models
|
|
938
|
+
*/
|
|
939
|
+
readonly orientation?: "horizontal" | "vertical";
|
|
940
|
+
}
|
|
941
|
+
declare function separatorProps<const Options extends SeparatorOptions>(_options: Options): ({ property }: Dom.InternalPropsHelpers<Options>) => {
|
|
942
|
+
readonly role: "separator";
|
|
943
|
+
readonly "aria-orientation": "horizontal" | Exclude<Dom.Property<Options, "orientation">, Dom.Nullish>;
|
|
944
|
+
};
|
|
945
|
+
type SeparatorProps<Options extends SeparatorOptions> = ReturnType<ReturnType<typeof separatorProps<Options>>>;
|
|
946
|
+
/**
|
|
947
|
+
* Renders a separator with explicit horizontal or vertical orientation.
|
|
948
|
+
*
|
|
949
|
+
* @remarks
|
|
950
|
+
* ## Why
|
|
951
|
+
*
|
|
952
|
+
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
953
|
+
* through the shared DOM boundary.
|
|
954
|
+
*
|
|
955
|
+
* ## Ownership and lifetime
|
|
956
|
+
*
|
|
957
|
+
* The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
|
|
958
|
+
* collection registrations only when rendered. The rendering Scope removes those resources;
|
|
959
|
+
* unrelated nodes and attributes remain caller-owned.
|
|
960
|
+
*
|
|
961
|
+
* @example
|
|
962
|
+
* ```ts
|
|
963
|
+
* import * as Menu from "@typed/ui/Menu";
|
|
964
|
+
*
|
|
965
|
+
* const view = Menu.Separator({ orientation: "horizontal" });
|
|
966
|
+
* ```
|
|
967
|
+
* @since 1.0.0
|
|
968
|
+
* @category components
|
|
969
|
+
*/
|
|
970
|
+
export declare function Separator<const Options extends SeparatorOptions, const Host extends HostResult = never>(options: Options, host?: Dom.HostOverride<Dom.RenderHostProps<Options, SeparatorProps<Options>>, "", Host>): Fx<RenderEvent, Renderable.Error<Options | Host>, Renderable.Services<Options | Host> | Scope.Scope | RenderTemplate>;
|
|
971
|
+
export {};
|
|
972
|
+
//# sourceMappingURL=Menu.d.ts.map
|