@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
@@ -15624,6 +15624,7 @@ const customMixin$6 = (superclass) =>
15624
15624
  'allow-alphanumeric-input',
15625
15625
  'format-value',
15626
15626
  'strict-validation',
15627
+ 'phone-input-type',
15627
15628
  ],
15628
15629
  });
15629
15630
  }
@@ -15970,6 +15971,7 @@ const customMixin$5 = (superclass) =>
15970
15971
  'format-value',
15971
15972
  'strict-validation',
15972
15973
  'data-errormessage-type-mismatch',
15974
+ 'phone-input-type',
15973
15975
  ],
15974
15976
  });
15975
15977
  }
@@ -24233,6 +24235,7 @@ const attrs = {
24233
24235
  'phone-minlength',
24234
24236
  'phone-format-value',
24235
24237
  'phone-strict-validation',
24238
+ 'phone-input-type',
24236
24239
  'data-errormessage-value-missing-phone',
24237
24240
  ],
24238
24241
  inputBox: [
@@ -24241,6 +24244,7 @@ const attrs = {
24241
24244
  'phone-minlength',
24242
24245
  'phone-format-value',
24243
24246
  'phone-strict-validation',
24247
+ 'phone-input-type',
24244
24248
  'data-errormessage-value-missing-phone',
24245
24249
  ],
24246
24250
  },
