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