-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add zip, ssn, and phone masks (#256)
* Add zip code mask; Rename doc page * Add zip code unmask option * Use regex for chunking * Add SSN mask * Add additional test; Rename currency field * Remove zip code unmask method * Document reasoning for not unmasking zip code * Add phone mask * Support unexpectedly long mask values * Support unmasking zip value * Refactor organization of class methods
- Loading branch information
Showing
8 changed files
with
349 additions
and
149 deletions.
There are no files selected for viewing
18 changes: 0 additions & 18 deletions
18
packages/core/src/components/TextField/CurrencyField.example.jsx
This file was deleted.
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
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,50 @@ | ||
import TextField, { unmaskValue } from './TextField'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
// import { unmaskValue } from '@cmsgov/design-system-core'; | ||
|
||
function handleBlur(evt, mask) { | ||
console.log('Unmasked value:', unmaskValue(evt.target.value, mask)); | ||
} | ||
|
||
const Example = () => { | ||
return ( | ||
<div> | ||
<TextField | ||
ariaLabel="Enter monthly income amount in dollars." | ||
label="Currency" | ||
mask="currency" | ||
name="currency_example" | ||
onBlur={evt => handleBlur(evt, 'currency')} | ||
value="2500" | ||
/> | ||
|
||
<TextField | ||
label="Phone number" | ||
mask="phone" | ||
name="phone_example" | ||
onBlur={evt => handleBlur(evt, 'phone')} | ||
type="tel" | ||
value="1234567890" | ||
/> | ||
|
||
<TextField | ||
label="Social security number (SSN)" | ||
mask="ssn" | ||
name="ssn_example" | ||
onBlur={evt => handleBlur(evt, 'ssn')} | ||
value="123456789" | ||
/> | ||
|
||
<TextField | ||
label="Zip code" | ||
mask="zip" | ||
name="zip_example" | ||
onBlur={evt => handleBlur(evt, 'zip')} | ||
value="123456789" | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
ReactDOM.render(<Example />, document.getElementById('js-example')); |
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
Oops, something went wrong.