@oxyhq/bloom 0.4.0 → 0.5.1

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 (275) hide show
  1. package/README.md +105 -90
  2. package/lib/commonjs/bottom-sheet/index.js +2 -2
  3. package/lib/commonjs/context-menu/index.js +18 -19
  4. package/lib/commonjs/context-menu/index.js.map +1 -1
  5. package/lib/commonjs/dialog/BloomDialogProvider.js +61 -0
  6. package/lib/commonjs/dialog/BloomDialogProvider.js.map +1 -0
  7. package/lib/commonjs/dialog/BloomDialogProvider.web.js +45 -0
  8. package/lib/commonjs/dialog/BloomDialogProvider.web.js.map +1 -0
  9. package/lib/commonjs/dialog/Dialog.js +197 -100
  10. package/lib/commonjs/dialog/Dialog.js.map +1 -1
  11. package/lib/commonjs/dialog/Dialog.web.js +194 -84
  12. package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
  13. package/lib/commonjs/dialog/SheetShell.js +149 -0
  14. package/lib/commonjs/dialog/SheetShell.js.map +1 -0
  15. package/lib/commonjs/dialog/alert-store.js +116 -0
  16. package/lib/commonjs/dialog/alert-store.js.map +1 -0
  17. package/lib/commonjs/dialog/alert.js +38 -0
  18. package/lib/commonjs/dialog/alert.js.map +1 -0
  19. package/lib/commonjs/dialog/context.js +10 -2
  20. package/lib/commonjs/dialog/context.js.map +1 -1
  21. package/lib/commonjs/dialog/index.js +8 -24
  22. package/lib/commonjs/dialog/index.js.map +1 -1
  23. package/lib/commonjs/dialog/index.web.js +10 -20
  24. package/lib/commonjs/dialog/index.web.js.map +1 -1
  25. package/lib/commonjs/fonts/FontLoader.js +6 -5
  26. package/lib/commonjs/fonts/FontLoader.js.map +1 -1
  27. package/lib/commonjs/fonts/apply-font-faces.js +4 -4
  28. package/lib/commonjs/fonts/apply-font-faces.web.js +13 -12
  29. package/lib/commonjs/fonts/apply-font-faces.web.js.map +1 -1
  30. package/lib/commonjs/fonts/font-assets.js +2 -2
  31. package/lib/commonjs/fonts/font-data.web.js +22 -0
  32. package/lib/commonjs/fonts/font-data.web.js.map +1 -0
  33. package/lib/commonjs/index.js +101 -66
  34. package/lib/commonjs/index.js.map +1 -1
  35. package/lib/commonjs/index.web.js +101 -66
  36. package/lib/commonjs/index.web.js.map +1 -1
  37. package/lib/commonjs/menu/index.js +21 -23
  38. package/lib/commonjs/menu/index.js.map +1 -1
  39. package/lib/commonjs/select/index.js +26 -27
  40. package/lib/commonjs/select/index.js.map +1 -1
  41. package/lib/commonjs/toast/index.js +42 -13
  42. package/lib/commonjs/toast/index.js.map +1 -1
  43. package/lib/commonjs/toast/index.web.js +19 -15
  44. package/lib/commonjs/toast/index.web.js.map +1 -1
  45. package/lib/module/bottom-sheet/index.js +2 -2
  46. package/lib/module/context-menu/index.js +15 -16
  47. package/lib/module/context-menu/index.js.map +1 -1
  48. package/lib/module/dialog/BloomDialogProvider.js +57 -0
  49. package/lib/module/dialog/BloomDialogProvider.js.map +1 -0
  50. package/lib/module/dialog/BloomDialogProvider.web.js +41 -0
  51. package/lib/module/dialog/BloomDialogProvider.web.js.map +1 -0
  52. package/lib/module/dialog/Dialog.js +199 -87
  53. package/lib/module/dialog/Dialog.js.map +1 -1
  54. package/lib/module/dialog/Dialog.web.js +195 -70
  55. package/lib/module/dialog/Dialog.web.js.map +1 -1
  56. package/lib/module/dialog/SheetShell.js +143 -0
  57. package/lib/module/dialog/SheetShell.js.map +1 -0
  58. package/lib/module/dialog/alert-store.js +107 -0
  59. package/lib/module/dialog/alert-store.js.map +1 -0
  60. package/lib/module/dialog/alert.js +35 -0
  61. package/lib/module/dialog/alert.js.map +1 -0
  62. package/lib/module/dialog/context.js +10 -2
  63. package/lib/module/dialog/context.js.map +1 -1
  64. package/lib/module/dialog/index.js +3 -1
  65. package/lib/module/dialog/index.js.map +1 -1
  66. package/lib/module/dialog/index.web.js +9 -7
  67. package/lib/module/dialog/index.web.js.map +1 -1
  68. package/lib/module/fonts/FontLoader.js +6 -5
  69. package/lib/module/fonts/FontLoader.js.map +1 -1
  70. package/lib/module/fonts/apply-font-faces.js +4 -4
  71. package/lib/module/fonts/apply-font-faces.web.js +13 -10
  72. package/lib/module/fonts/apply-font-faces.web.js.map +1 -1
  73. package/lib/module/fonts/font-assets.js +2 -2
  74. package/lib/module/fonts/font-data.web.js +18 -0
  75. package/lib/module/fonts/font-data.web.js.map +1 -0
  76. package/lib/module/fonts/index.web.js +4 -4
  77. package/lib/module/index.js +2 -3
  78. package/lib/module/index.js.map +1 -1
  79. package/lib/module/index.web.js +2 -3
  80. package/lib/module/index.web.js.map +1 -1
  81. package/lib/module/menu/index.js +11 -13
  82. package/lib/module/menu/index.js.map +1 -1
  83. package/lib/module/select/index.js +27 -28
  84. package/lib/module/select/index.js.map +1 -1
  85. package/lib/module/toast/index.js +41 -11
  86. package/lib/module/toast/index.js.map +1 -1
  87. package/lib/module/toast/index.web.js +18 -13
  88. package/lib/module/toast/index.web.js.map +1 -1
  89. package/lib/typescript/commonjs/bottom-sheet/index.d.ts +1 -1
  90. package/lib/typescript/commonjs/context-menu/index.d.ts +4 -3
  91. package/lib/typescript/commonjs/context-menu/index.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/dialog/BloomDialogProvider.d.ts +27 -0
  93. package/lib/typescript/commonjs/dialog/BloomDialogProvider.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/dialog/BloomDialogProvider.web.d.ts +15 -0
  95. package/lib/typescript/commonjs/dialog/BloomDialogProvider.web.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/dialog/Dialog.d.ts +37 -10
  97. package/lib/typescript/commonjs/dialog/Dialog.d.ts.map +1 -1
  98. package/lib/typescript/commonjs/dialog/Dialog.web.d.ts +26 -10
  99. package/lib/typescript/commonjs/dialog/Dialog.web.d.ts.map +1 -1
  100. package/lib/typescript/commonjs/dialog/SheetShell.d.ts +31 -0
  101. package/lib/typescript/commonjs/dialog/SheetShell.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/dialog/alert-store.d.ts +70 -0
  103. package/lib/typescript/commonjs/dialog/alert-store.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/dialog/alert.d.ts +27 -0
  105. package/lib/typescript/commonjs/dialog/alert.d.ts.map +1 -0
  106. package/lib/typescript/commonjs/dialog/context.d.ts +7 -0
  107. package/lib/typescript/commonjs/dialog/context.d.ts.map +1 -1
  108. package/lib/typescript/commonjs/dialog/index.d.ts +5 -2
  109. package/lib/typescript/commonjs/dialog/index.d.ts.map +1 -1
  110. package/lib/typescript/commonjs/dialog/index.web.d.ts +5 -2
  111. package/lib/typescript/commonjs/dialog/index.web.d.ts.map +1 -1
  112. package/lib/typescript/commonjs/dialog/types.d.ts +70 -15
  113. package/lib/typescript/commonjs/dialog/types.d.ts.map +1 -1
  114. package/lib/typescript/commonjs/fonts/FontLoader.d.ts.map +1 -1
  115. package/lib/typescript/commonjs/fonts/apply-font-faces.web.d.ts +8 -1
  116. package/lib/typescript/commonjs/fonts/apply-font-faces.web.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/fonts/font-data.web.d.ts +5 -0
  118. package/lib/typescript/commonjs/fonts/font-data.web.d.ts.map +1 -0
  119. package/lib/typescript/commonjs/index.d.ts +3 -3
  120. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  121. package/lib/typescript/commonjs/index.web.d.ts +3 -3
  122. package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
  123. package/lib/typescript/commonjs/menu/index.d.ts +4 -4
  124. package/lib/typescript/commonjs/menu/index.d.ts.map +1 -1
  125. package/lib/typescript/commonjs/select/index.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/toast/index.d.ts +32 -3
  127. package/lib/typescript/commonjs/toast/index.d.ts.map +1 -1
  128. package/lib/typescript/commonjs/toast/index.web.d.ts +14 -7
  129. package/lib/typescript/commonjs/toast/index.web.d.ts.map +1 -1
  130. package/lib/typescript/module/bottom-sheet/index.d.ts +1 -1
  131. package/lib/typescript/module/context-menu/index.d.ts +4 -3
  132. package/lib/typescript/module/context-menu/index.d.ts.map +1 -1
  133. package/lib/typescript/module/dialog/BloomDialogProvider.d.ts +27 -0
  134. package/lib/typescript/module/dialog/BloomDialogProvider.d.ts.map +1 -0
  135. package/lib/typescript/module/dialog/BloomDialogProvider.web.d.ts +15 -0
  136. package/lib/typescript/module/dialog/BloomDialogProvider.web.d.ts.map +1 -0
  137. package/lib/typescript/module/dialog/Dialog.d.ts +37 -10
  138. package/lib/typescript/module/dialog/Dialog.d.ts.map +1 -1
  139. package/lib/typescript/module/dialog/Dialog.web.d.ts +26 -10
  140. package/lib/typescript/module/dialog/Dialog.web.d.ts.map +1 -1
  141. package/lib/typescript/module/dialog/SheetShell.d.ts +31 -0
  142. package/lib/typescript/module/dialog/SheetShell.d.ts.map +1 -0
  143. package/lib/typescript/module/dialog/alert-store.d.ts +70 -0
  144. package/lib/typescript/module/dialog/alert-store.d.ts.map +1 -0
  145. package/lib/typescript/module/dialog/alert.d.ts +27 -0
  146. package/lib/typescript/module/dialog/alert.d.ts.map +1 -0
  147. package/lib/typescript/module/dialog/context.d.ts +7 -0
  148. package/lib/typescript/module/dialog/context.d.ts.map +1 -1
  149. package/lib/typescript/module/dialog/index.d.ts +5 -2
  150. package/lib/typescript/module/dialog/index.d.ts.map +1 -1
  151. package/lib/typescript/module/dialog/index.web.d.ts +5 -2
  152. package/lib/typescript/module/dialog/index.web.d.ts.map +1 -1
  153. package/lib/typescript/module/dialog/types.d.ts +70 -15
  154. package/lib/typescript/module/dialog/types.d.ts.map +1 -1
  155. package/lib/typescript/module/fonts/FontLoader.d.ts.map +1 -1
  156. package/lib/typescript/module/fonts/apply-font-faces.web.d.ts +8 -1
  157. package/lib/typescript/module/fonts/apply-font-faces.web.d.ts.map +1 -1
  158. package/lib/typescript/module/fonts/font-data.web.d.ts +5 -0
  159. package/lib/typescript/module/fonts/font-data.web.d.ts.map +1 -0
  160. package/lib/typescript/module/index.d.ts +3 -3
  161. package/lib/typescript/module/index.d.ts.map +1 -1
  162. package/lib/typescript/module/index.web.d.ts +3 -3
  163. package/lib/typescript/module/index.web.d.ts.map +1 -1
  164. package/lib/typescript/module/menu/index.d.ts +4 -4
  165. package/lib/typescript/module/menu/index.d.ts.map +1 -1
  166. package/lib/typescript/module/select/index.d.ts.map +1 -1
  167. package/lib/typescript/module/toast/index.d.ts +32 -3
  168. package/lib/typescript/module/toast/index.d.ts.map +1 -1
  169. package/lib/typescript/module/toast/index.web.d.ts +14 -7
  170. package/lib/typescript/module/toast/index.web.d.ts.map +1 -1
  171. package/package.json +38 -18
  172. package/src/__tests__/Dialog.test.tsx +177 -0
  173. package/src/avatar/Avatar.stories.tsx +69 -0
  174. package/src/bottom-sheet/BottomSheet.stories.tsx +92 -0
  175. package/src/bottom-sheet/index.tsx +3 -3
  176. package/src/button/Button.stories.tsx +94 -0
  177. package/src/context-menu/ContextMenu.stories.tsx +71 -0
  178. package/src/context-menu/index.tsx +12 -12
  179. package/src/dialog/BloomDialogProvider.tsx +61 -0
  180. package/src/dialog/BloomDialogProvider.web.tsx +46 -0
  181. package/src/dialog/Dialog.stories.tsx +112 -0
  182. package/src/dialog/Dialog.tsx +217 -64
  183. package/src/dialog/Dialog.web.tsx +240 -75
  184. package/src/dialog/SheetShell.tsx +154 -0
  185. package/src/dialog/alert-store.ts +126 -0
  186. package/src/dialog/alert.ts +42 -0
  187. package/src/dialog/context.ts +14 -3
  188. package/src/dialog/index.ts +14 -2
  189. package/src/dialog/index.web.ts +20 -8
  190. package/src/dialog/types.ts +73 -16
  191. package/src/fonts/FontLoader.tsx +6 -5
  192. package/src/fonts/apply-font-faces.ts +4 -4
  193. package/src/fonts/apply-font-faces.web.ts +18 -10
  194. package/src/fonts/font-assets.ts +2 -2
  195. package/src/fonts/font-data.web.ts +15 -0
  196. package/src/fonts/index.web.ts +4 -4
  197. package/src/index.ts +17 -3
  198. package/src/index.web.ts +17 -3
  199. package/src/loading/Loading.stories.tsx +60 -0
  200. package/src/menu/Menu.stories.tsx +79 -0
  201. package/src/menu/index.tsx +13 -17
  202. package/src/prompt-input/PromptInput.stories.tsx +82 -0
  203. package/src/select/Select.stories.tsx +84 -0
  204. package/src/select/index.tsx +30 -30
  205. package/src/settings-list/SettingsList.stories.tsx +106 -0
  206. package/src/text-field/TextField.stories.tsx +90 -0
  207. package/src/toast/Toast.stories.tsx +109 -0
  208. package/src/toast/index.tsx +55 -11
  209. package/src/toast/index.web.tsx +33 -13
  210. package/lib/commonjs/fonts/assets/BlomusModernus-Bold.woff2 +0 -0
  211. package/lib/commonjs/fonts/assets/BlomusModernus-Regular.woff2 +0 -0
  212. package/lib/commonjs/fonts/assets/GeistMono-Variable.woff2 +0 -0
  213. package/lib/commonjs/fonts/assets/InterVariable.woff2 +0 -0
  214. package/lib/commonjs/prompt/Prompt.js +0 -267
  215. package/lib/commonjs/prompt/Prompt.js.map +0 -1
  216. package/lib/commonjs/prompt/index.js +0 -61
  217. package/lib/commonjs/prompt/index.js.map +0 -1
  218. package/lib/module/fonts/assets/BlomusModernus-Bold.woff2 +0 -0
  219. package/lib/module/fonts/assets/BlomusModernus-Regular.woff2 +0 -0
  220. package/lib/module/fonts/assets/GeistMono-Variable.woff2 +0 -0
  221. package/lib/module/fonts/assets/InterVariable.woff2 +0 -0
  222. package/lib/module/prompt/Prompt.js +0 -250
  223. package/lib/module/prompt/Prompt.js.map +0 -1
  224. package/lib/module/prompt/index.js +0 -4
  225. package/lib/module/prompt/index.js.map +0 -1
  226. package/lib/typescript/commonjs/__tests__/BloomThemeProvider.fonts-web.test.d.ts +0 -5
  227. package/lib/typescript/commonjs/__tests__/BloomThemeProvider.fonts-web.test.d.ts.map +0 -1
  228. package/lib/typescript/commonjs/__tests__/BloomThemeProvider.test.d.ts +0 -2
  229. package/lib/typescript/commonjs/__tests__/BloomThemeProvider.test.d.ts.map +0 -1
  230. package/lib/typescript/commonjs/__tests__/BottomSheet.test.d.ts +0 -2
  231. package/lib/typescript/commonjs/__tests__/BottomSheet.test.d.ts.map +0 -1
  232. package/lib/typescript/commonjs/__tests__/Button.test.d.ts +0 -2
  233. package/lib/typescript/commonjs/__tests__/Button.test.d.ts.map +0 -1
  234. package/lib/typescript/commonjs/__tests__/Code.test.d.ts +0 -2
  235. package/lib/typescript/commonjs/__tests__/Code.test.d.ts.map +0 -1
  236. package/lib/typescript/commonjs/__tests__/FontLoader.native.test.d.ts +0 -2
  237. package/lib/typescript/commonjs/__tests__/FontLoader.native.test.d.ts.map +0 -1
  238. package/lib/typescript/commonjs/__tests__/Pre.test.d.ts +0 -2
  239. package/lib/typescript/commonjs/__tests__/Pre.test.d.ts.map +0 -1
  240. package/lib/typescript/commonjs/__tests__/SettingsList.test.d.ts +0 -2
  241. package/lib/typescript/commonjs/__tests__/SettingsList.test.d.ts.map +0 -1
  242. package/lib/typescript/commonjs/__tests__/apply-font-faces.test.d.ts +0 -5
  243. package/lib/typescript/commonjs/__tests__/apply-font-faces.test.d.ts.map +0 -1
  244. package/lib/typescript/commonjs/__tests__/theme.test.d.ts +0 -2
  245. package/lib/typescript/commonjs/__tests__/theme.test.d.ts.map +0 -1
  246. package/lib/typescript/commonjs/prompt/Prompt.d.ts +0 -42
  247. package/lib/typescript/commonjs/prompt/Prompt.d.ts.map +0 -1
  248. package/lib/typescript/commonjs/prompt/index.d.ts +0 -3
  249. package/lib/typescript/commonjs/prompt/index.d.ts.map +0 -1
  250. package/lib/typescript/module/__tests__/BloomThemeProvider.fonts-web.test.d.ts +0 -5
  251. package/lib/typescript/module/__tests__/BloomThemeProvider.fonts-web.test.d.ts.map +0 -1
  252. package/lib/typescript/module/__tests__/BloomThemeProvider.test.d.ts +0 -2
  253. package/lib/typescript/module/__tests__/BloomThemeProvider.test.d.ts.map +0 -1
  254. package/lib/typescript/module/__tests__/BottomSheet.test.d.ts +0 -2
  255. package/lib/typescript/module/__tests__/BottomSheet.test.d.ts.map +0 -1
  256. package/lib/typescript/module/__tests__/Button.test.d.ts +0 -2
  257. package/lib/typescript/module/__tests__/Button.test.d.ts.map +0 -1
  258. package/lib/typescript/module/__tests__/Code.test.d.ts +0 -2
  259. package/lib/typescript/module/__tests__/Code.test.d.ts.map +0 -1
  260. package/lib/typescript/module/__tests__/FontLoader.native.test.d.ts +0 -2
  261. package/lib/typescript/module/__tests__/FontLoader.native.test.d.ts.map +0 -1
  262. package/lib/typescript/module/__tests__/Pre.test.d.ts +0 -2
  263. package/lib/typescript/module/__tests__/Pre.test.d.ts.map +0 -1
  264. package/lib/typescript/module/__tests__/SettingsList.test.d.ts +0 -2
  265. package/lib/typescript/module/__tests__/SettingsList.test.d.ts.map +0 -1
  266. package/lib/typescript/module/__tests__/apply-font-faces.test.d.ts +0 -5
  267. package/lib/typescript/module/__tests__/apply-font-faces.test.d.ts.map +0 -1
  268. package/lib/typescript/module/__tests__/theme.test.d.ts +0 -2
  269. package/lib/typescript/module/__tests__/theme.test.d.ts.map +0 -1
  270. package/lib/typescript/module/prompt/Prompt.d.ts +0 -42
  271. package/lib/typescript/module/prompt/Prompt.d.ts.map +0 -1
  272. package/lib/typescript/module/prompt/index.d.ts +0 -3
  273. package/lib/typescript/module/prompt/index.d.ts.map +0 -1
  274. package/src/prompt/Prompt.tsx +0 -247
  275. package/src/prompt/index.ts +0 -13
