@situaction/traq-ui-ste 1.2.25 → 1.2.26
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.
|
@@ -24,6 +24,10 @@ export interface StepperProps {
|
|
|
24
24
|
autoStatusFromActive?: boolean;
|
|
25
25
|
/** Optional: force some steps disabled without setting status on each item */
|
|
26
26
|
disabledIds?: string[];
|
|
27
|
+
/** If false, render only the dots/connectors (no item.content). */
|
|
28
|
+
showContent?: boolean;
|
|
29
|
+
/** Optional accessible label for each dot. */
|
|
30
|
+
getDotAriaLabel?: (item: StepITem, index: number, status: StepStatus) => string;
|
|
27
31
|
}
|
|
28
32
|
/** Stepper layout: dots + absolute connectors between each dot */
|
|
29
33
|
export declare const Stepper: FC<StepperProps>;
|
|
@@ -1,82 +1,86 @@
|
|
|
1
|
-
import { jsx as _, jsxs as
|
|
2
|
-
import { useMemo as h, useRef as
|
|
3
|
-
import '../../styles/Stepper.css';const
|
|
4
|
-
wrapper:
|
|
5
|
-
steps:
|
|
6
|
-
row:
|
|
7
|
-
connectorAbs:
|
|
8
|
-
connectorProgress:
|
|
9
|
-
connectorGradient:
|
|
10
|
-
connectorDefault:
|
|
11
|
-
dotButton:
|
|
12
|
-
dotButtonDisabled:
|
|
13
|
-
dotOuter:
|
|
14
|
-
dotInner:
|
|
15
|
-
"dotButton--upcoming": "_dotButton--
|
|
16
|
-
"dotButton--active": "_dotButton--
|
|
17
|
-
"dotButton--completed": "_dotButton--
|
|
18
|
-
"dotButton--disabled": "_dotButton--
|
|
19
|
-
|
|
1
|
+
import { jsx as _, jsxs as E } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as h, useRef as G, useState as W, useLayoutEffect as X } from "react";
|
|
3
|
+
import '../../styles/Stepper.css';const Z = "_wrapper_1fl3r_30", L = "_steps_1fl3r_35", tt = "_row_1fl3r_42", et = "_connectorAbs_1fl3r_50", nt = "_connectorProgress_1fl3r_60", ot = "_connectorGradient_1fl3r_64", rt = "_connectorDefault_1fl3r_69", st = "_dotButton_1fl3r_75", ct = "_dotButtonDisabled_1fl3r_90", dt = "_dotOuter_1fl3r_96", it = "_dotInner_1fl3r_103", at = "_rowNoContent_1fl3r_165", lt = "_content_1fl3r_170", o = {
|
|
4
|
+
wrapper: Z,
|
|
5
|
+
steps: L,
|
|
6
|
+
row: tt,
|
|
7
|
+
connectorAbs: et,
|
|
8
|
+
connectorProgress: nt,
|
|
9
|
+
connectorGradient: ot,
|
|
10
|
+
connectorDefault: rt,
|
|
11
|
+
dotButton: st,
|
|
12
|
+
dotButtonDisabled: ct,
|
|
13
|
+
dotOuter: dt,
|
|
14
|
+
dotInner: it,
|
|
15
|
+
"dotButton--upcoming": "_dotButton--upcoming_1fl3r_108",
|
|
16
|
+
"dotButton--active": "_dotButton--active_1fl3r_120",
|
|
17
|
+
"dotButton--completed": "_dotButton--completed_1fl3r_142",
|
|
18
|
+
"dotButton--disabled": "_dotButton--disabled_1fl3r_153",
|
|
19
|
+
rowNoContent: at,
|
|
20
|
+
content: lt
|
|
21
|
+
}, ut = (n, d) => {
|
|
20
22
|
if (n === d) return !0;
|
|
21
23
|
if (n.length !== d.length) return !1;
|
|
22
24
|
for (let u = 0; u < n.length; u++) {
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
+
const f = n[u], i = d[u];
|
|
26
|
+
if (f.key !== i.key || f.leftPx !== i.leftPx || f.topPx !== i.topPx || f.heightPx !== i.heightPx || f.variant !== i.variant)
|
|
25
27
|
return !1;
|
|
26
28
|
}
|
|
27
29
|
return !0;
|
|
28
|
-
},
|
|
30
|
+
}, _t = ({
|
|
29
31
|
items: n,
|
|
30
32
|
onDotClick: d,
|
|
31
33
|
dotOffsetPx: u = 18,
|
|
32
|
-
dotsClickable:
|
|
34
|
+
dotsClickable: f = !0,
|
|
33
35
|
activeId: i,
|
|
34
|
-
autoStatusFromActive:
|
|
35
|
-
disabledIds:
|
|
36
|
+
autoStatusFromActive: P = !0,
|
|
37
|
+
disabledIds: m = [],
|
|
38
|
+
showContent: y = !0,
|
|
39
|
+
getDotAriaLabel: w
|
|
36
40
|
}) => {
|
|
37
|
-
const
|
|
41
|
+
const I = h(
|
|
38
42
|
() => ({ "--flowline-dot-offset": `${u}px` }),
|
|
39
43
|
[u]
|
|
40
|
-
),
|
|
41
|
-
var
|
|
42
|
-
const t = new Set(
|
|
43
|
-
return n.map((e,
|
|
44
|
-
}, [n, i,
|
|
45
|
-
x.current.set(t,
|
|
46
|
-
}, []), [
|
|
47
|
-
return
|
|
48
|
-
const t =
|
|
44
|
+
), C = h(() => m.join("|"), [m]), B = h(() => {
|
|
45
|
+
var l, s;
|
|
46
|
+
const t = new Set(m), r = i ?? ((l = n.find((e) => e.status !== "disabled" && !t.has(e.id))) == null ? void 0 : l.id) ?? ((s = n[0]) == null ? void 0 : s.id), a = n.findIndex((e) => e.id === r);
|
|
47
|
+
return n.map((e, p) => e.status === "disabled" || t.has(e.id) ? "disabled" : P ? p < a ? "completed" : p === a ? "active" : "upcoming" : e.status ?? "upcoming");
|
|
48
|
+
}, [n, i, P, C]), Y = h(() => B.join("|"), [B]), z = h(() => n.map((t) => t.id).join("|"), [n]), N = G(null), x = G(/* @__PURE__ */ new Map()), K = h(() => (t) => (r) => {
|
|
49
|
+
x.current.set(t, r);
|
|
50
|
+
}, []), [q, D] = W([]);
|
|
51
|
+
return X(() => {
|
|
52
|
+
const t = N.current;
|
|
49
53
|
if (!t) return;
|
|
50
|
-
let
|
|
51
|
-
const
|
|
52
|
-
const e = t.getBoundingClientRect(),
|
|
53
|
-
for (let c = 0; c <
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
56
|
-
const g =
|
|
57
|
-
|
|
58
|
-
key: `${
|
|
59
|
-
leftPx:
|
|
60
|
-
topPx:
|
|
61
|
-
heightPx:
|
|
62
|
-
variant:
|
|
54
|
+
let r = null;
|
|
55
|
+
const a = () => {
|
|
56
|
+
const e = t.getBoundingClientRect(), p = [], v = n.map((c) => c.id);
|
|
57
|
+
for (let c = 0; c < v.length - 1; c++) {
|
|
58
|
+
const R = v[c], j = v[c + 1], O = x.current.get(R), $ = x.current.get(j);
|
|
59
|
+
if (!O || !$) continue;
|
|
60
|
+
const g = O.getBoundingClientRect(), b = $.getBoundingClientRect(), k = Math.round(g.left + g.width / 2 - e.left), F = g.top + g.height / 2 - e.top, H = b.top + b.height / 2 - e.top, J = g.height / 2, Q = b.height / 2, A = 2, M = Math.round(F + J + A), T = Math.round(H - Q - A), U = Math.max(0, T - M), S = B[c], V = S === "completed" ? "progress" : S === "active" ? "gradient" : "default";
|
|
61
|
+
p.push({
|
|
62
|
+
key: `${R}__${j}`,
|
|
63
|
+
leftPx: k,
|
|
64
|
+
topPx: M,
|
|
65
|
+
heightPx: U,
|
|
66
|
+
variant: V
|
|
63
67
|
});
|
|
64
68
|
}
|
|
65
|
-
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
D((c) => ut(c, p) ? c : p);
|
|
70
|
+
}, l = () => {
|
|
71
|
+
r == null && (r = requestAnimationFrame(() => {
|
|
72
|
+
r = null, a();
|
|
69
73
|
}));
|
|
70
74
|
};
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
return
|
|
74
|
-
e &&
|
|
75
|
-
}), window.addEventListener("resize",
|
|
76
|
-
|
|
75
|
+
l();
|
|
76
|
+
const s = new ResizeObserver(l);
|
|
77
|
+
return s.observe(t), x.current.forEach((e) => {
|
|
78
|
+
e && s.observe(e);
|
|
79
|
+
}), window.addEventListener("resize", l), () => {
|
|
80
|
+
r != null && cancelAnimationFrame(r), s.disconnect(), window.removeEventListener("resize", l);
|
|
77
81
|
};
|
|
78
|
-
}, [
|
|
79
|
-
|
|
82
|
+
}, [z, Y]), /* @__PURE__ */ _("div", { className: o.wrapper, style: I, children: /* @__PURE__ */ E("div", { ref: N, className: o.steps, children: [
|
|
83
|
+
q.map((t) => /* @__PURE__ */ _(
|
|
80
84
|
"span",
|
|
81
85
|
{
|
|
82
86
|
className: [
|
|
@@ -92,31 +96,41 @@ import '../../styles/Stepper.css';const V = "_wrapper_187j3_30", W = "_steps_187
|
|
|
92
96
|
},
|
|
93
97
|
t.key
|
|
94
98
|
)),
|
|
95
|
-
n.map((t,
|
|
96
|
-
const
|
|
97
|
-
return /* @__PURE__ */
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
99
|
+
n.map((t, r) => {
|
|
100
|
+
const a = B[r], s = f && !(a === "disabled") && !!d;
|
|
101
|
+
return /* @__PURE__ */ E(
|
|
102
|
+
"div",
|
|
103
|
+
{
|
|
104
|
+
className: [
|
|
105
|
+
o.row,
|
|
106
|
+
y ? "" : o.rowNoContent
|
|
107
|
+
].filter(Boolean).join(" "),
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ _(
|
|
110
|
+
"button",
|
|
111
|
+
{
|
|
112
|
+
type: "button",
|
|
113
|
+
className: [
|
|
114
|
+
o.dotButton,
|
|
115
|
+
o[`dotButton--${a}`],
|
|
116
|
+
s ? "" : o.dotButtonDisabled
|
|
117
|
+
].filter(Boolean).join(" "),
|
|
118
|
+
onClick: () => {
|
|
119
|
+
s && (d == null || d(t.id));
|
|
120
|
+
},
|
|
121
|
+
"aria-label": (w == null ? void 0 : w(t, r, a)) ?? `Open step ${t.id}`,
|
|
122
|
+
disabled: !s,
|
|
123
|
+
children: /* @__PURE__ */ _("span", { ref: K(t.id), className: o.dotOuter, children: /* @__PURE__ */ _("span", { className: o.dotInner }) })
|
|
124
|
+
}
|
|
125
|
+
),
|
|
126
|
+
y ? /* @__PURE__ */ _("div", { className: o.content, children: t.content }) : null
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
t.id
|
|
130
|
+
);
|
|
117
131
|
})
|
|
118
132
|
] }) });
|
|
119
133
|
};
|
|
120
134
|
export {
|
|
121
|
-
|
|
135
|
+
_t as Stepper
|
|
122
136
|
};
|
package/dist/styles/Stepper.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._wrapper_1fl3r_30{--stepper-left-col: 20px;--stepper-dot-button: 24px}._steps_1fl3r_35{position:relative;display:flex;flex-direction:column;gap:var(--spacing-xs-3)}._row_1fl3r_42{display:grid;grid-template-columns:var(--stepper-left-col) 1fr;column-gap:var(--spacing-xs-3);align-items:start}._connectorAbs_1fl3r_50{position:absolute;width:1px;transform:translate(-50%);border-radius:999px;pointer-events:none;z-index:0}._connectorProgress_1fl3r_60{background:var(--flow-point-line-active)}._connectorGradient_1fl3r_64{background:linear-gradient(to bottom,var(--flow-point-line-active),var(--flow-point-line-inactive))}._connectorDefault_1fl3r_69{background-image:linear-gradient(to bottom,var(--flow-point-line-inactive) 50%,transparent 0);background-size:2px 8px;background-repeat:repeat-y}._dotButton_1fl3r_75{margin-top:.625rem;width:var(--stepper-dot-button);height:var(--stepper-dot-button);padding:0;border:0;background:transparent;display:flex;align-items:center;justify-content:center;cursor:pointer;position:relative;z-index:1}._dotButtonDisabled_1fl3r_90{cursor:default;opacity:.5}._dotOuter_1fl3r_96{display:flex;align-items:center;justify-content:center;border-radius:999px}._dotInner_1fl3r_103{border-radius:999px}._dotButton--upcoming_1fl3r_108 ._dotOuter_1fl3r_96{width:10px;height:10px;border:none;background:var(--flow-point-line-inactive)}._dotButton--upcoming_1fl3r_108 ._dotInner_1fl3r_103{display:none}._dotButton--active_1fl3r_120 ._dotOuter_1fl3r_96{width:16px;height:16px;border-radius:999px;border:1px solid var(--flow-point-line-active);background:transparent;padding:1px;box-sizing:border-box;display:flex;align-items:center;justify-content:center}._dotButton--active_1fl3r_120 ._dotInner_1fl3r_103{width:10px;height:10px;border-radius:999px;background:var(--flow-point-line-active);display:block}._dotButton--completed_1fl3r_142 ._dotOuter_1fl3r_96{width:10px;height:10px;background:var(--flow-point-line-active)}._dotButton--completed_1fl3r_142 ._dotInner_1fl3r_103{display:none}._dotButton--disabled_1fl3r_153 ._dotOuter_1fl3r_96{width:10px;height:10px;border:none;background:var(--general-border-window);opacity:.6}._dotButton--disabled_1fl3r_153 ._dotInner_1fl3r_103{display:none}._rowNoContent_1fl3r_165{grid-template-columns:var(--stepper-left-col);column-gap:0}._rowNoContent_1fl3r_165 ._content_1fl3r_170{display:none}
|