@neko-os/ui 0.4.0 → 0.5.1
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/abstractions/KeyboardDismissView.js +3 -0
- package/dist/abstractions/KeyboardDismissView.native.js +9 -0
- package/dist/abstractions/index.js +1 -0
- package/dist/components/actions/ClearLink.js +6 -0
- package/dist/components/actions/FloatingMenu.js +1 -1
- package/dist/components/calendar/CalendarNav.js +6 -6
- package/dist/components/carousel/Carousel.js +48 -0
- package/dist/components/carousel/CarouselArrows.js +40 -0
- package/dist/components/carousel/CarouselArrows.native.js +40 -0
- package/dist/components/carousel/CarouselDots.js +32 -0
- package/dist/components/carousel/CarouselDots.native.js +36 -0
- package/dist/components/carousel/CarouselHandler.js +86 -0
- package/dist/components/carousel/CarouselSlider.js +124 -0
- package/dist/components/carousel/CarouselSlider.native.js +121 -0
- package/dist/components/carousel/InfiniteCarousel.js +50 -0
- package/dist/components/carousel/index.js +6 -0
- package/dist/components/form/Form.js +5 -3
- package/dist/components/index.js +3 -1
- package/dist/components/inputs/DateInput.js +7 -4
- package/dist/components/inputs/InputWrapper.js +1 -2
- package/dist/components/inputs/Select.js +56 -52
- package/dist/components/inputs/TextInput.js +7 -6
- package/dist/components/inputs/datePicker/DayPicker.js +71 -23
- package/dist/components/inputs/datePicker/MonthPicker.js +61 -32
- package/dist/components/inputs/datePicker/QuarterPicker.js +62 -33
- package/dist/components/inputs/datePicker/WeekPicker.js +65 -24
- package/dist/components/inputs/datePicker/YearPicker.js +69 -40
- package/dist/components/keyboard/KeyboardDismissButton.js +3 -0
- package/dist/components/keyboard/KeyboardDismissButton.native.js +38 -0
- package/dist/components/keyboard/index.js +1 -0
- package/dist/components/modals/bottomDrawer/native/BottomDrawer.js +28 -7
- package/dist/components/presentation/LabelValue.js +1 -1
- package/dist/components/presentation/Result.js +11 -3
- package/dist/components/structure/KeyboardAvoidingView.js +9 -2
- package/dist/components/theme/ThemePicker.js +7 -12
- package/dist/components/theme/ThemeThumb.js +1 -1
- package/dist/index.js +1 -0
- package/dist/theme/ThemeHandler.js +31 -3
- package/package.json +1 -1
- package/src/abstractions/KeyboardDismissView.js +3 -0
- package/src/abstractions/KeyboardDismissView.native.js +9 -0
- package/src/abstractions/index.js +1 -0
- package/src/components/actions/ClearLink.js +6 -0
- package/src/components/actions/FloatingMenu.js +1 -1
- package/src/components/calendar/CalendarNav.js +6 -6
- package/src/components/carousel/Carousel.js +48 -0
- package/src/components/carousel/CarouselArrows.js +40 -0
- package/src/components/carousel/CarouselArrows.native.js +40 -0
- package/src/components/carousel/CarouselDots.js +32 -0
- package/src/components/carousel/CarouselDots.native.js +36 -0
- package/src/components/carousel/CarouselHandler.js +86 -0
- package/src/components/carousel/CarouselSlider.js +124 -0
- package/src/components/carousel/CarouselSlider.native.js +121 -0
- package/src/components/carousel/InfiniteCarousel.js +50 -0
- package/src/components/carousel/index.js +6 -0
- package/src/components/form/Form.js +2 -0
- package/src/components/index.js +2 -0
- package/src/components/inputs/DateInput.js +4 -1
- package/src/components/inputs/InputWrapper.js +1 -2
- package/src/components/inputs/Select.js +19 -15
- package/src/components/inputs/TextInput.js +5 -4
- package/src/components/inputs/datePicker/DayPicker.js +69 -21
- package/src/components/inputs/datePicker/MonthPicker.js +60 -31
- package/src/components/inputs/datePicker/QuarterPicker.js +60 -31
- package/src/components/inputs/datePicker/WeekPicker.js +63 -22
- package/src/components/inputs/datePicker/YearPicker.js +68 -39
- package/src/components/keyboard/KeyboardDismissButton.js +3 -0
- package/src/components/keyboard/KeyboardDismissButton.native.js +38 -0
- package/src/components/keyboard/index.js +1 -0
- package/src/components/modals/bottomDrawer/native/BottomDrawer.js +27 -6
- package/src/components/presentation/LabelValue.js +1 -1
- package/src/components/presentation/Result.js +10 -2
- package/src/components/structure/KeyboardAvoidingView.js +9 -2
- package/src/components/theme/ThemePicker.js +8 -13
- package/src/components/theme/ThemeThumb.js +1 -1
- package/src/index.js +1 -0
- package/src/theme/ThemeHandler.js +31 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/abstractions/KeyboardDismissView.native.js";import { Keyboard, Pressable } from "react-native-web";import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
export function AbsKeyboardDismissView(_ref) {var children = _ref.children,style = _ref.style;
|
|
4
|
+
return (
|
|
5
|
+
_jsx(Pressable, { onPress: Keyboard.dismiss, accessible: false, style: style, children:
|
|
6
|
+
children }
|
|
7
|
+
));
|
|
8
|
+
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Platform";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/actions/ClearLink.js";var _excluded = ["hide", "value", "onChange"];function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}import { Link } from "./Link";import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
export function ClearLink(_ref) {var hide = _ref.hide,value = _ref.value,onChange = _ref.onChange,props = _objectWithoutProperties(_ref, _excluded);
|
|
4
|
+
if (!!hide || !!value) return false;
|
|
5
|
+
return _jsx(Link, Object.assign({ center: true, red: true, label: "Remove Value", onPress: function onPress() {return onChange(null);}, padding: "sm" }, props));
|
|
6
|
+
}
|
|
@@ -14,7 +14,7 @@ export function FloatingMenu(_ref) {var _this = this;var fixed = _ref.fixed,onCh
|
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
_jsx(View, { absolute: !fixed, fixed: fixed, left: "md", right: "md", centerH: true, bottom: Math.max(insets.bottom / 2, 16), children:
|
|
17
|
-
_jsx(WrapperView, Object.assign({ height: height, shadow: true, round: true, row: true, paddingH: "sm", bg: bg }, props, { children:
|
|
17
|
+
_jsx(WrapperView, Object.assign({ height: height, shadow: true, round: true, row: true, paddingH: "sm", bg: bg, border: "overlayDivider" }, props, { children:
|
|
18
18
|
items.map(function (item, index) {var _item$icon;
|
|
19
19
|
var isActive = index === activeIndex;
|
|
20
20
|
|
|
@@ -20,7 +20,7 @@ export function CalendarNav(_ref) {var value = _ref.value,onChange = _ref.onChan
|
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
22
|
_jsxs(View, Object.assign({ className: "neko-calendar-nav", row: true, centerV: true, gap: "xxs", height: 30 }, props, { children: [
|
|
23
|
-
_jsx(Link, { onPress: prevDecade, "aria-label": "Previous decade", padding: "
|
|
23
|
+
_jsx(Link, { onPress: prevDecade, "aria-label": "Previous decade", padding: "sm", paddingL: 0, children:
|
|
24
24
|
_jsx(Icon, { name: "arrow-left-double-line" }) }
|
|
25
25
|
),
|
|
26
26
|
|
|
@@ -28,7 +28,7 @@ export function CalendarNav(_ref) {var value = _ref.value,onChange = _ref.onChan
|
|
|
28
28
|
year, "-", year + 9] }
|
|
29
29
|
),
|
|
30
30
|
|
|
31
|
-
_jsx(Link, { onPress: nextDecade, "aria-label": "Next decade", padding: "
|
|
31
|
+
_jsx(Link, { onPress: nextDecade, "aria-label": "Next decade", padding: "sm", paddingR: 0, children:
|
|
32
32
|
_jsx(Icon, { name: "arrow-right-double-line" }) }
|
|
33
33
|
)] })
|
|
34
34
|
));
|
|
@@ -37,12 +37,12 @@ export function CalendarNav(_ref) {var value = _ref.value,onChange = _ref.onChan
|
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
39
|
_jsxs(View, Object.assign({ className: "neko-calendar-nav", row: true, centerV: true, gap: "xxs", height: 30 }, props, { children: [
|
|
40
|
-
_jsx(Link, { onPress: prevYear, "aria-label": "Previous year", padding: "
|
|
40
|
+
_jsx(Link, { onPress: prevYear, "aria-label": "Previous year", padding: "sm", paddingR: 0, children:
|
|
41
41
|
_jsx(Icon, { name: "arrow-left-double-line" }) }
|
|
42
42
|
),
|
|
43
43
|
|
|
44
44
|
showMonth &&
|
|
45
|
-
_jsx(Link, { onPress: prevMonth, "aria-label": "Previous month", padding: "
|
|
45
|
+
_jsx(Link, { onPress: prevMonth, "aria-label": "Previous month", padding: "sm", children:
|
|
46
46
|
_jsx(Icon, { name: "arrow-left-s-line" }) }
|
|
47
47
|
),
|
|
48
48
|
|
|
@@ -54,12 +54,12 @@ export function CalendarNav(_ref) {var value = _ref.value,onChange = _ref.onChan
|
|
|
54
54
|
),
|
|
55
55
|
|
|
56
56
|
showMonth &&
|
|
57
|
-
_jsx(Link, { onPress: nextMonth, "aria-label": "Next month", padding: "
|
|
57
|
+
_jsx(Link, { onPress: nextMonth, "aria-label": "Next month", padding: "sm", children:
|
|
58
58
|
_jsx(Icon, { name: "arrow-right-s-line" }) }
|
|
59
59
|
),
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
_jsx(Link, { onPress: nextYear, "aria-label": "Next year", padding: "
|
|
62
|
+
_jsx(Link, { onPress: nextYear, "aria-label": "Next year", padding: "sm", paddingL: 0, children:
|
|
63
63
|
_jsx(Icon, { name: "arrow-right-double-line" }) }
|
|
64
64
|
)] })
|
|
65
65
|
));
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/carousel/Carousel.js";var _excluded = ["items", "activeIndex", "activeKey", "onChange", "afterChange", "autoplay", "autoplaySpeed", "draggable", "loop", "showDots", "showArrows", "floatingDots", "dotsProps", "arrowsProps", "children"];function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}import { View } from "../structure/View";
|
|
2
|
+
import { CarouselArrows } from "./CarouselArrows";
|
|
3
|
+
import { CarouselDots } from "./CarouselDots";
|
|
4
|
+
import { CarouselHandler } from "./CarouselHandler";
|
|
5
|
+
import { CarouselSlider } from "./CarouselSlider";import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
export function Carousel(_ref)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
{var items = _ref.items,activeIndex = _ref.activeIndex,activeKey = _ref.activeKey,onChange = _ref.onChange,afterChange = _ref.afterChange,autoplay = _ref.autoplay,autoplaySpeed = _ref.autoplaySpeed,draggable = _ref.draggable,loop = _ref.loop,showDots = _ref.showDots,showArrows = _ref.showArrows,floatingDots = _ref.floatingDots,dotsProps = _ref.dotsProps,arrowsProps = _ref.arrowsProps,children = _ref.children,rootProps = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
return (
|
|
26
|
+
_jsx(CarouselHandler, {
|
|
27
|
+
items: items,
|
|
28
|
+
activeIndex: activeIndex,
|
|
29
|
+
activeKey: activeKey,
|
|
30
|
+
onChange: onChange,
|
|
31
|
+
afterChange: afterChange,
|
|
32
|
+
autoplay: autoplay,
|
|
33
|
+
autoplaySpeed: autoplaySpeed,
|
|
34
|
+
draggable: draggable,
|
|
35
|
+
loop: loop, children:
|
|
36
|
+
|
|
37
|
+
_jsxs(View, Object.assign({}, rootProps, { children: [
|
|
38
|
+
_jsxs(View, { relative: true, children: [
|
|
39
|
+
_jsx(CarouselSlider, {}),
|
|
40
|
+
showArrows && _jsx(CarouselArrows, Object.assign({}, arrowsProps)),
|
|
41
|
+
showDots && floatingDots && _jsx(CarouselDots, Object.assign({ absolute: true, bottom: "xs", left: 0, right: 0 }, dotsProps))] }
|
|
42
|
+
),
|
|
43
|
+
showDots && !floatingDots && _jsx(CarouselDots, Object.assign({}, dotsProps)),
|
|
44
|
+
children] })
|
|
45
|
+
) }
|
|
46
|
+
));
|
|
47
|
+
|
|
48
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/carousel/CarouselArrows.js";var _excluded = ["iconSize"];function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Icon } from "../presentation/Icon";
|
|
4
|
+
import { Link } from "../actions/Link";
|
|
5
|
+
import { View } from "../structure/View";
|
|
6
|
+
import { useCarousel } from "./CarouselHandler";import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
export function CarouselArrows(_ref) {var _ref$iconSize = _ref.iconSize,iconSize = _ref$iconSize === void 0 ? 'md' : _ref$iconSize,props = _objectWithoutProperties(_ref, _excluded);
|
|
9
|
+
var _useCarousel = useCarousel(),goToNext = _useCarousel.goToNext,goToPrev = _useCarousel.goToPrev,activeIndex = _useCarousel.activeIndex,itemsCount = _useCarousel.itemsCount,loop = _useCarousel.loop;
|
|
10
|
+
|
|
11
|
+
var showPrev = loop || activeIndex > 0;
|
|
12
|
+
var showNext = loop || activeIndex < itemsCount - 1;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
_jsxs(View, Object.assign({
|
|
16
|
+
absoluteFill: true,
|
|
17
|
+
row: true,
|
|
18
|
+
centerV: true,
|
|
19
|
+
paddingH: "xs",
|
|
20
|
+
justify: "space-between",
|
|
21
|
+
style: { pointerEvents: 'none' } },
|
|
22
|
+
props, { children: [
|
|
23
|
+
|
|
24
|
+
showPrev ?
|
|
25
|
+
_jsx(Link, { onPress: goToPrev, bg: "overlayBG_op80", round: true, padding: "xs", shadow: true, style: { pointerEvents: 'auto' }, children:
|
|
26
|
+
_jsx(Icon, { name: "arrow-left-s-line", text3: true, size: iconSize }) }
|
|
27
|
+
) :
|
|
28
|
+
|
|
29
|
+
_jsx(View, {}),
|
|
30
|
+
|
|
31
|
+
showNext ?
|
|
32
|
+
_jsx(Link, { onPress: goToNext, bg: "overlayBG_op80", round: true, padding: "xs", shadow: true, style: { pointerEvents: 'auto' }, children:
|
|
33
|
+
_jsx(Icon, { name: "arrow-right-s-line", text3: true, size: iconSize }) }
|
|
34
|
+
) :
|
|
35
|
+
|
|
36
|
+
_jsx(View, {})] })
|
|
37
|
+
|
|
38
|
+
));
|
|
39
|
+
|
|
40
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/carousel/CarouselArrows.native.js";var _excluded = ["iconSize"];function _objectWithoutProperties(e, t) {if (null == e) return {};var o,r,i = _objectWithoutPropertiesLoose(e, t);if (Object.getOwnPropertySymbols) {var n = Object.getOwnPropertySymbols(e);for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);}return i;}function _objectWithoutPropertiesLoose(r, e) {if (null == r) return {};var t = {};for (var n in r) if ({}.hasOwnProperty.call(r, n)) {if (-1 !== e.indexOf(n)) continue;t[n] = r[n];}return t;}import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Icon } from "../presentation/Icon";
|
|
4
|
+
import { Link } from "../actions/Link";
|
|
5
|
+
import { View } from "../structure/View";
|
|
6
|
+
import { useCarousel } from "./CarouselHandler";import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
export function CarouselArrows(_ref) {var _ref$iconSize = _ref.iconSize,iconSize = _ref$iconSize === void 0 ? 'md' : _ref$iconSize,props = _objectWithoutProperties(_ref, _excluded);
|
|
9
|
+
var _useCarousel = useCarousel(),goToNext = _useCarousel.goToNext,goToPrev = _useCarousel.goToPrev,activeIndex = _useCarousel.activeIndex,itemsCount = _useCarousel.itemsCount,loop = _useCarousel.loop;
|
|
10
|
+
|
|
11
|
+
var showPrev = loop || activeIndex > 0;
|
|
12
|
+
var showNext = loop || activeIndex < itemsCount - 1;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
_jsxs(View, Object.assign({
|
|
16
|
+
absoluteFill: true,
|
|
17
|
+
row: true,
|
|
18
|
+
centerV: true,
|
|
19
|
+
paddingH: "xs",
|
|
20
|
+
justify: "space-between",
|
|
21
|
+
pointerEvents: "box-none" },
|
|
22
|
+
props, { children: [
|
|
23
|
+
|
|
24
|
+
showPrev ?
|
|
25
|
+
_jsx(Link, { onPress: goToPrev, bg: "overlayBG_op80", round: true, padding: "xs", shadow: true, children:
|
|
26
|
+
_jsx(Icon, { name: "arrow-left-s-line", text3: true, size: iconSize }) }
|
|
27
|
+
) :
|
|
28
|
+
|
|
29
|
+
_jsx(View, {}),
|
|
30
|
+
|
|
31
|
+
showNext ?
|
|
32
|
+
_jsx(Link, { onPress: goToNext, bg: "overlayBG_op80", round: true, padding: "xs", shadow: true, children:
|
|
33
|
+
_jsx(Icon, { name: "arrow-right-s-line", text3: true, size: iconSize }) }
|
|
34
|
+
) :
|
|
35
|
+
|
|
36
|
+
_jsx(View, {})] })
|
|
37
|
+
|
|
38
|
+
));
|
|
39
|
+
|
|
40
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/carousel/CarouselDots.js";import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Pressable } from "../actions/Pressable";
|
|
4
|
+
import { View } from "../structure/View";
|
|
5
|
+
import { useCarousel } from "./CarouselHandler";import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
function Dot(_ref) {var active = _ref.active,onPress = _ref.onPress;
|
|
8
|
+
return (
|
|
9
|
+
_jsx(Pressable, {
|
|
10
|
+
onPress: onPress,
|
|
11
|
+
width: active ? 20 : 8,
|
|
12
|
+
height: 8,
|
|
13
|
+
round: true,
|
|
14
|
+
bg: active ? 'primary' : 'text4_op30',
|
|
15
|
+
style: { transition: 'all 200ms ease-in-out' } }
|
|
16
|
+
));
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function CarouselDots(props) {var _this = this;
|
|
21
|
+
var _useCarousel = useCarousel(),items = _useCarousel.items,activeIndex = _useCarousel.activeIndex,goTo = _useCarousel.goTo;
|
|
22
|
+
|
|
23
|
+
if (!(items != null && items.length)) return null;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
_jsx(View, Object.assign({ row: true, center: true, gap: "xs", paddingV: "sm" }, props, { children:
|
|
27
|
+
items.map(function (item, index) {return (
|
|
28
|
+
_jsx(Dot, { active: index === activeIndex, onPress: function onPress() {return goTo(index);} }, item.key));}
|
|
29
|
+
) })
|
|
30
|
+
));
|
|
31
|
+
|
|
32
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/carousel/CarouselDots.native.js";import React from 'react';
|
|
2
|
+
import Animated, { useAnimatedStyle, withTiming } from 'react-native-reanimated';
|
|
3
|
+
|
|
4
|
+
import { Pressable } from "../actions/Pressable";
|
|
5
|
+
import { View } from "../structure/View";
|
|
6
|
+
import { useColors } from "../../theme/ThemeHandler";
|
|
7
|
+
import { useCarousel } from "./CarouselHandler";import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
function Dot(_ref) {var active = _ref.active,onPress = _ref.onPress;
|
|
10
|
+
var colors = useColors();
|
|
11
|
+
|
|
12
|
+
var animatedStyle = useAnimatedStyle(function () {return {
|
|
13
|
+
width: withTiming(active ? 20 : 8, { duration: 200 }),
|
|
14
|
+
backgroundColor: withTiming(active ? colors.primary : colors.text4_op30, { duration: 200 })
|
|
15
|
+
};}, [active]);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
_jsx(Pressable, { onPress: onPress, children:
|
|
19
|
+
_jsx(Animated.View, { style: [{ height: 8, borderRadius: 4 }, animatedStyle] }) }
|
|
20
|
+
));
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function CarouselDots(props) {var _this = this;
|
|
25
|
+
var _useCarousel = useCarousel(),items = _useCarousel.items,activeIndex = _useCarousel.activeIndex,goTo = _useCarousel.goTo;
|
|
26
|
+
|
|
27
|
+
if (!(items != null && items.length)) return null;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
_jsx(View, Object.assign({ row: true, center: true, gap: "xs", paddingV: "sm" }, props, { children:
|
|
31
|
+
items.map(function (item, index) {return (
|
|
32
|
+
_jsx(Dot, { active: index === activeIndex, onPress: function onPress() {return goTo(index);} }, item.key));}
|
|
33
|
+
) })
|
|
34
|
+
));
|
|
35
|
+
|
|
36
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/carousel/CarouselHandler.js";function _slicedToArray(r, e) {return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();}function _nonIterableRest() {throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r, a) {if (r) {if ("string" == typeof r) return _arrayLikeToArray(r, a);var t = {}.toString.call(r).slice(8, -1);return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;}}function _arrayLikeToArray(r, a) {(null == a || a > r.length) && (a = r.length);for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];return n;}function _iterableToArrayLimit(r, l) {var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];if (null != t) {var e,n,i,u,a = [],f = !0,o = !1;try {if (i = (t = t.call(r)).next, 0 === l) {if (Object(t) !== t) return;f = !1;} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);} catch (r) {o = !0, n = r;} finally {try {if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;} finally {if (o) throw n;}}return a;}}function _arrayWithHoles(r) {if (Array.isArray(r)) return r;}import React from 'react';import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
var CarouselContext = React.createContext(null);
|
|
4
|
+
export var useCarousel = function useCarousel() {return React.useContext(CarouselContext) || {};};
|
|
5
|
+
|
|
6
|
+
export function CarouselHandler(_ref)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
{var children = _ref.children,items = _ref.items,controlledIndex = _ref.activeIndex,activeKey = _ref.activeKey,onChange = _ref.onChange,afterChange = _ref.afterChange,autoplay = _ref.autoplay,_ref$autoplaySpeed = _ref.autoplaySpeed,autoplaySpeed = _ref$autoplaySpeed === void 0 ? 3000 : _ref$autoplaySpeed,draggable = _ref.draggable,loop = _ref.loop;
|
|
18
|
+
var itemsCount = (items == null ? void 0 : items.length) || 0;
|
|
19
|
+
var isControlled = controlledIndex !== undefined || activeKey !== undefined;
|
|
20
|
+
|
|
21
|
+
var _React$useState = React.useState(function () {
|
|
22
|
+
if (controlledIndex !== undefined) return controlledIndex;
|
|
23
|
+
if (activeKey !== undefined) return Math.max(0, (items == null ? void 0 : items.findIndex(function (i) {return i.key === activeKey;})) || 0);
|
|
24
|
+
return 0;
|
|
25
|
+
}),_React$useState2 = _slicedToArray(_React$useState, 2),internalIndex = _React$useState2[0],setInternalIndex = _React$useState2[1];
|
|
26
|
+
|
|
27
|
+
var resolvedIndex = isControlled ?
|
|
28
|
+
activeKey !== undefined ?
|
|
29
|
+
Math.max(0, (items == null ? void 0 : items.findIndex(function (i) {return i.key === activeKey;})) || 0) :
|
|
30
|
+
controlledIndex :
|
|
31
|
+
internalIndex;
|
|
32
|
+
|
|
33
|
+
var activeItem = React.useMemo(function () {return items == null ? void 0 : items[resolvedIndex];}, [items, resolvedIndex]);
|
|
34
|
+
|
|
35
|
+
var pausedRef = React.useRef(false);
|
|
36
|
+
|
|
37
|
+
var goTo = React.useCallback(
|
|
38
|
+
function (index) {var _items$next;
|
|
39
|
+
var next = index;
|
|
40
|
+
if (loop) next = (next % itemsCount + itemsCount) % itemsCount;else
|
|
41
|
+
next = Math.max(0, Math.min(next, itemsCount - 1));
|
|
42
|
+
|
|
43
|
+
if (!isControlled) setInternalIndex(next);
|
|
44
|
+
onChange == null ? void 0 : onChange(items == null ? void 0 : (_items$next = items[next]) == null ? void 0 : _items$next.key, next);
|
|
45
|
+
},
|
|
46
|
+
[loop, itemsCount, isControlled, onChange, items]
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
var goToNext = React.useCallback(function () {return goTo(resolvedIndex + 1);}, [goTo, resolvedIndex]);
|
|
50
|
+
var goToPrev = React.useCallback(function () {return goTo(resolvedIndex - 1);}, [goTo, resolvedIndex]);
|
|
51
|
+
|
|
52
|
+
var pauseAutoplay = React.useCallback(function () {
|
|
53
|
+
pausedRef.current = true;
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
56
|
+
var resumeAutoplay = React.useCallback(function () {
|
|
57
|
+
pausedRef.current = false;
|
|
58
|
+
}, []);
|
|
59
|
+
|
|
60
|
+
React.useEffect(function () {
|
|
61
|
+
if (!autoplay || itemsCount <= 1) return;
|
|
62
|
+
|
|
63
|
+
var interval = setInterval(function () {
|
|
64
|
+
if (!pausedRef.current) goToNext();
|
|
65
|
+
}, autoplaySpeed);
|
|
66
|
+
|
|
67
|
+
return function () {return clearInterval(interval);};
|
|
68
|
+
}, [autoplay, autoplaySpeed, itemsCount, resolvedIndex, goToNext]);
|
|
69
|
+
|
|
70
|
+
var value = {
|
|
71
|
+
items: items,
|
|
72
|
+
activeIndex: resolvedIndex,
|
|
73
|
+
activeItem: activeItem,
|
|
74
|
+
itemsCount: itemsCount,
|
|
75
|
+
goTo: goTo,
|
|
76
|
+
goToNext: goToNext,
|
|
77
|
+
goToPrev: goToPrev,
|
|
78
|
+
afterChange: afterChange,
|
|
79
|
+
draggable: draggable,
|
|
80
|
+
loop: loop,
|
|
81
|
+
pauseAutoplay: pauseAutoplay,
|
|
82
|
+
resumeAutoplay: resumeAutoplay
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return _jsx(CarouselContext.Provider, { value: value, children: children });
|
|
86
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/carousel/CarouselSlider.js";function _slicedToArray(r, e) {return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();}function _nonIterableRest() {throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r, a) {if (r) {if ("string" == typeof r) return _arrayLikeToArray(r, a);var t = {}.toString.call(r).slice(8, -1);return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;}}function _arrayLikeToArray(r, a) {(null == a || a > r.length) && (a = r.length);for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];return n;}function _iterableToArrayLimit(r, l) {var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];if (null != t) {var e,n,i,u,a = [],f = !0,o = !1;try {if (i = (t = t.call(r)).next, 0 === l) {if (Object(t) !== t) return;f = !1;} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);} catch (r) {o = !0, n = r;} finally {try {if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;} finally {if (o) throw n;}}return a;}}function _arrayWithHoles(r) {if (Array.isArray(r)) return r;}import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { View } from "../structure/View";
|
|
4
|
+
import { useCarousel } from "./CarouselHandler";import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
function SlideContent(_ref) {var item = _ref.item;
|
|
7
|
+
var Content = React.useMemo(
|
|
8
|
+
function () {return item.render || item.renderContent || item.Content;},
|
|
9
|
+
[item.render, item.renderContent, item.Content]
|
|
10
|
+
);
|
|
11
|
+
return Content ? _jsx(Content, {}) : null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function CarouselSlider() {var _this = this;
|
|
15
|
+
var _useCarousel =
|
|
16
|
+
useCarousel(),items = _useCarousel.items,activeIndex = _useCarousel.activeIndex,itemsCount = _useCarousel.itemsCount,draggable = _useCarousel.draggable,loop = _useCarousel.loop,afterChange = _useCarousel.afterChange,goToNext = _useCarousel.goToNext,goToPrev = _useCarousel.goToPrev,pauseAutoplay = _useCarousel.pauseAutoplay,resumeAutoplay = _useCarousel.resumeAutoplay;
|
|
17
|
+
|
|
18
|
+
var containerRef = React.useRef(null);
|
|
19
|
+
var _React$useState = React.useState(false),_React$useState2 = _slicedToArray(_React$useState, 2),isDragging = _React$useState2[0],setIsDragging = _React$useState2[1];
|
|
20
|
+
var _React$useState3 = React.useState(0),_React$useState4 = _slicedToArray(_React$useState3, 2),dragOffset = _React$useState4[0],setDragOffset = _React$useState4[1];
|
|
21
|
+
var startXRef = React.useRef(0);
|
|
22
|
+
var startTimeRef = React.useRef(0);
|
|
23
|
+
var prevItemsRef = React.useRef(items);
|
|
24
|
+
var skipTransitionRef = React.useRef(false);
|
|
25
|
+
|
|
26
|
+
if (items !== prevItemsRef.current) {
|
|
27
|
+
skipTransitionRef.current = true;
|
|
28
|
+
prevItemsRef.current = items;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
React.useEffect(function () {
|
|
32
|
+
if (skipTransitionRef.current) {
|
|
33
|
+
var id = requestAnimationFrame(function () {
|
|
34
|
+
skipTransitionRef.current = false;
|
|
35
|
+
});
|
|
36
|
+
return function () {return cancelAnimationFrame(id);};
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (!(items != null && items.length)) return null;
|
|
41
|
+
|
|
42
|
+
var baseTranslate = -(activeIndex * 100) / itemsCount;
|
|
43
|
+
var dragPercent =
|
|
44
|
+
isDragging && containerRef.current ? dragOffset / containerRef.current.offsetWidth * (100 / itemsCount) : 0;
|
|
45
|
+
var transformX = baseTranslate + dragPercent;
|
|
46
|
+
|
|
47
|
+
var dragStateRef = React.useRef({ isDragging: false, dragOffset: 0 });
|
|
48
|
+
|
|
49
|
+
var handlePointerDown = function handlePointerDown(e) {
|
|
50
|
+
if (!draggable) return;
|
|
51
|
+
startXRef.current = e.clientX;
|
|
52
|
+
startTimeRef.current = Date.now();
|
|
53
|
+
dragStateRef.current = { isDragging: true, dragOffset: 0 };
|
|
54
|
+
setIsDragging(true);
|
|
55
|
+
setDragOffset(0);
|
|
56
|
+
pauseAutoplay();
|
|
57
|
+
|
|
58
|
+
var onMove = function onMove(ev) {
|
|
59
|
+
var raw = ev.clientX - startXRef.current;
|
|
60
|
+
var offset = raw;
|
|
61
|
+
if (!loop) {var _containerRef$current;
|
|
62
|
+
var containerWidth = ((_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.offsetWidth) || 1;
|
|
63
|
+
var atStart = activeIndex === 0 && raw > 0;
|
|
64
|
+
var atEnd = activeIndex === itemsCount - 1 && raw < 0;
|
|
65
|
+
if (atStart || atEnd) offset = raw * 0.3;
|
|
66
|
+
}
|
|
67
|
+
dragStateRef.current.dragOffset = offset;
|
|
68
|
+
setDragOffset(offset);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
var _onUp = function onUp() {var _containerRef$current2;
|
|
72
|
+
window.removeEventListener('pointermove', onMove);
|
|
73
|
+
window.removeEventListener('pointerup', _onUp);
|
|
74
|
+
window.removeEventListener('pointercancel', _onUp);
|
|
75
|
+
|
|
76
|
+
var offset = dragStateRef.current.dragOffset;
|
|
77
|
+
var containerWidth = ((_containerRef$current2 = containerRef.current) == null ? void 0 : _containerRef$current2.offsetWidth) || 1;
|
|
78
|
+
var threshold = containerWidth * 0.25;
|
|
79
|
+
var elapsed = Date.now() - startTimeRef.current;
|
|
80
|
+
var velocity = Math.abs(offset) / (elapsed || 1);
|
|
81
|
+
|
|
82
|
+
if (offset < -threshold || offset < 0 && velocity > 0.5) {
|
|
83
|
+
goToNext();
|
|
84
|
+
} else if (offset > threshold || offset > 0 && velocity > 0.5) {
|
|
85
|
+
goToPrev();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
dragStateRef.current = { isDragging: false, dragOffset: 0 };
|
|
89
|
+
setIsDragging(false);
|
|
90
|
+
setDragOffset(0);
|
|
91
|
+
resumeAutoplay();
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
window.addEventListener('pointermove', onMove);
|
|
95
|
+
window.addEventListener('pointerup', _onUp);
|
|
96
|
+
window.addEventListener('pointercancel', _onUp);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
_jsx(View, { hiddenOverflow: true, fullW: true, ref: containerRef, children:
|
|
101
|
+
_jsx(View, {
|
|
102
|
+
row: true,
|
|
103
|
+
style: {
|
|
104
|
+
width: `${itemsCount * 100}%`,
|
|
105
|
+
transform: `translateX(${transformX}%)`,
|
|
106
|
+
transition: isDragging || skipTransitionRef.current ? 'none' : 'transform 300ms ease-in-out',
|
|
107
|
+
touchAction: 'pan-y',
|
|
108
|
+
cursor: draggable ? isDragging ? 'grabbing' : 'grab' : undefined,
|
|
109
|
+
userSelect: 'none'
|
|
110
|
+
},
|
|
111
|
+
onTransitionEnd: afterChange ? function (e) {var _items$activeIndex;
|
|
112
|
+
if (e.propertyName === 'transform') afterChange(items == null ? void 0 : (_items$activeIndex = items[activeIndex]) == null ? void 0 : _items$activeIndex.key, activeIndex);
|
|
113
|
+
} : undefined,
|
|
114
|
+
onPointerDown: draggable ? handlePointerDown : undefined, children:
|
|
115
|
+
|
|
116
|
+
items.map(function (item) {return (
|
|
117
|
+
_jsx(View, { style: { width: `${100 / itemsCount}%` }, children:
|
|
118
|
+
_jsx(SlideContent, { item: item }) }, item.key
|
|
119
|
+
));}
|
|
120
|
+
) }
|
|
121
|
+
) }
|
|
122
|
+
));
|
|
123
|
+
|
|
124
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
var _jsxFileName = "/Users/christianstorch/Apps/nekoapps/libs/neko-ui/src/components/carousel/CarouselSlider.native.js";function _slicedToArray(r, e) {return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();}function _nonIterableRest() {throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r, a) {if (r) {if ("string" == typeof r) return _arrayLikeToArray(r, a);var t = {}.toString.call(r).slice(8, -1);return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;}}function _arrayLikeToArray(r, a) {(null == a || a > r.length) && (a = r.length);for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];return n;}function _iterableToArrayLimit(r, l) {var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];if (null != t) {var e,n,i,u,a = [],f = !0,o = !1;try {if (i = (t = t.call(r)).next, 0 === l) {if (Object(t) !== t) return;f = !1;} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);} catch (r) {o = !0, n = r;} finally {try {if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;} finally {if (o) throw n;}}return a;}}function _arrayWithHoles(r) {if (Array.isArray(r)) return r;}import React from 'react';
|
|
2
|
+
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
3
|
+
import Animated, { useSharedValue, useAnimatedStyle, withTiming, runOnJS } from 'react-native-reanimated';
|
|
4
|
+
|
|
5
|
+
import { View } from "../structure/View";
|
|
6
|
+
import { useCarousel } from "./CarouselHandler";import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
function SlideContent(_ref) {var item = _ref.item;
|
|
9
|
+
var Content = React.useMemo(
|
|
10
|
+
function () {return item.render || item.renderContent || item.Content;},
|
|
11
|
+
[item.render, item.renderContent, item.Content]
|
|
12
|
+
);
|
|
13
|
+
return Content ? _jsx(Content, {}) : null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function clampIndex(index, count, loop) {
|
|
17
|
+
'worklet';
|
|
18
|
+
if (loop) return (index % count + count) % count;
|
|
19
|
+
return Math.max(0, Math.min(index, count - 1));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function CarouselSlider() {var _this = this;
|
|
23
|
+
var _useCarousel =
|
|
24
|
+
useCarousel(),items = _useCarousel.items,activeIndex = _useCarousel.activeIndex,itemsCount = _useCarousel.itemsCount,draggable = _useCarousel.draggable,goTo = _useCarousel.goTo,afterChange = _useCarousel.afterChange,pauseAutoplay = _useCarousel.pauseAutoplay,resumeAutoplay = _useCarousel.resumeAutoplay,loop = _useCarousel.loop;
|
|
25
|
+
|
|
26
|
+
var _React$useState = React.useState(0),_React$useState2 = _slicedToArray(_React$useState, 2),slideWidth = _React$useState2[0],setSlideWidth = _React$useState2[1];
|
|
27
|
+
var translateX = useSharedValue(0);
|
|
28
|
+
var gestureStartX = useSharedValue(0);
|
|
29
|
+
var prevItemsRef = React.useRef(items);
|
|
30
|
+
var gestureAnimatingRef = React.useRef(false);
|
|
31
|
+
|
|
32
|
+
var setGestureAnimating = React.useCallback(function (v) {
|
|
33
|
+
gestureAnimatingRef.current = v;
|
|
34
|
+
}, []);
|
|
35
|
+
|
|
36
|
+
React.useEffect(function () {
|
|
37
|
+
if (slideWidth > 0) {
|
|
38
|
+
if (prevItemsRef.current !== items) {
|
|
39
|
+
prevItemsRef.current = items;
|
|
40
|
+
translateX.value = -activeIndex * slideWidth;
|
|
41
|
+
} else if (gestureAnimatingRef.current) {
|
|
42
|
+
|
|
43
|
+
gestureAnimatingRef.current = false;
|
|
44
|
+
} else {
|
|
45
|
+
translateX.value = withTiming(-activeIndex * slideWidth, { duration: 300 }, function (finished) {var _items$activeIndex;
|
|
46
|
+
if (finished && afterChange) runOnJS(afterChange)(items == null ? void 0 : (_items$activeIndex = items[activeIndex]) == null ? void 0 : _items$activeIndex.key, activeIndex);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, [activeIndex, slideWidth, items]);
|
|
51
|
+
|
|
52
|
+
var onLayout = React.useCallback(function (e) {
|
|
53
|
+
setSlideWidth(e.nativeEvent.layout.width);
|
|
54
|
+
}, []);
|
|
55
|
+
|
|
56
|
+
var animatedStyle = useAnimatedStyle(function () {return {
|
|
57
|
+
transform: [{ translateX: translateX.value }]
|
|
58
|
+
};});
|
|
59
|
+
|
|
60
|
+
if (!(items != null && items.length)) return null;
|
|
61
|
+
|
|
62
|
+
var minTranslate = -(itemsCount - 1) * slideWidth;
|
|
63
|
+
var maxTranslate = 0;
|
|
64
|
+
|
|
65
|
+
var panGesture = Gesture.Pan().
|
|
66
|
+
activeOffsetX([-10, 10]).
|
|
67
|
+
failOffsetY([-10, 10]).
|
|
68
|
+
onStart(function () {
|
|
69
|
+
gestureStartX.value = translateX.value;
|
|
70
|
+
runOnJS(pauseAutoplay)();
|
|
71
|
+
}).
|
|
72
|
+
onUpdate(function (e) {
|
|
73
|
+
var raw = gestureStartX.value + e.translationX;
|
|
74
|
+
if (loop) {
|
|
75
|
+
translateX.value = raw;
|
|
76
|
+
} else {
|
|
77
|
+
|
|
78
|
+
if (raw > maxTranslate) {
|
|
79
|
+
translateX.value = maxTranslate + (raw - maxTranslate) * 0.3;
|
|
80
|
+
} else if (raw < minTranslate) {
|
|
81
|
+
translateX.value = minTranslate + (raw - minTranslate) * 0.3;
|
|
82
|
+
} else {
|
|
83
|
+
translateX.value = raw;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}).
|
|
87
|
+
onEnd(function (e) {
|
|
88
|
+
var threshold = slideWidth * 0.25;
|
|
89
|
+
var targetIndex = activeIndex;
|
|
90
|
+
|
|
91
|
+
if (e.translationX < -threshold || e.velocityX < -500) {
|
|
92
|
+
targetIndex = activeIndex + 1;
|
|
93
|
+
} else if (e.translationX > threshold || e.velocityX > 500) {
|
|
94
|
+
targetIndex = activeIndex - 1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
var clamped = clampIndex(targetIndex, itemsCount, loop);
|
|
98
|
+
translateX.value = withTiming(-clamped * slideWidth, { duration: 300 }, function (finished) {var _items$clamped;
|
|
99
|
+
if (finished && afterChange) runOnJS(afterChange)(items == null ? void 0 : (_items$clamped = items[clamped]) == null ? void 0 : _items$clamped.key, clamped);
|
|
100
|
+
});
|
|
101
|
+
runOnJS(setGestureAnimating)(true);
|
|
102
|
+
runOnJS(goTo)(targetIndex);
|
|
103
|
+
runOnJS(resumeAutoplay)();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
var track =
|
|
107
|
+
_jsx(Animated.View, { style: [{ flexDirection: 'row', width: slideWidth * itemsCount }, animatedStyle], children:
|
|
108
|
+
items.map(function (item) {return (
|
|
109
|
+
_jsx(View, { style: { width: slideWidth }, children:
|
|
110
|
+
_jsx(SlideContent, { item: item }) }, item.key
|
|
111
|
+
));}
|
|
112
|
+
) }
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
_jsx(View, { hiddenOverflow: true, fullW: true, onLayout: onLayout, children:
|
|
118
|
+
draggable ? _jsx(GestureDetector, { gesture: panGesture, children: track }) : track }
|
|
119
|
+
));
|
|
120
|
+
|
|
121
|
+
}
|