@situaction/traq-ui-ste 1.2.17 → 1.2.18

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,108 +1,110 @@
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
- dragging: je,
8
- slide: Oe,
9
- navButton: Xe,
10
- navPrev: He,
11
- navNext: Ve
12
- }, C = (...M) => M.filter(Boolean).join(" "), Ye = ze(
1
+ import { jsxs as ie, jsx as R, Fragment as We } from "react/jsx-runtime";
2
+ import ze, { forwardRef as Ee, useMemo as ue, useRef as l, useState as $, useEffect as j, useCallback as i, useImperativeHandle as Fe } from "react";
3
+ import '../../styles/Carousel.css';const Be = "_root_36mqp_6", $e = "_viewport_36mqp_11", je = "_dragEnabled_36mqp_27", Oe = "_dragging_36mqp_32", Xe = "_slide_36mqp_39", He = "_navButton_36mqp_46", Ve = "_navPrev_36mqp_63", Ke = "_navNext_36mqp_67", d = {
4
+ root: Be,
5
+ viewport: $e,
6
+ dragEnabled: je,
7
+ dragging: Oe,
8
+ slide: Xe,
9
+ navButton: He,
10
+ navPrev: Ve,
11
+ navNext: Ke
12
+ }, S = (...M) => M.filter(Boolean).join(" "), Ge = Ee(
13
13
  ({
14
14
  children: M,
15
- className: ue,
16
- viewportClassName: le,
17
- slideClassName: fe,
18
- style: de,
19
- slideSize: pe = "30%",
20
- gap: me = 12,
21
- align: w = "center",
22
- showArrows: ve = !0,
15
+ className: le,
16
+ viewportClassName: fe,
17
+ slideClassName: de,
18
+ style: pe,
19
+ slideSize: me = "30%",
20
+ gap: ve = 12,
21
+ align: g = "center",
22
+ showArrows: ge = !0,
23
23
  dragEnabled: y = !0,
24
- snapOnRelease: G = !0,
24
+ snapOnRelease: J = !0,
25
25
  keyboardNavigation: we = !0,
26
- step: ge = 1,
27
- initialIndex: J = 0,
26
+ step: he = 1,
27
+ initialIndex: Q = 0,
28
28
  loop: N = !1,
29
- ariaLabel: Q = "Carousel",
30
- iconLeft: he,
31
- iconRight: xe,
32
- onIndexChange: A
29
+ ariaLabel: Z = "Carousel",
30
+ iconLeft: xe,
31
+ iconRight: Ie,
32
+ onIndexChange: O
33
33
  }, _e) => {
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(() => {
34
+ const w = ue(() => ze.Children.toArray(M), [M]), s = w.length, c = N && s > 1, A = Math.max(1, Math.min(he, Math.max(1, s))), p = c ? s : 0, h = ue(() => {
35
35
  if (!c)
36
- return g.map((n, o) => ({
36
+ return w.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 = g.map((n, o) => ({
42
+ const e = w.map((n, o) => ({
43
43
  key: `clone-head-${o}`,
44
44
  node: n,
45
45
  realIndex: o,
46
46
  isClone: !0
47
- })), t = g.map((n, o) => ({
47
+ })), t = w.map((n, o) => ({
48
48
  key: `real-${o}`,
49
49
  node: n,
50
50
  realIndex: o,
51
51
  isClone: !1
52
- })), r = g.map((n, o) => ({
52
+ })), r = w.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, 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
- (e) => {
61
- k.current = e, Ie(e), A == null || A(e);
62
- },
63
- [A]
64
- ), ne = i((e) => {
59
+ }, [c, w]), X = h.length, a = l(null), x = l([]), [Le, be] = $(0), k = l(0), [Re, ee] = $(!1), [ye, te] = $(!1), I = l(!1), re = l(0), H = l(0), V = l(!1), K = l(!1), [Ne, ne] = $(!1), T = l(O);
60
+ j(() => {
61
+ T.current = O;
62
+ }, [O]);
63
+ const m = i((e) => {
64
+ var t;
65
+ k.current = e, be(e), (t = T.current) == null || t.call(T, e);
66
+ }, []), oe = i((e) => {
65
67
  const t = a.current;
66
68
  t && (t.style.scrollSnapType = e ? "x mandatory" : "none", t.style.scrollBehavior = e ? "smooth" : "auto");
67
- }, []), P = i(
68
- (e, t) => w === "center" ? t.offsetLeft - (e.clientWidth - t.offsetWidth) / 2 : t.offsetLeft,
69
- [w]
70
- ), L = i(
69
+ }, []), C = i(
70
+ (e, t) => g === "center" ? t.offsetLeft - (e.clientWidth - t.offsetWidth) / 2 : t.offsetLeft,
71
+ [g]
72
+ ), _ = i(
71
73
  (e, t = "smooth") => {
72
74
  const r = a.current, n = x.current[e];
73
75
  if (!r || !n) return;
74
- const o = P(r, n);
76
+ const o = C(r, n);
75
77
  r.scrollTo({ left: o, behavior: t });
76
78
  },
77
- [P]
79
+ [C]
78
80
  ), q = i(
79
81
  (e) => s === 0 ? 0 : N ? (e % s + s) % s : Math.max(0, Math.min(s - 1, e)),
80
82
  [N, s]
81
83
  ), D = i(
82
84
  (e) => c ? p + e : e,
83
85
  [c, p]
84
- ), I = i(
86
+ ), L = i(
85
87
  (e, t = "smooth") => {
86
88
  const r = q(e), n = D(r);
87
- L(n, t), m(r);
89
+ _(n, t), m(r);
88
90
  },
89
- [q, D, L, m]
91
+ [q, D, _, m]
90
92
  ), W = i(() => {
91
93
  const e = a.current;
92
- if (!e || j === 0) return 0;
93
- const t = e.scrollLeft, r = w === "center" ? t + e.clientWidth / 2 : t;
94
+ if (!e || X === 0) return 0;
95
+ const t = e.scrollLeft, r = g === "center" ? t + e.clientWidth / 2 : t;
94
96
  let n = 0, o = Number.POSITIVE_INFINITY;
95
- for (let f = 0; f < j; f++) {
97
+ for (let f = 0; f < X; f++) {
96
98
  const u = x.current[f];
97
99
  if (!u) continue;
98
- const v = w === "center" ? u.offsetLeft + u.offsetWidth / 2 : u.offsetLeft, B = Math.abs(v - r);
100
+ const v = g === "center" ? u.offsetLeft + u.offsetWidth / 2 : u.offsetLeft, B = Math.abs(v - r);
99
101
  B < o && (o = B, n = f);
100
102
  }
101
103
  return n;
102
- }, [w, j]), z = i(
104
+ }, [g, X]), z = i(
103
105
  (e) => c ? e < p ? e + s : e >= p + s ? e - s : e : e,
104
106
  [c, p, s]
105
- ), oe = l({
107
+ ), se = l({
106
108
  middleStart: 0,
107
109
  groupWidth: 0
108
110
  }), b = i(() => {
@@ -111,77 +113,77 @@ import '../../styles/Carousel.css';const Fe = "_root_36mqp_6", Be = "_viewport_3
111
113
  if (!e) return;
112
114
  const t = x.current[p], r = x.current[p + s];
113
115
  if (!t || !r) return;
114
- const n = P(e, t), o = P(e, r);
115
- oe.current = {
116
+ const n = C(e, t), o = C(e, r);
117
+ se.current = {
116
118
  middleStart: n,
117
119
  groupWidth: o - n
118
120
  };
119
- }, [c, p, s, P]), V = l(!1), K = i(
121
+ }, [c, p, s, C]), U = l(!1), Y = i(
120
122
  (e) => {
121
123
  if (!c) return;
122
124
  const t = a.current;
123
125
  if (!t) return;
124
- const { middleStart: r, groupWidth: n } = oe.current;
126
+ const { middleStart: r, groupWidth: n } = se.current;
125
127
  if (n <= 0) return;
126
128
  const o = r, f = r + n;
127
129
  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);
130
+ u < o ? v = Math.ceil((o - u) / n) * n : u > f && (v = -Math.ceil((u - f) / n) * n), v !== 0 && (U.current = !0, t.scrollLeft = u + v, e === "drag" && (H.current += v), U.current = !1);
129
131
  },
130
132
  [c]
131
- ), S = i(() => {
133
+ ), P = i(() => {
132
134
  if (N) {
133
- Z(s > 1), ee(s > 1);
135
+ ee(s > 1), te(s > 1);
134
136
  return;
135
137
  }
136
138
  const e = a.current;
137
139
  if (!e) return;
138
140
  const t = e.scrollWidth - e.clientWidth, r = 1;
139
- Z(t > r && e.scrollLeft > r), ee(t > r && e.scrollLeft < t - r);
141
+ ee(t > r && e.scrollLeft > r), te(t > r && e.scrollLeft < t - r);
140
142
  }, [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(() => {
143
+ s <= 1 || L(k.current + A);
144
+ }, [L, s, A]), F = i(() => {
145
+ s <= 1 || L(k.current - A);
146
+ }, [L, s, A]), ke = i(() => {
145
147
  var n;
146
- if (!G) return;
148
+ if (!J) return;
147
149
  const e = W(), t = z(e);
148
- L(t, "smooth");
150
+ _(t, "smooth");
149
151
  const r = ((n = h[t]) == null ? void 0 : n.realIndex) ?? 0;
150
152
  m(r);
151
153
  }, [
152
- G,
154
+ J,
153
155
  W,
154
156
  z,
155
- L,
157
+ _,
156
158
  h,
157
159
  m
158
160
  ]);
159
- Ee(
161
+ Fe(
160
162
  _e,
161
163
  () => ({
162
164
  next: E,
163
165
  prev: F,
164
- goTo: I,
166
+ goTo: L,
165
167
  getIndex: () => k.current,
166
168
  getLength: () => s
167
169
  }),
168
- [I, E, F, s]
169
- ), Y(() => {
170
+ [L, E, F, s]
171
+ ), j(() => {
170
172
  if (s === 0) return;
171
- const e = q(J), t = D(e), r = window.requestAnimationFrame(() => {
172
- b(), L(t, "auto"), m(e), S();
173
+ const e = q(Q), t = D(e), r = window.requestAnimationFrame(() => {
174
+ b(), _(t, "auto"), m(e), P();
173
175
  });
174
176
  return () => window.cancelAnimationFrame(r);
175
177
  }, [
176
178
  s,
177
- J,
179
+ Q,
178
180
  q,
179
181
  D,
180
- L,
182
+ _,
181
183
  m,
182
- S,
184
+ P,
183
185
  b
184
- ]), Y(() => {
186
+ ]), j(() => {
185
187
  if (!c) return;
186
188
  const e = a.current;
187
189
  if (!e) return;
@@ -195,11 +197,11 @@ import '../../styles/Carousel.css';const Fe = "_root_36mqp_6", Be = "_viewport_3
195
197
  return () => {
196
198
  window.removeEventListener("resize", r), window.cancelAnimationFrame(n), t == null || t.disconnect();
197
199
  };
198
- }, [c, b]), Y(() => {
200
+ }, [c, b]), j(() => {
199
201
  const e = a.current;
200
202
  if (!e) return;
201
203
  const t = { current: 0 }, r = () => {
202
- V.current || (c && !_.current && K("scroll"), S(), !t.current && (t.current = window.requestAnimationFrame(() => {
204
+ U.current || (c && !I.current && Y("scroll"), P(), !t.current && (t.current = window.requestAnimationFrame(() => {
203
205
  var u;
204
206
  t.current = 0;
205
207
  const n = W(), o = z(n), f = ((u = h[o]) == null ? void 0 : u.realIndex) ?? 0;
@@ -211,73 +213,73 @@ import '../../styles/Carousel.css';const Fe = "_root_36mqp_6", Be = "_viewport_3
211
213
  };
212
214
  }, [
213
215
  c,
214
- K,
215
- S,
216
+ Y,
217
+ P,
216
218
  W,
217
219
  z,
218
220
  h,
219
221
  m
220
222
  ]);
221
- const ke = (e) => e instanceof HTMLElement ? !!e.closest(
223
+ const Ce = (e) => e instanceof HTMLElement ? !!e.closest(
222
224
  'button, a, input, textarea, select, option, [role="button"], [data-carousel-no-drag="true"]'
223
- ) : !1, U = l(null), se = l(0), Pe = (e) => {
225
+ ) : !1, G = l(null), ce = l(0), Pe = (e) => {
224
226
  var t, r, n, o;
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)));
227
+ y && a.current && (Ce(e.target) || e.pointerType === "mouse" && e.button !== 0 || (e.preventDefault(), oe(!1), I.current = !0, V.current = !1, re.current = e.clientX, H.current = a.current.scrollLeft, ne(!0), (r = (t = a.current).focus) == null || r.call(t), (o = (n = a.current).setPointerCapture) == null || o.call(n, e.pointerId)));
226
228
  }, Se = (e) => {
227
- if (!y || !_.current || (e.preventDefault(), !a.current)) return;
228
- const r = e.clientX - te.current;
229
- Math.abs(r) > 4 && (X.current = !0);
230
- const n = O.current - r;
231
- se.current = n, U.current == null && (U.current = window.requestAnimationFrame(() => {
232
- U.current = null;
229
+ if (!y || !I.current || (e.preventDefault(), !a.current)) return;
230
+ const r = e.clientX - re.current;
231
+ Math.abs(r) > 4 && (V.current = !0);
232
+ const n = H.current - r;
233
+ ce.current = n, G.current == null && (G.current = window.requestAnimationFrame(() => {
234
+ G.current = null;
233
235
  const o = a.current;
234
- o && (o.scrollLeft = se.current, c && K("drag"));
236
+ o && (o.scrollLeft = ce.current, c && Y("drag"));
235
237
  }));
236
- }, ce = (e) => {
238
+ }, ae = (e) => {
237
239
  var r;
238
240
  const t = a.current;
239
- if (_.current = !1, re(!1), t && e != null)
241
+ if (I.current = !1, ne(!1), t && e != null)
240
242
  try {
241
243
  (r = t.releasePointerCapture) == null || r.call(t, e);
242
244
  } catch {
243
245
  }
244
- X.current && (H.current = !0, window.setTimeout(() => {
245
- H.current = !1;
246
- }, 0)), ne(!0), Ne(), S();
247
- }, Ce = (e) => {
248
- y && _.current && ce(e.pointerId);
246
+ V.current && (K.current = !0, window.setTimeout(() => {
247
+ K.current = !1;
248
+ }, 0)), oe(!0), ke(), P();
249
249
  }, Me = (e) => {
250
- y && _.current && ce(e.pointerId);
250
+ y && I.current && ae(e.pointerId);
251
251
  }, Ae = (e) => {
252
- H.current && (e.preventDefault(), e.stopPropagation());
252
+ y && I.current && ae(e.pointerId);
253
253
  }, Te = (e) => {
254
+ K.current && (e.preventDefault(), e.stopPropagation());
255
+ }, qe = (e) => {
254
256
  we && (e.key === "ArrowLeft" ? (e.preventDefault(), F()) : e.key === "ArrowRight" && (e.preventDefault(), E()));
255
- }, qe = {
256
- ...de ?? {},
257
- "--carousel-gap": `${me}px`,
258
- "--carousel-slide-size": pe,
259
- "--carousel-snap-align": w
257
+ }, De = {
258
+ ...pe ?? {},
259
+ "--carousel-gap": `${ve}px`,
260
+ "--carousel-slide-size": me,
261
+ "--carousel-snap-align": g
260
262
  };
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(
263
+ return /* @__PURE__ */ ie("div", { className: S(d.root, le), style: De, "aria-label": Z, children: [
264
+ ge && s > 1 && /* @__PURE__ */ ie(We, { children: [
265
+ Re && /* @__PURE__ */ R(
264
266
  "button",
265
267
  {
266
268
  type: "button",
267
- className: C(d.navButton, d.navPrev),
269
+ className: S(d.navButton, d.navPrev),
268
270
  onClick: F,
269
271
  "aria-label": "Précédent",
270
- children: he ?? /* @__PURE__ */ R("span", { "aria-hidden": !0, children: "‹" })
272
+ children: xe ?? /* @__PURE__ */ R("span", { "aria-hidden": !0, children: "‹" })
271
273
  }
272
274
  ),
273
- Re && /* @__PURE__ */ R(
275
+ ye && /* @__PURE__ */ R(
274
276
  "button",
275
277
  {
276
278
  type: "button",
277
- className: C(d.navButton, d.navNext),
279
+ className: S(d.navButton, d.navNext),
278
280
  onClick: E,
279
281
  "aria-label": "Suivant",
280
- children: xe ?? /* @__PURE__ */ R("span", { "aria-hidden": !0, children: "›" })
282
+ children: Ie ?? /* @__PURE__ */ R("span", { "aria-hidden": !0, children: "›" })
281
283
  }
282
284
  )
283
285
  ] }),
@@ -285,29 +287,29 @@ import '../../styles/Carousel.css';const Fe = "_root_36mqp_6", Be = "_viewport_3
285
287
  "div",
286
288
  {
287
289
  ref: a,
288
- className: C(
290
+ className: S(
289
291
  d.viewport,
290
292
  y && d.dragEnabled,
291
- ye && d.dragging,
292
- le
293
+ Ne && d.dragging,
294
+ fe
293
295
  ),
294
296
  tabIndex: 0,
295
297
  role: "region",
296
298
  "aria-roledescription": "carousel",
297
- "aria-label": Q,
298
- onKeyDown: Te,
299
+ "aria-label": Z,
300
+ onKeyDown: qe,
299
301
  onPointerDown: Pe,
300
302
  onPointerMove: Se,
301
- onPointerUp: Ce,
302
- onPointerCancel: Me,
303
- onClickCapture: Ae,
303
+ onPointerUp: Me,
304
+ onPointerCancel: Ae,
305
+ onClickCapture: Te,
304
306
  children: h.map((e, t) => /* @__PURE__ */ R(
305
307
  "div",
306
308
  {
307
309
  ref: (r) => {
308
310
  x.current[t] = r;
309
311
  },
310
- className: C(d.slide, fe),
312
+ className: S(d.slide, de),
311
313
  "data-carousel-slide": !0,
312
314
  "data-carousel-clone": e.isClone ? "true" : "false",
313
315
  "aria-label": `Item ${e.realIndex + 1} sur ${s}`,
@@ -322,5 +324,5 @@ import '../../styles/Carousel.css';const Fe = "_root_36mqp_6", Be = "_viewport_3
322
324
  }
323
325
  );
324
326
  export {
325
- Ye as Carousel
327
+ Ge as Carousel
326
328
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@situaction/traq-ui-ste",
3
- "version": "1.2.17",
3
+ "version": "1.2.18",
4
4
  "description": "library react component Situaction",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",