@codeleap/mobile 2.0.6 → 2.1.1
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/dist/components/Button/index.js +1 -1
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Button/styles.js +1 -4
- package/dist/components/Button/styles.js.map +1 -1
- package/dist/components/Checkbox/index.js +19 -16
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Checkbox/styles.d.ts +2 -1
- package/dist/components/Checkbox/styles.js +3 -6
- package/dist/components/Checkbox/styles.js.map +1 -1
- package/dist/components/ContentView/index.d.ts +1 -1
- package/dist/components/ContentView/index.js +2 -2
- package/dist/components/ContentView/index.js.map +1 -1
- package/dist/components/ContentView/styles.js +3 -3
- package/dist/components/ContentView/styles.js.map +1 -1
- package/dist/components/EmptyPlaceholder/index.d.ts +1 -1
- package/dist/components/FileInput/index.d.ts +2 -11
- package/dist/components/FileInput/index.js +2 -30
- package/dist/components/FileInput/index.js.map +1 -1
- package/dist/components/InputLabel/index.d.ts +12 -0
- package/dist/components/InputLabel/index.js +62 -0
- package/dist/components/InputLabel/index.js.map +1 -0
- package/dist/components/InputLabel/styles.d.ts +4 -0
- package/dist/components/InputLabel/styles.js +26 -0
- package/dist/components/InputLabel/styles.js.map +1 -0
- package/dist/components/RadioInput/index.d.ts +1 -0
- package/dist/components/RadioInput/index.js +5 -4
- package/dist/components/RadioInput/index.js.map +1 -1
- package/dist/components/RadioInput/styles.d.ts +2 -1
- package/dist/components/RadioInput/styles.js.map +1 -1
- package/dist/components/SegmentedControl/index.d.ts +2 -1
- package/dist/components/SegmentedControl/index.js +8 -14
- package/dist/components/SegmentedControl/index.js.map +1 -1
- package/dist/components/SegmentedControl/styles.d.ts +2 -1
- package/dist/components/SegmentedControl/styles.js.map +1 -1
- package/dist/components/Slider/index.js +6 -5
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Slider/styles.d.ts +2 -1
- package/dist/components/Slider/styles.js.map +1 -1
- package/dist/components/Switch/index.js +6 -1
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Switch/styles.d.ts +2 -1
- package/dist/components/Switch/styles.js +1 -1
- package/dist/components/Switch/styles.js.map +1 -1
- package/dist/components/TextInput/index.d.ts +0 -1
- package/dist/components/TextInput/index.js +7 -5
- package/dist/components/TextInput/index.js.map +1 -1
- package/dist/components/TextInput/styles.d.ts +2 -1
- package/dist/components/TextInput/styles.js +3 -6
- package/dist/components/TextInput/styles.js.map +1 -1
- package/dist/components/Touchable/index.js +7 -5
- package/dist/components/Touchable/index.js.map +1 -1
- package/dist/components/components.d.ts +1 -0
- package/dist/components/components.js +1 -0
- package/dist/components/components.js.map +1 -1
- package/dist/components/defaultStyles.d.ts +3 -0
- package/dist/components/defaultStyles.js +2 -0
- package/dist/components/defaultStyles.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/index.tsx +1 -1
- package/src/components/Button/styles.ts +1 -0
- package/src/components/Checkbox/index.tsx +19 -18
- package/src/components/Checkbox/styles.ts +7 -7
- package/src/components/ContentView/index.tsx +3 -3
- package/src/components/ContentView/styles.ts +2 -3
- package/src/components/EmptyPlaceholder/index.tsx +1 -1
- package/src/components/FileInput/index.tsx +6 -52
- package/src/components/InputLabel/index.tsx +38 -0
- package/src/components/InputLabel/styles.ts +19 -0
- package/src/components/RadioInput/index.tsx +7 -3
- package/src/components/RadioInput/styles.ts +2 -1
- package/src/components/SegmentedControl/index.tsx +9 -3
- package/src/components/SegmentedControl/styles.ts +3 -1
- package/src/components/Slider/index.tsx +12 -7
- package/src/components/Slider/styles.ts +2 -1
- package/src/components/Switch/index.tsx +7 -2
- package/src/components/Switch/styles.ts +3 -2
- package/src/components/TextInput/index.tsx +6 -9
- package/src/components/TextInput/styles.ts +8 -11
- package/src/components/Touchable/index.tsx +8 -6
- package/src/components/components.ts +1 -0
- package/src/components/defaultStyles.ts +2 -0
- package/src/components/TextInput/Label.tsx +0 -26
|
@@ -9,14 +9,15 @@ import {
|
|
|
9
9
|
PropsOf,
|
|
10
10
|
} from '@codeleap/common'
|
|
11
11
|
import { ComponentPropsWithRef, forwardRef, ReactNode } from 'react'
|
|
12
|
-
import { Switch as NativeCheckbox } from 'react-native'
|
|
13
|
-
import {
|
|
12
|
+
import { StyleSheet, Switch as NativeCheckbox } from 'react-native'
|
|
13
|
+
import { FormError } from '../TextInput'
|
|
14
14
|
import { View } from '../View'
|
|
15
15
|
import { Touchable } from '../Touchable'
|
|
16
16
|
import {
|
|
17
17
|
CheckboxStyles,
|
|
18
18
|
CheckboxComposition,
|
|
19
19
|
} from './styles'
|
|
20
|
+
import { InputLabel } from '../InputLabel'
|
|
20
21
|
export * from './styles'
|
|
21
22
|
|
|
22
23
|
type NativeCheckboxProps = Omit<
|
|
@@ -45,29 +46,25 @@ export const Checkbox = forwardRef<GetRefType<PropsOf<typeof View>['ref']>, Chec
|
|
|
45
46
|
...props
|
|
46
47
|
} = checkboxProps
|
|
47
48
|
|
|
48
|
-
const variantStyles = useDefaultComponentStyle('Checkbox', {
|
|
49
|
-
// @ts-ignore
|
|
49
|
+
const variantStyles = useDefaultComponentStyle<'u:Checkbox', typeof CheckboxStyles>('u:Checkbox', {
|
|
50
50
|
variants,
|
|
51
|
+
styles,
|
|
52
|
+
transform: StyleSheet.flatten,
|
|
51
53
|
})
|
|
52
54
|
|
|
53
55
|
const { error, showError } = useValidate(value, validate)
|
|
54
56
|
|
|
55
|
-
function getStyles(key: CheckboxComposition) {
|
|
57
|
+
function getStyles(key: CheckboxComposition, styleObj = variantStyles) {
|
|
56
58
|
return [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
key
|
|
60
|
-
|
|
61
|
-
value ? styles[key + ':checked'] : {},
|
|
62
|
-
showError ? variantStyles[key + ':error'] : {},
|
|
63
|
-
showError ? styles[key + ':error'] : {},
|
|
64
|
-
checkboxProps.disabled ? variantStyles[key + ':disabled'] : {},
|
|
65
|
-
checkboxProps.disabled ? styles[key + ':disabled'] : {},
|
|
59
|
+
styleObj[key],
|
|
60
|
+
value ? styleObj[key + ':checked'] : {},
|
|
61
|
+
showError ? styleObj[key + ':error'] : {},
|
|
62
|
+
checkboxProps.disabled ? styleObj[key + ':disabled'] : {},
|
|
66
63
|
]
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
return (
|
|
70
|
-
<View style={getStyles('wrapper')} ref={ref} {...props}>
|
|
67
|
+
<View style={[getStyles('wrapper'), style]} ref={ref} {...props}>
|
|
71
68
|
<Touchable
|
|
72
69
|
debugName={`Set checkbox value to ${!value}`}
|
|
73
70
|
style={getStyles('input')}
|
|
@@ -79,9 +76,13 @@ export const Checkbox = forwardRef<GetRefType<PropsOf<typeof View>['ref']>, Chec
|
|
|
79
76
|
<View style={getStyles('checkmarkWrapper')}>
|
|
80
77
|
<View style={getStyles('checkmark')} />
|
|
81
78
|
</View>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
|
|
80
|
+
<InputLabel label={label} styles={{
|
|
81
|
+
asterisk: getStyles('labelAsterisk'),
|
|
82
|
+
wrapper: getStyles('labelWrapper'),
|
|
83
|
+
text: getStyles('labelText'),
|
|
84
|
+
}} required={required}/>
|
|
85
|
+
|
|
85
86
|
</Touchable>
|
|
86
87
|
<FormError text={error.message} style={getStyles('error')} />
|
|
87
88
|
</View>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
|
|
2
|
+
import { InputLabelComposition } from '../InputLabel'
|
|
2
3
|
|
|
3
4
|
type CheckboxParts =
|
|
4
5
|
| 'wrapper'
|
|
5
|
-
| 'label'
|
|
6
|
-
| 'labelWrapper'
|
|
7
6
|
| 'input'
|
|
8
7
|
| 'inputFeedback'
|
|
9
8
|
| 'checkmark'
|
|
10
9
|
| 'checkmarkWrapper'
|
|
11
10
|
| 'error'
|
|
11
|
+
| `label${Capitalize<InputLabelComposition>}`
|
|
12
12
|
|
|
13
13
|
export type CheckboxComposition =
|
|
14
14
|
| CheckboxParts
|
|
@@ -36,18 +36,17 @@ export const CheckboxStyles = {
|
|
|
36
36
|
input: {
|
|
37
37
|
flexDirection: 'row',
|
|
38
38
|
...theme.presets.alignCenter,
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
},
|
|
41
41
|
labelWrapper: {
|
|
42
|
-
flex: 1,
|
|
42
|
+
// flex: 1,
|
|
43
|
+
...theme.spacing.marginLeft(1),
|
|
44
|
+
|
|
43
45
|
},
|
|
44
46
|
inputFeedback: {
|
|
45
47
|
type: 'opacity',
|
|
46
48
|
value: 0.5,
|
|
47
49
|
},
|
|
48
|
-
label: {
|
|
49
|
-
...theme.spacing.marginLeft(0.5),
|
|
50
|
-
},
|
|
51
50
|
|
|
52
51
|
checkmark: {
|
|
53
52
|
position: 'absolute',
|
|
@@ -67,6 +66,7 @@ export const CheckboxStyles = {
|
|
|
67
66
|
checkmarkWrapper: {
|
|
68
67
|
position: 'relative',
|
|
69
68
|
width: size,
|
|
69
|
+
borderRadius: theme.borderRadius.small,
|
|
70
70
|
height: size,
|
|
71
71
|
...theme.border.neutral(1),
|
|
72
72
|
},
|
|
@@ -20,7 +20,7 @@ export type ContentViewProps = Omit<
|
|
|
20
20
|
ViewProps,
|
|
21
21
|
'variants' | 'responsiveVariants'
|
|
22
22
|
> & {
|
|
23
|
-
|
|
23
|
+
message?: string
|
|
24
24
|
loading?: boolean
|
|
25
25
|
styles?: StylesOf<ViewComposition>
|
|
26
26
|
} & ComponentVariants<typeof ContentViewStyles>
|
|
@@ -30,7 +30,7 @@ const WrapContent = ({ children, ...props }) => (
|
|
|
30
30
|
)
|
|
31
31
|
|
|
32
32
|
export const ContentView: React.FC<ContentViewProps> = (rawProps) => {
|
|
33
|
-
const { children,
|
|
33
|
+
const { children, message, loading, variants, styles, ...props } =
|
|
34
34
|
rawProps
|
|
35
35
|
|
|
36
36
|
const variantStyle = useDefaultComponentStyle('ContentView', {
|
|
@@ -57,7 +57,7 @@ export const ContentView: React.FC<ContentViewProps> = (rawProps) => {
|
|
|
57
57
|
|
|
58
58
|
return (
|
|
59
59
|
<WrapContent {...props} style={styles}>
|
|
60
|
-
<Text text={
|
|
60
|
+
<Text text={message} />
|
|
61
61
|
</WrapContent>
|
|
62
62
|
)
|
|
63
63
|
}
|
|
@@ -14,12 +14,11 @@ export const ContentViewStyles = {
|
|
|
14
14
|
wrapper: {
|
|
15
15
|
display: 'flex',
|
|
16
16
|
...theme.presets.column,
|
|
17
|
-
...theme.presets.alignCenter,
|
|
18
17
|
},
|
|
19
18
|
loader: {
|
|
20
19
|
alignSelf: 'center',
|
|
21
|
-
height:
|
|
22
|
-
width:
|
|
20
|
+
height: theme.values.width * 0.15,
|
|
21
|
+
width: theme.values.width * 0.15,
|
|
23
22
|
},
|
|
24
23
|
})),
|
|
25
24
|
}
|
|
@@ -23,7 +23,7 @@ export * from './styles'
|
|
|
23
23
|
|
|
24
24
|
export type EmptyPlaceholderProps = {
|
|
25
25
|
itemName?: string
|
|
26
|
-
title?:
|
|
26
|
+
title?: React.ReactElement
|
|
27
27
|
loading?: boolean
|
|
28
28
|
styles?: StylesOf<EmptyPlaceholderComposition>
|
|
29
29
|
variants?: ComponentVariants<typeof EmptyPlaceholderStyles>['variants']
|
|
@@ -1,45 +1,28 @@
|
|
|
1
1
|
import React, { forwardRef, useImperativeHandle } from 'react'
|
|
2
2
|
import { DocumentPicker, ImageCropPicker } from '../../modules/documentPicker'
|
|
3
3
|
import {
|
|
4
|
-
ComponentVariants,
|
|
5
|
-
|
|
6
|
-
IconPlaceholder,
|
|
7
4
|
MobileInputFile,
|
|
8
5
|
parseFilePathData,
|
|
9
|
-
useDefaultComponentStyle,
|
|
10
6
|
useCodeleapContext,
|
|
11
7
|
MobileFile,
|
|
12
8
|
} from '@codeleap/common'
|
|
13
|
-
import { StylesOf } from '../../types'
|
|
14
|
-
import { Button, ButtonProps } from '../Button'
|
|
15
|
-
import { View } from '../View'
|
|
16
|
-
import { InputLabel } from '../TextInput'
|
|
17
9
|
import { OSAlert } from '../../utils'
|
|
18
10
|
import { Options } from 'react-native-image-crop-picker'
|
|
19
11
|
import { DocumentPickerOptions } from '../../modules/types/documentPicker'
|
|
20
12
|
|
|
21
13
|
export * from './styles'
|
|
22
14
|
|
|
23
|
-
import {
|
|
24
|
-
FileInputComposition,
|
|
25
|
-
FileInputStyles,
|
|
26
|
-
} from './styles'
|
|
27
|
-
|
|
28
15
|
export type FileInputRef = {
|
|
29
16
|
openFilePicker: (string?: 'camera' | 'library') => void
|
|
30
17
|
}
|
|
31
18
|
|
|
32
19
|
export type FileInputProps = {
|
|
33
|
-
label?: string
|
|
34
|
-
iconName?: IconPlaceholder
|
|
35
|
-
styles?: StylesOf<FileInputComposition>
|
|
36
20
|
mode: 'hidden' | 'button'
|
|
37
|
-
variants?: ComponentVariants<typeof FileInputStyles>['variants']
|
|
38
21
|
onFileSelect(files: MobileInputFile[]): void
|
|
39
22
|
options?: DocumentPickerOptions<any>
|
|
40
|
-
|
|
23
|
+
|
|
41
24
|
ref?: FileInputRef
|
|
42
|
-
|
|
25
|
+
|
|
43
26
|
type?: 'image' | 'anyFile'
|
|
44
27
|
alertProps?: Parameters<typeof OSAlert.ask>[0]
|
|
45
28
|
pickerOptions?: Partial<Options>
|
|
@@ -76,27 +59,21 @@ export const FileInput = forwardRef<
|
|
|
76
59
|
FileInputProps
|
|
77
60
|
>((fileInputProps, ref) => {
|
|
78
61
|
const {
|
|
79
|
-
|
|
62
|
+
|
|
80
63
|
onFileSelect,
|
|
81
|
-
|
|
82
|
-
styles,
|
|
83
|
-
label,
|
|
84
|
-
variants,
|
|
64
|
+
|
|
85
65
|
options,
|
|
86
66
|
type = 'image',
|
|
87
67
|
alertProps,
|
|
88
|
-
|
|
68
|
+
|
|
89
69
|
pickerOptions,
|
|
90
|
-
|
|
91
|
-
buttonProps,
|
|
70
|
+
|
|
92
71
|
onOpenCamera = null,
|
|
93
72
|
onOpenGallery = null,
|
|
94
73
|
onOpenFileSystem = null,
|
|
95
74
|
onError,
|
|
96
75
|
} = fileInputProps
|
|
97
76
|
|
|
98
|
-
const [file, setFile] = React.useState(null)
|
|
99
|
-
|
|
100
77
|
const { logger } = useCodeleapContext()
|
|
101
78
|
|
|
102
79
|
async function openFileSystem() {
|
|
@@ -105,7 +82,6 @@ export const FileInput = forwardRef<
|
|
|
105
82
|
if (!Array.isArray(files)) {
|
|
106
83
|
files = [files]
|
|
107
84
|
}
|
|
108
|
-
setFile(files)
|
|
109
85
|
onFileSelect(files.map((file) => ({ preview: file.uri, file })))
|
|
110
86
|
} catch (err) {
|
|
111
87
|
handleError(err)
|
|
@@ -191,31 +167,9 @@ export const FileInput = forwardRef<
|
|
|
191
167
|
|
|
192
168
|
}
|
|
193
169
|
|
|
194
|
-
const variantStyles = useDefaultComponentStyle('FileInput', {
|
|
195
|
-
styles,
|
|
196
|
-
variants,
|
|
197
|
-
})
|
|
198
|
-
|
|
199
170
|
useImperativeHandle(ref, () => ({
|
|
200
171
|
openFilePicker,
|
|
201
172
|
}))
|
|
202
173
|
|
|
203
|
-
const filenames = file ? file.map((f) => f.name) : ''
|
|
204
|
-
if (mode === 'button') {
|
|
205
|
-
return (
|
|
206
|
-
<View style={variantStyles.wrapper}>
|
|
207
|
-
<InputLabel label={label} style={variantStyles.label} required={required}/>
|
|
208
|
-
<Button
|
|
209
|
-
onPress={() => openFilePicker()}
|
|
210
|
-
text={filenames || placeholder}
|
|
211
|
-
debugName={'Open file picker'}
|
|
212
|
-
icon={iconName || ('fileInputButton' as IconPlaceholder)}
|
|
213
|
-
variants={filenames ? '' : 'icon'}
|
|
214
|
-
{...buttonProps}
|
|
215
|
-
/>
|
|
216
|
-
</View>
|
|
217
|
-
)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
174
|
return null
|
|
221
175
|
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { ComponentVariants, FormTypes, useDefaultComponentStyle } from '@codeleap/common'
|
|
3
|
+
import { StylesOf } from '../../types'
|
|
4
|
+
import { View, ViewProps } from '../View'
|
|
5
|
+
import { InputLabelComposition, InputLabelStyles } from './styles'
|
|
6
|
+
import { Text } from '../Text'
|
|
7
|
+
import { StyleSheet } from 'react-native'
|
|
8
|
+
|
|
9
|
+
export type InputLabelProps = ViewProps & {
|
|
10
|
+
styles?: StylesOf<InputLabelComposition>
|
|
11
|
+
label?: FormTypes.Label
|
|
12
|
+
required?: boolean
|
|
13
|
+
} & ComponentVariants<typeof InputLabelStyles>
|
|
14
|
+
|
|
15
|
+
export * from './styles'
|
|
16
|
+
|
|
17
|
+
export const InputLabel:React.FC<InputLabelProps> = (props) => {
|
|
18
|
+
const { label, required = false, variants = [], styles = {}, style, ...viewProps } = props
|
|
19
|
+
const variantStyles = useDefaultComponentStyle<'u:InputLabel', typeof InputLabelStyles>('u:InputLabel', {
|
|
20
|
+
variants, styles, transform: StyleSheet.flatten,
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
if (!label) return null
|
|
24
|
+
|
|
25
|
+
switch (typeof label) {
|
|
26
|
+
case 'string':
|
|
27
|
+
return <View {...viewProps} style={[variantStyles.wrapper, style]}>
|
|
28
|
+
<Text style={variantStyles.text} text={label} />
|
|
29
|
+
{required && <Text style={variantStyles.asterisk} text={' *'} />}
|
|
30
|
+
</View>
|
|
31
|
+
case 'object':
|
|
32
|
+
return <>
|
|
33
|
+
{label as React.ReactNode}
|
|
34
|
+
</>
|
|
35
|
+
default:
|
|
36
|
+
return null
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { assignTextStyle, createDefaultVariantFactory } from '@codeleap/common'
|
|
2
|
+
|
|
3
|
+
export type InputLabelComposition = 'text' | 'wrapper' | 'asterisk'
|
|
4
|
+
|
|
5
|
+
const createInputLabelStyle = createDefaultVariantFactory<InputLabelComposition>()
|
|
6
|
+
|
|
7
|
+
export const InputLabelStyles = {
|
|
8
|
+
default: createInputLabelStyle((theme) => ({
|
|
9
|
+
asterisk: {
|
|
10
|
+
color: theme.colors.negative,
|
|
11
|
+
},
|
|
12
|
+
wrapper: {
|
|
13
|
+
...theme.presets.row,
|
|
14
|
+
},
|
|
15
|
+
text: {
|
|
16
|
+
...assignTextStyle('h5')(theme).text,
|
|
17
|
+
},
|
|
18
|
+
})),
|
|
19
|
+
}
|
|
@@ -5,11 +5,13 @@ import { Text } from '../Text'
|
|
|
5
5
|
import { Touchable } from '../Touchable'
|
|
6
6
|
import {
|
|
7
7
|
ComponentVariants,
|
|
8
|
+
getNestedStylesByKey,
|
|
8
9
|
StylesOf,
|
|
9
10
|
useDefaultComponentStyle,
|
|
10
11
|
} from '@codeleap/common'
|
|
11
12
|
import { View } from '../View'
|
|
12
13
|
import { RadioInputComposition, RadioInputStyles } from './styles'
|
|
14
|
+
import { InputLabel } from '../InputLabel'
|
|
13
15
|
|
|
14
16
|
export * from './styles'
|
|
15
17
|
|
|
@@ -18,7 +20,7 @@ type RadioItem<T extends unknown = any> = {
|
|
|
18
20
|
label: ReactNode
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
const getRadioStyle = (props) => useDefaultComponentStyle('RadioInput', props)
|
|
23
|
+
const getRadioStyle = (props) => useDefaultComponentStyle<'u:RadioInput', typeof RadioInputStyles>('u:RadioInput', props)
|
|
22
24
|
|
|
23
25
|
export type RadioButtonProps = Omit<
|
|
24
26
|
ComponentPropsWithoutRef<typeof Touchable>,
|
|
@@ -35,6 +37,7 @@ export type RadioGroupProps<T> = {
|
|
|
35
37
|
options: RadioItem<T>[]
|
|
36
38
|
value: T
|
|
37
39
|
onValueChange(value: T): void
|
|
40
|
+
required?: boolean
|
|
38
41
|
label: ReactNode
|
|
39
42
|
styles?: StylesOf<RadioInputComposition>
|
|
40
43
|
} & ComponentVariants<typeof RadioInputStyles>
|
|
@@ -73,6 +76,7 @@ export const RadioGroup = <T extends unknown>(
|
|
|
73
76
|
onValueChange,
|
|
74
77
|
label,
|
|
75
78
|
responsiveVariants,
|
|
79
|
+
required = false,
|
|
76
80
|
variants,
|
|
77
81
|
styles,
|
|
78
82
|
} = radioGroupProps
|
|
@@ -84,8 +88,8 @@ export const RadioGroup = <T extends unknown>(
|
|
|
84
88
|
})
|
|
85
89
|
return (
|
|
86
90
|
<View style={radioStyle.wrapper}>
|
|
87
|
-
{
|
|
88
|
-
<View style={radioStyle.
|
|
91
|
+
<InputLabel required={required} label={label} styles={getNestedStylesByKey('label', radioStyle)}/>
|
|
92
|
+
<View style={radioStyle.list}>
|
|
89
93
|
{options?.map((item, idx) => (
|
|
90
94
|
<RadioButton
|
|
91
95
|
debugName={'RadioButton'}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createDefaultVariantFactory, includePresets,
|
|
3
3
|
} from '@codeleap/common'
|
|
4
|
+
import { InputLabelComposition } from '../InputLabel'
|
|
4
5
|
type RadioParts = 'button' | 'itemWrapper' | 'text' | 'buttonMark' | 'buttonFeedback'
|
|
5
6
|
|
|
6
|
-
type RadioGroupParts =
|
|
7
|
+
type RadioGroupParts = `label${Capitalize<InputLabelComposition>}` | 'wrapper' | 'list'
|
|
7
8
|
|
|
8
9
|
export type RadioInputComposition =
|
|
9
10
|
| `${RadioParts}:checked`
|
|
@@ -2,13 +2,14 @@ import React, { ReactElement, useImperativeHandle, useMemo, useRef } from 'react
|
|
|
2
2
|
import { Scroll, ScrollProps } from '../Scroll'
|
|
3
3
|
|
|
4
4
|
import { Easing, EasingFunction, StyleSheet } from 'react-native'
|
|
5
|
-
import {
|
|
5
|
+
import { FormTypes, getNestedStylesByKey, PropsOf, useDefaultComponentStyle } from '@codeleap/common'
|
|
6
6
|
import { SegmentedControlComposition, SegmentedControlStyles } from './styles'
|
|
7
7
|
import { Touchable } from '../Touchable'
|
|
8
8
|
import { StylesOf } from '../../types/utility'
|
|
9
9
|
import { Text, TextProps } from '../Text'
|
|
10
10
|
import { KeyboardAwareScrollViewTypes } from '../../modules'
|
|
11
11
|
import { View } from '../View'
|
|
12
|
+
import { InputLabel } from '../InputLabel'
|
|
12
13
|
export * from './styles'
|
|
13
14
|
export type SegmentedControlRef =KeyboardAwareScrollViewTypes.KeyboardAwareScrollView & {
|
|
14
15
|
scrollTo: (index: number) => void
|
|
@@ -28,6 +29,7 @@ export type SegmentedControlProps<T = string> = ScrollProps & {
|
|
|
28
29
|
touchableProps?: Partial<PropsOf<typeof Touchable>>
|
|
29
30
|
styles?: StylesOf<SegmentedControlComposition>
|
|
30
31
|
scrollProps?: any
|
|
32
|
+
label?: FormTypes.Label
|
|
31
33
|
RenderButton?: (props: SegmentedControlProps & {
|
|
32
34
|
touchableProps: PropsOf<typeof Touchable>
|
|
33
35
|
textProps: PropsOf<typeof Text>
|
|
@@ -48,6 +50,7 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
48
50
|
options = [],
|
|
49
51
|
onValueChange,
|
|
50
52
|
debugName,
|
|
53
|
+
label,
|
|
51
54
|
value,
|
|
52
55
|
styles = {},
|
|
53
56
|
animation = {},
|
|
@@ -56,7 +59,6 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
56
59
|
getItemWidth = (i) => i.label.length * 20,
|
|
57
60
|
RenderAnimatedView,
|
|
58
61
|
RenderButton,
|
|
59
|
-
...viewProps
|
|
60
62
|
} = props
|
|
61
63
|
|
|
62
64
|
let _animation = {
|
|
@@ -119,7 +121,10 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
119
121
|
const AnimatedView = RenderAnimatedView || View
|
|
120
122
|
variantStyles = JSON.parse(JSON.stringify(variantStyles))
|
|
121
123
|
_animation = JSON.parse(JSON.stringify(_animation))
|
|
122
|
-
|
|
124
|
+
|
|
125
|
+
const labelStyles = getNestedStylesByKey('label', variantStyles)
|
|
126
|
+
return (<>
|
|
127
|
+
<InputLabel label={label} styles={labelStyles} required={false}/>
|
|
123
128
|
<Scroll
|
|
124
129
|
horizontal
|
|
125
130
|
showsHorizontalScrollIndicator={false}
|
|
@@ -186,6 +191,7 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
186
191
|
})}
|
|
187
192
|
</View>
|
|
188
193
|
</Scroll>
|
|
194
|
+
</>
|
|
189
195
|
)
|
|
190
196
|
|
|
191
197
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createDefaultVariantFactory, includePresets, StylesOf } from '@codeleap/common'
|
|
2
|
+
import { InputLabelComposition } from '../InputLabel'
|
|
2
3
|
import { TouchableStylesGen } from '../Touchable'
|
|
3
4
|
|
|
4
5
|
export type SegmentedControlStates = 'selected'
|
|
@@ -12,7 +13,8 @@ export type SegmentedControlComposition =
|
|
|
12
13
|
`text:${SegmentedControlStates}` |
|
|
13
14
|
'button' |
|
|
14
15
|
'buttonFeedback' |
|
|
15
|
-
`button:${SegmentedControlStates}`
|
|
16
|
+
`button:${SegmentedControlStates}` |
|
|
17
|
+
`label${Capitalize<InputLabelComposition>}`
|
|
16
18
|
|
|
17
19
|
export type SegmentedControlStylesGen<TCSS = any> =
|
|
18
20
|
StylesOf<
|
|
@@ -7,10 +7,13 @@ import { useRef } from 'react'
|
|
|
7
7
|
import { StyleSheet } from 'react-native'
|
|
8
8
|
import { View } from '../View'
|
|
9
9
|
import {
|
|
10
|
+
getNestedStylesByKey,
|
|
10
11
|
useDefaultComponentStyle,
|
|
11
12
|
} from '@codeleap/common'
|
|
12
|
-
|
|
13
|
+
|
|
13
14
|
import { SliderProps } from './types'
|
|
15
|
+
import { InputLabel } from '../InputLabel'
|
|
16
|
+
import { SliderStyles } from './styles'
|
|
14
17
|
|
|
15
18
|
export * from './styles'
|
|
16
19
|
|
|
@@ -38,8 +41,10 @@ export const Slider: React.FC<SliderProps> = (sliderProps) => {
|
|
|
38
41
|
const toggleTooltipTimeout = useRef(null)
|
|
39
42
|
const valueRef = useRef(value)
|
|
40
43
|
|
|
41
|
-
const variantStyles = useDefaultComponentStyle('Slider', {
|
|
44
|
+
const variantStyles = useDefaultComponentStyle<'u:Slider', typeof SliderStyles>('u:Slider', {
|
|
42
45
|
variants,
|
|
46
|
+
styles,
|
|
47
|
+
transform: StyleSheet.flatten,
|
|
43
48
|
})
|
|
44
49
|
|
|
45
50
|
function setValue() {
|
|
@@ -66,7 +71,7 @@ export const Slider: React.FC<SliderProps> = (sliderProps) => {
|
|
|
66
71
|
|
|
67
72
|
return (
|
|
68
73
|
<View style={[variantStyles.wrapper, style]}>
|
|
69
|
-
<InputLabel label={label}
|
|
74
|
+
<InputLabel label={label} styles={getNestedStylesByKey('label', variantStyles)} />
|
|
70
75
|
<RNSlider
|
|
71
76
|
value={value}
|
|
72
77
|
onSlidingStart={() => {
|
|
@@ -105,16 +110,16 @@ export const Slider: React.FC<SliderProps> = (sliderProps) => {
|
|
|
105
110
|
maximumValue={labels ? labels.length - 1 : 10}
|
|
106
111
|
trackMarks={labels ? Object.keys(labels).map((z) => parseInt(z)) : []}
|
|
107
112
|
containerStyle={
|
|
108
|
-
[variantStyles.inputContainer
|
|
113
|
+
[variantStyles.inputContainer] as any
|
|
109
114
|
}
|
|
110
115
|
thumbStyle={
|
|
111
|
-
StyleSheet.flatten([variantStyles.handle
|
|
116
|
+
StyleSheet.flatten([variantStyles.handle]) as any
|
|
112
117
|
}
|
|
113
|
-
trackStyle={[variantStyles.track
|
|
118
|
+
trackStyle={[variantStyles.track] as any}
|
|
114
119
|
minimumTrackTintColor={
|
|
115
120
|
StyleSheet.flatten([
|
|
116
121
|
variantStyles.selectedTrack,
|
|
117
|
-
|
|
122
|
+
|
|
118
123
|
])?.backgroundColor
|
|
119
124
|
}
|
|
120
125
|
{...props}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { assignTextStyle, createDefaultVariantFactory, includePresets } from '@codeleap/common'
|
|
2
|
+
import { InputLabelComposition } from '../InputLabel'
|
|
2
3
|
|
|
3
4
|
export type SliderComposition =
|
|
4
5
|
| 'wrapper'
|
|
5
6
|
| 'handle'
|
|
6
7
|
| 'track'
|
|
7
|
-
|
|
|
8
|
+
| `label${Capitalize<InputLabelComposition>}`
|
|
8
9
|
| 'selectedTrack'
|
|
9
10
|
| 'inputContainer'
|
|
10
11
|
| 'tooltip'
|
|
@@ -10,13 +10,14 @@ import {
|
|
|
10
10
|
} from '@codeleap/common'
|
|
11
11
|
import { ComponentPropsWithRef, forwardRef, ReactNode } from 'react'
|
|
12
12
|
import { StyleSheet, Switch as NativeSwitch } from 'react-native'
|
|
13
|
-
import {
|
|
13
|
+
import { FormError } from '../TextInput'
|
|
14
14
|
import { View } from '../View'
|
|
15
15
|
|
|
16
16
|
import {
|
|
17
17
|
SwitchStyles,
|
|
18
18
|
SwitchComposition,
|
|
19
19
|
} from './styles'
|
|
20
|
+
import { InputLabel } from '../InputLabel'
|
|
20
21
|
export * from './styles'
|
|
21
22
|
type NativeSwitchProps = Omit<
|
|
22
23
|
ComponentPropsWithRef<typeof NativeSwitch>,
|
|
@@ -77,7 +78,11 @@ export const Switch = forwardRef<NativeSwitch, SwitchProps>(
|
|
|
77
78
|
ref={ref}
|
|
78
79
|
{...props}
|
|
79
80
|
/>
|
|
80
|
-
<InputLabel label={label}
|
|
81
|
+
<InputLabel label={label} styles={{
|
|
82
|
+
asterisk: getStyles('labelAsterisk'),
|
|
83
|
+
text: getStyles('labelText'),
|
|
84
|
+
wrapper: getStyles('labelWrapper'),
|
|
85
|
+
}} />
|
|
81
86
|
</View>
|
|
82
87
|
<FormError text={error.message} style={getStyles('error')} />
|
|
83
88
|
</View>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
|
|
2
|
+
import { InputLabelComposition } from '../InputLabel'
|
|
2
3
|
|
|
3
|
-
export type SwitchParts = 'wrapper' |
|
|
4
|
+
export type SwitchParts = 'wrapper' | `label${Capitalize<InputLabelComposition>}` | 'input' | 'error' | 'inputWrapper'
|
|
4
5
|
export type SwitchComposition =
|
|
5
6
|
| SwitchParts
|
|
6
7
|
| `${SwitchParts}:disabled`
|
|
@@ -19,7 +20,7 @@ export const SwitchStyles = {
|
|
|
19
20
|
...theme.presets.row,
|
|
20
21
|
...theme.presets.alignCenter,
|
|
21
22
|
},
|
|
22
|
-
|
|
23
|
+
labelWrapper: {
|
|
23
24
|
...theme.spacing.marginLeft(0.5),
|
|
24
25
|
},
|
|
25
26
|
input: {
|
|
@@ -15,13 +15,10 @@ import { ComponentPropsWithoutRef, forwardRef, useImperativeHandle, useRef, useS
|
|
|
15
15
|
import { Text, TextProps } from '../Text'
|
|
16
16
|
import { View, ViewProps } from '../View'
|
|
17
17
|
import { StylesOf } from '../../types'
|
|
18
|
-
import { Icon } from '../Icon'
|
|
19
18
|
import { NativeSyntheticEvent, StyleSheet, TextInput as NativeTextInput, TextInputChangeEventData } from 'react-native'
|
|
20
19
|
import { Touchable, TouchableProps } from '../Touchable'
|
|
21
20
|
import { MaskedTextInput, TextInputMaskProps } from '../../modules/textInputMask'
|
|
22
|
-
import { InputLabel } from '
|
|
23
|
-
|
|
24
|
-
export { InputLabel } from './Label'
|
|
21
|
+
import { InputLabel } from '../InputLabel'
|
|
25
22
|
|
|
26
23
|
export * from './styles'
|
|
27
24
|
|
|
@@ -32,8 +29,6 @@ import {
|
|
|
32
29
|
} from './styles'
|
|
33
30
|
import { ActionIcon, ActionIconParts, ActionIconProps } from '../ActionIcon'
|
|
34
31
|
|
|
35
|
-
type IconProp = { name: IconPlaceholder; action?: () => void }
|
|
36
|
-
|
|
37
32
|
type NativeProps = ComponentPropsWithoutRef<typeof NativeTextInput>
|
|
38
33
|
|
|
39
34
|
type SubtitleProps = {
|
|
@@ -194,9 +189,11 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((rawprops,
|
|
|
194
189
|
>
|
|
195
190
|
<InputLabel
|
|
196
191
|
label={label}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
192
|
+
styles={{
|
|
193
|
+
wrapper: getStyles('labelWrapper'),
|
|
194
|
+
asterisk: getStyles('labelAsterisk'),
|
|
195
|
+
text: getStyles('labelText'),
|
|
196
|
+
}}
|
|
200
197
|
required={required}
|
|
201
198
|
/>
|
|
202
199
|
<View style={getStyles('innerWrapper')} {...innerWrapperProps}>
|