@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.
Files changed (44) hide show
  1. package/dist/components/Checkbox/index.js +10 -12
  2. package/dist/components/Checkbox/index.js.map +1 -1
  3. package/dist/components/DatePickerModal/index.js +9 -10
  4. package/dist/components/DatePickerModal/index.js.map +1 -1
  5. package/dist/components/InputBase/useInputBase.d.ts +40 -2
  6. package/dist/components/InputBase/useInputBase.js +9 -6
  7. package/dist/components/InputBase/useInputBase.js.map +1 -1
  8. package/dist/components/NumberIncrement/index.js +5 -5
  9. package/dist/components/NumberIncrement/index.js.map +1 -1
  10. package/dist/components/NumberIncrement/useNumberIncrement.d.ts +36 -1
  11. package/dist/components/NumberIncrement/useNumberIncrement.js +23 -21
  12. package/dist/components/NumberIncrement/useNumberIncrement.js.map +1 -1
  13. package/dist/components/PlacesAutocomplete/index.js +5 -5
  14. package/dist/components/PlacesAutocomplete/index.js.map +1 -1
  15. package/dist/components/RadioInput/index.js +3 -3
  16. package/dist/components/RadioInput/index.js.map +1 -1
  17. package/dist/components/SearchInput/index.js +1 -1
  18. package/dist/components/SearchInput/index.js.map +1 -1
  19. package/dist/components/Select/index.js +16 -17
  20. package/dist/components/Select/index.js.map +1 -1
  21. package/dist/components/Slider/index.js +10 -10
  22. package/dist/components/Slider/index.js.map +1 -1
  23. package/dist/components/Switch/index.js +10 -12
  24. package/dist/components/Switch/index.js.map +1 -1
  25. package/dist/components/TextInput/index.js +4 -4
  26. package/dist/components/TextInput/index.js.map +1 -1
  27. package/dist/components/TextInput/useTextInput.d.ts +36 -1
  28. package/dist/components/TextInput/useTextInput.js +9 -7
  29. package/dist/components/TextInput/useTextInput.js.map +1 -1
  30. package/package.json +15 -15
  31. package/package.json.bak +1 -1
  32. package/src/components/Checkbox/index.tsx +12 -13
  33. package/src/components/DatePickerModal/index.tsx +13 -14
  34. package/src/components/InputBase/useInputBase.ts +10 -8
  35. package/src/components/NumberIncrement/index.tsx +7 -6
  36. package/src/components/NumberIncrement/useNumberIncrement.ts +25 -21
  37. package/src/components/PlacesAutocomplete/index.tsx +4 -4
  38. package/src/components/RadioInput/index.tsx +6 -5
  39. package/src/components/SearchInput/index.tsx +1 -1
  40. package/src/components/Select/index.tsx +24 -20
  41. package/src/components/Slider/index.tsx +12 -11
  42. package/src/components/Switch/index.tsx +12 -13
  43. package/src/components/TextInput/index.tsx +6 -5
  44. 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
- } = useInputBase<boolean>(field, fields.boolean, [value, onValueChange])
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 = fieldHandle?.value ? styles['box:disabled-checked'] : styles['box:disabled-unchecked']
57
+ disabledStyle = inputValue ? styles['box:disabled-checked'] : styles['box:disabled-unchecked']
57
58
  }
58
- const style = fieldHandle?.value ? styles['box:checked'] : styles['box:unchecked']
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: [fieldHandle?.value, disabled],
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 = fieldHandle?.value ? styles['checkmarkWrapper:disabled-checked'] : styles['checkmarkWrapper:disabled-unchecked']
78
+ disabledStyle = inputValue ? styles['checkmarkWrapper:disabled-checked'] : styles['checkmarkWrapper:disabled-unchecked']
78
79
  }
79
- const style = fieldHandle?.value ? styles['checkmarkWrapper:checked'] : styles['checkmarkWrapper:unchecked']
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: [fieldHandle?.value, disabled],
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.showError || forceError
93
+ const hasError = validation?.showError || forceError
93
94
 
