quasar-ui-danx 0.3.44 → 0.3.45

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.3.44",
3
+ "version": "0.3.45",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -7,6 +7,8 @@
7
7
  // semantic variable names, long (over 2MB) dataURL support, and hidden by default temp anchors
8
8
  // https://github.com/rndme/download
9
9
 
10
+ import { FlashMessages } from "../helpers";
11
+
10
12
  export async function downloadBlobOrUrl(blobOrUrl, filename = "download") {
11
13
  // Create a Promise that resolves to a Blob URL
12
14
  const blobUrlPromise = new Promise((resolve, reject) => {
@@ -28,36 +30,25 @@ export async function downloadBlobOrUrl(blobOrUrl, filename = "download") {
28
30
  });
29
31
 
30
32
  return await blobUrlPromise.then((blobUrl) => {
31
- // Create a temporary anchor element
32
- const anchor = document.createElement("a");
33
- anchor.style.display = "none";
34
- anchor.href = blobUrl as string;
35
- anchor.download = filename;
36
- anchor.target = "_blank";
37
-
38
- // Append the anchor to the body
39
- document.body.appendChild(anchor);
40
-
41
- // Programmatically trigger a click event on the anchor
42
- const clickEvent = new MouseEvent("click", {
43
- view: window,
44
- bubbles: true,
45
- cancelable: true
46
- });
47
- anchor.dispatchEvent(clickEvent);
33
+ const downloadTimeout = 60000;
48
34
 
49
- // Remove the anchor from the document
50
- document.body.removeChild(anchor);
35
+ FlashMessages.success(`Click to save photo to phone: <a target="_blank" href='${blobUrl}' download="${filename}">${filename.replace(/.*\//, "")}</a>`, {
36
+ html: true,
37
+ timeout: downloadTimeout
38
+ });
51
39
 
52
40
  // Revoke the object URL if we created one
53
41
  if (blobOrUrl instanceof Blob) {
54
- setTimeout(() => URL.revokeObjectURL(blobUrl), 100);
42
+ setTimeout(() => URL.revokeObjectURL(blobUrl), downloadTimeout);
55
43
  }
56
44
  }).catch((error) => {
57
45
  console.error("An error occurred while downloading the file:", error);
58
46
  });
59
47
  }
60
48
 
49
+ /**
50
+ * @deprecated Use downloadBlobOrUrl instead
51
+ */
61
52
  /* eslint-disable */
62
53
  export function download(data, strFileName, strMimeType) {
63
54
  var self = window;