@descope/web-components-ui 3.2.1 → 3.3.0
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 +81 -8
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +81 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/descope-recaptcha-index-js.js +1 -1
- package/dist/umd/descope-recaptcha-index-js.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/package.json +32 -32
- package/src/components/descope-recaptcha/RecaptchaClass.js +81 -8
package/dist/index.esm.js
CHANGED
|
@@ -13047,7 +13047,7 @@ customElements.define(componentName$V, NewPasswordClass);
|
|
|
13047
13047
|
|
|
13048
13048
|
const componentName$U = getComponentName('recaptcha');
|
|
13049
13049
|
|
|
13050
|
-
const observedAttributes$3 = ['enabled', 'site-key', 'action', 'enterprise'];
|
|
13050
|
+
const observedAttributes$3 = ['enabled', 'site-key', 'action', 'enterprise', 'variant'];
|
|
13051
13051
|
|
|
13052
13052
|
const BaseClass$7 = createBaseClass({
|
|
13053
13053
|
componentName: componentName$U,
|
|
@@ -13064,6 +13064,10 @@ class RawRecaptcha extends BaseClass$7 {
|
|
|
13064
13064
|
if (attrName === 'enabled') {
|
|
13065
13065
|
this.#toggleRecaptcha(newValue === 'true');
|
|
13066
13066
|
}
|
|
13067
|
+
|
|
13068
|
+
if (attrName === 'variant') {
|
|
13069
|
+
this.updatePreview();
|
|
13070
|
+
}
|
|
13067
13071
|
}
|
|
13068
13072
|
}
|
|
13069
13073
|
|
|
@@ -13076,13 +13080,37 @@ class RawRecaptcha extends BaseClass$7 {
|
|
|
13076
13080
|
this.toggleRecaptchaEles(enabled);
|
|
13077
13081
|
}
|
|
13078
13082
|
|
|
13083
|
+
displayRecaptcha() {
|
|
13084
|
+
if (this.isWidget) {
|
|
13085
|
+
this.displayWidget();
|
|
13086
|
+
} else {
|
|
13087
|
+
this.displayDeprecated();
|
|
13088
|
+
}
|
|
13089
|
+
}
|
|
13090
|
+
|
|
13091
|
+
displayWidget() {
|
|
13092
|
+
this.mockRecaptchaEle.style.display = 'none';
|
|
13093
|
+
this.recaptchaWidgetEle.style.display = '';
|
|
13094
|
+
this.depercatedRecaptchaEle.style.display = 'none';
|
|
13095
|
+
}
|
|
13096
|
+
|
|
13097
|
+
hideRecaptcha() {
|
|
13098
|
+
this.recaptchaWidgetEle.style.display = 'none';
|
|
13099
|
+
this.depercatedRecaptchaEle.style.display = 'none';
|
|
13100
|
+
this.mockRecaptchaEle.style.display = '';
|
|
13101
|
+
}
|
|
13102
|
+
|
|
13103
|
+
displayDeprecated() {
|
|
13104
|
+
this.mockRecaptchaEle.style.display = 'none';
|
|
13105
|
+
this.recaptchaWidgetEle.style.display = 'none';
|
|
13106
|
+
this.depercatedRecaptchaEle.style.display = '';
|
|
13107
|
+
}
|
|
13108
|
+
|
|
13079
13109
|
toggleRecaptchaEles(enabled) {
|
|
13080
13110
|
if (enabled) {
|
|
13081
|
-
this.
|
|
13082
|
-
this.mockRecaptchaEle.style.display = 'none';
|
|
13111
|
+
this.displayRecaptcha();
|
|
13083
13112
|
} else {
|
|
13084
|
-
this.
|
|
13085
|
-
this.mockRecaptchaEle.style.display = '';
|
|
13113
|
+
this.hideRecaptcha();
|
|
13086
13114
|
}
|
|
13087
13115
|
}
|
|
13088
13116
|
|
|
@@ -13092,6 +13120,8 @@ class RawRecaptcha extends BaseClass$7 {
|
|
|
13092
13120
|
this.attachShadow({ mode: 'open' }).innerHTML = `
|
|
13093
13121
|
<div class="badge">
|
|
13094
13122
|
<span id="recaptcha"></span>
|
|
13123
|
+
<span id="recaptcha-widget"></span>
|
|
13124
|
+
<input id="recaptcha-widget-input" type="hidden" name="recaptcha-widget" required />
|
|
13095
13125
|
<img src="https://imgs.descope.com/connectors/templates/recaptcha/recaptcha-big.png" alt="recaptcha"/>
|
|
13096
13126
|
</div>
|
|
13097
13127
|
<slot></slot>
|
|
@@ -13115,6 +13145,13 @@ class RawRecaptcha extends BaseClass$7 {
|
|
|
13115
13145
|
width: 100%;
|
|
13116
13146
|
height: 100%;
|
|
13117
13147
|
}
|
|
13148
|
+
:host #recaptcha-widget {
|
|
13149
|
+
width: 100%;
|
|
13150
|
+
height: 100%;
|
|
13151
|
+
}
|
|
13152
|
+
:host #recaptcha-widget-input {
|
|
13153
|
+
display: none;
|
|
13154
|
+
}
|
|
13118
13155
|
:host img {
|
|
13119
13156
|
width: 256px;
|
|
13120
13157
|
}
|
|
@@ -13128,7 +13165,9 @@ class RawRecaptcha extends BaseClass$7 {
|
|
|
13128
13165
|
this
|
|
13129
13166
|
);
|
|
13130
13167
|
|
|
13131
|
-
this.
|
|
13168
|
+
this.depercatedRecaptchaEle = this.baseElement.querySelector('#recaptcha');
|
|
13169
|
+
this.recaptchaWidgetEle = this.baseElement.querySelector('#recaptcha-widget');
|
|
13170
|
+
this.recaptchaWidgetInputEle = this.baseElement.querySelector('#recaptcha-widget-input');
|
|
13132
13171
|
this.mockRecaptchaEle = this.baseElement.querySelector('img');
|
|
13133
13172
|
this.badge = this.shadowRoot.querySelector('.badge');
|
|
13134
13173
|
}
|
|
@@ -13141,7 +13180,8 @@ class RawRecaptcha extends BaseClass$7 {
|
|
|
13141
13180
|
|
|
13142
13181
|
updatePreview() {
|
|
13143
13182
|
if (this.children.length) {
|
|
13144
|
-
this.
|
|
13183
|
+
this.depercatedRecaptchaEle.style.display = 'none';
|
|
13184
|
+
this.recaptchaWidgetEle.style.display = 'none';
|
|
13145
13185
|
this.mockRecaptchaEle.style.display = 'none';
|
|
13146
13186
|
this.badge.classList.add('hidden');
|
|
13147
13187
|
} else {
|
|
@@ -13150,6 +13190,26 @@ class RawRecaptcha extends BaseClass$7 {
|
|
|
13150
13190
|
}
|
|
13151
13191
|
}
|
|
13152
13192
|
|
|
13193
|
+
getValidity() {
|
|
13194
|
+
if (!this.isWidget) {
|
|
13195
|
+
return {};
|
|
13196
|
+
}
|
|
13197
|
+
|
|
13198
|
+
if (!this.recaptchaWidgetInputEle.value) {
|
|
13199
|
+
return { valueMissing: true };
|
|
13200
|
+
}
|
|
13201
|
+
|
|
13202
|
+
return {};
|
|
13203
|
+
}
|
|
13204
|
+
|
|
13205
|
+
checkValidity() {
|
|
13206
|
+
if (!this.isWidget) {
|
|
13207
|
+
return true;
|
|
13208
|
+
}
|
|
13209
|
+
|
|
13210
|
+
return !!this.recaptchaWidgetInputEle.value;
|
|
13211
|
+
}
|
|
13212
|
+
|
|
13153
13213
|
get enterprise() {
|
|
13154
13214
|
return this.getAttribute('enterprise') === 'true';
|
|
13155
13215
|
}
|
|
@@ -13166,6 +13226,14 @@ class RawRecaptcha extends BaseClass$7 {
|
|
|
13166
13226
|
return this.getAttribute('enabled') === 'true';
|
|
13167
13227
|
}
|
|
13168
13228
|
|
|
13229
|
+
get variant() {
|
|
13230
|
+
return this.getAttribute('variant') || 'text';
|
|
13231
|
+
}
|
|
13232
|
+
|
|
13233
|
+
get isWidget() {
|
|
13234
|
+
return this.variant === 'widget';
|
|
13235
|
+
}
|
|
13236
|
+
|
|
13169
13237
|
get scriptURL() {
|
|
13170
13238
|
const url = new URL('https://www.google.com/recaptcha/');
|
|
13171
13239
|
url.pathname += `${this.enterprise ? 'enterprise' : 'api'}.js`;
|
|
@@ -13176,6 +13244,11 @@ class RawRecaptcha extends BaseClass$7 {
|
|
|
13176
13244
|
|
|
13177
13245
|
#toggleRecaptcha(enabled) {
|
|
13178
13246
|
this.renderRecaptcha(enabled);
|
|
13247
|
+
if (this.isWidget) {
|
|
13248
|
+
// For the v2 checkbox flow, scripts are loaded/executed by the runtime (grecaptcha-v2).
|
|
13249
|
+
// This legacy v3/invisible path must be fully skipped.
|
|
13250
|
+
return;
|
|
13251
|
+
}
|
|
13179
13252
|
if (enabled) {
|
|
13180
13253
|
this.#createOnLoadScript();
|
|
13181
13254
|
if (!document.getElementById('recaptcha-script')) {
|
|
@@ -13248,7 +13321,7 @@ class RawRecaptcha extends BaseClass$7 {
|
|
|
13248
13321
|
|
|
13249
13322
|
#createOnLoadScript() {
|
|
13250
13323
|
window.onRecaptchaLoadCallback = () => {
|
|
13251
|
-
const currentNode = this.
|
|
13324
|
+
const currentNode = this.depercatedRecaptchaEle;
|
|
13252
13325
|
|
|
13253
13326
|
// if there are child nodes, it means that the recaptcha was already rendered
|
|
13254
13327
|
if (currentNode.hasChildNodes()) {
|