Open fredvisser opened 6 months ago
@fredvisser is this for number inputs or number rendering as text? Number input support is likely to be challenging.
Some of the challenges if we want to support formatting inputs:
.
for decimal separator and ,
for thousands separator, but some locales use the opposite or other characters like space. If the user types one of those characters, how do we interpret it? If we decide to allow inputting only in en-us, will it be weird to switch the format to a different locale after the user commits the value?Answer to point 1: The input format should be depending on the language set on the UI (Browser). YOu should save always in the same format independent to the display format.
Answer to point 2: If the field is configured with 2 digits after the comma. If you try to enter a third digit this digit should not be displayed in the input field and it shouldn't be saved.
Ran into the maskito library which looks potentially promising for building up some forms of formatted text input: https://maskito.dev/getting-started/what-is-maskito
😯 Problem to Solve
Clients like DFF require locale-specific, decimal number formatting in the
nimble-number-field
.💁 Proposed Solution
Adopt the decimal formatting options from the
nimble-table-column-number-text
component.format
property including thedefault
anddecimal
optionsdecimal-digits
anddecimal-maximum-digits
propertiesAdopt the automatically locale specific number formatting from thenimble-table-column-number-text
component.- E.g. Should render1,002.9
as1.002,9
for German locales.Support browser APIs for locale aware number inputs. E.g. German locales will enter and render numbers as
1002,9
.📋 Tasks