@semcore/carousel 3.48.0 → 16.0.0-prerelease.10

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