@@ -0,0 +1,42 @@
1
+ import {
2
+ enqueueAlert,
3
+ resolveButtons,
4
+ type AlertButton,
5
+ } from './alert-store';
6
+
7
+ /**
8
+ * Show a Bloom-styled confirmation dialog. Mirrors React Native's
9
+ * `Alert.alert(title, message?, buttons?)` signature so existing call
10
+ * sites migrate by changing the import only.
11
+ *
12
+ * If no buttons are passed, a single `OK` confirmation is rendered.
13
+ *
14
+ * The alert is enqueued in a module-scope store and rendered by
15
+ * `<BloomDialogProvider>`. Calls made before the provider mounts are
16
+ * queued and drained once the provider attaches — there is no fire-and-
17
+ * forget loss window. Calls made when no provider is ever mounted are
18
+ * silently queued forever; in development, mount the provider once at
19
+ * the app root and the queue will catch up immediately.
20
+ *
21
+ * ```tsx
22
+ * import { alert } from '@oxyhq/bloom';
23
+ *
24
+ * alert('Sign out?', 'You will need to enter your password to sign in again.', [
25
+ * { text: 'Cancel', style: 'cancel' },
26
+ * { text: 'Sign out', style: 'destructive', onPress: doSignOut },
27
+ * ]);
28
+ * ```
29
+ */
30
+ export function alert(
31
+ title: string,
32
+ message?: string,
33
+ buttons?: AlertButton[],
34
+ ): void {
35
+ enqueueAlert({
36
+ title,
37
+ message,
38
+ buttons: resolveButtons(buttons),
39
+ });
40
+ }
41
+
42
+ export type { AlertButton, AlertButtonStyle } from './alert-store';
@@ -1,5 +1,9 @@
1
1
  import { createContext, useContext, useId, useMemo, useRef } from 'react';
