@codeleap/mobile 2.3.7 → 2.3.10
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/CodeLeap-Mobile-Packages.code-workspace +7 -7
- package/dist/components/ActionIcon/index.d.ts +13 -13
- package/dist/components/ActionIcon/index.js +54 -54
- package/dist/components/ActionIcon/styles.d.ts +65 -65
- package/dist/components/ActionIcon/styles.js +60 -60
- package/dist/components/ActivityIndicator/index.d.ts +15 -15
- package/dist/components/ActivityIndicator/index.js +58 -58
- package/dist/components/ActivityIndicator/styles.d.ts +59 -59
- package/dist/components/ActivityIndicator/styles.js +51 -51
- package/dist/components/Animated.d.ts +124 -124
- package/dist/components/Animated.js +58 -58
- package/dist/components/AutoComplete/index.d.ts +33 -33
- package/dist/components/AutoComplete/index.js +128 -128
- package/dist/components/AutoComplete/styles.d.ts +57 -57
- package/dist/components/AutoComplete/styles.js +24 -24
- package/dist/components/Backdrop/index.d.ts +14 -14
- package/dist/components/Backdrop/index.js +62 -62
- package/dist/components/Backdrop/styles.d.ts +53 -53
- package/dist/components/Backdrop/styles.js +27 -27
- package/dist/components/Button/index.d.ts +246 -246
- package/dist/components/Button/index.js +118 -118
- package/dist/components/Button/styles.d.ts +65 -65
- package/dist/components/Button/styles.js +60 -60
- package/dist/components/Calendar/index.d.ts +15 -15
- package/dist/components/Calendar/index.js +79 -79
- package/dist/components/Calendar/style.d.ts +4 -4
- package/dist/components/Calendar/style.js +35 -35
- package/dist/components/Calendar/types.d.ts +95 -95
- package/dist/components/Calendar/types.js +2 -2
- package/dist/components/Checkbox/index.d.ts +15 -15
- package/dist/components/Checkbox/index.js +84 -84
- package/dist/components/Checkbox/styles.d.ts +56 -56
- package/dist/components/Checkbox/styles.js +52 -52
- package/dist/components/ContentView/index.d.ts +12 -12
- package/dist/components/ContentView/index.js +65 -65
- package/dist/components/ContentView/styles.d.ts +53 -53
- package/dist/components/ContentView/styles.js +25 -25
- package/dist/components/Drawer/index.d.ts +7 -7
- package/dist/components/Drawer/index.js +69 -69
- package/dist/components/Drawer/styles.d.ts +56 -56
- package/dist/components/Drawer/styles.js +38 -38
- package/dist/components/EmptyPlaceholder/index.d.ts +22 -22
- package/dist/components/EmptyPlaceholder/index.js +77 -77
- package/dist/components/EmptyPlaceholder/styles.d.ts +55 -55
- package/dist/components/EmptyPlaceholder/styles.js +31 -31
- package/dist/components/FileInput/index.d.ts +24 -24
- package/dist/components/FileInput/index.js +182 -182
- package/dist/components/FileInput/styles.d.ts +53 -53
- package/dist/components/FileInput/styles.js +18 -18
- package/dist/components/Grid/index.d.ts +32 -32
- package/dist/components/Grid/index.js +83 -83
- package/dist/components/Grid/styles.d.ts +5 -5
- package/dist/components/Grid/styles.js +18 -18
- package/dist/components/Icon/index.d.ts +14 -14
- package/dist/components/Icon/index.js +78 -78
- package/dist/components/Icon/styles.d.ts +61 -61
- package/dist/components/Icon/styles.js +48 -48
- package/dist/components/Image/index.d.ts +20 -20
- package/dist/components/Image/index.js +90 -90
- package/dist/components/Image/styles.d.ts +54 -54
- package/dist/components/Image/styles.js +24 -24
- package/dist/components/ImageView/Spotlight.d.ts +25 -25
- package/dist/components/ImageView/Spotlight.js +153 -153
- package/dist/components/ImageView/component.d.ts +5 -5
- package/dist/components/ImageView/component.js +53 -53
- package/dist/components/ImageView/index.d.ts +2 -2
- package/dist/components/ImageView/index.js +18 -18
- package/dist/components/InputLabel/index.d.ts +12 -12
- package/dist/components/InputLabel/index.js +61 -61
- package/dist/components/InputLabel/styles.d.ts +4 -4
- package/dist/components/InputLabel/styles.js +25 -25
- package/dist/components/List/PaginationIndicator.d.ts +67 -67
- package/dist/components/List/PaginationIndicator.js +50 -50
- package/dist/components/List/index.d.ts +31 -31
- package/dist/components/List/index.js +80 -80
- package/dist/components/List/styles.d.ts +5 -5
- package/dist/components/List/styles.js +26 -26
- package/dist/components/Modal/index.d.ts +41 -41
- package/dist/components/Modal/index.js +143 -143
- package/dist/components/Modal/styles.d.ts +58 -58
- package/dist/components/Modal/styles.js +74 -74
- package/dist/components/MultiSelect/index.d.ts +6 -6
- package/dist/components/MultiSelect/index.js +117 -117
- package/dist/components/MultiSelect/styles.d.ts +58 -58
- package/dist/components/MultiSelect/styles.js +21 -21
- package/dist/components/MultiSelect/types.d.ts +35 -35
- package/dist/components/MultiSelect/types.js +2 -2
- package/dist/components/Navigation/Navigation.d.ts +3 -3
- package/dist/components/Navigation/Navigation.js +83 -83
- package/dist/components/Navigation/constants.d.ts +5 -5
- package/dist/components/Navigation/constants.js +10 -10
- package/dist/components/Navigation/index.d.ts +3 -3
- package/dist/components/Navigation/index.js +19 -19
- package/dist/components/Navigation/types.d.ts +26 -26
- package/dist/components/Navigation/types.js +7 -7
- package/dist/components/Navigation/utils.d.ts +3 -3
- package/dist/components/Navigation/utils.js +68 -68
- package/dist/components/Pager/index.d.ts +26 -26
- package/dist/components/Pager/index.js +87 -87
- package/dist/components/Pager/styles.d.ts +87 -87
- package/dist/components/Pager/styles.js +71 -71
- package/dist/components/RadioInput/index.d.ts +27 -27
- package/dist/components/RadioInput/index.js +75 -75
- package/dist/components/RadioInput/styles.d.ts +58 -58
- package/dist/components/RadioInput/styles.js +49 -49
- package/dist/components/Scroll/index.d.ts +20 -20
- package/dist/components/Scroll/index.js +100 -100
- package/dist/components/Scroll/styles.d.ts +4 -4
- package/dist/components/Scroll/styles.js +26 -26
- package/dist/components/Sections/index.d.ts +11 -11
- package/dist/components/Sections/index.js +79 -79
- package/dist/components/SegmentedControl/index.d.ts +52 -52
- package/dist/components/SegmentedControl/index.js +132 -132
- package/dist/components/SegmentedControl/styles.d.ts +60 -60
- package/dist/components/SegmentedControl/styles.js +42 -42
- package/dist/components/Select/index.d.ts +13 -13
- package/dist/components/Select/index.js +130 -130
- package/dist/components/Select/styles.d.ts +59 -59
- package/dist/components/Select/styles.js +31 -31
- package/dist/components/Select/types.d.ts +36 -36
- package/dist/components/Select/types.js +2 -2
- package/dist/components/Slider/Mark.d.ts +3 -3
- package/dist/components/Slider/Mark.js +31 -31
- package/dist/components/Slider/Thumb.d.ts +7 -7
- package/dist/components/Slider/Thumb.js +29 -29
- package/dist/components/Slider/index.d.ts +4 -4
- package/dist/components/Slider/index.js +102 -102
- package/dist/components/Slider/styles.d.ts +54 -54
- package/dist/components/Slider/styles.js +60 -60
- package/dist/components/Slider/types.d.ts +26 -26
- package/dist/components/Slider/types.js +2 -2
- package/dist/components/Switch/index.d.ts +14 -14
- package/dist/components/Switch/index.js +84 -84
- package/dist/components/Switch/styles.d.ts +55 -55
- package/dist/components/Switch/styles.js +33 -33
- package/dist/components/Text/index.d.ts +23 -23
- package/dist/components/Text/index.js +124 -124
- package/dist/components/Text/styles.d.ts +70 -70
- package/dist/components/Text/styles.js +30 -30
- package/dist/components/TextInput/index.d.ts +181 -181
- package/dist/components/TextInput/index.js +213 -213
- package/dist/components/TextInput/styles.d.ts +63 -63
- package/dist/components/TextInput/styles.js +64 -64
- package/dist/components/Touchable/index.d.ts +21 -21
- package/dist/components/Touchable/index.js +157 -157
- package/dist/components/Touchable/styles.d.ts +58 -58
- package/dist/components/Touchable/styles.js +23 -23
- package/dist/components/View/index.d.ts +132 -132
- package/dist/components/View/index.js +101 -101
- package/dist/components/View/styles.d.ts +54 -54
- package/dist/components/View/styles.js +28 -28
- package/dist/components/components.d.ts +38 -38
- package/dist/components/components.js +67 -67
- package/dist/components/defaultStyles.d.ts +1369 -1369
- package/dist/components/defaultStyles.js +64 -64
- package/dist/components/legacy/Modal/index.d.ts +28 -28
- package/dist/components/legacy/Modal/index.js +113 -113
- package/dist/components/legacy/Modal/styles.d.ts +64 -64
- package/dist/components/legacy/Modal/styles.js +59 -59
- package/dist/components/legacy/Pager/index.d.ts +20 -20
- package/dist/components/legacy/Pager/index.js +167 -167
- package/dist/components/legacy/Pager/styles.d.ts +54 -54
- package/dist/components/legacy/Pager/styles.js +43 -43
- package/dist/components/legacy/index.d.ts +2 -2
- package/dist/components/legacy/index.js +18 -18
- package/dist/index.d.ts +7 -7
- package/dist/index.js +42 -42
- package/dist/modules/documentPicker.d.ts +3 -3
- package/dist/modules/documentPicker.js +11 -11
- package/dist/modules/fastImage.d.ts +1 -1
- package/dist/modules/fastImage.js +9 -9
- package/dist/modules/reactNavigation.d.ts +5 -5
- package/dist/modules/reactNavigation.js +25 -25
- package/dist/modules/textInputMask.d.ts +10 -10
- package/dist/modules/textInputMask.js +22 -22
- package/dist/modules/types/fileTypes.d.ts +138 -138
- package/dist/modules/types/fileTypes.js +2 -2
- package/dist/modules/types/textInputMask.d.ts +7 -7
- package/dist/modules/types/textInputMask.js +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +17 -17
- package/dist/types/utility.d.ts +8 -8
- package/dist/types/utility.js +2 -2
- package/dist/utils/KeyboardAware/context.d.ts +13 -13
- package/dist/utils/KeyboardAware/context.js +67 -67
- package/dist/utils/KeyboardAware/index.d.ts +8 -8
- package/dist/utils/KeyboardAware/index.js +32 -32
- package/dist/utils/KeyboardAware/keyboardHooks.d.ts +26 -26
- package/dist/utils/KeyboardAware/keyboardHooks.js +89 -89
- package/dist/utils/KeyboardAware/lib/KeyboardAwareFlatList.d.ts +3 -3
- package/dist/utils/KeyboardAware/lib/KeyboardAwareFlatList.js +8 -8
- package/dist/utils/KeyboardAware/lib/KeyboardAwareHOC.d.ts +67 -67
- package/dist/utils/KeyboardAware/lib/KeyboardAwareHOC.js +450 -450
- package/dist/utils/KeyboardAware/lib/KeyboardAwareInterface.d.ts +7 -7
- package/dist/utils/KeyboardAware/lib/KeyboardAwareInterface.js +3 -3
- package/dist/utils/KeyboardAware/lib/KeyboardAwareScrollView.d.ts +3 -3
- package/dist/utils/KeyboardAware/lib/KeyboardAwareScrollView.js +9 -9
- package/dist/utils/KeyboardAware/lib/KeyboardAwareSectionList.d.ts +3 -3
- package/dist/utils/KeyboardAware/lib/KeyboardAwareSectionList.js +9 -9
- package/dist/utils/KeyboardAware/types.d.ts +1 -1
- package/dist/utils/KeyboardAware/types.js +6 -6
- package/dist/utils/ModalManager/components.d.ts +20 -20
- package/dist/utils/ModalManager/components.js +117 -117
- package/dist/utils/ModalManager/context.d.ts +48 -48
- package/dist/utils/ModalManager/context.js +204 -204
- package/dist/utils/ModalManager/index.d.ts +11 -11
- package/dist/utils/ModalManager/index.js +12 -12
- package/dist/utils/OSAlert.d.ts +32 -32
- package/dist/utils/OSAlert.js +142 -142
- package/dist/utils/PermissionManager/context.d.ts +52 -52
- package/dist/utils/PermissionManager/context.js +315 -315
- package/dist/utils/PermissionManager/index.d.ts +4 -4
- package/dist/utils/PermissionManager/index.js +8 -8
- package/dist/utils/PermissionManager/types.d.ts +13 -13
- package/dist/utils/PermissionManager/types.js +2 -2
- package/dist/utils/hooks.d.ts +40 -40
- package/dist/utils/hooks.js +130 -130
- package/dist/utils/index.d.ts +10 -10
- package/dist/utils/index.js +39 -39
- package/dist/utils/input.d.ts +35 -35
- package/dist/utils/input.js +48 -48
- package/dist/utils/misc.d.ts +6 -6
- package/dist/utils/misc.js +86 -86
- package/dist/utils/notifications.d.ts +34 -34
- package/dist/utils/notifications.js +267 -267
- package/dist/utils/theme.d.ts +42 -42
- package/dist/utils/theme.js +52 -52
- package/package.json +54 -54
- package/src/components/ActionIcon/index.tsx +32 -0
- package/src/components/ActionIcon/styles.ts +97 -0
- package/src/components/ActivityIndicator/index.tsx +50 -0
- package/src/components/ActivityIndicator/styles.ts +68 -0
- package/src/components/Animated.tsx +34 -0
- package/src/components/AutoComplete/index.tsx +163 -0
- package/src/components/AutoComplete/styles.ts +44 -0
- package/src/components/Backdrop/index.tsx +48 -0
- package/src/components/Backdrop/styles.ts +33 -0
- package/src/components/Button/index.tsx +155 -0
- package/src/components/Button/styles.ts +129 -0
- package/src/components/Calendar/index.tsx +65 -0
- package/src/components/Calendar/style.ts +35 -0
- package/src/components/Calendar/types.ts +102 -0
- package/src/components/Checkbox/index.tsx +91 -0
- package/src/components/Checkbox/styles.ts +81 -0
- package/src/components/ContentView/index.tsx +63 -0
- package/src/components/ContentView/styles.ts +24 -0
- package/src/components/Drawer/index.tsx +33 -0
- package/src/components/Drawer/styles.ts +43 -0
- package/src/components/EmptyPlaceholder/index.tsx +88 -0
- package/src/components/EmptyPlaceholder/styles.ts +58 -0
- package/src/components/FileInput/index.tsx +181 -0
- package/src/components/FileInput/styles.ts +15 -0
- package/src/components/Grid/index.tsx +117 -0
- package/src/components/Grid/styles.ts +11 -0
- package/src/components/Icon/index.tsx +69 -0
- package/src/components/Icon/styles.ts +57 -0
- package/src/components/Image/index.tsx +91 -0
- package/src/components/Image/styles.ts +20 -0
- package/src/components/ImageView/Spotlight.tsx +157 -0
- package/src/components/ImageView/component.tsx +38 -0
- package/src/components/ImageView/index.ts +2 -0
- package/src/components/InputLabel/index.tsx +38 -0
- package/src/components/InputLabel/styles.ts +19 -0
- package/src/components/List/PaginationIndicator.tsx +71 -0
- package/src/components/List/index.tsx +114 -0
- package/src/components/List/styles.ts +19 -0
- package/src/components/Modal/index.tsx +218 -0
- package/src/components/Modal/styles.ts +153 -0
- package/src/components/MultiSelect/index.tsx +138 -0
- package/src/components/MultiSelect/styles.ts +18 -0
- package/src/components/MultiSelect/types.ts +42 -0
- package/src/components/Navigation/Navigation.tsx +54 -0
- package/src/components/Navigation/constants.ts +8 -0
- package/src/components/Navigation/index.tsx +3 -0
- package/src/components/Navigation/types.ts +35 -0
- package/src/components/Navigation/utils.tsx +57 -0
- package/src/components/Pager/index.tsx +121 -0
- package/src/components/Pager/styles.ts +81 -0
- package/src/components/RadioInput/index.tsx +106 -0
- package/src/components/RadioInput/styles.ts +67 -0
- package/src/components/Scroll/index.tsx +124 -0
- package/src/components/Scroll/styles.ts +18 -0
- package/src/components/Sections/index.tsx +91 -0
- package/src/components/SegmentedControl/index.tsx +204 -0
- package/src/components/SegmentedControl/styles.ts +89 -0
- package/src/components/Select/index.tsx +167 -0
- package/src/components/Select/styles.ts +62 -0
- package/src/components/Select/types.ts +43 -0
- package/src/components/Slider/Mark.tsx +46 -0
- package/src/components/Slider/Thumb.tsx +29 -0
- package/src/components/Slider/index.tsx +130 -0
- package/src/components/Slider/styles.ts +76 -0
- package/src/components/Slider/types.ts +30 -0
- package/src/components/Switch/index.tsx +91 -0
- package/src/components/Switch/styles.ts +38 -0
- package/src/components/Text/index.tsx +124 -0
- package/src/components/Text/styles.ts +50 -0
- package/src/components/TextInput/index.tsx +319 -0
- package/src/components/TextInput/styles.ts +127 -0
- package/src/components/Touchable/index.tsx +174 -0
- package/src/components/Touchable/styles.ts +28 -0
- package/src/components/View/index.tsx +103 -0
- package/src/components/View/styles.ts +24 -0
- package/src/components/components.ts +42 -0
- package/src/components/defaultStyles.ts +62 -0
- package/src/components/legacy/Modal/index.tsx +163 -0
- package/src/components/legacy/Modal/styles.ts +125 -0
- package/src/components/legacy/Pager/index.tsx +242 -0
- package/src/components/legacy/Pager/styles.ts +51 -0
- package/src/components/legacy/index.ts +2 -0
- package/src/index.ts +7 -7
- package/src/modules/documentPicker.ts +7 -0
- package/src/modules/fastImage.ts +2 -0
- package/src/modules/imageCropPicker.d.ts +497 -0
- package/src/modules/index.d.ts +682 -0
- package/src/modules/reactNavigation.ts +15 -0
- package/src/modules/textInputMask.ts +11 -0
- package/src/modules/types/documentPicker.d.ts +215 -0
- package/src/modules/types/fileTypes.ts +138 -0
- package/src/modules/types/textInputMask.ts +9 -0
- package/src/types/index.ts +1 -0
- package/src/types/utility.ts +9 -0
- package/src/utils/KeyboardAware/context.tsx +75 -0
- package/src/utils/KeyboardAware/index.ts +17 -0
- package/src/utils/KeyboardAware/keyboardHooks.ts +124 -0
- package/src/utils/KeyboardAware/lib/KeyboardAwareFlatList.ts +4 -0
- package/src/utils/KeyboardAware/lib/KeyboardAwareHOC.tsx +618 -0
- package/src/utils/KeyboardAware/lib/KeyboardAwareInterface.ts +13 -0
- package/src/utils/KeyboardAware/lib/KeyboardAwareScrollView.ts +6 -0
- package/src/utils/KeyboardAware/lib/KeyboardAwareSectionList.ts +6 -0
- package/src/utils/KeyboardAware/types.ts +159 -0
- package/src/utils/ModalManager/components.tsx +112 -0
- package/src/utils/ModalManager/context.tsx +260 -0
- package/src/utils/ModalManager/index.ts +16 -0
- package/src/utils/OSAlert.ts +180 -0
- package/src/utils/PermissionManager/context.tsx +302 -0
- package/src/utils/PermissionManager/index.ts +20 -0
- package/src/utils/PermissionManager/types.ts +24 -0
- package/src/utils/hooks.ts +163 -0
- package/src/utils/index.ts +11 -0
- package/src/utils/input.ts +51 -0
- package/src/utils/misc.ts +83 -0
- package/src/utils/notifications.ts +206 -0
- package/src/utils/theme.ts +58 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { assignTextStyle, createDefaultVariantFactory } from '@codeleap/common'
|
|
2
|
+
import { SelectComposition, SelectStyles } from '../Select'
|
|
3
|
+
import { TextInputComposition } from '../TextInput'
|
|
4
|
+
|
|
5
|
+
export type AutoCompleteComposition = SelectComposition | `searchInput${Capitalize<TextInputComposition>}` | 'titleWrapper'
|
|
6
|
+
|
|
7
|
+
const createAutoCompleteStyle = createDefaultVariantFactory<AutoCompleteComposition>()
|
|
8
|
+
|
|
9
|
+
export const AutoCompleteStyles = {
|
|
10
|
+
...SelectStyles,
|
|
11
|
+
default: createAutoCompleteStyle((theme) => {
|
|
12
|
+
const defaultStyle = SelectStyles.default(theme)
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
...defaultStyle,
|
|
16
|
+
header: {
|
|
17
|
+
...theme.spacing.paddingHorizontal(2),
|
|
18
|
+
...theme.spacing.paddingTop(1),
|
|
19
|
+
...theme.presets.column,
|
|
20
|
+
...theme.presets.alignStart,
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
searchInputWrapper: {
|
|
24
|
+
...theme.presets.fullWidth,
|
|
25
|
+
...theme.spacing.marginTop(2),
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
titleWrapper: {
|
|
29
|
+
...theme.presets.row,
|
|
30
|
+
...theme.presets.alignCenter,
|
|
31
|
+
...theme.presets.fullWidth,
|
|
32
|
+
...theme.presets.justifyCenter,
|
|
33
|
+
},
|
|
34
|
+
title: {
|
|
35
|
+
...theme.presets.textCenter,
|
|
36
|
+
flex: 1,
|
|
37
|
+
},
|
|
38
|
+
closeButtonWrapper: {
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
right: 0,
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
}),
|
|
44
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { ComponentVariants, onUpdate, PropsOf, useDefaultComponentStyle } from '@codeleap/common'
|
|
3
|
+
import { useDynamicAnimation } from 'moti'
|
|
4
|
+
import { Touchable } from '../Touchable'
|
|
5
|
+
import { View } from '../View'
|
|
6
|
+
|
|
7
|
+
import { StylesOf } from '../../types/utility'
|
|
8
|
+
import { StyleSheet } from 'react-native'
|
|
9
|
+
import { useStaticAnimationStyles } from '../../utils'
|
|
10
|
+
import { BackdropComposition, BackdropStyles } from './styles'
|
|
11
|
+
|
|
12
|
+
export * from './styles'
|
|
13
|
+
export type BackdropProps = PropsOf<typeof Touchable> & {
|
|
14
|
+
visible: boolean
|
|
15
|
+
wrapperProps?: PropsOf<typeof View>
|
|
16
|
+
variants?: ComponentVariants<typeof BackdropStyles>['variants']
|
|
17
|
+
styles?: StylesOf<BackdropComposition>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const Backdrop = (backdropProps:BackdropProps) => {
|
|
21
|
+
const { variants = [], styles = {}, visible, children, wrapperProps = {}, ...props } = backdropProps
|
|
22
|
+
|
|
23
|
+
const variantStyles = useDefaultComponentStyle<'u:Backdrop', typeof BackdropStyles>('u:Backdrop', {
|
|
24
|
+
variants,
|
|
25
|
+
rootElement: 'wrapper',
|
|
26
|
+
styles,
|
|
27
|
+
transform: StyleSheet.flatten,
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const animationStates = useStaticAnimationStyles(variantStyles, ['wrapper:hidden', 'wrapper:visible'])
|
|
31
|
+
|
|
32
|
+
const animation = useDynamicAnimation(() => {
|
|
33
|
+
return visible ? animationStates['wrapper:visible'] : animationStates['wrapper:hidden']
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
onUpdate(() => {
|
|
37
|
+
animation.animateTo(visible ? animationStates['wrapper:visible'] : animationStates['wrapper:hidden'])
|
|
38
|
+
}, [visible, animationStates])
|
|
39
|
+
|
|
40
|
+
return <View pointerEvents={visible ? 'auto' : 'none' } animated style={variantStyles.wrapper} state={animation} {...wrapperProps}>
|
|
41
|
+
{
|
|
42
|
+
props?.onPress ?
|
|
43
|
+
<Touchable style={variantStyles.touchable} {...props} noFeedback android_ripple={null}/>
|
|
44
|
+
: null
|
|
45
|
+
}
|
|
46
|
+
{children}
|
|
47
|
+
</View>
|
|
48
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
|
|
2
|
+
|
|
3
|
+
export type BackdropComposition =
|
|
4
|
+
'wrapper'|
|
|
5
|
+
'touchable' |
|
|
6
|
+
'wrapper:visible' |
|
|
7
|
+
'wrapper:hidden'
|
|
8
|
+
|
|
9
|
+
const createBackdropVariant = createDefaultVariantFactory<BackdropComposition>()
|
|
10
|
+
|
|
11
|
+
const presets = includePresets((style) => createBackdropVariant(() => ({ wrapper: style })))
|
|
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
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
useDefaultComponentStyle,
|
|
4
|
+
ComponentVariants,
|
|
5
|
+
|
|
6
|
+
IconPlaceholder,
|
|
7
|
+
GetRefType,
|
|
8
|
+
SmartOmit,
|
|
9
|
+
TypeGuards,
|
|
10
|
+
deepMerge,
|
|
11
|
+
PropsOf,
|
|
12
|
+
} from '@codeleap/common'
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
ButtonStyles,
|
|
16
|
+
ButtonComposition,
|
|
17
|
+
ButtonParts,
|
|
18
|
+
} from './styles'
|
|
19
|
+
import { forwardRef } from 'react'
|
|
20
|
+
import { StylesOf } from '../../types/utility'
|
|
21
|
+
import { Text } from '../Text'
|
|
22
|
+
import { Touchable, TouchableProps } from '../Touchable'
|
|
23
|
+
import { Icon } from '../Icon'
|
|
24
|
+
import { View, ViewProps } from '../View'
|
|
25
|
+
import { ActivityIndicator } from '../ActivityIndicator'
|
|
26
|
+
import { StyleSheet } from 'react-native'
|
|
27
|
+
export * from './styles'
|
|
28
|
+
|
|
29
|
+
type ChildProps = {
|
|
30
|
+
styles: StylesOf<ButtonParts>
|
|
31
|
+
props: Omit<ButtonProps, 'children'>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type BadgeProps = Partial<ViewProps> & {
|
|
35
|
+
text?: string
|
|
36
|
+
children?: React.ReactElement | ((props: Partial<SmartOmit<BadgeProps, 'children'>>) => React.ReactElement)
|
|
37
|
+
styles?: StylesOf<'text'|'wrapper'>
|
|
38
|
+
position?: [number, number]
|
|
39
|
+
textProps?: Partial<PropsOf<typeof Text>>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type ButtonProps = Omit<TouchableProps, 'variants'> &
|
|
43
|
+
ComponentVariants<typeof ButtonStyles> & {
|
|
44
|
+
text?: string
|
|
45
|
+
rightIcon?: IconPlaceholder
|
|
46
|
+
icon?: IconPlaceholder
|
|
47
|
+
styles?: StylesOf<ButtonComposition>
|
|
48
|
+
loading?: boolean
|
|
49
|
+
debounce?: number
|
|
50
|
+
debugName: string
|
|
51
|
+
badge?: React.ReactElement | BadgeProps
|
|
52
|
+
children?: React.ReactNode | ((props: ChildProps) => React.ReactNode)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const Badge = forwardRef<GetRefType<ViewProps['ref']>, BadgeProps>((props, ref) => {
|
|
56
|
+
const {
|
|
57
|
+
children = null,
|
|
58
|
+
styles,
|
|
59
|
+
text,
|
|
60
|
+
textProps = {},
|
|
61
|
+
...viewProps
|
|
62
|
+
} = props
|
|
63
|
+
|
|
64
|
+
return <View style={[styles.wrapper]} {...viewProps} ref={ref}>
|
|
65
|
+
{text && <Text text={text} style={styles.text} {...textProps}/>}
|
|
66
|
+
{(TypeGuards.isFunction(children) ? children({ ...viewProps, styles, text }) : children)}
|
|
67
|
+
</View>
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
export const Button = forwardRef<GetRefType<TouchableProps['ref']>, ButtonProps>((buttonProps, ref) => {
|
|
71
|
+
const {
|
|
72
|
+
variants = [],
|
|
73
|
+
children,
|
|
74
|
+
icon,
|
|
75
|
+
text,
|
|
76
|
+
loading,
|
|
77
|
+
styles = {},
|
|
78
|
+
onPress,
|
|
79
|
+
disabled,
|
|
80
|
+
badge = null,
|
|
81
|
+
rightIcon,
|
|
82
|
+
style,
|
|
83
|
+
...props
|
|
84
|
+
} = buttonProps
|
|
85
|
+
|
|
86
|
+
const variantStyles = useDefaultComponentStyle('u:Button', {
|
|
87
|
+
variants,
|
|
88
|
+
transform: StyleSheet.flatten,
|
|
89
|
+
styles,
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
function getStyles(key: ButtonParts) {
|
|
93
|
+
return [
|
|
94
|
+
variantStyles[key],
|
|
95
|
+
key === 'wrapper' && style,
|
|
96
|
+
disabled && variantStyles[key + ':disabled'],
|
|
97
|
+
styles[key],
|
|
98
|
+
disabled && styles[key + ':disabled'],
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const iconStyle = getStyles('icon')
|
|
103
|
+
|
|
104
|
+
const leftIconStyle = StyleSheet.flatten([iconStyle, getStyles('leftIcon')])
|
|
105
|
+
const rightIconStyle = StyleSheet.flatten([iconStyle, getStyles('rightIcon')])
|
|
106
|
+
|
|
107
|
+
const hasText = !!(text || children)
|
|
108
|
+
|
|
109
|
+
const _styles = {
|
|
110
|
+
wrapper: getStyles('wrapper'),
|
|
111
|
+
loader: getStyles('loader'),
|
|
112
|
+
leftIcon: leftIconStyle,
|
|
113
|
+
rightIcon: rightIconStyle,
|
|
114
|
+
text: getStyles('text'),
|
|
115
|
+
icon: getStyles('icon'),
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const childrenContent = TypeGuards.isFunction(children) ?
|
|
120
|
+
// @ts-ignore
|
|
121
|
+
children({ styles: _styles, props: buttonProps })
|
|
122
|
+
: children
|
|
123
|
+
|
|
124
|
+
let _badge = null
|
|
125
|
+
|
|
126
|
+
if (badge) {
|
|
127
|
+
_badge = React.isValidElement(badge) ? badge : <Badge {...badge} styles={deepMerge({
|
|
128
|
+
text: variantStyles.badgeText,
|
|
129
|
+
wrapper: variantStyles.badgeWrapper,
|
|
130
|
+
}, badge?.styles || {})}/>
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<Touchable
|
|
136
|
+
style={_styles.wrapper}
|
|
137
|
+
ref={ref}
|
|
138
|
+
disabled={disabled}
|
|
139
|
+
styles={{
|
|
140
|
+
feedback: variantStyles.feedback,
|
|
141
|
+
}}
|
|
142
|
+
onPress={onPress}
|
|
143
|
+
debugComponent={'Button'}
|
|
144
|
+
noFeedback={!onPress}
|
|
145
|
+
{...props}
|
|
146
|
+
>
|
|
147
|
+
{_badge}
|
|
148
|
+
{loading && <ActivityIndicator style={_styles.loader} />}
|
|
149
|
+
{!loading && <Icon name={icon} style={_styles.leftIcon} renderEmptySpace={hasText && !!rightIcon}/>}
|
|
150
|
+
{text ? <Text text={text} style={_styles.text} /> : null}
|
|
151
|
+
{childrenContent}
|
|
152
|
+
<Icon name={rightIcon} style={_styles.rightIcon} renderEmptySpace={(hasText && !!icon) || loading} />
|
|
153
|
+
</Touchable>
|
|
154
|
+
)
|
|
155
|
+
})
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { createDefaultVariantFactory, includePresets, StylesOf } from '@codeleap/common'
|
|
2
|
+
import { ActivityIndicatorComposition } from '../ActivityIndicator'
|
|
3
|
+
import { TouchableStylesGen } from '../Touchable'
|
|
4
|
+
|
|
5
|
+
export type ButtonStates = 'disabled'
|
|
6
|
+
export type ButtonParts =
|
|
7
|
+
| 'text'
|
|
8
|
+
| 'inner'
|
|
9
|
+
| 'wrapper'
|
|
10
|
+
| 'icon'
|
|
11
|
+
| 'leftIcon'
|
|
12
|
+
| 'rightIcon'
|
|
13
|
+
| 'loader'
|
|
14
|
+
| `loader${Capitalize<ActivityIndicatorComposition>}`
|
|
15
|
+
| 'badgeText'
|
|
16
|
+
| 'badgeWrapper'
|
|
17
|
+
|
|
18
|
+
export type ButtonComposition = `${ButtonParts}:${ButtonStates}` | ButtonParts
|
|
19
|
+
|
|
20
|
+
export type ButtonStylesGen<TCSS = any> = StylesOf<ButtonComposition, TCSS> & {
|
|
21
|
+
feedback?: TouchableStylesGen['feedback']
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const createButtonStyle = createDefaultVariantFactory<ButtonComposition, ButtonStylesGen >()
|
|
25
|
+
|
|
26
|
+
const presets = includePresets((styles) => createButtonStyle(() => ({ wrapper: styles })))
|
|
27
|
+
|
|
28
|
+
export const ButtonStyles = {
|
|
29
|
+
...presets,
|
|
30
|
+
default: createButtonStyle((theme) => ({
|
|
31
|
+
wrapper: {
|
|
32
|
+
|
|
33
|
+
flexDirection: 'row',
|
|
34
|
+
backgroundColor: theme.colors.primary,
|
|
35
|
+
...theme.presets.justifyCenter,
|
|
36
|
+
...theme.presets.alignCenter,
|
|
37
|
+
...theme.spacing.paddingHorizontal(2.5),
|
|
38
|
+
},
|
|
39
|
+
text: {
|
|
40
|
+
textAlign: 'center',
|
|
41
|
+
// ...theme.spacing.marginHorizontal(2.5),
|
|
42
|
+
},
|
|
43
|
+
loader: {
|
|
44
|
+
height: 20,
|
|
45
|
+
width: 20,
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
loaderFrontCircle: {
|
|
49
|
+
borderTopColor: theme.colors.white,
|
|
50
|
+
},
|
|
51
|
+
'wrapper:disabled': {
|
|
52
|
+
backgroundColor: theme.colors.disabled,
|
|
53
|
+
opacity: 0.9,
|
|
54
|
+
cursor: 'auto',
|
|
55
|
+
|
|
56
|
+
},
|
|
57
|
+
badgeWrapper: {
|
|
58
|
+
backgroundColor: theme.colors.negative,
|
|
59
|
+
position: 'absolute',
|
|
60
|
+
...theme.spacing.padding(2.5),
|
|
61
|
+
},
|
|
62
|
+
badgeText: {
|
|
63
|
+
color: theme.colors.white,
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
leftIcon: {
|
|
67
|
+
...theme.sized(4),
|
|
68
|
+
...theme.spacing.marginRight('auto'),
|
|
69
|
+
// ...theme.spacing.marginLeft(2.5),
|
|
70
|
+
},
|
|
71
|
+
rightIcon: {
|
|
72
|
+
...theme.spacing.marginLeft('auto'),
|
|
73
|
+
// ...theme.spacing.marginRight(2.5),
|
|
74
|
+
...theme.sized(4),
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
})),
|
|
78
|
+
negative: createButtonStyle((theme) => ({
|
|
79
|
+
wrapper: {
|
|
80
|
+
backgroundColor: theme.colors.negative,
|
|
81
|
+
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
})),
|
|
85
|
+
|
|
86
|
+
circle: createButtonStyle((theme) => ({
|
|
87
|
+
wrapper: {
|
|
88
|
+
borderRadius: 100,
|
|
89
|
+
...theme.spacing.padding(1),
|
|
90
|
+
},
|
|
91
|
+
})),
|
|
92
|
+
pill: createButtonStyle((theme) => ({
|
|
93
|
+
wrapper: {
|
|
94
|
+
borderRadius: theme.borderRadius.medium,
|
|
95
|
+
...theme.spacing.paddingHorizontal(1),
|
|
96
|
+
...theme.spacing.paddingVertical(0.5),
|
|
97
|
+
},
|
|
98
|
+
})),
|
|
99
|
+
icon: createButtonStyle((theme) => ({
|
|
100
|
+
wrapper: {
|
|
101
|
+
backgroundColor: 'transparent',
|
|
102
|
+
aspectRatio: 1,
|
|
103
|
+
display: 'flex',
|
|
104
|
+
...theme.presets.center,
|
|
105
|
+
...theme.spacing.padding(0),
|
|
106
|
+
|
|
107
|
+
},
|
|
108
|
+
text: {
|
|
109
|
+
flex: 1,
|
|
110
|
+
textAlign: 'center',
|
|
111
|
+
},
|
|
112
|
+
loader: {
|
|
113
|
+
...theme.spacing.margin(0),
|
|
114
|
+
},
|
|
115
|
+
icon: {
|
|
116
|
+
...theme.spacing.margin(0),
|
|
117
|
+
...theme.presets.center,
|
|
118
|
+
height: null,
|
|
119
|
+
width: null,
|
|
120
|
+
color: theme.colors.icon,
|
|
121
|
+
},
|
|
122
|
+
leftIcon: {
|
|
123
|
+
...theme.spacing.marginRight(0),
|
|
124
|
+
},
|
|
125
|
+
rightIcon: {
|
|
126
|
+
...theme.spacing.marginRight(0),
|
|
127
|
+
},
|
|
128
|
+
})),
|
|
129
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { ComponentVariants, PropsOf, TypeGuards, useDefaultComponentStyle } from '@codeleap/common'
|
|
3
|
+
import { StyleSheet } from 'react-native'
|
|
4
|
+
import { format, formatISO } from 'date-fns'
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import { Calendar as RNCalendar, CalendarProps as RNCalendarProps, DateData } from 'react-native-calendars'
|
|
7
|
+
|
|
8
|
+
import { View } from '../View'
|
|
9
|
+
import { CalendarStyles } from './style'
|
|
10
|
+
import { TCalendarStyles } from './types'
|
|
11
|
+
export type CalendarProps = PropsOf<typeof View> & {
|
|
12
|
+
styles?: TCalendarStyles
|
|
13
|
+
onValueChange?: (date: Date|string) => any
|
|
14
|
+
value?: Date|string
|
|
15
|
+
calendarProps?: RNCalendarProps
|
|
16
|
+
} & ComponentVariants<typeof CalendarStyles>
|
|
17
|
+
export * from './style'
|
|
18
|
+
export * from './types'
|
|
19
|
+
|
|
20
|
+
export const Calendar = (props:CalendarProps) => {
|
|
21
|
+
const {
|
|
22
|
+
variants = [],
|
|
23
|
+
style,
|
|
24
|
+
styles = {},
|
|
25
|
+
calendarProps,
|
|
26
|
+
value,
|
|
27
|
+
onValueChange,
|
|
28
|
+
...viewProps
|
|
29
|
+
} = props
|
|
30
|
+
const variantStyles = useDefaultComponentStyle<'u:Calendar', typeof CalendarStyles>('u:Calendar', {
|
|
31
|
+
variants,
|
|
32
|
+
styles,
|
|
33
|
+
transform: StyleSheet.flatten,
|
|
34
|
+
rootElement: 'wrapper',
|
|
35
|
+
})
|
|
36
|
+
const isDateObject = TypeGuards.isInstance(value, Date)
|
|
37
|
+
const stringValue:string = isDateObject ? format(value, 'yyyy/MM/dd') : value
|
|
38
|
+
|
|
39
|
+
function handleChange(date:DateData) {
|
|
40
|
+
if (!onValueChange) return
|
|
41
|
+
if (isDateObject) {
|
|
42
|
+
onValueChange(new Date(date.timestamp))
|
|
43
|
+
} else {
|
|
44
|
+
onValueChange(date.dateString)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return <View style={[variantStyles.wrapper, style]} {...viewProps}>
|
|
49
|
+
<RNCalendar
|
|
50
|
+
onDayPress={handleChange}
|
|
51
|
+
current={new Date(value).toISOString()}
|
|
52
|
+
monthFormat={'MMMM yyyy'}
|
|
53
|
+
markedDates={{
|
|
54
|
+
[stringValue]: { selected: true },
|
|
55
|
+
}}
|
|
56
|
+
theme={{
|
|
57
|
+
...variantStyles.theme,
|
|
58
|
+
stylesheet: {
|
|
59
|
+
...variantStyles,
|
|
60
|
+
},
|
|
61
|
+
}}
|
|
62
|
+
{...calendarProps}
|
|
63
|
+
/>
|
|
64
|
+
</View>
|
|
65
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createDefaultVariantFactory } from '@codeleap/common'
|
|
2
|
+
import { TCalendarStyles, CalendarComposition } from './types'
|
|
3
|
+
|
|
4
|
+
const createCalendarStyle = createDefaultVariantFactory<CalendarComposition, TCalendarStyles>()
|
|
5
|
+
|
|
6
|
+
export const CalendarStyles = {
|
|
7
|
+
default: createCalendarStyle((theme) => ({
|
|
8
|
+
theme: {
|
|
9
|
+
backgroundColor: '#0000',
|
|
10
|
+
calendarBackground: '#0000',
|
|
11
|
+
textSectionTitleColor: theme.colors.textH,
|
|
12
|
+
textSectionTitleDisabledColor: theme.colors.disabled,
|
|
13
|
+
selectedDayBackgroundColor: theme.colors.primary,
|
|
14
|
+
selectedDayTextColor: theme.colors.white,
|
|
15
|
+
todayTextColor: theme.colors.textH,
|
|
16
|
+
dayTextColor: theme.colors.textP,
|
|
17
|
+
textDisabledColor: theme.colors.disabled,
|
|
18
|
+
dotColor: theme.colors.primary,
|
|
19
|
+
selectedDotColor: theme.colors.primary,
|
|
20
|
+
arrowColor: theme.colors.primary,
|
|
21
|
+
disabledArrowColor: theme.colors.disabled,
|
|
22
|
+
monthTextColor: theme.colors.textH,
|
|
23
|
+
indicatorColor: theme.colors.backgroundSecondary,
|
|
24
|
+
textDayFontFamily: theme.typography.fontFamily,
|
|
25
|
+
textMonthFontFamily: theme.typography.fontFamily,
|
|
26
|
+
textDayHeaderFontFamily: theme.typography.fontFamily,
|
|
27
|
+
textDayFontWeight: '400',
|
|
28
|
+
textMonthFontWeight: 'bold',
|
|
29
|
+
textDayHeaderFontWeight: '400',
|
|
30
|
+
textDayFontSize: 16,
|
|
31
|
+
textMonthFontSize: 22,
|
|
32
|
+
textDayHeaderFontSize: 15,
|
|
33
|
+
},
|
|
34
|
+
})),
|
|
35
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { FilterKeys } from '@codeleap/common'
|
|
2
|
+
import { Paths } from '@codeleap/common/dist/types/pathMapping'
|
|
3
|
+
import { TextStyle, ViewStyle } from 'react-native';
|
|
4
|
+
|
|
5
|
+
type CalendarTheme = {
|
|
6
|
+
timelineContainer?: object;
|
|
7
|
+
contentStyle?: ViewStyle;
|
|
8
|
+
event?: object;
|
|
9
|
+
eventTitle?: object;
|
|
10
|
+
eventSummary?: object;
|
|
11
|
+
eventTimes?: object;
|
|
12
|
+
line?: object;
|
|
13
|
+
verticalLine?: object;
|
|
14
|
+
nowIndicatorLine?: object;
|
|
15
|
+
nowIndicatorKnob?: object;
|
|
16
|
+
timeLabel?: object;
|
|
17
|
+
todayTextColor?: string;
|
|
18
|
+
calendarBackground?: string;
|
|
19
|
+
indicatorColor?: string;
|
|
20
|
+
textSectionTitleColor?: string;
|
|
21
|
+
textSectionTitleDisabledColor?: string;
|
|
22
|
+
dayTextColor?: string;
|
|
23
|
+
selectedDayTextColor?: string;
|
|
24
|
+
monthTextColor?: string;
|
|
25
|
+
selectedDayBackgroundColor?: string;
|
|
26
|
+
arrowColor?: string;
|
|
27
|
+
textDisabledColor?: string;
|
|
28
|
+
textInactiveColor?: string;
|
|
29
|
+
backgroundColor?: string; //TODO: remove in V2
|
|
30
|
+
dotColor?: string;
|
|
31
|
+
selectedDotColor?: string;
|
|
32
|
+
disabledArrowColor?: string;
|
|
33
|
+
textDayFontFamily?: TextStyle['fontFamily'];
|
|
34
|
+
textMonthFontFamily?: TextStyle['fontFamily'];
|
|
35
|
+
textDayHeaderFontFamily?: TextStyle['fontFamily'];
|
|
36
|
+
textDayFontWeight?: TextStyle['fontWeight'];
|
|
37
|
+
textMonthFontWeight?: TextStyle['fontWeight'];
|
|
38
|
+
textDayHeaderFontWeight?: TextStyle['fontWeight'];
|
|
39
|
+
textDayFontSize?: number;
|
|
40
|
+
textMonthFontSize?: number;
|
|
41
|
+
textDayHeaderFontSize?: number;
|
|
42
|
+
agendaDayTextColor?: string;
|
|
43
|
+
agendaDayNumColor?: string;
|
|
44
|
+
agendaTodayColor?: string;
|
|
45
|
+
agendaKnobColor?: string;
|
|
46
|
+
todayButtonFontFamily?: TextStyle['fontFamily'];
|
|
47
|
+
todayButtonFontWeight?: TextStyle['fontWeight'];
|
|
48
|
+
todayButtonFontSize?: number;
|
|
49
|
+
textDayStyle?: TextStyle;
|
|
50
|
+
dotStyle?: object;
|
|
51
|
+
arrowStyle?: ViewStyle;
|
|
52
|
+
todayBackgroundColor?: string;
|
|
53
|
+
disabledDotColor?: string;
|
|
54
|
+
inactiveDotColor?: string;
|
|
55
|
+
todayDotColor?: string;
|
|
56
|
+
todayButtonTextColor?: string;
|
|
57
|
+
todayButtonPosition?: string;
|
|
58
|
+
arrowHeight?: number;
|
|
59
|
+
arrowWidth?: number;
|
|
60
|
+
weekVerticalMargin?: number;
|
|
61
|
+
stylesheet?: {
|
|
62
|
+
calendar?: {
|
|
63
|
+
main?: object;
|
|
64
|
+
header?: object;
|
|
65
|
+
};
|
|
66
|
+
day?: {
|
|
67
|
+
basic?: object;
|
|
68
|
+
period?: object;
|
|
69
|
+
};
|
|
70
|
+
dot?: object;
|
|
71
|
+
marking?: object;
|
|
72
|
+
'calendar-list'?: {
|
|
73
|
+
main?: object;
|
|
74
|
+
};
|
|
75
|
+
agenda?: {
|
|
76
|
+
main?: object;
|
|
77
|
+
list?: object;
|
|
78
|
+
};
|
|
79
|
+
expandable?: {
|
|
80
|
+
main?: object;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
type FlatStyleKeys = 'dot' | 'marking'
|
|
86
|
+
|
|
87
|
+
type StyleSheetKeys = Exclude<keyof CalendarTheme['stylesheet'], FlatStyleKeys>
|
|
88
|
+
|
|
89
|
+
type ThemeObjPrimitiveKeys = FilterKeys<CalendarTheme, string|number>
|
|
90
|
+
|
|
91
|
+
type ThemeObjCompositionKeys = Exclude<keyof CalendarTheme, ThemeObjPrimitiveKeys | 'stylesheet'>
|
|
92
|
+
|
|
93
|
+
type StyleSheetObjKeys = Exclude<Paths<CalendarTheme['stylesheet']>, StyleSheetKeys>
|
|
94
|
+
|
|
95
|
+
export type CalendarStyleGen<TCSS = any> = {
|
|
96
|
+
theme?: Partial<{
|
|
97
|
+
[P in ThemeObjPrimitiveKeys]: CalendarTheme[P]
|
|
98
|
+
}>
|
|
99
|
+
} & Partial<Record<StyleSheetObjKeys | 'wrapper' | ThemeObjCompositionKeys, TCSS>>
|
|
100
|
+
|
|
101
|
+
export type CalendarComposition = keyof CalendarStyleGen
|
|
102
|
+
export type TCalendarStyles = CalendarStyleGen<any>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
ComponentVariants,
|
|
4
|
+
useDefaultComponentStyle,
|
|
5
|
+
StylesOf,
|
|
6
|
+
Form,
|
|
7
|
+
useValidate,
|
|
8
|
+
GetRefType,
|
|
9
|
+
PropsOf,
|
|
10
|
+
} from '@codeleap/common'
|
|
11
|
+
import { ComponentPropsWithRef, forwardRef, ReactNode } from 'react'
|
|
12
|
+
import { StyleSheet, Switch as NativeCheckbox } from 'react-native'
|
|
13
|
+
import { FormError } from '../TextInput'
|
|
14
|
+
import { View } from '../View'
|
|
15
|
+
import { Touchable } from '../Touchable'
|
|
16
|
+
import {
|
|
17
|
+
CheckboxStyles,
|
|
18
|
+
CheckboxComposition,
|
|
19
|
+
} from './styles'
|
|
20
|
+
import { InputLabel } from '../InputLabel'
|
|
21
|
+
export * from './styles'
|
|
22
|
+
|
|
23
|
+
type NativeCheckboxProps = Omit<
|
|
24
|
+
ComponentPropsWithRef<typeof NativeCheckbox>,
|
|
25
|
+
'thumbColor' | 'trackColor'
|
|
26
|
+
>
|
|
27
|
+
type CheckboxProps = NativeCheckboxProps & {
|
|
28
|
+
variants?: ComponentVariants<typeof CheckboxStyles>['variants']
|
|
29
|
+
label?: ReactNode
|
|
30
|
+
styles?: StylesOf<CheckboxComposition>
|
|
31
|
+
validate?: Form.ValidatorFunctionWithoutForm | string
|
|
32
|
+
required?: boolean
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const Checkbox = forwardRef<GetRefType<PropsOf<typeof View>['ref']>, CheckboxProps>(
|
|
36
|
+
(checkboxProps, ref) => {
|
|
37
|
+
const {
|
|
38
|
+
variants = [],
|
|
39
|
+
style = {},
|
|
40
|
+
styles = {},
|
|
41
|
+
label,
|
|
42
|
+
value,
|
|
43
|
+
onValueChange,
|
|
44
|
+
validate,
|
|
45
|
+
required,
|
|
46
|
+
...props
|
|
47
|
+
} = checkboxProps
|
|
48
|
+
|
|
49
|
+
const variantStyles = useDefaultComponentStyle<'u:Checkbox', typeof CheckboxStyles>('u:Checkbox', {
|
|
50
|
+
variants,
|
|
51
|
+
styles,
|
|
52
|
+
transform: StyleSheet.flatten,
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const { error, showError } = useValidate(value, validate)
|
|
56
|
+
|
|
57
|
+
function getStyles(key: CheckboxComposition, styleObj = variantStyles) {
|
|
58
|
+
return [
|
|
59
|
+
styleObj[key],
|
|
60
|
+
value ? styleObj[key + ':checked'] : {},
|
|
61
|
+
showError ? styleObj[key + ':error'] : {},
|
|
62
|
+
checkboxProps.disabled ? styleObj[key + ':disabled'] : {},
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<View style={[getStyles('wrapper'), style]} ref={ref} {...props}>
|
|
68
|
+
<Touchable
|
|
69
|
+
debugName={`Set checkbox value to ${!value}`}
|
|
70
|
+
style={getStyles('input')}
|
|
71
|
+
onPress={() => onValueChange(!value)}
|
|
72
|
+
styles={{
|
|
73
|
+
feedback: getStyles('inputFeedback'),
|
|
74
|
+
}}
|
|
75
|
+
>
|
|
76
|
+
<View style={getStyles('checkmarkWrapper')}>
|
|
77
|
+
<View style={getStyles('checkmark')} />
|
|
78
|
+
</View>
|
|
79
|
+
|
|
80
|
+
<InputLabel label={label} styles={{
|
|
81
|
+
asterisk: getStyles('labelAsterisk'),
|
|
82
|
+
wrapper: getStyles('labelWrapper'),
|
|
83
|
+
text: getStyles('labelText'),
|
|
84
|
+
}} required={required}/>
|
|
85
|
+
|
|
86
|
+
</Touchable>
|
|
87
|
+
<FormError text={error.message} style={getStyles('error')} />
|
|
88
|
+
</View>
|
|
89
|
+
)
|
|
90
|
+
},
|
|
91
|
+
)
|