@tauri-apps/plugin-dialog 2.0.0-rc.0 → 2.0.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 -2
- package/dist-js/index.cjs +15 -15
- package/dist-js/index.d.ts +17 -18
- package/dist-js/index.js +15 -15
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,9 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Native system dialogs for opening and saving files along with message dialogs.
|
|
4
4
|
|
|
5
|
+
| Platform | Supported |
|
|
6
|
+
| -------- | --------- |
|
|
7
|
+
| Linux | ✓ |
|
|
8
|
+
| Windows | ✓ |
|
|
9
|
+
| macOS | ✓ |
|
|
10
|
+
| Android | ✓ |
|
|
11
|
+
| iOS | ✓ |
|
|
12
|
+
|
|
5
13
|
## Install
|
|
6
14
|
|
|
7
|
-
_This plugin requires a Rust version of at least **1.
|
|
15
|
+
_This plugin requires a Rust version of at least **1.78**_
|
|
8
16
|
|
|
9
17
|
There are three general methods of installation that we can recommend.
|
|
10
18
|
|
|
@@ -18,7 +26,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file:
|
|
|
18
26
|
|
|
19
27
|
```toml
|
|
20
28
|
[dependencies]
|
|
21
|
-
tauri-plugin-dialog = "2.0.0
|
|
29
|
+
tauri-plugin-dialog = "2.0.0"
|
|
22
30
|
# alternatively with Git:
|
|
23
31
|
tauri-plugin-dialog = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
|
24
32
|
```
|
package/dist-js/index.cjs
CHANGED
|
@@ -58,10 +58,10 @@ var core = require('@tauri-apps/api/core');
|
|
|
58
58
|
* @since 2.0.0
|
|
59
59
|
*/
|
|
60
60
|
async function open(options = {}) {
|
|
61
|
-
if (typeof options ===
|
|
61
|
+
if (typeof options === 'object') {
|
|
62
62
|
Object.freeze(options);
|
|
63
63
|
}
|
|
64
|
-
return await core.invoke(
|
|
64
|
+
return await core.invoke('plugin:dialog|open', { options });
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Open a file/directory save dialog.
|
|
@@ -88,10 +88,10 @@ async function open(options = {}) {
|
|
|
88
88
|
* @since 2.0.0
|
|
89
89
|
*/
|
|
90
90
|
async function save(options = {}) {
|
|
91
|
-
if (typeof options ===
|
|
91
|
+
if (typeof options === 'object') {
|
|
92
92
|
Object.freeze(options);
|
|
93
93
|
}
|
|
94
|
-
return await core.invoke(
|
|
94
|
+
return await core.invoke('plugin:dialog|save', { options });
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
* Shows a message dialog with an `Ok` button.
|
|
@@ -111,12 +111,12 @@ async function save(options = {}) {
|
|
|
111
111
|
*
|
|
112
112
|
*/
|
|
113
113
|
async function message(message, options) {
|
|
114
|
-
const opts = typeof options ===
|
|
115
|
-
await core.invoke(
|
|
114
|
+
const opts = typeof options === 'string' ? { title: options } : options;
|
|
115
|
+
await core.invoke('plugin:dialog|message', {
|
|
116
116
|
message: message.toString(),
|
|
117
117
|
title: opts?.title?.toString(),
|
|
118
118
|
kind: opts?.kind,
|
|
119
|
-
okButtonLabel: opts?.okLabel?.toString()
|
|
119
|
+
okButtonLabel: opts?.okLabel?.toString()
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
@@ -136,13 +136,13 @@ async function message(message, options) {
|
|
|
136
136
|
* @since 2.0.0
|
|
137
137
|
*/
|
|
138
138
|
async function ask(message, options) {
|
|
139
|
-
const opts = typeof options ===
|
|
140
|
-
return await core.invoke(
|
|
139
|
+
const opts = typeof options === 'string' ? { title: options } : options;
|
|
140
|
+
return await core.invoke('plugin:dialog|ask', {
|
|
141
141
|
message: message.toString(),
|
|
142
142
|
title: opts?.title?.toString(),
|
|
143
143
|
kind: opts?.kind,
|
|
144
|
-
okButtonLabel: opts?.okLabel?.toString() ??
|
|
145
|
-
cancelButtonLabel: opts?.cancelLabel?.toString() ??
|
|
144
|
+
okButtonLabel: opts?.okLabel?.toString() ?? 'Yes',
|
|
145
|
+
cancelButtonLabel: opts?.cancelLabel?.toString() ?? 'No'
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
@@ -162,13 +162,13 @@ async function ask(message, options) {
|
|
|
162
162
|
* @since 2.0.0
|
|
163
163
|
*/
|
|
164
164
|
async function confirm(message, options) {
|
|
165
|
-
const opts = typeof options ===
|
|
166
|
-
return await core.invoke(
|
|
165
|
+
const opts = typeof options === 'string' ? { title: options } : options;
|
|
166
|
+
return await core.invoke('plugin:dialog|confirm', {
|
|
167
167
|
message: message.toString(),
|
|
168
168
|
title: opts?.title?.toString(),
|
|
169
169
|
kind: opts?.kind,
|
|
170
|
-
okButtonLabel: opts?.okLabel?.toString() ??
|
|
171
|
-
cancelButtonLabel: opts?.cancelLabel?.toString() ??
|
|
170
|
+
okButtonLabel: opts?.okLabel?.toString() ?? 'Ok',
|
|
171
|
+
cancelButtonLabel: opts?.cancelLabel?.toString() ?? 'Cancel'
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
|
package/dist-js/index.d.ts
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
interface FileResponse {
|
|
2
|
-
base64Data?: string;
|
|
3
|
-
duration?: number;
|
|
4
|
-
height?: number;
|
|
5
|
-
width?: number;
|
|
6
|
-
mimeType?: string;
|
|
7
|
-
modifiedAt?: number;
|
|
8
|
-
name?: string;
|
|
9
|
-
path: string;
|
|
10
|
-
size: number;
|
|
11
|
-
}
|
|
12
1
|
/**
|
|
13
2
|
* Extension filters for the file dialog.
|
|
14
3
|
*
|
|
@@ -32,11 +21,18 @@ interface DialogFilter {
|
|
|
32
21
|
* @since 2.0.0
|
|
33
22
|
*/
|
|
34
23
|
interface OpenDialogOptions {
|
|
35
|
-
/** The title of the dialog window. */
|
|
24
|
+
/** The title of the dialog window (desktop only). */
|
|
36
25
|
title?: string;
|
|
37
26
|
/** The filters of the dialog. */
|
|
38
27
|
filters?: DialogFilter[];
|
|
39
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Initial directory or file path.
|
|
30
|
+
* If it's a directory path, the dialog interface will change to that folder.
|
|
31
|
+
* If it's not an existing directory, the file name will be set to the dialog's file name input and the dialog will be set to the parent folder.
|
|
32
|
+
*
|
|
33
|
+
* On mobile the file name is always used on the dialog's file name input.
|
|
34
|
+
* If not provided, Android uses `(invalid).txt` as default file name.
|
|
35
|
+
*/
|
|
40
36
|
defaultPath?: string;
|
|
41
37
|
/** Whether the dialog allows multiple selection or not. */
|
|
42
38
|
multiple?: boolean;
|
|
@@ -56,7 +52,7 @@ interface OpenDialogOptions {
|
|
|
56
52
|
* @since 2.0.0
|
|
57
53
|
*/
|
|
58
54
|
interface SaveDialogOptions {
|
|
59
|
-
/** The title of the dialog window. */
|
|
55
|
+
/** The title of the dialog window (desktop only). */
|
|
60
56
|
title?: string;
|
|
61
57
|
/** The filters of the dialog. */
|
|
62
58
|
filters?: DialogFilter[];
|
|
@@ -64,6 +60,9 @@ interface SaveDialogOptions {
|
|
|
64
60
|
* Initial directory or file path.
|
|
65
61
|
* If it's a directory path, the dialog interface will change to that folder.
|
|
66
62
|
* If it's not an existing directory, the file name will be set to the dialog's file name input and the dialog will be set to the parent folder.
|
|
63
|
+
*
|
|
64
|
+
* On mobile the file name is always used on the dialog's file name input.
|
|
65
|
+
* If not provided, Android uses `(invalid).txt` as default file name.
|
|
67
66
|
*/
|
|
68
67
|
defaultPath?: string;
|
|
69
68
|
/** Whether to allow creating directories in the dialog. Enabled by default. **macOS Only** */
|
|
@@ -76,7 +75,7 @@ interface MessageDialogOptions {
|
|
|
76
75
|
/** The title of the dialog. Defaults to the app name. */
|
|
77
76
|
title?: string;
|
|
78
77
|
/** The kind of the dialog. Defaults to `info`. */
|
|
79
|
-
kind?:
|
|
78
|
+
kind?: 'info' | 'warning' | 'error';
|
|
80
79
|
/** The label of the confirm button. */
|
|
81
80
|
okLabel?: string;
|
|
82
81
|
}
|
|
@@ -84,13 +83,13 @@ interface ConfirmDialogOptions {
|
|
|
84
83
|
/** The title of the dialog. Defaults to the app name. */
|
|
85
84
|
title?: string;
|
|
86
85
|
/** The kind of the dialog. Defaults to `info`. */
|
|
87
|
-
kind?:
|
|
86
|
+
kind?: 'info' | 'warning' | 'error';
|
|
88
87
|
/** The label of the confirm button. */
|
|
89
88
|
okLabel?: string;
|
|
90
89
|
/** The label of the cancel button. */
|
|
91
90
|
cancelLabel?: string;
|
|
92
91
|
}
|
|
93
|
-
type OpenDialogReturn<T extends OpenDialogOptions> = T[
|
|
92
|
+
type OpenDialogReturn<T extends OpenDialogOptions> = T['directory'] extends true ? T['multiple'] extends true ? string[] | null : string | null : T['multiple'] extends true ? string[] | null : string | null;
|
|
94
93
|
/**
|
|
95
94
|
* Open a file/directory selection dialog.
|
|
96
95
|
*
|
|
@@ -221,5 +220,5 @@ declare function ask(message: string, options?: string | ConfirmDialogOptions):
|
|
|
221
220
|
* @since 2.0.0
|
|
222
221
|
*/
|
|
223
222
|
declare function confirm(message: string, options?: string | ConfirmDialogOptions): Promise<boolean>;
|
|
224
|
-
export type { DialogFilter,
|
|
223
|
+
export type { DialogFilter, OpenDialogOptions, OpenDialogReturn, SaveDialogOptions, MessageDialogOptions, ConfirmDialogOptions };
|
|
225
224
|
export { open, save, message, ask, confirm };
|
package/dist-js/index.js
CHANGED
|
@@ -56,10 +56,10 @@ import { invoke } from '@tauri-apps/api/core';
|
|
|
56
56
|
* @since 2.0.0
|
|
57
57
|
*/
|
|
58
58
|
async function open(options = {}) {
|
|
59
|
-
if (typeof options ===
|
|
59
|
+
if (typeof options === 'object') {
|
|
60
60
|
Object.freeze(options);
|
|
61
61
|
}
|
|
62
|
-
return await invoke(
|
|
62
|
+
return await invoke('plugin:dialog|open', { options });
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* Open a file/directory save dialog.
|
|
@@ -86,10 +86,10 @@ async function open(options = {}) {
|
|
|
86
86
|
* @since 2.0.0
|
|
87
87
|
*/
|
|
88
88
|
async function save(options = {}) {
|
|
89
|
-
if (typeof options ===
|
|
89
|
+
if (typeof options === 'object') {
|
|
90
90
|
Object.freeze(options);
|
|
91
91
|
}
|
|
92
|
-
return await invoke(
|
|
92
|
+
return await invoke('plugin:dialog|save', { options });
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Shows a message dialog with an `Ok` button.
|
|
@@ -109,12 +109,12 @@ async function save(options = {}) {
|
|
|
109
109
|
*
|
|
110
110
|
*/
|
|
111
111
|
async function message(message, options) {
|
|
112
|
-
const opts = typeof options ===
|
|
113
|
-
await invoke(
|
|
112
|
+
const opts = typeof options === 'string' ? { title: options } : options;
|
|
113
|
+
await invoke('plugin:dialog|message', {
|
|
114
114
|
message: message.toString(),
|
|
115
115
|
title: opts?.title?.toString(),
|
|
116
116
|
kind: opts?.kind,
|
|
117
|
-
okButtonLabel: opts?.okLabel?.toString()
|
|
117
|
+
okButtonLabel: opts?.okLabel?.toString()
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
@@ -134,13 +134,13 @@ async function message(message, options) {
|
|
|
134
134
|
* @since 2.0.0
|
|
135
135
|
*/
|
|
136
136
|
async function ask(message, options) {
|
|
137
|
-
const opts = typeof options ===
|
|
138
|
-
return await invoke(
|
|
137
|
+
const opts = typeof options === 'string' ? { title: options } : options;
|
|
138
|
+
return await invoke('plugin:dialog|ask', {
|
|
139
139
|
message: message.toString(),
|
|
140
140
|
title: opts?.title?.toString(),
|
|
141
141
|
kind: opts?.kind,
|
|
142
|
-
okButtonLabel: opts?.okLabel?.toString() ??
|
|
143
|
-
cancelButtonLabel: opts?.cancelLabel?.toString() ??
|
|
142
|
+
okButtonLabel: opts?.okLabel?.toString() ?? 'Yes',
|
|
143
|
+
cancelButtonLabel: opts?.cancelLabel?.toString() ?? 'No'
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
@@ -160,13 +160,13 @@ async function ask(message, options) {
|
|
|
160
160
|
* @since 2.0.0
|
|
161
161
|
*/
|
|
162
162
|
async function confirm(message, options) {
|
|
163
|
-
const opts = typeof options ===
|
|
164
|
-
return await invoke(
|
|
163
|
+
const opts = typeof options === 'string' ? { title: options } : options;
|
|
164
|
+
return await invoke('plugin:dialog|confirm', {
|
|
165
165
|
message: message.toString(),
|
|
166
166
|
title: opts?.title?.toString(),
|
|
167
167
|
kind: opts?.kind,
|
|
168
|
-
okButtonLabel: opts?.okLabel?.toString() ??
|
|
169
|
-
cancelButtonLabel: opts?.cancelLabel?.toString() ??
|
|
168
|
+
okButtonLabel: opts?.okLabel?.toString() ?? 'Ok',
|
|
169
|
+
cancelButtonLabel: opts?.cancelLabel?.toString() ?? 'Cancel'
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tauri-apps/plugin-dialog",
|
|
3
|
-
"version": "2.0.0
|
|
4
|
-
"license": "MIT
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"license": "MIT OR Apache-2.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Tauri Programme within The Commons Conservancy"
|
|
7
7
|
],
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
"LICENSE"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@tauri-apps/api": "^2.0.0
|
|
27
|
+
"@tauri-apps/api": "^2.0.0"
|
|
28
28
|
}
|
|
29
29
|
}
|