@descope/web-components-ui 1.0.120 → 1.0.122

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.esm.js CHANGED
@@ -3129,6 +3129,7 @@ const ComboBoxClass = compose(
3129
3129
  selector: '',
3130
3130
  mappings: {
3131
3131
  backgroundColor: { selector: 'vaadin-combo-box-scroller' },
3132
+ fontFamily: { selector: 'vaadin-combo-box-item' },
3132
3133
  // TODO: this mapping doesn't work, needs fixing.
3133
3134
  cursor: { selector: 'vaadin-combo-box-item' },
3134
3135
  },
@@ -4403,6 +4404,7 @@ const comboBoxItem = ({ code, dialCode, name: country }) => (`
4403
4404
  style="display:flex; flex-direction: column;"
4404
4405
  data-id="${code}"
4405
4406
  data-name="${code} ${dialCode} ${country}"
4407
+ data-dial-code="${dialCode}"
4406
4408
  >
4407
4409
  <div>
4408
4410
  <span>
@@ -4474,7 +4476,10 @@ class PhoneFieldInternal extends BaseInputClass$1 {
4474
4476
 
4475
4477
  set value(val) {
4476
4478
  const [countryCode = '', phoneNumber = ''] = val.split('-');
4477
- this.countryCodeInput.value = countryCode;
4479
+ const countryCodeItem = this.getCountryByDialCode(countryCode);
4480
+ if (countryCodeItem) {
4481
+ this.countryCodeInput.selectedItem = countryCodeItem;
4482
+ }
4478
4483
  this.phoneNumberInput.value = phoneNumber;
4479
4484
  }
4480
4485
 
@@ -4509,7 +4514,6 @@ class PhoneFieldInternal extends BaseInputClass$1 {
4509
4514
  };
4510
4515
 
4511
4516
  init() {
4512
-
4513
4517
  this.addEventListener('focus', (e) => {
4514
4518
  // we want to ignore focus events we are dispatching
4515
4519
  if (e.isTrusted)
@@ -4521,18 +4525,24 @@ class PhoneFieldInternal extends BaseInputClass$1 {
4521
4525
  this.setComboBoxDescriptor();
4522
4526
  }
4523
4527
 
4528
+ getCountryByDialCode(countryDialCode) {
4529
+ return this.countryCodeInput.items.find(c => c.getAttribute('data-dial-code') === countryDialCode);
4530
+ }
4531
+
4532
+ getCountryByCodeId(countryCode) {
4533
+ return this.countryCodeInput.items.find(c => c['data-id'] === countryCode)?.['data-name'];
4534
+ }
4535
+
4524
4536
  handleDefaultCountryCode(countryCode) {
4525
4537
  if (!this.countryCodeInput.value) {
4526
- const countryData = this.countryCodeInput.items.find(c => c['data-id'] === countryCode)?.['data-name'];
4527
-
4538
+ const countryCodeItem = this.getCountryByCodeId(countryCode);
4528
4539
  // When replacing the input component (inserting internal component into text-field) -
4529
4540
  // Vaadin resets the input's value. We use setTimeout in order to make sure this happens
4530
4541
  // after the reset.
4531
- if (countryData) {
4542
+ if (countryCodeItem) {
4532
4543
  setTimeout(() => {
4533
- this.countryCodeInput.selectedItem = this.countryCodeInput.items.find(node => node['data-id'] === countryCode);
4544
+ this.countryCodeInput.selectedItem = countryCodeItem;
4534
4545
  });
4535
-
4536
4546
  }
4537
4547
  }
4538
4548
  }
@@ -4695,7 +4705,11 @@ const PhoneFieldClass = compose(
4695
4705
  fontFamily: [
4696
4706
  label$1,
4697
4707
  errorMessage$1,
4698
- helperText$1
4708
+ helperText$1,
4709
+ {
4710
+ ...countryCodeInput,
4711
+ property: ComboBoxClass.cssVarList.overlay.fontFamily
4712
+ }
4699
4713
  ],
4700
4714
  hostWidth: [
4701
4715
  { ...host$1, property: 'width' },
@@ -5208,7 +5222,7 @@ const globalsThemeToStyle = (theme, themeName = '') => {
5208
5222
  ''
5209
5223
  );
5210
5224
 
5211
- if(!themeName) return style
5225
+ if (!themeName) return style
5212
5226
 
5213
5227
  return `*[data-theme="${themeName}"] {${style}}`
5214
5228
  };