@algorithm-shift/design-system 1.3.124 → 1.3.126
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.css +17 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +187 -100
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +187 -100
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -174,6 +174,7 @@ interface StagesProps extends ElementProps {
|
|
|
174
174
|
saving?: boolean;
|
|
175
175
|
canvasMode?: 'desktop' | 'tablet' | 'mobile' | 'app';
|
|
176
176
|
primaryColor?: string
|
|
177
|
+
[key: string]: any;
|
|
177
178
|
}
|
|
178
179
|
|
|
179
180
|
type ButtonProps = ElementProps & React.ComponentProps<"button"> & {
|
|
@@ -365,7 +366,10 @@ declare const ImageControl: ({ className, style, imageUrl, altText, apiUrl, ...p
|
|
|
365
366
|
|
|
366
367
|
declare const Shape: ({ children, className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
|
|
367
368
|
|
|
368
|
-
|
|
369
|
+
type TypographyWrapperProps = TypographyProps & {
|
|
370
|
+
format?: string;
|
|
371
|
+
};
|
|
372
|
+
declare const Typography: ({ className, style, tagName, textContent, onClick, format, }: TypographyWrapperProps) => React$1.DetailedReactHTMLElement<{
|
|
369
373
|
style: React$1.CSSProperties | undefined;
|
|
370
374
|
className: string;
|
|
371
375
|
onClick: ((e: React$1.MouseEvent<HTMLElement, MouseEvent>) => void) | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -174,6 +174,7 @@ interface StagesProps extends ElementProps {
|
|
|
174
174
|
saving?: boolean;
|
|
175
175
|
canvasMode?: 'desktop' | 'tablet' | 'mobile' | 'app';
|
|
176
176
|
primaryColor?: string
|
|
177
|
+
[key: string]: any;
|
|
177
178
|
}
|
|
178
179
|
|
|
179
180
|
type ButtonProps = ElementProps & React.ComponentProps<"button"> & {
|
|
@@ -365,7 +366,10 @@ declare const ImageControl: ({ className, style, imageUrl, altText, apiUrl, ...p
|
|
|
365
366
|
|
|
366
367
|
declare const Shape: ({ children, className, style }: ElementProps) => react_jsx_runtime.JSX.Element;
|
|
367
368
|
|
|
368
|
-
|
|
369
|
+
type TypographyWrapperProps = TypographyProps & {
|
|
370
|
+
format?: string;
|
|
371
|
+
};
|
|
372
|
+
declare const Typography: ({ className, style, tagName, textContent, onClick, format, }: TypographyWrapperProps) => React$1.DetailedReactHTMLElement<{
|
|
369
373
|
style: React$1.CSSProperties | undefined;
|
|
370
374
|
className: string;
|
|
371
375
|
onClick: ((e: React$1.MouseEvent<HTMLElement, MouseEvent>) => void) | undefined;
|
package/dist/index.js
CHANGED
|
@@ -618,14 +618,64 @@ var Shape_default = Shape;
|
|
|
618
618
|
|
|
619
619
|
// src/components/Basic/Typography/Typography.tsx
|
|
620
620
|
var import_react7 = __toESM(require("react"));
|
|
621
|
+
|
|
622
|
+
// src/lib/dayjs-setup.ts
|
|
623
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
624
|
+
var import_utc = __toESM(require("dayjs/plugin/utc"));
|
|
625
|
+
import_dayjs.default.extend(import_utc.default);
|
|
626
|
+
var dayjs_setup_default = import_dayjs.default;
|
|
627
|
+
|
|
628
|
+
// src/lib/table/valueFormatter.ts
|
|
629
|
+
var valueFormatter = (value, format3, customFormatters = {}) => {
|
|
630
|
+
if (!format3) return value;
|
|
631
|
+
if (value == null || value === "" || value === void 0) return "-";
|
|
632
|
+
if (format3.startsWith("custom:")) {
|
|
633
|
+
const key = format3.replace("custom:", "");
|
|
634
|
+
return customFormatters[key] ? customFormatters[key](value) : value;
|
|
635
|
+
}
|
|
636
|
+
const [type, arg] = format3.split(":");
|
|
637
|
+
switch (type) {
|
|
638
|
+
case "date":
|
|
639
|
+
return dayjs_setup_default(value).format(arg || "YYYY-MM-DD");
|
|
640
|
+
case "datetimenumber":
|
|
641
|
+
return dayjs_setup_default(value).format("YYYY-MM-DD hh:mm");
|
|
642
|
+
case "datetime":
|
|
643
|
+
return dayjs_setup_default(value).format("DD MMM YYYY hh:mm A");
|
|
644
|
+
case "days":
|
|
645
|
+
return `${dayjs_setup_default().diff(dayjs_setup_default(value), "day")} days`;
|
|
646
|
+
case "months":
|
|
647
|
+
return `${dayjs_setup_default().diff(dayjs_setup_default(value), "month")} months`;
|
|
648
|
+
case "years":
|
|
649
|
+
return `${dayjs_setup_default().diff(dayjs_setup_default(value), "year")} years`;
|
|
650
|
+
case "time":
|
|
651
|
+
return dayjs_setup_default(value).format("HH:mm");
|
|
652
|
+
case "number":
|
|
653
|
+
return Number(value).toFixed(parseInt(arg || "2"));
|
|
654
|
+
case "currency":
|
|
655
|
+
return new Intl.NumberFormat("en-IN", {
|
|
656
|
+
style: "currency",
|
|
657
|
+
currency: arg || "INR"
|
|
658
|
+
}).format(Number(value));
|
|
659
|
+
case "uppercase":
|
|
660
|
+
return String(value).toUpperCase();
|
|
661
|
+
case "lowercase":
|
|
662
|
+
return String(value).toLowerCase();
|
|
663
|
+
default:
|
|
664
|
+
return value;
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
// src/components/Basic/Typography/Typography.tsx
|
|
621
669
|
var Typography = ({
|
|
622
670
|
className,
|
|
623
671
|
style,
|
|
624
672
|
tagName,
|
|
625
673
|
textContent,
|
|
626
|
-
onClick
|
|
674
|
+
onClick,
|
|
675
|
+
format: format3
|
|
627
676
|
}) => {
|
|
628
677
|
const Tag = tagName || "h1";
|
|
678
|
+
const formattedContent = format3 != null && format3 !== "" ? valueFormatter(textContent, format3) : textContent;
|
|
629
679
|
return import_react7.default.createElement(
|
|
630
680
|
Tag,
|
|
631
681
|
{
|
|
@@ -637,7 +687,7 @@ var Typography = ({
|
|
|
637
687
|
import_react7.default.createElement("span", {
|
|
638
688
|
key: "html",
|
|
639
689
|
className: "pointer-events-none",
|
|
640
|
-
dangerouslySetInnerHTML: { __html:
|
|
690
|
+
dangerouslySetInnerHTML: { __html: formattedContent || "--" }
|
|
641
691
|
})
|
|
642
692
|
]
|
|
643
693
|
);
|
|
@@ -2328,6 +2378,7 @@ function LazySelectDropdown({
|
|
|
2328
2378
|
}) {
|
|
2329
2379
|
const [isOpen, setIsOpen] = (0, import_react22.useState)(false);
|
|
2330
2380
|
const [searchTerm, setSearchTerm] = (0, import_react22.useState)("");
|
|
2381
|
+
const [highlightedIndex, setHighlightedIndex] = (0, import_react22.useState)(-1);
|
|
2331
2382
|
const dropdownRef = (0, import_react22.useRef)(null);
|
|
2332
2383
|
const observerTarget = (0, import_react22.useRef)(null);
|
|
2333
2384
|
const {
|
|
@@ -2352,11 +2403,19 @@ function LazySelectDropdown({
|
|
|
2352
2403
|
enforceStrictQueryParams
|
|
2353
2404
|
});
|
|
2354
2405
|
const selectedOption = (0, import_react22.useMemo)(() => lazyOptions.find((opt) => opt.value === value), [lazyOptions, value]);
|
|
2406
|
+
(0, import_react22.useEffect)(() => {
|
|
2407
|
+
if (!isOpen) {
|
|
2408
|
+
setHighlightedIndex(-1);
|
|
2409
|
+
} else if (lazyOptions.length > 0 && highlightedIndex === -1) {
|
|
2410
|
+
setHighlightedIndex(0);
|
|
2411
|
+
}
|
|
2412
|
+
}, [isOpen, lazyOptions.length, highlightedIndex]);
|
|
2355
2413
|
(0, import_react22.useEffect)(() => {
|
|
2356
2414
|
const handleClickOutside = (e) => {
|
|
2357
2415
|
if (dropdownRef.current && !dropdownRef.current.contains(e.target)) {
|
|
2358
2416
|
setIsOpen(false);
|
|
2359
2417
|
setSearchTerm("");
|
|
2418
|
+
setHighlightedIndex(-1);
|
|
2360
2419
|
}
|
|
2361
2420
|
};
|
|
2362
2421
|
document.addEventListener("mousedown", handleClickOutside);
|
|
@@ -2376,24 +2435,30 @@ function LazySelectDropdown({
|
|
|
2376
2435
|
const handleSearchChange = (e) => {
|
|
2377
2436
|
const term = e.target.value;
|
|
2378
2437
|
setSearchTerm(term);
|
|
2438
|
+
setHighlightedIndex(-1);
|
|
2379
2439
|
search(term);
|
|
2380
2440
|
};
|
|
2381
2441
|
const handleSelect = (optValue) => {
|
|
2382
2442
|
onChange?.(optValue, id || "");
|
|
2383
2443
|
setIsOpen(false);
|
|
2384
2444
|
setSearchTerm("");
|
|
2445
|
+
setHighlightedIndex(-1);
|
|
2385
2446
|
reset();
|
|
2386
2447
|
};
|
|
2387
2448
|
const handleFocus = () => {
|
|
2388
|
-
if (!disabled)
|
|
2389
|
-
|
|
2390
|
-
|
|
2449
|
+
if (!disabled) {
|
|
2450
|
+
setIsOpen(true);
|
|
2451
|
+
if (lazyOptions.length === 0) {
|
|
2452
|
+
loadPage(1, "");
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2391
2455
|
};
|
|
2392
2456
|
const handleRemoveSelection = (e) => {
|
|
2393
2457
|
e.preventDefault();
|
|
2394
2458
|
e.stopPropagation();
|
|
2395
2459
|
onChange?.("", id || "");
|
|
2396
2460
|
setSearchTerm("");
|
|
2461
|
+
setHighlightedIndex(-1);
|
|
2397
2462
|
reset();
|
|
2398
2463
|
search("");
|
|
2399
2464
|
};
|
|
@@ -2403,9 +2468,50 @@ function LazySelectDropdown({
|
|
|
2403
2468
|
onChange?.(option.value, id || "");
|
|
2404
2469
|
setIsOpen(false);
|
|
2405
2470
|
setSearchTerm("");
|
|
2471
|
+
setHighlightedIndex(-1);
|
|
2406
2472
|
reset();
|
|
2407
2473
|
}
|
|
2408
2474
|
};
|
|
2475
|
+
const handleKeyDown = (e) => {
|
|
2476
|
+
if (disabled || readOnly) return;
|
|
2477
|
+
if (!isOpen) {
|
|
2478
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
2479
|
+
e.preventDefault();
|
|
2480
|
+
setIsOpen(true);
|
|
2481
|
+
if (lazyOptions.length > 0) {
|
|
2482
|
+
setHighlightedIndex(0);
|
|
2483
|
+
}
|
|
2484
|
+
return;
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
switch (e.key) {
|
|
2488
|
+
case "ArrowDown":
|
|
2489
|
+
e.preventDefault();
|
|
2490
|
+
setHighlightedIndex(
|
|
2491
|
+
(prev) => prev < lazyOptions.length - 1 ? prev + 1 : 0
|
|
2492
|
+
);
|
|
2493
|
+
break;
|
|
2494
|
+
case "ArrowUp":
|
|
2495
|
+
e.preventDefault();
|
|
2496
|
+
setHighlightedIndex(
|
|
2497
|
+
(prev) => prev > 0 ? prev - 1 : lazyOptions.length - 1
|
|
2498
|
+
);
|
|
2499
|
+
break;
|
|
2500
|
+
case "Enter":
|
|
2501
|
+
e.preventDefault();
|
|
2502
|
+
if (highlightedIndex >= 0 && highlightedIndex < lazyOptions.length) {
|
|
2503
|
+
handleSelect(lazyOptions[highlightedIndex].value);
|
|
2504
|
+
}
|
|
2505
|
+
break;
|
|
2506
|
+
case "Escape":
|
|
2507
|
+
e.preventDefault();
|
|
2508
|
+
setIsOpen(false);
|
|
2509
|
+
setSearchTerm("");
|
|
2510
|
+
setHighlightedIndex(-1);
|
|
2511
|
+
reset();
|
|
2512
|
+
break;
|
|
2513
|
+
}
|
|
2514
|
+
};
|
|
2409
2515
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { ref: dropdownRef, className: "relative w-full", children: [
|
|
2410
2516
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
2411
2517
|
"input",
|
|
@@ -2423,6 +2529,7 @@ function LazySelectDropdown({
|
|
|
2423
2529
|
value: isOpen ? searchTerm : selectedOption?.label || "",
|
|
2424
2530
|
onFocus: handleFocus,
|
|
2425
2531
|
onChange: handleSearchChange,
|
|
2532
|
+
onKeyDown: handleKeyDown,
|
|
2426
2533
|
readOnly: !isOpen || readOnly,
|
|
2427
2534
|
disabled,
|
|
2428
2535
|
autoComplete: "off"
|
|
@@ -2460,10 +2567,18 @@ function LazySelectDropdown({
|
|
|
2460
2567
|
lazyOptions.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
2461
2568
|
"div",
|
|
2462
2569
|
{
|
|
2463
|
-
|
|
2464
|
-
|
|
2570
|
+
tabIndex: 0,
|
|
2571
|
+
className: cn(
|
|
2572
|
+
"px-3 py-2 hover:bg-blue-50 cursor-pointer text-sm focus:outline-none",
|
|
2573
|
+
option.value === value ? "bg-blue-100" : "",
|
|
2574
|
+
index === highlightedIndex ? "bg-blue-200" : ""
|
|
2575
|
+
),
|
|
2576
|
+
onClick: () => handleSelect(option.value),
|
|
2577
|
+
onKeyDown: (e) => {
|
|
2578
|
+
if (e.key === "Enter") {
|
|
2579
|
+
handleSelect(option.value);
|
|
2580
|
+
}
|
|
2465
2581
|
},
|
|
2466
|
-
className: `px-3 py-2 hover:bg-blue-50 cursor-pointer text-sm ${option.value === value ? "bg-blue-100" : ""}`,
|
|
2467
2582
|
children: option.label
|
|
2468
2583
|
},
|
|
2469
2584
|
`${option.value}-${index}`
|
|
@@ -2484,9 +2599,7 @@ function LazySelectDropdown({
|
|
|
2484
2599
|
enableAddNewOption && searchTerm && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
2485
2600
|
"div",
|
|
2486
2601
|
{
|
|
2487
|
-
onClick: () =>
|
|
2488
|
-
handleAddNewOption(searchTerm);
|
|
2489
|
-
},
|
|
2602
|
+
onClick: () => handleAddNewOption(searchTerm),
|
|
2490
2603
|
className: "mt-2 px-3 py-2 bg-green-50 hover:bg-green-100 cursor-pointer text-green-700 rounded text-sm",
|
|
2491
2604
|
children: `Add "${searchTerm}"`
|
|
2492
2605
|
}
|
|
@@ -3237,7 +3350,7 @@ function DateTimePicker({
|
|
|
3237
3350
|
};
|
|
3238
3351
|
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
3239
3352
|
const yearOptions = [];
|
|
3240
|
-
for (let y = currentYear -
|
|
3353
|
+
for (let y = currentYear - 90; y <= currentYear; y++) {
|
|
3241
3354
|
yearOptions.push(y);
|
|
3242
3355
|
}
|
|
3243
3356
|
const displayValue = React8.useMemo(() => {
|
|
@@ -3844,54 +3957,6 @@ var import_react31 = __toESM(require("react"));
|
|
|
3844
3957
|
var LucideIcons2 = __toESM(require("lucide-react"));
|
|
3845
3958
|
var import_lucide_react11 = require("lucide-react");
|
|
3846
3959
|
var import_image = __toESM(require("next/image"));
|
|
3847
|
-
|
|
3848
|
-
// src/lib/dayjs-setup.ts
|
|
3849
|
-
var import_dayjs = __toESM(require("dayjs"));
|
|
3850
|
-
var import_utc = __toESM(require("dayjs/plugin/utc"));
|
|
3851
|
-
import_dayjs.default.extend(import_utc.default);
|
|
3852
|
-
var dayjs_setup_default = import_dayjs.default;
|
|
3853
|
-
|
|
3854
|
-
// src/lib/table/valueFormatter.ts
|
|
3855
|
-
var valueFormatter = (value, format3, customFormatters = {}) => {
|
|
3856
|
-
if (!format3) return value;
|
|
3857
|
-
if (value == null || value === "" || value === void 0) return "-";
|
|
3858
|
-
if (format3.startsWith("custom:")) {
|
|
3859
|
-
const key = format3.replace("custom:", "");
|
|
3860
|
-
return customFormatters[key] ? customFormatters[key](value) : value;
|
|
3861
|
-
}
|
|
3862
|
-
const [type, arg] = format3.split(":");
|
|
3863
|
-
switch (type) {
|
|
3864
|
-
case "date":
|
|
3865
|
-
return dayjs_setup_default(value).format(arg || "YYYY-MM-DD");
|
|
3866
|
-
case "datetimenumber":
|
|
3867
|
-
return dayjs_setup_default(value).format("YYYY-MM-DD hh:mm");
|
|
3868
|
-
case "datetime":
|
|
3869
|
-
return dayjs_setup_default(value).format("DD MMM YYYY hh:mm A");
|
|
3870
|
-
case "days":
|
|
3871
|
-
return `${dayjs_setup_default().diff(dayjs_setup_default(value), "day")} days`;
|
|
3872
|
-
case "months":
|
|
3873
|
-
return `${dayjs_setup_default().diff(dayjs_setup_default(value), "month")} months`;
|
|
3874
|
-
case "years":
|
|
3875
|
-
return `${dayjs_setup_default().diff(dayjs_setup_default(value), "year")} years`;
|
|
3876
|
-
case "time":
|
|
3877
|
-
return dayjs_setup_default(value).format("HH:mm");
|
|
3878
|
-
case "number":
|
|
3879
|
-
return Number(value).toFixed(parseInt(arg || "2"));
|
|
3880
|
-
case "currency":
|
|
3881
|
-
return new Intl.NumberFormat("en-IN", {
|
|
3882
|
-
style: "currency",
|
|
3883
|
-
currency: arg || "INR"
|
|
3884
|
-
}).format(Number(value));
|
|
3885
|
-
case "uppercase":
|
|
3886
|
-
return String(value).toUpperCase();
|
|
3887
|
-
case "lowercase":
|
|
3888
|
-
return String(value).toLowerCase();
|
|
3889
|
-
default:
|
|
3890
|
-
return value;
|
|
3891
|
-
}
|
|
3892
|
-
};
|
|
3893
|
-
|
|
3894
|
-
// src/lib/table/cellRendererFactory.tsx
|
|
3895
3960
|
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
3896
3961
|
var getContrastColor = (bg) => {
|
|
3897
3962
|
let c = bg.trim().toUpperCase();
|
|
@@ -4710,7 +4775,7 @@ function DataTable({
|
|
|
4710
4775
|
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
4711
4776
|
TableCell,
|
|
4712
4777
|
{
|
|
4713
|
-
className: `break-words whitespace-normal align-top ${
|
|
4778
|
+
className: `break-words whitespace-normal align-top ${isClickable ? "cursor-pointer hover:bg-gray-100 underline text-blue-500" : ""} relative py-2 ${meta2?.cellClass ?? ""}`,
|
|
4714
4779
|
style: {
|
|
4715
4780
|
width: cell.column.getSize(),
|
|
4716
4781
|
minWidth: cell.column.columnDef.minSize,
|
|
@@ -5780,11 +5845,13 @@ var StagesComponent = ({
|
|
|
5780
5845
|
return;
|
|
5781
5846
|
}
|
|
5782
5847
|
};
|
|
5783
|
-
const lastStage = stages && stages.length > 0 ? stages[stages.length - 1][dataKey] : null;
|
|
5784
5848
|
const isMobile = canvasMode === "mobile";
|
|
5785
5849
|
const onStageClick = (stageKey) => {
|
|
5786
5850
|
if (!stageKey || stageKey === activeStage) return;
|
|
5787
5851
|
setActiveStage(stageKey);
|
|
5852
|
+
const { activeRoot, activeChild } = findStageContext(stages, stageKey);
|
|
5853
|
+
setActiveRootStage(activeRoot);
|
|
5854
|
+
setActiveChildStage(activeChild);
|
|
5788
5855
|
if (triggerOnClick) {
|
|
5789
5856
|
onStageChange?.(stageKey);
|
|
5790
5857
|
}
|
|
@@ -5821,7 +5888,7 @@ var StagesComponent = ({
|
|
|
5821
5888
|
setActiveRootStage(activeRoot);
|
|
5822
5889
|
setActiveChildStage(activeChild);
|
|
5823
5890
|
}, [currentStage, stages]);
|
|
5824
|
-
const isAllStagesCompleted = isCompleted
|
|
5891
|
+
const isAllStagesCompleted = isCompleted;
|
|
5825
5892
|
const disabled = isAllStagesCompleted || loading || saving;
|
|
5826
5893
|
const primaryColor = props.primaryColor || "#12715b";
|
|
5827
5894
|
return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className, style, children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
|
|
@@ -5857,51 +5924,71 @@ var StagesComponent = ({
|
|
|
5857
5924
|
disabled: true
|
|
5858
5925
|
},
|
|
5859
5926
|
index
|
|
5860
|
-
)) : (stages || [])?.length > 0 &&
|
|
5861
|
-
const
|
|
5862
|
-
const
|
|
5863
|
-
const
|
|
5864
|
-
const
|
|
5865
|
-
const
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5927
|
+
)) : (stages || [])?.length > 0 && (() => {
|
|
5928
|
+
const safeStages = stages ?? [];
|
|
5929
|
+
const activeRootKey = activeRootStage?.[dataKey];
|
|
5930
|
+
const isActiveStageTopLevel = safeStages.some((s) => s?.[dataKey] === activeStage);
|
|
5931
|
+
const activeIndexKey = isActiveStageTopLevel ? activeStage : activeRootKey ?? activeStage;
|
|
5932
|
+
const currentIndex = safeStages.findIndex((s) => s?.[dataKey] === activeIndexKey);
|
|
5933
|
+
const isOutcomeWon = activeChildStage?.is_won === true;
|
|
5934
|
+
const isOutcomeLost = activeChildStage?.is_won === false;
|
|
5935
|
+
const hasOutcome = isOutcomeWon || isOutcomeLost;
|
|
5936
|
+
const activeOutcomeClass = isOutcomeWon ? "bg-green-600 text-white shadow-md" : isOutcomeLost ? "bg-red-600 text-white shadow-md" : "";
|
|
5937
|
+
return safeStages.map((stage, index) => {
|
|
5938
|
+
const isCompletedStage = isAllStagesCompleted || index <= currentIndex;
|
|
5939
|
+
const showAsActive = isAllStagesCompleted ? index === safeStages.length - 1 : index === currentIndex;
|
|
5940
|
+
const isCurrentRootStage = activeRootStage?.[dataKey] === stage[dataKey];
|
|
5941
|
+
const stageHasChildren = Array.isArray(stage?.children) && stage.children.length > 0;
|
|
5942
|
+
const isCurrentChildStage = activeChildStage?.[dataKey] === activeStage;
|
|
5943
|
+
const showOutcomeForCurrentStage = showAsActive && hasOutcome && stageHasChildren && isCurrentRootStage && isCurrentChildStage;
|
|
5944
|
+
let stageColor = `text-[${primaryColor}] border-2 border-[${primaryColor}]`;
|
|
5945
|
+
let stageStyle = {
|
|
5946
|
+
borderColor: primaryColor,
|
|
5947
|
+
color: showAsActive ? "white" : primaryColor,
|
|
5948
|
+
backgroundColor: showAsActive ? primaryColor : "transparent"
|
|
5949
|
+
};
|
|
5950
|
+
if (stage.hasOwnProperty("isSuccess") && stage.isSuccess === false) {
|
|
5877
5951
|
stageColor = "bg-red-50 text-red-700 border-2 border-red-700";
|
|
5878
5952
|
stageStyle = { borderColor: "red", color: "red", backgroundColor: "transparent" };
|
|
5879
5953
|
}
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5954
|
+
if (showOutcomeForCurrentStage) {
|
|
5955
|
+
stageColor = isOutcomeWon ? "bg-green-600 text-white border-2 border-green-600" : "bg-red-600 text-white border-2 border-red-600";
|
|
5956
|
+
stageStyle = isOutcomeWon ? { borderColor: "#16a34a", color: "white", backgroundColor: "#16a34a" } : { borderColor: "#dc2626", color: "white", backgroundColor: "#dc2626" };
|
|
5957
|
+
}
|
|
5958
|
+
let stageLabel = stage[dataLabel];
|
|
5959
|
+
if (stage[dataKey] !== activeChildStage?.[dataKey] && activeRootStage?.[dataKey] === stage[dataKey]) {
|
|
5960
|
+
stageLabel = activeChildStage?.[dataLabel] || stageLabel;
|
|
5961
|
+
stageColor = `text-[${primaryColor}] border-2 border-[${primaryColor}]`;
|
|
5962
|
+
if (showOutcomeForCurrentStage) {
|
|
5963
|
+
stageColor = isOutcomeWon ? "bg-green-600 text-white border-2 border-green-600" : "bg-red-600 text-white border-2 border-red-600";
|
|
5964
|
+
stageStyle = isOutcomeWon ? { borderColor: "#16a34a", color: "white", backgroundColor: "#16a34a" } : { borderColor: "#dc2626", color: "white", backgroundColor: "#dc2626" };
|
|
5965
|
+
}
|
|
5966
|
+
}
|
|
5967
|
+
const stageKey = typeof stage[dataKey] === "string" ? stage[dataKey] : JSON.stringify(stage[dataKey]);
|
|
5968
|
+
return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_react34.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Tooltip, { delayDuration: 500, disableHoverableContent: true, children: [
|
|
5969
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
5970
|
+
"button",
|
|
5971
|
+
{
|
|
5972
|
+
className: `
|
|
5887
5973
|
min-w-[70px] sm:min-w-[80px] w-full sm:w-auto px-3 sm:px-4 py-1.5 sm:py-2
|
|
5888
5974
|
rounded-full text-xs sm:text-sm font-medium transition-colors duration-200
|
|
5889
5975
|
whitespace-normal sm:whitespace-nowrap flex-shrink-0 max-w-[150px] text-ellipsis overflow-hidden
|
|
5890
|
-
${showAsActive ? `bg-[${primaryColor}] text-white shadow-md` : isCompletedStage ? stageColor : "bg-white border border-gray-200"}
|
|
5976
|
+
${showAsActive ? showOutcomeForCurrentStage ? activeOutcomeClass : `bg-[${primaryColor}] text-white shadow-md` : isCompletedStage ? stageColor : "bg-white border border-gray-200"}
|
|
5891
5977
|
${isMobile ? "flex-1 text-center py-2.5" : ""}
|
|
5892
5978
|
`,
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5979
|
+
onClick: () => {
|
|
5980
|
+
if (isAllStagesCompleted) return;
|
|
5981
|
+
onStageClick(stage[dataKey]);
|
|
5982
|
+
},
|
|
5983
|
+
style: stageStyle,
|
|
5984
|
+
children: stageLabel
|
|
5985
|
+
}
|
|
5986
|
+
) }),
|
|
5987
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(TooltipContent, { side: "top", sideOffset: 6, hideArrow: true, children: stageLabel }),
|
|
5988
|
+
!isMobile && index < safeStages.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "hidden sm:flex sm:flex-shrink-0 w-3 h-px bg-gray-300 sm:w-4" })
|
|
5989
|
+
] }, stageKey) }, stageKey);
|
|
5990
|
+
});
|
|
5991
|
+
})()
|
|
5905
5992
|
}
|
|
5906
5993
|
),
|
|
5907
5994
|
isShowBtn && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|