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

[WIP] Add full-width numbers support for Time, Date, DateTime, DateRange #907

Closed

Conversation

rikusen0335
Copy link
Contributor

@rikusen0335 rikusen0335 commented Jan 16, 2024

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Refactoring
  • Build or CI related changes
  • Tests related changes
  • Documentation content changes

What is the current behaviour?

Closes #884

This PR implements full-width to half-width preprocessor into time, or datetime or almost similar masks.

Please see issue page for more detail

What is the new behaviour?

Above masks will have full-width to half-width preprocessor.

Implementation

  • Moved createFullWidthToHalfWidthPreprocessor from projects/kit/src/lib/masks/number/processors to projects/kit/src/lib/processors (also tests)
  • Added createFullWidthToHalfWidthPreprocessor to Time, Date, DateTime, DateRange masks
  • Added e2e tests for Time, Date, DateTime, DateRange masks WIP

@rikusen0335 rikusen0335 marked this pull request as draft January 16, 2024 01:07
@nsbarsukov nsbarsukov added the community contribution This issue was closed by a PR from the community label Jan 16, 2024
@rikusen0335
Copy link
Contributor Author

@nsbarsukov Idk who to mention, but I have a question. Have you tried IME/Do you have IME on your input method?

I am struggling with entering full-width numbers sometimes doesn't pass data, which is {elementState, data} used in processors.
I think This part does IME thing, but it doesn't work as I expected.

I can explain more in detail, but thinking about should I elaborate this to issue or slack something.

If you guys have time, please take a light look about this.

Thanks

@nsbarsukov
Copy link
Member

@rikusen0335

Have you tried IME/Do you have IME on your input method?

Yep, I've made some basic checks of IME to ensure that everything works fine.
But I am not sure that I've done everything right (I don't use IME in my everyday life – that's why I don't have enough knowledge about this question).

I will appreciate if you can help with it to make our library better)

You can write me in Telegram: https://t.me/nsbarsukov
Or we can use Twitter: https://twitter.com/nsbarsukov

@rikusen0335
Copy link
Contributor Author

I'm working on date (or also date related) processors to fix this:
Still stuggling with how processors works...

Screen.Recording.2024-01-26.at.17.19.22.mov

@nsbarsukov
Copy link
Member

@rikusen0335 Hello!

I've finally refactored code to improve support of IME composition for built-in Date / DateRange / DateTime.

Now it will work in the following way:

new-way.mov

Could you rebase your branch, please ?
I think we can finish your PR and finally merge it.

Comment on lines +14 to +15
['1', '1'],
['18', '18'],
Copy link
Member

Choose a reason for hiding this comment

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

Should we use full-width characters ?

Suggested change
['1', '1'],
['18', '18'],
['', '1'],
['18', '18'],

});
});

describe('Should reject when invalid cases', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
describe('Should reject when invalid cases', () => {
describe('pads digits with zero if date segment exceeds its max possible value', () => {

});

describe('Should reject when invalid cases', () => {
// NOTE: months doesn't have 29, so it should prevents entering invalid month
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// NOTE: months doesn't have 29, so it should prevents entering invalid month
// NOTE: months can be > 12 => pads the first 2 with zero

Comment on lines +34 to +36
.should('have.value', '2010/02')
.should('have.prop', 'selectionStart', '2010/02'.length)
.should('have.prop', 'selectionEnd', '2010/02'.length);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.should('have.value', '2010/02')
.should('have.prop', 'selectionStart', '2010/02'.length)
.should('have.prop', 'selectionEnd', '2010/02'.length);
.should('have.value', '2010/02/09')
.should('have.prop', 'selectionStart', '2010/02/09'.length)
.should('have.prop', 'selectionEnd', '2010/02/09'.length);

projects/kit/src/lib/masks/time/time-mask.ts Show resolved Hide resolved
@nsbarsukov
Copy link
Member

Enable this test, please

// TODO: https://github.com/taiga-family/maskito/pull/907
xit('accepts full width characters', () => {

(xit => it)

@rikusen0335
Copy link
Contributor Author

Will work on this for this weekend! Thank you for refactoring and sharing it! :))

@rikusen0335
Copy link
Contributor Author

rikusen0335 commented Feb 10, 2024

Due to complexity (and also I forgot where was I fixing at), I moved PR to #1043

@rikusen0335 rikusen0335 deleted the feat/884_full-width-support branch February 10, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community contribution This issue was closed by a PR from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 - Add full-width numbers support for Time, Date, DateTime, DateRange
2 participants