@descope/web-components-ui 1.0.406 → 1.0.408

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.
Files changed (31) hide show
  1. package/dist/cjs/index.cjs.js +171 -54
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +173 -55
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/umd/1053.js +1 -1
  6. package/dist/umd/{5459.js → 2755.js} +1 -1
  7. package/dist/umd/4480.js +1 -0
  8. package/dist/umd/4619.js +1 -1
  9. package/dist/umd/6726.js +1 -1
  10. package/dist/umd/7212.js +1 -1
  11. package/dist/umd/7607.js +1 -1
  12. package/dist/umd/DescopeDev.js +1 -1
  13. package/dist/umd/descope-combo-box-index-js.js +7 -7
  14. package/dist/umd/descope-date-field-descope-calendar-index-js.js +1 -1
  15. package/dist/umd/descope-hybrid-field-index-js.js +3 -3
  16. package/dist/umd/descope-recaptcha-index-js.js +1 -1
  17. package/dist/umd/descope-security-questions-setup-index-js.js +1 -1
  18. package/dist/umd/index.js +1 -1
  19. package/dist/umd/mapping-fields-descope-mappings-field-index-js.js +1 -1
  20. package/dist/umd/mapping-fields-descope-saml-group-mappings-index-js.js +1 -1
  21. package/dist/umd/phone-fields-descope-phone-field-descope-phone-field-internal-index-js.js +1 -1
  22. package/dist/umd/phone-fields-descope-phone-field-index-js.js +1 -1
  23. package/dist/umd/phone-fields-descope-phone-input-box-field-descope-phone-input-box-internal-index-js.js +2 -2
  24. package/dist/umd/phone-fields-descope-phone-input-box-field-index-js.js +8 -8
  25. package/package.json +1 -1
  26. package/src/components/descope-combo-box/ComboBoxClass.js +112 -46
  27. package/src/components/descope-date-field/descope-calendar/CalendarClass.js +8 -6
  28. package/src/components/descope-recaptcha/RecaptchaClass.js +32 -3
  29. package/src/components/phone-fields/descope-phone-field/descope-phone-field-internal/PhoneFieldInternal.js +2 -1
  30. package/src/mixins/normalizeBooleanAttributesMixin.js +2 -0
  31. package/src/theme/components/comboBox.js +19 -0
package/dist/index.esm.js CHANGED
@@ -640,6 +640,8 @@ const booleanAttributesList = [
640
640
  'opening',
641
641
  'closing',
642
642
  'has-no-options',
643
+ 'loading',
644
+ 'allow-custom-value',
643
645
  ];
644
646
 
645
647
  const isBooleanAttribute = (attr) => {
@@ -2774,6 +2776,23 @@ const ComboBoxMixin = (superclass) =>
2774
2776
  this.renderItems();
2775
2777
  }
2776
2778
 
