quasar-ui-danx 0.4.2 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. package/dist/danx.es.js +7127 -6615
  2. package/dist/danx.es.js.map +1 -1
  3. package/dist/danx.umd.js +11 -5
  4. package/dist/danx.umd.js.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/package.json +3 -1
  7. package/src/components/ActionTable/ActionTable.vue +28 -41
  8. package/src/components/ActionTable/Columns/ActionTableColumn.vue +19 -18
  9. package/src/components/ActionTable/Filters/CollapsableFiltersSidebar.vue +6 -6
  10. package/src/components/ActionTable/Filters/{FilterFieldList.vue → FilterList.vue} +26 -26
  11. package/src/components/ActionTable/Filters/FilterableField.vue +28 -31
  12. package/src/components/ActionTable/Filters/index.ts +2 -2
  13. package/src/components/ActionTable/Form/Fields/EditOnClickTextField.vue +71 -0
  14. package/src/components/ActionTable/Form/Fields/FieldLabel.vue +8 -13
  15. package/src/components/ActionTable/Form/Fields/MultiFileField.vue +48 -44
  16. package/src/components/ActionTable/Form/Fields/SelectField.vue +24 -38
  17. package/src/components/ActionTable/Form/Fields/SelectWithChildrenField.vue +28 -33
  18. package/src/components/ActionTable/Form/Fields/SingleFileField.vue +15 -15
  19. package/src/components/ActionTable/Form/Fields/SliderNumberField.vue +45 -0
  20. package/src/components/ActionTable/Form/Fields/TextField.vue +47 -66
  21. package/src/components/ActionTable/Form/Fields/index.ts +2 -0
  22. package/src/components/ActionTable/Form/RenderedForm.vue +50 -9
  23. package/src/components/ActionTable/Form/Utilities/MaxLengthCounter.vue +17 -0
  24. package/src/components/ActionTable/Form/Utilities/index.ts +1 -0
  25. package/src/components/ActionTable/Form/index.ts +1 -0
  26. package/src/components/ActionTable/Layouts/ActionTableLayout.vue +16 -15
  27. package/src/components/ActionTable/Toolbars/ActionToolbar.vue +6 -6
  28. package/src/components/ActionTable/listControls.ts +106 -166
  29. package/src/components/ActionTable/listHelpers.ts +2 -3
  30. package/src/components/ActionTable/tableColumns.ts +3 -27
  31. package/src/components/AuditHistory/AuditHistoryItemValue.vue +26 -26
  32. package/src/components/PanelsDrawer/PanelsDrawer.vue +17 -4
  33. package/src/components/PanelsDrawer/PanelsDrawerPanels.vue +6 -11
  34. package/src/components/PanelsDrawer/PanelsDrawerTabs.vue +20 -20
  35. package/src/components/Utility/Dialogs/ConfirmActionDialog.vue +39 -0
  36. package/src/components/Utility/Dialogs/ConfirmDialog.vue +10 -24
  37. package/src/components/Utility/Dialogs/DialogLayout.vue +10 -28
  38. package/src/components/Utility/Dialogs/FullscreenCarouselDialog.vue +42 -36
  39. package/src/components/Utility/Dialogs/index.ts +1 -0
  40. package/src/components/Utility/Files/FilePreview.vue +76 -73
  41. package/src/components/Utility/Layouts/ContentDrawer.vue +24 -31
  42. package/src/components/Utility/Tools/ActionVnode.vue +3 -3
  43. package/src/components/Utility/Tools/RenderVnode.vue +1 -1
  44. package/src/components/Utility/Transitions/MaxHeightTransition.vue +26 -0
  45. package/src/components/Utility/Transitions/index.ts +1 -0
  46. package/src/config/index.ts +36 -31
  47. package/src/helpers/FileUpload.ts +295 -297
  48. package/src/helpers/FlashMessages.ts +80 -71
  49. package/src/helpers/actions.ts +102 -82
  50. package/src/helpers/download.ts +189 -189
  51. package/src/helpers/downloadPdf.ts +55 -52
  52. package/src/helpers/formats.ts +151 -109
  53. package/src/helpers/index.ts +2 -0
  54. package/src/helpers/multiFileUpload.ts +72 -58
  55. package/src/helpers/objectStore.ts +52 -0
  56. package/src/helpers/request.ts +70 -51
  57. package/src/helpers/routes.ts +29 -0
  58. package/src/helpers/storage.ts +7 -3
  59. package/src/helpers/utils.ts +47 -29
  60. package/src/styles/quasar-reset.scss +16 -1
  61. package/src/styles/themes/danx/dialogs.scss +4 -0
  62. package/src/types/actions.d.ts +43 -0
  63. package/src/types/config.d.ts +15 -0
  64. package/src/types/controls.d.ts +99 -0
  65. package/src/types/dialogs.d.ts +32 -0
  66. package/src/types/fields.d.ts +20 -0
  67. package/src/types/files.d.ts +54 -0
  68. package/src/types/formats.d.ts +4 -0
  69. package/src/{components/ActionTable/Form/form.d.ts → types/forms.d.ts} +6 -0
  70. package/src/types/index.d.ts +12 -0
  71. package/src/types/requests.d.ts +13 -0
  72. package/src/types/shared.d.ts +15 -0
  73. package/src/types/tables.d.ts +27 -0
  74. package/types/index.d.ts +1 -1
  75. /package/src/components/ActionTable/Filters/{FilterFieldItem.vue → FilterItem.vue} +0 -0
