@semcore/carousel 16.0.0-prerelease.6 → 16.0.0-prerelease.9

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.
@@ -1,517 +1,689 @@
1
- import w from "@babel/runtime/helpers/esm/extends";
2
- import C from "@babel/runtime/helpers/esm/objectSpread2";
3
- import N from "@babel/runtime/helpers/esm/toConsumableArray";
4
- import $ from "@babel/runtime/helpers/esm/classCallCheck";
5
- import O from "@babel/runtime/helpers/esm/createClass";
6
- import m from "@babel/runtime/helpers/esm/assertThisInitialized";
7
- import Z from "@babel/runtime/helpers/esm/inherits";
8
- import F from "@babel/runtime/helpers/esm/createSuper";
9
- import h from "@babel/runtime/helpers/esm/defineProperty";
10
- import { sstyled as g, createComponent as L, assignProps as S, Component as A } from "@semcore/core";
11
- import i from "react";
12
- import R from "@semcore/button";
13
- import j from "@semcore/modal";
14
- import { Flex as T, Box as I } from "@semcore/flex-box";
15
- import U from "@semcore/icon/ChevronRight/l";
16
- import V from "@semcore/icon/ChevronLeft/l";
17
- import X from "@semcore/core/lib/utils/uniqueID";
18
- import W from "@semcore/core/lib/utils/enhances/i18nEnhance";
19
- import { localizedMessages as H } from "./translations/__intergalactic-dynamic-locales.mjs";
20
- import z from "@semcore/core/lib/utils/logger";
21
- import { findAllComponents as M } from "@semcore/core/lib/utils/findComponent";
22
- import { createBreakpoints as q } from "@semcore/breakpoints";
23
- import Y from "@semcore/core/lib/utils/enhances/keyboardFocusEnhance";
24
- var G = (
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 = (
25
25
  /*__reshadow_css_start__*/
26
- (g.insert(
26
+ (sstyled.insert(
27
27
  /*__inner_css_start__*/
28
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
29
  "vh2eh_gg_"
30
30
  ), {
31
- __SCarousel: "___SCarousel_vh2eh_gg_",
32
- __SContainer: "___SContainer_vh2eh_gg_",
31
+ "__SCarousel": "___SCarousel_vh2eh_gg_",
32
+ "__SContainer": "___SContainer_vh2eh_gg_",
33
33
  "--duration": "--duration_vh2eh",
34
- __SModalContainer: "___SModalContainer_vh2eh_gg_",
35
- __SItem: "___SItem_vh2eh_gg_",
34
+ "__SModalContainer": "___SModalContainer_vh2eh_gg_",
35
+ "__SItem": "___SItem_vh2eh_gg_",
36
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_"
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_"
51
51
  })
52
- ), J = {
52
+ );
53
+ var MAP_TRANSFORM = {
53
54
  ArrowLeft: "left",
54
55
  ArrowRight: "right"
55
- }, Q = [X(), W(H)], ee = ["(min-width: 481px)", "(max-width: 480px)"], D = q(ee), te = function(c) {
56
- return c === 1;
57
- }, E = /* @__PURE__ */ function(p) {
58
- Z(_, p);
59
- var c = F(_);
60
- function _(a) {
61
- var r, n, e;
62
- return $(this, _), e = c.call(this, a), h(m(e), "defaultItemsCount", 0), h(m(e), "refCarousel", /* @__PURE__ */ i.createRef()), h(m(e), "refContainer", /* @__PURE__ */ i.createRef()), h(m(e), "refModalContainer", /* @__PURE__ */ i.createRef()), h(m(e), "_touchStartCoord", -1), h(m(e), "handlerKeyDown", function(t) {
63
- var o = 1, s = e.state.items.length + 1;
64
- switch (t.key) {
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) {
65
80
  case "ArrowLeft":
66
81
  case "ArrowRight": {
67
- t.preventDefault(), e.transformItem(J[t.key]);
82
+ e.preventDefault();
83
+ _this.transformItem(MAP_TRANSFORM[e.key]);
68
84
  break;
69
85
  }
70
86
  case "Home": {
71
- t.preventDefault(), e.slideToValue(o);
87
+ e.preventDefault();
88
+ _this.slideToValue(firstSlide);
72
89
  break;
73
90
  }
74
91
  case "End": {
75
- t.preventDefault(), e.slideToValue(s);
92
+ e.preventDefault();
93
+ _this.slideToValue(lastSlide);
76
94
  break;
77
95
  }
78
96
  }
79
- t.metaKey && (t.key === "ArrowLeft" ? (t.preventDefault(), e.slideToValue(o)) : t.key === "ArrowRight" && (t.preventDefault(), e.slideToValue(s))), (t.key === "Enter" || t.key === " ") && t.target instanceof HTMLDivElement && t.target.role === "tabpanel" && e.handleToggleZoomModal();
80
- }), h(m(e), "toggleItem", function(t) {
81
- var o = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
82
- e.setState(function(s) {
83
- var d = o ? s.items.filter(function(l) {
84
- return l.node !== t.node;
85
- }) : [].concat(N(s.items), [t]);
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]);
86
116
  return {
87
- items: d
117
+ items: newItems
88
118
  };
89
- }), o || e.defaultItemsCount++;
90
- }), h(m(e), "transformContainer", function() {
91
- var t = e.state.selectedIndex * -1 * 100;
92
- e.refContainer.current && (e.refContainer.current.style.transform = "translateX(".concat(t, "%)")), e.refModalContainer.current && (e.refModalContainer.current.style.transform = "translateX(".concat(t, "%)"));
93
- }), h(m(e), "getDirection", function(t, o) {
94
- var s = e.asProps.bounded;
95
- if (s)
96
- return t < o ? "right" : "left";
97
- var d = e.state.items, l = d.map(function(k, x) {
98
- return x;
99
- }), u = N(l), f = u[0], y = u[u.length - 1];
100
- if (u.length === 2)
101
- return t < o ? "right" : "left";
102
- t === f && (u.unshift(y), u.pop()), t === y && (u.shift(), u.push(f));
103
- var b = u.indexOf(t), P = u.indexOf(o);
104
- return P - b < 0 ? "left" : "right";
105
- }), h(m(e), "slideToValue", function(t) {
106
- for (var o = e.state.selectedIndex, s = o < t ? "right" : "left", d = Math.abs(o - t); d > 0; )
107
- e.transformItem(s), d--;
108
- }), h(m(e), "transformItem", function(t) {
109
- var o = e.asProps.bounded, s = e.state, d = s.items, l = s.selectedIndex, u = d.length - 1;
110
- if (t === "right") {
111
- if (o && l === u) {
112
- e.handlers.index(u);
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);
113
176
  return;
114
177
  }
115
- if (e.isControlled) {
116
- e.handlers.index(l === u ? 0 : l + 1);
178
+ if (_this.isControlled) {
179
+ _this.handlers.index(selectedIndex === maxIndexIndicator ? 0 : selectedIndex + 1);
117
180
  return;
118
181
  }
119
- e.setState(function(f) {
182
+ _this.setState(function(prevState) {
120
183
  return {
121
- selectedIndex: f.selectedIndex + 1
184
+ selectedIndex: prevState.selectedIndex + 1
122
185
  };
123
186
  }, function() {
124
- e.transformContainer(), e.handlers.index(e.getIndex());
187
+ _this.transformContainer();
188
+ _this.handlers.index(_this.getIndex());
125
189
  });
126
190
  return;
127
191
  }
128
- if (t === "left") {
129
- if (o && l === 0) {
130
- e.handlers.index(0);
192
+ if (direction === "left") {
193
+ if (bounded && selectedIndex === 0) {
194
+ _this.handlers.index(0);
131
195
  return;
132
196
  }
133
- if (e.isControlled) {
134
- e.handlers.index(l === 0 ? u : l - 1);
197
+ if (_this.isControlled) {
198
+ _this.handlers.index(selectedIndex === 0 ? maxIndexIndicator : selectedIndex - 1);
135
199
  return;
136
200
  }
137
- e.setState(function(f) {
201
+ _this.setState(function(prevState) {
138
202
  return {
139
- selectedIndex: f.selectedIndex - 1
203
+ selectedIndex: prevState.selectedIndex - 1
140
204
  };
141
205
  }, function() {
142
- e.transformContainer(), e.handlers.index(e.getIndex());
206
+ _this.transformContainer();
207
+ _this.handlers.index(_this.getIndex());
143
208
  });
144
209
  return;
145
210
  }
146
- }), h(m(e), "bindHandlerClick", function(t) {
211
+ });
212
+ _defineProperty(_assertThisInitialized(_this), "bindHandlerClick", function(direction) {
147
213
  return function() {
148
- e.transformItem(t);
214
+ _this.transformItem(direction);
149
215
  };
150
- }), h(m(e), "bindHandlerClickIndicator", function(t) {
216
+ });
217
+ _defineProperty(_assertThisInitialized(_this), "bindHandlerClickIndicator", function(value) {
151
218
  return function() {
152
- var o = e.state, s = o.selectedIndex, d = o.items;
153
- if (!e.isControlled && t !== s) {
154
- var l = Math.floor(s / d.length) * d.length + t;
155
- e.slideToValue(l);
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);
156
223
  }
157
- e.handlers.index(t);
224
+ _this.handlers.index(value);
158
225
  };
159
- }), h(m(e), "handlerTouchStart", function(t) {
160
- e._touchStartCoord = t.changedTouches[0].clientX;
161
- }), h(m(e), "handlerTouchEnd", function(t) {
162
- var o = t.changedTouches[0].clientX, s = o - e._touchStartCoord;
163
- s > 50 ? e.transformItem("left") : s < -50 && e.transformItem("right");
164
- }), h(m(e), "handleToggleZoomModal", function() {
165
- e.setState(function(t) {
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) {
166
241
  return {
167
- isOpenZoom: !t.isOpenZoom
242
+ isOpenZoom: !prevState.isOpenZoom
168
243
  };
169
244
  }, function() {
170
- e.state.isOpenZoom && e.transformContainer();
245
+ _this.state.isOpenZoom && _this.transformContainer();
171
246
  });
172
- }), h(m(e), "bindHandlerKeydownControl", function(t) {
173
- return function(o) {
174
- (o.key === "Enter" || o.key === " ") && (o.preventDefault(), e.bindHandlerClick(t)());
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
+ }
175
254
  };
176
- }), e.isControlled = a.index !== void 0, e.state = {
255
+ });
256
+ _this.isControlled = props.index !== void 0;
257
+ _this.state = {
177
258
  items: [],
178
- isOpenZoom: !1,
179
- selectedIndex: (r = (n = a.index) !== null && n !== void 0 ? n : a.defaultIndex) !== null && r !== void 0 ? r : 0
180
- }, e;
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;
181
263
  }
182
- return O(_, [{
264
+ _createClass(CarouselRoot2, [{
183
265
  key: "uncontrolledProps",
184
- value: function() {
185
- var r = this;
266
+ value: function uncontrolledProps() {
267
+ var _this2 = this;
186
268
  return {
187
- index: [null, function(n) {
188
- var e;
189
- (e = r.refCarousel.current) === null || e === void 0 || e.blur(), setTimeout(function() {
190
- var t;
191
- (t = r.refCarousel.current) === null || t === void 0 || t.focus();
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();
192
275
  }, 0);
193
276
  }]
194
277
  };
195
278
  }
196
279
  }, {
197
280
  key: "componentDidMount",
198
- value: function() {
199
- var r = this.state.selectedIndex;
200
- r !== 0 && (r < 0 || r >= this.defaultItemsCount ? (z.warn(!0, "You couldn't use value for the `index` or `defaultIndex` not from `Item's` length range.", _.displayName), this.setState({
201
- selectedIndex: 0
202
- })) : this.transformContainer());
203
- var n = M(this.asProps.Children, ["Carousel.Prev", "Carousel.Next", "Carousel.Indicators"]);
204
- z.warn(n.length > 0, "Please, try to remove `Prev`, `Next`, `Indicators` and other children components from your Carousel, except only `Item` elements.", _.displayName);
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);
205
295
  }
206
296
  }, {
207
297
  key: "componentDidUpdate",
208
- value: function(r) {
209
- var n = this, e = this.asProps.index;
210
- r.index !== e && this.isControlled && e !== void 0 && this.setState({
211
- selectedIndex: e
212
- }, function() {
213
- return n.transformContainer();
214
- });
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
+ }
215
308
  }
216
309
  }, {
217
310
  key: "getContainerProps",
218
- value: function() {
219
- var r = this.asProps.duration;
311
+ value: function getContainerProps() {
312
+ var duration = this.asProps.duration;
220
313
  return {
221
314
  ref: this.refContainer,
222
- duration: r
315
+ duration
223
316
  };
224
317
  }
225
318
  }, {
226
319
  key: "getItemProps",
227
- value: function(r, n) {
228
- var e = this.asProps.zoom, t = this.isSelected(n);
320
+ value: function getItemProps(props, index) {
321
+ var zoom = this.asProps.zoom;
322
+ var isCurrent = this.isSelected(index);
229
323
  return {
230
324
  toggleItem: this.toggleItem,
231
325
  uid: this.asProps.uid,
232
- index: n,
233
- current: t,
234
- zoomIn: e,
326
+ index,
327
+ current: isCurrent,
328
+ zoomIn: zoom,
235
329
  onToggleZoomModal: this.handleToggleZoomModal,
236
- transform: t ? this.getTransform() : void 0,
330
+ transform: isCurrent ? this.getTransform() : void 0,
237
331
  isOpenZoom: this.state.isOpenZoom
238
332
  };
239
333
  }
240
334
  }, {
241
335
  key: "getPrevProps",
242
- value: function() {
243
- var r = this.asProps, n = r.bounded, e = r.getI18nText, t = r.uid, o = this.state, s = o.items, d = o.selectedIndex, l = !1;
244
- return s.length && n && (l = d === 0), {
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 {
245
344
  onClick: this.bindHandlerClick("left"),
246
345
  onKeyDown: this.bindHandlerKeydownControl("left"),
247
- disabled: l,
248
- label: e("prev"),
249
- "aria-controls": "igc-".concat(t, "-carousel")
346
+ disabled,
347
+ label: getI18nText("prev"),
348
+ "aria-controls": "igc-".concat(uid, "-carousel")
250
349
  };
251
350
  }
252
351
  }, {
253
352
  key: "getNextProps",
254
- value: function() {
255
- var r = this.asProps, n = r.bounded, e = r.getI18nText, t = r.uid, o = this.state, s = o.items, d = o.selectedIndex, l = !1;
256
- return s.length && n && (l = d === s.length - 1), {
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 {
257
361
  onClick: this.bindHandlerClick("right"),
258
362
  onKeyDown: this.bindHandlerKeydownControl("right"),
259
- disabled: l,
260
- label: e("next"),
261
- "aria-controls": "igc-".concat(t, "-carousel")
363
+ disabled,
364
+ label: getI18nText("next"),
365
+ "aria-controls": "igc-".concat(uid, "-carousel")
262
366
  };
263
367
  }
264
368
  }, {
265
369
  key: "getIndicatorsProps",
266
- value: function() {
267
- var r = this, n = this.state.items, e = this.asProps.getI18nText;
370
+ value: function getIndicatorsProps() {
371
+ var _this4 = this;
372
+ var items = this.state.items;
373
+ var getI18nText = this.asProps.getI18nText;
268
374
  return {
269
- items: n.map(function(t, o) {
375
+ items: items.map(function(item, key) {
270
376
  return {
271
- active: r.isSelected(o),
272
- onClick: r.bindHandlerClickIndicator(o),
273
- key: o
377
+ active: _this4.isSelected(key),
378
+ onClick: _this4.bindHandlerClickIndicator(key),
379
+ key
274
380
  };
275
381
  }),
276
382
  role: "tablist",
277
383
  tabIndex: 0,
278
- "aria-label": e("slides")
384
+ "aria-label": getI18nText("slides")
279
385
  };
280
386
  }
281
387
  }, {
282
388
  key: "getIndicatorProps",
283
- value: function(r, n) {
284
- var e = this.isSelected(n), t = this.asProps.getI18nText;
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": e,
288
- "aria-controls": "igc-".concat(this.asProps.uid, "-carousel-item-").concat(n),
289
- "aria-label": t("slide", {
290
- slideNumber: n + 1
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 r = this.state, n = r.items, e = r.selectedIndex, t = e > 0 ? 1 : -1, o = n.length === 0 ? 0 : Math.floor(e / n.length) * t, s = e > 0 && e < n.length ? 0 : 100 * t * o * n.length;
298
- return s;
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 r = this.state, n = r.items, e = r.selectedIndex;
304
- return n.length === 0 ? 0 : e >= 0 ? e % n.length : (n.length + e % n.length) % n.length;
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(r) {
309
- var n = this.state.items;
310
- return n.length === 0 ? !0 : r === this.getIndex();
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(r, n) {
315
- var e = this.asProps, t, o = this, s = I, d = I, l = this.asProps, u = l.styles, f = l.uid, y = l.duration, b = l.zoomWidth, P = this.state.isOpenZoom;
316
- return t = g(u), /* @__PURE__ */ i.createElement(j, t.cn("Modal", {
317
- visible: P,
318
- onClose: this.handleToggleZoomModal,
319
- ghost: !0,
320
- closable: !r
321
- }), /* @__PURE__ */ i.createElement(T, t.cn("Flex", {
322
- direction: r ? "column" : "row"
323
- }), !r && /* @__PURE__ */ i.createElement(v.Prev, {
324
- inverted: !0
325
- }), /* @__PURE__ */ i.createElement(d, t.cn("SModalBox", {}), /* @__PURE__ */ i.createElement(s, t.cn("SModalContainer", C({}, S({
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(y, "ms"),
328
- ref: this.refModalContainer,
450
+ "use:duration": "".concat(duration, "ms"),
451
+ "ref": this.refModalContainer,
329
452
  "use:w": void 0,
330
- wMax: b
331
- }, e))), n.map(function(k, x) {
332
- return /* @__PURE__ */ i.createElement(v.Item, w({}, k.props, {
333
- key: k.key,
334
- uid: f,
335
- index: x,
336
- current: o.isSelected(x),
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: !0,
339
- zoomOut: !0,
340
- transform: o.isSelected(x) ? o.getTransform() : void 0
461
+ zoom: true,
462
+ zoomOut: true,
463
+ transform: _this5.isSelected(i) ? _this5.getTransform() : void 0
341
464
  }));
342
- }))), r ? /* @__PURE__ */ i.createElement(T, t.cn("Flex", {
343
- justifyContent: "center",
344
- mt: 2
345
- }), /* @__PURE__ */ i.createElement(v.Prev, {
346
- inverted: !0
347
- }), /* @__PURE__ */ i.createElement(v.Next, {
348
- inverted: !0
349
- })) : /* @__PURE__ */ i.createElement(v.Next, {
350
- inverted: !0
351
- })), !r && /* @__PURE__ */ i.createElement(v.Indicators, {
352
- inverted: !0
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 r = this.asProps, n, e = this, t = I, o = this.asProps, s = o.styles, d = o.Children, l = o.uid, u = o.zoom, f = o["aria-label"], y = o["aria-roledescription"], b = o.indicators, P = M(d, ["Carousel.Item"]), k = M(d, ["Carousel.Prev", "Carousel.Next", "Carousel.Indicators"]);
359
- return n = g(s), /* @__PURE__ */ i.createElement(t, n.cn("SCarousel", C({}, S({
360
- role: "region",
361
- roledescription: "carousel",
362
- onKeyDown: this.handlerKeyDown,
363
- onTouchStart: this.handlerTouchStart,
364
- onTouchEnd: this.handlerTouchEnd,
365
- ref: this.refCarousel,
366
- id: "igc-".concat(l, "-carousel"),
367
- "aria-roledescription": y
368
- }, r))), k.length === 0 ? /* @__PURE__ */ i.createElement(i.Fragment, null, /* @__PURE__ */ i.createElement(T, n.cn("Flex", {}), /* @__PURE__ */ i.createElement(v.Prev, null), /* @__PURE__ */ i.createElement(v.ContentBox, null, /* @__PURE__ */ i.createElement(v.Container, {
369
- "aria-label": f
370
- }, /* @__PURE__ */ i.createElement(d, n.cn("Children", {})))), /* @__PURE__ */ i.createElement(v.Next, null)), b === "default" && /* @__PURE__ */ i.createElement(v.Indicators, null), b === "preview" && /* @__PURE__ */ i.createElement(v.Indicators, null, function() {
371
- return P.map(function(x, B) {
372
- return /* @__PURE__ */ i.createElement(v.Indicator, w({}, x.props, {
373
- key: x.key,
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: e.isSelected(B),
378
- onClick: e.bindHandlerClickIndicator(B)
504
+ active: _this6.isSelected(index),
505
+ onClick: _this6.bindHandlerClickIndicator(index)
379
506
  }));
380
507
  });
381
- })) : /* @__PURE__ */ i.createElement(d, n.cn("Children", {})), u && /* @__PURE__ */ i.createElement(D, n.cn("BreakPoints", {}), /* @__PURE__ */ i.createElement(D.Context.Consumer, null, function(x) {
382
- return e.renderModal(te(x), P);
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
- }(A);
387
- h(E, "displayName", "Carousel");
388
- h(E, "defaultProps", {
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: !1,
393
- i18n: H,
520
+ bounded: false,
521
+ i18n: localizedMessages,
394
522
  locale: "en",
395
523
  indicators: "default"
396
524
  });
397
- h(E, "style", G);
398
- h(E, "enhance", Q);
399
- var re = function(c) {
400
- var _ = arguments[0], a, r = I, n = c.styles, e = c.duration;
401
- return a = g(n), /* @__PURE__ */ i.createElement(r, a.cn("SContainer", C({}, S({
402
- "use:duration": "".concat(e, "ms"),
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
- }, ne = function(c) {
406
- var _ = arguments[0], a, r = I, n = c.styles;
407
- return a = g(n), /* @__PURE__ */ i.createElement(r, a.cn("SContentBox", C({}, S({}, _))));
408
- }, K = /* @__PURE__ */ function(p) {
409
- Z(_, p);
410
- var c = F(_);
411
- function _() {
412
- var a;
413
- $(this, _);
414
- for (var r = arguments.length, n = new Array(r), e = 0; e < r; e++)
415
- n[e] = arguments[e];
416
- return a = c.call.apply(c, [this].concat(n)), h(m(a), "refItem", /* @__PURE__ */ i.createRef()), h(m(a), "keepFocusTimeout", void 0), a;
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
- return O(_, [{
556
+ _createClass(Item2, [{
419
557
  key: "componentDidMount",
420
- value: function() {
421
- var r = this.props, n = r.toggleItem, e = r.transform, t = this.refItem.current;
422
- n && t && n({
423
- node: t
424
- }), e && t && (t.style.transform = "translateX(".concat(e, "%)"));
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 r = this.props.toggleItem, n = this.refItem.current;
430
- r && n && r({
431
- node: n
432
- }, !0), clearTimeout(this.keepFocusTimeout);
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(r) {
437
- var n = this;
580
+ value: function componentDidUpdate(prevProps) {
581
+ var _this8 = this;
438
582
  clearTimeout(this.keepFocusTimeout);
439
- var e = this.props.transform, t = this.refItem.current;
440
- r.transform !== e && t && (t.style.transform = "translateX(".concat(e, "%)")), this.props.current && (this.keepFocusTimeout = setTimeout(function() {
441
- var o;
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));
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 r = this.asProps, n, e = this.props, t = e.styles, o = e.index, s = e.uid, d = e.current, l = e.zoomIn, u = e.onToggleZoomModal, f = I;
452
- return n = g(t), /* @__PURE__ */ i.createElement(f, n.cn("SItem", C({}, S({
453
- ref: this.refItem,
454
- role: "tabpanel",
455
- "data-carousel": "igc-".concat(s, "-carousel"),
456
- id: "igc-".concat(s, "-carousel-item-").concat(o),
457
- "aria-current": d,
458
- "use:tabIndex": d ? 0 : -1,
459
- onClick: l ? u : void 0,
460
- zoomIn: l
461
- }, r))));
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
- }(A);
465
- h(K, "enhance", [Y(!1)]);
466
- var oe = function(c) {
467
- var _ = arguments[0], a, r = c.styles, n = c.children, e = c.Children, t = c.label, o = c.top, s = o === void 0 ? 0 : o, d = c.inverted, l = I, u = R;
468
- return a = g(r), /* @__PURE__ */ i.createElement(l, a.cn("SPrev", C({}, S({
469
- top: s
470
- }, _))), n ? /* @__PURE__ */ i.createElement(e, a.cn("Children", {})) : /* @__PURE__ */ i.createElement(u, a.cn("SPrevButton", {
471
- addonLeft: V,
472
- "aria-label": t,
473
- theme: d ? "invert" : "muted",
474
- use: "tertiary",
475
- size: "l",
476
- innerOutline: !0
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
477
638
  })));
478
- }, ae = function(c) {
479
- var _ = arguments[0], a, r = c.styles, n = c.children, e = c.Children, t = c.label, o = c.top, s = o === void 0 ? 0 : o, d = c.inverted, l = I, u = R;
480
- return a = g(r), /* @__PURE__ */ i.createElement(l, a.cn("SNext", C({}, S({
481
- top: s
482
- }, _))), n ? /* @__PURE__ */ i.createElement(e, a.cn("Children", {})) : /* @__PURE__ */ i.createElement(u, a.cn("SNextButton", {
483
- addonLeft: U,
484
- "aria-label": t,
485
- theme: d ? "invert" : "muted",
486
- use: "tertiary",
487
- size: "l",
488
- innerOutline: !0
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
489
654
  })));
490
- }, ie = function(c) {
491
- var _ = arguments[0], a, r = c.items, n = c.styles, e = c.Children, t = c.inverted, o = I;
492
- if (e.origin) {
493
- var s;
494
- return s = g(n), /* @__PURE__ */ i.createElement(o, s.cn("SIndicators", C({}, S({}, _))), /* @__PURE__ */ i.createElement(e, s.cn("Children", {})));
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", {})));
495
663
  }
496
- return a = g(n), /* @__PURE__ */ i.createElement(o, a.cn("SIndicators", C({}, S({}, _))), r == null ? void 0 : r.map(function(d, l) {
497
- return /* @__PURE__ */ i.createElement(v.Indicator, w({
498
- key: l
499
- }, d, {
500
- inverted: t
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
501
669
  }));
502
670
  }));
503
- }, se = function(c) {
504
- var _ = arguments[0], a, r = c.styles, n = c.Children, e = I;
505
- return a = g(r), /* @__PURE__ */ i.createElement(e, a.cn("SIndicator", C({}, S({}, _))), /* @__PURE__ */ i.createElement(n, a.cn("Children", {})));
506
- }, v = L(E, {
507
- Container: re,
508
- ContentBox: ne,
509
- Indicators: ie,
510
- Indicator: se,
511
- Item: K,
512
- Prev: oe,
513
- Next: ae
671
+ };
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
- v as default
688
+ Carousel as default
517
689
  };