@algorithm-shift/design-system 1.3.107 → 1.3.108
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.css +3 -3
- package/dist/index.css.map +1 -1
- package/dist/index.js +277 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +292 -73
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3577,6 +3577,7 @@ import {
|
|
|
3577
3577
|
getFilteredRowModel,
|
|
3578
3578
|
useReactTable
|
|
3579
3579
|
} from "@tanstack/react-table";
|
|
3580
|
+
import axios3 from "axios";
|
|
3580
3581
|
import { ArrowDown, ArrowUp, ArrowUpDown, Search } from "lucide-react";
|
|
3581
3582
|
|
|
3582
3583
|
// src/components/ui/table.tsx
|
|
@@ -4013,13 +4014,153 @@ function DataTable({
|
|
|
4013
4014
|
onDeleteRow,
|
|
4014
4015
|
rowActions,
|
|
4015
4016
|
enableRowSelection = false,
|
|
4016
|
-
getRowSelection
|
|
4017
|
+
getRowSelection,
|
|
4018
|
+
tableId,
|
|
4019
|
+
manageColumns = false,
|
|
4020
|
+
preferenceUrl,
|
|
4021
|
+
axiosInstance
|
|
4017
4022
|
}) {
|
|
4018
4023
|
const [columnFilters, setColumnFilters] = React11.useState([]);
|
|
4019
4024
|
const [columnVisibility, setColumnVisibility] = React11.useState({});
|
|
4025
|
+
const hasLoadedInitialState = React11.useRef(false);
|
|
4026
|
+
const isSavingRef = React11.useRef(false);
|
|
4027
|
+
const isFetchingRef = React11.useRef(false);
|
|
4028
|
+
const transformApiToFrontend = React11.useCallback((apiSettings, allColumnIds) => {
|
|
4029
|
+
if (!apiSettings || !apiSettings.columns || !apiSettings.columns.visible) {
|
|
4030
|
+
return {};
|
|
4031
|
+
}
|
|
4032
|
+
const visibleColumns = apiSettings.columns.visible;
|
|
4033
|
+
const result = {};
|
|
4034
|
+
allColumnIds.forEach((colId) => {
|
|
4035
|
+
result[colId] = visibleColumns.includes(colId);
|
|
4036
|
+
});
|
|
4037
|
+
return result;
|
|
4038
|
+
}, []);
|
|
4039
|
+
const transformFrontendToApi = React11.useCallback((visibility) => {
|
|
4040
|
+
const visibleColumns = Object.keys(visibility).filter((colId) => visibility[colId] === true);
|
|
4041
|
+
return {
|
|
4042
|
+
columns: {
|
|
4043
|
+
visible: visibleColumns
|
|
4044
|
+
}
|
|
4045
|
+
};
|
|
4046
|
+
}, []);
|
|
4047
|
+
const fetchColumnPreferences = React11.useCallback(async () => {
|
|
4048
|
+
if (isFetchingRef.current) {
|
|
4049
|
+
return;
|
|
4050
|
+
}
|
|
4051
|
+
if (!tableId || !manageColumns) {
|
|
4052
|
+
hasLoadedInitialState.current = true;
|
|
4053
|
+
return;
|
|
4054
|
+
}
|
|
4055
|
+
isFetchingRef.current = true;
|
|
4056
|
+
try {
|
|
4057
|
+
const entityKey = `table:${tableId}`;
|
|
4058
|
+
const apiUrl = `${preferenceUrl}/${encodeURIComponent(entityKey)}`;
|
|
4059
|
+
const axiosClient = axiosInstance ?? axios3;
|
|
4060
|
+
const response = await axiosClient.get(apiUrl, {
|
|
4061
|
+
withCredentials: true
|
|
4062
|
+
});
|
|
4063
|
+
if (response) {
|
|
4064
|
+
const data2 = response.data;
|
|
4065
|
+
if (data2.success && data2.data && data2.data.exists && data2.data.settings) {
|
|
4066
|
+
let allColumnIds = [];
|
|
4067
|
+
if (tableRef.current) {
|
|
4068
|
+
allColumnIds = tableRef.current.getAllLeafColumns().map((col) => col.id).filter(Boolean);
|
|
4069
|
+
} else {
|
|
4070
|
+
allColumnIds = columns.map((col) => {
|
|
4071
|
+
if (typeof col.id === "string") {
|
|
4072
|
+
return col.id;
|
|
4073
|
+
}
|
|
4074
|
+
if (col.accessorKey) {
|
|
4075
|
+
return col.accessorKey;
|
|
4076
|
+
}
|
|
4077
|
+
return null;
|
|
4078
|
+
}).filter((id) => !!id);
|
|
4079
|
+
if (enableRowSelection && !allColumnIds.includes("__select__")) {
|
|
4080
|
+
allColumnIds.unshift("__select__");
|
|
4081
|
+
}
|
|
4082
|
+
}
|
|
4083
|
+
if (allColumnIds.length > 0) {
|
|
4084
|
+
const transformed = transformApiToFrontend(data2.data.settings, allColumnIds);
|
|
4085
|
+
console.log("[DataTable] Loaded column preferences:", {
|
|
4086
|
+
visibleColumns: data2.data.settings.columns?.visible,
|
|
4087
|
+
allColumnIds,
|
|
4088
|
+
transformed
|
|
4089
|
+
});
|
|
4090
|
+
if (Object.keys(transformed).length > 0) {
|
|
4091
|
+
setColumnVisibility(transformed);
|
|
4092
|
+
}
|
|
4093
|
+
}
|
|
4094
|
+
} else {
|
|
4095
|
+
console.log("[DataTable] No saved preferences found, using default visibility");
|
|
4096
|
+
}
|
|
4097
|
+
} else {
|
|
4098
|
+
console.warn("Failed to fetch column preferences:", response);
|
|
4099
|
+
}
|
|
4100
|
+
} catch (error) {
|
|
4101
|
+
console.error("Error fetching column preferences:", error);
|
|
4102
|
+
} finally {
|
|
4103
|
+
hasLoadedInitialState.current = true;
|
|
4104
|
+
isFetchingRef.current = false;
|
|
4105
|
+
}
|
|
4106
|
+
}, [tableId, transformApiToFrontend, manageColumns]);
|
|
4107
|
+
const saveColumnPreferences = React11.useCallback(async (visibility) => {
|
|
4108
|
+
if (!tableId || isSavingRef.current || !manageColumns) {
|
|
4109
|
+
return;
|
|
4110
|
+
}
|
|
4111
|
+
isSavingRef.current = true;
|
|
4112
|
+
try {
|
|
4113
|
+
const entityKey = `table:${tableId}`;
|
|
4114
|
+
const apiUrl = `${preferenceUrl}/${encodeURIComponent(entityKey)}`;
|
|
4115
|
+
const settings = transformFrontendToApi(visibility);
|
|
4116
|
+
const requestBody = {
|
|
4117
|
+
settings,
|
|
4118
|
+
is_default: true
|
|
4119
|
+
};
|
|
4120
|
+
const axiosClient = axiosInstance ?? axios3;
|
|
4121
|
+
const response = await axiosClient.post(apiUrl, requestBody, {
|
|
4122
|
+
withCredentials: true
|
|
4123
|
+
});
|
|
4124
|
+
if (!response) {
|
|
4125
|
+
console.error("Failed to save column preferences:", response);
|
|
4126
|
+
}
|
|
4127
|
+
} catch (error) {
|
|
4128
|
+
console.error("Error saving column preferences:", error);
|
|
4129
|
+
} finally {
|
|
4130
|
+
isSavingRef.current = false;
|
|
4131
|
+
}
|
|
4132
|
+
}, [tableId, transformFrontendToApi, manageColumns]);
|
|
4133
|
+
React11.useEffect(() => {
|
|
4134
|
+
if (hasLoadedInitialState.current || isFetchingRef.current) {
|
|
4135
|
+
return;
|
|
4136
|
+
}
|
|
4137
|
+
if (!tableId) {
|
|
4138
|
+
return;
|
|
4139
|
+
}
|
|
4140
|
+
if (manageColumns) {
|
|
4141
|
+
fetchColumnPreferences();
|
|
4142
|
+
}
|
|
4143
|
+
}, [tableId, manageColumns]);
|
|
4020
4144
|
const [manualSort, setManualSort] = React11.useState(null);
|
|
4021
4145
|
const [searchTerm, setSearchTerm] = React11.useState("");
|
|
4022
4146
|
const tableData = Array.isArray(data) ? data : [];
|
|
4147
|
+
const filteredData = React11.useMemo(() => {
|
|
4148
|
+
if (paginationMode === "client" && globalSearch && searchTerm.trim()) {
|
|
4149
|
+
const searchLower = searchTerm.toLowerCase().trim();
|
|
4150
|
+
return tableData.filter((row) => {
|
|
4151
|
+
return columns.some((column) => {
|
|
4152
|
+
const columnId = typeof column.id === "string" ? column.id : column.accessorKey;
|
|
4153
|
+
if (!columnId) return false;
|
|
4154
|
+
const accessorFn = column.accessorFn;
|
|
4155
|
+
const cellValue = accessorFn ? accessorFn(row, 0) : row[columnId];
|
|
4156
|
+
const cellValueStr = cellValue != null ? String(cellValue).toLowerCase() : "";
|
|
4157
|
+
return cellValueStr.includes(searchLower);
|
|
4158
|
+
});
|
|
4159
|
+
});
|
|
4160
|
+
}
|
|
4161
|
+
return tableData;
|
|
4162
|
+
}, [tableData, searchTerm, paginationMode, globalSearch, columns]);
|
|
4163
|
+
const finalData = paginationMode === "client" && globalSearch ? filteredData : tableData;
|
|
4023
4164
|
const finalCols = [...columns];
|
|
4024
4165
|
if (enableRowSelection) {
|
|
4025
4166
|
finalCols.unshift({
|
|
@@ -4046,44 +4187,89 @@ function DataTable({
|
|
|
4046
4187
|
const dynamicCols = useDynamicColumns({ columns: finalCols, enableRowSelection });
|
|
4047
4188
|
const [rowSelection, setRowSelection] = React11.useState({});
|
|
4048
4189
|
const [localPageSize, setLocalPageSize] = React11.useState(pageSize);
|
|
4190
|
+
const [localPageIndex, setLocalPageIndex] = React11.useState(0);
|
|
4191
|
+
const isUpdatingPageSizeRef = React11.useRef(false);
|
|
4192
|
+
const tableRef = React11.useRef(null);
|
|
4193
|
+
React11.useEffect(() => {
|
|
4194
|
+
if (paginationMode === "client") {
|
|
4195
|
+
setLocalPageSize(pageSize);
|
|
4196
|
+
}
|
|
4197
|
+
}, [pageSize, paginationMode]);
|
|
4049
4198
|
const table = useReactTable({
|
|
4050
|
-
data:
|
|
4199
|
+
data: finalData,
|
|
4051
4200
|
columns: dynamicCols,
|
|
4201
|
+
initialState: {
|
|
4202
|
+
pagination: {
|
|
4203
|
+
pageIndex: 0,
|
|
4204
|
+
pageSize
|
|
4205
|
+
}
|
|
4206
|
+
},
|
|
4052
4207
|
state: {
|
|
4053
4208
|
columnFilters,
|
|
4054
4209
|
columnVisibility,
|
|
4055
4210
|
rowSelection,
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
}
|
|
4061
|
-
} : {}
|
|
4211
|
+
pagination: {
|
|
4212
|
+
pageIndex: paginationMode === "server" ? controlledPageIndex ?? 0 : localPageIndex,
|
|
4213
|
+
pageSize: localPageSize
|
|
4214
|
+
}
|
|
4062
4215
|
},
|
|
4063
4216
|
enableRowSelection: !!enableRowSelection,
|
|
4064
4217
|
onRowSelectionChange: (updater) => {
|
|
4065
4218
|
setRowSelection((old) => {
|
|
4066
4219
|
const newState = typeof updater === "function" ? updater(old) : updater;
|
|
4067
|
-
const selectedData = Object.keys(newState).filter((key) => newState[key]).map((rowId) =>
|
|
4220
|
+
const selectedData = Object.keys(newState).filter((key) => newState[key]).map((rowId) => finalData[Number(rowId)]);
|
|
4068
4221
|
getRowSelection?.({ rows: selectedData });
|
|
4069
4222
|
return newState;
|
|
4070
4223
|
});
|
|
4071
4224
|
},
|
|
4072
4225
|
onColumnFiltersChange: setColumnFilters,
|
|
4073
|
-
onColumnVisibilityChange:
|
|
4226
|
+
onColumnVisibilityChange: (updater) => {
|
|
4227
|
+
setColumnVisibility((old) => {
|
|
4228
|
+
const newState = typeof updater === "function" ? updater(old) : updater;
|
|
4229
|
+
setTimeout(() => {
|
|
4230
|
+
if (tableRef.current && tableId && hasLoadedInitialState.current) {
|
|
4231
|
+
try {
|
|
4232
|
+
const completeVisibility = {};
|
|
4233
|
+
tableRef.current.getAllLeafColumns().forEach((column) => {
|
|
4234
|
+
completeVisibility[column.id] = column.getIsVisible();
|
|
4235
|
+
});
|
|
4236
|
+
if (Object.keys(completeVisibility).length > 0) {
|
|
4237
|
+
saveColumnPreferences(completeVisibility);
|
|
4238
|
+
}
|
|
4239
|
+
} catch (error) {
|
|
4240
|
+
console.error("Error saving column visibility to API:", error);
|
|
4241
|
+
}
|
|
4242
|
+
}
|
|
4243
|
+
}, 0);
|
|
4244
|
+
return newState;
|
|
4245
|
+
});
|
|
4246
|
+
},
|
|
4074
4247
|
getCoreRowModel: getCoreRowModel(),
|
|
4075
4248
|
getFilteredRowModel: getFilteredRowModel(),
|
|
4076
4249
|
getPaginationRowModel: pagination && paginationMode === "client" ? getPaginationRowModel() : void 0,
|
|
4077
4250
|
manualPagination: paginationMode === "server",
|
|
4078
4251
|
pageCount: paginationMode === "server" ? Math.ceil(totalRecords / localPageSize) : void 0,
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4252
|
+
onPaginationChange: (updater) => {
|
|
4253
|
+
if (isUpdatingPageSizeRef.current) {
|
|
4254
|
+
isUpdatingPageSizeRef.current = false;
|
|
4255
|
+
return;
|
|
4256
|
+
}
|
|
4257
|
+
const prev = table.getState().pagination;
|
|
4258
|
+
const next = typeof updater === "function" ? updater(prev) : updater;
|
|
4259
|
+
if (paginationMode === "server") {
|
|
4083
4260
|
onPageChange?.(next.pageIndex, next.pageSize);
|
|
4261
|
+
} else {
|
|
4262
|
+
setLocalPageIndex(next.pageIndex);
|
|
4263
|
+
setLocalPageSize(next.pageSize);
|
|
4084
4264
|
}
|
|
4085
|
-
}
|
|
4265
|
+
}
|
|
4086
4266
|
});
|
|
4267
|
+
React11.useEffect(() => {
|
|
4268
|
+
tableRef.current = table;
|
|
4269
|
+
if (table && !hasLoadedInitialState.current && !isFetchingRef.current && tableId) {
|
|
4270
|
+
fetchColumnPreferences();
|
|
4271
|
+
}
|
|
4272
|
+
}, [table, tableId]);
|
|
4087
4273
|
const getPageNumbers = (currentPage, totalPages, maxVisiblePages = 5) => {
|
|
4088
4274
|
if (totalPages <= maxVisiblePages) {
|
|
4089
4275
|
return Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
@@ -4106,17 +4292,26 @@ function DataTable({
|
|
|
4106
4292
|
const pageCount = table.getPageCount() === 0 ? 1 : table.getPageCount();
|
|
4107
4293
|
const handlePageSizeChange = (e) => {
|
|
4108
4294
|
const newSize = Number(e.target.value);
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4295
|
+
if (paginationMode === "server") {
|
|
4296
|
+
const currentPageIndex = table.getState().pagination.pageIndex;
|
|
4297
|
+
onPageChange?.(currentPageIndex, newSize);
|
|
4298
|
+
setLocalPageSize(newSize);
|
|
4299
|
+
} else {
|
|
4300
|
+
isUpdatingPageSizeRef.current = true;
|
|
4301
|
+
setLocalPageSize(newSize);
|
|
4302
|
+
setLocalPageIndex(0);
|
|
4303
|
+
}
|
|
4112
4304
|
};
|
|
4113
4305
|
const pageSizeOptions = React11.useMemo(() => {
|
|
4306
|
+
if (paginationMode === "client") {
|
|
4307
|
+
return [5, 10, 20, 50, 100];
|
|
4308
|
+
}
|
|
4114
4309
|
const options = [5, 10, 20, 50, 100].filter((size) => size < totalRecords);
|
|
4115
4310
|
if (options.length === 0) {
|
|
4116
4311
|
options.push(5);
|
|
4117
4312
|
}
|
|
4118
4313
|
return options;
|
|
4119
|
-
}, [totalRecords]);
|
|
4314
|
+
}, [paginationMode, totalRecords]);
|
|
4120
4315
|
return /* @__PURE__ */ jsxs30("div", { className: "overflow-hidden rounded-md w-full", children: [
|
|
4121
4316
|
!loading && /* @__PURE__ */ jsxs30("div", { className: "flex justify-between p-2 bg-gray-50", children: [
|
|
4122
4317
|
/* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-4 w-full", children: [
|
|
@@ -4132,10 +4327,17 @@ function DataTable({
|
|
|
4132
4327
|
type: "text",
|
|
4133
4328
|
placeholder: "Search...",
|
|
4134
4329
|
value: searchTerm,
|
|
4135
|
-
onChange: (e) =>
|
|
4330
|
+
onChange: (e) => {
|
|
4331
|
+
setSearchTerm(e.target.value);
|
|
4332
|
+
if (paginationMode === "client") {
|
|
4333
|
+
setLocalPageIndex(0);
|
|
4334
|
+
}
|
|
4335
|
+
},
|
|
4136
4336
|
onKeyDown: (e) => {
|
|
4137
|
-
if (e.key === "Enter"
|
|
4138
|
-
onGlobalSearch
|
|
4337
|
+
if (e.key === "Enter") {
|
|
4338
|
+
if (paginationMode === "server" && onGlobalSearch) {
|
|
4339
|
+
onGlobalSearch(searchTerm.trim());
|
|
4340
|
+
}
|
|
4139
4341
|
}
|
|
4140
4342
|
},
|
|
4141
4343
|
className: "border border-gray-300 rounded-md text-sm px-3 py-2 pl-8 w-full focus:outline-none focus:ring-1 focus:ring-[#12715B]"
|
|
@@ -4143,7 +4345,7 @@ function DataTable({
|
|
|
4143
4345
|
),
|
|
4144
4346
|
/* @__PURE__ */ jsx51(Search, { className: "absolute left-2 top-2.5 text-gray-400", size: 16 })
|
|
4145
4347
|
] }),
|
|
4146
|
-
/* @__PURE__ */ jsx51(
|
|
4348
|
+
paginationMode === "server" && /* @__PURE__ */ jsx51(
|
|
4147
4349
|
Button,
|
|
4148
4350
|
{
|
|
4149
4351
|
size: "sm",
|
|
@@ -4154,7 +4356,7 @@ function DataTable({
|
|
|
4154
4356
|
)
|
|
4155
4357
|
] })
|
|
4156
4358
|
] }),
|
|
4157
|
-
/* @__PURE__ */ jsxs30(Popover, { children: [
|
|
4359
|
+
manageColumns && /* @__PURE__ */ jsxs30(Popover, { children: [
|
|
4158
4360
|
/* @__PURE__ */ jsx51(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx51(
|
|
4159
4361
|
Button,
|
|
4160
4362
|
{
|
|
@@ -4164,42 +4366,44 @@ function DataTable({
|
|
|
4164
4366
|
children: "Manage Columns"
|
|
4165
4367
|
}
|
|
4166
4368
|
) }),
|
|
4167
|
-
/* @__PURE__ */ jsxs30(PopoverContent, { align: "end", className: "w-48 p-3
|
|
4369
|
+
/* @__PURE__ */ jsxs30(PopoverContent, { align: "end", className: "w-48 p-3", children: [
|
|
4168
4370
|
/* @__PURE__ */ jsx51("div", { className: "text-sm font-medium mb-2", children: "Show / Hide Columns" }),
|
|
4169
|
-
/* @__PURE__ */ jsxs30("
|
|
4170
|
-
/* @__PURE__ */
|
|
4171
|
-
"input",
|
|
4172
|
-
{
|
|
4173
|
-
type: "checkbox",
|
|
4174
|
-
checked: table.getAllLeafColumns().every((col) => col.getIsVisible()),
|
|
4175
|
-
ref: (input) => {
|
|
4176
|
-
if (input) {
|
|
4177
|
-
input.indeterminate = table.getAllLeafColumns().some((col) => col.getIsVisible()) && !table.getAllLeafColumns().every((col) => col.getIsVisible());
|
|
4178
|
-
}
|
|
4179
|
-
},
|
|
4180
|
-
onChange: (e) => {
|
|
4181
|
-
table.getAllLeafColumns().forEach(
|
|
4182
|
-
(col) => col.toggleVisibility(e.target.checked)
|
|
4183
|
-
);
|
|
4184
|
-
}
|
|
4185
|
-
}
|
|
4186
|
-
),
|
|
4187
|
-
"Toggle All"
|
|
4188
|
-
] }),
|
|
4189
|
-
table.getAllLeafColumns().map((column) => {
|
|
4190
|
-
const header = column.columnDef.header;
|
|
4191
|
-
return /* @__PURE__ */ jsxs30("label", { className: "flex items-center gap-2 text-sm", children: [
|
|
4371
|
+
/* @__PURE__ */ jsxs30("div", { className: "max-h-56 overflow-y-auto pr-1 space-y-2", children: [
|
|
4372
|
+
/* @__PURE__ */ jsxs30("label", { className: "flex items-center gap-2 text-sm font-semibold border-b pb-2 mb-2", children: [
|
|
4192
4373
|
/* @__PURE__ */ jsx51(
|
|
4193
4374
|
"input",
|
|
4194
4375
|
{
|
|
4195
4376
|
type: "checkbox",
|
|
4196
|
-
checked:
|
|
4197
|
-
|
|
4377
|
+
checked: table.getAllLeafColumns().every((col) => col.getIsVisible()),
|
|
4378
|
+
ref: (input) => {
|
|
4379
|
+
if (input) {
|
|
4380
|
+
input.indeterminate = table.getAllLeafColumns().some((col) => col.getIsVisible()) && !table.getAllLeafColumns().every((col) => col.getIsVisible());
|
|
4381
|
+
}
|
|
4382
|
+
},
|
|
4383
|
+
onChange: (e) => {
|
|
4384
|
+
table.getAllLeafColumns().forEach(
|
|
4385
|
+
(col) => col.toggleVisibility(e.target.checked)
|
|
4386
|
+
);
|
|
4387
|
+
}
|
|
4198
4388
|
}
|
|
4199
4389
|
),
|
|
4200
|
-
|
|
4201
|
-
] },
|
|
4202
|
-
|
|
4390
|
+
"Toggle All"
|
|
4391
|
+
] }),
|
|
4392
|
+
table.getAllLeafColumns().map((column) => {
|
|
4393
|
+
const header = column.columnDef.header;
|
|
4394
|
+
return /* @__PURE__ */ jsxs30("label", { className: "flex items-center gap-2 text-sm", children: [
|
|
4395
|
+
/* @__PURE__ */ jsx51(
|
|
4396
|
+
"input",
|
|
4397
|
+
{
|
|
4398
|
+
type: "checkbox",
|
|
4399
|
+
checked: column.getIsVisible(),
|
|
4400
|
+
onChange: (e) => column.toggleVisibility(e.target.checked)
|
|
4401
|
+
}
|
|
4402
|
+
),
|
|
4403
|
+
typeof header === "function" ? header({ column, header, table }) : typeof header === "string" ? header : column.id
|
|
4404
|
+
] }, column.id);
|
|
4405
|
+
})
|
|
4406
|
+
] })
|
|
4203
4407
|
] })
|
|
4204
4408
|
] })
|
|
4205
4409
|
] }),
|
|
@@ -4298,7 +4502,22 @@ function DataTable({
|
|
|
4298
4502
|
`header-${header.id}-${index}`
|
|
4299
4503
|
);
|
|
4300
4504
|
}) }, `header-group-${hg.id}`)) }),
|
|
4301
|
-
/* @__PURE__ */ jsx51(TableBody, { children: loading ? /* @__PURE__ */ jsx51(Fragment21, { children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ jsx51(TableRow, { children:
|
|
4505
|
+
/* @__PURE__ */ jsx51(TableBody, { children: loading ? /* @__PURE__ */ jsx51(Fragment21, { children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ jsx51(TableRow, { children: table.getHeaderGroups()[0].headers.map((header, j) => {
|
|
4506
|
+
const column = header.column;
|
|
4507
|
+
return /* @__PURE__ */ jsx51(
|
|
4508
|
+
TableCell,
|
|
4509
|
+
{
|
|
4510
|
+
className: "p-3",
|
|
4511
|
+
style: {
|
|
4512
|
+
width: column.getSize(),
|
|
4513
|
+
minWidth: column.columnDef.minSize,
|
|
4514
|
+
maxWidth: column.columnDef.maxSize
|
|
4515
|
+
},
|
|
4516
|
+
children: /* @__PURE__ */ jsx51("span", { className: "h-4 bg-gray-200 rounded w-full block animate-pulse" })
|
|
4517
|
+
},
|
|
4518
|
+
j
|
|
4519
|
+
);
|
|
4520
|
+
}) }, i)) }) : table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx51(TableRow, { children: row.getVisibleCells().map((cell, cellIndex, arr) => {
|
|
4302
4521
|
const meta = cell.column.columnDef.meta || {};
|
|
4303
4522
|
const isClickable = meta?.isClickable;
|
|
4304
4523
|
const isLastCell = cellIndex === arr.length - 1;
|
|
@@ -4876,7 +5095,7 @@ var HistoryTimeline = ({
|
|
|
4876
5095
|
var HistoryTimeline_default = HistoryTimeline;
|
|
4877
5096
|
|
|
4878
5097
|
// src/components/Navigation/Tabs/Tabs.tsx
|
|
4879
|
-
import { useCallback as
|
|
5098
|
+
import { useCallback as useCallback5, useMemo as useMemo9, useState as useState12 } from "react";
|
|
4880
5099
|
import { ChevronDown as ChevronDown2, Menu } from "lucide-react";
|
|
4881
5100
|
import Link3 from "next/link";
|
|
4882
5101
|
import { usePathname, useRouter } from "next/navigation";
|
|
@@ -5131,7 +5350,7 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
|
|
|
5131
5350
|
const router = useRouter();
|
|
5132
5351
|
const [showExitDialog, setShowExitDialog] = useState12(false);
|
|
5133
5352
|
const [pendingUrl, setPendingUrl] = useState12(null);
|
|
5134
|
-
const handleBuilderExit =
|
|
5353
|
+
const handleBuilderExit = useCallback5(
|
|
5135
5354
|
(e, url) => {
|
|
5136
5355
|
if (isBuilder) {
|
|
5137
5356
|
e.preventDefault();
|
|
@@ -5298,7 +5517,7 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
|
|
|
5298
5517
|
var Tabs_default = Tabs;
|
|
5299
5518
|
|
|
5300
5519
|
// src/components/Navigation/Stages/Stages.tsx
|
|
5301
|
-
import React12, { useEffect as
|
|
5520
|
+
import React12, { useEffect as useEffect27, useState as useState13 } from "react";
|
|
5302
5521
|
|
|
5303
5522
|
// src/components/ui/tooltip.tsx
|
|
5304
5523
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
@@ -5371,7 +5590,7 @@ var StagesComponent = ({
|
|
|
5371
5590
|
const [isCompleted, setIsCompleted] = useState13(false);
|
|
5372
5591
|
const [activeChildStage, setActiveChildStage] = useState13(null);
|
|
5373
5592
|
const [activeRootStage, setActiveRootStage] = useState13(null);
|
|
5374
|
-
|
|
5593
|
+
useEffect27(() => {
|
|
5375
5594
|
if (currentStage) {
|
|
5376
5595
|
setActiveStage(currentStage);
|
|
5377
5596
|
} else {
|
|
@@ -5431,7 +5650,7 @@ var StagesComponent = ({
|
|
|
5431
5650
|
}
|
|
5432
5651
|
return { activeRoot: null, activeChild: null };
|
|
5433
5652
|
};
|
|
5434
|
-
|
|
5653
|
+
useEffect27(() => {
|
|
5435
5654
|
if (!currentStage || !Array.isArray(stages)) {
|
|
5436
5655
|
setActiveRootStage(null);
|
|
5437
5656
|
setActiveChildStage(null);
|
|
@@ -5562,7 +5781,7 @@ import { jsx as jsx64, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
|
5562
5781
|
import { jsx as jsx65 } from "react/jsx-runtime";
|
|
5563
5782
|
|
|
5564
5783
|
// src/components/Navigation/Navbar/Navbar.tsx
|
|
5565
|
-
import { useCallback as
|
|
5784
|
+
import { useCallback as useCallback6, useMemo as useMemo10, useState as useState14, useEffect as useEffect28 } from "react";
|
|
5566
5785
|
import { Bell, Search as Search2, Menu as Menu2 } from "lucide-react";
|
|
5567
5786
|
import Image3 from "next/image";
|
|
5568
5787
|
import Link4 from "next/link";
|
|
@@ -5631,7 +5850,7 @@ function Navbar({
|
|
|
5631
5850
|
const [screenMode, setScreenMode] = useState14(
|
|
5632
5851
|
canvasMode
|
|
5633
5852
|
);
|
|
5634
|
-
|
|
5853
|
+
useEffect28(() => {
|
|
5635
5854
|
const detectMode = () => {
|
|
5636
5855
|
if (window.innerWidth < 640) setScreenMode("mobile");
|
|
5637
5856
|
else if (window.innerWidth < 1024) setScreenMode("tablet");
|
|
@@ -5645,7 +5864,7 @@ function Navbar({
|
|
|
5645
5864
|
const isMobile = mode === "mobile";
|
|
5646
5865
|
const isTablet = mode === "tablet";
|
|
5647
5866
|
const isDesktop = mode === "desktop";
|
|
5648
|
-
const handleBuilderExit =
|
|
5867
|
+
const handleBuilderExit = useCallback6(
|
|
5649
5868
|
(e, url) => {
|
|
5650
5869
|
if (isBuilder) {
|
|
5651
5870
|
e.preventDefault();
|
|
@@ -5738,8 +5957,8 @@ function Navbar({
|
|
|
5738
5957
|
}
|
|
5739
5958
|
|
|
5740
5959
|
// src/components/Chart/BarChart.tsx
|
|
5741
|
-
import React14, { useEffect as
|
|
5742
|
-
import
|
|
5960
|
+
import React14, { useEffect as useEffect29, useMemo as useMemo11, useState as useState15, useCallback as useCallback7 } from "react";
|
|
5961
|
+
import axios4 from "axios";
|
|
5743
5962
|
import {
|
|
5744
5963
|
BarChart,
|
|
5745
5964
|
Bar,
|
|
@@ -5816,12 +6035,12 @@ var ChartComponent = ({
|
|
|
5816
6035
|
const [currentPage, setCurrentPage] = useState15(1);
|
|
5817
6036
|
const effectiveData = apiUrl ? rawData : props.data || [];
|
|
5818
6037
|
const effectiveLoading = apiUrl ? localLoading : externalLoading;
|
|
5819
|
-
|
|
6038
|
+
useEffect29(() => {
|
|
5820
6039
|
if (apiUrl) {
|
|
5821
6040
|
setCurrentPage(1);
|
|
5822
6041
|
}
|
|
5823
6042
|
}, [apiUrl]);
|
|
5824
|
-
const fetchData =
|
|
6043
|
+
const fetchData = useCallback7(async (page) => {
|
|
5825
6044
|
if (!apiUrl) return;
|
|
5826
6045
|
const cancelled = false;
|
|
5827
6046
|
try {
|
|
@@ -5830,7 +6049,7 @@ var ChartComponent = ({
|
|
|
5830
6049
|
page: page.toString(),
|
|
5831
6050
|
limit: limit.toString()
|
|
5832
6051
|
});
|
|
5833
|
-
const axiosClient = props.axiosInstance ??
|
|
6052
|
+
const axiosClient = props.axiosInstance ?? axios4;
|
|
5834
6053
|
const res = await axiosClient.get(`${apiUrl}?${params.toString()}`, {
|
|
5835
6054
|
withCredentials: true
|
|
5836
6055
|
});
|
|
@@ -5858,7 +6077,7 @@ var ChartComponent = ({
|
|
|
5858
6077
|
if (!cancelled) setLocalLoading(false);
|
|
5859
6078
|
}
|
|
5860
6079
|
}, [apiUrl, limit]);
|
|
5861
|
-
|
|
6080
|
+
useEffect29(() => {
|
|
5862
6081
|
if (!apiUrl) return;
|
|
5863
6082
|
fetchData(currentPage);
|
|
5864
6083
|
}, [apiUrl, currentPage, fetchData]);
|
|
@@ -6057,8 +6276,8 @@ var ChartComponent = ({
|
|
|
6057
6276
|
var BarChart_default = React14.memo(ChartComponent);
|
|
6058
6277
|
|
|
6059
6278
|
// src/components/Chart/PieChart.tsx
|
|
6060
|
-
import React15, { useEffect as
|
|
6061
|
-
import
|
|
6279
|
+
import React15, { useEffect as useEffect30, useMemo as useMemo12, useState as useState16 } from "react";
|
|
6280
|
+
import axios5 from "axios";
|
|
6062
6281
|
import {
|
|
6063
6282
|
PieChart,
|
|
6064
6283
|
Pie,
|
|
@@ -6147,13 +6366,13 @@ var DonutChart = ({
|
|
|
6147
6366
|
const [localLoading, setLocalLoading] = useState16(false);
|
|
6148
6367
|
const effectiveData = apiUrl ? rawData : props.data || [];
|
|
6149
6368
|
const effectiveLoading = apiUrl ? localLoading : externalLoading;
|
|
6150
|
-
|
|
6369
|
+
useEffect30(() => {
|
|
6151
6370
|
if (!apiUrl) return;
|
|
6152
6371
|
let cancelled = false;
|
|
6153
6372
|
const fetchData = async () => {
|
|
6154
6373
|
try {
|
|
6155
6374
|
setLocalLoading(true);
|
|
6156
|
-
const axiosClient = props.axiosInstance ??
|
|
6375
|
+
const axiosClient = props.axiosInstance ?? axios5;
|
|
6157
6376
|
const res = await axiosClient.get(apiUrl, {
|
|
6158
6377
|
withCredentials: true
|
|
6159
6378
|
});
|
|
@@ -6229,7 +6448,7 @@ var DonutChart = ({
|
|
|
6229
6448
|
return { inner: 70, outer: 130 };
|
|
6230
6449
|
};
|
|
6231
6450
|
const [mounted, setMounted] = useState16(false);
|
|
6232
|
-
|
|
6451
|
+
useEffect30(() => {
|
|
6233
6452
|
const timeout = setTimeout(() => setMounted(true), 100);
|
|
6234
6453
|
return () => clearTimeout(timeout);
|
|
6235
6454
|
}, []);
|