@helpdice/ui 1.7.5 → 1.7.8
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
package/esm/button/button.js
CHANGED
|
@@ -7,13 +7,12 @@ import _JSXStyle from "../styled-jsx.es.js";
|
|
|
7
7
|
|
|
8
8
|
import React, { useRef, useState, useMemo, useImperativeHandle } from 'react';
|
|
9
9
|
import useScale, { withScale } from '../use-scale';
|
|
10
|
-
import useTheme from '
|
|
10
|
+
import { useTheme, useClasses } from '@helpdice/theme';
|
|
11
11
|
import ButtonDrip from './button.drip';
|
|
12
12
|
import ButtonLoading from './button-loading';
|
|
13
13
|
import { filterPropsWithGroup, getButtonChildrenWithIcon } from './utils';
|
|
14
14
|
import { useButtonGroupContext } from '../button-group/button-group-context';
|
|
15
15
|
import { getButtonColors, getButtonCursor, getButtonDripColor, getButtonHoverColors } from './styles';
|
|
16
|
-
import useClasses from '../use-classes';
|
|
17
16
|
var ButtonComponent = /*#__PURE__*/React.forwardRef(function (btnProps, ref) {
|
|
18
17
|
var theme = useTheme();
|
|
19
18
|
var _useScale = useScale(),
|
package/esm/button/utils.js
CHANGED
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _JSXStyle from "../styled-jsx.es.js";
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import ButtonIcon from './button-icon';
|
|
5
|
-
import useClasses from '
|
|
5
|
+
import { useClasses } from '@helpdice/theme';
|
|
6
6
|
export var getButtonChildrenWithIcon = function getButtonChildrenWithIcon(auto, children, icons) {
|
|
7
7
|
var icon = icons.icon,
|
|
8
8
|
iconRight = icons.iconRight;
|
|
@@ -5,7 +5,7 @@ import _JSXStyle from "../styled-jsx.es.js";
|
|
|
5
5
|
/* "use client" */
|
|
6
6
|
|
|
7
7
|
import React, { useMemo } from 'react';
|
|
8
|
-
import useTheme from '
|
|
8
|
+
import { useTheme } from '@helpdice/theme';
|
|
9
9
|
import { getColor } from './styles';
|
|
10
10
|
import { useButtonDropdown } from './button-dropdown-context';
|
|
11
11
|
import Loading from '../loading';
|
|
@@ -6,7 +6,7 @@ import _JSXStyle from "../styled-jsx.es.js";
|
|
|
6
6
|
/* "use client" */
|
|
7
7
|
|
|
8
8
|
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
9
|
-
import useTheme from '
|
|
9
|
+
import { useTheme, useClasses } from '@helpdice/theme';
|
|
10
10
|
import useClickAway from '../utils/use-click-away';
|
|
11
11
|
import { getColor } from './styles';
|
|
12
12
|
import ButtonDropdownIcon from './icon';
|
|
@@ -14,7 +14,6 @@ import ButtonDropdownItem from './button-dropdown-item';
|
|
|
14
14
|
import { ButtonDropdownContext } from './button-dropdown-context';
|
|
15
15
|
import { pickChild, pickChildByProps } from '../utils/collections';
|
|
16
16
|
import useScale, { withScale } from '../use-scale';
|
|
17
|
-
import useClasses from '../use-classes';
|
|
18
17
|
var stopPropagation = function stopPropagation(event) {
|
|
19
18
|
event.stopPropagation();
|
|
20
19
|
event.nativeEvent.stopImmediatePropagation();
|
|
@@ -3,10 +3,9 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
3
3
|
var _excluded = ["disabled", "type", "ghost", "vertical", "children", "className"];
|
|
4
4
|
import _JSXStyle from "../styled-jsx.es.js";
|
|
5
5
|
import React, { useMemo } from 'react';
|
|
6
|
-
import useTheme from '
|
|
6
|
+
import { useTheme, useClasses } from '@helpdice/theme';
|
|
7
7
|
import { ButtonGroupContext } from './button-group-context';
|
|
8
8
|
import useScale, { withScale } from '../use-scale';
|
|
9
|
-
import useClasses from '../use-classes';
|
|
10
9
|
var getGroupBorderColors = function getGroupBorderColors(palette, props) {
|
|
11
10
|
var _props$ghost = props.ghost,
|
|
12
11
|
ghost = _props$ghost === void 0 ? false : _props$ghost,
|
package/esm/capacity/capacity.js
CHANGED
|
@@ -3,10 +3,9 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
3
3
|
var _excluded = ["value", "limit", "color", "className"];
|
|
4
4
|
import _JSXStyle from "../styled-jsx.es.js";
|
|
5
5
|
import React, { useMemo } from 'react';
|
|
6
|
-
import useTheme from '
|
|
6
|
+
import { useTheme, useClasses } from '@helpdice/theme';
|
|
7
7
|
import { useProportions } from '../utils/calculations';
|
|
8
8
|
import useScale, { withScale } from '../use-scale';
|
|
9
|
-
import useClasses from '../use-classes';
|
|
10
9
|
var getColor = function getColor(val, palette) {
|
|
11
10
|
if (val < 33) return palette.cyan;
|
|
12
11
|
if (val < 66) return palette.warning;
|
package/esm/card/card-content.js
CHANGED
|
@@ -4,7 +4,7 @@ var _excluded = ["className", "children"];
|
|
|
4
4
|
import _JSXStyle from "../styled-jsx.es.js";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import useScale, { withScale } from '../use-scale';
|
|
7
|
-
import useClasses from '
|
|
7
|
+
import { useClasses } from '@helpdice/theme';
|
|
8
8
|
var CardContentComponent = function CardContentComponent(_ref) {
|
|
9
9
|
var _ref$className = _ref.className,
|
|
10
10
|
className = _ref$className === void 0 ? '' : _ref$className,
|
package/esm/card/card-footer.js
CHANGED
|
@@ -3,9 +3,8 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
3
3
|
var _excluded = ["children", "className", "disableAutoMargin"];
|
|
4
4
|
import _JSXStyle from "../styled-jsx.es.js";
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import useTheme from '
|
|
6
|
+
import { useTheme, useClasses } from '@helpdice/theme';
|
|
7
7
|
import useScale, { withScale } from '../use-scale';
|
|
8
|
-
import useClasses from '../use-classes';
|
|
9
8
|
var CardFooterComponent = function CardFooterComponent(_ref) {
|
|
10
9
|
var children = _ref.children,
|
|
11
10
|
_ref$className = _ref.className,
|
package/esm/card/card.js
CHANGED
|
@@ -4,14 +4,13 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
4
4
|
var _excluded = ["children", "hoverable", "className", "shadow", "type"];
|
|
5
5
|
import _JSXStyle from "../styled-jsx.es.js";
|
|
6
6
|
import React, { useMemo } from 'react';
|
|
7
|
-
import useTheme from '
|
|
7
|
+
import { useTheme, useClasses } from '@helpdice/theme';
|
|
8
8
|
import { getStyles } from './styles';
|
|
9
9
|
import CardFooter from './card-footer';
|
|
10
10
|
import CardContent from './card-content';
|
|
11
11
|
import Image from '../image';
|
|
12
12
|
import { hasChild, pickChild } from '../utils/collections';
|
|
13
13
|
import useScale, { withScale } from '../use-scale';
|
|
14
|
-
import useClasses from '../use-classes';
|
|
15
14
|
var CardComponent = function CardComponent(_ref) {
|
|
16
15
|
var children = _ref.children,
|
|
17
16
|
_ref$hoverable = _ref.hoverable,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import klass from '../../cssClasses'; // Assuming cssClasses.ts is in src/
|
|
3
|
+
|
|
4
|
+
var Arrow = function Arrow(_ref) {
|
|
5
|
+
var direction = _ref.direction,
|
|
6
|
+
onClickHandler = _ref.onClickHandler,
|
|
7
|
+
enabled = _ref.enabled,
|
|
8
|
+
label = _ref.label;
|
|
9
|
+
var isPrev = direction === 'prev';
|
|
10
|
+
var arrowClassName = isPrev ? klass.ARROW_PREV(!enabled) : klass.ARROW_NEXT(!enabled);
|
|
11
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
12
|
+
type: "button",
|
|
13
|
+
"aria-label": label,
|
|
14
|
+
className: arrowClassName,
|
|
15
|
+
onClick: onClickHandler
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export default Arrow;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import klass from '../../cssClasses'; // Assuming cssClasses.ts is in src/
|
|
3
|
+
|
|
4
|
+
var Indicator = function Indicator(_ref) {
|
|
5
|
+
var onClickHandler = _ref.onClickHandler,
|
|
6
|
+
isSelected = _ref.isSelected,
|
|
7
|
+
index = _ref.index,
|
|
8
|
+
label = _ref.label;
|
|
9
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
10
|
+
className: klass.DOT(isSelected),
|
|
11
|
+
onClick: onClickHandler,
|
|
12
|
+
onKeyDown: onClickHandler,
|
|
13
|
+
value: index,
|
|
14
|
+
key: index,
|
|
15
|
+
role: "button",
|
|
16
|
+
tabIndex: 0,
|
|
17
|
+
"aria-label": "".concat(label, " ").concat(index + 1)
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
export default Indicator;
|
|
@@ -0,0 +1,302 @@
|
|
|
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, { Component, Children } from 'react';
|
|
11
|
+
import klass from '../cssClasses';
|
|
12
|
+
import { outerWidth } from '../dimensions';
|
|
13
|
+
import CSSTranslate from '../CSSTranslate';
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
import Swipe from 'react-easy-swipe';
|
|
16
|
+
import getWindow from '../shims/window';
|
|
17
|
+
var isKeyboardEvent = function isKeyboardEvent(e) {
|
|
18
|
+
return e.hasOwnProperty('key');
|
|
19
|
+
};
|
|
20
|
+
var Thumbs = /*#__PURE__*/function (_Component) {
|
|
21
|
+
function Thumbs(_props) {
|
|
22
|
+
var _this;
|
|
23
|
+
_classCallCheck(this, Thumbs);
|
|
24
|
+
_this = _callSuper(this, Thumbs, [_props]);
|
|
25
|
+
_defineProperty(_this, "setItemsWrapperRef", function (node) {
|
|
26
|
+
_this.itemsWrapperRef = node;
|
|
27
|
+
});
|
|
28
|
+
_defineProperty(_this, "setItemsListRef", function (node) {
|
|
29
|
+
_this.itemsListRef = node;
|
|
30
|
+
});
|
|
31
|
+
_defineProperty(_this, "setThumbsRef", function (node, index) {
|
|
32
|
+
if (!_this.thumbsRef) {
|
|
33
|
+
_this.thumbsRef = [];
|
|
34
|
+
}
|
|
35
|
+
_this.thumbsRef[index] = node;
|
|
36
|
+
});
|
|
37
|
+
_defineProperty(_this, "updateSizes", function () {
|
|
38
|
+
if (!_this.props.children || !_this.itemsWrapperRef || !_this.thumbsRef) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
var total = Children.count(_this.props.children);
|
|
42
|
+
var wrapperSize = _this.itemsWrapperRef.clientWidth;
|
|
43
|
+
var itemSize = _this.props.thumbWidth ? _this.props.thumbWidth : outerWidth(_this.thumbsRef[0]);
|
|
44
|
+
var visibleItems = Math.floor(wrapperSize / itemSize);
|
|
45
|
+
var showArrows = visibleItems < total;
|
|
46
|
+
var lastPosition = showArrows ? total - visibleItems : 0;
|
|
47
|
+
_this.setState(function (_state, props) {
|
|
48
|
+
return {
|
|
49
|
+
itemSize: itemSize,
|
|
50
|
+
visibleItems: visibleItems,
|
|
51
|
+
firstItem: showArrows ? _this.getFirstItem(props.selectedItem) : 0,
|
|
52
|
+
lastPosition: lastPosition,
|
|
53
|
+
showArrows: showArrows
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
_defineProperty(_this, "handleClickItem", function (index, item, e) {
|
|
58
|
+
if (!isKeyboardEvent(e) || e.key === 'Enter') {
|
|
59
|
+
var handler = _this.props.onSelectItem;
|
|
60
|
+
if (typeof handler === 'function') {
|
|
61
|
+
handler(index, item);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
_defineProperty(_this, "onSwipeStart", function () {
|
|
66
|
+
_this.setState({
|
|
67
|
+
swiping: true
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
_defineProperty(_this, "onSwipeEnd", function () {
|
|
71
|
+
_this.setState({
|
|
72
|
+
swiping: false
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
_defineProperty(_this, "onSwipeMove", function (delta) {
|
|
76
|
+
var deltaX = delta.x;
|
|
77
|
+
if (!_this.state.itemSize || !_this.itemsWrapperRef || !_this.state.visibleItems) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
var leftBoundary = 0;
|
|
81
|
+
var childrenLength = Children.count(_this.props.children);
|
|
82
|
+
var currentPosition = -(_this.state.firstItem * 100) / _this.state.visibleItems;
|
|
83
|
+
var lastLeftItem = Math.max(childrenLength - _this.state.visibleItems, 0);
|
|
84
|
+
var lastLeftBoundary = -lastLeftItem * 100 / _this.state.visibleItems;
|
|
85
|
+
|
|
86
|
+
// prevent user from swiping left out of boundaries
|
|
87
|
+
if (currentPosition === leftBoundary && deltaX > 0) {
|
|
88
|
+
deltaX = 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// prevent user from swiping right out of boundaries
|
|
92
|
+
if (currentPosition === lastLeftBoundary && deltaX < 0) {
|
|
93
|
+
deltaX = 0;
|
|
94
|
+
}
|
|
95
|
+
var wrapperSize = _this.itemsWrapperRef.clientWidth;
|
|
96
|
+
var position = currentPosition + 100 / (wrapperSize / deltaX);
|
|
97
|
+
// if 3d isn't available we will use left to move
|
|
98
|
+
if (_this.itemsListRef) {
|
|
99
|
+
['WebkitTransform', 'MozTransform', 'MsTransform', 'OTransform', 'transform', 'msTransform'].forEach(function (prop) {
|
|
100
|
+
_this.itemsListRef.style[prop] = CSSTranslate(position, '%', _this.props.axis);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
});
|
|
105
|
+
_defineProperty(_this, "slideRight", function (positions) {
|
|
106
|
+
_this.moveTo(_this.state.firstItem - (typeof positions === 'number' ? positions : 1));
|
|
107
|
+
});
|
|
108
|
+
_defineProperty(_this, "slideLeft", function (positions) {
|
|
109
|
+
_this.moveTo(_this.state.firstItem + (typeof positions === 'number' ? positions : 1));
|
|
110
|
+
});
|
|
111
|
+
_defineProperty(_this, "moveTo", function (position) {
|
|
112
|
+
// position can't be lower than 0
|
|
113
|
+
position = position < 0 ? 0 : position;
|
|
114
|
+
// position can't be higher than last postion
|
|
115
|
+
position = position >= _this.state.lastPosition ? _this.state.lastPosition : position;
|
|
116
|
+
_this.setState({
|
|
117
|
+
firstItem: position
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
_this.state = {
|
|
121
|
+
selectedItem: _props.selectedItem,
|
|
122
|
+
swiping: false,
|
|
123
|
+
showArrows: false,
|
|
124
|
+
firstItem: 0,
|
|
125
|
+
visibleItems: 0,
|
|
126
|
+
lastPosition: 0
|
|
127
|
+
};
|
|
128
|
+
return _this;
|
|
129
|
+
}
|
|
130
|
+
_inherits(Thumbs, _Component);
|
|
131
|
+
return _createClass(Thumbs, [{
|
|
132
|
+
key: "componentDidMount",
|
|
133
|
+
value: function componentDidMount() {
|
|
134
|
+
this.setupThumbs();
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
key: "componentDidUpdate",
|
|
138
|
+
value: function componentDidUpdate(prevProps) {
|
|
139
|
+
if (this.props.selectedItem !== this.state.selectedItem) {
|
|
140
|
+
this.setState({
|
|
141
|
+
selectedItem: this.props.selectedItem,
|
|
142
|
+
firstItem: this.getFirstItem(this.props.selectedItem)
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if (this.props.children === prevProps.children) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// This will capture any size changes for arrow adjustments etc.
|
|
150
|
+
// usually in the same render cycle so we don't see any flickers
|
|
151
|
+
this.updateSizes();
|
|
152
|
+
}
|
|
153
|
+
}, {
|
|
154
|
+
key: "componentWillUnmount",
|
|
155
|
+
value: function componentWillUnmount() {
|
|
156
|
+
this.destroyThumbs();
|
|
157
|
+
}
|
|
158
|
+
}, {
|
|
159
|
+
key: "setupThumbs",
|
|
160
|
+
value: function setupThumbs() {
|
|
161
|
+
// as the widths are calculated, we need to resize
|
|
162
|
+
// the carousel when the window is resized
|
|
163
|
+
getWindow().addEventListener('resize', this.updateSizes);
|
|
164
|
+
// issue #2 - image loading smaller
|
|
165
|
+
getWindow().addEventListener('DOMContentLoaded', this.updateSizes);
|
|
166
|
+
|
|
167
|
+
// when the component is rendered we need to calculate
|
|
168
|
+
// the container size to adjust the responsive behaviour
|
|
169
|
+
this.updateSizes();
|
|
170
|
+
}
|
|
171
|
+
}, {
|
|
172
|
+
key: "destroyThumbs",
|
|
173
|
+
value: function destroyThumbs() {
|
|
174
|
+
// removing listeners
|
|
175
|
+
getWindow().removeEventListener('resize', this.updateSizes);
|
|
176
|
+
getWindow().removeEventListener('DOMContentLoaded', this.updateSizes);
|
|
177
|
+
}
|
|
178
|
+
}, {
|
|
179
|
+
key: "getFirstItem",
|
|
180
|
+
value: function getFirstItem(selectedItem) {
|
|
181
|
+
var firstItem = selectedItem;
|
|
182
|
+
if (selectedItem >= this.state.lastPosition) {
|
|
183
|
+
firstItem = this.state.lastPosition;
|
|
184
|
+
}
|
|
185
|
+
if (selectedItem < this.state.firstItem + this.state.visibleItems) {
|
|
186
|
+
firstItem = this.state.firstItem;
|
|
187
|
+
}
|
|
188
|
+
if (selectedItem < this.state.firstItem) {
|
|
189
|
+
firstItem = selectedItem;
|
|
190
|
+
}
|
|
191
|
+
return firstItem;
|
|
192
|
+
}
|
|
193
|
+
}, {
|
|
194
|
+
key: "renderItems",
|
|
195
|
+
value: function renderItems() {
|
|
196
|
+
var _this2 = this;
|
|
197
|
+
return this.props.children.map(function (img, index) {
|
|
198
|
+
var itemClass = klass.ITEM(false, index === _this2.state.selectedItem);
|
|
199
|
+
var thumbProps = {
|
|
200
|
+
key: index,
|
|
201
|
+
ref: function ref(e) {
|
|
202
|
+
return _this2.setThumbsRef(e, index);
|
|
203
|
+
},
|
|
204
|
+
className: itemClass,
|
|
205
|
+
onClick: _this2.handleClickItem.bind(_this2, index, _this2.props.children[index]),
|
|
206
|
+
onKeyDown: _this2.handleClickItem.bind(_this2, index, _this2.props.children[index]),
|
|
207
|
+
'aria-label': "".concat(_this2.props.labels.item, " ").concat(index + 1),
|
|
208
|
+
style: {
|
|
209
|
+
width: _this2.props.thumbWidth
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
return /*#__PURE__*/React.createElement("li", _extends({}, thumbProps, {
|
|
213
|
+
role: "button",
|
|
214
|
+
tabIndex: 0
|
|
215
|
+
}), img);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}, {
|
|
219
|
+
key: "render",
|
|
220
|
+
value: function render() {
|
|
221
|
+
var _this3 = this;
|
|
222
|
+
if (!this.props.children) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
var isSwipeable = Children.count(this.props.children) > 1;
|
|
226
|
+
|
|
227
|
+
// show left arrow?
|
|
228
|
+
var hasPrev = this.state.showArrows && this.state.firstItem > 0;
|
|
229
|
+
// show right arrow
|
|
230
|
+
var hasNext = this.state.showArrows && this.state.firstItem < this.state.lastPosition;
|
|
231
|
+
// obj to hold the transformations and styles
|
|
232
|
+
var itemListStyles = {};
|
|
233
|
+
var currentPosition = -this.state.firstItem * (this.state.itemSize || 0);
|
|
234
|
+
var transformProp = CSSTranslate(currentPosition, 'px', this.props.axis);
|
|
235
|
+
var transitionTime = this.props.transitionTime + 'ms';
|
|
236
|
+
itemListStyles = {
|
|
237
|
+
WebkitTransform: transformProp,
|
|
238
|
+
MozTransform: transformProp,
|
|
239
|
+
MsTransform: transformProp,
|
|
240
|
+
OTransform: transformProp,
|
|
241
|
+
transform: transformProp,
|
|
242
|
+
msTransform: transformProp,
|
|
243
|
+
WebkitTransitionDuration: transitionTime,
|
|
244
|
+
MozTransitionDuration: transitionTime,
|
|
245
|
+
MsTransitionDuration: transitionTime,
|
|
246
|
+
OTransitionDuration: transitionTime,
|
|
247
|
+
transitionDuration: transitionTime,
|
|
248
|
+
msTransitionDuration: transitionTime
|
|
249
|
+
};
|
|
250
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
251
|
+
className: klass.CAROUSEL(false)
|
|
252
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
253
|
+
className: klass.WRAPPER(false),
|
|
254
|
+
ref: this.setItemsWrapperRef
|
|
255
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
256
|
+
type: "button",
|
|
257
|
+
className: klass.ARROW_PREV(!hasPrev),
|
|
258
|
+
onClick: function onClick() {
|
|
259
|
+
return _this3.slideRight();
|
|
260
|
+
},
|
|
261
|
+
"aria-label": this.props.labels.leftArrow
|
|
262
|
+
}), isSwipeable ? /*#__PURE__*/React.createElement(Swipe, {
|
|
263
|
+
tagName: "ul",
|
|
264
|
+
className: klass.SLIDER(false, this.state.swiping),
|
|
265
|
+
onSwipeLeft: this.slideLeft,
|
|
266
|
+
onSwipeRight: this.slideRight,
|
|
267
|
+
onSwipeMove: this.onSwipeMove,
|
|
268
|
+
onSwipeStart: this.onSwipeStart,
|
|
269
|
+
onSwipeEnd: this.onSwipeEnd,
|
|
270
|
+
style: itemListStyles,
|
|
271
|
+
innerRef: this.setItemsListRef,
|
|
272
|
+
allowMouseEvents: this.props.emulateTouch
|
|
273
|
+
}, this.renderItems()) : /*#__PURE__*/React.createElement("ul", {
|
|
274
|
+
className: klass.SLIDER(false, this.state.swiping),
|
|
275
|
+
ref: function ref(node) {
|
|
276
|
+
return _this3.setItemsListRef(node);
|
|
277
|
+
},
|
|
278
|
+
style: itemListStyles
|
|
279
|
+
}, this.renderItems()), /*#__PURE__*/React.createElement("button", {
|
|
280
|
+
type: "button",
|
|
281
|
+
className: klass.ARROW_NEXT(!hasNext),
|
|
282
|
+
onClick: function onClick() {
|
|
283
|
+
return _this3.slideLeft();
|
|
284
|
+
},
|
|
285
|
+
"aria-label": this.props.labels.rightArrow
|
|
286
|
+
})));
|
|
287
|
+
}
|
|
288
|
+
}]);
|
|
289
|
+
}(Component);
|
|
290
|
+
_defineProperty(Thumbs, "displayName", 'Thumbs');
|
|
291
|
+
_defineProperty(Thumbs, "defaultProps", {
|
|
292
|
+
axis: 'horizontal',
|
|
293
|
+
labels: {
|
|
294
|
+
leftArrow: 'previous slide / item',
|
|
295
|
+
rightArrow: 'next slide / item',
|
|
296
|
+
item: 'slide item'
|
|
297
|
+
},
|
|
298
|
+
selectedItem: 0,
|
|
299
|
+
thumbWidth: 80,
|
|
300
|
+
transitionTime: 350
|
|
301
|
+
});
|
|
302
|
+
export { Thumbs as default };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { Children } from 'react';
|
|
3
|
+
import CSSTranslate from '../../CSSTranslate';
|
|
4
|
+
import { getPosition, setPosition } from './utils';
|
|
5
|
+
/**
|
|
6
|
+
* Main animation handler for the default 'sliding' style animation
|
|
7
|
+
* @param props
|
|
8
|
+
* @param state
|
|
9
|
+
*/
|
|
10
|
+
export var slideAnimationHandler = function slideAnimationHandler(props, state) {
|
|
11
|
+
var returnStyles = {};
|
|
12
|
+
var selectedItem = state.selectedItem;
|
|
13
|
+
var previousItem = selectedItem;
|
|
14
|
+
var lastPosition = Children.count(props.children) - 1;
|
|
15
|
+
var needClonedSlide = props.infiniteLoop && (selectedItem < 0 || selectedItem > lastPosition);
|
|
16
|
+
|
|
17
|
+
// Handle list position if it needs a clone
|
|
18
|
+
if (needClonedSlide) {
|
|
19
|
+
if (previousItem < 0) {
|
|
20
|
+
if (props.centerMode && props.centerSlidePercentage && props.axis === 'horizontal') {
|
|
21
|
+
returnStyles.itemListStyle = setPosition(-(lastPosition + 2) * props.centerSlidePercentage - (100 - props.centerSlidePercentage) / 2, props.axis);
|
|
22
|
+
} else {
|
|
23
|
+
returnStyles.itemListStyle = setPosition(-(lastPosition + 2) * 100, props.axis);
|
|
24
|
+
}
|
|
25
|
+
} else if (previousItem > lastPosition) {
|
|
26
|
+
returnStyles.itemListStyle = setPosition(0, props.axis);
|
|
27
|
+
}
|
|
28
|
+
return returnStyles;
|
|
29
|
+
}
|
|
30
|
+
var currentPosition = getPosition(selectedItem, props);
|
|
31
|
+
|
|
32
|
+
// if 3d is available, let's take advantage of the performance of transform
|
|
33
|
+
var transformProp = CSSTranslate(currentPosition, '%', props.axis);
|
|
34
|
+
var transitionTime = props.transitionTime + 'ms';
|
|
35
|
+
returnStyles.itemListStyle = {
|
|
36
|
+
WebkitTransform: transformProp,
|
|
37
|
+
msTransform: transformProp,
|
|
38
|
+
OTransform: transformProp,
|
|
39
|
+
transform: transformProp
|
|
40
|
+
};
|
|
41
|
+
if (!state.swiping) {
|
|
42
|
+
returnStyles.itemListStyle = _extends({}, returnStyles.itemListStyle, {
|
|
43
|
+
WebkitTransitionDuration: transitionTime,
|
|
44
|
+
MozTransitionDuration: transitionTime,
|
|
45
|
+
OTransitionDuration: transitionTime,
|
|
46
|
+
transitionDuration: transitionTime,
|
|
47
|
+
msTransitionDuration: transitionTime
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return returnStyles;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Swiping animation handler for the default 'sliding' style animation
|
|
55
|
+
* @param delta
|
|
56
|
+
* @param props
|
|
57
|
+
* @param state
|
|
58
|
+
* @param setState
|
|
59
|
+
*/
|
|
60
|
+
export var slideSwipeAnimationHandler = function slideSwipeAnimationHandler(delta, props, state, setState) {
|
|
61
|
+
var returnStyles = {};
|
|
62
|
+
var isHorizontal = props.axis === 'horizontal';
|
|
63
|
+
var childrenLength = Children.count(props.children);
|
|
64
|
+
var initialBoundry = 0;
|
|
65
|
+
var currentPosition = getPosition(state.selectedItem, props);
|
|
66
|
+
var finalBoundry = props.infiniteLoop ? getPosition(childrenLength - 1, props) - 100 : getPosition(childrenLength - 1, props);
|
|
67
|
+
var axisDelta = isHorizontal ? delta.x : delta.y;
|
|
68
|
+
var handledDelta = axisDelta;
|
|
69
|
+
|
|
70
|
+
// prevent user from swiping left out of boundaries
|
|
71
|
+
if (currentPosition === initialBoundry && axisDelta > 0) {
|
|
72
|
+
handledDelta = 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// prevent user from swiping right out of boundaries
|
|
76
|
+
if (currentPosition === finalBoundry && axisDelta < 0) {
|
|
77
|
+
handledDelta = 0;
|
|
78
|
+
}
|
|
79
|
+
var position = currentPosition + 100 / (state.itemSize / handledDelta);
|
|
80
|
+
var hasMoved = Math.abs(axisDelta) > props.swipeScrollTolerance;
|
|
81
|
+
if (props.infiniteLoop && hasMoved) {
|
|
82
|
+
// When allowing infinite loop, if we slide left from position 0 we reveal the cloned last slide that appears before it
|
|
83
|
+
// if we slide even further we need to jump to other side so it can continue - and vice versa for the last slide
|
|
84
|
+
if (state.selectedItem === 0 && position > -100) {
|
|
85
|
+
position -= childrenLength * 100;
|
|
86
|
+
} else if (state.selectedItem === childrenLength - 1 && position < -childrenLength * 100) {
|
|
87
|
+
position += childrenLength * 100;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (!props.preventMovementUntilSwipeScrollTolerance || hasMoved || state.swipeMovementStarted) {
|
|
91
|
+
if (!state.swipeMovementStarted) {
|
|
92
|
+
setState({
|
|
93
|
+
swipeMovementStarted: true
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
returnStyles.itemListStyle = setPosition(position, props.axis);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//allows scroll if the swipe was within the tolerance
|
|
100
|
+
if (hasMoved && !state.cancelClick) {
|
|
101
|
+
setState({
|
|
102
|
+
cancelClick: true
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return returnStyles;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Default 'sliding' style animination handler for when a swipe action stops.
|
|
110
|
+
* @param props
|
|
111
|
+
* @param state
|
|
112
|
+
*/
|
|
113
|
+
export var slideStopSwipingHandler = function slideStopSwipingHandler(props, state) {
|
|
114
|
+
var currentPosition = getPosition(state.selectedItem, props);
|
|
115
|
+
var itemListStyle = setPosition(currentPosition, props.axis);
|
|
116
|
+
return {
|
|
117
|
+
itemListStyle: itemListStyle
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Main animation handler for the default 'fade' style animation
|
|
123
|
+
* @param props
|
|
124
|
+
* @param state
|
|
125
|
+
*/
|
|
126
|
+
export var fadeAnimationHandler = function fadeAnimationHandler(props, state) {
|
|
127
|
+
var transitionTime = props.transitionTime + 'ms';
|
|
128
|
+
var transitionTimingFunction = 'ease-in-out';
|
|
129
|
+
var slideStyle = {
|
|
130
|
+
position: 'absolute',
|
|
131
|
+
display: 'block',
|
|
132
|
+
zIndex: -2,
|
|
133
|
+
minHeight: '100%',
|
|
134
|
+
opacity: 0,
|
|
135
|
+
top: 0,
|
|
136
|
+
right: 0,
|
|
137
|
+
left: 0,
|
|
138
|
+
bottom: 0,
|
|
139
|
+
transitionTimingFunction: transitionTimingFunction,
|
|
140
|
+
msTransitionTimingFunction: transitionTimingFunction,
|
|
141
|
+
MozTransitionTimingFunction: transitionTimingFunction,
|
|
142
|
+
WebkitTransitionTimingFunction: transitionTimingFunction,
|
|
143
|
+
OTransitionTimingFunction: transitionTimingFunction
|
|
144
|
+
};
|
|
145
|
+
if (!state.swiping) {
|
|
146
|
+
slideStyle = _extends({}, slideStyle, {
|
|
147
|
+
WebkitTransitionDuration: transitionTime,
|
|
148
|
+
MozTransitionDuration: transitionTime,
|
|
149
|
+
OTransitionDuration: transitionTime,
|
|
150
|
+
transitionDuration: transitionTime,
|
|
151
|
+
msTransitionDuration: transitionTime
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
slideStyle: slideStyle,
|
|
156
|
+
selectedStyle: _extends({}, slideStyle, {
|
|
157
|
+
opacity: 1,
|
|
158
|
+
position: 'relative'
|
|
159
|
+
}),
|
|
160
|
+
prevStyle: _extends({}, slideStyle)
|
|
161
|
+
};
|
|
162
|
+
};
|