@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.
Files changed (215) hide show
  1. package/lib/commonjs/components/button/DeleteButton.js +7 -8
  2. package/lib/commonjs/components/button/DeleteButton.js.map +1 -1
  3. package/lib/commonjs/components/button/LoadingButton.js +3 -3
  4. package/lib/commonjs/components/button/LoadingButton.js.map +1 -1
  5. package/lib/commonjs/components/button/Toggle.js +21 -17
  6. package/lib/commonjs/components/button/Toggle.js.map +1 -1
  7. package/lib/commonjs/components/form/Form.js +30 -4
  8. package/lib/commonjs/components/form/Form.js.map +1 -1
  9. package/lib/commonjs/components/form/FormFooter.js +3 -2
  10. package/lib/commonjs/components/form/FormFooter.js.map +1 -1
  11. package/lib/commonjs/components/form/input/Editable.js +50 -73
  12. package/lib/commonjs/components/form/input/Editable.js.map +1 -1
  13. package/lib/commonjs/components/form/input/StandaloneInput.js.map +1 -1
  14. package/lib/commonjs/components/form/input/common/InputClearButton.js +2 -1
  15. package/lib/commonjs/components/form/input/common/InputClearButton.js.map +1 -1
  16. package/lib/commonjs/components/form/input/date/index.js +23 -10
  17. package/lib/commonjs/components/form/input/date/index.js.map +1 -1
  18. package/lib/commonjs/components/form/input/datetime/index.js +32 -11
  19. package/lib/commonjs/components/form/input/datetime/index.js.map +1 -1
  20. package/lib/commonjs/components/form/input/file/index.js +27 -27
  21. package/lib/commonjs/components/form/input/file/index.js.map +1 -1
  22. package/lib/commonjs/components/form/input/hooks/useInputStyles.js +5 -6
  23. package/lib/commonjs/components/form/input/hooks/useInputStyles.js.map +1 -1
  24. package/lib/commonjs/components/form/input/input.js +3 -3
  25. package/lib/commonjs/components/form/input/input.js.map +1 -1
  26. package/lib/commonjs/components/form/input/multipleSelect/index.js +41 -24
  27. package/lib/commonjs/components/form/input/multipleSelect/index.js.map +1 -1
  28. package/lib/commonjs/components/form/input/select/index.js +1 -1
  29. package/lib/commonjs/components/form/input/select/index.js.map +1 -1
  30. package/lib/commonjs/components/form/input/socialMedia/index.js +3 -2
  31. package/lib/commonjs/components/form/input/socialMedia/index.js.map +1 -1
  32. package/lib/commonjs/components/form/input/text/AutoResizeTextarea.js +1 -6
  33. package/lib/commonjs/components/form/input/text/AutoResizeTextarea.js.map +1 -1
  34. package/lib/commonjs/components/form/input/text/index.js +5 -3
  35. package/lib/commonjs/components/form/input/text/index.js.map +1 -1
  36. package/lib/commonjs/components/form/input/text/textarea.js +3 -13
  37. package/lib/commonjs/components/form/input/text/textarea.js.map +1 -1
  38. package/lib/commonjs/components/form/input/text/useWebAutoResize.js +7 -8
  39. package/lib/commonjs/components/form/input/text/useWebAutoResize.js.map +1 -1
  40. package/lib/commonjs/components/form/input/time/index.js +2 -1
  41. package/lib/commonjs/components/form/input/time/index.js.map +1 -1
  42. package/lib/commonjs/components/form/view/file.js +21 -12
  43. package/lib/commonjs/components/form/view/file.js.map +1 -1
  44. package/lib/commonjs/components/form/view/index.js +29 -18
  45. package/lib/commonjs/components/form/view/index.js.map +1 -1
  46. package/lib/commonjs/components/form/view/multipleSelect.js +17 -13
  47. package/lib/commonjs/components/form/view/multipleSelect.js.map +1 -1
  48. package/lib/commonjs/components/form/view/select.js +20 -9
  49. package/lib/commonjs/components/form/view/select.js.map +1 -1
  50. package/lib/commonjs/components/form/view/styles.js +0 -3
  51. package/lib/commonjs/components/form/view/styles.js.map +1 -1
  52. package/lib/commonjs/components/image/ImageViewModal.js +18 -15
  53. package/lib/commonjs/components/image/ImageViewModal.js.map +1 -1
  54. package/lib/commonjs/components/layout/CollapseHorizontal.js +84 -0
  55. package/lib/commonjs/components/layout/CollapseHorizontal.js.map +1 -0
  56. package/lib/commonjs/components/loading/LoadingImage.js +20 -13
  57. package/lib/commonjs/components/loading/LoadingImage.js.map +1 -1
  58. package/lib/commonjs/components/theme/colorMode/DarkModeToggle.js +2 -1
  59. package/lib/commonjs/components/theme/colorMode/DarkModeToggle.js.map +1 -1
  60. package/lib/commonjs/contexts/root.js +6 -6
  61. package/lib/commonjs/contexts/root.js.map +1 -1
  62. package/lib/commonjs/index.js +11 -0
  63. package/lib/commonjs/index.js.map +1 -1
  64. package/lib/commonjs/types/forms.js +6 -0
  65. package/lib/commonjs/types/forms.js.map +1 -0
  66. package/lib/commonjs/types/index.js +17 -0
  67. package/lib/commonjs/types/index.js.map +1 -0
  68. package/lib/module/components/button/DeleteButton.js +8 -9
  69. package/lib/module/components/button/DeleteButton.js.map +1 -1
  70. package/lib/module/components/button/LoadingButton.js +4 -4
  71. package/lib/module/components/button/LoadingButton.js.map +1 -1
  72. package/lib/module/components/button/Toggle.js +24 -20
  73. package/lib/module/components/button/Toggle.js.map +1 -1
  74. package/lib/module/components/form/Form.js +31 -5
  75. package/lib/module/components/form/Form.js.map +1 -1
  76. package/lib/module/components/form/FormFooter.js +4 -3
  77. package/lib/module/components/form/FormFooter.js.map +1 -1
  78. package/lib/module/components/form/input/Editable.js +51 -74
  79. package/lib/module/components/form/input/Editable.js.map +1 -1
  80. package/lib/module/components/form/input/StandaloneInput.js.map +1 -1
  81. package/lib/module/components/form/input/common/InputClearButton.js +3 -2
  82. package/lib/module/components/form/input/common/InputClearButton.js.map +1 -1
  83. package/lib/module/components/form/input/date/index.js +24 -11
  84. package/lib/module/components/form/input/date/index.js.map +1 -1
  85. package/lib/module/components/form/input/datetime/index.js +33 -12
  86. package/lib/module/components/form/input/datetime/index.js.map +1 -1
  87. package/lib/module/components/form/input/file/index.js +29 -29
  88. package/lib/module/components/form/input/file/index.js.map +1 -1
  89. package/lib/module/components/form/input/hooks/useInputStyles.js +5 -6
  90. package/lib/module/components/form/input/hooks/useInputStyles.js.map +1 -1
  91. package/lib/module/components/form/input/input.js +3 -3
  92. package/lib/module/components/form/input/input.js.map +1 -1
  93. package/lib/module/components/form/input/multipleSelect/index.js +41 -24
  94. package/lib/module/components/form/input/multipleSelect/index.js.map +1 -1
  95. package/lib/module/components/form/input/select/index.js +1 -1
  96. package/lib/module/components/form/input/select/index.js.map +1 -1
  97. package/lib/module/components/form/input/socialMedia/index.js +4 -3
  98. package/lib/module/components/form/input/socialMedia/index.js.map +1 -1
  99. package/lib/module/components/form/input/text/AutoResizeTextarea.js +1 -6
  100. package/lib/module/components/form/input/text/AutoResizeTextarea.js.map +1 -1
  101. package/lib/module/components/form/input/text/index.js +6 -4
  102. package/lib/module/components/form/input/text/index.js.map +1 -1
  103. package/lib/module/components/form/input/text/textarea.js +4 -14
  104. package/lib/module/components/form/input/text/textarea.js.map +1 -1
  105. package/lib/module/components/form/input/text/useWebAutoResize.js +7 -8
  106. package/lib/module/components/form/input/text/useWebAutoResize.js.map +1 -1
  107. package/lib/module/components/form/input/time/index.js +3 -2
  108. package/lib/module/components/form/input/time/index.js.map +1 -1
  109. package/lib/module/components/form/view/file.js +15 -6
  110. package/lib/module/components/form/view/file.js.map +1 -1
  111. package/lib/module/components/form/view/index.js +19 -8
  112. package/lib/module/components/form/view/index.js.map +1 -1
  113. package/lib/module/components/form/view/multipleSelect.js +18 -14
  114. package/lib/module/components/form/view/multipleSelect.js.map +1 -1
  115. package/lib/module/components/form/view/select.js +20 -9
  116. package/lib/module/components/form/view/select.js.map +1 -1
  117. package/lib/module/components/form/view/styles.js +0 -3
  118. package/lib/module/components/form/view/styles.js.map +1 -1
  119. package/lib/module/components/image/ImageViewModal.js +20 -17
  120. package/lib/module/components/image/ImageViewModal.js.map +1 -1
  121. package/lib/module/components/layout/CollapseHorizontal.js +76 -0
  122. package/lib/module/components/layout/CollapseHorizontal.js.map +1 -0
  123. package/lib/module/components/loading/LoadingImage.js +21 -14
  124. package/lib/module/components/loading/LoadingImage.js.map +1 -1
  125. package/lib/module/components/theme/colorMode/DarkModeToggle.js +3 -2
  126. package/lib/module/components/theme/colorMode/DarkModeToggle.js.map +1 -1
  127. package/lib/module/contexts/root.js +6 -6
  128. package/lib/module/contexts/root.js.map +1 -1
  129. package/lib/module/index.js +1 -0
  130. package/lib/module/index.js.map +1 -1
  131. package/lib/module/types/forms.js +2 -0
  132. package/lib/module/types/forms.js.map +1 -0
  133. package/lib/module/types/index.js +2 -0
  134. package/lib/module/types/index.js.map +1 -0
  135. package/lib/typescript/components/button/DeleteButton.d.ts.map +1 -1
  136. package/lib/typescript/components/button/LoadingButton.d.ts.map +1 -1
  137. package/lib/typescript/components/button/Toggle.d.ts +5 -2
  138. package/lib/typescript/components/button/Toggle.d.ts.map +1 -1
  139. package/lib/typescript/components/form/Form.d.ts.map +1 -1
  140. package/lib/typescript/components/form/FormFooter.d.ts.map +1 -1
  141. package/lib/typescript/components/form/input/Editable.d.ts +2 -2
  142. package/lib/typescript/components/form/input/Editable.d.ts.map +1 -1
  143. package/lib/typescript/components/form/input/StandaloneInput.d.ts +5 -14
  144. package/lib/typescript/components/form/input/StandaloneInput.d.ts.map +1 -1
  145. package/lib/typescript/components/form/input/common/InputClearButton.d.ts.map +1 -1
  146. package/lib/typescript/components/form/input/date/index.d.ts.map +1 -1
  147. package/lib/typescript/components/form/input/datetime/index.d.ts.map +1 -1
  148. package/lib/typescript/components/form/input/file/index.d.ts +2 -1
  149. package/lib/typescript/components/form/input/file/index.d.ts.map +1 -1
  150. package/lib/typescript/components/form/input/hooks/useInputStyles.d.ts +3 -6
  151. package/lib/typescript/components/form/input/hooks/useInputStyles.d.ts.map +1 -1
  152. package/lib/typescript/components/form/input/multipleSelect/index.d.ts.map +1 -1
  153. package/lib/typescript/components/form/input/socialMedia/index.d.ts.map +1 -1
  154. package/lib/typescript/components/form/input/text/AutoResizeTextarea.d.ts.map +1 -1
  155. package/lib/typescript/components/form/input/text/index.d.ts.map +1 -1
  156. package/lib/typescript/components/form/input/text/textarea.d.ts +2 -2
  157. package/lib/typescript/components/form/input/text/textarea.d.ts.map +1 -1
  158. package/lib/typescript/components/form/input/text/useWebAutoResize.d.ts +2 -3
  159. package/lib/typescript/components/form/input/text/useWebAutoResize.d.ts.map +1 -1
  160. package/lib/typescript/components/form/input/time/index.d.ts.map +1 -1
  161. package/lib/typescript/components/form/view/file.d.ts.map +1 -1
  162. package/lib/typescript/components/form/view/index.d.ts +3 -2
  163. package/lib/typescript/components/form/view/index.d.ts.map +1 -1
  164. package/lib/typescript/components/form/view/multipleSelect.d.ts.map +1 -1
  165. package/lib/typescript/components/form/view/select.d.ts +2 -1
  166. package/lib/typescript/components/form/view/select.d.ts.map +1 -1
  167. package/lib/typescript/components/form/view/styles.d.ts +0 -3
  168. package/lib/typescript/components/form/view/styles.d.ts.map +1 -1
  169. package/lib/typescript/components/image/ImageViewModal.d.ts.map +1 -1
  170. package/lib/typescript/components/layout/CollapseHorizontal.d.ts +9 -0
  171. package/lib/typescript/components/layout/CollapseHorizontal.d.ts.map +1 -0
  172. package/lib/typescript/components/loading/LoadingImage.d.ts +4 -1
  173. package/lib/typescript/components/loading/LoadingImage.d.ts.map +1 -1
  174. package/lib/typescript/components/theme/colorMode/DarkModeToggle.d.ts.map +1 -1
  175. package/lib/typescript/index.d.ts +1 -0
  176. package/lib/typescript/index.d.ts.map +1 -1
  177. package/lib/typescript/types/forms.d.ts +5 -0
  178. package/lib/typescript/types/forms.d.ts.map +1 -0
  179. package/lib/typescript/types/index.d.ts +2 -0
  180. package/lib/typescript/types/index.d.ts.map +1 -0
  181. package/package.json +4 -4
  182. package/src/components/button/DeleteButton.tsx +12 -25
  183. package/src/components/button/LoadingButton.tsx +4 -5
  184. package/src/components/button/Toggle.tsx +24 -19
  185. package/src/components/form/Form.tsx +31 -11
  186. package/src/components/form/FormFooter.tsx +6 -5
  187. package/src/components/form/input/Editable.tsx +52 -92
  188. package/src/components/form/input/StandaloneInput.tsx +4 -13
  189. package/src/components/form/input/common/InputClearButton.tsx +4 -3
  190. package/src/components/form/input/date/index.tsx +24 -11
  191. package/src/components/form/input/datetime/index.tsx +37 -15
  192. package/src/components/form/input/file/index.tsx +34 -35
  193. package/src/components/form/input/hooks/useInputStyles.ts +10 -7
  194. package/src/components/form/input/input.tsx +2 -2
  195. package/src/components/form/input/multipleSelect/index.tsx +47 -36
  196. package/src/components/form/input/select/index.tsx +1 -1
  197. package/src/components/form/input/socialMedia/index.tsx +6 -5
  198. package/src/components/form/input/text/AutoResizeTextarea.tsx +1 -5
  199. package/src/components/form/input/text/index.tsx +7 -5
  200. package/src/components/form/input/text/textarea.tsx +4 -16
  201. package/src/components/form/input/text/useWebAutoResize.tsx +9 -8
  202. package/src/components/form/input/time/index.tsx +4 -3
  203. package/src/components/form/view/file.tsx +9 -5
  204. package/src/components/form/view/index.tsx +26 -7
  205. package/src/components/form/view/multipleSelect.tsx +11 -9
  206. package/src/components/form/view/select.tsx +12 -3
  207. package/src/components/form/view/styles.ts +0 -3
  208. package/src/components/image/ImageViewModal.tsx +56 -50
  209. package/src/components/layout/CollapseHorizontal.tsx +92 -0
  210. package/src/components/loading/LoadingImage.tsx +19 -19
  211. package/src/components/theme/colorMode/DarkModeToggle.tsx +4 -3
  212. package/src/contexts/root.tsx +6 -6
  213. package/src/index.ts +1 -0
  214. package/src/types/forms.ts +14 -0
  215. 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
