@bitforgehq/ui 0.3.0

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 (281) hide show
  1. package/CHANGELOG.md +3665 -0
  2. package/LICENSE +21 -0
  3. package/README.md +175 -0
  4. package/ai/MANIFEST.index.json +383 -0
  5. package/ai/MANIFEST.json +7528 -0
  6. package/ai/REFERENCE.index.json +1461 -0
  7. package/ai/REFERENCE.json +7213 -0
  8. package/ai/UI_GUIDE.md +1159 -0
  9. package/ai/components/action-bar.md +209 -0
  10. package/ai/components/action-sheet.md +526 -0
  11. package/ai/components/alert-dialog.md +509 -0
  12. package/ai/components/alert.md +376 -0
  13. package/ai/components/avatar.md +146 -0
  14. package/ai/components/back-button.md +286 -0
  15. package/ai/components/badge.md +171 -0
  16. package/ai/components/button.md +431 -0
  17. package/ai/components/card.md +303 -0
  18. package/ai/components/checkbox.md +418 -0
  19. package/ai/components/chip-group.md +205 -0
  20. package/ai/components/chip.md +300 -0
  21. package/ai/components/content.md +474 -0
  22. package/ai/components/desktop-toast.md +420 -0
  23. package/ai/components/dialog.md +962 -0
  24. package/ai/components/empty-state.md +146 -0
  25. package/ai/components/field.md +319 -0
  26. package/ai/components/header.md +809 -0
  27. package/ai/components/icon-button.md +221 -0
  28. package/ai/components/icon.md +176 -0
  29. package/ai/components/input.md +455 -0
  30. package/ai/components/list-item.md +326 -0
  31. package/ai/components/list.md +178 -0
  32. package/ai/components/menu-button.md +377 -0
  33. package/ai/components/menu.md +661 -0
  34. package/ai/components/modal.md +613 -0
  35. package/ai/components/number-input.md +423 -0
  36. package/ai/components/page.md +299 -0
  37. package/ai/components/progress.md +215 -0
  38. package/ai/components/radio-group.md +432 -0
  39. package/ai/components/refresher.md +377 -0
  40. package/ai/components/segmented.md +517 -0
  41. package/ai/components/select.md +510 -0
  42. package/ai/components/sheet.md +845 -0
  43. package/ai/components/spinner.md +171 -0
  44. package/ai/components/stack-outlet.md +661 -0
  45. package/ai/components/tab-bar.md +427 -0
  46. package/ai/components/tab.md +295 -0
  47. package/ai/components/tabs.md +408 -0
  48. package/ai/components/textarea.md +371 -0
  49. package/ai/components/toast.md +522 -0
  50. package/ai/components/toggle.md +387 -0
  51. package/ai/reference/bf-action-directive.md +21 -0
  52. package/ai/reference/bf-action-sheet-action-role.md +27 -0
  53. package/ai/reference/bf-action-sheet-action.md +28 -0
  54. package/ai/reference/bf-action-sheet-options.md +28 -0
  55. package/ai/reference/bf-action-sheet-service.md +33 -0
  56. package/ai/reference/bf-alert-dialog-button-role.md +27 -0
  57. package/ai/reference/bf-alert-dialog-button.md +27 -0
  58. package/ai/reference/bf-alert-dialog-options.md +29 -0
  59. package/ai/reference/bf-alert-dialog-service.md +34 -0
  60. package/ai/reference/bf-alert-variant.md +28 -0
  61. package/ai/reference/bf-autocapitalize.md +30 -0
  62. package/ai/reference/bf-avatar-size.md +27 -0
  63. package/ai/reference/bf-avatar-variant.md +28 -0
  64. package/ai/reference/bf-back-at-root.md +28 -0
  65. package/ai/reference/bf-back-button-service.md +40 -0
  66. package/ai/reference/bf-badge-variant.md +29 -0
  67. package/ai/reference/bf-button-size.md +29 -0
  68. package/ai/reference/bf-button-type.md +28 -0
  69. package/ai/reference/bf-button-variant.md +29 -0
  70. package/ai/reference/bf-card-padding.md +26 -0
  71. package/ai/reference/bf-card-variant.md +28 -0
  72. package/ai/reference/bf-chip-group-mode.md +27 -0
  73. package/ai/reference/bf-chip-variant.md +26 -0
  74. package/ai/reference/bf-compare-with.md +24 -0
  75. package/ai/reference/bf-component-overlay-ref.md +33 -0
  76. package/ai/reference/bf-confirm-button-role.md +26 -0
  77. package/ai/reference/bf-confirm-button.md +27 -0
  78. package/ai/reference/bf-confirm-options.md +31 -0
  79. package/ai/reference/bf-confirm-size.md +26 -0
  80. package/ai/reference/bf-content-scroll-event.md +21 -0
  81. package/ai/reference/bf-defaults-options.md +32 -0
  82. package/ai/reference/bf-defaults.md +28 -0
  83. package/ai/reference/bf-desktop-toast-config.md +28 -0
  84. package/ai/reference/bf-desktop-toast-harness.md +33 -0
  85. package/ai/reference/bf-desktop-toast-options.md +28 -0
  86. package/ai/reference/bf-desktop-toast-position.md +28 -0
  87. package/ai/reference/bf-desktop-toast-service.md +42 -0
  88. package/ai/reference/bf-dialog-config.md +44 -0
  89. package/ai/reference/bf-dialog-harness.md +52 -0
  90. package/ai/reference/bf-dialog-ref.md +44 -0
  91. package/ai/reference/bf-dialog-role.md +26 -0
  92. package/ai/reference/bf-dialog-service.md +55 -0
  93. package/ai/reference/bf-dialog-size.md +31 -0
  94. package/ai/reference/bf-dialog-template-context.md +32 -0
  95. package/ai/reference/bf-empty-state-heading-level.md +26 -0
  96. package/ai/reference/bf-enter-key-hint.md +31 -0
  97. package/ai/reference/bf-field-control-class.md +32 -0
  98. package/ai/reference/bf-field-control-state.md +28 -0
  99. package/ai/reference/bf-field-size.md +29 -0
  100. package/ai/reference/bf-haptics-impact-style.md +27 -0
  101. package/ai/reference/bf-haptics-notification-type.md +27 -0
  102. package/ai/reference/bf-haptics-service.md +41 -0
  103. package/ai/reference/bf-harness-filters.md +29 -0
  104. package/ai/reference/bf-horizontal-scroll-directive.md +129 -0
  105. package/ai/reference/bf-icon-button-variant.md +28 -0
  106. package/ai/reference/bf-icon-size.md +27 -0
  107. package/ai/reference/bf-input-autocapitalize.md +36 -0
  108. package/ai/reference/bf-input-enter-key-hint.md +38 -0
  109. package/ai/reference/bf-input-input-mode.md +38 -0
  110. package/ai/reference/bf-input-mode.md +32 -0
  111. package/ai/reference/bf-input-type.md +35 -0
  112. package/ai/reference/bf-jsdom-shim-options.md +22 -0
  113. package/ai/reference/bf-keyboard-assist-behavior.md +26 -0
  114. package/ai/reference/bf-keyboard-assist-directive.md +185 -0
  115. package/ai/reference/bf-keyboard-phase.md +30 -0
  116. package/ai/reference/bf-keyboard-service.md +50 -0
  117. package/ai/reference/bf-labels-overrides.md +26 -0
  118. package/ai/reference/bf-labels.md +44 -0
  119. package/ai/reference/bf-menu-button-harness.md +40 -0
  120. package/ai/reference/bf-menu-button-variant.md +27 -0
  121. package/ai/reference/bf-menu-divider-directive.md +13 -0
  122. package/ai/reference/bf-menu-group-directive.md +14 -0
  123. package/ai/reference/bf-menu-harness.md +55 -0
  124. package/ai/reference/bf-menu-item-checkbox-directive.md +31 -0
  125. package/ai/reference/bf-menu-item-directive.md +31 -0
  126. package/ai/reference/bf-menu-item-harness.md +52 -0
  127. package/ai/reference/bf-menu-item-radio-directive.md +29 -0
  128. package/ai/reference/bf-menu-placement.md +29 -0
  129. package/ai/reference/bf-menu-trigger-directive.md +46 -0
  130. package/ai/reference/bf-modal-options.md +30 -0
  131. package/ai/reference/bf-modal-presentation.md +26 -0
  132. package/ai/reference/bf-modal-service.md +38 -0
  133. package/ai/reference/bf-nav-controller.md +59 -0
  134. package/ai/reference/bf-nav-direction.md +23 -0
  135. package/ai/reference/bf-nav-target.md +21 -0
  136. package/ai/reference/bf-number-input-mode.md +28 -0
  137. package/ai/reference/bf-number-input-step.md +25 -0
  138. package/ai/reference/bf-overlay-auto-focus.md +29 -0
  139. package/ai/reference/bf-overlay-controller.md +22 -0
  140. package/ai/reference/bf-overlay-host.md +36 -0
  141. package/ai/reference/bf-overlay-options.md +53 -0
  142. package/ai/reference/bf-overlay-position.md +30 -0
  143. package/ai/reference/bf-overlay-ref.md +53 -0
  144. package/ai/reference/bf-overlay-role.md +27 -0
  145. package/ai/reference/bf-overlay-service.md +53 -0
  146. package/ai/reference/bf-overlay-stack-options.md +24 -0
  147. package/ai/reference/bf-overlay-stack.md +81 -0
  148. package/ai/reference/bf-overlay-template-context.md +24 -0
  149. package/ai/reference/bf-overscroll-stretch-directive.md +163 -0
  150. package/ai/reference/bf-page-context.md +24 -0
  151. package/ai/reference/bf-platform-service.md +53 -0
  152. package/ai/reference/bf-platform.md +28 -0
  153. package/ai/reference/bf-progress-size.md +26 -0
  154. package/ai/reference/bf-progress-tone.md +28 -0
  155. package/ai/reference/bf-radio-group-harness.md +49 -0
  156. package/ai/reference/bf-radio-group-orientation.md +26 -0
  157. package/ai/reference/bf-radio-option.md +30 -0
  158. package/ai/reference/bf-refresher-refresh-event.md +22 -0
  159. package/ai/reference/bf-segment-option.md +29 -0
  160. package/ai/reference/bf-segmented-harness.md +48 -0
  161. package/ai/reference/bf-segmented-size.md +29 -0
  162. package/ai/reference/bf-select-harness.md +70 -0
  163. package/ai/reference/bf-select-option.md +29 -0
  164. package/ai/reference/bf-sheet-auto-focus.md +29 -0
  165. package/ai/reference/bf-sheet-options.md +32 -0
  166. package/ai/reference/bf-sheet-ref.md +45 -0
  167. package/ai/reference/bf-sheet-service.md +34 -0
  168. package/ai/reference/bf-shell-config-mode.md +28 -0
  169. package/ai/reference/bf-shell-config.md +38 -0
  170. package/ai/reference/bf-shell-dynamic-type-limit.md +21 -0
  171. package/ai/reference/bf-shell-dynamic-type.md +25 -0
  172. package/ai/reference/bf-shell-mode.md +28 -0
  173. package/ai/reference/bf-shell-testing-options.md +26 -0
  174. package/ai/reference/bf-size.md +45 -0
  175. package/ai/reference/bf-spinner-size.md +27 -0
  176. package/ai/reference/bf-stack-change.md +22 -0
  177. package/ai/reference/bf-stack-reuse-strategy.md +32 -0
  178. package/ai/reference/bf-stack-transition-event.md +26 -0
  179. package/ai/reference/bf-stack-transition.md +26 -0
  180. package/ai/reference/bf-stacked-overlay.md +23 -0
  181. package/ai/reference/bf-system-bars-style.md +38 -0
  182. package/ai/reference/bf-tab-bar-controller.md +51 -0
  183. package/ai/reference/bf-tab-bar-host.md +52 -0
  184. package/ai/reference/bf-tab-context.md +32 -0
  185. package/ai/reference/bf-tab-links.md +37 -0
  186. package/ai/reference/bf-testing-options.md +27 -0
  187. package/ai/reference/bf-text-scale-service.md +35 -0
  188. package/ai/reference/bf-theme.md +27 -0
  189. package/ai/reference/bf-toast-action.md +25 -0
  190. package/ai/reference/bf-toast-controller.md +17 -0
  191. package/ai/reference/bf-toast-dismiss-reason.md +29 -0
  192. package/ai/reference/bf-toast-options.md +29 -0
  193. package/ai/reference/bf-toast-position.md +26 -0
  194. package/ai/reference/bf-toast-ref.md +41 -0
  195. package/ai/reference/bf-toast-service.md +39 -0
  196. package/ai/reference/bf-toggle-label-position.md +26 -0
  197. package/ai/reference/bf-transition-kind.md +28 -0
  198. package/ai/reference/bf-validation-message.md +31 -0
  199. package/ai/reference/bf-validation-messages.md +33 -0
  200. package/ai/reference/bf-view-event.md +28 -0
  201. package/ai/reference/bf-view-lifecycle.md +41 -0
  202. package/ai/reference/bf-view-state.md +28 -0
  203. package/ai/reference/bf_default_labels.md +21 -0
  204. package/ai/reference/bf_default_values.md +21 -0
  205. package/ai/reference/bf_defaults.md +21 -0
  206. package/ai/reference/bf_desktop_toast_defaults.md +21 -0
  207. package/ai/reference/bf_dialog_data.md +17 -0
  208. package/ai/reference/bf_labels.md +21 -0
  209. package/ai/reference/bf_overlay_data.md +19 -0
  210. package/ai/reference/bf_overlay_host.md +21 -0
  211. package/ai/reference/bf_sheet_default_snap_points.md +17 -0
  212. package/ai/reference/bf_shell_config.md +21 -0
  213. package/ai/reference/bf_shell_defaults.md +21 -0
  214. package/ai/reference/bf_tab_bar.md +21 -0
  215. package/ai/reference/bf_tab_bar_controller.md +21 -0
  216. package/ai/reference/bf_tab_context.md +21 -0
  217. package/ai/reference/bf_tab_links.md +21 -0
  218. package/ai/reference/bf_theme_storage.md +19 -0
  219. package/ai/reference/create-transition.md +36 -0
  220. package/ai/reference/duration_fast.md +17 -0
  221. package/ai/reference/duration_md.md +17 -0
  222. package/ai/reference/duration_overlay.md +17 -0
  223. package/ai/reference/duration_push.md +17 -0
  224. package/ai/reference/fade-down.md +26 -0
  225. package/ai/reference/fade-in.md +25 -0
  226. package/ai/reference/fade-out.md +25 -0
  227. package/ai/reference/fade-up.md +26 -0
  228. package/ai/reference/inject-shell-mode.md +23 -0
  229. package/ai/reference/install-bf-jsdom-shims.md +31 -0
  230. package/ai/reference/ios_duration.md +17 -0
  231. package/ai/reference/ios_easing.md +17 -0
  232. package/ai/reference/is-text-entry.md +25 -0
  233. package/ai/reference/max_complete_ms.md +17 -0
  234. package/ai/reference/md-transition.md +31 -0
  235. package/ai/reference/md_duration.md +17 -0
  236. package/ai/reference/md_easing.md +17 -0
  237. package/ai/reference/overlay_duration.md +21 -0
  238. package/ai/reference/overlay_easing.md +19 -0
  239. package/ai/reference/overlay_reduced_duration.md +17 -0
  240. package/ai/reference/pop-frames-at.md +25 -0
  241. package/ai/reference/prefers-reduced-motion.md +25 -0
  242. package/ai/reference/provide-bf-defaults.md +33 -0
  243. package/ai/reference/provide-bf-desktop-toast.md +28 -0
  244. package/ai/reference/provide-bf-labels.md +38 -0
  245. package/ai/reference/provide-bf-shell-testing.md +34 -0
  246. package/ai/reference/provide-bf-shell.md +41 -0
  247. package/ai/reference/provide-bf-testing.md +33 -0
  248. package/ai/reference/reduced-transition.md +28 -0
  249. package/ai/reference/reduced_duration.md +17 -0
  250. package/ai/reference/resolve-shell-mode.md +33 -0
  251. package/ai/reference/scale-in.md +25 -0
  252. package/ai/reference/settle-duration.md +25 -0
  253. package/ai/reference/settle-pop.md +33 -0
  254. package/ai/reference/settle_easing.md +17 -0
  255. package/ai/reference/should-complete-pop.md +26 -0
  256. package/ai/reference/slide-down.md +26 -0
  257. package/ai/reference/slide-up.md +26 -0
  258. package/ai/reference/with-bf-shell-routing.md +19 -0
  259. package/bin/bf-ui.js +81 -0
  260. package/fesm2022/bitforgehq-ui-icons.mjs +230 -0
  261. package/fesm2022/bitforgehq-ui-icons.mjs.map +1 -0
  262. package/fesm2022/bitforgehq-ui-mobile.mjs +5530 -0
  263. package/fesm2022/bitforgehq-ui-mobile.mjs.map +1 -0
  264. package/fesm2022/bitforgehq-ui-number-input.mjs +680 -0
  265. package/fesm2022/bitforgehq-ui-number-input.mjs.map +1 -0
  266. package/fesm2022/bitforgehq-ui-overlay.mjs +2675 -0
  267. package/fesm2022/bitforgehq-ui-overlay.mjs.map +1 -0
  268. package/fesm2022/bitforgehq-ui-testing.mjs +402 -0
  269. package/fesm2022/bitforgehq-ui-testing.mjs.map +1 -0
  270. package/fesm2022/bitforgehq-ui.mjs +7765 -0
  271. package/fesm2022/bitforgehq-ui.mjs.map +1 -0
  272. package/llms-full.txt +25394 -0
  273. package/llms.txt +329 -0
  274. package/package.json +94 -0
  275. package/theme.css +253 -0
  276. package/types/bitforgehq-ui-icons.d.ts +50 -0
  277. package/types/bitforgehq-ui-mobile.d.ts +2914 -0
  278. package/types/bitforgehq-ui-number-input.d.ts +282 -0
  279. package/types/bitforgehq-ui-overlay.d.ts +1514 -0
  280. package/types/bitforgehq-ui-testing.d.ts +495 -0
  281. package/types/bitforgehq-ui.d.ts +3499 -0
