@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.
Files changed (130) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -1
  3. package/dist/Alert.d.ts +35 -41
  4. package/dist/Alert.d.ts.map +1 -1
  5. package/dist/Alert.js +23 -20
  6. package/dist/Button.d.ts +34 -78
  7. package/dist/Button.d.ts.map +1 -1
  8. package/dist/Button.js +16 -12
  9. package/dist/Carousel.d.ts +35 -236
  10. package/dist/Carousel.d.ts.map +1 -1
  11. package/dist/Carousel.js +13 -136
  12. package/dist/Checkbox.d.ts +55 -90
  13. package/dist/Checkbox.d.ts.map +1 -1
  14. package/dist/Checkbox.js +44 -38
  15. package/dist/Collection.d.ts +15 -15
  16. package/dist/Collection.js +7 -7
  17. package/dist/Combobox.d.ts +38 -187
  18. package/dist/Combobox.d.ts.map +1 -1
  19. package/dist/Combobox.js +9 -80
  20. package/dist/Component.d.ts +30 -24
  21. package/dist/Component.d.ts.map +1 -1
  22. package/dist/Component.js +23 -12
  23. package/dist/Composite.d.ts +50 -50
  24. package/dist/Composite.js +20 -20
  25. package/dist/Dialog.d.ts +34 -34
  26. package/dist/Dialog.d.ts.map +1 -1
  27. package/dist/Dialog.js +16 -14
  28. package/dist/Disclosure.d.ts +15 -15
  29. package/dist/Disclosure.js +6 -6
  30. package/dist/Dom/Events.d.ts +4 -4
  31. package/dist/Dom/Events.js +4 -4
  32. package/dist/Dom/Props.d.ts +9 -9
  33. package/dist/Dom/Props.js +4 -4
  34. package/dist/Dom/Refs.d.ts +2 -2
  35. package/dist/Dom/Refs.js +1 -1
  36. package/dist/Dom/Render.d.ts +2 -2
  37. package/dist/Dom/Render.js +2 -2
  38. package/dist/Dom/Types.d.ts +33 -33
  39. package/dist/Dom/index.d.ts +5 -5
  40. package/dist/Dom/index.d.ts.map +1 -1
  41. package/dist/Dom/index.js +4 -4
  42. package/dist/Dom.d.ts +1 -1
  43. package/dist/Dom.js +1 -1
  44. package/dist/Focusable.d.ts +5 -5
  45. package/dist/Focusable.js +1 -1
  46. package/dist/Form.d.ts +565 -533
  47. package/dist/Form.d.ts.map +1 -1
  48. package/dist/Form.js +350 -195
  49. package/dist/Grid.d.ts +39 -220
  50. package/dist/Grid.d.ts.map +1 -1
  51. package/dist/Grid.js +12 -107
  52. package/dist/Group.d.ts +50 -69
  53. package/dist/Group.d.ts.map +1 -1
  54. package/dist/Group.js +33 -25
  55. package/dist/Heading.d.ts +41 -40
  56. package/dist/Heading.d.ts.map +1 -1
  57. package/dist/Heading.js +26 -16
  58. package/dist/Hovercard.d.ts +18 -18
  59. package/dist/Hovercard.js +6 -6
  60. package/dist/HttpRouter.d.ts +3 -3
  61. package/dist/HttpRouter.js +5 -5
  62. package/dist/Link.d.ts +17 -21
  63. package/dist/Link.d.ts.map +1 -1
  64. package/dist/Link.js +11 -0
  65. package/dist/Listbox.d.ts +31 -163
  66. package/dist/Listbox.d.ts.map +1 -1
  67. package/dist/Listbox.js +9 -80
  68. package/dist/Menu.d.ts +67 -376
  69. package/dist/Menu.d.ts.map +1 -1
  70. package/dist/Menu.js +17 -179
  71. package/dist/Menubar.d.ts +24 -142
  72. package/dist/Menubar.d.ts.map +1 -1
  73. package/dist/Menubar.js +8 -66
  74. package/dist/Meter.d.ts +72 -132
  75. package/dist/Meter.d.ts.map +1 -1
  76. package/dist/Meter.js +35 -42
  77. package/dist/NativeDetails.d.ts +1 -1
  78. package/dist/NativeDetails.js +1 -1
  79. package/dist/NativeDialog.d.ts +7 -5
  80. package/dist/NativeDialog.d.ts.map +1 -1
  81. package/dist/NativeDialog.js +42 -4
  82. package/dist/NativePopover.d.ts +6 -4
  83. package/dist/NativePopover.d.ts.map +1 -1
  84. package/dist/NativePopover.js +43 -5
  85. package/dist/Popover.d.ts +18 -19
  86. package/dist/Popover.d.ts.map +1 -1
  87. package/dist/Popover.js +7 -8
  88. package/dist/RadioGroup.d.ts +86 -188
  89. package/dist/RadioGroup.d.ts.map +1 -1
  90. package/dist/RadioGroup.js +55 -105
  91. package/dist/Role.d.ts +4 -4
  92. package/dist/Role.js +1 -1
  93. package/dist/Select.d.ts +109 -220
  94. package/dist/Select.d.ts.map +1 -1
  95. package/dist/Select.js +67 -117
  96. package/dist/Separator.d.ts +30 -26
  97. package/dist/Separator.d.ts.map +1 -1
  98. package/dist/Separator.js +16 -10
  99. package/dist/Slider.d.ts +64 -111
  100. package/dist/Slider.d.ts.map +1 -1
  101. package/dist/Slider.js +47 -42
  102. package/dist/SpinButton.d.ts +64 -111
  103. package/dist/SpinButton.d.ts.map +1 -1
  104. package/dist/SpinButton.js +47 -42
  105. package/dist/Storybook.d.ts +2 -2
  106. package/dist/Storybook.js +1 -1
  107. package/dist/Switch.d.ts +52 -91
  108. package/dist/Switch.d.ts.map +1 -1
  109. package/dist/Switch.js +30 -36
  110. package/dist/Tabs.d.ts +44 -224
  111. package/dist/Tabs.d.ts.map +1 -1
  112. package/dist/Tabs.js +10 -94
  113. package/dist/Toolbar.d.ts +24 -142
  114. package/dist/Toolbar.d.ts.map +1 -1
  115. package/dist/Toolbar.js +8 -66
  116. package/dist/Tooltip.d.ts +20 -20
  117. package/dist/Tooltip.js +6 -6
  118. package/dist/Tree.d.ts +43 -229
  119. package/dist/Tree.d.ts.map +1 -1
  120. package/dist/Tree.js +12 -113
  121. package/dist/TreeGrid.d.ts +45 -264
  122. package/dist/TreeGrid.d.ts.map +1 -1
  123. package/dist/TreeGrid.js +13 -125
  124. package/dist/VisuallyHidden.d.ts +41 -27
  125. package/dist/VisuallyHidden.d.ts.map +1 -1
  126. package/dist/VisuallyHidden.js +27 -10
  127. package/dist/WindowSplitter.d.ts +68 -108
  128. package/dist/WindowSplitter.d.ts.map +1 -1
  129. package/dist/WindowSplitter.js +106 -23
  130. package/package.json +13 -12
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present The Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > **Beta:** This package is in beta; APIs may change.
4
4
 
