@zap-wunschlachen/wl-shared-components 1.0.51 → 1.0.52

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": "@zap-wunschlachen/wl-shared-components",
3
- "version": "1.0.51",
3
+ "version": "1.0.52",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -19,13 +19,13 @@
19
19
  hide-details
20
20
  :aria-invalid="state === ValidationState.ERROR"
21
21
  :countryIconMode="'svg'"
22
- @update:model-value="(value) => emit('update:phone', value)"
22
+ @update:model-value="onPhoneUpdate"
23
23
  data-testid="root"
24
24
  />
25
25
  </template>
26
26
 
27
27
  <script setup lang="ts">
28
- import { defineProps, PropType, ref, nextTick, computed, inject } from 'vue';
28
+ import { PropType, ref, nextTick, computed, inject } from 'vue';
29
29
  import { VPhoneInput } from 'v-phone-input';
30
30
  import './PhoneInput.css'
31
31
  import { siteColors } from "../../utils/index";
@@ -87,10 +87,21 @@ const props = defineProps({
87
87
 
88
88
  const emit = defineEmits<{
89
89
  (e: 'update:phone', value: string): void
90
+ (e: 'update:valid', isValid: boolean): void
90
91
  }>();
91
92
 
92
93
  const inputRef = ref(null)
93
94
 
95
+ // Handle phone input updates
96
+ const onPhoneUpdate = (value: string) => {
97
+ emit('update:phone', value);
98
+ // Check validity after the VPhoneInput has processed the value
99
+ nextTick(() => {
100
+ const valid = inputRef.value?.isValid ?? false;
101
+ emit('update:valid', valid);
102
+ });
103
+ };
104
+
94
105
  const getNativeInput = () => {
95
106
  return inputRef.value?.phoneInputRef?.$el?.querySelector('input');
96
107
  }
@@ -113,10 +124,14 @@ const focus = () => {
113
124
  });
114
125
  };
115
126
 
127
+ // Computed property to expose isValid from VPhoneInput
128
+ const isValid = computed(() => inputRef.value?.isValid ?? false);
129
+
116
130
  defineExpose({
117
131
  blur,
118
132
  select,
119
- focus
133
+ focus,
134
+ isValid
120
135
  });
121
136
 
122
137
  </script>