@codeleap/mobile 5.0.8 → 5.0.10
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/Autocomplete/types.d.ts +1 -2
- package/dist/components/Backdrop/index.js +2 -2
- package/dist/components/Backdrop/index.js.map +1 -1
- package/dist/components/Checkbox/index.js +10 -12
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/DatePickerModal/index.js +11 -13
- 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/Modal/index.d.ts +0 -1
- package/dist/components/Modal/index.js +25 -41
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/styles.d.ts +1 -1
- package/dist/components/Modal/types.d.ts +1 -2
- 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 +20 -22
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/types.d.ts +1 -2
- package/dist/components/Slider/index.js +10 -10
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/SortablePhotos/useSortablePhotos.js +2 -6
- package/dist/components/SortablePhotos/useSortablePhotos.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/dist/deprecated/index.d.ts +1 -0
- package/dist/deprecated/index.js +2 -0
- package/dist/deprecated/index.js.map +1 -1
- package/dist/{utils/ModalManager/context.js → deprecated/modals/Context.js} +3 -6
- package/dist/deprecated/modals/Context.js.map +1 -0
- package/dist/{utils/ModalManager → deprecated/modals}/components.js +1 -1
- package/dist/deprecated/modals/components.js.map +1 -0
- package/dist/{utils/ModalManager → deprecated/modals}/index.d.ts +1 -1
- package/dist/{utils/ModalManager → deprecated/modals}/index.js +1 -1
- package/dist/deprecated/modals/index.js.map +1 -0
- package/dist/deprecated/permissions/Context.js +1 -1
- package/dist/deprecated/permissions/Context.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/types/utility.d.ts +8 -0
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -2
- package/dist/utils/index.js.map +1 -1
- package/package.json +17 -15
- package/package.json.bak +4 -2
- package/src/components/Autocomplete/types.ts +1 -2
- package/src/components/Backdrop/index.tsx +2 -2
- package/src/components/Checkbox/index.tsx +12 -13
- package/src/components/DatePickerModal/index.tsx +15 -17
- package/src/components/InputBase/useInputBase.ts +10 -8
- package/src/components/Modal/index.tsx +77 -96
- package/src/components/Modal/styles.ts +0 -1
- package/src/components/Modal/types.ts +1 -2
- 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 +28 -24
- package/src/components/Select/types.ts +1 -2
- package/src/components/Slider/index.tsx +12 -11
- package/src/components/SortablePhotos/useSortablePhotos.ts +2 -7
- package/src/components/Switch/index.tsx +12 -13
- package/src/components/TextInput/index.tsx +6 -5
- package/src/components/TextInput/useTextInput.ts +11 -7
- package/src/deprecated/index.ts +2 -1
- package/src/{utils/ModalManager/context.tsx → deprecated/modals/Context.tsx} +9 -11
- package/src/{utils/ModalManager → deprecated/modals}/components.tsx +5 -5
- package/src/{utils/ModalManager → deprecated/modals}/index.ts +2 -2
- package/src/deprecated/permissions/Context.tsx +1 -1
- package/src/index.ts +1 -2
- package/src/types/utility.ts +8 -0
- package/src/utils/index.ts +0 -2
- package/dist/utils/KeyboardAware/context.d.ts +0 -14
- package/dist/utils/KeyboardAware/context.js +0 -15
- package/dist/utils/KeyboardAware/context.js.map +0 -1
- package/dist/utils/KeyboardAware/index.d.ts +0 -2
- package/dist/utils/KeyboardAware/index.js +0 -3
- package/dist/utils/KeyboardAware/index.js.map +0 -1
- package/dist/utils/KeyboardAware/keyboardHooks.d.ts +0 -21
- package/dist/utils/KeyboardAware/keyboardHooks.js +0 -77
- package/dist/utils/KeyboardAware/keyboardHooks.js.map +0 -1
- package/dist/utils/ModalManager/components.js.map +0 -1
- package/dist/utils/ModalManager/context.js.map +0 -1
- package/dist/utils/ModalManager/index.js.map +0 -1
- package/src/utils/KeyboardAware/context.tsx +0 -21
- package/src/utils/KeyboardAware/index.ts +0 -4
- package/src/utils/KeyboardAware/keyboardHooks.ts +0 -110
- /package/dist/{utils/ModalManager/context.d.ts → deprecated/modals/Context.d.ts} +0 -0
- /package/dist/{utils/ModalManager → deprecated/modals}/components.d.ts +0 -0
|
@@ -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
|
}}
|
|
@@ -2,9 +2,8 @@ import React, { useMemo, useRef } from 'react'
|
|
|
2
2
|
import { TypeGuards } from '@codeleap/types'
|
|
3
3
|
import { useConditionalState } from '@codeleap/hooks'
|
|
4
4
|
import DatePicker from 'react-native-date-picker'
|
|
5
|
-
import Modal from '../Modal'
|
|
5
|
+
import { Modal } from '../Modal'
|
|
6
6
|
import { TextInput } from '../TextInput'
|
|
7
|
-
import { ModalManager } from '../../utils'
|
|
8
7
|
import { Button } from '../Button'
|
|
9
8
|
import { DatePickerModalProps } from './types'
|
|
10
9
|
import { AnyRecord, IJSX, StyledComponentProps, useCompositionStyles } from '@codeleap/styles'
|
|
@@ -113,8 +112,8 @@ export const DatePickerModal = (props: DatePickerModalProps) => {
|
|
|
113
112
|
footerComponent: Footer,
|
|
114
113
|
toggleOnConfirm,
|
|
115
114
|
onConfirm: _onConfirm,
|
|
116
|
-
value
|
|
117
|
-
onValueChange
|
|
115
|
+
value,
|
|
116
|
+
onValueChange,
|
|
118
117
|
locale,
|
|
119
118
|
...modalProps
|
|
120
119
|
} = allProps
|
|
@@ -124,22 +123,21 @@ export const DatePickerModal = (props: DatePickerModalProps) => {
|
|
|
124
123
|
const [visible, toggle] = useConditionalState(_visible, _toggle, { initialValue: false, isBooleanToggle: true })
|
|
125
124
|
|
|
126
125
|
const {
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
inputValue,
|
|
127
|
+
onInputValueChange,
|
|
128
|
+
} = useInputBase(field, fields.date, { value, onValueChange })
|
|
129
129
|
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
const Wrapper = isCustomModal ? ModalManager.Modal : React.Fragment
|
|
130
|
+
const Wrapper = isCustomModal ? Modal : React.Fragment
|
|
133
131
|
|
|
134
132
|
const compositionStyles = useCompositionStyles(['input', 'doneButton', 'cancelButton', 'confirmButton'], styles)
|
|
135
133
|
|
|
136
|
-
const formattedDate =
|
|
134
|
+
const formattedDate = inputValue ? formatDate(inputValue) : ''
|
|
137
135
|
|
|
138
136
|
const tempDate = useRef<Date | null>(initialDate instanceof Date ? initialDate : new Date(initialDate))
|
|
139
137
|
|
|
140
138
|
const onConfirm = () => {
|
|
141
139
|
if (commitDate == 'onConfirm' && !!tempDate.current) {
|
|
142
|
-
|
|
140
|
+
onInputValueChange(tempDate.current)
|
|
143
141
|
}
|
|
144
142
|
|
|
145
143
|
if (isCustomModal && toggleOnConfirm) {
|
|
@@ -179,20 +177,20 @@ export const DatePickerModal = (props: DatePickerModalProps) => {
|
|
|
179
177
|
} : {}
|
|
180
178
|
|
|
181
179
|
const date = useMemo(() => {
|
|
182
|
-
const newValue =
|
|
180
|
+
const newValue = inputValue ?? initialDate
|
|
183
181
|
return newValue instanceof Date ? newValue : new Date(newValue)
|
|
184
|
-
}, [
|
|
182
|
+
}, [inputValue, initialDate])
|
|
185
183
|
|
|
186
184
|
return (
|
|
187
185
|
<>
|
|
188
186
|
{!hideInput ? <OuterInput
|
|
189
187
|
{...allProps}
|
|
190
188
|
style={compositionStyles?.input}
|
|
191
|
-
value={
|
|
189
|
+
value={inputValue}
|
|
192
190
|
debugName={debugName}
|
|
193
191
|
visible={visible}
|
|
194
192
|
toggle={toggle}
|
|
195
|
-
onValueChange={
|
|
193
|
+
onValueChange={onInputValueChange}
|
|
196
194
|
valueLabel={formattedDate}
|
|
197
195
|
/> : null}
|
|
198
196
|
|
|
@@ -206,7 +204,7 @@ export const DatePickerModal = (props: DatePickerModalProps) => {
|
|
|
206
204
|
tempDate.current = currentDate
|
|
207
205
|
|
|
208
206
|
if (commitDate === 'onChange') {
|
|
209
|
-
|
|
207
|
+
onInputValueChange(currentDate)
|
|
210
208
|
}
|
|
211
209
|
}}
|
|
212
210
|
locale={locale}
|
|
@@ -214,7 +212,7 @@ export const DatePickerModal = (props: DatePickerModalProps) => {
|
|
|
214
212
|
textColor={styles?.picker?.color}
|
|
215
213
|
theme='light'
|
|
216
214
|
androidVariant='iosClone'
|
|
217
|
-
onConfirm={
|
|
215
|
+
onConfirm={onInputValueChange}
|
|
218
216
|
minimumDate={minimumDate}
|
|
219
217
|
maximumDate={maximumDate}
|
|
220
218
|
{...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
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { Fragment } from 'react'
|
|
2
2
|
import { View } from '../View'
|
|
3
3
|
import { Scroll } from '../Scroll'
|
|
4
4
|
import { TypeGuards } from '@codeleap/types'
|
|
@@ -7,12 +7,12 @@ import { useBackButton } from '../../utils/hooks'
|
|
|
7
7
|
import { Text } from '../Text'
|
|
8
8
|
import { Touchable } from '../Touchable'
|
|
9
9
|
import { ActionIcon } from '../ActionIcon'
|
|
10
|
-
import { useState } from 'react'
|
|
11
10
|
import { ModalHeaderProps, ModalProps } from './types'
|
|
12
|
-
import { AnyRecord, AppIcon, useNestedStylesByKey, IJSX, StyledComponentProps
|
|
11
|
+
import { AnyRecord, AppIcon, useNestedStylesByKey, IJSX, StyledComponentProps } from '@codeleap/styles'
|
|
13
12
|
import { MobileStyleRegistry } from '../../Registry'
|
|
14
13
|
import { useStylesFor } from '../../hooks'
|
|
15
14
|
import { FadeIn, FadeOut } from 'react-native-reanimated'
|
|
15
|
+
import { Portal } from '@gorhom/portal'
|
|
16
16
|
|
|
17
17
|
export * from './styles'
|
|
18
18
|
export * from './types'
|
|
@@ -67,26 +67,22 @@ export const Modal = (modalProps: ModalProps) => {
|
|
|
67
67
|
children,
|
|
68
68
|
toggle = () => null,
|
|
69
69
|
dismissOnBackdrop,
|
|
70
|
-
header
|
|
70
|
+
header,
|
|
71
71
|
debugName,
|
|
72
72
|
scroll,
|
|
73
|
-
renderHeader,
|
|
74
|
-
zIndex = null,
|
|
73
|
+
renderHeader: Header,
|
|
75
74
|
scrollProps = {},
|
|
76
75
|
closeOnHardwareBackPress,
|
|
77
76
|
style,
|
|
78
77
|
boxExiting,
|
|
79
78
|
boxEntering,
|
|
79
|
+
withPortal,
|
|
80
80
|
...props
|
|
81
81
|
} = {
|
|
82
82
|
...Modal.defaultProps,
|
|
83
83
|
...modalProps,
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
const themeValues = useTheme(store => (store.current as AppTheme<Theme>)?.values)
|
|
87
|
-
|
|
88
|
-
const [modalHeight, setModalHeight] = useState(0)
|
|
89
|
-
|
|
90
86
|
const styles = useStylesFor(Modal.styleRegistryName, style)
|
|
91
87
|
|
|
92
88
|
const buttonStyles = useNestedStylesByKey('closeButton', styles)
|
|
@@ -94,17 +90,7 @@ export const Modal = (modalProps: ModalProps) => {
|
|
|
94
90
|
const ScrollComponent = scroll ? Scroll : View
|
|
95
91
|
const scrollStyle = scroll ? styles?.scroll : styles?.innerWrapper
|
|
96
92
|
|
|
97
|
-
const
|
|
98
|
-
const topSpacing = modalHeight > heightThreshold ? styles?.topSpacing : 0
|
|
99
|
-
|
|
100
|
-
const headerProps: ModalHeaderProps = {
|
|
101
|
-
...modalProps,
|
|
102
|
-
closable,
|
|
103
|
-
styles,
|
|
104
|
-
buttonStyles,
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const Header = renderHeader || DefaultHeader
|
|
93
|
+
const Wrapper = withPortal ? Portal : Fragment
|
|
108
94
|
|
|
109
95
|
useBackButton(() => {
|
|
110
96
|
if (visible && closeOnHardwareBackPress) {
|
|
@@ -113,82 +99,77 @@ export const Modal = (modalProps: ModalProps) => {
|
|
|
113
99
|
}
|
|
114
100
|
}, [visible, toggle, closeOnHardwareBackPress])
|
|
115
101
|
|
|
116
|
-
const onModalLayout = (event) => {
|
|
117
|
-
const { height } = event.nativeEvent.layout
|
|
118
|
-
setModalHeight(height)
|
|
119
|
-
props?.onLayout?.(event)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
102
|
return (
|
|
123
|
-
<
|
|
124
|
-
style={
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
103
|
+
<Wrapper>
|
|
104
|
+
<View style={styles?.wrapper} pointerEvents={visible ? 'auto' : 'none'}>
|
|
105
|
+
<Backdrop
|
|
106
|
+
visible={visible}
|
|
107
|
+
debugName={`Modal ${debugName} backdrop`}
|
|
108
|
+
style={{
|
|
109
|
+
'wrapper:hidden': styles['backdrop:hidden'],
|
|
110
|
+
'wrapper:visible': styles['backdrop:visible'],
|
|
111
|
+
'wrapper': styles?.backdrop,
|
|
112
|
+
}}
|
|
113
|
+
wrapperProps={{
|
|
114
|
+
// @ts-expect-error
|
|
115
|
+
transition: styles['backdrop:transition'],
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
118
|
+
|
|
119
|
+
<ScrollComponent
|
|
120
|
+
contentContainerStyle={styles?.scrollContent}
|
|
121
|
+
showsVerticalScrollIndicator={false}
|
|
122
|
+
keyboardAware
|
|
123
|
+
animated
|
|
124
|
+
{...scrollProps}
|
|
125
|
+
style={scrollStyle}
|
|
126
|
+
>
|
|
127
|
+
{dismissOnBackdrop ? (
|
|
128
|
+
<Touchable
|
|
129
|
+
onPress={closable && visible ? toggle : (() => { })}
|
|
130
|
+
debounce={400}
|
|
131
|
+
debugName={'Modal backdrop touchable'}
|
|
132
|
+
style={styles?.backdropTouchable}
|
|
133
|
+
android_ripple={null}
|
|
134
|
+
noFeedback
|
|
135
|
+
/>) : null}
|
|
136
|
+
{
|
|
137
|
+
visible ? (
|
|
138
|
+
<View
|
|
139
|
+
animated
|
|
140
|
+
// @ts-ignore
|
|
141
|
+
entering={boxEntering}
|
|
142
|
+
exiting={boxExiting}
|
|
143
|
+
{...props}
|
|
144
|
+
style={styles?.box}
|
|
145
|
+
>
|
|
146
|
+
{header ? header : (
|
|
147
|
+
<Header
|
|
148
|
+
{...modalProps}
|
|
149
|
+
closable={closable}
|
|
150
|
+
styles={styles}
|
|
151
|
+
buttonStyles={buttonStyles}
|
|
152
|
+
/>
|
|
153
|
+
)}
|
|
154
|
+
|
|
155
|
+
<View style={styles?.body}>{children}</View>
|
|
156
|
+
|
|
157
|
+
{footer ? (
|
|
158
|
+
<View style={styles?.footer}>
|
|
159
|
+
{typeof footer === 'string' ? <Text text={footer} /> : footer}
|
|
160
|
+
</View>
|
|
161
|
+
) : null}
|
|
162
|
+
</View>
|
|
163
|
+
) : null
|
|
164
|
+
}
|
|
165
|
+
</ScrollComponent>
|
|
166
|
+
</View>
|
|
167
|
+
</Wrapper>
|
|
187
168
|
)
|
|
188
169
|
}
|
|
189
170
|
|
|
190
171
|
Modal.styleRegistryName = 'Modal'
|
|
191
|
-
Modal.elements = ['wrapper', 'box', 'backdrop', 'innerWrapper', 'scroll', 'body', 'footer', 'header', 'title', 'description', 'closeButton'
|
|
172
|
+
Modal.elements = ['wrapper', 'box', 'backdrop', 'innerWrapper', 'scroll', 'body', 'footer', 'header', 'title', 'description', 'closeButton']
|
|
192
173
|
Modal.rootElement = 'wrapper'
|
|
193
174
|
|
|
194
175
|
Modal.withVariantTypes = <S extends AnyRecord>(styles: S) => {
|
|
@@ -201,10 +182,10 @@ Modal.defaultProps = {
|
|
|
201
182
|
dismissOnBackdrop: true,
|
|
202
183
|
scroll: true,
|
|
203
184
|
closeOnHardwareBackPress: true,
|
|
204
|
-
boxEntering: FadeIn.duration(100).build(),
|
|
185
|
+
boxEntering: FadeIn.duration(100).delay(50).build(),
|
|
205
186
|
boxExiting: FadeOut.duration(100).build(),
|
|
187
|
+
withPortal: true,
|
|
188
|
+
renderHeader: DefaultHeader,
|
|
206
189
|
} as Partial<ModalProps>
|
|
207
190
|
|
|
208
|
-
MobileStyleRegistry.registerComponent(Modal)
|
|
209
|
-
|
|
210
|
-
export default Modal
|
|
191
|
+
MobileStyleRegistry.registerComponent(Modal)
|
|
@@ -20,7 +20,6 @@ export type ModalProps =
|
|
|
20
20
|
closeIconName?: AppIcon
|
|
21
21
|
visible?: boolean
|
|
22
22
|
toggle?: () => void
|
|
23
|
-
zIndex?: number
|
|
24
23
|
description?: React.ReactElement
|
|
25
24
|
scroll?: boolean
|
|
26
25
|
header?: React.ReactElement
|
|
@@ -30,7 +29,7 @@ export type ModalProps =
|
|
|
30
29
|
scrollProps?: PropsOf<typeof Scroll, 'ref'>
|
|
31
30
|
style?: StyledProp<ModalComposition>
|
|
32
31
|
id?: string
|
|
33
|
-
|
|
32
|
+
withPortal?: boolean
|
|
34
33
|
boxEntering?: ReanimatedEnteringAnimation
|
|
35
34
|
boxExiting?: ReanimatedExitingAnimation
|
|
36
35
|
}
|
|
@@ -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 ? (
|