@codeleap/mobile 1.9.26 → 1.9.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Backdrop.d.ts +66 -0
- package/dist/components/Backdrop.js +70 -0
- package/dist/components/Backdrop.js.map +1 -0
- package/dist/components/Button.d.ts +11 -4
- package/dist/components/Button.js +17 -6
- package/dist/components/Button.js.map +1 -1
- package/dist/components/EmptyPlaceholder.d.ts +12 -0
- package/dist/components/EmptyPlaceholder.js +54 -0
- package/dist/components/EmptyPlaceholder.js.map +1 -0
- package/dist/components/FileInput.js +0 -2
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/Gap.d.ts +8 -0
- package/dist/components/Gap.js +60 -0
- package/dist/components/Gap.js.map +1 -0
- package/dist/components/Image.js +2 -2
- package/dist/components/Image.js.map +1 -1
- package/dist/components/List.d.ts +25 -6
- package/dist/components/List.js +20 -3
- package/dist/components/List.js.map +1 -1
- package/dist/components/Modal/index.d.ts +2 -1
- package/dist/components/Modal/index.js +27 -27
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/styles.d.ts +4 -15
- package/dist/components/Modal/styles.js +27 -23
- package/dist/components/Modal/styles.js.map +1 -1
- package/dist/components/NewModal/index.d.ts +27 -0
- package/dist/components/NewModal/index.js +99 -0
- package/dist/components/NewModal/index.js.map +1 -0
- package/dist/components/NewModal/styles.d.ts +57 -0
- package/dist/components/NewModal/styles.js +58 -0
- package/dist/components/NewModal/styles.js.map +1 -0
- package/dist/components/NewPager/index.js +3 -7
- package/dist/components/NewPager/index.js.map +1 -1
- package/dist/components/Overlay.js +13 -9
- package/dist/components/Overlay.js.map +1 -1
- package/dist/components/Scroll.d.ts +4 -2
- package/dist/components/Scroll.js.map +1 -1
- package/dist/components/SegmentedControl/index.d.ts +42 -0
- package/dist/components/SegmentedControl/index.js +137 -0
- package/dist/components/SegmentedControl/index.js.map +1 -0
- package/dist/components/SegmentedControl/styles.d.ts +54 -0
- package/dist/components/SegmentedControl/styles.js +36 -0
- package/dist/components/SegmentedControl/styles.js.map +1 -0
- package/dist/components/SegmentedControl.d.ts +5 -0
- package/dist/components/SegmentedControl.js +32 -0
- package/dist/components/SegmentedControl.js.map +1 -0
- package/dist/components/Select/index.js +1 -1
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Text.d.ts +8 -3
- package/dist/components/Text.js +12 -5
- package/dist/components/Text.js.map +1 -1
- package/dist/components/TextInput.d.ts +4 -2
- package/dist/components/TextInput.js +2 -2
- package/dist/components/TextInput.js.map +1 -1
- package/dist/components/Touchable.d.ts +5 -3
- package/dist/components/Touchable.js +26 -19
- package/dist/components/Touchable.js.map +1 -1
- package/dist/components/View.js +1 -1
- package/dist/components/View.js.map +1 -1
- package/dist/components/_Modal/index.d.ts +27 -0
- package/dist/components/_Modal/index.js +114 -0
- package/dist/components/_Modal/index.js.map +1 -0
- package/dist/components/_Modal/styles.d.ts +64 -0
- package/dist/components/_Modal/styles.js +60 -0
- package/dist/components/_Modal/styles.js.map +1 -0
- package/dist/components/components.d.ts +5 -1
- package/dist/components/components.js +5 -1
- package/dist/components/components.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/modules/textInputMask.d.ts +4 -7
- package/dist/modules/types/textInputMask.d.ts +5 -10
- package/dist/utils/ModalManager/components.d.ts +12 -0
- package/dist/utils/ModalManager/components.js +86 -0
- package/dist/utils/ModalManager/components.js.map +1 -0
- package/dist/utils/ModalManager/context.d.ts +47 -0
- package/dist/utils/ModalManager/context.js +196 -0
- package/dist/utils/ModalManager/context.js.map +1 -0
- package/dist/utils/ModalManager/index.d.ts +10 -0
- package/dist/utils/ModalManager/index.js +12 -0
- package/dist/utils/ModalManager/index.js.map +1 -0
- package/dist/utils/PermissionManager/components.d.ts +18 -0
- package/dist/utils/PermissionManager/components.js +52 -0
- package/dist/utils/PermissionManager/components.js.map +1 -0
- package/dist/utils/PermissionManager/context.d.ts +52 -0
- package/dist/utils/PermissionManager/context.js +325 -0
- package/dist/utils/PermissionManager/context.js.map +1 -0
- package/dist/utils/PermissionManager/index.d.ts +4 -0
- package/dist/utils/PermissionManager/index.js +9 -0
- package/dist/utils/PermissionManager/index.js.map +1 -0
- package/dist/utils/PermissionManager/types.d.ts +13 -0
- package/dist/utils/PermissionManager/types.js +3 -0
- package/dist/utils/PermissionManager/types.js.map +1 -0
- package/dist/utils/hooks.d.ts +6 -0
- package/dist/utils/hooks.js +62 -0
- package/dist/utils/hooks.js.map +1 -0
- package/package.json +2 -1
- package/src/components/Backdrop.tsx +77 -0
- package/src/components/Button.tsx +31 -8
- package/src/components/EmptyPlaceholder.tsx +53 -0
- package/src/components/FileInput.tsx +2 -2
- package/src/components/Gap.tsx +40 -0
- package/src/components/Image.tsx +3 -2
- package/src/components/List.tsx +50 -6
- package/src/components/Modal/index.tsx +39 -49
- package/src/components/Modal/styles.ts +36 -39
- package/src/components/NewPager/index.tsx +5 -7
- package/src/components/Overlay.tsx +22 -13
- package/src/components/Pager/index.tsx +19 -19
- package/src/components/Pager/styles.ts +6 -7
- package/src/components/Scroll.tsx +3 -1
- package/src/components/SegmentedControl/index.tsx +182 -0
- package/src/components/SegmentedControl/styles.ts +65 -0
- package/src/components/Select/index.tsx +1 -2
- package/src/components/Text.tsx +23 -10
- package/src/components/TextInput.tsx +4 -2
- package/src/components/Touchable.tsx +31 -20
- package/src/components/View.tsx +1 -1
- package/src/components/_Modal/index.tsx +162 -0
- package/src/components/_Modal/styles.ts +125 -0
- package/src/components/components.ts +5 -1
- package/src/index.ts +6 -0
- package/src/modules/imageCropPicker.d.ts +497 -0
- package/src/modules/index.d.ts +186 -0
- package/src/modules/types/textInputMask.ts +6 -10
- package/src/utils/ModalManager/components.tsx +69 -0
- package/src/utils/ModalManager/context.tsx +247 -0
- package/src/utils/ModalManager/index.ts +13 -0
- package/src/utils/PermissionManager/context.tsx +299 -0
- package/src/utils/PermissionManager/index.ts +20 -0
- package/src/utils/PermissionManager/types.ts +24 -0
- package/src/utils/hooks.ts +65 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React, { useMemo } from 'react'
|
|
2
|
+
import { Icon } from './Icon'
|
|
3
|
+
import { View } from './View'
|
|
4
|
+
import { Text } from './Text'
|
|
5
|
+
import { ActivityIndicator } from './ActivityIndicator'
|
|
6
|
+
import {
|
|
7
|
+
ComponentVariants,
|
|
8
|
+
EmptyPlaceholderComposition,
|
|
9
|
+
EmptyPlaceholderStyles,
|
|
10
|
+
getNestedStylesByKey,
|
|
11
|
+
IconPlaceholder,
|
|
12
|
+
useDefaultComponentStyle,
|
|
13
|
+
} from '@codeleap/common'
|
|
14
|
+
import { StyleSheet } from 'react-native'
|
|
15
|
+
import { StylesOf } from '../types/utility'
|
|
16
|
+
|
|
17
|
+
export type EmptyPlaceholderProps = {
|
|
18
|
+
itemName?: string
|
|
19
|
+
title?: string
|
|
20
|
+
loading?: boolean
|
|
21
|
+
styles?: StylesOf<EmptyPlaceholderComposition>
|
|
22
|
+
variants?: ComponentVariants<typeof EmptyPlaceholderStyles>['variants']
|
|
23
|
+
emptyIconName?: IconPlaceholder
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const EmptyPlaceholder:React.FC<EmptyPlaceholderProps> = (props: EmptyPlaceholderProps) => {
|
|
27
|
+
const { itemName, title, loading, styles = {}, variants = [], emptyIconName = 'search' } = props
|
|
28
|
+
const emptyText = title || (itemName && `No ${itemName} found.`) || 'No items.'
|
|
29
|
+
|
|
30
|
+
const componentStyles = useDefaultComponentStyle('EmptyPlaceholder', {
|
|
31
|
+
variants,
|
|
32
|
+
transform: StyleSheet.flatten,
|
|
33
|
+
styles,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const activityIndicatorStyles = useMemo(() => getNestedStylesByKey('loader', componentStyles)
|
|
37
|
+
, [componentStyles])
|
|
38
|
+
|
|
39
|
+
if (loading) {
|
|
40
|
+
return (
|
|
41
|
+
<View style={[componentStyles.wrapper, componentStyles['wrapper:loading']]} >
|
|
42
|
+
<ActivityIndicator styles={activityIndicatorStyles}/>
|
|
43
|
+
</View>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<View style={componentStyles.wrapper}>
|
|
49
|
+
<Icon name={emptyIconName as IconPlaceholder} style={componentStyles.icon}/>
|
|
50
|
+
<Text text={emptyText} style={componentStyles.text}/>
|
|
51
|
+
</View>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
@@ -112,11 +112,11 @@ export const FileInput = forwardRef<
|
|
|
112
112
|
if (warn) {
|
|
113
113
|
// NOTE yeah, it should not be both of course but just logger.* isn't showing for some reason
|
|
114
114
|
logger.warn(err)
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
} else {
|
|
117
117
|
// NOTE yeah, it should not be both of course but just logger.* isn't showing for some reason
|
|
118
118
|
logger.error(err)
|
|
119
|
-
|
|
119
|
+
|
|
120
120
|
if (onError) {
|
|
121
121
|
onError(err)
|
|
122
122
|
} else {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { useCodeleapContext } from '@codeleap/common'
|
|
3
|
+
import { View, ViewProps } from './View'
|
|
4
|
+
|
|
5
|
+
type GapProps = ViewProps & {
|
|
6
|
+
value: number
|
|
7
|
+
|
|
8
|
+
defaultProps?: any
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Gap:React.FC<GapProps> = ({ children, value, defaultProps = {}, ...props }) => {
|
|
12
|
+
const { Theme } = useCodeleapContext()
|
|
13
|
+
const horizontal = props.variants?.includes('row')
|
|
14
|
+
return (
|
|
15
|
+
<View {...props}>
|
|
16
|
+
{
|
|
17
|
+
React.Children.toArray(children).map((Element, idx, childArr) => {
|
|
18
|
+
if (React.isValidElement(Element)) {
|
|
19
|
+
const props = { ...Element.props, ...defaultProps }
|
|
20
|
+
|
|
21
|
+
let spacingFunction = horizontal ? 'marginHorizontal' : 'marginVertical'
|
|
22
|
+
switch (idx) {
|
|
23
|
+
case 0:
|
|
24
|
+
spacingFunction = horizontal ? 'marginRight' : 'marginBottom'
|
|
25
|
+
break
|
|
26
|
+
case childArr.length - 1:
|
|
27
|
+
spacingFunction = horizontal ? 'marginLeft' : 'marginTop'
|
|
28
|
+
break
|
|
29
|
+
default:
|
|
30
|
+
break
|
|
31
|
+
}
|
|
32
|
+
props.style = [props.style, Theme.spacing[spacingFunction](value / 2)]
|
|
33
|
+
return React.cloneElement(Element, props)
|
|
34
|
+
}
|
|
35
|
+
return Element
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
</View>
|
|
39
|
+
)
|
|
40
|
+
}
|
package/src/components/Image.tsx
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
Image as NativeImage,
|
|
12
12
|
ImageStyle,
|
|
13
13
|
StyleProp,
|
|
14
|
+
StyleSheet,
|
|
14
15
|
TextStyle,
|
|
15
16
|
ViewStyle,
|
|
16
17
|
} from 'react-native'
|
|
@@ -35,14 +36,14 @@ export const ImageComponent: React.FC<ImageProps> = (props) => {
|
|
|
35
36
|
|
|
36
37
|
const variantStyles = useDefaultComponentStyle('Image', { variants })
|
|
37
38
|
|
|
38
|
-
const styles = [variantStyles.wrapper, style]
|
|
39
|
+
const styles = StyleSheet.flatten([variantStyles.wrapper, style])
|
|
39
40
|
|
|
40
41
|
if (fast) {
|
|
41
42
|
return (
|
|
42
43
|
<FastImage
|
|
43
44
|
style={styles}
|
|
44
45
|
// @ts-ignore
|
|
45
|
-
tintColor={
|
|
46
|
+
tintColor={styles?.tintColor}
|
|
46
47
|
resizeMode={FastImage.resizeMode[resizeMode || 'contain']}
|
|
47
48
|
{...imageProps}
|
|
48
49
|
/>
|
package/src/components/List.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
useDefaultComponentStyle,
|
|
7
7
|
usePrevious,
|
|
8
8
|
useCodeleapContext,
|
|
9
|
+
TypeGuards,
|
|
9
10
|
} from '@codeleap/common'
|
|
10
11
|
import {
|
|
11
12
|
|
|
@@ -13,18 +14,36 @@ import {
|
|
|
13
14
|
// @ts-ignore
|
|
14
15
|
} from 'react-native-keyboard-aware-scroll-view'
|
|
15
16
|
|
|
16
|
-
import { RefreshControl, FlatList } from 'react-native'
|
|
17
|
+
import { RefreshControl, FlatList, FlatListProps as RNFlatListProps, ListRenderItemInfo } from 'react-native'
|
|
17
18
|
import { View, ViewProps } from './View'
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
import { EmptyPlaceholder, EmptyPlaceholderProps } from './EmptyPlaceholder'
|
|
20
|
+
import { ActivityIndicator } from './ActivityIndicator'
|
|
21
|
+
import { Text } from './Text'
|
|
22
|
+
export type DataboundFlatListPropsTypes = 'data' | 'renderItem' | 'keyExtractor' | 'getItemLayout'
|
|
23
|
+
|
|
24
|
+
export type ReplaceFlatlistProps<P, T> = Omit<P, DataboundFlatListPropsTypes> & {
|
|
25
|
+
data: T[]
|
|
26
|
+
keyExtractor?: (item: T, index: number) => string
|
|
27
|
+
renderItem: (data: ListRenderItemInfo<T>) => React.ReactElement
|
|
28
|
+
onRefresh?: () => void
|
|
29
|
+
getItemLayout?: ((
|
|
30
|
+
data:T,
|
|
31
|
+
index: number,
|
|
32
|
+
) => { length: number; offset: number; index: number })
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type FlatListProps<
|
|
36
|
+
T = any[],
|
|
37
|
+
Data = T extends Array<infer D> ? D : never
|
|
38
|
+
> =RNFlatListProps<Data> &
|
|
21
39
|
ViewProps & {
|
|
22
|
-
onRefresh?: () => void
|
|
23
40
|
refreshTimeout?: number
|
|
24
41
|
changeData?: any
|
|
25
42
|
separators?: boolean
|
|
26
43
|
refreshing?: boolean
|
|
44
|
+
placeholder?: EmptyPlaceholderProps
|
|
27
45
|
keyboardAware?: boolean
|
|
46
|
+
|
|
28
47
|
}
|
|
29
48
|
|
|
30
49
|
const KeyboardAwareFlatList =
|
|
@@ -42,6 +61,7 @@ const ListCP = forwardRef<FlatList, FlatListProps>(
|
|
|
42
61
|
style,
|
|
43
62
|
refreshTimeout = 3000,
|
|
44
63
|
changeData,
|
|
64
|
+
placeholder,
|
|
45
65
|
keyboardAware = true,
|
|
46
66
|
...props
|
|
47
67
|
} = flatListProps
|
|
@@ -102,10 +122,34 @@ const ListCP = forwardRef<FlatList, FlatListProps>(
|
|
|
102
122
|
<RefreshControl refreshing={refreshingDisplay} onRefresh={onRefresh} />
|
|
103
123
|
)
|
|
104
124
|
}
|
|
125
|
+
ListEmptyComponent={<EmptyPlaceholder {...placeholder}/>}
|
|
105
126
|
{...props}
|
|
106
127
|
/>
|
|
107
128
|
)
|
|
108
129
|
},
|
|
109
130
|
)
|
|
110
131
|
|
|
111
|
-
export
|
|
132
|
+
export type PaginationIndicatorProps = {
|
|
133
|
+
isFetching?: boolean
|
|
134
|
+
hasMore?: boolean
|
|
135
|
+
noMoreItemsText: React.ReactChild
|
|
136
|
+
activityIndicator?: JSX.Element
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export const PaginationIndicator = ({ hasMore, isFetching, noMoreItemsText, activityIndicator }: PaginationIndicatorProps) => {
|
|
140
|
+
if (isFetching) {
|
|
141
|
+
return activityIndicator || <ActivityIndicator variants={['center', 'marginVertical:3']}/>
|
|
142
|
+
}
|
|
143
|
+
if (!hasMore) {
|
|
144
|
+
if (TypeGuards.isString(noMoreItemsText) || TypeGuards.isNumber(noMoreItemsText)) {
|
|
145
|
+
return <Text variants={['h4', 'marginVertical:3', 'textCenter', 'fullWidth']} text={noMoreItemsText.toString()}/>
|
|
146
|
+
}
|
|
147
|
+
return noMoreItemsText
|
|
148
|
+
}
|
|
149
|
+
return null
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export type ListComponentType = <T extends any[] = any[]>(props: FlatListProps<T>) => React.ReactElement
|
|
153
|
+
|
|
154
|
+
export const List = ListCP as ListComponentType
|
|
155
|
+
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
-
import { View, ViewProps
|
|
2
|
+
import { View, ViewProps } from '../View'
|
|
3
3
|
import { Button, ButtonProps } from '../Button'
|
|
4
4
|
import { Scroll } from '../Scroll'
|
|
5
5
|
import {
|
|
6
|
-
capitalize,
|
|
7
6
|
ComponentVariants,
|
|
7
|
+
getNestedStylesByKey,
|
|
8
8
|
IconPlaceholder,
|
|
9
9
|
onUpdate,
|
|
10
|
+
TypeGuards,
|
|
10
11
|
useDefaultComponentStyle,
|
|
11
|
-
useCodeleapContext,
|
|
12
12
|
} from '@codeleap/common'
|
|
13
13
|
import {
|
|
14
14
|
MobileModalComposition,
|
|
@@ -18,9 +18,10 @@ import {
|
|
|
18
18
|
import { StyleSheet } from 'react-native'
|
|
19
19
|
import { StylesOf } from '../../types/utility'
|
|
20
20
|
|
|
21
|
-
import {
|
|
21
|
+
import { useDynamicAnimation } from 'moti'
|
|
22
|
+
import { Backdrop } from '../Backdrop'
|
|
23
|
+
import { useStaticAnimationStyles } from '../../utils/hooks'
|
|
22
24
|
import { Text } from '../Text'
|
|
23
|
-
import { Animated } from '../Animated'
|
|
24
25
|
|
|
25
26
|
export * from './styles'
|
|
26
27
|
|
|
@@ -34,10 +35,11 @@ export type ModalProps = Omit<ViewProps, 'variants' | 'styles'> & {
|
|
|
34
35
|
closable?: boolean
|
|
35
36
|
footer?: React.ReactNode
|
|
36
37
|
title?: React.ReactNode
|
|
37
|
-
debugName
|
|
38
|
+
debugName: string
|
|
38
39
|
closeIconName?: IconPlaceholder
|
|
39
40
|
visible: boolean
|
|
40
41
|
toggle?: () => void
|
|
42
|
+
zIndex?: number
|
|
41
43
|
scroll?: boolean
|
|
42
44
|
keyboardAware?: boolean
|
|
43
45
|
}
|
|
@@ -58,10 +60,11 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
58
60
|
debugName,
|
|
59
61
|
scroll = true,
|
|
60
62
|
keyboardAware = true,
|
|
63
|
+
zIndex = null,
|
|
61
64
|
...props
|
|
62
65
|
} = modalProps
|
|
63
66
|
|
|
64
|
-
const variantStyles = useDefaultComponentStyle('Modal', {
|
|
67
|
+
const variantStyles = useDefaultComponentStyle('u:Modal', {
|
|
65
68
|
variants: variants as any,
|
|
66
69
|
transform: StyleSheet.flatten,
|
|
67
70
|
styles,
|
|
@@ -71,60 +74,46 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
71
74
|
const s = [
|
|
72
75
|
variantStyles[key],
|
|
73
76
|
styles[key],
|
|
74
|
-
visible ? variantStyles[key + ':visible'] : {},
|
|
75
|
-
visible ? styles[key + ':visible'] : {},
|
|
76
77
|
]
|
|
77
78
|
|
|
78
|
-
return s
|
|
79
|
+
return StyleSheet.flatten(s)
|
|
79
80
|
}
|
|
81
|
+
const buttonStyles = React.useMemo(() => getNestedStylesByKey('closeButton', variantStyles), [variantStyles])
|
|
80
82
|
|
|
81
|
-
const
|
|
82
|
-
const buttonEntries = {}
|
|
83
|
+
const boxAnimationStates = useStaticAnimationStyles(variantStyles, ['box:hidden', 'box:visible'])
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return buttonEntries
|
|
90
|
-
}, [variantStyles])
|
|
91
|
-
|
|
92
|
-
const boxAnimation = {
|
|
93
|
-
hidden: {
|
|
94
|
-
...variantStyles['box:pose'],
|
|
95
|
-
...styles['box:pose'],
|
|
96
|
-
},
|
|
97
|
-
visible: {
|
|
98
|
-
...variantStyles['box:pose:visible'],
|
|
99
|
-
...styles['box:pose:visible'],
|
|
100
|
-
},
|
|
101
|
-
}
|
|
85
|
+
const boxAnimation = useDynamicAnimation(() => {
|
|
86
|
+
return visible ? boxAnimationStates['box:visible'] : boxAnimationStates['box:hidden']
|
|
87
|
+
})
|
|
102
88
|
|
|
89
|
+
onUpdate(() => {
|
|
90
|
+
boxAnimation.animateTo(visible ? boxAnimationStates['box:visible'] : boxAnimationStates['box:hidden'])
|
|
91
|
+
}, [visible])
|
|
92
|
+
const wrapperStyle = getStyles('wrapper')
|
|
103
93
|
return (
|
|
104
|
-
<View
|
|
105
|
-
|
|
106
|
-
pointerEvents={visible ? 'auto' : 'none'}
|
|
107
|
-
>
|
|
108
|
-
<AnimatedView style={getStyles('overlay')} transition={'opacity'} />
|
|
94
|
+
<View style={[wrapperStyle, { zIndex: TypeGuards.isNumber(zIndex) ? zIndex : wrapperStyle?.zIndex }]} pointerEvents={visible ? 'auto' : 'none'}>
|
|
95
|
+
|
|
109
96
|
<Scroll
|
|
110
97
|
style={getStyles('innerWrapper')}
|
|
111
98
|
contentContainerStyle={getStyles('innerWrapperScroll')}
|
|
112
99
|
scrollEnabled={scroll}
|
|
113
100
|
keyboardAware={keyboardAware}
|
|
114
101
|
>
|
|
115
|
-
{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
102
|
+
<Backdrop visible={visible} debugName={`Modal ${debugName} backdrop`} styles={{
|
|
103
|
+
'wrapper:hidden': variantStyles['backdrop:hidden'],
|
|
104
|
+
'wrapper:visible': variantStyles['backdrop:visible'],
|
|
105
|
+
wrapper: variantStyles.backdrop,
|
|
106
|
+
}} onPress={(dismissOnBackdrop && closable) ? toggle : (() => {})}
|
|
107
|
+
wrapperProps={{
|
|
108
|
+
transition: { ...variantStyles['backdrop:transition'] },
|
|
109
|
+
}}
|
|
110
|
+
/>
|
|
111
|
+
<View
|
|
112
|
+
animated
|
|
113
|
+
state={boxAnimation}
|
|
127
114
|
style={getStyles('box')}
|
|
115
|
+
transition={{ ...variantStyles['box:transition'] }}
|
|
116
|
+
{...props}
|
|
128
117
|
>
|
|
129
118
|
{(title || showClose) && (
|
|
130
119
|
<View style={getStyles('header')}>
|
|
@@ -134,7 +123,7 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
134
123
|
title
|
|
135
124
|
)}
|
|
136
125
|
|
|
137
|
-
{showClose && closable && (
|
|
126
|
+
{(showClose && closable) && (
|
|
138
127
|
<Button
|
|
139
128
|
debugName={`${debugName} modal close button`}
|
|
140
129
|
icon={closeIconName as IconPlaceholder}
|
|
@@ -152,9 +141,10 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
152
141
|
{typeof footer === 'string' ? <Text text={footer} /> : footer}
|
|
153
142
|
</View>
|
|
154
143
|
)}
|
|
155
|
-
</
|
|
144
|
+
</View>
|
|
156
145
|
</Scroll>
|
|
157
146
|
</View>
|
|
147
|
+
|
|
158
148
|
)
|
|
159
149
|
}
|
|
160
150
|
|
|
@@ -1,58 +1,40 @@
|
|
|
1
1
|
import {
|
|
2
|
+
assignTextStyle,
|
|
2
3
|
ButtonComposition,
|
|
3
4
|
createDefaultVariantFactory,
|
|
4
5
|
includePresets,
|
|
5
|
-
ModalComposition,
|
|
6
|
-
ModalStyles,
|
|
7
|
-
assignTextStyle,
|
|
8
6
|
} from '@codeleap/common'
|
|
9
7
|
|
|
10
|
-
export
|
|
11
|
-
duration: 200,
|
|
12
|
-
ease: 'easeOut',
|
|
13
|
-
useNativeDriver: false,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const modalTransition = {
|
|
17
|
-
duration: 150,
|
|
18
|
-
ease: 'easeOut',
|
|
19
|
-
useNativeDriver: false,
|
|
20
|
-
}
|
|
8
|
+
export type AnimatableParts = 'box' | 'backdrop'
|
|
21
9
|
|
|
22
10
|
export type MobileModalParts =
|
|
11
|
+
| AnimatableParts
|
|
23
12
|
| 'wrapper'
|
|
24
|
-
| 'overlay'
|
|
25
13
|
| 'innerWrapper'
|
|
26
14
|
| 'innerWrapperScroll'
|
|
27
|
-
| 'box'
|
|
28
|
-
| 'footer'
|
|
29
15
|
| 'body'
|
|
16
|
+
| 'footer'
|
|
30
17
|
| 'header'
|
|
31
|
-
| 'touchableBackdrop'
|
|
32
|
-
| 'box:pose'
|
|
33
18
|
| 'title'
|
|
34
19
|
| `closeButton${Capitalize<ButtonComposition>}`
|
|
35
20
|
|
|
36
21
|
export type MobileModalComposition =
|
|
37
22
|
| MobileModalParts
|
|
38
|
-
| `${
|
|
23
|
+
| `${AnimatableParts}:visible`
|
|
24
|
+
| `${AnimatableParts}:hidden`
|
|
25
|
+
| `${AnimatableParts}:transition`
|
|
39
26
|
|
|
40
27
|
const createModalStyle = createDefaultVariantFactory<MobileModalComposition>()
|
|
41
28
|
|
|
42
|
-
const presets = includePresets((style) => createModalStyle(() => ({ body: style }))
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
const defaultModalStyles = ModalStyles
|
|
29
|
+
const presets = includePresets((style) => createModalStyle(() => ({ body: style })))
|
|
46
30
|
|
|
47
31
|
export const MobileModalStyles = {
|
|
48
|
-
|
|
32
|
+
|
|
49
33
|
...presets,
|
|
50
34
|
default: createModalStyle((Theme) => {
|
|
51
35
|
const fullSize = {
|
|
52
36
|
...Theme.presets.whole,
|
|
53
37
|
position: 'absolute',
|
|
54
|
-
width: Theme?.values?.width,
|
|
55
|
-
height: Theme?.values?.height,
|
|
56
38
|
}
|
|
57
39
|
|
|
58
40
|
return {
|
|
@@ -61,16 +43,34 @@ export const MobileModalStyles = {
|
|
|
61
43
|
|
|
62
44
|
...fullSize,
|
|
63
45
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
46
|
+
'box:transition': {
|
|
47
|
+
scale: {
|
|
48
|
+
duration: Theme.values.transitions.modal.duration,
|
|
49
|
+
type: 'timing',
|
|
50
|
+
},
|
|
51
|
+
opacity: {
|
|
52
|
+
duration: Theme.values.transitions.modal.duration,
|
|
53
|
+
type: 'timing',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
'backdrop:transition': {
|
|
57
|
+
opacity: {
|
|
58
|
+
duration: Theme.values.transitions.modal.duration,
|
|
59
|
+
type: 'timing',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
backdrop: {
|
|
67
63
|
|
|
68
64
|
backgroundColor: Theme.colors.black,
|
|
69
65
|
...fullSize,
|
|
70
66
|
},
|
|
71
|
-
|
|
67
|
+
|
|
68
|
+
'backdrop:visible': {
|
|
72
69
|
opacity: 0.5,
|
|
73
70
|
},
|
|
71
|
+
'backdrop:hidden': {
|
|
72
|
+
opacity: 0,
|
|
73
|
+
},
|
|
74
74
|
innerWrapper: {},
|
|
75
75
|
innerWrapperScroll: {
|
|
76
76
|
display: 'flex',
|
|
@@ -84,18 +84,15 @@ export const MobileModalStyles = {
|
|
|
84
84
|
borderRadius: Theme.borderRadius.medium,
|
|
85
85
|
...Theme.spacing.padding(2),
|
|
86
86
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
'box:pose': {
|
|
87
|
+
|
|
88
|
+
'box:hidden': {
|
|
91
89
|
opacity: 0,
|
|
92
90
|
scale: 0.8,
|
|
93
|
-
|
|
91
|
+
|
|
94
92
|
},
|
|
95
|
-
'box:
|
|
93
|
+
'box:visible': {
|
|
96
94
|
opacity: 1,
|
|
97
95
|
scale: 1,
|
|
98
|
-
transition: modalTransition,
|
|
99
96
|
},
|
|
100
97
|
header: {
|
|
101
98
|
flexDirection: 'row',
|
|
@@ -114,7 +111,7 @@ export const MobileModalStyles = {
|
|
|
114
111
|
},
|
|
115
112
|
}
|
|
116
113
|
}),
|
|
117
|
-
popup: createModalStyle((
|
|
114
|
+
popup: createModalStyle(() => ({})),
|
|
118
115
|
fullscreen: createModalStyle((theme) => ({
|
|
119
116
|
overlay: {
|
|
120
117
|
backgroundColor: theme.colors.background,
|
|
@@ -43,9 +43,9 @@ export const NewPager:React.FC<NewPagerProps> = (pagerProps) => {
|
|
|
43
43
|
returnEarly = true,
|
|
44
44
|
renderPageWrapper,
|
|
45
45
|
pageWrapperProps = {},
|
|
46
|
-
|
|
46
|
+
children,
|
|
47
47
|
} = pagerProps
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
let variantStyles = useDefaultComponentStyle<'u:Pager', typeof NewMobilePagerStyles>(
|
|
50
50
|
'u:Pager',
|
|
51
51
|
{
|
|
@@ -58,7 +58,7 @@ export const NewPager:React.FC<NewPagerProps> = (pagerProps) => {
|
|
|
58
58
|
|
|
59
59
|
const lastPage = nChildren - 1
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
const childArr = React.Children.toArray(children)
|
|
62
62
|
|
|
63
63
|
const WrapperComponent = renderPageWrapper || View
|
|
64
64
|
|
|
@@ -68,7 +68,7 @@ export const NewPager:React.FC<NewPagerProps> = (pagerProps) => {
|
|
|
68
68
|
return (
|
|
69
69
|
<View style={[variantStyles.wrapper, style]} >
|
|
70
70
|
{
|
|
71
|
-
|
|
71
|
+
childArr.map((child:NewPagerProps['children'][number], index) => {
|
|
72
72
|
const isActive = index === page
|
|
73
73
|
const isLast = index === lastPage
|
|
74
74
|
const isFirst = index === 0
|
|
@@ -96,9 +96,7 @@ export const NewPager:React.FC<NewPagerProps> = (pagerProps) => {
|
|
|
96
96
|
index,
|
|
97
97
|
page,
|
|
98
98
|
}
|
|
99
|
-
|
|
100
|
-
child,
|
|
101
|
-
})
|
|
99
|
+
|
|
102
100
|
const content = typeof child === 'function' ? child(pageProps) : child
|
|
103
101
|
|
|
104
102
|
const wrapperProps = {
|
|
@@ -2,6 +2,7 @@ import * as React from 'react'
|
|
|
2
2
|
import {
|
|
3
3
|
ComponentVariants,
|
|
4
4
|
IconPlaceholder,
|
|
5
|
+
onUpdate,
|
|
5
6
|
OverlayComposition,
|
|
6
7
|
OverlayStyles,
|
|
7
8
|
useDefaultComponentStyle,
|
|
@@ -13,7 +14,8 @@ import { Button } from './Button'
|
|
|
13
14
|
import { View } from './View'
|
|
14
15
|
import { StylesOf } from '../types/utility'
|
|
15
16
|
import { StyleSheet, ViewProps } from 'react-native'
|
|
16
|
-
import { AnimatedTouchable } from './Touchable'
|
|
17
|
+
import { AnimatedTouchable, Touchable } from './Touchable'
|
|
18
|
+
import { useAnimationState } from 'moti'
|
|
17
19
|
|
|
18
20
|
export type OverlayProps = ViewProps & {
|
|
19
21
|
title?: ReactNode
|
|
@@ -43,21 +45,28 @@ export const Overlay: React.FC<OverlayProps> = (overlayProps) => {
|
|
|
43
45
|
variants: variants as any,
|
|
44
46
|
}) as StylesOf<OverlayComposition>
|
|
45
47
|
|
|
46
|
-
const
|
|
48
|
+
const animation = useAnimationState({
|
|
49
|
+
visible: variantStyles['wrapper:visible'],
|
|
50
|
+
hidden: styles['wrapper:visible'],
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
onUpdate(() => {
|
|
54
|
+
animation.transitionTo(visible ? 'visible' : 'hidden')
|
|
55
|
+
}, [visible])
|
|
56
|
+
|
|
57
|
+
const viewStyles = [
|
|
47
58
|
variantStyles.wrapper,
|
|
48
59
|
styles.wrapper,
|
|
49
|
-
visible && variantStyles['wrapper:visible'],
|
|
50
|
-
visible && styles['wrapper:visible'],
|
|
51
60
|
]
|
|
52
61
|
|
|
53
62
|
return (
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
<View animated state={animation} style={viewStyles}>
|
|
64
|
+
<Touchable
|
|
65
|
+
|
|
66
|
+
feedbackVariant='none'
|
|
67
|
+
variants={['whole', 'full', 'absolute']}
|
|
68
|
+
{...props}
|
|
69
|
+
>
|
|
61
70
|
{(title || showClose) && (
|
|
62
71
|
<View style={variantStyles.header}>
|
|
63
72
|
<InputLabel style={variantStyles.title} label={title} />
|
|
@@ -71,7 +80,7 @@ export const Overlay: React.FC<OverlayProps> = (overlayProps) => {
|
|
|
71
80
|
)}
|
|
72
81
|
</View>
|
|
73
82
|
)}
|
|
74
|
-
</
|
|
75
|
-
</
|
|
83
|
+
</Touchable>
|
|
84
|
+
</View>
|
|
76
85
|
)
|
|
77
86
|
}
|