Skip to content

Commit

Permalink
feat(props): country is now optional
Browse files Browse the repository at this point in the history
  • Loading branch information
recursive-beast committed Dec 22, 2020
1 parent 9b554e8 commit 28ba593
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/CountriesMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const menuData = getCountries()

export interface CountriesMenuProps {
/** The selected country. */
selectedCountry: CountryCode,
selectedCountry?: CountryCode,
/** A map of names to be displayed in the menu for each country code. */
countryDisplayNames?: Record<CountryCode, string>,
/** Callback fired when an item from the menu is clicked. */
Expand Down
4 changes: 2 additions & 2 deletions src/Flag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import "./sprite.css";

interface FlagProps extends React.HTMLAttributes<HTMLDivElement> {
/** The country corresponding to the displayed flag. */
countryCode: CountryCode
countryCode?: CountryCode
}

export default function Flag({ className, countryCode, ...props }: FlagProps) {
return <div
{...props}
className={[
"flag",
`flag-${countryCode}`,
countryCode && `flag-${countryCode}`,
className,
].filter(Boolean).join(" ")} />;
}
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type PhoneTextFieldProps = Omit<TextFieldProps, "onChange"> & {
/** A map of names to be displayed in the menu for each country code. */
countryDisplayNames?: CountriesMenuProps["countryDisplayNames"],
/** The currently selected country. */
country: CountryCode,
country?: CountryCode,
/** Callback fired when a country is selected from the menu. */
onCountrySelect?: (data: OnCountrySelectData) => void,
/** Callback fired when the input value changes. */
Expand All @@ -53,7 +53,7 @@ class PhoneTextField extends Component<PhoneTextFieldProps> {
// its corresponding propType should be specified.
static propTypes = {
countryDisplayNames: PropTypes.shape(countryDisplayNamesShape),
country: PropTypes.oneOf(countryCodes).isRequired,
country: PropTypes.oneOf(countryCodes),
onCountrySelect: PropTypes.func,
onChange: PropTypes.func,
InputProps: PropTypes.object,
Expand Down

0 comments on commit 28ba593

Please sign in to comment.