@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.
- package/README.md +105 -90
- package/lib/commonjs/bottom-sheet/index.js +2 -2
- package/lib/commonjs/context-menu/index.js +18 -19
- package/lib/commonjs/context-menu/index.js.map +1 -1
- package/lib/commonjs/dialog/BloomDialogProvider.js +61 -0
- package/lib/commonjs/dialog/BloomDialogProvider.js.map +1 -0
- package/lib/commonjs/dialog/BloomDialogProvider.web.js +45 -0
- package/lib/commonjs/dialog/BloomDialogProvider.web.js.map +1 -0
- package/lib/commonjs/dialog/Dialog.js +197 -100
- package/lib/commonjs/dialog/Dialog.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.web.js +194 -84
- package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
- package/lib/commonjs/dialog/SheetShell.js +149 -0
- package/lib/commonjs/dialog/SheetShell.js.map +1 -0
- package/lib/commonjs/dialog/alert-store.js +116 -0
- package/lib/commonjs/dialog/alert-store.js.map +1 -0
- package/lib/commonjs/dialog/alert.js +38 -0
- package/lib/commonjs/dialog/alert.js.map +1 -0
- package/lib/commonjs/dialog/context.js +10 -2
- package/lib/commonjs/dialog/context.js.map +1 -1
- package/lib/commonjs/dialog/index.js +8 -24
- package/lib/commonjs/dialog/index.js.map +1 -1
- package/lib/commonjs/dialog/index.web.js +10 -20
- package/lib/commonjs/dialog/index.web.js.map +1 -1
- package/lib/commonjs/fonts/FontLoader.js +6 -5
- package/lib/commonjs/fonts/FontLoader.js.map +1 -1
- package/lib/commonjs/fonts/apply-font-faces.js +4 -4
- package/lib/commonjs/fonts/apply-font-faces.web.js +13 -12
- package/lib/commonjs/fonts/apply-font-faces.web.js.map +1 -1
- package/lib/commonjs/fonts/font-assets.js +2 -2
- package/lib/commonjs/fonts/font-data.web.js +22 -0
- package/lib/commonjs/fonts/font-data.web.js.map +1 -0
- package/lib/commonjs/index.js +101 -66
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +101 -66
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/menu/index.js +21 -23
- package/lib/commonjs/menu/index.js.map +1 -1
- package/lib/commonjs/select/index.js +26 -27
- package/lib/commonjs/select/index.js.map +1 -1
- package/lib/commonjs/toast/index.js +42 -13
- package/lib/commonjs/toast/index.js.map +1 -1
- package/lib/commonjs/toast/index.web.js +19 -15
- package/lib/commonjs/toast/index.web.js.map +1 -1
- package/lib/module/bottom-sheet/index.js +2 -2
- package/lib/module/context-menu/index.js +15 -16
- package/lib/module/context-menu/index.js.map +1 -1
- package/lib/module/dialog/BloomDialogProvider.js +57 -0
- package/lib/module/dialog/BloomDialogProvider.js.map +1 -0
- package/lib/module/dialog/BloomDialogProvider.web.js +41 -0
- package/lib/module/dialog/BloomDialogProvider.web.js.map +1 -0
- package/lib/module/dialog/Dialog.js +199 -87
- package/lib/module/dialog/Dialog.js.map +1 -1
- package/lib/module/dialog/Dialog.web.js +195 -70
- package/lib/module/dialog/Dialog.web.js.map +1 -1
- package/lib/module/dialog/SheetShell.js +143 -0
- package/lib/module/dialog/SheetShell.js.map +1 -0
- package/lib/module/dialog/alert-store.js +107 -0
- package/lib/module/dialog/alert-store.js.map +1 -0
- package/lib/module/dialog/alert.js +35 -0
- package/lib/module/dialog/alert.js.map +1 -0
- package/lib/module/dialog/context.js +10 -2
- package/lib/module/dialog/context.js.map +1 -1
- package/lib/module/dialog/index.js +3 -1
- package/lib/module/dialog/index.js.map +1 -1
- package/lib/module/dialog/index.web.js +9 -7
- package/lib/module/dialog/index.web.js.map +1 -1
- package/lib/module/fonts/FontLoader.js +6 -5
- package/lib/module/fonts/FontLoader.js.map +1 -1
- package/lib/module/fonts/apply-font-faces.js +4 -4
- package/lib/module/fonts/apply-font-faces.web.js +13 -10
- package/lib/module/fonts/apply-font-faces.web.js.map +1 -1
- package/lib/module/fonts/font-assets.js +2 -2
- package/lib/module/fonts/font-data.web.js +18 -0
- package/lib/module/fonts/font-data.web.js.map +1 -0
- package/lib/module/fonts/index.web.js +4 -4
- package/lib/module/index.js +2 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +2 -3
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/menu/index.js +11 -13
- package/lib/module/menu/index.js.map +1 -1
- package/lib/module/select/index.js +27 -28
- package/lib/module/select/index.js.map +1 -1
- package/lib/module/toast/index.js +41 -11
- package/lib/module/toast/index.js.map +1 -1
- package/lib/module/toast/index.web.js +18 -13
- package/lib/module/toast/index.web.js.map +1 -1
- package/lib/typescript/commonjs/bottom-sheet/index.d.ts +1 -1
- package/lib/typescript/commonjs/context-menu/index.d.ts +4 -3
- package/lib/typescript/commonjs/context-menu/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/BloomDialogProvider.d.ts +27 -0
- package/lib/typescript/commonjs/dialog/BloomDialogProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/dialog/BloomDialogProvider.web.d.ts +15 -0
- package/lib/typescript/commonjs/dialog/BloomDialogProvider.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/dialog/Dialog.d.ts +37 -10
- package/lib/typescript/commonjs/dialog/Dialog.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/Dialog.web.d.ts +26 -10
- package/lib/typescript/commonjs/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/SheetShell.d.ts +31 -0
- package/lib/typescript/commonjs/dialog/SheetShell.d.ts.map +1 -0
- package/lib/typescript/commonjs/dialog/alert-store.d.ts +70 -0
- package/lib/typescript/commonjs/dialog/alert-store.d.ts.map +1 -0
- package/lib/typescript/commonjs/dialog/alert.d.ts +27 -0
- package/lib/typescript/commonjs/dialog/alert.d.ts.map +1 -0
- package/lib/typescript/commonjs/dialog/context.d.ts +7 -0
- package/lib/typescript/commonjs/dialog/context.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/index.d.ts +5 -2
- package/lib/typescript/commonjs/dialog/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/index.web.d.ts +5 -2
- package/lib/typescript/commonjs/dialog/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/types.d.ts +70 -15
- package/lib/typescript/commonjs/dialog/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/fonts/FontLoader.d.ts.map +1 -1
- package/lib/typescript/commonjs/fonts/apply-font-faces.web.d.ts +8 -1
- package/lib/typescript/commonjs/fonts/apply-font-faces.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/fonts/font-data.web.d.ts +5 -0
- package/lib/typescript/commonjs/fonts/font-data.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +3 -3
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.web.d.ts +3 -3
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/menu/index.d.ts +4 -4
- package/lib/typescript/commonjs/menu/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/select/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/toast/index.d.ts +32 -3
- package/lib/typescript/commonjs/toast/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/toast/index.web.d.ts +14 -7
- package/lib/typescript/commonjs/toast/index.web.d.ts.map +1 -1
- package/lib/typescript/module/bottom-sheet/index.d.ts +1 -1
- package/lib/typescript/module/context-menu/index.d.ts +4 -3
- package/lib/typescript/module/context-menu/index.d.ts.map +1 -1
- package/lib/typescript/module/dialog/BloomDialogProvider.d.ts +27 -0
- package/lib/typescript/module/dialog/BloomDialogProvider.d.ts.map +1 -0
- package/lib/typescript/module/dialog/BloomDialogProvider.web.d.ts +15 -0
- package/lib/typescript/module/dialog/BloomDialogProvider.web.d.ts.map +1 -0
- package/lib/typescript/module/dialog/Dialog.d.ts +37 -10
- package/lib/typescript/module/dialog/Dialog.d.ts.map +1 -1
- package/lib/typescript/module/dialog/Dialog.web.d.ts +26 -10
- package/lib/typescript/module/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/module/dialog/SheetShell.d.ts +31 -0
- package/lib/typescript/module/dialog/SheetShell.d.ts.map +1 -0
- package/lib/typescript/module/dialog/alert-store.d.ts +70 -0
- package/lib/typescript/module/dialog/alert-store.d.ts.map +1 -0
- package/lib/typescript/module/dialog/alert.d.ts +27 -0
- package/lib/typescript/module/dialog/alert.d.ts.map +1 -0
- package/lib/typescript/module/dialog/context.d.ts +7 -0
- package/lib/typescript/module/dialog/context.d.ts.map +1 -1
- package/lib/typescript/module/dialog/index.d.ts +5 -2
- package/lib/typescript/module/dialog/index.d.ts.map +1 -1
- package/lib/typescript/module/dialog/index.web.d.ts +5 -2
- package/lib/typescript/module/dialog/index.web.d.ts.map +1 -1
- package/lib/typescript/module/dialog/types.d.ts +70 -15
- package/lib/typescript/module/dialog/types.d.ts.map +1 -1
- package/lib/typescript/module/fonts/FontLoader.d.ts.map +1 -1
- package/lib/typescript/module/fonts/apply-font-faces.web.d.ts +8 -1
- package/lib/typescript/module/fonts/apply-font-faces.web.d.ts.map +1 -1
- package/lib/typescript/module/fonts/font-data.web.d.ts +5 -0
- package/lib/typescript/module/fonts/font-data.web.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +3 -3
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/index.web.d.ts +3 -3
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/lib/typescript/module/menu/index.d.ts +4 -4
- package/lib/typescript/module/menu/index.d.ts.map +1 -1
- package/lib/typescript/module/select/index.d.ts.map +1 -1
- package/lib/typescript/module/toast/index.d.ts +32 -3
- package/lib/typescript/module/toast/index.d.ts.map +1 -1
- package/lib/typescript/module/toast/index.web.d.ts +14 -7
- package/lib/typescript/module/toast/index.web.d.ts.map +1 -1
- package/package.json +38 -18
- package/src/__tests__/Dialog.test.tsx +177 -0
- package/src/avatar/Avatar.stories.tsx +69 -0
- package/src/bottom-sheet/BottomSheet.stories.tsx +92 -0
- package/src/bottom-sheet/index.tsx +3 -3
- package/src/button/Button.stories.tsx +94 -0
- package/src/context-menu/ContextMenu.stories.tsx +71 -0
- package/src/context-menu/index.tsx +12 -12
- package/src/dialog/BloomDialogProvider.tsx +61 -0
- package/src/dialog/BloomDialogProvider.web.tsx +46 -0
- package/src/dialog/Dialog.stories.tsx +112 -0
- package/src/dialog/Dialog.tsx +217 -64
- package/src/dialog/Dialog.web.tsx +240 -75
- package/src/dialog/SheetShell.tsx +154 -0
- package/src/dialog/alert-store.ts +126 -0
- package/src/dialog/alert.ts +42 -0
- package/src/dialog/context.ts +14 -3
- package/src/dialog/index.ts +14 -2
- package/src/dialog/index.web.ts +20 -8
- package/src/dialog/types.ts +73 -16
- package/src/fonts/FontLoader.tsx +6 -5
- package/src/fonts/apply-font-faces.ts +4 -4
- package/src/fonts/apply-font-faces.web.ts +18 -10
- package/src/fonts/font-assets.ts +2 -2
- package/src/fonts/font-data.web.ts +15 -0
- package/src/fonts/index.web.ts +4 -4
- package/src/index.ts +17 -3
- package/src/index.web.ts +17 -3
- package/src/loading/Loading.stories.tsx +60 -0
- package/src/menu/Menu.stories.tsx +79 -0
- package/src/menu/index.tsx +13 -17
- package/src/prompt-input/PromptInput.stories.tsx +82 -0
- package/src/select/Select.stories.tsx +84 -0
- package/src/select/index.tsx +30 -30
- package/src/settings-list/SettingsList.stories.tsx +106 -0
- package/src/text-field/TextField.stories.tsx +90 -0
- package/src/toast/Toast.stories.tsx +109 -0
- package/src/toast/index.tsx +55 -11
- package/src/toast/index.web.tsx +33 -13
- package/lib/commonjs/fonts/assets/BlomusModernus-Bold.woff2 +0 -0
- package/lib/commonjs/fonts/assets/BlomusModernus-Regular.woff2 +0 -0
- package/lib/commonjs/fonts/assets/GeistMono-Variable.woff2 +0 -0
- package/lib/commonjs/fonts/assets/InterVariable.woff2 +0 -0
- package/lib/commonjs/prompt/Prompt.js +0 -267
- package/lib/commonjs/prompt/Prompt.js.map +0 -1
- package/lib/commonjs/prompt/index.js +0 -61
- package/lib/commonjs/prompt/index.js.map +0 -1
- package/lib/module/fonts/assets/BlomusModernus-Bold.woff2 +0 -0
- package/lib/module/fonts/assets/BlomusModernus-Regular.woff2 +0 -0
- package/lib/module/fonts/assets/GeistMono-Variable.woff2 +0 -0
- package/lib/module/fonts/assets/InterVariable.woff2 +0 -0
- package/lib/module/prompt/Prompt.js +0 -250
- package/lib/module/prompt/Prompt.js.map +0 -1
- package/lib/module/prompt/index.js +0 -4
- package/lib/module/prompt/index.js.map +0 -1
- package/lib/typescript/commonjs/__tests__/BloomThemeProvider.fonts-web.test.d.ts +0 -5
- package/lib/typescript/commonjs/__tests__/BloomThemeProvider.fonts-web.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/BloomThemeProvider.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/BloomThemeProvider.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/BottomSheet.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/BottomSheet.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/Button.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/Button.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/Code.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/Code.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/FontLoader.native.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/FontLoader.native.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/Pre.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/Pre.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/SettingsList.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/SettingsList.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/apply-font-faces.test.d.ts +0 -5
- package/lib/typescript/commonjs/__tests__/apply-font-faces.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/__tests__/theme.test.d.ts +0 -2
- package/lib/typescript/commonjs/__tests__/theme.test.d.ts.map +0 -1
- package/lib/typescript/commonjs/prompt/Prompt.d.ts +0 -42
- package/lib/typescript/commonjs/prompt/Prompt.d.ts.map +0 -1
- package/lib/typescript/commonjs/prompt/index.d.ts +0 -3
- package/lib/typescript/commonjs/prompt/index.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/BloomThemeProvider.fonts-web.test.d.ts +0 -5
- package/lib/typescript/module/__tests__/BloomThemeProvider.fonts-web.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/BloomThemeProvider.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/BloomThemeProvider.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/BottomSheet.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/BottomSheet.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/Button.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/Button.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/Code.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/Code.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/FontLoader.native.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/FontLoader.native.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/Pre.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/Pre.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/SettingsList.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/SettingsList.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/apply-font-faces.test.d.ts +0 -5
- package/lib/typescript/module/__tests__/apply-font-faces.test.d.ts.map +0 -1
- package/lib/typescript/module/__tests__/theme.test.d.ts +0 -2
- package/lib/typescript/module/__tests__/theme.test.d.ts.map +0 -1
- package/lib/typescript/module/prompt/Prompt.d.ts +0 -42
- package/lib/typescript/module/prompt/Prompt.d.ts.map +0 -1
- package/lib/typescript/module/prompt/index.d.ts +0 -3
- package/lib/typescript/module/prompt/index.d.ts.map +0 -1
- package/src/prompt/Prompt.tsx +0 -247
- 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';
|
package/src/dialog/context.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { createContext, useContext, useId, useMemo, useRef } from 'react';
|
|
2
|
-
import type {
|
|
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: (
|
|
26
|
-
control.current?.open(
|
|
36
|
+
open: () => {
|
|
37
|
+
control.current?.open();
|
|
27
38
|
},
|
|
28
39
|
close: (cb) => {
|
|
29
40
|
control.current?.close(cb);
|
package/src/dialog/index.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
export {
|
|
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 {
|
|
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';
|
package/src/dialog/index.web.ts
CHANGED
|
@@ -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
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
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 {
|
|
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 {
|
|
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';
|
package/src/dialog/types.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import type {
|
|
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: (
|
|
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
|
-
|
|
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
|
-
|
|
23
|
-
|
|
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
|
-
*
|
|
27
|
-
*
|
|
28
|
-
|
|
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
|
+
};
|
package/src/fonts/FontLoader.tsx
CHANGED
|
@@ -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
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// bundlers — Metro selects `FontLoader.native.tsx` on iOS/Android
|
|
7
|
-
// is safe to take a direct dependency on the web implementation
|
|
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
|
-
//
|
|
6
|
-
// imports
|
|
7
|
-
//
|
|
8
|
-
//
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
*
|
|
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(${
|
|
28
|
-
@font-face { font-family: 'BlomusModernus'; src: url(${
|
|
29
|
-
@font-face { font-family: 'Inter'; src: url(${
|
|
30
|
-
@font-face { font-family: 'Geist Mono'; src: url(${
|
|
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};
|
package/src/fonts/font-assets.ts
CHANGED
|
@@ -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`
|
|
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'),
|