@semcore/carousel 16.0.0-prerelease.2 → 16.0.0-prerelease.21

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