nx-react-native-cli 2.2.0 → 2.3.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/README.md +1 -2
- package/lib/index.cjs +2 -2
- package/package.json +11 -11
- package/templates/.eslintrc.json +2 -8
- package/templates/.nvmrc +1 -1
- package/templates/apps/mobile/Gemfile +1 -1
- package/templates/apps/mobile/android/build.gradle +4 -4
- package/templates/apps/mobile/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/templates/apps/mobile/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/templates/apps/mobile/android/gradle.properties +4 -0
- package/templates/apps/mobile/android/gradlew +4 -4
- package/templates/apps/mobile/android/gradlew.bat +7 -2
- package/templates/apps/mobile/babel.config.json +1 -1
- package/templates/apps/mobile/package.json +3 -2
- package/templates/apps/mobile/src/app/index.tsx +13 -8
- package/templates/apps/mobile/src/components/atoms/KeyboardAccessory/index.ts +1 -0
- package/templates/apps/mobile/src/components/atoms/KeyboardAccessory/keyboard-accessory.component.tsx +25 -0
- package/templates/apps/mobile/src/components/atoms/KeyboardAwareScrollView/keyboard-aware-scroll-view.component.tsx +7 -8
- package/templates/apps/mobile/src/components/atoms/TextInput/bottom-sheet-text-input.component.tsx +49 -6
- package/templates/apps/mobile/src/components/atoms/TextInput/constants.ts +13 -7
- package/templates/apps/mobile/src/components/atoms/TextInput/text-input-area.component.tsx +12 -13
- package/templates/apps/mobile/src/components/atoms/TextInput/text-input.component.tsx +42 -4
- package/templates/apps/mobile/src/components/atoms/index.ts +1 -0
- package/templates/apps/mobile/src/components/molecules/ScreenContainer/screen-container.component.tsx +3 -3
- package/templates/apps/mobile/src/hooks/useDebounce.hook.ts +1 -1
- package/templates/apps/mobile/src/hooks/useThrottle.hook.ts +1 -1
- package/templates/apps/mobile/src/icons/cross.svg +4 -0
- package/templates/apps/mobile/src/icons/index.ts +3 -1
- package/templates/apps/mobile/src/icons/keyboard-hide.svg +1 -0
- package/templates/apps/mobile/src/stores/mmkvStorage.ts +3 -3
- package/templates/apps/mobile/src/tailwind/index.ts +4 -4
- package/templates/apps/mobile/tsconfig.app.json +2 -2
- package/templates/clean-generated-outputs.sh +22 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import {
|
|
3
|
+
Pressable,
|
|
3
4
|
TextInput as RNTextInput,
|
|
4
5
|
TextInputProps as RNTextInputProps,
|
|
5
6
|
StyleProp,
|
|
@@ -7,20 +8,25 @@ import {
|
|
|
7
8
|
View,
|
|
8
9
|
} from 'react-native';
|
|
9
10
|
|
|
10
|
-
import { DefaultNameInputProps } from '
|
|
11
|
+
import { DefaultNameInputProps } from './constants';
|
|
12
|
+
|
|
11
13
|
import {
|
|
12
14
|
colors,
|
|
13
15
|
defaultInputContainerStyle,
|
|
14
16
|
defaultInputTextStyle,
|
|
15
17
|
disabledInputStyle,
|
|
16
18
|
focusedInputStyle,
|
|
19
|
+
tw,
|
|
17
20
|
} from '@/tailwind';
|
|
18
|
-
import { DefaultComponentProps } from '@/types';
|
|
21
|
+
import { DefaultComponentProps } from '@/types/component.type';
|
|
22
|
+
import { CrossIcon } from '@/icons';
|
|
19
23
|
|
|
20
24
|
export type TextInputProps = DefaultComponentProps &
|
|
21
25
|
RNTextInputProps & {
|
|
22
26
|
textInputRef?: React.RefObject<RNTextInput>;
|
|
23
27
|
textStyle?: StyleProp<TextStyle>;
|
|
28
|
+
showClearButton?: boolean;
|
|
29
|
+
onClearButtonPress?: () => void;
|
|
24
30
|
};
|
|
25
31
|
|
|
26
32
|
export function TextInput(props: TextInputProps) {
|
|
@@ -28,25 +34,47 @@ export function TextInput(props: TextInputProps) {
|
|
|
28
34
|
isDisabled = false,
|
|
29
35
|
multiline = false,
|
|
30
36
|
onChangeText,
|
|
37
|
+
onClearButtonPress,
|
|
31
38
|
placeholder,
|
|
39
|
+
showClearButton = true,
|
|
32
40
|
style,
|
|
33
41
|
textInputRef,
|
|
34
42
|
textStyle,
|
|
35
43
|
value,
|
|
36
44
|
...extraProps
|
|
37
45
|
} = props;
|
|
46
|
+
const [isClearButtonVisible, setIsClearButtonVisible] = useState<boolean>(false);
|
|
38
47
|
const [isFocused, setFocused] = useState<boolean>(false);
|
|
39
48
|
|
|
40
49
|
function handleOnChangeText(text: string) {
|
|
41
50
|
onChangeText?.(text);
|
|
51
|
+
|
|
52
|
+
if (showClearButton) {
|
|
53
|
+
setIsClearButtonVisible(text.length > 0);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function handleOnClearPress() {
|
|
58
|
+
handleOnChangeText?.('');
|
|
59
|
+
onClearButtonPress?.();
|
|
42
60
|
}
|
|
43
61
|
|
|
44
62
|
function handleOnFocus() {
|
|
45
63
|
setFocused(true);
|
|
64
|
+
|
|
65
|
+
const shouldShowClearButton = showClearButton && value?.length;
|
|
66
|
+
if (shouldShowClearButton) {
|
|
67
|
+
setIsClearButtonVisible(true);
|
|
68
|
+
}
|
|
46
69
|
}
|
|
47
70
|
|
|
48
71
|
function handleOnBlur() {
|
|
49
72
|
setFocused(false);
|
|
73
|
+
|
|
74
|
+
const shouldShowClearButton = showClearButton && value?.length;
|
|
75
|
+
if (shouldShowClearButton) {
|
|
76
|
+
setIsClearButtonVisible(false);
|
|
77
|
+
}
|
|
50
78
|
}
|
|
51
79
|
|
|
52
80
|
return (
|
|
@@ -64,8 +92,8 @@ export function TextInput(props: TextInputProps) {
|
|
|
64
92
|
editable={!isDisabled}
|
|
65
93
|
multiline={multiline}
|
|
66
94
|
placeholder={placeholder}
|
|
67
|
-
placeholderTextColor={colors.gray[
|
|
68
|
-
selectionColor={colors.primary
|
|
95
|
+
placeholderTextColor={colors.gray[500]}
|
|
96
|
+
selectionColor={colors.primary}
|
|
69
97
|
style={[defaultInputTextStyle, textStyle]}
|
|
70
98
|
value={value}
|
|
71
99
|
onBlur={handleOnBlur}
|
|
@@ -73,6 +101,16 @@ export function TextInput(props: TextInputProps) {
|
|
|
73
101
|
onFocus={handleOnFocus}
|
|
74
102
|
{...extraProps}
|
|
75
103
|
/>
|
|
104
|
+
{isClearButtonVisible && (
|
|
105
|
+
<Pressable
|
|
106
|
+
hitSlop={30}
|
|
107
|
+
style={tw`items-center justify-center`}
|
|
108
|
+
testID="clear-button"
|
|
109
|
+
onPress={handleOnClearPress}
|
|
110
|
+
>
|
|
111
|
+
<CrossIcon style={tw`text-gray-400`} />
|
|
112
|
+
</Pressable>
|
|
113
|
+
)}
|
|
76
114
|
</View>
|
|
77
115
|
);
|
|
78
116
|
}
|
|
@@ -3,6 +3,7 @@ export * from './Button';
|
|
|
3
3
|
export * from './Divider';
|
|
4
4
|
export * from './ExcludedEdges';
|
|
5
5
|
export * from './InputLayout';
|
|
6
|
+
export * from './KeyboardAccessory';
|
|
6
7
|
export * from './KeyboardAwareScrollView';
|
|
7
8
|
export * from './ListLoadingItem';
|
|
8
9
|
export * from './Modal';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useFocusEffect } from '@react-navigation/
|
|
1
|
+
import { useFocusEffect } from '@react-navigation/native';
|
|
2
2
|
import React, { ReactElement } from 'react';
|
|
3
3
|
import {
|
|
4
4
|
NativeScrollEvent,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
View,
|
|
12
12
|
ViewStyle,
|
|
13
13
|
} from 'react-native';
|
|
14
|
-
import {
|
|
14
|
+
import { ScrollView as RNScrollView } from 'react-native-gesture-handler';
|
|
15
15
|
import { Edge, SafeAreaProviderProps, SafeAreaView } from 'react-native-safe-area-context';
|
|
16
16
|
|
|
17
17
|
import { KeyboardAwareScrollView } from '@/components';
|
|
@@ -20,7 +20,7 @@ import { tw } from '@/tailwind';
|
|
|
20
20
|
|
|
21
21
|
type Props = SafeAreaProviderProps & {
|
|
22
22
|
barStyle?: StatusBarStyle;
|
|
23
|
-
scrollViewRef?: React.RefObject<
|
|
23
|
+
scrollViewRef?: React.RefObject<RNScrollView | null>;
|
|
24
24
|
containerStyle?: StyleProp<ViewStyle>;
|
|
25
25
|
excludedEdges?: Edge[];
|
|
26
26
|
extraBottomPadding?: number;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.5 0.875C3.84231 0.875 0.875 3.84231 0.875 7.5C0.875 11.1577 3.84231 14.125 7.5 14.125C11.1577 14.125 14.125 11.1577 14.125 7.5C14.125 3.84231 11.1577 0.875 7.5 0.875ZM5.85355 5.14645C5.65829 4.95118 5.34171 4.95118 5.14645 5.14645C4.95118 5.34171 4.95118 5.65829 5.14645 5.85355L6.79289 7.5L5.14645 9.14645C4.95118 9.34171 4.95118 9.65829 5.14645 9.85355C5.34171 10.0488 5.65829 10.0488 5.85355 9.85355L7.5 8.20711L9.14645 9.85355C9.34171 10.0488 9.65829 10.0488 9.85355 9.85355C10.0488 9.65829 10.0488 9.34171 9.85355 9.14645L8.20711 7.5L9.85355 5.85355C10.0488 5.65829 10.0488 5.34171 9.85355 5.14645C9.65829 4.95118 9.34171 4.95118 9.14645 5.14645L7.5 6.79289L5.85355 5.14645Z" fill="currentColor"/>
|
|
4
|
+
</svg>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import ArrowLeftIcon from './arrow-left.svg';
|
|
2
|
+
import CrossIcon from './cross.svg';
|
|
2
3
|
import GearIcon from './gear.svg';
|
|
4
|
+
import KeyboardHideIcon from './keyboard-hide.svg';
|
|
3
5
|
|
|
4
|
-
export { ArrowLeftIcon, GearIcon };
|
|
6
|
+
export { ArrowLeftIcon, CrossIcon, GearIcon, KeyboardHideIcon };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960"><path d="M480-40 320-200h320zM160-280q-33 0-56.5-23.5T80-360v-400q0-33 23.5-56.5T160-840h640q33 0 56.5 23.5T880-760v400q0 33-23.5 56.5T800-280zm0-80h640v-400H160zm160-40h320v-80H320zM200-520h80v-80h-80zm120 0h80v-80h-80zm120 0h80v-80h-80zm120 0h80v-80h-80zm120 0h80v-80h-80zM200-640h80v-80h-80zm120 0h80v-80h-80zm120 0h80v-80h-80zm120 0h80v-80h-80zm120 0h80v-80h-80zM160-360v-400z" fill="currentColor"/></svg>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createMMKV } from 'react-native-mmkv';
|
|
2
2
|
import { StateStorage } from 'zustand/middleware';
|
|
3
3
|
|
|
4
4
|
import CONFIG from '@/config';
|
|
5
5
|
|
|
6
|
-
const storage =
|
|
6
|
+
const storage = createMMKV({
|
|
7
7
|
encryptionKey: CONFIG.STORAGE_KEY,
|
|
8
8
|
id: 'mmkv',
|
|
9
9
|
});
|
|
@@ -14,6 +14,6 @@ export const MmkvStorage: StateStorage = {
|
|
|
14
14
|
|
|
15
15
|
return value ?? null;
|
|
16
16
|
},
|
|
17
|
-
removeItem: (name) => storage.
|
|
17
|
+
removeItem: (name) => storage.remove(name),
|
|
18
18
|
setItem: (name, value) => storage.set(name, value),
|
|
19
19
|
};
|
|
@@ -58,14 +58,14 @@ export const tw = create({
|
|
|
58
58
|
|
|
59
59
|
export const errorContainerStyle = (err: boolean) => err && tw`border-red-600`;
|
|
60
60
|
|
|
61
|
-
export const disabledInputStyle = (isDisabled: boolean) => isDisabled && tw`opacity-
|
|
61
|
+
export const disabledInputStyle = (isDisabled: boolean) => isDisabled && tw`opacity-50`;
|
|
62
62
|
|
|
63
|
-
export const focusedInputStyle = (isFocused: boolean) => isFocused && tw
|
|
63
|
+
export const focusedInputStyle = (isFocused: boolean) => isFocused && tw``;
|
|
64
64
|
|
|
65
65
|
export const errorTextStyle = (err: boolean) => err && tw`text-red-600`;
|
|
66
66
|
|
|
67
|
-
export const defaultInputContainerStyle = tw`rounded-xl border border-gray-900
|
|
68
|
-
export const defaultInputTextStyle = tw`
|
|
67
|
+
export const defaultInputContainerStyle = tw`flex-row rounded-xl border border-gray-900 p-3`;
|
|
68
|
+
export const defaultInputTextStyle = tw`flex-1 font-normal text-gray-950`;
|
|
69
69
|
|
|
70
70
|
export const colors = {
|
|
71
71
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"outDir": "../../dist/out-tsc",
|
|
5
5
|
"strict": true,
|
|
6
|
-
"types": ["node"],
|
|
6
|
+
"types": ["node", "jest"],
|
|
7
7
|
"baseUrl": ".",
|
|
8
8
|
"paths": {
|
|
9
9
|
"@/*": ["src/*"]
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"files": ["../../node_modules/@nx/react-native/typings/svg.d.ts"],
|
|
13
|
-
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.spec.tsx", "test-setup.ts"],
|
|
13
|
+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.spec.tsx", "**/testHelpers", "**/__mocks__", "**/__fixtures__", "**/node_modules", "**/Pods", "test-setup.ts"],
|
|
14
14
|
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/**/*.jsx"]
|
|
15
15
|
}
|
|
@@ -3,18 +3,31 @@
|
|
|
3
3
|
# Clean generated outputs
|
|
4
4
|
echo "Cleaning generated outputs..."
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
root_node_modules_path="node_modules"
|
|
8
7
|
app_rn_name="mobile"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
app_rn_android_gradle_path="apps/$app_rn_name/android/.gradle"
|
|
9
|
+
app_rn_android_build_path="apps/$app_rn_name/android/build"
|
|
10
|
+
app_rn_android_cxx_path="apps/$app_rn_name/android/app/.cxx"
|
|
11
|
+
app_rn_android_cxx_build_path="apps/$app_rn_name/android/app/build"
|
|
12
|
+
app_rn_node_modules_path="node_modules"
|
|
12
13
|
app_rn_ios_pods_path="apps/$app_rn_name/ios/Pods"
|
|
13
14
|
app_rn_ios_build_path="apps/$app_rn_name/ios/build"
|
|
14
15
|
|
|
16
|
+
echo "Deleting root $root_build_path..."
|
|
17
|
+
rm -rf "$root_build_path"
|
|
18
|
+
|
|
15
19
|
echo "Deleting root $root_node_modules_path..."
|
|
16
20
|
rm -rf "$root_node_modules_path"
|
|
17
21
|
|
|
22
|
+
echo "Deleting $app_rn_android_build_path..."
|
|
23
|
+
rm -rf "$app_rn_android_build_path"
|
|
24
|
+
|
|
25
|
+
echo "Deleting $app_rn_android_cxx_path..."
|
|
26
|
+
rm -rf "$app_rn_android_cxx_path"
|
|
27
|
+
|
|
28
|
+
echo "Deleting $app_rn_android_cxx_build_path..."
|
|
29
|
+
rm -rf "$app_rn_android_cxx_build_path"
|
|
30
|
+
|
|
18
31
|
echo "Deleting $app_rn_node_modules_path..."
|
|
19
32
|
rm -rf "$app_rn_node_modules_path"
|
|
20
33
|
|
|
@@ -27,6 +40,10 @@ rm -rf "$app_rn_ios_build_path"
|
|
|
27
40
|
echo "Deleting $app_rn_android_gradle_path..."
|
|
28
41
|
rm -rf "$app_rn_android_gradle_path"
|
|
29
42
|
|
|
43
|
+
echo "Installing dependencies..."
|
|
30
44
|
yarn install
|
|
31
45
|
|
|
32
|
-
echo "
|
|
46
|
+
echo "Installing pods..."
|
|
47
|
+
yarn run pod-install
|
|
48
|
+
|
|
49
|
+
echo "Done!"
|