(text, { ok, cancel, input = false } = {})
| 77 | * `input` is string: <?string> i.e. string on Ok, null otherwise; |
| 78 | */ |
| 79 | export function showConfirmation(text, { ok, cancel, input = false } = {}) { |
| 80 | return new Promise(resolve => { |
| 81 | const hasInput = input !== false; |
| 82 | const onCancel = () => resolve(hasInput ? null : false); |
| 83 | const onOk = val => resolve(!hasInput || val); |
| 84 | showMessage({ |
| 85 | input, |
| 86 | text, |
| 87 | buttons: [ |
| 88 | ok !== false && { text: i18n('buttonOK'), onClick: onOk, ...ok }, |
| 89 | cancel !== false && { text: i18n('buttonCancel'), onClick: onCancel, ...cancel }, |
| 90 | ].filter(Boolean), |
| 91 | onBackdropClick: onCancel, |
| 92 | onDismiss: onCancel, // Esc key |
| 93 | }); |
| 94 | }); |
| 95 | } |
| 96 | |
| 97 | /** @returns {?number} Number of lines + 1 if the last line is not empty */ |
| 98 | export function calcRows(val) { |
no test coverage detected