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.
@@ -1,129 +1,154 @@
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 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: F,
12
- visibleSlides: g = 1,
11
+ renderCarousel: q,
12
+ visibleSlides: k = 1,
13
13
  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
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
- 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);
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 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));
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
- C(() => {
45
+ E(() => {
36
46
  if (o)
37
- return l.current = setTimeout(() => i(!1), E), () => clearTimeout(l.current);
38
- }, [o]), C(() => {
39
- if (!h || a) return;
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
- p((r) => r >= s ? 0 : r + 1);
42
- }, M * 1e3);
51
+ b((t) => t >= s ? 0 : t + 1);
52
+ }, C * 1e3);
43
53
  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,
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: B,
64
- onMouseEnter: H,
65
- onMouseLeave: U,
66
- onKeyDown: O,
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__ */ 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(
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
- I
168
+ O
144
169
  ]
145
170
  }
146
171
  ),
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,
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: r === n,
152
- onClick: () => p(r),
153
- "aria-label": `Slide ${r + 1} of ${I}`,
154
- "aria-current": r === n ? "true" : void 0
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
- r
181
+ t
157
182
  )) })
158
183
  ]
159
184
  }
160
185
  );
161
186
  };
162
187
  export {
163
- de as default
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.0",
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",