@semcore/carousel 3.17.1-prerelease.1 → 3.18.0
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/CHANGELOG.md +7 -1
- package/lib/cjs/Carousel.js +424 -263
- package/lib/cjs/Carousel.js.map +1 -1
- package/lib/cjs/Carousel.types.js +2 -0
- package/lib/cjs/Carousel.types.js.map +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/carousel.shadow.css +19 -2
- package/lib/es6/Carousel.js +426 -264
- package/lib/es6/Carousel.js.map +1 -1
- package/lib/es6/Carousel.types.js +2 -0
- package/lib/es6/Carousel.types.js.map +1 -0
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/carousel.shadow.css +19 -2
- package/package.json +8 -5
- package/src/Carousel.tsx +676 -0
- package/src/Carousel.types.ts +122 -0
- package/src/style/carousel.shadow.css +19 -2
- package/lib/cjs/index.d.js +0 -2
- package/lib/cjs/index.d.js.map +0 -1
- package/lib/es6/index.d.js +0 -2
- package/lib/es6/index.d.js.map +0 -1
- package/lib/types/index.d.ts +0 -76
- package/src/Carousel.jsx +0 -458
- package/src/index.d.ts +0 -76
- /package/src/{index.js → index.ts} +0 -0
package/lib/es6/Carousel.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
3
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
3
4
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
@@ -8,6 +9,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
8
9
|
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
9
10
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
11
|
import { sstyled as _sstyled } from "@semcore/core";
|
|
12
|
+
import { assignProps as _assignProps9 } from "@semcore/core";
|
|
11
13
|
import { assignProps as _assignProps8 } from "@semcore/core";
|
|
12
14
|
import { assignProps as _assignProps7 } from "@semcore/core";
|
|
13
15
|
import { assignProps as _assignProps6 } from "@semcore/core";
|
|
@@ -18,118 +20,95 @@ import { assignProps as _assignProps2 } from "@semcore/core";
|
|
|
18
20
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
19
21
|
import React from 'react';
|
|
20
22
|
import createComponent, { Component, sstyled, Root } from '@semcore/core';
|
|
21
|
-
import
|
|
23
|
+
import Button from '@semcore/button';
|
|
24
|
+
import Modal from '@semcore/modal';
|
|
25
|
+
import { Box, Flex } from '@semcore/flex-box';
|
|
22
26
|
import ChevronRight from '@semcore/icon/ChevronRight/l';
|
|
23
27
|
import ChevronLeft from '@semcore/icon/ChevronLeft/l';
|
|
24
28
|
import uniqueIDEnhancement from '@semcore/utils/lib/uniqueID';
|
|
25
29
|
import i18nEnhance from '@semcore/utils/lib/enhances/i18nEnhance';
|
|
26
30
|
import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
|
|
31
|
+
import logger from '@semcore/utils/lib/logger';
|
|
27
32
|
/*__reshadow-styles__:"./style/carousel.shadow.css"*/
|
|
28
|
-
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".
|
|
29
|
-
"__SCarousel": "
|
|
30
|
-
"__SContainer": "
|
|
31
|
-
"--duration": "--
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
33
|
+
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SCarousel_6hx6h_gg_{overflow:hidden;outline:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.___SContainer_6hx6h_gg_,.___SModalContainer_6hx6h_gg_{display:flex;transition:transform var(--duration_6hx6h) ease-in-out}.___SItem_6hx6h_gg_{flex:0 0 100%;max-width:100%;box-sizing:border-box;transform:var(--transform_6hx6h);border-radius:var(--intergalactic-surface-rounded, 6px);overflow:hidden}.___SItem_6hx6h_gg_.__zoomIn_6hx6h_gg_{cursor:zoom-in}.___SItem_6hx6h_gg_.__zoomOut_6hx6h_gg_{cursor:zoom-out}.___SIndicators_6hx6h_gg_{display:flex;justify-content:center;margin-top:var(--intergalactic-spacing-4x, 16px)}.___SIndicator_6hx6h_gg_{margin:0 calc(.5*var(--intergalactic-spacing-3x, 12px));cursor:pointer;display:block;width:12px;height:12px;border-radius:var(--intergalactic-control-rounded, 6px);background-color:var(--intergalactic-icon-secondary-neutral, #a9abb6);opacity:var(--intergalactic-disabled-opacity, 0.3);-o-object-fit:cover;object-fit:cover;transition:ease-in-out opacity .1s}@media (hover:hover){.___SIndicator_6hx6h_gg_:hover{opacity:calc(2*var(--intergalactic-disabled-opacity, 0.3))}}.___SIndicator_6hx6h_gg_.__active_6hx6h_gg_{opacity:1}.___SIndicator_6hx6h_gg_.__inverted_6hx6h_gg_{background-color:var(--intergalactic-icon-primary-invert, #ffffff)}.___SNext_6hx6h_gg_,.___SPrev_6hx6h_gg_{display:inline-flex;align-items:center;justify-content:center;cursor:pointer;color:var(--intergalactic-icon-primary-neutral, #6c6e79)}.___SPrev_6hx6h_gg_{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SNext_6hx6h_gg_{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SNext_6hx6h_gg_.__disabled_6hx6h_gg_,.___SPrev_6hx6h_gg_.__disabled_6hx6h_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}@media (prefers-reduced-motion){.___SContainer_6hx6h_gg_{transition:none}}" /*__inner_css_end__*/, "6hx6h_gg_") /*__reshadow_css_end__*/, {
|
|
34
|
+
"__SCarousel": "___SCarousel_6hx6h_gg_",
|
|
35
|
+
"__SContainer": "___SContainer_6hx6h_gg_",
|
|
36
|
+
"--duration": "--duration_6hx6h",
|
|
37
|
+
"__SModalContainer": "___SModalContainer_6hx6h_gg_",
|
|
38
|
+
"__SItem": "___SItem_6hx6h_gg_",
|
|
39
|
+
"--transform": "--transform_6hx6h",
|
|
40
|
+
"_zoomIn": "__zoomIn_6hx6h_gg_",
|
|
41
|
+
"_zoomOut": "__zoomOut_6hx6h_gg_",
|
|
42
|
+
"__SIndicators": "___SIndicators_6hx6h_gg_",
|
|
43
|
+
"__SIndicator": "___SIndicator_6hx6h_gg_",
|
|
44
|
+
"_active": "__active_6hx6h_gg_",
|
|
45
|
+
"_inverted": "__inverted_6hx6h_gg_",
|
|
46
|
+
"__SPrev": "___SPrev_6hx6h_gg_",
|
|
47
|
+
"__SNext": "___SNext_6hx6h_gg_",
|
|
48
|
+
"_disabled": "__disabled_6hx6h_gg_"
|
|
40
49
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var indexItem = 0;
|
|
44
|
-
items.forEach(function (item, index) {
|
|
45
|
-
if (item.position < items[indexItem].position) {
|
|
46
|
-
indexItem = index;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return indexItem;
|
|
50
|
-
},
|
|
51
|
-
getItemMax: function getItemMax(items) {
|
|
52
|
-
var indexItem = 0;
|
|
53
|
-
items.forEach(function (item, index) {
|
|
54
|
-
if (item.position > items[indexItem].position) {
|
|
55
|
-
indexItem = index;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
return indexItem;
|
|
59
|
-
},
|
|
60
|
-
getMin: function getMin(items) {
|
|
61
|
-
return items[position.getItemMin(items)].position;
|
|
62
|
-
},
|
|
63
|
-
getMax: function getMax(items) {
|
|
64
|
-
return items[position.getItemMax(items)].position;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
50
|
+
import { findAllComponents } from '@semcore/utils/lib/findComponent';
|
|
51
|
+
import { createBreakpoints } from '@semcore/breakpoints';
|
|
67
52
|
var MAP_TRANSFORM = {
|
|
68
53
|
ArrowLeft: 'left',
|
|
69
54
|
ArrowRight: 'right'
|
|
70
55
|
};
|
|
56
|
+
var enhance = {
|
|
57
|
+
uid: uniqueIDEnhancement(),
|
|
58
|
+
getI18nText: i18nEnhance(localizedMessages)
|
|
59
|
+
};
|
|
60
|
+
var media = ['(min-width: 481px)', '(max-width: 480px)'];
|
|
61
|
+
var BreakPoints = createBreakpoints(media);
|
|
62
|
+
var isSmallScreen = function isSmallScreen(index) {
|
|
63
|
+
return index === 1;
|
|
64
|
+
};
|
|
71
65
|
var CarouselRoot = /*#__PURE__*/function (_Component) {
|
|
72
66
|
_inherits(CarouselRoot, _Component);
|
|
73
67
|
var _super = _createSuper(CarouselRoot);
|
|
74
68
|
function CarouselRoot(props) {
|
|
69
|
+
var _ref18, _props$index;
|
|
75
70
|
var _this;
|
|
76
71
|
_classCallCheck(this, CarouselRoot);
|
|
77
72
|
_this = _super.call(this, props);
|
|
73
|
+
_defineProperty(_assertThisInitialized(_this), "defaultItemsCount", 0);
|
|
78
74
|
_defineProperty(_assertThisInitialized(_this), "refContainer", /*#__PURE__*/React.createRef());
|
|
79
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
80
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
81
|
-
_defineProperty(_assertThisInitialized(_this), "indexIndicator", 0);
|
|
75
|
+
_defineProperty(_assertThisInitialized(_this), "refModalContainer", /*#__PURE__*/React.createRef());
|
|
76
|
+
_defineProperty(_assertThisInitialized(_this), "_touchStartCoord", -1);
|
|
82
77
|
_defineProperty(_assertThisInitialized(_this), "handlerKeyDown", function (e) {
|
|
83
78
|
switch (e.key) {
|
|
84
79
|
case 'ArrowLeft':
|
|
85
80
|
case 'ArrowRight':
|
|
86
81
|
{
|
|
87
82
|
e.preventDefault();
|
|
88
|
-
|
|
89
|
-
activeItemIndex = _this$controlTransfor.activeItemIndex;
|
|
90
|
-
_this.handlers.index(activeItemIndex);
|
|
83
|
+
_this.transformItem(MAP_TRANSFORM[e.key]);
|
|
91
84
|
}
|
|
92
85
|
}
|
|
93
86
|
});
|
|
94
87
|
_defineProperty(_assertThisInitialized(_this), "toggleItem", function (item) {
|
|
95
88
|
var removeItem = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (removeItem) {
|
|
99
|
-
_this.updateItems(items.filter(function (element) {
|
|
89
|
+
_this.setState(function (prevState) {
|
|
90
|
+
var newItems = removeItem ? prevState.items.filter(function (element) {
|
|
100
91
|
return element.node !== item.node;
|
|
101
|
-
}));
|
|
102
|
-
} else {
|
|
103
|
-
_this.setState(function (state) {
|
|
104
|
-
return {
|
|
105
|
-
items: [].concat(_toConsumableArray(state.items), [item]).map(function (element, position) {
|
|
106
|
-
return _objectSpread(_objectSpread({}, element), {}, {
|
|
107
|
-
position: position,
|
|
108
|
-
transform: 0
|
|
109
|
-
});
|
|
110
|
-
})
|
|
111
|
-
};
|
|
112
|
-
}, function () {
|
|
113
|
-
var items = _this.state.items;
|
|
114
|
-
if (items.length > index && index >= 0) {
|
|
115
|
-
_this.slideToValue(_this.indexIndicator, index);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
_defineProperty(_assertThisInitialized(_this), "updateItems", function (items) {
|
|
121
|
-
_this.setState(function () {
|
|
92
|
+
}) : [].concat(_toConsumableArray(prevState.items), [item]);
|
|
122
93
|
return {
|
|
123
|
-
items:
|
|
94
|
+
items: newItems
|
|
124
95
|
};
|
|
125
96
|
});
|
|
97
|
+
if (!removeItem) {
|
|
98
|
+
_this.defaultItemsCount++;
|
|
99
|
+
}
|
|
126
100
|
});
|
|
127
|
-
_defineProperty(_assertThisInitialized(_this), "transformContainer", function (
|
|
101
|
+
_defineProperty(_assertThisInitialized(_this), "transformContainer", function () {
|
|
102
|
+
var transform = _this.state.selectedIndex * -1 * 100;
|
|
128
103
|
if (_this.refContainer.current) {
|
|
129
104
|
_this.refContainer.current.style.transform = "translateX(".concat(transform, "%)");
|
|
130
105
|
}
|
|
106
|
+
if (_this.refModalContainer.current) {
|
|
107
|
+
_this.refModalContainer.current.style.transform = "translateX(".concat(transform, "%)");
|
|
108
|
+
}
|
|
131
109
|
});
|
|
132
|
-
_defineProperty(_assertThisInitialized(_this), "getDirection", function (currentIndex, nextIndex
|
|
110
|
+
_defineProperty(_assertThisInitialized(_this), "getDirection", function (currentIndex, nextIndex) {
|
|
111
|
+
var bounded = _this.asProps.bounded;
|
|
133
112
|
if (bounded) {
|
|
134
113
|
return currentIndex < nextIndex ? 'right' : 'left';
|
|
135
114
|
}
|
|
@@ -155,114 +134,74 @@ var CarouselRoot = /*#__PURE__*/function (_Component) {
|
|
|
155
134
|
var left = tmpArr.indexOf(nextIndex);
|
|
156
135
|
return left - tmpCurrentIndex < 0 ? 'left' : 'right';
|
|
157
136
|
});
|
|
158
|
-
_defineProperty(_assertThisInitialized(_this), "slideToValue", function (
|
|
159
|
-
|
|
160
|
-
var direction =
|
|
161
|
-
var
|
|
162
|
-
while (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
i = activeItemIndex;
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
_defineProperty(_assertThisInitialized(_this), "controlTransformItem", function (direction) {
|
|
169
|
-
var _this$asProps = _this.asProps,
|
|
170
|
-
bounded = _this$asProps.bounded,
|
|
171
|
-
index = _this$asProps.index;
|
|
172
|
-
var items = _this.state.items;
|
|
173
|
-
var maxIndexIndicator = items.length - 1;
|
|
174
|
-
if (_this.isControlled) {
|
|
175
|
-
if (direction === 'right') {
|
|
176
|
-
if (bounded && index === maxIndexIndicator) {
|
|
177
|
-
return {
|
|
178
|
-
activeItemIndex: maxIndexIndicator
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
activeItemIndex: index === maxIndexIndicator ? 0 : index + 1
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
if (direction === 'left') {
|
|
186
|
-
if (bounded && index === 0) {
|
|
187
|
-
return {
|
|
188
|
-
activeItemIndex: 0
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
return {
|
|
192
|
-
activeItemIndex: index === 0 ? maxIndexIndicator : index - 1
|
|
193
|
-
};
|
|
194
|
-
}
|
|
137
|
+
_defineProperty(_assertThisInitialized(_this), "slideToValue", function (nextIndex) {
|
|
138
|
+
var selectedIndex = _this.state.selectedIndex;
|
|
139
|
+
var direction = selectedIndex < nextIndex ? 'right' : 'left';
|
|
140
|
+
var diff = Math.abs(selectedIndex - nextIndex);
|
|
141
|
+
while (diff > 0) {
|
|
142
|
+
_this.transformItem(direction);
|
|
143
|
+
diff--;
|
|
195
144
|
}
|
|
196
|
-
return _this.transformItem(direction);
|
|
197
145
|
});
|
|
198
146
|
_defineProperty(_assertThisInitialized(_this), "transformItem", function (direction) {
|
|
199
|
-
var
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
147
|
+
var bounded = _this.asProps.bounded;
|
|
148
|
+
var _this$state = _this.state,
|
|
149
|
+
items = _this$state.items,
|
|
150
|
+
selectedIndex = _this$state.selectedIndex;
|
|
203
151
|
var maxIndexIndicator = items.length - 1;
|
|
204
|
-
var nextItemPosition = undefined;
|
|
205
152
|
if (direction === 'right') {
|
|
206
|
-
if (bounded &&
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
};
|
|
153
|
+
if (bounded && selectedIndex === maxIndexIndicator) {
|
|
154
|
+
_this.handlers.index(maxIndexIndicator);
|
|
155
|
+
return;
|
|
210
156
|
}
|
|
211
|
-
_this.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
nextItemPosition = position.getItemMin(items);
|
|
215
|
-
items[nextItemPosition].position = positionItemMax + 1;
|
|
216
|
-
items[nextItemPosition].transform += items.length * step;
|
|
217
|
-
_this.updateItems(_toConsumableArray(items));
|
|
157
|
+
if (_this.isControlled) {
|
|
158
|
+
_this.handlers.index(selectedIndex === maxIndexIndicator ? 0 : selectedIndex + 1);
|
|
159
|
+
return;
|
|
218
160
|
}
|
|
219
|
-
_this.
|
|
220
|
-
if (_this.indexIndicator > maxIndexIndicator) {
|
|
221
|
-
_this.indexIndicator = 0;
|
|
222
|
-
}
|
|
223
|
-
_this.transform -= step;
|
|
224
|
-
}
|
|
225
|
-
if (direction === 'left') {
|
|
226
|
-
if (bounded && _this.positionLeftItem === 0) {
|
|
161
|
+
_this.setState(function (prevState) {
|
|
227
162
|
return {
|
|
228
|
-
|
|
163
|
+
selectedIndex: prevState.selectedIndex + 1
|
|
229
164
|
};
|
|
165
|
+
}, function () {
|
|
166
|
+
_this.transformContainer();
|
|
167
|
+
_this.handlers.index(_this.state.selectedIndex);
|
|
168
|
+
});
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (direction === 'left') {
|
|
172
|
+
if (bounded && selectedIndex === 0) {
|
|
173
|
+
_this.handlers.index(0);
|
|
174
|
+
return;
|
|
230
175
|
}
|
|
231
|
-
_this.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
nextItemPosition = position.getItemMax(items);
|
|
235
|
-
items[nextItemPosition].position = positionItemMin - 1;
|
|
236
|
-
items[nextItemPosition].transform -= items.length * step;
|
|
237
|
-
_this.updateItems(_toConsumableArray(items));
|
|
238
|
-
}
|
|
239
|
-
_this.indexIndicator -= 1;
|
|
240
|
-
if (_this.indexIndicator < 0) {
|
|
241
|
-
_this.indexIndicator = maxIndexIndicator;
|
|
176
|
+
if (_this.isControlled) {
|
|
177
|
+
_this.handlers.index(selectedIndex === 0 ? maxIndexIndicator : selectedIndex - 1);
|
|
178
|
+
return;
|
|
242
179
|
}
|
|
243
|
-
_this.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
180
|
+
_this.setState(function (prevState) {
|
|
181
|
+
return {
|
|
182
|
+
selectedIndex: prevState.selectedIndex - 1
|
|
183
|
+
};
|
|
184
|
+
}, function () {
|
|
185
|
+
_this.transformContainer();
|
|
186
|
+
_this.handlers.index(_this.state.selectedIndex);
|
|
187
|
+
});
|
|
188
|
+
return;
|
|
250
189
|
}
|
|
251
|
-
_this.transformContainer(_this.transform);
|
|
252
|
-
return {
|
|
253
|
-
activeItemIndex: activeItemIndex
|
|
254
|
-
};
|
|
255
190
|
});
|
|
256
191
|
_defineProperty(_assertThisInitialized(_this), "bindHandlerClick", function (direction) {
|
|
257
192
|
return function () {
|
|
258
|
-
|
|
259
|
-
activeItemIndex = _this$controlTransfor2.activeItemIndex;
|
|
260
|
-
_this.handlers.index(activeItemIndex);
|
|
193
|
+
_this.transformItem(direction);
|
|
261
194
|
};
|
|
262
195
|
});
|
|
263
196
|
_defineProperty(_assertThisInitialized(_this), "bindHandlerClickIndicator", function (value) {
|
|
264
197
|
return function () {
|
|
265
|
-
|
|
198
|
+
var _this$state2 = _this.state,
|
|
199
|
+
selectedIndex = _this$state2.selectedIndex,
|
|
200
|
+
items = _this$state2.items;
|
|
201
|
+
if (!_this.isControlled && value !== selectedIndex) {
|
|
202
|
+
var newValueIndex = Math.floor(selectedIndex / items.length) * items.length + value;
|
|
203
|
+
_this.slideToValue(newValueIndex);
|
|
204
|
+
}
|
|
266
205
|
_this.handlers.index(value);
|
|
267
206
|
};
|
|
268
207
|
});
|
|
@@ -273,15 +212,20 @@ var CarouselRoot = /*#__PURE__*/function (_Component) {
|
|
|
273
212
|
var touchEndCoord = e.changedTouches[0].clientX;
|
|
274
213
|
var delta = touchEndCoord - _this._touchStartCoord;
|
|
275
214
|
if (delta > 50) {
|
|
276
|
-
|
|
277
|
-
activeItemIndex = _this$controlTransfor3.activeItemIndex;
|
|
278
|
-
_this.handlers.index(activeItemIndex);
|
|
215
|
+
_this.transformItem('left');
|
|
279
216
|
} else if (delta < -50) {
|
|
280
|
-
|
|
281
|
-
_activeItemIndex = _this$controlTransfor4.activeItemIndex;
|
|
282
|
-
_this.handlers.index(_activeItemIndex);
|
|
217
|
+
_this.transformItem('right');
|
|
283
218
|
}
|
|
284
219
|
});
|
|
220
|
+
_defineProperty(_assertThisInitialized(_this), "handleToggleZoomModal", function () {
|
|
221
|
+
_this.setState(function (prevState) {
|
|
222
|
+
return {
|
|
223
|
+
isOpenZoom: !prevState.isOpenZoom
|
|
224
|
+
};
|
|
225
|
+
}, function () {
|
|
226
|
+
_this.state.isOpenZoom && _this.transformContainer();
|
|
227
|
+
});
|
|
228
|
+
});
|
|
285
229
|
_defineProperty(_assertThisInitialized(_this), "bindHandlerKeydownControl", function (direction) {
|
|
286
230
|
return function (e) {
|
|
287
231
|
var key = e.key;
|
|
@@ -293,7 +237,9 @@ var CarouselRoot = /*#__PURE__*/function (_Component) {
|
|
|
293
237
|
});
|
|
294
238
|
_this.isControlled = props.index !== undefined;
|
|
295
239
|
_this.state = {
|
|
296
|
-
items: []
|
|
240
|
+
items: [],
|
|
241
|
+
isOpenZoom: false,
|
|
242
|
+
selectedIndex: (_ref18 = (_props$index = props.index) !== null && _props$index !== void 0 ? _props$index : props.defaultIndex) !== null && _ref18 !== void 0 ? _ref18 : 0
|
|
297
243
|
};
|
|
298
244
|
return _this;
|
|
299
245
|
}
|
|
@@ -304,12 +250,34 @@ var CarouselRoot = /*#__PURE__*/function (_Component) {
|
|
|
304
250
|
index: null
|
|
305
251
|
};
|
|
306
252
|
}
|
|
253
|
+
}, {
|
|
254
|
+
key: "componentDidMount",
|
|
255
|
+
value: function componentDidMount() {
|
|
256
|
+
var selectedIndex = this.state.selectedIndex;
|
|
257
|
+
if (selectedIndex !== 0) {
|
|
258
|
+
if (selectedIndex < 0 || selectedIndex >= this.defaultItemsCount) {
|
|
259
|
+
logger.warn(true, "You couldn't use value for the `index` or `defaultIndex` not from `Item's` length range.", CarouselRoot.displayName);
|
|
260
|
+
this.setState({
|
|
261
|
+
selectedIndex: 0
|
|
262
|
+
});
|
|
263
|
+
} else {
|
|
264
|
+
this.transformContainer();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
var deprecatedComponents = findAllComponents(this.asProps.Children, ['Carousel.Prev', 'Carousel.Next', 'Carousel.Indicators']);
|
|
268
|
+
logger.warn(deprecatedComponents.length > 0, 'Please, try to remove `Prev`, `Next`, `Indicators` and other children components from your Carousel, except only `Item` elements.', CarouselRoot.displayName);
|
|
269
|
+
}
|
|
307
270
|
}, {
|
|
308
271
|
key: "componentDidUpdate",
|
|
309
272
|
value: function componentDidUpdate(prevProps) {
|
|
273
|
+
var _this2 = this;
|
|
310
274
|
var index = this.asProps.index;
|
|
311
|
-
if (prevProps.index !== index && this.isControlled) {
|
|
312
|
-
this.
|
|
275
|
+
if (prevProps.index !== index && this.isControlled && index !== undefined) {
|
|
276
|
+
this.setState({
|
|
277
|
+
selectedIndex: index
|
|
278
|
+
}, function () {
|
|
279
|
+
return _this2.transformContainer();
|
|
280
|
+
});
|
|
313
281
|
}
|
|
314
282
|
}
|
|
315
283
|
}, {
|
|
@@ -323,25 +291,31 @@ var CarouselRoot = /*#__PURE__*/function (_Component) {
|
|
|
323
291
|
}
|
|
324
292
|
}, {
|
|
325
293
|
key: "getItemProps",
|
|
326
|
-
value: function getItemProps(
|
|
294
|
+
value: function getItemProps(props, index) {
|
|
295
|
+
var zoom = this.asProps.zoom;
|
|
296
|
+
var isCurrent = this.isSelected(index);
|
|
327
297
|
return {
|
|
328
298
|
toggleItem: this.toggleItem,
|
|
329
299
|
uid: this.asProps.uid,
|
|
330
300
|
index: index,
|
|
331
|
-
current:
|
|
301
|
+
current: isCurrent,
|
|
302
|
+
zoomIn: zoom,
|
|
303
|
+
onToggleZoomModal: this.handleToggleZoomModal,
|
|
304
|
+
transform: isCurrent ? this.getTransform() : undefined
|
|
332
305
|
};
|
|
333
306
|
}
|
|
334
307
|
}, {
|
|
335
308
|
key: "getPrevProps",
|
|
336
309
|
value: function getPrevProps() {
|
|
337
|
-
var _this$
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
310
|
+
var _this$asProps = this.asProps,
|
|
311
|
+
bounded = _this$asProps.bounded,
|
|
312
|
+
getI18nText = _this$asProps.getI18nText;
|
|
313
|
+
var _this$state3 = this.state,
|
|
314
|
+
items = _this$state3.items,
|
|
315
|
+
selectedIndex = _this$state3.selectedIndex;
|
|
342
316
|
var disabled = false;
|
|
343
317
|
if (items.length && bounded) {
|
|
344
|
-
disabled =
|
|
318
|
+
disabled = selectedIndex === 0;
|
|
345
319
|
}
|
|
346
320
|
return {
|
|
347
321
|
onClick: this.bindHandlerClick('left'),
|
|
@@ -353,14 +327,15 @@ var CarouselRoot = /*#__PURE__*/function (_Component) {
|
|
|
353
327
|
}, {
|
|
354
328
|
key: "getNextProps",
|
|
355
329
|
value: function getNextProps() {
|
|
356
|
-
var _this$
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
330
|
+
var _this$asProps2 = this.asProps,
|
|
331
|
+
bounded = _this$asProps2.bounded,
|
|
332
|
+
getI18nText = _this$asProps2.getI18nText;
|
|
333
|
+
var _this$state4 = this.state,
|
|
334
|
+
items = _this$state4.items,
|
|
335
|
+
selectedIndex = _this$state4.selectedIndex;
|
|
361
336
|
var disabled = false;
|
|
362
337
|
if (items.length && bounded) {
|
|
363
|
-
disabled =
|
|
338
|
+
disabled = selectedIndex === items.length - 1;
|
|
364
339
|
}
|
|
365
340
|
return {
|
|
366
341
|
onClick: this.bindHandlerClick('right'),
|
|
@@ -372,35 +347,147 @@ var CarouselRoot = /*#__PURE__*/function (_Component) {
|
|
|
372
347
|
}, {
|
|
373
348
|
key: "getIndicatorsProps",
|
|
374
349
|
value: function getIndicatorsProps() {
|
|
375
|
-
var
|
|
350
|
+
var _this3 = this;
|
|
376
351
|
var items = this.state.items;
|
|
377
|
-
var index = this.asProps.index;
|
|
378
352
|
return {
|
|
379
353
|
items: items.map(function (item, key) {
|
|
380
354
|
return {
|
|
381
|
-
active: key
|
|
382
|
-
onClick:
|
|
355
|
+
active: _this3.isSelected(key),
|
|
356
|
+
onClick: _this3.bindHandlerClickIndicator(key),
|
|
383
357
|
key: key
|
|
384
358
|
};
|
|
385
359
|
})
|
|
386
360
|
};
|
|
387
361
|
}
|
|
362
|
+
}, {
|
|
363
|
+
key: "getTransform",
|
|
364
|
+
value: function getTransform() {
|
|
365
|
+
var _this$state5 = this.state,
|
|
366
|
+
items = _this$state5.items,
|
|
367
|
+
selectedIndex = _this$state5.selectedIndex;
|
|
368
|
+
var direction = selectedIndex > 0 ? 1 : -1;
|
|
369
|
+
var count = items.length === 0 ? 0 : Math.floor(selectedIndex / items.length) * direction;
|
|
370
|
+
var transform = selectedIndex > 0 && selectedIndex < items.length ? 0 : 100 * direction * count * items.length;
|
|
371
|
+
return transform;
|
|
372
|
+
}
|
|
373
|
+
}, {
|
|
374
|
+
key: "isSelected",
|
|
375
|
+
value: function isSelected(index) {
|
|
376
|
+
var _this$state6 = this.state,
|
|
377
|
+
items = _this$state6.items,
|
|
378
|
+
selectedIndex = _this$state6.selectedIndex;
|
|
379
|
+
if (items.length === 0) {
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
382
|
+
if (selectedIndex >= 0) {
|
|
383
|
+
return index === selectedIndex % items.length;
|
|
384
|
+
}
|
|
385
|
+
return index === (items.length + selectedIndex % items.length) % items.length;
|
|
386
|
+
}
|
|
387
|
+
}, {
|
|
388
|
+
key: "renderModal",
|
|
389
|
+
value: function renderModal(isSmall, ComponentItems) {
|
|
390
|
+
var _ref = this.asProps,
|
|
391
|
+
_ref9,
|
|
392
|
+
_this4 = this;
|
|
393
|
+
var SModalContainer = Box;
|
|
394
|
+
var _this$asProps3 = this.asProps,
|
|
395
|
+
styles = _this$asProps3.styles,
|
|
396
|
+
uid = _this$asProps3.uid,
|
|
397
|
+
duration = _this$asProps3.duration,
|
|
398
|
+
hasZoom = _this$asProps3.zoom,
|
|
399
|
+
zoomWidth = _this$asProps3.zoomWidth,
|
|
400
|
+
ariaLabel = _this$asProps3['aria-label'],
|
|
401
|
+
ariaRoledescription = _this$asProps3['aria-roledescription'];
|
|
402
|
+
var isOpenZoom = this.state.isOpenZoom;
|
|
403
|
+
return _ref9 = sstyled(styles), /*#__PURE__*/React.createElement(Modal, _ref9.cn("Modal", {
|
|
404
|
+
"visible": isOpenZoom,
|
|
405
|
+
"onClose": this.handleToggleZoomModal,
|
|
406
|
+
"ghost": true,
|
|
407
|
+
"closable": !isSmall
|
|
408
|
+
}), /*#__PURE__*/React.createElement(Flex, _ref9.cn("Flex", {
|
|
409
|
+
"direction": isSmall ? 'column' : 'row'
|
|
410
|
+
}), !isSmall && /*#__PURE__*/React.createElement(Carousel.Prev, {
|
|
411
|
+
inverted: true
|
|
412
|
+
}), /*#__PURE__*/React.createElement(Box, _ref9.cn("Box", {
|
|
413
|
+
"style": {
|
|
414
|
+
overflow: 'hidden',
|
|
415
|
+
borderRadius: 6
|
|
416
|
+
}
|
|
417
|
+
}), /*#__PURE__*/React.createElement(SModalContainer, _ref9.cn("SModalContainer", _objectSpread({}, _assignProps({
|
|
418
|
+
"role": 'list',
|
|
419
|
+
"use:duration": "".concat(duration, "ms"),
|
|
420
|
+
"ref": this.refModalContainer,
|
|
421
|
+
"use:w": undefined,
|
|
422
|
+
"wMax": zoomWidth
|
|
423
|
+
}, _ref))), ComponentItems.map(function (item, i) {
|
|
424
|
+
return /*#__PURE__*/React.createElement(Carousel.Item, _extends({}, item.props, {
|
|
425
|
+
key: item.key,
|
|
426
|
+
uid: uid,
|
|
427
|
+
index: i,
|
|
428
|
+
current: _this4.isSelected(i),
|
|
429
|
+
toggleItem: undefined,
|
|
430
|
+
zoom: true,
|
|
431
|
+
zoomOut: true,
|
|
432
|
+
transform: _this4.isSelected(i) ? _this4.getTransform() : undefined
|
|
433
|
+
}));
|
|
434
|
+
}))), isSmall ? /*#__PURE__*/React.createElement(Flex, _ref9.cn("Flex", {
|
|
435
|
+
"justifyContent": 'center',
|
|
436
|
+
"mt": 2
|
|
437
|
+
}), /*#__PURE__*/React.createElement(Carousel.Prev, {
|
|
438
|
+
inverted: true
|
|
439
|
+
}), /*#__PURE__*/React.createElement(Carousel.Next, {
|
|
440
|
+
inverted: true
|
|
441
|
+
})) : /*#__PURE__*/React.createElement(Carousel.Next, {
|
|
442
|
+
inverted: true
|
|
443
|
+
})), !isSmall && /*#__PURE__*/React.createElement(Carousel.Indicators, {
|
|
444
|
+
inverted: true
|
|
445
|
+
}));
|
|
446
|
+
}
|
|
388
447
|
}, {
|
|
389
448
|
key: "render",
|
|
390
449
|
value: function render() {
|
|
391
|
-
var
|
|
392
|
-
|
|
450
|
+
var _ref2 = this.asProps,
|
|
451
|
+
_ref10,
|
|
452
|
+
_this5 = this;
|
|
393
453
|
var SCarousel = Box;
|
|
394
|
-
var _this$
|
|
395
|
-
styles = _this$
|
|
396
|
-
Children = _this$
|
|
397
|
-
|
|
454
|
+
var _this$asProps4 = this.asProps,
|
|
455
|
+
styles = _this$asProps4.styles,
|
|
456
|
+
Children = _this$asProps4.Children,
|
|
457
|
+
hasZoom = _this$asProps4.zoom,
|
|
458
|
+
ariaLabel = _this$asProps4['aria-label'],
|
|
459
|
+
ariaRoledescription = _this$asProps4['aria-roledescription'],
|
|
460
|
+
indicators = _this$asProps4.indicators;
|
|
461
|
+
var ComponentItems = findAllComponents(Children, ['Carousel.Item']);
|
|
462
|
+
var Controls = findAllComponents(Children, ['Carousel.Prev', 'Carousel.Next', 'Carousel.Indicators']);
|
|
463
|
+
return _ref10 = sstyled(styles), /*#__PURE__*/React.createElement(SCarousel, _ref10.cn("SCarousel", _objectSpread({}, _assignProps2({
|
|
398
464
|
"role": 'group',
|
|
399
465
|
"onKeyDown": this.handlerKeyDown,
|
|
400
466
|
"tabIndex": 0,
|
|
401
467
|
"onTouchStart": this.handlerTouchStart,
|
|
402
468
|
"onTouchEnd": this.handlerTouchEnd
|
|
403
|
-
},
|
|
469
|
+
}, _ref2))), Controls.length === 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Flex, _ref10.cn("Flex", {}), /*#__PURE__*/React.createElement(Carousel.Prev, null), /*#__PURE__*/React.createElement(Box, _ref10.cn("Box", {
|
|
470
|
+
"style": {
|
|
471
|
+
overflow: 'hidden',
|
|
472
|
+
borderRadius: 6
|
|
473
|
+
}
|
|
474
|
+
}), /*#__PURE__*/React.createElement(Carousel.Container, {
|
|
475
|
+
"aria-roledescription": ariaRoledescription,
|
|
476
|
+
"aria-label": ariaLabel
|
|
477
|
+
}, /*#__PURE__*/React.createElement(Children, _ref10.cn("Children", {})))), /*#__PURE__*/React.createElement(Carousel.Next, null)), indicators === 'default' && /*#__PURE__*/React.createElement(Carousel.Indicators, null), indicators === 'preview' && /*#__PURE__*/React.createElement(Carousel.Indicators, null, function () {
|
|
478
|
+
return ComponentItems.map(function (item, index) {
|
|
479
|
+
return /*#__PURE__*/React.createElement(Carousel.Indicator, _extends({}, item.props, {
|
|
480
|
+
key: item.key,
|
|
481
|
+
w: 100,
|
|
482
|
+
h: 100,
|
|
483
|
+
"aria-roledescription": "slide",
|
|
484
|
+
active: _this5.isSelected(index),
|
|
485
|
+
onClick: _this5.bindHandlerClickIndicator(index)
|
|
486
|
+
}));
|
|
487
|
+
});
|
|
488
|
+
})) : /*#__PURE__*/React.createElement(Children, _ref10.cn("Children", {})), hasZoom && /*#__PURE__*/React.createElement(BreakPoints, _ref10.cn("BreakPoints", {}), /*#__PURE__*/React.createElement(BreakPoints.Context.Consumer, null, function (mediaIndex) {
|
|
489
|
+
return _this5.renderModal(isSmallScreen(mediaIndex), ComponentItems);
|
|
490
|
+
})));
|
|
404
491
|
}
|
|
405
492
|
}]);
|
|
406
493
|
return CarouselRoot;
|
|
@@ -412,112 +499,187 @@ _defineProperty(CarouselRoot, "defaultProps", {
|
|
|
412
499
|
step: 100,
|
|
413
500
|
bounded: false,
|
|
414
501
|
i18n: localizedMessages,
|
|
415
|
-
locale: 'en'
|
|
502
|
+
locale: 'en',
|
|
503
|
+
indicators: 'default'
|
|
416
504
|
});
|
|
417
505
|
_defineProperty(CarouselRoot, "style", style);
|
|
418
|
-
_defineProperty(CarouselRoot, "enhance",
|
|
506
|
+
_defineProperty(CarouselRoot, "enhance", Object.values(enhance));
|
|
419
507
|
var Container = function Container(props) {
|
|
420
|
-
var
|
|
421
|
-
|
|
508
|
+
var _ref3 = arguments[0],
|
|
509
|
+
_ref11;
|
|
422
510
|
var SContainer = Box;
|
|
423
511
|
var styles = props.styles,
|
|
424
512
|
duration = props.duration;
|
|
425
|
-
return
|
|
513
|
+
return _ref11 = sstyled(styles), /*#__PURE__*/React.createElement(SContainer, _ref11.cn("SContainer", _objectSpread({}, _assignProps3({
|
|
426
514
|
"role": 'list',
|
|
427
515
|
"use:duration": "".concat(duration, "ms")
|
|
428
|
-
}, _ref2))));
|
|
429
|
-
};
|
|
430
|
-
var Item = function Item(props) {
|
|
431
|
-
var _ref3 = arguments[0],
|
|
432
|
-
_ref10;
|
|
433
|
-
var styles = props.styles,
|
|
434
|
-
toggleItem = props.toggleItem,
|
|
435
|
-
index = props.index,
|
|
436
|
-
uid = props.uid,
|
|
437
|
-
current = props.current;
|
|
438
|
-
var SItem = Box;
|
|
439
|
-
var refItem = /*#__PURE__*/React.createRef();
|
|
440
|
-
React.useEffect(function () {
|
|
441
|
-
// add item
|
|
442
|
-
toggleItem({
|
|
443
|
-
node: refItem.current
|
|
444
|
-
});
|
|
445
|
-
return function () {
|
|
446
|
-
// remove item
|
|
447
|
-
toggleItem({
|
|
448
|
-
node: refItem.current
|
|
449
|
-
}, true);
|
|
450
|
-
};
|
|
451
|
-
}, []);
|
|
452
|
-
return _ref10 = sstyled(styles), /*#__PURE__*/React.createElement(SItem, _ref10.cn("SItem", _objectSpread({}, _assignProps3({
|
|
453
|
-
"ref": refItem,
|
|
454
|
-
"role": 'listitem',
|
|
455
|
-
"id": "igc-".concat(uid, "-carousel-item-").concat(index),
|
|
456
|
-
"aria-current": current
|
|
457
516
|
}, _ref3))));
|
|
458
517
|
};
|
|
518
|
+
var Item = /*#__PURE__*/function (_Component2) {
|
|
519
|
+
_inherits(Item, _Component2);
|
|
520
|
+
var _super2 = _createSuper(Item);
|
|
521
|
+
function Item() {
|
|
522
|
+
var _this6;
|
|
523
|
+
_classCallCheck(this, Item);
|
|
524
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
525
|
+
args[_key] = arguments[_key];
|
|
526
|
+
}
|
|
527
|
+
_this6 = _super2.call.apply(_super2, [this].concat(args));
|
|
528
|
+
_defineProperty(_assertThisInitialized(_this6), "refItem", /*#__PURE__*/React.createRef());
|
|
529
|
+
return _this6;
|
|
530
|
+
}
|
|
531
|
+
_createClass(Item, [{
|
|
532
|
+
key: "componentDidMount",
|
|
533
|
+
value: function componentDidMount() {
|
|
534
|
+
var toggleItem = this.props.toggleItem;
|
|
535
|
+
var refItem = this.refItem.current;
|
|
536
|
+
toggleItem && refItem && toggleItem({
|
|
537
|
+
node: refItem
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
}, {
|
|
541
|
+
key: "componentWillUnmount",
|
|
542
|
+
value: function componentWillUnmount() {
|
|
543
|
+
var toggleItem = this.props.toggleItem;
|
|
544
|
+
var refItem = this.refItem.current;
|
|
545
|
+
toggleItem && refItem && toggleItem({
|
|
546
|
+
node: refItem
|
|
547
|
+
}, true);
|
|
548
|
+
}
|
|
549
|
+
}, {
|
|
550
|
+
key: "componentDidUpdate",
|
|
551
|
+
value: function componentDidUpdate(prevProps) {
|
|
552
|
+
var transform = this.props.transform;
|
|
553
|
+
var refItem = this.refItem.current;
|
|
554
|
+
if (prevProps.transform !== transform && refItem) {
|
|
555
|
+
refItem.style.transform = "translateX(".concat(transform, "%)");
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}, {
|
|
559
|
+
key: "render",
|
|
560
|
+
value: function render() {
|
|
561
|
+
var _ref4 = this.asProps,
|
|
562
|
+
_ref12;
|
|
563
|
+
var _this$props = this.props,
|
|
564
|
+
styles = _this$props.styles,
|
|
565
|
+
index = _this$props.index,
|
|
566
|
+
uid = _this$props.uid,
|
|
567
|
+
current = _this$props.current,
|
|
568
|
+
zoomIn = _this$props.zoomIn,
|
|
569
|
+
onToggleZoomModal = _this$props.onToggleZoomModal,
|
|
570
|
+
transform = _this$props.transform;
|
|
571
|
+
var SItem = Box;
|
|
572
|
+
return _ref12 = sstyled(styles), /*#__PURE__*/React.createElement(SItem, _ref12.cn("SItem", _objectSpread({}, _assignProps4({
|
|
573
|
+
"ref": this.refItem,
|
|
574
|
+
"role": 'listitem',
|
|
575
|
+
"id": "igc-".concat(uid, "-carousel-item-").concat(index),
|
|
576
|
+
"aria-current": current,
|
|
577
|
+
"onClick": zoomIn ? onToggleZoomModal : undefined,
|
|
578
|
+
"zoomIn": zoomIn
|
|
579
|
+
}, _ref4))));
|
|
580
|
+
}
|
|
581
|
+
}]);
|
|
582
|
+
return Item;
|
|
583
|
+
}(Component);
|
|
459
584
|
var Prev = function Prev(props) {
|
|
460
|
-
var
|
|
461
|
-
|
|
585
|
+
var _ref5 = arguments[0],
|
|
586
|
+
_ref13;
|
|
462
587
|
var styles = props.styles,
|
|
463
588
|
children = props.children,
|
|
464
589
|
Children = props.Children,
|
|
465
590
|
label = props.label,
|
|
466
591
|
_props$top = props.top,
|
|
467
|
-
top = _props$top === void 0 ? 0 : _props$top
|
|
592
|
+
top = _props$top === void 0 ? 0 : _props$top,
|
|
593
|
+
inverted = props.inverted;
|
|
468
594
|
var SPrev = Box;
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
595
|
+
var _React$useState = React.useState(false),
|
|
596
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
597
|
+
isActive = _React$useState2[0],
|
|
598
|
+
setIsActive = _React$useState2[1];
|
|
599
|
+
var handleMouseEnter = React.useCallback(function () {
|
|
600
|
+
setIsActive(true);
|
|
601
|
+
}, []);
|
|
602
|
+
var handleMouseLeave = React.useCallback(function () {
|
|
603
|
+
setIsActive(false);
|
|
604
|
+
}, []);
|
|
605
|
+
return _ref13 = sstyled(styles), /*#__PURE__*/React.createElement(SPrev, _ref13.cn("SPrev", _objectSpread({}, _assignProps5({
|
|
606
|
+
"top": top,
|
|
607
|
+
"onMouseEnter": handleMouseEnter,
|
|
608
|
+
"onMouseLeave": handleMouseLeave
|
|
609
|
+
}, _ref5))), children ? /*#__PURE__*/React.createElement(Children, _ref13.cn("Children", {})) : /*#__PURE__*/React.createElement(Button, _ref13.cn("Button", {
|
|
610
|
+
"addonLeft": ChevronLeft,
|
|
611
|
+
"aria-label": label,
|
|
612
|
+
"theme": inverted ? 'invert' : 'muted',
|
|
613
|
+
"use": 'tertiary',
|
|
614
|
+
"active": isActive,
|
|
615
|
+
"size": 'l'
|
|
474
616
|
})));
|
|
475
617
|
};
|
|
476
618
|
var Next = function Next(props) {
|
|
477
|
-
var
|
|
478
|
-
|
|
619
|
+
var _ref6 = arguments[0],
|
|
620
|
+
_ref14;
|
|
479
621
|
var styles = props.styles,
|
|
480
622
|
children = props.children,
|
|
481
623
|
Children = props.Children,
|
|
482
624
|
label = props.label,
|
|
483
625
|
_props$top2 = props.top,
|
|
484
|
-
top = _props$top2 === void 0 ? 0 : _props$top2
|
|
626
|
+
top = _props$top2 === void 0 ? 0 : _props$top2,
|
|
627
|
+
inverted = props.inverted;
|
|
485
628
|
var SNext = Box;
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
629
|
+
var _React$useState3 = React.useState(false),
|
|
630
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
631
|
+
isActive = _React$useState4[0],
|
|
632
|
+
setIsActive = _React$useState4[1];
|
|
633
|
+
var handleMouseEnter = React.useCallback(function () {
|
|
634
|
+
setIsActive(true);
|
|
635
|
+
}, []);
|
|
636
|
+
var handleMouseLeave = React.useCallback(function () {
|
|
637
|
+
setIsActive(false);
|
|
638
|
+
}, []);
|
|
639
|
+
return _ref14 = sstyled(styles), /*#__PURE__*/React.createElement(SNext, _ref14.cn("SNext", _objectSpread({}, _assignProps6({
|
|
640
|
+
"top": top,
|
|
641
|
+
"onMouseEnter": handleMouseEnter,
|
|
642
|
+
"onMouseLeave": handleMouseLeave
|
|
643
|
+
}, _ref6))), children ? /*#__PURE__*/React.createElement(Children, _ref14.cn("Children", {})) : /*#__PURE__*/React.createElement(Button, _ref14.cn("Button", {
|
|
644
|
+
"addonLeft": ChevronRight,
|
|
645
|
+
"aria-label": label,
|
|
646
|
+
"theme": inverted ? 'invert' : 'muted',
|
|
647
|
+
"use": 'tertiary',
|
|
648
|
+
"active": isActive,
|
|
649
|
+
"size": 'l'
|
|
491
650
|
})));
|
|
492
651
|
};
|
|
493
|
-
var Indicators = function Indicators(
|
|
494
|
-
var
|
|
495
|
-
|
|
496
|
-
var items =
|
|
497
|
-
styles =
|
|
498
|
-
Children =
|
|
652
|
+
var Indicators = function Indicators(_ref19) {
|
|
653
|
+
var _ref7 = arguments[0],
|
|
654
|
+
_ref16;
|
|
655
|
+
var items = _ref19.items,
|
|
656
|
+
styles = _ref19.styles,
|
|
657
|
+
Children = _ref19.Children,
|
|
658
|
+
inverted = _ref19.inverted;
|
|
499
659
|
var SIndicators = Box;
|
|
500
660
|
if (Children.origin) {
|
|
501
|
-
var
|
|
502
|
-
return
|
|
661
|
+
var _ref15;
|
|
662
|
+
return _ref15 = sstyled(styles), /*#__PURE__*/React.createElement(SIndicators, _ref15.cn("SIndicators", _objectSpread({}, _assignProps7({
|
|
503
663
|
"aria-hidden": 'true'
|
|
504
|
-
},
|
|
664
|
+
}, _ref7))), /*#__PURE__*/React.createElement(Children, _ref15.cn("Children", {})));
|
|
505
665
|
}
|
|
506
|
-
return
|
|
666
|
+
return _ref16 = sstyled(styles), /*#__PURE__*/React.createElement(SIndicators, _ref16.cn("SIndicators", _objectSpread({}, _assignProps8({
|
|
507
667
|
"aria-hidden": 'true'
|
|
508
|
-
},
|
|
668
|
+
}, _ref7))), items === null || items === void 0 ? void 0 : items.map(function (item, index) {
|
|
509
669
|
return /*#__PURE__*/React.createElement(Carousel.Indicator, _extends({
|
|
510
670
|
key: index
|
|
511
|
-
}, item
|
|
671
|
+
}, item, {
|
|
672
|
+
inverted: inverted
|
|
673
|
+
}));
|
|
512
674
|
}));
|
|
513
675
|
};
|
|
514
|
-
var Indicator = function Indicator(
|
|
515
|
-
var
|
|
516
|
-
|
|
517
|
-
var styles =
|
|
518
|
-
Children =
|
|
676
|
+
var Indicator = function Indicator(_ref20) {
|
|
677
|
+
var _ref8 = arguments[0],
|
|
678
|
+
_ref17;
|
|
679
|
+
var styles = _ref20.styles,
|
|
680
|
+
Children = _ref20.Children;
|
|
519
681
|
var SIndicator = Box;
|
|
520
|
-
return
|
|
682
|
+
return _ref17 = sstyled(styles), /*#__PURE__*/React.createElement(SIndicator, _ref17.cn("SIndicator", _objectSpread({}, _assignProps9({}, _ref8))), /*#__PURE__*/React.createElement(Children, _ref17.cn("Children", {})));
|
|
521
683
|
};
|
|
522
684
|
var Carousel = createComponent(CarouselRoot, {
|
|
523
685
|
Container: Container,
|