@canutin/svelte-currency-input 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,11 +41,12 @@ const setUnformattedValue = (event) => {
41
41
  // Don't format if the user is typing a `currencyDecimal` point
42
42
  if (event.key === currencyDecimal)
43
43
  return;
44
- // Always convert _the opposite_ decimal key press to the `currencyDecimal` point
44
+ // Pressing `.` when the decimal point is `,` gets replaced with `,`
45
45
  if (isDecimalComma && event.key === '.')
46
- formattedValue = formattedValue.replace('.', currencyDecimal);
46
+ formattedValue = formattedValue.replace(/\.([^.]*)$/, currencyDecimal + '$1'); // Only replace the last occurence
47
+ // Pressing `,` when the decimal point is `.` gets replaced with `.`
47
48
  if (!isDecimalComma && event.key === ',')
48
- formattedValue = formattedValue.replace(',', currencyDecimal);
49
+ formattedValue = formattedValue.replace(/\,([^,]*)$/, currencyDecimal + '$1'); // Only replace the last occurence
49
50
  // Don't format if `formattedValue` is ['$', '-$', "-"]
50
51
  const ignoreSymbols = [currencySymbol, `-${currencySymbol}`, '-'];
51
52
  const strippedUnformattedValue = formattedValue.replace(' ', '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canutin/svelte-currency-input",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "exports": {
5
5
  "./package.json": "./package.json",
6
6
  ".": "./index.js",