@chem-po/react-native 0.0.15 → 0.0.16

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/form/Field.js +4 -2
  2. package/lib/commonjs/components/form/Field.js.map +1 -1
  3. package/lib/commonjs/components/form/Form.js +20 -7
  4. package/lib/commonjs/components/form/Form.js.map +1 -1
  5. package/lib/commonjs/components/form/input/Editable.js +24 -7
  6. package/lib/commonjs/components/form/input/Editable.js.map +1 -1
  7. package/lib/commonjs/components/form/input/common/InputClearButton.js +10 -5
  8. package/lib/commonjs/components/form/input/common/InputClearButton.js.map +1 -1
  9. package/lib/commonjs/components/form/input/date/index.js +23 -15
  10. package/lib/commonjs/components/form/input/date/index.js.map +1 -1
  11. package/lib/commonjs/components/form/input/datetime/index.js +22 -18
  12. package/lib/commonjs/components/form/input/datetime/index.js.map +1 -1
  13. package/lib/commonjs/components/form/input/hooks/index.js +4 -4
  14. package/lib/commonjs/components/form/input/hooks/index.js.map +1 -1
  15. package/lib/commonjs/components/form/input/hooks/useInputStyles.js +111 -0
  16. package/lib/commonjs/components/form/input/hooks/useInputStyles.js.map +1 -0
  17. package/lib/commonjs/components/form/input/input.js +49 -11
  18. package/lib/commonjs/components/form/input/input.js.map +1 -1
  19. package/lib/commonjs/components/form/input/multipleSelect/index.js +162 -44
  20. package/lib/commonjs/components/form/input/multipleSelect/index.js.map +1 -1
  21. package/lib/commonjs/components/form/input/number/index.js +10 -5
  22. package/lib/commonjs/components/form/input/number/index.js.map +1 -1
  23. package/lib/commonjs/components/form/input/select/index.js +84 -173
  24. package/lib/commonjs/components/form/input/select/index.js.map +1 -1
  25. package/lib/commonjs/components/form/input/text/index.js +7 -5
  26. package/lib/commonjs/components/form/input/text/index.js.map +1 -1
  27. package/lib/commonjs/components/form/input/text/textarea.js +10 -5
  28. package/lib/commonjs/components/form/input/text/textarea.js.map +1 -1
  29. package/lib/commonjs/components/form/input/time/index.js +22 -13
  30. package/lib/commonjs/components/form/input/time/index.js.map +1 -1
  31. package/lib/commonjs/components/form/view/file.js +18 -4
  32. package/lib/commonjs/components/form/view/file.js.map +1 -1
  33. package/lib/commonjs/components/form/view/index.js +24 -23
  34. package/lib/commonjs/components/form/view/index.js.map +1 -1
  35. package/lib/commonjs/components/form/view/multipleSelect.js +38 -10
  36. package/lib/commonjs/components/form/view/multipleSelect.js.map +1 -1
  37. package/lib/commonjs/components/form/view/select.js +24 -9
  38. package/lib/commonjs/components/form/view/select.js.map +1 -1
  39. package/lib/commonjs/components/form/view/styles.js +21 -0
  40. package/lib/commonjs/components/form/view/styles.js.map +1 -0
  41. package/lib/module/components/form/Field.js +4 -2
  42. package/lib/module/components/form/Field.js.map +1 -1
  43. package/lib/module/components/form/Form.js +20 -7
  44. package/lib/module/components/form/Form.js.map +1 -1
  45. package/lib/module/components/form/input/Editable.js +24 -7
  46. package/lib/module/components/form/input/Editable.js.map +1 -1
  47. package/lib/module/components/form/input/common/InputClearButton.js +11 -6
  48. package/lib/module/components/form/input/common/InputClearButton.js.map +1 -1
  49. package/lib/module/components/form/input/date/index.js +23 -15
  50. package/lib/module/components/form/input/date/index.js.map +1 -1
  51. package/lib/module/components/form/input/datetime/index.js +22 -18
  52. package/lib/module/components/form/input/datetime/index.js.map +1 -1
  53. package/lib/module/components/form/input/hooks/index.js +1 -1
  54. package/lib/module/components/form/input/hooks/index.js.map +1 -1
  55. package/lib/module/components/form/input/hooks/useInputStyles.js +104 -0
  56. package/lib/module/components/form/input/hooks/useInputStyles.js.map +1 -0
  57. package/lib/module/components/form/input/input.js +51 -13
  58. package/lib/module/components/form/input/input.js.map +1 -1
  59. package/lib/module/components/form/input/multipleSelect/index.js +163 -46
  60. package/lib/module/components/form/input/multipleSelect/index.js.map +1 -1
  61. package/lib/module/components/form/input/number/index.js +10 -5
  62. package/lib/module/components/form/input/number/index.js.map +1 -1
  63. package/lib/module/components/form/input/select/index.js +86 -175
  64. package/lib/module/components/form/input/select/index.js.map +1 -1
  65. package/lib/module/components/form/input/text/index.js +7 -5
  66. package/lib/module/components/form/input/text/index.js.map +1 -1
  67. package/lib/module/components/form/input/text/textarea.js +11 -6
  68. package/lib/module/components/form/input/text/textarea.js.map +1 -1
  69. package/lib/module/components/form/input/time/index.js +22 -13
  70. package/lib/module/components/form/input/time/index.js.map +1 -1
  71. package/lib/module/components/form/view/file.js +18 -4
  72. package/lib/module/components/form/view/file.js.map +1 -1
  73. package/lib/module/components/form/view/index.js +25 -24
  74. package/lib/module/components/form/view/index.js.map +1 -1
  75. package/lib/module/components/form/view/multipleSelect.js +38 -10
  76. package/lib/module/components/form/view/multipleSelect.js.map +1 -1
  77. package/lib/module/components/form/view/select.js +23 -9
  78. package/lib/module/components/form/view/select.js.map +1 -1
  79. package/lib/module/components/form/view/styles.js +15 -0
  80. package/lib/module/components/form/view/styles.js.map +1 -0
  81. package/lib/typescript/components/form/Field.d.ts +2 -1
  82. package/lib/typescript/components/form/Field.d.ts.map +1 -1
  83. package/lib/typescript/components/form/Form.d.ts +7 -4
  84. package/lib/typescript/components/form/Form.d.ts.map +1 -1
  85. package/lib/typescript/components/form/input/Editable.d.ts +1 -1
  86. package/lib/typescript/components/form/input/Editable.d.ts.map +1 -1
  87. package/lib/typescript/components/form/input/common/InputClearButton.d.ts +4 -2
  88. package/lib/typescript/components/form/input/common/InputClearButton.d.ts.map +1 -1
  89. package/lib/typescript/components/form/input/date/index.d.ts.map +1 -1
  90. package/lib/typescript/components/form/input/datetime/index.d.ts.map +1 -1
  91. package/lib/typescript/components/form/input/hooks/index.d.ts +1 -1
  92. package/lib/typescript/components/form/input/hooks/index.d.ts.map +1 -1
  93. package/lib/typescript/components/form/input/hooks/useInputStyles.d.ts +61 -0
  94. package/lib/typescript/components/form/input/hooks/useInputStyles.d.ts.map +1 -0
  95. package/lib/typescript/components/form/input/input.d.ts.map +1 -1
  96. package/lib/typescript/components/form/input/multipleSelect/index.d.ts +6 -1
  97. package/lib/typescript/components/form/input/multipleSelect/index.d.ts.map +1 -1
  98. package/lib/typescript/components/form/input/number/index.d.ts.map +1 -1
  99. package/lib/typescript/components/form/input/select/index.d.ts.map +1 -1
  100. package/lib/typescript/components/form/input/text/index.d.ts.map +1 -1
  101. package/lib/typescript/components/form/input/text/textarea.d.ts.map +1 -1
  102. package/lib/typescript/components/form/input/time/index.d.ts.map +1 -1
  103. package/lib/typescript/components/form/view/file.d.ts +3 -1
  104. package/lib/typescript/components/form/view/file.d.ts.map +1 -1
  105. package/lib/typescript/components/form/view/index.d.ts +3 -1
  106. package/lib/typescript/components/form/view/index.d.ts.map +1 -1
  107. package/lib/typescript/components/form/view/multipleSelect.d.ts +5 -3
  108. package/lib/typescript/components/form/view/multipleSelect.d.ts.map +1 -1
  109. package/lib/typescript/components/form/view/select.d.ts +4 -1
  110. package/lib/typescript/components/form/view/select.d.ts.map +1 -1
  111. package/lib/typescript/components/form/view/styles.d.ts +14 -0
  112. package/lib/typescript/components/form/view/styles.d.ts.map +1 -0
  113. package/package.json +5 -4
  114. package/src/components/form/Field.tsx +3 -2
  115. package/src/components/form/Form.tsx +41 -11
  116. package/src/components/form/input/Editable.tsx +23 -6
  117. package/src/components/form/input/common/InputClearButton.tsx +12 -4
  118. package/src/components/form/input/date/index.tsx +23 -12
  119. package/src/components/form/input/datetime/index.tsx +27 -14
  120. package/src/components/form/input/hooks/index.ts +1 -1
  121. package/src/components/form/input/hooks/useInputStyles.ts +124 -0
  122. package/src/components/form/input/input.tsx +57 -25
  123. package/src/components/form/input/multipleSelect/index.tsx +189 -60
  124. package/src/components/form/input/number/index.tsx +5 -4
  125. package/src/components/form/input/select/index.tsx +88 -166
  126. package/src/components/form/input/text/index.tsx +4 -9
  127. package/src/components/form/input/text/textarea.tsx +18 -16
  128. package/src/components/form/input/time/index.tsx +31 -11
  129. package/src/components/form/view/file.tsx +19 -4
  130. package/src/components/form/view/index.tsx +36 -22
  131. package/src/components/form/view/multipleSelect.tsx +42 -15
  132. package/src/components/form/view/select.tsx +28 -11
  133. package/src/components/form/view/styles.ts +15 -0
  134. package/lib/commonjs/components/form/input/hooks/useInputStyle.js +0 -50
  135. package/lib/commonjs/components/form/input/hooks/useInputStyle.js.map +0 -1
  136. package/lib/commonjs/components/form/input/styles.js +0 -17
  137. package/lib/commonjs/components/form/input/styles.js.map +0 -1
  138. package/lib/module/components/form/input/hooks/useInputStyle.js +0 -43
  139. package/lib/module/components/form/input/hooks/useInputStyle.js.map +0 -1
  140. package/lib/module/components/form/input/styles.js +0 -11
  141. package/lib/module/components/form/input/styles.js.map +0 -1
  142. package/lib/typescript/components/form/input/hooks/useInputStyle.d.ts +0 -9
  143. package/lib/typescript/components/form/input/hooks/useInputStyle.d.ts.map +0 -1
  144. package/lib/typescript/components/form/input/styles.d.ts +0 -10
  145. package/lib/typescript/components/form/input/styles.d.ts.map +0 -1
  146. package/src/components/form/input/hooks/useInputStyle.ts +0 -40
  147. package/src/components/form/input/styles.ts +0 -11
