react-native-unified-action-sheet 0.2.0 → 0.4.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 +87 -1
- package/README.md +44 -112
- package/android/build.gradle +28 -1
- package/android/src/main/java/com/unifiedactionsheet/ActionSheetOptions.kt +41 -2
- package/android/src/main/java/com/unifiedactionsheet/PromptOptions.kt +27 -5
- package/android/src/main/java/com/unifiedactionsheet/SheetContentBuilder.kt +75 -9
- package/android/src/main/java/com/unifiedactionsheet/SheetPresenters.kt +61 -10
- package/android/src/main/java/com/unifiedactionsheet/UnifiedActionSheetModule.kt +14 -7
- package/android/src/material/java/com/unifiedactionsheet/BottomSheetPresenterFactory.kt +10 -0
- package/android/src/material/java/com/unifiedactionsheet/MaterialBottomSheetPresenter.kt +153 -0
- package/android/src/material/res/values/unified_action_sheet_bottom_sheet.xml +22 -0
- package/android/src/noMaterial/java/com/unifiedactionsheet/BottomSheetPresenterFactory.kt +10 -0
- package/app.plugin.js +1 -0
- package/ios/BottomSheetViewController.swift +210 -0
- package/ios/UnifiedActionSheet.mm +51 -5
- package/ios/UnifiedActionSheetImpl.swift +259 -22
- package/jest/index.d.ts +12 -9
- package/jest/index.js +37 -18
- package/lib/commonjs/NativeUnifiedActionSheet.js.map +1 -1
- package/lib/commonjs/index.js +102 -18
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeUnifiedActionSheet.js.map +1 -1
- package/lib/module/index.js +102 -18
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/NativeUnifiedActionSheet.d.ts +10 -1
- package/lib/typescript/commonjs/src/NativeUnifiedActionSheet.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/action-sheet-options.interface.d.ts +5 -2
- package/lib/typescript/commonjs/src/action-sheet-options.interface.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/common-options.interface.d.ts +9 -0
- package/lib/typescript/commonjs/src/common-options.interface.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +6 -6
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/prompt-options.interface.d.ts +10 -6
- package/lib/typescript/commonjs/src/prompt-options.interface.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeUnifiedActionSheet.d.ts +10 -1
- package/lib/typescript/module/src/NativeUnifiedActionSheet.d.ts.map +1 -1
- package/lib/typescript/module/src/action-sheet-options.interface.d.ts +5 -2
- package/lib/typescript/module/src/action-sheet-options.interface.d.ts.map +1 -1
- package/lib/typescript/module/src/common-options.interface.d.ts +9 -0
- package/lib/typescript/module/src/common-options.interface.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +6 -6
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/prompt-options.interface.d.ts +10 -6
- package/lib/typescript/module/src/prompt-options.interface.d.ts.map +1 -1
- package/package.json +12 -2
- package/plugin/withUnifiedActionSheet.js +58 -0
- package/src/NativeUnifiedActionSheet.ts +12 -2
- package/src/action-sheet-options.interface.ts +12 -1
- package/src/common-options.interface.ts +18 -0
- package/src/index.tsx +147 -42
- package/src/prompt-options.interface.ts +21 -5
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type TurboModule } from 'react-native';
|
|
2
2
|
export interface Spec extends TurboModule {
|
|
3
|
+
getConstants(): {
|
|
4
|
+
isMaterialEnabled: boolean;
|
|
5
|
+
};
|
|
3
6
|
showActionSheetWithOptions(options: {
|
|
4
7
|
options: string[];
|
|
5
8
|
cancelButtonIndex?: number;
|
|
@@ -14,6 +17,8 @@ export interface Spec extends TurboModule {
|
|
|
14
17
|
userInterfaceStyle?: string;
|
|
15
18
|
presentationStyle?: string;
|
|
16
19
|
anchorAlignment?: string;
|
|
20
|
+
preferredButtonIndex?: number;
|
|
21
|
+
detents?: string[];
|
|
17
22
|
anchorRect?: {
|
|
18
23
|
x: number;
|
|
19
24
|
y: number;
|
|
@@ -28,10 +33,13 @@ export interface Spec extends TurboModule {
|
|
|
28
33
|
disabledButtonIndices?: number[];
|
|
29
34
|
title?: string;
|
|
30
35
|
message?: string;
|
|
36
|
+
preferredButtonIndex?: number;
|
|
37
|
+
textRequiredButtonIndices?: number[];
|
|
38
|
+
type?: string;
|
|
31
39
|
placeholder?: string;
|
|
40
|
+
passwordPlaceholder?: string;
|
|
32
41
|
defaultValue?: string;
|
|
33
42
|
keyboardType?: string;
|
|
34
|
-
secureTextEntry?: boolean;
|
|
35
43
|
tintColor?: string;
|
|
36
44
|
cancelButtonTintColor?: string;
|
|
37
45
|
destructiveColor?: string;
|
|
@@ -40,6 +48,7 @@ export interface Spec extends TurboModule {
|
|
|
40
48
|
}): Promise<{
|
|
41
49
|
buttonIndex: number;
|
|
42
50
|
text: string;
|
|
51
|
+
password: string;
|
|
43
52
|
}>;
|
|
44
53
|
dismissActionSheet(): void;
|
|
45
54
|
dismissAllActionSheets(): void;
|
|
@@ -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,kBAA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AAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrE,kBAAkB,IAAI,IAAI,CAAC;IAC3B,sBAAsB,IAAI,IAAI,CAAC;CAChC;;AAED,wBAA4E"}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import type { BaseAndroidOptionsInterface, BaseButtonInterface, BaseOptionsInterface } from './common-options.interface.js';
|
|
1
|
+
import type { BaseAndroidOptionsInterface, BaseButtonInterface, BaseOptionsInterface, CloseResultInterface } from './common-options.interface.js';
|
|
2
2
|
export interface ActionSheetButtonInterface extends BaseButtonInterface {
|
|
3
3
|
onPress?: () => void;
|
|
4
4
|
}
|
|
5
5
|
export interface ActionSheetAnchorInterface {
|
|
6
6
|
measureInWindow: (callback: (x: number, y: number, width: number, height: number) => void) => void;
|
|
7
7
|
}
|
|
8
|
+
export type ActionSheetDetent = 'auto' | 'medium' | 'large';
|
|
8
9
|
export interface ActionSheetCommonOptionsInterface extends BaseOptionsInterface {
|
|
9
10
|
options: ActionSheetButtonInterface[];
|
|
10
11
|
anchor?: ActionSheetAnchorInterface | {
|
|
11
12
|
current: ActionSheetAnchorInterface | null;
|
|
12
13
|
} | null;
|
|
13
|
-
presentationStyle?: 'centered' | 'anchored';
|
|
14
|
+
presentationStyle?: 'centered' | 'anchored' | 'bottom';
|
|
15
|
+
detents?: ActionSheetDetent[];
|
|
14
16
|
}
|
|
15
17
|
export interface ActionSheetAndroidOptionsInterface extends BaseAndroidOptionsInterface {
|
|
16
18
|
anchorAlignment?: 'start' | 'center';
|
|
17
19
|
}
|
|
18
20
|
export interface ActionSheetOptionsInterface extends ActionSheetCommonOptionsInterface, ActionSheetAndroidOptionsInterface {
|
|
19
21
|
}
|
|
22
|
+
export type ActionSheetResultInterface = CloseResultInterface;
|
|
20
23
|
//# sourceMappingURL=action-sheet-options.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,+BAA4B,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;
|
|
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,EACpB,oBAAoB,EACrB,MAAM,+BAA4B,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;AAID,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE5D,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,GAAG,QAAQ,CAAC;IAIvD,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,kCAAmC,SAAQ,2BAA2B;IACrF,eAAe,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CACtC;AAED,MAAM,WAAW,2BACf,SACE,iCAAiC,EACjC,kCAAkC;CAAG;AAEzC,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,CAAC"}
|
|
@@ -2,6 +2,7 @@ export interface BaseButtonInterface {
|
|
|
2
2
|
label: string;
|
|
3
3
|
style?: 'cancel' | 'destructive';
|
|
4
4
|
disabled?: boolean;
|
|
5
|
+
preferred?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export interface BaseOptionsInterface {
|
|
7
8
|
title?: string;
|
|
@@ -14,4 +15,12 @@ export interface BaseOptionsInterface {
|
|
|
14
15
|
export interface BaseAndroidOptionsInterface {
|
|
15
16
|
buttonTextAlignment?: 'start' | 'center';
|
|
16
17
|
}
|
|
18
|
+
export type CloseReason = 'selected' | 'cancelled' | 'dismissed';
|
|
19
|
+
export type CloseResultInterface = {
|
|
20
|
+
reason: 'selected' | 'cancelled';
|
|
21
|
+
buttonIndex: number;
|
|
22
|
+
} | {
|
|
23
|
+
reason: 'dismissed';
|
|
24
|
+
buttonIndex: undefined;
|
|
25
|
+
};
|
|
17
26
|
//# sourceMappingURL=common-options.interface.d.ts.map
|
|
@@ -1 +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;
|
|
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;IAKnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;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;AAOD,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;AAIjE,MAAM,MAAM,oBAAoB,GAC5B;IAAE,MAAM,EAAE,UAAU,GAAG,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,SAAS,CAAA;CAAE,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ActionSheetOptionsInterface } from './action-sheet-options.interface.js';
|
|
2
|
-
export type { BaseButtonInterface, BaseOptionsInterface, BaseAndroidOptionsInterface, } from './common-options.interface.js';
|
|
3
|
-
export type { PromptButtonInterface, PromptCommonOptionsInterface, PromptAndroidOptionsInterface, PromptOptionsInterface, PromptResultInterface, } from './prompt-options.interface.js';
|
|
1
|
+
import type { ActionSheetOptionsInterface, ActionSheetResultInterface } from './action-sheet-options.interface.js';
|
|
4
2
|
import type { PromptOptionsInterface, PromptResultInterface } from './prompt-options.interface.js';
|
|
5
|
-
export type {
|
|
6
|
-
export
|
|
3
|
+
export type { BaseButtonInterface, BaseOptionsInterface, BaseAndroidOptionsInterface, CloseReason, CloseResultInterface, } from './common-options.interface.js';
|
|
4
|
+
export type { PromptButtonInterface, PromptCommonOptionsInterface, PromptAndroidOptionsInterface, PromptOptionsInterface, PromptResultInterface, PromptValuesInterface, } from './prompt-options.interface.js';
|
|
5
|
+
export type { ActionSheetAnchorInterface, ActionSheetButtonInterface, ActionSheetCommonOptionsInterface, ActionSheetAndroidOptionsInterface, ActionSheetDetent, ActionSheetOptionsInterface, ActionSheetResultInterface, } from './action-sheet-options.interface.js';
|
|
6
|
+
export declare const showActionSheetWithOptions: (options: ActionSheetOptionsInterface) => Promise<ActionSheetResultInterface>;
|
|
7
7
|
export declare const dismissActionSheet: () => void;
|
|
8
8
|
export declare const dismissAllActionSheets: () => void;
|
|
9
|
-
export declare const showPromptWithOptions: (options: PromptOptionsInterface) => Promise<PromptResultInterface
|
|
9
|
+
export declare const showPromptWithOptions: (options: PromptOptionsInterface) => Promise<PromptResultInterface>;
|
|
10
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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,2BAA2B,EAC3B,0BAA0B,EAC3B,MAAM,qCAAkC,CAAC;AAK1C,OAAO,KAAK,EAEV,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,+BAA4B,CAAC;AAEpC,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,EAC3B,WAAW,EACX,oBAAoB,GACrB,MAAM,+BAA4B,CAAC;AAEpC,YAAY,EACV,qBAAqB,EACrB,4BAA4B,EAC5B,6BAA6B,EAC7B,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,+BAA4B,CAAC;AAEpC,YAAY,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,iCAAiC,EACjC,kCAAkC,EAClC,iBAAiB,EACjB,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,qCAAkC,CAAC;AAiK1C,eAAO,MAAM,0BAA0B,GACrC,SAAS,2BAA2B,KACnC,OAAO,CAAC,0BAA0B,CAwBpC,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,CA8C/B,CAAC"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import type { BaseAndroidOptionsInterface, BaseButtonInterface, BaseOptionsInterface } from './common-options.interface.js';
|
|
1
|
+
import type { BaseAndroidOptionsInterface, BaseButtonInterface, BaseOptionsInterface, CloseResultInterface } from './common-options.interface.js';
|
|
2
|
+
export interface PromptValuesInterface {
|
|
3
|
+
text: string;
|
|
4
|
+
password?: string;
|
|
5
|
+
}
|
|
2
6
|
export interface PromptButtonInterface extends BaseButtonInterface {
|
|
3
|
-
onPress?: (
|
|
7
|
+
onPress?: (values: PromptValuesInterface) => void;
|
|
8
|
+
requiresText?: boolean;
|
|
4
9
|
}
|
|
5
10
|
export interface PromptCommonOptionsInterface extends BaseOptionsInterface {
|
|
6
11
|
options: PromptButtonInterface[];
|
|
12
|
+
type?: 'plain-text' | 'secure-text' | 'login-password';
|
|
7
13
|
placeholder?: string;
|
|
14
|
+
passwordPlaceholder?: string;
|
|
8
15
|
defaultValue?: string;
|
|
9
16
|
keyboardType?: 'default' | 'email-address' | 'numeric' | 'phone-pad' | 'url';
|
|
10
17
|
secureTextEntry?: boolean;
|
|
@@ -12,8 +19,5 @@ export interface PromptCommonOptionsInterface extends BaseOptionsInterface {
|
|
|
12
19
|
export type PromptAndroidOptionsInterface = BaseAndroidOptionsInterface;
|
|
13
20
|
export interface PromptOptionsInterface extends PromptCommonOptionsInterface, PromptAndroidOptionsInterface {
|
|
14
21
|
}
|
|
15
|
-
export
|
|
16
|
-
buttonIndex: number;
|
|
17
|
-
text: string;
|
|
18
|
-
}
|
|
22
|
+
export type PromptResultInterface = CloseResultInterface & PromptValuesInterface;
|
|
19
23
|
//# sourceMappingURL=prompt-options.interface.d.ts.map
|
|
@@ -1 +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,+BAA4B,CAAC;
|
|
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,EACpB,oBAAoB,EACrB,MAAM,+BAA4B,CAAC;AAIpC,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAGlD,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,4BAA6B,SAAQ,oBAAoB;IACxE,OAAO,EAAE,qBAAqB,EAAE,CAAC;IAGjC,IAAI,CAAC,EAAE,YAAY,GAAG,aAAa,GAAG,gBAAgB,CAAC;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,SAAS,GAAG,eAAe,GAAG,SAAS,GAAG,WAAW,GAAG,KAAK,CAAC;IAG7E,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,MAAM,6BAA6B,GAAG,2BAA2B,CAAC;AAExE,MAAM,WAAW,sBACf,SAAQ,4BAA4B,EAAE,6BAA6B;CAAG;AAExE,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,GACtD,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-unified-action-sheet",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Unified action sheet for React Native
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Unified native action sheet for React Native, one API on iOS and Android",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"types": "./lib/typescript/commonjs/src/index.d.ts",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"./package.json": "./package.json",
|
|
21
|
+
"./app.plugin.js": "./app.plugin.js",
|
|
21
22
|
"./jest": {
|
|
22
23
|
"types": "./jest/index.d.ts",
|
|
23
24
|
"default": "./jest/index.js"
|
|
@@ -27,6 +28,8 @@
|
|
|
27
28
|
"src",
|
|
28
29
|
"lib",
|
|
29
30
|
"jest",
|
|
31
|
+
"plugin",
|
|
32
|
+
"app.plugin.js",
|
|
30
33
|
"android",
|
|
31
34
|
"ios",
|
|
32
35
|
"*.podspec",
|
|
@@ -56,6 +59,7 @@
|
|
|
56
59
|
"action-sheet",
|
|
57
60
|
"actionsheet",
|
|
58
61
|
"action-sheet-ios",
|
|
62
|
+
"bottom-sheet",
|
|
59
63
|
"turbomodule"
|
|
60
64
|
],
|
|
61
65
|
"repository": {
|
|
@@ -97,9 +101,15 @@
|
|
|
97
101
|
"typescript": "^6.0.3"
|
|
98
102
|
},
|
|
99
103
|
"peerDependencies": {
|
|
104
|
+
"@expo/config-plugins": "*",
|
|
100
105
|
"react": "*",
|
|
101
106
|
"react-native": ">=0.81.0"
|
|
102
107
|
},
|
|
108
|
+
"peerDependenciesMeta": {
|
|
109
|
+
"@expo/config-plugins": {
|
|
110
|
+
"optional": true
|
|
111
|
+
}
|
|
112
|
+
},
|
|
103
113
|
"workspaces": [
|
|
104
114
|
"example"
|
|
105
115
|
],
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expo config plugin. Writes the gradle properties that opt the Android build
|
|
3
|
+
* into Material, which presentationStyle 'bottom' needs:
|
|
4
|
+
*
|
|
5
|
+
* plugins: [['react-native-unified-action-sheet', { material: true }]]
|
|
6
|
+
*
|
|
7
|
+
* Options:
|
|
8
|
+
* material enable the Material bottom sheet (default false)
|
|
9
|
+
* materialVersion override the Material version the library pins
|
|
10
|
+
*/
|
|
11
|
+
const MATERIAL_KEY = 'unifiedActionSheet.material';
|
|
12
|
+
const MATERIAL_VERSION_KEY = 'unifiedActionSheet.materialVersion';
|
|
13
|
+
|
|
14
|
+
/// Pure, so it can be tested without Expo. Drops any previous value of both
|
|
15
|
+
/// keys before adding the current ones: prebuild runs repeatedly, and turning
|
|
16
|
+
/// the option off must remove what an earlier run wrote.
|
|
17
|
+
const applyMaterialProperties = (properties, options = {}) => {
|
|
18
|
+
const next = properties.filter(
|
|
19
|
+
(item) =>
|
|
20
|
+
!(
|
|
21
|
+
item.type === 'property' &&
|
|
22
|
+
(item.key === MATERIAL_KEY || item.key === MATERIAL_VERSION_KEY)
|
|
23
|
+
)
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
if (options.material) {
|
|
27
|
+
next.push({ type: 'property', key: MATERIAL_KEY, value: 'true' });
|
|
28
|
+
|
|
29
|
+
if (options.materialVersion) {
|
|
30
|
+
next.push({
|
|
31
|
+
type: 'property',
|
|
32
|
+
key: MATERIAL_VERSION_KEY,
|
|
33
|
+
value: String(options.materialVersion),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return next;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const withUnifiedActionSheet = (config, options = {}) => {
|
|
42
|
+
// Required here rather than at the top: @expo/config-plugins is an optional
|
|
43
|
+
// peer, present in every Expo project and absent from bare ones, which never
|
|
44
|
+
// load this file.
|
|
45
|
+
const { withGradleProperties } = require('@expo/config-plugins');
|
|
46
|
+
|
|
47
|
+
return withGradleProperties(config, (modConfig) => {
|
|
48
|
+
modConfig.modResults = applyMaterialProperties(
|
|
49
|
+
modConfig.modResults,
|
|
50
|
+
options
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return modConfig;
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
module.exports = withUnifiedActionSheet;
|
|
58
|
+
module.exports.applyMaterialProperties = applyMaterialProperties;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { TurboModuleRegistry, type TurboModule } from 'react-native';
|
|
2
2
|
|
|
3
3
|
export interface Spec extends TurboModule {
|
|
4
|
+
getConstants(): {
|
|
5
|
+
/// Android: whether the app opted into Material (presentationStyle
|
|
6
|
+
/// 'bottom'). Always false on iOS, which needs no opt-in.
|
|
7
|
+
isMaterialEnabled: boolean;
|
|
8
|
+
};
|
|
4
9
|
showActionSheetWithOptions(options: {
|
|
5
10
|
options: string[];
|
|
6
11
|
cancelButtonIndex?: number;
|
|
@@ -15,6 +20,8 @@ export interface Spec extends TurboModule {
|
|
|
15
20
|
userInterfaceStyle?: string;
|
|
16
21
|
presentationStyle?: string;
|
|
17
22
|
anchorAlignment?: string;
|
|
23
|
+
preferredButtonIndex?: number;
|
|
24
|
+
detents?: string[];
|
|
18
25
|
anchorRect?: {
|
|
19
26
|
x: number;
|
|
20
27
|
y: number;
|
|
@@ -29,16 +36,19 @@ export interface Spec extends TurboModule {
|
|
|
29
36
|
disabledButtonIndices?: number[];
|
|
30
37
|
title?: string;
|
|
31
38
|
message?: string;
|
|
39
|
+
preferredButtonIndex?: number;
|
|
40
|
+
textRequiredButtonIndices?: number[];
|
|
41
|
+
type?: string;
|
|
32
42
|
placeholder?: string;
|
|
43
|
+
passwordPlaceholder?: string;
|
|
33
44
|
defaultValue?: string;
|
|
34
45
|
keyboardType?: string;
|
|
35
|
-
secureTextEntry?: boolean;
|
|
36
46
|
tintColor?: string;
|
|
37
47
|
cancelButtonTintColor?: string;
|
|
38
48
|
destructiveColor?: string;
|
|
39
49
|
buttonTextAlignment?: string;
|
|
40
50
|
userInterfaceStyle?: string;
|
|
41
|
-
}): Promise<{ buttonIndex: number; text: string }>;
|
|
51
|
+
}): Promise<{ buttonIndex: number; text: string; password: string }>;
|
|
42
52
|
dismissActionSheet(): void;
|
|
43
53
|
dismissAllActionSheets(): void;
|
|
44
54
|
}
|
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
BaseAndroidOptionsInterface,
|
|
3
3
|
BaseButtonInterface,
|
|
4
4
|
BaseOptionsInterface,
|
|
5
|
+
CloseResultInterface,
|
|
5
6
|
} from './common-options.interface';
|
|
6
7
|
|
|
7
8
|
export interface ActionSheetButtonInterface extends BaseButtonInterface {
|
|
@@ -14,13 +15,21 @@ export interface ActionSheetAnchorInterface {
|
|
|
14
15
|
) => void;
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
/// A bottom sheet's height: 'auto' fits the content, 'medium' is half the
|
|
19
|
+
/// screen, 'large' is the full height below the status bar.
|
|
20
|
+
export type ActionSheetDetent = 'auto' | 'medium' | 'large';
|
|
21
|
+
|
|
17
22
|
export interface ActionSheetCommonOptionsInterface extends BaseOptionsInterface {
|
|
18
23
|
options: ActionSheetButtonInterface[];
|
|
19
24
|
anchor?:
|
|
20
25
|
| ActionSheetAnchorInterface
|
|
21
26
|
| { current: ActionSheetAnchorInterface | null }
|
|
22
27
|
| null;
|
|
23
|
-
presentationStyle?: 'centered' | 'anchored';
|
|
28
|
+
presentationStyle?: 'centered' | 'anchored' | 'bottom';
|
|
29
|
+
/// 'bottom' only: the heights the sheet can rest at. It opens at the first
|
|
30
|
+
/// and can be dragged to the others. Unset, a short list fits its content
|
|
31
|
+
/// and a long one opens at half height and expands to full.
|
|
32
|
+
detents?: ActionSheetDetent[];
|
|
24
33
|
}
|
|
25
34
|
|
|
26
35
|
export interface ActionSheetAndroidOptionsInterface extends BaseAndroidOptionsInterface {
|
|
@@ -31,3 +40,5 @@ export interface ActionSheetOptionsInterface
|
|
|
31
40
|
extends
|
|
32
41
|
ActionSheetCommonOptionsInterface,
|
|
33
42
|
ActionSheetAndroidOptionsInterface {}
|
|
43
|
+
|
|
44
|
+
export type ActionSheetResultInterface = CloseResultInterface;
|
|
@@ -2,6 +2,11 @@ export interface BaseButtonInterface {
|
|
|
2
2
|
label: string;
|
|
3
3
|
style?: 'cancel' | 'destructive';
|
|
4
4
|
disabled?: boolean;
|
|
5
|
+
/// The default action, emphasized: bold on Android and in the iOS bottom
|
|
6
|
+
/// sheet; in iOS alerts and prompts UIKit's own preferred-action style (a
|
|
7
|
+
/// filled button from iOS 26, bold text before). Only the first preferred
|
|
8
|
+
/// button counts. UIKit ignores it in the standard iOS action sheet.
|
|
9
|
+
preferred?: boolean;
|
|
5
10
|
}
|
|
6
11
|
|
|
7
12
|
export interface BaseOptionsInterface {
|
|
@@ -16,3 +21,16 @@ export interface BaseOptionsInterface {
|
|
|
16
21
|
export interface BaseAndroidOptionsInterface {
|
|
17
22
|
buttonTextAlignment?: 'start' | 'center';
|
|
18
23
|
}
|
|
24
|
+
|
|
25
|
+
/// Why a sheet or prompt closed.
|
|
26
|
+
/// - 'selected': a button other than the cancel button.
|
|
27
|
+
/// - 'cancelled': the cancel button, a backdrop tap, back, or a swipe down.
|
|
28
|
+
/// - 'dismissed': dismissActionSheet(), dismissAllActionSheets(), or a JS
|
|
29
|
+
/// reload; also on a platform without the native module.
|
|
30
|
+
export type CloseReason = 'selected' | 'cancelled' | 'dismissed';
|
|
31
|
+
|
|
32
|
+
/// buttonIndex is the button that closed it. A cancellation carries the cancel
|
|
33
|
+
/// button's index, or -1 when there is none; a dismissal carries no index.
|
|
34
|
+
export type CloseResultInterface =
|
|
35
|
+
| { reason: 'selected' | 'cancelled'; buttonIndex: number }
|
|
36
|
+
| { reason: 'dismissed'; buttonIndex: undefined };
|