diff --git a/.changes/dialog-remove-ok-label.md b/.changes/dialog-remove-ok-label.md new file mode 100644 index 000000000..edf4cb4a5 --- /dev/null +++ b/.changes/dialog-remove-ok-label.md @@ -0,0 +1,6 @@ +--- +"dialog-js": major +"dialog": major +--- + +**Breaking:** Removed the deprecated `okLabel` option of `MessageDialogOptions`. Use `buttons: { ok: 'label' }` instead. `ConfirmDialogOptions` (used by `ask` and `confirm`) still accepts `okLabel` and `cancelLabel`. diff --git a/plugins/dialog/api-iife.js b/plugins/dialog/api-iife.js index d82e4234f..add39cce2 100644 --- a/plugins/dialog/api-iife.js +++ b/plugins/dialog/api-iife.js @@ -1 +1 @@ -if("__TAURI__"in window){var __TAURI_PLUGIN_DIALOG__=function(n){"use strict";async function e(n,e={},t){return window.__TAURI_INTERNALS__.invoke(n,e,t)}function t(n){if(void 0!==n)return"string"==typeof n?n:"ok"in n&&"cancel"in n?{OkCancelCustom:[n.ok,n.cancel]}:"yes"in n&&"no"in n&&"cancel"in n?{YesNoCancelCustom:[n.yes,n.no,n.cancel]}:"ok"in n?{OkCustom:n.ok}:void 0}async function o(n,o){return await e("plugin:dialog|message",{message:n,title:o?.title,kind:o?.kind,buttons:t(o?.buttons)})}return"function"==typeof SuppressedError&&SuppressedError,n.ask=async function(n,e){const t="string"==typeof e?{title:e}:e,i=t?.okLabel||t?.cancelLabel,a=t?.okLabel??"Yes";return await o(n,{title:t?.title,kind:t?.kind,buttons:i?{ok:a,cancel:t.cancelLabel??"No"}:"YesNo"})===a},n.confirm=async function(n,e){const t="string"==typeof e?{title:e}:e,i=t?.okLabel||t?.cancelLabel,a=t?.okLabel??"Ok";return await o(n,{title:t?.title,kind:t?.kind,buttons:i?{ok:a,cancel:t.cancelLabel??"Cancel"}:"OkCancel"})===a},n.message=async function(n,e){const t="string"==typeof e?{title:e}:e;return t&&!t.buttons&&t.okLabel&&(t.buttons={ok:t.okLabel}),o(n,t)},n.open=async function(n={}){return"object"==typeof n&&Object.freeze(n),await e("plugin:dialog|open",{options:n})},n.save=async function(n={}){return"object"==typeof n&&Object.freeze(n),await e("plugin:dialog|save",{options:n})},n}({});Object.defineProperty(window.__TAURI__,"dialog",{value:__TAURI_PLUGIN_DIALOG__})} +if("__TAURI__"in window){var __TAURI_PLUGIN_DIALOG__=function(n){"use strict";async function e(n,e={},t){return window.__TAURI_INTERNALS__.invoke(n,e,t)}function t(n){if(void 0!==n)return"string"==typeof n?n:"ok"in n&&"cancel"in n?{OkCancelCustom:[n.ok,n.cancel]}:"yes"in n&&"no"in n&&"cancel"in n?{YesNoCancelCustom:[n.yes,n.no,n.cancel]}:"ok"in n?{OkCustom:n.ok}:void 0}async function o(n,o){return await e("plugin:dialog|message",{message:n,title:o?.title,kind:o?.kind,buttons:t(o?.buttons)})}return"function"==typeof SuppressedError&&SuppressedError,n.ask=async function(n,e){const t="string"==typeof e?{title:e}:e,i=t?.okLabel||t?.cancelLabel,a=t?.okLabel??"Yes";return await o(n,{title:t?.title,kind:t?.kind,buttons:i?{ok:a,cancel:t.cancelLabel??"No"}:"YesNo"})===a},n.confirm=async function(n,e){const t="string"==typeof e?{title:e}:e,i=t?.okLabel||t?.cancelLabel,a=t?.okLabel??"Ok";return await o(n,{title:t?.title,kind:t?.kind,buttons:i?{ok:a,cancel:t.cancelLabel??"Cancel"}:"OkCancel"})===a},n.message=async function(n,e){return o(n,"string"==typeof e?{title:e}:e)},n.open=async function(n={}){return"object"==typeof n&&Object.freeze(n),await e("plugin:dialog|open",{options:n})},n.save=async function(n={}){return"object"==typeof n&&Object.freeze(n),await e("plugin:dialog|save",{options:n})},n}({});Object.defineProperty(window.__TAURI__,"dialog",{value:__TAURI_PLUGIN_DIALOG__})} diff --git a/plugins/dialog/guest-js/index.ts b/plugins/dialog/guest-js/index.ts index 90d6b26ae..52e57d63f 100644 --- a/plugins/dialog/guest-js/index.ts +++ b/plugins/dialog/guest-js/index.ts @@ -228,12 +228,6 @@ interface MessageDialogOptions { title?: string /** The kind of the dialog. Defaults to `info`. */ kind?: 'info' | 'warning' | 'error' - /** - * The label of the Ok button. - * - * @deprecated Use {@linkcode MessageDialogOptions.buttons} instead. - */ - okLabel?: string /** * The buttons of the dialog. * @@ -405,10 +399,7 @@ async function save(options: SaveDialogOptions = {}): Promise { */ export type MessageDialogResult = 'Yes' | 'No' | 'Ok' | 'Cancel' | (string & {}) -async function messageCommand( - message: string, - options?: Omit -) { +async function messageCommand(message: string, options?: MessageDialogOptions) { return await invoke('plugin:dialog|message', { message, title: options?.title, @@ -439,9 +430,6 @@ async function message( options?: string | MessageDialogOptions ): Promise { const opts = typeof options === 'string' ? { title: options } : options - if (opts && !opts.buttons && opts.okLabel) { - opts.buttons = { ok: opts.okLabel } - } return messageCommand(message, opts) }