@codeleap/mobile 3.24.3 → 4.0.0
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 +6 -4
- package/src/Registry.ts +52 -0
- package/src/components/ActionIcon/index.tsx +55 -37
- package/src/components/ActionIcon/styles.ts +2 -4
- package/src/components/ActionIcon/types.ts +15 -0
- package/src/components/ActivityIndicator/index.tsx +42 -64
- package/src/components/ActivityIndicator/styles.ts +1 -10
- package/src/components/ActivityIndicator/types.ts +9 -0
- package/src/components/Autocomplete/index.tsx +46 -54
- package/src/components/Autocomplete/styles.ts +2 -5
- package/src/components/Autocomplete/types.ts +13 -23
- package/src/components/Avatar/index.tsx +59 -71
- package/src/components/Avatar/styles.ts +1 -9
- package/src/components/Avatar/types.ts +23 -0
- package/src/components/AvatarGroup/index.tsx +30 -44
- package/src/components/AvatarGroup/styles.ts +0 -6
- package/src/components/AvatarGroup/types.ts +10 -0
- package/src/components/Backdrop/index.tsx +51 -34
- package/src/components/Backdrop/styles.ts +5 -10
- package/src/components/Backdrop/types.ts +14 -0
- package/src/components/Badge/index.tsx +36 -62
- package/src/components/Badge/styles.ts +3 -11
- package/src/components/Badge/types.ts +27 -0
- package/src/components/Button/index.tsx +55 -82
- package/src/components/Button/styles.ts +13 -14
- package/src/components/Button/types.ts +20 -0
- package/src/components/Calendar/index.tsx +35 -29
- package/src/components/Checkbox/index.tsx +43 -64
- package/src/components/Checkbox/styles.ts +1 -6
- package/src/components/Checkbox/types.ts +13 -0
- package/src/components/DatePickerModal/index.tsx +50 -65
- package/src/components/DatePickerModal/styles.ts +9 -10
- package/src/components/DatePickerModal/types.ts +36 -54
- package/src/components/EmptyPlaceholder/index.tsx +40 -63
- package/src/components/EmptyPlaceholder/styles.ts +0 -5
- package/src/components/EmptyPlaceholder/types.ts +21 -0
- package/src/components/FileInput/index.tsx +11 -49
- package/src/components/FileInput/types.ts +27 -0
- package/src/components/Grid/index.tsx +84 -116
- package/src/components/Grid/styles.ts +0 -5
- package/src/components/Grid/types.ts +20 -0
- package/src/components/Icon/index.tsx +44 -79
- package/src/components/Icon/styles.ts +0 -6
- package/src/components/Icon/types.ts +15 -0
- package/src/components/Image/index.tsx +58 -78
- package/src/components/Image/styles.ts +1 -6
- package/src/components/Image/types.ts +18 -0
- package/src/components/ImageView/Spotlight.tsx +1 -4
- package/src/components/ImageView/component.tsx +1 -2
- package/src/components/InputBase/index.tsx +33 -24
- package/src/components/InputBase/styles.ts +66 -75
- package/src/components/InputBase/types.ts +3 -4
- package/src/components/InputBase/utils.ts +6 -4
- package/src/components/List/index.tsx +99 -151
- package/src/components/List/styles.ts +0 -6
- package/src/components/List/types.ts +41 -0
- package/src/components/LoadingOverlay/index.tsx +42 -29
- package/src/components/LoadingOverlay/styles.ts +7 -7
- package/src/components/LoadingOverlay/types.ts +9 -0
- package/src/components/Modal/index.tsx +80 -127
- package/src/components/Modal/styles.ts +0 -8
- package/src/components/Modal/types.ts +41 -0
- package/src/components/Navigation/Navigation.tsx +1 -0
- package/src/components/Navigation/types.ts +2 -9
- package/src/components/NumberIncrement/index.tsx +50 -60
- package/src/components/NumberIncrement/styles.ts +0 -5
- package/src/components/NumberIncrement/types.ts +32 -39
- package/src/components/Pager/index.tsx +42 -94
- package/src/components/Pager/styles.ts +1 -13
- package/src/components/Pager/types.ts +37 -0
- package/src/components/PaginationIndicator/index.tsx +51 -0
- package/src/components/PaginationIndicator/styles.ts +3 -0
- package/src/components/PaginationIndicator/types.ts +10 -0
- package/src/components/RadioInput/index.tsx +32 -57
- package/src/components/RadioInput/styles.ts +5 -7
- package/src/components/RadioInput/types.ts +31 -0
- package/src/components/RefreshControl/index.tsx +39 -19
- package/src/components/RefreshControl/styles.ts +1 -6
- package/src/components/RefreshControl/types.ts +9 -0
- package/src/components/Scroll/index.tsx +89 -105
- package/src/components/Scroll/styles.ts +0 -5
- package/src/components/Scroll/types.ts +21 -0
- package/src/components/SearchInput/index.tsx +90 -0
- package/src/components/Sections/index.tsx +111 -161
- package/src/components/Sections/styles.ts +0 -5
- package/src/components/Sections/types.ts +39 -0
- package/src/components/SegmentedControl/Option.tsx +46 -31
- package/src/components/SegmentedControl/index.tsx +86 -121
- package/src/components/SegmentedControl/styles.ts +15 -22
- package/src/components/SegmentedControl/types.ts +31 -0
- package/src/components/Select/index.tsx +71 -82
- package/src/components/Select/styles.ts +3 -5
- package/src/components/Select/types.ts +20 -25
- package/src/components/Slider/index.tsx +58 -43
- package/src/components/Slider/styles.ts +15 -6
- package/src/components/Slider/types.ts +9 -14
- package/src/components/Switch/index.tsx +43 -56
- package/src/components/Switch/styles.ts +1 -7
- package/src/components/Switch/types.ts +12 -0
- package/src/components/Text/index.tsx +56 -52
- package/src/components/Text/styles.ts +1 -7
- package/src/components/Text/types.ts +18 -0
- package/src/components/TextInput/index.tsx +49 -162
- package/src/components/TextInput/styles.ts +2 -8
- package/src/components/TextInput/types.ts +23 -0
- package/src/components/Touchable/index.tsx +44 -87
- package/src/components/Touchable/styles.ts +0 -9
- package/src/components/Touchable/types.ts +27 -0
- package/src/components/View/index.tsx +23 -92
- package/src/components/View/styles.ts +0 -6
- package/src/components/View/types.ts +13 -0
- package/src/components/components.ts +2 -6
- package/src/hooks/index.ts +13 -0
- package/src/index.ts +2 -0
- package/src/modules/PressableRipple/type.ts +1 -0
- package/src/utils/KeyboardAware/context.tsx +0 -2
- package/src/utils/KeyboardAware/keyboardHooks.ts +1 -2
- package/src/utils/ModalManager/components.tsx +1 -30
- package/src/utils/ModalManager/context.tsx +4 -4
- package/src/utils/ModalManager/index.ts +1 -4
- package/src/utils/hooks.ts +12 -1
- package/src/components/Calendar/style.ts +0 -6
- package/src/components/ContentView/index.tsx +0 -63
- package/src/components/ContentView/styles.ts +0 -8
- package/src/components/Drawer/index.tsx +0 -28
- package/src/components/Drawer/styles.ts +0 -8
- package/src/components/FileInput/styles.ts +0 -8
- package/src/components/InputLabel/index.tsx +0 -38
- package/src/components/InputLabel/styles.ts +0 -7
- package/src/components/List/PaginationIndicator.tsx +0 -54
- package/src/components/defaultStyles.ts +0 -77
|
@@ -1,72 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { View
|
|
3
|
-
import { ButtonProps } from '../Button'
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View } from '../View'
|
|
4
3
|
import { Scroll } from '../Scroll'
|
|
5
|
-
import {
|
|
6
|
-
ComponentVariants,
|
|
7
|
-
getNestedStylesByKey,
|
|
8
|
-
IconPlaceholder,
|
|
9
|
-
PropsOf,
|
|
10
|
-
TypeGuards,
|
|
11
|
-
useDefaultComponentStyle,
|
|
12
|
-
useRef,
|
|
13
|
-
useCodeleapContext,
|
|
14
|
-
} from '@codeleap/common'
|
|
15
|
-
import {
|
|
16
|
-
ModalComposition,
|
|
17
|
-
ModalPresets,
|
|
18
|
-
ModalParts,
|
|
19
|
-
} from './styles'
|
|
20
|
-
import { ScrollView, StyleSheet } from 'react-native'
|
|
21
|
-
import { StylesOf } from '../../types/utility'
|
|
22
|
-
|
|
4
|
+
import { TypeGuards } from '@codeleap/common'
|
|
23
5
|
import { Backdrop } from '../Backdrop'
|
|
24
6
|
import { useAnimatedVariantStyles, useBackButton } from '../../utils/hooks'
|
|
25
|
-
import { Text
|
|
7
|
+
import { Text } from '../Text'
|
|
26
8
|
import { Touchable } from '../Touchable'
|
|
27
9
|
import { ActionIcon } from '../ActionIcon'
|
|
28
10
|
import { useState } from 'react'
|
|
11
|
+
import { ModalHeaderProps, ModalProps } from './types'
|
|
12
|
+
import { AnyRecord, AppIcon, useNestedStylesByKey, IJSX, StyledComponentProps, useTheme, AppTheme, Theme } from '@codeleap/styles'
|
|
13
|
+
import { MobileStyleRegistry } from '../../Registry'
|
|
14
|
+
import { useStylesFor } from '../../hooks'
|
|
29
15
|
|
|
30
16
|
export * from './styles'
|
|
31
|
-
|
|
32
|
-
export type ModalProps = Omit<ViewProps, 'variants' | 'styles'> & {
|
|
33
|
-
variants?: ComponentVariants<typeof ModalPresets>['variants']
|
|
34
|
-
styles?: StylesOf<ModalComposition>
|
|
35
|
-
dismissOnBackdrop?: boolean
|
|
36
|
-
buttonProps?: ButtonProps
|
|
37
|
-
accessible?: boolean
|
|
38
|
-
showClose?: boolean
|
|
39
|
-
closable?: boolean
|
|
40
|
-
footer?: React.ReactNode
|
|
41
|
-
title?: React.ReactNode
|
|
42
|
-
debugName: string
|
|
43
|
-
closeIconName?: IconPlaceholder
|
|
44
|
-
visible: boolean
|
|
45
|
-
toggle?: () => void
|
|
46
|
-
zIndex?: number
|
|
47
|
-
description?: React.ReactElement
|
|
48
|
-
scroll?: boolean
|
|
49
|
-
header?: React.ReactElement
|
|
50
|
-
closeOnHardwareBackPress?: boolean
|
|
51
|
-
renderHeader?: (props: ModalHeaderProps) => React.ReactElement
|
|
52
|
-
keyboardAware?: boolean
|
|
53
|
-
scrollProps?: PropsOf<typeof Scroll, 'ref'>
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export type ModalHeaderProps = Omit<ModalProps, 'styles' | 'renderHeader'> & {
|
|
57
|
-
styles: {
|
|
58
|
-
wrapper: ViewProps['style']
|
|
59
|
-
titleWrapper: ViewProps['style']
|
|
60
|
-
title: TextProps['style']
|
|
61
|
-
description: TextProps['style']
|
|
62
|
-
closeButton: ButtonProps['styles']
|
|
63
|
-
}
|
|
64
|
-
description?: React.ReactElement
|
|
65
|
-
}
|
|
17
|
+
export * from './types'
|
|
66
18
|
|
|
67
19
|
const DefaultHeader = (props: ModalHeaderProps) => {
|
|
68
20
|
const {
|
|
69
21
|
styles,
|
|
22
|
+
buttonStyles,
|
|
70
23
|
title = null,
|
|
71
24
|
showClose = false,
|
|
72
25
|
description = null,
|
|
@@ -74,9 +27,10 @@ const DefaultHeader = (props: ModalHeaderProps) => {
|
|
|
74
27
|
closeIconName = 'x',
|
|
75
28
|
toggle,
|
|
76
29
|
} = props
|
|
30
|
+
|
|
77
31
|
return <>
|
|
78
32
|
{(title || showClose || description) && (
|
|
79
|
-
<View style={styles.
|
|
33
|
+
<View style={styles.header}>
|
|
80
34
|
<View style={styles.titleWrapper}>
|
|
81
35
|
{TypeGuards.isString(title) ? (
|
|
82
36
|
<Text text={title} style={styles.title} />
|
|
@@ -84,14 +38,14 @@ const DefaultHeader = (props: ModalHeaderProps) => {
|
|
|
84
38
|
title
|
|
85
39
|
)}
|
|
86
40
|
|
|
87
|
-
{(showClose && closable)
|
|
41
|
+
{(showClose && closable) ? (
|
|
88
42
|
<ActionIcon
|
|
89
43
|
debugName={`${debugName} modal close button`}
|
|
90
|
-
icon={closeIconName as
|
|
44
|
+
icon={closeIconName as AppIcon}
|
|
91
45
|
onPress={toggle}
|
|
92
|
-
|
|
46
|
+
style={buttonStyles}
|
|
93
47
|
/>
|
|
94
|
-
)}
|
|
48
|
+
) : null}
|
|
95
49
|
</View>
|
|
96
50
|
|
|
97
51
|
{TypeGuards.isString(description) ? (
|
|
@@ -100,51 +54,39 @@ const DefaultHeader = (props: ModalHeaderProps) => {
|
|
|
100
54
|
description
|
|
101
55
|
)}
|
|
102
56
|
</View>
|
|
103
|
-
)}
|
|
57
|
+
)}
|
|
58
|
+
</>
|
|
104
59
|
}
|
|
105
60
|
|
|
106
61
|
export const Modal = (modalProps: ModalProps) => {
|
|
107
62
|
const {
|
|
108
|
-
variants = [],
|
|
109
|
-
styles = {},
|
|
110
63
|
visible,
|
|
111
|
-
|
|
112
|
-
closable = true,
|
|
113
|
-
|
|
64
|
+
closable,
|
|
114
65
|
footer,
|
|
115
66
|
children,
|
|
116
67
|
toggle = () => null,
|
|
117
|
-
dismissOnBackdrop
|
|
68
|
+
dismissOnBackdrop,
|
|
118
69
|
header = null,
|
|
119
70
|
debugName,
|
|
120
|
-
scroll
|
|
71
|
+
scroll,
|
|
121
72
|
renderHeader,
|
|
122
73
|
zIndex = null,
|
|
123
74
|
scrollProps = {},
|
|
124
|
-
closeOnHardwareBackPress
|
|
75
|
+
closeOnHardwareBackPress,
|
|
76
|
+
style,
|
|
125
77
|
...props
|
|
126
78
|
} = {
|
|
127
79
|
...Modal.defaultProps,
|
|
128
80
|
...modalProps,
|
|
129
81
|
}
|
|
82
|
+
|
|
83
|
+
const themeValues = useTheme(store => (store.current as AppTheme<Theme>)?.values)
|
|
84
|
+
|
|
130
85
|
const [modalHeight, setModalHeight] = useState(0)
|
|
131
|
-
const { Theme } = useCodeleapContext()
|
|
132
86
|
|
|
133
|
-
const
|
|
134
|
-
variants: variants as any,
|
|
135
|
-
transform: StyleSheet.flatten,
|
|
136
|
-
styles,
|
|
137
|
-
}) as ModalProps['styles']
|
|
138
|
-
const scrollRef = useRef<ScrollView>(null)
|
|
139
|
-
function getStyles(key: ModalParts) {
|
|
140
|
-
const s = [
|
|
141
|
-
variantStyles[key],
|
|
142
|
-
styles[key],
|
|
143
|
-
]
|
|
87
|
+
const styles = useStylesFor(Modal.styleRegistryName, style)
|
|
144
88
|
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
const buttonStyles = React.useMemo(() => getNestedStylesByKey('closeButton', variantStyles), [variantStyles])
|
|
89
|
+
const buttonStyles = useNestedStylesByKey('closeButton', styles)
|
|
148
90
|
|
|
149
91
|
const boxAnimationStyles = useAnimatedVariantStyles({
|
|
150
92
|
updater: (states) => {
|
|
@@ -152,31 +94,24 @@ export const Modal = (modalProps: ModalProps) => {
|
|
|
152
94
|
return visible ? states['box:visible'] : states['box:hidden']
|
|
153
95
|
},
|
|
154
96
|
animatedProperties: ['box:hidden', 'box:visible'],
|
|
155
|
-
variantStyles,
|
|
156
|
-
transition:
|
|
97
|
+
variantStyles: styles,
|
|
98
|
+
transition: styles['box:transition'],
|
|
157
99
|
dependencies: [visible],
|
|
158
100
|
})
|
|
159
101
|
|
|
160
|
-
const wrapperStyle = getStyles('wrapper')
|
|
161
|
-
|
|
162
102
|
const ScrollComponent = scroll ? Scroll : View
|
|
163
|
-
const scrollStyle = scroll ?
|
|
103
|
+
const scrollStyle = scroll ? styles?.scroll : styles?.innerWrapper
|
|
164
104
|
|
|
165
|
-
const heightThreshold =
|
|
166
|
-
const topSpacing = modalHeight > heightThreshold ?
|
|
105
|
+
const heightThreshold = themeValues?.height * 0.75
|
|
106
|
+
const topSpacing = modalHeight > heightThreshold ? styles?.topSpacing : 0
|
|
167
107
|
|
|
168
108
|
const headerProps: ModalHeaderProps = {
|
|
169
|
-
|
|
170
109
|
...modalProps,
|
|
171
110
|
closable,
|
|
172
|
-
styles
|
|
173
|
-
|
|
174
|
-
title: getStyles('title'),
|
|
175
|
-
description: getStyles('description'),
|
|
176
|
-
closeButton: buttonStyles,
|
|
177
|
-
titleWrapper: getStyles('titleWrapper'),
|
|
178
|
-
},
|
|
111
|
+
styles,
|
|
112
|
+
buttonStyles,
|
|
179
113
|
}
|
|
114
|
+
|
|
180
115
|
const Header = renderHeader || DefaultHeader
|
|
181
116
|
|
|
182
117
|
useBackButton(() => {
|
|
@@ -194,65 +129,83 @@ export const Modal = (modalProps: ModalProps) => {
|
|
|
194
129
|
|
|
195
130
|
return (
|
|
196
131
|
<View
|
|
197
|
-
style={[
|
|
198
|
-
|
|
199
|
-
|
|
132
|
+
style={[
|
|
133
|
+
styles?.wrapper,
|
|
134
|
+
// @ts-expect-error
|
|
135
|
+
{ zIndex: TypeGuards.isNumber(zIndex) ? zIndex : styles?.wrapper?.zIndex, ...topSpacing }
|
|
136
|
+
]}
|
|
200
137
|
pointerEvents={visible ? 'auto' : 'none'}
|
|
201
138
|
>
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
139
|
+
<Backdrop
|
|
140
|
+
visible={visible}
|
|
141
|
+
debugName={`Modal ${debugName} backdrop`}
|
|
142
|
+
style={{
|
|
143
|
+
'wrapper:hidden': styles['backdrop:hidden'],
|
|
144
|
+
'wrapper:visible': styles['backdrop:visible'],
|
|
145
|
+
'wrapper': styles?.backdrop,
|
|
146
|
+
}}
|
|
208
147
|
wrapperProps={{
|
|
209
|
-
|
|
148
|
+
// @ts-expect-error
|
|
149
|
+
transition: styles['backdrop:transition'],
|
|
210
150
|
}}
|
|
211
151
|
/>
|
|
152
|
+
|
|
212
153
|
<ScrollComponent
|
|
213
|
-
|
|
214
|
-
contentContainerStyle={getStyles('scrollContent')}
|
|
154
|
+
contentContainerStyle={styles?.scrollContent}
|
|
215
155
|
showsVerticalScrollIndicator={false}
|
|
216
156
|
keyboardAware
|
|
217
157
|
animated
|
|
218
|
-
|
|
219
158
|
{...scrollProps}
|
|
159
|
+
style={scrollStyle}
|
|
220
160
|
>
|
|
221
|
-
{dismissOnBackdrop
|
|
161
|
+
{dismissOnBackdrop ? (
|
|
222
162
|
<Touchable
|
|
223
163
|
onPress={closable && visible ? toggle : (() => { })}
|
|
224
164
|
debounce={400}
|
|
225
165
|
debugName={'Modal backdrop touchable'}
|
|
226
|
-
style={
|
|
166
|
+
style={styles?.backdropTouchable}
|
|
227
167
|
android_ripple={null}
|
|
228
168
|
noFeedback
|
|
229
|
-
/>}
|
|
169
|
+
/>) : null}
|
|
230
170
|
|
|
231
171
|
<View
|
|
232
172
|
animated
|
|
233
|
-
|
|
173
|
+
animatedStyle={boxAnimationStyles}
|
|
234
174
|
{...props}
|
|
235
175
|
onLayout={onModalLayout}
|
|
176
|
+
style={styles?.box}
|
|
236
177
|
>
|
|
237
|
-
|
|
238
178
|
{header ? header : <Header {...headerProps} />}
|
|
239
179
|
|
|
240
|
-
<View style={
|
|
241
|
-
|
|
242
|
-
|
|
180
|
+
<View style={styles?.body}>{children}</View>
|
|
181
|
+
|
|
182
|
+
{footer ? (
|
|
183
|
+
<View style={styles?.footer}>
|
|
243
184
|
{typeof footer === 'string' ? <Text text={footer} /> : footer}
|
|
244
185
|
</View>
|
|
245
|
-
)}
|
|
186
|
+
) : null}
|
|
246
187
|
</View>
|
|
247
|
-
|
|
248
188
|
</ScrollComponent>
|
|
249
189
|
</View >
|
|
250
|
-
|
|
251
190
|
)
|
|
252
191
|
}
|
|
253
192
|
|
|
254
|
-
Modal.
|
|
255
|
-
|
|
193
|
+
Modal.styleRegistryName = 'Modal'
|
|
194
|
+
Modal.elements = ['box', 'backdrop', 'innerWrapper', 'scroll', 'body', 'footer', 'header', 'title', 'description', 'closeButton', 'topSpacing']
|
|
195
|
+
Modal.rootElement = 'wrapper'
|
|
196
|
+
|
|
197
|
+
Modal.withVariantTypes = <S extends AnyRecord>(styles: S) => {
|
|
198
|
+
return Modal as (props: StyledComponentProps<ModalProps, typeof styles>) => IJSX
|
|
256
199
|
}
|
|
257
200
|
|
|
201
|
+
Modal.defaultProps = {
|
|
202
|
+
closeIconName: 'close' as AppIcon,
|
|
203
|
+
closable: true,
|
|
204
|
+
dismissOnBackdrop: true,
|
|
205
|
+
scroll: true,
|
|
206
|
+
closeOnHardwareBackPress: true,
|
|
207
|
+
} as Partial<ModalProps>
|
|
208
|
+
|
|
209
|
+
MobileStyleRegistry.registerComponent(Modal)
|
|
210
|
+
|
|
258
211
|
export default Modal
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createDefaultVariantFactory,
|
|
3
|
-
includePresets,
|
|
4
|
-
} from '@codeleap/common'
|
|
5
1
|
import { ActionIconComposition } from '../ActionIcon'
|
|
6
2
|
|
|
7
3
|
export type AnimatableParts = 'box' | 'backdrop'
|
|
@@ -27,7 +23,3 @@ export type ModalComposition =
|
|
|
27
23
|
| `${AnimatableParts}:visible`
|
|
28
24
|
| `${AnimatableParts}:hidden`
|
|
29
25
|
| `${AnimatableParts}:transition`
|
|
30
|
-
|
|
31
|
-
const createModalStyle = createDefaultVariantFactory<ModalComposition>()
|
|
32
|
-
|
|
33
|
-
export const ModalPresets = includePresets((style) => createModalStyle(() => ({ body: style })))
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PropsOf } from '@codeleap/common'
|
|
2
|
+
import { AppIcon, ICSS, StyledProp } from '@codeleap/styles'
|
|
3
|
+
import { ButtonProps } from '../Button'
|
|
4
|
+
import { Scroll } from '../Scroll'
|
|
5
|
+
import { ViewProps } from '../View'
|
|
6
|
+
import { ModalComposition } from './styles'
|
|
7
|
+
|
|
8
|
+
export type ModalProps =
|
|
9
|
+
Omit<ViewProps, 'style'> &
|
|
10
|
+
{
|
|
11
|
+
dismissOnBackdrop?: boolean
|
|
12
|
+
buttonProps?: ButtonProps
|
|
13
|
+
accessible?: boolean
|
|
14
|
+
showClose?: boolean
|
|
15
|
+
closable?: boolean
|
|
16
|
+
footer?: React.ReactNode
|
|
17
|
+
title?: React.ReactNode
|
|
18
|
+
debugName?: string
|
|
19
|
+
closeIconName?: AppIcon
|
|
20
|
+
visible?: boolean
|
|
21
|
+
toggle?: () => void
|
|
22
|
+
zIndex?: number
|
|
23
|
+
description?: React.ReactElement
|
|
24
|
+
scroll?: boolean
|
|
25
|
+
header?: React.ReactElement
|
|
26
|
+
closeOnHardwareBackPress?: boolean
|
|
27
|
+
renderHeader?: (props: ModalHeaderProps) => React.ReactElement
|
|
28
|
+
keyboardAware?: boolean
|
|
29
|
+
scrollProps?: PropsOf<typeof Scroll, 'ref'>
|
|
30
|
+
style?: StyledProp<ModalComposition>
|
|
31
|
+
id?: string
|
|
32
|
+
absolute?: boolean
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type ModalHeaderProps =
|
|
36
|
+
Omit<ModalProps, 'renderHeader'> &
|
|
37
|
+
{
|
|
38
|
+
styles: Record<ModalComposition, ICSS>
|
|
39
|
+
buttonStyles: any
|
|
40
|
+
description?: React.ReactElement
|
|
41
|
+
}
|
|
@@ -34,6 +34,7 @@ export const Navigation = <T extends NavigatorType>({ type, scenes, ...props }:
|
|
|
34
34
|
options: (optionProps) => ({
|
|
35
35
|
title,
|
|
36
36
|
tabBarIcon: (style) => <Icon name={content?.icon} style={style}/>,
|
|
37
|
+
tabIcon: content?.icon,
|
|
37
38
|
tabBarIconFocused: content?.iconFocused ? (style) => <Icon name={content?.iconFocused} style={style}/> : null,
|
|
38
39
|
...(TypeGuards.isFunction(content.options) ? content.options(optionProps) : content.options),
|
|
39
40
|
}),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppIcon } from '@codeleap/styles'
|
|
2
2
|
import { Navigators } from './constants'
|
|
3
3
|
|
|
4
4
|
export type TNavigators = typeof Navigators
|
|
@@ -13,7 +13,7 @@ export type PropTypes = {
|
|
|
13
13
|
}
|
|
14
14
|
export type SceneComponent<K extends NavigatorType> = PropTypes[K]['Screen']
|
|
15
15
|
export type SceneOptions<K extends NavigatorType> =
|
|
16
|
-
{ icon?:
|
|
16
|
+
{ icon?: AppIcon; default?:SceneComponent<K> } & PropTypes[K]['Screen']
|
|
17
17
|
export type Scene<K extends NavigatorType> = SceneComponent<K> | SceneOptions<K>
|
|
18
18
|
|
|
19
19
|
export type Scenes<K extends NavigatorType> = {
|
|
@@ -26,10 +26,3 @@ export type NavigationProps<T extends NavigatorType> = {
|
|
|
26
26
|
type: T
|
|
27
27
|
scenes: Scenes<T>
|
|
28
28
|
} & PropTypes[T]['Navigator']
|
|
29
|
-
|
|
30
|
-
// export type NavigationStructure = {
|
|
31
|
-
// [module:string] : {
|
|
32
|
-
// scenes: Scenes,
|
|
33
|
-
|
|
34
|
-
// }
|
|
35
|
-
// }
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
useDefaultComponentStyle,
|
|
4
|
-
TypeGuards,
|
|
5
|
-
useState,
|
|
6
|
-
useRef,
|
|
7
|
-
useValidate,
|
|
8
|
-
IconPlaceholder,
|
|
9
|
-
} from '@codeleap/common'
|
|
1
|
+
import React, { useState, useRef } from 'react'
|
|
2
|
+
import { TypeGuards, useValidate } from '@codeleap/common'
|
|
10
3
|
import { forwardRef, useImperativeHandle } from 'react'
|
|
11
|
-
import { NumberIncrementPresets } from './styles'
|
|
12
4
|
import { InputBase, selectInputBaseProps } from '../InputBase'
|
|
13
5
|
import { Text } from '../Text'
|
|
14
6
|
import { MaskedTextInput } from '../../modules/textInputMask'
|
|
@@ -16,6 +8,9 @@ import { TextInput as NativeTextInput, TextInputProps as NativeTextInputProps, N
|
|
|
16
8
|
import { Touchable } from '../Touchable'
|
|
17
9
|
import { useActionValidate } from './utils'
|
|
18
10
|
import { NumberIncrementProps } from './types'
|
|
11
|
+
import { AnyRecord, AppIcon, IJSX, StyledComponentProps, StyledComponentWithProps } from '@codeleap/styles'
|
|
12
|
+
import { MobileStyleRegistry } from '../../Registry'
|
|
13
|
+
import { useStylesFor } from '../../hooks'
|
|
19
14
|
|
|
20
15
|
export * from './styles'
|
|
21
16
|
export * from './types'
|
|
@@ -30,22 +25,6 @@ const defaultParseValue = (_value: string) => {
|
|
|
30
25
|
return parseFloat(parsedValue)
|
|
31
26
|
}
|
|
32
27
|
|
|
33
|
-
const defaultProps: Partial<NumberIncrementProps> = {
|
|
34
|
-
max: MAX_VALID_DIGITS,
|
|
35
|
-
min: 0,
|
|
36
|
-
step: 1,
|
|
37
|
-
editable: true,
|
|
38
|
-
separator: null,
|
|
39
|
-
formatter: null,
|
|
40
|
-
parseValue: defaultParseValue,
|
|
41
|
-
delimiter: null,
|
|
42
|
-
mask: null,
|
|
43
|
-
masking: null,
|
|
44
|
-
timeoutActionFocus: 300,
|
|
45
|
-
actionPressAutoFocus: true,
|
|
46
|
-
actionDebounce: null,
|
|
47
|
-
}
|
|
48
|
-
|
|
49
28
|
export const NumberIncrement = forwardRef<NativeTextInput, NumberIncrementProps>((props, inputRef) => {
|
|
50
29
|
const {
|
|
51
30
|
inputBaseProps,
|
|
@@ -56,9 +35,7 @@ export const NumberIncrement = forwardRef<NativeTextInput, NumberIncrementProps>
|
|
|
56
35
|
})
|
|
57
36
|
|
|
58
37
|
const {
|
|
59
|
-
|
|
60
|
-
style = {},
|
|
61
|
-
styles = {},
|
|
38
|
+
style,
|
|
62
39
|
value,
|
|
63
40
|
disabled,
|
|
64
41
|
onChangeText,
|
|
@@ -127,34 +104,29 @@ export const NumberIncrement = forwardRef<NativeTextInput, NumberIncrementProps>
|
|
|
127
104
|
return false
|
|
128
105
|
}, [value])
|
|
129
106
|
|
|
130
|
-
const
|
|
131
|
-
'u:NumberIncrement',
|
|
132
|
-
{
|
|
133
|
-
variants,
|
|
134
|
-
styles,
|
|
135
|
-
rootElement: 'wrapper',
|
|
136
|
-
},
|
|
137
|
-
)
|
|
107
|
+
const styles = useStylesFor(NumberIncrement.styleRegistryName, style)
|
|
138
108
|
|
|
139
109
|
const inputTextStyle = React.useMemo(() => ([
|
|
140
|
-
|
|
141
|
-
isFocused &&
|
|
142
|
-
hasError &&
|
|
143
|
-
disabled &&
|
|
110
|
+
styles.input,
|
|
111
|
+
isFocused && styles['input:focus'],
|
|
112
|
+
hasError && styles['input:error'],
|
|
113
|
+
disabled && styles['input:disabled'],
|
|
144
114
|
]), [disabled, isFocused, hasError])
|
|
145
115
|
|
|
146
116
|
const placeholderTextColor = [
|
|
147
|
-
[disabled,
|
|
148
|
-
[hasError,
|
|
149
|
-
[isFocused,
|
|
150
|
-
[true,
|
|
117
|
+
[disabled, styles['placeholder:disabled']],
|
|
118
|
+
[hasError, styles['placeholder:error']],
|
|
119
|
+
[isFocused, styles['placeholder:focus']],
|
|
120
|
+
[true, styles.placeholder],
|
|
121
|
+
// @ts-expect-error
|
|
151
122
|
].find(([x]) => x)?.[1]?.color
|
|
152
123
|
|
|
153
124
|
const selectionColor = [
|
|
154
|
-
[disabled,
|
|
155
|
-
[!validation.isValid,
|
|
156
|
-
[isFocused,
|
|
157
|
-
[true,
|
|
125
|
+
[disabled, styles['selection:disabled']],
|
|
126
|
+
[!validation.isValid, styles['selection:error']],
|
|
127
|
+
[isFocused, styles['selection:focus']],
|
|
128
|
+
[true, styles.selection],
|
|
129
|
+
// @ts-expect-error
|
|
158
130
|
].find(([x]) => x)?.[1]?.color
|
|
159
131
|
|
|
160
132
|
const onChange = (newValue: number) => {
|
|
@@ -257,27 +229,21 @@ export const NumberIncrement = forwardRef<NativeTextInput, NumberIncrementProps>
|
|
|
257
229
|
<InputBase
|
|
258
230
|
{...inputBaseProps}
|
|
259
231
|
error={hasError ? errorMessage : null}
|
|
260
|
-
|
|
261
|
-
...variantStyles,
|
|
262
|
-
innerWrapper: [
|
|
263
|
-
variantStyles.innerWrapper,
|
|
264
|
-
],
|
|
265
|
-
}}
|
|
232
|
+
style={styles}
|
|
266
233
|
rightIcon={{
|
|
267
|
-
name: 'plus' as
|
|
234
|
+
name: 'plus' as AppIcon,
|
|
268
235
|
disabled: disabled || incrementDisabled || !editable,
|
|
269
236
|
onPress: () => handleChange('increment'),
|
|
270
237
|
debounce: actionDebounce,
|
|
271
238
|
...inputBaseProps.rightIcon,
|
|
272
239
|
}}
|
|
273
240
|
leftIcon={{
|
|
274
|
-
name: 'minus' as
|
|
241
|
+
name: 'minus' as AppIcon,
|
|
275
242
|
disabled: disabled || decrementDisabled || !editable,
|
|
276
243
|
onPress: () => handleChange('decrement'),
|
|
277
244
|
debounce: actionDebounce,
|
|
278
245
|
...inputBaseProps.leftIcon,
|
|
279
246
|
}}
|
|
280
|
-
style={style}
|
|
281
247
|
disabled={disabled}
|
|
282
248
|
focused={isFocused}
|
|
283
249
|
innerWrapper={Touchable}
|
|
@@ -313,6 +279,30 @@ export const NumberIncrement = forwardRef<NativeTextInput, NumberIncrementProps>
|
|
|
313
279
|
)}
|
|
314
280
|
</InputBase>
|
|
315
281
|
)
|
|
316
|
-
})
|
|
282
|
+
}) as StyledComponentWithProps<NumberIncrementProps>
|
|
283
|
+
|
|
284
|
+
NumberIncrement.styleRegistryName = 'NumberIncrement'
|
|
285
|
+
NumberIncrement.elements = [...InputBase.elements, 'input', 'placeholder', 'selection']
|
|
286
|
+
NumberIncrement.rootElement = 'wrapper'
|
|
287
|
+
|
|
288
|
+
NumberIncrement.withVariantTypes = <S extends AnyRecord>(styles: S) => {
|
|
289
|
+
return NumberIncrement as (props: StyledComponentProps<NumberIncrementProps, typeof styles>) => IJSX
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
NumberIncrement.defaultProps = {
|
|
293
|
+
max: MAX_VALID_DIGITS,
|
|
294
|
+
min: 0,
|
|
295
|
+
step: 1,
|
|
296
|
+
editable: true,
|
|
297
|
+
separator: null,
|
|
298
|
+
formatter: null,
|
|
299
|
+
parseValue: defaultParseValue,
|
|
300
|
+
delimiter: null,
|
|
301
|
+
mask: null,
|
|
302
|
+
masking: null,
|
|
303
|
+
timeoutActionFocus: 300,
|
|
304
|
+
actionPressAutoFocus: true,
|
|
305
|
+
actionDebounce: null,
|
|
306
|
+
} as Partial<NumberIncrementProps>
|
|
317
307
|
|
|
318
|
-
NumberIncrement
|
|
308
|
+
MobileStyleRegistry.registerComponent(NumberIncrement)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
|
|
2
1
|
import { InputBaseParts, InputBaseStates } from '../InputBase'
|
|
3
2
|
|
|
4
3
|
export type NumberIncrementParts = InputBaseParts | 'input' | 'placeholder' | 'selection'
|
|
@@ -8,7 +7,3 @@ export type NumberIncrementStates = InputBaseStates
|
|
|
8
7
|
export type NumberIncrementComposition =
|
|
9
8
|
| NumberIncrementParts
|
|
10
9
|
| `${NumberIncrementParts}:${NumberIncrementStates}`
|
|
11
|
-
|
|
12
|
-
const createNumberIncrementStyle = createDefaultVariantFactory<NumberIncrementComposition>()
|
|
13
|
-
|
|
14
|
-
export const NumberIncrementPresets = includePresets((styles) => createNumberIncrementStyle(() => ({ wrapper: styles })))
|
|
@@ -1,44 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
yup,
|
|
4
|
-
StylesOf,
|
|
5
|
-
PropsOf,
|
|
6
|
-
FormTypes,
|
|
7
|
-
} from '@codeleap/common'
|
|
8
|
-
import { NumberIncrementPresets, NumberIncrementComposition } from './styles'
|
|
1
|
+
import { yup, FormTypes, AnyFunction } from '@codeleap/common'
|
|
2
|
+
import { NumberIncrementComposition } from './styles'
|
|
9
3
|
import { TextInputMaskProps } from '../../modules/textInputMask'
|
|
10
|
-
import { TextInputProps as
|
|
11
|
-
import { View } from '../View'
|
|
12
|
-
import { Touchable } from '../Touchable'
|
|
4
|
+
import { TextInputProps as RNTextInputProps } from 'react-native'
|
|
13
5
|
import { InputBaseProps } from '../InputBase'
|
|
6
|
+
import { StyledProp } from '@codeleap/styles'
|
|
14
7
|
|
|
15
8
|
type Masking = FormTypes.TextField['masking']
|
|
16
|
-
type MaskOptions =
|
|
9
|
+
type MaskOptions = Masking['options']
|
|
17
10
|
|
|
18
|
-
export type NumberIncrementProps =
|
|
19
|
-
Omit<InputBaseProps, '
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
11
|
+
export type NumberIncrementProps =
|
|
12
|
+
Omit<InputBaseProps, 'style'> &
|
|
13
|
+
Omit<RNTextInputProps, 'style'> &
|
|
14
|
+
{
|
|
15
|
+
value: number
|
|
16
|
+
validate?: FormTypes.ValidatorWithoutForm<string> | yup.SchemaOf<string>
|
|
17
|
+
max?: number
|
|
18
|
+
min?: number
|
|
19
|
+
step?: number
|
|
20
|
+
editable?: boolean
|
|
21
|
+
_error?: string
|
|
22
|
+
placeholder?: string
|
|
23
|
+
onChangeMask?: TextInputMaskProps['onChangeText']
|
|
24
|
+
masking?: Exclude<Masking, 'mask' | 'format'>
|
|
25
|
+
prefix?: MaskOptions['unit']
|
|
26
|
+
suffix?: MaskOptions['suffixUnit']
|
|
27
|
+
separator?: MaskOptions['separator']
|
|
28
|
+
delimiter?: MaskOptions['delimiter']
|
|
29
|
+
mask?: MaskOptions['mask']
|
|
30
|
+
formatter?: (value: string | number) => string
|
|
31
|
+
parseValue?: (value: string) => number
|
|
32
|
+
timeoutActionFocus?: number
|
|
33
|
+
actionPressAutoFocus?: boolean
|
|
34
|
+
actionDebounce?: number | null
|
|
35
|
+
onPress?: AnyFunction
|
|
36
|
+
style?: StyledProp<NumberIncrementComposition>
|
|
37
|
+
}
|