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