@fctc/sme-widget-ui 2.1.5 → 2.1.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/index.js +38 -8
- package/dist/index.mjs +38 -8
- package/dist/utils.js +4 -2
- package/dist/utils.mjs +4 -2
- package/dist/widgets.d.mts +1 -0
- package/dist/widgets.d.ts +1 -0
- package/dist/widgets.js +38 -8
- package/dist/widgets.mjs +38 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9961,7 +9961,8 @@ var vi_default = {
|
|
|
9961
9961
|
upload_file_placeholder: "T\u1EA3i t\u1EC7p c\u1EE7a b\u1EA1n",
|
|
9962
9962
|
"no-available": "Kh\xF4ng c\xF3 l\u1EF1a ch\u1ECDn n\xE0o",
|
|
9963
9963
|
paid_amount: "S\u1ED1 ti\u1EC1n \u0111\xE3 \u0111\xF3ng",
|
|
9964
|
-
remanining_amount: "S\u1ED1 ti\u1EC1n c\xF2n l\u1EA1i"
|
|
9964
|
+
remanining_amount: "S\u1ED1 ti\u1EC1n c\xF2n l\u1EA1i",
|
|
9965
|
+
only_image_accept: "Ch\u1EC9 \u0111\u01B0\u1EE3c upload file h\xECnh \u1EA3nh"
|
|
9965
9966
|
};
|
|
9966
9967
|
|
|
9967
9968
|
// src/locales/en.json
|
|
@@ -10010,7 +10011,8 @@ var en_default = {
|
|
|
10010
10011
|
upload_file_placeholder: "Upload your file",
|
|
10011
10012
|
"no-available": "No options available",
|
|
10012
10013
|
paid_amount: "Amount Paid",
|
|
10013
|
-
remanining_amount: "Amount Remaining"
|
|
10014
|
+
remanining_amount: "Amount Remaining",
|
|
10015
|
+
only_image_accept: "Only accept image"
|
|
10014
10016
|
};
|
|
10015
10017
|
|
|
10016
10018
|
// src/utils/i18n.ts
|
|
@@ -16863,6 +16865,7 @@ var BinaryField = (props) => {
|
|
|
16863
16865
|
isEditTable,
|
|
16864
16866
|
widget,
|
|
16865
16867
|
string,
|
|
16868
|
+
value,
|
|
16866
16869
|
// from hook
|
|
16867
16870
|
placeHolderImage,
|
|
16868
16871
|
inputId,
|
|
@@ -16871,13 +16874,18 @@ var BinaryField = (props) => {
|
|
|
16871
16874
|
handleFileChange,
|
|
16872
16875
|
handleRemoveFile,
|
|
16873
16876
|
checkIsImageLink: checkIsImageLink2,
|
|
16874
|
-
onDownload
|
|
16877
|
+
onDownload,
|
|
16878
|
+
setInitialFile
|
|
16875
16879
|
} = props;
|
|
16876
16880
|
const { t: t3 } = useI18n();
|
|
16877
16881
|
const [fileInfo, setFileInfo] = (0, import_react39.useState)(null);
|
|
16882
|
+
const onlyImage = widget === "image" || widget === "image_url";
|
|
16883
|
+
(0, import_react39.useEffect)(() => {
|
|
16884
|
+
setInitialFile(value);
|
|
16885
|
+
}, [value]);
|
|
16878
16886
|
(0, import_react39.useEffect)(() => {
|
|
16879
16887
|
const loadFromLink = async () => {
|
|
16880
|
-
if (!initialFile) return;
|
|
16888
|
+
if (!initialFile || !initialFile.startsWith("http")) return;
|
|
16881
16889
|
if (typeof initialFile !== "string") {
|
|
16882
16890
|
setFileInfo(initialFile);
|
|
16883
16891
|
return;
|
|
@@ -16886,10 +16894,11 @@ var BinaryField = (props) => {
|
|
|
16886
16894
|
let type = "application/octet-stream";
|
|
16887
16895
|
let size4 = 0;
|
|
16888
16896
|
let name3 = formValues?.[filename ?? ""] || initialFile.split("/").pop() || "unknown_file";
|
|
16889
|
-
if (checkIsImageLink2(initialFile)) {
|
|
16897
|
+
if (checkIsImageLink2(initialFile) || onlyImage) {
|
|
16890
16898
|
type = "image/*";
|
|
16891
16899
|
} else {
|
|
16892
16900
|
const response = await fetch(initialFile);
|
|
16901
|
+
console.log("responsessss", response);
|
|
16893
16902
|
const responseBlob = await response.blob();
|
|
16894
16903
|
if (responseBlob) {
|
|
16895
16904
|
type = responseBlob?.type;
|
|
@@ -16912,6 +16921,11 @@ var BinaryField = (props) => {
|
|
|
16912
16921
|
const handleChange = (e3, onChange2) => {
|
|
16913
16922
|
const file = e3.target.files?.[0];
|
|
16914
16923
|
if (!file) return;
|
|
16924
|
+
if (onlyImage && !file.type.startsWith("image/")) {
|
|
16925
|
+
methods?.setError(t3("only_image_accept"));
|
|
16926
|
+
e3.target.value = "";
|
|
16927
|
+
return;
|
|
16928
|
+
}
|
|
16915
16929
|
const isImage = file.type.startsWith("image/");
|
|
16916
16930
|
const preview = isImage ? URL.createObjectURL(file) : null;
|
|
16917
16931
|
const normalized = {
|
|
@@ -16935,7 +16949,11 @@ var BinaryField = (props) => {
|
|
|
16935
16949
|
{
|
|
16936
16950
|
src: url,
|
|
16937
16951
|
alt: name3,
|
|
16938
|
-
className: `w-full h-full rounded-lg object-contain ${isEditTable ? "max-h-10 max-w-10" : "max-w-32 max-h-32"}
|
|
16952
|
+
className: `w-full h-full rounded-lg object-contain ${isEditTable ? "max-h-10 max-w-10" : "max-w-32 max-h-32"}`,
|
|
16953
|
+
style: {
|
|
16954
|
+
maxWidth: isEditTable ? "40px" : "128px",
|
|
16955
|
+
maxHeight: isEditTable ? "40px" : "128px"
|
|
16956
|
+
}
|
|
16939
16957
|
}
|
|
16940
16958
|
);
|
|
16941
16959
|
if (type?.startsWith("video/"))
|
|
@@ -16944,6 +16962,10 @@ var BinaryField = (props) => {
|
|
|
16944
16962
|
{
|
|
16945
16963
|
src: url,
|
|
16946
16964
|
className: `rounded-lg object-cover ${isEditTable ? "max-h-10 max-w-10" : "max-w-32 max-h-32"}`,
|
|
16965
|
+
style: {
|
|
16966
|
+
maxWidth: isEditTable ? "40px" : "128px",
|
|
16967
|
+
maxHeight: isEditTable ? "40px" : "128px"
|
|
16968
|
+
},
|
|
16947
16969
|
controls: true
|
|
16948
16970
|
}
|
|
16949
16971
|
);
|
|
@@ -16959,12 +16981,20 @@ var BinaryField = (props) => {
|
|
|
16959
16981
|
return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
16960
16982
|
getFileIcon(),
|
|
16961
16983
|
/* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { children: [
|
|
16962
|
-
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
16984
|
+
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
16985
|
+
"p",
|
|
16986
|
+
{
|
|
16987
|
+
style: {
|
|
16988
|
+
maxWidth: "120px"
|
|
16989
|
+
},
|
|
16990
|
+
className: "text-sm font-medium text-gray-600 truncate max-w-[120px]",
|
|
16991
|
+
children: name3
|
|
16992
|
+
}
|
|
16993
|
+
),
|
|
16963
16994
|
isShowSize && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "text-xs text-[#666] font-semibold", children: formatFileSize(size4) })
|
|
16964
16995
|
] })
|
|
16965
16996
|
] });
|
|
16966
16997
|
};
|
|
16967
|
-
const onlyImage = widget === "image" || widget === "image_url";
|
|
16968
16998
|
return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
16969
16999
|
Controller,
|
|
16970
17000
|
{
|
package/dist/index.mjs
CHANGED
|
@@ -9836,7 +9836,8 @@ var vi_default = {
|
|
|
9836
9836
|
upload_file_placeholder: "T\u1EA3i t\u1EC7p c\u1EE7a b\u1EA1n",
|
|
9837
9837
|
"no-available": "Kh\xF4ng c\xF3 l\u1EF1a ch\u1ECDn n\xE0o",
|
|
9838
9838
|
paid_amount: "S\u1ED1 ti\u1EC1n \u0111\xE3 \u0111\xF3ng",
|
|
9839
|
-
remanining_amount: "S\u1ED1 ti\u1EC1n c\xF2n l\u1EA1i"
|
|
9839
|
+
remanining_amount: "S\u1ED1 ti\u1EC1n c\xF2n l\u1EA1i",
|
|
9840
|
+
only_image_accept: "Ch\u1EC9 \u0111\u01B0\u1EE3c upload file h\xECnh \u1EA3nh"
|
|
9840
9841
|
};
|
|
9841
9842
|
|
|
9842
9843
|
// src/locales/en.json
|
|
@@ -9885,7 +9886,8 @@ var en_default = {
|
|
|
9885
9886
|
upload_file_placeholder: "Upload your file",
|
|
9886
9887
|
"no-available": "No options available",
|
|
9887
9888
|
paid_amount: "Amount Paid",
|
|
9888
|
-
remanining_amount: "Amount Remaining"
|
|
9889
|
+
remanining_amount: "Amount Remaining",
|
|
9890
|
+
only_image_accept: "Only accept image"
|
|
9889
9891
|
};
|
|
9890
9892
|
|
|
9891
9893
|
// src/utils/i18n.ts
|
|
@@ -16738,6 +16740,7 @@ var BinaryField = (props) => {
|
|
|
16738
16740
|
isEditTable,
|
|
16739
16741
|
widget,
|
|
16740
16742
|
string,
|
|
16743
|
+
value,
|
|
16741
16744
|
// from hook
|
|
16742
16745
|
placeHolderImage,
|
|
16743
16746
|
inputId,
|
|
@@ -16746,13 +16749,18 @@ var BinaryField = (props) => {
|
|
|
16746
16749
|
handleFileChange,
|
|
16747
16750
|
handleRemoveFile,
|
|
16748
16751
|
checkIsImageLink: checkIsImageLink2,
|
|
16749
|
-
onDownload
|
|
16752
|
+
onDownload,
|
|
16753
|
+
setInitialFile
|
|
16750
16754
|
} = props;
|
|
16751
16755
|
const { t: t3 } = useI18n();
|
|
16752
16756
|
const [fileInfo, setFileInfo] = useState11(null);
|
|
16757
|
+
const onlyImage = widget === "image" || widget === "image_url";
|
|
16758
|
+
useEffect11(() => {
|
|
16759
|
+
setInitialFile(value);
|
|
16760
|
+
}, [value]);
|
|
16753
16761
|
useEffect11(() => {
|
|
16754
16762
|
const loadFromLink = async () => {
|
|
16755
|
-
if (!initialFile) return;
|
|
16763
|
+
if (!initialFile || !initialFile.startsWith("http")) return;
|
|
16756
16764
|
if (typeof initialFile !== "string") {
|
|
16757
16765
|
setFileInfo(initialFile);
|
|
16758
16766
|
return;
|
|
@@ -16761,10 +16769,11 @@ var BinaryField = (props) => {
|
|
|
16761
16769
|
let type = "application/octet-stream";
|
|
16762
16770
|
let size4 = 0;
|
|
16763
16771
|
let name3 = formValues?.[filename ?? ""] || initialFile.split("/").pop() || "unknown_file";
|
|
16764
|
-
if (checkIsImageLink2(initialFile)) {
|
|
16772
|
+
if (checkIsImageLink2(initialFile) || onlyImage) {
|
|
16765
16773
|
type = "image/*";
|
|
16766
16774
|
} else {
|
|
16767
16775
|
const response = await fetch(initialFile);
|
|
16776
|
+
console.log("responsessss", response);
|
|
16768
16777
|
const responseBlob = await response.blob();
|
|
16769
16778
|
if (responseBlob) {
|
|
16770
16779
|
type = responseBlob?.type;
|
|
@@ -16787,6 +16796,11 @@ var BinaryField = (props) => {
|
|
|
16787
16796
|
const handleChange = (e3, onChange2) => {
|
|
16788
16797
|
const file = e3.target.files?.[0];
|
|
16789
16798
|
if (!file) return;
|
|
16799
|
+
if (onlyImage && !file.type.startsWith("image/")) {
|
|
16800
|
+
methods?.setError(t3("only_image_accept"));
|
|
16801
|
+
e3.target.value = "";
|
|
16802
|
+
return;
|
|
16803
|
+
}
|
|
16790
16804
|
const isImage = file.type.startsWith("image/");
|
|
16791
16805
|
const preview = isImage ? URL.createObjectURL(file) : null;
|
|
16792
16806
|
const normalized = {
|
|
@@ -16810,7 +16824,11 @@ var BinaryField = (props) => {
|
|
|
16810
16824
|
{
|
|
16811
16825
|
src: url,
|
|
16812
16826
|
alt: name3,
|
|
16813
|
-
className: `w-full h-full rounded-lg object-contain ${isEditTable ? "max-h-10 max-w-10" : "max-w-32 max-h-32"}
|
|
16827
|
+
className: `w-full h-full rounded-lg object-contain ${isEditTable ? "max-h-10 max-w-10" : "max-w-32 max-h-32"}`,
|
|
16828
|
+
style: {
|
|
16829
|
+
maxWidth: isEditTable ? "40px" : "128px",
|
|
16830
|
+
maxHeight: isEditTable ? "40px" : "128px"
|
|
16831
|
+
}
|
|
16814
16832
|
}
|
|
16815
16833
|
);
|
|
16816
16834
|
if (type?.startsWith("video/"))
|
|
@@ -16819,6 +16837,10 @@ var BinaryField = (props) => {
|
|
|
16819
16837
|
{
|
|
16820
16838
|
src: url,
|
|
16821
16839
|
className: `rounded-lg object-cover ${isEditTable ? "max-h-10 max-w-10" : "max-w-32 max-h-32"}`,
|
|
16840
|
+
style: {
|
|
16841
|
+
maxWidth: isEditTable ? "40px" : "128px",
|
|
16842
|
+
maxHeight: isEditTable ? "40px" : "128px"
|
|
16843
|
+
},
|
|
16822
16844
|
controls: true
|
|
16823
16845
|
}
|
|
16824
16846
|
);
|
|
@@ -16834,12 +16856,20 @@ var BinaryField = (props) => {
|
|
|
16834
16856
|
return /* @__PURE__ */ jsxs49("div", { className: "flex items-center gap-2", children: [
|
|
16835
16857
|
getFileIcon(),
|
|
16836
16858
|
/* @__PURE__ */ jsxs49("div", { children: [
|
|
16837
|
-
/* @__PURE__ */ jsx74(
|
|
16859
|
+
/* @__PURE__ */ jsx74(
|
|
16860
|
+
"p",
|
|
16861
|
+
{
|
|
16862
|
+
style: {
|
|
16863
|
+
maxWidth: "120px"
|
|
16864
|
+
},
|
|
16865
|
+
className: "text-sm font-medium text-gray-600 truncate max-w-[120px]",
|
|
16866
|
+
children: name3
|
|
16867
|
+
}
|
|
16868
|
+
),
|
|
16838
16869
|
isShowSize && /* @__PURE__ */ jsx74("span", { className: "text-xs text-[#666] font-semibold", children: formatFileSize(size4) })
|
|
16839
16870
|
] })
|
|
16840
16871
|
] });
|
|
16841
16872
|
};
|
|
16842
|
-
const onlyImage = widget === "image" || widget === "image_url";
|
|
16843
16873
|
return /* @__PURE__ */ jsx74(
|
|
16844
16874
|
Controller,
|
|
16845
16875
|
{
|
package/dist/utils.js
CHANGED
|
@@ -6854,7 +6854,8 @@ var vi_default = {
|
|
|
6854
6854
|
upload_file_placeholder: "T\u1EA3i t\u1EC7p c\u1EE7a b\u1EA1n",
|
|
6855
6855
|
"no-available": "Kh\xF4ng c\xF3 l\u1EF1a ch\u1ECDn n\xE0o",
|
|
6856
6856
|
paid_amount: "S\u1ED1 ti\u1EC1n \u0111\xE3 \u0111\xF3ng",
|
|
6857
|
-
remanining_amount: "S\u1ED1 ti\u1EC1n c\xF2n l\u1EA1i"
|
|
6857
|
+
remanining_amount: "S\u1ED1 ti\u1EC1n c\xF2n l\u1EA1i",
|
|
6858
|
+
only_image_accept: "Ch\u1EC9 \u0111\u01B0\u1EE3c upload file h\xECnh \u1EA3nh"
|
|
6858
6859
|
};
|
|
6859
6860
|
|
|
6860
6861
|
// src/locales/en.json
|
|
@@ -6903,7 +6904,8 @@ var en_default = {
|
|
|
6903
6904
|
upload_file_placeholder: "Upload your file",
|
|
6904
6905
|
"no-available": "No options available",
|
|
6905
6906
|
paid_amount: "Amount Paid",
|
|
6906
|
-
remanining_amount: "Amount Remaining"
|
|
6907
|
+
remanining_amount: "Amount Remaining",
|
|
6908
|
+
only_image_accept: "Only accept image"
|
|
6907
6909
|
};
|
|
6908
6910
|
|
|
6909
6911
|
// src/utils/i18n.ts
|
package/dist/utils.mjs
CHANGED
|
@@ -6831,7 +6831,8 @@ var vi_default = {
|
|
|
6831
6831
|
upload_file_placeholder: "T\u1EA3i t\u1EC7p c\u1EE7a b\u1EA1n",
|
|
6832
6832
|
"no-available": "Kh\xF4ng c\xF3 l\u1EF1a ch\u1ECDn n\xE0o",
|
|
6833
6833
|
paid_amount: "S\u1ED1 ti\u1EC1n \u0111\xE3 \u0111\xF3ng",
|
|
6834
|
-
remanining_amount: "S\u1ED1 ti\u1EC1n c\xF2n l\u1EA1i"
|
|
6834
|
+
remanining_amount: "S\u1ED1 ti\u1EC1n c\xF2n l\u1EA1i",
|
|
6835
|
+
only_image_accept: "Ch\u1EC9 \u0111\u01B0\u1EE3c upload file h\xECnh \u1EA3nh"
|
|
6835
6836
|
};
|
|
6836
6837
|
|
|
6837
6838
|
// src/locales/en.json
|
|
@@ -6880,7 +6881,8 @@ var en_default = {
|
|
|
6880
6881
|
upload_file_placeholder: "Upload your file",
|
|
6881
6882
|
"no-available": "No options available",
|
|
6882
6883
|
paid_amount: "Amount Paid",
|
|
6883
|
-
remanining_amount: "Amount Remaining"
|
|
6884
|
+
remanining_amount: "Amount Remaining",
|
|
6885
|
+
only_image_accept: "Only accept image"
|
|
6884
6886
|
};
|
|
6885
6887
|
|
|
6886
6888
|
// src/utils/i18n.ts
|
package/dist/widgets.d.mts
CHANGED
package/dist/widgets.d.ts
CHANGED
package/dist/widgets.js
CHANGED
|
@@ -7777,7 +7777,8 @@ var vi_default = {
|
|
|
7777
7777
|
upload_file_placeholder: "T\u1EA3i t\u1EC7p c\u1EE7a b\u1EA1n",
|
|
7778
7778
|
"no-available": "Kh\xF4ng c\xF3 l\u1EF1a ch\u1ECDn n\xE0o",
|
|
7779
7779
|
paid_amount: "S\u1ED1 ti\u1EC1n \u0111\xE3 \u0111\xF3ng",
|
|
7780
|
-
remanining_amount: "S\u1ED1 ti\u1EC1n c\xF2n l\u1EA1i"
|
|
7780
|
+
remanining_amount: "S\u1ED1 ti\u1EC1n c\xF2n l\u1EA1i",
|
|
7781
|
+
only_image_accept: "Ch\u1EC9 \u0111\u01B0\u1EE3c upload file h\xECnh \u1EA3nh"
|
|
7781
7782
|
};
|
|
7782
7783
|
|
|
7783
7784
|
// src/locales/en.json
|
|
@@ -7826,7 +7827,8 @@ var en_default = {
|
|
|
7826
7827
|
upload_file_placeholder: "Upload your file",
|
|
7827
7828
|
"no-available": "No options available",
|
|
7828
7829
|
paid_amount: "Amount Paid",
|
|
7829
|
-
remanining_amount: "Amount Remaining"
|
|
7830
|
+
remanining_amount: "Amount Remaining",
|
|
7831
|
+
only_image_accept: "Only accept image"
|
|
7830
7832
|
};
|
|
7831
7833
|
|
|
7832
7834
|
// src/utils/i18n.ts
|
|
@@ -16115,6 +16117,7 @@ var BinaryField = (props) => {
|
|
|
16115
16117
|
isEditTable,
|
|
16116
16118
|
widget,
|
|
16117
16119
|
string,
|
|
16120
|
+
value,
|
|
16118
16121
|
// from hook
|
|
16119
16122
|
placeHolderImage,
|
|
16120
16123
|
inputId,
|
|
@@ -16123,13 +16126,18 @@ var BinaryField = (props) => {
|
|
|
16123
16126
|
handleFileChange,
|
|
16124
16127
|
handleRemoveFile,
|
|
16125
16128
|
checkIsImageLink: checkIsImageLink2,
|
|
16126
|
-
onDownload
|
|
16129
|
+
onDownload,
|
|
16130
|
+
setInitialFile
|
|
16127
16131
|
} = props;
|
|
16128
16132
|
const { t: t3 } = useI18n();
|
|
16129
16133
|
const [fileInfo, setFileInfo] = (0, import_react39.useState)(null);
|
|
16134
|
+
const onlyImage = widget === "image" || widget === "image_url";
|
|
16135
|
+
(0, import_react39.useEffect)(() => {
|
|
16136
|
+
setInitialFile(value);
|
|
16137
|
+
}, [value]);
|
|
16130
16138
|
(0, import_react39.useEffect)(() => {
|
|
16131
16139
|
const loadFromLink = async () => {
|
|
16132
|
-
if (!initialFile) return;
|
|
16140
|
+
if (!initialFile || !initialFile.startsWith("http")) return;
|
|
16133
16141
|
if (typeof initialFile !== "string") {
|
|
16134
16142
|
setFileInfo(initialFile);
|
|
16135
16143
|
return;
|
|
@@ -16138,10 +16146,11 @@ var BinaryField = (props) => {
|
|
|
16138
16146
|
let type = "application/octet-stream";
|
|
16139
16147
|
let size4 = 0;
|
|
16140
16148
|
let name3 = formValues?.[filename ?? ""] || initialFile.split("/").pop() || "unknown_file";
|
|
16141
|
-
if (checkIsImageLink2(initialFile)) {
|
|
16149
|
+
if (checkIsImageLink2(initialFile) || onlyImage) {
|
|
16142
16150
|
type = "image/*";
|
|
16143
16151
|
} else {
|
|
16144
16152
|
const response = await fetch(initialFile);
|
|
16153
|
+
console.log("responsessss", response);
|
|
16145
16154
|
const responseBlob = await response.blob();
|
|
16146
16155
|
if (responseBlob) {
|
|
16147
16156
|
type = responseBlob?.type;
|
|
@@ -16164,6 +16173,11 @@ var BinaryField = (props) => {
|
|
|
16164
16173
|
const handleChange = (e3, onChange2) => {
|
|
16165
16174
|
const file = e3.target.files?.[0];
|
|
16166
16175
|
if (!file) return;
|
|
16176
|
+
if (onlyImage && !file.type.startsWith("image/")) {
|
|
16177
|
+
methods?.setError(t3("only_image_accept"));
|
|
16178
|
+
e3.target.value = "";
|
|
16179
|
+
return;
|
|
16180
|
+
}
|
|
16167
16181
|
const isImage = file.type.startsWith("image/");
|
|
16168
16182
|
const preview = isImage ? URL.createObjectURL(file) : null;
|
|
16169
16183
|
const normalized = {
|
|
@@ -16187,7 +16201,11 @@ var BinaryField = (props) => {
|
|
|
16187
16201
|
{
|
|
16188
16202
|
src: url,
|
|
16189
16203
|
alt: name3,
|
|
16190
|
-
className: `w-full h-full rounded-lg object-contain ${isEditTable ? "max-h-10 max-w-10" : "max-w-32 max-h-32"}
|
|
16204
|
+
className: `w-full h-full rounded-lg object-contain ${isEditTable ? "max-h-10 max-w-10" : "max-w-32 max-h-32"}`,
|
|
16205
|
+
style: {
|
|
16206
|
+
maxWidth: isEditTable ? "40px" : "128px",
|
|
16207
|
+
maxHeight: isEditTable ? "40px" : "128px"
|
|
16208
|
+
}
|
|
16191
16209
|
}
|
|
16192
16210
|
);
|
|
16193
16211
|
if (type?.startsWith("video/"))
|
|
@@ -16196,6 +16214,10 @@ var BinaryField = (props) => {
|
|
|
16196
16214
|
{
|
|
16197
16215
|
src: url,
|
|
16198
16216
|
className: `rounded-lg object-cover ${isEditTable ? "max-h-10 max-w-10" : "max-w-32 max-h-32"}`,
|
|
16217
|
+
style: {
|
|
16218
|
+
maxWidth: isEditTable ? "40px" : "128px",
|
|
16219
|
+
maxHeight: isEditTable ? "40px" : "128px"
|
|
16220
|
+
},
|
|
16199
16221
|
controls: true
|
|
16200
16222
|
}
|
|
16201
16223
|
);
|
|
@@ -16211,12 +16233,20 @@ var BinaryField = (props) => {
|
|
|
16211
16233
|
return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
16212
16234
|
getFileIcon(),
|
|
16213
16235
|
/* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { children: [
|
|
16214
|
-
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
16236
|
+
/* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
16237
|
+
"p",
|
|
16238
|
+
{
|
|
16239
|
+
style: {
|
|
16240
|
+
maxWidth: "120px"
|
|
16241
|
+
},
|
|
16242
|
+
className: "text-sm font-medium text-gray-600 truncate max-w-[120px]",
|
|
16243
|
+
children: name3
|
|
16244
|
+
}
|
|
16245
|
+
),
|
|
16215
16246
|
isShowSize && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "text-xs text-[#666] font-semibold", children: formatFileSize(size4) })
|
|
16216
16247
|
] })
|
|
16217
16248
|
] });
|
|
16218
16249
|
};
|
|
16219
|
-
const onlyImage = widget === "image" || widget === "image_url";
|
|
16220
16250
|
return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
16221
16251
|
Controller,
|
|
16222
16252
|
{
|
package/dist/widgets.mjs
CHANGED
|
@@ -7715,7 +7715,8 @@ var vi_default = {
|
|
|
7715
7715
|
upload_file_placeholder: "T\u1EA3i t\u1EC7p c\u1EE7a b\u1EA1n",
|
|
7716
7716
|
"no-available": "Kh\xF4ng c\xF3 l\u1EF1a ch\u1ECDn n\xE0o",
|
|
7717
7717
|
paid_amount: "S\u1ED1 ti\u1EC1n \u0111\xE3 \u0111\xF3ng",
|
|
7718
|
-
remanining_amount: "S\u1ED1 ti\u1EC1n c\xF2n l\u1EA1i"
|
|
7718
|
+
remanining_amount: "S\u1ED1 ti\u1EC1n c\xF2n l\u1EA1i",
|
|
7719
|
+
only_image_accept: "Ch\u1EC9 \u0111\u01B0\u1EE3c upload file h\xECnh \u1EA3nh"
|
|
7719
7720
|
};
|
|
7720
7721
|
|
|
7721
7722
|
// src/locales/en.json
|
|
@@ -7764,7 +7765,8 @@ var en_default = {
|
|
|
7764
7765
|
upload_file_placeholder: "Upload your file",
|
|
7765
7766
|
"no-available": "No options available",
|
|
7766
7767
|
paid_amount: "Amount Paid",
|
|
7767
|
-
remanining_amount: "Amount Remaining"
|
|
7768
|
+
remanining_amount: "Amount Remaining",
|
|
7769
|
+
only_image_accept: "Only accept image"
|
|
7768
7770
|
};
|
|
7769
7771
|
|
|
7770
7772
|
// src/utils/i18n.ts
|
|
@@ -16053,6 +16055,7 @@ var BinaryField = (props) => {
|
|
|
16053
16055
|
isEditTable,
|
|
16054
16056
|
widget,
|
|
16055
16057
|
string,
|
|
16058
|
+
value,
|
|
16056
16059
|
// from hook
|
|
16057
16060
|
placeHolderImage,
|
|
16058
16061
|
inputId,
|
|
@@ -16061,13 +16064,18 @@ var BinaryField = (props) => {
|
|
|
16061
16064
|
handleFileChange,
|
|
16062
16065
|
handleRemoveFile,
|
|
16063
16066
|
checkIsImageLink: checkIsImageLink2,
|
|
16064
|
-
onDownload
|
|
16067
|
+
onDownload,
|
|
16068
|
+
setInitialFile
|
|
16065
16069
|
} = props;
|
|
16066
16070
|
const { t: t3 } = useI18n();
|
|
16067
16071
|
const [fileInfo, setFileInfo] = useState11(null);
|
|
16072
|
+
const onlyImage = widget === "image" || widget === "image_url";
|
|
16073
|
+
useEffect11(() => {
|
|
16074
|
+
setInitialFile(value);
|
|
16075
|
+
}, [value]);
|
|
16068
16076
|
useEffect11(() => {
|
|
16069
16077
|
const loadFromLink = async () => {
|
|
16070
|
-
if (!initialFile) return;
|
|
16078
|
+
if (!initialFile || !initialFile.startsWith("http")) return;
|
|
16071
16079
|
if (typeof initialFile !== "string") {
|
|
16072
16080
|
setFileInfo(initialFile);
|
|
16073
16081
|
return;
|
|
@@ -16076,10 +16084,11 @@ var BinaryField = (props) => {
|
|
|
16076
16084
|
let type = "application/octet-stream";
|
|
16077
16085
|
let size4 = 0;
|
|
16078
16086
|
let name3 = formValues?.[filename ?? ""] || initialFile.split("/").pop() || "unknown_file";
|
|
16079
|
-
if (checkIsImageLink2(initialFile)) {
|
|
16087
|
+
if (checkIsImageLink2(initialFile) || onlyImage) {
|
|
16080
16088
|
type = "image/*";
|
|
16081
16089
|
} else {
|
|
16082
16090
|
const response = await fetch(initialFile);
|
|
16091
|
+
console.log("responsessss", response);
|
|
16083
16092
|
const responseBlob = await response.blob();
|
|
16084
16093
|
if (responseBlob) {
|
|
16085
16094
|
type = responseBlob?.type;
|
|
@@ -16102,6 +16111,11 @@ var BinaryField = (props) => {
|
|
|
16102
16111
|
const handleChange = (e3, onChange2) => {
|
|
16103
16112
|
const file = e3.target.files?.[0];
|
|
16104
16113
|
if (!file) return;
|
|
16114
|
+
if (onlyImage && !file.type.startsWith("image/")) {
|
|
16115
|
+
methods?.setError(t3("only_image_accept"));
|
|
16116
|
+
e3.target.value = "";
|
|
16117
|
+
return;
|
|
16118
|
+
}
|
|
16105
16119
|
const isImage = file.type.startsWith("image/");
|
|
16106
16120
|
const preview = isImage ? URL.createObjectURL(file) : null;
|
|
16107
16121
|
const normalized = {
|
|
@@ -16125,7 +16139,11 @@ var BinaryField = (props) => {
|
|
|
16125
16139
|
{
|
|
16126
16140
|
src: url,
|
|
16127
16141
|
alt: name3,
|
|
16128
|
-
className: `w-full h-full rounded-lg object-contain ${isEditTable ? "max-h-10 max-w-10" : "max-w-32 max-h-32"}
|
|
16142
|
+
className: `w-full h-full rounded-lg object-contain ${isEditTable ? "max-h-10 max-w-10" : "max-w-32 max-h-32"}`,
|
|
16143
|
+
style: {
|
|
16144
|
+
maxWidth: isEditTable ? "40px" : "128px",
|
|
16145
|
+
maxHeight: isEditTable ? "40px" : "128px"
|
|
16146
|
+
}
|
|
16129
16147
|
}
|
|
16130
16148
|
);
|
|
16131
16149
|
if (type?.startsWith("video/"))
|
|
@@ -16134,6 +16152,10 @@ var BinaryField = (props) => {
|
|
|
16134
16152
|
{
|
|
16135
16153
|
src: url,
|
|
16136
16154
|
className: `rounded-lg object-cover ${isEditTable ? "max-h-10 max-w-10" : "max-w-32 max-h-32"}`,
|
|
16155
|
+
style: {
|
|
16156
|
+
maxWidth: isEditTable ? "40px" : "128px",
|
|
16157
|
+
maxHeight: isEditTable ? "40px" : "128px"
|
|
16158
|
+
},
|
|
16137
16159
|
controls: true
|
|
16138
16160
|
}
|
|
16139
16161
|
);
|
|
@@ -16149,12 +16171,20 @@ var BinaryField = (props) => {
|
|
|
16149
16171
|
return /* @__PURE__ */ jsxs49("div", { className: "flex items-center gap-2", children: [
|
|
16150
16172
|
getFileIcon(),
|
|
16151
16173
|
/* @__PURE__ */ jsxs49("div", { children: [
|
|
16152
|
-
/* @__PURE__ */ jsx74(
|
|
16174
|
+
/* @__PURE__ */ jsx74(
|
|
16175
|
+
"p",
|
|
16176
|
+
{
|
|
16177
|
+
style: {
|
|
16178
|
+
maxWidth: "120px"
|
|
16179
|
+
},
|
|
16180
|
+
className: "text-sm font-medium text-gray-600 truncate max-w-[120px]",
|
|
16181
|
+
children: name3
|
|
16182
|
+
}
|
|
16183
|
+
),
|
|
16153
16184
|
isShowSize && /* @__PURE__ */ jsx74("span", { className: "text-xs text-[#666] font-semibold", children: formatFileSize(size4) })
|
|
16154
16185
|
] })
|
|
16155
16186
|
] });
|
|
16156
16187
|
};
|
|
16157
|
-
const onlyImage = widget === "image" || widget === "image_url";
|
|
16158
16188
|
return /* @__PURE__ */ jsx74(
|
|
16159
16189
|
Controller,
|
|
16160
16190
|
{
|