react-native-unified-action-sheet 0.1.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 -0
- package/LICENSE +20 -0
- package/README.md +167 -0
- package/android/build.gradle +51 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/unifiedactionsheet/ActionSheetOptions.kt +134 -0
- package/android/src/main/java/com/unifiedactionsheet/SheetContentBuilder.kt +159 -0
- package/android/src/main/java/com/unifiedactionsheet/SheetPresenters.kt +214 -0
- package/android/src/main/java/com/unifiedactionsheet/SheetTheming.kt +56 -0
- package/android/src/main/java/com/unifiedactionsheet/UnifiedActionSheetModule.kt +126 -0
- package/android/src/main/java/com/unifiedactionsheet/UnifiedActionSheetPackage.kt +30 -0
- package/ios/UnifiedActionSheet.h +5 -0
- package/ios/UnifiedActionSheet.mm +96 -0
- package/ios/UnifiedActionSheetImpl.swift +240 -0
- package/jest/index.d.ts +12 -0
- package/jest/index.js +46 -0
- package/lib/commonjs/NativeUnifiedActionSheet.js +9 -0
- package/lib/commonjs/NativeUnifiedActionSheet.js.map +1 -0
- package/lib/commonjs/action-sheet-options.interface.js +2 -0
- package/lib/commonjs/action-sheet-options.interface.js.map +1 -0
- package/lib/commonjs/index.js +104 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/NativeUnifiedActionSheet.js +5 -0
- package/lib/module/NativeUnifiedActionSheet.js.map +1 -0
- package/lib/module/action-sheet-options.interface.js +2 -0
- package/lib/module/action-sheet-options.interface.js.map +1 -0
- package/lib/module/index.js +97 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeUnifiedActionSheet.d.ts +29 -0
- package/lib/typescript/commonjs/src/NativeUnifiedActionSheet.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/action-sheet-options.interface.d.ts +29 -0
- package/lib/typescript/commonjs/src/action-sheet-options.interface.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +6 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeUnifiedActionSheet.d.ts +29 -0
- package/lib/typescript/module/src/NativeUnifiedActionSheet.d.ts.map +1 -0
- package/lib/typescript/module/src/action-sheet-options.interface.d.ts +29 -0
- package/lib/typescript/module/src/action-sheet-options.interface.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +6 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +155 -0
- package/react-native-unified-action-sheet.podspec +23 -0
- package/src/NativeUnifiedActionSheet.ts +29 -0
- package/src/action-sheet-options.interface.ts +43 -0
- package/src/index.tsx +131 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UIKit
|
|
3
|
+
|
|
4
|
+
@objc(UnifiedActionSheetImpl)
|
|
5
|
+
public class UnifiedActionSheetImpl: NSObject, UIPopoverPresentationControllerDelegate {
|
|
6
|
+
@objc public static let shared = UnifiedActionSheetImpl()
|
|
7
|
+
|
|
8
|
+
private static let dismissedByApi = -2
|
|
9
|
+
|
|
10
|
+
private var presentations: [Presentation] = []
|
|
11
|
+
|
|
12
|
+
@objc public func show(
|
|
13
|
+
options: NSDictionary,
|
|
14
|
+
completion: @escaping (Int) -> Void
|
|
15
|
+
) {
|
|
16
|
+
let labels = options["options"] as? [String] ?? []
|
|
17
|
+
let cancelButtonIndex = (options["cancelButtonIndex"] as? NSNumber)?.intValue ?? -1
|
|
18
|
+
let destructiveIndices = Set(
|
|
19
|
+
(options["destructiveButtonIndices"] as? [NSNumber])?.map { $0.intValue } ?? []
|
|
20
|
+
)
|
|
21
|
+
let disabledIndices = Set(
|
|
22
|
+
(options["disabledButtonIndices"] as? [NSNumber])?.map { $0.intValue } ?? []
|
|
23
|
+
)
|
|
24
|
+
let tintColor = Self.color(options["tintColor"])
|
|
25
|
+
let cancelButtonTintColor = Self.color(options["cancelButtonTintColor"])
|
|
26
|
+
let destructiveColor = Self.color(options["destructiveColor"])
|
|
27
|
+
|
|
28
|
+
guard let parent = Self.presentedViewController() else {
|
|
29
|
+
completion(cancelButtonIndex)
|
|
30
|
+
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 'centered' maps to UIKit's centered alert style; anything else (including
|
|
35
|
+
// absent, and 'anchored') stays .actionSheet, the iOS default — presented
|
|
36
|
+
// from the bottom on iPhone and as a popover on iPad.
|
|
37
|
+
let isCentered = options["presentationStyle"] as? String == "centered"
|
|
38
|
+
|
|
39
|
+
let alert = UIAlertController(
|
|
40
|
+
title: Self.text(options["title"]),
|
|
41
|
+
message: Self.text(options["message"]),
|
|
42
|
+
preferredStyle: isCentered ? .alert : .actionSheet
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
let presentation = Presentation(
|
|
46
|
+
controller: alert,
|
|
47
|
+
cancelButtonIndex: cancelButtonIndex,
|
|
48
|
+
completion: completion
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
for (index, label) in labels.enumerated() {
|
|
52
|
+
let isCancel = index == cancelButtonIndex
|
|
53
|
+
let style: UIAlertAction.Style =
|
|
54
|
+
destructiveIndices.contains(index) ? .destructive : (isCancel ? .cancel : .default)
|
|
55
|
+
|
|
56
|
+
let action = UIAlertAction(title: label, style: style) { [weak self] _ in
|
|
57
|
+
self?.finish(presentation, index: index)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Precedence matches Android: destructive > cancel tint > tint > default.
|
|
61
|
+
// disabledButtonTintColor is deliberately absent: UIKit owns the
|
|
62
|
+
// appearance of a disabled action and discards titleTextColor for it.
|
|
63
|
+
let color: UIColor? =
|
|
64
|
+
style == .destructive
|
|
65
|
+
? destructiveColor
|
|
66
|
+
: (isCancel ? (cancelButtonTintColor ?? tintColor) : tintColor)
|
|
67
|
+
|
|
68
|
+
action.isEnabled = !disabledIndices.contains(index)
|
|
69
|
+
|
|
70
|
+
if let color {
|
|
71
|
+
// UIKit exposes no public API for per-action title colors.
|
|
72
|
+
action.setValue(color, forKey: "titleTextColor")
|
|
73
|
+
}
|
|
74
|
+
alert.addAction(action)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
alert.view.tintColor = tintColor
|
|
78
|
+
|
|
79
|
+
switch options["userInterfaceStyle"] as? String {
|
|
80
|
+
case "dark": alert.overrideUserInterfaceStyle = .dark
|
|
81
|
+
case "light": alert.overrideUserInterfaceStyle = .light
|
|
82
|
+
default: alert.overrideUserInterfaceStyle = .unspecified
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if let popover = alert.popoverPresentationController {
|
|
86
|
+
let anchorRect = Self.rect(options["anchorRect"])
|
|
87
|
+
|
|
88
|
+
if anchorRect == nil {
|
|
89
|
+
popover.permittedArrowDirections = []
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Only iPad, where an unanchored action sheet raises an exception. Setting
|
|
93
|
+
// these on iPhone makes iOS 26 present the sheet as a popover, which is
|
|
94
|
+
// narrower and silently drops the cancel action.
|
|
95
|
+
if UIDevice.current.userInterfaceIdiom == .pad, let source = parent.view {
|
|
96
|
+
popover.sourceView = source
|
|
97
|
+
// Measured from the ref in JS, already in window points — iOS needs
|
|
98
|
+
// neither the density conversion nor the screen offset Android does.
|
|
99
|
+
popover.sourceRect = anchorRect.map { source.convert($0, from: nil) }
|
|
100
|
+
?? source.bounds
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// An iPad popover tapped away runs no action handler — UIKit drops the
|
|
105
|
+
// cancel action in popovers — so without this the promise would never
|
|
106
|
+
// resolve. The delegate goes on the popover controller: UIKit raises if you
|
|
107
|
+
// set one on a UIAlertController's own presentationController.
|
|
108
|
+
alert.popoverPresentationController?.delegate = self
|
|
109
|
+
|
|
110
|
+
presentations.append(presentation)
|
|
111
|
+
parent.present(alert, animated: true)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@objc public func dismissAll() {
|
|
115
|
+
guard let bottom = presentations.first else { return }
|
|
116
|
+
|
|
117
|
+
let all = presentations
|
|
118
|
+
|
|
119
|
+
// Sheets stack by presenting on top of each other, and dismiss() tears down
|
|
120
|
+
// what the receiver *presented*, not the receiver itself. Dismissing each
|
|
121
|
+
// controller in turn therefore closes only the top one. Asking the lowest
|
|
122
|
+
// sheet's presenter to dismiss removes that sheet and everything above it.
|
|
123
|
+
guard let presenter = bottom.controller.presentingViewController else {
|
|
124
|
+
all.forEach { finish($0, index: Self.dismissedByApi) }
|
|
125
|
+
|
|
126
|
+
return
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
presenter.dismiss(animated: true) { [weak self] in
|
|
130
|
+
all.forEach { self?.finish($0, index: Self.dismissedByApi) }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@objc public func dismiss() {
|
|
135
|
+
guard let presentation = presentations.last else { return }
|
|
136
|
+
|
|
137
|
+
presentation.controller.dismiss(animated: true) { [weak self] in
|
|
138
|
+
self?.finish(presentation, index: Self.dismissedByApi)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/// Interactive dismissal only — a programmatic dismiss() does not call this,
|
|
143
|
+
/// so the -2 sentinel it resolves with is never overwritten here.
|
|
144
|
+
public func popoverPresentationControllerDidDismissPopover(
|
|
145
|
+
_ popoverPresentationController: UIPopoverPresentationController
|
|
146
|
+
) {
|
|
147
|
+
guard
|
|
148
|
+
let alert = popoverPresentationController.presentedViewController
|
|
149
|
+
as? UIAlertController,
|
|
150
|
+
let presentation = presentations.first(where: { $0.controller === alert })
|
|
151
|
+
else { return }
|
|
152
|
+
|
|
153
|
+
finish(presentation, index: presentation.cancelButtonIndex)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/// Resolves a presentation once and drops it from the stack. A sheet dismissed
|
|
157
|
+
/// without a selection resolves with the cancel index, matching Android.
|
|
158
|
+
private func finish(_ presentation: Presentation, index: Int) {
|
|
159
|
+
presentations.removeAll { $0 === presentation }
|
|
160
|
+
presentation.resolve(index)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private final class Presentation {
|
|
164
|
+
let controller: UIAlertController
|
|
165
|
+
let cancelButtonIndex: Int
|
|
166
|
+
private var completion: ((Int) -> Void)?
|
|
167
|
+
|
|
168
|
+
init(
|
|
169
|
+
controller: UIAlertController,
|
|
170
|
+
cancelButtonIndex: Int,
|
|
171
|
+
completion: @escaping (Int) -> Void
|
|
172
|
+
) {
|
|
173
|
+
self.controller = controller
|
|
174
|
+
self.cancelButtonIndex = cancelButtonIndex
|
|
175
|
+
self.completion = completion
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
func resolve(_ index: Int) {
|
|
179
|
+
guard let completion else { return }
|
|
180
|
+
|
|
181
|
+
self.completion = nil
|
|
182
|
+
completion(index)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
private static func presentedViewController() -> UIViewController? {
|
|
187
|
+
let window = UIApplication.shared.connectedScenes
|
|
188
|
+
.compactMap { $0 as? UIWindowScene }
|
|
189
|
+
.flatMap { $0.windows }
|
|
190
|
+
.first { $0.isKeyWindow }
|
|
191
|
+
|
|
192
|
+
var controller = window?.rootViewController
|
|
193
|
+
while let presented = controller?.presentedViewController {
|
|
194
|
+
controller = presented
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return controller
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private static func rect(_ value: Any?) -> CGRect? {
|
|
201
|
+
guard let map = value as? NSDictionary,
|
|
202
|
+
let x = (map["x"] as? NSNumber)?.doubleValue,
|
|
203
|
+
let y = (map["y"] as? NSNumber)?.doubleValue,
|
|
204
|
+
let width = (map["width"] as? NSNumber)?.doubleValue,
|
|
205
|
+
let height = (map["height"] as? NSNumber)?.doubleValue
|
|
206
|
+
else { return nil }
|
|
207
|
+
|
|
208
|
+
return CGRect(x: x, y: y, width: width, height: height)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
private static func text(_ value: Any?) -> String? {
|
|
212
|
+
guard let string = value as? String, !string.isEmpty else { return nil }
|
|
213
|
+
|
|
214
|
+
return string
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/// Colors cross the bridge as hex strings, matching the Android side.
|
|
218
|
+
private static func color(_ value: Any?) -> UIColor? {
|
|
219
|
+
guard var hex = value as? String else { return nil }
|
|
220
|
+
|
|
221
|
+
hex = hex.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
222
|
+
if hex.hasPrefix("#") { hex.removeFirst() }
|
|
223
|
+
|
|
224
|
+
if hex.count == 3 {
|
|
225
|
+
hex = hex.map { "\($0)\($0)" }.joined()
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
guard hex.count == 6 || hex.count == 8, let value = UInt64(hex, radix: 16) else {
|
|
229
|
+
return nil
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
let hasAlpha = hex.count == 8
|
|
233
|
+
let alpha = hasAlpha ? CGFloat((value >> 24) & 0xFF) / 255 : 1
|
|
234
|
+
let red = CGFloat((value >> 16) & 0xFF) / 255
|
|
235
|
+
let green = CGFloat((value >> 8) & 0xFF) / 255
|
|
236
|
+
let blue = CGFloat(value & 0xFF) / 255
|
|
237
|
+
|
|
238
|
+
return UIColor(red: red, green: green, blue: blue, alpha: alpha)
|
|
239
|
+
}
|
|
240
|
+
}
|
package/jest/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ActionSheetOptionsInterface } from 'react-native-unified-action-sheet';
|
|
2
|
+
|
|
3
|
+
/// Queues the index the next sheet resolves with. Pass nothing to go back to
|
|
4
|
+
/// resolving with no selection.
|
|
5
|
+
export declare function setNextButtonIndex(index?: number): void;
|
|
6
|
+
|
|
7
|
+
export declare const showActionSheetWithOptions: jest.Mock<
|
|
8
|
+
Promise<number | undefined>,
|
|
9
|
+
[ActionSheetOptionsInterface]
|
|
10
|
+
>;
|
|
11
|
+
export declare const dismissActionSheet: jest.Mock<void, []>;
|
|
12
|
+
export declare const dismissAllActionSheets: jest.Mock<void, []>;
|
package/jest/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/* global jest */
|
|
2
|
+
/**
|
|
3
|
+
* A drop-in mock of the public API, so a screen that opens a sheet can be
|
|
4
|
+
* tested without the native module.
|
|
5
|
+
*
|
|
6
|
+
* jest.mock('react-native-unified-action-sheet', () =>
|
|
7
|
+
* require('react-native-unified-action-sheet/jest')
|
|
8
|
+
* );
|
|
9
|
+
*
|
|
10
|
+
* By default every sheet resolves with no selection. To simulate a tap, queue
|
|
11
|
+
* the index the next sheet should resolve with; the pressed button's onPress
|
|
12
|
+
* runs, exactly as it would in the real module:
|
|
13
|
+
*
|
|
14
|
+
* setNextButtonIndex(0);
|
|
15
|
+
* await openTheSheet();
|
|
16
|
+
*
|
|
17
|
+
* Prefer that over mockResolvedValueOnce, which replaces the implementation and
|
|
18
|
+
* so skips onPress.
|
|
19
|
+
*/
|
|
20
|
+
let nextButtonIndex;
|
|
21
|
+
|
|
22
|
+
const setNextButtonIndex = (index) => {
|
|
23
|
+
nextButtonIndex = index;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const showActionSheetWithOptions = jest.fn((options) => {
|
|
27
|
+
const buttonIndex = nextButtonIndex;
|
|
28
|
+
nextButtonIndex = undefined;
|
|
29
|
+
|
|
30
|
+
if (buttonIndex != null) {
|
|
31
|
+
const button = options && options.options && options.options[buttonIndex];
|
|
32
|
+
if (button && typeof button.onPress === 'function') button.onPress();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return Promise.resolve(buttonIndex);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const dismissActionSheet = jest.fn();
|
|
39
|
+
const dismissAllActionSheets = jest.fn();
|
|
40
|
+
|
|
41
|
+
module.exports = {
|
|
42
|
+
setNextButtonIndex,
|
|
43
|
+
showActionSheetWithOptions,
|
|
44
|
+
dismissActionSheet,
|
|
45
|
+
dismissAllActionSheets,
|
|
46
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('UnifiedActionSheet');
|
|
9
|
+
//# sourceMappingURL=NativeUnifiedActionSheet.js.map
|
|
@@ -0,0 +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,GA4BtDC,gCAAmB,CAACC,YAAY,CAAO,oBAAoB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["action-sheet-options.interface.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.showActionSheetWithOptions = exports.dismissAllActionSheets = exports.dismissActionSheet = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
const DISMISSED_BY_API = -2;
|
|
9
|
+
|
|
10
|
+
/// The native wire format is index-based; the public API is not. Nothing below
|
|
11
|
+
/// index.tsx knows buttons are described as objects.
|
|
12
|
+
|
|
13
|
+
const nativeModule = () => require('./NativeUnifiedActionSheet').default;
|
|
14
|
+
|
|
15
|
+
/// Flattens the buttons into the labels and index sets the native side expects.
|
|
16
|
+
/// Only the first button styled 'cancel' counts, since there is one cancel row.
|
|
17
|
+
const toWireOptions = ({
|
|
18
|
+
options,
|
|
19
|
+
// Dropped deliberately: the anchor is a ref, and only its measured rect
|
|
20
|
+
// crosses the bridge. Omit<> would not strip it at runtime.
|
|
21
|
+
anchor: _anchor,
|
|
22
|
+
...rest
|
|
23
|
+
}) => {
|
|
24
|
+
const labels = [];
|
|
25
|
+
const destructive = [];
|
|
26
|
+
const disabled = [];
|
|
27
|
+
let cancelButtonIndex;
|
|
28
|
+
options.forEach((button, index) => {
|
|
29
|
+
labels.push(button.label);
|
|
30
|
+
if (button.style === 'destructive') destructive.push(index);
|
|
31
|
+
if (button.style === 'cancel' && cancelButtonIndex == null) {
|
|
32
|
+
cancelButtonIndex = index;
|
|
33
|
+
}
|
|
34
|
+
if (button.disabled) disabled.push(index);
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
...rest,
|
|
38
|
+
options: labels,
|
|
39
|
+
...(cancelButtonIndex == null ? {} : {
|
|
40
|
+
cancelButtonIndex
|
|
41
|
+
}),
|
|
42
|
+
...(destructive.length === 0 ? {} : {
|
|
43
|
+
destructiveButtonIndices: destructive
|
|
44
|
+
}),
|
|
45
|
+
...(disabled.length === 0 ? {} : {
|
|
46
|
+
disabledButtonIndices: disabled
|
|
47
|
+
})
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const showWithNativeModule = options => nativeModule().showActionSheetWithOptions(options)
|
|
51
|
+
// A programmatic dismiss resolves with no index rather than a selection.
|
|
52
|
+
.then(buttonIndex => buttonIndex === DISMISSED_BY_API ? undefined : buttonIndex).catch(() => options.cancelButtonIndex ?? -1);
|
|
53
|
+
|
|
54
|
+
/// The anchor is measured in JS and sent across as a rect, so neither native
|
|
55
|
+
/// module has to resolve a view: a ref's own measureInWindow is the supported
|
|
56
|
+
/// way to do this on both architectures, unlike a react tag.
|
|
57
|
+
const withAnchorRect = (wire, anchor) => {
|
|
58
|
+
const target = anchor && 'measureInWindow' in anchor ? anchor : anchor?.current ?? null;
|
|
59
|
+
if (!target) return Promise.resolve(wire);
|
|
60
|
+
return new Promise(resolve => {
|
|
61
|
+
target.measureInWindow((x, y, width, height) => {
|
|
62
|
+
const measured = typeof x === 'number' && typeof y === 'number';
|
|
63
|
+
resolve(measured ? {
|
|
64
|
+
...wire,
|
|
65
|
+
anchorRect: {
|
|
66
|
+
x,
|
|
67
|
+
y,
|
|
68
|
+
width,
|
|
69
|
+
height
|
|
70
|
+
}
|
|
71
|
+
} : wire);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const showActionSheetWithOptions = options => {
|
|
76
|
+
const wire = toWireOptions(options);
|
|
77
|
+
|
|
78
|
+
// -1 and undefined index nothing, so optional chaining covers both.
|
|
79
|
+
const press = buttonIndex => {
|
|
80
|
+
if (buttonIndex != null) options.options[buttonIndex]?.onPress?.();
|
|
81
|
+
return buttonIndex;
|
|
82
|
+
};
|
|
83
|
+
if (_reactNative.Platform.OS !== 'ios' && _reactNative.Platform.OS !== 'android') {
|
|
84
|
+
return Promise.resolve(undefined);
|
|
85
|
+
}
|
|
86
|
+
return withAnchorRect(wire, options.anchor).then(showWithNativeModule).then(press);
|
|
87
|
+
};
|
|
88
|
+
exports.showActionSheetWithOptions = showActionSheetWithOptions;
|
|
89
|
+
const dismissActionSheet = () => {
|
|
90
|
+
if (_reactNative.Platform.OS === 'ios' || _reactNative.Platform.OS === 'android') {
|
|
91
|
+
nativeModule().dismissActionSheet();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/// Closes every open sheet, not just the top-most one. Each resolves with no
|
|
96
|
+
/// index, exactly as dismissActionSheet() does.
|
|
97
|
+
exports.dismissActionSheet = dismissActionSheet;
|
|
98
|
+
const dismissAllActionSheets = () => {
|
|
99
|
+
if (_reactNative.Platform.OS === 'ios' || _reactNative.Platform.OS === 'android') {
|
|
100
|
+
nativeModule().dismissAllActionSheets();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
exports.dismissAllActionSheets = dismissAllActionSheets;
|
|
104
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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;AAaA,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,KAAkB;EAC9C,MAAMC,MAAgB,GAAG,EAAE;EAC3B,MAAMC,WAAqB,GAAG,EAAE;EAChC,MAAMC,QAAkB,GAAG,EAAE;EAC7B,IAAIC,iBAAqC;EAEzCP,OAAO,CAACQ,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;MAC1DA,iBAAiB,GAAGG,KAAK;IAC3B;IACA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,sBAAsB,CAAC,CAAC;EACzC;AACF,CAAC;AAACF,OAAA,CAAAE,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeUnifiedActionSheet.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAA0B,cAAc;AA4BpE,eAAeA,mBAAmB,CAACC,YAAY,CAAO,oBAAoB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["action-sheet-options.interface.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
const DISMISSED_BY_API = -2;
|
|
5
|
+
|
|
6
|
+
/// The native wire format is index-based; the public API is not. Nothing below
|
|
7
|
+
/// index.tsx knows buttons are described as objects.
|
|
8
|
+
|
|
9
|
+
const nativeModule = () => require('./NativeUnifiedActionSheet').default;
|
|
10
|
+
|
|
11
|
+
/// Flattens the buttons into the labels and index sets the native side expects.
|
|
12
|
+
/// Only the first button styled 'cancel' counts, since there is one cancel row.
|
|
13
|
+
const toWireOptions = ({
|
|
14
|
+
options,
|
|
15
|
+
// Dropped deliberately: the anchor is a ref, and only its measured rect
|
|
16
|
+
// crosses the bridge. Omit<> would not strip it at runtime.
|
|
17
|
+
anchor: _anchor,
|
|
18
|
+
...rest
|
|
19
|
+
}) => {
|
|
20
|
+
const labels = [];
|
|
21
|
+
const destructive = [];
|
|
22
|
+
const disabled = [];
|
|
23
|
+
let cancelButtonIndex;
|
|
24
|
+
options.forEach((button, index) => {
|
|
25
|
+
labels.push(button.label);
|
|
26
|
+
if (button.style === 'destructive') destructive.push(index);
|
|
27
|
+
if (button.style === 'cancel' && cancelButtonIndex == null) {
|
|
28
|
+
cancelButtonIndex = index;
|
|
29
|
+
}
|
|
30
|
+
if (button.disabled) disabled.push(index);
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
...rest,
|
|
34
|
+
options: labels,
|
|
35
|
+
...(cancelButtonIndex == null ? {} : {
|
|
36
|
+
cancelButtonIndex
|
|
37
|
+
}),
|
|
38
|
+
...(destructive.length === 0 ? {} : {
|
|
39
|
+
destructiveButtonIndices: destructive
|
|
40
|
+
}),
|
|
41
|
+
...(disabled.length === 0 ? {} : {
|
|
42
|
+
disabledButtonIndices: disabled
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const showWithNativeModule = options => nativeModule().showActionSheetWithOptions(options)
|
|
47
|
+
// A programmatic dismiss resolves with no index rather than a selection.
|
|
48
|
+
.then(buttonIndex => buttonIndex === DISMISSED_BY_API ? undefined : buttonIndex).catch(() => options.cancelButtonIndex ?? -1);
|
|
49
|
+
|
|
50
|
+
/// The anchor is measured in JS and sent across as a rect, so neither native
|
|
51
|
+
/// module has to resolve a view: a ref's own measureInWindow is the supported
|
|
52
|
+
/// way to do this on both architectures, unlike a react tag.
|
|
53
|
+
const withAnchorRect = (wire, anchor) => {
|
|
54
|
+
const target = anchor && 'measureInWindow' in anchor ? anchor : anchor?.current ?? null;
|
|
55
|
+
if (!target) return Promise.resolve(wire);
|
|
56
|
+
return new Promise(resolve => {
|
|
57
|
+
target.measureInWindow((x, y, width, height) => {
|
|
58
|
+
const measured = typeof x === 'number' && typeof y === 'number';
|
|
59
|
+
resolve(measured ? {
|
|
60
|
+
...wire,
|
|
61
|
+
anchorRect: {
|
|
62
|
+
x,
|
|
63
|
+
y,
|
|
64
|
+
width,
|
|
65
|
+
height
|
|
66
|
+
}
|
|
67
|
+
} : wire);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
export const showActionSheetWithOptions = options => {
|
|
72
|
+
const wire = toWireOptions(options);
|
|
73
|
+
|
|
74
|
+
// -1 and undefined index nothing, so optional chaining covers both.
|
|
75
|
+
const press = buttonIndex => {
|
|
76
|
+
if (buttonIndex != null) options.options[buttonIndex]?.onPress?.();
|
|
77
|
+
return buttonIndex;
|
|
78
|
+
};
|
|
79
|
+
if (Platform.OS !== 'ios' && Platform.OS !== 'android') {
|
|
80
|
+
return Promise.resolve(undefined);
|
|
81
|
+
}
|
|
82
|
+
return withAnchorRect(wire, options.anchor).then(showWithNativeModule).then(press);
|
|
83
|
+
};
|
|
84
|
+
export const dismissActionSheet = () => {
|
|
85
|
+
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
86
|
+
nativeModule().dismissActionSheet();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/// Closes every open sheet, not just the top-most one. Each resolves with no
|
|
91
|
+
/// index, exactly as dismissActionSheet() does.
|
|
92
|
+
export const dismissAllActionSheets = () => {
|
|
93
|
+
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
94
|
+
nativeModule().dismissAllActionSheets();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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;AAavC,MAAMC,gBAAgB,GAAG,CAAC,CAAC;;AAE3B;AACA;;AASA,MAAMC,YAAY,GAAGA,CAAA,KACnBC,OAAO,CAAC,4BAA4B,CAAC,C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Ac,CAACC,IAAI,EAAExB,OAAO,CAACC,MAAM,CAAC,CACxCkB,IAAI,CAACF,oBAAoB,CAAC,CAC1BE,IAAI,CAACiB,KAAK,CAAC;AAChB,CAAC;AAED,OAAO,MAAMG,kBAAkB,GAAGA,CAAA,KAAY;EAC5C,IAAI7C,QAAQ,CAAC4C,EAAE,KAAK,KAAK,IAAI5C,QAAQ,CAAC4C,EAAE,KAAK,SAAS,EAAE;IACtD1C,YAAY,CAAC,CAAC,CAAC2C,kBAAkB,CAAC,CAAC;EACrC;AACF,CAAC;;AAED;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAGA,CAAA,KAAY;EAChD,IAAI9C,QAAQ,CAAC4C,EAAE,KAAK,KAAK,IAAI5C,QAAQ,CAAC4C,EAAE,KAAK,SAAS,EAAE;IACtD1C,YAAY,CAAC,CAAC,CAAC4C,sBAAsB,CAAC,CAAC;EACzC;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type TurboModule } from 'react-native';
|
|
2
|
+
export interface Spec extends TurboModule {
|
|
3
|
+
showActionSheetWithOptions(options: {
|
|
4
|
+
options: string[];
|
|
5
|
+
cancelButtonIndex?: number;
|
|
6
|
+
destructiveButtonIndices?: number[];
|
|
7
|
+
title?: string;
|
|
8
|
+
message?: string;
|
|
9
|
+
tintColor?: string;
|
|
10
|
+
cancelButtonTintColor?: string;
|
|
11
|
+
destructiveColor?: string;
|
|
12
|
+
buttonTextAlignment?: string;
|
|
13
|
+
disabledButtonIndices?: number[];
|
|
14
|
+
userInterfaceStyle?: string;
|
|
15
|
+
presentationStyle?: string;
|
|
16
|
+
anchorAlignment?: string;
|
|
17
|
+
anchorRect?: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
};
|
|
23
|
+
}): Promise<number>;
|
|
24
|
+
dismissActionSheet(): void;
|
|
25
|
+
dismissAllActionSheets(): void;
|
|
26
|
+
}
|
|
27
|
+
declare const _default: Spec;
|
|
28
|
+
export default _default;
|
|
29
|
+
//# sourceMappingURL=NativeUnifiedActionSheet.d.ts.map
|
|
@@ -0,0 +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,CAAC;QAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,UAAU,CAAC,EAAE;YACX,CAAC,EAAE,MAAM,CAAC;YACV,CAAC,EAAE,MAAM,CAAC;YACV,KAAK,EAAE,MAAM,CAAC;YACd,MAAM,EAAE,MAAM,CAAC;SAChB,CAAC;KACH,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,kBAAkB,IAAI,IAAI,CAAC;IAC3B,sBAAsB,IAAI,IAAI,CAAC;CAChC;;AAED,wBAA4E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface ActionSheetButtonInterface {
|
|
2
|
+
label: string;
|
|
3
|
+
style?: 'cancel' | 'destructive';
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
onPress?: () => void;
|
|
6
|
+
}
|
|
7
|
+
export interface ActionSheetAnchorInterface {
|
|
8
|
+
measureInWindow: (callback: (x: number, y: number, width: number, height: number) => void) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface ActionSheetCommonOptionsInterface {
|
|
11
|
+
options: ActionSheetButtonInterface[];
|
|
12
|
+
title?: string;
|
|
13
|
+
message?: string;
|
|
14
|
+
tintColor?: string;
|
|
15
|
+
cancelButtonTintColor?: string;
|
|
16
|
+
userInterfaceStyle?: 'light' | 'dark';
|
|
17
|
+
anchor?: ActionSheetAnchorInterface | {
|
|
18
|
+
current: ActionSheetAnchorInterface | null;
|
|
19
|
+
} | null;
|
|
20
|
+
destructiveColor?: string;
|
|
21
|
+
presentationStyle?: 'centered' | 'anchored';
|
|
22
|
+
}
|
|
23
|
+
export interface ActionSheetAndroidOptionsInterface {
|
|
24
|
+
buttonTextAlignment?: 'start' | 'center';
|
|
25
|
+
anchorAlignment?: 'start' | 'center';
|
|
26
|
+
}
|
|
27
|
+
export interface ActionSheetOptionsInterface extends ActionSheetCommonOptionsInterface, ActionSheetAndroidOptionsInterface {
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=action-sheet-options.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-sheet-options.interface.d.ts","sourceRoot":"","sources":["../../../../src/action-sheet-options.interface.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAGnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAID,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,iCAAiC;IAChD,OAAO,EAAE,0BAA0B,EAAE,CAAC;IACtC,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,kBAAkB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACtC,MAAM,CAAC,EACH,0BAA0B,GAC1B;QAAE,OAAO,EAAE,0BAA0B,GAAG,IAAI,CAAA;KAAE,GAC9C,IAAI,CAAC;IACT,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;CAC7C;AAED,MAAM,WAAW,kCAAkC;IACjD,mBAAmB,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzC,eAAe,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CACtC;AAED,MAAM,WAAW,2BACf,SACE,iCAAiC,EACjC,kCAAkC;CAAG"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ActionSheetOptionsInterface } from './action-sheet-options.interface';
|
|
2
|
+
export type { ActionSheetAnchorInterface, ActionSheetButtonInterface, ActionSheetCommonOptionsInterface, ActionSheetAndroidOptionsInterface, ActionSheetOptionsInterface, } from './action-sheet-options.interface';
|
|
3
|
+
export declare const showActionSheetWithOptions: (options: ActionSheetOptionsInterface) => Promise<number | undefined>;
|
|
4
|
+
export declare const dismissActionSheet: () => void;
|
|
5
|
+
export declare const dismissAllActionSheets: () => void;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;AAsF1C,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|