@codeleap/mobile 3.24.2 → 3.25.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.
Files changed (131) hide show
  1. package/package.json +6 -4
  2. package/src/Registry.ts +52 -0
  3. package/src/components/ActionIcon/index.tsx +55 -37
  4. package/src/components/ActionIcon/styles.ts +2 -4
  5. package/src/components/ActionIcon/types.ts +15 -0
  6. package/src/components/ActivityIndicator/index.tsx +42 -64
  7. package/src/components/ActivityIndicator/styles.ts +1 -10
  8. package/src/components/ActivityIndicator/types.ts +9 -0
  9. package/src/components/Autocomplete/index.tsx +46 -54
  10. package/src/components/Autocomplete/styles.ts +2 -5
  11. package/src/components/Autocomplete/types.ts +13 -23
  12. package/src/components/Avatar/index.tsx +59 -71
  13. package/src/components/Avatar/styles.ts +1 -9
  14. package/src/components/Avatar/types.ts +23 -0
  15. package/src/components/AvatarGroup/index.tsx +30 -44
  16. package/src/components/AvatarGroup/styles.ts +0 -6
  17. package/src/components/AvatarGroup/types.ts +10 -0
  18. package/src/components/Backdrop/index.tsx +51 -34
  19. package/src/components/Backdrop/styles.ts +5 -10
  20. package/src/components/Backdrop/types.ts +14 -0
  21. package/src/components/Badge/index.tsx +36 -62
  22. package/src/components/Badge/styles.ts +3 -11
  23. package/src/components/Badge/types.ts +27 -0
  24. package/src/components/Button/index.tsx +55 -82
  25. package/src/components/Button/styles.ts +13 -14
  26. package/src/components/Button/types.ts +20 -0
  27. package/src/components/Calendar/index.tsx +35 -29
  28. package/src/components/Checkbox/index.tsx +43 -64
  29. package/src/components/Checkbox/styles.ts +1 -6
  30. package/src/components/Checkbox/types.ts +13 -0
  31. package/src/components/DatePickerModal/index.tsx +50 -65
  32. package/src/components/DatePickerModal/styles.ts +9 -10
  33. package/src/components/DatePickerModal/types.ts +36 -54
  34. package/src/components/EmptyPlaceholder/index.tsx +40 -63
  35. package/src/components/EmptyPlaceholder/styles.ts +0 -5
  36. package/src/components/EmptyPlaceholder/types.ts +21 -0
  37. package/src/components/FileInput/index.tsx +11 -49
  38. package/src/components/FileInput/types.ts +27 -0
  39. package/src/components/Grid/index.tsx +84 -116
  40. package/src/components/Grid/styles.ts +0 -5
  41. package/src/components/Grid/types.ts +20 -0
  42. package/src/components/Icon/index.tsx +44 -79
  43. package/src/components/Icon/styles.ts +0 -6
  44. package/src/components/Icon/types.ts +15 -0
  45. package/src/components/Image/index.tsx +58 -78
  46. package/src/components/Image/styles.ts +1 -6
  47. package/src/components/Image/types.ts +18 -0
  48. package/src/components/ImageView/Spotlight.tsx +1 -4
  49. package/src/components/ImageView/component.tsx +1 -2
  50. package/src/components/InputBase/index.tsx +33 -24
  51. package/src/components/InputBase/styles.ts +66 -75
  52. package/src/components/InputBase/types.ts +3 -4
  53. package/src/components/InputBase/utils.ts +6 -4
  54. package/src/components/List/index.tsx +99 -151
  55. package/src/components/List/styles.ts +0 -6
  56. package/src/components/List/types.ts +41 -0
  57. package/src/components/LoadingOverlay/index.tsx +42 -29
  58. package/src/components/LoadingOverlay/styles.ts +7 -7
  59. package/src/components/LoadingOverlay/types.ts +9 -0
  60. package/src/components/Modal/index.tsx +80 -127
  61. package/src/components/Modal/styles.ts +0 -8
  62. package/src/components/Modal/types.ts +41 -0
  63. package/src/components/Navigation/Navigation.tsx +1 -0
  64. package/src/components/Navigation/types.ts +2 -9
  65. package/src/components/NumberIncrement/index.tsx +50 -60
  66. package/src/components/NumberIncrement/styles.ts +0 -5
  67. package/src/components/NumberIncrement/types.ts +32 -39
  68. package/src/components/Pager/index.tsx +42 -94
  69. package/src/components/Pager/styles.ts +1 -13
  70. package/src/components/Pager/types.ts +37 -0
  71. package/src/components/PaginationIndicator/index.tsx +51 -0
  72. package/src/components/PaginationIndicator/styles.ts +3 -0
  73. package/src/components/PaginationIndicator/types.ts +10 -0
  74. package/src/components/RadioInput/index.tsx +32 -57
  75. package/src/components/RadioInput/styles.ts +5 -7
  76. package/src/components/RadioInput/types.ts +31 -0
  77. package/src/components/RefreshControl/index.tsx +39 -19
  78. package/src/components/RefreshControl/styles.ts +1 -6
  79. package/src/components/RefreshControl/types.ts +9 -0
  80. package/src/components/Scroll/index.tsx +89 -105
  81. package/src/components/Scroll/styles.ts +0 -5
  82. package/src/components/Scroll/types.ts +21 -0
  83. package/src/components/SearchInput/index.tsx +90 -0
  84. package/src/components/Sections/index.tsx +111 -161
  85. package/src/components/Sections/styles.ts +0 -5
  86. package/src/components/Sections/types.ts +39 -0
  87. package/src/components/SegmentedControl/Option.tsx +46 -31
  88. package/src/components/SegmentedControl/index.tsx +86 -121
  89. package/src/components/SegmentedControl/styles.ts +15 -22
  90. package/src/components/SegmentedControl/types.ts +31 -0
  91. package/src/components/Select/index.tsx +71 -82
  92. package/src/components/Select/styles.ts +3 -5
  93. package/src/components/Select/types.ts +20 -25
  94. package/src/components/Slider/index.tsx +58 -43
  95. package/src/components/Slider/styles.ts +15 -6
  96. package/src/components/Slider/types.ts +9 -14
  97. package/src/components/Switch/index.tsx +43 -56
  98. package/src/components/Switch/styles.ts +1 -7
  99. package/src/components/Switch/types.ts +12 -0
  100. package/src/components/Text/index.tsx +56 -52
  101. package/src/components/Text/styles.ts +1 -7
  102. package/src/components/Text/types.ts +18 -0
  103. package/src/components/TextInput/index.tsx +49 -162
  104. package/src/components/TextInput/styles.ts +2 -8
  105. package/src/components/TextInput/types.ts +23 -0
  106. package/src/components/Touchable/index.tsx +44 -87
  107. package/src/components/Touchable/styles.ts +0 -9
  108. package/src/components/Touchable/types.ts +27 -0
  109. package/src/components/View/index.tsx +23 -92
  110. package/src/components/View/styles.ts +0 -6
  111. package/src/components/View/types.ts +13 -0
  112. package/src/components/components.ts +2 -6
  113. package/src/hooks/index.ts +13 -0
  114. package/src/index.ts +2 -0
  115. package/src/modules/PressableRipple/type.ts +1 -0
  116. package/src/utils/KeyboardAware/context.tsx +0 -2
  117. package/src/utils/KeyboardAware/keyboardHooks.ts +1 -2
  118. package/src/utils/ModalManager/components.tsx +1 -30
  119. package/src/utils/ModalManager/context.tsx +4 -4
  120. package/src/utils/ModalManager/index.ts +1 -4
  121. package/src/utils/hooks.ts +12 -1
  122. package/src/components/Calendar/style.ts +0 -6
  123. package/src/components/ContentView/index.tsx +0 -63
  124. package/src/components/ContentView/styles.ts +0 -8
  125. package/src/components/Drawer/index.tsx +0 -28
  126. package/src/components/Drawer/styles.ts +0 -8
  127. package/src/components/FileInput/styles.ts +0 -8
  128. package/src/components/InputLabel/index.tsx +0 -38
  129. package/src/components/InputLabel/styles.ts +0 -7
  130. package/src/components/List/PaginationIndicator.tsx +0 -54
  131. package/src/components/defaultStyles.ts +0 -77
