capacitor-extended-dialog 0.0.2 → 0.0.4
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 +131 -61
- package/android/src/main/java/com/albermonte/extendeddialog/ExtendedDialog.java +37 -1
- package/android/src/main/java/com/albermonte/extendeddialog/ExtendedDialogPlugin.java +45 -0
- package/android/src/main/java/com/albermonte/extendeddialog/FullScreenDialogFragment.java +12 -23
- package/android/src/main/java/com/albermonte/extendeddialog/SheetBottomDialogFragment.java +430 -0
- package/android/src/main/res/values/themes.xml +14 -0
- package/dist/docs.json +280 -49
- package/dist/esm/definitions.d.ts +169 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +3 -1
- package/dist/esm/web.js +93 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +93 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +93 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/ExtendedDialogPlugin/ExtendedDialog.swift +104 -2
- package/ios/Sources/ExtendedDialogPlugin/ExtendedDialogPlugin.swift +31 -1
- package/ios/Sources/ExtendedDialogPlugin/FullScreenDialogViewController.swift +441 -72
- package/package.json +2 -2
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dialog presentation mode.
|
|
3
|
+
*
|
|
4
|
+
* - `'basic'` — Standard modal dialog (default)
|
|
5
|
+
* - `'fullscreen'` — Full-screen dialog presentation
|
|
6
|
+
*/
|
|
1
7
|
export declare type DialogMode = 'basic' | 'fullscreen';
|
|
2
8
|
export interface DialogStyleOptions {
|
|
3
9
|
/**
|
|
@@ -34,21 +40,63 @@ export interface DialogStyleOptions {
|
|
|
34
40
|
buttonFontSize?: number;
|
|
35
41
|
}
|
|
36
42
|
export interface BaseDialogOptions extends DialogStyleOptions {
|
|
43
|
+
/**
|
|
44
|
+
* Title displayed at the top of the dialog.
|
|
45
|
+
*/
|
|
37
46
|
title?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Message body displayed in the dialog.
|
|
49
|
+
*/
|
|
38
50
|
message: string;
|
|
51
|
+
/**
|
|
52
|
+
* Presentation mode for the dialog.
|
|
53
|
+
*
|
|
54
|
+
* @default 'basic'
|
|
55
|
+
*/
|
|
39
56
|
mode?: DialogMode;
|
|
40
57
|
}
|
|
41
58
|
export interface AlertOptions extends BaseDialogOptions {
|
|
59
|
+
/**
|
|
60
|
+
* Title for the dismiss button.
|
|
61
|
+
*
|
|
62
|
+
* @default "OK"
|
|
63
|
+
*/
|
|
42
64
|
buttonTitle?: string;
|
|
43
65
|
}
|
|
44
66
|
export interface ConfirmOptions extends BaseDialogOptions {
|
|
67
|
+
/**
|
|
68
|
+
* Title for the confirmation button.
|
|
69
|
+
*
|
|
70
|
+
* @default "OK"
|
|
71
|
+
*/
|
|
45
72
|
okButtonTitle?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Title for the cancel button.
|
|
75
|
+
*
|
|
76
|
+
* @default "Cancel"
|
|
77
|
+
*/
|
|
46
78
|
cancelButtonTitle?: string;
|
|
47
79
|
}
|
|
48
80
|
export interface PromptOptions extends BaseDialogOptions {
|
|
81
|
+
/**
|
|
82
|
+
* Title for the confirmation button.
|
|
83
|
+
*
|
|
84
|
+
* @default "OK"
|
|
85
|
+
*/
|
|
49
86
|
okButtonTitle?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Title for the cancel button.
|
|
89
|
+
*
|
|
90
|
+
* @default "Cancel"
|
|
91
|
+
*/
|
|
50
92
|
cancelButtonTitle?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Placeholder text shown in the input field when empty.
|
|
95
|
+
*/
|
|
51
96
|
inputPlaceholder?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Pre-filled value for the input field.
|
|
99
|
+
*/
|
|
52
100
|
inputText?: string;
|
|
53
101
|
/**
|
|
54
102
|
* Whether to automatically focus the input field and open the keyboard when the dialog appears.
|
|
@@ -62,40 +110,161 @@ export interface PromptOptions extends BaseDialogOptions {
|
|
|
62
110
|
focusInput?: boolean;
|
|
63
111
|
}
|
|
64
112
|
export interface SelectOption {
|
|
113
|
+
/**
|
|
114
|
+
* Display text for the option.
|
|
115
|
+
*/
|
|
65
116
|
label: string;
|
|
117
|
+
/**
|
|
118
|
+
* Value returned when the option is selected.
|
|
119
|
+
*/
|
|
66
120
|
value: string;
|
|
67
121
|
}
|
|
68
122
|
export interface SingleSelectOptions extends BaseDialogOptions {
|
|
123
|
+
/**
|
|
124
|
+
* List of options to display for selection.
|
|
125
|
+
*/
|
|
69
126
|
options: SelectOption[];
|
|
127
|
+
/**
|
|
128
|
+
* Value of the initially selected option.
|
|
129
|
+
*/
|
|
70
130
|
selectedValue?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Title for the confirmation button.
|
|
133
|
+
*
|
|
134
|
+
* @default "OK"
|
|
135
|
+
*/
|
|
71
136
|
okButtonTitle?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Title for the cancel button.
|
|
139
|
+
*
|
|
140
|
+
* @default "Cancel"
|
|
141
|
+
*/
|
|
72
142
|
cancelButtonTitle?: string;
|
|
73
143
|
}
|
|
74
144
|
export interface MultiSelectOptions extends BaseDialogOptions {
|
|
145
|
+
/**
|
|
146
|
+
* List of options to display for selection.
|
|
147
|
+
*/
|
|
75
148
|
options: SelectOption[];
|
|
149
|
+
/**
|
|
150
|
+
* Values of the initially selected options.
|
|
151
|
+
*/
|
|
76
152
|
selectedValues?: string[];
|
|
153
|
+
/**
|
|
154
|
+
* Title for the confirmation button.
|
|
155
|
+
*
|
|
156
|
+
* @default "OK"
|
|
157
|
+
*/
|
|
77
158
|
okButtonTitle?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Title for the cancel button.
|
|
161
|
+
*
|
|
162
|
+
* @default "Cancel"
|
|
163
|
+
*/
|
|
78
164
|
cancelButtonTitle?: string;
|
|
79
165
|
}
|
|
80
166
|
export interface ConfirmResult {
|
|
167
|
+
/**
|
|
168
|
+
* Whether the user confirmed (`true`) or cancelled (`false`).
|
|
169
|
+
*/
|
|
81
170
|
value: boolean;
|
|
82
171
|
}
|
|
83
172
|
export interface PromptResult {
|
|
173
|
+
/**
|
|
174
|
+
* The text entered by the user. Empty string if cancelled.
|
|
175
|
+
*/
|
|
84
176
|
value: string;
|
|
177
|
+
/**
|
|
178
|
+
* Whether the user cancelled the dialog.
|
|
179
|
+
*/
|
|
85
180
|
cancelled: boolean;
|
|
86
181
|
}
|
|
87
182
|
export interface SingleSelectResult {
|
|
183
|
+
/**
|
|
184
|
+
* The value of the selected option, or `null` if cancelled.
|
|
185
|
+
*/
|
|
88
186
|
value: string | null;
|
|
187
|
+
/**
|
|
188
|
+
* Whether the user cancelled the dialog.
|
|
189
|
+
*/
|
|
89
190
|
cancelled: boolean;
|
|
90
191
|
}
|
|
91
192
|
export interface MultiSelectResult {
|
|
193
|
+
/**
|
|
194
|
+
* The values of the selected options. Empty array if cancelled.
|
|
195
|
+
*/
|
|
92
196
|
values: string[];
|
|
197
|
+
/**
|
|
198
|
+
* Whether the user cancelled the dialog.
|
|
199
|
+
*/
|
|
93
200
|
cancelled: boolean;
|
|
94
201
|
}
|
|
202
|
+
export interface SheetRow {
|
|
203
|
+
/** Row title (required) */
|
|
204
|
+
title: string;
|
|
205
|
+
/** Optional logo/icon - supports base64 data URL or HTTP/HTTPS URL */
|
|
206
|
+
logo?: string;
|
|
207
|
+
/** Optional value displayed on the right */
|
|
208
|
+
value?: string;
|
|
209
|
+
}
|
|
210
|
+
export interface SheetOptions extends DialogStyleOptions {
|
|
211
|
+
/** Header logo - supports base64 data URL or HTTP/HTTPS URL */
|
|
212
|
+
headerLogo?: string;
|
|
213
|
+
/** Sheet title */
|
|
214
|
+
title: string;
|
|
215
|
+
/** Description rows */
|
|
216
|
+
rows: SheetRow[];
|
|
217
|
+
/** Confirm button title */
|
|
218
|
+
confirmButtonTitle?: string;
|
|
219
|
+
/** Cancel button title */
|
|
220
|
+
cancelButtonTitle?: string;
|
|
221
|
+
/** Dialog mode */
|
|
222
|
+
mode?: DialogMode;
|
|
223
|
+
}
|
|
224
|
+
export interface SheetResult {
|
|
225
|
+
/** True if confirmed, false if cancelled */
|
|
226
|
+
confirmed: boolean;
|
|
227
|
+
}
|
|
95
228
|
export interface ExtendedDialogPlugin {
|
|
229
|
+
/**
|
|
230
|
+
* Show an alert dialog with a single dismiss button.
|
|
231
|
+
*
|
|
232
|
+
* @param options - Alert configuration options.
|
|
233
|
+
*/
|
|
96
234
|
alert(options: AlertOptions): Promise<void>;
|
|
235
|
+
/**
|
|
236
|
+
* Show a confirmation dialog with OK and Cancel buttons.
|
|
237
|
+
*
|
|
238
|
+
* @param options - Confirm configuration options.
|
|
239
|
+
* @returns The user's confirmation choice.
|
|
240
|
+
*/
|
|
97
241
|
confirm(options: ConfirmOptions): Promise<ConfirmResult>;
|
|
242
|
+
/**
|
|
243
|
+
* Show a prompt dialog with a text input field.
|
|
244
|
+
*
|
|
245
|
+
* @param options - Prompt configuration options.
|
|
246
|
+
* @returns The entered text and whether the dialog was cancelled.
|
|
247
|
+
*/
|
|
98
248
|
prompt(options: PromptOptions): Promise<PromptResult>;
|
|
249
|
+
/**
|
|
250
|
+
* Show a single-select dialog where the user picks one option.
|
|
251
|
+
*
|
|
252
|
+
* @param options - Single select configuration options.
|
|
253
|
+
* @returns The selected value and whether the dialog was cancelled.
|
|
254
|
+
*/
|
|
99
255
|
singleSelect(options: SingleSelectOptions): Promise<SingleSelectResult>;
|
|
256
|
+
/**
|
|
257
|
+
* Show a multi-select dialog where the user picks one or more options.
|
|
258
|
+
*
|
|
259
|
+
* @param options - Multi select configuration options.
|
|
260
|
+
* @returns The selected values and whether the dialog was cancelled.
|
|
261
|
+
*/
|
|
100
262
|
multiSelect(options: MultiSelectOptions): Promise<MultiSelectResult>;
|
|
263
|
+
/**
|
|
264
|
+
* Show a sheet dialog with a header, title, and structured data rows.
|
|
265
|
+
*
|
|
266
|
+
* @param options - Sheet configuration options.
|
|
267
|
+
* @returns Whether the user confirmed or cancelled the sheet.
|
|
268
|
+
*/
|
|
269
|
+
sheet(options: SheetOptions): Promise<SheetResult>;
|
|
101
270
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Dialog presentation mode.\n *\n * - `'basic'` — Standard modal dialog (default)\n * - `'fullscreen'` — Full-screen dialog presentation\n */\nexport type DialogMode = 'basic' | 'fullscreen';\n\nexport interface DialogStyleOptions {\n /**\n * Color for the OK/primary button (hex format, e.g., \"#FF5722\")\n */\n buttonColor?: string;\n /**\n * Color for the cancel button (hex format, e.g., \"#757575\")\n */\n cancelButtonColor?: string;\n /**\n * Color for the title text (hex format, e.g., \"#000000\")\n */\n titleColor?: string;\n /**\n * Color for the message text (hex format, e.g., \"#666666\")\n */\n messageColor?: string;\n /**\n * Background color of the dialog (hex format, e.g., \"#FFFFFF\")\n */\n backgroundColor?: string;\n /**\n * Font size for the title text in sp/pt (e.g., 20)\n */\n titleFontSize?: number;\n /**\n * Font size for the message text in sp/pt (e.g., 16)\n */\n messageFontSize?: number;\n /**\n * Font size for the button text in sp/pt (e.g., 14)\n */\n buttonFontSize?: number;\n}\n\nexport interface BaseDialogOptions extends DialogStyleOptions {\n /**\n * Title displayed at the top of the dialog.\n */\n title?: string;\n /**\n * Message body displayed in the dialog.\n */\n message: string;\n /**\n * Presentation mode for the dialog.\n *\n * @default 'basic'\n */\n mode?: DialogMode;\n}\n\nexport interface AlertOptions extends BaseDialogOptions {\n /**\n * Title for the dismiss button.\n *\n * @default \"OK\"\n */\n buttonTitle?: string;\n}\n\nexport interface ConfirmOptions extends BaseDialogOptions {\n /**\n * Title for the confirmation button.\n *\n * @default \"OK\"\n */\n okButtonTitle?: string;\n /**\n * Title for the cancel button.\n *\n * @default \"Cancel\"\n */\n cancelButtonTitle?: string;\n}\n\nexport interface PromptOptions extends BaseDialogOptions {\n /**\n * Title for the confirmation button.\n *\n * @default \"OK\"\n */\n okButtonTitle?: string;\n /**\n * Title for the cancel button.\n *\n * @default \"Cancel\"\n */\n cancelButtonTitle?: string;\n /**\n * Placeholder text shown in the input field when empty.\n */\n inputPlaceholder?: string;\n /**\n * Pre-filled value for the input field.\n */\n inputText?: string;\n /**\n * Whether to automatically focus the input field and open the keyboard when the dialog appears.\n *\n * Note: On iOS, basic (non-fullscreen) dialogs always auto-focus the input field due to\n * UIAlertController's built-in behavior. This option only takes effect on iOS when using\n * fullscreen mode (`mode: 'fullscreen'`). On Android and web, this works for all modes.\n *\n * @default false\n */\n focusInput?: boolean;\n}\n\nexport interface SelectOption {\n /**\n * Display text for the option.\n */\n label: string;\n /**\n * Value returned when the option is selected.\n */\n value: string;\n}\n\nexport interface SingleSelectOptions extends BaseDialogOptions {\n /**\n * List of options to display for selection.\n */\n options: SelectOption[];\n /**\n * Value of the initially selected option.\n */\n selectedValue?: string;\n /**\n * Title for the confirmation button.\n *\n * @default \"OK\"\n */\n okButtonTitle?: string;\n /**\n * Title for the cancel button.\n *\n * @default \"Cancel\"\n */\n cancelButtonTitle?: string;\n}\n\nexport interface MultiSelectOptions extends BaseDialogOptions {\n /**\n * List of options to display for selection.\n */\n options: SelectOption[];\n /**\n * Values of the initially selected options.\n */\n selectedValues?: string[];\n /**\n * Title for the confirmation button.\n *\n * @default \"OK\"\n */\n okButtonTitle?: string;\n /**\n * Title for the cancel button.\n *\n * @default \"Cancel\"\n */\n cancelButtonTitle?: string;\n}\n\nexport interface ConfirmResult {\n /**\n * Whether the user confirmed (`true`) or cancelled (`false`).\n */\n value: boolean;\n}\n\nexport interface PromptResult {\n /**\n * The text entered by the user. Empty string if cancelled.\n */\n value: string;\n /**\n * Whether the user cancelled the dialog.\n */\n cancelled: boolean;\n}\n\nexport interface SingleSelectResult {\n /**\n * The value of the selected option, or `null` if cancelled.\n */\n value: string | null;\n /**\n * Whether the user cancelled the dialog.\n */\n cancelled: boolean;\n}\n\nexport interface MultiSelectResult {\n /**\n * The values of the selected options. Empty array if cancelled.\n */\n values: string[];\n /**\n * Whether the user cancelled the dialog.\n */\n cancelled: boolean;\n}\n\nexport interface SheetRow {\n /** Row title (required) */\n title: string;\n /** Optional logo/icon - supports base64 data URL or HTTP/HTTPS URL */\n logo?: string;\n /** Optional value displayed on the right */\n value?: string;\n}\n\nexport interface SheetOptions extends DialogStyleOptions {\n /** Header logo - supports base64 data URL or HTTP/HTTPS URL */\n headerLogo?: string;\n /** Sheet title */\n title: string;\n /** Description rows */\n rows: SheetRow[];\n /** Confirm button title */\n confirmButtonTitle?: string; // default: \"Confirm\"\n /** Cancel button title */\n cancelButtonTitle?: string; // default: \"Cancel\"\n /** Dialog mode */\n mode?: DialogMode;\n}\n\nexport interface SheetResult {\n /** True if confirmed, false if cancelled */\n confirmed: boolean;\n}\n\nexport interface ExtendedDialogPlugin {\n /**\n * Show an alert dialog with a single dismiss button.\n *\n * @param options - Alert configuration options.\n */\n alert(options: AlertOptions): Promise<void>;\n /**\n * Show a confirmation dialog with OK and Cancel buttons.\n *\n * @param options - Confirm configuration options.\n * @returns The user's confirmation choice.\n */\n confirm(options: ConfirmOptions): Promise<ConfirmResult>;\n /**\n * Show a prompt dialog with a text input field.\n *\n * @param options - Prompt configuration options.\n * @returns The entered text and whether the dialog was cancelled.\n */\n prompt(options: PromptOptions): Promise<PromptResult>;\n /**\n * Show a single-select dialog where the user picks one option.\n *\n * @param options - Single select configuration options.\n * @returns The selected value and whether the dialog was cancelled.\n */\n singleSelect(options: SingleSelectOptions): Promise<SingleSelectResult>;\n /**\n * Show a multi-select dialog where the user picks one or more options.\n *\n * @param options - Multi select configuration options.\n * @returns The selected values and whether the dialog was cancelled.\n */\n multiSelect(options: MultiSelectOptions): Promise<MultiSelectResult>;\n /**\n * Show a sheet dialog with a header, title, and structured data rows.\n *\n * @param options - Sheet configuration options.\n * @returns Whether the user confirmed or cancelled the sheet.\n */\n sheet(options: SheetOptions): Promise<SheetResult>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type { ExtendedDialogPlugin, AlertOptions, ConfirmOptions, ConfirmResult, PromptOptions, PromptResult, SingleSelectOptions, SingleSelectResult, MultiSelectOptions, MultiSelectResult } from './definitions';
|
|
2
|
+
import type { ExtendedDialogPlugin, AlertOptions, ConfirmOptions, ConfirmResult, PromptOptions, PromptResult, SingleSelectOptions, SingleSelectResult, MultiSelectOptions, MultiSelectResult, SheetOptions, SheetResult } from './definitions';
|
|
3
3
|
export declare class ExtendedDialogWeb extends WebPlugin implements ExtendedDialogPlugin {
|
|
4
4
|
alert(options: AlertOptions): Promise<void>;
|
|
5
5
|
confirm(options: ConfirmOptions): Promise<ConfirmResult>;
|
|
@@ -11,4 +11,6 @@ export declare class ExtendedDialogWeb extends WebPlugin implements ExtendedDial
|
|
|
11
11
|
private createButtonContainer;
|
|
12
12
|
private createButton;
|
|
13
13
|
private removeOverlay;
|
|
14
|
+
sheet(options: SheetOptions): Promise<SheetResult>;
|
|
15
|
+
private createSheetDialogContainer;
|
|
14
16
|
}
|
package/dist/esm/web.js
CHANGED
|
@@ -189,5 +189,98 @@ export class ExtendedDialogWeb extends WebPlugin {
|
|
|
189
189
|
removeOverlay(overlay) {
|
|
190
190
|
overlay.remove();
|
|
191
191
|
}
|
|
192
|
+
async sheet(options) {
|
|
193
|
+
return new Promise((resolve) => {
|
|
194
|
+
var _a, _b, _c, _d;
|
|
195
|
+
const overlay = this.createOverlay();
|
|
196
|
+
const dialog = this.createSheetDialogContainer(options);
|
|
197
|
+
// Header section with logo and title
|
|
198
|
+
const headerSection = document.createElement('div');
|
|
199
|
+
headerSection.style.cssText = 'display: flex; flex-direction: column; align-items: center; margin-bottom: 24px;';
|
|
200
|
+
if (options.headerLogo) {
|
|
201
|
+
const headerLogo = document.createElement('img');
|
|
202
|
+
headerLogo.src = options.headerLogo;
|
|
203
|
+
headerLogo.style.cssText = 'width: 48px; height: 48px; object-fit: contain; margin-bottom: 12px; border-radius: 8px;';
|
|
204
|
+
headerLogo.onerror = () => {
|
|
205
|
+
headerLogo.style.display = 'none';
|
|
206
|
+
};
|
|
207
|
+
headerSection.appendChild(headerLogo);
|
|
208
|
+
}
|
|
209
|
+
const titleEl = document.createElement('h2');
|
|
210
|
+
titleEl.textContent = options.title;
|
|
211
|
+
const titleFontSize = (_a = options.titleFontSize) !== null && _a !== void 0 ? _a : 20;
|
|
212
|
+
const titleColor = (_b = options.titleColor) !== null && _b !== void 0 ? _b : 'inherit';
|
|
213
|
+
titleEl.style.cssText = `margin: 0; font-size: ${titleFontSize}px; font-weight: 600; color: ${titleColor}; text-align: center;`;
|
|
214
|
+
headerSection.appendChild(titleEl);
|
|
215
|
+
dialog.appendChild(headerSection);
|
|
216
|
+
// Rows container
|
|
217
|
+
const rowsContainer = document.createElement('div');
|
|
218
|
+
rowsContainer.style.cssText = 'display: flex; flex-direction: column; gap: 0; margin-bottom: 24px;';
|
|
219
|
+
options.rows.forEach((row, index) => {
|
|
220
|
+
var _a, _b;
|
|
221
|
+
const rowEl = document.createElement('div');
|
|
222
|
+
rowEl.style.cssText = `
|
|
223
|
+
display: flex;
|
|
224
|
+
align-items: center;
|
|
225
|
+
padding: 16px 0;
|
|
226
|
+
${index < options.rows.length - 1 ? 'border-bottom: 1px solid #e0e0e0;' : ''}
|
|
227
|
+
`;
|
|
228
|
+
if (row.logo) {
|
|
229
|
+
const rowLogo = document.createElement('img');
|
|
230
|
+
rowLogo.src = row.logo;
|
|
231
|
+
rowLogo.style.cssText = 'width: 24px; height: 24px; object-fit: contain; margin-right: 12px; border-radius: 4px; flex-shrink: 0;';
|
|
232
|
+
rowLogo.onerror = () => {
|
|
233
|
+
rowLogo.style.display = 'none';
|
|
234
|
+
};
|
|
235
|
+
rowEl.appendChild(rowLogo);
|
|
236
|
+
}
|
|
237
|
+
const rowTitle = document.createElement('span');
|
|
238
|
+
rowTitle.textContent = row.title;
|
|
239
|
+
const messageFontSize = (_a = options.messageFontSize) !== null && _a !== void 0 ? _a : 16;
|
|
240
|
+
const messageColor = (_b = options.messageColor) !== null && _b !== void 0 ? _b : '#333';
|
|
241
|
+
rowTitle.style.cssText = `font-size: ${messageFontSize}px; color: ${messageColor}; flex: 1;`;
|
|
242
|
+
rowEl.appendChild(rowTitle);
|
|
243
|
+
if (row.value) {
|
|
244
|
+
const rowValue = document.createElement('span');
|
|
245
|
+
rowValue.textContent = row.value;
|
|
246
|
+
rowValue.style.cssText = `font-size: ${messageFontSize}px; color: #666; text-align: right; margin-left: 12px;`;
|
|
247
|
+
rowEl.appendChild(rowValue);
|
|
248
|
+
}
|
|
249
|
+
rowsContainer.appendChild(rowEl);
|
|
250
|
+
});
|
|
251
|
+
dialog.appendChild(rowsContainer);
|
|
252
|
+
// Button container
|
|
253
|
+
const buttonContainer = this.createButtonContainer();
|
|
254
|
+
const cancelButton = this.createButton((_c = options.cancelButtonTitle) !== null && _c !== void 0 ? _c : 'Cancel', false, () => {
|
|
255
|
+
this.removeOverlay(overlay);
|
|
256
|
+
resolve({ confirmed: false });
|
|
257
|
+
}, options);
|
|
258
|
+
const confirmButton = this.createButton((_d = options.confirmButtonTitle) !== null && _d !== void 0 ? _d : 'Confirm', true, () => {
|
|
259
|
+
this.removeOverlay(overlay);
|
|
260
|
+
resolve({ confirmed: true });
|
|
261
|
+
}, options);
|
|
262
|
+
buttonContainer.appendChild(cancelButton);
|
|
263
|
+
buttonContainer.appendChild(confirmButton);
|
|
264
|
+
dialog.appendChild(buttonContainer);
|
|
265
|
+
overlay.appendChild(dialog);
|
|
266
|
+
document.body.appendChild(overlay);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
createSheetDialogContainer(options) {
|
|
270
|
+
var _a;
|
|
271
|
+
const dialog = document.createElement('div');
|
|
272
|
+
const bgColor = (_a = options.backgroundColor) !== null && _a !== void 0 ? _a : 'white';
|
|
273
|
+
dialog.style.cssText = `
|
|
274
|
+
background: ${bgColor};
|
|
275
|
+
border-radius: 16px;
|
|
276
|
+
padding: 24px;
|
|
277
|
+
min-width: 320px;
|
|
278
|
+
max-width: 420px;
|
|
279
|
+
max-height: 80vh;
|
|
280
|
+
overflow-y: auto;
|
|
281
|
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
|
|
282
|
+
`;
|
|
283
|
+
return dialog;
|
|
284
|
+
}
|
|
192
285
|
}
|
|
193
286
|
//# sourceMappingURL=web.js.map
|
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;AAgB5C,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC9C,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;QAC3F,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAuB;QACnC,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;QAC3F,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,MAAM,CA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,YAAY,CAAE,WAAW,mCAAI,SAAS,CAAC;QAC5D,MAAM,WAAW,SAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,iBAAiB,mCAAI,SAAS,CAAC;QACjE,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG;;;mBAGR,QAAQ;;;;QAInB,OAAO,CAAC,CAAC,CAAC,eAAe,YAAY,iBAAiB,CAAC,CAAC,CAAC,mCAAmC,WAAW,GAAG;KAC7G,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,aAAa,CAAC,OAAuB;QAC3C,OAAO,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n ExtendedDialogPlugin,\n AlertOptions,\n ConfirmOptions,\n ConfirmResult,\n PromptOptions,\n PromptResult,\n SingleSelectOptions,\n SingleSelectResult,\n MultiSelectOptions,\n MultiSelectResult,\n DialogStyleOptions,\n} from './definitions';\n\nexport class ExtendedDialogWeb extends WebPlugin implements ExtendedDialogPlugin {\n async alert(options: AlertOptions): Promise<void> {\n const message = options.title ? `${options.title}\\n\\n${options.message}` : options.message;\n window.alert(message);\n }\n\n async confirm(options: ConfirmOptions): Promise<ConfirmResult> {\n const message = options.title ? `${options.title}\\n\\n${options.message}` : options.message;\n const result = window.confirm(message);\n return { value: result };\n }\n\n async prompt(options: PromptOptions): Promise<PromptResult> {\n // Note: focusInput option is ignored on web as window.prompt() handles focus automatically\n // and does not provide programmatic control over keyboard/focus behavior\n const message = options.title ? `${options.title}\\n\\n${options.message}` : options.message;\n const result = window.prompt(message, options.inputText ?? '');\n return {\n value: result ?? '',\n cancelled: result === null,\n };\n }\n\n async singleSelect(options: SingleSelectOptions): Promise<SingleSelectResult> {\n return new Promise((resolve) => {\n const overlay = this.createOverlay();\n const dialog = this.createDialogContainer(options.title, options.message, options);\n\n const optionsContainer = document.createElement('div');\n optionsContainer.style.cssText = 'max-height: 300px; overflow-y: auto; margin: 16px 0;';\n\n let selectedValue = options.selectedValue ?? null;\n\n options.options.forEach((option) => {\n const label = document.createElement('label');\n label.style.cssText =\n 'display: flex; align-items: center; padding: 12px 0; cursor: pointer; border-bottom: 1px solid #e0e0e0;';\n\n const radio = document.createElement('input');\n radio.type = 'radio';\n radio.name = 'singleSelect';\n radio.value = option.value;\n radio.checked = option.value === selectedValue;\n radio.style.cssText = 'margin-right: 12px; width: 20px; height: 20px;';\n radio.addEventListener('change', () => {\n selectedValue = option.value;\n });\n\n const text = document.createElement('span');\n text.textContent = option.label;\n text.style.cssText = 'font-size: 16px;';\n\n label.appendChild(radio);\n label.appendChild(text);\n optionsContainer.appendChild(label);\n });\n\n dialog.appendChild(optionsContainer);\n\n const buttonContainer = this.createButtonContainer();\n\n const cancelButton = this.createButton(\n options.cancelButtonTitle ?? 'Cancel',\n false,\n () => {\n this.removeOverlay(overlay);\n resolve({ value: null, cancelled: true });\n },\n options,\n );\n\n const okButton = this.createButton(\n options.okButtonTitle ?? 'OK',\n true,\n () => {\n this.removeOverlay(overlay);\n resolve({ value: selectedValue, cancelled: false });\n },\n options,\n );\n\n buttonContainer.appendChild(cancelButton);\n buttonContainer.appendChild(okButton);\n dialog.appendChild(buttonContainer);\n overlay.appendChild(dialog);\n document.body.appendChild(overlay);\n });\n }\n\n async multiSelect(options: MultiSelectOptions): Promise<MultiSelectResult> {\n return new Promise((resolve) => {\n const overlay = this.createOverlay();\n const dialog = this.createDialogContainer(options.title, options.message, options);\n\n const optionsContainer = document.createElement('div');\n optionsContainer.style.cssText = 'max-height: 300px; overflow-y: auto; margin: 16px 0;';\n\n const selectedValues = new Set(options.selectedValues ?? []);\n\n options.options.forEach((option) => {\n const label = document.createElement('label');\n label.style.cssText =\n 'display: flex; align-items: center; padding: 12px 0; cursor: pointer; border-bottom: 1px solid #e0e0e0;';\n\n const checkbox = document.createElement('input');\n checkbox.type = 'checkbox';\n checkbox.value = option.value;\n checkbox.checked = selectedValues.has(option.value);\n checkbox.style.cssText = 'margin-right: 12px; width: 20px; height: 20px;';\n checkbox.addEventListener('change', () => {\n if (checkbox.checked) {\n selectedValues.add(option.value);\n } else {\n selectedValues.delete(option.value);\n }\n });\n\n const text = document.createElement('span');\n text.textContent = option.label;\n text.style.cssText = 'font-size: 16px;';\n\n label.appendChild(checkbox);\n label.appendChild(text);\n optionsContainer.appendChild(label);\n });\n\n dialog.appendChild(optionsContainer);\n\n const buttonContainer = this.createButtonContainer();\n\n const cancelButton = this.createButton(\n options.cancelButtonTitle ?? 'Cancel',\n false,\n () => {\n this.removeOverlay(overlay);\n resolve({ values: [], cancelled: true });\n },\n options,\n );\n\n const okButton = this.createButton(\n options.okButtonTitle ?? 'OK',\n true,\n () => {\n this.removeOverlay(overlay);\n resolve({ values: Array.from(selectedValues), cancelled: false });\n },\n options,\n );\n\n buttonContainer.appendChild(cancelButton);\n buttonContainer.appendChild(okButton);\n dialog.appendChild(buttonContainer);\n overlay.appendChild(dialog);\n document.body.appendChild(overlay);\n });\n }\n\n private createOverlay(): HTMLDivElement {\n const overlay = document.createElement('div');\n overlay.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 999999;\n `;\n return overlay;\n }\n\n private createDialogContainer(title?: string, message?: string, styleOptions?: DialogStyleOptions): HTMLDivElement {\n const dialog = document.createElement('div');\n const bgColor = styleOptions?.backgroundColor ?? 'white';\n dialog.style.cssText = `\n background: ${bgColor};\n border-radius: 16px;\n padding: 24px;\n min-width: 300px;\n max-width: 400px;\n max-height: 80vh;\n overflow-y: auto;\n box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);\n `;\n\n if (title) {\n const titleEl = document.createElement('h2');\n titleEl.textContent = title;\n const titleFontSize = styleOptions?.titleFontSize ?? 20;\n const titleColor = styleOptions?.titleColor ?? 'inherit';\n titleEl.style.cssText = `margin: 0 0 8px 0; font-size: ${titleFontSize}px; font-weight: 600; color: ${titleColor};`;\n dialog.appendChild(titleEl);\n }\n\n if (message) {\n const messageEl = document.createElement('p');\n messageEl.textContent = message;\n const messageFontSize = styleOptions?.messageFontSize ?? 14;\n const messageColor = styleOptions?.messageColor ?? '#666';\n messageEl.style.cssText = `margin: 0; font-size: ${messageFontSize}px; color: ${messageColor};`;\n dialog.appendChild(messageEl);\n }\n\n return dialog;\n }\n\n private createButtonContainer(): HTMLDivElement {\n const container = document.createElement('div');\n container.style.cssText = 'display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px;';\n return container;\n }\n\n private createButton(\n text: string,\n primary: boolean,\n onClick: () => void,\n styleOptions?: DialogStyleOptions,\n ): HTMLButtonElement {\n const button = document.createElement('button');\n button.textContent = text;\n const fontSize = styleOptions?.buttonFontSize ?? 14;\n const primaryColor = styleOptions?.buttonColor ?? '#6750A4';\n const cancelColor = styleOptions?.cancelButtonColor ?? '#6750A4';\n button.style.cssText = `\n padding: 10px 24px;\n border-radius: 8px;\n font-size: ${fontSize}px;\n font-weight: 500;\n cursor: pointer;\n border: none;\n ${primary ? `background: ${primaryColor}; color: white;` : `background: transparent; color: ${cancelColor};`}\n `;\n button.addEventListener('click', onClick);\n return button;\n }\n\n private removeOverlay(overlay: HTMLDivElement): void {\n overlay.remove();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAkB5C,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC9C,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC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n ConfirmOptions,\n ConfirmResult,\n PromptOptions,\n PromptResult,\n SingleSelectOptions,\n SingleSelectResult,\n MultiSelectOptions,\n MultiSelectResult,\n SheetOptions,\n SheetResult,\n DialogStyleOptions,\n} from './definitions';\n\nexport class ExtendedDialogWeb extends WebPlugin implements ExtendedDialogPlugin {\n async alert(options: AlertOptions): Promise<void> {\n const message = options.title ? `${options.title}\\n\\n${options.message}` : options.message;\n window.alert(message);\n }\n\n async confirm(options: ConfirmOptions): Promise<ConfirmResult> {\n const message = options.title ? `${options.title}\\n\\n${options.message}` : options.message;\n const result = window.confirm(message);\n return { value: result };\n }\n\n async prompt(options: PromptOptions): Promise<PromptResult> {\n // Note: focusInput option is ignored on web as window.prompt() handles focus automatically\n // and does not provide programmatic control over keyboard/focus behavior\n const message = options.title ? `${options.title}\\n\\n${options.message}` : options.message;\n const result = window.prompt(message, options.inputText ?? '');\n return {\n value: result ?? '',\n cancelled: result === null,\n };\n }\n\n async singleSelect(options: SingleSelectOptions): Promise<SingleSelectResult> {\n return new Promise((resolve) => {\n const overlay = this.createOverlay();\n const dialog = this.createDialogContainer(options.title, options.message, options);\n\n const optionsContainer = document.createElement('div');\n optionsContainer.style.cssText = 'max-height: 300px; overflow-y: auto; margin: 16px 0;';\n\n let selectedValue = options.selectedValue ?? null;\n\n options.options.forEach((option) => {\n const label = document.createElement('label');\n label.style.cssText =\n 'display: flex; align-items: center; padding: 12px 0; cursor: pointer; border-bottom: 1px solid #e0e0e0;';\n\n const radio = document.createElement('input');\n radio.type = 'radio';\n radio.name = 'singleSelect';\n radio.value = option.value;\n radio.checked = option.value === selectedValue;\n radio.style.cssText = 'margin-right: 12px; width: 20px; height: 20px;';\n radio.addEventListener('change', () => {\n selectedValue = option.value;\n });\n\n const text = document.createElement('span');\n text.textContent = option.label;\n text.style.cssText = 'font-size: 16px;';\n\n label.appendChild(radio);\n label.appendChild(text);\n optionsContainer.appendChild(label);\n });\n\n dialog.appendChild(optionsContainer);\n\n const buttonContainer = this.createButtonContainer();\n\n const cancelButton = this.createButton(\n options.cancelButtonTitle ?? 'Cancel',\n false,\n () => {\n this.removeOverlay(overlay);\n resolve({ value: null, cancelled: true });\n },\n options,\n );\n\n const okButton = this.createButton(\n options.okButtonTitle ?? 'OK',\n true,\n () => {\n this.removeOverlay(overlay);\n resolve({ value: selectedValue, cancelled: false });\n },\n options,\n );\n\n buttonContainer.appendChild(cancelButton);\n buttonContainer.appendChild(okButton);\n dialog.appendChild(buttonContainer);\n overlay.appendChild(dialog);\n document.body.appendChild(overlay);\n });\n }\n\n async multiSelect(options: MultiSelectOptions): Promise<MultiSelectResult> {\n return new Promise((resolve) => {\n const overlay = this.createOverlay();\n const dialog = this.createDialogContainer(options.title, options.message, options);\n\n const optionsContainer = document.createElement('div');\n optionsContainer.style.cssText = 'max-height: 300px; overflow-y: auto; margin: 16px 0;';\n\n const selectedValues = new Set(options.selectedValues ?? []);\n\n options.options.forEach((option) => {\n const label = document.createElement('label');\n label.style.cssText =\n 'display: flex; align-items: center; padding: 12px 0; cursor: pointer; border-bottom: 1px solid #e0e0e0;';\n\n const checkbox = document.createElement('input');\n checkbox.type = 'checkbox';\n checkbox.value = option.value;\n checkbox.checked = selectedValues.has(option.value);\n checkbox.style.cssText = 'margin-right: 12px; width: 20px; height: 20px;';\n checkbox.addEventListener('change', () => {\n if (checkbox.checked) {\n selectedValues.add(option.value);\n } else {\n selectedValues.delete(option.value);\n }\n });\n\n const text = document.createElement('span');\n text.textContent = option.label;\n text.style.cssText = 'font-size: 16px;';\n\n label.appendChild(checkbox);\n label.appendChild(text);\n optionsContainer.appendChild(label);\n });\n\n dialog.appendChild(optionsContainer);\n\n const buttonContainer = this.createButtonContainer();\n\n const cancelButton = this.createButton(\n options.cancelButtonTitle ?? 'Cancel',\n false,\n () => {\n this.removeOverlay(overlay);\n resolve({ values: [], cancelled: true });\n },\n options,\n );\n\n const okButton = this.createButton(\n options.okButtonTitle ?? 'OK',\n true,\n () => {\n this.removeOverlay(overlay);\n resolve({ values: Array.from(selectedValues), cancelled: false });\n },\n options,\n );\n\n buttonContainer.appendChild(cancelButton);\n buttonContainer.appendChild(okButton);\n dialog.appendChild(buttonContainer);\n overlay.appendChild(dialog);\n document.body.appendChild(overlay);\n });\n }\n\n private createOverlay(): HTMLDivElement {\n const overlay = document.createElement('div');\n overlay.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 999999;\n `;\n return overlay;\n }\n\n private createDialogContainer(title?: string, message?: string, styleOptions?: DialogStyleOptions): HTMLDivElement {\n const dialog = document.createElement('div');\n const bgColor = styleOptions?.backgroundColor ?? 'white';\n dialog.style.cssText = `\n background: ${bgColor};\n border-radius: 16px;\n padding: 24px;\n min-width: 300px;\n max-width: 400px;\n max-height: 80vh;\n overflow-y: auto;\n box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);\n `;\n\n if (title) {\n const titleEl = document.createElement('h2');\n titleEl.textContent = title;\n const titleFontSize = styleOptions?.titleFontSize ?? 20;\n const titleColor = styleOptions?.titleColor ?? 'inherit';\n titleEl.style.cssText = `margin: 0 0 8px 0; font-size: ${titleFontSize}px; font-weight: 600; color: ${titleColor};`;\n dialog.appendChild(titleEl);\n }\n\n if (message) {\n const messageEl = document.createElement('p');\n messageEl.textContent = message;\n const messageFontSize = styleOptions?.messageFontSize ?? 14;\n const messageColor = styleOptions?.messageColor ?? '#666';\n messageEl.style.cssText = `margin: 0; font-size: ${messageFontSize}px; color: ${messageColor};`;\n dialog.appendChild(messageEl);\n }\n\n return dialog;\n }\n\n private createButtonContainer(): HTMLDivElement {\n const container = document.createElement('div');\n container.style.cssText = 'display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px;';\n return container;\n }\n\n private createButton(\n text: string,\n primary: boolean,\n onClick: () => void,\n styleOptions?: DialogStyleOptions,\n ): HTMLButtonElement {\n const button = document.createElement('button');\n button.textContent = text;\n const fontSize = styleOptions?.buttonFontSize ?? 14;\n const primaryColor = styleOptions?.buttonColor ?? '#6750A4';\n const cancelColor = styleOptions?.cancelButtonColor ?? '#6750A4';\n button.style.cssText = `\n padding: 10px 24px;\n border-radius: 8px;\n font-size: ${fontSize}px;\n font-weight: 500;\n cursor: pointer;\n border: none;\n ${primary ? `background: ${primaryColor}; color: white;` : `background: transparent; color: ${cancelColor};`}\n `;\n button.addEventListener('click', onClick);\n return button;\n }\n\n private removeOverlay(overlay: HTMLDivElement): void {\n overlay.remove();\n }\n\n async sheet(options: SheetOptions): Promise<SheetResult> {\n return new Promise((resolve) => {\n const overlay = this.createOverlay();\n const dialog = this.createSheetDialogContainer(options);\n\n // Header section with logo and title\n const headerSection = document.createElement('div');\n headerSection.style.cssText = 'display: flex; flex-direction: column; align-items: center; margin-bottom: 24px;';\n\n if (options.headerLogo) {\n const headerLogo = document.createElement('img');\n headerLogo.src = options.headerLogo;\n headerLogo.style.cssText = 'width: 48px; height: 48px; object-fit: contain; margin-bottom: 12px; border-radius: 8px;';\n headerLogo.onerror = () => {\n headerLogo.style.display = 'none';\n };\n headerSection.appendChild(headerLogo);\n }\n\n const titleEl = document.createElement('h2');\n titleEl.textContent = options.title;\n const titleFontSize = options.titleFontSize ?? 20;\n const titleColor = options.titleColor ?? 'inherit';\n titleEl.style.cssText = `margin: 0; font-size: ${titleFontSize}px; font-weight: 600; color: ${titleColor}; text-align: center;`;\n headerSection.appendChild(titleEl);\n\n dialog.appendChild(headerSection);\n\n // Rows container\n const rowsContainer = document.createElement('div');\n rowsContainer.style.cssText = 'display: flex; flex-direction: column; gap: 0; margin-bottom: 24px;';\n\n options.rows.forEach((row, index) => {\n const rowEl = document.createElement('div');\n rowEl.style.cssText = `\n display: flex;\n align-items: center;\n padding: 16px 0;\n ${index < options.rows.length - 1 ? 'border-bottom: 1px solid #e0e0e0;' : ''}\n `;\n\n if (row.logo) {\n const rowLogo = document.createElement('img');\n rowLogo.src = row.logo;\n rowLogo.style.cssText = 'width: 24px; height: 24px; object-fit: contain; margin-right: 12px; border-radius: 4px; flex-shrink: 0;';\n rowLogo.onerror = () => {\n rowLogo.style.display = 'none';\n };\n rowEl.appendChild(rowLogo);\n }\n\n const rowTitle = document.createElement('span');\n rowTitle.textContent = row.title;\n const messageFontSize = options.messageFontSize ?? 16;\n const messageColor = options.messageColor ?? '#333';\n rowTitle.style.cssText = `font-size: ${messageFontSize}px; color: ${messageColor}; flex: 1;`;\n rowEl.appendChild(rowTitle);\n\n if (row.value) {\n const rowValue = document.createElement('span');\n rowValue.textContent = row.value;\n rowValue.style.cssText = `font-size: ${messageFontSize}px; color: #666; text-align: right; margin-left: 12px;`;\n rowEl.appendChild(rowValue);\n }\n\n rowsContainer.appendChild(rowEl);\n });\n\n dialog.appendChild(rowsContainer);\n\n // Button container\n const buttonContainer = this.createButtonContainer();\n\n const cancelButton = this.createButton(\n options.cancelButtonTitle ?? 'Cancel',\n false,\n () => {\n this.removeOverlay(overlay);\n resolve({ confirmed: false });\n },\n options,\n );\n\n const confirmButton = this.createButton(\n options.confirmButtonTitle ?? 'Confirm',\n true,\n () => {\n this.removeOverlay(overlay);\n resolve({ confirmed: true });\n },\n options,\n );\n\n buttonContainer.appendChild(cancelButton);\n buttonContainer.appendChild(confirmButton);\n dialog.appendChild(buttonContainer);\n overlay.appendChild(dialog);\n document.body.appendChild(overlay);\n });\n }\n\n private createSheetDialogContainer(options: SheetOptions): HTMLDivElement {\n const dialog = document.createElement('div');\n const bgColor = options.backgroundColor ?? 'white';\n dialog.style.cssText = `\n background: ${bgColor};\n border-radius: 16px;\n padding: 24px;\n min-width: 320px;\n max-width: 420px;\n max-height: 80vh;\n overflow-y: auto;\n box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);\n `;\n return dialog;\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -196,6 +196,99 @@ class ExtendedDialogWeb extends core.WebPlugin {
|
|
|
196
196
|
removeOverlay(overlay) {
|
|
197
197
|
overlay.remove();
|
|
198
198
|
}
|
|
199
|
+
async sheet(options) {
|
|
200
|
+
return new Promise((resolve) => {
|
|
201
|
+
var _a, _b, _c, _d;
|
|
202
|
+
const overlay = this.createOverlay();
|
|
203
|
+
const dialog = this.createSheetDialogContainer(options);
|
|
204
|
+
// Header section with logo and title
|
|
205
|
+
const headerSection = document.createElement('div');
|
|
206
|
+
headerSection.style.cssText = 'display: flex; flex-direction: column; align-items: center; margin-bottom: 24px;';
|
|
207
|
+
if (options.headerLogo) {
|
|
208
|
+
const headerLogo = document.createElement('img');
|
|
209
|
+
headerLogo.src = options.headerLogo;
|
|
210
|
+
headerLogo.style.cssText = 'width: 48px; height: 48px; object-fit: contain; margin-bottom: 12px; border-radius: 8px;';
|
|
211
|
+
headerLogo.onerror = () => {
|
|
212
|
+
headerLogo.style.display = 'none';
|
|
213
|
+
};
|
|
214
|
+
headerSection.appendChild(headerLogo);
|
|
215
|
+
}
|
|
216
|
+
const titleEl = document.createElement('h2');
|
|
217
|
+
titleEl.textContent = options.title;
|
|
218
|
+
const titleFontSize = (_a = options.titleFontSize) !== null && _a !== void 0 ? _a : 20;
|
|
219
|
+
const titleColor = (_b = options.titleColor) !== null && _b !== void 0 ? _b : 'inherit';
|
|
220
|
+
titleEl.style.cssText = `margin: 0; font-size: ${titleFontSize}px; font-weight: 600; color: ${titleColor}; text-align: center;`;
|
|
221
|
+
headerSection.appendChild(titleEl);
|
|
222
|
+
dialog.appendChild(headerSection);
|
|
223
|
+
// Rows container
|
|
224
|
+
const rowsContainer = document.createElement('div');
|
|
225
|
+
rowsContainer.style.cssText = 'display: flex; flex-direction: column; gap: 0; margin-bottom: 24px;';
|
|
226
|
+
options.rows.forEach((row, index) => {
|
|
227
|
+
var _a, _b;
|
|
228
|
+
const rowEl = document.createElement('div');
|
|
229
|
+
rowEl.style.cssText = `
|
|
230
|
+
display: flex;
|
|
231
|
+
align-items: center;
|
|
232
|
+
padding: 16px 0;
|
|
233
|
+
${index < options.rows.length - 1 ? 'border-bottom: 1px solid #e0e0e0;' : ''}
|
|
234
|
+
`;
|
|
235
|
+
if (row.logo) {
|
|
236
|
+
const rowLogo = document.createElement('img');
|
|
237
|
+
rowLogo.src = row.logo;
|
|
238
|
+
rowLogo.style.cssText = 'width: 24px; height: 24px; object-fit: contain; margin-right: 12px; border-radius: 4px; flex-shrink: 0;';
|
|
239
|
+
rowLogo.onerror = () => {
|
|
240
|
+
rowLogo.style.display = 'none';
|
|
241
|
+
};
|
|
242
|
+
rowEl.appendChild(rowLogo);
|
|
243
|
+
}
|
|
244
|
+
const rowTitle = document.createElement('span');
|
|
245
|
+
rowTitle.textContent = row.title;
|
|
246
|
+
const messageFontSize = (_a = options.messageFontSize) !== null && _a !== void 0 ? _a : 16;
|
|
247
|
+
const messageColor = (_b = options.messageColor) !== null && _b !== void 0 ? _b : '#333';
|
|
248
|
+
rowTitle.style.cssText = `font-size: ${messageFontSize}px; color: ${messageColor}; flex: 1;`;
|
|
249
|
+
rowEl.appendChild(rowTitle);
|
|
250
|
+
if (row.value) {
|
|
251
|
+
const rowValue = document.createElement('span');
|
|
252
|
+
rowValue.textContent = row.value;
|
|
253
|
+
rowValue.style.cssText = `font-size: ${messageFontSize}px; color: #666; text-align: right; margin-left: 12px;`;
|
|
254
|
+
rowEl.appendChild(rowValue);
|
|
255
|
+
}
|
|
256
|
+
rowsContainer.appendChild(rowEl);
|
|
257
|
+
});
|
|
258
|
+
dialog.appendChild(rowsContainer);
|
|
259
|
+
// Button container
|
|
260
|
+
const buttonContainer = this.createButtonContainer();
|
|
261
|
+
const cancelButton = this.createButton((_c = options.cancelButtonTitle) !== null && _c !== void 0 ? _c : 'Cancel', false, () => {
|
|
262
|
+
this.removeOverlay(overlay);
|
|
263
|
+
resolve({ confirmed: false });
|
|
264
|
+
}, options);
|
|
265
|
+
const confirmButton = this.createButton((_d = options.confirmButtonTitle) !== null && _d !== void 0 ? _d : 'Confirm', true, () => {
|
|
266
|
+
this.removeOverlay(overlay);
|
|
267
|
+
resolve({ confirmed: true });
|
|
268
|
+
}, options);
|
|
269
|
+
buttonContainer.appendChild(cancelButton);
|
|
270
|
+
buttonContainer.appendChild(confirmButton);
|
|
271
|
+
dialog.appendChild(buttonContainer);
|
|
272
|
+
overlay.appendChild(dialog);
|
|
273
|
+
document.body.appendChild(overlay);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
createSheetDialogContainer(options) {
|
|
277
|
+
var _a;
|
|
278
|
+
const dialog = document.createElement('div');
|
|
279
|
+
const bgColor = (_a = options.backgroundColor) !== null && _a !== void 0 ? _a : 'white';
|
|
280
|
+
dialog.style.cssText = `
|
|
281
|
+
background: ${bgColor};
|
|
282
|
+
border-radius: 16px;
|
|
283
|
+
padding: 24px;
|
|
284
|
+
min-width: 320px;
|
|
285
|
+
max-width: 420px;
|
|
286
|
+
max-height: 80vh;
|
|
287
|
+
overflow-y: auto;
|
|
288
|
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
|
|
289
|
+
`;
|
|
290
|
+
return dialog;
|
|
291
|
+
}
|
|
199
292
|
}
|
|
200
293
|
|
|
201
294
|
var web = /*#__PURE__*/Object.freeze({
|