@situaction/traq-ui-ste 1.2.16 → 1.2.17
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,15 +1,15 @@
|
|
|
1
|
-
import { jsxs as ae, jsx as
|
|
2
|
-
import
|
|
3
|
-
import '../../styles/Carousel.css';const
|
|
4
|
-
root:
|
|
5
|
-
viewport:
|
|
6
|
-
dragEnabled:
|
|
1
|
+
import { jsxs as ae, jsx as R, Fragment as De } from "react/jsx-runtime";
|
|
2
|
+
import We, { forwardRef as ze, useMemo as ie, useRef as l, useState as $, useCallback as i, useImperativeHandle as Ee, useEffect as Y } from "react";
|
|
3
|
+
import '../../styles/Carousel.css';const Fe = "_root_36mqp_6", Be = "_viewport_36mqp_11", $e = "_dragEnabled_36mqp_27", je = "_dragging_36mqp_32", Oe = "_slide_36mqp_39", Xe = "_navButton_36mqp_46", He = "_navPrev_36mqp_63", Ve = "_navNext_36mqp_67", d = {
|
|
4
|
+
root: Fe,
|
|
5
|
+
viewport: Be,
|
|
6
|
+
dragEnabled: $e,
|
|
7
7
|
dragging: je,
|
|
8
8
|
slide: Oe,
|
|
9
9
|
navButton: Xe,
|
|
10
10
|
navPrev: He,
|
|
11
11
|
navNext: Ve
|
|
12
|
-
}, C = (...M) => M.filter(Boolean).join(" "), Ye =
|
|
12
|
+
}, C = (...M) => M.filter(Boolean).join(" "), Ye = ze(
|
|
13
13
|
({
|
|
14
14
|
children: M,
|
|
15
15
|
className: ue,
|
|
@@ -17,56 +17,56 @@ import '../../styles/Carousel.css';const Be = "_root_1kths_1", $e = "_viewport_1
|
|
|
17
17
|
slideClassName: fe,
|
|
18
18
|
style: de,
|
|
19
19
|
slideSize: pe = "30%",
|
|
20
|
-
gap:
|
|
21
|
-
align:
|
|
22
|
-
showArrows:
|
|
23
|
-
dragEnabled:
|
|
20
|
+
gap: me = 12,
|
|
21
|
+
align: w = "center",
|
|
22
|
+
showArrows: ve = !0,
|
|
23
|
+
dragEnabled: y = !0,
|
|
24
24
|
snapOnRelease: G = !0,
|
|
25
|
-
keyboardNavigation:
|
|
26
|
-
step:
|
|
25
|
+
keyboardNavigation: we = !0,
|
|
26
|
+
step: ge = 1,
|
|
27
27
|
initialIndex: J = 0,
|
|
28
|
-
loop:
|
|
28
|
+
loop: N = !1,
|
|
29
29
|
ariaLabel: Q = "Carousel",
|
|
30
|
-
iconLeft:
|
|
30
|
+
iconLeft: he,
|
|
31
31
|
iconRight: xe,
|
|
32
32
|
onIndexChange: A
|
|
33
33
|
}, _e) => {
|
|
34
|
-
const
|
|
34
|
+
const g = ie(() => We.Children.toArray(M), [M]), s = g.length, c = N && s > 1, T = Math.max(1, Math.min(ge, Math.max(1, s))), p = c ? s : 0, h = ie(() => {
|
|
35
35
|
if (!c)
|
|
36
|
-
return
|
|
36
|
+
return g.map((n, o) => ({
|
|
37
37
|
key: `real-${o}`,
|
|
38
38
|
node: n,
|
|
39
39
|
realIndex: o,
|
|
40
40
|
isClone: !1
|
|
41
41
|
}));
|
|
42
|
-
const e =
|
|
42
|
+
const e = g.map((n, o) => ({
|
|
43
43
|
key: `clone-head-${o}`,
|
|
44
44
|
node: n,
|
|
45
45
|
realIndex: o,
|
|
46
46
|
isClone: !0
|
|
47
|
-
})), t =
|
|
47
|
+
})), t = g.map((n, o) => ({
|
|
48
48
|
key: `real-${o}`,
|
|
49
49
|
node: n,
|
|
50
50
|
realIndex: o,
|
|
51
51
|
isClone: !1
|
|
52
|
-
})), r =
|
|
52
|
+
})), r = g.map((n, o) => ({
|
|
53
53
|
key: `clone-tail-${o}`,
|
|
54
54
|
node: n,
|
|
55
55
|
realIndex: o,
|
|
56
56
|
isClone: !0
|
|
57
57
|
}));
|
|
58
58
|
return [...e, ...t, ...r];
|
|
59
|
-
}, [c,
|
|
59
|
+
}, [c, g]), j = h.length, a = l(null), x = l([]), [Le, Ie] = $(0), k = l(0), [be, Z] = $(!1), [Re, ee] = $(!1), _ = l(!1), te = l(0), O = l(0), X = l(!1), H = l(!1), [ye, re] = $(!1), m = i(
|
|
60
60
|
(e) => {
|
|
61
|
-
|
|
61
|
+
k.current = e, Ie(e), A == null || A(e);
|
|
62
62
|
},
|
|
63
63
|
[A]
|
|
64
64
|
), ne = i((e) => {
|
|
65
65
|
const t = a.current;
|
|
66
66
|
t && (t.style.scrollSnapType = e ? "x mandatory" : "none", t.style.scrollBehavior = e ? "smooth" : "auto");
|
|
67
67
|
}, []), P = i(
|
|
68
|
-
(e, t) =>
|
|
69
|
-
[
|
|
68
|
+
(e, t) => w === "center" ? t.offsetLeft - (e.clientWidth - t.offsetWidth) / 2 : t.offsetLeft,
|
|
69
|
+
[w]
|
|
70
70
|
), L = i(
|
|
71
71
|
(e, t = "smooth") => {
|
|
72
72
|
const r = a.current, n = x.current[e];
|
|
@@ -75,37 +75,37 @@ import '../../styles/Carousel.css';const Be = "_root_1kths_1", $e = "_viewport_1
|
|
|
75
75
|
r.scrollTo({ left: o, behavior: t });
|
|
76
76
|
},
|
|
77
77
|
[P]
|
|
78
|
+
), q = i(
|
|
79
|
+
(e) => s === 0 ? 0 : N ? (e % s + s) % s : Math.max(0, Math.min(s - 1, e)),
|
|
80
|
+
[N, s]
|
|
78
81
|
), D = i(
|
|
79
|
-
(e) => s === 0 ? 0 : y ? (e % s + s) % s : Math.max(0, Math.min(s - 1, e)),
|
|
80
|
-
[y, s]
|
|
81
|
-
), W = i(
|
|
82
82
|
(e) => c ? p + e : e,
|
|
83
83
|
[c, p]
|
|
84
|
-
),
|
|
84
|
+
), I = i(
|
|
85
85
|
(e, t = "smooth") => {
|
|
86
|
-
const r =
|
|
87
|
-
L(n, t),
|
|
86
|
+
const r = q(e), n = D(r);
|
|
87
|
+
L(n, t), m(r);
|
|
88
88
|
},
|
|
89
|
-
[
|
|
90
|
-
),
|
|
89
|
+
[q, D, L, m]
|
|
90
|
+
), W = i(() => {
|
|
91
91
|
const e = a.current;
|
|
92
92
|
if (!e || j === 0) return 0;
|
|
93
|
-
const t = e.scrollLeft, r =
|
|
93
|
+
const t = e.scrollLeft, r = w === "center" ? t + e.clientWidth / 2 : t;
|
|
94
94
|
let n = 0, o = Number.POSITIVE_INFINITY;
|
|
95
95
|
for (let f = 0; f < j; f++) {
|
|
96
96
|
const u = x.current[f];
|
|
97
97
|
if (!u) continue;
|
|
98
|
-
const
|
|
99
|
-
|
|
98
|
+
const v = w === "center" ? u.offsetLeft + u.offsetWidth / 2 : u.offsetLeft, B = Math.abs(v - r);
|
|
99
|
+
B < o && (o = B, n = f);
|
|
100
100
|
}
|
|
101
101
|
return n;
|
|
102
|
-
}, [
|
|
102
|
+
}, [w, j]), z = i(
|
|
103
103
|
(e) => c ? e < p ? e + s : e >= p + s ? e - s : e : e,
|
|
104
104
|
[c, p, s]
|
|
105
105
|
), oe = l({
|
|
106
106
|
middleStart: 0,
|
|
107
107
|
groupWidth: 0
|
|
108
|
-
}),
|
|
108
|
+
}), b = i(() => {
|
|
109
109
|
if (!c) return;
|
|
110
110
|
const e = a.current;
|
|
111
111
|
if (!e) return;
|
|
@@ -124,12 +124,12 @@ import '../../styles/Carousel.css';const Be = "_root_1kths_1", $e = "_viewport_1
|
|
|
124
124
|
const { middleStart: r, groupWidth: n } = oe.current;
|
|
125
125
|
if (n <= 0) return;
|
|
126
126
|
const o = r, f = r + n;
|
|
127
|
-
let u = t.scrollLeft,
|
|
128
|
-
u < o ?
|
|
127
|
+
let u = t.scrollLeft, v = 0;
|
|
128
|
+
u < o ? v = Math.ceil((o - u) / n) * n : u > f && (v = -Math.ceil((u - f) / n) * n), v !== 0 && (V.current = !0, t.scrollLeft = u + v, e === "drag" && (O.current += v), V.current = !1);
|
|
129
129
|
},
|
|
130
130
|
[c]
|
|
131
131
|
), S = i(() => {
|
|
132
|
-
if (
|
|
132
|
+
if (N) {
|
|
133
133
|
Z(s > 1), ee(s > 1);
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
@@ -137,73 +137,73 @@ import '../../styles/Carousel.css';const Be = "_root_1kths_1", $e = "_viewport_1
|
|
|
137
137
|
if (!e) return;
|
|
138
138
|
const t = e.scrollWidth - e.clientWidth, r = 1;
|
|
139
139
|
Z(t > r && e.scrollLeft > r), ee(t > r && e.scrollLeft < t - r);
|
|
140
|
-
}, [
|
|
141
|
-
s <= 1 ||
|
|
142
|
-
}, [
|
|
143
|
-
s <= 1 ||
|
|
144
|
-
}, [
|
|
140
|
+
}, [N, s]), E = i(() => {
|
|
141
|
+
s <= 1 || I(k.current + T);
|
|
142
|
+
}, [I, s, T]), F = i(() => {
|
|
143
|
+
s <= 1 || I(k.current - T);
|
|
144
|
+
}, [I, s, T]), Ne = i(() => {
|
|
145
145
|
var n;
|
|
146
146
|
if (!G) return;
|
|
147
|
-
const e =
|
|
147
|
+
const e = W(), t = z(e);
|
|
148
148
|
L(t, "smooth");
|
|
149
|
-
const r = ((n =
|
|
150
|
-
|
|
149
|
+
const r = ((n = h[t]) == null ? void 0 : n.realIndex) ?? 0;
|
|
150
|
+
m(r);
|
|
151
151
|
}, [
|
|
152
152
|
G,
|
|
153
|
+
W,
|
|
153
154
|
z,
|
|
154
|
-
E,
|
|
155
155
|
L,
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
h,
|
|
157
|
+
m
|
|
158
158
|
]);
|
|
159
|
-
|
|
159
|
+
Ee(
|
|
160
160
|
_e,
|
|
161
161
|
() => ({
|
|
162
|
-
next:
|
|
163
|
-
prev:
|
|
164
|
-
goTo:
|
|
165
|
-
getIndex: () =>
|
|
162
|
+
next: E,
|
|
163
|
+
prev: F,
|
|
164
|
+
goTo: I,
|
|
165
|
+
getIndex: () => k.current,
|
|
166
166
|
getLength: () => s
|
|
167
167
|
}),
|
|
168
|
-
[
|
|
168
|
+
[I, E, F, s]
|
|
169
169
|
), Y(() => {
|
|
170
170
|
if (s === 0) return;
|
|
171
|
-
const e =
|
|
172
|
-
|
|
171
|
+
const e = q(J), t = D(e), r = window.requestAnimationFrame(() => {
|
|
172
|
+
b(), L(t, "auto"), m(e), S();
|
|
173
173
|
});
|
|
174
174
|
return () => window.cancelAnimationFrame(r);
|
|
175
175
|
}, [
|
|
176
176
|
s,
|
|
177
177
|
J,
|
|
178
|
+
q,
|
|
178
179
|
D,
|
|
179
|
-
W,
|
|
180
180
|
L,
|
|
181
|
-
|
|
181
|
+
m,
|
|
182
182
|
S,
|
|
183
|
-
|
|
183
|
+
b
|
|
184
184
|
]), Y(() => {
|
|
185
185
|
if (!c) return;
|
|
186
186
|
const e = a.current;
|
|
187
187
|
if (!e) return;
|
|
188
188
|
const t = typeof ResizeObserver < "u" ? new ResizeObserver(() => {
|
|
189
|
-
|
|
189
|
+
b();
|
|
190
190
|
}) : null;
|
|
191
191
|
t == null || t.observe(e), x.current.forEach((o) => o && (t == null ? void 0 : t.observe(o)));
|
|
192
|
-
const r = () =>
|
|
192
|
+
const r = () => b();
|
|
193
193
|
window.addEventListener("resize", r);
|
|
194
|
-
const n = window.requestAnimationFrame(() =>
|
|
194
|
+
const n = window.requestAnimationFrame(() => b());
|
|
195
195
|
return () => {
|
|
196
196
|
window.removeEventListener("resize", r), window.cancelAnimationFrame(n), t == null || t.disconnect();
|
|
197
197
|
};
|
|
198
|
-
}, [c,
|
|
198
|
+
}, [c, b]), Y(() => {
|
|
199
199
|
const e = a.current;
|
|
200
200
|
if (!e) return;
|
|
201
201
|
const t = { current: 0 }, r = () => {
|
|
202
202
|
V.current || (c && !_.current && K("scroll"), S(), !t.current && (t.current = window.requestAnimationFrame(() => {
|
|
203
203
|
var u;
|
|
204
204
|
t.current = 0;
|
|
205
|
-
const n =
|
|
206
|
-
f !==
|
|
205
|
+
const n = W(), o = z(n), f = ((u = h[o]) == null ? void 0 : u.realIndex) ?? 0;
|
|
206
|
+
f !== k.current && m(f);
|
|
207
207
|
})));
|
|
208
208
|
};
|
|
209
209
|
return e.addEventListener("scroll", r, { passive: !0 }), () => {
|
|
@@ -213,18 +213,18 @@ import '../../styles/Carousel.css';const Be = "_root_1kths_1", $e = "_viewport_1
|
|
|
213
213
|
c,
|
|
214
214
|
K,
|
|
215
215
|
S,
|
|
216
|
+
W,
|
|
216
217
|
z,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
v
|
|
218
|
+
h,
|
|
219
|
+
m
|
|
220
220
|
]);
|
|
221
|
-
const
|
|
221
|
+
const ke = (e) => e instanceof HTMLElement ? !!e.closest(
|
|
222
222
|
'button, a, input, textarea, select, option, [role="button"], [data-carousel-no-drag="true"]'
|
|
223
223
|
) : !1, U = l(null), se = l(0), Pe = (e) => {
|
|
224
224
|
var t, r, n, o;
|
|
225
|
-
|
|
225
|
+
y && a.current && (ke(e.target) || e.pointerType === "mouse" && e.button !== 0 || (e.preventDefault(), ne(!1), _.current = !0, X.current = !1, te.current = e.clientX, O.current = a.current.scrollLeft, re(!0), (r = (t = a.current).focus) == null || r.call(t), (o = (n = a.current).setPointerCapture) == null || o.call(n, e.pointerId)));
|
|
226
226
|
}, Se = (e) => {
|
|
227
|
-
if (!
|
|
227
|
+
if (!y || !_.current || (e.preventDefault(), !a.current)) return;
|
|
228
228
|
const r = e.clientX - te.current;
|
|
229
229
|
Math.abs(r) > 4 && (X.current = !0);
|
|
230
230
|
const n = O.current - r;
|
|
@@ -243,54 +243,52 @@ import '../../styles/Carousel.css';const Be = "_root_1kths_1", $e = "_viewport_1
|
|
|
243
243
|
}
|
|
244
244
|
X.current && (H.current = !0, window.setTimeout(() => {
|
|
245
245
|
H.current = !1;
|
|
246
|
-
}, 0)), ne(!0),
|
|
246
|
+
}, 0)), ne(!0), Ne(), S();
|
|
247
247
|
}, Ce = (e) => {
|
|
248
|
-
|
|
248
|
+
y && _.current && ce(e.pointerId);
|
|
249
249
|
}, Me = (e) => {
|
|
250
|
-
|
|
250
|
+
y && _.current && ce(e.pointerId);
|
|
251
251
|
}, Ae = (e) => {
|
|
252
252
|
H.current && (e.preventDefault(), e.stopPropagation());
|
|
253
253
|
}, Te = (e) => {
|
|
254
|
-
|
|
255
|
-
},
|
|
254
|
+
we && (e.key === "ArrowLeft" ? (e.preventDefault(), F()) : e.key === "ArrowRight" && (e.preventDefault(), E()));
|
|
255
|
+
}, qe = {
|
|
256
256
|
...de ?? {},
|
|
257
|
-
"--carousel-gap": `${
|
|
257
|
+
"--carousel-gap": `${me}px`,
|
|
258
258
|
"--carousel-slide-size": pe,
|
|
259
|
-
"--carousel-snap-align":
|
|
259
|
+
"--carousel-snap-align": w
|
|
260
260
|
};
|
|
261
|
-
return /* @__PURE__ */ ae("div", { className: C(d.root, ue), style:
|
|
262
|
-
|
|
263
|
-
/* @__PURE__ */
|
|
261
|
+
return /* @__PURE__ */ ae("div", { className: C(d.root, ue), style: qe, "aria-label": Q, children: [
|
|
262
|
+
ve && s > 1 && /* @__PURE__ */ ae(De, { children: [
|
|
263
|
+
be && /* @__PURE__ */ R(
|
|
264
264
|
"button",
|
|
265
265
|
{
|
|
266
266
|
type: "button",
|
|
267
267
|
className: C(d.navButton, d.navPrev),
|
|
268
|
-
onClick:
|
|
269
|
-
disabled: !ke,
|
|
268
|
+
onClick: F,
|
|
270
269
|
"aria-label": "Précédent",
|
|
271
|
-
children:
|
|
270
|
+
children: he ?? /* @__PURE__ */ R("span", { "aria-hidden": !0, children: "‹" })
|
|
272
271
|
}
|
|
273
272
|
),
|
|
274
|
-
/* @__PURE__ */
|
|
273
|
+
Re && /* @__PURE__ */ R(
|
|
275
274
|
"button",
|
|
276
275
|
{
|
|
277
276
|
type: "button",
|
|
278
277
|
className: C(d.navButton, d.navNext),
|
|
279
|
-
onClick:
|
|
280
|
-
disabled: !Ie,
|
|
278
|
+
onClick: E,
|
|
281
279
|
"aria-label": "Suivant",
|
|
282
|
-
children: xe ?? /* @__PURE__ */
|
|
280
|
+
children: xe ?? /* @__PURE__ */ R("span", { "aria-hidden": !0, children: "›" })
|
|
283
281
|
}
|
|
284
282
|
)
|
|
285
283
|
] }),
|
|
286
|
-
/* @__PURE__ */
|
|
284
|
+
/* @__PURE__ */ R(
|
|
287
285
|
"div",
|
|
288
286
|
{
|
|
289
287
|
ref: a,
|
|
290
288
|
className: C(
|
|
291
289
|
d.viewport,
|
|
292
|
-
|
|
293
|
-
|
|
290
|
+
y && d.dragEnabled,
|
|
291
|
+
ye && d.dragging,
|
|
294
292
|
le
|
|
295
293
|
),
|
|
296
294
|
tabIndex: 0,
|
|
@@ -303,7 +301,7 @@ import '../../styles/Carousel.css';const Be = "_root_1kths_1", $e = "_viewport_1
|
|
|
303
301
|
onPointerUp: Ce,
|
|
304
302
|
onPointerCancel: Me,
|
|
305
303
|
onClickCapture: Ae,
|
|
306
|
-
children:
|
|
304
|
+
children: h.map((e, t) => /* @__PURE__ */ R(
|
|
307
305
|
"div",
|
|
308
306
|
{
|
|
309
307
|
ref: (r) => {
|
package/dist/styles/Carousel.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._root_36mqp_6{position:relative;width:100%}._viewport_36mqp_11{display:flex;gap:var(--carousel-gap, 12px);overflow-x:auto;overflow-y:hidden;scroll-snap-type:x mandatory;scroll-behavior:smooth;-webkit-overflow-scrolling:touch;padding:4px;scrollbar-width:none}._viewport_36mqp_11::-webkit-scrollbar{display:none}._dragEnabled_36mqp_27{cursor:grab;touch-action:pan-y}._dragging_36mqp_32{cursor:grabbing;scroll-behavior:auto;scroll-snap-type:none;-webkit-user-select:none;user-select:none}._slide_36mqp_39{flex:0 0 var(--carousel-slide-size, 280px);width:var(--carousel-slide-size, 280px);scroll-snap-align:var(--carousel-snap-align, start);min-width:0}._navButton_36mqp_46{position:absolute;top:50%;transform:translateY(-50%);z-index:2;padding:.375rem;border:.75px solid var(--button-tertiary-default-border);border-radius:999px;display:flex;align-items:center;justify-content:center;background:var(--background-primary);box-shadow:0 2px 8px #00000026;cursor:pointer;-webkit-user-select:none;user-select:none}._navPrev_36mqp_63{left:8px}._navNext_36mqp_67{right:8px}
|