@chem-po/react-native 0.0.29 → 0.0.31
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/button/DeleteButton.js +7 -8
- package/lib/commonjs/components/button/DeleteButton.js.map +1 -1
- package/lib/commonjs/components/button/LoadingButton.js +3 -3
- package/lib/commonjs/components/button/LoadingButton.js.map +1 -1
- package/lib/commonjs/components/button/Toggle.js +21 -17
- package/lib/commonjs/components/button/Toggle.js.map +1 -1
- package/lib/commonjs/components/form/Form.js +30 -4
- package/lib/commonjs/components/form/Form.js.map +1 -1
- package/lib/commonjs/components/form/FormFooter.js +3 -2
- package/lib/commonjs/components/form/FormFooter.js.map +1 -1
- package/lib/commonjs/components/form/input/Editable.js +50 -73
- package/lib/commonjs/components/form/input/Editable.js.map +1 -1
- package/lib/commonjs/components/form/input/StandaloneInput.js.map +1 -1
- package/lib/commonjs/components/form/input/common/InputClearButton.js +2 -1
- package/lib/commonjs/components/form/input/common/InputClearButton.js.map +1 -1
- package/lib/commonjs/components/form/input/date/index.js +23 -10
- package/lib/commonjs/components/form/input/date/index.js.map +1 -1
- package/lib/commonjs/components/form/input/datetime/index.js +32 -11
- package/lib/commonjs/components/form/input/datetime/index.js.map +1 -1
- package/lib/commonjs/components/form/input/file/index.js +27 -27
- package/lib/commonjs/components/form/input/file/index.js.map +1 -1
- package/lib/commonjs/components/form/input/hooks/useInputStyles.js +5 -6
- package/lib/commonjs/components/form/input/hooks/useInputStyles.js.map +1 -1
- package/lib/commonjs/components/form/input/input.js +3 -3
- package/lib/commonjs/components/form/input/input.js.map +1 -1
- package/lib/commonjs/components/form/input/multipleSelect/index.js +41 -24
- package/lib/commonjs/components/form/input/multipleSelect/index.js.map +1 -1
- package/lib/commonjs/components/form/input/select/index.js +1 -1
- package/lib/commonjs/components/form/input/select/index.js.map +1 -1
- package/lib/commonjs/components/form/input/socialMedia/index.js +3 -2
- package/lib/commonjs/components/form/input/socialMedia/index.js.map +1 -1
- package/lib/commonjs/components/form/input/text/AutoResizeTextarea.js +1 -6
- package/lib/commonjs/components/form/input/text/AutoResizeTextarea.js.map +1 -1
- package/lib/commonjs/components/form/input/text/index.js +5 -3
- package/lib/commonjs/components/form/input/text/index.js.map +1 -1
- package/lib/commonjs/components/form/input/text/textarea.js +3 -13
- package/lib/commonjs/components/form/input/text/textarea.js.map +1 -1
- package/lib/commonjs/components/form/input/text/useWebAutoResize.js +7 -8
- package/lib/commonjs/components/form/input/text/useWebAutoResize.js.map +1 -1
- package/lib/commonjs/components/form/input/time/index.js +2 -1
- package/lib/commonjs/components/form/input/time/index.js.map +1 -1
- package/lib/commonjs/components/form/view/file.js +21 -12
- package/lib/commonjs/components/form/view/file.js.map +1 -1
- package/lib/commonjs/components/form/view/index.js +29 -18
- package/lib/commonjs/components/form/view/index.js.map +1 -1
- package/lib/commonjs/components/form/view/multipleSelect.js +17 -13
- package/lib/commonjs/components/form/view/multipleSelect.js.map +1 -1
- package/lib/commonjs/components/form/view/select.js +20 -9
- package/lib/commonjs/components/form/view/select.js.map +1 -1
- package/lib/commonjs/components/form/view/styles.js +0 -3
- package/lib/commonjs/components/form/view/styles.js.map +1 -1
- package/lib/commonjs/components/image/ImageViewModal.js +18 -15
- package/lib/commonjs/components/image/ImageViewModal.js.map +1 -1
- package/lib/commonjs/components/layout/CollapseHorizontal.js +84 -0
- package/lib/commonjs/components/layout/CollapseHorizontal.js.map +1 -0
- package/lib/commonjs/components/loading/LoadingImage.js +20 -13
- package/lib/commonjs/components/loading/LoadingImage.js.map +1 -1
- package/lib/commonjs/components/theme/colorMode/DarkModeToggle.js +2 -1
- package/lib/commonjs/components/theme/colorMode/DarkModeToggle.js.map +1 -1
- package/lib/commonjs/contexts/root.js +6 -6
- package/lib/commonjs/contexts/root.js.map +1 -1
- package/lib/commonjs/index.js +11 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/forms.js +6 -0
- package/lib/commonjs/types/forms.js.map +1 -0
- package/lib/commonjs/types/index.js +17 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/module/components/button/DeleteButton.js +8 -9
- package/lib/module/components/button/DeleteButton.js.map +1 -1
- package/lib/module/components/button/LoadingButton.js +4 -4
- package/lib/module/components/button/LoadingButton.js.map +1 -1
- package/lib/module/components/button/Toggle.js +24 -20
- package/lib/module/components/button/Toggle.js.map +1 -1
- package/lib/module/components/form/Form.js +31 -5
- package/lib/module/components/form/Form.js.map +1 -1
- package/lib/module/components/form/FormFooter.js +4 -3
- package/lib/module/components/form/FormFooter.js.map +1 -1
- package/lib/module/components/form/input/Editable.js +51 -74
- package/lib/module/components/form/input/Editable.js.map +1 -1
- package/lib/module/components/form/input/StandaloneInput.js.map +1 -1
- package/lib/module/components/form/input/common/InputClearButton.js +3 -2
- package/lib/module/components/form/input/common/InputClearButton.js.map +1 -1
- package/lib/module/components/form/input/date/index.js +24 -11
- package/lib/module/components/form/input/date/index.js.map +1 -1
- package/lib/module/components/form/input/datetime/index.js +33 -12
- package/lib/module/components/form/input/datetime/index.js.map +1 -1
- package/lib/module/components/form/input/file/index.js +29 -29
- package/lib/module/components/form/input/file/index.js.map +1 -1
- package/lib/module/components/form/input/hooks/useInputStyles.js +5 -6
- package/lib/module/components/form/input/hooks/useInputStyles.js.map +1 -1
- package/lib/module/components/form/input/input.js +3 -3
- package/lib/module/components/form/input/input.js.map +1 -1
- package/lib/module/components/form/input/multipleSelect/index.js +41 -24
- package/lib/module/components/form/input/multipleSelect/index.js.map +1 -1
- package/lib/module/components/form/input/select/index.js +1 -1
- package/lib/module/components/form/input/select/index.js.map +1 -1
- package/lib/module/components/form/input/socialMedia/index.js +4 -3
- package/lib/module/components/form/input/socialMedia/index.js.map +1 -1
- package/lib/module/components/form/input/text/AutoResizeTextarea.js +1 -6
- package/lib/module/components/form/input/text/AutoResizeTextarea.js.map +1 -1
- package/lib/module/components/form/input/text/index.js +6 -4
- package/lib/module/components/form/input/text/index.js.map +1 -1
- package/lib/module/components/form/input/text/textarea.js +4 -14
- package/lib/module/components/form/input/text/textarea.js.map +1 -1
- package/lib/module/components/form/input/text/useWebAutoResize.js +7 -8
- package/lib/module/components/form/input/text/useWebAutoResize.js.map +1 -1
- package/lib/module/components/form/input/time/index.js +3 -2
- package/lib/module/components/form/input/time/index.js.map +1 -1
- package/lib/module/components/form/view/file.js +15 -6
- package/lib/module/components/form/view/file.js.map +1 -1
- package/lib/module/components/form/view/index.js +19 -8
- package/lib/module/components/form/view/index.js.map +1 -1
- package/lib/module/components/form/view/multipleSelect.js +18 -14
- package/lib/module/components/form/view/multipleSelect.js.map +1 -1
- package/lib/module/components/form/view/select.js +20 -9
- package/lib/module/components/form/view/select.js.map +1 -1
- package/lib/module/components/form/view/styles.js +0 -3
- package/lib/module/components/form/view/styles.js.map +1 -1
- package/lib/module/components/image/ImageViewModal.js +20 -17
- package/lib/module/components/image/ImageViewModal.js.map +1 -1
- package/lib/module/components/layout/CollapseHorizontal.js +76 -0
- package/lib/module/components/layout/CollapseHorizontal.js.map +1 -0
- package/lib/module/components/loading/LoadingImage.js +21 -14
- package/lib/module/components/loading/LoadingImage.js.map +1 -1
- package/lib/module/components/theme/colorMode/DarkModeToggle.js +3 -2
- package/lib/module/components/theme/colorMode/DarkModeToggle.js.map +1 -1
- package/lib/module/contexts/root.js +6 -6
- package/lib/module/contexts/root.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/forms.js +2 -0
- package/lib/module/types/forms.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/typescript/components/button/DeleteButton.d.ts.map +1 -1
- package/lib/typescript/components/button/LoadingButton.d.ts.map +1 -1
- package/lib/typescript/components/button/Toggle.d.ts +5 -2
- package/lib/typescript/components/button/Toggle.d.ts.map +1 -1
- package/lib/typescript/components/form/Form.d.ts.map +1 -1
- package/lib/typescript/components/form/FormFooter.d.ts.map +1 -1
- package/lib/typescript/components/form/input/Editable.d.ts +2 -2
- package/lib/typescript/components/form/input/Editable.d.ts.map +1 -1
- package/lib/typescript/components/form/input/StandaloneInput.d.ts +5 -14
- package/lib/typescript/components/form/input/StandaloneInput.d.ts.map +1 -1
- package/lib/typescript/components/form/input/common/InputClearButton.d.ts.map +1 -1
- package/lib/typescript/components/form/input/date/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/datetime/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/file/index.d.ts +2 -1
- package/lib/typescript/components/form/input/file/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/hooks/useInputStyles.d.ts +3 -6
- package/lib/typescript/components/form/input/hooks/useInputStyles.d.ts.map +1 -1
- package/lib/typescript/components/form/input/multipleSelect/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/socialMedia/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/text/AutoResizeTextarea.d.ts.map +1 -1
- package/lib/typescript/components/form/input/text/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/text/textarea.d.ts +2 -2
- package/lib/typescript/components/form/input/text/textarea.d.ts.map +1 -1
- package/lib/typescript/components/form/input/text/useWebAutoResize.d.ts +2 -3
- package/lib/typescript/components/form/input/text/useWebAutoResize.d.ts.map +1 -1
- package/lib/typescript/components/form/input/time/index.d.ts.map +1 -1
- 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.map +1 -1
- package/lib/typescript/components/form/view/select.d.ts +2 -1
- package/lib/typescript/components/form/view/select.d.ts.map +1 -1
- package/lib/typescript/components/form/view/styles.d.ts +0 -3
- package/lib/typescript/components/form/view/styles.d.ts.map +1 -1
- package/lib/typescript/components/image/ImageViewModal.d.ts.map +1 -1
- package/lib/typescript/components/layout/CollapseHorizontal.d.ts +9 -0
- package/lib/typescript/components/layout/CollapseHorizontal.d.ts.map +1 -0
- package/lib/typescript/components/loading/LoadingImage.d.ts +4 -1
- package/lib/typescript/components/loading/LoadingImage.d.ts.map +1 -1
- package/lib/typescript/components/theme/colorMode/DarkModeToggle.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types/forms.d.ts +5 -0
- package/lib/typescript/types/forms.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +2 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/components/button/DeleteButton.tsx +12 -25
- package/src/components/button/LoadingButton.tsx +4 -5
- package/src/components/button/Toggle.tsx +24 -19
- package/src/components/form/Form.tsx +31 -11
- package/src/components/form/FormFooter.tsx +6 -5
- package/src/components/form/input/Editable.tsx +52 -92
- package/src/components/form/input/StandaloneInput.tsx +4 -13
- package/src/components/form/input/common/InputClearButton.tsx +4 -3
- package/src/components/form/input/date/index.tsx +24 -11
- package/src/components/form/input/datetime/index.tsx +37 -15
- package/src/components/form/input/file/index.tsx +34 -35
- package/src/components/form/input/hooks/useInputStyles.ts +10 -7
- package/src/components/form/input/input.tsx +2 -2
- package/src/components/form/input/multipleSelect/index.tsx +47 -36
- package/src/components/form/input/select/index.tsx +1 -1
- package/src/components/form/input/socialMedia/index.tsx +6 -5
- package/src/components/form/input/text/AutoResizeTextarea.tsx +1 -5
- package/src/components/form/input/text/index.tsx +7 -5
- package/src/components/form/input/text/textarea.tsx +4 -16
- package/src/components/form/input/text/useWebAutoResize.tsx +9 -8
- package/src/components/form/input/time/index.tsx +4 -3
- package/src/components/form/view/file.tsx +9 -5
- package/src/components/form/view/index.tsx +26 -7
- package/src/components/form/view/multipleSelect.tsx +11 -9
- package/src/components/form/view/select.tsx +12 -3
- package/src/components/form/view/styles.ts +0 -3
- package/src/components/image/ImageViewModal.tsx +56 -50
- package/src/components/layout/CollapseHorizontal.tsx +92 -0
- package/src/components/loading/LoadingImage.tsx +19 -19
- package/src/components/theme/colorMode/DarkModeToggle.tsx +4 -3
- package/src/contexts/root.tsx +6 -6
- package/src/index.ts +1 -0
- package/src/types/forms.ts +14 -0
- package/src/types/index.ts +1 -0
|
@@ -48,20 +48,17 @@ const BaseMultipleSelectComponent = <T extends MultipleSelectField>(
|
|
|
48
48
|
|
|
49
49
|
const colorMode = useColorMode()
|
|
50
50
|
const inputRef = useRef<IDropdownRef>(null)
|
|
51
|
-
const {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
buttonContainer,
|
|
57
|
-
size,
|
|
58
|
-
} = useInputStyles(inEditable, field.size, formSize)
|
|
51
|
+
const { container, iconSize, clearButtonSize, text, buttonContainer, size } = useInputStyles(
|
|
52
|
+
inEditable,
|
|
53
|
+
field.size,
|
|
54
|
+
formSize,
|
|
55
|
+
)
|
|
59
56
|
const iconColor = useIconColor()
|
|
60
57
|
const textColor = useTextColor()
|
|
61
58
|
const placeholderColor = usePlaceholderColor()
|
|
62
59
|
const menuBg = useBackgroundColor(100)
|
|
63
60
|
const inputBg = useBackgroundColor(50)
|
|
64
|
-
const selectedOptionBg = useColorModeValue('#
|
|
61
|
+
const selectedOptionBg = useColorModeValue('#ffffff22', '#ffffff22')
|
|
65
62
|
const borderColor = useBorderColor()
|
|
66
63
|
|
|
67
64
|
useImperativeHandle(ref, () => ({
|
|
@@ -73,13 +70,6 @@ const BaseMultipleSelectComponent = <T extends MultipleSelectField>(
|
|
|
73
70
|
},
|
|
74
71
|
}))
|
|
75
72
|
|
|
76
|
-
const defaultSelectedOptionStyle = useMemo(() => {
|
|
77
|
-
return {
|
|
78
|
-
paddingVertical: inputStyles.paddingVertical,
|
|
79
|
-
paddingHorizontal: inputStyles.paddingHorizontal,
|
|
80
|
-
}
|
|
81
|
-
}, [inputStyles])
|
|
82
|
-
|
|
83
73
|
const RenderOptionText = (
|
|
84
74
|
props: RenderSelectOptionProps<T['options'][number]['value'], T['options'][number]>,
|
|
85
75
|
) => {
|
|
@@ -96,19 +86,27 @@ const BaseMultipleSelectComponent = <T extends MultipleSelectField>(
|
|
|
96
86
|
return RenderOption(props)
|
|
97
87
|
}
|
|
98
88
|
return (
|
|
99
|
-
|
|
100
|
-
<Txt style={[
|
|
101
|
-
|
|
89
|
+
<View style={{ padding: 6 }}>
|
|
90
|
+
<Txt style={[text]}>{props.option.label}</Txt>
|
|
91
|
+
</View>
|
|
102
92
|
)
|
|
103
93
|
}
|
|
104
94
|
|
|
95
|
+
const selectedOptions = useMemo(() => {
|
|
96
|
+
return options.filter(o => value?.includes(o.value))
|
|
97
|
+
}, [options, value])
|
|
98
|
+
|
|
105
99
|
return (
|
|
106
100
|
<View style={[styles.wrapper]}>
|
|
107
101
|
<MultiSelect
|
|
108
102
|
ref={inputRef}
|
|
109
|
-
style={[
|
|
103
|
+
style={[container, { borderColor, boxShadow: `0 0 10px ${borderColor}`, borderWidth: 0 }]}
|
|
110
104
|
placeholderStyle={[text, { color: value?.length ? textColor : placeholderColor }]}
|
|
111
|
-
containerStyle={{
|
|
105
|
+
containerStyle={{
|
|
106
|
+
backgroundColor: menuBg,
|
|
107
|
+
boxShadow: `0 0 6px ${borderColor}`,
|
|
108
|
+
borderWidth: 0,
|
|
109
|
+
}}
|
|
112
110
|
inputSearchStyle={[styles.inputSearch, text, { backgroundColor: inputBg, borderWidth: 0 }]}
|
|
113
111
|
iconStyle={styles.iconStyle}
|
|
114
112
|
data={options}
|
|
@@ -117,7 +115,9 @@ const BaseMultipleSelectComponent = <T extends MultipleSelectField>(
|
|
|
117
115
|
maxHeight={300}
|
|
118
116
|
labelField="label"
|
|
119
117
|
valueField="value"
|
|
120
|
-
placeholder={
|
|
118
|
+
placeholder={
|
|
119
|
+
selectedOptions.length ? selectedOptions.map(v => v.label).join(', ') : placeholder
|
|
120
|
+
}
|
|
121
121
|
searchPlaceholder={searchPlaceholder ?? placeholder}
|
|
122
122
|
value={value ?? []}
|
|
123
123
|
onChange={updated => {
|
|
@@ -125,21 +125,33 @@ const BaseMultipleSelectComponent = <T extends MultipleSelectField>(
|
|
|
125
125
|
}}
|
|
126
126
|
onFocus={onFocus}
|
|
127
127
|
onBlur={onBlur}
|
|
128
|
+
itemContainerStyle={{
|
|
129
|
+
backgroundColor: menuBg,
|
|
130
|
+
borderTopWidth: 1,
|
|
131
|
+
borderColor: borderColor,
|
|
132
|
+
}}
|
|
128
133
|
renderItem={(item, selected) => (
|
|
129
|
-
<View
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
<View
|
|
135
|
+
style={{
|
|
136
|
+
backgroundColor: selected ? selectedOptionBg : 'transparent',
|
|
137
|
+
paddingVertical: 8,
|
|
138
|
+
paddingHorizontal: 12,
|
|
139
|
+
flexDirection: 'row',
|
|
140
|
+
alignItems: 'center',
|
|
141
|
+
width: '100%',
|
|
142
|
+
}}>
|
|
143
|
+
<RenderOptionText
|
|
144
|
+
value={item.value}
|
|
145
|
+
option={item}
|
|
146
|
+
colorMode={colorMode}
|
|
147
|
+
isSelected={!!selected}
|
|
148
|
+
size={size}
|
|
149
|
+
/>
|
|
150
|
+
{selected ? <Ionicons name="checkmark" size={iconSize} color={iconColor} /> : null}
|
|
139
151
|
</View>
|
|
140
152
|
)}
|
|
141
153
|
renderSelectedItem={item => (
|
|
142
|
-
<SelectedOptionContainer>
|
|
154
|
+
<SelectedOptionContainer style={{ marginTop: 10 }}>
|
|
143
155
|
<RenderSelectedOptionText
|
|
144
156
|
value={item.value}
|
|
145
157
|
option={item}
|
|
@@ -179,7 +191,7 @@ const styles = StyleSheet.create({
|
|
|
179
191
|
width: '100%',
|
|
180
192
|
},
|
|
181
193
|
defaultOption: {
|
|
182
|
-
|
|
194
|
+
flex: 1,
|
|
183
195
|
},
|
|
184
196
|
iconStyle: {
|
|
185
197
|
width: 20,
|
|
@@ -188,7 +200,6 @@ const styles = StyleSheet.create({
|
|
|
188
200
|
inputSearch: {
|
|
189
201
|
paddingVertical: 4,
|
|
190
202
|
minHeight: 0,
|
|
191
|
-
height: 'auto',
|
|
192
203
|
outlineWidth: 0,
|
|
193
204
|
fontSize: 16,
|
|
194
205
|
},
|
|
@@ -198,6 +209,7 @@ const styles = StyleSheet.create({
|
|
|
198
209
|
borderWidth: 1,
|
|
199
210
|
alignItems: 'center',
|
|
200
211
|
marginTop: 4,
|
|
212
|
+
marginBottom: 4,
|
|
201
213
|
marginHorizontal: 4,
|
|
202
214
|
},
|
|
203
215
|
optionClearContainer: {
|
|
@@ -205,7 +217,6 @@ const styles = StyleSheet.create({
|
|
|
205
217
|
borderLeftWidth: 1,
|
|
206
218
|
borderTopRightRadius: 8,
|
|
207
219
|
borderBottomRightRadius: 8,
|
|
208
|
-
height: '100%',
|
|
209
220
|
justifyContent: 'center',
|
|
210
221
|
},
|
|
211
222
|
})
|
|
@@ -9,7 +9,8 @@ import React, {
|
|
|
9
9
|
useMemo,
|
|
10
10
|
useState,
|
|
11
11
|
} from 'react'
|
|
12
|
-
import { Modal, StyleSheet, Text, TextInput,
|
|
12
|
+
import { Modal, StyleSheet, Text, TextInput, View } from 'react-native'
|
|
13
|
+
import { Pressable } from 'react-native-gesture-handler'
|
|
13
14
|
import { FieldProps } from '../../types'
|
|
14
15
|
const siteToIcon: Record<SocialMediaSites, string> = {
|
|
15
16
|
facebook: 'facebook',
|
|
@@ -42,11 +43,11 @@ const SocialMediaSiteInput: FC<{
|
|
|
42
43
|
|
|
43
44
|
return (
|
|
44
45
|
<>
|
|
45
|
-
<
|
|
46
|
+
<Pressable
|
|
46
47
|
style={[styles.iconButton, !handle && styles.iconButtonInactive]}
|
|
47
48
|
onPress={() => onModalClose()}>
|
|
48
49
|
<Text style={styles.iconText}>{siteToIcon[site]}</Text>
|
|
49
|
-
</
|
|
50
|
+
</Pressable>
|
|
50
51
|
|
|
51
52
|
<Modal
|
|
52
53
|
visible={isModalVisible}
|
|
@@ -65,9 +66,9 @@ const SocialMediaSiteInput: FC<{
|
|
|
65
66
|
autoCapitalize="none"
|
|
66
67
|
autoCorrect={false}
|
|
67
68
|
/>
|
|
68
|
-
<
|
|
69
|
+
<Pressable style={styles.closeButton} onPress={onModalClose}>
|
|
69
70
|
<Text style={styles.closeButtonText}>Close</Text>
|
|
70
|
-
</
|
|
71
|
+
</Pressable>
|
|
71
72
|
</View>
|
|
72
73
|
</View>
|
|
73
74
|
</Modal>
|
|
@@ -10,7 +10,7 @@ export const AutoResizeTextarea = forwardRef<TextInput, TextInputProps>(
|
|
|
10
10
|
({ style, value, onChangeText, ...props }, ref) => {
|
|
11
11
|
const textColor = useTextColor()
|
|
12
12
|
|
|
13
|
-
const { handleChange, height
|
|
13
|
+
const { handleChange, height } = useWebAutoResize(onChangeText, style)
|
|
14
14
|
|
|
15
15
|
const iconColor = useIconColor()
|
|
16
16
|
|
|
@@ -18,9 +18,6 @@ export const AutoResizeTextarea = forwardRef<TextInput, TextInputProps>(
|
|
|
18
18
|
<TextInput
|
|
19
19
|
ref={ref}
|
|
20
20
|
cursorColor={iconColor}
|
|
21
|
-
onContentSizeChange={e => {
|
|
22
|
-
setHeight(e.nativeEvent.contentSize.height)
|
|
23
|
-
}}
|
|
24
21
|
multiline
|
|
25
22
|
style={[styles.textarea, { color: textColor, height }, style]}
|
|
26
23
|
value={value}
|
|
@@ -33,7 +30,6 @@ export const AutoResizeTextarea = forwardRef<TextInput, TextInputProps>(
|
|
|
33
30
|
const styles = StyleSheet.create({
|
|
34
31
|
textarea: {
|
|
35
32
|
width: '100%',
|
|
36
|
-
minHeight: 18,
|
|
37
33
|
backgroundColor: 'transparent',
|
|
38
34
|
textAlignVertical: 'top',
|
|
39
35
|
outlineWidth: 0,
|
|
@@ -2,7 +2,8 @@ import { InputRef } from '@chem-po/core'
|
|
|
2
2
|
import { TextField, usePlaceholderColor, useTextColor } from '@chem-po/react'
|
|
3
3
|
import { Ionicons } from '@expo/vector-icons'
|
|
4
4
|
import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react'
|
|
5
|
-
import { StyleSheet, TextInput,
|
|
5
|
+
import { StyleSheet, TextInput, View } from 'react-native'
|
|
6
|
+
import { Pressable } from 'react-native-gesture-handler'
|
|
6
7
|
import { FieldProps } from '../../types'
|
|
7
8
|
import { useInputStyles } from '../hooks/useInputStyles'
|
|
8
9
|
import { TextAreaComponent } from './textarea'
|
|
@@ -24,7 +25,7 @@ export const TextComponent = forwardRef<InputRef, FieldProps<TextField>>(
|
|
|
24
25
|
inputRef.current?.focus()
|
|
25
26
|
},
|
|
26
27
|
blur: () => {
|
|
27
|
-
inputRef.current?.
|
|
28
|
+
inputRef.current?.clear()
|
|
28
29
|
},
|
|
29
30
|
}))
|
|
30
31
|
|
|
@@ -34,7 +35,7 @@ export const TextComponent = forwardRef<InputRef, FieldProps<TextField>>(
|
|
|
34
35
|
if (type === 'textarea') {
|
|
35
36
|
return (
|
|
36
37
|
<TextAreaComponent
|
|
37
|
-
ref={
|
|
38
|
+
ref={inputRef}
|
|
38
39
|
formSize={formSize}
|
|
39
40
|
inputStyle={inputStyle}
|
|
40
41
|
inEditable={inEditable}
|
|
@@ -51,6 +52,7 @@ export const TextComponent = forwardRef<InputRef, FieldProps<TextField>>(
|
|
|
51
52
|
ref={inputRef}
|
|
52
53
|
style={[inputStyles, { color }, inputStyle]}
|
|
53
54
|
secureTextEntry={isHidden}
|
|
55
|
+
selectTextOnFocus={inEditable}
|
|
54
56
|
placeholderTextColor={placeholderColor}
|
|
55
57
|
placeholder={placeholder}
|
|
56
58
|
value={value ?? ''}
|
|
@@ -62,9 +64,9 @@ export const TextComponent = forwardRef<InputRef, FieldProps<TextField>>(
|
|
|
62
64
|
return type === 'password' ? (
|
|
63
65
|
<View style={[conatinerStyles, styles.passwordContainer, style]}>
|
|
64
66
|
{body}
|
|
65
|
-
<
|
|
67
|
+
<Pressable style={styles.eyeIcon} onPress={() => setIsHidden(!isHidden)}>
|
|
66
68
|
<Ionicons name={isHidden ? 'eye' : 'eye-off'} size={20} color="#666" />
|
|
67
|
-
</
|
|
69
|
+
</Pressable>
|
|
68
70
|
</View>
|
|
69
71
|
) : (
|
|
70
72
|
<View style={[conatinerStyles, style]}>{body}</View>
|
|
@@ -1,34 +1,22 @@
|
|
|
1
|
-
import { InputRef } from '@chem-po/core'
|
|
2
1
|
import { TextField, usePlaceholderColor, useTextColor } from '@chem-po/react'
|
|
3
|
-
import React, { forwardRef
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
4
3
|
import { TextInput, View } from 'react-native'
|
|
5
4
|
import { FieldProps } from '../../types'
|
|
6
5
|
import { useInputStyles } from '../hooks/useInputStyles'
|
|
7
6
|
import { AutoResizeTextarea } from './AutoResizeTextarea'
|
|
8
7
|
|
|
9
|
-
export const TextAreaComponent = forwardRef<
|
|
8
|
+
export const TextAreaComponent = forwardRef<TextInput, FieldProps<TextField>>(
|
|
10
9
|
({ input, field, inEditable, formSize, inputStyle, style }, ref) => {
|
|
11
|
-
const inputRef = useRef<TextInput>(null)
|
|
12
10
|
const { text, container } = useInputStyles(inEditable, field.size, formSize)
|
|
13
11
|
const { value, onChange, ...inputProps } = input
|
|
14
|
-
|
|
15
|
-
useImperativeHandle(ref, () => ({
|
|
16
|
-
focus: () => {
|
|
17
|
-
inputRef.current?.focus()
|
|
18
|
-
},
|
|
19
|
-
blur: () => {
|
|
20
|
-
inputRef.current?.blur()
|
|
21
|
-
},
|
|
22
|
-
}))
|
|
23
|
-
|
|
24
12
|
const placeholderColor = usePlaceholderColor()
|
|
25
13
|
const color = useTextColor()
|
|
26
14
|
|
|
27
15
|
return (
|
|
28
16
|
<View style={[container, style]}>
|
|
29
17
|
<AutoResizeTextarea
|
|
30
|
-
ref={
|
|
31
|
-
style={[{ color, ...text }, inputStyle]}
|
|
18
|
+
ref={ref}
|
|
19
|
+
style={[{ color, ...text, paddingBottom: inEditable ? 0 : 4 }, inputStyle]}
|
|
32
20
|
placeholder={field.placeholder}
|
|
33
21
|
placeholderTextColor={placeholderColor}
|
|
34
22
|
multiline
|
|
@@ -38,33 +38,34 @@ export const useWebAutoResize = (
|
|
|
38
38
|
onChangeText: ((e: string) => void) | undefined,
|
|
39
39
|
style: StyleProp<TextStyle> | undefined,
|
|
40
40
|
) => {
|
|
41
|
-
const
|
|
41
|
+
const flattenedStyle = useMemo(() => StyleSheet.flatten(style), [style])
|
|
42
|
+
const fontSize = useMemo(() => flattenedStyle.fontSize ?? 16, [flattenedStyle.fontSize])
|
|
43
|
+
const [height, setHeight] = useState<number | 'auto'>(
|
|
44
|
+
Platform.OS === 'web' ? fontSize + 10 : 'auto',
|
|
45
|
+
)
|
|
42
46
|
const spanRef = useRef<HTMLSpanElement>(
|
|
43
47
|
Platform.OS === 'web' ? document.createElement('span') : null,
|
|
44
48
|
)
|
|
45
49
|
|
|
46
50
|
useEffect(() => {
|
|
47
51
|
if (Platform.OS === 'web' && spanRef.current) {
|
|
48
|
-
updateSpanStyle(spanRef.current,
|
|
49
|
-
...StyleSheet.flatten(style),
|
|
50
|
-
})
|
|
52
|
+
updateSpanStyle(spanRef.current, flattenedStyle)
|
|
51
53
|
}
|
|
52
|
-
}, [
|
|
54
|
+
}, [flattenedStyle])
|
|
53
55
|
const handleChange = useMemo(
|
|
54
56
|
() =>
|
|
55
57
|
Platform.OS === 'web'
|
|
56
58
|
? (e: string) => {
|
|
57
59
|
if (spanRef.current) {
|
|
58
60
|
const height = getWebTextHeight(e, spanRef)
|
|
59
|
-
setHeight(height ??
|
|
61
|
+
setHeight((height ?? fontSize) + 8)
|
|
60
62
|
if (onChangeText) onChangeText(e)
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
: onChangeText,
|
|
64
|
-
[onChangeText],
|
|
66
|
+
[onChangeText, fontSize],
|
|
65
67
|
)
|
|
66
68
|
return {
|
|
67
|
-
getWebTextHeight,
|
|
68
69
|
handleChange,
|
|
69
70
|
height,
|
|
70
71
|
setHeight,
|
|
@@ -2,7 +2,8 @@ import { InputRef, padZeros } from '@chem-po/core'
|
|
|
2
2
|
import { TimeField, useIconColor } from '@chem-po/react'
|
|
3
3
|
import { Ionicons } from '@expo/vector-icons'
|
|
4
4
|
import React, { forwardRef, useImperativeHandle, useMemo, useState } from 'react'
|
|
5
|
-
import { StyleSheet, Text,
|
|
5
|
+
import { StyleSheet, Text, View } from 'react-native'
|
|
6
|
+
import { Pressable } from 'react-native-gesture-handler'
|
|
6
7
|
import { Portal } from 'react-native-paper'
|
|
7
8
|
import { TimePickerModal } from 'react-native-paper-dates'
|
|
8
9
|
import { FieldProps } from '../../types'
|
|
@@ -71,7 +72,7 @@ export const TimeInput = forwardRef<InputRef, FieldProps<TimeField>>(
|
|
|
71
72
|
|
|
72
73
|
return (
|
|
73
74
|
<View style={styles.container}>
|
|
74
|
-
<
|
|
75
|
+
<Pressable
|
|
75
76
|
style={[styles.button, inputStyles]}
|
|
76
77
|
onPress={() => {
|
|
77
78
|
setVisible(true)
|
|
@@ -90,7 +91,7 @@ export const TimeInput = forwardRef<InputRef, FieldProps<TimeField>>(
|
|
|
90
91
|
/>
|
|
91
92
|
) : null}
|
|
92
93
|
</View>
|
|
93
|
-
</
|
|
94
|
+
</Pressable>
|
|
94
95
|
<Portal>
|
|
95
96
|
<TimePickerModal
|
|
96
97
|
visible={visible}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ImageViewOptions, InputSize } from '@chem-po/core'
|
|
2
|
-
import { FileField } from '@chem-po/react'
|
|
2
|
+
import { FileField, usePlaceholderColor } from '@chem-po/react'
|
|
3
3
|
import React, { useMemo } from 'react'
|
|
4
4
|
import { StyleSheet, Text, View, ViewStyle } from 'react-native'
|
|
5
|
+
import { Txt } from '../../text/Txt'
|
|
5
6
|
import { FileView } from '../input/file'
|
|
7
|
+
import { useInputStyles } from '../input/hooks/useInputStyles'
|
|
6
8
|
|
|
7
9
|
const styles = StyleSheet.create({
|
|
8
10
|
container: {
|
|
@@ -16,9 +18,6 @@ const styles = StyleSheet.create({
|
|
|
16
18
|
opacity: 0.7,
|
|
17
19
|
fontWeight: '600',
|
|
18
20
|
},
|
|
19
|
-
emptyText: {
|
|
20
|
-
opacity: 0.7,
|
|
21
|
-
},
|
|
22
21
|
fileContainer: {
|
|
23
22
|
padding: 4,
|
|
24
23
|
},
|
|
@@ -59,6 +58,9 @@ export const FileFieldView = ({
|
|
|
59
58
|
[imageOptions, size, sizeProp],
|
|
60
59
|
)
|
|
61
60
|
|
|
61
|
+
const { text, container } = useInputStyles(false, field.size, sizeProp)
|
|
62
|
+
const placeholderColor = usePlaceholderColor()
|
|
63
|
+
|
|
62
64
|
return (
|
|
63
65
|
<View style={[value ? styles.container : styles.rowContainer, style]}>
|
|
64
66
|
{!noLabel && <Text style={styles.label}>{placeholder}</Text>}
|
|
@@ -67,7 +69,9 @@ export const FileFieldView = ({
|
|
|
67
69
|
<FileView imageOptions={options} value={value} />
|
|
68
70
|
</View>
|
|
69
71
|
) : (
|
|
70
|
-
<
|
|
72
|
+
<View style={container}>
|
|
73
|
+
<Txt style={[text, { color: placeholderColor }]}>None</Txt>
|
|
74
|
+
</View>
|
|
71
75
|
)}
|
|
72
76
|
</View>
|
|
73
77
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { displayField, InputSize } from '@chem-po/core'
|
|
2
|
-
import { Field, FormatField } from '@chem-po/react'
|
|
2
|
+
import { Field, FormatField, usePlaceholderColor } from '@chem-po/react'
|
|
3
3
|
import React, { useMemo } from 'react'
|
|
4
4
|
import { StyleSheet, View, ViewStyle } from 'react-native'
|
|
5
5
|
import { Txt } from '../../text'
|
|
@@ -22,30 +22,33 @@ const DefaultFieldView = ({
|
|
|
22
22
|
noLabel,
|
|
23
23
|
style,
|
|
24
24
|
size: sizeProp,
|
|
25
|
+
inEditable,
|
|
25
26
|
}: {
|
|
26
27
|
field: Field
|
|
27
28
|
value: any
|
|
28
29
|
noLabel?: boolean
|
|
29
30
|
style?: ViewStyle
|
|
30
31
|
size?: InputSize
|
|
32
|
+
inEditable?: boolean
|
|
31
33
|
}) => {
|
|
32
34
|
const { placeholder } = field
|
|
33
35
|
|
|
34
|
-
const { text } = useInputStyles(
|
|
36
|
+
const { text, container: containerStyles } = useInputStyles(inEditable, field.size, sizeProp)
|
|
35
37
|
const formatted = useMemo(() => {
|
|
36
38
|
const format = displayField[field._type] as FormatField<Field>
|
|
37
39
|
if (!format) return value
|
|
38
40
|
return format(field, value)
|
|
39
41
|
}, [value, field])
|
|
40
42
|
|
|
43
|
+
const placeholderColor = usePlaceholderColor()
|
|
41
44
|
const hasValue = useMemo(() => {
|
|
42
45
|
return value !== null && value !== undefined && value !== ''
|
|
43
46
|
}, [value])
|
|
44
47
|
|
|
45
48
|
return (
|
|
46
|
-
<View style={[styles.container, style]}>
|
|
49
|
+
<View style={[styles.container, containerStyles, { backgroundColor: 'transparent' }, style]}>
|
|
47
50
|
{!noLabel && <Txt style={[inputViewStyles.label, text]}>{placeholder}</Txt>}
|
|
48
|
-
<Txt style={[hasValue ?
|
|
51
|
+
<Txt style={[text, { color: hasValue ? undefined : placeholderColor }]}>
|
|
49
52
|
{hasValue ? formatted : 'None'}
|
|
50
53
|
</Txt>
|
|
51
54
|
</View>
|
|
@@ -58,17 +61,26 @@ export const FieldView = ({
|
|
|
58
61
|
noLabel,
|
|
59
62
|
style,
|
|
60
63
|
size,
|
|
64
|
+
inEditable,
|
|
61
65
|
}: {
|
|
62
66
|
field: Field
|
|
63
|
-
value
|
|
67
|
+
value?: any
|
|
64
68
|
noLabel?: boolean
|
|
65
69
|
style?: ViewStyle
|
|
66
70
|
size?: InputSize
|
|
71
|
+
inEditable?: boolean
|
|
67
72
|
}) => {
|
|
68
73
|
switch (field._type) {
|
|
69
74
|
case 'select':
|
|
70
75
|
return (
|
|
71
|
-
<SelectFieldView
|
|
76
|
+
<SelectFieldView
|
|
77
|
+
style={style}
|
|
78
|
+
field={field}
|
|
79
|
+
value={value}
|
|
80
|
+
noLabel={noLabel}
|
|
81
|
+
size={size}
|
|
82
|
+
inEditable={inEditable}
|
|
83
|
+
/>
|
|
72
84
|
)
|
|
73
85
|
case 'multipleSelect':
|
|
74
86
|
return (
|
|
@@ -86,7 +98,14 @@ export const FieldView = ({
|
|
|
86
98
|
)
|
|
87
99
|
default:
|
|
88
100
|
return (
|
|
89
|
-
<DefaultFieldView
|
|
101
|
+
<DefaultFieldView
|
|
102
|
+
style={style}
|
|
103
|
+
field={field}
|
|
104
|
+
value={value}
|
|
105
|
+
noLabel={noLabel}
|
|
106
|
+
size={size}
|
|
107
|
+
inEditable={inEditable}
|
|
108
|
+
/>
|
|
90
109
|
)
|
|
91
110
|
}
|
|
92
111
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { InputSize } from '@chem-po/core'
|
|
2
|
-
import { MultipleSelectField, useColorMode } from '@chem-po/react'
|
|
2
|
+
import { MultipleSelectField, useColorMode, usePlaceholderColor } from '@chem-po/react'
|
|
3
3
|
import { useMemo } from 'react'
|
|
4
4
|
import React, { StyleSheet, Text, View, ViewStyle } from 'react-native'
|
|
5
|
+
import { Txt } from '../../text/Txt'
|
|
5
6
|
import { useInputStyles } from '../input/hooks/useInputStyles'
|
|
6
7
|
import { SelectedOptionContainer } from '../input/multipleSelect'
|
|
7
8
|
import { DefaultRenderOption } from './select'
|
|
@@ -12,6 +13,7 @@ const styles = StyleSheet.create({
|
|
|
12
13
|
flexWrap: 'wrap',
|
|
13
14
|
alignItems: 'center',
|
|
14
15
|
maxWidth: '100%',
|
|
16
|
+
backgroundColor: 'transparent',
|
|
15
17
|
},
|
|
16
18
|
label: {
|
|
17
19
|
paddingRight: 8,
|
|
@@ -27,9 +29,6 @@ const styles = StyleSheet.create({
|
|
|
27
29
|
marginTop: 2,
|
|
28
30
|
marginHorizontal: 2,
|
|
29
31
|
},
|
|
30
|
-
emptyText: {
|
|
31
|
-
opacity: 0.6,
|
|
32
|
-
},
|
|
33
32
|
})
|
|
34
33
|
|
|
35
34
|
export const MultipleSelectFieldView = <F extends MultipleSelectField>({
|
|
@@ -48,13 +47,14 @@ export const MultipleSelectFieldView = <F extends MultipleSelectField>({
|
|
|
48
47
|
const { placeholder, renderOption: customRender, options } = field
|
|
49
48
|
const selectedOptions = options.filter(o => value?.includes(o.value))
|
|
50
49
|
const colorMode = useColorMode()
|
|
51
|
-
const { size,
|
|
50
|
+
const { size, text, container } = useInputStyles(true, field.size, sizeProp)
|
|
51
|
+
const placeholderColor = usePlaceholderColor()
|
|
52
52
|
const selectedOptionStyle = useMemo<ViewStyle>(() => {
|
|
53
53
|
return {
|
|
54
|
-
paddingHorizontal:
|
|
55
|
-
paddingVertical:
|
|
54
|
+
paddingHorizontal: container.paddingHorizontal,
|
|
55
|
+
paddingVertical: container.paddingVertical,
|
|
56
56
|
}
|
|
57
|
-
}, [
|
|
57
|
+
}, [container])
|
|
58
58
|
const RenderOption = useMemo(() => customRender ?? DefaultRenderOption, [customRender])
|
|
59
59
|
return (
|
|
60
60
|
<View style={[styles.container, style]}>
|
|
@@ -74,7 +74,9 @@ export const MultipleSelectFieldView = <F extends MultipleSelectField>({
|
|
|
74
74
|
))}
|
|
75
75
|
</View>
|
|
76
76
|
) : (
|
|
77
|
-
<
|
|
77
|
+
<View style={container}>
|
|
78
|
+
<Txt style={[text, { color: placeholderColor }]}>None</Txt>
|
|
79
|
+
</View>
|
|
78
80
|
)}
|
|
79
81
|
</View>
|
|
80
82
|
)
|
|
@@ -10,6 +10,7 @@ const styles = StyleSheet.create({
|
|
|
10
10
|
container: {
|
|
11
11
|
flexDirection: 'row',
|
|
12
12
|
alignItems: 'center',
|
|
13
|
+
backgroundColor: 'transparent',
|
|
13
14
|
},
|
|
14
15
|
label: {
|
|
15
16
|
paddingRight: 10,
|
|
@@ -23,7 +24,11 @@ export const DefaultRenderOption = <
|
|
|
23
24
|
>({
|
|
24
25
|
option,
|
|
25
26
|
}: RenderSelectOptionProps<Value, Option>) => {
|
|
26
|
-
return
|
|
27
|
+
return (
|
|
28
|
+
<View style={{ padding: 6 }}>
|
|
29
|
+
<Txt style={inputViewStyles.value}>{option.label}</Txt>
|
|
30
|
+
</View>
|
|
31
|
+
)
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
export const SelectFieldView = ({
|
|
@@ -32,17 +37,19 @@ export const SelectFieldView = ({
|
|
|
32
37
|
noLabel,
|
|
33
38
|
style,
|
|
34
39
|
size: sizeProp,
|
|
40
|
+
inEditable,
|
|
35
41
|
}: {
|
|
36
42
|
field: SelectField
|
|
37
43
|
value: any
|
|
38
44
|
noLabel?: boolean
|
|
39
45
|
style?: ViewStyle
|
|
40
46
|
size?: InputSize
|
|
47
|
+
inEditable?: boolean
|
|
41
48
|
}) => {
|
|
42
49
|
const { placeholder, renderOption: customRender } = field
|
|
43
50
|
const colorMode = useColorMode()
|
|
44
51
|
const placeholderColor = usePlaceholderColor()
|
|
45
|
-
const { size, text } = useInputStyles(
|
|
52
|
+
const { size, text, container } = useInputStyles(inEditable, field.size, sizeProp)
|
|
46
53
|
const selectedOption = field.options.find(o => o.value === value)
|
|
47
54
|
const RenderOption = customRender ?? DefaultRenderOption
|
|
48
55
|
return (
|
|
@@ -59,7 +66,9 @@ export const SelectFieldView = ({
|
|
|
59
66
|
size={size}
|
|
60
67
|
/>
|
|
61
68
|
) : (
|
|
62
|
-
<
|
|
69
|
+
<View style={container}>
|
|
70
|
+
<Txt style={[text, { color: placeholderColor }]}>None</Txt>
|
|
71
|
+
</View>
|
|
63
72
|
)}
|
|
64
73
|
</View>
|
|
65
74
|
)
|