@oxyhq/bloom 0.44.1 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/lib/commonjs/dialog/Dialog.js +12 -3
  2. package/lib/commonjs/dialog/Dialog.js.map +1 -1
  3. package/lib/commonjs/dialog/Dialog.web.js +23 -8
  4. package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
  5. package/lib/commonjs/index.js +29 -0
  6. package/lib/commonjs/index.js.map +1 -1
  7. package/lib/commonjs/index.web.js +73 -44
  8. package/lib/commonjs/index.web.js.map +1 -1
  9. package/lib/commonjs/surfaces/SurfaceHost.js +189 -0
  10. package/lib/commonjs/surfaces/SurfaceHost.js.map +1 -0
  11. package/lib/commonjs/surfaces/api.js +83 -0
  12. package/lib/commonjs/surfaces/api.js.map +1 -0
  13. package/lib/commonjs/surfaces/index.js +82 -0
  14. package/lib/commonjs/surfaces/index.js.map +1 -0
  15. package/lib/commonjs/surfaces/index.web.js +77 -0
  16. package/lib/commonjs/surfaces/index.web.js.map +1 -0
  17. package/lib/commonjs/surfaces/prompts.js +154 -0
  18. package/lib/commonjs/surfaces/prompts.js.map +1 -0
  19. package/lib/commonjs/surfaces/surfaceStore.js +172 -0
  20. package/lib/commonjs/surfaces/surfaceStore.js.map +1 -0
  21. package/lib/commonjs/surfaces/types.js +6 -0
  22. package/lib/commonjs/surfaces/types.js.map +1 -0
  23. package/lib/commonjs/surfaces/useSurface.js +36 -0
  24. package/lib/commonjs/surfaces/useSurface.js.map +1 -0
  25. package/lib/commonjs/theme/BloomThemeProvider.js +34 -15
  26. package/lib/commonjs/theme/BloomThemeProvider.js.map +1 -1
  27. package/lib/commonjs/theme/ambient-store.js +153 -0
  28. package/lib/commonjs/theme/ambient-store.js.map +1 -0
  29. package/lib/commonjs/theme/index.js +13 -0
  30. package/lib/commonjs/theme/index.js.map +1 -1
  31. package/lib/module/dialog/Dialog.js +13 -4
  32. package/lib/module/dialog/Dialog.js.map +1 -1
  33. package/lib/module/dialog/Dialog.web.js +23 -8
  34. package/lib/module/dialog/Dialog.web.js.map +1 -1
  35. package/lib/module/index.js +5 -0
  36. package/lib/module/index.js.map +1 -1
  37. package/lib/module/index.web.js +5 -0
  38. package/lib/module/index.web.js.map +1 -1
  39. package/lib/module/surfaces/SurfaceHost.js +184 -0
  40. package/lib/module/surfaces/SurfaceHost.js.map +1 -0
  41. package/lib/module/surfaces/api.js +48 -0
  42. package/lib/module/surfaces/api.js.map +1 -0
  43. package/lib/module/surfaces/index.js +24 -0
  44. package/lib/module/surfaces/index.js.map +1 -0
  45. package/lib/module/surfaces/index.web.js +19 -0
  46. package/lib/module/surfaces/index.web.js.map +1 -0
  47. package/lib/module/surfaces/prompts.js +148 -0
  48. package/lib/module/surfaces/prompts.js.map +1 -0
  49. package/lib/module/surfaces/surfaceStore.js +159 -0
  50. package/lib/module/surfaces/surfaceStore.js.map +1 -0
  51. package/lib/module/surfaces/types.js +4 -0
  52. package/lib/module/surfaces/types.js.map +1 -0
  53. package/lib/module/surfaces/useSurface.js +31 -0
  54. package/lib/module/surfaces/useSurface.js.map +1 -0
  55. package/lib/module/theme/BloomThemeProvider.js +34 -15
  56. package/lib/module/theme/BloomThemeProvider.js.map +1 -1
  57. package/lib/module/theme/ambient-store.js +146 -0
  58. package/lib/module/theme/ambient-store.js.map +1 -0
  59. package/lib/module/theme/index.js +1 -0
  60. package/lib/module/theme/index.js.map +1 -1
  61. package/lib/typescript/commonjs/dialog/Dialog.d.ts.map +1 -1
  62. package/lib/typescript/commonjs/dialog/Dialog.web.d.ts.map +1 -1
  63. package/lib/typescript/commonjs/dialog/types.d.ts +10 -0
  64. package/lib/typescript/commonjs/dialog/types.d.ts.map +1 -1
  65. package/lib/typescript/commonjs/index.d.ts +2 -0
  66. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  67. package/lib/typescript/commonjs/index.web.d.ts +2 -0
  68. package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
  69. package/lib/typescript/commonjs/surfaces/SurfaceHost.d.ts +25 -0
  70. package/lib/typescript/commonjs/surfaces/SurfaceHost.d.ts.map +1 -0
  71. package/lib/typescript/commonjs/surfaces/api.d.ts +41 -0
  72. package/lib/typescript/commonjs/surfaces/api.d.ts.map +1 -0
  73. package/lib/typescript/commonjs/surfaces/index.d.ts +25 -0
  74. package/lib/typescript/commonjs/surfaces/index.d.ts.map +1 -0
  75. package/lib/typescript/commonjs/surfaces/index.web.d.ts +20 -0
  76. package/lib/typescript/commonjs/surfaces/index.web.d.ts.map +1 -0
  77. package/lib/typescript/commonjs/surfaces/prompts.d.ts +13 -0
  78. package/lib/typescript/commonjs/surfaces/prompts.d.ts.map +1 -0
  79. package/lib/typescript/commonjs/surfaces/surfaceStore.d.ts +51 -0
  80. package/lib/typescript/commonjs/surfaces/surfaceStore.d.ts.map +1 -0
  81. package/lib/typescript/commonjs/surfaces/types.d.ts +145 -0
  82. package/lib/typescript/commonjs/surfaces/types.d.ts.map +1 -0
  83. package/lib/typescript/commonjs/surfaces/useSurface.d.ts +21 -0
  84. package/lib/typescript/commonjs/surfaces/useSurface.d.ts.map +1 -0
  85. package/lib/typescript/commonjs/theme/BloomThemeProvider.d.ts.map +1 -1
  86. package/lib/typescript/commonjs/theme/ambient-store.d.ts +61 -0
  87. package/lib/typescript/commonjs/theme/ambient-store.d.ts.map +1 -0
  88. package/lib/typescript/commonjs/theme/index.d.ts +2 -0
  89. package/lib/typescript/commonjs/theme/index.d.ts.map +1 -1
  90. package/lib/typescript/module/dialog/Dialog.d.ts.map +1 -1
  91. package/lib/typescript/module/dialog/Dialog.web.d.ts.map +1 -1
  92. package/lib/typescript/module/dialog/types.d.ts +10 -0
  93. package/lib/typescript/module/dialog/types.d.ts.map +1 -1
  94. package/lib/typescript/module/index.d.ts +2 -0
  95. package/lib/typescript/module/index.d.ts.map +1 -1
  96. package/lib/typescript/module/index.web.d.ts +2 -0
  97. package/lib/typescript/module/index.web.d.ts.map +1 -1
  98. package/lib/typescript/module/surfaces/SurfaceHost.d.ts +25 -0
  99. package/lib/typescript/module/surfaces/SurfaceHost.d.ts.map +1 -0
  100. package/lib/typescript/module/surfaces/api.d.ts +41 -0
  101. package/lib/typescript/module/surfaces/api.d.ts.map +1 -0
  102. package/lib/typescript/module/surfaces/index.d.ts +25 -0
  103. package/lib/typescript/module/surfaces/index.d.ts.map +1 -0
  104. package/lib/typescript/module/surfaces/index.web.d.ts +20 -0
  105. package/lib/typescript/module/surfaces/index.web.d.ts.map +1 -0
  106. package/lib/typescript/module/surfaces/prompts.d.ts +13 -0
  107. package/lib/typescript/module/surfaces/prompts.d.ts.map +1 -0
  108. package/lib/typescript/module/surfaces/surfaceStore.d.ts +51 -0
  109. package/lib/typescript/module/surfaces/surfaceStore.d.ts.map +1 -0
  110. package/lib/typescript/module/surfaces/types.d.ts +145 -0
  111. package/lib/typescript/module/surfaces/types.d.ts.map +1 -0
  112. package/lib/typescript/module/surfaces/useSurface.d.ts +21 -0
  113. package/lib/typescript/module/surfaces/useSurface.d.ts.map +1 -0
  114. package/lib/typescript/module/theme/BloomThemeProvider.d.ts.map +1 -1
  115. package/lib/typescript/module/theme/ambient-store.d.ts +61 -0
  116. package/lib/typescript/module/theme/ambient-store.d.ts.map +1 -0
  117. package/lib/typescript/module/theme/index.d.ts +2 -0
  118. package/lib/typescript/module/theme/index.d.ts.map +1 -1
  119. package/package.json +17 -1
  120. package/src/__tests__/ambient-theme.test.tsx +136 -0
  121. package/src/__tests__/surfaceStore.test.ts +219 -0
  122. package/src/dialog/Dialog.tsx +14 -3
  123. package/src/dialog/Dialog.web.tsx +25 -6
  124. package/src/dialog/types.ts +10 -0
  125. package/src/index.ts +15 -0
  126. package/src/index.web.ts +15 -0
  127. package/src/surfaces/SurfaceHost.tsx +207 -0
  128. package/src/surfaces/api.ts +55 -0
  129. package/src/surfaces/index.ts +38 -0
  130. package/src/surfaces/index.web.ts +33 -0
  131. package/src/surfaces/prompts.tsx +178 -0
  132. package/src/surfaces/surfaceStore.ts +168 -0
  133. package/src/surfaces/types.ts +156 -0
  134. package/src/surfaces/useSurface.ts +33 -0
  135. package/src/theme/BloomThemeProvider.tsx +52 -13
  136. package/src/theme/ambient-store.ts +186 -0
  137. package/src/theme/index.ts +7 -0
