@dgshahr/ui-kit 0.0.3 → 0.0.5
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/Accordion/AccordionGroup.d.ts.map +1 -1
- package/dist/Accordion/index.cjs +1 -1
- package/dist/Accordion/index.js +1 -1
- package/dist/Alert/index.cjs +73 -73
- package/dist/Alert/index.d.ts.map +1 -1
- package/dist/Alert/index.js +73 -73
- package/dist/Breadcrumb/index.cjs +1 -1
- package/dist/Breadcrumb/index.d.ts.map +1 -1
- package/dist/Breadcrumb/index.js +1 -1
- package/dist/Button/index.d.ts.map +1 -1
- package/dist/Form/Checkbox/index.cjs +4 -4
- package/dist/Form/Checkbox/index.d.ts +1 -1
- package/dist/Form/Checkbox/index.d.ts.map +1 -1
- package/dist/Form/Checkbox/index.js +4 -4
- package/dist/Form/Input/index.cjs +1 -1
- package/dist/Form/Input/index.d.ts.map +1 -1
- package/dist/Form/Input/index.js +1 -1
- package/dist/Form/RadioButton/index.d.ts +1 -1
- package/dist/Form/RadioButton/index.d.ts.map +1 -1
- package/dist/Form/Textarea/index.cjs +1 -1
- package/dist/Form/Textarea/index.js +1 -1
- package/dist/Form/Wrappers/TextFieldWrapper/FieldBottomInfo.d.ts.map +1 -1
- package/dist/Form/Wrappers/TextFieldWrapper/TextFieldWrapper.d.ts.map +1 -1
- package/dist/Pagination/index.cjs +3 -3
- package/dist/Pagination/index.js +3 -3
- package/dist/Slide-BDD1_RXD.js +215 -0
- package/dist/Slide-Q5_7SCZR.cjs +218 -0
- package/dist/Slider/Slide.d.ts.map +1 -1
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/index.cjs +1 -1
- package/dist/Slider/index.js +1 -1
- package/dist/assets/Button.css +12 -6
- package/dist/assets/styles.css +12 -6
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/package.json +114 -69
- package/dist/Slide-6SD8mElS.js +0 -198
- package/dist/Slide-BiCQh7AV.cjs +0 -201
- package/dist/{AccordionItem-BBbE__nk.js → AccordionItem-DN7bi5kw.js} +1 -1
- package/dist/{AccordionItem-BOXOB5GK.cjs → AccordionItem-lq6ehxKe.cjs} +1 -1
- package/dist/{TextFieldWrapper-D3oaEPmc.js → TextFieldWrapper--hxpmYuz.js} +32 -32
- package/dist/{TextFieldWrapper-C80myx6j.cjs → TextFieldWrapper-DaoZxs1E.cjs} +32 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dgshahr/ui-kit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "dgshahr ui-kit",
|
|
5
5
|
"author": "dgshahr",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,70 +17,17 @@
|
|
|
17
17
|
"main": "./dist/index.cjs",
|
|
18
18
|
"module": "./dist/index.js",
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
|
-
"scripts": {
|
|
21
|
-
"dev": "storybook dev -p 6006",
|
|
22
|
-
"build": "tsc && vite build && node scripts/generate-exports.js",
|
|
23
|
-
"build:story": "storybook build",
|
|
24
|
-
"lint": "eslint --fix src/**/* --report-unused-disable-directives --max-warnings 0",
|
|
25
|
-
"format": "prettier src/**/* --write --ignore-unknown",
|
|
26
|
-
"prepublishOnly": "npm run build",
|
|
27
|
-
"prepare": "husky"
|
|
28
|
-
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"@commitlint/cli": "^19.5.0",
|
|
31
|
-
"@commitlint/config-conventional": "^19.5.0",
|
|
32
|
-
"@dgshahr/dg-theme-tailwind-plugin": "^1.0.3",
|
|
33
|
-
"@eslint/compat": "^1.1.1",
|
|
34
|
-
"@eslint/eslintrc": "^3.1.0",
|
|
35
|
-
"@eslint/js": "^9.11.1",
|
|
36
|
-
"@storybook/addon-actions": "^8.3.2",
|
|
37
|
-
"@storybook/addon-essentials": "^8.3.2",
|
|
38
|
-
"@storybook/blocks": "^8.3.2",
|
|
39
|
-
"@storybook/builder-vite": "^8.3.2",
|
|
40
|
-
"@storybook/react": "^8.3.2",
|
|
41
|
-
"@storybook/react-vite": "^8.3.2",
|
|
42
|
-
"@types/node": "^22.5.5",
|
|
43
|
-
"@types/react": "^18.2.43",
|
|
44
|
-
"@types/react-dom": "^18.2.17",
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "^8.6.0",
|
|
46
|
-
"@typescript-eslint/parser": "^8.6.0",
|
|
47
|
-
"@vitejs/plugin-react-swc": "^3.5.0",
|
|
48
|
-
"autoprefixer": "^10.4.16",
|
|
49
|
-
"clsx": "^2.0.0",
|
|
50
|
-
"eslint": "^9.11.1",
|
|
51
|
-
"eslint-config-prettier": "^9.1.0",
|
|
52
|
-
"eslint-plugin-jest-dom": "^5.1.0",
|
|
53
|
-
"eslint-plugin-react": "^7.33.2",
|
|
54
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
55
|
-
"eslint-plugin-react-refresh": "^0.4.5",
|
|
56
|
-
"eslint-plugin-storybook": "^0.8.0",
|
|
57
|
-
"globals": "^15.9.0",
|
|
58
|
-
"husky": "^9.1.6",
|
|
59
|
-
"jsdom": "^25.0.1",
|
|
60
|
-
"lint-staged": "^15.2.10",
|
|
61
|
-
"postcss": "^8.4.32",
|
|
62
|
-
"prettier": "^3.1.1",
|
|
63
|
-
"react": "^18.2.0",
|
|
64
|
-
"react-dom": "^18.2.0",
|
|
65
|
-
"storybook": "^8.3.2",
|
|
66
|
-
"strip-ansi": "6",
|
|
67
|
-
"tailwindcss": "^3.3.6",
|
|
68
|
-
"typescript": "^5.2.2",
|
|
69
|
-
"vite": "^5.0.8",
|
|
70
|
-
"vite-plugin-dts": "^4.2.1",
|
|
71
|
-
"vite-plugin-lib-inject-css": "^2.1.1"
|
|
72
|
-
},
|
|
73
|
-
"peerDependencies": {
|
|
74
|
-
"react": "^18.2.0",
|
|
75
|
-
"react-dom": "^18.2.0"
|
|
76
|
-
},
|
|
77
|
-
"lint-staged": {
|
|
78
|
-
"*.+(js|jsx|ts|tsx)": [
|
|
79
|
-
"yarn lint",
|
|
80
|
-
"yarn format"
|
|
81
|
-
]
|
|
82
|
-
},
|
|
83
20
|
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.cjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
84
31
|
"./Accordion": {
|
|
85
32
|
"import": {
|
|
86
33
|
"types": "./dist/Accordion/index.d.ts",
|
|
@@ -141,14 +88,44 @@
|
|
|
141
88
|
"default": "./dist/Divider/index.cjs"
|
|
142
89
|
}
|
|
143
90
|
},
|
|
144
|
-
"
|
|
91
|
+
"./Form/Checkbox": {
|
|
145
92
|
"import": {
|
|
146
|
-
"types": "./dist/index.d.ts",
|
|
147
|
-
"default": "./dist/index.js"
|
|
93
|
+
"types": "./dist/Form/Checkbox/index.d.ts",
|
|
94
|
+
"default": "./dist/Form/Checkbox/index.js"
|
|
148
95
|
},
|
|
149
96
|
"require": {
|
|
150
|
-
"types": "./dist/index.d.ts",
|
|
151
|
-
"default": "./dist/index.cjs"
|
|
97
|
+
"types": "./dist/Form/Checkbox/index.d.ts",
|
|
98
|
+
"default": "./dist/Form/Checkbox/index.cjs"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"./Form/Input": {
|
|
102
|
+
"import": {
|
|
103
|
+
"types": "./dist/Form/Input/index.d.ts",
|
|
104
|
+
"default": "./dist/Form/Input/index.js"
|
|
105
|
+
},
|
|
106
|
+
"require": {
|
|
107
|
+
"types": "./dist/Form/Input/index.d.ts",
|
|
108
|
+
"default": "./dist/Form/Input/index.cjs"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"./Form/RadioButton": {
|
|
112
|
+
"import": {
|
|
113
|
+
"types": "./dist/Form/RadioButton/index.d.ts",
|
|
114
|
+
"default": "./dist/Form/RadioButton/index.js"
|
|
115
|
+
},
|
|
116
|
+
"require": {
|
|
117
|
+
"types": "./dist/Form/RadioButton/index.d.ts",
|
|
118
|
+
"default": "./dist/Form/RadioButton/index.cjs"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"./Form/Textarea": {
|
|
122
|
+
"import": {
|
|
123
|
+
"types": "./dist/Form/Textarea/index.d.ts",
|
|
124
|
+
"default": "./dist/Form/Textarea/index.js"
|
|
125
|
+
},
|
|
126
|
+
"require": {
|
|
127
|
+
"types": "./dist/Form/Textarea/index.d.ts",
|
|
128
|
+
"default": "./dist/Form/Textarea/index.cjs"
|
|
152
129
|
}
|
|
153
130
|
},
|
|
154
131
|
"./Pagination": {
|
|
@@ -171,5 +148,73 @@
|
|
|
171
148
|
"default": "./dist/Slider/index.cjs"
|
|
172
149
|
}
|
|
173
150
|
}
|
|
151
|
+
},
|
|
152
|
+
"scripts": {
|
|
153
|
+
"dev": "storybook dev -p 6006",
|
|
154
|
+
"build": "tsc && vite build && node scripts/generate-exports.js",
|
|
155
|
+
"build:story": "storybook build",
|
|
156
|
+
"lint": "eslint --fix src/**/* --report-unused-disable-directives --max-warnings 0 -f codeframe",
|
|
157
|
+
"format": "prettier src/**/* --write --ignore-unknown",
|
|
158
|
+
"prepublishOnly": "npm run build",
|
|
159
|
+
"prepare": "husky",
|
|
160
|
+
"transform-icons": "rm -rf src/icons/ && svgr assets/icons/ --config-file svgr.config.cjs"
|
|
161
|
+
},
|
|
162
|
+
"devDependencies": {
|
|
163
|
+
"@commitlint/cli": "^19.5.0",
|
|
164
|
+
"@commitlint/config-conventional": "^19.5.0",
|
|
165
|
+
"@dgshahr/dg-theme-tailwind-plugin": "^1.0.3",
|
|
166
|
+
"@eslint/compat": "^1.1.1",
|
|
167
|
+
"@eslint/eslintrc": "^3.1.0",
|
|
168
|
+
"@eslint/js": "^9.11.1",
|
|
169
|
+
"@storybook/addon-actions": "^8.3.2",
|
|
170
|
+
"@storybook/addon-essentials": "^8.3.2",
|
|
171
|
+
"@storybook/blocks": "^8.3.2",
|
|
172
|
+
"@storybook/builder-vite": "^8.3.2",
|
|
173
|
+
"@storybook/react": "^8.3.2",
|
|
174
|
+
"@storybook/react-vite": "^8.3.2",
|
|
175
|
+
"@svgr/cli": "^8.1.0",
|
|
176
|
+
"@types/node": "^22.5.5",
|
|
177
|
+
"@types/react": "^18.2.43",
|
|
178
|
+
"@types/react-dom": "^18.2.17",
|
|
179
|
+
"@typescript-eslint/eslint-plugin": "^8.6.0",
|
|
180
|
+
"@typescript-eslint/parser": "^8.6.0",
|
|
181
|
+
"@vitejs/plugin-react-swc": "^3.5.0",
|
|
182
|
+
"autoprefixer": "^10.4.16",
|
|
183
|
+
"clsx": "^2.0.0",
|
|
184
|
+
"eslint": "^9.11.1",
|
|
185
|
+
"eslint-config-prettier": "^9.1.0",
|
|
186
|
+
"eslint-formatter-codeframe": "^7.32.1",
|
|
187
|
+
"eslint-import-resolver-typescript": "^3.6.3",
|
|
188
|
+
"eslint-plugin-import": "^2.30.0",
|
|
189
|
+
"eslint-plugin-jest-dom": "^5.1.0",
|
|
190
|
+
"eslint-plugin-react": "^7.33.2",
|
|
191
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
192
|
+
"eslint-plugin-react-refresh": "^0.4.5",
|
|
193
|
+
"eslint-plugin-storybook": "^0.8.0",
|
|
194
|
+
"globals": "^15.9.0",
|
|
195
|
+
"husky": "^9.1.6",
|
|
196
|
+
"jsdom": "^25.0.1",
|
|
197
|
+
"lint-staged": "^15.2.10",
|
|
198
|
+
"postcss": "^8.4.32",
|
|
199
|
+
"prettier": "^3.1.1",
|
|
200
|
+
"react": "^18.2.0",
|
|
201
|
+
"react-dom": "^18.2.0",
|
|
202
|
+
"storybook": "^8.3.2",
|
|
203
|
+
"strip-ansi": "6",
|
|
204
|
+
"tailwindcss": "^3.3.6",
|
|
205
|
+
"typescript": "^5.2.2",
|
|
206
|
+
"vite": "^5.0.8",
|
|
207
|
+
"vite-plugin-dts": "^4.2.1",
|
|
208
|
+
"vite-plugin-lib-inject-css": "^2.1.1"
|
|
209
|
+
},
|
|
210
|
+
"peerDependencies": {
|
|
211
|
+
"react": "^18.2.0",
|
|
212
|
+
"react-dom": "^18.2.0"
|
|
213
|
+
},
|
|
214
|
+
"lint-staged": {
|
|
215
|
+
"*.+(js|jsx|ts|tsx)": [
|
|
216
|
+
"yarn lint",
|
|
217
|
+
"yarn format"
|
|
218
|
+
]
|
|
174
219
|
}
|
|
175
220
|
}
|
package/dist/Slide-6SD8mElS.js
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { c as clsx } from './clsx-ChV9xqsO.js';
|
|
3
|
-
import { createContext, useContext, useState, useEffect, useRef, Children } from 'react';
|
|
4
|
-
import Button from './Button/index.js';
|
|
5
|
-
import { A as ArrowRight2Icon } from './ArrowRight2-DCxJPvNC.js';
|
|
6
|
-
import { A as ArrowLeft2Icon } from './ArrowLeft2-BURhvXT2.js';
|
|
7
|
-
|
|
8
|
-
const sliderContext = createContext({
|
|
9
|
-
slidesPerView: 1,
|
|
10
|
-
spaceBetween: 0
|
|
11
|
-
});
|
|
12
|
-
const useSliderContext = () => useContext(sliderContext);
|
|
13
|
-
|
|
14
|
-
function styleNavigationDot({ active, autoplay, variant }) {
|
|
15
|
-
const variantClassName = {
|
|
16
|
-
inside: "bg-gray-500/50 hover:bg-gray-500/80",
|
|
17
|
-
outside: "bg-gray-200 hover:bg-gray-300"
|
|
18
|
-
};
|
|
19
|
-
return [variantClassName[variant], active ? "w-[22px]" : "w-[6px]", autoplay ? "p-[1px]" : ""];
|
|
20
|
-
}
|
|
21
|
-
const NavigationDot = (props) => {
|
|
22
|
-
const { active, autoplay, variant, onClick, onNavigateToNext } = props;
|
|
23
|
-
const [fillPercentage, setFillPercentage] = useState(0);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (!active || !autoplay) return;
|
|
26
|
-
const autoplayTime = typeof autoplay === "boolean" ? 7e3 : autoplay?.delay ?? 7e3;
|
|
27
|
-
let startTime = Date.now();
|
|
28
|
-
const autoplayInterval = setInterval(() => {
|
|
29
|
-
const elapsed = Date.now() - startTime;
|
|
30
|
-
const percentage = elapsed / autoplayTime * 100;
|
|
31
|
-
setFillPercentage(Math.min(percentage, 100));
|
|
32
|
-
if (elapsed >= autoplayTime && typeof onNavigateToNext === "function") {
|
|
33
|
-
onNavigateToNext();
|
|
34
|
-
}
|
|
35
|
-
}, 100);
|
|
36
|
-
return function cleanup() {
|
|
37
|
-
setFillPercentage(0);
|
|
38
|
-
startTime = Date.now();
|
|
39
|
-
return clearInterval(autoplayInterval);
|
|
40
|
-
};
|
|
41
|
-
}, [active, autoplay, onNavigateToNext]);
|
|
42
|
-
return /* @__PURE__ */ jsx(
|
|
43
|
-
"button",
|
|
44
|
-
{
|
|
45
|
-
className: clsx(
|
|
46
|
-
"rounded-full overflow-hidden transition-all h-[6px]",
|
|
47
|
-
styleNavigationDot({ active, autoplay, variant })
|
|
48
|
-
),
|
|
49
|
-
onClick,
|
|
50
|
-
children: active && /* @__PURE__ */ jsx(
|
|
51
|
-
"div",
|
|
52
|
-
{
|
|
53
|
-
className: clsx("h-full rounded-full", {
|
|
54
|
-
"bg-white": variant === "inside",
|
|
55
|
-
"bg-gray-700": variant === "outside"
|
|
56
|
-
}),
|
|
57
|
-
style: { width: autoplay ? `${fillPercentage}%` : "100%" }
|
|
58
|
-
}
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const Slider = (props) => {
|
|
65
|
-
const {
|
|
66
|
-
className = "",
|
|
67
|
-
containerClassName = "",
|
|
68
|
-
showNavigationDots = true,
|
|
69
|
-
dotsClassName = "",
|
|
70
|
-
slidesPerView = 1,
|
|
71
|
-
autoplay,
|
|
72
|
-
navigationButtonsShowType = "hide",
|
|
73
|
-
spaceBetween = 0,
|
|
74
|
-
navigationVariant = "outside",
|
|
75
|
-
showPaginationText = false
|
|
76
|
-
} = props;
|
|
77
|
-
const [slideIndex, setSlideIndex] = useState(0);
|
|
78
|
-
const containerRef = useRef(null);
|
|
79
|
-
const childsCount = Children.count(props.children);
|
|
80
|
-
const slidesCount = Math.ceil(childsCount / slidesPerView);
|
|
81
|
-
const haveNavigation = showNavigationDots || navigationButtonsShowType && navigationButtonsShowType !== "hide" || showPaginationText;
|
|
82
|
-
function detectCarouselPosition(e) {
|
|
83
|
-
const itemsWidth = e.currentTarget.scrollWidth / slidesCount;
|
|
84
|
-
const position = (e.currentTarget.scrollWidth - e.currentTarget.scrollLeft) / itemsWidth;
|
|
85
|
-
setSlideIndex(Math.round(position % slidesCount));
|
|
86
|
-
}
|
|
87
|
-
function navigate(target) {
|
|
88
|
-
if (!containerRef.current) return;
|
|
89
|
-
const slideWidth = containerRef.current.offsetWidth;
|
|
90
|
-
let nextSlideScroll = -(slideWidth * target);
|
|
91
|
-
if (target < 0) nextSlideScroll = -(slideWidth * slidesCount);
|
|
92
|
-
else if (target >= slidesCount) nextSlideScroll = 0;
|
|
93
|
-
containerRef.current.scrollTo({
|
|
94
|
-
left: nextSlideScroll,
|
|
95
|
-
behavior: "smooth"
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
return /* @__PURE__ */ jsxs("div", { className: clsx("overflow-hidden relative group", className), children: [
|
|
99
|
-
/* @__PURE__ */ jsx(
|
|
100
|
-
"div",
|
|
101
|
-
{
|
|
102
|
-
className: clsx(
|
|
103
|
-
"flex snap-x snap-mandatory overflow-x-hidden [&>*]:snap-start no-scrollbar [&>*]:snap-always",
|
|
104
|
-
containerClassName
|
|
105
|
-
),
|
|
106
|
-
style: { marginLeft: -spaceBetween },
|
|
107
|
-
onScroll: detectCarouselPosition,
|
|
108
|
-
ref: containerRef,
|
|
109
|
-
children: /* @__PURE__ */ jsx(sliderContext.Provider, { value: { slidesPerView, spaceBetween }, children: props.children })
|
|
110
|
-
}
|
|
111
|
-
),
|
|
112
|
-
haveNavigation && /* @__PURE__ */ jsxs(
|
|
113
|
-
"div",
|
|
114
|
-
{
|
|
115
|
-
className: clsx("flex", {
|
|
116
|
-
"items-center justify-between mt-2": navigationVariant === "outside",
|
|
117
|
-
"absolute bottom-4 w-full justify-center": navigationVariant === "inside"
|
|
118
|
-
}),
|
|
119
|
-
children: [
|
|
120
|
-
navigationButtonsShowType && navigationButtonsShowType !== "hide" && /* @__PURE__ */ jsxs(
|
|
121
|
-
"div",
|
|
122
|
-
{
|
|
123
|
-
className: clsx("flex gap-2", {
|
|
124
|
-
"absolute bottom-0 left-[5.5%]": navigationVariant === "inside",
|
|
125
|
-
"opacity-0 group-hover:opacity-100 transition": navigationButtonsShowType === "hover"
|
|
126
|
-
}),
|
|
127
|
-
children: [
|
|
128
|
-
/* @__PURE__ */ jsx(
|
|
129
|
-
Button,
|
|
130
|
-
{
|
|
131
|
-
type: "button",
|
|
132
|
-
variant: "secondary",
|
|
133
|
-
onClick: () => navigate(slideIndex - 1),
|
|
134
|
-
rightIcon: /* @__PURE__ */ jsx(ArrowRight2Icon, {})
|
|
135
|
-
}
|
|
136
|
-
),
|
|
137
|
-
/* @__PURE__ */ jsx(
|
|
138
|
-
Button,
|
|
139
|
-
{
|
|
140
|
-
type: "button",
|
|
141
|
-
variant: "secondary",
|
|
142
|
-
onClick: () => navigate(slideIndex + 1),
|
|
143
|
-
rightIcon: /* @__PURE__ */ jsx(ArrowLeft2Icon, {})
|
|
144
|
-
}
|
|
145
|
-
)
|
|
146
|
-
]
|
|
147
|
-
}
|
|
148
|
-
),
|
|
149
|
-
(showNavigationDots || showPaginationText) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
150
|
-
showPaginationText && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 font-caption-regular text-gray-400 ss02", children: [
|
|
151
|
-
/* @__PURE__ */ jsx(
|
|
152
|
-
"span",
|
|
153
|
-
{
|
|
154
|
-
className: clsx("font-bold", {
|
|
155
|
-
"text-gray-600": navigationVariant === "outside",
|
|
156
|
-
"text-white": navigationVariant === "inside"
|
|
157
|
-
}),
|
|
158
|
-
children: slideIndex + 1
|
|
159
|
-
}
|
|
160
|
-
),
|
|
161
|
-
/* @__PURE__ */ jsx("span", { children: "از" }),
|
|
162
|
-
/* @__PURE__ */ jsx("span", { children: slidesCount })
|
|
163
|
-
] }),
|
|
164
|
-
showNavigationDots && /* @__PURE__ */ jsx("div", { className: clsx("flex items-center justify-center gap-2", dotsClassName), children: Array.from(Array(slidesCount).keys()).map((item, index) => /* @__PURE__ */ jsx(
|
|
165
|
-
NavigationDot,
|
|
166
|
-
{
|
|
167
|
-
active: slideIndex === index,
|
|
168
|
-
autoplay: autoplay ?? false,
|
|
169
|
-
variant: navigationVariant,
|
|
170
|
-
onClick: () => navigate(index),
|
|
171
|
-
onNavigateToNext: () => navigate(slideIndex + 1)
|
|
172
|
-
},
|
|
173
|
-
item + slidesCount
|
|
174
|
-
)) })
|
|
175
|
-
] })
|
|
176
|
-
]
|
|
177
|
-
}
|
|
178
|
-
)
|
|
179
|
-
] });
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const Slide = (props) => {
|
|
183
|
-
const { children, className } = props;
|
|
184
|
-
const { slidesPerView, spaceBetween } = useSliderContext();
|
|
185
|
-
return /* @__PURE__ */ jsx(
|
|
186
|
-
"div",
|
|
187
|
-
{
|
|
188
|
-
className: clsx("shrink-0", className),
|
|
189
|
-
style: {
|
|
190
|
-
width: 100 / (slidesPerView ?? 1) + "%",
|
|
191
|
-
paddingLeft: spaceBetween
|
|
192
|
-
},
|
|
193
|
-
children
|
|
194
|
-
}
|
|
195
|
-
);
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
export { Slider as S, Slide as a };
|
package/dist/Slide-BiCQh7AV.cjs
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
const clsx = require('./clsx-BtxeOLZW.cjs');
|
|
5
|
-
const react = require('react');
|
|
6
|
-
const Button = require('./Button/index.cjs');
|
|
7
|
-
const ArrowRight2 = require('./ArrowRight2-DTuru_sP.cjs');
|
|
8
|
-
const ArrowLeft2 = require('./ArrowLeft2-iZ0Au6Fn.cjs');
|
|
9
|
-
|
|
10
|
-
const sliderContext = react.createContext({
|
|
11
|
-
slidesPerView: 1,
|
|
12
|
-
spaceBetween: 0
|
|
13
|
-
});
|
|
14
|
-
const useSliderContext = () => react.useContext(sliderContext);
|
|
15
|
-
|
|
16
|
-
function styleNavigationDot({ active, autoplay, variant }) {
|
|
17
|
-
const variantClassName = {
|
|
18
|
-
inside: "bg-gray-500/50 hover:bg-gray-500/80",
|
|
19
|
-
outside: "bg-gray-200 hover:bg-gray-300"
|
|
20
|
-
};
|
|
21
|
-
return [variantClassName[variant], active ? "w-[22px]" : "w-[6px]", autoplay ? "p-[1px]" : ""];
|
|
22
|
-
}
|
|
23
|
-
const NavigationDot = (props) => {
|
|
24
|
-
const { active, autoplay, variant, onClick, onNavigateToNext } = props;
|
|
25
|
-
const [fillPercentage, setFillPercentage] = react.useState(0);
|
|
26
|
-
react.useEffect(() => {
|
|
27
|
-
if (!active || !autoplay) return;
|
|
28
|
-
const autoplayTime = typeof autoplay === "boolean" ? 7e3 : autoplay?.delay ?? 7e3;
|
|
29
|
-
let startTime = Date.now();
|
|
30
|
-
const autoplayInterval = setInterval(() => {
|
|
31
|
-
const elapsed = Date.now() - startTime;
|
|
32
|
-
const percentage = elapsed / autoplayTime * 100;
|
|
33
|
-
setFillPercentage(Math.min(percentage, 100));
|
|
34
|
-
if (elapsed >= autoplayTime && typeof onNavigateToNext === "function") {
|
|
35
|
-
onNavigateToNext();
|
|
36
|
-
}
|
|
37
|
-
}, 100);
|
|
38
|
-
return function cleanup() {
|
|
39
|
-
setFillPercentage(0);
|
|
40
|
-
startTime = Date.now();
|
|
41
|
-
return clearInterval(autoplayInterval);
|
|
42
|
-
};
|
|
43
|
-
}, [active, autoplay, onNavigateToNext]);
|
|
44
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
45
|
-
"button",
|
|
46
|
-
{
|
|
47
|
-
className: clsx.clsx(
|
|
48
|
-
"rounded-full overflow-hidden transition-all h-[6px]",
|
|
49
|
-
styleNavigationDot({ active, autoplay, variant })
|
|
50
|
-
),
|
|
51
|
-
onClick,
|
|
52
|
-
children: active && /* @__PURE__ */ jsxRuntime.jsx(
|
|
53
|
-
"div",
|
|
54
|
-
{
|
|
55
|
-
className: clsx.clsx("h-full rounded-full", {
|
|
56
|
-
"bg-white": variant === "inside",
|
|
57
|
-
"bg-gray-700": variant === "outside"
|
|
58
|
-
}),
|
|
59
|
-
style: { width: autoplay ? `${fillPercentage}%` : "100%" }
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const Slider = (props) => {
|
|
67
|
-
const {
|
|
68
|
-
className = "",
|
|
69
|
-
containerClassName = "",
|
|
70
|
-
showNavigationDots = true,
|
|
71
|
-
dotsClassName = "",
|
|
72
|
-
slidesPerView = 1,
|
|
73
|
-
autoplay,
|
|
74
|
-
navigationButtonsShowType = "hide",
|
|
75
|
-
spaceBetween = 0,
|
|
76
|
-
navigationVariant = "outside",
|
|
77
|
-
showPaginationText = false
|
|
78
|
-
} = props;
|
|
79
|
-
const [slideIndex, setSlideIndex] = react.useState(0);
|
|
80
|
-
const containerRef = react.useRef(null);
|
|
81
|
-
const childsCount = react.Children.count(props.children);
|
|
82
|
-
const slidesCount = Math.ceil(childsCount / slidesPerView);
|
|
83
|
-
const haveNavigation = showNavigationDots || navigationButtonsShowType && navigationButtonsShowType !== "hide" || showPaginationText;
|
|
84
|
-
function detectCarouselPosition(e) {
|
|
85
|
-
const itemsWidth = e.currentTarget.scrollWidth / slidesCount;
|
|
86
|
-
const position = (e.currentTarget.scrollWidth - e.currentTarget.scrollLeft) / itemsWidth;
|
|
87
|
-
setSlideIndex(Math.round(position % slidesCount));
|
|
88
|
-
}
|
|
89
|
-
function navigate(target) {
|
|
90
|
-
if (!containerRef.current) return;
|
|
91
|
-
const slideWidth = containerRef.current.offsetWidth;
|
|
92
|
-
let nextSlideScroll = -(slideWidth * target);
|
|
93
|
-
if (target < 0) nextSlideScroll = -(slideWidth * slidesCount);
|
|
94
|
-
else if (target >= slidesCount) nextSlideScroll = 0;
|
|
95
|
-
containerRef.current.scrollTo({
|
|
96
|
-
left: nextSlideScroll,
|
|
97
|
-
behavior: "smooth"
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx.clsx("overflow-hidden relative group", className), children: [
|
|
101
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
102
|
-
"div",
|
|
103
|
-
{
|
|
104
|
-
className: clsx.clsx(
|
|
105
|
-
"flex snap-x snap-mandatory overflow-x-hidden [&>*]:snap-start no-scrollbar [&>*]:snap-always",
|
|
106
|
-
containerClassName
|
|
107
|
-
),
|
|
108
|
-
style: { marginLeft: -spaceBetween },
|
|
109
|
-
onScroll: detectCarouselPosition,
|
|
110
|
-
ref: containerRef,
|
|
111
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(sliderContext.Provider, { value: { slidesPerView, spaceBetween }, children: props.children })
|
|
112
|
-
}
|
|
113
|
-
),
|
|
114
|
-
haveNavigation && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
115
|
-
"div",
|
|
116
|
-
{
|
|
117
|
-
className: clsx.clsx("flex", {
|
|
118
|
-
"items-center justify-between mt-2": navigationVariant === "outside",
|
|
119
|
-
"absolute bottom-4 w-full justify-center": navigationVariant === "inside"
|
|
120
|
-
}),
|
|
121
|
-
children: [
|
|
122
|
-
navigationButtonsShowType && navigationButtonsShowType !== "hide" && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
123
|
-
"div",
|
|
124
|
-
{
|
|
125
|
-
className: clsx.clsx("flex gap-2", {
|
|
126
|
-
"absolute bottom-0 left-[5.5%]": navigationVariant === "inside",
|
|
127
|
-
"opacity-0 group-hover:opacity-100 transition": navigationButtonsShowType === "hover"
|
|
128
|
-
}),
|
|
129
|
-
children: [
|
|
130
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
131
|
-
Button,
|
|
132
|
-
{
|
|
133
|
-
type: "button",
|
|
134
|
-
variant: "secondary",
|
|
135
|
-
onClick: () => navigate(slideIndex - 1),
|
|
136
|
-
rightIcon: /* @__PURE__ */ jsxRuntime.jsx(ArrowRight2.ArrowRight2Icon, {})
|
|
137
|
-
}
|
|
138
|
-
),
|
|
139
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
140
|
-
Button,
|
|
141
|
-
{
|
|
142
|
-
type: "button",
|
|
143
|
-
variant: "secondary",
|
|
144
|
-
onClick: () => navigate(slideIndex + 1),
|
|
145
|
-
rightIcon: /* @__PURE__ */ jsxRuntime.jsx(ArrowLeft2.ArrowLeft2Icon, {})
|
|
146
|
-
}
|
|
147
|
-
)
|
|
148
|
-
]
|
|
149
|
-
}
|
|
150
|
-
),
|
|
151
|
-
(showNavigationDots || showPaginationText) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
152
|
-
showPaginationText && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 font-caption-regular text-gray-400 ss02", children: [
|
|
153
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
154
|
-
"span",
|
|
155
|
-
{
|
|
156
|
-
className: clsx.clsx("font-bold", {
|
|
157
|
-
"text-gray-600": navigationVariant === "outside",
|
|
158
|
-
"text-white": navigationVariant === "inside"
|
|
159
|
-
}),
|
|
160
|
-
children: slideIndex + 1
|
|
161
|
-
}
|
|
162
|
-
),
|
|
163
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "از" }),
|
|
164
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: slidesCount })
|
|
165
|
-
] }),
|
|
166
|
-
showNavigationDots && /* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx.clsx("flex items-center justify-center gap-2", dotsClassName), children: Array.from(Array(slidesCount).keys()).map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
167
|
-
NavigationDot,
|
|
168
|
-
{
|
|
169
|
-
active: slideIndex === index,
|
|
170
|
-
autoplay: autoplay ?? false,
|
|
171
|
-
variant: navigationVariant,
|
|
172
|
-
onClick: () => navigate(index),
|
|
173
|
-
onNavigateToNext: () => navigate(slideIndex + 1)
|
|
174
|
-
},
|
|
175
|
-
item + slidesCount
|
|
176
|
-
)) })
|
|
177
|
-
] })
|
|
178
|
-
]
|
|
179
|
-
}
|
|
180
|
-
)
|
|
181
|
-
] });
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const Slide = (props) => {
|
|
185
|
-
const { children, className } = props;
|
|
186
|
-
const { slidesPerView, spaceBetween } = useSliderContext();
|
|
187
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
188
|
-
"div",
|
|
189
|
-
{
|
|
190
|
-
className: clsx.clsx("shrink-0", className),
|
|
191
|
-
style: {
|
|
192
|
-
width: 100 / (slidesPerView ?? 1) + "%",
|
|
193
|
-
paddingLeft: spaceBetween
|
|
194
|
-
},
|
|
195
|
-
children
|
|
196
|
-
}
|
|
197
|
-
);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
exports.Slide = Slide;
|
|
201
|
-
exports.Slider = Slider;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { createContext, useContext, useState, useId } from 'react';
|
|
3
2
|
import { c as clsx } from './clsx-ChV9xqsO.js';
|
|
3
|
+
import { createContext, useContext, useState, useId } from 'react';
|
|
4
4
|
import Divider from './Divider/index.js';
|
|
5
5
|
|
|
6
6
|
const accordionContext = createContext({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
const react = require('react');
|
|
5
4
|
const clsx = require('./clsx-BtxeOLZW.cjs');
|
|
5
|
+
const react = require('react');
|
|
6
6
|
const Divider = require('./Divider/index.cjs');
|
|
7
7
|
|
|
8
8
|
const accordionContext = react.createContext({
|