@fctc/sme-widget-ui 2.9.6 → 2.9.8

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.js CHANGED
@@ -6864,7 +6864,8 @@ var vi_default = {
6864
6864
  "message-text-error": " kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 {{max}} k\xFD t\u1EF1",
6865
6865
  upcase: ", {{count}} ch\u1EEF in hoa",
6866
6866
  digit: ", {{count}} s\u1ED1",
6867
- special: ", {{count}} k\xFD t\u1EF1 \u0111\u1EB7c bi\u1EC7t"
6867
+ special: ", {{count}} k\xFD t\u1EF1 \u0111\u1EB7c bi\u1EC7t",
6868
+ upload_files_accept: "Ch\u1EC9 ch\u1EA5p nh\u1EADn c\xE1c \u0111\u1ECBnh d\u1EA1ng JPEG, PNG, PDF, MP4, XLS, XLXS, ZIP"
6868
6869
  };
6869
6870
 
6870
6871
  // src/locales/en.json
@@ -6923,7 +6924,8 @@ var en_default = {
6923
6924
  "message-text-error": " must not exceed {{max}} characters",
6924
6925
  upcase: ", {{count}} uppercase letter",
6925
6926
  digit: ", {{count}} digit",
6926
- special: ", {{count}} special character"
6927
+ special: ", {{count}} special character",
6928
+ upload_files_accept: "Only JPEG, PNG, PDF, MP4, XLS, XLXS, ZIP, JSON formats are allowed"
6927
6929
  };
6928
6930
 
6929
6931
  // src/utils/i18n.ts
package/dist/utils.mjs CHANGED
@@ -6841,7 +6841,8 @@ var vi_default = {
6841
6841
  "message-text-error": " kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 {{max}} k\xFD t\u1EF1",
6842
6842
  upcase: ", {{count}} ch\u1EEF in hoa",
6843
6843
  digit: ", {{count}} s\u1ED1",
6844
- special: ", {{count}} k\xFD t\u1EF1 \u0111\u1EB7c bi\u1EC7t"
6844
+ special: ", {{count}} k\xFD t\u1EF1 \u0111\u1EB7c bi\u1EC7t",
6845
+ upload_files_accept: "Ch\u1EC9 ch\u1EA5p nh\u1EADn c\xE1c \u0111\u1ECBnh d\u1EA1ng JPEG, PNG, PDF, MP4, XLS, XLXS, ZIP"
6845
6846
  };
6846
6847
 
6847
6848
  // src/locales/en.json
@@ -6900,7 +6901,8 @@ var en_default = {
6900
6901
  "message-text-error": " must not exceed {{max}} characters",
6901
6902
  upcase: ", {{count}} uppercase letter",
6902
6903
  digit: ", {{count}} digit",
6903
- special: ", {{count}} special character"
6904
+ special: ", {{count}} special character",
6905
+ upload_files_accept: "Only JPEG, PNG, PDF, MP4, XLS, XLXS, ZIP, JSON formats are allowed"
6904
6906
  };
6905
6907
 
6906
6908
  // src/utils/i18n.ts
@@ -162,14 +162,15 @@ declare const AvatarField: (props: IAvatarProps) => JSX.Element;
162
162
 
163
163
  interface IBinaryFieldProps extends IInputFieldProps {
164
164
  placeHolderImage?: any;
165
- inputId?: any;
166
- initialFile?: any;
167
- binaryRef?: any;
168
- handleFileChange?: any;
169
- handleRemoveFile?: any;
170
- checkIsImageLink?: any;
171
- onDownload?: any;
172
- setInitialFile?: any;
165
+ onUploadFile: (formData: FormData) => string;
166
+ onDownload?: (url: string, filename?: string) => void;
167
+ onDeleteFile?: () => void;
168
+ url?: string;
169
+ fileInfor?: {
170
+ type?: string;
171
+ date?: string;
172
+ size?: string;
173
+ };
173
174
  }
