@juv/codego-react-ui 3.4.4 → 3.4.6

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.cjs CHANGED
@@ -6648,7 +6648,9 @@ function FieldRenderer({ field, value, onChange }) {
6648
6648
  case "rich-text":
6649
6649
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(RichTextEditor, { value: value ?? "", onChange: (v) => onChange(v) });
6650
6650
  case "file-upload":
6651
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(FileUpload, { onFilesChange: (files) => onChange(files), multiple: true });
6651
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(FileUpload, { onFileSelect: (file) => onChange(file), onFilesChange: (files) => {
6652
+ if (files.length > 1) onChange(files);
6653
+ } });
6652
6654
  case "repeater": {
6653
6655
  const items = Array.isArray(value) ? value : [];
6654
6656
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
@@ -6722,7 +6724,7 @@ function EditModal({
6722
6724
  const [form, setForm] = React28.useState(() => {
6723
6725
  const init = {};
6724
6726
  fields.forEach((f) => {
6725
- init[f.key] = item[f.key] ?? "";
6727
+ init[f.key] = f.type === "file-upload" ? null : item[f.key] ?? "";
6726
6728
  });
6727
6729
  return init;
6728
6730
  });
@@ -6734,6 +6736,7 @@ function EditModal({
6734
6736
  e.preventDefault();
6735
6737
  const errs = {};
6736
6738
  fields.forEach((f) => {
6739
+ if (f.type === "file-upload" && !form[f.key] && item[f.key]) return;
6737
6740
  const msg = validateField(f, form[f.key]);
6738
6741
  if (msg) errs[f.key] = msg;
6739
6742
  });
@@ -6747,19 +6750,20 @@ function EditModal({
6747
6750
  try {
6748
6751
  const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
6749
6752
  if (!csrfToken) throw new Error("[Table] CSRF token not found.");
6750
- const hasFiles = Object.values(form).some(
6751
- (v) => Array.isArray(v) && v.length > 0 && v[0] instanceof File || v instanceof File
6752
- );
6753
+ const isFile = (v) => v instanceof File;
6754
+ const isFileArray = (v) => Array.isArray(v) && v.length > 0 && v[0] instanceof File;
6755
+ const hasFiles = Object.values(form).some((v) => isFile(v) || isFileArray(v));
6753
6756
  let body;
6754
6757
  if (hasFiles) {
6755
6758
  const fd = new FormData();
6756
6759
  fd.append("_method", "PUT");
6757
6760
  Object.entries(form).forEach(([k, v]) => {
6758
- if (Array.isArray(v) && v[0] instanceof File) {
6761
+ if (isFileArray(v)) {
6759
6762
  v.forEach((f) => fd.append(k, f));
6760
- } else if (v instanceof File) {
6763
+ } else if (isFile(v)) {
6761
6764
  fd.append(k, v);
6762
- } else if (v !== null && v !== void 0) {
6765
+ } else if (v === null || v === void 0) {
6766
+ } else if (!Array.isArray(v)) {
6763
6767
  fd.append(k, String(v));
6764
6768
  }
6765
6769
  });
@@ -12868,6 +12872,12 @@ var axiosInstance = import_axios5.default.create({
12868
12872
  Accept: "application/json"
12869
12873
  }
12870
12874
  });
12875
+ axiosInstance.interceptors.request.use((config) => {
12876
+ if (config.data instanceof FormData) {
12877
+ delete config.headers["Content-Type"];
12878
+ }
12879
+ return config;
12880
+ });
12871
12881
 
12872
12882
  // src/lib/codego/request.ts
12873
12883
  var request = async (config) => {
@@ -69794,7 +69794,9 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
69794
69794
  case "rich-text":
69795
69795
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(RichTextEditor, { value: value ?? "", onChange: (v) => onChange(v) });
69796
69796
  case "file-upload":
69797
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(FileUpload, { onFilesChange: (files) => onChange(files), multiple: true });
69797
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(FileUpload, { onFileSelect: (file) => onChange(file), onFilesChange: (files) => {
69798
+ if (files.length > 1) onChange(files);
69799
+ } });
69798
69800
  case "repeater": {
69799
69801
  const items = Array.isArray(value) ? value : [];
69800
69802
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
@@ -69868,7 +69870,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
69868
69870
  const [form, setForm] = React28.useState(() => {
69869
69871
  const init = {};
69870
69872
  fields.forEach((f) => {
69871
- init[f.key] = item[f.key] ?? "";
69873
+ init[f.key] = f.type === "file-upload" ? null : item[f.key] ?? "";
69872
69874
  });
69873
69875
  return init;
69874
69876
  });
@@ -69880,6 +69882,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
69880
69882
  e.preventDefault();
69881
69883
  const errs = {};
69882
69884
  fields.forEach((f) => {
69885
+ if (f.type === "file-upload" && !form[f.key] && item[f.key]) return;
69883
69886
  const msg = validateField(f, form[f.key]);
69884
69887
  if (msg) errs[f.key] = msg;
69885
69888
  });
@@ -69893,19 +69896,20 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
69893
69896
  try {
69894
69897
  const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
69895
69898
  if (!csrfToken) throw new Error("[Table] CSRF token not found.");
69896
- const hasFiles = Object.values(form).some(
69897
- (v) => Array.isArray(v) && v.length > 0 && v[0] instanceof File || v instanceof File
69898
- );
69899
+ const isFile2 = (v) => v instanceof File;
69900
+ const isFileArray = (v) => Array.isArray(v) && v.length > 0 && v[0] instanceof File;
69901
+ const hasFiles = Object.values(form).some((v) => isFile2(v) || isFileArray(v));
69899
69902
  let body;
69900
69903
  if (hasFiles) {
69901
69904
  const fd = new FormData();
69902
69905
  fd.append("_method", "PUT");
69903
69906
  Object.entries(form).forEach(([k, v]) => {
69904
- if (Array.isArray(v) && v[0] instanceof File) {
69907
+ if (isFileArray(v)) {
69905
69908
  v.forEach((f) => fd.append(k, f));
69906
- } else if (v instanceof File) {
69909
+ } else if (isFile2(v)) {
69907
69910
  fd.append(k, v);
69908
- } else if (v !== null && v !== void 0) {
69911
+ } else if (v === null || v === void 0) {
69912
+ } else if (!Array.isArray(v)) {
69909
69913
  fd.append(k, String(v));
69910
69914
  }
69911
69915
  });
@@ -76424,6 +76428,12 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
76424
76428
  Accept: "application/json"
76425
76429
  }
76426
76430
  });
76431
+ axiosInstance.interceptors.request.use((config) => {
76432
+ if (config.data instanceof FormData) {
76433
+ delete config.headers["Content-Type"];
76434
+ }
76435
+ return config;
76436
+ });
76427
76437
 
76428
76438
  // src/lib/codego/request.ts
76429
76439
  var request = async (config) => {
package/dist/index.js CHANGED
@@ -6527,7 +6527,9 @@ function FieldRenderer({ field, value, onChange }) {
6527
6527
  case "rich-text":
6528
6528
  return /* @__PURE__ */ jsx32(RichTextEditor, { value: value ?? "", onChange: (v) => onChange(v) });
6529
6529
  case "file-upload":
6530
- return /* @__PURE__ */ jsx32(FileUpload, { onFilesChange: (files) => onChange(files), multiple: true });
6530
+ return /* @__PURE__ */ jsx32(FileUpload, { onFileSelect: (file) => onChange(file), onFilesChange: (files) => {
6531
+ if (files.length > 1) onChange(files);
6532
+ } });
6531
6533
  case "repeater": {
6532
6534
  const items = Array.isArray(value) ? value : [];
6533
6535
  return /* @__PURE__ */ jsx32(
@@ -6601,7 +6603,7 @@ function EditModal({
6601
6603
  const [form, setForm] = React28.useState(() => {
6602
6604
  const init = {};
6603
6605
  fields.forEach((f) => {
6604
- init[f.key] = item[f.key] ?? "";
6606
+ init[f.key] = f.type === "file-upload" ? null : item[f.key] ?? "";
6605
6607
  });
6606
6608
  return init;
6607
6609
  });
@@ -6613,6 +6615,7 @@ function EditModal({
6613
6615
  e.preventDefault();
6614
6616
  const errs = {};
6615
6617
  fields.forEach((f) => {
6618
+ if (f.type === "file-upload" && !form[f.key] && item[f.key]) return;
6616
6619
  const msg = validateField(f, form[f.key]);
6617
6620
  if (msg) errs[f.key] = msg;
6618
6621
  });
@@ -6626,19 +6629,20 @@ function EditModal({
6626
6629
  try {
6627
6630
  const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
6628
6631
  if (!csrfToken) throw new Error("[Table] CSRF token not found.");
6629
- const hasFiles = Object.values(form).some(
6630
- (v) => Array.isArray(v) && v.length > 0 && v[0] instanceof File || v instanceof File
6631
- );
6632
+ const isFile = (v) => v instanceof File;
6633
+ const isFileArray = (v) => Array.isArray(v) && v.length > 0 && v[0] instanceof File;
6634
+ const hasFiles = Object.values(form).some((v) => isFile(v) || isFileArray(v));
6632
6635
  let body;
6633
6636
  if (hasFiles) {
6634
6637
  const fd = new FormData();
6635
6638
  fd.append("_method", "PUT");
6636
6639
  Object.entries(form).forEach(([k, v]) => {
6637
- if (Array.isArray(v) && v[0] instanceof File) {
6640
+ if (isFileArray(v)) {
6638
6641
  v.forEach((f) => fd.append(k, f));
6639
- } else if (v instanceof File) {
6642
+ } else if (isFile(v)) {
6640
6643
  fd.append(k, v);
6641
- } else if (v !== null && v !== void 0) {
6644
+ } else if (v === null || v === void 0) {
6645
+ } else if (!Array.isArray(v)) {
6642
6646
  fd.append(k, String(v));
6643
6647
  }
6644
6648
  });
@@ -12747,6 +12751,12 @@ var axiosInstance = axios5.create({
12747
12751
  Accept: "application/json"
12748
12752
  }
12749
12753
  });
12754
+ axiosInstance.interceptors.request.use((config) => {
12755
+ if (config.data instanceof FormData) {
12756
+ delete config.headers["Content-Type"];
12757
+ }
12758
+ return config;
12759
+ });
12750
12760
 
12751
12761
  // src/lib/codego/request.ts
12752
12762
  var request = async (config) => {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "registry": "https://registry.npmjs.org/",
5
5
  "access": "public"
6
6
  },
7
- "version": "3.4.4",
7
+ "version": "3.4.6",
8
8
  "description": "Reusable React UI components",
9
9
  "license": "MIT",
10
10
  "main": "dist/index.js",