@desource/phone-mask-svelte 1.2.0 β†’ 1.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # @desource/phone-mask-svelte
2
2
 
3
+ ## 1.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Core Upgrades:
8
+ - Sync country masks with google-libphonenumber (πŸ‡ΈπŸ‡° Slovakia updates)
9
+
10
+ - Updated dependencies []:
11
+ - @desource/phone-mask@1.3.1
12
+
13
+ ## 1.3.0
14
+
15
+ ### Minor Changes
16
+
17
+ - Core Upgrades:
18
+ - Improved process keydown event handler for browser autocomplete cases
19
+
20
+ - Vue Upgrades:
21
+ - Added new `@desource/phone-mask-vue/core` subpath export (direct core helpers re-export)
22
+ - Root `PMaskHelpers` facade removed from index (helpers now via `/core` to reduce bundle size impact for Vue users)
23
+ - Added `id` and `name` props on `PhoneInput`, passed to underlying `<input>` element for better form integration and accessibility
24
+ - Added autofill style normalization (`-webkit-autofill` / `-moz-autofill`) for better visual consistency
25
+
26
+ - React Upgrades:
27
+ - Added new `@desource/phone-mask-react/core` subpath export (direct core helpers re-export)
28
+ - Root `PMaskHelpers` facade removed from index (helpers now via `/core` to reduce bundle size impact for React users)
29
+ - Added `id` and `name` props on `PhoneInput`, passed to underlying `<input>` element for better form integration and accessibility
30
+ - Added autofill style normalization (`-webkit-autofill` / `-moz-autofill`) for better visual consistency
31
+ - `useCountrySelector`, `useClipboard` internals stabilized (deps/callback consistency improvements)
32
+ - `usePhoneMask` callback dependency tuning for better stability
33
+
34
+ - Svelte Upgrades:
35
+ - Added new `@desource/phone-mask-svelte/core` subpath export (direct core helpers re-export)
36
+ - Root `PMaskHelpers` facade removed from index (helpers now via `/core` to reduce bundle size impact for Svelte users)
37
+ - Added `id` and `name` props on `PhoneInput`, passed to underlying `<input>` element for better form integration and accessibility
38
+ - Added autofill style normalization (`-webkit-autofill` / `-moz-autofill`) for better visual consistency
39
+
40
+ - Nuxt Upgrades:
41
+ - Module options expanded and clarified:
42
+ - `types` (default `true`): auto-import types from packages for TypeScript users
43
+ - `helpers` (default `false`): auto-import core helpers for direct usage in Nuxt apps (optional due to potential bundle size impact)
44
+ - new: `composable` (default `false`): auto-import Vue composable for custom phone mask logic (optional for users who only need more custom solution than the provided component/directive)
45
+ - Default auto-imports now focus on component/directive/types; helpers/composable are opt-in
46
+ - Runtime shared exports updated:
47
+ - `usePhoneMask` (composable) is now a separate export from `phoneMaskDirective` and `PhoneInput` component for more flexible usage patterns
48
+ - `PMaskHelpers` sourced via `@desource/phone-mask-vue/core` for better tree-shaking and bundle size control
49
+
50
+ ### Patch Changes
51
+
52
+ - Updated dependencies []:
53
+ - @desource/phone-mask@1.3.0
54
+
3
55
  ## 1.2.0
4
56
 
5
57
  ### Minor Changes
package/README.md CHANGED
@@ -49,6 +49,12 @@ Composable mode:
49
49
  import { usePhoneMask } from '@desource/phone-mask-svelte';
50
50
  ```
51
51
 
52
+ Core helpers (direct re-exports from `@desource/phone-mask`):
53
+
54
+ ```ts
55
+ import { getFlagEmoji, formatDigitsWithMap } from '@desource/phone-mask-svelte/core';
56
+ ```
57
+
52
58
  Attachment mode (for existing `<input>` elements, requires Svelte 5.29+):
53
59
 
54
60
  ```ts
@@ -198,6 +204,101 @@ With auto-detection:
198
204
  <input use:phoneMask={{ detect: true, onChange: handleChange }} />
199
205
  ```
200
206
 
207
+ ### Send Raw Digits to Backend
208
+
209
+ ```svelte
210
+ <script lang="ts">
211
+ import { PhoneInput, type PMaskPhoneNumber } from '@desource/phone-mask-svelte';
212
+
213
+ let digits = $state('');
214
+
215
+ async function handlePhoneChange(phone: PMaskPhoneNumber) {
216
+ await fetch('/api/profile/phone', {
217
+ method: 'POST',
218
+ headers: { 'content-type': 'application/json' },
219
+ body: JSON.stringify({
220
+ phoneDigits: phone.digits, // unformatted value for backend
221
+ phoneFull: phone.full // optional full number with country code
222
+ })
223
+ });
224
+ }
225
+ </script>
226
+
227
+ <PhoneInput bind:value={digits} country="US" onchange={handlePhoneChange} />
228
+ ```
229
+
230
+ ### Dynamic Mask Updates on Country Change
231
+
232
+ ```svelte
233
+ <script lang="ts">
234
+ import { usePhoneMask, type PCountryKey } from '@desource/phone-mask-svelte';
235
+
236
+ let selectedCountry = $state<PCountryKey>('US');
237
+ let digits = $state('');
238
+
239
+ const phoneMask = usePhoneMask({
240
+ value: () => digits,
241
+ onChange: (value) => (digits = value),
242
+ country: () => selectedCountry
243
+ });
244
+
245
+ function onCountrySelect(nextCountry: PCountryKey) {
246
+ selectedCountry = nextCountry;
247
+ phoneMask.setCountry(nextCountry); // updates mask immediately
248
+ }
249
+ </script>
250
+
251
+ <select
252
+ value={selectedCountry}
253
+ onchange={(e) => onCountrySelect((e.currentTarget as HTMLSelectElement).value as PCountryKey)}
254
+ >
255
+ <option value="US">US</option>
256
+ <option value="GB">GB</option>
257
+ <option value="DE">DE</option>
258
+ </select>
259
+
260
+ <input bind:this={phoneMask.inputRef} type="tel" />
261
+ <p>{phoneMask.fullFormatted}</p>
262
+ <p>{phoneMask.isComplete ? 'complete' : 'incomplete'}</p>
263
+ ```
264
+
265
+ ### Multi-tenant: tenantId Default Country + Tenant-specific Validation Rules
266
+
267
+ ```svelte
268
+ <script lang="ts">
269
+ import { usePhoneMask, type PCountryKey } from '@desource/phone-mask-svelte';
270
+
271
+ type TenantPolicy = {
272
+ defaultCountry: PCountryKey;
273
+ prefixRule?: RegExp;
274
+ };
275
+
276
+ let { tenantId }: { tenantId: string } = $props();
277
+
278
+ const TENANT_POLICIES: Record<string, TenantPolicy> = {
279
+ acme: { defaultCountry: 'US', prefixRule: /^(202|303)\d{7}$/ },
280
+ globex: { defaultCountry: 'GB', prefixRule: /^7\d{9}$/ }
281
+ };
282
+
283
+ const policy = $derived(TENANT_POLICIES[tenantId] ?? { defaultCountry: 'US' as const });
284
+ let digits = $state('');
285
+
286
+ const phoneMask = usePhoneMask({
287
+ value: () => digits,
288
+ onChange: (value) => (digits = value),
289
+ country: () => policy.defaultCountry
290
+ });
291
+
292
+ const isTenantValid = $derived(
293
+ phoneMask.isComplete && (policy.prefixRule ? policy.prefixRule.test(phoneMask.digits) : true)
294
+ );
295
+ </script>
296
+
297
+ <input bind:this={phoneMask.inputRef} type="tel" />
298
+ <p>Default country: {policy.defaultCountry}</p>
299
+ <p>Tenant validation: {isTenantValid ? 'pass' : 'fail'}</p>
300
+ ```
301
+
201
302
  ## πŸ“– Component API
202
303
 
203
304
  ### Props
@@ -209,6 +310,10 @@ interface PhoneInputProps {
209
310
  // Bindable value (digits only, without country code)
210
311
  value?: string;
211
312
 
313
+ // Optional id/name applied to the underlying <input> for forms/autofill
314
+ id?: string;
315
+ name?: string;
316
+
212
317
  // Preselected country (ISO 3166-1 alpha-2)
213
318
  country?: CountryKey;
214
319
 
@@ -497,10 +602,7 @@ Pass reactive state directly β€” the factory re-runs automatically when `selecte
497
602
  <option value="DE">πŸ‡©πŸ‡ͺ Germany</option>
498
603
  </select>
499
604
 
500
- <input
501
- {@attach phoneMask({ country: selectedCountry, onChange: (p) => (phoneData = p) })}
502
- placeholder="Phone number"
503
- />
605
+ <input {@attach phoneMask({ country: selectedCountry, onChange: (p) => (phoneData = p) })} placeholder="Phone number" />
504
606
  ```
505
607
 
506
608
  ## 🎬 Action API
@@ -573,10 +675,7 @@ Pass reactive `$state` inside the options object β€” Svelte calls `update()` aut
573
675
  <option value="DE">πŸ‡©πŸ‡ͺ Germany</option>
574
676
  </select>
575
677
 
576
- <input
577
- use:phoneMask={{ country: selectedCountry, onChange: (p) => (phoneData = p) }}
578
- placeholder="Phone number"
579
- />
678
+ <input use:phoneMask={{ country: selectedCountry, onChange: (p) => (phoneData = p) }} placeholder="Phone number" />
580
679
  ```
581
680
 
582
681
  ### Action vs Attachment
@@ -786,10 +885,12 @@ Or with CSS:
786
885
  ```
787
886
  @desource/phone-mask-svelte/
788
887
  β”œβ”€β”€ dist/
789
- β”‚ β”œβ”€β”€ types/ # TypeScript declaration files
790
- β”‚ β”œβ”€β”€ index.mjs # ES module bundle
791
- β”‚ β”œβ”€β”€ index.cjs # CommonJS bundle
792
- β”‚ └── phone-mask-svelte.css # Component styles
888
+ β”‚ β”œβ”€β”€ index.mjs # Main ESM/Svelte entry
889
+ β”‚ β”œβ”€β”€ index.cjs # Main CommonJS entry
890
+ β”‚ β”œβ”€β”€ core.mjs # Core helpers subpath (@desource/phone-mask-svelte/core)
891
+ β”‚ β”œβ”€β”€ core.cjs # Core helpers CJS subpath
892
+ β”‚ β”œβ”€β”€ phone-mask-svelte.css # Component styles
893
+ β”‚ └── types/ # TypeScript declaration files
793
894
  β”œβ”€β”€ README.md # This file
794
895
  └── package.json # Package manifest
795
896
  ```