@@ -0,0 +1,387 @@
1
+ # bf-toggle
2
+
3
+ On/off switch for settings that apply immediately, with Signal Forms binding
4
+
5
+ `BfToggleComponent` from `@bitforgehq/ui` · Forms · since 0.1.0
6
+
7
+ ## Example
8
+
9
+ ```ts
10
+ import { Component, computed, signal } from '@angular/core';
11
+ import { BfToggleComponent } from '@bitforgehq/ui';
12
+
13
+ /**
14
+ * The bf-toggle overview.
15
+ *
16
+ * Live demo of `bf-toggle`: a default switch and a label-first switch in a constrained row; then the sm, md and lg sizes in a row.
17
+ */
18
+ @Component({
19
+ selector: 'app-example-toggle-overview',
20
+ imports: [BfToggleComponent],
21
+ template: `
22
+ <div class="flex flex-col gap-3">
23
+ <bf-toggle label="Notifications" [(checked)]="notifications" />
24
+ <div class="w-64">
25
+ <bf-toggle label="Weekly summary" labelPosition="start" [(checked)]="weeklySummary" />
26
+ </div>
27
+ <bf-toggle label="Disabled" [disabled]="true" />
28
+ <p data-status aria-live="polite" class="text-caption text-text-muted">{{ status() }}</p>
29
+ <div data-sizes class="flex flex-wrap items-center gap-3">
30
+ <bf-toggle size="sm" label="sm · 32 px" [checked]="true" />
31
+ <bf-toggle label="md · 40 px" [checked]="true" />
32
+ <bf-toggle size="lg" label="lg · 48 px" [checked]="true" />
33
+ </div>
34
+ </div>
35
+ `,
36
+ })
37
+ export class ToggleOverviewExampleComponent {
38
+ readonly notifications = signal(true);
39
+ readonly weeklySummary = signal(false);
40
+
41
+ readonly status = computed(
42
+ () =>
43
+ `Notifications ${this.notifications() ? 'on' : 'off'} · Weekly summary ${this.weeklySummary() ? 'on' : 'off'}`,
44
+ );
45
+ }
46
+ ```
47
+
48
+ ## Overview
49
+
50
+ On/off switch for settings that apply immediately. Implements the Signal Forms checkbox contract.
51
+
52
+ A switch for settings that take effect immediately: notifications, sounds, dark mode. The native checkbox underneath carries `role="switch"` so assistive tech announces it correctly.
53
+
54
+ ## When to use
55
+
56
+ Use `bf-toggle` for a setting that applies the moment it changes: notifications, sounds, dark mode. Use [bf-checkbox](https://bitforge-ui.web.app/components/checkbox) instead inside a form that is saved or submitted later, and [bf-segmented](https://bitforge-ui.web.app/components/segmented) for a choice between two named options that are not on and off.
57
+
58
+ ## Basic usage
59
+
60
+ ```ts
61
+ import { Component, signal } from '@angular/core';
62
+ import { BfToggleComponent } from '@bitforgehq/ui';
63
+
64
+ /** A labelled toggle that reports each change. */
65
+ @Component({
66
+ selector: 'app-example-toggle-basic',
67
+ imports: [BfToggleComponent],
68
+ template: `
69
+ <div class="flex flex-col gap-2">
70
+ <bf-toggle label="Notifications" [(checked)]="notifications" (changed)="save($event)" />
71
+ <p aria-live="polite" class="text-caption text-text-muted">{{ status() }}</p>
72
+ </div>
73
+ `,
74
+ })
75
+ export class ToggleBasicExampleComponent {
76
+ protected readonly notifications = signal(true);
77
+ protected readonly status = signal('');
78
+
79
+ protected save(on: boolean): void {
80
+ this.status.set(on ? 'Notifications on.' : 'Notifications off.');
81
+ }
82
+ }
83
+ ```
84
+
85
+ ## In a settings list
86
+
87
+ Put the label first so a column of toggles lines up on the right, as in the Meadow Sage profile screen.
88
+
89
+ ```ts
90
+ import { Component, signal } from '@angular/core';
91
+ import { BfToggleComponent } from '@bitforgehq/ui';
92
+
93
+ /** A full-width settings toggle with its label at the start. */
94
+ @Component({
95
+ selector: 'app-example-toggle-settings',
96
+ imports: [BfToggleComponent],
97
+ template: `
98
+ <bf-toggle label="Weekly summary" labelPosition="start" class="w-full" [(checked)]="weekly" />
99
+ `,
100
+ })
101
+ export class ToggleSettingsExampleComponent {
102
+ protected readonly weekly = signal(true);
103
+ }
104
+ ```
105
+
106
+ When the row itself already shows the title, such as a `bf-list-item`'s `title`/`subtitle`, don't repeat it as the toggle's own `label`; give it `ariaLabel` instead so the switch still has an accessible name, or `ariaLabelledby` with the id of the element that shows the title.
107
+
108
+ ```ts
109
+ import { Component, signal } from '@angular/core';
110
+ import { BfListComponent, BfListItemComponent, BfToggleComponent } from '@bitforgehq/ui';
111
+
112
+ /**
113
+ * A toggle in a settings row.
114
+ *
115
+ * The row shows the title and subtitle; the toggle in the trailing slot takes an `ariaLabel`.
116
+ */
117
+ @Component({
118
+ selector: 'app-example-toggle-list-row',
119
+ imports: [BfListComponent, BfListItemComponent, BfToggleComponent],
120
+ template: `
121
+ <bf-list>
122
+ <bf-list-item title="Weekly summary" subtitle="Every Monday at 8:00">
123
+ <bf-toggle bfSlot="trailing" ariaLabel="Weekly summary" [(checked)]="weekly" />
124
+ </bf-list-item>
125
+ </bf-list>
126
+ `,
127
+ })
128
+ export class ToggleListRowExampleComponent {
129
+ protected readonly weekly = signal(false);
130
+ }
131
+ ```
132
+
133
+ ## Sizes
134
+
135
+ `sm` (32 px row, 24×40 track), `md` (default, 40 px row, 28×48 track), `lg` (48 px row, 32×56 track). Unset, `size` follows `provideBfDefaults()`'s `controlSize`, `md` by default (`provideBfDefaults({ size: 'lg' })` enlarges every control of a Capacitor app; `{ size: 'sm' }` in a component's `providers` makes a dense sub-tree). Under a fine pointer the row is the hit area (32 px and up, above the 24 px of WCAG 2.5.8); under a coarse pointer (touch) `sm` and `md` rows grow to 44 px. The knob travels to the inline end, so it moves left under `dir="rtl"`.
136
+
137
+ ```ts
138
+ import { Component, signal } from '@angular/core';
139
+ import { BfToggleComponent } from '@bitforgehq/ui';
140
+
141
+ /** The sm, md and lg toggle sizes. */
142
+ @Component({
143
+ selector: 'app-example-toggle-sizes',
144
+ imports: [BfToggleComponent],
145
+ template: `
146
+ <div class="flex flex-col gap-2">
147
+ <bf-toggle size="sm" label="Compact rows" [(checked)]="compact" />
148
+ <bf-toggle label="Notifications" [(checked)]="notifications" />
149
+ <bf-toggle size="lg" label="Sounds" [(checked)]="sounds" />
150
+ </div>
151
+ `,
152
+ })
153
+ export class ToggleSizesExampleComponent {
154
+ protected readonly compact = signal(false);
155
+ protected readonly notifications = signal(true);
156
+ protected readonly sounds = signal(false);
157
+ }
158
+ ```
159
+
160
+ ## With Signal Forms
161
+
162
+ ```ts
163
+ import { Component, signal } from '@angular/core';
164
+ import { FormField, form } from '@angular/forms/signals';
165
+ import { BfToggleComponent } from '@bitforgehq/ui';
166
+
167
+ /** A toggle bound to a Signal Forms field. */
168
+ @Component({
169
+ selector: 'app-example-toggle-signal-forms',
170
+ imports: [FormField, BfToggleComponent],
171
+ template: `
172
+ <div class="flex flex-col gap-2">
173
+ <bf-toggle label="Public profile" [formField]="profile.public" />
174
+ <p class="text-caption text-text-muted">public: {{ profile.public().value() }}</p>
175
+ </div>
176
+ `,
177
+ })
178
+ export class ToggleSignalFormsExampleComponent {
179
+ private readonly model = signal({ public: false });
180
+ protected readonly profile = form(this.model);
181
+ }
182
+ ```
183
+
184
+ ## Read-only
185
+
186
+ `readonly` shows the setting but blocks changes: clicks and Space do nothing and the switch stays
187
+ in the tab order. The track rests on the muted surface like the other read-only controls; when on,
188
+ it is outlined in `primary` and the knob turns `primary-strong`. Signal Forms binds it from `readonly()`
189
+ rules.
190
+
191
+ ```ts
192
+ import { Component } from '@angular/core';
193
+ import { BfToggleComponent } from '@bitforgehq/ui';
194
+
195
+ /** A read-only toggle an admin manages. */
196
+ @Component({
197
+ selector: 'app-example-toggle-readonly',
198
+ imports: [BfToggleComponent],
199
+ template: `<bf-toggle label="Managed by your admin" [readonly]="true" [checked]="managed" />`,
200
+ })
201
+ export class ToggleReadonlyExampleComponent {
202
+ protected readonly managed = true;
203
+ }
204
+ ```
205
+
206
+ ## Validation
207
+
208
+ Once the control is touched it shows the first error as text: the error's own `message`, else the default for its kind from `provideBfLabels()`'s `validation` labels (`required` "Fill in this field", `email`, `pattern`, `parse`, `min(n)`, `max(n)`, `minLength(n)` "Use at least n characters", `maxLength(n)`, `minDate(d)`, `maxDate(d)`, and `fallback` "Check this value" for any other kind), so it never turns red without text. Reactive Forms `Validators.*` errors carry no message and get the same defaults (`minlength`/`maxlength` read their limit from the error's `context`). An explicit `errorMessage` wins over both and shows at once, e.g. for a server error.
209
+
210
+ ```ts
211
+ import { Component, signal } from '@angular/core';
212
+ import { FormField, FormRoot, form, required } from '@angular/forms/signals';
213
+ import { BfButtonComponent, BfToggleComponent } from '@bitforgehq/ui';
214
+
215
+ /**
216
+ * A required toggle with the default message.
217
+ *
218
+ * `required(p.consent)` has no message, so a submit shows "Fill in this field".
219
+ */
220
+ @Component({
221
+ selector: 'app-example-toggle-validation',
222
+ imports: [FormField, FormRoot, BfButtonComponent, BfToggleComponent],
223
+ template: `
224
+ <form [formRoot]="settings" class="flex flex-col items-start gap-3">
225
+ <bf-toggle label="Share usage data" [formField]="settings.consent" />
226
+ <bf-button type="submit">Save</bf-button>
227
+ </form>
228
+ `,
229
+ })
230
+ export class ToggleValidationExampleComponent {
231
+ private readonly model = signal({ consent: false });
232
+ protected readonly settings = form(
233
+ this.model,
234
+ (p) => {
235
+ required(p.consent);
236
+ },
237
+ { submission: { action: () => Promise.resolve(undefined) } },
238
+ );
239
+ }
240
+ ```
241
+
242
+ ## Desktop
243
+
244
+ Hovering the row darkens the track (`primary-hover` when on, `text-muted` when off) with the pointer cursor; a read-only switch has no hover. Hover styles apply only on devices that can hover, so a tap never leaves one stuck. The ring shows around the track on keyboard focus only. Under a fine pointer the row is the hit area, at least 24 × 24 px; `sm` (32 px rows) suits dense desktop forms and tables; set it with `provideBfDefaults({ size: 'sm' })` ([density guide](https://bitforge-ui.web.app/density)).
245
+
246
+ ## Theming
247
+
248
+ - Track: `primary` when checked, `control-off` when unchecked; hovering the row (pointer cursor)
249
+ darkens it to `primary-hover` / `text-muted`.
250
+ - Pressed (the row held down): the track takes a `text` border; not while disabled or read-only.
251
+ - Knob: `on-primary` when on (≥ 3:1 on the `primary` track for any configured primary), `surface`
252
+ when off, with the `segment` shadow.
253
+ - Shape (track and knob): `rounded-control` (`--radius-control`, `9999px` by default).
254
+ - Focus (the native input is visually hidden; the ring renders on the track through `peer-focus-visible`): `ring`.
255
+ - Disabled: track `primary-soft` when checked, `surface-sunken` when unchecked; label `text-disabled` (never opacity).
256
+ - Read-only: track `surface-muted`, bordered `primary` with a `primary-strong` knob when checked (≥ 3:1 on `surface-muted` for any primary) and `control-off` with the `surface` knob when unchecked (≥ 3:1 on `bg` and `surface`); no hover, default cursor.
257
+ - Error text: `danger`.
258
+ - Label: a long label (or a large text size) wraps beside the track, a long word breaking anywhere, instead of overflowing the row.
259
+
260
+ The track sits 10 px from the label (as on `bf-checkbox` and `bf-radio-group`) and the error text 6 px under the row.
261
+
262
+ ## Accessibility
263
+
264
+ Native `<input type="checkbox" role="switch">`, visually hidden (`sr-only`) and wrapped in a `<label>` so the whole row is tappable. Keyboard: native checkbox behaviour — Space toggles it while focused. `aria-checked` mirrors `checked`; `aria-label` carries `ariaLabel` and `aria-labelledby` carries `ariaLabelledby` whenever they are set (use them only when there is no visible `label`); `aria-invalid`, `aria-describedby` and `aria-errormessage` point at the error text once the field is touched and invalid (an explicit `errorMessage` shows immediately). Read-only: `aria-readonly="true"`, still focusable; the click (which Space also triggers) is cancelled, so the state never changes. `focus()` focuses the native switch; Signal Forms calls it from `focusBoundControl()`.
265
+
266
+ ### Keyboard
267
+
268
+ | Key | Action |
269
+ | ------------------------------------------------ | --------------------------------------------------------------------------- |
270
+ | <kbd>Tab</kbd> / <kbd>Shift</kbd>+<kbd>Tab</kbd> | Moves focus to and from the switch; a `readonly` one stays in the tab order |
271
+ | <kbd>Space</kbd> | Turns it on or off; nothing while `readonly` |
272
+
273
+ ## Inputs
274
+
275
+ | Name | Type | Default | Description |
276
+ | ---------------- | ----------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
277
+ | `label` | `string` | `''` | Label text; the default slot works too. |
278
+ | `ariaLabel` | `string` | `''` | Accessible name when no visible label is rendered (e.g. a switch in a list row). |
279
+ | `ariaLabelledby` | `string` | `''` | Id(s) of the element(s) that name the control when no visible label is rendered (e.g. a table column header). |
280
+ | `size` | `BfSize \| undefined` (`'sm' \| 'md' \| 'lg' \| undefined`) | `undefined` | Height step of the row: sm 32, md 40, lg 48 px (44 px under a coarse pointer for sm and md); unset follows `provideBfDefaults()` (`controlSize`, `md` by default). |
281
+ | `labelPosition` | `BfToggleLabelPosition` (`'end' \| 'start'`) | `'end'` | Put the label before the switch (as in settings lists). |
282
+ | `disabled` | `boolean` | `false` | Disables the control. Set by `[formField]`; do not bind it yourself. |
283
+ | `readonly` | `boolean` | `false` | Shows the state but blocks changes; the switch stays focusable and exposes `aria-readonly`. Set by `[formField]`; do not bind it yourself. |
284
+ | `required` | `boolean` | `false` | Marks the control required. Set by `[formField]`; do not bind it yourself. |
285
+ | `invalid` | `boolean` | `false` | Field validity from Signal Forms. Set by `[formField]`; do not bind it yourself. |
286
+ | `touched` | `boolean` | `false` | Whether the user has left the field. Set by `[formField]`; do not bind it yourself. |
287
+ | `errors` | `readonly ValidationError.WithOptionalFieldTree[]` | `[]` | Validation errors from Signal Forms. Set by `[formField]`; do not bind it yourself. |
288
+ | `errorMessage` | `string` | `''` | Explicit error text; takes precedence over Signal Forms errors. |
289
+ | `name` | `string` | `''` | Native name attribute. Set by `[formField]`; do not bind it yourself. |
290
+ | `id` | `string` | `generated` | Control id; generated when not set. |
291
+ | `checked` | `boolean` | `false` | Whether the switch is on; two-way bindable and bound by `[formField]`. Two-way: `[(checked)]`. |
292
+
293
+ ## Outputs
294
+
295
+ | Name | Payload | Description |
296
+ | --------- | --------- | ------------------------------------------------------------------------------------------------------- |
297
+ | `changed` | `boolean` | Emitted with the new state after a user change. |
298
+ | `touch` | `void` | Emitted on blur so Signal Forms marks the field touched. Set by `[formField]`; do not bind it yourself. |
299
+
300
+ ## Slots
301
+
302
+ - `default`: Rich label content after the `label` text.
303
+
304
+ ## Methods
305
+
306
+ ### `focus(options?: FocusOptions): void`
307
+
308
+ Focuses the native switch; Signal Forms calls it from `focusBoundControl()`.
309
+
310
+ | Parameter | Type | Description |
311
+ | ---------- | -------------- | --------------------------------------------------------------------- |
312
+ | `options?` | `FocusOptions` | Passed on to the native `focus()`, such as `{ preventScroll: true }`. |
313
+
314
+ ## Notes
315
+
316
+ ### Do
317
+
318
+ - Apply the change immediately and confirm it visually; a toggle should never need a Save button.
319
+ - Label the setting, not the state ("Notifications", not "On").
320
+ - Use `ariaLabel` or `ariaLabelledby` only when there is no visible `label`; otherwise the visible text is the name.
321
+
322
+ ### Don't
323
+
324
+ - Don't use a toggle inside a form that is submitted later; use `bf-checkbox`.
325
+
326
+ ## Migration notes
327
+
328
+ ### 0.3.0
329
+
330
+ New `ariaLabelledby` input: the id of the element that names the switch when no visible `label`
331
+ is shown, set as the native switch's `aria-labelledby`. Additive.
332
+
333
+ New exported `BfToggleLabelPosition` (`'end' | 'start'`), the type of `labelPosition` (was an
334
+ inline union with the same values).
335
+
336
+ **Behaviour:** new `size` (`BfSize`; unset follows `provideBfDefaults()`'s `controlSize`): rows
337
+ are `sm` 32, `md` 40 (default), `lg` 48 px under a fine pointer, and at least 44 px under a coarse
338
+ pointer (was 44 px everywhere); the track is 24×40 / 28×48 / 32×56 px with a matching knob, and the knob
339
+ travels to the inline end (mirrored under `dir="rtl"`).
340
+
341
+ **Behaviour:** an error without a message shows its kind's default text (was a red border only):
342
+ once touched, the field shows the first error's own `message`, else `provideBfLabels()`'s
343
+ `validation` text for its kind (Signal Forms and Reactive interop kinds), else
344
+ `validation.fallback`. `errorMessage` still wins. See Migration 1.
345
+
346
+ **Behaviour:** the track and the knob use `rounded-control` (`--radius-control`, `9999px` by
347
+ default, so they render as before).
348
+
349
+ **Behaviour:** the knob carries the state for any configured primary: `on-primary` on the on track
350
+ (was `surface`), `primary-strong` when read-only and on (was `primary`); off and disabled knobs
351
+ stay `surface`.
352
+
353
+ JSDoc of `toggle.component.ts` for the API reference: `@slot` docs for `default`; `@param` docs;
354
+ template handlers and framework hooks marked `@internal`, so the reference leaves them out. No
355
+ behaviour change.
356
+
357
+ **Behaviour:** a pressed state (F-045): the track takes a `text` border while the row is held down. None while disabled or read-only; under forced colours the system colours win.
358
+
359
+ **Behaviour:** sets `aria-errormessage` to its error paragraph (`<id>-error`) while
360
+ `aria-invalid="true"`, and an error that appears while a pointer button is held down (a press
361
+ elsewhere that blurred it) shows once the press ends, so the layout never moves under the pointer
362
+ (F-020).
363
+
364
+ **Behaviour:** the label wraps (`min-w-0 wrap-anywhere`) instead of overflowing its row at large
365
+ text sizes (F-051): a `labelPosition="start"` label in a `bf-list-item` spilled past the row's
366
+ start edge at the iOS AX sizes.
367
+
368
+ ### 0.2.0
369
+
370
+ The track sits 10 px from the label (`gap-2.5`, was 12 px), like checkbox and radio. Label and
371
+ error text are wrapped in a `flex flex-col items-start gap-1.5` column, so the error sits 6 px
372
+ under the 44 px row (it followed with no gap). Disabled uses tokens instead of `opacity-60`: the
373
+ track is `primary-soft` when checked and `surface-sunken` when unchecked, the label `text-disabled`.
374
+
375
+ Fixed: hovering an enabled row darkens the track (`primary-hover` on, `text-muted` off).
376
+
377
+ Added: `readonly` input. Behaviour change: the control ignored Signal Forms `readonly()` rules and
378
+ could be edited; it now declares `readonly` and blocks changes. While read-only the click (which
379
+ Space also triggers) is cancelled and `aria-readonly="true"` is set; the switch stays focusable, the
380
+ track rests on `surface-muted` without hover, bordered `primary` with a `primary` knob when on and
381
+ `control-off` (keeping the ≥ 3:1 boundary) when off. `focus(options?)` focuses the native control, so Signal
382
+ Forms' `focusBoundControl()` and "focus the first invalid field" on submit now work (they were
383
+ no-ops).
384
+
385
+ ### 0.1.0
386
+
387
+ Added `errorMessage` and Signal Forms error rendering (matching `bf-checkbox`): a `<p>` under the label, `aria-invalid` and `aria-describedby` on the input. `labelPosition="start"` now stretches the label to `w-full` with `justify-between` for settings-list layouts. The track and knob keep a transparent 1.5px border and the focus ring clears in forced-colors mode. The host no longer reflects a static `id` attribute onto `<bf-toggle>`. Fixed the knob sitting off-centre: the track's padding was `p-[3px]` alongside its `border-[1.5px]`, so the 22px knob had unequal 4.5px/1.5px margins at the two ends of its 20px `translate-x-5` travel; padding is now `p-[1.5px]` for equal 3px margins on both sides. Also removed the redundant `box-border` from the knob (preflight already sets `box-sizing: border-box` globally). The label's clickable hit area is now `min-h-11 items-center` instead of a `::after` pseudo-element, in both `labelPosition` branches, for the same reason as `bf-checkbox`.
@@ -0,0 +1,21 @@
1
+ # BfActionDirective
2
+
3
+ Makes one link or button the click target of a whole card or list row
4
+
5
+ Directive from `@bitforgehq/ui` · since 0.3.0
6
+
7
+ The one interactive element of a `bf-card` or `bf-list-item` (the stretched-link pattern): put
8
+ it on the `<a>` (navigation) or `<button>` (an action) that holds the card's heading text or the
9
+ row's title. Its `::after` stretches the hit area over the nearest positioned ancestor (the card
10
+ box, the row), so the whole surface is clickable while only the heading's link or button is
11
+ exposed: the heading stays a heading and the accessible name is the title alone. It registers
12
+ with the nearest card or row, which then draws the pointer, the hover and, while the action has
13
+ keyboard focus, the focus ring; a card is never lit by the actions of rows nested in it. Give
14
+ secondary controls inside the surface `class="relative z-1"` so they stay clickable above the
15
+ stretched area.
16
+
17
+ ```ts
18
+ import { BfActionDirective } from '@bitforgehq/ui';
19
+ ```
20
+
21
+ Selector: `a[bfAction], button[bfAction]`
@@ -0,0 +1,27 @@
1
+ # BfActionSheetActionRole
2
+
3
+ The role of an action sheet row, a destructive action or the cancel button
4
+
5
+ Type from `@bitforgehq/ui/mobile` · since 0.3.0
6
+
7
+ The role of an action sheet row: `destructive` renders it in `text-danger`, `cancel` makes it the
8
+ separate cancel button.
9
+
10
+ ```ts
11
+ import { type BfActionSheetActionRole } from '@bitforgehq/ui/mobile';
12
+ ```
13
+
14
+ ## Signature
15
+
16
+ ```ts
17
+ type BfActionSheetActionRole = 'destructive' | 'cancel'
18
+ ```
19
+
20
+ ## Values
21
+
22
+ - `destructive`
23
+ - `cancel`
24
+
25
+ ## Used by
26
+
27
+ - [BfActionSheetAction](bf-action-sheet-action.md)
@@ -0,0 +1,28 @@
1
+ # BfActionSheetAction
2
+
3
+ One row of an action sheet, or its cancel button, with its answer and role
4
+
5
+ Interface from `@bitforgehq/ui/mobile` · since 0.2.0
6
+
7
+ One row of an action sheet, or its cancel action when `role: 'cancel'`.
8
+
9
+ ```ts
10
+ import { type BfActionSheetAction } from '@bitforgehq/ui/mobile';
11
+ ```
12
+
13
+ ## Properties
14
+
15
+ | Name | Type | Default | Description |
16
+ | ------- | ------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17
+ | `id` | `string` | | What `open()` resolves with when the row is tapped (default `label`); keeps the answer stable when the label is translated or two rows share a label. Ignored on the cancel action, which always resolves `undefined`. |
18
+ | `label` | `string` | required | Row text; also what `open()` resolves with when the row is tapped and has no `id`. |
19
+ | `icon` | `IconNode` | | Icon rendered in the row's leading slot. |
20
+ | `role` | `BfActionSheetActionRole` (`'destructive' \| 'cancel'`) | | `destructive` renders the row's label in `text-danger`; `cancel` renders it as the separate cancel button instead of a row (a plain row when omitted). |
21
+
22
+ ## Uses
23
+
24
+ - [BfActionSheetActionRole](bf-action-sheet-action-role.md)
25
+
26
+ ## Used by
27
+
28
+ - [BfActionSheetOptions](bf-action-sheet-options.md)
@@ -0,0 +1,28 @@
1
+ # BfActionSheetOptions
2
+
3
+ Options of an action sheet: its title, its rows and when it closes
4
+
5
+ Interface from `@bitforgehq/ui/mobile` · since 0.2.0
6
+
7
+ Options of `BfActionSheetService.open()`.
8
+
9
+ ```ts
10
+ import { type BfActionSheetOptions } from '@bitforgehq/ui/mobile';
11
+ ```
12
+
13
+ ## Properties
14
+
15
+ | Name | Type | Default | Description |
16
+ | ------------------- | ----------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17
+ | `title` | `string` | | Heading above the rows; also the panel's accessible name (default `provideBfLabels()`'s `actions`, "Actions"). |
18
+ | `actions` | `BfActionSheetAction[]` | required | Rows, in order; a `cancel`-role entry becomes the separate cancel button instead of a row. Only the first `cancel`-role entry is used; any further ones are ignored. |
19
+ | `closeOnNavigation` | `boolean` | `true` | A navigation to another URL path closes the sheet, resolving `undefined` (default true). |
20
+ | `injector` | `Injector` | | Injector the action sheet resolves its labels (`BF_LABELS`) from and the parent of its content's injector (default the root injector). Pass the opening component's `inject(Injector)` so a feature-level `provideBfLabels()` and other feature providers reach it. |
21
+
22
+ ## Uses
23
+
24
+ - [BfActionSheetAction](bf-action-sheet-action.md)
25
+
26
+ ## Used by
27
+
28
+ - [BfActionSheetService](bf-action-sheet-service.md)
@@ -0,0 +1,33 @@
1
+ # BfActionSheetService
2
+
3
+ Opens bottom action sheets that resolve with the row the user tapped
4
+
5
+ Service from `@bitforgehq/ui/mobile` · since 0.2.0
6
+
7
+ Opens action sheets: a bottom-anchored list of actions on the overlay core (`position:
8
+ 'bottom'`, not counted as a modal). Renders `title` above a `bf-list` of the non-cancel
9
+ `actions` as interactive rows (destructive ones in `text-danger`, an icon in the leading slot
10
+ from `icon`), and a separate `tonal` `bf-button` for the cancel action — the caller's
11
+ first `cancel`-role entry if any (further ones are ignored), else a synthesized one labelled `provideBfLabels()`'s `cancel` ("Cancel").
12
+ Focus starts on the cancel button. `open()` resolves with the tapped row's `id ?? label`; the
13
+ cancel button, a backdrop tap, `Escape`, the hardware back button and a navigation to another
14
+ URL path all resolve `undefined`.
15
+
16
+ ```ts
17
+ import { BfActionSheetService } from '@bitforgehq/ui/mobile';
18
+ ```
19
+
20
+ ## Methods
21
+
22
+ ### `open(options: BfActionSheetOptions): Promise<string | undefined>`
23
+
24
+ Opens the action sheet described by `options`; resolves with the tapped row's `id ?? label`,
25
+ or `undefined` when cancelled.
26
+
27
+ | Parameter | Type | Description |
28
+ | --------- | ---------------------- | -------------------------------- |
29
+ | `options` | `BfActionSheetOptions` | The title and rows of the sheet. |
30
+
31
+ ## Uses
32
+
33
+ - [BfActionSheetOptions](bf-action-sheet-options.md)
@@ -0,0 +1,27 @@
1
+ # BfAlertDialogButtonRole
2
+
3
+ The role of an alert dialog button, the cancel answer or a destructive action
4
+
5
+ Type from `@bitforgehq/ui/mobile` · since 0.3.0
6
+
7
+ The role of an alert dialog button: `cancel` answers `Escape` and the hardware back button,
8
+ `destructive` renders `danger`.
9
+
10
+ ```ts
11
+ import { type BfAlertDialogButtonRole } from '@bitforgehq/ui/mobile';
12
+ ```
13
+
14
+ ## Signature
15
+
16
+ ```ts
17
+ type BfAlertDialogButtonRole = 'cancel' | 'destructive'
18
+ ```
19
+
20
+ ## Values
21
+
22
+ - `cancel`
23
+ - `destructive`
24
+
25
+ ## Used by
26
+
27
+ - [BfAlertDialogButton](bf-alert-dialog-button.md)
@@ -0,0 +1,27 @@
1
+ # BfAlertDialogButton
2
+
3
+ One button of an alert dialog: its answer, its label and its role
4
+
5
+ Interface from `@bitforgehq/ui/mobile` · since 0.2.0
6
+
7
+ A button of `BfAlertDialogService.open()`.
8
+
9
+ ```ts
10
+ import { type BfAlertDialogButton } from '@bitforgehq/ui/mobile';
11
+ ```
12
+
13
+ ## Properties
14
+
15
+ | Name | Type | Default | Description |
16
+ | ------- | ------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17
+ | `id` | `string` | | What `open()` resolves with when the button is tapped (default `label`); keeps the answer stable when the label is translated or two buttons share a label. |
18
+ | `label` | `string` | required | Button text; also the value `open()` resolves with when it is tapped and has no `id`. |
19
+ | `role` | `BfAlertDialogButtonRole` (`'cancel' \| 'destructive'`) | | `cancel` renders as a `text` button, takes the initial focus and is what `Escape`/the hardware back button answer with; `destructive` renders `danger` (a plain `primary`/`tonal` button when omitted). |
20
+
21
+ ## Uses
22
+
23
+ - [BfAlertDialogButtonRole](bf-alert-dialog-button-role.md)
24
+
25
+ ## Used by
26
+
27
+ - [BfAlertDialogOptions](bf-alert-dialog-options.md)
@@ -0,0 +1,29 @@
1
+ # BfAlertDialogOptions
2
+
3
+ Options of an alert dialog: its title, message, buttons and when it closes
4
+
5
+ Interface from `@bitforgehq/ui/mobile` · since 0.2.0
6
+
7
+ Options of `BfAlertDialogService.open()`.
8
+
9
+ ```ts
10
+ import { type BfAlertDialogOptions } from '@bitforgehq/ui/mobile';
11
+ ```
12
+
13
+ ## Properties
14
+
15
+ | Name | Type | Default | Description |
16
+ | ------------------- | ----------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17
+ | `title` | `string` | required | Dialog heading, rendered as the `h2` the panel's `aria-labelledby` points to. |
18
+ | `message` | `string` | | Body text under the title. |
19
+ | `buttons` | `BfAlertDialogButton[]` | | Buttons, left to right (default one button labelled `provideBfLabels()`'s `ok`, "OK"). |
20
+ | `closeOnNavigation` | `boolean` | `true` | A navigation to another URL path closes the alert, resolving the cancel button's answer, or `undefined` without one (default true). |
21
+ | `injector` | `Injector` | | Injector the dialog resolves its labels (`BF_LABELS`) from and the parent of its content's injector (default the root injector). Pass the opening component's `inject(Injector)` so a feature-level `provideBfLabels()` and other feature providers reach it. |
22
+
23
+ ## Uses
24
+
25
+ - [BfAlertDialogButton](bf-alert-dialog-button.md)
26
+
27
+ ## Used by
28
+
29
+ - [BfAlertDialogService](bf-alert-dialog-service.md)
@@ -0,0 +1,34 @@
1
+ # BfAlertDialogService
2
+
3
+ Opens small centred alerts that resolve with the button the user tapped
4
+
5
+ Service from `@bitforgehq/ui/mobile` · since 0.2.0
6
+
7
+ Opens alert dialogs: a centred, 300 px card on the overlay core (`position: 'center'`, no
8
+ backdrop dismiss). Renders `title` as an `h2`, an optional `message`, and `buttons` (default
9
+ one `ok` button from the app's `provideBfLabels()`, "OK") as a right-aligned row — `cancel`-role `text`, `destructive`-role
10
+ `danger`, the first plain button `primary`, further plain ones `tonal`. Focus starts on the
11
+ `cancel`-role button, else the first one. `open()` resolves with the tapped button's
12
+ `id ?? label`. `Escape` and the hardware back button resolve with the cancel button's answer
13
+ when `buttons` has one; with none, they are claimed and ignored — an alert
14
+ with no cancel button can only be answered by tapping a button, or closed by a navigation to
15
+ another URL path, which resolves the cancel button's answer, else `undefined`.
16
+
17
+ ```ts
18
+ import { BfAlertDialogService } from '@bitforgehq/ui/mobile';
19
+ ```
20
+
21
+ ## Methods
22
+
23
+ ### `open(options: BfAlertDialogOptions): Promise<string | undefined>`
24
+
25
+ Opens the alert described by `options`; resolves with the tapped button's `id ?? label`, or
26
+ `undefined` when a navigation closes an alert that has no cancel button.
27
+
28
+ | Parameter | Type | Description |
29
+ | --------- | ---------------------- | -------------------------------------------- |
30
+ | `options` | `BfAlertDialogOptions` | The title, message and buttons of the alert. |
31
+
32
+ ## Uses
33
+
34
+ - [BfAlertDialogOptions](bf-alert-dialog-options.md)