@algorithm-shift/design-system 1.2.963 → 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 +30 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -29894,7 +29894,7 @@ var Pagination_default = CustomPagination;
|
|
|
29894
29894
|
// src/components/Navigation/Tabs/Tabs.tsx
|
|
29895
29895
|
import { useCallback as useCallback3, useMemo as useMemo6, useState as useState8 } from "react";
|
|
29896
29896
|
import Link5 from "next/link";
|
|
29897
|
-
import { useRouter } from "next/navigation";
|
|
29897
|
+
import { usePathname, useRouter } from "next/navigation";
|
|
29898
29898
|
|
|
29899
29899
|
// src/components/ui/dialog.tsx
|
|
29900
29900
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
@@ -30051,6 +30051,7 @@ function showSonnerToast({
|
|
|
30051
30051
|
import { Fragment as Fragment22, jsx as jsx56, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
30052
30052
|
var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder = false, source, parentKey, menuNameKey, menuUrlKey, loading, bgActiveColor, textActiveColor }) => {
|
|
30053
30053
|
const [openIndex, setOpenIndex] = useState8(null);
|
|
30054
|
+
const currentPathname = usePathname();
|
|
30054
30055
|
function groupMenus(menus = []) {
|
|
30055
30056
|
const menuMap = /* @__PURE__ */ new Map();
|
|
30056
30057
|
menus.forEach((menu) => {
|
|
@@ -30099,7 +30100,7 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
|
|
|
30099
30100
|
while (p.endsWith("/")) p = p.slice(0, -1);
|
|
30100
30101
|
return p;
|
|
30101
30102
|
};
|
|
30102
|
-
const current = clean(pathname
|
|
30103
|
+
const current = clean(pathname ?? currentPathname ?? "");
|
|
30103
30104
|
const target = clean(path);
|
|
30104
30105
|
if (!current || !target) return false;
|
|
30105
30106
|
if (current === target) return true;
|
|
@@ -30142,7 +30143,8 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
|
|
|
30142
30143
|
const finalStyle = {
|
|
30143
30144
|
...tab.style,
|
|
30144
30145
|
backgroundColor: active && bgActiveColor ? bgActiveColor : void 0,
|
|
30145
|
-
color: active && textActiveColor ? textActiveColor : void 0
|
|
30146
|
+
color: active && textActiveColor ? textActiveColor : void 0,
|
|
30147
|
+
border: active && textActiveColor ? `1px solid ${textActiveColor}` : void 0
|
|
30146
30148
|
};
|
|
30147
30149
|
if (Array.isArray(tab.children) && tab.children.length > 0 && tab.isDropDown) {
|
|
30148
30150
|
return /* @__PURE__ */ jsxs33(
|
|
@@ -30283,24 +30285,38 @@ var Tabs_default = Tabs;
|
|
|
30283
30285
|
// src/components/Navigation/Stages/Stages.tsx
|
|
30284
30286
|
import React10, { useState as useState9 } from "react";
|
|
30285
30287
|
import { jsx as jsx57, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
30286
|
-
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 }) => {
|
|
30287
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
|
+
};
|
|
30288
30295
|
const nextStage = () => {
|
|
30289
30296
|
if (!stages || stages.length === 0) return;
|
|
30290
30297
|
const currentIndex = stages.findIndex((stage) => stage[dataKey] === activeStage);
|
|
30291
|
-
if (currentIndex
|
|
30292
|
-
const
|
|
30293
|
-
|
|
30294
|
-
|
|
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;
|
|
30295
30308
|
}
|
|
30296
30309
|
};
|
|
30297
30310
|
const lastStage = stages && stages.length > 0 ? stages[stages.length - 1][dataKey] : null;
|
|
30298
30311
|
const onStageClick = (stageKey) => {
|
|
30299
30312
|
if (!stageKey || stageKey === activeStage || activeStage === lastStage) return;
|
|
30300
30313
|
setActiveStage(stageKey);
|
|
30301
|
-
|
|
30314
|
+
if (triggerOnClick) {
|
|
30315
|
+
onStageChange?.(stageKey);
|
|
30316
|
+
}
|
|
30302
30317
|
};
|
|
30303
|
-
const isAllStagesCompleted =
|
|
30318
|
+
const isAllStagesCompleted = isCompleted || currentStage === lastStage;
|
|
30319
|
+
const disabled = isAllStagesCompleted || loading || saving;
|
|
30304
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: [
|
|
30305
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" }) }) }) }),
|
|
30306
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(
|
|
@@ -30314,7 +30330,7 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
|
|
|
30314
30330
|
index
|
|
30315
30331
|
)) : stages?.length > 0 && stages?.map((stage, index) => {
|
|
30316
30332
|
const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
|
|
30317
|
-
const
|
|
30333
|
+
const isCompleted2 = isAllStagesCompleted || index < currentIndex;
|
|
30318
30334
|
const isActive = !isAllStagesCompleted && index === currentIndex;
|
|
30319
30335
|
return /* @__PURE__ */ jsxs34(React10.Fragment, { children: [
|
|
30320
30336
|
/* @__PURE__ */ jsx57(
|
|
@@ -30322,7 +30338,7 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
|
|
|
30322
30338
|
{
|
|
30323
30339
|
className: `
|
|
30324
30340
|
min-w-[80px] px-4 py-2 rounded-full text-sm font-medium transition-colors duration-200 whitespace-nowrap
|
|
30325
|
-
${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"}`,
|
|
30326
30342
|
onClick: () => {
|
|
30327
30343
|
if (isAllStagesCompleted) return;
|
|
30328
30344
|
onStageClick(stage[dataKey]);
|
|
@@ -30336,11 +30352,12 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
|
|
|
30336
30352
|
isShowBtn && /* @__PURE__ */ jsx57("div", { className: "flex items-center", children: /* @__PURE__ */ jsx57(
|
|
30337
30353
|
"button",
|
|
30338
30354
|
{
|
|
30339
|
-
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" : ""}`,
|
|
30340
30356
|
onClick: () => {
|
|
30341
30357
|
nextStage();
|
|
30342
30358
|
},
|
|
30343
|
-
|
|
30359
|
+
disabled,
|
|
30360
|
+
children: saving ? "Updating..." : buttonText
|
|
30344
30361
|
}
|
|
30345
30362
|
) })
|
|
30346
30363
|
] }) });
|