-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pickers] Infer mask from inputFormat
#5060
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6414283
remove fixed workaround
alexfauquette 3ea0cf7
allows to choose library to run tests
alexfauquette 859887a
test all default masks
alexfauquette 7e21abd
replace yargs to allow using karma
alexfauquette d751857
fix types
alexfauquette 236dc9b
Andrew feedback
alexfauquette 6b981c5
compute mask from inputFormat
alexfauquette bf60918
remove default mask
alexfauquette 32b0850
add demo to show the interest of the infered mask
alexfauquette 71fdb65
update tests
alexfauquette 673b61f
remove warning in production
alexfauquette File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -26,18 +26,42 @@ describe('text-field-helper', () => { | |
}); | ||
|
||
[ | ||
{ mask: '__.__.____', format: adapterToUse.formats.keyboardDate, isValid: false }, | ||
{ mask: '__/__/____', format: adapterToUse.formats.keyboardDate, isValid: true }, | ||
{ mask: '__:__ _m', format: adapterToUse.formats.fullTime, isValid: false }, | ||
{ mask: '__/__/____ __:__ _m', format: adapterToUse.formats.keyboardDateTime, isValid: false }, | ||
{ mask: '__/__/____ __:__', format: adapterToUse.formats.keyboardDateTime24h, isValid: true }, | ||
{ mask: '__/__/____', format: 'MM/dd/yyyy', isValid: true }, | ||
{ mask: '__/__/____', format: 'MMMM yyyy', isValid: false }, | ||
// Time picker | ||
// - with ampm = true | ||
{ mask: '__:__ _m', format: adapterToUse.formats.fullTime12h, isValid: true }, | ||
// - with ampm=false | ||
{ mask: '__:__', format: adapterToUse.formats.fullTime24h, isValid: true }, | ||
// Date Picker | ||
{ | ||
mask: '__/__/____', | ||
format: adapterToUse.formats.keyboardDate, | ||
isValid: true, | ||
}, | ||
// - with year only | ||
{ | ||
mask: '____', | ||
format: adapterToUse.formats.year, | ||
isValid: true, | ||
}, | ||
// DateTimePicker | ||
// - with ampm=true | ||
{ | ||
mask: '__/__/____ __:__ _m', | ||
format: adapterToUse.formats.keyboardDateTime12h, | ||
isValid: true, | ||
}, | ||
// - with ampm=false | ||
{ | ||
mask: '__/__/____ __:__', | ||
format: adapterToUse.formats.keyboardDateTime24h, | ||
isValid: true, | ||
}, | ||
// Test rejections | ||
{ mask: '__.__.____', format: adapterToUse.formats.keyboardDate, isValid: false }, | ||
{ mask: '__:__ _m', format: adapterToUse.formats.fullTime, isValid: false }, | ||
{ mask: '__/__/____ __:__ _m', format: adapterToUse.formats.keyboardDateTime, isValid: false }, | ||
{ mask: '__/__/____', format: 'MM/dd/yyyy', isValid: adapterToUse.lib === 'date-fns' }, // only pass with date-fns | ||
{ mask: '__/__/____', format: 'MMMM yyyy', isValid: false }, | ||
].forEach(({ mask, format, isValid }, index) => { | ||
it(`checkMaskIsValidFormat returns ${isValid} for mask #${index} '${mask}' and format ${format}`, () => { | ||
const runMaskValidation = () => | ||
|
@@ -46,12 +70,7 @@ describe('text-field-helper', () => { | |
if (isValid) { | ||
expect(runMaskValidation()).to.be.equal(true); | ||
} else { | ||
expect(runMaskValidation).toWarnDev( | ||
[ | ||
`The mask "${mask}" you passed is not valid for the format used ${format}.`, | ||
`Falling down to uncontrolled no-mask input.`, | ||
].join('\n'), | ||
); | ||
Comment on lines
-49
to
-54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the |
||
expect(runMaskValidation).toWarnDev('Falling down to uncontrolled no-mask 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since default mask is inferred, this can be done