@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.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
@@ -3692,11 +3693,9 @@ var valueFormatter = (value, format3, customFormatters = {}) => {
3692
3693
  case "date":
3693
3694
  return dayjs_setup_default(value).format(arg || "YYYY-MM-DD");
3694
3695
  case "datetimenumber":
3695
- const parsed = dayjs_setup_default(value).isValid() ? dayjs_setup_default(value).utc() : dayjs_setup_default(value);
3696
- return parsed.format("YYYY-MM-DD hh:mm");
3696
+ return dayjs_setup_default(value).format("YYYY-MM-DD hh:mm");
3697
3697
  case "datetime":
3698
- const formated = dayjs_setup_default(value).isValid() ? dayjs_setup_default(value).utc() : dayjs_setup_default(value);
3699
- return formated.format("DD MMM YYYY hh:mm A");
3698
+ return dayjs_setup_default(value).format("DD MMM YYYY hh:mm A");
3700
3699
  case "days":
3701
3700
  return `${dayjs_setup_default().diff(dayjs_setup_default(value), "day")} days`;
3702
3701
  case "months":
@@ -4013,13 +4012,153 @@ function DataTable({
4013
4012
  onDeleteRow,
4014
4013
  rowActions,
4015
4014
  enableRowSelection = false,
4016
- getRowSelection
4015
+ getRowSelection,
4016
+ tableId,
4017
+ manageColumns = false,
4018
+ preferenceUrl,
4019
+ axiosInstance
4017
4020
  }) {
4018
4021
  const [columnFilters, setColumnFilters] = React11.useState([]);
4019
4022
  const [columnVisibility, setColumnVisibility] = React11.useState({});
4023
+ const hasLoadedInitialState = React11.useRef(false);
4024
+ const isSavingRef = React11.useRef(false);
4025
+ const isFetchingRef = React11.useRef(false);
4026
+ const transformApiToFrontend = React11.useCallback((apiSettings, allColumnIds) => {
4027
+ if (!apiSettings || !apiSettings.columns || !apiSettings.columns.visible) {
4028
+ return {};
4029
+ }
4030
+ const visibleColumns = apiSettings.columns.visible;
4031
+ const result = {};
4032
+ allColumnIds.forEach((colId) => {
4033
+ result[colId] = visibleColumns.includes(colId);
4034
+ });
4035
+ return result;
4036
+ }, []);
4037
+ const transformFrontendToApi = React11.useCallback((visibility) => {
4038
+ const visibleColumns = Object.keys(visibility).filter((colId) => visibility[colId] === true);
4039
+ return {
4040
+ columns: {
4041
+ visible: visibleColumns
4042
+ }
4043
+ };
4044
+ }, []);
4045
+ const fetchColumnPreferences = React11.useCallback(async () => {
4046
+ if (isFetchingRef.current) {
4047
+ return;
4048
+ }
4049
+ if (!tableId || !manageColumns) {
4050
+ hasLoadedInitialState.current = true;
4051
+ return;
4052
+ }
4053
+ isFetchingRef.current = true;
4054
+ try {
4055
+ const entityKey = `table:${tableId}`;
4056
+ const apiUrl = `${preferenceUrl}/${encodeURIComponent(entityKey)}`;
4057
+ const axiosClient = axiosInstance ?? axios3;
4058
+ const response = await axiosClient.get(apiUrl, {
4059
+ withCredentials: true
4060
+ });
4061
+ if (response) {
4062
+ const data2 = response.data;
4063
+ if (data2.success && data2.data && data2.data.exists && data2.data.settings) {
4064
+ let allColumnIds = [];
4065
+ if (tableRef.current) {
4066
+ allColumnIds = tableRef.current.getAllLeafColumns().map((col) => col.id).filter(Boolean);
4067
+ } else {
4068
+ allColumnIds = columns.map((col) => {
4069
+ if (typeof col.id === "string") {
4070
+ return col.id;
4071
+ }
4072
+ if (col.accessorKey) {
4073
+ return col.accessorKey;
4074
+ }
4075
+ return null;
4076
+ }).filter((id) => !!id);
4077
+ if (enableRowSelection && !allColumnIds.includes("__select__")) {
4078
+ allColumnIds.unshift("__select__");
4079
+ }
4080
+ }
4081
+ if (allColumnIds.length > 0) {
4082
+ const transformed = transformApiToFrontend(data2.data.settings, allColumnIds);
4083
+ console.log("[DataTable] Loaded column preferences:", {
4084
+ visibleColumns: data2.data.settings.columns?.visible,
4085
+ allColumnIds,
4086
+ transformed
4087
+ });
4088
+ if (Object.keys(transformed).length > 0) {
4089
+ setColumnVisibility(transformed);
4090
+ }
4091
+ }
4092
+ } else {
4093
+ console.log("[DataTable] No saved preferences found, using default visibility");
4094
+ }
4095
+ } else {
4096
+ console.warn("Failed to fetch column preferences:", response);
4097
+ }
4098
+ } catch (error) {
4099
+ console.error("Error fetching column preferences:", error);
4100
+ } finally {
4101
+ hasLoadedInitialState.current = true;
4102
+ isFetchingRef.current = false;
4103
+ }
4104
+ }, [tableId, transformApiToFrontend, manageColumns]);
4105
+ const saveColumnPreferences = React11.useCallback(async (visibility) => {
4106
+ if (!tableId || isSavingRef.current || !manageColumns) {
4107
+ return;
4108
+ }
4109
+ isSavingRef.current = true;
4110
+ try {
4111
+ const entityKey = `table:${tableId}`;
4112
+ const apiUrl = `${preferenceUrl}/${encodeURIComponent(entityKey)}`;
4113
+ const settings = transformFrontendToApi(visibility);
4114
+ const requestBody = {
4115
+ settings,
4116
+ is_default: true
4117
+ };
4118
+ const axiosClient = axiosInstance ?? axios3;
4119
+ const response = await axiosClient.post(apiUrl, requestBody, {
4120
+ withCredentials: true
4121
+ });
4122
+ if (!response) {
4123
+ console.error("Failed to save column preferences:", response);
4124
+ }
4125
+ } catch (error) {
4126
+ console.error("Error saving column preferences:", error);
4127
+ } finally {
4128
+ isSavingRef.current = false;
4129
+ }
4130
+ }, [tableId, transformFrontendToApi, manageColumns]);
4131
+ React11.useEffect(() => {
4132
+ if (hasLoadedInitialState.current || isFetchingRef.current) {
4133
+ return;
4134
+ }
4135
+ if (!tableId) {
4136
+ return;
4137
+ }
4138
+ if (manageColumns) {
4139
+ fetchColumnPreferences();
4140
+ }
4141
+ }, [tableId, manageColumns]);
4020
4142
  const [manualSort, setManualSort] = React11.useState(null);
4021
4143
  const [searchTerm, setSearchTerm] = React11.useState("");
4022
4144
  const tableData = Array.isArray(data) ? data : [];
4145
+ const filteredData = React11.useMemo(() => {
4146
+ if (paginationMode === "client" && globalSearch && searchTerm.trim()) {
4147
+ const searchLower = searchTerm.toLowerCase().trim();
4148
+ return tableData.filter((row) => {
4149
+ return columns.some((column) => {
4150
+ const columnId = typeof column.id === "string" ? column.id : column.accessorKey;
4151
+ if (!columnId) return false;
4152
+ const accessorFn = column.accessorFn;
4153
+ const cellValue = accessorFn ? accessorFn(row, 0) : row[columnId];
4154
+ const cellValueStr = cellValue != null ? String(cellValue).toLowerCase() : "";
4155
+ return cellValueStr.includes(searchLower);
4156
+ });
4157
+ });
4158
+ }
4159
+ return tableData;
4160
+ }, [tableData, searchTerm, paginationMode, globalSearch, columns]);
4161
+ const finalData = paginationMode === "client" && globalSearch ? filteredData : tableData;
4023
4162
  const finalCols = [...columns];
4024
4163
  if (enableRowSelection) {
4025
4164
  finalCols.unshift({
@@ -4046,44 +4185,89 @@ function DataTable({
4046
4185
  const dynamicCols = useDynamicColumns({ columns: finalCols, enableRowSelection });
4047
4186
  const [rowSelection, setRowSelection] = React11.useState({});
4048
4187
  const [localPageSize, setLocalPageSize] = React11.useState(pageSize);
4188
+ const [localPageIndex, setLocalPageIndex] = React11.useState(0);
4189
+ const isUpdatingPageSizeRef = React11.useRef(false);
4190
+ const tableRef = React11.useRef(null);
4191
+ React11.useEffect(() => {
4192
+ if (paginationMode === "client") {
4193
+ setLocalPageSize(pageSize);
4194
+ }
4195
+ }, [pageSize, paginationMode]);
4049
4196
  const table = useReactTable({
4050
- data: tableData,
4197
+ data: finalData,
4051
4198
  columns: dynamicCols,
4199
+ initialState: {
4200
+ pagination: {
4201
+ pageIndex: 0,
4202
+ pageSize
4203
+ }
4204
+ },
4052
4205
  state: {
4053
4206
  columnFilters,
4054
4207
  columnVisibility,
4055
4208
  rowSelection,
4056
- ...paginationMode === "server" ? {
4057
- pagination: {
4058
- pageIndex: controlledPageIndex ?? 0,
4059
- pageSize: localPageSize
4060
- }
4061
- } : {}
4209
+ pagination: {
4210
+ pageIndex: paginationMode === "server" ? controlledPageIndex ?? 0 : localPageIndex,
4211
+ pageSize: localPageSize
4212
+ }
4062
4213
  },
4063
4214
  enableRowSelection: !!enableRowSelection,
4064
4215
  onRowSelectionChange: (updater) => {
4065
4216
  setRowSelection((old) => {
4066
4217
  const newState = typeof updater === "function" ? updater(old) : updater;
4067
- const selectedData = Object.keys(newState).filter((key) => newState[key]).map((rowId) => tableData[Number(rowId)]);
4218
+ const selectedData = Object.keys(newState).filter((key) => newState[key]).map((rowId) => finalData[Number(rowId)]);
4068
4219
  getRowSelection?.({ rows: selectedData });
4069
4220
  return newState;
4070
4221
  });
4071
4222
  },
4072
4223
  onColumnFiltersChange: setColumnFilters,
4073
- onColumnVisibilityChange: setColumnVisibility,
4224
+ onColumnVisibilityChange: (updater) => {
4225
+ setColumnVisibility((old) => {
4226
+ const newState = typeof updater === "function" ? updater(old) : updater;
4227
+ setTimeout(() => {
4228
+ if (tableRef.current && tableId && hasLoadedInitialState.current) {
4229
+ try {
4230
+ const completeVisibility = {};
4231
+ tableRef.current.getAllLeafColumns().forEach((column) => {
4232
+ completeVisibility[column.id] = column.getIsVisible();
4233
+ });
4234
+ if (Object.keys(completeVisibility).length > 0) {
4235
+ saveColumnPreferences(completeVisibility);
4236
+ }
4237
+ } catch (error) {
4238
+ console.error("Error saving column visibility to API:", error);
4239
+ }
4240
+ }
4241
+ }, 0);
4242
+ return newState;
4243
+ });
4244
+ },
4074
4245
  getCoreRowModel: getCoreRowModel(),
4075
4246
  getFilteredRowModel: getFilteredRowModel(),
4076
4247
  getPaginationRowModel: pagination && paginationMode === "client" ? getPaginationRowModel() : void 0,
4077
4248
  manualPagination: paginationMode === "server",
4078
4249
  pageCount: paginationMode === "server" ? Math.ceil(totalRecords / localPageSize) : void 0,
4079
- ...paginationMode === "server" ? {
4080
- onPaginationChange: (updater) => {
4081
- const prev = table.getState().pagination;
4082
- const next = typeof updater === "function" ? updater(prev) : updater;
4250
+ onPaginationChange: (updater) => {
4251
+ if (isUpdatingPageSizeRef.current) {
4252
+ isUpdatingPageSizeRef.current = false;
4253
+ return;
4254
+ }
4255
+ const prev = table.getState().pagination;
4256
+ const next = typeof updater === "function" ? updater(prev) : updater;
4257
+ if (paginationMode === "server") {
4083
4258
  onPageChange?.(next.pageIndex, next.pageSize);
4259
+ } else {
4260
+ setLocalPageIndex(next.pageIndex);
4261
+ setLocalPageSize(next.pageSize);
4084
4262
  }
4085
- } : {}
4263
+ }
4086
4264
  });
4265
+ React11.useEffect(() => {
4266
+ tableRef.current = table;
4267
+ if (table && !hasLoadedInitialState.current && !isFetchingRef.current && tableId) {
4268
+ fetchColumnPreferences();
4269
+ }
4270
+ }, [table, tableId]);
4087
4271
  const getPageNumbers = (currentPage, totalPages, maxVisiblePages = 5) => {
4088
4272
  if (totalPages <= maxVisiblePages) {
4089
4273
  return Array.from({ length: totalPages }, (_, i) => i + 1);
@@ -4106,17 +4290,26 @@ function DataTable({
4106
4290
  const pageCount = table.getPageCount() === 0 ? 1 : table.getPageCount();
4107
4291
  const handlePageSizeChange = (e) => {
4108
4292
  const newSize = Number(e.target.value);
4109
- const currentPageIndex = table.getState().pagination.pageIndex;
4110
- onPageChange?.(currentPageIndex, newSize);
4111
- setLocalPageSize(newSize);
4293
+ if (paginationMode === "server") {
4294
+ const currentPageIndex = table.getState().pagination.pageIndex;
4295
+ onPageChange?.(currentPageIndex, newSize);
4296
+ setLocalPageSize(newSize);
4297
+ } else {
4298
+ isUpdatingPageSizeRef.current = true;
4299
+ setLocalPageSize(newSize);
4300
+ setLocalPageIndex(0);
4301
+ }
4112
4302
  };
4113
4303
  const pageSizeOptions = React11.useMemo(() => {
4304
+ if (paginationMode === "client") {
4305
+ return [5, 10, 20, 50, 100];
4306
+ }
4114
4307
  const options = [5, 10, 20, 50, 100].filter((size) => size < totalRecords);
4115
4308
  if (options.length === 0) {
4116
4309
  options.push(5);
4117
4310
  }
4118
4311
  return options;
4119
- }, [totalRecords]);
4312
+ }, [paginationMode, totalRecords]);
4120
4313
  return /* @__PURE__ */ jsxs30("div", { className: "overflow-hidden rounded-md w-full", children: [
4121
4314
  !loading && /* @__PURE__ */ jsxs30("div", { className: "flex justify-between p-2 bg-gray-50", children: [
4122
4315
  /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-4 w-full", children: [
@@ -4132,10 +4325,17 @@ function DataTable({
4132
4325
  type: "text",
4133
4326
  placeholder: "Search...",
4134
4327
  value: searchTerm,
4135
- onChange: (e) => setSearchTerm(e.target.value),
4328
+ onChange: (e) => {
4329
+ setSearchTerm(e.target.value);
4330
+ if (paginationMode === "client") {
4331
+ setLocalPageIndex(0);
4332
+ }
4333
+ },
4136
4334
  onKeyDown: (e) => {
4137
- if (e.key === "Enter" && onGlobalSearch) {
4138
- onGlobalSearch(searchTerm.trim());
4335
+ if (e.key === "Enter") {
4336
+ if (paginationMode === "server" && onGlobalSearch) {
4337
+ onGlobalSearch(searchTerm.trim());
4338
+ }
4139
4339
  }
4140
4340
  },
4141
4341
  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 +4343,7 @@ function DataTable({
4143
4343
  ),
4144
4344
  /* @__PURE__ */ jsx51(Search, { className: "absolute left-2 top-2.5 text-gray-400", size: 16 })
4145
4345
  ] }),
4146
- /* @__PURE__ */ jsx51(
4346
+ paginationMode === "server" && /* @__PURE__ */ jsx51(
4147
4347
  Button,
4148
4348
  {
4149
4349
  size: "sm",
@@ -4154,7 +4354,7 @@ function DataTable({
4154
4354
  )
4155
4355
  ] })
4156
4356
  ] }),
4157
- /* @__PURE__ */ jsxs30(Popover, { children: [
4357
+ manageColumns && /* @__PURE__ */ jsxs30(Popover, { children: [
4158
4358
  /* @__PURE__ */ jsx51(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx51(
4159
4359
  Button,
4160
4360
  {
@@ -4164,42 +4364,44 @@ function DataTable({
4164
4364
  children: "Manage Columns"
4165
4365
  }
4166
4366
  ) }),
4167
- /* @__PURE__ */ jsxs30(PopoverContent, { align: "end", className: "w-48 p-3 space-y-2", children: [
4367
+ /* @__PURE__ */ jsxs30(PopoverContent, { align: "end", className: "w-48 p-3", children: [
4168
4368
  /* @__PURE__ */ jsx51("div", { className: "text-sm font-medium mb-2", children: "Show / Hide Columns" }),
4169
- /* @__PURE__ */ jsxs30("label", { className: "flex items-center gap-2 text-sm font-semibold border-b pb-2 mb-2", children: [
4170
- /* @__PURE__ */ jsx51(
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: [
4369
+ /* @__PURE__ */ jsxs30("div", { className: "max-h-56 overflow-y-auto pr-1 space-y-2", children: [
4370
+ /* @__PURE__ */ jsxs30("label", { className: "flex items-center gap-2 text-sm font-semibold border-b pb-2 mb-2", children: [
4192
4371
  /* @__PURE__ */ jsx51(
4193
4372
  "input",
4194
4373
  {
4195
4374
  type: "checkbox",
4196
- checked: column.getIsVisible(),
4197
- onChange: (e) => column.toggleVisibility(e.target.checked)
4375
+ checked: table.getAllLeafColumns().every((col) => col.getIsVisible()),
4376
+ ref: (input) => {
4377
+ if (input) {
4378
+ input.indeterminate = table.getAllLeafColumns().some((col) => col.getIsVisible()) && !table.getAllLeafColumns().every((col) => col.getIsVisible());
4379
+ }
4380
+ },
4381
+ onChange: (e) => {
4382
+ table.getAllLeafColumns().forEach(
4383
+ (col) => col.toggleVisibility(e.target.checked)
4384
+ );
4385
+ }
4198
4386
  }
4199
4387
  ),
4200
- typeof header === "function" ? header({ column, header, table }) : typeof header === "string" ? header : column.id
4201
- ] }, column.id);
4202
- })
4388
+ "Toggle All"
4389
+ ] }),
4390
+ table.getAllLeafColumns().map((column) => {
4391
+ const header = column.columnDef.header;
4392
+ return /* @__PURE__ */ jsxs30("label", { className: "flex items-center gap-2 text-sm", children: [
4393
+ /* @__PURE__ */ jsx51(
4394
+ "input",
4395
+ {
4396
+ type: "checkbox",
4397
+ checked: column.getIsVisible(),
4398
+ onChange: (e) => column.toggleVisibility(e.target.checked)
4399
+ }
4400
+ ),
4401
+ typeof header === "function" ? header({ column, header, table }) : typeof header === "string" ? header : column.id
4402
+ ] }, column.id);
4403
+ })
4404
+ ] })
4203
4405
  ] })
4204
4406
  ] })
4205
4407
  ] }),
@@ -4298,7 +4500,22 @@ function DataTable({
4298
4500
  `header-${header.id}-${index}`
4299
4501
  );
4300
4502
  }) }, `header-group-${hg.id}`)) }),
4301
- /* @__PURE__ */ jsx51(TableBody, { children: loading ? /* @__PURE__ */ jsx51(Fragment21, { children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ jsx51(TableRow, { children: dynamicCols.map((_2, j) => /* @__PURE__ */ jsx51(TableCell, { className: "p-3", children: /* @__PURE__ */ jsx51("span", { className: "h-4 bg-gray-200 rounded w-3/4 block animate-pulse" }) }, j)) }, i)) }) : table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx51(TableRow, { children: row.getVisibleCells().map((cell, cellIndex, arr) => {
4503
+ /* @__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) => {
4504
+ const column = header.column;
4505
+ return /* @__PURE__ */ jsx51(
4506
+ TableCell,
4507
+ {
4508
+ className: "p-3",
4509
+ style: {
4510
+ width: column.getSize(),
4511
+ minWidth: column.columnDef.minSize,
4512
+ maxWidth: column.columnDef.maxSize
4513
+ },
4514
+ children: /* @__PURE__ */ jsx51("span", { className: "h-4 bg-gray-200 rounded w-full block animate-pulse" })
4515
+ },
4516
+ j
4517
+ );
4518
+ }) }, i)) }) : table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx51(TableRow, { children: row.getVisibleCells().map((cell, cellIndex, arr) => {
4302
4519
  const meta = cell.column.columnDef.meta || {};
4303
4520
  const isClickable = meta?.isClickable;
4304
4521
  const isLastCell = cellIndex === arr.length - 1;
@@ -4876,7 +5093,7 @@ var HistoryTimeline = ({
4876
5093
  var HistoryTimeline_default = HistoryTimeline;
4877
5094
 
4878
5095
  // src/components/Navigation/Tabs/Tabs.tsx
4879
- import { useCallback as useCallback4, useMemo as useMemo9, useState as useState12 } from "react";
5096
+ import { useCallback as useCallback5, useMemo as useMemo9, useState as useState12 } from "react";
4880
5097
  import { ChevronDown as ChevronDown2, Menu } from "lucide-react";
4881
5098
  import Link3 from "next/link";
4882
5099
  import { usePathname, useRouter } from "next/navigation";
@@ -5131,7 +5348,7 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
5131
5348
  const router = useRouter();
5132
5349
  const [showExitDialog, setShowExitDialog] = useState12(false);
5133
5350
  const [pendingUrl, setPendingUrl] = useState12(null);
5134
- const handleBuilderExit = useCallback4(
5351
+ const handleBuilderExit = useCallback5(
5135
5352
  (e, url) => {
5136
5353
  if (isBuilder) {
5137
5354
  e.preventDefault();
@@ -5298,7 +5515,7 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
5298
5515
  var Tabs_default = Tabs;
5299
5516
 
5300
5517
  // src/components/Navigation/Stages/Stages.tsx
5301
- import React12, { useEffect as useEffect26, useState as useState13 } from "react";
5518
+ import React12, { useEffect as useEffect27, useState as useState13 } from "react";
5302
5519
 
5303
5520
  // src/components/ui/tooltip.tsx
5304
5521
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
@@ -5326,29 +5543,6 @@ function TooltipTrigger({
5326
5543
  }) {
5327
5544
  return /* @__PURE__ */ jsx60(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
5328
5545
  }
5329
- function TooltipContent({
5330
- className,
5331
- sideOffset = 0,
5332
- children,
5333
- ...props
5334
- }) {
5335
- return /* @__PURE__ */ jsx60(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsxs37(
5336
- TooltipPrimitive.Content,
5337
- {
5338
- "data-slot": "tooltip-content",
5339
- sideOffset,
5340
- className: cn(
5341
- "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",
5342
- className
5343
- ),
5344
- ...props,
5345
- children: [
5346
- children,
5347
- /* @__PURE__ */ jsx60(TooltipPrimitive.Arrow, { className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
5348
- ]
5349
- }
5350
- ) });
5351
- }
5352
5546
 
5353
5547
  // src/components/Navigation/Stages/Stages.tsx
5354
5548
  import { jsx as jsx61, jsxs as jsxs38 } from "react/jsx-runtime";
@@ -5365,13 +5559,14 @@ var StagesComponent = ({
5365
5559
  loading,
5366
5560
  saving,
5367
5561
  triggerOnClick = false,
5368
- canvasMode = "desktop"
5562
+ canvasMode = "desktop",
5563
+ ...props
5369
5564
  }) => {
5370
5565
  const [activeStage, setActiveStage] = useState13("");
5371
5566
  const [isCompleted, setIsCompleted] = useState13(false);
5372
5567
  const [activeChildStage, setActiveChildStage] = useState13(null);
5373
5568
  const [activeRootStage, setActiveRootStage] = useState13(null);
5374
- useEffect26(() => {
5569
+ useEffect27(() => {
5375
5570
  if (currentStage) {
5376
5571
  setActiveStage(currentStage);
5377
5572
  } else {
@@ -5431,7 +5626,7 @@ var StagesComponent = ({
5431
5626
  }
5432
5627
  return { activeRoot: null, activeChild: null };
5433
5628
  };
5434
- useEffect26(() => {
5629
+ useEffect27(() => {
5435
5630
  if (!currentStage || !Array.isArray(stages)) {
5436
5631
  setActiveRootStage(null);
5437
5632
  setActiveChildStage(null);
@@ -5443,6 +5638,7 @@ var StagesComponent = ({
5443
5638
  }, [currentStage, stages]);
5444
5639
  const isAllStagesCompleted = isCompleted || activeRootStage?.[dataKey] === lastStage;
5445
5640
  const disabled = isAllStagesCompleted || loading || saving;
5641
+ const primaryColor = props.primaryColor || "#12715b";
5446
5642
  return /* @__PURE__ */ jsx61("div", { className, style, children: /* @__PURE__ */ jsxs38(
5447
5643
  "div",
5448
5644
  {
@@ -5480,16 +5676,19 @@ var StagesComponent = ({
5480
5676
  const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
5481
5677
  const isCompletedStage = isAllStagesCompleted || index <= currentIndex;
5482
5678
  const isActive = !isAllStagesCompleted && index === currentIndex;
5483
- let stageColor = "bg-green-50 text-green-700 border-2 border-green-700";
5679
+ let stageColor = `text-[${primaryColor}] border-2 border-[${primaryColor}]`;
5680
+ let stageStyle = { borderColor: primaryColor, color: isActive ? "white" : primaryColor, backgroundColor: isActive ? primaryColor : "transparent" };
5484
5681
  if (stage.hasOwnProperty("isSuccess") && stage.isSuccess === false) {
5485
- stageColor = "bg-red-50 text-red-700 border-2 border-red-700";
5682
+ stageColor = `bg-red-50 text-red-700 border-2 border-red-700`;
5683
+ stageStyle = { borderColor: "red", color: "red", backgroundColor: "transparent" };
5486
5684
  }
5487
5685
  let stageLabel = stage[dataLabel];
5488
5686
  if (stage[dataKey] !== activeChildStage?.[dataKey] && activeRootStage?.[dataKey] === stage[dataKey]) {
5489
5687
  stageLabel = activeChildStage?.[dataLabel] || stageLabel;
5490
- stageColor = "bg-green-50 text-green-700 border-2 border-green-700";
5688
+ stageColor = `text-[${primaryColor}] border-2 border-[${primaryColor}]`;
5491
5689
  if (activeChildStage.hasOwnProperty("isSuccess") && activeChildStage.isSuccess === false) {
5492
5690
  stageColor = "bg-red-50 text-red-700 border-2 border-red-700";
5691
+ stageStyle = { borderColor: "red", color: "red", backgroundColor: "transparent" };
5493
5692
  }
5494
5693
  }
5495
5694
  const stageKey = typeof stage[dataKey] === "string" ? stage[dataKey] : JSON.stringify(stage[dataKey]);
@@ -5501,17 +5700,17 @@ var StagesComponent = ({
5501
5700
  min-w-[70px] sm:min-w-[80px] w-full sm:w-auto px-3 sm:px-4 py-1.5 sm:py-2
5502
5701
  rounded-full text-xs sm:text-sm font-medium transition-colors duration-200
5503
5702
  whitespace-normal sm:whitespace-nowrap flex-shrink-0 max-w-[150px] text-ellipsis overflow-hidden
5504
- ${isActive ? "bg-green-700 text-white shadow-md" : isCompletedStage ? stageColor : "bg-white text-gray-700 hover:bg-gray-100 border border-gray-200"}
5703
+ ${isActive ? `bg-[${primaryColor}] text-white shadow-md` : isCompletedStage ? stageColor : "bg-white border border-gray-200"}
5505
5704
  ${isMobile ? "flex-1 text-center py-2.5" : ""}
5506
5705
  `,
5507
5706
  onClick: () => {
5508
5707
  if (isAllStagesCompleted) return;
5509
5708
  onStageClick(stage[dataKey]);
5510
5709
  },
5710
+ style: stageStyle,
5511
5711
  children: stageLabel
5512
5712
  }
5513
5713
  ) }),
5514
- /* @__PURE__ */ jsx61(TooltipContent, { className: "max-w-[400px] p-3 text-xs text-muted-foreground space-y-2", children: /* @__PURE__ */ jsx61("span", { children: /* @__PURE__ */ jsx61("b", { children: stageLabel }) }) }),
5515
5714
  !isMobile && index < stages.length - 1 && /* @__PURE__ */ jsx61("div", { className: "hidden sm:flex sm:flex-shrink-0 w-3 h-px bg-gray-300 sm:w-4" })
5516
5715
  ] }, stageKey) }, stageKey);
5517
5716
  })
@@ -5528,12 +5727,13 @@ var StagesComponent = ({
5528
5727
  "button",
5529
5728
  {
5530
5729
  className: `
5531
- w-full lg:w-auto bg-green-700 text-white px-4 lg:px-6 py-2.5
5730
+ w-full lg:w-auto text-white px-4 lg:px-6 py-2.5
5532
5731
  rounded-lg text-sm font-medium transition-colors duration-200
5533
5732
  shadow-sm ${disabled ? "opacity-50 cursor-not-allowed" : "hover:shadow-md"}
5534
5733
  `,
5535
5734
  onClick: nextStage,
5536
5735
  disabled,
5736
+ style: { backgroundColor: primaryColor },
5537
5737
  children: saving ? "Updating..." : buttonText
5538
5738
  }
5539
5739
  )
@@ -5562,7 +5762,7 @@ import { jsx as jsx64, jsxs as jsxs40 } from "react/jsx-runtime";
5562
5762
  import { jsx as jsx65 } from "react/jsx-runtime";
5563
5763
 
5564
5764
  // src/components/Navigation/Navbar/Navbar.tsx
5565
- import { useCallback as useCallback5, useMemo as useMemo10, useState as useState14, useEffect as useEffect27 } from "react";
5765
+ import { useCallback as useCallback6, useMemo as useMemo10, useState as useState14, useEffect as useEffect28 } from "react";
5566
5766
  import { Bell, Search as Search2, Menu as Menu2 } from "lucide-react";
5567
5767
  import Image3 from "next/image";
5568
5768
  import Link4 from "next/link";
@@ -5631,7 +5831,7 @@ function Navbar({
5631
5831
  const [screenMode, setScreenMode] = useState14(
5632
5832
  canvasMode
5633
5833
  );
5634
- useEffect27(() => {
5834
+ useEffect28(() => {
5635
5835
  const detectMode = () => {
5636
5836
  if (window.innerWidth < 640) setScreenMode("mobile");
5637
5837
  else if (window.innerWidth < 1024) setScreenMode("tablet");
@@ -5645,7 +5845,7 @@ function Navbar({
5645
5845
  const isMobile = mode === "mobile";
5646
5846
  const isTablet = mode === "tablet";
5647
5847
  const isDesktop = mode === "desktop";
5648
- const handleBuilderExit = useCallback5(
5848
+ const handleBuilderExit = useCallback6(
5649
5849
  (e, url) => {
5650
5850
  if (isBuilder) {
5651
5851
  e.preventDefault();
@@ -5738,8 +5938,8 @@ function Navbar({
5738
5938
  }
5739
5939
 
5740
5940
  // src/components/Chart/BarChart.tsx
5741
- import React14, { useEffect as useEffect28, useMemo as useMemo11, useState as useState15, useCallback as useCallback6 } from "react";
5742
- import axios3 from "axios";
5941
+ import React14, { useEffect as useEffect29, useMemo as useMemo11, useState as useState15, useCallback as useCallback7 } from "react";
5942
+ import axios4 from "axios";
5743
5943
  import {
5744
5944
  BarChart,
5745
5945
  Bar,
@@ -5816,12 +6016,12 @@ var ChartComponent = ({
5816
6016
  const [currentPage, setCurrentPage] = useState15(1);
5817
6017
  const effectiveData = apiUrl ? rawData : props.data || [];
5818
6018
  const effectiveLoading = apiUrl ? localLoading : externalLoading;
5819
- useEffect28(() => {
6019
+ useEffect29(() => {
5820
6020
  if (apiUrl) {
5821
6021
  setCurrentPage(1);
5822
6022
  }
5823
6023
  }, [apiUrl]);
5824
- const fetchData = useCallback6(async (page) => {
6024
+ const fetchData = useCallback7(async (page) => {
5825
6025
  if (!apiUrl) return;
5826
6026
  const cancelled = false;
5827
6027
  try {
@@ -5830,7 +6030,7 @@ var ChartComponent = ({
5830
6030
  page: page.toString(),
5831
6031
  limit: limit.toString()
5832
6032
  });
5833
- const axiosClient = props.axiosInstance ?? axios3;
6033
+ const axiosClient = props.axiosInstance ?? axios4;
5834
6034
  const res = await axiosClient.get(`${apiUrl}?${params.toString()}`, {
5835
6035
  withCredentials: true
5836
6036
  });
@@ -5858,7 +6058,7 @@ var ChartComponent = ({
5858
6058
  if (!cancelled) setLocalLoading(false);
5859
6059
  }
5860
6060
  }, [apiUrl, limit]);
5861
- useEffect28(() => {
6061
+ useEffect29(() => {
5862
6062
  if (!apiUrl) return;
5863
6063
  fetchData(currentPage);
5864
6064
  }, [apiUrl, currentPage, fetchData]);
@@ -6057,8 +6257,8 @@ var ChartComponent = ({
6057
6257
  var BarChart_default = React14.memo(ChartComponent);
6058
6258
 
6059
6259
  // src/components/Chart/PieChart.tsx
6060
- import React15, { useEffect as useEffect29, useMemo as useMemo12, useState as useState16 } from "react";
6061
- import axios4 from "axios";
6260
+ import React15, { useEffect as useEffect30, useMemo as useMemo12, useState as useState16 } from "react";
6261
+ import axios5 from "axios";
6062
6262
  import {
6063
6263
  PieChart,
6064
6264
  Pie,
@@ -6147,13 +6347,13 @@ var DonutChart = ({
6147
6347
  const [localLoading, setLocalLoading] = useState16(false);
6148
6348
  const effectiveData = apiUrl ? rawData : props.data || [];
6149
6349
  const effectiveLoading = apiUrl ? localLoading : externalLoading;
6150
- useEffect29(() => {
6350
+ useEffect30(() => {
6151
6351
  if (!apiUrl) return;
6152
6352
  let cancelled = false;
6153
6353
  const fetchData = async () => {
6154
6354
  try {
6155
6355
  setLocalLoading(true);
6156
- const axiosClient = props.axiosInstance ?? axios4;
6356
+ const axiosClient = props.axiosInstance ?? axios5;
6157
6357
  const res = await axiosClient.get(apiUrl, {
6158
6358
  withCredentials: true
6159
6359
  });
@@ -6229,7 +6429,7 @@ var DonutChart = ({
6229
6429
  return { inner: 70, outer: 130 };
6230
6430
  };
6231
6431
  const [mounted, setMounted] = useState16(false);
6232
- useEffect29(() => {
6432
+ useEffect30(() => {
6233
6433
  const timeout = setTimeout(() => setMounted(true), 100);
6234
6434
  return () => clearTimeout(timeout);
6235
6435
  }, []);