@@ -1,51 +1,66 @@
1
1
  import React from 'react'
2
- import { IconPlaceholder, PropsOf } from '@codeleap/common'
2
+ import { PropsOf } from '@codeleap/common'
3
3
  import { StylesOf } from '../../types'
4
4
  import { Text } from '../Text'
5
- import { Touchable } from '../Touchable'
5
+ import { Touchable, TouchableProps } from '../Touchable'
6
6
  import { SegmentedControlComposition } from './styles'
7
7
  import { Icon } from '../Icon'
8
+ import { AppIcon } from '@codeleap/styles'
8
9
 
9
- export type SegmentedControlOptionProps = PropsOf<typeof Touchable> & {
10
+ export type SegmentedControlOptionProps = Omit<TouchableProps, 'debugName'> & {
10
11
  selected?: boolean
11
12
  label: string
12
13
  value: string
13
14
  variantStyles?: StylesOf<SegmentedControlComposition>
14
15
  textProps?: Omit<PropsOf<typeof Text>, 'key'>
15
- icon?: IconPlaceholder
16
+ icon?: AppIcon
16
17
  badge?: React.ReactNode
18
+ debugName?: string
17
19
  }
18
20
 
19
21
  export const SegmentedControlOption = (props: SegmentedControlOptionProps) => {
20
- const { selected, onPress, debugName, style, variantStyles, label, value, icon, textProps, badge = null, ...touchableProps } = props
22
+ const {
23
+ selected,
24
+ onPress,
25
+ debugName,
26
+ style,
27
+ variantStyles,
28
+ label,
29
+ value,
30
+ icon,
31
+ textProps,
32
+ badge = null,
33
+ ...touchableProps
34
+ } = props
21
35
 
22
- return <Touchable
23
- debugName={`Segmented Control ${debugName}, option ${label}`}
24
- noFeedback={selected}
25
-
26
- styles={{
27
- feedback: variantStyles.buttonFeedback,
28
- }}
29
- style={[variantStyles.button, selected && variantStyles['button:selected'], style]}
30
- onPress={onPress}
31
- {...touchableProps}
32
- >
33
- {
34
- !!icon && (
35
- <Icon name={icon} style={[variantStyles.icon]} />
36
-
37
- )
38
- }
39
- <Text
40
- text={label}
36
+ return (
37
+ <Touchable
38
+ debugName={`Segmented Control ${debugName}, option ${label}`}
39
+ noFeedback={selected}
41
40
  style={[
42
- variantStyles.text,
43
- selected && variantStyles['text:selected'],
44
- touchableProps?.disabled && variantStyles['text:disabled'],
41
+ variantStyles?.button,
42
+ selected && variantStyles['button:selected'],
43
+ style,
44
+ {
45
+ feedback: variantStyles.buttonFeedback,
46
+ }
45
47
  ]}
46
- {...textProps}
47
- />
48
- { badge }
48
+ onPress={onPress}
49
+ {...touchableProps}
50
+ >
51
+ {!!icon ? <Icon name={icon} style={variantStyles?.icon} /> : null}
52
+
53
+ <Text
54
+ text={label}
55
+ style={[
56
+ variantStyles?.text,
57
+ selected && variantStyles['text:selected'],
58
+ touchableProps?.disabled && variantStyles['text:disabled'],
59
+ ]}
60
+ {...textProps}
61
+ />
49
62
 
50
- </Touchable>
63
+ {badge}
64
+ </Touchable>
65
+ )
51
66
  }
@@ -1,51 +1,19 @@
1
- import React, { ReactElement, useImperativeHandle, useMemo, useRef } from 'react'
2
- import { Scroll, ScrollProps, ScrollRef } from '../Scroll'
3
-
4
- import { Easing, StyleSheet } from 'react-native'
5
- import { FormTypes, getNestedStylesByKey, PropsOf, useCodeleapContext, useDefaultComponentStyle, useState } from '@codeleap/common'
6
- import { SegmentedControlComposition, SegmentedControlPresets } from './styles'
7
- import { Touchable } from '../Touchable'
8
- import { StylesOf } from '../../types/utility'
1
+ import React, { useImperativeHandle, useMemo, useRef, useState, Ref } from 'react'
2
+ import { Easing, ScrollView } from 'react-native'
9
3
  import { Text } from '../Text'
10
4
  import { View } from '../View'
11
- import { InputLabel } from '../InputLabel'
12
- import { useAnimatedVariantStyles, TransitionConfig } from '../../utils'
5
+ import { useAnimatedVariantStyles } from '../../utils'
13
6
  import { SegmentedControlOption } from './Option'
14
- import { SegmentedControlOptionProps } from './Option'
7
+ import { SegmentedControlProps, SegmentedControlRef } from './types'
8
+ import { AnyRecord, IJSX, StyledComponentProps, StyledComponentWithProps, useTheme } from '@codeleap/styles'
9
+ import { MobileStyleRegistry } from '../../Registry'
10
+ import { useStylesFor } from '../../hooks'
15
11
 
16
12
  export * from './styles'
13
+ export * from './types'
17
14
 
18
- export type SegmentedControlRef = ScrollRef & {
19
- scrollTo: (index: number) => void
20
- scrollToCurrent: () => void
21
- }
22
-
23
- const DefaultBubble = (props: Partial<SegmentedControlProps>) => {
24
- const {
25
- style,
26
-
27
- } = props
28
- return <View
29
- animated
30
- style={style}
31
- />
32
- }
33
-
34
- export type SegmentedControlProps<T = string> = ScrollProps & {
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
15
+ const DefaultBubble = (props) => {
16
+ return <View animated {...props} />
49
17
  }
50
18
 
51
19
  const defaultAnimation = {
@@ -54,9 +22,9 @@ const defaultAnimation = {
54
22
  easing: Easing.linear,
55
23
  }
56
24
 
57
- const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControlProps>((props, ref) => {
58
-
59
- const { Theme } = useCodeleapContext()
25
+ export const SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControlProps>((props, ref) => {
26
+ // @ts-expect-error
27
+ const [themeValues, themeSpacing] = useTheme(store => [store.current?.values, store.current?.spacing])
60
28
 
61
29
  const {
62
30
  options = [],
@@ -64,32 +32,28 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
64
32
  debugName,
65
33
  label,
66
34
  value,
67
- styles = {},
68
35
  animation = {},
69
- variants = [],
70
36
  scrollProps = {},
71
- getItemWidth = (i) => (Theme.values.width - Theme.spacing.value(4)) / options.length,
37
+ getItemWidth = () => (themeValues?.width - themeSpacing?.value?.(4)) / options.length,
72
38
  renderBubble,
73
- scrollToCurrentOptionOnMount = true,
39
+ scrollToCurrentOptionOnMount,
74
40
  renderOption,
75
41
  touchableProps,
42
+ style,
43
+ ...viewProps
76
44
  } = {
77
- ...(_SegmentedControl.defaultProps || {}),
45
+ ...SegmentedControl.defaultProps,
78
46
  ...props,
79
47
  }
80
48
 
81
49
  const [bubbleWidth, setBubbleWidth] = useState(0)
82
50
 
83
51
  const _animation = {
84
- ...defaultAnimation, ...animation,
52
+ ...defaultAnimation,
53
+ ...animation,
85
54
  }
86
55
 
87
- let variantStyles = useDefaultComponentStyle<'u:SegmentedControl', typeof SegmentedControlPresets>('u:SegmentedControl', {
88
- styles,
89
- transform: StyleSheet.flatten,
90
- variants,
91
- rootElement: 'scroll',
92
- })
56
+ const styles = useStylesFor(SegmentedControl.styleRegistryName, style)
93
57
 
94
58
  const scrollRef = useRef<SegmentedControlRef>(null)
95
59
 
@@ -148,12 +112,8 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
148
112
  const BubbleView = renderBubble
149
113
  const Option = renderOption
150
114
 
151
- variantStyles = JSON.parse(JSON.stringify(variantStyles))
152
-
153
- const labelStyles = getNestedStylesByKey('label', variantStyles)
154
-
155
115
  const bubbleAnimation = useAnimatedVariantStyles({
156
- variantStyles,
116
+ variantStyles: styles,
157
117
  animatedProperties: [],
158
118
  updater: () => {
159
119
  'worklet'
@@ -167,69 +127,74 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
167
127
 
168
128
  const largestWidth = useRef(0)
169
129
 
170
- return (<View style={variantStyles.wrapper}>
171
- <InputLabel label={label} styles={labelStyles} required={false} />
172
- <Scroll
173
- horizontal
174
- showsHorizontalScrollIndicator={false}
175
- style={variantStyles.scroll}
176
- contentContainerStyle={variantStyles.scrollContent}
177
- {...scrollProps}
178
- keyboardAware={{
179
- enabled: false,
180
- }}
181
- ref={scrollRef}
182
- >
183
- <View style={variantStyles.innerWrapper}>
184
- <BubbleView
185
- options={options}
186
- styles={variantStyles}
187
- animated
188
- style={[
189
- variantStyles.selectedBubble,
190
- props?.touchableProps?.disabled && variantStyles['selectedBubble:disabled'],
191
- widthStyle,
192
- bubbleAnimation,
193
- ]}
194
- />
195
- {options.map((o, idx) => (
196
- <Option
197
- debugName={debugName}
198
- label={o.label}
199
- value={o.value}
200
- icon={o.icon}
201
- onPress={onPress(o.value, idx)}
202
- key={idx}
203
- style={widthStyle}
204
- selected={value === o.value}
205
- variantStyles={variantStyles}
206
- onLayout={e => {
207
- const { width } = e.nativeEvent.layout
208
- if (width > largestWidth.current) {
209
- largestWidth.current = width
210
- }
211
-
212
- if (idx === options.length - 1) {
213
- setBubbleWidth(largestWidth.current)
214
- largestWidth.current = 0
215
- }
216
- }}
217
- {...touchableProps}
218
- />
219
- ))}
130
+ return (
131
+ <View style={styles?.wrapper}>
132
+ <View {...viewProps} style={styles?.labelWrapper}>
133
+ <Text style={styles?.labelText} text={label} />
220
134
  </View>
221
- </Scroll>
222
- </View>
135
+
136
+ <ScrollView
137
+ horizontal
138
+ showsHorizontalScrollIndicator={false}
139
+ style={styles?.scroll}
140
+ contentContainerStyle={styles?.scrollContent}
141
+ {...scrollProps}
142
+ ref={scrollRef as unknown as Ref<ScrollView>}
143
+ >
144
+ <View style={styles?.innerWrapper}>
145
+ <BubbleView
146
+ options={options}
147
+ animated
148
+ animatedStyle={bubbleAnimation}
149
+ style={[
150
+ styles?.selectedBubble,
151
+ props?.touchableProps?.disabled && styles?.['selectedBubble:disabled'],
152
+ widthStyle,
153
+ ]}
154
+ />
155
+ {options.map((o, idx) => (
156
+ <Option
157
+ debugName={debugName}
158
+ label={o.label}
159
+ value={o.value}
160
+ icon={o.icon}
161
+ onPress={onPress(o.value, idx)}
162
+ key={idx}
163
+ style={widthStyle}
164
+ selected={value === o.value}
165
+ variantStyles={styles}
166
+ onLayout={e => {
167
+ const { width } = e.nativeEvent.layout
168
+ if (width > largestWidth.current) {
169
+ largestWidth.current = width
170
+ }
171
+
172
+ if (idx === options.length - 1) {
173
+ setBubbleWidth(largestWidth.current)
174
+ largestWidth.current = 0
175
+ }
176
+ }}
177
+ {...touchableProps}
178
+ />
179
+ ))}
180
+ </View>
181
+ </ScrollView>
182
+ </View>
223
183
  )
184
+ }) as StyledComponentWithProps<SegmentedControlProps>
224
185
 
225
- })
186
+ SegmentedControl.styleRegistryName = 'SegmentedControl'
187
+ SegmentedControl.elements = ['wrapper', 'selectedBubble', 'innerWrapper', 'scroll', 'text', 'icon', 'button', 'label', 'badge']
188
+ SegmentedControl.rootElement = 'scroll'
226
189
 
227
- _SegmentedControl.defaultProps = {
228
- renderBubble: DefaultBubble,
229
- renderOption: SegmentedControlOption,
230
- touchableProps: {},
190
+ SegmentedControl.withVariantTypes = <S extends AnyRecord>(styles: S) => {
191
+ return SegmentedControl as (<T = string>(props: StyledComponentProps<SegmentedControlProps<T> & { ref?: React.Ref<SegmentedControlRef> }, typeof styles>) => IJSX)
231
192
  }
232
193
 
233
- type SegControlComponent = <T = string>(props: SegmentedControlProps<T> & { ref?: React.Ref<SegmentedControlRef> }) => ReactElement
194
+ SegmentedControl.defaultProps = {
195
+ renderBubble: DefaultBubble,
196
+ renderOption: SegmentedControlOption,
197
+ scrollToCurrentOptionOnMount: true,
198
+ } as Partial<SegmentedControlProps>
234
199
 
235
- export const SegmentedControl = _SegmentedControl as SegControlComponent
200
+ MobileStyleRegistry.registerComponent(SegmentedControl)
@@ -1,25 +1,25 @@
1
- import { createDefaultVariantFactory, includePresets, StylesOf } from '@codeleap/common'
1
+ import { StylesOf } from '@codeleap/common'
2
2
  import { BadgeComposition } from '../Badge'
3
- import { InputLabelComposition } from '../InputLabel'
4
3
  import { TouchableStylesGen } from '../Touchable'
5
4
 
6
5
  export type SegmentedControlStates = 'selected' | 'disabled'
7
6
 
8
7
  export type SegmentedControlComposition =
9
- 'selectedBubble' |
10
- 'wrapper' |
11
- 'innerWrapper' |
12
- 'scroll' |
13
- 'scrollContent' |
14
- 'text' |
15
- `text:${SegmentedControlStates}` |
16
- 'icon' |
17
- 'button' |
18
- 'buttonFeedback' |
19
- `button:${SegmentedControlStates}` |
8
+ 'selectedBubble' |
9
+ 'wrapper' |
10
+ 'innerWrapper' |
11
+ 'scroll' |
12
+ 'scrollContent' |
13
+ 'text' |
14
+ `text:${SegmentedControlStates}` |
15
+ 'icon' |
16
+ 'button' |
17
+ 'buttonFeedback' |
18
+ `button:${SegmentedControlStates}` |
20
19
  `selectedBubble:${SegmentedControlStates}` |
21
- `label${Capitalize<InputLabelComposition>}` |
22
- `badge${Capitalize<BadgeComposition>}`
20
+ 'labelText' |
21
+ 'labelWrapper' |
22
+ `badge${Capitalize<BadgeComposition>}`
23
23
 
24
24
  export type SegmentedControlStylesGen<TCSS = any> =
25
25
  StylesOf<
@@ -27,10 +27,3 @@ export type SegmentedControlStylesGen<TCSS = any> =
27
27
  > & {
28
28
  buttonFeedback?: TouchableStylesGen['feedback']
29
29
  }
30
-
31
- const createSegmentedControlStyle = createDefaultVariantFactory<
32
- SegmentedControlComposition,
33
- SegmentedControlStylesGen
34
- >()
35
-
36
- export const SegmentedControlPresets = includePresets((style) => createSegmentedControlStyle(() => ({ wrapper: style })))
@@ -0,0 +1,31 @@
1
+ import { ScrollProps, ScrollRef } from '../Scroll'
2
+ import { SegmentedControlOptionProps } from './Option'
3
+ import { TransitionConfig } from '../../utils'
4
+ import { TextProps } from '../Text'
5
+ import { TouchableProps } from '../Touchable'
6
+ import { FormTypes } from '@codeleap/common'
7
+ import { StyledProp } from '@codeleap/styles'
8
+ import { SegmentedControlComposition } from '../components'
9
+
10
+ export type SegmentedControlRef = ScrollRef & {
11
+ scrollTo: (index: number) => void
12
+ scrollToCurrent: () => void
13
+ }
14
+
15
+ export type SegmentedControlProps<T = string> =
16
+ Omit<ScrollProps, 'style'> &
17
+ {
18
+ options: SegmentedControlOptionProps[]
19
+ onValueChange: (value: T) => any
20
+ value: T
21
+ debugName: string
22
+ animation?: TransitionConfig
23
+ textProps?: Partial<TextProps>
24
+ touchableProps?: Partial<TouchableProps>
25
+ label?: FormTypes.Label
26
+ renderOption?: (props: SegmentedControlOptionProps) => JSX.Element
27
+ renderBubble?: (props: Partial<SegmentedControlProps>) => JSX.Element
28
+ getItemWidth?: (item: { label: string; value: T }, idx: number, arr: { label: string; value: T }[]) => number
29
+ scrollToCurrentOptionOnMount?: boolean
30
+ style?: StyledProp<SegmentedControlComposition>
31
+ }