@codeleap/mobile 4.3.9 → 5.0.0
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/index.js.map +1 -1
- package/dist/components/Autocomplete/types.d.ts +9 -10
- package/dist/components/Backdrop/index.js.map +1 -1
- package/dist/components/Checkbox/index.js +13 -9
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Checkbox/types.d.ts +5 -2
- package/dist/components/DatePickerModal/index.js +18 -11
- package/dist/components/DatePickerModal/index.js.map +1 -1
- package/dist/components/DatePickerModal/types.d.ts +12 -9
- package/dist/components/FileInput/types.d.ts +3 -4
- package/dist/components/Grid/index.js.map +1 -1
- package/dist/components/Image/types.d.ts +2 -5
- package/dist/components/InputBase/index.d.ts +2 -6
- package/dist/components/InputBase/index.js +9 -5
- package/dist/components/InputBase/index.js.map +1 -1
- package/dist/components/InputBase/types.d.ts +2 -0
- package/dist/components/InputBase/useInputBase.d.ts +24 -0
- package/dist/components/InputBase/useInputBase.js +46 -0
- package/dist/components/InputBase/useInputBase.js.map +1 -0
- package/dist/components/InputBase/useInputBasePartialStyles.d.ts +2 -0
- package/dist/components/InputBase/useInputBasePartialStyles.js +30 -0
- package/dist/components/InputBase/useInputBasePartialStyles.js.map +1 -0
- package/dist/components/InputBase/utils.js +16 -16
- package/dist/components/InputBase/utils.js.map +1 -1
- package/dist/components/List/index.js +1 -1
- package/dist/components/List/index.js.map +1 -1
- package/dist/components/Modal/index.js +4 -14
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/NumberIncrement/index.js +21 -132
- package/dist/components/NumberIncrement/index.js.map +1 -1
- package/dist/components/NumberIncrement/types.d.ts +7 -5
- package/dist/components/NumberIncrement/useNumberIncrement.d.ts +55 -0
- package/dist/components/NumberIncrement/useNumberIncrement.js +107 -0
- package/dist/components/NumberIncrement/useNumberIncrement.js.map +1 -0
- package/dist/components/RadioInput/index.d.ts +1 -1
- package/dist/components/RadioInput/index.js +20 -41
- package/dist/components/RadioInput/index.js.map +1 -1
- package/dist/components/RadioInput/types.d.ts +11 -9
- package/dist/components/Scroll/index.js +25 -28
- package/dist/components/Scroll/index.js.map +1 -1
- package/dist/components/Scroll/types.d.ts +4 -4
- package/dist/components/Sections/index.js +1 -1
- package/dist/components/Sections/index.js.map +1 -1
- package/dist/components/SegmentedControl/index.js +6 -4
- package/dist/components/SegmentedControl/index.js.map +1 -1
- package/dist/components/SegmentedControl/types.d.ts +4 -3
- package/dist/components/Select/index.js +10 -6
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/types.d.ts +19 -18
- package/dist/components/Slider/index.js +18 -57
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Slider/types.d.ts +7 -5
- package/dist/components/SortablePhotos/index.js +17 -18
- package/dist/components/SortablePhotos/index.js.map +1 -1
- package/dist/components/SortablePhotos/types.d.ts +5 -15
- package/dist/components/SortablePhotos/useSortablePhotos.d.ts +11 -8
- package/dist/components/SortablePhotos/useSortablePhotos.js +18 -11
- package/dist/components/SortablePhotos/useSortablePhotos.js.map +1 -1
- package/dist/components/Switch/index.js +13 -9
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Switch/types.d.ts +5 -2
- package/dist/components/TextInput/index.js +26 -70
- package/dist/components/TextInput/index.js.map +1 -1
- package/dist/components/TextInput/types.d.ts +8 -6
- package/dist/components/TextInput/useTextInput.d.ts +54 -0
- package/dist/components/TextInput/useTextInput.js +59 -0
- package/dist/components/TextInput/useTextInput.js.map +1 -0
- package/dist/components/Touchable/index.js +4 -3
- package/dist/components/Touchable/index.js.map +1 -1
- package/dist/components/View/index.d.ts +7 -12
- package/dist/components/View/index.js +9 -7
- package/dist/components/View/index.js.map +1 -1
- package/dist/components/View/types.d.ts +6 -6
- package/dist/components/components.d.ts +0 -2
- package/dist/components/components.js +0 -2
- package/dist/components/components.js.map +1 -1
- package/dist/hooks/index.d.ts +3 -2
- package/dist/hooks/index.js +3 -10
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useKeyboardController.d.ts +6 -0
- package/dist/hooks/useKeyboardController.js +19 -0
- package/dist/hooks/useKeyboardController.js.map +1 -0
- package/dist/hooks/useStatusBar.d.ts +6 -0
- package/dist/hooks/useStatusBar.js +15 -0
- package/dist/hooks/useStatusBar.js.map +1 -0
- package/dist/hooks/useStylesFor.d.ts +2 -0
- package/dist/hooks/useStylesFor.js +11 -0
- package/dist/hooks/useStylesFor.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/modules/backgroundTimer.d.ts +3 -0
- package/dist/modules/backgroundTimer.js +31 -0
- package/dist/modules/backgroundTimer.js.map +1 -0
- package/dist/modules/index.d.ts +3 -0
- package/dist/modules/index.js +3 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/reactNavigation.d.ts +8 -21
- package/dist/modules/reactNavigation.js +38 -12
- package/dist/modules/reactNavigation.js.map +1 -1
- package/dist/modules/scroll.d.ts +18 -0
- package/dist/modules/scroll.js +57 -0
- package/dist/modules/scroll.js.map +1 -0
- package/dist/modules/types/textInputMask.d.ts +6 -2
- package/dist/utils/KeyboardAware/context.js +2 -6
- package/dist/utils/KeyboardAware/context.js.map +1 -1
- package/dist/utils/KeyboardAware/index.d.ts +0 -1
- package/dist/utils/KeyboardAware/index.js +0 -1
- package/dist/utils/KeyboardAware/index.js.map +1 -1
- package/dist/utils/ModalManager/context.js +2 -2
- package/dist/utils/ModalManager/context.js.map +1 -1
- package/dist/utils/hooks.js +4 -4
- package/dist/utils/hooks.js.map +1 -1
- package/dist/utils/locale.d.ts +1 -1
- package/dist/utils/locale.js +10 -5
- package/dist/utils/locale.js.map +1 -1
- package/dist/utils/theme.d.ts +1 -0
- package/dist/utils/theme.js +4 -2
- package/dist/utils/theme.js.map +1 -1
- package/package.json +31 -35
- package/package.json.bak +17 -20
- package/src/components/Autocomplete/index.tsx +2 -3
- package/src/components/Autocomplete/types.ts +9 -10
- package/src/components/Backdrop/index.tsx +0 -1
- package/src/components/Checkbox/index.tsx +23 -9
- package/src/components/Checkbox/types.ts +5 -2
- package/src/components/DatePickerModal/index.tsx +27 -18
- package/src/components/DatePickerModal/types.ts +12 -9
- package/src/components/FileInput/types.ts +3 -4
- package/src/components/Grid/index.tsx +3 -3
- package/src/components/Image/types.ts +3 -6
- package/src/components/InputBase/index.tsx +13 -7
- package/src/components/InputBase/types.ts +2 -0
- package/src/components/InputBase/useInputBase.ts +60 -0
- package/src/components/InputBase/useInputBasePartialStyles.ts +38 -0
- package/src/components/InputBase/utils.ts +17 -17
- package/src/components/List/index.tsx +0 -1
- package/src/components/Modal/index.tsx +4 -15
- package/src/components/NumberIncrement/index.tsx +52 -160
- package/src/components/NumberIncrement/types.ts +7 -5
- package/src/components/NumberIncrement/useNumberIncrement.ts +152 -0
- package/src/components/RadioInput/index.tsx +37 -53
- package/src/components/RadioInput/types.ts +11 -9
- package/src/components/Scroll/index.tsx +44 -45
- package/src/components/Scroll/types.ts +4 -4
- package/src/components/Sections/index.tsx +0 -1
- package/src/components/SegmentedControl/index.tsx +8 -6
- package/src/components/SegmentedControl/types.ts +4 -3
- package/src/components/Select/index.tsx +32 -24
- package/src/components/Select/types.ts +19 -18
- package/src/components/Slider/index.tsx +34 -66
- package/src/components/Slider/types.ts +7 -5
- package/src/components/SortablePhotos/index.tsx +31 -47
- package/src/components/SortablePhotos/types.ts +6 -15
- package/src/components/SortablePhotos/useSortablePhotos.ts +28 -22
- package/src/components/Switch/index.tsx +23 -9
- package/src/components/Switch/types.ts +5 -2
- package/src/components/TextInput/index.tsx +55 -89
- package/src/components/TextInput/types.ts +9 -7
- package/src/components/TextInput/useTextInput.ts +88 -0
- package/src/components/Touchable/index.tsx +5 -1
- package/src/components/View/index.tsx +19 -12
- package/src/components/View/types.ts +7 -6
- package/src/components/components.ts +0 -2
- package/src/hooks/index.ts +3 -13
- package/src/hooks/useKeyboardController.ts +28 -0
- package/src/hooks/useStatusBar.ts +21 -0
- package/src/hooks/useStylesFor.ts +13 -0
- package/src/index.ts +3 -1
- package/src/modules/backgroundTimer.ts +39 -0
- package/src/modules/index.ts +3 -0
- package/src/modules/reactNavigation.ts +64 -14
- package/src/modules/scroll.tsx +89 -0
- package/src/modules/types/textInputMask.ts +8 -4
- package/src/types/index.ts +1 -0
- package/src/utils/KeyboardAware/context.tsx +2 -6
- package/src/utils/KeyboardAware/index.ts +1 -1
- package/src/utils/ModalManager/context.tsx +2 -2
- package/src/utils/hooks.ts +4 -4
- package/src/utils/locale.ts +13 -5
- package/src/utils/theme.ts +6 -2
- package/dist/components/Navigation/Navigation.d.ts +0 -55
- package/dist/components/Navigation/Navigation.js +0 -41
- package/dist/components/Navigation/Navigation.js.map +0 -1
- package/dist/components/Navigation/constants.d.ts +0 -9
- package/dist/components/Navigation/constants.js +0 -9
- package/dist/components/Navigation/constants.js.map +0 -1
- package/dist/components/Navigation/index.d.ts +0 -3
- package/dist/components/Navigation/index.js +0 -4
- package/dist/components/Navigation/index.js.map +0 -1
- package/dist/components/Navigation/types.d.ts +0 -26
- package/dist/components/Navigation/types.js +0 -2
- package/dist/components/Navigation/types.js.map +0 -1
- package/dist/components/Navigation/utils.d.ts +0 -3
- package/dist/components/Navigation/utils.js +0 -34
- package/dist/components/Navigation/utils.js.map +0 -1
- package/dist/components/NumberIncrement/utils.d.ts +0 -5
- package/dist/components/NumberIncrement/utils.js +0 -23
- package/dist/components/NumberIncrement/utils.js.map +0 -1
- package/dist/utils/KeyboardAware/types.d.ts +0 -1
- package/dist/utils/KeyboardAware/types.js +0 -6
- package/dist/utils/KeyboardAware/types.js.map +0 -1
- package/src/components/Navigation/Navigation.tsx +0 -55
- package/src/components/Navigation/constants.ts +0 -24
- package/src/components/Navigation/index.tsx +0 -3
- package/src/components/Navigation/types.ts +0 -28
- package/src/components/Navigation/utils.tsx +0 -57
- package/src/components/NumberIncrement/utils.ts +0 -27
- package/src/utils/KeyboardAware/types.ts +0 -159
|
@@ -1,104 +1,59 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { useValidate } from '@codeleap/form';
|
|
3
|
-
import { useBooleanToggle } from '@codeleap/hooks';
|
|
1
|
+
import React from 'react';
|
|
4
2
|
import { TypeGuards } from '@codeleap/types';
|
|
5
|
-
import { forwardRef
|
|
3
|
+
import { forwardRef } from 'react';
|
|
6
4
|
import { TextInput as NativeTextInput } from 'react-native';
|
|
7
5
|
import { InputBase, selectInputBaseProps } from '../InputBase';
|
|
8
6
|
import { Touchable } from '../Touchable';
|
|
9
7
|
import { MaskedTextInput } from '../../modules/textInputMask';
|
|
10
8
|
import { MobileStyleRegistry } from '../../Registry';
|
|
11
9
|
import { useStylesFor } from '../../hooks';
|
|
10
|
+
import { useTextInput } from './useTextInput';
|
|
11
|
+
import { useInputBasePartialStyles } from '../InputBase/useInputBasePartialStyles';
|
|
12
12
|
export * from './styles';
|
|
13
13
|
export * from './types';
|
|
14
14
|
export const TextInput = forwardRef((props, inputRef) => {
|
|
15
|
-
const
|
|
16
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
17
|
-
const [currentSelection, setCurrentSelection] = useState({ start: 0 });
|
|
18
|
-
const { inputBaseProps, others, } = selectInputBaseProps({
|
|
15
|
+
const allProps = {
|
|
19
16
|
...TextInput.defaultProps,
|
|
20
17
|
...props,
|
|
21
|
-
}
|
|
22
|
-
const {
|
|
23
|
-
const
|
|
24
|
-
const isMasked = !!masking;
|
|
25
|
-
const InputElement = isMasked ? MaskedTextInput : NativeTextInput;
|
|
18
|
+
};
|
|
19
|
+
const { inputBaseProps, others, } = selectInputBaseProps(allProps);
|
|
20
|
+
const { debugName, visibilityToggle, masking, secure, field, onChangeMask, onPress, visibleIcon, hiddenIcon, style, autoAdjustSelection, selectionStart, forceError, onChangeText, multiline, ...textInputProps } = others;
|
|
26
21
|
const styles = useStylesFor(TextInput.styleRegistryName, style);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
...innerInputRef.current,
|
|
31
|
-
focus: () => {
|
|
32
|
-
innerInputRef.current?.focus?.();
|
|
33
|
-
},
|
|
34
|
-
isTextInput: true,
|
|
35
|
-
};
|
|
36
|
-
}, [!!innerInputRef?.current?.focus]);
|
|
22
|
+
const { fieldHandle, validation, innerInputRef, wrapperRef, isFocused, secureTextEntry, currentSelection, hasMultipleLines, hasValue, hasError, toggleSecureTextEntry, handleMaskChange, handleBlur, handleFocus, } = useTextInput(allProps);
|
|
23
|
+
const InputElement = masking ? MaskedTextInput : NativeTextInput;
|
|
37
24
|
const isPressable = TypeGuards.isFunction(onPress);
|
|
38
|
-
const validation = useValidate(value, validate);
|
|
39
|
-
const handleBlur = React.useCallback((e) => {
|
|
40
|
-
validation.onInputBlurred();
|
|
41
|
-
setIsFocused(false);
|
|
42
|
-
if (autoAdjustSelection)
|
|
43
|
-
setCurrentSelection({ start: selectionStart });
|
|
44
|
-
props.onBlur?.(e);
|
|
45
|
-
}, [validation.onInputBlurred, props.onBlur]);
|
|
46
|
-
const handleFocus = React.useCallback((e) => {
|
|
47
|
-
validation.onInputFocused();
|
|
48
|
-
setIsFocused(true);
|
|
49
|
-
if (autoAdjustSelection)
|
|
50
|
-
setCurrentSelection(null);
|
|
51
|
-
props.onFocus?.(e);
|
|
52
|
-
}, [validation.onInputFocused, props.onFocus]);
|
|
53
|
-
const handleMaskChange = (masked, unmasked) => {
|
|
54
|
-
if (textInputProps.onChangeText)
|
|
55
|
-
textInputProps.onChangeText(masking?.saveFormatted ? masked : masked);
|
|
56
|
-
if (onChangeMask)
|
|
57
|
-
onChangeMask(masked, unmasked);
|
|
58
|
-
};
|
|
59
|
-
const isMultiline = textInputProps.multiline;
|
|
60
25
|
const isDisabled = !!inputBaseProps.disabled;
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// @ts-expect-error
|
|
67
|
-
].find(([x]) => x)?.[1]?.color;
|
|
68
|
-
const selectionColor = [
|
|
69
|
-
[isDisabled, styles['selection:disabled']],
|
|
70
|
-
[!validation.isValid, styles['selection:error']],
|
|
71
|
-
[isFocused, styles['selection:focus']],
|
|
72
|
-
[true, styles?.selection],
|
|
73
|
-
// @ts-expect-error
|
|
74
|
-
].find(([x]) => x)?.[1]?.color;
|
|
26
|
+
const partialStyles = useInputBasePartialStyles(styles, ['placeholder', 'selection'], {
|
|
27
|
+
disabled: isDisabled,
|
|
28
|
+
error: !!hasError,
|
|
29
|
+
focus: isFocused,
|
|
30
|
+
});
|
|
75
31
|
const visibilityToggleProps = visibilityToggle ? {
|
|
76
32
|
onPress: toggleSecureTextEntry,
|
|
77
33
|
icon: (secureTextEntry ? hiddenIcon : visibleIcon),
|
|
78
34
|
debugName: `${debugName} toggle visibility`,
|
|
79
35
|
} : null;
|
|
80
36
|
const rightIcon = inputBaseProps?.rightIcon ?? visibilityToggleProps;
|
|
81
|
-
const maskingExtraProps =
|
|
37
|
+
const maskingExtraProps = masking ? {
|
|
82
38
|
onChangeText: handleMaskChange,
|
|
83
39
|
ref: null,
|
|
84
40
|
refInput: (inputRef) => {
|
|
85
|
-
if (!!inputRef)
|
|
41
|
+
if (!!inputRef)
|
|
86
42
|
innerInputRef.current = inputRef;
|
|
87
|
-
}
|
|
88
43
|
},
|
|
89
44
|
...masking,
|
|
90
|
-
} : {
|
|
45
|
+
} : {
|
|
46
|
+
onChangeText: fieldHandle.setValue
|
|
47
|
+
};
|
|
91
48
|
const buttonModeProps = isPressable ? {
|
|
92
49
|
editable: false,
|
|
93
50
|
caretHidden: true,
|
|
94
51
|
} : {};
|
|
95
|
-
|
|
96
|
-
const hasValue = value?.length > 0;
|
|
97
|
-
return <InputBase {...inputBaseProps} innerWrapper={isPressable ? Touchable : undefined} debugName={debugName} error={(validation.isValid && !_error) ? null : _error || validation.message} style={{
|
|
52
|
+
return <InputBase {...inputBaseProps} ref={wrapperRef} innerWrapper={isPressable ? Touchable : undefined} debugName={debugName} error={hasError ? validation.message || forceError : null} style={{
|
|
98
53
|
...styles,
|
|
99
54
|
innerWrapper: [
|
|
100
55
|
styles?.innerWrapper,
|
|
101
|
-
|
|
56
|
+
multiline && styles['innerWrapper:multiline'],
|
|
102
57
|
hasMultipleLines && styles['innerWrapper:hasMultipleLines'],
|
|
103
58
|
],
|
|
104
59
|
}} innerWrapperProps={{
|
|
@@ -107,11 +62,11 @@ export const TextInput = forwardRef((props, inputRef) => {
|
|
|
107
62
|
debugName,
|
|
108
63
|
dismissKeyboard: false,
|
|
109
64
|
}} rightIcon={rightIcon} focused={isFocused} hasValue={hasValue}>
|
|
110
|
-
<InputElement allowFontScaling={false} editable={!isPressable && !isDisabled} {...buttonModeProps} selection={autoAdjustSelection ? currentSelection : undefined} placeholderTextColor={
|
|
65
|
+
<InputElement allowFontScaling={false} editable={!isPressable && !isDisabled} {...buttonModeProps} selection={autoAdjustSelection ? currentSelection : undefined} placeholderTextColor={partialStyles?.placeholder?.color} value={fieldHandle?.value} selectionColor={partialStyles?.selection?.color} secureTextEntry={secure && secureTextEntry} textAlignVertical={multiline ? 'top' : undefined} multiline={multiline} {...textInputProps} onBlur={handleBlur} onFocus={handleFocus} style={[
|
|
111
66
|
styles?.input,
|
|
112
|
-
|
|
67
|
+
multiline && styles['input:multiline'],
|
|
113
68
|
isFocused && styles['input:focused'],
|
|
114
|
-
|
|
69
|
+
hasError && styles['input:error'],
|
|
115
70
|
isDisabled && styles['input:disabled'],
|
|
116
71
|
hasMultipleLines && styles['input:hasMultipleLines'],
|
|
117
72
|
hasValue && styles['input:typed'],
|
|
@@ -130,6 +85,7 @@ TextInput.defaultProps = {
|
|
|
130
85
|
visibilityToggle: false,
|
|
131
86
|
autoAdjustSelection: false,
|
|
132
87
|
selectionStart: 0,
|
|
88
|
+
secure: false,
|
|
133
89
|
};
|
|
134
90
|
MobileStyleRegistry.registerComponent(TextInput);
|
|
135
91
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TextInput/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TextInput/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,SAAS,IAAI,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAG7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAA;AAElF,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAEvB,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAkC,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;IACvF,MAAM,QAAQ,GAAG;QACf,GAAG,SAAS,CAAC,YAAY;QACzB,GAAG,KAAK;KACT,CAAA;IAED,MAAM,EACJ,cAAc,EACd,MAAM,GACP,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IAElC,MAAM,EACJ,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,MAAM,EACN,KAAK,EACL,YAAY,EACZ,OAAO,EACP,WAAW,EACX,UAAU,EACV,KAAK,EACL,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,YAAY,EACZ,SAAS,EACT,GAAG,cAAc,EAClB,GAAG,MAA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AE,EAAE;IAC9D,OAAO,SAAiF,CAAA;AAC1F,CAAC,CAAA;AAED,SAAS,CAAC,YAAY,GAAG;IACvB,UAAU,EAAE,wBAAmC;IAC/C,WAAW,EAAE,yBAAoC;IACjD,gBAAgB,EAAE,KAAK;IACvB,mBAAmB,EAAE,KAAK;IAC1B,cAAc,EAAE,CAAC;IACjB,MAAM,EAAE,KAAK;CACa,CAAA;AAE5B,mBAAmB,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAA"}
|
|
@@ -2,23 +2,25 @@
|
|
|
2
2
|
import { InputBaseProps } from '../InputBase';
|
|
3
3
|
import { TextInputProps as RNTextInputProps, TextInput as RNTextInput } from 'react-native';
|
|
4
4
|
import { AnyFunction } from '@codeleap/types';
|
|
5
|
-
import { FormTypes, yup } from '@codeleap/form';
|
|
6
5
|
import { AppIcon, StyledProp } from '@codeleap/styles';
|
|
7
6
|
import { TextInputMaskProps } from '../../modules/textInputMask';
|
|
8
7
|
import { TextInputComposition } from './styles';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import { Field } from '@codeleap/form';
|
|
9
|
+
export type TextInputProps = Omit<InputBaseProps, 'style' | 'ref'> & Omit<RNTextInputProps, 'style'> & {
|
|
10
|
+
secure?: boolean;
|
|
12
11
|
debugName: string;
|
|
13
12
|
autoAdjustSelection?: boolean;
|
|
14
13
|
selectionStart?: number;
|
|
15
14
|
visibilityToggle?: boolean;
|
|
16
|
-
masking?: FormTypes.TextField['masking'];
|
|
17
15
|
onChangeMask?: TextInputMaskProps['onChangeText'];
|
|
16
|
+
masking?: TextInputMaskProps['masking'];
|
|
18
17
|
visibleIcon?: AppIcon;
|
|
19
18
|
hiddenIcon?: AppIcon;
|
|
20
|
-
|
|
19
|
+
forceError?: string;
|
|
21
20
|
onPress?: AnyFunction;
|
|
22
21
|
style?: StyledProp<TextInputComposition>;
|
|
23
22
|
ref?: React.Ref<RNTextInput>;
|
|
23
|
+
field?: Field<string, any, any>;
|
|
24
|
+
value?: string;
|
|
25
|
+
onValueChange?: (value: string) => void;
|
|
24
26
|
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TextInputProps } from './types';
|
|
3
|
+
import { NativeSyntheticEvent, TextInputFocusEventData } from 'react-native/types';
|
|
4
|
+
export declare function useTextInput(props: Partial<TextInputProps>): {
|
|
5
|
+
isFocused: boolean;
|
|
6
|
+
currentSelection: {
|
|
7
|
+
start: number;
|
|
8
|
+
};
|
|
9
|
+
secureTextEntry: boolean;
|
|
10
|
+
handleBlur: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;
|
|
11
|
+
handleFocus: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;
|
|
12
|
+
handleMaskChange: (masked: any, unmasked: any) => void;
|
|
13
|
+
fieldHandle: {
|
|
14
|
+
validation: {
|
|
15
|
+
onInputBlurred(): void;
|
|
16
|
+
hasBlurred: boolean;
|
|
17
|
+
hasChanged: boolean;
|
|
18
|
+
startedUnset: boolean;
|
|
19
|
+
isSet: boolean;
|
|
20
|
+
isInvalid: boolean;
|
|
21
|
+
isValid: boolean;
|
|
22
|
+
message: any;
|
|
23
|
+
showError: boolean;
|
|
24
|
+
isUnset: boolean;
|
|
25
|
+
validation: import("@codeleap/form").ValidationResult<any, unknown>;
|
|
26
|
+
value: string;
|
|
27
|
+
};
|
|
28
|
+
value: string;
|
|
29
|
+
setValue: (to: string) => void;
|
|
30
|
+
changed: boolean;
|
|
31
|
+
representation: any;
|
|
32
|
+
options: import("@codeleap/form").FieldOptions<string, any>;
|
|
33
|
+
};
|
|
34
|
+
validation: {
|
|
35
|
+
onInputBlurred(): void;
|
|
36
|
+
hasBlurred: boolean;
|
|
37
|
+
hasChanged: boolean;
|
|
38
|
+
startedUnset: boolean;
|
|
39
|
+
isSet: boolean;
|
|
40
|
+
isInvalid: boolean;
|
|
41
|
+
isValid: boolean;
|
|
42
|
+
message: any;
|
|
43
|
+
showError: boolean;
|
|
44
|
+
isUnset: boolean;
|
|
45
|
+
validation: import("@codeleap/form").ValidationResult<any, unknown>;
|
|
46
|
+
value: string;
|
|
47
|
+
};
|
|
48
|
+
innerInputRef: import("react").MutableRefObject<import("react-native/types").TextInput>;
|
|
49
|
+
wrapperRef: import("react").MutableRefObject<import("react-native/types").View>;
|
|
50
|
+
toggleSecureTextEntry: () => void;
|
|
51
|
+
hasMultipleLines: boolean;
|
|
52
|
+
hasValue: boolean;
|
|
53
|
+
hasError: string | true;
|
|
54
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { useInputBase } from '../InputBase/useInputBase';
|
|
3
|
+
import { fields } from '@codeleap/form';
|
|
4
|
+
export function useTextInput(props) {
|
|
5
|
+
const { onFocus, onBlur, secure, field, autoAdjustSelection, selectionStart, masking, onChangeMask, multiline, forceError, value, onValueChange, } = props;
|
|
6
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
7
|
+
const [currentSelection, setCurrentSelection] = useState({ start: 0 });
|
|
8
|
+
const [secureTextEntry, setSecureTextEntry] = useState(secure);
|
|
9
|
+
const toggleSecureTextEntry = () => setSecureTextEntry(s => !s);
|
|
10
|
+
const { fieldHandle, validation, innerInputRef, wrapperRef, } = useInputBase(field, fields.text, [value, onValueChange], {
|
|
11
|
+
revealValue() {
|
|
12
|
+
setSecureTextEntry(false);
|
|
13
|
+
},
|
|
14
|
+
hideValue() {
|
|
15
|
+
setSecureTextEntry(true);
|
|
16
|
+
},
|
|
17
|
+
toggleValueVisibility() {
|
|
18
|
+
toggleSecureTextEntry();
|
|
19
|
+
},
|
|
20
|
+
}, [setSecureTextEntry]);
|
|
21
|
+
const handleBlur = useCallback((e) => {
|
|
22
|
+
validation.onInputBlurred();
|
|
23
|
+
setIsFocused(false);
|
|
24
|
+
if (autoAdjustSelection)
|
|
25
|
+
setCurrentSelection({ start: selectionStart });
|
|
26
|
+
onBlur?.(e);
|
|
27
|
+
}, [validation.onInputBlurred, onBlur]);
|
|
28
|
+
const handleFocus = useCallback((e) => {
|
|
29
|
+
setIsFocused(true);
|
|
30
|
+
if (autoAdjustSelection)
|
|
31
|
+
setCurrentSelection(null);
|
|
32
|
+
onFocus?.(e);
|
|
33
|
+
}, [onFocus]);
|
|
34
|
+
const handleMaskChange = useCallback((masked, unmasked) => {
|
|
35
|
+
fieldHandle.setValue(masking?.saveFormatted ? masked : masked);
|
|
36
|
+
if (onChangeMask)
|
|
37
|
+
onChangeMask(masked, unmasked);
|
|
38
|
+
}, [masking?.saveFormatted, onChangeMask]);
|
|
39
|
+
const hasMultipleLines = multiline && fieldHandle?.value?.includes('\n');
|
|
40
|
+
const hasValue = fieldHandle?.value?.length > 0;
|
|
41
|
+
const hasError = validation.showError || forceError;
|
|
42
|
+
return {
|
|
43
|
+
isFocused,
|
|
44
|
+
currentSelection,
|
|
45
|
+
secureTextEntry,
|
|
46
|
+
handleBlur,
|
|
47
|
+
handleFocus,
|
|
48
|
+
handleMaskChange,
|
|
49
|
+
fieldHandle,
|
|
50
|
+
validation,
|
|
51
|
+
innerInputRef,
|
|
52
|
+
wrapperRef,
|
|
53
|
+
toggleSecureTextEntry,
|
|
54
|
+
hasMultipleLines,
|
|
55
|
+
hasValue,
|
|
56
|
+
hasError,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=useTextInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTextInput.js","sourceRoot":"","sources":["../../../src/components/TextInput/useTextInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC,MAAM,UAAU,YAAY,CAAC,KAA8B;IACzD,MAAM,EACJ,OAAO,EACP,MAAM,EACN,MAAM,EACN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W,CAAC,CAAC,CAAgD,EAAE,EAAE;QACnF,YAAY,CAAC,IAAI,CAAC,CAAA;QAClB,IAAI,mBAAmB;YAAE,mBAAmB,CAAC,IAAI,CAAC,CAAA;QAClD,OAAO,EAAE,CAAC,CAAC,CAAC,CAAA;IACd,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IAEb,MAAM,gBAAgB,GAAG,WAAW,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;QACxD,WAAW,CAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;QAC9D,IAAI,YAAY;YAAE,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAClD,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC,CAAA;IAE1C,MAAM,gBAAgB,GAAG,SAAS,IAAI,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;IAExE,MAAM,QAAQ,GAAG,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAAA;IAE/C,MAAM,QAAQ,GAAG,UAAU,CAAC,SAAS,IAAI,UAAU,CAAA;IAEnD,OAAO;QACL,SAAS;QACT,gBAAgB;QAChB,eAAe;QACf,UAAU;QACV,WAAW;QACX,gBAAgB;QAChB,WAAW;QACX,UAAU;QACV,aAAa;QACb,UAAU;QACV,qBAAqB;QACrB,gBAAgB;QAChB,QAAQ;QACR,QAAQ;KACT,CAAA;AACH,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import { TypeGuards } from '@codeleap/types';
|
|
3
|
-
import { onMount } from '@codeleap/hooks';
|
|
3
|
+
import { onMount, useComponentTestId } from '@codeleap/hooks';
|
|
4
4
|
import { useGlobalContext } from '@codeleap/hooks';
|
|
5
5
|
import { Pressable, StyleSheet, Platform } from 'react-native';
|
|
6
6
|
import { View } from '../View';
|
|
@@ -26,6 +26,7 @@ export const Touchable = forwardRef((touchableProps, ref) => {
|
|
|
26
26
|
});
|
|
27
27
|
const styles = useStylesFor(Touchable.styleRegistryName, style);
|
|
28
28
|
const { logger } = useGlobalContext();
|
|
29
|
+
const testId = useComponentTestId(Touchable, touchableProps, ['style', 'children', 'debounce']);
|
|
29
30
|
const press = () => {
|
|
30
31
|
if (!onPress)
|
|
31
32
|
return;
|
|
@@ -138,7 +139,7 @@ export const Touchable = forwardRef((touchableProps, ref) => {
|
|
|
138
139
|
} : props.hitSlop;
|
|
139
140
|
const disableRipple = disableFeedback || rippleDisabled || Platform.OS !== 'android';
|
|
140
141
|
return (<Wrapper style={wrapperStyle} hitSlop={hitSlop}>
|
|
141
|
-
{!disableRipple ? (<PressableRipple onPress={press} {...props} style={[pressableStyle, styles?.pressable]} rippleFades={false} rippleDuration={350} rippleOpacity={0.1} {...rippleConfig} radiusStyles={radiusStyle}
|
|
142
|
+
{!disableRipple ? (<PressableRipple onPress={press} testID={testId} {...props} style={[pressableStyle, styles?.pressable]} rippleFades={false} rippleDuration={350} rippleOpacity={0.1} {...rippleConfig} radiusStyles={radiusStyle}
|
|
142
143
|
// @ts-ignore
|
|
143
144
|
ref={ref}>
|
|
144
145
|
{children}
|
|
@@ -146,7 +147,7 @@ export const Touchable = forwardRef((touchableProps, ref) => {
|
|
|
146
147
|
pressableStyle,
|
|
147
148
|
getFeedbackStyle(pressed),
|
|
148
149
|
styles?.pressable,
|
|
149
|
-
])} {...props} ref={ref}>
|
|
150
|
+
])} testID={testId} {...props} ref={ref}>
|
|
150
151
|
{children}
|
|
151
152
|
</Pressable>)}
|
|
152
153
|
</Wrapper>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Touchable/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAC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
/// <reference types="react" />
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
import { ViewAnimatedProps, ViewProps } from './types';
|
|
6
4
|
export * from './types';
|
|
7
5
|
export * from './styles';
|
|
8
|
-
export declare const View: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
elements: string[];
|
|
13
|
-
rootElement: string;
|
|
14
|
-
withVariantTypes<S extends AnyRecord>(styles: S): <T_1 extends React.ComponentType<{}> = typeof RNView>(props: StyledComponentProps<ViewProps<T_1>, S>) => IJSX;
|
|
6
|
+
export declare const View: ((props: ViewProps) => JSX.Element) & {
|
|
7
|
+
defaultProps?: Partial<ViewProps>;
|
|
8
|
+
} & import("@codeleap/styles").GenericStyledComponentAttributes<ViewProps> & {
|
|
9
|
+
Animated?: (props: ViewAnimatedProps) => JSX.Element;
|
|
15
10
|
};
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import { View as RNView } from 'react-native';
|
|
3
3
|
import { MobileStyleRegistry } from '../../Registry';
|
|
4
4
|
import Animated from 'react-native-reanimated';
|
|
5
5
|
import { useStylesFor } from '../../hooks';
|
|
6
|
+
import { useComponentTestId } from '@codeleap/hooks';
|
|
6
7
|
export * from './types';
|
|
7
8
|
export * from './styles';
|
|
8
|
-
export const View = (props) => {
|
|
9
|
-
const { style,
|
|
9
|
+
export const View = forwardRef((props, ref) => {
|
|
10
|
+
const { style, animated = false, animatedStyle, ...viewProps } = props;
|
|
10
11
|
const styles = useStylesFor(View.styleRegistryName, style);
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
};
|
|
12
|
+
const testId = useComponentTestId(View, props, ['style', 'children', 'animated']);
|
|
13
|
+
const Component = animated ? Animated.View : RNView;
|
|
14
|
+
return (<Component testID={testId} {...viewProps} style={[styles.wrapper, animatedStyle]} ref={ref}/>);
|
|
15
|
+
});
|
|
14
16
|
View.Animated = (props) => {
|
|
15
|
-
return <View {...props}
|
|
17
|
+
return <View {...props}/>;
|
|
16
18
|
};
|
|
17
19
|
View.styleRegistryName = 'View';
|
|
18
20
|
View.elements = ['wrapper'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/View/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/View/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,QAAQ,MAAM,yBAAyB,CAAA;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AAExB,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAAoB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAC/D,MAAM,EACJ,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,aAAa,EACb,GAAG,SAAS,EACb,GAAG,KAAK,CAAA;IAET,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAA;IAE1D,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAA;IAEjF,MAAM,SAAS,GAAmC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAA;IAEnF,OAAO,CACL,CAAC,SAAS,CACR,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,IAAI,SAAS,CAAC,CACd,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CACvC,GAAG,CAAC,CAAC,GAAG,CAAC,EACT,CACH,CAAA;AACH,CAAC,CAAmG,CAAA;AAEpG,IAAI,CAAC,QAAQ,GAAG,CAAC,KAAwB,EAAE,EAAE;IAC3C,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,EAAG,CAAA;AAC5B,CAAC,CAAA;AAED,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAA;AAC/B,IAAI,CAAC,QAAQ,GAAG,CAAC,SAAS,CAAC,CAAA;AAC3B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;AAE5B,IAAI,CAAC,gBAAgB,GAAG,CAAsB,MAAS,EAAE,EAAE;IACzD,OAAO,IAAuE,CAAA;AAChF,CAAC,CAAA;AAED,mBAAmB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { PropsOf } from '@codeleap/types';
|
|
3
2
|
import { StyledProp } from '@codeleap/styles';
|
|
4
|
-
import { ImageStyle, TextStyle,
|
|
5
|
-
import { AnimatedStyleProp } from 'react-native-reanimated';
|
|
3
|
+
import { ImageStyle, TextStyle, ViewProps as RNViewProps, ViewStyle } from 'react-native';
|
|
4
|
+
import Animated, { AnimatedStyleProp } from 'react-native-reanimated';
|
|
6
5
|
import { ViewComposition } from './styles';
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import { PropsOf } from '@codeleap/types';
|
|
7
|
+
export type ViewProps = Omit<RNViewProps, 'style'> & {
|
|
9
8
|
style?: StyledProp<ViewComposition>;
|
|
10
9
|
animated?: boolean;
|
|
11
10
|
children?: React.ReactNode;
|
|
12
11
|
animatedStyle?: AnimatedStyleProp<ViewStyle | ImageStyle | TextStyle>;
|
|
13
|
-
}
|
|
12
|
+
};
|
|
13
|
+
export type ViewAnimatedProps = ViewProps & Omit<PropsOf<typeof Animated.View>, 'style'>;
|
|
@@ -12,7 +12,6 @@ export * from './Select';
|
|
|
12
12
|
export * from './FileInput';
|
|
13
13
|
export * from './Slider';
|
|
14
14
|
export * from './SegmentedControl';
|
|
15
|
-
export * from './Navigation';
|
|
16
15
|
export * from './Scroll';
|
|
17
16
|
export * from './List';
|
|
18
17
|
export * from './ActivityIndicator';
|
|
@@ -20,7 +19,6 @@ export * from './Button';
|
|
|
20
19
|
export * from './Modal';
|
|
21
20
|
export * from './Calendar';
|
|
22
21
|
export * from './ImageView';
|
|
23
|
-
export * from './Navigation';
|
|
24
22
|
export * from './Pager';
|
|
25
23
|
export * from './EmptyPlaceholder';
|
|
26
24
|
export * from './Backdrop';
|
|
@@ -12,7 +12,6 @@ export * from './Select';
|
|
|
12
12
|
export * from './FileInput';
|
|
13
13
|
export * from './Slider';
|
|
14
14
|
export * from './SegmentedControl';
|
|
15
|
-
export * from './Navigation';
|
|
16
15
|
export * from './Scroll';
|
|
17
16
|
export * from './List';
|
|
18
17
|
export * from './ActivityIndicator';
|
|
@@ -20,7 +19,6 @@ export * from './Button';
|
|
|
20
19
|
export * from './Modal';
|
|
21
20
|
export * from './Calendar';
|
|
22
21
|
export * from './ImageView';
|
|
23
|
-
export * from './Navigation';
|
|
24
22
|
export * from './Pager';
|
|
25
23
|
export * from './EmptyPlaceholder';
|
|
26
24
|
export * from './Backdrop';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/components/components.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cA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AkB,CAAA"}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
export * from './useStylesFor';
|
|
2
|
+
export * from './useStatusBar';
|
|
3
|
+
export * from './useKeyboardController';
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export const useStylesFor = (componentName, style) => {
|
|
5
|
-
const styleObserver = useStyleObserver(style);
|
|
6
|
-
const styles = useMemo(() => {
|
|
7
|
-
return MobileStyleRegistry.current.styleFor(componentName, style);
|
|
8
|
-
}, [styleObserver]);
|
|
9
|
-
return styles;
|
|
10
|
-
};
|
|
1
|
+
export * from './useStylesFor';
|
|
2
|
+
export * from './useStatusBar';
|
|
3
|
+
export * from './useKeyboardController';
|
|
11
4
|
//# sourceMappingURL=index.js.map
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { KeyboardEvents } from 'react-native-keyboard-controller';
|
|
3
|
+
export function useKeyboardController() {
|
|
4
|
+
const [keyboardState, setKeyboardState] = useState({ isVisible: false, height: 0 });
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const show = KeyboardEvents.addListener('keyboardWillShow', event => {
|
|
7
|
+
setKeyboardState({ isVisible: true, height: event?.height });
|
|
8
|
+
});
|
|
9
|
+
const hide = KeyboardEvents.addListener('keyboardWillHide', event => {
|
|
10
|
+
setKeyboardState(prev => ({ isVisible: false, height: prev?.height }));
|
|
11
|
+
});
|
|
12
|
+
return () => {
|
|
13
|
+
show.remove();
|
|
14
|
+
hide.remove();
|
|
15
|
+
};
|
|
16
|
+
}, []);
|
|
17
|
+
return keyboardState;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=useKeyboardController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useKeyboardController.js","sourceRoot":"","sources":["../../src/hooks/useKeyboardController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAOjE,MAAM,UAAU,qBAAqB;IACnC,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAA0B,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;IAE5G,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,IAAI,GAAG,cAAc,CAAC,WAAW,CAAC,kBAAkB,EAAE,KAAK,CAAC,EAAE;YAClE,gBAAgB,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;QAC9D,CAAC,CAAC,CAAA;QAEF,MAAM,IAAI,GAAG,cAAc,CAAC,WAAW,CAAC,kBAAkB,EAAE,KAAK,CAAC,EAAE;YAClE,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;QACxE,CAAC,CAAC,CAAA;QAEF,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,MAAM,EAAE,CAAA;YACb,IAAI,CAAC,MAAM,EAAE,CAAA;QACf,CAAC,CAAA;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,aAAa,CAAA;AACtB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useIsFocused } from '@react-navigation/native';
|
|
2
|
+
import { useLayoutEffect } from '@codeleap/hooks';
|
|
3
|
+
import { StatusBar } from 'react-native';
|
|
4
|
+
export function useStatusBar({ statusBarColor }) {
|
|
5
|
+
const focused = useIsFocused();
|
|
6
|
+
useLayoutEffect(() => {
|
|
7
|
+
if (!focused || !statusBarColor)
|
|
8
|
+
return;
|
|
9
|
+
const statusBarEntry = StatusBar.pushStackEntry({ barStyle: statusBarColor });
|
|
10
|
+
return () => {
|
|
11
|
+
StatusBar.popStackEntry(statusBarEntry);
|
|
12
|
+
};
|
|
13
|
+
}, [statusBarColor, focused]);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=useStatusBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStatusBar.js","sourceRoot":"","sources":["../../src/hooks/useStatusBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAkB,MAAM,cAAc,CAAA;AAMxD,MAAM,UAAU,YAAY,CAAC,EAAE,cAAc,EAAuB;IAClE,MAAM,OAAO,GAAG,YAAY,EAAE,CAAA;IAE9B,eAAe,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,OAAO,IAAI,CAAC,cAAc;YAAE,OAAM;QAEvC,MAAM,cAAc,GAAG,SAAS,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,CAAA;QAE7E,OAAO,GAAG,EAAE;YACV,SAAS,CAAC,aAAa,CAAC,cAAc,CAAC,CAAA;QACzC,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAA;AAC/B,CAAC"}
|