@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
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ComponentVariants,
|
|
3
|
+
FormTypes,
|
|
4
|
+
IconPlaceholder,
|
|
5
|
+
PropsOf,
|
|
6
|
+
} from '@codeleap/common'
|
|
7
|
+
import { AutocompletePresets } from '.'
|
|
8
|
+
import { StylesOf } from '../../types/utility'
|
|
9
|
+
import { GetKeyboardAwarePropsOptions } from '../../utils'
|
|
10
|
+
import { Icon } from '../Icon'
|
|
11
|
+
import { FlatListProps } from '../List'
|
|
12
|
+
import { Text } from '../Text'
|
|
13
|
+
import { SearchInputProps, TextInputProps } from '../TextInput'
|
|
14
|
+
import { Touchable } from '../Touchable'
|
|
15
|
+
import { AutocompleteComposition } from './styles'
|
|
16
|
+
|
|
17
|
+
export type AutocompleteRenderFNProps<T> = {
|
|
18
|
+
styles: StylesOf<AutocompleteComposition>
|
|
19
|
+
onPress: () => void
|
|
20
|
+
isSelected?: boolean
|
|
21
|
+
item: FormTypes.Options<T>[number]
|
|
22
|
+
touchableProps?: Partial<PropsOf<typeof Touchable>>
|
|
23
|
+
textProps?: Partial<PropsOf<typeof Text>>
|
|
24
|
+
iconProps?: Partial<PropsOf<typeof Icon>>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type AutocompleteRenderFN<T> = (props: AutocompleteRenderFNProps<T>) => JSX.Element
|
|
28
|
+
|
|
29
|
+
export type AutocompleteValue<T, Multi extends boolean = false> = Multi extends true ? T[] : T
|
|
30
|
+
|
|
31
|
+
export type ValueBoundAutocompleteProps<T, Multi extends boolean = false> = {
|
|
32
|
+
options?: FormTypes.Options<T>
|
|
33
|
+
defaultOptions?: FormTypes.Options<T>
|
|
34
|
+
loadOptions?: (search: string) => Promise<FormTypes.Options<T>>
|
|
35
|
+
value: AutocompleteValue<T, Multi>
|
|
36
|
+
renderItem?: AutocompleteRenderFN<AutocompleteValue<T, Multi>>
|
|
37
|
+
onValueChange: (value: AutocompleteValue<T, Multi>) => void
|
|
38
|
+
filterItems?: (search: string, items: FormTypes.Options<T>) => FormTypes.Options<T>
|
|
39
|
+
onLoadOptionsError?: (error: any) => void
|
|
40
|
+
multiple?: Multi
|
|
41
|
+
getLabel?: (forOption: Multi extends true ? FormTypes.Options<T> : FormTypes.Options<T>[number]) => FormTypes.Label
|
|
42
|
+
onItemPressed?: (item: FormTypes.Options<T>[number]) => any
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type ReplaceAutocompleteProps<Props, T, Multi extends boolean = false> = Omit<
|
|
46
|
+
Props,
|
|
47
|
+
keyof ValueBoundAutocompleteProps<T, Multi>
|
|
48
|
+
> & ValueBoundAutocompleteProps<T, Multi>
|
|
49
|
+
|
|
50
|
+
export type AutocompleteProps<T = any, Multi extends boolean = false> = {
|
|
51
|
+
placeholder?: string
|
|
52
|
+
label?: FormTypes.Label
|
|
53
|
+
styles?: StylesOf<AutocompleteComposition>
|
|
54
|
+
style?: TextInputProps['style']
|
|
55
|
+
closeOnSelect?: boolean
|
|
56
|
+
listProps?: Partial<FlatListProps>
|
|
57
|
+
keyboardAware?: GetKeyboardAwarePropsOptions
|
|
58
|
+
multiple?: Multi
|
|
59
|
+
itemProps?: Partial<
|
|
60
|
+
Pick<AutocompleteRenderFNProps<any>, 'iconProps'|'textProps'|'touchableProps'
|
|
61
|
+
>>
|
|
62
|
+
searchable?: boolean
|
|
63
|
+
limit?: number
|
|
64
|
+
selectedIcon?: IconPlaceholder
|
|
65
|
+
loadOptionsOnMount?: boolean
|
|
66
|
+
loadOptionsOnOpen?: boolean
|
|
67
|
+
selectable?: boolean
|
|
68
|
+
searchInputProps?: Partial<SearchInputProps>
|
|
69
|
+
debugName: string
|
|
70
|
+
searchComponent?: React.ComponentType<SearchInputProps>
|
|
71
|
+
}
|
|
72
|
+
& Omit<FlatListProps<T>, 'renderItem'|'styles'|'style'>
|
|
73
|
+
& ComponentVariants<typeof AutocompletePresets>
|
|
74
|
+
& ValueBoundAutocompleteProps<T, Multi>
|
|
75
|
+
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ComponentVariants,
|
|
3
|
+
IconPlaceholder,
|
|
4
|
+
TypeGuards,
|
|
5
|
+
matchInitialToColor,
|
|
6
|
+
useDefaultComponentStyle,
|
|
7
|
+
useMemo,
|
|
8
|
+
getNestedStylesByKey,
|
|
9
|
+
} from '@codeleap/common'
|
|
10
|
+
import React from 'react'
|
|
11
|
+
import { StyleSheet } from 'react-native'
|
|
12
|
+
import { StylesOf } from '../../types'
|
|
13
|
+
import { AvatarComposition, AvatarPresets } from './styles'
|
|
14
|
+
import { Image, ImageProps } from '../Image'
|
|
15
|
+
import { Touchable } from '../Touchable'
|
|
16
|
+
import { Text } from '../Text'
|
|
17
|
+
import { View, ViewProps } from '../View'
|
|
18
|
+
import { Icon } from '../Icon'
|
|
19
|
+
import { Badge, BadgeComponentProps } from '../Badge'
|
|
20
|
+
|
|
21
|
+
export type AvatarProps = ComponentVariants<typeof AvatarPresets> & {
|
|
22
|
+
styles?: StylesOf<AvatarComposition>
|
|
23
|
+
image?: ImageProps['source']
|
|
24
|
+
name?: string | string[]
|
|
25
|
+
debugName: string
|
|
26
|
+
firstNameOnly?: boolean
|
|
27
|
+
text?: string
|
|
28
|
+
description?: string
|
|
29
|
+
icon?: IconPlaceholder
|
|
30
|
+
badgeIcon?: IconPlaceholder
|
|
31
|
+
style?: ViewProps['style']
|
|
32
|
+
onPress?: () => void
|
|
33
|
+
noFeedback?: boolean
|
|
34
|
+
} & BadgeComponentProps
|
|
35
|
+
|
|
36
|
+
export const Avatar: React.FC<AvatarProps> = (props) => {
|
|
37
|
+
const {
|
|
38
|
+
debugName,
|
|
39
|
+
name = '',
|
|
40
|
+
firstNameOnly = true,
|
|
41
|
+
image,
|
|
42
|
+
variants = [],
|
|
43
|
+
styles,
|
|
44
|
+
style,
|
|
45
|
+
icon,
|
|
46
|
+
badgeIcon,
|
|
47
|
+
text,
|
|
48
|
+
description,
|
|
49
|
+
onPress,
|
|
50
|
+
noFeedback,
|
|
51
|
+
badge = false,
|
|
52
|
+
badgeProps = {},
|
|
53
|
+
...viewProps
|
|
54
|
+
} = props
|
|
55
|
+
|
|
56
|
+
const variantStyles = useDefaultComponentStyle('u:Avatar', {
|
|
57
|
+
variants,
|
|
58
|
+
styles,
|
|
59
|
+
transform: StyleSheet.flatten,
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const hasImage = !!image
|
|
63
|
+
|
|
64
|
+
const { initials, randomColor } = useMemo(() => {
|
|
65
|
+
const [first = '', last = ''] = TypeGuards.isString(name)
|
|
66
|
+
? name.split(' ')
|
|
67
|
+
: name
|
|
68
|
+
const initials = [first[0]]
|
|
69
|
+
if (!firstNameOnly) {
|
|
70
|
+
initials.push(last[0])
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
initials: initials.join(' '),
|
|
74
|
+
randomColor: matchInitialToColor(first[0]),
|
|
75
|
+
}
|
|
76
|
+
}, [name, firstNameOnly])
|
|
77
|
+
|
|
78
|
+
const renderContent = () => {
|
|
79
|
+
if (hasImage) return <Image source={image} style={variantStyles.image} />
|
|
80
|
+
if (icon) return <Icon name={icon} style={variantStyles.icon} />
|
|
81
|
+
return <Text text={text || initials} style={variantStyles.initials} />
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const hasBackgroundColor = !!variantStyles?.touchable?.backgroundColor
|
|
85
|
+
|
|
86
|
+
const badgeStyles = getNestedStylesByKey('badge', variantStyles)
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<View style={[variantStyles.wrapper, style]} {...viewProps}>
|
|
90
|
+
<Touchable
|
|
91
|
+
debugName={'Avatar ' + debugName}
|
|
92
|
+
onPress={() => onPress?.()}
|
|
93
|
+
style={[
|
|
94
|
+
variantStyles.touchable,
|
|
95
|
+
!hasBackgroundColor && {
|
|
96
|
+
backgroundColor: randomColor,
|
|
97
|
+
},
|
|
98
|
+
]}
|
|
99
|
+
noFeedback={noFeedback || !onPress}
|
|
100
|
+
>
|
|
101
|
+
{renderContent()}
|
|
102
|
+
|
|
103
|
+
{!!description && (
|
|
104
|
+
<View style={variantStyles.descriptionOverlay}>
|
|
105
|
+
<Text text={description} style={variantStyles.description} />
|
|
106
|
+
</View>
|
|
107
|
+
)}
|
|
108
|
+
|
|
109
|
+
<Badge badge={badge} style={badgeStyles} {...badgeProps} />
|
|
110
|
+
</Touchable>
|
|
111
|
+
|
|
112
|
+
{badgeIcon && (
|
|
113
|
+
<Touchable
|
|
114
|
+
debugName={`${debugName} badge`}
|
|
115
|
+
style={variantStyles.badgeIconWrapper}
|
|
116
|
+
onPress={() => onPress?.()}
|
|
117
|
+
noFeedback
|
|
118
|
+
>
|
|
119
|
+
<Icon name={badgeIcon} style={variantStyles.badgeIcon} />
|
|
120
|
+
</Touchable>
|
|
121
|
+
)}
|
|
122
|
+
</View>
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export * from './styles'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
|
|
2
|
+
import { BadgeComposition } from '../Badge'
|
|
3
|
+
|
|
4
|
+
export type AvatarParts =
|
|
5
|
+
| 'wrapper'
|
|
6
|
+
| 'touchable'
|
|
7
|
+
| 'initials'
|
|
8
|
+
| 'image'
|
|
9
|
+
| 'icon'
|
|
10
|
+
| 'iconWrapper'
|
|
11
|
+
| 'description'
|
|
12
|
+
| 'descriptionOverlay'
|
|
13
|
+
| 'badgeIconWrapper'
|
|
14
|
+
| 'badgeIcon'
|
|
15
|
+
| `badge${Capitalize<BadgeComposition>}`
|
|
16
|
+
|
|
17
|
+
export type AvatarComposition = AvatarParts
|
|
18
|
+
|
|
19
|
+
const createAvatarStyle = createDefaultVariantFactory<AvatarComposition>()
|
|
20
|
+
|
|
21
|
+
export const AvatarPresets = includePresets((styles) => createAvatarStyle(() => ({ wrapper: styles })),
|
|
22
|
+
)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ComponentVariants,
|
|
3
|
+
useDefaultComponentStyle,
|
|
4
|
+
useNestedStylesByKey,
|
|
5
|
+
} from '@codeleap/common'
|
|
6
|
+
import React from 'react'
|
|
7
|
+
import { StyleSheet } from 'react-native'
|
|
8
|
+
import { StylesOf } from '../../types'
|
|
9
|
+
import { AvatarGroupComposition, AvatarGroupPresets } from './styles'
|
|
10
|
+
import { View, ViewProps } from '../View'
|
|
11
|
+
import { Avatar, AvatarProps } from '../Avatar'
|
|
12
|
+
|
|
13
|
+
export type AvatarGroupProps = ComponentVariants<typeof AvatarGroupPresets> & {
|
|
14
|
+
styles?: StylesOf<AvatarGroupComposition>
|
|
15
|
+
style?: ViewProps['style']
|
|
16
|
+
avatars: AvatarProps[]
|
|
17
|
+
displacement?: number
|
|
18
|
+
avatarVariants?: AvatarProps['variants']
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const defaultProps:Partial<AvatarGroupProps> = {
|
|
22
|
+
displacement: 20.5,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
export const AvatarGroup: React.FC<AvatarGroupProps> = (props) => {
|
|
28
|
+
const {
|
|
29
|
+
variants = [],
|
|
30
|
+
avatars = [],
|
|
31
|
+
avatarVariants,
|
|
32
|
+
styles,
|
|
33
|
+
style,
|
|
34
|
+
displacement,
|
|
35
|
+
...viewProps
|
|
36
|
+
} = {
|
|
37
|
+
...defaultProps,
|
|
38
|
+
...props
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const variantStyles = useDefaultComponentStyle('u:AvatarGroup', {
|
|
42
|
+
variants,
|
|
43
|
+
styles,
|
|
44
|
+
transform: StyleSheet.flatten,
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const avatarStyles = useNestedStylesByKey('avatar', variantStyles)
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<View
|
|
51
|
+
style={[variantStyles.wrapper, style]}
|
|
52
|
+
variants={['row']}
|
|
53
|
+
{...viewProps}
|
|
54
|
+
>
|
|
55
|
+
{avatars.map((avatar, index) => (
|
|
56
|
+
<Avatar
|
|
57
|
+
firstNameOnly
|
|
58
|
+
key={avatar.debugName || index}
|
|
59
|
+
{...avatar}
|
|
60
|
+
variants={avatar.variants || avatarVariants}
|
|
61
|
+
style={getAvatarStyle(index,displacement)}
|
|
62
|
+
styles={avatarStyles}
|
|
63
|
+
/>
|
|
64
|
+
))}
|
|
65
|
+
</View>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
AvatarGroup.defaultProps = defaultProps
|
|
70
|
+
|
|
71
|
+
const getAvatarStyle = (index: number,displacementPixels: number) => {
|
|
72
|
+
const displacement = index * 20.5
|
|
73
|
+
return { right: `${displacement}%` }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export * from './styles'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
|
|
2
|
+
import { AvatarComposition } from '../components'
|
|
3
|
+
|
|
4
|
+
export type AvatarGroupParts = 'wrapper'
|
|
5
|
+
|
|
6
|
+
export type AvatarGroupComposition = AvatarGroupParts | `avatar${Capitalize<AvatarComposition>}`
|
|
7
|
+
|
|
8
|
+
const createAvatarStyle = createDefaultVariantFactory<AvatarGroupComposition>()
|
|
9
|
+
|
|
10
|
+
export const AvatarGroupPresets = includePresets((styles) => createAvatarStyle(() => ({ wrapper: styles })),
|
|
11
|
+
)
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { ComponentVariants, onUpdate, PropsOf, useDefaultComponentStyle } from '@codeleap/common'
|
|
3
|
-
import { useDynamicAnimation } from 'moti'
|
|
4
3
|
import { Touchable } from '../Touchable'
|
|
5
4
|
import { View } from '../View'
|
|
6
5
|
|
|
7
6
|
import { StylesOf } from '../../types/utility'
|
|
8
7
|
import { StyleSheet } from 'react-native'
|
|
9
|
-
import {
|
|
10
|
-
import { BackdropComposition,
|
|
8
|
+
import { useAnimatedVariantStyles } from '../../utils'
|
|
9
|
+
import { BackdropComposition, BackdropPresets } from './styles'
|
|
11
10
|
|
|
12
11
|
export * from './styles'
|
|
13
12
|
export type BackdropProps = React.PropsWithChildren<
|
|
@@ -15,31 +14,33 @@ export type BackdropProps = React.PropsWithChildren<
|
|
|
15
14
|
PropsOf<typeof Touchable> & {
|
|
16
15
|
visible: boolean
|
|
17
16
|
wrapperProps?: PropsOf<typeof View>
|
|
18
|
-
variants?: ComponentVariants<typeof
|
|
17
|
+
variants?: ComponentVariants<typeof BackdropPresets>['variants']
|
|
19
18
|
styles?: StylesOf<BackdropComposition>
|
|
20
19
|
}>
|
|
21
20
|
|
|
22
21
|
export const Backdrop = (backdropProps:BackdropProps) => {
|
|
23
22
|
const { variants = [], styles = {}, visible, children, wrapperProps = {}, ...props } = backdropProps
|
|
24
23
|
|
|
25
|
-
const variantStyles = useDefaultComponentStyle<'u:Backdrop', typeof
|
|
24
|
+
const variantStyles = useDefaultComponentStyle<'u:Backdrop', typeof BackdropPresets>('u:Backdrop', {
|
|
26
25
|
variants,
|
|
27
26
|
rootElement: 'wrapper',
|
|
28
27
|
styles,
|
|
29
28
|
transform: StyleSheet.flatten,
|
|
30
29
|
})
|
|
31
30
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
const animation = useAnimatedVariantStyles({
|
|
32
|
+
variantStyles,
|
|
33
|
+
animatedProperties: ['wrapper:hidden', 'wrapper:visible'],
|
|
34
|
+
updater: (s) => {
|
|
35
|
+
'worklet'
|
|
36
|
+
return visible ? s['wrapper:visible'] : s['wrapper:hidden']
|
|
37
|
+
},
|
|
38
|
+
dependencies: [visible],
|
|
39
|
+
transition: variantStyles.transition,
|
|
36
40
|
})
|
|
37
41
|
|
|
38
|
-
onUpdate(() => {
|
|
39
|
-
animation.animateTo(visible ? animationStates['wrapper:visible'] : animationStates['wrapper:hidden'])
|
|
40
|
-
}, [visible, animationStates])
|
|
41
42
|
|
|
42
|
-
return <View pointerEvents={visible ? 'auto' : 'none' } animated style={variantStyles.wrapper
|
|
43
|
+
return <View pointerEvents={visible ? 'auto' : 'none' } animated style={[variantStyles.wrapper, animation]} {...wrapperProps}>
|
|
43
44
|
{
|
|
44
45
|
!!props?.onPress ?
|
|
45
46
|
<Touchable style={variantStyles.touchable} {...props} noFeedback android_ripple={null}/>
|
|
@@ -4,30 +4,9 @@ export type BackdropComposition =
|
|
|
4
4
|
'wrapper'|
|
|
5
5
|
'touchable' |
|
|
6
6
|
'wrapper:visible' |
|
|
7
|
-
'wrapper:hidden'
|
|
7
|
+
'wrapper:hidden' |
|
|
8
|
+
'transition'
|
|
8
9
|
|
|
9
10
|
const createBackdropVariant = createDefaultVariantFactory<BackdropComposition>()
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
export const BackdropStyles = {
|
|
14
|
-
...presets,
|
|
15
|
-
default: createBackdropVariant((theme) => ({
|
|
16
|
-
wrapper: {
|
|
17
|
-
backgroundColor: theme.colors.black,
|
|
18
|
-
...theme.presets.whole,
|
|
19
|
-
...theme.presets.absolute,
|
|
20
|
-
},
|
|
21
|
-
'wrapper:visible': {
|
|
22
|
-
opacity: 0.5,
|
|
23
|
-
},
|
|
24
|
-
'wrapper:hidden': {
|
|
25
|
-
|
|
26
|
-
opacity: 0,
|
|
27
|
-
},
|
|
28
|
-
touchable: {
|
|
29
|
-
...theme.presets.whole,
|
|
30
|
-
...theme.presets.absolute,
|
|
31
|
-
},
|
|
32
|
-
})),
|
|
33
|
-
}
|
|
12
|
+
export const BackdropPresets = includePresets((style) => createBackdropVariant(() => ({ wrapper: style })))
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { ComponentVariants, PropsOf, StylesOf, TypeGuards, useDefaultComponentStyle } from '@codeleap/common'
|
|
3
|
+
import { Text } from '../Text'
|
|
4
|
+
import { View, ViewProps } from '../View'
|
|
5
|
+
import { BadgeComposition, BadgePresets } from './styles'
|
|
6
|
+
import { StyleSheet } from 'react-native'
|
|
7
|
+
|
|
8
|
+
export * from './styles'
|
|
9
|
+
|
|
10
|
+
export type BadgeProps = ComponentVariants<typeof BadgePresets>
|
|
11
|
+
& ViewProps
|
|
12
|
+
& {
|
|
13
|
+
styles?: StylesOf<BadgeComposition>
|
|
14
|
+
maxCount?: number
|
|
15
|
+
minCount?: number
|
|
16
|
+
debugName?: string
|
|
17
|
+
innerWrapperProps?: Partial<PropsOf<typeof View>>
|
|
18
|
+
textProps?: Partial<PropsOf<typeof Text>>
|
|
19
|
+
getBadgeContent?: (props: BadgeContent) => string
|
|
20
|
+
renderBadgeContent?: (props: BadgeContent & { content: string }) => JSX.Element
|
|
21
|
+
disabled?: boolean
|
|
22
|
+
badge?: number | boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type BadgeContent = BadgeProps & { count: number }
|
|
26
|
+
|
|
27
|
+
export type BadgeComponentProps = {
|
|
28
|
+
badge?: BadgeProps['badge']
|
|
29
|
+
badgeProps?: Partial<BadgeProps>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const defaultGetBadgeContent = ({ count, maxCount }: BadgeContent) => {
|
|
33
|
+
if (Number(count) > maxCount) {
|
|
34
|
+
return `${maxCount}+`
|
|
35
|
+
} else {
|
|
36
|
+
return String(count)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const defaultProps: Partial<BadgeProps> = {
|
|
41
|
+
maxCount: 9,
|
|
42
|
+
minCount: 1,
|
|
43
|
+
getBadgeContent: defaultGetBadgeContent,
|
|
44
|
+
renderBadgeContent: null,
|
|
45
|
+
disabled: false,
|
|
46
|
+
badge: true,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const Badge = (props: BadgeProps) => {
|
|
50
|
+
const allProps = {
|
|
51
|
+
...Badge.defaultProps,
|
|
52
|
+
...props,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const {
|
|
56
|
+
debugName,
|
|
57
|
+
innerWrapperProps = {},
|
|
58
|
+
textProps = {},
|
|
59
|
+
maxCount,
|
|
60
|
+
minCount,
|
|
61
|
+
getBadgeContent,
|
|
62
|
+
renderBadgeContent,
|
|
63
|
+
styles = {},
|
|
64
|
+
variants,
|
|
65
|
+
disabled,
|
|
66
|
+
style = {},
|
|
67
|
+
badge,
|
|
68
|
+
...rest
|
|
69
|
+
} = allProps
|
|
70
|
+
|
|
71
|
+
const visible = (TypeGuards.isBoolean(badge) && badge === true) || TypeGuards.isNumber(badge)
|
|
72
|
+
|
|
73
|
+
if (!visible) return null
|
|
74
|
+
|
|
75
|
+
const variantStyles = useDefaultComponentStyle<'u:Badge', typeof BadgePresets>('u:Badge', {
|
|
76
|
+
variants,
|
|
77
|
+
styles,
|
|
78
|
+
rootElement: 'wrapper',
|
|
79
|
+
transform: StyleSheet.flatten,
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
const wrapperStyles: ViewProps['style'] = [
|
|
83
|
+
variantStyles?.wrapper,
|
|
84
|
+
(disabled && variantStyles?.['wrapper:disabled']),
|
|
85
|
+
style,
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
const innerWrapperStyles: ViewProps['style'] = [
|
|
89
|
+
variantStyles?.innerWrapper,
|
|
90
|
+
(disabled && variantStyles?.['innerWrapper:disabled']),
|
|
91
|
+
innerWrapperProps?.style,
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
const countStyles = [
|
|
95
|
+
variantStyles?.count,
|
|
96
|
+
(disabled && variantStyles?.['count:disabled']),
|
|
97
|
+
textProps?.style,
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
const count = TypeGuards.isNumber(badge) ? badge : null
|
|
101
|
+
|
|
102
|
+
const content = getBadgeContent({ ...props, maxCount, minCount, count })
|
|
103
|
+
|
|
104
|
+
const showContent = TypeGuards.isNumber(count) && count >= minCount
|
|
105
|
+
|
|
106
|
+
let BadgeContent = renderBadgeContent
|
|
107
|
+
|
|
108
|
+
if (TypeGuards.isNil(renderBadgeContent)) {
|
|
109
|
+
BadgeContent = () => <Text text={content} {...textProps} style={countStyles} />
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<View
|
|
114
|
+
{...rest}
|
|
115
|
+
style={wrapperStyles}
|
|
116
|
+
>
|
|
117
|
+
<View {...innerWrapperProps} style={innerWrapperStyles}>
|
|
118
|
+
{showContent
|
|
119
|
+
? <BadgeContent
|
|
120
|
+
{...props}
|
|
121
|
+
maxCount={maxCount}
|
|
122
|
+
minCount={minCount}
|
|
123
|
+
count={count}
|
|
124
|
+
getBadgeContent={getBadgeContent}
|
|
125
|
+
content={content}
|
|
126
|
+
/>
|
|
127
|
+
: null
|
|
128
|
+
}
|
|
129
|
+
</View>
|
|
130
|
+
</View>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
Badge.defaultProps = defaultProps
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
|
|
2
|
+
|
|
3
|
+
type BadgeParts = 'wrapper' | 'innerWrapper' | 'count'
|
|
4
|
+
|
|
5
|
+
type BadgeStates = 'disabled'
|
|
6
|
+
|
|
7
|
+
export type BadgeComposition =
|
|
8
|
+
`${BadgeParts}:${BadgeStates}`
|
|
9
|
+
| BadgeParts
|
|
10
|
+
|
|
11
|
+
const createBadgeStyle =
|
|
12
|
+
createDefaultVariantFactory<BadgeComposition>()
|
|
13
|
+
|
|
14
|
+
export const BadgePresets = includePresets((styles) => createBadgeStyle(() => ({ wrapper: styles })))
|