@codeleap/mobile 3.1.2 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/src/components/ActionIcon/index.tsx +1 -1
- package/src/components/ActivityIndicator/index.tsx +13 -12
- package/src/components/Avatar/index.tsx +7 -7
- package/src/components/AvatarGroup/index.tsx +4 -6
- package/src/components/Badge/index.tsx +12 -12
- package/src/components/Button/index.tsx +2 -1
- package/src/components/DatePickerModal/index.tsx +4 -0
- package/src/components/DatePickerModal/types.ts +4 -1
- package/src/components/EmptyPlaceholder/index.tsx +3 -3
- package/src/components/FileInput/index.tsx +46 -16
- package/src/components/Icon/index.tsx +11 -12
- package/src/components/Image/index.tsx +17 -15
- package/src/components/ImageView/Spotlight.tsx +2 -2
- package/src/components/List/index.tsx +1 -1
- package/src/components/Modal/index.tsx +2 -2
- package/src/components/Navigation/constants.ts +19 -3
- package/src/components/Pager/index.tsx +7 -11
- package/src/components/RadioInput/index.tsx +1 -1
- package/src/components/RefreshControl/index.tsx +1 -1
- package/src/components/Scroll/index.tsx +7 -9
- package/src/components/Sections/index.tsx +8 -11
- package/src/components/SegmentedControl/Option.tsx +2 -2
- package/src/components/SegmentedControl/index.tsx +72 -33
- package/src/components/Select/index.tsx +2 -1
- package/src/components/Select/styles.ts +0 -1
- package/src/components/Select/types.ts +10 -4
- package/src/components/Slider/index.tsx +46 -50
- package/src/components/Switch/index.tsx +92 -98
- package/src/components/Text/index.tsx +8 -14
- package/src/components/TextInput/index.tsx +8 -2
- package/src/components/Touchable/index.tsx +13 -9
- package/src/components/View/index.tsx +17 -20
- package/src/components/components.ts +1 -1
- package/src/modules/reactNavigation.ts +1 -2
- package/src/modules/textInputMask.tsx +0 -6
- package/src/utils/theme.ts +1 -1
- 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/rnDeviceInfo.ts +0 -6
- package/src/modules/types/documentPicker.d.ts +0 -215
- package/src/modules/types/fileTypes.ts +0 -138
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
onUpdate,
|
|
4
4
|
TypeGuards,
|
|
5
5
|
useDefaultComponentStyle,
|
|
6
|
-
useWarning
|
|
6
|
+
useWarning,
|
|
7
7
|
} from '@codeleap/common'
|
|
8
8
|
import React, { ReactNode, useCallback, useRef } from 'react'
|
|
9
9
|
import {
|
|
@@ -46,7 +46,7 @@ export type PagerProps = React.PropsWithChildren<{
|
|
|
46
46
|
windowing?:boolean
|
|
47
47
|
}>
|
|
48
48
|
|
|
49
|
-
export const Pager
|
|
49
|
+
export const Pager = (pagerProps:PagerProps) => {
|
|
50
50
|
const {
|
|
51
51
|
styles,
|
|
52
52
|
variants,
|
|
@@ -61,12 +61,11 @@ export const Pager: React.FC<PagerProps> = (pagerProps) => {
|
|
|
61
61
|
setPage,
|
|
62
62
|
} = pagerProps
|
|
63
63
|
|
|
64
|
-
|
|
65
64
|
const childArr = React.Children.toArray(children)
|
|
66
65
|
const scrollRef = useRef<ScrollView>(null)
|
|
67
66
|
const [positionX, setPositionX] = React.useState(0)
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
|
|
68
|
+
const variantStyles = useDefaultComponentStyle<'u:Pager', typeof PagerPresets>(
|
|
70
69
|
'u:Pager',
|
|
71
70
|
{
|
|
72
71
|
styles,
|
|
@@ -75,15 +74,14 @@ export const Pager: React.FC<PagerProps> = (pagerProps) => {
|
|
|
75
74
|
},
|
|
76
75
|
)
|
|
77
76
|
|
|
78
|
-
|
|
79
77
|
const windowWidth = Dimensions.get('window').width
|
|
80
78
|
let width = widthProp ?? variantStyles.wrapper.width
|
|
81
79
|
|
|
82
80
|
const validWidth = TypeGuards.isNumber(width)
|
|
83
|
-
|
|
81
|
+
|
|
84
82
|
if (!validWidth) {
|
|
85
83
|
width = windowWidth
|
|
86
|
-
|
|
84
|
+
|
|
87
85
|
}
|
|
88
86
|
|
|
89
87
|
useWarning(
|
|
@@ -98,7 +96,6 @@ export const Pager: React.FC<PagerProps> = (pagerProps) => {
|
|
|
98
96
|
|
|
99
97
|
const WrapperComponent = renderPageWrapper || View
|
|
100
98
|
|
|
101
|
-
|
|
102
99
|
const handleScrollEnd = useCallback(
|
|
103
100
|
({ nativeEvent }: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
104
101
|
const x = nativeEvent.contentOffset.x
|
|
@@ -142,14 +139,13 @@ export const Pager: React.FC<PagerProps> = (pagerProps) => {
|
|
|
142
139
|
const isFirst = index === 0
|
|
143
140
|
const isNext = index === page + 1
|
|
144
141
|
const isPrevious = index === page - 1
|
|
145
|
-
|
|
142
|
+
|
|
146
143
|
const shouldRender = windowing ? (isActive || isNext || isPrevious) : true
|
|
147
144
|
|
|
148
145
|
if (!shouldRender && returnEarly) {
|
|
149
146
|
return <View style={{ height: '100%', width }} />
|
|
150
147
|
}
|
|
151
148
|
|
|
152
|
-
|
|
153
149
|
const pageProps:PageProps = {
|
|
154
150
|
isLast,
|
|
155
151
|
isActive,
|
|
@@ -6,7 +6,7 @@ export type RefreshControlProps = {
|
|
|
6
6
|
styles?: StylesOf<RefreshControlComposition>
|
|
7
7
|
} & RNRefreshControlProps & ComponentVariants<typeof RefreshControlPresets>
|
|
8
8
|
|
|
9
|
-
export const RefreshControl
|
|
9
|
+
export const RefreshControl = (props:RefreshControlProps) => {
|
|
10
10
|
const { variants = [], styles } = props
|
|
11
11
|
|
|
12
12
|
const variantStyles = useDefaultComponentStyle<'u:RefreshControl', typeof RefreshControlPresets>('u:RefreshControl', {
|
|
@@ -6,16 +6,13 @@ import {
|
|
|
6
6
|
useDefaultComponentStyle,
|
|
7
7
|
usePrevious,
|
|
8
8
|
} from '@codeleap/common'
|
|
9
|
-
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
|
|
10
9
|
import { ScrollView, StyleSheet } from 'react-native'
|
|
11
10
|
import { ViewProps } from '../View'
|
|
12
11
|
import { RefreshControl, RefreshControlProps } from '../RefreshControl'
|
|
13
|
-
import { KeyboardAwareScrollViewTypes } from '../../modules'
|
|
14
12
|
import { StylesOf } from '../../types'
|
|
15
13
|
import { ScrollComposition, ScrollPresets } from './styles'
|
|
16
14
|
import { GetKeyboardAwarePropsOptions } from '../../utils'
|
|
17
|
-
|
|
18
|
-
type KeyboardAwareScrollViewProps = KeyboardAwareScrollViewTypes.KeyboardAwareScrollViewProps
|
|
15
|
+
import { KeyboardAwareScrollView, KeyboardAwareScrollViewProps } from 'react-native-keyboard-aware-scroll-view'
|
|
19
16
|
|
|
20
17
|
export type ScrollProps = KeyboardAwareScrollViewProps &
|
|
21
18
|
ViewProps & {
|
|
@@ -29,7 +26,9 @@ export type ScrollProps = KeyboardAwareScrollViewProps &
|
|
|
29
26
|
debugName?: string
|
|
30
27
|
}
|
|
31
28
|
|
|
32
|
-
export
|
|
29
|
+
export type ScrollRef = KeyboardAwareScrollView
|
|
30
|
+
|
|
31
|
+
export const Scroll = forwardRef<ScrollRef, ScrollProps>(
|
|
33
32
|
(scrollProps, ref) => {
|
|
34
33
|
const {
|
|
35
34
|
variants = [],
|
|
@@ -41,7 +40,6 @@ export const Scroll = forwardRef<ScrollView, ScrollProps>(
|
|
|
41
40
|
refreshControlProps = {},
|
|
42
41
|
contentContainerStyle,
|
|
43
42
|
keyboardAware,
|
|
44
|
-
debugName = '',
|
|
45
43
|
animated = true,
|
|
46
44
|
...props
|
|
47
45
|
} = scrollProps
|
|
@@ -81,14 +79,14 @@ export const Scroll = forwardRef<ScrollView, ScrollProps>(
|
|
|
81
79
|
rootElement: 'content',
|
|
82
80
|
})
|
|
83
81
|
|
|
84
|
-
const Component =
|
|
82
|
+
const Component = KeyboardAwareScrollView
|
|
85
83
|
|
|
86
84
|
return (
|
|
87
85
|
<Component
|
|
88
86
|
style={[variantStyles.wrapper, style]}
|
|
89
87
|
contentContainerStyle={[variantStyles.content, contentContainerStyle]}
|
|
90
88
|
showsVerticalScrollIndicator={false}
|
|
91
|
-
// @ts-
|
|
89
|
+
// @ts-ignore
|
|
92
90
|
ref={ref}
|
|
93
91
|
refreshControl= {
|
|
94
92
|
hasRefresh && (
|
|
@@ -105,5 +103,5 @@ export const Scroll = forwardRef<ScrollView, ScrollProps>(
|
|
|
105
103
|
</Component>
|
|
106
104
|
)
|
|
107
105
|
},
|
|
108
|
-
)
|
|
106
|
+
) as unknown as (props:ScrollProps) => JSX.Element
|
|
109
107
|
export * from './styles'
|
|
@@ -6,23 +6,22 @@ import {
|
|
|
6
6
|
useCallback,
|
|
7
7
|
} from '@codeleap/common'
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
RefreshControl,
|
|
11
|
-
StyleSheet,
|
|
12
|
-
RefreshControlProps,
|
|
9
|
+
import {
|
|
10
|
+
RefreshControl,
|
|
11
|
+
StyleSheet,
|
|
12
|
+
RefreshControlProps,
|
|
13
13
|
SectionListRenderItemInfo,
|
|
14
14
|
SectionListProps as RNSectionListProps,
|
|
15
15
|
} from 'react-native'
|
|
16
16
|
import { View, ViewProps } from '../View'
|
|
17
17
|
import { EmptyPlaceholderProps } from '../EmptyPlaceholder'
|
|
18
18
|
import { StylesOf } from '../../types'
|
|
19
|
-
import { KeyboardAwareSectionList } from 'react-native-keyboard-aware-scroll-view'
|
|
19
|
+
import { KeyboardAwareSectionList, KeyboardAwareSectionListProps } from 'react-native-keyboard-aware-scroll-view'
|
|
20
20
|
import { SectionsComposition, SectionsPresets } from './styles'
|
|
21
21
|
export * from './styles'
|
|
22
22
|
|
|
23
23
|
export type DataboundSectionListPropsTypes = 'data' | 'renderItem' | 'keyExtractor' | 'getItemLayout'
|
|
24
24
|
|
|
25
|
-
|
|
26
25
|
export type AugmentedSectionRenderItemInfo<T> = SectionListRenderItemInfo<T> & {
|
|
27
26
|
isFirst: boolean
|
|
28
27
|
isLast: boolean
|
|
@@ -43,7 +42,6 @@ export type ReplaceSectionListProps<P, T> = Omit<P, DataboundSectionListPropsTyp
|
|
|
43
42
|
|
|
44
43
|
export * from './styles'
|
|
45
44
|
|
|
46
|
-
|
|
47
45
|
export type SectionListProps<
|
|
48
46
|
T = any[],
|
|
49
47
|
Data = T extends Array<infer D> ? D : never
|
|
@@ -56,7 +54,6 @@ export type SectionListProps<
|
|
|
56
54
|
fakeEmpty?: boolean
|
|
57
55
|
} & ComponentVariants<typeof SectionsPresets>
|
|
58
56
|
|
|
59
|
-
|
|
60
57
|
export const Sections = forwardRef<KeyboardAwareSectionList, SectionListProps>(
|
|
61
58
|
(sectionsProps, ref) => {
|
|
62
59
|
const {
|
|
@@ -80,7 +77,7 @@ export const Sections = forwardRef<KeyboardAwareSectionList, SectionListProps>(
|
|
|
80
77
|
transform: StyleSheet.flatten,
|
|
81
78
|
|
|
82
79
|
})
|
|
83
|
-
|
|
80
|
+
|
|
84
81
|
const renderSeparator = () => {
|
|
85
82
|
return (
|
|
86
83
|
<View style={variantStyles.separator}></View>
|
|
@@ -132,7 +129,7 @@ export const Sections = forwardRef<KeyboardAwareSectionList, SectionListProps>(
|
|
|
132
129
|
|
|
133
130
|
return (
|
|
134
131
|
<KeyboardAwareSectionList
|
|
135
|
-
style={[variantStyles.wrapper,style]}
|
|
132
|
+
style={[variantStyles.wrapper, style]}
|
|
136
133
|
contentContainerStyle={[variantStyles.content]}
|
|
137
134
|
showsVerticalScrollIndicator={false}
|
|
138
135
|
// @ts-ignore
|
|
@@ -150,4 +147,4 @@ export const Sections = forwardRef<KeyboardAwareSectionList, SectionListProps>(
|
|
|
150
147
|
/>
|
|
151
148
|
)
|
|
152
149
|
},
|
|
153
|
-
)
|
|
150
|
+
) as unknown as <T = any>(props: SectionListProps<T>) => JSX.Element
|
|
@@ -3,7 +3,6 @@ import { IconPlaceholder, PropsOf } from '@codeleap/common'
|
|
|
3
3
|
import { StylesOf } from '../../types'
|
|
4
4
|
import { Text } from '../Text'
|
|
5
5
|
import { Touchable } from '../Touchable'
|
|
6
|
-
import { Gap, View } from '../View'
|
|
7
6
|
import { SegmentedControlComposition } from './styles'
|
|
8
7
|
import { Icon } from '../Icon'
|
|
9
8
|
|
|
@@ -23,12 +22,13 @@ export const SegmentedControlOption = (props: SegmentedControlOptionProps) => {
|
|
|
23
22
|
return <Touchable
|
|
24
23
|
debugName={`Segmented Control ${debugName}, option ${label}`}
|
|
25
24
|
noFeedback={selected}
|
|
26
|
-
|
|
25
|
+
|
|
27
26
|
styles={{
|
|
28
27
|
feedback: variantStyles.buttonFeedback,
|
|
29
28
|
}}
|
|
30
29
|
style={[variantStyles.button, selected && variantStyles['button:selected'], style]}
|
|
31
30
|
onPress={onPress}
|
|
31
|
+
{...touchableProps}
|
|
32
32
|
>
|
|
33
33
|
{
|
|
34
34
|
!!icon && (
|
|
@@ -1,30 +1,38 @@
|
|
|
1
1
|
import React, { ReactElement, useImperativeHandle, useMemo, useRef } from 'react'
|
|
2
|
-
import { Scroll, ScrollProps } from '../Scroll'
|
|
2
|
+
import { Scroll, ScrollProps, ScrollRef } from '../Scroll'
|
|
3
3
|
|
|
4
4
|
import { Easing, StyleSheet } from 'react-native'
|
|
5
|
-
import { FormTypes, getNestedStylesByKey, PropsOf,
|
|
5
|
+
import { FormTypes, getNestedStylesByKey, PropsOf, useCodeleapContext, useDefaultComponentStyle, useState } from '@codeleap/common'
|
|
6
6
|
import { SegmentedControlComposition, SegmentedControlPresets } from './styles'
|
|
7
7
|
import { Touchable } from '../Touchable'
|
|
8
8
|
import { StylesOf } from '../../types/utility'
|
|
9
9
|
import { Text } from '../Text'
|
|
10
|
-
import { KeyboardAwareScrollViewTypes } from '../../modules'
|
|
11
10
|
import { View } from '../View'
|
|
12
11
|
import { InputLabel } from '../InputLabel'
|
|
13
12
|
import { useAnimatedVariantStyles, TransitionConfig } from '../../utils'
|
|
14
13
|
import { SegmentedControlOption } from './Option'
|
|
15
|
-
import {
|
|
16
|
-
import { Badge, BadgeProps } from '../Badge'
|
|
14
|
+
import { SegmentedControlOptionProps } from './Option'
|
|
17
15
|
|
|
18
16
|
export * from './styles'
|
|
19
|
-
|
|
17
|
+
|
|
18
|
+
export type SegmentedControlRef = ScrollRef & {
|
|
20
19
|
scrollTo: (index: number) => void
|
|
21
20
|
scrollToCurrent: () => void
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
const DefaultBubble = (props:Partial<SegmentedControlProps>) => {
|
|
24
|
+
const {
|
|
25
|
+
style,
|
|
26
|
+
|
|
27
|
+
} = props
|
|
28
|
+
return <View
|
|
29
|
+
animated
|
|
30
|
+
style={style}
|
|
31
|
+
/>
|
|
32
|
+
}
|
|
25
33
|
|
|
26
34
|
export type SegmentedControlProps<T = string> = ScrollProps & {
|
|
27
|
-
options :
|
|
35
|
+
options : SegmentedControlOptionProps[]
|
|
28
36
|
onValueChange: (value: T) => any
|
|
29
37
|
value: T
|
|
30
38
|
debugName: string
|
|
@@ -34,14 +42,10 @@ export type SegmentedControlProps<T = string> = ScrollProps & {
|
|
|
34
42
|
styles?: StylesOf<SegmentedControlComposition>
|
|
35
43
|
scrollProps?: any
|
|
36
44
|
label?: FormTypes.Label
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}) => ReactElement
|
|
42
|
-
RenderAnimatedView?: (props: Partial<SegmentedControlProps>) => ReactElement
|
|
43
|
-
getItemWidth?: (item: SegmentedContropOptions, idx: number, arr: SegmentedContropOptions[]) => number
|
|
44
|
-
badgeProps?: Partial<BadgeProps>
|
|
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
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
const defaultAnimation = {
|
|
@@ -65,10 +69,15 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
65
69
|
variants = [],
|
|
66
70
|
scrollProps = {},
|
|
67
71
|
getItemWidth = (i) => (Theme.values.width - Theme.spacing.value(4)) / options.length,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
} =
|
|
72
|
+
renderBubble,
|
|
73
|
+
scrollToCurrentOptionOnMount = true,
|
|
74
|
+
renderOption,
|
|
75
|
+
} = {
|
|
76
|
+
...(_SegmentedControl.defaultProps || {}),
|
|
77
|
+
...props,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const [bubbleWidth, setBubbleWidth] = useState(0)
|
|
72
81
|
|
|
73
82
|
const _animation = {
|
|
74
83
|
...defaultAnimation, ...animation,
|
|
@@ -81,7 +90,7 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
81
90
|
rootElement: 'scroll',
|
|
82
91
|
})
|
|
83
92
|
|
|
84
|
-
const scrollRef = useRef<
|
|
93
|
+
const scrollRef = useRef<SegmentedControlRef>(null)
|
|
85
94
|
|
|
86
95
|
function scrollTo(idx:number) {
|
|
87
96
|
if (!scrollRef.current) return
|
|
@@ -91,11 +100,18 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
91
100
|
}
|
|
92
101
|
|
|
93
102
|
const widthStyle = useMemo(() => {
|
|
94
|
-
|
|
95
|
-
|
|
103
|
+
if (getItemWidth) {
|
|
104
|
+
const sizes = options.map(getItemWidth)
|
|
105
|
+
const maxWidth = sizes.sort((a, b) => b - a)[0]
|
|
106
|
+
|
|
107
|
+
return { width: maxWidth }
|
|
96
108
|
|
|
97
|
-
|
|
98
|
-
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
width: bubbleWidth,
|
|
113
|
+
}
|
|
114
|
+
}, [options, bubbleWidth])
|
|
99
115
|
|
|
100
116
|
const currentOptionIdx = options.findIndex(o => o.value === value) || 0
|
|
101
117
|
|
|
@@ -119,14 +135,18 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
119
135
|
scrollTo(currentOptionIdx)
|
|
120
136
|
},
|
|
121
137
|
} as SegmentedControlRef
|
|
122
|
-
}
|
|
138
|
+
}, [
|
|
139
|
+
currentOptionIdx,
|
|
140
|
+
])
|
|
123
141
|
|
|
124
|
-
if (!hasScrolledInitially.current && scrollRef.current) {
|
|
142
|
+
if (!hasScrolledInitially.current && scrollRef.current && scrollToCurrentOptionOnMount) {
|
|
125
143
|
scrollTo(currentOptionIdx)
|
|
126
144
|
hasScrolledInitially.current = true
|
|
127
145
|
}
|
|
128
146
|
|
|
129
|
-
const BubbleView =
|
|
147
|
+
const BubbleView = renderBubble
|
|
148
|
+
const Option = renderOption
|
|
149
|
+
|
|
130
150
|
variantStyles = JSON.parse(JSON.stringify(variantStyles))
|
|
131
151
|
|
|
132
152
|
const labelStyles = getNestedStylesByKey('label', variantStyles)
|
|
@@ -144,7 +164,7 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
144
164
|
dependencies: [currentOptionIdx, widthStyle.width],
|
|
145
165
|
})
|
|
146
166
|
|
|
147
|
-
const
|
|
167
|
+
const largestWidth = useRef(0)
|
|
148
168
|
|
|
149
169
|
return (<View style={variantStyles.wrapper}>
|
|
150
170
|
<InputLabel label={label} styles={labelStyles} required={false}/>
|
|
@@ -164,11 +184,15 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
164
184
|
options={options}
|
|
165
185
|
styles={variantStyles}
|
|
166
186
|
animated
|
|
167
|
-
style={[
|
|
168
|
-
|
|
187
|
+
style={[
|
|
188
|
+
variantStyles.selectedBubble,
|
|
189
|
+
props?.touchableProps?.disabled && variantStyles['selectedBubble:disabled'],
|
|
190
|
+
widthStyle,
|
|
191
|
+
bubbleAnimation,
|
|
192
|
+
]}
|
|
169
193
|
/>
|
|
170
194
|
{options.map((o, idx) => (
|
|
171
|
-
<
|
|
195
|
+
<Option
|
|
172
196
|
debugName={debugName}
|
|
173
197
|
label={o.label}
|
|
174
198
|
value={o.value}
|
|
@@ -178,7 +202,17 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
178
202
|
style={widthStyle}
|
|
179
203
|
selected={value === o.value}
|
|
180
204
|
variantStyles={variantStyles}
|
|
181
|
-
|
|
205
|
+
onLayout={e => {
|
|
206
|
+
const { width } = e.nativeEvent.layout
|
|
207
|
+
if (width > largestWidth.current) {
|
|
208
|
+
largestWidth.current = width
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (idx === options.length - 1) {
|
|
212
|
+
setBubbleWidth(largestWidth.current)
|
|
213
|
+
largestWidth.current = 0
|
|
214
|
+
}
|
|
215
|
+
}}
|
|
182
216
|
/>
|
|
183
217
|
))}
|
|
184
218
|
</View>
|
|
@@ -188,6 +222,11 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
188
222
|
|
|
189
223
|
})
|
|
190
224
|
|
|
225
|
+
_SegmentedControl.defaultProps = {
|
|
226
|
+
renderBubble: DefaultBubble,
|
|
227
|
+
renderOption: SegmentedControlOption,
|
|
228
|
+
}
|
|
229
|
+
|
|
191
230
|
type SegControlComponent = <T = string>(props: SegmentedControlProps<T> & {ref?: React.Ref<SegmentedControlRef>}) => ReactElement
|
|
192
231
|
|
|
193
232
|
export const SegmentedControl = _SegmentedControl as SegControlComponent
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
1
2
|
import { IconPlaceholder,
|
|
2
3
|
useDefaultComponentStyle,
|
|
3
4
|
TypeGuards,
|
|
@@ -312,7 +313,7 @@ export const Select = <T extends string|number = string, Multi extends boolean =
|
|
|
312
313
|
icon: inputIcon as IconPlaceholder,
|
|
313
314
|
onPress: onPressInputIcon,
|
|
314
315
|
}}
|
|
315
|
-
|
|
316
|
+
|
|
316
317
|
currentValueLabel={currentValueLabel}
|
|
317
318
|
|
|
318
319
|
debugName={`${debugName} select input`}
|
|
@@ -35,13 +35,18 @@ type SelectHeaderProps = {
|
|
|
35
35
|
searchComponent?: React.ReactNode
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
type
|
|
38
|
+
export type SelectOuterInputProps<T = any, Multi extends boolean = false> = Omit<SelectProps<T, Multi>, 'variants'| 'styles'> & {
|
|
39
39
|
currentValueLabel: FormTypes.Label
|
|
40
40
|
styles?: StylesOf<TextInputComposition>
|
|
41
41
|
clearIcon?: Partial<ActionIconProps>
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
type OuterInputComponent<T, Multi extends boolean> = (props: SelectOuterInputProps<T, Multi>) => JSX.Element
|
|
45
|
+
|
|
46
|
+
export type ValueBoundSelectProps<
|
|
47
|
+
T,
|
|
48
|
+
Multi extends boolean = false
|
|
49
|
+
> = {
|
|
45
50
|
options?: FormTypes.Options<T>
|
|
46
51
|
defaultOptions?: FormTypes.Options<T>
|
|
47
52
|
loadOptions?: (search: string) => Promise<FormTypes.Options<T>>
|
|
@@ -52,7 +57,8 @@ export type ValueBoundSelectProps<T, Multi extends boolean = false> = {
|
|
|
52
57
|
onLoadOptionsError?: (error: any) => void
|
|
53
58
|
multiple?: Multi
|
|
54
59
|
getLabel?: (forOption: Multi extends true ? FormTypes.Options<T> : FormTypes.Options<T>[number]) => FormTypes.Label
|
|
55
|
-
outerInputComponent?:
|
|
60
|
+
outerInputComponent?: OuterInputComponent<T, Multi>
|
|
61
|
+
inputProps?: Partial<SelectOuterInputProps<T, Multi>>
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
export type ReplaceSelectProps<Props, T, Multi extends boolean = false> = Omit<
|
|
@@ -69,7 +75,7 @@ export type SelectProps<T = any, Multi extends boolean = false> = {
|
|
|
69
75
|
selectedIcon?: IconPlaceholder
|
|
70
76
|
arrowIconName?: IconPlaceholder
|
|
71
77
|
closeOnSelect?: boolean
|
|
72
|
-
|
|
78
|
+
|
|
73
79
|
listProps?: Partial<FlatListProps>
|
|
74
80
|
clearable?: boolean
|
|
75
81
|
clearIconName?: IconPlaceholder
|