@juv/codego-react-ui 3.3.6 → 3.3.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.cjs +20 -3
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.global.js +20 -3
- package/dist/index.js +20 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6405,7 +6405,7 @@ var import_react_dom2 = require("react-dom");
|
|
|
6405
6405
|
var import_axios3 = __toESM(require("axios"), 1);
|
|
6406
6406
|
var import_lucide_react17 = require("lucide-react");
|
|
6407
6407
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
6408
|
-
function useServerTable({ url, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce = 300, transform, manual = false, onSuccess, onError }) {
|
|
6408
|
+
function useServerTable({ url, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce = 300, transform, manual = false, refresh: refreshEnabled = false, refreshInterval = 0, hardReload, onSuccess, onError }) {
|
|
6409
6409
|
const [data, setData] = React28.useState([]);
|
|
6410
6410
|
const [columns, setColumns] = React28.useState([]);
|
|
6411
6411
|
const [currentPage, setCurrentPage] = React28.useState(1);
|
|
@@ -6415,6 +6415,14 @@ function useServerTable({ url, params, encrypt, key, decryptPayloadLog, columnOv
|
|
|
6415
6415
|
const [tick, setTick] = React28.useState(0);
|
|
6416
6416
|
const [searchValue, setSearchValue] = React28.useState("");
|
|
6417
6417
|
const debounceTimer = React28.useRef(void 0);
|
|
6418
|
+
React28.useEffect(() => {
|
|
6419
|
+
if (hardReload) hardReload.current = () => setTick((t) => t + 1);
|
|
6420
|
+
}, [hardReload]);
|
|
6421
|
+
React28.useEffect(() => {
|
|
6422
|
+
if (!refreshInterval || refreshInterval <= 0) return;
|
|
6423
|
+
const id = setInterval(() => setTick((t) => t + 1), refreshInterval);
|
|
6424
|
+
return () => clearInterval(id);
|
|
6425
|
+
}, [refreshInterval]);
|
|
6418
6426
|
React28.useEffect(() => {
|
|
6419
6427
|
if (manual && tick === 0) return;
|
|
6420
6428
|
let cancelled = false;
|
|
@@ -6486,6 +6494,7 @@ function useServerTable({ url, params, encrypt, key, decryptPayloadLog, columnOv
|
|
|
6486
6494
|
error,
|
|
6487
6495
|
goToPage: (page) => setCurrentPage(page),
|
|
6488
6496
|
reload: () => setTick((t) => t + 1),
|
|
6497
|
+
refresh: () => setTick((t) => t + 1),
|
|
6489
6498
|
searchValue,
|
|
6490
6499
|
onSearchChange: handleSearchChange
|
|
6491
6500
|
};
|
|
@@ -6734,7 +6743,10 @@ function EditModal({
|
|
|
6734
6743
|
setLoading(true);
|
|
6735
6744
|
setError(null);
|
|
6736
6745
|
try {
|
|
6737
|
-
|
|
6746
|
+
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
6747
|
+
await import_axios3.default.put(`${baseUrl}/${itemId}/update`, form, {
|
|
6748
|
+
headers: csrfToken ? { "X-CSRF-Token": csrfToken } : {}
|
|
6749
|
+
});
|
|
6738
6750
|
const updated = { ...item, ...form };
|
|
6739
6751
|
if (notif && (notif.type ?? "toast") === "notification") {
|
|
6740
6752
|
setBanner(true);
|
|
@@ -6825,7 +6837,10 @@ function DeleteModal({
|
|
|
6825
6837
|
setLoading(true);
|
|
6826
6838
|
setError(null);
|
|
6827
6839
|
try {
|
|
6828
|
-
|
|
6840
|
+
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
6841
|
+
await import_axios3.default.delete(`${baseUrl}/${itemId}/delete`, {
|
|
6842
|
+
headers: csrfToken ? { "X-CSRF-Token": csrfToken } : {}
|
|
6843
|
+
});
|
|
6829
6844
|
onSuccess?.(item);
|
|
6830
6845
|
onClose();
|
|
6831
6846
|
} catch (err) {
|
|
@@ -7340,6 +7355,7 @@ function Table({
|
|
|
7340
7355
|
(prev) => prev.map((r) => String(r[actionIdKey]) === String(updated[actionIdKey]) ? updated : r)
|
|
7341
7356
|
);
|
|
7342
7357
|
defaultActions.onSuccess?.("edit", updated);
|
|
7358
|
+
defaultActions.onReload?.();
|
|
7343
7359
|
const notif = defaultActions.onSuccessNotif;
|
|
7344
7360
|
if (notif && (notif.type ?? "toast") === "toast") {
|
|
7345
7361
|
toast({
|
|
@@ -7365,6 +7381,7 @@ function Table({
|
|
|
7365
7381
|
(prev) => prev.filter((r) => String(r[actionIdKey]) !== String(deleted[actionIdKey]))
|
|
7366
7382
|
);
|
|
7367
7383
|
defaultActions.onSuccess?.("delete", deleted);
|
|
7384
|
+
defaultActions.onReload?.();
|
|
7368
7385
|
const notif = defaultActions.onSuccessNotif;
|
|
7369
7386
|
if (notif && (notif.type ?? "toast") === "toast") {
|
|
7370
7387
|
toast({
|
package/dist/index.d.cts
CHANGED
|
@@ -256,6 +256,19 @@ interface UseServerTableOptions {
|
|
|
256
256
|
transform?: (response: any) => any[];
|
|
257
257
|
/** If true, hook won't fetch automatically. Call reload() manually */
|
|
258
258
|
manual?: boolean;
|
|
259
|
+
/** If true, refetch data whenever reload() is called (e.g. after edit/delete) */
|
|
260
|
+
refresh?: boolean;
|
|
261
|
+
/** Auto-refresh interval in milliseconds. Omit or set 0 to disable */
|
|
262
|
+
refreshInterval?: number;
|
|
263
|
+
/**
|
|
264
|
+
* A ref that will be assigned the reload function.
|
|
265
|
+
* Call `hardReloadRef.current()` from any external button or function to trigger a refetch.
|
|
266
|
+
* @example
|
|
267
|
+
* const hardReloadRef = React.useRef<() => void>(() => {})
|
|
268
|
+
* useServerTable({ url, hardReload: hardReloadRef })
|
|
269
|
+
* // then anywhere: hardReloadRef.current()
|
|
270
|
+
*/
|
|
271
|
+
hardReload?: React.MutableRefObject<() => void>;
|
|
259
272
|
/** Called after successful data fetch */
|
|
260
273
|
onSuccess?: (data: any[]) => void;
|
|
261
274
|
/** Called on fetch error */
|
|
@@ -276,6 +289,8 @@ interface UseServerTableReturn<T> {
|
|
|
276
289
|
error: string | null;
|
|
277
290
|
goToPage: (page: number) => void;
|
|
278
291
|
reload: () => void;
|
|
292
|
+
/** Manually trigger a data refresh (alias for reload, respects refresh option) */
|
|
293
|
+
refresh: () => void;
|
|
279
294
|
searchValue?: string;
|
|
280
295
|
onSearchChange?: (value: string) => void;
|
|
281
296
|
}
|
|
@@ -304,7 +319,7 @@ interface ServerPaginationProp {
|
|
|
304
319
|
* })
|
|
305
320
|
* ```
|
|
306
321
|
*/
|
|
307
|
-
declare function useServerTable<T extends Record<string, any>>({ url, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce, transform, manual, onSuccess, onError }: UseServerTableOptions): UseServerTableReturn<T>;
|
|
322
|
+
declare function useServerTable<T extends Record<string, any>>({ url, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce, transform, manual, refresh: refreshEnabled, refreshInterval, hardReload, onSuccess, onError }: UseServerTableOptions): UseServerTableReturn<T>;
|
|
308
323
|
/**
|
|
309
324
|
* Available field types for action forms (edit/view modals)
|
|
310
325
|
* @type {ActionFieldType}
|
|
@@ -454,6 +469,8 @@ interface DefaultActionsConfig<T> {
|
|
|
454
469
|
deleteButton?: ActionButtonConfig;
|
|
455
470
|
/** Extra action buttons rendered alongside view/edit/delete */
|
|
456
471
|
extraActions?: ExtraActionConfig<T>[];
|
|
472
|
+
/** Called after a successful edit or delete to trigger a server-side reload (e.g. pass reload from useServerTable) */
|
|
473
|
+
onReload?: () => void;
|
|
457
474
|
}
|
|
458
475
|
/**
|
|
459
476
|
* Configuration for success notifications after edit/delete operations
|
package/dist/index.d.ts
CHANGED
|
@@ -256,6 +256,19 @@ interface UseServerTableOptions {
|
|
|
256
256
|
transform?: (response: any) => any[];
|
|
257
257
|
/** If true, hook won't fetch automatically. Call reload() manually */
|
|
258
258
|
manual?: boolean;
|
|
259
|
+
/** If true, refetch data whenever reload() is called (e.g. after edit/delete) */
|
|
260
|
+
refresh?: boolean;
|
|
261
|
+
/** Auto-refresh interval in milliseconds. Omit or set 0 to disable */
|
|
262
|
+
refreshInterval?: number;
|
|
263
|
+
/**
|
|
264
|
+
* A ref that will be assigned the reload function.
|
|
265
|
+
* Call `hardReloadRef.current()` from any external button or function to trigger a refetch.
|
|
266
|
+
* @example
|
|
267
|
+
* const hardReloadRef = React.useRef<() => void>(() => {})
|
|
268
|
+
* useServerTable({ url, hardReload: hardReloadRef })
|
|
269
|
+
* // then anywhere: hardReloadRef.current()
|
|
270
|
+
*/
|
|
271
|
+
hardReload?: React.MutableRefObject<() => void>;
|
|
259
272
|
/** Called after successful data fetch */
|
|
260
273
|
onSuccess?: (data: any[]) => void;
|
|
261
274
|
/** Called on fetch error */
|
|
@@ -276,6 +289,8 @@ interface UseServerTableReturn<T> {
|
|
|
276
289
|
error: string | null;
|
|
277
290
|
goToPage: (page: number) => void;
|
|
278
291
|
reload: () => void;
|
|
292
|
+
/** Manually trigger a data refresh (alias for reload, respects refresh option) */
|
|
293
|
+
refresh: () => void;
|
|
279
294
|
searchValue?: string;
|
|
280
295
|
onSearchChange?: (value: string) => void;
|
|
281
296
|
}
|
|
@@ -304,7 +319,7 @@ interface ServerPaginationProp {
|
|
|
304
319
|
* })
|
|
305
320
|
* ```
|
|
306
321
|
*/
|
|
307
|
-
declare function useServerTable<T extends Record<string, any>>({ url, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce, transform, manual, onSuccess, onError }: UseServerTableOptions): UseServerTableReturn<T>;
|
|
322
|
+
declare function useServerTable<T extends Record<string, any>>({ url, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce, transform, manual, refresh: refreshEnabled, refreshInterval, hardReload, onSuccess, onError }: UseServerTableOptions): UseServerTableReturn<T>;
|
|
308
323
|
/**
|
|
309
324
|
* Available field types for action forms (edit/view modals)
|
|
310
325
|
* @type {ActionFieldType}
|
|
@@ -454,6 +469,8 @@ interface DefaultActionsConfig<T> {
|
|
|
454
469
|
deleteButton?: ActionButtonConfig;
|
|
455
470
|
/** Extra action buttons rendered alongside view/edit/delete */
|
|
456
471
|
extraActions?: ExtraActionConfig<T>[];
|
|
472
|
+
/** Called after a successful edit or delete to trigger a server-side reload (e.g. pass reload from useServerTable) */
|
|
473
|
+
onReload?: () => void;
|
|
457
474
|
}
|
|
458
475
|
/**
|
|
459
476
|
* Configuration for success notifications after edit/delete operations
|
package/dist/index.global.js
CHANGED
|
@@ -69551,7 +69551,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69551
69551
|
var React28 = __toESM(require_react(), 1);
|
|
69552
69552
|
var import_react_dom2 = __toESM(require_react_dom(), 1);
|
|
69553
69553
|
var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
|
|
69554
|
-
function useServerTable({ url: url2, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce = 300, transform, manual = false, onSuccess, onError }) {
|
|
69554
|
+
function useServerTable({ url: url2, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce = 300, transform, manual = false, refresh: refreshEnabled = false, refreshInterval = 0, hardReload, onSuccess, onError }) {
|
|
69555
69555
|
const [data, setData] = React28.useState([]);
|
|
69556
69556
|
const [columns, setColumns] = React28.useState([]);
|
|
69557
69557
|
const [currentPage, setCurrentPage] = React28.useState(1);
|
|
@@ -69561,6 +69561,14 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69561
69561
|
const [tick, setTick] = React28.useState(0);
|
|
69562
69562
|
const [searchValue, setSearchValue] = React28.useState("");
|
|
69563
69563
|
const debounceTimer = React28.useRef(void 0);
|
|
69564
|
+
React28.useEffect(() => {
|
|
69565
|
+
if (hardReload) hardReload.current = () => setTick((t) => t + 1);
|
|
69566
|
+
}, [hardReload]);
|
|
69567
|
+
React28.useEffect(() => {
|
|
69568
|
+
if (!refreshInterval || refreshInterval <= 0) return;
|
|
69569
|
+
const id = setInterval(() => setTick((t) => t + 1), refreshInterval);
|
|
69570
|
+
return () => clearInterval(id);
|
|
69571
|
+
}, [refreshInterval]);
|
|
69564
69572
|
React28.useEffect(() => {
|
|
69565
69573
|
if (manual && tick === 0) return;
|
|
69566
69574
|
let cancelled = false;
|
|
@@ -69632,6 +69640,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69632
69640
|
error,
|
|
69633
69641
|
goToPage: (page) => setCurrentPage(page),
|
|
69634
69642
|
reload: () => setTick((t) => t + 1),
|
|
69643
|
+
refresh: () => setTick((t) => t + 1),
|
|
69635
69644
|
searchValue,
|
|
69636
69645
|
onSearchChange: handleSearchChange
|
|
69637
69646
|
};
|
|
@@ -69880,7 +69889,10 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69880
69889
|
setLoading(true);
|
|
69881
69890
|
setError(null);
|
|
69882
69891
|
try {
|
|
69883
|
-
|
|
69892
|
+
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
69893
|
+
await axios_default.put(`${baseUrl}/${itemId}/update`, form, {
|
|
69894
|
+
headers: csrfToken ? { "X-CSRF-Token": csrfToken } : {}
|
|
69895
|
+
});
|
|
69884
69896
|
const updated = { ...item, ...form };
|
|
69885
69897
|
if (notif && (notif.type ?? "toast") === "notification") {
|
|
69886
69898
|
setBanner(true);
|
|
@@ -69971,7 +69983,10 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
69971
69983
|
setLoading(true);
|
|
69972
69984
|
setError(null);
|
|
69973
69985
|
try {
|
|
69974
|
-
|
|
69986
|
+
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
69987
|
+
await axios_default.delete(`${baseUrl}/${itemId}/delete`, {
|
|
69988
|
+
headers: csrfToken ? { "X-CSRF-Token": csrfToken } : {}
|
|
69989
|
+
});
|
|
69975
69990
|
onSuccess?.(item);
|
|
69976
69991
|
onClose();
|
|
69977
69992
|
} catch (err) {
|
|
@@ -70486,6 +70501,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
70486
70501
|
(prev) => prev.map((r2) => String(r2[actionIdKey]) === String(updated[actionIdKey]) ? updated : r2)
|
|
70487
70502
|
);
|
|
70488
70503
|
defaultActions.onSuccess?.("edit", updated);
|
|
70504
|
+
defaultActions.onReload?.();
|
|
70489
70505
|
const notif = defaultActions.onSuccessNotif;
|
|
70490
70506
|
if (notif && (notif.type ?? "toast") === "toast") {
|
|
70491
70507
|
toast({
|
|
@@ -70511,6 +70527,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
70511
70527
|
(prev) => prev.filter((r2) => String(r2[actionIdKey]) !== String(deleted[actionIdKey]))
|
|
70512
70528
|
);
|
|
70513
70529
|
defaultActions.onSuccess?.("delete", deleted);
|
|
70530
|
+
defaultActions.onReload?.();
|
|
70514
70531
|
const notif = defaultActions.onSuccessNotif;
|
|
70515
70532
|
if (notif && (notif.type ?? "toast") === "toast") {
|
|
70516
70533
|
toast({
|
package/dist/index.js
CHANGED
|
@@ -6285,7 +6285,7 @@ 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
|
-
function useServerTable({ url, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce = 300, transform, manual = false, onSuccess, onError }) {
|
|
6288
|
+
function useServerTable({ url, params, encrypt, key, decryptPayloadLog, columnOverrides, debounce = 300, transform, manual = false, refresh: refreshEnabled = false, refreshInterval = 0, hardReload, onSuccess, onError }) {
|
|
6289
6289
|
const [data, setData] = React28.useState([]);
|
|
6290
6290
|
const [columns, setColumns] = React28.useState([]);
|
|
6291
6291
|
const [currentPage, setCurrentPage] = React28.useState(1);
|
|
@@ -6295,6 +6295,14 @@ function useServerTable({ url, params, encrypt, key, decryptPayloadLog, columnOv
|
|
|
6295
6295
|
const [tick, setTick] = React28.useState(0);
|
|
6296
6296
|
const [searchValue, setSearchValue] = React28.useState("");
|
|
6297
6297
|
const debounceTimer = React28.useRef(void 0);
|
|
6298
|
+
React28.useEffect(() => {
|
|
6299
|
+
if (hardReload) hardReload.current = () => setTick((t) => t + 1);
|
|
6300
|
+
}, [hardReload]);
|
|
6301
|
+
React28.useEffect(() => {
|
|
6302
|
+
if (!refreshInterval || refreshInterval <= 0) return;
|
|
6303
|
+
const id = setInterval(() => setTick((t) => t + 1), refreshInterval);
|
|
6304
|
+
return () => clearInterval(id);
|
|
6305
|
+
}, [refreshInterval]);
|
|
6298
6306
|
React28.useEffect(() => {
|
|
6299
6307
|
if (manual && tick === 0) return;
|
|
6300
6308
|
let cancelled = false;
|
|
@@ -6366,6 +6374,7 @@ function useServerTable({ url, params, encrypt, key, decryptPayloadLog, columnOv
|
|
|
6366
6374
|
error,
|
|
6367
6375
|
goToPage: (page) => setCurrentPage(page),
|
|
6368
6376
|
reload: () => setTick((t) => t + 1),
|
|
6377
|
+
refresh: () => setTick((t) => t + 1),
|
|
6369
6378
|
searchValue,
|
|
6370
6379
|
onSearchChange: handleSearchChange
|
|
6371
6380
|
};
|
|
@@ -6614,7 +6623,10 @@ function EditModal({
|
|
|
6614
6623
|
setLoading(true);
|
|
6615
6624
|
setError(null);
|
|
6616
6625
|
try {
|
|
6617
|
-
|
|
6626
|
+
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
6627
|
+
await axios3.put(`${baseUrl}/${itemId}/update`, form, {
|
|
6628
|
+
headers: csrfToken ? { "X-CSRF-Token": csrfToken } : {}
|
|
6629
|
+
});
|
|
6618
6630
|
const updated = { ...item, ...form };
|
|
6619
6631
|
if (notif && (notif.type ?? "toast") === "notification") {
|
|
6620
6632
|
setBanner(true);
|
|
@@ -6705,7 +6717,10 @@ function DeleteModal({
|
|
|
6705
6717
|
setLoading(true);
|
|
6706
6718
|
setError(null);
|
|
6707
6719
|
try {
|
|
6708
|
-
|
|
6720
|
+
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute("content");
|
|
6721
|
+
await axios3.delete(`${baseUrl}/${itemId}/delete`, {
|
|
6722
|
+
headers: csrfToken ? { "X-CSRF-Token": csrfToken } : {}
|
|
6723
|
+
});
|
|
6709
6724
|
onSuccess?.(item);
|
|
6710
6725
|
onClose();
|
|
6711
6726
|
} catch (err) {
|
|
@@ -7220,6 +7235,7 @@ function Table({
|
|
|
7220
7235
|
(prev) => prev.map((r) => String(r[actionIdKey]) === String(updated[actionIdKey]) ? updated : r)
|
|
7221
7236
|
);
|
|
7222
7237
|
defaultActions.onSuccess?.("edit", updated);
|
|
7238
|
+
defaultActions.onReload?.();
|
|
7223
7239
|
const notif = defaultActions.onSuccessNotif;
|
|
7224
7240
|
if (notif && (notif.type ?? "toast") === "toast") {
|
|
7225
7241
|
toast({
|
|
@@ -7245,6 +7261,7 @@ function Table({
|
|
|
7245
7261
|
(prev) => prev.filter((r) => String(r[actionIdKey]) !== String(deleted[actionIdKey]))
|
|
7246
7262
|
);
|
|
7247
7263
|
defaultActions.onSuccess?.("delete", deleted);
|
|
7264
|
+
defaultActions.onReload?.();
|
|
7248
7265
|
const notif = defaultActions.onSuccessNotif;
|
|
7249
7266
|
if (notif && (notif.type ?? "toast") === "toast") {
|
|
7250
7267
|
toast({
|