@juv/codego-react-ui 3.4.2 → 3.4.11
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 +16 -11
- package/dist/index.d.cts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.global.js +16 -11
- package/dist/index.js +16 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6406,6 +6406,16 @@ var import_react_dom2 = require("react-dom");
|
|
|
6406
6406
|
var import_axios3 = __toESM(require("axios"), 1);
|
|
6407
6407
|
var import_lucide_react17 = require("lucide-react");
|
|
6408
6408
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
6409
|
+
var csrfAxios = import_axios3.default.create();
|
|
6410
|
+
csrfAxios.interceptors.request.use((config) => {
|
|
6411
|
+
const method = (config.method ?? "").toUpperCase();
|
|
6412
|
+
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
|
6413
|
+
const token = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
6414
|
+
if (!token) throw new Error('[Table] CSRF token not found. Add <meta name="csrf-token" content="..."> to your HTML <head>.');
|
|
6415
|
+
config.headers.set("X-CSRF-Token", token);
|
|
6416
|
+
}
|
|
6417
|
+
return config;
|
|
6418
|
+
});
|
|
6409
6419
|
function useServerTable({ url, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce = 300, transform, manual = false, refresh: refreshEnabled = false, refreshInterval = 0, hardReload, onSuccess, onError }) {
|
|
6410
6420
|
const [data, setData] = React28.useState([]);
|
|
6411
6421
|
const [columns, setColumns] = React28.useState([]);
|
|
@@ -6555,7 +6565,6 @@ function validateField(field, value) {
|
|
|
6555
6565
|
return null;
|
|
6556
6566
|
}
|
|
6557
6567
|
function FieldRenderer({ field, value, onChange }) {
|
|
6558
|
-
if (field.component) return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: field.component });
|
|
6559
6568
|
if (field.render) return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: field.render(value, onChange) });
|
|
6560
6569
|
const toLabelValue = (o) => {
|
|
6561
6570
|
if (typeof o === "string") return { label: o, value: o };
|
|
@@ -6702,7 +6711,7 @@ function ViewModal({
|
|
|
6702
6711
|
footer: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Button, { variant: "outline", size: "sm", onClick: onClose, children: "Close" }),
|
|
6703
6712
|
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "space-y-3", children: fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { children: [
|
|
6704
6713
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-xs font-semibold text-muted-foreground mb-1", children: f.label }),
|
|
6705
|
-
f.
|
|
6714
|
+
f.render ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: f.render(item[f.key], () => {
|
|
6706
6715
|
}) }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-sm text-foreground break-words", children: item[f.key] === null || item[f.key] === void 0 || item[f.key] === "" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "text-muted-foreground italic", children: "\u2014" }) : String(item[f.key]) })
|
|
6707
6716
|
] }, f.key)) })
|
|
6708
6717
|
}
|
|
@@ -6745,9 +6754,7 @@ function EditModal({
|
|
|
6745
6754
|
setLoading(true);
|
|
6746
6755
|
setError(null);
|
|
6747
6756
|
try {
|
|
6748
|
-
|
|
6749
|
-
if (!csrfToken) throw new Error("[Table] CSRF token not found.");
|
|
6750
|
-
await import_axios3.default.put(`${baseUrl}/${itemId}/update`, { ...form, csrfToken }, { headers: { "X-CSRF-Token": csrfToken } });
|
|
6757
|
+
await csrfAxios.put(`${baseUrl}/${itemId}/update`, form);
|
|
6751
6758
|
const updated = { ...item, ...form };
|
|
6752
6759
|
if (notif && (notif.type ?? "toast") === "notification") {
|
|
6753
6760
|
setBanner(true);
|
|
@@ -6788,14 +6795,14 @@ function EditModal({
|
|
|
6788
6795
|
),
|
|
6789
6796
|
notif.action && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { children: notif.action })
|
|
6790
6797
|
] }),
|
|
6791
|
-
fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime32.
|
|
6798
|
+
fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
6792
6799
|
"div",
|
|
6793
6800
|
{
|
|
6794
6801
|
style: {
|
|
6795
6802
|
...f.colSpan ? { gridColumn: `span ${f.colSpan}` } : {},
|
|
6796
6803
|
...f.rowSpan ? { gridRow: `span ${f.rowSpan}` } : {}
|
|
6797
6804
|
},
|
|
6798
|
-
children:
|
|
6805
|
+
children: [
|
|
6799
6806
|
f.type !== "checkbox" && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("label", { className: "block text-xs font-semibold text-muted-foreground mb-1", children: [
|
|
6800
6807
|
f.label,
|
|
6801
6808
|
f.required && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "text-danger ml-0.5", children: "*" })
|
|
@@ -6815,7 +6822,7 @@ function EditModal({
|
|
|
6815
6822
|
}
|
|
6816
6823
|
),
|
|
6817
6824
|
fieldErrors[f.key] && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-xs text-danger mt-1", children: fieldErrors[f.key] })
|
|
6818
|
-
]
|
|
6825
|
+
]
|
|
6819
6826
|
},
|
|
6820
6827
|
f.key
|
|
6821
6828
|
)),
|
|
@@ -6838,9 +6845,7 @@ function DeleteModal({
|
|
|
6838
6845
|
setLoading(true);
|
|
6839
6846
|
setError(null);
|
|
6840
6847
|
try {
|
|
6841
|
-
|
|
6842
|
-
if (!csrfToken) throw new Error("[Table] CSRF token not found.");
|
|
6843
|
-
await import_axios3.default.delete(`${baseUrl}/${itemId}/delete?csrfToken=${encodeURIComponent(csrfToken)}`, { headers: { "X-CSRF-Token": csrfToken } });
|
|
6848
|
+
await csrfAxios.delete(`${baseUrl}/${itemId}/delete`);
|
|
6844
6849
|
onSuccess?.(item);
|
|
6845
6850
|
onClose();
|
|
6846
6851
|
} catch (err) {
|
package/dist/index.d.cts
CHANGED
|
@@ -360,8 +360,6 @@ interface ActionField {
|
|
|
360
360
|
rowSpan?: number;
|
|
361
361
|
/** Custom render — overrides built-in field renderer */
|
|
362
362
|
render?: (value: any, onChange: (v: any) => void) => React.ReactNode;
|
|
363
|
-
/** Drop-in React component — rendered as-is, bypasses label and built-in renderer. Use for fully custom fields. */
|
|
364
|
-
component?: React.ReactNode;
|
|
365
363
|
/** Hide this field from view/edit forms */
|
|
366
364
|
hidden?: boolean;
|
|
367
365
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -360,8 +360,6 @@ interface ActionField {
|
|
|
360
360
|
rowSpan?: number;
|
|
361
361
|
/** Custom render — overrides built-in field renderer */
|
|
362
362
|
render?: (value: any, onChange: (v: any) => void) => React.ReactNode;
|
|
363
|
-
/** Drop-in React component — rendered as-is, bypasses label and built-in renderer. Use for fully custom fields. */
|
|
364
|
-
component?: React.ReactNode;
|
|
365
363
|
/** Hide this field from view/edit forms */
|
|
366
364
|
hidden?: boolean;
|
|
367
365
|
}
|
package/dist/index.global.js
CHANGED
|
@@ -69552,6 +69552,16 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69552
69552
|
var React28 = __toESM(require_react(), 1);
|
|
69553
69553
|
var import_react_dom2 = __toESM(require_react_dom(), 1);
|
|
69554
69554
|
var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
|
|
69555
|
+
var csrfAxios = axios_default.create();
|
|
69556
|
+
csrfAxios.interceptors.request.use((config) => {
|
|
69557
|
+
const method = (config.method ?? "").toUpperCase();
|
|
69558
|
+
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
|
69559
|
+
const token = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
69560
|
+
if (!token) throw new Error('[Table] CSRF token not found. Add <meta name="csrf-token" content="..."> to your HTML <head>.');
|
|
69561
|
+
config.headers.set("X-CSRF-Token", token);
|
|
69562
|
+
}
|
|
69563
|
+
return config;
|
|
69564
|
+
});
|
|
69555
69565
|
function useServerTable({ url: url2, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce = 300, transform, manual = false, refresh: refreshEnabled = false, refreshInterval = 0, hardReload, onSuccess, onError }) {
|
|
69556
69566
|
const [data, setData] = React28.useState([]);
|
|
69557
69567
|
const [columns, setColumns] = React28.useState([]);
|
|
@@ -69701,7 +69711,6 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69701
69711
|
return null;
|
|
69702
69712
|
}
|
|
69703
69713
|
function FieldRenderer({ field, value, onChange }) {
|
|
69704
|
-
if (field.component) return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: field.component });
|
|
69705
69714
|
if (field.render) return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: field.render(value, onChange) });
|
|
69706
69715
|
const toLabelValue = (o) => {
|
|
69707
69716
|
if (typeof o === "string") return { label: o, value: o };
|
|
@@ -69848,7 +69857,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69848
69857
|
footer: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Button, { variant: "outline", size: "sm", onClick: onClose, children: "Close" }),
|
|
69849
69858
|
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "space-y-3", children: fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { children: [
|
|
69850
69859
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-xs font-semibold text-muted-foreground mb-1", children: f.label }),
|
|
69851
|
-
f.
|
|
69860
|
+
f.render ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: f.render(item[f.key], () => {
|
|
69852
69861
|
}) }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-sm text-foreground break-words", children: item[f.key] === null || item[f.key] === void 0 || item[f.key] === "" ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "text-muted-foreground italic", children: "\u2014" }) : String(item[f.key]) })
|
|
69853
69862
|
] }, f.key)) })
|
|
69854
69863
|
}
|
|
@@ -69891,9 +69900,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69891
69900
|
setLoading(true);
|
|
69892
69901
|
setError(null);
|
|
69893
69902
|
try {
|
|
69894
|
-
|
|
69895
|
-
if (!csrfToken) throw new Error("[Table] CSRF token not found.");
|
|
69896
|
-
await axios_default.put(`${baseUrl}/${itemId}/update`, { ...form, csrfToken }, { headers: { "X-CSRF-Token": csrfToken } });
|
|
69903
|
+
await csrfAxios.put(`${baseUrl}/${itemId}/update`, form);
|
|
69897
69904
|
const updated = { ...item, ...form };
|
|
69898
69905
|
if (notif && (notif.type ?? "toast") === "notification") {
|
|
69899
69906
|
setBanner(true);
|
|
@@ -69934,14 +69941,14 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69934
69941
|
),
|
|
69935
69942
|
notif.action && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { children: notif.action })
|
|
69936
69943
|
] }),
|
|
69937
|
-
fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime32.
|
|
69944
|
+
fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
69938
69945
|
"div",
|
|
69939
69946
|
{
|
|
69940
69947
|
style: {
|
|
69941
69948
|
...f.colSpan ? { gridColumn: `span ${f.colSpan}` } : {},
|
|
69942
69949
|
...f.rowSpan ? { gridRow: `span ${f.rowSpan}` } : {}
|
|
69943
69950
|
},
|
|
69944
|
-
children:
|
|
69951
|
+
children: [
|
|
69945
69952
|
f.type !== "checkbox" && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("label", { className: "block text-xs font-semibold text-muted-foreground mb-1", children: [
|
|
69946
69953
|
f.label,
|
|
69947
69954
|
f.required && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "text-danger ml-0.5", children: "*" })
|
|
@@ -69961,7 +69968,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69961
69968
|
}
|
|
69962
69969
|
),
|
|
69963
69970
|
fieldErrors[f.key] && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-xs text-danger mt-1", children: fieldErrors[f.key] })
|
|
69964
|
-
]
|
|
69971
|
+
]
|
|
69965
69972
|
},
|
|
69966
69973
|
f.key
|
|
69967
69974
|
)),
|
|
@@ -69984,9 +69991,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69984
69991
|
setLoading(true);
|
|
69985
69992
|
setError(null);
|
|
69986
69993
|
try {
|
|
69987
|
-
|
|
69988
|
-
if (!csrfToken) throw new Error("[Table] CSRF token not found.");
|
|
69989
|
-
await axios_default.delete(`${baseUrl}/${itemId}/delete?csrfToken=${encodeURIComponent(csrfToken)}`, { headers: { "X-CSRF-Token": csrfToken } });
|
|
69994
|
+
await csrfAxios.delete(`${baseUrl}/${itemId}/delete`);
|
|
69990
69995
|
onSuccess?.(item);
|
|
69991
69996
|
onClose();
|
|
69992
69997
|
} catch (err) {
|
package/dist/index.js
CHANGED
|
@@ -6285,6 +6285,16 @@ import { createPortal as createPortal3 } from "react-dom";
|
|
|
6285
6285
|
import axios3 from "axios";
|
|
6286
6286
|
import { ChevronLeft as ChevronLeft6, ChevronRight as ChevronRight8, Search as Search5, Trash2 as Trash22, ChevronsUpDown, ChevronUp, ChevronDown as ChevronDown4, X as X9, Eye as Eye2, Pencil as Pencil2, Trash as Trash3, Loader2 as Loader22 } from "lucide-react";
|
|
6287
6287
|
import { Fragment as Fragment11, jsx as jsx32, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
6288
|
+
var csrfAxios = axios3.create();
|
|
6289
|
+
csrfAxios.interceptors.request.use((config) => {
|
|
6290
|
+
const method = (config.method ?? "").toUpperCase();
|
|
6291
|
+
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
|
6292
|
+
const token = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
6293
|
+
if (!token) throw new Error('[Table] CSRF token not found. Add <meta name="csrf-token" content="..."> to your HTML <head>.');
|
|
6294
|
+
config.headers.set("X-CSRF-Token", token);
|
|
6295
|
+
}
|
|
6296
|
+
return config;
|
|
6297
|
+
});
|
|
6288
6298
|
function useServerTable({ url, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce = 300, transform, manual = false, refresh: refreshEnabled = false, refreshInterval = 0, hardReload, onSuccess, onError }) {
|
|
6289
6299
|
const [data, setData] = React28.useState([]);
|
|
6290
6300
|
const [columns, setColumns] = React28.useState([]);
|
|
@@ -6434,7 +6444,6 @@ function validateField(field, value) {
|
|
|
6434
6444
|
return null;
|
|
6435
6445
|
}
|
|
6436
6446
|
function FieldRenderer({ field, value, onChange }) {
|
|
6437
|
-
if (field.component) return /* @__PURE__ */ jsx32(Fragment11, { children: field.component });
|
|
6438
6447
|
if (field.render) return /* @__PURE__ */ jsx32(Fragment11, { children: field.render(value, onChange) });
|
|
6439
6448
|
const toLabelValue = (o) => {
|
|
6440
6449
|
if (typeof o === "string") return { label: o, value: o };
|
|
@@ -6581,7 +6590,7 @@ function ViewModal({
|
|
|
6581
6590
|
footer: /* @__PURE__ */ jsx32(Button, { variant: "outline", size: "sm", onClick: onClose, children: "Close" }),
|
|
6582
6591
|
children: /* @__PURE__ */ jsx32("div", { className: "space-y-3", children: fields.map((f) => /* @__PURE__ */ jsxs30("div", { children: [
|
|
6583
6592
|
/* @__PURE__ */ jsx32("p", { className: "text-xs font-semibold text-muted-foreground mb-1", children: f.label }),
|
|
6584
|
-
f.
|
|
6593
|
+
f.render ? /* @__PURE__ */ jsx32(Fragment11, { children: f.render(item[f.key], () => {
|
|
6585
6594
|
}) }) : /* @__PURE__ */ jsx32("p", { className: "text-sm text-foreground break-words", children: item[f.key] === null || item[f.key] === void 0 || item[f.key] === "" ? /* @__PURE__ */ jsx32("span", { className: "text-muted-foreground italic", children: "\u2014" }) : String(item[f.key]) })
|
|
6586
6595
|
] }, f.key)) })
|
|
6587
6596
|
}
|
|
@@ -6624,9 +6633,7 @@ function EditModal({
|
|
|
6624
6633
|
setLoading(true);
|
|
6625
6634
|
setError(null);
|
|
6626
6635
|
try {
|
|
6627
|
-
|
|
6628
|
-
if (!csrfToken) throw new Error("[Table] CSRF token not found.");
|
|
6629
|
-
await axios3.put(`${baseUrl}/${itemId}/update`, { ...form, csrfToken }, { headers: { "X-CSRF-Token": csrfToken } });
|
|
6636
|
+
await csrfAxios.put(`${baseUrl}/${itemId}/update`, form);
|
|
6630
6637
|
const updated = { ...item, ...form };
|
|
6631
6638
|
if (notif && (notif.type ?? "toast") === "notification") {
|
|
6632
6639
|
setBanner(true);
|
|
@@ -6667,14 +6674,14 @@ function EditModal({
|
|
|
6667
6674
|
),
|
|
6668
6675
|
notif.action && /* @__PURE__ */ jsx32("div", { children: notif.action })
|
|
6669
6676
|
] }),
|
|
6670
|
-
fields.map((f) => /* @__PURE__ */
|
|
6677
|
+
fields.map((f) => /* @__PURE__ */ jsxs30(
|
|
6671
6678
|
"div",
|
|
6672
6679
|
{
|
|
6673
6680
|
style: {
|
|
6674
6681
|
...f.colSpan ? { gridColumn: `span ${f.colSpan}` } : {},
|
|
6675
6682
|
...f.rowSpan ? { gridRow: `span ${f.rowSpan}` } : {}
|
|
6676
6683
|
},
|
|
6677
|
-
children:
|
|
6684
|
+
children: [
|
|
6678
6685
|
f.type !== "checkbox" && /* @__PURE__ */ jsxs30("label", { className: "block text-xs font-semibold text-muted-foreground mb-1", children: [
|
|
6679
6686
|
f.label,
|
|
6680
6687
|
f.required && /* @__PURE__ */ jsx32("span", { className: "text-danger ml-0.5", children: "*" })
|
|
@@ -6694,7 +6701,7 @@ function EditModal({
|
|
|
6694
6701
|
}
|
|
6695
6702
|
),
|
|
6696
6703
|
fieldErrors[f.key] && /* @__PURE__ */ jsx32("p", { className: "text-xs text-danger mt-1", children: fieldErrors[f.key] })
|
|
6697
|
-
]
|
|
6704
|
+
]
|
|
6698
6705
|
},
|
|
6699
6706
|
f.key
|
|
6700
6707
|
)),
|
|
@@ -6717,9 +6724,7 @@ function DeleteModal({
|
|
|
6717
6724
|
setLoading(true);
|
|
6718
6725
|
setError(null);
|
|
6719
6726
|
try {
|
|
6720
|
-
|
|
6721
|
-
if (!csrfToken) throw new Error("[Table] CSRF token not found.");
|
|
6722
|
-
await axios3.delete(`${baseUrl}/${itemId}/delete?csrfToken=${encodeURIComponent(csrfToken)}`, { headers: { "X-CSRF-Token": csrfToken } });
|
|
6727
|
+
await csrfAxios.delete(`${baseUrl}/${itemId}/delete`);
|
|
6723
6728
|
onSuccess?.(item);
|
|
6724
6729
|
onClose();
|
|
6725
6730
|
} catch (err) {
|