@algorithm-shift/design-system 1.2.87 → 1.2.89

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,9 @@ interface StagesProps extends ElementProps {
143
143
  buttonText?: string;
144
144
  onStageChange?: (stageId: string) => void;
145
145
  currentStage?: string;
146
+ dataKey?: string;
147
+ dataLabel?: string;
148
+ loading?: boolean;
146
149
  }
147
150
 
148
151
  type ButtonProps = ElementProps & React.ComponentProps<"button"> & {
@@ -375,7 +378,7 @@ declare const CustomPagination: ({ totalPages, currentPage, onPageChange, maxVis
375
378
 
376
379
  declare const Tabs: ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder, source, parentKey, menuNameKey, menuUrlKey, loading }: TabsProps) => react_jsx_runtime.JSX.Element;
377
380
 
378
- declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage }: StagesProps) => react_jsx_runtime.JSX.Element;
381
+ declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey, dataLabel, loading }: StagesProps) => react_jsx_runtime.JSX.Element;
379
382
 
380
383
  declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
381
384
 
package/dist/index.d.ts CHANGED
@@ -143,6 +143,9 @@ interface StagesProps extends ElementProps {
143
143
  buttonText?: string;
144
144
  onStageChange?: (stageId: string) => void;
145
145
  currentStage?: string;
146
+ dataKey?: string;
147
+ dataLabel?: string;
148
+ loading?: boolean;
146
149
  }
147
150
 
148
151
  type ButtonProps = ElementProps & React.ComponentProps<"button"> & {
@@ -375,7 +378,7 @@ declare const CustomPagination: ({ totalPages, currentPage, onPageChange, maxVis
375
378
 
376
379
  declare const Tabs: ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder, source, parentKey, menuNameKey, menuUrlKey, loading }: TabsProps) => react_jsx_runtime.JSX.Element;
377
380
 
378
- declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage }: StagesProps) => react_jsx_runtime.JSX.Element;
381
+ declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey, dataLabel, loading }: StagesProps) => react_jsx_runtime.JSX.Element;
379
382
 
380
383
  declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
381
384
 
package/dist/index.js CHANGED
@@ -30128,27 +30128,51 @@ 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", loading }) => {
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
- /* @__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;
30151
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex items-center flex-1 px-2 flex-wrap gap-2", children: loading ? Array(6).fill(null).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
30152
+ "button",
30153
+ {
30154
+ className: `
30155
+ min-w-[80px] min-h-[35px] px-4 py-2 rounded-full text-sm font-medium transition-colors duration-200 whitespace-nowrap
30156
+ text-gray-700 hover:bg-gray-100 border border-gray-200 bg-gray-100 animate-pulse`,
30157
+ disabled: true
30158
+ },
30159
+ index
30160
+ )) : stages?.length > 0 && stages?.map((stage, index) => {
30161
+ const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
30162
+ const isCompleted = isAllStagesCompleted || index < currentIndex;
30163
+ const isActive = !isAllStagesCompleted && index === currentIndex;
30139
30164
  return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_react30.default.Fragment, { children: [
30140
30165
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
30141
30166
  "button",
30142
30167
  {
30143
30168
  className: `
30144
- 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"}`,
30169
+ min-w-[80px] px-4 py-2 rounded-full text-sm font-medium transition-colors duration-200 whitespace-nowrap
30170
+ ${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
30171
  onClick: () => {
30147
- if (onStageChange) {
30148
- onStageChange(stage.key);
30149
- }
30172
+ if (isAllStagesCompleted) return;
30173
+ onStageClick(stage[dataKey]);
30150
30174
  },
30151
- children: stage.header
30175
+ children: stage[dataLabel]
30152
30176
  }
30153
30177
  ),
30154
30178
  index < stages.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex-shrink-0 w-3 h-px bg-gray-300" })
@@ -30157,9 +30181,9 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
30157
30181
  isShowBtn && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
30158
30182
  "button",
30159
30183
  {
30160
- className: "bg-[#034486] text-white px-6 py-2 rounded-lg text-sm font-medium transition-colors duration-200 shadow-sm",
30184
+ className: "bg-green-700 text-white px-6 py-2 rounded-lg text-sm font-medium transition-colors duration-200 shadow-sm",
30161
30185
  onClick: () => {
30162
- onStageChange?.("completed");
30186
+ nextStage();
30163
30187
  },
30164
30188
  children: buttonText
30165
30189
  }