@canutin/svelte-currency-input 0.10.0 → 0.11.0

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.
package/README.md CHANGED
@@ -66,7 +66,8 @@ currency | `string` | `USD` | Overrides default currency.
66
66
  name | `string` | `total` | Applies the name to the [input fields](#how-it-works) for _unformatted_ (e.g `[name=total]`) and _formatted_ (e.g. `[name=formatted-total]`) values |
67
67
  required | `boolean` | `false` | Marks the inputs as required |
68
68
  disabled | `boolean` | `false` | Marks the inputs as disabled |
69
- placeholder | `number` `null` | `0` | Overrides the default placeholder. Setting the value to a `number` will display it as formatted. Setting it to `null` will not show a placeholder |
69
+ placeholder | `string` `number` `null` | `0` | A `string` will override the default placeholder. A `number` will override it by formatting it to the set currency. Setting it to `null` will not show a placeholder |
70
+ isZeroNullish | `boolean` | `false` | If `true` and when the value is `0`, it will override the default placeholder and render the formatted value in the field like any other value. _Note: this option might become the default in future versions_ |
70
71
  autocomplete | `string` | `undefined` | Sets the autocomplete attribute. Accepts any valid HTML [autocomplete attribute values](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#values) |
71
72
  isNegativeAllowed | `boolean` | `true` | If `false`, forces formatting only to positive values and ignores `--positive` and `--negative` styling modifiers |
72
73
  fractionDigits | `number` | `2` | Sets `maximumFractionDigits` in [`Intl.NumberFormat()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#minimumfractiondigits) used for formatting the currency. Supported digits: `0` to `20` |
@@ -0,0 +1,172 @@
1
+ <script>import { onMount } from "svelte";
2
+ const DEFAULT_LOCALE = "en-US";
3
+ const DEFAULT_CURRENCY = "USD";
4
+ const DEFAULT_NAME = "total";
5
+ const DEFAULT_VALUE = 0;
6
+ const DEFAULT_FRACTION_DIGITS = 2;
7
+ const DEFAULT_CLASS_WRAPPER = "currencyInput";
8
+ const DEFAULT_CLASS_UNFORMATTED = "currencyInput__unformatted";
9
+ const DEFAULT_CLASS_FORMATTED = "currencyInput__formatted";
10
+ const DEFAULT_CLASS_FORMATTED_POSITIVE = "currencyInput__formatted--positive";
11
+ const DEFAULT_CLASS_FORMATTED_NEGATIVE = "currencyInput__formatted--negative";
12
+ const DEFAULT_CLASS_FORMATTED_ZERO = "currencyInput__formatted--zero";
13
+ export let value = DEFAULT_VALUE;
14
+ export let locale = DEFAULT_LOCALE;
15
+ export let currency = DEFAULT_CURRENCY;
16
+ export let name = DEFAULT_NAME;
17
+ export let required = false;
18
+ export let disabled = false;
19
+ export let placeholder = DEFAULT_VALUE;
20
+ export let autocomplete = void 0;
21
+ export let isNegativeAllowed = true;
22
+ export let isZeroNullish = false;
23
+ export let fractionDigits = DEFAULT_FRACTION_DIGITS;
24
+ export let inputClasses = null;
25
+ export let onValueChange = () => {
26
+ };
27
+ const formatCurrency = (value2, maximumFractionDigits, minimumFractionDigits) => {
28
+ return new Intl.NumberFormat(locale, {
29
+ currency,
30
+ style: "currency",
31
+ maximumFractionDigits: maximumFractionDigits || 0,
32
+ minimumFractionDigits: minimumFractionDigits || 0
33
+ }).format(value2);
34
+ };
35
+ const handleKeyDown = (event) => {
36
+ const isDeletion = event.key === "Backspace" || event.key === "Delete";
37
+ const isModifier = event.metaKey || event.altKey || event.ctrlKey;
38
+ const isArrowKey = event.key === "ArrowLeft" || event.key === "ArrowRight";
39
+ const isTab = event.key === "Tab";
40
+ const isInvalidCharacter = !/^\d|,|\.|-$/g.test(event.key);
41
+ if (!isDeletion && !isModifier && !isArrowKey && isInvalidCharacter && !isTab)
42
+ event.preventDefault();
43
+ };
44
+ const handleOnBlur = () => setFormattedValue(true);
45
+ onMount(() => setFormattedValue(true));
46
+ let inputTarget;
47
+ const currencyDecimal = new Intl.NumberFormat(locale).format(1.1).charAt(1);
48
+ const isDecimalComma = currencyDecimal === ",";
49
+ const currencySymbol = formatCurrency(0, 0).replace("0", "").replace(/\u00A0/, "");
50
+ const setUnformattedValue = (event) => {
51
+ if (event) {
52
+ if (event.key === currencyDecimal)
53
+ return;
54
+ if (isDecimalComma && event.key === ".")
55
+ formattedValue = formattedValue.replace(/\.([^.]*)$/, currencyDecimal + "$1");
56
+ if (!isDecimalComma && event.key === ",")
57
+ formattedValue = formattedValue.replace(/\,([^,]*)$/, currencyDecimal + "$1");
58
+ const ignoreSymbols = [currencySymbol, `-${currencySymbol}`, "-"];
59
+ const strippedUnformattedValue = formattedValue.replace(" ", "");
60
+ if (ignoreSymbols.includes(strippedUnformattedValue))
61
+ return;
62
+ inputTarget = event.target;
63
+ if (isNegativeAllowed && event.key === "-")
64
+ value = value * -1;
65
+ }
66
+ let unformattedValue = isNegativeAllowed ? formattedValue.replace(/[^0-9,.-]/g, "") : formattedValue.replace(/[^0-9,.]/g, "");
67
+ if (Number.isNaN(parseFloat(unformattedValue))) {
68
+ value = 0;
69
+ } else {
70
+ unformattedValue = unformattedValue.replace(isDecimalComma ? /\./g : /\,/g, "");
71
+ if (isDecimalComma)
72
+ unformattedValue = unformattedValue.replace(",", ".");
73
+ const previousValue = value;
74
+ value = parseFloat(unformattedValue);
75
+ if (event && previousValue === value) {
76
+ if (unformattedValue.includes(".") && unformattedValue.split(".")[1].length > fractionDigits) {
77
+ setFormattedValue();
78
+ }
79
+ }
80
+ }
81
+ };
82
+ const setFormattedValue = (hasMinFractionDigits) => {
83
+ const startCaretPosition = inputTarget?.selectionStart || 0;
84
+ const previousFormattedValueLength = formattedValue.length;
85
+ formattedValue = isZero && !isZeroNullish ? "" : formatCurrency(value, fractionDigits, hasMinFractionDigits ? fractionDigits : 0);
86
+ setUnformattedValue();
87
+ let retries = 0;
88
+ while (previousFormattedValueLength === formattedValue.length && retries < 10)
89
+ retries++;
90
+ if (previousFormattedValueLength !== formattedValue.length) {
91
+ const endCaretPosition = startCaretPosition + formattedValue.length - previousFormattedValueLength;
92
+ inputTarget?.setSelectionRange(endCaretPosition, endCaretPosition);
93
+ }
94
+ onValueChange(value);
95
+ };
96
+ const handlePlaceholder = (placeholder2) => {
97
+ if (typeof placeholder2 === "number")
98
+ return formatCurrency(placeholder2, fractionDigits, fractionDigits);
99
+ if (placeholder2 === null)
100
+ return "";
101
+ return placeholder2;
102
+ };
103
+ let formattedValue = "";
104
+ $:
105
+ isNegative = value < 0;
106
+ $:
107
+ isPositive = value > 0;
108
+ $:
109
+ isZero = !isNegative && !isPositive;
110
+ $:
111
+ value, setFormattedValue();
112
+ </script>
113
+
114
+ <div class={inputClasses?.wrapper ?? DEFAULT_CLASS_WRAPPER}>
115
+ <input
116
+ class={inputClasses?.unformatted ?? DEFAULT_CLASS_UNFORMATTED}
117
+ type="hidden"
118
+ {name}
119
+ {disabled}
120
+ bind:value
121
+ />
122
+ <input
123
+ class="
124
+ {inputClasses?.formatted ?? DEFAULT_CLASS_FORMATTED}
125
+ {isNegativeAllowed && !isZero && !isNegative
126
+ ? inputClasses?.formattedPositive ?? DEFAULT_CLASS_FORMATTED_POSITIVE
127
+ : ''}
128
+ {isZero ? inputClasses?.formattedZero ?? DEFAULT_CLASS_FORMATTED_ZERO : ''}
129
+ {isNegativeAllowed && isNegative
130
+ ? inputClasses?.formattedNegative ?? DEFAULT_CLASS_FORMATTED_NEGATIVE
131
+ : ''}
132
+ "
133
+ type="text"
134
+ inputmode="numeric"
135
+ name={`formatted-${name}`}
136
+ required={required && !isZero}
137
+ placeholder={handlePlaceholder(placeholder)}
138
+ {autocomplete}
139
+ {disabled}
140
+ bind:value={formattedValue}
141
+ on:keydown={handleKeyDown}
142
+ on:keyup={setUnformattedValue}
143
+ on:blur={handleOnBlur}
144
+ />
145
+ </div>
146
+
147
+ <style>
148
+ input.currencyInput__formatted {
149
+ border: 1px solid #e2e2e2;
150
+ padding: 10px;
151
+ box-sizing: border-box;
152
+ }
153
+
154
+ input.currencyInput__formatted--zero {
155
+ color: #333;
156
+ }
157
+
158
+ input.currencyInput__formatted--positive {
159
+ color: #00a36f;
160
+ }
161
+
162
+ input.currencyInput__formatted--negative {
163
+ color: #e75258;
164
+ }
165
+
166
+ input.currencyInput__formatted:disabled {
167
+ color: #999;
168
+ background-color: #e2e2e2;
169
+ pointer-events: none;
170
+ cursor: default;
171
+ }
172
+ </style>
@@ -1,4 +1,4 @@
1
- import { SvelteComponentTyped } from "svelte";
1
+ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  value?: number | undefined;
@@ -7,9 +7,10 @@ declare const __propDef: {
7
7
  name?: string | undefined;
8
8
  required?: boolean | undefined;
9
9
  disabled?: boolean | undefined;
10
- placeholder?: number | null | undefined;
10
+ placeholder?: string | number | null | undefined;
11
11
  autocomplete?: string | null | undefined;
12
12
  isNegativeAllowed?: boolean | undefined;
13
+ isZeroNullish?: boolean | undefined;
13
14
  fractionDigits?: number | undefined;
14
15
  inputClasses?: {
15
16
  wrapper?: string | undefined;
@@ -26,9 +27,9 @@ declare const __propDef: {
26
27
  };
27
28
  slots: {};
28
29
  };
29
- export declare type CurrencyInputProps = typeof __propDef.props;
30
- export declare type CurrencyInputEvents = typeof __propDef.events;
31
- export declare type CurrencyInputSlots = typeof __propDef.slots;
32
- export default class CurrencyInput extends SvelteComponentTyped<CurrencyInputProps, CurrencyInputEvents, CurrencyInputSlots> {
30
+ export type CurrencyInputProps = typeof __propDef.props;
31
+ export type CurrencyInputEvents = typeof __propDef.events;
32
+ export type CurrencyInputSlots = typeof __propDef.slots;
33
+ export default class CurrencyInput extends SvelteComponent<CurrencyInputProps, CurrencyInputEvents, CurrencyInputSlots> {
33
34
  }
34
35
  export {};
package/package.json CHANGED
@@ -1,51 +1,73 @@
1
1
  {
2
- "name": "@canutin/svelte-currency-input",
3
- "version": "0.10.0",
4
- "exports": {
5
- "./package.json": "./package.json",
6
- ".": "./index.js",
7
- "./CurrencyInput.svelte": "./CurrencyInput.svelte"
8
- },
9
- "devDependencies": {
10
- "@playwright/test": "^1.37.1",
11
- "@sveltejs/adapter-auto": "next",
12
- "@sveltejs/kit": "next",
13
- "@sveltejs/package": "next",
14
- "@typescript-eslint/eslint-plugin": "^5.27.0",
15
- "@typescript-eslint/parser": "^5.27.0",
16
- "eslint": "^8.16.0",
17
- "eslint-config-prettier": "^8.3.0",
18
- "eslint-plugin-svelte3": "^4.0.0",
19
- "prettier": "^2.6.2",
20
- "prettier-plugin-svelte": "^2.7.0",
21
- "semantic-release": "^19.0.5",
22
- "svelte": "^3.44.0",
23
- "svelte-check": "^2.7.1",
24
- "svelte-preprocess": "^4.10.6",
25
- "tslib": "^2.3.1",
26
- "typescript": "^4.7.4",
27
- "vite": "^3.1.0"
28
- },
29
- "type": "module",
30
- "description": "A form input that converts numbers to currencies as you type in localized formats",
31
- "keywords": [
32
- "svelte",
33
- "currency",
34
- "money",
35
- "input",
36
- "i18n",
37
- "positive",
38
- "negative"
39
- ],
40
- "repository": {
41
- "type": "git",
42
- "url": "git+https://github.com/fmaclen/svelte-currency-input.git"
43
- },
44
- "author": "Fernando Maclen <hello@fernando.is>",
45
- "license": "MIT",
46
- "bugs": {
47
- "url": "https://github.com/fmaclen/svelte-currency-input/issues"
48
- },
49
- "homepage": "https://github.com/fmaclen/svelte-currency-input#readme",
50
- "svelte": "./index.js"
2
+ "name": "@canutin/svelte-currency-input",
3
+ "version": "0.11.0",
4
+ "scripts": {
5
+ "dev": "vite dev",
6
+ "build": "vite build",
7
+ "preview": "vite preview",
8
+ "package": "svelte-kit sync && svelte-package && publint",
9
+ "test": "playwright test",
10
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
11
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
12
+ "lint": "prettier --plugin-search-dir . --check . && eslint .",
13
+ "format": "prettier --plugin-search-dir . --write ."
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "svelte": "./dist/index.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "!dist/**/*.test.*",
24
+ "!dist/**/*.spec.*"
25
+ ],
26
+ "peerDependencies": {
27
+ "svelte": "^4.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "@playwright/test": "^1.39.0",
31
+ "@sveltejs/adapter-auto": "^2.0.0",
32
+ "@sveltejs/adapter-cloudflare": "^2.3.3",
33
+ "@sveltejs/kit": "^1.26.0",
34
+ "@sveltejs/package": "^2.2.2",
35
+ "@types/node": "^20.8.7",
36
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
37
+ "@typescript-eslint/parser": "^6.0.0",
38
+ "date-fns": "^2.30.0",
39
+ "eslint": "^8.28.0",
40
+ "eslint-config-prettier": "^8.5.0",
41
+ "eslint-plugin-svelte": "^2.30.0",
42
+ "prettier": "^2.8.0",
43
+ "prettier-plugin-svelte": "^2.10.1",
44
+ "publint": "^0.2.5",
45
+ "sass": "^1.69.0",
46
+ "semantic-release": "^19.0.5",
47
+ "svelte-check": "^3.4.3",
48
+ "tslib": "^2.4.1",
49
+ "typescript": "^5.0.0",
50
+ "vite": "^4.4.2"
51
+ },
52
+ "type": "module",
53
+ "description": "A form input that converts numbers to currencies as you type in localized formats",
54
+ "keywords": [
55
+ "svelte",
56
+ "currency",
57
+ "money",
58
+ "input",
59
+ "i18n",
60
+ "positive",
61
+ "negative"
62
+ ],
63
+ "repository": {
64
+ "type": "git",
65
+ "url": "git+https://github.com/fmaclen/svelte-currency-input.git"
66
+ },
67
+ "author": "Fernando Maclen <hello@fernando.is>",
68
+ "license": "MIT",
69
+ "bugs": {
70
+ "url": "https://github.com/fmaclen/svelte-currency-input/issues"
71
+ },
72
+ "homepage": "https://svelte-currency-input.fernando.is"
51
73
  }
@@ -1,182 +0,0 @@
1
- <script>const DEFAULT_LOCALE = 'en-US';
2
- const DEFAULT_CURRENCY = 'USD';
3
- const DEFAULT_NAME = 'total';
4
- const DEFAULT_VALUE = 0;
5
- const DEFAULT_FRACTION_DIGITS = 2;
6
- const DEFAULT_CLASS_WRAPPER = 'currencyInput';
7
- const DEFAULT_CLASS_UNFORMATTED = 'currencyInput__unformatted';
8
- const DEFAULT_CLASS_FORMATTED = 'currencyInput__formatted';
9
- const DEFAULT_CLASS_FORMATTED_POSITIVE = 'currencyInput__formatted--positive';
10
- const DEFAULT_CLASS_FORMATTED_NEGATIVE = 'currencyInput__formatted--negative';
11
- const DEFAULT_CLASS_FORMATTED_ZERO = 'currencyInput__formatted--zero';
12
- export let value = DEFAULT_VALUE;
13
- export let locale = DEFAULT_LOCALE;
14
- export let currency = DEFAULT_CURRENCY;
15
- export let name = DEFAULT_NAME;
16
- export let required = false;
17
- export let disabled = false;
18
- export let placeholder = DEFAULT_VALUE;
19
- export let autocomplete = undefined;
20
- export let isNegativeAllowed = true;
21
- export let fractionDigits = DEFAULT_FRACTION_DIGITS;
22
- export let inputClasses = null;
23
- export let onValueChange = () => { };
24
- // Formats value as: e.g. $1,523.00 | -$1,523.00
25
- const formatCurrency = (value, maximumFractionDigits, minimumFractionDigits) => {
26
- return new Intl.NumberFormat(locale, {
27
- currency: currency,
28
- style: 'currency',
29
- maximumFractionDigits: maximumFractionDigits || 0,
30
- minimumFractionDigits: minimumFractionDigits || 0
31
- }).format(value);
32
- };
33
- // Checks if the key pressed is allowed
34
- const handleKeyDown = (event) => {
35
- const isDeletion = event.key === 'Backspace' || event.key === 'Delete';
36
- const isModifier = event.metaKey || event.altKey || event.ctrlKey;
37
- const isArrowKey = event.key === 'ArrowLeft' || event.key === 'ArrowRight';
38
- const isTab = event.key === 'Tab';
39
- const isInvalidCharacter = !/^\d|,|\.|-$/g.test(event.key); // Keys that are not a digit, comma, period or minus sign
40
- if (!isDeletion && !isModifier && !isArrowKey && isInvalidCharacter && !isTab)
41
- event.preventDefault();
42
- };
43
- let inputTarget;
44
- const currencyDecimal = new Intl.NumberFormat(locale).format(1.1).charAt(1); // '.' or ','
45
- const isDecimalComma = currencyDecimal === ',';
46
- const currencySymbol = formatCurrency(0, 0)
47
- .replace('0', '') // e.g. '$0' > '$'
48
- .replace(/\u00A0/, ''); // e.g '0 €' > '€'
49
- // Updates `value` by stripping away the currency formatting
50
- const setUnformattedValue = (event) => {
51
- if (event) {
52
- // Don't format if the user is typing a `currencyDecimal` point
53
- if (event.key === currencyDecimal)
54
- return;
55
- // Pressing `.` when the decimal point is `,` gets replaced with `,`
56
- if (isDecimalComma && event.key === '.')
57
- formattedValue = formattedValue.replace(/\.([^.]*)$/, currencyDecimal + '$1'); // Only replace the last occurence
58
- // Pressing `,` when the decimal point is `.` gets replaced with `.`
59
- if (!isDecimalComma && event.key === ',')
60
- formattedValue = formattedValue.replace(/\,([^,]*)$/, currencyDecimal + '$1'); // Only replace the last occurence
61
- // Don't format if `formattedValue` is ['$', '-$', "-"]
62
- const ignoreSymbols = [currencySymbol, `-${currencySymbol}`, '-'];
63
- const strippedUnformattedValue = formattedValue.replace(' ', '');
64
- if (ignoreSymbols.includes(strippedUnformattedValue))
65
- return;
66
- // Set the starting caret positions
67
- inputTarget = event.target;
68
- // Reverse the value when minus is pressed
69
- if (isNegativeAllowed && event.key === '-')
70
- value = value * -1;
71
- }
72
- // Remove all characters that arent: numbers, commas, periods (or minus signs if `isNegativeAllowed`)
73
- let unformattedValue = isNegativeAllowed
74
- ? formattedValue.replace(/[^0-9,.-]/g, '')
75
- : formattedValue.replace(/[^0-9,.]/g, '');
76
- // Finally set the value
77
- if (Number.isNaN(parseFloat(unformattedValue))) {
78
- value = 0;
79
- }
80
- else {
81
- // The order of the following operations is *critical*
82
- unformattedValue = unformattedValue.replace(isDecimalComma ? /\./g : /\,/g, ''); // Remove all group symbols
83
- if (isDecimalComma)
84
- unformattedValue = unformattedValue.replace(',', '.'); // If the decimal point is a comma, replace it with a period
85
- // If the zero-key has been pressed
86
- // and if the current `value` is the same as the `value` before the key-press
87
- // formatting may need to be done (Issue #30)
88
- const previousValue = value;
89
- value = parseFloat(unformattedValue);
90
- if (event && previousValue === value) {
91
- // Do the formatting if the number of digits after the decimal point exceeds `fractionDigits`
92
- if (unformattedValue.includes('.') &&
93
- unformattedValue.split('.')[1].length > fractionDigits) {
94
- setFormattedValue();
95
- }
96
- }
97
- }
98
- };
99
- const setFormattedValue = () => {
100
- // Previous caret position
101
- const startCaretPosition = inputTarget?.selectionStart || 0;
102
- const previousFormattedValueLength = formattedValue.length;
103
- // Apply formatting to input
104
- formattedValue = isZero ? '' : formatCurrency(value, fractionDigits, 0);
105
- // Update `value` after formatting
106
- setUnformattedValue();
107
- let retries = 0;
108
- while (previousFormattedValueLength === formattedValue.length && retries < 10)
109
- retries++;
110
- if (previousFormattedValueLength !== formattedValue.length) {
111
- const endCaretPosition = startCaretPosition + formattedValue.length - previousFormattedValueLength;
112
- inputTarget?.setSelectionRange(endCaretPosition, endCaretPosition);
113
- }
114
- // Run callback function when `value` changes
115
- onValueChange(value);
116
- };
117
- let formattedValue = '';
118
- let formattedPlaceholder = placeholder !== null ? formatCurrency(placeholder, fractionDigits, fractionDigits) : '';
119
- $: isZero = value === 0;
120
- $: isNegative = value < 0;
121
- $: value, setFormattedValue();
122
- </script>
123
-
124
- <div class={inputClasses?.wrapper ?? DEFAULT_CLASS_WRAPPER}>
125
- <input
126
- class={inputClasses?.unformatted ?? DEFAULT_CLASS_UNFORMATTED}
127
- type="hidden"
128
- {name}
129
- {disabled}
130
- bind:value
131
- />
132
- <input
133
- class="
134
- {inputClasses?.formatted ?? DEFAULT_CLASS_FORMATTED}
135
- {isNegativeAllowed && !isZero && !isNegative
136
- ? inputClasses?.formattedPositive ?? DEFAULT_CLASS_FORMATTED_POSITIVE
137
- : ''}
138
- {isZero ? inputClasses?.formattedZero ?? DEFAULT_CLASS_FORMATTED_ZERO : ''}
139
- {isNegativeAllowed && isNegative
140
- ? inputClasses?.formattedNegative ?? DEFAULT_CLASS_FORMATTED_NEGATIVE
141
- : ''}
142
- "
143
- type="text"
144
- inputmode="numeric"
145
- name={`formatted-${name}`}
146
- required={required && !isZero}
147
- placeholder={formattedPlaceholder}
148
- {autocomplete}
149
- {disabled}
150
- bind:value={formattedValue}
151
- on:keydown={handleKeyDown}
152
- on:keyup={setUnformattedValue}
153
- on:blur={setFormattedValue}
154
- />
155
- </div>
156
-
157
- <style>
158
- input.currencyInput__formatted {
159
- border: 1px solid #e2e2e2;
160
- padding: 10px;
161
- box-sizing: border-box;
162
- }
163
-
164
- input.currencyInput__formatted--zero {
165
- color: #333;
166
- }
167
-
168
- input.currencyInput__formatted--positive {
169
- color: #00a36f;
170
- }
171
-
172
- input.currencyInput__formatted--negative {
173
- color: #e75258;
174
- }
175
-
176
- input.currencyInput__formatted:disabled {
177
- color: #999;
178
- background-color: #e2e2e2;
179
- pointer-events: none;
180
- cursor: default;
181
- }
182
- </style>
File without changes
File without changes