quasar-ui-danx 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/danx.es.js +7127 -6615
- package/dist/danx.es.js.map +1 -1
- package/dist/danx.umd.js +11 -5
- package/dist/danx.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +3 -1
- package/src/components/ActionTable/ActionTable.vue +28 -41
- package/src/components/ActionTable/Columns/ActionTableColumn.vue +19 -18
- package/src/components/ActionTable/Filters/CollapsableFiltersSidebar.vue +6 -6
- package/src/components/ActionTable/Filters/{FilterFieldList.vue → FilterList.vue} +26 -26
- package/src/components/ActionTable/Filters/FilterableField.vue +28 -31
- package/src/components/ActionTable/Filters/index.ts +2 -2
- package/src/components/ActionTable/Form/Fields/EditOnClickTextField.vue +71 -0
- package/src/components/ActionTable/Form/Fields/FieldLabel.vue +8 -13
- package/src/components/ActionTable/Form/Fields/MultiFileField.vue +48 -44
- package/src/components/ActionTable/Form/Fields/SelectField.vue +24 -38
- package/src/components/ActionTable/Form/Fields/SelectWithChildrenField.vue +28 -33
- package/src/components/ActionTable/Form/Fields/SingleFileField.vue +15 -15
- package/src/components/ActionTable/Form/Fields/SliderNumberField.vue +45 -0
- package/src/components/ActionTable/Form/Fields/TextField.vue +47 -66
- package/src/components/ActionTable/Form/Fields/index.ts +2 -0
- package/src/components/ActionTable/Form/RenderedForm.vue +50 -9
- package/src/components/ActionTable/Form/Utilities/MaxLengthCounter.vue +17 -0
- package/src/components/ActionTable/Form/Utilities/index.ts +1 -0
- package/src/components/ActionTable/Form/index.ts +1 -0
- package/src/components/ActionTable/Layouts/ActionTableLayout.vue +16 -15
- package/src/components/ActionTable/Toolbars/ActionToolbar.vue +6 -6
- package/src/components/ActionTable/listControls.ts +104 -166
- package/src/components/ActionTable/listHelpers.ts +2 -3
- package/src/components/ActionTable/tableColumns.ts +3 -27
- package/src/components/AuditHistory/AuditHistoryItemValue.vue +26 -26
- package/src/components/PanelsDrawer/PanelsDrawer.vue +17 -4
- package/src/components/PanelsDrawer/PanelsDrawerPanels.vue +6 -11
- package/src/components/PanelsDrawer/PanelsDrawerTabs.vue +20 -20
- package/src/components/Utility/Dialogs/ConfirmActionDialog.vue +39 -0
- package/src/components/Utility/Dialogs/ConfirmDialog.vue +10 -24
- package/src/components/Utility/Dialogs/DialogLayout.vue +10 -28
- package/src/components/Utility/Dialogs/FullscreenCarouselDialog.vue +42 -36
- package/src/components/Utility/Dialogs/index.ts +1 -0
- package/src/components/Utility/Files/FilePreview.vue +76 -73
- package/src/components/Utility/Layouts/ContentDrawer.vue +24 -31
- package/src/components/Utility/Tools/ActionVnode.vue +3 -3
- package/src/components/Utility/Tools/RenderVnode.vue +1 -1
- package/src/components/Utility/Transitions/MaxHeightTransition.vue +26 -0
- package/src/components/Utility/Transitions/index.ts +1 -0
- package/src/config/index.ts +36 -31
- package/src/helpers/FileUpload.ts +295 -297
- package/src/helpers/FlashMessages.ts +80 -71
- package/src/helpers/actions.ts +102 -82
- package/src/helpers/download.ts +189 -189
- package/src/helpers/downloadPdf.ts +55 -52
- package/src/helpers/formats.ts +151 -109
- package/src/helpers/index.ts +2 -0
- package/src/helpers/multiFileUpload.ts +72 -58
- package/src/helpers/objectStore.ts +52 -0
- package/src/helpers/request.ts +70 -51
- package/src/helpers/routes.ts +29 -0
- package/src/helpers/storage.ts +7 -3
- package/src/helpers/utils.ts +47 -29
- package/src/styles/quasar-reset.scss +16 -1
- package/src/styles/themes/danx/dialogs.scss +4 -0
- package/src/types/actions.d.ts +43 -0
- package/src/types/config.d.ts +15 -0
- package/src/types/controls.d.ts +99 -0
- package/src/types/dialogs.d.ts +32 -0
- package/src/types/fields.d.ts +20 -0
- package/src/types/files.d.ts +54 -0
- package/src/types/formats.d.ts +4 -0
- package/src/{components/ActionTable/Form/form.d.ts → types/forms.d.ts} +6 -0
- package/src/types/index.d.ts +12 -0
- package/src/types/requests.d.ts +13 -0
- package/src/types/shared.d.ts +15 -0
- package/src/types/tables.d.ts +27 -0
- package/types/index.d.ts +1 -1
- /package/src/components/ActionTable/Filters/{FilterFieldItem.vue → FilterItem.vue} +0 -0
package/src/helpers/download.ts
CHANGED
@@ -8,193 +8,193 @@
|
|
8
8
|
// https://github.com/rndme/download
|
9
9
|
|
10
10
|
/* eslint-disable */
|
11
|
-
export function download(data, strFileName, strMimeType) {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
11
|
+
export function download(data: any, strFileName?: string, strMimeType?: string) {
|
12
|
+
var self = window;
|
13
|
+
// this script is only for browsers anyway...
|
14
|
+
|
15
|
+
var defaultMime = "application/octet-stream";
|
16
|
+
// this default mime also triggers iframe downloads
|
17
|
+
|
18
|
+
var mimeType = strMimeType || defaultMime;
|
19
|
+
|
20
|
+
var payload = data;
|
21
|
+
|
22
|
+
var url = !strFileName && !strMimeType && payload;
|
23
|
+
|
24
|
+
var anchor = document.createElement("a");
|
25
|
+
|
26
|
+
var toString = function (a) {
|
27
|
+
return String(a);
|
28
|
+
};
|
29
|
+
|
30
|
+
// @ts-ignore
|
31
|
+
var myBlob = self.Blob || self.MozBlob || self.WebKitBlob || toString;
|
32
|
+
|
33
|
+
var fileName = strFileName || "download";
|
34
|
+
|
35
|
+
var blob;
|
36
|
+
|
37
|
+
var reader;
|
38
|
+
myBlob = myBlob.call ? myBlob.bind(self) : Blob;
|
39
|
+
|
40
|
+
if (String(this) === "true") {
|
41
|
+
// reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback
|
42
|
+
payload = [payload, mimeType];
|
43
|
+
mimeType = payload[0];
|
44
|
+
payload = payload[1];
|
45
|
+
}
|
46
|
+
|
47
|
+
if (url && url.length < 2048) {
|
48
|
+
// if no filename and no mime, assume a url was passed as the only argument
|
49
|
+
fileName = url.split("/").pop().split("?")[0];
|
50
|
+
anchor.href = url; // assign href prop to temp anchor
|
51
|
+
|
52
|
+
// if the browser determines that it's a potentially valid url path:
|
53
|
+
if (
|
54
|
+
anchor.href.indexOf(url) !== -1 ||
|
55
|
+
anchor.href.indexOf(encodeURI(url)) !== -1 ||
|
56
|
+
anchor.href === encodeURI(url)
|
57
|
+
) {
|
58
|
+
var ajax = new XMLHttpRequest();
|
59
|
+
ajax.open("GET", url + "?no-cache=" + Date.now(), true);
|
60
|
+
ajax.responseType = "blob";
|
61
|
+
ajax.onload = function (e) {
|
62
|
+
// @ts-ignore
|
63
|
+
download(e.target.response, fileName, defaultMime);
|
64
|
+
};
|
65
|
+
ajax.onerror = function (e) {
|
66
|
+
// As a fallback, just open the request in a new tab
|
67
|
+
window.open(url, "_blank").focus();
|
68
|
+
};
|
69
|
+
setTimeout(function () {
|
70
|
+
ajax.send();
|
71
|
+
}, 0); // allows setting custom ajax headers using the return:
|
72
|
+
return ajax;
|
73
|
+
} else {
|
74
|
+
throw new Error("Invalid URL given, cannot download file: " + url);
|
75
|
+
}
|
76
|
+
} // end if url?
|
77
|
+
|
78
|
+
// go ahead and download dataURLs right away
|
79
|
+
if (/^data:[\w+-]+\/[\w+-]+[,;]/.test(payload)) {
|
80
|
+
if (payload.length > 1024 * 1024 * 1.999 && myBlob !== toString) {
|
81
|
+
payload = dataUrlToBlob(payload);
|
82
|
+
mimeType = payload.type || defaultMime;
|
83
|
+
} else {
|
84
|
+
// IE10 can't do a[download], only Blobs
|
85
|
+
// everyone else can save dataURLs un-processed
|
86
|
+
// @ts-ignore
|
87
|
+
return navigator.msSaveBlob ? navigator.msSaveBlob(dataUrlToBlob(payload), fileName) : saver(payload);
|
88
|
+
}
|
89
|
+
} // end if dataURL passed?
|
90
|
+
|
91
|
+
blob =
|
92
|
+
payload instanceof myBlob
|
93
|
+
? payload
|
94
|
+
: new myBlob([payload], { type: mimeType });
|
95
|
+
|
96
|
+
function dataUrlToBlob(strUrl) {
|
97
|
+
var parts = strUrl.split(/[:;,]/);
|
98
|
+
|
99
|
+
var type = parts[1];
|
100
|
+
|
101
|
+
var decoder = parts[2] === "base64" ? atob : decodeURIComponent;
|
102
|
+
|
103
|
+
var binData = decoder(parts.pop());
|
104
|
+
|
105
|
+
var mx = binData.length;
|
106
|
+
|
107
|
+
var i = 0;
|
108
|
+
|
109
|
+
var uiArr = new Uint8Array(mx);
|
110
|
+
|
111
|
+
for (i; i < mx; ++i) uiArr[i] = binData.charCodeAt(i);
|
112
|
+
|
113
|
+
return new myBlob([uiArr], { type: type });
|
114
|
+
}
|
115
|
+
|
116
|
+
function saver(url, winMode) {
|
117
|
+
if ("download" in anchor) {
|
118
|
+
// html5 A[download]
|
119
|
+
anchor.href = url;
|
120
|
+
anchor.setAttribute("download", fileName);
|
121
|
+
anchor.className = "download-js-link";
|
122
|
+
anchor.innerHTML = "downloading...";
|
123
|
+
anchor.style.display = "none";
|
124
|
+
document.body.appendChild(anchor);
|
125
|
+
setTimeout(function () {
|
126
|
+
anchor.click();
|
127
|
+
document.body.removeChild(anchor);
|
128
|
+
if (winMode === true) {
|
129
|
+
setTimeout(function () {
|
130
|
+
self.URL.revokeObjectURL(anchor.href);
|
131
|
+
}, 250);
|
132
|
+
}
|
133
|
+
}, 66);
|
134
|
+
return true;
|
135
|
+
}
|
136
|
+
|
137
|
+
// handle non-a[download] safari as best we can:
|
138
|
+
if (
|
139
|
+
/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)
|
140
|
+
) {
|
141
|
+
url = url.replace(/^data:([\w/\-+]+)/, defaultMime);
|
142
|
+
if (!window.open(url)) {
|
143
|
+
// popup blocked, offer direct download:
|
144
|
+
if (
|
145
|
+
confirm(
|
146
|
+
"Displaying New Document\n\nUse Save As... to download, then click back to return to this page."
|
147
|
+
)
|
148
|
+
) {
|
149
|
+
location.href = url;
|
150
|
+
}
|
151
|
+
}
|
152
|
+
return true;
|
153
|
+
}
|
154
|
+
|
155
|
+
// do iframe dataURL download (old ch+FF):
|
156
|
+
var f = document.createElement("iframe");
|
157
|
+
document.body.appendChild(f);
|
158
|
+
|
159
|
+
if (!winMode) {
|
160
|
+
// force a mime that will download:
|
161
|
+
url = "data:" + url.replace(/^data:([\w/\-+]+)/, defaultMime);
|
162
|
+
}
|
163
|
+
f.src = url;
|
164
|
+
setTimeout(function () {
|
165
|
+
document.body.removeChild(f);
|
166
|
+
}, 333);
|
167
|
+
} // end saver
|
168
|
+
|
169
|
+
// @ts-ignore
|
170
|
+
if (navigator.msSaveBlob) {
|
171
|
+
// IE10+ : (has Blob, but not a[download] or URL)
|
172
|
+
// @ts-ignore
|
173
|
+
return navigator.msSaveBlob(blob, fileName);
|
174
|
+
}
|
175
|
+
|
176
|
+
if (self.URL) {
|
177
|
+
// simple fast and modern way using Blob and URL:
|
178
|
+
saver(self.URL.createObjectURL(blob), true);
|
179
|
+
} else {
|
180
|
+
// handle non-Blob()+non-URL browsers:
|
181
|
+
if (typeof blob === "string" || blob.constructor === toString) {
|
182
|
+
try {
|
183
|
+
// @ts-ignore
|
184
|
+
return saver("data:" + mimeType + ";base64," + self.btoa(blob));
|
185
|
+
} catch (y) {
|
186
|
+
// @ts-ignore
|
187
|
+
return saver("data:" + mimeType + "," + encodeURIComponent(blob));
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
// Blob but not URL support:
|
192
|
+
reader = new FileReader();
|
193
|
+
reader.onload = function (e) {
|
194
|
+
// @ts-ignore
|
195
|
+
saver(this.result);
|
196
|
+
};
|
197
|
+
reader.readAsDataURL(blob);
|
198
|
+
}
|
199
|
+
return true;
|
200
200
|
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { danxOptions } from "../config";
|
2
|
+
import { AnyObject, HttpResponse } from "../types";
|
1
3
|
import { download } from "./download";
|
2
4
|
|
3
5
|
/**
|
@@ -8,43 +10,44 @@ import { download } from "./download";
|
|
8
10
|
* @param postParams
|
9
11
|
* @returns {Promise<void>}
|
10
12
|
*/
|
11
|
-
export async function downloadFile(url, filename = "", postParams = null) {
|
12
|
-
|
13
|
+
export async function downloadFile(url: string, filename = "", postParams: AnyObject | null = null) {
|
14
|
+
let fetchOptions: AnyObject | undefined = undefined;
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
if (postParams) {
|
17
|
+
fetchOptions = {
|
18
|
+
method: "POST",
|
19
|
+
headers: {
|
20
|
+
...danxOptions.value.request?.headers
|
21
|
+
},
|
22
|
+
body: JSON.stringify(postParams)
|
23
|
+
};
|
24
|
+
}
|
21
25
|
|
22
|
-
|
26
|
+
const response: HttpResponse = await fetch(url, fetchOptions);
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
28
|
+
if (!response.ok) {
|
29
|
+
throw Error("File download failed: invalid response from server");
|
30
|
+
}
|
27
31
|
|
28
|
-
|
32
|
+
let errorMessage;
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
}
|
34
|
+
// Handle a JSON response (which indicates an error occurred)
|
35
|
+
try {
|
36
|
+
const jsonResponse = JSON.parse(new TextDecoder().decode(response.data));
|
37
|
+
console.error("Error downloading file:", jsonResponse);
|
38
|
+
errorMessage = jsonResponse.message;
|
39
|
+
if (jsonResponse.errors) {
|
40
|
+
errorMessage = jsonResponse.errors[0].message;
|
41
|
+
}
|
42
|
+
} catch (e) {
|
43
|
+
// we expect an error thrown for invalid JSON when the response is a file
|
44
|
+
}
|
42
45
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
if (errorMessage) {
|
47
|
+
throw new Error("Failed to download file: " + errorMessage);
|
48
|
+
}
|
46
49
|
|
47
|
-
|
50
|
+
await downloadFileResponse(response, filename);
|
48
51
|
}
|
49
52
|
|
50
53
|
/**
|
@@ -53,25 +56,25 @@ export async function downloadFile(url, filename = "", postParams = null) {
|
|
53
56
|
* @param response
|
54
57
|
* @param filename
|
55
58
|
*/
|
56
|
-
export async function downloadFileResponse(response, filename = "") {
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
export async function downloadFileResponse(response: HttpResponse, filename = "") {
|
60
|
+
const contentDisposition = getResponseHeader(
|
61
|
+
response,
|
62
|
+
"content-disposition",
|
63
|
+
""
|
64
|
+
);
|
62
65
|
|
63
|
-
|
66
|
+
const contentType = getResponseHeader(response, "content-type", "");
|
64
67
|
|
65
|
-
|
68
|
+
const match = contentDisposition.match(/filename="([^"]+)"/);
|
66
69
|
|
67
|
-
|
70
|
+
filename = filename || (match && match[1]) || "download.pdf";
|
68
71
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
72
|
+
let data = response.data;
|
73
|
+
if (!data) {
|
74
|
+
data = await response.blob();
|
75
|
+
}
|
73
76
|
|
74
|
-
|
77
|
+
download(data, filename, contentType);
|
75
78
|
}
|
76
79
|
|
77
80
|
/**
|
@@ -81,12 +84,12 @@ export async function downloadFileResponse(response, filename = "") {
|
|
81
84
|
* @param defaultValue
|
82
85
|
* @returns {*}
|
83
86
|
*/
|
84
|
-
export function getResponseHeader(response, header, defaultValue) {
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
export function getResponseHeader(response: HttpResponse, header: string, defaultValue: any) {
|
88
|
+
if (response.headers) {
|
89
|
+
if (typeof response.headers.get === "function") {
|
90
|
+
return response.headers.get(header) || defaultValue;
|
91
|
+
} else {
|
92
|
+
return response.headers[header] || defaultValue;
|
93
|
+
}
|
94
|
+
}
|
92
95
|
}
|