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