@@ -1,15 +1,10 @@
1
- import { FieldType, InputRef } from '@chem-po/core'
2
- import {
3
- Field,
4
- TypedField,
5
- useBackgroundColor,
6
- usePlaceholderColor,
7
- useThemeValue,
8
- } from '@chem-po/react'
1
+ import { FieldType, formatField, InputRef, parseField } from '@chem-po/core'
2
+ import { Field, FormatField, TypedField, usePlaceholderColor, useThemeValue } from '@chem-po/react'
9
3
  import React, {
10
4
  ForwardedRef,
11
5
  forwardRef,
12
6
  ForwardRefExoticComponent,
7
+ useCallback,
13
8
  useEffect,
14
9
  useMemo,
15
10
  } from 'react'
@@ -21,6 +16,7 @@ import { ColorComponent } from './color'
21
16
  import { DateInput } from './date'
22
17
  import { DateTimeInput } from './datetime'
23
18
  import { FileComponent } from './file'
19
+ import { useInputStyles } from './hooks/useInputStyles'
24
20
  import { MultipleSelectComponent } from './multipleSelect'
25
21
  import { CurrencyAmountComponent, NumberComponent } from './number'
26
22
  import { SelectComponent } from './select'
@@ -52,6 +48,7 @@ const InputBase = <T extends Field>(props: FieldProps<T>, ref: ForwardedRef<Inpu
52
48
  meta: { error, active, touched },
53
49
  input,
54
50
  inEditable,
51
+ formSize,
55
52
  style,
56
53
  } = props
