From f394b8002857d371cfaabe5cd45627e9453c3ec0 Mon Sep 17 00:00:00 2001 From: RevIQ Date: Sat, 10 Jan 2026 16:07:32 +0800 Subject: [PATCH] Add PhoneNumberInput component with libphonenumber-js formatting Uses AsYouType for real-time phone number formatting as user types. Implements digit-based cursor positioning to handle formatting changes without cursor jumping. Co-Authored-By: Claude Opus 4.5 --- .../components/ui/phone-number-input/index.ts | 7 ++ .../phone-number-input.svelte | 111 ++++++++++++++++++ .../src/routes/account/+page.svelte | 4 +- 3 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 apps/publisher-dashboard/src/lib/components/ui/phone-number-input/index.ts create mode 100644 apps/publisher-dashboard/src/lib/components/ui/phone-number-input/phone-number-input.svelte diff --git a/apps/publisher-dashboard/src/lib/components/ui/phone-number-input/index.ts b/apps/publisher-dashboard/src/lib/components/ui/phone-number-input/index.ts new file mode 100644 index 0000000..2de5dd2 --- /dev/null +++ b/apps/publisher-dashboard/src/lib/components/ui/phone-number-input/index.ts @@ -0,0 +1,7 @@ +import Root from "./phone-number-input.svelte"; + +export { + Root, + // + Root as PhoneNumberInput, +}; diff --git a/apps/publisher-dashboard/src/lib/components/ui/phone-number-input/phone-number-input.svelte b/apps/publisher-dashboard/src/lib/components/ui/phone-number-input/phone-number-input.svelte new file mode 100644 index 0000000..661d7f9 --- /dev/null +++ b/apps/publisher-dashboard/src/lib/components/ui/phone-number-input/phone-number-input.svelte @@ -0,0 +1,111 @@ + + + diff --git a/apps/publisher-dashboard/src/routes/account/+page.svelte b/apps/publisher-dashboard/src/routes/account/+page.svelte index bf721f2..a4e5c89 100644 --- a/apps/publisher-dashboard/src/routes/account/+page.svelte +++ b/apps/publisher-dashboard/src/routes/account/+page.svelte @@ -16,6 +16,7 @@ import { } from "$lib/components/ui/card"; import { Input } from "$lib/components/ui/input"; import { Label } from "$lib/components/ui/label"; +import { PhoneNumberInput } from "$lib/components/ui/phone-number-input"; import { LoadingButton } from "$lib/components/ui/loading-button"; import { Separator } from "$lib/components/ui/separator"; import { cn } from "$lib/utils"; @@ -224,9 +225,8 @@ function getInitials(name: string | null | undefined): string {
-