@algorithm-shift/design-system 1.2.87 → 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.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"> & {
@@ -375,7 +377,7 @@ declare const CustomPagination: ({ totalPages, currentPage, onPageChange, maxVis
375
377
 
376
378
  declare const Tabs: ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder, source, parentKey, menuNameKey, menuUrlKey, loading }: TabsProps) => react_jsx_runtime.JSX.Element;
377
379
 
378
- 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;
379
381
 
380
382
  declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
381
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"> & {
@@ -375,7 +377,7 @@ declare const CustomPagination: ({ totalPages, currentPage, onPageChange, maxVis
375
377
 
376
378
  declare const Tabs: ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder, source, parentKey, menuNameKey, menuUrlKey, loading }: TabsProps) => react_jsx_runtime.JSX.Element;
377
379
 
378
- 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;
379
381
 
380
382
  declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
381
383
 
package/dist/index.js CHANGED
@@ -30128,27 +30128,42 @@ var Tabs_default = Tabs;
30128
30128
  // src/components/Navigation/Stages/Stages.tsx
30129
30129
  var import_react30 = __toESM(require("react"));
30130
30130
  var import_jsx_runtime58 = require("react/jsx-runtime");
30131
- 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;
30132
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: [
30133
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" }) }) }) }),
30134
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) => {
30135
- const currentIndex = stages.findIndex((s) => s.key === currentStage);
30136
- const isAllCompleted = currentStage === "completed";
30137
- const isCompleted = isAllCompleted || index < currentIndex;
30138
- 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;
30139
30155
  return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_react30.default.Fragment, { children: [
30140
30156
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
30141
30157
  "button",
30142
30158
  {
30143
30159
  className: `
30144
30160
  min-w-[120px] px-4 py-2 rounded-full text-sm font-medium transition-colors duration-200 whitespace-nowrap
30145
- ${isActive ? "bg-[#034486] text-white shadow-md" : isCompleted ? "bg-[#e0f2fe] text-[#034486] border border-[#034486]" : "bg-white text-gray-700 hover:bg-gray-100 border border-gray-200"}`,
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"}`,
30146
30162
  onClick: () => {
30147
- if (onStageChange) {
30148
- onStageChange(stage.key);
30149
- }
30163
+ if (isAllStagesCompleted) return;
30164
+ onStageClick(stage[dataKey]);
30150
30165
  },
30151
- children: stage.header
30166
+ children: stage[dataLabel]
30152
30167
  }
30153
30168
  ),
30154
30169
  index < stages.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex-shrink-0 w-3 h-px bg-gray-300" })
@@ -30157,9 +30172,9 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
30157
30172
  isShowBtn && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
30158
30173
  "button",
30159
30174
  {
30160
- className: "bg-[#034486] text-white px-6 py-2 rounded-lg text-sm font-medium transition-colors duration-200 shadow-sm",
30175
+ className: "bg-green-700 text-white px-6 py-2 rounded-lg text-sm font-medium transition-colors duration-200 shadow-sm",
30161
30176
  onClick: () => {
30162
- onStageChange?.("completed");
30177
+ nextStage();
30163
30178
  },
30164
30179
  children: buttonText
30165
30180
  }