- container: inputStyles,
53
- iconSize,
54
- clearButtonSize,
55
- text,
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('#ffffff55', '#ffffff22')
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={[defaultSelectedOptionStyle, text]}>{props.option.label}</Txt>
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={[inputStyles, { borderColor }]}
103
+ style={[container, { borderColor, boxShadow: `0 0 10px ${borderColor}`, borderWidth: 0 }]}
110
104
  placeholderStyle={[text, { color: value?.length ? textColor : placeholderColor }]}
111
- containerStyle={{ backgroundColor: menuBg, boxShadow: `0 0 10px ${borderColor}` }}
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={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 style={{ backgroundColor: menuBg }}>
130
- <View style={{ backgroundColor: selected ? selectedOptionBg : 'transparent' }}>
131
- <RenderOptionText
132
- value={item.value}
133
- option={item}
134
- colorMode={colorMode}
135
- isSelected={!!selected}
136
- size={size}
137
- />
138
- </View>
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
- padding: 10,
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
  })
@@ -120,7 +120,7 @@ const BaseSelectComponent = <T extends SelectField>(
120
120
  size={iconSize}
121
121
  color={iconColor}
122
122
  />
123
- {optional && value && !inEditable ? (
123
+ {optional && value ? (
124
124
  <InputClearButton
125
125
  size={clearButtonSize}
126
126
  onPress={() => {
@@ -9,7 +9,8 @@ import React, {
9
9
  useMemo,
10
10
  useState,
11
11
  } from 'react'
12
- import { Modal, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native'
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
- <TouchableOpacity
46
+ <Pressable
46
47
  style={[styles.iconButton, !handle && styles.iconButtonInactive]}
47
48
  onPress={() => onModalClose()}>
48
49
  <Text style={styles.iconText}>{siteToIcon[site]}</Text>
49
- </TouchableOpacity>
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
- <TouchableOpacity style={styles.closeButton} onPress={onModalClose}>
69
+ <Pressable style={styles.closeButton} onPress={onModalClose}>
69
70
  <Text style={styles.closeButtonText}>Close</Text>
70
- </TouchableOpacity>
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, setHeight } = useWebAutoResize(onChangeText, style)
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, TouchableOpacity, View } from 'react-native'
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?.blur()
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={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
- <TouchableOpacity style={styles.eyeIcon} onPress={() => setIsHidden(!isHidden)}>
67
+ <Pressable style={styles.eyeIcon} onPress={() => setIsHidden(!isHidden)}>
66
68
  <Ionicons name={isHidden ? 'eye' : 'eye-off'} size={20} color="#666" />
67
- </TouchableOpacity>
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, useImperativeHandle, useRef } from 'react'
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<InputRef, FieldProps<TextField>>(
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={inputRef}
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 [height, setHeight] = useState(18)
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
- }, [style])
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 ?? 18)
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, TouchableOpacity, View } from 'react-native'
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
- <TouchableOpacity
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
- </TouchableOpacity>
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
- <Text style={styles.emptyText}>None</Text>
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(false, field.size, sizeProp)
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 ? inputViewStyles.value : inputViewStyles.valueEmpty, text]}>
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: any
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 style={style} field={field} value={value} noLabel={noLabel} size={size} />
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 style={style} field={field} value={value} noLabel={noLabel} size={size} />
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, container: inputStyles, text } = useInputStyles(undefined, field.size, sizeProp)
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: inputStyles.paddingHorizontal,
55
- paddingVertical: inputStyles.paddingVertical,
54
+ paddingHorizontal: container.paddingHorizontal,
55
+ paddingVertical: container.paddingVertical,
56
56
  }
57
- }, [inputStyles])
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
- <Text style={[styles.emptyText, text]}>None</Text>
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 <Txt style={inputViewStyles.value}>{option.label}</Txt>
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(false, field.size, sizeProp)
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
- <Txt style={inputViewStyles.valueEmpty}>None</Txt>
69
+ <View style={container}>
70
+ <Txt style={[text, { color: placeholderColor }]}>None</Txt>
71
+ </View>
63
72
  )}
64
73
  </View>
65
74
  )
@@ -9,7 +9,4 @@ export const inputViewStyles = StyleSheet.create({
9
9
  value: {
10
10
  opacity: 1,
11
11
  },
12
- valueEmpty: {
13
- opacity: 0.6,
14
- },
15
12
  })