@capawesome/capacitor-dialog 0.0.1

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.
Files changed (45) hide show
  1. package/CapawesomeCapacitorDialog.podspec +17 -0
  2. package/LICENSE +21 -0
  3. package/Package.swift +28 -0
  4. package/README.md +232 -0
  5. package/android/build.gradle +58 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/io/capawesome/capacitorjs/plugins/dialog/Dialog.java +75 -0
  8. package/android/src/main/java/io/capawesome/capacitorjs/plugins/dialog/DialogPlugin.java +121 -0
  9. package/android/src/main/java/io/capawesome/capacitorjs/plugins/dialog/classes/CustomException.java +20 -0
  10. package/android/src/main/java/io/capawesome/capacitorjs/plugins/dialog/classes/CustomExceptions.java +6 -0
  11. package/android/src/main/java/io/capawesome/capacitorjs/plugins/dialog/classes/options/AlertOptions.java +43 -0
  12. package/android/src/main/java/io/capawesome/capacitorjs/plugins/dialog/classes/options/ConfirmOptions.java +52 -0
  13. package/android/src/main/java/io/capawesome/capacitorjs/plugins/dialog/classes/options/PromptOptions.java +70 -0
  14. package/android/src/main/java/io/capawesome/capacitorjs/plugins/dialog/classes/results/ConfirmResult.java +22 -0
  15. package/android/src/main/java/io/capawesome/capacitorjs/plugins/dialog/classes/results/PromptResult.java +27 -0
  16. package/android/src/main/java/io/capawesome/capacitorjs/plugins/dialog/interfaces/Callback.java +5 -0
  17. package/android/src/main/java/io/capawesome/capacitorjs/plugins/dialog/interfaces/EmptyCallback.java +5 -0
  18. package/android/src/main/java/io/capawesome/capacitorjs/plugins/dialog/interfaces/NonEmptyResultCallback.java +7 -0
  19. package/android/src/main/java/io/capawesome/capacitorjs/plugins/dialog/interfaces/Result.java +7 -0
  20. package/android/src/main/res/.gitkeep +0 -0
  21. package/dist/docs.json +433 -0
  22. package/dist/esm/definitions.d.ts +180 -0
  23. package/dist/esm/definitions.js +2 -0
  24. package/dist/esm/definitions.js.map +1 -0
  25. package/dist/esm/index.d.ts +4 -0
  26. package/dist/esm/index.js +7 -0
  27. package/dist/esm/index.js.map +1 -0
  28. package/dist/esm/web.d.ts +8 -0
  29. package/dist/esm/web.js +29 -0
  30. package/dist/esm/web.js.map +1 -0
  31. package/dist/plugin.cjs.js +43 -0
  32. package/dist/plugin.cjs.js.map +1 -0
  33. package/dist/plugin.js +46 -0
  34. package/dist/plugin.js.map +1 -0
  35. package/ios/Plugin/Classes/Options/AlertOptions.swift +17 -0
  36. package/ios/Plugin/Classes/Options/ConfirmOptions.swift +19 -0
  37. package/ios/Plugin/Classes/Options/PromptOptions.swift +23 -0
  38. package/ios/Plugin/Classes/Results/ConfirmResult.swift +16 -0
  39. package/ios/Plugin/Classes/Results/PromptResult.swift +19 -0
  40. package/ios/Plugin/Dialog.swift +57 -0
  41. package/ios/Plugin/DialogPlugin.swift +83 -0
  42. package/ios/Plugin/Enums/CustomError.swift +21 -0
  43. package/ios/Plugin/Info.plist +24 -0
  44. package/ios/Plugin/Protocols/Result.swift +5 -0
  45. package/package.json +95 -0
