@codeleap/mobile 3.14.2 → 3.15.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 +1 -1
- package/src/components/Grid/index.tsx +18 -5
- package/src/components/InputBase/index.tsx +7 -5
- package/src/components/List/index.tsx +28 -12
- package/src/components/Pager/index.tsx +21 -5
- package/src/components/Scroll/index.tsx +14 -4
- package/src/components/Sections/index.tsx +17 -5
- package/src/components/SegmentedControl/index.tsx +22 -19
- package/src/components/TextInput/index.tsx +3 -2
- package/src/components/Touchable/index.tsx +8 -0
- package/src/types/index.ts +5 -2
package/package.json
CHANGED
|
@@ -41,6 +41,11 @@ const RenderSeparator = (props: { separatorStyles: ViewProps['style'] }) => {
|
|
|
41
41
|
)
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
const defaultProps: Partial<GridProps> = {
|
|
45
|
+
keyboardShouldPersistTaps: 'handled',
|
|
46
|
+
refreshControlProps: {},
|
|
47
|
+
}
|
|
48
|
+
|
|
44
49
|
const GridCP = forwardRef<KeyboardAwareFlatList, GridProps>(
|
|
45
50
|
(flatGridProps, ref) => {
|
|
46
51
|
const {
|
|
@@ -54,7 +59,11 @@ const GridCP = forwardRef<KeyboardAwareFlatList, GridProps>(
|
|
|
54
59
|
spacing,
|
|
55
60
|
numColumns,
|
|
56
61
|
...props
|
|
57
|
-
} =
|
|
62
|
+
} = {
|
|
63
|
+
...defaultProps,
|
|
64
|
+
...flatGridProps,
|
|
65
|
+
}
|
|
66
|
+
|
|
58
67
|
const { Theme } = useCodeleapContext()
|
|
59
68
|
const variantStyles = useDefaultComponentStyle<'u:Grid', typeof GridPresets>('u:Grid', {
|
|
60
69
|
variants,
|
|
@@ -90,12 +99,12 @@ const GridCP = forwardRef<KeyboardAwareFlatList, GridProps>(
|
|
|
90
99
|
}, [props?.renderItem, props?.data?.length])
|
|
91
100
|
|
|
92
101
|
const separatorStyles = { height: Theme.spacing.value(spacing), ...variantStyles.separator }
|
|
93
|
-
const separator = props?.separators || (!!spacing ? <RenderSeparator separatorStyles={separatorStyles}/> : null)
|
|
94
|
-
const refreshControl = !!onRefresh && <RefreshControl refreshing={refreshing} onRefresh={onRefresh} {...refreshControlProps}/>
|
|
102
|
+
const separator = props?.separators || (!!spacing ? <RenderSeparator separatorStyles={separatorStyles} /> : null)
|
|
103
|
+
const refreshControl = !!onRefresh && <RefreshControl refreshing={refreshing} onRefresh={onRefresh} {...refreshControlProps} />
|
|
95
104
|
const _gridProps = {
|
|
96
105
|
...props,
|
|
97
106
|
ref: ref,
|
|
98
|
-
ListEmptyComponent: <EmptyPlaceholder {...placeholder}/>,
|
|
107
|
+
ListEmptyComponent: <EmptyPlaceholder {...placeholder} />,
|
|
99
108
|
ListHeaderComponentStyle: variantStyles.header,
|
|
100
109
|
ListFooterComponentStyle: variantStyles.footer,
|
|
101
110
|
ItemSeparatorComponent: separator,
|
|
@@ -116,7 +125,11 @@ const GridCP = forwardRef<KeyboardAwareFlatList, GridProps>(
|
|
|
116
125
|
},
|
|
117
126
|
)
|
|
118
127
|
|
|
119
|
-
export type GridComponentType = <T extends any[] = any[]>(props: GridProps<T>) =>
|
|
128
|
+
export type GridComponentType = (<T extends any[] = any[]>(props: GridProps<T>) => JSX.Element) & {
|
|
129
|
+
defaultProps?: Partial<GridProps>
|
|
130
|
+
}
|
|
120
131
|
|
|
121
132
|
export const Grid = GridCP as unknown as GridComponentType
|
|
122
133
|
|
|
134
|
+
Grid.defaultProps = defaultProps
|
|
135
|
+
|
|
@@ -10,7 +10,7 @@ export * from './styles'
|
|
|
10
10
|
export * from './utils'
|
|
11
11
|
export * from './types'
|
|
12
12
|
|
|
13
|
-
export const InputBaseDefaultOrder:InputBaseProps['order'] = [
|
|
13
|
+
export const InputBaseDefaultOrder: InputBaseProps['order'] = [
|
|
14
14
|
'label',
|
|
15
15
|
'description',
|
|
16
16
|
'innerWrapper',
|
|
@@ -52,6 +52,7 @@ export const InputBase = React.forwardRef<any, InputBaseProps>((props, ref) => {
|
|
|
52
52
|
// @ts-ignore
|
|
53
53
|
styles: _styles.leftIconStyles,
|
|
54
54
|
debugName: `${debugName} left icon`,
|
|
55
|
+
dismissKeyboard: false,
|
|
55
56
|
})
|
|
56
57
|
|
|
57
58
|
const _rightIcon = getRenderedComponent<Partial<ActionIconProps>>(rightIcon, ActionIcon, {
|
|
@@ -59,13 +60,14 @@ export const InputBase = React.forwardRef<any, InputBaseProps>((props, ref) => {
|
|
|
59
60
|
// @ts-ignore
|
|
60
61
|
styles: _styles.rightIconStyles,
|
|
61
62
|
debugName: `${debugName} right icon`,
|
|
63
|
+
dismissKeyboard: false,
|
|
62
64
|
})
|
|
63
65
|
|
|
64
|
-
const _label = TypeGuards.isString(label) ? <Text text={label} style={_styles.labelStyle}/> : label
|
|
66
|
+
const _label = TypeGuards.isString(label) ? <Text text={label} style={_styles.labelStyle} /> : label
|
|
65
67
|
|
|
66
|
-
const _error = TypeGuards.isString(error) ? <Text text={error} style={_styles.errorStyle}/> : error
|
|
68
|
+
const _error = TypeGuards.isString(error) ? <Text text={error} style={_styles.errorStyle} /> : error
|
|
67
69
|
|
|
68
|
-
const _description = TypeGuards.isString(description) ? <Text text={description} style={_styles.descriptionStyle}/> : description
|
|
70
|
+
const _description = TypeGuards.isString(description) ? <Text text={description} style={_styles.descriptionStyle} /> : description
|
|
69
71
|
|
|
70
72
|
const parts = {
|
|
71
73
|
label: labelAsRow ? <View style={_styles.labelRowStyle}>
|
|
@@ -81,7 +83,7 @@ export const InputBase = React.forwardRef<any, InputBaseProps>((props, ref) => {
|
|
|
81
83
|
{_rightIcon}
|
|
82
84
|
</InnerWrapperComponent>,
|
|
83
85
|
error: hideErrorMessage ? null : (
|
|
84
|
-
_error || <Text text={''} style={_styles.errorStyle}/>
|
|
86
|
+
_error || <Text text={''} style={_styles.errorStyle} />
|
|
85
87
|
),
|
|
86
88
|
}
|
|
87
89
|
|
|
@@ -31,7 +31,7 @@ export type ReplaceFlatlistProps<P, T> = Omit<P, DataboundFlatListPropsTypes> &
|
|
|
31
31
|
renderItem: (data: AugmentedRenderItemInfo<T>) => React.ReactElement
|
|
32
32
|
onRefresh?: () => void
|
|
33
33
|
getItemLayout?: ((
|
|
34
|
-
data:T,
|
|
34
|
+
data: T,
|
|
35
35
|
index: number,
|
|
36
36
|
) => { length: number; offset: number; index: number })
|
|
37
37
|
fakeEmpty?: boolean
|
|
@@ -61,23 +61,36 @@ const RenderSeparator = (props: { separatorStyles: ViewProps['style'] }) => {
|
|
|
61
61
|
)
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
const defaultProps: Partial<FlatListProps> = {
|
|
65
|
+
keyboardShouldPersistTaps: 'handled',
|
|
66
|
+
styles: {},
|
|
67
|
+
variants: [],
|
|
68
|
+
refreshControlProps: {},
|
|
69
|
+
fakeEmpty: false,
|
|
70
|
+
loading: false,
|
|
71
|
+
keyboardAware: true,
|
|
72
|
+
}
|
|
73
|
+
|
|
64
74
|
const ListCP = forwardRef<FlatList, FlatListProps>(
|
|
65
75
|
(flatListProps, ref) => {
|
|
66
76
|
const {
|
|
67
|
-
variants
|
|
77
|
+
variants,
|
|
68
78
|
style,
|
|
69
|
-
styles
|
|
79
|
+
styles,
|
|
70
80
|
onRefresh,
|
|
71
81
|
component,
|
|
72
82
|
refreshing,
|
|
73
83
|
placeholder,
|
|
74
|
-
refreshControlProps
|
|
75
|
-
loading
|
|
76
|
-
keyboardAware
|
|
84
|
+
refreshControlProps,
|
|
85
|
+
loading,
|
|
86
|
+
keyboardAware,
|
|
77
87
|
fakeEmpty = loading,
|
|
78
88
|
contentContainerStyle,
|
|
79
89
|
...props
|
|
80
|
-
} =
|
|
90
|
+
} = {
|
|
91
|
+
...defaultProps,
|
|
92
|
+
...flatListProps,
|
|
93
|
+
}
|
|
81
94
|
|
|
82
95
|
const variantStyles = useDefaultComponentStyle<'u:List', typeof ListPresets>('u:List', {
|
|
83
96
|
variants,
|
|
@@ -87,7 +100,7 @@ const ListCP = forwardRef<FlatList, FlatListProps>(
|
|
|
87
100
|
})
|
|
88
101
|
|
|
89
102
|
// const isEmpty = !props.data || !props.data.length
|
|
90
|
-
const separator = props?.separators && <RenderSeparator separatorStyles={variantStyles.separator}/>
|
|
103
|
+
const separator = props?.separators && <RenderSeparator separatorStyles={variantStyles.separator} />
|
|
91
104
|
|
|
92
105
|
const renderItem = useCallback((data: ListRenderItemInfo<any>) => {
|
|
93
106
|
if (!props?.renderItem) return null
|
|
@@ -138,10 +151,10 @@ const ListCP = forwardRef<FlatList, FlatListProps>(
|
|
|
138
151
|
/>
|
|
139
152
|
)}
|
|
140
153
|
|
|
141
|
-
ListEmptyComponent={<EmptyPlaceholder {..._placeholder}/>}
|
|
154
|
+
ListEmptyComponent={<EmptyPlaceholder {..._placeholder} />}
|
|
142
155
|
{...props}
|
|
143
156
|
data={fakeEmpty ? [] : props.data}
|
|
144
|
-
ref={
|
|
157
|
+
ref={ref}
|
|
145
158
|
renderItem={renderItem}
|
|
146
159
|
|
|
147
160
|
/>
|
|
@@ -149,7 +162,10 @@ const ListCP = forwardRef<FlatList, FlatListProps>(
|
|
|
149
162
|
},
|
|
150
163
|
)
|
|
151
164
|
|
|
152
|
-
export type ListComponentType = <T extends any[] = any[]>(props: FlatListProps<T>) => JSX.Element
|
|
153
|
-
|
|
165
|
+
export type ListComponentType = (<T extends any[] = any[]>(props: FlatListProps<T>) => JSX.Element) & {
|
|
166
|
+
defaultProps: Partial<FlatListProps>
|
|
167
|
+
}
|
|
154
168
|
export const List = ListCP as unknown as ListComponentType
|
|
155
169
|
|
|
170
|
+
List.defaultProps = defaultProps
|
|
171
|
+
|
|
@@ -44,11 +44,21 @@ export type PagerProps = React.PropsWithChildren<{
|
|
|
44
44
|
pageWrapperProps?: any
|
|
45
45
|
width?: number
|
|
46
46
|
onScroll: ScrollProps['onScroll']
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
/** If TRUE render page, nextPage and prevPage only */
|
|
48
|
+
windowing?: boolean
|
|
49
49
|
} & ScrollViewProps>
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
const defaultProps: Partial<PagerProps> = {
|
|
52
|
+
variants: [],
|
|
53
|
+
styles: {},
|
|
54
|
+
page: 0,
|
|
55
|
+
returnEarly: true,
|
|
56
|
+
windowing: false,
|
|
57
|
+
scrollEnabled: true,
|
|
58
|
+
keyboardShouldPersistTaps: 'handled',
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const Pager = (pagerProps: PagerProps) => {
|
|
52
62
|
const {
|
|
53
63
|
styles,
|
|
54
64
|
variants,
|
|
@@ -62,7 +72,10 @@ export const Pager = (pagerProps:PagerProps) => {
|
|
|
62
72
|
windowing = false,
|
|
63
73
|
setPage,
|
|
64
74
|
scrollEnabled = true,
|
|
65
|
-
} =
|
|
75
|
+
} = {
|
|
76
|
+
...defaultProps,
|
|
77
|
+
...pagerProps,
|
|
78
|
+
}
|
|
66
79
|
|
|
67
80
|
const childArr = React.Children.toArray(children)
|
|
68
81
|
const scrollRef = useRef<ScrollView>(null)
|
|
@@ -134,6 +147,7 @@ export const Pager = (pagerProps:PagerProps) => {
|
|
|
134
147
|
style={[variantStyles.wrapper, style]}
|
|
135
148
|
{...pagerProps}
|
|
136
149
|
scrollEnabled={childArr.length > 1 && scrollEnabled}
|
|
150
|
+
|
|
137
151
|
>
|
|
138
152
|
{childArr.map((child: PagerProps['children'][number], index) => {
|
|
139
153
|
|
|
@@ -149,7 +163,7 @@ export const Pager = (pagerProps:PagerProps) => {
|
|
|
149
163
|
return <View style={{ height: '100%', width }} />
|
|
150
164
|
}
|
|
151
165
|
|
|
152
|
-
const pageProps:PageProps = {
|
|
166
|
+
const pageProps: PageProps = {
|
|
153
167
|
isLast,
|
|
154
168
|
isActive,
|
|
155
169
|
isFirst,
|
|
@@ -172,3 +186,5 @@ export const Pager = (pagerProps:PagerProps) => {
|
|
|
172
186
|
</ScrollView>
|
|
173
187
|
)
|
|
174
188
|
}
|
|
189
|
+
|
|
190
|
+
Pager.defaultProps = defaultProps
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { ScrollView, StyleSheet } from 'react-native'
|
|
10
10
|
import { ViewProps } from '../View'
|
|
11
11
|
import { RefreshControl, RefreshControlProps } from '../RefreshControl'
|
|
12
|
-
import { StylesOf } from '../../types'
|
|
12
|
+
import { ComponentWithDefaultProps, StylesOf } from '../../types'
|
|
13
13
|
import { ScrollComposition, ScrollPresets } from './styles'
|
|
14
14
|
import { GetKeyboardAwarePropsOptions, useKeyboardPaddingStyle } from '../../utils'
|
|
15
15
|
import { KeyboardAwareScrollView, KeyboardAwareScrollViewProps } from 'react-native-keyboard-aware-scroll-view'
|
|
@@ -29,6 +29,10 @@ export type ScrollProps = KeyboardAwareScrollViewProps &
|
|
|
29
29
|
|
|
30
30
|
export type ScrollRef = KeyboardAwareScrollView
|
|
31
31
|
|
|
32
|
+
const defaultProps: Partial<ScrollProps> = {
|
|
33
|
+
keyboardShouldPersistTaps: 'handled',
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
export const Scroll = forwardRef<ScrollRef, ScrollProps>(
|
|
33
37
|
(scrollProps, ref) => {
|
|
34
38
|
const {
|
|
@@ -43,7 +47,10 @@ export const Scroll = forwardRef<ScrollRef, ScrollProps>(
|
|
|
43
47
|
keyboardAware = true,
|
|
44
48
|
animated = true,
|
|
45
49
|
...props
|
|
46
|
-
} =
|
|
50
|
+
} = {
|
|
51
|
+
...defaultProps,
|
|
52
|
+
...scrollProps,
|
|
53
|
+
}
|
|
47
54
|
const hasRefresh = !!props.onRefresh
|
|
48
55
|
const [refreshingState, setRefreshing] = useState(false)
|
|
49
56
|
const refreshingDisplay = props.refreshing !== undefined ? props.refreshing : refreshingState
|
|
@@ -91,7 +98,7 @@ export const Scroll = forwardRef<ScrollRef, ScrollProps>(
|
|
|
91
98
|
showsVerticalScrollIndicator={false}
|
|
92
99
|
// @ts-ignore
|
|
93
100
|
ref={ref}
|
|
94
|
-
refreshControl=
|
|
101
|
+
refreshControl={
|
|
95
102
|
hasRefresh && (
|
|
96
103
|
<RefreshControl
|
|
97
104
|
refreshing={refreshingDisplay}
|
|
@@ -106,5 +113,8 @@ export const Scroll = forwardRef<ScrollRef, ScrollProps>(
|
|
|
106
113
|
</Component>
|
|
107
114
|
)
|
|
108
115
|
},
|
|
109
|
-
) as unknown as
|
|
116
|
+
) as unknown as ComponentWithDefaultProps<ScrollProps>
|
|
117
|
+
|
|
118
|
+
Scroll.defaultProps = defaultProps
|
|
119
|
+
|
|
110
120
|
export * from './styles'
|
|
@@ -35,7 +35,7 @@ export type ReplaceSectionListProps<P, T> = Omit<P, DataboundSectionListPropsTyp
|
|
|
35
35
|
renderItem: (data: AugmentedSectionRenderItemInfo<T>) => React.ReactElement
|
|
36
36
|
onRefresh?: () => void
|
|
37
37
|
getItemLayout?: ((
|
|
38
|
-
data:T,
|
|
38
|
+
data: T,
|
|
39
39
|
index: number,
|
|
40
40
|
) => { length: number; offset: number; index: number })
|
|
41
41
|
fakeEmpty?: boolean
|
|
@@ -56,6 +56,13 @@ export type SectionListProps<
|
|
|
56
56
|
keyboardAware?: boolean
|
|
57
57
|
} & ComponentVariants<typeof SectionsPresets>
|
|
58
58
|
|
|
59
|
+
const defaultProps: Partial<SectionListProps> = {
|
|
60
|
+
keyboardShouldPersistTaps: 'handled',
|
|
61
|
+
refreshControlProps: {},
|
|
62
|
+
keyboardAware: true,
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
59
66
|
export const Sections = forwardRef<SectionList, SectionListProps>(
|
|
60
67
|
(sectionsProps, ref) => {
|
|
61
68
|
const {
|
|
@@ -66,14 +73,17 @@ export const Sections = forwardRef<SectionList, SectionListProps>(
|
|
|
66
73
|
component,
|
|
67
74
|
refreshing,
|
|
68
75
|
placeholder,
|
|
69
|
-
keyboardAware
|
|
70
|
-
refreshControlProps
|
|
76
|
+
keyboardAware,
|
|
77
|
+
refreshControlProps,
|
|
71
78
|
contentContainerStyle,
|
|
72
79
|
|
|
73
80
|
fakeEmpty,
|
|
74
81
|
refreshControl,
|
|
75
82
|
...props
|
|
76
|
-
} =
|
|
83
|
+
} = {
|
|
84
|
+
...defaultProps,
|
|
85
|
+
...sectionsProps,
|
|
86
|
+
}
|
|
77
87
|
|
|
78
88
|
const variantStyles = useDefaultComponentStyle<'u:Sections', typeof SectionsPresets>('u:Sections', {
|
|
79
89
|
variants,
|
|
@@ -153,4 +163,6 @@ export const Sections = forwardRef<SectionList, SectionListProps>(
|
|
|
153
163
|
/>
|
|
154
164
|
)
|
|
155
165
|
},
|
|
156
|
-
) as unknown as <T = any>(props: SectionListProps<T>) => JSX.Element
|
|
166
|
+
) as unknown as (<T = any>(props: SectionListProps<T>) => JSX.Element) & {
|
|
167
|
+
defaultProps: Partial<SectionListProps>
|
|
168
|
+
}
|
|
@@ -20,7 +20,7 @@ export type SegmentedControlRef = ScrollRef & {
|
|
|
20
20
|
scrollToCurrent: () => void
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const DefaultBubble = (props:Partial<SegmentedControlProps>) => {
|
|
23
|
+
const DefaultBubble = (props: Partial<SegmentedControlProps>) => {
|
|
24
24
|
const {
|
|
25
25
|
style,
|
|
26
26
|
|
|
@@ -32,20 +32,20 @@ const DefaultBubble = (props:Partial<SegmentedControlProps>) => {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export type SegmentedControlProps<T = string> = ScrollProps & {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
options: SegmentedControlOptionProps[]
|
|
36
|
+
onValueChange: (value: T) => any
|
|
37
|
+
value: T
|
|
38
|
+
debugName: string
|
|
39
|
+
animation?: TransitionConfig
|
|
40
|
+
textProps?: Partial<PropsOf<typeof Text>>
|
|
41
|
+
touchableProps?: Partial<PropsOf<typeof Touchable>>
|
|
42
|
+
styles?: StylesOf<SegmentedControlComposition>
|
|
43
|
+
scrollProps?: any
|
|
44
|
+
label?: FormTypes.Label
|
|
45
|
+
renderOption?: (props: SegmentedControlOptionProps) => JSX.Element
|
|
46
|
+
renderBubble?: (props: Partial<SegmentedControlProps>) => JSX.Element
|
|
47
|
+
getItemWidth?: (item: { label: string; value: T }, idx: number, arr: { label: string; value: T }[]) => number
|
|
48
|
+
scrollToCurrentOptionOnMount?: boolean
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
const defaultAnimation = {
|
|
@@ -72,6 +72,7 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
72
72
|
renderBubble,
|
|
73
73
|
scrollToCurrentOptionOnMount = true,
|
|
74
74
|
renderOption,
|
|
75
|
+
touchableProps,
|
|
75
76
|
} = {
|
|
76
77
|
...(_SegmentedControl.defaultProps || {}),
|
|
77
78
|
...props,
|
|
@@ -92,7 +93,7 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
92
93
|
|
|
93
94
|
const scrollRef = useRef<SegmentedControlRef>(null)
|
|
94
95
|
|
|
95
|
-
function scrollTo(idx:number) {
|
|
96
|
+
function scrollTo(idx: number) {
|
|
96
97
|
if (!scrollRef.current) return
|
|
97
98
|
setTimeout(() => {
|
|
98
99
|
scrollRef.current?.scrollToPosition?.(widthStyle.width * idx, 0, true)
|
|
@@ -115,7 +116,7 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
115
116
|
|
|
116
117
|
const currentOptionIdx = options.findIndex(o => o.value === value) || 0
|
|
117
118
|
|
|
118
|
-
const onPress = (txt:string, idx: number) => {
|
|
119
|
+
const onPress = (txt: string, idx: number) => {
|
|
119
120
|
return () => {
|
|
120
121
|
onValueChange(txt)
|
|
121
122
|
scrollTo(idx)
|
|
@@ -167,7 +168,7 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
167
168
|
const largestWidth = useRef(0)
|
|
168
169
|
|
|
169
170
|
return (<View style={variantStyles.wrapper}>
|
|
170
|
-
<InputLabel label={label} styles={labelStyles} required={false}/>
|
|
171
|
+
<InputLabel label={label} styles={labelStyles} required={false} />
|
|
171
172
|
<Scroll
|
|
172
173
|
horizontal
|
|
173
174
|
showsHorizontalScrollIndicator={false}
|
|
@@ -213,6 +214,7 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
213
214
|
largestWidth.current = 0
|
|
214
215
|
}
|
|
215
216
|
}}
|
|
217
|
+
{...touchableProps}
|
|
216
218
|
/>
|
|
217
219
|
))}
|
|
218
220
|
</View>
|
|
@@ -225,8 +227,9 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
225
227
|
_SegmentedControl.defaultProps = {
|
|
226
228
|
renderBubble: DefaultBubble,
|
|
227
229
|
renderOption: SegmentedControlOption,
|
|
230
|
+
touchableProps: {},
|
|
228
231
|
}
|
|
229
232
|
|
|
230
|
-
type SegControlComponent = <T = string>(props: SegmentedControlProps<T> & {ref?: React.Ref<SegmentedControlRef>}) => ReactElement
|
|
233
|
+
type SegControlComponent = <T = string>(props: SegmentedControlProps<T> & { ref?: React.Ref<SegmentedControlRef> }) => ReactElement
|
|
231
234
|
|
|
232
235
|
export const SegmentedControl = _SegmentedControl as SegControlComponent
|
|
@@ -38,7 +38,7 @@ export type TextInputProps =
|
|
|
38
38
|
_error?: string
|
|
39
39
|
} & Pick<PropsOf<typeof Touchable>, 'onPress'>
|
|
40
40
|
|
|
41
|
-
const defaultProps:Partial<TextInputProps> = {
|
|
41
|
+
const defaultProps: Partial<TextInputProps> = {
|
|
42
42
|
hiddenIcon: 'input-visiblity:hidden' as IconPlaceholder,
|
|
43
43
|
visibleIcon: 'input-visiblity:visible' as IconPlaceholder,
|
|
44
44
|
}
|
|
@@ -182,6 +182,7 @@ const TextInputComponent = forwardRef<NativeTextInput, TextInputProps>((props, i
|
|
|
182
182
|
...(inputBaseProps.innerWrapperProps || {}),
|
|
183
183
|
onPress,
|
|
184
184
|
debugName,
|
|
185
|
+
dismissKeyboard: false,
|
|
185
186
|
}}
|
|
186
187
|
rightIcon={rightIcon}
|
|
187
188
|
focused={isFocused}
|
|
@@ -246,7 +247,7 @@ export const SearchInput: ComponentWithDefaultProps<SearchInputProps> = (props)
|
|
|
246
247
|
|
|
247
248
|
const [search, setSearch] = !TypeGuards.isNil(value) && !!onValueChange ? [value, onValueChange] : useState('')
|
|
248
249
|
|
|
249
|
-
const setSearchTimeout = React.useRef<NodeJS.Timeout|null>(null)
|
|
250
|
+
const setSearchTimeout = React.useRef<NodeJS.Timeout | null>(null)
|
|
250
251
|
|
|
251
252
|
const handleChangeSearch = (value: string) => {
|
|
252
253
|
setSearch(value)
|
|
@@ -14,6 +14,7 @@ import { TouchableComposition, TouchablePresets } from './styles'
|
|
|
14
14
|
import { StylesOf } from '../../types'
|
|
15
15
|
import { View } from '../View'
|
|
16
16
|
import { usePressableFeedback } from '../../utils'
|
|
17
|
+
import { Keyboard } from 'react-native'
|
|
17
18
|
|
|
18
19
|
import { PressableRipple } from '../../modules/PressableRipple'
|
|
19
20
|
export type TouchableProps =
|
|
@@ -39,6 +40,7 @@ export type TouchableProps =
|
|
|
39
40
|
analyticsEnabled?: boolean
|
|
40
41
|
analyticsName?: string
|
|
41
42
|
analyticsData?: Record<string, any>
|
|
43
|
+
dismissKeyboard?: boolean
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
export * from './styles'
|
|
@@ -50,6 +52,7 @@ const defaultProps: Partial<TouchableProps> = {
|
|
|
50
52
|
analyticsEnabled: false,
|
|
51
53
|
analyticsName: null,
|
|
52
54
|
analyticsData: {},
|
|
55
|
+
dismissKeyboard: true,
|
|
53
56
|
}
|
|
54
57
|
const _Touchable = forwardRef<
|
|
55
58
|
RNView,
|
|
@@ -71,6 +74,7 @@ const _Touchable = forwardRef<
|
|
|
71
74
|
analyticsEnabled,
|
|
72
75
|
analyticsName,
|
|
73
76
|
analyticsData = {},
|
|
77
|
+
dismissKeyboard,
|
|
74
78
|
...props
|
|
75
79
|
} = {
|
|
76
80
|
...defaultProps,
|
|
@@ -109,12 +113,16 @@ const _Touchable = forwardRef<
|
|
|
109
113
|
debugName || variants,
|
|
110
114
|
'User interaction',
|
|
111
115
|
)
|
|
116
|
+
if (dismissKeyboard) {
|
|
117
|
+
Keyboard.dismiss()
|
|
118
|
+
}
|
|
112
119
|
if (analyticsEnabled) {
|
|
113
120
|
const name = analyticsName || debugName
|
|
114
121
|
if (!!name?.trim?.()) {
|
|
115
122
|
logger.analytics?.interaction(name, analyticsData)
|
|
116
123
|
}
|
|
117
124
|
}
|
|
125
|
+
|
|
118
126
|
onPress && onPress()
|
|
119
127
|
}
|
|
120
128
|
if (TypeGuards.isNumber(debounce)) {
|
package/src/types/index.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export * from './utility'
|
|
2
2
|
|
|
3
|
+
export type ComponentWithDefaultProps<P = any> = ((props: P) => JSX.Element) & {
|
|
4
|
+
defaultProps: Partial<P>
|
|
5
|
+
}
|
|
3
6
|
|
|
4
|
-
export type
|
|
7
|
+
export type ForwardRefComponentWithDefaultProps<P = any, R = any> = ((props: P, ref: R) => JSX.Element) & {
|
|
5
8
|
defaultProps: Partial<P>
|
|
6
|
-
}
|
|
9
|
+
}
|