meticulous-ui 3.1.0 → 3.1.1
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/components/Carousel/Carousel.js +149 -124
- package/components/Carousel/styles.js +1 -1
- package/package.json +1 -1
|
@@ -1,129 +1,154 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { Wrapper as
|
|
6
|
-
const
|
|
7
|
-
/* @__PURE__ */
|
|
8
|
-
/* @__PURE__ */
|
|
9
|
-
] }),
|
|
1
|
+
import { jsxs as X, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as a, useRef as T, useEffect as E } from "react";
|
|
3
|
+
import le from "../Icons/ChevronLeft/ChevronLeft.js";
|
|
4
|
+
import de from "../Icons/ChevronRight/ChevronRight.js";
|
|
5
|
+
import { Wrapper as he, SlideArea as fe, NavButton as N, SlideViewport as me, SlideTrack as pe, PauseButton as ve, ProgressBar as we, DotsWrapper as ge, Dot as Me } from "./styles.js";
|
|
6
|
+
const I = 50, R = 2e3, be = () => /* @__PURE__ */ X("svg", { width: 12, height: 12, viewBox: "0 0 12 12", fill: "currentColor", "aria-hidden": "true", children: [
|
|
7
|
+
/* @__PURE__ */ r("rect", { x: "2", y: "1", width: "3", height: "10", rx: "1" }),
|
|
8
|
+
/* @__PURE__ */ r("rect", { x: "7", y: "1", width: "3", height: "10", rx: "1" })
|
|
9
|
+
] }), $e = () => /* @__PURE__ */ r("svg", { width: 12, height: 12, viewBox: "0 0 12 12", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ r("path", { d: "M2 1.5l9 4.5-9 4.5V1.5z" }) }), ke = ({
|
|
10
10
|
data: P,
|
|
11
|
-
renderCarousel:
|
|
12
|
-
visibleSlides:
|
|
11
|
+
renderCarousel: q,
|
|
12
|
+
visibleSlides: k = 1,
|
|
13
13
|
overlayArrows: o = !1,
|
|
14
|
-
arrowTop:
|
|
15
|
-
areDotsHidden:
|
|
16
|
-
autoSlide:
|
|
17
|
-
autoSlideSec:
|
|
18
|
-
loop:
|
|
19
|
-
dragToSlide:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
arrowTop: v,
|
|
15
|
+
areDotsHidden: Y = !1,
|
|
16
|
+
autoSlide: w = !1,
|
|
17
|
+
autoSlideSec: C = 3,
|
|
18
|
+
loop: l = !1,
|
|
19
|
+
dragToSlide: g = !1,
|
|
20
|
+
liveDrag: M = !1,
|
|
21
|
+
liveDragMobile: L = !0,
|
|
22
|
+
showProgress: G = !1,
|
|
23
|
+
defaultIndex: J = 0,
|
|
24
|
+
onSlideChange: y
|
|
23
25
|
}) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
var K;
|
|
27
|
+
const [n, b] = a(J), [B, d] = a(!0), [V, W] = a(!1), [h, f] = a(!1), [Q, m] = a(0), [F, p] = a(!1), [D, _] = a(!1), c = T(null), i = T(null), u = T(null), z = T(null);
|
|
28
|
+
E(() => {
|
|
29
|
+
const e = window.matchMedia("(max-width: 1024px)");
|
|
30
|
+
_(e.matches);
|
|
31
|
+
const t = (ue) => _(ue.matches);
|
|
32
|
+
return e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
33
|
+
}, []);
|
|
34
|
+
const s = P.length - k, $ = () => b((e) => l && e === 0 ? s : Math.max(e - 1, 0)), x = () => b((e) => l && e >= s ? 0 : Math.min(e + 1, s));
|
|
35
|
+
E(() => {
|
|
36
|
+
y == null || y(n);
|
|
27
37
|
}, [n]);
|
|
28
|
-
const
|
|
29
|
-
o && (clearTimeout(
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
|
|
38
|
+
const H = () => {
|
|
39
|
+
o && (clearTimeout(u.current), d(!0), u.current = setTimeout(() => d(!1), R));
|
|
40
|
+
}, Z = () => {
|
|
41
|
+
f(!0), o && (clearTimeout(u.current), d(!0));
|
|
42
|
+
}, S = () => {
|
|
43
|
+
f(!1), o && (u.current = setTimeout(() => d(!1), R));
|
|
34
44
|
};
|
|
35
|
-
|
|
45
|
+
E(() => {
|
|
36
46
|
if (o)
|
|
37
|
-
return
|
|
38
|
-
}, [o]),
|
|
39
|
-
if (!
|
|
47
|
+
return u.current = setTimeout(() => d(!1), R), () => clearTimeout(u.current);
|
|
48
|
+
}, [o]), E(() => {
|
|
49
|
+
if (!w || h) return;
|
|
40
50
|
const e = setInterval(() => {
|
|
41
|
-
|
|
42
|
-
},
|
|
51
|
+
b((t) => t >= s ? 0 : t + 1);
|
|
52
|
+
}, C * 1e3);
|
|
43
53
|
return () => clearInterval(e);
|
|
44
|
-
}, [
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
}, [w, C, h, s]);
|
|
55
|
+
const U = (e) => l ? e : n === 0 && e > 0 || n === s && e < 0 ? e * 0.3 : e, ee = (e) => {
|
|
56
|
+
c.current = e.touches[0].clientX, L && D && p(!0), H();
|
|
57
|
+
}, te = (e) => {
|
|
58
|
+
!L || !D || c.current === null || m(U(e.touches[0].clientX - c.current));
|
|
59
|
+
}, re = (e) => {
|
|
60
|
+
if (L && D && (p(!1), m(0)), c.current === null) return;
|
|
61
|
+
const t = c.current - e.changedTouches[0].clientX;
|
|
62
|
+
t > I ? x() : t < -I && $(), c.current = null;
|
|
63
|
+
}, ne = (e) => {
|
|
64
|
+
g && (i.current = e.clientX, M && p(!0));
|
|
65
|
+
}, se = (e) => {
|
|
66
|
+
!g || !M || i.current === null || m(U(e.clientX - i.current));
|
|
67
|
+
}, oe = (e) => {
|
|
68
|
+
if (!g || i.current === null) return;
|
|
69
|
+
M && (p(!1), m(0));
|
|
70
|
+
const t = i.current - e.clientX;
|
|
71
|
+
t > I ? x() : t < -I && $(), i.current = null;
|
|
72
|
+
}, ie = (e) => {
|
|
73
|
+
e.key === "ArrowLeft" ? (e.preventDefault(), $()) : e.key === "ArrowRight" && (e.preventDefault(), x());
|
|
74
|
+
}, j = ((K = z.current) == null ? void 0 : K.clientWidth) ?? 0, ae = j > 0 ? Q / j * 100 : 0, ce = -(n * (100 / k)) + ae, A = v !== void 0 ? typeof v == "number" ? `${v}px` : v : void 0, O = s + 1;
|
|
75
|
+
return /* @__PURE__ */ X(
|
|
76
|
+
he,
|
|
62
77
|
{
|
|
63
|
-
onClick:
|
|
64
|
-
onMouseEnter:
|
|
65
|
-
onMouseLeave:
|
|
66
|
-
|
|
78
|
+
onClick: H,
|
|
79
|
+
onMouseEnter: Z,
|
|
80
|
+
onMouseLeave: S,
|
|
81
|
+
onMouseMove: se,
|
|
82
|
+
onMouseUp: oe,
|
|
83
|
+
onKeyDown: ie,
|
|
67
84
|
role: "region",
|
|
68
85
|
"aria-label": "Carousel",
|
|
69
86
|
children: [
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
87
|
+
/* @__PURE__ */ X(
|
|
88
|
+
fe,
|
|
89
|
+
{
|
|
90
|
+
onTouchStart: ee,
|
|
91
|
+
onTouchMove: te,
|
|
92
|
+
onTouchEnd: re,
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ r(
|
|
95
|
+
N,
|
|
96
|
+
{
|
|
97
|
+
onClick: $,
|
|
98
|
+
disabled: !l && n === 0,
|
|
99
|
+
"aria-label": "Previous slide",
|
|
100
|
+
$overlay: o,
|
|
101
|
+
$visible: B,
|
|
102
|
+
$arrowTop: A,
|
|
103
|
+
$viewportFocused: V,
|
|
104
|
+
children: /* @__PURE__ */ r(le, { size: 20, "aria-hidden": "true" })
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
/* @__PURE__ */ r(
|
|
108
|
+
me,
|
|
109
|
+
{
|
|
110
|
+
ref: z,
|
|
111
|
+
tabIndex: 0,
|
|
112
|
+
"aria-label": "Carousel slides. Use arrow keys to navigate.",
|
|
113
|
+
$draggable: g,
|
|
114
|
+
onFocus: () => {
|
|
115
|
+
W(!0), f(!0);
|
|
116
|
+
},
|
|
117
|
+
onBlur: () => {
|
|
118
|
+
W(!1), f(!1);
|
|
119
|
+
},
|
|
120
|
+
onMouseDown: ne,
|
|
121
|
+
onMouseLeave: (e) => {
|
|
122
|
+
e.buttons !== 1 && (M && F && (p(!1), m(0)), i.current = null);
|
|
123
|
+
},
|
|
124
|
+
children: /* @__PURE__ */ r(pe, { $translateX: ce, $visibleSlides: k, $dragging: F, children: P.map(q) })
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
/* @__PURE__ */ r(
|
|
128
|
+
N,
|
|
129
|
+
{
|
|
130
|
+
onClick: x,
|
|
131
|
+
disabled: !l && n === s,
|
|
132
|
+
"aria-label": "Next slide",
|
|
133
|
+
$overlay: o,
|
|
134
|
+
$visible: B,
|
|
135
|
+
$arrowTop: A,
|
|
136
|
+
$viewportFocused: V,
|
|
137
|
+
children: /* @__PURE__ */ r(de, { size: 20, "aria-hidden": "true" })
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
w && /* @__PURE__ */ r(
|
|
141
|
+
ve,
|
|
142
|
+
{
|
|
143
|
+
onClick: () => f((e) => !e),
|
|
144
|
+
"aria-label": h ? "Play slideshow" : "Pause slideshow",
|
|
145
|
+
children: h ? /* @__PURE__ */ r($e, {}) : /* @__PURE__ */ r(be, {})
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
/* @__PURE__ */ X(
|
|
127
152
|
"div",
|
|
128
153
|
{
|
|
129
154
|
"aria-live": "polite",
|
|
@@ -140,25 +165,25 @@ const $ = 50, E = 2e3, oe = () => /* @__PURE__ */ b("svg", { width: 12, height:
|
|
|
140
165
|
"Slide ",
|
|
141
166
|
n + 1,
|
|
142
167
|
" of ",
|
|
143
|
-
|
|
168
|
+
O
|
|
144
169
|
]
|
|
145
170
|
}
|
|
146
171
|
),
|
|
147
|
-
|
|
148
|
-
!
|
|
149
|
-
|
|
172
|
+
w && G && /* @__PURE__ */ r(we, { $duration: C, $paused: h }, n),
|
|
173
|
+
!Y && /* @__PURE__ */ r(ge, { children: Array.from({ length: O }).map((e, t) => /* @__PURE__ */ r(
|
|
174
|
+
Me,
|
|
150
175
|
{
|
|
151
|
-
$active:
|
|
152
|
-
onClick: () =>
|
|
153
|
-
"aria-label": `Slide ${
|
|
154
|
-
"aria-current":
|
|
176
|
+
$active: t === n,
|
|
177
|
+
onClick: () => b(t),
|
|
178
|
+
"aria-label": `Slide ${t + 1} of ${O}`,
|
|
179
|
+
"aria-current": t === n ? "true" : void 0
|
|
155
180
|
},
|
|
156
|
-
|
|
181
|
+
t
|
|
157
182
|
)) })
|
|
158
183
|
]
|
|
159
184
|
}
|
|
160
185
|
);
|
|
161
186
|
};
|
|
162
187
|
export {
|
|
163
|
-
|
|
188
|
+
ke as default
|
|
164
189
|
};
|
|
@@ -23,7 +23,7 @@ const d = o.div`
|
|
|
23
23
|
display: flex;
|
|
24
24
|
width: 100%;
|
|
25
25
|
transform: translateX(${({ $translateX: e }) => e}%);
|
|
26
|
-
transition: transform 0.35s ease;
|
|
26
|
+
transition: ${({ $dragging: e }) => e ? "none" : "transform 0.35s ease"};
|
|
27
27
|
|
|
28
28
|
@media (prefers-reduced-motion: reduce) {
|
|
29
29
|
transition: none;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meticulous-ui",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A comprehensive React UI component library with a wide range of customizable components, icons, colors, and utilities for building modern web applications.",
|
|
6
6
|
"main": "./index.js",
|