@citygross/components 0.7.209 → 0.7.211

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.
@@ -17,10 +17,8 @@ var SlickSlider__default = /*#__PURE__*/_interopDefaultLegacy(SlickSlider);
17
17
 
18
18
  var defaultSlides = 5;
19
19
  var Slider = function (_a) {
20
- var children = _a.children, slotsLength = _a.slotsLength, _b = _a.iconHeight, iconHeight = _b === void 0 ? 32 : _b, _c = _a.iconWidth, iconWidth = _c === void 0 ? 32 : _c, _d = _a.iconColor, iconColor = _d === void 0 ? 'darkest' : _d, _e = _a.initialSlot, initialSlot = _e === void 0 ? 7 : _e, responsiveSettings = _a.responsiveSettings;
21
- var _f = React.useState(false), isMax = _f[0], setIsMax = _f[1];
22
- var _g = React.useState(true), isMin = _g[0], setIsMin = _g[1];
23
- var _h = React.useState(initialSlot), currentPage = _h[0], setCurrentPage = _h[1];
20
+ var children = _a.children, slotsLength = _a.slotsLength, _b = _a.iconHeight, iconHeight = _b === void 0 ? 32 : _b, _c = _a.iconWidth, iconWidth = _c === void 0 ? 32 : _c, _d = _a.iconColor, iconColor = _d === void 0 ? 'darkest' : _d, _e = _a.initialSlot, initialSlot = _e === void 0 ? 0 : _e, responsiveSettings = _a.responsiveSettings;
21
+ var _f = React.useState(initialSlot), currentPage = _f[0], setCurrentPage = _f[1];
24
22
  var width = utils.useWindowSize().width;
25
23
  var ref = React.useRef(null);
26
24
  var resizeSlides = React.useMemo(function () {
@@ -28,7 +26,6 @@ var Slider = function (_a) {
28
26
  var _a;
29
27
  return {
30
28
  breakpoint: item.breakpoint,
31
- // @ts-ignore
32
29
  slidesToShow: (_a = item.settings) === null || _a === void 0 ? void 0 : _a.slidesToScroll
33
30
  };
34
31
  }).sort(function (a, b) { return a.breakpoint - b.breakpoint; });
@@ -51,42 +48,7 @@ var Slider = function (_a) {
51
48
  touchMove: true,
52
49
  arrows: false,
53
50
  beforeChange: function (_, next) {
54
- var _a, _b;
55
- var totalPages = (_b = Math.ceil((_a = slotsLength / resizeSlides) !== null && _a !== void 0 ? _a : 0)) !== null && _b !== void 0 ? _b : 0;
56
- var curPage = next / totalPages;
57
- var slides = slotsLength || 0;
58
51
  setCurrentPage(next);
59
- if (curPage === 0 || next === 0) {
60
- setIsMin(true);
61
- setIsMax(false);
62
- return;
63
- }
64
- if (next + resizeSlides >= slides) {
65
- setIsMax(true);
66
- setIsMin(false);
67
- return;
68
- }
69
- setIsMax(false);
70
- setIsMin(false);
71
- },
72
- onInit: function () {
73
- var _a, _b;
74
- var totalPages = (_b = Math.ceil((_a = slotsLength / resizeSlides) !== null && _a !== void 0 ? _a : 0)) !== null && _b !== void 0 ? _b : 0;
75
- var curPage = initialSlot / totalPages;
76
- var slides = slotsLength || 0;
77
- setCurrentPage(curPage);
78
- if (curPage === 0 || initialSlot === 0) {
79
- setIsMin(true);
80
- setIsMax(false);
81
- return;
82
- }
83
- if (initialSlot + resizeSlides >= slides) {
84
- setIsMax(true);
85
- setIsMin(false);
86
- return;
87
- }
88
- setIsMax(false);
89
- setIsMin(false);
90
52
  },
91
53
  responsive: responsiveSettings
92
54
  };
@@ -94,14 +56,14 @@ var Slider = function (_a) {
94
56
  React__default["default"].createElement(Slider_styles.Container, null,
95
57
  React__default["default"].createElement(SlickSlider__default["default"], _tslib.__assign({ ref: ref }, settings), children),
96
58
  React__default["default"].createElement(Slider_styles.LeftIconButtonContainer, null,
97
- React__default["default"].createElement(IconButton.IconButton, { isDisabled: isMin, color: iconColor, icon: React__default["default"].createElement(Icon.Icons.ChevronLeft, { color: 'white' }), height: iconHeight, width: iconWidth, borderRadius: 100, onClick: function () {
59
+ React__default["default"].createElement(IconButton.IconButton, { isDisabled: currentPage < 1, color: iconColor, icon: React__default["default"].createElement(Icon.Icons.ChevronLeft, { color: 'white' }), height: iconHeight, width: iconWidth, borderRadius: 100, onClick: function () {
98
60
  var _a;
99
- var prevPage = pageSections.reverse().find(function (section) { return section < currentPage; }) ||
100
- 0;
61
+ var prevSections = pageSections.slice().reverse();
62
+ var prevPage = prevSections.find(function (section) { return section < currentPage; }) || 0;
101
63
  (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.slickGoTo(prevPage);
102
64
  } })),
103
65
  React__default["default"].createElement(Slider_styles.RightIconButtonContainer, null,
104
- React__default["default"].createElement(IconButton.IconButton, { isDisabled: isMax, color: iconColor, icon: React__default["default"].createElement(Icon.Icons.ChevronRight, { color: 'white' }), height: iconHeight, width: iconWidth, borderRadius: 100, onClick: function () {
66
+ React__default["default"].createElement(IconButton.IconButton, { isDisabled: currentPage + resizeSlides >= slotsLength, color: iconColor, icon: React__default["default"].createElement(Icon.Icons.ChevronRight, { color: 'white' }), height: iconHeight, width: iconWidth, borderRadius: 100, onClick: function () {
105
67
  var _a;
106
68
  var nextPage = pageSections.find(function (section) { return section > currentPage; }) ||
107
69
  pageSections[(pageSections === null || pageSections === void 0 ? void 0 : pageSections.length) - 1];
@@ -1 +1 @@
1
- {"version":3,"file":"Slider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Slider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -8,10 +8,8 @@ import { useWindowSize } from '@citygross/utils';
8
8
 
9
9
  var defaultSlides = 5;
10
10
  var Slider = function (_a) {
11
- var children = _a.children, slotsLength = _a.slotsLength, _b = _a.iconHeight, iconHeight = _b === void 0 ? 32 : _b, _c = _a.iconWidth, iconWidth = _c === void 0 ? 32 : _c, _d = _a.iconColor, iconColor = _d === void 0 ? 'darkest' : _d, _e = _a.initialSlot, initialSlot = _e === void 0 ? 7 : _e, responsiveSettings = _a.responsiveSettings;
12
- var _f = useState(false), isMax = _f[0], setIsMax = _f[1];
13
- var _g = useState(true), isMin = _g[0], setIsMin = _g[1];
14
- var _h = useState(initialSlot), currentPage = _h[0], setCurrentPage = _h[1];
11
+ var children = _a.children, slotsLength = _a.slotsLength, _b = _a.iconHeight, iconHeight = _b === void 0 ? 32 : _b, _c = _a.iconWidth, iconWidth = _c === void 0 ? 32 : _c, _d = _a.iconColor, iconColor = _d === void 0 ? 'darkest' : _d, _e = _a.initialSlot, initialSlot = _e === void 0 ? 0 : _e, responsiveSettings = _a.responsiveSettings;
12
+ var _f = useState(initialSlot), currentPage = _f[0], setCurrentPage = _f[1];
15
13
  var width = useWindowSize().width;
16
14
  var ref = useRef(null);
17
15
  var resizeSlides = useMemo(function () {
@@ -19,7 +17,6 @@ var Slider = function (_a) {
19
17
  var _a;
20
18
  return {
21
19
  breakpoint: item.breakpoint,
22
- // @ts-ignore
23
20
  slidesToShow: (_a = item.settings) === null || _a === void 0 ? void 0 : _a.slidesToScroll
24
21
  };
25
22
  }).sort(function (a, b) { return a.breakpoint - b.breakpoint; });
@@ -42,42 +39,7 @@ var Slider = function (_a) {
42
39
  touchMove: true,
43
40
  arrows: false,
44
41
  beforeChange: function (_, next) {
45
- var _a, _b;
46
- var totalPages = (_b = Math.ceil((_a = slotsLength / resizeSlides) !== null && _a !== void 0 ? _a : 0)) !== null && _b !== void 0 ? _b : 0;
47
- var curPage = next / totalPages;
48
- var slides = slotsLength || 0;
49
42
  setCurrentPage(next);
50
- if (curPage === 0 || next === 0) {
51
- setIsMin(true);
52
- setIsMax(false);
53
- return;
54
- }
55
- if (next + resizeSlides >= slides) {
56
- setIsMax(true);
57
- setIsMin(false);
58
- return;
59
- }
60
- setIsMax(false);
61
- setIsMin(false);
62
- },
63
- onInit: function () {
64
- var _a, _b;
65
- var totalPages = (_b = Math.ceil((_a = slotsLength / resizeSlides) !== null && _a !== void 0 ? _a : 0)) !== null && _b !== void 0 ? _b : 0;
66
- var curPage = initialSlot / totalPages;
67
- var slides = slotsLength || 0;
68
- setCurrentPage(curPage);
69
- if (curPage === 0 || initialSlot === 0) {
70
- setIsMin(true);
71
- setIsMax(false);
72
- return;
73
- }
74
- if (initialSlot + resizeSlides >= slides) {
75
- setIsMax(true);
76
- setIsMin(false);
77
- return;
78
- }
79
- setIsMax(false);
80
- setIsMin(false);
81
43
  },
82
44
  responsive: responsiveSettings
83
45
  };
@@ -85,14 +47,14 @@ var Slider = function (_a) {
85
47
  React.createElement(Container, null,
86
48
  React.createElement(SlickSlider, __assign({ ref: ref }, settings), children),
87
49
  React.createElement(LeftIconButtonContainer, null,
88
- React.createElement(IconButton, { isDisabled: isMin, color: iconColor, icon: React.createElement(Icons.ChevronLeft, { color: 'white' }), height: iconHeight, width: iconWidth, borderRadius: 100, onClick: function () {
50
+ React.createElement(IconButton, { isDisabled: currentPage < 1, color: iconColor, icon: React.createElement(Icons.ChevronLeft, { color: 'white' }), height: iconHeight, width: iconWidth, borderRadius: 100, onClick: function () {
89
51
  var _a;
90
- var prevPage = pageSections.reverse().find(function (section) { return section < currentPage; }) ||
91
- 0;
52
+ var prevSections = pageSections.slice().reverse();
53
+ var prevPage = prevSections.find(function (section) { return section < currentPage; }) || 0;
92
54
  (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.slickGoTo(prevPage);
93
55
  } })),
94
56
  React.createElement(RightIconButtonContainer, null,
95
- React.createElement(IconButton, { isDisabled: isMax, color: iconColor, icon: React.createElement(Icons.ChevronRight, { color: 'white' }), height: iconHeight, width: iconWidth, borderRadius: 100, onClick: function () {
57
+ React.createElement(IconButton, { isDisabled: currentPage + resizeSlides >= slotsLength, color: iconColor, icon: React.createElement(Icons.ChevronRight, { color: 'white' }), height: iconHeight, width: iconWidth, borderRadius: 100, onClick: function () {
96
58
  var _a;
97
59
  var nextPage = pageSections.find(function (section) { return section > currentPage; }) ||
98
60
  pageSections[(pageSections === null || pageSections === void 0 ? void 0 : pageSections.length) - 1];
@@ -1 +1 @@
1
- {"version":3,"file":"Slider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Slider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citygross/components",
3
- "version": "0.7.209",
3
+ "version": "0.7.211",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "./build/cjs/components/src/index.js",
@@ -74,5 +74,5 @@
74
74
  "react-slick": "^0.30.1",
75
75
  "slick-carousel": "^1.8.1"
76
76
  },
77
- "gitHead": "28adf3a3331e88dd821aa1a816db9ee4bb280b89"
77
+ "gitHead": "d46519d614514f303d66b6d91da301993d0a9fcc"
78
78
  }