package/dist/core.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=require(`@desource/phone-mask`);Object.keys(e).forEach(function(t){t!==`default`&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
package/dist/core.mjs ADDED
@@ -0,0 +1 @@
1
+ export*from"@desource/phone-mask";
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@desource/phone-mask`);require(`svelte/internal/disclose-version`);let l=require(`svelte/internal/client`);l=s(l);let u=require(`svelte`);function d({country:e,locale:t,detect:n,onCountryChange:r}={}){let i=l.state(l.proxy((0,c.parseCountryCode)(e?.(),`US`))),a=l.derived(()=>t?.()||(0,c.getNavigatorLang)()),o=l.derived(()=>(0,c.getCountry)(l.get(i),l.get(a))),s=e=>{let t=(0,c.parseCountryCode)(e);return t?(l.set(i,t,!0),!0):!1},u=async()=>{s(await(0,c.detectByGeoIp)())||s((0,c.detectCountryFromLocale)())};return l.user_effect(()=>{let t=e?.();t&&t!==l.get(i)&&s(t)}),l.user_effect(()=>{n?.()&&!e?.()&&u()}),l.user_effect(()=>{r?.(l.get(o))}),{get country(){return l.get(o)},get locale(){return l.get(a)},setCountry:s}}function f({country:e,value:t,onChange:n,onPhoneChange:r,onValidationChange:i}){let a=l.derived(()=>(0,c.createPhoneFormatter)(e())),o=l.derived(()=>l.get(a).getMaxDigits()),s=l.derived(()=>(0,c.extractDigits)(t(),l.get(o))),u=l.derived(()=>l.get(a).getPlaceholder()),d=l.derived(()=>l.get(a).formatDisplay(l.get(s))),f=l.derived(()=>l.get(s)?`${e().code}${l.get(s)}`:``),p=l.derived(()=>l.get(d)?`${e().code} ${l.get(d)}`:``),m=l.derived(()=>l.get(a).isComplete(l.get(s))),h=l.derived(()=>l.get(s).length===0),g=l.derived(()=>!l.get(h)&&!l.get(m)),_=l.derived(()=>({full:l.get(f),fullFormatted:l.get(p),digits:l.get(s)}));return l.user_pre_effect(()=>{let e=t(),r=l.get(s);e!==r&&n(r)}),l.user_effect(()=>{r?.(l.get(_))}),l.user_effect(()=>{i?.(l.get(m))}),{get digits(){return l.get(s)},get formatter(){return l.get(a)},get displayPlaceholder(){return l.get(u)},get displayValue(){return l.get(d)},get full(){return l.get(f)},get fullFormatted(){return l.get(p)},get isComplete(){return l.get(m)},get isEmpty(){return l.get(h)},get shouldShowWarn(){return l.get(g)}}}function p(){let e=null,t=()=>{e&&=(clearTimeout(e),null)};return(0,u.onDestroy)(t),{set:(n,r)=>{t(),e=setTimeout(n,r)},clear:t}}function m(){let e=l.state(!1),t=p();return{get showValidationHint(){return l.get(e)},clearValidationHint:(n=!0)=>{n&&l.set(e,!1),t.clear()},scheduleValidationHint:n=>{l.set(e,!1),t.set(()=>{l.set(e,!0)},n)}}}var h=500,g=300;function _(e){let{formatter:t,digits:n,inactive:r,onChange:i,scheduleValidationHint:a}=e,o=(e,n)=>{(0,u.tick)().then(()=>{e&&(0,c.setCaret)(e,t().getCaretPosition(n))})};return{handleBeforeInput:e=>{(0,c.processBeforeInput)(e)},handleInput:e=>{if(r?.())return;let n=(0,c.processInput)(e,{formatter:t()});n&&(i?.(n.newDigits),o(e.target,n.caretDigitIndex),a?.(h))},handleKeydown:e=>{if(r?.())return;let s=(0,c.processKeydown)(e,{digits:n(),formatter:t()});s&&(i?.(s.newDigits),o(e.target,s.caretDigitIndex),a?.(g))},handlePaste:e=>{if(r?.())return;let s=(0,c.processPaste)(e,{digits:n(),formatter:t()});s&&(i?.(s.newDigits),o(e.target,s.caretDigitIndex),a?.(g))}}}function v({rootRef:e,dropdownRef:t,searchRef:n,selectorRef:r,locale:i,countryOption:a,inactive:o,onSelectCountry:s,onAfterSelect:d}){let f=l.state(``),p=l.state(!1),m=l.state(!1),h=l.state(l.proxy({})),g=l.state(0),_=l.derived(()=>(0,c.MasksFull)(i())),v=l.derived(()=>(0,c.filterCountries)(l.get(_),l.get(f))),y=l.derived(()=>!a?.()&&l.get(_).length>1),b=e=>{l.set(g,e,!0)},ee=()=>{(0,u.tick)().then(()=>n()?.focus({preventScroll:!0}))},x=()=>{l.get(p)&&l.set(m,!0)},S=()=>{l.set(m,!1),l.set(p,!0),b(0),ee()},te=()=>{l.get(m)&&(l.set(p,!1),l.set(m,!1))},C=()=>{o?.()||!l.get(y)||(l.get(p)?x():S())},w=e=>{s(e),x(),l.set(f,``),b(0),d?.()},ne=e=>{l.set(f,e.target.value,!0),b(0)},T=e=>{let n=e.target,i=t(),a=r();n&&(i?.contains(n)||a?.contains(n)||x())},E=n=>{if(n?.type===`scroll`&&n.target&&t()?.contains(n.target))return;let r=e();if(!r)return;let i=r.getBoundingClientRect();l.set(h,{top:`${i.bottom+globalThis.scrollY+8}px`,left:`${i.left+globalThis.scrollX}px`,width:`${i.width}px`},!0)},D=()=>{(0,u.tick)().then(()=>{let e=t()?.lastElementChild,n=e?.children[l.get(g)];if(!e||!n)return;let r=e.getBoundingClientRect(),i=n.getBoundingClientRect(),a=0;if(i.top<r.top)a=e.scrollTop-(r.top-i.top);else if(i.bottom>r.bottom)a=e.scrollTop+(i.bottom-r.bottom);else return;e.scrollTo({top:a,behavior:`smooth`})})},re=e=>{e.key===`ArrowDown`?(e.preventDefault(),b(Math.min(l.get(g)+1,l.get(v).length-1)),D()):e.key===`ArrowUp`?(e.preventDefault(),b(Math.max(l.get(g)-1,0)),D()):e.key===`Enter`&&l.get(v)[l.get(g)]?(e.preventDefault(),w(l.get(v)[l.get(g)].id)):e.key===`Escape`&&x()},O=()=>{globalThis.removeEventListener(`resize`,E),globalThis.removeEventListener(`scroll`,E,!0),globalThis.removeEventListener(`click`,T,!0)};return l.user_effect(()=>{!l.get(y)&&l.get(p)&&x()}),l.user_effect(()=>{if(!l.get(p)){O();return}E(),globalThis.addEventListener(`resize`,E),globalThis.addEventListener(`scroll`,E,!0),globalThis.addEventListener(`click`,T,!0)}),(0,u.onDestroy)(O),{get dropdownOpen(){return l.get(p)},get isClosing(){return l.get(m)},get search(){return l.get(f)},get focusedIndex(){return l.get(g)},get dropdownStyle(){return l.get(h)},get filteredCountries(){return l.get(v)},get hasDropdown(){return l.get(y)},openDropdown:S,closeDropdown:x,toggleDropdown:C,selectCountry:w,setFocusedIndex:b,handleSearchChange:ne,handleSearchKeydown:re,handleDropdownAnimationEnd:te}}function y(e=1800){let t=l.state(!1),n=l.state(!1),r=p();return{get copied(){return l.get(t)},get isCopying(){return l.get(n)},copy:async i=>{if(l.get(n))return!1;let a=i.trim();if(!a)return!1;l.set(n,!0);try{return await navigator.clipboard.writeText(a),l.set(t,!0),r.set(()=>{l.set(t,!1)},e),!0}catch(e){return console.warn(`Copy failed`,e),!1}finally{l.set(n,!1)}}}}var b=1800;function ee({liveRef:e,fullFormatted:t,onCopy:n}){let r=p(),i=y(b),a=l.derived(()=>i.copied?`Copied`:`Copy ${t()}`),o=l.derived(()=>i.copied?`Copied`:`Copy phone number`),s=t=>{let n=e?.();n&&(n.textContent=t,r.set(()=>{let t=e?.();t&&(t.textContent=``)},b))};return{get copied(){return i.copied},get copyAriaLabel(){return l.get(a)},get copyButtonTitle(){return l.get(o)},onCopyClick:async()=>{let e=t().trim();await i.copy(e)&&(n?.(e),s(`Phone number copied to clipboard`))}}}function x({theme:e}){let t=l.state(!1),n=l.derived(()=>(()=>{let n=e();return n===`auto`?l.get(t)?`theme-dark`:`theme-light`:`theme-${n}`})());return l.user_effect(()=>{let e=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`)??null;if(!e)return;l.set(t,e.matches,!0);let n=e=>{l.set(t,e.matches,!0)};return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)}),{get themeClass(){return l.get(n)}}}var S=l.from_svg(`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true"><path d="M2.5 4.5L6 8L9.5 4.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>`),te=l.from_svg(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M6.5 11.5L3 8L4.06 6.94L6.5 9.38L11.94 3.94L13 5L6.5 11.5Z" fill="currentColor"></path></svg>`),C=l.from_svg(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M13.5 5.5V13.5H5.5V5.5H13.5ZM13.5 4H5.5C4.67 4 4 4.67 4 5.5V13.5C4 14.33 4.67 15 5.5 15H13.5C14.33 15 15 14.33 15 13.5V5.5C15 4.67 14.33 4 13.5 4ZM10.5 1H2.5V11H4V2.5H10.5V1Z" fill="currentColor"></path></svg>`),w=l.from_html(`<button type="button"><!></button>`),ne=l.from_svg(`<svg width="11" height="11" viewBox="0 0 14 14" fill="none" aria-hidden="true"><path d="M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z" fill="currentColor"></path></svg>`),T=l.from_html(`<button type="button" class="pi-btn pi-btn-clear"><!></button>`),E=l.from_html(`<li role="option"><span class="pi-flag" role="img"><!></span> <span class="pi-opt-name"> </span> <span class="pi-opt-code"> </span></li>`),D=l.from_html(`<li class="pi-empty"> </li>`),re=l.from_html(`<div role="dialog" aria-modal="false" aria-label="Select country"><div class="pi-search-wrap"><input type="search" class="pi-search" aria-label="Search countries"/></div> <ul class="pi-options" role="listbox" tabindex="-1"></ul></div>`),O=l.from_html(`<div><div class="pi-selector"><button type="button"><span class="pi-flag" role="img"><!></span> <span class="pi-code"> </span> <!></button></div> <div class="pi-input-wrap"><input type="tel" inputmode="tel" autocomplete="tel-national" autocorrect="off" autocapitalize="off" spellcheck="false" class="pi-input"/> <div class="pi-actions" role="toolbar" aria-label="Phone input actions"><!> <!> <!></div></div></div> <!> <div class="sr-only" role="status" aria-live="polite" aria-atomic="true"></div>`,1);function ie(e,t){l.push(t,!0);let n=l.prop(t,`value`,15,``),r=l.prop(t,`detect`,3,!0),i=l.prop(t,`size`,3,`normal`),a=l.prop(t,`theme`,3,`auto`),o=l.prop(t,`disabled`,3,!1),s=l.prop(t,`readonly`,3,!1),c=l.prop(t,`showCopy`,3,!0),p=l.prop(t,`showClear`,3,!1),h=l.prop(t,`withValidity`,3,!0),g=l.prop(t,`searchPlaceholder`,3,`Search country or code...`),y=l.prop(t,`noResultsText`,3,`No countries found`),b=l.prop(t,`clearButtonLabel`,3,`Clear phone number`),ie=l.prop(t,`dropdownClass`,3,``),k=l.prop(t,`disableDefaultStyles`,3,!1),ae=l.rest_props(t,`$$slots.$$events.$$legacy.value.country.detect.locale.size.theme.disabled.readonly.showCopy.showClear.withValidity.searchPlaceholder.noResultsText.clearButtonLabel.dropdownClass.disableDefaultStyles.onchange.oncountrychange.onvalidationchange.onfocus.onblur.oncopy.onclear.flag.copysvg.clearsvg.actionsbefore.class`.split(`.`)),A=l.state(null),j=l.state(null),M=l.state(null),N=l.state(null),P=l.state(null),F=l.state(null),I=d({country:()=>t.country,locale:()=>t.locale,detect:()=>r(),onCountryChange:(...e)=>t.oncountrychange?.(...e)}),L=f({country:()=>I.country,value:()=>n(),onChange:e=>n(e),onPhoneChange:(...e)=>t.onchange?.(...e),onValidationChange:(...e)=>t.onvalidationchange?.(...e)}),R=m(),z=l.derived(()=>o()||s()),oe=l.derived(()=>R.showValidationHint&&L.shouldShowWarn),se=l.derived(()=>c()&&!L.isEmpty&&!o()),B=l.derived(()=>p()&&!L.isEmpty&&!l.get(z)),V=ee({liveRef:()=>l.get(M),fullFormatted:()=>L.fullFormatted,onCopy:(...e)=>t.oncopy?.(...e)}),H=()=>(0,u.tick)().then(()=>l.get(j)?.focus()),U=v({rootRef:()=>l.get(A),dropdownRef:()=>l.get(N),searchRef:()=>l.get(P),selectorRef:()=>l.get(F),locale:()=>I.locale,countryOption:()=>t.country,inactive:()=>l.get(z),onSelectCountry:I.setCountry,onAfterSelect:H}),W=l.state(`0`);(0,u.onMount)(()=>{l.set(W,Math.random().toString(36).slice(2,10),!0)});let G=l.derived(()=>`pi-options-${l.get(W)}`),K=e=>`pi-option-${l.get(W)}-${e}`,ce=l.derived(()=>U.dropdownOpen&&U.filteredCountries[U.focusedIndex]?K(U.focusedIndex):void 0),q=_({formatter:()=>L.formatter,digits:()=>L.digits,inactive:()=>l.get(z),onChange:e=>n(e),scheduleValidationHint:R.scheduleValidationHint}),le=e=>{R.clearValidationHint(!1),U.closeDropdown(),t.onfocus?.(e)},ue=e=>t.onblur?.(e);function de(){H()}function fe(){l.get(j)?.blur()}function pe(){n(``),R.clearValidationHint(),t.onclear?.()}function me(e){I.setCountry(e)}function he(){return L.full}function ge(){return L.fullFormatted}function _e(){return L.digits}function ve(){return L.isComplete}function ye(){return L.isComplete}let be=()=>{pe(),H()},xe=x({theme:()=>a()}),Se=l.derived(()=>[`phone-input`,`size-${i()}`,xe.themeClass,o()&&`is-disabled`,s()&&`is-readonly`,k()&&`is-unstyled`,h()&&l.get(oe)&&`is-incomplete`,h()&&L.isComplete&&`is-complete`,t.class].filter(Boolean).join(` `)),Ce=l.derived(()=>+l.get(se)+ +l.get(B)+(t.actionsbefore?1:0));function we(e){return document.body.appendChild(e),{destroy:()=>e.remove()}}var Te={focus:de,blur:fe,clear:pe,selectCountry:me,getFullNumber:he,getFullFormattedNumber:ge,getDigits:_e,isValid:ve,isComplete:ye},Ee=O(),J=l.first_child(Ee);l.attribute_effect(J,()=>({class:l.get(Se),...ae,role:`group`,"aria-label":`Phone input with country selector`,[l.STYLE]:{"--pi-actions-count":l.get(Ce)}}));var Y=l.child(J),X=l.child(Y);let De;var Z=l.child(X),Oe=l.child(Z),ke=e=>{var n=l.comment(),r=l.first_child(n);l.snippet(r,()=>t.flag,()=>I.country),l.append(e,n)},Ae=e=>{var t=l.text();l.template_effect(()=>l.set_text(t,I.country.flag)),l.append(e,t)};l.if(Oe,e=>{t.flag?e(ke):e(Ae,-1)}),l.reset(Z);var Q=l.sibling(Z,2),je=l.child(Q,!0);l.reset(Q);var Me=l.sibling(Q,2),Ne=e=>{var t=S();let n;l.template_effect(()=>n=l.set_class(t,0,`pi-chevron`,null,n,{"is-open":U.dropdownOpen})),l.append(e,t)};l.if(Me,e=>{!l.get(z)&&U.hasDropdown&&e(Ne)}),l.reset(X),l.reset(Y),l.bind_this(Y,e=>l.set(F,e),()=>l.get(F));var Pe=l.sibling(Y,2),$=l.child(Pe);l.remove_input_defaults($),l.bind_this($,e=>l.set(j,e),()=>l.get(j));var Fe=l.sibling($,2),Ie=l.child(Fe),Le=e=>{var n=l.comment(),r=l.first_child(n);l.snippet(r,()=>t.actionsbefore),l.append(e,n)};l.if(Ie,e=>{t.actionsbefore&&e(Le)});var Re=l.sibling(Ie,2),ze=e=>{var n=w();let r;var i=l.child(n),a=e=>{var n=l.comment(),r=l.first_child(n);l.snippet(r,()=>t.copysvg,()=>V.copied),l.append(e,n)},o=e=>{var t=te();l.append(e,t)},s=e=>{var t=C();l.append(e,t)};l.if(i,e=>{t.copysvg?e(a):V.copied?e(o,1):e(s,-1)}),l.reset(n),l.template_effect(()=>{r=l.set_class(n,1,`pi-btn pi-btn-copy`,null,r,{"is-copied":V.copied}),l.set_attribute(n,`aria-label`,V.copyAriaLabel),l.set_attribute(n,`title`,V.copyButtonTitle)}),l.delegated(`click`,n,function(...e){V.onCopyClick?.apply(this,e)}),l.append(e,n)};l.if(Re,e=>{l.get(se)&&e(ze)});var Be=l.sibling(Re,2),Ve=e=>{var n=T(),r=l.child(n),i=e=>{var n=l.comment(),r=l.first_child(n);l.snippet(r,()=>t.clearsvg),l.append(e,n)},a=e=>{var t=ne();l.append(e,t)};l.if(r,e=>{t.clearsvg?e(i):e(a,-1)}),l.reset(n),l.template_effect(()=>{l.set_attribute(n,`aria-label`,b()),l.set_attribute(n,`title`,b())}),l.delegated(`click`,n,be),l.append(e,n)};l.if(Be,e=>{l.get(B)&&e(Ve)}),l.reset(Fe),l.reset(Pe),l.reset(J),l.bind_this(J,e=>l.set(A,e),()=>l.get(A));var He=l.sibling(J,2),Ue=e=>{var n=re();let r,i;var a=l.child(n),o=l.child(a);l.remove_input_defaults(o),l.bind_this(o,e=>l.set(P,e),()=>l.get(P)),l.reset(a);var s=l.sibling(a,2);l.each(s,23,()=>U.filteredCountries,e=>e.id,(e,n,r)=>{var i=E();let a;var o=l.child(i),s=l.child(o),c=e=>{var r=l.comment(),i=l.first_child(r);l.snippet(i,()=>t.flag,()=>l.get(n)),l.append(e,r)},u=e=>{var t=l.text();l.template_effect(()=>l.set_text(t,l.get(n).flag)),l.append(e,t)};l.if(s,e=>{t.flag?e(c):e(u,-1)}),l.reset(o);var d=l.sibling(o,2),f=l.child(d,!0);l.reset(d);var p=l.sibling(d,2),m=l.child(p,!0);l.reset(p),l.reset(i),l.template_effect(e=>{l.set_attribute(i,`id`,e),a=l.set_class(i,1,`pi-option`,null,a,{"is-focused":l.get(r)===U.focusedIndex,"is-selected":l.get(n).id===I.country.id}),l.set_attribute(i,`aria-selected`,l.get(n).id===I.country.id),l.set_attribute(i,`title`,l.get(n).name),l.set_attribute(o,`aria-label`,`${l.get(n).name??``} flag`),l.set_text(f,l.get(n).name),l.set_text(m,l.get(n).code)},[()=>K(l.get(r))]),l.delegated(`click`,i,()=>U.selectCountry(l.get(n).id)),l.event(`mouseenter`,i,()=>U.setFocusedIndex(l.get(r))),l.append(e,i)},e=>{var t=D(),n=l.child(t,!0);l.reset(t),l.template_effect(()=>l.set_text(n,y())),l.append(e,t)}),l.reset(s),l.reset(n),l.action(n,e=>we?.(e)),l.bind_this(n,e=>l.set(N,e),()=>l.get(N)),l.template_effect(()=>{r=l.set_class(n,1,`phone-dropdown ${ie()??``} ${xe.themeClass??``}`,null,r,{"is-closing":U.isClosing}),i=l.set_style(n,``,i,{position:`absolute`,top:U.dropdownStyle.top,left:U.dropdownStyle.left,width:U.dropdownStyle.width}),l.set_attribute(o,`placeholder`,g()),l.set_attribute(o,`aria-controls`,l.get(G)),l.set_attribute(o,`aria-activedescendant`,l.get(ce)),l.set_value(o,U.search),l.set_attribute(s,`id`,l.get(G))}),l.event(`animationend`,n,function(...e){U.handleDropdownAnimationEnd?.apply(this,e)}),l.delegated(`keydown`,o,function(...e){U.handleSearchKeydown?.apply(this,e)}),l.delegated(`input`,o,function(...e){U.handleSearchChange?.apply(this,e)}),l.append(e,n)};l.if(He,e=>{U.dropdownOpen&&e(Ue)});var We=l.sibling(He,2);return l.bind_this(We,e=>l.set(M,e),()=>l.get(M)),l.template_effect(()=>{De=l.set_class(X,1,`pi-selector-btn`,null,De,{"no-dropdown":!U.hasDropdown||s()}),X.disabled=o(),l.set_attribute(X,`tabindex`,l.get(z)||!U.hasDropdown?-1:void 0),l.set_attribute(X,`aria-label`,`Selected country: ${I.country.name??``}`),l.set_attribute(X,`aria-expanded`,U.dropdownOpen),l.set_attribute(X,`aria-haspopup`,U.hasDropdown?`listbox`:void 0),l.set_attribute(Z,`aria-label`,`${I.country.name??``} flag`),l.set_text(je,I.country.code),l.set_attribute($,`placeholder`,L.displayPlaceholder),l.set_value($,L.displayValue),$.disabled=o(),$.readOnly=s(),l.set_attribute($,`aria-invalid`,l.get(oe))}),l.delegated(`click`,X,function(...e){U.toggleDropdown?.apply(this,e)}),l.delegated(`beforeinput`,$,function(...e){q.handleBeforeInput?.apply(this,e)}),l.delegated(`input`,$,function(...e){q.handleInput?.apply(this,e)}),l.delegated(`keydown`,$,function(...e){q.handleKeydown?.apply(this,e)}),l.event(`paste`,$,function(...e){q.handlePaste?.apply(this,e)}),l.event(`focus`,$,le),l.event(`blur`,$,ue),l.append(e,Ee),l.pop(Te)}l.delegate([`click`,`beforeinput`,`input`,`keydown`]);function k(e){let t=l.state(null),n=d({country:e.country,locale:e.locale,detect:e.detect,onCountryChange:e.onCountryChange}),r=f({country:()=>n.country,value:e.value,onChange:e.onChange,onPhoneChange:e.onPhoneChange}),{handleBeforeInput:i,handleInput:a,handleKeydown:o,handlePaste:s}=_({formatter:()=>r.formatter,digits:()=>r.digits,onChange:e.onChange});return l.user_effect(()=>{let e=l.get(t);if(e)return e.setAttribute(`type`,`tel`),e.setAttribute(`inputmode`,`tel`),e.addEventListener(`beforeinput`,i),e.addEventListener(`input`,a),e.addEventListener(`keydown`,o),e.addEventListener(`paste`,s),()=>{e.removeEventListener(`beforeinput`,i),e.removeEventListener(`input`,a),e.removeEventListener(`keydown`,o),e.removeEventListener(`paste`,s)}}),l.user_effect(()=>{let e=l.get(t);e&&(e.value=r.displayValue,e.setAttribute(`placeholder`,r.displayPlaceholder))}),{get inputRef(){return l.get(t)},set inputRef(e){l.set(t,e,!0)},get digits(){return r.digits},get formatter(){return r.formatter},get full(){return r.full},get fullFormatted(){return r.fullFormatted},get isComplete(){return r.isComplete},get isEmpty(){return r.isEmpty},get shouldShowWarn(){return r.shouldShowWarn},get country(){return n.country},get locale(){return n.locale},setCountry:n.setCountry,clear:()=>{e.onChange(``)}}}function ae(e){return typeof e==`string`?{country:e}:e&&typeof e==`object`?e:{}}function A(e){return t=>{if(t.tagName!==`INPUT`){console.warn(`[phoneMaskAttachment] Attachment can only be used on input elements`);return}let n=ae(e),r=l.effect_root(()=>{let e=l.state(l.proxy(t.value||``)),r=k({country:()=>n.country,locale:()=>n.locale,detect:()=>n.detect,value:()=>l.get(e),onChange:t=>{l.set(e,t,!0)},onPhoneChange:n.onChange,onCountryChange:n.onCountryChange});r.inputRef=t,t.__phoneMaskState={get country(){return r.country},get formatter(){return r.formatter},get digits(){return r.digits},get locale(){return r.locale},options:n,setCountry:e=>r.setCountry(e)}});return()=>{r(),delete t.__phoneMaskState}}}function j(e){return typeof e==`string`?{country:e}:e&&typeof e==`object`?e:{}}function M(e,t,n){if(t.digits=n,e.value=t.formatter.formatDisplay(t.digits),t.options.onChange){let n=e.value?`${t.country.code} ${e.value}`:``,r=t.digits?`${t.country.code}${t.digits}`:``;t.options.onChange({full:r,fullFormatted:n,digits:t.digits})}}function N(e,t){let n=t.formatter.getMaxDigits(),r=(0,c.extractDigits)(e.value,n),i=t.formatter.formatDisplay(r);(r!==t.digits||e.value!==i)&&M(e,t,r)}function P(e){let t=e.country.id,n=(0,c.parseCountryCode)(e.options.country);n&&n!==t&&e.setCountry(n)}function F(e,t,n){return r=>{let i=n(r,t);i&&(M(e,t,i.newDigits),Promise.resolve().then(()=>{(0,c.setCaret)(e,t.formatter.getCaretPosition(i.caretDigitIndex))}))}}async function I(e){let t=(0,c.parseCountryCode)(e.country);if(t)return t;if(e.detect){let e=(0,c.parseCountryCode)(await(0,c.detectByGeoIp)());if(e)return e;let t=(0,c.parseCountryCode)((0,c.detectCountryFromLocale)());if(t)return t}return`US`}function L(e,t){if(e.tagName!==`INPUT`)return console.warn(`[phoneMaskAction] Action can only be used on input elements`),{update(){},destroy(){}};e.setAttribute(`type`,`tel`),e.setAttribute(`inputmode`,`tel`),e.setAttribute(`placeholder`,``);let n=j(t),r=n.locale||(0,c.getNavigatorLang)(),i=(0,c.getCountry)((0,c.parseCountryCode)(n.country,`US`),r),a={country:i,formatter:(0,c.createPhoneFormatter)(i),digits:``,locale:r,options:n,setCountry(t){let n=(0,c.parseCountryCode)(t);if(!n)return!1;let r=(0,c.getCountry)(n,this.locale);return this.country=r,this.options.onCountryChange?.(r),this.formatter=(0,c.createPhoneFormatter)(r),e.placeholder=this.formatter.getPlaceholder(),N(e,this),!0}};e.__phoneMaskState=a;let o=F(e,a,c.processInput),s=F(e,a,c.processKeydown),l=F(e,a,c.processPaste);return e.addEventListener(`beforeinput`,c.processBeforeInput),e.addEventListener(`input`,o),e.addEventListener(`keydown`,s),e.addEventListener(`paste`,l),I(n).then(t=>{e.__phoneMaskState===a&&a.setCountry(t)}),{update(t){a.options=j(t),P(a),N(e,a)},destroy(){e.removeEventListener(`beforeinput`,c.processBeforeInput),e.removeEventListener(`input`,o),e.removeEventListener(`keydown`,s),e.removeEventListener(`paste`,l),delete e.__phoneMaskState}}}var R=ie,z={getFlagEmoji:c.getFlagEmoji,countPlaceholders:c.countPlaceholders,formatDigitsWithMap:c.formatDigitsWithMap,pickMaskVariant:c.pickMaskVariant,removeCountryCodePrefix:c.removeCountryCodePrefix};exports.PMaskHelpers=z,exports.PhoneInput=R,exports.phoneMaskAction=L,exports.phoneMaskAttachment=A,exports.usePhoneMask=k;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));require(`svelte/internal/disclose-version`);let c=require(`svelte/internal/client`),l=s(c,1);c=s(c);let u=require(`svelte`),d=require(`@desource/phone-mask`);function f({country:e,locale:t,detect:n,onCountryChange:r}={}){let i=l.state(l.proxy((0,d.parseCountryCode)(e?.(),`US`))),a=l.derived(()=>t?.()||(0,d.getNavigatorLang)()),o=l.derived(()=>(0,d.getCountry)(l.get(i),l.get(a))),s=e=>{let t=(0,d.parseCountryCode)(e);return t?(l.set(i,t,!0),!0):!1},c=async()=>{s(await(0,d.detectByGeoIp)())||s((0,d.detectCountryFromLocale)())};return l.user_effect(()=>{let t=e?.();t&&t!==l.get(i)&&s(t)}),l.user_effect(()=>{n?.()&&!e?.()&&c()}),l.user_effect(()=>{r?.(l.get(o))}),{get country(){return l.get(o)},get locale(){return l.get(a)},setCountry:s}}function p({country:e,value:t,onChange:n,onPhoneChange:r,onValidationChange:i}){let a=l.derived(()=>(0,d.createPhoneFormatter)(e())),o=l.derived(()=>l.get(a).getMaxDigits()),s=l.derived(()=>(0,d.extractDigits)(t(),l.get(o))),c=l.derived(()=>l.get(a).getPlaceholder()),u=l.derived(()=>l.get(a).formatDisplay(l.get(s))),f=l.derived(()=>l.get(s)?`${e().code}${l.get(s)}`:``),p=l.derived(()=>l.get(u)?`${e().code} ${l.get(u)}`:``),m=l.derived(()=>l.get(a).isComplete(l.get(s))),h=l.derived(()=>l.get(s).length===0),g=l.derived(()=>!l.get(h)&&!l.get(m)),_=l.derived(()=>({full:l.get(f),fullFormatted:l.get(p),digits:l.get(s)}));return l.user_pre_effect(()=>{let e=t(),r=l.get(s);e!==r&&n(r)}),l.user_effect(()=>{r?.(l.get(_))}),l.user_effect(()=>{i?.(l.get(m))}),{get digits(){return l.get(s)},get formatter(){return l.get(a)},get displayPlaceholder(){return l.get(c)},get displayValue(){return l.get(u)},get full(){return l.get(f)},get fullFormatted(){return l.get(p)},get isComplete(){return l.get(m)},get isEmpty(){return l.get(h)},get shouldShowWarn(){return l.get(g)}}}function m(){let e=null,t=()=>{e&&=(clearTimeout(e),null)};return(0,u.onDestroy)(t),{set:(n,r)=>{t(),e=setTimeout(n,r)},clear:t}}function h(){let e=l.state(!1),t=m();return{get showValidationHint(){return l.get(e)},clearValidationHint:(n=!0)=>{n&&l.set(e,!1),t.clear()},scheduleValidationHint:n=>{l.set(e,!1),t.set(()=>{l.set(e,!0)},n)}}}var g=500,_=300;function v(e){let{formatter:t,digits:n,inactive:r,onChange:i,scheduleValidationHint:a}=e,o=(e,n)=>{(0,u.tick)().then(()=>{e&&(0,d.setCaret)(e,t().getCaretPosition(n))})};return{handleBeforeInput:e=>{(0,d.processBeforeInput)(e)},handleInput:e=>{if(r?.())return;let n=(0,d.processInput)(e,{formatter:t()});n&&(i?.(n.newDigits),o(e.target,n.caretDigitIndex),a?.(g))},handleKeydown:e=>{if(r?.())return;let s=(0,d.processKeydown)(e,{digits:n(),formatter:t()});s&&(i?.(s.newDigits),o(e.target,s.caretDigitIndex),a?.(_))},handlePaste:e=>{if(r?.())return;let s=(0,d.processPaste)(e,{digits:n(),formatter:t()});s&&(i?.(s.newDigits),o(e.target,s.caretDigitIndex),a?.(_))}}}function y({rootRef:e,dropdownRef:t,searchRef:n,selectorRef:r,locale:i,countryOption:a,inactive:o,onSelectCountry:s,onAfterSelect:c}){let f=l.state(``),p=l.state(!1),m=l.state(!1),h=l.state(l.proxy({})),g=l.state(0),_=l.derived(()=>(0,d.MasksFull)(i())),v=l.derived(()=>(0,d.filterCountries)(l.get(_),l.get(f))),y=l.derived(()=>!a?.()&&l.get(_).length>1),b=e=>{l.set(g,e,!0)},x=()=>{(0,u.tick)().then(()=>n()?.focus({preventScroll:!0}))},S=()=>{l.get(p)&&l.set(m,!0)},C=()=>{l.set(m,!1),l.set(p,!0),b(0),x()},ee=()=>{l.get(m)&&(l.set(p,!1),l.set(m,!1))},te=()=>{o?.()||!l.get(y)||(l.get(p)?S():C())},w=e=>{s(e),S(),l.set(f,``),b(0),c?.()},ne=e=>{l.set(f,e.target.value,!0),b(0)},T=e=>{let n=e.target,i=t(),a=r();n&&(i?.contains(n)||a?.contains(n)||S())},E=n=>{if(n?.type===`scroll`&&n.target&&t()?.contains(n.target))return;let r=e();if(!r)return;let i=r.getBoundingClientRect();l.set(h,{top:`${i.bottom+globalThis.scrollY+8}px`,left:`${i.left+globalThis.scrollX}px`,width:`${i.width}px`},!0)},D=()=>{(0,u.tick)().then(()=>{let e=t()?.lastElementChild,n=e?.children[l.get(g)];if(!e||!n)return;let r=e.getBoundingClientRect(),i=n.getBoundingClientRect(),a=0;if(i.top<r.top)a=e.scrollTop-(r.top-i.top);else if(i.bottom>r.bottom)a=e.scrollTop+(i.bottom-r.bottom);else return;e.scrollTo({top:a,behavior:`smooth`})})},re=e=>{e.key===`ArrowDown`?(e.preventDefault(),b(Math.min(l.get(g)+1,l.get(v).length-1)),D()):e.key===`ArrowUp`?(e.preventDefault(),b(Math.max(l.get(g)-1,0)),D()):e.key===`Enter`&&l.get(v)[l.get(g)]?(e.preventDefault(),w(l.get(v)[l.get(g)].id)):e.key===`Escape`&&S()},O=()=>{globalThis.removeEventListener(`resize`,E),globalThis.removeEventListener(`scroll`,E,!0),globalThis.removeEventListener(`click`,T,!0)};return l.user_effect(()=>{!l.get(y)&&l.get(p)&&S()}),l.user_effect(()=>{if(!l.get(p)){O();return}E(),globalThis.addEventListener(`resize`,E),globalThis.addEventListener(`scroll`,E,!0),globalThis.addEventListener(`click`,T,!0)}),(0,u.onDestroy)(O),{get dropdownOpen(){return l.get(p)},get isClosing(){return l.get(m)},get search(){return l.get(f)},get focusedIndex(){return l.get(g)},get dropdownStyle(){return l.get(h)},get filteredCountries(){return l.get(v)},get hasDropdown(){return l.get(y)},openDropdown:C,closeDropdown:S,toggleDropdown:te,selectCountry:w,setFocusedIndex:b,handleSearchChange:ne,handleSearchKeydown:re,handleDropdownAnimationEnd:ee}}function b(e=1800){let t=l.state(!1),n=l.state(!1),r=m();return{get copied(){return l.get(t)},get isCopying(){return l.get(n)},copy:async i=>{if(l.get(n))return!1;let a=i.trim();if(!a)return!1;l.set(n,!0);try{return await navigator.clipboard.writeText(a),l.set(t,!0),r.set(()=>{l.set(t,!1)},e),!0}catch(e){return console.warn(`Copy failed`,e),!1}finally{l.set(n,!1)}}}}var x=1800;function S({liveRef:e,fullFormatted:t,onCopy:n}){let r=m(),i=b(x),a=l.derived(()=>i.copied?`Copied`:`Copy ${t()}`),o=l.derived(()=>i.copied?`Copied`:`Copy phone number`),s=t=>{let n=e?.();n&&(n.textContent=t,r.set(()=>{let t=e?.();t&&(t.textContent=``)},x))};return{get copied(){return i.copied},get copyAriaLabel(){return l.get(a)},get copyButtonTitle(){return l.get(o)},onCopyClick:async()=>{let e=t().trim();await i.copy(e)&&(n?.(e),s(`Phone number copied to clipboard`))}}}function C({theme:e}){let t=l.state(!1),n=l.derived(()=>(()=>{let n=e();return n===`auto`?l.get(t)?`theme-dark`:`theme-light`:`theme-${n}`})());return l.user_effect(()=>{let e=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`)??null;if(!e)return;l.set(t,e.matches,!0);let n=e=>{l.set(t,e.matches,!0)};return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)}),{get themeClass(){return l.get(n)}}}var ee=c.from_svg(`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true"><path d="M2.5 4.5L6 8L9.5 4.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>`),te=c.from_svg(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M6.5 11.5L3 8L4.06 6.94L6.5 9.38L11.94 3.94L13 5L6.5 11.5Z" fill="currentColor"></path></svg>`),w=c.from_svg(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M13.5 5.5V13.5H5.5V5.5H13.5ZM13.5 4H5.5C4.67 4 4 4.67 4 5.5V13.5C4 14.33 4.67 15 5.5 15H13.5C14.33 15 15 14.33 15 13.5V5.5C15 4.67 14.33 4 13.5 4ZM10.5 1H2.5V11H4V2.5H10.5V1Z" fill="currentColor"></path></svg>`),ne=c.from_html(`<button type="button"><!></button>`),T=c.from_svg(`<svg width="11" height="11" viewBox="0 0 14 14" fill="none" aria-hidden="true"><path d="M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z" fill="currentColor"></path></svg>`),E=c.from_html(`<button type="button" class="pi-btn pi-btn-clear"><!></button>`),D=c.from_html(`<li role="option"><span class="pi-flag" role="img"><!></span> <span class="pi-opt-name"> </span> <span class="pi-opt-code"> </span></li>`),re=c.from_html(`<li class="pi-empty"> </li>`),O=c.from_html(`<div role="dialog" aria-modal="false" aria-label="Select country"><div class="pi-search-wrap"><input type="search" class="pi-search" aria-label="Search countries"/></div> <ul class="pi-options" role="listbox" tabindex="-1"></ul></div>`),ie=c.from_html(`<div><div class="pi-selector"><button type="button"><span class="pi-flag" role="img"><!></span> <span class="pi-code"> </span> <!></button></div> <div class="pi-input-wrap"><input type="tel" inputmode="tel" autocomplete="tel-national" autocorrect="off" autocapitalize="off" spellcheck="false" class="pi-input"/> <div class="pi-actions" role="toolbar" aria-label="Phone input actions"><!> <!> <!></div></div></div> <!> <div class="sr-only" role="status" aria-live="polite" aria-atomic="true"></div>`,1);function ae(e,t){c.push(t,!0);let n=c.prop(t,`value`,15,``),r=c.prop(t,`detect`,3,!0),i=c.prop(t,`size`,3,`normal`),a=c.prop(t,`theme`,3,`auto`),o=c.prop(t,`disabled`,3,!1),s=c.prop(t,`readonly`,3,!1),l=c.prop(t,`showCopy`,3,!0),d=c.prop(t,`showClear`,3,!1),m=c.prop(t,`withValidity`,3,!0),g=c.prop(t,`searchPlaceholder`,3,`Search country or code...`),_=c.prop(t,`noResultsText`,3,`No countries found`),b=c.prop(t,`clearButtonLabel`,3,`Clear phone number`),x=c.prop(t,`dropdownClass`,3,``),ae=c.prop(t,`disableDefaultStyles`,3,!1),k=c.rest_props(t,`$$slots.$$events.$$legacy.value.id.name.country.detect.locale.size.theme.disabled.readonly.showCopy.showClear.withValidity.searchPlaceholder.noResultsText.clearButtonLabel.dropdownClass.disableDefaultStyles.onchange.oncountrychange.onvalidationchange.onfocus.onblur.oncopy.onclear.flag.copysvg.clearsvg.actionsbefore.class`.split(`.`)),A=c.state(null),j=c.state(null),M=c.state(null),N=c.state(null),P=c.state(null),F=c.state(null),I=f({country:()=>t.country,locale:()=>t.locale,detect:()=>r(),onCountryChange:(...e)=>t.oncountrychange?.(...e)}),L=p({country:()=>I.country,value:()=>n(),onChange:e=>n(e),onPhoneChange:(...e)=>t.onchange?.(...e),onValidationChange:(...e)=>t.onvalidationchange?.(...e)}),R=h(),z=c.derived(()=>o()||s()),oe=c.derived(()=>R.showValidationHint&&L.shouldShowWarn),se=c.derived(()=>l()&&!L.isEmpty&&!o()),B=c.derived(()=>d()&&!L.isEmpty&&!c.get(z)),V=S({liveRef:()=>c.get(M),fullFormatted:()=>L.fullFormatted,onCopy:(...e)=>t.oncopy?.(...e)}),H=()=>(0,u.tick)().then(()=>c.get(j)?.focus()),U=y({rootRef:()=>c.get(A),dropdownRef:()=>c.get(N),searchRef:()=>c.get(P),selectorRef:()=>c.get(F),locale:()=>I.locale,countryOption:()=>t.country,inactive:()=>c.get(z),onSelectCountry:I.setCountry,onAfterSelect:H}),W=c.state(`0`);(0,u.onMount)(()=>{c.set(W,Math.random().toString(36).slice(2,10),!0)});let G=c.derived(()=>`pi-options-${c.get(W)}`),K=e=>`pi-option-${c.get(W)}-${e}`,ce=c.derived(()=>U.dropdownOpen&&U.filteredCountries[U.focusedIndex]?K(U.focusedIndex):void 0),q=v({formatter:()=>L.formatter,digits:()=>L.digits,inactive:()=>c.get(z),onChange:e=>n(e),scheduleValidationHint:R.scheduleValidationHint}),le=e=>{R.clearValidationHint(!1),U.closeDropdown(),t.onfocus?.(e)},ue=e=>t.onblur?.(e);function de(){H()}function fe(){c.get(j)?.blur()}function pe(){n(``),R.clearValidationHint(),t.onclear?.()}function me(e){I.setCountry(e)}function he(){return L.full}function ge(){return L.fullFormatted}function _e(){return L.digits}function ve(){return L.isComplete}function ye(){return L.isComplete}let be=()=>{pe(),H()},xe=C({theme:()=>a()}),Se=c.derived(()=>[`phone-input`,`size-${i()}`,xe.themeClass,o()&&`is-disabled`,s()&&`is-readonly`,ae()&&`is-unstyled`,m()&&c.get(oe)&&`is-incomplete`,m()&&L.isComplete&&`is-complete`,t.class].filter(Boolean).join(` `)),Ce=c.derived(()=>+c.get(se)+ +c.get(B)+ +!!t.actionsbefore);function we(e){return document.body.appendChild(e),{destroy:()=>e.remove()}}var Te={focus:de,blur:fe,clear:pe,selectCountry:me,getFullNumber:he,getFullFormattedNumber:ge,getDigits:_e,isValid:ve,isComplete:ye},Ee=ie(),J=c.first_child(Ee);c.attribute_effect(J,()=>({class:c.get(Se),...k,role:`group`,"aria-label":`Phone input with country selector`,[c.STYLE]:{"--pi-actions-count":c.get(Ce)}}));var Y=c.child(J),X=c.child(Y);let De;var Z=c.child(X),Oe=c.child(Z),ke=e=>{var n=c.comment(),r=c.first_child(n);c.snippet(r,()=>t.flag,()=>I.country),c.append(e,n)},Ae=e=>{var t=c.text();c.template_effect(()=>c.set_text(t,I.country.flag)),c.append(e,t)};c.if(Oe,e=>{t.flag?e(ke):e(Ae,-1)}),c.reset(Z);var Q=c.sibling(Z,2),je=c.child(Q,!0);c.reset(Q);var Me=c.sibling(Q,2),Ne=e=>{var t=ee();let n;c.template_effect(()=>n=c.set_class(t,0,`pi-chevron`,null,n,{"is-open":U.dropdownOpen})),c.append(e,t)};c.if(Me,e=>{!c.get(z)&&U.hasDropdown&&e(Ne)}),c.reset(X),c.reset(Y),c.bind_this(Y,e=>c.set(F,e),()=>c.get(F));var Pe=c.sibling(Y,2),$=c.child(Pe);c.remove_input_defaults($),c.bind_this($,e=>c.set(j,e),()=>c.get(j));var Fe=c.sibling($,2),Ie=c.child(Fe),Le=e=>{var n=c.comment(),r=c.first_child(n);c.snippet(r,()=>t.actionsbefore),c.append(e,n)};c.if(Ie,e=>{t.actionsbefore&&e(Le)});var Re=c.sibling(Ie,2),ze=e=>{var n=ne();let r;var i=c.child(n),a=e=>{var n=c.comment(),r=c.first_child(n);c.snippet(r,()=>t.copysvg,()=>V.copied),c.append(e,n)},o=e=>{var t=te();c.append(e,t)},s=e=>{var t=w();c.append(e,t)};c.if(i,e=>{t.copysvg?e(a):V.copied?e(o,1):e(s,-1)}),c.reset(n),c.template_effect(()=>{r=c.set_class(n,1,`pi-btn pi-btn-copy`,null,r,{"is-copied":V.copied}),c.set_attribute(n,`aria-label`,V.copyAriaLabel),c.set_attribute(n,`title`,V.copyButtonTitle)}),c.delegated(`click`,n,function(...e){V.onCopyClick?.apply(this,e)}),c.append(e,n)};c.if(Re,e=>{c.get(se)&&e(ze)});var Be=c.sibling(Re,2),Ve=e=>{var n=E(),r=c.child(n),i=e=>{var n=c.comment(),r=c.first_child(n);c.snippet(r,()=>t.clearsvg),c.append(e,n)},a=e=>{var t=T();c.append(e,t)};c.if(r,e=>{t.clearsvg?e(i):e(a,-1)}),c.reset(n),c.template_effect(()=>{c.set_attribute(n,`aria-label`,b()),c.set_attribute(n,`title`,b())}),c.delegated(`click`,n,be),c.append(e,n)};c.if(Be,e=>{c.get(B)&&e(Ve)}),c.reset(Fe),c.reset(Pe),c.reset(J),c.bind_this(J,e=>c.set(A,e),()=>c.get(A));var He=c.sibling(J,2),Ue=e=>{var n=O();let r,i;var a=c.child(n),o=c.child(a);c.remove_input_defaults(o),c.bind_this(o,e=>c.set(P,e),()=>c.get(P)),c.reset(a);var s=c.sibling(a,2);c.each(s,23,()=>U.filteredCountries,e=>e.id,(e,n,r)=>{var i=D();let a;var o=c.child(i),s=c.child(o),l=e=>{var r=c.comment(),i=c.first_child(r);c.snippet(i,()=>t.flag,()=>c.get(n)),c.append(e,r)},u=e=>{var t=c.text();c.template_effect(()=>c.set_text(t,c.get(n).flag)),c.append(e,t)};c.if(s,e=>{t.flag?e(l):e(u,-1)}),c.reset(o);var d=c.sibling(o,2),f=c.child(d,!0);c.reset(d);var p=c.sibling(d,2),m=c.child(p,!0);c.reset(p),c.reset(i),c.template_effect(e=>{c.set_attribute(i,`id`,e),a=c.set_class(i,1,`pi-option`,null,a,{"is-focused":c.get(r)===U.focusedIndex,"is-selected":c.get(n).id===I.country.id}),c.set_attribute(i,`aria-selected`,c.get(n).id===I.country.id),c.set_attribute(i,`title`,c.get(n).name),c.set_attribute(o,`aria-label`,`${c.get(n).name??``} flag`),c.set_text(f,c.get(n).name),c.set_text(m,c.get(n).code)},[()=>K(c.get(r))]),c.delegated(`click`,i,()=>U.selectCountry(c.get(n).id)),c.event(`mouseenter`,i,()=>U.setFocusedIndex(c.get(r))),c.append(e,i)},e=>{var t=re(),n=c.child(t,!0);c.reset(t),c.template_effect(()=>c.set_text(n,_())),c.append(e,t)}),c.reset(s),c.reset(n),c.action(n,e=>we?.(e)),c.bind_this(n,e=>c.set(N,e),()=>c.get(N)),c.template_effect(()=>{r=c.set_class(n,1,`phone-dropdown ${x()??``} ${xe.themeClass??``}`,null,r,{"is-closing":U.isClosing}),i=c.set_style(n,``,i,{position:`absolute`,top:U.dropdownStyle.top,left:U.dropdownStyle.left,width:U.dropdownStyle.width}),c.set_attribute(o,`placeholder`,g()),c.set_attribute(o,`aria-controls`,c.get(G)),c.set_attribute(o,`aria-activedescendant`,c.get(ce)),c.set_value(o,U.search),c.set_attribute(s,`id`,c.get(G))}),c.event(`animationend`,n,function(...e){U.handleDropdownAnimationEnd?.apply(this,e)}),c.delegated(`keydown`,o,function(...e){U.handleSearchKeydown?.apply(this,e)}),c.delegated(`input`,o,function(...e){U.handleSearchChange?.apply(this,e)}),c.append(e,n)};c.if(He,e=>{U.dropdownOpen&&e(Ue)});var We=c.sibling(He,2);return c.bind_this(We,e=>c.set(M,e),()=>c.get(M)),c.template_effect(()=>{De=c.set_class(X,1,`pi-selector-btn`,null,De,{"no-dropdown":!U.hasDropdown||s()}),X.disabled=o(),c.set_attribute(X,`tabindex`,c.get(z)||!U.hasDropdown?-1:void 0),c.set_attribute(X,`aria-label`,`Selected country: ${I.country.name??``}`),c.set_attribute(X,`aria-expanded`,U.dropdownOpen),c.set_attribute(X,`aria-haspopup`,U.hasDropdown?`listbox`:void 0),c.set_attribute(Z,`aria-label`,`${I.country.name??``} flag`),c.set_text(je,I.country.code),c.set_attribute($,`id`,t.id),c.set_attribute($,`name`,t.name),c.set_attribute($,`placeholder`,L.displayPlaceholder),c.set_value($,L.displayValue),$.disabled=o(),$.readOnly=s(),c.set_attribute($,`aria-invalid`,c.get(oe))}),c.delegated(`click`,X,function(...e){U.toggleDropdown?.apply(this,e)}),c.delegated(`beforeinput`,$,function(...e){q.handleBeforeInput?.apply(this,e)}),c.delegated(`input`,$,function(...e){q.handleInput?.apply(this,e)}),c.delegated(`keydown`,$,function(...e){q.handleKeydown?.apply(this,e)}),c.event(`paste`,$,function(...e){q.handlePaste?.apply(this,e)}),c.event(`focus`,$,le),c.event(`blur`,$,ue),c.append(e,Ee),c.pop(Te)}c.delegate([`click`,`beforeinput`,`input`,`keydown`]);function k(e){let t=l.state(null),n=f({country:e.country,locale:e.locale,detect:e.detect,onCountryChange:e.onCountryChange}),r=p({country:()=>n.country,value:e.value,onChange:e.onChange,onPhoneChange:e.onPhoneChange}),{handleBeforeInput:i,handleInput:a,handleKeydown:o,handlePaste:s}=v({formatter:()=>r.formatter,digits:()=>r.digits,onChange:e.onChange});return l.user_effect(()=>{let e=l.get(t);if(e)return e.setAttribute(`type`,`tel`),e.setAttribute(`inputmode`,`tel`),e.addEventListener(`beforeinput`,i),e.addEventListener(`input`,a),e.addEventListener(`keydown`,o),e.addEventListener(`paste`,s),()=>{e.removeEventListener(`beforeinput`,i),e.removeEventListener(`input`,a),e.removeEventListener(`keydown`,o),e.removeEventListener(`paste`,s)}}),l.user_effect(()=>{let e=l.get(t);e&&(e.value=r.displayValue,e.setAttribute(`placeholder`,r.displayPlaceholder))}),{get inputRef(){return l.get(t)},set inputRef(e){l.set(t,e,!0)},get digits(){return r.digits},get formatter(){return r.formatter},get full(){return r.full},get fullFormatted(){return r.fullFormatted},get isComplete(){return r.isComplete},get isEmpty(){return r.isEmpty},get shouldShowWarn(){return r.shouldShowWarn},get country(){return n.country},get locale(){return n.locale},setCountry:n.setCountry,clear:()=>{e.onChange(``)}}}function A(e){return typeof e==`string`?{country:e}:e&&typeof e==`object`?e:{}}function j(e){return t=>{if(t.tagName!==`INPUT`){console.warn(`[phoneMaskAttachment] Attachment can only be used on input elements`);return}let n=A(e),r=l.effect_root(()=>{let e=l.state(l.proxy(t.value||``)),r=k({country:()=>n.country,locale:()=>n.locale,detect:()=>n.detect,value:()=>l.get(e),onChange:t=>{l.set(e,t,!0)},onPhoneChange:n.onChange,onCountryChange:n.onCountryChange});r.inputRef=t,t.__phoneMaskState={get country(){return r.country},get formatter(){return r.formatter},get digits(){return r.digits},get locale(){return r.locale},options:n,setCountry:e=>r.setCountry(e)}});return()=>{r(),delete t.__phoneMaskState}}}function M(e){return typeof e==`string`?{country:e}:e&&typeof e==`object`?e:{}}function N(e,t,n){if(t.digits=n,e.value=t.formatter.formatDisplay(t.digits),t.options.onChange){let n=e.value?`${t.country.code} ${e.value}`:``,r=t.digits?`${t.country.code}${t.digits}`:``;t.options.onChange({full:r,fullFormatted:n,digits:t.digits})}}function P(e,t){let n=t.formatter.getMaxDigits(),r=(0,d.extractDigits)(e.value,n),i=t.formatter.formatDisplay(r);(r!==t.digits||e.value!==i)&&N(e,t,r)}function F(e){let t=e.country.id,n=(0,d.parseCountryCode)(e.options.country);n&&n!==t&&e.setCountry(n)}function I(e,t,n){return r=>{let i=n(r,t);i&&(N(e,t,i.newDigits),Promise.resolve().then(()=>{(0,d.setCaret)(e,t.formatter.getCaretPosition(i.caretDigitIndex))}))}}async function L(e){let t=(0,d.parseCountryCode)(e.country);if(t)return t;if(e.detect){let e=(0,d.parseCountryCode)(await(0,d.detectByGeoIp)());if(e)return e;let t=(0,d.parseCountryCode)((0,d.detectCountryFromLocale)());if(t)return t}return`US`}function R(e,t){if(e.tagName!==`INPUT`)return console.warn(`[phoneMaskAction] Action can only be used on input elements`),{update(){},destroy(){}};e.setAttribute(`type`,`tel`),e.setAttribute(`inputmode`,`tel`),e.setAttribute(`placeholder`,``);let n=M(t),r=n.locale||(0,d.getNavigatorLang)(),i=(0,d.getCountry)((0,d.parseCountryCode)(n.country,`US`),r),a={country:i,formatter:(0,d.createPhoneFormatter)(i),digits:``,locale:r,options:n,setCountry(t){let n=(0,d.parseCountryCode)(t);if(!n)return!1;let r=(0,d.getCountry)(n,this.locale);return this.country=r,this.options.onCountryChange?.(r),this.formatter=(0,d.createPhoneFormatter)(r),e.placeholder=this.formatter.getPlaceholder(),P(e,this),!0}};e.__phoneMaskState=a;let o=I(e,a,d.processInput),s=I(e,a,d.processKeydown),c=I(e,a,d.processPaste);return e.addEventListener(`beforeinput`,d.processBeforeInput),e.addEventListener(`input`,o),e.addEventListener(`keydown`,s),e.addEventListener(`paste`,c),L(n).then(t=>{e.__phoneMaskState===a&&a.setCountry(t)}),{update(t){a.options=M(t),F(a),P(e,a)},destroy(){e.removeEventListener(`beforeinput`,d.processBeforeInput),e.removeEventListener(`input`,o),e.removeEventListener(`keydown`,s),e.removeEventListener(`paste`,c),delete e.__phoneMaskState}}}var z=ae;exports.PhoneInput=z,exports.phoneMaskAction=R,exports.phoneMaskAttachment=j,exports.usePhoneMask=k;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{MasksFull as e,countPlaceholders as t,createPhoneFormatter as n,detectByGeoIp as r,detectCountryFromLocale as i,extractDigits as a,filterCountries as o,formatDigitsWithMap as s,getCountry as c,getFlagEmoji as l,getNavigatorLang as u,parseCountryCode as d,pickMaskVariant as f,processBeforeInput as p,processInput as m,processKeydown as h,processPaste as g,removeCountryCodePrefix as _,setCaret as v}from"@desource/phone-mask";import"svelte/internal/disclose-version";import*as y from"svelte/internal/client";import{onDestroy as b,onMount as x,tick as S}from"svelte";function C({country:e,locale:t,detect:n,onCountryChange:a}={}){let o=y.state(y.proxy(d(e?.(),`US`))),s=y.derived(()=>t?.()||u()),l=y.derived(()=>c(y.get(o),y.get(s))),f=e=>{let t=d(e);return t?(y.set(o,t,!0),!0):!1},p=async()=>{f(await r())||f(i())};return y.user_effect(()=>{let t=e?.();t&&t!==y.get(o)&&f(t)}),y.user_effect(()=>{n?.()&&!e?.()&&p()}),y.user_effect(()=>{a?.(y.get(l))}),{get country(){return y.get(l)},get locale(){return y.get(s)},setCountry:f}}function w({country:e,value:t,onChange:r,onPhoneChange:i,onValidationChange:o}){let s=y.derived(()=>n(e())),c=y.derived(()=>y.get(s).getMaxDigits()),l=y.derived(()=>a(t(),y.get(c))),u=y.derived(()=>y.get(s).getPlaceholder()),d=y.derived(()=>y.get(s).formatDisplay(y.get(l))),f=y.derived(()=>y.get(l)?`${e().code}${y.get(l)}`:``),p=y.derived(()=>y.get(d)?`${e().code} ${y.get(d)}`:``),m=y.derived(()=>y.get(s).isComplete(y.get(l))),h=y.derived(()=>y.get(l).length===0),g=y.derived(()=>!y.get(h)&&!y.get(m)),_=y.derived(()=>({full:y.get(f),fullFormatted:y.get(p),digits:y.get(l)}));return y.user_pre_effect(()=>{let e=t(),n=y.get(l);e!==n&&r(n)}),y.user_effect(()=>{i?.(y.get(_))}),y.user_effect(()=>{o?.(y.get(m))}),{get digits(){return y.get(l)},get formatter(){return y.get(s)},get displayPlaceholder(){return y.get(u)},get displayValue(){return y.get(d)},get full(){return y.get(f)},get fullFormatted(){return y.get(p)},get isComplete(){return y.get(m)},get isEmpty(){return y.get(h)},get shouldShowWarn(){return y.get(g)}}}function T(){let e=null,t=()=>{e&&=(clearTimeout(e),null)};return b(t),{set:(n,r)=>{t(),e=setTimeout(n,r)},clear:t}}function E(){let e=y.state(!1),t=T();return{get showValidationHint(){return y.get(e)},clearValidationHint:(n=!0)=>{n&&y.set(e,!1),t.clear()},scheduleValidationHint:n=>{y.set(e,!1),t.set(()=>{y.set(e,!0)},n)}}}var D=500,O=300;function k(e){let{formatter:t,digits:n,inactive:r,onChange:i,scheduleValidationHint:a}=e,o=(e,n)=>{S().then(()=>{e&&v(e,t().getCaretPosition(n))})};return{handleBeforeInput:e=>{p(e)},handleInput:e=>{if(r?.())return;let n=m(e,{formatter:t()});n&&(i?.(n.newDigits),o(e.target,n.caretDigitIndex),a?.(D))},handleKeydown:e=>{if(r?.())return;let s=h(e,{digits:n(),formatter:t()});s&&(i?.(s.newDigits),o(e.target,s.caretDigitIndex),a?.(O))},handlePaste:e=>{if(r?.())return;let s=g(e,{digits:n(),formatter:t()});s&&(i?.(s.newDigits),o(e.target,s.caretDigitIndex),a?.(O))}}}function A({rootRef:t,dropdownRef:n,searchRef:r,selectorRef:i,locale:a,countryOption:s,inactive:c,onSelectCountry:l,onAfterSelect:u}){let d=y.state(``),f=y.state(!1),p=y.state(!1),m=y.state(y.proxy({})),h=y.state(0),g=y.derived(()=>e(a())),_=y.derived(()=>o(y.get(g),y.get(d))),v=y.derived(()=>!s?.()&&y.get(g).length>1),x=e=>{y.set(h,e,!0)},C=()=>{S().then(()=>r()?.focus({preventScroll:!0}))},w=()=>{y.get(f)&&y.set(p,!0)},T=()=>{y.set(p,!1),y.set(f,!0),x(0),C()},E=()=>{y.get(p)&&(y.set(f,!1),y.set(p,!1))},D=()=>{c?.()||!y.get(v)||(y.get(f)?w():T())},O=e=>{l(e),w(),y.set(d,``),x(0),u?.()},k=e=>{y.set(d,e.target.value,!0),x(0)},A=e=>{let t=e.target,r=n(),a=i();t&&(r?.contains(t)||a?.contains(t)||w())},j=e=>{if(e?.type===`scroll`&&e.target&&n()?.contains(e.target))return;let r=t();if(!r)return;let i=r.getBoundingClientRect();y.set(m,{top:`${i.bottom+globalThis.scrollY+8}px`,left:`${i.left+globalThis.scrollX}px`,width:`${i.width}px`},!0)},M=()=>{S().then(()=>{let e=n()?.lastElementChild,t=e?.children[y.get(h)];if(!e||!t)return;let r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a=0;if(i.top<r.top)a=e.scrollTop-(r.top-i.top);else if(i.bottom>r.bottom)a=e.scrollTop+(i.bottom-r.bottom);else return;e.scrollTo({top:a,behavior:`smooth`})})},N=e=>{e.key===`ArrowDown`?(e.preventDefault(),x(Math.min(y.get(h)+1,y.get(_).length-1)),M()):e.key===`ArrowUp`?(e.preventDefault(),x(Math.max(y.get(h)-1,0)),M()):e.key===`Enter`&&y.get(_)[y.get(h)]?(e.preventDefault(),O(y.get(_)[y.get(h)].id)):e.key===`Escape`&&w()},P=()=>{globalThis.removeEventListener(`resize`,j),globalThis.removeEventListener(`scroll`,j,!0),globalThis.removeEventListener(`click`,A,!0)};return y.user_effect(()=>{!y.get(v)&&y.get(f)&&w()}),y.user_effect(()=>{if(!y.get(f)){P();return}j(),globalThis.addEventListener(`resize`,j),globalThis.addEventListener(`scroll`,j,!0),globalThis.addEventListener(`click`,A,!0)}),b(P),{get dropdownOpen(){return y.get(f)},get isClosing(){return y.get(p)},get search(){return y.get(d)},get focusedIndex(){return y.get(h)},get dropdownStyle(){return y.get(m)},get filteredCountries(){return y.get(_)},get hasDropdown(){return y.get(v)},openDropdown:T,closeDropdown:w,toggleDropdown:D,selectCountry:O,setFocusedIndex:x,handleSearchChange:k,handleSearchKeydown:N,handleDropdownAnimationEnd:E}}function j(e=1800){let t=y.state(!1),n=y.state(!1),r=T();return{get copied(){return y.get(t)},get isCopying(){return y.get(n)},copy:async i=>{if(y.get(n))return!1;let a=i.trim();if(!a)return!1;y.set(n,!0);try{return await navigator.clipboard.writeText(a),y.set(t,!0),r.set(()=>{y.set(t,!1)},e),!0}catch(e){return console.warn(`Copy failed`,e),!1}finally{y.set(n,!1)}}}}var M=1800;function N({liveRef:e,fullFormatted:t,onCopy:n}){let r=T(),i=j(M),a=y.derived(()=>i.copied?`Copied`:`Copy ${t()}`),o=y.derived(()=>i.copied?`Copied`:`Copy phone number`),s=t=>{let n=e?.();n&&(n.textContent=t,r.set(()=>{let t=e?.();t&&(t.textContent=``)},M))};return{get copied(){return i.copied},get copyAriaLabel(){return y.get(a)},get copyButtonTitle(){return y.get(o)},onCopyClick:async()=>{let e=t().trim();await i.copy(e)&&(n?.(e),s(`Phone number copied to clipboard`))}}}function P({theme:e}){let t=y.state(!1),n=y.derived(()=>(()=>{let n=e();return n===`auto`?y.get(t)?`theme-dark`:`theme-light`:`theme-${n}`})());return y.user_effect(()=>{let e=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`)??null;if(!e)return;y.set(t,e.matches,!0);let n=e=>{y.set(t,e.matches,!0)};return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)}),{get themeClass(){return y.get(n)}}}var ee=y.from_svg(`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true"><path d="M2.5 4.5L6 8L9.5 4.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>`),te=y.from_svg(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M6.5 11.5L3 8L4.06 6.94L6.5 9.38L11.94 3.94L13 5L6.5 11.5Z" fill="currentColor"></path></svg>`),ne=y.from_svg(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M13.5 5.5V13.5H5.5V5.5H13.5ZM13.5 4H5.5C4.67 4 4 4.67 4 5.5V13.5C4 14.33 4.67 15 5.5 15H13.5C14.33 15 15 14.33 15 13.5V5.5C15 4.67 14.33 4 13.5 4ZM10.5 1H2.5V11H4V2.5H10.5V1Z" fill="currentColor"></path></svg>`),re=y.from_html(`<button type="button"><!></button>`),ie=y.from_svg(`<svg width="11" height="11" viewBox="0 0 14 14" fill="none" aria-hidden="true"><path d="M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z" fill="currentColor"></path></svg>`),ae=y.from_html(`<button type="button" class="pi-btn pi-btn-clear"><!></button>`),oe=y.from_html(`<li role="option"><span class="pi-flag" role="img"><!></span> <span class="pi-opt-name"> </span> <span class="pi-opt-code"> </span></li>`),se=y.from_html(`<li class="pi-empty"> </li>`),ce=y.from_html(`<div role="dialog" aria-modal="false" aria-label="Select country"><div class="pi-search-wrap"><input type="search" class="pi-search" aria-label="Search countries"/></div> <ul class="pi-options" role="listbox" tabindex="-1"></ul></div>`),le=y.from_html(`<div><div class="pi-selector"><button type="button"><span class="pi-flag" role="img"><!></span> <span class="pi-code"> </span> <!></button></div> <div class="pi-input-wrap"><input type="tel" inputmode="tel" autocomplete="tel-national" autocorrect="off" autocapitalize="off" spellcheck="false" class="pi-input"/> <div class="pi-actions" role="toolbar" aria-label="Phone input actions"><!> <!> <!></div></div></div> <!> <div class="sr-only" role="status" aria-live="polite" aria-atomic="true"></div>`,1);function F(e,t){y.push(t,!0);let n=y.prop(t,`value`,15,``),r=y.prop(t,`detect`,3,!0),i=y.prop(t,`size`,3,`normal`),a=y.prop(t,`theme`,3,`auto`),o=y.prop(t,`disabled`,3,!1),s=y.prop(t,`readonly`,3,!1),c=y.prop(t,`showCopy`,3,!0),l=y.prop(t,`showClear`,3,!1),u=y.prop(t,`withValidity`,3,!0),d=y.prop(t,`searchPlaceholder`,3,`Search country or code...`),f=y.prop(t,`noResultsText`,3,`No countries found`),p=y.prop(t,`clearButtonLabel`,3,`Clear phone number`),m=y.prop(t,`dropdownClass`,3,``),h=y.prop(t,`disableDefaultStyles`,3,!1),g=y.rest_props(t,`$$slots.$$events.$$legacy.value.country.detect.locale.size.theme.disabled.readonly.showCopy.showClear.withValidity.searchPlaceholder.noResultsText.clearButtonLabel.dropdownClass.disableDefaultStyles.onchange.oncountrychange.onvalidationchange.onfocus.onblur.oncopy.onclear.flag.copysvg.clearsvg.actionsbefore.class`.split(`.`)),_=y.state(null),v=y.state(null),b=y.state(null),T=y.state(null),D=y.state(null),O=y.state(null),j=C({country:()=>t.country,locale:()=>t.locale,detect:()=>r(),onCountryChange:(...e)=>t.oncountrychange?.(...e)}),M=w({country:()=>j.country,value:()=>n(),onChange:e=>n(e),onPhoneChange:(...e)=>t.onchange?.(...e),onValidationChange:(...e)=>t.onvalidationchange?.(...e)}),F=E(),I=y.derived(()=>o()||s()),L=y.derived(()=>F.showValidationHint&&M.shouldShowWarn),R=y.derived(()=>c()&&!M.isEmpty&&!o()),z=y.derived(()=>l()&&!M.isEmpty&&!y.get(I)),B=N({liveRef:()=>y.get(b),fullFormatted:()=>M.fullFormatted,onCopy:(...e)=>t.oncopy?.(...e)}),V=()=>S().then(()=>y.get(v)?.focus()),H=A({rootRef:()=>y.get(_),dropdownRef:()=>y.get(T),searchRef:()=>y.get(D),selectorRef:()=>y.get(O),locale:()=>j.locale,countryOption:()=>t.country,inactive:()=>y.get(I),onSelectCountry:j.setCountry,onAfterSelect:V}),U=y.state(`0`);x(()=>{y.set(U,Math.random().toString(36).slice(2,10),!0)});let W=y.derived(()=>`pi-options-${y.get(U)}`),G=e=>`pi-option-${y.get(U)}-${e}`,ue=y.derived(()=>H.dropdownOpen&&H.filteredCountries[H.focusedIndex]?G(H.focusedIndex):void 0),K=k({formatter:()=>M.formatter,digits:()=>M.digits,inactive:()=>y.get(I),onChange:e=>n(e),scheduleValidationHint:F.scheduleValidationHint}),de=e=>{F.clearValidationHint(!1),H.closeDropdown(),t.onfocus?.(e)},fe=e=>t.onblur?.(e);function pe(){V()}function me(){y.get(v)?.blur()}function he(){n(``),F.clearValidationHint(),t.onclear?.()}function ge(e){j.setCountry(e)}function _e(){return M.full}function ve(){return M.fullFormatted}function ye(){return M.digits}function be(){return M.isComplete}function xe(){return M.isComplete}let Se=()=>{he(),V()},Ce=P({theme:()=>a()}),we=y.derived(()=>[`phone-input`,`size-${i()}`,Ce.themeClass,o()&&`is-disabled`,s()&&`is-readonly`,h()&&`is-unstyled`,u()&&y.get(L)&&`is-incomplete`,u()&&M.isComplete&&`is-complete`,t.class].filter(Boolean).join(` `)),Te=y.derived(()=>+y.get(R)+ +y.get(z)+(t.actionsbefore?1:0));function Ee(e){return document.body.appendChild(e),{destroy:()=>e.remove()}}var De={focus:pe,blur:me,clear:he,selectCountry:ge,getFullNumber:_e,getFullFormattedNumber:ve,getDigits:ye,isValid:be,isComplete:xe},Oe=le(),q=y.first_child(Oe);y.attribute_effect(q,()=>({class:y.get(we),...g,role:`group`,"aria-label":`Phone input with country selector`,[y.STYLE]:{"--pi-actions-count":y.get(Te)}}));var J=y.child(q),Y=y.child(J);let ke;var X=y.child(Y),Ae=y.child(X),je=e=>{var n=y.comment(),r=y.first_child(n);y.snippet(r,()=>t.flag,()=>j.country),y.append(e,n)},Me=e=>{var t=y.text();y.template_effect(()=>y.set_text(t,j.country.flag)),y.append(e,t)};y.if(Ae,e=>{t.flag?e(je):e(Me,-1)}),y.reset(X);var Z=y.sibling(X,2),Ne=y.child(Z,!0);y.reset(Z);var Pe=y.sibling(Z,2),Fe=e=>{var t=ee();let n;y.template_effect(()=>n=y.set_class(t,0,`pi-chevron`,null,n,{"is-open":H.dropdownOpen})),y.append(e,t)};y.if(Pe,e=>{!y.get(I)&&H.hasDropdown&&e(Fe)}),y.reset(Y),y.reset(J),y.bind_this(J,e=>y.set(O,e),()=>y.get(O));var Ie=y.sibling(J,2),Q=y.child(Ie);y.remove_input_defaults(Q),y.bind_this(Q,e=>y.set(v,e),()=>y.get(v));var Le=y.sibling(Q,2),Re=y.child(Le),ze=e=>{var n=y.comment(),r=y.first_child(n);y.snippet(r,()=>t.actionsbefore),y.append(e,n)};y.if(Re,e=>{t.actionsbefore&&e(ze)});var Be=y.sibling(Re,2),Ve=e=>{var n=re();let r;var i=y.child(n),a=e=>{var n=y.comment(),r=y.first_child(n);y.snippet(r,()=>t.copysvg,()=>B.copied),y.append(e,n)},o=e=>{var t=te();y.append(e,t)},s=e=>{var t=ne();y.append(e,t)};y.if(i,e=>{t.copysvg?e(a):B.copied?e(o,1):e(s,-1)}),y.reset(n),y.template_effect(()=>{r=y.set_class(n,1,`pi-btn pi-btn-copy`,null,r,{"is-copied":B.copied}),y.set_attribute(n,`aria-label`,B.copyAriaLabel),y.set_attribute(n,`title`,B.copyButtonTitle)}),y.delegated(`click`,n,function(...e){B.onCopyClick?.apply(this,e)}),y.append(e,n)};y.if(Be,e=>{y.get(R)&&e(Ve)});var He=y.sibling(Be,2),Ue=e=>{var n=ae(),r=y.child(n),i=e=>{var n=y.comment(),r=y.first_child(n);y.snippet(r,()=>t.clearsvg),y.append(e,n)},a=e=>{var t=ie();y.append(e,t)};y.if(r,e=>{t.clearsvg?e(i):e(a,-1)}),y.reset(n),y.template_effect(()=>{y.set_attribute(n,`aria-label`,p()),y.set_attribute(n,`title`,p())}),y.delegated(`click`,n,Se),y.append(e,n)};y.if(He,e=>{y.get(z)&&e(Ue)}),y.reset(Le),y.reset(Ie),y.reset(q),y.bind_this(q,e=>y.set(_,e),()=>y.get(_));var $=y.sibling(q,2),We=e=>{var n=ce();let r,i;var a=y.child(n),o=y.child(a);y.remove_input_defaults(o),y.bind_this(o,e=>y.set(D,e),()=>y.get(D)),y.reset(a);var s=y.sibling(a,2);y.each(s,23,()=>H.filteredCountries,e=>e.id,(e,n,r)=>{var i=oe();let a;var o=y.child(i),s=y.child(o),c=e=>{var r=y.comment(),i=y.first_child(r);y.snippet(i,()=>t.flag,()=>y.get(n)),y.append(e,r)},l=e=>{var t=y.text();y.template_effect(()=>y.set_text(t,y.get(n).flag)),y.append(e,t)};y.if(s,e=>{t.flag?e(c):e(l,-1)}),y.reset(o);var u=y.sibling(o,2),d=y.child(u,!0);y.reset(u);var f=y.sibling(u,2),p=y.child(f,!0);y.reset(f),y.reset(i),y.template_effect(e=>{y.set_attribute(i,`id`,e),a=y.set_class(i,1,`pi-option`,null,a,{"is-focused":y.get(r)===H.focusedIndex,"is-selected":y.get(n).id===j.country.id}),y.set_attribute(i,`aria-selected`,y.get(n).id===j.country.id),y.set_attribute(i,`title`,y.get(n).name),y.set_attribute(o,`aria-label`,`${y.get(n).name??``} flag`),y.set_text(d,y.get(n).name),y.set_text(p,y.get(n).code)},[()=>G(y.get(r))]),y.delegated(`click`,i,()=>H.selectCountry(y.get(n).id)),y.event(`mouseenter`,i,()=>H.setFocusedIndex(y.get(r))),y.append(e,i)},e=>{var t=se(),n=y.child(t,!0);y.reset(t),y.template_effect(()=>y.set_text(n,f())),y.append(e,t)}),y.reset(s),y.reset(n),y.action(n,e=>Ee?.(e)),y.bind_this(n,e=>y.set(T,e),()=>y.get(T)),y.template_effect(()=>{r=y.set_class(n,1,`phone-dropdown ${m()??``} ${Ce.themeClass??``}`,null,r,{"is-closing":H.isClosing}),i=y.set_style(n,``,i,{position:`absolute`,top:H.dropdownStyle.top,left:H.dropdownStyle.left,width:H.dropdownStyle.width}),y.set_attribute(o,`placeholder`,d()),y.set_attribute(o,`aria-controls`,y.get(W)),y.set_attribute(o,`aria-activedescendant`,y.get(ue)),y.set_value(o,H.search),y.set_attribute(s,`id`,y.get(W))}),y.event(`animationend`,n,function(...e){H.handleDropdownAnimationEnd?.apply(this,e)}),y.delegated(`keydown`,o,function(...e){H.handleSearchKeydown?.apply(this,e)}),y.delegated(`input`,o,function(...e){H.handleSearchChange?.apply(this,e)}),y.append(e,n)};y.if($,e=>{H.dropdownOpen&&e(We)});var Ge=y.sibling($,2);return y.bind_this(Ge,e=>y.set(b,e),()=>y.get(b)),y.template_effect(()=>{ke=y.set_class(Y,1,`pi-selector-btn`,null,ke,{"no-dropdown":!H.hasDropdown||s()}),Y.disabled=o(),y.set_attribute(Y,`tabindex`,y.get(I)||!H.hasDropdown?-1:void 0),y.set_attribute(Y,`aria-label`,`Selected country: ${j.country.name??``}`),y.set_attribute(Y,`aria-expanded`,H.dropdownOpen),y.set_attribute(Y,`aria-haspopup`,H.hasDropdown?`listbox`:void 0),y.set_attribute(X,`aria-label`,`${j.country.name??``} flag`),y.set_text(Ne,j.country.code),y.set_attribute(Q,`placeholder`,M.displayPlaceholder),y.set_value(Q,M.displayValue),Q.disabled=o(),Q.readOnly=s(),y.set_attribute(Q,`aria-invalid`,y.get(L))}),y.delegated(`click`,Y,function(...e){H.toggleDropdown?.apply(this,e)}),y.delegated(`beforeinput`,Q,function(...e){K.handleBeforeInput?.apply(this,e)}),y.delegated(`input`,Q,function(...e){K.handleInput?.apply(this,e)}),y.delegated(`keydown`,Q,function(...e){K.handleKeydown?.apply(this,e)}),y.event(`paste`,Q,function(...e){K.handlePaste?.apply(this,e)}),y.event(`focus`,Q,de),y.event(`blur`,Q,fe),y.append(e,Oe),y.pop(De)}y.delegate([`click`,`beforeinput`,`input`,`keydown`]);function I(e){let t=y.state(null),n=C({country:e.country,locale:e.locale,detect:e.detect,onCountryChange:e.onCountryChange}),r=w({country:()=>n.country,value:e.value,onChange:e.onChange,onPhoneChange:e.onPhoneChange}),{handleBeforeInput:i,handleInput:a,handleKeydown:o,handlePaste:s}=k({formatter:()=>r.formatter,digits:()=>r.digits,onChange:e.onChange});return y.user_effect(()=>{let e=y.get(t);if(e)return e.setAttribute(`type`,`tel`),e.setAttribute(`inputmode`,`tel`),e.addEventListener(`beforeinput`,i),e.addEventListener(`input`,a),e.addEventListener(`keydown`,o),e.addEventListener(`paste`,s),()=>{e.removeEventListener(`beforeinput`,i),e.removeEventListener(`input`,a),e.removeEventListener(`keydown`,o),e.removeEventListener(`paste`,s)}}),y.user_effect(()=>{let e=y.get(t);e&&(e.value=r.displayValue,e.setAttribute(`placeholder`,r.displayPlaceholder))}),{get inputRef(){return y.get(t)},set inputRef(e){y.set(t,e,!0)},get digits(){return r.digits},get formatter(){return r.formatter},get full(){return r.full},get fullFormatted(){return r.fullFormatted},get isComplete(){return r.isComplete},get isEmpty(){return r.isEmpty},get shouldShowWarn(){return r.shouldShowWarn},get country(){return n.country},get locale(){return n.locale},setCountry:n.setCountry,clear:()=>{e.onChange(``)}}}function L(e){return typeof e==`string`?{country:e}:e&&typeof e==`object`?e:{}}function R(e){return t=>{if(t.tagName!==`INPUT`){console.warn(`[phoneMaskAttachment] Attachment can only be used on input elements`);return}let n=L(e),r=y.effect_root(()=>{let e=y.state(y.proxy(t.value||``)),r=I({country:()=>n.country,locale:()=>n.locale,detect:()=>n.detect,value:()=>y.get(e),onChange:t=>{y.set(e,t,!0)},onPhoneChange:n.onChange,onCountryChange:n.onCountryChange});r.inputRef=t,t.__phoneMaskState={get country(){return r.country},get formatter(){return r.formatter},get digits(){return r.digits},get locale(){return r.locale},options:n,setCountry:e=>r.setCountry(e)}});return()=>{r(),delete t.__phoneMaskState}}}function z(e){return typeof e==`string`?{country:e}:e&&typeof e==`object`?e:{}}function B(e,t,n){if(t.digits=n,e.value=t.formatter.formatDisplay(t.digits),t.options.onChange){let n=e.value?`${t.country.code} ${e.value}`:``,r=t.digits?`${t.country.code}${t.digits}`:``;t.options.onChange({full:r,fullFormatted:n,digits:t.digits})}}function V(e,t){let n=t.formatter.getMaxDigits(),r=a(e.value,n),i=t.formatter.formatDisplay(r);(r!==t.digits||e.value!==i)&&B(e,t,r)}function H(e){let t=e.country.id,n=d(e.options.country);n&&n!==t&&e.setCountry(n)}function U(e,t,n){return r=>{let i=n(r,t);i&&(B(e,t,i.newDigits),Promise.resolve().then(()=>{v(e,t.formatter.getCaretPosition(i.caretDigitIndex))}))}}async function W(e){let t=d(e.country);if(t)return t;if(e.detect){let e=d(await r());if(e)return e;let t=d(i());if(t)return t}return`US`}function G(e,t){if(e.tagName!==`INPUT`)return console.warn(`[phoneMaskAction] Action can only be used on input elements`),{update(){},destroy(){}};e.setAttribute(`type`,`tel`),e.setAttribute(`inputmode`,`tel`),e.setAttribute(`placeholder`,``);let r=z(t),i=r.locale||u(),a=c(d(r.country,`US`),i),o={country:a,formatter:n(a),digits:``,locale:i,options:r,setCountry(t){let r=d(t);if(!r)return!1;let i=c(r,this.locale);return this.country=i,this.options.onCountryChange?.(i),this.formatter=n(i),e.placeholder=this.formatter.getPlaceholder(),V(e,this),!0}};e.__phoneMaskState=o;let s=U(e,o,m),l=U(e,o,h),f=U(e,o,g);return e.addEventListener(`beforeinput`,p),e.addEventListener(`input`,s),e.addEventListener(`keydown`,l),e.addEventListener(`paste`,f),W(r).then(t=>{e.__phoneMaskState===o&&o.setCountry(t)}),{update(t){o.options=z(t),H(o),V(e,o)},destroy(){e.removeEventListener(`beforeinput`,p),e.removeEventListener(`input`,s),e.removeEventListener(`keydown`,l),e.removeEventListener(`paste`,f),delete e.__phoneMaskState}}}var ue=F,K={getFlagEmoji:l,countPlaceholders:t,formatDigitsWithMap:s,pickMaskVariant:f,removeCountryCodePrefix:_};export{K as PMaskHelpers,ue as PhoneInput,G as phoneMaskAction,R as phoneMaskAttachment,I as usePhoneMask};
1
+ import"svelte/internal/disclose-version";import*as e from"svelte/internal/client";import{onDestroy as t,onMount as n,tick as r}from"svelte";import{MasksFull as i,createPhoneFormatter as a,detectByGeoIp as o,detectCountryFromLocale as s,extractDigits as c,filterCountries as l,getCountry as u,getNavigatorLang as d,parseCountryCode as f,processBeforeInput as p,processInput as m,processKeydown as h,processPaste as g,setCaret as _}from"@desource/phone-mask";function v({country:t,locale:n,detect:r,onCountryChange:i}={}){let a=e.state(e.proxy(f(t?.(),`US`))),c=e.derived(()=>n?.()||d()),l=e.derived(()=>u(e.get(a),e.get(c))),p=t=>{let n=f(t);return n?(e.set(a,n,!0),!0):!1},m=async()=>{p(await o())||p(s())};return e.user_effect(()=>{let n=t?.();n&&n!==e.get(a)&&p(n)}),e.user_effect(()=>{r?.()&&!t?.()&&m()}),e.user_effect(()=>{i?.(e.get(l))}),{get country(){return e.get(l)},get locale(){return e.get(c)},setCountry:p}}function y({country:t,value:n,onChange:r,onPhoneChange:i,onValidationChange:o}){let s=e.derived(()=>a(t())),l=e.derived(()=>e.get(s).getMaxDigits()),u=e.derived(()=>c(n(),e.get(l))),d=e.derived(()=>e.get(s).getPlaceholder()),f=e.derived(()=>e.get(s).formatDisplay(e.get(u))),p=e.derived(()=>e.get(u)?`${t().code}${e.get(u)}`:``),m=e.derived(()=>e.get(f)?`${t().code} ${e.get(f)}`:``),h=e.derived(()=>e.get(s).isComplete(e.get(u))),g=e.derived(()=>e.get(u).length===0),_=e.derived(()=>!e.get(g)&&!e.get(h)),v=e.derived(()=>({full:e.get(p),fullFormatted:e.get(m),digits:e.get(u)}));return e.user_pre_effect(()=>{let t=n(),i=e.get(u);t!==i&&r(i)}),e.user_effect(()=>{i?.(e.get(v))}),e.user_effect(()=>{o?.(e.get(h))}),{get digits(){return e.get(u)},get formatter(){return e.get(s)},get displayPlaceholder(){return e.get(d)},get displayValue(){return e.get(f)},get full(){return e.get(p)},get fullFormatted(){return e.get(m)},get isComplete(){return e.get(h)},get isEmpty(){return e.get(g)},get shouldShowWarn(){return e.get(_)}}}function b(){let e=null,n=()=>{e&&=(clearTimeout(e),null)};return t(n),{set:(t,r)=>{n(),e=setTimeout(t,r)},clear:n}}function x(){let t=e.state(!1),n=b();return{get showValidationHint(){return e.get(t)},clearValidationHint:(r=!0)=>{r&&e.set(t,!1),n.clear()},scheduleValidationHint:r=>{e.set(t,!1),n.set(()=>{e.set(t,!0)},r)}}}var S=500,C=300;function w(e){let{formatter:t,digits:n,inactive:i,onChange:a,scheduleValidationHint:o}=e,s=(e,n)=>{r().then(()=>{e&&_(e,t().getCaretPosition(n))})};return{handleBeforeInput:e=>{p(e)},handleInput:e=>{if(i?.())return;let n=m(e,{formatter:t()});n&&(a?.(n.newDigits),s(e.target,n.caretDigitIndex),o?.(S))},handleKeydown:e=>{if(i?.())return;let r=h(e,{digits:n(),formatter:t()});r&&(a?.(r.newDigits),s(e.target,r.caretDigitIndex),o?.(C))},handlePaste:e=>{if(i?.())return;let r=g(e,{digits:n(),formatter:t()});r&&(a?.(r.newDigits),s(e.target,r.caretDigitIndex),o?.(C))}}}function T({rootRef:n,dropdownRef:a,searchRef:o,selectorRef:s,locale:c,countryOption:u,inactive:d,onSelectCountry:f,onAfterSelect:p}){let m=e.state(``),h=e.state(!1),g=e.state(!1),_=e.state(e.proxy({})),v=e.state(0),y=e.derived(()=>i(c())),b=e.derived(()=>l(e.get(y),e.get(m))),x=e.derived(()=>!u?.()&&e.get(y).length>1),S=t=>{e.set(v,t,!0)},C=()=>{r().then(()=>o()?.focus({preventScroll:!0}))},w=()=>{e.get(h)&&e.set(g,!0)},T=()=>{e.set(g,!1),e.set(h,!0),S(0),C()},E=()=>{e.get(g)&&(e.set(h,!1),e.set(g,!1))},D=()=>{d?.()||!e.get(x)||(e.get(h)?w():T())},O=t=>{f(t),w(),e.set(m,``),S(0),p?.()},ee=t=>{e.set(m,t.target.value,!0),S(0)},k=e=>{let t=e.target,n=a(),r=s();t&&(n?.contains(t)||r?.contains(t)||w())},A=t=>{if(t?.type===`scroll`&&t.target&&a()?.contains(t.target))return;let r=n();if(!r)return;let i=r.getBoundingClientRect();e.set(_,{top:`${i.bottom+globalThis.scrollY+8}px`,left:`${i.left+globalThis.scrollX}px`,width:`${i.width}px`},!0)},j=()=>{r().then(()=>{let t=a()?.lastElementChild,n=t?.children[e.get(v)];if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),o=0;if(i.top<r.top)o=t.scrollTop-(r.top-i.top);else if(i.bottom>r.bottom)o=t.scrollTop+(i.bottom-r.bottom);else return;t.scrollTo({top:o,behavior:`smooth`})})},te=t=>{t.key===`ArrowDown`?(t.preventDefault(),S(Math.min(e.get(v)+1,e.get(b).length-1)),j()):t.key===`ArrowUp`?(t.preventDefault(),S(Math.max(e.get(v)-1,0)),j()):t.key===`Enter`&&e.get(b)[e.get(v)]?(t.preventDefault(),O(e.get(b)[e.get(v)].id)):t.key===`Escape`&&w()},M=()=>{globalThis.removeEventListener(`resize`,A),globalThis.removeEventListener(`scroll`,A,!0),globalThis.removeEventListener(`click`,k,!0)};return e.user_effect(()=>{!e.get(x)&&e.get(h)&&w()}),e.user_effect(()=>{if(!e.get(h)){M();return}A(),globalThis.addEventListener(`resize`,A),globalThis.addEventListener(`scroll`,A,!0),globalThis.addEventListener(`click`,k,!0)}),t(M),{get dropdownOpen(){return e.get(h)},get isClosing(){return e.get(g)},get search(){return e.get(m)},get focusedIndex(){return e.get(v)},get dropdownStyle(){return e.get(_)},get filteredCountries(){return e.get(b)},get hasDropdown(){return e.get(x)},openDropdown:T,closeDropdown:w,toggleDropdown:D,selectCountry:O,setFocusedIndex:S,handleSearchChange:ee,handleSearchKeydown:te,handleDropdownAnimationEnd:E}}function E(t=1800){let n=e.state(!1),r=e.state(!1),i=b();return{get copied(){return e.get(n)},get isCopying(){return e.get(r)},copy:async a=>{if(e.get(r))return!1;let o=a.trim();if(!o)return!1;e.set(r,!0);try{return await navigator.clipboard.writeText(o),e.set(n,!0),i.set(()=>{e.set(n,!1)},t),!0}catch(e){return console.warn(`Copy failed`,e),!1}finally{e.set(r,!1)}}}}var D=1800;function O({liveRef:t,fullFormatted:n,onCopy:r}){let i=b(),a=E(D),o=e.derived(()=>a.copied?`Copied`:`Copy ${n()}`),s=e.derived(()=>a.copied?`Copied`:`Copy phone number`),c=e=>{let n=t?.();n&&(n.textContent=e,i.set(()=>{let e=t?.();e&&(e.textContent=``)},D))};return{get copied(){return a.copied},get copyAriaLabel(){return e.get(o)},get copyButtonTitle(){return e.get(s)},onCopyClick:async()=>{let e=n().trim();await a.copy(e)&&(r?.(e),c(`Phone number copied to clipboard`))}}}function ee({theme:t}){let n=e.state(!1),r=e.derived(()=>(()=>{let r=t();return r===`auto`?e.get(n)?`theme-dark`:`theme-light`:`theme-${r}`})());return e.user_effect(()=>{let t=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`)??null;if(!t)return;e.set(n,t.matches,!0);let r=t=>{e.set(n,t.matches,!0)};return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)}),{get themeClass(){return e.get(r)}}}var k=e.from_svg(`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true"><path d="M2.5 4.5L6 8L9.5 4.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>`),A=e.from_svg(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M6.5 11.5L3 8L4.06 6.94L6.5 9.38L11.94 3.94L13 5L6.5 11.5Z" fill="currentColor"></path></svg>`),j=e.from_svg(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M13.5 5.5V13.5H5.5V5.5H13.5ZM13.5 4H5.5C4.67 4 4 4.67 4 5.5V13.5C4 14.33 4.67 15 5.5 15H13.5C14.33 15 15 14.33 15 13.5V5.5C15 4.67 14.33 4 13.5 4ZM10.5 1H2.5V11H4V2.5H10.5V1Z" fill="currentColor"></path></svg>`),te=e.from_html(`<button type="button"><!></button>`),M=e.from_svg(`<svg width="11" height="11" viewBox="0 0 14 14" fill="none" aria-hidden="true"><path d="M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z" fill="currentColor"></path></svg>`),ne=e.from_html(`<button type="button" class="pi-btn pi-btn-clear"><!></button>`),re=e.from_html(`<li role="option"><span class="pi-flag" role="img"><!></span> <span class="pi-opt-name"> </span> <span class="pi-opt-code"> </span></li>`),ie=e.from_html(`<li class="pi-empty"> </li>`),ae=e.from_html(`<div role="dialog" aria-modal="false" aria-label="Select country"><div class="pi-search-wrap"><input type="search" class="pi-search" aria-label="Search countries"/></div> <ul class="pi-options" role="listbox" tabindex="-1"></ul></div>`),oe=e.from_html(`<div><div class="pi-selector"><button type="button"><span class="pi-flag" role="img"><!></span> <span class="pi-code"> </span> <!></button></div> <div class="pi-input-wrap"><input type="tel" inputmode="tel" autocomplete="tel-national" autocorrect="off" autocapitalize="off" spellcheck="false" class="pi-input"/> <div class="pi-actions" role="toolbar" aria-label="Phone input actions"><!> <!> <!></div></div></div> <!> <div class="sr-only" role="status" aria-live="polite" aria-atomic="true"></div>`,1);function N(t,i){e.push(i,!0);let a=e.prop(i,`value`,15,``),o=e.prop(i,`detect`,3,!0),s=e.prop(i,`size`,3,`normal`),c=e.prop(i,`theme`,3,`auto`),l=e.prop(i,`disabled`,3,!1),u=e.prop(i,`readonly`,3,!1),d=e.prop(i,`showCopy`,3,!0),f=e.prop(i,`showClear`,3,!1),p=e.prop(i,`withValidity`,3,!0),m=e.prop(i,`searchPlaceholder`,3,`Search country or code...`),h=e.prop(i,`noResultsText`,3,`No countries found`),g=e.prop(i,`clearButtonLabel`,3,`Clear phone number`),_=e.prop(i,`dropdownClass`,3,``),b=e.prop(i,`disableDefaultStyles`,3,!1),S=e.rest_props(i,`$$slots.$$events.$$legacy.value.id.name.country.detect.locale.size.theme.disabled.readonly.showCopy.showClear.withValidity.searchPlaceholder.noResultsText.clearButtonLabel.dropdownClass.disableDefaultStyles.onchange.oncountrychange.onvalidationchange.onfocus.onblur.oncopy.onclear.flag.copysvg.clearsvg.actionsbefore.class`.split(`.`)),C=e.state(null),E=e.state(null),D=e.state(null),N=e.state(null),P=e.state(null),F=e.state(null),I=v({country:()=>i.country,locale:()=>i.locale,detect:()=>o(),onCountryChange:(...e)=>i.oncountrychange?.(...e)}),L=y({country:()=>I.country,value:()=>a(),onChange:e=>a(e),onPhoneChange:(...e)=>i.onchange?.(...e),onValidationChange:(...e)=>i.onvalidationchange?.(...e)}),R=x(),z=e.derived(()=>l()||u()),B=e.derived(()=>R.showValidationHint&&L.shouldShowWarn),V=e.derived(()=>d()&&!L.isEmpty&&!l()),H=e.derived(()=>f()&&!L.isEmpty&&!e.get(z)),U=O({liveRef:()=>e.get(D),fullFormatted:()=>L.fullFormatted,onCopy:(...e)=>i.oncopy?.(...e)}),W=()=>r().then(()=>e.get(E)?.focus()),G=T({rootRef:()=>e.get(C),dropdownRef:()=>e.get(N),searchRef:()=>e.get(P),selectorRef:()=>e.get(F),locale:()=>I.locale,countryOption:()=>i.country,inactive:()=>e.get(z),onSelectCountry:I.setCountry,onAfterSelect:W}),K=e.state(`0`);n(()=>{e.set(K,Math.random().toString(36).slice(2,10),!0)});let se=e.derived(()=>`pi-options-${e.get(K)}`),ce=t=>`pi-option-${e.get(K)}-${t}`,le=e.derived(()=>G.dropdownOpen&&G.filteredCountries[G.focusedIndex]?ce(G.focusedIndex):void 0),q=w({formatter:()=>L.formatter,digits:()=>L.digits,inactive:()=>e.get(z),onChange:e=>a(e),scheduleValidationHint:R.scheduleValidationHint}),ue=e=>{R.clearValidationHint(!1),G.closeDropdown(),i.onfocus?.(e)},de=e=>i.onblur?.(e);function fe(){W()}function pe(){e.get(E)?.blur()}function me(){a(``),R.clearValidationHint(),i.onclear?.()}function he(e){I.setCountry(e)}function ge(){return L.full}function _e(){return L.fullFormatted}function ve(){return L.digits}function ye(){return L.isComplete}function be(){return L.isComplete}let xe=()=>{me(),W()},Se=ee({theme:()=>c()}),Ce=e.derived(()=>[`phone-input`,`size-${s()}`,Se.themeClass,l()&&`is-disabled`,u()&&`is-readonly`,b()&&`is-unstyled`,p()&&e.get(B)&&`is-incomplete`,p()&&L.isComplete&&`is-complete`,i.class].filter(Boolean).join(` `)),we=e.derived(()=>+e.get(V)+ +e.get(H)+ +!!i.actionsbefore);function Te(e){return document.body.appendChild(e),{destroy:()=>e.remove()}}var Ee={focus:fe,blur:pe,clear:me,selectCountry:he,getFullNumber:ge,getFullFormattedNumber:_e,getDigits:ve,isValid:ye,isComplete:be},De=oe(),J=e.first_child(De);e.attribute_effect(J,()=>({class:e.get(Ce),...S,role:`group`,"aria-label":`Phone input with country selector`,[e.STYLE]:{"--pi-actions-count":e.get(we)}}));var Y=e.child(J),X=e.child(Y);let Oe;var Z=e.child(X),ke=e.child(Z),Ae=t=>{var n=e.comment(),r=e.first_child(n);e.snippet(r,()=>i.flag,()=>I.country),e.append(t,n)},je=t=>{var n=e.text();e.template_effect(()=>e.set_text(n,I.country.flag)),e.append(t,n)};e.if(ke,e=>{i.flag?e(Ae):e(je,-1)}),e.reset(Z);var Q=e.sibling(Z,2),Me=e.child(Q,!0);e.reset(Q);var Ne=e.sibling(Q,2),Pe=t=>{var n=k();let r;e.template_effect(()=>r=e.set_class(n,0,`pi-chevron`,null,r,{"is-open":G.dropdownOpen})),e.append(t,n)};e.if(Ne,t=>{!e.get(z)&&G.hasDropdown&&t(Pe)}),e.reset(X),e.reset(Y),e.bind_this(Y,t=>e.set(F,t),()=>e.get(F));var Fe=e.sibling(Y,2),$=e.child(Fe);e.remove_input_defaults($),e.bind_this($,t=>e.set(E,t),()=>e.get(E));var Ie=e.sibling($,2),Le=e.child(Ie),Re=t=>{var n=e.comment(),r=e.first_child(n);e.snippet(r,()=>i.actionsbefore),e.append(t,n)};e.if(Le,e=>{i.actionsbefore&&e(Re)});var ze=e.sibling(Le,2),Be=t=>{var n=te();let r;var a=e.child(n),o=t=>{var n=e.comment(),r=e.first_child(n);e.snippet(r,()=>i.copysvg,()=>U.copied),e.append(t,n)},s=t=>{var n=A();e.append(t,n)},c=t=>{var n=j();e.append(t,n)};e.if(a,e=>{i.copysvg?e(o):U.copied?e(s,1):e(c,-1)}),e.reset(n),e.template_effect(()=>{r=e.set_class(n,1,`pi-btn pi-btn-copy`,null,r,{"is-copied":U.copied}),e.set_attribute(n,`aria-label`,U.copyAriaLabel),e.set_attribute(n,`title`,U.copyButtonTitle)}),e.delegated(`click`,n,function(...e){U.onCopyClick?.apply(this,e)}),e.append(t,n)};e.if(ze,t=>{e.get(V)&&t(Be)});var Ve=e.sibling(ze,2),He=t=>{var n=ne(),r=e.child(n),a=t=>{var n=e.comment(),r=e.first_child(n);e.snippet(r,()=>i.clearsvg),e.append(t,n)},o=t=>{var n=M();e.append(t,n)};e.if(r,e=>{i.clearsvg?e(a):e(o,-1)}),e.reset(n),e.template_effect(()=>{e.set_attribute(n,`aria-label`,g()),e.set_attribute(n,`title`,g())}),e.delegated(`click`,n,xe),e.append(t,n)};e.if(Ve,t=>{e.get(H)&&t(He)}),e.reset(Ie),e.reset(Fe),e.reset(J),e.bind_this(J,t=>e.set(C,t),()=>e.get(C));var Ue=e.sibling(J,2),We=t=>{var n=ae();let r,a;var o=e.child(n),s=e.child(o);e.remove_input_defaults(s),e.bind_this(s,t=>e.set(P,t),()=>e.get(P)),e.reset(o);var c=e.sibling(o,2);e.each(c,23,()=>G.filteredCountries,e=>e.id,(t,n,r)=>{var a=re();let o;var s=e.child(a),c=e.child(s),l=t=>{var r=e.comment(),a=e.first_child(r);e.snippet(a,()=>i.flag,()=>e.get(n)),e.append(t,r)},u=t=>{var r=e.text();e.template_effect(()=>e.set_text(r,e.get(n).flag)),e.append(t,r)};e.if(c,e=>{i.flag?e(l):e(u,-1)}),e.reset(s);var d=e.sibling(s,2),f=e.child(d,!0);e.reset(d);var p=e.sibling(d,2),m=e.child(p,!0);e.reset(p),e.reset(a),e.template_effect(t=>{e.set_attribute(a,`id`,t),o=e.set_class(a,1,`pi-option`,null,o,{"is-focused":e.get(r)===G.focusedIndex,"is-selected":e.get(n).id===I.country.id}),e.set_attribute(a,`aria-selected`,e.get(n).id===I.country.id),e.set_attribute(a,`title`,e.get(n).name),e.set_attribute(s,`aria-label`,`${e.get(n).name??``} flag`),e.set_text(f,e.get(n).name),e.set_text(m,e.get(n).code)},[()=>ce(e.get(r))]),e.delegated(`click`,a,()=>G.selectCountry(e.get(n).id)),e.event(`mouseenter`,a,()=>G.setFocusedIndex(e.get(r))),e.append(t,a)},t=>{var n=ie(),r=e.child(n,!0);e.reset(n),e.template_effect(()=>e.set_text(r,h())),e.append(t,n)}),e.reset(c),e.reset(n),e.action(n,e=>Te?.(e)),e.bind_this(n,t=>e.set(N,t),()=>e.get(N)),e.template_effect(()=>{r=e.set_class(n,1,`phone-dropdown ${_()??``} ${Se.themeClass??``}`,null,r,{"is-closing":G.isClosing}),a=e.set_style(n,``,a,{position:`absolute`,top:G.dropdownStyle.top,left:G.dropdownStyle.left,width:G.dropdownStyle.width}),e.set_attribute(s,`placeholder`,m()),e.set_attribute(s,`aria-controls`,e.get(se)),e.set_attribute(s,`aria-activedescendant`,e.get(le)),e.set_value(s,G.search),e.set_attribute(c,`id`,e.get(se))}),e.event(`animationend`,n,function(...e){G.handleDropdownAnimationEnd?.apply(this,e)}),e.delegated(`keydown`,s,function(...e){G.handleSearchKeydown?.apply(this,e)}),e.delegated(`input`,s,function(...e){G.handleSearchChange?.apply(this,e)}),e.append(t,n)};e.if(Ue,e=>{G.dropdownOpen&&e(We)});var Ge=e.sibling(Ue,2);return e.bind_this(Ge,t=>e.set(D,t),()=>e.get(D)),e.template_effect(()=>{Oe=e.set_class(X,1,`pi-selector-btn`,null,Oe,{"no-dropdown":!G.hasDropdown||u()}),X.disabled=l(),e.set_attribute(X,`tabindex`,e.get(z)||!G.hasDropdown?-1:void 0),e.set_attribute(X,`aria-label`,`Selected country: ${I.country.name??``}`),e.set_attribute(X,`aria-expanded`,G.dropdownOpen),e.set_attribute(X,`aria-haspopup`,G.hasDropdown?`listbox`:void 0),e.set_attribute(Z,`aria-label`,`${I.country.name??``} flag`),e.set_text(Me,I.country.code),e.set_attribute($,`id`,i.id),e.set_attribute($,`name`,i.name),e.set_attribute($,`placeholder`,L.displayPlaceholder),e.set_value($,L.displayValue),$.disabled=l(),$.readOnly=u(),e.set_attribute($,`aria-invalid`,e.get(B))}),e.delegated(`click`,X,function(...e){G.toggleDropdown?.apply(this,e)}),e.delegated(`beforeinput`,$,function(...e){q.handleBeforeInput?.apply(this,e)}),e.delegated(`input`,$,function(...e){q.handleInput?.apply(this,e)}),e.delegated(`keydown`,$,function(...e){q.handleKeydown?.apply(this,e)}),e.event(`paste`,$,function(...e){q.handlePaste?.apply(this,e)}),e.event(`focus`,$,ue),e.event(`blur`,$,de),e.append(t,De),e.pop(Ee)}e.delegate([`click`,`beforeinput`,`input`,`keydown`]);function P(t){let n=e.state(null),r=v({country:t.country,locale:t.locale,detect:t.detect,onCountryChange:t.onCountryChange}),i=y({country:()=>r.country,value:t.value,onChange:t.onChange,onPhoneChange:t.onPhoneChange}),{handleBeforeInput:a,handleInput:o,handleKeydown:s,handlePaste:c}=w({formatter:()=>i.formatter,digits:()=>i.digits,onChange:t.onChange});return e.user_effect(()=>{let t=e.get(n);if(t)return t.setAttribute(`type`,`tel`),t.setAttribute(`inputmode`,`tel`),t.addEventListener(`beforeinput`,a),t.addEventListener(`input`,o),t.addEventListener(`keydown`,s),t.addEventListener(`paste`,c),()=>{t.removeEventListener(`beforeinput`,a),t.removeEventListener(`input`,o),t.removeEventListener(`keydown`,s),t.removeEventListener(`paste`,c)}}),e.user_effect(()=>{let t=e.get(n);t&&(t.value=i.displayValue,t.setAttribute(`placeholder`,i.displayPlaceholder))}),{get inputRef(){return e.get(n)},set inputRef(t){e.set(n,t,!0)},get digits(){return i.digits},get formatter(){return i.formatter},get full(){return i.full},get fullFormatted(){return i.fullFormatted},get isComplete(){return i.isComplete},get isEmpty(){return i.isEmpty},get shouldShowWarn(){return i.shouldShowWarn},get country(){return r.country},get locale(){return r.locale},setCountry:r.setCountry,clear:()=>{t.onChange(``)}}}function F(e){return typeof e==`string`?{country:e}:e&&typeof e==`object`?e:{}}function I(t){return n=>{if(n.tagName!==`INPUT`){console.warn(`[phoneMaskAttachment] Attachment can only be used on input elements`);return}let r=F(t),i=e.effect_root(()=>{let t=e.state(e.proxy(n.value||``)),i=P({country:()=>r.country,locale:()=>r.locale,detect:()=>r.detect,value:()=>e.get(t),onChange:n=>{e.set(t,n,!0)},onPhoneChange:r.onChange,onCountryChange:r.onCountryChange});i.inputRef=n,n.__phoneMaskState={get country(){return i.country},get formatter(){return i.formatter},get digits(){return i.digits},get locale(){return i.locale},options:r,setCountry:e=>i.setCountry(e)}});return()=>{i(),delete n.__phoneMaskState}}}function L(e){return typeof e==`string`?{country:e}:e&&typeof e==`object`?e:{}}function R(e,t,n){if(t.digits=n,e.value=t.formatter.formatDisplay(t.digits),t.options.onChange){let n=e.value?`${t.country.code} ${e.value}`:``,r=t.digits?`${t.country.code}${t.digits}`:``;t.options.onChange({full:r,fullFormatted:n,digits:t.digits})}}function z(e,t){let n=t.formatter.getMaxDigits(),r=c(e.value,n),i=t.formatter.formatDisplay(r);(r!==t.digits||e.value!==i)&&R(e,t,r)}function B(e){let t=e.country.id,n=f(e.options.country);n&&n!==t&&e.setCountry(n)}function V(e,t,n){return r=>{let i=n(r,t);i&&(R(e,t,i.newDigits),Promise.resolve().then(()=>{_(e,t.formatter.getCaretPosition(i.caretDigitIndex))}))}}async function H(e){let t=f(e.country);if(t)return t;if(e.detect){let e=f(await o());if(e)return e;let t=f(s());if(t)return t}return`US`}function U(e,t){if(e.tagName!==`INPUT`)return console.warn(`[phoneMaskAction] Action can only be used on input elements`),{update(){},destroy(){}};e.setAttribute(`type`,`tel`),e.setAttribute(`inputmode`,`tel`),e.setAttribute(`placeholder`,``);let n=L(t),r=n.locale||d(),i=u(f(n.country,`US`),r),o={country:i,formatter:a(i),digits:``,locale:r,options:n,setCountry(t){let n=f(t);if(!n)return!1;let r=u(n,this.locale);return this.country=r,this.options.onCountryChange?.(r),this.formatter=a(r),e.placeholder=this.formatter.getPlaceholder(),z(e,this),!0}};e.__phoneMaskState=o;let s=V(e,o,m),c=V(e,o,h),l=V(e,o,g);return e.addEventListener(`beforeinput`,p),e.addEventListener(`input`,s),e.addEventListener(`keydown`,c),e.addEventListener(`paste`,l),H(n).then(t=>{e.__phoneMaskState===o&&o.setCountry(t)}),{update(t){o.options=L(t),B(o),z(e,o)},destroy(){e.removeEventListener(`beforeinput`,p),e.removeEventListener(`input`,s),e.removeEventListener(`keydown`,c),e.removeEventListener(`paste`,l),delete e.__phoneMaskState}}}var W=N;export{W as PhoneInput,U as phoneMaskAction,I as phoneMaskAttachment,P as usePhoneMask};
@@ -1,2 +1,2 @@
1
- .phone-input,.phone-dropdown{--pi-bg:#fff;--pi-fg:#111827;--pi-muted:#6b7280;--pi-border:#e5e7eb;--pi-border-hover:#d1d5db;--pi-border-focus:#3b82f6;--pi-radius:8px;--pi-padding:12px;--pi-font-size:16px;--pi-height:44px;--pi-actions-size:32px;--pi-shadow:0 1px 2px 0 #0000000d;--pi-shadow-lg:0 10px 15px -3px #0000001a, 0 4px 6px -2px #0000000d;--pi-warning:#f59e0b;--pi-warning-light:#fbbf24;--pi-success:#10b981;--pi-focus-ring:3px solid #3b82f626;--pi-focus-ring-warning:3px solid #f59e0b26;--pi-focus-ring-success:3px solid #10b98126;--pi-disabled-bg:#f9fafb;--pi-disabled-fg:#9ca3af}.phone-input.theme-dark,.phone-dropdown.theme-dark{--pi-bg:#1f2937;--pi-fg:#f9fafb;--pi-muted:#9ca3af;--pi-border:#374151;--pi-border-hover:#4b5563;--pi-border-focus:#60a5fa;--pi-shadow:0 1px 3px 0 #0000004d;--pi-shadow-lg:0 20px 25px -5px #0000004d, 0 10px 10px -5px #0003;--pi-warning:#fbbf24;--pi-warning-light:#fcd34d;--pi-focus-ring:3px solid #60a5fa33;--pi-focus-ring-warning:3px solid #fbbf1833;--pi-focus-ring-success:3px solid #10b98133;--pi-disabled-bg:#374151}.phone-input,.phone-dropdown{font-size:var(--pi-font-size);background:var(--pi-bg);color:var(--pi-fg);border-radius:var(--pi-radius);border:1px solid var(--pi-border)}.phone-input *,.phone-input :before,.phone-input :after,.phone-dropdown *,.phone-dropdown :before,.phone-dropdown :after{box-sizing:border-box}.phone-input button,.phone-input input,.phone-dropdown button,.phone-dropdown input{font:inherit;color:inherit;background:0 0;border:none;margin:0;padding:0}.phone-input button,.phone-dropdown button{cursor:pointer}.phone-input button:disabled,.phone-dropdown button:disabled{cursor:not-allowed}.phone-input input,.phone-dropdown input{outline:none}.phone-input input::placeholder,.phone-dropdown input::placeholder{opacity:.5}.phone-input input:disabled,.phone-dropdown input:disabled{cursor:not-allowed}.phone-input{align-items:stretch;width:100%;display:flex;position:relative}.phone-input:focus-within{outline:var(--pi-focus-ring)}.phone-input.is-incomplete{border-color:var(--pi-warning)}.phone-input.is-incomplete:focus-within{outline:var(--pi-focus-ring-warning)}.phone-input.is-complete{border-color:var(--pi-success)}.phone-input.is-complete:focus-within{outline:var(--pi-focus-ring-success)}.phone-input.is-disabled{background:var(--pi-disabled-bg);color:var(--pi-disabled-fg)}.phone-input.is-readonly{cursor:default}.phone-input.size-compact{--pi-font-size:14px;--pi-height:36px;--pi-padding:10px;--pi-actions-size:24px}.phone-input.size-large{--pi-font-size:18px;--pi-height:52px;--pi-padding:16px;--pi-actions-size:32px}.phone-input.is-unstyled{all:initial;display:block}.phone-input .pi-selector{flex-shrink:0}.phone-input .pi-selector-btn{padding-left:var(--pi-padding);min-height:var(--pi-height);border-radius:var(--pi-radius) 0 0 var(--pi-radius);border:1px solid #0000;align-items:center;gap:6px;padding-right:0;transition:all .15s cubic-bezier(.4,0,.2,1);display:flex}.phone-input .pi-selector-btn.no-dropdown{cursor:default}.phone-input .pi-selector-btn:focus-visible{border-color:var(--pi-border-focus);outline:none}.phone-input .pi-selector-btn:disabled>.pi-flag{opacity:.5}.phone-input .pi-flag{font-size:1.25em;line-height:1;display:inline-flex}.phone-input .pi-code{color:var(--pi-fg)}.phone-input .pi-chevron{color:var(--pi-muted);margin-left:2px;transition:transform .2s}.phone-input .pi-chevron.is-open{transform:rotate(180deg)}.phone-input .pi-input-wrap{flex:1;align-items:center;display:flex;position:relative}.phone-input .pi-input{width:100%;padding-left:var(--pi-padding);padding-right:calc((var(--pi-actions-size) + 2px) * var(--pi-actions-count) + var(--pi-padding));min-height:var(--pi-height);border-radius:0 var(--pi-radius) var(--pi-radius) 0;flex:1;transition:all .15s cubic-bezier(.4,0,.2,1)}.phone-input .pi-input:hover:not(:disabled):not(:read-only){border-color:var(--pi-border-hover)}.phone-input .pi-input:focus{border-color:var(--pi-border-focus);position:relative}.phone-input .pi-actions{align-items:center;gap:2px;display:inline-flex;position:absolute;top:50%;right:2px;transform:translateY(-50%)}.phone-input .pi-btn{width:var(--pi-actions-size);height:var(--pi-actions-size);color:var(--pi-muted);background:0 0;border:none;border-radius:9999px;justify-content:center;align-items:center;transition:all .15s cubic-bezier(.4,0,.2,1);display:flex}.phone-input .pi-btn:hover{background:var(--pi-disabled-bg);color:var(--pi-fg)}.phone-input .pi-btn:active:not(:disabled){transform:scale(.95)}.phone-input .pi-btn:focus{outline:1px solid var(--pi-border-focus);outline-offset:-1px}.phone-input .pi-btn.is-copied{color:var(--pi-success);border-color:var(--pi-success)}.phone-input .pi-btn svg{flex-shrink:0}.phone-dropdown{z-index:9999;max-width:400px;box-shadow:var(--pi-shadow-lg);animation:.2s cubic-bezier(.4,0,.2,1) both dropdown-enter;position:absolute;overflow:hidden}.phone-dropdown .pi-search-wrap{border-bottom:1px solid var(--pi-border);padding:8px}.phone-dropdown .pi-search{border:1px solid var(--pi-border);border-radius:calc(var(--pi-radius) - 2px);background:var(--pi-bg);width:100%;padding:8px 12px;font-size:.875em;transition:border-color .15s}.phone-dropdown .pi-search:focus{border-color:var(--pi-border-focus)}.phone-dropdown .pi-options{max-height:300px;margin:0;padding:4px 0;list-style:none;overflow-y:auto}.phone-dropdown .pi-options::-webkit-scrollbar{width:8px}.phone-dropdown .pi-options::-webkit-scrollbar-track{background:0 0}.phone-dropdown .pi-options::-webkit-scrollbar-thumb{background:var(--pi-border);border-radius:4px}.phone-dropdown .pi-options::-webkit-scrollbar-thumb:hover{background:var(--pi-border-hover)}.phone-dropdown .pi-option{cursor:pointer;align-items:center;gap:8px;padding:8px 12px;transition:background-color .1s;display:flex}.phone-dropdown .pi-option:hover,.phone-dropdown .pi-option.is-focused{background:var(--pi-disabled-bg)}.phone-dropdown .pi-option.is-selected{background:var(--pi-border);font-weight:500}.phone-dropdown .pi-opt-name{text-overflow:ellipsis;white-space:nowrap;flex:1;overflow:hidden}.phone-dropdown .pi-opt-code{color:var(--pi-muted);font-size:.875em}.phone-dropdown .pi-empty{text-align:center;color:var(--pi-muted);padding:12px;font-size:.875em}@keyframes dropdown-enter{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}@keyframes dropdown-leave{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-8px)}}.phone-dropdown.is-closing{animation:.2s cubic-bezier(.4,0,.2,1) both dropdown-leave}@keyframes fade-scale-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}.pi-actions .pi-btn{animation:.2s cubic-bezier(.4,0,.2,1) both fade-scale-in}.sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}@media (width<=480px){.phone-input{--pi-padding:8px;--pi-actions-size:24px}.size-compact{--pi-actions-size:20px}.phone-dropdown{max-width:none;left:0;right:0}}@media (prefers-reduced-motion:reduce){*{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}
1
+ .phone-input,.phone-dropdown{--pi-bg:#fff;--pi-fg:#111827;--pi-muted:#6b7280;--pi-border:#e5e7eb;--pi-border-hover:#d1d5db;--pi-border-focus:#3b82f6;--pi-radius:8px;--pi-padding:12px;--pi-font-size:16px;--pi-height:44px;--pi-actions-size:32px;--pi-shadow:0 1px 2px 0 #0000000d;--pi-shadow-lg:0 10px 15px -3px #0000001a, 0 4px 6px -2px #0000000d;--pi-warning:#f59e0b;--pi-warning-light:#fbbf24;--pi-success:#10b981;--pi-focus-ring:3px solid #3b82f626;--pi-focus-ring-warning:3px solid #f59e0b26;--pi-focus-ring-success:3px solid #10b98126;--pi-disabled-bg:#f9fafb;--pi-disabled-fg:#9ca3af}.phone-input.theme-dark,.phone-dropdown.theme-dark{--pi-bg:#1f2937;--pi-fg:#f9fafb;--pi-muted:#9ca3af;--pi-border:#374151;--pi-border-hover:#4b5563;--pi-border-focus:#60a5fa;--pi-shadow:0 1px 3px 0 #0000004d;--pi-shadow-lg:0 20px 25px -5px #0000004d, 0 10px 10px -5px #0003;--pi-warning:#fbbf24;--pi-warning-light:#fcd34d;--pi-focus-ring:3px solid #60a5fa33;--pi-focus-ring-warning:3px solid #fbbf1833;--pi-focus-ring-success:3px solid #10b98133;--pi-disabled-bg:#374151}.phone-input,.phone-dropdown{font-size:var(--pi-font-size);background:var(--pi-bg);color:var(--pi-fg);border-radius:var(--pi-radius);border:1px solid var(--pi-border)}.phone-input *,.phone-input :before,.phone-input :after,.phone-dropdown *,.phone-dropdown :before,.phone-dropdown :after{box-sizing:border-box}.phone-input button,.phone-input input,.phone-dropdown button,.phone-dropdown input{font:inherit;color:inherit;background:0 0;border:none;margin:0;padding:0}.phone-input button,.phone-dropdown button{cursor:pointer}.phone-input button:disabled,.phone-dropdown button:disabled{cursor:not-allowed}.phone-input input,.phone-dropdown input{outline:none}.phone-input input::placeholder,.phone-dropdown input::placeholder{opacity:.5}.phone-input input:disabled,.phone-dropdown input:disabled{cursor:not-allowed}.phone-input{align-items:stretch;width:100%;display:flex;position:relative}.phone-input:focus-within{outline:var(--pi-focus-ring)}.phone-input.is-incomplete{border-color:var(--pi-warning)}.phone-input.is-incomplete:focus-within{outline:var(--pi-focus-ring-warning)}.phone-input.is-complete{border-color:var(--pi-success)}.phone-input.is-complete:focus-within{outline:var(--pi-focus-ring-success)}.phone-input.is-disabled{background:var(--pi-disabled-bg);color:var(--pi-disabled-fg)}.phone-input.is-readonly{cursor:default}.phone-input.size-compact{--pi-font-size:14px;--pi-height:36px;--pi-padding:10px;--pi-actions-size:24px}.phone-input.size-large{--pi-font-size:18px;--pi-height:52px;--pi-padding:16px;--pi-actions-size:32px}.phone-input.is-unstyled{all:initial;display:block}.phone-input .pi-selector{flex-shrink:0}.phone-input .pi-selector-btn{padding-left:var(--pi-padding);min-height:var(--pi-height);border-radius:var(--pi-radius) 0 0 var(--pi-radius);border:1px solid #0000;align-items:center;gap:6px;padding-right:0;transition:all .15s cubic-bezier(.4,0,.2,1);display:flex}.phone-input .pi-selector-btn.no-dropdown{cursor:default}.phone-input .pi-selector-btn:focus-visible{border-color:var(--pi-border-focus);outline:none}.phone-input .pi-selector-btn:disabled>.pi-flag{opacity:.5}.phone-input .pi-flag{font-size:1.25em;line-height:1;display:inline-flex}.phone-input .pi-code{color:var(--pi-fg)}.phone-input .pi-chevron{color:var(--pi-muted);margin-left:2px;transition:transform .2s}.phone-input .pi-chevron.is-open{transform:rotate(180deg)}.phone-input .pi-input-wrap{flex:1;align-items:center;display:flex;position:relative}.phone-input .pi-input{width:100%;padding-left:var(--pi-padding);padding-right:calc((var(--pi-actions-size) + 2px) * var(--pi-actions-count) + var(--pi-padding));min-height:var(--pi-height);border-radius:0 var(--pi-radius) var(--pi-radius) 0;flex:1;transition:all .15s cubic-bezier(.4,0,.2,1)}.phone-input .pi-input:hover:not(:disabled):not(:read-only){border-color:var(--pi-border-hover)}.phone-input .pi-input:focus{border-color:var(--pi-border-focus);position:relative}.phone-input .pi-input:-webkit-autofill{-webkit-text-fill-color:var(--pi-fg);caret-color:var(--pi-fg);-webkit-box-shadow:0 0 0 1000px var(--pi-bg) inset;box-shadow:0 0 0 1000px var(--pi-bg) inset;transition:background-color 9999s ease-out,color 9999s ease-out}.phone-input .pi-input:-webkit-autofill:hover{-webkit-text-fill-color:var(--pi-fg);caret-color:var(--pi-fg);-webkit-box-shadow:0 0 0 1000px var(--pi-bg) inset;box-shadow:0 0 0 1000px var(--pi-bg) inset;transition:background-color 9999s ease-out,color 9999s ease-out}.phone-input .pi-input:-webkit-autofill:focus{-webkit-text-fill-color:var(--pi-fg);caret-color:var(--pi-fg);-webkit-box-shadow:0 0 0 1000px var(--pi-bg) inset;box-shadow:0 0 0 1000px var(--pi-bg) inset;transition:background-color 9999s ease-out,color 9999s ease-out}.phone-input .pi-input:-webkit-autofill:active{-webkit-text-fill-color:var(--pi-fg);caret-color:var(--pi-fg);-webkit-box-shadow:0 0 0 1000px var(--pi-bg) inset;box-shadow:0 0 0 1000px var(--pi-bg) inset;transition:background-color 9999s ease-out,color 9999s ease-out}.phone-input .pi-input:-moz-autofill{-moz-text-fill-color:var(--pi-fg);box-shadow:0 0 0 1000px var(--pi-bg) inset}.phone-input .pi-actions{align-items:center;gap:2px;display:inline-flex;position:absolute;top:50%;right:2px;transform:translateY(-50%)}.phone-input .pi-btn{width:var(--pi-actions-size);height:var(--pi-actions-size);color:var(--pi-muted);background:0 0;border:none;border-radius:9999px;justify-content:center;align-items:center;transition:all .15s cubic-bezier(.4,0,.2,1);display:flex}.phone-input .pi-btn:hover{background:var(--pi-disabled-bg);color:var(--pi-fg)}.phone-input .pi-btn:active:not(:disabled){transform:scale(.95)}.phone-input .pi-btn:focus{outline:1px solid var(--pi-border-focus);outline-offset:-1px}.phone-input .pi-btn.is-copied{color:var(--pi-success);border-color:var(--pi-success)}.phone-input .pi-btn svg{flex-shrink:0}.phone-dropdown{z-index:9999;max-width:400px;box-shadow:var(--pi-shadow-lg);animation:.2s cubic-bezier(.4,0,.2,1) both dropdown-enter;position:absolute;overflow:hidden}.phone-dropdown .pi-search-wrap{border-bottom:1px solid var(--pi-border);padding:8px}.phone-dropdown .pi-search{border:1px solid var(--pi-border);border-radius:calc(var(--pi-radius) - 2px);background:var(--pi-bg);width:100%;padding:8px 12px;font-size:.875em;transition:border-color .15s}.phone-dropdown .pi-search:focus{border-color:var(--pi-border-focus)}.phone-dropdown .pi-options{max-height:300px;margin:0;padding:4px 0;list-style:none;overflow-y:auto}.phone-dropdown .pi-options::-webkit-scrollbar{width:8px}.phone-dropdown .pi-options::-webkit-scrollbar-track{background:0 0}.phone-dropdown .pi-options::-webkit-scrollbar-thumb{background:var(--pi-border);border-radius:4px}.phone-dropdown .pi-options::-webkit-scrollbar-thumb:hover{background:var(--pi-border-hover)}.phone-dropdown .pi-option{cursor:pointer;align-items:center;gap:8px;padding:8px 12px;transition:background-color .1s;display:flex}.phone-dropdown .pi-option:hover,.phone-dropdown .pi-option.is-focused{background:var(--pi-disabled-bg)}.phone-dropdown .pi-option.is-selected{background:var(--pi-border);font-weight:500}.phone-dropdown .pi-opt-name{text-overflow:ellipsis;white-space:nowrap;flex:1;overflow:hidden}.phone-dropdown .pi-opt-code{color:var(--pi-muted);font-size:.875em}.phone-dropdown .pi-empty{text-align:center;color:var(--pi-muted);padding:12px;font-size:.875em}@keyframes dropdown-enter{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}@keyframes dropdown-leave{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-8px)}}.phone-dropdown.is-closing{animation:.2s cubic-bezier(.4,0,.2,1) both dropdown-leave}@keyframes fade-scale-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}.pi-actions .pi-btn{animation:.2s cubic-bezier(.4,0,.2,1) both fade-scale-in}.sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}@media (width<=480px){.phone-input{--pi-padding:8px;--pi-actions-size:24px}.size-compact{--pi-actions-size:20px}.phone-dropdown{max-width:none;left:0;right:0}}@media (prefers-reduced-motion:reduce){*{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}
2
2
  /*$vite$:1*/
@@ -0,0 +1,2 @@
1
+ export * from '@desource/phone-mask';
2
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -1,4 +1,3 @@
1
- import { countPlaceholders, formatDigitsWithMap, pickMaskVariant, removeCountryCodePrefix } from '@desource/phone-mask';
2
1
  import type { Component } from 'svelte';
3
2
  import './style.scss';
4
3
  export { usePhoneMask } from './composables/usePhoneMask.svelte';
@@ -9,11 +8,4 @@ export type { UsePhoneMaskOptions, UsePhoneMaskReturn, PhoneInputProps, PhoneInp
9
8
  export declare const PhoneInput: Component<PhoneInputProps, PhoneInputExposed>;
10
9
  export type { PhoneNumber as PMaskPhoneNumber, Size as PhoneInputSize, Theme as PhoneInputTheme } from './types';
11
10
  export type { CountryKey as PCountryKey, MaskBase as PMaskBase, MaskBaseMap as PMaskBaseMap, Mask as PMask, MaskMap as PMaskMap, MaskWithFlag as PMaskWithFlag, MaskWithFlagMap as PMaskWithFlagMap, MaskFull as PMaskFull, MaskFullMap as PMaskFullMap } from '@desource/phone-mask';
12
- export declare const PMaskHelpers: {
13
- getFlagEmoji: (cc: string) => string;
14
- countPlaceholders: typeof countPlaceholders;
15
- formatDigitsWithMap: typeof formatDigitsWithMap;
16
- pickMaskVariant: typeof pickMaskVariant;
17
- removeCountryCodePrefix: typeof removeCountryCodePrefix;
18
- };
19
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,cAAc,CAAC;AAItB,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAClE,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,UAAU,EAAqC,SAAS,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AAE1G,YAAY,EAAE,WAAW,IAAI,gBAAgB,EAAE,IAAI,IAAI,cAAc,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,SAAS,CAAC;AAEjH,YAAY,EACV,UAAU,IAAI,WAAW,EACzB,QAAQ,IAAI,SAAS,EACrB,WAAW,IAAI,YAAY,EAC3B,IAAI,IAAI,KAAK,EACb,OAAO,IAAI,QAAQ,EACnB,YAAY,IAAI,aAAa,EAC7B,eAAe,IAAI,gBAAgB,EACnC,QAAQ,IAAI,SAAS,EACrB,WAAW,IAAI,YAAY,EAC5B,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,YAAY;;;;;;CAMxB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,cAAc,CAAC;AAItB,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAClE,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,UAAU,EAAqC,SAAS,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AAE1G,YAAY,EAAE,WAAW,IAAI,gBAAgB,EAAE,IAAI,IAAI,cAAc,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,SAAS,CAAC;AAEjH,YAAY,EACV,UAAU,IAAI,WAAW,EACzB,QAAQ,IAAI,SAAS,EACrB,WAAW,IAAI,YAAY,EAC3B,IAAI,IAAI,KAAK,EACb,OAAO,IAAI,QAAQ,EACnB,YAAY,IAAI,aAAa,EAC7B,eAAe,IAAI,gBAAgB,EACnC,QAAQ,IAAI,SAAS,EACrB,WAAW,IAAI,YAAY,EAC5B,MAAM,sBAAsB,CAAC"}
@@ -16,6 +16,10 @@ export type PhoneNumber = {
16
16
  export interface PhoneInputProps {
17
17
  /** Controlled/bindable value (digits only, without country code) */
18
18
  value?: string;
19
+ /** Optional id attribute applied to the underlying phone input element */
20
+ id?: string;
21
+ /** Optional name attribute applied to the underlying phone input element */
22
+ name?: string;
19
23
  /** Whether to preselect a country by ISO 3166-1 alpha-2 code */
20
24
  country?: CountryKey;
21
25
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@desource/phone-mask-svelte",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "🌍 Svelte 5 component, composable, action, and attachment for international phone number masking. Powered by @desource/phone-mask with Google libphonenumber sync.",
5
5
  "keywords": [
6
6
  "svelte",
@@ -44,6 +44,11 @@
44
44
  "import": "./dist/index.mjs",
45
45
  "require": "./dist/index.cjs"
46
46
  },
47
+ "./core": {
48
+ "types": "./dist/types/core.d.ts",
49
+ "import": "./dist/core.mjs",
50
+ "require": "./dist/core.cjs"
51
+ },
47
52
  "./assets/lib.css": "./dist/phone-mask-svelte.css"
48
53
  },
49
54
  "files": [
@@ -55,13 +60,13 @@
55
60
  "svelte": "^5.0.0"
56
61
  },
57
62
  "dependencies": {
58
- "@desource/phone-mask": "1.2.0"
63
+ "@desource/phone-mask": "1.3.1"
59
64
  },
60
65
  "devDependencies": {
61
66
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
62
67
  "@testing-library/svelte": "^5.3.1",
63
- "svelte": "^5.54.1",
64
- "svelte-check": "^4.4.5"
68
+ "svelte": "^5.55.4",
69
+ "svelte-check": "^4.4.6"
65
70
  },
66
71
  "scripts": {
67
72
  "clean": "rimraf dist tsconfig.tsbuildinfo test-results coverage",