@helpdice/ui 1.7.8 → 1.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/breadcrumbs/index.js +10 -7
  2. package/dist/card/index.js +10 -7
  3. package/dist/carousal/CSSTranslate.d.ts +2 -0
  4. package/dist/carousal/component/Arrow.d.ts +9 -0
  5. package/dist/carousal/component/Indicator.d.ts +9 -0
  6. package/dist/carousal/component/Thumbs.d.ts +65 -0
  7. package/dist/carousal/component/animations.d.ts +27 -0
  8. package/dist/carousal/component/index.d.ts +87 -0
  9. package/dist/carousal/component/types.d.ts +79 -0
  10. package/dist/carousal/component/utils.d.ts +15 -0
  11. package/dist/carousal/cssClasses.d.ts +11 -0
  12. package/dist/carousal/dimensions.d.ts +1 -0
  13. package/dist/carousal/index.d.ts +3 -0
  14. package/dist/carousal/index.js +13166 -0
  15. package/dist/carousal/shims/document.d.ts +2 -0
  16. package/dist/carousal/shims/window.d.ts +2 -0
  17. package/dist/image/index.js +10 -7
  18. package/dist/index.d.ts +4 -0
  19. package/dist/index.js +2794 -197
  20. package/dist/link/index.js +10 -7
  21. package/dist/link/link.d.ts +2 -1
  22. package/dist/swipe/index.d.ts +4 -0
  23. package/dist/swipe/index.js +1314 -0
  24. package/dist/swipe/react-swipe.d.ts +58 -0
  25. package/dist/user/index.js +10 -7
  26. package/esm/carousal/CSSTranslate.d.ts +2 -0
  27. package/esm/carousal/CSSTranslate.js +7 -0
  28. package/esm/carousal/component/Arrow.d.ts +9 -0
  29. package/esm/carousal/component/Arrow.js +21 -0
  30. package/esm/carousal/component/Indicator.d.ts +9 -0
  31. package/esm/carousal/component/Indicator.js +23 -0
  32. package/esm/carousal/component/Thumbs.d.ts +65 -0
  33. package/esm/carousal/{Thumbs.js → component/Thumbs.js} +41 -12
  34. package/esm/carousal/component/animations.d.ts +27 -0
  35. package/esm/carousal/{animations.js → component/animations.js} +1 -1
  36. package/esm/carousal/component/index.d.ts +87 -0
  37. package/esm/carousal/component/index.js +698 -0
  38. package/esm/carousal/component/types.d.ts +79 -0
  39. package/esm/carousal/component/utils.d.ts +15 -0
  40. package/esm/carousal/{utils.js → component/utils.js} +1 -1
  41. package/esm/carousal/cssClasses.d.ts +11 -0
  42. package/esm/carousal/cssClasses.js +56 -0
  43. package/esm/carousal/dimensions.d.ts +1 -0
  44. package/esm/carousal/dimensions.js +6 -0
  45. package/esm/carousal/index.d.ts +3 -0
  46. package/esm/carousal/index.js +2 -683
  47. package/esm/carousal/main.js +59 -0
  48. package/esm/carousal/shims/document.d.ts +2 -0
  49. package/esm/carousal/shims/document.js +3 -0
  50. package/esm/carousal/shims/window.d.ts +2 -0
  51. package/esm/carousal/shims/window.js +3 -0
  52. package/esm/index.d.ts +4 -0
  53. package/esm/index.js +6 -1
  54. package/esm/link/link.d.ts +2 -1
  55. package/esm/link/link.js +10 -7
  56. package/esm/login-with/index.js +0 -2
  57. package/esm/swipe/demo.js +57 -0
  58. package/esm/swipe/index.d.ts +4 -0
  59. package/esm/swipe/index.js +2 -0
  60. package/esm/swipe/react-swipe.d.ts +58 -0
  61. package/esm/swipe/react-swipe.js +246 -0
  62. package/package.json +4 -3
  63. package/esm/carousal/Arrow.js +0 -18
  64. package/esm/carousal/Indicator.js +0 -20
  65. /package/esm/carousal/{types.js → component/types.js} +0 -0
