@codeleap/mobile 3.25.0 → 3.25.3
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/package.json +4 -6
- package/src/components/ActionIcon/index.tsx +37 -55
- package/src/components/ActionIcon/styles.ts +4 -2
- package/src/components/ActivityIndicator/index.tsx +64 -42
- package/src/components/ActivityIndicator/styles.ts +10 -1
- package/src/components/Autocomplete/index.tsx +54 -46
- package/src/components/Autocomplete/styles.ts +5 -2
- package/src/components/Autocomplete/types.ts +23 -13
- package/src/components/Avatar/index.tsx +71 -59
- package/src/components/Avatar/styles.ts +9 -1
- package/src/components/AvatarGroup/index.tsx +44 -30
- package/src/components/AvatarGroup/styles.ts +6 -0
- package/src/components/Backdrop/index.tsx +34 -51
- package/src/components/Backdrop/styles.ts +10 -5
- package/src/components/Badge/index.tsx +62 -36
- package/src/components/Badge/styles.ts +11 -3
- package/src/components/Button/index.tsx +82 -55
- package/src/components/Button/styles.ts +14 -13
- package/src/components/Calendar/index.tsx +29 -35
- package/src/components/Calendar/style.ts +6 -0
- package/src/components/Checkbox/index.tsx +64 -43
- package/src/components/Checkbox/styles.ts +6 -1
- package/src/components/ContentView/index.tsx +63 -0
- package/src/components/ContentView/styles.ts +8 -0
- package/src/components/DatePickerModal/index.tsx +65 -50
- package/src/components/DatePickerModal/styles.ts +10 -9
- package/src/components/DatePickerModal/types.ts +54 -36
- package/src/components/Drawer/index.tsx +28 -0
- package/src/components/Drawer/styles.ts +8 -0
- package/src/components/EmptyPlaceholder/index.tsx +63 -40
- package/src/components/EmptyPlaceholder/styles.ts +5 -0
- package/src/components/FileInput/index.tsx +49 -11
- package/src/components/FileInput/styles.ts +8 -0
- package/src/components/Grid/index.tsx +116 -84
- package/src/components/Grid/styles.ts +5 -0
- package/src/components/Icon/index.tsx +79 -44
- package/src/components/Icon/styles.ts +6 -0
- package/src/components/Image/index.tsx +78 -58
- package/src/components/Image/styles.ts +6 -1
- package/src/components/ImageView/Spotlight.tsx +4 -1
- package/src/components/ImageView/component.tsx +2 -1
- package/src/components/InputBase/index.tsx +24 -33
- package/src/components/InputBase/styles.ts +75 -66
- package/src/components/InputBase/types.ts +4 -3
- package/src/components/InputBase/utils.ts +4 -6
- package/src/components/InputLabel/index.tsx +38 -0
- package/src/components/InputLabel/styles.ts +7 -0
- package/src/components/List/PaginationIndicator.tsx +54 -0
- package/src/components/List/index.tsx +151 -99
- package/src/components/List/styles.ts +6 -0
- package/src/components/LoadingOverlay/index.tsx +29 -42
- package/src/components/LoadingOverlay/styles.ts +7 -7
- package/src/components/Modal/index.tsx +127 -80
- package/src/components/Modal/styles.ts +8 -0
- package/src/components/Navigation/Navigation.tsx +0 -1
- package/src/components/Navigation/types.ts +9 -2
- package/src/components/NumberIncrement/index.tsx +60 -50
- package/src/components/NumberIncrement/styles.ts +5 -0
- package/src/components/NumberIncrement/types.ts +39 -32
- package/src/components/Pager/index.tsx +94 -42
- package/src/components/Pager/styles.ts +13 -1
- package/src/components/RadioInput/index.tsx +57 -32
- package/src/components/RadioInput/styles.ts +7 -5
- package/src/components/RefreshControl/index.tsx +19 -39
- package/src/components/RefreshControl/styles.ts +6 -1
- package/src/components/Scroll/index.tsx +105 -89
- package/src/components/Scroll/styles.ts +5 -0
- package/src/components/Sections/index.tsx +161 -111
- package/src/components/Sections/styles.ts +5 -0
- package/src/components/SegmentedControl/Option.tsx +31 -46
- package/src/components/SegmentedControl/index.tsx +121 -86
- package/src/components/SegmentedControl/styles.ts +22 -15
- package/src/components/Select/index.tsx +82 -71
- package/src/components/Select/styles.ts +5 -3
- package/src/components/Select/types.ts +25 -20
- package/src/components/Slider/index.tsx +43 -58
- package/src/components/Slider/styles.ts +6 -15
- package/src/components/Slider/types.ts +14 -9
- package/src/components/Switch/index.tsx +56 -43
- package/src/components/Switch/styles.ts +7 -1
- package/src/components/Text/index.tsx +52 -56
- package/src/components/Text/styles.ts +7 -1
- package/src/components/TextInput/index.tsx +162 -49
- package/src/components/TextInput/styles.ts +8 -2
- package/src/components/Touchable/index.tsx +87 -44
- package/src/components/Touchable/styles.ts +9 -0
- package/src/components/View/index.tsx +92 -23
- package/src/components/View/styles.ts +6 -0
- package/src/components/components.ts +6 -2
- package/src/components/defaultStyles.ts +77 -0
- package/src/index.ts +0 -2
- package/src/modules/PressableRipple/type.ts +0 -1
- package/src/utils/KeyboardAware/context.tsx +2 -0
- package/src/utils/KeyboardAware/keyboardHooks.ts +2 -1
- package/src/utils/ModalManager/components.tsx +30 -1
- package/src/utils/ModalManager/context.tsx +4 -4
- package/src/utils/ModalManager/index.ts +4 -1
- package/src/utils/hooks.ts +1 -12
- package/src/Registry.ts +0 -52
- package/src/components/ActionIcon/types.ts +0 -15
- package/src/components/ActivityIndicator/types.ts +0 -9
- package/src/components/Avatar/types.ts +0 -23
- package/src/components/AvatarGroup/types.ts +0 -10
- package/src/components/Backdrop/types.ts +0 -14
- package/src/components/Badge/types.ts +0 -27
- package/src/components/Button/types.ts +0 -20
- package/src/components/Checkbox/types.ts +0 -13
- package/src/components/EmptyPlaceholder/types.ts +0 -21
- package/src/components/FileInput/types.ts +0 -27
- package/src/components/Grid/types.ts +0 -20
- package/src/components/Icon/types.ts +0 -15
- package/src/components/Image/types.ts +0 -18
- package/src/components/List/types.ts +0 -41
- package/src/components/LoadingOverlay/types.ts +0 -9
- package/src/components/Modal/types.ts +0 -41
- package/src/components/Pager/types.ts +0 -37
- package/src/components/PaginationIndicator/index.tsx +0 -51
- package/src/components/PaginationIndicator/styles.ts +0 -3
- package/src/components/PaginationIndicator/types.ts +0 -10
- package/src/components/RadioInput/types.ts +0 -31
- package/src/components/RefreshControl/types.ts +0 -9
- package/src/components/Scroll/types.ts +0 -21
- package/src/components/SearchInput/index.tsx +0 -90
- package/src/components/Sections/types.ts +0 -39
- package/src/components/SegmentedControl/types.ts +0 -31
- package/src/components/Switch/types.ts +0 -12
- package/src/components/Text/types.ts +0 -18
- package/src/components/TextInput/types.ts +0 -23
- package/src/components/Touchable/types.ts +0 -27
- package/src/components/View/types.ts +0 -13
- package/src/hooks/index.ts +0 -13
|
@@ -1,38 +1,107 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { forwardRef } from 'react'
|
|
3
|
+
import {
|
|
4
|
+
ComponentVariants,
|
|
5
|
+
useDefaultComponentStyle,
|
|
6
|
+
ViewStyles,
|
|
7
|
+
useCodeleapContext,
|
|
8
|
+
useMemo,
|
|
9
|
+
AnyRef,
|
|
10
|
+
TypeGuards,
|
|
11
|
+
} from '@codeleap/common'
|
|
12
|
+
import { View as NativeView, ViewProps as RNViewProps } from 'react-native'
|
|
13
|
+
import { TransitionConfig } from '../../types'
|
|
5
14
|
import Animated from 'react-native-reanimated'
|
|
6
|
-
import { ViewProps } from './types'
|
|
7
|
-
import { useStylesFor } from '../../hooks'
|
|
8
|
-
|
|
9
|
-
export * from './types'
|
|
10
15
|
export * from './styles'
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
type NativeViewProps = RNViewProps
|
|
18
|
+
|
|
19
|
+
export type ViewRefType = NativeView
|
|
20
|
+
|
|
21
|
+
export type ViewProps = {
|
|
22
|
+
ref?: AnyRef<ViewRefType>
|
|
23
|
+
component?: any
|
|
24
|
+
animated?: boolean
|
|
25
|
+
keyboardAware?: boolean
|
|
26
|
+
transition?: Partial<TransitionConfig>
|
|
27
|
+
}
|
|
28
|
+
& NativeViewProps
|
|
29
|
+
& ComponentVariants<typeof ViewStyles>
|
|
30
|
+
|
|
31
|
+
export const View = forwardRef<NativeView, ViewProps>((viewProps, ref) => {
|
|
13
32
|
const {
|
|
33
|
+
responsiveVariants = {},
|
|
34
|
+
variants = [],
|
|
35
|
+
children,
|
|
14
36
|
style,
|
|
15
|
-
|
|
37
|
+
keyboardAware,
|
|
38
|
+
component,
|
|
16
39
|
animated = false,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} = props
|
|
40
|
+
...props
|
|
41
|
+
} = viewProps
|
|
20
42
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
43
|
+
const variantStyles = useDefaultComponentStyle('View', {
|
|
44
|
+
responsiveVariants,
|
|
45
|
+
variants,
|
|
46
|
+
})
|
|
47
|
+
const Component = animated ? Animated.View : component || NativeView
|
|
24
48
|
|
|
25
49
|
return (
|
|
26
|
-
<Component {...
|
|
50
|
+
<Component {...props} style={[variantStyles.wrapper, style]}>
|
|
51
|
+
{children}
|
|
52
|
+
</Component>
|
|
27
53
|
)
|
|
54
|
+
}) as unknown as ((props: ViewProps) => JSX.Element)
|
|
55
|
+
|
|
56
|
+
type GapProps = ViewProps & {
|
|
57
|
+
value: number
|
|
58
|
+
crossValue?: number
|
|
59
|
+
defaultProps?: any
|
|
28
60
|
}
|
|
29
61
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
62
|
+
export const Gap = ({ children, value, defaultProps = {}, crossValue = null, ...props }: GapProps) => {
|
|
63
|
+
const { Theme } = useCodeleapContext()
|
|
64
|
+
const childArr = React.Children.toArray(children)
|
|
33
65
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
66
|
+
const horizontal = props.variants?.includes('row')
|
|
67
|
+
|
|
68
|
+
const spacings = useMemo(() => {
|
|
69
|
+
return childArr.map((_, idx) => {
|
|
70
|
+
|
|
71
|
+
const space = Theme.spacing.value(value)
|
|
72
|
+
const crossSpace = Theme.spacing.value(crossValue)
|
|
37
73
|
|
|
38
|
-
|
|
74
|
+
const isLast = idx === childArr.length - 1
|
|
75
|
+
|
|
76
|
+
const spacingProperty = horizontal ? 'marginRight' : 'marginBottom'
|
|
77
|
+
const crossSpacingProperty = horizontal ? 'marginBottom' : 'marginRight'
|
|
78
|
+
|
|
79
|
+
const style = isLast ? {} : {
|
|
80
|
+
[spacingProperty]: space,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!TypeGuards.isNil(crossValue)) {
|
|
84
|
+
style[crossSpacingProperty] = crossSpace
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return style
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
}, [childArr.length, horizontal])
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<View {...props}>
|
|
94
|
+
{
|
|
95
|
+
childArr.map((Element, idx, childArr) => {
|
|
96
|
+
if (React.isValidElement(Element)) {
|
|
97
|
+
const props = { ...Element.props, ...defaultProps }
|
|
98
|
+
|
|
99
|
+
props.style = [props.style, spacings[idx]]
|
|
100
|
+
return React.cloneElement(Element, props)
|
|
101
|
+
}
|
|
102
|
+
return Element
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
</View>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
|
|
1
2
|
|
|
2
3
|
export type ViewComposition = 'wrapper'
|
|
4
|
+
|
|
5
|
+
const createViewStyle = createDefaultVariantFactory<ViewComposition>()
|
|
6
|
+
|
|
7
|
+
export const ViewPresets = includePresets((styles) => createViewStyle(() => ({ wrapper: styles })))
|
|
8
|
+
|
|
@@ -7,6 +7,7 @@ export * from './Checkbox'
|
|
|
7
7
|
export * from './TextInput'
|
|
8
8
|
export * from './RadioInput'
|
|
9
9
|
export * from './Switch'
|
|
10
|
+
export * from './ContentView'
|
|
10
11
|
export * from './Sections'
|
|
11
12
|
export * from './Select'
|
|
12
13
|
export * from './FileInput'
|
|
@@ -17,6 +18,7 @@ export * from './Scroll'
|
|
|
17
18
|
export * from './List'
|
|
18
19
|
export * from './ActivityIndicator'
|
|
19
20
|
export * from './Button'
|
|
21
|
+
export * from './ContentView'
|
|
20
22
|
export * from './Modal'
|
|
21
23
|
export * from './Calendar'
|
|
22
24
|
export * from './ImageView'
|
|
@@ -24,9 +26,11 @@ export * from './Navigation'
|
|
|
24
26
|
export * from './Pager'
|
|
25
27
|
export * from './EmptyPlaceholder'
|
|
26
28
|
export * from './Backdrop'
|
|
29
|
+
export * from './Drawer'
|
|
27
30
|
export * from './SegmentedControl'
|
|
28
31
|
export * from './Autocomplete'
|
|
29
32
|
export * from './Grid'
|
|
33
|
+
export * from './InputLabel'
|
|
30
34
|
export * from './LoadingOverlay'
|
|
31
35
|
export * from './ActionIcon'
|
|
32
36
|
export * from './InputBase'
|
|
@@ -36,5 +40,5 @@ export * from './Avatar'
|
|
|
36
40
|
export * from './AvatarGroup'
|
|
37
41
|
export * from './NumberIncrement'
|
|
38
42
|
export * from './Badge'
|
|
39
|
-
|
|
40
|
-
export * from './
|
|
43
|
+
|
|
44
|
+
export * from './defaultStyles'
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ViewPresets } from './View'
|
|
2
|
+
import { IconPresets } from './Icon'
|
|
3
|
+
import { TouchablePresets } from './Touchable'
|
|
4
|
+
import { TextPresets } from './Text'
|
|
5
|
+
import { ImagePresets } from './Image'
|
|
6
|
+
import { CheckboxPresets } from './Checkbox'
|
|
7
|
+
import { TextInputPresets } from './TextInput'
|
|
8
|
+
import { RadioInputPresets } from './RadioInput'
|
|
9
|
+
import { SwitchPresets } from './Switch'
|
|
10
|
+
import { SelectPresets } from './Select'
|
|
11
|
+
import { FileInputPresets } from './FileInput'
|
|
12
|
+
import { SliderPresets } from './Slider'
|
|
13
|
+
import { SegmentedControlPresets } from './SegmentedControl'
|
|
14
|
+
import { ActivityIndicatorPresets } from './ActivityIndicator'
|
|
15
|
+
import { ButtonPresets } from './Button'
|
|
16
|
+
import { ContentViewPresets } from './ContentView'
|
|
17
|
+
import { ModalPresets } from './Modal'
|
|
18
|
+
import { EmptyPlaceholderPresets } from './EmptyPlaceholder'
|
|
19
|
+
import { BackdropPresets } from './Backdrop'
|
|
20
|
+
import { PagerPresets } from './Pager'
|
|
21
|
+
import { CalendarPresets } from './Calendar'
|
|
22
|
+
import { DrawerPresets } from './Drawer/styles'
|
|
23
|
+
import { ListPresets, PaginationIndicatorPresets } from './List'
|
|
24
|
+
|
|
25
|
+
import { ScrollPresets } from './Scroll'
|
|
26
|
+
import { ActionIconPresets } from './ActionIcon'
|
|
27
|
+
import { GridPresets } from './Grid'
|
|
28
|
+
import { InputLabelPresets } from './InputLabel'
|
|
29
|
+
import { LoadingOverlayPresets } from './LoadingOverlay'
|
|
30
|
+
import { InputBasePresets } from './InputBase'
|
|
31
|
+
import { RefreshControlPresets } from './RefreshControl'
|
|
32
|
+
import { AvatarPresets } from './Avatar'
|
|
33
|
+
import { AvatarGroupPresets } from './AvatarGroup'
|
|
34
|
+
import { SectionsPresets } from './Sections'
|
|
35
|
+
import { DatePickerModalPresets } from './DatePickerModal'
|
|
36
|
+
import { NumberIncrementPresets } from './NumberIncrement'
|
|
37
|
+
import { BadgePresets } from './Badge'
|
|
38
|
+
|
|
39
|
+
export const defaultStyles = {
|
|
40
|
+
View: ViewPresets,
|
|
41
|
+
Icon: IconPresets,
|
|
42
|
+
Avatar: AvatarPresets,
|
|
43
|
+
AvatarGroup: AvatarGroupPresets,
|
|
44
|
+
Touchable: TouchablePresets,
|
|
45
|
+
Text: TextPresets,
|
|
46
|
+
Image: ImagePresets,
|
|
47
|
+
Checkbox: CheckboxPresets,
|
|
48
|
+
TextInput: TextInputPresets,
|
|
49
|
+
RadioInput: RadioInputPresets,
|
|
50
|
+
Switch: SwitchPresets,
|
|
51
|
+
Select: SelectPresets,
|
|
52
|
+
FileInput: FileInputPresets,
|
|
53
|
+
List: ListPresets,
|
|
54
|
+
Slider: SliderPresets,
|
|
55
|
+
SegmentedControl: SegmentedControlPresets,
|
|
56
|
+
ActivityIndicator: ActivityIndicatorPresets,
|
|
57
|
+
Button: ButtonPresets,
|
|
58
|
+
ContentView: ContentViewPresets,
|
|
59
|
+
Modal: ModalPresets,
|
|
60
|
+
EmptyPlaceholder: EmptyPlaceholderPresets,
|
|
61
|
+
Backdrop: BackdropPresets,
|
|
62
|
+
Calendar: CalendarPresets,
|
|
63
|
+
Pager: PagerPresets,
|
|
64
|
+
Drawer: DrawerPresets,
|
|
65
|
+
Scroll: ScrollPresets,
|
|
66
|
+
Sections: SectionsPresets,
|
|
67
|
+
ActionIcon: ActionIconPresets,
|
|
68
|
+
Grid: GridPresets,
|
|
69
|
+
LoadingOverlay: LoadingOverlayPresets,
|
|
70
|
+
InputLabel: InputLabelPresets,
|
|
71
|
+
InputBase: InputBasePresets,
|
|
72
|
+
DatePickerModal: DatePickerModalPresets,
|
|
73
|
+
RefreshControl: RefreshControlPresets,
|
|
74
|
+
PaginationIndicator: PaginationIndicatorPresets,
|
|
75
|
+
NumberIncrement: NumberIncrementPresets,
|
|
76
|
+
Badge: BadgePresets,
|
|
77
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export * from './components/components'
|
|
2
2
|
export { Linking } from 'react-native'
|
|
3
3
|
export * from './utils'
|
|
4
|
-
export * from './hooks'
|
|
5
4
|
import uuid from 'react-native-uuid'
|
|
6
5
|
import * as RNKeyboardAwareScrollView from './utils/KeyboardAware'
|
|
7
6
|
export { uuid, RNKeyboardAwareScrollView }
|
|
8
|
-
export { MobileStyleRegistry } from './Registry'
|
|
@@ -11,9 +11,11 @@ type TKeyboardCtx = {
|
|
|
11
11
|
* @deprecated useKeyboard does not need to be wrapped in a provider
|
|
12
12
|
*/
|
|
13
13
|
export const KeyboardProvider = ({ children }) => {
|
|
14
|
+
|
|
14
15
|
return <>
|
|
15
16
|
{children}
|
|
16
17
|
</>
|
|
18
|
+
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
export const useKeyboard = (): TKeyboardCtx => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PropsOf, TypeGuards } from '@codeleap/common'
|
|
1
|
+
import { PropsOf, useCodeleapContext, TypeGuards } from '@codeleap/common'
|
|
2
2
|
import { ScrollView, Platform, StyleSheet, Dimensions, EasingFunction, Easing } from 'react-native'
|
|
3
3
|
import { TransitionConfig } from '../../types'
|
|
4
4
|
import { useKeyboard } from './context'
|
|
@@ -26,6 +26,7 @@ type UseKeyboardAwareViewParams = {
|
|
|
26
26
|
|
|
27
27
|
export const useKeyboardAwareView = (params?: UseKeyboardAwareViewParams) => {
|
|
28
28
|
const keyboard = useKeyboard()
|
|
29
|
+
const { logger } = useCodeleapContext()
|
|
29
30
|
const options = params || {}
|
|
30
31
|
|
|
31
32
|
const _options:GetKeyboardAwarePropsOptions = {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import * as React from 'react'
|
|
2
2
|
import { usePrevious, onMount, onUpdate, PropsOf } from '@codeleap/common'
|
|
3
3
|
import { useModalContext } from './context'
|
|
4
4
|
import { Portal } from '@gorhom/portal'
|
|
5
5
|
import { Modal as _Modal } from '../../components/Modal'
|
|
6
|
+
import { Drawer as _Drawer } from '../../components/Drawer'
|
|
6
7
|
|
|
7
8
|
type UseManagedModalArgs = {
|
|
8
9
|
id?: string
|
|
@@ -81,3 +82,31 @@ export const Modal:React.FC<ManagedModalProps> = ({
|
|
|
81
82
|
|
|
82
83
|
return content
|
|
83
84
|
}
|
|
85
|
+
|
|
86
|
+
export type ManagedDrawerProps<T = PropsOf<typeof _Drawer>> = Omit<T, 'visible' | 'toggle'> & UseManagedModalArgs & {
|
|
87
|
+
|
|
88
|
+
absolute?: boolean
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const Drawer:React.FC<ManagedDrawerProps> = ({
|
|
93
|
+
children,
|
|
94
|
+
absolute = true,
|
|
95
|
+
...props
|
|
96
|
+
}) => {
|
|
97
|
+
const componentProps = useManagedModal(props)
|
|
98
|
+
|
|
99
|
+
const content = (
|
|
100
|
+
<_Drawer {...componentProps}>
|
|
101
|
+
{children}
|
|
102
|
+
</_Drawer>
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
if (absolute) {
|
|
106
|
+
return <Portal>
|
|
107
|
+
{content}
|
|
108
|
+
</Portal>
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return content
|
|
112
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { AnyFunction, onUpdate, TypeGuards, useState } from '@codeleap/common'
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { AnyFunction, onUpdate, TypeGuards, useCodeleapContext, useState } from '@codeleap/common'
|
|
3
3
|
import { PortalProvider } from '@gorhom/portal'
|
|
4
4
|
import { KeyboardProvider } from '../KeyboardAware'
|
|
5
5
|
|
|
@@ -69,8 +69,8 @@ export function Provider({ children }) {
|
|
|
69
69
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
const defaultDuration = 300
|
|
72
|
+
const codeleapCtx = useCodeleapContext()
|
|
73
|
+
const defaultDuration = codeleapCtx?.Theme?.values?.transitions?.modal?.duration || 300
|
|
74
74
|
const transition:TModalContext['transition'] = (from, to, options) => {
|
|
75
75
|
return new Promise((resolve) => {
|
|
76
76
|
setTimeout(() => {
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { useModalContext, useModalSequence, Provider } from './context'
|
|
2
|
-
import { Modal, ManagedModalProps } from './components'
|
|
2
|
+
import { Modal, ManagedModalProps, Drawer, ManagedDrawerProps } from './components'
|
|
3
3
|
|
|
4
4
|
export const ModalManager = {
|
|
5
5
|
useModalContext,
|
|
6
6
|
Modal,
|
|
7
|
+
Drawer,
|
|
7
8
|
Provider,
|
|
8
9
|
useModalSequence,
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export type {
|
|
12
13
|
ManagedModalProps,
|
|
14
|
+
ManagedDrawerProps,
|
|
15
|
+
|
|
13
16
|
}
|
package/src/utils/hooks.ts
CHANGED
|
@@ -6,7 +6,6 @@ import { AnimatedStyleProp, Easing, EasingFn, interpolateColor, runOnJS, useAnim
|
|
|
6
6
|
import { PressableRippleProps } from '../modules/PressableRipple/type'
|
|
7
7
|
import { useSoftInputState } from 'react-native-avoid-softinput'
|
|
8
8
|
import { useMemo } from 'react'
|
|
9
|
-
import { mergeStyles } from '@codeleap/styles'
|
|
10
9
|
|
|
11
10
|
export function useAnimateColor(value: string, opts?: Partial<Animated.TimingAnimationConfig>) {
|
|
12
11
|
const iters = useRef(0)
|
|
@@ -200,16 +199,6 @@ type RippleConfig = {
|
|
|
200
199
|
}
|
|
201
200
|
export type TouchableFeedbackConfig = RippleConfig | FeedbackConfig
|
|
202
201
|
|
|
203
|
-
export type TouchFeedbackConfig = {
|
|
204
|
-
type?: 'ripple' | 'opacity' | 'highlight' | 'styles' | 'none'
|
|
205
|
-
config?: PressableRippleProps
|
|
206
|
-
iosFallback?: FeedbackConfig
|
|
207
|
-
value?: number
|
|
208
|
-
brightness?: number
|
|
209
|
-
shiftOpacity?: number
|
|
210
|
-
styles?: StyleProp<ViewStyle>
|
|
211
|
-
}
|
|
212
|
-
|
|
213
202
|
export type UsePressableFeedbackConfig = {
|
|
214
203
|
disabled?: boolean
|
|
215
204
|
feedbackConfig?: TouchableFeedbackConfig
|
|
@@ -364,5 +353,5 @@ export function useKeyboardPaddingStyle(styles: ViewStyle[], enabled = true) {
|
|
|
364
353
|
|
|
365
354
|
const totalPadding = softInputHeight + bottomPadding
|
|
366
355
|
|
|
367
|
-
return isSoftInputShown && enabled ?
|
|
356
|
+
return isSoftInputShown && enabled ? [propStyle, { paddingBottom: totalPadding }] : [propStyle]
|
|
368
357
|
}
|
package/src/Registry.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { AnyStyledComponent, CodeleapStyleRegistry, ICSS, StylePersistor } from '@codeleap/styles'
|
|
2
|
-
import { StyleSheet } from 'react-native'
|
|
3
|
-
import { MMKV } from 'react-native-mmkv'
|
|
4
|
-
|
|
5
|
-
const mmkvStorage = new MMKV()
|
|
6
|
-
|
|
7
|
-
const persistor = new StylePersistor({
|
|
8
|
-
set(key, value) {
|
|
9
|
-
return mmkvStorage?.set(key, value)
|
|
10
|
-
},
|
|
11
|
-
get(key) {
|
|
12
|
-
return mmkvStorage?.getString(key)
|
|
13
|
-
},
|
|
14
|
-
del(key) {
|
|
15
|
-
return mmkvStorage?.delete(key)
|
|
16
|
-
},
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
let instance: MobileStyleRegistry
|
|
20
|
-
|
|
21
|
-
const components: CodeleapStyleRegistry['components'][string][] = []
|
|
22
|
-
|
|
23
|
-
export class MobileStyleRegistry extends CodeleapStyleRegistry {
|
|
24
|
-
constructor() {
|
|
25
|
-
super(persistor)
|
|
26
|
-
|
|
27
|
-
components.forEach((component) => {
|
|
28
|
-
this.registerComponent(component)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
if (!instance) {
|
|
32
|
-
instance = this
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return instance
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
createStyle(css: ICSS): ICSS {
|
|
39
|
-
return StyleSheet.create({ s: css }).s
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static get current() {
|
|
43
|
-
return instance
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static registerComponent(component: AnyStyledComponent) {
|
|
47
|
-
components.push(component)
|
|
48
|
-
if (instance) {
|
|
49
|
-
instance.registerComponent(component)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { AppIcon, StyledProp } from '@codeleap/styles'
|
|
2
|
-
import { BadgeComponentProps } from '../Badge'
|
|
3
|
-
import { IconProps } from '../Icon'
|
|
4
|
-
import { TouchableProps } from '../Touchable'
|
|
5
|
-
import { ActionIconComposition } from './styles'
|
|
6
|
-
|
|
7
|
-
export type ActionIconProps =
|
|
8
|
-
Omit<TouchableProps, 'style'> &
|
|
9
|
-
BadgeComponentProps &
|
|
10
|
-
{
|
|
11
|
-
iconProps?: Partial<IconProps>
|
|
12
|
-
icon?: AppIcon
|
|
13
|
-
name?: AppIcon
|
|
14
|
-
style?: StyledProp<ActionIconComposition>
|
|
15
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { PropsOf } from '@codeleap/common'
|
|
2
|
-
import { StyledProp } from '@codeleap/styles'
|
|
3
|
-
import { ActivityIndicator as RNActivityIndicator } from 'react-native'
|
|
4
|
-
import { ActivityIndicatorComposition } from './styles'
|
|
5
|
-
|
|
6
|
-
export type ActivityIndicatorProps<T extends React.ComponentType = typeof RNActivityIndicator> = {
|
|
7
|
-
style?: StyledProp<ActivityIndicatorComposition>
|
|
8
|
-
component?: T
|
|
9
|
-
} & PropsOf<T>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { StyledProp } from '@codeleap/styles'
|
|
2
|
-
import { BadgeComponentProps } from '../Badge'
|
|
3
|
-
import { IconProps } from '../Icon'
|
|
4
|
-
import { ImageProps } from '../Image'
|
|
5
|
-
import { ViewProps } from '../View'
|
|
6
|
-
import { AvatarComposition } from './styles'
|
|
7
|
-
|
|
8
|
-
export type AvatarProps =
|
|
9
|
-
Omit<ViewProps, 'style'> &
|
|
10
|
-
BadgeComponentProps &
|
|
11
|
-
{
|
|
12
|
-
image?: ImageProps['source']
|
|
13
|
-
name?: string | string[]
|
|
14
|
-
debugName: string
|
|
15
|
-
firstNameOnly?: boolean
|
|
16
|
-
text?: string
|
|
17
|
-
description?: string
|
|
18
|
-
icon?: IconProps['name']
|
|
19
|
-
badgeIcon?: IconProps['name']
|
|
20
|
-
style?: StyledProp<AvatarComposition>
|
|
21
|
-
onPress?: () => void
|
|
22
|
-
noFeedback?: boolean
|
|
23
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { StyledProp } from '@codeleap/styles'
|
|
2
|
-
import { AvatarProps } from '../Avatar/types'
|
|
3
|
-
import { AvatarGroupComposition } from './styles'
|
|
4
|
-
|
|
5
|
-
export type AvatarGroupProps = {
|
|
6
|
-
style?: StyledProp<AvatarGroupComposition>
|
|
7
|
-
avatars: Partial<AvatarProps>[]
|
|
8
|
-
displacement?: number
|
|
9
|
-
debugName: string
|
|
10
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { StyledProp } from '@codeleap/styles'
|
|
2
|
-
import { ReactNode } from 'react'
|
|
3
|
-
import { TouchableProps } from '../Touchable'
|
|
4
|
-
import { ViewProps } from '../View/types'
|
|
5
|
-
import { BackdropComposition } from './styles'
|
|
6
|
-
|
|
7
|
-
export type BackdropProps =
|
|
8
|
-
Omit<TouchableProps, 'style'> &
|
|
9
|
-
{
|
|
10
|
-
children?: ReactNode
|
|
11
|
-
visible: boolean
|
|
12
|
-
wrapperProps?: ViewProps
|
|
13
|
-
style?: StyledProp<BackdropComposition>
|
|
14
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { PropsOf } from '@codeleap/common'
|
|
2
|
-
import { StyledProp } from '@codeleap/styles'
|
|
3
|
-
import { Text } from '../Text'
|
|
4
|
-
import { View, ViewProps } from '../View'
|
|
5
|
-
import { BadgeComposition } from './styles'
|
|
6
|
-
|
|
7
|
-
export type BadgeProps =
|
|
8
|
-
Omit<ViewProps, 'style'> &
|
|
9
|
-
{
|
|
10
|
-
style?: StyledProp<BadgeComposition>
|
|
11
|
-
maxCount?: number
|
|
12
|
-
minCount?: number
|
|
13
|
-
debugName?: string
|
|
14
|
-
innerWrapperProps?: Partial<PropsOf<typeof View>>
|
|
15
|
-
textProps?: Partial<PropsOf<typeof Text>>
|
|
16
|
-
getBadgeContent?: (props: BadgeContent) => string
|
|
17
|
-
renderBadgeContent?: (props: BadgeContent & { content: string }) => JSX.Element
|
|
18
|
-
disabled?: boolean
|
|
19
|
-
badge?: number | boolean
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type BadgeContent = BadgeProps & { count: number }
|
|
23
|
-
|
|
24
|
-
export type BadgeComponentProps = {
|
|
25
|
-
badge?: BadgeProps['badge']
|
|
26
|
-
badgeProps?: Partial<BadgeProps>
|
|
27
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AppIcon, StyledProp } from '@codeleap/styles'
|
|
2
|
-
import { ReactNode } from 'react'
|
|
3
|
-
import { BadgeComponentProps } from '../Badge'
|
|
4
|
-
import { TouchableProps } from '../Touchable'
|
|
5
|
-
import { ButtonComposition } from './styles'
|
|
6
|
-
|
|
7
|
-
export type ButtonProps =
|
|
8
|
-
Omit<TouchableProps, 'style'> &
|
|
9
|
-
BadgeComponentProps &
|
|
10
|
-
{
|
|
11
|
-
text?: string
|
|
12
|
-
rightIcon?: AppIcon
|
|
13
|
-
icon?: AppIcon
|
|
14
|
-
loading?: boolean
|
|
15
|
-
debounce?: number
|
|
16
|
-
debugName: string
|
|
17
|
-
selected?: boolean
|
|
18
|
-
children?: ReactNode
|
|
19
|
-
style?: StyledProp<ButtonComposition>
|
|
20
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AppIcon, StyledProp } from '@codeleap/styles'
|
|
2
|
-
import { InputBaseProps } from '../InputBase'
|
|
3
|
-
import { CheckboxComposition } from './styles'
|
|
4
|
-
|
|
5
|
-
export type CheckboxProps =
|
|
6
|
-
Pick<InputBaseProps, 'debugName' | 'disabled' | 'label'> &
|
|
7
|
-
{
|
|
8
|
-
value: boolean
|
|
9
|
-
onValueChange: (value: boolean) => void
|
|
10
|
-
style?: StyledProp<CheckboxComposition>
|
|
11
|
-
checkboxOnLeft?: boolean
|
|
12
|
-
checkIcon?: AppIcon
|
|
13
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { AppIcon, StyledProp } from '@codeleap/styles'
|
|
2
|
-
import { ReactElement } from 'react'
|
|
3
|
-
import { ImageProps } from '../Image'
|
|
4
|
-
import { EmptyPlaceholderComposition } from './styles'
|
|
5
|
-
|
|
6
|
-
type RenderEmpty = (props: {
|
|
7
|
-
emptyText: string | ReactElement
|
|
8
|
-
emptyIconName?: AppIcon
|
|
9
|
-
style?: StyledProp<EmptyPlaceholderComposition>
|
|
10
|
-
}) => ReactElement
|
|
11
|
-
|
|
12
|
-
export type EmptyPlaceholderProps = {
|
|
13
|
-
itemName?: string
|
|
14
|
-
title?: ReactElement | string
|
|
15
|
-
description?: ReactElement | string
|
|
16
|
-
image?: ImageProps['source']
|
|
17
|
-
icon?: AppIcon
|
|
18
|
-
loading?: boolean
|
|
19
|
-
style?: StyledProp<EmptyPlaceholderComposition>
|
|
20
|
-
renderEmpty?: RenderEmpty
|
|
21
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AnyRef, FormTypes } from '@codeleap/common'
|
|
2
|
-
import { DocumentPickerOptions } from 'react-native-document-picker'
|
|
3
|
-
import { Options } from 'react-native-image-crop-picker'
|
|
4
|
-
import { OSAlert } from '../../utils'
|
|
5
|
-
|
|
6
|
-
export type FileInputImageSource = 'camera' | 'library' | 'fs'
|
|
7
|
-
|
|
8
|
-
export type FileResult = FormTypes.AnyFile
|
|
9
|
-
|
|
10
|
-
export type FileInputRef = {
|
|
11
|
-
openFilePicker: (string?: FileInputImageSource) => Promise<FileResult[]>
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type FileInputProps = {
|
|
15
|
-
mode: 'hidden' | 'button'
|
|
16
|
-
onFileSelect?: (files: FileResult[]) => void
|
|
17
|
-
options?: DocumentPickerOptions<any>
|
|
18
|
-
ref?: AnyRef<FileInputRef>
|
|
19
|
-
type?: 'image' | 'anyFile'
|
|
20
|
-
alertProps?: Parameters<typeof OSAlert.ask>[0]
|
|
21
|
-
pickerOptions?: Partial<Options>
|
|
22
|
-
required?: boolean
|
|
23
|
-
onOpenCamera?: (resolve: (() => void)) => Promise<void>
|
|
24
|
-
onOpenFileSystem?: (resolve: (() => void)) => Promise<void>
|
|
25
|
-
onOpenGallery?: (resolve: (() => void)) => Promise<void>
|
|
26
|
-
onError?: (error: any) => void
|
|
27
|
-
}
|