@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,116 @@
|
|
|
1
|
+
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { useInputBase } from '../InputBase/useInputBase';
|
|
3
|
+
import { TypeGuards } from '@codeleap/types';
|
|
4
|
+
import { fields } from '@codeleap/form';
|
|
5
|
+
/** Beyond this value JS floating-point arithmetic loses integer precision, so increment/decrement results become unreliable. */
|
|
6
|
+
export const MAX_VALID_DIGITS = 1000000000000000; // maximum number of digits that the input supports to perform operations
|
|
7
|
+
export function useNumberIncrement(props) {
|
|
8
|
+
const { onFocus, onBlur, field, actionPressAutoFocus, timeoutActionFocus, onChangeMask, forceError, editable, step, parseValue, min, max, value, onValueChange, } = props;
|
|
9
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
10
|
+
const { fieldHandle, validation, innerInputRef, wrapperRef, inputValue, onInputValueChange, } = useInputBase(field, fields.number, { value, onValueChange });
|
|
11
|
+
const incrementDisabled = useMemo(() => {
|
|
12
|
+
const maxLimit = TypeGuards.isNumber(max) && (Number(inputValue) >= max);
|
|
13
|
+
return maxLimit;
|
|
14
|
+
}, [inputValue]);
|
|
15
|
+
const decrementDisabled = useMemo(() => {
|
|
16
|
+
const minLimit = TypeGuards.isNumber(min) && (Number(inputValue) <= min);
|
|
17
|
+
return minLimit;
|
|
18
|
+
}, [inputValue]);
|
|
19
|
+
/**
|
|
20
|
+
* The increment/decrement buttons briefly set `isFocused` to style the input as active, then
|
|
21
|
+
* clear it after `timeoutActionFocus` ms. The timeout must be cancelled if the user taps again
|
|
22
|
+
* or focuses the real text input before it fires, otherwise the focus state flickers off mid-type.
|
|
23
|
+
*/
|
|
24
|
+
const actionTimeoutRef = useRef(null);
|
|
25
|
+
const clearActionTimeoutRef = useCallback(() => {
|
|
26
|
+
if (actionTimeoutRef.current !== null) {
|
|
27
|
+
clearTimeout(actionTimeoutRef.current);
|
|
28
|
+
actionTimeoutRef.current = null;
|
|
29
|
+
}
|
|
30
|
+
}, [actionTimeoutRef.current]);
|
|
31
|
+
const handleChange = useCallback((action) => {
|
|
32
|
+
if (actionPressAutoFocus)
|
|
33
|
+
setIsFocused(true);
|
|
34
|
+
clearActionTimeoutRef();
|
|
35
|
+
if (action === 'increment' && !incrementDisabled) {
|
|
36
|
+
const newValue = Number(inputValue) + step;
|
|
37
|
+
onInputValueChange(newValue);
|
|
38
|
+
}
|
|
39
|
+
else if (action === 'decrement' && !decrementDisabled) {
|
|
40
|
+
const newValue = Number(inputValue) - step;
|
|
41
|
+
onInputValueChange(newValue);
|
|
42
|
+
}
|
|
43
|
+
if (actionPressAutoFocus) {
|
|
44
|
+
actionTimeoutRef.current = setTimeout(() => {
|
|
45
|
+
setIsFocused(false);
|
|
46
|
+
}, timeoutActionFocus);
|
|
47
|
+
}
|
|
48
|
+
}, [inputValue, incrementDisabled, decrementDisabled]);
|
|
49
|
+
const checkValue = useCallback((newValue = null, withLimits = true) => {
|
|
50
|
+
const value = newValue ?? inputValue;
|
|
51
|
+
if (withLimits) {
|
|
52
|
+
if (TypeGuards.isNumber(max) && (Number(value) >= max)) {
|
|
53
|
+
return max;
|
|
54
|
+
}
|
|
55
|
+
else if (TypeGuards.isNumber(min) && (Number(value) <= min) || TypeGuards.isNil(value) || String(value)?.length <= 0) {
|
|
56
|
+
return min;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (!value) {
|
|
60
|
+
return min;
|
|
61
|
+
}
|
|
62
|
+
if (value >= MAX_VALID_DIGITS) {
|
|
63
|
+
onInputValueChange(MAX_VALID_DIGITS);
|
|
64
|
+
return MAX_VALID_DIGITS;
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}, [inputValue]);
|
|
68
|
+
/** Clamps to min/max on blur so a user who clears the field or types an out-of-range number gets corrected without showing an error mid-type. */
|
|
69
|
+
const handleBlur = useCallback((e) => {
|
|
70
|
+
onInputValueChange(checkValue());
|
|
71
|
+
validation?.onInputBlurred?.();
|
|
72
|
+
setIsFocused(false);
|
|
73
|
+
onBlur?.(e);
|
|
74
|
+
}, [validation?.onInputBlurred, onBlur, checkValue]);
|
|
75
|
+
const handleFocus = useCallback((e) => {
|
|
76
|
+
clearActionTimeoutRef();
|
|
77
|
+
if (editable)
|
|
78
|
+
setIsFocused(true);
|
|
79
|
+
onFocus?.(e);
|
|
80
|
+
}, [onFocus]);
|
|
81
|
+
const handleChangeInput = useCallback((text) => {
|
|
82
|
+
const value = checkValue(parseValue(text), false);
|
|
83
|
+
onInputValueChange(value);
|
|
84
|
+
return value;
|
|
85
|
+
}, [checkValue]);
|
|
86
|
+
const handleMaskChange = useCallback((masked, unmasked) => {
|
|
87
|
+
handleChangeInput?.(masked);
|
|
88
|
+
if (onChangeMask)
|
|
89
|
+
onChangeMask(masked, unmasked);
|
|
90
|
+
}, [onChangeMask, handleChangeInput]);
|
|
91
|
+
const hasValue = TypeGuards.isString(inputValue)
|
|
92
|
+
? inputValue.length > 0
|
|
93
|
+
: !TypeGuards.isNil(inputValue);
|
|
94
|
+
const hasError = validation?.showError || forceError;
|
|
95
|
+
return {
|
|
96
|
+
isFocused,
|
|
97
|
+
handleBlur,
|
|
98
|
+
handleFocus,
|
|
99
|
+
handleMaskChange,
|
|
100
|
+
handleChange,
|
|
101
|
+
handleChangeInput,
|
|
102
|
+
fieldHandle,
|
|
103
|
+
validation,
|
|
104
|
+
innerInputRef,
|
|
105
|
+
wrapperRef,
|
|
106
|
+
hasValue,
|
|
107
|
+
hasError,
|
|
108
|
+
incrementDisabled,
|
|
109
|
+
decrementDisabled,
|
|
110
|
+
min,
|
|
111
|
+
max,
|
|
112
|
+
inputValue,
|
|
113
|
+
onInputValueChange,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=useNumberIncrement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNumberIncrement.js","sourceRoot":"","sources":["../../../src/components/NumberIncrement/useNumberIncrement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAS,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE9C,gIAAgI;AAChI,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAA,CAAC,yEAAyE;AAE1H,MAAM,UAAU,kBAAkB,CAAC,KAAoC;IACrE,MAAM,EACJ,OAAO,EACP,MAAM,EACN,KAAK,EACL,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,GAAG,EACH,GAAG,EACH,KAAK,EACL,aAAa,GACd,GAAG,KAAK,CAAA;IAET,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEjD,MAAM,EACJ,WAAW,EACX,UAAU,EACV,aAAa,EACb,UAAU,EACV,UAAU,EACV,kBAAkB,GACnB,GAAG,YAAY,CACd,KAAgC,EAChC,MAAM,CAAC,MAAuC,EAC9C,EAAE,KAAK,EAAE,aAAa,EAAE,CACzB,CAAA;IAED,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,EAAE;QACrC,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAA;QACxE,OAAO,QAAQ,CAAA;IACjB,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAA;IAEhB,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,E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U;QACV,kBAAkB;KACnB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Animated, { useAnimatedStyle } from 'react-native-reanimated';
|
|
3
|
+
import { Touchable } from '../Touchable';
|
|
4
|
+
import { View } from '../View';
|
|
5
|
+
function Dot({ onPress, isActive, index, styles }) {
|
|
6
|
+
/** `isActive` is a plain boolean captured by the worklet closure — this is safe because the Dot remounts when `currentPage` changes (keyed list), so the closure is never stale. If Dot were memoized across page changes this would need a SharedValue instead. */
|
|
7
|
+
const animation = useAnimatedStyle(() => {
|
|
8
|
+
const scale = isActive ? 1 : 0.6;
|
|
9
|
+
return {
|
|
10
|
+
transform: [{ scale }],
|
|
11
|
+
...(isActive ? styles['dot:active'] : styles.dot),
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
return (_jsx(Touchable, { debugName: `default-pager-dot-touchable-${index}`, onPress: onPress, noFeedback: true, style: [styles.touchable, isActive && styles['touchable:active']], children: _jsx(Animated.View, { style: [animation, styles.dot] }) }));
|
|
15
|
+
}
|
|
16
|
+
export function PagerDots({ styles, currentPage, setCurrentPage, pages }) {
|
|
17
|
+
return (_jsx(View, { style: styles.wrapper, children: pages?.map((_, i) => (_jsx(Dot, { index: i, onPress: () => setCurrentPage(i), isActive: i === currentPage, styles: styles }, `default-pager-dots-index-${i}`))) }));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=PagerDots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PagerDots.js","sourceRoot":"","sources":["../../../src/components/Pager/PagerDots.tsx"],"names":[],"mappings":";AACA,OAAO,QAAQ,EAAE,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAU9B,SAAS,GAAG,CAAC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jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memoBy } from '@codeleap/utils';
|
|
3
|
+
import { TypeGuards } from '@codeleap/types';
|
|
4
|
+
function PagerItemComponent(props) {
|
|
5
|
+
const { item, renderItem: RenderItem, ...info } = props;
|
|
6
|
+
if (TypeGuards.isFunction(item)) {
|
|
7
|
+
const ItemComponent = item;
|
|
8
|
+
return _jsx(ItemComponent, { ...info });
|
|
9
|
+
}
|
|
10
|
+
return _jsx(RenderItem, { ...info, item: item });
|
|
11
|
+
}
|
|
12
|
+
/** Memoized only on `renderItem` and `item` — positional props (`isFirst`, `isLast`, etc.) are intentionally excluded so that changing the active page doesn't re-render every item in the carousel. */
|
|
13
|
+
export const PagerItem = memoBy(PagerItemComponent, ['renderItem', 'item']);
|
|
14
|
+
//# sourceMappingURL=PagerItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PagerItem.js","sourceRoot":"","sources":["../../../src/components/Pager/PagerItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAM5C,SAAS,kBAAkB,CAAC,KAA8B;IACxD,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAA;IAEvD,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,MAAM,aAAa,GAAG,IAAI,CAAA;QAC1B,OAAO,KAAC,aAAa,OAAK,IAAI,GAAI,CAAA;IACpC,CAAC;IAED,OAAO,KAAC,UAAU,OAAK,IAAI,EAAE,IAAI,EAAE,IAAI,GAAI,CAAA;AAC7C,CAAC;AAED,wMAAwM;AACxM,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,kBAAkB,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { ReduceMotion } from 'react-native-reanimated';
|
|
4
|
+
import Carousel from 'react-native-reanimated-carousel';
|
|
5
|
+
import { Dimensions } from 'react-native';
|
|
6
|
+
import { useConditionalState } from '@codeleap/hooks';
|
|
7
|
+
import { useNestedStylesByKey } from '@codeleap/styles';
|
|
8
|
+
import { useStylesFor } from '../../hooks';
|
|
9
|
+
import { MobileStyleRegistry } from '../../Registry';
|
|
10
|
+
import { View } from '../View';
|
|
11
|
+
import { PagerDots } from './PagerDots';
|
|
12
|
+
import { PagerItem } from './PagerItem';
|
|
13
|
+
export * from './styles';
|
|
14
|
+
export * from './types';
|
|
15
|
+
export * from './PagerDots';
|
|
16
|
+
const window = Dimensions.get('screen');
|
|
17
|
+
export function Pager(props) {
|
|
18
|
+
const { pages, page, onChangePage, initialPage, style, showDots, renderItem, footer, width: carouselWidth, height: carouselHeight, autoCalculateFooterHeight, removeFixedHeight, removeFixedWidth, ...rest } = {
|
|
19
|
+
...Pager.defaultProps,
|
|
20
|
+
...props,
|
|
21
|
+
};
|
|
22
|
+
const carouselRef = useRef(null);
|
|
23
|
+
const [currentPage, setCurrentPage] = useConditionalState(page, onChangePage, { initialValue: initialPage });
|
|
24
|
+
const [footerHeight, setFooterHeight] = useState(0);
|
|
25
|
+
const [loaded, setLoaded] = useState(!showDots && !footer ? true : false);
|
|
26
|
+
const styles = useStylesFor(Pager.styleRegistryName, style);
|
|
27
|
+
const dotStyles = useNestedStylesByKey('dot', styles);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (carouselRef.current?.getCurrentIndex?.() !== currentPage) {
|
|
30
|
+
carouselRef.current?.scrollTo?.({ index: currentPage, animated: true });
|
|
31
|
+
}
|
|
32
|
+
}, [currentPage]);
|
|
33
|
+
const getItemInfo = useCallback((index) => {
|
|
34
|
+
const info = {
|
|
35
|
+
isFirst: index === 0,
|
|
36
|
+
isLast: index === pages?.length - 1,
|
|
37
|
+
isOnly: pages?.length === 1,
|
|
38
|
+
index,
|
|
39
|
+
};
|
|
40
|
+
return info;
|
|
41
|
+
}, []);
|
|
42
|
+
/** `animationValue` is a Reanimated SharedValue driven by the carousel's scroll position; it is forwarded to each item so children can react to swipe progress on the UI thread without JS round-trips. */
|
|
43
|
+
const customRenderItem = useCallback(({ item, index, animationValue }) => {
|
|
44
|
+
const info = getItemInfo(index);
|
|
45
|
+
return (_jsx(PagerItem, { ...info, renderItem: renderItem, item: item, animationValue: animationValue }));
|
|
46
|
+
}, [renderItem, getItemInfo]);
|
|
47
|
+
const onFooterLayout = useCallback((event) => {
|
|
48
|
+
setFooterHeight(event.nativeEvent.layout.height);
|
|
49
|
+
/** Deferred a frame so `height` is stable before the carousel becomes visible, preventing a layout flash. */
|
|
50
|
+
setTimeout(() => setLoaded(true), 0);
|
|
51
|
+
}, []);
|
|
52
|
+
const width = carouselWidth - removeFixedWidth;
|
|
53
|
+
const height = carouselHeight - ((autoCalculateFooterHeight ? footerHeight : 0) + removeFixedHeight);
|
|
54
|
+
return (_jsxs(View, { style: [{ width, opacity: !loaded ? 0 : 1 }, styles.wrapper], children: [_jsx(Carousel, { data: pages, autoPlay: false, loop: false, overscrollEnabled: false, pagingEnabled: false, ref: carouselRef, defaultIndex: initialPage, onSnapToItem: setCurrentPage, maxScrollDistancePerSwipe: carouselWidth, minScrollDistancePerSwipe: carouselWidth * 0.1, width: width, height: height, renderItem: customRenderItem, withAnimation: {
|
|
55
|
+
type: 'timing',
|
|
56
|
+
config: {
|
|
57
|
+
reduceMotion: ReduceMotion.Never,
|
|
58
|
+
},
|
|
59
|
+
}, ...rest, style: styles.carousel }), _jsxs(View, { onLayout: onFooterLayout, style: styles.footerWrapper, children: [footer, showDots ? (_jsx(PagerDots, { currentPage: currentPage, pages: pages, setCurrentPage: setCurrentPage, styles: dotStyles })) : null] })] }));
|
|
60
|
+
}
|
|
61
|
+
Pager.styleRegistryName = 'Pager';
|
|
62
|
+
Pager.elements = ['carousel', 'wrapper', 'footerWrapper', 'dot'];
|
|
63
|
+
Pager.rootElement = 'wrapper';
|
|
64
|
+
Pager.withVariantTypes = (styles) => {
|
|
65
|
+
return Pager;
|
|
66
|
+
};
|
|
67
|
+
Pager.defaultProps = {
|
|
68
|
+
width: window.width,
|
|
69
|
+
height: window.height,
|
|
70
|
+
showDots: true,
|
|
71
|
+
autoCalculateFooterHeight: true,
|
|
72
|
+
initialPage: 0,
|
|
73
|
+
footer: null,
|
|
74
|
+
removeFixedHeight: 0,
|
|
75
|
+
removeFixedWidth: 0,
|
|
76
|
+
};
|
|
77
|
+
MobileStyleRegistry.registerComponent(Pager);
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Pager/index.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,QAA+B,MAAM,kCAAkC,CAAA;AAE9E,OAAO,EAAE,UAAU,EAAqB,MAAM,cAAc,CAAA;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAyC,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAC9F,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAE9B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,cAAc,UAAU,CAAA;AACxB,cAAc,S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AED,KAAK,CAAC,YAAY,GAAG;IACnB,KAAK,EAAE,MAAM,CAAC,KAAK;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,QAAQ,EAAE,IAAI;IACd,yBAAyB,EAAE,IAAI;IAC/B,WAAW,EAAE,CAAC;IACd,MAAM,EAAE,IAAI;IACZ,iBAAiB,EAAE,CAAC;IACpB,gBAAgB,EAAE,CAAC;CACY,CAAA;AAEjC,mBAAmB,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/Pager/styles.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/Pager/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { TypeGuards } from '@codeleap/types';
|
|
3
|
+
import { ActivityIndicator } from '../ActivityIndicator';
|
|
4
|
+
import { Text } from '../Text';
|
|
5
|
+
import { useNestedStylesByKey } from '@codeleap/styles';
|
|
6
|
+
import { MobileStyleRegistry } from '../../Registry';
|
|
7
|
+
import { useStylesFor } from '../../hooks';
|
|
8
|
+
export * from './styles';
|
|
9
|
+
export * from './types';
|
|
10
|
+
export const PaginationIndicator = (props) => {
|
|
11
|
+
const { hasMore, isFetching, noMoreItemsText, style, activityIndicator, } = {
|
|
12
|
+
...PaginationIndicator.defaultProps,
|
|
13
|
+
...props,
|
|
14
|
+
};
|
|
15
|
+
const styles = useStylesFor(PaginationIndicator.styleRegistryName, style);
|
|
16
|
+
const loaderStyles = useNestedStylesByKey('loader', styles);
|
|
17
|
+
if (isFetching) {
|
|
18
|
+
return activityIndicator || _jsx(ActivityIndicator, { style: loaderStyles });
|
|
19
|
+
}
|
|
20
|
+
if (!hasMore) {
|
|
21
|
+
if (TypeGuards.isString(noMoreItemsText) || TypeGuards.isNumber(noMoreItemsText)) {
|
|
22
|
+
return _jsx(Text, { style: styles.text, text: noMoreItemsText.toString() });
|
|
23
|
+
}
|
|
24
|
+
return noMoreItemsText;
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
PaginationIndicator.styleRegistryName = 'PaginationIndicator';
|
|
29
|
+
PaginationIndicator.elements = ['text', 'loader'];
|
|
30
|
+
PaginationIndicator.rootElement = 'text';
|
|
31
|
+
PaginationIndicator.withVariantTypes = (styles) => {
|
|
32
|
+
return PaginationIndicator;
|
|
33
|
+
};
|
|
34
|
+
PaginationIndicator.defaultProps = {};
|
|
35
|
+
MobileStyleRegistry.registerComponent(PaginationIndicator);
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/PaginationIndicator/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAa,oBAAoB,EAA8B,MAAM,kBAAkB,CAAA;AAC9F,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAA+B,EAAE,EAAE;IACrE,MAAM,EACJ,OAAO,EACP,UAAU,EACV,eAAe,EACf,KAAK,EACL,iBAAiB,GAClB,GAAG;QACF,GAAG,mBAAmB,CAAC,YAAY;QACnC,GAAG,KAAK;KACT,CAAA;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,mBAAmB,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAA;IAEzE,MAAM,YAAY,GAAG,oBAAoB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAE3D,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,iBAAiB,IAAI,KAAC,iBAAiB,IAAC,KAAK,EAAE,YAAY,GAAI,CAAA;IACxE,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,IAAI,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;YACjF,OAAO,KAAC,IAAI,IAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,CAAC,QAAQ,EAAE,GAAI,CAAA;QACvE,CAAC;QAED,OAAO,eAAe,CAAA;IACxB,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,mBAAmB,CAAC,iBAAiB,GAAG,qBAAqB,CAAA;AAC7D,mBAAmB,CAAC,QAAQ,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AACjD,mBAAmB,CAAC,WAAW,GAAG,MAAM,CAAA;AAExC,mBAAmB,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IACxE,OAAO,mBAAqG,CAAA;AAC9G,CAAC,CAAA;AAED,mBAAmB,CAAC,YAAY,GAAG,EAA8B,CAAA;AAEjE,mBAAmB,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/PaginationIndicator/styles.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/PaginationIndicator/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { useCompositionStyles } from '@codeleap/styles';
|
|
4
|
+
import { useStylesFor } from '../../hooks';
|
|
5
|
+
import { Text } from '../Text';
|
|
6
|
+
import { View } from '../View';
|
|
7
|
+
import { MobileStyleRegistry } from '../../Registry';
|
|
8
|
+
import { TextInput } from '../TextInput';
|
|
9
|
+
import { List } from '../List';
|
|
10
|
+
import { Touchable } from '../Touchable';
|
|
11
|
+
import { EmptyPlaceholder } from '../EmptyPlaceholder';
|
|
12
|
+
import { ActivityIndicator } from '../ActivityIndicator';
|
|
13
|
+
import { usePlacesAutocompleteUtils } from '@codeleap/hooks';
|
|
14
|
+
export * from './styles';
|
|
15
|
+
export * from './types';
|
|
16
|
+
const DefaultPlaceRow = (props) => {
|
|
17
|
+
const { item, onPress, styles } = props;
|
|
18
|
+
if (item?.content) {
|
|
19
|
+
return item?.content;
|
|
20
|
+
}
|
|
21
|
+
const isLatLng = !!item?.formatted_address;
|
|
22
|
+
const mainTitle = isLatLng ? item?.formatted_address : item?.description;
|
|
23
|
+
return (_jsx(Touchable, { onPress: () => onPress(mainTitle, item), debugName: `PlaceRow ${item?.place_id}`, style: styles.placeRowWrapper, children: _jsx(Text, { text: `${mainTitle}`, style: styles.placeRowText }) }));
|
|
24
|
+
};
|
|
25
|
+
export const PlacesAutocomplete = (props) => {
|
|
26
|
+
const { style, itemRow, data = [], customData = [], onPress, onValueChange, showClearIcon, showEmptyPlaceholder, clearIcon, textInputProps, listProps, emptyPlaceholderProps, placeRow = null, renderPlaceRow: PlaceRow, activityIndicatorProps, debounce, isLoading, persistResultsOnBlur, ...rest } = props;
|
|
27
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
28
|
+
const styles = useStylesFor(PlacesAutocomplete.styleRegistryName, style);
|
|
29
|
+
const compositionStyles = useCompositionStyles(['input', 'list', 'loader'], styles);
|
|
30
|
+
/** When the caller fully controls the input value via `textInputProps.value`, the internal debounce is disabled to avoid double-buffering the typed string. */
|
|
31
|
+
const hasCustomValue = !!textInputProps?.value;
|
|
32
|
+
const { handleChangeAddress, handlePressAddress, handleClearAddress, address, isTyping, setIsTyping, } = usePlacesAutocompleteUtils({
|
|
33
|
+
onValueChange,
|
|
34
|
+
onPress,
|
|
35
|
+
debounce: hasCustomValue ? null : 250
|
|
36
|
+
});
|
|
37
|
+
const _showEmptyPlaceholder = !!address && !isTyping && showEmptyPlaceholder && !isLoading;
|
|
38
|
+
const showResults = isFocused || persistResultsOnBlur;
|
|
39
|
+
const _showClearIcon = showClearIcon && !!address?.trim?.();
|
|
40
|
+
const rightIcon = _showClearIcon ? {
|
|
41
|
+
name: clearIcon,
|
|
42
|
+
onPress: handleClearAddress,
|
|
43
|
+
} : textInputProps?.rightIcon;
|
|
44
|
+
const _data = customData?.length > 0 && address ? [...customData, ...data] : data;
|
|
45
|
+
const renderItem = useCallback((props) => {
|
|
46
|
+
return (placeRow ? placeRow : _jsx(PlaceRow, { onPress: handlePressAddress, styles: styles, ...props }));
|
|
47
|
+
}, [placeRow]);
|
|
48
|
+
return (_jsxs(View, { style: styles.wrapper, ...rest, children: [_jsx(TextInput, { style: compositionStyles.input, onBlur: () => {
|
|
49
|
+
setIsFocused(false);
|
|
50
|
+
}, onFocus: () => {
|
|
51
|
+
setIsFocused(true);
|
|
52
|
+
}, ...textInputProps, value: hasCustomValue ? textInputProps?.value : address, onValueChange: (value) => {
|
|
53
|
+
setIsTyping(true);
|
|
54
|
+
handleChangeAddress(value);
|
|
55
|
+
}, rightIcon: rightIcon }), isTyping ? (_jsx(View, { style: styles.loadingWrapper, children: _jsx(ActivityIndicator, { style: compositionStyles.loader, ...activityIndicatorProps }) })) : (showResults ? (_jsx(List, { data: _data, renderItem: renderItem, ListEmptyComponent: _showEmptyPlaceholder ? _jsx(EmptyPlaceholder, { ...emptyPlaceholderProps }) : null, style: compositionStyles.list, separators: true, ...listProps })) : null)] }));
|
|
56
|
+
};
|
|
57
|
+
PlacesAutocomplete.styleRegistryName = 'PlacesAutocomplete';
|
|
58
|
+
PlacesAutocomplete.elements = ['wrapper', 'input', 'list', 'loader', 'placeRow', 'loadingWrapper'];
|
|
59
|
+
PlacesAutocomplete.withVariantTypes = (styles) => {
|
|
60
|
+
return PlacesAutocomplete;
|
|
61
|
+
};
|
|
62
|
+
PlacesAutocomplete.defaultProps = {
|
|
63
|
+
showClearIcon: false,
|
|
64
|
+
showEmptyPlaceholder: true,
|
|
65
|
+
clearIcon: 'x',
|
|
66
|
+
placeRowComponent: DefaultPlaceRow,
|
|
67
|
+
renderPlaceRow: DefaultPlaceRow,
|
|
68
|
+
debounce: 250,
|
|
69
|
+
};
|
|
70
|
+
MobileStyleRegistry.registerComponent(PlacesAutocomplete);
|
|
71
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/PlacesAutocomplete/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAkD,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvG,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAA;AAE5D,cAAc,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AS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAA;AAClG,kBAAkB,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IACvE,OAAO,kBAAmG,CAAA;AAC5G,CAAC,CAAA;AAED,kBAAkB,CAAC,YAAY,GAAG;IAChC,aAAa,EAAE,KAAK;IACpB,oBAAoB,EAAE,IAAI;IAC1B,SAAS,EAAE,GAAc;IACzB,iBAAiB,EAAE,eAAe;IAClC,cAAc,EAAE,eAAe;IAC/B,QAAQ,EAAE,GAAG;CACd,CAAA;AAED,mBAAmB,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/PlacesAutocomplete/styles.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/PlacesAutocomplete/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from '../Text';
|
|
3
|
+
import { Touchable } from '../Touchable';
|
|
4
|
+
import { TypeGuards } from '@codeleap/types';
|
|
5
|
+
import { View } from '../View';
|
|
6
|
+
import { InputBase, selectInputBaseProps } from '../InputBase';
|
|
7
|
+
import { MobileStyleRegistry } from '../../Registry';
|
|
8
|
+
import { useStylesFor } from '../../hooks';
|
|
9
|
+
import { useInputBasePartialStyles } from '../InputBase/useInputBasePartialStyles';
|
|
10
|
+
import { useInputBase } from '../InputBase/useInputBase';
|
|
11
|
+
import { fields } from '@codeleap/form';
|
|
12
|
+
export * from './styles';
|
|
13
|
+
export * from './types';
|
|
14
|
+
const Option = (props) => {
|
|
15
|
+
const { debugName, item, disabled, styles, selected, onSelect, separator = false, reverseOrder, } = props;
|
|
16
|
+
const isDisabled = disabled || item.disabled;
|
|
17
|
+
const partialStyles = useInputBasePartialStyles(styles, ['optionLabel', 'optionWrapper', 'optionIndicator', 'optionIndicatorInner'], {
|
|
18
|
+
selectedDisabled: isDisabled && selected,
|
|
19
|
+
disabled: isDisabled,
|
|
20
|
+
selected,
|
|
21
|
+
});
|
|
22
|
+
const label = TypeGuards.isString(item.label) ? _jsx(Text, { style: partialStyles.optionLabel, text: item.label }) : item.label;
|
|
23
|
+
return _jsxs(_Fragment, { children: [_jsx(Touchable, { debugName: `${debugName} option ${item.value}`, style: partialStyles.optionWrapper, rippleDisabled: true, onPress: onSelect, disabled: isDisabled, children: reverseOrder ? (_jsxs(_Fragment, { children: [label, _jsx(View, { style: partialStyles.optionIndicator, children: _jsx(View, { style: partialStyles.optionIndicatorInner }) })] })) : (_jsxs(_Fragment, { children: [_jsx(View, { style: partialStyles.optionIndicator, children: _jsx(View, { style: partialStyles.optionIndicatorInner }) }), label] })) }), separator ? _jsx(View, { style: styles.optionSeparator }) : null] });
|
|
24
|
+
};
|
|
25
|
+
export const RadioGroup = (props) => {
|
|
26
|
+
const { inputBaseProps, others, } = selectInputBaseProps({
|
|
27
|
+
...RadioGroup.defaultProps,
|
|
28
|
+
...props,
|
|
29
|
+
});
|
|
30
|
+
const { disabled, debugName, radioOnRight, style, field, options, value, onValueChange, } = others;
|
|
31
|
+
const styles = useStylesFor(RadioGroup.styleRegistryName, style);
|
|
32
|
+
const { wrapperRef, inputValue, onInputValueChange, } = useInputBase(field, fields.selectable, { value, onValueChange });
|
|
33
|
+
/** `radioOnRight` can be baked into the style variant via `__props` so themes can set the default layout without requiring a prop on every usage site. */
|
|
34
|
+
// @ts-expect-error icss type
|
|
35
|
+
const _radioOnRight = radioOnRight ?? styles?.__props?.radioOnRight;
|
|
36
|
+
const hasValue = !TypeGuards.isNil(inputValue);
|
|
37
|
+
return _jsx(InputBase, { ...inputBaseProps, ref: wrapperRef, disabled: disabled, style: styles, debugName: debugName, hasValue: hasValue, children: options?.map((item, idx) => (_jsx(Option, { debugName: debugName, item: item, disabled: disabled, styles: styles, selected: inputValue === item.value, onSelect: () => onInputValueChange(item.value), separator: idx < options?.length - 1, reverseOrder: _radioOnRight }, idx))) });
|
|
38
|
+
};
|
|
39
|
+
RadioGroup.styleRegistryName = 'RadioGroup';
|
|
40
|
+
RadioGroup.elements = [...InputBase.elements, 'option', '__props'];
|
|
41
|
+
RadioGroup.rootElement = 'wrapper';
|
|
42
|
+
RadioGroup.withVariantTypes = (styles) => {
|
|
43
|
+
return RadioGroup;
|
|
44
|
+
};
|
|
45
|
+
RadioGroup.defaultProps = {};
|
|
46
|
+
MobileStyleRegistry.registerComponent(RadioGroup);
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/RadioInput/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAG9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAA;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAmB,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAExD,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB,MAAM,MAAM,GAAG,CAA4B,KAA0B,EAAE,EAAE;IACvE,MAAM,EACJ,SAA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C,IAAI,CAAC,KAAK,CAAC,EAC9C,SAAS,EAAE,GAAG,GAAG,OAAO,EAAE,MAAM,GAAG,CAAC,EACpC,YAAY,EAAE,aAAa,IANtB,GAAG,CAOR,CACH,CAAC,GACQ,CAAA;AACd,CAAC,CAAA;AAED,UAAU,CAAC,iBAAiB,GAAG,YAAY,CAAA;AAC3C,UAAU,CAAC,QAAQ,GAAG,CAAC,GAAG,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAA;AAClE,UAAU,CAAC,WAAW,GAAG,SAAS,CAAA;AAElC,UAAU,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IAC/D,OAAO,UAAmH,CAAA;AAC5H,CAAC,CAAA;AAED,UAAU,CAAC,YAAY,GAAG,EAAsC,CAAA;AAEhE,mBAAmB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/RadioInput/styles.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/RadioInput/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { RefreshControl as RNRefreshControl } from 'react-native';
|
|
3
|
+
import { MobileStyleRegistry } from '../../Registry';
|
|
4
|
+
import { useStylesFor } from '../../hooks';
|
|
5
|
+
export * from './styles';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export const RefreshControl = (props) => {
|
|
8
|
+
const { style, ...rest } = {
|
|
9
|
+
...RefreshControl.defaultProps,
|
|
10
|
+
...props,
|
|
11
|
+
};
|
|
12
|
+
const styles = useStylesFor(RefreshControl.styleRegistryName, style);
|
|
13
|
+
/** RN's `RefreshControl` accepts spinner colors only as raw `ColorValue` props, not via `style`; the design token values are therefore extracted from the style record and forwarded as explicit props. */
|
|
14
|
+
const color = styles?.loadingAnimation?.color;
|
|
15
|
+
const titleColor = styles?.titleColor?.color;
|
|
16
|
+
const progressBackgroundColor = styles?.progressBackgroundColor?.color;
|
|
17
|
+
return (_jsx(RNRefreshControl, { colors: [color], tintColor: color, progressBackgroundColor: progressBackgroundColor, titleColor: titleColor, ...rest }));
|
|
18
|
+
};
|
|
19
|
+
RefreshControl.styleRegistryName = 'RefreshControl';
|
|
20
|
+
RefreshControl.elements = ['loadingAnimation', 'progressBackgroundColor', 'titleColor'];
|
|
21
|
+
RefreshControl.rootElement = 'wrapper';
|
|
22
|
+
RefreshControl.withVariantTypes = (styles) => {
|
|
23
|
+
return RefreshControl;
|
|
24
|
+
};
|
|
25
|
+
RefreshControl.defaultProps = {};
|
|
26
|
+
MobileStyleRegistry.registerComponent(RefreshControl);
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/RefreshControl/index.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,cAAc,IAAI,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAA0B,EAAE,EAAE;IAC3D,MAAM,EACJ,KAAK,EACL,GAAG,IAAI,EACR,GAAG;QACF,GAAG,cAAc,CAAC,YAAY;QAC9B,GAAG,KAAK;KACT,CAAA;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,cAAc,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAA;IAEpE,2MAA2M;IAC3M,MAAM,KAAK,GAAgB,MAAM,EAAE,gBAA8B,EAAE,KAAK,CAAA;IACxE,MAAM,UAAU,GAAgB,MAAM,EAAE,UAAwB,EAAE,KAAK,CAAA;IACvE,MAAM,uBAAuB,GAAgB,MAAM,EAAE,uBAAqC,EAAE,KAAK,CAAA;IAEjG,OAAO,CACL,KAAC,gBAAgB,IACf,MAAM,EAAE,CAAC,KAAK,CAAC,EACf,SAAS,EAAE,KAAK,EAChB,uBAAuB,EAAE,uBAAuB,EAChD,UAAU,EAAE,UAAU,KAClB,IAAI,GACR,CACH,CAAA;AACH,CAAC,CAAA;AAED,cAAc,CAAC,iBAAiB,GAAG,gBAAgB,CAAA;AACnD,cAAc,CAAC,QAAQ,GAAG,CAAC,kBAAkB,EAAE,yBAAyB,EAAE,YAAY,CAAC,CAAA;AACvF,cAAc,CAAC,WAAW,GAAG,SAAS,CAAA;AAEtC,cAAc,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IACnE,OAAO,cAA2F,CAAA;AACpG,CAAC,CAAA;AAED,cAAc,CAAC,YAAY,GAAG,EAAkC,CAAA;AAEhE,mBAAmB,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/RefreshControl/styles.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/RefreshControl/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { ScrollView } from 'react-native';
|
|
4
|
+
import { MobileStyleRegistry } from '../../Registry';
|
|
5
|
+
import { useStylesFor } from '../../hooks';
|
|
6
|
+
import { KeyboardAwareScrollView } from 'react-native-keyboard-controller';
|
|
7
|
+
import { ScrollProvider, useScrollPubSub } from '../../modules/scroll';
|
|
8
|
+
export * from './styles';
|
|
9
|
+
export * from './types';
|
|
10
|
+
export const Scroll = (scrollProps) => {
|
|
11
|
+
const { style, refreshTimeout, children, refreshControlProps = {}, contentContainerStyle, keyboardAware, ...props } = {
|
|
12
|
+
...Scroll.defaultProps,
|
|
13
|
+
...scrollProps,
|
|
14
|
+
};
|
|
15
|
+
const styles = useStylesFor(Scroll.styleRegistryName, style);
|
|
16
|
+
const Component = keyboardAware ? KeyboardAwareScrollView : ScrollView;
|
|
17
|
+
const _scrollRef = useRef(null);
|
|
18
|
+
/** `useScrollPubSub` wires a pub/sub channel so that sibling components (e.g. sticky headers, parallax layers) can subscribe to scroll events without prop-drilling. The suppressed TS error is because the generic `ScrollView` ref type doesn't satisfy the overloaded signature inside `useScrollPubSub`. */
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
const { ref: scrollRef, emit } = useScrollPubSub(_scrollRef);
|
|
21
|
+
return (_jsx(ScrollProvider, { ref: scrollRef, children: _jsx(Component, { showsVerticalScrollIndicator: false,
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
ref: _scrollRef, bottomOffset: 30, ...props, style: styles?.wrapper, contentContainerStyle: [styles?.content, contentContainerStyle], onMomentumScrollEnd: (e) => {
|
|
24
|
+
emit('onMomentumScrollEnd', e);
|
|
25
|
+
props?.onMomentumScrollEnd?.(e);
|
|
26
|
+
}, children: children }) }));
|
|
27
|
+
};
|
|
28
|
+
Scroll.styleRegistryName = 'Scroll';
|
|
29
|
+
Scroll.elements = ['wrapper', 'content'];
|
|
30
|
+
Scroll.rootElement = 'wrapper';
|
|
31
|
+
Scroll.withVariantTypes = (styles) => {
|
|
32
|
+
return Scroll;
|
|
33
|
+
};
|
|
34
|
+
Scroll.defaultProps = {
|
|
35
|
+
keyboardShouldPersistTaps: 'handled',
|
|
36
|
+
refreshTimeout: 3000,
|
|
37
|
+
keyboardAware: true,
|
|
38
|
+
};
|
|
39
|
+
MobileStyleRegistry.registerComponent(Scroll);
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,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