@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 I, Fragment as We } from "react/jsx-runtime";
2
- import ze, { forwardRef as Ee, useMemo as ie, useRef as l, useState as q, useCallback as i, useImperativeHandle as Fe, useEffect as Y } from "react";
3
- import '../../styles/Carousel.css';const Be = "_root_1kths_1", $e = "_viewport_1kths_6", qe = "_dragEnabled_1kths_22", je = "_dragging_1kths_27", Oe = "_slide_1kths_34", Xe = "_navButton_1kths_41", He = "_navPrev_1kths_63", Ve = "_navNext_1kths_67", d = {
4
- root: Be,
5
- viewport: $e,
6
- dragEnabled: qe,
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 = Ee(
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: ve = 12,
21
- align: h = "center",
22
- showArrows: me = !0,
23
- dragEnabled: R = !0,
20
+ gap: me = 12,
21
+ align: w = "center",
22
+ showArrows: ve = !0,
23
+ dragEnabled: y = !0,
24
24
  snapOnRelease: G = !0,
25
- keyboardNavigation: he = !0,
26
- step: we = 1,
25
+ keyboardNavigation: we = !0,
26
+ step: ge = 1,
27
27
  initialIndex: J = 0,
28
- loop: y = !1,
28
+ loop: N = !1,
29
29
  ariaLabel: Q = "Carousel",
30
- iconLeft: ge,
30
+ iconLeft: he,
31
31
  iconRight: xe,
32
32
  onIndexChange: A
33
33
  }, _e) => {
34
- const w = ie(() => ze.Children.toArray(M), [M]), s = w.length, c = y && s > 1, T = Math.max(1, Math.min(we, Math.max(1, s))), p = c ? s : 0, g = ie(() => {
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 w.map((n, o) => ({
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 = w.map((n, o) => ({
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 = w.map((n, o) => ({
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 = w.map((n, o) => ({
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, w]), j = g.length, a = l(null), x = l([]), [Le, be] = q(0), N = l(0), [ke, Z] = q(!1), [Ie, ee] = q(!1), _ = l(!1), te = l(0), O = l(0), X = l(!1), H = l(!1), [Re, re] = q(!1), v = i(
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
- N.current = e, be(e), A == null || A(e);
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) => h === "center" ? t.offsetLeft - (e.clientWidth - t.offsetWidth) / 2 : t.offsetLeft,
69
- [h]
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
- ), b = i(
84
+ ), I = i(
85
85
  (e, t = "smooth") => {
86
- const r = D(e), n = W(r);
87
- L(n, t), v(r);
86
+ const r = q(e), n = D(r);
87
+ L(n, t), m(r);
88
88
  },
89
- [D, W, L, v]
90
- ), z = i(() => {
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 = h === "center" ? t + e.clientWidth / 2 : t;
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 m = h === "center" ? u.offsetLeft + u.offsetWidth / 2 : u.offsetLeft, $ = Math.abs(m - r);
99
- $ < o && (o = $, n = f);
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
- }, [h, j]), E = i(
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
- }), k = i(() => {
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, m = 0;
128
- u < o ? m = Math.ceil((o - u) / n) * n : u > f && (m = -Math.ceil((u - f) / n) * n), m !== 0 && (V.current = !0, t.scrollLeft = u + m, e === "drag" && (O.current += m), V.current = !1);
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 (y) {
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
- }, [y, s]), F = i(() => {
141
- s <= 1 || b(N.current + T);
142
- }, [b, s, T]), B = i(() => {
143
- s <= 1 || b(N.current - T);
144
- }, [b, s, T]), ye = i(() => {
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 = z(), t = E(e);
147
+ const e = W(), t = z(e);
148
148
  L(t, "smooth");
149
- const r = ((n = g[t]) == null ? void 0 : n.realIndex) ?? 0;
150
- v(r);
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
- g,
157
- v
156
+ h,
157
+ m
158
158
  ]);
159
- Fe(
159
+ Ee(
160
160
  _e,
161
161
  () => ({
162
- next: F,
163
- prev: B,
164
- goTo: b,
165
- getIndex: () => N.current,
162
+ next: E,
163
+ prev: F,
164
+ goTo: I,
165
+ getIndex: () => k.current,
166
166
  getLength: () => s
167
167
  }),
168
- [b, F, B, s]
168
+ [I, E, F, s]
169
169
  ), Y(() => {
170
170
  if (s === 0) return;
171
- const e = D(J), t = W(e), r = window.requestAnimationFrame(() => {
172
- k(), L(t, "auto"), v(e), S();
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
- v,
181
+ m,
182
182
  S,
183
- k
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
- k();
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 = () => k();
192
+ const r = () => b();
193
193
  window.addEventListener("resize", r);
194
- const n = window.requestAnimationFrame(() => k());
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, k]), Y(() => {
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 = z(), o = E(n), f = ((u = g[o]) == null ? void 0 : u.realIndex) ?? 0;
206
- f !== N.current && v(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
- E,
218
- g,
219
- v
218
+ h,
219
+ m
220
220
  ]);
221
- const Ne = (e) => e instanceof HTMLElement ? !!e.closest(
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
- R && a.current && (Ne(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)));
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 (!R || !_.current || (e.preventDefault(), !a.current)) return;
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), ye(), S();
246
+ }, 0)), ne(!0), Ne(), S();
247
247
  }, Ce = (e) => {
248
- R && _.current && ce(e.pointerId);
248
+ y && _.current && ce(e.pointerId);
249
249
  }, Me = (e) => {
250
- R && _.current && ce(e.pointerId);
250
+ y && _.current && ce(e.pointerId);
251
251
  }, Ae = (e) => {
252
252
  H.current && (e.preventDefault(), e.stopPropagation());
253
253
  }, Te = (e) => {
254
- he && (e.key === "ArrowLeft" ? (e.preventDefault(), B()) : e.key === "ArrowRight" && (e.preventDefault(), F()));
255
- }, De = {
254
+ we && (e.key === "ArrowLeft" ? (e.preventDefault(), F()) : e.key === "ArrowRight" && (e.preventDefault(), E()));
255
+ }, qe = {
256
256
  ...de ?? {},
257
- "--carousel-gap": `${ve}px`,
257
+ "--carousel-gap": `${me}px`,
258
258
  "--carousel-slide-size": pe,
259
- "--carousel-snap-align": h
259
+ "--carousel-snap-align": w
260
260
  };
261
- return /* @__PURE__ */ ae("div", { className: C(d.root, ue), style: De, "aria-label": Q, children: [
262
- me && s > 1 && /* @__PURE__ */ ae(We, { children: [
263
- /* @__PURE__ */ I(
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: B,
269
- disabled: !ke,
268
+ onClick: F,
270
269
  "aria-label": "Précédent",
271
- children: ge ?? /* @__PURE__ */ I("span", { "aria-hidden": !0, children: "‹" })
270
+ children: he ?? /* @__PURE__ */ R("span", { "aria-hidden": !0, children: "‹" })
272
271
  }
273
272
  ),
274
- /* @__PURE__ */ I(
273
+ Re && /* @__PURE__ */ R(
275
274
  "button",
276
275
  {
277
276
  type: "button",
278
277
  className: C(d.navButton, d.navNext),
279
- onClick: F,
280
- disabled: !Ie,
278
+ onClick: E,
281
279
  "aria-label": "Suivant",
282
- children: xe ?? /* @__PURE__ */ I("span", { "aria-hidden": !0, children: "›" })
280
+ children: xe ?? /* @__PURE__ */ R("span", { "aria-hidden": !0, children: "›" })
283
281
  }
284
282
  )
285
283
  ] }),
286
- /* @__PURE__ */ I(
284
+ /* @__PURE__ */ R(
287
285
  "div",
288
286
  {
289
287
  ref: a,
290
288
  className: C(
291
289
  d.viewport,
292
- R && d.dragEnabled,
293
- Re && d.dragging,
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: g.map((e, t) => /* @__PURE__ */ I(
304
+ children: h.map((e, t) => /* @__PURE__ */ R(
307
305
  "div",
308
306
  {
309
307
  ref: (r) => {
@@ -1 +1 @@
1
- ._root_1kths_1{position:relative;width:100%}._viewport_1kths_6{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_1kths_6::-webkit-scrollbar{display:none}._dragEnabled_1kths_22{cursor:grab;touch-action:pan-y}._dragging_1kths_27{cursor:grabbing;scroll-behavior:auto;scroll-snap-type:none;-webkit-user-select:none;user-select:none}._slide_1kths_34{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_1kths_41{position:absolute;top:50%;transform:translateY(-50%);z-index:2;width:36px;height:36px;border:0;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;background:#ffffffeb;box-shadow:0 2px 8px #00000026;cursor:pointer;-webkit-user-select:none;user-select:none}._navButton_1kths_41:disabled{opacity:.4;cursor:not-allowed}._navPrev_1kths_63{left:8px}._navNext_1kths_67{right:8px}
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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@situaction/traq-ui-ste",
3
- "version": "1.2.16",
3
+ "version": "1.2.17",
4
4
  "description": "library react component Situaction",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",