57
54
 
@@ -60,7 +57,6 @@ const InputBase = <T extends Field>(props: FieldProps<T>, ref: ForwardedRef<Inpu
60
57
  const placeholderColor = usePlaceholderColor()
61
58
  const activeColor = useThemeValue('colors.accent.400')
62
59
  const errorColor = useThemeValue('colors.error.400')
63
-
64
60
  const shadowColorAnim = useMemo(() => new Animated.Value(0), [])
65
61
 
66
62
  const displayedError = useMemo(() => {
@@ -91,7 +87,7 @@ const InputBase = <T extends Field>(props: FieldProps<T>, ref: ForwardedRef<Inpu
91
87
  [value, _type],
92
88
  )
93
89
 
94
- const bg = useBackgroundColor(150)
90
+ // const bg = useBackgroundColor(150)
95
91
 
96
92
  const animatedStyles = useMemo(() => {
97
93
  if (inEditable) return {}
@@ -109,15 +105,46 @@ const InputBase = <T extends Field>(props: FieldProps<T>, ref: ForwardedRef<Inpu
109
105
  shadowOpacity: 1,
110
106
  shadowRadius: 4,
111
107
  elevation: 5,
112
- backgroundColor: bg,
108
+ // backgroundColor: bg,
113
109
  } as Animated.WithAnimatedValue<ViewStyle>
114
110
  default:
115
111
  return {}
116
112
  }
117
- }, [_type, animatedShadowColor, inEditable, bg])
113
+ }, [_type, animatedShadowColor, inEditable])
118
114
 
