-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pc/modals: PhoneInput component with bundled flag icons (#2378)
- Loading branch information
1 parent
84838b4
commit 159b235
Showing
3 changed files
with
46 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Input, InputProps } from "@fidesui/react"; | ||
import dynamic from "next/dynamic"; | ||
// Importing the flag icons causes them to be bundled into the app instead of loaded from an outside | ||
// domain. See: https://gitlab.com/catamphetamine/react-phone-number-input#including-all-flags | ||
import FLAG_ICONS from "react-phone-number-input/flags"; | ||
import "react-phone-number-input/style.css"; | ||
|
||
const ReactPhoneNumberInput = dynamic( | ||
() => import("react-phone-number-input"), | ||
{ | ||
ssr: false, | ||
} | ||
); | ||
|
||
/** | ||
* Wraps the PhoneInput component from react-phone-number-input in a Chakra Input | ||
* with common default props. | ||
*/ | ||
export const PhoneInput = (props: InputProps) => ( | ||
<Input | ||
as={ReactPhoneNumberInput} | ||
flags={FLAG_ICONS} | ||
type="tel" | ||
focusBorderColor="primary.500" | ||
placeholder="000 000 0000" | ||
defaultCountry="US" | ||
{...props} | ||
/> | ||
); |