@alikhalilll/ui 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -45
- package/dist/assets/styles.css +2 -74
- package/dist/chunks/AResponsivePopoverContent.vue_vue_type_script_setup_true_lang-BrBsDiHc.mjs +113 -0
- package/dist/chunks/AResponsivePopoverContent.vue_vue_type_script_setup_true_lang-BrBsDiHc.mjs.map +1 -0
- package/dist/chunks/ATellInput.vue_vue_type_script_setup_true_lang-D4odgAna.mjs +1606 -0
- package/dist/chunks/ATellInput.vue_vue_type_script_setup_true_lang-D4odgAna.mjs.map +1 -0
- package/dist/chunks/useEventScrollLock-BcP8fg-L.mjs +241 -0
- package/dist/chunks/useEventScrollLock-BcP8fg-L.mjs.map +1 -0
- package/dist/entries/drawer/components/ADrawer.vue.d.ts +27 -0
- package/dist/entries/drawer/components/ADrawer.vue.d.ts.map +1 -0
- package/dist/entries/drawer/components/ADrawerContent.vue.d.ts +29 -0
- package/dist/entries/drawer/components/ADrawerContent.vue.d.ts.map +1 -0
- package/dist/entries/drawer/components/ADrawerOverlay.vue.d.ts +9 -0
- package/dist/entries/drawer/components/ADrawerOverlay.vue.d.ts.map +1 -0
- package/dist/entries/drawer/components/ADrawerTrigger.vue.d.ts +11 -0
- package/dist/entries/drawer/components/ADrawerTrigger.vue.d.ts.map +1 -0
- package/dist/entries/drawer/index.d.ts +5 -0
- package/dist/entries/drawer/index.d.ts.map +1 -0
- package/dist/entries/input/components/AInput.vue.d.ts +32 -0
- package/dist/entries/input/components/AInput.vue.d.ts.map +1 -0
- package/dist/entries/input/index.d.ts +2 -0
- package/dist/entries/input/index.d.ts.map +1 -0
- package/dist/entries/popover/components/APopover.vue.d.ts +20 -0
- package/dist/entries/popover/components/APopover.vue.d.ts.map +1 -0
- package/dist/entries/popover/components/APopoverContent.vue.d.ts +44 -0
- package/dist/entries/popover/components/APopoverContent.vue.d.ts.map +1 -0
- package/dist/entries/popover/components/APopoverOverlay.vue.d.ts +17 -0
- package/dist/entries/popover/components/APopoverOverlay.vue.d.ts.map +1 -0
- package/dist/entries/popover/components/APopoverTrigger.vue.d.ts +11 -0
- package/dist/entries/popover/components/APopoverTrigger.vue.d.ts.map +1 -0
- package/dist/entries/popover/composables/useEventScrollLock.d.ts +21 -0
- package/dist/entries/popover/composables/useEventScrollLock.d.ts.map +1 -0
- package/dist/entries/popover/index.d.ts +6 -0
- package/dist/entries/popover/index.d.ts.map +1 -0
- package/dist/entries/responsive-popover/components/AResponsivePopover.vue.d.ts +46 -0
- package/dist/entries/responsive-popover/components/AResponsivePopover.vue.d.ts.map +1 -0
- package/dist/entries/responsive-popover/components/AResponsivePopoverContent.vue.d.ts +35 -0
- package/dist/entries/responsive-popover/components/AResponsivePopoverContent.vue.d.ts.map +1 -0
- package/dist/entries/responsive-popover/components/AResponsivePopoverTrigger.vue.d.ts +16 -0
- package/dist/entries/responsive-popover/components/AResponsivePopoverTrigger.vue.d.ts.map +1 -0
- package/dist/entries/responsive-popover/composables/useResponsivePopoverContext.d.ts +10 -0
- package/dist/entries/responsive-popover/composables/useResponsivePopoverContext.d.ts.map +1 -0
- package/dist/entries/responsive-popover/index.d.ts +4 -0
- package/dist/entries/responsive-popover/index.d.ts.map +1 -0
- package/dist/entries/tell-input/components/ACountryFlag.vue.d.ts +26 -0
- package/dist/entries/tell-input/components/ACountryFlag.vue.d.ts.map +1 -0
- package/dist/entries/tell-input/components/ACountrySelect.vue.d.ts +136 -0
- package/dist/entries/tell-input/components/ACountrySelect.vue.d.ts.map +1 -0
- package/dist/entries/tell-input/components/ATellInput.vue.d.ts +141 -0
- package/dist/entries/tell-input/components/ATellInput.vue.d.ts.map +1 -0
- package/dist/entries/tell-input/composables/useCountryDetection.d.ts +44 -0
- package/dist/entries/tell-input/composables/useCountryDetection.d.ts.map +1 -0
- package/dist/entries/tell-input/composables/useCountryMatching.d.ts +44 -0
- package/dist/entries/tell-input/composables/useCountryMatching.d.ts.map +1 -0
- package/dist/entries/tell-input/composables/usePhoneValidation.d.ts +110 -0
- package/dist/entries/tell-input/composables/usePhoneValidation.d.ts.map +1 -0
- package/dist/entries/tell-input/composables/useTellInputValidation.d.ts +67 -0
- package/dist/entries/tell-input/composables/useTellInputValidation.d.ts.map +1 -0
- package/dist/entries/tell-input/composables/useTypingPhase.d.ts +50 -0
- package/dist/entries/tell-input/composables/useTypingPhase.d.ts.map +1 -0
- package/dist/entries/tell-input/index.d.ts +12 -0
- package/dist/entries/tell-input/index.d.ts.map +1 -0
- package/dist/entries/tell-input/utils/digits.d.ts +22 -0
- package/dist/entries/tell-input/utils/digits.d.ts.map +1 -0
- package/dist/entries/tell-input/utils/flag-url.d.ts +8 -0
- package/dist/entries/tell-input/utils/flag-url.d.ts.map +1 -0
- package/dist/entries/tell-input/utils/types.d.ts +120 -0
- package/dist/entries/tell-input/utils/types.d.ts.map +1 -0
- package/dist/index.d.ts +7 -1139
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +39 -33
- package/dist/popover.mjs +5 -4
- package/dist/responsive-popover.mjs +1 -1
- package/dist/tell-input.mjs +14 -9
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/{utils.d.ts → utils/sizes.d.ts} +18 -29
- package/dist/utils/sizes.d.ts.map +1 -0
- package/package.json +14 -10
- package/dist/chunks/APopoverContent.vue_vue_type_script_setup_true_lang-CjiJ12DR.mjs +0 -132
- package/dist/chunks/APopoverContent.vue_vue_type_script_setup_true_lang-CjiJ12DR.mjs.map +0 -1
- package/dist/chunks/AResponsivePopoverContent.vue_vue_type_script_setup_true_lang-5YbO6FdM.mjs +0 -92
- package/dist/chunks/AResponsivePopoverContent.vue_vue_type_script_setup_true_lang-5YbO6FdM.mjs.map +0 -1
- package/dist/chunks/ATellInput.vue_vue_type_script_setup_true_lang-D7hPj1g1.mjs +0 -1489
- package/dist/chunks/ATellInput.vue_vue_type_script_setup_true_lang-D7hPj1g1.mjs.map +0 -1
- package/dist/drawer.d.ts +0 -116
- package/dist/input.d.ts +0 -65
- package/dist/popover.d.ts +0 -117
- package/dist/responsive-popover.d.ts +0 -124
- package/dist/tell-input.d.ts +0 -740
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'vue';
|
|
2
|
+
import { type CountryOption } from '../composables/usePhoneValidation';
|
|
3
|
+
import { type Size } from '../../../utils';
|
|
4
|
+
type __VLS_Props = {
|
|
5
|
+
class?: HTMLAttributes['class'];
|
|
6
|
+
triggerClass?: HTMLAttributes['class'];
|
|
7
|
+
contentClass?: HTMLAttributes['class'];
|
|
8
|
+
popoverClass?: HTMLAttributes['class'];
|
|
9
|
+
drawerClass?: HTMLAttributes['class'];
|
|
10
|
+
searchPlaceholder?: string;
|
|
11
|
+
emptyText?: string;
|
|
12
|
+
loadingText?: string;
|
|
13
|
+
suggestedLabel?: string;
|
|
14
|
+
allCountriesLabel?: string;
|
|
15
|
+
/** ISO2 codes that are selectable. Others are listed but disabled. */
|
|
16
|
+
allowedDialCodes?: string[];
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** Drives the trigger button padding + text size. Matches ATellInput's `size`. */
|
|
19
|
+
size?: Size;
|
|
20
|
+
/** Max items rendered under the "Suggested" header (current + recents, deduped). */
|
|
21
|
+
suggestedLimit?: number;
|
|
22
|
+
/** Cap the number of matching countries shown in search results. */
|
|
23
|
+
maxResults?: number;
|
|
24
|
+
/** Override the flag URL builder, e.g. `(iso, w) => \`/flags/${iso}.svg\``. */
|
|
25
|
+
flagUrl?: (iso2: string, width: number) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Custom search predicate. Default: substring match on the precomputed `search_key`.
|
|
28
|
+
* Return `true` to keep the country in results.
|
|
29
|
+
*/
|
|
30
|
+
searcher?: (query: string, country: CountryOption) => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Provide your own country list (bypasses the REST Countries fetch). Useful when you
|
|
33
|
+
* already have a curated subset, an i18n'd list, or want to avoid the network call.
|
|
34
|
+
*/
|
|
35
|
+
countries?: CountryOption[];
|
|
36
|
+
/** Override the right-side kbd hints. Pass `null` to hide. */
|
|
37
|
+
kbdOpen?: string | null;
|
|
38
|
+
kbdClose?: string | null;
|
|
39
|
+
/** BCP-47 locale — country names render localized via `Intl.DisplayNames`. */
|
|
40
|
+
locale?: string;
|
|
41
|
+
/** Prefix of the trigger's `aria-label` when a country is selected, e.g. `"Country"`. */
|
|
42
|
+
countryLabel?: string;
|
|
43
|
+
/** Trigger's `aria-label` when no country is selected. */
|
|
44
|
+
selectCountryLabel?: string;
|
|
45
|
+
/**
|
|
46
|
+
* How page scroll is blocked while the popover is open. Defaults to `'events'` — an
|
|
47
|
+
* event-based lock that keeps the page scrollbar visible and `position: sticky` working.
|
|
48
|
+
* Pass `'body'` for the legacy `body { overflow: hidden }` lock, or `'none'` to allow
|
|
49
|
+
* the page to scroll freely.
|
|
50
|
+
*/
|
|
51
|
+
scrollLock?: 'events' | 'body' | 'none';
|
|
52
|
+
};
|
|
53
|
+
type __VLS_Slots = {
|
|
54
|
+
/** Replace the entire country picker trigger button. */
|
|
55
|
+
trigger?: (props: {
|
|
56
|
+
selectedCountry: CountryOption | null;
|
|
57
|
+
open: boolean;
|
|
58
|
+
sizeClasses: string;
|
|
59
|
+
}) => unknown;
|
|
60
|
+
/** Replace the chevron icon. */
|
|
61
|
+
chevron?: (props: {
|
|
62
|
+
open: boolean;
|
|
63
|
+
}) => unknown;
|
|
64
|
+
/** Replace just the flag rendered in the trigger and items. */
|
|
65
|
+
flag?: (props: {
|
|
66
|
+
country: CountryOption;
|
|
67
|
+
context: 'trigger' | 'item';
|
|
68
|
+
}) => unknown;
|
|
69
|
+
/** Replace the entire search bar (input + icon + kbd). */
|
|
70
|
+
search?: (props: {
|
|
71
|
+
value: string;
|
|
72
|
+
setValue: (v: string) => void;
|
|
73
|
+
isSearching: boolean;
|
|
74
|
+
}) => unknown;
|
|
75
|
+
/** Replace the search-bar leading icon. */
|
|
76
|
+
'search-icon'?: () => unknown;
|
|
77
|
+
/** Replace the loading state. */
|
|
78
|
+
loading?: () => unknown;
|
|
79
|
+
/** Replace the empty/no-results state. */
|
|
80
|
+
empty?: (props: {
|
|
81
|
+
query: string;
|
|
82
|
+
}) => unknown;
|
|
83
|
+
/** Replace a section header. */
|
|
84
|
+
'group-header'?: (props: {
|
|
85
|
+
label: string;
|
|
86
|
+
group: 'suggested' | 'all';
|
|
87
|
+
}) => unknown;
|
|
88
|
+
/** Replace each country list row. Default render still available via <ACountrySelectItem />. */
|
|
89
|
+
item?: (props: {
|
|
90
|
+
country: CountryOption;
|
|
91
|
+
selected: boolean;
|
|
92
|
+
disabled: boolean;
|
|
93
|
+
select: () => void;
|
|
94
|
+
}) => unknown;
|
|
95
|
+
/** Replace just the right-side check icon for the selected row. */
|
|
96
|
+
'item-check'?: (props: {
|
|
97
|
+
country: CountryOption;
|
|
98
|
+
}) => unknown;
|
|
99
|
+
};
|
|
100
|
+
declare function selectCountry(option: CountryOption): void;
|
|
101
|
+
type __VLS_ModelProps = {
|
|
102
|
+
'selected'?: string;
|
|
103
|
+
};
|
|
104
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
105
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
106
|
+
open: import("vue").Ref<boolean, boolean>;
|
|
107
|
+
setOpen: (v: boolean) => boolean;
|
|
108
|
+
search: import("vue").Ref<string, string>;
|
|
109
|
+
setSearch: (v: string) => string;
|
|
110
|
+
selectedCountry: import("vue").ComputedRef<CountryOption<import("../index").RestCountry> | null>;
|
|
111
|
+
selectCountry: typeof selectCountry;
|
|
112
|
+
countries: import("vue").ComputedRef<CountryOption<import("../index").RestCountry>[]>;
|
|
113
|
+
recents: import("vue").Ref<string[], string[]>;
|
|
114
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
115
|
+
"update:selected": (value: string) => any;
|
|
116
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
117
|
+
"onUpdate:selected"?: ((value: string) => any) | undefined;
|
|
118
|
+
}>, {
|
|
119
|
+
size: Size;
|
|
120
|
+
searchPlaceholder: string;
|
|
121
|
+
emptyText: string;
|
|
122
|
+
loadingText: string;
|
|
123
|
+
suggestedLabel: string;
|
|
124
|
+
allCountriesLabel: string;
|
|
125
|
+
countryLabel: string;
|
|
126
|
+
selectCountryLabel: string;
|
|
127
|
+
suggestedLimit: number;
|
|
128
|
+
maxResults: number;
|
|
129
|
+
kbdOpen: string | null;
|
|
130
|
+
kbdClose: string | null;
|
|
131
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
132
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
133
|
+
declare const _default: typeof __VLS_export;
|
|
134
|
+
export default _default;
|
|
135
|
+
type __VLS_WithSlots<T, S> = T & (new () => (T extends new (...args: any) => infer R ? R : {}) & { $slots: S });
|
|
136
|
+
//# sourceMappingURL=ACountrySelect.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ACountrySelect.vue.d.ts","sourceRoot":"","sources":["../../../../entries/tell-input/components/ACountrySelect.vue"],"names":[],"mappings":"AA6gBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAS1C,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAkD,KAAK,IAAI,EAAE,MAAM,SAAS,CAAC;AAGpF,KAAK,WAAW,GAAG;IACf,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAChC,YAAY,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IACvC,YAAY,CAAC,EAAE,cAAc,CAAC,OAAO,C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,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,aAAa,CAAA;KAAE,KAAK,OAAO,CAAC;CAC/D,CAAC;AAuJF,iBAAS,aAAa,CAAC,MAAM,EAAE,aAAa,QAK3C;AAsBD,KAAK,gBAAgB,GAAG;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAmBF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAsiBxD,QAAA,MAAM,UAAU;;iBAzkBD,OAAO;;mBAEL,MAAM;;;;;;;;;;UA5PZ,IAAI;uBATS,MAAM;eACd,MAAM;iBACJ,MAAM;oBACH,MAAM;uBACH,MAAM;kBA4BX,MAAM;wBAEA,MAAM;oBAvBV,MAAM;gBAEV,MAAM;aAcT,MAAM,GAAG,IAAI;cACZ,MAAM,GAAG,IAAI;6EAqzB1B,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { type CountryOption, type PhoneValidationResult } from '../composables/usePhoneValidation';
|
|
2
|
+
import { type DetectCountryOptions } from '../composables/useCountryDetection';
|
|
3
|
+
import { type ATellInputProps } from '../utils/types';
|
|
4
|
+
interface ExtendedProps extends ATellInputProps {
|
|
5
|
+
/** Override the flag URL builder, forwarded to ACountrySelect. */
|
|
6
|
+
flagUrl?: (iso2: string, width: number) => string;
|
|
7
|
+
/** Custom search predicate, forwarded to ACountrySelect. */
|
|
8
|
+
searcher?: (query: string, country: CountryOption) => boolean;
|
|
9
|
+
/** Provide your own country list, forwarded to ACountrySelect. */
|
|
10
|
+
countries?: CountryOption[];
|
|
11
|
+
/**
|
|
12
|
+
* Fully custom country detection. When provided, this function runs in place of the
|
|
13
|
+
* built-in chain — `detectCountry`-style options are still honored but the function
|
|
14
|
+
* receives them and is free to ignore them.
|
|
15
|
+
*/
|
|
16
|
+
detector?: (options: DetectCountryOptions) => Promise<string | null | undefined>;
|
|
17
|
+
/** Forwarded to ACountrySelect: classes for the popover content surface. */
|
|
18
|
+
contentClass?: string;
|
|
19
|
+
popoverClass?: string;
|
|
20
|
+
drawerClass?: string;
|
|
21
|
+
/** Classes for the inner phone field input element. */
|
|
22
|
+
inputClass?: string;
|
|
23
|
+
/** Classes for the outer wrapper that holds country select + input. */
|
|
24
|
+
fieldClass?: string;
|
|
25
|
+
/** Classes for the helper hint line. */
|
|
26
|
+
hintClass?: string;
|
|
27
|
+
/** Classes for the error message line. */
|
|
28
|
+
errorClass?: string;
|
|
29
|
+
/**
|
|
30
|
+
* How page scroll is blocked while the country popover is open. Defaults to `'events'`
|
|
31
|
+
* (sticky-safe document-level lock). Pass `'body'` for the legacy
|
|
32
|
+
* `body { overflow: hidden }` lock, or `'none'` to leave page scrolling alone.
|
|
33
|
+
*/
|
|
34
|
+
scrollLock?: 'events' | 'body' | 'none';
|
|
35
|
+
}
|
|
36
|
+
type __VLS_Props = ExtendedProps;
|
|
37
|
+
type __VLS_Slots = {
|
|
38
|
+
/** Content before the country select trigger (e.g. an icon). */
|
|
39
|
+
prefix?: () => unknown;
|
|
40
|
+
/** Content between the input and the validation icons. */
|
|
41
|
+
suffix?: (props: {
|
|
42
|
+
validationState: 'idle' | 'valid' | 'error';
|
|
43
|
+
validation: PhoneValidationResult;
|
|
44
|
+
}) => unknown;
|
|
45
|
+
/** Replace the green check shown when the number validates. */
|
|
46
|
+
'valid-icon'?: () => unknown;
|
|
47
|
+
/** Replace the warning icon shown when the number fails validation. */
|
|
48
|
+
'error-icon'?: (props: {
|
|
49
|
+
reason: string;
|
|
50
|
+
}) => unknown;
|
|
51
|
+
/** Replace the dim helper line shown below the input when empty. */
|
|
52
|
+
hint?: (props: {
|
|
53
|
+
country: string;
|
|
54
|
+
formatHint: string;
|
|
55
|
+
example: string | null;
|
|
56
|
+
}) => unknown;
|
|
57
|
+
/** Replace the error message rendered when invalid. */
|
|
58
|
+
error?: (props: {
|
|
59
|
+
message: string;
|
|
60
|
+
reason: string;
|
|
61
|
+
validation: PhoneValidationResult;
|
|
62
|
+
}) => unknown;
|
|
63
|
+
/** Forwarded to ACountrySelect — replace the trigger button. */
|
|
64
|
+
trigger?: (props: {
|
|
65
|
+
selectedCountry: CountryOption | null;
|
|
66
|
+
open: boolean;
|
|
67
|
+
sizeClasses: string;
|
|
68
|
+
}) => unknown;
|
|
69
|
+
/** Forwarded to ACountrySelect — replace the chevron. */
|
|
70
|
+
chevron?: (props: {
|
|
71
|
+
open: boolean;
|
|
72
|
+
}) => unknown;
|
|
73
|
+
/** Forwarded — replace any flag rendering. */
|
|
74
|
+
flag?: (props: {
|
|
75
|
+
country: CountryOption;
|
|
76
|
+
context: 'trigger' | 'item';
|
|
77
|
+
}) => unknown;
|
|
78
|
+
/** Forwarded — replace each country list row. */
|
|
79
|
+
item?: (props: {
|
|
80
|
+
country: CountryOption;
|
|
81
|
+
selected: boolean;
|
|
82
|
+
disabled: boolean;
|
|
83
|
+
select: () => void;
|
|
84
|
+
}) => unknown;
|
|
85
|
+
/** Forwarded — section header. */
|
|
86
|
+
'group-header'?: (props: {
|
|
87
|
+
label: string;
|
|
88
|
+
group: 'suggested' | 'all';
|
|
89
|
+
}) => unknown;
|
|
90
|
+
/** Forwarded — search bar. */
|
|
91
|
+
search?: (props: {
|
|
92
|
+
value: string;
|
|
93
|
+
setValue: (v: string) => void;
|
|
94
|
+
isSearching: boolean;
|
|
95
|
+
}) => unknown;
|
|
96
|
+
loading?: () => unknown;
|
|
97
|
+
empty?: (props: {
|
|
98
|
+
query: string;
|
|
99
|
+
}) => unknown;
|
|
100
|
+
/** Replace the spinner shown in the picker slot during the debounce window. */
|
|
101
|
+
detecting?: () => unknown;
|
|
102
|
+
};
|
|
103
|
+
type __VLS_ModelProps = {
|
|
104
|
+
'phone'?: string;
|
|
105
|
+
/** Public `v-model:country` — the **dial number** (e.g. `20` for Egypt, `44` for the UK,
|
|
106
|
+
* `1` for the NANP block). `null` means no country selected. Internally the component
|
|
107
|
+
* tracks a richer ISO2 code (`selectedIso2`) because dial codes alone can't disambiguate
|
|
108
|
+
* NANP (`+1` covers 25+ countries) — the picker still needs an exact country. */
|
|
109
|
+
'country'?: number | null;
|
|
110
|
+
};
|
|
111
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
112
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
113
|
+
validation: import("vue").ComputedRef<PhoneValidationResult>;
|
|
114
|
+
required: import("vue").ComputedRef<import("../index").PhoneRequiredInfo | null>;
|
|
115
|
+
selectedDialCode: import("vue").ComputedRef<string | null>;
|
|
116
|
+
validationState: import("vue").ComputedRef<"error" | "idle" | "valid">;
|
|
117
|
+
visibleValidationState: import("vue").ComputedRef<"error" | "idle" | "valid">;
|
|
118
|
+
isDetecting: Readonly<import("vue").Ref<boolean, boolean>>;
|
|
119
|
+
hasFinishedTyping: Readonly<import("vue").Ref<boolean, boolean>>;
|
|
120
|
+
detectionAttempted: Readonly<import("vue").Ref<boolean, boolean>>;
|
|
121
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
122
|
+
"update:phone": (value: string) => any;
|
|
123
|
+
"update:country": (value: number | null) => any;
|
|
124
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
125
|
+
"onUpdate:phone"?: ((value: string) => any) | undefined;
|
|
126
|
+
"onUpdate:country"?: ((value: number | null) => any) | undefined;
|
|
127
|
+
}>, {
|
|
128
|
+
size: import("../index").ATellInputSize;
|
|
129
|
+
placeholder: string;
|
|
130
|
+
ipEndpoint: string;
|
|
131
|
+
defaultCountry: string;
|
|
132
|
+
showValidationIcon: boolean;
|
|
133
|
+
detectCountry: import("../index").DetectionStrategy;
|
|
134
|
+
detectFromInput: boolean;
|
|
135
|
+
detectDebounceMs: number;
|
|
136
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
137
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
138
|
+
declare const _default: typeof __VLS_export;
|
|
139
|
+
export default _default;
|
|
140
|
+
type __VLS_WithSlots<T, S> = T & (new () => (T extends new (...args: any) => infer R ? R : {}) & { $slots: S });
|
|
141
|
+
//# sourceMappingURL=ATellInput.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ATellInput.vue.d.ts","sourceRoot":"","sources":["../../../../entries/tell-input/components/ATellInput.vue"],"names":[],"mappings":"AA8mBA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAK9F,OAAO,EAAuC,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAI3F,UAAU,aAAc,SAAQ,eAAe;IAC7C,kEAAkE;IAClE,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAClD,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC;IAC9D,kEAAkE;IAClE,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACjF,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,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AE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAgBF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AA2axD,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;6EAKd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort country detection chain: IP geolocation → timezone → navigator.language → fallback.
|
|
3
|
+
* Every step is independent and degrades gracefully; the final fallback is always returned.
|
|
4
|
+
*
|
|
5
|
+
* The composable returns reactive state so consumers can swap in the detected ISO2 the moment it
|
|
6
|
+
* resolves, while still rendering an input immediately on mount.
|
|
7
|
+
*/
|
|
8
|
+
import { type Ref } from 'vue';
|
|
9
|
+
export type DetectionStrategy = 'auto' | 'locale' | 'none';
|
|
10
|
+
export interface DetectCountryOptions {
|
|
11
|
+
/**
|
|
12
|
+
* - `'auto'` — try IP geolocation first, then timezone, then `navigator.language`, then default.
|
|
13
|
+
* - `'locale'` — skip the network call, use timezone + locale only.
|
|
14
|
+
* - `'none'` — return `defaultCountry` immediately.
|
|
15
|
+
*/
|
|
16
|
+
strategy?: DetectionStrategy;
|
|
17
|
+
/** Endpoint returning a JSON body with a `country_code` (or `country`) field. */
|
|
18
|
+
ipEndpoint?: string;
|
|
19
|
+
/** Fallback ISO2 used when every step fails. */
|
|
20
|
+
defaultCountry?: string;
|
|
21
|
+
/** Abort the IP request after this many ms. */
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
/** Persist the resolved country in sessionStorage so re-mounts within the session skip detection. */
|
|
24
|
+
cache?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Imperative API. Use this when you want to call detection from outside Vue (e.g. inside a
|
|
28
|
+
* non-component composable, server middleware, or unit test).
|
|
29
|
+
*/
|
|
30
|
+
export declare function detectCountry(opts?: DetectCountryOptions): Promise<string>;
|
|
31
|
+
export interface UseCountryDetectionReturn {
|
|
32
|
+
/** Resolved ISO2 code. Initially `null` until detection completes. */
|
|
33
|
+
country: Ref<string | null>;
|
|
34
|
+
/** True while detection is in flight. */
|
|
35
|
+
isLoading: Ref<boolean>;
|
|
36
|
+
/** Manually re-run detection (e.g. after the user changes their VPN). */
|
|
37
|
+
refresh: () => Promise<string>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Reactive wrapper. Kicks off detection in `onMounted` so SSR renders an empty value and the
|
|
41
|
+
* client patches in the real country once resolved.
|
|
42
|
+
*/
|
|
43
|
+
export declare function useCountryDetection(opts?: DetectCountryOptions): UseCountryDetectionReturn;
|
|
44
|
+
//# sourceMappingURL=useCountryDetection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCountryDetection.d.ts","sourceRoot":"","sources":["../../../../entries/tell-input/composables/useCountryDetection.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAkB,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/C,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE3D,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,iFAAiF;IACjF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qGAAqG;IACrG,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAuJD;;;GAGG;AACH,wBAAsB,aAAa,CAAC,IAAI,GAAE,oBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BpF;AAED,MAAM,WAAW,yBAAyB;IACxC,sEAAsE;IACtE,OAAO,EAAE,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC5B,yCAAyC;IACzC,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACxB,yEAAyE;IACzE,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CAChC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,GAAE,oBAAyB,GAAG,yBAAyB,CAmB9F"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CountryOption } from './usePhoneValidation';
|
|
2
|
+
/** Synchronous dial-digit → ISO2 fallback for common countries, used when the async
|
|
3
|
+
* REST Countries fetch hasn't populated `getCountriesByDial`'s index yet at setup. */
|
|
4
|
+
export declare const DIAL_TO_ISO2_FALLBACK: Record<string, string>;
|
|
5
|
+
/** localStorage key for the user's most recently picked countries. Used as a
|
|
6
|
+
* tie-breaker when multiple countries share a dial code (e.g. all NANP). */
|
|
7
|
+
export declare const COUNTRY_RECENTS_KEY = "ali_ui_country_recents_v1";
|
|
8
|
+
export interface DialMatch {
|
|
9
|
+
country: CountryOption;
|
|
10
|
+
/** The national significant number — what the phone input should hold, with both the
|
|
11
|
+
* dial code and the national prefix (e.g. Egyptian leading `0`) stripped. */
|
|
12
|
+
nationalNumber: string;
|
|
13
|
+
}
|
|
14
|
+
export interface MatchLeadingDialCodeOptions {
|
|
15
|
+
/** ISO2 hint for libphonenumber's national-format parse (tier 2). Typically the
|
|
16
|
+
* IP/timezone/locale-resolved country. */
|
|
17
|
+
hintCountry?: string;
|
|
18
|
+
/** Currently selected ISO2 — preferred when a shared dial code yields multiple
|
|
19
|
+
* countries (tier 3 tie-break). */
|
|
20
|
+
currentIso2?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface CountryMatchingDeps {
|
|
23
|
+
/** Country lookup by ISO2 code — typically `usePhoneValidation().getCountryByValue`. */
|
|
24
|
+
getCountryByValue: (value: string) => CountryOption | null;
|
|
25
|
+
/** Country lookup by dial digits — typically `usePhoneValidation().getCountriesByDial`. */
|
|
26
|
+
getCountriesByDial: (dial: string) => CountryOption[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Country-matching helpers used by the tel input — pure functions on top of the
|
|
30
|
+
* `usePhoneValidation` country index. Split out of `ATellInput.vue` so the component
|
|
31
|
+
* script stays focused on UI state and the matching logic is independently testable.
|
|
32
|
+
*
|
|
33
|
+
* **Important**: takes the validation lookups as dependencies rather than calling
|
|
34
|
+
* `usePhoneValidation()` itself. `usePhoneValidation` creates a fresh state on every
|
|
35
|
+
* call, so calling it here would produce a *second* empty country index that never gets
|
|
36
|
+
* populated by the caller's `getCountries()` — the matcher would see no countries and
|
|
37
|
+
* all tier-3 prefix lookups would fall through to the (much smaller) fallback table.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useCountryMatching(deps: CountryMatchingDeps): {
|
|
40
|
+
resolveCountryIdentifier: (raw: string | undefined | null) => string;
|
|
41
|
+
dialNumberFor: (iso2: string) => number | null;
|
|
42
|
+
matchLeadingDialCode: (digits: string, options?: MatchLeadingDialCodeOptions) => DialMatch | null;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=useCountryMatching.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCountryMatching.d.ts","sourceRoot":"","sources":["../../../../entries/tell-input/composables/useCountryMatching.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D;uFACuF;AACvF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA4DxD,CAAC;AAEF;6EAC6E;AAC7E,eAAO,MAAM,mBAAmB,8BAA8B,CAAC;AAE/D,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,aAAa,CAAC;IACvB;kFAC8E;IAC9E,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,2BAA2B;IAC1C;+CAC2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;wCACoC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAcD,MAAM,WAAW,mBAAmB;IAClC,wFAAwF;IACxF,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,aAAa,GAAG,IAAI,CAAC;IAC3D,2FAA2F;IAC3F,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,EAAE,CAAC;CACvD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,mBAAmB;oCAKnB,MAAM,GAAG,SAAS,GAAG,IAAI,KAAG,MAAM;0BAe5C,MAAM,KAAG,MAAM,GAAG,IAAI;mCAiBzC,MAAM,YACL,2BAA2B,KACnC,SAAS,GAAG,IAAI;EAwDpB"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Country list + phone validation, framework-agnostic.
|
|
3
|
+
*
|
|
4
|
+
* Ported from the reference @pkgs/ui ATellInput composable with these cleanups:
|
|
5
|
+
* - Drop Nuxt-only `process.client` checks → use plain `typeof window !== 'undefined'`.
|
|
6
|
+
* - Drop Arabic default placeholder; let consumers pass their own.
|
|
7
|
+
* - Expand the offline fallback list from 2 → ~20 of the most-populated countries.
|
|
8
|
+
* - Keep REST Countries fetch + localStorage cache + libphonenumber-js examples + fast `search_key`.
|
|
9
|
+
*/
|
|
10
|
+
import { type Ref } from 'vue';
|
|
11
|
+
export interface RestCountry {
|
|
12
|
+
name?: {
|
|
13
|
+
common?: string;
|
|
14
|
+
};
|
|
15
|
+
cca2?: string;
|
|
16
|
+
idd?: {
|
|
17
|
+
root?: string;
|
|
18
|
+
suffixes?: string[];
|
|
19
|
+
};
|
|
20
|
+
flags?: {
|
|
21
|
+
png?: string;
|
|
22
|
+
svg?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface CountryOption<T = RestCountry> {
|
|
26
|
+
/** Display label, e.g. "Egypt (+20)". */
|
|
27
|
+
label: string;
|
|
28
|
+
/** Stable unique ID — the ISO 3166-1 alpha-2 code, e.g. "EG". */
|
|
29
|
+
value: string;
|
|
30
|
+
/** Precomputed normalized string for fast substring search. */
|
|
31
|
+
search_key: string;
|
|
32
|
+
raw_data: {
|
|
33
|
+
iso2: string;
|
|
34
|
+
dial_code: string;
|
|
35
|
+
dial_digits: string;
|
|
36
|
+
name: string;
|
|
37
|
+
flag: string | null;
|
|
38
|
+
source: 'restcountries' | 'fallback';
|
|
39
|
+
original: T;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface PhoneRequiredInfo {
|
|
43
|
+
iso2: string;
|
|
44
|
+
dial_code: string;
|
|
45
|
+
/** Empty by default — consumer passes a placeholder via the component prop. */
|
|
46
|
+
placeholder: string;
|
|
47
|
+
example_national: string;
|
|
48
|
+
example_e164: string;
|
|
49
|
+
national_number_length: {
|
|
50
|
+
min: number | null;
|
|
51
|
+
max: number | null;
|
|
52
|
+
};
|
|
53
|
+
format_hint: string;
|
|
54
|
+
}
|
|
55
|
+
export type PhoneValidationReason = 'missing_country' | 'country_not_supported' | 'phone_has_non_digits' | 'too_short' | 'too_long' | 'invalid_phone' | 'parse_failed';
|
|
56
|
+
export interface PhoneValidationResult {
|
|
57
|
+
ok: boolean;
|
|
58
|
+
reason: PhoneValidationReason | null;
|
|
59
|
+
country: {
|
|
60
|
+
iso2: string;
|
|
61
|
+
dial_code: string;
|
|
62
|
+
} | null;
|
|
63
|
+
phone: {
|
|
64
|
+
raw: string | null;
|
|
65
|
+
digits: string;
|
|
66
|
+
};
|
|
67
|
+
full_phone: string | null;
|
|
68
|
+
required: PhoneRequiredInfo | null;
|
|
69
|
+
details?: Record<string, unknown>;
|
|
70
|
+
}
|
|
71
|
+
export type ValidateArgs = {
|
|
72
|
+
country: {
|
|
73
|
+
iso2: string;
|
|
74
|
+
dial_code?: string;
|
|
75
|
+
} | null | undefined;
|
|
76
|
+
phone?: undefined;
|
|
77
|
+
/** BCP-47 locale — localizes the numerals in the returned `required.format_hint`. */
|
|
78
|
+
locale?: string;
|
|
79
|
+
} | {
|
|
80
|
+
country: {
|
|
81
|
+
iso2: string;
|
|
82
|
+
dial_code?: string;
|
|
83
|
+
} | null | undefined;
|
|
84
|
+
phone: string | null;
|
|
85
|
+
/** BCP-47 locale — localizes the numerals in the returned `required.format_hint`. */
|
|
86
|
+
locale?: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Return a copy of the country list with display names localized to `locale` via
|
|
90
|
+
* `Intl.DisplayNames`. `search_key` is rebuilt (keeping the English name too) so search
|
|
91
|
+
* still matches either spelling. Unknown locales / regions fall back to the English name.
|
|
92
|
+
*/
|
|
93
|
+
export declare function localizeCountries(list: CountryOption[], locale?: string): CountryOption[];
|
|
94
|
+
export interface UsePhoneValidationReturn {
|
|
95
|
+
countries: Ref<CountryOption[]>;
|
|
96
|
+
isCountriesLoading: Ref<boolean>;
|
|
97
|
+
getCountries(options?: {
|
|
98
|
+
force?: boolean;
|
|
99
|
+
}): Promise<CountryOption[]>;
|
|
100
|
+
searchCountries(keyword: string, limit?: number): CountryOption[];
|
|
101
|
+
getCountryByValue(value: string): CountryOption | null;
|
|
102
|
+
getCountriesByDial(dial: string): CountryOption[];
|
|
103
|
+
getRequiredInfo(country: {
|
|
104
|
+
iso2: string;
|
|
105
|
+
dial_code?: string;
|
|
106
|
+
}, locale?: string): PhoneRequiredInfo | null;
|
|
107
|
+
validate(input: ValidateArgs): PhoneValidationResult;
|
|
108
|
+
}
|
|
109
|
+
export declare function usePhoneValidation(): UsePhoneValidationReturn;
|
|
110
|
+
//# sourceMappingURL=usePhoneValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePhoneValid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AG,aAAa,EAAE,CA0BzF;AAoDD,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC;IAChC,kBAAkB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACjC,YAAY,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IACtE,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,EAAE,CAAC;IAClE,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAAC;IACvD,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAAC;IAClD,eAAe,CACb,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,EAC7C,MAAM,CAAC,EAAE,MAAM,GACd,iBAAiB,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,qBAAqB,CAAC;CACtD;AAED,wBAAgB,kBAAkB,IAAI,wBAAwB,CAmT7D"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type ComputedRef, type Ref } from 'vue';
|
|
2
|
+
import type { PhoneValidationReason, PhoneValidationResult, PhoneRequiredInfo, UsePhoneValidationReturn } from './usePhoneValidation';
|
|
3
|
+
import type { TellInputMessages } from '../utils/types';
|
|
4
|
+
/**
|
|
5
|
+
* Validation surfacing facade for ATellInput.
|
|
6
|
+
*
|
|
7
|
+
* Wraps the raw `usePhoneValidation()` calls and produces the *view-layer* surface the
|
|
8
|
+
* component needs:
|
|
9
|
+
*
|
|
10
|
+
* - `validation` / `validationState` — the raw + simplified state of the current input.
|
|
11
|
+
* - `visibleValidationState` — `validationState` gated by the `hasFinishedTyping` flag
|
|
12
|
+
* from {@link useTypingPhase}, so error tints / icons / messages only appear once the
|
|
13
|
+
* user has paused. This is the value the template should bind to.
|
|
14
|
+
* - `errorMessage` — localised error string for the current `validation.reason`, or
|
|
15
|
+
* `null` when the input is empty or valid.
|
|
16
|
+
* - `showError` / `showHint` — boolean computed properties for conditional rendering
|
|
17
|
+
* in the template; both already respect `showValidation` and the typing-pause gate.
|
|
18
|
+
* - `selectedDialCode` — the human-readable dial prefix (`+20`, `+1`, …) for the
|
|
19
|
+
* selected country, used as an in-input prefix.
|
|
20
|
+
*
|
|
21
|
+
* Design notes:
|
|
22
|
+
*
|
|
23
|
+
* - The composable takes the `usePhoneValidation()` return value as a *dependency*
|
|
24
|
+
* rather than calling `usePhoneValidation()` itself. That function creates a fresh
|
|
25
|
+
* country index per invocation; calling it here would produce a second, empty index
|
|
26
|
+
* that never gets populated by the caller's `getCountries()` (the same bug pattern
|
|
27
|
+
* {@link useCountryMatching} avoids).
|
|
28
|
+
*
|
|
29
|
+
* - All inputs are `Ref` / `ComputedRef` so reactivity flows correctly. Method
|
|
30
|
+
* references on the validation singleton (`validate`, `getRequiredInfo`,
|
|
31
|
+
* `getCountryByValue`) are passed verbatim — their backing state is reactive.
|
|
32
|
+
*/
|
|
33
|
+
export interface UseTellInputValidationDeps {
|
|
34
|
+
validate: UsePhoneValidationReturn['validate'];
|
|
35
|
+
getRequiredInfo: UsePhoneValidationReturn['getRequiredInfo'];
|
|
36
|
+
getCountryByValue: UsePhoneValidationReturn['getCountryByValue'];
|
|
37
|
+
}
|
|
38
|
+
export interface UseTellInputValidationInputs {
|
|
39
|
+
/** Digits-only national number model. */
|
|
40
|
+
phone: Ref<string>;
|
|
41
|
+
/** Currently selected ISO2 — empty string when no country chosen. */
|
|
42
|
+
selectedIso2: Ref<string>;
|
|
43
|
+
/** From {@link useTypingPhase} — gates visible state during the debounce window. */
|
|
44
|
+
hasFinishedTyping: Readonly<Ref<boolean>>;
|
|
45
|
+
/** Resolved i18n messages (merged defaults + consumer overrides). */
|
|
46
|
+
messages: ComputedRef<TellInputMessages>;
|
|
47
|
+
}
|
|
48
|
+
export interface UseTellInputValidationConfig {
|
|
49
|
+
/** BCP-47 locale; affects `format_hint` numeral rendering. */
|
|
50
|
+
locale: () => string | undefined;
|
|
51
|
+
/** Light up field tinting + error message line. From props. */
|
|
52
|
+
showValidation: () => boolean | undefined;
|
|
53
|
+
/** Per-reason error string overrides. From props. */
|
|
54
|
+
errorMessages: () => Partial<Record<PhoneValidationReason, string>> | undefined;
|
|
55
|
+
}
|
|
56
|
+
export interface UseTellInputValidationReturn {
|
|
57
|
+
validation: ComputedRef<PhoneValidationResult>;
|
|
58
|
+
required: ComputedRef<PhoneRequiredInfo | null>;
|
|
59
|
+
validationState: ComputedRef<'idle' | 'valid' | 'error'>;
|
|
60
|
+
visibleValidationState: ComputedRef<'idle' | 'valid' | 'error'>;
|
|
61
|
+
errorMessage: ComputedRef<string | null>;
|
|
62
|
+
showError: ComputedRef<boolean>;
|
|
63
|
+
showHint: ComputedRef<boolean>;
|
|
64
|
+
selectedDialCode: ComputedRef<string | null>;
|
|
65
|
+
}
|
|
66
|
+
export declare function useTellInputValidation(deps: UseTellInputValidationDeps, inputs: UseTellInputValidationInputs, config: UseTellInputValidationConfig): UseTellInputValidationReturn;
|
|
67
|
+
//# sourceMappingURL=useTellInputValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTellInputValidation.d.ts","sourceRoot":"","sources":["../../../../entries/tell-input/composables/useTellInputValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAC3D,OAAO,KAAK,EAEV,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG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B,gBAAgB,EAAE,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC9C;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,0BAA0B,EAChC,MAAM,EAAE,4BAA4B,EACpC,MAAM,EAAE,4BAA4B,GACnC,4BAA4B,CAuD9B"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type ComputedRef, type Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Typing-phase state machine for the tel input.
|
|
4
|
+
*
|
|
5
|
+
* Owns the three reactive flags that drive the "is the user still typing?" UX:
|
|
6
|
+
*
|
|
7
|
+
* - `isDetecting` — true while the debounce window is in flight (user is mid-burst or
|
|
8
|
+
* has just paused). Drives the loading spinner in the picker slot.
|
|
9
|
+
* - `hasFinishedTyping` — false from the moment a key lands until the debounce settles.
|
|
10
|
+
* Gates validation visibility, so error/success states only appear once the user pauses.
|
|
11
|
+
* - `detectionAttempted` — flips true the first time the debounce fires on non-empty
|
|
12
|
+
* input. Used by the consumer to keep the country picker visible after a failed
|
|
13
|
+
* detection (so the user can pick manually instead of being stranded).
|
|
14
|
+
*
|
|
15
|
+
* Design notes:
|
|
16
|
+
*
|
|
17
|
+
* - The composable is pure state — it does not know about country detection, phone
|
|
18
|
+
* numbers, or libphonenumber. The consumer wires the `onSettle` callback to whatever
|
|
19
|
+
* "what to do when typing pauses" logic is appropriate (typically: try to detect a
|
|
20
|
+
* country from the current digits, mark a detection attempt, and apply the match).
|
|
21
|
+
*
|
|
22
|
+
* - `markDetectionAttempt()` is exposed separately so the caller controls *when* the
|
|
23
|
+
* "keep the picker visible" flag flips — not every settle triggers a real attempt
|
|
24
|
+
* (e.g. when input is empty or the user already picked a country manually).
|
|
25
|
+
*
|
|
26
|
+
* - Refs are exposed `readonly` so external code can't bypass the state machine; all
|
|
27
|
+
* transitions go through the exposed actions.
|
|
28
|
+
*/
|
|
29
|
+
export interface UseTypingPhaseOptions {
|
|
30
|
+
/** Debounce window in ms. Reactive so consumers can change `detectDebounceMs` at runtime. */
|
|
31
|
+
debounceMs: ComputedRef<number>;
|
|
32
|
+
/** Fired when the debounce timer settles. Runs regardless of input state — use this
|
|
33
|
+
* to clear loading UI, then perform any pause-triggered work (e.g. detection). */
|
|
34
|
+
onSettle?: () => void;
|
|
35
|
+
}
|
|
36
|
+
export interface UseTypingPhaseReturn {
|
|
37
|
+
isDetecting: Readonly<Ref<boolean>>;
|
|
38
|
+
hasFinishedTyping: Readonly<Ref<boolean>>;
|
|
39
|
+
detectionAttempted: Readonly<Ref<boolean>>;
|
|
40
|
+
/** Call from the input handler on every keystroke that produces non-empty input. */
|
|
41
|
+
markTyping: () => void;
|
|
42
|
+
/** Flip `detectionAttempted` to true. Call from within the `onSettle` callback when
|
|
43
|
+
* a real detection attempt is about to run — so the picker stays visible after even
|
|
44
|
+
* a failed match. */
|
|
45
|
+
markDetectionAttempt: () => void;
|
|
46
|
+
/** Reset all three flags to defaults. Call when the input is cleared. */
|
|
47
|
+
reset: () => void;
|
|
48
|
+
}
|
|
49
|
+
export declare function useTypingPhase(opts: UseTypingPhaseOptions): UseTypingPhaseReturn;
|
|
50
|
+
//# sourceMappingURL=useTypingPhase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTypingPhase.d.ts","sourceRoot":"","sources":["../../../../entries/tell-input/composables/useTypingPhase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAGhE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,qBAAqB;IACpC,6FAA6F;IAC7F,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC;uFACmF;IACnF,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IACpC,iBAAiB,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1C,kBAAkB,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,oFAAoF;IACpF,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB;;0BAEsB;IACtB,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,yEAAyE;IACzE,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,qBAAqB,GAAG,oBAAoB,CAmChF"}
|