@descope/web-components-ui 3.2.2 → 3.3.1

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 (26) hide show
  1. package/dist/cjs/index.cjs.js +87 -10
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +106 -12
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/umd/DescopeDev.js +1 -1
  6. package/dist/umd/DescopeDev.js.map +1 -1
  7. package/dist/umd/descope-hybrid-field-index-js.js +2 -2
  8. package/dist/umd/descope-hybrid-field-index-js.js.map +1 -1
  9. package/dist/umd/descope-recaptcha-index-js.js +1 -1
  10. package/dist/umd/descope-recaptcha-index-js.js.map +1 -1
  11. package/dist/umd/index.js +1 -1
  12. package/dist/umd/phone-fields-descope-phone-field-descope-phone-field-internal-index-js.js +1 -1
  13. package/dist/umd/phone-fields-descope-phone-field-descope-phone-field-internal-index-js.js.map +1 -1
  14. package/dist/umd/phone-fields-descope-phone-field-index-js.js +1 -1
  15. package/dist/umd/phone-fields-descope-phone-field-index-js.js.map +1 -1
  16. package/dist/umd/phone-fields-descope-phone-input-box-field-descope-phone-input-box-internal-index-js.js +1 -1
  17. package/dist/umd/phone-fields-descope-phone-input-box-field-descope-phone-input-box-internal-index-js.js.map +1 -1
  18. package/dist/umd/phone-fields-descope-phone-input-box-field-index-js.js +1 -1
  19. package/dist/umd/phone-fields-descope-phone-input-box-field-index-js.js.map +1 -1
  20. package/package.json +32 -32
  21. package/src/components/descope-hybrid-field/HybridFieldClass.js +4 -2
  22. package/src/components/descope-recaptcha/RecaptchaClass.js +81 -8
  23. package/src/components/phone-fields/descope-phone-field/PhoneFieldClass.js +1 -0
  24. package/src/components/phone-fields/descope-phone-field/descope-phone-field-internal/PhoneFieldInternal.js +12 -2
  25. package/src/components/phone-fields/descope-phone-input-box-field/PhoneFieldInputBoxClass.js +1 -0
  26. package/src/components/phone-fields/descope-phone-input-box-field/descope-phone-input-box-internal/PhoneFieldInternalInputBox.js +7 -0
package/dist/index.esm.js CHANGED
@@ -11075,12 +11075,19 @@ const componentName$$ = getComponentName('phone-field-internal');
11075
11075
 
11076
11076
  const commonAttrs$2 = ['disabled', 'size', 'bordered', 'readonly'];
11077
11077
  const countryAttrs = ['country-input-placeholder', 'default-code', 'restrict-countries'];
11078
- const phoneAttrs = ['phone-input-placeholder', 'maxlength', 'autocomplete', 'name'];
11078
+ const phoneAttrs = [
11079
+ 'phone-input-placeholder',
11080
+ 'maxlength',
11081
+ 'autocomplete',
11082
+ 'name',
11083
+ 'phone-input-type',
11084
+ ];
11079
11085
  const labelTypeAttrs$1 = ['label-type', 'country-input-label', 'label'];
11080
11086
  const mapAttrs$1 = {
11081
11087
  'country-input-label': 'label',
11082
11088
  'country-input-placeholder': 'placeholder',
11083
11089
  'phone-input-placeholder': 'placeholder',
11090
+ 'phone-input-type': 'type',
11084
11091
  };
11085
11092
 
11086
11093
  const inputRelatedAttrs$1 = [].concat(commonAttrs$2, countryAttrs, phoneAttrs, labelTypeAttrs$1);
