@codeleap/mobile 5.0.8 → 5.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Checkbox/index.js +10 -12
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/DatePickerModal/index.js +9 -10
- package/dist/components/DatePickerModal/index.js.map +1 -1
- package/dist/components/InputBase/useInputBase.d.ts +40 -2
- package/dist/components/InputBase/useInputBase.js +9 -6
- package/dist/components/InputBase/useInputBase.js.map +1 -1
- package/dist/components/NumberIncrement/index.js +5 -5
- package/dist/components/NumberIncrement/index.js.map +1 -1
- package/dist/components/NumberIncrement/useNumberIncrement.d.ts +36 -1
- package/dist/components/NumberIncrement/useNumberIncrement.js +23 -21
- package/dist/components/NumberIncrement/useNumberIncrement.js.map +1 -1
- package/dist/components/PlacesAutocomplete/index.js +5 -5
- package/dist/components/PlacesAutocomplete/index.js.map +1 -1
- package/dist/components/RadioInput/index.js +3 -3
- package/dist/components/RadioInput/index.js.map +1 -1
- package/dist/components/SearchInput/index.js +1 -1
- package/dist/components/SearchInput/index.js.map +1 -1
- package/dist/components/Select/index.js +16 -17
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Slider/index.js +10 -10
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Switch/index.js +10 -12
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/TextInput/index.js +4 -4
- package/dist/components/TextInput/index.js.map +1 -1
- package/dist/components/TextInput/useTextInput.d.ts +36 -1
- package/dist/components/TextInput/useTextInput.js +9 -7
- package/dist/components/TextInput/useTextInput.js.map +1 -1
- package/package.json +15 -15
- package/package.json.bak +1 -1
- package/src/components/Checkbox/index.tsx +12 -13
- package/src/components/DatePickerModal/index.tsx +13 -14
- package/src/components/InputBase/useInputBase.ts +10 -8
- package/src/components/NumberIncrement/index.tsx +7 -6
- package/src/components/NumberIncrement/useNumberIncrement.ts +25 -21
- package/src/components/PlacesAutocomplete/index.tsx +4 -4
- package/src/components/RadioInput/index.tsx +6 -5
- package/src/components/SearchInput/index.tsx +1 -1
- package/src/components/Select/index.tsx +24 -20
- package/src/components/Slider/index.tsx +12 -11
- package/src/components/Switch/index.tsx +12 -13
- package/src/components/TextInput/index.tsx +6 -5
- package/src/components/TextInput/useTextInput.ts +11 -7
|
@@ -40,10 +40,11 @@ export const Checkbox = (props: CheckboxProps) => {
|
|
|
40
40
|
const styles = useStylesFor(Checkbox.styleRegistryName, style)
|
|
41
41
|
|
|
42
42
|
const {
|
|
43
|
-
fieldHandle,
|
|
44
43
|
validation,
|
|
45
44
|
wrapperRef,
|
|
46
|
-
|
|
45
|
+
inputValue,
|
|
46
|
+
onInputValueChange,
|
|
47
|
+
} = useInputBase(field, fields.boolean, { value, onValueChange })
|
|
47
48
|
|
|
48
49
|
const boxAnimation = useAnimatedVariantStyles({
|
|
49
50
|
variantStyles: styles,
|
|
@@ -53,9 +54,9 @@ export const Checkbox = (props: CheckboxProps) => {
|
|
|
53
54
|
'worklet'
|
|
54
55
|
let disabledStyle = {}
|
|
55
56
|
if (disabled) {
|
|
56
|
-
disabledStyle =
|
|
57
|
+
disabledStyle = inputValue ? styles['box:disabled-checked'] : styles['box:disabled-unchecked']
|
|
57
58
|
}
|
|
58
|
-
const style =
|
|
59
|
+
const style = inputValue ? styles['box:checked'] : styles['box:unchecked']
|
|
59
60
|
|
|
60
61
|
return {
|
|
61
62
|
...style,
|
|
@@ -63,7 +64,7 @@ export const Checkbox = (props: CheckboxProps) => {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
},
|
|
66
|
-
dependencies: [
|
|
67
|
+
dependencies: [inputValue, disabled],
|
|
67
68
|
})
|
|
68
69
|
|
|
69
70
|
const checkmarkWrapperAnimation = useAnimatedVariantStyles({
|
|
@@ -74,34 +75,32 @@ export const Checkbox = (props: CheckboxProps) => {
|
|
|
74
75
|
'worklet'
|
|
75
76
|
let disabledStyle = {}
|
|
76
77
|
if (disabled) {
|
|
77
|
-
disabledStyle =
|
|
78
|
+
disabledStyle = inputValue ? styles['checkmarkWrapper:disabled-checked'] : styles['checkmarkWrapper:disabled-unchecked']
|
|
78
79
|
}
|
|
79
|
-
const style =
|
|
80
|
+
const style = inputValue ? styles['checkmarkWrapper:checked'] : styles['checkmarkWrapper:unchecked']
|
|
80
81
|
return {
|
|
81
82
|
...style,
|
|
82
83
|
...disabledStyle,
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
},
|
|
86
|
-
dependencies: [
|
|
87
|
+
dependencies: [inputValue, disabled],
|
|
87
88
|
})
|
|
88
89
|
|
|
89
90
|
// @ts-expect-error
|
|
90
91
|
const _checkboxOnLeft = checkboxOnLeft ?? styles.__props?.checkboxOnLeft
|
|
91
92
|
|
|
92
|
-
const hasError = validation
|
|
93
|
+
const hasError = validation?.showError || forceError
|
|
93
94
|
|
|
94
95
|
return <InputBase
|
|
95
96
|
{...inputBaseProps}
|
|
96
97
|
ref={wrapperRef}
|
|
97
|
-
error={hasError ? validation
|
|
98
|
+
error={hasError ? validation?.message || forceError : null}
|
|
98
99
|
debugName={debugName}
|
|
99
100
|
wrapper={Touchable}
|
|
100
101
|
style={styles}
|
|
101
102
|
wrapperProps={{
|
|
102
|
-
onPress: () =>
|
|
103
|
-
fieldHandle.setValue(!fieldHandle?.value)
|
|
104
|
-
},
|
|
103
|
+
onPress: () => onInputValueChange(!inputValue),
|
|
105
104
|
disabled,
|
|
106
105
|
rippleDisabled: true,
|
|
107
106
|
}}
|
|
@@ -113,8 +113,8 @@ export const DatePickerModal = (props: DatePickerModalProps) => {
|
|
|
113
113
|
footerComponent: Footer,
|
|
114
114
|
toggleOnConfirm,
|
|
115
115
|
onConfirm: _onConfirm,
|
|
116
|
-
value
|
|
117
|
-
onValueChange
|
|
116
|
+
value,
|
|
117
|
+
onValueChange,
|
|
118
118
|
locale,
|
|
119
119
|
...modalProps
|
|
120
120
|
} = allProps
|
|
@@ -124,22 +124,21 @@ export const DatePickerModal = (props: DatePickerModalProps) => {
|
|
|
124
124
|
const [visible, toggle] = useConditionalState(_visible, _toggle, { initialValue: false, isBooleanToggle: true })
|
|
125
125
|
|
|
126
126
|
const {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const [value, setValue] = [fieldHandle?.value, fieldHandle.setValue]
|
|
127
|
+
inputValue,
|
|
128
|
+
onInputValueChange,
|
|
129
|
+
} = useInputBase(field, fields.date, { value, onValueChange })
|
|
131
130
|
|
|
132
131
|
const Wrapper = isCustomModal ? ModalManager.Modal : React.Fragment
|
|
133
132
|
|
|
134
133
|
const compositionStyles = useCompositionStyles(['input', 'doneButton', 'cancelButton', 'confirmButton'], styles)
|
|
135
134
|
|
|
136
|
-
const formattedDate =
|
|
135
|
+
const formattedDate = inputValue ? formatDate(inputValue) : ''
|
|
137
136
|
|
|
138
137
|
const tempDate = useRef<Date | null>(initialDate instanceof Date ? initialDate : new Date(initialDate))
|
|
139
138
|
|
|
140
139
|
const onConfirm = () => {
|
|
141
140
|
if (commitDate == 'onConfirm' && !!tempDate.current) {
|
|
142
|
-
|
|
141
|
+
onInputValueChange(tempDate.current)
|
|
143
142
|
}
|
|
144
143
|
|
|
145
144
|
if (isCustomModal && toggleOnConfirm) {
|
|
@@ -179,20 +178,20 @@ export const DatePickerModal = (props: DatePickerModalProps) => {
|
|
|
179
178
|
} : {}
|
|
180
179
|
|
|
181
180
|
const date = useMemo(() => {
|
|
182
|
-
const newValue =
|
|
181
|
+
const newValue = inputValue ?? initialDate
|
|
183
182
|
return newValue instanceof Date ? newValue : new Date(newValue)
|
|
184
|
-
}, [
|
|
183
|
+
}, [inputValue, initialDate])
|
|
185
184
|
|
|
186
185
|
return (
|
|
187
186
|
<>
|
|
188
187
|
{!hideInput ? <OuterInput
|
|
189
188
|
{...allProps}
|
|
190
189
|
style={compositionStyles?.input}
|
|
191
|
-
value={
|
|
190
|
+
value={inputValue}
|
|
192
191
|
debugName={debugName}
|
|
193
192
|
visible={visible}
|
|
194
193
|
toggle={toggle}
|
|
195
|
-
onValueChange={
|
|
194
|
+
onValueChange={onInputValueChange}
|
|
196
195
|
valueLabel={formattedDate}
|
|
197
196
|
/> : null}
|
|
198
197
|
|
|
@@ -206,7 +205,7 @@ export const DatePickerModal = (props: DatePickerModalProps) => {
|
|
|
206
205
|
tempDate.current = currentDate
|
|
207
206
|
|
|
208
207
|
if (commitDate === 'onChange') {
|
|
209
|
-
|
|
208
|
+
onInputValueChange(currentDate)
|
|
210
209
|
}
|
|
211
210
|
}}
|
|
212
211
|
locale={locale}
|
|
@@ -214,7 +213,7 @@ export const DatePickerModal = (props: DatePickerModalProps) => {
|
|
|
214
213
|
textColor={styles?.picker?.color}
|
|
215
214
|
theme='light'
|
|
216
215
|
androidVariant='iosClone'
|
|
217
|
-
onConfirm={
|
|
216
|
+
onConfirm={onInputValueChange}
|
|
218
217
|
minimumDate={minimumDate}
|
|
219
218
|
maximumDate={maximumDate}
|
|
220
219
|
{...datePickerProps}
|
|
@@ -2,18 +2,18 @@ import { useMemo, useRef } from 'react'
|
|
|
2
2
|
import { View, TextInput } from 'react-native'
|
|
3
3
|
import { useWrappingScrollable } from '../../modules/scroll'
|
|
4
4
|
import { Field, IFieldRef, fields, useField } from '@codeleap/form'
|
|
5
|
-
import { AnyRecord } from '@codeleap/types'
|
|
5
|
+
import { AnyRecord, TypeGuards } from '@codeleap/types'
|
|
6
6
|
|
|
7
7
|
export function useInputBase<V, T extends Field<V, any, any, unknown> = Field<V, any, any, unknown>>(
|
|
8
8
|
field: T,
|
|
9
|
-
defaultField: (options
|
|
10
|
-
|
|
9
|
+
defaultField: (options?: AnyRecord) => T = fields.text as () => T,
|
|
10
|
+
internalState: { value: V; onValueChange: (value: V) => void },
|
|
11
11
|
params: Partial<IFieldRef<V>> = {},
|
|
12
12
|
deps: any[] = []
|
|
13
13
|
) {
|
|
14
|
-
const
|
|
14
|
+
const { value, onValueChange } = internalState
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const hasInternalState = useMemo(() => TypeGuards.isFunction(onValueChange) && !TypeGuards.isNil(value), [])
|
|
17
17
|
|
|
18
18
|
const wrapperRef = useRef<View>()
|
|
19
19
|
|
|
@@ -21,7 +21,7 @@ export function useInputBase<V, T extends Field<V, any, any, unknown> = Field<V
|
|
|
21
21
|
|
|
22
22
|
const scrollable = useWrappingScrollable()
|
|
23
23
|
|
|
24
|
-
const fieldHandle = useField<V, T>(field as T, [
|
|
24
|
+
const fieldHandle = hasInternalState ? {} as Partial<ReturnType<typeof useField>> : useField<V, T>(field as T, [
|
|
25
25
|
{
|
|
26
26
|
blur() {
|
|
27
27
|
innerInputRef.current.blur()
|
|
@@ -40,9 +40,9 @@ export function useInputBase<V, T extends Field<V, any, any, unknown> = Field<V
|
|
|
40
40
|
...params,
|
|
41
41
|
},
|
|
42
42
|
deps
|
|
43
|
-
] as unknown as Parameters<T['use']>,
|
|
43
|
+
] as unknown as Parameters<T['use']>, defaultField)
|
|
44
44
|
|
|
45
|
-
const validation = fieldHandle
|
|
45
|
+
const validation = fieldHandle?.validation
|
|
46
46
|
|
|
47
47
|
return {
|
|
48
48
|
fieldHandle,
|
|
@@ -50,5 +50,7 @@ export function useInputBase<V, T extends Field<V, any, any, unknown> = Field<V
|
|
|
50
50
|
wrapperRef,
|
|
51
51
|
innerInputRef,
|
|
52
52
|
scrollable,
|
|
53
|
+
inputValue: (hasInternalState ? value : fieldHandle?.value) as V,
|
|
54
|
+
onInputValueChange: hasInternalState ? onValueChange : fieldHandle?.setValue,
|
|
53
55
|
}
|
|
54
56
|
}
|
|
@@ -63,7 +63,6 @@ export const NumberIncrement = forwardRef<NativeTextInput, NumberIncrementProps>
|
|
|
63
63
|
const styles = useStylesFor(NumberIncrement.styleRegistryName, style)
|
|
64
64
|
|
|
65
65
|
const {
|
|
66
|
-
fieldHandle,
|
|
67
66
|
validation,
|
|
68
67
|
min,
|
|
69
68
|
max,
|
|
@@ -79,6 +78,8 @@ export const NumberIncrement = forwardRef<NativeTextInput, NumberIncrementProps>
|
|
|
79
78
|
handleMaskChange,
|
|
80
79
|
handleBlur,
|
|
81
80
|
handleFocus,
|
|
81
|
+
inputValue,
|
|
82
|
+
onInputValueChange,
|
|
82
83
|
} = useNumberIncrement(allProps)
|
|
83
84
|
|
|
84
85
|
const isFormatted = TypeGuards.isFunction(formatter)
|
|
@@ -123,9 +124,9 @@ export const NumberIncrement = forwardRef<NativeTextInput, NumberIncrementProps>
|
|
|
123
124
|
} : {}
|
|
124
125
|
|
|
125
126
|
const currencyExtraProps = isCurrency ? {
|
|
126
|
-
value:
|
|
127
|
+
value: inputValue,
|
|
127
128
|
onChangeText: null,
|
|
128
|
-
onChangeValue:
|
|
129
|
+
onChangeValue: onInputValueChange,
|
|
129
130
|
prefix: prefix,
|
|
130
131
|
separator: separator ?? '.',
|
|
131
132
|
suffix: suffix,
|
|
@@ -145,7 +146,7 @@ export const NumberIncrement = forwardRef<NativeTextInput, NumberIncrementProps>
|
|
|
145
146
|
<InputBase
|
|
146
147
|
{...inputBaseProps}
|
|
147
148
|
ref={wrapperRef}
|
|
148
|
-
error={hasError ? validation
|
|
149
|
+
error={hasError ? validation?.message || forceError : null}
|
|
149
150
|
style={styles}
|
|
150
151
|
rightIcon={TypeGuards.isComponentOrElement(inputBaseProps.rightIcon) ? inputBaseProps.rightIcon : {
|
|
151
152
|
name: 'plus' as AppIcon,
|
|
@@ -182,7 +183,7 @@ export const NumberIncrement = forwardRef<NativeTextInput, NumberIncrementProps>
|
|
|
182
183
|
selectionColor={partialStyles?.selection?.color}
|
|
183
184
|
{...textInputProps}
|
|
184
185
|
onChangeText={handleChangeInput}
|
|
185
|
-
value={isFormatted ? formatter(
|
|
186
|
+
value={isFormatted ? formatter(inputValue ?? min) : String(inputValue ?? min)}
|
|
186
187
|
onBlur={handleBlur}
|
|
187
188
|
onFocus={handleFocus}
|
|
188
189
|
style={[styles.input, partialStyles.input]}
|
|
@@ -192,7 +193,7 @@ export const NumberIncrement = forwardRef<NativeTextInput, NumberIncrementProps>
|
|
|
192
193
|
/>
|
|
193
194
|
) : (
|
|
194
195
|
<Text
|
|
195
|
-
text={isFormatted ? formatter(
|
|
196
|
+
text={isFormatted ? formatter(inputValue) : String(inputValue)}
|
|
196
197
|
style={[styles.input, partialStyles.input]}
|
|
197
198
|
/>
|
|
198
199
|
)}
|
|
@@ -32,21 +32,23 @@ export function useNumberIncrement(props: Partial<NumberIncrementProps>) {
|
|
|
32
32
|
validation,
|
|
33
33
|
innerInputRef,
|
|
34
34
|
wrapperRef,
|
|
35
|
+
inputValue,
|
|
36
|
+
onInputValueChange,
|
|
35
37
|
} = useInputBase(
|
|
36
38
|
field as Field<number, any, any>,
|
|
37
39
|
fields.number as () => Field<number, any, any>,
|
|
38
|
-
|
|
40
|
+
{ value, onValueChange }
|
|
39
41
|
)
|
|
40
42
|
|
|
41
43
|
const incrementDisabled = useMemo(() => {
|
|
42
|
-
const maxLimit = TypeGuards.isNumber(max) && (Number(
|
|
44
|
+
const maxLimit = TypeGuards.isNumber(max) && (Number(inputValue) >= max)
|
|
43
45
|
return maxLimit
|
|
44
|
-
}, [
|
|
46
|
+
}, [inputValue])
|
|
45
47
|
|
|
46
48
|
const decrementDisabled = useMemo(() => {
|
|
47
|
-
const minLimit = TypeGuards.isNumber(min) && (Number(
|
|
49
|
+
const minLimit = TypeGuards.isNumber(min) && (Number(inputValue) <= min)
|
|
48
50
|
return minLimit
|
|
49
|
-
}, [
|
|
51
|
+
}, [inputValue])
|
|
50
52
|
|
|
51
53
|
const actionTimeoutRef = useRef(null)
|
|
52
54
|
|
|
@@ -62,11 +64,11 @@ export function useNumberIncrement(props: Partial<NumberIncrementProps>) {
|
|
|
62
64
|
clearActionTimeoutRef()
|
|
63
65
|
|
|
64
66
|
if (action === 'increment' && !incrementDisabled) {
|
|
65
|
-
const newValue = Number(
|
|
66
|
-
|
|
67
|
+
const newValue = Number(inputValue) + step
|
|
68
|
+
onInputValueChange(newValue)
|
|
67
69
|
} else if (action === 'decrement' && !decrementDisabled) {
|
|
68
|
-
const newValue = Number(
|
|
69
|
-
|
|
70
|
+
const newValue = Number(inputValue) - step
|
|
71
|
+
onInputValueChange(newValue)
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
if (actionPressAutoFocus) {
|
|
@@ -74,10 +76,10 @@ export function useNumberIncrement(props: Partial<NumberIncrementProps>) {
|
|
|
74
76
|
setIsFocused(false)
|
|
75
77
|
}, timeoutActionFocus)
|
|
76
78
|
}
|
|
77
|
-
}, [
|
|
79
|
+
}, [inputValue, incrementDisabled, decrementDisabled])
|
|
78
80
|
|
|
79
81
|
const checkValue = useCallback((newValue: number = null, withLimits = true) => {
|
|
80
|
-
const value = newValue ??
|
|
82
|
+
const value = newValue ?? inputValue
|
|
81
83
|
|
|
82
84
|
if (withLimits) {
|
|
83
85
|
if (TypeGuards.isNumber(max) && (Number(value) >= max)) {
|
|
@@ -92,19 +94,19 @@ export function useNumberIncrement(props: Partial<NumberIncrementProps>) {
|
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
if (value >= MAX_VALID_DIGITS) {
|
|
95
|
-
|
|
97
|
+
onInputValueChange(MAX_VALID_DIGITS)
|
|
96
98
|
return MAX_VALID_DIGITS
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
return value
|
|
100
|
-
}, [
|
|
102
|
+
}, [inputValue])
|
|
101
103
|
|
|
102
104
|
const handleBlur = useCallback((e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
103
|
-
|
|
104
|
-
validation
|
|
105
|
+
onInputValueChange(checkValue())
|
|
106
|
+
validation?.onInputBlurred?.()
|
|
105
107
|
setIsFocused(false)
|
|
106
108
|
onBlur?.(e)
|
|
107
|
-
}, [validation
|
|
109
|
+
}, [validation?.onInputBlurred, onBlur, checkValue])
|
|
108
110
|
|
|
109
111
|
const handleFocus = useCallback((e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
110
112
|
clearActionTimeoutRef()
|
|
@@ -115,7 +117,7 @@ export function useNumberIncrement(props: Partial<NumberIncrementProps>) {
|
|
|
115
117
|
const handleChangeInput = useCallback((text: string) => {
|
|
116
118
|
const value = checkValue(parseValue(text), false)
|
|
117
119
|
|
|
118
|
-
|
|
120
|
+
onInputValueChange(value)
|
|
119
121
|
|
|
120
122
|
return value
|
|
121
123
|
}, [checkValue])
|
|
@@ -125,11 +127,11 @@ export function useNumberIncrement(props: Partial<NumberIncrementProps>) {
|
|
|
125
127
|
if (onChangeMask) onChangeMask(masked, unmasked)
|
|
126
128
|
}, [onChangeMask, handleChangeInput])
|
|
127
129
|
|
|
128
|
-
const hasValue = TypeGuards.isString(
|
|
129
|
-
? (
|
|
130
|
-
: !TypeGuards.isNil(
|
|
130
|
+
const hasValue = TypeGuards.isString(inputValue)
|
|
131
|
+
? (inputValue as string).length > 0
|
|
132
|
+
: !TypeGuards.isNil(inputValue)
|
|
131
133
|
|
|
132
|
-
const hasError = validation
|
|
134
|
+
const hasError = validation?.showError || forceError
|
|
133
135
|
|
|
134
136
|
return {
|
|
135
137
|
isFocused,
|
|
@@ -148,5 +150,7 @@ export function useNumberIncrement(props: Partial<NumberIncrementProps>) {
|
|
|
148
150
|
decrementDisabled,
|
|
149
151
|
min,
|
|
150
152
|
max,
|
|
153
|
+
inputValue,
|
|
154
|
+
onInputValueChange,
|
|
151
155
|
}
|
|
152
156
|
}
|
|
@@ -99,10 +99,6 @@ export const PlacesAutocomplete = (props: PlacesAutocompleteProps) => {
|
|
|
99
99
|
<View style={styles.wrapper} {...rest}>
|
|
100
100
|
<TextInput
|
|
101
101
|
style={compositionStyles.input}
|
|
102
|
-
onChangeText={(value) => {
|
|
103
|
-
setIsTyping(true)
|
|
104
|
-
handleChangeAddress(value)
|
|
105
|
-
}}
|
|
106
102
|
onBlur={() => {
|
|
107
103
|
setIsFocused(false)
|
|
108
104
|
}}
|
|
@@ -111,6 +107,10 @@ export const PlacesAutocomplete = (props: PlacesAutocompleteProps) => {
|
|
|
111
107
|
}}
|
|
112
108
|
{...textInputProps}
|
|
113
109
|
value={hasCustomValue ? textInputProps?.value : address}
|
|
110
|
+
onValueChange={(value) => {
|
|
111
|
+
setIsTyping(true)
|
|
112
|
+
handleChangeAddress(value)
|
|
113
|
+
}}
|
|
114
114
|
rightIcon={rightIcon}
|
|
115
115
|
/>
|
|
116
116
|
{isTyping ? (
|
|
@@ -96,18 +96,19 @@ export const RadioGroup = <T extends string | number>(props: RadioGroupProps<T>)
|
|
|
96
96
|
const styles = useStylesFor(RadioGroup.styleRegistryName, style)
|
|
97
97
|
|
|
98
98
|
const {
|
|
99
|
-
fieldHandle,
|
|
100
99
|
wrapperRef,
|
|
100
|
+
inputValue,
|
|
101
|
+
onInputValueChange,
|
|
101
102
|
} = useInputBase(
|
|
102
103
|
field as SelectableField<T, any>,
|
|
103
104
|
fields.selectable as () => SelectableField<T, any>,
|
|
104
|
-
|
|
105
|
+
{ value, onValueChange }
|
|
105
106
|
)
|
|
106
107
|
|
|
107
108
|
// @ts-expect-error icss type
|
|
108
109
|
const _radioOnRight = radioOnRight ?? styles?.__props?.radioOnRight
|
|
109
110
|
|
|
110
|
-
const hasValue = !TypeGuards.isNil(
|
|
111
|
+
const hasValue = !TypeGuards.isNil(inputValue)
|
|
111
112
|
|
|
112
113
|
return <InputBase
|
|
113
114
|
{...inputBaseProps}
|
|
@@ -124,8 +125,8 @@ export const RadioGroup = <T extends string | number>(props: RadioGroupProps<T>)
|
|
|
124
125
|
key={idx}
|
|
125
126
|
disabled={disabled}
|
|
126
127
|
styles={styles}
|
|
127
|
-
selected={
|
|
128
|
-
onSelect={() =>
|
|
128
|
+
selected={inputValue === item.value}
|
|
129
|
+
onSelect={() => onInputValueChange(item.value)}
|
|
129
130
|
separator={idx < options?.length - 1}
|
|
130
131
|
reverseOrder={_radioOnRight}
|
|
131
132
|
/>
|
|
@@ -117,17 +117,22 @@ export const Select = <T extends string | number = string, Multi extends boolean
|
|
|
117
117
|
outerInputComponent,
|
|
118
118
|
disabled,
|
|
119
119
|
field,
|
|
120
|
-
value
|
|
121
|
-
onValueChange
|
|
120
|
+
value,
|
|
121
|
+
onValueChange,
|
|
122
122
|
onSelect,
|
|
123
123
|
...modalProps
|
|
124
124
|
} = allProps
|
|
125
125
|
|
|
126
|
-
const {
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
const {
|
|
127
|
+
inputValue,
|
|
128
|
+
onInputValueChange,
|
|
129
|
+
} = useInputBase(
|
|
130
|
+
field,
|
|
131
|
+
fields.selectable as () => SelectableField<T, any>,
|
|
132
|
+
{ value, onValueChange }
|
|
133
|
+
)
|
|
129
134
|
|
|
130
|
-
const isValueArray = TypeGuards.isArray(
|
|
135
|
+
const isValueArray = TypeGuards.isArray(inputValue) && multiple
|
|
131
136
|
|
|
132
137
|
const {
|
|
133
138
|
loading,
|
|
@@ -138,7 +143,7 @@ export const Select = <T extends string | number = string, Multi extends boolean
|
|
|
138
143
|
load,
|
|
139
144
|
onChangeSearch,
|
|
140
145
|
} = useSearch({
|
|
141
|
-
value,
|
|
146
|
+
value: inputValue,
|
|
142
147
|
multiple,
|
|
143
148
|
options,
|
|
144
149
|
filterItems,
|
|
@@ -186,25 +191,25 @@ export const Select = <T extends string | number = string, Multi extends boolean
|
|
|
186
191
|
let removedIndex = null
|
|
187
192
|
|
|
188
193
|
if (multiple && isValueArray) {
|
|
189
|
-
if (
|
|
190
|
-
removedIndex =
|
|
194
|
+
if (inputValue.includes(selectedValue)) {
|
|
195
|
+
removedIndex = inputValue.findIndex(v => v === selectedValue)
|
|
191
196
|
|
|
192
|
-
newValue =
|
|
197
|
+
newValue = inputValue.filter((v, i) => i !== removedIndex)
|
|
193
198
|
} else {
|
|
194
|
-
if (TypeGuards.isNumber(limit) &&
|
|
199
|
+
if (TypeGuards.isNumber(limit) && inputValue.length >= limit) {
|
|
195
200
|
return
|
|
196
201
|
}
|
|
197
202
|
|
|
198
203
|
newOption = currentOptions.find(o => o.value === selectedValue)
|
|
199
204
|
|
|
200
|
-
newValue = [...
|
|
205
|
+
newValue = [...inputValue, selectedValue]
|
|
201
206
|
}
|
|
202
207
|
} else {
|
|
203
208
|
newValue = selectedValue
|
|
204
209
|
newOption = currentOptions.find(o => o.value === selectedValue)
|
|
205
210
|
}
|
|
206
211
|
|
|
207
|
-
|
|
212
|
+
onInputValueChange(newValue)
|
|
208
213
|
|
|
209
214
|
onSelect?.(newValue)
|
|
210
215
|
|
|
@@ -224,15 +229,15 @@ export const Select = <T extends string | number = string, Multi extends boolean
|
|
|
224
229
|
if (closeOnSelect) {
|
|
225
230
|
close?.()
|
|
226
231
|
}
|
|
227
|
-
}, [isValueArray, (isValueArray ?
|
|
232
|
+
}, [isValueArray, (isValueArray ? inputValue : [inputValue]), limit, multiple, labelOptions, currentOptions])
|
|
228
233
|
|
|
229
234
|
const renderListItem = useCallback(({ item, index }) => {
|
|
230
235
|
let selected = false
|
|
231
236
|
|
|
232
237
|
if (multiple && isValueArray) {
|
|
233
|
-
selected =
|
|
238
|
+
selected = inputValue?.includes(item.value)
|
|
234
239
|
} else {
|
|
235
|
-
selected =
|
|
240
|
+
selected = inputValue === item.value
|
|
236
241
|
}
|
|
237
242
|
|
|
238
243
|
return (
|
|
@@ -251,20 +256,19 @@ export const Select = <T extends string | number = string, Multi extends boolean
|
|
|
251
256
|
{...itemProps}
|
|
252
257
|
/>
|
|
253
258
|
)
|
|
254
|
-
}, [
|
|
259
|
+
}, [inputValue, select, multiple])
|
|
255
260
|
|
|
256
|
-
const isEmpty = TypeGuards.isNil(
|
|
261
|
+
const isEmpty = TypeGuards.isNil(inputValue)
|
|
257
262
|
const showClearIcon = !isEmpty && clearable
|
|
258
263
|
|
|
259
264
|
const inputIcon = showClearIcon ? clearIconName : arrowIconName
|
|
260
265
|
|
|
261
266
|
const onPressInputIcon = () => {
|
|
262
267
|
if (showClearIcon) {
|
|
263
|
-
|
|
268
|
+
onInputValueChange(null)
|
|
264
269
|
} else {
|
|
265
270
|
close?.()
|
|
266
271
|
}
|
|
267
|
-
|
|
268
272
|
}
|
|
269
273
|
|
|
270
274
|
const searchHeader = searchable ? <SearchInput
|
|
@@ -64,18 +64,19 @@ export const Slider = (props: SliderProps) => {
|
|
|
64
64
|
} = others
|
|
65
65
|
|
|
66
66
|
const {
|
|
67
|
-
fieldHandle,
|
|
68
67
|
wrapperRef,
|
|
69
|
-
|
|
68
|
+
inputValue,
|
|
69
|
+
onInputValueChange,
|
|
70
|
+
} = useInputBase(field, fields.number, { value, onValueChange })
|
|
70
71
|
|
|
71
|
-
const [_value, _setValue] = updateImmediately ? [
|
|
72
|
+
const [_value, _setValue] = updateImmediately ? [inputValue, onInputValueChange] : React.useState<number | Array<number>>(0)
|
|
72
73
|
|
|
73
74
|
onUpdate(() => {
|
|
74
75
|
if (updateImmediately) return
|
|
75
|
-
if (
|
|
76
|
-
_setValue(
|
|
76
|
+
if (inputValue !== _value) {
|
|
77
|
+
_setValue(inputValue)
|
|
77
78
|
}
|
|
78
|
-
}, [
|
|
79
|
+
}, [inputValue])
|
|
79
80
|
|
|
80
81
|
const styles = useStylesFor(Slider.styleRegistryName, style)
|
|
81
82
|
|
|
@@ -106,7 +107,7 @@ export const Slider = (props: SliderProps) => {
|
|
|
106
107
|
<View style={styles.labelRow}>
|
|
107
108
|
{label ? (
|
|
108
109
|
<Touchable
|
|
109
|
-
onPress={() => labelClickable ?
|
|
110
|
+
onPress={() => labelClickable ? onInputValueChange(sliderProps?.minimumValue || minimumValue) : null}
|
|
110
111
|
style={styles.labelBtn}
|
|
111
112
|
debugName='slider title'
|
|
112
113
|
>
|
|
@@ -115,7 +116,7 @@ export const Slider = (props: SliderProps) => {
|
|
|
115
116
|
) : null}
|
|
116
117
|
{description ? (
|
|
117
118
|
<Touchable
|
|
118
|
-
onPress={() => labelClickable ?
|
|
119
|
+
onPress={() => labelClickable ? onInputValueChange(sliderProps?.maximumValue || maximumValue) : null}
|
|
119
120
|
style={styles?.descriptionBtn}
|
|
120
121
|
debugName='slider description'
|
|
121
122
|
>
|
|
@@ -137,7 +138,7 @@ export const Slider = (props: SliderProps) => {
|
|
|
137
138
|
maximumValue={maximumValue}
|
|
138
139
|
onSlidingComplete={() => {
|
|
139
140
|
if (updateImmediately) return
|
|
140
|
-
|
|
141
|
+
onInputValueChange(_value)
|
|
141
142
|
}}
|
|
142
143
|
disabled={disabled}
|
|
143
144
|
{...sliderProps}
|
|
@@ -163,7 +164,7 @@ export const Slider = (props: SliderProps) => {
|
|
|
163
164
|
index={idx}
|
|
164
165
|
style={style}
|
|
165
166
|
key={idx}
|
|
166
|
-
onPress={() => trackMarksClickable ?
|
|
167
|
+
onPress={() => trackMarksClickable ? onInputValueChange(trackMarksProp[idx]) : null}
|
|
167
168
|
/>
|
|
168
169
|
}
|
|
169
170
|
|
|
@@ -175,7 +176,7 @@ export const Slider = (props: SliderProps) => {
|
|
|
175
176
|
content={content}
|
|
176
177
|
style={style}
|
|
177
178
|
key={idx}
|
|
178
|
-
onPress={() => trackMarksClickable ?
|
|
179
|
+
onPress={() => trackMarksClickable ? onInputValueChange(trackMarksProp[idx]) : null}
|
|
179
180
|
/>
|
|
180
181
|
})
|
|
181
182
|
}
|