edvoyui-component-library-test-flight 0.0.241 → 0.0.242

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.
@@ -79,7 +79,7 @@ import {
79
79
  type PhoneMeta,
80
80
  type VueTelInputProps,
81
81
  } from "vue-tel-input";
82
- import { getExampleNumber } from "libphonenumber-js";
82
+ import { type CountryCode, getExampleNumber } from "libphonenumber-js";
83
83
  import mobileExamples from "libphonenumber-js/mobile/examples";
84
84
  import "vue-tel-input/vue-tel-input.css";
85
85
 
@@ -160,9 +160,9 @@ const id = generateUID();
160
160
 
161
161
  const hasError = computed({
162
162
  set: (value) => {
163
- emit("update:isValid", value);
163
+ emit("update:isValid", !value);
164
164
  },
165
- get: () => isValid.value,
165
+ get: () => !isValid.value,
166
166
  });
167
167
 
168
168
  const inputValue = computed(() => {
@@ -191,8 +191,13 @@ const getCountryMaxLength = (
191
191
  ) => {
192
192
  if (!country) return props.length;
193
193
 
194
- const countryCode = typeof country === "string" ? country : country.iso2;
195
- const example = getExampleNumber(countryCode, mobileExamples);
194
+ const rawCode = typeof country === "string" ? country : country.iso2;
195
+ const countryCode = (
196
+ rawCode ? String(rawCode).toUpperCase() : ""
197
+ ) as CountryCode;
198
+ const example = countryCode
199
+ ? getExampleNumber(countryCode, mobileExamples)
200
+ : undefined;
196
201
  if (!example) return props.length;
197
202
 
198
203
  const dialCodeLength = String(example.countryCallingCode ?? "").length;
@@ -251,24 +256,11 @@ const onInputChanged = (
251
256
  _formattedNumber: string,
252
257
  phoneObject: TelephoneInputMeta,
253
258
  ) => {
254
- const countryCode = phoneObject.country ?? activeCountry.value?.iso2;
255
- const example = countryCode
256
- ? getExampleNumber(countryCode, mobileExamples)
257
- : undefined;
258
- const dialCode =
259
- example?.countryCallingCode ?? activeCountry.value?.dialCode ?? "";
260
- const phoneDigits = String(phoneObject.number ?? "").replace(/\D/g, "");
261
- const nationalDigits = phoneDigits.slice(String(dialCode).length);
262
-
263
- if (nationalDigits.length > 0) {
264
- isTouched.value = true;
265
- }
266
-
267
259
  telephoneIsValid.value = Boolean(phoneObject.valid);
268
- hasError.value = telephoneIsValid.value;
260
+ hasError.value = !telephoneIsValid.value;
269
261
 
270
262
  dynamicMaxLength.value = getCountryMaxLength(
271
- activeCountry.value ?? phoneObject.country ?? null,
263
+ phoneObject.country ?? activeCountry.value ?? null,
272
264
  );
273
265
 
274
266
  emit("update:modelValue", phoneObject.number);
@@ -313,12 +305,19 @@ const externalErrorMessage = computed(() => {
313
305
  });
314
306
 
315
307
  const internalErrorMessage = computed(() => {
316
- if (!isTouched.value || props.readonly || props.disabled) return "";
308
+ if (
309
+ !isTouched.value ||
310
+ telephoneIsValid.value ||
311
+ props.readonly ||
312
+ props.disabled
313
+ ) {
314
+ return "";
315
+ }
317
316
 
318
317
  const value = String(mobile.value ?? "").trim();
319
318
  if (!value) return props.required ? "Mobile number is required" : "";
320
319
 
321
- return telephoneIsValid.value ? "" : "Enter a valid phone number";
320
+ return "Enter a valid phone number";
322
321
  });
323
322
 
324
323
  const errorMessage = computed(