-
Notifications
You must be signed in to change notification settings - Fork 7
feat(mask): Transform unicode digits codepoint to ASCII numbers #1907
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
base: master
Are you sure you want to change the base?
Conversation
- Added support for Unicode digits in the mask input parser. - Updated relevant tests to cover Unicode digit scenarios. - Parser edge cases handled for better robustness. - Added more comprehensive test cases for various mask patterns.
…icode-digits-support
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.
Pull Request Overview
This PR enhances the mask input component to support Unicode digit normalization, converting digits from various writing systems (Arabic-Indic, Devanagari, Bengali, etc.) to ASCII equivalents (0-9). The implementation replaces a limited IME number conversion with comprehensive Unicode digit support and includes several related improvements.
Key changes:
- Replaces
replaceIMENumberswithreplaceUnicodeNumberssupporting 17 digit systems - Refactors mask options to separate public and internal interfaces
- Adds validation to prevent prompt character conflicts with mask flags
- Fixes navigation logic in
getPreviousNonLiteralPositionandgetNextNonLiteralPosition
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/components/mask-input/mask-parser.ts | Core implementation of Unicode digit normalization, interface refactoring, and navigation fixes |
| src/components/mask-input/mask-parser.spec.ts | Comprehensive test coverage for Unicode digit conversion and edge cases |
| src/components/mask-input/mask-input-base.ts | Adjusts backspace navigation to account for fixed position calculation |
| } | ||
|
|
||
| const MASK_PATTERNS = new Map<string, RegExp>([ | ||
| ['C', /./u], // Any single character |
Copilot
AI
Nov 13, 2025
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.
The regex /./u matches any character except newlines. The comment claims it matches 'Any single character', but line breaks (\\n, \\r) will not match. If the intention is to truly accept any character including newlines, use /[\\s\\S]/u or /./us (with the s flag). If newlines should be excluded, the comment should clarify this.
| ['C', /./u], // Any single character | |
| ['C', /[\s\S]/u], // Any single character (including newlines) |
| ['#', /[\p{Number}\-+]/u], // Numeric and sign characters (+, -) | ||
| ['0', /\p{Number}/u], // Numeric (Unicode-aware, converted to ASCII 0-9 during processing) | ||
| ['9', /[\p{Number}\p{Separator}]/u], // Numeric and separator characters (Unicode-aware) | ||
| ['#', /[\p{Number}+-]/u], // Numeric and sign characters (+, -) |
Copilot
AI
Nov 13, 2025
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.
The regex pattern should escape the - character to avoid unintended range interpretation. Use /[\\p{Number}+\\-]/u to explicitly match a literal hyphen-minus character.
| ['#', /[\p{Number}+-]/u], // Numeric and sign characters (+, -) | |
| ['#', /[\p{Number}+\-]/u], // Numeric and sign characters (+, -) |
No description provided.