react-native-unified-action-sheet 0.1.0 → 0.2.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/CHANGELOG.md +41 -1
- package/README.md +42 -21
- package/android/src/main/java/com/unifiedactionsheet/PromptOptions.kt +132 -0
- package/android/src/main/java/com/unifiedactionsheet/SheetContentBuilder.kt +31 -0
- package/android/src/main/java/com/unifiedactionsheet/SheetPresenters.kt +54 -0
- package/android/src/main/java/com/unifiedactionsheet/UnifiedActionSheetModule.kt +55 -0
- package/ios/UnifiedActionSheet.mm +47 -0
- package/ios/UnifiedActionSheetImpl.swift +101 -4
- package/jest/index.d.ts +15 -1
- package/jest/index.js +28 -0
- package/lib/commonjs/NativeUnifiedActionSheet.js.map +1 -1
- package/lib/commonjs/action-sheet-options.interface.js +4 -0
- package/lib/commonjs/common-options.interface.js +2 -0
- package/lib/commonjs/common-options.interface.js.map +1 -0
- package/lib/commonjs/index.js +39 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/prompt-options.interface.js +6 -0
- package/lib/commonjs/prompt-options.interface.js.map +1 -0
- package/lib/module/NativeUnifiedActionSheet.js.map +1 -1
- package/lib/module/action-sheet-options.interface.js +2 -0
- package/lib/module/common-options.interface.js +2 -0
- package/lib/module/common-options.interface.js.map +1 -0
- package/lib/module/index.js +37 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/prompt-options.interface.js +4 -0
- package/lib/module/prompt-options.interface.js.map +1 -0
- package/lib/typescript/commonjs/src/NativeUnifiedActionSheet.d.ts +20 -0
- package/lib/typescript/commonjs/src/NativeUnifiedActionSheet.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/action-sheet-options.interface.d.ts +4 -13
- package/lib/typescript/commonjs/src/action-sheet-options.interface.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/common-options.interface.d.ts +17 -0
- package/lib/typescript/commonjs/src/common-options.interface.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +4 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/prompt-options.interface.d.ts +19 -0
- package/lib/typescript/commonjs/src/prompt-options.interface.d.ts.map +1 -0
- package/lib/typescript/module/src/NativeUnifiedActionSheet.d.ts +20 -0
- package/lib/typescript/module/src/NativeUnifiedActionSheet.d.ts.map +1 -1
- package/lib/typescript/module/src/action-sheet-options.interface.d.ts +4 -13
- package/lib/typescript/module/src/action-sheet-options.interface.d.ts.map +1 -1
- package/lib/typescript/module/src/common-options.interface.d.ts +17 -0
- package/lib/typescript/module/src/common-options.interface.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +4 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/prompt-options.interface.d.ts +19 -0
- package/lib/typescript/module/src/prompt-options.interface.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/NativeUnifiedActionSheet.ts +17 -0
- package/src/action-sheet-options.interface.ts +9 -19
- package/src/common-options.interface.ts +18 -0
- package/src/index.tsx +65 -3
- package/src/prompt-options.interface.ts +27 -0
|
@@ -45,7 +45,7 @@ public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDe
|
|
|
45
45
|
let presentation = Presentation(
|
|
46
46
|
controller: alert,
|
|
47
47
|
cancelButtonIndex: cancelButtonIndex,
|
|
48
|
-
completion: completion
|
|
48
|
+
completion: { index, _ in completion(index) }
|
|
49
49
|
)
|
|
50
50
|
|
|
51
51
|
for (index, label) in labels.enumerated() {
|
|
@@ -111,6 +111,86 @@ public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDe
|
|
|
111
111
|
parent.present(alert, animated: true)
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/// React Native's Alert.prompt is iOS-only; this is the shared half of the
|
|
115
|
+
/// unified prompt. Always .alert -- UIKit has no text field in an action
|
|
116
|
+
/// sheet, and a prompt is inherently a centered, modal question.
|
|
117
|
+
@objc public func showPrompt(
|
|
118
|
+
options: NSDictionary,
|
|
119
|
+
completion: @escaping (Int, String) -> Void
|
|
120
|
+
) {
|
|
121
|
+
let labels = options["options"] as? [String] ?? []
|
|
122
|
+
let cancelButtonIndex = (options["cancelButtonIndex"] as? NSNumber)?.intValue ?? -1
|
|
123
|
+
let destructiveIndices = Set(
|
|
124
|
+
(options["destructiveButtonIndices"] as? [NSNumber])?.map { $0.intValue } ?? []
|
|
125
|
+
)
|
|
126
|
+
let disabledIndices = Set(
|
|
127
|
+
(options["disabledButtonIndices"] as? [NSNumber])?.map { $0.intValue } ?? []
|
|
128
|
+
)
|
|
129
|
+
let tintColor = Self.color(options["tintColor"])
|
|
130
|
+
let cancelButtonTintColor = Self.color(options["cancelButtonTintColor"])
|
|
131
|
+
let destructiveColor = Self.color(options["destructiveColor"])
|
|
132
|
+
|
|
133
|
+
guard let parent = Self.presentedViewController() else {
|
|
134
|
+
completion(cancelButtonIndex, "")
|
|
135
|
+
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
let alert = UIAlertController(
|
|
140
|
+
title: Self.text(options["title"]),
|
|
141
|
+
message: Self.text(options["message"]),
|
|
142
|
+
preferredStyle: .alert
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
alert.addTextField { field in
|
|
146
|
+
field.placeholder = Self.text(options["placeholder"])
|
|
147
|
+
field.text = Self.text(options["defaultValue"])
|
|
148
|
+
field.isSecureTextEntry = (options["secureTextEntry"] as? NSNumber)?.boolValue ?? false
|
|
149
|
+
field.keyboardType = Self.keyboardType(options["keyboardType"])
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let presentation = Presentation(
|
|
153
|
+
controller: alert,
|
|
154
|
+
cancelButtonIndex: cancelButtonIndex,
|
|
155
|
+
// Weak, or the presentation would retain the controller it is stored on.
|
|
156
|
+
currentText: { [weak alert] in alert?.textFields?.first?.text ?? "" },
|
|
157
|
+
completion: completion
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
for (index, label) in labels.enumerated() {
|
|
161
|
+
let isCancel = index == cancelButtonIndex
|
|
162
|
+
let style: UIAlertAction.Style =
|
|
163
|
+
destructiveIndices.contains(index) ? .destructive : (isCancel ? .cancel : .default)
|
|
164
|
+
|
|
165
|
+
let action = UIAlertAction(title: label, style: style) { [weak self] _ in
|
|
166
|
+
self?.finish(presentation, index: index)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
let color: UIColor? =
|
|
170
|
+
style == .destructive
|
|
171
|
+
? destructiveColor
|
|
172
|
+
: (isCancel ? (cancelButtonTintColor ?? tintColor) : tintColor)
|
|
173
|
+
|
|
174
|
+
action.isEnabled = !disabledIndices.contains(index)
|
|
175
|
+
|
|
176
|
+
if let color {
|
|
177
|
+
action.setValue(color, forKey: "titleTextColor")
|
|
178
|
+
}
|
|
179
|
+
alert.addAction(action)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
alert.view.tintColor = tintColor
|
|
183
|
+
|
|
184
|
+
switch options["userInterfaceStyle"] as? String {
|
|
185
|
+
case "dark": alert.overrideUserInterfaceStyle = .dark
|
|
186
|
+
case "light": alert.overrideUserInterfaceStyle = .light
|
|
187
|
+
default: alert.overrideUserInterfaceStyle = .unspecified
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
presentations.append(presentation)
|
|
191
|
+
parent.present(alert, animated: true)
|
|
192
|
+
}
|
|
193
|
+
|
|
114
194
|
@objc public func dismissAll() {
|
|
115
195
|
guard let bottom = presentations.first else { return }
|
|
116
196
|
|
|
@@ -163,15 +243,20 @@ public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDe
|
|
|
163
243
|
private final class Presentation {
|
|
164
244
|
let controller: UIAlertController
|
|
165
245
|
let cancelButtonIndex: Int
|
|
166
|
-
|
|
246
|
+
/// Read at resolve time, not at creation: the value that matters is
|
|
247
|
+
/// whatever is in the field when the prompt closes. Sheets pass a constant.
|
|
248
|
+
private let currentText: () -> String
|
|
249
|
+
private var completion: ((Int, String) -> Void)?
|
|
167
250
|
|
|
168
251
|
init(
|
|
169
252
|
controller: UIAlertController,
|
|
170
253
|
cancelButtonIndex: Int,
|
|
171
|
-
|
|
254
|
+
currentText: @escaping () -> String = { "" },
|
|
255
|
+
completion: @escaping (Int, String) -> Void
|
|
172
256
|
) {
|
|
173
257
|
self.controller = controller
|
|
174
258
|
self.cancelButtonIndex = cancelButtonIndex
|
|
259
|
+
self.currentText = currentText
|
|
175
260
|
self.completion = completion
|
|
176
261
|
}
|
|
177
262
|
|
|
@@ -179,7 +264,7 @@ public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDe
|
|
|
179
264
|
guard let completion else { return }
|
|
180
265
|
|
|
181
266
|
self.completion = nil
|
|
182
|
-
completion(index)
|
|
267
|
+
completion(index, currentText())
|
|
183
268
|
}
|
|
184
269
|
}
|
|
185
270
|
|
|
@@ -208,6 +293,18 @@ public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDe
|
|
|
208
293
|
return CGRect(x: x, y: y, width: width, height: height)
|
|
209
294
|
}
|
|
210
295
|
|
|
296
|
+
/// Mirrors the subset of React Native's keyboardType values that map cleanly
|
|
297
|
+
/// onto both platforms; anything else falls back to the default keyboard.
|
|
298
|
+
private static func keyboardType(_ value: Any?) -> UIKeyboardType {
|
|
299
|
+
switch value as? String {
|
|
300
|
+
case "email-address": return .emailAddress
|
|
301
|
+
case "numeric": return .numberPad
|
|
302
|
+
case "phone-pad": return .phonePad
|
|
303
|
+
case "url": return .URL
|
|
304
|
+
default: return .default
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
211
308
|
private static func text(_ value: Any?) -> String? {
|
|
212
309
|
guard let string = value as? String, !string.isEmpty else { return nil }
|
|
213
310
|
|
package/jest/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ActionSheetOptionsInterface,
|
|
3
|
+
PromptOptionsInterface,
|
|
4
|
+
PromptResultInterface,
|
|
5
|
+
} from 'react-native-unified-action-sheet';
|
|
2
6
|
|
|
3
7
|
/// Queues the index the next sheet resolves with. Pass nothing to go back to
|
|
4
8
|
/// resolving with no selection.
|
|
@@ -8,5 +12,15 @@ export declare const showActionSheetWithOptions: jest.Mock<
|
|
|
8
12
|
Promise<number | undefined>,
|
|
9
13
|
[ActionSheetOptionsInterface]
|
|
10
14
|
>;
|
|
15
|
+
/// Queues what the next prompt resolves with. Pass nothing to go back to
|
|
16
|
+
/// resolving with no selection.
|
|
17
|
+
export declare function setNextPromptResult(
|
|
18
|
+
result?: PromptResultInterface
|
|
19
|
+
): void;
|
|
20
|
+
|
|
21
|
+
export declare const showPromptWithOptions: jest.Mock<
|
|
22
|
+
Promise<PromptResultInterface | undefined>,
|
|
23
|
+
[PromptOptionsInterface]
|
|
24
|
+
>;
|
|
11
25
|
export declare const dismissActionSheet: jest.Mock<void, []>;
|
|
12
26
|
export declare const dismissAllActionSheets: jest.Mock<void, []>;
|
package/jest/index.js
CHANGED
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
*
|
|
17
17
|
* Prefer that over mockResolvedValueOnce, which replaces the implementation and
|
|
18
18
|
* so skips onPress.
|
|
19
|
+
*
|
|
20
|
+
* A prompt is queued the same way, with the text the field should resolve with:
|
|
21
|
+
*
|
|
22
|
+
* setNextPromptResult({ buttonIndex: 0, text: 'typed' });
|
|
23
|
+
* await openThePrompt();
|
|
19
24
|
*/
|
|
20
25
|
let nextButtonIndex;
|
|
21
26
|
|
|
@@ -35,12 +40,35 @@ const showActionSheetWithOptions = jest.fn((options) => {
|
|
|
35
40
|
return Promise.resolve(buttonIndex);
|
|
36
41
|
});
|
|
37
42
|
|
|
43
|
+
let nextPromptResult;
|
|
44
|
+
|
|
45
|
+
const setNextPromptResult = (result) => {
|
|
46
|
+
nextPromptResult = result;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const showPromptWithOptions = jest.fn((options) => {
|
|
50
|
+
const result = nextPromptResult;
|
|
51
|
+
nextPromptResult = undefined;
|
|
52
|
+
|
|
53
|
+
if (result) {
|
|
54
|
+
const button =
|
|
55
|
+
options && options.options && options.options[result.buttonIndex];
|
|
56
|
+
if (button && typeof button.onPress === 'function') {
|
|
57
|
+
button.onPress(result.text);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return Promise.resolve(result);
|
|
62
|
+
});
|
|
63
|
+
|
|
38
64
|
const dismissActionSheet = jest.fn();
|
|
39
65
|
const dismissAllActionSheets = jest.fn();
|
|
40
66
|
|
|
41
67
|
module.exports = {
|
|
42
68
|
setNextButtonIndex,
|
|
69
|
+
setNextPromptResult,
|
|
43
70
|
showActionSheetWithOptions,
|
|
71
|
+
showPromptWithOptions,
|
|
44
72
|
dismissActionSheet,
|
|
45
73
|
dismissAllActionSheets,
|
|
46
74
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeUnifiedActionSheet.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAqE,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeUnifiedActionSheet.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAqE,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GA6CtDC,gCAAmB,CAACC,YAAY,CAAO,oBAAoB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["common-options.interface.ts"],"mappings":"","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.showActionSheetWithOptions = exports.dismissAllActionSheets = exports.dismissActionSheet = void 0;
|
|
6
|
+
exports.showPromptWithOptions = exports.showActionSheetWithOptions = exports.dismissAllActionSheets = exports.dismissActionSheet = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
const DISMISSED_BY_API = -2;
|
|
9
9
|
|
|
@@ -20,12 +20,18 @@ const toWireOptions = ({
|
|
|
20
20
|
// crosses the bridge. Omit<> would not strip it at runtime.
|
|
21
21
|
anchor: _anchor,
|
|
22
22
|
...rest
|
|
23
|
-
}) => {
|
|
23
|
+
}) => ({
|
|
24
|
+
...rest,
|
|
25
|
+
...toWireButtons(options)
|
|
26
|
+
});
|
|
27
|
+
/// Same flattening as the sheet: labels plus index sets. Kept generic over the
|
|
28
|
+
/// button shape so the two APIs cannot disagree about what 'cancel' means.
|
|
29
|
+
const toWireButtons = buttons => {
|
|
24
30
|
const labels = [];
|
|
25
31
|
const destructive = [];
|
|
26
32
|
const disabled = [];
|
|
27
33
|
let cancelButtonIndex;
|
|
28
|
-
|
|
34
|
+
buttons.forEach((button, index) => {
|
|
29
35
|
labels.push(button.label);
|
|
30
36
|
if (button.style === 'destructive') destructive.push(index);
|
|
31
37
|
if (button.style === 'cancel' && cancelButtonIndex == null) {
|
|
@@ -34,7 +40,6 @@ const toWireOptions = ({
|
|
|
34
40
|
if (button.disabled) disabled.push(index);
|
|
35
41
|
});
|
|
36
42
|
return {
|
|
37
|
-
...rest,
|
|
38
43
|
options: labels,
|
|
39
44
|
...(cancelButtonIndex == null ? {} : {
|
|
40
45
|
cancelButtonIndex
|
|
@@ -100,5 +105,35 @@ const dismissAllActionSheets = () => {
|
|
|
100
105
|
nativeModule().dismissAllActionSheets();
|
|
101
106
|
}
|
|
102
107
|
};
|
|
108
|
+
|
|
109
|
+
/// A prompt is the sheet's centered dialog with a text field: iOS presents a
|
|
110
|
+
/// UIAlertController alert with addTextField, Android the same AppCompatDialog
|
|
111
|
+
/// the centered style uses. React Native's own Alert.prompt is iOS-only and a
|
|
112
|
+
/// silent no-op on Android, which is the gap this fills.
|
|
103
113
|
exports.dismissAllActionSheets = dismissAllActionSheets;
|
|
114
|
+
const showPromptWithOptions = options => {
|
|
115
|
+
const {
|
|
116
|
+
options: buttons,
|
|
117
|
+
...rest
|
|
118
|
+
} = options;
|
|
119
|
+
const wire = {
|
|
120
|
+
...rest,
|
|
121
|
+
...toWireButtons(buttons)
|
|
122
|
+
};
|
|
123
|
+
if (_reactNative.Platform.OS !== 'ios' && _reactNative.Platform.OS !== 'android') {
|
|
124
|
+
return Promise.resolve(undefined);
|
|
125
|
+
}
|
|
126
|
+
return nativeModule().showPromptWithOptions(wire).then(result =>
|
|
127
|
+
// A programmatic dismiss resolves with no selection, matching the sheet.
|
|
128
|
+
result.buttonIndex === DISMISSED_BY_API ? undefined : result).catch(() => ({
|
|
129
|
+
buttonIndex: wire.cancelButtonIndex ?? -1,
|
|
130
|
+
text: ''
|
|
131
|
+
})).then(result => {
|
|
132
|
+
// The text goes to the handler, so a caller using onPress alone never
|
|
133
|
+
// has to read the resolved value.
|
|
134
|
+
if (result) buttons[result.buttonIndex]?.onPress?.(result.text);
|
|
135
|
+
return result;
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
exports.showPromptWithOptions = showPromptWithOptions;
|
|
104
139
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","DISMISSED_BY_API","nativeModule","default","toWireOptions","options","anchor","_anchor","rest","labels","destructive","disabled","cancelButtonIndex","forEach","button","index","push","label","style","length","destructiveButtonIndices","disabledButtonIndices","showWithNativeModule","showActionSheetWithOptions","then","buttonIndex","undefined","catch","withAnchorRect","wire","target","current","Promise","resolve","measureInWindow","x","y","width","height","measured","anchorRect","press","onPress","Platform","OS","exports","dismissActionSheet","dismissAllActionSheets"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_reactNative","require","DISMISSED_BY_API","nativeModule","default","toWireOptions","options","anchor","_anchor","rest","toWireButtons","buttons","labels","destructive","disabled","cancelButtonIndex","forEach","button","index","push","label","style","length","destructiveButtonIndices","disabledButtonIndices","showWithNativeModule","showActionSheetWithOptions","then","buttonIndex","undefined","catch","withAnchorRect","wire","target","current","Promise","resolve","measureInWindow","x","y","width","height","measured","anchorRect","press","onPress","Platform","OS","exports","dismissActionSheet","dismissAllActionSheets","showPromptWithOptions","result","text"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAgCA,MAAMC,gBAAgB,GAAG,CAAC,CAAC;;AAE3B;AACA;;AASA,MAAMC,YAAY,GAAGA,CAAA,KACnBF,OAAO,CAAC,4BAA4B,CAAC,CAACG,OAAe;;AAEvD;AACA;AACA,MAAMC,aAAa,GAAGA,CAAC;EACrBC,OAAO;EACP;EACA;EACAC,MAAM,EAAEC,OAAO;EACf,GAAGC;AACwB,CAAC,MAAmB;EAC/C,GAAGA,IAAI;EACP,GAAGC,aAAa,CAACJ,OAAO;AAC1B,CAAC,CAAC;AASF;AACA;AACA,MAAMI,aAAa,GAAIC,OAA2C,IAAK;EACrE,MAAMC,MAAgB,GAAG,EAAE;EAC3B,MAAMC,WAAqB,GAAG,EAAE;EAChC,MAAMC,QAAkB,GAAG,EAAE;EAC7B,IAAIC,iBAAqC;EAEzCJ,OAAO,CAACK,OAAO,CAAC,CAACC,MAAM,EAAEC,KAAK,KAAK;IACjCN,MAAM,CAACO,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;IAEzB,IAAIH,MAAM,CAACI,KAAK,KAAK,aAAa,EAAER,WAAW,CAACM,IAAI,CAACD,KAAK,CAAC;IAC3D,IAAID,MAAM,CAACI,KAAK,KAAK,QAAQ,IAAIN,iBAAiB,IAAI,IAAI,EAAE;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,YAAY,CAAC,CAAC,CAAC+C,sBAAsB,CAAC,CAAC;EACzC;AACF,CAAC;;AAED;AACA;AACA;AACA;AAAAF,OAAA,CAAAE,sBAAA,GAAAA,sBAAA;AACO,MAAMC,qBAAqB,GAChC7C,OAA+B,IACgB;EAC/C,MAAM;IAAEA,OAAO,EAAEK,OAAO;IAAE,GAAGF;EAAK,CAAC,GAAGH,OAAO;EAC7C,MAAM0B,IAAuB,GAAG;IAAE,GAAGvB,IAAI;IAAE,GAAGC,aAAa,CAACC,OAAO;EAAE,CAAC;EAEtE,IAAImC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAID,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;IACtD,OAAOZ,OAAO,CAACC,OAAO,CAACP,SAAS,CAAC;EACnC;EAEA,OAAO1B,YAAY,CAAC,CAAC,CAClBgD,qBAAqB,CAACnB,IAAI,CAAC,CAC3BL,IAAI,CAAEyB,MAAM;EACX;EACAA,MAAM,CAACxB,WAAW,KAAK1B,gBAAgB,GAAG2B,SAAS,GAAGuB,MACxD,CAAC,CACAtB,KAAK,CAAC,OAAO;IAAEF,WAAW,EAAEI,IAAI,CAACjB,iBAAiB,IAAI,CAAC,CAAC;IAAEsC,IAAI,EAAE;EAAG,CAAC,CAAC,CAAC,CACtE1B,IAAI,CAAEyB,MAAM,IAAK;IAChB;IACA;IACA,IAAIA,MAAM,EAAEzC,OAAO,CAACyC,MAAM,CAACxB,WAAW,CAAC,EAAEiB,OAAO,GAAGO,MAAM,CAACC,IAAI,CAAC;IAE/D,OAAOD,MAAM;EACf,CAAC,CAAC;AACN,CAAC;AAACJ,OAAA,CAAAG,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["prompt-options.interface.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeUnifiedActionSheet.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAA0B,cAAc;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeUnifiedActionSheet.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAA0B,cAAc;AA6CpE,eAAeA,mBAAmB,CAACC,YAAY,CAAO,oBAAoB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["common-options.interface.ts"],"mappings":"","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -16,12 +16,18 @@ const toWireOptions = ({
|
|
|
16
16
|
// crosses the bridge. Omit<> would not strip it at runtime.
|
|
17
17
|
anchor: _anchor,
|
|
18
18
|
...rest
|
|
19
|
-
}) => {
|
|
19
|
+
}) => ({
|
|
20
|
+
...rest,
|
|
21
|
+
...toWireButtons(options)
|
|
22
|
+
});
|
|
23
|
+
/// Same flattening as the sheet: labels plus index sets. Kept generic over the
|
|
24
|
+
/// button shape so the two APIs cannot disagree about what 'cancel' means.
|
|
25
|
+
const toWireButtons = buttons => {
|
|
20
26
|
const labels = [];
|
|
21
27
|
const destructive = [];
|
|
22
28
|
const disabled = [];
|
|
23
29
|
let cancelButtonIndex;
|
|
24
|
-
|
|
30
|
+
buttons.forEach((button, index) => {
|
|
25
31
|
labels.push(button.label);
|
|
26
32
|
if (button.style === 'destructive') destructive.push(index);
|
|
27
33
|
if (button.style === 'cancel' && cancelButtonIndex == null) {
|
|
@@ -30,7 +36,6 @@ const toWireOptions = ({
|
|
|
30
36
|
if (button.disabled) disabled.push(index);
|
|
31
37
|
});
|
|
32
38
|
return {
|
|
33
|
-
...rest,
|
|
34
39
|
options: labels,
|
|
35
40
|
...(cancelButtonIndex == null ? {} : {
|
|
36
41
|
cancelButtonIndex
|
|
@@ -94,4 +99,33 @@ export const dismissAllActionSheets = () => {
|
|
|
94
99
|
nativeModule().dismissAllActionSheets();
|
|
95
100
|
}
|
|
96
101
|
};
|
|
102
|
+
|
|
103
|
+
/// A prompt is the sheet's centered dialog with a text field: iOS presents a
|
|
104
|
+
/// UIAlertController alert with addTextField, Android the same AppCompatDialog
|
|
105
|
+
/// the centered style uses. React Native's own Alert.prompt is iOS-only and a
|
|
106
|
+
/// silent no-op on Android, which is the gap this fills.
|
|
107
|
+
export const showPromptWithOptions = options => {
|
|
108
|
+
const {
|
|
109
|
+
options: buttons,
|
|
110
|
+
...rest
|
|
111
|
+
} = options;
|
|
112
|
+
const wire = {
|
|
113
|
+
...rest,
|
|
114
|
+
...toWireButtons(buttons)
|
|
115
|
+
};
|
|
116
|
+
if (Platform.OS !== 'ios' && Platform.OS !== 'android') {
|
|
117
|
+
return Promise.resolve(undefined);
|
|
118
|
+
}
|
|
119
|
+
return nativeModule().showPromptWithOptions(wire).then(result =>
|
|
120
|
+
// A programmatic dismiss resolves with no selection, matching the sheet.
|
|
121
|
+
result.buttonIndex === DISMISSED_BY_API ? undefined : result).catch(() => ({
|
|
122
|
+
buttonIndex: wire.cancelButtonIndex ?? -1,
|
|
123
|
+
text: ''
|
|
124
|
+
})).then(result => {
|
|
125
|
+
// The text goes to the handler, so a caller using onPress alone never
|
|
126
|
+
// has to read the resolved value.
|
|
127
|
+
if (result) buttons[result.buttonIndex]?.onPress?.(result.text);
|
|
128
|
+
return result;
|
|
129
|
+
});
|
|
130
|
+
};
|
|
97
131
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","DISMISSED_BY_API","nativeModule","require","default","toWireOptions","options","anchor","_anchor","rest","labels","destructive","disabled","cancelButtonIndex","forEach","button","index","push","label","style","length","destructiveButtonIndices","disabledButtonIndices","showWithNativeModule","showActionSheetWithOptions","then","buttonIndex","undefined","catch","withAnchorRect","wire","target","current","Promise","resolve","measureInWindow","x","y","width","height","measured","anchorRect","press","onPress","OS","dismissActionSheet","dismissAllActionSheets"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["Platform","DISMISSED_BY_API","nativeModule","require","default","toWireOptions","options","anchor","_anchor","rest","toWireButtons","buttons","labels","destructive","disabled","cancelButtonIndex","forEach","button","index","push","label","style","length","destructiveButtonIndices","disabledButtonIndices","showWithNativeModule","showActionSheetWithOptions","then","buttonIndex","undefined","catch","withAnchorRect","wire","target","current","Promise","resolve","measureInWindow","x","y","width","height","measured","anchorRect","press","onPress","OS","dismissActionSheet","dismissAllActionSheets","showPromptWithOptions","result","text"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAgCvC,MAAMC,gBAAgB,GAAG,CAAC,CAAC;;AAE3B;AACA;;AASA,MAAMC,YAAY,GAAGA,CAAA,KACnBC,OAAO,CAAC,4BAA4B,CAAC,CAACC,OAAe;;AAEvD;AACA;AACA,MAAMC,aAAa,GAAGA,CAAC;EACrBC,OAAO;EACP;EACA;EACAC,MAAM,EAAEC,OAAO;EACf,GAAGC;AACwB,CAAC,MAAmB;EAC/C,GAAGA,IAAI;EACP,GAAGC,aAAa,CAACJ,OAAO;AAC1B,CAAC,CAAC;AASF;AACA;AACA,MAAMI,aAAa,GAAIC,OAA2C,IAAK;EACrE,MAAMC,MAAgB,GAAG,EAAE;EAC3B,MAAMC,WAAqB,GAAG,EAAE;EAChC,MAAMC,QAAkB,GAAG,EAAE;EAC7B,IAAIC,iBAAqC;EAEzCJ,OAAO,CAACK,OAAO,CAAC,CAACC,MAAM,EAAEC,KAAK,KAAK;IACjCN,MAAM,CAACO,IAAI,CAACF,MAAM,CAACG,KAAK,CAAC;IAEzB,IAAIH,MAAM,CAACI,KAAK,KAAK,aAAa,EAAER,WAAW,CAACM,IAAI,CAACD,KAAK,CAAC;IAC3D,IAAID,MAAM,CAACI,K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AAY,CAAC,CAAC,CAAC8C,sBAAsB,CAAC,CAAC;EACzC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAChC3C,OAA+B,IACgB;EAC/C,MAAM;IAAEA,OAAO,EAAEK,OAAO;IAAE,GAAGF;EAAK,CAAC,GAAGH,OAAO;EAC7C,MAAM0B,IAAuB,GAAG;IAAE,GAAGvB,IAAI;IAAE,GAAGC,aAAa,CAACC,OAAO;EAAE,CAAC;EAEtE,IAAIX,QAAQ,CAAC8C,EAAE,KAAK,KAAK,IAAI9C,QAAQ,CAAC8C,EAAE,KAAK,SAAS,EAAE;IACtD,OAAOX,OAAO,CAACC,OAAO,CAACP,SAAS,CAAC;EACnC;EAEA,OAAO3B,YAAY,CAAC,CAAC,CAClB+C,qBAAqB,CAACjB,IAAI,CAAC,CAC3BL,IAAI,CAAEuB,MAAM;EACX;EACAA,MAAM,CAACtB,WAAW,KAAK3B,gBAAgB,GAAG4B,SAAS,GAAGqB,MACxD,CAAC,CACApB,KAAK,CAAC,OAAO;IAAEF,WAAW,EAAEI,IAAI,CAACjB,iBAAiB,IAAI,CAAC,CAAC;IAAEoC,IAAI,EAAE;EAAG,CAAC,CAAC,CAAC,CACtExB,IAAI,CAAEuB,MAAM,IAAK;IAChB;IACA;IACA,IAAIA,MAAM,EAAEvC,OAAO,CAACuC,MAAM,CAACtB,WAAW,CAAC,EAAEiB,OAAO,GAAGK,MAAM,CAACC,IAAI,CAAC;IAE/D,OAAOD,MAAM;EACf,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["prompt-options.interface.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -21,6 +21,26 @@ export interface Spec extends TurboModule {
|
|
|
21
21
|
height: number;
|
|
22
22
|
};
|
|
23
23
|
}): Promise<number>;
|
|
24
|
+
showPromptWithOptions(options: {
|
|
25
|
+
options: string[];
|
|
26
|
+
cancelButtonIndex?: number;
|
|
27
|
+
destructiveButtonIndices?: number[];
|
|
28
|
+
disabledButtonIndices?: number[];
|
|
29
|
+
title?: string;
|
|
30
|
+
message?: string;
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
defaultValue?: string;
|
|
33
|
+
keyboardType?: string;
|
|
34
|
+
secureTextEntry?: boolean;
|
|
35
|
+
tintColor?: string;
|
|
36
|
+
cancelButtonTintColor?: string;
|
|
37
|
+
destructiveColor?: string;
|
|
38
|
+
buttonTextAlignment?: string;
|
|
39
|
+
userInterfaceStyle?: string;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
buttonIndex: number;
|
|
42
|
+
text: string;
|
|
43
|
+
}>;
|
|
24
44
|
dismissActionSheet(): void;
|
|
25
45
|
dismissAllActionSheets(): void;
|
|
26
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeUnifiedActionSheet.d.ts","sourceRoot":"","sources":["../../../../src/NativeUnifiedActionSheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,0BAA0B,CAAC,OAAO,EAAE;QAClC,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;QACpC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;QACjC,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,iBAAiB,CAAC,EAAE,MAAM,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AC,MAAM,CAAC,CAAC;IACpB,qBAAqB,CAAC,OAAO,EAAE;QAC7B,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;QACpC,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;QACjC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B,GAAG,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,kBAAkB,IAAI,IAAI,CAAC;IAC3B,sBAAsB,IAAI,IAAI,CAAC;CAChC;;AAED,wBAA4E"}
|
|
@@ -1,27 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
style?: 'cancel' | 'destructive';
|
|
4
|
-
disabled?: boolean;
|
|
1
|
+
import type { BaseAndroidOptionsInterface, BaseButtonInterface, BaseOptionsInterface } from './common-options.interface';
|
|
2
|
+
export interface ActionSheetButtonInterface extends BaseButtonInterface {
|
|
5
3
|
onPress?: () => void;
|
|
6
4
|
}
|
|
7
5
|
export interface ActionSheetAnchorInterface {
|
|
8
6
|
measureInWindow: (callback: (x: number, y: number, width: number, height: number) => void) => void;
|
|
9
7
|
}
|
|
10
|
-
export interface ActionSheetCommonOptionsInterface {
|
|
8
|
+
export interface ActionSheetCommonOptionsInterface extends BaseOptionsInterface {
|
|
11
9
|
options: ActionSheetButtonInterface[];
|
|
12
|
-
title?: string;
|
|
13
|
-
message?: string;
|
|
14
|
-
tintColor?: string;
|
|
15
|
-
cancelButtonTintColor?: string;
|
|
16
|
-
userInterfaceStyle?: 'light' | 'dark';
|
|
17
10
|
anchor?: ActionSheetAnchorInterface | {
|
|
18
11
|
current: ActionSheetAnchorInterface | null;
|
|
19
12
|
} | null;
|
|
20
|
-
destructiveColor?: string;
|
|
21
13
|
presentationStyle?: 'centered' | 'anchored';
|
|
22
14
|
}
|
|
23
|
-
export interface ActionSheetAndroidOptionsInterface {
|
|
24
|
-
buttonTextAlignment?: 'start' | 'center';
|
|
15
|
+
export interface ActionSheetAndroidOptionsInterface extends BaseAndroidOptionsInterface {
|
|
25
16
|
anchorAlignment?: 'start' | 'center';
|
|
26
17
|
}
|
|
27
18
|
export interface ActionSheetOptionsInterface extends ActionSheetCommonOptionsInterface, ActionSheetAndroidOptionsInterface {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-sheet-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/action-sheet-options.interface.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"action-sheet-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/action-sheet-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,0BAA2B,SAAQ,mBAAmB;IACrE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACzC,eAAe,EAAE,CACf,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,KACpE,IAAI,CAAC;CACX;AAED,MAAM,WAAW,iCAAkC,SAAQ,oBAAoB;IAC7E,OAAO,EAAE,0BAA0B,EAAE,CAAC;IACtC,MAAM,CAAC,EACH,0BAA0B,GAC1B;QAAE,OAAO,EAAE,0BAA0B,GAAG,IAAI,CAAA;KAAE,GAC9C,IAAI,CAAC;IACT,iBAAiB,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;CAC7C;AAED,MAAM,WAAW,kCAAmC,SAAQ,2BAA2B;IACrF,eAAe,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CACtC;AAED,MAAM,WAAW,2BACf,SACE,iCAAiC,EACjC,kCAAkC;CAAG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface BaseButtonInterface {
|
|
2
|
+
label: string;
|
|
3
|
+
style?: 'cancel' | 'destructive';
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface BaseOptionsInterface {
|
|
7
|
+
title?: string;
|
|
8
|
+
message?: string;
|
|
9
|
+
tintColor?: string;
|
|
10
|
+
cancelButtonTintColor?: string;
|
|
11
|
+
destructiveColor?: string;
|
|
12
|
+
userInterfaceStyle?: 'light' | 'dark';
|
|
13
|
+
}
|
|
14
|
+
export interface BaseAndroidOptionsInterface {
|
|
15
|
+
buttonTextAlignment?: 'start' | 'center';
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=common-options.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/common-options.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACvC;AAED,MAAM,WAAW,2BAA2B;IAC1C,mBAAmB,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC1C"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { ActionSheetOptionsInterface } from './action-sheet-options.interface';
|
|
2
|
+
export type { BaseButtonInterface, BaseOptionsInterface, BaseAndroidOptionsInterface, } from './common-options.interface';
|
|
3
|
+
export type { PromptButtonInterface, PromptCommonOptionsInterface, PromptAndroidOptionsInterface, PromptOptionsInterface, PromptResultInterface, } from './prompt-options.interface';
|
|
4
|
+
import type { PromptOptionsInterface, PromptResultInterface } from './prompt-options.interface';
|
|
2
5
|
export type { ActionSheetAnchorInterface, ActionSheetButtonInterface, ActionSheetCommonOptionsInterface, ActionSheetAndroidOptionsInterface, ActionSheetOptionsInterface, } from './action-sheet-options.interface';
|
|
3
6
|
export declare const showActionSheetWithOptions: (options: ActionSheetOptionsInterface) => Promise<number | undefined>;
|
|
4
7
|
export declare const dismissActionSheet: () => void;
|
|
5
8
|
export declare const dismissAllActionSheets: () => void;
|
|
9
|
+
export declare const showPromptWithOptions: (options: PromptOptionsInterface) => Promise<PromptResultInterface | undefined>;
|
|
6
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAEpF,YAAY,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,iCAAiC,EACjC,kCAAkC,EAClC,2BAA2B,GAC5B,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAEpF,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EACV,qBAAqB,EACrB,4BAA4B,EAC5B,6BAA6B,EAC7B,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,iCAAiC,EACjC,kCAAkC,EAClC,2BAA2B,GAC5B,MAAM,kCAAkC,CAAC;AAmG1C,eAAO,MAAM,0BAA0B,GACrC,SAAS,2BAA2B,KACnC,OAAO,CAAC,MAAM,GAAG,SAAS,CAiB5B,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,IAIrC,CAAC;AAIF,eAAO,MAAM,sBAAsB,QAAO,IAIzC,CAAC;AAMF,eAAO,MAAM,qBAAqB,GAChC,SAAS,sBAAsB,KAC9B,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAsB3C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BaseAndroidOptionsInterface, BaseButtonInterface, BaseOptionsInterface } from './common-options.interface';
|
|
2
|
+
export interface PromptButtonInterface extends BaseButtonInterface {
|
|
3
|
+
onPress?: (text: string) => void;
|
|
4
|
+
}
|
|
5
|
+
export interface PromptCommonOptionsInterface extends BaseOptionsInterface {
|
|
6
|
+
options: PromptButtonInterface[];
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
defaultValue?: string;
|
|
9
|
+
keyboardType?: 'default' | 'email-address' | 'numeric' | 'phone-pad' | 'url';
|
|
10
|
+
secureTextEntry?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type PromptAndroidOptionsInterface = BaseAndroidOptionsInterface;
|
|
13
|
+
export interface PromptOptionsInterface extends PromptCommonOptionsInterface, PromptAndroidOptionsInterface {
|
|
14
|
+
}
|
|
15
|
+
export interface PromptResultInterface {
|
|
16
|
+
buttonIndex: number;
|
|
17
|
+
text: string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=prompt-options.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/prompt-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,4BAA6B,SAAQ,oBAAoB;IACxE,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,SAAS,GAAG,eAAe,GAAG,SAAS,GAAG,WAAW,GAAG,KAAK,CAAC;IAC7E,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,MAAM,6BAA6B,GAAG,2BAA2B,CAAC;AAExE,MAAM,WAAW,sBACf,SAAQ,4BAA4B,EAAE,6BAA6B;CAAG;AAExE,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -21,6 +21,26 @@ export interface Spec extends TurboModule {
|
|
|
21
21
|
height: number;
|
|
22
22
|
};
|
|
23
23
|
}): Promise<number>;
|
|
24
|
+
showPromptWithOptions(options: {
|
|
25
|
+
options: string[];
|
|
26
|
+
cancelButtonIndex?: number;
|
|
27
|
+
destructiveButtonIndices?: number[];
|
|
28
|
+
disabledButtonIndices?: number[];
|
|
29
|
+
title?: string;
|
|
30
|
+
message?: string;
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
defaultValue?: string;
|
|
33
|
+
keyboardType?: string;
|
|
34
|
+
secureTextEntry?: boolean;
|
|
35
|
+
tintColor?: string;
|
|
36
|
+
cancelButtonTintColor?: string;
|
|
37
|
+
destructiveColor?: string;
|
|
38
|
+
buttonTextAlignment?: string;
|
|
39
|
+
userInterfaceStyle?: string;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
buttonIndex: number;
|
|
42
|
+
text: string;
|
|
43
|
+
}>;
|
|
24
44
|
dismissActionSheet(): void;
|
|
25
45
|
dismissAllActionSheets(): void;
|
|
26
46
|
}
|