@capacitor/action-sheet 8.0.1 → 8.0.2-dev-2285-20260220T141207.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -8
- package/android/src/main/java/com/capacitorjs/plugins/actionsheet/ActionSheet.java +3 -1
- package/android/src/main/java/com/capacitorjs/plugins/actionsheet/ActionSheetPlugin.java +13 -1
- package/dist/docs.json +25 -1
- package/dist/esm/definitions.d.ts +21 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.js +10 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +10 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +10 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/ActionSheetPlugin/ActionSheetPlugin.swift +28 -5
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -84,18 +84,20 @@ to select.
|
|
|
84
84
|
|
|
85
85
|
#### ShowActionsResult
|
|
86
86
|
|
|
87
|
-
| Prop
|
|
88
|
-
|
|
|
89
|
-
| **`index`**
|
|
87
|
+
| Prop | Type | Description | Since |
|
|
88
|
+
| -------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
|
|
89
|
+
| **`index`** | <code>number</code> | The index of the clicked option (Zero-based), or -1 if the sheet was canceled. On iOS, if there is a button with <a href="#actionsheetbuttonstyle">ActionSheetButtonStyle.Cancel</a>, and user clicks outside the sheet, the index of the cancel option is returned | 1.0.0 |
|
|
90
|
+
| **`canceled`** | <code>boolean</code> | True if sheet was canceled by user; False otherwise On Web, requires having @ionic/pwa-elements version 3.4.0 or higher. | 8.1.0 |
|
|
90
91
|
|
|
91
92
|
|
|
92
93
|
#### ShowActionsOptions
|
|
93
94
|
|
|
94
|
-
| Prop
|
|
95
|
-
|
|
|
96
|
-
| **`title`**
|
|
97
|
-
| **`message`**
|
|
98
|
-
| **`options`**
|
|
95
|
+
| Prop | Type | Description | Since |
|
|
96
|
+
| ---------------- | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
|
|
97
|
+
| **`title`** | <code>string</code> | The title of the Action Sheet. | 1.0.0 |
|
|
98
|
+
| **`message`** | <code>string</code> | A message to show under the title. This option is only supported on iOS. | 1.0.0 |
|
|
99
|
+
| **`options`** | <code>ActionSheetButton[]</code> | Options the user can choose from. | 1.0.0 |
|
|
100
|
+
| **`cancelable`** | <code>boolean</code> | If true, sheet is canceled when clicked outside; If false, it is not. By default, false. Not available on iOS, sheet is always cancelable by clicking outside of it. On Web, requires having @ionic/pwa-elements version 3.4.0 or higher. | 8.1.0 |
|
|
99
101
|
|
|
100
102
|
|
|
101
103
|
#### ActionSheetButton
|
|
@@ -26,7 +26,9 @@ public class ActionSheet extends BottomSheetDialogFragment {
|
|
|
26
26
|
@Override
|
|
27
27
|
public void onCancel(DialogInterface dialog) {
|
|
28
28
|
super.onCancel(dialog);
|
|
29
|
-
this.cancelListener
|
|
29
|
+
if (this.cancelListener != null) {
|
|
30
|
+
this.cancelListener.onCancel();
|
|
31
|
+
}
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
private String title;
|
|
@@ -19,6 +19,7 @@ public class ActionSheetPlugin extends Plugin {
|
|
|
19
19
|
@PluginMethod
|
|
20
20
|
public void showActions(final PluginCall call) {
|
|
21
21
|
String title = call.getString("title");
|
|
22
|
+
boolean cancelable = Boolean.TRUE.equals(call.getBoolean("cancelable", false));
|
|
22
23
|
JSArray options = call.getArray("options");
|
|
23
24
|
if (options == null) {
|
|
24
25
|
call.reject("Must supply options");
|
|
@@ -39,7 +40,10 @@ public class ActionSheetPlugin extends Plugin {
|
|
|
39
40
|
}
|
|
40
41
|
implementation.setTitle(title);
|
|
41
42
|
implementation.setOptions(actionOptions);
|
|
42
|
-
implementation.setCancelable(
|
|
43
|
+
implementation.setCancelable(cancelable);
|
|
44
|
+
if (cancelable) {
|
|
45
|
+
implementation.setOnCancelListener(() -> resolve(call, -1));
|
|
46
|
+
}
|
|
43
47
|
implementation.setOnSelectedListener((index) -> {
|
|
44
48
|
JSObject ret = new JSObject();
|
|
45
49
|
ret.put("index", index);
|
|
@@ -52,4 +56,12 @@ public class ActionSheetPlugin extends Plugin {
|
|
|
52
56
|
call.reject("JSON error processing an option for showActions", ex);
|
|
53
57
|
}
|
|
54
58
|
}
|
|
59
|
+
|
|
60
|
+
private void resolve(final PluginCall call, int selectedIndex) {
|
|
61
|
+
JSObject ret = new JSObject();
|
|
62
|
+
ret.put("index", selectedIndex);
|
|
63
|
+
ret.put("canceled", selectedIndex < 0);
|
|
64
|
+
call.resolve(ret);
|
|
65
|
+
implementation.dismiss();
|
|
66
|
+
}
|
|
55
67
|
}
|
package/dist/docs.json
CHANGED
|
@@ -48,9 +48,21 @@
|
|
|
48
48
|
"name": "since"
|
|
49
49
|
}
|
|
50
50
|
],
|
|
51
|
-
"docs": "The index of the clicked option (Zero-based)",
|
|
51
|
+
"docs": "The index of the clicked option (Zero-based), or -1 if the sheet was canceled.\n\nOn iOS, if there is a button with ActionSheetButtonStyle.Cancel, and user clicks outside the sheet, the index of the cancel option is returned",
|
|
52
52
|
"complexTypes": [],
|
|
53
53
|
"type": "number"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "canceled",
|
|
57
|
+
"tags": [
|
|
58
|
+
{
|
|
59
|
+
"text": "8.1.0",
|
|
60
|
+
"name": "since"
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"docs": "True if sheet was canceled by user; False otherwise\n\nOn Web, requires having @ionic/pwa-elements version 3.4.0 or higher.",
|
|
64
|
+
"complexTypes": [],
|
|
65
|
+
"type": "boolean"
|
|
54
66
|
}
|
|
55
67
|
]
|
|
56
68
|
},
|
|
@@ -98,6 +110,18 @@
|
|
|
98
110
|
"ActionSheetButton"
|
|
99
111
|
],
|
|
100
112
|
"type": "ActionSheetButton[]"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "cancelable",
|
|
116
|
+
"tags": [
|
|
117
|
+
{
|
|
118
|
+
"text": "8.1.0",
|
|
119
|
+
"name": "since"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"docs": "If true, sheet is canceled when clicked outside; If false, it is not. By default, false.\n\nNot available on iOS, sheet is always cancelable by clicking outside of it.\n\nOn Web, requires having @ionic/pwa-elements version 3.4.0 or higher.",
|
|
123
|
+
"complexTypes": [],
|
|
124
|
+
"type": "boolean | undefined"
|
|
101
125
|
}
|
|
102
126
|
]
|
|
103
127
|
},
|
|
@@ -19,6 +19,16 @@ export interface ShowActionsOptions {
|
|
|
19
19
|
* @since 1.0.0
|
|
20
20
|
*/
|
|
21
21
|
options: ActionSheetButton[];
|
|
22
|
+
/**
|
|
23
|
+
* If true, sheet is canceled when clicked outside; If false, it is not. By default, false.
|
|
24
|
+
*
|
|
25
|
+
* Not available on iOS, sheet is always cancelable by clicking outside of it.
|
|
26
|
+
*
|
|
27
|
+
* On Web, requires having @ionic/pwa-elements version 3.4.0 or higher.
|
|
28
|
+
*
|
|
29
|
+
* @since 8.1.0
|
|
30
|
+
*/
|
|
31
|
+
cancelable?: boolean;
|
|
22
32
|
}
|
|
23
33
|
export declare enum ActionSheetButtonStyle {
|
|
24
34
|
/**
|
|
@@ -67,11 +77,21 @@ export interface ActionSheetButton {
|
|
|
67
77
|
}
|
|
68
78
|
export interface ShowActionsResult {
|
|
69
79
|
/**
|
|
70
|
-
* The index of the clicked option (Zero-based)
|
|
80
|
+
* The index of the clicked option (Zero-based), or -1 if the sheet was canceled.
|
|
81
|
+
*
|
|
82
|
+
* On iOS, if there is a button with ActionSheetButtonStyle.Cancel, and user clicks outside the sheet, the index of the cancel option is returned
|
|
71
83
|
*
|
|
72
84
|
* @since 1.0.0
|
|
73
85
|
*/
|
|
74
86
|
index: number;
|
|
87
|
+
/**
|
|
88
|
+
* True if sheet was canceled by user; False otherwise
|
|
89
|
+
*
|
|
90
|
+
* On Web, requires having @ionic/pwa-elements version 3.4.0 or higher.
|
|
91
|
+
*
|
|
92
|
+
* @since 8.1.0
|
|
93
|
+
*/
|
|
94
|
+
canceled: boolean;
|
|
75
95
|
}
|
|
76
96
|
export interface ActionSheetPlugin {
|
|
77
97
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAoCA,MAAM,CAAN,IAAY,sBAsBX;AAtBD,WAAY,sBAAsB;IAChC;;;;OAIG;IACH,6CAAmB,CAAA;IAEnB;;;;OAIG;IACH,qDAA2B,CAAA;IAE3B;;;;;OAKG;IACH,2CAAiB,CAAA;AACnB,CAAC,EAtBW,sBAAsB,KAAtB,sBAAsB,QAsBjC;AA4ED;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,sBAAsB,CAAC","sourcesContent":["export interface ShowActionsOptions {\n /**\n * The title of the Action Sheet.\n *\n * @since 1.0.0\n */\n title?: string;\n\n /**\n * A message to show under the title.\n *\n * This option is only supported on iOS.\n *\n * @since 1.0.0\n */\n message?: string;\n\n /**\n * Options the user can choose from.\n *\n * @since 1.0.0\n */\n options: ActionSheetButton[];\n\n /**\n * If true, sheet is canceled when clicked outside; If false, it is not. By default, false.\n *\n * Not available on iOS, sheet is always cancelable by clicking outside of it.\n *\n * On Web, requires having @ionic/pwa-elements version 3.4.0 or higher.\n *\n * @since 8.1.0\n */\n cancelable?: boolean;\n}\n\nexport enum ActionSheetButtonStyle {\n /**\n * Default style of the option.\n *\n * @since 1.0.0\n */\n Default = 'DEFAULT',\n\n /**\n * Style to use on destructive options.\n *\n * @since 1.0.0\n */\n Destructive = 'DESTRUCTIVE',\n\n /**\n * Style to use on the option that cancels the Action Sheet.\n * If used, should be on the latest availabe option.\n *\n * @since 1.0.0\n */\n Cancel = 'CANCEL',\n}\n\nexport interface ActionSheetButton {\n /**\n * The title of the option\n *\n * @since 1.0.0\n */\n title: string;\n\n /**\n * The style of the option\n *\n * This option is only supported on iOS.\n *\n * @since 1.0.0\n */\n style?: ActionSheetButtonStyle;\n\n /**\n * Icon for the option (ionicon naming convention)\n *\n * This option is only supported on Web.\n *\n * @since 1.0.0\n */\n icon?: string;\n}\n\nexport interface ShowActionsResult {\n /**\n * The index of the clicked option (Zero-based), or -1 if the sheet was canceled.\n *\n * On iOS, if there is a button with ActionSheetButtonStyle.Cancel, and user clicks outside the sheet, the index of the cancel option is returned\n *\n * @since 1.0.0\n */\n index: number;\n /**\n * True if sheet was canceled by user; False otherwise\n *\n * On Web, requires having @ionic/pwa-elements version 3.4.0 or higher.\n *\n * @since 8.1.0\n */\n canceled: boolean;\n}\n\nexport interface ActionSheetPlugin {\n /**\n * Show an Action Sheet style modal with various options for the user\n * to select.\n *\n * @since 1.0.0\n */\n showActions(options: ShowActionsOptions): Promise<ShowActionsResult>;\n}\n\n/**\n * @deprecated Use `ShowActionsOptions`.\n * @since 1.0.0\n */\nexport type ActionSheetOptions = ShowActionsOptions;\n\n/**\n * @deprecated Use `ShowActionsResult`.\n * @since 1.0.0\n */\nexport type ActionSheetResult = ShowActionsResult;\n\n/**\n * @deprecated Use `ActionSheetButton`.\n * @since 1.0.0\n */\nexport type ActionSheetOption = ActionSheetButton;\n\n/**\n * @deprecated Use `ActionSheetButtonStyle`.\n * @since 1.0.0\n */\nexport const ActionSheetOptionStyle = ActionSheetButtonStyle;\n"]}
|
package/dist/esm/web.js
CHANGED
|
@@ -8,14 +8,23 @@ export class ActionSheetWeb extends WebPlugin {
|
|
|
8
8
|
document.body.appendChild(actionSheet);
|
|
9
9
|
}
|
|
10
10
|
actionSheet.header = options.title;
|
|
11
|
-
actionSheet.cancelable =
|
|
11
|
+
actionSheet.cancelable = options.cancelable;
|
|
12
12
|
actionSheet.options = options.options;
|
|
13
13
|
actionSheet.addEventListener('onSelection', async (e) => {
|
|
14
14
|
const selection = e.detail;
|
|
15
15
|
resolve({
|
|
16
16
|
index: selection,
|
|
17
|
+
canceled: false,
|
|
17
18
|
});
|
|
18
19
|
});
|
|
20
|
+
if (options.cancelable) {
|
|
21
|
+
actionSheet.addEventListener('onCanceled', async () => {
|
|
22
|
+
resolve({
|
|
23
|
+
index: -1,
|
|
24
|
+
canceled: true,
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
19
28
|
});
|
|
20
29
|
}
|
|
21
30
|
}
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,cAAe,SAAQ,SAAS;IAC3C,KAAK,CAAC,WAAW,CAAC,OAA2B;QAC3C,OAAO,IAAI,OAAO,CAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;YACzD,IAAI,WAAW,GAAQ,QAAQ,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;YAClE,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;gBACzD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;YACzC,CAAC;YACD,WAAW,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;YACnC,WAAW,CAAC,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,cAAe,SAAQ,SAAS;IAC3C,KAAK,CAAC,WAAW,CAAC,OAA2B;QAC3C,OAAO,IAAI,OAAO,CAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;YACzD,IAAI,WAAW,GAAQ,QAAQ,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;YAClE,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;gBACzD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;YACzC,CAAC;YACD,WAAW,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;YACnC,WAAW,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;YAC5C,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;YACtC,WAAW,CAAC,gBAAgB,CAAC,aAAa,EAAE,KAAK,EAAE,CAAM,EAAE,EAAE;gBAC3D,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;gBAC3B,OAAO,CAAC;oBACN,KAAK,EAAE,SAAS;oBAChB,QAAQ,EAAE,KAAK;iBAChB,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YACH,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,WAAW,CAAC,gBAAgB,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;oBACpD,OAAO,CAAC;wBACN,KAAK,EAAE,CAAC,CAAC;wBACT,QAAQ,EAAE,IAAI;qBACf,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { ActionSheetPlugin, ShowActionsResult, ShowActionsOptions } from './definitions';\n\nexport class ActionSheetWeb extends WebPlugin implements ActionSheetPlugin {\n async showActions(options: ShowActionsOptions): Promise<ShowActionsResult> {\n return new Promise<ShowActionsResult>((resolve, _reject) => {\n let actionSheet: any = document.querySelector('pwa-action-sheet');\n if (!actionSheet) {\n actionSheet = document.createElement('pwa-action-sheet');\n document.body.appendChild(actionSheet);\n }\n actionSheet.header = options.title;\n actionSheet.cancelable = options.cancelable;\n actionSheet.options = options.options;\n actionSheet.addEventListener('onSelection', async (e: any) => {\n const selection = e.detail;\n resolve({\n index: selection,\n canceled: false,\n });\n });\n if (options.cancelable) {\n actionSheet.addEventListener('onCanceled', async () => {\n resolve({\n index: -1,\n canceled: true,\n });\n });\n }\n });\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -43,14 +43,23 @@ class ActionSheetWeb extends core.WebPlugin {
|
|
|
43
43
|
document.body.appendChild(actionSheet);
|
|
44
44
|
}
|
|
45
45
|
actionSheet.header = options.title;
|
|
46
|
-
actionSheet.cancelable =
|
|
46
|
+
actionSheet.cancelable = options.cancelable;
|
|
47
47
|
actionSheet.options = options.options;
|
|
48
48
|
actionSheet.addEventListener('onSelection', async (e) => {
|
|
49
49
|
const selection = e.detail;
|
|
50
50
|
resolve({
|
|
51
51
|
index: selection,
|
|
52
|
+
canceled: false,
|
|
52
53
|
});
|
|
53
54
|
});
|
|
55
|
+
if (options.cancelable) {
|
|
56
|
+
actionSheet.addEventListener('onCanceled', async () => {
|
|
57
|
+
resolve({
|
|
58
|
+
index: -1,
|
|
59
|
+
canceled: true,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
54
63
|
});
|
|
55
64
|
}
|
|
56
65
|
}
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var ActionSheetButtonStyle;\n(function (ActionSheetButtonStyle) {\n /**\n * Default style of the option.\n *\n * @since 1.0.0\n */\n ActionSheetButtonStyle[\"Default\"] = \"DEFAULT\";\n /**\n * Style to use on destructive options.\n *\n * @since 1.0.0\n */\n ActionSheetButtonStyle[\"Destructive\"] = \"DESTRUCTIVE\";\n /**\n * Style to use on the option that cancels the Action Sheet.\n * If used, should be on the latest availabe option.\n *\n * @since 1.0.0\n */\n ActionSheetButtonStyle[\"Cancel\"] = \"CANCEL\";\n})(ActionSheetButtonStyle || (ActionSheetButtonStyle = {}));\n/**\n * @deprecated Use `ActionSheetButtonStyle`.\n * @since 1.0.0\n */\nexport const ActionSheetOptionStyle = ActionSheetButtonStyle;\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst ActionSheet = registerPlugin('ActionSheet', {\n web: () => import('./web').then((m) => new m.ActionSheetWeb()),\n});\nexport * from './definitions';\nexport { ActionSheet };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ActionSheetWeb extends WebPlugin {\n async showActions(options) {\n return new Promise((resolve, _reject) => {\n let actionSheet = document.querySelector('pwa-action-sheet');\n if (!actionSheet) {\n actionSheet = document.createElement('pwa-action-sheet');\n document.body.appendChild(actionSheet);\n }\n actionSheet.header = options.title;\n actionSheet.cancelable =
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var ActionSheetButtonStyle;\n(function (ActionSheetButtonStyle) {\n /**\n * Default style of the option.\n *\n * @since 1.0.0\n */\n ActionSheetButtonStyle[\"Default\"] = \"DEFAULT\";\n /**\n * Style to use on destructive options.\n *\n * @since 1.0.0\n */\n ActionSheetButtonStyle[\"Destructive\"] = \"DESTRUCTIVE\";\n /**\n * Style to use on the option that cancels the Action Sheet.\n * If used, should be on the latest availabe option.\n *\n * @since 1.0.0\n */\n ActionSheetButtonStyle[\"Cancel\"] = \"CANCEL\";\n})(ActionSheetButtonStyle || (ActionSheetButtonStyle = {}));\n/**\n * @deprecated Use `ActionSheetButtonStyle`.\n * @since 1.0.0\n */\nexport const ActionSheetOptionStyle = ActionSheetButtonStyle;\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst ActionSheet = registerPlugin('ActionSheet', {\n web: () => import('./web').then((m) => new m.ActionSheetWeb()),\n});\nexport * from './definitions';\nexport { ActionSheet };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ActionSheetWeb extends WebPlugin {\n async showActions(options) {\n return new Promise((resolve, _reject) => {\n let actionSheet = document.querySelector('pwa-action-sheet');\n if (!actionSheet) {\n actionSheet = document.createElement('pwa-action-sheet');\n document.body.appendChild(actionSheet);\n }\n actionSheet.header = options.title;\n actionSheet.cancelable = options.cancelable;\n actionSheet.options = options.options;\n actionSheet.addEventListener('onSelection', async (e) => {\n const selection = e.detail;\n resolve({\n index: selection,\n canceled: false,\n });\n });\n if (options.cancelable) {\n actionSheet.addEventListener('onCanceled', async () => {\n resolve({\n index: -1,\n canceled: true,\n });\n });\n }\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ActionSheetButtonStyle","registerPlugin","WebPlugin"],"mappings":";;;;AAAWA;AACX,CAAC,UAAU,sBAAsB,EAAE;AACnC;AACA;AACA;AACA;AACA;AACA,IAAI,sBAAsB,CAAC,SAAS,CAAC,GAAG,SAAS;AACjD;AACA;AACA;AACA;AACA;AACA,IAAI,sBAAsB,CAAC,aAAa,CAAC,GAAG,aAAa;AACzD;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,sBAAsB,CAAC,QAAQ,CAAC,GAAG,QAAQ;AAC/C,CAAC,EAAEA,8BAAsB,KAAKA,8BAAsB,GAAG,EAAE,CAAC,CAAC;AAC3D;AACA;AACA;AACA;AACY,MAAC,sBAAsB,GAAGA;;ACzBjC,MAAC,WAAW,GAAGC,mBAAc,CAAC,aAAa,EAAE;AAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;AAClE,CAAC;;ACFM,MAAM,cAAc,SAASC,cAAS,CAAC;AAC9C,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;AAC/B,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK;AACjD,YAAY,IAAI,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,kBAAkB,CAAC;AACxE,YAAY,IAAI,CAAC,WAAW,EAAE;AAC9B,gBAAgB,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,kBAAkB,CAAC;AACxE,gBAAgB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC;AACtD,YAAY;AACZ,YAAY,WAAW,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK;AAC9C,YAAY,WAAW,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU;AACvD,YAAY,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO;AACjD,YAAY,WAAW,CAAC,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,KAAK;AACrE,gBAAgB,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM;AAC1C,gBAAgB,OAAO,CAAC;AACxB,oBAAoB,KAAK,EAAE,SAAS;AACpC,oBAAoB,QAAQ,EAAE,KAAK;AACnC,iBAAiB,CAAC;AAClB,YAAY,CAAC,CAAC;AACd,YAAY,IAAI,OAAO,CAAC,UAAU,EAAE;AACpC,gBAAgB,WAAW,CAAC,gBAAgB,CAAC,YAAY,EAAE,YAAY;AACvE,oBAAoB,OAAO,CAAC;AAC5B,wBAAwB,KAAK,EAAE,EAAE;AACjC,wBAAwB,QAAQ,EAAE,IAAI;AACtC,qBAAqB,CAAC;AACtB,gBAAgB,CAAC,CAAC;AAClB,YAAY;AACZ,QAAQ,CAAC,CAAC;AACV,IAAI;AACJ;;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -42,14 +42,23 @@ var capacitorActionSheet = (function (exports, core) {
|
|
|
42
42
|
document.body.appendChild(actionSheet);
|
|
43
43
|
}
|
|
44
44
|
actionSheet.header = options.title;
|
|
45
|
-
actionSheet.cancelable =
|
|
45
|
+
actionSheet.cancelable = options.cancelable;
|
|
46
46
|
actionSheet.options = options.options;
|
|
47
47
|
actionSheet.addEventListener('onSelection', async (e) => {
|
|
48
48
|
const selection = e.detail;
|
|
49
49
|
resolve({
|
|
50
50
|
index: selection,
|
|
51
|
+
canceled: false,
|
|
51
52
|
});
|
|
52
53
|
});
|
|
54
|
+
if (options.cancelable) {
|
|
55
|
+
actionSheet.addEventListener('onCanceled', async () => {
|
|
56
|
+
resolve({
|
|
57
|
+
index: -1,
|
|
58
|
+
canceled: true,
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
53
62
|
});
|
|
54
63
|
}
|
|
55
64
|
}
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var ActionSheetButtonStyle;\n(function (ActionSheetButtonStyle) {\n /**\n * Default style of the option.\n *\n * @since 1.0.0\n */\n ActionSheetButtonStyle[\"Default\"] = \"DEFAULT\";\n /**\n * Style to use on destructive options.\n *\n * @since 1.0.0\n */\n ActionSheetButtonStyle[\"Destructive\"] = \"DESTRUCTIVE\";\n /**\n * Style to use on the option that cancels the Action Sheet.\n * If used, should be on the latest availabe option.\n *\n * @since 1.0.0\n */\n ActionSheetButtonStyle[\"Cancel\"] = \"CANCEL\";\n})(ActionSheetButtonStyle || (ActionSheetButtonStyle = {}));\n/**\n * @deprecated Use `ActionSheetButtonStyle`.\n * @since 1.0.0\n */\nexport const ActionSheetOptionStyle = ActionSheetButtonStyle;\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst ActionSheet = registerPlugin('ActionSheet', {\n web: () => import('./web').then((m) => new m.ActionSheetWeb()),\n});\nexport * from './definitions';\nexport { ActionSheet };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ActionSheetWeb extends WebPlugin {\n async showActions(options) {\n return new Promise((resolve, _reject) => {\n let actionSheet = document.querySelector('pwa-action-sheet');\n if (!actionSheet) {\n actionSheet = document.createElement('pwa-action-sheet');\n document.body.appendChild(actionSheet);\n }\n actionSheet.header = options.title;\n actionSheet.cancelable =
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var ActionSheetButtonStyle;\n(function (ActionSheetButtonStyle) {\n /**\n * Default style of the option.\n *\n * @since 1.0.0\n */\n ActionSheetButtonStyle[\"Default\"] = \"DEFAULT\";\n /**\n * Style to use on destructive options.\n *\n * @since 1.0.0\n */\n ActionSheetButtonStyle[\"Destructive\"] = \"DESTRUCTIVE\";\n /**\n * Style to use on the option that cancels the Action Sheet.\n * If used, should be on the latest availabe option.\n *\n * @since 1.0.0\n */\n ActionSheetButtonStyle[\"Cancel\"] = \"CANCEL\";\n})(ActionSheetButtonStyle || (ActionSheetButtonStyle = {}));\n/**\n * @deprecated Use `ActionSheetButtonStyle`.\n * @since 1.0.0\n */\nexport const ActionSheetOptionStyle = ActionSheetButtonStyle;\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst ActionSheet = registerPlugin('ActionSheet', {\n web: () => import('./web').then((m) => new m.ActionSheetWeb()),\n});\nexport * from './definitions';\nexport { ActionSheet };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ActionSheetWeb extends WebPlugin {\n async showActions(options) {\n return new Promise((resolve, _reject) => {\n let actionSheet = document.querySelector('pwa-action-sheet');\n if (!actionSheet) {\n actionSheet = document.createElement('pwa-action-sheet');\n document.body.appendChild(actionSheet);\n }\n actionSheet.header = options.title;\n actionSheet.cancelable = options.cancelable;\n actionSheet.options = options.options;\n actionSheet.addEventListener('onSelection', async (e) => {\n const selection = e.detail;\n resolve({\n index: selection,\n canceled: false,\n });\n });\n if (options.cancelable) {\n actionSheet.addEventListener('onCanceled', async () => {\n resolve({\n index: -1,\n canceled: true,\n });\n });\n }\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["ActionSheetButtonStyle","registerPlugin","WebPlugin"],"mappings":";;;AAAWA;IACX,CAAC,UAAU,sBAAsB,EAAE;IACnC;IACA;IACA;IACA;IACA;IACA,IAAI,sBAAsB,CAAC,SAAS,CAAC,GAAG,SAAS;IACjD;IACA;IACA;IACA;IACA;IACA,IAAI,sBAAsB,CAAC,aAAa,CAAC,GAAG,aAAa;IACzD;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,sBAAsB,CAAC,QAAQ,CAAC,GAAG,QAAQ;IAC/C,CAAC,EAAEA,8BAAsB,KAAKA,8BAAsB,GAAG,EAAE,CAAC,CAAC;IAC3D;IACA;IACA;IACA;AACY,UAAC,sBAAsB,GAAGA;;ACzBjC,UAAC,WAAW,GAAGC,mBAAc,CAAC,aAAa,EAAE;IAClD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;IAClE,CAAC;;ICFM,MAAM,cAAc,SAASC,cAAS,CAAC;IAC9C,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK;IACjD,YAAY,IAAI,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,kBAAkB,CAAC;IACxE,YAAY,IAAI,CAAC,WAAW,EAAE;IAC9B,gBAAgB,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,kBAAkB,CAAC;IACxE,gBAAgB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC;IACtD,YAAY;IACZ,YAAY,WAAW,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK;IAC9C,YAAY,WAAW,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU;IACvD,YAAY,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO;IACjD,YAAY,WAAW,CAAC,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,KAAK;IACrE,gBAAgB,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM;IAC1C,gBAAgB,OAAO,CAAC;IACxB,oBAAoB,KAAK,EAAE,SAAS;IACpC,oBAAoB,QAAQ,EAAE,KAAK;IACnC,iBAAiB,CAAC;IAClB,YAAY,CAAC,CAAC;IACd,YAAY,IAAI,OAAO,CAAC,UAAU,EAAE;IACpC,gBAAgB,WAAW,CAAC,gBAAgB,CAAC,YAAY,EAAE,YAAY;IACvE,oBAAoB,OAAO,CAAC;IAC5B,wBAAwB,KAAK,EAAE,EAAE;IACjC,wBAAwB,QAAQ,EAAE,IAAI;IACtC,qBAAqB,CAAC;IACtB,gBAAgB,CAAC,CAAC;IAClB,YAAY;IACZ,QAAQ,CAAC,CAAC;IACV,IAAI;IACJ;;;;;;;;;;;;;;;;"}
|
|
@@ -6,13 +6,14 @@ import Capacitor
|
|
|
6
6
|
* here: https://capacitorjs.com/docs/plugins/ios
|
|
7
7
|
*/
|
|
8
8
|
@objc(ActionSheetPlugin)
|
|
9
|
-
public class ActionSheetPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
9
|
+
public class ActionSheetPlugin: CAPPlugin, CAPBridgedPlugin, UIAdaptivePresentationControllerDelegate {
|
|
10
10
|
public let identifier = "ActionSheetPlugin"
|
|
11
11
|
public let jsName = "ActionSheet"
|
|
12
12
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
13
13
|
CAPPluginMethod(name: "showActions", returnType: CAPPluginReturnPromise)
|
|
14
14
|
]
|
|
15
15
|
private let implementation = ActionSheet()
|
|
16
|
+
private var currentCall: CAPPluginCall?
|
|
16
17
|
|
|
17
18
|
@objc func showActions(_ call: CAPPluginCall) {
|
|
18
19
|
let title = call.options["title"] as? String
|
|
@@ -29,20 +30,42 @@ public class ActionSheetPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
29
30
|
} else if style == "CANCEL" {
|
|
30
31
|
buttonStyle = .cancel
|
|
31
32
|
}
|
|
32
|
-
let action = UIAlertAction(title: title, style: buttonStyle, handler: { (_) in
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
let action = UIAlertAction(title: title, style: buttonStyle, handler: { [weak self] (_) in
|
|
34
|
+
if buttonStyle == .cancel {
|
|
35
|
+
call.resolve([
|
|
36
|
+
"index": -1,
|
|
37
|
+
"canceled": true
|
|
38
|
+
])
|
|
39
|
+
} else {
|
|
40
|
+
call.resolve([
|
|
41
|
+
"index": index,
|
|
42
|
+
"canceled": false
|
|
43
|
+
])
|
|
44
|
+
}
|
|
45
|
+
self?.currentCall = nil
|
|
36
46
|
})
|
|
37
47
|
alertActions.append(action)
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
DispatchQueue.main.async { [weak self] in
|
|
41
51
|
if let alertController = self?.implementation.buildActionSheet(title: title, message: message, actions: alertActions) {
|
|
52
|
+
self?.currentCall = call
|
|
53
|
+
|
|
54
|
+
alertController.presentationController?.delegate = self
|
|
55
|
+
|
|
42
56
|
self?.setCenteredPopover(alertController)
|
|
43
57
|
self?.bridge?.viewController?.present(alertController, animated: true, completion: nil)
|
|
44
58
|
}
|
|
45
59
|
}
|
|
46
60
|
}
|
|
47
61
|
|
|
62
|
+
// MARK: - UIAdaptivePresentationControllerDelegate
|
|
63
|
+
|
|
64
|
+
public func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
|
|
65
|
+
self.currentCall?.resolve([
|
|
66
|
+
"index": -1,
|
|
67
|
+
"canceled": true
|
|
68
|
+
])
|
|
69
|
+
self.currentCall = nil
|
|
70
|
+
}
|
|
48
71
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/action-sheet",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.2-dev-2285-20260220T141207.0",
|
|
4
4
|
"description": "The Action Sheet API provides access to native Action Sheets, which come up from the bottom of the screen and display actions a user can take.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -80,6 +80,5 @@
|
|
|
80
80
|
},
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
|
-
}
|
|
84
|
-
"gitHead": "bf4fe8c9ace79237c048c9b5ee0ab7455042bc86"
|
|
83
|
+
}
|
|
85
84
|
}
|