@algorithm-shift/design-system 1.3.107 → 1.3.109
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 -9
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +292 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +307 -107
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -168,6 +168,7 @@ interface StagesProps extends ElementProps {
|
|
|
168
168
|
triggerOnClick?: boolean;
|
|
169
169
|
saving?: boolean;
|
|
170
170
|
canvasMode?: 'desktop' | 'tablet' | 'mobile' | 'app';
|
|
171
|
+
primaryColor?: string
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
type ButtonProps = ElementProps & React.ComponentProps<"button"> & {
|
|
@@ -494,7 +495,7 @@ declare const HistoryTimeline: ({ title, className, loading, titleKey, descripti
|
|
|
494
495
|
|
|
495
496
|
declare const Tabs: ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder, source, parentKey, menuNameKey, menuUrlKey, loading, bgActiveColor, textActiveColor }: TabsProps) => react_jsx_runtime.JSX.Element;
|
|
496
497
|
|
|
497
|
-
declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey, dataLabel, loading, saving, triggerOnClick, canvasMode }: StagesProps) => react_jsx_runtime.JSX.Element;
|
|
498
|
+
declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey, dataLabel, loading, saving, triggerOnClick, canvasMode, ...props }: StagesProps) => react_jsx_runtime.JSX.Element;
|
|
498
499
|
|
|
499
500
|
declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
|
|
500
501
|
|
package/dist/index.d.ts
CHANGED
|
@@ -168,6 +168,7 @@ interface StagesProps extends ElementProps {
|
|
|
168
168
|
triggerOnClick?: boolean;
|
|
169
169
|
saving?: boolean;
|
|
170
170
|
canvasMode?: 'desktop' | 'tablet' | 'mobile' | 'app';
|
|
171
|
+
primaryColor?: string
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
type ButtonProps = ElementProps & React.ComponentProps<"button"> & {
|
|
@@ -494,7 +495,7 @@ declare const HistoryTimeline: ({ title, className, loading, titleKey, descripti
|
|
|
494
495
|
|
|
495
496
|
declare const Tabs: ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder, source, parentKey, menuNameKey, menuUrlKey, loading, bgActiveColor, textActiveColor }: TabsProps) => react_jsx_runtime.JSX.Element;
|
|
496
497
|
|
|
497
|
-
declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey, dataLabel, loading, saving, triggerOnClick, canvasMode }: StagesProps) => react_jsx_runtime.JSX.Element;
|
|
498
|
+
declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey, dataLabel, loading, saving, triggerOnClick, canvasMode, ...props }: StagesProps) => react_jsx_runtime.JSX.Element;
|
|
498
499
|
|
|
499
500
|
declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
|
|
500
501
|
|
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
|
|
@@ -3780,11 +3781,9 @@ var valueFormatter = (value, format3, customFormatters = {}) => {
|
|
|
3780
3781
|
case "date":
|
|
3781
3782
|
return dayjs_setup_default(value).format(arg || "YYYY-MM-DD");
|
|
3782
3783
|
case "datetimenumber":
|
|
3783
|
-
|
|
3784
|
-
return parsed.format("YYYY-MM-DD hh:mm");
|
|
3784
|
+
return dayjs_setup_default(value).format("YYYY-MM-DD hh:mm");
|
|
3785
3785
|
case "datetime":
|
|
3786
|
-
|
|
3787
|
-
return formated.format("DD MMM YYYY hh:mm A");
|
|
3786
|
+
return dayjs_setup_default(value).format("DD MMM YYYY hh:mm A");
|
|
3788
3787
|
case "days":
|
|
3789
3788
|
return `${dayjs_setup_default().diff(dayjs_setup_default(value), "day")} days`;
|
|
3790
3789
|
case "months":
|
|
@@ -4101,13 +4100,153 @@ function DataTable({
|
|
|
4101
4100
|
onDeleteRow,
|
|
4102
4101
|
rowActions,
|
|
4103
4102
|
enableRowSelection = false,
|
|
4104
|
-
getRowSelection
|
|
4103
|
+
getRowSelection,
|
|
4104
|
+
tableId,
|
|
4105
|
+
manageColumns = false,
|
|
4106
|
+
preferenceUrl,
|
|
4107
|
+
axiosInstance
|
|
4105
4108
|
}) {
|
|
4106
4109
|
const [columnFilters, setColumnFilters] = React11.useState([]);
|
|
4107
4110
|
const [columnVisibility, setColumnVisibility] = React11.useState({});
|
|
4111
|
+
const hasLoadedInitialState = React11.useRef(false);
|
|
4112
|
+
const isSavingRef = React11.useRef(false);
|
|
4113
|
+
const isFetchingRef = React11.useRef(false);
|
|
4114
|
+
const transformApiToFrontend = React11.useCallback((apiSettings, allColumnIds) => {
|
|
4115
|
+
if (!apiSettings || !apiSettings.columns || !apiSettings.columns.visible) {
|
|
4116
|
+
return {};
|
|
4117
|
+
}
|
|
4118
|
+
const visibleColumns = apiSettings.columns.visible;
|
|
4119
|
+
const result = {};
|
|
4120
|
+
allColumnIds.forEach((colId) => {
|
|
4121
|
+
result[colId] = visibleColumns.includes(colId);
|
|
4122
|
+
});
|
|
4123
|
+
return result;
|
|
4124
|
+
}, []);
|
|
4125
|
+
const transformFrontendToApi = React11.useCallback((visibility) => {
|
|
4126
|
+
const visibleColumns = Object.keys(visibility).filter((colId) => visibility[colId] === true);
|
|
4127
|
+
return {
|
|
4128
|
+
columns: {
|
|
4129
|
+
visible: visibleColumns
|
|
4130
|
+
}
|
|
4131
|
+
};
|
|
4132
|
+
}, []);
|
|
4133
|
+
const fetchColumnPreferences = React11.useCallback(async () => {
|
|
4134
|
+
if (isFetchingRef.current) {
|
|
4135
|
+
return;
|
|
4136
|
+
}
|
|
4137
|
+
if (!tableId || !manageColumns) {
|
|
4138
|
+
hasLoadedInitialState.current = true;
|
|
4139
|
+
return;
|
|
4140
|
+
}
|
|
4141
|
+
isFetchingRef.current = true;
|
|
4142
|
+
try {
|
|
4143
|
+
const entityKey = `table:${tableId}`;
|
|
4144
|
+
const apiUrl = `${preferenceUrl}/${encodeURIComponent(entityKey)}`;
|
|
4145
|
+
const axiosClient = axiosInstance ?? import_axios3.default;
|
|
4146
|
+
const response = await axiosClient.get(apiUrl, {
|
|
4147
|
+
withCredentials: true
|
|
4148
|
+
});
|
|
4149
|
+
if (response) {
|
|
4150
|
+
const data2 = response.data;
|
|
4151
|
+
if (data2.success && data2.data && data2.data.exists && data2.data.settings) {
|
|
4152
|
+
let allColumnIds = [];
|
|
4153
|
+
if (tableRef.current) {
|
|
4154
|
+
allColumnIds = tableRef.current.getAllLeafColumns().map((col) => col.id).filter(Boolean);
|
|
4155
|
+
} else {
|
|
4156
|
+
allColumnIds = columns.map((col) => {
|
|
4157
|
+
if (typeof col.id === "string") {
|
|
4158
|
+
return col.id;
|
|
4159
|
+
}
|
|
4160
|
+
if (col.accessorKey) {
|
|
4161
|
+
return col.accessorKey;
|
|
4162
|
+
}
|
|
4163
|
+
return null;
|
|
4164
|
+
}).filter((id) => !!id);
|
|
4165
|
+
if (enableRowSelection && !allColumnIds.includes("__select__")) {
|
|
4166
|
+
allColumnIds.unshift("__select__");
|
|
4167
|
+
}
|
|
4168
|
+
}
|
|
4169
|
+
if (allColumnIds.length > 0) {
|
|
4170
|
+
const transformed = transformApiToFrontend(data2.data.settings, allColumnIds);
|
|
4171
|
+
console.log("[DataTable] Loaded column preferences:", {
|
|
4172
|
+
visibleColumns: data2.data.settings.columns?.visible,
|
|
4173
|
+
allColumnIds,
|
|
4174
|
+
transformed
|
|
4175
|
+
});
|
|
4176
|
+
if (Object.keys(transformed).length > 0) {
|
|
4177
|
+
setColumnVisibility(transformed);
|
|
4178
|
+
}
|
|
4179
|
+
}
|
|
4180
|
+
} else {
|
|
4181
|
+
console.log("[DataTable] No saved preferences found, using default visibility");
|
|
4182
|
+
}
|
|
4183
|
+
} else {
|
|
4184
|
+
console.warn("Failed to fetch column preferences:", response);
|
|
4185
|
+
}
|
|
4186
|
+
} catch (error) {
|
|
4187
|
+
console.error("Error fetching column preferences:", error);
|
|
4188
|
+
} finally {
|
|
4189
|
+
hasLoadedInitialState.current = true;
|
|
4190
|
+
isFetchingRef.current = false;
|
|
4191
|
+
}
|
|
4192
|
+
}, [tableId, transformApiToFrontend, manageColumns]);
|
|
4193
|
+
const saveColumnPreferences = React11.useCallback(async (visibility) => {
|
|
4194
|
+
if (!tableId || isSavingRef.current || !manageColumns) {
|
|
4195
|
+
return;
|
|
4196
|
+
}
|
|
4197
|
+
isSavingRef.current = true;
|
|
4198
|
+
try {
|
|
4199
|
+
const entityKey = `table:${tableId}`;
|
|
4200
|
+
const apiUrl = `${preferenceUrl}/${encodeURIComponent(entityKey)}`;
|
|
4201
|
+
const settings = transformFrontendToApi(visibility);
|
|
4202
|
+
const requestBody = {
|
|
4203
|
+
settings,
|
|
4204
|
+
is_default: true
|
|
4205
|
+
};
|
|
4206
|
+
const axiosClient = axiosInstance ?? import_axios3.default;
|
|
4207
|
+
const response = await axiosClient.post(apiUrl, requestBody, {
|
|
4208
|
+
withCredentials: true
|
|
4209
|
+
});
|
|
4210
|
+
if (!response) {
|
|
4211
|
+
console.error("Failed to save column preferences:", response);
|
|
4212
|
+
}
|
|
4213
|
+
} catch (error) {
|
|
4214
|
+
console.error("Error saving column preferences:", error);
|
|
4215
|
+
} finally {
|
|
4216
|
+
isSavingRef.current = false;
|
|
4217
|
+
}
|
|
4218
|
+
}, [tableId, transformFrontendToApi, manageColumns]);
|
|
4219
|
+
React11.useEffect(() => {
|
|
4220
|
+
if (hasLoadedInitialState.current || isFetchingRef.current) {
|
|
4221
|
+
return;
|
|
4222
|
+
}
|
|
4223
|
+
if (!tableId) {
|
|
4224
|
+
return;
|
|
4225
|
+
}
|
|
4226
|
+
if (manageColumns) {
|
|
4227
|
+
fetchColumnPreferences();
|
|
4228
|
+
}
|
|
4229
|
+
}, [tableId, manageColumns]);
|
|
4108
4230
|
const [manualSort, setManualSort] = React11.useState(null);
|
|
4109
4231
|
const [searchTerm, setSearchTerm] = React11.useState("");
|
|
4110
4232
|
const tableData = Array.isArray(data) ? data : [];
|
|
4233
|
+
const filteredData = React11.useMemo(() => {
|
|
4234
|
+
if (paginationMode === "client" && globalSearch && searchTerm.trim()) {
|
|
4235
|
+
const searchLower = searchTerm.toLowerCase().trim();
|
|
4236
|
+
return tableData.filter((row) => {
|
|
4237
|
+
return columns.some((column) => {
|
|
4238
|
+
const columnId = typeof column.id === "string" ? column.id : column.accessorKey;
|
|
4239
|
+
if (!columnId) return false;
|
|
4240
|
+
const accessorFn = column.accessorFn;
|
|
4241
|
+
const cellValue = accessorFn ? accessorFn(row, 0) : row[columnId];
|
|
4242
|
+
const cellValueStr = cellValue != null ? String(cellValue).toLowerCase() : "";
|
|
4243
|
+
return cellValueStr.includes(searchLower);
|
|
4244
|
+
});
|
|
4245
|
+
});
|
|
4246
|
+
}
|
|
4247
|
+
return tableData;
|
|
4248
|
+
}, [tableData, searchTerm, paginationMode, globalSearch, columns]);
|
|
4249
|
+
const finalData = paginationMode === "client" && globalSearch ? filteredData : tableData;
|
|
4111
4250
|
const finalCols = [...columns];
|
|
4112
4251
|
if (enableRowSelection) {
|
|
4113
4252
|
finalCols.unshift({
|
|
@@ -4134,44 +4273,89 @@ function DataTable({
|
|
|
4134
4273
|
const dynamicCols = useDynamicColumns({ columns: finalCols, enableRowSelection });
|
|
4135
4274
|
const [rowSelection, setRowSelection] = React11.useState({});
|
|
4136
4275
|
const [localPageSize, setLocalPageSize] = React11.useState(pageSize);
|
|
4276
|
+
const [localPageIndex, setLocalPageIndex] = React11.useState(0);
|
|
4277
|
+
const isUpdatingPageSizeRef = React11.useRef(false);
|
|
4278
|
+
const tableRef = React11.useRef(null);
|
|
4279
|
+
React11.useEffect(() => {
|
|
4280
|
+
if (paginationMode === "client") {
|
|
4281
|
+
setLocalPageSize(pageSize);
|
|
4282
|
+
}
|
|
4283
|
+
}, [pageSize, paginationMode]);
|
|
4137
4284
|
const table = (0, import_react_table2.useReactTable)({
|
|
4138
|
-
data:
|
|
4285
|
+
data: finalData,
|
|
4139
4286
|
columns: dynamicCols,
|
|
4287
|
+
initialState: {
|
|
4288
|
+
pagination: {
|
|
4289
|
+
pageIndex: 0,
|
|
4290
|
+
pageSize
|
|
4291
|
+
}
|
|
4292
|
+
},
|
|
4140
4293
|
state: {
|
|
4141
4294
|
columnFilters,
|
|
4142
4295
|
columnVisibility,
|
|
4143
4296
|
rowSelection,
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
}
|
|
4149
|
-
} : {}
|
|
4297
|
+
pagination: {
|
|
4298
|
+
pageIndex: paginationMode === "server" ? controlledPageIndex ?? 0 : localPageIndex,
|
|
4299
|
+
pageSize: localPageSize
|
|
4300
|
+
}
|
|
4150
4301
|
},
|
|
4151
4302
|
enableRowSelection: !!enableRowSelection,
|
|
4152
4303
|
onRowSelectionChange: (updater) => {
|
|
4153
4304
|
setRowSelection((old) => {
|
|
4154
4305
|
const newState = typeof updater === "function" ? updater(old) : updater;
|
|
4155
|
-
const selectedData = Object.keys(newState).filter((key) => newState[key]).map((rowId) =>
|
|
4306
|
+
const selectedData = Object.keys(newState).filter((key) => newState[key]).map((rowId) => finalData[Number(rowId)]);
|
|
4156
4307
|
getRowSelection?.({ rows: selectedData });
|
|
4157
4308
|
return newState;
|
|
4158
4309
|
});
|
|
4159
4310
|
},
|
|
4160
4311
|
onColumnFiltersChange: setColumnFilters,
|
|
4161
|
-
onColumnVisibilityChange:
|
|
4312
|
+
onColumnVisibilityChange: (updater) => {
|
|
4313
|
+
setColumnVisibility((old) => {
|
|
4314
|
+
const newState = typeof updater === "function" ? updater(old) : updater;
|
|
4315
|
+
setTimeout(() => {
|
|
4316
|
+
if (tableRef.current && tableId && hasLoadedInitialState.current) {
|
|
4317
|
+
try {
|
|
4318
|
+
const completeVisibility = {};
|
|
4319
|
+
tableRef.current.getAllLeafColumns().forEach((column) => {
|
|
4320
|
+
completeVisibility[column.id] = column.getIsVisible();
|
|
4321
|
+
});
|
|
4322
|
+
if (Object.keys(completeVisibility).length > 0) {
|
|
4323
|
+
saveColumnPreferences(completeVisibility);
|
|
4324
|
+
}
|
|
4325
|
+
} catch (error) {
|
|
4326
|
+
console.error("Error saving column visibility to API:", error);
|
|
4327
|
+
}
|
|
4328
|
+
}
|
|
4329
|
+
}, 0);
|
|
4330
|
+
return newState;
|
|
4331
|
+
});
|
|
4332
|
+
},
|
|
4162
4333
|
getCoreRowModel: (0, import_react_table2.getCoreRowModel)(),
|
|
4163
4334
|
getFilteredRowModel: (0, import_react_table2.getFilteredRowModel)(),
|
|
4164
4335
|
getPaginationRowModel: pagination && paginationMode === "client" ? (0, import_react_table2.getPaginationRowModel)() : void 0,
|
|
4165
4336
|
manualPagination: paginationMode === "server",
|
|
4166
4337
|
pageCount: paginationMode === "server" ? Math.ceil(totalRecords / localPageSize) : void 0,
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4338
|
+
onPaginationChange: (updater) => {
|
|
4339
|
+
if (isUpdatingPageSizeRef.current) {
|
|
4340
|
+
isUpdatingPageSizeRef.current = false;
|
|
4341
|
+
return;
|
|
4342
|
+
}
|
|
4343
|
+
const prev = table.getState().pagination;
|
|
4344
|
+
const next = typeof updater === "function" ? updater(prev) : updater;
|
|
4345
|
+
if (paginationMode === "server") {
|
|
4171
4346
|
onPageChange?.(next.pageIndex, next.pageSize);
|
|
4347
|
+
} else {
|
|
4348
|
+
setLocalPageIndex(next.pageIndex);
|
|
4349
|
+
setLocalPageSize(next.pageSize);
|
|
4172
4350
|
}
|
|
4173
|
-
}
|
|
4351
|
+
}
|
|
4174
4352
|
});
|
|
4353
|
+
React11.useEffect(() => {
|
|
4354
|
+
tableRef.current = table;
|
|
4355
|
+
if (table && !hasLoadedInitialState.current && !isFetchingRef.current && tableId) {
|
|
4356
|
+
fetchColumnPreferences();
|
|
4357
|
+
}
|
|
4358
|
+
}, [table, tableId]);
|
|
4175
4359
|
const getPageNumbers = (currentPage, totalPages, maxVisiblePages = 5) => {
|
|
4176
4360
|
if (totalPages <= maxVisiblePages) {
|
|
4177
4361
|
return Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
@@ -4194,17 +4378,26 @@ function DataTable({
|
|
|
4194
4378
|
const pageCount = table.getPageCount() === 0 ? 1 : table.getPageCount();
|
|
4195
4379
|
const handlePageSizeChange = (e) => {
|
|
4196
4380
|
const newSize = Number(e.target.value);
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4381
|
+
if (paginationMode === "server") {
|
|
4382
|
+
const currentPageIndex = table.getState().pagination.pageIndex;
|
|
4383
|
+
onPageChange?.(currentPageIndex, newSize);
|
|
4384
|
+
setLocalPageSize(newSize);
|
|
4385
|
+
} else {
|
|
4386
|
+
isUpdatingPageSizeRef.current = true;
|
|
4387
|
+
setLocalPageSize(newSize);
|
|
4388
|
+
setLocalPageIndex(0);
|
|
4389
|
+
}
|
|
4200
4390
|
};
|
|
4201
4391
|
const pageSizeOptions = React11.useMemo(() => {
|
|
4392
|
+
if (paginationMode === "client") {
|
|
4393
|
+
return [5, 10, 20, 50, 100];
|
|
4394
|
+
}
|
|
4202
4395
|
const options = [5, 10, 20, 50, 100].filter((size) => size < totalRecords);
|
|
4203
4396
|
if (options.length === 0) {
|
|
4204
4397
|
options.push(5);
|
|
4205
4398
|
}
|
|
4206
4399
|
return options;
|
|
4207
|
-
}, [totalRecords]);
|
|
4400
|
+
}, [paginationMode, totalRecords]);
|
|
4208
4401
|
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "overflow-hidden rounded-md w-full", children: [
|
|
4209
4402
|
!loading && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex justify-between p-2 bg-gray-50", children: [
|
|
4210
4403
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center gap-4 w-full", children: [
|
|
@@ -4220,10 +4413,17 @@ function DataTable({
|
|
|
4220
4413
|
type: "text",
|
|
4221
4414
|
placeholder: "Search...",
|
|
4222
4415
|
value: searchTerm,
|
|
4223
|
-
onChange: (e) =>
|
|
4416
|
+
onChange: (e) => {
|
|
4417
|
+
setSearchTerm(e.target.value);
|
|
4418
|
+
if (paginationMode === "client") {
|
|
4419
|
+
setLocalPageIndex(0);
|
|
4420
|
+
}
|
|
4421
|
+
},
|
|
4224
4422
|
onKeyDown: (e) => {
|
|
4225
|
-
if (e.key === "Enter"
|
|
4226
|
-
onGlobalSearch
|
|
4423
|
+
if (e.key === "Enter") {
|
|
4424
|
+
if (paginationMode === "server" && onGlobalSearch) {
|
|
4425
|
+
onGlobalSearch(searchTerm.trim());
|
|
4426
|
+
}
|
|
4227
4427
|
}
|
|
4228
4428
|
},
|
|
4229
4429
|
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 +4431,7 @@ function DataTable({
|
|
|
4231
4431
|
),
|
|
4232
4432
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_lucide_react12.Search, { className: "absolute left-2 top-2.5 text-gray-400", size: 16 })
|
|
4233
4433
|
] }),
|
|
4234
|
-
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4434
|
+
paginationMode === "server" && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4235
4435
|
Button,
|
|
4236
4436
|
{
|
|
4237
4437
|
size: "sm",
|
|
@@ -4242,7 +4442,7 @@ function DataTable({
|
|
|
4242
4442
|
)
|
|
4243
4443
|
] })
|
|
4244
4444
|
] }),
|
|
4245
|
-
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Popover, { children: [
|
|
4445
|
+
manageColumns && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Popover, { children: [
|
|
4246
4446
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4247
4447
|
Button,
|
|
4248
4448
|
{
|
|
@@ -4252,42 +4452,44 @@ function DataTable({
|
|
|
4252
4452
|
children: "Manage Columns"
|
|
4253
4453
|
}
|
|
4254
4454
|
) }),
|
|
4255
|
-
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(PopoverContent, { align: "end", className: "w-48 p-3
|
|
4455
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(PopoverContent, { align: "end", className: "w-48 p-3", children: [
|
|
4256
4456
|
/* @__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: [
|
|
4457
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "max-h-56 overflow-y-auto pr-1 space-y-2", children: [
|
|
4458
|
+
/* @__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
4459
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4281
4460
|
"input",
|
|
4282
4461
|
{
|
|
4283
4462
|
type: "checkbox",
|
|
4284
|
-
checked:
|
|
4285
|
-
|
|
4463
|
+
checked: table.getAllLeafColumns().every((col) => col.getIsVisible()),
|
|
4464
|
+
ref: (input) => {
|
|
4465
|
+
if (input) {
|
|
4466
|
+
input.indeterminate = table.getAllLeafColumns().some((col) => col.getIsVisible()) && !table.getAllLeafColumns().every((col) => col.getIsVisible());
|
|
4467
|
+
}
|
|
4468
|
+
},
|
|
4469
|
+
onChange: (e) => {
|
|
4470
|
+
table.getAllLeafColumns().forEach(
|
|
4471
|
+
(col) => col.toggleVisibility(e.target.checked)
|
|
4472
|
+
);
|
|
4473
|
+
}
|
|
4286
4474
|
}
|
|
4287
4475
|
),
|
|
4288
|
-
|
|
4289
|
-
] },
|
|
4290
|
-
|
|
4476
|
+
"Toggle All"
|
|
4477
|
+
] }),
|
|
4478
|
+
table.getAllLeafColumns().map((column) => {
|
|
4479
|
+
const header = column.columnDef.header;
|
|
4480
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "flex items-center gap-2 text-sm", children: [
|
|
4481
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4482
|
+
"input",
|
|
4483
|
+
{
|
|
4484
|
+
type: "checkbox",
|
|
4485
|
+
checked: column.getIsVisible(),
|
|
4486
|
+
onChange: (e) => column.toggleVisibility(e.target.checked)
|
|
4487
|
+
}
|
|
4488
|
+
),
|
|
4489
|
+
typeof header === "function" ? header({ column, header, table }) : typeof header === "string" ? header : column.id
|
|
4490
|
+
] }, column.id);
|
|
4491
|
+
})
|
|
4492
|
+
] })
|
|
4291
4493
|
] })
|
|
4292
4494
|
] })
|
|
4293
4495
|
] }),
|
|
@@ -4386,7 +4588,22 @@ function DataTable({
|
|
|
4386
4588
|
`header-${header.id}-${index}`
|
|
4387
4589
|
);
|
|
4388
4590
|
}) }, `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:
|
|
4591
|
+
/* @__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) => {
|
|
4592
|
+
const column = header.column;
|
|
4593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
4594
|
+
TableCell,
|
|
4595
|
+
{
|
|
4596
|
+
className: "p-3",
|
|
4597
|
+
style: {
|
|
4598
|
+
width: column.getSize(),
|
|
4599
|
+
minWidth: column.columnDef.minSize,
|
|
4600
|
+
maxWidth: column.columnDef.maxSize
|
|
4601
|
+
},
|
|
4602
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "h-4 bg-gray-200 rounded w-full block animate-pulse" })
|
|
4603
|
+
},
|
|
4604
|
+
j
|
|
4605
|
+
);
|
|
4606
|
+
}) }, 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
4607
|
const meta = cell.column.columnDef.meta || {};
|
|
4391
4608
|
const isClickable = meta?.isClickable;
|
|
4392
4609
|
const isLastCell = cellIndex === arr.length - 1;
|
|
@@ -5410,29 +5627,6 @@ function TooltipTrigger({
|
|
|
5410
5627
|
}) {
|
|
5411
5628
|
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
5412
5629
|
}
|
|
5413
|
-
function TooltipContent({
|
|
5414
|
-
className,
|
|
5415
|
-
sideOffset = 0,
|
|
5416
|
-
children,
|
|
5417
|
-
...props
|
|
5418
|
-
}) {
|
|
5419
|
-
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(TooltipPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
|
|
5420
|
-
TooltipPrimitive.Content,
|
|
5421
|
-
{
|
|
5422
|
-
"data-slot": "tooltip-content",
|
|
5423
|
-
sideOffset,
|
|
5424
|
-
className: cn(
|
|
5425
|
-
"bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
|
|
5426
|
-
className
|
|
5427
|
-
),
|
|
5428
|
-
...props,
|
|
5429
|
-
children: [
|
|
5430
|
-
children,
|
|
5431
|
-
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(TooltipPrimitive.Arrow, { className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
|
|
5432
|
-
]
|
|
5433
|
-
}
|
|
5434
|
-
) });
|
|
5435
|
-
}
|
|
5436
5630
|
|
|
5437
5631
|
// src/components/Navigation/Stages/Stages.tsx
|
|
5438
5632
|
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
@@ -5449,7 +5643,8 @@ var StagesComponent = ({
|
|
|
5449
5643
|
loading,
|
|
5450
5644
|
saving,
|
|
5451
5645
|
triggerOnClick = false,
|
|
5452
|
-
canvasMode = "desktop"
|
|
5646
|
+
canvasMode = "desktop",
|
|
5647
|
+
...props
|
|
5453
5648
|
}) => {
|
|
5454
5649
|
const [activeStage, setActiveStage] = (0, import_react34.useState)("");
|
|
5455
5650
|
const [isCompleted, setIsCompleted] = (0, import_react34.useState)(false);
|
|
@@ -5527,6 +5722,7 @@ var StagesComponent = ({
|
|
|
5527
5722
|
}, [currentStage, stages]);
|
|
5528
5723
|
const isAllStagesCompleted = isCompleted || activeRootStage?.[dataKey] === lastStage;
|
|
5529
5724
|
const disabled = isAllStagesCompleted || loading || saving;
|
|
5725
|
+
const primaryColor = props.primaryColor || "#12715b";
|
|
5530
5726
|
return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className, style, children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
|
|
5531
5727
|
"div",
|
|
5532
5728
|
{
|
|
@@ -5564,16 +5760,19 @@ var StagesComponent = ({
|
|
|
5564
5760
|
const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
|
|
5565
5761
|
const isCompletedStage = isAllStagesCompleted || index <= currentIndex;
|
|
5566
5762
|
const isActive = !isAllStagesCompleted && index === currentIndex;
|
|
5567
|
-
let stageColor =
|
|
5763
|
+
let stageColor = `text-[${primaryColor}] border-2 border-[${primaryColor}]`;
|
|
5764
|
+
let stageStyle = { borderColor: primaryColor, color: isActive ? "white" : primaryColor, backgroundColor: isActive ? primaryColor : "transparent" };
|
|
5568
5765
|
if (stage.hasOwnProperty("isSuccess") && stage.isSuccess === false) {
|
|
5569
|
-
stageColor =
|
|
5766
|
+
stageColor = `bg-red-50 text-red-700 border-2 border-red-700`;
|
|
5767
|
+
stageStyle = { borderColor: "red", color: "red", backgroundColor: "transparent" };
|
|
5570
5768
|
}
|
|
5571
5769
|
let stageLabel = stage[dataLabel];
|
|
5572
5770
|
if (stage[dataKey] !== activeChildStage?.[dataKey] && activeRootStage?.[dataKey] === stage[dataKey]) {
|
|
5573
5771
|
stageLabel = activeChildStage?.[dataLabel] || stageLabel;
|
|
5574
|
-
stageColor =
|
|
5772
|
+
stageColor = `text-[${primaryColor}] border-2 border-[${primaryColor}]`;
|
|
5575
5773
|
if (activeChildStage.hasOwnProperty("isSuccess") && activeChildStage.isSuccess === false) {
|
|
5576
5774
|
stageColor = "bg-red-50 text-red-700 border-2 border-red-700";
|
|
5775
|
+
stageStyle = { borderColor: "red", color: "red", backgroundColor: "transparent" };
|
|
5577
5776
|
}
|
|
5578
5777
|
}
|
|
5579
5778
|
const stageKey = typeof stage[dataKey] === "string" ? stage[dataKey] : JSON.stringify(stage[dataKey]);
|
|
@@ -5585,17 +5784,17 @@ var StagesComponent = ({
|
|
|
5585
5784
|
min-w-[70px] sm:min-w-[80px] w-full sm:w-auto px-3 sm:px-4 py-1.5 sm:py-2
|
|
5586
5785
|
rounded-full text-xs sm:text-sm font-medium transition-colors duration-200
|
|
5587
5786
|
whitespace-normal sm:whitespace-nowrap flex-shrink-0 max-w-[150px] text-ellipsis overflow-hidden
|
|
5588
|
-
${isActive ?
|
|
5787
|
+
${isActive ? `bg-[${primaryColor}] text-white shadow-md` : isCompletedStage ? stageColor : "bg-white border border-gray-200"}
|
|
5589
5788
|
${isMobile ? "flex-1 text-center py-2.5" : ""}
|
|
5590
5789
|
`,
|
|
5591
5790
|
onClick: () => {
|
|
5592
5791
|
if (isAllStagesCompleted) return;
|
|
5593
5792
|
onStageClick(stage[dataKey]);
|
|
5594
5793
|
},
|
|
5794
|
+
style: stageStyle,
|
|
5595
5795
|
children: stageLabel
|
|
5596
5796
|
}
|
|
5597
5797
|
) }),
|
|
5598
|
-
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(TooltipContent, { className: "max-w-[400px] p-3 text-xs text-muted-foreground space-y-2", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("b", { children: stageLabel }) }) }),
|
|
5599
5798
|
!isMobile && index < stages.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "hidden sm:flex sm:flex-shrink-0 w-3 h-px bg-gray-300 sm:w-4" })
|
|
5600
5799
|
] }, stageKey) }, stageKey);
|
|
5601
5800
|
})
|
|
@@ -5612,12 +5811,13 @@ var StagesComponent = ({
|
|
|
5612
5811
|
"button",
|
|
5613
5812
|
{
|
|
5614
5813
|
className: `
|
|
5615
|
-
w-full lg:w-auto
|
|
5814
|
+
w-full lg:w-auto text-white px-4 lg:px-6 py-2.5
|
|
5616
5815
|
rounded-lg text-sm font-medium transition-colors duration-200
|
|
5617
5816
|
shadow-sm ${disabled ? "opacity-50 cursor-not-allowed" : "hover:shadow-md"}
|
|
5618
5817
|
`,
|
|
5619
5818
|
onClick: nextStage,
|
|
5620
5819
|
disabled,
|
|
5820
|
+
style: { backgroundColor: primaryColor },
|
|
5621
5821
|
children: saving ? "Updating..." : buttonText
|
|
5622
5822
|
}
|
|
5623
5823
|
)
|
|
@@ -5823,7 +6023,7 @@ function Navbar({
|
|
|
5823
6023
|
|
|
5824
6024
|
// src/components/Chart/BarChart.tsx
|
|
5825
6025
|
var import_react36 = __toESM(require("react"));
|
|
5826
|
-
var
|
|
6026
|
+
var import_axios4 = __toESM(require("axios"));
|
|
5827
6027
|
var import_recharts = require("recharts");
|
|
5828
6028
|
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
5829
6029
|
var getRandomColor = () => {
|
|
@@ -5903,7 +6103,7 @@ var ChartComponent = ({
|
|
|
5903
6103
|
page: page.toString(),
|
|
5904
6104
|
limit: limit.toString()
|
|
5905
6105
|
});
|
|
5906
|
-
const axiosClient = props.axiosInstance ??
|
|
6106
|
+
const axiosClient = props.axiosInstance ?? import_axios4.default;
|
|
5907
6107
|
const res = await axiosClient.get(`${apiUrl}?${params.toString()}`, {
|
|
5908
6108
|
withCredentials: true
|
|
5909
6109
|
});
|
|
@@ -6131,7 +6331,7 @@ var BarChart_default = import_react36.default.memo(ChartComponent);
|
|
|
6131
6331
|
|
|
6132
6332
|
// src/components/Chart/PieChart.tsx
|
|
6133
6333
|
var import_react37 = __toESM(require("react"));
|
|
6134
|
-
var
|
|
6334
|
+
var import_axios5 = __toESM(require("axios"));
|
|
6135
6335
|
var import_recharts2 = require("recharts");
|
|
6136
6336
|
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
6137
6337
|
var getRandomColor2 = () => {
|
|
@@ -6220,7 +6420,7 @@ var DonutChart = ({
|
|
|
6220
6420
|
const fetchData = async () => {
|
|
6221
6421
|
try {
|
|
6222
6422
|
setLocalLoading(true);
|
|
6223
|
-
const axiosClient = props.axiosInstance ??
|
|
6423
|
+
const axiosClient = props.axiosInstance ?? import_axios5.default;
|
|
6224
6424
|
const res = await axiosClient.get(apiUrl, {
|
|
6225
6425
|
withCredentials: true
|
|
6226
6426
|
});
|