@nexus-cross/design-system 1.0.13 → 1.0.14

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.
@@ -19,10 +19,38 @@ var stepperVariants = cva("nexus-stepper", {
19
19
  size: "md"
20
20
  }
21
21
  });
22
- var CheckIcon = ({ className }) => /* @__PURE__ */ jsx("svg", { className, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: /* @__PURE__ */ jsx("path", { d: "M3.5 8.5l3 3 6-6", strokeLinecap: "round", strokeLinejoin: "round" }) });
22
+ var CheckIcon = ({ className }) => /* @__PURE__ */ jsx(
23
+ "svg",
24
+ {
25
+ className,
26
+ viewBox: "0 0 14 14",
27
+ fill: "none",
28
+ stroke: "currentColor",
29
+ strokeWidth: "2",
30
+ children: /* @__PURE__ */ jsx("path", { d: "M2.5 7.5l3 3 6-6", strokeLinecap: "round", strokeLinejoin: "round" })
31
+ }
32
+ );
23
33
  var Stepper = React.forwardRef(
24
- ({ className, orientation, size, steps, current = 0, status = "process", ...props }, ref) => {
34
+ ({
35
+ className,
36
+ orientation,
37
+ size,
38
+ steps,
39
+ current = 0,
40
+ status = "process",
41
+ ...props
42
+ }, ref) => {
25
43
  const isHorizontal = orientation !== "vertical";
44
+ const prevCurrentRef = React.useRef(current);
45
+ const [animatingIdx, setAnimatingIdx] = React.useState(null);
46
+ React.useEffect(() => {
47
+ if (prevCurrentRef.current !== current) {
48
+ setAnimatingIdx(current);
49
+ prevCurrentRef.current = current;
50
+ const timer = setTimeout(() => setAnimatingIdx(null), 600);
51
+ return () => clearTimeout(timer);
52
+ }
53
+ }, [current]);
26
54
  return /* @__PURE__ */ jsx(
27
55
  "div",
28
56
  {
@@ -34,12 +62,15 @@ var Stepper = React.forwardRef(
34
62
  const state = i < current ? "completed" : i === current ? status === "error" ? "error" : "active" : "pending";
35
63
  const isFirst = i === 0;
36
64
  const isLast = i === steps.length - 1;
37
- const prevCompleted = i <= current;
38
- const nextCompleted = i < current;
65
+ const isAnimating = animatingIdx === i;
39
66
  return /* @__PURE__ */ jsxs(
40
67
  "div",
41
68
  {
42
- className: cn("nexus-stepper__step", `nexus-stepper__step--${state}`),
69
+ className: cn(
70
+ "nexus-stepper__step",
71
+ `nexus-stepper__step--${state}`,
72
+ isAnimating && "nexus-stepper__step--animating"
73
+ ),
43
74
  children: [
44
75
  /* @__PURE__ */ jsx("div", { className: "nexus-stepper__indicator-wrap", children: isHorizontal ? /* @__PURE__ */ jsxs(Fragment, { children: [
45
76
  /* @__PURE__ */ jsx(
@@ -47,8 +78,7 @@ var Stepper = React.forwardRef(
47
78
  {
48
79
  className: cn(
49
80
  "nexus-stepper__connector",
50
- isFirst && "nexus-stepper__connector--hidden",
51
- prevCompleted && "nexus-stepper__connector--completed"
81
+ isFirst && "nexus-stepper__connector--hidden"
52
82
  )
53
83
  }
54
84
  ),
@@ -58,14 +88,14 @@ var Stepper = React.forwardRef(
58
88
  {
59
89
  className: cn(
60
90
  "nexus-stepper__connector",
61
- isLast && "nexus-stepper__connector--hidden",
62
- nextCompleted && "nexus-stepper__connector--completed"
91
+ isLast && "nexus-stepper__connector--hidden"
63
92
  )
64
93
  }
65
94
  )
66
95
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
67
- !isFirst && /* @__PURE__ */ jsx("div", { className: cn("nexus-stepper__connector", prevCompleted && "nexus-stepper__connector--completed") }),
68
- /* @__PURE__ */ jsx("div", { className: "nexus-stepper__indicator", children: state === "completed" ? /* @__PURE__ */ jsx(CheckIcon, { className: "nexus-stepper__check" }) : /* @__PURE__ */ jsx("span", { children: i + 1 }) })
96
+ !isFirst && /* @__PURE__ */ jsx("div", { className: "nexus-stepper__connector" }),
97
+ /* @__PURE__ */ jsx("div", { className: "nexus-stepper__indicator", children: state === "completed" ? /* @__PURE__ */ jsx(CheckIcon, { className: "nexus-stepper__check" }) : /* @__PURE__ */ jsx("span", { children: i + 1 }) }),
98
+ !isLast && /* @__PURE__ */ jsx("div", { className: "nexus-stepper__connector" })
69
99
  ] }) }),
70
100
  /* @__PURE__ */ jsxs("div", { className: "nexus-stepper__content", children: [
71
101
  /* @__PURE__ */ jsx("span", { className: "nexus-stepper__label", children: step.label }),