@tauri-apps/plugin-dialog 2.0.0-alpha.4 → 2.0.0-beta.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 +1 -1
- package/dist-js/index.cjs +6 -6
- package/dist-js/index.d.ts +55 -17
- package/dist-js/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Install the Core plugin by adding the following to your `Cargo.toml` file:
|
|
|
18
18
|
|
|
19
19
|
```toml
|
|
20
20
|
[dependencies]
|
|
21
|
-
tauri-plugin-dialog = "2.0.0-
|
|
21
|
+
tauri-plugin-dialog = "2.0.0-beta"
|
|
22
22
|
# alternatively with Git:
|
|
23
23
|
tauri-plugin-dialog = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" }
|
|
24
24
|
```
|
package/dist-js/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var core = require('@tauri-apps/api/core');
|
|
4
4
|
|
|
5
5
|
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
6
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -61,7 +61,7 @@ async function open(options = {}) {
|
|
|
61
61
|
if (typeof options === "object") {
|
|
62
62
|
Object.freeze(options);
|
|
63
63
|
}
|
|
64
|
-
return
|
|
64
|
+
return core.invoke("plugin:dialog|open", { options });
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Open a file/directory save dialog.
|
|
@@ -91,7 +91,7 @@ async function save(options = {}) {
|
|
|
91
91
|
if (typeof options === "object") {
|
|
92
92
|
Object.freeze(options);
|
|
93
93
|
}
|
|
94
|
-
return
|
|
94
|
+
return core.invoke("plugin:dialog|save", { options });
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
* Shows a message dialog with an `Ok` button.
|
|
@@ -112,7 +112,7 @@ async function save(options = {}) {
|
|
|
112
112
|
*/
|
|
113
113
|
async function message(message, options) {
|
|
114
114
|
const opts = typeof options === "string" ? { title: options } : options;
|
|
115
|
-
return
|
|
115
|
+
return core.invoke("plugin:dialog|message", {
|
|
116
116
|
message: message.toString(),
|
|
117
117
|
title: opts?.title?.toString(),
|
|
118
118
|
type_: opts?.type,
|
|
@@ -137,7 +137,7 @@ async function message(message, options) {
|
|
|
137
137
|
*/
|
|
138
138
|
async function ask(message, options) {
|
|
139
139
|
const opts = typeof options === "string" ? { title: options } : options;
|
|
140
|
-
return
|
|
140
|
+
return core.invoke("plugin:dialog|ask", {
|
|
141
141
|
message: message.toString(),
|
|
142
142
|
title: opts?.title?.toString(),
|
|
143
143
|
type_: opts?.type,
|
|
@@ -163,7 +163,7 @@ async function ask(message, options) {
|
|
|
163
163
|
*/
|
|
164
164
|
async function confirm(message, options) {
|
|
165
165
|
const opts = typeof options === "string" ? { title: options } : options;
|
|
166
|
-
return
|
|
166
|
+
return core.invoke("plugin:dialog|confirm", {
|
|
167
167
|
message: message.toString(),
|
|
168
168
|
title: opts?.title?.toString(),
|
|
169
169
|
type_: opts?.type,
|
package/dist-js/index.d.ts
CHANGED
|
@@ -86,22 +86,60 @@ interface ConfirmDialogOptions {
|
|
|
86
86
|
/** The label of the cancel button. */
|
|
87
87
|
cancelLabel?: string;
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
89
|
+
type OpenDialogReturn<T extends OpenDialogOptions> = T["directory"] extends true ? T["multiple"] extends true ? string[] | null : string | null : T["multiple"] extends true ? FileResponse[] | null : FileResponse | null;
|
|
90
|
+
/**
|
|
91
|
+
* Open a file/directory selection dialog.
|
|
92
|
+
*
|
|
93
|
+
* The selected paths are added to the filesystem and asset protocol scopes.
|
|
94
|
+
* When security is more important than the easy of use of this API,
|
|
95
|
+
* prefer writing a dedicated command instead.
|
|
96
|
+
*
|
|
97
|
+
* Note that the scope change is not persisted, so the values are cleared when the application is restarted.
|
|
98
|
+
* You can save it to the filesystem using [tauri-plugin-persisted-scope](https://github.com/tauri-apps/tauri-plugin-persisted-scope).
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* import { open } from '@tauri-apps/plugin-dialog';
|
|
102
|
+
* // Open a selection dialog for image files
|
|
103
|
+
* const selected = await open({
|
|
104
|
+
* multiple: true,
|
|
105
|
+
* filters: [{
|
|
106
|
+
* name: 'Image',
|
|
107
|
+
* extensions: ['png', 'jpeg']
|
|
108
|
+
* }]
|
|
109
|
+
* });
|
|
110
|
+
* if (Array.isArray(selected)) {
|
|
111
|
+
* // user selected multiple files
|
|
112
|
+
* } else if (selected === null) {
|
|
113
|
+
* // user cancelled the selection
|
|
114
|
+
* } else {
|
|
115
|
+
* // user selected a single file
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* import { open } from '@tauri-apps/plugin-dialog';
|
|
122
|
+
* import { appDir } from '@tauri-apps/api/path';
|
|
123
|
+
* // Open a selection dialog for directories
|
|
124
|
+
* const selected = await open({
|
|
125
|
+
* directory: true,
|
|
126
|
+
* multiple: true,
|
|
127
|
+
* defaultPath: await appDir(),
|
|
128
|
+
* });
|
|
129
|
+
* if (Array.isArray(selected)) {
|
|
130
|
+
* // user selected multiple directories
|
|
131
|
+
* } else if (selected === null) {
|
|
132
|
+
* // user cancelled the selection
|
|
133
|
+
* } else {
|
|
134
|
+
* // user selected a single directory
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* @returns A promise resolving to the selected path(s)
|
|
139
|
+
*
|
|
140
|
+
* @since 2.0.0
|
|
141
|
+
*/
|
|
142
|
+
declare function open<T extends OpenDialogOptions>(options?: T): Promise<OpenDialogReturn<T>>;
|
|
105
143
|
/**
|
|
106
144
|
* Open a file/directory save dialog.
|
|
107
145
|
*
|
|
@@ -179,5 +217,5 @@ declare function ask(message: string, options?: string | ConfirmDialogOptions):
|
|
|
179
217
|
* @since 2.0.0
|
|
180
218
|
*/
|
|
181
219
|
declare function confirm(message: string, options?: string | ConfirmDialogOptions): Promise<boolean>;
|
|
182
|
-
export type { DialogFilter, OpenDialogOptions, SaveDialogOptions, MessageDialogOptions, ConfirmDialogOptions, };
|
|
220
|
+
export type { DialogFilter, FileResponse, OpenDialogOptions, OpenDialogReturn, SaveDialogOptions, MessageDialogOptions, ConfirmDialogOptions, };
|
|
183
221
|
export { open, save, message, ask, confirm };
|
package/dist-js/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tauri-apps/plugin-dialog",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
4
|
"license": "MIT or APACHE-2.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Tauri Programme within The Commons Conservancy"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"LICENSE"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@tauri-apps/api": "2.0.0-
|
|
23
|
+
"@tauri-apps/api": "2.0.0-beta.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "rollup -c"
|