2
- import type { DialogContextProps, DialogControlRefProps, DialogControlProps } from './types';
2
+ import type {
3
+ DialogContextProps,
4
+ DialogControlProps,
5
+ DialogControlRefProps,
6
+ } from './types';
3
7
 
4
8
  export const Context = createContext<DialogContextProps>({
5
9
  close: () => {},
@@ -11,6 +15,13 @@ export function useDialogContext(): DialogContextProps {
11
15
  return useContext(Context);
12
16
  }
13
17
 
18
+ /**
19
+ * Return a stable handle that can imperatively `open()` and `close()` a
20
+ * `<Dialog>` mounted with the same control.
21
+ *
22
+ * The handle survives across re-renders; mounting a different `<Dialog>`
23
+ * with the same control attaches the new instance via the internal ref.
24
+ */
14
25
  export function useDialogControl(): DialogControlProps {
15
26
  const id = useId();
16
27
  const control = useRef<DialogControlRefProps | null>({
@@ -22,8 +33,8 @@ export function useDialogControl(): DialogControlProps {
22
33
  () => ({
23
34
  id,
24
35
  ref: control,
25
- open: (options) => {
26
- control.current?.open(options);
36
+ open: () => {
37
+ control.current?.open();
27
38
  },
28
39
  close: (cb) => {
29
40
  control.current?.close(cb);
@@ -1,3 +1,15 @@
1
- export { Outer, Inner, ScrollableInner, Handle, Close, Backdrop } from './Dialog';
1
+ export { Dialog } from './Dialog';
2
+ export { BloomDialogProvider } from './BloomDialogProvider';
3
+ export { alert } from './alert';
2
4
  export { useDialogContext, useDialogControl } from './context';
3
- export type { DialogControlProps, DialogOuterProps, DialogInnerProps, DialogContextProps } from './types';
5
+ export type {
6
+ AlertButton,
7
+ AlertButtonStyle,
8
+ } from './alert-store';
9
+ export type {
10
+ DialogAction,
11
+ DialogActionColor,
12
+ DialogContextProps,
13
+ DialogControlProps,
14
+ DialogProps,
15
+ } from './types';
@@ -1,13 +1,25 @@
1
1
  // Web variant of the `./dialog` barrel.
2
2
  //
3
- // The default barrel (`./index.ts`) re-exports from `./Dialog`, which on
4
- // native uses `react-native-safe-area-context` and Bloom's own `BottomSheet`
5
- // primitive. The web fork (`./Dialog.web`) is a pure-DOM modal overlay that
6
- // depends only on `react-remove-scroll-bar` and the in-package `Portal`.
3
+ // The default barrel (`./index.ts`) re-exports from `./Dialog`, which uses
4
+ // bloom's `BottomSheet` (a native-only primitive built on
5
+ // react-native-gesture-handler + reanimated). The web fork (`./Dialog.web`)
6
+ // is a pure-DOM modal overlay that renders into the bloom Portal.
7
7
  //
8
- // Web bundlers select this file via the `"browser"` condition in
8
+ // Web bundlers select this file via the `"browser"` export condition in
9
9
  // `package.json`'s `exports['./dialog']`; native bundlers fall through to
10
- // the React Native build.
11
- export { Outer, Inner, ScrollableInner, Handle, Close, Backdrop } from './Dialog.web';
10
+ // the React Native build above.
11
+ export { Dialog, BLOOM_DIALOG_CSS } from './Dialog.web';
12
+ export { BloomDialogProvider } from './BloomDialogProvider.web';
13
+ export { alert } from './alert';
12
14
  export { useDialogContext, useDialogControl } from './context';
13
- export type { DialogControlProps, DialogOuterProps, DialogInnerProps, DialogContextProps } from './types';
15
+ export type {
16
+ AlertButton,
17
+ AlertButtonStyle,
18
+ } from './alert-store';
19
+ export type {
20
+ DialogAction,
21
+ DialogActionColor,
22
+ DialogContextProps,
23
+ DialogControlProps,
24
+ DialogProps,
25
+ } from './types';
@@ -1,7 +1,15 @@
1
- import type { ScrollViewProps, StyleProp, ViewStyle } from 'react-native';
1
+ import type { GestureResponderEvent, StyleProp, ViewStyle } from 'react-native';
2
2
 
3
+ /**
4
+ * Imperative open/close handle returned by `useDialogControl`.
5
+ *
6
+ * Consumers receive an instance of `DialogControlProps`, which is a stable
7
+ * object whose `open`/`close` methods proxy to whichever `Dialog` instance
8
+ * has currently registered itself via the internal ref. Re-rendering the
9
+ * dialog under the same control does not break the handle.
10
+ */
3
11
  export type DialogControlRefProps = {
4
- open: (options?: Record<string, unknown>) => void;
12
+ open: () => void;
5
13
  close: (callback?: () => void) => void;
6
14
  };
7
15
 
@@ -15,25 +23,74 @@ export type DialogContextProps = {
15
23
  isWithinDialog: boolean;
16
24
  };
17
25
 
18
- export type DialogOuterProps = {
26
+ /**
27
+ * Color of a declarative `DialogAction`. Maps to bloom's theme palette:
28
+ *
29
+ * - `'default'` -> theme primary (filled CTA)
30
+ * - `'cancel'` -> theme secondary (auto-dismiss, no `onPress` required)
31
+ * - `'destructive'` -> theme negative
32
+ */
33
+ export type DialogActionColor = 'default' | 'cancel' | 'destructive';
34
+
35
+ export type DialogAction = {
36
+ label: string;
37
+ onPress?: (e: GestureResponderEvent) => void;
38
+ color?: DialogActionColor;
39
+ disabled?: boolean;
40
+ /**
41
+ * Defaults to `true`. When `true`, the dialog closes (and runs the close
42
+ * animation) before `onPress` is invoked, which gives the surrounding
43
+ * screen transition a chance to start before the action's side effects
44
+ * (navigation, network, etc.) kick in. Set `false` to keep the dialog
45
+ * mounted (e.g. while an async confirmation is in flight).
46
+ */
47
+ shouldCloseOnPress?: boolean;
48
+ testID?: string;
49
+ };
50
+
51
+ /**
52
+ * Props accepted by the unified `<Dialog>` component.
53
+ *
54
+ * Three usage modes — pick whichever fits the call site:
55
+ *
56
+ * 1. **Declarative (`title` / `description` / `actions`).** Most common
57
+ * confirm/cancel surface. Bloom renders the title, description and
58
+ * action row for you.
59
+ *
60
+ * 2. **Custom children.** Pass any JSX as `children` and bloom renders it
61
+ * verbatim inside the dialog frame. Combine with `title` to keep the
62
+ * header consistent.
63
+ *
64
+ * 3. **Imperative `alert()`.** Bypass the JSX layer entirely — see the
65
+ * module-level `alert()` helper.
66
+ */
67
+ export type DialogProps = React.PropsWithChildren<{
19
68
  control: DialogControlProps;
69
+ /** Fires after the dialog has finished closing. */
20
70
  onClose?: () => void;
21
71
  testID?: string;
22
- webOptions?: {
23
- alignCenter?: boolean;
24
- };
72
+ /** Optional dialog header text. Rendered above `description` / `children`. */
73
+ title?: string;
74
+ /** Optional supporting copy, rendered below the title. */
75
+ description?: string;
25
76
  /**
26
- * @deprecated No-op since 0.3.12. Bloom's BottomSheet sizes to its content by
27
- * default (capped by safe-area `maxHeight`), so dialogs no longer expand to
28
- * fill the screen and a manual lock is unnecessary.
77
+ * Optional action row. When provided, bloom renders the appropriate
78
+ * confirm/cancel/destructive buttons for you. Order is preserved.
79
+ */
80
+ actions?: DialogAction[];
81
+ /**
82
+ * Style overrides applied to the inner content container on native (the
83
+ * floating bottom-sheet card) and to the modal panel on web.
29
84
  */
30
- preventExpansion?: boolean;
31
- };
32
-
33
- export type DialogInnerProps = React.PropsWithChildren<{
34
85
  style?: StyleProp<ViewStyle>;
86
+ /** Accessibility label, applied to the dialog role on web. */
35
87
  label?: string;
36
- header?: React.ReactNode;
37
- contentContainerStyle?: StyleProp<ViewStyle>;
38
- keyboardDismissMode?: ScrollViewProps['keyboardDismissMode'];
39
88
  }>;
89
+
90
+ /**
91
+ * Web-only options. Native uses bloom's `BottomSheet` underneath which has
92
+ * its own positioning model.
93
+ */
94
+ export type DialogWebOptions = {
95
+ alignCenter?: boolean;
96
+ };
@@ -1,10 +1,11 @@
1
1
  import React, { useRef } from 'react';
2
2
  // Reach for the web variant explicitly. The default `./apply-font-faces`
3
- // is a no-op stub that exists so Metro never sees the module-level
4
- // `.woff2` imports on native (Metro's default `assetExts` does not include
5
- // `.woff2`). This file (`FontLoader.tsx`) is only picked up by web
6
- // bundlers — Metro selects `FontLoader.native.tsx` on iOS/Android — so it
7
- // is safe to take a direct dependency on the web implementation here.
3
+ // is a no-op stub on native native loads its fonts via
4
+ // `useFonts(FONT_ASSETS)` in `FontLoader.native.tsx` and has no use for
5
+ // CSS `@font-face` injection. This file (`FontLoader.tsx`) is only picked
6
+ // up by web bundlers — Metro selects `FontLoader.native.tsx` on iOS/Android
7
+ // — so it is safe to take a direct dependency on the web implementation
8
+ // here.
8
9
  import { applyFontFaces } from './apply-font-faces.web';
9
10
 
10
11
  export interface FontLoaderProps {
@@ -2,10 +2,10 @@
2
2
  // is selected by bundlers via the package.json conditions. RN consumers
3
3
  // never need font-face injection — useFonts handles loading on native.
4
4
  //
5
- // This file MUST have zero `.woff2` imports. Metro parses module-level
6
- // imports at bundle time and would otherwise fail to resolve the `.woff2`
7
- // assets (not in Metro's default `assetExts`). See
8
- // `apply-font-faces.web.ts` for the real implementation.
5
+ // The web variant does NOT pull in any `.woff2` files via asset imports —
6
+ // it imports base64 data URLs from `font-data.web.ts`. This stub stays
7
+ // here so the file split (`*.ts` vs `*.web.ts`) makes the platform
8
+ // intent explicit and so the runtime API surface matches across platforms.
9
9
  export function applyFontFaces(): void {
10
10
  // intentionally empty
11
11
  }
@@ -1,8 +1,9 @@
1
- /// <reference path="../assets.d.ts" />
2
- import blomusReg from './assets/BlomusModernus-Regular.woff2';
3
- import blomusBold from './assets/BlomusModernus-Bold.woff2';
4
- import interVar from './assets/InterVariable.woff2';
5
- import geistMono from './assets/GeistMono-Variable.woff2';
1
+ import {
2
+ blomusModernusRegular,
3
+ blomusModernusBold,
4
+ interVariable,
5
+ geistMonoVariable,
6
+ } from './font-data.web';
6
7
  import { fontFamilies } from './tokens';
7
8
 
8
9
  const STYLE_ID = 'bloom-fonts';
@@ -12,10 +13,17 @@ const STYLE_ID = 'bloom-fonts';
12
13
  *
13
14
  * Web-only. The native counterpart in `apply-font-faces.ts` is a no-op
14
15
  * stub — Metro cannot parse `.woff2` imports, so the file split keeps
15
- * those imports out of the native bundle entirely. Idempotent: safe to
16
+ * the font payload out of the native bundle entirely. Idempotent: safe to
16
17
  * call multiple times; subsequent calls early-return after the
17
18
  * `<style id="bloom-fonts">` tag has been mounted. SSR-safe via the
18
19
  * `typeof document === 'undefined'` guard.
20
+ *
21
+ * The font URLs come from `./font-data.web`, a generated module that
22
+ * embeds the woff2 bytes as base64 data URLs. Inlining (rather than
23
+ * relying on bundler asset loaders for `.woff2`) means consumers do not
24
+ * have to extend Metro's `assetExts` or add a webpack/Vite asset rule —
25
+ * the published JS is self-contained. See `scripts/generate-font-data.mjs`
26
+ * for the rationale and trade-offs.
19
27
  */
20
28
  export function applyFontFaces(): void {
21
29
  if (typeof document === 'undefined') return;
@@ -24,10 +32,10 @@ export function applyFontFaces(): void {
24
32
  const style = document.createElement('style');
25
33
  style.id = STYLE_ID;
26
34
  style.textContent = `
27
- @font-face { font-family: 'BlomusModernus'; src: url(${blomusReg}) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
28
- @font-face { font-family: 'BlomusModernus'; src: url(${blomusBold}) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
29
- @font-face { font-family: 'Inter'; src: url(${interVar}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
30
- @font-face { font-family: 'Geist Mono'; src: url(${geistMono}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
35
+ @font-face { font-family: 'BlomusModernus'; src: url(${blomusModernusRegular}) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
36
+ @font-face { font-family: 'BlomusModernus'; src: url(${blomusModernusBold}) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
37
+ @font-face { font-family: 'Inter'; src: url(${interVariable}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
38
+ @font-face { font-family: 'Geist Mono'; src: url(${geistMonoVariable}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
31
39
  :root {
32
40
  --bloom-font-display: ${fontFamilies.display};
33
41
  --bloom-font-sans: ${fontFamilies.sans};
@@ -5,8 +5,8 @@
5
5
  // covers all weights at runtime. `@fontsource(-variable)?/*` packages only
6
6
  // publish .woff2 for their variable axes — modern react-native font loading
7
7
  // requires .ttf, so we use the upstream variable TTFs instead. On web,
8
- // `apply-font-faces.web.ts` references the .woff2 variants directly and this
9
- // file is never imported.
8
+ // `apply-font-faces.web.ts` inlines the .woff2 variants as base64 data URLs
9
+ // (see `font-data.web.ts`) and this file is never imported.
10
10
 
11
11
  export const FONT_ASSETS = {
12
12
  BlomusModernus: require('./assets/BlomusModernus-Regular.ttf'),