@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
@@ -38,10 +38,11 @@ export const Switch = (props: SwitchProps) => {
38
38
  const styles = useStylesFor(Switch.styleRegistryName, style)
39
39
 
40
40
  const {
41
- fieldHandle,
42
41
  validation,
43
42
  wrapperRef,
44
- } = useInputBase<boolean>(field, fields.boolean, [value, onValueChange])
43
+ inputValue,
44
+ onInputValueChange,
45
+ } = useInputBase<boolean>(field, fields.boolean, { value, onValueChange })
45
46
 
46
47
  const trackAnimation = useAnimatedVariantStyles({
47
48
  variantStyles: styles,
@@ -51,16 +52,16 @@ export const Switch = (props: SwitchProps) => {
51
52
  'worklet'
52
53
  let disabledStyle = {}
53
54
  if (disabled) {
54
- disabledStyle = fieldHandle?.value ? styles['track:disabled-on'] : styles['track:disabled-off']
55
+ disabledStyle = inputValue ? styles['track:disabled-on'] : styles['track:disabled-off']
55
56
  }
56
- const style = fieldHandle?.value ? styles['track:on'] : styles['track:off']
57
+ const style = inputValue ? styles['track:on'] : styles['track:off']
57
58
 
58
59
  return {
59
60
  ...style,
60
61
  ...disabledStyle,
61
62
  }
62
63
  },
63
- dependencies: [fieldHandle?.value, disabled],
64
+ dependencies: [inputValue, disabled],
64
65
  })
65
66
 
66
67
  const thumbAnimation = useAnimatedVariantStyles({
@@ -71,34 +72,32 @@ export const Switch = (props: SwitchProps) => {
71
72
  'worklet'
72
73
  let disabledStyle = {}
73
74
  if (disabled) {
74
- disabledStyle = fieldHandle?.value ? styles['thumb:disabled-on'] : styles['thumb:disabled-off']
75
+ disabledStyle = inputValue ? styles['thumb:disabled-on'] : styles['thumb:disabled-off']
75
76
  }
76
- const style = fieldHandle?.value ? styles['thumb:on'] : styles['thumb:off']
77
+ const style = inputValue ? styles['thumb:on'] : styles['thumb:off']
77
78
  return {
78
79
  ...style,
79
80
  ...disabledStyle,
80
81
  }
81
82
 
82
83
  },
83
- dependencies: [fieldHandle?.value, disabled],
84
+ dependencies: [inputValue, disabled],
84
85
  })
85
86
 
86
87
  // @ts-expect-error
87
88
  const _switchOnLeft = switchOnLeft ?? styles?.__props?.switchOnLeft
88
89
 
89
- const hasError = validation.showError || forceError
90
+ const hasError = validation?.showError || forceError
90
91
 
91
92
  return <InputBase
92
93
  {...inputBaseProps}
93
94
  ref={wrapperRef}
94
95
  debugName={debugName}
95
96
  wrapper={Touchable}
96
- error={hasError ? validation.message || forceError : null}
97
+ error={hasError ? validation?.message || forceError : null}
97
98
  style={styles}
98
99
  wrapperProps={{
99
- onPress: () => {
100
- fieldHandle.setValue(!fieldHandle?.value)
101
- },
100
+ onPress: () => onInputValueChange(!inputValue),
102
101
  disabled,
103
102
  rippleDisabled: true,
104
103
  }}
@@ -47,8 +47,9 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((props, inp
47
47
  const styles = useStylesFor(TextInput.styleRegistryName, style)
48
48
 
49
49
  const {
50
- fieldHandle,
51
50
  validation,
51
+ inputValue,
52
+ onInputValueChange,
52
53
  innerInputRef,
53
54
  wrapperRef,
54
55
  isFocused,
@@ -91,7 +92,7 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((props, inp
91
92
  },
92
93
  ...masking,
93
94
  } : {
94
- onChangeText: fieldHandle.setValue
95
+ onChangeText: onInputValueChange,
95
96
  }
96
97
 
97
98
  const buttonModeProps = isPressable ? {
@@ -104,7 +105,7 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((props, inp
104
105
  ref={wrapperRef}
105
106
  innerWrapper={isPressable ? Touchable : undefined}
106
107
  debugName={debugName}
107
- error={hasError ? validation.message || forceError : null}
108
+ error={hasError ? validation?.message || forceError : null}
108
109
  style={{
109
110
  ...styles,
110
111
  innerWrapper: [
@@ -134,8 +135,8 @@ export const TextInput = forwardRef<NativeTextInput, TextInputProps>((props, inp
134
135
  textAlignVertical={multiline ? 'top' : undefined}
135
136
  multiline={multiline}
136
137
  {...textInputProps}
137
- value={fieldHandle?.value}
138
- onChangeText={fieldHandle?.setValue}
138
+ value={inputValue}
139
+ onChangeText={onInputValueChange}
139
140
  onBlur={handleBlur}
140
141
  onFocus={handleFocus}
141
142
  style={[
@@ -33,7 +33,9 @@ export function useTextInput(props: Partial<TextInputProps>) {
33
33
  validation,
34
34
  innerInputRef,
35
35
  wrapperRef,
36
- } = useInputBase<string>(field, fields.text, [value, onValueChange], {
36
+ onInputValueChange,
37
+ inputValue,
38
+ } = useInputBase<string>(field, fields.text, { value, onValueChange }, {
37
39
  revealValue() {
38
40
  setSecureTextEntry(false)
39
41
  },
@@ -46,11 +48,11 @@ export function useTextInput(props: Partial<TextInputProps>) {
46
48
  }, [setSecureTextEntry])
47
49
 
48
50
  const handleBlur = useCallback((e: NativeSyntheticEvent<TextInputFocusEventData>) => {
49
- validation.onInputBlurred()
51
+ validation?.onInputBlurred?.()
50
52
  setIsFocused(false)
51
53
  if (autoAdjustSelection) setCurrentSelection({ start: selectionStart })
52
54
  onBlur?.(e)
53
- }, [validation.onInputBlurred, onBlur])
55
+ }, [validation?.onInputBlurred, onBlur])
54
56
 
55
57
  const handleFocus = useCallback((e: NativeSyntheticEvent<TextInputFocusEventData>) => {
56
58
  setIsFocused(true)
@@ -59,15 +61,15 @@ export function useTextInput(props: Partial<TextInputProps>) {
59
61
  }, [onFocus])
60
62
 
61
63
  const handleMaskChange = useCallback((masked, unmasked) => {
62
- fieldHandle.setValue(masking?.saveFormatted ? masked : masked)
64
+ onInputValueChange(masking?.saveFormatted ? masked : masked)
63
65
  if (onChangeMask) onChangeMask(masked, unmasked)
64
66
  }, [masking?.saveFormatted, onChangeMask])
65
67
 
66
- const hasMultipleLines = multiline && fieldHandle?.value?.includes('\n')
68
+ const hasMultipleLines = multiline && inputValue?.includes('\n')
67
69
 
68
- const hasValue = fieldHandle?.value?.length > 0
70
+ const hasValue = inputValue?.length > 0
69
71
 
70
- const hasError = validation.showError || forceError
72
+ const hasError = validation?.showError || forceError
71
73
 
72
74
  return {
73
75
  isFocused,
@@ -84,5 +86,7 @@ export function useTextInput(props: Partial<TextInputProps>) {
84
86
  hasMultipleLines,
85
87
  hasValue,
86
88
  hasError,
89
+ inputValue,
90
+ onInputValueChange,
87
91
  }
88
92
  }