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