@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
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SurfaceProvider = exports.SurfaceHost = void 0;
7
+ Object.defineProperty(exports, "confirm", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _api.confirm;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "dismiss", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _api.dismiss;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "dismissAll", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _api.dismissAll;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "dismissById", {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _api.dismissById;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, "dismissToRoot", {
32
+ enumerable: true,
33
+ get: function () {
34
+ return _api.dismissToRoot;
35
+ }
36
+ });
37
+ Object.defineProperty(exports, "present", {
38
+ enumerable: true,
39
+ get: function () {
40
+ return _api.present;
41
+ }
42
+ });
43
+ Object.defineProperty(exports, "prompt", {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _api.prompt;
47
+ }
48
+ });
49
+ Object.defineProperty(exports, "surfaces", {
50
+ enumerable: true,
51
+ get: function () {
52
+ return _api.surfaces;
53
+ }
54
+ });
55
+ Object.defineProperty(exports, "useSurface", {
56
+ enumerable: true,
57
+ get: function () {
58
+ return _useSurface.useSurface;
59
+ }
60
+ });
61
+ var _dialog = require("../dialog");
62
+ var _SurfaceHost = require("./SurfaceHost.js");
63
+ var _api = require("./api.js");
64
+ var _useSurface = require("./useSurface.js");
65
+ /**
66
+ * The shared, content-agnostic SURFACE STACK.
67
+ *
68
+ * `<SurfaceProvider>`/`<SurfaceHost>` render the coordinated stack; the
69
+ * imperative `surfaces` API (+ its named functions) present into it from
70
+ * anywhere; `useSurface()` gives a presented surface its own controls.
71
+ *
72
+ * `SurfaceHost`/`SurfaceProvider` are bound to the NATIVE `Dialog` here; the web
73
+ * fork (`./index.web`) binds the web `Dialog`. The store, imperative API, hook,
74
+ * and types are platform-agnostic and shared by both.
75
+ */
76
+ const {
77
+ SurfaceHost,
78
+ SurfaceProvider
79
+ } = (0, _SurfaceHost.createSurfaceHost)(_dialog.Dialog);
80
+ exports.SurfaceProvider = SurfaceProvider;
81
+ exports.SurfaceHost = SurfaceHost;
82
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_dialog","require","_SurfaceHost","_api","_useSurface","SurfaceHost","SurfaceProvider","createSurfaceHost","Dialog","exports"],"sourceRoot":"../../../src","sources":["surfaces/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAgBA,IAAAE,IAAA,GAAAF,OAAA;AAUA,IAAAG,WAAA,GAAAH,OAAA;AAxBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;EAAEI,WAAW;EAAEC;AAAgB,CAAC,GAAG,IAAAC,8BAAiB,EAACC,cAAM,CAAC;AAACC,OAAA,CAAAH,eAAA,GAAAA,eAAA;AAAAG,OAAA,CAAAJ,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SurfaceProvider = exports.SurfaceHost = void 0;
7
+ Object.defineProperty(exports, "confirm", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _api.confirm;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "dismiss", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _api.dismiss;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "dismissAll", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _api.dismissAll;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "dismissById", {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _api.dismissById;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, "dismissToRoot", {
32
+ enumerable: true,
33
+ get: function () {
34
+ return _api.dismissToRoot;
35
+ }
36
+ });
37
+ Object.defineProperty(exports, "present", {
38
+ enumerable: true,
39
+ get: function () {
40
+ return _api.present;
41
+ }
42
+ });
43
+ Object.defineProperty(exports, "prompt", {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _api.prompt;
47
+ }
48
+ });
49
+ Object.defineProperty(exports, "surfaces", {
50
+ enumerable: true,
51
+ get: function () {
52
+ return _api.surfaces;
53
+ }
54
+ });
55
+ Object.defineProperty(exports, "useSurface", {
56
+ enumerable: true,
57
+ get: function () {
58
+ return _useSurface.useSurface;
59
+ }
60
+ });
61
+ var _indexWeb = require("../dialog/index.web.js");
62
+ var _SurfaceHost = require("./SurfaceHost.js");
63
+ var _api = require("./api.js");
64
+ var _useSurface = require("./useSurface.js");
65
+ /**
66
+ * Web variant of the surface stack barrel. Identical surface area to the native
67
+ * `./index.ts` — it just binds the web-fork `Dialog` (`Dialog.web.tsx`, a
68
+ * pure-DOM overlay) instead of the native `BottomSheet`-backed one. The store,
69
+ * imperative API, hook, and types are shared, platform-agnostic modules.
70
+ */
71
+ const {
72
+ SurfaceHost,
73
+ SurfaceProvider
74
+ } = (0, _SurfaceHost.createSurfaceHost)(_indexWeb.Dialog);
75
+ exports.SurfaceProvider = SurfaceProvider;
76
+ exports.SurfaceHost = SurfaceHost;
77
+ //# sourceMappingURL=index.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_indexWeb","require","_SurfaceHost","_api","_useSurface","SurfaceHost","SurfaceProvider","createSurfaceHost","Dialog","exports"],"sourceRoot":"../../../src","sources":["surfaces/index.web.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAWA,IAAAE,IAAA,GAAAF,OAAA;AAUA,IAAAG,WAAA,GAAAH,OAAA;AAnBA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;EAAEI,WAAW;EAAEC;AAAgB,CAAC,GAAG,IAAAC,8BAAiB,EAACC,gBAAM,CAAC;AAACC,OAAA,CAAAH,eAAA,GAAAA,eAAA;AAAAG,OAAA,CAAAJ,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.confirm = confirm;
7
+ exports.prompt = prompt;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactNative = require("react-native");
10
+ var _button = require("../button");
11
+ var _index = require("../text-field/index.js");
12
+ var _useTheme = require("../theme/use-theme.js");
13
+ var _surfaceStore = require("./surfaceStore.js");
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ 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); }
16
+ /**
17
+ * Built-in `confirm` / `prompt` surfaces.
18
+ *
19
+ * They are implemented AS surfaces — each calls `present(...)` so it STACKS
20
+ * correctly above any open surface with the right layer/z (unlike Bloom's
21
+ * one-at-a-time `alert()` FIFO queue, which cannot layer over another surface).
22
+ * Their buttons resolve through the surface's own `dismiss(result)` (NOT the
23
+ * underlying `Dialog`'s close), so the value flows back through the `present()`
24
+ * promise.
25
+ */
26
+
27
+ const TITLE_STYLE = {
28
+ fontSize: 22,
29
+ fontWeight: '600',
30
+ lineHeight: 30
31
+ };
32
+ const MESSAGE_STYLE = {
33
+ fontSize: 16,
34
+ lineHeight: 22
35
+ };
36
+ function ConfirmSurface({
37
+ options,
38
+ surface
39
+ }) {
40
+ const theme = (0, _useTheme.useTheme)();
41
+ const onConfirm = (0, _react.useCallback)(() => surface.dismiss(true), [surface]);
42
+ const onCancel = (0, _react.useCallback)(() => surface.dismiss(false), [surface]);
43
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
44
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
45
+ style: [TITLE_STYLE, {
46
+ color: theme.colors.text,
47
+ paddingBottom: options.message ? 4 : 16
48
+ }],
49
+ children: options.title
50
+ }), options.message ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
51
+ style: [MESSAGE_STYLE, {
52
+ color: theme.colors.textSecondary,
53
+ paddingBottom: 16
54
+ }],
55
+ children: options.message
56
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
57
+ style: {
58
+ gap: 8
59
+ },
60
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
61
+ variant: options.destructive ? 'destructive' : 'primary',
62
+ onPress: onConfirm,
63
+ testID: "bloom-surface-confirm-confirm",
64
+ children: options.confirmLabel ?? 'Confirm'
65
+ }), options.hideCancel ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
66
+ variant: "secondary",
67
+ onPress: onCancel,
68
+ testID: "bloom-surface-confirm-cancel",
69
+ children: options.cancelLabel ?? 'Cancel'
70
+ })]
71
+ })]
72
+ });
73
+ }
74
+ function PromptSurface({
75
+ options,
76
+ surface
77
+ }) {
78
+ const theme = (0, _useTheme.useTheme)();
79
+ const [value, setValue] = (0, _react.useState)(options.defaultValue ?? '');
80
+ const onSubmit = (0, _react.useCallback)(() => surface.dismiss(value), [surface, value]);
81
+ const onCancel = (0, _react.useCallback)(() => surface.dismiss(null), [surface]);
82
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
83
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
84
+ style: [TITLE_STYLE, {
85
+ color: theme.colors.text,
86
+ paddingBottom: options.message ? 4 : 16
87
+ }],
88
+ children: options.title
89
+ }), options.message ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
90
+ style: [MESSAGE_STYLE, {
91
+ color: theme.colors.textSecondary,
92
+ paddingBottom: 16
93
+ }],
94
+ children: options.message
95
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.TextFieldInput, {
96
+ label: options.inputLabel ?? options.title,
97
+ placeholder: options.placeholder,
98
+ value: value,
99
+ onChangeText: setValue,
100
+ autoFocus: true,
101
+ returnKeyType: "done",
102
+ onSubmitEditing: onSubmit,
103
+ testID: "bloom-surface-prompt-input"
104
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
105
+ style: {
106
+ gap: 8,
107
+ paddingTop: 16
108
+ },
109
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
110
+ variant: "primary",
111
+ onPress: onSubmit,
112
+ testID: "bloom-surface-prompt-confirm",
113
+ children: options.confirmLabel ?? 'OK'
114
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
115
+ variant: "secondary",
116
+ onPress: onCancel,
117
+ testID: "bloom-surface-prompt-cancel",
118
+ children: options.cancelLabel ?? 'Cancel'
119
+ })]
120
+ })]
121
+ });
122
+ }
123
+
124
+ /**
125
+ * Present a confirm surface stacked on top of anything currently open. Resolves
126
+ * `true` on confirm, `false` on cancel OR on backdrop/Escape/back dismissal.
127
+ */
128
+ function confirm(options) {
129
+ return (0, _surfaceStore.present)(surface => /*#__PURE__*/(0, _jsxRuntime.jsx)(ConfirmSurface, {
130
+ options: options,
131
+ surface: surface
132
+ }), {
133
+ placement: options.placement ?? 'center',
134
+ dismissOnBackdrop: options.dismissible ?? true,
135
+ label: options.title
136
+ }).then(result => result === true);
137
+ }
138
+
139
+ /**
140
+ * Present a prompt surface stacked on top of anything currently open. Resolves
141
+ * the entered string on submit, or `null` on cancel OR backdrop/Escape/back
142
+ * dismissal.
143
+ */
144
+ function prompt(options) {
145
+ return (0, _surfaceStore.present)(surface => /*#__PURE__*/(0, _jsxRuntime.jsx)(PromptSurface, {
146
+ options: options,
147
+ surface: surface
148
+ }), {
149
+ placement: options.placement ?? 'center',
150
+ dismissOnBackdrop: options.dismissible ?? true,
151
+ label: options.title
152
+ }).then(result => typeof result === 'string' ? result : null);
153
+ }
154
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_button","_index","_useTheme","_surfaceStore","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","TITLE_STYLE","fontSize","fontWeight","lineHeight","MESSAGE_STYLE","ConfirmSurface","options","surface","theme","useTheme","onConfirm","useCallback","dismiss","onCancel","jsxs","View","children","jsx","Text","style","color","colors","text","paddingBottom","message","title","textSecondary","gap","Button","variant","destructive","onPress","testID","confirmLabel","hideCancel","cancelLabel","PromptSurface","value","setValue","useState","defaultValue","onSubmit","TextFieldInput","label","inputLabel","placeholder","onChangeText","autoFocus","returnKeyType","onSubmitEditing","paddingTop","confirm","present","placement","dismissOnBackdrop","dismissible","then","result","prompt"],"sourceRoot":"../../../src","sources":["surfaces/prompts.tsx"],"mappings":";;;;;;;AAAA,IAAAA,MAAA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
4
+ value: true
5
+ });
6
+ exports.__resetSurfacesForTests = __resetSurfacesForTests;
7
+ exports.dismissAll = dismissAll;
8
+ exports.dismissToRoot = dismissToRoot;
9
+ exports.dismissTop = dismissTop;
10
+ exports.finalizeClose = finalizeClose;
11
+ exports.getSnapshot = getSnapshot;
12
+ exports.present = present;
13
+ exports.requestDismiss = requestDismiss;
14
+ exports.resetSurfaces = resetSurfaces;
15
+ exports.subscribe = subscribe;
16
+ /**
17
+ * The shared, content-agnostic SURFACE STACK.
18
+ *
19
+ * A module-singleton store (same pattern as `theme/ambient-store.ts` and
20
+ * `dialog/alert-store.ts`) holding an ordered stack of surfaces presented ON TOP
21
+ * of each other — bottom→top, the last entry is the top. One coordinated stack
22
+ * that the whole ecosystem (the SDK AND consumer apps) presents into, so
23
+ * overlays never clash: per-layer z, top-only interactivity, backdrop/Escape/
24
+ * back routed to the TOP surface, lower layers dimmed.
25
+ *
26
+ * It is CONTENT-AGNOSTIC: `present` takes a render function, not a route name.
27
+ * Bloom must never know about routes; the SDK layers its route registry on top.
28
+ *
29
+ * `getSnapshot` returns a STABLE reference while unchanged (the array identity
30
+ * only changes on a real mutation), so `useSyncExternalStore` — and the React
31
+ * Compiler — never see a silently-stale value.
32
+ */
33
+
34
+ let idCounter = 0;
35
+ function genId() {
36
+ idCounter += 1;
37
+ return `bloom-surface-${idCounter}`;
38
+ }
39
+
40
+ /** A single frozen "empty stack" snapshot returned by `getSnapshot` when idle. */
41
+ const EMPTY = Object.freeze([]);
42
+ let surfaces = EMPTY;
43
+ const listeners = new Set();
44
+ function emit() {
45
+ for (const listener of listeners) listener();
46
+ }
47
+
48
+ /** Subscribe to stack changes. Returns an unsubscribe fn. */
49
+ function subscribe(listener) {
50
+ listeners.add(listener);
51
+ return () => {
52
+ listeners.delete(listener);
53
+ };
54
+ }
55
+
56
+ /** Current stack snapshot (stable ref while unchanged). Bottom→top. */
57
+ function getSnapshot() {
58
+ return surfaces;
59
+ }
60
+
61
+ /**
62
+ * Present a new surface on TOP of the stack. Returns a promise that resolves
63
+ * with the value passed to `dismiss(result)` (or `undefined` when the surface is
64
+ * dismissed without a result / by a stack-wide clear).
65
+ */
66
+ function present(render, opts) {
67
+ return new Promise(resolve => {
68
+ const entry = {
69
+ id: genId(),
70
+ render,
71
+ presentation: opts ?? {},
72
+ status: 'open',
73
+ resolve: resolve,
74
+ settled: false,
75
+ generation: 0
76
+ };
77
+ surfaces = [...surfaces, entry];
78
+ emit();
79
+ });
80
+ }
81
+
82
+ /**
83
+ * Request dismissal of a surface. RESOLVES THE PROMISE IMMEDIATELY (the exit
84
+ * animation that follows is cosmetic) and flips the entry to `'closing'` so the
85
+ * host runs its exit animation. Resolution is resolve-once via the `settled`
86
+ * guard — a second request (or the host's post-exit `onClose`) never re-resolves
87
+ * with a different value. Bumps the entry `generation` so a completion callback
88
+ * from a superseded cycle is inert.
89
+ */
90
+ function requestDismiss(id, result) {
91
+ const entry = surfaces.find(e => e.id === id);
92
+ if (!entry) return;
93
+
94
+ // Resolve-once. The mapped replacement below carries `settled: true`, so a
95
+ // later `requestDismiss(id)` reads the settled entry and skips this branch —
96
+ // no in-place mutation of the live entry is needed.
97
+ if (!entry.settled) {
98
+ entry.resolve(result);
99
+ }
100
+ if (entry.status === 'closing') return;
101
+ surfaces = surfaces.map(e => e.id === id ? {
102
+ ...e,
103
+ settled: true,
104
+ status: 'closing',
105
+ generation: e.generation + 1
106
+ } : e);
107
+ emit();
108
+ }
109
+
110
+ /**
111
+ * Splice a surface out of the stack once its exit animation has settled. Called
112
+ * by the host from the `Dialog`'s post-exit `onClose`. Idempotent and gated on
113
+ * `'closing'` status: a stale/duplicate call — or one for an entry that is not
114
+ * actually closing — is a no-op, which (together with unique entry ids) is the
115
+ * stale-callback hygiene `BottomSheetBase`'s generation guard provides for its
116
+ * reused instance.
117
+ */
118
+ function finalizeClose(id) {
119
+ const entry = surfaces.find(e => e.id === id);
120
+ if (!entry || entry.status !== 'closing') return;
121
+ const next = surfaces.filter(e => e.id !== id);
122
+ surfaces = next.length === 0 ? EMPTY : next;
123
+ emit();
124
+ }
125
+
126
+ /** Dismiss the TOP surface, resolving its promise with `result`. */
127
+ function dismissTop(result) {
128
+ const top = surfaces[surfaces.length - 1];
129
+ if (top) requestDismiss(top.id, result);
130
+ }
131
+
132
+ /**
133
+ * Dismiss every surface ABOVE the bottom-most one, keeping the root surface
134
+ * open. Pending awaiters of the dismissed surfaces resolve with `undefined` so
135
+ * they never hang. No-op with 0 or 1 surfaces.
136
+ */
137
+ function dismissToRoot() {
138
+ if (surfaces.length <= 1) return;
139
+ const above = surfaces.slice(1).map(e => e.id);
140
+ for (const id of above) requestDismiss(id, undefined);
141
+ }
142
+
143
+ /**
144
+ * Dismiss the ENTIRE stack. Every pending awaiter resolves with `undefined` so
145
+ * none hang.
146
+ */
147
+ function dismissAll() {
148
+ const ids = surfaces.map(e => e.id);
149
+ for (const id of ids) requestDismiss(id, undefined);
150
+ }
151
+
152
+ /**
153
+ * Hard-reset the stack synchronously (no exit animation), resolving all pending
154
+ * awaiters with `undefined`. Used when the host provider unmounts so no
155
+ * `present()` promise is stranded.
156
+ */
157
+ function resetSurfaces() {
158
+ if (surfaces.length === 0) return;
159
+ const pending = surfaces;
160
+ surfaces = EMPTY;
161
+ for (const entry of pending) {
162
+ if (!entry.settled) entry.resolve(undefined);
163
+ }
164
+ emit();
165
+ }
166
+
167
+ /** Test-only: hard-reset without notifying (drops listeners' work). */
168
+ function __resetSurfacesForTests() {
169
+ surfaces = EMPTY;
170
+ idCounter = 0;
171
+ }
172
+ //# sourceMappingURL=surfaceStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["idCounter","genId","EMPTY","Object","freeze","surfaces","listeners","Set","emit","listener","subscribe","add","delete","getSnapshot","present","render","opts","Promise","resolve","entry","id","presentation","status","settled","generation","requestDismiss","result","find","e","map","finalizeClose","next","filter","length","dismissTop","top","dismissToRoot","above","slice","undefined","dismissAll","ids","resetSurfaces","pending","__resetSurfacesForTests"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ourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["surfaces/types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SurfaceContext = void 0;
7
+ exports.useSurface = useSurface;
8
+ var _react = require("react");
9
+ /**
10
+ * Context carrying the CURRENT surface's controls. The host wraps each presented
11
+ * surface's content in a provider bound to that entry's id, so a nested surface
12
+ * reads its OWN controls — `dismiss` targets this surface, `present` stacks a
13
+ * child above it.
14
+ */
15
+ const SurfaceContext = exports.SurfaceContext = /*#__PURE__*/(0, _react.createContext)(null);
16
+ SurfaceContext.displayName = 'BloomSurfaceContext';
17
+
18
+ /**
19
+ * Read the current surface's {@link SurfaceControls} from inside a presented
20
+ * surface. Equivalent to the `surface` argument the render function receives —
21
+ * use whichever is convenient (props vs. context).
22
+ *
23
+ * DEPTH only: `dismiss` (resolve this surface's promise + close) and `present`
24
+ * (stack a child). Navigation within a surface is the SDK's route layer, not
25
+ * this hook.
26
+ *
27
+ * @throws if called outside a presented surface.
28
+ */
29
+ function useSurface() {
30
+ const controls = (0, _react.useContext)(SurfaceContext);
31
+ if (!controls) {
32
+ throw new Error('useSurface must be called from within a presented surface (rendered by <SurfaceProvider>/<SurfaceHost>).');
33
+ }
34
+ return controls;
35
+ }
36
+ //# sourceMappingURL=useSurface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","SurfaceContext","exports","createContext","displayName","useSurface","controls","useContext","Error"],"sourceRoot":"../../../src","sources":["surfaces/useSurface.ts"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,gBAAG,IAAAE,oBAAa,EAAyB,IAAI,CAAC;AACzEF,cAAc,CAACG,WAAW,GAAG,qBAAqB;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,UAAUA,CAAA,EAAoB;EAC5C,MAAMC,QAAQ,GAAG,IAAAC,iBAAU,EAACN,cAAc,CAAC;EAC3C,IAAI,CAACK,QAAQ,EAAE;IACb,MAAM,IAAIE,KAAK,CACb,0GACF,CAAC;EACH;EACA,OAAOF,QAAQ;AACjB","ignoreList":[]}
@@ -10,6 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _reactNative = require("react-native");
11
11
  var _useControllableState = require("../hooks/useControllableState.js");
