@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.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
|
@@ -30140,6 +30140,7 @@ function showSonnerToast({
|
|
|
30140
30140
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
30141
30141
|
var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuilder = false, source, parentKey, menuNameKey, menuUrlKey, loading, bgActiveColor, textActiveColor }) => {
|
|
30142
30142
|
const [openIndex, setOpenIndex] = (0, import_react31.useState)(null);
|
|
30143
|
+
const currentPathname = (0, import_navigation3.usePathname)();
|
|
30143
30144
|
function groupMenus(menus = []) {
|
|
30144
30145
|
const menuMap = /* @__PURE__ */ new Map();
|
|
30145
30146
|
menus.forEach((menu) => {
|
|
@@ -30188,7 +30189,7 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
|
|
|
30188
30189
|
while (p.endsWith("/")) p = p.slice(0, -1);
|
|
30189
30190
|
return p;
|
|
30190
30191
|
};
|
|
30191
|
-
const current = clean(pathname
|
|
30192
|
+
const current = clean(pathname ?? currentPathname ?? "");
|
|
30192
30193
|
const target = clean(path);
|
|
30193
30194
|
if (!current || !target) return false;
|
|
30194
30195
|
if (current === target) return true;
|
|
@@ -30231,7 +30232,8 @@ var Tabs = ({ className, style, tabs, verticalMenu, pathname, canvasMode, isBuil
|
|
|
30231
30232
|
const finalStyle = {
|
|
30232
30233
|
...tab.style,
|
|
30233
30234
|
backgroundColor: active && bgActiveColor ? bgActiveColor : void 0,
|
|
30234
|
-
color: active && textActiveColor ? textActiveColor : void 0
|
|
30235
|
+
color: active && textActiveColor ? textActiveColor : void 0,
|
|
30236
|
+
border: active && textActiveColor ? `1px solid ${textActiveColor}` : void 0
|
|
30235
30237
|
};
|
|
30236
30238
|
if (Array.isArray(tab.children) && tab.children.length > 0 && tab.isDropDown) {
|
|
30237
30239
|
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
|
|
@@ -30372,24 +30374,38 @@ var Tabs_default = Tabs;
|
|
|
30372
30374
|
// src/components/Navigation/Stages/Stages.tsx
|
|
30373
30375
|
var import_react32 = __toESM(require("react"));
|
|
30374
30376
|
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
30375
|
-
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 }) => {
|
|
30376
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
|
+
};
|
|
30377
30384
|
const nextStage = () => {
|
|
30378
30385
|
if (!stages || stages.length === 0) return;
|
|
30379
30386
|
const currentIndex = stages.findIndex((stage) => stage[dataKey] === activeStage);
|
|
30380
|
-
if (currentIndex
|
|
30381
|
-
const
|
|
30382
|
-
|
|
30383
|
-
|
|
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;
|
|
30384
30397
|
}
|
|
30385
30398
|
};
|
|
30386
30399
|
const lastStage = stages && stages.length > 0 ? stages[stages.length - 1][dataKey] : null;
|
|
30387
30400
|
const onStageClick = (stageKey) => {
|
|
30388
30401
|
if (!stageKey || stageKey === activeStage || activeStage === lastStage) return;
|
|
30389
30402
|
setActiveStage(stageKey);
|
|
30390
|
-
|
|
30403
|
+
if (triggerOnClick) {
|
|
30404
|
+
onStageChange?.(stageKey);
|
|
30405
|
+
}
|
|
30391
30406
|
};
|
|
30392
|
-
const isAllStagesCompleted =
|
|
30407
|
+
const isAllStagesCompleted = isCompleted || currentStage === lastStage;
|
|
30408
|
+
const disabled = isAllStagesCompleted || loading || saving;
|
|
30393
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: [
|
|
30394
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" }) }) }) }),
|
|
30395
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)(
|
|
@@ -30403,7 +30419,7 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
|
|
|
30403
30419
|
index
|
|
30404
30420
|
)) : stages?.length > 0 && stages?.map((stage, index) => {
|
|
30405
30421
|
const currentIndex = stages.findIndex((s) => s[dataKey] === activeStage);
|
|
30406
|
-
const
|
|
30422
|
+
const isCompleted2 = isAllStagesCompleted || index < currentIndex;
|
|
30407
30423
|
const isActive = !isAllStagesCompleted && index === currentIndex;
|
|
30408
30424
|
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_react32.default.Fragment, { children: [
|
|
30409
30425
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
@@ -30411,7 +30427,7 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
|
|
|
30411
30427
|
{
|
|
30412
30428
|
className: `
|
|
30413
30429
|
min-w-[80px] px-4 py-2 rounded-full text-sm font-medium transition-colors duration-200 whitespace-nowrap
|
|
30414
|
-
${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"}`,
|
|
30415
30431
|
onClick: () => {
|
|
30416
30432
|
if (isAllStagesCompleted) return;
|
|
30417
30433
|
onStageClick(stage[dataKey]);
|
|
@@ -30425,11 +30441,12 @@ var StagesComponent = ({ stages, isShowBtn, buttonText, className, style, onStag
|
|
|
30425
30441
|
isShowBtn && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
30426
30442
|
"button",
|
|
30427
30443
|
{
|
|
30428
|
-
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" : ""}`,
|
|
30429
30445
|
onClick: () => {
|
|
30430
30446
|
nextStage();
|
|
30431
30447
|
},
|
|
30432
|
-
|
|
30448
|
+
disabled,
|
|
30449
|
+
children: saving ? "Updating..." : buttonText
|
|
30433
30450
|
}
|
|
30434
30451
|
) })
|
|
30435
30452
|
] }) });
|