@chem-po/react-native 0.0.42 → 0.0.43
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/lib/commonjs/components/form/input/Editable.js +7 -4
- package/lib/commonjs/components/form/input/Editable.js.map +1 -1
- package/lib/commonjs/components/form/input/file/index.js +3 -2
- package/lib/commonjs/components/form/input/file/index.js.map +1 -1
- package/lib/commonjs/components/form/input/multipleSelect/index.js +8 -8
- package/lib/commonjs/components/form/input/multipleSelect/index.js.map +1 -1
- package/lib/commonjs/components/form/input/select/index.js +3 -6
- package/lib/commonjs/components/form/input/select/index.js.map +1 -1
- package/lib/commonjs/components/form/view/file.js +4 -2
- package/lib/commonjs/components/form/view/file.js.map +1 -1
- package/lib/commonjs/components/form/view/index.js +9 -3
- package/lib/commonjs/components/form/view/index.js.map +1 -1
- package/lib/commonjs/components/form/view/multipleSelect.js +7 -9
- package/lib/commonjs/components/form/view/multipleSelect.js.map +1 -1
- package/lib/commonjs/components/form/view/select.js +14 -11
- package/lib/commonjs/components/form/view/select.js.map +1 -1
- package/lib/module/components/form/input/Editable.js +7 -4
- package/lib/module/components/form/input/Editable.js.map +1 -1
- package/lib/module/components/form/input/file/index.js +3 -2
- package/lib/module/components/form/input/file/index.js.map +1 -1
- package/lib/module/components/form/input/multipleSelect/index.js +9 -9
- package/lib/module/components/form/input/multipleSelect/index.js.map +1 -1
- package/lib/module/components/form/input/select/index.js +4 -7
- package/lib/module/components/form/input/select/index.js.map +1 -1
- package/lib/module/components/form/view/file.js +4 -2
- package/lib/module/components/form/view/file.js.map +1 -1
- package/lib/module/components/form/view/index.js +9 -3
- package/lib/module/components/form/view/index.js.map +1 -1
- package/lib/module/components/form/view/multipleSelect.js +7 -9
- package/lib/module/components/form/view/multipleSelect.js.map +1 -1
- package/lib/module/components/form/view/select.js +13 -10
- package/lib/module/components/form/view/select.js.map +1 -1
- package/lib/typescript/components/form/input/Editable.d.ts +1 -1
- package/lib/typescript/components/form/input/Editable.d.ts.map +1 -1
- package/lib/typescript/components/form/input/file/index.d.ts +3 -2
- package/lib/typescript/components/form/input/file/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/multipleSelect/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/select/index.d.ts.map +1 -1
- package/lib/typescript/components/form/view/file.d.ts +3 -2
- package/lib/typescript/components/form/view/file.d.ts.map +1 -1
- package/lib/typescript/components/form/view/index.d.ts +3 -2
- package/lib/typescript/components/form/view/index.d.ts.map +1 -1
- package/lib/typescript/components/form/view/multipleSelect.d.ts +6 -3
- package/lib/typescript/components/form/view/multipleSelect.d.ts.map +1 -1
- package/lib/typescript/components/form/view/select.d.ts +10 -6
- package/lib/typescript/components/form/view/select.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/form/input/Editable.tsx +5 -4
- package/src/components/form/input/file/index.tsx +4 -2
- package/src/components/form/input/multipleSelect/index.tsx +5 -6
- package/src/components/form/input/select/index.tsx +7 -12
- package/src/components/form/view/file.tsx +5 -3
- package/src/components/form/view/index.tsx +17 -3
- package/src/components/form/view/multipleSelect.tsx +13 -11
- package/src/components/form/view/select.tsx +24 -16
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { InputSize } from '@chem-po/core'
|
|
1
|
+
import { BaseSelectOption, InputSize } from '@chem-po/core'
|
|
2
2
|
import { MultipleSelectField, useColorMode, usePlaceholderColor } from '@chem-po/react'
|
|
3
3
|
import { useMemo } from 'react'
|
|
4
|
-
import React, { StyleSheet, Text, View, ViewStyle } from 'react-native'
|
|
4
|
+
import React, { StyleProp, StyleSheet, Text, TextStyle, View, ViewStyle } from 'react-native'
|
|
5
5
|
import { Txt } from '../../text/Txt'
|
|
6
6
|
import { useInputStyles } from '../input/hooks/useInputStyles'
|
|
7
7
|
import { SelectedOptionContainer } from '../input/multipleSelect'
|
|
@@ -31,16 +31,23 @@ const styles = StyleSheet.create({
|
|
|
31
31
|
},
|
|
32
32
|
})
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
type NativeMultipleSelectField<
|
|
35
|
+
Value extends any[] = string[],
|
|
36
|
+
Option extends BaseSelectOption<Value[number]> = BaseSelectOption<Value[number]>,
|
|
37
|
+
> = MultipleSelectField<Value, Option>
|
|
38
|
+
|
|
39
|
+
export const MultipleSelectFieldView = <F extends NativeMultipleSelectField>({
|
|
35
40
|
field,
|
|
36
41
|
value,
|
|
37
42
|
noLabel,
|
|
38
43
|
size: sizeProp,
|
|
39
44
|
style,
|
|
45
|
+
textStyle,
|
|
40
46
|
}: {
|
|
41
47
|
field: F
|
|
42
48
|
value?: F['defaultValue']
|
|
43
49
|
noLabel?: boolean
|
|
50
|
+
textStyle?: StyleProp<TextStyle>
|
|
44
51
|
size?: InputSize
|
|
45
52
|
style?: ViewStyle
|
|
46
53
|
}) => {
|
|
@@ -49,12 +56,6 @@ export const MultipleSelectFieldView = <F extends MultipleSelectField>({
|
|
|
49
56
|
const colorMode = useColorMode()
|
|
50
57
|
const { size, text, container } = useInputStyles(true, field.size, sizeProp)
|
|
51
58
|
const placeholderColor = usePlaceholderColor()
|
|
52
|
-
const selectedOptionStyle = useMemo<ViewStyle>(() => {
|
|
53
|
-
return {
|
|
54
|
-
paddingHorizontal: container.paddingHorizontal,
|
|
55
|
-
paddingVertical: container.paddingVertical,
|
|
56
|
-
}
|
|
57
|
-
}, [container])
|
|
58
59
|
const RenderOption = useMemo(() => customRender ?? DefaultRenderOption, [customRender])
|
|
59
60
|
return (
|
|
60
61
|
<View style={[styles.container, style]}>
|
|
@@ -62,10 +63,11 @@ export const MultipleSelectFieldView = <F extends MultipleSelectField>({
|
|
|
62
63
|
{value?.length ? (
|
|
63
64
|
<View style={styles.optionsContainer}>
|
|
64
65
|
{selectedOptions.map(o => (
|
|
65
|
-
<SelectedOptionContainer key={o.value} style={
|
|
66
|
+
<SelectedOptionContainer key={o.value} style={[container, { width: 'auto' }]}>
|
|
66
67
|
<RenderOption
|
|
67
68
|
option={o}
|
|
68
69
|
value={o.value}
|
|
70
|
+
textStyle={[text, textStyle]}
|
|
69
71
|
colorMode={colorMode}
|
|
70
72
|
isSelected
|
|
71
73
|
size={size}
|
|
@@ -75,7 +77,7 @@ export const MultipleSelectFieldView = <F extends MultipleSelectField>({
|
|
|
75
77
|
</View>
|
|
76
78
|
) : (
|
|
77
79
|
<View style={container}>
|
|
78
|
-
<Txt style={[text, { color: placeholderColor }]}>None</Txt>
|
|
80
|
+
<Txt style={[text, { color: placeholderColor }, textStyle]}>None</Txt>
|
|
79
81
|
</View>
|
|
80
82
|
)}
|
|
81
83
|
</View>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputSize, RenderSelectOptionProps } from '@chem-po/core'
|
|
2
2
|
import { SelectField, useColorMode, usePlaceholderColor } from '@chem-po/react'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { StyleSheet, Text, View, ViewStyle } from 'react-native'
|
|
3
|
+
import React, { useMemo } from 'react'
|
|
4
|
+
import { StyleProp, StyleSheet, Text, TextStyle, View, ViewStyle } from 'react-native'
|
|
5
5
|
import { Txt } from '../../text'
|
|
6
6
|
import { useInputStyles } from '../input/hooks/useInputStyles'
|
|
7
7
|
import { inputViewStyles } from './styles'
|
|
@@ -18,31 +18,35 @@ const styles = StyleSheet.create({
|
|
|
18
18
|
},
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
-
export const DefaultRenderOption =
|
|
22
|
-
Value = string,
|
|
23
|
-
Option extends BaseSelectOption<Value> = BaseSelectOption<Value>,
|
|
24
|
-
>({
|
|
21
|
+
export const DefaultRenderOption = ({
|
|
25
22
|
option,
|
|
26
|
-
|
|
23
|
+
containerStyle,
|
|
24
|
+
textStyle,
|
|
25
|
+
}: RenderSelectOptionProps & {
|
|
26
|
+
containerStyle?: StyleProp<ViewStyle>
|
|
27
|
+
textStyle?: StyleProp<TextStyle>
|
|
28
|
+
}) => {
|
|
27
29
|
return (
|
|
28
|
-
<View style={
|
|
29
|
-
<Txt style={inputViewStyles.value}>{option.label}</Txt>
|
|
30
|
+
<View style={containerStyle}>
|
|
31
|
+
<Txt style={[inputViewStyles.value, textStyle]}>{option.label}</Txt>
|
|
30
32
|
</View>
|
|
31
33
|
)
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
export const SelectFieldView = ({
|
|
36
|
+
export const SelectFieldView = <F extends SelectField>({
|
|
35
37
|
field,
|
|
36
38
|
value,
|
|
37
39
|
noLabel,
|
|
38
40
|
style,
|
|
39
41
|
size: sizeProp,
|
|
40
42
|
inEditable,
|
|
43
|
+
textStyle,
|
|
41
44
|
}: {
|
|
42
|
-
field:
|
|
43
|
-
value:
|
|
45
|
+
field: F
|
|
46
|
+
value: F['defaultValue']
|
|
44
47
|
noLabel?: boolean
|
|
45
48
|
style?: ViewStyle
|
|
49
|
+
textStyle?: StyleProp<TextStyle>
|
|
46
50
|
size?: InputSize
|
|
47
51
|
inEditable?: boolean
|
|
48
52
|
}) => {
|
|
@@ -51,23 +55,27 @@ export const SelectFieldView = ({
|
|
|
51
55
|
const placeholderColor = usePlaceholderColor()
|
|
52
56
|
const { size, text, container } = useInputStyles(inEditable, field.size, sizeProp)
|
|
53
57
|
const selectedOption = field.options.find(o => o.value === value)
|
|
54
|
-
const RenderOption = customRender ?? DefaultRenderOption
|
|
58
|
+
const RenderOption = useMemo(() => customRender ?? DefaultRenderOption, [customRender])
|
|
55
59
|
return (
|
|
56
60
|
<View style={[styles.container, style]}>
|
|
57
61
|
{!noLabel && (
|
|
58
|
-
<Text style={[styles.label, text, { color: placeholderColor }]}>
|
|
62
|
+
<Text style={[styles.label, text, { color: placeholderColor }, textStyle]}>
|
|
63
|
+
{placeholder}
|
|
64
|
+
</Text>
|
|
59
65
|
)}
|
|
60
66
|
{selectedOption ? (
|
|
61
67
|
<RenderOption
|
|
62
68
|
value={selectedOption.value}
|
|
63
69
|
option={selectedOption}
|
|
70
|
+
containerStyle={container}
|
|
71
|
+
textStyle={[text, textStyle]}
|
|
64
72
|
colorMode={colorMode}
|
|
65
73
|
isSelected={true}
|
|
66
74
|
size={size}
|
|
67
75
|
/>
|
|
68
76
|
) : (
|
|
69
77
|
<View style={container}>
|
|
70
|
-
<Txt style={[text, { color: placeholderColor }]}>None</Txt>
|
|
78
|
+
<Txt style={[text, { color: placeholderColor }, textStyle]}>None</Txt>
|
|
71
79
|
</View>
|
|
72
80
|
)}
|
|
73
81
|
</View>
|