@fctc/sme-widget-ui 2.9.6 → 2.9.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 +201 -220
- package/dist/index.mjs +262 -281
- package/dist/utils.js +4 -2
- package/dist/utils.mjs +4 -2
- package/dist/widgets.d.mts +9 -8
- package/dist/widgets.d.ts +9 -8
- package/dist/widgets.js +201 -241
- package/dist/widgets.mjs +262 -302
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9995,7 +9995,8 @@ var vi_default = {
|
|
|
9995
9995
|
"message-text-error": " kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 {{max}} k\xFD t\u1EF1",
|
|
9996
9996
|
upcase: ", {{count}} ch\u1EEF in hoa",
|
|
9997
9997
|
digit: ", {{count}} s\u1ED1",
|
|
9998
|
-
special: ", {{count}} k\xFD t\u1EF1 \u0111\u1EB7c bi\u1EC7t"
|
|
9998
|
+
special: ", {{count}} k\xFD t\u1EF1 \u0111\u1EB7c bi\u1EC7t",
|
|
9999
|
+
upload_files_accept: "Ch\u1EC9 ch\u1EA5p nh\u1EADn c\xE1c \u0111\u1ECBnh d\u1EA1ng JPEG, PNG, PDF, MP4, XLS, XLXS, ZIP"
|
|
9999
10000
|
};
|
|
10000
10001
|
|
|
10001
10002
|
// src/locales/en.json
|
|
@@ -10054,7 +10055,8 @@ var en_default = {
|
|
|
10054
10055
|
"message-text-error": " must not exceed {{max}} characters",
|
|
10055
10056
|
upcase: ", {{count}} uppercase letter",
|
|
10056
10057
|
digit: ", {{count}} digit",
|
|
10057
|
-
special: ", {{count}} special character"
|
|
10058
|
+
special: ", {{count}} special character",
|
|
10059
|
+
upload_files_accept: "Only JPEG, PNG, PDF, MP4, XLS, XLXS, ZIP, JSON formats are allowed"
|
|
10058
10060
|
};
|
|
10059
10061
|
|
|
10060
10062
|
// src/utils/i18n.ts
|
|
@@ -16664,7 +16666,7 @@ var ButtonSelectFiles = ({
|
|
|
16664
16666
|
isText
|
|
16665
16667
|
}) => {
|
|
16666
16668
|
const { t: t3 } = useI18n();
|
|
16667
|
-
const
|
|
16669
|
+
const ALLOWED_TYPES2 = [
|
|
16668
16670
|
"image/jpeg",
|
|
16669
16671
|
"image/png",
|
|
16670
16672
|
"application/pdf",
|
|
@@ -16681,7 +16683,7 @@ var ButtonSelectFiles = ({
|
|
|
16681
16683
|
const { mutate, isPending } = isBinary ? useUploadFile() : useUploadImage();
|
|
16682
16684
|
const dataUser = user?.userProfile?.data;
|
|
16683
16685
|
const validateFile = (file) => {
|
|
16684
|
-
if (!
|
|
16686
|
+
if (!ALLOWED_TYPES2.includes(file.type)) {
|
|
16685
16687
|
setUploadError(t3("file_accept_single"));
|
|
16686
16688
|
return false;
|
|
16687
16689
|
}
|
|
@@ -16896,123 +16898,115 @@ var AvatarField = (props) => {
|
|
|
16896
16898
|
// src/widgets/basic/binary-field/binary.tsx
|
|
16897
16899
|
var import_react39 = require("react");
|
|
16898
16900
|
var import_jsx_runtime75 = require("react/jsx-runtime");
|
|
16901
|
+
var ALLOWED_TYPES = [
|
|
16902
|
+
"image/jpeg",
|
|
16903
|
+
"image/png",
|
|
16904
|
+
"application/pdf",
|
|
16905
|
+
"video/mp4",
|
|
16906
|
+
"application/zip",
|
|
16907
|
+
"application/x-zip-compressed",
|
|
16908
|
+
"application/vnd.ms-excel",
|
|
16909
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
16910
|
+
"application/json"
|
|
16911
|
+
];
|
|
16899
16912
|
var BinaryField = (props) => {
|
|
16900
16913
|
const {
|
|
16914
|
+
value,
|
|
16901
16915
|
name,
|
|
16902
|
-
methods,
|
|
16903
|
-
readonly = false,
|
|
16904
|
-
placeholder,
|
|
16905
|
-
required = false,
|
|
16906
|
-
invisible = false,
|
|
16907
|
-
filename,
|
|
16908
|
-
formValues,
|
|
16909
16916
|
isEditTable,
|
|
16910
16917
|
widget,
|
|
16911
|
-
|
|
16912
|
-
value,
|
|
16913
|
-
// from hook
|
|
16918
|
+
readonly,
|
|
16914
16919
|
placeHolderImage,
|
|
16915
|
-
|
|
16916
|
-
|
|
16917
|
-
|
|
16918
|
-
|
|
16919
|
-
|
|
16920
|
-
|
|
16920
|
+
placeholder,
|
|
16921
|
+
required,
|
|
16922
|
+
invisible,
|
|
16923
|
+
methods,
|
|
16924
|
+
string,
|
|
16925
|
+
isForm,
|
|
16921
16926
|
onDownload,
|
|
16922
|
-
|
|
16927
|
+
onUploadFile,
|
|
16928
|
+
onDeleteFile,
|
|
16929
|
+
url,
|
|
16930
|
+
fileInfor
|
|
16923
16931
|
} = props;
|
|
16924
16932
|
const { t: t3 } = useI18n();
|
|
16925
|
-
const [
|
|
16933
|
+
const [loading, setLoading] = (0, import_react39.useState)(false);
|
|
16934
|
+
const hasFetchedMeta = (0, import_react39.useRef)(false);
|
|
16926
16935
|
const onlyImage = widget === "image" || widget === "image_url";
|
|
16927
|
-
|
|
16928
|
-
|
|
16929
|
-
|
|
16930
|
-
|
|
16931
|
-
|
|
16932
|
-
|
|
16933
|
-
|
|
16934
|
-
|
|
16935
|
-
|
|
16936
|
-
}
|
|
16937
|
-
try {
|
|
16938
|
-
let type = "application/octet-stream";
|
|
16939
|
-
let size4 = 0;
|
|
16940
|
-
let name2 = formValues?.[filename ?? ""] || initialFile.split("/").pop() || "unknown_file";
|
|
16941
|
-
if (checkIsImageLink2(initialFile) || onlyImage) {
|
|
16942
|
-
type = "image/*";
|
|
16943
|
-
} else {
|
|
16944
|
-
const response = await fetch(initialFile);
|
|
16945
|
-
console.log("responsessss", response);
|
|
16946
|
-
const responseBlob = await response.blob();
|
|
16947
|
-
if (responseBlob) {
|
|
16948
|
-
type = responseBlob?.type;
|
|
16949
|
-
size4 = responseBlob.size;
|
|
16950
|
-
}
|
|
16951
|
-
}
|
|
16952
|
-
setFileInfo({
|
|
16953
|
-
name: name2,
|
|
16954
|
-
type,
|
|
16955
|
-
url: initialFile,
|
|
16956
|
-
size: size4,
|
|
16957
|
-
source: "link"
|
|
16958
|
-
});
|
|
16959
|
-
} catch (error2) {
|
|
16960
|
-
console.warn("Cannot load link info:", error2);
|
|
16961
|
-
}
|
|
16962
|
-
};
|
|
16963
|
-
loadFromLink();
|
|
16964
|
-
}, [initialFile]);
|
|
16965
|
-
const handleChange = (e3, onChange2) => {
|
|
16966
|
-
const file = e3.target.files?.[0];
|
|
16936
|
+
const acceptType = !onlyImage ? `.pdf,.json,.mp4,.zip,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,.jpeg,.jpg,.png` : ".jpeg,.jpg,.png";
|
|
16937
|
+
const validateFile = (file) => {
|
|
16938
|
+
if (!ALLOWED_TYPES.includes(file.type)) {
|
|
16939
|
+
return t3("upload_files_accept");
|
|
16940
|
+
}
|
|
16941
|
+
return true;
|
|
16942
|
+
};
|
|
16943
|
+
const handleUpload = async (e3) => {
|
|
16944
|
+
const file = e3.target.files[0];
|
|
16967
16945
|
if (!file) return;
|
|
16968
16946
|
if (onlyImage && !file.type.startsWith("image/")) {
|
|
16969
|
-
methods?.setError(
|
|
16947
|
+
methods?.setError(name, {
|
|
16948
|
+
type: "manual",
|
|
16949
|
+
message: t3("only_image_accept")
|
|
16950
|
+
});
|
|
16970
16951
|
e3.target.value = "";
|
|
16971
16952
|
return;
|
|
16972
16953
|
}
|
|
16973
|
-
const
|
|
16974
|
-
|
|
16975
|
-
|
|
16976
|
-
|
|
16977
|
-
|
|
16978
|
-
|
|
16979
|
-
|
|
16980
|
-
|
|
16981
|
-
|
|
16982
|
-
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
|
|
16954
|
+
const valid = validateFile(file);
|
|
16955
|
+
if (valid !== true) {
|
|
16956
|
+
methods?.setError(name, { type: "manual", message: valid });
|
|
16957
|
+
return;
|
|
16958
|
+
}
|
|
16959
|
+
methods?.clearErrors(name);
|
|
16960
|
+
const formData = new FormData();
|
|
16961
|
+
formData.append("file", file);
|
|
16962
|
+
setLoading(true);
|
|
16963
|
+
try {
|
|
16964
|
+
onUploadFile?.(formData);
|
|
16965
|
+
} catch (error2) {
|
|
16966
|
+
console.error(error2);
|
|
16967
|
+
}
|
|
16968
|
+
setLoading(false);
|
|
16986
16969
|
};
|
|
16987
|
-
const
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
16991
|
-
|
|
16992
|
-
|
|
16993
|
-
|
|
16994
|
-
|
|
16995
|
-
|
|
16996
|
-
|
|
16997
|
-
|
|
16998
|
-
|
|
16999
|
-
|
|
16970
|
+
const handleDelete = () => {
|
|
16971
|
+
onDeleteFile && onDeleteFile();
|
|
16972
|
+
hasFetchedMeta.current = false;
|
|
16973
|
+
};
|
|
16974
|
+
const renderPreview = () => {
|
|
16975
|
+
if (!url) return null;
|
|
16976
|
+
const type = fileInfor?.type;
|
|
16977
|
+
const date = fileInfor?.date;
|
|
16978
|
+
const size4 = fileInfor?.size;
|
|
16979
|
+
if (type?.includes("image")) {
|
|
16980
|
+
return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "flex gap-2 items-center", children: [
|
|
16981
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
16982
|
+
"img",
|
|
16983
|
+
{
|
|
16984
|
+
src: url,
|
|
16985
|
+
alt: name,
|
|
16986
|
+
className: `image-value w-full h-full object-contain ${onlyImage ? "rounded-lg" : "rounded-[4px]"} ${isEditTable ? "max-h-10 max-w-10 h-10 w-10" : "max-w-32 max-h-32"}`,
|
|
16987
|
+
style: {
|
|
16988
|
+
maxWidth: isEditTable ? "40px" : "128px",
|
|
16989
|
+
maxHeight: isEditTable ? "40px" : "128px",
|
|
16990
|
+
height: isEditTable ? "40px" : "128px",
|
|
16991
|
+
width: isEditTable ? "40px" : "128px"
|
|
16992
|
+
}
|
|
17000
16993
|
}
|
|
17001
|
-
|
|
17002
|
-
|
|
17003
|
-
|
|
17004
|
-
|
|
17005
|
-
|
|
17006
|
-
|
|
17007
|
-
|
|
17008
|
-
|
|
17009
|
-
|
|
17010
|
-
|
|
17011
|
-
|
|
17012
|
-
|
|
17013
|
-
|
|
17014
|
-
}
|
|
17015
|
-
);
|
|
16994
|
+
),
|
|
16995
|
+
!onlyImage && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { children: [
|
|
16996
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
16997
|
+
"p",
|
|
16998
|
+
{
|
|
16999
|
+
style: {
|
|
17000
|
+
maxWidth: "120px"
|
|
17001
|
+
},
|
|
17002
|
+
className: "text-sm font-medium text-gray-600 truncate max-w-[120px]",
|
|
17003
|
+
children: url?.split("/").pop()
|
|
17004
|
+
}
|
|
17005
|
+
),
|
|
17006
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "text-xs text-[#666] font-semibold", children: size4 })
|
|
17007
|
+
] })
|
|
17008
|
+
] });
|
|
17009
|
+
}
|
|
17016
17010
|
const getFileIcon = () => {
|
|
17017
17011
|
if (type === "application/pdf") return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(PdfIcon, {});
|
|
17018
17012
|
if (type?.includes("excel") || type?.includes("spreadsheet"))
|
|
@@ -17021,7 +17015,6 @@ var BinaryField = (props) => {
|
|
|
17021
17015
|
if (type === "application/json") return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(JSONFileIcon, {});
|
|
17022
17016
|
return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DefaultFileIcon, {});
|
|
17023
17017
|
};
|
|
17024
|
-
const isShowSize = !isNaN(size4);
|
|
17025
17018
|
return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
17026
17019
|
getFileIcon(),
|
|
17027
17020
|
/* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { children: [
|
|
@@ -17032,10 +17025,10 @@ var BinaryField = (props) => {
|
|
|
17032
17025
|
maxWidth: "120px"
|
|
17033
17026
|
},
|
|
17034
17027
|
className: "text-sm font-medium text-gray-600 truncate max-w-[120px]",
|
|
17035
|
-
children:
|
|
17028
|
+
children: url?.split("/").pop()
|
|
17036
17029
|
}
|
|
17037
17030
|
),
|
|
17038
|
-
|
|
17031
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "text-xs text-[#666] font-semibold", children: size4 })
|
|
17039
17032
|
] })
|
|
17040
17033
|
] });
|
|
17041
17034
|
};
|
|
@@ -17045,136 +17038,124 @@ var BinaryField = (props) => {
|
|
|
17045
17038
|
name: name ?? "",
|
|
17046
17039
|
control: methods?.control,
|
|
17047
17040
|
rules: {
|
|
17048
|
-
required: required && !invisible ? { value: true, message: `${string} ${t3("must_required")}` } : false
|
|
17041
|
+
required: required && !invisible ? { value: true, message: `${string} ${t3("must_required")}` } : false,
|
|
17042
|
+
validate: {
|
|
17043
|
+
fileValidate: (value2) => {
|
|
17044
|
+
if (!value2) return true;
|
|
17045
|
+
return validateFile(value2);
|
|
17046
|
+
}
|
|
17047
|
+
}
|
|
17049
17048
|
},
|
|
17050
|
-
render: ({
|
|
17051
|
-
|
|
17049
|
+
render: ({ fieldState: { error: error2 } }) => {
|
|
17050
|
+
console.log("error", error2);
|
|
17052
17051
|
return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, { children: [
|
|
17053
17052
|
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
17054
17053
|
"div",
|
|
17055
17054
|
{
|
|
17056
|
-
|
|
17057
|
-
|
|
17058
|
-
children: hasFile ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
17055
|
+
className: `widget binary-field flex w-fit items-center gap-4 ${onlyImage ? "shadow-md rounded-[12px]" : ""} ${isEditTable ? "p-2" : ""}`,
|
|
17056
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "relative group", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
|
|
17059
17057
|
"div",
|
|
17060
17058
|
{
|
|
17061
|
-
className: `relative
|
|
17062
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
|
|
17063
|
-
"div",
|
|
17064
|
-
{
|
|
17065
|
-
className: `flex gap-2 items-center bg-[#FAFAFA] rounded-[8px] p-[6px] ${onlyImage ? "h-32 w-32" : "max-h-fit max-w-fit"}`,
|
|
17066
|
-
children: [
|
|
17067
|
-
renderPreview(fileInfo),
|
|
17068
|
-
/* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
|
|
17069
|
-
"div",
|
|
17070
|
-
{
|
|
17071
|
-
style: {
|
|
17072
|
-
display: "flex",
|
|
17073
|
-
alignItems: "center",
|
|
17074
|
-
borderRadius: "8px",
|
|
17075
|
-
padding: "4px",
|
|
17076
|
-
gap: "8px",
|
|
17077
|
-
backgroundColor: onlyImage ? "rgba(0,0,0,0.03)" : "white",
|
|
17078
|
-
boxShadow: "0 2px 4px 0 rgba(27, 28, 29, 0.04)",
|
|
17079
|
-
position: onlyImage ? "absolute" : "relative",
|
|
17080
|
-
bottom: onlyImage ? "0" : "none",
|
|
17081
|
-
right: onlyImage ? "0" : "none"
|
|
17082
|
-
},
|
|
17083
|
-
children: [
|
|
17084
|
-
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
17085
|
-
"span",
|
|
17086
|
-
{
|
|
17087
|
-
className: "cursor-pointer",
|
|
17088
|
-
onClick: () => onDownload && onDownload(
|
|
17089
|
-
fileInfo?.url || fileInfo?.data,
|
|
17090
|
-
fileInfo?.name || fileInfo?.display_name
|
|
17091
|
-
),
|
|
17092
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DownloadIcon, {})
|
|
17093
|
-
}
|
|
17094
|
-
),
|
|
17095
|
-
!readonly && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
17096
|
-
"span",
|
|
17097
|
-
{
|
|
17098
|
-
className: "cursor-pointer",
|
|
17099
|
-
onClick: () => {
|
|
17100
|
-
setFileInfo(null);
|
|
17101
|
-
handleRemoveFile(field.onChange);
|
|
17102
|
-
},
|
|
17103
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DeleteIconDanger, {})
|
|
17104
|
-
}
|
|
17105
|
-
)
|
|
17106
|
-
]
|
|
17107
|
-
}
|
|
17108
|
-
)
|
|
17109
|
-
]
|
|
17110
|
-
}
|
|
17111
|
-
)
|
|
17112
|
-
}
|
|
17113
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
|
|
17114
|
-
"label",
|
|
17115
|
-
{
|
|
17116
|
-
htmlFor: inputId,
|
|
17117
|
-
className: `relative p-2 flex cursor-pointer items-center justify-center rounded-[12px] transition-colors duration-300 ${readonly && "pointer-events-none"} ${onlyImage ? "h-32 w-32 border border-gray-300 hover:border-primary bg-white" : "w-fit h-fit "}`,
|
|
17059
|
+
className: `flex items-center gap-2 bg-[#FAFAFA] relative ${onlyImage ? `h-32 w-32 rounded-[12px] ${value ? "" : "p-2"}` : `max-h-fit max-w-fit rounded-[8px] border ${!value ? "hover:border-[var(--color-primary)]" : ""} ${isEditTable && value ? "p-2" : ""}`} ${error2 && isForm && isEditTable && "widget-error"} `,
|
|
17118
17060
|
children: [
|
|
17119
|
-
|
|
17120
|
-
|
|
17121
|
-
{
|
|
17122
|
-
id: inputId,
|
|
17123
|
-
type: "file",
|
|
17124
|
-
readOnly: readonly,
|
|
17125
|
-
placeholder,
|
|
17126
|
-
required: !invisible && required,
|
|
17127
|
-
onChange: (e3) => handleChange(e3, field.onChange),
|
|
17128
|
-
className: "hidden",
|
|
17129
|
-
accept: ".jpeg,.jpg,.png,.pdf,.json,.mp4,.zip,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
|
|
17130
|
-
}
|
|
17131
|
-
),
|
|
17132
|
-
onlyImage && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
17133
|
-
"img",
|
|
17134
|
-
{
|
|
17135
|
-
src: placeHolderImage,
|
|
17136
|
-
alt: "",
|
|
17137
|
-
className: "z-0 relative"
|
|
17138
|
-
}
|
|
17139
|
-
),
|
|
17140
|
-
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
17061
|
+
renderPreview(),
|
|
17062
|
+
value ? /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
|
|
17141
17063
|
"div",
|
|
17142
17064
|
{
|
|
17143
|
-
className: "
|
|
17065
|
+
className: "widget",
|
|
17144
17066
|
style: {
|
|
17067
|
+
display: "flex",
|
|
17068
|
+
alignItems: "center",
|
|
17069
|
+
borderRadius: "8px",
|
|
17070
|
+
padding: "4px",
|
|
17071
|
+
gap: "8px",
|
|
17072
|
+
backgroundColor: onlyImage ? "rgba(0,0,0,0.03)" : "white",
|
|
17073
|
+
boxShadow: "0 2px 4px 0 rgba(27, 28, 29, 0.04)",
|
|
17145
17074
|
position: onlyImage ? "absolute" : "relative",
|
|
17146
|
-
bottom: onlyImage ? "
|
|
17147
|
-
|
|
17148
|
-
boxShadow: "0 1px 2px 0 rgba(228, 229, 231, 0.24)",
|
|
17149
|
-
width: "2rem",
|
|
17150
|
-
height: "2rem",
|
|
17151
|
-
border: onlyImage ? "1px solid transparent" : "1px solid var(--color-primary)",
|
|
17152
|
-
borderRadius: onlyImage ? "100%" : "8px"
|
|
17075
|
+
bottom: onlyImage ? "0" : "none",
|
|
17076
|
+
right: onlyImage ? "0" : "none"
|
|
17153
17077
|
},
|
|
17154
|
-
children:
|
|
17155
|
-
|
|
17156
|
-
|
|
17157
|
-
|
|
17158
|
-
|
|
17159
|
-
|
|
17160
|
-
|
|
17161
|
-
|
|
17162
|
-
|
|
17163
|
-
|
|
17164
|
-
|
|
17165
|
-
|
|
17166
|
-
|
|
17167
|
-
|
|
17168
|
-
|
|
17169
|
-
|
|
17170
|
-
|
|
17171
|
-
|
|
17172
|
-
|
|
17078
|
+
children: [
|
|
17079
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
17080
|
+
"span",
|
|
17081
|
+
{
|
|
17082
|
+
onClick: () => onDownload && onDownload(url || "", url?.split("/").pop()),
|
|
17083
|
+
className: "cursor-pointer",
|
|
17084
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DownloadIcon, {})
|
|
17085
|
+
}
|
|
17086
|
+
),
|
|
17087
|
+
!readonly && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { onClick: handleDelete, className: "cursor-pointer", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DeleteIconDanger, {}) })
|
|
17088
|
+
]
|
|
17089
|
+
}
|
|
17090
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
|
|
17091
|
+
"label",
|
|
17092
|
+
{
|
|
17093
|
+
style: {
|
|
17094
|
+
maxWidth: "180px",
|
|
17095
|
+
maxHeight: "180px"
|
|
17096
|
+
},
|
|
17097
|
+
className: `relative flex cursor-pointer items-center justify-center rounded-[12px] transition-colors duration-300 ${readonly && "pointer-events-none"} ${onlyImage ? "border border-gray-300 hover:border-primary bg-white" : "w-fit h-fit "}`,
|
|
17098
|
+
children: [
|
|
17099
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
17100
|
+
"input",
|
|
17101
|
+
{
|
|
17102
|
+
type: "file",
|
|
17103
|
+
readOnly: readonly,
|
|
17104
|
+
placeholder,
|
|
17105
|
+
required: !invisible && required,
|
|
17106
|
+
onChange: handleUpload,
|
|
17107
|
+
className: "hidden",
|
|
17108
|
+
accept: acceptType
|
|
17109
|
+
}
|
|
17110
|
+
),
|
|
17111
|
+
onlyImage && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
17112
|
+
"img",
|
|
17113
|
+
{
|
|
17114
|
+
src: placeHolderImage,
|
|
17115
|
+
alt: "",
|
|
17116
|
+
className: "z-0 relative"
|
|
17117
|
+
}
|
|
17118
|
+
),
|
|
17119
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
17120
|
+
"div",
|
|
17121
|
+
{
|
|
17122
|
+
className: " size-8 bg-white rounded-lg flex justify-center items-center z-20",
|
|
17123
|
+
style: {
|
|
17124
|
+
position: onlyImage ? "absolute" : "relative",
|
|
17125
|
+
bottom: onlyImage ? "-8px" : "auto",
|
|
17126
|
+
left: onlyImage ? "-8px" : "auto",
|
|
17127
|
+
boxShadow: "0 1px 2px 0 rgba(228, 229, 231, 0.24)",
|
|
17128
|
+
width: "2rem",
|
|
17129
|
+
height: "2rem",
|
|
17130
|
+
borderRadius: onlyImage ? "100%" : "8px"
|
|
17131
|
+
},
|
|
17132
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
17133
|
+
"svg",
|
|
17134
|
+
{
|
|
17135
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
17136
|
+
width: "14",
|
|
17137
|
+
height: "14",
|
|
17138
|
+
viewBox: "0 0 14 14",
|
|
17139
|
+
fill: "none",
|
|
17140
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
17141
|
+
"path",
|
|
17142
|
+
{
|
|
17143
|
+
"fill-rule": "evenodd",
|
|
17144
|
+
"clip-rule": "evenodd",
|
|
17145
|
+
d: "M13.1868 0.813097C12.7961 0.422532 12.2663 0.203125 11.7139 0.203125C11.1615 0.203125 10.6317 0.422532 10.241 0.813097L9.35765 1.69726L12.3035 4.64393L12.0085 4.9381L11.7143 5.2331L8.76765 2.28643L1.40182 9.65226C1.34395 9.7104 1.30452 9.78432 1.28848 9.86476L0.698483 12.8114C0.685057 12.8787 0.688459 12.9483 0.708387 13.014C0.728316 13.0796 0.764154 13.1394 0.812719 13.1878C0.861283 13.2363 0.92107 13.2721 0.986769 13.2919C1.05247 13.3117 1.12204 13.315 1.18932 13.3014L4.13515 12.7123C4.21599 12.6961 4.29023 12.6564 4.34848 12.5981L13.1868 3.75976C13.3803 3.5663 13.5338 3.33661 13.6386 3.08381C13.7433 2.83102 13.7972 2.56006 13.7972 2.28643C13.7972 2.0128 13.7433 1.74184 13.6386 1.48905C13.5338 1.23625 13.3803 1.00656 13.1868 0.813097Z",
|
|
17146
|
+
fill: "black"
|
|
17147
|
+
}
|
|
17148
|
+
)
|
|
17149
|
+
}
|
|
17150
|
+
)
|
|
17151
|
+
}
|
|
17152
|
+
)
|
|
17153
|
+
]
|
|
17173
17154
|
}
|
|
17174
17155
|
)
|
|
17175
17156
|
]
|
|
17176
17157
|
}
|
|
17177
|
-
)
|
|
17158
|
+
) })
|
|
17178
17159
|
}
|
|
17179
17160
|
),
|
|
17180
17161
|
error2 && !isEditTable && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("p", { className: "text-[#de4747] text-sm mt-1", children: error2.message })
|