From 7d5c21b03b371ff41247621c25878cdfe881e6e0 Mon Sep 17 00:00:00 2001 From: Fernando Maclen Date: Fri, 10 Nov 2023 14:25:42 -0500 Subject: [PATCH] fix: set `inputmode` dynamically based on fractionDigits (#72) * fix: set inputmode dynamically based on `fractionDigits` * feat: make demo page responsive * fix: tweak styles of h1 * add title tag and link to REPL * add test * fix: remove peerDependencies --- package.json | 3 - src/app.html | 1 + src/lib/CurrencyInput.svelte | 2 +- src/routes/+page.svelte | 93 +++++++++++++++++++++-------- tests/svelte-currency-input.test.ts | 14 +++++ 5 files changed, 84 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 077427d..0db6487 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,6 @@ "!dist/**/*.test.*", "!dist/**/*.spec.*" ], - "peerDependencies": { - "svelte": "^3.59.2" - }, "devDependencies": { "@playwright/test": "^1.39.0", "@sveltejs/adapter-auto": "^2.0.0", diff --git a/src/app.html b/src/app.html index c1b3437..f293b7e 100644 --- a/src/app.html +++ b/src/app.html @@ -1,6 +1,7 @@ + svelte-currency-input | Demo diff --git a/src/lib/CurrencyInput.svelte b/src/lib/CurrencyInput.svelte index da618bf..22f596d 100644 --- a/src/lib/CurrencyInput.svelte +++ b/src/lib/CurrencyInput.svelte @@ -204,7 +204,7 @@ : ''} " type="text" - inputmode="numeric" + inputmode={fractionDigits > 0 ? "decimal" : "numeric"} name={`formatted-${name}`} required={required && !isZero} placeholder={handlePlaceholder(placeholder)} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 1c63635..85ef1e8 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -15,6 +15,33 @@
+ +
@@ -66,7 +93,7 @@ /> - +
- -