@semcore/carousel 16.1.13 → 17.0.0-prerelease.18

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