@@ -32,6 +32,11 @@ export { sizes as iconSizes, useCommonSVGProps } from "./icons/common.js";
32
32
  // Core components
33
33
  export * from "./portal/index.web.js";
34
34
  export { Dialog, DIALOG_SHEET_BACKDROP_TESTID, BloomDialogProvider, alert, useDialogContext, useDialogControl } from "./dialog/index.web.js";
35
+ // Surface stack — the shared, coordinated overlay system. The imperative API is
36
+ // the `surfaces` object (its members would otherwise clash with alert-dialog's
37
+ // `confirm`); the individual functions are also named exports of
38
+ // `@oxyhq/bloom/surfaces`.
39
+ export { surfaces, SurfaceProvider, SurfaceHost, useSurface } from "./surfaces/index.web.js";
35
40
  export * from "./button/index.web.js";
36
41
  export { Fab } from "./fab/index.web.js";
37
42
  export { FrostedIconButton } from "./frosted-icon-button/index.web.js";
@@ -1 +1 @@
1
- {"version":3,"names":["atoms","flatten","Z_INDEX","zIndex","tokens","web","native","ios","android","platform","select","bloomTailwindPreset","bloomThemeCss","bloomThemeBlock","FILL_ROLES","TEXT_ROLES","BORDER_ROLES","SPACING","RADIUS","BORDER_WIDTH","TYPOGRAPHY","FONT_FAMILY_VARS","SHADOW_BOX","bloomShadowStyle","useInteractionState","useDelayedLoading","useThrottledValue","useHaptics","BloomHapticsProvider","useGutters","useImagePreload","preloadImage","Icons","sizes","iconSizes","useCommonSVGProps","Dialog","DIALOG_SHEET_BACKDROP_TESTID","BloomDialogProvider","alert","useDialogContext","useDialogControl","Fab","FrostedIconButton","ErrorBoundary","AvatarGroup","UserHoverCard","toast","Typography","Skeleton","Grid","Fill","MediaInsetBorder","IconCircle","ConnectionDots","BenefitRow","BenefitList","PressableScale","PressableWithHover","SubtleHover","ScaleAndFadeIn","ScaleAndFadeOut","ShrinkAndPop","ScreenTransition","AnimatedCheck","SearchInput","Label","Field","InputGroup","Slider","Combobox","BottomSheet","LinkPreviewCard","CompositionBar","DotGridMeter","StatBar","ActivityHeatmap","bucketByDay","ProfileCard","Item","Kbd","AlertDialog","AlertDialogHost","confirm","Command","Code","Fonts"],"sourceRoot":"../../src","sources":["index.web.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AAEA;AACA,cAAc,kBAAS;;AAEvB;AACA,SAASA,KAAK,EAAEC,OAAO,EAAEC,OAAO,EAAEC,MAAM,QAAQ,mBAAU;AAE1D,OAAO,KAAKC,MAAM,MAAM,oBAAiB;AACzC,SAASC,GAAG,EAAEC,MAAM,EAAEC,GAAG,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,sBAAmB;;AAE/E;AACA;AACA;AACA,SACEC,mBAAmB,EACnBC,aAAa,EACbC,eAAe,EACfC,UAAU,EACVC,UAAU,EACVC,YAAY,EACZC,OAAO,EACPC,MAAM,EACNC,YAAY,EACZC,UAAU,EACVC,gBAAgB,EAChBC,UAAU,EACVC,gBAAgB,QACX,0BAAiB;AAYxB;AACA,SAASC,mBAAmB,QAAQ,gCAA6B;AACjE,SAASC,iBAAiB,QAAQ,8BAA2B;AAC7D,SAASC,iBAAiB,QAAQ,8BAA2B;AAC7D,SAASC,UAAU,EAAEC,oBAAoB,QAAQ,uBAAoB;AAErE,SAASC,UAAU,QAAQ,uBAAoB;AAE/C,SAASC,eAAe,EAAEC,YAAY,QAAQ,4BAAyB;;AAEvE;AACA,OAAO,KAAKC,KAAK,MAAM,kBAAS;AAChC,SAAkCC,KAAK,IAAIC,SAAS,EAAEC,iBAAiB,QAAQ,mBAAgB;;AAE/F;AACA,cAAc,uBAAoB;AAClC,SACEC,MAAM,EACNC,4BAA4B,EAC5BC,mBAAmB,EACnBC,KAAK,EACLC,gBAAgB,EAChBC,gBAAgB,QACX,uBAAoB;AAa3B,cAAc,uBAAoB;AAClC,SAASC,GAAG,QAAQ,oBAAiB;AAErC,SAASC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tB,cAAc,iBAAQ;AACtB,cAAc,qBAAY;AAC1B,cAAc,sBAAa;AAC3B,SAASC,eAAe,QAAQ,yBAAgB;AAGhD;AACA,SAASC,cAAc,QAAQ,4BAAmB;AAElD,SAASC,YAAY,QAAQ,2BAAkB;AAE/C,SAASC,OAAO,QAAQ,qBAAY;AAOpC,SAASC,eAAe,EAAEC,WAAW,QAAQ,6BAAoB;AAEjE,SAASC,WAAW,QAAQ,yBAAgB;AAU5C;AACA,cAAc,0BAAiB;AAC/B,SAASC,IAAI,QAAQ,iBAAQ;AAE7B,SAASC,GAAG,QAAQ,gBAAO;AAG3B;AACA,cAAc,uBAAc;AAC5B,cAAc,qBAAkB;AAChC,cAAc,wBAAqB;AACnC,cAAc,uBAAoB;AAClC,cAAc,6BAA0B;AACxC,cAAc,wBAAqB;AACnC,SAASC,WAAW,EAAEC,eAAe,EAAEC,OAAO,QAAQ,6BAA0B;AAMhF,SAASC,OAAO,QAAQ,wBAAqB;AAG7C;AACA,OAAO,KAAKC,IAAI,MAAM,iBAAQ;;AAE9B;AACA,OAAO,KAAKC,KAAK,MAAM,sBAAmB","ignoreList":[]}
1
+ {"version":3,"names":["atoms","flatten","Z_INDEX","zIndex","tokens","web","native","ios","android","platform","select","bloomTailwindPreset","bloomThemeCss","bloomThemeBlock","FILL_ROLES","TEXT_ROLES","BORDER_ROLES","SPACING","RADIUS","BORDER_WIDTH","TYPOGRAPHY","FONT_FAMILY_VARS","SHADOW_BOX","bloomShadowStyle","useInteractionState","useDelayedLoading","useThrottledValue","useHaptics","BloomHapticsProvider","useGutters","useImagePreload","preloadImage","Icons","sizes","iconSizes","useCommonSVGProps","Dialog","DIALOG_SHEET_BACKDROP_TESTID","BloomDialogProvider","alert","useDialogContext","useDialogControl","surfaces","SurfaceProvider","SurfaceHost","useSurface","Fab","FrostedIconButton","ErrorBoundary","AvatarGroup","UserHoverCard","toast","Typography","Skeleton","Grid","Fill","MediaInsetBorder","IconCircle","ConnectionDots","BenefitRow","BenefitList","PressableScale","PressableWithHover","SubtleHover","ScaleAndFadeIn","ScaleAndFadeOut","ShrinkAndPop","ScreenTransition","AnimatedCheck","SearchInput","Label","Field","InputGroup","Slider","Combobox","BottomSheet","LinkPreviewCard","CompositionBar","DotGridMeter","StatBar","ActivityHeatmap","bucketByDay","ProfileCard","Item","Kbd","AlertDialog","AlertDialogHost","confirm","Command","Code","Fonts"],"sourceRoot":"../../src","sources":["index.web.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AAEA;AACA,cAAc,kBAAS;;AAEvB;AACA,SAASA,KAAK,EAAEC,OAAO,EAAEC,OAAO,EAAEC,MAAM,QAAQ,mBAAU;AAE1D,OAAO,KAAKC,MAAM,MAAM,oBAAiB;AACzC,SAASC,GAAG,EAAEC,MAAM,EAAEC,GAAG,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,sBAAmB;;AAE/E;AACA;AACA;AACA,SACEC,mBAAmB,EACnBC,aAAa,EACbC,eAAe,EACfC,UAAU,EACVC,UAAU,EACVC,YAAY,EACZC,OAAO,EACPC,MAAM,EACNC,YAAY,EACZC,UAAU,EACVC,gBAAgB,EAChBC,UAAU,EACVC,gBAAgB,QACX,0BAAiB;AAYxB;AACA,SAASC,mBAAmB,QAAQ,gCAA6B;AACjE,SAASC,iBAAiB,QAAQ,8BAA2B;AAC7D,SAASC,iBAAiB,QAAQ,8BAA2B;AAC7D,SAASC,UAAU,EAAEC,oBAAoB,QAAQ,uBAAoB;AAErE,SAASC,UAAU,QAAQ,uBAAoB;AAE/C,SAASC,eAAe,EAAEC,YAAY,QAAQ,4BAAyB;;AAEvE;AACA,OAAO,KAAKC,KAAK,MAAM,kBAAS;AAChC,SAAkCC,KAAK,IAAIC,SAAS,EAAEC,iBAAiB,QAAQ,mBAAgB;;AAE/F;AACA,cAAc,uBAAoB;AAClC,SACEC,MAAM,EACNC,4BAA4B,EAC5BC,mBAAmB,EACnBC,KAAK,EACLC,gBAAgB,EAChBC,gBAAgB,Q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C,SAASC,MAAM,QAAQ,mBAAU;AAEjC,SAASC,QAAQ,QAAQ,yBAAsB;AAG/C;AACA,SAASC,WAAW,QAAQ,6BAA0B;AAGtD;AACA,cAAc,iBAAQ;AACtB,cAAc,kBAAS;AACvB,cAAc,iBAAQ;AACtB,cAAc,iBAAQ;AACtB,cAAc,qBAAY;AAC1B,cAAc,sBAAa;AAC3B,SAASC,eAAe,QAAQ,yBAAgB;AAGhD;AACA,SAASC,cAAc,QAAQ,4BAAmB;AAElD,SAASC,YAAY,QAAQ,2BAAkB;AAE/C,SAASC,OAAO,QAAQ,qBAAY;AAOpC,SAASC,eAAe,EAAEC,WAAW,QAAQ,6BAAoB;AAEjE,SAASC,WAAW,QAAQ,yBAAgB;AAU5C;AACA,cAAc,0BAAiB;AAC/B,SAASC,IAAI,QAAQ,iBAAQ;AAE7B,SAASC,GAAG,QAAQ,gBAAO;AAG3B;AACA,cAAc,uBAAc;AAC5B,cAAc,qBAAkB;AAChC,cAAc,wBAAqB;AACnC,cAAc,uBAAoB;AAClC,cAAc,6BAA0B;AACxC,cAAc,wBAAqB;AACnC,SAASC,WAAW,EAAEC,eAAe,EAAEC,OAAO,QAAQ,6BAA0B;AAMhF,SAASC,OAAO,QAAQ,wBAAqB;AAG7C;AACA,OAAO,KAAKC,IAAI,MAAM,iBAAQ;;AAE9B;AACA,OAAO,KAAKC,KAAK,MAAM,sBAAmB","ignoreList":[]}
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+
3
+ import React, { useCallback, useEffect, useMemo, useSyncExternalStore } from 'react';
4
+ import { BackHandler, Platform } from 'react-native';
5
+ import { useDialogControl } from "../dialog/context.js";
6
+ import { finalizeClose, getSnapshot, present, requestDismiss, resetSurfaces, subscribe } from "./surfaceStore.js";
7
+ import { SurfaceContext } from "./useSurface.js";
8
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
9
+ /** Default placement — the ecosystem's responsive "sheet" (bottom → centered). */
10
+ const DEFAULT_PLACEMENT = {
11
+ base: 'bottom',
12
+ md: 'center'
13
+ };
14
+
15
+ /** Map a surface's presentation config onto the shared `Dialog` props. */
16
+ function placementFor(p) {
17
+ return {
18
+ placement: p.placement ?? DEFAULT_PLACEMENT,
19
+ width: p.width,
20
+ maxWidth: p.maxWidth,
21
+ maxHeightRatio: p.maxHeightRatio,
22
+ inset: p.inset,
23
+ showHandle: p.showHandle,
24
+ dismissOnBackdrop: p.dismissOnBackdrop,
25
+ contentPadding: p.contentPadding,
26
+ style: p.style,
27
+ panelStyle: p.panelStyle,
28
+ panelClassName: p.panelClassName,
29
+ containerStyle: p.containerStyle,
30
+ containerClassName: p.containerClassName,
31
+ label: p.label,
32
+ testID: p.testID
33
+ };
34
+ }
35
+
36
+ /**
37
+ * Build the `<SurfaceHost>` + `<SurfaceProvider>` bound to a platform `Dialog`.
38
+ *
39
+ * `Dialog` is platform-forked (native `BottomSheet`-backed vs. pure-DOM web
40
+ * overlay), so — like `createAlertDialog` — the platform entry files
41
+ * (`index.ts` / `index.web.ts`) inject the correct one. The stack logic below is
42
+ * single-source, no duplication.
43
+ */
44
+ export function createSurfaceHost(Dialog) {
45
+ /**
46
+ * One stacked surface. Bridges a store entry onto an IMPERATIVE `Dialog`
47
+ * (`useDialogControl()` + `open()`/`close()`) — never the controlled
48
+ * `open`/`onClose` boolean path, which fires `onClose` synchronously as the
49
+ * dismiss REQUEST and has no post-exit callback, so it could never tell the
50
+ * store WHEN to splice the entry after the exit animation.
51
+ */
52
+ function SurfaceLayer({
53
+ entry,
54
+ index
55
+ }) {
56
+ const control = useDialogControl();
57
+ const {
58
+ id,
59
+ status
60
+ } = entry;
61
+ const controls = useMemo(() => ({
62
+ dismiss: result => requestDismiss(id, result),
63
+ present: (render, opts) => present(render, opts)
64
+ }), [id]);
65
+
66
+ // Open imperatively on mount (mirrors `AlertDialog`'s canonical
67
+ // fresh-mount open-from-effect; `control` is stable for the layer's life).
68
+ useEffect(() => {
69
+ control.open();
70
+ }, [control]);
71
+
72
+ // When the store flips this entry to 'closing' (a programmatic dismiss,
73
+ // dismissAll, dismissToRoot, Escape, or Android-back), run the exit
74
+ // animation. A user backdrop/Escape handled by the Dialog itself instead
75
+ // drives its own internal close; either way `onClose` fires post-exit.
76
+ useEffect(() => {
77
+ if (status === 'closing') control.close();
78
+ }, [status, control]);
79
+
80
+ // Fires AFTER the exit animation settles (imperative mode), for ANY
81
+ // dismissal path — user backdrop/Escape/back OR a programmatic dismiss.
82
+ // `requestDismiss` resolves-once (a programmatic dismiss already resolved
83
+ // with its result; this is a no-op then), then `finalizeClose` splices the
84
+ // entry out. Guarded by unique ids + `'closing'` status in the store.
85
+ const handleClose = useCallback(() => {
86
+ requestDismiss(id);
87
+ finalizeClose(id);
88
+ }, [id]);
89
+ const placement = useMemo(() => placementFor(entry.presentation), [entry.presentation]);
90
+ return /*#__PURE__*/_jsx(Dialog, {
91
+ control: control,
92
+ onClose: handleClose,
93
+ layer: index,
94
+ ...placement,
95
+ children: /*#__PURE__*/_jsx(SurfaceContext.Provider, {
96
+ value: controls,
97
+ children: entry.render(controls)
98
+ })
99
+ });
100
+ }
101
+ function SurfaceHost() {
102
+ const stack = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
103
+ useAndroidBackDismissesTop();
104
+ useEscapeDismissesTop();
105
+ return /*#__PURE__*/_jsx(_Fragment, {
106
+ children: stack.map((entry, index) => /*#__PURE__*/_jsx(SurfaceLayer, {
107
+ entry: entry,
108
+ index: index
109
+ }, entry.id))
110
+ });
111
+ }
112
+ SurfaceHost.displayName = 'SurfaceHost';
113
+
114
+ /**
115
+ * Mount ONCE near your app root — renders `children` plus the stack host.
116
+ * Requires the Bloom Portal provider to be mounted too (same as any `<Dialog>`
117
+ * usage): on web the Portal auto-creates `#bloom-portal-root`; on native mount
118
+ * `<Provider>`/`<Outlet>` from `@oxyhq/bloom/portal`. Can equally be folded
119
+ * next to that Portal provider — `<SurfaceHost>` used directly does the same
120
+ * job without wrapping `children`.
121
+ */
122
+ function SurfaceProvider({
123
+ children
124
+ }) {
125
+ // Resolve any pending awaiters if the provider unmounts so no `present()`
126
+ // promise is stranded.
127
+ useEffect(() => () => resetSurfaces(), []);
128
+ return /*#__PURE__*/_jsxs(_Fragment, {
129
+ children: [children, /*#__PURE__*/_jsx(SurfaceHost, {})]
130
+ });
131
+ }
132
+ SurfaceProvider.displayName = 'SurfaceProvider';
133
+ return {
134
+ SurfaceHost,
135
+ SurfaceProvider
136
+ };
137
+ }
138
+
139
+ /**
140
+ * ONE Android hardware-back handler for the whole stack → dismiss the TOP
141
+ * surface. Reads the live top from the store so a single registration always
142
+ * targets the current top. Returns `false` when the stack is empty so app-level
143
+ * back navigation is untouched.
144
+ */
145
+ function useAndroidBackDismissesTop() {
146
+ useEffect(() => {
147
+ if (Platform.OS !== 'android') return;
148
+ const sub = BackHandler.addEventListener('hardwareBackPress', () => {
149
+ const stack = getSnapshot();
150
+ const top = stack[stack.length - 1];
151
+ if (!top) return false;
152
+ if (top.presentation.dismissOnBackdrop === false) return true;
153
+ requestDismiss(top.id);
154
+ return true;
155
+ });
156
+ return () => sub.remove();
157
+ }, []);
158
+ }
159
+
160
+ /**
161
+ * Web-only: route Escape to the TOP surface only. A window-CAPTURE listener runs
162
+ * before each `Dialog`'s own document-level keydown, so `stopImmediatePropagation`
163
+ * prevents the lower stacked dialogs from ALSO handling Escape (they each add a
164
+ * document listener) — Escape dismisses strictly the top, LIFO. No-op on native.
165
+ */
166
+ function useEscapeDismissesTop() {
167
+ useEffect(() => {
168
+ if (Platform.OS !== 'web') return;
169
+ if (typeof window === 'undefined' || typeof document === 'undefined') return;
170
+ const handler = e => {
171
+ if (e.key !== 'Escape') return;
172
+ const stack = getSnapshot();
173
+ const top = stack[stack.length - 1];
174
+ if (!top) return;
175
+ if (top.presentation.dismissOnBackdrop === false) return;
176
+ e.stopImmediatePropagation();
177
+ e.preventDefault();
178
+ requestDismiss(top.id);
179
+ };
180
+ window.addEventListener('keydown', handler, true);
181
+ return () => window.removeEventListener('keydown', handler, true);
182
+ }, []);
183
+ }
184
+ //# sourceMappingURL=SurfaceHost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useEffect","useMemo","useSyncExternalStore","BackHandler","Platform","useDialogControl","finalizeClose","getSnapshot","present","requestDismiss","resetSurfaces","subscribe","SurfaceContext","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","DEFAULT_PLACEMENT","base","md","placementFor","p","placement","width","maxWidth","maxHeightRatio","inset","showHandle","dismissOnBackdrop","contentPadding","style","panelStyle","panelClassName","containerStyle","containerClassName","label","testID","createSurfaceHost","Dialog","SurfaceLayer","entry","index","control","id","status","controls","dismiss","result","render","opts","open","close","handleClose","presentation","onClose","layer","children","Provider","value","SurfaceHost","stack","useAndroidBackDismissesTop","useEscapeDismissesTop","map","displayName","SurfaceProvider","OS","sub","addEventListener","top","length","remove","window","document","handler","e","key","stopImmediatePropagation","preventDefault","removeEventListener"],"sourceRoot":"../../../src","sources":["surfaces/SurfaceHost.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IACVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,oBAAoB,QACf,OAAO;AACd,SAASC,WAAW,EAAEC,QAAQ,QAAQ,cAAc;AAEpD,SAASC,gBAAgB,QAAQ,sBAAmB;AAEpD,SACEC,aAAa,EACbC,WAAW,EACXC,OAAO,EACPC,cAAc,EACdC,aAAa,EACbC,SAAS,QACJ,mBAAgB;AACvB,SAASC,cAAc,QAAQ,iBAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAK9C;AACA,MAAMC,iBAAmD,GAAG;EAC1DC,IAAI,EAAE,QAAQ;EACdC,EAAE,EAAE;AACN,CAAC;;AAED;AACA,SAASC,YAAYA,CAACC,CAAsB,EAAwB;EAClE,OAAO;IACLC,SAAS,EAAED,CAAC,CAACC,SAAS,IAAIL,iBAAiB;IAC3CM,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MC,OAAO,GAAIC,CAAgB,IAAK;MACpC,IAAIA,CAAC,CAACC,GAAG,KAAK,QAAQ,EAAE;MACxB,MAAMhB,KAAK,GAAGvD,WAAW,CAAC,CAAC;MAC3B,MAAMgE,GAAG,GAAGT,KAAK,CAACA,KAAK,CAACU,MAAM,GAAG,CAAC,CAAC;MACnC,IAAI,CAACD,GAAG,EAAE;MACV,IAAIA,GAAG,CAAChB,YAAY,CAACzB,iBAAiB,KAAK,KAAK,EAAE;MAClD+C,CAAC,CAACE,wBAAwB,CAAC,CAAC;MAC5BF,CAAC,CAACG,cAAc,CAAC,CAAC;MAClBvE,cAAc,CAAC8D,GAAG,CAAC1B,EAAE,CAAC;IACxB,CAAC;IACD6B,MAAM,CAACJ,gBAAgB,CAAC,SAAS,EAAEM,OAAO,EAAE,IAAI,CAAC;IACjD,OAAO,MAAMF,MAAM,CAACO,mBAAmB,CAAC,SAAS,EAAEL,OAAO,EAAE,IAAI,CAAC;EACnE,CAAC,EAAE,EAAE,CAAC;AACR","ignoreList":[]}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ import { dismissAll, dismissToRoot, dismissTop, present, requestDismiss } from "./surfaceStore.js";
4
+ import { confirm, prompt } from "./prompts.js";
5
+ /**
6
+ * Dismiss the TOP surface, resolving its `present()` promise with `result`.
7
+ * The public counterpart of the store's `dismissTop`.
8
+ */
9
+ function dismiss(result) {
10
+ dismissTop(result);
11
+ }
12
+
13
+ /**
14
+ * Dismiss a SPECIFIC surface by id, resolving its `present()` promise with
15
+ * `result`. Rarely needed — most call sites use `dismiss()` (top) or the
16
+ * per-surface `SurfaceControls.dismiss`.
17
+ */
18
+ function dismissById(id, result) {
19
+ requestDismiss(id, result);
20
+ }
21
+
22
+ /**
23
+ * The shared imperative surface-stack API — a module singleton (mirrors
24
+ * `alert()`'s shape) so any consumer, in the SDK or an app, presents into the
25
+ * SAME coordinated Bloom stack from anywhere without threading a provider.
26
+ *
27
+ * Exposed at the package root as `surfaces` (avoids a bare `present`/`confirm`
28
+ * name clash with the existing `alert-dialog` `confirm`); the individual
29
+ * functions are also named exports of `@oxyhq/bloom/surfaces` for direct import.
30
+ */
31
+ export const surfaces = {
32
+ /** Present a new surface on top. Resolves with the dismissal result. */
33
+ present: (render, opts) => present(render, opts),
34
+ /** Dismiss the top surface. */
35
+ dismiss,
36
+ /** Dismiss a specific surface by id. */
37
+ dismissById,
38
+ /** Dismiss everything above the root surface. */
39
+ dismissToRoot,
40
+ /** Dismiss the entire stack (resolves pending awaiters with `undefined`). */
41
+ dismissAll,
42
+ /** Present a confirm surface; resolves `true`/`false`. */
43
+ confirm,
44
+ /** Present a prompt surface; resolves the string or `null`. */
45
+ prompt
46
+ };
47
+ export { confirm, dismiss, dismissAll, dismissById, dismissToRoot, present, prompt };
48
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["dismissAll","dismissToRoot","dismissTop","present","requestDismiss","confirm","prompt","dismiss","result","dismissById","id","surfaces","render","opts"],"sourceRoot":"../../../src","sources":["surfaces/api.ts"],"mappings":";;AAAA,SACEA,UAAU,EACVC,aAAa,EACbC,UAAU,EACVC,OAAO,EACPC,cAAc,QACT,mBAAgB;AACvB,SAASC,OAAO,EAAEC,MAAM,QAAQ,cAAW;AAG3C;AACA;AACA;AACA;AACA,SAASC,OAAOA,CAACC,MAAgB,EAAQ;EACvCN,UAAU,CAACM,MAAM,CAAC;AACpB;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASC,WAAWA,CAACC,EAAU,EAAEF,MAAgB,EAAQ;EACvDJ,cAAc,CAACM,EAAE,EAAEF,MAAM,CAAC;AAC5B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,QAAQ,GAAG;EACtB;EACAR,OAAO,EAAEA,CAAmBS,MAAuB,EAAEC,IAAqB,KACxEV,OAAO,CAASS,MAAM,EAAEC,IAAI,CAAC;EAC/B;EACAN,OAAO;EACP;EACAE,WAAW;EACX;EACAR,aAAa;EACb;EACAD,UAAU;EACV;EACAK,OAAO;EACP;EACAC;AACF,CAAU;AAEV,SAASD,OAAO,EAAEE,OAAO,EAAEP,UAAU,EAAES,WAAW,EAAER,aAAa,EAAEE,OAAO,EAAEG,MAAM","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ import { Dialog } from '../dialog';
4
+ import { createSurfaceHost } from "./SurfaceHost.js";
5
+
6
+ /**
7
+ * The shared, content-agnostic SURFACE STACK.
8
+ *
9
+ * `<SurfaceProvider>`/`<SurfaceHost>` render the coordinated stack; the
10
+ * imperative `surfaces` API (+ its named functions) present into it from
11
+ * anywhere; `useSurface()` gives a presented surface its own controls.
12
+ *
13
+ * `SurfaceHost`/`SurfaceProvider` are bound to the NATIVE `Dialog` here; the web
14
+ * fork (`./index.web`) binds the web `Dialog`. The store, imperative API, hook,
15
+ * and types are platform-agnostic and shared by both.
16
+ */
17
+ const {
18
+ SurfaceHost,
19
+ SurfaceProvider
20
+ } = createSurfaceHost(Dialog);
21
+ export { SurfaceHost, SurfaceProvider };
22
+ export { surfaces, present, dismiss, dismissById, dismissToRoot, dismissAll, confirm, prompt } from "./api.js";
23
+ export { useSurface } from "./useSurface.js";
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Dialog","createSurfaceHost","SurfaceHost","SurfaceProvider","surfaces","present","dismiss","dismissById","dismissToRoot","dismissAll","confirm","prompt","useSurface"],"sourceRoot":"../../../src","sources":["surfaces/index.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,WAAW;AAClC,SAASC,iBAAiB,QAAQ,kBAAe;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;EAAEC,WAAW;EAAEC;AAAgB,CAAC,GAAGF,iBAAiB,CAACD,MAAM,CAAC;AAElE,SAASE,WAAW,EAAEC,eAAe;AACrC,SACEC,QAAQ,EACRC,OAAO,EACPC,OAAO,EACPC,WAAW,EACXC,aAAa,EACbC,UAAU,EACVC,OAAO,EACPC,MAAM,QACD,UAAO;AACd,SAASC,UAAU,QAAQ,iBAAc","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ import { Dialog } from "../dialog/index.web.js";
4
+ import { createSurfaceHost } from "./SurfaceHost.js";
5
+
6
+ /**
7
+ * Web variant of the surface stack barrel. Identical surface area to the native
8
+ * `./index.ts` — it just binds the web-fork `Dialog` (`Dialog.web.tsx`, a
9
+ * pure-DOM overlay) instead of the native `BottomSheet`-backed one. The store,
10
+ * imperative API, hook, and types are shared, platform-agnostic modules.
11
+ */
12
+ const {
13
+ SurfaceHost,
14
+ SurfaceProvider
15
+ } = createSurfaceHost(Dialog);
16
+ export { SurfaceHost, SurfaceProvider };
17
+ export { surfaces, present, dismiss, dismissById, dismissToRoot, dismissAll, confirm, prompt } from "./api.js";
18
+ export { useSurface } from "./useSurface.js";
19
+ //# sourceMappingURL=index.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Dialog","createSurfaceHost","SurfaceHost","SurfaceProvider","surfaces","present","dismiss","dismissById","dismissToRoot","dismissAll","confirm","prompt","useSurface"],"sourceRoot":"../../../src","sources":["surfaces/index.web.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,wBAAqB;AAC5C,SAASC,iBAAiB,QAAQ,kBAAe;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;EAAEC,WAAW;EAAEC;AAAgB,CAAC,GAAGF,iBAAiB,CAACD,MAAM,CAAC;AAElE,SAASE,WAAW,EAAEC,eAAe;AACrC,SACEC,QAAQ,EACRC,OAAO,EACPC,OAAO,EACPC,WAAW,EACXC,aAAa,EACbC,UAAU,EACVC,OAAO,EACPC,MAAM,QACD,UAAO;AACd,SAASC,UAAU,QAAQ,iBAAc","ignoreList":[]}
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+
3
+ import React, { useCallback, useState } from 'react';
4
+ import { Text, View } from 'react-native';
5
+ import { Button } from '../button';
6
+ import { TextFieldInput } from "../text-field/index.js";
7
+ import { useTheme } from "../theme/use-theme.js";
8
+ import { present } from "./surfaceStore.js";
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ /**
11
+ * Built-in `confirm` / `prompt` surfaces.
12
+ *
13
+ * They are implemented AS surfaces — each calls `present(...)` so it STACKS
14
+ * correctly above any open surface with the right layer/z (unlike Bloom's
15
+ * one-at-a-time `alert()` FIFO queue, which cannot layer over another surface).
16
+ * Their buttons resolve through the surface's own `dismiss(result)` (NOT the
17
+ * underlying `Dialog`'s close), so the value flows back through the `present()`
18
+ * promise.
19
+ */
20
+
21
+ const TITLE_STYLE = {
22
+ fontSize: 22,
23
+ fontWeight: '600',
24
+ lineHeight: 30
25
+ };
26
+ const MESSAGE_STYLE = {
27
+ fontSize: 16,
28
+ lineHeight: 22
29
+ };
30
+ function ConfirmSurface({
31
+ options,
32
+ surface
33
+ }) {
34
+ const theme = useTheme();
35
+ const onConfirm = useCallback(() => surface.dismiss(true), [surface]);
36
+ const onCancel = useCallback(() => surface.dismiss(false), [surface]);
37
+ return /*#__PURE__*/_jsxs(View, {
38
+ children: [/*#__PURE__*/_jsx(Text, {
39
+ style: [TITLE_STYLE, {
40
+ color: theme.colors.text,
41
+ paddingBottom: options.message ? 4 : 16
42
+ }],
43
+ children: options.title
44
+ }), options.message ? /*#__PURE__*/_jsx(Text, {
45
+ style: [MESSAGE_STYLE, {
46
+ color: theme.colors.textSecondary,
47
+ paddingBottom: 16
48
+ }],
49
+ children: options.message
50
+ }) : null, /*#__PURE__*/_jsxs(View, {
51
+ style: {
52
+ gap: 8
53
+ },
54
+ children: [/*#__PURE__*/_jsx(Button, {
55
+ variant: options.destructive ? 'destructive' : 'primary',
56
+ onPress: onConfirm,
57
+ testID: "bloom-surface-confirm-confirm",
58
+ children: options.confirmLabel ?? 'Confirm'
59
+ }), options.hideCancel ? null : /*#__PURE__*/_jsx(Button, {
60
+ variant: "secondary",
61
+ onPress: onCancel,
62
+ testID: "bloom-surface-confirm-cancel",
63
+ children: options.cancelLabel ?? 'Cancel'
64
+ })]
65
+ })]
66
+ });
67
+ }
68
+ function PromptSurface({
69
+ options,
70
+ surface
71
+ }) {
72
+ const theme = useTheme();
73
+ const [value, setValue] = useState(options.defaultValue ?? '');
74
+ const onSubmit = useCallback(() => surface.dismiss(value), [surface, value]);
75
+ const onCancel = useCallback(() => surface.dismiss(null), [surface]);
76
+ return /*#__PURE__*/_jsxs(View, {
77
+ children: [/*#__PURE__*/_jsx(Text, {
78
+ style: [TITLE_STYLE, {
79
+ color: theme.colors.text,
80
+ paddingBottom: options.message ? 4 : 16
81
+ }],
82
+ children: options.title
83
+ }), options.message ? /*#__PURE__*/_jsx(Text, {
84
+ style: [MESSAGE_STYLE, {
85
+ color: theme.colors.textSecondary,
86
+ paddingBottom: 16
87
+ }],
88
+ children: options.message
89
+ }) : null, /*#__PURE__*/_jsx(TextFieldInput, {
90
+ label: options.inputLabel ?? options.title,
91
+ placeholder: options.placeholder,
92
+ value: value,
93
+ onChangeText: setValue,
94
+ autoFocus: true,
95
+ returnKeyType: "done",
96
+ onSubmitEditing: onSubmit,
97
+ testID: "bloom-surface-prompt-input"
98
+ }), /*#__PURE__*/_jsxs(View, {
99
+ style: {
100
+ gap: 8,
101
+ paddingTop: 16
102
+ },
103
+ children: [/*#__PURE__*/_jsx(Button, {
104
+ variant: "primary",
105
+ onPress: onSubmit,
106
+ testID: "bloom-surface-prompt-confirm",
107
+ children: options.confirmLabel ?? 'OK'
108
+ }), /*#__PURE__*/_jsx(Button, {
109
+ variant: "secondary",
110
+ onPress: onCancel,
111
+ testID: "bloom-surface-prompt-cancel",
112
+ children: options.cancelLabel ?? 'Cancel'
113
+ })]
114
+ })]
115
+ });
116
+ }
117
+
118
+ /**
119
+ * Present a confirm surface stacked on top of anything currently open. Resolves
120
+ * `true` on confirm, `false` on cancel OR on backdrop/Escape/back dismissal.
121
+ */
122
+ export function confirm(options) {
123
+ return present(surface => /*#__PURE__*/_jsx(ConfirmSurface, {
124
+ options: options,
125
+ surface: surface
126
+ }), {
127
+ placement: options.placement ?? 'center',
128
+ dismissOnBackdrop: options.dismissible ?? true,
129
+ label: options.title
130
+ }).then(result => result === true);
131
+ }
132
+
133
+ /**
134
+ * Present a prompt surface stacked on top of anything currently open. Resolves
135
+ * the entered string on submit, or `null` on cancel OR backdrop/Escape/back
136
+ * dismissal.
137
+ */
138
+ export function prompt(options) {
139
+ return present(surface => /*#__PURE__*/_jsx(PromptSurface, {
140
+ options: options,
141
+ surface: surface
142
+ }), {
143
+ placement: options.placement ?? 'center',
144
+ dismissOnBackdrop: options.dismissible ?? true,
145
+ label: options.title
146
+ }).then(result => typeof result === 'string' ? result : null);
147
+ }
148
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useCallback","useState","Text","View","Button","TextFieldInput","useTheme","present","jsx","_jsx","jsxs","_jsxs","TITLE_STYLE","fontSize","fontWeight","lineHeight","MESSAGE_STYLE","ConfirmSurface","options","surface","theme","onConfirm","dismiss","onCancel","children","style","color","colors","text","paddingBottom","message","title","textSecondary","gap","variant","destructive","onPress","testID","confirmLabel","hideCancel","cancelLabel","PromptSurface","value","setValue","defaultValue","onSubmit","label","inputLabel","placeholder","onChangeText","autoFocus","returnKeyType","onSubmitEditing","paddingTop","confirm","placement","dismissOnBackdrop","dismissible","then","result","prompt"],"sourceRoot":"../../../src","sources":["surfaces/prompts.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AACpD,SAASC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAEzC,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,cAAc,QAAQ,wBAAe;AAC9C,SAASC,QAAQ,QAAQ,uBAAoB;AAC7C,SAASC,OAAO,QAAQ,mBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAA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;IACxCC,iBAAiB,EAAEtC,OAAO,CAACuC,WAAW,IAAI,IAAI;IAC9CX,KAAK,EAAE5B,OAAO,CAACa;EACjB,CACF,CAAC,CAAC2B,IAAI,CAAEC,MAAM,IAAKA,MAAM,KAAK,IAAI,CAAC;AACrC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,MAAMA,CAAC1C,OAA6B,EAA0B;EAC5E,OAAOX,OAAO,CACXY,OAAO,iBAAKV,IAAA,CAACgC,aAAa;IAACvB,OAAO,EAAEA,OAAQ;IAACC,OAAO,EAAEA;EAAQ,CAAE,CAAC,EAClE;IACEoC,SAAS,EAAErC,OAAO,CAACqC,SAAS,IAAI,QAAQ;IACxCC,iBAAiB,EAAEtC,OAAO,CAACuC,WAAW,IAAI,IAAI;IAC9CX,KAAK,EAAE5B,OAAO,CAACa;EACjB,CACF,CAAC,CAAC2B,IAAI,CAAEC,MAAM,IAAM,OAAOA,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAG,IAAK,CAAC;AAClE","ignoreList":[]}
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The shared, content-agnostic SURFACE STACK.
5
+ *
6
+ * A module-singleton store (same pattern as `theme/ambient-store.ts` and
7
+ * `dialog/alert-store.ts`) holding an ordered stack of surfaces presented ON TOP
8
+ * of each other — bottom→top, the last entry is the top. One coordinated stack
9
+ * that the whole ecosystem (the SDK AND consumer apps) presents into, so
10
+ * overlays never clash: per-layer z, top-only interactivity, backdrop/Escape/
11
+ * back routed to the TOP surface, lower layers dimmed.
12
+ *
13
+ * It is CONTENT-AGNOSTIC: `present` takes a render function, not a route name.
14
+ * Bloom must never know about routes; the SDK layers its route registry on top.
15
+ *
16
+ * `getSnapshot` returns a STABLE reference while unchanged (the array identity
17
+ * only changes on a real mutation), so `useSyncExternalStore` — and the React
18
+ * Compiler — never see a silently-stale value.
19
+ */
20
+
21
+ let idCounter = 0;
22
+ function genId() {
23
+ idCounter += 1;
24
+ return `bloom-surface-${idCounter}`;
25
+ }
26
+
27
+ /** A single frozen "empty stack" snapshot returned by `getSnapshot` when idle. */
28
+ const EMPTY = Object.freeze([]);
29
+ let surfaces = EMPTY;
30
+ const listeners = new Set();
31
+ function emit() {
32
+ for (const listener of listeners) listener();
33
+ }
34
+
35
+ /** Subscribe to stack changes. Returns an unsubscribe fn. */
36
+ export function subscribe(listener) {
37
+ listeners.add(listener);
38
+ return () => {
39
+ listeners.delete(listener);
40
+ };
41
+ }
42
+
43
+ /** Current stack snapshot (stable ref while unchanged). Bottom→top. */
44
+ export function getSnapshot() {
45
+ return surfaces;
46
+ }
47
+
48
+ /**
49
+ * Present a new surface on TOP of the stack. Returns a promise that resolves
50
+ * with the value passed to `dismiss(result)` (or `undefined` when the surface is
51
+ * dismissed without a result / by a stack-wide clear).
52
+ */
53
+ export function present(render, opts) {
54
+ return new Promise(resolve => {
55
+ const entry = {
56
+ id: genId(),
57
+ render,
58
+ presentation: opts ?? {},
59
+ status: 'open',
60
+ resolve: resolve,
61
+ settled: false,
62
+ generation: 0
63
+ };
64
+ surfaces = [...surfaces, entry];
65
+ emit();
66
+ });
67
+ }
68
+
69
+ /**
70
+ * Request dismissal of a surface. RESOLVES THE PROMISE IMMEDIATELY (the exit
71
+ * animation that follows is cosmetic) and flips the entry to `'closing'` so the
72
+ * host runs its exit animation. Resolution is resolve-once via the `settled`
73
+ * guard — a second request (or the host's post-exit `onClose`) never re-resolves
74
+ * with a different value. Bumps the entry `generation` so a completion callback
75
+ * from a superseded cycle is inert.
76
+ */
77
+ export function requestDismiss(id, result) {
78
+ const entry = surfaces.find(e => e.id === id);
79
+ if (!entry) return;
80
+
81
+ // Resolve-once. The mapped replacement below carries `settled: true`, so a
82
+ // later `requestDismiss(id)` reads the settled entry and skips this branch —
83
+ // no in-place mutation of the live entry is needed.
84
+ if (!entry.settled) {
85
+ entry.resolve(result);
86
+ }
87
+ if (entry.status === 'closing') return;
88
+ surfaces = surfaces.map(e => e.id === id ? {
89
+ ...e,
90
+ settled: true,
91
+ status: 'closing',
92
+ generation: e.generation + 1
93
+ } : e);
94
+ emit();
95
+ }
96
+
97
+ /**
98
+ * Splice a surface out of the stack once its exit animation has settled. Called
99
+ * by the host from the `Dialog`'s post-exit `onClose`. Idempotent and gated on
100
+ * `'closing'` status: a stale/duplicate call — or one for an entry that is not
101
+ * actually closing — is a no-op, which (together with unique entry ids) is the
102
+ * stale-callback hygiene `BottomSheetBase`'s generation guard provides for its
103
+ * reused instance.
104
+ */
105
+ export function finalizeClose(id) {
106
+ const entry = surfaces.find(e => e.id === id);
107
+ if (!entry || entry.status !== 'closing') return;
108
+ const next = surfaces.filter(e => e.id !== id);
109
+ surfaces = next.length === 0 ? EMPTY : next;
110
+ emit();
111
+ }
112
+
113
+ /** Dismiss the TOP surface, resolving its promise with `result`. */
114
+ export function dismissTop(result) {
115
+ const top = surfaces[surfaces.length - 1];
116
+ if (top) requestDismiss(top.id, result);
117
+ }
118
+
119
+ /**
120
+ * Dismiss every surface ABOVE the bottom-most one, keeping the root surface
121
+ * open. Pending awaiters of the dismissed surfaces resolve with `undefined` so
122
+ * they never hang. No-op with 0 or 1 surfaces.
123
+ */
124
+ export function dismissToRoot() {
125
+ if (surfaces.length <= 1) return;
126
+ const above = surfaces.slice(1).map(e => e.id);
127
+ for (const id of above) requestDismiss(id, undefined);
128
+ }
129
+
130
+ /**
131
+ * Dismiss the ENTIRE stack. Every pending awaiter resolves with `undefined` so
132
+ * none hang.
133
+ */
134
+ export function dismissAll() {
135
+ const ids = surfaces.map(e => e.id);
136
+ for (const id of ids) requestDismiss(id, undefined);
137
+ }
138
+
139
+ /**
140
+ * Hard-reset the stack synchronously (no exit animation), resolving all pending
141
+ * awaiters with `undefined`. Used when the host provider unmounts so no
142
+ * `present()` promise is stranded.
143
+ */
144
+ export function resetSurfaces() {
145
+ if (surfaces.length === 0) return;
146
+ const pending = surfaces;
147
+ surfaces = EMPTY;
148
+ for (const entry of pending) {
149
+ if (!entry.settled) entry.resolve(undefined);
150
+ }
151
+ emit();
152
+ }
153
+
154
+ /** Test-only: hard-reset without notifying (drops listeners' work). */
155
+ export function __resetSurfacesForTests() {
156
+ surfaces = EMPTY;
157
+ idCounter = 0;
158
+ }
159
+ //# sourceMappingURL=surfaceStore.js.map