@chem-po/react-native 0.0.30 → 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 (147) 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 +2 -1
  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 +4 -6
  12. package/lib/commonjs/components/form/input/Editable.js.map +1 -1
  13. package/lib/commonjs/components/form/input/common/InputClearButton.js +2 -1
  14. package/lib/commonjs/components/form/input/common/InputClearButton.js.map +1 -1
  15. package/lib/commonjs/components/form/input/date/index.js +23 -10
  16. package/lib/commonjs/components/form/input/date/index.js.map +1 -1
  17. package/lib/commonjs/components/form/input/datetime/index.js +27 -11
  18. package/lib/commonjs/components/form/input/datetime/index.js.map +1 -1
  19. package/lib/commonjs/components/form/input/file/index.js +27 -27
  20. package/lib/commonjs/components/form/input/file/index.js.map +1 -1
  21. package/lib/commonjs/components/form/input/hooks/useInputStyles.js +5 -6
  22. package/lib/commonjs/components/form/input/hooks/useInputStyles.js.map +1 -1
  23. package/lib/commonjs/components/form/input/input.js +3 -3
  24. package/lib/commonjs/components/form/input/input.js.map +1 -1
  25. package/lib/commonjs/components/form/input/multipleSelect/index.js +35 -23
  26. package/lib/commonjs/components/form/input/multipleSelect/index.js.map +1 -1
  27. package/lib/commonjs/components/form/input/socialMedia/index.js +3 -2
  28. package/lib/commonjs/components/form/input/socialMedia/index.js.map +1 -1
  29. package/lib/commonjs/components/form/input/text/AutoResizeTextarea.js +1 -6
  30. package/lib/commonjs/components/form/input/text/AutoResizeTextarea.js.map +1 -1
  31. package/lib/commonjs/components/form/input/text/index.js +2 -1
  32. package/lib/commonjs/components/form/input/text/index.js.map +1 -1
  33. package/lib/commonjs/components/form/input/text/textarea.js +2 -1
  34. package/lib/commonjs/components/form/input/text/textarea.js.map +1 -1
  35. package/lib/commonjs/components/form/input/text/useWebAutoResize.js +4 -4
  36. package/lib/commonjs/components/form/input/text/useWebAutoResize.js.map +1 -1
  37. package/lib/commonjs/components/form/input/time/index.js +2 -1
  38. package/lib/commonjs/components/form/input/time/index.js.map +1 -1
  39. package/lib/commonjs/components/form/view/select.js +6 -2
  40. package/lib/commonjs/components/form/view/select.js.map +1 -1
  41. package/lib/commonjs/components/image/ImageViewModal.js +18 -15
  42. package/lib/commonjs/components/image/ImageViewModal.js.map +1 -1
  43. package/lib/commonjs/components/layout/CollapseHorizontal.js +23 -11
  44. package/lib/commonjs/components/layout/CollapseHorizontal.js.map +1 -1
  45. package/lib/commonjs/components/loading/LoadingImage.js +20 -13
  46. package/lib/commonjs/components/loading/LoadingImage.js.map +1 -1
  47. package/lib/commonjs/components/theme/colorMode/DarkModeToggle.js +2 -1
  48. package/lib/commonjs/components/theme/colorMode/DarkModeToggle.js.map +1 -1
  49. package/lib/module/components/button/DeleteButton.js +8 -9
  50. package/lib/module/components/button/DeleteButton.js.map +1 -1
  51. package/lib/module/components/button/LoadingButton.js +4 -4
  52. package/lib/module/components/button/LoadingButton.js.map +1 -1
  53. package/lib/module/components/button/Toggle.js +3 -2
  54. package/lib/module/components/button/Toggle.js.map +1 -1
  55. package/lib/module/components/form/Form.js +31 -5
  56. package/lib/module/components/form/Form.js.map +1 -1
  57. package/lib/module/components/form/FormFooter.js +4 -3
  58. package/lib/module/components/form/FormFooter.js.map +1 -1
  59. package/lib/module/components/form/input/Editable.js +5 -7
  60. package/lib/module/components/form/input/Editable.js.map +1 -1
  61. package/lib/module/components/form/input/common/InputClearButton.js +3 -2
  62. package/lib/module/components/form/input/common/InputClearButton.js.map +1 -1
  63. package/lib/module/components/form/input/date/index.js +24 -11
  64. package/lib/module/components/form/input/date/index.js.map +1 -1
  65. package/lib/module/components/form/input/datetime/index.js +29 -13
  66. package/lib/module/components/form/input/datetime/index.js.map +1 -1
  67. package/lib/module/components/form/input/file/index.js +29 -29
  68. package/lib/module/components/form/input/file/index.js.map +1 -1
  69. package/lib/module/components/form/input/hooks/useInputStyles.js +5 -6
  70. package/lib/module/components/form/input/hooks/useInputStyles.js.map +1 -1
  71. package/lib/module/components/form/input/input.js +3 -3
  72. package/lib/module/components/form/input/input.js.map +1 -1
  73. package/lib/module/components/form/input/multipleSelect/index.js +35 -23
  74. package/lib/module/components/form/input/multipleSelect/index.js.map +1 -1
  75. package/lib/module/components/form/input/socialMedia/index.js +4 -3
  76. package/lib/module/components/form/input/socialMedia/index.js.map +1 -1
  77. package/lib/module/components/form/input/text/AutoResizeTextarea.js +1 -6
  78. package/lib/module/components/form/input/text/AutoResizeTextarea.js.map +1 -1
  79. package/lib/module/components/form/input/text/index.js +3 -2
  80. package/lib/module/components/form/input/text/index.js.map +1 -1
  81. package/lib/module/components/form/input/text/textarea.js +2 -1
  82. package/lib/module/components/form/input/text/textarea.js.map +1 -1
  83. package/lib/module/components/form/input/text/useWebAutoResize.js +4 -4
  84. package/lib/module/components/form/input/text/useWebAutoResize.js.map +1 -1
  85. package/lib/module/components/form/input/time/index.js +3 -2
  86. package/lib/module/components/form/input/time/index.js.map +1 -1
  87. package/lib/module/components/form/view/select.js +6 -2
  88. package/lib/module/components/form/view/select.js.map +1 -1
  89. package/lib/module/components/image/ImageViewModal.js +20 -17
  90. package/lib/module/components/image/ImageViewModal.js.map +1 -1
  91. package/lib/module/components/layout/CollapseHorizontal.js +24 -12
  92. package/lib/module/components/layout/CollapseHorizontal.js.map +1 -1
  93. package/lib/module/components/loading/LoadingImage.js +21 -14
  94. package/lib/module/components/loading/LoadingImage.js.map +1 -1
  95. package/lib/module/components/theme/colorMode/DarkModeToggle.js +3 -2
  96. package/lib/module/components/theme/colorMode/DarkModeToggle.js.map +1 -1
  97. package/lib/typescript/components/button/DeleteButton.d.ts.map +1 -1
  98. package/lib/typescript/components/button/LoadingButton.d.ts.map +1 -1
  99. package/lib/typescript/components/button/Toggle.d.ts.map +1 -1
  100. package/lib/typescript/components/form/Form.d.ts.map +1 -1
  101. package/lib/typescript/components/form/FormFooter.d.ts.map +1 -1
  102. package/lib/typescript/components/form/input/Editable.d.ts.map +1 -1
  103. package/lib/typescript/components/form/input/common/InputClearButton.d.ts.map +1 -1
  104. package/lib/typescript/components/form/input/date/index.d.ts.map +1 -1
  105. package/lib/typescript/components/form/input/datetime/index.d.ts.map +1 -1
  106. package/lib/typescript/components/form/input/file/index.d.ts +2 -1
  107. package/lib/typescript/components/form/input/file/index.d.ts.map +1 -1
  108. package/lib/typescript/components/form/input/hooks/useInputStyles.d.ts +3 -6
  109. package/lib/typescript/components/form/input/hooks/useInputStyles.d.ts.map +1 -1
  110. package/lib/typescript/components/form/input/multipleSelect/index.d.ts.map +1 -1
  111. package/lib/typescript/components/form/input/socialMedia/index.d.ts.map +1 -1
  112. package/lib/typescript/components/form/input/text/AutoResizeTextarea.d.ts.map +1 -1
  113. package/lib/typescript/components/form/input/text/index.d.ts.map +1 -1
  114. package/lib/typescript/components/form/input/text/useWebAutoResize.d.ts +2 -3
  115. package/lib/typescript/components/form/input/text/useWebAutoResize.d.ts.map +1 -1
  116. package/lib/typescript/components/form/input/time/index.d.ts.map +1 -1
  117. package/lib/typescript/components/form/view/select.d.ts.map +1 -1
  118. package/lib/typescript/components/image/ImageViewModal.d.ts.map +1 -1
  119. package/lib/typescript/components/layout/CollapseHorizontal.d.ts.map +1 -1
  120. package/lib/typescript/components/loading/LoadingImage.d.ts +4 -1
  121. package/lib/typescript/components/loading/LoadingImage.d.ts.map +1 -1
  122. package/lib/typescript/components/theme/colorMode/DarkModeToggle.d.ts.map +1 -1
  123. package/package.json +4 -4
  124. package/src/components/button/DeleteButton.tsx +12 -25
  125. package/src/components/button/LoadingButton.tsx +4 -5
  126. package/src/components/button/Toggle.tsx +4 -3
  127. package/src/components/form/Form.tsx +31 -11
  128. package/src/components/form/FormFooter.tsx +6 -5
  129. package/src/components/form/input/Editable.tsx +8 -9
  130. package/src/components/form/input/common/InputClearButton.tsx +4 -3
  131. package/src/components/form/input/date/index.tsx +24 -11
  132. package/src/components/form/input/datetime/index.tsx +33 -16
  133. package/src/components/form/input/file/index.tsx +34 -35
  134. package/src/components/form/input/hooks/useInputStyles.ts +10 -7
  135. package/src/components/form/input/input.tsx +2 -2
  136. package/src/components/form/input/multipleSelect/index.tsx +35 -35
  137. package/src/components/form/input/socialMedia/index.tsx +6 -5
  138. package/src/components/form/input/text/AutoResizeTextarea.tsx +1 -5
  139. package/src/components/form/input/text/index.tsx +4 -3
  140. package/src/components/form/input/text/textarea.tsx +1 -1
  141. package/src/components/form/input/text/useWebAutoResize.tsx +6 -4
  142. package/src/components/form/input/time/index.tsx +4 -3
  143. package/src/components/form/view/select.tsx +5 -1
  144. package/src/components/image/ImageViewModal.tsx +56 -50
  145. package/src/components/layout/CollapseHorizontal.tsx +20 -10
  146. package/src/components/loading/LoadingImage.tsx +19 -19
  147. package/src/components/theme/colorMode/DarkModeToggle.tsx +4 -3