5
- `@typed/ui` is the **web integration layer** for `@typed/router` and `@typed/template`. It bridges typed-smol's routing and template system with the browser and Effect's HTTP stack.
5
+ `@typed/ui` is the **web integration layer** for `@typed/router` and `@typed/template`. It bridges typed's routing and template system with the browser and Effect's HTTP stack.
6
6
 
7
7
  ## Capabilities
8
8
 
package/dist/Alert.d.ts CHANGED
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Assertive live-region content without focus movement or an announcement queue.
3
+ * Use urgent text updates deliberately; routine feedback usually belongs in a status region.
4
+ *
5
+ * Read the [Alert guide](/explore/ui-alert) for a complete example.
6
+ *
7
+ * [APG interaction reference](https://www.w3.org/WAI/ARIA/apg/patterns/alert/).
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";
@@ -7,36 +18,16 @@ import type { HostResult } from "./Dom/Types.js";
7
18
  * Options for the assertive alert live region.
8
19
  *
9
20
  * @remarks
10
- * ## Why
11
- *
12
21
  * Alerts announce important, time-sensitive output without moving focus or
13
22
  * requiring a modal interaction.
14
- *
15
- * ## Ownership and lifetime
16
- *
17
- * The options are inert. Rendering owns only the alert host and subscriptions
18
- * for renderable option values; the running Effect Scope removes them.
19
- *
20
23
  * @since 1.0.0
21
- * @category models
24
+ * @category Component options
22
25
  */
23
26
  export interface AlertOptions extends Dom.HostOptions<HTMLDivElement> {
24
27
  /**
25
28
  * Content announced by the `role="alert"` live region.
26
- *
27
- * @remarks
28
- * ## Why
29
- *
30
- * Keeping the announcement renderable lets applications publish Effect- or
31
- * Fx-backed status while retaining the platform accessibility tree.
32
- *
33
- * ## Ownership and lifetime
34
- *
35
- * The value acquires no resources itself. Rendering subscribes to dynamic
36
- * content for the lifetime of the alert's Scope.
37
- *
38
29
  * @since 1.0.0
39
- * @category content
30
+ * @category Rendered content
40
31
  */
41
32
  readonly content: Renderable.Any;
42
33
  }
@@ -45,33 +36,36 @@ declare function internalProps(): {
45
36
  };
46
37
  type AlertInternalProps = ReturnType<typeof internalProps>;
47
38
  /**
48
- * Renders a non-modal, assertive live region.
49
- *
50
- * For an interrupting confirmation, use `Dialog.Content` with
51
- * `role="alertdialog"`; an alert must not take focus or require dismissal.
39
+ * Renders an assertive alert region without moving focus.
52
40
  *
53
41
  * @remarks
54
- * ## Why
55
- *
56
- * `Alert` supplies the native ARIA live-region contract while leaving content,
57
- * host choice, and Effect requirements composable. It does not synthesize an
58
- * event or introduce an application-owned announcement queue.
59
- *
60
- * ## Ownership and lifetime
61
- *
62
- * Calling `Alert` starts no work. Running the returned Fx owns the rendered
63
- * host, dynamic values, and listeners in its Effect Scope; finalization removes
64
- * only those resources. A custom host must preserve the supplied `role`.
42
+ * Keep the region mounted and change its text when an urgent event occurs. Initial page content
43
+ * or repeated identical messages may not announce as expected. This primitive does not queue
44
+ * announcements, schedule dismissal, or provide an acknowledgement dialog. Prefer a status
45
+ * region for routine updates.
65
46
  *
66
47
  * @example
67
48
  * ```ts
68
- * import { Alert } from "@typed/ui/Alert"
49
+ * import { RefSubject } from "@typed/fx";
50
+ * import { html } from "@typed/template";
51
+ * import { Alert } from "@typed/ui/Alert";
52
+ * import { Button } from "@typed/ui/Button";
53
+ * import { component } from "@typed/ui/Component";
69
54
  *
70
- * const saved = Alert({ content: "Changes saved" })
55
+ * export const AlertPreview = component(function* () {
56
+ * const message = yield* RefSubject.make("");
57
+ * return html`<section>
58
+ * <p>Preview the message shown when an upload fails.</p>
59
+ * ${Button({
60
+ * content: "Preview upload failure",
61
+ * onclick: RefSubject.set(message, "Upload failed. Your file is still available; try again."),
62
+ * })}
63
+ * ${Alert({ content: message, props: { class: "upload-alert" } })}
64
+ * </section>`;
65
+ * });
71
66
  * ```
72
- *
73
67
  * @since 1.0.0
74
- * @category components
68
+ * @category Controls
75
69
  */
76
70
  export declare function Alert<const Options extends AlertOptions, const Host extends HostResult = never>(options: Options, host?: Dom.HostOverride<Dom.RenderHostProps<Options, AlertInternalProps>, Options["content"], Host>): Fx<RenderEvent, Renderable.Error<Options | Host>, Renderable.Services<Options | Host> | Scope.Scope | RenderTemplate>;
77
71
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../src/Alert.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,KA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AEjD;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAa,SAAQ,GAAG,CAAC,WAAW,CAAC,cAAc,CAAC;IACnE;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC;CAClC;AAED,iBAAS,aAAa;aACX,IAAI,EAAE,OAAO;EACvB;AACD,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,KAAK,CAAC,KAAK,CAAC,OAAO,SAAS,YAAY,EAAE,KAAK,CAAC,IAAI,SAAS,UAAU,GAAG,KAAK,EAC7F,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,GAAG,CAAC,YAAY,CACrB,GAAG,CAAC,eAAe,CAAC,OAAO,EAAE,kBAAkB,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,CAQA"}
package/dist/Alert.js CHANGED
@@ -4,33 +4,36 @@ function internalProps() {
4
4
  return { role: "alert" };
5
5
  }
6
6
  /**
7
- * Renders a non-modal, assertive live region.
8
- *
9
- * For an interrupting confirmation, use `Dialog.Content` with
10
- * `role="alertdialog"`; an alert must not take focus or require dismissal.
7
+ * Renders an assertive alert region without moving focus.
11
8
  *
12
9
  * @remarks
13
- * ## Why
14
- *
15
- * `Alert` supplies the native ARIA live-region contract while leaving content,
16
- * host choice, and Effect requirements composable. It does not synthesize an
17
- * event or introduce an application-owned announcement queue.
18
- *
19
- * ## Ownership and lifetime
20
- *
21
- * Calling `Alert` starts no work. Running the returned Fx owns the rendered
22
- * host, dynamic values, and listeners in its Effect Scope; finalization removes
23
- * only those resources. A custom host must preserve the supplied `role`.
10
+ * Keep the region mounted and change its text when an urgent event occurs. Initial page content
11
+ * or repeated identical messages may not announce as expected. This primitive does not queue
12
+ * announcements, schedule dismissal, or provide an acknowledgement dialog. Prefer a status
13
+ * region for routine updates.
24
14
  *
25
15
  * @example
26
16
  * ```ts
27
- * import { Alert } from "@typed/ui/Alert"
28
- *
29
- * const saved = Alert({ content: "Changes saved" })
17
+ * import { RefSubject } from "@typed/fx";
18
+ * import { html } from "@typed/template";
19
+ * import { Alert } from "@typed/ui/Alert";
20
+ * import { Button } from "@typed/ui/Button";
21
+ * import { component } from "@typed/ui/Component";
22
+ *
23
+ * export const AlertPreview = component(function* () {
24
+ * const message = yield* RefSubject.make("");
25
+ * return html`<section>
26
+ * <p>Preview the message shown when an upload fails.</p>
27
+ * ${Button({
28
+ * content: "Preview upload failure",
29
+ * onclick: RefSubject.set(message, "Upload failed. Your file is still available; try again."),
30
+ * })}
31
+ * ${Alert({ content: message, props: { class: "upload-alert" } })}
32
+ * </section>`;
33
+ * });
30
34
  * ```
31
- *
32
35
  * @since 1.0.0
33
- * @category components
36
+ * @category Controls
34
37
  */
35
38
  export function Alert(options, host) {
36
39
  return Dom.renderHost()(options, host, internalProps, options.content, (props, content) => html `<div ...${props}>${content}</div>`);
package/dist/Button.d.ts CHANGED
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Native command activation and explicit button/submit/reset behavior.
3
+ * The control has no internal click action; return application Effects from its handler.
4
+ *
5
+ * Read the [Button guide](/explore/ui-button) for a complete example.
6
+ *
7
+ * [APG interaction reference](https://www.w3.org/WAI/ARIA/apg/patterns/button/).
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";
@@ -7,103 +18,44 @@ import type { HostResult } from "./Dom/Types.js";
7
18
  * Native button submission behavior.
8
19
  *
9
20
  * @remarks
10
- * ## Why
11
- *
12
21
  * The union exposes the exact HTML button types and defaults components to the
13
22
  * non-submitting `button` behavior.
14
- *
15
- * ## Ownership and lifetime
16
- *
17
- * This is a pure type and acquires no resources.
18
- *
19
23
  * @since 1.0.0
20
- * @category models
24
+ * @category State models
21
25
  */
22
26
  export type ButtonType = "button" | "submit" | "reset";
23
27
  /**
24
28
  * Renderable state and host options for a native button.
25
29
  *
26
30
  * @remarks
27
- * ## Why
28
- *
29
31
  * The model keeps native button semantics while allowing content, disabled
30
32
  * state, and handlers to come from any Typed renderable source.
31
- *
32
- * ## Ownership and lifetime
33
- *
34
- * The options are inert. The rendered component's Scope owns dynamic option
35
- * subscriptions and listener cleanup.
36
- *
37
33
  * @since 1.0.0
38
- * @category models
34
+ * @category Component options
39
35
  */
40
36
  export interface ButtonOptions extends Dom.HostOptions<HTMLButtonElement> {
41
37
  /**
42
38
  * The button's visible and accessible content.
43
- *
44
- * @remarks
45
- * ## Why
46
- *
47
- * Native content supplies the accessible name unless the host explicitly
48
- * provides another naming mechanism.
49
- *
50
- * ## Ownership and lifetime
51
- *
52
- * Dynamic content is subscribed to only while the component Scope is open.
53
- *
54
39
  * @since 1.0.0
55
- * @category content
40
+ * @category Rendered content
56
41
  */
57
42
  readonly content: Renderable.Any;
58
43
  /**
59
44
  * The native `type` attribute; defaults to `"button"`.
60
- *
61
- * @remarks
62
- * ## Why
63
- *
64
- * An explicit non-submitting default prevents a reusable button from
65
- * accidentally submitting an enclosing form.
66
- *
67
- * ## Ownership and lifetime
68
- *
69
- * The value is reflected by the renderer and retains no resources.
70
- *
71
45
  * @since 1.0.0
72
- * @category attributes
46
+ * @category Native attributes
73
47
  */
74
48
  readonly type?: Renderable.Any<ButtonType | null | undefined>;
75
49
  /**
76
50
  * Whether the native control is disabled.
77
- *
78
- * @remarks
79
- * ## Why
80
- *
81
- * Using the native disabled state removes the button from interaction and
82
- * form submission according to browser semantics.
83
- *
84
- * ## Ownership and lifetime
85
- *
86
- * Dynamic values are observed for the component Scope and then released.
87
- *
88
51
  * @since 1.0.0
89
- * @category attributes
52
+ * @category Availability
90
53
  */
91
54
  readonly disabled?: Renderable.Any<boolean | null | undefined>;
92
55
  /**
93
56
  * A real DOM click handler supplied by the consumer.
94
- *
95
- * @remarks
96
- * ## Why
97
- *
98
- * `Button` has no internal activation handler. The supplied handler receives
99
- * the real DOM click event; browser default actions remain native.
100
- *
101
- * ## Ownership and lifetime
102
- *
103
- * Rendering installs the listener and the component Scope removes it.
104
- *
105
57
  * @since 1.0.0
106
- * @category events
58
+ * @category Event handlers
107
59
  */
108
60
  readonly onclick?: Dom.EventHandlerInput<Dom.EventOf<HTMLButtonElement["onclick"]>>;
109
61
  }
@@ -116,28 +68,32 @@ type ButtonInternalProps<Options extends ButtonOptions> = ReturnType<typeof inte
116
68
  * Renders a semantic native button with cooperative host customization.
117
69
  *
118
70
  * @remarks
119
- * ## Why
120
- *
121
71
  * `Button` retains browser keyboard, form, focus, and accessibility behavior.
122
72
  * Its internal props only establish the default type and disabled state. Any
123
73
  * `onclick` behavior belongs entirely to the consumer and receives a real DOM
124
74
  * event; there is no component-internal click action to chain or cancel.
125
75
  *
126
- * ## Ownership and lifetime
127
- *
128
- * Calling the factory is inert. Running its Fx owns the host's dynamic parts
129
- * and listeners in an Effect Scope. A custom host must apply the supplied props
130
- * and content so disabled and button-type semantics are not lost.
131
- *
132
76
  * @example
133
77
  * ```ts
134
- * import { Button } from "@typed/ui/Button"
135
- *
136
- * const submit = Button({ type: "submit", content: "Save" })
78
+ * import { RefSubject } from "@typed/fx";
79
+ * import { html } from "@typed/template";
80
+ * import { Button } from "@typed/ui/Button";
81
+ * import { component } from "@typed/ui/Component";
82
+ *
83
+ * export const PreviewCounter = component(function* () {
84
+ * const previews = yield* RefSubject.make(0);
85
+ * return html`<section>
86
+ * ${Button({
87
+ * content: "Recalculate preview",
88
+ * props: { class: "preview-action" },
89
+ * onclick: RefSubject.update(previews, (count) => count + 1),
90
+ * })}
91
+ * <p role="status">Preview calculations: ${previews}</p>
92
+ * </section>`;
93
+ * });
137
94
  * ```
138
- *
139
95
  * @since 1.0.0
140
- * @category components
96
+ * @category Native controls
141
97
  */
142
98
  export declare function Button<const Options extends ButtonOptions, const Host extends HostResult = never>(options: Options, host?: Dom.HostOverride<Dom.RenderHostProps<Options, ButtonInternalProps<Options>>, Options["content"], Host>): Fx<RenderEvent, Renderable.Error<Options | Host>, Renderable.Services<Options | Host> | Scope.Scope | RenderTemplate>;
143
99
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../src/Button.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;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,aAAc,SAAQ,GAAG,CAAC,WAAW,CAAC,iBAAiB,CAAC;IACvE;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC;IACjC;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IAC9D;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,GAAG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YAAY,CACrB,GAAG,CAAC,eAAe,CAAC,OAAO,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC,EAC1D,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,CAQA"}
package/dist/Button.js CHANGED
@@ -10,28 +10,32 @@ function internalProps({ property, }) {
10
10
  * Renders a semantic native button with cooperative host customization.
11
11
  *
12
12
  * @remarks
13
- * ## Why
14
- *
15
13
  * `Button` retains browser keyboard, form, focus, and accessibility behavior.
16
14
  * Its internal props only establish the default type and disabled state. Any
17
15
  * `onclick` behavior belongs entirely to the consumer and receives a real DOM
18
16
  * event; there is no component-internal click action to chain or cancel.
19
17
  *
20
- * ## Ownership and lifetime
21
- *
22
- * Calling the factory is inert. Running its Fx owns the host's dynamic parts
23
- * and listeners in an Effect Scope. A custom host must apply the supplied props
24
- * and content so disabled and button-type semantics are not lost.
25
- *
26
18
  * @example
27
19
  * ```ts
28
- * import { Button } from "@typed/ui/Button"
20
+ * import { RefSubject } from "@typed/fx";
21
+ * import { html } from "@typed/template";
22
+ * import { Button } from "@typed/ui/Button";
23
+ * import { component } from "@typed/ui/Component";
29
24
  *
30
- * const submit = Button({ type: "submit", content: "Save" })
25
+ * export const PreviewCounter = component(function* () {
26
+ * const previews = yield* RefSubject.make(0);
27
+ * return html`<section>
28
+ * ${Button({
29
+ * content: "Recalculate preview",
30
+ * props: { class: "preview-action" },
31
+ * onclick: RefSubject.update(previews, (count) => count + 1),
32
+ * })}
33
+ * <p role="status">Preview calculations: ${previews}</p>
34
+ * </section>`;
35
+ * });
31
36
  * ```
32
- *
33
37
  * @since 1.0.0
34
- * @category components
38
+ * @category Native controls
35
39
  */
36
40
  export function Button(options, host) {
37
41
  return Dom.renderHost()(options, host, internalProps, options.content, (props, content) => html `<button ...${props}>${content}</button>`);