@@ -11116,7 +11123,10 @@ let PhoneFieldInternal$1 = class PhoneFieldInternal extends BaseInputClass$a {
11116
11123
  this.inputs = [this.comboBox, this.textField];
11117
11124
 
11118
11125
  forwardAttrs(this, this.comboBox, { includeAttrs: ['label-type'] });
11119
- forwardAttrs(this, this.textField, { includeAttrs: ['label-type', 'required'] });
11126
+ forwardAttrs(this, this.textField, {
11127
+ includeAttrs: ['label-type', 'required', 'phone-input-type'],
11128
+ mapAttrs: { 'phone-input-type': 'type' },
11129
+ });
11120
11130
 
11121
11131
  // override combo box setter to display dialCode value in input
11122
11132
  this.comboBox.customValueTransformFn = (val) => {
@@ -11486,6 +11496,7 @@ const customMixin$b = (superclass) =>
11486
11496
  'allow-alphanumeric-input',
11487
11497
  'format-value',
11488
11498
  'strict-validation',
11499
+ 'phone-input-type',
11489
11500
  ],
11490
11501
  });
11491
11502
  }
@@ -11765,9 +11776,11 @@ const observedAttributes$4 = [
11765
11776
  'maxlength',
11766
11777
  'autocomplete',
11767
11778
  'label-type',
11779
+ 'phone-input-type',
11768
11780
  ];
11769
11781
  const mapAttrs = {
11770
11782
  'phone-input-placeholder': 'placeholder',
11783
+ 'phone-input-type': 'type',
11771
11784
  };
11772
11785
 
11773
11786
  const BaseInputClass$9 = createBaseInputClass({ componentName: componentName$Z, baseSelector: 'div' });
@@ -11861,6 +11874,11 @@ class PhoneFieldInternal extends BaseInputClass$9 {
11861
11874
  this.handleFocusEventsDispatching([this.textField]);
11862
11875
 
11863
11876
  forwardAttrs$1(this.textField, this, { includeAttrs: ['has-value'] });
11877
+
11878
+ forwardAttrs$1(this, this.textField, {
11879
+ includeAttrs: ['phone-input-type'],
11880
+ mapAttrs: { 'phone-input-type': 'type' },
11881
+ });
11864
11882
  }
11865
11883
 
11866
11884
  getValidity() {
@@ -12063,6 +12081,7 @@ const customMixin$a = (superclass) =>
12063
12081
  'format-value',
12064
12082
  'strict-validation',
12065
12083
  'data-errormessage-type-mismatch',
12084
+ 'phone-input-type',
12066
12085
  ],
12067
12086
  });
12068
12087
  }
@@ -13047,7 +13066,7 @@ customElements.define(componentName$V, NewPasswordClass);
13047
13066
 
13048
13067
  const componentName$U = getComponentName('recaptcha');
13049
13068
 
13050
- const observedAttributes$3 = ['enabled', 'site-key', 'action', 'enterprise'];
13069
+ const observedAttributes$3 = ['enabled', 'site-key', 'action', 'enterprise', 'variant'];
13051
13070
 
