@typed/ui 1.0.0-beta.5 → 1.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Alert.d.ts +35 -41
- package/dist/Alert.d.ts.map +1 -1
- package/dist/Alert.js +23 -20
- package/dist/Button.d.ts +34 -78
- package/dist/Button.d.ts.map +1 -1
- package/dist/Button.js +16 -12
- package/dist/Carousel.d.ts +35 -236
- package/dist/Carousel.d.ts.map +1 -1
- package/dist/Carousel.js +13 -136
- package/dist/Checkbox.d.ts +55 -90
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Checkbox.js +44 -38
- package/dist/Collection.d.ts +15 -15
- package/dist/Collection.js +7 -7
- package/dist/Combobox.d.ts +38 -187
- package/dist/Combobox.d.ts.map +1 -1
- package/dist/Combobox.js +9 -80
- package/dist/Component.d.ts +30 -24
- package/dist/Component.d.ts.map +1 -1
- package/dist/Component.js +23 -12
- package/dist/Composite.d.ts +50 -50
- package/dist/Composite.js +20 -20
- package/dist/Dialog.d.ts +34 -34
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Dialog.js +16 -14
- package/dist/Disclosure.d.ts +15 -15
- package/dist/Disclosure.js +6 -6
- package/dist/Dom/Events.d.ts +4 -4
- package/dist/Dom/Events.js +4 -4
- package/dist/Dom/Props.d.ts +9 -9
- package/dist/Dom/Props.js +4 -4
- package/dist/Dom/Refs.d.ts +2 -2
- package/dist/Dom/Refs.js +1 -1
- package/dist/Dom/Render.d.ts +2 -2
- package/dist/Dom/Render.js +2 -2
- package/dist/Dom/Types.d.ts +33 -33
- package/dist/Dom/index.d.ts +5 -5
- package/dist/Dom/index.d.ts.map +1 -1
- package/dist/Dom/index.js +4 -4
- package/dist/Dom.d.ts +1 -1
- package/dist/Dom.js +1 -1
- package/dist/Focusable.d.ts +5 -5
- package/dist/Focusable.js +1 -1
- package/dist/Form.d.ts +565 -533
- package/dist/Form.d.ts.map +1 -1
- package/dist/Form.js +350 -195
- package/dist/Grid.d.ts +39 -220
- package/dist/Grid.d.ts.map +1 -1
- package/dist/Grid.js +12 -107
- package/dist/Group.d.ts +50 -69
- package/dist/Group.d.ts.map +1 -1
- package/dist/Group.js +33 -25
- package/dist/Heading.d.ts +41 -40
- package/dist/Heading.d.ts.map +1 -1
- package/dist/Heading.js +26 -16
- package/dist/Hovercard.d.ts +18 -18
- package/dist/Hovercard.js +6 -6
- package/dist/HttpRouter.d.ts +3 -3
- package/dist/HttpRouter.js +5 -5
- package/dist/Link.d.ts +17 -21
- package/dist/Link.d.ts.map +1 -1
- package/dist/Link.js +11 -0
- package/dist/Listbox.d.ts +31 -163
- package/dist/Listbox.d.ts.map +1 -1
- package/dist/Listbox.js +9 -80
- package/dist/Menu.d.ts +67 -376
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Menu.js +17 -179
- package/dist/Menubar.d.ts +24 -142
- package/dist/Menubar.d.ts.map +1 -1
- package/dist/Menubar.js +8 -66
- package/dist/Meter.d.ts +72 -132
- package/dist/Meter.d.ts.map +1 -1
- package/dist/Meter.js +35 -42
- package/dist/NativeDetails.d.ts +1 -1
- package/dist/NativeDetails.js +1 -1
- package/dist/NativeDialog.d.ts +7 -5
- package/dist/NativeDialog.d.ts.map +1 -1
- package/dist/NativeDialog.js +42 -4
- package/dist/NativePopover.d.ts +6 -4
- package/dist/NativePopover.d.ts.map +1 -1
- package/dist/NativePopover.js +43 -5
- package/dist/Popover.d.ts +18 -19
- package/dist/Popover.d.ts.map +1 -1
- package/dist/Popover.js +7 -8
- package/dist/RadioGroup.d.ts +86 -188
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RadioGroup.js +55 -105
- package/dist/Role.d.ts +4 -4
- package/dist/Role.js +1 -1
- package/dist/Select.d.ts +109 -220
- package/dist/Select.d.ts.map +1 -1
- package/dist/Select.js +67 -117
- package/dist/Separator.d.ts +30 -26
- package/dist/Separator.d.ts.map +1 -1
- package/dist/Separator.js +16 -10
- package/dist/Slider.d.ts +64 -111
- package/dist/Slider.d.ts.map +1 -1
- package/dist/Slider.js +47 -42
- package/dist/SpinButton.d.ts +64 -111
- package/dist/SpinButton.d.ts.map +1 -1
- package/dist/SpinButton.js +47 -42
- package/dist/Storybook.d.ts +2 -2
- package/dist/Storybook.js +1 -1
- package/dist/Switch.d.ts +52 -91
- package/dist/Switch.d.ts.map +1 -1
- package/dist/Switch.js +30 -36
- package/dist/Tabs.d.ts +44 -224
- package/dist/Tabs.d.ts.map +1 -1
- package/dist/Tabs.js +10 -94
- package/dist/Toolbar.d.ts +24 -142
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar.js +8 -66
- package/dist/Tooltip.d.ts +20 -20
- package/dist/Tooltip.js +6 -6
- package/dist/Tree.d.ts +43 -229
- package/dist/Tree.d.ts.map +1 -1
- package/dist/Tree.js +12 -113
- package/dist/TreeGrid.d.ts +45 -264
- package/dist/TreeGrid.d.ts.map +1 -1
- package/dist/TreeGrid.js +13 -125
- package/dist/VisuallyHidden.d.ts +41 -27
- package/dist/VisuallyHidden.d.ts.map +1 -1
- package/dist/VisuallyHidden.js +27 -10
- package/dist/WindowSplitter.d.ts +68 -108
- package/dist/WindowSplitter.d.ts.map +1 -1
- package/dist/WindowSplitter.js +106 -23
- package/package.json +9 -8
package/dist/Tree.js
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* the state and pure operations without mounting UI, or supply custom hosts without replacing native
|
|
9
9
|
* events and browser-owned focus.
|
|
10
10
|
*
|
|
11
|
+
* Learn the interaction in the [Tree guide](/explore/ui-tree).
|
|
12
|
+
*
|
|
11
13
|
* @since 1.0.0
|
|
12
14
|
* @category modules
|
|
13
15
|
* @packageDocumentation
|
|
@@ -23,15 +25,6 @@ import * as Dom from "./Dom.js";
|
|
|
23
25
|
* Effect Schema used by makeState to encode, decode, and hydrate Tree state.
|
|
24
26
|
*
|
|
25
27
|
* @remarks
|
|
26
|
-
* ## Why
|
|
27
|
-
*
|
|
28
|
-
* A public schema makes hydration and serialized state use the same runtime validation as direct
|
|
29
|
-
* construction.
|
|
30
|
-
*
|
|
31
|
-
* ## Ownership and lifetime
|
|
32
|
-
*
|
|
33
|
-
* This declaration is data or schema metadata and acquires no resources.
|
|
34
|
-
*
|
|
35
28
|
* @example
|
|
36
29
|
* ```ts
|
|
37
30
|
* import * as Schema from "effect/Schema";
|
|
@@ -40,7 +33,7 @@ import * as Dom from "./Dom.js";
|
|
|
40
33
|
* const decodeState = Schema.decodeUnknownEffect(Tree.StateSchema);
|
|
41
34
|
* ```
|
|
42
35
|
* @since 1.0.0
|
|
43
|
-
* @category
|
|
36
|
+
* @category Hierarchy state
|
|
44
37
|
*/
|
|
45
38
|
export const StateSchema = Schema.Struct({
|
|
46
39
|
activeId: Schema.NullOr(Schema.String),
|
|
@@ -51,12 +44,6 @@ export const StateSchema = Schema.Struct({
|
|
|
51
44
|
* Creates hydrated Tree state. activeId defaults null and expandedIds defaults empty.
|
|
52
45
|
*
|
|
53
46
|
* @remarks
|
|
54
|
-
* ## Why
|
|
55
|
-
*
|
|
56
|
-
* State and collection ownership can be composed and tested independently from any renderer.
|
|
57
|
-
*
|
|
58
|
-
* ## Ownership and lifetime
|
|
59
|
-
*
|
|
60
47
|
* The returned Effect creates the RefSubject when run. That state is renderer-independent;
|
|
61
48
|
* collection registrations belong to the separate Scope that runs register or ref, not to state
|
|
62
49
|
* creation.
|
|
@@ -75,7 +62,7 @@ export const StateSchema = Schema.Struct({
|
|
|
75
62
|
* );
|
|
76
63
|
* ```
|
|
77
64
|
* @since 1.0.0
|
|
78
|
-
* @category
|
|
65
|
+
* @category Hierarchy state
|
|
79
66
|
*/
|
|
80
67
|
export function makeState(initial = {}) {
|
|
81
68
|
return RefSubject.hydrate(StateSchema, {
|
|
@@ -88,12 +75,6 @@ export function makeState(initial = {}) {
|
|
|
88
75
|
* Creates a scoped Collection for Tree items.
|
|
89
76
|
*
|
|
90
77
|
* @remarks
|
|
91
|
-
* ## Why
|
|
92
|
-
*
|
|
93
|
-
* State and collection ownership can be composed and tested independently from any renderer.
|
|
94
|
-
*
|
|
95
|
-
* ## Ownership and lifetime
|
|
96
|
-
*
|
|
97
78
|
* The returned Effect allocates the RefSubject in the caller's Scope. Each later registration is
|
|
98
79
|
* owned by the Scope that runs register, independently of this construction Effect.
|
|
99
80
|
*
|
|
@@ -110,20 +91,16 @@ export function makeState(initial = {}) {
|
|
|
110
91
|
* );
|
|
111
92
|
* ```
|
|
112
93
|
* @since 1.0.0
|
|
113
|
-
* @category
|
|
94
|
+
* @category Node registration
|
|
114
95
|
*/
|
|
115
96
|
export const makeCollection = Collection.makeState;
|
|
116
97
|
/**
|
|
117
98
|
* Tests membership in expandedIds without touching the DOM.
|
|
118
99
|
*
|
|
119
100
|
* @remarks
|
|
120
|
-
* ## Why
|
|
121
|
-
*
|
|
122
101
|
* Separating this deterministic policy from event wiring lets applications test it directly and
|
|
123
102
|
* reuse it in custom composites.
|
|
124
103
|
*
|
|
125
|
-
* ## Ownership and lifetime
|
|
126
|
-
*
|
|
127
104
|
* This is a synchronous calculation. It acquires no resources and does not mutate the input array,
|
|
128
105
|
* state, event, or DOM.
|
|
129
106
|
*
|
|
@@ -134,7 +111,7 @@ export const makeCollection = Collection.makeState;
|
|
|
134
111
|
* const expanded = Tree.isExpanded({ activeId: null, expandedIds: ["parent"], loop: true }, "parent");
|
|
135
112
|
* ```
|
|
136
113
|
* @since 1.0.0
|
|
137
|
-
* @category
|
|
114
|
+
* @category Expansion
|
|
138
115
|
*/
|
|
139
116
|
export function isExpanded(state, id) {
|
|
140
117
|
return state.expandedIds.includes(id);
|
|
@@ -143,24 +120,11 @@ export function isExpanded(state, id) {
|
|
|
143
120
|
* Adds an id once to expandedIds.
|
|
144
121
|
*
|
|
145
122
|
* @remarks
|
|
146
|
-
* ## Why
|
|
147
|
-
*
|
|
148
123
|
* The operation exposes Tree's transition directly so callers can compose it in Effect programs
|
|
149
124
|
* and native event handlers.
|
|
150
125
|
*
|
|
151
|
-
* ## Ownership and lifetime
|
|
152
|
-
*
|
|
153
|
-
* The returned Effect performs the update or DOM side effect only when run, preserves the declared
|
|
154
|
-
* error and service channels, and retains no resources after completion.
|
|
155
|
-
*
|
|
156
|
-
* ## Example
|
|
157
|
-
*
|
|
158
|
-
* Import with `import { expand } from "@typed/ui/Tree";` Extend the [Tree.makeState runnable
|
|
159
|
-
* setup](/reference/%40typed%2Fui%2FTree%23makeState). Inside the linked Effect program invoke
|
|
160
|
-
* `yield* expand(state, "item-2")`, then read the state snapshot to observe the transition
|
|
161
|
-
* described above.
|
|
162
126
|
* @since 1.0.0
|
|
163
|
-
* @category
|
|
127
|
+
* @category Expansion
|
|
164
128
|
*/
|
|
165
129
|
export function expand(state, id) {
|
|
166
130
|
return RefSubject.update(state, (current) => isExpanded(current, id) ? current : { ...current, expandedIds: [...current.expandedIds, id] });
|
|
@@ -169,24 +133,11 @@ export function expand(state, id) {
|
|
|
169
133
|
* Removes an id from expandedIds.
|
|
170
134
|
*
|
|
171
135
|
* @remarks
|
|
172
|
-
* ## Why
|
|
173
|
-
*
|
|
174
136
|
* The operation exposes Tree's transition directly so callers can compose it in Effect programs
|
|
175
137
|
* and native event handlers.
|
|
176
138
|
*
|
|
177
|
-
* ## Ownership and lifetime
|
|
178
|
-
*
|
|
179
|
-
* The returned Effect performs the update or DOM side effect only when run, preserves the declared
|
|
180
|
-
* error and service channels, and retains no resources after completion.
|
|
181
|
-
*
|
|
182
|
-
* ## Example
|
|
183
|
-
*
|
|
184
|
-
* Import with `import { collapse } from "@typed/ui/Tree";` Extend the [Tree.makeState runnable
|
|
185
|
-
* setup](/reference/%40typed%2Fui%2FTree%23makeState). Inside the linked Effect program invoke
|
|
186
|
-
* `yield* collapse(state, "item-2")`, then read the state snapshot to observe the transition
|
|
187
|
-
* described above.
|
|
188
139
|
* @since 1.0.0
|
|
189
|
-
* @category
|
|
140
|
+
* @category Expansion
|
|
190
141
|
*/
|
|
191
142
|
export function collapse(state, id) {
|
|
192
143
|
return RefSubject.update(state, (current) => ({
|
|
@@ -198,24 +149,11 @@ export function collapse(state, id) {
|
|
|
198
149
|
* Sets the active tree item id without changing expansion.
|
|
199
150
|
*
|
|
200
151
|
* @remarks
|
|
201
|
-
* ## Why
|
|
202
|
-
*
|
|
203
152
|
* The operation exposes Tree's transition directly so callers can compose it in Effect programs
|
|
204
153
|
* and native event handlers.
|
|
205
154
|
*
|
|
206
|
-
* ## Ownership and lifetime
|
|
207
|
-
*
|
|
208
|
-
* The returned Effect performs the update or DOM side effect only when run, preserves the declared
|
|
209
|
-
* error and service channels, and retains no resources after completion.
|
|
210
|
-
*
|
|
211
|
-
* ## Example
|
|
212
|
-
*
|
|
213
|
-
* Import with `import { activate } from "@typed/ui/Tree";` Extend the [Tree.makeState runnable
|
|
214
|
-
* setup](/reference/%40typed%2Fui%2FTree%23makeState). Inside the linked Effect program invoke
|
|
215
|
-
* `yield* activate(state, "item-2")`, then read the state snapshot to observe the transition
|
|
216
|
-
* described above.
|
|
217
155
|
* @since 1.0.0
|
|
218
|
-
* @category
|
|
156
|
+
* @category Node focus
|
|
219
157
|
*/
|
|
220
158
|
export function activate(state, activeId) {
|
|
221
159
|
return RefSubject.update(state, (current) => ({ ...current, activeId }));
|
|
@@ -249,25 +187,12 @@ function rootInternalProps(options) {
|
|
|
249
187
|
* Renders the tree root and applies hierarchy-aware keyboard navigation to registered items.
|
|
250
188
|
*
|
|
251
189
|
* @remarks
|
|
252
|
-
* ## Why
|
|
253
|
-
*
|
|
254
|
-
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
255
|
-
* through the shared DOM boundary.
|
|
256
|
-
*
|
|
257
|
-
* ## Ownership and lifetime
|
|
258
|
-
*
|
|
259
190
|
* The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
|
|
260
191
|
* collection registrations only when rendered. The rendering Scope removes those resources;
|
|
261
192
|
* unrelated nodes and attributes remain caller-owned.
|
|
262
193
|
*
|
|
263
|
-
* ## Example
|
|
264
|
-
*
|
|
265
|
-
* Import with `import { Root } from "@typed/ui/Tree";` Extend the [Tree.makeState runnable
|
|
266
|
-
* setup](/reference/%40typed%2Fui%2FTree%23makeState). Replace the linked program's final snapshot
|
|
267
|
-
* read with `Root({ state, label: "Files", content: "Items" })`; render that Fx before the same
|
|
268
|
-
* Scope closes.
|
|
269
194
|
* @since 1.0.0
|
|
270
|
-
* @category
|
|
195
|
+
* @category Tree surface
|
|
271
196
|
*/
|
|
272
197
|
export function Root(options, host) {
|
|
273
198
|
return Dom.renderHost()(options, host, rootInternalProps(options), options.content, (props, content) => {
|
|
@@ -303,25 +228,12 @@ function itemInternalProps(options) {
|
|
|
303
228
|
* state.
|
|
304
229
|
*
|
|
305
230
|
* @remarks
|
|
306
|
-
* ## Why
|
|
307
|
-
*
|
|
308
|
-
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
309
|
-
* through the shared DOM boundary.
|
|
310
|
-
*
|
|
311
|
-
* ## Ownership and lifetime
|
|
312
|
-
*
|
|
313
231
|
* The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
|
|
314
232
|
* collection registrations only when rendered. The rendering Scope removes those resources;
|
|
315
233
|
* unrelated nodes and attributes remain caller-owned.
|
|
316
234
|
*
|
|
317
|
-
* ## Example
|
|
318
|
-
*
|
|
319
|
-
* Import with `import { Item } from "@typed/ui/Tree";` Extend the [Tree.makeState runnable
|
|
320
|
-
* setup](/reference/%40typed%2Fui%2FTree%23makeState). Replace the linked program's final snapshot
|
|
321
|
-
* read with `Item({ state, id: "src", hasChildren: true, content: "src" })`; render that Fx before
|
|
322
|
-
* the same Scope closes.
|
|
323
235
|
* @since 1.0.0
|
|
324
|
-
* @category
|
|
236
|
+
* @category Tree nodes
|
|
325
237
|
*/
|
|
326
238
|
export function Item(options, host) {
|
|
327
239
|
return Dom.renderHost()(options, host, itemInternalProps(options), options.content, (props, content) => {
|
|
@@ -338,25 +250,12 @@ function groupInternalProps(options) {
|
|
|
338
250
|
* Renders a child group and hides it while its parent id is not expanded.
|
|
339
251
|
*
|
|
340
252
|
* @remarks
|
|
341
|
-
* ## Why
|
|
342
|
-
*
|
|
343
|
-
* The component applies the family behavior while leaving callers free to supply a custom host
|
|
344
|
-
* through the shared DOM boundary.
|
|
345
|
-
*
|
|
346
|
-
* ## Ownership and lifetime
|
|
347
|
-
*
|
|
348
253
|
* The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
|
|
349
254
|
* collection registrations only when rendered. The rendering Scope removes those resources;
|
|
350
255
|
* unrelated nodes and attributes remain caller-owned.
|
|
351
256
|
*
|
|
352
|
-
* ## Example
|
|
353
|
-
*
|
|
354
|
-
* Import with `import { Group } from "@typed/ui/Tree";` Extend the [Tree.makeState runnable
|
|
355
|
-
* setup](/reference/%40typed%2Fui%2FTree%23makeState). Replace the linked program's final snapshot
|
|
356
|
-
* read with `Group({ state, parentId: "src", content: "Children" })`; render that Fx before the
|
|
357
|
-
* same Scope closes.
|
|
358
257
|
* @since 1.0.0
|
|
359
|
-
* @category
|
|
258
|
+
* @category Child visibility
|
|
360
259
|
*/
|
|
361
260
|
export function Group(options, host) {
|
|
362
261
|
return Dom.renderHost()(options, host, groupInternalProps(options), options.content, (props, content) => html `<div ...${props}>${content}</div>`);
|