-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Pretend that inputMask is supported
inputMask is used under the hood by the postcode component. The formio builder implementation stops at the placeholder. Since these components are not actually used in the renderer/SDK and are only set up for preview purposes and it's *too much* work to get the masking hooked up, I've decided to let it be.
- Loading branch information
1 parent
fcc665a
commit 09ccef5
Showing
3 changed files
with
68 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
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,23 @@ | ||
/** | ||
* This is Formio.js 4.13.x's input mask behaviour. | ||
* | ||
* It is known to have accessibility issues because the value is set, causing some | ||
* screenreaders to read out the placeholders. For more information, see | ||
* https://giovanicamara.com/blog/accessible-input-masking/ | ||
* | ||
* This functionality only exists here to achieve feature parity with the native | ||
* form builder, for the actual SDK/formio renderer, a better solution needs to be | ||
* found. | ||
* | ||
* @deprecated Do not use this (anymore) for user-facing forms. | ||
* | ||
*/ | ||
// @ts-ignore there are no type definitions | ||
import {conformToMask} from '@formio/vanilla-text-mask'; | ||
import {Utils} from 'formiojs'; | ||
|
||
export const applyInputMask = (textValue: string, mask: string) => { | ||
const options = {placeholderChar: '_'}; | ||
const result = conformToMask(textValue, Utils.getInputMask(mask), options); | ||
return result.conformedValue; | ||
}; |