@esic-lab/data-core-ui 0.0.43 → 0.0.45

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.mjs CHANGED
@@ -2424,7 +2424,7 @@ function SelectField({
2424
2424
  Select,
2425
2425
  {
2426
2426
  showSearch: true,
2427
- value,
2427
+ value: value ? value : void 0,
2428
2428
  defaultValue,
2429
2429
  onChange,
2430
2430
  className: `body-1 flex justify-center w-full ${className ?? ""}`,
@@ -2495,7 +2495,7 @@ function SelectFieldGroup({
2495
2495
  Select2,
2496
2496
  {
2497
2497
  showSearch: true,
2498
- value,
2498
+ value: value ? value : void 0,
2499
2499
  defaultValue,
2500
2500
  onChange,
2501
2501
  className: `body-1 flex justify-center w-full ${className ?? ""}`,
@@ -2582,7 +2582,7 @@ function SelectFieldStatus({
2582
2582
  {
2583
2583
  disabled,
2584
2584
  suffixIcon: /* @__PURE__ */ jsx29(DownOutlined, { style: { color: value ? "#fff" : "#D9D9D9" } }),
2585
- value,
2585
+ value: value ? value : void 0,
2586
2586
  onChange,
2587
2587
  className: `body-3 custom-select flex justify-center w-full ${className ?? ""}`,
2588
2588
  placeholder,
@@ -2649,7 +2649,7 @@ function SelectFieldStatusReport({
2649
2649
  {
2650
2650
  disabled,
2651
2651
  suffixIcon: /* @__PURE__ */ jsx30(DownOutlined2, { style: { color: value ? "#fff" : "#D9D9D9" } }),
2652
- value,
2652
+ value: value ? value : void 0,
2653
2653
  onChange,
2654
2654
  className: `body-3 custom-select flex justify-center w-full ${className ?? ""}`,
2655
2655
  placeholder,
@@ -2721,7 +2721,7 @@ function SelectFieldTag({
2721
2721
  mode: "tags",
2722
2722
  className: `body-1 flex justify-center w-full ${className ?? ""}`,
2723
2723
  placeholder,
2724
- value,
2724
+ value: value ? value : void 0,
2725
2725
  onChange: handleChange,
2726
2726
  onSearch: handleSearch,
2727
2727
  filterOption: (input, option) => {
@@ -2791,7 +2791,7 @@ function SelectCustom({
2791
2791
  /* @__PURE__ */ jsx32(
2792
2792
  Select6,
2793
2793
  {
2794
- value,
2794
+ value: value ? value : void 0,
2795
2795
  onChange: handleChange,
2796
2796
  placeholder,
2797
2797
  options: filteredOptions,
@@ -2800,16 +2800,29 @@ function SelectCustom({
2800
2800
  }
2801
2801
  ),
2802
2802
  error && /* @__PURE__ */ jsx32("p", { className: "text-red-500 caption-1", children: error }),
2803
- /* @__PURE__ */ jsx32("div", { className: "w-full p-[2px] overflow-y-auto", children: valueList.map((v, index) => /* @__PURE__ */ jsxs28("div", { className: "flex justify-between items-center py-[2px] body-1", children: [
2804
- /* @__PURE__ */ jsxs28("div", { className: "flex flex-row gap-[8px]", children: [
2805
- /* @__PURE__ */ jsxs28("p", { children: [
2806
- index + 1,
2807
- "."
2808
- ] }),
2809
- /* @__PURE__ */ jsx32("p", { children: v })
2810
- ] }),
2811
- /* @__PURE__ */ jsx32(IconTrash, { className: "cursor-pointer", onClick: () => handleDelete(v) })
2812
- ] }, index)) })
2803
+ /* @__PURE__ */ jsx32("div", { className: "w-full p-[2px] overflow-y-auto", children: valueList.map((v, index) => /* @__PURE__ */ jsxs28(
2804
+ "div",
2805
+ {
2806
+ className: "flex justify-between items-center py-[2px] body-1",
2807
+ children: [
2808
+ /* @__PURE__ */ jsxs28("div", { className: "flex flex-row gap-[8px]", children: [
2809
+ /* @__PURE__ */ jsxs28("p", { children: [
2810
+ index + 1,
2811
+ "."
2812
+ ] }),
2813
+ /* @__PURE__ */ jsx32("p", { children: v })
2814
+ ] }),
2815
+ /* @__PURE__ */ jsx32(
2816
+ IconTrash,
2817
+ {
2818
+ className: "cursor-pointer",
2819
+ onClick: () => handleDelete(v)
2820
+ }
2821
+ )
2822
+ ]
2823
+ },
2824
+ index
2825
+ )) })
2813
2826
  ] })
2814
2827
  }
2815
2828
  );
@@ -2946,12 +2959,14 @@ function FileUploader({
2946
2959
  disabled,
2947
2960
  mode = "drop",
2948
2961
  description,
2949
- label
2962
+ label,
2963
+ value
2950
2964
  }) {
2951
- const [fileList, setFileList] = useState11([]);
2965
+ const [internalFileList, setInternalFileList] = useState11([]);
2952
2966
  const [uploading, setUploading] = useState11(false);
2953
2967
  const [dragActive, setDragActive] = useState11(false);
2954
2968
  const inputRef = useRef4(null);
2969
+ const filesToDisplay = value || internalFileList;
2955
2970
  const validateFile = (file) => {
2956
2971
  if (accept && !accept.includes(file.type)) {
2957
2972
  onError?.(`Invalid file type. file: ${file.name}`);
@@ -2971,9 +2986,11 @@ function FileUploader({
2971
2986
  if (onRemove) {
2972
2987
  await onRemove(index);
2973
2988
  }
2974
- const updatedList = [...fileList];
2975
- updatedList.splice(index, 1);
2976
- setFileList(updatedList);
2989
+ if (!value) {
2990
+ const updatedList = [...internalFileList];
2991
+ updatedList.splice(index, 1);
2992
+ setInternalFileList(updatedList);
2993
+ }
2977
2994
  } catch (error) {
2978
2995
  console.log(error);
2979
2996
  }
@@ -2991,13 +3008,19 @@ function FileUploader({
2991
3008
  if (!files) return;
2992
3009
  const fileArray = Array.from(files);
2993
3010
  for (const file of fileArray) {
2994
- if (!validateFile(file)) continue;
3011
+ try {
3012
+ validateFile(file);
3013
+ } catch (e) {
3014
+ continue;
3015
+ }
2995
3016
  setUploading(true);
2996
3017
  try {
2997
3018
  if (onUpload) {
2998
3019
  await onUpload(file);
2999
3020
  }
3000
- setFileList((prev) => [...prev, file]);
3021
+ if (!value) {
3022
+ setInternalFileList((prev) => [...prev, file]);
3023
+ }
3001
3024
  } catch (err) {
3002
3025
  console.log("catch");
3003
3026
  console.error(err);
@@ -3064,10 +3087,10 @@ function FileUploader({
3064
3087
  )
3065
3088
  ] }),
3066
3089
  description && /* @__PURE__ */ jsx34("p", { className: "text-gray-400 body-4", children: description }),
3067
- /* @__PURE__ */ jsx34("div", { className: "mt-[8px]", children: fileList.length !== 0 && fileList.map((file, index) => /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-2 rounded-[4px] px-[8px] py-[4px] body-1", children: [
3090
+ /* @__PURE__ */ jsx34("div", { className: "mt-[8px]", children: filesToDisplay.length !== 0 && filesToDisplay.map((file, index) => /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-2 rounded-[4px] px-[8px] py-[4px] body-1", children: [
3068
3091
  /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-2 w-[75%] overflow-hidden", children: [
3069
3092
  /* @__PURE__ */ jsx34("div", { className: "w-[15px] h-[15px]", children: /* @__PURE__ */ jsx34(IconPaperclip, { size: 15 }) }),
3070
- /* @__PURE__ */ jsx34("span", { className: "truncate", children: file.name })
3093
+ /* @__PURE__ */ jsx34("span", { className: "truncate", children: file.name || file.fileName })
3071
3094
  ] }),
3072
3095
  /* @__PURE__ */ jsx34(
3073
3096
  IconTrash2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esic-lab/data-core-ui",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",