@fctc/sme-widget-ui 2.1.6 → 2.1.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/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
@@ -16113,7 +16115,7 @@ var Search = ({
16113
16115
  }
16114
16116
  )
16115
16117
  ] }),
16116
- (showFiltersGroups || filterBy?.length > 0 || groupBy?.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
16118
+ showFiltersGroups && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
16117
16119
  /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
16118
16120
  "div",
16119
16121
  {
@@ -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 = {
@@ -16981,7 +16995,6 @@ var BinaryField = (props) => {
16981
16995
  ] })
16982
16996
  ] });
16983
16997
  };
16984
- const onlyImage = widget === "image" || widget === "image_url";
16985
16998
  return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
16986
16999
  Controller,
16987
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
@@ -15988,7 +15990,7 @@ var Search = ({
15988
15990
  }
15989
15991
  )
15990
15992
  ] }),
15991
- (showFiltersGroups || filterBy?.length > 0 || groupBy?.length > 0) && /* @__PURE__ */ jsxs41(Fragment10, { children: [
15993
+ showFiltersGroups && /* @__PURE__ */ jsxs41(Fragment10, { children: [
15992
15994
  /* @__PURE__ */ jsxs41(
15993
15995
  "div",
15994
15996
  {
@@ -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 = {
@@ -16856,7 +16870,6 @@ var BinaryField = (props) => {
16856
16870
  ] })
16857
16871
  ] });
16858
16872
  };
16859
- const onlyImage = widget === "image" || widget === "image_url";
16860
16873
  return /* @__PURE__ */ jsx74(
16861
16874
  Controller,
16862
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
@@ -166,6 +166,7 @@ interface IBinaryFieldProps extends IInputFieldProps {
166
166
  handleRemoveFile?: any;
167
167
  checkIsImageLink?: any;
168
168
  onDownload?: any;
169
+ setInitialFile?: any;
169
170
  }
170
171
 
171
172
  declare const BinaryField: (props: IBinaryFieldProps) => JSX.Element;
package/dist/widgets.d.ts CHANGED
@@ -166,6 +166,7 @@ interface IBinaryFieldProps extends IInputFieldProps {
166
166
  handleRemoveFile?: any;
167
167
  checkIsImageLink?: any;
168
168
  onDownload?: any;
169
+ setInitialFile?: any;
169
170
  }
170
171
 
171
172
  declare const BinaryField: (props: IBinaryFieldProps) => JSX.Element;
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
@@ -15365,7 +15367,7 @@ var Search = ({
15365
15367
  }
15366
15368
  )
15367
15369
  ] }),
15368
- (showFiltersGroups || filterBy?.length > 0 || groupBy?.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
15370
+ showFiltersGroups && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
15369
15371
  /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
15370
15372
  "div",
15371
15373
  {
@@ -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 = {
@@ -16233,7 +16247,6 @@ var BinaryField = (props) => {
16233
16247
  ] })
16234
16248
  ] });
16235
16249
  };
16236
- const onlyImage = widget === "image" || widget === "image_url";
16237
16250
  return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
16238
16251
  Controller,
16239
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
@@ -15303,7 +15305,7 @@ var Search = ({
15303
15305
  }
15304
15306
  )
15305
15307
  ] }),
15306
- (showFiltersGroups || filterBy?.length > 0 || groupBy?.length > 0) && /* @__PURE__ */ jsxs41(Fragment10, { children: [
15308
+ showFiltersGroups && /* @__PURE__ */ jsxs41(Fragment10, { children: [
15307
15309
  /* @__PURE__ */ jsxs41(
15308
15310
  "div",
15309
15311
  {
@@ -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 = {
@@ -16171,7 +16185,6 @@ var BinaryField = (props) => {
16171
16185
  ] })
16172
16186
  ] });
16173
16187
  };
16174
- const onlyImage = widget === "image" || widget === "image_url";
16175
16188
  return /* @__PURE__ */ jsx74(
16176
16189
  Controller,
16177
16190
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fctc/sme-widget-ui",
3
- "version": "2.1.6",
3
+ "version": "2.1.8",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",