@oxyhq/bloom 0.3.12 → 0.5.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.
- package/README.md +133 -90
- package/lib/commonjs/bottom-sheet/index.js +341 -98
- package/lib/commonjs/bottom-sheet/index.js.map +1 -1
- 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/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 +341 -98
- package/lib/module/bottom-sheet/index.js.map +1 -1
- 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/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/__tests__/Dialog.test.d.ts +2 -0
- package/lib/typescript/commonjs/__tests__/Dialog.test.d.ts.map +1 -0
- package/lib/typescript/commonjs/bottom-sheet/index.d.ts +47 -1
- package/lib/typescript/commonjs/bottom-sheet/index.d.ts.map +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/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/__tests__/Dialog.test.d.ts +2 -0
- package/lib/typescript/module/__tests__/Dialog.test.d.ts.map +1 -0
- package/lib/typescript/module/bottom-sheet/index.d.ts +47 -1
- package/lib/typescript/module/bottom-sheet/index.d.ts.map +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/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 +3 -14
- package/src/__tests__/BottomSheet.test.tsx +149 -2
- package/src/__tests__/Dialog.test.tsx +177 -0
- package/src/bottom-sheet/index.tsx +367 -83
- 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.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/index.ts +17 -3
- package/src/index.web.ts +17 -3
- package/src/menu/index.tsx +13 -17
- package/src/select/index.tsx +30 -30
- package/src/toast/index.tsx +55 -11
- package/src/toast/index.web.tsx +33 -13
- 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/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/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/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
|
@@ -15,17 +15,19 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
15
15
|
var _reactNative = require("react-native");
|
|
16
16
|
var _useTheme = require("../theme/use-theme.js");
|
|
17
17
|
var _index = require("../typography/index.js");
|
|
18
|
-
var
|
|
18
|
+
var _context = require("../dialog/context.js");
|
|
19
|
+
var _SheetShell = require("../dialog/SheetShell.js");
|
|
19
20
|
var _useInteractionState = require("../hooks/useInteractionState.js");
|
|
20
|
-
var
|
|
21
|
+
var _context2 = require("./context.js");
|
|
21
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
23
|
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); }
|
|
23
24
|
/**
|
|
24
25
|
* ContextMenu — Native implementation
|
|
25
26
|
*
|
|
26
|
-
* Opens a bottom-sheet menu
|
|
27
|
-
*
|
|
28
|
-
*
|
|
27
|
+
* Opens a bottom-sheet menu when the user long-presses the trigger. The
|
|
28
|
+
* menu body uses bloom's internal `SheetShell` (a `BottomSheet`
|
|
29
|
+
* presentation primitive with the same drag-handle + close-on-tap
|
|
30
|
+
* semantics shared by `Menu` and `Select`).
|
|
29
31
|
*/
|
|
30
32
|
|
|
31
33
|
// ---------------------------------------------------------------------------
|
|
@@ -49,7 +51,7 @@ function useNativeContextMenuContext() {
|
|
|
49
51
|
function Root({
|
|
50
52
|
children
|
|
51
53
|
}) {
|
|
52
|
-
const control =
|
|
54
|
+
const control = (0, _context.useDialogControl)();
|
|
53
55
|
const ctx = (0, _react.useMemo)(() => ({
|
|
54
56
|
isOpen: false,
|
|
55
57
|
open: () => control.open(),
|
|
@@ -112,24 +114,21 @@ function Outer({
|
|
|
112
114
|
const {
|
|
113
115
|
control
|
|
114
116
|
} = useNativeContextMenuContext();
|
|
115
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
117
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SheetShell.SheetShell, {
|
|
116
118
|
control: control,
|
|
117
|
-
|
|
118
|
-
children:
|
|
119
|
+
label: "Context menu",
|
|
120
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeContextMenuContext.Provider, {
|
|
119
121
|
value: {
|
|
120
122
|
isOpen: true,
|
|
121
123
|
open: () => control.open(),
|
|
122
124
|
close: () => control.close(),
|
|
123
125
|
control
|
|
124
126
|
},
|
|
125
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
126
|
-
|
|
127
|
-
children:
|
|
128
|
-
style: [styles.outerContent, style],
|
|
129
|
-
children: children
|
|
130
|
-
})
|
|
127
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
128
|
+
style: [styles.outerContent, style],
|
|
129
|
+
children: children
|
|
131
130
|
})
|
|
132
|
-
})
|
|
131
|
+
})
|
|
133
132
|
});
|
|
134
133
|
}
|
|
135
134
|
|
|
@@ -184,7 +183,7 @@ function Item({
|
|
|
184
183
|
}, isHighlighted && {
|
|
185
184
|
backgroundColor: theme.colors.backgroundSecondary
|
|
186
185
|
}, style],
|
|
187
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
186
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_context2.ItemCtx.Provider, {
|
|
188
187
|
value: itemCtx,
|
|
189
188
|
children: children
|
|
190
189
|
})
|
|
@@ -202,7 +201,7 @@ function ItemText({
|
|
|
202
201
|
const theme = (0, _useTheme.useTheme)();
|
|
203
202
|
const {
|
|
204
203
|
disabled
|
|
205
|
-
} = (0,
|
|
204
|
+
} = (0, _context2.useItemContext)();
|
|
206
205
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Text, {
|
|
207
206
|
numberOfLines: 2,
|
|
208
207
|
ellipsizeMode: "middle",
|
|
@@ -223,7 +222,7 @@ function ItemIcon({
|
|
|
223
222
|
const theme = (0, _useTheme.useTheme)();
|
|
224
223
|
const {
|
|
225
224
|
disabled
|
|
226
|
-
} = (0,
|
|
225
|
+
} = (0, _context2.useItemContext)();
|
|
227
226
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, {
|
|
228
227
|
size: "lg",
|
|
229
228
|
fill: disabled ? theme.colors.textTertiary : theme.colors.textSecondary
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_useTheme","_index","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_useTheme","_index","_context","_SheetShell","_useInteractionState","_context2","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NativeContextMenuContext","createContext","displayName","useNativeContextMenuContext","ctx","useContext","Error","Root","children","control","useDialogControl","useMemo","isOpen","open","close","jsx","Provider","value","Trigger","label","hint","style","state","focused","onIn","onFocus","onOut","onBlur","useInteractionState","View","hovered","pressed","props","onPress","onLongPress","accessibilityLabel","accessibilityHint","Outer","SheetShell","styles","outerContent","Item","disabled","theme","useTheme","onPressIn","onPressOut","isHighlighted","handlePress","useCallback","itemCtx","Pressable","accessibilityState","item","backgroundColor","colors","contrast50","borderColor","borderLight","backgroundSecondary","ItemCtx","ItemText","useItemContext","Text","numberOfLines","ellipsizeMode","itemText","color","textTertiary","text","ItemIcon","icon","Comp","size","fill","textSecondary","Group","Divider","divider","borderTopColor","StyleSheet","create","gap","flexDirection","alignItems","paddingHorizontal","borderRadius","overflow","borderWidth","minHeight","paddingVertical","flex","fontSize","fontWeight","borderTopWidth","hairlineWidth","marginVertical"],"sourceRoot":"../../../src","sources":["context-menu/index.tsx"],"mappings":";;;;;;;;;;;;;AAQA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAMA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAEA,IAAAM,oBAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAAoD,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAD,wBAAAU,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAU,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,C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IAAI,EAAE;IACJ8B,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBF,GAAG,EAAE,CAAC;IACNG,iBAAiB,EAAE,EAAE;IACrBC,YAAY,EAAE,CAAC;IACfC,QAAQ,EAAE,QAAQ;IAClBC,WAAW,EAAE,CAAC;IACdC,SAAS,EAAE,EAAE;IACbC,eAAe,EAAE;EACnB,CAAC;EACDxB,QAAQ,EAAE;IACRyB,IAAI,EAAE,CAAC;IACPC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACDf,OAAO,EAAE;IACPgB,cAAc,EAAEd,uBAAU,CAACe,aAAa;IACxCC,cAAc,EAAE;EAClB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BloomDialogProvider = BloomDialogProvider;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _Dialog = require("./Dialog");
|
|
9
|
+
var _alertStore = require("./alert-store.js");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
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); }
|
|
12
|
+
/**
|
|
13
|
+
* Mounts the imperative `alert()` host inside your app.
|
|
14
|
+
*
|
|
15
|
+
* Wrap your app root once (after `BloomThemeProvider`, so the dialog's
|
|
16
|
+
* colours come from the active theme) and you can call `alert()` from
|
|
17
|
+
* anywhere — including from code that runs before the provider mounts
|
|
18
|
+
* (alerts are queued and drained on subscribe).
|
|
19
|
+
*
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import { BloomDialogProvider } from '@oxyhq/bloom';
|
|
22
|
+
*
|
|
23
|
+
* <BloomThemeProvider mode="system" colorPreset="oxy">
|
|
24
|
+
* <BloomDialogProvider>
|
|
25
|
+
* <App />
|
|
26
|
+
* </BloomDialogProvider>
|
|
27
|
+
* </BloomThemeProvider>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* Alerts are presented one at a time. While one is on screen, subsequent
|
|
31
|
+
* `alert()` calls enqueue and present in FIFO order once their predecessor
|
|
32
|
+
* has finished closing.
|
|
33
|
+
*/
|
|
34
|
+
function BloomDialogProvider({
|
|
35
|
+
children
|
|
36
|
+
}) {
|
|
37
|
+
const [queue, setQueue] = (0, _react.useState)([]);
|
|
38
|
+
(0, _react.useEffect)(() => (0, _alertStore.subscribeAlerts)(setQueue), []);
|
|
39
|
+
|
|
40
|
+
// Only the head of the queue is presented; this keeps the bottom-sheet
|
|
41
|
+
// exit/enter animations clean and matches the platform `Alert.alert`
|
|
42
|
+
// behaviour our consumers expect.
|
|
43
|
+
const head = queue[0];
|
|
44
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
45
|
+
children: [children, head ? /*#__PURE__*/(0, _jsxRuntime.jsx)(AlertHost, {
|
|
46
|
+
entry: head
|
|
47
|
+
}, head.id) : null]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function AlertHost({
|
|
51
|
+
entry
|
|
52
|
+
}) {
|
|
53
|
+
const actions = entry.buttons.map(_alertStore.buttonToAction);
|
|
54
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Dialog.AutoMountedDialog, {
|
|
55
|
+
title: entry.title,
|
|
56
|
+
description: entry.message,
|
|
57
|
+
actions: actions,
|
|
58
|
+
onResolve: () => (0, _alertStore.dismissAlert)(entry.id)
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=BloomDialogProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_Dialog","_alertStore","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","BloomDialogProvider","children","queue","setQueue","useState","useEffect","subscribeAlerts","head","jsxs","Fragment","jsx","AlertHost","entry","id","actions","buttons","map","buttonToAction","AutoMountedDialog","title","description","message","onResolve","dismissAlert"],"sourceRoot":"../../../src","sources":["dialog/BloomDialogProvider.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKuB,IAAAG,WAAA,GAAAH,OAAA;AAAA,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,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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P,KAAK,CAACO,KAAM;IACnBC,WAAW,EAAER,KAAK,CAACS,OAAQ;IAC3BP,OAAO,EAAEA,OAAQ;IACjBQ,SAAS,EAAEA,CAAA,KAAM,IAAAC,wBAAY,EAACX,KAAK,CAACC,EAAE;EAAE,CACzC,CAAC;AAEN","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BloomDialogProvider = BloomDialogProvider;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _DialogWeb = require("./Dialog.web.js");
|
|
9
|
+
var _alertStore = require("./alert-store.js");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
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); }
|
|
12
|
+
/**
|
|
13
|
+
* Web variant of `BloomDialogProvider`. Identical surface area to the
|
|
14
|
+
* native version — it just uses the web-fork `Dialog` (`Dialog.web.tsx`)
|
|
15
|
+
* underneath instead of the bottom-sheet variant.
|
|
16
|
+
*
|
|
17
|
+
* See the native file (`./BloomDialogProvider.tsx`) for the full design
|
|
18
|
+
* notes; this fork exists purely so the bundler's `browser` condition can
|
|
19
|
+
* resolve to a `Dialog` that doesn't pull in the native gesture-handler /
|
|
20
|
+
* reanimated stack.
|
|
21
|
+
*/
|
|
22
|
+
function BloomDialogProvider({
|
|
23
|
+
children
|
|
24
|
+
}) {
|
|
25
|
+
const [queue, setQueue] = (0, _react.useState)([]);
|
|
26
|
+
(0, _react.useEffect)(() => (0, _alertStore.subscribeAlerts)(setQueue), []);
|
|
27
|
+
const head = queue[0];
|
|
28
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
29
|
+
children: [children, head ? /*#__PURE__*/(0, _jsxRuntime.jsx)(AlertHost, {
|
|
30
|
+
entry: head
|
|
31
|
+
}, head.id) : null]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function AlertHost({
|
|
35
|
+
entry
|
|
36
|
+
}) {
|
|
37
|
+
const actions = entry.buttons.map(_alertStore.buttonToAction);
|
|
38
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DialogWeb.AutoMountedDialog, {
|
|
39
|
+
title: entry.title,
|
|
40
|
+
description: entry.message,
|
|
41
|
+
actions: actions,
|
|
42
|
+
onResolve: () => (0, _alertStore.dismissAlert)(entry.id)
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=BloomDialogProvider.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_DialogWeb","_alertStore","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","BloomDialogProvider","children","queue","setQueue","useState","useEffect","subscribeAlerts","head","jsxs","Fragment","jsx","AlertHost","entry","id","actions","buttons","map","buttonToAction","AutoMountedDialog","title","description","message","onResolve","dismissAlert"],"sourceRoot":"../../../src","sources":["dialog/BloomDialogProvider.web.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKuB,IAAAG,WAAA,GAAAH,OAAA;AA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AMI,IAAI,GAAGL,KAAK,CAAC,CAAC,CAAC;EAErB,oBACE,IAAAtB,WAAA,CAAA4B,IAAA,EAAA5B,WAAA,CAAA6B,QAAA;IAAAR,QAAA,GACGA,QAAQ,EACRM,IAAI,gBAAG,IAAA3B,WAAA,CAAA8B,GAAA,EAACC,SAAS;MAAeC,KAAK,EAAEL;IAAK,GAArBA,IAAI,CAACM,EAAkB,CAAC,GAAG,IAAI;EAAA,CACvD,CAAC;AAEP;AAEA,SAASF,SAASA,CAAC;EAAEC;AAA6B,CAAC,EAAE;EACnD,MAAME,OAAO,GAAGF,KAAK,CAACG,OAAO,CAACC,GAAG,CAACC,0BAAc,CAAC;EACjD,oBACE,IAAArC,WAAA,CAAA8B,GAAA,EAAChC,UAAA,CAAAwC,iBAAiB;IAChBC,KAAK,EAAEP,KAAK,CAACO,KAAM;IACnBC,WAAW,EAAER,KAAK,CAACS,OAAQ;IAC3BP,OAAO,EAAEA,OAAQ;IACjBQ,SAAS,EAAEA,CAAA,KAAM,IAAAC,wBAAY,EAACX,KAAK,CAACC,EAAE;EAAE,CACzC,CAAC;AAEN","ignoreList":[]}
|
|
@@ -3,24 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.Handle = Handle;
|
|
9
|
-
exports.Inner = Inner;
|
|
10
|
-
exports.Outer = Outer;
|
|
11
|
-
exports.ScrollableInner = ScrollableInner;
|
|
12
|
-
Object.defineProperty(exports, "useDialogContext", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _context.useDialogContext;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "useDialogControl", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _context.useDialogControl;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
6
|
+
exports.AutoMountedDialog = AutoMountedDialog;
|
|
7
|
+
exports.Dialog = Dialog;
|
|
24
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
25
9
|
var _reactNative = require("react-native");
|
|
26
10
|
var _index = require("../bottom-sheet/index.js");
|
|
@@ -28,24 +12,60 @@ var _useTheme = require("../theme/use-theme.js");
|
|
|
28
12
|
var _context = require("./context.js");
|
|
29
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
30
14
|
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); }
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Native variant of `<Dialog>`.
|
|
17
|
+
*
|
|
18
|
+
* Uses bloom's own `BottomSheet` in `detached` mode as the underlying
|
|
19
|
+
* surface — a floating, dynamically-sized, content-hugging card that
|
|
20
|
+
* gracefully degrades from sheet (phone) to centered card (tablet, via the
|
|
21
|
+
* 500px max-width cap).
|
|
22
|
+
*
|
|
23
|
+
* The component accepts three rendering modes simultaneously:
|
|
24
|
+
*
|
|
25
|
+
* 1. Declarative — `title`, `description`, `actions`. Bloom renders a
|
|
26
|
+
* standard confirm/destructive/cancel layout.
|
|
27
|
+
* 2. Custom children — caller passes JSX, bloom renders the chrome (title
|
|
28
|
+
* + close behaviour) and the children fill the body.
|
|
29
|
+
* 3. Pure children — no `title`/`description`/`actions`; caller owns
|
|
30
|
+
* every pixel.
|
|
31
|
+
*
|
|
32
|
+
* All three share the same dismissal semantics: tapping the backdrop, the
|
|
33
|
+
* drag handle, swiping down, or `control.close()` runs the queued close
|
|
34
|
+
* callbacks once the sheet's exit animation has settled.
|
|
35
|
+
*/
|
|
36
|
+
function Dialog({
|
|
33
37
|
control,
|
|
34
38
|
onClose,
|
|
35
|
-
testID
|
|
39
|
+
testID,
|
|
40
|
+
title,
|
|
41
|
+
description,
|
|
42
|
+
actions,
|
|
43
|
+
style,
|
|
44
|
+
label,
|
|
45
|
+
children
|
|
36
46
|
}) {
|
|
37
47
|
const theme = (0, _useTheme.useTheme)();
|
|
38
48
|
const ref = (0, _react.useRef)(null);
|
|
39
49
|
const closeCallbacks = (0, _react.useRef)([]);
|
|
50
|
+
const titleId = (0, _react.useId)();
|
|
51
|
+
const descriptionId = (0, _react.useId)();
|
|
52
|
+
|
|
53
|
+
// Drain queued close callbacks atomically — capturing the list and
|
|
54
|
+
// resetting it before invocation ensures a callback that synchronously
|
|
55
|
+
// re-opens the dialog (and queues fresh callbacks) does not see the old
|
|
56
|
+
// ones replayed against the new session.
|
|
40
57
|
const callQueuedCallbacks = (0, _react.useCallback)(() => {
|
|
41
|
-
|
|
58
|
+
const queued = closeCallbacks.current;
|
|
59
|
+
closeCallbacks.current = [];
|
|
60
|
+
for (const cb of queued) {
|
|
42
61
|
try {
|
|
43
62
|
cb();
|
|
44
63
|
} catch (e) {
|
|
45
|
-
|
|
64
|
+
if (typeof console !== 'undefined' && console.error) {
|
|
65
|
+
console.error('Dialog close callback error:', e);
|
|
66
|
+
}
|
|
46
67
|
}
|
|
47
68
|
}
|
|
48
|
-
closeCallbacks.current = [];
|
|
49
69
|
}, []);
|
|
50
70
|
const open = (0, _react.useCallback)(() => {
|
|
51
71
|
ref.current?.present();
|
|
@@ -56,11 +76,6 @@ function Outer({
|
|
|
56
76
|
}
|
|
57
77
|
ref.current?.dismiss();
|
|
58
78
|
}, []);
|
|
59
|
-
|
|
60
|
-
// onDismiss fires after the BottomSheet's close animation finishes — this is
|
|
61
|
-
// the integration point for the closeCallbacks queue. Consumers (e.g.
|
|
62
|
-
// Prompt.Action) rely on the queued callback running AFTER the sheet has
|
|
63
|
-
// visually closed so the screen transition feels natural.
|
|
64
79
|
const handleDismiss = (0, _react.useCallback)(() => {
|
|
65
80
|
callQueuedCallbacks();
|
|
66
81
|
onClose?.();
|
|
@@ -76,9 +91,9 @@ function Outer({
|
|
|
76
91
|
const sheetStyle = (0, _react.useMemo)(() => ({
|
|
77
92
|
maxWidth: 500,
|
|
78
93
|
backgroundColor: theme.colors.background,
|
|
79
|
-
// All four corners rounded —
|
|
80
|
-
//
|
|
81
|
-
//
|
|
94
|
+
// All four corners rounded — bloom's BottomSheet defaults to top-only
|
|
95
|
+
// radius in flush mode, but we use `detached` so the whole card is
|
|
96
|
+
// floating and rounded uniformly.
|
|
82
97
|
borderRadius: 20
|
|
83
98
|
}), [theme.colors.background]);
|
|
84
99
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.BottomSheet, {
|
|
@@ -86,95 +101,177 @@ function Outer({
|
|
|
86
101
|
onDismiss: handleDismiss,
|
|
87
102
|
enablePanDownToClose: true,
|
|
88
103
|
detached: true
|
|
89
|
-
// Stronger dim
|
|
90
|
-
//
|
|
104
|
+
// Stronger dim when a Dialog is stacked over another sheet so the
|
|
105
|
+
// underlying sheet's handle/content doesn't bleed through.
|
|
91
106
|
,
|
|
92
107
|
backdropOpacity: 0.7,
|
|
93
108
|
style: sheetStyle,
|
|
94
109
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.Context.Provider, {
|
|
95
110
|
value: context,
|
|
96
|
-
children: /*#__PURE__*/(0, _jsxRuntime.
|
|
111
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
97
112
|
testID: testID,
|
|
98
|
-
|
|
113
|
+
accessibilityLabel: label,
|
|
114
|
+
"aria-labelledby": title ? titleId : undefined,
|
|
115
|
+
"aria-describedby": description ? descriptionId : undefined,
|
|
116
|
+
style: [
|
|
117
|
+
// Detached BottomSheet already adds `marginBottom: insets.bottom + 16`
|
|
118
|
+
// to the sheet container — the floating card sits ABOVE the
|
|
119
|
+
// system gesture bar, so we don't add `insets.bottom` here.
|
|
120
|
+
{
|
|
121
|
+
paddingTop: 20,
|
|
122
|
+
paddingHorizontal: 20,
|
|
123
|
+
paddingBottom: 20
|
|
124
|
+
}, {
|
|
99
125
|
backgroundColor: theme.colors.background
|
|
100
|
-
},
|
|
101
|
-
children:
|
|
126
|
+
}, style],
|
|
127
|
+
children: [title ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
128
|
+
nativeID: titleId,
|
|
129
|
+
style: {
|
|
130
|
+
fontSize: 22,
|
|
131
|
+
fontWeight: '600',
|
|
132
|
+
color: theme.colors.text,
|
|
133
|
+
paddingBottom: description ? 4 : 16,
|
|
134
|
+
lineHeight: 30
|
|
135
|
+
},
|
|
136
|
+
children: title
|
|
137
|
+
}) : null, description ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
138
|
+
nativeID: descriptionId,
|
|
139
|
+
style: {
|
|
140
|
+
fontSize: 16,
|
|
141
|
+
color: theme.colors.textSecondary,
|
|
142
|
+
paddingBottom: 16,
|
|
143
|
+
lineHeight: 22
|
|
144
|
+
},
|
|
145
|
+
children: description
|
|
146
|
+
}) : null, children, actions && actions.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionRow, {
|
|
147
|
+
actions: actions
|
|
148
|
+
}) : null]
|
|
102
149
|
})
|
|
103
150
|
})
|
|
104
151
|
});
|
|
105
152
|
}
|
|
106
|
-
function
|
|
107
|
-
|
|
108
|
-
style,
|
|
109
|
-
header,
|
|
110
|
-
contentContainerStyle
|
|
153
|
+
function ActionRow({
|
|
154
|
+
actions
|
|
111
155
|
}) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
paddingBottom: 20
|
|
122
|
-
}, contentContainerStyle, style],
|
|
123
|
-
children: children
|
|
124
|
-
})]
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
function ScrollableInner(props) {
|
|
128
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Inner, {
|
|
129
|
-
...props
|
|
156
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
157
|
+
style: {
|
|
158
|
+
width: '100%',
|
|
159
|
+
gap: 8,
|
|
160
|
+
justifyContent: 'flex-end'
|
|
161
|
+
},
|
|
162
|
+
children: actions.map((action, idx) => /*#__PURE__*/(0, _jsxRuntime.jsx)(ActionButton, {
|
|
163
|
+
action: action
|
|
164
|
+
}, `${action.label}-${idx}`))
|
|
130
165
|
});
|
|
131
166
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
width: '100%',
|
|
136
|
-
alignItems: 'center',
|
|
137
|
-
zIndex: 10,
|
|
138
|
-
height: 20
|
|
139
|
-
},
|
|
140
|
-
bar: {
|
|
141
|
-
top: 8,
|
|
142
|
-
width: 35,
|
|
143
|
-
height: 5,
|
|
144
|
-
borderRadius: 3,
|
|
145
|
-
alignSelf: 'center',
|
|
146
|
-
opacity: 0.5
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
function Handle() {
|
|
150
|
-
const theme = (0, _useTheme.useTheme)();
|
|
167
|
+
function ActionButton({
|
|
168
|
+
action
|
|
169
|
+
}) {
|
|
151
170
|
const {
|
|
152
171
|
close
|
|
153
172
|
} = (0, _context.useDialogContext)();
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
173
|
+
const theme = (0, _useTheme.useTheme)();
|
|
174
|
+
const color = action.color ?? 'default';
|
|
175
|
+
const shouldCloseOnPress = action.shouldCloseOnPress ?? true;
|
|
176
|
+
const {
|
|
177
|
+
background,
|
|
178
|
+
foreground
|
|
179
|
+
} = getActionPalette(color, theme.colors);
|
|
180
|
+
const handlePress = (0, _react.useCallback)(e => {
|
|
181
|
+
const onPress = action.onPress;
|
|
182
|
+
if (color === 'cancel') {
|
|
183
|
+
// Cancel always dismisses; consumer's onPress (rare) runs after.
|
|
184
|
+
close(onPress ? () => onPress(e) : undefined);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (shouldCloseOnPress) {
|
|
188
|
+
close(onPress ? () => onPress(e) : undefined);
|
|
189
|
+
} else {
|
|
190
|
+
onPress?.(e);
|
|
191
|
+
}
|
|
192
|
+
}, [action.onPress, close, color, shouldCloseOnPress]);
|
|
193
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
194
|
+
style: {
|
|
195
|
+
borderRadius: 9999,
|
|
196
|
+
alignItems: 'center',
|
|
197
|
+
justifyContent: 'center',
|
|
198
|
+
backgroundColor: background,
|
|
199
|
+
opacity: action.disabled ? 0.5 : 1,
|
|
200
|
+
paddingVertical: 12,
|
|
201
|
+
paddingHorizontal: 24
|
|
202
|
+
},
|
|
203
|
+
onPress: handlePress,
|
|
204
|
+
disabled: action.disabled,
|
|
205
|
+
activeOpacity: 0.7,
|
|
206
|
+
testID: action.testID,
|
|
207
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
208
|
+
style: {
|
|
209
|
+
fontSize: 16,
|
|
210
|
+
fontWeight: '500',
|
|
211
|
+
color: foreground
|
|
165
212
|
},
|
|
166
|
-
children:
|
|
167
|
-
style: [handleStyles.bar, {
|
|
168
|
-
backgroundColor: theme.colors.text
|
|
169
|
-
}]
|
|
170
|
-
})
|
|
213
|
+
children: action.label
|
|
171
214
|
})
|
|
172
215
|
});
|
|
173
216
|
}
|
|
174
|
-
function
|
|
175
|
-
|
|
217
|
+
function getActionPalette(color, colors) {
|
|
218
|
+
switch (color) {
|
|
219
|
+
case 'destructive':
|
|
220
|
+
return {
|
|
221
|
+
background: colors.negative,
|
|
222
|
+
foreground: colors.negativeForeground
|
|
223
|
+
};
|
|
224
|
+
case 'cancel':
|
|
225
|
+
return {
|
|
226
|
+
background: colors.contrast50,
|
|
227
|
+
foreground: colors.text
|
|
228
|
+
};
|
|
229
|
+
case 'default':
|
|
230
|
+
return {
|
|
231
|
+
background: colors.primary,
|
|
232
|
+
foreground: '#FFFFFF'
|
|
233
|
+
};
|
|
234
|
+
/* c8 ignore next 2 -- TS exhaustiveness check guards this branch */
|
|
235
|
+
default:
|
|
236
|
+
{
|
|
237
|
+
const _exhaustive = color;
|
|
238
|
+
return {
|
|
239
|
+
background: colors.primary,
|
|
240
|
+
foreground: '#FFFFFF'
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
}
|
|
176
244
|
}
|
|
177
|
-
|
|
178
|
-
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Helper used by the imperative `alert()` API. Mounts a `<Dialog>` against
|
|
248
|
+
* a fresh control and presents it immediately. `onResolve` is invoked
|
|
249
|
+
* exactly once when the dialog finishes closing (regardless of how the
|
|
250
|
+
* dismissal happened).
|
|
251
|
+
*
|
|
252
|
+
* Kept private to the dialog module — `alert()` is the public surface.
|
|
253
|
+
*/
|
|
254
|
+
function AutoMountedDialog({
|
|
255
|
+
title,
|
|
256
|
+
description,
|
|
257
|
+
actions,
|
|
258
|
+
onResolve
|
|
259
|
+
}) {
|
|
260
|
+
const control = (0, _context.useDialogControl)();
|
|
261
|
+
|
|
262
|
+
// `control` is referentially stable for the lifetime of the component
|
|
263
|
+
// (memoised by `useDialogControl` on `[id]`), so this effect runs exactly
|
|
264
|
+
// once per mount — present-on-mount semantics for an `alert()` call
|
|
265
|
+
// without re-presenting on subsequent renders.
|
|
266
|
+
(0, _react.useEffect)(() => {
|
|
267
|
+
control.open();
|
|
268
|
+
}, [control]);
|
|
269
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Dialog, {
|
|
270
|
+
control: control,
|
|
271
|
+
title: title,
|
|
272
|
+
description: description,
|
|
273
|
+
actions: actions,
|
|
274
|
+
onClose: onResolve
|
|
275
|
+
});
|
|
179
276
|
}
|
|
180
277
|
//# sourceMappingURL=Dialog.js.map
|