@descope/web-components-ui 1.0.380 → 1.0.382
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/cjs/index.cjs.js +2 -3
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +30 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/DescopeDev.js +1 -1
- package/dist/umd/descope-date-field-index-js.js +1 -1
- package/dist/umd/phone-fields-descope-phone-field-descope-phone-field-internal-index-js.js +1 -1
- package/dist/umd/phone-fields-descope-phone-field-index-js.js +1 -1
- package/package.json +1 -1
- package/src/components/descope-date-field/DateFieldClass.js +2 -3
- package/src/components/phone-fields/descope-phone-field/descope-phone-field-internal/PhoneFieldInternal.js +2 -5
- package/src/components/phone-fields/descope-phone-field/helpers.js +28 -0
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
|
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';
|
@@ -4703,9 +4703,6 @@ class RawDateFieldClass extends BaseInputClass$8 {
|
|
4703
4703
|
this.baseElement.noCloseOnOutsideClick = true;
|
4704
4704
|
this.baseElement.renderer = this.#popoverRenderer.bind(this);
|
4705
4705
|
|
4706
|
-
// override vaadin's constructed stylesheet which hides the host element
|
4707
|
-
overrideConstructedStylesheet(this.baseElement);
|
4708
|
-
|
4709
4706
|
// block popover events from focusing/blurring the text-field
|
4710
4707
|
this.baseElement.addEventListener('click', (e) => {
|
4711
4708
|
e.preventDefault();
|
@@ -4717,6 +4714,8 @@ class RawDateFieldClass extends BaseInputClass$8 {
|
|
4717
4714
|
// popoverRenderer should run only once, when the popover is first rendering.
|
4718
4715
|
if (!root.firstChild) {
|
4719
4716
|
root.appendChild(this.#getPopoverContent());
|
4717
|
+
// override vaadin's constructed stylesheet which hides the host element
|
4718
|
+
overrideConstructedStylesheet(this.baseElement);
|
4720
4719
|
|
4721
4720
|
// To prevent position flickering of the dialog we set opacity to 0
|
4722
4721
|
root.style.setProperty('opacity', '0');
|
@@ -7942,6 +7941,32 @@ const comboBoxItem = ({ code, dialCode, name: country }) => `
|
|
7942
7941
|
</div>
|
7943
7942
|
`;
|
7944
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
|
+
|
7945
7970
|
const componentName$C = getComponentName('phone-field-internal');
|
7946
7971
|
|
7947
7972
|
const commonAttrs$1 = ['disabled', 'size', 'bordered', 'invalid', 'readonly'];
|
@@ -8001,9 +8026,7 @@ let PhoneFieldInternal$1 = class PhoneFieldInternal extends BaseInputClass$6 {
|
|
8001
8026
|
}
|
8002
8027
|
|
8003
8028
|
set value(val) {
|
8004
|
-
const
|
8005
|
-
const countryCode = parsed?.countryCallingCode ? `+${parsed.countryCallingCode}` : '';
|
8006
|
-
const phoneNumber = parsed?.nationalNumber || '';
|
8029
|
+
const [countryCode, phoneNumber] = parsePhoneNumber(val);
|
8007
8030
|
|
8008
8031
|
if (countryCode) {
|
8009
8032
|
const countryCodeItem = this.getCountryByDialCode(countryCode);
|