@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/Select.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* A native popover-backed listbox with separate selection, focus, and visibility.
|
|
3
|
+
* Unlike Form.Select, these options are divs rather than native select options.
|
|
4
|
+
* Pass one collection to Content and its Options for registered keyboard navigation.
|
|
5
5
|
*
|
|
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.
|
|
6
|
+
* Read the [Select guide](/explore/ui-select) for a complete example.
|
|
10
7
|
*
|
|
8
|
+
* [APG interaction reference](https://www.w3.org/WAI/ARIA/apg/patterns/listbox/).
|
|
11
9
|
* @since 1.0.0
|
|
12
|
-
* @category
|
|
10
|
+
* @category Overview
|
|
13
11
|
* @packageDocumentation
|
|
14
12
|
*/
|
|
15
13
|
import * as Effect from "effect/Effect";
|
|
@@ -26,15 +24,9 @@ const invokers = new WeakMap();
|
|
|
26
24
|
* Effect Schema used by makeState to encode, decode, and hydrate Select state.
|
|
27
25
|
*
|
|
28
26
|
* @remarks
|
|
29
|
-
* ## Why
|
|
30
|
-
*
|
|
31
27
|
* A public schema makes hydration and serialized state use the same runtime validation as direct
|
|
32
28
|
* construction.
|
|
33
29
|
*
|
|
34
|
-
* ## Ownership and lifetime
|
|
35
|
-
*
|
|
36
|
-
* This declaration is data or schema metadata and acquires no resources.
|
|
37
|
-
*
|
|
38
30
|
* @example
|
|
39
31
|
* ```ts
|
|
40
32
|
* import * as Schema from "effect/Schema";
|
|
@@ -43,7 +35,7 @@ const invokers = new WeakMap();
|
|
|
43
35
|
* const decodeState = Schema.decodeUnknownEffect(Select.StateSchema);
|
|
44
36
|
* ```
|
|
45
37
|
* @since 1.0.0
|
|
46
|
-
* @category schemas
|
|
38
|
+
* @category Hydration schemas
|
|
47
39
|
*/
|
|
48
40
|
export const StateSchema = Schema.Struct({
|
|
49
41
|
id: Schema.String,
|
|
@@ -60,12 +52,8 @@ export const StateSchema = Schema.Struct({
|
|
|
60
52
|
* false, and loop true.
|
|
61
53
|
*
|
|
62
54
|
* @remarks
|
|
63
|
-
* ## Why
|
|
64
|
-
*
|
|
65
55
|
* State and collection ownership can be composed and tested independently from any renderer.
|
|
66
56
|
*
|
|
67
|
-
* ## Ownership and lifetime
|
|
68
|
-
*
|
|
69
57
|
* The returned Effect creates the RefSubject when run. That state is renderer-independent;
|
|
70
58
|
* collection registrations belong to the separate Scope that runs register or ref, not to state
|
|
71
59
|
* creation.
|
|
@@ -84,7 +72,7 @@ export const StateSchema = Schema.Struct({
|
|
|
84
72
|
* );
|
|
85
73
|
* ```
|
|
86
74
|
* @since 1.0.0
|
|
87
|
-
* @category
|
|
75
|
+
* @category State construction
|
|
88
76
|
*/
|
|
89
77
|
export function makeState(initial) {
|
|
90
78
|
return RefSubject.hydrate(StateSchema, {
|
|
@@ -102,12 +90,8 @@ export function makeState(initial) {
|
|
|
102
90
|
* Creates a scoped Collection for Select items.
|
|
103
91
|
*
|
|
104
92
|
* @remarks
|
|
105
|
-
* ## Why
|
|
106
|
-
*
|
|
107
93
|
* State and collection ownership can be composed and tested independently from any renderer.
|
|
108
94
|
*
|
|
109
|
-
* ## Ownership and lifetime
|
|
110
|
-
*
|
|
111
95
|
* The returned Effect allocates the RefSubject in the caller's Scope. Each later registration is
|
|
112
96
|
* owned by the Scope that runs register, independently of this construction Effect.
|
|
113
97
|
*
|
|
@@ -124,31 +108,18 @@ export function makeState(initial) {
|
|
|
124
108
|
* );
|
|
125
109
|
* ```
|
|
126
110
|
* @since 1.0.0
|
|
127
|
-
* @category
|
|
111
|
+
* @category State construction
|
|
128
112
|
*/
|
|
129
113
|
export const makeCollection = Collection.makeState;
|
|
130
114
|
/**
|
|
131
|
-
*
|
|
115
|
+
* Commits an option ID and value, then marks the popup closed.
|
|
132
116
|
*
|
|
133
117
|
* @remarks
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* and native event handlers.
|
|
138
|
-
*
|
|
139
|
-
* ## Ownership and lifetime
|
|
140
|
-
*
|
|
141
|
-
* The returned Effect performs the update or DOM side effect only when run, preserves the declared
|
|
142
|
-
* error and service channels, and retains no resources after completion.
|
|
143
|
-
*
|
|
144
|
-
* ## Example
|
|
145
|
-
*
|
|
146
|
-
* Import with `import { select } from "@typed/ui/Select";` Extend the [Select.makeState runnable
|
|
147
|
-
* setup](/reference/%40typed%2Fui%2FSelect%23makeState). Inside the linked Effect program invoke
|
|
148
|
-
* `yield* select(state, "utc", "UTC")`, then read state to observe selection and active focus
|
|
149
|
-
* update together while the popup closes.
|
|
118
|
+
* This Effect changes state only. It does not check collection membership or move focus itself;
|
|
119
|
+
* the mounted popover observes the visibility change. Keep id and value consistent with the
|
|
120
|
+
* option being selected.
|
|
150
121
|
* @since 1.0.0
|
|
151
|
-
* @category
|
|
122
|
+
* @category State transitions
|
|
152
123
|
*/
|
|
153
124
|
export function select(state, id, value) {
|
|
154
125
|
return RefSubject.update(state, (current) => ({ ...current, activeId: id, value, open: false }));
|
|
@@ -194,54 +165,59 @@ function invokerRef(state) {
|
|
|
194
165
|
});
|
|
195
166
|
}
|
|
196
167
|
/**
|
|
197
|
-
* Renders the native button that
|
|
168
|
+
* Renders the native button that toggles the select listbox popover.
|
|
198
169
|
*
|
|
199
170
|
* @remarks
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
171
|
+
* The generated button ID labels Content; popovertarget points to state.id. ArrowDown invokes
|
|
172
|
+
* the native button click. Content synchronizes native toggle events with open state. Render a
|
|
173
|
+
* useful name containing the current choice; the trigger does not format selected values for
|
|
174
|
+
* you.
|
|
204
175
|
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
* ## Example
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* import { RefSubject } from "@typed/fx";
|
|
179
|
+
* import { html } from "@typed/template";
|
|
180
|
+
* import { component } from "@typed/ui/Component";
|
|
181
|
+
* import * as Select from "@typed/ui/Select";
|
|
212
182
|
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
183
|
+
* export const DensityPicker = component(function* () {
|
|
184
|
+
* const state = yield* Select.makeState({ id: "density-options", value: "comfortable" });
|
|
185
|
+
* const collection = yield* Select.makeCollection();
|
|
186
|
+
* const label = RefSubject.map(state, ({ value }) =>
|
|
187
|
+
* value === "compact" ? "Density: compact" : "Density: comfortable",
|
|
188
|
+
* );
|
|
189
|
+
* return html`<div class="density-picker">
|
|
190
|
+
* ${Select.Trigger({ state, content: label })}
|
|
191
|
+
* ${Select.Content({
|
|
192
|
+
* state, collection,
|
|
193
|
+
* content: [
|
|
194
|
+
* Select.Option({
|
|
195
|
+
* state, collection, id: "density-comfortable", value: "comfortable",
|
|
196
|
+
* textValue: "Comfortable", content: "Comfortable",
|
|
197
|
+
* }),
|
|
198
|
+
* Select.Option({
|
|
199
|
+
* state, collection, id: "density-compact", value: "compact",
|
|
200
|
+
* textValue: "Compact", content: "Compact",
|
|
201
|
+
* }),
|
|
202
|
+
* ],
|
|
203
|
+
* })}
|
|
204
|
+
* </div>`;
|
|
205
|
+
* });
|
|
206
|
+
* ```
|
|
217
207
|
* @since 1.0.0
|
|
218
|
-
* @category
|
|
208
|
+
* @category Controls
|
|
219
209
|
*/
|
|
220
210
|
export function Trigger(options, host) {
|
|
221
211
|
return Dom.renderHost()(options, host, triggerProps(options), options.content, (props, content) => html `<button ...${props}>${content}</button>`);
|
|
222
212
|
}
|
|
223
213
|
/**
|
|
224
|
-
*
|
|
214
|
+
* Alias of Trigger.
|
|
225
215
|
*
|
|
226
216
|
* @remarks
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
230
|
-
* through the shared DOM boundary.
|
|
231
|
-
*
|
|
232
|
-
* ## Ownership and lifetime
|
|
233
|
-
*
|
|
234
|
-
* The alias acquires nothing. Rendering it has exactly the canonical component's Scope and DOM
|
|
235
|
-
* ownership contract.
|
|
236
|
-
*
|
|
237
|
-
* ## Example
|
|
238
|
-
*
|
|
239
|
-
* Import with `import { Select } from "@typed/ui/Select";` Extend the [Select.makeState runnable
|
|
240
|
-
* setup](/reference/%40typed%2Fui%2FSelect%23makeState). Replace the linked program's final
|
|
241
|
-
* snapshot read with `Select({ state, content: "Choose timezone" })`; render that Fx before the
|
|
242
|
-
* same Scope closes.
|
|
217
|
+
* Calling Select alone creates only the invoker button. Compose Content and Option for the popup
|
|
218
|
+
* choice surface; use Form.Select for a native select element.
|
|
243
219
|
* @since 1.0.0
|
|
244
|
-
* @category
|
|
220
|
+
* @category Controls
|
|
245
221
|
*/
|
|
246
222
|
export const Select = Trigger;
|
|
247
223
|
function contentProps(options) {
|
|
@@ -323,28 +299,16 @@ function contentProps(options) {
|
|
|
323
299
|
});
|
|
324
300
|
}
|
|
325
301
|
/**
|
|
326
|
-
* Renders manual-popover listbox
|
|
302
|
+
* Renders the manual-popover listbox and coordinates registered keyboard movement.
|
|
327
303
|
*
|
|
328
304
|
* @remarks
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
* ## Ownership and lifetime
|
|
335
|
-
*
|
|
336
|
-
* The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
|
|
337
|
-
* collection registrations only when rendered. The rendering Scope removes those resources;
|
|
338
|
-
* unrelated nodes and attributes remain caller-owned.
|
|
339
|
-
*
|
|
340
|
-
* ## Example
|
|
341
|
-
*
|
|
342
|
-
* Import with `import { Content } from "@typed/ui/Select";` Extend the [Select.makeState runnable
|
|
343
|
-
* setup](/reference/%40typed%2Fui%2FSelect%23makeState). Replace the linked program's final
|
|
344
|
-
* snapshot read with `Content({ state, content: "Timezones" })`; render that Fx before the same
|
|
345
|
-
* Scope closes.
|
|
305
|
+
* With a collection, arrows and Home/End move focus, buffered typeahead locates options,
|
|
306
|
+
* Enter/Space commits the active choice, and Escape closes with invoker focus restoration.
|
|
307
|
+
* Opening focuses a registered option matching the selected value; an unmatched or null value
|
|
308
|
+
* does not choose the first option. Manual popover mode does not imply auto-mode outside-click
|
|
309
|
+
* dismissal.
|
|
346
310
|
* @since 1.0.0
|
|
347
|
-
* @category
|
|
311
|
+
* @category Controls
|
|
348
312
|
*/
|
|
349
313
|
export function Content(options, host) {
|
|
350
314
|
return Dom.renderHost()(options, host, contentProps(options), options.content, (props, content) => {
|
|
@@ -375,29 +339,15 @@ function optionProps(options) {
|
|
|
375
339
|
});
|
|
376
340
|
}
|
|
377
341
|
/**
|
|
378
|
-
* Renders
|
|
379
|
-
* unless disabled.
|
|
342
|
+
* Renders a selectable listbox option with distinct active and selected state.
|
|
380
343
|
*
|
|
381
344
|
* @remarks
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
* ## Ownership and lifetime
|
|
388
|
-
*
|
|
389
|
-
* The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
|
|
390
|
-
* collection registrations only when rendered. The rendering Scope removes those resources;
|
|
391
|
-
* unrelated nodes and attributes remain caller-owned.
|
|
392
|
-
*
|
|
393
|
-
* ## Example
|
|
394
|
-
*
|
|
395
|
-
* Import with `import { Option } from "@typed/ui/Select";` Extend the [Select.makeState runnable
|
|
396
|
-
* setup](/reference/%40typed%2Fui%2FSelect%23makeState). Replace the linked program's final
|
|
397
|
-
* snapshot read with `Option({ state, id: "utc", value: "UTC", content: "UTC" })`; render that Fx
|
|
398
|
-
* before the same Scope closes.
|
|
345
|
+
* Click commits value and closes the popup; focus updates activeId without committing a new
|
|
346
|
+
* value. Register every option with the same collection used by Content for keyboard navigation.
|
|
347
|
+
* Supply textValue for readable typeahead when value is an internal code. This div is not a
|
|
348
|
+
* native form field.
|
|
399
349
|
* @since 1.0.0
|
|
400
|
-
* @category
|
|
350
|
+
* @category Controls
|
|
401
351
|
*/
|
|
402
352
|
export function Option(options, host) {
|
|
403
353
|
return Dom.renderHost()(options, host, optionProps(options), options.content, (props, content) => html `<div ...${props}>${content}</div>`);
|
package/dist/Separator.d.ts
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A non-focusable semantic boundary with an orientation attribute.
|
|
3
|
+
* CSS draws the line; WindowSplitter supplies the separate adjustable-pane interaction.
|
|
4
|
+
*
|
|
5
|
+
* Read the [Separator guide](/explore/ui-separator) for a complete example.
|
|
6
|
+
*
|
|
7
|
+
* [Platform reference](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/separator_role).
|
|
8
|
+
* @since 1.0.0
|
|
9
|
+
* @category Overview
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
1
12
|
import type * as Scope from "effect/Scope";
|
|
2
13
|
import type { Fx } from "@typed/fx/Fx";
|
|
3
14
|
import { type Renderable, type RenderEvent, type RenderTemplate } from "@typed/template";
|
|
4
15
|
import * as Dom from "./Dom.js";
|
|
5
16
|
import type { HostResult } from "./Dom/Types.js";
|
|
6
17
|
/**
|
|
7
|
-
* Options for a non-interactive ARIA separator.
|
|
8
|
-
* @remarks
|
|
9
|
-
* ## Why
|
|
10
|
-
* Orientation communicates whether the visual division is horizontal or
|
|
11
|
-
* vertical without implying splitter interaction.
|
|
12
|
-
* ## Ownership and lifetime
|
|
13
|
-
* The model is inert; dynamic orientation follows the rendered Scope.
|
|
14
|
-
* @since 1.0.0
|
|
15
|
-
* @category models
|
|
16
18
|
*/
|
|
17
19
|
export interface SeparatorOptions extends Dom.HostOptions<HTMLDivElement> {
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* ## Why
|
|
21
|
-
* Assistive technology uses orientation to interpret the division.
|
|
22
|
-
* ## Ownership and lifetime
|
|
23
|
-
* The dynamic attribute subscription ends with the component Scope.
|
|
20
|
+
/**
|
|
21
|
+
* Separator orientation, defaulting to horizontal.
|
|
24
22
|
* @since 1.0.0
|
|
25
|
-
* @category
|
|
23
|
+
* @category Keyboard navigation
|
|
26
24
|
*/
|
|
27
25
|
readonly orientation?: Renderable.Any<"horizontal" | "vertical" | null | undefined>;
|
|
28
26
|
}
|
|
@@ -32,22 +30,28 @@ declare function internalProps<const Options extends SeparatorOptions>({ propert
|
|
|
32
30
|
};
|
|
33
31
|
type SeparatorInternalProps<Options extends SeparatorOptions> = ReturnType<typeof internalProps<Options>>;
|
|
34
32
|
/**
|
|
35
|
-
* Renders a non-
|
|
33
|
+
* Renders a non-interactive semantic division.
|
|
34
|
+
*
|
|
36
35
|
* @remarks
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* Running the Fx owns its reactive attribute until the Effect Scope closes. A
|
|
42
|
-
* custom host must preserve the role and orientation.
|
|
36
|
+
* orientation defaults to horizontal and changes aria-orientation, not layout or dimensions.
|
|
37
|
+
* Supply the visible line through CSS. Do not make this host focusable to imitate a resizer;
|
|
38
|
+
* WindowSplitter owns that separate interaction.
|
|
39
|
+
*
|
|
43
40
|
* @example
|
|
44
41
|
* ```ts
|
|
45
|
-
* import {
|
|
42
|
+
* import { html } from "@typed/template";
|
|
43
|
+
* import { Heading } from "@typed/ui/Heading";
|
|
44
|
+
* import { Separator } from "@typed/ui/Separator";
|
|
46
45
|
*
|
|
47
|
-
* const
|
|
46
|
+
* export const AccountSummary = html`<section>
|
|
47
|
+
* ${Heading({ level: 2, content: "Account summary" })}
|
|
48
|
+
* <p>Personal account</p>
|
|
49
|
+
* ${Separator({ props: { class: "summary-divider" } })}
|
|
50
|
+
* <p>Next renewal: September 30</p>
|
|
51
|
+
* </section>`;
|
|
48
52
|
* ```
|
|
49
53
|
* @since 1.0.0
|
|
50
|
-
* @category
|
|
54
|
+
* @category Structure and naming
|
|
51
55
|
*/
|
|
52
56
|
export declare function Separator<const Options extends SeparatorOptions, const Host extends HostResult = never>(options: Options, host?: Dom.HostOverride<Dom.RenderHostProps<Options, SeparatorInternalProps<Options>>, "", Host>): Fx<RenderEvent, Renderable.Error<Options | Host>, Renderable.Services<Options | Host> | Scope.Scope | RenderTemplate>;
|
|
53
57
|
export {};
|
package/dist/Separator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Separator.d.ts","sourceRoot":"","sources":["../src/Separator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAQ,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"Separator.d.ts","sourceRoot":"","sources":["../src/Separator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAQ,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD;GACG;AACH,MAAM,WAAW,gBAAiB,SAAQ,GAAG,CAAC,WAAW,CAAC,cAAc,CAAC;IACvE;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,YAAY,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CACrF;AAED,iBAAS,aAAa,CAAC,KAAK,CAAC,OAAO,SAAS,gBAAgB,EAAE,EAC7D,QAAQ,GACT,EAAE,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC;IACzB,IAAI;IAAe,kBAAkB;EAC/C;AAED,KAAK,sBAAsB,CAAC,OAAO,SAAS,gBAAgB,IAAI,UAAU,CACxE,OAAO,aAAa,CAAC,OAAO,CAAC,CAC9B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CACvB,KAAK,CAAC,OAAO,SAAS,gBAAgB,EACtC,KAAK,CAAC,IAAI,SAAS,UAAU,GAAG,KAAK,EAErC,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,GAC/F,EAAE,CACH,WAAW,EACX,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,EAChC,UAAU,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,GAAG,cAAc,CACnE,CAQA"}
|
package/dist/Separator.js
CHANGED
|
@@ -4,22 +4,28 @@ function internalProps({ property, }) {
|
|
|
4
4
|
return { role: "separator", "aria-orientation": property("orientation", "horizontal") };
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* Renders a non-
|
|
7
|
+
* Renders a non-interactive semantic division.
|
|
8
|
+
*
|
|
8
9
|
* @remarks
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* Running the Fx owns its reactive attribute until the Effect Scope closes. A
|
|
14
|
-
* custom host must preserve the role and orientation.
|
|
10
|
+
* orientation defaults to horizontal and changes aria-orientation, not layout or dimensions.
|
|
11
|
+
* Supply the visible line through CSS. Do not make this host focusable to imitate a resizer;
|
|
12
|
+
* WindowSplitter owns that separate interaction.
|
|
13
|
+
*
|
|
15
14
|
* @example
|
|
16
15
|
* ```ts
|
|
17
|
-
* import {
|
|
16
|
+
* import { html } from "@typed/template";
|
|
17
|
+
* import { Heading } from "@typed/ui/Heading";
|
|
18
|
+
* import { Separator } from "@typed/ui/Separator";
|
|
18
19
|
*
|
|
19
|
-
* const
|
|
20
|
+
* export const AccountSummary = html`<section>
|
|
21
|
+
* ${Heading({ level: 2, content: "Account summary" })}
|
|
22
|
+
* <p>Personal account</p>
|
|
23
|
+
* ${Separator({ props: { class: "summary-divider" } })}
|
|
24
|
+
* <p>Next renewal: September 30</p>
|
|
25
|
+
* </section>`;
|
|
20
26
|
* ```
|
|
21
27
|
* @since 1.0.0
|
|
22
|
-
* @category
|
|
28
|
+
* @category Structure and naming
|
|
23
29
|
*/
|
|
24
30
|
export function Separator(options, host) {
|
|
25
31
|
return Dom.renderHost()(options, host, internalProps, "", (props) => html `<div ...${props}></div>`);
|
package/dist/Slider.d.ts
CHANGED
|
@@ -1,68 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native range input publishing numeric updates during input.
|
|
3
|
+
* Keep programmatic values coherent with bounds and control expensive downstream work separately.
|
|
4
|
+
*
|
|
5
|
+
* Read the [Slider guide](/explore/ui-slider) for a complete example.
|
|
6
|
+
*
|
|
7
|
+
* [APG interaction reference](https://www.w3.org/WAI/ARIA/apg/patterns/slider/).
|
|
8
|
+
* @since 1.0.0
|
|
9
|
+
* @category Overview
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
1
12
|
import * as Effect from "effect/Effect";
|
|
2
13
|
import * as Schema from "effect/Schema";
|
|
3
14
|
import { RefSubject } from "@typed/fx";
|
|
4
15
|
import { EventHandler, type Renderable } from "@typed/template";
|
|
5
16
|
import * as Dom from "./Dom.js";
|
|
6
17
|
import type { HostResult } from "./Dom/Types.js";
|
|
7
|
-
/**
|
|
8
|
-
* @remarks
|
|
9
|
-
* ## Why
|
|
10
|
-
* Value logic remains testable without mounting a range input.
|
|
11
|
-
* ## Ownership and lifetime
|
|
12
|
-
* Plain state is resource-free; RefSubject ownership is Scope-based.
|
|
13
|
-
* @since 1.0.0
|
|
14
|
-
* @category state
|
|
18
|
+
/**
|
|
15
19
|
*/
|
|
16
20
|
export interface State {
|
|
17
|
-
/**
|
|
18
|
-
* @remarks
|
|
19
|
-
* ## Why
|
|
20
|
-
* A single numeric source prevents state and DOM drift.
|
|
21
|
-
* ## Ownership and lifetime
|
|
22
|
-
* Plain data acquires no resources.
|
|
23
|
-
* @since 1.0.0
|
|
24
|
-
* @category state
|
|
21
|
+
/**
|
|
25
22
|
*/
|
|
26
23
|
readonly value: number;
|
|
27
24
|
}
|
|
28
|
-
/**
|
|
29
|
-
* @remarks
|
|
30
|
-
* ## Why
|
|
31
|
-
* Explicit state gives SSR and hydration the same numeric snapshot.
|
|
32
|
-
* ## Ownership and lifetime
|
|
33
|
-
* Configuration is inert.
|
|
34
|
-
* @since 1.0.0
|
|
35
|
-
* @category state
|
|
25
|
+
/**
|
|
36
26
|
*/
|
|
37
27
|
export interface InitialState {
|
|
38
|
-
/**
|
|
39
|
-
* @remarks
|
|
40
|
-
* ## Why
|
|
41
|
-
* It seeds the synchronized input state.
|
|
42
|
-
* ## Ownership and lifetime
|
|
43
|
-
* Plain data retains no resources.
|
|
44
|
-
* @since 1.0.0
|
|
45
|
-
* @category state
|
|
28
|
+
/**
|
|
46
29
|
*/
|
|
47
30
|
readonly value: number;
|
|
48
31
|
}
|
|
49
|
-
/**
|
|
50
|
-
* @remarks
|
|
51
|
-
* ## Why
|
|
52
|
-
* Finite validation prevents invalid serialized range values.
|
|
53
|
-
* ## Ownership and lifetime
|
|
54
|
-
* The immutable schema acquires no resources.
|
|
55
|
-
* @since 1.0.0
|
|
56
|
-
* @category schemas
|
|
32
|
+
/**
|
|
57
33
|
*/
|
|
58
34
|
export declare const StateSchema: Schema.Struct<{
|
|
59
35
|
readonly value: Schema.Finite;
|
|
60
36
|
}>;
|
|
61
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Creates hydrated slider state.
|
|
62
39
|
* @remarks
|
|
63
|
-
* ## Why
|
|
64
40
|
* State can be composed and tested independently of the renderer.
|
|
65
|
-
* ## Ownership and lifetime
|
|
66
41
|
* The calling Effect Scope owns the returned RefSubject.
|
|
67
42
|
* @example
|
|
68
43
|
* ```ts
|
|
@@ -74,80 +49,47 @@ export declare const StateSchema: Schema.Struct<{
|
|
|
74
49
|
* })
|
|
75
50
|
* ```
|
|
76
51
|
* @since 1.0.0
|
|
77
|
-
* @category
|
|
52
|
+
* @category State construction
|
|
78
53
|
*/
|
|
79
54
|
export declare function makeState(initial: InitialState): Effect.Effect<RefSubject.HydratedRefSubject<{
|
|
80
55
|
readonly value: number;
|
|
81
56
|
}, Schema.SchemaError, never, never>, never, import("effect/Scope").Scope>;
|
|
82
|
-
/**
|
|
83
|
-
*
|
|
84
|
-
* ## Why
|
|
85
|
-
* An explicit Effect transition preserves RefSubject failures and services.
|
|
86
|
-
* ## Ownership and lifetime
|
|
87
|
-
* It uses the existing state lifetime and acquires no resource.
|
|
88
|
-
* @example
|
|
89
|
-
* ```ts
|
|
90
|
-
* import { Effect } from "effect"
|
|
91
|
-
* import * as Slider from "@typed/ui/Slider"
|
|
57
|
+
/**
|
|
58
|
+
* Assigns a range value without clamping or snapping it.
|
|
92
59
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* ```
|
|
60
|
+
* @remarks
|
|
61
|
+
* min, max, and step belong to the native input options and are not consulted here. Validate or
|
|
62
|
+
* normalize programmatic values before assignment so the subject and browser-sanitized range
|
|
63
|
+
* value stay consistent.
|
|
98
64
|
* @since 1.0.0
|
|
99
|
-
* @category
|
|
65
|
+
* @category State transitions
|
|
100
66
|
*/
|
|
101
67
|
export declare function setValue<E, R>(state: RefSubject.RefSubject<State, E, R>, value: number): Effect.Effect<State, E, R>;
|
|
102
|
-
/**
|
|
103
|
-
* @remarks
|
|
104
|
-
* ## Why
|
|
105
|
-
* Native range semantics provide keyboard and accessibility behavior while
|
|
106
|
-
* Typed synchronizes renderer-independent state.
|
|
107
|
-
* ## Ownership and lifetime
|
|
108
|
-
* Options are inert; the mounted component owns subscriptions by Scope.
|
|
109
|
-
* @since 1.0.0
|
|
110
|
-
* @category models
|
|
68
|
+
/**
|
|
111
69
|
*/
|
|
112
70
|
export interface SliderOptions extends Dom.HostOptions<HTMLInputElement> {
|
|
113
|
-
/**
|
|
114
|
-
*
|
|
115
|
-
* ## Why
|
|
116
|
-
* One source serves SSR, UI, and state-only tests.
|
|
117
|
-
* ## Ownership and lifetime
|
|
118
|
-
* The component borrows state and subscribes only while mounted.
|
|
71
|
+
/**
|
|
72
|
+
* Hydrated state synchronized to the input.
|
|
119
73
|
* @since 1.0.0
|
|
120
|
-
* @category
|
|
74
|
+
* @category State connection
|
|
121
75
|
*/
|
|
122
76
|
readonly state: RefSubject.HydratedRefSubject<State, Schema.SchemaError>;
|
|
123
|
-
/**
|
|
124
|
-
*
|
|
125
|
-
* ## Why
|
|
126
|
-
* The platform uses this bound for keyboard and constraint behavior.
|
|
127
|
-
* ## Ownership and lifetime
|
|
128
|
-
* Dynamic attributes follow the component Scope.
|
|
77
|
+
/**
|
|
78
|
+
* Native minimum value.
|
|
129
79
|
* @since 1.0.0
|
|
130
|
-
* @category
|
|
80
|
+
* @category Numeric bounds
|
|
131
81
|
*/
|
|
132
82
|
readonly min?: Renderable.Any<number | null | undefined>;
|
|
133
|
-
/**
|
|
134
|
-
*
|
|
135
|
-
* ## Why
|
|
136
|
-
* The platform uses this bound for keyboard and constraint behavior.
|
|
137
|
-
* ## Ownership and lifetime
|
|
138
|
-
* Dynamic attributes follow the component Scope.
|
|
83
|
+
/**
|
|
84
|
+
* Native maximum value.
|
|
139
85
|
* @since 1.0.0
|
|
140
|
-
* @category
|
|
86
|
+
* @category Numeric bounds
|
|
141
87
|
*/
|
|
142
88
|
readonly max?: Renderable.Any<number | null | undefined>;
|
|
143
|
-
/**
|
|
144
|
-
*
|
|
145
|
-
* ## Why
|
|
146
|
-
* Step semantics remain delegated to the input element.
|
|
147
|
-
* ## Ownership and lifetime
|
|
148
|
-
* Dynamic attributes follow the component Scope.
|
|
89
|
+
/**
|
|
90
|
+
* Native step value or `"any"`.
|
|
149
91
|
* @since 1.0.0
|
|
150
|
-
* @category
|
|
92
|
+
* @category Numeric bounds
|
|
151
93
|
*/
|
|
152
94
|
readonly step?: Renderable.Any<number | "any" | null | undefined>;
|
|
153
95
|
}
|
|
@@ -162,26 +104,37 @@ declare function internalProps<const Options extends SliderOptions>(options: Opt
|
|
|
162
104
|
readonly ref: RefSubject.HydratedRefSubject<State, Schema.SchemaError, never, never>;
|
|
163
105
|
};
|
|
164
106
|
type SliderInternalProps<Options extends SliderOptions> = ReturnType<ReturnType<typeof internalProps<Options>>>;
|
|
165
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Renders a native range input whose input events update numeric state.
|
|
109
|
+
*
|
|
166
110
|
* @remarks
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* custom host must preserve type, value, range props, and the hydration ref.
|
|
111
|
+
* Dragging publishes through input, so expensive downstream work should control its own update
|
|
112
|
+
* rate. Native min/max/step, keyboard interaction, and pointer behavior stay with the browser.
|
|
113
|
+
* Supply a label and a unit-bearing readout; a custom non-input host must implement the
|
|
114
|
+
* interaction itself.
|
|
115
|
+
*
|
|
173
116
|
* @example
|
|
174
117
|
* ```ts
|
|
175
|
-
* import {
|
|
176
|
-
* import
|
|
118
|
+
* import { RefSubject } from "@typed/fx";
|
|
119
|
+
* import { html } from "@typed/template";
|
|
120
|
+
* import { component } from "@typed/ui/Component";
|
|
121
|
+
* import * as Slider from "@typed/ui/Slider";
|
|
177
122
|
*
|
|
178
|
-
* const
|
|
179
|
-
* const state = yield* Slider.makeState({ value:
|
|
180
|
-
*
|
|
181
|
-
*
|
|
123
|
+
* export const ZoomControl = component(function* () {
|
|
124
|
+
* const state = yield* Slider.makeState({ value: 100 });
|
|
125
|
+
* const percentage = RefSubject.map(state, ({ value }) => `${value}%`);
|
|
126
|
+
* return html`<div class="zoom-control">
|
|
127
|
+
* <label for="preview-zoom">Preview zoom</label>
|
|
128
|
+
* ${Slider.Slider({
|
|
129
|
+
* state, min: 50, max: 200, step: 10,
|
|
130
|
+
* props: { id: "preview-zoom", name: "zoom", "aria-valuetext": percentage },
|
|
131
|
+
* })}
|
|
132
|
+
* <output for="preview-zoom">${percentage}</output>
|
|
133
|
+
* </div>`;
|
|
134
|
+
* });
|
|
182
135
|
* ```
|
|
183
136
|
* @since 1.0.0
|
|
184
|
-
* @category
|
|
137
|
+
* @category Native controls
|
|
185
138
|
*/
|
|
186
139
|
export declare function Slider<const Options extends SliderOptions, const Host extends HostResult = never>(options: Options, host?: Dom.HostOverride<Dom.RenderHostProps<Options, SliderInternalProps<Options>>, "", Host>): import("./Dom/Types.js").HostComponent<Host | Options>;
|
|
187
140
|
export {};
|