tsv2-library 1.0.61-alpha.66 → 1.0.61-alpha.68

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.
@@ -1,10 +1,11 @@
1
1
  export declare const buildFileURL: (name?: string, width?: number, height?: number) => string;
2
2
  /**
3
3
  *
4
- * @param fileUrl The full URL
4
+ * @param name The full URL, or the file token as it appears on the server
5
5
  * @param fileName Custom File name
6
6
  * @param immediateRevoke Immediately revoke the object URL after download - default to true
7
+ * @param viewNewTab View the file in a new tab - default to false
7
8
  * @returns
8
9
  */
9
- export declare const downloadFile: (fileUrl: string, customFileName?: string, immediateRevoke?: boolean, viewNewTab?: boolean) => Promise<string>;
10
+ export declare const downloadFile: (name: string, customFileName?: string, immediateRevoke?: boolean, viewNewTab?: boolean) => Promise<string>;
10
11
  export declare const getImageURL: (name?: string | null, width?: number, height?: number, returnURLOnly?: boolean) => Promise<string | undefined>;
@@ -19616,7 +19616,9 @@ const getAuthToken = () => {
19616
19616
  const user = JSON.parse(localStorage.getItem("user") ?? "{}");
19617
19617
  return user.jwt ?? user.token ?? "";
19618
19618
  };
19619
- const fetchFile = async (url, token) => {
19619
+ const fetchFile = async (name) => {
19620
+ const token = getAuthToken();
19621
+ const url = name.startsWith("http") ? name : await getImageURL(name, void 0, void 0, true);
19620
19622
  const res = await axios.get(url, {
19621
19623
  responseType: "blob",
19622
19624
  headers: {
@@ -19630,9 +19632,8 @@ const fetchFile = async (url, token) => {
19630
19632
  fileName: getFilenameFromResponse(res)
19631
19633
  };
19632
19634
  };
19633
- const downloadFile = async (fileUrl, customFileName, immediateRevoke = true, viewNewTab = false) => {
19634
- const token = getAuthToken();
19635
- const { blob: blob2, fileName: fetchFileName } = await fetchFile(fileUrl, token);
19635
+ const downloadFile = async (name, customFileName, immediateRevoke = true, viewNewTab = false) => {
19636
+ const { blob: blob2, fileName: fetchFileName } = await fetchFile(name);
19636
19637
  let objectUrl = "";
19637
19638
  const isViewable = /^(image|application\/pdf)/i.test(blob2.type);
19638
19639
  const fileName = customFileName ?? fetchFileName;
@@ -19660,8 +19661,7 @@ const downloadFile = async (fileUrl, customFileName, immediateRevoke = true, vie
19660
19661
  };
19661
19662
  const createBlobURL = async (rawFileUrl) => {
19662
19663
  try {
19663
- const token = getAuthToken();
19664
- const { blob: blob2 } = await fetchFile(rawFileUrl, token);
19664
+ const { blob: blob2 } = await fetchFile(rawFileUrl);
19665
19665
  return URL.createObjectURL(blob2);
19666
19666
  } catch (err) {
19667
19667
  return void 0;
@@ -61237,7 +61237,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
61237
61237
  };
61238
61238
  const reRenderPanel = () => {
61239
61239
  var _a;
61240
- if (((_a = calendar.value) == null ? void 0 : _a.currentView) === "date") {
61240
+ if (((_a = calendar.value) == null ? void 0 : _a.currentView) === "date" && props.showTime) {
61241
61241
  closePanel();
61242
61242
  nextTick(showPanel);
61243
61243
  }