@algorithm-shift/design-system 1.2.86 → 1.2.88
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 +33 -14
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +100 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +112 -66
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -143,6 +143,8 @@ interface StagesProps extends ElementProps {
|
|
|
143
143
|
buttonText?: string;
|
|
144
144
|
onStageChange?: (stageId: string) => void;
|
|
145
145
|
currentStage?: string;
|
|
146
|
+
dataKey?: string;
|
|
147
|
+
dataLabel?: string;
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
type ButtonProps = ElementProps & React.ComponentProps<"button"> & {
|
|
@@ -195,7 +197,7 @@ interface NavbarProps extends ElementProps {
|
|
|
195
197
|
showName?: boolean;
|
|
196
198
|
imageUrl?: string;
|
|
197
199
|
altText?: string;
|
|
198
|
-
canvasMode?: 'desktop' | 'tablet' | 'mobile';
|
|
200
|
+
canvasMode?: 'desktop' | 'tablet' | 'mobile' | string;
|
|
199
201
|
list?: Record<string, any>;
|
|
200
202
|
profileMenu?: Record<string, any>;
|
|
201
203
|
userName?: string;
|
|
@@ -256,8 +258,10 @@ interface RepeaterProps<T> {
|
|
|
256
258
|
emptyFallback?: React__default.ReactNode;
|
|
257
259
|
wrapper?: (children: React__default.ReactNode) => React__default.ReactNode;
|
|
258
260
|
className?: string;
|
|
261
|
+
loading?: boolean;
|
|
262
|
+
loadingText?: string;
|
|
259
263
|
}
|
|
260
|
-
declare function Repeater<T>({ items, count, render, emptyFallback, wrapper, className, }: RepeaterProps<T>): react_jsx_runtime.JSX.Element;
|
|
264
|
+
declare function Repeater<T>({ items, count, render, emptyFallback, wrapper, className, loading, loadingText, }: RepeaterProps<T>): react_jsx_runtime.JSX.Element;
|
|
261
265
|
declare const _default$2: typeof Repeater;
|
|
262
266
|
|
|
263
267
|
declare const ButtonWrapper: ({ className, style, textContent, loadingText, loading, ...props }: ButtonProps) => react_jsx_runtime.JSX.Element;
|
|
@@ -367,13 +371,13 @@ interface ExtendedTableProps extends TableProps {
|
|
|
367
371
|
enableDelete?: boolean;
|
|
368
372
|
}
|
|
369
373
|
|
|
370
|
-
declare const Table: ({ columns, data, rowActions, className, style, pagination, paginationMode, itemsPerPage, onPageChange, onSortChange, onFilterChange, onGlobalSearch, page, loading, totalRecords, globalSearch, onCellClick,
|
|
374
|
+
declare const Table: ({ columns, data, rowActions, className, style, pagination, paginationMode, itemsPerPage, onPageChange, onSortChange, onFilterChange, onGlobalSearch, page, loading, totalRecords, globalSearch, onCellClick, onDeleteRow, ...props }: ExtendedTableProps) => react_jsx_runtime.JSX.Element;
|
|
371
375
|
|
|
372
376
|
declare const CustomPagination: ({ totalPages, currentPage, onPageChange, maxVisiblePages, perPage, }: CustomPaginationProps) => react_jsx_runtime.JSX.Element;
|
|
373
377
|
|
|
374
378
|
declare const Tabs: ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder, source, parentKey, menuNameKey, menuUrlKey, loading }: TabsProps) => react_jsx_runtime.JSX.Element;
|
|
375
379
|
|
|
376
|
-
declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage }: StagesProps) => react_jsx_runtime.JSX.Element;
|
|
380
|
+
declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey, dataLabel }: StagesProps) => react_jsx_runtime.JSX.Element;
|
|
377
381
|
|
|
378
382
|
declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
|
|
379
383
|
|
package/dist/index.d.ts
CHANGED
|
@@ -143,6 +143,8 @@ interface StagesProps extends ElementProps {
|
|
|
143
143
|
buttonText?: string;
|
|
144
144
|
onStageChange?: (stageId: string) => void;
|
|
145
145
|
currentStage?: string;
|
|
146
|
+
dataKey?: string;
|
|
147
|
+
dataLabel?: string;
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
type ButtonProps = ElementProps & React.ComponentProps<"button"> & {
|
|
@@ -195,7 +197,7 @@ interface NavbarProps extends ElementProps {
|
|
|
195
197
|
showName?: boolean;
|
|
196
198
|
imageUrl?: string;
|
|
197
199
|
altText?: string;
|
|
198
|
-
canvasMode?: 'desktop' | 'tablet' | 'mobile';
|
|
200
|
+
canvasMode?: 'desktop' | 'tablet' | 'mobile' | string;
|
|
199
201
|
list?: Record<string, any>;
|
|
200
202
|
profileMenu?: Record<string, any>;
|
|
201
203
|
userName?: string;
|
|
@@ -256,8 +258,10 @@ interface RepeaterProps<T> {
|
|
|
256
258
|
emptyFallback?: React__default.ReactNode;
|
|
257
259
|
wrapper?: (children: React__default.ReactNode) => React__default.ReactNode;
|
|
258
260
|
className?: string;
|
|
261
|
+
loading?: boolean;
|
|
262
|
+
loadingText?: string;
|
|
259
263
|
}
|
|
260
|
-
declare function Repeater<T>({ items, count, render, emptyFallback, wrapper, className, }: RepeaterProps<T>): react_jsx_runtime.JSX.Element;
|
|
264
|
+
declare function Repeater<T>({ items, count, render, emptyFallback, wrapper, className, loading, loadingText, }: RepeaterProps<T>): react_jsx_runtime.JSX.Element;
|
|
261
265
|
declare const _default$2: typeof Repeater;
|
|
262
266
|
|
|
263
267
|
declare const ButtonWrapper: ({ className, style, textContent, loadingText, loading, ...props }: ButtonProps) => react_jsx_runtime.JSX.Element;
|
|
@@ -367,13 +371,13 @@ interface ExtendedTableProps extends TableProps {
|
|
|
367
371
|
enableDelete?: boolean;
|
|
368
372
|
}
|
|
369
373
|
|
|
370
|
-
declare const Table: ({ columns, data, rowActions, className, style, pagination, paginationMode, itemsPerPage, onPageChange, onSortChange, onFilterChange, onGlobalSearch, page, loading, totalRecords, globalSearch, onCellClick,
|
|
374
|
+
declare const Table: ({ columns, data, rowActions, className, style, pagination, paginationMode, itemsPerPage, onPageChange, onSortChange, onFilterChange, onGlobalSearch, page, loading, totalRecords, globalSearch, onCellClick, onDeleteRow, ...props }: ExtendedTableProps) => react_jsx_runtime.JSX.Element;
|
|
371
375
|
|
|
372
376
|
declare const CustomPagination: ({ totalPages, currentPage, onPageChange, maxVisiblePages, perPage, }: CustomPaginationProps) => react_jsx_runtime.JSX.Element;
|
|
373
377
|
|
|
374
378
|
declare const Tabs: ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder, source, parentKey, menuNameKey, menuUrlKey, loading }: TabsProps) => react_jsx_runtime.JSX.Element;
|
|
375
379
|
|
|
376
|
-
declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage }: StagesProps) => react_jsx_runtime.JSX.Element;
|
|
380
|
+
declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey, dataLabel }: StagesProps) => react_jsx_runtime.JSX.Element;
|
|
377
381
|
|
|
378
382
|
declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
|
|
379
383
|
|
package/dist/index.js
CHANGED
|
@@ -323,12 +323,17 @@ function Repeater({
|
|
|
323
323
|
render,
|
|
324
324
|
emptyFallback = null,
|
|
325
325
|
wrapper,
|
|
326
|
-
className
|
|
326
|
+
className,
|
|
327
|
+
loading = false,
|
|
328
|
+
loadingText = "Loading..."
|
|
327
329
|
}) {
|
|
328
330
|
const list = import_react4.default.useMemo(
|
|
329
331
|
() => typeof count === "number" ? items.slice(0, count) : items,
|
|
330
332
|
[items, count]
|
|
331
333
|
);
|
|
334
|
+
if (loading) {
|
|
335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className, children: loadingText });
|
|
336
|
+
}
|
|
332
337
|
if (!list.length) {
|
|
333
338
|
return emptyFallback ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: emptyFallback }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className, children: "No items to display." });
|
|
334
339
|
}
|
|
@@ -27814,6 +27819,31 @@ function useLazyDropdown(config) {
|
|
|
27814
27819
|
setLoading(false);
|
|
27815
27820
|
}
|
|
27816
27821
|
}, [fetchApiData, transformToOptions]);
|
|
27822
|
+
const fetchValueItem = async () => {
|
|
27823
|
+
if (!configRef.current.apiUrl) return [];
|
|
27824
|
+
try {
|
|
27825
|
+
setLoading(true);
|
|
27826
|
+
const res = await import_axios.default.get(configRef.current.apiUrl, {
|
|
27827
|
+
params: { [configRef.current.dataKey]: configRef.current.value },
|
|
27828
|
+
withCredentials: true
|
|
27829
|
+
});
|
|
27830
|
+
if (res.data?.success && Array.isArray(res.data.data) && res.data.data.length > 0) {
|
|
27831
|
+
const fetched = transformToOptions(res.data.data);
|
|
27832
|
+
setOptions((prev) => [...fetched, ...prev]);
|
|
27833
|
+
}
|
|
27834
|
+
} catch (err) {
|
|
27835
|
+
console.warn("\u26A0\uFE0F Failed to fetch default value for dropdown:", err);
|
|
27836
|
+
} finally {
|
|
27837
|
+
setLoading(false);
|
|
27838
|
+
}
|
|
27839
|
+
};
|
|
27840
|
+
(0, import_react19.useEffect)(() => {
|
|
27841
|
+
const cfg = configRef.current;
|
|
27842
|
+
if (!cfg.enabled || !cfg.value || cfg.dataSource !== "api" || !cfg.apiUrl) return;
|
|
27843
|
+
const valueExists = options.some((opt) => opt.value === cfg.value);
|
|
27844
|
+
if (valueExists) return;
|
|
27845
|
+
fetchValueItem();
|
|
27846
|
+
}, [config.value, config.dataKey, config.apiUrl, config.dataSource, transformToOptions]);
|
|
27817
27847
|
const loadMore = (0, import_react19.useCallback)(() => {
|
|
27818
27848
|
if (!loading && hasMore) {
|
|
27819
27849
|
loadPage(page + 1, searchTerm);
|
|
@@ -27890,7 +27920,8 @@ function LazySelectDropdown({
|
|
|
27890
27920
|
pageSize: pageSize || 10,
|
|
27891
27921
|
dataKey,
|
|
27892
27922
|
dataLabel,
|
|
27893
|
-
initialData: options || []
|
|
27923
|
+
initialData: options || [],
|
|
27924
|
+
value
|
|
27894
27925
|
});
|
|
27895
27926
|
const selectedOption = lazyOptions.find((opt) => opt.value === value);
|
|
27896
27927
|
(0, import_react20.useEffect)(() => {
|
|
@@ -27955,7 +27986,7 @@ function LazySelectDropdown({
|
|
|
27955
27986
|
"div",
|
|
27956
27987
|
{
|
|
27957
27988
|
onMouseDown: (e) => e.stopPropagation(),
|
|
27958
|
-
className: "absolute z-[
|
|
27989
|
+
className: "absolute z-[900] w-fit mt-1 bg-white border border-gray-300 rounded-lg shadow-lg max-h-60 overflow-y-auto",
|
|
27959
27990
|
style: {
|
|
27960
27991
|
width: dropdownRef.current?.offsetWidth,
|
|
27961
27992
|
top: dropdownRef.current ? dropdownRef.current.getBoundingClientRect().bottom + window.scrollY : 0,
|
|
@@ -29326,7 +29357,10 @@ var useDynamicColumns = (config, customRenderers = {}, customFormatters = {}) =>
|
|
|
29326
29357
|
col.format,
|
|
29327
29358
|
customFormatters
|
|
29328
29359
|
);
|
|
29329
|
-
}
|
|
29360
|
+
},
|
|
29361
|
+
enableSorting: col.enableSorting,
|
|
29362
|
+
enableColumnFilter: col.enableColumnFilter,
|
|
29363
|
+
meta: col.meta
|
|
29330
29364
|
});
|
|
29331
29365
|
});
|
|
29332
29366
|
};
|
|
@@ -29349,37 +29383,13 @@ function DataTable({
|
|
|
29349
29383
|
globalSearch,
|
|
29350
29384
|
onCellClick,
|
|
29351
29385
|
onDeleteRow,
|
|
29352
|
-
|
|
29386
|
+
rowActions
|
|
29353
29387
|
}) {
|
|
29354
29388
|
const [columnFilters, setColumnFilters] = React9.useState([]);
|
|
29355
29389
|
const [columnVisibility, setColumnVisibility] = React9.useState({});
|
|
29356
29390
|
const [manualSort, setManualSort] = React9.useState(null);
|
|
29357
29391
|
const [searchTerm, setSearchTerm] = React9.useState("");
|
|
29358
|
-
const
|
|
29359
|
-
id: "delete",
|
|
29360
|
-
header: "Actions",
|
|
29361
|
-
cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
29362
|
-
"button",
|
|
29363
|
-
{
|
|
29364
|
-
className: "px-3 py-1 text-[12px] bg-red-800 text-white rounded hover:bg-neutral-600 cursor-pointer",
|
|
29365
|
-
onClick: (event) => {
|
|
29366
|
-
event.stopPropagation();
|
|
29367
|
-
if (onDeleteRow) {
|
|
29368
|
-
onDeleteRow(row.original, "delete");
|
|
29369
|
-
}
|
|
29370
|
-
},
|
|
29371
|
-
children: "Delete"
|
|
29372
|
-
}
|
|
29373
|
-
),
|
|
29374
|
-
meta: { isClickable: true }
|
|
29375
|
-
}), [onDeleteRow]);
|
|
29376
|
-
const combinedColumns = React9.useMemo(() => {
|
|
29377
|
-
if (enableDelete) {
|
|
29378
|
-
return [...columns, deleteColumn];
|
|
29379
|
-
}
|
|
29380
|
-
return columns;
|
|
29381
|
-
}, [columns, enableDelete, deleteColumn]);
|
|
29382
|
-
const dynamicCols = useDynamicColumns({ columns: combinedColumns });
|
|
29392
|
+
const dynamicCols = useDynamicColumns({ columns });
|
|
29383
29393
|
const table = (0, import_react_table2.useReactTable)({
|
|
29384
29394
|
data,
|
|
29385
29395
|
columns: dynamicCols,
|
|
@@ -29505,7 +29515,7 @@ function DataTable({
|
|
|
29505
29515
|
] })
|
|
29506
29516
|
] }),
|
|
29507
29517
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Table3, { children: [
|
|
29508
|
-
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableHeader, { children: table.getHeaderGroups().map((hg) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableRow, { children: hg.headers.map((header) => {
|
|
29518
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableHeader, { children: table.getHeaderGroups().map((hg) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableRow, { children: hg.headers.map((header, index) => {
|
|
29509
29519
|
const canSort = header.column.getCanSort();
|
|
29510
29520
|
const canFilter = header.column.getCanFilter();
|
|
29511
29521
|
const sortDir = manualSort?.key === header.column.id ? manualSort.dir : null;
|
|
@@ -29585,26 +29595,49 @@ function DataTable({
|
|
|
29585
29595
|
}
|
|
29586
29596
|
)
|
|
29587
29597
|
] })
|
|
29588
|
-
] }) }, header.id);
|
|
29589
|
-
}) }, hg.id)) }),
|
|
29590
|
-
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableBody, { children: loading ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableRow, { children:
|
|
29598
|
+
] }) }, `header-${header.id}-${index}`);
|
|
29599
|
+
}) }, `header-group-${hg.id}`)) }),
|
|
29600
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableBody, { children: loading ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_jsx_runtime53.Fragment, { children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableRow, { children: dynamicCols.map((_2, j) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableCell, { className: "p-3", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("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__ */ (0, import_jsx_runtime53.jsx)(TableRow, { children: row.getVisibleCells().map((cell, cellIndex, arr) => {
|
|
29591
29601
|
const meta = cell.column.columnDef.meta || {};
|
|
29592
29602
|
const isClickable = meta?.isClickable;
|
|
29593
|
-
|
|
29603
|
+
const isLastCell = cellIndex === arr.length - 1;
|
|
29604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
29594
29605
|
TableCell,
|
|
29595
29606
|
{
|
|
29596
|
-
className: `${meta?.cellClass ?? ""} ${isClickable ? "cursor-pointer hover:bg-gray-100" : ""}`,
|
|
29607
|
+
className: `${meta?.cellClass ?? ""} ${isClickable ? "cursor-pointer hover:bg-gray-100" : ""} relative`,
|
|
29597
29608
|
style: meta?.cellStyle,
|
|
29598
29609
|
onClick: () => {
|
|
29599
29610
|
if (isClickable && onCellClick) {
|
|
29600
29611
|
onCellClick(cell.row.original, cell.column.id);
|
|
29601
29612
|
}
|
|
29602
29613
|
},
|
|
29603
|
-
children:
|
|
29614
|
+
children: [
|
|
29615
|
+
(0, import_react_table2.flexRender)(cell.column.columnDef.cell, cell.getContext()),
|
|
29616
|
+
isLastCell && rowActions && rowActions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "absolute bg-[#fff] p-1 px-4 inset-y-0 right-0 flex items-center opacity-0 group-hover:opacity-100 transition-opacity duration-200 shadow-lg rounded", children: rowActions.map((action) => {
|
|
29617
|
+
const isDelete = action.id === "delete" || action.icon === "delete";
|
|
29618
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
29619
|
+
"button",
|
|
29620
|
+
{
|
|
29621
|
+
className: `ml-2 px-2 py-1 text-[12px] rounded cursor-pointer ${isDelete ? "bg-red-800 text-white hover:bg-neutral-600" : "bg-gray-300 hover:bg-gray-400"}`,
|
|
29622
|
+
onClick: (event) => {
|
|
29623
|
+
event.stopPropagation();
|
|
29624
|
+
if (isDelete) {
|
|
29625
|
+
onDeleteRow?.(cell.row.original, "delete");
|
|
29626
|
+
} else {
|
|
29627
|
+
onCellClick?.(cell.row.original, cell.column.id);
|
|
29628
|
+
}
|
|
29629
|
+
},
|
|
29630
|
+
title: action.header,
|
|
29631
|
+
children: action.header
|
|
29632
|
+
},
|
|
29633
|
+
action.id
|
|
29634
|
+
);
|
|
29635
|
+
}) })
|
|
29636
|
+
]
|
|
29604
29637
|
},
|
|
29605
|
-
cell.id
|
|
29638
|
+
`cell-${cell.id}-${cellIndex}`
|
|
29606
29639
|
);
|
|
29607
|
-
}) }, row.id)) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableCell, { colSpan:
|
|
29640
|
+
}) }, row.id)) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(TableCell, { colSpan: dynamicCols.length, className: "h-24 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "flex items-center justify-center py-10 w-full min-w-full text-gray-600 bg-gray-100", children: "No results." }) }) }) })
|
|
29608
29641
|
] }),
|
|
29609
29642
|
pagination && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "flex items-center justify-between py-3 px-2 text-sm w-full", children: [
|
|
29610
29643
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { children: [
|
|
@@ -29671,7 +29704,6 @@ var Table4 = ({
|
|
|
29671
29704
|
totalRecords = 0,
|
|
29672
29705
|
globalSearch = false,
|
|
29673
29706
|
onCellClick,
|
|
29674
|
-
enableDelete,
|
|
29675
29707
|
onDeleteRow,
|
|
29676
29708
|
...props
|
|
29677
29709
|
}) => {
|
|
@@ -29703,8 +29735,7 @@ var Table4 = ({
|
|
|
29703
29735
|
},
|
|
29704
29736
|
onDeleteRow: (cell) => {
|
|
29705
29737
|
onDeleteRow?.(cell.id);
|
|
29706
|
-
}
|
|
29707
|
-
enableDelete
|
|
29738
|
+
}
|
|
29708
29739
|
}
|
|
29709
29740
|
) });
|
|
29710
29741
|
};
|
|
@@ -30097,27 +30128,42 @@ var Tabs_default = Tabs;
|
|
|
30097
30128
|
// src/components/Navigation/Stages/Stages.tsx
|
|
30098
30129
|
var import_react30 = __toESM(require("react"));
|
|
30099
30130
|
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
30100
|
-
var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage }) => {
|
|
30131
|
+
var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey = "key", dataLabel = "header" }) => {
|
|
30132
|
+
const [activeStage, setActiveStage] = (0, import_react30.useState)(currentStage || (stages && stages.length > 0 ? stages[0].key : null));
|
|
30133
|
+
const nextStage = () => {
|
|
30134
|
+
if (!stages || stages.length === 0) return;
|
|
30135
|
+
const currentIndex = stages.findIndex((stage) => stage[dataKey] === activeStage);
|
|
30136
|
+
if (currentIndex < stages.length - 1) {
|
|
30137
|
+
const newStage = stages[currentIndex + 1];
|
|
30138
|
+
setActiveStage(newStage[dataKey]);
|
|
30139
|
+
onStageChange?.(newStage[dataKey]);
|
|
30140
|
+
}
|
|
30141
|
+
};
|
|
30142
|
+
const lastStage = stages && stages.length > 0 ? stages[stages.length - 1][dataKey] : null;
|
|
30143
|
+
const onStageClick = (stageKey) => {
|
|
30144
|
+
if (!stageKey || stageKey === activeStage || activeStage === lastStage) return;
|
|
30145
|
+
setActiveStage(stageKey);
|
|
30146
|
+
onStageChange?.(stageKey);
|
|
30147
|
+
};
|
|
30148
|
+
const isAllStagesCompleted = activeStage === lastStage;
|
|
30101
30149
|
return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className, style, children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "flex items-center justify-between bg-red p-2 rounded-lg border border-gray-200 w-full", children: [
|
|
30102
30150
|
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("button", { className: "p-2 hover:bg-gray-100 rounded", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("svg", { className: "w-4 h-4 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) }) }) }),
|
|
30103
30151
|
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex items-center flex-1 px-2 flex-wrap gap-2", children: stages?.length > 0 && stages?.map((stage, index) => {
|
|
30104
|
-
const currentIndex = stages.findIndex((s) => s
|
|
30105
|
-
const
|
|
30106
|
-
const
|
|
30107
|
-
const isActive = !isAllCompleted && index === currentIndex;
|
|
30152
|
+
const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
|
|
30153
|
+
const isCompleted = isAllStagesCompleted || index < currentIndex;
|
|
30154
|
+
const isActive = !isAllStagesCompleted && index === currentIndex;
|
|
30108
30155
|
return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_react30.default.Fragment, { children: [
|
|
30109
30156
|
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
30110
30157
|
"button",
|
|
30111
30158
|
{
|
|
30112
30159
|
className: `
|
|
30113
30160
|
min-w-[120px] px-4 py-2 rounded-full text-sm font-medium transition-colors duration-200 whitespace-nowrap
|
|
30114
|
-
${isActive ? "bg-
|
|
30161
|
+
${isActive ? "bg-green-700 text-white shadow-md" : isCompleted ? "bg-green-50 text-green-700 border border-green-700" : "bg-white text-gray-700 hover:bg-gray-100 border border-gray-200"}`,
|
|
30115
30162
|
onClick: () => {
|
|
30116
|
-
if (
|
|
30117
|
-
|
|
30118
|
-
}
|
|
30163
|
+
if (isAllStagesCompleted) return;
|
|
30164
|
+
onStageClick(stage[dataKey]);
|
|
30119
30165
|
},
|
|
30120
|
-
children: stage
|
|
30166
|
+
children: stage[dataLabel]
|
|
30121
30167
|
}
|
|
30122
30168
|
),
|
|
30123
30169
|
index < stages.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex-shrink-0 w-3 h-px bg-gray-300" })
|
|
@@ -30126,9 +30172,9 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
|
|
|
30126
30172
|
isShowBtn && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
30127
30173
|
"button",
|
|
30128
30174
|
{
|
|
30129
|
-
className: "bg-
|
|
30175
|
+
className: "bg-green-700 text-white px-6 py-2 rounded-lg text-sm font-medium transition-colors duration-200 shadow-sm",
|
|
30130
30176
|
onClick: () => {
|
|
30131
|
-
|
|
30177
|
+
nextStage();
|
|
30132
30178
|
},
|
|
30133
30179
|
children: buttonText
|
|
30134
30180
|
}
|