@@ -0,0 +1,698 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
7
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
+ import _JSXStyle from "../styled-jsx.es.js";
9
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
10
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
+ import React, { Children } from 'react';
12
+ // @ts-ignore
13
+ import Swipe from '../../swipe';
14
+ import klass from '../cssClasses';
15
+ import Thumbs from './Thumbs';
16
+ import getDocument from '../shims/document';
17
+ import getWindow from '../shims/window';
18
+ import { noop, defaultStatusFormatter, isKeyboardEvent } from './utils';
19
+ import Arrow from './Arrow';
20
+ import Indicator from './Indicator';
21
+ import { slideAnimationHandler, slideSwipeAnimationHandler, slideStopSwipingHandler, fadeAnimationHandler } from './animations';
22
+ var Carousel = /*#__PURE__*/function (_React$Component) {
23
+ function Carousel(props) {
24
+ var _this;
25
+ _classCallCheck(this, Carousel);
26
+ _this = _callSuper(this, Carousel, [props]);
27
+ _defineProperty(_this, "setThumbsRef", function (node) {
28
+ _this.thumbsRef = node;
29
+ });
30
+ _defineProperty(_this, "setCarouselWrapperRef", function (node) {
31
+ _this.carouselWrapperRef = node;
32
+ });
33
+ _defineProperty(_this, "setListRef", function (node) {
34
+ _this.listRef = node;
35
+ });
36
+ _defineProperty(_this, "setItemsRef", function (node, index) {
37
+ if (!_this.itemsRef) {
38
+ _this.itemsRef = [];
39
+ }
40
+ _this.itemsRef[index] = node;
41
+ });
42
+ _defineProperty(_this, "autoPlay", function () {
43
+ if (Children.count(_this.props.children) <= 1) {
44
+ return;
45
+ }
46
+ _this.clearAutoPlay();
47
+ if (!_this.props.autoPlay) {
48
+ return;
49
+ }
50
+ _this.timer = setTimeout(function () {
51
+ _this.increment();
52
+ }, _this.props.interval);
53
+ });
54
+ _defineProperty(_this, "clearAutoPlay", function () {
55
+ if (_this.timer) clearTimeout(_this.timer);
56
+ });
57
+ _defineProperty(_this, "resetAutoPlay", function () {
58
+ _this.clearAutoPlay();
59
+ _this.autoPlay();
60
+ });
61
+ _defineProperty(_this, "stopOnHover", function () {
62
+ _this.setState({
63
+ isMouseEntered: true
64
+ }, _this.clearAutoPlay);
65
+ });
66
+ _defineProperty(_this, "startOnLeave", function () {
67
+ _this.setState({
68
+ isMouseEntered: false
69
+ }, _this.autoPlay);
70
+ });
71
+ _defineProperty(_this, "isFocusWithinTheCarousel", function () {
72
+ if (!_this.carouselWrapperRef) {
73
+ return false;
74
+ }
75
+ if (getDocument().activeElement === _this.carouselWrapperRef || _this.carouselWrapperRef.contains(getDocument().activeElement)) {
76
+ return true;
77
+ }
78
+ return false;
79
+ });
80
+ _defineProperty(_this, "navigateWithKeyboard", function (e) {
81
+ if (!_this.isFocusWithinTheCarousel()) {
82
+ return;
83
+ }
84
+ var axis = _this.props.axis;
85
+ var isHorizontal = axis === 'horizontal';
86
+ var keyNames = {
87
+ ArrowUp: 38,
88
+ ArrowRight: 39,
89
+ ArrowDown: 40,
90
+ ArrowLeft: 37
91
+ };
92
+ var nextKey = isHorizontal ? keyNames.ArrowRight : keyNames.ArrowDown;
93
+ var prevKey = isHorizontal ? keyNames.ArrowLeft : keyNames.ArrowUp;
94
+ if (nextKey === e.keyCode) {
95
+ _this.increment();
96
+ } else if (prevKey === e.keyCode) {
97
+ _this.decrement();
98
+ }
99
+ });
100
+ _defineProperty(_this, "updateSizes", function () {
101
+ if (!_this.state.initialized || !_this.itemsRef || _this.itemsRef.length === 0) {
102
+ return;
103
+ }
104
+ var isHorizontal = _this.props.axis === 'horizontal';
105
+ var firstItem = _this.itemsRef[0];
106
+ if (!firstItem) {
107
+ return;
108
+ }
109
+ var itemSize = isHorizontal ? firstItem.clientWidth : firstItem.clientHeight;
110
+ _this.setState({
111
+ itemSize: itemSize
112
+ });
113
+ if (_this.thumbsRef) {
114
+ _this.thumbsRef.updateSizes();
115
+ }
116
+ });
117
+ _defineProperty(_this, "setMountState", function () {
118
+ _this.setState({
119
+ hasMount: true
120
+ });
121
+ _this.updateSizes();
122
+ });
123
+ _defineProperty(_this, "handleClickItem", function (index, item) {
124
+ if (Children.count(_this.props.children) === 0) {
125
+ return;
126
+ }
127
+ if (_this.state.cancelClick) {
128
+ _this.setState({
129
+ cancelClick: false
130
+ });
131
+ return;
132
+ }
133
+ _this.props.onClickItem(index, item);
134
+ if (index !== _this.state.selectedItem) {
135
+ _this.setState({
136
+ selectedItem: index
137
+ });
138
+ }
139
+ });
140
+ /**
141
+ * On Change handler, Passes the index and React node to the supplied onChange prop
142
+ * @param index of the carousel item
143
+ * @param item React node of the item being changed
144
+ */
145
+ _defineProperty(_this, "handleOnChange", function (index, item) {
146
+ if (Children.count(_this.props.children) <= 1) {
147
+ return;
148
+ }
149
+ _this.props.onChange(index, item);
150
+ });
151
+ _defineProperty(_this, "handleClickThumb", function (index, item) {
152
+ _this.props.onClickThumb(index, item);
153
+ _this.moveTo(index);
154
+ });
155
+ _defineProperty(_this, "onSwipeStart", function (event) {
156
+ _this.setState({
157
+ swiping: true
158
+ });
159
+ _this.props.onSwipeStart(event);
160
+ });
161
+ _defineProperty(_this, "onSwipeEnd", function (event) {
162
+ _this.setState({
163
+ swiping: false,
164
+ cancelClick: false,
165
+ swipeMovementStarted: false
166
+ });
167
+ _this.props.onSwipeEnd(event);
168
+ _this.clearAutoPlay();
169
+ if (_this.state.autoPlay) {
170
+ _this.autoPlay();
171
+ }
172
+ });
173
+ _defineProperty(_this, "onSwipeMove", function (delta, event) {
174
+ _this.props.onSwipeMove(event);
175
+ var animationHandlerResponse = _this.props.swipeAnimationHandler(delta, _this.props, _this.state, _this.setState.bind(_this));
176
+ _this.setState(_extends({}, animationHandlerResponse));
177
+
178
+ // If we have not moved, we should have an empty object returned
179
+ // Return false to allow scrolling when not swiping
180
+ return !!Object.keys(animationHandlerResponse).length;
181
+ });
182
+ /**
183
+ * Decrements the selectedItem index a number of positions through the children list
184
+ * @param positions
185
+ * @param fromSwipe
186
+ */
187
+ _defineProperty(_this, "decrement", function () {
188
+ var positions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
189
+ _this.moveTo(_this.state.selectedItem - (typeof positions === 'number' ? positions : 1));
190
+ });
191
+ /**
192
+ * Increments the selectedItem index a number of positions through the children list
193
+ * @param positions
194
+ * @param fromSwipe
195
+ */
196
+ _defineProperty(_this, "increment", function () {
197
+ var positions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
198
+ _this.moveTo(_this.state.selectedItem + (typeof positions === 'number' ? positions : 1));
199
+ });
200
+ /**
201
+ * Moves the selected item to the position provided
202
+ * @param position
203
+ * @param fromSwipe
204
+ */
205
+ _defineProperty(_this, "moveTo", function (position) {
206
+ if (typeof position !== 'number') {
207
+ return;
208
+ }
209
+ var lastPosition = Children.count(_this.props.children) - 1;
210
+ if (position < 0) {
211
+ position = _this.props.infiniteLoop ? lastPosition : 0;
212
+ }
213
+ if (position > lastPosition) {
214
+ position = _this.props.infiniteLoop ? 0 : lastPosition;
215
+ }
216
+ _this.selectItem({
217
+ // if it's not a slider, we don't need to set position here
218
+ selectedItem: position
219
+ });
220
+
221
+ // don't reset auto play when stop on hover is enabled, doing so will trigger a call to auto play more than once
222
+ // and will result in the interval function not being cleared correctly.
223
+ if (_this.state.autoPlay && _this.state.isMouseEntered === false) {
224
+ _this.resetAutoPlay();
225
+ }
226
+ });
227
+ _defineProperty(_this, "onClickNext", function () {
228
+ _this.increment(1);
229
+ });
230
+ _defineProperty(_this, "onClickPrev", function () {
231
+ _this.decrement(1);
232
+ });
233
+ _defineProperty(_this, "onSwipeForward", function () {
234
+ _this.increment(1);
235
+ if (_this.props.emulateTouch) {
236
+ _this.setState({
237
+ cancelClick: true
238
+ });
239
+ }
240
+ });
241
+ _defineProperty(_this, "onSwipeBackwards", function () {
242
+ _this.decrement(1);
243
+ if (_this.props.emulateTouch) {
244
+ _this.setState({
245
+ cancelClick: true
246
+ });
247
+ }
248
+ });
249
+ _defineProperty(_this, "changeItem", function (newIndex) {
250
+ return function (e) {
251
+ if (!isKeyboardEvent(e) || e.key === 'Enter') {
252
+ _this.moveTo(newIndex);
253
+ }
254
+ };
255
+ });
256
+ /**
257
+ * This function is called when you want to 'select' a new item, or rather move to a 'selected' item
258
+ * It also handles the onChange callback wrapper
259
+ * @param state state object with updated selected item, and swiping bool if relevant
260
+ */
261
+ _defineProperty(_this, "selectItem", function (state) {
262
+ // Merge in the new state while updating updating previous item
263
+ _this.setState(_extends({
264
+ previousItem: _this.state.selectedItem
265
+ }, state), function () {
266
+ // Run animation handler and update styles based on it
267
+ _this.setState(_this.animationHandler(_this.props, _this.state));
268
+ });
269
+ _this.handleOnChange(state.selectedItem, Children.toArray(_this.props.children)[state.selectedItem]);
270
+ });
271
+ _defineProperty(_this, "getInitialImage", function () {
272
+ var selectedItem = _this.props.selectedItem;
273
+ var item = _this.itemsRef && _this.itemsRef[selectedItem];
274
+ var images = item && item.getElementsByTagName('img') || [];
275
+ return images[0];
276
+ });
277
+ _defineProperty(_this, "getVariableItemHeight", function (position) {
278
+ var item = _this.itemsRef && _this.itemsRef[position];
279
+ if (_this.state.hasMount && item && item.children.length) {
280
+ var slideImages = item.children[0].getElementsByTagName('img') || [];
281
+ if (slideImages.length > 0) {
282
+ var image = slideImages[0];
283
+ if (!image.complete) {
284
+ // if the image is still loading, the size won't be available so we trigger a new render after it's done
285
+ var _onImageLoad = function onImageLoad() {
286
+ _this.forceUpdate();
287
+ image.removeEventListener('load', _onImageLoad);
288
+ };
289
+ image.addEventListener('load', _onImageLoad);
290
+ }
291
+ }
292
+
293
+ // try to get img first, if img not there find first display tag
294
+ var displayItem = slideImages[0] || item.children[0];
295
+ var height = displayItem.clientHeight;
296
+ return height > 0 ? height : null;
297
+ }
298
+ return null;
299
+ });
300
+ var initState = {
301
+ initialized: false,
302
+ previousItem: props.selectedItem,
303
+ selectedItem: props.selectedItem,
304
+ hasMount: false,
305
+ isMouseEntered: false,
306
+ autoPlay: props.autoPlay,
307
+ swiping: false,
308
+ swipeMovementStarted: false,
309
+ cancelClick: false,
310
+ itemSize: 1,
311
+ itemListStyle: {},
312
+ slideStyle: {},
313
+ selectedStyle: {},
314
+ prevStyle: {}
315
+ };
316
+ _this.animationHandler = typeof props.animationHandler === 'function' && props.animationHandler || props.animationHandler === 'fade' && fadeAnimationHandler || slideAnimationHandler;
317
+ _this.state = _extends({}, initState, _this.animationHandler(props, initState));
318
+ return _this;
319
+ }
320
+ _inherits(Carousel, _React$Component);
321
+ return _createClass(Carousel, [{
322
+ key: "componentDidMount",
323
+ value: function componentDidMount() {
324
+ if (!this.props.children) {
325
+ return;
326
+ }
327
+ this.setupCarousel();
328
+ }
329
+ }, {
330
+ key: "componentDidUpdate",
331
+ value: function componentDidUpdate(prevProps, prevState) {
332
+ if (!prevProps.children && this.props.children && !this.state.initialized) {
333
+ this.setupCarousel();
334
+ }
335
+ if (!prevProps.autoFocus && this.props.autoFocus) {
336
+ this.forceFocus();
337
+ }
338
+ if (prevState.swiping && !this.state.swiping) {
339
+ // We stopped swiping, ensure we are heading to the new/current slide and not stuck
340
+
341
+ this.setState(_extends({}, this.props.stopSwipingHandler(this.props, this.state)));
342
+ }
343
+ if (prevProps.selectedItem !== this.props.selectedItem || prevProps.centerMode !== this.props.centerMode) {
344
+ this.updateSizes();
345
+ this.moveTo(this.props.selectedItem);
346
+ }
347
+ if (prevProps.autoPlay !== this.props.autoPlay) {
348
+ if (this.props.autoPlay) {
349
+ this.setupAutoPlay();
350
+ } else {
351
+ this.destroyAutoPlay();
352
+ }
353
+ this.setState({
354
+ autoPlay: this.props.autoPlay
355
+ });
356
+ }
357
+ }
358
+ }, {
359
+ key: "componentWillUnmount",
360
+ value: function componentWillUnmount() {
361
+ this.destroyCarousel();
362
+ }
363
+ }, {
364
+ key: "setupCarousel",
365
+ value: function setupCarousel() {
366
+ var _this2 = this;
367
+ this.bindEvents();
368
+ if (this.state.autoPlay && Children.count(this.props.children) > 1) {
369
+ this.setupAutoPlay();
370
+ }
371
+ if (this.props.autoFocus) {
372
+ this.forceFocus();
373
+ }
374
+ this.setState({
375
+ initialized: true
376
+ }, function () {
377
+ var initialImage = _this2.getInitialImage();
378
+ if (initialImage && !initialImage.complete) {
379
+ // if it's a carousel of images, we set the mount state after the first image is loaded
380
+ initialImage.addEventListener('load', _this2.setMountState);
381
+ } else {
382
+ _this2.setMountState();
383
+ }
384
+ });
385
+ }
386
+ }, {
387
+ key: "destroyCarousel",
388
+ value: function destroyCarousel() {
389
+ if (this.state.initialized) {
390
+ this.unbindEvents();
391
+ this.destroyAutoPlay();
392
+ }
393
+ }
394
+ }, {
395
+ key: "setupAutoPlay",
396
+ value: function setupAutoPlay() {
397
+ this.autoPlay();
398
+ var carouselWrapper = this.carouselWrapperRef;
399
+ if (this.props.stopOnHover && carouselWrapper) {
400
+ carouselWrapper.addEventListener('mouseenter', this.stopOnHover);
401
+ carouselWrapper.addEventListener('mouseleave', this.startOnLeave);
402
+ }
403
+ }
404
+ }, {
405
+ key: "destroyAutoPlay",
406
+ value: function destroyAutoPlay() {
407
+ this.clearAutoPlay();
408
+ var carouselWrapper = this.carouselWrapperRef;
409
+ if (this.props.stopOnHover && carouselWrapper) {
410
+ carouselWrapper.removeEventListener('mouseenter', this.stopOnHover);
411
+ carouselWrapper.removeEventListener('mouseleave', this.startOnLeave);
412
+ }
413
+ }
414
+ }, {
415
+ key: "bindEvents",
416
+ value: function bindEvents() {
417
+ // as the widths are calculated, we need to resize
418
+ // the carousel when the window is resized
419
+ getWindow().addEventListener('resize', this.updateSizes);
420
+ // issue #2 - image loading smaller
421
+ getWindow().addEventListener('DOMContentLoaded', this.updateSizes);
422
+ if (this.props.useKeyboardArrows) {
423
+ getDocument().addEventListener('keydown', this.navigateWithKeyboard);
424
+ }
425
+ }
426
+ }, {
427
+ key: "unbindEvents",
428
+ value: function unbindEvents() {
429
+ // removing listeners
430
+ getWindow().removeEventListener('resize', this.updateSizes);
431
+ getWindow().removeEventListener('DOMContentLoaded', this.updateSizes);
432
+ var initialImage = this.getInitialImage();
433
+ if (initialImage) {
434
+ initialImage.removeEventListener('load', this.setMountState);
435
+ }
436
+ if (this.props.useKeyboardArrows) {
437
+ getDocument().removeEventListener('keydown', this.navigateWithKeyboard);
438
+ }
439
+ }
440
+ }, {
441
+ key: "forceFocus",
442
+ value: function forceFocus() {
443
+ var _this$carouselWrapper;
444
+ (_this$carouselWrapper = this.carouselWrapperRef) === null || _this$carouselWrapper === void 0 || _this$carouselWrapper.focus();
445
+ }
446
+ }, {
447
+ key: "renderItems",
448
+ value: function renderItems(isClone) {
449
+ var _this3 = this;
450
+ if (!this.props.children) {
451
+ return [];
452
+ }
453
+ return Children.map(this.props.children, function (item, index) {
454
+ var isSelected = index === _this3.state.selectedItem;
455
+ var isPrevious = index === _this3.state.previousItem;
456
+ var style = isSelected && _this3.state.selectedStyle || isPrevious && _this3.state.prevStyle || _this3.state.slideStyle || {};
457
+ if (_this3.props.centerMode && _this3.props.axis === 'horizontal') {
458
+ style = _extends({}, style, {
459
+ minWidth: _this3.props.centerSlidePercentage + '%'
460
+ });
461
+ }
462
+ if (_this3.state.swiping && _this3.state.swipeMovementStarted) {
463
+ style = _extends({}, style, {
464
+ pointerEvents: 'none'
465
+ });
466
+ }
467
+ var slideProps = {
468
+ ref: function ref(e) {
469
+ return _this3.setItemsRef(e, index);
470
+ },
471
+ key: 'itemKey' + index + (isClone ? 'clone' : ''),
472
+ className: klass.ITEM(true, index === _this3.state.selectedItem, index === _this3.state.previousItem),
473
+ onClick: _this3.handleClickItem.bind(_this3, index, item),
474
+ style: style
475
+ };
476
+ return /*#__PURE__*/React.createElement("li", _extends({}, slideProps, {
477
+ className: "jsx-2755164558" + " " + (slideProps && slideProps.className != null && slideProps.className || "")
478
+ }), _this3.props.renderItem(item, {
479
+ isSelected: index === _this3.state.selectedItem,
480
+ isPrevious: index === _this3.state.previousItem
481
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
482
+ id: "2755164558"
483
+ }, ".slide.jsx-2755164558{min-width:100%;margin:0;position:relative;text-align:center;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}img.jsx-2755164558{width:100%;vertical-align:top;border:0;}iframe.jsx-2755164558{display:inline-block;width:calc(100% - 80px);margin:0 40px 40px;border:0;}.legend.jsx-2755164558{-webkit-transition:opacity 0.35s ease-in-out;transition:opacity 0.35s ease-in-out;position:absolute;bottom:40px;left:50%;margin-left:-45%;width:90%;border-radius:10px;background:#000;color:#fff;padding:10px;font-size:12px;text-align:center;opacity:0.25;}.slide.jsx-2755164558 .legend.jsx-2755164558{opacity:1;}"));
484
+ });
485
+ }
486
+ }, {
487
+ key: "renderControls",
488
+ value: function renderControls() {
489
+ var _this4 = this;
490
+ var _this$props = this.props,
491
+ showIndicators = _this$props.showIndicators,
492
+ labels = _this$props.labels,
493
+ renderIndicator = _this$props.renderIndicator,
494
+ children = _this$props.children;
495
+ if (!showIndicators) {
496
+ return null;
497
+ }
498
+ return /*#__PURE__*/React.createElement("ul", {
499
+ className: "jsx-4140983776" + " " + "control-dots"
500
+ }, Children.map(children, function (_, index) {
501
+ return renderIndicator && renderIndicator(_this4.changeItem(index), index === _this4.state.selectedItem, index, labels.item);
502
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
503
+ id: "4140983776"
504
+ }, ".control-dots.jsx-4140983776{position:absolute;bottom:0;margin:10px 0;padding:0;text-align:center;width:100%;z-index:1;}"));
505
+ }
506
+ }, {
507
+ key: "renderStatus",
508
+ value: function renderStatus() {
509
+ if (!this.props.showStatus) {
510
+ return null;
511
+ }
512
+ return /*#__PURE__*/React.createElement("p", {
513
+ className: "jsx-2959489890" + " " + "carousel-status"
514
+ }, this.props.statusFormatter(this.state.selectedItem + 1, Children.count(this.props.children)), /*#__PURE__*/React.createElement(_JSXStyle, {
515
+ id: "2959489890"
516
+ }, ".carousel-status.jsx-2959489890{position:absolute;top:0;right:0;padding:5px;font-size:10px;text-shadow:1px 1px 1px rgba(0,0,0,0.9);color:#fff;}"));
517
+ }
518
+ }, {
519
+ key: "renderThumbs",
520
+ value: function renderThumbs() {
521
+ if (!this.props.showThumbs || !this.props.children || Children.count(this.props.children) === 0) {
522
+ return null;
523
+ }
524
+ return /*#__PURE__*/React.createElement(Thumbs, {
525
+ ref: this.setThumbsRef,
526
+ onSelectItem: this.handleClickThumb,
527
+ selectedItem: this.state.selectedItem,
528
+ transitionTime: this.props.transitionTime,
529
+ thumbWidth: this.props.thumbWidth,
530
+ labels: this.props.labels,
531
+ emulateTouch: this.props.emulateTouch
532
+ }, this.props.renderThumbs(this.props.children));
533
+ }
534
+ }, {
535
+ key: "render",
536
+ value: function render() {
537
+ var _this5 = this;
538
+ if (!this.props.children || Children.count(this.props.children) === 0) {
539
+ return null;
540
+ }
541
+ var isSwipeable = this.props.swipeable && Children.count(this.props.children) > 1;
542
+ var isHorizontal = this.props.axis === 'horizontal';
543
+ var canShowArrows = this.props.showArrows && Children.count(this.props.children) > 1;
544
+
545
+ // show left arrow?
546
+ var hasPrev = canShowArrows && (this.state.selectedItem > 0 || this.props.infiniteLoop) || false;
547
+ // show right arrow
548
+ var hasNext = canShowArrows && (this.state.selectedItem < Children.count(this.props.children) - 1 || this.props.infiniteLoop) || false;
549
+ var itemsClone = this.renderItems(true);
550
+ var firstClone = itemsClone.shift();
551
+ var lastClone = itemsClone.pop();
552
+ var swiperProps = {
553
+ className: klass.SLIDER(true, this.state.swiping),
554
+ onSwipeMove: this.onSwipeMove,
555
+ onSwipeStart: this.onSwipeStart,
556
+ onSwipeEnd: this.onSwipeEnd,
557
+ style: _extends({
558
+ margin: 0,
559
+ display: this.props.axis === 'horizontal' ? 'flex' : 'unset',
560
+ flexDirection: this.props.axis === 'horizontal' ? 'row' : 'column'
561
+ }, this.state.itemListStyle),
562
+ tolerance: this.props.swipeScrollTolerance
563
+ };
564
+ var containerStyles = {};
565
+ if (isHorizontal) {
566
+ swiperProps.onSwipeLeft = this.onSwipeForward;
567
+ swiperProps.onSwipeRight = this.onSwipeBackwards;
568
+ if (this.props.dynamicHeight) {
569
+ var itemHeight = this.getVariableItemHeight(this.state.selectedItem);
570
+ // swiperProps.style.height = itemHeight || 'auto';
571
+ containerStyles.height = itemHeight || 'auto';
572
+ }
573
+ } else {
574
+ swiperProps.onSwipeUp = this.props.verticalSwipe === 'natural' ? this.onSwipeBackwards : this.onSwipeForward;
575
+ swiperProps.onSwipeDown = this.props.verticalSwipe === 'natural' ? this.onSwipeForward : this.onSwipeBackwards;
576
+ swiperProps.style = _extends({}, swiperProps.style, {
577
+ height: this.state.itemSize
578
+ });
579
+ containerStyles.height = this.state.itemSize;
580
+ }
581
+ return /*#__PURE__*/React.createElement("div", {
582
+ "aria-label": this.props.ariaLabel,
583
+ ref: this.setCarouselWrapperRef,
584
+ tabIndex: this.props.useKeyboardArrows ? 0 : undefined,
585
+ className: "jsx-535322850" + " " + (klass.ROOT(this.props.className) || "")
586
+ }, /*#__PURE__*/React.createElement("div", {
587
+ style: {
588
+ width: this.props.width
589
+ },
590
+ className: "jsx-535322850" + " " + (klass.CAROUSEL(true) || "")
591
+ }, this.renderControls(), this.props.renderArrowPrev(this.onClickPrev, hasPrev, this.props.labels.leftArrow), /*#__PURE__*/React.createElement("div", {
592
+ style: containerStyles,
593
+ className: "jsx-535322850" + " " + (klass.WRAPPER(true, this.props.axis) || "")
594
+ }, isSwipeable ? /*#__PURE__*/React.createElement(Swipe, _extends({
595
+ tagName: "ul",
596
+ innerRef: this.setListRef
597
+ }, swiperProps, {
598
+ allowMouseEvents: this.props.emulateTouch
599
+ }), this.props.infiniteLoop && lastClone, this.renderItems(), this.props.infiniteLoop && firstClone) : /*#__PURE__*/React.createElement("ul", {
600
+ ref: function ref(node) {
601
+ return _this5.setListRef(node);
602
+ },
603
+ style: this.state.itemListStyle || {},
604
+ className: "jsx-535322850" + " " + (klass.SLIDER(true, this.state.swiping) || "")
605
+ }, this.props.infiniteLoop && lastClone, this.renderItems(), this.props.infiniteLoop && firstClone)), this.props.renderArrowNext(this.onClickNext, hasNext, this.props.labels.rightArrow), this.renderStatus()), this.renderThumbs(), /*#__PURE__*/React.createElement(_JSXStyle, {
606
+ id: "535322850"
607
+ }, ".carousel-root.jsx-535322850{outline:none;}.slider.jsx-535322850{margin:0 !important;padding:0;position:relative;list-style:none;width:100%;}.slider.jsx-535322850 .animated.jsx-535322850{-webkit-transition:all 0.35s ease-in-out;transition:all 0.35s ease-in-out;}.carousel.jsx-535322850{position:relative;width:100%;}.carousel.jsx-535322850 img.jsx-535322850{width:100%;display:inline-block;pointer-events:none;}.carousel.jsx-535322850 .carousel.jsx-535322850{position:relative;}.carousel-slider.jsx-535322850{position:relative;margin:0;overflow:hidden;}.slider-wrapper.jsx-535322850{overflow:hidden;margin:auto;width:100%;-webkit-transition:height 0.15s ease-in;transition:height 0.15s ease-in;}"));
608
+ }
609
+ }]);
610
+ }(React.Component);
611
+ // @ts-ignore
612
+ _defineProperty(Carousel, "displayName", 'Carousel');
613
+ _defineProperty(Carousel, "defaultProps", {
614
+ ariaLabel: undefined,
615
+ axis: 'horizontal',
616
+ centerSlidePercentage: 80,
617
+ interval: 3000,
618
+ labels: {
619
+ leftArrow: 'previous slide / item',
620
+ rightArrow: 'next slide / item',
621
+ item: 'slide item'
622
+ },
623
+ onClickItem: noop,
624
+ onClickThumb: noop,
625
+ onChange: noop,
626
+ onSwipeStart: function onSwipeStart() {},
627
+ onSwipeEnd: function onSwipeEnd() {},
628
+ onSwipeMove: function onSwipeMove() {
629
+ return false;
630
+ },
631
+ preventMovementUntilSwipeScrollTolerance: false,
632
+ renderArrowPrev: function renderArrowPrev(onClickHandler, hasPrev, label) {
633
+ return /*#__PURE__*/React.createElement(Arrow, {
634
+ direction: "prev",
635
+ onClickHandler: onClickHandler,
636
+ enabled: hasPrev,
637
+ label: label
638
+ });
639
+ },
640
+ renderArrowNext: function renderArrowNext(onClickHandler, hasNext, label) {
641
+ return /*#__PURE__*/React.createElement(Arrow, {
642
+ direction: "next",
643
+ onClickHandler: onClickHandler,
644
+ enabled: hasNext,
645
+ label: label
646
+ });
647
+ },
648
+ renderIndicator: function renderIndicator(onClickHandler, isSelected, index, label) {
649
+ return /*#__PURE__*/React.createElement(Indicator, {
650
+ onClickHandler: onClickHandler,
651
+ isSelected: isSelected,
652
+ index: index,
653
+ label: label
654
+ });
655
+ },
656
+ renderItem: function renderItem(item) {
657
+ return item;
658
+ },
659
+ renderThumbs: function renderThumbs(children) {
660
+ var images = Children.map(children, function (item) {
661
+ var img = item;
662
+
663
+ // if the item is not an image, try to find the first image in the item's children.
664
+ if (item.type !== 'img') {
665
+ img = Children.toArray(item.props.children).find(function (children) {
666
+ return children.type === 'img';
667
+ });
668
+ }
669
+ if (!img) {
670
+ return undefined;
671
+ }
672
+ return img;
673
+ });
674
+ if (images.filter(function (image) {
675
+ return image;
676
+ }).length === 0) {
677
+ console.warn("No images found! Can't build the thumb list without images. If you don't need thumbs, set showThumbs={false} in the Carousel. Note that it's not possible to get images rendered inside custom components. More info at https://github.com/leandrowd/react-responsive-carousel/blob/master/TROUBLESHOOTING.md");
678
+ return [];
679
+ }
680
+ return images;
681
+ },
682
+ statusFormatter: defaultStatusFormatter,
683
+ selectedItem: 0,
684
+ showArrows: true,
685
+ showIndicators: true,
686
+ showStatus: true,
687
+ showThumbs: true,
688
+ stopOnHover: true,
689
+ swipeScrollTolerance: 5,
690
+ swipeable: true,
691
+ transitionTime: 350,
692
+ verticalSwipe: 'standard',
693
+ width: '100%',
694
+ animationHandler: 'slide',
695
+ swipeAnimationHandler: slideSwipeAnimationHandler,
696
+ stopSwipingHandler: slideStopSwipingHandler
697
+ });
698
+ export { Carousel as default };