94
95
  return <InputBase
95
96
  {...inputBaseProps}
96
97
  ref={wrapperRef}
97
- error={hasError ? validation.message || forceError : null}
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: _value,
117
- onValueChange: _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
- fieldHandle,
128
- } = useInputBase(field, fields.date as () => DateField<any>, [_value, _onValueChange])
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 = value ? formatDate(value) : ''
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
- setValue(tempDate.current)
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 = value ?? initialDate
181
+ const newValue = inputValue ?? initialDate
183
182
  return newValue instanceof Date ? newValue : new Date(newValue)
184
- }, [value, initialDate])
183
+ }, [inputValue, initialDate])
185
184
 
186
185
  return (
187
186
  <>
188
187
  {!hideInput ? <OuterInput
189
188
  {...allProps}
190
189
  style={compositionStyles?.input}
191
- value={value}
190
+ value={inputValue}
192
191
  debugName={debugName}
193
192
  visible={visible}
194
193
  toggle={toggle}
195
- onValueChange={setValue}
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
- setValue(currentDate)
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={setValue}
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: AnyRecord) => T = fields.text as () => T,
10
- customState: [V, (value: V) => void] | [] = [],
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 [value, onValueChange] = customState
14
+ const { value, onValueChange } = internalState
15
15
 
16
- const hasState = useMemo(() => customState.filter(Boolean)?.length >= 1, [])
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']>, () => defaultField(hasState ? { onValueChange, defaultValue: value } : {}))
43
+ ] as unknown as Parameters<T['use']>, defaultField)
44
44
 
45
- const validation = fieldHandle.validation
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: fieldHandle?.value,
127
+ value: inputValue,
127
128
  onChangeText: null,
128
- onChangeValue: fieldHandle.setValue,
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.message || forceError : null}
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(fieldHandle?.value ?? min) : String(fieldHandle?.value ?? min)}
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(fieldHandle?.value) : String(fieldHandle?.value)}
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
- [value, onValueChange]
40
+ { value, onValueChange }
39
41
  )
40
42
 
41
43
  const incrementDisabled = useMemo(() => {
42
- const maxLimit = TypeGuards.isNumber(max) && (Number(fieldHandle?.value) >= max)
44
+ const maxLimit = TypeGuards.isNumber(max) && (Number(inputValue) >= max)
43
45
  return maxLimit
44
- }, [fieldHandle?.value])
46
+ }, [inputValue])
45
47
 
46
48
  const decrementDisabled = useMemo(() => {
47
- const minLimit = TypeGuards.isNumber(min) && (Number(fieldHandle?.value) <= min)
49
+ const minLimit = TypeGuards.isNumber(min) && (Number(inputValue) <= min)
48
50
  return minLimit
49
- }, [fieldHandle?.value])
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(fieldHandle?.value) + step
66
- fieldHandle.setValue(newValue)
67
+ const newValue = Number(inputValue) + step
68
+ onInputValueChange(newValue)
67
69
  } else if (action === 'decrement' && !decrementDisabled) {
68
- const newValue = Number(fieldHandle?.value) - step
69
- fieldHandle.setValue(newValue)
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
- }, [fieldHandle?.value, incrementDisabled, decrementDisabled])
79
+ }, [inputValue, incrementDisabled, decrementDisabled])
78
80
 
79
81
  const checkValue = useCallback((newValue: number = null, withLimits = true) => {
80
- const value = newValue ?? fieldHandle?.value
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
- fieldHandle.setValue(MAX_VALID_DIGITS)
97
+ onInputValueChange(MAX_VALID_DIGITS)
96
98
  return MAX_VALID_DIGITS
97
99
  }
98
100
 
99
101
  return value
100
- }, [fieldHandle?.value])
102
+ }, [inputValue])
101
103
 