174
175
 
175
176
  declare const BinaryField: (props: IBinaryFieldProps) => JSX.Element;
package/dist/widgets.d.ts CHANGED
@@ -162,14 +162,15 @@ declare const AvatarField: (props: IAvatarProps) => JSX.Element;
162
162
 
163
163
  interface IBinaryFieldProps extends IInputFieldProps {
164
164
  placeHolderImage?: any;
165
- inputId?: any;
166
- initialFile?: any;
167
- binaryRef?: any;
168
- handleFileChange?: any;
169
- handleRemoveFile?: any;
170
- checkIsImageLink?: any;
171
- onDownload?: any;
172
- setInitialFile?: any;
165
+ onUploadFile: (formData: FormData) => string;
166
+ onDownload?: (url: string, filename?: string) => void;
167
+ onDeleteFile?: () => void;
168
+ url?: string;
169
+ fileInfor?: {
170
+ type?: string;
171
+ date?: string;
172
+ size?: string;
173
+ };
173
174
  }
174
175
 
175
176
  declare const BinaryField: (props: IBinaryFieldProps) => JSX.Element;
package/dist/widgets.js CHANGED
@@ -7788,7 +7788,8 @@ var vi_default = {
7788
7788
  "message-text-error": " kh\xF4ng \u0111\u01B0\u1EE3c v\u01B0\u1EE3t qu\xE1 {{max}} k\xFD t\u1EF1",
7789
7789
  upcase: ", {{count}} ch\u1EEF in hoa",
7790
7790
  digit: ", {{count}} s\u1ED1",
7791
- special: ", {{count}} k\xFD t\u1EF1 \u0111\u1EB7c bi\u1EC7t"
7791
+ special: ", {{count}} k\xFD t\u1EF1 \u0111\u1EB7c bi\u1EC7t",
7792
+ upload_files_accept: "Ch\u1EC9 ch\u1EA5p nh\u1EADn c\xE1c \u0111\u1ECBnh d\u1EA1ng JPEG, PNG, PDF, MP4, XLS, XLXS, ZIP"
7792
7793
  };
7793
7794
 
7794
7795
  // src/locales/en.json
@@ -7847,7 +7848,8 @@ var en_default = {
7847
7848
  "message-text-error": " must not exceed {{max}} characters",
7848
7849
  upcase: ", {{count}} uppercase letter",
7849
7850
  digit: ", {{count}} digit",
7850
- special: ", {{count}} special character"
7851
+ special: ", {{count}} special character",
7852
+ upload_files_accept: "Only JPEG, PNG, PDF, MP4, XLS, XLXS, ZIP, JSON formats are allowed"
7851
7853
  };
7852
7854
 
7853
7855
  // src/utils/i18n.ts
@@ -9527,27 +9529,6 @@ var PaidIcon = () => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
9527
9529
 
9528
9530
  // src/icons/placeholder-icon.tsx
9529
9531
  var import_jsx_runtime37 = require("react/jsx-runtime");
9530
- var PlaceHolderIcon = () => {
9531
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
9532
- "svg",
9533
- {
9534
- xmlns: "http://www.w3.org/2000/svg",
9535
- version: "1.0",
9536
- width: "256.000000pt",
9537
- height: "256.000000pt",
9538
- viewBox: "0 0 256.000000 256.000000",
9539
- preserveAspectRatio: "xMidYMid meet",
9540
- children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
9541
- "g",
9542
- {
9543
- transform: "translate(0.000000,256.000000) scale(0.100000,-0.100000)",
9544
- fill: "#000000",
9545
- stroke: "none"
9546
- }
9547
- )
9548
- }
9549
- );
9550
- };
9551
9532
 
9552
9533
  // src/icons/google-icon.tsx
9553
9534
  var import_jsx_runtime38 = require("react/jsx-runtime");
