-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,433 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
name: TelInput | ||
menu: Components | ||
route: /components/tel-input | ||
--- | ||
|
||
import { PropsTable, Playground } from 'docz'; | ||
|
||
import TelInput from './'; | ||
|
||
# TelInput | ||
|
||
Entering and validating international telephone numbers. | ||
|
||
## When To Use | ||
|
||
- you want to format and validating the user's phone numbers. | ||
|
||
## Examples | ||
|
||
```js | ||
import { TelInput } from 'tailor-ui'; | ||
``` | ||
|
||
### Basic | ||
|
||
<Playground> | ||
<TelInput onChange={console.log} /> | ||
</Playground> | ||
|
||
## API | ||
|
||
<PropsTable of={TelInput} /> | ||
|
||
The component is based on `react-intl-tel-input`, please check more API on it's [document](https://patw0929.github.io/react-intl-tel-input/). |
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,40 @@ | ||
import IntlTelInput from 'react-intl-tel-input'; | ||
import React, { FunctionComponent, MouseEventHandler } from 'react'; | ||
|
||
import StyledTelInput from './style'; | ||
|
||
interface ITelInputProps { | ||
id?: string; | ||
name?: string; | ||
value?: string; | ||
defaultValue?: string; | ||
onChange?: ( | ||
isValid: boolean, | ||
value: string, | ||
phoneInfo: object, | ||
fullPhoneNumber: string | ||
) => void; | ||
onBlur?: MouseEventHandler; | ||
} | ||
|
||
const TelInput: FunctionComponent<ITelInputProps> = ({ | ||
id, | ||
name, | ||
onChange, | ||
onBlur, | ||
...props | ||
}) => ( | ||
<StyledTelInput> | ||
<IntlTelInput | ||
fieldId={id} | ||
fieldName={name} | ||
onPhoneNumberChange={onChange} | ||
onPhoneNumberBlur={onBlur} | ||
format | ||
preferredCountries={['tw']} | ||
{...props} | ||
/> | ||
</StyledTelInput> | ||
); | ||
|
||
export default TelInput; |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
export { default } from './TelInput'; |
Oops, something went wrong.