@salesforcedevs/dw-components 1.3.397-canary.5 → 1.3.397-canary.6
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/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import { track as trackGtm } from "dxUtils/analytics";
|
|
|
4
4
|
import { submitForm, ErrorCode, SignupForm, UserData } from "./submitForm";
|
|
5
5
|
import { CountryOptions } from "typings/custom";
|
|
6
6
|
import { stateMap } from "dwUtils/forms";
|
|
7
|
-
import Recaptcha from "
|
|
7
|
+
import Recaptcha from "dw/recaptcha";
|
|
8
8
|
|
|
9
9
|
type SelectOption = { value: string; label: string };
|
|
10
10
|
type Country = SelectOption & {
|
|
@@ -86,7 +86,9 @@ export default class DeSignupForm extends LightningElement {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
onSlotChange(e: Event) {
|
|
89
|
-
this.recaptchaComponent =
|
|
89
|
+
this.recaptchaComponent = (
|
|
90
|
+
e.target as HTMLSlotElement
|
|
91
|
+
)?.assignedElements()[0] as unknown as Recaptcha;
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
createUUID() {
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
@import "dxHelpers/reset";
|
|
2
2
|
@import "dxHelpers/text";
|
|
3
3
|
|
|
4
|
-
.container {
|
|
5
|
-
width: 100%;
|
|
6
|
-
display: flex;
|
|
7
|
-
justify-content: center;
|
|
8
|
-
margin-bottom: var(--dx-g-spacing-lg);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
4
|
.error-message-box {
|
|
12
5
|
margin-top: var(--dx-g-spacing-xs);
|
|
13
6
|
display: block;
|
|
@@ -7,8 +7,9 @@ type RecaptchaApi = {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export default class Recaptcha extends LightningElement {
|
|
10
|
+
private didRenderRecaptcha = false;
|
|
10
11
|
private errorMessage = "";
|
|
11
|
-
private recaptchaDiv
|
|
12
|
+
private recaptchaDiv?: HTMLDivElement;
|
|
12
13
|
private recaptchaApi?: RecaptchaApi;
|
|
13
14
|
private recaptchaToken = "";
|
|
14
15
|
|
|
@@ -22,7 +23,10 @@ export default class Recaptcha extends LightningElement {
|
|
|
22
23
|
|
|
23
24
|
@api
|
|
24
25
|
recaptchaScriptOnLoad = (recaptchaApi: RecaptchaApi) => {
|
|
26
|
+
// store callbacks to be used with recaptcha
|
|
25
27
|
this.recaptchaApi = recaptchaApi;
|
|
28
|
+
|
|
29
|
+
// and if we have everything needed to render, render
|
|
26
30
|
if (this.recaptchaDiv) {
|
|
27
31
|
this.renderRecaptcha();
|
|
28
32
|
}
|
|
@@ -47,30 +51,36 @@ export default class Recaptcha extends LightningElement {
|
|
|
47
51
|
return Boolean(this.recaptchaToken);
|
|
48
52
|
};
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
private onSlotChange = (e: Event) => {
|
|
55
|
+
this.recaptchaDiv = (
|
|
56
|
+
e.target as HTMLSlotElement
|
|
57
|
+
)?.assignedElements?.()[0] as HTMLDivElement;
|
|
58
|
+
|
|
59
|
+
// if we have everything needed to render, render
|
|
60
|
+
if (this.recaptchaApi) {
|
|
61
|
+
this.renderRecaptcha();
|
|
58
62
|
}
|
|
59
|
-
}
|
|
63
|
+
};
|
|
60
64
|
|
|
61
65
|
private renderRecaptcha = () => {
|
|
66
|
+
if (this.didRenderRecaptcha) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
62
70
|
const smallMatchMedia = window.matchMedia(
|
|
63
71
|
"screen and (max-width: 768px)"
|
|
64
72
|
);
|
|
65
73
|
|
|
66
74
|
// render recaptcha, referencing this component's callbacks for handling events
|
|
67
|
-
this.recaptchaApi?.render(this.recaptchaDiv, {
|
|
75
|
+
this.recaptchaApi?.render(this.recaptchaDiv as HTMLDivElement, {
|
|
68
76
|
sitekey: this.recaptchaSiteKey,
|
|
69
77
|
callback: this.recaptchaCallback,
|
|
70
78
|
"expired-callback": this.recaptchaExpiredCallback,
|
|
71
79
|
"error-callback": this.recaptchaErrorCallback,
|
|
72
80
|
size: smallMatchMedia.matches ? "compact" : "normal"
|
|
73
81
|
});
|
|
82
|
+
|
|
83
|
+
this.didRenderRecaptcha = true;
|
|
74
84
|
};
|
|
75
85
|
|
|
76
86
|
private recaptchaCallback = (token: string) => {
|