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