13052
13071
  const BaseClass$7 = createBaseClass({
13053
13072
  componentName: componentName$U,
@@ -13064,6 +13083,10 @@ class RawRecaptcha extends BaseClass$7 {
13064
13083
  if (attrName === 'enabled') {
13065
13084
  this.#toggleRecaptcha(newValue === 'true');
13066
13085
  }
13086
+
13087
+ if (attrName === 'variant') {
13088
+ this.updatePreview();
13089
+ }
13067
13090
  }
13068
13091
  }
13069
13092
 
@@ -13076,13 +13099,37 @@ class RawRecaptcha extends BaseClass$7 {
13076
13099
  this.toggleRecaptchaEles(enabled);
13077
13100
  }
13078
13101
 
13102
+ displayRecaptcha() {
13103
+ if (this.isWidget) {
13104
+ this.displayWidget();
13105
+ } else {
13106
+ this.displayDeprecated();
13107
+ }
13108
+ }
13109
+
13110
+ displayWidget() {
13111
+ this.mockRecaptchaEle.style.display = 'none';
13112
+ this.recaptchaWidgetEle.style.display = '';
13113
+ this.depercatedRecaptchaEle.style.display = 'none';
13114
+ }
13115
+
13116
+ hideRecaptcha() {
13117
+ this.recaptchaWidgetEle.style.display = 'none';
13118
+ this.depercatedRecaptchaEle.style.display = 'none';
13119
+ this.mockRecaptchaEle.style.display = '';
13120
+ }
13121
+
13122
+ displayDeprecated() {
13123
+ this.mockRecaptchaEle.style.display = 'none';
13124
+ this.recaptchaWidgetEle.style.display = 'none';
13125
+ this.depercatedRecaptchaEle.style.display = '';
13126
+ }
13127
+
13079
13128
  toggleRecaptchaEles(enabled) {
13080
13129
  if (enabled) {
13081
- this.recaptchaEle.style.display = '';
13082
- this.mockRecaptchaEle.style.display = 'none';
13130
+ this.displayRecaptcha();
13083
13131
  } else {
13084
- this.recaptchaEle.style.display = 'none';
13085
- this.mockRecaptchaEle.style.display = '';
13132
+ this.hideRecaptcha();
13086
13133
  }
13087
13134
  }
13088
13135
 
@@ -13092,6 +13139,8 @@ class RawRecaptcha extends BaseClass$7 {
13092
13139
  this.attachShadow({ mode: 'open' }).innerHTML = `
13093
13140
  <div class="badge">
13094
13141
  <span id="recaptcha"></span>
13142
+ <span id="recaptcha-widget"></span>
13143
+ <input id="recaptcha-widget-input" type="hidden" name="recaptcha-widget" required />
13095
13144
  <img src="https://imgs.descope.com/connectors/templates/recaptcha/recaptcha-big.png" alt="recaptcha"/>
13096
13145
  </div>
13097
13146
  <slot></slot>
@@ -13115,6 +13164,13 @@ class RawRecaptcha extends BaseClass$7 {
13115
13164
  width: 100%;
13116
13165
  height: 100%;
13117
13166
  }
13167
+ :host #recaptcha-widget {
13168
+ width: 100%;
13169
+ height: 100%;
13170
+ }
13171
+ :host #recaptcha-widget-input {
13172
+ display: none;
13173
+ }
13118
13174
  :host img {
13119
13175
  width: 256px;
13120
13176
  }
@@ -13128,7 +13184,9 @@ class RawRecaptcha extends BaseClass$7 {
13128
13184
  this
13129
13185
  );
13130
13186
 
13131
- this.recaptchaEle = this.baseElement.querySelector('#recaptcha');
13187
+ this.depercatedRecaptchaEle = this.baseElement.querySelector('#recaptcha');
13188
+ this.recaptchaWidgetEle = this.baseElement.querySelector('#recaptcha-widget');
13189
+ this.recaptchaWidgetInputEle = this.baseElement.querySelector('#recaptcha-widget-input');
13132
13190
  this.mockRecaptchaEle = this.baseElement.querySelector('img');
13133
13191
  this.badge = this.shadowRoot.querySelector('.badge');
13134
13192
  }
@@ -13141,7 +13199,8 @@ class RawRecaptcha extends BaseClass$7 {
13141
13199
 
13142
13200
  updatePreview() {
13143
13201
  if (this.children.length) {
13144
- this.recaptchaEle.style.display = 'none';
13202
+ this.depercatedRecaptchaEle.style.display = 'none';
13203
+ this.recaptchaWidgetEle.style.display = 'none';
13145
13204
  this.mockRecaptchaEle.style.display = 'none';
13146
13205
  this.badge.classList.add('hidden');
13147
13206
  } else {
@@ -13150,6 +13209,26 @@ class RawRecaptcha extends BaseClass$7 {
13150
13209
  }
13151
13210
  }
13152
13211
 
13212
+ getValidity() {
13213
+ if (!this.isWidget) {
13214
+ return {};
13215
+ }
13216
+
13217
+ if (!this.recaptchaWidgetInputEle.value) {
13218
+ return { valueMissing: true };
13219
+ }
13220
+
13221
+ return {};
13222
+ }
13223
+
13224
+ checkValidity() {
13225
+ if (!this.isWidget) {
13226
+ return true;
13227
+ }
13228
+
13229
+ return !!this.recaptchaWidgetInputEle.value;
13230
+ }
13231
+
13153
13232
  get enterprise() {
13154
13233
  return this.getAttribute('enterprise') === 'true';
13155
13234
  }
@@ -13166,6 +13245,14 @@ class RawRecaptcha extends BaseClass$7 {
13166
13245
  return this.getAttribute('enabled') === 'true';
13167
13246
  }
13168
13247
 
13248
+ get variant() {
13249
+ return this.getAttribute('variant') || 'text';
13250
+ }
13251
+
13252
+ get isWidget() {
13253
+ return this.variant === 'widget';
13254
+ }
13255
+
13169
13256
  get scriptURL() {
13170
13257
  const url = new URL('https://www.google.com/recaptcha/');
13171
13258
  url.pathname += `${this.enterprise ? 'enterprise' : 'api'}.js`;
@@ -13176,6 +13263,11 @@ class RawRecaptcha extends BaseClass$7 {
13176
13263
 
13177
13264
  #toggleRecaptcha(enabled) {
13178
13265
  this.renderRecaptcha(enabled);
13266
+ if (this.isWidget) {
13267
+ // For the v2 checkbox flow, scripts are loaded/executed by the runtime (grecaptcha-v2).
13268
+ // This legacy v3/invisible path must be fully skipped.
13269
+ return;
13270
+ }
13179
13271
  if (enabled) {
13180
13272
  this.#createOnLoadScript();
13181
13273
  if (!document.getElementById('recaptcha-script')) {
@@ -13248,7 +13340,7 @@ class RawRecaptcha extends BaseClass$7 {
13248
13340
 
13249
13341
  #createOnLoadScript() {
13250
13342
  window.onRecaptchaLoadCallback = () => {
13251
- const currentNode = this.recaptchaEle;
13343
+ const currentNode = this.depercatedRecaptchaEle;
13252
13344
 
13253
13345
  // if there are child nodes, it means that the recaptcha was already rendered
13254
13346
  if (currentNode.hasChildNodes()) {
@@ -18952,6 +19044,7 @@ const attrs = {
18952
19044
  'phone-minlength',
18953
19045
  'phone-format-value',
18954
19046
  'phone-strict-validation',
19047
+ 'phone-input-type',
18955
19048
  'data-errormessage-value-missing-phone',
18956
19049
  ],
18957
19050
  inputBox: [
@@ -18960,6 +19053,7 @@ const attrs = {
18960
19053
  'phone-minlength',
18961
19054
  'phone-format-value',
18962
19055
  'phone-strict-validation',
19056
+ 'phone-input-type',
18963
19057
  'data-errormessage-value-missing-phone',
18964
19058
  ],
18965
19059
  },
@@ -18999,8 +19093,8 @@ class RawHybridField extends BaseClass$6 {
18999
19093
  this.attachShadow({ mode: 'open' }).innerHTML = `
19000
19094
  <div class="wrapper">
19001
19095
  <descope-email-field external-input="${this.isExternalInput}"></descope-email-field>
19002
- <descope-phone-field allow-alphanumeric-input="true"></descope-phone-field>
19003
- <descope-phone-input-box-field allow-alphanumeric-input="true"></descope-phone-input-box-field>
19096
+ <descope-phone-field allow-alphanumeric-input="true" phone-input-type="text"></descope-phone-field>
19097
+ <descope-phone-input-box-field allow-alphanumeric-input="true" phone-input-type="text"></descope-phone-input-box-field>
19004
19098
  </div>
19005
19099
  `;
19006
19100