Skip to content

Commit

Permalink
add declaration files
Browse files Browse the repository at this point in the history
  • Loading branch information
sohantalukder committed Jan 7, 2025
1 parent dac426a commit 86d306c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 41 deletions.
4 changes: 2 additions & 2 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
import type {
ColorValue,
StyleProp,
TextInputProps,
TextStyle,
ViewStyle,
} from 'react-native';
import { CountryCode, EachCountry } from './lib/constants/types';
import type { CountryCode, EachCountry } from './lib/constants/constants.d';

/**
* Props for the RNPhoneInput component.
Expand Down
86 changes: 48 additions & 38 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@ import Picker from './lib/country-picker/Picker';
import assets from './lib/assets/assets';

Check failure on line 12 in src/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Cannot find module './lib/assets/assets' or its corresponding type declarations.
import styles from './styles';
import type { RNPhoneInputProps, RNPhoneInputRef } from './index.d';
import type { CountryCode, EachCountry } from './lib/constants/types';
import type { CountryCode, EachCountry } from './lib/constants/constants.d';

Check failure on line 15 in src/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Cannot find module './lib/constants/constants.d' or its corresponding type declarations.
import CountryPickerModal from './lib/country-picker/CountryPickerModal';

Check failure on line 16 in src/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Cannot find module './lib/country-picker/CountryPickerModal' or its corresponding type declarations.

declare global {
namespace NodeJS {
interface Global {
openCountryModal: () => void;
}
}
}
const RNPhoneInput = forwardRef<RNPhoneInputRef, RNPhoneInputProps>(
(
{
Expand All @@ -39,7 +47,7 @@ const RNPhoneInput = forwardRef<RNPhoneInputRef, RNPhoneInputProps>(
const scheme = useColorScheme();
const openBottomSheet = () => {
global.openCountryModal({

Check failure on line 49 in src/index.tsx

View workflow job for this annotation

GitHub Actions / lint

Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
component: Picker as any,
component: Picker as unknown as unknown as React.FC,
componentProps: { onSelect: onSelect },
});
};
Expand All @@ -65,48 +73,50 @@ const RNPhoneInput = forwardRef<RNPhoneInputRef, RNPhoneInputProps>(
onSelectCountryCode && onSelectCountryCode(item);
};
const handleChangeText = (text: string) => {
console.log(text, text.match(new RegExp(country.regex)));
setValue(text);
onChangeText && onChangeText(text);
};
return (
<View style={[styles.container, containerStyle]}>
<TouchableOpacity
activeOpacity={0.7}
onPress={openBottomSheet}
style={[styles.flexRow, iconContainerStyle]}
>
<Text style={styles.ft28}>{country.icon}</Text>
{downArrowIcon && (
<Image
source={{
uri:
scheme !== 'dark'
? assets.downArrowDarkIcon
: assets.downArrowDefaultIcon,
}}
resizeMode="contain"
height={10}
width={10}
<>
<View style={[styles.container, containerStyle]}>
<TouchableOpacity
activeOpacity={0.7}
onPress={openBottomSheet}
style={[styles.flexRow, iconContainerStyle]}
>
<Text style={styles.ft28}>{country.icon}</Text>
{downArrowIcon && (
<Image
source={{
uri:
scheme !== 'dark'
? assets.downArrowDarkIcon
: assets.downArrowDefaultIcon,
}}
resizeMode="contain"
height={10}
width={10}
/>
)}
</TouchableOpacity>
<View style={[styles.flexRow, styles.gap10]}>
<Text style={[styles.ft16, codeTextStyle]}>
+{country.callingCode}
</Text>
<TextInput
style={[styles.width75, styles.ft16, textInputStyle]}
placeholder={placeholder || 'Phone Number'}
numberOfLines={1}
defaultValue={value}
placeholderTextColor={placeholderColor}
onChangeText={handleChangeText}
inputMode="numeric"
{...inputProps}
/>
)}
</TouchableOpacity>
<View style={[styles.flexRow, styles.gap10]}>
<Text style={[styles.ft16, codeTextStyle]}>
+{country.callingCode}
</Text>
<TextInput
style={[styles.width75, styles.ft16, textInputStyle]}
placeholder={placeholder || 'Phone Number'}
numberOfLines={1}
defaultValue={value}
placeholderTextColor={placeholderColor}
onChangeText={handleChangeText}
inputMode="numeric"
{...inputProps}
/>
</View>
</View>
</View>
<CountryPickerModal />
</>
);
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/styles.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DimensionValue } from 'react-native';
import type { DimensionValue } from 'react-native';

type ContainerStyle = {
flexDirection: 'row';
Expand Down

0 comments on commit 86d306c

Please sign in to comment.