@canutin/svelte-currency-input 0.9.1 → 0.9.3

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.
@@ -103,13 +103,13 @@ const setFormattedValue = () => {
103
103
  formattedValue = isZero ? '' : formatCurrency(value, fractionDigits, 0);
104
104
  // Update `value` after formatting
105
105
  setUnformattedValue();
106
- // New caret position
107
- const endCaretPosition = startCaretPosition + formattedValue.length - previousFormattedValueLength;
108
- // HACK:
109
- // Delay setting the new caret position until the input has been formatted
110
- setTimeout(() => {
106
+ let retries = 0;
107
+ while (previousFormattedValueLength === formattedValue.length && retries < 10)
108
+ retries++;
109
+ if (previousFormattedValueLength !== formattedValue.length) {
110
+ const endCaretPosition = startCaretPosition + formattedValue.length - previousFormattedValueLength;
111
111
  inputTarget?.setSelectionRange(endCaretPosition, endCaretPosition);
112
- }, 0.1);
112
+ }
113
113
  // Run callback function when `value` changes
114
114
  onValueChange(value);
115
115
  };
package/README.md CHANGED
@@ -20,7 +20,7 @@ A form input that converts numbers to localized currency formats as you type
20
20
  ## Usage
21
21
 
22
22
  ```bash
23
- npm install svelte-currency-input --save
23
+ npm install @canutin/svelte-currency-input --save
24
24
  ```
25
25
 
26
26
  ```html
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canutin/svelte-currency-input",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "exports": {
5
5
  "./package.json": "./package.json",
6
6
  ".": "./index.js",
@@ -39,13 +39,13 @@
39
39
  ],
40
40
  "repository": {
41
41
  "type": "git",
42
- "url": "git+https://github.com/canutin/svelte-currency-input.git"
42
+ "url": "git+https://github.com/fmaclen/svelte-currency-input.git"
43
43
  },
44
44
  "author": "Fernando Maclen <hello@fernando.is>",
45
45
  "license": "MIT",
46
46
  "bugs": {
47
- "url": "https://github.com/canutin/svelte-currency-input/issues"
47
+ "url": "https://github.com/fmaclen/svelte-currency-input/issues"
48
48
  },
49
- "homepage": "https://github.com/canutin/svelte-currency-input#readme",
49
+ "homepage": "https://github.com/fmaclen/svelte-currency-input#readme",
50
50
  "svelte": "./index.js"
51
51
  }