@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.d.mts
CHANGED
|
@@ -150,6 +150,8 @@ interface StagesProps extends ElementProps {
|
|
|
150
150
|
dataKey?: string;
|
|
151
151
|
dataLabel?: string;
|
|
152
152
|
loading?: boolean;
|
|
153
|
+
triggerOnClick?: boolean;
|
|
154
|
+
saving?: boolean;
|
|
153
155
|
}
|
|
154
156
|
|
|
155
157
|
type ButtonProps = ElementProps & React.ComponentProps<"button"> & {
|
|
@@ -386,7 +388,7 @@ declare const CustomPagination: ({ totalPages, currentPage, onPageChange, maxVis
|
|
|
386
388
|
|
|
387
389
|
declare const Tabs: ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder, source, parentKey, menuNameKey, menuUrlKey, loading, bgActiveColor, textActiveColor }: TabsProps) => react_jsx_runtime.JSX.Element;
|
|
388
390
|
|
|
389
|
-
declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey, dataLabel, loading }: StagesProps) => react_jsx_runtime.JSX.Element;
|
|
391
|
+
declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey, dataLabel, loading, saving, triggerOnClick }: StagesProps) => react_jsx_runtime.JSX.Element;
|
|
390
392
|
|
|
391
393
|
declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
|
|
392
394
|
|
package/dist/index.d.ts
CHANGED
|
@@ -150,6 +150,8 @@ interface StagesProps extends ElementProps {
|
|
|
150
150
|
dataKey?: string;
|
|
151
151
|
dataLabel?: string;
|
|
152
152
|
loading?: boolean;
|
|
153
|
+
triggerOnClick?: boolean;
|
|
154
|
+
saving?: boolean;
|
|
153
155
|
}
|
|
154
156
|
|
|
155
157
|
type ButtonProps = ElementProps & React.ComponentProps<"button"> & {
|
|
@@ -386,7 +388,7 @@ declare const CustomPagination: ({ totalPages, currentPage, onPageChange, maxVis
|
|
|
386
388
|
|
|
387
389
|
declare const Tabs: ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder, source, parentKey, menuNameKey, menuUrlKey, loading, bgActiveColor, textActiveColor }: TabsProps) => react_jsx_runtime.JSX.Element;
|
|
388
390
|
|
|
389
|
-
declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey, dataLabel, loading }: StagesProps) => react_jsx_runtime.JSX.Element;
|
|
391
|
+
declare const StagesComponent: ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey, dataLabel, loading, saving, triggerOnClick }: StagesProps) => react_jsx_runtime.JSX.Element;
|
|
390
392
|
|
|
391
393
|
declare const Spacer: ({ className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
|
|
392
394
|
|
package/dist/index.js
CHANGED
|
@@ -30374,24 +30374,38 @@ var Tabs_default = Tabs;
|
|
|
30374
30374
|
// src/components/Navigation/Stages/Stages.tsx
|
|
30375
30375
|
var import_react32 = __toESM(require("react"));
|
|
30376
30376
|
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
30377
|
-
var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey = "key", dataLabel = "header", loading }) => {
|
|
30377
|
+
var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStageChange, currentStage, dataKey = "key", dataLabel = "header", loading, saving, triggerOnClick = false }) => {
|
|
30378
30378
|
const [activeStage, setActiveStage] = (0, import_react32.useState)(currentStage || (stages && stages.length > 0 ? stages[0].key : null));
|
|
30379
|
+
const [isCompleted, setIsCompleted] = (0, import_react32.useState)(false);
|
|
30380
|
+
const updateStage = (stageKey) => {
|
|
30381
|
+
setActiveStage(stageKey);
|
|
30382
|
+
onStageChange?.(stageKey);
|
|
30383
|
+
};
|
|
30379
30384
|
const nextStage = () => {
|
|
30380
30385
|
if (!stages || stages.length === 0) return;
|
|
30381
30386
|
const currentIndex = stages.findIndex((stage) => stage[dataKey] === activeStage);
|
|
30382
|
-
if (currentIndex
|
|
30383
|
-
const
|
|
30384
|
-
|
|
30385
|
-
|
|
30387
|
+
if (currentIndex + 1 === stages.length) {
|
|
30388
|
+
const currentStage2 = stages[currentIndex];
|
|
30389
|
+
updateStage(currentStage2[dataKey]);
|
|
30390
|
+
setIsCompleted(true);
|
|
30391
|
+
return;
|
|
30392
|
+
}
|
|
30393
|
+
if (currentIndex < stages.length) {
|
|
30394
|
+
const currentStage2 = stages[currentIndex];
|
|
30395
|
+
updateStage(currentStage2[dataKey]);
|
|
30396
|
+
return;
|
|
30386
30397
|
}
|
|
30387
30398
|
};
|
|
30388
30399
|
const lastStage = stages && stages.length > 0 ? stages[stages.length - 1][dataKey] : null;
|
|
30389
30400
|
const onStageClick = (stageKey) => {
|
|
30390
30401
|
if (!stageKey || stageKey === activeStage || activeStage === lastStage) return;
|
|
30391
30402
|
setActiveStage(stageKey);
|
|
30392
|
-
|
|
30403
|
+
if (triggerOnClick) {
|
|
30404
|
+
onStageChange?.(stageKey);
|
|
30405
|
+
}
|
|
30393
30406
|
};
|
|
30394
|
-
const isAllStagesCompleted =
|
|
30407
|
+
const isAllStagesCompleted = isCompleted || currentStage === lastStage;
|
|
30408
|
+
const disabled = isAllStagesCompleted || loading || saving;
|
|
30395
30409
|
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className, style, children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "flex items-center justify-between bg-red p-2 rounded-lg border border-gray-200 w-full", children: [
|
|
30396
30410
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("button", { className: "p-2 hover:bg-gray-100 rounded", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("svg", { className: "w-4 h-4 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) }) }) }),
|
|
30397
30411
|
/* @__PURE__ */ (0, import_jsx_runtime57.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_runtime57.jsx)(
|
|
@@ -30405,7 +30419,7 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
|
|
|
30405
30419
|
index
|
|
30406
30420
|
)) : stages?.length > 0 && stages?.map((stage, index) => {
|
|
30407
30421
|
const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
|
|
30408
|
-
const
|
|
30422
|
+
const isCompleted2 = isAllStagesCompleted || index < currentIndex;
|
|
30409
30423
|
const isActive = !isAllStagesCompleted && index === currentIndex;
|
|
30410
30424
|
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_react32.default.Fragment, { children: [
|
|
30411
30425
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
@@ -30413,7 +30427,7 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
|
|
|
30413
30427
|
{
|
|
30414
30428
|
className: `
|
|
30415
30429
|
min-w-[80px] px-4 py-2 rounded-full text-sm font-medium transition-colors duration-200 whitespace-nowrap
|
|
30416
|
-
${isActive ? "bg-green-700 text-white shadow-md" :
|
|
30430
|
+
${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"}`,
|
|
30417
30431
|
onClick: () => {
|
|
30418
30432
|
if (isAllStagesCompleted) return;
|
|
30419
30433
|
onStageClick(stage[dataKey]);
|
|
@@ -30427,11 +30441,12 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
|
|
|
30427
30441
|
isShowBtn && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
30428
30442
|
"button",
|
|
30429
30443
|
{
|
|
30430
|
-
className:
|
|
30444
|
+
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" : ""}`,
|
|
30431
30445
|
onClick: () => {
|
|
30432
30446
|
nextStage();
|
|
30433
30447
|
},
|
|
30434
|
-
|
|
30448
|
+
disabled,
|
|
30449
|
+
children: saving ? "Updating..." : buttonText
|
|
30435
30450
|
}
|
|
30436
30451
|
) })
|
|
30437
30452
|
] }) });
|