@fctc/interface-logic 3.2.6 → 3.2.7
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/dist/utils.d.mts +2 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +33 -0
- package/dist/utils.mjs +32 -0
- package/package.json +1 -1
package/dist/utils.d.mts
CHANGED
|
@@ -106,5 +106,6 @@ declare const useField: (props: any) => {
|
|
|
106
106
|
readonly: boolean;
|
|
107
107
|
nameField: string | null;
|
|
108
108
|
};
|
|
109
|
+
declare const downloadFile: (url: string, filename?: string) => Promise<void>;
|
|
109
110
|
|
|
110
|
-
export { WesapError, checkIsImageLink, convertFloatToTime, convertTimeToFloat, copyTextToClipboard, domainHelper, evalJSONContext, evalJSONDomain, filterFieldDirty, formatCurrency, formatDate, formatFileSize, formatSortingString, formatUrlPath, getFieldsOnChange, getOffSet, getSubdomain, handleError, isBase64File, isBase64Image, isObjectEmpty, mergeObjects, removeUndefinedFields, resequence, sessionStorageUtils, stringToColor, toQueryString, updateTokenParamInOriginalRequest, useField, useTabModel, validateAndParseDate };
|
|
111
|
+
export { WesapError, checkIsImageLink, convertFloatToTime, convertTimeToFloat, copyTextToClipboard, domainHelper, downloadFile, evalJSONContext, evalJSONDomain, filterFieldDirty, formatCurrency, formatDate, formatFileSize, formatSortingString, formatUrlPath, getFieldsOnChange, getOffSet, getSubdomain, handleError, isBase64File, isBase64Image, isObjectEmpty, mergeObjects, removeUndefinedFields, resequence, sessionStorageUtils, stringToColor, toQueryString, updateTokenParamInOriginalRequest, useField, useTabModel, validateAndParseDate };
|
package/dist/utils.d.ts
CHANGED
|
@@ -106,5 +106,6 @@ declare const useField: (props: any) => {
|
|
|
106
106
|
readonly: boolean;
|
|
107
107
|
nameField: string | null;
|
|
108
108
|
};
|
|
109
|
+
declare const downloadFile: (url: string, filename?: string) => Promise<void>;
|
|
109
110
|
|
|
110
|
-
export { WesapError, checkIsImageLink, convertFloatToTime, convertTimeToFloat, copyTextToClipboard, domainHelper, evalJSONContext, evalJSONDomain, filterFieldDirty, formatCurrency, formatDate, formatFileSize, formatSortingString, formatUrlPath, getFieldsOnChange, getOffSet, getSubdomain, handleError, isBase64File, isBase64Image, isObjectEmpty, mergeObjects, removeUndefinedFields, resequence, sessionStorageUtils, stringToColor, toQueryString, updateTokenParamInOriginalRequest, useField, useTabModel, validateAndParseDate };
|
|
111
|
+
export { WesapError, checkIsImageLink, convertFloatToTime, convertTimeToFloat, copyTextToClipboard, domainHelper, downloadFile, evalJSONContext, evalJSONDomain, filterFieldDirty, formatCurrency, formatDate, formatFileSize, formatSortingString, formatUrlPath, getFieldsOnChange, getOffSet, getSubdomain, handleError, isBase64File, isBase64Image, isObjectEmpty, mergeObjects, removeUndefinedFields, resequence, sessionStorageUtils, stringToColor, toQueryString, updateTokenParamInOriginalRequest, useField, useTabModel, validateAndParseDate };
|
package/dist/utils.js
CHANGED
|
@@ -36,6 +36,7 @@ __export(utils_exports, {
|
|
|
36
36
|
convertTimeToFloat: () => convertTimeToFloat,
|
|
37
37
|
copyTextToClipboard: () => copyTextToClipboard,
|
|
38
38
|
domainHelper: () => domainHelper,
|
|
39
|
+
downloadFile: () => downloadFile,
|
|
39
40
|
evalJSONContext: () => evalJSONContext,
|
|
40
41
|
evalJSONDomain: () => evalJSONDomain,
|
|
41
42
|
filterFieldDirty: () => filterFieldDirty,
|
|
@@ -2943,6 +2944,37 @@ var useField = (props) => {
|
|
|
2943
2944
|
nameField
|
|
2944
2945
|
};
|
|
2945
2946
|
};
|
|
2947
|
+
var downloadFile = async (url, filename) => {
|
|
2948
|
+
try {
|
|
2949
|
+
const response = await fetch(url);
|
|
2950
|
+
if (!response.ok) throw new Error(`Failed to fetch ${url}`);
|
|
2951
|
+
const contentType = response.headers.get("Content-Type") || "";
|
|
2952
|
+
let ext = "";
|
|
2953
|
+
if (contentType.includes("pdf")) ext = ".pdf";
|
|
2954
|
+
else if (contentType.includes("png")) ext = ".png";
|
|
2955
|
+
else if (contentType.includes("jpeg") || contentType.includes("jpg"))
|
|
2956
|
+
ext = ".jpg";
|
|
2957
|
+
else if (contentType.includes("zip")) ext = ".zip";
|
|
2958
|
+
else if (contentType.includes("msword")) ext = ".doc";
|
|
2959
|
+
else if (contentType.includes("spreadsheet")) ext = ".xls";
|
|
2960
|
+
else if (contentType.includes("json")) ext = ".json";
|
|
2961
|
+
else if (contentType.includes("text")) ext = ".txt";
|
|
2962
|
+
else {
|
|
2963
|
+
ext = "";
|
|
2964
|
+
}
|
|
2965
|
+
const blob = await response.blob();
|
|
2966
|
+
const urlBlob = window.URL.createObjectURL(blob);
|
|
2967
|
+
const link = document.createElement("a");
|
|
2968
|
+
link.href = urlBlob;
|
|
2969
|
+
link.download = (filename || "file") + ext;
|
|
2970
|
+
document.body.appendChild(link);
|
|
2971
|
+
link.click();
|
|
2972
|
+
document.body.removeChild(link);
|
|
2973
|
+
window.URL.revokeObjectURL(urlBlob);
|
|
2974
|
+
} catch (error) {
|
|
2975
|
+
console.error("File download failed:", error);
|
|
2976
|
+
}
|
|
2977
|
+
};
|
|
2946
2978
|
|
|
2947
2979
|
// src/utils/storage/session-storage.ts
|
|
2948
2980
|
var sessionStorageUtils = /* @__PURE__ */ (() => {
|
|
@@ -3001,6 +3033,7 @@ var sessionStorageUtils = /* @__PURE__ */ (() => {
|
|
|
3001
3033
|
convertTimeToFloat,
|
|
3002
3034
|
copyTextToClipboard,
|
|
3003
3035
|
domainHelper,
|
|
3036
|
+
downloadFile,
|
|
3004
3037
|
evalJSONContext,
|
|
3005
3038
|
evalJSONDomain,
|
|
3006
3039
|
filterFieldDirty,
|
package/dist/utils.mjs
CHANGED
|
@@ -2877,6 +2877,37 @@ var useField = (props) => {
|
|
|
2877
2877
|
nameField
|
|
2878
2878
|
};
|
|
2879
2879
|
};
|
|
2880
|
+
var downloadFile = async (url, filename) => {
|
|
2881
|
+
try {
|
|
2882
|
+
const response = await fetch(url);
|
|
2883
|
+
if (!response.ok) throw new Error(`Failed to fetch ${url}`);
|
|
2884
|
+
const contentType = response.headers.get("Content-Type") || "";
|
|
2885
|
+
let ext = "";
|
|
2886
|
+
if (contentType.includes("pdf")) ext = ".pdf";
|
|
2887
|
+
else if (contentType.includes("png")) ext = ".png";
|
|
2888
|
+
else if (contentType.includes("jpeg") || contentType.includes("jpg"))
|
|
2889
|
+
ext = ".jpg";
|
|
2890
|
+
else if (contentType.includes("zip")) ext = ".zip";
|
|
2891
|
+
else if (contentType.includes("msword")) ext = ".doc";
|
|
2892
|
+
else if (contentType.includes("spreadsheet")) ext = ".xls";
|
|
2893
|
+
else if (contentType.includes("json")) ext = ".json";
|
|
2894
|
+
else if (contentType.includes("text")) ext = ".txt";
|
|
2895
|
+
else {
|
|
2896
|
+
ext = "";
|
|
2897
|
+
}
|
|
2898
|
+
const blob = await response.blob();
|
|
2899
|
+
const urlBlob = window.URL.createObjectURL(blob);
|
|
2900
|
+
const link = document.createElement("a");
|
|
2901
|
+
link.href = urlBlob;
|
|
2902
|
+
link.download = (filename || "file") + ext;
|
|
2903
|
+
document.body.appendChild(link);
|
|
2904
|
+
link.click();
|
|
2905
|
+
document.body.removeChild(link);
|
|
2906
|
+
window.URL.revokeObjectURL(urlBlob);
|
|
2907
|
+
} catch (error) {
|
|
2908
|
+
console.error("File download failed:", error);
|
|
2909
|
+
}
|
|
2910
|
+
};
|
|
2880
2911
|
|
|
2881
2912
|
// src/utils/storage/session-storage.ts
|
|
2882
2913
|
var sessionStorageUtils = /* @__PURE__ */ (() => {
|
|
@@ -2934,6 +2965,7 @@ export {
|
|
|
2934
2965
|
convertTimeToFloat,
|
|
2935
2966
|
copyTextToClipboard,
|
|
2936
2967
|
domainHelper,
|
|
2968
|
+
downloadFile,
|
|
2937
2969
|
evalJSONContext,
|
|
2938
2970
|
evalJSONDomain,
|
|
2939
2971
|
filterFieldDirty,
|