@dgshahr/ui-kit 0.0.33 → 0.0.35

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