@codeleap/mobile 7.0.0 → 7.0.2
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/Registry.js +47 -0
- package/dist/Registry.js.map +1 -0
- package/dist/components/ActivityIndicator/index.js +28 -0
- package/dist/components/ActivityIndicator/index.js.map +1 -0
- package/dist/components/ActivityIndicator/styles.js +2 -0
- package/dist/components/ActivityIndicator/styles.js.map +1 -0
- package/dist/components/ActivityIndicator/types.js +2 -0
- package/dist/components/ActivityIndicator/types.js.map +1 -0
- package/dist/components/Autocomplete/index.js +150 -0
- package/dist/components/Autocomplete/index.js.map +1 -0
- package/dist/components/Autocomplete/styles.js +2 -0
- package/dist/components/Autocomplete/styles.js.map +1 -0
- package/dist/components/Autocomplete/types.js +2 -0
- package/dist/components/Autocomplete/types.js.map +1 -0
- package/dist/components/Avatar/components/Badge.js +13 -0
- package/dist/components/Avatar/components/Badge.js.map +1 -0
- package/dist/components/Avatar/components/Content.js +19 -0
- package/dist/components/Avatar/components/Content.js.map +1 -0
- package/dist/components/Avatar/components/Illustration.js +11 -0
- package/dist/components/Avatar/components/Illustration.js.map +1 -0
- package/dist/components/Avatar/components/OverlayIcon.js +11 -0
- package/dist/components/Avatar/components/OverlayIcon.js.map +1 -0
- package/dist/components/Avatar/components/Text.js +19 -0
- package/dist/components/Avatar/components/Text.js.map +1 -0
- package/dist/components/Avatar/components/Wrapper.js +30 -0
- package/dist/components/Avatar/components/Wrapper.js.map +1 -0
- package/dist/components/Avatar/context.js +13 -0
- package/dist/components/Avatar/context.js.map +1 -0
- package/dist/components/Avatar/index.js +35 -0
- package/dist/components/Avatar/index.js.map +1 -0
- package/dist/components/Avatar/styles.js +2 -0
- package/dist/components/Avatar/styles.js.map +1 -0
- package/dist/components/Avatar/types.js +2 -0
- package/dist/components/Avatar/types.js.map +1 -0
- package/dist/components/AvatarGroup/index.js +36 -0
- package/dist/components/AvatarGroup/index.js.map +1 -0
- package/dist/components/AvatarGroup/styles.js +2 -0
- package/dist/components/AvatarGroup/styles.js.map +1 -0
- package/dist/components/AvatarGroup/types.js +2 -0
- package/dist/components/AvatarGroup/types.js.map +1 -0
- package/dist/components/Backdrop/index.js +34 -0
- package/dist/components/Backdrop/index.js.map +1 -0
- package/dist/components/Backdrop/styles.js +2 -0
- package/dist/components/Backdrop/styles.js.map +1 -0
- package/dist/components/Backdrop/types.js +2 -0
- package/dist/components/Backdrop/types.js.map +1 -0
- package/dist/components/Badge/index.js +66 -0
- package/dist/components/Badge/index.js.map +1 -0
- package/dist/components/Badge/styles.js +2 -0
- package/dist/components/Badge/styles.js.map +1 -0
- package/dist/components/Badge/types.js +2 -0
- package/dist/components/Badge/types.js.map +1 -0
- package/dist/components/Button/index.js +73 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Button/styles.js +2 -0
- package/dist/components/Button/styles.js.map +1 -0
- package/dist/components/Button/types.js +2 -0
- package/dist/components/Button/types.js.map +1 -0
- package/dist/components/Calendar/index.js +100 -0
- package/dist/components/Calendar/index.js.map +1 -0
- package/dist/components/Calendar/styles.js +2 -0
- package/dist/components/Calendar/styles.js.map +1 -0
- package/dist/components/Calendar/types.js +2 -0
- package/dist/components/Calendar/types.js.map +1 -0
- package/dist/components/CalendarInput/index.js +67 -0
- package/dist/components/CalendarInput/index.js.map +1 -0
- package/dist/components/CalendarInput/styles.js +2 -0
- package/dist/components/CalendarInput/styles.js.map +1 -0
- package/dist/components/CalendarInput/types.js +2 -0
- package/dist/components/CalendarInput/types.js.map +1 -0
- package/dist/components/Checkbox/index.js +85 -0
- package/dist/components/Checkbox/index.js.map +1 -0
- package/dist/components/Checkbox/styles.js +2 -0
- package/dist/components/Checkbox/styles.js.map +1 -0
- package/dist/components/Checkbox/types.js +2 -0
- package/dist/components/Checkbox/types.js.map +1 -0
- package/dist/components/Collapse/index.js +45 -0
- package/dist/components/Collapse/index.js.map +1 -0
- package/dist/components/Collapse/types.js +2 -0
- package/dist/components/Collapse/types.js.map +1 -0
- package/dist/components/DatePickerModal/index.js +107 -0
- package/dist/components/DatePickerModal/index.js.map +1 -0
- package/dist/components/DatePickerModal/styles.js +2 -0
- package/dist/components/DatePickerModal/styles.js.map +1 -0
- package/dist/components/DatePickerModal/types.js +2 -0
- package/dist/components/DatePickerModal/types.js.map +1 -0
- package/dist/components/EmptyPlaceholder/components/Button.js +15 -0
- package/dist/components/EmptyPlaceholder/components/Button.js.map +1 -0
- package/dist/components/EmptyPlaceholder/components/Content.js +36 -0
- package/dist/components/EmptyPlaceholder/components/Content.js.map +1 -0
- package/dist/components/EmptyPlaceholder/components/Illustration.js +9 -0
- package/dist/components/EmptyPlaceholder/components/Illustration.js.map +1 -0
- package/dist/components/EmptyPlaceholder/components/Info.js +9 -0
- package/dist/components/EmptyPlaceholder/components/Info.js.map +1 -0
- package/dist/components/EmptyPlaceholder/components/Loading.js +20 -0
- package/dist/components/EmptyPlaceholder/components/Loading.js.map +1 -0
- package/dist/components/EmptyPlaceholder/context.js +13 -0
- package/dist/components/EmptyPlaceholder/context.js.map +1 -0
- package/dist/components/EmptyPlaceholder/index.js +38 -0
- package/dist/components/EmptyPlaceholder/index.js.map +1 -0
- package/dist/components/EmptyPlaceholder/styles.js +2 -0
- package/dist/components/EmptyPlaceholder/styles.js.map +1 -0
- package/dist/components/EmptyPlaceholder/types.js +2 -0
- package/dist/components/EmptyPlaceholder/types.js.map +1 -0
- package/dist/components/FileInput/index.js +126 -0
- package/dist/components/FileInput/index.js.map +1 -0
- package/dist/components/FileInput/types.js +2 -0
- package/dist/components/FileInput/types.js.map +1 -0
- package/dist/components/Grid/index.js +65 -0
- package/dist/components/Grid/index.js.map +1 -0
- package/dist/components/Grid/styles.js +2 -0
- package/dist/components/Grid/styles.js.map +1 -0
- package/dist/components/Grid/types.js +2 -0
- package/dist/components/Grid/types.js.map +1 -0
- package/dist/components/Icon/index.js +59 -0
- package/dist/components/Icon/index.js.map +1 -0
- package/dist/components/Icon/styles.js +2 -0
- package/dist/components/Icon/styles.js.map +1 -0
- package/dist/components/Icon/types.js +2 -0
- package/dist/components/Icon/types.js.map +1 -0
- package/dist/components/Image/index.js +108 -0
- package/dist/components/Image/index.js.map +1 -0
- package/dist/components/Image/styles.js +2 -0
- package/dist/components/Image/styles.js.map +1 -0
- package/dist/components/Image/types.js +2 -0
- package/dist/components/Image/types.js.map +1 -0
- package/dist/components/ImageView/Spotlight.js +139 -0
- package/dist/components/ImageView/Spotlight.js.map +1 -0
- package/dist/components/ImageView/component.js +17 -0
- package/dist/components/ImageView/component.js.map +1 -0
- package/dist/components/ImageView/index.js +3 -0
- package/dist/components/ImageView/index.js.map +1 -0
- package/dist/components/InputBase/index.js +37 -0
- package/dist/components/InputBase/index.js.map +1 -0
- package/dist/components/InputBase/styles.js +98 -0
- package/dist/components/InputBase/styles.js.map +1 -0
- package/dist/components/InputBase/types.js +2 -0
- package/dist/components/InputBase/types.js.map +1 -0
- package/dist/components/InputBase/useInputBase.js +48 -0
- package/dist/components/InputBase/useInputBase.js.map +1 -0
- package/dist/components/InputBase/useInputBasePartialStyles.js +35 -0
- package/dist/components/InputBase/useInputBasePartialStyles.js.map +1 -0
- package/dist/components/InputBase/utils.js +31 -0
- package/dist/components/InputBase/utils.js.map +1 -0
- package/dist/components/InputOverlay/index.js +68 -0
- package/dist/components/InputOverlay/index.js.map +1 -0
- package/dist/components/InputOverlay/store.js +49 -0
- package/dist/components/InputOverlay/store.js.map +1 -0
- package/dist/components/InputOverlay/types.js +2 -0
- package/dist/components/InputOverlay/types.js.map +1 -0
- package/dist/components/List/index.js +66 -0
- package/dist/components/List/index.js.map +1 -0
- package/dist/components/List/styles.js +2 -0
- package/dist/components/List/styles.js.map +1 -0
- package/dist/components/List/types.js +2 -0
- package/dist/components/List/types.js.map +1 -0
- package/dist/components/LoadingOverlay/index.js +51 -0
- package/dist/components/LoadingOverlay/index.js.map +1 -0
- package/dist/components/LoadingOverlay/styles.js +2 -0
- package/dist/components/LoadingOverlay/styles.js.map +1 -0
- package/dist/components/LoadingOverlay/types.js +2 -0
- package/dist/components/LoadingOverlay/types.js.map +1 -0
- package/dist/components/Modal/index.js +76 -0
- package/dist/components/Modal/index.js.map +1 -0
- package/dist/components/Modal/styles.js +2 -0
- package/dist/components/Modal/styles.js.map +1 -0
- package/dist/components/Modal/types.js +2 -0
- package/dist/components/Modal/types.js.map +1 -0
- package/dist/components/NumberIncrement/index.js +120 -0
- package/dist/components/NumberIncrement/index.js.map +1 -0
- package/dist/components/NumberIncrement/styles.js +2 -0
- package/dist/components/NumberIncrement/styles.js.map +1 -0
- package/dist/components/NumberIncrement/types.js +2 -0
- package/dist/components/NumberIncrement/types.js.map +1 -0
- package/dist/components/NumberIncrement/useNumberIncrement.js +116 -0
- package/dist/components/NumberIncrement/useNumberIncrement.js.map +1 -0
- package/dist/components/Pager/PagerDots.js +19 -0
- package/dist/components/Pager/PagerDots.js.map +1 -0
- package/dist/components/Pager/PagerItem.js +14 -0
- package/dist/components/Pager/PagerItem.js.map +1 -0
- package/dist/components/Pager/index.js +78 -0
- package/dist/components/Pager/index.js.map +1 -0
- package/dist/components/Pager/styles.js +2 -0
- package/dist/components/Pager/styles.js.map +1 -0
- package/dist/components/Pager/types.js +2 -0
- package/dist/components/Pager/types.js.map +1 -0
- package/dist/components/PaginationIndicator/index.js +36 -0
- package/dist/components/PaginationIndicator/index.js.map +1 -0
- package/dist/components/PaginationIndicator/styles.js +2 -0
- package/dist/components/PaginationIndicator/styles.js.map +1 -0
- package/dist/components/PaginationIndicator/types.js +2 -0
- package/dist/components/PaginationIndicator/types.js.map +1 -0
- package/dist/components/PlacesAutocomplete/index.js +71 -0
- package/dist/components/PlacesAutocomplete/index.js.map +1 -0
- package/dist/components/PlacesAutocomplete/styles.js +2 -0
- package/dist/components/PlacesAutocomplete/styles.js.map +1 -0
- package/dist/components/PlacesAutocomplete/types.js +2 -0
- package/dist/components/PlacesAutocomplete/types.js.map +1 -0
- package/dist/components/RadioInput/index.js +47 -0
- package/dist/components/RadioInput/index.js.map +1 -0
- package/dist/components/RadioInput/styles.js +2 -0
- package/dist/components/RadioInput/styles.js.map +1 -0
- package/dist/components/RadioInput/types.js +2 -0
- package/dist/components/RadioInput/types.js.map +1 -0
- package/dist/components/RefreshControl/index.js +27 -0
- package/dist/components/RefreshControl/index.js.map +1 -0
- package/dist/components/RefreshControl/styles.js +2 -0
- package/dist/components/RefreshControl/styles.js.map +1 -0
- package/dist/components/RefreshControl/types.js +2 -0
- package/dist/components/RefreshControl/types.js.map +1 -0
- package/dist/components/Scroll/index.js +40 -0
- package/dist/components/Scroll/index.js.map +1 -0
- package/dist/components/Scroll/styles.js +2 -0
- package/dist/components/Scroll/styles.js.map +1 -0
- package/dist/components/Scroll/types.js +2 -0
- package/dist/components/Scroll/types.js.map +1 -0
- package/dist/components/SearchInput/index.js +48 -0
- package/dist/components/SearchInput/index.js.map +1 -0
- package/dist/components/SectionFilters/context.js +6 -0
- package/dist/components/SectionFilters/context.js.map +1 -0
- package/dist/components/SectionFilters/index.js +47 -0
- package/dist/components/SectionFilters/index.js.map +1 -0
- package/dist/components/SectionFilters/types.js +2 -0
- package/dist/components/SectionFilters/types.js.map +1 -0
- package/dist/components/SectionFilters/useSectionFilters.js +148 -0
- package/dist/components/SectionFilters/useSectionFilters.js.map +1 -0
- package/dist/components/Sections/index.js +105 -0
- package/dist/components/Sections/index.js.map +1 -0
- package/dist/components/Sections/styles.js +2 -0
- package/dist/components/Sections/styles.js.map +1 -0
- package/dist/components/Sections/types.js +2 -0
- package/dist/components/Sections/types.js.map +1 -0
- package/dist/components/SegmentedControl/Option.js +20 -0
- package/dist/components/SegmentedControl/Option.js.map +1 -0
- package/dist/components/SegmentedControl/index.js +130 -0
- package/dist/components/SegmentedControl/index.js.map +1 -0
- package/dist/components/SegmentedControl/styles.js +2 -0
- package/dist/components/SegmentedControl/styles.js.map +1 -0
- package/dist/components/SegmentedControl/types.js +2 -0
- package/dist/components/SegmentedControl/types.js.map +1 -0
- package/dist/components/Select/index.js +204 -0
- package/dist/components/Select/index.js.map +1 -0
- package/dist/components/Select/styles.js +2 -0
- package/dist/components/Select/styles.js.map +1 -0
- package/dist/components/Select/types.js +2 -0
- package/dist/components/Select/types.js.map +1 -0
- package/dist/components/Slider/index.js +99 -0
- package/dist/components/Slider/index.js.map +1 -0
- package/dist/components/Slider/styles.js +2 -0
- package/dist/components/Slider/styles.js.map +1 -0
- package/dist/components/Slider/types.js +2 -0
- package/dist/components/Slider/types.js.map +1 -0
- package/dist/components/SortablePhotos/index.js +85 -0
- package/dist/components/SortablePhotos/index.js.map +1 -0
- package/dist/components/SortablePhotos/styles.js +2 -0
- package/dist/components/SortablePhotos/styles.js.map +1 -0
- package/dist/components/SortablePhotos/types.js +2 -0
- package/dist/components/SortablePhotos/types.js.map +1 -0
- package/dist/components/SortablePhotos/useSortablePhotos.js +143 -0
- package/dist/components/SortablePhotos/useSortablePhotos.js.map +1 -0
- package/dist/components/Switch/index.js +81 -0
- package/dist/components/Switch/index.js.map +1 -0
- package/dist/components/Switch/styles.js +2 -0
- package/dist/components/Switch/styles.js.map +1 -0
- package/dist/components/Switch/types.js +2 -0
- package/dist/components/Switch/types.js.map +1 -0
- package/dist/components/Tabs/Context.js +44 -0
- package/dist/components/Tabs/Context.js.map +1 -0
- package/dist/components/Tabs/Panel.js +21 -0
- package/dist/components/Tabs/Panel.js.map +1 -0
- package/dist/components/Tabs/Tab.js +28 -0
- package/dist/components/Tabs/Tab.js.map +1 -0
- package/dist/components/Tabs/TabList.js +16 -0
- package/dist/components/Tabs/TabList.js.map +1 -0
- package/dist/components/Tabs/index.js +34 -0
- package/dist/components/Tabs/index.js.map +1 -0
- package/dist/components/Tabs/styles.js +2 -0
- package/dist/components/Tabs/styles.js.map +1 -0
- package/dist/components/Tabs/types.js +2 -0
- package/dist/components/Tabs/types.js.map +1 -0
- package/dist/components/Text/index.js +82 -0
- package/dist/components/Text/index.js.map +1 -0
- package/dist/components/Text/styles.js +2 -0
- package/dist/components/Text/styles.js.map +1 -0
- package/dist/components/Text/types.js +2 -0
- package/dist/components/Text/types.js.map +1 -0
- package/dist/components/TextInput/index.js +99 -0
- package/dist/components/TextInput/index.js.map +1 -0
- package/dist/components/TextInput/styles.js +2 -0
- package/dist/components/TextInput/styles.js.map +1 -0
- package/dist/components/TextInput/types.js +2 -0
- package/dist/components/TextInput/types.js.map +1 -0
- package/dist/components/TextInput/useTextInput.js +66 -0
- package/dist/components/TextInput/useTextInput.js.map +1 -0
- package/dist/components/TimeInput/index.js +50 -0
- package/dist/components/TimeInput/index.js.map +1 -0
- package/dist/components/TimeInput/styles.js +2 -0
- package/dist/components/TimeInput/styles.js.map +1 -0
- package/dist/components/TimeInput/types.js +2 -0
- package/dist/components/TimeInput/types.js.map +1 -0
- package/dist/components/Touchable/index.js +170 -0
- package/dist/components/Touchable/index.js.map +1 -0
- package/dist/components/Touchable/styles.js +2 -0
- package/dist/components/Touchable/styles.js.map +1 -0
- package/dist/components/Touchable/types.js +2 -0
- package/dist/components/Touchable/types.js.map +1 -0
- package/dist/components/View/index.js +28 -0
- package/dist/components/View/index.js.map +1 -0
- package/dist/components/View/styles.js +2 -0
- package/dist/components/View/styles.js.map +1 -0
- package/dist/components/View/types.js +2 -0
- package/dist/components/View/types.js.map +1 -0
- package/dist/components/components.js +46 -0
- package/dist/components/components.js.map +1 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useAnimatedState.js +28 -0
- package/dist/hooks/useAnimatedState.js.map +1 -0
- package/dist/hooks/useAppState.js +16 -0
- package/dist/hooks/useAppState.js.map +1 -0
- package/dist/hooks/useKeyboardController.js +22 -0
- package/dist/hooks/useKeyboardController.js.map +1 -0
- package/dist/hooks/useStatusBar.js +18 -0
- package/dist/hooks/useStatusBar.js.map +1 -0
- package/dist/hooks/useStylesFor.js +13 -0
- package/dist/hooks/useStylesFor.js.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/PressableRipple/index.js +3 -0
- package/dist/modules/PressableRipple/index.js.map +1 -0
- package/dist/modules/PressableRipple/ripple.js +168 -0
- package/dist/modules/PressableRipple/ripple.js.map +1 -0
- package/dist/modules/PressableRipple/styles.js +18 -0
- package/dist/modules/PressableRipple/styles.js.map +1 -0
- package/dist/modules/PressableRipple/type.js +2 -0
- package/dist/modules/PressableRipple/type.js.map +1 -0
- package/dist/modules/backgroundTimer.js +33 -0
- package/dist/modules/backgroundTimer.js.map +1 -0
- package/dist/modules/formConfig.js +26 -0
- package/dist/modules/formConfig.js.map +1 -0
- package/dist/modules/index.js +3 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/reactNavigation.js +39 -0
- package/dist/modules/reactNavigation.js.map +1 -0
- package/dist/modules/scroll.js +59 -0
- package/dist/modules/scroll.js.map +1 -0
- package/dist/modules/textInputMask.js +7 -0
- package/dist/modules/textInputMask.js.map +1 -0
- package/dist/modules/types/textInputMask.js +2 -0
- package/dist/modules/types/textInputMask.js.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/utility.js +2 -0
- package/dist/types/utility.js.map +1 -0
- package/dist/utils/NotificationManager/index.js +170 -0
- package/dist/utils/NotificationManager/index.js.map +1 -0
- package/dist/utils/NotificationManager/types.js +2 -0
- package/dist/utils/NotificationManager/types.js.map +1 -0
- package/dist/utils/OSAlert.js +128 -0
- package/dist/utils/OSAlert.js.map +1 -0
- package/dist/utils/StorageManager.js +84 -0
- package/dist/utils/StorageManager.js.map +1 -0
- package/dist/utils/Subscription.js +48 -0
- package/dist/utils/Subscription.js.map +1 -0
- package/dist/utils/hooks.js +199 -0
- package/dist/utils/hooks.js.map +1 -0
- package/dist/utils/index.js +11 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/input.js +45 -0
- package/dist/utils/input.js.map +1 -0
- package/dist/utils/locale.js +11 -0
- package/dist/utils/locale.js.map +1 -0
- package/dist/utils/misc.js +111 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/theme.js +37 -0
- package/dist/utils/theme.js.map +1 -0
- package/dist/utils/useQueryListRefresh.js +33 -0
- package/dist/utils/useQueryListRefresh.js.map +1 -0
- package/package.json +19 -19
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import React, { PureComponent } from 'react';
|
|
4
|
+
import { View, Animated, Easing, Platform, TouchableWithoutFeedback, I18nManager } from 'react-native';
|
|
5
|
+
import { styles, radius } from './styles.js';
|
|
6
|
+
export default class Ripple extends PureComponent {
|
|
7
|
+
static defaultProps = {
|
|
8
|
+
...TouchableWithoutFeedback.defaultProps,
|
|
9
|
+
rippleColor: 'rgb(0, 0, 0)',
|
|
10
|
+
rippleOpacity: 0.30,
|
|
11
|
+
rippleDuration: 400,
|
|
12
|
+
rippleSize: 0,
|
|
13
|
+
rippleContainerBorderRadius: 0,
|
|
14
|
+
rippleCentered: false,
|
|
15
|
+
rippleSequential: false,
|
|
16
|
+
rippleFades: true,
|
|
17
|
+
disabled: false,
|
|
18
|
+
onRippleAnimation: (animation, callback) => animation.start(callback),
|
|
19
|
+
};
|
|
20
|
+
static propTypes = {
|
|
21
|
+
...Animated.View.propTypes,
|
|
22
|
+
...TouchableWithoutFeedback.propTypes,
|
|
23
|
+
rippleColor: PropTypes.string,
|
|
24
|
+
rippleOpacity: PropTypes.number,
|
|
25
|
+
rippleDuration: PropTypes.number,
|
|
26
|
+
rippleSize: PropTypes.number,
|
|
27
|
+
rippleContainerBorderRadius: PropTypes.number,
|
|
28
|
+
rippleCentered: PropTypes.bool,
|
|
29
|
+
rippleSequential: PropTypes.bool,
|
|
30
|
+
rippleFades: PropTypes.bool,
|
|
31
|
+
disabled: PropTypes.bool,
|
|
32
|
+
onRippleAnimation: PropTypes.func,
|
|
33
|
+
};
|
|
34
|
+
constructor(props) {
|
|
35
|
+
super(props);
|
|
36
|
+
this.onLayout = this.onLayout.bind(this);
|
|
37
|
+
this.onPress = this.onPress.bind(this);
|
|
38
|
+
this.onPressIn = this.onPressIn.bind(this);
|
|
39
|
+
this.onPressOut = this.onPressOut.bind(this);
|
|
40
|
+
this.onLongPress = this.onLongPress.bind(this);
|
|
41
|
+
this.onAnimationEnd = this.onAnimationEnd.bind(this);
|
|
42
|
+
this.renderRipple = this.renderRipple.bind(this);
|
|
43
|
+
this.unique = 0;
|
|
44
|
+
this.mounted = false;
|
|
45
|
+
this.state = {
|
|
46
|
+
width: 0,
|
|
47
|
+
height: 0,
|
|
48
|
+
ripples: [],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
componentDidMount() {
|
|
52
|
+
this.mounted = true;
|
|
53
|
+
}
|
|
54
|
+
componentWillUnmount() {
|
|
55
|
+
this.mounted = false;
|
|
56
|
+
}
|
|
57
|
+
onLayout(event) {
|
|
58
|
+
let { width, height } = event.nativeEvent.layout;
|
|
59
|
+
let { onLayout } = this.props;
|
|
60
|
+
if ('function' === typeof onLayout) {
|
|
61
|
+
onLayout(event);
|
|
62
|
+
}
|
|
63
|
+
this.setState({ width, height });
|
|
64
|
+
}
|
|
65
|
+
onPress(event) {
|
|
66
|
+
let { onPress } = this.props;
|
|
67
|
+
if ('function' === typeof onPress) {
|
|
68
|
+
onPress(event);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
onLongPress(event) {
|
|
72
|
+
let { onLongPress } = this.props;
|
|
73
|
+
if ('function' === typeof onLongPress) {
|
|
74
|
+
requestAnimationFrame(() => onLongPress(event));
|
|
75
|
+
}
|
|
76
|
+
this.startRipple(event);
|
|
77
|
+
}
|
|
78
|
+
onPressIn(event) {
|
|
79
|
+
let { onPressIn } = this.props;
|
|
80
|
+
if ('function' === typeof onPressIn) {
|
|
81
|
+
onPressIn(event);
|
|
82
|
+
}
|
|
83
|
+
this.startRipple(event);
|
|
84
|
+
}
|
|
85
|
+
onPressOut(event) {
|
|
86
|
+
let { onPressOut } = this.props;
|
|
87
|
+
if ('function' === typeof onPressOut) {
|
|
88
|
+
onPressOut(event);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
onAnimationEnd() {
|
|
92
|
+
if (this.mounted) {
|
|
93
|
+
this.setState(({ ripples }) => ({ ripples: ripples.slice(1) }));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
startRipple(event) {
|
|
97
|
+
let { width, height } = this.state;
|
|
98
|
+
let { rippleDuration, rippleCentered, rippleSize, onRippleAnimation, } = this.props;
|
|
99
|
+
let w2 = 0.5 * width;
|
|
100
|
+
let h2 = 0.5 * height;
|
|
101
|
+
let { locationX, locationY } = rippleCentered ?
|
|
102
|
+
{ locationX: w2, locationY: h2 } :
|
|
103
|
+
event.nativeEvent;
|
|
104
|
+
let offsetX = Math.abs(w2 - locationX);
|
|
105
|
+
let offsetY = Math.abs(h2 - locationY);
|
|
106
|
+
let R = rippleSize > 0 ?
|
|
107
|
+
0.5 * rippleSize :
|
|
108
|
+
Math.sqrt(Math.pow(w2 + offsetX, 2) + Math.pow(h2 + offsetY, 2));
|
|
109
|
+
let ripple = {
|
|
110
|
+
unique: this.unique++,
|
|
111
|
+
progress: new Animated.Value(0),
|
|
112
|
+
locationX,
|
|
113
|
+
locationY,
|
|
114
|
+
R,
|
|
115
|
+
};
|
|
116
|
+
let animation = Animated
|
|
117
|
+
.timing(ripple.progress, {
|
|
118
|
+
toValue: 1,
|
|
119
|
+
easing: Easing.out(Easing.ease),
|
|
120
|
+
duration: rippleDuration,
|
|
121
|
+
useNativeDriver: true,
|
|
122
|
+
});
|
|
123
|
+
onRippleAnimation(animation, this.onAnimationEnd);
|
|
124
|
+
this.setState(({ ripples }) => ({ ripples: ripples.concat(ripple) }));
|
|
125
|
+
}
|
|
126
|
+
renderRipple({ unique, progress, locationX, locationY, R }) {
|
|
127
|
+
let { rippleColor, color = rippleColor, rippleOpacity, rippleFades } = this.props;
|
|
128
|
+
let rippleStyle = {
|
|
129
|
+
top: locationY - radius,
|
|
130
|
+
[I18nManager.isRTL ? 'right' : 'left']: locationX - radius,
|
|
131
|
+
backgroundColor: color,
|
|
132
|
+
transform: [{
|
|
133
|
+
scale: progress.interpolate({
|
|
134
|
+
inputRange: [0, 1],
|
|
135
|
+
outputRange: [0.5 / radius, R / radius],
|
|
136
|
+
}),
|
|
137
|
+
}],
|
|
138
|
+
opacity: rippleFades ?
|
|
139
|
+
progress.interpolate({
|
|
140
|
+
inputRange: [0, 1],
|
|
141
|
+
outputRange: [rippleOpacity, 0],
|
|
142
|
+
}) :
|
|
143
|
+
rippleOpacity,
|
|
144
|
+
};
|
|
145
|
+
return (_jsx(Animated.View, { style: [styles.ripple, rippleStyle] }, unique));
|
|
146
|
+
}
|
|
147
|
+
render() {
|
|
148
|
+
let { ripples } = this.state;
|
|
149
|
+
let { delayLongPress, delayPressIn, delayPressOut, disabled, hitSlop, pressRetentionOffset, children, rippleContainerBorderRadius, testID, nativeID, accessible, accessibilityHint, accessibilityLabel, onPress, onLongPress, onLayout, onRippleAnimation, rippleColor, rippleOpacity, rippleDuration, rippleSize, rippleCentered, rippleSequential, rippleFades, ref, radiusStyles, ...props } = this.props;
|
|
150
|
+
let touchableProps = {
|
|
151
|
+
disabled,
|
|
152
|
+
hitSlop,
|
|
153
|
+
pressRetentionOffset,
|
|
154
|
+
testID,
|
|
155
|
+
accessible,
|
|
156
|
+
accessibilityHint,
|
|
157
|
+
accessibilityLabel,
|
|
158
|
+
onLayout: this.onLayout,
|
|
159
|
+
onPress: this.onPress,
|
|
160
|
+
onPressIn: this.onPressIn,
|
|
161
|
+
onPressOut: this.onPressOut,
|
|
162
|
+
onLongPress: onLongPress ? this.onLongPress : undefined,
|
|
163
|
+
...('web' !== Platform.OS ? { nativeID } : null),
|
|
164
|
+
};
|
|
165
|
+
return (_jsx(TouchableWithoutFeedback, { ...touchableProps, ref: ref, children: _jsxs(Animated.View, { ...props, children: [children, _jsx(View, { style: [styles.container, radiusStyles], pointerEvents: 'none', children: ripples.map(this.renderRipple) })] }) }));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=ripple.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ripple.js","sourceRoot":"","sources":["../../../src/modules/PressableRipple/ripple.js"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACtG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAE5C,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,aAAa;IAC/C,MAAM,CAAC,YAAY,GAAG;QACpB,GAAG,wBAAwB,CAAC,YAAY;QAExC,WAAW,EAAE,cAAc;QAC3B,aAAa,EAAE,IAAI;QACnB,cAAc,EAAE,GAAG;QACnB,UAAU,EAAE,CAAC;QACb,2BAA2B,EAAE,CAAC;QAC9B,cAAc,EAAE,KAAK;QACrB,gBAAgB,EAAE,KAAK;QACvB,WAAW,EAAE,IAAI;QACjB,QAAQ,EAAE,KAAK;QAEf,iBAAiB,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC;KACtE,CAAA;IAED,MAAM,CAAC,SAAS,GAAG;QACjB,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS;QAC1B,GAAG,wBAAwB,CAAC,SAAS;QAErC,WAAW,EAAE,SAAS,CAAC,MAAM;QAC7B,aAAa,EAAE,SAAS,CAAC,MAAM;QAC/B,cAAc,EAAE,SAAS,CAAC,MAAM;QAChC,UAAU,EAAE,SAAS,CAAC,MAAM;QAC5B,2BAA2B,EAAE,SAAS,CAAC,MAAM;QAC7C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AAI,OAAK,KAAK,aACrB,QAAQ,EACT,KAAC,IAAI,IAAC,KAAK,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,aAAa,EAAC,MAAM,YAChE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,GAC1B,IACO,GACS,CAC5B,CAAA;IACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
const radius = 10;
|
|
3
|
+
const styles = StyleSheet.create({
|
|
4
|
+
container: {
|
|
5
|
+
...StyleSheet.absoluteFillObject,
|
|
6
|
+
backgroundColor: 'transparent',
|
|
7
|
+
overflow: 'hidden',
|
|
8
|
+
},
|
|
9
|
+
ripple: {
|
|
10
|
+
width: radius * 2,
|
|
11
|
+
height: radius * 2,
|
|
12
|
+
borderRadius: radius,
|
|
13
|
+
overflow: 'hidden',
|
|
14
|
+
position: 'absolute',
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
export { styles, radius };
|
|
18
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/modules/PressableRipple/styles.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,MAAM,MAAM,GAAG,EAAE,CAAA;AAEjB,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,GAAG,UAAU,CAAC,kBAAkB;QAEhC,eAAe,EAAE,aAAa;QAC9B,QAAQ,EAAE,QAAQ;KACnB;IAED,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,GAAG,CAAC;QACjB,MAAM,EAAE,MAAM,GAAG,CAAC;QAClB,YAAY,EAAE,MAAM;QACpB,QAAQ,EAAE,QAAQ;QAClB,QAAQ,EAAE,UAAU;KACrB;CACF,CAAC,CAAA;AAEF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../../src/modules/PressableRipple/type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import uuid from 'react-native-uuid';
|
|
2
|
+
/**
|
|
3
|
+
* Timer maps are module-level singletons keyed by caller-supplied `ref` strings so that disparate call sites (e.g. a button handler and an effect) can share and cancel the same logical timer without passing the id through props. If no `ref` is provided a UUID is generated, making each call site independent — callers must capture and reuse the returned ref to cancel or coalesce subsequent calls.
|
|
4
|
+
*/
|
|
5
|
+
const throttleTimerId = {};
|
|
6
|
+
export function throttle(func, ref, delay = 200) {
|
|
7
|
+
if (!ref) {
|
|
8
|
+
ref = uuid.v4();
|
|
9
|
+
}
|
|
10
|
+
if (throttleTimerId[ref]) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
throttleTimerId[ref] = setTimeout(function () {
|
|
14
|
+
func();
|
|
15
|
+
throttleTimerId[ref] = undefined;
|
|
16
|
+
}, delay);
|
|
17
|
+
return ref;
|
|
18
|
+
}
|
|
19
|
+
const debounceTimerId = {};
|
|
20
|
+
export function debounce(func, ref, delay = 200) {
|
|
21
|
+
if (!ref) {
|
|
22
|
+
ref = uuid.v4();
|
|
23
|
+
}
|
|
24
|
+
if (debounceTimerId[ref]) {
|
|
25
|
+
clearTimeout(debounceTimerId[ref]);
|
|
26
|
+
}
|
|
27
|
+
debounceTimerId[ref] = setTimeout(function () {
|
|
28
|
+
func();
|
|
29
|
+
debounceTimerId[ref] = undefined;
|
|
30
|
+
}, delay);
|
|
31
|
+
return ref;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=backgroundTimer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backgroundTimer.js","sourceRoot":"","sources":["../../src/modules/backgroundTimer.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,mBAAmB,CAAA;AAEpC;;GAEG;AACH,MAAM,eAAe,GAAG,EAAE,CAAA;AAE1B,MAAM,UAAU,QAAQ,CAAC,IAAiB,EAAE,GAAY,EAAE,KAAK,GAAG,GAAG;IACnE,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,GAAG,GAAG,IAAI,CAAC,EAAE,EAAY,CAAA;IAC3B,CAAC;IACD,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,OAAM;IACR,CAAC;IACD,eAAe,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC;QAChC,IAAI,EAAE,CAAA;QACN,eAAe,CAAC,GAAG,CAAC,GAAG,SAAS,CAAA;IAClC,CAAC,EAAE,KAAK,CAAC,CAAA;IAET,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,MAAM,eAAe,GAAG,EAAE,CAAA;AAE1B,MAAM,UAAU,QAAQ,CAAC,IAAiB,EAAE,GAAY,EAAE,KAAK,GAAG,GAAG;IACnE,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,GAAG,GAAG,IAAI,CAAC,EAAE,EAAY,CAAA;IAC3B,CAAC;IAED,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,YAAY,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAA;IACpC,CAAC;IAED,eAAe,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC;QAChC,IAAI,EAAE,CAAA;QACN,eAAe,CAAC,GAAG,CAAC,GAAG,SAAS,CAAA;IAClC,CAAC,EAAE,KAAK,CAAC,CAAA;IAET,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Field } from '@codeleap/form';
|
|
2
|
+
import { StatusBar } from 'react-native';
|
|
3
|
+
Field.methodGetPadding = (field) => {
|
|
4
|
+
return StatusBar.currentHeight - 16;
|
|
5
|
+
};
|
|
6
|
+
Field.methodMeasurePosition = (field, wrapperRef) => {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
wrapperRef.current.measure((x, y, width, height, pageX, pageY) => {
|
|
9
|
+
resolve({ x, y, width, height, pageX, pageY });
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
Field.methodScrollTo = (field, scrollRef, measure) => {
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
const target = measure?.pageY - field.getPadding();
|
|
16
|
+
const unsub = scrollRef.current.subscribe('onMomentumScrollEnd', e => {
|
|
17
|
+
resolve(null);
|
|
18
|
+
unsub();
|
|
19
|
+
});
|
|
20
|
+
scrollRef.current.scrollTo({
|
|
21
|
+
y: target,
|
|
22
|
+
animated: true,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=formConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formConfig.js","sourceRoot":"","sources":["../../src/modules/formConfig.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAQ,MAAM,cAAc,CAAA;AAG9C,KAAK,CAAC,gBAAgB,GAAG,CAAC,KAAK,EAAE,EAAE;IACjC,OAAO,SAAS,CAAC,aAAa,GAAG,EAAE,CAAA;AACrC,CAAC,CAAA;AAED,KAAK,CAAC,qBAAqB,GAAG,CAAC,KAAK,EAAE,UAAwC,EAAE,EAAE;IAChF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,UAAU,CAAC,OAAO,CAAC,OAAO,CACxB,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YACpC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;QAChD,CAAC,CACF,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,KAAK,CAAC,cAAc,GAAG,CAAC,KAAK,EAAE,SAA6C,EAAE,OAAO,EAAE,EAAE;IACvF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,OAAO,EAAE,KAAK,GAAG,KAAK,CAAC,UAAU,EAAE,CAAA;QAElD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,qBAAqB,EAAE,CAAC,CAAC,EAAE;YACnE,OAAO,CAAC,IAAI,CAAC,CAAA;YACb,KAAK,EAAE,CAAA;QACT,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC;YACzB,CAAC,EAAE,MAAM;YACT,QAAQ,EAAE,IAAI;SACf,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { deepMerge } from '@codeleap/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Accesses `config.screenOptions` and `group.screenOptions` via `@ts-ignore` because `@react-navigation/native` does not expose these properties in the public `TreeStack` type — they exist at runtime but are considered internal to the static navigation builder. If React Navigation changes this internal shape, the extraction will silently return empty options rather than throwing.
|
|
4
|
+
*/
|
|
5
|
+
export function staticNavigationExtractOptions(stack) {
|
|
6
|
+
const { config } = stack;
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
const defaultOptions = config.screenOptions;
|
|
9
|
+
let result = {};
|
|
10
|
+
function extractScreens(screens, groupKey, groupOptions) {
|
|
11
|
+
let screenResults = {};
|
|
12
|
+
for (const screenKey in screens) {
|
|
13
|
+
const screen = screens[screenKey];
|
|
14
|
+
const key = groupKey ? `${groupKey}.${screenKey}` : screenKey;
|
|
15
|
+
const isComponentInstance = typeof screen !== 'object';
|
|
16
|
+
const defaultScreenOptions = deepMerge(defaultOptions, groupOptions);
|
|
17
|
+
if (isComponentInstance) {
|
|
18
|
+
screenResults[key] = defaultScreenOptions;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const screenOptions = deepMerge(defaultScreenOptions, screen.options);
|
|
22
|
+
const isNavigationInstance = !!screen?.screen?.config?.screens;
|
|
23
|
+
if (isNavigationInstance) {
|
|
24
|
+
screenResults = deepMerge(screenResults, extractScreens(screen?.screen?.config?.screens, null, screenOptions));
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
screenResults[key] = screenOptions;
|
|
28
|
+
}
|
|
29
|
+
return screenResults;
|
|
30
|
+
}
|
|
31
|
+
for (const groupKey in config.groups) {
|
|
32
|
+
const group = config.groups[groupKey];
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
const groupOptions = group.screenOptions;
|
|
35
|
+
result = deepMerge(result, extractScreens(group.screens, null, groupOptions));
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=reactNavigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactNavigation.js","sourceRoot":"","sources":["../../src/modules/reactNavigation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAK3C;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAAC,KAAgB;IAC7D,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAA;IAExB,aAAa;IACb,MAAM,cAAc,GAAG,MAAM,CAAC,aAAa,CAAA;IAE3C,IAAI,MAAM,GAAG,EAAE,CAAA;IAEf,SAAS,cAAc,CAAC,OAA4B,EAAE,QAAuB,EAAE,YAAuB;QACpG,IAAI,aAAa,GAAG,EAAE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IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { logger } from '@codeleap/logger';
|
|
3
|
+
import React, { useCallback, useContext, useImperativeHandle, useRef } from 'react';
|
|
4
|
+
const scrollProperties = [
|
|
5
|
+
'scrollTo',
|
|
6
|
+
];
|
|
7
|
+
const noOpScrollMethods = Object.fromEntries(scrollProperties.map(p => [p, () => {
|
|
8
|
+
logger.warn(`"${p}" was called from a ScrollProvider ref without a bound scrollable component. This does not cause errors but may impact user experience and indicate an unhandled edge case in calling code`);
|
|
9
|
+
}]));
|
|
10
|
+
const noOpScrollable = {
|
|
11
|
+
...noOpScrollMethods,
|
|
12
|
+
subscribe(e, cb) {
|
|
13
|
+
return () => { };
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const ScrollContext = React.createContext({});
|
|
17
|
+
/**
|
|
18
|
+
* Augments a plain `ScrollView` ref with a pub/sub `subscribe` method so that sibling components (e.g. a floating header) can react to scroll events without prop-drilling. The augmented ref is exposed via `useImperativeHandle` so the parent sees the extended interface; the underlying `ScrollView` ref is called through directly so no native bridge call is duplicated.
|
|
19
|
+
*/
|
|
20
|
+
export const useScrollPubSub = (ref) => {
|
|
21
|
+
const listeners = useRef(new Map());
|
|
22
|
+
const augmentedRef = useRef(null);
|
|
23
|
+
const emit = useCallback((event, e) => {
|
|
24
|
+
listeners.current.forEach((cb, key) => {
|
|
25
|
+
if (key.startsWith(`${event}-`)) {
|
|
26
|
+
cb(e);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}, []);
|
|
30
|
+
useImperativeHandle(augmentedRef, () => ({
|
|
31
|
+
scrollTo(...args) {
|
|
32
|
+
ref?.current.scrollTo(...args);
|
|
33
|
+
},
|
|
34
|
+
subscribe(e, cb) {
|
|
35
|
+
const id = `${e}-${listeners.current.size}`;
|
|
36
|
+
listeners.current.set(id, cb);
|
|
37
|
+
return () => {
|
|
38
|
+
listeners.current.delete(id);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}), [ref]);
|
|
42
|
+
return {
|
|
43
|
+
ref: augmentedRef,
|
|
44
|
+
emit
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export const ScrollProvider = React.forwardRef(({ children }, ref) => {
|
|
48
|
+
return _jsx(ScrollContext.Provider, { value: { ref: ref }, children: children });
|
|
49
|
+
});
|
|
50
|
+
export function useWrappingScrollable() {
|
|
51
|
+
const ctx = useContext(ScrollContext);
|
|
52
|
+
if (!ctx) {
|
|
53
|
+
return {
|
|
54
|
+
current: noOpScrollable
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return ctx.ref;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=scroll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll.js","sourceRoot":"","sources":["../../src/modules/scroll.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,EAAE,EAAoB,WAAW,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAGrG,MAAM,gBAAgB,GAAG;IACtB,UAAU;CACmB,CAAA;AAgBhC,MAAM,iBAAiB,GAAG,MAAM,CAAC,WAAW,CAC1C,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE;QACjC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,4LAA4L,CAAC,CAAA;IAChN,CAAC,CAAC,CAAC,CACJ,CAAA;AAED,MAAM,cAAc,GAAG;IACrB,GAAG,iBAAiB;IACpB,SAAS,CAAC,CAAC,EAAE,EAAE;QACb,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;IACjB,CAAC;CACa,CAAA;AAEhB,MAAM,aAAa,GAAG,KAAK,CAAC,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AQ,EAAC,EAAE,GAAG,EAAE,EAAE;IACtG,OAAO,KAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,GAAG,EAAE,GAAgB,EAAE,YAC5D,QAAQ,GACc,CAAA;AAC3B,CAAC,CAAC,CAAA;AAEF,MAAM,UAAU,qBAAqB;IACnC,MAAM,GAAG,GAAG,UAAU,CAAC,aAAa,CAAC,CAAA;IAErC,IAAG,CAAC,GAAG,EAAC,CAAC;QACP,OAAO;YACL,OAAO,EAAE,cAAc;SACxB,CAAA;IACH,CAAC;IAED,OAAO,GAAG,CAAC,GAAG,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TextInputMask } from 'react-native-masked-text';
|
|
2
|
+
/**
|
|
3
|
+
* Re-exported with a looser type because `react-native-masked-text` does not forward refs in its public typings; the cast to `ForwardRefExoticComponent` lets callers attach a ref to read the raw (unmasked) value via `.getRawValue()` — without the ref the only value accessible is the formatted display string.
|
|
4
|
+
*/
|
|
5
|
+
export const MaskedTextInput = TextInputMask;
|
|
6
|
+
export * from './types/textInputMask';
|
|
7
|
+
//# sourceMappingURL=textInputMask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textInputMask.js","sourceRoot":"","sources":["../../src/modules/textInputMask.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAsB,MAAM,0BAA0B,CAAA;AAE5E;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,aAE7B,CAAA;AAEF,cAAc,uBAAuB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textInputMask.js","sourceRoot":"","sources":["../../../src/modules/types/textInputMask.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../src/types/utility.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import messaging from '@react-native-firebase/messaging';
|
|
2
|
+
import { Subscription } from '../Subscription';
|
|
3
|
+
import { logger } from '@codeleap/logger';
|
|
4
|
+
export * from './types';
|
|
5
|
+
const MODULE = 'NotificationManager';
|
|
6
|
+
/**
|
|
7
|
+
* Requires `@react-native-firebase/messaging` to be installed and the app to have a valid `google-services.json` / `GoogleService-Info.plist`. `initialize` must be awaited at app boot — calling `registerEvent` before `initialize` is safe (events are stored) but `invokeForInitialNotification` will be skipped if `initialized` is already `true`, so calling `initialize` twice silently drops the cold-start notification. `onBackgroundMessage` registers a global Firebase background handler that persists beyond the component lifecycle; it is never automatically cleaned up.
|
|
8
|
+
*/
|
|
9
|
+
export class NotificationManager {
|
|
10
|
+
parser = (message) => message;
|
|
11
|
+
currentOptions = {
|
|
12
|
+
handleInitialNotification: true,
|
|
13
|
+
debug: false,
|
|
14
|
+
slackDebug: false,
|
|
15
|
+
};
|
|
16
|
+
currentToken = null;
|
|
17
|
+
registeredUnsubscribers = {};
|
|
18
|
+
initialized = false;
|
|
19
|
+
events = new Subscription();
|
|
20
|
+
constructor(options = {}) {
|
|
21
|
+
if (typeof options?.parser == 'function') {
|
|
22
|
+
this.parser = options?.parser;
|
|
23
|
+
}
|
|
24
|
+
this.currentOptions = {
|
|
25
|
+
...this.currentOptions,
|
|
26
|
+
...options
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
invoke(args) {
|
|
30
|
+
this.log('Invoke this events:', this.events.getSubscribersKeys());
|
|
31
|
+
this.events.invoke({
|
|
32
|
+
data: this.parser(args?.data),
|
|
33
|
+
type: args?.type
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
log(description, data = '') {
|
|
37
|
+
if (this.currentOptions.debug) {
|
|
38
|
+
logger.log(`(${MODULE})`, description, data);
|
|
39
|
+
}
|
|
40
|
+
if (this.currentOptions.slackDebug) {
|
|
41
|
+
logger.slack.echo(description, data, MODULE, {
|
|
42
|
+
'include': ['version'],
|
|
43
|
+
'sendIn': ['release', 'debug']
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Checks if you are authorized for notifications and returns the result
|
|
49
|
+
*
|
|
50
|
+
* @return hasAuthorization (boolean)
|
|
51
|
+
*/
|
|
52
|
+
async getHasAuthorization() {
|
|
53
|
+
const authStatus = await messaging().hasPermission();
|
|
54
|
+
const hasAuthorization = authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
|
|
55
|
+
authStatus === messaging.AuthorizationStatus.PROVISIONAL;
|
|
56
|
+
return hasAuthorization;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Gets and returns the device token
|
|
60
|
+
*
|
|
61
|
+
* @return token (string) or null if an error occurs
|
|
62
|
+
*/
|
|
63
|
+
async getToken() {
|
|
64
|
+
try {
|
|
65
|
+
const token = await messaging().getToken();
|
|
66
|
+
this.log('Get token', { token });
|
|
67
|
+
this.currentToken = token;
|
|
68
|
+
return token;
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
this.log('Get token error', err);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
onTokenRefresh(cb) {
|
|
76
|
+
const unsubscribe = messaging().onTokenRefresh(newToken => {
|
|
77
|
+
this.log('Refreshed token', { newToken });
|
|
78
|
+
this.currentToken = newToken;
|
|
79
|
+
cb(newToken);
|
|
80
|
+
});
|
|
81
|
+
return unsubscribe;
|
|
82
|
+
}
|
|
83
|
+
async invokeForInitialNotification() {
|
|
84
|
+
if (this.initialized)
|
|
85
|
+
return;
|
|
86
|
+
const initialNotification = await messaging().getInitialNotification();
|
|
87
|
+
this.log('Initial Notification', initialNotification);
|
|
88
|
+
if (!!initialNotification && this.currentOptions.handleInitialNotification) {
|
|
89
|
+
this.invoke({
|
|
90
|
+
data: initialNotification,
|
|
91
|
+
type: 'initial'
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
onBackgroundMessage() {
|
|
96
|
+
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
|
|
97
|
+
this.log('Notification in background:', remoteMessage);
|
|
98
|
+
this.invoke({
|
|
99
|
+
data: remoteMessage,
|
|
100
|
+
type: 'background'
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
return () => messaging().setBackgroundMessageHandler(async () => { });
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Responsible for initializing all notification services: token refresh, background, foreground, press and initial notification
|
|
107
|
+
*
|
|
108
|
+
* @param {function} callback Callback that is executed when the services are initialized, returning the device token
|
|
109
|
+
*/
|
|
110
|
+
async initialize(callback) {
|
|
111
|
+
this.log('Initialize');
|
|
112
|
+
this.unsubscribe();
|
|
113
|
+
const token = await this.getToken();
|
|
114
|
+
callback(token);
|
|
115
|
+
this.invokeForInitialNotification();
|
|
116
|
+
const unsubscribeOnNotificationOpenedApp = messaging().onNotificationOpenedApp(remoteMessage => {
|
|
117
|
+
this.log('Notification pressed:', remoteMessage);
|
|
118
|
+
this.invoke({
|
|
119
|
+
data: remoteMessage,
|
|
120
|
+
type: 'press'
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
this.registeredUnsubscribers['openApp'] = unsubscribeOnNotificationOpenedApp;
|
|
124
|
+
const unsubscribeOnBackgroundMessage = this.onBackgroundMessage();
|
|
125
|
+
this.registeredUnsubscribers['background'] = unsubscribeOnBackgroundMessage;
|
|
126
|
+
const unsubscribeOnMessage = messaging().onMessage(async (remoteMessage) => {
|
|
127
|
+
this.log('Notification in foreground', remoteMessage);
|
|
128
|
+
this.invoke({
|
|
129
|
+
data: remoteMessage,
|
|
130
|
+
type: 'foreground'
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
this.registeredUnsubscribers['foreground'] = unsubscribeOnMessage;
|
|
134
|
+
const unsubscribeOnTokenRefresh = this.onTokenRefresh(callback);
|
|
135
|
+
this.registeredUnsubscribers['refreshToken'] = unsubscribeOnTokenRefresh;
|
|
136
|
+
this.initialized = true;
|
|
137
|
+
}
|
|
138
|
+
async unsubscribe() {
|
|
139
|
+
this.log('Unsubscribe handlers', this.registeredUnsubscribers);
|
|
140
|
+
for (const unsubscribeKey in this.registeredUnsubscribers) {
|
|
141
|
+
this.registeredUnsubscribers[unsubscribeKey]();
|
|
142
|
+
delete this.registeredUnsubscribers[unsubscribeKey];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Unsubscribe all services that have been started
|
|
147
|
+
*
|
|
148
|
+
* @param {function} callback Callback that is executed when the services are deinitialized
|
|
149
|
+
*/
|
|
150
|
+
async deinitialize(callback = null) {
|
|
151
|
+
if (!this.initialized)
|
|
152
|
+
return;
|
|
153
|
+
this.log('Deinitialize');
|
|
154
|
+
this.unsubscribe();
|
|
155
|
+
if (typeof callback == 'function') {
|
|
156
|
+
callback();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Registers an event that will be called by all notification services that have been started
|
|
161
|
+
*
|
|
162
|
+
* @param {string} eventName Event name
|
|
163
|
+
* @param {string} handler Function that will be performed
|
|
164
|
+
* @return unsubscribe event (function)
|
|
165
|
+
*/
|
|
166
|
+
registerEvent(eventName, handler) {
|
|
167
|
+
return this.events.subscribe(eventName, handler);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/NotificationManager/index.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,kCAAkC,CAAA;AACxD,OAAO,EAAc,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE1D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAA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