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