@typed/ui 1.0.0-beta.1 → 1.0.0-beta.11

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.
Files changed (155) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +54 -10
  3. package/dist/Alert.d.ts +72 -0
  4. package/dist/Alert.d.ts.map +1 -0
  5. package/dist/Alert.js +40 -0
  6. package/dist/Button.d.ts +100 -0
  7. package/dist/Button.d.ts.map +1 -0
  8. package/dist/Button.js +42 -0
  9. package/dist/Carousel.d.ts +346 -0
  10. package/dist/Carousel.d.ts.map +1 -0
  11. package/dist/Carousel.js +264 -0
  12. package/dist/Checkbox.d.ts +168 -0
  13. package/dist/Checkbox.d.ts.map +1 -0
  14. package/dist/Checkbox.js +146 -0
  15. package/dist/Collection.d.ts +254 -0
  16. package/dist/Collection.d.ts.map +1 -0
  17. package/dist/Collection.js +218 -0
  18. package/dist/Combobox.d.ts +367 -0
  19. package/dist/Combobox.d.ts.map +1 -0
  20. package/dist/Combobox.js +300 -0
  21. package/dist/Composite.d.ts +823 -0
  22. package/dist/Composite.d.ts.map +1 -0
  23. package/dist/Composite.js +615 -0
  24. package/dist/Dialog.d.ts +544 -0
  25. package/dist/Dialog.d.ts.map +1 -0
  26. package/dist/Dialog.js +357 -0
  27. package/dist/Disclosure.d.ts +219 -0
  28. package/dist/Disclosure.d.ts.map +1 -0
  29. package/dist/Disclosure.js +128 -0
  30. package/dist/Dom/Events.d.ts +122 -0
  31. package/dist/Dom/Events.d.ts.map +1 -0
  32. package/dist/Dom/Events.js +192 -0
  33. package/dist/Dom/Props.d.ts +161 -0
  34. package/dist/Dom/Props.d.ts.map +1 -0
  35. package/dist/Dom/Props.js +110 -0
  36. package/dist/Dom/Refs.d.ts +58 -0
  37. package/dist/Dom/Refs.d.ts.map +1 -0
  38. package/dist/Dom/Refs.js +61 -0
  39. package/dist/Dom/Render.d.ts +59 -0
  40. package/dist/Dom/Render.d.ts.map +1 -0
  41. package/dist/Dom/Render.js +71 -0
  42. package/dist/Dom/Types.d.ts +570 -0
  43. package/dist/Dom/Types.d.ts.map +1 -0
  44. package/dist/Dom/Types.js +1 -0
  45. package/dist/Dom/index.d.ts +20 -0
  46. package/dist/Dom/index.d.ts.map +1 -0
  47. package/dist/Dom/index.js +8 -0
  48. package/dist/Dom.d.ts +14 -0
  49. package/dist/Dom.d.ts.map +1 -0
  50. package/dist/Dom.js +13 -0
  51. package/dist/Focusable.d.ts +85 -0
  52. package/dist/Focusable.d.ts.map +1 -0
  53. package/dist/Focusable.js +35 -0
  54. package/dist/Form.d.ts +1727 -0
  55. package/dist/Form.d.ts.map +1 -0
  56. package/dist/Form.js +1142 -0
  57. package/dist/Grid.d.ts +388 -0
  58. package/dist/Grid.d.ts.map +1 -0
  59. package/dist/Grid.js +284 -0
  60. package/dist/Group.d.ts +128 -0
  61. package/dist/Group.d.ts.map +1 -0
  62. package/dist/Group.js +71 -0
  63. package/dist/Heading.d.ts +87 -0
  64. package/dist/Heading.d.ts.map +1 -0
  65. package/dist/Heading.js +58 -0
  66. package/dist/Hovercard.d.ts +297 -0
  67. package/dist/Hovercard.d.ts.map +1 -0
  68. package/dist/Hovercard.js +188 -0
  69. package/dist/HttpRouter.d.ts +129 -6
  70. package/dist/HttpRouter.d.ts.map +1 -1
  71. package/dist/HttpRouter.js +198 -55
  72. package/dist/Link.d.ts +63 -28
  73. package/dist/Link.d.ts.map +1 -1
  74. package/dist/Link.js +84 -37
  75. package/dist/Listbox.d.ts +305 -0
  76. package/dist/Listbox.d.ts.map +1 -0
  77. package/dist/Listbox.js +245 -0
  78. package/dist/Menu.d.ts +663 -0
  79. package/dist/Menu.d.ts.map +1 -0
  80. package/dist/Menu.js +569 -0
  81. package/dist/Menubar.d.ts +249 -0
  82. package/dist/Menubar.d.ts.map +1 -0
  83. package/dist/Menubar.js +207 -0
  84. package/dist/Meter.d.ts +157 -0
  85. package/dist/Meter.d.ts.map +1 -0
  86. package/dist/Meter.js +87 -0
  87. package/dist/NativeDetails.d.ts +41 -0
  88. package/dist/NativeDetails.d.ts.map +1 -0
  89. package/dist/NativeDetails.js +40 -0
  90. package/dist/NativeDialog.d.ts +66 -0
  91. package/dist/NativeDialog.d.ts.map +1 -0
  92. package/dist/NativeDialog.js +88 -0
  93. package/dist/NativePopover.d.ts +43 -0
  94. package/dist/NativePopover.d.ts.map +1 -0
  95. package/dist/NativePopover.js +84 -0
  96. package/dist/Popover.d.ts +240 -0
  97. package/dist/Popover.d.ts.map +1 -0
  98. package/dist/Popover.js +140 -0
  99. package/dist/RadioGroup.d.ts +330 -0
  100. package/dist/RadioGroup.d.ts.map +1 -0
  101. package/dist/RadioGroup.js +241 -0
  102. package/dist/Role.d.ts +64 -0
  103. package/dist/Role.d.ts.map +1 -0
  104. package/dist/Role.js +27 -0
  105. package/dist/Select.d.ts +418 -0
  106. package/dist/Select.d.ts.map +1 -0
  107. package/dist/Select.js +357 -0
  108. package/dist/Separator.d.ts +58 -0
  109. package/dist/Separator.d.ts.map +1 -0
  110. package/dist/Separator.js +32 -0
  111. package/dist/Slider.d.ts +141 -0
  112. package/dist/Slider.d.ts.map +1 -0
  113. package/dist/Slider.js +101 -0
  114. package/dist/SpinButton.d.ts +141 -0
  115. package/dist/SpinButton.d.ts.map +1 -0
  116. package/dist/SpinButton.js +101 -0
  117. package/dist/Storybook.d.ts +76 -0
  118. package/dist/Storybook.d.ts.map +1 -0
  119. package/dist/Storybook.js +102 -0
  120. package/dist/Switch.d.ts +148 -0
  121. package/dist/Switch.d.ts.map +1 -0
  122. package/dist/Switch.js +110 -0
  123. package/dist/Tab.d.ts +26 -0
  124. package/dist/Tab.d.ts.map +1 -0
  125. package/dist/Tab.js +25 -0
  126. package/dist/Tabs.d.ts +411 -0
  127. package/dist/Tabs.d.ts.map +1 -0
  128. package/dist/Tabs.js +262 -0
  129. package/dist/Toolbar.d.ts +248 -0
  130. package/dist/Toolbar.d.ts.map +1 -0
  131. package/dist/Toolbar.js +187 -0
  132. package/dist/Tooltip.d.ts +296 -0
  133. package/dist/Tooltip.d.ts.map +1 -0
  134. package/dist/Tooltip.js +172 -0
  135. package/dist/Tree.d.ts +405 -0
  136. package/dist/Tree.d.ts.map +1 -0
  137. package/dist/Tree.js +333 -0
  138. package/dist/TreeGrid.d.ts +426 -0
  139. package/dist/TreeGrid.d.ts.map +1 -0
  140. package/dist/TreeGrid.js +308 -0
  141. package/dist/VisuallyHidden.d.ts +68 -0
  142. package/dist/VisuallyHidden.d.ts.map +1 -0
  143. package/dist/VisuallyHidden.js +44 -0
  144. package/dist/WindowSplitter.d.ts +336 -0
  145. package/dist/WindowSplitter.d.ts.map +1 -0
  146. package/dist/WindowSplitter.js +305 -0
  147. package/dist/index.d.ts +48 -0
  148. package/dist/index.d.ts.map +1 -1
  149. package/dist/index.js +48 -0
  150. package/package.json +48 -20
  151. package/src/HttpRouter.test.ts +0 -294
  152. package/src/HttpRouter.ts +0 -168
  153. package/src/Link.test.ts +0 -84
  154. package/src/Link.ts +0 -107
  155. package/src/index.ts +0 -2
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Menubar is a persistent horizontal composite. Its root establishes DOM-order roving focus and
3
+ * typeahead; items expose menuitem semantics and invoke caller-provided activation Effects.
4
+ *
5
+ * @remarks
6
+ * The module keeps policy, state transitions, and DOM rendering separable so applications can use
7
+ * the state and pure operations without mounting UI, or supply custom hosts without replacing native
8
+ * events and browser-owned focus.
9
+ *
10
+ * Learn the interaction in the [Menubar guide](/explore/ui-menubar).
11
+ *
12
+ * @since 1.0.0
13
+ * @category modules
14
+ * @packageDocumentation
15
+ */
16
+ import * as Effect from "effect/Effect";
17
+ import type * as Scope from "effect/Scope";
18
+ import * as Schema from "effect/Schema";
19
+ import type { Fx } from "@typed/fx/Fx";
20
+ import { RefSubject } from "@typed/fx";
21
+ import { EventHandler, type Renderable, type RenderEvent, type RenderTemplate } from "@typed/template";
22
+ import * as Collection from "./Collection.js";
23
+ import * as Composite from "./Composite.js";
24
+ import * as Dom from "./Dom.js";
25
+ import type { HostResult } from "./Dom/Types.js";
26
+ /**
27
+ * The active top-level command and horizontal navigation policy.
28
+ * Child menu visibility belongs to the separate Menu state connected by its submenu trigger.
29
+ *
30
+ * @since 1.0.0
31
+ * @category Command focus
32
+ */
33
+ export interface State extends Composite.State {
34
+ }
35
+ /**
36
+ * Initial Menubar values. Uses Composite defaults unless overridden.
37
+ *
38
+ * @since 1.0.0
39
+ * @category Command focus
40
+ */
41
+ export type InitialState = Composite.InitialState;
42
+ /**
43
+ * Effect Schema used by makeState to encode, decode, and hydrate Menubar state.
44
+ *
45
+ * @remarks
46
+ * @example
47
+ * ```ts
48
+ * import * as Schema from "effect/Schema";
49
+ * import * as Menubar from "@typed/ui/Menubar";
50
+ *
51
+ * const decodeState = Schema.decodeUnknownEffect(Menubar.StateSchema);
52
+ * ```
53
+ * @since 1.0.0
54
+ * @category Command focus
55
+ */
56
+ export declare const StateSchema: Schema.Struct<{
57
+ readonly activeId: Schema.NullOr<Schema.String>;
58
+ readonly orientation: Schema.Literals<readonly ["horizontal", "vertical", "both"]>;
59
+ readonly loop: Schema.Boolean;
60
+ readonly rtl: Schema.Boolean;
61
+ readonly virtualFocus: Schema.Boolean;
62
+ }>;
63
+ /**
64
+ * Creates hydrated Menubar state. Uses Composite defaults unless overridden.
65
+ *
66
+ * @remarks
67
+ * The returned Effect creates the RefSubject when run. That state is renderer-independent;
68
+ * collection registrations belong to the separate Scope that runs register or ref, not to state
69
+ * creation.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * import * as Effect from "effect/Effect";
74
+ * import * as Menubar from "@typed/ui/Menubar";
75
+ *
76
+ * const program = Effect.scoped(
77
+ * Effect.gen(function* () {
78
+ * const state = yield* Menubar.makeState({});
79
+ * const collection = yield* Menubar.makeCollection();
80
+ * return { state: yield* state, collection: yield* collection };
81
+ * }),
82
+ * );
83
+ * ```
84
+ * @since 1.0.0
85
+ * @category Command focus
86
+ */
87
+ export declare function makeState(initial?: InitialState): Effect.Effect<RefSubject.HydratedRefSubject<{
88
+ readonly activeId: string | null;
89
+ readonly orientation: "both" | "horizontal" | "vertical";
90
+ readonly loop: boolean;
91
+ readonly rtl: boolean;
92
+ readonly virtualFocus: boolean;
93
+ }, Schema.SchemaError, never, never>, never, Scope.Scope>;
94
+ /**
95
+ * Creates a scoped Collection for Menubar items.
96
+ *
97
+ * @remarks
98
+ * The returned Effect allocates the RefSubject in the caller's Scope. Each later registration is
99
+ * owned by the Scope that runs register, independently of this construction Effect.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * import * as Effect from "effect/Effect";
104
+ * import * as Menubar from "@typed/ui/Menubar";
105
+ *
106
+ * const program = Effect.scoped(
107
+ * Effect.gen(function* () {
108
+ * const collection = yield* Menubar.makeCollection();
109
+ * return yield* collection;
110
+ * }),
111
+ * );
112
+ * ```
113
+ * @since 1.0.0
114
+ * @category Command registration
115
+ */
116
+ export declare const makeCollection: (initial?: Collection.State<string, Element>) => Effect.Effect<RefSubject.RefSubject<Collection.State<string, Element>, never, never>, never, Scope.Scope>;
117
+ /**
118
+ * Inputs accepted by Menubar.Root in addition to the shared DOM host options.
119
+ *
120
+ * @since 1.0.0
121
+ * @category Menubar surface
122
+ */
123
+ export interface RootOptions extends Dom.HostOptions<HTMLDivElement> {
124
+ /**
125
+ * Renderer-independent RefSubject state consumed by this component or operation.
126
+ * @since 1.0.0
127
+ * @category State connection
128
+ */
129
+ readonly state: RefSubject.HydratedRefSubject<State, Schema.SchemaError>;
130
+ /**
131
+ * Item registry used for collection-driven keyboard behavior and mounted ordering.
132
+ * @since 1.0.0
133
+ * @category Item registration
134
+ */
135
+ readonly collection?: RefSubject.RefSubject<Collection.State<string>>;
136
+ /**
137
+ * Renderable child content for the component host.
138
+ * @since 1.0.0
139
+ * @category Rendered content
140
+ */
141
+ readonly content: Renderable.Any;
142
+ /**
143
+ * Accessible label rendered through aria-label.
144
+ * @since 1.0.0
145
+ * @category Accessible naming
146
+ */
147
+ readonly label?: Renderable.Any<string | null | undefined>;
148
+ }
149
+ declare function rootProps<const Options extends RootOptions>(options: Options): ({ property }: Dom.InternalPropsHelpers<Options>) => {
150
+ readonly role: "menubar";
151
+ readonly "aria-label": Exclude<Dom.Property<Options, "label">, Dom.Nullish> | undefined;
152
+ readonly "aria-orientation": RefSubject.Computed<Composite.Orientation, Schema.SchemaError, never>;
153
+ readonly tabindex: RefSubject.Computed<-1 | 0, Schema.SchemaError, never>;
154
+ readonly onfocus: Effect.Effect<void, Schema.SchemaError, never> | undefined;
155
+ readonly onkeydown: EventHandler.EventHandler<KeyboardEvent, Schema.SchemaError, never> | undefined;
156
+ readonly ref: RefSubject.HydratedRefSubject<State, Schema.SchemaError, never, never>;
157
+ };
158
+ type RootProps<Options extends RootOptions> = ReturnType<ReturnType<typeof rootProps<Options>>>;
159
+ /**
160
+ * Renders the persistent menubar root with roving focus, orientation-aware keys, and typeahead.
161
+ *
162
+ * @remarks
163
+ * The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
164
+ * collection registrations only when rendered. The rendering Scope removes those resources;
165
+ * unrelated nodes and attributes remain caller-owned.
166
+ *
167
+ * @since 1.0.0
168
+ * @category Menubar surface
169
+ */
170
+ export declare function Root<const Options extends RootOptions, const Host extends HostResult = never>(options: Options, host?: Dom.HostOverride<Dom.RenderHostProps<Options, RootProps<Options>>, Options["content"], Host>): Fx<RenderEvent, Renderable.Error<Options | Host>, Renderable.Services<Options | Host> | Scope.Scope | RenderTemplate>;
171
+ /**
172
+ * Consumer-facing alias of the canonical Menubar component with identical behavior and lifetime.
173
+ *
174
+ * @remarks
175
+ * The alias acquires nothing. Rendering it has exactly the canonical component's Scope and DOM
176
+ * ownership contract.
177
+ *
178
+ * @since 1.0.0
179
+ * @category Menubar surface
180
+ */
181
+ export declare const Menubar: typeof Root;
182
+ /**
183
+ * Inputs accepted by Menubar.Item in addition to the shared DOM host options.
184
+ *
185
+ * @since 1.0.0
186
+ * @category Top-level commands
187
+ */
188
+ export interface ItemOptions extends Dom.HostOptions<HTMLDivElement> {
189
+ /**
190
+ * Renderer-independent RefSubject state consumed by this component or operation.
191
+ * @since 1.0.0
192
+ * @category State connection
193
+ */
194
+ readonly state: RefSubject.HydratedRefSubject<State, Schema.SchemaError>;
195
+ /**
196
+ * Item registry used for collection-driven keyboard behavior and mounted ordering.
197
+ * @since 1.0.0
198
+ * @category Item registration
199
+ */
200
+ readonly collection?: RefSubject.RefSubject<Collection.State<string>>;
201
+ /**
202
+ * Stable id used for collection identity and ARIA relationships.
203
+ * @since 1.0.0
204
+ * @category Identity and relationships
205
+ */
206
+ readonly id: string;
207
+ /**
208
+ * Renderable child content for the component host.
209
+ * @since 1.0.0
210
+ * @category Rendered content
211
+ */
212
+ readonly content: Renderable.Any;
213
+ /**
214
+ * Search text used by typeahead independently of rendered markup.
215
+ * @since 1.0.0
216
+ * @category Text matching
217
+ */
218
+ readonly textValue?: string;
219
+ /**
220
+ * Flag used by collection movement and widget handlers to skip activation by default.
221
+ * @since 1.0.0
222
+ * @category Availability
223
+ */
224
+ readonly disabled?: boolean;
225
+ }
226
+ declare function itemProps<const Options extends ItemOptions>(options: Options): () => {
227
+ readonly id: string;
228
+ readonly role: "menuitem";
229
+ readonly "aria-disabled": boolean;
230
+ readonly tabindex: RefSubject.Computed<-1 | 0, Schema.SchemaError, never>;
231
+ readonly onfocus: Effect.Effect<State, Schema.SchemaError, never>;
232
+ readonly onclick: Effect.Effect<void, never, never> | Effect.Effect<State, Schema.SchemaError, never>;
233
+ readonly ref: ((element: Element & HTMLDivElement & RefSubject.HydrationElement) => Effect.Effect<void, any, any>) | undefined;
234
+ };
235
+ type ItemProps<Options extends ItemOptions> = ReturnType<ReturnType<typeof itemProps<Options>>>;
236
+ /**
237
+ * Renders a registered menuitem and runs onActivate for native focus or click unless disabled.
238
+ *
239
+ * @remarks
240
+ * The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
241
+ * collection registrations only when rendered. The rendering Scope removes those resources;
242
+ * unrelated nodes and attributes remain caller-owned.
243
+ *
244
+ * @since 1.0.0
245
+ * @category Top-level commands
246
+ */
247
+ 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>;
248
+ export {};
249
+ //# sourceMappingURL=Menubar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menubar.d.ts","sourceRoot":"","sources":["../src/Menubar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,YAAY,EAEZ,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,WAAW,KAAM,SAAQ,SAAS,CAAC,KAAK;CAAG;AACjD;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC;AAClD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW;;;;;;EAAwB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,YAAiB;;;;;;0DAEnD;A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EAAE,GAAG,CAAC,YAAY,CACrB,GAAG,CAAC,eAAe,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,EAChD,OAAO,CAAC,SAAS,CAAC,EAClB,IAAI,CACL,GACA,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,CAcA"}
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Menubar is a persistent horizontal composite. Its root establishes DOM-order roving focus and
3
+ * typeahead; items expose menuitem semantics and invoke caller-provided activation Effects.
4
+ *
5
+ * @remarks
6
+ * The module keeps policy, state transitions, and DOM rendering separable so applications can use
7
+ * the state and pure operations without mounting UI, or supply custom hosts without replacing native
8
+ * events and browser-owned focus.
9
+ *
10
+ * Learn the interaction in the [Menubar guide](/explore/ui-menubar).
11
+ *
12
+ * @since 1.0.0
13
+ * @category modules
14
+ * @packageDocumentation
15
+ */
16
+ import * as Effect from "effect/Effect";
17
+ import { RefSubject } from "@typed/fx";
18
+ import { EventHandler, html, } from "@typed/template";
19
+ import * as Collection from "./Collection.js";
20
+ import * as Composite from "./Composite.js";
21
+ import * as Dom from "./Dom.js";
22
+ /**
23
+ * Effect Schema used by makeState to encode, decode, and hydrate Menubar state.
24
+ *
25
+ * @remarks
26
+ * @example
27
+ * ```ts
28
+ * import * as Schema from "effect/Schema";
29
+ * import * as Menubar from "@typed/ui/Menubar";
30
+ *
31
+ * const decodeState = Schema.decodeUnknownEffect(Menubar.StateSchema);
32
+ * ```
33
+ * @since 1.0.0
34
+ * @category Command focus
35
+ */
36
+ export const StateSchema = Composite.StateSchema;
37
+ /**
38
+ * Creates hydrated Menubar state. Uses Composite defaults unless overridden.
39
+ *
40
+ * @remarks
41
+ * The returned Effect creates the RefSubject when run. That state is renderer-independent;
42
+ * collection registrations belong to the separate Scope that runs register or ref, not to state
43
+ * creation.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import * as Effect from "effect/Effect";
48
+ * import * as Menubar from "@typed/ui/Menubar";
49
+ *
50
+ * const program = Effect.scoped(
51
+ * Effect.gen(function* () {
52
+ * const state = yield* Menubar.makeState({});
53
+ * const collection = yield* Menubar.makeCollection();
54
+ * return { state: yield* state, collection: yield* collection };
55
+ * }),
56
+ * );
57
+ * ```
58
+ * @since 1.0.0
59
+ * @category Command focus
60
+ */
61
+ export function makeState(initial = {}) {
62
+ return Composite.makeState({ ...initial, orientation: initial.orientation ?? "horizontal" });
63
+ }
64
+ /**
65
+ * Creates a scoped Collection for Menubar items.
66
+ *
67
+ * @remarks
68
+ * The returned Effect allocates the RefSubject in the caller's Scope. Each later registration is
69
+ * owned by the Scope that runs register, independently of this construction Effect.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * import * as Effect from "effect/Effect";
74
+ * import * as Menubar from "@typed/ui/Menubar";
75
+ *
76
+ * const program = Effect.scoped(
77
+ * Effect.gen(function* () {
78
+ * const collection = yield* Menubar.makeCollection();
79
+ * return yield* collection;
80
+ * }),
81
+ * );
82
+ * ```
83
+ * @since 1.0.0
84
+ * @category Command registration
85
+ */
86
+ export const makeCollection = Collection.makeState;
87
+ function rootProps(options) {
88
+ let typeahead = { value: "", updatedAt: 0 };
89
+ const onfocus = options.collection === undefined
90
+ ? undefined
91
+ : Effect.gen(function* () {
92
+ if ((yield* options.state).activeId !== null)
93
+ return;
94
+ yield* Composite.moveAndFocus({
95
+ state: options.state,
96
+ collection: options.collection,
97
+ includeDisabled: true,
98
+ }, "first");
99
+ });
100
+ const onkeydown = options.collection === undefined
101
+ ? undefined
102
+ : EventHandler.make(Effect.fn(function* (event) {
103
+ if (event.key === "ArrowDown" || event.key === "Enter" || event.key === " ") {
104
+ const activeId = (yield* options.state).activeId;
105
+ const item = activeId === null
106
+ ? undefined
107
+ : (yield* options.collection).find((item) => item.id === activeId);
108
+ const shouldActivate = event.key !== "ArrowDown" || item?.submenu === true;
109
+ const element = shouldActivate && item?.disabled !== true ? item?.element : undefined;
110
+ const click = element === undefined ? undefined : Reflect.get(element, "click");
111
+ if (typeof click === "function") {
112
+ event.preventDefault();
113
+ yield* Effect.sync(() => click.call(element));
114
+ return;
115
+ }
116
+ }
117
+ const direction = Composite.keyMove(event, yield* options.state);
118
+ if (direction !== undefined) {
119
+ event.preventDefault();
120
+ yield* Composite.moveAndFocus({ state: options.state, collection: options.collection, includeDisabled: true }, direction);
121
+ return;
122
+ }
123
+ const key = Composite.typeaheadKey(event);
124
+ if (key === null)
125
+ return;
126
+ typeahead = Composite.updateTypeaheadBuffer(typeahead, key, Date.now());
127
+ const activeId = Composite.typeaheadFrom(yield* options.collection, typeahead.value, (yield* options.state).activeId, undefined, true);
128
+ if (activeId === null)
129
+ return;
130
+ event.preventDefault();
131
+ yield* RefSubject.update(options.state, (state) => ({ ...state, activeId }));
132
+ yield* Composite.focusActive({ state: options.state, collection: options.collection });
133
+ }));
134
+ return ({ property }) => ({
135
+ role: "menubar",
136
+ "aria-label": property("label", undefined),
137
+ "aria-orientation": RefSubject.map(options.state, (state) => state.orientation),
138
+ tabindex: Composite.rootTabIndex(options.state),
139
+ onfocus,
140
+ onkeydown,
141
+ ref: options.state,
142
+ });
143
+ }
144
+ /**
145
+ * Renders the persistent menubar root with roving focus, orientation-aware keys, and typeahead.
146
+ *
147
+ * @remarks
148
+ * The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
149
+ * collection registrations only when rendered. The rendering Scope removes those resources;
150
+ * unrelated nodes and attributes remain caller-owned.
151
+ *
152
+ * @since 1.0.0
153
+ * @category Menubar surface
154
+ */
155
+ export function Root(options, host) {
156
+ return Dom.renderHost()(options, host, rootProps(options), options.content, (props, content) => {
157
+ return html `<div ...${props}>${content}</div>`;
158
+ });
159
+ }
160
+ /**
161
+ * Consumer-facing alias of the canonical Menubar component with identical behavior and lifetime.
162
+ *
163
+ * @remarks
164
+ * The alias acquires nothing. Rendering it has exactly the canonical component's Scope and DOM
165
+ * ownership contract.
166
+ *
167
+ * @since 1.0.0
168
+ * @category Menubar surface
169
+ */
170
+ export const Menubar = Root;
171
+ function itemProps(options) {
172
+ const activate = options.disabled === true
173
+ ? Effect.void
174
+ : RefSubject.update(options.state, (state) => ({ ...state, activeId: options.id }));
175
+ const focus = RefSubject.update(options.state, (state) => ({ ...state, activeId: options.id }));
176
+ const register = options.collection === undefined
177
+ ? undefined
178
+ : Collection.ref(options.collection, {
179
+ id: options.id,
180
+ value: options.id,
181
+ textValue: options.textValue ?? options.id,
182
+ disabled: options.disabled,
183
+ });
184
+ return () => ({
185
+ id: options.id,
186
+ role: "menuitem",
187
+ "aria-disabled": options.disabled ?? false,
188
+ tabindex: Composite.tabIndex(options.state, options.id),
189
+ onfocus: focus,
190
+ onclick: activate,
191
+ ref: Dom.composeRefs(register, options.ref),
192
+ });
193
+ }
194
+ /**
195
+ * Renders a registered menuitem and runs onActivate for native focus or click unless disabled.
196
+ *
197
+ * @remarks
198
+ * The returned Fx installs DOM refs, native listeners, state subscriptions, and optional
199
+ * collection registrations only when rendered. The rendering Scope removes those resources;
200
+ * unrelated nodes and attributes remain caller-owned.
201
+ *
202
+ * @since 1.0.0
203
+ * @category Top-level commands
204
+ */
205
+ export function Item(options, host) {
206
+ return Dom.renderHost()(options, host, itemProps(options), options.content, (props, content) => html `<div ...${props}>${content}</div>`);
207
+ }
@@ -0,0 +1,157 @@
1
+ /**
2
+ * A non-interactive native measurement within a known range.
3
+ * Threshold options communicate preferred regions; they do not execute alert policies.
4
+ *
5
+ * Read the [Meter guide](/explore/ui-meter) for a complete example.
6
+ *
7
+ * [APG interaction reference](https://www.w3.org/WAI/ARIA/apg/patterns/meter/).
8
+ * @since 1.0.0
9
+ * @category Overview
10
+ * @packageDocumentation
11
+ */
12
+ import * as Effect from "effect/Effect";
13
+ import * as Schema from "effect/Schema";
14
+ import { RefSubject } from "@typed/fx";
15
+ import { type Renderable } from "@typed/template";
16
+ import * as Dom from "./Dom.js";
17
+ import type { HostResult } from "./Dom/Types.js";
18
+ /**
19
+ */
20
+ export interface State {
21
+ /**
22
+ */
23
+ readonly value: number;
24
+ }
25
+ /**
26
+ */
27
+ export interface InitialState {
28
+ /**
29
+ */
30
+ readonly value: number;
31
+ }
32
+ /**
33
+ */
34
+ export declare const StateSchema: Schema.Struct<{
35
+ readonly value: Schema.Finite;
36
+ }>;
37
+ /**
38
+ * Creates hydrated meter state.
39
+ * @remarks
40
+ * The state remains testable and reusable without rendering a UI component.
41
+ * The caller's Effect Scope owns the hydrated RefSubject.
42
+ * @example
43
+ * ```ts
44
+ * import { Effect } from "effect"
45
+ * import * as Meter from "@typed/ui/Meter"
46
+ *
47
+ * const program = Effect.gen(function* () {
48
+ * return yield* Meter.makeState({ value: 0.72 })
49
+ * })
50
+ * ```
51
+ * @since 1.0.0
52
+ * @category State construction
53
+ */
54
+ export declare function makeState(initial: InitialState): Effect.Effect<RefSubject.HydratedRefSubject<{
55
+ readonly value: number;
56
+ }, Schema.SchemaError, never, never>, never, import("effect/Scope").Scope>;
57
+ /**
58
+ * Assigns the displayed measurement without clamping it to the meter range.
59
+ *
60
+ * @remarks
61
+ * Keep measurement units consistent with min/max and threshold options. This operation does not
62
+ * execute threshold actions or validate the preferred range.
63
+ * @since 1.0.0
64
+ * @category State transitions
65
+ */
66
+ export declare function setValue<E, R>(state: RefSubject.RefSubject<State, E, R>, value: number): Effect.Effect<State, E, R>;
67
+ /**
68
+ */
69
+ export interface MeterOptions extends Dom.HostOptions<HTMLMeterElement> {
70
+ /**
71
+ * Hydrated value state borrowed by the element.
72
+ * @since 1.0.0
73
+ * @category State connection
74
+ */
75
+ readonly state: RefSubject.HydratedRefSubject<State, Schema.SchemaError>;
76
+ /**
77
+ * Lower bound of the measured range.
78
+ * @since 1.0.0
79
+ * @category Numeric bounds
80
+ */
81
+ readonly min?: Renderable.Any<number | null | undefined>;
82
+ /**
83
+ * Upper bound of the measured range.
84
+ * @since 1.0.0
85
+ * @category Numeric bounds
86
+ */
87
+ readonly max?: Renderable.Any<number | null | undefined>;
88
+ /**
89
+ * Boundary below which values are considered low.
90
+ * @since 1.0.0
91
+ * @category Measurement thresholds
92
+ */
93
+ readonly low?: Renderable.Any<number | null | undefined>;
94
+ /**
95
+ * Boundary above which values are considered high.
96
+ * @since 1.0.0
97
+ * @category Measurement thresholds
98
+ */
99
+ readonly high?: Renderable.Any<number | null | undefined>;
100
+ /**
101
+ * Preferred value within the meter range.
102
+ * @since 1.0.0
103
+ * @category Measurement thresholds
104
+ */
105
+ readonly optimum?: Renderable.Any<number | null | undefined>;
106
+ /**
107
+ * Fallback content rendered inside the meter.
108
+ * @since 1.0.0
109
+ * @category Rendered content
110
+ */
111
+ readonly content?: Renderable.Any;
112
+ }
113
+ declare function internalProps<const Options extends MeterOptions>(options: Options): ({ property }: Dom.InternalPropsHelpers<Options>) => {
114
+ readonly value: RefSubject.Computed<number, Schema.SchemaError, never>;
115
+ readonly min: Exclude<Dom.Property<Options, "min">, Dom.Nullish> | undefined;
116
+ readonly max: Exclude<Dom.Property<Options, "max">, Dom.Nullish> | undefined;
117
+ readonly low: Exclude<Dom.Property<Options, "low">, Dom.Nullish> | undefined;
118
+ readonly high: Exclude<Dom.Property<Options, "high">, Dom.Nullish> | undefined;
119
+ readonly optimum: Exclude<Dom.Property<Options, "optimum">, Dom.Nullish> | undefined;
120
+ readonly ref: RefSubject.HydratedRefSubject<State, Schema.SchemaError, never, never>;
121
+ };
122
+ type MeterInternalProps<Options extends MeterOptions> = ReturnType<ReturnType<typeof internalProps<Options>>>;
123
+ /**
124
+ * Renders a native meter for a measurement within a known range.
125
+ *
126
+ * @remarks
127
+ * Supply a label and coherent min/max/low/high/optimum values. The browser presents thresholds;
128
+ * the component does not trigger alerts when they are crossed. Use a slider for editing or a
129
+ * progress element for operation completion. The meter has no keyboard action.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * import { RefSubject } from "@typed/fx";
134
+ * import { html } from "@typed/template";
135
+ * import { component } from "@typed/template";
136
+ * import * as Meter from "@typed/ui/Meter";
137
+ *
138
+ * export const StorageUsage = component(function* () {
139
+ * const state = yield* Meter.makeState({ value: 64 });
140
+ * const description = RefSubject.map(state, ({ value }) => `${value} GB of 100 GB used`);
141
+ * return html`<section>
142
+ * <label for="storage-meter">Storage used</label>
143
+ * ${Meter.Meter({
144
+ * state, min: 0, max: 100, low: 60, high: 85, optimum: 0,
145
+ * content: description,
146
+ * props: { id: "storage-meter", "aria-valuetext": description },
147
+ * })}
148
+ * <p>${description}</p>
149
+ * </section>`;
150
+ * });
151
+ * ```
152
+ * @since 1.0.0
153
+ * @category Controls
154
+ */
155
+ export declare function Meter<const Options extends MeterOptions, const Host extends HostResult = never>(options: Options, host?: Dom.HostOverride<Dom.RenderHostProps<Options, MeterInternalProps<Options>>, Options["content"], Host>): import("./Dom/Types.js").HostComponent<Host | Options>;
156
+ export {};
157
+ //# sourceMappingURL=Meter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meter.d.ts","sourceRoot":"","sources":["../src/Meter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD;GACG;AACH,MAAM,WAAW,KAAK;IACpB;OACG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;GACG;AACH,MAAM,WAAW,YAAY;IAC3B;OACG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;GACG;AACH,eAAO,MAAM,WAAW;;EAA0C,CAA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