@citizenplane/pimp 9.7.4 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citizenplane/pimp",
3
- "version": "9.7.4",
3
+ "version": "9.7.5",
4
4
  "scripts": {
5
5
  "dev": "storybook dev -p 8080",
6
6
  "build-storybook": "storybook build --output-dir ./docs",
@@ -18,6 +18,7 @@
18
18
  @close="focusOnInput"
19
19
  @country-changed="handleCountryChanged"
20
20
  @open="handleDropdownOpen"
21
+ @validate="handleOnValidate"
21
22
  >
22
23
  <template #arrow-icon>
23
24
  <cp-icon class="cpTelInput__arrow" size="20" type="chevron-down" />
@@ -76,8 +77,18 @@ const props = withDefaults(defineProps<Props>(), {
76
77
 
77
78
  const emit = defineEmits<Emits>()
78
79
 
80
+ type PhoneObject = {
81
+ country: string
82
+ countryCode: string
83
+ formatted: string
84
+ nationalNumber: string
85
+ possible: boolean
86
+ valid: boolean
87
+ }
88
+
79
89
  interface Emits {
80
90
  (e: 'countryChanged', countryCode: string): void
91
+ (e: 'validate', phoneObject: PhoneObject): void
81
92
  }
82
93
 
83
94
  const inputModel = defineModel<string>()
@@ -139,6 +150,10 @@ const handleDropdownOpen = async () => {
139
150
  const handleCountryChanged = (country: { iso2: string }) => {
140
151
  emit('countryChanged', country?.iso2 || '')
141
152
  }
153
+
154
+ const handleOnValidate = (phoneObject: PhoneObject) => {
155
+ emit('validate', phoneObject)
156
+ }
142
157
  </script>
143
158
 
144
159
  <style lang="scss">