@alikhalilll/a-tel-input 1.0.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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +124 -0
  3. package/dist/index.cjs +5846 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +791 -0
  6. package/dist/index.d.ts +791 -0
  7. package/dist/index.js +5804 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/nuxt/index.cjs +30 -0
  10. package/dist/nuxt/index.cjs.map +1 -0
  11. package/dist/nuxt/index.d.cts +15 -0
  12. package/dist/nuxt/index.d.ts +15 -0
  13. package/dist/nuxt/index.js +30 -0
  14. package/dist/nuxt/index.js.map +1 -0
  15. package/dist/resolver/index.cjs +25 -0
  16. package/dist/resolver/index.cjs.map +1 -0
  17. package/dist/resolver/index.d.cts +14 -0
  18. package/dist/resolver/index.d.ts +14 -0
  19. package/dist/resolver/index.js +25 -0
  20. package/dist/resolver/index.js.map +1 -0
  21. package/dist/styles.css +520 -0
  22. package/package.json +123 -0
  23. package/src/components/ACountryFlag.vue +78 -0
  24. package/src/components/ACountrySelect.vue +674 -0
  25. package/src/components/ATelInput.vue +742 -0
  26. package/src/composables/useCountryDetection.ts +247 -0
  27. package/src/composables/useCountryMatching.ts +213 -0
  28. package/src/composables/usePhoneValidation.ts +573 -0
  29. package/src/composables/useTelInputValidation.ts +136 -0
  30. package/src/composables/useTypingPhase.ts +88 -0
  31. package/src/icons/AlertCircleIcon.vue +17 -0
  32. package/src/icons/CheckCircleIcon.vue +16 -0
  33. package/src/icons/CheckIcon.vue +15 -0
  34. package/src/icons/ChevronDownIcon.vue +15 -0
  35. package/src/icons/SearchIcon.vue +16 -0
  36. package/src/icons/SpinnerIcon.vue +28 -0
  37. package/src/icons/index.ts +6 -0
  38. package/src/index.ts +36 -0
  39. package/src/nuxt/index.ts +37 -0
  40. package/src/resolver/index.ts +29 -0
  41. package/src/types.ts +389 -0
  42. package/src/utils/digits.ts +42 -0
  43. package/src/utils/flag-url.ts +10 -0
  44. package/web-types.json +526 -0
@@ -0,0 +1,78 @@
1
+ <script setup lang="ts">
2
+ import { computed, ref, watch } from 'vue';
3
+ import { cn } from '@alikhalilll/a-ui-base';
4
+ import { defaultFlagUrl } from '../utils/flag-url';
5
+ import type { ACountryFlagProps, ACountryFlagSlots } from '../types';
6
+
7
+ const props = withDefaults(defineProps<ACountryFlagProps>(), { width: 40 });
8
+ defineSlots<ACountryFlagSlots>();
9
+
10
+ const url = computed(() => {
11
+ if (props.src) return props.src;
12
+ if (!props.iso2) return null;
13
+ return (props.flagUrl ?? defaultFlagUrl)(props.iso2, props.width);
14
+ });
15
+
16
+ // Image load failure → fall back to the ISO2 text badge. The flag URL can change as the
17
+ // user switches country, so reset the error flag whenever the URL changes.
18
+ const failed = ref(false);
19
+ watch(url, () => {
20
+ failed.value = false;
21
+ });
22
+
23
+ const iso2Label = computed(() => (props.iso2 ?? '').slice(0, 2).toUpperCase());
24
+ </script>
25
+
26
+ <template>
27
+ <img
28
+ v-if="url && !failed"
29
+ :src="url"
30
+ :alt="props.alt ?? `${props.iso2} flag`"
31
+ loading="lazy"
32
+ data-slot="country-flag"
33
+ :class="cn('a-country-flag', props.class)"
34
+ @error="failed = true"
35
+ />
36
+ <span
37
+ v-else-if="iso2Label"
38
+ data-slot="country-flag-fallback"
39
+ :aria-label="props.alt ?? `${props.iso2} flag`"
40
+ :class="cn('a-country-flag a-country-flag--fallback', props.class)"
41
+ >
42
+ {{ iso2Label }}
43
+ </span>
44
+ <slot v-else name="empty">
45
+ <span
46
+ data-slot="country-flag-empty"
47
+ :class="cn('a-country-flag a-country-flag--empty', props.class)"
48
+ />
49
+ </slot>
50
+ </template>
51
+
52
+ <style scoped>
53
+ .a-country-flag {
54
+ display: inline-block;
55
+ width: 1.5rem;
56
+ height: 1rem;
57
+ border-radius: 0.125rem;
58
+ object-fit: cover;
59
+ box-shadow: 0 0 0 1px hsl(var(--ak-ui-border) / 0.4);
60
+ }
61
+
62
+ .a-country-flag--fallback {
63
+ display: inline-flex;
64
+ align-items: center;
65
+ justify-content: center;
66
+ background: hsl(var(--ak-ui-muted));
67
+ color: hsl(var(--ak-ui-muted-foreground));
68
+ font-size: 8px;
69
+ font-weight: 600;
70
+ line-height: 1;
71
+ letter-spacing: -0.025em;
72
+ }
73
+
74
+ .a-country-flag--empty {
75
+ background: hsl(var(--ak-ui-muted));
76
+ box-shadow: none;
77
+ }
78
+ </style>