@@ -24280,8 +24284,8 @@ class RawHybridField extends BaseClass$2 {
24280
24284
  this.attachShadow({ mode: 'open' }).innerHTML = `
24281
24285
  <div class="wrapper">
24282
24286
  <descope-email-field external-input="${this.isExternalInput}"></descope-email-field>
24283
- <descope-phone-field allow-alphanumeric-input="true"></descope-phone-field>
24284
- <descope-phone-input-box-field allow-alphanumeric-input="true"></descope-phone-input-box-field>
24287
+ <descope-phone-field allow-alphanumeric-input="true" phone-input-type="text"></descope-phone-field>
24288
+ <descope-phone-input-box-field allow-alphanumeric-input="true" phone-input-type="text"></descope-phone-input-box-field>
24285
24289
  </div>
24286
24290
  `;
24287
24291
 
@@ -25119,7 +25123,7 @@ const darkTheme = merge({}, defaultTheme, {
25119
25123
 
25120
25124
  const componentName$2 = getComponentName$1('recaptcha');
25121
25125
 
25122
- const observedAttributes = ['enabled', 'site-key', 'action', 'enterprise'];
25126
+ const observedAttributes = ['enabled', 'site-key', 'action', 'enterprise', 'variant'];
25123
25127
 
25124
25128
  const BaseClass$1 = createBaseClass({
25125
25129
  componentName: componentName$2,
@@ -25136,6 +25140,10 @@ class RawRecaptcha extends BaseClass$1 {
25136
25140
  if (attrName === 'enabled') {
25137
25141
  this.#toggleRecaptcha(newValue === 'true');
25138
25142
  }
25143
+
25144
+ if (attrName === 'variant') {
25145
+ this.updatePreview();
25146
+ }
25139
25147
  }
25140
25148
  }
25141
25149
 
@@ -25148,13 +25156,37 @@ class RawRecaptcha extends BaseClass$1 {
25148
25156
  this.toggleRecaptchaEles(enabled);
25149
25157
  }
25150
25158
 
25159
+ displayRecaptcha() {
25160
+ if (this.isWidget) {
25161
+ this.displayWidget();
25162
+ } else {
25163
+ this.displayDeprecated();
25164
+ }
25165
+ }
25166
+
25167
+ displayWidget() {
25168
+ this.mockRecaptchaEle.style.display = 'none';
25169
+ this.recaptchaWidgetEle.style.display = '';
25170
+ this.depercatedRecaptchaEle.style.display = 'none';
25171
+ }
25172
+
25173
+ hideRecaptcha() {
25174
+ this.recaptchaWidgetEle.style.display = 'none';
25175
+ this.depercatedRecaptchaEle.style.display = 'none';
25176
+ this.mockRecaptchaEle.style.display = '';
25177
+ }
25178
+
25179
+ displayDeprecated() {
25180
+ this.mockRecaptchaEle.style.display = 'none';
25181
+ this.recaptchaWidgetEle.style.display = 'none';
25182
+ this.depercatedRecaptchaEle.style.display = '';
25183
+ }
25184
+
25151
25185
  toggleRecaptchaEles(enabled) {
25152
25186
  if (enabled) {
25153
- this.recaptchaEle.style.display = '';
25154
- this.mockRecaptchaEle.style.display = 'none';
25187
+ this.displayRecaptcha();
25155
25188
  } else {
25156
- this.recaptchaEle.style.display = 'none';
25157
- this.mockRecaptchaEle.style.display = '';
25189
+ this.hideRecaptcha();
25158
25190
  }
25159
25191
  }
25160
25192
 
@@ -25164,6 +25196,8 @@ class RawRecaptcha extends BaseClass$1 {
25164
25196
  this.attachShadow({ mode: 'open' }).innerHTML = `
25165
25197
  <div class="badge">
25166
25198
  <span id="recaptcha"></span>
25199
+ <span id="recaptcha-widget"></span>
25200
+ <input id="recaptcha-widget-input" type="hidden" name="recaptcha-widget" required />
25167
25201
  <img src="https://imgs.descope.com/connectors/templates/recaptcha/recaptcha-big.png" alt="recaptcha"/>
25168
25202
  </div>
25169
25203
  <slot></slot>
@@ -25187,6 +25221,13 @@ class RawRecaptcha extends BaseClass$1 {
25187
25221
  width: 100%;
25188
25222
  height: 100%;
25189
25223
  }
25224
+ :host #recaptcha-widget {
25225
+ width: 100%;
25226
+ height: 100%;
25227
+ }
25228
+ :host #recaptcha-widget-input {
25229
+ display: none;
25230
+ }
25190
25231
  :host img {
25191
25232
  width: 256px;
25192
25233
  }
@@ -25200,7 +25241,9 @@ class RawRecaptcha extends BaseClass$1 {
25200
25241
  this
25201
25242
  );
25202
25243
 
25203
- this.recaptchaEle = this.baseElement.querySelector('#recaptcha');
25244
+ this.depercatedRecaptchaEle = this.baseElement.querySelector('#recaptcha');
25245
+ this.recaptchaWidgetEle = this.baseElement.querySelector('#recaptcha-widget');
25246
+ this.recaptchaWidgetInputEle = this.baseElement.querySelector('#recaptcha-widget-input');
25204
25247
  this.mockRecaptchaEle = this.baseElement.querySelector('img');
25205
25248
  this.badge = this.shadowRoot.querySelector('.badge');
25206
25249
  }
@@ -25213,7 +25256,8 @@ class RawRecaptcha extends BaseClass$1 {
25213
25256
 
25214
25257
  updatePreview() {
25215
25258
  if (this.children.length) {
25216
- this.recaptchaEle.style.display = 'none';
25259
+ this.depercatedRecaptchaEle.style.display = 'none';
25260
+ this.recaptchaWidgetEle.style.display = 'none';
25217
25261
  this.mockRecaptchaEle.style.display = 'none';
25218
25262
  this.badge.classList.add('hidden');
25219
25263
  } else {
@@ -25222,6 +25266,26 @@ class RawRecaptcha extends BaseClass$1 {
25222
25266
  }
25223
25267
  }
25224
25268
 
25269
+ getValidity() {
25270
+ if (!this.isWidget) {
25271
+ return {};
25272
+ }
25273
+
25274
+ if (!this.recaptchaWidgetInputEle.value) {
25275
+ return { valueMissing: true };
25276
+ }
25277
+
25278
+ return {};
25279
+ }
25280
+
25281
+ checkValidity() {
25282
+ if (!this.isWidget) {
25283
+ return true;
25284
+ }
25285
+
25286
+ return !!this.recaptchaWidgetInputEle.value;
25287
+ }
25288
+
25225
25289
  get enterprise() {
25226
25290
  return this.getAttribute('enterprise') === 'true';
25227
25291
  }
@@ -25238,6 +25302,14 @@ class RawRecaptcha extends BaseClass$1 {
25238
25302
  return this.getAttribute('enabled') === 'true';
25239
25303
  }
25240
25304
 
25305
+ get variant() {
25306
+ return this.getAttribute('variant') || 'text';
25307
+ }
25308
+
25309
+ get isWidget() {
25310
+ return this.variant === 'widget';
25311
+ }
25312
+
25241
25313
  get scriptURL() {
25242
25314
  const url = new URL('https://www.google.com/recaptcha/');
25243
25315
  url.pathname += `${this.enterprise ? 'enterprise' : 'api'}.js`;
@@ -25248,6 +25320,11 @@ class RawRecaptcha extends BaseClass$1 {
25248
25320
 
25249
25321
  #toggleRecaptcha(enabled) {
25250
25322
  this.renderRecaptcha(enabled);
25323
+ if (this.isWidget) {
25324
+ // For the v2 checkbox flow, scripts are loaded/executed by the runtime (grecaptcha-v2).
25325
+ // This legacy v3/invisible path must be fully skipped.
25326
+ return;
25327
+ }
25251
25328
  if (enabled) {
25252
25329
  this.#createOnLoadScript();
25253
25330
  if (!document.getElementById('recaptcha-script')) {
@@ -25320,7 +25397,7 @@ class RawRecaptcha extends BaseClass$1 {
25320
25397
 
25321
25398
  #createOnLoadScript() {
25322
25399
  window.onRecaptchaLoadCallback = () => {
25323
- const currentNode = this.recaptchaEle;
25400
+ const currentNode = this.depercatedRecaptchaEle;
25324
25401
 
25325
25402
  // if there are child nodes, it means that the recaptcha was already rendered
25326
25403
  if (currentNode.hasChildNodes()) {