@@ -2,10 +2,11 @@ import { getDateTimeString, InputRef } from '@chem-po/core'
2
2
  import { DateTimeField, useIconColor } from '@chem-po/react'
3
3
  import { Ionicons } from '@expo/vector-icons'
4
4
  import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useState } from 'react'
5
- import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'
6
- import { Pressable } from 'react-native-gesture-handler'
5
+ import { StyleSheet, Text, View } from 'react-native'
6
+ import { Gesture, GestureDetector, Pressable } from 'react-native-gesture-handler'
7
7
  import { Portal } from 'react-native-paper'
8
8
  import { DatePickerModal, TimePickerModal } from 'react-native-paper-dates'
9
+ import { runOnJS } from 'react-native-reanimated'
9
10
  import { FieldProps } from '../../types'
10
11
  import { DateInputClearButton } from '../common/InputClearButton'
11
12
  import { useInputColor } from '../hooks/useInputColor'
@@ -64,11 +65,21 @@ export const DateTimeInput = forwardRef<InputRef, FieldProps<DateTimeField>>(
64
65
  )
65
66
 
66
67
  const handleDismiss = useCallback(() => {
67
- setShowDatePicker(true)
68
+ setShowDatePicker(false)
68
69
  setShowTimePicker(false)
69
70
  onBlur()
70
71
  }, [onBlur])
