@citizenplane/pimp 9.7.3 → 9.7.5
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/dist/pimp.es.js +720 -714
- package/dist/pimp.umd.js +9 -9
- package/package.json +1 -1
- package/src/components/CpTelInput.vue +26 -0
package/package.json
CHANGED
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
placeholder="Enter your phone number"
|
|
17
17
|
valid-characters-only
|
|
18
18
|
@close="focusOnInput"
|
|
19
|
+
@country-changed="handleCountryChanged"
|
|
19
20
|
@open="handleDropdownOpen"
|
|
21
|
+
@validate="handleOnValidate"
|
|
20
22
|
>
|
|
21
23
|
<template #arrow-icon>
|
|
22
24
|
<cp-icon class="cpTelInput__arrow" size="20" type="chevron-down" />
|
|
@@ -73,6 +75,22 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
73
75
|
size: Sizes.MD,
|
|
74
76
|
})
|
|
75
77
|
|
|
78
|
+
const emit = defineEmits<Emits>()
|
|
79
|
+
|
|
80
|
+
type PhoneObject = {
|
|
81
|
+
country: string
|
|
82
|
+
countryCode: string
|
|
83
|
+
formatted: string
|
|
84
|
+
nationalNumber: string
|
|
85
|
+
possible: boolean
|
|
86
|
+
valid: boolean
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface Emits {
|
|
90
|
+
(e: 'countryChanged', countryCode: string): void
|
|
91
|
+
(e: 'validate', phoneObject: PhoneObject): void
|
|
92
|
+
}
|
|
93
|
+
|
|
76
94
|
const inputModel = defineModel<string>()
|
|
77
95
|
const telInputRef = ref<HTMLInputElement | null>(null)
|
|
78
96
|
|
|
@@ -128,6 +146,14 @@ const handleDropdownOpen = async () => {
|
|
|
128
146
|
|
|
129
147
|
setTimeout(() => searchBox.focus(), 1)
|
|
130
148
|
}
|
|
149
|
+
|
|
150
|
+
const handleCountryChanged = (country: { iso2: string }) => {
|
|
151
|
+
emit('countryChanged', country?.iso2 || '')
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const handleOnValidate = (phoneObject: PhoneObject) => {
|
|
155
|
+
emit('validate', phoneObject)
|
|
156
|
+
}
|
|
131
157
|
</script>
|
|
132
158
|
|
|
133
159
|
<style lang="scss">
|