react-styled-slider-component 0.1.4 → 0.1.6
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.
|
@@ -10,12 +10,16 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { useState } from "react";
|
|
13
|
+
import React, { useState } from "react";
|
|
14
14
|
import { SliderWrapper, SlideTrack, Slide, DotsWrapper, Dot, Arrow, } from "./SliderStyles.styles";
|
|
15
15
|
var Slider = function (_a) {
|
|
16
16
|
var children = _a.children, _b = _a.visibleSlides, visibleSlides = _b === void 0 ? 1 : _b, _c = _a.showDots, showDots = _c === void 0 ? true : _c, _d = _a.showArrows, showArrows = _d === void 0 ? true : _d, _e = _a.dotsPosition, dotsPosition = _e === void 0 ? "bottom" : _e, _f = _a.slideStep, slideStep = _f === void 0 ? 1 : _f, _g = _a.direction, direction = _g === void 0 ? "horizontal" : _g, _h = _a.arrowStyle, arrowStyle = _h === void 0 ? "minimal" : _h, _j = _a.arrowColor, arrowColor = _j === void 0 ? "black" : _j;
|
|
17
|
+
// Hooks must always be called unconditionally
|
|
17
18
|
var _k = useState(0), currentIndex = _k[0], setCurrentIndex = _k[1];
|
|
18
|
-
|
|
19
|
+
if (!children || React.Children.count(children) === 0) {
|
|
20
|
+
return null; // Return null if children is null, avoiding rendering anything
|
|
21
|
+
}
|
|
22
|
+
var totalSlides = React.Children.count(children);
|
|
19
23
|
// Maximum index value, preventing overflow when navigating through slides.
|
|
20
24
|
var maxIndex = totalSlides - visibleSlides;
|
|
21
25
|
// Calculate the number of dots based on the total number of slides and the number of visible slides.
|
|
@@ -47,7 +51,7 @@ var Slider = function (_a) {
|
|
|
47
51
|
height: isHorizontal ? "auto" : "".concat(totalSlides * 100, "%"),
|
|
48
52
|
transition: "transform 0.3s ease-in-out",
|
|
49
53
|
boxSizing: "border-box",
|
|
50
|
-
} }, { children:
|
|
54
|
+
} }, { children: React.Children.map(children, function (child, index) { return (_jsx(Slide, __assign({ visibleSlides: visibleSlides, style: {
|
|
51
55
|
flex: isHorizontal ? "0 0 ".concat(slidePercentage, "%") : "1",
|
|
52
56
|
width: isHorizontal ? "".concat(slidePercentage, "%") : "100%",
|
|
53
57
|
height: isHorizontal ? "auto" : "".concat(100 / totalSlides, "%"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-styled-slider-component",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "A customizable React slider component built with react ts and styled-components.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,23 +28,18 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@testing-library/jest-dom": "^5.17.0",
|
|
32
|
-
"@testing-library/react": "^13.4.0",
|
|
33
|
-
"@testing-library/user-event": "^13.5.0",
|
|
34
|
-
"@types/jest": "^27.5.2",
|
|
35
|
-
"@types/node": "^16.18.107",
|
|
36
|
-
"@types/react": "^18.3.5",
|
|
37
|
-
"@types/react-dom": "^18.3.0",
|
|
38
|
-
"react": "^18.3.1",
|
|
39
|
-
"react-dom": "^18.3.1",
|
|
40
31
|
"react-scripts": "5.0.1",
|
|
41
|
-
"styled-components": "^6.1.13",
|
|
42
32
|
"typescript": "^4.9.5",
|
|
43
33
|
"web-vitals": "^2.1.4"
|
|
44
34
|
},
|
|
45
35
|
"devDependencies": {
|
|
46
36
|
"typescript": "^4.9.5"
|
|
47
37
|
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"react": "^18.0.0 || ^17.0.0",
|
|
40
|
+
"react-dom": "^18.0.0 || ^17.0.0",
|
|
41
|
+
"styled-components": "^5.0.0 || ^6.0.0"
|
|
42
|
+
},
|
|
48
43
|
"eslintConfig": {
|
|
49
44
|
"extends": [
|
|
50
45
|
"react-app",
|