@@ -15913,7 +15894,7 @@ var ButtonSelectFiles = ({
15913
15894
  isText
15914
15895
  }) => {
15915
15896
  const { t: t3 } = useI18n();
15916
- const ALLOWED_TYPES = [
15897
+ const ALLOWED_TYPES2 = [
15917
15898
  "image/jpeg",
15918
15899
  "image/png",
15919
15900
  "application/pdf",
@@ -15930,7 +15911,7 @@ var ButtonSelectFiles = ({
15930
15911
  const { mutate, isPending } = isBinary ? useUploadFile() : useUploadImage();
15931
15912
  const dataUser = user?.userProfile?.data;
15932
15913
  const validateFile = (file) => {
15933
- if (!ALLOWED_TYPES.includes(file.type)) {
15914
+ if (!ALLOWED_TYPES2.includes(file.type)) {
15934
15915
  setUploadError(t3("file_accept_single"));
15935
15916
  return false;
15936
15917
  }
@@ -16145,123 +16126,115 @@ var AvatarField = (props) => {
16145
16126
  // src/widgets/basic/binary-field/binary.tsx
16146
16127
  var import_react39 = require("react");
16147
16128
  var import_jsx_runtime75 = require("react/jsx-runtime");
16129
+ var ALLOWED_TYPES = [
16130
+ "image/jpeg",
16131
+ "image/png",
16132
+ "application/pdf",
16133
+ "video/mp4",
16134
+ "application/zip",
16135
+ "application/x-zip-compressed",
16136
+ "application/vnd.ms-excel",
16137
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
16138
+ "application/json"
16139
+ ];
16148
16140
  var BinaryField = (props) => {
16149
16141
  const {
16142
+ value,
16150
16143
  name,
16151
- methods,
16152
- readonly = false,
16153
- placeholder,
16154
- required = false,
16155
- invisible = false,
16156
- filename,
16157
- formValues,
16158
16144
  isEditTable,
16159
16145
  widget,
16160
- string,
16161
- value,
16162
- // from hook
16146
+ readonly,
16163
16147
  placeHolderImage,
16164
- inputId,
16165
- initialFile,
16166
- binaryRef,
16167
- handleFileChange,
16168
- handleRemoveFile,
16169
- checkIsImageLink: checkIsImageLink2,
16148
+ placeholder,
16149
+ required,
16150
+ invisible,
16151
+ methods,
16152
+ string,
16153
+ isForm,
16170
16154
  onDownload,
16171
- setInitialFile
16155
+ onUploadFile,
16156
+ onDeleteFile,
16157
+ url,
16158
+ fileInfor
16172
16159
  } = props;
16173
16160
  const { t: t3 } = useI18n();
16174
- const [fileInfo, setFileInfo] = (0, import_react39.useState)(null);
16161
+ const [loading, setLoading] = (0, import_react39.useState)(false);
16162
+ const hasFetchedMeta = (0, import_react39.useRef)(false);
16175
16163
  const onlyImage = widget === "image" || widget === "image_url";
16176
- (0, import_react39.useEffect)(() => {
16177
- setInitialFile(value);
16178
- }, [value]);
16179
- (0, import_react39.useEffect)(() => {
16180
- const loadFromLink = async () => {
16181
- if (!initialFile || !initialFile.startsWith("http")) return;
16182
- if (typeof initialFile !== "string") {
16183
- setFileInfo(initialFile);
16184
- return;
16185
- }
16186
- try {
16187
- let type = "application/octet-stream";
16188
- let size4 = 0;
16189
- let name2 = formValues?.[filename ?? ""] || initialFile.split("/").pop() || "unknown_file";
16190
- if (checkIsImageLink2(initialFile) || onlyImage) {
16191
- type = "image/*";
16192
- } else {
16193
- const response = await fetch(initialFile);
16194
- console.log("responsessss", response);
16195
- const responseBlob = await response.blob();
16196
- if (responseBlob) {
16197
- type = responseBlob?.type;
16198
- size4 = responseBlob.size;
16199
- }
16200
- }
16201
- setFileInfo({
16202
- name: name2,
16203
- type,
16204
- url: initialFile,
16205
- size: size4,
16206
- source: "link"
16207
- });
16208
- } catch (error2) {
16209
- console.warn("Cannot load link info:", error2);
16210
- }
16211
- };
16212
- loadFromLink();
16213
- }, [initialFile]);
16214
- const handleChange = (e3, onChange2) => {
16215
- const file = e3.target.files?.[0];
16164
+ const acceptType = !onlyImage ? `.pdf,.json,.mp4,.zip,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,.jpeg,.jpg,.png` : ".jpeg,.jpg,.png";
16165
+ const validateFile = (file) => {
16166
+ if (!ALLOWED_TYPES.includes(file.type)) {
16167
+ return t3("upload_files_accept");
16168
+ }
16169
+ return true;
16170
+ };
16171
+ const handleUpload = async (e3) => {
16172
+ const file = e3.target.files[0];
16216
16173
  if (!file) return;
16217
16174
  if (onlyImage && !file.type.startsWith("image/")) {
16218
- methods?.setError(t3("only_image_accept"));
16175
+ methods?.setError(name, {
16176
+ type: "manual",
16177
+ message: t3("only_image_accept")
16178
+ });
16219
16179
  e3.target.value = "";
16220
16180
  return;
16221
16181
  }
16222
- const isImage = file.type.startsWith("image/");
16223
- const preview = isImage ? URL.createObjectURL(file) : null;
16224
- const normalized = {
16225
- name: file.name,
16226
- type: file.type,
16227
- size: file.size,
16228
- url: preview,
16229
- // chỉ có giá trị nếu là ảnh
16230
- source: "upload",
16231
- raw: file
16232
- };
16233
- setFileInfo(normalized);
16234
- handleFileChange(e3, onChange2);
16182
+ const valid = validateFile(file);
16183
+ if (valid !== true) {
16184
+ methods?.setError(name, { type: "manual", message: valid });
16185
+ return;
16186
+ }
16187
+ methods?.clearErrors(name);
16188
+ const formData = new FormData();
16189
+ formData.append("file", file);
16190
+ setLoading(true);
16191
+ try {
16192
+ onUploadFile?.(formData);
16193
+ } catch (error2) {
16194
+ console.error(error2);
16195
+ }
16196
+ setLoading(false);
16235
16197
  };
16236
- const renderPreview = (file) => {
16237
- if (!file) return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(PlaceHolderIcon, {});
16238
- const { name: name2, type, url, size: size4 } = file;
16239
- if (type?.startsWith("image/") || checkIsImageLink2(url))
16240
- return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16241
- "img",
16242
- {
16243
- src: url,
16244
- alt: name2,
16245
- className: `w-full h-full rounded-lg object-contain ${isEditTable ? "max-h-10 max-w-10" : "max-w-32 max-h-32"}`,
16246
- style: {
16247
- maxWidth: isEditTable ? "40px" : "128px",
16248
- maxHeight: isEditTable ? "40px" : "128px"
16198
+ const handleDelete = () => {
16199
+ onDeleteFile && onDeleteFile();
16200
+ hasFetchedMeta.current = false;
16201
+ };
16202
+ const renderPreview = () => {
16203
+ if (!url) return null;
16204
+ const type = fileInfor?.type;
16205
+ const date = fileInfor?.date;
16206
+ const size4 = fileInfor?.size;
16207
+ if (type?.includes("image")) {
16208
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "flex gap-2 items-center", children: [
16209
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16210
+ "img",
16211
+ {
16212
+ src: url,
16213
+ alt: name,
16214
+ 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"}`,
16215
+ style: {
16216
+ maxWidth: isEditTable ? "40px" : "128px",
16217
+ maxHeight: isEditTable ? "40px" : "128px",
16218
+ height: isEditTable ? "40px" : "128px",
16219
+ width: isEditTable ? "40px" : "128px"
16220
+ }
16249
16221
  }
16250
- }
16251
- );
16252
- if (type?.startsWith("video/"))
16253
- return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16254
- "video",
16255
- {
16256
- src: url,
16257
- className: `rounded-lg object-cover ${isEditTable ? "max-h-10 max-w-10" : "max-w-32 max-h-32"}`,
16258
- style: {
16259
- maxWidth: isEditTable ? "40px" : "128px",
16260
- maxHeight: isEditTable ? "40px" : "128px"
16261
- },
16262
- controls: true
16263
- }
16264
- );
16222
+ ),
16223
+ !onlyImage && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { children: [
16224
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16225
+ "p",
16226
+ {
16227
+ style: {
16228
+ maxWidth: "120px"
16229
+ },
16230
+ className: "text-sm font-medium text-gray-600 truncate max-w-[120px]",
16231
+ children: url?.split("/").pop()
16232
+ }
16233
+ ),
16234
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "text-xs text-[#666] font-semibold", children: size4 })
16235
+ ] })
16236
+ ] });
16237
+ }
16265
16238
  const getFileIcon = () => {
16266
16239
  if (type === "application/pdf") return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(PdfIcon, {});
16267
16240
  if (type?.includes("excel") || type?.includes("spreadsheet"))
@@ -16270,7 +16243,6 @@ var BinaryField = (props) => {
16270
16243
  if (type === "application/json") return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(JSONFileIcon, {});
16271
16244
  return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DefaultFileIcon, {});
16272
16245
  };
16273
- const isShowSize = !isNaN(size4);
16274
16246
  return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "flex items-center gap-2", children: [
16275
16247
  getFileIcon(),
16276
16248
  /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { children: [
@@ -16281,10 +16253,10 @@ var BinaryField = (props) => {
16281
16253
  maxWidth: "120px"
16282
16254
  },
16283
16255
  className: "text-sm font-medium text-gray-600 truncate max-w-[120px]",
16284
- children: name2
16256
+ children: url?.split("/").pop()
16285
16257
  }
16286
16258
  ),
16287
- isShowSize && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "text-xs text-[#666] font-semibold", children: formatFileSize(size4) })
16259
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "text-xs text-[#666] font-semibold", children: size4 })
16288
16260
  ] })
