@algorithm-shift/design-system 1.2.964 → 1.2.965
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 +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +26 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -30285,24 +30285,38 @@ var Tabs_default = Tabs;
|
|
|
30285
30285
|
// src/components/Navigation/Stages/Stages.tsx
|
|
30286
30286
|
import React10, { useState as useState9 } from "react";
|
|
30287
30287
|
import { jsx as jsx57, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
30288
|
-
var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey = "key", dataLabel = "header", loading }) => {
|
|
30288
|
+
var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey = "key", dataLabel = "header", loading, saving, triggerOnClick = false }) => {
|
|
30289
30289
|
const [activeStage, setActiveStage] = useState9(currentStage || (stages && stages.length > 0 ? stages[0].key : null));
|
|
30290
|
+
const [isCompleted, setIsCompleted] = useState9(false);
|
|
30291
|
+
const updateStage = (stageKey) => {
|
|
30292
|
+
setActiveStage(stageKey);
|
|
30293
|
+
onStageChange?.(stageKey);
|
|
30294
|
+
};
|
|
30290
30295
|
const nextStage = () => {
|
|
30291
30296
|
if (!stages || stages.length === 0) return;
|
|
30292
30297
|
const currentIndex = stages.findIndex((stage) => stage[dataKey] === activeStage);
|
|
30293
|
-
if (currentIndex
|
|
30294
|
-
const
|
|
30295
|
-
|
|
30296
|
-
|
|
30298
|
+
if (currentIndex + 1 === stages.length) {
|
|
30299
|
+
const currentStage2 = stages[currentIndex];
|
|
30300
|
+
updateStage(currentStage2[dataKey]);
|
|
30301
|
+
setIsCompleted(true);
|
|
30302
|
+
return;
|
|
30303
|
+
}
|
|
30304
|
+
if (currentIndex < stages.length) {
|
|
30305
|
+
const currentStage2 = stages[currentIndex];
|
|
30306
|
+
updateStage(currentStage2[dataKey]);
|
|
30307
|
+
return;
|
|
30297
30308
|
}
|
|
30298
30309
|
};
|
|
30299
30310
|
const lastStage = stages && stages.length > 0 ? stages[stages.length - 1][dataKey] : null;
|
|
30300
30311
|
const onStageClick = (stageKey) => {
|
|
30301
30312
|
if (!stageKey || stageKey === activeStage || activeStage === lastStage) return;
|
|
30302
30313
|
setActiveStage(stageKey);
|
|
30303
|
-
|
|
30314
|
+
if (triggerOnClick) {
|
|
30315
|
+
onStageChange?.(stageKey);
|
|
30316
|
+
}
|
|
30304
30317
|
};
|
|
30305
|
-
const isAllStagesCompleted =
|
|
30318
|
+
const isAllStagesCompleted = isCompleted || currentStage === lastStage;
|
|
30319
|
+
const disabled = isAllStagesCompleted || loading || saving;
|
|
30306
30320
|
return /* @__PURE__ */ jsx57("div", { className, style, children: /* @__PURE__ */ jsxs34("div", { className: "flex items-center justify-between bg-red p-2 rounded-lg border border-gray-200 w-full", children: [
|
|
30307
30321
|
/* @__PURE__ */ jsx57("div", { className: "flex items-center", children: /* @__PURE__ */ jsx57("button", { className: "p-2 hover:bg-gray-100 rounded", children: /* @__PURE__ */ jsx57("svg", { className: "w-4 h-4 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx57("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) }) }) }),
|
|
30308
30322
|
/* @__PURE__ */ jsx57("div", { className: "flex items-center flex-1 px-2 flex-wrap gap-2", children: loading ? Array(6).fill(null).map((_, index) => /* @__PURE__ */ jsx57(
|
|
@@ -30316,7 +30330,7 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
|
|
|
30316
30330
|
index
|
|
30317
30331
|
)) : stages?.length > 0 && stages?.map((stage, index) => {
|
|
30318
30332
|
const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
|
|
30319
|
-
const
|
|
30333
|
+
const isCompleted2 = isAllStagesCompleted || index < currentIndex;
|
|
30320
30334
|
const isActive = !isAllStagesCompleted && index === currentIndex;
|
|
30321
30335
|
return /* @__PURE__ */ jsxs34(React10.Fragment, { children: [
|
|
30322
30336
|
/* @__PURE__ */ jsx57(
|
|
@@ -30324,7 +30338,7 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
|
|
|
30324
30338
|
{
|
|
30325
30339
|
className: `
|
|
30326
30340
|
min-w-[80px] px-4 py-2 rounded-full text-sm font-medium transition-colors duration-200 whitespace-nowrap
|
|
30327
|
-
${isActive ? "bg-green-700 text-white shadow-md" :
|
|
30341
|
+
${isActive ? "bg-green-700 text-white shadow-md" : isCompleted2 ? "bg-green-50 text-green-700 border border-green-700" : "bg-white text-gray-700 hover:bg-gray-100 border border-gray-200"}`,
|
|
30328
30342
|
onClick: () => {
|
|
30329
30343
|
if (isAllStagesCompleted) return;
|
|
30330
30344
|
onStageClick(stage[dataKey]);
|
|
@@ -30338,11 +30352,12 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
|
|
|
30338
30352
|
isShowBtn && /* @__PURE__ */ jsx57("div", { className: "flex items-center", children: /* @__PURE__ */ jsx57(
|
|
30339
30353
|
"button",
|
|
30340
30354
|
{
|
|
30341
|
-
className:
|
|
30355
|
+
className: `bg-green-700 text-white px-6 py-2 rounded-lg text-sm font-medium transition-colors duration-200 shadow-sm ${disabled ? "opacity-50 cursor-not-allowed" : ""}`,
|
|
30342
30356
|
onClick: () => {
|
|
30343
30357
|
nextStage();
|
|
30344
30358
|
},
|
|
30345
|
-
|
|
30359
|
+
disabled,
|
|
30360
|
+
children: saving ? "Updating..." : buttonText
|
|
30346
30361
|
}
|
|
30347
30362
|
) })
|
|
30348
30363
|
] }) });
|