@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,128 @@
|
|
|
1
|
+
/* eslint no-restricted-imports: 'off' */
|
|
2
|
+
/* eslint prefer-const: 'off' */
|
|
3
|
+
import { Alert } from 'react-native';
|
|
4
|
+
/** Deduplication map keyed by alert identity (type + title + body) — prevents the same alert from stacking when triggered multiple times before the user dismisses it. Entries are removed only after the user taps a button, so alerts that are dismissed via the hardware back button on Android will leave a stale entry and block the next identical alert. */
|
|
5
|
+
const currentAlerts = {};
|
|
6
|
+
function generateAlertID(from) {
|
|
7
|
+
return [
|
|
8
|
+
from.type,
|
|
9
|
+
from.title,
|
|
10
|
+
from.body,
|
|
11
|
+
].join('-');
|
|
12
|
+
}
|
|
13
|
+
function shouldShowAlert(args, type) {
|
|
14
|
+
const alertId = generateAlertID({ ...args, type });
|
|
15
|
+
if (!Object.keys(currentAlerts).includes(alertId)) {
|
|
16
|
+
currentAlerts[alertId] = true;
|
|
17
|
+
return alertId;
|
|
18
|
+
}
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
function popAlert(id) {
|
|
22
|
+
delete currentAlerts[id];
|
|
23
|
+
}
|
|
24
|
+
function ask({ title, body, options = null }) {
|
|
25
|
+
if (!title) {
|
|
26
|
+
title = 'Quick quetion';
|
|
27
|
+
}
|
|
28
|
+
_OSAlert({
|
|
29
|
+
title,
|
|
30
|
+
body,
|
|
31
|
+
options,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function warn(args) {
|
|
35
|
+
const id = shouldShowAlert(args, 'warn');
|
|
36
|
+
if (!id)
|
|
37
|
+
return;
|
|
38
|
+
let { title, body, onAccept, onReject, } = args;
|
|
39
|
+
if (!title) {
|
|
40
|
+
title = 'Hang on';
|
|
41
|
+
}
|
|
42
|
+
if (!body) {
|
|
43
|
+
body = 'Are you sure?';
|
|
44
|
+
}
|
|
45
|
+
if (!onReject) {
|
|
46
|
+
onReject = () => null;
|
|
47
|
+
}
|
|
48
|
+
_OSAlert({
|
|
49
|
+
title,
|
|
50
|
+
body,
|
|
51
|
+
options: [
|
|
52
|
+
{
|
|
53
|
+
text: 'Cancel',
|
|
54
|
+
onPress: () => {
|
|
55
|
+
popAlert(id);
|
|
56
|
+
onReject();
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
text: 'OK',
|
|
61
|
+
style: 'destructive',
|
|
62
|
+
onPress: () => {
|
|
63
|
+
popAlert(id);
|
|
64
|
+
onAccept?.();
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function info(args) {
|
|
71
|
+
const id = shouldShowAlert(args, 'info');
|
|
72
|
+
if (!id)
|
|
73
|
+
return;
|
|
74
|
+
let { title, body, onDismiss = () => null, } = args;
|
|
75
|
+
if (!title) {
|
|
76
|
+
title = 'FYI';
|
|
77
|
+
}
|
|
78
|
+
_OSAlert({
|
|
79
|
+
title,
|
|
80
|
+
body,
|
|
81
|
+
options: [
|
|
82
|
+
{
|
|
83
|
+
text: 'OK',
|
|
84
|
+
onPress: () => {
|
|
85
|
+
popAlert(id);
|
|
86
|
+
onDismiss?.();
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function OSError(args) {
|
|
93
|
+
const id = shouldShowAlert(args, 'error');
|
|
94
|
+
if (!id)
|
|
95
|
+
return;
|
|
96
|
+
let { title, body, } = args;
|
|
97
|
+
if (!title) {
|
|
98
|
+
title = 'Whoops!';
|
|
99
|
+
}
|
|
100
|
+
if (!body) {
|
|
101
|
+
body = 'Something went wrong';
|
|
102
|
+
}
|
|
103
|
+
_OSAlert({
|
|
104
|
+
title,
|
|
105
|
+
body,
|
|
106
|
+
options: [
|
|
107
|
+
{
|
|
108
|
+
text: 'OK',
|
|
109
|
+
onPress: () => {
|
|
110
|
+
popAlert(id);
|
|
111
|
+
args?.onDismiss?.();
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function _OSAlert(params) {
|
|
118
|
+
Alert.alert(params.title, params.body, params.options, {
|
|
119
|
+
cancelable: false,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
export const OSAlert = {
|
|
123
|
+
ask,
|
|
124
|
+
warn,
|
|
125
|
+
info,
|
|
126
|
+
error: OSError,
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=OSAlert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OSAlert.js","sourceRoot":"","sources":["../../src/utils/OSAlert.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,gCAAgC;AAChC,OAAO,EAAE,KAAK,EAAe,MAAM,cAAc,CAAA;AAyBjD,mWAAmW;AACnW,MAAM,aAAa,GAAG,EAErB,CAAA;AAED,SAAS,eAAe,CAAC,IAAsC;IAC7D,OAAO;QACL,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,IAAI;KACV,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACb,CAAC;AAED,SAAS,eAAe,CAAC,IAAgB,EAAE,IAAiB;IAC1D,MAAM,OAAO,GAAG,eAAe,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAElD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAClD,aAAa,CAAC,OAAO,CAAC,GAAG,IAAI,CAAA;QAE7B,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,OAAO,EAAE,CAAA;AACX,CAAC;AAED,SAAS,QAAQ,CAAC,EAAS;IACzB,OAAO,aAAa,CAA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AED,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,KAAK,EAAE,OAAO;CACf,CAAA"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { MMKV } from 'react-native-mmkv';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps `react-native-mmkv`, which is fully synchronous — reads and writes block the JS thread for microseconds but never return Promises, unlike AsyncStorage. Each `StorageManager` instance creates its own MMKV database file; if you need encryption, pass an `id` and `encryptionKey` to `new MMKV(options)` here before sharing the instance across the app.
|
|
4
|
+
*
|
|
5
|
+
* Objects are round-tripped through `JSON.stringify`/`JSON.parse`; non-serialisable values (class instances, functions) will silently lose their prototype on read-back.
|
|
6
|
+
*/
|
|
7
|
+
export class StorageManager {
|
|
8
|
+
instance = new MMKV();
|
|
9
|
+
storageKeys;
|
|
10
|
+
constructor(keys) {
|
|
11
|
+
this.storageKeys = keys;
|
|
12
|
+
}
|
|
13
|
+
getStorageKey(key) {
|
|
14
|
+
if (typeof key == 'function') {
|
|
15
|
+
return key(this.storageKeys);
|
|
16
|
+
}
|
|
17
|
+
if (Array.isArray(key)) {
|
|
18
|
+
const [storageKey, value] = key;
|
|
19
|
+
const extractor = this.storageKeys?.[storageKey];
|
|
20
|
+
return extractor?.(value);
|
|
21
|
+
}
|
|
22
|
+
const storageKey = this.storageKeys?.[key];
|
|
23
|
+
if (!!storageKey) {
|
|
24
|
+
return storageKey;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return key;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
parseValue(value) {
|
|
31
|
+
try {
|
|
32
|
+
return JSON.parse(value);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exists(key) {
|
|
39
|
+
const storageKey = this.getStorageKey(key);
|
|
40
|
+
return this.instance.contains(storageKey);
|
|
41
|
+
}
|
|
42
|
+
get(key, type) {
|
|
43
|
+
const storageKey = this.getStorageKey(key);
|
|
44
|
+
if (type === 'string') {
|
|
45
|
+
return this.instance.getString(storageKey);
|
|
46
|
+
}
|
|
47
|
+
else if (type === 'number') {
|
|
48
|
+
return this.instance.getNumber(storageKey);
|
|
49
|
+
}
|
|
50
|
+
else if (type === 'boolean') {
|
|
51
|
+
return this.instance.getBoolean(storageKey);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const value = this.instance.getString(storageKey);
|
|
55
|
+
return !!value ? this.parseValue(value) : undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
set(key, value) {
|
|
59
|
+
const storageKey = this.getStorageKey(key);
|
|
60
|
+
const isValidValue = typeof value == 'string' || typeof value == 'number' || typeof value == 'boolean';
|
|
61
|
+
const parsedValue = isValidValue ? value : JSON.stringify(value);
|
|
62
|
+
this.instance.set(storageKey, parsedValue);
|
|
63
|
+
}
|
|
64
|
+
remove(key) {
|
|
65
|
+
const storageKey = this.getStorageKey(key);
|
|
66
|
+
this.instance.delete(storageKey);
|
|
67
|
+
}
|
|
68
|
+
multiRemove(keys) {
|
|
69
|
+
for (const key of keys) {
|
|
70
|
+
const storageKey = this.getStorageKey(key);
|
|
71
|
+
this.instance.delete(storageKey);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
multiGet(keys) {
|
|
75
|
+
const values = {};
|
|
76
|
+
for (const key of keys) {
|
|
77
|
+
const storageKey = this.getStorageKey(key);
|
|
78
|
+
const value = this.instance.getString(storageKey);
|
|
79
|
+
values[key] = value;
|
|
80
|
+
}
|
|
81
|
+
return values;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=StorageManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageManager.js","sourceRoot":"","sources":["../../src/utils/StorageManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;A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0B;QAC3C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;YAC1C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;QAClC,CAAC;IACH,CAAC;IAEM,QAAQ,CAAC,IAA0B;QACxC,MAAM,MAAM,GAAkC,EAAE,CAAA;QAEhD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;YAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;YAEjD,MAAM,CAAC,GAAc,CAAC,GAAG,KAAK,CAAA;QAChC,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
class Subscription {
|
|
3
|
+
subscribers = {};
|
|
4
|
+
_history = [];
|
|
5
|
+
get history() {
|
|
6
|
+
return Object.freeze(this._history);
|
|
7
|
+
}
|
|
8
|
+
subscribe(key, cb) {
|
|
9
|
+
this.subscribers[key] = cb;
|
|
10
|
+
return () => {
|
|
11
|
+
delete this.subscribers[key];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
getSubscriber(key) {
|
|
15
|
+
return this.subscribers[key];
|
|
16
|
+
}
|
|
17
|
+
removerSubscriber(key) {
|
|
18
|
+
delete this.subscribers[key];
|
|
19
|
+
}
|
|
20
|
+
getSubscribersKeys() {
|
|
21
|
+
return Object.keys(this.subscribers);
|
|
22
|
+
}
|
|
23
|
+
invoke(e) {
|
|
24
|
+
this._history.push(e);
|
|
25
|
+
for (const subscriber in this.subscribers) {
|
|
26
|
+
this.subscribers[subscriber](e);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
removeAllListeners() {
|
|
30
|
+
this.subscribers = {};
|
|
31
|
+
}
|
|
32
|
+
static createSubscriptor(events) {
|
|
33
|
+
return (e, key, cb) => {
|
|
34
|
+
return events[e].subscribe(key, cb);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function useSubscriptionHistory(subscription) {
|
|
39
|
+
const [state, setState] = React.useState(subscription.history);
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
return subscription.subscribe('subscription-history', e => {
|
|
42
|
+
setState([...state, e]);
|
|
43
|
+
});
|
|
44
|
+
}, []);
|
|
45
|
+
return state;
|
|
46
|
+
}
|
|
47
|
+
export { Subscription, useSubscriptionHistory };
|
|
48
|
+
//# sourceMappingURL=Subscription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Subscription.js","sourceRoot":"","sources":["../../src/utils/Subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAYzB,MAAM,YAAY;IACT,WAAW,GAA6B,EAA8B,CAAA;IAErE,QAAQ,GAAQ,EAAE,CAAA;IAE1B,IAAI,OAAO;QACT,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACrC,CAAC;IAED,SAAS,CAAC,GAAM,EAAE,EAAiB;QACjC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;QAE1B,OAAO,GAAG,EAAE;YACV,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QAC9B,CAAC,CAAA;IACH,CAAC;IAED,aAAa,CAAC,GAAM;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;IAED,iBAAiB,CAAC,GAAM;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;IAED,kBAAkB;QAChB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IACtC,CAAC;IAED,MAAM,CAAC,CAAI;QACT,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAErB,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YAC1C,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;QACjC,CAAC;IACH,CAAC;IAED,kBAAkB;QAChB,IAAI,CAAC,WAAW,GAAG,EAA8B,CAAA;IACnD,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAgC,MAAU;QAChE,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE;YACpB,OAAO,MAAM,CAAC,CAAC,CAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;QACtC,CAAC,CAAA;IACH,CAAC;CACF;AAED,SAAS,sBAAsB,CAAI,YAA6B;IAC9D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;IAE9D,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,OAAO,YAAY,CAAC,SAAS,CAAC,sBAAsB,EAAE,CAAC,CAAC,EAAE;YACxD,QAAQ,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;QACzB,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,KAAK,CAAA;AACd,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,CAAA"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { onUpdate, usePrevious, useRef, useState } from '@codeleap/hooks';
|
|
2
|
+
import { shadeColor } from '@codeleap/utils';
|
|
3
|
+
import { TypeGuards } from '@codeleap/types';
|
|
4
|
+
import { Animated, Platform, BackHandler, StyleSheet } from 'react-native';
|
|
5
|
+
import { Easing, useAnimatedStyle, withTiming } from 'react-native-reanimated';
|
|
6
|
+
import { useMemo } from 'react';
|
|
7
|
+
import { mergeStyles } from '@codeleap/styles';
|
|
8
|
+
import { useKeyboardController } from '../hooks';
|
|
9
|
+
export function useAnimateColor(value, opts) {
|
|
10
|
+
const iters = useRef(0);
|
|
11
|
+
const [anim] = useState(new Animated.Value(iters.current));
|
|
12
|
+
const _prev = usePrevious(value);
|
|
13
|
+
const prev = _prev || value;
|
|
14
|
+
onUpdate(() => {
|
|
15
|
+
// if (value === prev) return
|
|
16
|
+
const animation = Animated.timing(anim, {
|
|
17
|
+
...opts,
|
|
18
|
+
toValue: iters.current + 1,
|
|
19
|
+
useNativeDriver: false,
|
|
20
|
+
});
|
|
21
|
+
animation.start(() => {
|
|
22
|
+
iters.current += 1;
|
|
23
|
+
});
|
|
24
|
+
return () => {
|
|
25
|
+
animation.stop();
|
|
26
|
+
};
|
|
27
|
+
}, [value]);
|
|
28
|
+
const color = anim.interpolate({
|
|
29
|
+
outputRange: [prev, value],
|
|
30
|
+
inputRange: [iters.current, iters.current + 1],
|
|
31
|
+
});
|
|
32
|
+
return color;
|
|
33
|
+
}
|
|
34
|
+
export function useStaticAnimationStyles(obj, keys) {
|
|
35
|
+
const styles = useRef({});
|
|
36
|
+
if (Object.keys(styles.current).length === 0) {
|
|
37
|
+
const mappedStyles = keys.map((k) => [k, { ...obj[k] }]);
|
|
38
|
+
styles.current = Object.fromEntries(mappedStyles);
|
|
39
|
+
}
|
|
40
|
+
return styles.current;
|
|
41
|
+
}
|
|
42
|
+
const buildAnimatedStyle = (property, value, currentStyle, applyFN = (v) => v) => {
|
|
43
|
+
'worklet';
|
|
44
|
+
const newStyle = { ...currentStyle };
|
|
45
|
+
switch (property) {
|
|
46
|
+
case 'opacity':
|
|
47
|
+
newStyle.opacity = applyFN(value);
|
|
48
|
+
break;
|
|
49
|
+
case 'backgroundColor':
|
|
50
|
+
newStyle.backgroundColor = applyFN(value);
|
|
51
|
+
break;
|
|
52
|
+
case 'scale':
|
|
53
|
+
case 'scaleX':
|
|
54
|
+
case 'scaleY':
|
|
55
|
+
case 'translateX':
|
|
56
|
+
case 'translateY':
|
|
57
|
+
if (!newStyle.transform) {
|
|
58
|
+
newStyle.transform = [];
|
|
59
|
+
}
|
|
60
|
+
newStyle.transform.push({
|
|
61
|
+
[property]: applyFN(value),
|
|
62
|
+
});
|
|
63
|
+
default:
|
|
64
|
+
newStyle[property] = value;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
return newStyle;
|
|
68
|
+
};
|
|
69
|
+
const transformProperties = (properties, transition) => {
|
|
70
|
+
'worklet';
|
|
71
|
+
let styles = {};
|
|
72
|
+
for (const [prop, value] of Object.entries(properties)) {
|
|
73
|
+
const transitionConfig = transition[prop] || transition;
|
|
74
|
+
const _transitionConfig = {
|
|
75
|
+
type: 'timing',
|
|
76
|
+
duration: 100,
|
|
77
|
+
easing: Easing.linear,
|
|
78
|
+
...transitionConfig,
|
|
79
|
+
};
|
|
80
|
+
const { type, duration, easing } = _transitionConfig;
|
|
81
|
+
let fn = (v) => v;
|
|
82
|
+
switch (type) {
|
|
83
|
+
case 'timing':
|
|
84
|
+
fn = (v) => withTiming(v, {
|
|
85
|
+
duration,
|
|
86
|
+
easing,
|
|
87
|
+
});
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
styles = buildAnimatedStyle(prop, value, styles, fn);
|
|
93
|
+
}
|
|
94
|
+
return styles;
|
|
95
|
+
};
|
|
96
|
+
export function useAnimatedVariantStyles(config) {
|
|
97
|
+
const { animatedProperties, updater, variantStyles, transition = {}, dependencies = [] } = config;
|
|
98
|
+
const _transition = useRef(null);
|
|
99
|
+
if (!_transition.current) {
|
|
100
|
+
_transition.current = JSON.parse(JSON.stringify(transition || {}));
|
|
101
|
+
}
|
|
102
|
+
const staticStyles = useStaticAnimationStyles(variantStyles, animatedProperties);
|
|
103
|
+
const animated = useAnimatedStyle(() => {
|
|
104
|
+
const nextState = updater(staticStyles);
|
|
105
|
+
const formatted = transformProperties(nextState, _transition.current);
|
|
106
|
+
return formatted;
|
|
107
|
+
}, dependencies);
|
|
108
|
+
return animated;
|
|
109
|
+
}
|
|
110
|
+
export function usePressableFeedback(styles, config) {
|
|
111
|
+
const { disabled, feedbackConfig, hightlightPropertyIn = 'backgroundColor', hightlightPropertyOut = 'backgroundColor', } = config;
|
|
112
|
+
const _feedbackConfig = {
|
|
113
|
+
...feedbackConfig,
|
|
114
|
+
};
|
|
115
|
+
let style;
|
|
116
|
+
if (TypeGuards.isObject(styles)) {
|
|
117
|
+
style = styles?.[hightlightPropertyIn];
|
|
118
|
+
}
|
|
119
|
+
else if (TypeGuards.isArray(styles)) {
|
|
120
|
+
style = styles.reverse().find(s => s[hightlightPropertyIn]);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
style = StyleSheet.flatten(styles)[hightlightPropertyIn];
|
|
124
|
+
}
|
|
125
|
+
const disableFeedback = disabled;
|
|
126
|
+
const rippleEnabled = _feedbackConfig?.type === 'ripple' && !disableFeedback;
|
|
127
|
+
const rippleConfig = rippleEnabled ? _feedbackConfig?.config : null;
|
|
128
|
+
function getFeedbackStyle(pressed) {
|
|
129
|
+
if (disableFeedback)
|
|
130
|
+
return {};
|
|
131
|
+
let feedbackConfig = { ..._feedbackConfig };
|
|
132
|
+
if (rippleEnabled && feedbackConfig.type === 'ripple' && Platform.OS === 'ios' && !!_feedbackConfig?.iosFallback) {
|
|
133
|
+
feedbackConfig = feedbackConfig?.iosFallback;
|
|
134
|
+
}
|
|
135
|
+
switch (feedbackConfig.type) {
|
|
136
|
+
case 'highlight':
|
|
137
|
+
if (!pressed && hightlightPropertyIn !== hightlightPropertyOut)
|
|
138
|
+
return {};
|
|
139
|
+
let highlightColorDefault = style || '#0000';
|
|
140
|
+
if (pressed) {
|
|
141
|
+
if (feedbackConfig?.color) {
|
|
142
|
+
highlightColorDefault = feedbackConfig?.color;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
let opacity = feedbackConfig?.shiftOpacity;
|
|
146
|
+
let brightness = feedbackConfig?.brightness;
|
|
147
|
+
if (!TypeGuards.isNumber(opacity)) {
|
|
148
|
+
opacity = 1;
|
|
149
|
+
}
|
|
150
|
+
if (!TypeGuards.isNumber(brightness)) {
|
|
151
|
+
brightness = 0;
|
|
152
|
+
}
|
|
153
|
+
highlightColorDefault = shadeColor(highlightColorDefault, brightness * 100, opacity);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
[hightlightPropertyOut]: highlightColorDefault,
|
|
158
|
+
};
|
|
159
|
+
break;
|
|
160
|
+
case 'opacity':
|
|
161
|
+
return {
|
|
162
|
+
opacity: pressed ? feedbackConfig?.value : 1,
|
|
163
|
+
};
|
|
164
|
+
case 'styles':
|
|
165
|
+
return pressed ? feedbackConfig?.styles : {};
|
|
166
|
+
case 'none':
|
|
167
|
+
return {};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
getFeedbackStyle,
|
|
172
|
+
rippleConfig,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export function useBackButton(cb, deps = []) {
|
|
176
|
+
onUpdate(() => {
|
|
177
|
+
const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
|
|
178
|
+
const stopBubbling = cb();
|
|
179
|
+
if (TypeGuards.isBoolean(stopBubbling)) {
|
|
180
|
+
return stopBubbling;
|
|
181
|
+
}
|
|
182
|
+
return false;
|
|
183
|
+
});
|
|
184
|
+
return () => {
|
|
185
|
+
subscription.remove();
|
|
186
|
+
};
|
|
187
|
+
}, deps);
|
|
188
|
+
}
|
|
189
|
+
/** Merges keyboard height into `paddingBottom` rather than adjusting layout height or using `KeyboardAvoidingView` because padding-based adjustment composites cleanly with existing scroll content insets and does not cause a layout jump on Android. */
|
|
190
|
+
export function useKeyboardPaddingStyle(styles, enabled = true) {
|
|
191
|
+
const { isVisible, height } = useKeyboardController();
|
|
192
|
+
const propStyle = useMemo(() => {
|
|
193
|
+
return StyleSheet.flatten(styles);
|
|
194
|
+
}, styles);
|
|
195
|
+
const bottomPadding = propStyle && TypeGuards.isNumber(propStyle.paddingBottom) ? propStyle.paddingBottom : 0;
|
|
196
|
+
const totalPadding = height + bottomPadding;
|
|
197
|
+
return isVisible && enabled ? mergeStyles([propStyle, { paddingBottom: totalPadding }]) : propStyle;
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/utils/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAoC,UAAU,EAAa,MAAM,cAAc,CAAA;AACvH,OAAO,EAAiB,MAAM,EAAkB,gBAAgB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAE7G,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAEhD,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,IAA8C;IAC3F,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IACvB,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;IAC1D,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,CAAA;IAChC,MAAM,IAA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
|
|
3
|
+
export * from './misc';
|
|
4
|
+
export * from './NotificationManager';
|
|
5
|
+
export * from './input';
|
|
6
|
+
export * from './theme';
|
|
7
|
+
export * from './locale';
|
|
8
|
+
export * from './Subscription';
|
|
9
|
+
export * from './useQueryListRefresh';
|
|
10
|
+
export * from './StorageManager';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,uBAAuB,CAAA;AACrC,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const createInputPresets = (p) => {
|
|
2
|
+
return p;
|
|
3
|
+
};
|
|
4
|
+
export const mobileInputPresets = createInputPresets({
|
|
5
|
+
email: () => ({
|
|
6
|
+
keyboardType: 'email-address',
|
|
7
|
+
autoCapitalize: 'none',
|
|
8
|
+
autoComplete: 'email',
|
|
9
|
+
textContentType: 'emailAddress',
|
|
10
|
+
}),
|
|
11
|
+
name: () => ({
|
|
12
|
+
autoCapitalize: 'words',
|
|
13
|
+
autoComplete: 'name',
|
|
14
|
+
textContentType: 'name',
|
|
15
|
+
}),
|
|
16
|
+
chat: () => ({
|
|
17
|
+
returnKeyType: 'send',
|
|
18
|
+
}),
|
|
19
|
+
password: (options) => {
|
|
20
|
+
return {
|
|
21
|
+
autoCapitalize: 'none',
|
|
22
|
+
autoComplete: options?.new ? 'password-new' : 'password',
|
|
23
|
+
textContentType: options?.new ? 'newPassword' : 'password',
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
search: () => ({
|
|
27
|
+
returnKeyType: 'search',
|
|
28
|
+
}),
|
|
29
|
+
redeemCode: (action = 'obtain') => {
|
|
30
|
+
const isJoin = action === 'join';
|
|
31
|
+
if (isJoin) {
|
|
32
|
+
return {
|
|
33
|
+
returnKeyType: 'join',
|
|
34
|
+
textContentType: 'oneTimeCode',
|
|
35
|
+
autoComplete: 'sms-otp',
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
returnKeyType: 'done',
|
|
40
|
+
textContentType: 'oneTimeCode',
|
|
41
|
+
autoComplete: 'sms-otp',
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"AAEA,MAAM,kBAAkB,GAAG,CAAuE,CAAG,EAAI,EAAE;IACzG,OAAO,CAAC,CAAA;AACV,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;IACnD,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACZ,YAAY,EAAE,eAAe;QAC7B,cAAc,EAAE,MAAM;QACtB,YAAY,EAAE,OAAO;QACrB,eAAe,EAAE,cAAc;KAEhC,CAAC;IACF,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;QACX,cAAc,EAAE,OAAO;QACvB,YAAY,EAAE,MAAM;QACpB,eAAe,EAAE,MAAM;KAExB,CAAC;IACF,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;QACX,aAAa,EAAE,MAAM;KAEtB,CAAC;IACF,QAAQ,EAAE,CAAC,OAAyB,EAAE,EAAE;QACtC,OAAO;YACL,cAAc,EAAE,MAAM;YACtB,YAAY,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,UAAU;YACxD,eAAe,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU;SAC3D,CAAA;IACH,CAAC;IACD,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QACb,aAAa,EAAE,QAAQ;KACxB,CAAC;IACF,UAAU,EAAE,CAAC,SAAyB,QAAQ,EAAE,EAAE;QAChD,MAAM,MAAM,GAAG,MAAM,KAAK,MAAM,CAAA;QAChC,IAAI,MAAM,EAAE,CAAC;YACX,OAAO;gBACL,aAAa,EAAE,MAAM;gBACrB,eAAe,EAAE,aAAa;gBAC9B,YAAY,EAAE,SAAS;aACxB,CAAA;QACH,CAAC;QACD,OAAO;YACL,aAAa,EAAE,MAAM;YACrB,eAAe,EAAE,aAAa;YAC9B,YAAY,EAAE,SAAS;SACxB,CAAA;IAEH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { findBestLanguageTag, getLocales } from 'react-native-localize';
|
|
2
|
+
export function getDeviceLocale(dictionary, defaultLocale) {
|
|
3
|
+
const deviceLocales = getLocales().map(locale => locale?.languageTag);
|
|
4
|
+
const dictionaryLocales = Object.keys(dictionary);
|
|
5
|
+
const possibleLocales = [...new Set([...dictionaryLocales, ...deviceLocales])];
|
|
6
|
+
const bestLocale = findBestLanguageTag(possibleLocales);
|
|
7
|
+
if (!bestLocale)
|
|
8
|
+
return defaultLocale;
|
|
9
|
+
return bestLocale?.languageTag;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=locale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/utils/locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvE,MAAM,UAAU,eAAe,CAAC,UAA+B,EAAE,aAAqB;IACpF,MAAM,aAAa,GAAG,UAAU,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IAErE,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAEjD,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,iBAAiB,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAA;IAE9E,MAAM,UAAU,GAAG,mBAAmB,CAAC,eAAe,CAAC,CAAA;IAEvD,IAAI,CAAC,UAAU;QAAE,OAAO,aAAa,CAAA;IAErC,OAAO,UAAU,EAAE,WAAW,CAAA;AAChC,CAAC"}
|