-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Merge pull request #11152 from 18F/stages/rc-2024-08-27-revert"
- Loading branch information
Showing
42 changed files
with
605 additions
and
198 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
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
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 |
---|---|---|
@@ -1,49 +1,42 @@ | ||
import Cleave from 'cleave.js'; | ||
|
||
function formatSSNFieldAndLimitLength() { | ||
const inputs = document.querySelectorAll<HTMLInputElement>('input.ssn-toggle[type="password"]'); | ||
|
||
if (inputs) { | ||
inputs.forEach((input) => { | ||
const toggle = document.querySelector<HTMLInputElement>(`[aria-controls="${input.id}"]`)!; | ||
|
||
let cleave: Cleave | undefined; | ||
|
||
function sync() { | ||
const { value } = input; | ||
cleave?.destroy(); | ||
if (toggle.checked) { | ||
cleave = new Cleave(input, { | ||
numericOnly: true, | ||
blocks: [3, 2, 4], | ||
delimiter: '-', | ||
}); | ||
} else { | ||
const nextValue = value.replace(/-/g, ''); | ||
if (nextValue !== value) { | ||
input.value = nextValue; | ||
} | ||
} | ||
const didFormat = input.value !== value; | ||
if (didFormat) { | ||
input.checkValidity(); | ||
} | ||
const inputs = document.querySelectorAll<HTMLInputElement>('input.ssn-toggle[type="password"]'); | ||
inputs.forEach((input) => { | ||
const toggle = document.querySelector<HTMLInputElement>(`[aria-controls="${input.id}"]`)!; | ||
|
||
let cleave: Cleave | undefined; | ||
|
||
function sync() { | ||
const { value } = input; | ||
cleave?.destroy(); | ||
if (toggle.checked) { | ||
cleave = new Cleave(input, { | ||
numericOnly: true, | ||
blocks: [3, 2, 4], | ||
delimiter: '-', | ||
}); | ||
} else { | ||
const nextValue = value.replace(/-/g, ''); | ||
if (nextValue !== value) { | ||
input.value = nextValue; | ||
} | ||
} | ||
const didFormat = input.value !== value; | ||
if (didFormat) { | ||
input.checkValidity(); | ||
} | ||
} | ||
|
||
sync(); | ||
toggle.addEventListener('change', sync); | ||
|
||
function limitLength(this: HTMLInputElement) { | ||
const maxLength = 9 + (this.value.match(/-/g) || []).length; | ||
if (this.value.length > maxLength) { | ||
this.value = this.value.slice(0, maxLength); | ||
this.checkValidity(); | ||
} | ||
} | ||
sync(); | ||
toggle.addEventListener('change', sync); | ||
|
||
input.addEventListener('input', limitLength.bind(input)); | ||
}); | ||
function limitLength(this: HTMLInputElement) { | ||
const maxLength = 9 + (this.value.match(/-/g) || []).length; | ||
if (this.value.length > maxLength) { | ||
this.value = this.value.slice(0, maxLength); | ||
this.checkValidity(); | ||
} | ||
} | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', formatSSNFieldAndLimitLength); | ||
input.addEventListener('input', limitLength.bind(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
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
Oops, something went wrong.