119
115
  const Component = useMemo(() => Components[_type] as ComponentType<T>, [_type])
120
116
 
117
+ const parse = useCallback(
118
+ (raw: any) => {
119
+ const defaultParse = parseField[field._type]
120
+ if (!defaultParse) return raw
121
+ return defaultParse(field, raw)
122
+ },
123
+ [field],
124
+ )
125
+
126
+ const { text } = useInputStyles(inEditable, field.size, formSize)
127
+
128
+ const format = useCallback(
129
+ (raw: any) => {
130
+ const defaultFormat = formatField[field._type] as FormatField<T>
131
+ if (!defaultFormat) return raw
132
+ return defaultFormat(field, raw)
133
+ },
134
+ [field],
135
+ )
136
+
137
+ const formattedValue = useMemo(() => format(value), [value, format])
138
+ const onChange = useCallback(
139
+ (v: any) => {
140
+ input.onChange(parse(v))
141
+ },
142
+ [input, parse],
143
+ )
144
+ const errorHeight = useMemo(() => {
145
+ return (text.fontSize ?? 16) - 2
146
+ }, [text])
147
+
121
148
  return (
122
149
  <View style={[staticStyles.container, style]}>
123
150
  {Label && !inEditable ? (
@@ -138,18 +165,18 @@ const InputBase = <T extends Field>(props: FieldProps<T>, ref: ForwardedRef<Inpu
138
165
  </AnimatedText>
139
166
  )}
140
167
  <Animated.View style={[staticStyles.inputContainer, animatedStyles]}>
141
- <Component ref={ref} {...props} />
168
+ <Component ref={ref} {...props} input={{ ...input, onChange, value: formattedValue }} />
142
169
  </Animated.View>
143
- {!inEditable && (
144
- <AnimatedText
145
- style={staticStyles.errorText}
146
- show={!!displayedError}
147
- color={errorColor}
148
- height={18}
149
- marginBottom={0}>
150
- {displayedError}
151
- </AnimatedText>
152
- )}
170
+ {/* {!inEditable && ( */}
171
+ <AnimatedText
172
+ style={[staticStyles.errorText, { fontSize: errorHeight }]}
173
+ show={!!displayedError}
174
+ color={errorColor}
175
+ height={errorHeight}
176
+ marginBottom={inEditable ? 10 : 0}>
177
+ {displayedError}
178
+ </AnimatedText>
179
+ {/* )} */}
153
180
  {/* {optional && !inEditable ? <OptionalTag field={field} value={value} /> : null} */}
154
181
  </View>
155
182
  )
@@ -159,7 +186,6 @@ const staticStyles = StyleSheet.create({
159
186
  container: {
160
187
  position: 'relative',
161
188
  width: '100%',
162
- paddingHorizontal: 4,
163
189
  // backgroundColor: 'blue',
164
190
  },
165
191
  label: {
@@ -174,8 +200,14 @@ const staticStyles = StyleSheet.create({
174
200
  overflow: 'hidden',
175
201
  },
176
202
  errorText: {
203
+ paddingHorizontal: 8,
204
+ fontWeight: 500,
205
+ // backgroundColor: 'red',
206
+ },
207
+ errorTextEditable: {
177
208
  fontSize: 14,
178
- paddingHorizontal: 4,
209
+ paddingHorizontal: 6,
210
+ paddingBottom: 8,
179
211
  fontWeight: 500,
180
212
  // backgroundColor: 'red',
181
213
  },
@@ -1,79 +1,208 @@
1
- import { InputRef } from '@chem-po/core'
2
- import { MultipleSelectField, useColorMode, usePlaceholderColor } from '@chem-po/react'
3
- import React, { forwardRef, useImperativeHandle } from 'react'
4
- import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'
1
+ import { InputRef, RenderSelectOptionProps } from '@chem-po/core'
2
+ import {
3
+ MultipleSelectField,
4
+ useBackgroundColor,
5
+ useBorderColor,
6
+ useColorMode,
7
+ useColorModeValue,
8
+ useIconColor,
9
+ usePlaceholderColor,
10
+ useTextColor,
11
+ } from '@chem-po/react'
12
+ import { Ionicons } from '@expo/vector-icons'
13
+ import React, {
14
+ ForwardedRef,
15
+ forwardRef,
16
+ PropsWithChildren,
17
+ useImperativeHandle,
18
+ useMemo,
19
+ useRef,
20
+ } from 'react'
21
+ import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native'
22
+ import { IDropdownRef, MultiSelect } from 'react-native-element-dropdown'
23
+ import { Txt } from '../../../text/Txt'
5
24
  import { FieldProps } from '../../types'
25
+ import { InputClearButton } from '../common/InputClearButton'
26
+ import { useInputStyles } from '../hooks/useInputStyles'
6
27
 
7
- export const MultipleSelectComponent = forwardRef<InputRef, FieldProps<MultipleSelectField>>(
8
- ({ field, input, inEditable }, ref) => {
9
- const { options, renderOption: RenderOption, getOptionKey } = field
10
- const { onChange, value, onFocus, onBlur } = input
11
- const colorMode = useColorMode()
28
+ export const SelectedOptionContainer = ({
29
+ children,
30
+ style,
31
+ }: PropsWithChildren<{ key?: string; style?: StyleProp<ViewStyle> }>) => {
32
+ const borderColor = useBorderColor()
33
+ return <View style={[styles.selectedOption, { borderColor }, style]}>{children}</View>
34
+ }
12
35
 
13
- const placeholderColor = usePlaceholderColor()
36
+ const BaseMultipleSelectComponent = <T extends MultipleSelectField>(
37
+ { field, input, meta, formSize, inEditable }: FieldProps<T>,
38
+ ref: ForwardedRef<InputRef>,
39
+ ) => {
40
+ const { placeholder, options, renderOption: RenderOption, searchable, searchPlaceholder } = field
41
+ const { onChange, value, onFocus, onBlur } = input
42
+ const { active } = meta
14
43
 
15
- useImperativeHandle(ref, () => ({
16
- focus: () => {
17
- onFocus()
18
- },
19
- blur: () => {
20
- onBlur()
21
- },
22
- }))
44
+ const colorMode = useColorMode()
45
+ const inputRef = useRef<IDropdownRef>(null)
46
+ const {
47
+ container: inputStyles,
48
+ iconSize,
49
+ clearButtonSize,
50
+ text,
51
+ buttonContainer,
52
+ size,
53
+ } = useInputStyles(inEditable, field.size, formSize)
54
+ const iconColor = useIconColor()
55
+ const textColor = useTextColor()
56
+ const placeholderColor = usePlaceholderColor()
57
+ const menuBg = useBackgroundColor(100)
58
+ const selectedOptionBg = useColorModeValue('#ffffff77', '#ffffff15')
59
+ const borderColor = useBorderColor()
23
60
 
24
- const handleOptionPress = (option: any) => {
25
- onChange(
26
- value?.includes(option) ? value.filter(v => v !== option) : [...(value ?? []), option],
27
- )
61
+ useImperativeHandle(ref, () => ({
62
+ focus: () => {
63
+ inputRef.current?.open()
64
+ },
65
+ blur: () => {
66
+ inputRef.current?.close()
67
+ },
68
+ }))
69
+
70
+ const defaultSelectedOptionStyle = useMemo(() => {
71
+ return {
72
+ paddingVertical: inputStyles.paddingVertical,
73
+ paddingHorizontal: inputStyles.paddingHorizontal,
28
74
  }
75
+ }, [inputStyles])
29
76
 
30
- const body = (
31
- <View style={styles.container}>
32
- {options.map(o => (
33
- <TouchableOpacity
34
- key={getOptionKey ? getOptionKey(o) : o}
35
- style={[styles.option, value?.includes(o) && styles.selectedOption]}
36
- onPress={() => handleOptionPress(o)}>
37
- <RenderOption value={o} colorMode={colorMode} isSelected={!!value?.includes(o)} />
38
- </TouchableOpacity>
39
- ))}
40
- </View>
41
- )
77
+ const RenderOptionText = (
78
+ props: RenderSelectOptionProps<T['options'][number]['value'], T['options'][number]>,
79
+ ) => {
80
+ if (typeof RenderOption === 'function') {
81
+ return RenderOption(props)
82
+ }
83
+ return <Txt style={[styles.defaultOption, text]}>{props.option.label}</Txt>
84
+ }
42
85
 
43
- return inEditable ? (
44
- <View style={styles.editableContainer}>
45
- <Text style={[styles.placeholder, { color: placeholderColor }]}>{field.placeholder}</Text>
46
- {body}
47
- </View>
48
- ) : (
49
- body
86
+ const RenderSelectedOptionText = (
87
+ props: RenderSelectOptionProps<T['options'][number]['value'], T['options'][number]>,
88
+ ) => {
89
+ if (typeof RenderOption === 'function') {
90
+ return RenderOption(props)
91
+ }
92
+ return (
93
+ <>
94
+ <Txt style={[defaultSelectedOptionStyle, text]}>{props.option.label}</Txt>
95
+ </>
50
96
  )
51
- },
52
- )
97
+ }
98
+
99
+ return (
100
+ <View style={[styles.wrapper]}>
101
+ <MultiSelect
102
+ ref={inputRef}
103
+ style={[inputStyles, { borderColor }]}
104
+ placeholderStyle={[text, { color: value?.length ? textColor : placeholderColor }]}
105
+ containerStyle={{ backgroundColor: menuBg }}
106
+ inputSearchStyle={[styles.inputSearch, text]}
107
+ iconStyle={styles.iconStyle}
108
+ data={options}
109
+ search={searchable}
110
+ searchField={searchable ? 'label' : undefined}
111
+ maxHeight={300}
112
+ labelField="label"
113
+ valueField="value"
114
+ placeholder={placeholder}
115
+ searchPlaceholder={searchPlaceholder ?? placeholder}
116
+ value={value ?? []}
117
+ onChange={updated => {
118
+ onChange(updated)
119
+ }}
120
+ activeColor={selectedOptionBg}
121
+ onFocus={onFocus}
122
+ onBlur={onBlur}
123
+ renderItem={(item, selected) => (
124
+ <View style={{ backgroundColor: selected ? selectedOptionBg : menuBg }}>
125
+ <RenderOptionText
126
+ value={item.value}
127
+ option={item}
128
+ colorMode={colorMode}
129
+ isSelected={!!selected}
130
+ size={size}
131
+ />
132
+ </View>
133
+ )}
134
+ renderSelectedItem={item => (
135
+ <SelectedOptionContainer>
136
+ <RenderSelectedOptionText
137
+ value={item.value}
138
+ option={item}
139
+ colorMode={colorMode}
140
+ isSelected
141
+ size={size}
142
+ />
143
+ <View
144
+ style={[
145
+ styles.optionClearContainer,
146
+ { borderColor, backgroundColor: selectedOptionBg },
147
+ ]}>
148
+ <InputClearButton
149
+ size={clearButtonSize}
150
+ onPress={() => {
151
+ onChange(value?.filter(v => v !== item.value))
152
+ }}
153
+ isActive
154
+ />
155
+ </View>
156
+ </SelectedOptionContainer>
157
+ )}
158
+ renderRightIcon={() => (
159
+ <View style={buttonContainer}>
160
+ <Ionicons
161
+ name={active ? 'chevron-up' : 'chevron-down'}
162
+ size={iconSize}
163
+ color={iconColor}
164
+ />
165
+ </View>
166
+ )}
167
+ />
168
+ </View>
169
+ )
170
+ }
171
+
172
+ export const MultipleSelectComponent = forwardRef(BaseMultipleSelectComponent)
53
173
 
54
174
  const styles = StyleSheet.create({
55
- container: {
175
+ wrapper: {
56
176
  width: '100%',
57
- flexDirection: 'row',
58
- flexWrap: 'wrap',
59
- gap: 4,
60
177
  },
61
- editableContainer: {
62
- width: '100%',
63
- paddingVertical: 2,
178
+ defaultOption: {
179
+ padding: 10,
64
180
  },
65
- placeholder: {
66
- fontSize: 14,
67
- fontWeight: '600',
68
- opacity: 0.8,
69
- paddingHorizontal: 8,
70
- marginBottom: 4,
181
+ iconStyle: {
182
+ width: 20,
183
+ height: 20,
71
184
  },
72
- option: {
73
- padding: 4,
74
- opacity: 0.7,
185
+ inputSearch: {
186
+ outlineWidth: 0,
187
+ paddingVertical: 4,
188
+ minHeight: 0,
189
+ height: 'auto',
190
+ fontSize: 16,
75
191
  },
76
192
  selectedOption: {
77
- opacity: 1,
193
+ flexDirection: 'row',
194
+ borderRadius: 4,
195
+ borderWidth: 1,
196
+ alignItems: 'center',
197
+ marginTop: 4,
198
+ marginHorizontal: 4,
199
+ },
200
+ optionClearContainer: {
201
+ paddingHorizontal: 8,
202
+ borderLeftWidth: 1,
203
+ borderTopRightRadius: 8,
204
+ borderBottomRightRadius: 8,
205
+ height: '100%',
206
+ justifyContent: 'center',
78
207
  },
79
208
  })
@@ -5,12 +5,13 @@ import { StyleSheet, Text, TextInput, View } from 'react-native'
5
5
  import { FieldProps } from '../../types'
6
6
  import { InputSlider } from '../InputSlider'
7
7
  import { useInputImperativeHandle } from '../hooks/useInputImperativeHandle'
8
- import { inputStyles } from '../styles'
8
+ import { useInputStyles } from '../hooks/useInputStyles'
9
9
 
10
10
  export const NumberComponent = forwardRef<InputRef, FieldProps<NumberField> & { prefix?: string }>(
11
- ({ input: { onChange, value, ...input }, field, prefix, inEditable: _, style }, ref) => {
12
- const { type, defaultValue, placeholder } = field
11
+ ({ input: { onChange, value, ...input }, field, prefix, inEditable, style, formSize }, ref) => {
12
+ const { type, defaultValue, placeholder, size } = field
13
13
  const color = useTextColor()
14
+ const { container: inputStyles } = useInputStyles(inEditable, size, formSize)
14
15
  const inputRef = useInputImperativeHandle(ref)
15
16
  const [endsWith, setEndsWith] = useState('')
16
17
  const displayed = typeof value === 'number' && !Number.isNaN(value) ? `${value}${endsWith}` : ''
@@ -33,7 +34,7 @@ export const NumberComponent = forwardRef<InputRef, FieldProps<NumberField> & {
33
34
  {prefix && <Text style={styles.prefix}>{prefix}</Text>}
34
35
  <TextInput
35
36
  ref={inputRef}
36
- style={[inputStyles.input, { color }, style]}
37
+ style={[inputStyles, { color }, style]}
37
38
  placeholder={field.placeholder}
38
39
  placeholderTextColor={placeholderColor}
39
40
  keyboardType="numeric"