@alikhalilll/a-tel-input 1.0.2 → 1.1.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/.media/README.md +3 -0
- package/.media/hero.png +0 -0
- package/README.md +597 -72
- package/dist/_chunks/types.d.ts +661 -0
- package/dist/_chunks/types.js +52 -0
- package/dist/_chunks/types.js.map +1 -0
- package/dist/_chunks/usePhoneValidation.js +539 -0
- package/dist/_chunks/usePhoneValidation.js.map +1 -0
- package/dist/index.cjs +471 -695
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +122 -587
- package/dist/index.d.ts +122 -587
- package/dist/index.js +454 -658
- package/dist/index.js.map +1 -1
- package/dist/styles.css +20 -5
- package/dist/vee-validate/index.cjs +113 -0
- package/dist/vee-validate/index.cjs.map +1 -0
- package/dist/vee-validate/index.d.cts +86 -0
- package/dist/vee-validate/index.d.ts +86 -0
- package/dist/vee-validate/index.js +112 -0
- package/dist/vee-validate/index.js.map +1 -0
- package/dist/zod/index.cjs +211 -0
- package/dist/zod/index.cjs.map +1 -0
- package/dist/zod/index.d.cts +65 -0
- package/dist/zod/index.d.ts +65 -0
- package/dist/zod/index.js +208 -0
- package/dist/zod/index.js.map +1 -0
- package/package.json +34 -3
- package/src/components/ACountrySelect.vue +17 -3
- package/src/components/ATelInput.vue +206 -66
- package/src/composables/useCountryDetection.ts +28 -11
- package/src/composables/useCountryMatching.ts +160 -20
- package/src/composables/useCountrySelection.ts +71 -0
- package/src/composables/usePhoneValidation.ts +81 -18
- package/src/composables/useSyncedModel.ts +80 -0
- package/src/composables/useTelInputValidation.ts +50 -11
- package/src/index.ts +2 -0
- package/src/types.ts +80 -0
- package/src/vee-validate/index.ts +2 -0
- package/src/vee-validate/useTelField.ts +202 -0
- package/src/zod/index.ts +259 -0
- package/web-types.json +44 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,527 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { A as RestCountry, C as UseTelInputValidationInputs, D as PhoneRequiredInfo, E as CountryOption, F as DetectCountryOptions, I as DetectionStrategy, L as UseCountryDetectionReturn, M as ValidateArgs, N as localizeCountries, O as PhoneValidationReason, P as usePhoneValidation, R as detectCountry, S as UseTelInputValidationDeps, T as useTelInputValidation, _ as resolveMessages, a as ACountrySelectSlots, b as ATelInputValidateOn, c as ATelInputProps, d as ATelInputVariants, f as DEFAULT_ERROR_MESSAGES, g as aTelInputVariants, h as TelInputMessagesInput, i as ACountrySelectProps, j as UsePhoneValidationReturn, k as PhoneValidationResult, l as ATelInputSize, m as TelInputMessages, n as ACountryFlagSlots, o as ATelInputDir, p as DEFAULT_MESSAGES, r as ACountrySelectEmits, s as ATelInputEmits, t as ACountryFlagProps, u as ATelInputSlots, v as FlagUrlBuilder, w as UseTelInputValidationReturn, x as UseTelInputValidationConfig, y as defaultFlagUrl, z as useCountryDetection } from "./_chunks/types.js";
|
|
2
|
+
import { ComputedRef, Ref, WatchSource } from "vue";
|
|
3
3
|
|
|
4
|
-
//#region src/composables/useCountryDetection.d.ts
|
|
5
|
-
type DetectionStrategy = 'auto' | 'locale' | 'none';
|
|
6
|
-
interface DetectCountryOptions {
|
|
7
|
-
/**
|
|
8
|
-
* - `'auto'` — try IP geolocation first, then timezone, then `navigator.language`, then default.
|
|
9
|
-
* - `'locale'` — skip the network call, use timezone + locale only.
|
|
10
|
-
* - `'none'` — return `defaultCountry` immediately.
|
|
11
|
-
*/
|
|
12
|
-
strategy?: DetectionStrategy;
|
|
13
|
-
/** Endpoint returning a JSON body with a `country_code` (or `country`) field. */
|
|
14
|
-
ipEndpoint?: string;
|
|
15
|
-
/** Fallback ISO2 used when every step fails. */
|
|
16
|
-
defaultCountry?: string;
|
|
17
|
-
/** Abort the IP request after this many ms. */
|
|
18
|
-
timeoutMs?: number;
|
|
19
|
-
/** Persist the resolved country in sessionStorage so re-mounts within the session skip detection. */
|
|
20
|
-
cache?: boolean;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Imperative API. Use this when you want to call detection from outside Vue (e.g. inside a
|
|
24
|
-
* non-component composable, server middleware, or unit test).
|
|
25
|
-
*/
|
|
26
|
-
declare function detectCountry(opts?: DetectCountryOptions): Promise<string>;
|
|
27
|
-
interface UseCountryDetectionReturn {
|
|
28
|
-
/** Resolved ISO2 code. Initially `null` until detection completes. */
|
|
29
|
-
country: Ref<string | null>;
|
|
30
|
-
/** True while detection is in flight. */
|
|
31
|
-
isLoading: Ref<boolean>;
|
|
32
|
-
/** Manually re-run detection (e.g. after the user changes their VPN). */
|
|
33
|
-
refresh: () => Promise<string>;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Reactive wrapper. Kicks off detection in `onMounted` so SSR renders an empty value and the
|
|
37
|
-
* client patches in the real country once resolved.
|
|
38
|
-
*/
|
|
39
|
-
declare function useCountryDetection(opts?: DetectCountryOptions): UseCountryDetectionReturn;
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region src/composables/usePhoneValidation.d.ts
|
|
42
|
-
interface RestCountry {
|
|
43
|
-
name?: {
|
|
44
|
-
common?: string;
|
|
45
|
-
};
|
|
46
|
-
cca2?: string;
|
|
47
|
-
idd?: {
|
|
48
|
-
root?: string;
|
|
49
|
-
suffixes?: string[];
|
|
50
|
-
};
|
|
51
|
-
flags?: {
|
|
52
|
-
png?: string;
|
|
53
|
-
svg?: string;
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
interface CountryOption<T = RestCountry> {
|
|
57
|
-
/** Display label, e.g. "Egypt (+20)". */
|
|
58
|
-
label: string;
|
|
59
|
-
/** Stable unique ID — the ISO 3166-1 alpha-2 code, e.g. "EG". */
|
|
60
|
-
value: string;
|
|
61
|
-
/** Precomputed normalized string for fast substring search. */
|
|
62
|
-
search_key: string;
|
|
63
|
-
raw_data: {
|
|
64
|
-
iso2: string;
|
|
65
|
-
dial_code: string;
|
|
66
|
-
dial_digits: string;
|
|
67
|
-
name: string;
|
|
68
|
-
flag: string | null;
|
|
69
|
-
source: 'restcountries' | 'fallback';
|
|
70
|
-
original: T;
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
interface PhoneRequiredInfo {
|
|
74
|
-
iso2: string;
|
|
75
|
-
dial_code: string;
|
|
76
|
-
/** Empty by default — consumer passes a placeholder via the component prop. */
|
|
77
|
-
placeholder: string;
|
|
78
|
-
example_national: string;
|
|
79
|
-
example_e164: string;
|
|
80
|
-
national_number_length: {
|
|
81
|
-
min: number | null;
|
|
82
|
-
max: number | null;
|
|
83
|
-
};
|
|
84
|
-
format_hint: string;
|
|
85
|
-
}
|
|
86
|
-
type PhoneValidationReason = 'missing_country' | 'country_not_supported' | 'phone_has_non_digits' | 'too_short' | 'too_long' | 'invalid_phone' | 'parse_failed';
|
|
87
|
-
interface PhoneValidationResult {
|
|
88
|
-
ok: boolean;
|
|
89
|
-
reason: PhoneValidationReason | null;
|
|
90
|
-
country: {
|
|
91
|
-
iso2: string;
|
|
92
|
-
dial_code: string;
|
|
93
|
-
} | null;
|
|
94
|
-
phone: {
|
|
95
|
-
raw: string | null;
|
|
96
|
-
digits: string;
|
|
97
|
-
};
|
|
98
|
-
full_phone: string | null;
|
|
99
|
-
required: PhoneRequiredInfo | null;
|
|
100
|
-
details?: Record<string, unknown>;
|
|
101
|
-
}
|
|
102
|
-
type ValidateArgs = {
|
|
103
|
-
country: {
|
|
104
|
-
iso2: string;
|
|
105
|
-
dial_code?: string;
|
|
106
|
-
} | null | undefined;
|
|
107
|
-
phone?: undefined; /** BCP-47 locale — localizes the numerals in the returned `required.format_hint`. */
|
|
108
|
-
locale?: string;
|
|
109
|
-
} | {
|
|
110
|
-
country: {
|
|
111
|
-
iso2: string;
|
|
112
|
-
dial_code?: string;
|
|
113
|
-
} | null | undefined;
|
|
114
|
-
phone: string | null; /** BCP-47 locale — localizes the numerals in the returned `required.format_hint`. */
|
|
115
|
-
locale?: string;
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Return a copy of the country list with display names localized to `locale` via
|
|
119
|
-
* `Intl.DisplayNames`. `search_key` is rebuilt (keeping the English name too) so search
|
|
120
|
-
* still matches either spelling. Unknown locales / regions fall back to the English name.
|
|
121
|
-
*/
|
|
122
|
-
declare function localizeCountries(list: CountryOption[], locale?: string): CountryOption[];
|
|
123
|
-
interface UsePhoneValidationReturn {
|
|
124
|
-
countries: Ref<CountryOption[]>;
|
|
125
|
-
isCountriesLoading: Ref<boolean>;
|
|
126
|
-
getCountries(options?: {
|
|
127
|
-
force?: boolean;
|
|
128
|
-
}): Promise<CountryOption[]>;
|
|
129
|
-
searchCountries(keyword: string, limit?: number): CountryOption[];
|
|
130
|
-
getCountryByValue(value: string): CountryOption | null;
|
|
131
|
-
getCountriesByDial(dial: string): CountryOption[];
|
|
132
|
-
getRequiredInfo(country: {
|
|
133
|
-
iso2: string;
|
|
134
|
-
dial_code?: string;
|
|
135
|
-
}, locale?: string): PhoneRequiredInfo | null;
|
|
136
|
-
validate(input: ValidateArgs): PhoneValidationResult;
|
|
137
|
-
}
|
|
138
|
-
declare function usePhoneValidation(): UsePhoneValidationReturn;
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region src/utils/flag-url.d.ts
|
|
141
|
-
/**
|
|
142
|
-
* Default flag URL builder — flagcdn.com hosts PNG flags at multiple widths and is
|
|
143
|
-
* generous with caching + no API key required. Swap via the `flagUrl` prop on
|
|
144
|
-
* ATelInput / ACountrySelect / ACountryFlag to use any other source.
|
|
145
|
-
*/
|
|
146
|
-
declare function defaultFlagUrl(iso2: string, width?: number): string;
|
|
147
|
-
type FlagUrlBuilder = (iso2: string, width: number) => string;
|
|
148
|
-
//#endregion
|
|
149
|
-
//#region ../AUiBase/dist/index.d.ts
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region src/sizes.d.ts
|
|
152
|
-
/**
|
|
153
|
-
* Shared size scale for every interactive component in the @alikhalilll/a-* set.
|
|
154
|
-
*
|
|
155
|
-
* xs = 28px · sm = 36px · md = 43px (default) · lg = 52px · xl = 60px
|
|
156
|
-
*
|
|
157
|
-
* Use the {@link controlHeight}, {@link controlPaddingX}, {@link controlTextSize}
|
|
158
|
-
* maps when building a CVA variant so every component stays in lockstep.
|
|
159
|
-
*/
|
|
160
|
-
type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
161
|
-
//#endregion
|
|
162
|
-
//#region src/types.d.ts
|
|
163
|
-
/** Alias for the shared `Size` scale — kept for backwards-friendly naming. */
|
|
164
|
-
type ATelInputSize = Size;
|
|
165
|
-
declare const aTelInputVariants: (props?: ({
|
|
166
|
-
size?: "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
167
|
-
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
168
|
-
type ATelInputVariants = VariantProps<typeof aTelInputVariants>;
|
|
169
|
-
/** Text direction for the field. `'auto'` (or omitting the prop) inherits from the
|
|
170
|
-
* nearest `[dir]` ancestor / `<html dir>`; `'ltr'` / `'rtl'` force it. */
|
|
171
|
-
type ATelInputDir = 'ltr' | 'rtl' | 'auto';
|
|
172
|
-
/**
|
|
173
|
-
* Every user-facing string in the tel-input UI, bundled so a consumer can localize the
|
|
174
|
-
* component in one prop. Each key has an English default in {@link DEFAULT_MESSAGES}.
|
|
175
|
-
*/
|
|
176
|
-
interface TelInputMessages {
|
|
177
|
-
/** Placeholder of the country-picker search box. */
|
|
178
|
-
searchPlaceholder: string;
|
|
179
|
-
/** Shown when a search yields no countries. */
|
|
180
|
-
emptyText: string;
|
|
181
|
-
/** Shown while the country list is loading. */
|
|
182
|
-
loadingText: string;
|
|
183
|
-
/** Header of the "Suggested" group (current + recent picks). */
|
|
184
|
-
suggestedLabel: string;
|
|
185
|
-
/** Header of the full country list. */
|
|
186
|
-
allCountriesLabel: string;
|
|
187
|
-
/** Validation error text, keyed by reason. */
|
|
188
|
-
errorMessages: Record<PhoneValidationReason, string>;
|
|
189
|
-
/** Prefix of the country trigger's `aria-label`, e.g. `"Country: Egypt"`. */
|
|
190
|
-
countryLabel: string;
|
|
191
|
-
/** `aria-label` of the country trigger when no country is selected. */
|
|
192
|
-
selectCountryLabel: string;
|
|
193
|
-
/** `aria-label` of the phone input element. */
|
|
194
|
-
phoneInputLabel: string;
|
|
195
|
-
}
|
|
196
|
-
/** Partial override shape for the `messages` prop — every key (and every error reason) is optional. */
|
|
197
|
-
type TelInputMessagesInput = Partial<Omit<TelInputMessages, 'errorMessages'>> & {
|
|
198
|
-
errorMessages?: Partial<Record<PhoneValidationReason, string>>;
|
|
199
|
-
};
|
|
200
|
-
interface ATelInputProps {
|
|
201
|
-
class?: HTMLAttributes['class'];
|
|
202
|
-
placeholder?: string;
|
|
203
|
-
disabled?: boolean;
|
|
204
|
-
loading?: boolean;
|
|
205
|
-
size?: ATelInputSize;
|
|
206
|
-
/**
|
|
207
|
-
* Text direction. Omit (or pass `'auto'`) to inherit from the page — RTL pages get an
|
|
208
|
-
* RTL field automatically. Pass `'ltr'` / `'rtl'` to force it.
|
|
209
|
-
*/
|
|
210
|
-
dir?: ATelInputDir;
|
|
211
|
-
/**
|
|
212
|
-
* BCP-47 locale (e.g. `'ar'`, `'fr'`). When set, country names render localized via
|
|
213
|
-
* `Intl.DisplayNames` and the format hint uses the locale's numerals.
|
|
214
|
-
*/
|
|
215
|
-
locale?: string;
|
|
216
|
-
/**
|
|
217
|
-
* Localized UI strings. A single bag covering the picker, validation errors, and a11y
|
|
218
|
-
* labels. Individual props (`searchPlaceholder`, `emptyText`, `loadingText`,
|
|
219
|
-
* `errorMessages`) take precedence over the matching `messages` key when both are set.
|
|
220
|
-
*/
|
|
221
|
-
messages?: TelInputMessagesInput;
|
|
222
|
-
/**
|
|
223
|
-
* Whitelist of allowed dial-digit codes (no `+`), e.g. `['20', '966']`.
|
|
224
|
-
* Countries outside this list are still shown in the picker but rendered as disabled.
|
|
225
|
-
*/
|
|
226
|
-
allowedDialCodes?: string[];
|
|
227
|
-
/** Light up the field's validation styling — coloured border + ring on the input and the
|
|
228
|
-
* error message line below — when the number is valid / invalid. Default `false`, so the
|
|
229
|
-
* field stays neutral and validation surfacing is left to the consumer (via the
|
|
230
|
-
* `validation` ref exposure). */
|
|
231
|
-
showValidation?: boolean;
|
|
232
|
-
/** Show the green check / red alert icon at the end of the field. Default `false`; opt
|
|
233
|
-
* in with `true`. Independent of `showValidation` — you can show the icon without the
|
|
234
|
-
* coloured field, or vice versa. The slots `#valid-icon` / `#error-icon` still apply. */
|
|
235
|
-
showValidationIcon?: boolean;
|
|
236
|
-
/**
|
|
237
|
-
* Country auto-detect strategy. Defaults to `'auto'` — try IP geolocation first, then
|
|
238
|
-
* timezone, then `navigator.language`, finally `defaultCountry`.
|
|
239
|
-
*/
|
|
240
|
-
detectCountry?: DetectionStrategy;
|
|
241
|
-
/**
|
|
242
|
-
* Initial country. Accepts either an ISO2 code (`'EG'`) or a dial-digit string
|
|
243
|
-
* (`'20'`, `'+20'`). When set, the picker is visible at mount with this country
|
|
244
|
-
* pre-selected — overrides the hidden-until-detected default.
|
|
245
|
-
*/
|
|
246
|
-
defaultCountry?: string;
|
|
247
|
-
/** Override the IP geolocation endpoint. Must return JSON with `country_code` or `country`. */
|
|
248
|
-
ipEndpoint?: string;
|
|
249
|
-
/** Localized strings for the country picker UI. */
|
|
250
|
-
searchPlaceholder?: string;
|
|
251
|
-
emptyText?: string;
|
|
252
|
-
loadingText?: string;
|
|
253
|
-
/** Error labels keyed by reason. Each gets a sensible English default. */
|
|
254
|
-
errorMessages?: Partial<Record<PhoneValidationReason, string>>;
|
|
255
|
-
/**
|
|
256
|
-
* When true, the country picker is hidden until a leading dial code is detected in the
|
|
257
|
-
* phone input. Every keystroke runs a longest-prefix match against known dial codes; on
|
|
258
|
-
* first match the picker reveals with that country and the matched dial digits are
|
|
259
|
-
* stripped from `phone`. Skips the onMount IP/timezone/locale detection chain.
|
|
260
|
-
*/
|
|
261
|
-
detectFromInput?: boolean;
|
|
262
|
-
/**
|
|
263
|
-
* Debounce window (ms) for `detectFromInput` detection. Each keystroke schedules the
|
|
264
|
-
* libphonenumber parse + lookup; bursts of typing/paste collapse into a single call.
|
|
265
|
-
* Clearing the input is not debounced — the picker hides immediately. Default 150ms.
|
|
266
|
-
*/
|
|
267
|
-
detectDebounceMs?: number;
|
|
268
|
-
/** Override the flag URL builder, forwarded to ACountrySelect. */
|
|
269
|
-
flagUrl?: (iso2: string, width: number) => string;
|
|
270
|
-
/** Custom search predicate, forwarded to ACountrySelect. */
|
|
271
|
-
searcher?: (query: string, country: CountryOption) => boolean;
|
|
272
|
-
/** Provide your own country list, forwarded to ACountrySelect. */
|
|
273
|
-
countries?: CountryOption[];
|
|
274
|
-
/**
|
|
275
|
-
* Fully custom country detection. When provided, this function runs in place of the
|
|
276
|
-
* built-in chain — `detectCountry`-style options are still honored but the function
|
|
277
|
-
* receives them and is free to ignore them.
|
|
278
|
-
*/
|
|
279
|
-
detector?: (options: DetectCountryOptions) => Promise<string | null | undefined>;
|
|
280
|
-
/** Forwarded to ACountrySelect: classes for the popover content surface. */
|
|
281
|
-
contentClass?: string;
|
|
282
|
-
/** Forwarded to ACountrySelect: classes for the desktop popover surface. */
|
|
283
|
-
popoverClass?: string;
|
|
284
|
-
/** Forwarded to ACountrySelect: classes for the mobile drawer surface. */
|
|
285
|
-
drawerClass?: string;
|
|
286
|
-
/** Classes for the inner phone field input element. */
|
|
287
|
-
inputClass?: string;
|
|
288
|
-
/** Classes for the outer wrapper that holds country select + input. */
|
|
289
|
-
fieldClass?: string;
|
|
290
|
-
/** Classes for the helper hint line. */
|
|
291
|
-
hintClass?: string;
|
|
292
|
-
/** Classes for the error message line. */
|
|
293
|
-
errorClass?: string;
|
|
294
|
-
/**
|
|
295
|
-
* How page scroll is blocked while the country popover is open. Defaults to `'events'`
|
|
296
|
-
* (sticky-safe document-level lock). Pass `'body'` for the legacy
|
|
297
|
-
* `body { overflow: hidden }` lock, or `'none'` to leave page scrolling alone.
|
|
298
|
-
*/
|
|
299
|
-
scrollLock?: 'events' | 'body' | 'none';
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Props for {@link ACountryFlag} — the standalone flag image component. Renders a
|
|
303
|
-
* `flagcdn` image for an ISO2 code with an automatic text-badge fallback when the
|
|
304
|
-
* image fails to load. Surface separately so it can be used outside `ATelInput`
|
|
305
|
-
* (e.g., in a custom country picker).
|
|
306
|
-
*/
|
|
307
|
-
interface ACountryFlagProps {
|
|
308
|
-
/** ISO 3166-1 alpha-2 country code, case-insensitive. */
|
|
309
|
-
iso2: string;
|
|
310
|
-
/** Pixel width served by flagcdn. 40 is crisp at retina up to ~24px wide. */
|
|
311
|
-
width?: number;
|
|
312
|
-
/** Optional explicit URL override. When set, `iso2` / `width` / `flagUrl` are ignored. */
|
|
313
|
-
src?: string | null;
|
|
314
|
-
/** Function `(iso2, width) => string` — fully replace the URL builder. */
|
|
315
|
-
flagUrl?: FlagUrlBuilder;
|
|
316
|
-
alt?: string;
|
|
317
|
-
class?: HTMLAttributes['class'];
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Slot prop shape for {@link ACountryFlag}. The `empty` slot is rendered when no
|
|
321
|
-
* flag URL is available and no ISO2 fallback can be derived.
|
|
322
|
-
*/
|
|
323
|
-
interface ACountryFlagSlots {
|
|
324
|
-
/** Rendered when the flag URL is unavailable and no ISO2 text fallback can be derived. */
|
|
325
|
-
empty?: () => unknown;
|
|
326
|
-
}
|
|
327
|
-
declare const DEFAULT_ERROR_MESSAGES: Record<PhoneValidationReason, string>;
|
|
328
|
-
/** English defaults for every {@link TelInputMessages} key. */
|
|
329
|
-
declare const DEFAULT_MESSAGES: TelInputMessages;
|
|
330
|
-
/**
|
|
331
|
-
* Merge a partial `messages` override onto the English defaults. Used internally by
|
|
332
|
-
* `ATelInput` to resolve a complete {@link TelInputMessages} object.
|
|
333
|
-
*/
|
|
334
|
-
declare function resolveMessages(input?: TelInputMessagesInput): TelInputMessages;
|
|
335
|
-
/**
|
|
336
|
-
* Slot prop shape for {@link ATelInput}. Use to get full slot-prop type inference
|
|
337
|
-
* when overriding slots in a consumer template:
|
|
338
|
-
*
|
|
339
|
-
* <ATelInput #suffix="{ validationState }">…</ATelInput>
|
|
340
|
-
* ↑ inferred as `'idle' | 'valid' | 'error'`
|
|
341
|
-
*
|
|
342
|
-
* Or in TypeScript code:
|
|
343
|
-
* type SuffixProps = Parameters<NonNullable<ATelInputSlots['suffix']>>[0];
|
|
344
|
-
*/
|
|
345
|
-
interface ATelInputSlots {
|
|
346
|
-
/** Content before the country select trigger (e.g. an icon). */
|
|
347
|
-
prefix?: () => unknown;
|
|
348
|
-
/** Content between the input and the validation icons. */
|
|
349
|
-
suffix?: (props: {
|
|
350
|
-
validationState: 'idle' | 'valid' | 'error';
|
|
351
|
-
validation: PhoneValidationResult;
|
|
352
|
-
}) => unknown;
|
|
353
|
-
/** Replace the green check shown when the number validates. */
|
|
354
|
-
'valid-icon'?: () => unknown;
|
|
355
|
-
/** Replace the warning icon shown when the number fails validation. */
|
|
356
|
-
'error-icon'?: (props: {
|
|
357
|
-
reason: string;
|
|
358
|
-
}) => unknown;
|
|
359
|
-
/** Replace the dim helper line shown below the input when empty. */
|
|
360
|
-
hint?: (props: {
|
|
361
|
-
country: string;
|
|
362
|
-
formatHint: string;
|
|
363
|
-
example: string | null;
|
|
364
|
-
}) => unknown;
|
|
365
|
-
/** Replace the error message rendered when invalid. */
|
|
366
|
-
error?: (props: {
|
|
367
|
-
message: string;
|
|
368
|
-
reason: string;
|
|
369
|
-
validation: PhoneValidationResult;
|
|
370
|
-
}) => unknown;
|
|
371
|
-
/** Forwarded to ACountrySelect — replace the trigger button. */
|
|
372
|
-
trigger?: (props: {
|
|
373
|
-
selectedCountry: CountryOption | null;
|
|
374
|
-
open: boolean;
|
|
375
|
-
sizeClasses: string;
|
|
376
|
-
}) => unknown;
|
|
377
|
-
/** Forwarded to ACountrySelect — replace the chevron. */
|
|
378
|
-
chevron?: (props: {
|
|
379
|
-
open: boolean;
|
|
380
|
-
}) => unknown;
|
|
381
|
-
/** Forwarded — replace any flag rendering. */
|
|
382
|
-
flag?: (props: {
|
|
383
|
-
country: CountryOption;
|
|
384
|
-
context: 'trigger' | 'item';
|
|
385
|
-
}) => unknown;
|
|
386
|
-
/** Forwarded — replace each country list row. */
|
|
387
|
-
item?: (props: {
|
|
388
|
-
country: CountryOption;
|
|
389
|
-
selected: boolean;
|
|
390
|
-
disabled: boolean;
|
|
391
|
-
select: () => void;
|
|
392
|
-
}) => unknown;
|
|
393
|
-
/** Forwarded — section header. */
|
|
394
|
-
'group-header'?: (props: {
|
|
395
|
-
label: string;
|
|
396
|
-
group: 'suggested' | 'all';
|
|
397
|
-
}) => unknown;
|
|
398
|
-
/** Forwarded — search bar. */
|
|
399
|
-
search?: (props: {
|
|
400
|
-
value: string;
|
|
401
|
-
setValue: (v: string) => void;
|
|
402
|
-
isSearching: boolean;
|
|
403
|
-
}) => unknown;
|
|
404
|
-
loading?: () => unknown;
|
|
405
|
-
empty?: (props: {
|
|
406
|
-
query: string;
|
|
407
|
-
}) => unknown;
|
|
408
|
-
/** Replace the spinner shown in the picker slot during the debounce window. */
|
|
409
|
-
detecting?: () => unknown;
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Emit map for {@link ATelInput}. `update:phone` carries the digits-only string,
|
|
413
|
-
* `update:country` carries the dial-number (not ISO2). Surface for consumers who
|
|
414
|
-
* wire the events manually instead of via `v-model:phone` / `v-model:country`.
|
|
415
|
-
*/
|
|
416
|
-
type ATelInputEmits = {
|
|
417
|
-
'update:phone': [value: string];
|
|
418
|
-
'update:country': [value: number | null];
|
|
419
|
-
};
|
|
420
|
-
/**
|
|
421
|
-
* Props for {@link ACountrySelect} — the standalone country picker. Surface
|
|
422
|
-
* separately so it can be used outside `ATelInput` with full type support.
|
|
423
|
-
*/
|
|
424
|
-
interface ACountrySelectProps {
|
|
425
|
-
class?: HTMLAttributes['class'];
|
|
426
|
-
triggerClass?: HTMLAttributes['class'];
|
|
427
|
-
contentClass?: HTMLAttributes['class'];
|
|
428
|
-
popoverClass?: HTMLAttributes['class'];
|
|
429
|
-
drawerClass?: HTMLAttributes['class'];
|
|
430
|
-
searchPlaceholder?: string;
|
|
431
|
-
emptyText?: string;
|
|
432
|
-
loadingText?: string;
|
|
433
|
-
suggestedLabel?: string;
|
|
434
|
-
allCountriesLabel?: string;
|
|
435
|
-
/** ISO2 codes that are selectable. Others are listed but disabled. */
|
|
436
|
-
allowedDialCodes?: string[];
|
|
437
|
-
disabled?: boolean;
|
|
438
|
-
/** Drives the trigger button padding + text size. Matches ATelInput's `size`. */
|
|
439
|
-
size?: ATelInputSize;
|
|
440
|
-
/** Max items rendered under the "Suggested" header (current + recents, deduped). */
|
|
441
|
-
suggestedLimit?: number;
|
|
442
|
-
/** Cap the number of matching countries shown in search results. */
|
|
443
|
-
maxResults?: number;
|
|
444
|
-
/** Override the flag URL builder, e.g. `(iso, w) => `/flags/${iso}.svg``. */
|
|
445
|
-
flagUrl?: (iso2: string, width: number) => string;
|
|
446
|
-
/** Custom search predicate. Default: substring match on the precomputed `search_key`. */
|
|
447
|
-
searcher?: (query: string, country: CountryOption) => boolean;
|
|
448
|
-
/** Provide your own country list (bypasses the REST Countries fetch). */
|
|
449
|
-
countries?: CountryOption[];
|
|
450
|
-
/** Override the right-side kbd hints. Pass `null` to hide. */
|
|
451
|
-
kbdOpen?: string | null;
|
|
452
|
-
kbdClose?: string | null;
|
|
453
|
-
/** BCP-47 locale — country names render localized via `Intl.DisplayNames`. */
|
|
454
|
-
locale?: string;
|
|
455
|
-
/** Prefix of the trigger's `aria-label` when a country is selected, e.g. `"Country"`. */
|
|
456
|
-
countryLabel?: string;
|
|
457
|
-
/** Trigger's `aria-label` when no country is selected. */
|
|
458
|
-
selectCountryLabel?: string;
|
|
459
|
-
/** How page scroll is blocked while the popover is open. Default `'events'`. */
|
|
460
|
-
scrollLock?: 'events' | 'body' | 'none';
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* Slot prop shape for {@link ACountrySelect}. Forwarded versions of these slots
|
|
464
|
-
* also appear on {@link ATelInputSlots} (`trigger`, `chevron`, `flag`, `item`,
|
|
465
|
-
* etc.) — keep them in sync when changing one.
|
|
466
|
-
*/
|
|
467
|
-
interface ACountrySelectSlots {
|
|
468
|
-
/** Replace the entire country picker trigger button. */
|
|
469
|
-
trigger?: (props: {
|
|
470
|
-
selectedCountry: CountryOption | null;
|
|
471
|
-
open: boolean;
|
|
472
|
-
sizeClasses: string;
|
|
473
|
-
}) => unknown;
|
|
474
|
-
/** Replace the chevron icon. */
|
|
475
|
-
chevron?: (props: {
|
|
476
|
-
open: boolean;
|
|
477
|
-
}) => unknown;
|
|
478
|
-
/** Replace just the flag rendered in the trigger and items. */
|
|
479
|
-
flag?: (props: {
|
|
480
|
-
country: CountryOption;
|
|
481
|
-
context: 'trigger' | 'item';
|
|
482
|
-
}) => unknown;
|
|
483
|
-
/** Replace the entire search bar (input + icon + kbd). */
|
|
484
|
-
search?: (props: {
|
|
485
|
-
value: string;
|
|
486
|
-
setValue: (v: string) => void;
|
|
487
|
-
isSearching: boolean;
|
|
488
|
-
}) => unknown;
|
|
489
|
-
/** Replace the search-bar leading icon. */
|
|
490
|
-
'search-icon'?: () => unknown;
|
|
491
|
-
/** Replace the loading state. */
|
|
492
|
-
loading?: () => unknown;
|
|
493
|
-
/** Replace the empty/no-results state. */
|
|
494
|
-
empty?: (props: {
|
|
495
|
-
query: string;
|
|
496
|
-
}) => unknown;
|
|
497
|
-
/** Replace a section header. */
|
|
498
|
-
'group-header'?: (props: {
|
|
499
|
-
label: string;
|
|
500
|
-
group: 'suggested' | 'all';
|
|
501
|
-
}) => unknown;
|
|
502
|
-
/** Replace each country list row. */
|
|
503
|
-
item?: (props: {
|
|
504
|
-
country: CountryOption;
|
|
505
|
-
selected: boolean;
|
|
506
|
-
disabled: boolean;
|
|
507
|
-
select: () => void;
|
|
508
|
-
}) => unknown;
|
|
509
|
-
/** Replace just the right-side check icon for the selected row. */
|
|
510
|
-
'item-check'?: (props: {
|
|
511
|
-
country: CountryOption;
|
|
512
|
-
}) => unknown;
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Emit map for {@link ACountrySelect}. The `selected` is `v-model:selected`,
|
|
516
|
-
* carrying the ISO2 code of the picked country.
|
|
517
|
-
*/
|
|
518
|
-
type ACountrySelectEmits = {
|
|
519
|
-
'update:selected': [value: string];
|
|
520
|
-
};
|
|
521
|
-
//#endregion
|
|
522
4
|
//#region src/components/ATelInput.vue.d.ts
|
|
523
5
|
type __VLS_Props$1 = ATelInputProps;
|
|
524
6
|
type __VLS_Slots$2 = ATelInputSlots;
|
|
7
|
+
declare function focus(options?: FocusOptions): void;
|
|
8
|
+
declare function blur(): void;
|
|
9
|
+
declare function select(): void;
|
|
525
10
|
type __VLS_ModelProps$1 = {
|
|
526
11
|
'phone'?: string;
|
|
527
12
|
/** Public `v-model:country` — the **dial number** (e.g. `20` for Egypt, `44` for the UK,
|
|
@@ -529,25 +14,54 @@ type __VLS_ModelProps$1 = {
|
|
|
529
14
|
* tracks a richer ISO2 code (`selectedIso2`) because dial codes alone can't disambiguate
|
|
530
15
|
* NANP (`+1` covers 25+ countries) — the picker still needs an exact country. */
|
|
531
16
|
'country'?: number | null;
|
|
17
|
+
/**
|
|
18
|
+
* Default v-model — the canonical **E.164** string (e.g. `'+201066105963'`).
|
|
19
|
+
*
|
|
20
|
+
* Single-string contract for VeeValidate's `<Field v-slot="{ field }">` pattern
|
|
21
|
+
* (`v-bind="field"`), native `<form>` submission, or any `v-model="phoneE164"`
|
|
22
|
+
* consumer. Bind it with:
|
|
23
|
+
*
|
|
24
|
+
* <ATelInput v-model="phoneE164" />
|
|
25
|
+
*
|
|
26
|
+
* <VeeField v-slot="{ field, errors }" name="phone">
|
|
27
|
+
* <ATelInput v-bind="field" :error="errors[0]" />
|
|
28
|
+
* </VeeField>
|
|
29
|
+
*
|
|
30
|
+
* When set externally, the value is parsed via libphonenumber-js → the country
|
|
31
|
+
* picker and the digits-only `phone` model are derived from it. When the user
|
|
32
|
+
* types or picks a country, the composed E.164 is written back out. Stays in
|
|
33
|
+
* sync with `v-model:phone` / `v-model:country` — you can use either contract.
|
|
34
|
+
*/
|
|
35
|
+
modelValue?: string;
|
|
532
36
|
};
|
|
533
37
|
type __VLS_PublicProps$1 = __VLS_Props$1 & __VLS_ModelProps$1;
|
|
534
38
|
declare const __VLS_base$2: import("vue").DefineComponent<__VLS_PublicProps$1, {
|
|
535
39
|
validation: import("vue").ComputedRef<PhoneValidationResult>;
|
|
536
40
|
required: import("vue").ComputedRef<PhoneRequiredInfo | null>;
|
|
537
41
|
selectedDialCode: import("vue").ComputedRef<string | null>;
|
|
538
|
-
validationState: import("vue").ComputedRef<"
|
|
539
|
-
visibleValidationState: import("vue").ComputedRef<"
|
|
42
|
+
validationState: import("vue").ComputedRef<"valid" | "error" | "idle">;
|
|
43
|
+
visibleValidationState: import("vue").ComputedRef<"valid" | "error" | "idle">;
|
|
540
44
|
isDetecting: Readonly<import("vue").Ref<boolean, boolean>>;
|
|
541
45
|
hasFinishedTyping: Readonly<import("vue").Ref<boolean, boolean>>;
|
|
542
46
|
detectionAttempted: Readonly<import("vue").Ref<boolean, boolean>>;
|
|
47
|
+
focus: typeof focus;
|
|
48
|
+
blur: typeof blur;
|
|
49
|
+
select: typeof select;
|
|
543
50
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
544
|
-
|
|
545
|
-
"update:
|
|
51
|
+
blur: (event: FocusEvent) => any;
|
|
52
|
+
"update:phone": (...args: unknown[]) => any;
|
|
53
|
+
"update:country": (...args: unknown[]) => any;
|
|
54
|
+
"update:modelValue": (...args: unknown[]) => any;
|
|
55
|
+
focus: (event: FocusEvent) => any;
|
|
546
56
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps$1> & Readonly<{
|
|
547
|
-
|
|
548
|
-
"onUpdate:
|
|
57
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
58
|
+
"onUpdate:phone"?: ((...args: unknown[]) => any) | undefined;
|
|
59
|
+
"onUpdate:country"?: ((...args: unknown[]) => any) | undefined;
|
|
60
|
+
"onUpdate:modelValue"?: ((...args: unknown[]) => any) | undefined;
|
|
61
|
+
onFocus?: ((event: FocusEvent) => any) | undefined;
|
|
549
62
|
}>, {
|
|
550
63
|
size: ATelInputSize;
|
|
64
|
+
validateOn: ATelInputValidateOn;
|
|
551
65
|
placeholder: string;
|
|
552
66
|
showValidationIcon: boolean;
|
|
553
67
|
detectCountry: DetectionStrategy;
|
|
@@ -581,18 +95,18 @@ declare const __VLS_base$1: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
581
95
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
582
96
|
"onUpdate:selected"?: ((value: string) => any) | undefined;
|
|
583
97
|
}>, {
|
|
98
|
+
size: ATelInputSize;
|
|
584
99
|
searchPlaceholder: string;
|
|
585
100
|
emptyText: string;
|
|
586
101
|
loadingText: string;
|
|
587
102
|
suggestedLabel: string;
|
|
588
103
|
allCountriesLabel: string;
|
|
589
|
-
|
|
104
|
+
countryLabel: string;
|
|
105
|
+
selectCountryLabel: string;
|
|
590
106
|
suggestedLimit: number;
|
|
591
107
|
maxResults: number;
|
|
592
108
|
kbdOpen: string | null;
|
|
593
109
|
kbdClose: string | null;
|
|
594
|
-
countryLabel: string;
|
|
595
|
-
selectCountryLabel: string;
|
|
596
110
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
597
111
|
declare const __VLS_export$1: typeof __VLS_base$1;
|
|
598
112
|
declare const _default$1: typeof __VLS_export$1;
|
|
@@ -635,6 +149,12 @@ declare const DIAL_TO_ISO2_FALLBACK: Record<string, string>;
|
|
|
635
149
|
/** localStorage key for the user's most recently picked countries. Used as a
|
|
636
150
|
* tie-breaker when multiple countries share a dial code (e.g. all NANP). */
|
|
637
151
|
declare const COUNTRY_RECENTS_KEY = "ali_ui_country_recents_v1";
|
|
152
|
+
/** ISO2 codes iterated by tier 2 of `matchLeadingDialCode` when looking for a country
|
|
153
|
+
* that accepts a local-format input as valid. Mirrors the `FALLBACK_COUNTRIES` list in
|
|
154
|
+
* {@link usePhoneValidation} (kept in sync by tests + by being short and obvious).
|
|
155
|
+
* Order matters — earlier entries get priority when multiple countries would each
|
|
156
|
+
* validate the same input. Built around the most-populated / most-likely countries. */
|
|
157
|
+
declare const FALLBACK_ISO2_LIST: readonly string[];
|
|
638
158
|
interface DialMatch {
|
|
639
159
|
country: CountryOption;
|
|
640
160
|
/** The national significant number — what the phone input should hold, with both the
|
|
@@ -722,70 +242,85 @@ interface UseTypingPhaseReturn {
|
|
|
722
242
|
}
|
|
723
243
|
declare function useTypingPhase(opts: UseTypingPhaseOptions): UseTypingPhaseReturn;
|
|
724
244
|
//#endregion
|
|
725
|
-
//#region src/composables/
|
|
245
|
+
//#region src/composables/useCountrySelection.d.ts
|
|
726
246
|
/**
|
|
727
|
-
*
|
|
247
|
+
* How the currently-selected country came to be.
|
|
728
248
|
*
|
|
729
|
-
*
|
|
730
|
-
*
|
|
249
|
+
* The source drives the detection state machine — some sources are "hints" that
|
|
250
|
+
* typed-international input is allowed to override (`'default'`, `'env'`,
|
|
251
|
+
* `'external'`), others are "locks" that must be cleared before detection can
|
|
252
|
+
* re-route the picker (`'picker'`, `'input'`).
|
|
253
|
+
*/
|
|
254
|
+
type CountrySource = /** Nothing selected. */'none' /** Seeded from the `defaultCountry` prop at mount. Overridable. */ | 'default' /** Silent IP / timezone / `navigator.language` resolution at mount. Overridable. */ | 'env' /** `tryMatchPhone` recognised a dial code in user input. Locks until cleared. */ | 'input' /** User clicked an item in the country picker. Locks until cleared. */ | 'picker'
|
|
255
|
+
/** Caller wrote `v-model:country` (dial number) or `v-model` (E.164) directly.
|
|
256
|
+
* Treated as a hint — typed-international input can still override. */
|
|
257
|
+
| 'external';
|
|
258
|
+
interface UseCountrySelectionReturn {
|
|
259
|
+
/** Currently selected ISO 3166-1 alpha-2 code, or `''` when no country selected. */
|
|
260
|
+
iso2: Ref<string>;
|
|
261
|
+
/** Where the current selection came from. */
|
|
262
|
+
source: Ref<CountrySource>;
|
|
263
|
+
/** `true` when typed-input detection should be suppressed (`'picker'` / `'input'`). */
|
|
264
|
+
detectionLocked: ComputedRef<boolean>;
|
|
265
|
+
/** Set both `iso2` and `source` atomically. The single mutator for the selection. */
|
|
266
|
+
set: (iso2: string, source: CountrySource) => void;
|
|
267
|
+
/** Reset to the empty / no-country state. */
|
|
268
|
+
clear: () => void;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* The picker selection state machine for {@link ATelInput}, consolidated into a
|
|
272
|
+
* single composable so the component doesn't have to juggle three boolean flags
|
|
273
|
+
* (`userPickedCountry` / `autoSettingCountry` / `inputDetectionApplied`) and
|
|
274
|
+
* reason about their pairwise interactions.
|
|
731
275
|
*
|
|
732
|
-
*
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
*
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
276
|
+
* Every write to the selection goes through {@link UseCountrySelectionReturn.set},
|
|
277
|
+
* which records both the new ISO2 and the *origin* of the change. That makes the
|
|
278
|
+
* downstream decision — should detection re-route the picker on the next typed-input
|
|
279
|
+
* burst? — a one-liner: `if (detectionLocked.value) return;`.
|
|
280
|
+
*/
|
|
281
|
+
declare function useCountrySelection(): UseCountrySelectionReturn;
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/composables/useSyncedModel.d.ts
|
|
284
|
+
interface UseSyncedModelOptions<T> {
|
|
285
|
+
/** The `defineModel` ref to keep in sync with internal state. */
|
|
286
|
+
model: Ref<T>;
|
|
287
|
+
/**
|
|
288
|
+
* Internal reactive sources that, when they change, should re-compose and emit
|
|
289
|
+
* a new model value. Typically the refs that {@link compose} reads from.
|
|
290
|
+
*/
|
|
291
|
+
triggers: WatchSource[];
|
|
292
|
+
/** Compose the next model value from current internal state. */
|
|
293
|
+
compose: () => T;
|
|
294
|
+
/** Apply an externally-written model value into internal state. */
|
|
295
|
+
apply: (next: T) => void;
|
|
296
|
+
/** Equality test for the model value. Defaults to `Object.is`. */
|
|
297
|
+
isEqual?: (a: T, b: T) => boolean;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Two-way bidirectional sync between a `defineModel` ref and internal component
|
|
301
|
+
* state — with the **echo-loop guard** built in. Solves a recurring class of
|
|
302
|
+
* bugs in this component where two watchers (external→internal and
|
|
303
|
+
* internal→external) would fight each other and rewrite values the user just
|
|
304
|
+
* typed.
|
|
742
305
|
*
|
|
743
|
-
*
|
|
306
|
+
* Mechanics:
|
|
744
307
|
*
|
|
745
|
-
*
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
308
|
+
* 1. When any of `triggers` change AND we're not currently applying an
|
|
309
|
+
* external write, recompute the model value via `compose()` and write it
|
|
310
|
+
* into `model`. Stamp `lastEmitted` first so we recognise the echo.
|
|
311
|
+
* 2. When `model` changes AND the new value isn't the echo of our last emit,
|
|
312
|
+
* apply it into internal state via `apply()`. The `applying` flag is held
|
|
313
|
+
* for the duration of `apply()` so step (1) skips while we mutate.
|
|
750
314
|
*
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
* `
|
|
315
|
+
* Used for:
|
|
316
|
+
* - `modelValue` (E.164 string) ↔ `phone` + `selectedIso2`.
|
|
317
|
+
* - `country` (dial-number) ↔ `selectedIso2`.
|
|
318
|
+
*
|
|
319
|
+
* The hand-rolled equivalents (`applyingModelValue` / `lastEmittedModelValue`
|
|
320
|
+
* plus the country↔iso2 watcher pair with `autoSettingCountry`) collapse into
|
|
321
|
+
* two calls to this helper.
|
|
754
322
|
*/
|
|
755
|
-
|
|
756
|
-
validate: UsePhoneValidationReturn['validate'];
|
|
757
|
-
getRequiredInfo: UsePhoneValidationReturn['getRequiredInfo'];
|
|
758
|
-
getCountryByValue: UsePhoneValidationReturn['getCountryByValue'];
|
|
759
|
-
}
|
|
760
|
-
interface UseTelInputValidationInputs {
|
|
761
|
-
/** Digits-only national number model. */
|
|
762
|
-
phone: Ref<string>;
|
|
763
|
-
/** Currently selected ISO2 — empty string when no country chosen. */
|
|
764
|
-
selectedIso2: Ref<string>;
|
|
765
|
-
/** From {@link useTypingPhase} — gates visible state during the debounce window. */
|
|
766
|
-
hasFinishedTyping: Readonly<Ref<boolean>>;
|
|
767
|
-
/** Resolved i18n messages (merged defaults + consumer overrides). */
|
|
768
|
-
messages: ComputedRef<TelInputMessages>;
|
|
769
|
-
}
|
|
770
|
-
interface UseTelInputValidationConfig {
|
|
771
|
-
/** BCP-47 locale; affects `format_hint` numeral rendering. */
|
|
772
|
-
locale: () => string | undefined;
|
|
773
|
-
/** Light up field tinting + error message line. From props. */
|
|
774
|
-
showValidation: () => boolean | undefined;
|
|
775
|
-
/** Per-reason error string overrides. From props. */
|
|
776
|
-
errorMessages: () => Partial<Record<PhoneValidationReason, string>> | undefined;
|
|
777
|
-
}
|
|
778
|
-
interface UseTelInputValidationReturn {
|
|
779
|
-
validation: ComputedRef<PhoneValidationResult>;
|
|
780
|
-
required: ComputedRef<PhoneRequiredInfo | null>;
|
|
781
|
-
validationState: ComputedRef<'idle' | 'valid' | 'error'>;
|
|
782
|
-
visibleValidationState: ComputedRef<'idle' | 'valid' | 'error'>;
|
|
783
|
-
errorMessage: ComputedRef<string | null>;
|
|
784
|
-
showError: ComputedRef<boolean>;
|
|
785
|
-
showHint: ComputedRef<boolean>;
|
|
786
|
-
selectedDialCode: ComputedRef<string | null>;
|
|
787
|
-
}
|
|
788
|
-
declare function useTelInputValidation(deps: UseTelInputValidationDeps, inputs: UseTelInputValidationInputs, config: UseTelInputValidationConfig): UseTelInputValidationReturn;
|
|
323
|
+
declare function useSyncedModel<T>(options: UseSyncedModelOptions<T>): void;
|
|
789
324
|
//#endregion
|
|
790
|
-
export { _default as ACountryFlag, type ACountryFlagProps, type ACountryFlagSlots, _default$1 as ACountrySelect, type ACountrySelectEmits, type ACountrySelectProps, type ACountrySelectSlots, _default$2 as ATelInput, type ATelInputDir, type ATelInputEmits, type ATelInputProps, type ATelInputSize, type ATelInputSlots, type ATelInputVariants, COUNTRY_RECENTS_KEY, CountryMatchingDeps, CountryOption, DEFAULT_ERROR_MESSAGES, DEFAULT_MESSAGES, DIAL_TO_ISO2_FALLBACK, DetectCountryOptions, DetectionStrategy, DialMatch, type FlagUrlBuilder, LOCALE_DIGIT_RANGES, MatchLeadingDialCodeOptions, PhoneRequiredInfo, PhoneValidationReason, PhoneValidationResult, RestCountry, type TelInputMessages, type TelInputMessagesInput, UseCountryDetectionReturn, UsePhoneValidationReturn, UseTelInputValidationConfig, UseTelInputValidationDeps, UseTelInputValidationInputs, UseTelInputValidationReturn, UseTypingPhaseOptions, UseTypingPhaseReturn, ValidateArgs, aTelInputVariants, defaultFlagUrl, detectCountry, localizeCountries, normalizeDigits, resolveMessages, useCountryDetection, useCountryMatching, usePhoneValidation, useTelInputValidation, useTypingPhase };
|
|
325
|
+
export { _default as ACountryFlag, type ACountryFlagProps, type ACountryFlagSlots, _default$1 as ACountrySelect, type ACountrySelectEmits, type ACountrySelectProps, type ACountrySelectSlots, _default$2 as ATelInput, type ATelInputDir, type ATelInputEmits, type ATelInputProps, type ATelInputSize, type ATelInputSlots, ATelInputValidateOn, type ATelInputVariants, COUNTRY_RECENTS_KEY, CountryMatchingDeps, CountryOption, CountrySource, DEFAULT_ERROR_MESSAGES, DEFAULT_MESSAGES, DIAL_TO_ISO2_FALLBACK, DetectCountryOptions, DetectionStrategy, DialMatch, FALLBACK_ISO2_LIST, type FlagUrlBuilder, LOCALE_DIGIT_RANGES, MatchLeadingDialCodeOptions, PhoneRequiredInfo, PhoneValidationReason, PhoneValidationResult, RestCountry, type TelInputMessages, type TelInputMessagesInput, UseCountryDetectionReturn, UseCountrySelectionReturn, UsePhoneValidationReturn, UseSyncedModelOptions, UseTelInputValidationConfig, UseTelInputValidationDeps, UseTelInputValidationInputs, UseTelInputValidationReturn, UseTypingPhaseOptions, UseTypingPhaseReturn, ValidateArgs, aTelInputVariants, defaultFlagUrl, detectCountry, localizeCountries, normalizeDigits, resolveMessages, useCountryDetection, useCountryMatching, useCountrySelection, usePhoneValidation, useSyncedModel, useTelInputValidation, useTypingPhase };
|
|
791
326
|
//# sourceMappingURL=index.d.cts.map
|