sales-frontend-components 0.0.218 → 0.0.219
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/index.cjs.js +20 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +20 -13
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs.js
CHANGED
|
@@ -149,16 +149,6 @@ var isClient = () => {
|
|
|
149
149
|
return false;
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
|
-
var getBusinessWorkDivisionCode = (pathname) => {
|
|
153
|
-
return location.pathname.split("/")[1] ?? "";
|
|
154
|
-
};
|
|
155
|
-
var getServicePath = () => {
|
|
156
|
-
if (typeof window.isStorybookEnv === "boolean") {
|
|
157
|
-
return "";
|
|
158
|
-
} else {
|
|
159
|
-
return `/${getBusinessWorkDivisionCode()}`;
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
152
|
var isAndroidDevice = () => {
|
|
163
153
|
if (isClient() === false) {
|
|
164
154
|
return false;
|
|
@@ -4897,9 +4887,26 @@ const useDownloader = () => {
|
|
|
4897
4887
|
const [isLoading, setIsLoading] = React.useState(false);
|
|
4898
4888
|
const downloadFile = async (url, fileName) => {
|
|
4899
4889
|
try {
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4890
|
+
let downloadUrl = "";
|
|
4891
|
+
if (url.startsWith("http")) {
|
|
4892
|
+
const response = await fetch(url);
|
|
4893
|
+
if (!response.ok) {
|
|
4894
|
+
throw new Error(`Failed to download ${url}`);
|
|
4895
|
+
}
|
|
4896
|
+
const blob = await response.blob();
|
|
4897
|
+
downloadUrl = window.URL.createObjectURL(blob);
|
|
4898
|
+
} else if (url.startsWith("blob")) {
|
|
4899
|
+
downloadUrl = url;
|
|
4900
|
+
} else {
|
|
4901
|
+
throw new Error(`unknown type : ${url}`);
|
|
4902
|
+
}
|
|
4903
|
+
const a = document.createElement("a");
|
|
4904
|
+
a.href = downloadUrl;
|
|
4905
|
+
a.download = fileName || url.split("/").pop() || "download";
|
|
4906
|
+
document.body.appendChild(a);
|
|
4907
|
+
a.click();
|
|
4908
|
+
a.remove();
|
|
4909
|
+
window.URL.revokeObjectURL(downloadUrl);
|
|
4903
4910
|
} catch (e) {
|
|
4904
4911
|
console.error(e);
|
|
4905
4912
|
throw e;
|