@codeleap/mobile 1.2.1 → 1.4.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 (194) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.js +3 -0
  3. package/.vscode/settings.json +11 -0
  4. package/CodeLeap-Mobile-Packages.code-workspace +8 -0
  5. package/dist/components/ActivityIndicator.js +9 -6
  6. package/dist/components/ActivityIndicator.js.map +1 -1
  7. package/dist/components/Animated.d.ts +15 -0
  8. package/dist/components/Animated.js +55 -0
  9. package/dist/components/Animated.js.map +1 -0
  10. package/dist/components/Button.d.ts +107 -104
  11. package/dist/components/Button.js +30 -9
  12. package/dist/components/Button.js.map +1 -1
  13. package/dist/components/Checkbox/index.d.ts +1 -1
  14. package/dist/components/Checkbox/index.js +7 -8
  15. package/dist/components/Checkbox/index.js.map +1 -1
  16. package/dist/components/Checkbox/styles.d.ts +47 -43
  17. package/dist/components/Checkbox/styles.js +8 -8
  18. package/dist/components/Checkbox/styles.js.map +1 -1
  19. package/dist/components/ContentView.js +4 -2
  20. package/dist/components/ContentView.js.map +1 -1
  21. package/dist/components/FileInput.d.ts +26 -2
  22. package/dist/components/FileInput.js +151 -4
  23. package/dist/components/FileInput.js.map +1 -1
  24. package/dist/components/Icon.d.ts +4 -6
  25. package/dist/components/Icon.js +25 -11
  26. package/dist/components/Icon.js.map +1 -1
  27. package/dist/components/Image.d.ts +7 -6
  28. package/dist/components/Image.js +4 -4
  29. package/dist/components/Image.js.map +1 -1
  30. package/dist/components/List.d.ts +11 -0
  31. package/dist/components/List.js +77 -0
  32. package/dist/components/List.js.map +1 -0
  33. package/dist/components/Modal/index.d.ts +25 -0
  34. package/dist/components/Modal/index.js +109 -0
  35. package/dist/components/Modal/index.js.map +1 -0
  36. package/dist/components/Modal/styles.d.ts +66 -0
  37. package/dist/components/Modal/styles.js +57 -0
  38. package/dist/components/Modal/styles.js.map +1 -0
  39. package/dist/components/Navigation/Navigation.d.ts +3 -0
  40. package/dist/components/Navigation/Navigation.js +76 -0
  41. package/dist/components/Navigation/Navigation.js.map +1 -0
  42. package/dist/components/Navigation/constants.d.ts +5 -0
  43. package/dist/components/Navigation/constants.js +11 -0
  44. package/dist/components/Navigation/constants.js.map +1 -0
  45. package/dist/components/Navigation/index.d.ts +3 -0
  46. package/dist/components/Navigation/index.js +16 -0
  47. package/dist/components/Navigation/index.js.map +1 -0
  48. package/dist/components/Navigation/types.d.ts +26 -0
  49. package/dist/components/Navigation/types.js +8 -0
  50. package/dist/components/Navigation/types.js.map +1 -0
  51. package/dist/components/Navigation/utils.d.ts +3 -0
  52. package/dist/components/Navigation/utils.js +67 -0
  53. package/dist/components/Navigation/utils.js.map +1 -0
  54. package/dist/components/Overlay.d.ts +16 -0
  55. package/dist/components/Overlay.js +66 -0
  56. package/dist/components/Overlay.js.map +1 -0
  57. package/dist/components/Pager/index.d.ts +19 -0
  58. package/dist/components/Pager/index.js +164 -0
  59. package/dist/components/Pager/index.js.map +1 -0
  60. package/dist/components/Pager/styles.d.ts +51 -0
  61. package/dist/components/Pager/styles.js +44 -0
  62. package/dist/components/Pager/styles.js.map +1 -0
  63. package/dist/components/RadioInput/index.d.ts +1 -0
  64. package/dist/components/RadioInput/index.js +13 -19
  65. package/dist/components/RadioInput/index.js.map +1 -1
  66. package/dist/components/RadioInput/styles.d.ts +48 -44
  67. package/dist/components/RadioInput/styles.js +4 -4
  68. package/dist/components/RadioInput/styles.js.map +1 -1
  69. package/dist/components/Scroll.d.ts +3 -96
  70. package/dist/components/Scroll.js +11 -8
  71. package/dist/components/Scroll.js.map +1 -1
  72. package/dist/components/Sections.d.ts +11 -0
  73. package/dist/components/Sections.js +77 -0
  74. package/dist/components/Sections.js.map +1 -0
  75. package/dist/components/Select/index.d.ts +5 -2
  76. package/dist/components/Select/index.js +118 -5
  77. package/dist/components/Select/index.js.map +1 -1
  78. package/dist/components/Select/styles.d.ts +9 -0
  79. package/dist/components/Select/styles.js +57 -0
  80. package/dist/components/Select/styles.js.map +1 -0
  81. package/dist/components/Select/types.d.ts +33 -0
  82. package/dist/components/Select/types.js +3 -0
  83. package/dist/components/Select/types.js.map +1 -0
  84. package/dist/components/Slider/Mark.d.ts +3 -0
  85. package/dist/components/Slider/Mark.js +32 -0
  86. package/dist/components/Slider/Mark.js.map +1 -0
  87. package/dist/components/Slider/Thumb.d.ts +7 -0
  88. package/dist/components/Slider/Thumb.js +30 -0
  89. package/dist/components/Slider/Thumb.js.map +1 -0
  90. package/dist/components/Slider/index.d.ts +3 -0
  91. package/dist/components/Slider/index.js +94 -0
  92. package/dist/components/Slider/index.js.map +1 -0
  93. package/dist/components/{Slider.d.ts → Slider/types.d.ts} +12 -7
  94. package/dist/components/Slider/types.js +3 -0
  95. package/dist/components/Slider/types.js.map +1 -0
  96. package/dist/components/Switch.d.ts +2 -2
  97. package/dist/components/Switch.js +6 -7
  98. package/dist/components/Switch.js.map +1 -1
  99. package/dist/components/Text.js +5 -5
  100. package/dist/components/Text.js.map +1 -1
  101. package/dist/components/TextInput.d.ts +108 -94
  102. package/dist/components/TextInput.js +42 -35
  103. package/dist/components/TextInput.js.map +1 -1
  104. package/dist/components/Touchable.d.ts +9 -14
  105. package/dist/components/Touchable.js +11 -15
  106. package/dist/components/Touchable.js.map +1 -1
  107. package/dist/components/View.d.ts +105 -181
  108. package/dist/components/View.js +6 -8
  109. package/dist/components/View.js.map +1 -1
  110. package/dist/components/{index.d.ts → components.d.ts} +6 -0
  111. package/dist/components/{index.js → components.js} +7 -1
  112. package/dist/components/components.js.map +1 -0
  113. package/dist/index.d.ts +4 -1
  114. package/dist/index.js +7 -2
  115. package/dist/index.js.map +1 -1
  116. package/dist/modules/documentPicker.d.ts +3 -0
  117. package/dist/modules/documentPicker.js +12 -0
  118. package/dist/modules/documentPicker.js.map +1 -0
  119. package/dist/modules/fastImage.js +1 -1
  120. package/dist/modules/fastImage.js.map +1 -1
  121. package/dist/modules/reactNavigation.d.ts +3 -0
  122. package/dist/modules/reactNavigation.js +11 -0
  123. package/dist/modules/reactNavigation.js.map +1 -0
  124. package/dist/modules/types/fileTypes.d.ts +138 -0
  125. package/dist/modules/types/fileTypes.js +3 -0
  126. package/dist/modules/types/fileTypes.js.map +1 -0
  127. package/dist/types/utility.d.ts +1 -1
  128. package/dist/utils/OSAlert.d.ts +3 -3
  129. package/dist/utils/OSAlert.js.map +1 -1
  130. package/dist/utils/misc.d.ts +2 -0
  131. package/dist/utils/misc.js +26 -0
  132. package/dist/utils/misc.js.map +1 -0
  133. package/dist/utils/styles.js +1 -1
  134. package/dist/utils/styles.js.map +1 -1
  135. package/package.json +10 -4
  136. package/src/components/ActivityIndicator.tsx +38 -28
  137. package/src/components/Animated.tsx +34 -0
  138. package/src/components/Button.tsx +68 -34
  139. package/src/components/Checkbox/index.tsx +60 -48
  140. package/src/components/Checkbox/styles.ts +39 -30
  141. package/src/components/ContentView.tsx +24 -18
  142. package/src/components/FileInput.tsx +177 -5
  143. package/src/components/Icon.tsx +36 -23
  144. package/src/components/Image.tsx +41 -35
  145. package/src/components/List.tsx +100 -0
  146. package/src/components/Modal/index.tsx +158 -0
  147. package/src/components/Modal/styles.ts +118 -0
  148. package/src/components/Navigation/Navigation.tsx +51 -0
  149. package/src/components/Navigation/constants.ts +8 -0
  150. package/src/components/Navigation/index.tsx +3 -0
  151. package/src/components/Navigation/types.ts +37 -0
  152. package/src/components/Navigation/utils.tsx +54 -0
  153. package/src/components/Overlay.tsx +76 -0
  154. package/src/components/Pager/index.tsx +241 -0
  155. package/src/components/Pager/styles.ts +51 -0
  156. package/src/components/RadioInput/index.tsx +76 -52
  157. package/src/components/RadioInput/styles.ts +23 -18
  158. package/src/components/Scroll.tsx +84 -73
  159. package/src/components/Select/index.tsx +179 -6
  160. package/src/components/Select/styles.ts +81 -0
  161. package/src/components/Select/types.ts +41 -0
  162. package/src/components/Slider/Mark.tsx +46 -0
  163. package/src/components/Slider/Thumb.tsx +29 -0
  164. package/src/components/Slider/index.tsx +123 -0
  165. package/src/components/Slider/types.ts +25 -0
  166. package/src/components/Switch.tsx +63 -54
  167. package/src/components/Text.tsx +22 -23
  168. package/src/components/TextInput.tsx +194 -191
  169. package/src/components/Touchable.tsx +45 -35
  170. package/src/components/View.tsx +33 -40
  171. package/src/components/components.ts +26 -0
  172. package/src/index.ts +6 -2
  173. package/src/modules/documentPicker.ts +8 -0
  174. package/src/modules/fastImage.ts +2 -2
  175. package/src/modules/index.d.ts +496 -0
  176. package/src/modules/reactNavigation.ts +4 -0
  177. package/src/modules/types/documentPicker.d.ts +215 -0
  178. package/src/modules/types/fileTypes.ts +138 -0
  179. package/src/types/utility.ts +2 -2
  180. package/src/utils/OSAlert.ts +35 -33
  181. package/src/utils/misc.ts +24 -0
  182. package/src/utils/styles.ts +13 -16
  183. package/dist/components/Drawer.d.ts +0 -23
  184. package/dist/components/Drawer.js +0 -78
  185. package/dist/components/Drawer.js.map +0 -1
  186. package/dist/components/Navigation.d.ts +0 -30
  187. package/dist/components/Navigation.js +0 -126
  188. package/dist/components/Navigation.js.map +0 -1
  189. package/dist/components/Slider.js +0 -130
  190. package/dist/components/Slider.js.map +0 -1
  191. package/dist/components/index.js.map +0 -1
  192. package/src/components/Navigation.tsx +0 -125
  193. package/src/components/Slider.tsx +0 -198
  194. package/src/components/index.ts +0 -19