2779
+ set renderer(fn) {
2780
+ // fn takes (root, comboBox, model) as arguments
2781
+ this.baseElement.renderer = fn;
2782
+ }
2783
+
2784
+ get loading() {
2785
+ return this.getAttribute('loading') === 'true';
2786
+ }
2787
+
2788
+ set loading(val) {
2789
+ if (val) {
2790
+ this.setAttribute('loading', 'true');
2791
+ } else {
2792
+ this.removeAttribute('loading');
2793
+ }
2794
+ }
2795
+
2777
2796
  get data() {
2778
2797
  if (this.#data) return this.#data;
2779
2798
 
@@ -2817,14 +2836,20 @@ const ComboBoxMixin = (superclass) =>
2817
2836
  }
2818
2837
 
2819
2838
  renderItems() {
2820
- const template = this.getItemsTemplate();
2821
- if (template) this.innerHTML = template;
2839
+ if (this.#data || this.getAttribute('data')) {
2840
+ const template = this.getItemsTemplate();
2841
+ this.innerHTML = template;
2842
+ }
2822
2843
  }
2823
2844
 
2824
2845
  handleSelectedItem() {
2825
- const currentSelected = this.baseElement.selectedItem?.['data-id'];
2846
+ const { selectedItem } = this.baseElement;
2847
+ const currentSelected = selectedItem?.['data-id'];
2826
2848
 
2827
- this.baseElement.selectedItem = undefined;
2849
+ // If the selected item is still a child, there's no need to update the value
2850
+ if (selectedItem && Array.from(this.children).includes(selectedItem)) {
2851
+ return;
2852
+ }
2828
2853
 
2829
2854
  // if previously selected item ID exists in current children, set it as selected
2830
2855
  if (currentSelected) {
@@ -2857,7 +2882,7 @@ const ComboBoxMixin = (superclass) =>
2857
2882
  value: {
2858
2883
  ...valueDescriptor,
2859
2884
  set(val) {
2860
- if (!comboBox.baseElement.items?.length) {
2885
+ if (!comboBox.baseElement.items?.length && !comboBox.allowCustomValue) {
2861
2886
  return;
2862
2887
  }
2863
2888
 
@@ -2877,39 +2902,27 @@ const ComboBoxMixin = (superclass) =>
2877
2902
  // in order to avoid it, we are passing the children of this component
2878
2903
  // to the items & renderer props, so it will be used as the combo box items
2879
2904
  #onChildrenChange() {
2880
- const baseElement = this.shadowRoot.querySelector(this.baseSelector);
2881
2905
  const items = Array.from(this.children);
2882
2906
 
2883
2907
  // we want the data-name attribute to be accessible as an object attribute
2884
- if (items.length) {
2885
- items.forEach((node) => {
2886
- Object.defineProperty(node, 'data-name', {
2887
- value: node.getAttribute('data-name'),
2888
- configurable: true,
2889
- writable: true,
2890
- });
2891
- Object.defineProperty(node, 'data-id', {
2892
- value: node.getAttribute('data-id'),
2893
- configurable: true,
2894
- writable: true,
2895
- });
2908
+ items.forEach((node) => {
2909
+ Object.defineProperty(node, 'data-name', {
2910
+ value: node.getAttribute('data-name'),
2911
+ configurable: true,
2912
+ writable: true,
2896
2913
  });
2914
+ Object.defineProperty(node, 'data-id', {
2915
+ value: node.getAttribute('data-id'),
2916
+ configurable: true,
2917
+ writable: true,
2918
+ });
2919
+ });
2897
2920
 
2898
- baseElement.items = items;
2899
-
2900
- setTimeout(() => {
2901
- // set timeout to ensure this runs after customValueTransformFn had the chance to be overriden
2902
- this.handleSelectedItem();
2903
- }, 0);
2904
- }
2905
-
2906
- // use vaadin combobox custom renderer to render options as HTML
2907
- // and not via default renderer, which renders only the data-name's value
2908
- // in its own HTML template
2909
- baseElement.renderer = (root, combo, model) => {
2910
- // eslint-disable-next-line no-param-reassign
2911
- root.innerHTML = model.item.outerHTML;
2912
- };
2921
+ this.baseElement.items = items;
2922
+ setTimeout(() => {
2923
+ // set timeout to ensure this runs after customValueTransformFn had the chance to be overriden
2924
+ this.handleSelectedItem();
2925
+ }, 0);
2913
2926
  }
2914
2927
 
2915
2928
  // the default vaadin behavior is to attach the overlay to the body when opened
@@ -2924,6 +2937,16 @@ const ComboBoxMixin = (superclass) =>
2924
2937
  overlay._enterModalState = () => {};
2925
2938
  }
2926
2939
 
2940
+ #overrideRenderer() {
2941
+ // use vaadin combobox custom renderer to render options as HTML
2942
+ // and not via default renderer, which renders only the data-name's value
2943
+ // in its own HTML template
2944
+ this.baseElement.renderer = (root, combo, model) => {
2945
+ // eslint-disable-next-line no-param-reassign
2946
+ root.innerHTML = model.item.outerHTML;
2947
+ };
2948
+ }
2949
+
2927
2950
  init() {
2928
2951
  super.init?.();
2929
2952
 
@@ -2938,13 +2961,11 @@ const ComboBoxMixin = (superclass) =>
2938
2961
  };
2939
2962
 
2940
2963
  this.setComboBoxDescriptor();
2941
-
2942
2964
  this.#overrideOverlaySettings();
2965
+ this.#overrideRenderer();
2943
2966
 
2944
- this.renderItems();
2945
-
2967
+ // Set up observers - order matters here since renderItems can clear innerHTML
2946
2968
  observeAttributes(this, this.renderItems.bind(this), { includeAttrs: ['data'] });
2947
-
2948
2969
  observeChildren(this, this.#onChildrenChange.bind(this));
2949
2970
 
2950
2971
  this.setDefaultValue();
@@ -2977,16 +2998,38 @@ const ComboBoxMixin = (superclass) =>
2977
2998
  }
2978
2999
 
2979
3000
  setDefaultValue() {
2980
- this.value = this.defaultValue;
3001
+ if (this.defaultValue) {
3002
+ this.value = this.defaultValue;
3003
+ }
2981
3004
  }
2982
3005
 
2983
- set value(val) {
2984
- if (val) {
2985
- const child = this.baseElement.items?.find((item) => item['data-id'] === val);
3006
+ #getChildToSelect(val) {
3007
+ return this.baseElement.items?.find((item) => item['data-id'] === val);
3008
+ }
2986
3009
 
2987
- if (child) {
2988
- this.baseElement.selectedItem = child;
2989
- }
3010
+ #preventSelectedItemChangeEventIfNeeded(val, selectedChild) {
3011
+ // If the actual value didn't change, but the selected item did (the element changed),
3012
+ // we want to stop the event propagation since it's not a real change
3013
+ const shouldPreventItemChangeEvent =
3014
+ val === this.value && selectedChild !== this.baseElement.selectedItem;
3015
+ if (shouldPreventItemChangeEvent) {
3016
+ this.baseElement.addEventListener(
3017
+ 'selected-item-changed',
3018
+ (e) => {
3019
+ e.stopImmediatePropagation();
3020
+ },
3021
+ { once: true, capture: true }
3022
+ );
3023
+ }
3024
+ }
3025
+
3026
+ set value(val) {
3027
+ const selectedChild = this.#getChildToSelect(val);
3028
+ this.#preventSelectedItemChangeEventIfNeeded(val, selectedChild);
3029
+ if (val && selectedChild) {
3030
+ this.baseElement.selectedItem = selectedChild;
3031
+ } else if (!selectedChild && this.allowCustomValue) {
3032
+ this.baseElement.value = val;
2990
3033
  } else {
2991
3034
  this.baseElement.selectedItem = undefined;
2992
3035
  }
@@ -3116,7 +3159,10 @@ const ComboBoxClass = compose(
3116
3159
  name: 'overlay',
3117
3160
  selector: '',
3118
3161
  mappings: {
3119
- backgroundColor: { selector: 'vaadin-combo-box-scroller' },
3162
+ backgroundColor: [
3163
+ { selector: 'vaadin-combo-box-scroller' },
3164
+ { selector: 'vaadin-combo-box-overlay::part(overlay)' },
3165
+ ],
3120
3166
  minHeight: { selector: 'vaadin-combo-box-overlay' },
3121
3167
  margin: { selector: 'vaadin-combo-box-overlay' },
3122
3168
  cursor: { selector: 'vaadin-combo-box-item' },
@@ -3129,6 +3175,24 @@ const ComboBoxClass = compose(
3129
3175
  property: 'padding-inline-start',
3130
3176
  },
3131
3177
  itemPaddingInlineEnd: { selector: 'vaadin-combo-box-item', property: 'padding-inline-end' },
3178
+
3179
+ loaderTop: { selector: 'vaadin-combo-box-overlay::part(loader)', property: 'top' },
3180
+ loaderLeft: { selector: 'vaadin-combo-box-overlay::part(loader)', property: 'left' },
3181
+ loaderRight: { selector: 'vaadin-combo-box-overlay::part(loader)', property: 'right' },
3182
+ loaderMargin: { selector: 'vaadin-combo-box-overlay::part(loader)', property: 'margin' },
3183
+ loaderWidth: { selector: 'vaadin-combo-box-overlay::part(loader)', property: 'width' },
3184
+ loaderHeight: { selector: 'vaadin-combo-box-overlay::part(loader)', property: 'height' },
3185
+ loaderBorder: { selector: 'vaadin-combo-box-overlay::part(loader)', property: 'border' },
3186
+ loaderBorderColor: {
3187
+ selector: 'vaadin-combo-box-overlay::part(loader)',
3188
+ property: 'border-color',
3189
+ },
3190
+ loaderBorderRadius: {
3191
+ selector: 'vaadin-combo-box-overlay::part(loader)',
3192
+ property: 'border-radius',
3193
+ },
3194
+ contentHeight: { selector: 'vaadin-combo-box-overlay::part(content)', property: 'height' },
3195
+ contentOpacity: { selector: 'vaadin-combo-box-overlay::part(content)', property: 'opacity' },
3132
3196
  },
3133
3197
  forward: {
3134
3198
  include: false,
@@ -3176,6 +3240,10 @@ const ComboBoxClass = compose(
3176
3240
  align-self: center;
3177
3241
  }
3178
3242
 
3243
+ vaadin-combo-box[hide-toggle-button="true"]::part(toggle-button) {
3244
+ display: none;
3245
+ }
3246
+
3179
3247
  vaadin-combo-box[label-type="floating"]:not([focused])[readonly] > input:placeholder-shown {
3180
3248
  opacity: 0;
3181
3249
  }
@@ -3190,7 +3258,7 @@ const ComboBoxClass = compose(
3190
3258
  // with the same name. Including it will cause Vaadin to calculate NaN size,
3191
3259
  // and reset items to an empty array, and opening the list box with no items
3192
3260
  // to display.
3193
- excludeAttrsSync: ['tabindex', 'size', 'data'],
3261
+ excludeAttrsSync: ['tabindex', 'size', 'data', 'loading'],
3194
3262
  componentName: componentName$Z,
3195
3263
  includeForwardProps: ['items', 'renderer', 'selectedItem'],
3196
3264
  })
@@ -3766,7 +3834,9 @@ class RawCalendar extends BaseInputClass$9 {
3766
3834
  this.monthInput.value = month;
3767
3835
  // For the yearInput we update the base element directly to properly trigger the change event
3768
3836
  // since this can be a custom value
3769
- this.yearInput.baseElement.value = year;
3837
+ setTimeout(() => {
3838
+ this.yearInput.baseElement.value = year;
3839
+ });
3770
3840
  }
3771
3841
  }
3772
3842
 
@@ -3905,11 +3975,10 @@ class RawCalendar extends BaseInputClass$9 {
3905
3975
  }
3906
3976
 
3907
3977
  onMonthNamesChange() {
3908
- Array.from(this.monthInput?.children || []).forEach((child, index) => {
3909
- const month = this.monthNames[index];
3910
- child.setAttribute('data-name', month);
3911
- // eslint-disable-next-line no-param-reassign
3912
- child.textContent = month;
3978
+ setTimeout(() => {
3979
+ if (this.monthInput) {
3980
+ this.monthInput.innerHTML = getMonthsOptions(this.monthNames);
3981
+ }
3913
3982
  });
3914
3983
  }
3915
3984
 
@@ -8199,7 +8268,8 @@ let PhoneFieldInternal$1 = class PhoneFieldInternal extends BaseInputClass$6 {
8199
8268
  }
8200
8269
 
8201
8270
  getRestrictedCountries() {
8202
- return this.getAttribute('restrict-countries')?.split(',') || [];
8271
+ const attr = this.getAttribute('restrict-countries');
8272
+ return attr ? attr.split(',') : [];
8203
8273
  }
8204
8274
 
8205
8275
  getCountryByDialCode(countryDialCode) {
@@ -9698,6 +9768,11 @@ class RawRecaptcha extends BaseClass$1 {
9698
9768
  }
9699
9769
 
9700
9770
  renderRecaptcha(enabled) {
9771
+ if (this.children.length) {
9772
+ this.updatePreview();
9773
+ return;
9774
+ }
9775
+
9701
9776
  if (enabled) {
9702
9777
  this.recaptchaEle.style.display = '';
9703
9778
  this.mockRecaptchaEle.style.display = 'none';
@@ -9715,7 +9790,7 @@ class RawRecaptcha extends BaseClass$1 {
9715
9790
  :host {
9716
9791
  display: inline-flex;
9717
9792
  }
9718
- :host > div {
9793
+ :host > div:not(.hidden) {
9719
9794
  display: flex;
9720
9795
  }
9721
9796
  :host #recaptcha .grecaptcha-badge {
@@ -9730,16 +9805,40 @@ class RawRecaptcha extends BaseClass$1 {
9730
9805
  }
9731
9806
  :host img {
9732
9807
  width: 256px;
9808
+ }
9809
+ :host([full-width="true"]) {
9810
+ width: 100%;
9811
+ }
9812
+ .hidden {
9813
+ display: none;
9733
9814
  }
9734
9815
  </style>
9735
- <div>
9816
+ <div class="badge">
9736
9817
  <span id="recaptcha"></span>
9737
9818
  <img src="https://imgs.descope.com/connectors/templates/recaptcha/recaptcha-big.png" alt="recaptcha"/>
9738
9819
  </div>
9820
+ <slot></slot>
9739
9821
  `;
9740
9822
 
9741
9823
  this.recaptchaEle = this.baseElement.querySelector('#recaptcha');
9742
9824
  this.mockRecaptchaEle = this.baseElement.querySelector('img');
9825
+ this.badge = this.shadowRoot.querySelector('.badge');
9826
+ }
9827
+
9828
+ init() {
9829
+ super.init?.();
9830
+
9831
+ observeChildren(this, this.updatePreview.bind(this));
9832
+ }
9833
+
9834
+ updatePreview() {
9835
+ if (this.children.length) {
9836
+ this.recaptchaEle.style.display = 'none';
9837
+ this.mockRecaptchaEle.style.display = 'none';
9838
+ this.badge.classList.add('hidden');
9839
+ } else {
9840
+ this.badge.classList.remove('hidden');
9841
+ }
9743
9842
  }
9744
9843
 
9745
9844
  get enterprise() {
@@ -17239,6 +17338,25 @@ const comboBox = {
17239
17338
  // Overlay direct theme:
17240
17339
  [vars$y.overlay.minHeight]: '400px',
17241
17340
  [vars$y.overlay.margin]: '0',
17341
+
17342
+ [vars$y.overlay.contentHeight]: '100%',
17343
+ [vars$y.overlay.contentOpacity]: '1',
17344
+ _loading: {
17345
+ [vars$y.overlay.loaderTop]: '50%',
17346
+ [vars$y.overlay.loaderLeft]: '50%',
17347
+ [vars$y.overlay.loaderRight]: 'auto',
17348
+ // Margin has to be negative to center the loader, "transform" can't be used because the animation uses it
17349
+ // Margin has to be half of the width/height of the loader to center it
17350
+ [vars$y.overlay.loaderMargin]: '-15px 0 0 -15px',
17351
+ [vars$y.overlay.loaderWidth]: '30px',
17352
+ [vars$y.overlay.loaderHeight]: '30px',
17353
+ [vars$y.overlay.loaderBorder]: '2px solid transparent',
17354
+ [vars$y.overlay
17355
+ .loaderBorderColor]: `${globalRefs$m.colors.primary.highlight} ${globalRefs$m.colors.primary.highlight} ${globalRefs$m.colors.primary.main} ${globalRefs$m.colors.primary.main}`,
17356
+ [vars$y.overlay.loaderBorderRadius]: '50%',
17357
+ [vars$y.overlay.contentHeight]: '100px',
17358
+ [vars$y.overlay.contentOpacity]: '0',
17359
+ },
17242
17360
  };
17243
17361
 
17244
17362
  var comboBox$1 = /*#__PURE__*/Object.freeze({