@semcore/carousel 16.1.13 → 17.0.0-prerelease.17
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 +6 -0
- package/README.md +4 -4
- package/lib/cjs/Carousel.js +536 -553
- package/lib/cjs/Carousel.js.map +1 -1
- package/lib/cjs/Carousel.types.js.map +1 -1
- package/lib/cjs/index.js +4 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +16 -16
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/Carousel.js +527 -544
- package/lib/es6/Carousel.js.map +1 -1
- package/lib/es6/Carousel.types.js.map +1 -1
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +15 -15
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/esm/Carousel.mjs +518 -481
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +1 -1
- package/lib/types/Carousel.types.d.ts +2 -11
- package/package.json +9 -8
- package/src/Carousel.tsx +15 -15
- package/src/Carousel.types.ts +2 -8
package/lib/es6/Carousel.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
3
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
4
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
5
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
6
|
-
import _callSuper from "@babel/runtime/helpers/callSuper";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
3
|
import { sstyled as _sstyled } from "@semcore/core";
|
|
10
4
|
import { assignProps as _assignProps0 } from "@semcore/core";
|
|
@@ -17,86 +11,80 @@ import { assignProps as _assignProps4 } from "@semcore/core";
|
|
|
17
11
|
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
18
12
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
19
13
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
20
|
-
import { createBreakpoints } from '@semcore/
|
|
14
|
+
import { createBreakpoints, Box, Flex } from '@semcore/base-components';
|
|
21
15
|
import Button from '@semcore/button';
|
|
22
16
|
import { createComponent, Component, sstyled, Root } from '@semcore/core';
|
|
23
17
|
import i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';
|
|
24
18
|
import { findAllComponents } from '@semcore/core/lib/utils/findComponent';
|
|
25
19
|
import logger from '@semcore/core/lib/utils/logger';
|
|
26
20
|
import uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';
|
|
27
|
-
import { Box, Flex } from '@semcore/flex-box';
|
|
28
21
|
import ChevronLeft from '@semcore/icon/ChevronLeft/l';
|
|
29
22
|
import ChevronRight from '@semcore/icon/ChevronRight/l';
|
|
30
23
|
import Modal from '@semcore/modal';
|
|
31
24
|
import React from 'react';
|
|
32
25
|
/*!__reshadow-styles__:"./style/carousel.shadow.css"*/
|
|
33
|
-
|
|
26
|
+
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SCarousel_13vnn_gg_{overflow:hidden;outline:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.___SContainer_13vnn_gg_{display:flex;transition:transform var(--duration_13vnn) ease-in-out}.___SContentBox_13vnn_gg_,.___SIndicator_13vnn_gg_,.___SModalBox_13vnn_gg_{position:relative;overflow:hidden;border-radius:var(--intergalactic-surface-rounded, 6px)}.___SContentBox_13vnn_gg_:has(.___SItem_13vnn_gg_:focus-visible)::after{border-radius:inherit;z-index:2;position:absolute;top:0;right:0;bottom:0;left:0;content:\"\";outline-color:var(--intergalactic-keyboard-focus-outline, #008ff8);outline-style:solid;outline-width:2px;outline-offset:-2px;transition-duration:calc(var(--intergalactic-duration-extra-fast, 100)*1ms);transition-timing-function:ease-in-out;transition-property:outline-color,outline-width,outline-offset}.___SImageBoxContainer_13vnn_gg_{position:relative;border-radius:var(--intergalactic-surface-rounded, 6px)}.___SImageBoxContainer_13vnn_gg_:has(.___SItem_13vnn_gg_:focus-visible)::after{border-radius:inherit;z-index:2;position:absolute;top:0;right:0;bottom:0;left:0;content:\"\";outline-color:var(--intergalactic-keyboard-focus-outline, #008ff8);outline-style:solid;outline-width:2px;outline-offset:2px;transition-duration:calc(var(--intergalactic-duration-extra-fast, 100)*1ms);transition-timing-function:ease-in-out;transition-property:outline-color,outline-width,outline-offset;outline-color:var(--intergalactic-keyboard-focus-invert-outline, rgba(255, 255, 255, 0.8))}.___SImageBoxContainer_13vnn_gg_ .___SItem_13vnn_gg_:focus-visible{outline:0}.___SModalContainer_13vnn_gg_{display:flex;transition:transform var(--duration_13vnn) ease-in-out}.___SItem_13vnn_gg_{flex:0 0 100%;max-width:100%;box-sizing:border-box;transform:var(--transform_13vnn);border-radius:var(--intergalactic-surface-rounded, 6px);overflow:hidden;outline:0}.___SItem_13vnn_gg_>img{display:block}.___SItem_13vnn_gg_.__zoomIn_13vnn_gg_{cursor:zoom-in}.___SItem_13vnn_gg_.__zoomOut_13vnn_gg_{cursor:zoom-out}.___SIndicators_13vnn_gg_{display:flex;justify-content:center;margin:var(--intergalactic-spacing-4x, 16px) 4px 4px 4px;outline:0;position:relative}.___SIndicator_13vnn_gg_{margin:0 calc(.5*var(--intergalactic-spacing-3x, 12px));cursor:pointer;display:block;width:12px;height:12px;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}.___SIndicator_13vnn_gg_[aria-roledescription=slide]{width:100px;height:100px}@media (hover:hover){.___SIndicator_13vnn_gg_:hover{opacity:calc(2*var(--intergalactic-disabled-opacity, 0.3))}}.___SIndicator_13vnn_gg_.__active_13vnn_gg_{opacity:1}.___SIndicator_13vnn_gg_.__inverted_13vnn_gg_{background-color:var(--intergalactic-icon-primary-invert, #ffffff)}.___SNext_13vnn_gg_,.___SPrev_13vnn_gg_{display:inline-flex;align-items:center;justify-content:center;cursor:pointer;color:var(--intergalactic-icon-primary-neutral, #6c6e79)}.___SNext_13vnn_gg_ .___SNextButton_13vnn_gg_ span:has(>svg:only-child),.___SNext_13vnn_gg_ .___SPrevButton_13vnn_gg_ span:has(>svg:only-child),.___SPrev_13vnn_gg_ .___SNextButton_13vnn_gg_ span:has(>svg:only-child),.___SPrev_13vnn_gg_ .___SPrevButton_13vnn_gg_ span:has(>svg:only-child){margin-left:calc(2*var(--intergalactic-spacing-1x, 4px) - 1px);margin-right:calc(2*var(--intergalactic-spacing-1x, 4px) - 1px)}.___SPrev_13vnn_gg_{margin-right:var(--intergalactic-spacing-2x, 8px)}.___SNext_13vnn_gg_{margin-left:var(--intergalactic-spacing-2x, 8px)}.___SNext_13vnn_gg_.__disabled_13vnn_gg_,.___SPrev_13vnn_gg_.__disabled_13vnn_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3);cursor:default;pointer-events:none}@media (prefers-reduced-motion){.___SContainer_13vnn_gg_{transition:none}}", /*__inner_css_end__*/"13vnn_gg_"),
|
|
34
27
|
/*__reshadow_css_end__*/
|
|
35
28
|
{
|
|
36
|
-
"__SCarousel": "
|
|
37
|
-
"__SContainer": "
|
|
38
|
-
"--duration": "--
|
|
39
|
-
"__SContentBox": "
|
|
40
|
-
"__SModalBox": "
|
|
41
|
-
"__SIndicator": "
|
|
42
|
-
"__SItem": "
|
|
43
|
-
"__SModalContainer": "
|
|
44
|
-
"_zoomIn": "
|
|
45
|
-
"_zoomOut": "
|
|
46
|
-
"__SIndicators": "
|
|
47
|
-
"_active": "
|
|
48
|
-
"_inverted": "
|
|
49
|
-
"__SPrev": "
|
|
50
|
-
"__SNext": "
|
|
51
|
-
"_disabled": "
|
|
52
|
-
"__SImageBoxContainer": "
|
|
53
|
-
"--transform": "--
|
|
54
|
-
"__SPrevButton": "
|
|
55
|
-
"__SNextButton": "
|
|
29
|
+
"__SCarousel": "___SCarousel_13vnn_gg_",
|
|
30
|
+
"__SContainer": "___SContainer_13vnn_gg_",
|
|
31
|
+
"--duration": "--duration_13vnn",
|
|
32
|
+
"__SContentBox": "___SContentBox_13vnn_gg_",
|
|
33
|
+
"__SModalBox": "___SModalBox_13vnn_gg_",
|
|
34
|
+
"__SIndicator": "___SIndicator_13vnn_gg_",
|
|
35
|
+
"__SItem": "___SItem_13vnn_gg_",
|
|
36
|
+
"__SModalContainer": "___SModalContainer_13vnn_gg_",
|
|
37
|
+
"_zoomIn": "__zoomIn_13vnn_gg_",
|
|
38
|
+
"_zoomOut": "__zoomOut_13vnn_gg_",
|
|
39
|
+
"__SIndicators": "___SIndicators_13vnn_gg_",
|
|
40
|
+
"_active": "__active_13vnn_gg_",
|
|
41
|
+
"_inverted": "__inverted_13vnn_gg_",
|
|
42
|
+
"__SPrev": "___SPrev_13vnn_gg_",
|
|
43
|
+
"__SNext": "___SNext_13vnn_gg_",
|
|
44
|
+
"_disabled": "__disabled_13vnn_gg_",
|
|
45
|
+
"__SImageBoxContainer": "___SImageBoxContainer_13vnn_gg_",
|
|
46
|
+
"--transform": "--transform_13vnn",
|
|
47
|
+
"__SPrevButton": "___SPrevButton_13vnn_gg_",
|
|
48
|
+
"__SNextButton": "___SNextButton_13vnn_gg_"
|
|
56
49
|
});
|
|
57
50
|
import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
|
|
58
|
-
|
|
51
|
+
const MAP_TRANSFORM = {
|
|
59
52
|
ArrowLeft: 'left',
|
|
60
53
|
ArrowRight: 'right'
|
|
61
54
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
_defineProperty(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
_defineProperty(_this, "refModalContainer", /*#__PURE__*/React.createRef());
|
|
78
|
-
_defineProperty(_this, "_touchStartCoord", -1);
|
|
79
|
-
_defineProperty(_this, "handlerKeyDown", function (e) {
|
|
80
|
-
var firstSlide = 1;
|
|
81
|
-
var lastSlide = _this.state.items.length + 1;
|
|
55
|
+
const enhance = [uniqueIDEnhancement(), i18nEnhance(localizedMessages)];
|
|
56
|
+
const media = ['(min-width: 481px)', '(max-width: 480px)'];
|
|
57
|
+
const BreakPoints = createBreakpoints(media);
|
|
58
|
+
const isSmallScreen = index => index === 1;
|
|
59
|
+
class CarouselRoot extends Component {
|
|
60
|
+
constructor(props) {
|
|
61
|
+
super(props);
|
|
62
|
+
_defineProperty(this, "defaultItemsCount", 0);
|
|
63
|
+
_defineProperty(this, "refCarousel", /*#__PURE__*/React.createRef());
|
|
64
|
+
_defineProperty(this, "refContainer", /*#__PURE__*/React.createRef());
|
|
65
|
+
_defineProperty(this, "refModalContainer", /*#__PURE__*/React.createRef());
|
|
66
|
+
_defineProperty(this, "_touchStartCoord", -1);
|
|
67
|
+
_defineProperty(this, "handlerKeyDown", e => {
|
|
68
|
+
const firstSlide = 1;
|
|
69
|
+
const lastSlide = this.state.items.length + 1;
|
|
82
70
|
switch (e.key) {
|
|
83
71
|
case 'ArrowLeft':
|
|
84
72
|
case 'ArrowRight':
|
|
85
73
|
{
|
|
86
74
|
e.preventDefault();
|
|
87
|
-
|
|
75
|
+
this.transformItem(MAP_TRANSFORM[e.key]);
|
|
88
76
|
break;
|
|
89
77
|
}
|
|
90
78
|
case 'Home':
|
|
91
79
|
{
|
|
92
80
|
e.preventDefault();
|
|
93
|
-
|
|
81
|
+
this.slideToValue(firstSlide);
|
|
94
82
|
break;
|
|
95
83
|
}
|
|
96
84
|
case 'End':
|
|
97
85
|
{
|
|
98
86
|
e.preventDefault();
|
|
99
|
-
|
|
87
|
+
this.slideToValue(lastSlide);
|
|
100
88
|
break;
|
|
101
89
|
}
|
|
102
90
|
}
|
|
@@ -104,51 +92,50 @@ var CarouselRoot = /*#__PURE__*/function (_Component) {
|
|
|
104
92
|
// like home or end
|
|
105
93
|
if (e.key === 'ArrowLeft') {
|
|
106
94
|
e.preventDefault();
|
|
107
|
-
|
|
95
|
+
this.slideToValue(firstSlide);
|
|
108
96
|
} else if (e.key === 'ArrowRight') {
|
|
109
97
|
e.preventDefault();
|
|
110
|
-
|
|
98
|
+
this.slideToValue(lastSlide);
|
|
111
99
|
}
|
|
112
100
|
}
|
|
113
101
|
if ((e.key === 'Enter' || e.key === ' ') && e.target instanceof HTMLDivElement && e.target.role === 'tabpanel') {
|
|
114
|
-
|
|
102
|
+
this.handleToggleZoomModal();
|
|
115
103
|
}
|
|
116
104
|
});
|
|
117
|
-
_defineProperty(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
var newItems = removeItem ? prevState.items.filter(function (element) {
|
|
121
|
-
return element.node !== item.node;
|
|
122
|
-
}) : [].concat(_toConsumableArray(prevState.items), [item]);
|
|
105
|
+
_defineProperty(this, "toggleItem", (item, removeItem = false) => {
|
|
106
|
+
this.setState(prevState => {
|
|
107
|
+
const newItems = removeItem ? prevState.items.filter(element => element.node !== item.node) : [...prevState.items, item];
|
|
123
108
|
return {
|
|
124
109
|
items: newItems
|
|
125
110
|
};
|
|
126
111
|
});
|
|
127
112
|
if (!removeItem) {
|
|
128
|
-
|
|
113
|
+
this.defaultItemsCount++;
|
|
129
114
|
}
|
|
130
115
|
});
|
|
131
|
-
_defineProperty(
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
|
|
116
|
+
_defineProperty(this, "transformContainer", () => {
|
|
117
|
+
const transform = this.state.selectedIndex * -1 * 100;
|
|
118
|
+
if (this.refContainer.current) {
|
|
119
|
+
this.refContainer.current.style.transform = `translateX(${transform}%)`;
|
|
135
120
|
}
|
|
136
|
-
if (
|
|
137
|
-
|
|
121
|
+
if (this.refModalContainer.current) {
|
|
122
|
+
this.refModalContainer.current.style.transform = `translateX(${transform}%)`;
|
|
138
123
|
}
|
|
139
124
|
});
|
|
140
|
-
_defineProperty(
|
|
141
|
-
|
|
125
|
+
_defineProperty(this, "getDirection", (currentIndex, nextIndex) => {
|
|
126
|
+
const {
|
|
127
|
+
bounded
|
|
128
|
+
} = this.asProps;
|
|
142
129
|
if (bounded) {
|
|
143
130
|
return currentIndex < nextIndex ? 'right' : 'left';
|
|
144
131
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
132
|
+
const {
|
|
133
|
+
items
|
|
134
|
+
} = this.state;
|
|
135
|
+
const listIndex = items.map((_, ind) => ind);
|
|
136
|
+
const tmpArr = [...listIndex];
|
|
137
|
+
const minTmpArr = tmpArr[0];
|
|
138
|
+
const maxTmpArr = tmpArr[tmpArr.length - 1];
|
|
152
139
|
if (tmpArr.length === 2) {
|
|
153
140
|
return currentIndex < nextIndex ? 'right' : 'left';
|
|
154
141
|
}
|
|
@@ -160,399 +147,381 @@ var CarouselRoot = /*#__PURE__*/function (_Component) {
|
|
|
160
147
|
tmpArr.shift();
|
|
161
148
|
tmpArr.push(minTmpArr);
|
|
162
149
|
}
|
|
163
|
-
|
|
164
|
-
|
|
150
|
+
const tmpCurrentIndex = tmpArr.indexOf(currentIndex);
|
|
151
|
+
const left = tmpArr.indexOf(nextIndex);
|
|
165
152
|
return left - tmpCurrentIndex < 0 ? 'left' : 'right';
|
|
166
153
|
});
|
|
167
|
-
_defineProperty(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
154
|
+
_defineProperty(this, "slideToValue", nextIndex => {
|
|
155
|
+
const {
|
|
156
|
+
selectedIndex
|
|
157
|
+
} = this.state;
|
|
158
|
+
const direction = selectedIndex < nextIndex ? 'right' : 'left';
|
|
159
|
+
let diff = Math.abs(selectedIndex - nextIndex);
|
|
171
160
|
while (diff > 0) {
|
|
172
|
-
|
|
161
|
+
this.transformItem(direction);
|
|
173
162
|
diff--;
|
|
174
163
|
}
|
|
175
164
|
});
|
|
176
|
-
_defineProperty(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
165
|
+
_defineProperty(this, "transformItem", direction => {
|
|
166
|
+
const {
|
|
167
|
+
bounded
|
|
168
|
+
} = this.asProps;
|
|
169
|
+
const {
|
|
170
|
+
items,
|
|
171
|
+
selectedIndex
|
|
172
|
+
} = this.state;
|
|
173
|
+
const maxIndexIndicator = items.length - 1;
|
|
182
174
|
if (direction === 'right') {
|
|
183
175
|
if (bounded && selectedIndex === maxIndexIndicator) {
|
|
184
|
-
|
|
176
|
+
this.handlers.index(maxIndexIndicator);
|
|
185
177
|
return;
|
|
186
178
|
}
|
|
187
|
-
if (
|
|
188
|
-
|
|
179
|
+
if (this.isControlled) {
|
|
180
|
+
this.handlers.index(selectedIndex === maxIndexIndicator ? 0 : selectedIndex + 1);
|
|
189
181
|
return;
|
|
190
182
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
_this.transformContainer();
|
|
197
|
-
_this.handlers.index(_this.getIndex());
|
|
183
|
+
this.setState(prevState => ({
|
|
184
|
+
selectedIndex: prevState.selectedIndex + 1
|
|
185
|
+
}), () => {
|
|
186
|
+
this.transformContainer();
|
|
187
|
+
this.handlers.index(this.getIndex());
|
|
198
188
|
});
|
|
199
189
|
return;
|
|
200
190
|
}
|
|
201
191
|
if (direction === 'left') {
|
|
202
192
|
if (bounded && selectedIndex === 0) {
|
|
203
|
-
|
|
193
|
+
this.handlers.index(0);
|
|
204
194
|
return;
|
|
205
195
|
}
|
|
206
|
-
if (
|
|
207
|
-
|
|
196
|
+
if (this.isControlled) {
|
|
197
|
+
this.handlers.index(selectedIndex === 0 ? maxIndexIndicator : selectedIndex - 1);
|
|
208
198
|
return;
|
|
209
199
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
_this.transformContainer();
|
|
216
|
-
_this.handlers.index(_this.getIndex());
|
|
200
|
+
this.setState(prevState => ({
|
|
201
|
+
selectedIndex: prevState.selectedIndex - 1
|
|
202
|
+
}), () => {
|
|
203
|
+
this.transformContainer();
|
|
204
|
+
this.handlers.index(this.getIndex());
|
|
217
205
|
});
|
|
218
206
|
return;
|
|
219
207
|
}
|
|
220
208
|
});
|
|
221
|
-
_defineProperty(
|
|
222
|
-
return
|
|
223
|
-
|
|
209
|
+
_defineProperty(this, "bindHandlerClick", direction => {
|
|
210
|
+
return () => {
|
|
211
|
+
this.transformItem(direction);
|
|
224
212
|
};
|
|
225
213
|
});
|
|
226
|
-
_defineProperty(
|
|
227
|
-
return
|
|
228
|
-
|
|
229
|
-
selectedIndex
|
|
230
|
-
items
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
214
|
+
_defineProperty(this, "bindHandlerClickIndicator", value => {
|
|
215
|
+
return () => {
|
|
216
|
+
const {
|
|
217
|
+
selectedIndex,
|
|
218
|
+
items
|
|
219
|
+
} = this.state;
|
|
220
|
+
if (!this.isControlled && value !== selectedIndex) {
|
|
221
|
+
const newValueIndex = Math.floor(selectedIndex / items.length) * items.length + value;
|
|
222
|
+
this.slideToValue(newValueIndex);
|
|
234
223
|
}
|
|
235
|
-
|
|
224
|
+
this.handlers.index(value);
|
|
236
225
|
};
|
|
237
226
|
});
|
|
238
|
-
_defineProperty(
|
|
239
|
-
|
|
227
|
+
_defineProperty(this, "handlerTouchStart", e => {
|
|
228
|
+
this._touchStartCoord = e.changedTouches[0].clientX;
|
|
240
229
|
});
|
|
241
|
-
_defineProperty(
|
|
242
|
-
|
|
243
|
-
|
|
230
|
+
_defineProperty(this, "handlerTouchEnd", e => {
|
|
231
|
+
const touchEndCoord = e.changedTouches[0].clientX;
|
|
232
|
+
const delta = touchEndCoord - this._touchStartCoord;
|
|
244
233
|
if (delta > 50) {
|
|
245
|
-
|
|
234
|
+
this.transformItem('left');
|
|
246
235
|
} else if (delta < -50) {
|
|
247
|
-
|
|
236
|
+
this.transformItem('right');
|
|
248
237
|
}
|
|
249
238
|
});
|
|
250
|
-
_defineProperty(
|
|
251
|
-
|
|
239
|
+
_defineProperty(this, "handleToggleZoomModal", () => {
|
|
240
|
+
this.setState(prevState => {
|
|
252
241
|
return {
|
|
253
242
|
isOpenZoom: !prevState.isOpenZoom
|
|
254
243
|
};
|
|
255
|
-
},
|
|
256
|
-
if (
|
|
257
|
-
|
|
244
|
+
}, () => {
|
|
245
|
+
if (this.state.isOpenZoom) {
|
|
246
|
+
this.transformContainer();
|
|
258
247
|
}
|
|
259
248
|
});
|
|
260
249
|
});
|
|
261
|
-
_defineProperty(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
};
|
|
250
|
+
_defineProperty(this, "bindHandlerKeydownControl", direction => e => {
|
|
251
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
252
|
+
e.preventDefault();
|
|
253
|
+
this.bindHandlerClick(direction)();
|
|
254
|
+
}
|
|
268
255
|
});
|
|
269
|
-
|
|
270
|
-
|
|
256
|
+
this.isControlled = props.index !== undefined;
|
|
257
|
+
this.state = {
|
|
271
258
|
items: [],
|
|
272
259
|
isOpenZoom: false,
|
|
273
|
-
selectedIndex:
|
|
260
|
+
selectedIndex: props.index ?? props.defaultIndex ?? 0
|
|
274
261
|
};
|
|
275
|
-
return _this;
|
|
276
262
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
key: "componentDidMount",
|
|
295
|
-
value: function componentDidMount() {
|
|
296
|
-
var selectedIndex = this.state.selectedIndex;
|
|
297
|
-
if (selectedIndex !== 0) {
|
|
298
|
-
if (selectedIndex < 0 || selectedIndex >= this.defaultItemsCount) {
|
|
299
|
-
logger.warn(true, "You couldn't use value for the `index` or `defaultIndex` not from `Item's` length range.", CarouselRoot.displayName);
|
|
300
|
-
this.setState({
|
|
301
|
-
selectedIndex: 0
|
|
302
|
-
});
|
|
303
|
-
} else {
|
|
304
|
-
this.transformContainer();
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
var deprecatedComponents = findAllComponents(this.asProps.Children, ['Carousel.Prev', 'Carousel.Next', 'Carousel.Indicators']);
|
|
308
|
-
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);
|
|
309
|
-
}
|
|
310
|
-
}, {
|
|
311
|
-
key: "componentDidUpdate",
|
|
312
|
-
value: function componentDidUpdate(prevProps) {
|
|
313
|
-
var _this3 = this;
|
|
314
|
-
var index = this.asProps.index;
|
|
315
|
-
if (prevProps.index !== index && this.isControlled && index !== undefined) {
|
|
263
|
+
uncontrolledProps() {
|
|
264
|
+
return {
|
|
265
|
+
index: [null, _index => {
|
|
266
|
+
this.refCarousel.current?.blur();
|
|
267
|
+
setTimeout(() => {
|
|
268
|
+
this.refCarousel.current?.focus();
|
|
269
|
+
}, 0);
|
|
270
|
+
}]
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
componentDidMount() {
|
|
274
|
+
const {
|
|
275
|
+
selectedIndex
|
|
276
|
+
} = this.state;
|
|
277
|
+
if (selectedIndex !== 0) {
|
|
278
|
+
if (selectedIndex < 0 || selectedIndex >= this.defaultItemsCount) {
|
|
279
|
+
logger.warn(true, `You couldn't use value for the \`index\` or \`defaultIndex\` not from \`Item's\` length range.`, CarouselRoot.displayName);
|
|
316
280
|
this.setState({
|
|
317
|
-
selectedIndex:
|
|
318
|
-
}, function () {
|
|
319
|
-
return _this3.transformContainer();
|
|
281
|
+
selectedIndex: 0
|
|
320
282
|
});
|
|
283
|
+
} else {
|
|
284
|
+
this.transformContainer();
|
|
321
285
|
}
|
|
322
286
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
value: function getItemProps(_props, index) {
|
|
335
|
-
var zoom = this.asProps.zoom;
|
|
336
|
-
var isCurrent = this.isSelected(index);
|
|
337
|
-
return {
|
|
338
|
-
toggleItem: this.toggleItem,
|
|
339
|
-
uid: this.asProps.uid,
|
|
340
|
-
index: index,
|
|
341
|
-
current: isCurrent,
|
|
342
|
-
zoomIn: zoom,
|
|
343
|
-
onToggleZoomModal: this.handleToggleZoomModal,
|
|
344
|
-
transform: isCurrent ? this.getTransform() : undefined,
|
|
345
|
-
isOpenZoom: this.state.isOpenZoom
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
}, {
|
|
349
|
-
key: "getPrevProps",
|
|
350
|
-
value: function getPrevProps() {
|
|
351
|
-
var _this$asProps = this.asProps,
|
|
352
|
-
bounded = _this$asProps.bounded,
|
|
353
|
-
getI18nText = _this$asProps.getI18nText,
|
|
354
|
-
uid = _this$asProps.uid;
|
|
355
|
-
var _this$state3 = this.state,
|
|
356
|
-
items = _this$state3.items,
|
|
357
|
-
selectedIndex = _this$state3.selectedIndex;
|
|
358
|
-
var disabled = false;
|
|
359
|
-
if (items.length && bounded) {
|
|
360
|
-
disabled = selectedIndex === 0;
|
|
361
|
-
}
|
|
362
|
-
return {
|
|
363
|
-
'onClick': this.bindHandlerClick('left'),
|
|
364
|
-
'onKeyDown': this.bindHandlerKeydownControl('left'),
|
|
365
|
-
disabled: disabled,
|
|
366
|
-
'label': getI18nText('prev'),
|
|
367
|
-
'aria-controls': "igc-".concat(uid, "-carousel")
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
}, {
|
|
371
|
-
key: "getNextProps",
|
|
372
|
-
value: function getNextProps() {
|
|
373
|
-
var _this$asProps2 = this.asProps,
|
|
374
|
-
bounded = _this$asProps2.bounded,
|
|
375
|
-
getI18nText = _this$asProps2.getI18nText,
|
|
376
|
-
uid = _this$asProps2.uid;
|
|
377
|
-
var _this$state4 = this.state,
|
|
378
|
-
items = _this$state4.items,
|
|
379
|
-
selectedIndex = _this$state4.selectedIndex;
|
|
380
|
-
var disabled = false;
|
|
381
|
-
if (items.length && bounded) {
|
|
382
|
-
disabled = selectedIndex === items.length - 1;
|
|
383
|
-
}
|
|
384
|
-
return {
|
|
385
|
-
'onClick': this.bindHandlerClick('right'),
|
|
386
|
-
'onKeyDown': this.bindHandlerKeydownControl('right'),
|
|
387
|
-
disabled: disabled,
|
|
388
|
-
'label': getI18nText('next'),
|
|
389
|
-
'aria-controls': "igc-".concat(uid, "-carousel")
|
|
390
|
-
};
|
|
287
|
+
const deprecatedComponents = findAllComponents(this.asProps.Children, ['Carousel.Prev', 'Carousel.Next', 'Carousel.Indicators']);
|
|
288
|
+
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);
|
|
289
|
+
}
|
|
290
|
+
componentDidUpdate(prevProps) {
|
|
291
|
+
const {
|
|
292
|
+
index
|
|
293
|
+
} = this.asProps;
|
|
294
|
+
if (prevProps.index !== index && this.isControlled && index !== undefined) {
|
|
295
|
+
this.setState({
|
|
296
|
+
selectedIndex: index
|
|
297
|
+
}, () => this.transformContainer());
|
|
391
298
|
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
299
|
+
}
|
|
300
|
+
getContainerProps() {
|
|
301
|
+
const {
|
|
302
|
+
duration
|
|
303
|
+
} = this.asProps;
|
|
304
|
+
return {
|
|
305
|
+
ref: this.refContainer,
|
|
306
|
+
duration
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
getItemProps(_props, index) {
|
|
310
|
+
const {
|
|
311
|
+
zoom
|
|
312
|
+
} = this.asProps;
|
|
313
|
+
const isCurrent = this.isSelected(index);
|
|
314
|
+
return {
|
|
315
|
+
toggleItem: this.toggleItem,
|
|
316
|
+
uid: this.asProps.uid,
|
|
317
|
+
index,
|
|
318
|
+
current: isCurrent,
|
|
319
|
+
zoomIn: zoom,
|
|
320
|
+
onToggleZoomModal: this.handleToggleZoomModal,
|
|
321
|
+
transform: isCurrent ? this.getTransform() : undefined,
|
|
322
|
+
isOpenZoom: this.state.isOpenZoom
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
getPrevProps() {
|
|
326
|
+
const {
|
|
327
|
+
bounded,
|
|
328
|
+
getI18nText,
|
|
329
|
+
uid
|
|
330
|
+
} = this.asProps;
|
|
331
|
+
const {
|
|
332
|
+
items,
|
|
333
|
+
selectedIndex
|
|
334
|
+
} = this.state;
|
|
335
|
+
let disabled = false;
|
|
336
|
+
if (items.length && bounded) {
|
|
337
|
+
disabled = selectedIndex === 0;
|
|
410
338
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
339
|
+
return {
|
|
340
|
+
'onClick': this.bindHandlerClick('left'),
|
|
341
|
+
'onKeyDown': this.bindHandlerKeydownControl('left'),
|
|
342
|
+
disabled,
|
|
343
|
+
'label': getI18nText('prev'),
|
|
344
|
+
'aria-controls': `igc-${uid}-carousel`
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
getNextProps() {
|
|
348
|
+
const {
|
|
349
|
+
bounded,
|
|
350
|
+
getI18nText,
|
|
351
|
+
uid
|
|
352
|
+
} = this.asProps;
|
|
353
|
+
const {
|
|
354
|
+
items,
|
|
355
|
+
selectedIndex
|
|
356
|
+
} = this.state;
|
|
357
|
+
let disabled = false;
|
|
358
|
+
if (items.length && bounded) {
|
|
359
|
+
disabled = selectedIndex === items.length - 1;
|
|
424
360
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
361
|
+
return {
|
|
362
|
+
'onClick': this.bindHandlerClick('right'),
|
|
363
|
+
'onKeyDown': this.bindHandlerKeydownControl('right'),
|
|
364
|
+
disabled,
|
|
365
|
+
'label': getI18nText('next'),
|
|
366
|
+
'aria-controls': `igc-${uid}-carousel`
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
getIndicatorsProps() {
|
|
370
|
+
const {
|
|
371
|
+
items
|
|
372
|
+
} = this.state;
|
|
373
|
+
const {
|
|
374
|
+
getI18nText
|
|
375
|
+
} = this.asProps;
|
|
376
|
+
return {
|
|
377
|
+
'items': items.map((_item, key) => ({
|
|
378
|
+
active: this.isSelected(key),
|
|
379
|
+
onClick: this.bindHandlerClickIndicator(key),
|
|
380
|
+
key
|
|
381
|
+
})),
|
|
382
|
+
'role': 'tablist',
|
|
383
|
+
'tabIndex': 0,
|
|
384
|
+
'aria-label': getI18nText('slides')
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
getIndicatorProps(_, index) {
|
|
388
|
+
const isCurrent = this.isSelected(index);
|
|
389
|
+
const {
|
|
390
|
+
getI18nText
|
|
391
|
+
} = this.asProps;
|
|
392
|
+
return {
|
|
393
|
+
'role': 'tab',
|
|
394
|
+
'aria-selected': isCurrent,
|
|
395
|
+
'aria-controls': `igc-${this.asProps.uid}-carousel-item-${index}`,
|
|
396
|
+
'aria-label': getI18nText('slide', {
|
|
397
|
+
slideNumber: index + 1
|
|
398
|
+
})
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
getTransform() {
|
|
402
|
+
const {
|
|
403
|
+
items,
|
|
404
|
+
selectedIndex
|
|
405
|
+
} = this.state;
|
|
406
|
+
const direction = selectedIndex > 0 ? 1 : -1;
|
|
407
|
+
const count = items.length === 0 ? 0 : Math.floor(selectedIndex / items.length) * direction;
|
|
408
|
+
const transform = selectedIndex > 0 && selectedIndex < items.length ? 0 : 100 * direction * count * items.length;
|
|
409
|
+
return transform;
|
|
410
|
+
}
|
|
411
|
+
getIndex() {
|
|
412
|
+
const {
|
|
413
|
+
items,
|
|
414
|
+
selectedIndex
|
|
415
|
+
} = this.state;
|
|
416
|
+
if (items.length === 0) {
|
|
417
|
+
return 0;
|
|
435
418
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
value: function getIndex() {
|
|
439
|
-
var _this$state6 = this.state,
|
|
440
|
-
items = _this$state6.items,
|
|
441
|
-
selectedIndex = _this$state6.selectedIndex;
|
|
442
|
-
if (items.length === 0) {
|
|
443
|
-
return 0;
|
|
444
|
-
}
|
|
445
|
-
if (selectedIndex >= 0) {
|
|
446
|
-
return selectedIndex % items.length;
|
|
447
|
-
}
|
|
448
|
-
return (items.length + selectedIndex % items.length) % items.length;
|
|
419
|
+
if (selectedIndex >= 0) {
|
|
420
|
+
return selectedIndex % items.length;
|
|
449
421
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
return
|
|
422
|
+
return (items.length + selectedIndex % items.length) % items.length;
|
|
423
|
+
}
|
|
424
|
+
isSelected(index) {
|
|
425
|
+
const {
|
|
426
|
+
items
|
|
427
|
+
} = this.state;
|
|
428
|
+
if (items.length === 0) {
|
|
429
|
+
return true;
|
|
458
430
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
431
|
+
return index === this.getIndex();
|
|
432
|
+
}
|
|
433
|
+
renderModal(isSmall, ComponentItems) {
|
|
434
|
+
var _ref = this.asProps,
|
|
435
|
+
_ref0;
|
|
436
|
+
const SModalContainer = Box;
|
|
437
|
+
const SModalBox = Box;
|
|
438
|
+
const SImageBoxContainer = Box;
|
|
439
|
+
const {
|
|
440
|
+
styles,
|
|
441
|
+
uid,
|
|
442
|
+
duration,
|
|
443
|
+
zoomWidth
|
|
444
|
+
} = this.asProps;
|
|
445
|
+
const {
|
|
446
|
+
isOpenZoom
|
|
447
|
+
} = this.state;
|
|
448
|
+
return _ref0 = sstyled(styles), /*#__PURE__*/React.createElement(Modal, _ref0.cn("Modal", {
|
|
449
|
+
"visible": isOpenZoom,
|
|
450
|
+
"onClose": this.handleToggleZoomModal,
|
|
451
|
+
"ghost": true,
|
|
452
|
+
"closable": !isSmall
|
|
453
|
+
}), /*#__PURE__*/React.createElement(Flex, _ref0.cn("Flex", {
|
|
454
|
+
"direction": isSmall ? 'column' : 'row'
|
|
455
|
+
}), !isSmall && /*#__PURE__*/React.createElement(Carousel.Prev, {
|
|
456
|
+
inverted: true
|
|
457
|
+
}), /*#__PURE__*/React.createElement(SImageBoxContainer, _ref0.cn("SImageBoxContainer", {}), /*#__PURE__*/React.createElement(SModalBox, _ref0.cn("SModalBox", {}), /*#__PURE__*/React.createElement(SModalContainer, _ref0.cn("SModalContainer", {
|
|
458
|
+
..._assignProps({
|
|
484
459
|
"aria-live": 'polite',
|
|
485
|
-
"use:duration":
|
|
460
|
+
"use:duration": `${duration}ms`,
|
|
486
461
|
"ref": this.refModalContainer,
|
|
487
462
|
"use:w": undefined,
|
|
488
463
|
"wMax": zoomWidth
|
|
489
|
-
}, _ref)
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
})))), isSmall ? /*#__PURE__*/React.createElement(Flex, _ref0.cn("Flex", {
|
|
501
|
-
"justifyContent": 'center',
|
|
502
|
-
"mt": 2
|
|
503
|
-
}), /*#__PURE__*/React.createElement(Carousel.Prev, {
|
|
504
|
-
inverted: true
|
|
505
|
-
}), /*#__PURE__*/React.createElement(Carousel.Next, {
|
|
506
|
-
inverted: true
|
|
507
|
-
})) : /*#__PURE__*/React.createElement(Carousel.Next, {
|
|
508
|
-
inverted: true
|
|
509
|
-
})), !isSmall && /*#__PURE__*/React.createElement(Carousel.Indicators, {
|
|
510
|
-
inverted: true
|
|
464
|
+
}, _ref)
|
|
465
|
+
}), ComponentItems.map((item, i) => {
|
|
466
|
+
return /*#__PURE__*/React.createElement(Carousel.Item, _extends({}, item.props, {
|
|
467
|
+
key: item.key,
|
|
468
|
+
uid: uid,
|
|
469
|
+
index: i,
|
|
470
|
+
current: this.isSelected(i),
|
|
471
|
+
toggleItem: undefined,
|
|
472
|
+
zoom: true,
|
|
473
|
+
zoomOut: true,
|
|
474
|
+
transform: this.isSelected(i) ? this.getTransform() : undefined
|
|
511
475
|
}));
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
476
|
+
})))), isSmall ? /*#__PURE__*/React.createElement(Flex, _ref0.cn("Flex", {
|
|
477
|
+
"justifyContent": 'center',
|
|
478
|
+
"mt": 2
|
|
479
|
+
}), /*#__PURE__*/React.createElement(Carousel.Prev, {
|
|
480
|
+
inverted: true
|
|
481
|
+
}), /*#__PURE__*/React.createElement(Carousel.Next, {
|
|
482
|
+
inverted: true
|
|
483
|
+
})) : /*#__PURE__*/React.createElement(Carousel.Next, {
|
|
484
|
+
inverted: true
|
|
485
|
+
})), !isSmall && /*#__PURE__*/React.createElement(Carousel.Indicators, {
|
|
486
|
+
inverted: true
|
|
487
|
+
}));
|
|
488
|
+
}
|
|
489
|
+
render() {
|
|
490
|
+
var _ref2 = this.asProps,
|
|
491
|
+
_ref1;
|
|
492
|
+
const SCarousel = Box;
|
|
493
|
+
const {
|
|
494
|
+
styles,
|
|
495
|
+
Children,
|
|
496
|
+
uid,
|
|
497
|
+
zoom: hasZoom,
|
|
498
|
+
'aria-label': ariaLabel,
|
|
499
|
+
indicators,
|
|
500
|
+
getI18nText
|
|
501
|
+
} = this.asProps;
|
|
502
|
+
const ComponentItems = findAllComponents(Children, ['Carousel.Item']);
|
|
503
|
+
const Controls = findAllComponents(Children, ['Carousel.Prev', 'Carousel.Next', 'Carousel.Indicators']);
|
|
504
|
+
return _ref1 = sstyled(styles), /*#__PURE__*/React.createElement(SCarousel, _ref1.cn("SCarousel", {
|
|
505
|
+
..._assignProps2({
|
|
531
506
|
"role": 'region',
|
|
532
507
|
"aria-roledescription": getI18nText('Carousel:aria-roledescription'),
|
|
533
508
|
"onKeyDown": this.handlerKeyDown,
|
|
534
509
|
"onTouchStart": this.handlerTouchStart,
|
|
535
510
|
"onTouchEnd": this.handlerTouchEnd,
|
|
536
511
|
"ref": this.refCarousel,
|
|
537
|
-
"id":
|
|
538
|
-
}, _ref2)
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
})) : /*#__PURE__*/React.createElement(Children, _ref1.cn("Children", {})), hasZoom && /*#__PURE__*/React.createElement(BreakPoints, _ref1.cn("BreakPoints", {}), /*#__PURE__*/React.createElement(BreakPoints.Context.Consumer, null, function (mediaIndex) {
|
|
551
|
-
return _this6.renderModal(isSmallScreen(mediaIndex), ComponentItems);
|
|
552
|
-
})));
|
|
553
|
-
}
|
|
554
|
-
}]);
|
|
555
|
-
}(Component);
|
|
512
|
+
"id": `igc-${uid}-carousel`
|
|
513
|
+
}, _ref2)
|
|
514
|
+
}), Controls.length === 0 ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Flex, _ref1.cn("Flex", {}), /*#__PURE__*/React.createElement(Carousel.Prev, null), /*#__PURE__*/React.createElement(Carousel.ContentBox, null, /*#__PURE__*/React.createElement(Carousel.Container, {
|
|
515
|
+
"aria-label": ariaLabel
|
|
516
|
+
}, /*#__PURE__*/React.createElement(Children, _ref1.cn("Children", {})))), /*#__PURE__*/React.createElement(Carousel.Next, null)), indicators === 'default' && /*#__PURE__*/React.createElement(Carousel.Indicators, null), indicators === 'preview' && /*#__PURE__*/React.createElement(Carousel.Indicators, null, () => ComponentItems.map((item, index) => /*#__PURE__*/React.createElement(Carousel.Indicator, _extends({}, item.props, {
|
|
517
|
+
key: item.key,
|
|
518
|
+
w: undefined,
|
|
519
|
+
"aria-roledescription": getI18nText('Carousel.Indicator:aria-roledescription'),
|
|
520
|
+
active: this.isSelected(index),
|
|
521
|
+
onClick: this.bindHandlerClickIndicator(index)
|
|
522
|
+
}))))) : /*#__PURE__*/React.createElement(Children, _ref1.cn("Children", {})), hasZoom && /*#__PURE__*/React.createElement(BreakPoints, _ref1.cn("BreakPoints", {}), /*#__PURE__*/React.createElement(BreakPoints.Context.Consumer, null, mediaIndex => this.renderModal(isSmallScreen(mediaIndex), ComponentItems))));
|
|
523
|
+
}
|
|
524
|
+
}
|
|
556
525
|
_defineProperty(CarouselRoot, "displayName", 'Carousel');
|
|
557
526
|
_defineProperty(CarouselRoot, "defaultProps", {
|
|
558
527
|
defaultIndex: 0,
|
|
@@ -565,113 +534,114 @@ _defineProperty(CarouselRoot, "defaultProps", {
|
|
|
565
534
|
});
|
|
566
535
|
_defineProperty(CarouselRoot, "style", style);
|
|
567
536
|
_defineProperty(CarouselRoot, "enhance", enhance);
|
|
568
|
-
|
|
537
|
+
function Container(props) {
|
|
569
538
|
var _ref3 = arguments[0],
|
|
570
539
|
_ref10;
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
}
|
|
579
|
-
|
|
540
|
+
const SContainer = Box;
|
|
541
|
+
const {
|
|
542
|
+
styles,
|
|
543
|
+
duration
|
|
544
|
+
} = props;
|
|
545
|
+
return _ref10 = sstyled(styles), /*#__PURE__*/React.createElement(SContainer, _ref10.cn("SContainer", {
|
|
546
|
+
..._assignProps3({
|
|
547
|
+
"use:duration": `${duration}ms`,
|
|
548
|
+
"aria-live": 'polite'
|
|
549
|
+
}, _ref3)
|
|
550
|
+
}));
|
|
551
|
+
}
|
|
552
|
+
function ContentBox(props) {
|
|
580
553
|
var _ref4 = arguments[0],
|
|
581
554
|
_ref11;
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
};
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
_defineProperty(_this7, "refItem", /*#__PURE__*/React.createRef());
|
|
595
|
-
return _this7;
|
|
555
|
+
const SContentBox = Box;
|
|
556
|
+
const {
|
|
557
|
+
styles
|
|
558
|
+
} = props;
|
|
559
|
+
return _ref11 = sstyled(styles), /*#__PURE__*/React.createElement(SContentBox, _ref11.cn("SContentBox", {
|
|
560
|
+
..._assignProps4({}, _ref4)
|
|
561
|
+
}));
|
|
562
|
+
}
|
|
563
|
+
class Item extends Component {
|
|
564
|
+
constructor(...args) {
|
|
565
|
+
super(...args);
|
|
566
|
+
_defineProperty(this, "refItem", /*#__PURE__*/React.createRef());
|
|
596
567
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
node: refItem
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
if (transform && refItem) {
|
|
611
|
-
refItem.style.transform = "translateX(".concat(transform, "%)");
|
|
612
|
-
}
|
|
568
|
+
componentDidMount() {
|
|
569
|
+
const {
|
|
570
|
+
toggleItem,
|
|
571
|
+
transform
|
|
572
|
+
} = this.props;
|
|
573
|
+
const refItem = this.refItem.current;
|
|
574
|
+
if (toggleItem && refItem) {
|
|
575
|
+
toggleItem({
|
|
576
|
+
node: refItem
|
|
577
|
+
});
|
|
613
578
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
value: function componentWillUnmount() {
|
|
617
|
-
var toggleItem = this.props.toggleItem;
|
|
618
|
-
var refItem = this.refItem.current;
|
|
619
|
-
if (toggleItem && refItem) {
|
|
620
|
-
toggleItem({
|
|
621
|
-
node: refItem
|
|
622
|
-
}, true);
|
|
623
|
-
}
|
|
579
|
+
if (transform && refItem) {
|
|
580
|
+
refItem.style.transform = `translateX(${transform}%)`;
|
|
624
581
|
}
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
582
|
+
}
|
|
583
|
+
componentWillUnmount() {
|
|
584
|
+
const {
|
|
585
|
+
toggleItem
|
|
586
|
+
} = this.props;
|
|
587
|
+
const refItem = this.refItem.current;
|
|
588
|
+
if (toggleItem && refItem) {
|
|
589
|
+
toggleItem({
|
|
590
|
+
node: refItem
|
|
591
|
+
}, true);
|
|
633
592
|
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
593
|
+
}
|
|
594
|
+
componentDidUpdate(prevProps) {
|
|
595
|
+
const transform = this.props.transform;
|
|
596
|
+
const refItem = this.refItem.current;
|
|
597
|
+
if (prevProps.transform !== transform && refItem) {
|
|
598
|
+
refItem.style.transform = `translateX(${transform}%)`;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
render() {
|
|
602
|
+
var _ref5 = this.asProps,
|
|
603
|
+
_ref12;
|
|
604
|
+
const {
|
|
605
|
+
styles,
|
|
606
|
+
index,
|
|
607
|
+
uid,
|
|
608
|
+
current,
|
|
609
|
+
zoomIn,
|
|
610
|
+
onToggleZoomModal
|
|
611
|
+
} = this.props;
|
|
612
|
+
const SItem = Box;
|
|
613
|
+
return _ref12 = sstyled(styles), /*#__PURE__*/React.createElement(SItem, _ref12.cn("SItem", {
|
|
614
|
+
..._assignProps5({
|
|
648
615
|
"ref": this.refItem,
|
|
649
616
|
"role": 'tabpanel',
|
|
650
|
-
"data-carousel":
|
|
651
|
-
"id":
|
|
617
|
+
"data-carousel": `igc-${uid}-carousel`,
|
|
618
|
+
"id": `igc-${uid}-carousel-item-${index}`,
|
|
652
619
|
"aria-current": current,
|
|
653
620
|
"use:tabIndex": current ? 0 : -1,
|
|
654
621
|
"onClick": zoomIn ? onToggleZoomModal : undefined,
|
|
655
622
|
"zoomIn": zoomIn
|
|
656
|
-
}, _ref5)
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
|
|
623
|
+
}, _ref5)
|
|
624
|
+
}));
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
function Prev(props) {
|
|
661
628
|
var _ref6 = arguments[0],
|
|
662
629
|
_ref13;
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
top =
|
|
669
|
-
inverted
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
630
|
+
const {
|
|
631
|
+
styles,
|
|
632
|
+
children,
|
|
633
|
+
Children,
|
|
634
|
+
label,
|
|
635
|
+
top = 0,
|
|
636
|
+
inverted
|
|
637
|
+
} = props;
|
|
638
|
+
const SPrev = Box;
|
|
639
|
+
const SPrevButton = Button;
|
|
640
|
+
return _ref13 = sstyled(styles), /*#__PURE__*/React.createElement(SPrev, _ref13.cn("SPrev", {
|
|
641
|
+
..._assignProps6({
|
|
642
|
+
"top": top
|
|
643
|
+
}, _ref6)
|
|
644
|
+
}), children ? /*#__PURE__*/React.createElement(Children, _ref13.cn("Children", {})) : /*#__PURE__*/React.createElement(SPrevButton, _ref13.cn("SPrevButton", {
|
|
675
645
|
"addonLeft": ChevronLeft,
|
|
676
646
|
"aria-label": label,
|
|
677
647
|
"theme": inverted ? 'invert' : 'muted',
|
|
@@ -679,22 +649,26 @@ var Prev = function Prev(props) {
|
|
|
679
649
|
"size": 'l',
|
|
680
650
|
"innerOutline": true
|
|
681
651
|
})));
|
|
682
|
-
}
|
|
683
|
-
|
|
652
|
+
}
|
|
653
|
+
;
|
|
654
|
+
function Next(props) {
|
|
684
655
|
var _ref7 = arguments[0],
|
|
685
656
|
_ref14;
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
top =
|
|
692
|
-
inverted
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
657
|
+
const {
|
|
658
|
+
styles,
|
|
659
|
+
children,
|
|
660
|
+
Children,
|
|
661
|
+
label,
|
|
662
|
+
top = 0,
|
|
663
|
+
inverted
|
|
664
|
+
} = props;
|
|
665
|
+
const SNext = Box;
|
|
666
|
+
const SNextButton = Button;
|
|
667
|
+
return _ref14 = sstyled(styles), /*#__PURE__*/React.createElement(SNext, _ref14.cn("SNext", {
|
|
668
|
+
..._assignProps7({
|
|
669
|
+
"top": top
|
|
670
|
+
}, _ref7)
|
|
671
|
+
}), children ? /*#__PURE__*/React.createElement(Children, _ref14.cn("Children", {})) : /*#__PURE__*/React.createElement(SNextButton, _ref14.cn("SNextButton", {
|
|
698
672
|
"addonLeft": ChevronRight,
|
|
699
673
|
"aria-label": label,
|
|
700
674
|
"theme": inverted ? 'invert' : 'muted',
|
|
@@ -702,48 +676,57 @@ var Next = function Next(props) {
|
|
|
702
676
|
"size": 'l',
|
|
703
677
|
"innerOutline": true
|
|
704
678
|
})));
|
|
705
|
-
}
|
|
706
|
-
|
|
679
|
+
}
|
|
680
|
+
;
|
|
681
|
+
function Indicators({
|
|
682
|
+
items,
|
|
683
|
+
styles,
|
|
684
|
+
Children,
|
|
685
|
+
inverted
|
|
686
|
+
}) {
|
|
707
687
|
var _ref8 = arguments[0],
|
|
708
688
|
_ref16;
|
|
709
|
-
|
|
710
|
-
styles = _ref19.styles,
|
|
711
|
-
Children = _ref19.Children,
|
|
712
|
-
inverted = _ref19.inverted;
|
|
713
|
-
var SIndicators = Box;
|
|
689
|
+
const SIndicators = Box;
|
|
714
690
|
if (Children.origin) {
|
|
715
691
|
var _ref15;
|
|
716
|
-
return _ref15 = sstyled(styles), /*#__PURE__*/React.createElement(SIndicators, _ref15.cn("SIndicators",
|
|
717
|
-
|
|
718
|
-
|
|
692
|
+
return _ref15 = sstyled(styles), /*#__PURE__*/React.createElement(SIndicators, _ref15.cn("SIndicators", {
|
|
693
|
+
..._assignProps8({
|
|
694
|
+
"innerOffset": true
|
|
695
|
+
}, _ref8)
|
|
696
|
+
}), /*#__PURE__*/React.createElement(Children, _ref15.cn("Children", {})));
|
|
719
697
|
}
|
|
720
|
-
return _ref16 = sstyled(styles), /*#__PURE__*/React.createElement(SIndicators, _ref16.cn("SIndicators",
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
}));
|
|
729
|
-
}
|
|
730
|
-
|
|
698
|
+
return _ref16 = sstyled(styles), /*#__PURE__*/React.createElement(SIndicators, _ref16.cn("SIndicators", {
|
|
699
|
+
..._assignProps9({
|
|
700
|
+
"invertOutline": inverted
|
|
701
|
+
}, _ref8)
|
|
702
|
+
}), items?.map((item, index) => /*#__PURE__*/React.createElement(Carousel.Indicator, _extends({
|
|
703
|
+
key: index
|
|
704
|
+
}, item, {
|
|
705
|
+
inverted: inverted
|
|
706
|
+
}))));
|
|
707
|
+
}
|
|
708
|
+
;
|
|
709
|
+
function Indicator({
|
|
710
|
+
styles,
|
|
711
|
+
Children,
|
|
712
|
+
inverted
|
|
713
|
+
}) {
|
|
731
714
|
var _ref9 = arguments[0],
|
|
732
715
|
_ref17;
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
Container
|
|
741
|
-
ContentBox
|
|
742
|
-
Indicators
|
|
743
|
-
Indicator
|
|
744
|
-
Item
|
|
745
|
-
Prev
|
|
746
|
-
Next
|
|
716
|
+
const SIndicator = Box;
|
|
717
|
+
return _ref17 = sstyled(styles), /*#__PURE__*/React.createElement(SIndicator, _ref17.cn("SIndicator", {
|
|
718
|
+
..._assignProps0({}, _ref9)
|
|
719
|
+
}), /*#__PURE__*/React.createElement(Children, _ref17.cn("Children", {})));
|
|
720
|
+
}
|
|
721
|
+
;
|
|
722
|
+
const Carousel = createComponent(CarouselRoot, {
|
|
723
|
+
Container,
|
|
724
|
+
ContentBox,
|
|
725
|
+
Indicators,
|
|
726
|
+
Indicator,
|
|
727
|
+
Item,
|
|
728
|
+
Prev,
|
|
729
|
+
Next
|
|
747
730
|
});
|
|
748
731
|
export default Carousel;
|
|
749
732
|
//# sourceMappingURL=Carousel.js.map
|