@@ -1,31 +1,30 @@
1
1
  import * as React from 'react'
2
2
  import { ComponentPropsWithoutRef, forwardRef } from 'react'
3
- import { ComponentVariants, useComponentStyle, BaseViewProps, TextStyles } from '@codeleap/common'
4
- import { Text as NativeText } from 'react-native'
3
+ import {
4
+ ComponentVariants,
5
+ useDefaultComponentStyle,
6
+ BaseViewProps,
7
+ TextStyles,
8
+ } from '@codeleap/common'
9
+ import { Text as NativeText } from 'react-native'
5
10
 
6
-
7
- export type TextProps =
8
- ComponentPropsWithoutRef<typeof NativeText> &
9
- {
10
- text?: string,
11
- variants?: ComponentVariants <typeof TextStyles>['variants'],
12
- } & BaseViewProps
11
+ export type TextProps = ComponentPropsWithoutRef<typeof NativeText> & {
12
+ text?: string;
13
+ variants?: ComponentVariants<typeof TextStyles>['variants'];
14
+ } & BaseViewProps;
13
15
 
14
16
  export const Text = forwardRef<NativeText, TextProps>((textProps, ref) => {
15
- const {
16
- variants = [],
17
- text,
18
- style,
19
- ...props
20
- } = textProps
21
-
22
- const variantStyles = useComponentStyle('Text', {
17
+ const { variants = [], text, style, ...props } = textProps
18
+
19
+ const variantStyles = useDefaultComponentStyle('Text', {
23
20
  variants,
24
- rootElement : 'text'
21
+ rootElement: 'text',
25
22
  })
26
-
23
+
27
24
  const styles = [variantStyles.text, style]
28
- return <NativeText {...props} style={styles} ref={ref}>
29
- {text}
30
- </NativeText>
31
- })
25
+ return (
26
+ <NativeText {...props} style={styles} ref={ref}>
27
+ {text}
28
+ </NativeText>
29
+ )
30
+ })
@@ -1,200 +1,203 @@
1
1
  import * as React from 'react'
