@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,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buttonToAction = buttonToAction;
|
|
7
|
+
exports.dismissAlert = dismissAlert;
|
|
8
|
+
exports.enqueueAlert = enqueueAlert;
|
|
9
|
+
exports.getAlertQueue = getAlertQueue;
|
|
10
|
+
exports.resolveButtons = resolveButtons;
|
|
11
|
+
exports.subscribeAlerts = subscribeAlerts;
|
|
12
|
+
let idCounter = 0;
|
|
13
|
+
function genId() {
|
|
14
|
+
idCounter += 1;
|
|
15
|
+
return `bloom-alert-${idCounter}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Imperative-alert store.
|
|
20
|
+
*
|
|
21
|
+
* The store sits in module scope so `alert()` works from anywhere — event
|
|
22
|
+
* handlers, async callbacks, top-level helpers — without threading a
|
|
23
|
+
* provider context through every call site.
|
|
24
|
+
*
|
|
25
|
+
* The visible UI is owned by a single subscriber (the `<BloomDialogProvider>`
|
|
26
|
+
* mounted inside the app's React tree). When there is no subscriber yet —
|
|
27
|
+
* because `alert()` was called before the provider mounted, or because the
|
|
28
|
+
* app forgot to mount the provider — entries accumulate in the queue and
|
|
29
|
+
* drain as soon as a subscriber attaches.
|
|
30
|
+
*
|
|
31
|
+
* Multiple subscribers are not supported by design. Two providers would
|
|
32
|
+
* race for the same alert; we instead enforce a single listener and let
|
|
33
|
+
* the most recent subscription win (the older one falls back to no-op).
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
let queue = [];
|
|
37
|
+
let listener = null;
|
|
38
|
+
function emit() {
|
|
39
|
+
if (listener) listener(queue);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Enqueue an alert. Returns the generated id so callers can dismiss it
|
|
44
|
+
* imperatively (rare — usually the dialog dismisses itself via a button
|
|
45
|
+
* tap). The runtime guarantees this enqueues even before any provider
|
|
46
|
+
* mounts; the provider drains pending entries on subscribe.
|
|
47
|
+
*/
|
|
48
|
+
function enqueueAlert(entry) {
|
|
49
|
+
const id = genId();
|
|
50
|
+
queue = [...queue, {
|
|
51
|
+
...entry,
|
|
52
|
+
id
|
|
53
|
+
}];
|
|
54
|
+
emit();
|
|
55
|
+
return id;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Remove an alert from the queue. Called by the provider once the bloom
|
|
60
|
+
* Dialog has finished closing for that entry.
|
|
61
|
+
*/
|
|
62
|
+
function dismissAlert(id) {
|
|
63
|
+
const next = queue.filter(e => e.id !== id);
|
|
64
|
+
if (next.length === queue.length) return;
|
|
65
|
+
queue = next;
|
|
66
|
+
emit();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Subscribe to queue changes. Replaces any previously-registered listener
|
|
71
|
+
* (single-subscriber model — see header). Returns an unsubscribe function.
|
|
72
|
+
*
|
|
73
|
+
* On subscribe, the current queue is delivered synchronously so the
|
|
74
|
+
* subscriber can render pending entries that arrived before mount.
|
|
75
|
+
*/
|
|
76
|
+
function subscribeAlerts(fn) {
|
|
77
|
+
listener = fn;
|
|
78
|
+
// Deliver the current queue immediately so a freshly-mounted provider
|
|
79
|
+
// catches up with whatever accumulated before it subscribed.
|
|
80
|
+
fn(queue);
|
|
81
|
+
return () => {
|
|
82
|
+
if (listener === fn) listener = null;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Inspect the current queue. Used internally and by tests. */
|
|
87
|
+
function getAlertQueue() {
|
|
88
|
+
return queue;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Translate an alert button to the action shape the unified `Dialog`
|
|
93
|
+
* accepts. Pure — no React, no theme — so it can be reused on web and
|
|
94
|
+
* native without forking.
|
|
95
|
+
*/
|
|
96
|
+
function buttonToAction(button) {
|
|
97
|
+
return {
|
|
98
|
+
label: button.text,
|
|
99
|
+
onPress: button.onPress ? () => button.onPress?.() : undefined,
|
|
100
|
+
color: button.style === 'destructive' ? 'destructive' : button.style === 'cancel' ? 'cancel' : 'default'
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Compute the effective button set for an alert. Mirrors React Native's
|
|
106
|
+
* `Alert.alert` semantics — an empty/omitted buttons array implies a
|
|
107
|
+
* single `OK` confirmation button.
|
|
108
|
+
*/
|
|
109
|
+
function resolveButtons(buttons) {
|
|
110
|
+
if (buttons && buttons.length > 0) return buttons;
|
|
111
|
+
return [{
|
|
112
|
+
text: 'OK',
|
|
113
|
+
style: 'default'
|
|
114
|
+
}];
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=alert-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["idCounter","genId","queue","listener","emit","enqueueAlert","entry","id","dismissAlert","next","filter","e","length","subscribeAlerts","fn","getAlertQueue","buttonToAction","button","label","text","onPress","undefined","color","style","resolveButtons","buttons"],"sourceRoot":"../../../src","sources":["dialog/alert-store.ts"],"mappings":";;;;;;;;;;;AAEA,IAAIA,SAAS,GAAG,CAAC;AACjB,SAASC,KAAKA,CAAA,EAAW;EACvBD,SAAS,IAAI,CAAC;EACd,OAAO,eAAeA,SAAS,EAAE;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsBA,IAAIE,KAAmB,GAAG,EAAE;AAC5B,IAAIC,QAAyB,GAAG,IAAI;AAEpC,SAASC,IAAIA,CAAA,EAAS;EACpB,IAAID,QAAQ,EAAEA,QAAQ,CAACD,KAAK,CAAC;AAC/B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,YAAYA,CAACC,KAA6B,EAAU;EAClE,MAAMC,EAAE,GAAGN,KAAK,CAAC,CAAC;EAClBC,KAAK,GAAG,CAAC,GAAGA,KAAK,EAAE;IAAE,GAAGI,KAAK;IAAEC;EAAG,CAAC,CAAC;EACpCH,IAAI,CAAC,CAAC;EACN,OAAOG,EAAE;AACX;;AAEA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAACD,EAAU,EAAQ;EAC7C,MAAME,IAAI,GAAGP,KAAK,CAACQ,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACJ,EAAE,KAAKA,EAAE,CAAC;EAC7C,IAAIE,IAAI,CAACG,MAAM,KAAKV,KAAK,CAACU,MAAM,EAAE;EAClCV,KAAK,GAAGO,IAAI;EACZL,IAAI,CAAC,CAAC;AACR;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,eAAeA,CAACC,EAAY,EAAc;EACxDX,QAAQ,GAAGW,EAAE;EACb;EACA;EACAA,EAAE,CAACZ,KAAK,CAAC;EACT,OAAO,MAAM;IACX,IAAIC,QAAQ,KAAKW,EAAE,EAAEX,QAAQ,GAAG,IAAI;EACtC,CAAC;AACH;;AAEA;AACO,SAASY,aAAaA,CAAA,EAA0B;EACrD,OAAOb,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASc,cAAcA,CAACC,MAAmB,EAAgB;EAChE,OAAO;IACLC,KAAK,EAAED,MAAM,CAACE,IAAI;IAClBC,OAAO,EAAEH,MAAM,CAACG,OAAO,GAAG,MAAMH,MAAM,CAACG,OAAO,GAAG,CAAC,GAAGC,SAAS;IAC9DC,KAAK,EACHL,MAAM,CAACM,KAAK,KAAK,aAAa,GAC1B,aAAa,GACbN,MAAM,CAACM,KAAK,KAAK,QAAQ,GACvB,QAAQ,GACR;EACV,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAACC,OAAkC,EAAiB;EAChF,IAAIA,OAAO,IAAIA,OAAO,CAACb,MAAM,GAAG,CAAC,EAAE,OAAOa,OAAO;EACjD,OAAO,CAAC;IAAEN,IAAI,EAAE,IAAI;IAAEI,KAAK,EAAE;EAAU,CAAC,CAAC;AAC3C","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.alert = alert;
|
|
7
|
+
var _alertStore = require("./alert-store.js");
|
|
8
|
+
/**
|
|
9
|
+
* Show a Bloom-styled confirmation dialog. Mirrors React Native's
|
|
10
|
+
* `Alert.alert(title, message?, buttons?)` signature so existing call
|
|
11
|
+
* sites migrate by changing the import only.
|
|
12
|
+
*
|
|
13
|
+
* If no buttons are passed, a single `OK` confirmation is rendered.
|
|
14
|
+
*
|
|
15
|
+
* The alert is enqueued in a module-scope store and rendered by
|
|
16
|
+
* `<BloomDialogProvider>`. Calls made before the provider mounts are
|
|
17
|
+
* queued and drained once the provider attaches — there is no fire-and-
|
|
18
|
+
* forget loss window. Calls made when no provider is ever mounted are
|
|
19
|
+
* silently queued forever; in development, mount the provider once at
|
|
20
|
+
* the app root and the queue will catch up immediately.
|
|
21
|
+
*
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { alert } from '@oxyhq/bloom';
|
|
24
|
+
*
|
|
25
|
+
* alert('Sign out?', 'You will need to enter your password to sign in again.', [
|
|
26
|
+
* { text: 'Cancel', style: 'cancel' },
|
|
27
|
+
* { text: 'Sign out', style: 'destructive', onPress: doSignOut },
|
|
28
|
+
* ]);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function alert(title, message, buttons) {
|
|
32
|
+
(0, _alertStore.enqueueAlert)({
|
|
33
|
+
title,
|
|
34
|
+
message,
|
|
35
|
+
buttons: (0, _alertStore.resolveButtons)(buttons)
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=alert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_alertStore","require","alert","title","message","buttons","enqueueAlert","resolveButtons"],"sourceRoot":"../../../src","sources":["dialog/alert.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,KAAKA,CACnBC,KAAa,EACbC,OAAgB,EAChBC,OAAuB,EACjB;EACN,IAAAC,wBAAY,EAAC;IACXH,KAAK;IACLC,OAAO;IACPC,OAAO,EAAE,IAAAE,0BAAc,EAACF,OAAO;EACjC,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -15,6 +15,14 @@ Context.displayName = 'BloomDialogContext';
|
|
|
15
15
|
function useDialogContext() {
|
|
16
16
|
return (0, _react.useContext)(Context);
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Return a stable handle that can imperatively `open()` and `close()` a
|
|
21
|
+
* `<Dialog>` mounted with the same control.
|
|
22
|
+
*
|
|
23
|
+
* The handle survives across re-renders; mounting a different `<Dialog>`
|
|
24
|
+
* with the same control attaches the new instance via the internal ref.
|
|
25
|
+
*/
|
|
18
26
|
function useDialogControl() {
|
|
19
27
|
const id = (0, _react.useId)();
|
|
20
28
|
const control = (0, _react.useRef)({
|
|
@@ -24,8 +32,8 @@ function useDialogControl() {
|
|
|
24
32
|
return (0, _react.useMemo)(() => ({
|
|
25
33
|
id,
|
|
26
34
|
ref: control,
|
|
27
|
-
open:
|
|
28
|
-
control.current?.open(
|
|
35
|
+
open: () => {
|
|
36
|
+
control.current?.open();
|
|
29
37
|
},
|
|
30
38
|
close: cb => {
|
|
31
39
|
control.current?.close(cb);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","Context","exports","createContext","close","isWithinDialog","displayName","useDialogContext","useContext","useDialogControl","id","useId","control","useRef","open","useMemo","ref","
|
|
1
|
+
{"version":3,"names":["_react","require","Context","exports","createContext","close","isWithinDialog","displayName","useDialogContext","useContext","useDialogControl","id","useId","control","useRef","open","useMemo","ref","current","cb"],"sourceRoot":"../../../src","sources":["dialog/context.ts"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAOO,MAAMC,OAAO,GAAAC,OAAA,CAAAD,OAAA,gBAAG,IAAAE,oBAAa,EAAqB;EACvDC,KAAK,EAAEA,CAAA,KAAM,CAAC,CAAC;EACfC,cAAc,EAAE;AAClB,CAAC,CAAC;AACFJ,OAAO,CAACK,WAAW,GAAG,oBAAoB;AAEnC,SAASC,gBAAgBA,CAAA,EAAuB;EACrD,OAAO,IAAAC,iBAAU,EAACP,OAAO,CAAC;AAC5B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,gBAAgBA,CAAA,EAAuB;EACrD,MAAMC,EAAE,GAAG,IAAAC,YAAK,EAAC,CAAC;EAClB,MAAMC,OAAO,GAAG,IAAAC,aAAM,EAA+B;IACnDC,IAAI,EAAEA,CAAA,KAAM,CAAC,CAAC;IACdV,KAAK,EAAEA,CAAA,KAAM,CAAC;EAChB,CAAC,CAAC;EAEF,OAAO,IAAAW,cAAO,EACZ,OAAO;IACLL,EAAE;IACFM,GAAG,EAAEJ,OAAO;IACZE,IAAI,EAAEA,CAAA,KAAM;MACVF,OAAO,CAACK,OAAO,EAAEH,IAAI,CAAC,CAAC;IACzB,CAAC;IACDV,KAAK,EAAGc,EAAE,IAAK;MACbN,OAAO,CAACK,OAAO,EAAEb,KAAK,CAACc,EAAE,CAAC;IAC5B;EACF,CAAC,CAAC,EACF,CAACR,EAAE,CACL,CAAC;AACH","ignoreList":[]}
|
|
@@ -3,40 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "BloomDialogProvider", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _BloomDialogProvider.BloomDialogProvider;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "Dialog", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return _Dialog.
|
|
15
|
+
return _Dialog.Dialog;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "alert", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "Inner", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _Dialog.Inner;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "Outer", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _Dialog.Outer;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "ScrollableInner", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _Dialog.ScrollableInner;
|
|
21
|
+
return _alert.alert;
|
|
40
22
|
}
|
|
41
23
|
});
|
|
42
24
|
Object.defineProperty(exports, "useDialogContext", {
|
|
@@ -52,5 +34,7 @@ Object.defineProperty(exports, "useDialogControl", {
|
|
|
52
34
|
}
|
|
53
35
|
});
|
|
54
36
|
var _Dialog = require("./Dialog");
|
|
37
|
+
var _BloomDialogProvider = require("./BloomDialogProvider");
|
|
38
|
+
var _alert = require("./alert.js");
|
|
55
39
|
var _context = require("./context.js");
|
|
56
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_Dialog","require","_context"],"sourceRoot":"../../../src","sources":["dialog/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_Dialog","require","_BloomDialogProvider","_alert","_context"],"sourceRoot":"../../../src","sources":["dialog/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA","ignoreList":[]}
|
|
@@ -3,40 +3,28 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "BLOOM_DIALOG_CSS", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return _DialogWeb.
|
|
9
|
+
return _DialogWeb.BLOOM_DIALOG_CSS;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "BloomDialogProvider", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return
|
|
15
|
+
return _BloomDialogProviderWeb.BloomDialogProvider;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "Dialog", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return _DialogWeb.
|
|
21
|
+
return _DialogWeb.Dialog;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "
|
|
24
|
+
Object.defineProperty(exports, "alert", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
get: function () {
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "Outer", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _DialogWeb.Outer;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "ScrollableInner", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _DialogWeb.ScrollableInner;
|
|
27
|
+
return _alert.alert;
|
|
40
28
|
}
|
|
41
29
|
});
|
|
42
30
|
Object.defineProperty(exports, "useDialogContext", {
|
|
@@ -52,5 +40,7 @@ Object.defineProperty(exports, "useDialogControl", {
|
|
|
52
40
|
}
|
|
53
41
|
});
|
|
54
42
|
var _DialogWeb = require("./Dialog.web.js");
|
|
43
|
+
var _BloomDialogProviderWeb = require("./BloomDialogProvider.web.js");
|
|
44
|
+
var _alert = require("./alert.js");
|
|
55
45
|
var _context = require("./context.js");
|
|
56
46
|
//# sourceMappingURL=index.web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_DialogWeb","require","_context"],"sourceRoot":"../../../src","sources":["dialog/index.web.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_DialogWeb","require","_BloomDialogProviderWeb","_alert","_context"],"sourceRoot":"../../../src","sources":["dialog/index.web.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA","ignoreList":[]}
|
|
@@ -9,11 +9,12 @@ var _applyFontFacesWeb = require("./apply-font-faces.web.js");
|
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
11
|
// Reach for the web variant explicitly. The default `./apply-font-faces`
|
|
12
|
-
// is a no-op stub
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// bundlers — Metro selects `FontLoader.native.tsx` on iOS/Android
|
|
16
|
-
// is safe to take a direct dependency on the web implementation
|
|
12
|
+
// is a no-op stub on native — native loads its fonts via
|
|
13
|
+
// `useFonts(FONT_ASSETS)` in `FontLoader.native.tsx` and has no use for
|
|
14
|
+
// CSS `@font-face` injection. This file (`FontLoader.tsx`) is only picked
|
|
15
|
+
// up by web bundlers — Metro selects `FontLoader.native.tsx` on iOS/Android
|
|
16
|
+
// — so it is safe to take a direct dependency on the web implementation
|
|
17
|
+
// here.
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Web font loader. Applies the Bloom `@font-face` rules and CSS variables
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_applyFontFacesWeb","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","FontLoader","enabled","children","applied","useRef","current","applyFontFaces","jsx","Fragment"],"sourceRoot":"../../../src","sources":["fonts/FontLoader.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_applyFontFacesWeb","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","FontLoader","enabled","children","applied","useRef","current","applyFontFaces","jsx","Fragment"],"sourceRoot":"../../../src","sources":["fonts/FontLoader.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAQA,IAAAC,kBAAA,GAAAD,OAAA;AAAwD,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAPxD;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASkB,UAAUA,CAAC;EAAEC,OAAO;EAAEC;AAA0B,CAAC,EAAE;EACjE,MAAMC,OAAO,GAAG,IAAAC,aAAM,EAAC,KAAK,CAAC;EAC7B,IAAIH,OAAO,IAAI,CAACE,OAAO,CAACE,OAAO,EAAE;IAC/BF,OAAO,CAACE,OAAO,GAAG,IAAI;IACtB,IAAAC,iCAAc,EAAC,CAAC;EAClB;EACA,oBAAO,IAAA1B,WAAA,CAAA2B,GAAA,EAAA3B,WAAA,CAAA4B,QAAA;IAAAN,QAAA,EAAGA;EAAQ,CAAG,CAAC;AACxB","ignoreList":[]}
|
|
@@ -8,10 +8,10 @@ exports.applyFontFaces = applyFontFaces;
|
|
|
8
8
|
// is selected by bundlers via the package.json conditions. RN consumers
|
|
9
9
|
// never need font-face injection — useFonts handles loading on native.
|
|
10
10
|
//
|
|
11
|
-
//
|
|
12
|
-
// imports
|
|
13
|
-
//
|
|
14
|
-
//
|
|
11
|
+
// The web variant does NOT pull in any `.woff2` files via asset imports —
|
|
12
|
+
// it imports base64 data URLs from `font-data.web.ts`. This stub stays
|
|
13
|
+
// here so the file split (`*.ts` vs `*.web.ts`) makes the platform
|
|
14
|
+
// intent explicit and so the runtime API surface matches across platforms.
|
|
15
15
|
function applyFontFaces() {
|
|
16
16
|
// intentionally empty
|
|
17
17
|
}
|
|
@@ -4,14 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.applyFontFaces = applyFontFaces;
|
|
7
|
-
var
|
|
8
|
-
var _BlomusModernusBold = _interopRequireDefault(require("./assets/BlomusModernus-Bold.woff2"));
|
|
9
|
-
var _InterVariable = _interopRequireDefault(require("./assets/InterVariable.woff2"));
|
|
10
|
-
var _GeistMonoVariable = _interopRequireDefault(require("./assets/GeistMono-Variable.woff2"));
|
|
7
|
+
var _fontDataWeb = require("./font-data.web.js");
|
|
11
8
|
var _tokens = require("./tokens.js");
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
/// <reference path="../assets.d.ts" />
|
|
14
|
-
|
|
15
9
|
const STYLE_ID = 'bloom-fonts';
|
|
16
10
|
|
|
17
11
|
/**
|
|
@@ -19,10 +13,17 @@ const STYLE_ID = 'bloom-fonts';
|
|
|
19
13
|
*
|
|
20
14
|
* Web-only. The native counterpart in `apply-font-faces.ts` is a no-op
|
|
21
15
|
* stub — Metro cannot parse `.woff2` imports, so the file split keeps
|
|
22
|
-
*
|
|
16
|
+
* the font payload out of the native bundle entirely. Idempotent: safe to
|
|
23
17
|
* call multiple times; subsequent calls early-return after the
|
|
24
18
|
* `<style id="bloom-fonts">` tag has been mounted. SSR-safe via the
|
|
25
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.
|
|
26
27
|
*/
|
|
27
28
|
function applyFontFaces() {
|
|
28
29
|
if (typeof document === 'undefined') return;
|
|
@@ -30,10 +31,10 @@ function applyFontFaces() {
|
|
|
30
31
|
const style = document.createElement('style');
|
|
31
32
|
style.id = STYLE_ID;
|
|
32
33
|
style.textContent = `
|
|
33
|
-
@font-face { font-family: 'BlomusModernus'; src: url(${
|
|
34
|
-
@font-face { font-family: 'BlomusModernus'; src: url(${
|
|
35
|
-
@font-face { font-family: 'Inter'; src: url(${
|
|
36
|
-
@font-face { font-family: 'Geist Mono'; src: url(${
|
|
34
|
+
@font-face { font-family: 'BlomusModernus'; src: url(${_fontDataWeb.blomusModernusRegular}) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
|
|
35
|
+
@font-face { font-family: 'BlomusModernus'; src: url(${_fontDataWeb.blomusModernusBold}) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
|
|
36
|
+
@font-face { font-family: 'Inter'; src: url(${_fontDataWeb.interVariable}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
37
|
+
@font-face { font-family: 'Geist Mono'; src: url(${_fontDataWeb.geistMonoVariable}) format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
37
38
|
:root {
|
|
38
39
|
--bloom-font-display: ${_tokens.fontFamilies.display};
|
|
39
40
|
--bloom-font-sans: ${_tokens.fontFamilies.sans};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_fontDataWeb","require","_tokens","STYLE_ID","applyFontFaces","document","getElementById","style","createElement","id","textContent","blomusModernusRegular","blomusModernusBold","interVariable","geistMonoVariable","fontFamilies","display","sans","mono","head","appendChild"],"sourceRoot":"../../../src","sources":["fonts/apply-font-faces.web.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,QAAQ,GAAG,aAAa;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAAA,EAAS;EACrC,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;EACrC,IAAIA,QAAQ,CAACC,cAAc,CAACH,QAAQ,CAAC,EAAE;EAEvC,MAAMI,KAAK,GAAGF,QAAQ,CAACG,aAAa,CAAC,OAAO,CAAC;EAC7CD,KAAK,CAACE,EAAE,GAAGN,QAAQ;EACnBI,KAAK,CAACG,WAAW,GAAG;AACtB,2DAA2DC,kCAAqB;AAChF,2DAA2DC,+BAAkB;AAC7E,kDAAkDC,0BAAa;AAC/D,uDAAuDC,8BAAiB;AACxE;AACA,8BAA8BC,oBAAY,CAACC,OAAO;AAClD,2BAA2BD,oBAAY,CAACE,IAAI;AAC5C,2BAA2BF,oBAAY,CAACG,IAAI;AAC5C;AACA,GAAG;EACDb,QAAQ,CAACc,IAAI,CAACC,WAAW,CAACb,KAAK,CAAC;AAClC","ignoreList":[]}
|
|
@@ -11,8 +11,8 @@ exports.FONT_ASSETS = void 0;
|
|
|
11
11
|
// covers all weights at runtime. `@fontsource(-variable)?/*` packages only
|
|
12
12
|
// publish .woff2 for their variable axes — modern react-native font loading
|
|
13
13
|
// requires .ttf, so we use the upstream variable TTFs instead. On web,
|
|
14
|
-
// `apply-font-faces.web.ts`
|
|
15
|
-
// file is never imported.
|
|
14
|
+
// `apply-font-faces.web.ts` inlines the .woff2 variants as base64 data URLs
|
|
15
|
+
// (see `font-data.web.ts`) and this file is never imported.
|
|
16
16
|
|
|
17
17
|
const FONT_ASSETS = exports.FONT_ASSETS = {
|
|
18
18
|
BlomusModernus: require('./assets/BlomusModernus-Regular.ttf'),
|