@dgshahr/ui-kit 1.4.0 → 1.5.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.
- package/dist/Button/index.cjs +1 -1
- package/dist/Button/index.d.ts.map +1 -1
- package/dist/Button/index.mjs +25 -25
- package/dist/Sidebar/Items.d.ts.map +1 -1
- package/dist/Sidebar/index.cjs +1 -1
- package/dist/Sidebar/index.mjs +190 -177
- package/dist/Slide-Cg1SjpFn.js +339 -0
- package/dist/Slide-YnGNNNXw.cjs +1 -0
- package/dist/Slider/Navigation.d.ts.map +1 -1
- package/dist/Slider/index.cjs +1 -1
- package/dist/Slider/index.mjs +1 -1
- package/dist/assets/styles.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/Slide-CdFHPwvj.cjs +0 -1
- package/dist/Slide-CyQuarjr.js +0 -331
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r, jsxs as w, Fragment as j } from "react/jsx-runtime";
|
|
3
|
+
import { c as k } from "./clsx-OuTLNxxd.js";
|
|
4
|
+
import { createContext as $, useContext as H, useState as x, useEffect as C, forwardRef as K, useRef as O, useImperativeHandle as _, useId as z } from "react";
|
|
5
|
+
import { I as X } from "./IconArrowLeft2-cxcPyDqS.js";
|
|
6
|
+
import { I as q } from "./IconArrowRight2-BoXg0Gkw.js";
|
|
7
|
+
import M from "./Button/index.mjs";
|
|
8
|
+
const R = $({
|
|
9
|
+
slidesPerView: 1,
|
|
10
|
+
spaceBetween: 0,
|
|
11
|
+
navigationVariant: "outside",
|
|
12
|
+
showNavigationDots: !0,
|
|
13
|
+
showPaginationText: !1,
|
|
14
|
+
childrenCount: 0,
|
|
15
|
+
sliderId: ""
|
|
16
|
+
}), W = () => H(R);
|
|
17
|
+
function G({
|
|
18
|
+
active: e,
|
|
19
|
+
autoplay: i,
|
|
20
|
+
variant: n = "outside"
|
|
21
|
+
}) {
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
inside: "dgsuikit:bg-gray-500/50 dgsuikit:hover:bg-gray-500/80",
|
|
25
|
+
outside: "dgsuikit:bg-gray-200 dgsuikit:hover:bg-gray-300"
|
|
26
|
+
}[n],
|
|
27
|
+
e ? "dgsuikit:w-[22px]" : "dgsuikit:w-[6px]",
|
|
28
|
+
i ? "dgsuikit:p-[1px]" : ""
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
const J = (e) => {
|
|
32
|
+
const { active: i, onClick: n, onNavigateToNext: a, index: t } = e, { autoplay: d, navigationVariant: m = "outside" } = W(), [l, u] = x(0);
|
|
33
|
+
return C(() => {
|
|
34
|
+
if (!i || !d) return;
|
|
35
|
+
const f = typeof d == "boolean" ? 7e3 : d?.delay ?? 7e3;
|
|
36
|
+
let v = Date.now();
|
|
37
|
+
const o = setInterval(() => {
|
|
38
|
+
const c = Date.now() - v, g = c / f * 100;
|
|
39
|
+
u(Math.min(g, 100)), c >= f && typeof a == "function" && (a(), u(0), clearInterval(o));
|
|
40
|
+
}, 100);
|
|
41
|
+
return function() {
|
|
42
|
+
return u(0), v = Date.now(), clearInterval(o);
|
|
43
|
+
};
|
|
44
|
+
}, [i, d, a]), /* @__PURE__ */ r(
|
|
45
|
+
"button",
|
|
46
|
+
{
|
|
47
|
+
className: k(
|
|
48
|
+
"dgsuikit:rounded-full dgsuikit:overflow-hidden dgsuikit:transition-all dgsuikit:h-[6px]",
|
|
49
|
+
G({ active: i, autoplay: d, variant: m })
|
|
50
|
+
),
|
|
51
|
+
onClick: n,
|
|
52
|
+
"aria-label": `slider-navigation-dot-${t + 1}`,
|
|
53
|
+
children: i && /* @__PURE__ */ r(
|
|
54
|
+
"div",
|
|
55
|
+
{
|
|
56
|
+
className: k("dgsuikit:h-full dgsuikit:rounded-full", {
|
|
57
|
+
"dgsuikit:bg-white": m === "inside",
|
|
58
|
+
"dgsuikit:bg-gray-700": m === "outside"
|
|
59
|
+
}),
|
|
60
|
+
style: { width: d ? `${l}%` : "100%" }
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}, B = "dgsuikit:opacity-0 dgsuikit:group-hover:opacity-100 dgsuikit:transition-opacity", Q = (e) => {
|
|
66
|
+
const { onNavigate: i, slideIndex: n, slidesCount: a } = e, {
|
|
67
|
+
navigationButtonsShowType: t = "hide",
|
|
68
|
+
dotsClassName: d,
|
|
69
|
+
navigationContainerClassName: m,
|
|
70
|
+
navigationVariant: l = "outside",
|
|
71
|
+
showNavigationDots: u = !0,
|
|
72
|
+
showPaginationText: f
|
|
73
|
+
} = W(), v = () => {
|
|
74
|
+
const o = k(
|
|
75
|
+
"dgsuikit:!absolute dgsuikit:top-1/2 dgsuikit:-translate-y-1/2",
|
|
76
|
+
B
|
|
77
|
+
);
|
|
78
|
+
return /* @__PURE__ */ w(j, { children: [
|
|
79
|
+
/* @__PURE__ */ r(
|
|
80
|
+
M,
|
|
81
|
+
{
|
|
82
|
+
type: "button",
|
|
83
|
+
variant: "secondary",
|
|
84
|
+
onClick: () => i(n - 1),
|
|
85
|
+
rightIcon: /* @__PURE__ */ r(q, {}),
|
|
86
|
+
"aria-label": "slider-previous-button",
|
|
87
|
+
className: t === "onSides" ? k(o, "dgsuikit:right-[5.5%]") : void 0
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ r(
|
|
91
|
+
M,
|
|
92
|
+
{
|
|
93
|
+
type: "button",
|
|
94
|
+
variant: "secondary",
|
|
95
|
+
onClick: () => i(n + 1),
|
|
96
|
+
rightIcon: /* @__PURE__ */ r(X, {}),
|
|
97
|
+
"aria-label": "slider-next-button",
|
|
98
|
+
className: t === "onSides" ? k(o, "dgsuikit:left-[5.5%]") : void 0
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
] });
|
|
102
|
+
};
|
|
103
|
+
return /* @__PURE__ */ w(j, { children: [
|
|
104
|
+
t && t !== "hide" && t === "onSides" && v,
|
|
105
|
+
/* @__PURE__ */ w(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
className: k(
|
|
109
|
+
"dgsuikit:flex",
|
|
110
|
+
{
|
|
111
|
+
"dgsuikit:items-center dgsuikit:mt-2": l === "outside",
|
|
112
|
+
"dgsuikit:absolute dgsuikit:bottom-4 dgsuikit:w-full dgsuikit:justify-center": l === "inside",
|
|
113
|
+
"dgsuikit:justify-between": l === "outside" && t !== "hide" && t !== "onSides",
|
|
114
|
+
"dgsuikit:justify-center": l === "outside" && (t === "hide" || t === "onSides")
|
|
115
|
+
},
|
|
116
|
+
m
|
|
117
|
+
),
|
|
118
|
+
children: [
|
|
119
|
+
t && t !== "hide" && t !== "onSides" && /* @__PURE__ */ r(
|
|
120
|
+
"div",
|
|
121
|
+
{
|
|
122
|
+
className: k(
|
|
123
|
+
"dgsuikit:flex dgsuikit:gap-2",
|
|
124
|
+
t === "hover" && B,
|
|
125
|
+
l === "inside" && "dgsuikit:absolute dgsuikit:bottom-0 dgsuikit:left-[5.5%]"
|
|
126
|
+
),
|
|
127
|
+
children: v()
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
(u || f) && /* @__PURE__ */ w("div", { className: "dgsuikit:flex dgsuikit:items-center dgsuikit:gap-3", children: [
|
|
131
|
+
f && /* @__PURE__ */ w("div", { className: "dgsuikit:flex dgsuikit:items-center dgsuikit:gap-1 dgsuikit:font-caption-regular dgsuikit:text-gray-400 dgsuikit:ss02", children: [
|
|
132
|
+
/* @__PURE__ */ r(
|
|
133
|
+
"span",
|
|
134
|
+
{
|
|
135
|
+
className: k("dgsuikit:font-bold", {
|
|
136
|
+
"dgsuikit:text-gray-600": l === "outside",
|
|
137
|
+
"dgsuikit:text-white": l === "inside"
|
|
138
|
+
}),
|
|
139
|
+
children: n + 1
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
/* @__PURE__ */ r("span", { children: "از" }),
|
|
143
|
+
/* @__PURE__ */ r("span", { children: a })
|
|
144
|
+
] }),
|
|
145
|
+
u && /* @__PURE__ */ r(
|
|
146
|
+
"div",
|
|
147
|
+
{
|
|
148
|
+
className: k(
|
|
149
|
+
"dgsuikit:flex dgsuikit:items-center dgsuikit:justify-center dgsuikit:gap-2",
|
|
150
|
+
d
|
|
151
|
+
),
|
|
152
|
+
children: Array.from(Array(a).keys()).map((o, c) => /* @__PURE__ */ r(
|
|
153
|
+
J,
|
|
154
|
+
{
|
|
155
|
+
active: n === c,
|
|
156
|
+
index: c,
|
|
157
|
+
onClick: () => i(c),
|
|
158
|
+
onNavigateToNext: () => i(n + 1)
|
|
159
|
+
},
|
|
160
|
+
o + a
|
|
161
|
+
))
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
] })
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
] });
|
|
169
|
+
}, U = K((e, i) => {
|
|
170
|
+
const [n, a] = x(e), {
|
|
171
|
+
className: t = "",
|
|
172
|
+
containerClassName: d = "",
|
|
173
|
+
showNavigationDots: m = !0,
|
|
174
|
+
slidesPerView: l = 1,
|
|
175
|
+
navigationButtonsShowType: u = "hide",
|
|
176
|
+
spaceBetween: f = 0,
|
|
177
|
+
showPaginationText: v,
|
|
178
|
+
onSlideIndexChange: o,
|
|
179
|
+
initialSlide: c,
|
|
180
|
+
containerXPadding: g = 0
|
|
181
|
+
} = n, [S, I] = x(0), [A, D] = x(0), E = Object.fromEntries(
|
|
182
|
+
Object.entries(n).filter(([s]) => s !== "children")
|
|
183
|
+
), h = O(null), p = Math.ceil(A / Math.floor(l)), V = (m || u && u !== "hide" || v) && p > 1;
|
|
184
|
+
function F(s) {
|
|
185
|
+
if (Math.ceil(Math.abs(s.currentTarget.scrollLeft)) + s.currentTarget.clientWidth + 1 + g >= s.currentTarget.scrollWidth) {
|
|
186
|
+
I(p - 1);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const N = s.currentTarget.scrollWidth - g * 2, b = N / p, y = (N - s.currentTarget.scrollLeft - g) / b;
|
|
190
|
+
if (y <= p) {
|
|
191
|
+
I(0);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
I(Math.round(y % p));
|
|
195
|
+
}
|
|
196
|
+
function P(s) {
|
|
197
|
+
if (!h.current) return;
|
|
198
|
+
const N = h.current.offsetWidth, b = S - s, y = h.current.scrollWidth / p, L = b * y;
|
|
199
|
+
s < 0 ? h.current.scrollTo({ behavior: "smooth", left: -(N * p) }) : s >= p ? h.current.scrollTo({ behavior: "smooth", left: 0 }) : h.current.scrollBy({ behavior: "smooth", left: L });
|
|
200
|
+
}
|
|
201
|
+
function T() {
|
|
202
|
+
const N = Object.keys(e.responsive).sort(
|
|
203
|
+
(y, L) => Number(y) - Number(L)
|
|
204
|
+
).findLast(
|
|
205
|
+
(y) => Number(y) <= window.innerWidth
|
|
206
|
+
), b = N ? e.responsive[Number(N)] : null;
|
|
207
|
+
a(b ? { ...n, ...b } : e);
|
|
208
|
+
}
|
|
209
|
+
return _(i, () => ({
|
|
210
|
+
element: h.current,
|
|
211
|
+
navigate: (s) => P(Math.max(0, s - 1))
|
|
212
|
+
})), C(() => {
|
|
213
|
+
if (!h.current) return;
|
|
214
|
+
let s = h.current.childElementCount;
|
|
215
|
+
g > 0 && (s -= 2), D(s);
|
|
216
|
+
}, [e.children, h, g]), C(() => {
|
|
217
|
+
if (!(!e.responsive || Object.keys(e.responsive).length <= 0))
|
|
218
|
+
return T(), window.addEventListener("resize", T), () => {
|
|
219
|
+
window.removeEventListener("resize", T);
|
|
220
|
+
};
|
|
221
|
+
}, [e.responsive]), C(() => {
|
|
222
|
+
o && typeof o == "function" && o(S);
|
|
223
|
+
}, [S]), C(() => {
|
|
224
|
+
typeof c == "number" && h.current && P(Math.max(0, c - 1));
|
|
225
|
+
}, [c, h.current]), /* @__PURE__ */ r(R.Provider, { value: { ...E, childrenCount: A, sliderId: z() }, children: /* @__PURE__ */ w(
|
|
226
|
+
"div",
|
|
227
|
+
{
|
|
228
|
+
className: k("dgsuikit:overflow-hidden dgsuikit:relative dgsuikit:group", t),
|
|
229
|
+
style: { direction: "rtl" },
|
|
230
|
+
children: [
|
|
231
|
+
/* @__PURE__ */ w(
|
|
232
|
+
"div",
|
|
233
|
+
{
|
|
234
|
+
className: k(
|
|
235
|
+
"dgsuikit:flex dgsuikit:snap-x dgsuikit:snap-mandatory dgsuikit:overflow-x-auto dgsuikit:no-scrollbar",
|
|
236
|
+
d
|
|
237
|
+
),
|
|
238
|
+
style: { marginLeft: -f },
|
|
239
|
+
onScroll: F,
|
|
240
|
+
ref: h,
|
|
241
|
+
children: [
|
|
242
|
+
g > 0 && /* @__PURE__ */ r(
|
|
243
|
+
"div",
|
|
244
|
+
{
|
|
245
|
+
className: "dgsuikit:shrink-0",
|
|
246
|
+
style: {
|
|
247
|
+
width: g,
|
|
248
|
+
paddingLeft: f
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
),
|
|
252
|
+
e.children,
|
|
253
|
+
g > 0 && /* @__PURE__ */ r(
|
|
254
|
+
"div",
|
|
255
|
+
{
|
|
256
|
+
className: "dgsuikit:shrink-0",
|
|
257
|
+
style: {
|
|
258
|
+
width: g,
|
|
259
|
+
paddingLeft: f
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
)
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
),
|
|
266
|
+
V && /* @__PURE__ */ r(
|
|
267
|
+
Q,
|
|
268
|
+
{
|
|
269
|
+
onNavigate: P,
|
|
270
|
+
slideIndex: S,
|
|
271
|
+
slidesCount: p
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
]
|
|
275
|
+
}
|
|
276
|
+
) });
|
|
277
|
+
});
|
|
278
|
+
U.displayName = "Slider";
|
|
279
|
+
function Y({
|
|
280
|
+
slidesPerView: e,
|
|
281
|
+
childIndex: i,
|
|
282
|
+
centerMode: n,
|
|
283
|
+
childrenCount: a,
|
|
284
|
+
haveContainerPadding: t
|
|
285
|
+
}) {
|
|
286
|
+
const d = i % Math.floor(e) === 0, m = e % 1 !== 0, l = i === 0, u = i === a - 1;
|
|
287
|
+
if (!d) return "none";
|
|
288
|
+
if (n) {
|
|
289
|
+
if (m && !t) {
|
|
290
|
+
if (l) return "start";
|
|
291
|
+
if (u) return "end";
|
|
292
|
+
}
|
|
293
|
+
return "center";
|
|
294
|
+
}
|
|
295
|
+
return "start";
|
|
296
|
+
}
|
|
297
|
+
const rt = (e) => {
|
|
298
|
+
const { children: i, className: n, style: a, ...t } = e, {
|
|
299
|
+
slidesPerView: d = 1,
|
|
300
|
+
spaceBetween: m = 0,
|
|
301
|
+
centerMode: l = !1,
|
|
302
|
+
containerXPadding: u = 0,
|
|
303
|
+
childrenCount: f = 0,
|
|
304
|
+
sliderId: v
|
|
305
|
+
} = W(), o = O(null), [c, g] = x(0);
|
|
306
|
+
return C(() => {
|
|
307
|
+
o.current && g(
|
|
308
|
+
Array.prototype.indexOf.call(
|
|
309
|
+
document.querySelectorAll(`[id='slide-item-${v}']`),
|
|
310
|
+
o.current
|
|
311
|
+
)
|
|
312
|
+
);
|
|
313
|
+
}, [o, f, u]), /* @__PURE__ */ r(
|
|
314
|
+
"div",
|
|
315
|
+
{
|
|
316
|
+
...t,
|
|
317
|
+
ref: o,
|
|
318
|
+
id: `slide-item-${v}`,
|
|
319
|
+
className: k("dgsuikit:shrink-0 dgsuikit:snap-normal", n),
|
|
320
|
+
style: {
|
|
321
|
+
width: 100 / (d ?? 1) + "%",
|
|
322
|
+
paddingLeft: m,
|
|
323
|
+
scrollSnapAlign: Y({
|
|
324
|
+
slidesPerView: d,
|
|
325
|
+
childIndex: c,
|
|
326
|
+
centerMode: l,
|
|
327
|
+
childrenCount: f || 0,
|
|
328
|
+
haveContainerPadding: u > 0
|
|
329
|
+
}),
|
|
330
|
+
...a
|
|
331
|
+
},
|
|
332
|
+
children: i
|
|
333
|
+
}
|
|
334
|
+
);
|
|
335
|
+
};
|
|
336
|
+
export {
|
|
337
|
+
U as S,
|
|
338
|
+
rt as a
|
|
339
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";const t=require("react/jsx-runtime"),v=require("./clsx-C11secjj.cjs"),n=require("react"),D=require("./IconArrowLeft2-CNA3H0xY.cjs"),q=require("./IconArrowRight2-CF_bdH81.cjs"),A=require("./Button/index.cjs"),R=n.createContext({slidesPerView:1,spaceBetween:0,navigationVariant:"outside",showNavigationDots:!0,showPaginationText:!1,childrenCount:0,sliderId:""}),P=()=>n.useContext(R);function F({active:i,autoplay:s,variant:r="outside"}){return[{inside:"dgsuikit:bg-gray-500/50 dgsuikit:hover:bg-gray-500/80",outside:"dgsuikit:bg-gray-200 dgsuikit:hover:bg-gray-300"}[r],i?"dgsuikit:w-[22px]":"dgsuikit:w-[6px]",s?"dgsuikit:p-[1px]":""]}const V=i=>{const{active:s,onClick:r,onNavigateToNext:d,index:e}=i,{autoplay:l,navigationVariant:x="outside"}=P(),[u,c]=n.useState(0);return n.useEffect(()=>{if(!s||!l)return;const k=typeof l=="boolean"?7e3:l?.delay??7e3;let m=Date.now();const a=setInterval(()=>{const g=Date.now()-m,h=g/k*100;c(Math.min(h,100)),g>=k&&typeof d=="function"&&(d(),c(0),clearInterval(a))},100);return function(){return c(0),m=Date.now(),clearInterval(a)}},[s,l,d]),t.jsx("button",{className:v.clsx("dgsuikit:rounded-full dgsuikit:overflow-hidden dgsuikit:transition-all dgsuikit:h-[6px]",F({active:s,autoplay:l,variant:x})),onClick:r,"aria-label":`slider-navigation-dot-${e+1}`,children:s&&t.jsx("div",{className:v.clsx("dgsuikit:h-full dgsuikit:rounded-full",{"dgsuikit:bg-white":x==="inside","dgsuikit:bg-gray-700":x==="outside"}),style:{width:l?`${u}%`:"100%"}})})},L="dgsuikit:opacity-0 dgsuikit:group-hover:opacity-100 dgsuikit:transition-opacity",$=i=>{const{onNavigate:s,slideIndex:r,slidesCount:d}=i,{navigationButtonsShowType:e="hide",dotsClassName:l,navigationContainerClassName:x,navigationVariant:u="outside",showNavigationDots:c=!0,showPaginationText:k}=P(),m=()=>{const a=v.clsx("dgsuikit:!absolute dgsuikit:top-1/2 dgsuikit:-translate-y-1/2",L);return t.jsxs(t.Fragment,{children:[t.jsx(A,{type:"button",variant:"secondary",onClick:()=>s(r-1),rightIcon:t.jsx(q.IconArrowRight2,{}),"aria-label":"slider-previous-button",className:e==="onSides"?v.clsx(a,"dgsuikit:right-[5.5%]"):void 0}),t.jsx(A,{type:"button",variant:"secondary",onClick:()=>s(r+1),rightIcon:t.jsx(D.IconArrowLeft2,{}),"aria-label":"slider-next-button",className:e==="onSides"?v.clsx(a,"dgsuikit:left-[5.5%]"):void 0})]})};return t.jsxs(t.Fragment,{children:[e&&e!=="hide"&&e==="onSides"&&m,t.jsxs("div",{className:v.clsx("dgsuikit:flex",{"dgsuikit:items-center dgsuikit:mt-2":u==="outside","dgsuikit:absolute dgsuikit:bottom-4 dgsuikit:w-full dgsuikit:justify-center":u==="inside","dgsuikit:justify-between":u==="outside"&&e!=="hide"&&e!=="onSides","dgsuikit:justify-center":u==="outside"&&(e==="hide"||e==="onSides")},x),children:[e&&e!=="hide"&&e!=="onSides"&&t.jsx("div",{className:v.clsx("dgsuikit:flex dgsuikit:gap-2",e==="hover"&&L,u==="inside"&&"dgsuikit:absolute dgsuikit:bottom-0 dgsuikit:left-[5.5%]"),children:m()}),(c||k)&&t.jsxs("div",{className:"dgsuikit:flex dgsuikit:items-center dgsuikit:gap-3",children:[k&&t.jsxs("div",{className:"dgsuikit:flex dgsuikit:items-center dgsuikit:gap-1 dgsuikit:font-caption-regular dgsuikit:text-gray-400 dgsuikit:ss02",children:[t.jsx("span",{className:v.clsx("dgsuikit:font-bold",{"dgsuikit:text-gray-600":u==="outside","dgsuikit:text-white":u==="inside"}),children:r+1}),t.jsx("span",{children:"از"}),t.jsx("span",{children:d})]}),c&&t.jsx("div",{className:v.clsx("dgsuikit:flex dgsuikit:items-center dgsuikit:justify-center dgsuikit:gap-2",l),children:Array.from(Array(d).keys()).map((a,g)=>t.jsx(V,{active:r===g,index:g,onClick:()=>s(g),onNavigateToNext:()=>s(r+1)},a+d))})]})]})]})},W=n.forwardRef((i,s)=>{const[r,d]=n.useState(i),{className:e="",containerClassName:l="",showNavigationDots:x=!0,slidesPerView:u=1,navigationButtonsShowType:c="hide",spaceBetween:k=0,showPaginationText:m,onSlideIndexChange:a,initialSlide:g,containerXPadding:h=0}=r,[b,C]=n.useState(0),[T,E]=n.useState(0),M=Object.fromEntries(Object.entries(r).filter(([o])=>o!=="children")),f=n.useRef(null),p=Math.ceil(T/Math.floor(u)),B=(x||c&&c!=="hide"||m)&&p>1;function O(o){if(Math.ceil(Math.abs(o.currentTarget.scrollLeft))+o.currentTarget.clientWidth+1+h>=o.currentTarget.scrollWidth){C(p-1);return}const w=o.currentTarget.scrollWidth-h*2,N=w/p,y=(w-o.currentTarget.scrollLeft-h)/N;if(y<=p){C(0);return}C(Math.round(y%p))}function S(o){if(!f.current)return;const w=f.current.offsetWidth,N=b-o,y=f.current.scrollWidth/p,I=N*y;o<0?f.current.scrollTo({behavior:"smooth",left:-(w*p)}):o>=p?f.current.scrollTo({behavior:"smooth",left:0}):f.current.scrollBy({behavior:"smooth",left:I})}function j(){const w=Object.keys(i.responsive).sort((y,I)=>Number(y)-Number(I)).findLast(y=>Number(y)<=window.innerWidth),N=w?i.responsive[Number(w)]:null;d(N?{...r,...N}:i)}return n.useImperativeHandle(s,()=>({element:f.current,navigate:o=>S(Math.max(0,o-1))})),n.useEffect(()=>{if(!f.current)return;let o=f.current.childElementCount;h>0&&(o-=2),E(o)},[i.children,f,h]),n.useEffect(()=>{if(!(!i.responsive||Object.keys(i.responsive).length<=0))return j(),window.addEventListener("resize",j),()=>{window.removeEventListener("resize",j)}},[i.responsive]),n.useEffect(()=>{a&&typeof a=="function"&&a(b)},[b]),n.useEffect(()=>{typeof g=="number"&&f.current&&S(Math.max(0,g-1))},[g,f.current]),t.jsx(R.Provider,{value:{...M,childrenCount:T,sliderId:n.useId()},children:t.jsxs("div",{className:v.clsx("dgsuikit:overflow-hidden dgsuikit:relative dgsuikit:group",e),style:{direction:"rtl"},children:[t.jsxs("div",{className:v.clsx("dgsuikit:flex dgsuikit:snap-x dgsuikit:snap-mandatory dgsuikit:overflow-x-auto dgsuikit:no-scrollbar",l),style:{marginLeft:-k},onScroll:O,ref:f,children:[h>0&&t.jsx("div",{className:"dgsuikit:shrink-0",style:{width:h,paddingLeft:k}}),i.children,h>0&&t.jsx("div",{className:"dgsuikit:shrink-0",style:{width:h,paddingLeft:k}})]}),B&&t.jsx($,{onNavigate:S,slideIndex:b,slidesCount:p})]})})});W.displayName="Slider";function H({slidesPerView:i,childIndex:s,centerMode:r,childrenCount:d,haveContainerPadding:e}){const l=s%Math.floor(i)===0,x=i%1!==0,u=s===0,c=s===d-1;if(!l)return"none";if(r){if(x&&!e){if(u)return"start";if(c)return"end"}return"center"}return"start"}const K=i=>{const{children:s,className:r,style:d,...e}=i,{slidesPerView:l=1,spaceBetween:x=0,centerMode:u=!1,containerXPadding:c=0,childrenCount:k=0,sliderId:m}=P(),a=n.useRef(null),[g,h]=n.useState(0);return n.useEffect(()=>{a.current&&h(Array.prototype.indexOf.call(document.querySelectorAll(`[id='slide-item-${m}']`),a.current))},[a,k,c]),t.jsx("div",{...e,ref:a,id:`slide-item-${m}`,className:v.clsx("dgsuikit:shrink-0 dgsuikit:snap-normal",r),style:{width:100/(l??1)+"%",paddingLeft:x,scrollSnapAlign:H({slidesPerView:l,childIndex:g,centerMode:u,childrenCount:k||0,haveContainerPadding:c>0}),...d},children:s})};exports.Slide=K;exports.Slider=W;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Navigation.d.ts","sourceRoot":"","sources":["../../src/components/Slider/Navigation.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAOhC,UAAU,eAAe;IACvB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"Navigation.d.ts","sourceRoot":"","sources":["../../src/components/Slider/Navigation.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAOhC,UAAU,eAAe;IACvB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAKD,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA4HnC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/dist/Slider/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../assets/styles.css');;/* empty css */const e=require("../Slide-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../assets/styles.css');;/* empty css */const e=require("../Slide-YnGNNNXw.cjs");exports.Slide=e.Slide;exports.Slider=e.Slider;
|
package/dist/Slider/index.mjs
CHANGED