@descope/web-components-ui 2.3.0 → 2.3.2
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 +4 -2
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +56 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/3685.js +1 -1
- package/dist/umd/3685.js.map +1 -1
- package/dist/umd/DescopeDev.js +1 -1
- package/dist/umd/DescopeDev.js.map +1 -1
- package/dist/umd/descope-hybrid-field-index-js.js +1 -1
- package/dist/umd/descope-hybrid-field-index-js.js.map +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-descope-phone-field-internal-index-js.js.map +1 -1
- package/dist/umd/phone-fields-descope-phone-field-index-js.js +1 -1
- package/dist/umd/phone-fields-descope-phone-field-index-js.js.map +1 -1
- package/package.json +31 -31
- package/src/components/descope-hybrid-field/HybridFieldClass.js +3 -1
- package/src/components/phone-fields/CountryCodes.js +1 -1
- package/src/components/phone-fields/descope-phone-field/descope-phone-field-internal/PhoneFieldInternal.js +51 -7
package/dist/index.esm.js
CHANGED
|
@@ -15,7 +15,7 @@ import '@vaadin/email-field';
|
|
|
15
15
|
import '@vaadin/number-field';
|
|
16
16
|
import '@vaadin/password-field';
|
|
17
17
|
import '@vaadin/text-area';
|
|
18
|
-
import parsePhoneNumberFromString$1, {
|
|
18
|
+
import parsePhoneNumberFromString$1, { parsePhoneNumberFromString, AsYouType } from 'libphonenumber-js/min';
|
|
19
19
|
import '@vaadin/grid';
|
|
20
20
|
import { GridSortColumn } from '@vaadin/grid/vaadin-grid-sort-column';
|
|
21
21
|
import { GridSelectionColumn } from '@vaadin/grid/vaadin-grid-selection-column';
|
|
@@ -10293,7 +10293,7 @@ var CountryCodes = [
|
|
|
10293
10293
|
},
|
|
10294
10294
|
{
|
|
10295
10295
|
name: 'Guyana',
|
|
10296
|
-
dialCode: '+
|
|
10296
|
+
dialCode: '+592',
|
|
10297
10297
|
code: 'GY',
|
|
10298
10298
|
},
|
|
10299
10299
|
{
|
|
@@ -11183,12 +11183,56 @@ let PhoneFieldInternal$1 = class PhoneFieldInternal extends BaseInputClass$9 {
|
|
|
11183
11183
|
return `${this.comboBox.value}-${this.textField.value.replace(/\D+/g, '')}`;
|
|
11184
11184
|
}
|
|
11185
11185
|
|
|
11186
|
+
#clearValue() {
|
|
11187
|
+
this.comboBox.selectedItem = undefined;
|
|
11188
|
+
this.textField.value = '';
|
|
11189
|
+
}
|
|
11190
|
+
|
|
11186
11191
|
set value(val) {
|
|
11187
|
-
|
|
11188
|
-
|
|
11189
|
-
|
|
11190
|
-
|
|
11192
|
+
// reject empty or digit-free values
|
|
11193
|
+
if (!val || !/\d/.test(val)) {
|
|
11194
|
+
this.#clearValue();
|
|
11195
|
+
return;
|
|
11196
|
+
}
|
|
11191
11197
|
|
|
11198
|
+
// ensure plus prefix
|
|
11199
|
+
if (!val.startsWith('+')) {
|
|
11200
|
+
val = `+${val}`;
|
|
11201
|
+
}
|
|
11202
|
+
|
|
11203
|
+
let dialCode = '';
|
|
11204
|
+
let nationalNumber = '';
|
|
11205
|
+
|
|
11206
|
+
if (val.includes('-')) {
|
|
11207
|
+
// dash explicitly marks where the dial code ends — no parsing needed
|
|
11208
|
+
const dashIdx = val.indexOf('-');
|
|
11209
|
+
dialCode = val.slice(0, dashIdx);
|
|
11210
|
+
nationalNumber = val.slice(dashIdx + 1).replace(/\D+/g, '');
|
|
11211
|
+
} else {
|
|
11212
|
+
// parse only to get dial code length,
|
|
11213
|
+
const parsed = parsePhoneNumberFromString(val);
|
|
11214
|
+
if (parsed?.countryCallingCode) {
|
|
11215
|
+
dialCode = `+${parsed.countryCallingCode}`;
|
|
11216
|
+
// slice the raw value to avoid parser transformations
|
|
11217
|
+
nationalNumber = val.slice(dialCode.length).replace(/\D+/g, '');
|
|
11218
|
+
}
|
|
11219
|
+
}
|
|
11220
|
+
|
|
11221
|
+
// dial code must contain digits (e.g. '+1', not just '+')
|
|
11222
|
+
if (!/\d/.test(dialCode)) {
|
|
11223
|
+
this.#clearValue();
|
|
11224
|
+
return;
|
|
11225
|
+
}
|
|
11226
|
+
|
|
11227
|
+
// resolve country code from dial code
|
|
11228
|
+
const countryCode = CountryCodes.find((c) => c.dialCode === dialCode)?.code;
|
|
11229
|
+
|
|
11230
|
+
// sync combo box when country changes
|
|
11231
|
+
if (countryCode && countryCode !== this.selectedCountryCode) {
|
|
11232
|
+
this.comboBox.selectedItem = this.#getCountryItemByCodeId(countryCode);
|
|
11233
|
+
}
|
|
11234
|
+
|
|
11235
|
+
// set formatted or raw national number on the text field
|
|
11192
11236
|
if (this.isFormatValue) {
|
|
11193
11237
|
this.textField.value = this.#formatNationalNumber(nationalNumber);
|
|
11194
11238
|
} else {
|
|
@@ -11239,7 +11283,7 @@ let PhoneFieldInternal$1 = class PhoneFieldInternal extends BaseInputClass$9 {
|
|
|
11239
11283
|
super.attributeChangedCallback(attrName, oldValue, newValue);
|
|
11240
11284
|
|
|
11241
11285
|
if (oldValue !== newValue) {
|
|
11242
|
-
if (attrName === 'default-code' && newValue) {
|
|
11286
|
+
if (attrName === 'default-code' && newValue && !this.selectedCountryCode) {
|
|
11243
11287
|
this.#handleDefaultCountryCode(newValue);
|
|
11244
11288
|
} else if (inputRelatedAttrs$1.includes(attrName)) {
|
|
11245
11289
|
const attr = mapAttrs$1[attrName] || attrName;
|
|
@@ -11317,7 +11361,7 @@ let PhoneFieldInternal$1 = class PhoneFieldInternal extends BaseInputClass$9 {
|
|
|
11317
11361
|
}
|
|
11318
11362
|
|
|
11319
11363
|
// return country item by country code `data-country-code` (e.g. `US`)
|
|
11320
|
-
#
|
|
11364
|
+
#getCountryItemByCodeId(countryCode) {
|
|
11321
11365
|
return this.comboBox.items?.find((c) => c.getAttribute('data-country-code') === countryCode);
|
|
11322
11366
|
}
|
|
11323
11367
|
|
|
@@ -11333,7 +11377,7 @@ let PhoneFieldInternal$1 = class PhoneFieldInternal extends BaseInputClass$9 {
|
|
|
11333
11377
|
|
|
11334
11378
|
#handleDefaultCountryCode(countryCode) {
|
|
11335
11379
|
if (!this.comboBox.value) {
|
|
11336
|
-
const countryCodeItem = this.#
|
|
11380
|
+
const countryCodeItem = this.#getCountryItemByCodeId(countryCode);
|
|
11337
11381
|
// When replacing the input component (inserting internal component into text-field) -
|
|
11338
11382
|
// Vaadin resets the input's value. We use setTimeout in order to make sure this happens
|
|
11339
11383
|
// after the reset.
|
|
@@ -18918,7 +18962,9 @@ class RawHybridField extends BaseClass$6 {
|
|
|
18918
18962
|
|
|
18919
18963
|
set value(val) {
|
|
18920
18964
|
this.handleActiveInput(val);
|
|
18921
|
-
|
|
18965
|
+
setTimeout(() => {
|
|
18966
|
+
this.activeInput.value = val;
|
|
18967
|
+
});
|
|
18922
18968
|
}
|
|
18923
18969
|
|
|
18924
18970
|
async init() {
|