@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.js
CHANGED
|
@@ -3665,6 +3665,7 @@ var React11 = __toESM(require("react"));
|
|
|
3665
3665
|
var import_free_solid_svg_icons2 = require("@fortawesome/free-solid-svg-icons");
|
|
3666
3666
|
var import_react_fontawesome3 = require("@fortawesome/react-fontawesome");
|
|
3667
3667
|
var import_react_table2 = require("@tanstack/react-table");
|
|
3668
|
+
var import_axios3 = __toESM(require("axios"));
|
|
3668
3669
|
var import_lucide_react12 = require("lucide-react");
|
|
3669
3670
|
|
|
3670
3671
|
// src/components/ui/table.tsx
|
|
@@ -4101,13 +4102,153 @@ function DataTable({
|
|
|
4101
4102
|
onDeleteRow,
|
|
4102
4103
|
rowActions,
|
|
4103
4104
|
enableRowSelection = false,
|
|
4104
|
-
getRowSelection
|
|
4105
|
+
getRowSelection,
|
|
4106
|
+
tableId,
|
|
4107
|
+
manageColumns = false,
|
|
4108
|
+
preferenceUrl,
|
|
4109
|
+
axiosInstance
|
|
4105
4110
|
}) {
|
|
4106
4111
|
const [columnFilters, setColumnFilters] = React11.useState([]);
|
|
4107
4112
|
const [columnVisibility, setColumnVisibility] = React11.useState({});
|
|
4113
|
+
const hasLoadedInitialState = React11.useRef(false);
|
|
4114
|
+
const isSavingRef = React11.useRef(false);
|
|
4115
|
+
const isFetchingRef = React11.useRef(false);
|
|
4116
|
+
const transformApiToFrontend = React11.useCallback((apiSettings, allColumnIds) => {
|
|
4117
|
+
if (!apiSettings || !apiSettings.columns || !apiSettings.columns.visible) {
|
|
4118
|
+
return {};
|
|
4119
|
+
}
|
|
4120
|
+
const visibleColumns = apiSettings.columns.visible;
|
|
4121
|
+
const result = {};
|
|
4122
|
+
allColumnIds.forEach((colId) => {
|
|
4123
|
+
result[colId] = visibleColumns.includes(colId);
|
|
4124
|
+
});
|
|
4125
|
+
return result;
|
|
4126
|
+
}, []);
|
|
4127
|
+
const transformFrontendToApi = React11.useCallback((visibility) => {
|
|
4128
|
+
const visibleColumns = Object.keys(visibility).filter((colId) => visibility[colId] === true);
|
|
4129
|
+
return {
|
|
4130
|
+
columns: {
|
|
4131
|
+
visible: visibleColumns
|
|
4132
|
+
}
|
|
4133
|
+
};
|
|
4134
|
+
}, []);
|
|
4135
|
+
const fetchColumnPreferences = React11.useCallback(async () => {
|
|
4136
|
+
if (isFetchingRef.current) {
|
|
4137
|
+
return;
|
|
4138
|
+
}
|
|
4139
|
+
if (!tableId || !manageColumns) {
|
|
4140
|
+
hasLoadedInitialState.current = true;
|
|
4141
|
+
return;
|
|
4142
|
+
}
|
|
4143
|
+
isFetchingRef.current = true;
|
|
4144
|
+
try {
|
|
4145
|
+
const entityKey = `table:${tableId}`;
|
|
4146
|
+
const apiUrl = `${preferenceUrl}/${encodeURIComponent(entityKey)}`;
|
|
4147
|
+
const axiosClient = axiosInstance ?? import_axios3.default;
|
|
4148
|
+
const response = await axiosClient.get(apiUrl, {
|
|
4149
|
+
withCredentials: true
|
|
4150
|
+
});
|
|
4151
|
+
if (response) {
|
|
4152
|
+
const data2 = response.data;
|
|
4153
|
+
if (data2.success && data2.data && data2.data.exists && data2.data.settings) {
|
|
4154
|
+
let allColumnIds = [];
|
|
4155
|
+
if (tableRef.current) {
|
|
4156
|
+
allColumnIds = tableRef.current.getAllLeafColumns().map((col) => col.id).filter(Boolean);
|
|
4157
|
+
} else {
|
|
4158
|
+
allColumnIds = columns.map((col) => {
|
|
4159
|
+
if (typeof col.id === "string") {
|
|
4160
|
+
return col.id;
|
|
4161
|
+
}
|
|
4162
|
+
if (col.accessorKey) {
|
|
4163
|
+
return col.accessorKey;
|
|
4164
|
+
}
|
|
4165
|
+
return null;
|
|
4166
|
+
}).filter((id) => !!id);
|
|
4167
|
+
if (enableRowSelection && !allColumnIds.includes("__select__")) {
|
|
4168
|
+
allColumnIds.unshift("__select__");
|
|
4169
|
+
}
|
|
4170
|
+
}
|
|
4171
|
+
if (allColumnIds.length > 0) {
|
|
4172
|
+
const transformed = transformApiToFrontend(data2.data.settings, allColumnIds);
|
|
4173
|
+
console.log("[DataTable] Loaded column preferences:", {
|
|
4174
|
+
visibleColumns: data2.data.settings.columns?.visible,
|
|
4175
|
+
allColumnIds,
|
|
4176
|
+
transformed
|
|
4177
|
+
});
|
|
4178
|
+
if (Object.keys(transformed).length > 0) {
|
|
4179
|
+
setColumnVisibility(transformed);
|
|
4180
|
+
}
|
|
4181
|
+
}
|
|
4182
|
+
} else {
|
|
4183
|
+
console.log("[DataTable] No saved preferences found, using default visibility");
|
|
4184
|
+
}
|
|
4185
|
+
} else {
|
|
4186
|
+
console.warn("Failed to fetch column preferences:", response);
|
|
4187
|
+
}
|
|
4188
|
+
} catch (error) {
|
|
4189
|
+
console.error("Error fetching column preferences:", error);
|
|
4190
|
+
} finally {
|
|
4191
|
+
hasLoadedInitialState.current = true;
|
|
4192
|
+
isFetchingRef.current = false;
|
|
4193
|
+
}
|
|
4194
|
+
}, [tableId, transformApiToFrontend, manageColumns]);
|
|
4195
|
+
const saveColumnPreferences = React11.useCallback(async (visibility) => {
|
|
4196
|
+
if (!tableId || isSavingRef.current || !manageColumns) {
|
|
4197
|
+
return;
|
|
4198
|
+
}
|
|
4199
|
+
isSavingRef.current = true;
|
|
4200
|
+
try {
|
|
4201
|
+
const entityKey = `table:${tableId}`;
|
|
4202
|
+
const apiUrl = `${preferenceUrl}/${encodeURIComponent(entityKey)}`;
|
|
4203
|
+
const settings = transformFrontendToApi(visibility);
|
|
4204
|
+
const requestBody = {
|
|
4205
|
+
settings,
|
|
4206
|
+
is_default: true
|
|
4207
|
+
};
|
|
4208
|
+
const axiosClient = axiosInstance ?? import_axios3.default;
|
|
4209
|
+
const response = await axiosClient.post(apiUrl, requestBody, {
|
|
4210
|
+
withCredentials: true
|
|
4211
|
+
});
|
|
4212
|
+
if (!response) {
|
|
4213
|
+
console.error("Failed to save column preferences:", response);
|
|
4214
|
+
}
|
|
4215
|
+
} catch (error) {
|
|
4216
|
+
console.error("Error saving column preferences:", error);
|
|
4217
|
+
} finally {
|
|
4218
|
+
isSavingRef.current = false;
|
|
4219
|
+
}
|
|
4220
|
+
}, [tableId, transformFrontendToApi, manageColumns]);
|
|
4221
|
+
React11.useEffect(() => {
|
|
4222
|
+
if (hasLoadedInitialState.current || isFetchingRef.current) {
|
|
4223
|
+
return;
|
|
4224
|
+
}
|
|
4225
|
+
if (!tableId) {
|
|
4226
|
+
return;
|
|
4227
|
+
}
|
|
4228
|
+
if (manageColumns) {
|
|
4229
|
+
fetchColumnPreferences();
|
|
4230
|
+
}
|
|
4231
|
+
}, [tableId, manageColumns]);
|
|
4108
4232
|
const [manualSort, setManualSort] = React11.useState(null);
|
|
4109
4233
|
const [searchTerm, setSearchTerm] = React11.useState("");
|
|
4110
4234
|
const tableData = Array.isArray(data) ? data : [];
|
|
4235
|
+
const filteredData = React11.useMemo(() => {
|
|
4236
|
+
if (paginationMode === "client" && globalSearch && searchTerm.trim()) {
|
|
4237
|
+
const searchLower = searchTerm.toLowerCase().trim();
|
|
4238
|
+
return tableData.filter((row) => {
|
|
4239
|
+
return columns.some((column) => {
|
|
4240
|
+
const columnId = typeof column.id === "string" ? column.id : column.accessorKey;
|
|
4241
|
+
if (!columnId) return false;
|
|
4242
|
+
const accessorFn = column.accessorFn;
|
|
4243
|
+
const cellValue = accessorFn ? accessorFn(row, 0) : row[columnId];
|
|
4244
|
+
const cellValueStr = cellValue != null ? String(cellValue).toLowerCase() : "";
|
|
4245
|
+
return cellValueStr.includes(searchLower);
|
|
4246
|
+
});
|
|
4247
|
+
});
|
|
4248
|
+
}
|
|
4249
|
+
return tableData;
|
|
4250
|
+
}, [tableData, searchTerm, paginationMode, globalSearch, columns]);
|
|
4251
|
+
const finalData = paginationMode === "client" && globalSearch ? filteredData : tableData;
|
|
4111
4252
|
const finalCols = [...columns];
|
|
4112
4253
|
if (enableRowSelection) {
|
|
4113
4254
|
finalCols.unshift({
|
|
@@ -4134,44 +4275,89 @@ function DataTable({
|
|
|
4134
4275
|
const dynamicCols = useDynamicColumns({ columns: finalCols, enableRowSelection });
|
|
4135
4276
|
const [rowSelection, setRowSelection] = React11.useState({});
|
|
4136
4277
|
const [localPageSize, setLocalPageSize] = React11.useState(pageSize);
|
|
4278
|
+
const [localPageIndex, setLocalPageIndex] = React11.useState(0);
|
|
4279
|
+
const isUpdatingPageSizeRef = React11.useRef(false);
|
|
4280
|
+
const tableRef = React11.useRef(null);
|
|
4281
|
+
React11.useEffect(() => {
|
|
4282
|
+
if (paginationMode === "client") {
|
|
4283
|
+
setLocalPageSize(pageSize);
|
|
4284
|
+
}
|
|
4285
|
+
}, [pageSize, paginationMode]);
|
|
4137
4286
|
const table = (0, import_react_table2.useReactTable)({
|
|
4138
|
-
data:
|
|
4287
|
+
data: finalData,
|
|
4139
4288
|
columns: dynamicCols,
|
|
4289
|
+
initialState: {
|
|
4290
|
+
pagination: {
|
|
4291
|
+
pageIndex: 0,
|
|
4292
|
+
pageSize
|
|
4293
|
+
}
|
|
4294
|
+
},
|
|
4140
4295
|
state: {
|
|
4141
4296
|
columnFilters,
|
|
4142
4297
|
columnVisibility,
|
|
4143
4298
|
rowSelection,
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
}
|
|
4149
|
-
} : {}
|
|
4299
|
+
pagination: {
|
|
4300
|
+
pageIndex: paginationMode === "server" ? controlledPageIndex ?? 0 : localPageIndex,
|
|
4301
|
+
pageSize: localPageSize
|
|
4302
|
+
}
|
|
4150
4303
|
},
|
|
4151
4304
|
enableRowSelection: !!enableRowSelection,
|
|
4152
4305
|
onRowSelectionChange: (updater) => {
|
|
4153
4306
|
setRowSelection((old) => {
|
|
4154
4307
|
const newState = typeof updater === "function" ? updater(old) : updater;
|
|
4155
|
-
const selectedData = Object.keys(newState).filter((key) => newState[key]).map((rowId) =>
|
|
4308
|
+
const selectedData = Object.keys(newState).filter((key) => newState[key]).map((rowId) => finalData[Number(rowId)]);
|
|
4156
4309
|
getRowSelection?.({ rows: selectedData });
|
|
4157
4310
|
return newState;
|
|
4158
4311
|
});
|
|
4159
4312
|
},
|
|
4160
4313
|
onColumnFiltersChange: setColumnFilters,
|
|
4161
|
-
onColumnVisibilityChange:
|
|
4314
|
+
onColumnVisibilityChange: (updater) => {
|
|
4315
|
+
setColumnVisibility((old) => {
|
|
4316
|
+
const newState = typeof updater === "function" ? updater(old) : updater;
|
|
4317
|
+
setTimeout(() => {
|
|
4318
|
+
if (tableRef.current && tableId && hasLoadedInitialState.current) {
|
|
4319
|
+
try {
|
|
4320
|
+
const completeVisibility = {};
|
|
4321
|
+
tableRef.current.getAllLeafColumns().forEach((column) => {
|
|
4322
|
+
completeVisibility[column.id] = column.getIsVisible();
|
|
4323
|
+
});
|
|
4324
|
+
if (Object.keys(completeVisibility).length > 0) {
|
|
4325
|
+
saveColumnPreferences(completeVisibility);
|
|
4326
|
+
}
|
|
4327
|
+
} catch (error) {
|
|
4328
|
+
console.error("Error saving column visibility to API:", error);
|
|
4329
|
+
}
|
|
4330
|
+
}
|
|
4331
|
+
}, 0);
|
|
4332
|
+
return newState;
|
|
4333
|
+
});
|
|
4334
|
+
},
|
|
4162
4335
|
getCoreRowModel: (0, import_react_table2.getCoreRowModel)(),
|
|
4163
4336
|
getFilteredRowModel: (0, import_react_table2.getFilteredRowModel)(),
|
|
4164
4337
|
getPaginationRowModel: pagination && paginationMode === "client" ? (0, import_react_table2.getPaginationRowModel)() : void 0,
|
|
4165
4338
|
manualPagination: paginationMode === "server",
|
|
4166
4339
|
pageCount: paginationMode === "server" ? Math.ceil(totalRecords / localPageSize) : void 0,
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4340
|
+
onPaginationChange: (updater) => {
|
|
4341
|
+
if (isUpdatingPageSizeRef.current) {
|
|
4342
|
+
isUpdatingPageSizeRef.current = false;
|
|
4343
|
+
return;
|
|
4344
|
+
}
|
|
4345
|
+
const prev = table.getState().pagination;
|
|
4346
|
+
const next = typeof updater === "function" ? updater(prev) : updater;
|
|
4347
|
+
if (paginationMode === "server") {
|
|
4171
4348
|
onPageChange?.(next.pageIndex, next.pageSize);
|
|
4349
|
+
} else {
|
|
4350
|
+
setLocalPageIndex(next.pageIndex);
|
|
4351
|
+
setLocalPageSize(next.pageSize);
|
|
4172
4352
|
}
|
|
4173
|
-
}
|
|
4353
|
+
}
|
|
4174
4354
|
});
|
|
4355
|
+
React11.useEffect(() => {
|
|
4356
|
+
tableRef.current = table;
|
|
4357
|
+
if (table && !hasLoadedInitialState.current && !isFetchingRef.current && tableId) {
|
|
4358
|
+
fetchColumnPreferences();
|
|
4359
|
+
}
|
|
4360
|
+
}, [table, tableId]);
|
|
4175
4361
|
const getPageNumbers = (currentPage, totalPages, maxVisiblePages = 5) => {
|
|
4176
4362
|
if (totalPages <= maxVisiblePages) {
|
|
4177
4363
|
return Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
@@ -4194,17 +4380,26 @@ function DataTable({
|
|
|
4194
4380
|
const pageCount = table.getPageCount() === 0 ? 1 : table.getPageCount();
|
|
4195
4381
|
const handlePageSizeChange = (e) => {
|
|
4196
4382
|
const newSize = Number(e.target.value);
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4383
|
+
if (paginationMode === "server") {
|
|
4384
|
+
const currentPageIndex = table.getState().pagination.pageIndex;
|
|
4385
|
+
onPageChange?.(currentPageIndex, newSize);
|
|
4386
|
+
setLocalPageSize(newSize);
|
|
4387
|
+
} else {
|
|
4388
|
+
isUpdatingPageSizeRef.current = true;
|
|
4389
|
+
setLocalPageSize(newSize);
|
|
4390
|
+
setLocalPageIndex(0);
|
|
4391
|
+
}
|
|
4200
4392
|
};
|
|
4201
4393
|
const pageSizeOptions = React11.useMemo(() => {
|
|
4394
|
+
if (paginationMode === "client") {
|
|
4395
|
+
return [5, 10, 20, 50, 100];
|
|
4396
|
+
}
|
|
4202
4397
|
const options = [5, 10, 20, 50, 100].filter((size) => size < totalRecords);
|
|
4203
4398
|
if (options.length === 0) {
|
|
4204
4399
|
options.push(5);
|
|
4205
4400
|
}
|
|
4206
4401
|
return options;
|
|
4207
|
-
}, [totalRecords]);
|
|
4402
|
+
}, [paginationMode, totalRecords]);
|
|
4208
4403
|
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "overflow-hidden rounded-md w-full", children: [
|
|
4209
4404
|
!loading && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex justify-between p-2 bg-gray-50", children: [
|
|
4210
4405
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center gap-4 w-full", children: [
|
|
@@ -4220,10 +4415,17 @@ function DataTable({
|
|
|
4220
4415
|
type: "text",
|
|
4221
4416
|
placeholder: "Search...",
|
|
4222
4417
|
value: searchTerm,
|
|
4223
|
-
onChange: (e) =>
|
|
4418
|
+
onChange: (e) => {
|
|
4419
|
+
setSearchTerm(e.target.value);
|
|
4420
|
+
if (paginationMode === "client") {
|
|
4421
|
+
setLocalPageIndex(0);
|
|
4422
|
+
}
|
|
4423
|
+
},
|
|
4224
4424
|
onKeyDown: (e) => {
|
|
4225
|
-
if (e.key === "Enter"
|
|
4226
|
-
onGlobalSearch
|
|
4425
|
+
if (e.key === "Enter") {
|
|
4426
|
+
if (paginationMode === "server" && onGlobalSearch) {
|
|
4427
|
+
onGlobalSearch(searchTerm.trim());
|
|
4428
|
+
}
|
|
4227
4429
|
}
|
|
4228
4430
|
},
|
|
4229
4431
|
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]"
|
|
@@ -4231,7 +4433,7 @@ function DataTable({
|
|
|
4231
4433
|
),
|
|
4232
4434
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_lucide_react12.Search, { className: "absolute left-2 top-2.5 text-gray-400", size: 16 })
|
|
4233
4435
|
] }),
|
|
4234
|
-
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4436
|
+
paginationMode === "server" && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4235
4437
|
Button,
|
|
4236
4438
|
{
|
|
4237
4439
|
size: "sm",
|
|
@@ -4242,7 +4444,7 @@ function DataTable({
|
|
|
4242
4444
|
)
|
|
4243
4445
|
] })
|
|
4244
4446
|
] }),
|
|
4245
|
-
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Popover, { children: [
|
|
4447
|
+
manageColumns && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Popover, { children: [
|
|
4246
4448
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4247
4449
|
Button,
|
|
4248
4450
|
{
|
|
@@ -4252,42 +4454,44 @@ function DataTable({
|
|
|
4252
4454
|
children: "Manage Columns"
|
|
4253
4455
|
}
|
|
4254
4456
|
) }),
|
|
4255
|
-
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(PopoverContent, { align: "end", className: "w-48 p-3
|
|
4457
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(PopoverContent, { align: "end", className: "w-48 p-3", children: [
|
|
4256
4458
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "text-sm font-medium mb-2", children: "Show / Hide Columns" }),
|
|
4257
|
-
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("
|
|
4258
|
-
/* @__PURE__ */ (0, import_jsx_runtime51.
|
|
4259
|
-
"input",
|
|
4260
|
-
{
|
|
4261
|
-
type: "checkbox",
|
|
4262
|
-
checked: table.getAllLeafColumns().every((col) => col.getIsVisible()),
|
|
4263
|
-
ref: (input) => {
|
|
4264
|
-
if (input) {
|
|
4265
|
-
input.indeterminate = table.getAllLeafColumns().some((col) => col.getIsVisible()) && !table.getAllLeafColumns().every((col) => col.getIsVisible());
|
|
4266
|
-
}
|
|
4267
|
-
},
|
|
4268
|
-
onChange: (e) => {
|
|
4269
|
-
table.getAllLeafColumns().forEach(
|
|
4270
|
-
(col) => col.toggleVisibility(e.target.checked)
|
|
4271
|
-
);
|
|
4272
|
-
}
|
|
4273
|
-
}
|
|
4274
|
-
),
|
|
4275
|
-
"Toggle All"
|
|
4276
|
-
] }),
|
|
4277
|
-
table.getAllLeafColumns().map((column) => {
|
|
4278
|
-
const header = column.columnDef.header;
|
|
4279
|
-
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "flex items-center gap-2 text-sm", children: [
|
|
4459
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "max-h-56 overflow-y-auto pr-1 space-y-2", children: [
|
|
4460
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "flex items-center gap-2 text-sm font-semibold border-b pb-2 mb-2", children: [
|
|
4280
4461
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4281
4462
|
"input",
|
|
4282
4463
|
{
|
|
4283
4464
|
type: "checkbox",
|
|
4284
|
-
checked:
|
|
4285
|
-
|
|
4465
|
+
checked: table.getAllLeafColumns().every((col) => col.getIsVisible()),
|
|
4466
|
+
ref: (input) => {
|
|
4467
|
+
if (input) {
|
|
4468
|
+
input.indeterminate = table.getAllLeafColumns().some((col) => col.getIsVisible()) && !table.getAllLeafColumns().every((col) => col.getIsVisible());
|
|
4469
|
+
}
|
|
4470
|
+
},
|
|
4471
|
+
onChange: (e) => {
|
|
4472
|
+
table.getAllLeafColumns().forEach(
|
|
4473
|
+
(col) => col.toggleVisibility(e.target.checked)
|
|
4474
|
+
);
|
|
4475
|
+
}
|
|
4286
4476
|
}
|
|
4287
4477
|
),
|
|
4288
|
-
|
|
4289
|
-
] },
|
|
4290
|
-
|
|
4478
|
+
"Toggle All"
|
|
4479
|
+
] }),
|
|
4480
|
+
table.getAllLeafColumns().map((column) => {
|
|
4481
|
+
const header = column.columnDef.header;
|
|
4482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "flex items-center gap-2 text-sm", children: [
|
|
4483
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4484
|
+
"input",
|
|
4485
|
+
{
|
|
4486
|
+
type: "checkbox",
|
|
4487
|
+
checked: column.getIsVisible(),
|
|
4488
|
+
onChange: (e) => column.toggleVisibility(e.target.checked)
|
|
4489
|
+
}
|
|
4490
|
+
),
|
|
4491
|
+
typeof header === "function" ? header({ column, header, table }) : typeof header === "string" ? header : column.id
|
|
4492
|
+
] }, column.id);
|
|
4493
|
+
})
|
|
4494
|
+
] })
|
|
4291
4495
|
] })
|
|
4292
4496
|
] })
|
|
4293
4497
|
] }),
|
|
@@ -4386,7 +4590,22 @@ function DataTable({
|
|
|
4386
4590
|
`header-${header.id}-${index}`
|
|
4387
4591
|
);
|
|
4388
4592
|
}) }, `header-group-${hg.id}`)) }),
|
|
4389
|
-
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(TableBody, { children: loading ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_jsx_runtime51.Fragment, { children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(TableRow, { children:
|
|
4593
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(TableBody, { children: loading ? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_jsx_runtime51.Fragment, { children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(TableRow, { children: table.getHeaderGroups()[0].headers.map((header, j) => {
|
|
4594
|
+
const column = header.column;
|
|
4595
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4596
|
+
TableCell,
|
|
4597
|
+
{
|
|
4598
|
+
className: "p-3",
|
|
4599
|
+
style: {
|
|
4600
|
+
width: column.getSize(),
|
|
4601
|
+
minWidth: column.columnDef.minSize,
|
|
4602
|
+
maxWidth: column.columnDef.maxSize
|
|
4603
|
+
},
|
|
4604
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "h-4 bg-gray-200 rounded w-full block animate-pulse" })
|
|
4605
|
+
},
|
|
4606
|
+
j
|
|
4607
|
+
);
|
|
4608
|
+
}) }, i)) }) : table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(TableRow, { children: row.getVisibleCells().map((cell, cellIndex, arr) => {
|
|
4390
4609
|
const meta = cell.column.columnDef.meta || {};
|
|
4391
4610
|
const isClickable = meta?.isClickable;
|
|
4392
4611
|
const isLastCell = cellIndex === arr.length - 1;
|
|
@@ -5823,7 +6042,7 @@ function Navbar({
|
|
|
5823
6042
|
|
|
5824
6043
|
// src/components/Chart/BarChart.tsx
|
|
5825
6044
|
var import_react36 = __toESM(require("react"));
|
|
5826
|
-
var
|
|
6045
|
+
var import_axios4 = __toESM(require("axios"));
|
|
5827
6046
|
var import_recharts = require("recharts");
|
|
5828
6047
|
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
5829
6048
|
var getRandomColor = () => {
|
|
@@ -5903,7 +6122,7 @@ var ChartComponent = ({
|
|
|
5903
6122
|
page: page.toString(),
|
|
5904
6123
|
limit: limit.toString()
|
|
5905
6124
|
});
|
|
5906
|
-
const axiosClient = props.axiosInstance ??
|
|
6125
|
+
const axiosClient = props.axiosInstance ?? import_axios4.default;
|
|
5907
6126
|
const res = await axiosClient.get(`${apiUrl}?${params.toString()}`, {
|
|
5908
6127
|
withCredentials: true
|
|
5909
6128
|
});
|
|
@@ -6131,7 +6350,7 @@ var BarChart_default = import_react36.default.memo(ChartComponent);
|
|
|
6131
6350
|
|
|
6132
6351
|
// src/components/Chart/PieChart.tsx
|
|
6133
6352
|
var import_react37 = __toESM(require("react"));
|
|
6134
|
-
var
|
|
6353
|
+
var import_axios5 = __toESM(require("axios"));
|
|
6135
6354
|
var import_recharts2 = require("recharts");
|
|
6136
6355
|
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
6137
6356
|
var getRandomColor2 = () => {
|
|
@@ -6220,7 +6439,7 @@ var DonutChart = ({
|
|
|
6220
6439
|
const fetchData = async () => {
|
|
6221
6440
|
try {
|
|
6222
6441
|
setLocalLoading(true);
|
|
6223
|
-
const axiosClient = props.axiosInstance ??
|
|
6442
|
+
const axiosClient = props.axiosInstance ?? import_axios5.default;
|
|
6224
6443
|
const res = await axiosClient.get(apiUrl, {
|
|
6225
6444
|
withCredentials: true
|
|
6226
6445
|
});
|