@caseparts-org/caseblocks 0.0.100 → 0.0.102
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/assets/HorizontalScroll.css +1 -1
- package/dist/atoms/HorizontalScroll/HorizontalScroll.d.ts +2 -1
- package/dist/atoms/HorizontalScroll/HorizontalScroll.js +76 -74
- package/dist/atoms/HorizontalScroll/HorizontalScroll.stories.d.ts +1 -1
- package/dist/atoms/HorizontalScroll/HorizontalScroll.stories.js +59 -56
- package/dist/atoms/Tooltip/Tooltip.d.ts +1 -0
- package/dist/atoms/Tooltip/Tooltip.js +62 -61
- package/dist/molecules/CategoryNav/CategoryNav.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._root_12m2a_1{width:100%}._header_12m2a_5{display:flex;align-items:center;justify-content:space-between;width:100%;gap:var(--spacing-spacing-2xs);margin-bottom:var(--spacing-spacing-2xs)}._controls_12m2a_13{display:flex;align-items:center;gap:var(--spacing-spacing-2xs)}._controlBtn_12m2a_18{cursor:pointer;padding:0;border:none;background-color:transparent;line-height:1;display:flex;align-items:center;justify-content:center}._controlBtn_12m2a_18:hover{color:var(--color-brand-primary-primary-teal-blue)}._controlBtn_12m2a_18:disabled:hover{cursor:default;color:var(--color-neutrals-neutral-3)}._container_12m2a_37{display:flex;flex-direction:row;align-items:center;flex-wrap:nowrap;overflow-x:auto;width:100%;-webkit-overflow-scrolling:touch;cursor:grab;-webkit-user-select:none;user-select:none;overscroll-behavior:contain;touch-action:pan-x}._dragging_12m2a_50{cursor:grabbing}._noOverflow_12m2a_53{cursor:default}._scrollVisibility--false_12m2a_58{scrollbar-width:none;-ms-overflow-style:none}._scrollVisibility--false_12m2a_58::-webkit-scrollbar{display:none}._viewport_12m2a_66{position:relative}._indicator_12m2a_69{position:absolute;top:0;bottom:0;width:48px;pointer-events:none;opacity:1;transition:opacity .25s;z-index:1}._left_12m2a_79{left:0;background:linear-gradient(to right,var(--horizontal-scroll-indicator-color, rgba(0,0,0,.15)) 0%,rgba(0,0,0,0) 100%)}._right_12m2a_85{right:0;background:linear-gradient(to left,var(--horizontal-scroll-indicator-color, rgba(0,0,0,.15)) 0%,rgba(0,0,0,0) 100%)}._hidden_12m2a_91{opacity:0}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PropsWithChildren, ReactNode } from 'react';
|
|
2
2
|
export interface HorizontalScrollProps extends PropsWithChildren {
|
|
3
3
|
className?: string;
|
|
4
|
+
childrenContainerClassName?: string;
|
|
4
5
|
childrenSpacing?: number | string;
|
|
5
6
|
showScrollbar?: boolean;
|
|
6
7
|
caption?: ReactNode;
|
|
@@ -11,4 +12,4 @@ export interface HorizontalScrollProps extends PropsWithChildren {
|
|
|
11
12
|
showIndicators?: boolean;
|
|
12
13
|
hideHeader?: boolean;
|
|
13
14
|
}
|
|
14
|
-
export declare function HorizontalScroll({ className, childrenSpacing, showScrollbar, children, caption, scrollStep, leftButtonContent, rightButtonContent, headerClassName, showIndicators, hideHeader, }: HorizontalScrollProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function HorizontalScroll({ className, childrenContainerClassName, childrenSpacing, showScrollbar, children, caption, scrollStep, leftButtonContent, rightButtonContent, headerClassName, showIndicators, hideHeader, }: HorizontalScrollProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,59 +1,60 @@
|
|
|
1
|
-
import { jsxs as i, jsx as l, Fragment as
|
|
2
|
-
import { useRef as
|
|
1
|
+
import { jsxs as i, jsx as l, Fragment as j } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as v, useState as h, useEffect as g } from "react";
|
|
3
3
|
import { Icon as N } from "../Icon/Icon.js";
|
|
4
|
-
import { Text as
|
|
5
|
-
import { c as
|
|
6
|
-
import '../../assets/HorizontalScroll.css';const
|
|
7
|
-
root:
|
|
8
|
-
header:
|
|
9
|
-
controls:
|
|
10
|
-
controlBtn:
|
|
11
|
-
container:
|
|
12
|
-
dragging:
|
|
13
|
-
noOverflow:
|
|
14
|
-
"scrollVisibility--false": "_scrollVisibility--
|
|
15
|
-
viewport:
|
|
16
|
-
indicator:
|
|
17
|
-
left:
|
|
18
|
-
right:
|
|
19
|
-
hidden:
|
|
4
|
+
import { Text as F } from "../Text/Text.js";
|
|
5
|
+
import { c as d } from "../../clsx-OuTLNxxd.js";
|
|
6
|
+
import '../../assets/HorizontalScroll.css';const K = "_root_12m2a_1", q = "_header_12m2a_5", G = "_controls_12m2a_13", I = "_controlBtn_12m2a_18", U = "_container_12m2a_37", $ = "_dragging_12m2a_50", J = "_noOverflow_12m2a_53", Q = "_viewport_12m2a_66", Z = "_indicator_12m2a_69", tt = "_left_12m2a_79", et = "_right_12m2a_85", rt = "_hidden_12m2a_91", e = {
|
|
7
|
+
root: K,
|
|
8
|
+
header: q,
|
|
9
|
+
controls: G,
|
|
10
|
+
controlBtn: I,
|
|
11
|
+
container: U,
|
|
12
|
+
dragging: $,
|
|
13
|
+
noOverflow: J,
|
|
14
|
+
"scrollVisibility--false": "_scrollVisibility--false_12m2a_58",
|
|
15
|
+
viewport: Q,
|
|
16
|
+
indicator: Z,
|
|
17
|
+
left: tt,
|
|
18
|
+
right: et,
|
|
19
|
+
hidden: rt
|
|
20
20
|
};
|
|
21
21
|
function it({
|
|
22
22
|
className: S,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
childrenContainerClassName: E,
|
|
24
|
+
childrenSpacing: C,
|
|
25
|
+
showScrollbar: D = !1,
|
|
26
|
+
children: W,
|
|
27
|
+
caption: f,
|
|
28
|
+
scrollStep: p = 160,
|
|
29
|
+
leftButtonContent: z,
|
|
30
|
+
rightButtonContent: O,
|
|
31
|
+
headerClassName: B,
|
|
32
|
+
showIndicators: M = !0,
|
|
33
|
+
hideHeader: P = !1
|
|
33
34
|
// new default
|
|
34
35
|
}) {
|
|
35
|
-
const n =
|
|
36
|
+
const n = v(null), [b, x] = h(!1), s = v({ x: 0, scroll: 0 }), u = v(!1), R = 5, [m, X] = h(!0), [_, k] = h(!1), [c, A] = h(!1), a = () => {
|
|
36
37
|
const t = n.current;
|
|
37
38
|
if (!t) return;
|
|
38
39
|
const r = t.scrollWidth - t.clientWidth;
|
|
39
|
-
|
|
40
|
-
}, A = (t) => {
|
|
41
|
-
!n.current || !u || (w(!0), s.current.x = t.clientX, s.current.scroll = n.current.scrollLeft, f.current = !1);
|
|
40
|
+
A(t.scrollWidth > t.clientWidth + 1), X(t.scrollLeft <= 0), k(t.scrollLeft >= r - 1);
|
|
42
41
|
}, H = (t) => {
|
|
43
|
-
|
|
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);
|
|
42
|
+
!n.current || !c || (x(!0), s.current.x = t.clientX, s.current.scroll = n.current.scrollLeft, u.current = !1);
|
|
48
43
|
}, T = (t) => {
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
if (!b || !n.current) return;
|
|
45
|
+
const r = t.clientX - s.current.x;
|
|
46
|
+
n.current.scrollLeft = s.current.scroll - r, Math.abs(t.clientX - s.current.x) > R && (u.current = !0);
|
|
47
|
+
}, y = () => {
|
|
48
|
+
n.current && x(!1);
|
|
49
|
+
}, V = (t) => {
|
|
50
|
+
u.current && (t.preventDefault(), t.stopPropagation(), u.current = !1);
|
|
51
|
+
}, w = (t) => {
|
|
51
52
|
const r = n.current;
|
|
52
53
|
if (!r) return;
|
|
53
54
|
const o = Math.max(0, Math.min(r.scrollLeft + t, r.scrollWidth - r.clientWidth));
|
|
54
|
-
r.scrollTo({ left: o, behavior: "smooth" }), requestAnimationFrame(
|
|
55
|
+
r.scrollTo({ left: o, behavior: "smooth" }), requestAnimationFrame(a);
|
|
55
56
|
};
|
|
56
|
-
|
|
57
|
+
g(() => {
|
|
57
58
|
const t = n.current;
|
|
58
59
|
if (!t) return;
|
|
59
60
|
const r = (o) => {
|
|
@@ -62,31 +63,31 @@ function it({
|
|
|
62
63
|
L !== 0 ? (o.preventDefault(), t.scrollLeft += L) : o.preventDefault();
|
|
63
64
|
};
|
|
64
65
|
return t.addEventListener("wheel", r, { passive: !1 }), () => t.removeEventListener("wheel", r);
|
|
65
|
-
}, []),
|
|
66
|
+
}, []), g(() => {
|
|
66
67
|
const t = n.current;
|
|
67
68
|
if (t)
|
|
68
|
-
return
|
|
69
|
-
}, []),
|
|
69
|
+
return a(), t.addEventListener("scroll", a), () => t.removeEventListener("scroll", a);
|
|
70
|
+
}, []), g(() => {
|
|
70
71
|
const t = n.current;
|
|
71
72
|
if (!t || typeof ResizeObserver > "u") return;
|
|
72
|
-
const r = new ResizeObserver(() =>
|
|
73
|
+
const r = new ResizeObserver(() => a());
|
|
73
74
|
return r.observe(t), () => r.disconnect();
|
|
74
75
|
}, []);
|
|
75
|
-
const
|
|
76
|
-
return /* @__PURE__ */ i("div", { className:
|
|
77
|
-
!
|
|
78
|
-
|
|
79
|
-
/* @__PURE__ */ i("div", { className: e.controls, children: [
|
|
76
|
+
const Y = () => f == null ? null : typeof f == "string" ? /* @__PURE__ */ l(F, { variant: "display", size: "2xl", className: e.caption, children: f }) : f;
|
|
77
|
+
return /* @__PURE__ */ i("div", { className: d(e.root, S), children: [
|
|
78
|
+
!P && /* @__PURE__ */ i("div", { className: d(e.header, B), children: [
|
|
79
|
+
Y(),
|
|
80
|
+
c && /* @__PURE__ */ i("div", { className: e.controls, children: [
|
|
80
81
|
/* @__PURE__ */ l(
|
|
81
82
|
"button",
|
|
82
83
|
{
|
|
83
84
|
type: "button",
|
|
84
85
|
className: e.controlBtn,
|
|
85
|
-
onClick: () =>
|
|
86
|
+
onClick: () => w(-p),
|
|
86
87
|
"aria-label": "Scroll left",
|
|
87
|
-
disabled:
|
|
88
|
-
"aria-disabled":
|
|
89
|
-
children:
|
|
88
|
+
disabled: m,
|
|
89
|
+
"aria-disabled": m,
|
|
90
|
+
children: z ?? /* @__PURE__ */ l(N, { iconKey: "fa-regular fa-chevron-left", size: "sm" })
|
|
90
91
|
}
|
|
91
92
|
),
|
|
92
93
|
/* @__PURE__ */ l(
|
|
@@ -94,11 +95,11 @@ function it({
|
|
|
94
95
|
{
|
|
95
96
|
type: "button",
|
|
96
97
|
className: e.controlBtn,
|
|
97
|
-
onClick: () =>
|
|
98
|
+
onClick: () => w(p),
|
|
98
99
|
"aria-label": "Scroll right",
|
|
99
|
-
disabled:
|
|
100
|
-
"aria-disabled":
|
|
101
|
-
children:
|
|
100
|
+
disabled: _,
|
|
101
|
+
"aria-disabled": _,
|
|
102
|
+
children: O ?? /* @__PURE__ */ l(N, { iconKey: "fa-regular fa-chevron-right", size: "sm" })
|
|
102
103
|
}
|
|
103
104
|
)
|
|
104
105
|
] })
|
|
@@ -108,39 +109,40 @@ function it({
|
|
|
108
109
|
"div",
|
|
109
110
|
{
|
|
110
111
|
ref: n,
|
|
111
|
-
style: { gap:
|
|
112
|
-
className:
|
|
112
|
+
style: { gap: C ?? "var(--spacing-spacing-3xs)" },
|
|
113
|
+
className: d(
|
|
113
114
|
e.container,
|
|
114
|
-
e[`scrollVisibility--${
|
|
115
|
-
|
|
116
|
-
!
|
|
115
|
+
e[`scrollVisibility--${D}`],
|
|
116
|
+
b ? e.dragging : "",
|
|
117
|
+
!c && e.noOverflow,
|
|
118
|
+
E
|
|
117
119
|
),
|
|
118
|
-
onPointerDown:
|
|
119
|
-
onPointerMove:
|
|
120
|
-
onPointerLeave:
|
|
121
|
-
onPointerUp:
|
|
122
|
-
onClickCapture:
|
|
123
|
-
children:
|
|
120
|
+
onPointerDown: H,
|
|
121
|
+
onPointerMove: T,
|
|
122
|
+
onPointerLeave: y,
|
|
123
|
+
onPointerUp: y,
|
|
124
|
+
onClickCapture: V,
|
|
125
|
+
children: W
|
|
124
126
|
}
|
|
125
127
|
),
|
|
126
|
-
|
|
128
|
+
M && /* @__PURE__ */ i(j, { children: [
|
|
127
129
|
/* @__PURE__ */ l(
|
|
128
130
|
"div",
|
|
129
131
|
{
|
|
130
|
-
className:
|
|
132
|
+
className: d(
|
|
131
133
|
e.indicator,
|
|
132
134
|
e.left,
|
|
133
|
-
(
|
|
135
|
+
(m || !c) && e.hidden
|
|
134
136
|
)
|
|
135
137
|
}
|
|
136
138
|
),
|
|
137
139
|
/* @__PURE__ */ l(
|
|
138
140
|
"div",
|
|
139
141
|
{
|
|
140
|
-
className:
|
|
142
|
+
className: d(
|
|
141
143
|
e.indicator,
|
|
142
144
|
e.right,
|
|
143
|
-
(
|
|
145
|
+
(_ || !c) && e.hidden
|
|
144
146
|
)
|
|
145
147
|
}
|
|
146
148
|
)
|
|
@@ -4,11 +4,11 @@ interface DemoArgs {
|
|
|
4
4
|
itemCount: number;
|
|
5
5
|
itemWidth: number;
|
|
6
6
|
itemHeight: number;
|
|
7
|
-
gap: number;
|
|
8
7
|
rounded: boolean;
|
|
9
8
|
gradient: boolean;
|
|
10
9
|
showIndicators: boolean;
|
|
11
10
|
hideHeader: boolean;
|
|
11
|
+
childrenSpacing: number;
|
|
12
12
|
}
|
|
13
13
|
type StoryArgs = DemoArgs;
|
|
14
14
|
declare const meta: Meta<StoryArgs>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as i, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { HorizontalScroll as r } from "./HorizontalScroll.js";
|
|
3
|
-
const
|
|
3
|
+
const u = {
|
|
4
4
|
title: "Case Parts/Atoms/HorizontalScroll",
|
|
5
5
|
component: r,
|
|
6
6
|
tags: ["autodocs"],
|
|
@@ -38,10 +38,6 @@ Use for carousels, chip lists, card rails, horizontally overflowing panels.
|
|
|
38
38
|
control: { type: "number", min: 30, max: 240, step: 5 },
|
|
39
39
|
description: "Height of each item (px)."
|
|
40
40
|
},
|
|
41
|
-
gap: {
|
|
42
|
-
control: { type: "number", min: 0, max: 48, step: 2 },
|
|
43
|
-
description: "Gap between items (px)."
|
|
44
|
-
},
|
|
45
41
|
rounded: {
|
|
46
42
|
control: { type: "boolean" },
|
|
47
43
|
description: "Apply border radius to items."
|
|
@@ -57,6 +53,10 @@ Use for carousels, chip lists, card rails, horizontally overflowing panels.
|
|
|
57
53
|
hideHeader: {
|
|
58
54
|
control: { type: "boolean" },
|
|
59
55
|
description: "Hide the caption row and arrow controls."
|
|
56
|
+
},
|
|
57
|
+
childrenSpacing: {
|
|
58
|
+
control: { type: "number", min: 0, max: 64, step: 2 },
|
|
59
|
+
description: "Gap between direct children (flex gap)."
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
args: {
|
|
@@ -64,25 +64,26 @@ Use for carousels, chip lists, card rails, horizontally overflowing panels.
|
|
|
64
64
|
itemCount: 20,
|
|
65
65
|
itemWidth: 120,
|
|
66
66
|
itemHeight: 80,
|
|
67
|
-
gap: 12,
|
|
68
67
|
rounded: !0,
|
|
69
68
|
gradient: !0,
|
|
70
69
|
showIndicators: !0,
|
|
71
70
|
// new default
|
|
72
|
-
hideHeader: !1
|
|
71
|
+
hideHeader: !1,
|
|
72
|
+
// new default
|
|
73
|
+
childrenSpacing: 12
|
|
73
74
|
// new default
|
|
74
75
|
}
|
|
75
|
-
},
|
|
76
|
+
}, n = /* @__PURE__ */ o("style", { children: `
|
|
76
77
|
.horizontalDemoScroll {
|
|
77
78
|
touch-action: none; /* ensure pointer events for horizontal drag */
|
|
78
79
|
}
|
|
79
80
|
.horizontalDemoScroll a {
|
|
80
81
|
-webkit-user-drag: none; /* Safari/Chrome: prevent ghost dragging of link */
|
|
81
82
|
}
|
|
82
|
-
` }),
|
|
83
|
-
const { itemCount: d, itemWidth:
|
|
84
|
-
return Array.from({ length: d }, (
|
|
85
|
-
const
|
|
83
|
+
` }), t = (e) => {
|
|
84
|
+
const { itemCount: d, itemWidth: c, itemHeight: l, rounded: s, gradient: h } = e;
|
|
85
|
+
return Array.from({ length: d }, (p, m) => {
|
|
86
|
+
const a = m + 1;
|
|
86
87
|
return /* @__PURE__ */ o(
|
|
87
88
|
"a",
|
|
88
89
|
{
|
|
@@ -90,29 +91,28 @@ Use for carousels, chip lists, card rails, horizontally overflowing panels.
|
|
|
90
91
|
draggable: !1,
|
|
91
92
|
style: {
|
|
92
93
|
flex: "0 0 auto",
|
|
93
|
-
width:
|
|
94
|
-
height:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
background: m ? "linear-gradient(135deg,#4F46E5,#6366F1)" : "#4F46E5",
|
|
94
|
+
width: c,
|
|
95
|
+
height: l,
|
|
96
|
+
borderRadius: s ? 8 : 0,
|
|
97
|
+
background: h ? "linear-gradient(135deg,#4F46E5,#6366F1)" : "#4F46E5",
|
|
98
98
|
color: "#fff",
|
|
99
99
|
display: "flex",
|
|
100
100
|
alignItems: "center",
|
|
101
101
|
justifyContent: "center",
|
|
102
|
-
fontSize: Math.max(12, Math.min(24,
|
|
102
|
+
fontSize: Math.max(12, Math.min(24, l / 3)),
|
|
103
103
|
fontWeight: 600,
|
|
104
104
|
userSelect: "none",
|
|
105
105
|
boxShadow: "0 2px 6px rgba(0,0,0,0.25)"
|
|
106
106
|
},
|
|
107
|
-
children:
|
|
107
|
+
children: a
|
|
108
108
|
},
|
|
109
|
-
|
|
109
|
+
a
|
|
110
110
|
);
|
|
111
111
|
});
|
|
112
|
-
},
|
|
112
|
+
}, w = {
|
|
113
113
|
name: "Playground",
|
|
114
|
-
render: (e) => /* @__PURE__ */
|
|
115
|
-
|
|
114
|
+
render: (e) => /* @__PURE__ */ i("div", { style: { padding: 24 }, children: [
|
|
115
|
+
n,
|
|
116
116
|
/* @__PURE__ */ o("h3", { style: { margin: "0 0 12px" }, children: "HorizontalScroll Playground" }),
|
|
117
117
|
/* @__PURE__ */ o("p", { style: { margin: "0 0 16px", fontSize: 14, color: "#555" }, children: "Drag horizontally or use the mouse wheel. Tweak values in Controls." }),
|
|
118
118
|
/* @__PURE__ */ o(
|
|
@@ -122,15 +122,16 @@ Use for carousels, chip lists, card rails, horizontally overflowing panels.
|
|
|
122
122
|
showScrollbar: e.showScrollbar,
|
|
123
123
|
showIndicators: e.showIndicators,
|
|
124
124
|
hideHeader: e.hideHeader,
|
|
125
|
+
childrenSpacing: e.childrenSpacing,
|
|
125
126
|
caption: `Playground (${e.itemCount} items)`,
|
|
126
|
-
children:
|
|
127
|
+
children: t(e)
|
|
127
128
|
}
|
|
128
129
|
)
|
|
129
130
|
] })
|
|
130
|
-
},
|
|
131
|
+
}, b = {
|
|
131
132
|
args: { showScrollbar: !0 },
|
|
132
|
-
render: (e) => /* @__PURE__ */
|
|
133
|
-
|
|
133
|
+
render: (e) => /* @__PURE__ */ i("div", { style: { padding: 24 }, children: [
|
|
134
|
+
n,
|
|
134
135
|
/* @__PURE__ */ o("h3", { style: { margin: "0 0 12px" }, children: "Scrollbar Visible" }),
|
|
135
136
|
/* @__PURE__ */ o(
|
|
136
137
|
r,
|
|
@@ -139,21 +140,21 @@ Use for carousels, chip lists, card rails, horizontally overflowing panels.
|
|
|
139
140
|
showScrollbar: !0,
|
|
140
141
|
showIndicators: e.showIndicators,
|
|
141
142
|
hideHeader: e.hideHeader,
|
|
143
|
+
childrenSpacing: e.childrenSpacing,
|
|
142
144
|
caption: "Scrollbar Visible",
|
|
143
|
-
children:
|
|
145
|
+
children: t(e)
|
|
144
146
|
}
|
|
145
147
|
)
|
|
146
148
|
] })
|
|
147
|
-
},
|
|
149
|
+
}, y = {
|
|
148
150
|
args: {
|
|
149
151
|
itemCount: 40,
|
|
150
152
|
itemWidth: 90,
|
|
151
153
|
itemHeight: 60,
|
|
152
|
-
gap: 8,
|
|
153
154
|
showScrollbar: !1
|
|
154
155
|
},
|
|
155
|
-
render: (e) => /* @__PURE__ */
|
|
156
|
-
|
|
156
|
+
render: (e) => /* @__PURE__ */ i("div", { style: { padding: 24 }, children: [
|
|
157
|
+
n,
|
|
157
158
|
/* @__PURE__ */ o("h3", { style: { margin: "0 0 12px" }, children: "Dense Small Items" }),
|
|
158
159
|
/* @__PURE__ */ o(
|
|
159
160
|
r,
|
|
@@ -162,21 +163,21 @@ Use for carousels, chip lists, card rails, horizontally overflowing panels.
|
|
|
162
163
|
showScrollbar: e.showScrollbar,
|
|
163
164
|
showIndicators: e.showIndicators,
|
|
164
165
|
hideHeader: e.hideHeader,
|
|
166
|
+
childrenSpacing: e.childrenSpacing,
|
|
165
167
|
caption: `Dense (${e.itemCount} items)`,
|
|
166
|
-
children:
|
|
168
|
+
children: t(e)
|
|
167
169
|
}
|
|
168
170
|
)
|
|
169
171
|
] })
|
|
170
|
-
},
|
|
172
|
+
}, f = {
|
|
171
173
|
args: {
|
|
172
174
|
itemCount: 12,
|
|
173
175
|
itemWidth: 260,
|
|
174
176
|
itemHeight: 160,
|
|
175
|
-
gap: 16,
|
|
176
177
|
gradient: !1
|
|
177
178
|
},
|
|
178
|
-
render: (e) => /* @__PURE__ */
|
|
179
|
-
|
|
179
|
+
render: (e) => /* @__PURE__ */ i("div", { style: { padding: 24 }, children: [
|
|
180
|
+
n,
|
|
180
181
|
/* @__PURE__ */ o("h3", { style: { margin: "0 0 12px" }, children: "Large Cards" }),
|
|
181
182
|
/* @__PURE__ */ o(
|
|
182
183
|
r,
|
|
@@ -185,22 +186,23 @@ Use for carousels, chip lists, card rails, horizontally overflowing panels.
|
|
|
185
186
|
showScrollbar: e.showScrollbar,
|
|
186
187
|
showIndicators: e.showIndicators,
|
|
187
188
|
hideHeader: e.hideHeader,
|
|
189
|
+
childrenSpacing: e.childrenSpacing,
|
|
188
190
|
caption: "Large Cards",
|
|
189
|
-
children:
|
|
191
|
+
children: t(e)
|
|
190
192
|
}
|
|
191
193
|
)
|
|
192
194
|
] })
|
|
193
|
-
},
|
|
195
|
+
}, H = {
|
|
194
196
|
name: "Without Indicators",
|
|
195
197
|
args: {
|
|
196
198
|
showIndicators: !1,
|
|
197
199
|
itemCount: 16,
|
|
198
200
|
itemWidth: 140,
|
|
199
201
|
itemHeight: 72,
|
|
200
|
-
|
|
202
|
+
childrenSpacing: 12
|
|
201
203
|
},
|
|
202
|
-
render: (e) => /* @__PURE__ */
|
|
203
|
-
|
|
204
|
+
render: (e) => /* @__PURE__ */ i("div", { style: { padding: 24 }, children: [
|
|
205
|
+
n,
|
|
204
206
|
/* @__PURE__ */ o("h3", { style: { margin: "0 0 12px" }, children: "Indicators Disabled" }),
|
|
205
207
|
/* @__PURE__ */ o(
|
|
206
208
|
r,
|
|
@@ -209,23 +211,23 @@ Use for carousels, chip lists, card rails, horizontally overflowing panels.
|
|
|
209
211
|
showScrollbar: e.showScrollbar,
|
|
210
212
|
showIndicators: !1,
|
|
211
213
|
hideHeader: e.hideHeader,
|
|
214
|
+
childrenSpacing: e.childrenSpacing,
|
|
212
215
|
caption: "No Edge Indicators",
|
|
213
|
-
children:
|
|
216
|
+
children: t(e)
|
|
214
217
|
}
|
|
215
218
|
)
|
|
216
219
|
] })
|
|
217
|
-
},
|
|
220
|
+
}, x = {
|
|
218
221
|
name: "Header Hidden",
|
|
219
222
|
args: {
|
|
220
223
|
hideHeader: !0,
|
|
221
224
|
itemCount: 14,
|
|
222
225
|
itemWidth: 130,
|
|
223
226
|
itemHeight: 70,
|
|
224
|
-
gap: 10,
|
|
225
227
|
showIndicators: !0
|
|
226
228
|
},
|
|
227
|
-
render: (e) => /* @__PURE__ */
|
|
228
|
-
|
|
229
|
+
render: (e) => /* @__PURE__ */ i("div", { style: { padding: 24 }, children: [
|
|
230
|
+
n,
|
|
229
231
|
/* @__PURE__ */ o("h3", { style: { margin: "0 0 12px" }, children: "Header Hidden" }),
|
|
230
232
|
/* @__PURE__ */ o(
|
|
231
233
|
r,
|
|
@@ -234,18 +236,19 @@ Use for carousels, chip lists, card rails, horizontally overflowing panels.
|
|
|
234
236
|
showScrollbar: e.showScrollbar,
|
|
235
237
|
showIndicators: e.showIndicators,
|
|
236
238
|
hideHeader: !0,
|
|
239
|
+
childrenSpacing: e.childrenSpacing,
|
|
237
240
|
caption: "(Will not render since header hidden)",
|
|
238
|
-
children:
|
|
241
|
+
children: t(e)
|
|
239
242
|
}
|
|
240
243
|
)
|
|
241
244
|
] })
|
|
242
245
|
};
|
|
243
246
|
export {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
247
|
+
y as DenseSmallItems,
|
|
248
|
+
x as HeaderHidden,
|
|
249
|
+
f as LargeCards,
|
|
250
|
+
w as Playground,
|
|
251
|
+
b as WithScrollbar,
|
|
252
|
+
H as WithoutIndicators,
|
|
253
|
+
u as default
|
|
251
254
|
};
|
|
@@ -1,78 +1,79 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as W, Fragment as A, jsx as S } from "react/jsx-runtime";
|
|
2
2
|
import * as i from "react";
|
|
3
|
-
import { c as
|
|
4
|
-
import { r as
|
|
5
|
-
import '../../assets/Tooltip.css';const
|
|
6
|
-
tooltip:
|
|
7
|
-
content:
|
|
3
|
+
import { c as j } from "../../clsx-OuTLNxxd.js";
|
|
4
|
+
import { r as D } from "../../index-B4KbmMH3.js";
|
|
5
|
+
import '../../assets/Tooltip.css';const I = "_tooltip_17o7a_1", O = "_content_17o7a_11", H = {
|
|
6
|
+
tooltip: I,
|
|
7
|
+
content: O
|
|
8
8
|
};
|
|
9
|
-
function
|
|
10
|
-
return
|
|
9
|
+
function $(u) {
|
|
10
|
+
return u ? u.includes(" ") ? u : `${u} center` : "top center";
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
const
|
|
12
|
+
function q(u) {
|
|
13
|
+
const w = $(u).toLowerCase(), [s, t] = w.split(" ");
|
|
14
14
|
return { side: ["top", "right", "bottom", "left"].includes(s) ? s : "top", align: t === "left" || t === "top" ? "start" : t === "right" || t === "bottom" ? "end" : "center" };
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const n =
|
|
18
|
-
let
|
|
19
|
-
s === "top" ?
|
|
20
|
-
const E = window.innerWidth,
|
|
21
|
-
return
|
|
16
|
+
function G(u, w, s, t, d = 0) {
|
|
17
|
+
const n = u.getBoundingClientRect(), f = w.getBoundingClientRect();
|
|
18
|
+
let a = 0, c = 0;
|
|
19
|
+
s === "top" ? a = n.top - f.height - d : s === "bottom" ? a = n.bottom + d : s === "left" ? c = n.left - f.width - d : s === "right" && (c = n.right + d), s === "top" || s === "bottom" ? t === "start" ? c = n.left : t === "end" ? c = n.right - f.width : c = n.left + n.width / 2 - f.width / 2 : t === "start" ? a = n.top : t === "end" ? a = n.bottom - f.height : a = n.top + n.height / 2 - f.height / 2;
|
|
20
|
+
const E = window.innerWidth, v = window.innerHeight;
|
|
21
|
+
return a = Math.max(4, Math.min(v - f.height - 4, a)), c = Math.max(4, Math.min(E - f.width - 4, c)), { top: a, left: c };
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
tooltipClassName:
|
|
25
|
-
contentClassName:
|
|
23
|
+
const U = ({
|
|
24
|
+
tooltipClassName: u,
|
|
25
|
+
contentClassName: w,
|
|
26
26
|
children: s,
|
|
27
27
|
trigger: t,
|
|
28
28
|
position: d,
|
|
29
29
|
disabled: n,
|
|
30
|
-
openDelay:
|
|
31
|
-
closeDelay:
|
|
32
|
-
leaveGraceMs: c = 0
|
|
30
|
+
openDelay: f = 150,
|
|
31
|
+
closeDelay: a = 100,
|
|
32
|
+
leaveGraceMs: c = 0,
|
|
33
|
+
tooltipOffset: E = 4
|
|
33
34
|
}) => {
|
|
34
|
-
const { side:
|
|
35
|
+
const { side: v, align: b } = q(d), [o, R] = i.useState(!1), [m, C] = i.useState(null), T = i.useRef(null), g = i.useRef(null), x = i.useRef(null), y = i.useRef(null), L = i.useRef(null), h = i.useRef(!1), p = (e) => {
|
|
35
36
|
e.current && (window.clearTimeout(e.current), e.current = null);
|
|
36
37
|
}, B = () => {
|
|
37
|
-
|
|
38
|
+
p(x), p(y), p(L);
|
|
38
39
|
};
|
|
39
40
|
i.useEffect(() => () => B(), []);
|
|
40
41
|
const k = () => {
|
|
41
|
-
n || o || (
|
|
42
|
+
n || o || (p(x), x.current = window.setTimeout(() => R(!0), f));
|
|
42
43
|
}, _ = () => {
|
|
43
|
-
o && (
|
|
44
|
-
|
|
45
|
-
},
|
|
44
|
+
o && (p(y), y.current = window.setTimeout(() => {
|
|
45
|
+
h.current || R(!1);
|
|
46
|
+
}, a));
|
|
46
47
|
}, z = () => {
|
|
47
48
|
if (o) {
|
|
48
|
-
if (
|
|
49
|
+
if (p(L), c <= 0) {
|
|
49
50
|
_();
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
L.current = window.setTimeout(() => {
|
|
54
|
+
h.current || _();
|
|
54
55
|
}, c);
|
|
55
56
|
}
|
|
56
|
-
},
|
|
57
|
-
e == null || e(
|
|
58
|
-
},
|
|
57
|
+
}, P = (e, r) => (l) => {
|
|
58
|
+
e == null || e(l), r == null || r(l);
|
|
59
|
+
}, N = i.cloneElement(t, {
|
|
59
60
|
ref: (e) => {
|
|
60
61
|
const { ref: r } = t;
|
|
61
62
|
typeof r == "function" ? r(e) : r && (r.current = e), T.current = e;
|
|
62
63
|
},
|
|
63
|
-
onPointerEnter:
|
|
64
|
-
onPointerLeave:
|
|
65
|
-
onFocus:
|
|
66
|
-
onBlur:
|
|
64
|
+
onPointerEnter: P(t.props.onPointerEnter, k),
|
|
65
|
+
onPointerLeave: P(t.props.onPointerLeave, z),
|
|
66
|
+
onFocus: P(t.props.onFocus, k),
|
|
67
|
+
onBlur: P(t.props.onBlur, _),
|
|
67
68
|
"aria-describedby": o ? "tooltip-popup" : void 0,
|
|
68
69
|
style: { ...t.props.style || {}, outline: "none" }
|
|
69
70
|
});
|
|
70
71
|
return i.useEffect(() => {
|
|
71
|
-
n && o && (B(),
|
|
72
|
+
n && o && (B(), R(!1));
|
|
72
73
|
}, [n]), i.useEffect(() => {
|
|
73
74
|
if (!o) return;
|
|
74
75
|
const e = (r) => {
|
|
75
|
-
r.key === "Escape" &&
|
|
76
|
+
r.key === "Escape" && R(!1);
|
|
76
77
|
};
|
|
77
78
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
78
79
|
}, [o]), i.useLayoutEffect(() => {
|
|
@@ -82,36 +83,36 @@ const Q = ({
|
|
|
82
83
|
}
|
|
83
84
|
const e = T.current, r = g.current;
|
|
84
85
|
if (!e || !r) return;
|
|
85
|
-
const
|
|
86
|
-
C(
|
|
86
|
+
const l = () => {
|
|
87
|
+
C(G(e, r, v, b, E));
|
|
87
88
|
};
|
|
88
|
-
return
|
|
89
|
-
window.removeEventListener("resize",
|
|
89
|
+
return l(), window.addEventListener("resize", l), window.addEventListener("scroll", l, !0), () => {
|
|
90
|
+
window.removeEventListener("resize", l), window.removeEventListener("scroll", l, !0);
|
|
90
91
|
};
|
|
91
|
-
}, [o,
|
|
92
|
+
}, [o, v, b, s, E]), i.useEffect(() => {
|
|
92
93
|
if (!o) return;
|
|
93
94
|
const e = (r) => {
|
|
94
|
-
const
|
|
95
|
-
if (!
|
|
96
|
-
const
|
|
97
|
-
!
|
|
95
|
+
const l = T.current, F = g.current;
|
|
96
|
+
if (!l || !F) return;
|
|
97
|
+
const M = r.target;
|
|
98
|
+
!l.contains(M) && !F.contains(M) && (h.current = !1, z());
|
|
98
99
|
};
|
|
99
100
|
return document.addEventListener("pointermove", e), () => document.removeEventListener("pointermove", e);
|
|
100
101
|
}, [o]), i.useEffect(() => {
|
|
101
|
-
o || (
|
|
102
|
-
}, [o]), /* @__PURE__ */
|
|
103
|
-
|
|
104
|
-
o && typeof document < "u" &&
|
|
105
|
-
/* @__PURE__ */
|
|
102
|
+
o || (h.current = !1);
|
|
103
|
+
}, [o]), /* @__PURE__ */ W(A, { children: [
|
|
104
|
+
N,
|
|
105
|
+
o && typeof document < "u" && D.createPortal(
|
|
106
|
+
/* @__PURE__ */ S(
|
|
106
107
|
"div",
|
|
107
108
|
{
|
|
108
109
|
id: "tooltip-popup",
|
|
109
110
|
ref: g,
|
|
110
111
|
role: "tooltip",
|
|
111
112
|
"aria-hidden": !o,
|
|
112
|
-
"data-side":
|
|
113
|
-
"data-align":
|
|
114
|
-
className:
|
|
113
|
+
"data-side": v,
|
|
114
|
+
"data-align": b,
|
|
115
|
+
className: j(H.tooltip, u),
|
|
115
116
|
style: {
|
|
116
117
|
position: "absolute",
|
|
117
118
|
top: (m == null ? void 0 : m.top) ?? 0,
|
|
@@ -120,12 +121,12 @@ const Q = ({
|
|
|
120
121
|
zIndex: 10
|
|
121
122
|
},
|
|
122
123
|
onPointerEnter: () => {
|
|
123
|
-
|
|
124
|
+
h.current = !0, p(y), p(L);
|
|
124
125
|
},
|
|
125
126
|
onPointerLeave: () => {
|
|
126
|
-
|
|
127
|
+
h.current = !1, z();
|
|
127
128
|
},
|
|
128
|
-
children: /* @__PURE__ */
|
|
129
|
+
children: /* @__PURE__ */ S("div", { className: j(H.content, w), children: s })
|
|
129
130
|
}
|
|
130
131
|
),
|
|
131
132
|
document.body
|
|
@@ -133,5 +134,5 @@ const Q = ({
|
|
|
133
134
|
] });
|
|
134
135
|
};
|
|
135
136
|
export {
|
|
136
|
-
|
|
137
|
+
U as Tooltip
|
|
137
138
|
};
|
|
@@ -19,6 +19,7 @@ function z({
|
|
|
19
19
|
{
|
|
20
20
|
openDelay: 180,
|
|
21
21
|
closeDelay: 0,
|
|
22
|
+
tooltipOffset: 0,
|
|
22
23
|
trigger: /* @__PURE__ */ e("li", { className: o.category, tabIndex: 0, children: /* @__PURE__ */ t(s, { href: i.route, children: [
|
|
23
24
|
/* @__PURE__ */ e(n, { size: "sm", weight: "semibold", children: i.label }),
|
|
24
25
|
i.showChevron && /* @__PURE__ */ e(
|