@@ -0,0 +1,52 @@
1
+ package io.capawesome.capacitorjs.plugins.dialog.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+ import com.getcapacitor.PluginCall;
6
+ import io.capawesome.capacitorjs.plugins.dialog.classes.CustomExceptions;
7
+
8
+ public class ConfirmOptions {
9
+
10
+ @NonNull
11
+ private final String cancelButtonTitle;
12
+
13
+ @NonNull
14
+ private final String message;
15
+
16
+ @NonNull
17
+ private final String okButtonTitle;
18
+
19
+ @Nullable
20
+ private final String title;
21
+
22
+ public ConfirmOptions(@NonNull PluginCall call) throws Exception {
23
+ String message = call.getString("message");
24
+ if (message == null) {
25
+ throw CustomExceptions.MESSAGE_MISSING;
26
+ }
27
+ this.message = message;
28
+ this.cancelButtonTitle = call.getString("cancelButtonTitle", "Cancel");
29
+ this.okButtonTitle = call.getString("okButtonTitle", "OK");
30
+ this.title = call.getString("title");
31
+ }
32
+
33
+ @NonNull
34
+ public String getCancelButtonTitle() {
35
+ return cancelButtonTitle;
36
+ }
37
+
38
+ @NonNull
39
+ public String getMessage() {
40
+ return message;
41
+ }
42
+
43
+ @NonNull
44
+ public String getOkButtonTitle() {
45
+ return okButtonTitle;
46
+ }
47
+
48
+ @Nullable
49
+ public String getTitle() {
50
+ return title;
51
+ }
52
+ }
@@ -0,0 +1,70 @@
1
+ package io.capawesome.capacitorjs.plugins.dialog.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+ import com.getcapacitor.PluginCall;
6
+ import io.capawesome.capacitorjs.plugins.dialog.classes.CustomExceptions;
7
+
8
+ public class PromptOptions {
9
+
10
+ @NonNull
11
+ private final String cancelButtonTitle;
12
+
13
+ @Nullable
14
+ private final String inputPlaceholder;
15
+
16
+ @Nullable
17
+ private final String inputText;
18
+
19
+ @NonNull
20
+ private final String message;
21
+
22
+ @NonNull
23
+ private final String okButtonTitle;
24
+
25
+ @Nullable
26
+ private final String title;
27
+
28
+ public PromptOptions(@NonNull PluginCall call) throws Exception {
29
+ String message = call.getString("message");
30
+ if (message == null) {
31
+ throw CustomExceptions.MESSAGE_MISSING;
32
+ }
33
+ this.message = message;
34
+ this.cancelButtonTitle = call.getString("cancelButtonTitle", "Cancel");
35
+ this.inputPlaceholder = call.getString("inputPlaceholder");
36
+ this.inputText = call.getString("inputText");
37
+ this.okButtonTitle = call.getString("okButtonTitle", "OK");
38
+ this.title = call.getString("title");
39
+ }
40
+
41
+ @NonNull
42
+ public String getCancelButtonTitle() {
43
+ return cancelButtonTitle;
44
+ }
45
+
46
+ @Nullable
47
+ public String getInputPlaceholder() {
48
+ return inputPlaceholder;
49
+ }
50
+
51
+ @Nullable
52
+ public String getInputText() {
53
+ return inputText;
54
+ }
55
+
56
+ @NonNull
57
+ public String getMessage() {
58
+ return message;
59
+ }
60
+
61
+ @NonNull
62
+ public String getOkButtonTitle() {
63
+ return okButtonTitle;
64
+ }
65
+
66
+ @Nullable
67
+ public String getTitle() {
68
+ return title;
69
+ }
70
+ }
@@ -0,0 +1,22 @@
1
+ package io.capawesome.capacitorjs.plugins.dialog.classes.results;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.JSObject;
5
+ import io.capawesome.capacitorjs.plugins.dialog.interfaces.Result;
6
+
7
+ public class ConfirmResult implements Result {
8
+
9
+ private final boolean value;
10
+
11
+ public ConfirmResult(boolean value) {
12
+ this.value = value;
13
+ }
14
+
15
+ @Override
16
+ @NonNull
17
+ public JSObject toJSObject() {
18
+ JSObject result = new JSObject();
19
+ result.put("value", value);
20
+ return result;
21
+ }
22
+ }
@@ -0,0 +1,27 @@
1
+ package io.capawesome.capacitorjs.plugins.dialog.classes.results;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.JSObject;
5
+ import io.capawesome.capacitorjs.plugins.dialog.interfaces.Result;
6
+
7
+ public class PromptResult implements Result {
8
+
9
+ private final boolean canceled;
10
+
11
+ @NonNull
12
+ private final String value;
13
+
14
+ public PromptResult(@NonNull String value, boolean canceled) {
15
+ this.value = value;
16
+ this.canceled = canceled;
17
+ }
18
+
19
+ @Override
20
+ @NonNull
21
+ public JSObject toJSObject() {
22
+ JSObject result = new JSObject();
23
+ result.put("canceled", canceled);
24
+ result.put("value", value);
25
+ return result;
26
+ }
27
+ }
@@ -0,0 +1,5 @@
1
+ package io.capawesome.capacitorjs.plugins.dialog.interfaces;
2
+
3
+ public interface Callback {
4
+ void error(Exception exception);
5
+ }
@@ -0,0 +1,5 @@
1
+ package io.capawesome.capacitorjs.plugins.dialog.interfaces;
2
+
3
+ public interface EmptyCallback extends Callback {
4
+ void success();
5
+ }
@@ -0,0 +1,7 @@
1
+ package io.capawesome.capacitorjs.plugins.dialog.interfaces;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ public interface NonEmptyResultCallback<T extends Result> extends Callback {
6
+ void success(@NonNull T result);
7
+ }
@@ -0,0 +1,7 @@
1
+ package io.capawesome.capacitorjs.plugins.dialog.interfaces;
2
+
3
+ import com.getcapacitor.JSObject;
4
+
5
+ public interface Result {
6
+ JSObject toJSObject();
7
+ }
File without changes
package/dist/docs.json ADDED
@@ -0,0 +1,433 @@
1
+ {
2
+ "api": {
3
+ "name": "DialogPlugin",
4
+ "slug": "dialogplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "alert",
10
+ "signature": "(options: AlertOptions) => Promise<void>",
11
+ "parameters": [
12
+ {
13
+ "name": "options",
14
+ "docs": "",
15
+ "type": "AlertOptions"
16
+ }
17
+ ],
18
+ "returns": "Promise<void>",
19
+ "tags": [
20
+ {
21
+ "name": "since",
22
+ "text": "0.1.0"
23
+ }
24
+ ],
25
+ "docs": "Display an alert dialog with a single button.",
26
+ "complexTypes": [
27
+ "AlertOptions"
28
+ ],
29
+ "slug": "alert"
30
+ },
31
+ {
32
+ "name": "confirm",
33
+ "signature": "(options: ConfirmOptions) => Promise<ConfirmResult>",
34
+ "parameters": [
35
+ {
36
+ "name": "options",
37
+ "docs": "",
38
+ "type": "ConfirmOptions"
39
+ }
40
+ ],
41
+ "returns": "Promise<ConfirmResult>",
42
+ "tags": [
43
+ {
44
+ "name": "since",
45
+ "text": "0.1.0"
46
+ }
47
+ ],
48
+ "docs": "Display a confirmation dialog with two buttons.",
49
+ "complexTypes": [
50
+ "ConfirmResult",
51
+ "ConfirmOptions"
52
+ ],
53
+ "slug": "confirm"
54
+ },
55
+ {
56
+ "name": "prompt",
57
+ "signature": "(options: PromptOptions) => Promise<PromptResult>",
58
+ "parameters": [
59
+ {
60
+ "name": "options",
61
+ "docs": "",
62
+ "type": "PromptOptions"
63
+ }
64
+ ],
65
+ "returns": "Promise<PromptResult>",
66
+ "tags": [
67
+ {
68
+ "name": "since",
69
+ "text": "0.1.0"
70
+ }
71
+ ],
72
+ "docs": "Display a prompt dialog with a text input, a confirm and a cancel button.",
73
+ "complexTypes": [
74
+ "PromptResult",
75
+ "PromptOptions"
76
+ ],
77
+ "slug": "prompt"
78
+ }
79
+ ],
80
+ "properties": []
81
+ },
82
+ "interfaces": [
83
+ {
84
+ "name": "AlertOptions",
85
+ "slug": "alertoptions",
86
+ "docs": "",
87
+ "tags": [
88
+ {
89
+ "text": "0.1.0",
90
+ "name": "since"
91
+ }
92
+ ],
93
+ "methods": [],
94
+ "properties": [
95
+ {
96
+ "name": "buttonTitle",
97
+ "tags": [
98
+ {
99
+ "text": "0.1.0",
100
+ "name": "since"
101
+ },
102
+ {
103
+ "text": "'OK'",
104
+ "name": "default"
105
+ },
106
+ {
107
+ "text": "'Got it'",
108
+ "name": "example"
109
+ }
110
+ ],
111
+ "docs": "The title of the button that confirms the dialog.\n\nOn the web, the button title cannot be customized and is ignored.",
112
+ "complexTypes": [],
113
+ "type": "string | undefined"
114
+ },
115
+ {
116
+ "name": "message",
117
+ "tags": [
118
+ {
119
+ "text": "0.1.0",
120
+ "name": "since"
121
+ },
122
+ {
123
+ "text": "'Your changes have been saved.'",
124
+ "name": "example"
125
+ }
126
+ ],
127
+ "docs": "The message to display in the dialog.",
128
+ "complexTypes": [],
129
+ "type": "string"
130
+ },
131
+ {
132
+ "name": "title",
133
+ "tags": [
134
+ {
135
+ "text": "0.1.0",
136
+ "name": "since"
137
+ },
138
+ {
139
+ "text": "'Success'",
140
+ "name": "example"
141
+ }
142
+ ],
143
+ "docs": "The title of the dialog.\n\nOn the web, the title cannot be customized and is ignored.",
144
+ "complexTypes": [],
145
+ "type": "string | undefined"
146
+ }
147
+ ]
148
+ },
149
+ {
150
+ "name": "ConfirmResult",
151
+ "slug": "confirmresult",
152
+ "docs": "",
153
+ "tags": [
154
+ {
155
+ "text": "0.1.0",
156
+ "name": "since"
157
+ }
158
+ ],
159
+ "methods": [],
160
+ "properties": [
161
+ {
162
+ "name": "value",
163
+ "tags": [
164
+ {
165
+ "text": "0.1.0",
166
+ "name": "since"
167
+ },
168
+ {
169
+ "text": "true",
170
+ "name": "example"
171
+ }
172
+ ],
173
+ "docs": "Whether the user confirmed the dialog.",
174
+ "complexTypes": [],
175
+ "type": "boolean"
176
+ }
177
+ ]
178
+ },
179
+ {
180
+ "name": "ConfirmOptions",
181
+ "slug": "confirmoptions",
182
+ "docs": "",
183
+ "tags": [
184
+ {
185
+ "text": "0.1.0",
186
+ "name": "since"
187
+ }
188
+ ],
189
+ "methods": [],
190
+ "properties": [
191
+ {
192
+ "name": "cancelButtonTitle",
193
+ "tags": [
194
+ {
195
+ "text": "0.1.0",
196
+ "name": "since"
197
+ },
198
+ {
199
+ "text": "'Cancel'",
200
+ "name": "default"
201
+ },
202
+ {
203
+ "text": "'No'",
204
+ "name": "example"
205
+ }
206
+ ],
207
+ "docs": "The title of the button that cancels the dialog.\n\nOn the web, the button title cannot be customized and is ignored.",
208
+ "complexTypes": [],
209
+ "type": "string | undefined"
210
+ },
211
+ {
212
+ "name": "message",
213
+ "tags": [
214
+ {
215
+ "text": "0.1.0",
216
+ "name": "since"
217
+ },
218
+ {
219
+ "text": "'Do you want to delete this item?'",
220
+ "name": "example"
221
+ }
222
+ ],
223
+ "docs": "The message to display in the dialog.",
224
+ "complexTypes": [],
225
+ "type": "string"
226
+ },
227
+ {
228
+ "name": "okButtonTitle",
229
+ "tags": [
230
+ {
231
+ "text": "0.1.0",
232
+ "name": "since"
233
+ },
234
+ {
235
+ "text": "'OK'",
236
+ "name": "default"
237
+ },
238
+ {
239
+ "text": "'Yes'",
240
+ "name": "example"
241
+ }
242
+ ],
243
+ "docs": "The title of the button that confirms the dialog.\n\nOn the web, the button title cannot be customized and is ignored.",
244
+ "complexTypes": [],
245
+ "type": "string | undefined"
246
+ },
247
+ {
248
+ "name": "title",
249
+ "tags": [
250
+ {
251
+ "text": "0.1.0",
252
+ "name": "since"
253
+ },
254
+ {
255
+ "text": "'Confirm'",
256
+ "name": "example"
257
+ }
258
+ ],
259
+ "docs": "The title of the dialog.\n\nOn the web, the title cannot be customized and is ignored.",
260
+ "complexTypes": [],
261
+ "type": "string | undefined"
262
+ }
263
+ ]
264
+ },
265
+ {
266
+ "name": "PromptResult",
267
+ "slug": "promptresult",
268
+ "docs": "",
269
+ "tags": [
270
+ {
271
+ "text": "0.1.0",
272
+ "name": "since"
273
+ }
274
+ ],
275
+ "methods": [],
276
+ "properties": [
277
+ {
278
+ "name": "canceled",
279
+ "tags": [
280
+ {
281
+ "text": "0.1.0",
282
+ "name": "since"
283
+ },
284
+ {
285
+ "text": "false",
286
+ "name": "example"
287
+ }
288
+ ],
289
+ "docs": "Whether the user canceled the dialog.",
290
+ "complexTypes": [],
291
+ "type": "boolean"
292
+ },
293
+ {
294
+ "name": "value",
295
+ "tags": [
296
+ {
297
+ "text": "0.1.0",
298
+ "name": "since"
299
+ },
300
+ {
301
+ "text": "'John Doe'",
302
+ "name": "example"
303
+ }
304
+ ],
305
+ "docs": "The value of the text input.",
306
+ "complexTypes": [],
307
+ "type": "string"
308
+ }
309
+ ]
310
+ },
311
+ {
312
+ "name": "PromptOptions",
313
+ "slug": "promptoptions",
314
+ "docs": "",
315
+ "tags": [
316
+ {
317
+ "text": "0.1.0",
318
+ "name": "since"
319
+ }
320
+ ],
321
+ "methods": [],
322
+ "properties": [
323
+ {
324
+ "name": "cancelButtonTitle",
325
+ "tags": [
326
+ {
327
+ "text": "0.1.0",
328
+ "name": "since"
329
+ },
330
+ {
331
+ "text": "'Cancel'",
332
+ "name": "default"
333
+ },
334
+ {
335
+ "text": "'No'",
336
+ "name": "example"
337
+ }
338
+ ],
339
+ "docs": "The title of the button that cancels the dialog.\n\nOn the web, the button title cannot be customized and is ignored.",
340
+ "complexTypes": [],
341
+ "type": "string | undefined"
342
+ },
343
+ {
344
+ "name": "inputPlaceholder",
345
+ "tags": [
346
+ {
347
+ "text": "0.1.0",
348
+ "name": "since"
349
+ },
350
+ {
351
+ "text": "'Enter your name'",
352
+ "name": "example"
353
+ }
354
+ ],
355
+ "docs": "The placeholder of the text input.\n\nOn the web, the placeholder cannot be customized and is ignored.",
356
+ "complexTypes": [],
357
+ "type": "string | undefined"
358
+ },
359
+ {
360
+ "name": "inputText",
361
+ "tags": [
362
+ {
363
+ "text": "0.1.0",
364
+ "name": "since"
365
+ },
366
+ {
367
+ "text": "'John Doe'",
368
+ "name": "example"
369
+ }
370
+ ],
371
+ "docs": "The initial value of the text input.",
372
+ "complexTypes": [],
373
+ "type": "string | undefined"
374
+ },
375
+ {
376
+ "name": "message",
377
+ "tags": [
378
+ {
379
+ "text": "0.1.0",
380
+ "name": "since"
381
+ },
382
+ {
383
+ "text": "'What is your name?'",
384
+ "name": "example"
385
+ }
386
+ ],
387
+ "docs": "The message to display in the dialog.",
388
+ "complexTypes": [],
389
+ "type": "string"
390
+ },
391
+ {
392
+ "name": "okButtonTitle",
393
+ "tags": [
394
+ {
395
+ "text": "0.1.0",
396
+ "name": "since"
397
+ },
398
+ {
399
+ "text": "'OK'",
400
+ "name": "default"
401
+ },
402
+ {
403
+ "text": "'Submit'",
404
+ "name": "example"
405
+ }
406
+ ],
407
+ "docs": "The title of the button that confirms the dialog.\n\nOn the web, the button title cannot be customized and is ignored.",
408
+ "complexTypes": [],
409
+ "type": "string | undefined"
410
+ },
411
+ {
412
+ "name": "title",
413
+ "tags": [
414
+ {
415
+ "text": "0.1.0",
416
+ "name": "since"
417
+ },
418
+ {
419
+ "text": "'Name'",
420
+ "name": "example"
421
+ }
422
+ ],
423
+ "docs": "The title of the dialog.\n\nOn the web, the title cannot be customized and is ignored.",
424
+ "complexTypes": [],
425
+ "type": "string | undefined"
426
+ }
427
+ ]
428
+ }
429
+ ],
430
+ "enums": [],
431
+ "typeAliases": [],
432
+ "pluginConfigs": []
433
+ }