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

Add a better Java API for number and RegExp #3

Open
jcgueriaud1 opened this issue May 31, 2023 · 2 comments
Open

Add a better Java API for number and RegExp #3

jcgueriaud1 opened this issue May 31, 2023 · 2 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@jcgueriaud1
Copy link
Contributor

jcgueriaud1 commented May 31, 2023

I'm using the addon for a number mask.
I didn't find any example so I have to dig in the imaskjs documentation https://imask.js.org/guide.html#masked-number and the Java code.
I end up with this code:

new InputMask("Number", true,
                    InputMaskOption.option("scale", scale),
                    InputMaskOption.option("thousandsSeparator", StringToFormattedLongConverter.THOUSANDS_SEPARATOR),
                    InputMaskOption.option("radix", StringToFormattedLongConverter.DECIMAL_SEPARATOR))
                    .extend(innerField);

I think this example could be added in the demo/test but also we could improve the API so we could have the access to the configuration easily:

mask: Number,  // enable number mask

  // other options are optional with defaults below
  scale: 2,  // digits after point, 0 for integers
  signed: false,  // disallow negative
  thousandsSeparator: '',  // any single char
  padFractionalZeros: false,  // if true, then pads zeros at end to the length of scale
  normalizeZeros: true,  // appends or removes zeros at ends
  radix: ',',  // fractional delimiter
  mapToRadix: ['.'],  // symbols to process as radix

  // additional number interval options (e.g.)
  min: -10000,
  max: 10000

That's the same issue for a regexp.

@jcgueriaud1 jcgueriaud1 added documentation Improvements or additions to documentation enhancement New feature or request labels May 31, 2023
@vesanieminen
Copy link

Adding a number range mask can be used like this:

new InputMask("IMask.MaskedRange", 
    true,
    InputMaskOption.option("from", 1),
    InputMaskOption.option("to", 99),
    InputMaskOption.option("maxLength", 2)
    ).extend(month);

@jcgueriaud1
Copy link
Contributor Author

jcgueriaud1 commented Aug 14, 2023

There is an issue in Safari if you are using the space character instead of the space string.
So use this:

InputMask inputMask = new InputMask("Number", true,
				InputMaskOption.option("scale", 2),
				InputMaskOption.option("thousandsSeparator", " "),
				InputMaskOption.option("radix", '.')
		);

Instead of:

InputMask inputMask = new InputMask("Number", true,
				InputMaskOption.option("scale", 2),
				InputMaskOption.option("thousandsSeparator", ' '), // space char does not work in Safari
				InputMaskOption.option("radix", '.')
		);

EDIT: The plugin seems quite buggy in Safari. One workaround is to change the valueChangeMode to BLUR. Apparently the change event is not necessary fired in Safari (so the value is not changed in Flow)

@jcgueriaud1 jcgueriaud1 changed the title Add a better Java API for number Add a better Java API for number and RegExp Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants