@dgshahr/ui-kit 0.0.52 → 0.0.53

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.
@@ -15,8 +15,8 @@ const M = F({
15
15
  sliderId: ""
16
16
  }), A = () => K(M);
17
17
  function G({
18
- active: i,
19
- autoplay: e,
18
+ active: e,
19
+ autoplay: i,
20
20
  variant: n = "outside"
21
21
  }) {
22
22
  return [
@@ -24,56 +24,56 @@ function G({
24
24
  inside: "dgs-ui-kit-bg-gray-500/50 hover:dgs-ui-kit-bg-gray-500/80",
25
25
  outside: "dgs-ui-kit-bg-gray-200 hover:dgs-ui-kit-bg-gray-300"
26
26
  }[n],
27
- i ? "dgs-ui-kit-w-[22px]" : "dgs-ui-kit-w-[6px]",
28
- e ? "dgs-ui-kit-p-[1px]" : ""
27
+ e ? "dgs-ui-kit-w-[22px]" : "dgs-ui-kit-w-[6px]",
28
+ i ? "dgs-ui-kit-p-[1px]" : ""
29
29
  ];
30
30
  }
31
- const J = (i) => {
32
- const { active: e, onClick: n, onNavigateToNext: a } = i, { autoplay: t, navigationVariant: c = "outside" } = A(), [k, r] = b(0);
31
+ const J = (e) => {
32
+ const { active: i, onClick: n, onNavigateToNext: a } = e, { autoplay: t, navigationVariant: c = "outside" } = A(), [m, s] = b(0);
33
33
  return C(() => {
34
- if (!e || !t) return;
34
+ if (!i || !t) return;
35
35
  const l = typeof t == "boolean" ? 7e3 : t?.delay ?? 7e3;
36
36
  let g = Date.now();
37
- const m = setInterval(() => {
38
- const d = Date.now() - g, f = d / l * 100;
39
- r(Math.min(f, 100)), d >= l && typeof a == "function" && a();
37
+ const f = setInterval(() => {
38
+ const d = Date.now() - g, k = d / l * 100;
39
+ s(Math.min(k, 100)), d >= l && typeof a == "function" && (a(), s(0), clearInterval(f));
40
40
  }, 100);
41
41
  return function() {
42
- return r(0), g = Date.now(), clearInterval(m);
42
+ return s(0), g = Date.now(), clearInterval(f);
43
43
  };
44
- }, [e, t, a]), /* @__PURE__ */ o(
44
+ }, [i, t, a]), /* @__PURE__ */ o(
45
45
  "button",
46
46
  {
47
47
  className: p(
48
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: c })
49
+ G({ active: i, autoplay: t, variant: c })
50
50
  ),
51
51
  onClick: n,
52
- children: e && /* @__PURE__ */ o(
52
+ children: i && /* @__PURE__ */ o(
53
53
  "div",
54
54
  {
55
55
  className: p("dgs-ui-kit-h-full dgs-ui-kit-rounded-full", {
56
56
  "dgs-ui-kit-bg-white": c === "inside",
57
57
  "dgs-ui-kit-bg-gray-700": c === "outside"
58
58
  }),
59
- style: { width: t ? `${k}%` : "100%" }
59
+ style: { width: t ? `${m}%` : "100%" }
60
60
  }
61
61
  )
62
62
  }
63
63
  );
64
- }, Q = (i) => {
65
- const { onNavigate: e, slideIndex: n, slidesCount: a } = i, {
64
+ }, Q = (e) => {
65
+ const { onNavigate: i, slideIndex: n, slidesCount: a } = e, {
66
66
  navigationButtonsShowType: t = "hide",
67
67
  dotsClassName: c,
68
- navigationContainerClassName: k,
69
- navigationVariant: r = "outside",
68
+ navigationContainerClassName: m,
69
+ navigationVariant: s = "outside",
70
70
  showNavigationDots: l = !0,
71
71
  showPaginationText: g
72
- } = A(), m = /* @__PURE__ */ w(
72
+ } = A(), f = /* @__PURE__ */ w(
73
73
  "div",
74
74
  {
75
75
  className: p("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%]": r === "inside" && t !== "onSides",
76
+ "dgs-ui-kit-absolute dgs-ui-kit-bottom-0 dgs-ui-kit-left-[5.5%]": s === "inside" && t !== "onSides",
77
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
78
  "dgs-ui-kit-opacity-0 group-hover:dgs-ui-kit-opacity-100 dgs-ui-kit-transition": t === "hover" || t === "onSides"
79
79
  }),
@@ -83,7 +83,7 @@ const J = (i) => {
83
83
  {
84
84
  type: "button",
85
85
  variant: "secondary",
86
- onClick: () => e(n - 1),
86
+ onClick: () => i(n - 1),
87
87
  rightIcon: /* @__PURE__ */ o(H, {})
88
88
  }
89
89
  ),
@@ -92,7 +92,7 @@ const J = (i) => {
92
92
  {
93
93
  type: "button",
94
94
  variant: "secondary",
95
- onClick: () => e(n + 1),
95
+ onClick: () => i(n + 1),
96
96
  rightIcon: /* @__PURE__ */ o(q, {})
97
97
  }
98
98
  )
@@ -100,30 +100,30 @@ const J = (i) => {
100
100
  }
101
101
  );
102
102
  return /* @__PURE__ */ w(V, { children: [
103
- t && t !== "hide" && t === "onSides" && m,
103
+ t && t !== "hide" && t === "onSides" && f,
104
104
  /* @__PURE__ */ w(
105
105
  "div",
106
106
  {
107
107
  className: p(
108
108
  "dgs-ui-kit-flex",
109
109
  {
110
- "dgs-ui-kit-items-center dgs-ui-kit-mt-2": r === "outside",
111
- "dgs-ui-kit-absolute dgs-ui-kit-bottom-4 dgs-ui-kit-w-full dgs-ui-kit-justify-center": r === "inside",
112
- "dgs-ui-kit-justify-between": r === "outside" && t !== "hide" && t !== "onSides",
113
- "dgs-ui-kit-justify-center": r === "outside" && (t === "hide" || t === "onSides")
110
+ "dgs-ui-kit-items-center dgs-ui-kit-mt-2": s === "outside",
111
+ "dgs-ui-kit-absolute dgs-ui-kit-bottom-4 dgs-ui-kit-w-full dgs-ui-kit-justify-center": s === "inside",
112
+ "dgs-ui-kit-justify-between": s === "outside" && t !== "hide" && t !== "onSides",
113
+ "dgs-ui-kit-justify-center": s === "outside" && (t === "hide" || t === "onSides")
114
114
  },
115
- k
115
+ m
116
116
  ),
117
117
  children: [
118
- t && t !== "hide" && t !== "onSides" && m,
118
+ t && t !== "hide" && t !== "onSides" && f,
119
119
  (l || g) && /* @__PURE__ */ w("div", { className: "dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-3", children: [
120
120
  g && /* @__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: [
121
121
  /* @__PURE__ */ o(
122
122
  "span",
123
123
  {
124
124
  className: p("dgs-ui-kit-font-bold", {
125
- "dgs-ui-kit-text-gray-600": r === "outside",
126
- "dgs-ui-kit-text-white": r === "inside"
125
+ "dgs-ui-kit-text-gray-600": s === "outside",
126
+ "dgs-ui-kit-text-white": s === "inside"
127
127
  }),
128
128
  children: n + 1
129
129
  }
@@ -138,12 +138,12 @@ const J = (i) => {
138
138
  "dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-justify-center dgs-ui-kit-gap-2",
139
139
  c
140
140
  ),
141
- children: Array.from(Array(a).keys()).map((d, f) => /* @__PURE__ */ o(
141
+ children: Array.from(Array(a).keys()).map((d, k) => /* @__PURE__ */ o(
142
142
  J,
143
143
  {
144
- active: n === f,
145
- onClick: () => e(f),
146
- onNavigateToNext: () => e(n + 1)
144
+ active: n === k,
145
+ onClick: () => i(k),
146
+ onNavigateToNext: () => i(n + 1)
147
147
  },
148
148
  d + a
149
149
  ))
@@ -154,61 +154,61 @@ const J = (i) => {
154
154
  }
155
155
  )
156
156
  ] });
157
- }, U = $((i, e) => {
158
- const [n, a] = b(i), {
157
+ }, U = $((e, i) => {
158
+ const [n, a] = b(e), {
159
159
  className: t = "",
160
160
  containerClassName: c = "",
161
- showNavigationDots: k = !0,
162
- slidesPerView: r = 1,
161
+ showNavigationDots: m = !0,
162
+ slidesPerView: s = 1,
163
163
  navigationButtonsShowType: l = "hide",
164
164
  spaceBetween: g = 0,
165
- showPaginationText: m,
165
+ showPaginationText: f,
166
166
  onSlideIndexChange: d,
167
- initialSlide: f,
167
+ initialSlide: k,
168
168
  containerXPadding: h = 0
169
- } = n, [S, P] = b(0), [j, B] = b(0), D = Object.fromEntries(
170
- Object.entries(n).filter(([s]) => s !== "children")
171
- ), u = W(null), v = Math.ceil(j / Math.floor(r)), R = (k || l && l !== "hide" || m) && v > 1;
172
- function E(s) {
173
- if (Math.ceil(Math.abs(s.currentTarget.scrollLeft)) + s.currentTarget.clientWidth + 1 + h >= s.currentTarget.scrollWidth) {
174
- P(v - 1);
169
+ } = n, [S, I] = b(0), [j, B] = b(0), D = Object.fromEntries(
170
+ Object.entries(n).filter(([r]) => r !== "children")
171
+ ), u = W(null), v = Math.ceil(j / Math.floor(s)), R = (m || l && l !== "hide" || f) && v > 1;
172
+ function E(r) {
173
+ if (Math.ceil(Math.abs(r.currentTarget.scrollLeft)) + r.currentTarget.clientWidth + 1 + h >= r.currentTarget.scrollWidth) {
174
+ I(v - 1);
175
175
  return;
176
176
  }
177
- const y = s.currentTarget.scrollWidth - h * 2, N = y / v, x = (y - s.currentTarget.scrollLeft - h) / N;
177
+ const y = r.currentTarget.scrollWidth - h * 2, N = y / v, x = (y - r.currentTarget.scrollLeft - h) / N;
178
178
  if (x <= v) {
179
- P(0);
179
+ I(0);
180
180
  return;
181
181
  }
182
- P(Math.round(x % v));
182
+ I(Math.round(x % v));
183
183
  }
184
- function I(s) {
184
+ function P(r) {
185
185
  if (!u.current) return;
186
- const y = u.current.offsetWidth, N = S - s, x = u.current.scrollWidth / v, O = N * x;
187
- s < 0 ? u.current.scrollTo({ behavior: "smooth", left: -(y * v) }) : s >= v ? u.current.scrollTo({ behavior: "smooth", left: 0 }) : u.current.scrollBy({ behavior: "smooth", left: O });
186
+ const y = u.current.offsetWidth, N = S - r, x = u.current.scrollWidth / v, O = N * x;
187
+ r < 0 ? u.current.scrollTo({ behavior: "smooth", left: -(y * v) }) : r >= v ? u.current.scrollTo({ behavior: "smooth", left: 0 }) : u.current.scrollBy({ behavior: "smooth", left: O });
188
188
  }
189
189
  function T() {
190
- const y = Object.keys(i.responsive).sort().findLast(
190
+ const y = Object.keys(e.responsive).sort().findLast(
191
191
  (x) => Number(x) <= window.innerWidth
192
- ), N = y ? i.responsive[Number(y)] : null;
193
- a(N ? { ...n, ...N } : i);
192
+ ), N = y ? e.responsive[Number(y)] : null;
193
+ a(N ? { ...n, ...N } : e);
194
194
  }
195
- return z(e, () => ({
195
+ return z(i, () => ({
196
196
  element: u.current,
197
- navigate: (s) => I(Math.max(0, s - 1))
197
+ navigate: (r) => P(Math.max(0, r - 1))
198
198
  })), C(() => {
199
199
  if (!u.current) return;
200
- let s = u.current.childElementCount;
201
- h > 0 && (s -= 2), B(s);
202
- }, [i.children, u, h]), C(() => {
203
- if (!(!i.responsive || Object.keys(i.responsive).length <= 0))
200
+ let r = u.current.childElementCount;
201
+ h > 0 && (r -= 2), B(r);
202
+ }, [e.children, u, h]), C(() => {
203
+ if (!(!e.responsive || Object.keys(e.responsive).length <= 0))
204
204
  return T(), window.addEventListener("resize", T), () => {
205
205
  window.removeEventListener("resize", T);
206
206
  };
207
- }, [i.responsive]), C(() => {
207
+ }, [e.responsive]), C(() => {
208
208
  d && typeof d == "function" && d(S);
209
209
  }, [S]), C(() => {
210
- typeof f == "number" && u.current && I(Math.max(0, f - 1));
211
- }, [f, u.current]), /* @__PURE__ */ o(M.Provider, { value: { ...D, childrenCount: j, sliderId: X() }, children: /* @__PURE__ */ w(
210
+ typeof k == "number" && u.current && P(Math.max(0, k - 1));
211
+ }, [k, u.current]), /* @__PURE__ */ o(M.Provider, { value: { ...D, childrenCount: j, sliderId: X() }, children: /* @__PURE__ */ w(
212
212
  "div",
213
213
  {
214
214
  className: p(
@@ -238,7 +238,7 @@ const J = (i) => {
238
238
  }
239
239
  }
240
240
  ),
241
- i.children,
241
+ e.children,
242
242
  h > 0 && /* @__PURE__ */ o(
243
243
  "div",
244
244
  {
@@ -255,7 +255,7 @@ const J = (i) => {
255
255
  R && /* @__PURE__ */ o(
256
256
  Q,
257
257
  {
258
- onNavigate: I,
258
+ onNavigate: P,
259
259
  slideIndex: S,
260
260
  slidesCount: v
261
261
  }
@@ -266,36 +266,36 @@ const J = (i) => {
266
266
  });
267
267
  U.displayName = "Slider";
268
268
  function Y({
269
- slidesPerView: i,
270
- childIndex: e,
269
+ slidesPerView: e,
270
+ childIndex: i,
271
271
  centerMode: n,
272
272
  childrenCount: a,
273
273
  haveContainerPadding: t
274
274
  }) {
275
- const c = e % Math.floor(i) === 0, k = i % 1 !== 0, r = e === 0, l = e === a - 1;
275
+ const c = i % Math.floor(e) === 0, m = e % 1 !== 0, s = i === 0, l = i === a - 1;
276
276
  if (!c) return "none";
277
277
  if (n) {
278
- if (k && !t) {
279
- if (r) return "start";
278
+ if (m && !t) {
279
+ if (s) return "start";
280
280
  if (l) return "end";
281
281
  }
282
282
  return "center";
283
283
  }
284
284
  return "start";
285
285
  }
286
- const st = (i) => {
287
- const { children: e, className: n, style: a, ...t } = i, {
286
+ const st = (e) => {
287
+ const { children: i, className: n, style: a, ...t } = e, {
288
288
  slidesPerView: c = 1,
289
- spaceBetween: k = 0,
290
- centerMode: r = !1,
289
+ spaceBetween: m = 0,
290
+ centerMode: s = !1,
291
291
  containerXPadding: l = 0,
292
292
  childrenCount: g = 0,
293
- sliderId: m
294
- } = A(), d = W(null), [f, h] = b(0);
293
+ sliderId: f
294
+ } = A(), d = W(null), [k, h] = b(0);
295
295
  return C(() => {
296
296
  d.current && h(
297
297
  Array.prototype.indexOf.call(
298
- document.querySelectorAll(`[id='slide-item-${m}']`),
298
+ document.querySelectorAll(`[id='slide-item-${f}']`),
299
299
  d.current
300
300
  )
301
301
  );
@@ -304,21 +304,21 @@ const st = (i) => {
304
304
  {
305
305
  ...t,
306
306
  ref: d,
307
- id: `slide-item-${m}`,
307
+ id: `slide-item-${f}`,
308
308
  className: p("dgs-ui-kit-shrink-0 dgs-ui-kit-snap-normal", n),
309
309
  style: {
310
310
  width: 100 / (c ?? 1) + "%",
311
- paddingLeft: k,
311
+ paddingLeft: m,
312
312
  scrollSnapAlign: Y({
313
313
  slidesPerView: c,
314
- childIndex: f,
315
- centerMode: r,
314
+ childIndex: k,
315
+ centerMode: s,
316
316
  childrenCount: g || 0,
317
317
  haveContainerPadding: l > 0
318
318
  }),
319
319
  ...a
320
320
  },
321
- children: e
321
+ children: i
322
322
  }
323
323
  );
324
324
  };
@@ -0,0 +1 @@
1
+ "use client";"use strict";const e=require("react/jsx-runtime"),y=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:""}),I=()=>n.useContext(A);function O({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 V=i=>{const{active:s,onClick:r,onNavigateToNext:d}=i,{autoplay:t,navigationVariant:g="outside"}=I(),[x,o]=n.useState(0);return n.useEffect(()=>{if(!s||!t)return;const u=typeof t=="boolean"?7e3:t?.delay??7e3;let f=Date.now();const k=setInterval(()=>{const l=Date.now()-f,v=l/u*100;o(Math.min(v,100)),l>=u&&typeof d=="function"&&(d(),o(0),clearInterval(k))},100);return function(){return o(0),f=Date.now(),clearInterval(k)}},[s,t,d]),e.jsx("button",{className:y.clsx("dgs-ui-kit-rounded-full dgs-ui-kit-overflow-hidden dgs-ui-kit-transition-all dgs-ui-kit-h-[6px]",O({active:s,autoplay:t,variant:g})),onClick:r,children:s&&e.jsx("div",{className:y.clsx("dgs-ui-kit-h-full dgs-ui-kit-rounded-full",{"dgs-ui-kit-bg-white":g==="inside","dgs-ui-kit-bg-gray-700":g==="outside"}),style:{width:t?`${x}%`:"100%"}})})},F=i=>{const{onNavigate:s,slideIndex:r,slidesCount:d}=i,{navigationButtonsShowType:t="hide",dotsClassName:g,navigationContainerClassName:x,navigationVariant:o="outside",showNavigationDots:u=!0,showPaginationText:f}=I(),k=e.jsxs("div",{className:y.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(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"&&k,e.jsxs("div",{className:y.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")},x),children:[t&&t!=="hide"&&t!=="onSides"&&k,(u||f)&&e.jsxs("div",{className:"dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-3",children:[f&&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:y.clsx("dgs-ui-kit-font-bold",{"dgs-ui-kit-text-gray-600":o==="outside","dgs-ui-kit-text-white":o==="inside"}),children:r+1}),e.jsx("span",{children:"از"}),e.jsx("span",{children:d})]}),u&&e.jsx("div",{className:y.clsx("dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-justify-center dgs-ui-kit-gap-2",g),children:Array.from(Array(d).keys()).map((l,v)=>e.jsx(V,{active:r===v,onClick:()=>s(v),onNavigateToNext:()=>s(r+1)},l+d))})]})]})]})},L=n.forwardRef((i,s)=>{const[r,d]=n.useState(i),{className:t="",containerClassName:g="",showNavigationDots:x=!0,slidesPerView:o=1,navigationButtonsShowType:u="hide",spaceBetween:f=0,showPaginationText:k,onSlideIndexChange:l,initialSlide:v,containerXPadding:h=0}=r,[C,j]=n.useState(0),[P,R]=n.useState(0),W=Object.fromEntries(Object.entries(r).filter(([a])=>a!=="children")),c=n.useRef(null),m=Math.ceil(P/Math.floor(o)),E=(x||u&&u!=="hide"||k)&&m>1;function M(a){if(Math.ceil(Math.abs(a.currentTarget.scrollLeft))+a.currentTarget.clientWidth+1+h>=a.currentTarget.scrollWidth){j(m-1);return}const p=a.currentTarget.scrollWidth-h*2,w=p/m,N=(p-a.currentTarget.scrollLeft-h)/w;if(N<=m){j(0);return}j(Math.round(N%m))}function S(a){if(!c.current)return;const p=c.current.offsetWidth,w=C-a,N=c.current.scrollWidth/m,B=w*N;a<0?c.current.scrollTo({behavior:"smooth",left:-(p*m)}):a>=m?c.current.scrollTo({behavior:"smooth",left:0}):c.current.scrollBy({behavior:"smooth",left:B})}function b(){const p=Object.keys(i.responsive).sort().findLast(N=>Number(N)<=window.innerWidth),w=p?i.responsive[Number(p)]:null;d(w?{...r,...w}:i)}return n.useImperativeHandle(s,()=>({element:c.current,navigate:a=>S(Math.max(0,a-1))})),n.useEffect(()=>{if(!c.current)return;let a=c.current.childElementCount;h>0&&(a-=2),R(a)},[i.children,c,h]),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 v=="number"&&c.current&&S(Math.max(0,v-1))},[v,c.current]),e.jsx(A.Provider,{value:{...W,childrenCount:P,sliderId:n.useId()},children:e.jsxs("div",{className:y.clsx("dgs-ui-kit-overflow-hidden dgs-ui-kit-relative dgs-ui-kit-group",t),style:{direction:"rtl"},children:[e.jsxs("div",{className:y.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:-f},onScroll:M,ref:c,children:[h>0&&e.jsx("div",{className:"dgs-ui-kit-shrink-0",style:{width:h,paddingLeft:f}}),i.children,h>0&&e.jsx("div",{className:"dgs-ui-kit-shrink-0",style:{width:h,paddingLeft:f}})]}),E&&e.jsx(F,{onNavigate:S,slideIndex:C,slidesCount:m})]})})});L.displayName="Slider";function K({slidesPerView:i,childIndex:s,centerMode:r,childrenCount:d,haveContainerPadding:t}){const g=s%Math.floor(i)===0,x=i%1!==0,o=s===0,u=s===d-1;if(!g)return"none";if(r){if(x&&!t){if(o)return"start";if(u)return"end"}return"center"}return"start"}const $=i=>{const{children:s,className:r,style:d,...t}=i,{slidesPerView:g=1,spaceBetween:x=0,centerMode:o=!1,containerXPadding:u=0,childrenCount:f=0,sliderId:k}=I(),l=n.useRef(null),[v,h]=n.useState(0);return n.useEffect(()=>{l.current&&h(Array.prototype.indexOf.call(document.querySelectorAll(`[id='slide-item-${k}']`),l.current))},[l,f,u]),e.jsx("div",{...t,ref:l,id:`slide-item-${k}`,className:y.clsx("dgs-ui-kit-shrink-0 dgs-ui-kit-snap-normal",r),style:{width:100/(g??1)+"%",paddingLeft:x,scrollSnapAlign:K({slidesPerView:g,childIndex:v,centerMode:o,childrenCount:f||0,haveContainerPadding:u>0}),...d},children:s})};exports.Slide=$;exports.Slider=L;
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationDot.d.ts","sourceRoot":"","sources":["../../src/components/Slider/NavigationDot.tsx"],"names":[],"mappings":"AAKA,UAAU,kBAAkB;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAuBD,QAAA,MAAM,aAAa,UAAW,kBAAkB,4CA8C/C,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"NavigationDot.d.ts","sourceRoot":"","sources":["../../src/components/Slider/NavigationDot.tsx"],"names":[],"mappings":"AAKA,UAAU,kBAAkB;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAuBD,QAAA,MAAM,aAAa,UAAW,kBAAkB,4CAgD/C,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../assets/styles.css');;/* empty css */const e=require("../Slide-h2OqEiNN.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-S7dYK-Ve.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-D_YyWKvD.js";
2
+ import { a as i, S as o } from "../Slide-Bkfv_374.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-h2OqEiNN.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-S7dYK-Ve.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-D_YyWKvD.js";
16
+ import { a as R, S as j } from "./Slide-Bkfv_374.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.52",
3
+ "version": "0.0.53",
4
4
  "description": "dgshahr ui-kit",
5
5
  "author": "dgshahr",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- "use client";"use strict";const e=require("react/jsx-runtime"),y=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 O({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 V=i=>{const{active:s,onClick:r,onNavigateToNext:d}=i,{autoplay:t,navigationVariant:g="outside"}=P(),[v,a]=n.useState(0);return n.useEffect(()=>{if(!s||!t)return;const l=typeof t=="boolean"?7e3:t?.delay??7e3;let f=Date.now();const x=setInterval(()=>{const u=Date.now()-f,k=u/l*100;a(Math.min(k,100)),u>=l&&typeof d=="function"&&d()},100);return function(){return a(0),f=Date.now(),clearInterval(x)}},[s,t,d]),e.jsx("button",{className:y.clsx("dgs-ui-kit-rounded-full dgs-ui-kit-overflow-hidden dgs-ui-kit-transition-all dgs-ui-kit-h-[6px]",O({active:s,autoplay:t,variant:g})),onClick:r,children:s&&e.jsx("div",{className:y.clsx("dgs-ui-kit-h-full dgs-ui-kit-rounded-full",{"dgs-ui-kit-bg-white":g==="inside","dgs-ui-kit-bg-gray-700":g==="outside"}),style:{width:t?`${v}%`:"100%"}})})},F=i=>{const{onNavigate:s,slideIndex:r,slidesCount:d}=i,{navigationButtonsShowType:t="hide",dotsClassName:g,navigationContainerClassName:v,navigationVariant:a="outside",showNavigationDots:l=!0,showPaginationText:f}=P(),x=e.jsxs("div",{className:y.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"&&x,e.jsxs("div",{className:y.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"&&x,(l||f)&&e.jsxs("div",{className:"dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-3",children:[f&&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:y.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:d})]}),l&&e.jsx("div",{className:y.clsx("dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-justify-center dgs-ui-kit-gap-2",g),children:Array.from(Array(d).keys()).map((u,k)=>e.jsx(V,{active:r===k,onClick:()=>s(k),onNavigateToNext:()=>s(r+1)},u+d))})]})]})]})},L=n.forwardRef((i,s)=>{const[r,d]=n.useState(i),{className:t="",containerClassName:g="",showNavigationDots:v=!0,slidesPerView:a=1,navigationButtonsShowType:l="hide",spaceBetween:f=0,showPaginationText:x,onSlideIndexChange:u,initialSlide:k,containerXPadding:h=0}=r,[C,j]=n.useState(0),[I,R]=n.useState(0),W=Object.fromEntries(Object.entries(r).filter(([o])=>o!=="children")),c=n.useRef(null),m=Math.ceil(I/Math.floor(a)),E=(v||l&&l!=="hide"||x)&&m>1;function M(o){if(Math.ceil(Math.abs(o.currentTarget.scrollLeft))+o.currentTarget.clientWidth+1+h>=o.currentTarget.scrollWidth){j(m-1);return}const p=o.currentTarget.scrollWidth-h*2,w=p/m,N=(p-o.currentTarget.scrollLeft-h)/w;if(N<=m){j(0);return}j(Math.round(N%m))}function S(o){if(!c.current)return;const p=c.current.offsetWidth,w=C-o,N=c.current.scrollWidth/m,B=w*N;o<0?c.current.scrollTo({behavior:"smooth",left:-(p*m)}):o>=m?c.current.scrollTo({behavior:"smooth",left:0}):c.current.scrollBy({behavior:"smooth",left:B})}function b(){const p=Object.keys(i.responsive).sort().findLast(N=>Number(N)<=window.innerWidth),w=p?i.responsive[Number(p)]:null;d(w?{...r,...w}:i)}return n.useImperativeHandle(s,()=>({element:c.current,navigate:o=>S(Math.max(0,o-1))})),n.useEffect(()=>{if(!c.current)return;let o=c.current.childElementCount;h>0&&(o-=2),R(o)},[i.children,c,h]),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(()=>{u&&typeof u=="function"&&u(C)},[C]),n.useEffect(()=>{typeof k=="number"&&c.current&&S(Math.max(0,k-1))},[k,c.current]),e.jsx(A.Provider,{value:{...W,childrenCount:I,sliderId:n.useId()},children:e.jsxs("div",{className:y.clsx("dgs-ui-kit-overflow-hidden dgs-ui-kit-relative dgs-ui-kit-group",t),style:{direction:"rtl"},children:[e.jsxs("div",{className:y.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:-f},onScroll:M,ref:c,children:[h>0&&e.jsx("div",{className:"dgs-ui-kit-shrink-0",style:{width:h,paddingLeft:f}}),i.children,h>0&&e.jsx("div",{className:"dgs-ui-kit-shrink-0",style:{width:h,paddingLeft:f}})]}),E&&e.jsx(F,{onNavigate:S,slideIndex:C,slidesCount:m})]})})});L.displayName="Slider";function K({slidesPerView:i,childIndex:s,centerMode:r,childrenCount:d,haveContainerPadding:t}){const g=s%Math.floor(i)===0,v=i%1!==0,a=s===0,l=s===d-1;if(!g)return"none";if(r){if(v&&!t){if(a)return"start";if(l)return"end"}return"center"}return"start"}const $=i=>{const{children:s,className:r,style:d,...t}=i,{slidesPerView:g=1,spaceBetween:v=0,centerMode:a=!1,containerXPadding:l=0,childrenCount:f=0,sliderId:x}=P(),u=n.useRef(null),[k,h]=n.useState(0);return n.useEffect(()=>{u.current&&h(Array.prototype.indexOf.call(document.querySelectorAll(`[id='slide-item-${x}']`),u.current))},[u,f,l]),e.jsx("div",{...t,ref:u,id:`slide-item-${x}`,className:y.clsx("dgs-ui-kit-shrink-0 dgs-ui-kit-snap-normal",r),style:{width:100/(g??1)+"%",paddingLeft:v,scrollSnapAlign:K({slidesPerView:g,childIndex:k,centerMode:a,childrenCount:f||0,haveContainerPadding:l>0}),...d},children:s})};exports.Slide=$;exports.Slider=L;