@dgshahr/ui-kit 0.0.21 → 0.0.23
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/Slide-CQBJqAor.js +274 -0
- package/dist/Slide-DAapDHVY.cjs +1 -0
- package/dist/Slider/Slide.d.ts.map +1 -1
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/index.cjs +1 -1
- package/dist/Slider/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/Slide-BEZZ-Egi.js +0 -275
- package/dist/Slide-C1oVFHZo.cjs +0 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as r, jsxs as y, Fragment as D } from "react/jsx-runtime";
|
|
3
|
+
import { c as v } from "./clsx-OuTLNxxd.js";
|
|
4
|
+
import { createContext as M, useContext as R, useState as N, useEffect as x, useRef as T } from "react";
|
|
5
|
+
import { A as O } from "./ArrowLeft2-jP2w1vwt.js";
|
|
6
|
+
import { A as V } from "./ArrowRight2-CcHdxGRE.js";
|
|
7
|
+
import S from "./Button/index.js";
|
|
8
|
+
const P = M({
|
|
9
|
+
slidesPerView: 1,
|
|
10
|
+
spaceBetween: 0,
|
|
11
|
+
navigationVariant: "outside",
|
|
12
|
+
showNavigationDots: !0,
|
|
13
|
+
showPaginationText: !1
|
|
14
|
+
}), C = () => R(P);
|
|
15
|
+
function E({
|
|
16
|
+
active: e,
|
|
17
|
+
autoplay: i,
|
|
18
|
+
variant: s = "outside"
|
|
19
|
+
}) {
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
inside: "dgs-ui-kit-bg-gray-500/50 hover:dgs-ui-kit-bg-gray-500/80",
|
|
23
|
+
outside: "dgs-ui-kit-bg-gray-200 hover:dgs-ui-kit-bg-gray-300"
|
|
24
|
+
}[s],
|
|
25
|
+
e ? "dgs-ui-kit-w-[22px]" : "dgs-ui-kit-w-[6px]",
|
|
26
|
+
i ? "dgs-ui-kit-p-[1px]" : ""
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
const F = (e) => {
|
|
30
|
+
const { active: i, onClick: s, onNavigateToNext: n } = e, { autoplay: t, navigationVariant: u = "outside" } = C(), [l, o] = N(0);
|
|
31
|
+
return x(() => {
|
|
32
|
+
if (!i || !t) return;
|
|
33
|
+
const c = typeof t == "boolean" ? 7e3 : t?.delay ?? 7e3;
|
|
34
|
+
let a = Date.now();
|
|
35
|
+
const g = setInterval(() => {
|
|
36
|
+
const h = Date.now() - a, f = h / c * 100;
|
|
37
|
+
o(Math.min(f, 100)), h >= c && typeof n == "function" && n();
|
|
38
|
+
}, 100);
|
|
39
|
+
return function() {
|
|
40
|
+
return o(0), a = Date.now(), clearInterval(g);
|
|
41
|
+
};
|
|
42
|
+
}, [i, t, n]), /* @__PURE__ */ r(
|
|
43
|
+
"button",
|
|
44
|
+
{
|
|
45
|
+
className: v(
|
|
46
|
+
"dgs-ui-kit-rounded-full dgs-ui-kit-overflow-hidden dgs-ui-kit-transition-all dgs-ui-kit-h-[6px]",
|
|
47
|
+
E({ active: i, autoplay: t, variant: u })
|
|
48
|
+
),
|
|
49
|
+
onClick: s,
|
|
50
|
+
children: i && /* @__PURE__ */ r(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
className: v("dgs-ui-kit-h-full dgs-ui-kit-rounded-full", {
|
|
54
|
+
"dgs-ui-kit-bg-white": u === "inside",
|
|
55
|
+
"dgs-ui-kit-bg-gray-700": u === "outside"
|
|
56
|
+
}),
|
|
57
|
+
style: { width: t ? `${l}%` : "100%" }
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}, K = (e) => {
|
|
63
|
+
const { onNavigate: i, slideIndex: s, slidesCount: n } = e, {
|
|
64
|
+
navigationButtonsShowType: t = "hide",
|
|
65
|
+
dotsClassName: u,
|
|
66
|
+
navigationContainerClassName: l,
|
|
67
|
+
navigationVariant: o = "outside",
|
|
68
|
+
showNavigationDots: c = !0,
|
|
69
|
+
showPaginationText: a
|
|
70
|
+
} = C(), g = /* @__PURE__ */ y(
|
|
71
|
+
"div",
|
|
72
|
+
{
|
|
73
|
+
className: v("dgs-ui-kit-flex dgs-ui-kit-gap-2", {
|
|
74
|
+
"dgs-ui-kit-absolute dgs-ui-kit-bottom-0 dgs-ui-kit-left-[5.5%]": o === "inside" && t !== "onSides",
|
|
75
|
+
"dgs-ui-kit-absolute dgs-ui-kit-justify-between dgs-ui-kit-top-1/2 -dgs-ui-kit-translate-y-1/2 dgs-ui-kit-w-full dgs-ui-kit-px-[5.5%]": t === "onSides",
|
|
76
|
+
"dgs-ui-kit-opacity-0 group-hover:dgs-ui-kit-opacity-100 dgs-ui-kit-transition": t === "hover" || t === "onSides"
|
|
77
|
+
}),
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ r(
|
|
80
|
+
S,
|
|
81
|
+
{
|
|
82
|
+
type: "button",
|
|
83
|
+
variant: "secondary",
|
|
84
|
+
onClick: () => i(s - 1),
|
|
85
|
+
rightIcon: /* @__PURE__ */ r(V, {})
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
/* @__PURE__ */ r(
|
|
89
|
+
S,
|
|
90
|
+
{
|
|
91
|
+
type: "button",
|
|
92
|
+
variant: "secondary",
|
|
93
|
+
onClick: () => i(s + 1),
|
|
94
|
+
rightIcon: /* @__PURE__ */ r(O, {})
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
return /* @__PURE__ */ y(D, { children: [
|
|
101
|
+
t && t !== "hide" && t === "onSides" && g,
|
|
102
|
+
/* @__PURE__ */ y(
|
|
103
|
+
"div",
|
|
104
|
+
{
|
|
105
|
+
className: v(
|
|
106
|
+
"dgs-ui-kit-flex",
|
|
107
|
+
{
|
|
108
|
+
"dgs-ui-kit-items-center dgs-ui-kit-mt-2": o === "outside",
|
|
109
|
+
"dgs-ui-kit-absolute dgs-ui-kit-bottom-4 dgs-ui-kit-w-full dgs-ui-kit-justify-center": o === "inside",
|
|
110
|
+
"dgs-ui-kit-justify-between": o === "outside" && t !== "hide" && t !== "onSides",
|
|
111
|
+
"dgs-ui-kit-justify-center": o === "outside" && (t === "hide" || t === "onSides")
|
|
112
|
+
},
|
|
113
|
+
l
|
|
114
|
+
),
|
|
115
|
+
children: [
|
|
116
|
+
t && t !== "hide" && t !== "onSides" && g,
|
|
117
|
+
(c || a) && /* @__PURE__ */ y("div", { className: "dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-3", children: [
|
|
118
|
+
a && /* @__PURE__ */ y("div", { className: "dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-1 dgs-ui-kit-font-caption-regular dgs-ui-kit-text-gray-400 ss02", children: [
|
|
119
|
+
/* @__PURE__ */ r(
|
|
120
|
+
"span",
|
|
121
|
+
{
|
|
122
|
+
className: v("dgs-ui-kit-font-bold", {
|
|
123
|
+
"dgs-ui-kit-text-gray-600": o === "outside",
|
|
124
|
+
"dgs-ui-kit-text-white": o === "inside"
|
|
125
|
+
}),
|
|
126
|
+
children: s + 1
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
/* @__PURE__ */ r("span", { children: "از" }),
|
|
130
|
+
/* @__PURE__ */ r("span", { children: n })
|
|
131
|
+
] }),
|
|
132
|
+
c && /* @__PURE__ */ r(
|
|
133
|
+
"div",
|
|
134
|
+
{
|
|
135
|
+
className: v(
|
|
136
|
+
"dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-justify-center dgs-ui-kit-gap-2",
|
|
137
|
+
u
|
|
138
|
+
),
|
|
139
|
+
children: Array.from(Array(n).keys()).map((h, f) => /* @__PURE__ */ r(
|
|
140
|
+
F,
|
|
141
|
+
{
|
|
142
|
+
active: s === f,
|
|
143
|
+
onClick: () => i(f),
|
|
144
|
+
onNavigateToNext: () => i(s + 1)
|
|
145
|
+
},
|
|
146
|
+
h + n
|
|
147
|
+
))
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
] })
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
] });
|
|
155
|
+
}, Q = (e) => {
|
|
156
|
+
const [i, s] = N(0), [n, t] = N(e), [u, l] = N(0), {
|
|
157
|
+
className: o = "",
|
|
158
|
+
containerClassName: c = "",
|
|
159
|
+
showNavigationDots: a = !0,
|
|
160
|
+
slidesPerView: g = 1,
|
|
161
|
+
navigationButtonsShowType: h = "hide",
|
|
162
|
+
spaceBetween: f = 0,
|
|
163
|
+
showPaginationText: j
|
|
164
|
+
} = n, I = Object.fromEntries(
|
|
165
|
+
Object.entries(n).filter(([d]) => d !== "children")
|
|
166
|
+
), k = T(null), m = Math.ceil(u / Math.floor(g)), A = (a || h && h !== "hide" || j) && m > 1;
|
|
167
|
+
function B(d) {
|
|
168
|
+
if (Math.ceil(Math.abs(d.currentTarget.scrollLeft)) + d.currentTarget.clientWidth === d.currentTarget.scrollWidth) {
|
|
169
|
+
s(m - 1);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const p = d.currentTarget.scrollWidth / m, w = (d.currentTarget.scrollWidth - d.currentTarget.scrollLeft) / p;
|
|
173
|
+
if (w <= m) {
|
|
174
|
+
s(0);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
s(Math.round(w % m));
|
|
178
|
+
}
|
|
179
|
+
function L(d) {
|
|
180
|
+
if (!k.current) return;
|
|
181
|
+
const p = k.current.offsetWidth;
|
|
182
|
+
d < 0 ? k.current.scrollTo({ behavior: "smooth", left: -(p * m) }) : d >= m ? k.current.scrollTo({ behavior: "smooth", left: 0 }) : i > d ? k.current.scrollBy({ behavior: "smooth", left: p }) : k.current.scrollBy({ behavior: "smooth", left: -p });
|
|
183
|
+
}
|
|
184
|
+
function b() {
|
|
185
|
+
const p = Object.keys(e.responsive).sort().findLast(
|
|
186
|
+
(W) => Number(W) <= window.innerWidth
|
|
187
|
+
), w = p ? e.responsive[Number(p)] : null;
|
|
188
|
+
t(w ? { ...n, ...w } : e);
|
|
189
|
+
}
|
|
190
|
+
return x(() => {
|
|
191
|
+
k.current && l(k.current.childNodes.length);
|
|
192
|
+
}, [e.children]), x(() => {
|
|
193
|
+
if (!(!e.responsive || Object.keys(e.responsive).length <= 0))
|
|
194
|
+
return b(), window.addEventListener("resize", b), () => {
|
|
195
|
+
window.removeEventListener("resize", b);
|
|
196
|
+
};
|
|
197
|
+
}, [e.responsive]), /* @__PURE__ */ r(P.Provider, { value: I, children: /* @__PURE__ */ y(
|
|
198
|
+
"div",
|
|
199
|
+
{
|
|
200
|
+
className: v(
|
|
201
|
+
"dgs-ui-kit-overflow-hidden dgs-ui-kit-relative dgs-ui-kit-group",
|
|
202
|
+
o
|
|
203
|
+
),
|
|
204
|
+
style: { direction: "rtl" },
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ r(
|
|
207
|
+
"div",
|
|
208
|
+
{
|
|
209
|
+
className: v(
|
|
210
|
+
"dgs-ui-kit-flex dgs-ui-kit-snap-x dgs-ui-kit-snap-mandatory dgs-ui-kit-overflow-x-auto no-scrollbar",
|
|
211
|
+
c
|
|
212
|
+
),
|
|
213
|
+
style: { marginLeft: -f },
|
|
214
|
+
onScroll: B,
|
|
215
|
+
ref: k,
|
|
216
|
+
children: e.children
|
|
217
|
+
}
|
|
218
|
+
),
|
|
219
|
+
A && /* @__PURE__ */ r(
|
|
220
|
+
K,
|
|
221
|
+
{
|
|
222
|
+
onNavigate: L,
|
|
223
|
+
slideIndex: i,
|
|
224
|
+
slidesCount: m
|
|
225
|
+
}
|
|
226
|
+
)
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
) });
|
|
230
|
+
};
|
|
231
|
+
function z({
|
|
232
|
+
slidesPerView: e,
|
|
233
|
+
childIndex: i,
|
|
234
|
+
centerMode: s,
|
|
235
|
+
childrenCount: n
|
|
236
|
+
}) {
|
|
237
|
+
const t = i % Math.floor(e) === 0, u = e % 1 !== 0, l = i === 0, o = i === n - 1;
|
|
238
|
+
return t ? s && u ? l ? "start" : o ? "end" : "center" : "start" : "none";
|
|
239
|
+
}
|
|
240
|
+
const U = (e) => {
|
|
241
|
+
const { children: i, className: s, style: n, ...t } = e, {
|
|
242
|
+
slidesPerView: u = 1,
|
|
243
|
+
spaceBetween: l = 0,
|
|
244
|
+
centerMode: o = !1,
|
|
245
|
+
containerXPadding: c = 0
|
|
246
|
+
} = C(), a = T(null), [g, h] = N(0), f = a.current?.parentNode?.children.length;
|
|
247
|
+
return x(() => {
|
|
248
|
+
a.current && h(Array.prototype.indexOf.call(a.current.parentNode?.children, a.current));
|
|
249
|
+
}, [a]), /* @__PURE__ */ r(
|
|
250
|
+
"div",
|
|
251
|
+
{
|
|
252
|
+
...t,
|
|
253
|
+
ref: a,
|
|
254
|
+
className: v("dgs-ui-kit-shrink-0 dgs-ui-kit-snap-always", s),
|
|
255
|
+
style: {
|
|
256
|
+
width: 100 / (u ?? 1) + "%",
|
|
257
|
+
paddingLeft: f && g === f - 1 ? c + l : l,
|
|
258
|
+
paddingRight: g === 0 ? c : 0,
|
|
259
|
+
scrollSnapAlign: z({
|
|
260
|
+
slidesPerView: u,
|
|
261
|
+
childIndex: g,
|
|
262
|
+
centerMode: o,
|
|
263
|
+
childrenCount: f || 0
|
|
264
|
+
}),
|
|
265
|
+
...n
|
|
266
|
+
},
|
|
267
|
+
children: i
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
};
|
|
271
|
+
export {
|
|
272
|
+
Q as S,
|
|
273
|
+
U as a
|
|
274
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";const e=require("react/jsx-runtime"),x=require("./clsx-C11secjj.cjs"),u=require("react"),L=require("./ArrowLeft2-B76dkC-C.cjs"),A=require("./ArrowRight2-CYowPzS8.cjs"),j=require("./Button/index.cjs"),b=u.createContext({slidesPerView:1,spaceBetween:0,navigationVariant:"outside",showNavigationDots:!0,showPaginationText:!1}),N=()=>u.useContext(b);function B({active:i,autoplay:s,variant:n="outside"}){return[{inside:"dgs-ui-kit-bg-gray-500/50 hover:dgs-ui-kit-bg-gray-500/80",outside:"dgs-ui-kit-bg-gray-200 hover:dgs-ui-kit-bg-gray-300"}[n],i?"dgs-ui-kit-w-[22px]":"dgs-ui-kit-w-[6px]",s?"dgs-ui-kit-p-[1px]":""]}const W=i=>{const{active:s,onClick:n,onNavigateToNext:r}=i,{autoplay:t,navigationVariant:l="outside"}=N(),[c,o]=u.useState(0);return u.useEffect(()=>{if(!s||!t)return;const g=typeof t=="boolean"?7e3:t?.delay??7e3;let a=Date.now();const h=setInterval(()=>{const f=Date.now()-a,k=f/g*100;o(Math.min(k,100)),f>=g&&typeof r=="function"&&r()},100);return function(){return o(0),a=Date.now(),clearInterval(h)}},[s,t,r]),e.jsx("button",{className:x.clsx("dgs-ui-kit-rounded-full dgs-ui-kit-overflow-hidden dgs-ui-kit-transition-all dgs-ui-kit-h-[6px]",B({active:s,autoplay:t,variant:l})),onClick:n,children:s&&e.jsx("div",{className:x.clsx("dgs-ui-kit-h-full dgs-ui-kit-rounded-full",{"dgs-ui-kit-bg-white":l==="inside","dgs-ui-kit-bg-gray-700":l==="outside"}),style:{width:t?`${c}%`:"100%"}})})},D=i=>{const{onNavigate:s,slideIndex:n,slidesCount:r}=i,{navigationButtonsShowType:t="hide",dotsClassName:l,navigationContainerClassName:c,navigationVariant:o="outside",showNavigationDots:g=!0,showPaginationText:a}=N(),h=e.jsxs("div",{className:x.clsx("dgs-ui-kit-flex dgs-ui-kit-gap-2",{"dgs-ui-kit-absolute dgs-ui-kit-bottom-0 dgs-ui-kit-left-[5.5%]":o==="inside"&&t!=="onSides","dgs-ui-kit-absolute dgs-ui-kit-justify-between dgs-ui-kit-top-1/2 -dgs-ui-kit-translate-y-1/2 dgs-ui-kit-w-full dgs-ui-kit-px-[5.5%]":t==="onSides","dgs-ui-kit-opacity-0 group-hover:dgs-ui-kit-opacity-100 dgs-ui-kit-transition":t==="hover"||t==="onSides"}),children:[e.jsx(j,{type:"button",variant:"secondary",onClick:()=>s(n-1),rightIcon:e.jsx(A.ArrowRight2Icon,{})}),e.jsx(j,{type:"button",variant:"secondary",onClick:()=>s(n+1),rightIcon:e.jsx(L.ArrowLeft2Icon,{})})]});return e.jsxs(e.Fragment,{children:[t&&t!=="hide"&&t==="onSides"&&h,e.jsxs("div",{className:x.clsx("dgs-ui-kit-flex",{"dgs-ui-kit-items-center dgs-ui-kit-mt-2":o==="outside","dgs-ui-kit-absolute dgs-ui-kit-bottom-4 dgs-ui-kit-w-full dgs-ui-kit-justify-center":o==="inside","dgs-ui-kit-justify-between":o==="outside"&&t!=="hide"&&t!=="onSides","dgs-ui-kit-justify-center":o==="outside"&&(t==="hide"||t==="onSides")},c),children:[t&&t!=="hide"&&t!=="onSides"&&h,(g||a)&&e.jsxs("div",{className:"dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-3",children:[a&&e.jsxs("div",{className:"dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-1 dgs-ui-kit-font-caption-regular dgs-ui-kit-text-gray-400 ss02",children:[e.jsx("span",{className:x.clsx("dgs-ui-kit-font-bold",{"dgs-ui-kit-text-gray-600":o==="outside","dgs-ui-kit-text-white":o==="inside"}),children:n+1}),e.jsx("span",{children:"از"}),e.jsx("span",{children:r})]}),g&&e.jsx("div",{className:x.clsx("dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-justify-center dgs-ui-kit-gap-2",l),children:Array.from(Array(r).keys()).map((f,k)=>e.jsx(W,{active:n===k,onClick:()=>s(k),onNavigateToNext:()=>s(n+1)},f+r))})]})]})]})},M=i=>{const[s,n]=u.useState(0),[r,t]=u.useState(i),[l,c]=u.useState(0),{className:o="",containerClassName:g="",showNavigationDots:a=!0,slidesPerView:h=1,navigationButtonsShowType:f="hide",spaceBetween:k=0,showPaginationText:C}=r,S=Object.fromEntries(Object.entries(r).filter(([d])=>d!=="children")),v=u.useRef(null),y=Math.ceil(l/Math.floor(h)),T=(a||f&&f!=="hide"||C)&&y>1;function P(d){if(Math.ceil(Math.abs(d.currentTarget.scrollLeft))+d.currentTarget.clientWidth===d.currentTarget.scrollWidth){n(y-1);return}const p=d.currentTarget.scrollWidth/y,m=(d.currentTarget.scrollWidth-d.currentTarget.scrollLeft)/p;if(m<=y){n(0);return}n(Math.round(m%y))}function R(d){if(!v.current)return;const p=v.current.offsetWidth;d<0?v.current.scrollTo({behavior:"smooth",left:-(p*y)}):d>=y?v.current.scrollTo({behavior:"smooth",left:0}):s>d?v.current.scrollBy({behavior:"smooth",left:p}):v.current.scrollBy({behavior:"smooth",left:-p})}function w(){const p=Object.keys(i.responsive).sort().findLast(I=>Number(I)<=window.innerWidth),m=p?i.responsive[Number(p)]:null;t(m?{...r,...m}:i)}return u.useEffect(()=>{v.current&&c(v.current.childNodes.length)},[i.children]),u.useEffect(()=>{if(!(!i.responsive||Object.keys(i.responsive).length<=0))return w(),window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w)}},[i.responsive]),e.jsx(b.Provider,{value:S,children:e.jsxs("div",{className:x.clsx("dgs-ui-kit-overflow-hidden dgs-ui-kit-relative dgs-ui-kit-group",o),style:{direction:"rtl"},children:[e.jsx("div",{className:x.clsx("dgs-ui-kit-flex dgs-ui-kit-snap-x dgs-ui-kit-snap-mandatory dgs-ui-kit-overflow-x-auto no-scrollbar",g),style:{marginLeft:-k},onScroll:P,ref:v,children:i.children}),T&&e.jsx(D,{onNavigate:R,slideIndex:s,slidesCount:y})]})})};function E({slidesPerView:i,childIndex:s,centerMode:n,childrenCount:r}){const t=s%Math.floor(i)===0,l=i%1!==0,c=s===0,o=s===r-1;return t?n&&l?c?"start":o?"end":"center":"start":"none"}const q=i=>{const{children:s,className:n,style:r,...t}=i,{slidesPerView:l=1,spaceBetween:c=0,centerMode:o=!1,containerXPadding:g=0}=N(),a=u.useRef(null),[h,f]=u.useState(0),k=a.current?.parentNode?.children.length;return u.useEffect(()=>{a.current&&f(Array.prototype.indexOf.call(a.current.parentNode?.children,a.current))},[a]),e.jsx("div",{...t,ref:a,className:x.clsx("dgs-ui-kit-shrink-0 dgs-ui-kit-snap-always",n),style:{width:100/(l??1)+"%",paddingLeft:k&&h===k-1?g+c:c,paddingRight:h===0?g:0,scrollSnapAlign:E({slidesPerView:l,childIndex:h,centerMode:o,childrenCount:k||0}),...r},children:s})};exports.Slide=q;exports.Slider=M;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slide.d.ts","sourceRoot":"","sources":["../../src/components/Slider/Slide.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,EAAE,EACP,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Slide.d.ts","sourceRoot":"","sources":["../../src/components/Slider/Slide.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,EAAE,EACP,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,OAAO,CAAC;AA4Bf,QAAA,MAAM,KAAK,EAAE,EAAE,CACb,iBAAiB,CAAC,iBAAiB,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC,CAAC,CA0CrF,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.d.ts","sourceRoot":"","sources":["../../src/components/Slider/Slider.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"Slider.d.ts","sourceRoot":"","sources":["../../src/components/Slider/Slider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAA2B,MAAM,OAAO,CAAC;AAInG,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EACL,OAAO,GACP;QACE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,CAAC;IACN,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,iBAAiB,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACzC,yBAAyB,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,CAAC;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;IAC7D,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,QAAA,MAAM,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAoH9C,CAAC;AAEF,eAAe,MAAM,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-DAapDHVY.cjs");exports.Slide=e.Slide;exports.Slider=e.Slider;
|
package/dist/Slider/index.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./assets/styles.css');;/* empty css */const r=require("./AccordionItem-AwBSlD0h.cjs"),o=require("./Alert/index.cjs"),t=require("./Badge/index.cjs"),i=require("./Breadcrumb/index.cjs"),n=require("./Button/index.cjs"),c=require("./Divider/index.cjs"),u=require("./Drawer/index.cjs"),s=require("./Form/Checkbox/index.cjs"),a=require("./Form/Input/index.cjs"),d=require("./Form/OtpInput/index.cjs"),q=require("./Form/RadioButton/index.cjs"),m=require("./Form/Textarea/index.cjs"),l=require("./Pagination/index.cjs"),B=require("./Progress/Bar/index.cjs"),e=require("./Slide-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./assets/styles.css');;/* empty css */const r=require("./AccordionItem-AwBSlD0h.cjs"),o=require("./Alert/index.cjs"),t=require("./Badge/index.cjs"),i=require("./Breadcrumb/index.cjs"),n=require("./Button/index.cjs"),c=require("./Divider/index.cjs"),u=require("./Drawer/index.cjs"),s=require("./Form/Checkbox/index.cjs"),a=require("./Form/Input/index.cjs"),d=require("./Form/OtpInput/index.cjs"),q=require("./Form/RadioButton/index.cjs"),m=require("./Form/Textarea/index.cjs"),l=require("./Pagination/index.cjs"),B=require("./Progress/Bar/index.cjs"),e=require("./Slide-DAapDHVY.cjs"),p=require("./Tabs/index.cjs");exports.AccordionGroup=r.AccordionGroup;exports.AccordionItem=r.AccordionItem;exports.Alert=o;exports.Badge=t;exports.Breadcrumb=i;exports.Button=n;exports.Divider=c;exports.Drawer=u;exports.Checkbox=s;exports.Input=a;exports.OtpInput=d;exports.RadioButton=q;exports.Textarea=m;exports.Pagination=l;exports.ProgressBar=B;exports.Slide=e.Slide;exports.Slider=e.Slider;exports.Tabs=p;
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { default as T } from "./Form/RadioButton/index.js";
|
|
|
13
13
|
import { default as k } from "./Form/Textarea/index.js";
|
|
14
14
|
import { default as w } from "./Pagination/index.js";
|
|
15
15
|
import { default as G } from "./Progress/Bar/index.js";
|
|
16
|
-
import { a as R, S as j } from "./Slide-
|
|
16
|
+
import { a as R, S as j } from "./Slide-CQBJqAor.js";
|
|
17
17
|
import { default as y } from "./Tabs/index.js";
|
|
18
18
|
export {
|
|
19
19
|
e as AccordionGroup,
|
package/package.json
CHANGED
package/dist/Slide-BEZZ-Egi.js
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as r, jsxs as y, Fragment as M } from "react/jsx-runtime";
|
|
3
|
-
import { c as f } from "./clsx-OuTLNxxd.js";
|
|
4
|
-
import { createContext as B, useContext as R, useState as x, useEffect as S, useRef as j, Children as V } from "react";
|
|
5
|
-
import { A as O } from "./ArrowLeft2-jP2w1vwt.js";
|
|
6
|
-
import { A as E } from "./ArrowRight2-CcHdxGRE.js";
|
|
7
|
-
import T from "./Button/index.js";
|
|
8
|
-
const I = B({
|
|
9
|
-
slidesPerView: 1,
|
|
10
|
-
spaceBetween: 0,
|
|
11
|
-
navigationVariant: "outside",
|
|
12
|
-
showNavigationDots: !0,
|
|
13
|
-
showPaginationText: !1
|
|
14
|
-
}), P = () => R(I);
|
|
15
|
-
function K({
|
|
16
|
-
active: i,
|
|
17
|
-
autoplay: e,
|
|
18
|
-
variant: s = "outside"
|
|
19
|
-
}) {
|
|
20
|
-
return [
|
|
21
|
-
{
|
|
22
|
-
inside: "dgs-ui-kit-bg-gray-500/50 hover:dgs-ui-kit-bg-gray-500/80",
|
|
23
|
-
outside: "dgs-ui-kit-bg-gray-200 hover:dgs-ui-kit-bg-gray-300"
|
|
24
|
-
}[s],
|
|
25
|
-
i ? "dgs-ui-kit-w-[22px]" : "dgs-ui-kit-w-[6px]",
|
|
26
|
-
e ? "dgs-ui-kit-p-[1px]" : ""
|
|
27
|
-
];
|
|
28
|
-
}
|
|
29
|
-
const z = (i) => {
|
|
30
|
-
const { active: e, onClick: s, onNavigateToNext: n } = i, { autoplay: t, navigationVariant: l = "outside" } = P(), [k, a] = x(0);
|
|
31
|
-
return S(() => {
|
|
32
|
-
if (!e || !t) return;
|
|
33
|
-
const u = typeof t == "boolean" ? 7e3 : t?.delay ?? 7e3;
|
|
34
|
-
let o = Date.now();
|
|
35
|
-
const c = setInterval(() => {
|
|
36
|
-
const h = Date.now() - o, g = h / u * 100;
|
|
37
|
-
a(Math.min(g, 100)), h >= u && typeof n == "function" && n();
|
|
38
|
-
}, 100);
|
|
39
|
-
return function() {
|
|
40
|
-
return a(0), o = Date.now(), clearInterval(c);
|
|
41
|
-
};
|
|
42
|
-
}, [e, t, n]), /* @__PURE__ */ r(
|
|
43
|
-
"button",
|
|
44
|
-
{
|
|
45
|
-
className: f(
|
|
46
|
-
"dgs-ui-kit-rounded-full dgs-ui-kit-overflow-hidden dgs-ui-kit-transition-all dgs-ui-kit-h-[6px]",
|
|
47
|
-
K({ active: e, autoplay: t, variant: l })
|
|
48
|
-
),
|
|
49
|
-
onClick: s,
|
|
50
|
-
children: e && /* @__PURE__ */ r(
|
|
51
|
-
"div",
|
|
52
|
-
{
|
|
53
|
-
className: f("dgs-ui-kit-h-full dgs-ui-kit-rounded-full", {
|
|
54
|
-
"dgs-ui-kit-bg-white": l === "inside",
|
|
55
|
-
"dgs-ui-kit-bg-gray-700": l === "outside"
|
|
56
|
-
}),
|
|
57
|
-
style: { width: t ? `${k}%` : "100%" }
|
|
58
|
-
}
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
}, F = (i) => {
|
|
63
|
-
const { onNavigate: e, slideIndex: s, slidesCount: n } = i, {
|
|
64
|
-
navigationButtonsShowType: t = "hide",
|
|
65
|
-
dotsClassName: l,
|
|
66
|
-
navigationContainerClassName: k,
|
|
67
|
-
navigationVariant: a = "outside",
|
|
68
|
-
showNavigationDots: u = !0,
|
|
69
|
-
showPaginationText: o
|
|
70
|
-
} = P(), c = /* @__PURE__ */ y(
|
|
71
|
-
"div",
|
|
72
|
-
{
|
|
73
|
-
className: f("dgs-ui-kit-flex dgs-ui-kit-gap-2", {
|
|
74
|
-
"dgs-ui-kit-absolute dgs-ui-kit-bottom-0 dgs-ui-kit-left-[5.5%]": a === "inside" && t !== "onSides",
|
|
75
|
-
"dgs-ui-kit-absolute dgs-ui-kit-justify-between dgs-ui-kit-top-1/2 -dgs-ui-kit-translate-y-1/2 dgs-ui-kit-w-full dgs-ui-kit-px-[5.5%]": t === "onSides",
|
|
76
|
-
"dgs-ui-kit-opacity-0 group-hover:dgs-ui-kit-opacity-100 dgs-ui-kit-transition": t === "hover" || t === "onSides"
|
|
77
|
-
}),
|
|
78
|
-
children: [
|
|
79
|
-
/* @__PURE__ */ r(
|
|
80
|
-
T,
|
|
81
|
-
{
|
|
82
|
-
type: "button",
|
|
83
|
-
variant: "secondary",
|
|
84
|
-
onClick: () => e(s - 1),
|
|
85
|
-
rightIcon: /* @__PURE__ */ r(E, {})
|
|
86
|
-
}
|
|
87
|
-
),
|
|
88
|
-
/* @__PURE__ */ r(
|
|
89
|
-
T,
|
|
90
|
-
{
|
|
91
|
-
type: "button",
|
|
92
|
-
variant: "secondary",
|
|
93
|
-
onClick: () => e(s + 1),
|
|
94
|
-
rightIcon: /* @__PURE__ */ r(O, {})
|
|
95
|
-
}
|
|
96
|
-
)
|
|
97
|
-
]
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
return /* @__PURE__ */ y(M, { children: [
|
|
101
|
-
t && t !== "hide" && t === "onSides" && c,
|
|
102
|
-
/* @__PURE__ */ y(
|
|
103
|
-
"div",
|
|
104
|
-
{
|
|
105
|
-
className: f(
|
|
106
|
-
"dgs-ui-kit-flex",
|
|
107
|
-
{
|
|
108
|
-
"dgs-ui-kit-items-center dgs-ui-kit-mt-2": a === "outside",
|
|
109
|
-
"dgs-ui-kit-absolute dgs-ui-kit-bottom-4 dgs-ui-kit-w-full dgs-ui-kit-justify-center": a === "inside",
|
|
110
|
-
"dgs-ui-kit-justify-between": a === "outside" && t !== "hide" && t !== "onSides",
|
|
111
|
-
"dgs-ui-kit-justify-center": a === "outside" && (t === "hide" || t === "onSides")
|
|
112
|
-
},
|
|
113
|
-
k
|
|
114
|
-
),
|
|
115
|
-
children: [
|
|
116
|
-
t && t !== "hide" && t !== "onSides" && c,
|
|
117
|
-
(u || o) && /* @__PURE__ */ y("div", { className: "dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-3", children: [
|
|
118
|
-
o && /* @__PURE__ */ y("div", { className: "dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-1 dgs-ui-kit-font-caption-regular dgs-ui-kit-text-gray-400 ss02", children: [
|
|
119
|
-
/* @__PURE__ */ r(
|
|
120
|
-
"span",
|
|
121
|
-
{
|
|
122
|
-
className: f("dgs-ui-kit-font-bold", {
|
|
123
|
-
"dgs-ui-kit-text-gray-600": a === "outside",
|
|
124
|
-
"dgs-ui-kit-text-white": a === "inside"
|
|
125
|
-
}),
|
|
126
|
-
children: s + 1
|
|
127
|
-
}
|
|
128
|
-
),
|
|
129
|
-
/* @__PURE__ */ r("span", { children: "از" }),
|
|
130
|
-
/* @__PURE__ */ r("span", { children: n })
|
|
131
|
-
] }),
|
|
132
|
-
u && /* @__PURE__ */ r(
|
|
133
|
-
"div",
|
|
134
|
-
{
|
|
135
|
-
className: f(
|
|
136
|
-
"dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-justify-center dgs-ui-kit-gap-2",
|
|
137
|
-
l
|
|
138
|
-
),
|
|
139
|
-
children: Array.from(Array(n).keys()).map((h, g) => /* @__PURE__ */ r(
|
|
140
|
-
z,
|
|
141
|
-
{
|
|
142
|
-
active: s === g,
|
|
143
|
-
onClick: () => e(g),
|
|
144
|
-
onNavigateToNext: () => e(s + 1)
|
|
145
|
-
},
|
|
146
|
-
h + n
|
|
147
|
-
))
|
|
148
|
-
}
|
|
149
|
-
)
|
|
150
|
-
] })
|
|
151
|
-
]
|
|
152
|
-
}
|
|
153
|
-
)
|
|
154
|
-
] });
|
|
155
|
-
}, U = (i) => {
|
|
156
|
-
const [e, s] = x(0), [n, t] = x(i), {
|
|
157
|
-
className: l = "",
|
|
158
|
-
containerClassName: k = "",
|
|
159
|
-
showNavigationDots: a = !0,
|
|
160
|
-
slidesPerView: u = 1,
|
|
161
|
-
navigationButtonsShowType: o = "hide",
|
|
162
|
-
spaceBetween: c = 0,
|
|
163
|
-
showPaginationText: h
|
|
164
|
-
} = n, g = Object.fromEntries(
|
|
165
|
-
Object.entries(n).filter(([d]) => d !== "children")
|
|
166
|
-
), w = j(null), L = V.count(i.children), v = Math.ceil(L / Math.floor(u)), W = (a || o && o !== "hide" || h) && v > 1;
|
|
167
|
-
function A(d) {
|
|
168
|
-
if (Math.ceil(Math.abs(d.currentTarget.scrollLeft)) + d.currentTarget.clientWidth === d.currentTarget.scrollWidth) {
|
|
169
|
-
s(v - 1);
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
const m = d.currentTarget.scrollWidth / v, p = (d.currentTarget.scrollWidth - d.currentTarget.scrollLeft) / m;
|
|
173
|
-
if (p <= v) {
|
|
174
|
-
s(0);
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
s(Math.round(p % v));
|
|
178
|
-
}
|
|
179
|
-
function D(d) {
|
|
180
|
-
if (!w.current) return;
|
|
181
|
-
const m = u % 1 !== 0, p = w.current.offsetWidth, N = m ? p / u : p;
|
|
182
|
-
let C = -(N * d);
|
|
183
|
-
d < 0 ? C = -(N * v) : d >= v && (C = 0), w.current.scrollTo({
|
|
184
|
-
left: C,
|
|
185
|
-
behavior: "smooth"
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
function b() {
|
|
189
|
-
const m = Object.keys(i.responsive).sort().findLast(
|
|
190
|
-
(N) => Number(N) <= window.innerWidth
|
|
191
|
-
), p = m ? i.responsive[Number(m)] : null;
|
|
192
|
-
t(p ? { ...n, ...p } : i);
|
|
193
|
-
}
|
|
194
|
-
return S(() => {
|
|
195
|
-
if (!(!i.responsive || Object.keys(i.responsive).length <= 0))
|
|
196
|
-
return b(), window.addEventListener("resize", b), () => {
|
|
197
|
-
window.removeEventListener("resize", b);
|
|
198
|
-
};
|
|
199
|
-
}, [i.responsive]), /* @__PURE__ */ r(I.Provider, { value: g, children: /* @__PURE__ */ y(
|
|
200
|
-
"div",
|
|
201
|
-
{
|
|
202
|
-
className: f(
|
|
203
|
-
"dgs-ui-kit-overflow-hidden dgs-ui-kit-relative dgs-ui-kit-group",
|
|
204
|
-
l
|
|
205
|
-
),
|
|
206
|
-
style: { direction: "rtl" },
|
|
207
|
-
children: [
|
|
208
|
-
/* @__PURE__ */ r(
|
|
209
|
-
"div",
|
|
210
|
-
{
|
|
211
|
-
className: f(
|
|
212
|
-
"dgs-ui-kit-flex dgs-ui-kit-snap-x dgs-ui-kit-snap-mandatory dgs-ui-kit-overflow-x-auto no-scrollbar",
|
|
213
|
-
k
|
|
214
|
-
),
|
|
215
|
-
style: { marginLeft: -c },
|
|
216
|
-
onScroll: A,
|
|
217
|
-
ref: w,
|
|
218
|
-
children: i.children
|
|
219
|
-
}
|
|
220
|
-
),
|
|
221
|
-
W && /* @__PURE__ */ r(
|
|
222
|
-
F,
|
|
223
|
-
{
|
|
224
|
-
onNavigate: D,
|
|
225
|
-
slideIndex: e,
|
|
226
|
-
slidesCount: v
|
|
227
|
-
}
|
|
228
|
-
)
|
|
229
|
-
]
|
|
230
|
-
}
|
|
231
|
-
) });
|
|
232
|
-
};
|
|
233
|
-
function X({
|
|
234
|
-
slidesPerView: i,
|
|
235
|
-
childIndex: e,
|
|
236
|
-
centerMode: s,
|
|
237
|
-
childsLength: n
|
|
238
|
-
}) {
|
|
239
|
-
return e % Math.floor(i) !== 0 ? "none" : s && i % 1 !== 0 ? e === 0 ? "start" : e === n - 1 ? "end" : "center" : "start";
|
|
240
|
-
}
|
|
241
|
-
const Y = (i) => {
|
|
242
|
-
const { children: e, className: s, style: n, ...t } = i, {
|
|
243
|
-
slidesPerView: l = 1,
|
|
244
|
-
spaceBetween: k = 0,
|
|
245
|
-
centerMode: a = !1,
|
|
246
|
-
containerXPadding: u = 0
|
|
247
|
-
} = P(), o = j(null), [c, h] = x(0), g = o.current?.parentNode?.children.length;
|
|
248
|
-
return S(() => {
|
|
249
|
-
o.current && h(Array.prototype.indexOf.call(o.current.parentNode?.children, o.current));
|
|
250
|
-
}, [o]), /* @__PURE__ */ r(
|
|
251
|
-
"div",
|
|
252
|
-
{
|
|
253
|
-
...t,
|
|
254
|
-
ref: o,
|
|
255
|
-
className: f("dgs-ui-kit-shrink-0 dgs-ui-kit-snap-always", s),
|
|
256
|
-
style: {
|
|
257
|
-
width: 100 / (l ?? 1) + "%",
|
|
258
|
-
paddingLeft: g && c === g - 1 ? u + k : k,
|
|
259
|
-
paddingRight: c === 0 ? u : 0,
|
|
260
|
-
scrollSnapAlign: X({
|
|
261
|
-
slidesPerView: l,
|
|
262
|
-
childIndex: c,
|
|
263
|
-
centerMode: a,
|
|
264
|
-
childsLength: g || 0
|
|
265
|
-
}),
|
|
266
|
-
...n
|
|
267
|
-
},
|
|
268
|
-
children: e
|
|
269
|
-
}
|
|
270
|
-
);
|
|
271
|
-
};
|
|
272
|
-
export {
|
|
273
|
-
U as S,
|
|
274
|
-
Y as a
|
|
275
|
-
};
|
package/dist/Slide-C1oVFHZo.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use client";"use strict";const e=require("react/jsx-runtime"),k=require("./clsx-C11secjj.cjs"),c=require("react"),I=require("./ArrowLeft2-B76dkC-C.cjs"),W=require("./ArrowRight2-CYowPzS8.cjs"),S=require("./Button/index.cjs"),C=c.createContext({slidesPerView:1,spaceBetween:0,navigationVariant:"outside",showNavigationDots:!0,showPaginationText:!1}),b=()=>c.useContext(C);function A({active:i,autoplay:s,variant:n="outside"}){return[{inside:"dgs-ui-kit-bg-gray-500/50 hover:dgs-ui-kit-bg-gray-500/80",outside:"dgs-ui-kit-bg-gray-200 hover:dgs-ui-kit-bg-gray-300"}[n],i?"dgs-ui-kit-w-[22px]":"dgs-ui-kit-w-[6px]",s?"dgs-ui-kit-p-[1px]":""]}const D=i=>{const{active:s,onClick:n,onNavigateToNext:r}=i,{autoplay:t,navigationVariant:l="outside"}=b(),[v,a]=c.useState(0);return c.useEffect(()=>{if(!s||!t)return;const u=typeof t=="boolean"?7e3:t?.delay??7e3;let o=Date.now();const g=setInterval(()=>{const f=Date.now()-o,h=f/u*100;a(Math.min(h,100)),f>=u&&typeof r=="function"&&r()},100);return function(){return a(0),o=Date.now(),clearInterval(g)}},[s,t,r]),e.jsx("button",{className:k.clsx("dgs-ui-kit-rounded-full dgs-ui-kit-overflow-hidden dgs-ui-kit-transition-all dgs-ui-kit-h-[6px]",A({active:s,autoplay:t,variant:l})),onClick:n,children:s&&e.jsx("div",{className:k.clsx("dgs-ui-kit-h-full dgs-ui-kit-rounded-full",{"dgs-ui-kit-bg-white":l==="inside","dgs-ui-kit-bg-gray-700":l==="outside"}),style:{width:t?`${v}%`:"100%"}})})},M=i=>{const{onNavigate:s,slideIndex:n,slidesCount:r}=i,{navigationButtonsShowType:t="hide",dotsClassName:l,navigationContainerClassName:v,navigationVariant:a="outside",showNavigationDots:u=!0,showPaginationText:o}=b(),g=e.jsxs("div",{className:k.clsx("dgs-ui-kit-flex dgs-ui-kit-gap-2",{"dgs-ui-kit-absolute dgs-ui-kit-bottom-0 dgs-ui-kit-left-[5.5%]":a==="inside"&&t!=="onSides","dgs-ui-kit-absolute dgs-ui-kit-justify-between dgs-ui-kit-top-1/2 -dgs-ui-kit-translate-y-1/2 dgs-ui-kit-w-full dgs-ui-kit-px-[5.5%]":t==="onSides","dgs-ui-kit-opacity-0 group-hover:dgs-ui-kit-opacity-100 dgs-ui-kit-transition":t==="hover"||t==="onSides"}),children:[e.jsx(S,{type:"button",variant:"secondary",onClick:()=>s(n-1),rightIcon:e.jsx(W.ArrowRight2Icon,{})}),e.jsx(S,{type:"button",variant:"secondary",onClick:()=>s(n+1),rightIcon:e.jsx(I.ArrowLeft2Icon,{})})]});return e.jsxs(e.Fragment,{children:[t&&t!=="hide"&&t==="onSides"&&g,e.jsxs("div",{className:k.clsx("dgs-ui-kit-flex",{"dgs-ui-kit-items-center dgs-ui-kit-mt-2":a==="outside","dgs-ui-kit-absolute dgs-ui-kit-bottom-4 dgs-ui-kit-w-full dgs-ui-kit-justify-center":a==="inside","dgs-ui-kit-justify-between":a==="outside"&&t!=="hide"&&t!=="onSides","dgs-ui-kit-justify-center":a==="outside"&&(t==="hide"||t==="onSides")},v),children:[t&&t!=="hide"&&t!=="onSides"&&g,(u||o)&&e.jsxs("div",{className:"dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-3",children:[o&&e.jsxs("div",{className:"dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-1 dgs-ui-kit-font-caption-regular dgs-ui-kit-text-gray-400 ss02",children:[e.jsx("span",{className:k.clsx("dgs-ui-kit-font-bold",{"dgs-ui-kit-text-gray-600":a==="outside","dgs-ui-kit-text-white":a==="inside"}),children:n+1}),e.jsx("span",{children:"از"}),e.jsx("span",{children:r})]}),u&&e.jsx("div",{className:k.clsx("dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-justify-center dgs-ui-kit-gap-2",l),children:Array.from(Array(r).keys()).map((f,h)=>e.jsx(D,{active:n===h,onClick:()=>s(h),onNavigateToNext:()=>s(n+1)},f+r))})]})]})]})},B=i=>{const[s,n]=c.useState(0),[r,t]=c.useState(i),{className:l="",containerClassName:v="",showNavigationDots:a=!0,slidesPerView:u=1,navigationButtonsShowType:o="hide",spaceBetween:g=0,showPaginationText:f}=r,h=Object.fromEntries(Object.entries(r).filter(([d])=>d!=="children")),m=c.useRef(null),P=c.Children.count(i.children),x=Math.ceil(P/Math.floor(u)),T=(a||o&&o!=="hide"||f)&&x>1;function L(d){if(Math.ceil(Math.abs(d.currentTarget.scrollLeft))+d.currentTarget.clientWidth===d.currentTarget.scrollWidth){n(x-1);return}const y=d.currentTarget.scrollWidth/x,p=(d.currentTarget.scrollWidth-d.currentTarget.scrollLeft)/y;if(p<=x){n(0);return}n(Math.round(p%x))}function R(d){if(!m.current)return;const y=u%1!==0,p=m.current.offsetWidth,w=y?p/u:p;let j=-(w*d);d<0?j=-(w*x):d>=x&&(j=0),m.current.scrollTo({left:j,behavior:"smooth"})}function N(){const y=Object.keys(i.responsive).sort().findLast(w=>Number(w)<=window.innerWidth),p=y?i.responsive[Number(y)]:null;t(p?{...r,...p}:i)}return c.useEffect(()=>{if(!(!i.responsive||Object.keys(i.responsive).length<=0))return N(),window.addEventListener("resize",N),()=>{window.removeEventListener("resize",N)}},[i.responsive]),e.jsx(C.Provider,{value:h,children:e.jsxs("div",{className:k.clsx("dgs-ui-kit-overflow-hidden dgs-ui-kit-relative dgs-ui-kit-group",l),style:{direction:"rtl"},children:[e.jsx("div",{className:k.clsx("dgs-ui-kit-flex dgs-ui-kit-snap-x dgs-ui-kit-snap-mandatory dgs-ui-kit-overflow-x-auto no-scrollbar",v),style:{marginLeft:-g},onScroll:L,ref:m,children:i.children}),T&&e.jsx(M,{onNavigate:R,slideIndex:s,slidesCount:x})]})})};function q({slidesPerView:i,childIndex:s,centerMode:n,childsLength:r}){return s%Math.floor(i)!==0?"none":n&&i%1!==0?s===0?"start":s===r-1?"end":"center":"start"}const E=i=>{const{children:s,className:n,style:r,...t}=i,{slidesPerView:l=1,spaceBetween:v=0,centerMode:a=!1,containerXPadding:u=0}=b(),o=c.useRef(null),[g,f]=c.useState(0),h=o.current?.parentNode?.children.length;return c.useEffect(()=>{o.current&&f(Array.prototype.indexOf.call(o.current.parentNode?.children,o.current))},[o]),e.jsx("div",{...t,ref:o,className:k.clsx("dgs-ui-kit-shrink-0 dgs-ui-kit-snap-always",n),style:{width:100/(l??1)+"%",paddingLeft:h&&g===h-1?u+v:v,paddingRight:g===0?u:0,scrollSnapAlign:q({slidesPerView:l,childIndex:g,centerMode:a,childsLength:h||0}),...r},children:s})};exports.Slide=E;exports.Slider=B;
|