Skip to content
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

feat: masks #4332

Merged
merged 8 commits into from
Jul 1, 2024
Merged

feat: masks #4332

merged 8 commits into from
Jul 1, 2024

Conversation

m0ksem
Copy link
Collaborator

@m0ksem m0ksem commented Jun 25, 2024

This PR originally created to replace cleavejs.
We can have it in beta state before 1.10.0

image

@m0ksem m0ksem self-assigned this Jun 25, 2024
@@ -0,0 +1,228 @@
interface TokenBase {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parser is actually good. The only problem here is in tree: Token[] type. I should've been use TokenBase[] here, because Token is declared after tree: Token[].

This also might be optimized if we parse normalized at the beginning. But it is too complex to understand.


type PossibleResult = RegexToken[]

export const normalizeTokens = (tokens: Token[], dynamic = false) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normalization is okay... Can be improved for better readability.

return true
}

const formatByRegexTokens = (possibleResults: PossibleResult[], value: string, reverse = false) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is a mess and most likely at unoptimized.

const suggestedChar = possibleSuggestions[0]?.expect ?? ''
let canBeSuggested = possibleSuggestions.every((token) => token.expect === suggestedChar) && value[valueOffset]?.length > 0

const onlyStaticLeft = possibleResults.length === 1 && possibleResults[0].slice(tokensOffset).every((token) => token.static)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It must be refactored.

@m0ksem m0ksem mentioned this pull request Jul 1, 2024
@m0ksem m0ksem merged commit 2ded0a2 into epicmaxco:develop Jul 1, 2024
2 checks passed
@m0ksem m0ksem deleted the feat/masks branch July 1, 2024 15:10
m0ksem added a commit that referenced this pull request Jul 23, 2024
* raw

* feat(masks): remove junk

* feat(masks): add docs

* feat(masks): improve suggestion when option group

* feat(masks): add static tokens if only one possible solution is left

* docs(masks): improve phone extended demo

* feat(masks): correct suggestion when only one possible solution is left
m0ksem added a commit that referenced this pull request Aug 26, 2024
* raw

* feat(masks): remove junk

* feat(masks): add docs

* feat(masks): improve suggestion when option group

* feat(masks): add static tokens if only one possible solution is left

* docs(masks): improve phone extended demo

* feat(masks): correct suggestion when only one possible solution is left
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant