@codeleap/mobile 2.4.7 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mobile-packages.code-workspace +27 -0
- package/package.json +25 -33
- package/src/components/ActionIcon/index.tsx +16 -6
- package/src/components/ActionIcon/styles.ts +3 -90
- package/src/components/ActivityIndicator/index.tsx +28 -9
- package/src/components/ActivityIndicator/styles.ts +2 -59
- package/src/components/Autocomplete/index.tsx +235 -0
- package/src/components/Autocomplete/styles.ts +18 -0
- package/src/components/Autocomplete/types.ts +75 -0
- package/src/components/Avatar/index.tsx +126 -0
- package/src/components/Avatar/styles.ts +22 -0
- package/src/components/AvatarGroup/index.tsx +76 -0
- package/src/components/AvatarGroup/styles.ts +11 -0
- package/src/components/Backdrop/index.tsx +14 -13
- package/src/components/Backdrop/styles.ts +3 -24
- package/src/components/Badge/index.tsx +134 -0
- package/src/components/Badge/styles.ts +14 -0
- package/src/components/Button/index.tsx +39 -49
- package/src/components/Button/styles.ts +6 -107
- package/src/components/Calendar/index.tsx +3 -3
- package/src/components/Calendar/style.ts +2 -31
- package/src/components/Checkbox/index.tsx +137 -74
- package/src/components/Checkbox/styles.ts +13 -73
- package/src/components/ContentView/index.tsx +2 -2
- package/src/components/ContentView/styles.ts +1 -17
- package/src/components/DatePickerModal/index.tsx +240 -0
- package/src/components/DatePickerModal/styles.ts +15 -0
- package/src/components/DatePickerModal/types.ts +55 -0
- package/src/components/Drawer/index.tsx +2 -2
- package/src/components/Drawer/styles.ts +4 -39
- package/src/components/EmptyPlaceholder/index.tsx +3 -3
- package/src/components/EmptyPlaceholder/styles.ts +2 -47
- package/src/components/FileInput/styles.ts +1 -8
- package/src/components/Grid/index.tsx +76 -72
- package/src/components/Grid/styles.ts +4 -7
- package/src/components/Icon/index.tsx +46 -8
- package/src/components/Icon/styles.ts +3 -51
- package/src/components/Image/index.tsx +18 -22
- package/src/components/Image/styles.ts +1 -14
- package/src/components/ImageView/Spotlight.tsx +4 -2
- package/src/components/ImageView/component.tsx +0 -3
- package/src/components/InputBase/index.tsx +101 -0
- package/src/components/InputBase/styles.ts +135 -0
- package/src/components/InputBase/types.ts +28 -0
- package/src/components/InputBase/utils.ts +42 -0
- package/src/components/InputLabel/index.tsx +3 -3
- package/src/components/InputLabel/styles.ts +2 -14
- package/src/components/List/PaginationIndicator.tsx +4 -21
- package/src/components/List/index.tsx +84 -46
- package/src/components/List/styles.ts +8 -20
- package/src/components/LoadingOverlay/index.tsx +45 -45
- package/src/components/LoadingOverlay/styles.ts +5 -27
- package/src/components/Modal/index.tsx +56 -32
- package/src/components/Modal/styles.ts +3 -114
- package/src/components/NumberIncrement/index.tsx +318 -0
- package/src/components/NumberIncrement/styles.ts +14 -0
- package/src/components/NumberIncrement/types.ts +44 -0
- package/src/components/NumberIncrement/utils.ts +27 -0
- package/src/components/Pager/index.tsx +120 -67
- package/src/components/Pager/styles.ts +2 -69
- package/src/components/RadioInput/index.tsx +145 -68
- package/src/components/RadioInput/styles.ts +8 -61
- package/src/components/RefreshControl/index.tsx +28 -0
- package/src/components/RefreshControl/styles.ts +7 -0
- package/src/components/Scroll/index.tsx +22 -37
- package/src/components/Scroll/styles.ts +2 -16
- package/src/components/Sections/index.tsx +116 -54
- package/src/components/Sections/styles.ts +7 -0
- package/src/components/SegmentedControl/Option.tsx +51 -0
- package/src/components/SegmentedControl/index.tsx +51 -67
- package/src/components/SegmentedControl/styles.ts +7 -63
- package/src/components/Select/index.tsx +268 -95
- package/src/components/Select/styles.ts +11 -131
- package/src/components/Select/types.ts +47 -11
- package/src/components/Slider/index.tsx +151 -94
- package/src/components/Slider/styles.ts +7 -72
- package/src/components/Slider/types.ts +18 -20
- package/src/components/Switch/index.tsx +115 -63
- package/src/components/Switch/styles.ts +13 -30
- package/src/components/Text/index.tsx +14 -31
- package/src/components/Text/styles.ts +2 -41
- package/src/components/TextInput/index.tsx +237 -259
- package/src/components/TextInput/styles.ts +6 -120
- package/src/components/Touchable/index.tsx +74 -27
- package/src/components/Touchable/styles.ts +1 -12
- package/src/components/View/index.tsx +11 -26
- package/src/components/View/styles.ts +1 -17
- package/src/components/components.ts +9 -5
- package/src/components/defaultStyles.ts +74 -61
- package/src/index.ts +0 -1
- package/src/modules/PressableRipple/index.ts +5 -0
- package/src/modules/PressableRipple/ripple.js +258 -0
- package/src/modules/PressableRipple/styles.js +22 -0
- package/src/modules/PressableRipple/type.ts +17 -0
- package/src/modules/textInputMask.tsx +13 -0
- package/src/types/index.ts +5 -0
- package/src/types/utility.ts +2 -2
- package/src/utils/KeyboardAware/index.ts +0 -13
- package/src/utils/KeyboardAware/keyboardHooks.ts +69 -79
- package/src/utils/hooks.ts +63 -36
- package/src/utils/index.ts +1 -0
- package/src/utils/locale.ts +7 -0
- package/src/utils/theme.ts +1 -21
- package/dist/components/ActionIcon/index.d.ts +0 -13
- package/dist/components/ActionIcon/index.js +0 -51
- package/dist/components/ActionIcon/index.js.map +0 -1
- package/dist/components/ActionIcon/styles.d.ts +0 -65
- package/dist/components/ActionIcon/styles.js +0 -61
- package/dist/components/ActionIcon/styles.js.map +0 -1
- package/dist/components/ActivityIndicator/index.d.ts +0 -15
- package/dist/components/ActivityIndicator/index.js +0 -55
- package/dist/components/ActivityIndicator/index.js.map +0 -1
- package/dist/components/ActivityIndicator/styles.d.ts +0 -59
- package/dist/components/ActivityIndicator/styles.js +0 -52
- package/dist/components/ActivityIndicator/styles.js.map +0 -1
- package/dist/components/Animated.d.ts +0 -15
- package/dist/components/Animated.js +0 -55
- package/dist/components/Animated.js.map +0 -1
- package/dist/components/AutoComplete/index.d.ts +0 -34
- package/dist/components/AutoComplete/index.js +0 -126
- package/dist/components/AutoComplete/index.js.map +0 -1
- package/dist/components/AutoComplete/styles.d.ts +0 -57
- package/dist/components/AutoComplete/styles.js +0 -89
- package/dist/components/AutoComplete/styles.js.map +0 -1
- package/dist/components/Backdrop/index.d.ts +0 -14
- package/dist/components/Backdrop/index.js +0 -59
- package/dist/components/Backdrop/index.js.map +0 -1
- package/dist/components/Backdrop/styles.d.ts +0 -53
- package/dist/components/Backdrop/styles.js +0 -28
- package/dist/components/Backdrop/styles.js.map +0 -1
- package/dist/components/Button/index.d.ts +0 -246
- package/dist/components/Button/index.js +0 -115
- package/dist/components/Button/index.js.map +0 -1
- package/dist/components/Button/styles.d.ts +0 -65
- package/dist/components/Button/styles.js +0 -61
- package/dist/components/Button/styles.js.map +0 -1
- package/dist/components/Calendar/index.d.ts +0 -15
- package/dist/components/Calendar/index.js +0 -76
- package/dist/components/Calendar/index.js.map +0 -1
- package/dist/components/Calendar/style.d.ts +0 -4
- package/dist/components/Calendar/style.js +0 -36
- package/dist/components/Calendar/style.js.map +0 -1
- package/dist/components/Calendar/types.d.ts +0 -95
- package/dist/components/Calendar/types.js +0 -3
- package/dist/components/Calendar/types.js.map +0 -1
- package/dist/components/Checkbox/index.d.ts +0 -15
- package/dist/components/Checkbox/index.js +0 -81
- package/dist/components/Checkbox/index.js.map +0 -1
- package/dist/components/Checkbox/styles.d.ts +0 -56
- package/dist/components/Checkbox/styles.js +0 -53
- package/dist/components/Checkbox/styles.js.map +0 -1
- package/dist/components/ContentView/index.d.ts +0 -12
- package/dist/components/ContentView/index.js +0 -62
- package/dist/components/ContentView/index.js.map +0 -1
- package/dist/components/ContentView/styles.d.ts +0 -53
- package/dist/components/ContentView/styles.js +0 -26
- package/dist/components/ContentView/styles.js.map +0 -1
- package/dist/components/Drawer/index.d.ts +0 -7
- package/dist/components/Drawer/index.js +0 -66
- package/dist/components/Drawer/index.js.map +0 -1
- package/dist/components/Drawer/styles.d.ts +0 -56
- package/dist/components/Drawer/styles.js +0 -39
- package/dist/components/Drawer/styles.js.map +0 -1
- package/dist/components/EmptyPlaceholder/index.d.ts +0 -25
- package/dist/components/EmptyPlaceholder/index.js +0 -88
- package/dist/components/EmptyPlaceholder/index.js.map +0 -1
- package/dist/components/EmptyPlaceholder/styles.d.ts +0 -55
- package/dist/components/EmptyPlaceholder/styles.js +0 -30
- package/dist/components/EmptyPlaceholder/styles.js.map +0 -1
- package/dist/components/FileInput/index.d.ts +0 -24
- package/dist/components/FileInput/index.js +0 -179
- package/dist/components/FileInput/index.js.map +0 -1
- package/dist/components/FileInput/styles.d.ts +0 -53
- package/dist/components/FileInput/styles.js +0 -19
- package/dist/components/FileInput/styles.js.map +0 -1
- package/dist/components/Grid/index.d.ts +0 -32
- package/dist/components/Grid/index.js +0 -80
- package/dist/components/Grid/index.js.map +0 -1
- package/dist/components/Grid/styles.d.ts +0 -54
- package/dist/components/Grid/styles.js +0 -19
- package/dist/components/Grid/styles.js.map +0 -1
- package/dist/components/Icon/index.d.ts +0 -14
- package/dist/components/Icon/index.js +0 -75
- package/dist/components/Icon/index.js.map +0 -1
- package/dist/components/Icon/styles.d.ts +0 -61
- package/dist/components/Icon/styles.js +0 -49
- package/dist/components/Icon/styles.js.map +0 -1
- package/dist/components/Image/index.d.ts +0 -25
- package/dist/components/Image/index.js +0 -130
- package/dist/components/Image/index.js.map +0 -1
- package/dist/components/Image/styles.d.ts +0 -55
- package/dist/components/Image/styles.js +0 -25
- package/dist/components/Image/styles.js.map +0 -1
- package/dist/components/ImageView/Spotlight.d.ts +0 -25
- package/dist/components/ImageView/Spotlight.js +0 -150
- package/dist/components/ImageView/Spotlight.js.map +0 -1
- package/dist/components/ImageView/component.d.ts +0 -5
- package/dist/components/ImageView/component.js +0 -50
- package/dist/components/ImageView/component.js.map +0 -1
- package/dist/components/ImageView/index.d.ts +0 -2
- package/dist/components/ImageView/index.js +0 -15
- package/dist/components/ImageView/index.js.map +0 -1
- package/dist/components/InputLabel/index.d.ts +0 -12
- package/dist/components/InputLabel/index.js +0 -58
- package/dist/components/InputLabel/index.js.map +0 -1
- package/dist/components/InputLabel/styles.d.ts +0 -4
- package/dist/components/InputLabel/styles.js +0 -26
- package/dist/components/InputLabel/styles.js.map +0 -1
- package/dist/components/List/PaginationIndicator.d.ts +0 -67
- package/dist/components/List/PaginationIndicator.js +0 -51
- package/dist/components/List/PaginationIndicator.js.map +0 -1
- package/dist/components/List/index.d.ts +0 -31
- package/dist/components/List/index.js +0 -77
- package/dist/components/List/index.js.map +0 -1
- package/dist/components/List/styles.d.ts +0 -54
- package/dist/components/List/styles.js +0 -28
- package/dist/components/List/styles.js.map +0 -1
- package/dist/components/LoadingOverlay/index.d.ts +0 -11
- package/dist/components/LoadingOverlay/index.js +0 -60
- package/dist/components/LoadingOverlay/index.js.map +0 -1
- package/dist/components/LoadingOverlay/styles.d.ts +0 -7
- package/dist/components/LoadingOverlay/styles.js +0 -34
- package/dist/components/LoadingOverlay/styles.js.map +0 -1
- package/dist/components/Modal/index.d.ts +0 -43
- package/dist/components/Modal/index.js +0 -147
- package/dist/components/Modal/index.js.map +0 -1
- package/dist/components/Modal/styles.d.ts +0 -58
- package/dist/components/Modal/styles.js +0 -74
- package/dist/components/Modal/styles.js.map +0 -1
- package/dist/components/MultiSelect/index.d.ts +0 -6
- package/dist/components/MultiSelect/index.js +0 -119
- package/dist/components/MultiSelect/index.js.map +0 -1
- package/dist/components/MultiSelect/styles.d.ts +0 -7
- package/dist/components/MultiSelect/styles.js +0 -84
- package/dist/components/MultiSelect/styles.js.map +0 -1
- package/dist/components/MultiSelect/types.d.ts +0 -43
- package/dist/components/MultiSelect/types.js +0 -3
- package/dist/components/MultiSelect/types.js.map +0 -1
- package/dist/components/Navigation/Navigation.d.ts +0 -3
- package/dist/components/Navigation/Navigation.js +0 -80
- package/dist/components/Navigation/Navigation.js.map +0 -1
- package/dist/components/Navigation/constants.d.ts +0 -5
- package/dist/components/Navigation/constants.js +0 -11
- package/dist/components/Navigation/constants.js.map +0 -1
- package/dist/components/Navigation/index.d.ts +0 -3
- package/dist/components/Navigation/index.js +0 -16
- package/dist/components/Navigation/index.js.map +0 -1
- package/dist/components/Navigation/types.d.ts +0 -26
- package/dist/components/Navigation/types.js +0 -8
- package/dist/components/Navigation/types.js.map +0 -1
- package/dist/components/Navigation/utils.d.ts +0 -3
- package/dist/components/Navigation/utils.js +0 -69
- package/dist/components/Navigation/utils.js.map +0 -1
- package/dist/components/Pager/index.d.ts +0 -26
- package/dist/components/Pager/index.js +0 -84
- package/dist/components/Pager/index.js.map +0 -1
- package/dist/components/Pager/styles.d.ts +0 -87
- package/dist/components/Pager/styles.js +0 -72
- package/dist/components/Pager/styles.js.map +0 -1
- package/dist/components/RadioInput/index.d.ts +0 -27
- package/dist/components/RadioInput/index.js +0 -72
- package/dist/components/RadioInput/index.js.map +0 -1
- package/dist/components/RadioInput/styles.d.ts +0 -58
- package/dist/components/RadioInput/styles.js +0 -50
- package/dist/components/RadioInput/styles.js.map +0 -1
- package/dist/components/Scroll/index.d.ts +0 -124
- package/dist/components/Scroll/index.js +0 -97
- package/dist/components/Scroll/index.js.map +0 -1
- package/dist/components/Scroll/styles.d.ts +0 -53
- package/dist/components/Scroll/styles.js +0 -26
- package/dist/components/Scroll/styles.js.map +0 -1
- package/dist/components/Sections/index.d.ts +0 -115
- package/dist/components/Sections/index.js +0 -76
- package/dist/components/Sections/index.js.map +0 -1
- package/dist/components/SegmentedControl/index.d.ts +0 -52
- package/dist/components/SegmentedControl/index.js +0 -131
- package/dist/components/SegmentedControl/index.js.map +0 -1
- package/dist/components/SegmentedControl/styles.d.ts +0 -60
- package/dist/components/SegmentedControl/styles.js +0 -43
- package/dist/components/SegmentedControl/styles.js.map +0 -1
- package/dist/components/Select/index.d.ts +0 -16
- package/dist/components/Select/index.js +0 -122
- package/dist/components/Select/index.js.map +0 -1
- package/dist/components/Select/styles.d.ts +0 -60
- package/dist/components/Select/styles.js +0 -83
- package/dist/components/Select/styles.js.map +0 -1
- package/dist/components/Select/types.d.ts +0 -43
- package/dist/components/Select/types.js +0 -3
- package/dist/components/Select/types.js.map +0 -1
- package/dist/components/Slider/Mark.d.ts +0 -3
- package/dist/components/Slider/Mark.js +0 -32
- package/dist/components/Slider/Mark.js.map +0 -1
- package/dist/components/Slider/Thumb.d.ts +0 -7
- package/dist/components/Slider/Thumb.js +0 -30
- package/dist/components/Slider/Thumb.js.map +0 -1
- package/dist/components/Slider/index.d.ts +0 -4
- package/dist/components/Slider/index.js +0 -99
- package/dist/components/Slider/index.js.map +0 -1
- package/dist/components/Slider/styles.d.ts +0 -54
- package/dist/components/Slider/styles.js +0 -61
- package/dist/components/Slider/styles.js.map +0 -1
- package/dist/components/Slider/types.d.ts +0 -26
- package/dist/components/Slider/types.js +0 -3
- package/dist/components/Slider/types.js.map +0 -1
- package/dist/components/Switch/index.d.ts +0 -14
- package/dist/components/Switch/index.js +0 -81
- package/dist/components/Switch/index.js.map +0 -1
- package/dist/components/Switch/styles.d.ts +0 -55
- package/dist/components/Switch/styles.js +0 -34
- package/dist/components/Switch/styles.js.map +0 -1
- package/dist/components/Text/index.d.ts +0 -25
- package/dist/components/Text/index.js +0 -121
- package/dist/components/Text/index.js.map +0 -1
- package/dist/components/Text/styles.d.ts +0 -70
- package/dist/components/Text/styles.js +0 -34
- package/dist/components/Text/styles.js.map +0 -1
- package/dist/components/TextInput/index.d.ts +0 -181
- package/dist/components/TextInput/index.js +0 -213
- package/dist/components/TextInput/index.js.map +0 -1
- package/dist/components/TextInput/styles.d.ts +0 -63
- package/dist/components/TextInput/styles.js +0 -65
- package/dist/components/TextInput/styles.js.map +0 -1
- package/dist/components/Touchable/index.d.ts +0 -22
- package/dist/components/Touchable/index.js +0 -165
- package/dist/components/Touchable/index.js.map +0 -1
- package/dist/components/Touchable/styles.d.ts +0 -58
- package/dist/components/Touchable/styles.js +0 -24
- package/dist/components/Touchable/styles.js.map +0 -1
- package/dist/components/View/index.d.ts +0 -25
- package/dist/components/View/index.js +0 -107
- package/dist/components/View/index.js.map +0 -1
- package/dist/components/View/styles.d.ts +0 -54
- package/dist/components/View/styles.js +0 -29
- package/dist/components/View/styles.js.map +0 -1
- package/dist/components/components.d.ts +0 -37
- package/dist/components/components.js +0 -50
- package/dist/components/components.js.map +0 -1
- package/dist/components/defaultStyles.d.ts +0 -1468
- package/dist/components/defaultStyles.js +0 -67
- package/dist/components/defaultStyles.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -39
- package/dist/index.js.map +0 -1
- package/dist/modules/documentPicker.d.ts +0 -3
- package/dist/modules/documentPicker.js +0 -12
- package/dist/modules/documentPicker.js.map +0 -1
- package/dist/modules/fastImage.d.ts +0 -1
- package/dist/modules/fastImage.js +0 -10
- package/dist/modules/fastImage.js.map +0 -1
- package/dist/modules/reactNavigation.d.ts +0 -5
- package/dist/modules/reactNavigation.js +0 -26
- package/dist/modules/reactNavigation.js.map +0 -1
- package/dist/modules/rnDeviceInfo.d.ts +0 -2
- package/dist/modules/rnDeviceInfo.js +0 -10
- package/dist/modules/rnDeviceInfo.js.map +0 -1
- package/dist/modules/textInputMask.d.ts +0 -10
- package/dist/modules/textInputMask.js +0 -19
- package/dist/modules/textInputMask.js.map +0 -1
- package/dist/modules/types/fileTypes.d.ts +0 -138
- package/dist/modules/types/fileTypes.js +0 -3
- package/dist/modules/types/fileTypes.js.map +0 -1
- package/dist/modules/types/textInputMask.d.ts +0 -7
- package/dist/modules/types/textInputMask.js +0 -3
- package/dist/modules/types/textInputMask.js.map +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +0 -14
- package/dist/types/index.js.map +0 -1
- package/dist/types/utility.d.ts +0 -14
- package/dist/types/utility.js +0 -3
- package/dist/types/utility.js.map +0 -1
- package/dist/utils/KeyboardAware/context.d.ts +0 -13
- package/dist/utils/KeyboardAware/context.js +0 -63
- package/dist/utils/KeyboardAware/context.js.map +0 -1
- package/dist/utils/KeyboardAware/index.d.ts +0 -8
- package/dist/utils/KeyboardAware/index.js +0 -29
- package/dist/utils/KeyboardAware/index.js.map +0 -1
- package/dist/utils/KeyboardAware/keyboardHooks.d.ts +0 -26
- package/dist/utils/KeyboardAware/keyboardHooks.js +0 -87
- package/dist/utils/KeyboardAware/keyboardHooks.js.map +0 -1
- package/dist/utils/KeyboardAware/lib/KeyboardAwareFlatList.d.ts +0 -3
- package/dist/utils/KeyboardAware/lib/KeyboardAwareFlatList.js +0 -9
- package/dist/utils/KeyboardAware/lib/KeyboardAwareFlatList.js.map +0 -1
- package/dist/utils/KeyboardAware/lib/KeyboardAwareHOC.d.ts +0 -67
- package/dist/utils/KeyboardAware/lib/KeyboardAwareHOC.js +0 -439
- package/dist/utils/KeyboardAware/lib/KeyboardAwareHOC.js.map +0 -1
- package/dist/utils/KeyboardAware/lib/KeyboardAwareInterface.d.ts +0 -7
- package/dist/utils/KeyboardAware/lib/KeyboardAwareInterface.js +0 -4
- package/dist/utils/KeyboardAware/lib/KeyboardAwareInterface.js.map +0 -1
- package/dist/utils/KeyboardAware/lib/KeyboardAwareScrollView.d.ts +0 -3
- package/dist/utils/KeyboardAware/lib/KeyboardAwareScrollView.js +0 -10
- package/dist/utils/KeyboardAware/lib/KeyboardAwareScrollView.js.map +0 -1
- package/dist/utils/KeyboardAware/lib/KeyboardAwareSectionList.d.ts +0 -3
- package/dist/utils/KeyboardAware/lib/KeyboardAwareSectionList.js +0 -10
- package/dist/utils/KeyboardAware/lib/KeyboardAwareSectionList.js.map +0 -1
- package/dist/utils/KeyboardAware/types.d.ts +0 -1
- package/dist/utils/KeyboardAware/types.js +0 -7
- package/dist/utils/KeyboardAware/types.js.map +0 -1
- package/dist/utils/ModalManager/components.d.ts +0 -20
- package/dist/utils/ModalManager/components.js +0 -114
- package/dist/utils/ModalManager/components.js.map +0 -1
- package/dist/utils/ModalManager/context.d.ts +0 -48
- package/dist/utils/ModalManager/context.js +0 -201
- package/dist/utils/ModalManager/context.js.map +0 -1
- package/dist/utils/ModalManager/index.d.ts +0 -11
- package/dist/utils/ModalManager/index.js +0 -13
- package/dist/utils/ModalManager/index.js.map +0 -1
- package/dist/utils/OSAlert.d.ts +0 -32
- package/dist/utils/OSAlert.js +0 -143
- package/dist/utils/OSAlert.js.map +0 -1
- package/dist/utils/PermissionManager/context.d.ts +0 -53
- package/dist/utils/PermissionManager/context.js +0 -320
- package/dist/utils/PermissionManager/context.js.map +0 -1
- package/dist/utils/PermissionManager/index.d.ts +0 -4
- package/dist/utils/PermissionManager/index.js +0 -9
- package/dist/utils/PermissionManager/index.js.map +0 -1
- package/dist/utils/PermissionManager/types.d.ts +0 -13
- package/dist/utils/PermissionManager/types.js +0 -3
- package/dist/utils/PermissionManager/types.js.map +0 -1
- package/dist/utils/hooks.d.ts +0 -61
- package/dist/utils/hooks.js +0 -233
- package/dist/utils/hooks.js.map +0 -1
- package/dist/utils/index.d.ts +0 -10
- package/dist/utils/index.js +0 -36
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/input.d.ts +0 -35
- package/dist/utils/input.js +0 -49
- package/dist/utils/input.js.map +0 -1
- package/dist/utils/misc.d.ts +0 -6
- package/dist/utils/misc.js +0 -87
- package/dist/utils/misc.js.map +0 -1
- package/dist/utils/notifications.d.ts +0 -34
- package/dist/utils/notifications.js +0 -268
- package/dist/utils/notifications.js.map +0 -1
- package/dist/utils/theme.d.ts +0 -42
- package/dist/utils/theme.js +0 -50
- package/dist/utils/theme.js.map +0 -1
- package/src/components/Animated.tsx +0 -34
- package/src/components/AutoComplete/index.tsx +0 -167
- package/src/components/AutoComplete/styles.ts +0 -150
- package/src/components/MultiSelect/index.tsx +0 -148
- package/src/components/MultiSelect/styles.ts +0 -131
- package/src/components/MultiSelect/types.ts +0 -51
- package/src/components/Slider/Mark.tsx +0 -46
- package/src/components/Slider/Thumb.tsx +0 -29
- package/src/modules/textInputMask.ts +0 -11
- package/src/utils/KeyboardAware/lib/KeyboardAwareFlatList.ts +0 -4
- package/src/utils/KeyboardAware/lib/KeyboardAwareHOC.tsx +0 -592
- package/src/utils/KeyboardAware/lib/KeyboardAwareInterface.ts +0 -13
- package/src/utils/KeyboardAware/lib/KeyboardAwareScrollView.ts +0 -6
- package/src/utils/KeyboardAware/lib/KeyboardAwareSectionList.ts +0 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { View, ViewProps } from '../View'
|
|
3
3
|
import { ButtonProps } from '../Button'
|
|
4
4
|
import { Scroll } from '../Scroll'
|
|
5
5
|
import {
|
|
@@ -12,14 +12,14 @@ import {
|
|
|
12
12
|
} from '@codeleap/common'
|
|
13
13
|
import {
|
|
14
14
|
ModalComposition,
|
|
15
|
-
|
|
15
|
+
ModalPresets,
|
|
16
16
|
ModalParts,
|
|
17
17
|
} from './styles'
|
|
18
18
|
import { StyleSheet } from 'react-native'
|
|
19
19
|
import { StylesOf } from '../../types/utility'
|
|
20
20
|
|
|
21
21
|
import { Backdrop } from '../Backdrop'
|
|
22
|
-
import { useAnimatedVariantStyles, useBackButton
|
|
22
|
+
import { useAnimatedVariantStyles, useBackButton } from '../../utils/hooks'
|
|
23
23
|
import { Text, TextProps } from '../Text'
|
|
24
24
|
import { Touchable } from '../Touchable'
|
|
25
25
|
import { GetKeyboardAwarePropsOptions } from '../../utils'
|
|
@@ -28,7 +28,7 @@ import { ActionIcon } from '../ActionIcon'
|
|
|
28
28
|
export * from './styles'
|
|
29
29
|
|
|
30
30
|
export type ModalProps = Omit<ViewProps, 'variants' | 'styles'> & {
|
|
31
|
-
variants?: ComponentVariants<typeof
|
|
31
|
+
variants?: ComponentVariants<typeof ModalPresets>['variants']
|
|
32
32
|
styles?: StylesOf<ModalComposition>
|
|
33
33
|
dismissOnBackdrop?: boolean
|
|
34
34
|
buttonProps?: ButtonProps
|
|
@@ -48,36 +48,54 @@ export type ModalProps = Omit<ViewProps, 'variants' | 'styles'> & {
|
|
|
48
48
|
closeOnHardwareBackPress?: boolean
|
|
49
49
|
renderHeader?: (props: ModalHeaderProps) => React.ReactElement
|
|
50
50
|
keyboardAware?: GetKeyboardAwarePropsOptions
|
|
51
|
-
scrollProps?: PropsOf<typeof Scroll>
|
|
51
|
+
scrollProps?: PropsOf<typeof Scroll, 'ref'>
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export type ModalHeaderProps = Omit<ModalProps, 'styles' | 'renderHeader'> & {
|
|
55
55
|
styles: {
|
|
56
56
|
wrapper: ViewProps['style']
|
|
57
|
+
titleWrapper: ViewProps['style']
|
|
57
58
|
title: TextProps['style']
|
|
59
|
+
description: TextProps['style']
|
|
58
60
|
closeButton: ButtonProps['styles']
|
|
59
61
|
}
|
|
60
62
|
description?: React.ReactElement
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
const DefaultHeader:React.FC<ModalHeaderProps> = (props) => {
|
|
64
|
-
const {
|
|
66
|
+
const {
|
|
67
|
+
styles,
|
|
68
|
+
title = null,
|
|
69
|
+
showClose = false,
|
|
70
|
+
description = null,
|
|
71
|
+
closable, debugName,
|
|
72
|
+
closeIconName = 'x',
|
|
73
|
+
toggle,
|
|
74
|
+
} = props
|
|
65
75
|
return <>
|
|
66
76
|
{(title || showClose || description) && (
|
|
67
77
|
<View style={styles.wrapper}>
|
|
68
|
-
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
<View style={styles.titleWrapper}>
|
|
79
|
+
{TypeGuards.isString(title) ? (
|
|
80
|
+
<Text text={title} style={styles.title} />
|
|
81
|
+
) : (
|
|
82
|
+
title
|
|
83
|
+
)}
|
|
84
|
+
|
|
85
|
+
{(showClose && closable) && (
|
|
86
|
+
<ActionIcon
|
|
87
|
+
debugName={`${debugName} modal close button`}
|
|
88
|
+
icon={closeIconName as IconPlaceholder}
|
|
89
|
+
onPress={toggle}
|
|
90
|
+
styles={styles.closeButton}
|
|
91
|
+
/>
|
|
92
|
+
)}
|
|
93
|
+
</View>
|
|
73
94
|
|
|
74
|
-
{(
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
onPress={toggle}
|
|
79
|
-
styles={styles.closeButton}
|
|
80
|
-
/>
|
|
95
|
+
{TypeGuards.isString(description) ? (
|
|
96
|
+
<Text text={description} style={styles.description} />
|
|
97
|
+
) : (
|
|
98
|
+
description
|
|
81
99
|
)}
|
|
82
100
|
</View>
|
|
83
101
|
)}</>
|
|
@@ -103,7 +121,10 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
103
121
|
scrollProps = {},
|
|
104
122
|
closeOnHardwareBackPress = true,
|
|
105
123
|
...props
|
|
106
|
-
} =
|
|
124
|
+
} = {
|
|
125
|
+
...Modal.defaultProps,
|
|
126
|
+
...modalProps,
|
|
127
|
+
}
|
|
107
128
|
const variantStyles = useDefaultComponentStyle('u:Modal', {
|
|
108
129
|
variants: variants as any,
|
|
109
130
|
transform: StyleSheet.flatten,
|
|
@@ -120,17 +141,15 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
120
141
|
}
|
|
121
142
|
const buttonStyles = React.useMemo(() => getNestedStylesByKey('closeButton', variantStyles), [variantStyles])
|
|
122
143
|
|
|
123
|
-
const boxAnimationStates = useStaticAnimationStyles(variantStyles, ['box:hidden', 'box:visible'])
|
|
124
|
-
|
|
125
144
|
const boxAnimationStyles = useAnimatedVariantStyles({
|
|
126
|
-
updater: (states
|
|
127
|
-
'worklet'
|
|
128
|
-
return visible ? states['box:visible'] : states['box:hidden']
|
|
145
|
+
updater: (states) => {
|
|
146
|
+
'worklet'
|
|
147
|
+
return visible ? states['box:visible'] : states['box:hidden']
|
|
129
148
|
},
|
|
130
149
|
animatedProperties: ['box:hidden', 'box:visible'],
|
|
131
150
|
variantStyles,
|
|
132
|
-
transition:variantStyles['box:transition'],
|
|
133
|
-
dependencies: [visible]
|
|
151
|
+
transition: variantStyles['box:transition'],
|
|
152
|
+
dependencies: [visible],
|
|
134
153
|
})
|
|
135
154
|
|
|
136
155
|
const wrapperStyle = getStyles('wrapper')
|
|
@@ -145,7 +164,9 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
145
164
|
styles: {
|
|
146
165
|
wrapper: getStyles('header'),
|
|
147
166
|
title: getStyles('title'),
|
|
167
|
+
description: getStyles('description'),
|
|
148
168
|
closeButton: buttonStyles,
|
|
169
|
+
titleWrapper: getStyles('titleWrapper'),
|
|
149
170
|
},
|
|
150
171
|
}
|
|
151
172
|
const Header = renderHeader || DefaultHeader
|
|
@@ -189,7 +210,7 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
189
210
|
>
|
|
190
211
|
{dismissOnBackdrop &&
|
|
191
212
|
<Touchable
|
|
192
|
-
onPress={
|
|
213
|
+
onPress={closable && visible ? toggle : (() => {})}
|
|
193
214
|
debounce={400}
|
|
194
215
|
debugName={'Modal backdrop touchable'}
|
|
195
216
|
style={variantStyles.backdropTouchable}
|
|
@@ -197,10 +218,9 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
197
218
|
noFeedback
|
|
198
219
|
/>}
|
|
199
220
|
|
|
200
|
-
<
|
|
201
|
-
|
|
202
|
-
style={[getStyles('box'),boxAnimationStyles]}
|
|
203
|
-
// transition={{ ...variantStyles['box:transition'] }}
|
|
221
|
+
<View
|
|
222
|
+
animated
|
|
223
|
+
style={[getStyles('box'), boxAnimationStyles]}
|
|
204
224
|
|
|
205
225
|
{...props}
|
|
206
226
|
>
|
|
@@ -213,7 +233,7 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
213
233
|
{typeof footer === 'string' ? <Text text={footer} /> : footer}
|
|
214
234
|
</View>
|
|
215
235
|
)}
|
|
216
|
-
</
|
|
236
|
+
</View>
|
|
217
237
|
|
|
218
238
|
</ScrollComponent>
|
|
219
239
|
</View>
|
|
@@ -221,4 +241,8 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
221
241
|
)
|
|
222
242
|
}
|
|
223
243
|
|
|
244
|
+
Modal.defaultProps = {
|
|
245
|
+
closeIconName: 'close' as IconPlaceholder,
|
|
246
|
+
}
|
|
247
|
+
|
|
224
248
|
export default Modal
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
assignTextStyle,
|
|
3
2
|
createDefaultVariantFactory,
|
|
4
3
|
includePresets,
|
|
5
4
|
} from '@codeleap/common'
|
|
@@ -18,6 +17,8 @@ export type ModalParts =
|
|
|
18
17
|
| 'header'
|
|
19
18
|
| 'backdropTouchable'
|
|
20
19
|
| 'title'
|
|
20
|
+
| 'description'
|
|
21
|
+
| 'titleWrapper'
|
|
21
22
|
| `closeButton${Capitalize<ActionIconComposition>}`
|
|
22
23
|
|
|
23
24
|
export type ModalComposition =
|
|
@@ -28,116 +29,4 @@ export type ModalComposition =
|
|
|
28
29
|
|
|
29
30
|
const createModalStyle = createDefaultVariantFactory<ModalComposition>()
|
|
30
31
|
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
export const ModalStyles = {
|
|
34
|
-
...presets,
|
|
35
|
-
default: createModalStyle((theme) => {
|
|
36
|
-
return {
|
|
37
|
-
wrapper: {
|
|
38
|
-
...theme.presets.absolute,
|
|
39
|
-
// ...theme.presets.whole,
|
|
40
|
-
...theme.presets.fullHeight,
|
|
41
|
-
...theme.presets.fullWidth,
|
|
42
|
-
},
|
|
43
|
-
'box:transition': {
|
|
44
|
-
scale: {
|
|
45
|
-
duration: theme.values.transitions.modal.duration,
|
|
46
|
-
type: 'timing',
|
|
47
|
-
},
|
|
48
|
-
opacity: {
|
|
49
|
-
duration: theme.values.transitions.modal.duration,
|
|
50
|
-
type: 'timing',
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
'backdrop:transition': {
|
|
54
|
-
opacity: {
|
|
55
|
-
duration: theme.values.transitions.modal.duration,
|
|
56
|
-
type: 'timing',
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
backdrop: {
|
|
60
|
-
...theme.presets.absolute,
|
|
61
|
-
...theme.presets.whole,
|
|
62
|
-
|
|
63
|
-
backgroundColor: theme.colors.black,
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
backdropTouchable: {
|
|
67
|
-
// height: '100%',
|
|
68
|
-
...theme.presets.absolute,
|
|
69
|
-
...theme.presets.whole,
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
'backdrop:visible': {
|
|
73
|
-
opacity: 0.5,
|
|
74
|
-
},
|
|
75
|
-
'backdrop:hidden': {
|
|
76
|
-
opacity: 0,
|
|
77
|
-
},
|
|
78
|
-
innerWrapper: {
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
scroll: {
|
|
82
|
-
flex: 1,
|
|
83
|
-
// maxHeight: theme.values.height,
|
|
84
|
-
},
|
|
85
|
-
scrollContent: {
|
|
86
|
-
...theme.presets.alignCenter,
|
|
87
|
-
...theme.presets.justifyCenter,
|
|
88
|
-
flexGrow: 1,
|
|
89
|
-
...theme.presets.safeAreaTop(theme.values.innerSpacing.Y),
|
|
90
|
-
...theme.presets.safeAreaBottom(theme.values.innerSpacing.Y),
|
|
91
|
-
},
|
|
92
|
-
box: {
|
|
93
|
-
backgroundColor: theme.colors.background,
|
|
94
|
-
width: theme.values.width - theme.spacing.value(theme.values.innerSpacing.X * 2),
|
|
95
|
-
borderRadius: theme.borderRadius.modalOuter,
|
|
96
|
-
...theme.spacing.paddingHorizontal(theme.values.innerSpacing.X),
|
|
97
|
-
...theme.spacing.paddingVertical(theme.values.innerSpacing.Y),
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
'box:hidden': {
|
|
101
|
-
opacity: 0,
|
|
102
|
-
scale: 0.8,
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
'box:visible': {
|
|
106
|
-
opacity: 1,
|
|
107
|
-
scale: 1,
|
|
108
|
-
},
|
|
109
|
-
header: {
|
|
110
|
-
flexDirection: 'row',
|
|
111
|
-
...theme.presets.justifySpaceBetween,
|
|
112
|
-
...theme.presets.alignCenter,
|
|
113
|
-
...theme.presets.alignSelfStretch,
|
|
114
|
-
...theme.spacing.marginBottom(1),
|
|
115
|
-
},
|
|
116
|
-
closeButtonTouchableWrapper: {
|
|
117
|
-
alignSelf: 'center',
|
|
118
|
-
...theme.spacing.marginLeft('auto'),
|
|
119
|
-
},
|
|
120
|
-
closeButtonIcon: {
|
|
121
|
-
color: theme.colors.text,
|
|
122
|
-
},
|
|
123
|
-
title: {
|
|
124
|
-
...assignTextStyle('h3')(theme).text,
|
|
125
|
-
},
|
|
126
|
-
}
|
|
127
|
-
}),
|
|
128
|
-
popup: createModalStyle(() => ({})),
|
|
129
|
-
fullscreen: createModalStyle((theme) => ({
|
|
130
|
-
scrollContent: {
|
|
131
|
-
paddingTop: 0,
|
|
132
|
-
paddingBottom: 0,
|
|
133
|
-
},
|
|
134
|
-
box: {
|
|
135
|
-
width: '100%',
|
|
136
|
-
flexGrow: 1,
|
|
137
|
-
borderRadius: 0,
|
|
138
|
-
...theme.presets.center,
|
|
139
|
-
...theme.presets.safeAreaTop(theme.values.innerSpacing.Y),
|
|
140
|
-
...theme.presets.safeAreaBottom(theme.values.innerSpacing.Y),
|
|
141
|
-
},
|
|
142
|
-
})),
|
|
143
|
-
}
|
|
32
|
+
export const ModalPresets = includePresets((style) => createModalStyle(() => ({ body: style })))
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
useDefaultComponentStyle,
|
|
4
|
+
TypeGuards,
|
|
5
|
+
useState,
|
|
6
|
+
useRef,
|
|
7
|
+
useValidate,
|
|
8
|
+
IconPlaceholder,
|
|
9
|
+
} from '@codeleap/common'
|
|
10
|
+
import { forwardRef, useImperativeHandle } from 'react'
|
|
11
|
+
import { NumberIncrementPresets } from './styles'
|
|
12
|
+
import { InputBase, selectInputBaseProps } from '../InputBase'
|
|
13
|
+
import { Text } from '../Text'
|
|
14
|
+
import { MaskedTextInput } from '../../modules/textInputMask'
|
|
15
|
+
import { TextInput as NativeTextInput, TextInputProps as NativeTextInputProps, NativeSyntheticEvent, TextInputFocusEventData } from 'react-native'
|
|
16
|
+
import { Touchable } from '../Touchable'
|
|
17
|
+
import { useActionValidate } from './utils'
|
|
18
|
+
import { NumberIncrementProps } from './types'
|
|
19
|
+
|
|
20
|
+
export * from './styles'
|
|
21
|
+
export * from './types'
|
|
22
|
+
|
|
23
|
+
const MAX_VALID_DIGITS = 1000000000000000 // maximum number of digits that the input supports to perform operations
|
|
24
|
+
|
|
25
|
+
const defaultParseValue = (_value: string) => {
|
|
26
|
+
const value = _value?.length > 0 ? _value : '0'
|
|
27
|
+
|
|
28
|
+
const parsedValue = value?.replace(/[^\d.]/g, '')
|
|
29
|
+
|
|
30
|
+
return parseFloat(parsedValue)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const defaultProps: Partial<NumberIncrementProps> = {
|
|
34
|
+
max: MAX_VALID_DIGITS,
|
|
35
|
+
min: 0,
|
|
36
|
+
step: 1,
|
|
37
|
+
editable: true,
|
|
38
|
+
separator: null,
|
|
39
|
+
formatter: null,
|
|
40
|
+
parseValue: defaultParseValue,
|
|
41
|
+
delimiter: null,
|
|
42
|
+
mask: null,
|
|
43
|
+
masking: null,
|
|
44
|
+
timeoutActionFocus: 300,
|
|
45
|
+
actionPressAutoFocus: true,
|
|
46
|
+
actionDebounce: null,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const NumberIncrement = forwardRef<NativeTextInput, NumberIncrementProps>((props, inputRef) => {
|
|
50
|
+
const {
|
|
51
|
+
inputBaseProps,
|
|
52
|
+
others,
|
|
53
|
+
} = selectInputBaseProps({
|
|
54
|
+
...NumberIncrement.defaultProps,
|
|
55
|
+
...props,
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const {
|
|
59
|
+
variants = [],
|
|
60
|
+
style = {},
|
|
61
|
+
styles = {},
|
|
62
|
+
value,
|
|
63
|
+
disabled,
|
|
64
|
+
onChangeText,
|
|
65
|
+
onChangeMask,
|
|
66
|
+
max,
|
|
67
|
+
min,
|
|
68
|
+
step,
|
|
69
|
+
editable,
|
|
70
|
+
validate,
|
|
71
|
+
onPress,
|
|
72
|
+
_error,
|
|
73
|
+
masking,
|
|
74
|
+
separator,
|
|
75
|
+
prefix,
|
|
76
|
+
suffix,
|
|
77
|
+
delimiter,
|
|
78
|
+
formatter,
|
|
79
|
+
actionPressAutoFocus,
|
|
80
|
+
parseValue,
|
|
81
|
+
timeoutActionFocus,
|
|
82
|
+
mask,
|
|
83
|
+
actionDebounce,
|
|
84
|
+
...textInputProps
|
|
85
|
+
} = others
|
|
86
|
+
|
|
87
|
+
const [isFocused, setIsFocused] = useState(false)
|
|
88
|
+
|
|
89
|
+
const innerInputRef = useRef<NativeTextInput>(null)
|
|
90
|
+
|
|
91
|
+
const actionValidation = useActionValidate(validate)
|
|
92
|
+
const validation = useValidate(value, validate)
|
|
93
|
+
|
|
94
|
+
const hasError = !validation.isValid || _error || !actionValidation?.isValid
|
|
95
|
+
const errorMessage = validation.message || _error || actionValidation?.message
|
|
96
|
+
|
|
97
|
+
const isFormatted = TypeGuards.isFunction(formatter)
|
|
98
|
+
|
|
99
|
+
const hasMaskProps = [masking, prefix, suffix, delimiter, separator, mask].some(v => !!v)
|
|
100
|
+
|
|
101
|
+
const isMasked = hasMaskProps && !isFormatted
|
|
102
|
+
|
|
103
|
+
const InputElement = isMasked ? MaskedTextInput : NativeTextInput
|
|
104
|
+
|
|
105
|
+
// @ts-expect-error - React's ref type system is weird
|
|
106
|
+
useImperativeHandle(inputRef, () => {
|
|
107
|
+
return {
|
|
108
|
+
...innerInputRef.current,
|
|
109
|
+
focus: () => {
|
|
110
|
+
innerInputRef.current?.focus?.()
|
|
111
|
+
},
|
|
112
|
+
isTextInput: true,
|
|
113
|
+
}
|
|
114
|
+
}, [!!innerInputRef?.current?.focus])
|
|
115
|
+
|
|
116
|
+
const incrementDisabled = React.useMemo(() => {
|
|
117
|
+
if (TypeGuards.isNumber(max) && (Number(value) >= max)) {
|
|
118
|
+
return true
|
|
119
|
+
}
|
|
120
|
+
return false
|
|
121
|
+
}, [value])
|
|
122
|
+
|
|
123
|
+
const decrementDisabled = React.useMemo(() => {
|
|
124
|
+
if (TypeGuards.isNumber(min) && (Number(value) <= min)) {
|
|
125
|
+
return true
|
|
126
|
+
}
|
|
127
|
+
return false
|
|
128
|
+
}, [value])
|
|
129
|
+
|
|
130
|
+
const variantStyles = useDefaultComponentStyle<'u:NumberIncrement', typeof NumberIncrementPresets>(
|
|
131
|
+
'u:NumberIncrement',
|
|
132
|
+
{
|
|
133
|
+
variants,
|
|
134
|
+
styles,
|
|
135
|
+
rootElement: 'wrapper',
|
|
136
|
+
},
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
const inputTextStyle = React.useMemo(() => ([
|
|
140
|
+
variantStyles.input,
|
|
141
|
+
isFocused && variantStyles['input:focus'],
|
|
142
|
+
hasError && variantStyles['input:error'],
|
|
143
|
+
disabled && variantStyles['input:disabled'],
|
|
144
|
+
]), [disabled, isFocused, hasError])
|
|
145
|
+
|
|
146
|
+
const placeholderTextColor = [
|
|
147
|
+
[disabled, variantStyles['placeholder:disabled']],
|
|
148
|
+
[hasError, variantStyles['placeholder:error']],
|
|
149
|
+
[isFocused, variantStyles['placeholder:focus']],
|
|
150
|
+
[true, variantStyles.placeholder],
|
|
151
|
+
].find(([x]) => x)?.[1]?.color
|
|
152
|
+
|
|
153
|
+
const selectionColor = [
|
|
154
|
+
[disabled, variantStyles['selection:disabled']],
|
|
155
|
+
[!validation.isValid, variantStyles['selection:error']],
|
|
156
|
+
[isFocused, variantStyles['selection:focus']],
|
|
157
|
+
[true, variantStyles.selection],
|
|
158
|
+
].find(([x]) => x)?.[1]?.color
|
|
159
|
+
|
|
160
|
+
const onChange = (newValue: number) => {
|
|
161
|
+
actionValidation.onAction(newValue)
|
|
162
|
+
// @ts-ignore
|
|
163
|
+
if (onChangeText) onChangeText?.(newValue)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const actionTimeoutRef = useRef(null)
|
|
167
|
+
|
|
168
|
+
const clearActionTimeoutRef = React.useCallback(() => {
|
|
169
|
+
if (actionTimeoutRef.current !== null) {
|
|
170
|
+
clearTimeout(actionTimeoutRef.current)
|
|
171
|
+
actionTimeoutRef.current = null
|
|
172
|
+
}
|
|
173
|
+
}, [actionTimeoutRef.current])
|
|
174
|
+
|
|
175
|
+
const handleChange = React.useCallback((action: 'increment' | 'decrement') => {
|
|
176
|
+
if (actionPressAutoFocus) setIsFocused(true)
|
|
177
|
+
clearActionTimeoutRef()
|
|
178
|
+
|
|
179
|
+
if (action === 'increment' && !incrementDisabled) {
|
|
180
|
+
const newValue = Number(value) + step
|
|
181
|
+
onChange(newValue)
|
|
182
|
+
} else if (action === 'decrement' && !decrementDisabled) {
|
|
183
|
+
const newValue = Number(value) - step
|
|
184
|
+
onChange(newValue)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (actionPressAutoFocus) {
|
|
188
|
+
actionTimeoutRef.current = setTimeout(() => {
|
|
189
|
+
setIsFocused(false)
|
|
190
|
+
}, timeoutActionFocus)
|
|
191
|
+
}
|
|
192
|
+
}, [value])
|
|
193
|
+
|
|
194
|
+
const handleBlur = React.useCallback((e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
195
|
+
if (TypeGuards.isNumber(max) && (value >= max)) {
|
|
196
|
+
onChange(max)
|
|
197
|
+
} else if (TypeGuards.isNumber(min) && (value <= min) || !value || String(value)?.length <= 0) {
|
|
198
|
+
onChange(min)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
validation?.onInputBlurred()
|
|
202
|
+
setIsFocused(false)
|
|
203
|
+
props?.onBlur?.(e)
|
|
204
|
+
}, [validation?.onInputBlurred, props?.onBlur, value])
|
|
205
|
+
|
|
206
|
+
const handleFocus = React.useCallback((e?: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
207
|
+
validation?.onInputFocused()
|
|
208
|
+
clearActionTimeoutRef()
|
|
209
|
+
if (editable) setIsFocused(true)
|
|
210
|
+
if (e) props?.onFocus?.(e)
|
|
211
|
+
}, [validation?.onInputFocused, props?.onFocus])
|
|
212
|
+
|
|
213
|
+
const handleChangeInput: NativeTextInputProps['onChangeText'] = (text) => {
|
|
214
|
+
const value = parseValue(text)
|
|
215
|
+
|
|
216
|
+
if (value >= MAX_VALID_DIGITS) {
|
|
217
|
+
onChange(MAX_VALID_DIGITS)
|
|
218
|
+
return MAX_VALID_DIGITS
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
onChange(value)
|
|
222
|
+
return value
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const handleMaskChange = (masked: string, unmasked: any) => {
|
|
226
|
+
handleChangeInput?.(masked)
|
|
227
|
+
if (onChangeMask) onChangeMask(masked, unmasked)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const maskingExtraProps = isMasked ? {
|
|
231
|
+
type: TypeGuards.isNil(mask) ? 'money' : 'custom',
|
|
232
|
+
onChangeText: handleMaskChange,
|
|
233
|
+
...masking,
|
|
234
|
+
options: {
|
|
235
|
+
unit: prefix,
|
|
236
|
+
separator: separator ?? '.',
|
|
237
|
+
suffixUnit: suffix,
|
|
238
|
+
delimiter: delimiter ?? ',',
|
|
239
|
+
mask: mask,
|
|
240
|
+
...masking?.options,
|
|
241
|
+
},
|
|
242
|
+
ref: null,
|
|
243
|
+
refInput: (inputRef) => {
|
|
244
|
+
if (!!inputRef) {
|
|
245
|
+
innerInputRef.current = inputRef
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
} : {}
|
|
249
|
+
|
|
250
|
+
const onPressInnerWrapper = () => {
|
|
251
|
+
handleFocus()
|
|
252
|
+
if (editable) innerInputRef.current?.focus?.()
|
|
253
|
+
if (onPress) onPress?.()
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<InputBase
|
|
258
|
+
{...inputBaseProps}
|
|
259
|
+
error={hasError ? errorMessage : null}
|
|
260
|
+
styles={{
|
|
261
|
+
...variantStyles,
|
|
262
|
+
innerWrapper: [
|
|
263
|
+
variantStyles.innerWrapper,
|
|
264
|
+
],
|
|
265
|
+
}}
|
|
266
|
+
rightIcon={{
|
|
267
|
+
name: 'plus' as IconPlaceholder,
|
|
268
|
+
disabled: disabled || incrementDisabled || !editable,
|
|
269
|
+
onPress: () => handleChange('increment'),
|
|
270
|
+
debounce: actionDebounce,
|
|
271
|
+
...inputBaseProps.rightIcon,
|
|
272
|
+
}}
|
|
273
|
+
leftIcon={{
|
|
274
|
+
name: 'minus' as IconPlaceholder,
|
|
275
|
+
disabled: disabled || decrementDisabled || !editable,
|
|
276
|
+
onPress: () => handleChange('decrement'),
|
|
277
|
+
debounce: actionDebounce,
|
|
278
|
+
...inputBaseProps.leftIcon,
|
|
279
|
+
}}
|
|
280
|
+
style={style}
|
|
281
|
+
disabled={disabled}
|
|
282
|
+
focused={isFocused}
|
|
283
|
+
innerWrapper={Touchable}
|
|
284
|
+
innerWrapperProps={{
|
|
285
|
+
...(inputBaseProps.innerWrapperProps || {}),
|
|
286
|
+
rippleDisabled: true,
|
|
287
|
+
onPress: onPressInnerWrapper,
|
|
288
|
+
}}
|
|
289
|
+
>
|
|
290
|
+
{editable && !disabled ? (
|
|
291
|
+
<InputElement
|
|
292
|
+
keyboardType='numeric'
|
|
293
|
+
textAlign='center'
|
|
294
|
+
textAlignVertical='center'
|
|
295
|
+
allowFontScaling={false}
|
|
296
|
+
editable={!disabled}
|
|
297
|
+
placeholderTextColor={placeholderTextColor}
|
|
298
|
+
value={isFormatted ? formatter(value) : String(value)}
|
|
299
|
+
selectionColor={selectionColor}
|
|
300
|
+
onChangeText={handleChangeInput}
|
|
301
|
+
{...textInputProps}
|
|
302
|
+
onBlur={handleBlur}
|
|
303
|
+
onFocus={handleFocus}
|
|
304
|
+
style={inputTextStyle}
|
|
305
|
+
ref={innerInputRef}
|
|
306
|
+
{...maskingExtraProps}
|
|
307
|
+
/>
|
|
308
|
+
) : (
|
|
309
|
+
<Text
|
|
310
|
+
text={isFormatted ? formatter(value) : String(value)}
|
|
311
|
+
style={inputTextStyle}
|
|
312
|
+
/>
|
|
313
|
+
)}
|
|
314
|
+
</InputBase>
|
|
315
|
+
)
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
NumberIncrement.defaultProps = defaultProps
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
|
|
2
|
+
import { InputBaseParts, InputBaseStates } from '../InputBase'
|
|
3
|
+
|
|
4
|
+
export type NumberIncrementParts = InputBaseParts | 'input' | 'placeholder' | 'selection'
|
|
5
|
+
|
|
6
|
+
export type NumberIncrementStates = InputBaseStates
|
|
7
|
+
|
|
8
|
+
export type NumberIncrementComposition =
|
|
9
|
+
| NumberIncrementParts
|
|
10
|
+
| `${NumberIncrementParts}:${NumberIncrementStates}`
|
|
11
|
+
|
|
12
|
+
const createNumberIncrementStyle = createDefaultVariantFactory<NumberIncrementComposition>()
|
|
13
|
+
|
|
14
|
+
export const NumberIncrementPresets = includePresets((styles) => createNumberIncrementStyle(() => ({ wrapper: styles })))
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ComponentVariants,
|
|
3
|
+
yup,
|
|
4
|
+
StylesOf,
|
|
5
|
+
PropsOf,
|
|
6
|
+
FormTypes,
|
|
7
|
+
} from '@codeleap/common'
|
|
8
|
+
import { NumberIncrementPresets, NumberIncrementComposition } from './styles'
|
|
9
|
+
import { TextInputMaskProps } from '../../modules/textInputMask'
|
|
10
|
+
import { TextInputProps as NativeTextInputProps } from 'react-native'
|
|
11
|
+
import { View } from '../View'
|
|
12
|
+
import { Touchable } from '../Touchable'
|
|
13
|
+
import { InputBaseProps } from '../InputBase'
|
|
14
|
+
|
|
15
|
+
type Masking = FormTypes.TextField['masking']
|
|
16
|
+
type MaskOptions = Masking['options']
|
|
17
|
+
|
|
18
|
+
export type NumberIncrementProps =
|
|
19
|
+
Omit<InputBaseProps, 'styles' | 'variants'> &
|
|
20
|
+
NativeTextInputProps & {
|
|
21
|
+
variants?: ComponentVariants<typeof NumberIncrementPresets>['variants']
|
|
22
|
+
styles?: StylesOf<NumberIncrementComposition>
|
|
23
|
+
value: number
|
|
24
|
+
validate?: FormTypes.ValidatorWithoutForm<string> | yup.SchemaOf<string>
|
|
25
|
+
style?: PropsOf<typeof View>['style']
|
|
26
|
+
max?: number
|
|
27
|
+
min?: number
|
|
28
|
+
step?: number
|
|
29
|
+
editable?: boolean
|
|
30
|
+
_error?: string
|
|
31
|
+
placeholder?: string
|
|
32
|
+
onChangeMask?: TextInputMaskProps['onChangeText']
|
|
33
|
+
masking?: Exclude<Masking, 'mask' | 'format'>
|
|
34
|
+
prefix?: MaskOptions['unit']
|
|
35
|
+
suffix?: MaskOptions['suffixUnit']
|
|
36
|
+
separator?: MaskOptions['separator']
|
|
37
|
+
delimiter?: MaskOptions['delimiter']
|
|
38
|
+
mask?: MaskOptions['mask']
|
|
39
|
+
formatter?: (value: string | number) => string
|
|
40
|
+
parseValue?: (value: string) => number
|
|
41
|
+
timeoutActionFocus?: number
|
|
42
|
+
actionPressAutoFocus?: boolean
|
|
43
|
+
actionDebounce?: number | null
|
|
44
|
+
} & Pick<PropsOf<typeof Touchable>, 'onPress'>
|