@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
|
@@ -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
|
-
|
|
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 =
|
|
55
|
+
disabledStyle = inputValue ? styles['track:disabled-on'] : styles['track:disabled-off']
|
|
55
56
|
}
|
|
56
|
-
const style =
|
|
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: [
|
|
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 =
|
|
75
|
+
disabledStyle = inputValue ? styles['thumb:disabled-on'] : styles['thumb:disabled-off']
|
|
75
76
|
}
|
|
76
|
-
const style =
|
|
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: [
|
|
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
|
|
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
|
|
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:
|
|
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
|
|
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={
|
|
138
|
-
onChangeText={
|
|
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
|
-
|
|
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
|
|
51
|
+
validation?.onInputBlurred?.()
|
|
50
52
|
setIsFocused(false)
|
|
51
53
|
if (autoAdjustSelection) setCurrentSelection({ start: selectionStart })
|
|
52
54
|
onBlur?.(e)
|
|
53
|
-
}, [validation
|
|
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
|
-
|
|
64
|
+
onInputValueChange(masking?.saveFormatted ? masked : masked)
|
|
63
65
|
if (onChangeMask) onChangeMask(masked, unmasked)
|
|
64
66
|
}, [masking?.saveFormatted, onChangeMask])
|
|
65
67
|
|
|
66
|
-
const hasMultipleLines = multiline &&
|
|
68
|
+
const hasMultipleLines = multiline && inputValue?.includes('\n')
|
|
67
69
|
|
|
68
|
-
const hasValue =
|
|
70
|
+
const hasValue = inputValue?.length > 0
|
|
69
71
|
|
|
70
|
-
const hasError = validation
|
|
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
|
}
|