71
72
 
73
+ const handleFocusTime = useCallback(() => {
74
+ setShowTimePicker(true)
75
+ onFocus()
76
+ }, [onFocus])
77
+
78
+ const handleFocusDate = useCallback(() => {
79
+ setShowDatePicker(true)
80
+ onFocus()
81
+ }, [onFocus])
82
+
72
83
  const date = useMemo(() => (value ? new Date(value) : undefined), [value])
73
84
 
74
85
  const formattedValue = useMemo(() => {
@@ -84,22 +95,25 @@ export const DateTimeInput = forwardRef<InputRef, FieldProps<DateTimeField>>(
84
95
  const iconColor = useIconColor()
85
96
  const inputColor = useInputColor(value)
86
97
 
98
+ const mainTap = Gesture.Tap().onStart(() => {
99
+ runOnJS(handleFocusDate)()
100
+ })
101
+
87
102
  return (
88
103
  <View style={styles.container}>
89
- <TouchableOpacity
90
- style={[styles.button, inputStyles]}
91
- onPress={() => {
92
- setShowDatePicker(true)
93
- onFocus()
94
- }}>
95
- <Text style={[styles.text, text, { color: inputColor }]}>
96
- {formattedValue ?? placeholder}
97
- </Text>
104
+ <View style={[styles.button, inputStyles]}>
105
+ <GestureDetector gesture={mainTap}>
106
+ <View style={styles.textContainer}>
107
+ <Text numberOfLines={1} style={[styles.text, text, { color: inputColor }]}>
108
+ {formattedValue ?? placeholder}
109
+ </Text>
110
+ </View>
111
+ </GestureDetector>
98
112
  <View style={buttonContainer}>
99
- <Pressable onPress={() => setShowDatePicker(true)}>
113
+ <Pressable onPress={handleFocusDate}>
100
114
  <Ionicons name="calendar" size={iconSize} color={iconColor} />
101
115
  </Pressable>
102
- <Pressable onPress={() => setShowTimePicker(true)}>
116
+ <Pressable onPress={handleFocusTime}>
103
117
  <Ionicons name="time" size={iconSize} color={iconColor} />
104
118
  </Pressable>
105
119
  {optional && value ? (
@@ -110,7 +124,7 @@ export const DateTimeInput = forwardRef<InputRef, FieldProps<DateTimeField>>(
110
124
  />
111
125
  ) : null}
112
126
  </View>
113
- </TouchableOpacity>
127
+ </View>
114
128
  <Portal>
115
129
  {showDatePicker && (
116
130
  <DatePickerModal
@@ -153,7 +167,10 @@ const styles = StyleSheet.create({
153
167
  justifyContent: 'space-between',
154
168
  width: '100%',
155
169
  },
156
- text: {
170
+ textContainer: {
157
171
  flex: 1,
158
172
  },
173
+ text: {
174
+ width: '100%',
175
+ },
159
176
  })
@@ -12,8 +12,9 @@ import {
12
12
  import { Ionicons } from '@expo/vector-icons'
13
13
  import * as DocumentPicker from 'expo-document-picker'
14
14
  import * as ImagePicker from 'expo-image-picker'
15
- import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useState } from 'react'
16
- import { StyleProp, StyleSheet, Text, TouchableOpacity, View, ViewStyle } from 'react-native'
15
+ import React, { forwardRef, useCallback, useImperativeHandle, useMemo } from 'react'
16
+ import { StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native'
17
+ import { Pressable } from 'react-native-gesture-handler'
17
18
  import { downloadFile } from '../../../../utils/downloadFile'
18
19
  import { LoadingImage } from '../../../loading/LoadingImage'
19
20
  import { FieldProps } from '../../types'
@@ -33,17 +34,17 @@ const generateAccept = (field: FileField) => {
33
34
  return accept.join(',')
34
35
  }
35
36
 
36
- const NoFileView = ({ hasUpload }: { hasUpload?: boolean }) => {
37
+ const NoFileView = ({ hasUpload, onPress }: { hasUpload?: boolean; onPress?: () => void }) => {
37
38
  const textColor = useTextColor()
38
39
  const iconColor = useIconColor()
39
40
  const borderColor = useBorderColor()
40
41
  return (
41
- <View style={[styles.noFileContainer, { borderColor }]}>
42
+ <Pressable style={[styles.noFileContainer, { borderColor }]} onPress={onPress}>
42
43
  <Text style={[styles.noFileText, { color: textColor }]}>
43
44
  {hasUpload ? 'Tap to upload file' : 'No file uploaded'}
44
45
  </Text>
45
46
  <Ionicons name="cloud-upload" size={24} color={iconColor} />
46
- </View>
47
+ </Pressable>
47
48
  )
48
49
  }
49
50
 
@@ -54,6 +55,7 @@ export const FileView = ({
54
55
  withFullView,
55
56
  nonImageContainerStyle,
56
57
  withDownload,
58
+ onUploadPress,
57
59
  }: {
58
60
  value?: FileValue | null
59
61
  hasUpload?: boolean
@@ -61,6 +63,7 @@ export const FileView = ({
61
63
  withFullView?: boolean
62
64
  nonImageContainerStyle?: StyleProp<ViewStyle>
63
65
  withDownload?: boolean
66
+ onUploadPress?: () => void
64
67
  }) => {
65
68
  const { storagePath, dataUrl } = value ?? {}
66
69
  const missingFile = !dataUrl && !storagePath
@@ -104,26 +107,22 @@ export const FileView = ({
104
107
  }
105
108
  }, [url, value, showError, showSuccess])
106
109
  if (!value || missingFile) {
107
- return <NoFileView hasUpload={hasUpload} />
108
- }
109
-
110
- if (value.type?.startsWith('image/')) {
111
- return (
112
- <LoadingImage
113
- withDownload={withDownload}
114
- filename={value.filename}
115
- src={url}
116
- fileType={value.type}
117
- loadingOverride={loading}
118
- width={imageOptions?.width ?? 120}
119
- height={imageOptions?.height ?? 120}
120
- withFullView={withFullView}
121
- style={styles.image}
122
- />
123
- )
110
+ return <NoFileView onPress={onUploadPress} hasUpload={hasUpload} />
124
111
  }
125
112
 
126
- return (
113
+ const body = value.type?.startsWith('image/') ? (
114
+ <LoadingImage
115
+ withDownload={withDownload}
116
+ filename={value.filename}
117
+ src={url}
118
+ fileType={value.type}
119
+ loadingOverride={loading}
120
+ width={imageOptions?.width ?? 120}
121
+ height={imageOptions?.height ?? 120}
122
+ withFullView={withFullView}
123
+ style={styles.image}
124
+ />
125
+ ) : (
127
126
  <View style={[styles.fileContainer, { borderColor, backgroundColor }, nonImageContainerStyle]}>
128
127
  <View style={styles.iconContainer}>
129
128
  <Ionicons name="document" size={24} color={iconColor} />
@@ -134,25 +133,25 @@ export const FileView = ({
134
133
  </Text>
135
134
  </View>
136
135
  {withDownload && (
137
- <TouchableOpacity
136
+ <Pressable
138
137
  style={styles.downloadButton}
139
138
  onPress={() => void handleDownload()}
140
139
  disabled={loading}>
141
140
  <Ionicons name="download" size={20} color={iconColor} />
142
- </TouchableOpacity>
141
+ </Pressable>
143
142
  )}
144
143
  </View>
145
144
  )
145
+
146
+ return onUploadPress ? <Pressable onPress={onUploadPress}>{body}</Pressable> : body
146
147
  }
147
148
 
148
149
  export const FileComponent = forwardRef<InputRef, FieldProps<FileField>>(
149
150
  ({ input: { value, onChange }, field }, ref) => {
150
- const [loading, setLoading] = useState(false)
151
151
  const { imageOptions } = field || {}
152
152
 
153
153
  const handlePickFile = useCallback(async () => {
154
154
  try {
155
- setLoading(true)
156
155
  let result: ImagePicker.ImagePickerResult | DocumentPicker.DocumentPickerResult
157
156
 
158
157
  if (field.accept?.includes('image')) {
@@ -193,8 +192,6 @@ export const FileComponent = forwardRef<InputRef, FieldProps<FileField>>(
193
192
  if (error instanceof Error) {
194
193
  console.error('Error picking file:', error.message)
195
194
  }
196
- } finally {
197
- setLoading(false)
198
195
  }
199
196
  }, [field, onChange, value])
200
197
 
@@ -227,12 +224,14 @@ export const FileComponent = forwardRef<InputRef, FieldProps<FileField>>(
227
224
  return (
228
225
  <View style={[styles.container, { borderColor }]}>
229
226
  <Text style={[styles.placeholder, { color: placeholderColor }]}>{field.placeholder}</Text>
230
- <TouchableOpacity
231
- style={styles.contentContainer}
232
- onPress={() => void handlePickFile()}
233
- disabled={loading}>
234
- <FileView hasUpload imageOptions={imgOptions} value={value} />
235
- </TouchableOpacity>
227
+ <View style={styles.contentContainer}>
228
+ <FileView
229
+ hasUpload
230
+ onUploadPress={() => void handlePickFile()}
231
+ imageOptions={imgOptions}
232
+ value={value}
233
+ />
234
+ </View>
236
235
  </View>
237
236
  )
238
237
  },
@@ -15,18 +15,15 @@ export const inputStyles = StyleSheet.create({
15
15
  borderRadius: 3,
16
16
  },
17
17
  inputSmall: {
18
- paddingVertical: 6,
19
- paddingHorizontal: 9,
18
+ padding: 8,
20
19
  borderRadius: 4,
21
20
  },
22
21
  inputMedium: {
23
- paddingVertical: 8,
24
- paddingHorizontal: 12,
22
+ padding: 12,
25
23
  borderRadius: 6,
26
24
  },
27
25
  inputLarge: {
28
- paddingVertical: 10,
29
- paddingHorizontal: 14,
26
+ padding: 14,
30
27
  borderRadius: 8,
31
28
  },
32
29
  inputTextSmall: {
@@ -110,7 +107,13 @@ export const useInputStyles = (
110
107
  const textColor = useTextColor()
111
108
  const usedSize = size ?? formSize
112
109
  return {
113
- text: { ...inputTextSizeMap[usedSize], color: textColor, outlineWidth: 0 },
110
+ text: {
111
+ ...inputTextSizeMap[usedSize],
112
+ paddingTop: 0,
113
+ paddingBottom: 0,
114
+ color: textColor,
115
+ outlineWidth: 0,
116
+ },
114
117
  container: {
115
118
  ...inputStyles.input,
116
119
  ...(inEditable ? editableInputSizeMap[usedSize] : inputSizeMap[usedSize]),
@@ -192,11 +192,11 @@ const staticStyles = StyleSheet.create({
192
192
  },
193
193
  inputContainer: {
194
194
  width: '100%',
195
- borderRadius: 4,
196
195
  paddingVertical: 1,
197
- overflow: 'hidden',
196
+ // overflow: 'hidden',
198
197
  },
199
198
  errorText: {
199
+ paddingTop: 3,
200
200
  paddingHorizontal: 8,
201
201
  fontWeight: 500,
202
202
  // backgroundColor: 'red',
@@ -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,9 +86,9 @@ 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
 
@@ -110,11 +100,11 @@ const BaseMultipleSelectComponent = <T extends MultipleSelectField>(
110
100
  <View style={[styles.wrapper]}>
111
101
  <MultiSelect
112
102
  ref={inputRef}
113
- style={[inputStyles, { borderColor }]}
103
+ style={[container, { borderColor, boxShadow: `0 0 10px ${borderColor}`, borderWidth: 0 }]}
114
104
  placeholderStyle={[text, { color: value?.length ? textColor : placeholderColor }]}
115
105
  containerStyle={{
116
106
  backgroundColor: menuBg,
117
- boxShadow: `0 0 10px ${borderColor}`,
107
+ boxShadow: `0 0 6px ${borderColor}`,
118
108
  borderWidth: 0,
119
109
  }}
120
110
  inputSearchStyle={[styles.inputSearch, text, { backgroundColor: inputBg, borderWidth: 0 }]}
@@ -135,21 +125,33 @@ const BaseMultipleSelectComponent = <T extends MultipleSelectField>(
135
125
  }}
136
126
  onFocus={onFocus}
137
127
  onBlur={onBlur}
128
+ itemContainerStyle={{
129
+ backgroundColor: menuBg,
130
+ borderTopWidth: 1,
131
+ borderColor: borderColor,
132
+ }}
138
133
  renderItem={(item, selected) => (
139
- <View style={{ backgroundColor: menuBg }}>
140
- <View style={{ backgroundColor: selected ? selectedOptionBg : 'transparent' }}>
141
- <RenderOptionText
142
- value={item.value}
143
- option={item}
144
- colorMode={colorMode}
145
- isSelected={!!selected}
146
- size={size}
147
- />
148
- </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}
149
151
  </View>
150
152
  )}
151
153
  renderSelectedItem={item => (
152
- <SelectedOptionContainer>
154
+ <SelectedOptionContainer style={{ marginTop: 10 }}>
153
155
  <RenderSelectedOptionText
154
156
  value={item.value}
155
157
  option={item}
@@ -189,7 +191,7 @@ const styles = StyleSheet.create({
189
191
  width: '100%',
190
192
  },
191
193
  defaultOption: {
192
- padding: 10,
194
+ flex: 1,
193
195
  },
194
196
  iconStyle: {
195
197
  width: 20,
@@ -198,7 +200,6 @@ const styles = StyleSheet.create({
198
200
  inputSearch: {
199
201
  paddingVertical: 4,
200
202
  minHeight: 0,
201
- height: 'auto',
202
203
  outlineWidth: 0,
203
204
  fontSize: 16,
204
205
  },
@@ -216,7 +217,6 @@ const styles = StyleSheet.create({
216
217
  borderLeftWidth: 1,
217
218
  borderTopRightRadius: 8,
218
219
  borderBottomRightRadius: 8,
219
- height: '100%',
220
220
  justifyContent: 'center',
221
221
  },
222
222
  })
@@ -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'
@@ -63,9 +64,9 @@ export const TextComponent = forwardRef<InputRef, FieldProps<TextField>>(
63
64
  return type === 'password' ? (
64
65
  <View style={[conatinerStyles, styles.passwordContainer, style]}>
65
66
  {body}
66
- <TouchableOpacity style={styles.eyeIcon} onPress={() => setIsHidden(!isHidden)}>
67
+ <Pressable style={styles.eyeIcon} onPress={() => setIsHidden(!isHidden)}>
67
68
  <Ionicons name={isHidden ? 'eye' : 'eye-off'} size={20} color="#666" />
68
- </TouchableOpacity>
69
+ </Pressable>
69
70
  </View>
70
71
  ) : (
71
72
  <View style={[conatinerStyles, style]}>{body}</View>
@@ -16,7 +16,7 @@ export const TextAreaComponent = forwardRef<TextInput, FieldProps<TextField>>(
16
16
  <View style={[container, style]}>
17
17
  <AutoResizeTextarea
18
18
  ref={ref}
19
- style={[{ color, ...text }, inputStyle]}
19
+ style={[{ color, ...text, paddingBottom: inEditable ? 0 : 4 }, inputStyle]}
20
20
  placeholder={field.placeholder}
21
21
  placeholderTextColor={placeholderColor}
22
22
  multiline
@@ -39,7 +39,10 @@ export const useWebAutoResize = (
39
39
  style: StyleProp<TextStyle> | undefined,
40
40
  ) => {
41
41
  const flattenedStyle = useMemo(() => StyleSheet.flatten(style), [style])
42
- const [height, setHeight] = useState((flattenedStyle.fontSize ?? 18) + 4)
42
+ const fontSize = useMemo(() => flattenedStyle.fontSize ?? 16, [flattenedStyle.fontSize])
43
+ const [height, setHeight] = useState<number | 'auto'>(
44
+ Platform.OS === 'web' ? fontSize + 10 : 'auto',
45
+ )
43
46
  const spanRef = useRef<HTMLSpanElement>(
44
47
  Platform.OS === 'web' ? document.createElement('span') : null,
45
48
  )
@@ -55,15 +58,14 @@ export const useWebAutoResize = (
55
58
  ? (e: string) => {
56
59
  if (spanRef.current) {
57
60
  const height = getWebTextHeight(e, spanRef)
58
- setHeight((height ?? 18) + 4)
61
+ setHeight((height ?? fontSize) + 8)
59
62
  if (onChangeText) onChangeText(e)
60
63
  }
61
64
  }
62
65
  : onChangeText,
63
- [onChangeText],
66
+ [onChangeText, fontSize],
64
67
  )
65
68
  return {
66
- getWebTextHeight,
67
69
  handleChange,
68
70
  height,
69
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}
@@ -24,7 +24,11 @@ export const DefaultRenderOption = <
24
24
  >({
25
25
  option,
26
26
  }: RenderSelectOptionProps<Value, Option>) => {
27
- 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
+ )
28
32
  }
29
33
 
30
34
  export const SelectFieldView = ({