16289
16261
  ] });
16290
16262
  };
@@ -16294,139 +16266,136 @@ var BinaryField = (props) => {
16294
16266
  name: name ?? "",
16295
16267
  control: methods?.control,
16296
16268
  rules: {
16297
- required: required && !invisible ? { value: true, message: `${string} ${t3("must_required")}` } : false
16269
+ required: required && !invisible ? { value: true, message: `${string} ${t3("must_required")}` } : false,
16270
+ validate: {
16271
+ fileValidate: (value2) => {
16272
+ if (!value2) return true;
16273
+ return validateFile(value2);
16274
+ }
16275
+ }
16298
16276
  },
16299
- render: ({ field, fieldState: { error: error2 } }) => {
16300
- const hasFile = !!fileInfo;
16277
+ render: ({ fieldState: { error: error2 } }) => {
16278
+ console.log("error", error2);
16301
16279
  return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, { children: [
16302
16280
  /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16303
16281
  "div",
16304
16282
  {
16305
- ref: binaryRef,
16306
- className: `widget binary-field flex w-fit items-center gap-4 ${onlyImage && initialFile ? "shadow-md rounded-lg" : ""}`,
16307
- children: hasFile ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16283
+ className: `widget binary-field flex w-fit items-center gap-4 ${onlyImage ? "shadow-md rounded-[12px]" : ""} ${isEditTable ? "p-2" : ""}`,
16284
+ children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "relative group", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
16308
16285
  "div",
16309
16286
  {
16310
- className: `relative group ${onlyImage ? "shadow-md rounded-lg" : ""}`,
16311
- children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
16312
- "div",
16313
- {
16314
- className: `flex gap-2 items-center bg-[#FAFAFA] rounded-[8px] p-[6px] ${onlyImage ? "h-32 w-32" : "max-h-fit max-w-fit"}`,
16315
- children: [
16316
- renderPreview(fileInfo),
16317
- /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
16318
- "div",
16319
- {
16320
- style: {
16321
- display: "flex",
16322
- alignItems: "center",
16323
- borderRadius: "8px",
16324
- padding: "4px",
16325
- gap: "8px",
16326
- backgroundColor: onlyImage ? "rgba(0,0,0,0.03)" : "white",
16327
- boxShadow: "0 2px 4px 0 rgba(27, 28, 29, 0.04)",
16328
- position: onlyImage ? "absolute" : "relative",
16329
- bottom: onlyImage ? "0" : "none",
16330
- right: onlyImage ? "0" : "none"
16331
- },
16332
- children: [
16333
- /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16334
- "span",
16335
- {
16336
- className: "cursor-pointer",
16337
- onClick: () => onDownload && onDownload(
16338
- fileInfo?.url || fileInfo?.data,
16339
- fileInfo?.name || fileInfo?.display_name
16340
- ),
16341
- children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DownloadIcon, {})
16342
- }
16343
- ),
16344
- !readonly && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16345
- "span",
16346
- {
16347
- className: "cursor-pointer",
16348
- onClick: () => {
16349
- setFileInfo(null);
16350
- handleRemoveFile(field.onChange);
16351
- },
16352
- children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DeleteIconDanger, {})
16353
- }
16354
- )
16355
- ]
16356
- }
16357
- )
16358
- ]
16359
- }
16360
- )
16361
- }
16362
- ) : /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
16363
- "label",
16364
- {
16365
- htmlFor: inputId,
16366
- 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 "}`,
16287
+ 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 || isForm && !isEditTable && !value ? "p-2" : ""} `} ${error2 && isForm && isEditTable && "widget-error"} `,
16367
16288
  children: [
16368
- /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16369
- "input",
16370
- {
16371
- id: inputId,
16372
- type: "file",
16373
- readOnly: readonly,
16374
- placeholder,
16375
- required: !invisible && required,
16376
- onChange: (e3) => handleChange(e3, field.onChange),
16377
- className: "hidden",
16378
- accept: ".jpeg,.jpg,.png,.pdf,.json,.mp4,.zip,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
16379
- }
16380
- ),
16381
- onlyImage && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16382
- "img",
16383
- {
16384
- src: placeHolderImage,
16385
- alt: "",
16386
- className: "z-0 relative"
16387
- }
16388
- ),
16389
- /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16289
+ renderPreview(),
16290
+ value ? /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
16390
16291
  "div",
