@athbnb/ui 0.0.2 → 0.0.3

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.
@@ -0,0 +1,232 @@
1
+ import { c as e } from "react/compiler-runtime";
2
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
+ import * as r from "react";
4
+ //#region src/ui/Slider.tsx
5
+ var i = 768, a = 1024;
6
+ function o() {
7
+ let t = e(2), [n, o] = r.useState(3), s, c;
8
+ return t[0] === Symbol.for("react.memo_cache_sentinel") ? (s = () => {
9
+ let e = () => {
10
+ let e = window.innerWidth;
11
+ o(e < i ? 1 : e < a ? 2 : 3);
12
+ };
13
+ return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
14
+ }, c = [], t[0] = s, t[1] = c) : (s = t[0], c = t[1]), r.useEffect(s, c), n;
15
+ }
16
+ function s(e) {
17
+ return e === 1 ? "100vw" : e === 2 ? "50vw" : "33.3333vw";
18
+ }
19
+ function c(n) {
20
+ let i = e(40), { children: a, className: c, autoPlay: l, intervalMs: u } = n, d = c === void 0 ? "" : c, f = l === void 0 ? !0 : l, p = u === void 0 ? 4e3 : u, m = o(), [h, g] = r.useState(0), [_, v] = r.useState(f), [y, b] = r.useState(0), [x, S] = r.useState(0), C, w;
21
+ i[0] === f ? (C = i[1], w = i[2]) : (C = () => {
22
+ v(f);
23
+ }, w = [f], i[0] = f, i[1] = C, i[2] = w), r.useEffect(C, w);
24
+ let T = r.Children.toArray(a).filter(r.isValidElement), E = T.length, D = Math.max(0, E - m), O = s(m), k, A;
25
+ i[3] !== h || i[4] !== D ? (k = () => {
26
+ h > D && g(0);
27
+ }, A = [h, D], i[3] = h, i[4] = D, i[5] = k, i[6] = A) : (k = i[5], A = i[6]), r.useEffect(k, A), r.useEffect(() => {
28
+ if (!_ || T.length === 0 || D === 0) return;
29
+ let e = window.setInterval(() => {
30
+ g((e) => {
31
+ let t = e + 1;
32
+ return t > D ? 0 : t;
33
+ });
34
+ }, p);
35
+ return () => window.clearInterval(e);
36
+ }, [
37
+ _,
38
+ D,
39
+ T.length,
40
+ p
41
+ ]);
42
+ let j;
43
+ i[7] === D ? j = i[8] : (j = () => {
44
+ g((e) => {
45
+ let t = e + 1;
46
+ return t > D ? 0 : t;
47
+ });
48
+ }, i[7] = D, i[8] = j);
49
+ let M = j, N;
50
+ i[9] === D ? N = i[10] : (N = () => {
51
+ g((e) => {
52
+ let t = e - 1;
53
+ return t < 0 ? D : t;
54
+ });
55
+ }, i[9] = D, i[10] = N);
56
+ let P = N, F;
57
+ i[11] === Symbol.for("react.memo_cache_sentinel") ? (F = (e) => {
58
+ b(e.targetTouches[0].clientX), v(!1);
59
+ }, i[11] = F) : F = i[11];
60
+ let I = F, L;
61
+ i[12] === Symbol.for("react.memo_cache_sentinel") ? (L = (e) => {
62
+ S(e.targetTouches[0].clientX);
63
+ }, i[12] = L) : L = i[12];
64
+ let R = L, z;
65
+ i[13] !== f || i[14] !== M || i[15] !== P || i[16] !== x || i[17] !== y ? (z = () => {
66
+ if (!y || !x) return;
67
+ let e = y - x;
68
+ e > 50 && M(), e < -50 && P(), b(0), S(0), window.setTimeout(() => v(f), 1e3);
69
+ }, i[13] = f, i[14] = M, i[15] = P, i[16] = x, i[17] = y, i[18] = z) : z = i[18];
70
+ let B = z, V;
71
+ i[19] !== f || i[20] !== M || i[21] !== P ? (V = (e) => {
72
+ let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left;
73
+ v(!1), n < t.width / 2 ? P() : M(), window.setTimeout(() => v(f), 1e3);
74
+ }, i[19] = f, i[20] = M, i[21] = P, i[22] = V) : V = i[22];
75
+ let H = V;
76
+ if (E === 0) return null;
77
+ if (E <= m) {
78
+ let e = `relative w-full py-16 md:py-[4.5rem] justify-center items-center overflow-hidden flex gap-8 ${d}`, n;
79
+ return i[23] === e ? n = i[24] : (n = e.trim(), i[23] = e, i[24] = n), /* @__PURE__ */ t("div", {
80
+ className: n,
81
+ children: /* @__PURE__ */ t("div", {
82
+ className: "flex w-full",
83
+ children: T.map((e, t) => r.cloneElement(e, {
84
+ key: t,
85
+ className: ["shrink-0", e.props.className].filter(Boolean).join(" "),
86
+ style: {
87
+ ...e.props.style ?? {},
88
+ width: O,
89
+ minWidth: O
90
+ }
91
+ }))
92
+ })
93
+ });
94
+ }
95
+ let U = `relative w-full py-16 md:py-[4.5rem] justify-center items-center overflow-hidden cursor-pointer ${d}`, W;
96
+ i[25] === U ? W = i[26] : (W = U.trim(), i[25] = U, i[26] = W);
97
+ let G = `translateX(-${100 / m * h}vw)`, K = `${T.length * 100 / m}vw`, q;
98
+ i[27] !== G || i[28] !== K ? (q = {
99
+ transform: G,
100
+ width: K
101
+ }, i[27] = G, i[28] = K, i[29] = q) : q = i[29];
102
+ let J = T.map((e, t) => r.cloneElement(e, {
103
+ key: t,
104
+ className: ["shrink-0", e.props.className].filter(Boolean).join(" "),
105
+ style: {
106
+ ...e.props.style ?? {},
107
+ width: O,
108
+ minWidth: O
109
+ }
110
+ })), Y;
111
+ i[30] !== q || i[31] !== J ? (Y = /* @__PURE__ */ t("div", {
112
+ className: "flex transition-transform duration-500 ease-in-out",
113
+ style: q,
114
+ children: J
115
+ }), i[30] = q, i[31] = J, i[32] = Y) : Y = i[32];
116
+ let X;
117
+ return i[33] !== H || i[34] !== B || i[35] !== R || i[36] !== I || i[37] !== W || i[38] !== Y ? (X = /* @__PURE__ */ t("div", {
118
+ className: W,
119
+ onClick: H,
120
+ onTouchStart: I,
121
+ onTouchMove: R,
122
+ onTouchEnd: B,
123
+ role: "region",
124
+ "aria-roledescription": "carousel",
125
+ children: Y
126
+ }), i[33] = H, i[34] = B, i[35] = R, i[36] = I, i[37] = W, i[38] = Y, i[39] = X) : X = i[39], X;
127
+ }
128
+ var l = 1024;
129
+ function u(t) {
130
+ let n = e(3), [i, a] = r.useState(typeof window < "u" ? window.innerWidth < t : !0), o, s;
131
+ return n[0] === t ? (o = n[1], s = n[2]) : (o = () => {
132
+ let e = () => a(window.innerWidth < t);
133
+ return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
134
+ }, s = [t], n[0] = t, n[1] = o, n[2] = s), r.useEffect(o, s), i;
135
+ }
136
+ function d(i) {
137
+ let a = e(36), { slides: o, className: s } = i, c = s === void 0 ? "" : s, d = r.useRef(null), f = u(l), [p, m] = r.useState(0), h;
138
+ a[0] === f ? h = a[1] : (h = () => {
139
+ if (!f || !d.current) return;
140
+ let e = d.current.scrollLeft, t = d.current.clientWidth;
141
+ m(Math.round(e / t));
142
+ }, a[0] = f, a[1] = h);
143
+ let g = h, _ = r.useRef(!1), v = r.useRef(0), y = r.useRef(0), b;
144
+ a[2] === f ? b = a[3] : (b = (e) => {
145
+ !f || !d.current || (_.current = !0, d.current.classList.add("cursor-grabbing"), v.current = e.pageX - d.current.offsetLeft, y.current = d.current.scrollLeft);
146
+ }, a[2] = f, a[3] = b);
147
+ let x = b, S;
148
+ a[4] === Symbol.for("react.memo_cache_sentinel") ? (S = () => {
149
+ _.current = !1, d.current?.classList.remove("cursor-grabbing");
150
+ }, a[4] = S) : S = a[4];
151
+ let C = S, w;
152
+ a[5] === f ? w = a[6] : (w = (e) => {
153
+ if (!f || !_.current || !d.current) return;
154
+ e.preventDefault();
155
+ let t = (e.pageX - d.current.offsetLeft - v.current) * 1.2;
156
+ d.current.scrollLeft = y.current - t;
157
+ }, a[5] = f, a[6] = w);
158
+ let T = w, E;
159
+ a[7] === c ? E = a[8] : (E = ["w-full", c].filter(Boolean), a[7] = c, a[8] = E);
160
+ let D = E.join(" "), O = f ? "cursor-grab" : "", k;
161
+ a[9] === O ? k = a[10] : (k = ["w-full overflow-x-auto no-scrollbar px-4 select-none", O].filter(Boolean), a[9] = O, a[10] = k);
162
+ let A = k.join(" "), j = f ? "x mandatory" : "none", M;
163
+ a[11] === j ? M = a[12] : (M = {
164
+ WebkitOverflowScrolling: "touch",
165
+ scrollSnapType: j,
166
+ scrollBehavior: "smooth"
167
+ }, a[11] = j, a[12] = M);
168
+ let N = f ? "flex transition-all duration-300" : "flex justify-center flex-wrap gap-6 transition-all duration-300", P;
169
+ if (a[13] !== f || a[14] !== o) {
170
+ let e;
171
+ a[16] === f ? e = a[17] : (e = (e, r) => /* @__PURE__ */ n("div", {
172
+ className: "shrink-0 rounded-2xl flex flex-col items-center pe-4 sm:pe-6",
173
+ style: {
174
+ width: f ? "100%" : "30%",
175
+ minWidth: f ? "100%" : "280px",
176
+ maxWidth: f ? "100%" : "450px",
177
+ height: "auto",
178
+ scrollSnapAlign: f ? "center" : "none"
179
+ },
180
+ children: [
181
+ /* @__PURE__ */ t("img", {
182
+ src: e.image,
183
+ alt: typeof e.imageAlt == "string" ? e.imageAlt : typeof e.title == "string" ? e.title : "Slide",
184
+ className: "rounded-xl w-full h-[180px] xs:h-[220px] sm:h-[260px] md:h-[300px] object-cover mb-3 sm:mb-4",
185
+ draggable: !1
186
+ }),
187
+ /* @__PURE__ */ t("div", {
188
+ className: "font-bold text-primary title-text mb-1 sm:mb-2 text-center px-2",
189
+ children: e.title
190
+ }),
191
+ /* @__PURE__ */ t("div", {
192
+ className: "text-secondary paragraph-text text-center px-2 pb-2",
193
+ children: e.description
194
+ })
195
+ ]
196
+ }, r), a[16] = f, a[17] = e), P = o.map(e), a[13] = f, a[14] = o, a[15] = P;
197
+ } else P = a[15];
198
+ let F;
199
+ a[18] !== N || a[19] !== P ? (F = /* @__PURE__ */ t("div", {
200
+ className: N,
201
+ children: P
202
+ }), a[18] = N, a[19] = P, a[20] = F) : F = a[20];
203
+ let I;
204
+ a[21] !== x || a[22] !== T || a[23] !== g || a[24] !== A || a[25] !== M || a[26] !== F ? (I = /* @__PURE__ */ t("div", {
205
+ ref: d,
206
+ className: A,
207
+ style: M,
208
+ onScroll: g,
209
+ onMouseDown: x,
210
+ onMouseLeave: C,
211
+ onMouseUp: C,
212
+ onMouseMove: T,
213
+ children: F
214
+ }), a[21] = x, a[22] = T, a[23] = g, a[24] = A, a[25] = M, a[26] = F, a[27] = I) : I = a[27];
215
+ let L;
216
+ a[28] !== p || a[29] !== f || a[30] !== o ? (L = f ? /* @__PURE__ */ t("div", {
217
+ className: "flex justify-center mt-3",
218
+ role: "tablist",
219
+ "aria-label": "Slides",
220
+ children: o.map((e, n) => /* @__PURE__ */ t("div", {
221
+ role: "presentation",
222
+ className: ["h-2 w-2 mx-1 rounded-full transition-all duration-300", p === n ? "bg-primary scale-125" : "bg-gray-400"].join(" ")
223
+ }, n))
224
+ }) : null, a[28] = p, a[29] = f, a[30] = o, a[31] = L) : L = a[31];
225
+ let R;
226
+ return a[32] !== I || a[33] !== L || a[34] !== D ? (R = /* @__PURE__ */ n("div", {
227
+ className: D,
228
+ children: [I, L]
229
+ }), a[32] = I, a[33] = L, a[34] = D, a[35] = R) : R = a[35], R;
230
+ }
231
+ //#endregion
232
+ export { c as Slider, d as SliderCards };
@@ -0,0 +1,70 @@
1
+ import { c as e } from "react/compiler-runtime";
2
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
+ //#region src/ui/Tabs.tsx
4
+ function r(e, n) {
5
+ return e ? /* @__PURE__ */ t(e, { className: n }) : null;
6
+ }
7
+ function i(i) {
8
+ let a = e(30), { items: o, activeId: s, onActiveIdChange: c, className: l, desktopNavClassName: u, mobileScrollClassName: d } = i, f = l === void 0 ? "" : l, p = u === void 0 ? "" : u, m = d === void 0 ? "" : d;
9
+ if (!o.length) return null;
10
+ let h;
11
+ a[0] === f ? h = a[1] : (h = f.trim() || void 0, a[0] = f, a[1] = h);
12
+ let g = `hidden lg:block space-y-1 ${p}`, _;
13
+ a[2] === g ? _ = a[3] : (_ = g.trim(), a[2] = g, a[3] = _);
14
+ let v;
15
+ if (a[4] !== s || a[5] !== o || a[6] !== c) {
16
+ let e;
17
+ a[8] !== s || a[9] !== c ? (e = (e) => {
18
+ let i = e.id === s;
19
+ return /* @__PURE__ */ n("button", {
20
+ type: "button",
21
+ role: "tab",
22
+ "aria-selected": i,
23
+ onClick: () => c(e.id),
24
+ className: "flex w-full cursor-pointer items-center gap-3 py-3 title-text",
25
+ children: [r(e.icon, "h-6 w-6 shrink-0 fill-primary text-primary"), /* @__PURE__ */ t("span", {
26
+ className: i ? "font-bold text-secondary" : "font-semibold text-secondary/80",
27
+ children: e.label
28
+ })]
29
+ }, e.id);
30
+ }, a[8] = s, a[9] = c, a[10] = e) : e = a[10], v = o.map(e), a[4] = s, a[5] = o, a[6] = c, a[7] = v;
31
+ } else v = a[7];
32
+ let y;
33
+ a[11] !== _ || a[12] !== v ? (y = /* @__PURE__ */ t("nav", {
34
+ className: _,
35
+ role: "tablist",
36
+ "aria-orientation": "vertical",
37
+ children: v
38
+ }), a[11] = _, a[12] = v, a[13] = y) : y = a[13];
39
+ let b = `flex gap-2 overflow-x-auto pb-2 no-scrollbar lg:hidden ${m}`, x;
40
+ a[14] === b ? x = a[15] : (x = b.trim(), a[14] = b, a[15] = x);
41
+ let S;
42
+ if (a[16] !== s || a[17] !== o || a[18] !== c) {
43
+ let e;
44
+ a[20] !== s || a[21] !== c ? (e = (e) => {
45
+ let t = e.id === s;
46
+ return /* @__PURE__ */ n("button", {
47
+ type: "button",
48
+ role: "tab",
49
+ "aria-selected": t,
50
+ onClick: () => c(e.id),
51
+ className: `title-text flex shrink-0 items-center gap-1 rounded-lg px-3 py-2 whitespace-nowrap ${t ? "bg-primary text-white" : "border border-primary text-secondary"}`.trim(),
52
+ children: [r(e.icon, t ? "h-4 w-4 shrink-0 fill-white text-white" : "h-4 w-4 shrink-0 fill-primary text-primary"), e.label]
53
+ }, e.id);
54
+ }, a[20] = s, a[21] = c, a[22] = e) : e = a[22], S = o.map(e), a[16] = s, a[17] = o, a[18] = c, a[19] = S;
55
+ } else S = a[19];
56
+ let C;
57
+ a[23] !== x || a[24] !== S ? (C = /* @__PURE__ */ t("div", {
58
+ className: x,
59
+ role: "tablist",
60
+ "aria-orientation": "horizontal",
61
+ children: S
62
+ }), a[23] = x, a[24] = S, a[25] = C) : C = a[25];
63
+ let w;
64
+ return a[26] !== C || a[27] !== h || a[28] !== y ? (w = /* @__PURE__ */ n("div", {
65
+ className: h,
66
+ children: [y, C]
67
+ }), a[26] = C, a[27] = h, a[28] = y, a[29] = w) : w = a[29], w;
68
+ }
69
+ //#endregion
70
+ export { i as Tabs };