@typed/ui 1.0.0-beta.6 → 1.0.0-beta.8
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/LICENSE +21 -0
- package/README.md +1 -1
- 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 +13 -12
package/dist/RadioGroup.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* ARIA state.
|
|
2
|
+
* Native radio selection with optional registered keyboard movement.
|
|
3
|
+
* Choice values, element IDs, and shared native names have distinct responsibilities.
|
|
5
4
|
*
|
|
6
|
-
*
|
|
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.
|
|
5
|
+
* Read the [RadioGroup guide](/explore/ui-radio-group) for a complete example.
|
|
10
6
|
*
|
|
7
|
+
* [APG interaction reference](https://www.w3.org/WAI/ARIA/apg/patterns/radio/).
|
|
11
8
|
* @since 1.0.0
|
|
12
|
-
* @category
|
|
9
|
+
* @category Overview
|
|
13
10
|
* @packageDocumentation
|
|
14
11
|
*/
|
|
15
12
|
import * as Effect from "effect/Effect";
|
|
@@ -23,15 +20,9 @@ import * as Dom from "./Dom.js";
|
|
|
23
20
|
* Effect Schema used by makeState to encode, decode, and hydrate RadioGroup state.
|
|
24
21
|
*
|
|
25
22
|
* @remarks
|
|
26
|
-
* ## Why
|
|
27
|
-
*
|
|
28
23
|
* A public schema makes hydration and serialized state use the same runtime validation as direct
|
|
29
24
|
* construction.
|
|
30
25
|
*
|
|
31
|
-
* ## Ownership and lifetime
|
|
32
|
-
*
|
|
33
|
-
* This declaration is data or schema metadata and acquires no resources.
|
|
34
|
-
*
|
|
35
26
|
* @example
|
|
36
27
|
* ```ts
|
|
37
28
|
* import * as Schema from "effect/Schema";
|
|
@@ -40,7 +31,7 @@ import * as Dom from "./Dom.js";
|
|
|
40
31
|
* const decodeState = Schema.decodeUnknownEffect(RadioGroup.StateSchema);
|
|
41
32
|
* ```
|
|
42
33
|
* @since 1.0.0
|
|
43
|
-
* @category schemas
|
|
34
|
+
* @category Hydration schemas
|
|
44
35
|
*/
|
|
45
36
|
export const StateSchema = Schema.Struct({
|
|
46
37
|
value: Schema.String,
|
|
@@ -51,19 +42,13 @@ export const StateSchema = Schema.Struct({
|
|
|
51
42
|
virtualFocus: Schema.Boolean,
|
|
52
43
|
});
|
|
53
44
|
/**
|
|
54
|
-
* Creates hydrated
|
|
55
|
-
*
|
|
45
|
+
* Creates hydrated radio selection with a required value, null active ID, and looping enabled by
|
|
46
|
+
* default.
|
|
56
47
|
*
|
|
57
48
|
* @remarks
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* ## Ownership and lifetime
|
|
63
|
-
*
|
|
64
|
-
* The returned Effect creates the RefSubject when run. That state is renderer-independent;
|
|
65
|
-
* collection registrations belong to the separate Scope that runs register or ref, not to state
|
|
66
|
-
* creation.
|
|
49
|
+
* The selected value and element ID are separate. The first keyboard movement can resolve the
|
|
50
|
+
* selected value against the mounted collection. Creation requires Scope; renderers borrow the
|
|
51
|
+
* returned subject.
|
|
67
52
|
*
|
|
68
53
|
* @example
|
|
69
54
|
* ```ts
|
|
@@ -79,7 +64,7 @@ export const StateSchema = Schema.Struct({
|
|
|
79
64
|
* );
|
|
80
65
|
* ```
|
|
81
66
|
* @since 1.0.0
|
|
82
|
-
* @category
|
|
67
|
+
* @category State construction
|
|
83
68
|
*/
|
|
84
69
|
export function makeState(initial) {
|
|
85
70
|
return RefSubject.hydrate(StateSchema, {
|
|
@@ -95,12 +80,8 @@ export function makeState(initial) {
|
|
|
95
80
|
* Creates a scoped Collection for RadioGroup items.
|
|
96
81
|
*
|
|
97
82
|
* @remarks
|
|
98
|
-
* ## Why
|
|
99
|
-
*
|
|
100
83
|
* State and collection ownership can be composed and tested independently from any renderer.
|
|
101
84
|
*
|
|
102
|
-
* ## Ownership and lifetime
|
|
103
|
-
*
|
|
104
85
|
* The returned Effect allocates the RefSubject in the caller's Scope. Each later registration is
|
|
105
86
|
* owned by the Scope that runs register, independently of this construction Effect.
|
|
106
87
|
*
|
|
@@ -117,31 +98,17 @@ export function makeState(initial) {
|
|
|
117
98
|
* );
|
|
118
99
|
* ```
|
|
119
100
|
* @since 1.0.0
|
|
120
|
-
* @category
|
|
101
|
+
* @category State construction
|
|
121
102
|
*/
|
|
122
103
|
export const makeCollection = Collection.makeState;
|
|
123
104
|
/**
|
|
124
|
-
* Sets selected value and
|
|
105
|
+
* Sets the selected value and optionally the active element ID.
|
|
125
106
|
*
|
|
126
107
|
* @remarks
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* The operation exposes RadioGroup's transition directly so callers can compose it in Effect
|
|
130
|
-
* programs and native event handlers.
|
|
131
|
-
*
|
|
132
|
-
* ## Ownership and lifetime
|
|
133
|
-
*
|
|
134
|
-
* The returned Effect performs the update or DOM side effect only when run, preserves the declared
|
|
135
|
-
* error and service channels, and retains no resources after completion.
|
|
136
|
-
*
|
|
137
|
-
* ## Example
|
|
138
|
-
*
|
|
139
|
-
* Import with `import { setValue } from "@typed/ui/RadioGroup";` Extend the [RadioGroup.makeState
|
|
140
|
-
* runnable setup](/reference/%40typed%2Fui%2FRadioGroup%23makeState). Inside the linked Effect
|
|
141
|
-
* program invoke `yield* setValue(state, "phone", "phone")`, then read state to observe the checked
|
|
142
|
-
* value and active roving-focus id update together.
|
|
108
|
+
* Omitting activeId preserves the previous active ID. This state update does not look up an
|
|
109
|
+
* item, move DOM focus, or verify that the value belongs to the group.
|
|
143
110
|
* @since 1.0.0
|
|
144
|
-
* @category
|
|
111
|
+
* @category State transitions
|
|
145
112
|
*/
|
|
146
113
|
export function setValue(state, value, activeId) {
|
|
147
114
|
return RefSubject.update(state, (current) => ({
|
|
@@ -182,28 +149,40 @@ function rootInternalProps(options) {
|
|
|
182
149
|
});
|
|
183
150
|
}
|
|
184
151
|
/**
|
|
185
|
-
* Renders
|
|
152
|
+
* Renders a named radiogroup around native radio items.
|
|
186
153
|
*
|
|
187
154
|
* @remarks
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
155
|
+
* Pass the same state to every item and the same native name to items in one group. With a
|
|
156
|
+
* collection, the root handles vertical arrow movement and Home/End, skips disabled
|
|
157
|
+
* registrations, updates selection, and moves real focus. Without a collection, native input
|
|
158
|
+
* behavior remains the keyboard boundary.
|
|
192
159
|
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
* ## Example
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* import { html } from "@typed/template";
|
|
163
|
+
* import { component } from "@typed/ui/Component";
|
|
164
|
+
* import * as RadioGroup from "@typed/ui/RadioGroup";
|
|
200
165
|
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
166
|
+
* export const DeliveryChoice = component(function* () {
|
|
167
|
+
* const state = yield* RadioGroup.makeState({ value: "standard" });
|
|
168
|
+
* const collection = yield* RadioGroup.makeCollection();
|
|
169
|
+
* return RadioGroup.Root({
|
|
170
|
+
* state,
|
|
171
|
+
* collection,
|
|
172
|
+
* label: "Delivery speed",
|
|
173
|
+
* content: html`
|
|
174
|
+
* <label>${RadioGroup.Item({
|
|
175
|
+
* state, collection, id: "delivery-standard", name: "delivery", value: "standard",
|
|
176
|
+
* })} Standard delivery</label>
|
|
177
|
+
* <label>${RadioGroup.Item({
|
|
178
|
+
* state, collection, id: "delivery-express", name: "delivery", value: "express",
|
|
179
|
+
* })} Express delivery</label>
|
|
180
|
+
* `,
|
|
181
|
+
* });
|
|
182
|
+
* });
|
|
183
|
+
* ```
|
|
205
184
|
* @since 1.0.0
|
|
206
|
-
* @category
|
|
185
|
+
* @category Native controls
|
|
207
186
|
*/
|
|
208
187
|
export function Root(options, host) {
|
|
209
188
|
return Dom.renderHost()(options, host, rootInternalProps(options), options.content, (props, content) => {
|
|
@@ -238,54 +217,25 @@ function itemInternalProps(options) {
|
|
|
238
217
|
});
|
|
239
218
|
}
|
|
240
219
|
/**
|
|
241
|
-
* Renders
|
|
220
|
+
* Renders one native radio input and optionally registers it for group navigation.
|
|
242
221
|
*
|
|
243
222
|
* @remarks
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
* through the shared DOM boundary.
|
|
248
|
-
*
|
|
249
|
-
* ## Ownership and lifetime
|
|
250
|
-
*
|
|
251
|
-
* The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
|
|
252
|
-
* collection registrations only when rendered. The rendering Scope removes those resources;
|
|
253
|
-
* unrelated nodes and attributes remain caller-owned.
|
|
254
|
-
*
|
|
255
|
-
* ## Example
|
|
256
|
-
*
|
|
257
|
-
* Import with `import { Item } from "@typed/ui/RadioGroup";` Extend the [RadioGroup.makeState
|
|
258
|
-
* runnable setup](/reference/%40typed%2Fui%2FRadioGroup%23makeState). Replace the linked program's
|
|
259
|
-
* final snapshot read with `Item({ state, id: "email", value: "email", name: "contact" })`; render
|
|
260
|
-
* that Fx before the same Scope closes.
|
|
223
|
+
* id identifies the element; value identifies the choice; name establishes the native browser
|
|
224
|
+
* group. A native change updates the selected value and active ID. Supply a wrapping label or an
|
|
225
|
+
* external label linked to id. Registration ends with the rendered Scope.
|
|
261
226
|
* @since 1.0.0
|
|
262
|
-
* @category
|
|
227
|
+
* @category Native controls
|
|
263
228
|
*/
|
|
264
229
|
export function Item(options, host) {
|
|
265
230
|
return Dom.renderHost()(options, host, itemInternalProps(options), "", (props) => html `<input ...${props} />`);
|
|
266
231
|
}
|
|
267
232
|
/**
|
|
268
|
-
*
|
|
269
|
-
* lifetime.
|
|
233
|
+
* Alias of Root.
|
|
270
234
|
*
|
|
271
235
|
* @remarks
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
275
|
-
* through the shared DOM boundary.
|
|
276
|
-
*
|
|
277
|
-
* ## Ownership and lifetime
|
|
278
|
-
*
|
|
279
|
-
* The alias acquires nothing. Rendering it has exactly the canonical component's Scope and DOM
|
|
280
|
-
* ownership contract.
|
|
281
|
-
*
|
|
282
|
-
* ## Example
|
|
283
|
-
*
|
|
284
|
-
* Import with `import { RadioGroup } from "@typed/ui/RadioGroup";` Extend the [RadioGroup.makeState
|
|
285
|
-
* runnable setup](/reference/%40typed%2Fui%2FRadioGroup%23makeState). Replace the linked program's
|
|
286
|
-
* final snapshot read with `RadioGroup({ state, label: "Contact method", content: "Choices" })`;
|
|
287
|
-
* render that Fx before the same Scope closes.
|
|
236
|
+
* The alias exposes the same native-input grouping and optional collection behavior; it introduces
|
|
237
|
+
* no additional state or focus policy.
|
|
288
238
|
* @since 1.0.0
|
|
289
|
-
* @category
|
|
239
|
+
* @category Native controls
|
|
290
240
|
*/
|
|
291
241
|
export const RadioGroup = Root;
|
package/dist/Role.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { HostResult } from "./Dom/Types.js";
|
|
|
12
12
|
* ## Ownership and lifetime
|
|
13
13
|
* The model acquires no resources; dynamic values follow the rendered Scope.
|
|
14
14
|
* @since 1.0.0
|
|
15
|
-
* @category
|
|
15
|
+
* @category Semantic hosts
|
|
16
16
|
*/
|
|
17
17
|
export interface RoleOptions extends Dom.HostOptions<HTMLDivElement> {
|
|
18
18
|
/** Content rendered inside the semantic host.
|
|
@@ -22,7 +22,7 @@ export interface RoleOptions extends Dom.HostOptions<HTMLDivElement> {
|
|
|
22
22
|
* ## Ownership and lifetime
|
|
23
23
|
* Dynamic content follows the component Scope.
|
|
24
24
|
* @since 1.0.0
|
|
25
|
-
* @category content
|
|
25
|
+
* @category Rendered content
|
|
26
26
|
*/
|
|
27
27
|
readonly content: Renderable.Any;
|
|
28
28
|
/** The explicit ARIA role.
|
|
@@ -32,7 +32,7 @@ export interface RoleOptions extends Dom.HostOptions<HTMLDivElement> {
|
|
|
32
32
|
* ## Ownership and lifetime
|
|
33
33
|
* The reflected value retains no resources.
|
|
34
34
|
* @since 1.0.0
|
|
35
|
-
* @category
|
|
35
|
+
* @category Semantic roles
|
|
36
36
|
*/
|
|
37
37
|
readonly role: Renderable.Any<string | null | undefined>;
|
|
38
38
|
}
|
|
@@ -57,7 +57,7 @@ type RoleInternalProps<Options extends RoleOptions> = ReturnType<typeof internal
|
|
|
57
57
|
* const status = Role({ role: "status", content: "Ready" })
|
|
58
58
|
* ```
|
|
59
59
|
* @since 1.0.0
|
|
60
|
-
* @category
|
|
60
|
+
* @category Semantic hosts
|
|
61
61
|
*/
|
|
62
62
|
export declare function Role<const Options extends RoleOptions, const Host extends HostResult = never>(options: Options, host?: Dom.HostOverride<Dom.RenderHostProps<Options, RoleInternalProps<Options>>, Options["content"], Host>): Fx<RenderEvent, Renderable.Error<Options | Host>, Renderable.Services<Options | Host> | Scope.Scope | RenderTemplate>;
|
|
63
63
|
export {};
|
package/dist/Role.js
CHANGED
|
@@ -20,7 +20,7 @@ function internalProps({ property, }) {
|
|
|
20
20
|
* const status = Role({ role: "status", content: "Ready" })
|
|
21
21
|
* ```
|
|
22
22
|
* @since 1.0.0
|
|
23
|
-
* @category
|
|
23
|
+
* @category Semantic hosts
|
|
24
24
|
*/
|
|
25
25
|
export function Role(options, host) {
|
|
26
26
|
return Dom.renderHost()(options, host, internalProps, options.content, (props, content) => html `<div ...${props}>${content}</div>`);
|