@dgshahr/ui-kit 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use client";"use strict";require('../../assets/styles.css');const i=require("react/jsx-runtime"),k=require("../../clsx-C11secjj.cjs"),h=require("react"),q=require("../Input/index.cjs"),m=require("../../TextFieldWrapper-fWVS7qVy.cjs");;/* empty css */const V=y=>{const{inputsNumber:a=4,onChange:c,onEnd:p,className:j,inputsContainerClassName:v,labelContent:f,hintMessage:g,errorMessage:l,isError:w,value:d}=y,[o,r]=h.useState([]);h.useEffect(()=>{if(d){const s=d.split("");r(s)}},[]);function u(s){const e=document.getElementById(`dgs-ui-kit-otp-input-${s}`);e?.focus(),e?.select()}function C(s,e){const t=[s.code,s.key];if(t.includes("Backspace")||t.includes("Delete")){const n=[...o];n[e]="",e!==0&&(n[e-1]="",u(e-1)),r(n)}else t.includes("ArrowLeft")?u(e+1):t.includes("ArrowRight")&&u(e-1)}function I(s,e){const t=s.currentTarget.value,n=[...o];n[e]=t,e+1!==a&&t?u(e+1):typeof p=="function"&&n.every(N=>!!N)&&p(n.join("")),r(n),typeof c=="function"&&c(n.join(""))}return i.jsxs("div",{className:k.clsx("dgs-ui-kit-space-y-2",j),children:[f?i.jsx(m.FieldLabel,{labelContent:f}):null,i.jsx("div",{className:k.clsx("dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-2",v),children:Array.from(Array(a).keys()).map((s,e)=>i.jsx(q,{containerClassName:"dgs-ui-kit-w-12 dgs-ui-kit-h-12 dgs-ui-kit-p-0",className:"dgs-ui-kit-w-full dgs-ui-kit-h-full !dgs-ui-kit-text-center placeholder:!dgs-ui-kit-text-center",placeholder:"-",autoFocus:e===0,onChange:t=>I(t,e),onKeyUp:t=>C(t,e),id:`dgs-ui-kit-otp-input-${e}`,maxLength:1,value:o[e],showMaxLength:!1,isError:!!l||w},s))}),l||g?i.jsx(m.FieldBottomInfo,{errorMessage:l,hintMessage:g}):null]})};module.exports=V;
1
+ "use client";"use strict";require('../../assets/styles.css');const i=require("react/jsx-runtime"),k=require("../../clsx-C11secjj.cjs"),h=require("react"),q=require("../Input/index.cjs"),m=require("../../TextFieldWrapper-fWVS7qVy.cjs");;/* empty css */const V=y=>{const{inputsNumber:a=4,onChange:c,onEnd:p,className:j,inputsContainerClassName:v,labelContent:f,hintMessage:g,errorMessage:l,isError:w,value:d}=y,[o,r]=h.useState([]);h.useEffect(()=>{if(d){const s=d.split("");r(s)}},[]);function u(s){const e=document.getElementById(`dgs-ui-kit-otp-input-${s}`);e?.focus(),e?.select()}function C(s,e){const t=[s.code,s.key];if(t.includes("Backspace")||t.includes("Delete")){const n=[...o];n[e]="",e!==0&&(n[e-1]="",u(e-1)),r(n)}else t.includes("ArrowLeft")?u(e+1):t.includes("ArrowRight")&&u(e-1)}function I(s,e){const t=s.currentTarget.value,n=[...o];n[e]=t,e+1!==a&&t?u(e+1):typeof p=="function"&&n.every(N=>!!N)&&p(n.join("")),r(n),typeof c=="function"&&c(n.join(""))}return i.jsxs("div",{className:k.clsx("dgs-ui-kit-space-y-2",j),children:[f?i.jsx(m.FieldLabel,{labelContent:f}):null,i.jsx("div",{className:k.clsx("dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-2",v),children:Array.from(Array(a).keys()).map((s,e)=>i.jsx(q,{containerClassName:"dgs-ui-kit-w-12 dgs-ui-kit-h-12 dgs-ui-kit-p-0",className:"dgs-ui-kit-w-full dgs-ui-kit-h-full !dgs-ui-kit-text-center placeholder:!dgs-ui-kit-text-center",placeholder:"-",type:"tel",autoFocus:e===0,onChange:t=>I(t,e),onKeyUp:t=>C(t,e),id:`dgs-ui-kit-otp-input-${e}`,maxLength:1,value:o[e],showMaxLength:!1,isError:!!l||w},s))}),l||g?i.jsx(m.FieldBottomInfo,{errorMessage:l,hintMessage:g}):null]})};module.exports=V;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/OtpInput/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAyC,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AAI3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,kBAAkB,CAAC;AAE1B,UAAU,aACR,SAAQ,IAAI,CAAC,kBAAkB,EAAE,cAAc,GAAG,cAAc,GAAG,SAAS,GAAG,aAAa,CAAC;IAC7F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CA0F/B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/OtpInput/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAyC,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AAI3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,kBAAkB,CAAC;AAE1B,UAAU,aACR,SAAQ,IAAI,CAAC,kBAAkB,EAAE,cAAc,GAAG,cAAc,GAAG,SAAS,GAAG,aAAa,CAAC;IAC7F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CA2F/B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -54,6 +54,7 @@ const U = (k) => {
54
54
  containerClassName: "dgs-ui-kit-w-12 dgs-ui-kit-h-12 dgs-ui-kit-p-0",
55
55
  className: "dgs-ui-kit-w-full dgs-ui-kit-h-full !dgs-ui-kit-text-center placeholder:!dgs-ui-kit-text-center",
56
56
  placeholder: "-",
57
+ type: "tel",
57
58
  autoFocus: e === 0,
58
59
  onChange: (t) => C(t, e),
59
60
  onKeyUp: (t) => w(t, e),
@@ -1,20 +1,20 @@
1
1
  "use client";
2
2
  import { jsx as r, jsxs as y, Fragment as M } from "react/jsx-runtime";
3
- import { c as g } from "./clsx-OuTLNxxd.js";
3
+ import { c as f } from "./clsx-OuTLNxxd.js";
4
4
  import { createContext as B, useContext as R, useState as x, useEffect as S, useRef as j, Children as V } from "react";
5
5
  import { A as O } from "./ArrowLeft2-jP2w1vwt.js";
6
6
  import { A as E } from "./ArrowRight2-CcHdxGRE.js";
7
- import P from "./Button/index.js";
7
+ import T from "./Button/index.js";
8
8
  const I = B({
9
9
  slidesPerView: 1,
10
10
  spaceBetween: 0,
11
11
  navigationVariant: "outside",
12
12
  showNavigationDots: !0,
13
13
  showPaginationText: !1
14
- }), T = () => R(I);
14
+ }), P = () => R(I);
15
15
  function K({
16
- active: e,
17
- autoplay: i,
16
+ active: i,
17
+ autoplay: e,
18
18
  variant: s = "outside"
19
19
  }) {
20
20
  return [
@@ -22,75 +22,75 @@ function K({
22
22
  inside: "dgs-ui-kit-bg-gray-500/50 hover:dgs-ui-kit-bg-gray-500/80",
23
23
  outside: "dgs-ui-kit-bg-gray-200 hover:dgs-ui-kit-bg-gray-300"
24
24
  }[s],
25
- e ? "dgs-ui-kit-w-[22px]" : "dgs-ui-kit-w-[6px]",
26
- i ? "dgs-ui-kit-p-[1px]" : ""
25
+ i ? "dgs-ui-kit-w-[22px]" : "dgs-ui-kit-w-[6px]",
26
+ e ? "dgs-ui-kit-p-[1px]" : ""
27
27
  ];
28
28
  }
29
- const z = (e) => {
30
- const { active: i, onClick: s, onNavigateToNext: n } = e, { autoplay: t, navigationVariant: u = "outside" } = T(), [v, a] = x(0);
29
+ const z = (i) => {
30
+ const { active: e, onClick: s, onNavigateToNext: n } = i, { autoplay: t, navigationVariant: l = "outside" } = P(), [k, a] = x(0);
31
31
  return S(() => {
32
- if (!i || !t) return;
33
- const o = typeof t == "boolean" ? 7e3 : t?.delay ?? 7e3;
34
- let l = Date.now();
35
- const h = setInterval(() => {
36
- const c = Date.now() - l, m = c / o * 100;
37
- a(Math.min(m, 100)), c >= o && typeof n == "function" && n();
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
38
  }, 100);
39
39
  return function() {
40
- return a(0), l = Date.now(), clearInterval(h);
40
+ return a(0), o = Date.now(), clearInterval(c);
41
41
  };
42
- }, [i, t, n]), /* @__PURE__ */ r(
42
+ }, [e, t, n]), /* @__PURE__ */ r(
43
43
  "button",
44
44
  {
45
- className: g(
45
+ className: f(
46
46
  "dgs-ui-kit-rounded-full dgs-ui-kit-overflow-hidden dgs-ui-kit-transition-all dgs-ui-kit-h-[6px]",
47
- K({ active: i, autoplay: t, variant: u })
47
+ K({ active: e, autoplay: t, variant: l })
48
48
  ),
49
49
  onClick: s,
50
- children: i && /* @__PURE__ */ r(
50
+ children: e && /* @__PURE__ */ r(
51
51
  "div",
52
52
  {
53
- className: g("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"
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
56
  }),
57
- style: { width: t ? `${v}%` : "100%" }
57
+ style: { width: t ? `${k}%` : "100%" }
58
58
  }
59
59
  )
60
60
  }
61
61
  );
62
- }, F = (e) => {
63
- const { onNavigate: i, slideIndex: s, slidesCount: n } = e, {
62
+ }, F = (i) => {
63
+ const { onNavigate: e, slideIndex: s, slidesCount: n } = i, {
64
64
  navigationButtonsShowType: t = "hide",
65
- dotsClassName: u,
66
- navigationContainerClassName: v,
65
+ dotsClassName: l,
66
+ navigationContainerClassName: k,
67
67
  navigationVariant: a = "outside",
68
- showNavigationDots: o = !0,
69
- showPaginationText: l
70
- } = T(), h = /* @__PURE__ */ y(
68
+ showNavigationDots: u = !0,
69
+ showPaginationText: o
70
+ } = P(), c = /* @__PURE__ */ y(
71
71
  "div",
72
72
  {
73
- className: g("dgs-ui-kit-flex dgs-ui-kit-gap-2", {
73
+ className: f("dgs-ui-kit-flex dgs-ui-kit-gap-2", {
74
74
  "dgs-ui-kit-absolute dgs-ui-kit-bottom-0 dgs-ui-kit-left-[5.5%]": a === "inside" && t !== "onSides",
75
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
76
  "dgs-ui-kit-opacity-0 group-hover:dgs-ui-kit-opacity-100 dgs-ui-kit-transition": t === "hover" || t === "onSides"
77
77
  }),
78
78
  children: [
79
79
  /* @__PURE__ */ r(
80
- P,
80
+ T,
81
81
  {
82
82
  type: "button",
83
83
  variant: "secondary",
84
- onClick: () => i(s - 1),
84
+ onClick: () => e(s - 1),
85
85
  rightIcon: /* @__PURE__ */ r(E, {})
86
86
  }
87
87
  ),
88
88
  /* @__PURE__ */ r(
89
- P,
89
+ T,
90
90
  {
91
91
  type: "button",
92
92
  variant: "secondary",
93
- onClick: () => i(s + 1),
93
+ onClick: () => e(s + 1),
94
94
  rightIcon: /* @__PURE__ */ r(O, {})
95
95
  }
96
96
  )
@@ -98,11 +98,11 @@ const z = (e) => {
98
98
  }
99
99
  );
100
100
  return /* @__PURE__ */ y(M, { children: [
101
- t && t !== "hide" && t === "onSides" && h,
101
+ t && t !== "hide" && t === "onSides" && c,
102
102
  /* @__PURE__ */ y(
103
103
  "div",
104
104
  {
105
- className: g(
105
+ className: f(
106
106
  "dgs-ui-kit-flex",
107
107
  {
108
108
  "dgs-ui-kit-items-center dgs-ui-kit-mt-2": a === "outside",
@@ -110,16 +110,16 @@ const z = (e) => {
110
110
  "dgs-ui-kit-justify-between": a === "outside" && t !== "hide" && t !== "onSides",
111
111
  "dgs-ui-kit-justify-center": a === "outside" && (t === "hide" || t === "onSides")
112
112
  },
113
- v
113
+ k
114
114
  ),
115
115
  children: [
116
- t && t !== "hide" && t !== "onSides" && h,
117
- (o || l) && /* @__PURE__ */ y("div", { className: "dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-3", children: [
118
- l && /* @__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: [
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
119
  /* @__PURE__ */ r(
120
120
  "span",
121
121
  {
122
- className: g("dgs-ui-kit-font-bold", {
122
+ className: f("dgs-ui-kit-font-bold", {
123
123
  "dgs-ui-kit-text-gray-600": a === "outside",
124
124
  "dgs-ui-kit-text-white": a === "inside"
125
125
  }),
@@ -129,21 +129,21 @@ const z = (e) => {
129
129
  /* @__PURE__ */ r("span", { children: "از" }),
130
130
  /* @__PURE__ */ r("span", { children: n })
131
131
  ] }),
132
- o && /* @__PURE__ */ r(
132
+ u && /* @__PURE__ */ r(
133
133
  "div",
134
134
  {
135
- className: g(
135
+ className: f(
136
136
  "dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-justify-center dgs-ui-kit-gap-2",
137
- u
137
+ l
138
138
  ),
139
- children: Array.from(Array(n).keys()).map((c, m) => /* @__PURE__ */ r(
139
+ children: Array.from(Array(n).keys()).map((h, g) => /* @__PURE__ */ r(
140
140
  z,
141
141
  {
142
- active: s === m,
143
- onClick: () => i(m),
144
- onNavigateToNext: () => i(s + 1)
142
+ active: s === g,
143
+ onClick: () => e(g),
144
+ onNavigateToNext: () => e(s + 1)
145
145
  },
146
- c + n
146
+ h + n
147
147
  ))
148
148
  }
149
149
  )
@@ -152,94 +152,99 @@ const z = (e) => {
152
152
  }
153
153
  )
154
154
  ] });
155
- }, X = (e) => {
156
- const [i, s] = x(0), [n, t] = x(e), {
157
- className: u = "",
158
- containerClassName: v = "",
155
+ }, U = (i) => {
156
+ const [e, s] = x(0), [n, t] = x(i), {
157
+ className: l = "",
158
+ containerClassName: k = "",
159
159
  showNavigationDots: a = !0,
160
- slidesPerView: o = 1,
161
- navigationButtonsShowType: l = "hide",
162
- spaceBetween: h = 0,
163
- showPaginationText: c
164
- } = n, m = Object.fromEntries(
160
+ slidesPerView: u = 1,
161
+ navigationButtonsShowType: o = "hide",
162
+ spaceBetween: c = 0,
163
+ showPaginationText: h
164
+ } = n, g = Object.fromEntries(
165
165
  Object.entries(n).filter(([d]) => d !== "children")
166
- ), w = j(null), L = V.count(e.children), f = Math.ceil(L / Math.floor(o)), W = (a || l && l !== "hide" || c) && f > 1;
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
167
  function A(d) {
168
168
  if (Math.ceil(Math.abs(d.currentTarget.scrollLeft)) + d.currentTarget.clientWidth === d.currentTarget.scrollWidth) {
169
- s(f - 1);
169
+ s(v - 1);
170
170
  return;
171
171
  }
172
- const p = d.currentTarget.scrollWidth / f, k = (d.currentTarget.scrollWidth - d.currentTarget.scrollLeft) / p;
173
- if (k <= f) {
172
+ const m = d.currentTarget.scrollWidth / v, p = (d.currentTarget.scrollWidth - d.currentTarget.scrollLeft) / m;
173
+ if (p <= v) {
174
174
  s(0);
175
175
  return;
176
176
  }
177
- s(Math.round(k % f));
177
+ s(Math.round(p % v));
178
178
  }
179
179
  function D(d) {
180
180
  if (!w.current) return;
181
- const p = o % 1 !== 0, k = w.current.offsetWidth, N = p ? k / o : k;
181
+ const m = u % 1 !== 0, p = w.current.offsetWidth, N = m ? p / u : p;
182
182
  let C = -(N * d);
183
- d < 0 ? C = -(N * f) : d >= f && (C = 0), w.current.scrollTo({
183
+ d < 0 ? C = -(N * v) : d >= v && (C = 0), w.current.scrollTo({
184
184
  left: C,
185
185
  behavior: "smooth"
186
186
  });
187
187
  }
188
188
  function b() {
189
- const p = Object.keys(e.responsive).sort().findLast(
189
+ const m = Object.keys(i.responsive).sort().findLast(
190
190
  (N) => Number(N) <= window.innerWidth
191
- ), k = p ? e.responsive[Number(p)] : null;
192
- t(k ? { ...n, ...k } : e);
191
+ ), p = m ? i.responsive[Number(m)] : null;
192
+ t(p ? { ...n, ...p } : i);
193
193
  }
194
194
  return S(() => {
195
- if (!(!e.responsive || Object.keys(e.responsive).length <= 0))
195
+ if (!(!i.responsive || Object.keys(i.responsive).length <= 0))
196
196
  return b(), window.addEventListener("resize", b), () => {
197
197
  window.removeEventListener("resize", b);
198
198
  };
199
- }, [e.responsive]), /* @__PURE__ */ r(I.Provider, { value: m, children: /* @__PURE__ */ y(
199
+ }, [i.responsive]), /* @__PURE__ */ r(I.Provider, { value: g, children: /* @__PURE__ */ y(
200
200
  "div",
201
201
  {
202
- className: g(
202
+ className: f(
203
203
  "dgs-ui-kit-overflow-hidden dgs-ui-kit-relative dgs-ui-kit-group",
204
- u
204
+ l
205
205
  ),
206
206
  style: { direction: "rtl" },
207
207
  children: [
208
208
  /* @__PURE__ */ r(
209
209
  "div",
210
210
  {
211
- className: g(
211
+ className: f(
212
212
  "dgs-ui-kit-flex dgs-ui-kit-snap-x dgs-ui-kit-snap-mandatory dgs-ui-kit-overflow-x-auto no-scrollbar",
213
- v
213
+ k
214
214
  ),
215
- style: { marginLeft: -h },
215
+ style: { marginLeft: -c },
216
216
  onScroll: A,
217
217
  ref: w,
218
- children: e.children
218
+ children: i.children
219
219
  }
220
220
  ),
221
221
  W && /* @__PURE__ */ r(
222
222
  F,
223
223
  {
224
224
  onNavigate: D,
225
- slideIndex: i,
226
- slidesCount: f
225
+ slideIndex: e,
226
+ slidesCount: v
227
227
  }
228
228
  )
229
229
  ]
230
230
  }
231
231
  ) });
232
232
  };
233
- function $({
234
- slidesPerView: e,
235
- childIndex: i,
233
+ function X({
234
+ slidesPerView: i,
235
+ childIndex: e,
236
236
  centerMode: s,
237
237
  childsLength: n
238
238
  }) {
239
- return i % Math.floor(e) !== 0 ? "none" : s && e % 1 !== 0 ? i === 0 ? "start" : i === n - 1 ? "end" : "center" : "start";
239
+ return e % Math.floor(i) !== 0 ? "none" : s && i % 1 !== 0 ? e === 0 ? "start" : e === n - 1 ? "end" : "center" : "start";
240
240
  }
241
- const Y = (e) => {
242
- const { children: i, className: s, style: n, ...t } = e, { slidesPerView: u = 1, spaceBetween: v = 0, centerMode: a = !1 } = T(), o = j(null), [l, h] = x(0), c = o.current?.parentNode?.children.length;
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;
243
248
  return S(() => {
244
249
  o.current && h(Array.prototype.indexOf.call(o.current.parentNode?.children, o.current));
245
250
  }, [o]), /* @__PURE__ */ r(
@@ -247,23 +252,24 @@ const Y = (e) => {
247
252
  {
248
253
  ...t,
249
254
  ref: o,
250
- className: g("dgs-ui-kit-shrink-0 dgs-ui-kit-snap-always", s),
255
+ className: f("dgs-ui-kit-shrink-0 dgs-ui-kit-snap-always", s),
251
256
  style: {
252
- width: 100 / (u ?? 1) + "%",
253
- paddingLeft: v,
254
- scrollSnapAlign: $({
255
- slidesPerView: u,
256
- childIndex: l,
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,
257
263
  centerMode: a,
258
- childsLength: c || 0
264
+ childsLength: g || 0
259
265
  }),
260
266
  ...n
261
267
  },
262
- children: i
268
+ children: e
263
269
  }
264
270
  );
265
271
  };
266
272
  export {
267
- X as S,
273
+ U as S,
268
274
  Y as a
269
275
  };
@@ -0,0 +1 @@
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;
@@ -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;AAuBf,QAAA,MAAM,KAAK,EAAE,EAAE,CACb,iBAAiB,CAAC,iBAAiB,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC,CAAC,CAiCrF,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;AAuBf,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
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../assets/styles.css');;/* empty css */const e=require("../Slide-DAjRWq7G.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-C1oVFHZo.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-DEFTnIi5.js";
2
+ import { a as i, S as o } from "../Slide-BEZZ-Egi.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-DAjRWq7G.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-C1oVFHZo.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-DEFTnIi5.js";
16
+ import { a as R, S as j } from "./Slide-BEZZ-Egi.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.19",
3
+ "version": "0.0.21",
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"),h=require("./clsx-C11secjj.cjs"),u=require("react"),R=require("./ArrowLeft2-B76dkC-C.cjs"),W=require("./ArrowRight2-CYowPzS8.cjs"),S=require("./Button/index.cjs"),C=u.createContext({slidesPerView:1,spaceBetween:0,navigationVariant:"outside",showNavigationDots:!0,showPaginationText:!1}),b=()=>u.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:c="outside"}=b(),[x,a]=u.useState(0);return u.useEffect(()=>{if(!s||!t)return;const o=typeof t=="boolean"?7e3:t?.delay??7e3;let l=Date.now();const f=setInterval(()=>{const g=Date.now()-l,p=g/o*100;a(Math.min(p,100)),g>=o&&typeof r=="function"&&r()},100);return function(){return a(0),l=Date.now(),clearInterval(f)}},[s,t,r]),e.jsx("button",{className:h.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:c})),onClick:n,children:s&&e.jsx("div",{className:h.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?`${x}%`:"100%"}})})},M=i=>{const{onNavigate:s,slideIndex:n,slidesCount:r}=i,{navigationButtonsShowType:t="hide",dotsClassName:c,navigationContainerClassName:x,navigationVariant:a="outside",showNavigationDots:o=!0,showPaginationText:l}=b(),f=e.jsxs("div",{className:h.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(R.ArrowLeft2Icon,{})})]});return e.jsxs(e.Fragment,{children:[t&&t!=="hide"&&t==="onSides"&&f,e.jsxs("div",{className:h.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")},x),children:[t&&t!=="hide"&&t!=="onSides"&&f,(o||l)&&e.jsxs("div",{className:"dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-3",children:[l&&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:h.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})]}),o&&e.jsx("div",{className:h.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(r).keys()).map((g,p)=>e.jsx(D,{active:n===p,onClick:()=>s(p),onNavigateToNext:()=>s(n+1)},g+r))})]})]})]})},B=i=>{const[s,n]=u.useState(0),[r,t]=u.useState(i),{className:c="",containerClassName:x="",showNavigationDots:a=!0,slidesPerView:o=1,navigationButtonsShowType:l="hide",spaceBetween:f=0,showPaginationText:g}=r,p=Object.fromEntries(Object.entries(r).filter(([d])=>d!=="children")),m=u.useRef(null),T=u.Children.count(i.children),k=Math.ceil(T/Math.floor(o)),P=(a||l&&l!=="hide"||g)&&k>1;function L(d){if(Math.ceil(Math.abs(d.currentTarget.scrollLeft))+d.currentTarget.clientWidth===d.currentTarget.scrollWidth){n(k-1);return}const y=d.currentTarget.scrollWidth/k,v=(d.currentTarget.scrollWidth-d.currentTarget.scrollLeft)/y;if(v<=k){n(0);return}n(Math.round(v%k))}function I(d){if(!m.current)return;const y=o%1!==0,v=m.current.offsetWidth,w=y?v/o:v;let j=-(w*d);d<0?j=-(w*k):d>=k&&(j=0),m.current.scrollTo({left:j,behavior:"smooth"})}function N(){const y=Object.keys(i.responsive).sort().findLast(w=>Number(w)<=window.innerWidth),v=y?i.responsive[Number(y)]:null;t(v?{...r,...v}:i)}return u.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:p,children:e.jsxs("div",{className:h.clsx("dgs-ui-kit-overflow-hidden dgs-ui-kit-relative dgs-ui-kit-group",c),style:{direction:"rtl"},children:[e.jsx("div",{className:h.clsx("dgs-ui-kit-flex dgs-ui-kit-snap-x dgs-ui-kit-snap-mandatory dgs-ui-kit-overflow-x-auto no-scrollbar",x),style:{marginLeft:-f},onScroll:L,ref:m,children:i.children}),P&&e.jsx(M,{onNavigate:I,slideIndex:s,slidesCount:k})]})})};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:c=1,spaceBetween:x=0,centerMode:a=!1}=b(),o=u.useRef(null),[l,f]=u.useState(0),g=o.current?.parentNode?.children.length;return u.useEffect(()=>{o.current&&f(Array.prototype.indexOf.call(o.current.parentNode?.children,o.current))},[o]),e.jsx("div",{...t,ref:o,className:h.clsx("dgs-ui-kit-shrink-0 dgs-ui-kit-snap-always",n),style:{width:100/(c??1)+"%",paddingLeft:x,scrollSnapAlign:q({slidesPerView:c,childIndex:l,centerMode:a,childsLength:g||0}),...r},children:s})};exports.Slide=E;exports.Slider=B;