16391
16292
  {
16392
- className: " size-8 bg-white rounded-lg flex justify-center items-center z-20",
16293
+ className: "widget",
16393
16294
  style: {
16295
+ display: "flex",
16296
+ alignItems: "center",
16297
+ borderRadius: "8px",
16298
+ padding: "4px",
16299
+ gap: "8px",
16300
+ backgroundColor: onlyImage ? "rgba(0,0,0,0.03)" : "white",
16301
+ boxShadow: "0 2px 4px 0 rgba(27, 28, 29, 0.04)",
16394
16302
  position: onlyImage ? "absolute" : "relative",
16395
- bottom: onlyImage ? "-8px" : "auto",
16396
- left: onlyImage ? "-8px" : "auto",
16397
- boxShadow: "0 1px 2px 0 rgba(228, 229, 231, 0.24)",
16398
- width: "2rem",
16399
- height: "2rem",
16400
- border: onlyImage ? "1px solid transparent" : "1px solid var(--color-primary)",
16401
- borderRadius: onlyImage ? "100%" : "8px"
16303
+ bottom: onlyImage ? "0" : "none",
16304
+ right: onlyImage ? "0" : "none"
16402
16305
  },
16403
- children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16404
- "svg",
16405
- {
16406
- xmlns: "http://www.w3.org/2000/svg",
16407
- width: "14",
16408
- height: "14",
16409
- viewBox: "0 0 14 14",
16410
- fill: "none",
16411
- children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16412
- "path",
16413
- {
16414
- "fill-rule": "evenodd",
16415
- "clip-rule": "evenodd",
16416
- 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",
16417
- fill: "black"
16418
- }
16419
- )
16420
- }
16421
- )
16306
+ children: [
16307
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16308
+ "span",
16309
+ {
16310
+ onClick: () => onDownload && onDownload(url || "", url?.split("/").pop()),
16311
+ className: "cursor-pointer",
16312
+ children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DownloadIcon, {})
16313
+ }
16314
+ ),
16315
+ !readonly && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { onClick: handleDelete, className: "cursor-pointer", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DeleteIconDanger, {}) })
16316
+ ]
16317
+ }
16318
+ ) : /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
16319
+ "label",
16320
+ {
16321
+ style: {
16322
+ maxWidth: "180px",
16323
+ maxHeight: "180px"
16324
+ },
16325
+ 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 "}`,
16326
+ children: [
16327
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16328
+ "input",
16329
+ {
16330
+ type: "file",
16331
+ readOnly: readonly,
16332
+ placeholder,
16333
+ required: !invisible && required,
16334
+ onChange: handleUpload,
16335
+ className: "hidden",
16336
+ accept: acceptType
16337
+ }
16338
+ ),
16339
+ onlyImage && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16340
+ "img",
16341
+ {
16342
+ src: placeHolderImage,
16343
+ alt: "",
16344
+ className: "z-0 relative"
16345
+ }
16346
+ ),
16347
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16348
+ "div",
16349
+ {
16350
+ className: " size-8 bg-white rounded-lg flex justify-center items-center z-20",
16351
+ style: {
16352
+ position: onlyImage ? "absolute" : "relative",
16353
+ bottom: onlyImage ? "-8px" : "auto",
16354
+ left: onlyImage ? "-8px" : "auto",
16355
+ boxShadow: "0 1px 2px 0 rgba(228, 229, 231, 0.24)",
16356
+ width: "2rem",
16357
+ height: "2rem",
16358
+ borderRadius: onlyImage ? "100%" : "8px"
16359
+ },
16360
+ children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16361
+ "svg",
16362
+ {
16363
+ xmlns: "http://www.w3.org/2000/svg",
16364
+ width: "14",
16365
+ height: "14",
16366
+ viewBox: "0 0 14 14",
16367
+ fill: "none",
16368
+ children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16369
+ "path",
16370
+ {
16371
+ "fill-rule": "evenodd",
16372
+ "clip-rule": "evenodd",
16373
+ 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",
16374
+ fill: "black"
16375
+ }
16376
+ )
16377
+ }
16378
+ )
16379
+ }
16380
+ )
16381
+ ]
16422
16382
  }
16423
16383
  )
16424
16384
  ]
16425
16385
  }
16426
- )
16386
+ ) })
16427
16387
  }
16428
16388
  ),
16429
- error2 && !isEditTable && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("p", { className: "text-[#de4747] text-sm mt-1", children: error2.message })
16389
+ error2 && !isEditTable && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
16390
+ "p",
16391
+ {
16392
+ style: {
16393
+ maxWidth: "180px"
16394
+ },
16395
+ className: "text-[#de4747] text-sm mt-1",
16396
+ children: error2.message
16397
+ }
16398
+ )
16430
16399
  ] });
16431
16400
  }
16432
16401
  }