102
104
  const handleBlur = useCallback((e: NativeSyntheticEvent<TextInputFocusEventData>) => {
103
- fieldHandle.setValue(checkValue())
104
- validation.onInputBlurred()
105
+ onInputValueChange(checkValue())
106
+ validation?.onInputBlurred?.()
105
107
  setIsFocused(false)
106
108
  onBlur?.(e)
107
- }, [validation.onInputBlurred, onBlur, checkValue])
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
- fieldHandle.setValue(value)
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(fieldHandle?.value)
129
- ? (fieldHandle?.value as string).length > 0
130
- : !TypeGuards.isNil(fieldHandle?.value)
130
+ const hasValue = TypeGuards.isString(inputValue)
131
+ ? (inputValue as string).length > 0
132
+ : !TypeGuards.isNil(inputValue)
131
133
 
132
- const hasError = validation.showError || forceError
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
- [value, onValueChange]
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(fieldHandle?.value)
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={fieldHandle?.value === item.value}
128
- onSelect={() => fieldHandle.setValue(item.value)}
128
+ selected={inputValue === item.value}
129
+ onSelect={() => onInputValueChange(item.value)}
129
130
  separator={idx < options?.length - 1}
130
131
  reverseOrder={_radioOnRight}
131
132
  />
@@ -68,7 +68,7 @@ export const SearchInput: ForwardRefComponentWithDefaultProps<SearchInputProps,
68
68
  return (
69
69
  <TextInput
70
70
  value={search}
71
- onChangeText={(value) => {
71
+ onValueChange={(value) => {
72
72
  onTypingChange?.(true)
73
73
  handleChangeSearch(value)
74
74
  }}
@@ -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: _value,
121
- onValueChange: _onValueChange,
120
+ value,
121
+ onValueChange,
122
122
  onSelect,
123
123
  ...modalProps
124
124
  } = allProps
125
125
 
126
- const { fieldHandle } = useInputBase(field, fields.selectable as () => SelectableField<T, any>, [_value, _onValueChange])
127
-
128
- const value = fieldHandle.value
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(value) && multiple
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 (value.includes(selectedValue)) {
190
- removedIndex = value.findIndex(v => v === selectedValue)
194
+ if (inputValue.includes(selectedValue)) {
195
+ removedIndex = inputValue.findIndex(v => v === selectedValue)
191
196
 
192
- newValue = value.filter((v, i) => i !== removedIndex)
197
+ newValue = inputValue.filter((v, i) => i !== removedIndex)
193
198
  } else {
194
- if (TypeGuards.isNumber(limit) && value.length >= 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 = [...value, selectedValue]
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
- fieldHandle.setValue(newValue)
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 ? value : [value]), limit, multiple, labelOptions, currentOptions])
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 = value?.includes(item.value)
238
+ selected = inputValue?.includes(item.value)
234
239
  } else {
235
- selected = value === item.value
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
- }, [value, select, multiple])
259
+ }, [inputValue, select, multiple])
255
260
 
256
- const isEmpty = TypeGuards.isNil(value)
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
- fieldHandle.setValue(null)
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
- } = useInputBase(field, fields.number, [value, onValueChange])
68
+ inputValue,
69
+ onInputValueChange,
70
+ } = useInputBase(field, fields.number, { value, onValueChange })
70
71
 
71
- const [_value, _setValue] = updateImmediately ? [fieldHandle?.value, fieldHandle.setValue] : React.useState<number | Array<number>>(0)
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 (fieldHandle?.value !== _value) {
76
- _setValue(fieldHandle?.value)
76
+ if (inputValue !== _value) {
77
+ _setValue(inputValue)
77
78
  }
78
- }, [fieldHandle?.value])
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 ? fieldHandle.setValue(sliderProps?.minimumValue || minimumValue) : null}
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 ? fieldHandle.setValue(sliderProps?.maximumValue || maximumValue) : null}
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
- fieldHandle.setValue(_value)
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 ? fieldHandle.setValue(trackMarksProp[idx]) : null}
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 ? fieldHandle.setValue(trackMarksProp[idx]) : null}
179
+ onPress={() => trackMarksClickable ? onInputValueChange(trackMarksProp[idx]) : null}
179
180
  />
180
181
  })
181
182
  }