2
- import {
3
- ComponentVariants,
4
- FormTypes,
5
- IconPlaceholder,
6
- TextInputComposition,
7
- TextInputStyles,
8
- useBooleanToggle,
9
- useComponentStyle,
10
- useValidate
11
- } from '@codeleap/common';
12
- import { ComponentPropsWithoutRef, forwardRef, useImperativeHandle, useRef, useState } from 'react'
13
- import { Text } from './Text';
14
- import { View } from './View';
15
- import { Button } from './Button';
16
- import { StylesOf } from '../types/utility';
17
- import { Icon } from './Icon';
18
- import {NativeSyntheticEvent, StyleSheet, TextInput as NativeTextInput, TextInputChangeEventData} from 'react-native'
19
- import { useLogStyles } from '../utils/styles';
20
-
21
- type IconProp = {name: IconPlaceholder, action?:() => void}
22
-
23
- type NativeProps = ComponentPropsWithoutRef<typeof NativeTextInput>
24
-
25
- export type TextInputProps =
26
- ComponentVariants<typeof TextInputStyles> &
27
- Omit<NativeProps, 'value'> &
28
- {
29
- multiline?: boolean;
30
- onChangeText?: (text: string) => void;
31
- disabled?: boolean;
32
- edited?: boolean;
33
- type?: string;
34
- label?:React.ReactNode
35
-
36
- leftIcon?:IconProp
37
- rightIcon?:IconProp
38
- styles?: StylesOf<TextInputComposition>
39
- validate?: FormTypes.ValidatorFunction | string
40
- value?:string
41
- password?:boolean
42
- visibilityToggle?: boolean
43
- };
44
-
45
- export const TextInput = forwardRef<NativeTextInput, TextInputProps>((rawprops, inputRef) => {
46
- const {
47
- onChange,
48
- type,
49
- value,
50
- onChangeText,
51
- disabled,
52
- edited,
53
- onFocus,
54
- onBlur,
55
- multiline,
56
- responsiveVariants,
57
- variants,
58
- label,
59
- leftIcon,
60
- rightIcon,
61
- styles,
62
- validate,
63
- password,
64
- visibilityToggle,
65
-
66
- ...props
67
- } = rawprops
68
-
69
- const [focused, setFocus] = useState(false)
70
- const [editedState, setEdited] = useState(edited)
71
-
72
- const input = useRef<any>(null)
73
- const [textIsVisible, setTextVisible] = useBooleanToggle(false)
74
- const variantStyles =useComponentStyle('TextInput', {
75
- variants,
76
- responsiveVariants,
77
- styles,
78
- transform: StyleSheet.flatten
79
- })
80
- const InputElement = NativeTextInput
81
-
82
- const handleBlur:TextInputProps['onBlur'] = (e) => {
83
- if (!editedState && value) setEdited(true)
84
- setFocus(false)
85
-
86
- if (onBlur) {
87
- onBlur(e)
88
- }
89
- }
90
-
91
- const handleFocus:TextInputProps['onFocus'] = (e) => {
92
- setFocus(true)
93
- if (onFocus) {
94
- onFocus(e)
95
- }
96
- }
97
-
98
- const handleChange = (event:NativeSyntheticEvent<TextInputChangeEventData>) => {
99
- const text = event.nativeEvent.text
100
-
101
- if (onChange) onChange(event)
102
- if (onChangeText) onChangeText(text)
103
- }
104
-
105
-
106
-
107
-
108
- useImperativeHandle(inputRef, () => input.current)
109
-
110
- const {showError, error} = useValidate(value, validate)
111
-
112
-
113
-
114
- function getStyles(k:TextInputComposition|TextInputComposition[]){
115
- let parts = k as string[]
116
- if(typeof k === 'string'){
117
- parts = [k]
118
- }
119
- const requestedStyles = parts.map(key => [
120
- variantStyles[key],
121
- showError ? variantStyles[key + ':error'] : {},
122
- focused ? variantStyles[key + ':focus'] : {}
123
- ])
2
+ import {
3
+ ComponentVariants,
4
+ FormTypes,
5
+ IconPlaceholder,
6
+ TextInputComposition,
7
+ TextInputStyles,
8
+ useBooleanToggle,
9
+ useDefaultComponentStyle,
10
+ useValidate,
11
+ } from '@codeleap/common'
12
+ import { ComponentPropsWithoutRef, forwardRef, useImperativeHandle, useRef, useState } from 'react'
13
+ import { Text } from './Text'
14
+ import { View, ViewProps } from './View'
15
+ import { Button } from './Button'
16
+ import { StylesOf } from '../types/utility'
17
+ import { Icon } from './Icon'
18
+ import { NativeSyntheticEvent, StyleSheet, TextInput as NativeTextInput, TextInputChangeEventData } from 'react-native'
19
+ import { Touchable, TouchableProps } from './Touchable'
124
20
 
125
- return StyleSheet.flatten(requestedStyles)
126
- }
21
+ type IconProp = { name: IconPlaceholder, action?: () => void }
22
+
23
+ type NativeProps = ComponentPropsWithoutRef<typeof NativeTextInput>
24
+
25
+ export type TextInputProps =
26
+ ComponentVariants<typeof TextInputStyles> &
27
+ Omit<NativeProps, 'value'> &
28
+ {
29
+ multiline?: boolean;
30
+ onChangeText?: (text: string) => void;
31
+ disabled?: boolean;
32
+ edited?: boolean;
33
+ type?: string;
34
+ label?: React.ReactNode
35
+
36
+ leftIcon?: IconProp
37
+ rightIcon?: IconProp
38
+ styles?: StylesOf<TextInputComposition>
39
+ validate?: FormTypes.ValidatorFunctionWithoutForm | string
40
+ value?: string
41
+ password?: boolean
42
+ visibilityToggle?: boolean
43
+ touchableWrapper?: boolean
44
+ innerWrapperProps?: TouchableProps | ViewProps
45
+ };
46
+
47
+ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((rawprops, inputRef) => {
48
+ const {
49
+ onChange,
50
+ type,
51
+ value,
52
+ onChangeText,
53
+ disabled,
54
+ edited,
55
+ onFocus,
56
+ onBlur,
57
+ multiline,
58
+ variants,
59
+ label,
60
+ leftIcon,
61
+ rightIcon,
62
+ styles,
63
+ validate,
64
+ password,
65
+ visibilityToggle,
66
+ touchableWrapper,
67
+ innerWrapperProps,
68
+ ...props
69
+ } = rawprops
127
70
 
128
- return (
129
- <View
130
- style={getStyles('wrapper')}
131
- >
132
- <InputLabel label={label} style={getStyles('label')}/>
133
-
134
- <View style={getStyles('innerWrapper')}>
135
-
136
-
137
- <InputIcon {...leftIcon} style={getStyles(['icon','leftIcon'])}/>
138
- <InputElement
139
- ref={input}
140
- secureTextEntry={password && !textIsVisible}
141
- onChange={handleChange}
142
- value={value}
143
- editable={disabled}
144
- onFocus={handleFocus}
145
- onBlur={handleBlur}
146
- {...props}
147
- style={getStyles('textField')}
148
- />
149
- {
150
- visibilityToggle ?
151
- <InputIcon name={
152
- (textIsVisible ? 'input-visiblity:visible' : 'input-visiblity:hidden') as IconPlaceholder
153
- } action={() => setTextVisible()} style={getStyles(['icon','rightIcon'])}/>
154
- :
155
- <InputIcon {...rightIcon} style={getStyles(['icon','rightIcon'])}/>
156
- }
157
- </View>
158
-
159
- <FormError message={error.message} style={getStyles(['error'])}/>
160
-
161
-
162
- </View>
163
- )
71
+ const [isFocused, setFocus] = useState(false)
72
+ const [editedState, setEdited] = useState(edited)
73
+
74
+ const input = useRef<any>(null)
75
+ const [textIsVisible, setTextVisible] = useBooleanToggle(false)
76
+ const variantStyles = useDefaultComponentStyle('TextInput', {
77
+ variants,
78
+ styles,
164
79
  })
165
-
166
- export const FormError = ({message, ...props}) => {
167
-
168
-
169
- if (['number', 'string', 'undefined'].includes(typeof message)){
170
- return <Text text={`${message||' '}`} variants={['p2', 'marginTop:1']} {...props}/>
80
+ const InputElement = NativeTextInput
81
+
82
+ const handleBlur: TextInputProps['onBlur'] = (e) => {
83
+ if (!editedState && value) setEdited(true)
84
+ setFocus(false)
85
+
86
+ if (onBlur) {
87
+ onBlur(e)
171
88
  }
172
- return message
173
89
  }
174
- export const InputIcon:React.FC<{style:any} & IconProp> = ({name, style, action}) => {
175
- if (!name) return null
176
-
177
- if (action){
178
-
179
- return <Button icon={name} onPress={() => action()} styles={{
180
- icon: style,
181
- }} variants={['icon']}/>
182
-
90
+
91
+ const handleFocus: TextInputProps['onFocus'] = (e) => {
92
+ setFocus(true)
93
+ if (onFocus) {
94
+ onFocus(e)
183
95
  }
184
-
185
- return <Icon name={name} style={style}/>
186
96
  }
187
- export const InputLabel = ({label, style}) => {
188
- if (!label) return null
189
-
190
- switch (typeof label){
191
- case 'string':
192
- return <Text variants={['p2']} style={style} text={label}/>
193
- case 'object':
194
-
195
- return label
196
- default:
197
- return null
198
- }
97
+
98
+ const handleChange = (event: NativeSyntheticEvent<TextInputChangeEventData>) => {
99
+ const text = event.nativeEvent.text
100
+
101
+ if (onChange) onChange(event)
102
+ if (onChangeText) onChangeText(text)
103
+ }
104
+
105
+ useImperativeHandle(inputRef, () => ({...input.current, focus: () => {
106
+ input.current?.focus?.()
107
+ }, isTextInput: true}))
108
+
109
+ const { showError, error } = useValidate(value, validate)
110
+
111
+ const leftIconStyle = {
112
+ ...variantStyles.icon,
113
+ ...(isFocused ? variantStyles['icon:focus'] : {}),
114
+ ...(showError ? variantStyles['icon:error'] : {}),
115
+ ...variantStyles.leftIcon,
116
+ ...(isFocused ? variantStyles['leftIcon:focus'] : {}),
117
+ ...(showError ? variantStyles['leftIcon:error'] : {}),
118
+ }
119
+
120
+ const rightIconStyle = {
121
+ ...variantStyles.icon,
122
+ ...(isFocused ? variantStyles['icon:focus'] : {}),
123
+ ...(showError ? variantStyles['icon:error'] : {}),
124
+ ...variantStyles.rightIcon,
125
+ ...(isFocused ? variantStyles['rightIcon:focus'] : {}),
126
+ ...(showError ? variantStyles['rightIcon:error'] : {}),
127
+ }
128
+
129
+ function getStyles(key: TextInputComposition) {
130
+ const requestedStyles = [
131
+ variantStyles[key],
132
+ isFocused ? variantStyles[key + ':focus'] : {},
133
+ showError ? variantStyles[key + ':error'] : {},
134
+ ]
135
+ return requestedStyles
136
+ }
137
+
138
+ const InnerWrapper = touchableWrapper ? Touchable : View
139
+
140
+ return (
141
+ <View
142
+ style={getStyles('wrapper')}
143
+ >
144
+ <InputLabel label={label} style={getStyles('label')} />
145
+ <InnerWrapper style={getStyles('innerWrapper')} {...innerWrapperProps}>
146
+ <InputIcon {...leftIcon} style={leftIconStyle} />
147
+ <InputElement
148
+ ref={input}
149
+ secureTextEntry={password && !textIsVisible}
150
+ onChange={handleChange}
151
+ value={value}
152
+ editable={disabled}
153
+ onFocus={handleFocus}
154
+ onBlur={handleBlur}
155
+ placeholderTextColor={StyleSheet.flatten(getStyles('placeholder'))?.color}
156
+ {...props}
157
+ style={getStyles('textField')}
158
+ />
159
+ {
160
+ visibilityToggle ?
161
+ <InputIcon name={
162
+ (textIsVisible ? 'input-visiblity:visible' : 'input-visiblity:hidden') as IconPlaceholder
163
+ } action={() => setTextVisible()} style={rightIconStyle} />
164
+ :
165
+ <InputIcon {...rightIcon} style={rightIconStyle} />
166
+ }
167
+ </InnerWrapper>
168
+ <FormError message={error.message} style={{
169
+ ...variantStyles.error,
170
+ }} />
171
+ </View>
172
+ )
173
+ })
174
+
175
+ export const FormError = ({ message, ...props }) => {
176
+ if (['number', 'string', 'undefined'].includes(typeof message)) {
177
+ return <Text text={`${message || ' '}`} variants={['p2', 'marginTop:1']} {...props} />
178
+ }
179
+ return message
180
+ }
181
+
182
+ export const InputIcon: React.FC<{ style: any } & IconProp> = ({ name, style, action }) => {
183
+ if (!name) return null
184
+ if (action) {
185
+ return <Button icon={name} onPress={() => action()} styles={{
186
+ icon: style,
187
+ }} variants={['icon']} />
188
+ }
189
+ return <Icon name={name} style={style} />
190
+ }
191
+
192
+ export const InputLabel = ({ label, style }) => {
193
+ if (!label) return null
194
+
195
+ switch (typeof label) {
196
+ case 'string':
197
+ return <Text style={style} text={label} />
198
+ case 'object':
199
+ return label
200
+ default:
201
+ return null
199
202
  }
200
-
203
+ }
@@ -1,54 +1,64 @@
1
1
  import * as React from 'react'
2
2
  import { ComponentPropsWithoutRef, forwardRef } from 'react'
3
- import { ComponentVariants, useComponentStyle, BaseViewProps, ViewStyles, useStyle } from '@codeleap/common'
4
- import { View } from './View'
5
- import { Animated, TouchableOpacity as NativeTouchable } from 'react-native'
3
+ import {
4
+ ComponentVariants,
5
+ useDefaultComponentStyle,
6
+ BaseViewProps,
7
+ ViewStyles,
8
+ useCodeleapContext,
9
+ AnyFunction,
10
+ } from '@codeleap/common'
11
+ import { TouchableOpacity as NativeTouchable } from 'react-native'
6
12
 
7
- export type TouchableProps =
8
- ComponentPropsWithoutRef<typeof NativeTouchable> &
9
- {
10
- variants?: ComponentVariants <typeof ViewStyles>['variants'],
11
- component?: any
12
- } & BaseViewProps
13
+ import { createAnimatableComponent } from 'react-native-animatable'
14
+ export type TouchableProps = Omit<
15
+ ComponentPropsWithoutRef<typeof NativeTouchable>,
16
+ 'onPress'
17
+ > & {
18
+ variants?: ComponentVariants<typeof ViewStyles>['variants'];
19
+ component?: any;
20
+ ref?: React.Ref<NativeTouchable>;
21
+ debugName?: string;
22
+ debugComponent?: string;
23
+ onPress?: AnyFunction;
24
+ } & BaseViewProps;
13
25
 
14
- export const Touchable = forwardRef<NativeTouchable, TouchableProps>((touchableProps, ref) => {
15
- const {
26
+ export const Touchable: React.FC<TouchableProps> = forwardRef<
27
+ NativeTouchable,
28
+ TouchableProps
29
+ >((touchableProps, ref) => {
30
+ const {
16
31
  variants = [],
17
32
  children,
18
33
  onPress,
19
34
  style,
35
+ debugName,
36
+ debugComponent,
20
37
  ...props
21
38
  } = touchableProps
22
-
23
- const variantStyles = useComponentStyle('View', {
39
+
40
+ const variantStyles = useDefaultComponentStyle('View', {
24
41
  variants,
25
42
  })
26
- const {logger} = useStyle()
43
+
44
+ const { logger } = useCodeleapContext()
27
45
  const press = () => {
28
- if(!onPress) throw {message: 'No onPress passed to touchable', touchableProps}
29
- logger.log('<Touchable/> pressed', { style, variants }, 'Component')
30
- onPress(null)
46
+ if (!onPress) { throw { message: 'No onPress passed to touchable', touchableProps } }
47
+ logger.log(
48
+ `<${debugComponent || 'Touchable'}/> pressed`,
49
+ { debugName, style, variants },
50
+ 'User interaction',
51
+ )
52
+ onPress && onPress()
31
53
  }
32
-
54
+
33
55
  const styles = [variantStyles.wrapper, style]
34
56
 
35
- return <NativeTouchable onPress={press} {...props} ref={ref}>
36
- <View style={styles}>
57
+ return (
58
+ <NativeTouchable onPress={press} style={styles} {...props} ref={ref}>
37
59
  {children}
38
- </View>
39
- </NativeTouchable>
60
+ </NativeTouchable>
61
+ )
40
62
  })
41
63
 
42
- export type AnimatedTouchableProps =
43
- ComponentPropsWithoutRef<typeof Animated.View> &
44
- TouchableProps
45
-
46
- export const AnimatedTouchable = forwardRef<typeof Animated.View, AnimatedTouchableProps>((viewProps, ref) => {
47
- // @ts-ignore
48
- return <Touchable
49
- component={Animated.View}
50
-
51
- {...viewProps}
52
- />
53
-
54
- })
64
+ export const AnimatedTouchable = createAnimatableComponent(Touchable)
@@ -1,53 +1,46 @@
1
- import * as React from 'react';
1
+ import * as React from 'react'
2
+ import * as Animatable from 'react-native-animatable'
2
3
  import { ComponentPropsWithoutRef, forwardRef } from 'react'
3
- import { ComponentVariants, useComponentStyle, ViewStyles, BaseViewProps } from '@codeleap/common'
4
- import { Animated, View as NativeView } from 'react-native'
4
+ import {
5
+ ComponentVariants,
6
+ useDefaultComponentStyle,
7
+ ViewStyles,
8
+ BaseViewProps,
9
+ } from '@codeleap/common'
10
+ import { View as NativeView, ViewStyle } from 'react-native'
5
11
 
6
- export type ViewProps =
7
- ComponentPropsWithoutRef<typeof NativeView> &
8
- ComponentVariants<typeof ViewStyles> & {
9
-
10
- component?: any
11
- } & BaseViewProps
12
+ export type ViewProps = ComponentPropsWithoutRef<typeof NativeView> &
13
+ ComponentVariants<typeof ViewStyles> & {
14
+ ref?: any;
15
+ component?: any;
16
+ } & BaseViewProps;
12
17
 
13
-
14
- export const View = forwardRef<NativeView, ViewProps>((viewProps, ref) => {
15
- const {
16
- responsiveVariants = {},
17
- variants = [],
18
+ export const View: React.FC<ViewProps> = forwardRef<NativeView, ViewProps>((viewProps, ref) => {
19
+ const {
20
+ responsiveVariants = {},
21
+ variants = [],
18
22
  children,
19
23
  style,
20
24
  onHover,
21
25
  component,
22
26
  ...props
23
- } = viewProps;
24
-
25
- const variantStyles = useComponentStyle('View', {
27
+ } = viewProps
28
+
29
+ const variantStyles = useDefaultComponentStyle('View', {
26
30
  responsiveVariants,
27
31
  variants,
28
- });
29
- const Component = component|| NativeView
32
+ })
33
+ const Component = component || NativeView
30
34
 
31
- return <Component
32
-
33
- style={[variantStyles.wrapper, style]}
34
- ref={ref}
35
- {...props}
36
- >
37
- {children}
38
- </Component>
35
+ return (
36
+ <Component style={[variantStyles.wrapper, style]} ref={ref} {...props}>
37
+ {children}
38
+ </Component>
39
+ )
39
40
  })
40
41
 
41
- export type AnimatedViewProps =
42
- ComponentPropsWithoutRef<typeof Animated.View> &
43
- ComponentVariants<typeof ViewStyles> & BaseViewProps
44
-
45
- export const AnimatedView = forwardRef<typeof Animated.View, AnimatedViewProps>((viewProps, ref) => {
46
- // @ts-ignore
47
- return <View
48
- component={Animated.View}
49
-
50
- {...viewProps}
51
- />
52
-
53
- })
42
+ export const AnimatedView = Animatable.createAnimatableComponent(
43
+ View,
44
+ ) as unknown as React.ForwardRefExoticComponent<
45
+ { transition?: any; animation?: any } & ViewProps
46
+ >
@@ -0,0 +1,26 @@
1
+ export * from './View'
2
+ export * from './Animated'
3
+ export * from './Icon'
4
+ export * from './Touchable'
5
+ export * from './Text'
6
+ export * from './Image'
7
+ export * from './Checkbox'
8
+ export * from './TextInput'
9
+ export * from './RadioInput'
10
+ export * from './Switch'
11
+ export * from './ContentView'
12
+
13
+ export * from './Select'
14
+ export * from './FileInput'
15
+ export * from './Slider'
16
+ export * from './Navigation'
17
+ export * from './Scroll'
18
+ export * from './List'
19
+ export * from './ActivityIndicator'
20
+ export * from './Button'
21
+ export * from './ContentView'
22
+ export * from './Overlay'
23
+ export * from './Modal'
24
+
25
+ export * from './Navigation'
26
+ export * from './Pager'
package/src/index.ts CHANGED
@@ -1,2 +1,6 @@
1
- export * from './components'
2
- export {default as OSAlert } from './utils/OSAlert'
1
+ export * from './components/components'
2
+ export { default as OSAlert } from './utils/OSAlert'
3
+ export { default as posed } from 'react-native-pose'
4
+ export { Linking } from 'react-native'
5
+ export * from './utils/misc'
6
+
@@ -0,0 +1,8 @@
1
+ // @ts-ignore
2
+ import DP from 'react-native-document-picker'
3
+ import * as DocumentPickerTypes from './types/documentPicker'
4
+
5
+
6
+ export const DocumentPicker = DP as DocumentPickerTypes.DocumentPicker
7
+
8
+ export {default as ImageCropPicker} from 'react-native-image-crop-picker'
@@ -1,2 +1,2 @@
1
- // @ts-ignore
2
- export {default as FastImage} from 'react-native-fast-image'
1
+ // @ts-ignore
2
+ export { default as FastImage } from 'react-native-fast-image'