@caseparts-org/caseblocks 0.0.99 → 0.0.100
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PropsWithChildren, ReactNode } from 'react';
|
|
2
2
|
export interface HorizontalScrollProps extends PropsWithChildren {
|
|
3
3
|
className?: string;
|
|
4
|
+
childrenSpacing?: number | string;
|
|
4
5
|
showScrollbar?: boolean;
|
|
5
6
|
caption?: ReactNode;
|
|
6
7
|
scrollStep?: number;
|
|
@@ -10,4 +11,4 @@ export interface HorizontalScrollProps extends PropsWithChildren {
|
|
|
10
11
|
showIndicators?: boolean;
|
|
11
12
|
hideHeader?: boolean;
|
|
12
13
|
}
|
|
13
|
-
export declare function HorizontalScroll({ className, showScrollbar, children, caption, scrollStep, leftButtonContent, rightButtonContent, headerClassName, showIndicators, hideHeader, }: HorizontalScrollProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function HorizontalScroll({ className, childrenSpacing, showScrollbar, children, caption, scrollStep, leftButtonContent, rightButtonContent, headerClassName, showIndicators, hideHeader, }: HorizontalScrollProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,58 +1,59 @@
|
|
|
1
|
-
import { jsxs as i, jsx as l, Fragment as
|
|
2
|
-
import { useRef as
|
|
1
|
+
import { jsxs as i, jsx as l, Fragment as Y } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as g, useState as h, useEffect as b } from "react";
|
|
3
3
|
import { Icon as N } from "../Icon/Icon.js";
|
|
4
|
-
import { Text as
|
|
4
|
+
import { Text as j } from "../Text/Text.js";
|
|
5
5
|
import { c as a } from "../../clsx-OuTLNxxd.js";
|
|
6
|
-
import '../../assets/HorizontalScroll.css';const
|
|
7
|
-
root:
|
|
8
|
-
header:
|
|
9
|
-
controls:
|
|
10
|
-
controlBtn:
|
|
11
|
-
container:
|
|
12
|
-
dragging:
|
|
13
|
-
noOverflow:
|
|
6
|
+
import '../../assets/HorizontalScroll.css';const F = "_root_1bnow_1", K = "_header_1bnow_5", q = "_controls_1bnow_13", G = "_controlBtn_1bnow_18", I = "_container_1bnow_37", U = "_dragging_1bnow_50", $ = "_noOverflow_1bnow_53", J = "_viewport_1bnow_66", Q = "_indicator_1bnow_69", Z = "_left_1bnow_79", tt = "_right_1bnow_85", et = "_hidden_1bnow_91", e = {
|
|
7
|
+
root: F,
|
|
8
|
+
header: K,
|
|
9
|
+
controls: q,
|
|
10
|
+
controlBtn: G,
|
|
11
|
+
container: I,
|
|
12
|
+
dragging: U,
|
|
13
|
+
noOverflow: $,
|
|
14
14
|
"scrollVisibility--false": "_scrollVisibility--false_1bnow_58",
|
|
15
|
-
viewport:
|
|
16
|
-
indicator:
|
|
17
|
-
left:
|
|
18
|
-
right:
|
|
19
|
-
hidden:
|
|
15
|
+
viewport: J,
|
|
16
|
+
indicator: Q,
|
|
17
|
+
left: Z,
|
|
18
|
+
right: tt,
|
|
19
|
+
hidden: et
|
|
20
20
|
};
|
|
21
|
-
function
|
|
21
|
+
function it({
|
|
22
22
|
className: S,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
childrenSpacing: E,
|
|
24
|
+
showScrollbar: C = !1,
|
|
25
|
+
children: D,
|
|
25
26
|
caption: d,
|
|
26
|
-
scrollStep:
|
|
27
|
-
leftButtonContent:
|
|
28
|
-
rightButtonContent:
|
|
29
|
-
headerClassName:
|
|
30
|
-
showIndicators:
|
|
31
|
-
hideHeader:
|
|
27
|
+
scrollStep: m = 160,
|
|
28
|
+
leftButtonContent: W,
|
|
29
|
+
rightButtonContent: z,
|
|
30
|
+
headerClassName: O,
|
|
31
|
+
showIndicators: B = !0,
|
|
32
|
+
hideHeader: M = !1
|
|
32
33
|
// new default
|
|
33
34
|
}) {
|
|
34
|
-
const n =
|
|
35
|
+
const n = g(null), [p, w] = h(!1), s = g({ x: 0, scroll: 0 }), f = g(!1), P = 5, [_, R] = h(!0), [v, X] = h(!1), [u, k] = h(!1), c = () => {
|
|
35
36
|
const t = n.current;
|
|
36
37
|
if (!t) return;
|
|
37
38
|
const r = t.scrollWidth - t.clientWidth;
|
|
38
|
-
|
|
39
|
-
}, k = (t) => {
|
|
40
|
-
!n.current || !u || (p(!0), c.current.x = t.clientX, c.current.scroll = n.current.scrollLeft, f.current = !1);
|
|
39
|
+
k(t.scrollWidth > t.clientWidth + 1), R(t.scrollLeft <= 0), X(t.scrollLeft >= r - 1);
|
|
41
40
|
}, A = (t) => {
|
|
42
|
-
|
|
43
|
-
const r = t.clientX - c.current.x;
|
|
44
|
-
n.current.scrollLeft = c.current.scroll - r, Math.abs(t.clientX - c.current.x) > M && (f.current = !0);
|
|
45
|
-
}, x = () => {
|
|
46
|
-
n.current && p(!1);
|
|
41
|
+
!n.current || !u || (w(!0), s.current.x = t.clientX, s.current.scroll = n.current.scrollLeft, f.current = !1);
|
|
47
42
|
}, H = (t) => {
|
|
43
|
+
if (!p || !n.current) return;
|
|
44
|
+
const r = t.clientX - s.current.x;
|
|
45
|
+
n.current.scrollLeft = s.current.scroll - r, Math.abs(t.clientX - s.current.x) > P && (f.current = !0);
|
|
46
|
+
}, x = () => {
|
|
47
|
+
n.current && w(!1);
|
|
48
|
+
}, T = (t) => {
|
|
48
49
|
f.current && (t.preventDefault(), t.stopPropagation(), f.current = !1);
|
|
49
50
|
}, y = (t) => {
|
|
50
51
|
const r = n.current;
|
|
51
52
|
if (!r) return;
|
|
52
53
|
const o = Math.max(0, Math.min(r.scrollLeft + t, r.scrollWidth - r.clientWidth));
|
|
53
|
-
r.scrollTo({ left: o, behavior: "smooth" }), requestAnimationFrame(
|
|
54
|
+
r.scrollTo({ left: o, behavior: "smooth" }), requestAnimationFrame(c);
|
|
54
55
|
};
|
|
55
|
-
|
|
56
|
+
b(() => {
|
|
56
57
|
const t = n.current;
|
|
57
58
|
if (!t) return;
|
|
58
59
|
const r = (o) => {
|
|
@@ -61,31 +62,31 @@ function st({
|
|
|
61
62
|
L !== 0 ? (o.preventDefault(), t.scrollLeft += L) : o.preventDefault();
|
|
62
63
|
};
|
|
63
64
|
return t.addEventListener("wheel", r, { passive: !1 }), () => t.removeEventListener("wheel", r);
|
|
64
|
-
}, []),
|
|
65
|
+
}, []), b(() => {
|
|
65
66
|
const t = n.current;
|
|
66
67
|
if (t)
|
|
67
|
-
return
|
|
68
|
-
}, []),
|
|
68
|
+
return c(), t.addEventListener("scroll", c), () => t.removeEventListener("scroll", c);
|
|
69
|
+
}, []), b(() => {
|
|
69
70
|
const t = n.current;
|
|
70
71
|
if (!t || typeof ResizeObserver > "u") return;
|
|
71
|
-
const r = new ResizeObserver(() =>
|
|
72
|
+
const r = new ResizeObserver(() => c());
|
|
72
73
|
return r.observe(t), () => r.disconnect();
|
|
73
74
|
}, []);
|
|
74
|
-
const
|
|
75
|
+
const V = () => d == null ? null : typeof d == "string" ? /* @__PURE__ */ l(j, { variant: "display", size: "2xl", className: e.caption, children: d }) : d;
|
|
75
76
|
return /* @__PURE__ */ i("div", { className: a(e.root, S), children: [
|
|
76
|
-
!
|
|
77
|
-
|
|
77
|
+
!M && /* @__PURE__ */ i("div", { className: a(e.header, O), children: [
|
|
78
|
+
V(),
|
|
78
79
|
/* @__PURE__ */ i("div", { className: e.controls, children: [
|
|
79
80
|
/* @__PURE__ */ l(
|
|
80
81
|
"button",
|
|
81
82
|
{
|
|
82
83
|
type: "button",
|
|
83
84
|
className: e.controlBtn,
|
|
84
|
-
onClick: () => y(-
|
|
85
|
+
onClick: () => y(-m),
|
|
85
86
|
"aria-label": "Scroll left",
|
|
86
87
|
disabled: _,
|
|
87
88
|
"aria-disabled": _,
|
|
88
|
-
children:
|
|
89
|
+
children: W ?? /* @__PURE__ */ l(N, { iconKey: "fa-regular fa-chevron-left", size: "sm" })
|
|
89
90
|
}
|
|
90
91
|
),
|
|
91
92
|
/* @__PURE__ */ l(
|
|
@@ -93,11 +94,11 @@ function st({
|
|
|
93
94
|
{
|
|
94
95
|
type: "button",
|
|
95
96
|
className: e.controlBtn,
|
|
96
|
-
onClick: () => y(
|
|
97
|
+
onClick: () => y(m),
|
|
97
98
|
"aria-label": "Scroll right",
|
|
98
99
|
disabled: v,
|
|
99
100
|
"aria-disabled": v,
|
|
100
|
-
children:
|
|
101
|
+
children: z ?? /* @__PURE__ */ l(N, { iconKey: "fa-regular fa-chevron-right", size: "sm" })
|
|
101
102
|
}
|
|
102
103
|
)
|
|
103
104
|
] })
|
|
@@ -107,21 +108,22 @@ function st({
|
|
|
107
108
|
"div",
|
|
108
109
|
{
|
|
109
110
|
ref: n,
|
|
111
|
+
style: { gap: E ?? "var(--spacing-spacing-3xs)" },
|
|
110
112
|
className: a(
|
|
111
113
|
e.container,
|
|
112
|
-
e[`scrollVisibility--${
|
|
113
|
-
|
|
114
|
+
e[`scrollVisibility--${C}`],
|
|
115
|
+
p ? e.dragging : "",
|
|
114
116
|
!u && e.noOverflow
|
|
115
117
|
),
|
|
116
|
-
onPointerDown:
|
|
117
|
-
onPointerMove:
|
|
118
|
+
onPointerDown: A,
|
|
119
|
+
onPointerMove: H,
|
|
118
120
|
onPointerLeave: x,
|
|
119
121
|
onPointerUp: x,
|
|
120
|
-
onClickCapture:
|
|
121
|
-
children:
|
|
122
|
+
onClickCapture: T,
|
|
123
|
+
children: D
|
|
122
124
|
}
|
|
123
125
|
),
|
|
124
|
-
|
|
126
|
+
B && /* @__PURE__ */ i(Y, { children: [
|
|
125
127
|
/* @__PURE__ */ l(
|
|
126
128
|
"div",
|
|
127
129
|
{
|
|
@@ -147,5 +149,5 @@ function st({
|
|
|
147
149
|
] });
|
|
148
150
|
}
|
|
149
151
|
export {
|
|
150
|
-
|
|
152
|
+
it as HorizontalScroll
|
|
151
153
|
};
|