@situaction/traq-ui-ste 1.1.11 → 1.1.13
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.
|
@@ -4,5 +4,8 @@ export interface ButtonControlledScrollProps {
|
|
|
4
4
|
items: React.ReactNode[];
|
|
5
5
|
iconLeft: ReactNode;
|
|
6
6
|
iconRight: ReactNode;
|
|
7
|
+
grabSpeed?: number;
|
|
8
|
+
scrollAmount?: number;
|
|
9
|
+
grabbable?: boolean;
|
|
7
10
|
}
|
|
8
11
|
export declare const ButtonControlledScroll: FC<ButtonControlledScrollProps>;
|
|
@@ -1,31 +1,54 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import '../../styles/ButtonControlledScroll.css';const
|
|
4
|
-
wrapper:
|
|
5
|
-
container:
|
|
6
|
-
btn:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { jsxs as D, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as l, useState as h, useEffect as k } from "react";
|
|
3
|
+
import '../../styles/ButtonControlledScroll.css';const E = "_wrapper_30f39_6", U = "_container_30f39_17", X = "_btn_30f39_27", j = "_grab_30f39_44", y = "_grabbing_30f39_48", B = "_btnLeft_30f39_54", O = "_btnRight_30f39_59", n = {
|
|
4
|
+
wrapper: E,
|
|
5
|
+
container: U,
|
|
6
|
+
btn: X,
|
|
7
|
+
grab: j,
|
|
8
|
+
grabbing: y,
|
|
9
|
+
btnLeft: B,
|
|
10
|
+
btnRight: O
|
|
11
|
+
}, T = ({ items: p, iconLeft: L, iconRight: b, scrollAmount: m = 150, grabSpeed: v = 1.5, grabbable: s = !0 }) => {
|
|
12
|
+
const i = m, r = l(null), [M, S] = h(!1), [R, w] = h(!1), o = l(!1), f = l(0), u = l(0), x = (t) => {
|
|
13
|
+
if (s) {
|
|
14
|
+
const e = r.current;
|
|
15
|
+
if (!e) return;
|
|
16
|
+
o.current = !0, f.current = t.pageX - e.offsetLeft, u.current = e.scrollLeft, e.classList.add(n.grabbing);
|
|
17
|
+
}
|
|
18
|
+
}, $ = (t) => {
|
|
19
|
+
if (s) {
|
|
20
|
+
const e = r.current;
|
|
21
|
+
if (!e || !o.current) return;
|
|
22
|
+
t.preventDefault();
|
|
23
|
+
const N = (t.pageX - e.offsetLeft - f.current) * v;
|
|
24
|
+
e.scrollLeft = u.current + N;
|
|
25
|
+
}
|
|
26
|
+
}, d = () => {
|
|
27
|
+
if (s) {
|
|
28
|
+
const t = r.current;
|
|
29
|
+
o.current = !1, t == null || t.classList.remove(n.grabbing);
|
|
30
|
+
}
|
|
31
|
+
}, C = () => {
|
|
32
|
+
o.current && s && d();
|
|
33
|
+
}, a = () => {
|
|
34
|
+
const t = r.current;
|
|
35
|
+
t && (S(t.scrollLeft > 0), w(t.scrollLeft + t.clientWidth < t.scrollWidth));
|
|
36
|
+
}, g = (t) => {
|
|
37
|
+
const e = r.current;
|
|
38
|
+
if (!e) return;
|
|
39
|
+
const _ = t === "left" ? -i : i;
|
|
40
|
+
e.scrollBy({ left: _, behavior: "smooth" });
|
|
18
41
|
};
|
|
19
|
-
return
|
|
20
|
-
const t =
|
|
42
|
+
return k(() => {
|
|
43
|
+
const t = r.current;
|
|
21
44
|
if (t)
|
|
22
|
-
return
|
|
23
|
-
}, []), /* @__PURE__ */
|
|
24
|
-
|
|
25
|
-
/* @__PURE__ */
|
|
26
|
-
|
|
45
|
+
return a(), t.addEventListener("scroll", a), () => t.removeEventListener("scroll", a);
|
|
46
|
+
}, []), /* @__PURE__ */ D("div", { className: `${n.wrapper}`, children: [
|
|
47
|
+
M && /* @__PURE__ */ c("button", { className: `${n.btn} ${n.btnLeft} padding-xs-5`, onClick: () => g("left"), children: L }),
|
|
48
|
+
/* @__PURE__ */ c("div", { onMouseDown: x, onMouseLeave: C, onMouseMove: $, onMouseUp: d, className: `${n.container} ${s && n.grab}`, ref: r, children: p.map((t, e) => /* @__PURE__ */ c("div", { className: n.item, children: t }, e)) }),
|
|
49
|
+
R && /* @__PURE__ */ c("button", { className: `${n.btn} ${n.btnRight} padding-xs-5`, onClick: () => g("right"), children: b })
|
|
27
50
|
] });
|
|
28
51
|
};
|
|
29
52
|
export {
|
|
30
|
-
|
|
53
|
+
T as ButtonControlledScroll
|
|
31
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._wrapper_30f39_6{position:relative;display:flex;align-items:center;width:100%;padding:10px;-webkit-user-select:none;user-select:none}._wrapper_30f39_6 label{-webkit-user-select:none;user-select:none}._wrapper_30f39_6 ._container_30f39_17{display:flex;overflow-x:auto;gap:10px;width:100%;scroll-behavior:smooth}._wrapper_30f39_6 ._container_30f39_17::-webkit-scrollbar{display:none}._wrapper_30f39_6 ._btn_30f39_27{transition:.3s;display:flex;justify-content:center;align-items:center;width:30px;height:30px;padding:.375rem;border-radius:50%;border:1px solid var(--button-tertiary-default-border);background-color:var(--background-primary);position:absolute;cursor:pointer}._wrapper_30f39_6 ._btn_30f39_27 *{z-index:2}._wrapper_30f39_6 ._grab_30f39_44{cursor:grab;scroll-behavior:initial}._wrapper_30f39_6 ._grabbing_30f39_48{cursor:grabbing}._wrapper_30f39_6 ._btn_30f39_27:hover{background-color:var(--background-tooltip)}._wrapper_30f39_6 ._btnLeft_30f39_54{left:0;top:50%;transform:translateY(-50%)}._wrapper_30f39_6 ._btnRight_30f39_59{right:0;top:50%;transform:translateY(-50%)}
|