@codeleap/mobile 2.3.5 → 2.3.6
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 +3 -2
- package/src/components/ActionIcon/index.tsx +0 -32
- package/src/components/ActionIcon/styles.ts +0 -97
- package/src/components/ActivityIndicator/index.tsx +0 -50
- package/src/components/ActivityIndicator/styles.ts +0 -68
- package/src/components/Animated.tsx +0 -34
- package/src/components/AutoComplete/index.tsx +0 -163
- package/src/components/AutoComplete/styles.ts +0 -44
- package/src/components/Backdrop/index.tsx +0 -48
- package/src/components/Backdrop/styles.ts +0 -33
- package/src/components/Button/index.tsx +0 -155
- package/src/components/Button/styles.ts +0 -129
- package/src/components/Calendar/index.tsx +0 -65
- package/src/components/Calendar/style.ts +0 -35
- package/src/components/Calendar/types.ts +0 -102
- package/src/components/Checkbox/index.tsx +0 -91
- package/src/components/Checkbox/styles.ts +0 -81
- package/src/components/ContentView/index.tsx +0 -63
- package/src/components/ContentView/styles.ts +0 -24
- package/src/components/Drawer/index.tsx +0 -33
- package/src/components/Drawer/styles.ts +0 -43
- package/src/components/EmptyPlaceholder/index.tsx +0 -88
- package/src/components/EmptyPlaceholder/styles.ts +0 -58
- package/src/components/FileInput/index.tsx +0 -181
- package/src/components/FileInput/styles.ts +0 -15
- package/src/components/Grid/index.tsx +0 -117
- package/src/components/Grid/styles.ts +0 -11
- package/src/components/Icon/index.tsx +0 -69
- package/src/components/Icon/styles.ts +0 -57
- package/src/components/Image/index.tsx +0 -91
- package/src/components/Image/styles.ts +0 -20
- package/src/components/ImageView/Spotlight.tsx +0 -157
- package/src/components/ImageView/component.tsx +0 -38
- package/src/components/ImageView/index.ts +0 -2
- package/src/components/InputLabel/index.tsx +0 -38
- package/src/components/InputLabel/styles.ts +0 -19
- package/src/components/List/PaginationIndicator.tsx +0 -71
- package/src/components/List/index.tsx +0 -114
- package/src/components/List/styles.ts +0 -19
- package/src/components/Modal/index.tsx +0 -218
- package/src/components/Modal/styles.ts +0 -153
- package/src/components/MultiSelect/index.tsx +0 -138
- package/src/components/MultiSelect/styles.ts +0 -18
- package/src/components/MultiSelect/types.ts +0 -42
- package/src/components/Navigation/Navigation.tsx +0 -54
- package/src/components/Navigation/constants.ts +0 -8
- package/src/components/Navigation/index.tsx +0 -3
- package/src/components/Navigation/types.ts +0 -35
- package/src/components/Navigation/utils.tsx +0 -57
- package/src/components/Pager/index.tsx +0 -121
- package/src/components/Pager/styles.ts +0 -81
- package/src/components/RadioInput/index.tsx +0 -106
- package/src/components/RadioInput/styles.ts +0 -67
- package/src/components/Scroll/index.tsx +0 -124
- package/src/components/Scroll/styles.ts +0 -18
- package/src/components/Sections/index.tsx +0 -91
- package/src/components/SegmentedControl/index.tsx +0 -204
- package/src/components/SegmentedControl/styles.ts +0 -89
- package/src/components/Select/index.tsx +0 -167
- package/src/components/Select/styles.ts +0 -62
- package/src/components/Select/types.ts +0 -43
- package/src/components/Slider/Mark.tsx +0 -46
- package/src/components/Slider/Thumb.tsx +0 -29
- package/src/components/Slider/index.tsx +0 -130
- package/src/components/Slider/styles.ts +0 -76
- package/src/components/Slider/types.ts +0 -30
- package/src/components/Switch/index.tsx +0 -91
- package/src/components/Switch/styles.ts +0 -38
- package/src/components/Text/index.tsx +0 -123
- package/src/components/Text/styles.ts +0 -50
- package/src/components/TextInput/index.tsx +0 -319
- package/src/components/TextInput/styles.ts +0 -127
- package/src/components/Touchable/index.tsx +0 -174
- package/src/components/Touchable/styles.ts +0 -28
- package/src/components/View/index.tsx +0 -103
- package/src/components/View/styles.ts +0 -24
- package/src/components/components.ts +0 -42
- package/src/components/defaultStyles.ts +0 -62
- package/src/components/legacy/Modal/index.tsx +0 -163
- package/src/components/legacy/Modal/styles.ts +0 -125
- package/src/components/legacy/Pager/index.tsx +0 -242
- package/src/components/legacy/Pager/styles.ts +0 -51
- package/src/components/legacy/index.ts +0 -2
- package/src/modules/documentPicker.ts +0 -7
- package/src/modules/fastImage.ts +0 -2
- package/src/modules/imageCropPicker.d.ts +0 -497
- package/src/modules/index.d.ts +0 -682
- package/src/modules/reactNavigation.ts +0 -15
- package/src/modules/textInputMask.ts +0 -11
- package/src/modules/types/documentPicker.d.ts +0 -215
- package/src/modules/types/fileTypes.ts +0 -138
- package/src/modules/types/textInputMask.ts +0 -9
- package/src/types/index.ts +0 -1
- package/src/types/utility.ts +0 -9
- package/src/utils/KeyboardAware/context.tsx +0 -75
- package/src/utils/KeyboardAware/index.ts +0 -17
- package/src/utils/KeyboardAware/keyboardHooks.ts +0 -124
- package/src/utils/KeyboardAware/lib/KeyboardAwareFlatList.ts +0 -4
- package/src/utils/KeyboardAware/lib/KeyboardAwareHOC.tsx +0 -618
- package/src/utils/KeyboardAware/lib/KeyboardAwareInterface.ts +0 -13
- package/src/utils/KeyboardAware/lib/KeyboardAwareScrollView.ts +0 -6
- package/src/utils/KeyboardAware/lib/KeyboardAwareSectionList.ts +0 -6
- package/src/utils/KeyboardAware/types.ts +0 -159
- package/src/utils/ModalManager/components.tsx +0 -112
- package/src/utils/ModalManager/context.tsx +0 -260
- package/src/utils/ModalManager/index.ts +0 -16
- package/src/utils/OSAlert.ts +0 -180
- package/src/utils/PermissionManager/context.tsx +0 -302
- package/src/utils/PermissionManager/index.ts +0 -20
- package/src/utils/PermissionManager/types.ts +0 -24
- package/src/utils/hooks.ts +0 -163
- package/src/utils/index.ts +0 -11
- package/src/utils/input.ts +0 -51
- package/src/utils/misc.ts +0 -83
- package/src/utils/notifications.ts +0 -206
- package/src/utils/theme.ts +0 -58
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createDefaultVariantFactory } from '@codeleap/common'
|
|
2
|
-
import { ScrollComposition, ScrollStyles } from '../Scroll/styles'
|
|
3
|
-
|
|
4
|
-
export type ListComposition = ScrollComposition | 'separator'
|
|
5
|
-
|
|
6
|
-
const createListStyle = createDefaultVariantFactory<ListComposition>()
|
|
7
|
-
|
|
8
|
-
export const ListStyles = {
|
|
9
|
-
default: createListStyle((theme) => {
|
|
10
|
-
const defaultStyles = ScrollStyles.default(theme)
|
|
11
|
-
return {
|
|
12
|
-
...defaultStyles,
|
|
13
|
-
separator: {
|
|
14
|
-
width: '100%',
|
|
15
|
-
height: theme.spacing.value(1),
|
|
16
|
-
},
|
|
17
|
-
}
|
|
18
|
-
}),
|
|
19
|
-
}
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
import { View, ViewProps } from '../View'
|
|
3
|
-
import { Button, ButtonProps } from '../Button'
|
|
4
|
-
import { Scroll } from '../Scroll'
|
|
5
|
-
import {
|
|
6
|
-
ComponentVariants,
|
|
7
|
-
getNestedStylesByKey,
|
|
8
|
-
IconPlaceholder,
|
|
9
|
-
onUpdate,
|
|
10
|
-
PropsOf,
|
|
11
|
-
TypeGuards,
|
|
12
|
-
useDefaultComponentStyle,
|
|
13
|
-
} from '@codeleap/common'
|
|
14
|
-
import {
|
|
15
|
-
ModalComposition,
|
|
16
|
-
ModalStyles,
|
|
17
|
-
ModalParts,
|
|
18
|
-
} from './styles'
|
|
19
|
-
import { StyleSheet } from 'react-native'
|
|
20
|
-
import { StylesOf } from '../../types/utility'
|
|
21
|
-
|
|
22
|
-
import { useDynamicAnimation } from 'moti'
|
|
23
|
-
import { Backdrop } from '../Backdrop'
|
|
24
|
-
import { useBackButton, useStaticAnimationStyles } from '../../utils/hooks'
|
|
25
|
-
import { Text, TextProps } from '../Text'
|
|
26
|
-
import { Touchable } from '../Touchable'
|
|
27
|
-
import { GetKeyboardAwarePropsOptions } from '../../utils'
|
|
28
|
-
|
|
29
|
-
export * from './styles'
|
|
30
|
-
|
|
31
|
-
export type ModalProps = Omit<ViewProps, 'variants' | 'styles'> & {
|
|
32
|
-
variants?: ComponentVariants<typeof ModalStyles>['variants']
|
|
33
|
-
styles?: StylesOf<ModalComposition>
|
|
34
|
-
dismissOnBackdrop?: boolean
|
|
35
|
-
buttonProps?: ButtonProps
|
|
36
|
-
accessible?: boolean
|
|
37
|
-
showClose?: boolean
|
|
38
|
-
closable?: boolean
|
|
39
|
-
footer?: React.ReactNode
|
|
40
|
-
title?: React.ReactNode
|
|
41
|
-
debugName: string
|
|
42
|
-
closeIconName?: IconPlaceholder
|
|
43
|
-
visible: boolean
|
|
44
|
-
toggle?: () => void
|
|
45
|
-
zIndex?: number
|
|
46
|
-
scroll?: boolean
|
|
47
|
-
header?: React.ReactElement
|
|
48
|
-
closeOnHardwareBackPress?: boolean
|
|
49
|
-
renderHeader?: (props: ModalHeaderProps) => React.ReactElement
|
|
50
|
-
keyboardAware?: GetKeyboardAwarePropsOptions
|
|
51
|
-
scrollProps?: PropsOf<typeof Scroll>
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export type ModalHeaderProps = Omit<ModalProps, 'styles' | 'renderHeader'> & {
|
|
55
|
-
styles: {
|
|
56
|
-
wrapper: ViewProps['style']
|
|
57
|
-
title: TextProps['style']
|
|
58
|
-
closeButton: ButtonProps['styles']
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const DefaultHeader:React.FC<ModalHeaderProps> = (props) => {
|
|
63
|
-
const { styles, title = null, showClose = false, closable, debugName, closeIconName = 'close', toggle } = props
|
|
64
|
-
return <>
|
|
65
|
-
{(title || showClose) && (
|
|
66
|
-
<View style={styles.wrapper}>
|
|
67
|
-
{typeof title === 'string' ? (
|
|
68
|
-
<Text text={title} style={styles.title} />
|
|
69
|
-
) : (
|
|
70
|
-
title
|
|
71
|
-
)}
|
|
72
|
-
|
|
73
|
-
{(showClose && closable) && (
|
|
74
|
-
<Button
|
|
75
|
-
debugName={`${debugName} modal close button`}
|
|
76
|
-
icon={closeIconName as IconPlaceholder}
|
|
77
|
-
variants={['icon']}
|
|
78
|
-
onPress={toggle}
|
|
79
|
-
styles={styles.closeButton}
|
|
80
|
-
/>
|
|
81
|
-
)}
|
|
82
|
-
</View>
|
|
83
|
-
)}</>
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
87
|
-
const {
|
|
88
|
-
variants = [],
|
|
89
|
-
styles = {},
|
|
90
|
-
visible,
|
|
91
|
-
|
|
92
|
-
closable = true,
|
|
93
|
-
|
|
94
|
-
footer,
|
|
95
|
-
children,
|
|
96
|
-
toggle = () => null,
|
|
97
|
-
dismissOnBackdrop = true,
|
|
98
|
-
header = null,
|
|
99
|
-
debugName,
|
|
100
|
-
scroll = true,
|
|
101
|
-
renderHeader,
|
|
102
|
-
zIndex = null,
|
|
103
|
-
scrollProps = {},
|
|
104
|
-
closeOnHardwareBackPress = true,
|
|
105
|
-
...props
|
|
106
|
-
} = modalProps
|
|
107
|
-
|
|
108
|
-
const variantStyles = useDefaultComponentStyle('u:Modal', {
|
|
109
|
-
variants: variants as any,
|
|
110
|
-
transform: StyleSheet.flatten,
|
|
111
|
-
styles,
|
|
112
|
-
}) as ModalProps['styles']
|
|
113
|
-
|
|
114
|
-
function getStyles(key: ModalParts) {
|
|
115
|
-
const s = [
|
|
116
|
-
variantStyles[key],
|
|
117
|
-
styles[key],
|
|
118
|
-
]
|
|
119
|
-
|
|
120
|
-
return StyleSheet.flatten(s)
|
|
121
|
-
}
|
|
122
|
-
const buttonStyles = React.useMemo(() => getNestedStylesByKey('closeButton', variantStyles), [variantStyles])
|
|
123
|
-
|
|
124
|
-
const boxAnimationStates = useStaticAnimationStyles(variantStyles, ['box:hidden', 'box:visible'])
|
|
125
|
-
|
|
126
|
-
const boxAnimation = useDynamicAnimation(() => {
|
|
127
|
-
return visible ? boxAnimationStates['box:visible'] : boxAnimationStates['box:hidden']
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
onUpdate(() => {
|
|
131
|
-
boxAnimation.animateTo(visible ? boxAnimationStates['box:visible'] : boxAnimationStates['box:hidden'])
|
|
132
|
-
}, [visible])
|
|
133
|
-
const wrapperStyle = getStyles('wrapper')
|
|
134
|
-
|
|
135
|
-
const ScrollComponent = scroll ? Scroll : View
|
|
136
|
-
const scrollStyle = scroll ? getStyles('scroll') : getStyles('innerWrapper')
|
|
137
|
-
|
|
138
|
-
const headerProps:ModalHeaderProps = {
|
|
139
|
-
...modalProps,
|
|
140
|
-
styles: {
|
|
141
|
-
wrapper: getStyles('header'),
|
|
142
|
-
title: getStyles('title'),
|
|
143
|
-
closeButton: buttonStyles,
|
|
144
|
-
},
|
|
145
|
-
}
|
|
146
|
-
const Header = renderHeader || DefaultHeader
|
|
147
|
-
|
|
148
|
-
useBackButton(() => {
|
|
149
|
-
if (visible && closeOnHardwareBackPress) {
|
|
150
|
-
toggle()
|
|
151
|
-
return true
|
|
152
|
-
}
|
|
153
|
-
}, [visible, toggle, closeOnHardwareBackPress])
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<View
|
|
157
|
-
style={[wrapperStyle, { zIndex: TypeGuards.isNumber(zIndex) ? zIndex : wrapperStyle?.zIndex }]}
|
|
158
|
-
pointerEvents={visible ? 'auto' : 'none'}
|
|
159
|
-
>
|
|
160
|
-
|
|
161
|
-
<Backdrop visible={visible} debugName={`Modal ${debugName} backdrop`} styles={{
|
|
162
|
-
'wrapper:hidden': variantStyles['backdrop:hidden'],
|
|
163
|
-
'wrapper:visible': variantStyles['backdrop:visible'],
|
|
164
|
-
wrapper: variantStyles.backdrop,
|
|
165
|
-
}}
|
|
166
|
-
wrapperProps={{
|
|
167
|
-
transition: { ...variantStyles['backdrop:transition'] },
|
|
168
|
-
}}
|
|
169
|
-
/>
|
|
170
|
-
<ScrollComponent
|
|
171
|
-
style={scrollStyle}
|
|
172
|
-
contentContainerStyle={getStyles('scrollContent')}
|
|
173
|
-
keyboardAware= {{
|
|
174
|
-
adapt: 'marginBottom',
|
|
175
|
-
baseStyleProp: 'style',
|
|
176
|
-
animated: true,
|
|
177
|
-
enabled: visible,
|
|
178
|
-
enableOnAndroid: true,
|
|
179
|
-
}}
|
|
180
|
-
animated
|
|
181
|
-
{ ...scrollProps}
|
|
182
|
-
>
|
|
183
|
-
{dismissOnBackdrop &&
|
|
184
|
-
<Touchable
|
|
185
|
-
onPress={ closable ? toggle : (() => {})}
|
|
186
|
-
debounce={400}
|
|
187
|
-
debugName={'Modal backdrop touchable'}
|
|
188
|
-
style={variantStyles.backdropTouchable}
|
|
189
|
-
android_ripple={null}
|
|
190
|
-
noFeedback
|
|
191
|
-
/>}
|
|
192
|
-
|
|
193
|
-
<View
|
|
194
|
-
animated
|
|
195
|
-
state={boxAnimation}
|
|
196
|
-
style={getStyles('box')}
|
|
197
|
-
transition={{ ...variantStyles['box:transition'] }}
|
|
198
|
-
|
|
199
|
-
{...props}
|
|
200
|
-
>
|
|
201
|
-
|
|
202
|
-
{header ? header : <Header {...headerProps}/>}
|
|
203
|
-
|
|
204
|
-
<View style={getStyles('body')}>{children}</View>
|
|
205
|
-
{footer && (
|
|
206
|
-
<View style={getStyles('footer')}>
|
|
207
|
-
{typeof footer === 'string' ? <Text text={footer} /> : footer}
|
|
208
|
-
</View>
|
|
209
|
-
)}
|
|
210
|
-
</View>
|
|
211
|
-
|
|
212
|
-
</ScrollComponent>
|
|
213
|
-
</View>
|
|
214
|
-
|
|
215
|
-
)
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export default Modal
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
assignTextStyle,
|
|
3
|
-
ButtonComposition,
|
|
4
|
-
createDefaultVariantFactory,
|
|
5
|
-
includePresets,
|
|
6
|
-
} from '@codeleap/common'
|
|
7
|
-
|
|
8
|
-
export type AnimatableParts = 'box' | 'backdrop'
|
|
9
|
-
|
|
10
|
-
export type ModalParts =
|
|
11
|
-
| AnimatableParts
|
|
12
|
-
| 'wrapper'
|
|
13
|
-
| 'innerWrapper'
|
|
14
|
-
|
|
15
|
-
| 'scrollContent'
|
|
16
|
-
| 'scroll'
|
|
17
|
-
| 'body'
|
|
18
|
-
| 'footer'
|
|
19
|
-
| 'header'
|
|
20
|
-
| 'backdropTouchable'
|
|
21
|
-
| 'title'
|
|
22
|
-
| `closeButton${Capitalize<ButtonComposition>}`
|
|
23
|
-
|
|
24
|
-
export type ModalComposition =
|
|
25
|
-
| ModalParts
|
|
26
|
-
| `${AnimatableParts}:visible`
|
|
27
|
-
| `${AnimatableParts}:hidden`
|
|
28
|
-
| `${AnimatableParts}:transition`
|
|
29
|
-
|
|
30
|
-
const createModalStyle = createDefaultVariantFactory<ModalComposition>()
|
|
31
|
-
|
|
32
|
-
const presets = includePresets((style) => createModalStyle(() => ({ body: style })))
|
|
33
|
-
|
|
34
|
-
export const ModalStyles = {
|
|
35
|
-
|
|
36
|
-
...presets,
|
|
37
|
-
default: createModalStyle((theme) => {
|
|
38
|
-
const fullSize = {
|
|
39
|
-
...theme.presets.whole,
|
|
40
|
-
position: 'absolute',
|
|
41
|
-
width: theme.values.width,
|
|
42
|
-
height: theme.values.height,
|
|
43
|
-
maxHeight: theme.values.height,
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
wrapper: {
|
|
48
|
-
zIndex: 1,
|
|
49
|
-
height: theme.values.height,
|
|
50
|
-
width: theme.values.width,
|
|
51
|
-
...theme.presets.whole,
|
|
52
|
-
position: 'absolute',
|
|
53
|
-
...theme.presets.safeAreaTop(),
|
|
54
|
-
paddingBottom: theme.values.bottomNavHeight,
|
|
55
|
-
},
|
|
56
|
-
'box:transition': {
|
|
57
|
-
scale: {
|
|
58
|
-
duration: theme.values.transitions.modal.duration,
|
|
59
|
-
type: 'timing',
|
|
60
|
-
},
|
|
61
|
-
opacity: {
|
|
62
|
-
duration: theme.values.transitions.modal.duration,
|
|
63
|
-
type: 'timing',
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
'backdrop:transition': {
|
|
67
|
-
opacity: {
|
|
68
|
-
duration: theme.values.transitions.modal.duration,
|
|
69
|
-
type: 'timing',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
backdrop: {
|
|
73
|
-
|
|
74
|
-
backgroundColor: theme.colors.black,
|
|
75
|
-
...fullSize,
|
|
76
|
-
},
|
|
77
|
-
backdropTouchable: {
|
|
78
|
-
...fullSize,
|
|
79
|
-
},
|
|
80
|
-
'backdrop:visible': {
|
|
81
|
-
opacity: 0.5,
|
|
82
|
-
},
|
|
83
|
-
'backdrop:hidden': {
|
|
84
|
-
opacity: 0,
|
|
85
|
-
},
|
|
86
|
-
innerWrapper: {
|
|
87
|
-
...theme.presets.alignCenter,
|
|
88
|
-
...theme.presets.justifyCenter,
|
|
89
|
-
width: theme.values.width,
|
|
90
|
-
flex: 1,
|
|
91
|
-
},
|
|
92
|
-
scroll: {
|
|
93
|
-
width: theme.values.width,
|
|
94
|
-
height: theme.values.window.height,
|
|
95
|
-
maxHeight: theme.values.window.height,
|
|
96
|
-
},
|
|
97
|
-
scrollContent: {
|
|
98
|
-
...theme.presets.alignCenter,
|
|
99
|
-
...theme.presets.justifyCenter,
|
|
100
|
-
...theme.spacing.paddingVertical(2),
|
|
101
|
-
...theme.presets.fullWidth,
|
|
102
|
-
flex: 1,
|
|
103
|
-
},
|
|
104
|
-
box: {
|
|
105
|
-
width: '80%',
|
|
106
|
-
backgroundColor: theme.colors.background,
|
|
107
|
-
borderRadius: theme.borderRadius.medium,
|
|
108
|
-
...theme.spacing.padding(2),
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
'box:hidden': {
|
|
112
|
-
opacity: 0,
|
|
113
|
-
scale: 0.8,
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
'box:visible': {
|
|
117
|
-
opacity: 1,
|
|
118
|
-
scale: 1,
|
|
119
|
-
},
|
|
120
|
-
header: {
|
|
121
|
-
flexDirection: 'row',
|
|
122
|
-
...theme.presets.justifySpaceBetween,
|
|
123
|
-
...theme.presets.alignCenter,
|
|
124
|
-
},
|
|
125
|
-
closeButtonWrapper: {
|
|
126
|
-
alignSelf: 'center',
|
|
127
|
-
...theme.spacing.marginLeft('auto'),
|
|
128
|
-
},
|
|
129
|
-
title: {
|
|
130
|
-
...theme.presets.textCenter,
|
|
131
|
-
...assignTextStyle('h3')(theme).text,
|
|
132
|
-
...theme.spacing.paddingBottom(1),
|
|
133
|
-
flex: 1,
|
|
134
|
-
},
|
|
135
|
-
}
|
|
136
|
-
}),
|
|
137
|
-
popup: createModalStyle(() => ({})),
|
|
138
|
-
fullscreen: createModalStyle((theme) => ({
|
|
139
|
-
overlay: {
|
|
140
|
-
backgroundColor: theme.colors.background,
|
|
141
|
-
},
|
|
142
|
-
'overlay:visible': {
|
|
143
|
-
opacity: 1,
|
|
144
|
-
},
|
|
145
|
-
box: {
|
|
146
|
-
flex: 1,
|
|
147
|
-
borderRadius: 0,
|
|
148
|
-
width: theme.values.width,
|
|
149
|
-
height: theme.values.window.height,
|
|
150
|
-
...theme.presets.center,
|
|
151
|
-
},
|
|
152
|
-
})),
|
|
153
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { IconPlaceholder,
|
|
2
|
-
getNestedStylesByKey,
|
|
3
|
-
useDefaultComponentStyle,
|
|
4
|
-
TypeGuards } from '@codeleap/common'
|
|
5
|
-
import React, { useMemo } from 'react'
|
|
6
|
-
import { StyleSheet } from 'react-native'
|
|
7
|
-
import { List } from '../List'
|
|
8
|
-
import { TextInput } from '../TextInput'
|
|
9
|
-
import { MultiSelectProps } from './types'
|
|
10
|
-
import { ModalManager } from '../../utils'
|
|
11
|
-
import { MultiSelectStyles } from './styles'
|
|
12
|
-
import { SelectItem } from '../Select'
|
|
13
|
-
|
|
14
|
-
export * from './styles'
|
|
15
|
-
export const MultiSelect = <T extends string|number = string>(selectProps:MultiSelectProps<T>) => {
|
|
16
|
-
const {
|
|
17
|
-
value,
|
|
18
|
-
onValueChange,
|
|
19
|
-
label,
|
|
20
|
-
styles = {},
|
|
21
|
-
options,
|
|
22
|
-
style,
|
|
23
|
-
variants,
|
|
24
|
-
hideInput = false,
|
|
25
|
-
renderItem,
|
|
26
|
-
listProps,
|
|
27
|
-
placeholder = 'Select',
|
|
28
|
-
arrowIconName = 'selectArrow',
|
|
29
|
-
selectedIcon = 'multiSelectMarker',
|
|
30
|
-
inputProps = {},
|
|
31
|
-
clearable = false,
|
|
32
|
-
clearIconName = 'close',
|
|
33
|
-
validate = null,
|
|
34
|
-
...drawerProps
|
|
35
|
-
} = selectProps
|
|
36
|
-
|
|
37
|
-
const variantStyles = useDefaultComponentStyle<'u:MultiSelect', typeof MultiSelectStyles>('u:MultiSelect', {
|
|
38
|
-
transform: StyleSheet.flatten,
|
|
39
|
-
rootElement: 'inputWrapper',
|
|
40
|
-
styles,
|
|
41
|
-
variants,
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
const inputStyles = useMemo(
|
|
45
|
-
() => getNestedStylesByKey('input', variantStyles),
|
|
46
|
-
[variantStyles],
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
const close = () => drawerProps?.toggle?.()
|
|
50
|
-
|
|
51
|
-
const select = (itemValue) => {
|
|
52
|
-
const newVal = [...value]
|
|
53
|
-
|
|
54
|
-
if (newVal.includes(itemValue)) {
|
|
55
|
-
newVal.splice(newVal.indexOf(itemValue), 1)
|
|
56
|
-
} else {
|
|
57
|
-
newVal.push(itemValue)
|
|
58
|
-
}
|
|
59
|
-
onValueChange(newVal)
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const selectedLabel:string = useMemo(() => {
|
|
64
|
-
const current = options.filter(o => value.includes(o.value)).map(o => o.label)
|
|
65
|
-
|
|
66
|
-
const display = current?.join(', ') ?? placeholder
|
|
67
|
-
|
|
68
|
-
return TypeGuards.isString(display) ? display : ''
|
|
69
|
-
}, [value, placeholder, options])
|
|
70
|
-
|
|
71
|
-
const Item = renderItem || SelectItem
|
|
72
|
-
|
|
73
|
-
const renderListItem = ({ item }) => {
|
|
74
|
-
return <Item
|
|
75
|
-
isSelected={value.includes(item.value)}
|
|
76
|
-
item={item}
|
|
77
|
-
onPress={() => select(item.value)}
|
|
78
|
-
styles={variantStyles}
|
|
79
|
-
icon={selectedIcon as IconPlaceholder}
|
|
80
|
-
/>
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const isEmpty = value.length === 0
|
|
84
|
-
const showClearIcon = !isEmpty && clearable
|
|
85
|
-
const inputIcon = showClearIcon ? clearIconName : arrowIconName
|
|
86
|
-
|
|
87
|
-
const onPressInputIcon = () => {
|
|
88
|
-
if (showClearIcon) {
|
|
89
|
-
onValueChange([])
|
|
90
|
-
} else {
|
|
91
|
-
close?.()
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
return <>
|
|
96
|
-
{
|
|
97
|
-
!hideInput && (
|
|
98
|
-
<TextInput
|
|
99
|
-
caretHidden
|
|
100
|
-
value={selectedLabel}
|
|
101
|
-
rightIcon={{
|
|
102
|
-
icon: inputIcon as IconPlaceholder,
|
|
103
|
-
onPress: onPressInputIcon,
|
|
104
|
-
}}
|
|
105
|
-
editable={false}
|
|
106
|
-
touchableWrapper
|
|
107
|
-
wrapperProps={{
|
|
108
|
-
debugName: 'Select',
|
|
109
|
-
onPress: close,
|
|
110
|
-
}}
|
|
111
|
-
pointerEvents={'none'}
|
|
112
|
-
label={label}
|
|
113
|
-
debugName={'Select input'}
|
|
114
|
-
styles={inputStyles}
|
|
115
|
-
style={style}
|
|
116
|
-
validate={validate}
|
|
117
|
-
{...inputProps}
|
|
118
|
-
/>
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
<ModalManager.Drawer scroll={false} title={label} {...drawerProps} styles={variantStyles}>
|
|
123
|
-
<List<MultiSelectProps<any>['options']>
|
|
124
|
-
data={options}
|
|
125
|
-
style={variantStyles.list}
|
|
126
|
-
contentContainerStyle={variantStyles.listContent}
|
|
127
|
-
keyExtractor={(i) => i.value}
|
|
128
|
-
renderItem={renderListItem}
|
|
129
|
-
{...listProps}
|
|
130
|
-
/>
|
|
131
|
-
</ModalManager.Drawer>
|
|
132
|
-
|
|
133
|
-
</>
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export * from './styles'
|
|
137
|
-
export * from './types'
|
|
138
|
-
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createDefaultVariantFactory } from '@codeleap/common'
|
|
2
|
-
import { SelectComposition, SelectStyles } from '../Select'
|
|
3
|
-
type ItemStates = '' | ':selected'
|
|
4
|
-
export type MultiSelectComposition =
|
|
5
|
-
SelectComposition | `itemIcon${ItemStates}`
|
|
6
|
-
|
|
7
|
-
const createMultiSelectStyle = createDefaultVariantFactory<MultiSelectComposition>()
|
|
8
|
-
|
|
9
|
-
export const MultiSelectStyles = {
|
|
10
|
-
...SelectStyles,
|
|
11
|
-
default: createMultiSelectStyle((theme) => {
|
|
12
|
-
const defaultStyle = SelectStyles.default(theme)
|
|
13
|
-
return {
|
|
14
|
-
...defaultStyle,
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
}),
|
|
18
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ComponentVariants,
|
|
3
|
-
FormTypes,
|
|
4
|
-
IconPlaceholder,
|
|
5
|
-
} from '@codeleap/common'
|
|
6
|
-
import { StylesOf } from '../../types/utility'
|
|
7
|
-
import { DrawerProps } from '../Drawer'
|
|
8
|
-
import { FlatListProps } from '../List'
|
|
9
|
-
import { TextInputProps } from '../TextInput'
|
|
10
|
-
import { MultiSelectComposition, MultiSelectStyles } from './styles'
|
|
11
|
-
|
|
12
|
-
export type MultiSelectRenderFNProps<T> = {
|
|
13
|
-
styles: StylesOf<MultiSelectComposition>
|
|
14
|
-
onPress: () => void
|
|
15
|
-
isSelected?: boolean
|
|
16
|
-
item: FormTypes.Options<T>[number]
|
|
17
|
-
icon?: IconPlaceholder
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type MultiSelectRenderFN<T> = (props: MultiSelectRenderFNProps<T>) => JSX.Element
|
|
21
|
-
|
|
22
|
-
type MultiSelectDrawerProps = Omit<DrawerProps, 'variants' | 'styles'>
|
|
23
|
-
|
|
24
|
-
export type MultiSelectProps<T> = MultiSelectDrawerProps & {
|
|
25
|
-
value: T[]
|
|
26
|
-
placeholder?: FormTypes.Label
|
|
27
|
-
label?: FormTypes.Label
|
|
28
|
-
options?: FormTypes.Options<T>
|
|
29
|
-
onValueChange?: (value: T[]) => void
|
|
30
|
-
renderItem?: MultiSelectRenderFN<T>
|
|
31
|
-
styles?: StylesOf<MultiSelectComposition>
|
|
32
|
-
style?: any
|
|
33
|
-
arrowIconName?: IconPlaceholder
|
|
34
|
-
inputProps?: Partial<TextInputProps>
|
|
35
|
-
selectedIcon?: IconPlaceholder
|
|
36
|
-
hideInput?: boolean
|
|
37
|
-
listProps?: Partial<FlatListProps>
|
|
38
|
-
clearable?: boolean
|
|
39
|
-
clearIconName?: IconPlaceholder
|
|
40
|
-
validate?: TextInputProps['validate']
|
|
41
|
-
} & ComponentVariants<typeof MultiSelectStyles>
|
|
42
|
-
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import * as React from 'react'
|
|
3
|
-
import {
|
|
4
|
-
TypeGuards,
|
|
5
|
-
} from '@codeleap/common'
|
|
6
|
-
import { Icon } from '../Icon'
|
|
7
|
-
import { NavigationProps, NavigatorType, PropTypes, TNavigators } from './types'
|
|
8
|
-
import { Navigators } from './constants'
|
|
9
|
-
|
|
10
|
-
export const Navigation = <T extends NavigatorType>({ type, scenes, ...props }: NavigationProps<T>) => {
|
|
11
|
-
const NavigationComponent = Navigators[type] as TNavigators[T]
|
|
12
|
-
|
|
13
|
-
// console.log('render Navigation', { type, scenes, props, defaultProps })
|
|
14
|
-
|
|
15
|
-
return <NavigationComponent.Navigator {...props}>
|
|
16
|
-
{
|
|
17
|
-
Object.entries(scenes).map(([name, content], idx) => {
|
|
18
|
-
const isFunction = TypeGuards.isFunction(content)
|
|
19
|
-
|
|
20
|
-
let screenProps = {
|
|
21
|
-
name,
|
|
22
|
-
} as PropTypes[T]['Screen']
|
|
23
|
-
|
|
24
|
-
if (isFunction) {
|
|
25
|
-
screenProps.component = content
|
|
26
|
-
// console.log('Render NavigationScreen', { scenes, screenProps, content, isFunction }, 'PACKAGES')
|
|
27
|
-
} else {
|
|
28
|
-
screenProps.component = content?.component?.default || content?.component || content?.default
|
|
29
|
-
const nameParts = name.split('.')
|
|
30
|
-
const title = content?.title || nameParts[nameParts.length - 1] || name.replace('.', '')
|
|
31
|
-
|
|
32
|
-
screenProps = {
|
|
33
|
-
...screenProps,
|
|
34
|
-
options: (optionProps) => ({
|
|
35
|
-
title,
|
|
36
|
-
tabBarIcon: (style) => <Icon name={content?.icon} style={style}/>,
|
|
37
|
-
tabBarIconFocused: content?.iconFocused ? (style) => <Icon name={content?.iconFocused} style={style}/> : null,
|
|
38
|
-
...(TypeGuards.isFunction(content.options) ? content.options(optionProps) : content.options),
|
|
39
|
-
}),
|
|
40
|
-
}
|
|
41
|
-
// console.log('Render NavigationScreen loop', { scenes, screenProps, content, title, isFunction, props }, 'PACKAGES')
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
<NavigationComponent.Screen
|
|
47
|
-
key={idx}
|
|
48
|
-
{...screenProps}
|
|
49
|
-
/>
|
|
50
|
-
)
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
</NavigationComponent.Navigator>
|
|
54
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import { createBottomTabNavigator, createDrawerNavigator, createStackNavigator } from '../../modules/reactNavigation'
|
|
3
|
-
|
|
4
|
-
export const Navigators = {
|
|
5
|
-
Drawer: createDrawerNavigator(),
|
|
6
|
-
Stack: createStackNavigator(),
|
|
7
|
-
Tab: createBottomTabNavigator(),
|
|
8
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { IconPlaceholder } from '@codeleap/common'
|
|
2
|
-
import { Navigators } from './constants'
|
|
3
|
-
|
|
4
|
-
export type TNavigators = typeof Navigators
|
|
5
|
-
export type NavigatorType = keyof TNavigators
|
|
6
|
-
|
|
7
|
-
export type PropTypes = {
|
|
8
|
-
[P in NavigatorType] : {
|
|
9
|
-
Screen: Omit<React.ComponentPropsWithRef<TNavigators[P]['Screen']>, 'children'|'name'>
|
|
10
|
-
Navigator: Omit<React.ComponentPropsWithRef<TNavigators[P]['Navigator']>, 'children'|'name'>
|
|
11
|
-
Group: Omit<React.ComponentPropsWithRef<TNavigators[P]['Group']>, 'children'|'name'>
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export type SceneComponent<K extends NavigatorType> = PropTypes[K]['Screen']
|
|
15
|
-
export type SceneOptions<K extends NavigatorType> =
|
|
16
|
-
{ icon?: IconPlaceholder; default?:SceneComponent<K> } & PropTypes[K]['Screen']
|
|
17
|
-
export type Scene<K extends NavigatorType> = SceneComponent<K> | SceneOptions<K>
|
|
18
|
-
|
|
19
|
-
export type Scenes<K extends NavigatorType> = {
|
|
20
|
-
[x:string] : Scene<K>
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type SceneProps = any
|
|
24
|
-
|
|
25
|
-
export type NavigationProps<T extends NavigatorType> = {
|
|
26
|
-
type: T
|
|
27
|
-
scenes: Scenes<T>
|
|
28
|
-
} & PropTypes[T]['Navigator']
|
|
29
|
-
|
|
30
|
-
// export type NavigationStructure = {
|
|
31
|
-
// [module:string] : {
|
|
32
|
-
// scenes: Scenes,
|
|
33
|
-
|
|
34
|
-
// }
|
|
35
|
-
// }
|