Repository navigation
feat: input masks, validators and formatters on Text and Numeric column editors (#376) - #512
Open
michaelstonis wants to merge 2 commits into
Open
michaelstonis wants to merge 2 commits into
michaelstonis wants to merge 2 commits into
Conversation
Comment on lines
+192
to
+195
| foreach (char c in inserted) | ||
| { | ||
| if (PlaceMasked(sb, ref next, c)) placed++; | ||
| } |
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #376.
Changes
Text and Numeric column editors can now take an input mask, a maximum length, an input validator and an output formatter from the column, in XAML and in code.
KumikoColumn:EditorMask,EditorMaskIncludesLiterals,EditorMaskPromptChar(a one-character string so XAML can set it on both hosts, Uno included; default"_"),EditorMaxLength,EditorInputValidator,EditorOutputFormatter.CellEditorFactorycopies them to theDrawnTextBoxofCreateTextEditorandCreateNumericEditor(Numeric keepsNumericOnly, applied before the mask).DrawnTextBox(new partial fileDrawnTextBox.Mask.cs): the mask language is#digit,Aletter,*any,\escape, other characters literal. Literals are inserted automatically when typing, pasting and committing a composition (all go throughTryReplaceSelection), characters that do not fit are dropped, and an edit that would push a character out of the mask is refused. Backspace and Delete skip literals and delete the neighboring input character. The unfilled positions are drawn with the prompt character in the placeholder color while editing (cached string, no per-frame allocation). The old reject-onlyValidateAgainstMaskis gone; the validator now sees the masked candidate text.IValueEditor.Valueis the typed characters without the literals, unlessInputMaskIncludesLiterals.EditSession.CommitEditrefuses a non-empty masked value with unfilled positions with the newKumikoStrings.EnterCompleteValue("Enter a complete value."), before conversion; one early check, no other change to the commit path, so it composes with the column validator and item validation steps after it. An emptied editor clears the cell.DrawnTextBox.PrefersNumericKeyboard(NumericOnly, or a mask whose input positions are all digits) is read by the MAUI Apple bridge, the Windows input scope and the Android mapper (which replaces its ownIsDigitMaskhelper). The Uno proxyTextBoxsets no input scope for numeric editors today, so there is nothing to match there.TextEditorDescriptor:MaskandMaxLength.Public API added (all in
PublicAPI.Unshipped.txtof Core; MAUI and Uno have no new public API):KumikoColumn.EditorMask,EditorMaskIncludesLiterals,EditorMaskPromptChar,EditorMaxLength,EditorInputValidator,EditorOutputFormatter;TextEditorDescriptor.Mask,MaxLength;DrawnTextBox.MaskPromptChar,InputMaskIncludesLiterals,MaskValue,IsMaskComplete,ApplyInputMask(string?),PrefersNumericKeyboard;KumikoStrings.EnterCompleteValue.Acceptance criteria
EditorMask,EditorMaxLength,EditorInputValidatorandEditorOutputFormatterapply to Text and Numeric column editors, from XAML and code (the Func properties are code only, like the other delegate properties).EnterCompleteValue, added to the German localization test); literals are stripped or kept perEditorMaskIncludesLiterals.TextEditorDescriptorexposesMaskandMaxLength.tests/KumikoUI.Core.Tests/Components/DrawnTextBoxMaskTests.cs(a sibling ofDrawnTextBoxTests.cs) andtests/KumikoUI.Core.Tests/Editing/MaskedEditorTests.cs.PublicAPI.Unshipped.txtupdated (see Verification for how).DrawnNumericUpDownis unchanged (the Numeric column editor is aDrawnTextBox).Verification
dotnet build src/KumikoUI.Core: 0 warnings, 0 errors.dotnet build src/KumikoUI.Maui -f net10.0-maccatalyst: 0 warnings, 0 errors.dotnet build src/KumikoUI.Uno -f net10.0-desktop: 0 errors; the 2 Uno0001 warnings (IsTextPredictionEnabled,IsHoldingEnabled) are in files this change does not touch.dotnet build samples/SampleApp.Uno -f net10.0-desktop: 0 warnings, 0 errors.dotnet build samples/SampleApp.Maui -f net10.0-maccatalyst: restore fails with NU1605 (Microsoft.Maui.Controls 10.0.110 vs 10.0.41) before this change too; with-p:NoWarn=NU1605 -p:TreatWarningsAsErrors=false -p:WarningsAsErrors=it builds with 0 errors, so the new XAML compiles.dotnet test tests/KumikoUI.Core.Tests: 4404 passed, 5 skipped (existing skips), 0 failed (about 45 new tests).dotnet test tests/KumikoUI.Maui.Tests: 449 passed.dotnet test tests/KumikoUI.Uno.Tests: 321 passed.eng/update-public-api.sh Corecould not regenerate the file here (dotnet format analyzersmade no changes), so the 26 new lines were taken from the RS0016 diagnostics of a clean build and merged in sorted order; the build is clean afterwards.EditorMaskPromptChar="."compiles in Uno XAML (acharproperty cannot be set from Uno XAML: UXAML0001) and in MAUI XAML. Verified by using it in both sample apps and building them, and by the README snippet projects (tests/KumikoUI.Docs.Snippets.Mauiand.Uno, 0 errors). Core 4404 + 5 new theory cases passing.