12
12
  var _FontLoader = require("../fonts/FontLoader");
13
+ var _ambientStore = require("./ambient-store.js");
13
14
  var _applyDarkClass = require("./apply-dark-class.js");
14
15
  var _buildTheme = require("./build-theme.js");
15
16
  var _buildThemeFromSeed = require("./build-theme-from-seed.js");
@@ -173,14 +174,32 @@ function BloomThemeProvider({
173
174
  }) {
174
175
  const rnScheme = (0, _reactNative.useColorScheme)();
175
176
 
177
+ // The app-wide ambient override, driven imperatively via `useAmbientTheme()`
178
+ // from anywhere in the app. Subscribed through the module-level store's
179
+ // `useSyncExternalStore` (stable snapshot ref while unchanged → React-Compiler
180
+ // safe). When an ambient seed is set it OVERRIDES the static `seed` prop and
181
+ // the active preset; clearing it restores them.
182
+ const ambient = (0, _ambientStore.useAmbientThemeState)();
183
+
184
+ // The EFFECTIVE dynamic seed + accents for this render: ambient wins over the
185
+ // static props. `null` ambient seed means "no override" → fall back to the
186
+ // `seed` prop (which itself may be undefined → preset path). When ambient is
187
+ // active, ambient accents replace the static accent props entirely (a null
188
+ // ambient accent = "no pin for this artwork colour").
189
+ const ambientActive = ambient.seed !== null;
190
+ const effectiveSeed = ambientActive ? ambient.seed ?? undefined : seed;
191
+ const effectiveSecondary = ambientActive ? ambient.secondary ?? undefined : secondaryColor;
192
+ const effectiveTertiary = ambientActive ? ambient.tertiary ?? undefined : tertiaryColor;
193
+
176
194
  // The app-wide pinned accents, if any. Memoized so its identity only changes
177
- // when a prop changes (keeps the effect/memo deps below stable). Left
195
+ // when an accent changes (keeps the effect/memo deps below stable). Left
178
196
  // `undefined` when neither is set so every downstream call is byte-identical
179
- // to the no-accent path.
180
- const explicitAccents = (0, _react.useMemo)(() => secondaryColor === undefined && tertiaryColor === undefined ? undefined : {
181
- secondaryHex: secondaryColor,
182
- tertiaryHex: tertiaryColor
183
- }, [secondaryColor, tertiaryColor]);
197
+ // to the no-accent path. Uses the EFFECTIVE accents so ambient accents apply
198
+ // to the preset path too when no ambient seed is present.
199
+ const explicitAccents = (0, _react.useMemo)(() => effectiveSecondary === undefined && effectiveTertiary === undefined ? undefined : {
200
+ secondaryHex: effectiveSecondary,
201
+ tertiaryHex: effectiveTertiary
202
+ }, [effectiveSecondary, effectiveTertiary]);
184
203
  const {
185
204
  mode,
186
205
  colorPreset,
@@ -211,16 +230,16 @@ function BloomThemeProvider({
211
230
  // (whole-app dynamic theming — `secondaryColor`/`tertiaryColor` pin this seed's
212
231
  // accents) when `seed` is set, else the named preset. Both go through the same
213
232
  // colour engine, so there is one code path — no seed/preset duplication.
214
- const themeVars = (0, _react.useMemo)(() => seed ? (0, _seedScope.buildSeedScopeVars)({
215
- seed,
233
+ const themeVars = (0, _react.useMemo)(() => effectiveSeed ? (0, _seedScope.buildSeedScopeVars)({
234
+ seed: effectiveSeed,
216
235
  mode: resolved,
217
- secondarySeed: secondaryColor,
218
- tertiarySeed: tertiaryColor
219
- }) : (0, _styleBuilder.buildScopeVars)(colorPreset, resolved, explicitAccents), [seed, secondaryColor, tertiaryColor, colorPreset, resolved, explicitAccents]);
220
- const themeColors = (0, _react.useMemo)(() => seed ? (0, _buildThemeFromSeed.buildThemeFromSeed)(seed, resolved, undefined, undefined, {
221
- secondarySeed: secondaryColor,
222
- tertiarySeed: tertiaryColor
223
- }) : (0, _buildTheme.buildTheme)(colorPreset, resolved, isAdaptive, explicitAccents), [seed, secondaryColor, tertiaryColor, colorPreset, resolved, isAdaptive, explicitAccents]);
236
+ secondarySeed: effectiveSecondary,
237
+ tertiarySeed: effectiveTertiary
238
+ }) : (0, _styleBuilder.buildScopeVars)(colorPreset, resolved, explicitAccents), [effectiveSeed, effectiveSecondary, effectiveTertiary, colorPreset, resolved, explicitAccents]);
239
+ const themeColors = (0, _react.useMemo)(() => effectiveSeed ? (0, _buildThemeFromSeed.buildThemeFromSeed)(effectiveSeed, resolved, undefined, undefined, {
240
+ secondarySeed: effectiveSecondary,
241
+ tertiarySeed: effectiveTertiary
242
+ }) : (0, _buildTheme.buildTheme)(colorPreset, resolved, isAdaptive, explicitAccents), [effectiveSeed, effectiveSecondary, effectiveTertiary, colorPreset, resolved, isAdaptive, explicitAccents]);
224
243
  (0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(() => {
225
244
  (0, _setColorSchemeSafe.setColorSchemeSafe)(effectiveMode);
226
245
  (0, _applyDarkClass.applyDarkClass)(resolved);