@descope/web-components-ui 1.0.381 → 1.0.382

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.esm.js CHANGED
@@ -13,7 +13,7 @@ import debounce from 'lodash.debounce';
13
13
  import '@vaadin/password-field';
14
14
  import MarkdownIt from 'markdown-it';
15
15
  import '@vaadin/text-area';
16
- import parsePhone from 'libphonenumber-js/min';
16
+ import { parsePhoneNumberFromString } from 'libphonenumber-js/min';
17
17
  import '@vaadin/grid';
18
18
  import { GridSortColumn } from '@vaadin/grid/vaadin-grid-sort-column';
19
19
  import { GridSelectionColumn } from '@vaadin/grid/vaadin-grid-selection-column';
@@ -7941,6 +7941,32 @@ const comboBoxItem = ({ code, dialCode, name: country }) => `
7941
7941
  </div>
7942
7942
  `;
7943
7943
 
7944
+ const parsePhoneNumber = (val) => {
7945
+ const value = val || '';
7946
+ let countryCode = '';
7947
+ let phoneNumber = '';
7948
+
7949
+ // Attempt to parse the value using libphonenumber-js
7950
+ const parsed = parsePhoneNumberFromString(value);
7951
+
7952
+ if (parsed) {
7953
+ if (parsed.countryCallingCode) {
7954
+ countryCode = `+${parsed.countryCallingCode}`;
7955
+ }
7956
+
7957
+ if (parsed.nationalNumber) {
7958
+ phoneNumber = parsed.nationalNumber;
7959
+ }
7960
+ } else {
7961
+ // Fallback: assume a dash separates country code and phone number
7962
+ const [country, phone] = value.split('-');
7963
+ countryCode = country || '';
7964
+ phoneNumber = phone || '';
7965
+ }
7966
+
7967
+ return [countryCode, phoneNumber];
7968
+ };
7969
+
7944
7970
  const componentName$C = getComponentName('phone-field-internal');
7945
7971
 
7946
7972
  const commonAttrs$1 = ['disabled', 'size', 'bordered', 'invalid', 'readonly'];
@@ -8000,9 +8026,7 @@ let PhoneFieldInternal$1 = class PhoneFieldInternal extends BaseInputClass$6 {
8000
8026
  }
8001
8027
 
8002
8028
  set value(val) {
8003
- const parsed = parsePhone(val || '');
8004
- const countryCode = parsed?.countryCallingCode ? `+${parsed.countryCallingCode}` : '';
8005
- const phoneNumber = parsed?.nationalNumber || '';
8029
+ const [countryCode, phoneNumber] = parsePhoneNumber(val);
8006
8030
 
8007
8031
  if (countryCode) {
8008
8032
  const countryCodeItem = this.getCountryByDialCode(countryCode);