@@ -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
- 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;
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
- let fetchOptions = undefined;
13
+ export async function downloadFile(url: string, filename = "", postParams: AnyObject | null = null) {
14
+ let fetchOptions: AnyObject | undefined = undefined;
13
15
 
14
- if (postParams) {
15
- fetchOptions = {
16
- method: "POST",
17
- "Content-Type": "application/json",
18
- body: JSON.stringify(postParams)
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
- const response = await fetch(url, fetchOptions);
26
+ const response: HttpResponse = await fetch(url, fetchOptions);
23
27
 
24
- if (!response.ok) {
25
- throw Error("File download failed: invalid response from server");
26
- }
28
+ if (!response.ok) {
29
+ throw Error("File download failed: invalid response from server");
30
+ }
27
31
 
28
- let errorMessage;
32
+ let errorMessage;
29
33
 
30
- // Handle a JSON response (which indicates an error occurred)
31
- try {
32
- // @ts-expect-error data is defined on response
33
- const jsonResponse = JSON.parse(new TextDecoder().decode(response.data));
34
- console.error("Error downloading file:", jsonResponse);
35
- errorMessage = jsonResponse.message;
36
- if (jsonResponse.errors) {
37
- errorMessage = jsonResponse.errors[0].message;
38
- }
39
- } catch (e) {
40
- // we expect an error thrown for invalid JSON when the response is a file
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
- if (errorMessage) {
44
- throw new Error("Failed to download file: " + errorMessage);
45
- }
46
+ if (errorMessage) {
47
+ throw new Error("Failed to download file: " + errorMessage);
48
+ }
46
49
 
47
- await downloadFileResponse(response, filename);
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
- const contentDisposition = getResponseHeader(
58
- response,
59
- "content-disposition",
60
- ""
61
- );
59
+ export async function downloadFileResponse(response: HttpResponse, filename = "") {
60
+ const contentDisposition = getResponseHeader(
61
+ response,
62
+ "content-disposition",
63
+ ""
64
+ );
62
65
 
63
- const contentType = getResponseHeader(response, "content-type", "");
66
+ const contentType = getResponseHeader(response, "content-type", "");
64
67
 
65
- const match = contentDisposition.match(/filename="([^"]+)"/);
68
+ const match = contentDisposition.match(/filename="([^"]+)"/);
66
69
 
67
- filename = filename || (match && match[1]) || "download.pdf";
70
+ filename = filename || (match && match[1]) || "download.pdf";
68
71
 
69
- let data = response.data;
70
- if (!data) {
71
- data = await response.blob();
72
- }
72
+ let data = response.data;
73
+ if (!data) {
74
+ data = await response.blob();
75
+ }
73
76
 
74
- download(data, filename, contentType);
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
- if (response.headers) {
86
- if (typeof response.headers.get === "function") {
87
- return response.headers.get(header) || defaultValue;
88
- } else {
89
- return response.headers[header] || defaultValue;
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
  }