keycloakify 6.7.2 → 6.8.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.
- package/README.md +6 -0
- package/lib/components/Error.d.ts +6 -3
- package/lib/components/Error.js +4 -4
- package/lib/components/Error.js.map +1 -1
- package/lib/components/IdpReviewUserProfile.d.ts +6 -3
- package/lib/components/IdpReviewUserProfile.js +10 -10
- package/lib/components/IdpReviewUserProfile.js.map +1 -1
- package/lib/components/Info.d.ts +6 -3
- package/lib/components/Info.js +4 -4
- package/lib/components/Info.js.map +1 -1
- package/lib/components/KcApp.d.ts +7 -4
- package/lib/components/KcApp.js +25 -24
- package/lib/components/KcApp.js.map +1 -1
- package/lib/components/Login.d.ts +6 -3
- package/lib/components/Login.js +17 -17
- package/lib/components/Login.js.map +1 -1
- package/lib/components/LoginConfigTotp.d.ts +6 -3
- package/lib/components/LoginConfigTotp.js +25 -25
- package/lib/components/LoginConfigTotp.js.map +1 -1
- package/lib/components/LoginIdpLinkConfirm.d.ts +6 -3
- package/lib/components/LoginIdpLinkConfirm.js +7 -7
- package/lib/components/LoginIdpLinkConfirm.js.map +1 -1
- package/lib/components/LoginIdpLinkEmail.d.ts +6 -3
- package/lib/components/LoginIdpLinkEmail.js +4 -4
- package/lib/components/LoginIdpLinkEmail.js.map +1 -1
- package/lib/components/LoginOtp.d.ts +6 -3
- package/lib/components/LoginOtp.js +19 -19
- package/lib/components/LoginOtp.js.map +1 -1
- package/lib/components/LoginPageExpired.d.ts +6 -3
- package/lib/components/LoginPageExpired.js +4 -4
- package/lib/components/LoginPageExpired.js.map +1 -1
- package/lib/components/LoginPassword.d.ts +6 -3
- package/lib/components/LoginPassword.js +12 -12
- package/lib/components/LoginPassword.js.map +1 -1
- package/lib/components/LoginResetPassword.d.ts +6 -3
- package/lib/components/LoginResetPassword.js +14 -14
- package/lib/components/LoginResetPassword.js.map +1 -1
- package/lib/components/LoginUpdatePassword.d.ts +6 -3
- package/lib/components/LoginUpdatePassword.js +20 -20
- package/lib/components/LoginUpdatePassword.js.map +1 -1
- package/lib/components/LoginUpdateProfile.d.ts +6 -3
- package/lib/components/LoginUpdateProfile.js +31 -31
- package/lib/components/LoginUpdateProfile.js.map +1 -1
- package/lib/components/LoginUsername.d.ts +6 -3
- package/lib/components/LoginUsername.js +13 -13
- package/lib/components/LoginUsername.js.map +1 -1
- package/lib/components/LoginVerifyEmail.d.ts +6 -3
- package/lib/components/LoginVerifyEmail.js +4 -4
- package/lib/components/LoginVerifyEmail.js.map +1 -1
- package/lib/components/LogoutConfirm.d.ts +6 -3
- package/lib/components/LogoutConfirm.js +8 -8
- package/lib/components/LogoutConfirm.js.map +1 -1
- package/lib/components/Register.d.ts +6 -3
- package/lib/components/Register.js +41 -41
- package/lib/components/Register.js.map +1 -1
- package/lib/components/RegisterUserProfile.d.ts +6 -3
- package/lib/components/RegisterUserProfile.js +12 -12
- package/lib/components/RegisterUserProfile.js.map +1 -1
- package/lib/components/Terms.d.ts +6 -3
- package/lib/components/Terms.js +6 -6
- package/lib/components/Terms.js.map +1 -1
- package/lib/components/UpdateUserProfile.d.ts +6 -3
- package/lib/components/UpdateUserProfile.js +11 -11
- package/lib/components/UpdateUserProfile.js.map +1 -1
- package/lib/components/WebauthnAuthenticate.d.ts +6 -3
- package/lib/components/WebauthnAuthenticate.js +18 -18
- package/lib/components/WebauthnAuthenticate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/lib/components/Error.tsx +34 -31
- package/src/lib/components/IdpReviewUserProfile.tsx +50 -47
- package/src/lib/components/Info.tsx +49 -46
- package/src/lib/components/KcApp.tsx +74 -69
- package/src/lib/components/Login.tsx +178 -175
- package/src/lib/components/LoginConfigTotp.tsx +163 -160
- package/src/lib/components/LoginIdpLinkConfirm.tsx +56 -43
- package/src/lib/components/LoginIdpLinkEmail.tsx +34 -31
- package/src/lib/components/LoginOtp.tsx +86 -83
- package/src/lib/components/LoginPageExpired.tsx +38 -35
- package/src/lib/components/LoginPassword.tsx +79 -76
- package/src/lib/components/LoginResetPassword.tsx +67 -64
- package/src/lib/components/LoginUpdatePassword.tsx +105 -102
- package/src/lib/components/LoginUpdateProfile.tsx +108 -105
- package/src/lib/components/LoginUsername.tsx +145 -142
- package/src/lib/components/LoginVerifyEmail.tsx +34 -31
- package/src/lib/components/LogoutConfirm.tsx +57 -54
- package/src/lib/components/Register.tsx +137 -134
- package/src/lib/components/RegisterUserProfile.tsx +63 -60
- package/src/lib/components/Terms.tsx +56 -52
- package/src/lib/components/UpdateUserProfile.tsx +61 -58
- package/src/lib/components/WebauthnAuthenticate.tsx +179 -178
@@ -1,169 +1,172 @@
|
|
1
1
|
import React, { memo } from "react";
|
2
|
-
import
|
2
|
+
import DefaultTemplate from "./Template";
|
3
|
+
import type { TemplateProps } from "./Template";
|
3
4
|
import type { KcProps } from "./KcProps";
|
4
5
|
import type { KcContextBase } from "../getKcContext/KcContextBase";
|
5
6
|
import { useCssAndCx } from "../tools/useCssAndCx";
|
6
7
|
import type { I18n } from "../i18n";
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}: { kcContext: KcContextBase.Register; i18n: I18n; doFetchDefaultThemeResources?: boolean } & KcProps) => {
|
15
|
-
const { url, messagesPerField, register, realm, passwordRequired, recaptchaRequired, recaptchaSiteKey } = kcContext;
|
9
|
+
export type RegisterProps = KcProps & {
|
10
|
+
kcContext: KcContextBase.Register;
|
11
|
+
i18n: I18n;
|
12
|
+
doFetchDefaultThemeResources?: boolean;
|
13
|
+
Template?: (props: TemplateProps) => JSX.Element | null;
|
14
|
+
};
|
16
15
|
|
17
|
-
|
16
|
+
const Register = memo((props: RegisterProps) => {
|
17
|
+
const { kcContext, i18n, doFetchDefaultThemeResources = true, Template = DefaultTemplate, ...kcProps } = props;
|
18
18
|
|
19
|
-
|
19
|
+
const { url, messagesPerField, register, realm, passwordRequired, recaptchaRequired, recaptchaSiteKey } = kcContext;
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
<
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
21
|
+
const { msg, msgStr } = i18n;
|
22
|
+
|
23
|
+
const { cx } = useCssAndCx();
|
24
|
+
|
25
|
+
return (
|
26
|
+
<Template
|
27
|
+
{...{ kcContext, i18n, doFetchDefaultThemeResources, ...kcProps }}
|
28
|
+
headerNode={msg("registerTitle")}
|
29
|
+
formNode={
|
30
|
+
<form id="kc-register-form" className={cx(kcProps.kcFormClass)} action={url.registrationAction} method="post">
|
31
|
+
<div className={cx(kcProps.kcFormGroupClass, messagesPerField.printIfExists("firstName", kcProps.kcFormGroupErrorClass))}>
|
32
|
+
<div className={cx(kcProps.kcLabelWrapperClass)}>
|
33
|
+
<label htmlFor="firstName" className={cx(kcProps.kcLabelClass)}>
|
34
|
+
{msg("firstName")}
|
35
|
+
</label>
|
36
|
+
</div>
|
37
|
+
<div className={cx(kcProps.kcInputWrapperClass)}>
|
38
|
+
<input
|
39
|
+
type="text"
|
40
|
+
id="firstName"
|
41
|
+
className={cx(kcProps.kcInputClass)}
|
42
|
+
name="firstName"
|
43
|
+
defaultValue={register.formData.firstName ?? ""}
|
44
|
+
/>
|
42
45
|
</div>
|
46
|
+
</div>
|
43
47
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
</div>
|
48
|
+
<div className={cx(kcProps.kcFormGroupClass, messagesPerField.printIfExists("lastName", kcProps.kcFormGroupErrorClass))}>
|
49
|
+
<div className={cx(kcProps.kcLabelWrapperClass)}>
|
50
|
+
<label htmlFor="lastName" className={cx(kcProps.kcLabelClass)}>
|
51
|
+
{msg("lastName")}
|
52
|
+
</label>
|
53
|
+
</div>
|
54
|
+
<div className={cx(kcProps.kcInputWrapperClass)}>
|
55
|
+
<input
|
56
|
+
type="text"
|
57
|
+
id="lastName"
|
58
|
+
className={cx(kcProps.kcInputClass)}
|
59
|
+
name="lastName"
|
60
|
+
defaultValue={register.formData.lastName ?? ""}
|
61
|
+
/>
|
59
62
|
</div>
|
63
|
+
</div>
|
60
64
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
+
<div className={cx(kcProps.kcFormGroupClass, messagesPerField.printIfExists("email", kcProps.kcFormGroupErrorClass))}>
|
66
|
+
<div className={cx(kcProps.kcLabelWrapperClass)}>
|
67
|
+
<label htmlFor="email" className={cx(kcProps.kcLabelClass)}>
|
68
|
+
{msg("email")}
|
69
|
+
</label>
|
70
|
+
</div>
|
71
|
+
<div className={cx(kcProps.kcInputWrapperClass)}>
|
72
|
+
<input
|
73
|
+
type="text"
|
74
|
+
id="email"
|
75
|
+
className={cx(kcProps.kcInputClass)}
|
76
|
+
name="email"
|
77
|
+
defaultValue={register.formData.email ?? ""}
|
78
|
+
autoComplete="email"
|
79
|
+
/>
|
80
|
+
</div>
|
81
|
+
</div>
|
82
|
+
{!realm.registrationEmailAsUsername && (
|
83
|
+
<div className={cx(kcProps.kcFormGroupClass, messagesPerField.printIfExists("username", kcProps.kcFormGroupErrorClass))}>
|
84
|
+
<div className={cx(kcProps.kcLabelWrapperClass)}>
|
85
|
+
<label htmlFor="username" className={cx(kcProps.kcLabelClass)}>
|
86
|
+
{msg("username")}
|
65
87
|
</label>
|
66
88
|
</div>
|
67
|
-
<div className={cx(
|
89
|
+
<div className={cx(kcProps.kcInputWrapperClass)}>
|
68
90
|
<input
|
69
91
|
type="text"
|
70
|
-
id="
|
71
|
-
className={cx(
|
72
|
-
name="
|
73
|
-
defaultValue={register.formData.
|
74
|
-
autoComplete="
|
92
|
+
id="username"
|
93
|
+
className={cx(kcProps.kcInputClass)}
|
94
|
+
name="username"
|
95
|
+
defaultValue={register.formData.username ?? ""}
|
96
|
+
autoComplete="username"
|
75
97
|
/>
|
76
98
|
</div>
|
77
99
|
</div>
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
100
|
+
)}
|
101
|
+
{passwordRequired && (
|
102
|
+
<>
|
103
|
+
<div className={cx(kcProps.kcFormGroupClass, messagesPerField.printIfExists("password", kcProps.kcFormGroupErrorClass))}>
|
104
|
+
<div className={cx(kcProps.kcLabelWrapperClass)}>
|
105
|
+
<label htmlFor="password" className={cx(kcProps.kcLabelClass)}>
|
106
|
+
{msg("password")}
|
83
107
|
</label>
|
84
108
|
</div>
|
85
|
-
<div className={cx(
|
109
|
+
<div className={cx(kcProps.kcInputWrapperClass)}>
|
86
110
|
<input
|
87
|
-
type="
|
88
|
-
id="
|
89
|
-
className={cx(
|
90
|
-
name="
|
91
|
-
|
92
|
-
autoComplete="username"
|
111
|
+
type="password"
|
112
|
+
id="password"
|
113
|
+
className={cx(kcProps.kcInputClass)}
|
114
|
+
name="password"
|
115
|
+
autoComplete="new-password"
|
93
116
|
/>
|
94
117
|
</div>
|
95
118
|
</div>
|
96
|
-
)}
|
97
|
-
{passwordRequired && (
|
98
|
-
<>
|
99
|
-
<div className={cx(props.kcFormGroupClass, messagesPerField.printIfExists("password", props.kcFormGroupErrorClass))}>
|
100
|
-
<div className={cx(props.kcLabelWrapperClass)}>
|
101
|
-
<label htmlFor="password" className={cx(props.kcLabelClass)}>
|
102
|
-
{msg("password")}
|
103
|
-
</label>
|
104
|
-
</div>
|
105
|
-
<div className={cx(props.kcInputWrapperClass)}>
|
106
|
-
<input
|
107
|
-
type="password"
|
108
|
-
id="password"
|
109
|
-
className={cx(props.kcInputClass)}
|
110
|
-
name="password"
|
111
|
-
autoComplete="new-password"
|
112
|
-
/>
|
113
|
-
</div>
|
114
|
-
</div>
|
115
119
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
</div>
|
127
|
-
<div className={cx(props.kcInputWrapperClass)}>
|
128
|
-
<input type="password" id="password-confirm" className={cx(props.kcInputClass)} name="password-confirm" />
|
129
|
-
</div>
|
120
|
+
<div
|
121
|
+
className={cx(
|
122
|
+
kcProps.kcFormGroupClass,
|
123
|
+
messagesPerField.printIfExists("password-confirm", kcProps.kcFormGroupErrorClass)
|
124
|
+
)}
|
125
|
+
>
|
126
|
+
<div className={cx(kcProps.kcLabelWrapperClass)}>
|
127
|
+
<label htmlFor="password-confirm" className={cx(kcProps.kcLabelClass)}>
|
128
|
+
{msg("passwordConfirm")}
|
129
|
+
</label>
|
130
130
|
</div>
|
131
|
-
|
132
|
-
|
133
|
-
{recaptchaRequired && (
|
134
|
-
<div className="form-group">
|
135
|
-
<div className={cx(props.kcInputWrapperClass)}>
|
136
|
-
<div className="g-recaptcha" data-size="compact" data-sitekey={recaptchaSiteKey}></div>
|
131
|
+
<div className={cx(kcProps.kcInputWrapperClass)}>
|
132
|
+
<input type="password" id="password-confirm" className={cx(kcProps.kcInputClass)} name="password-confirm" />
|
137
133
|
</div>
|
138
134
|
</div>
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
</span>
|
146
|
-
</div>
|
135
|
+
</>
|
136
|
+
)}
|
137
|
+
{recaptchaRequired && (
|
138
|
+
<div className="form-group">
|
139
|
+
<div className={cx(kcProps.kcInputWrapperClass)}>
|
140
|
+
<div className="g-recaptcha" data-size="compact" data-sitekey={recaptchaSiteKey}></div>
|
147
141
|
</div>
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
)}
|
157
|
-
type="submit"
|
158
|
-
value={msgStr("doRegister")}
|
159
|
-
/>
|
142
|
+
</div>
|
143
|
+
)}
|
144
|
+
<div className={cx(kcProps.kcFormGroupClass)}>
|
145
|
+
<div id="kc-form-options" className={cx(kcProps.kcFormOptionsClass)}>
|
146
|
+
<div className={cx(kcProps.kcFormOptionsWrapperClass)}>
|
147
|
+
<span>
|
148
|
+
<a href={url.loginUrl}>{msg("backToLogin")}</a>
|
149
|
+
</span>
|
160
150
|
</div>
|
161
151
|
</div>
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
152
|
+
|
153
|
+
<div id="kc-form-buttons" className={cx(kcProps.kcFormButtonsClass)}>
|
154
|
+
<input
|
155
|
+
className={cx(
|
156
|
+
kcProps.kcButtonClass,
|
157
|
+
kcProps.kcButtonPrimaryClass,
|
158
|
+
kcProps.kcButtonBlockClass,
|
159
|
+
kcProps.kcButtonLargeClass
|
160
|
+
)}
|
161
|
+
type="submit"
|
162
|
+
value={msgStr("doRegister")}
|
163
|
+
/>
|
164
|
+
</div>
|
165
|
+
</div>
|
166
|
+
</form>
|
167
|
+
}
|
168
|
+
/>
|
169
|
+
);
|
170
|
+
});
|
168
171
|
|
169
172
|
export default Register;
|
@@ -1,78 +1,81 @@
|
|
1
1
|
import React, { useMemo, memo, useState } from "react";
|
2
|
-
import
|
2
|
+
import DefaultTemplate from "./Template";
|
3
|
+
import type { TemplateProps } from "./Template";
|
3
4
|
import type { KcProps } from "./KcProps";
|
4
5
|
import type { KcContextBase } from "../getKcContext/KcContextBase";
|
5
6
|
import { useCssAndCx } from "../tools/useCssAndCx";
|
6
7
|
import type { I18n } from "../i18n";
|
7
8
|
import { UserProfileFormFields } from "./shared/UserProfileCommons";
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
}: { kcContext: KcContextBase.RegisterUserProfile; i18n: I18n; doFetchDefaultThemeResources?: boolean } & KcProps) => {
|
16
|
-
const { url, messagesPerField, recaptchaRequired, recaptchaSiteKey } = kcContext;
|
10
|
+
export type RegisterUserProfileProps = KcProps & {
|
11
|
+
kcContext: KcContextBase.RegisterUserProfile;
|
12
|
+
i18n: I18n;
|
13
|
+
doFetchDefaultThemeResources?: boolean;
|
14
|
+
Template?: (props: TemplateProps) => JSX.Element | null;
|
15
|
+
};
|
17
16
|
|
18
|
-
|
17
|
+
const RegisterUserProfile = memo((props: RegisterUserProfileProps) => {
|
18
|
+
const { kcContext, i18n, doFetchDefaultThemeResources = true, Template = DefaultTemplate, ...kcProps_ } = props;
|
19
19
|
|
20
|
-
|
20
|
+
const { url, messagesPerField, recaptchaRequired, recaptchaSiteKey } = kcContext;
|
21
21
|
|
22
|
-
|
23
|
-
() => ({
|
24
|
-
...props_,
|
25
|
-
"kcFormGroupClass": cx(props_.kcFormGroupClass, css({ "marginBottom": 20 }))
|
26
|
-
}),
|
27
|
-
[cx, css]
|
28
|
-
);
|
22
|
+
const { msg, msgStr } = i18n;
|
29
23
|
|
30
|
-
|
24
|
+
const { cx, css } = useCssAndCx();
|
31
25
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
26
|
+
const kcProps = useMemo(
|
27
|
+
() => ({
|
28
|
+
...kcProps_,
|
29
|
+
"kcFormGroupClass": cx(kcProps_.kcFormGroupClass, css({ "marginBottom": 20 }))
|
30
|
+
}),
|
31
|
+
[cx, css]
|
32
|
+
);
|
33
|
+
|
34
|
+
const [isFomSubmittable, setIsFomSubmittable] = useState(false);
|
35
|
+
|
36
|
+
return (
|
37
|
+
<Template
|
38
|
+
{...{ kcContext, i18n, doFetchDefaultThemeResources, ...kcProps }}
|
39
|
+
displayMessage={messagesPerField.exists("global")}
|
40
|
+
displayRequiredFields={true}
|
41
|
+
headerNode={msg("registerTitle")}
|
42
|
+
formNode={
|
43
|
+
<form id="kc-register-form" className={cx(kcProps.kcFormClass)} action={url.registrationAction} method="post">
|
44
|
+
<UserProfileFormFields kcContext={kcContext} onIsFormSubmittableValueChange={setIsFomSubmittable} i18n={i18n} {...kcProps} />
|
45
|
+
{recaptchaRequired && (
|
46
|
+
<div className="form-group">
|
47
|
+
<div className={cx(kcProps.kcInputWrapperClass)}>
|
48
|
+
<div className="g-recaptcha" data-size="compact" data-sitekey={recaptchaSiteKey} />
|
46
49
|
</div>
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
</
|
54
|
-
</
|
50
|
+
</div>
|
51
|
+
)}
|
52
|
+
<div className={cx(kcProps.kcFormGroupClass)}>
|
53
|
+
<div id="kc-form-options" className={cx(kcProps.kcFormOptionsClass)}>
|
54
|
+
<div className={cx(kcProps.kcFormOptionsWrapperClass)}>
|
55
|
+
<span>
|
56
|
+
<a href={url.loginUrl}>{msg("backToLogin")}</a>
|
57
|
+
</span>
|
55
58
|
</div>
|
59
|
+
</div>
|
56
60
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
</div>
|
61
|
+
<div id="kc-form-buttons" className={cx(kcProps.kcFormButtonsClass)}>
|
62
|
+
<input
|
63
|
+
className={cx(
|
64
|
+
kcProps.kcButtonClass,
|
65
|
+
kcProps.kcButtonPrimaryClass,
|
66
|
+
kcProps.kcButtonBlockClass,
|
67
|
+
kcProps.kcButtonLargeClass
|
68
|
+
)}
|
69
|
+
type="submit"
|
70
|
+
value={msgStr("doRegister")}
|
71
|
+
disabled={!isFomSubmittable}
|
72
|
+
/>
|
70
73
|
</div>
|
71
|
-
</
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
);
|
74
|
+
</div>
|
75
|
+
</form>
|
76
|
+
}
|
77
|
+
/>
|
78
|
+
);
|
79
|
+
});
|
77
80
|
|
78
81
|
export default RegisterUserProfile;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import React, { useEffect, memo } from "react";
|
2
|
-
import
|
2
|
+
import DefaultTemplate from "./Template";
|
3
|
+
import type { TemplateProps } from "./Template";
|
3
4
|
import type { KcProps } from "./KcProps";
|
4
5
|
import type { KcContextBase } from "../getKcContext/KcContextBase";
|
5
6
|
import { useCssAndCx } from "../tools/useCssAndCx";
|
@@ -12,6 +13,7 @@ import memoize from "memoizee";
|
|
12
13
|
import { useConst } from "powerhooks/useConst";
|
13
14
|
import { useConstCallback } from "powerhooks/useConstCallback";
|
14
15
|
import { Markdown } from "../tools/Markdown";
|
16
|
+
import type { Extends } from "tsafe";
|
15
17
|
|
16
18
|
export const evtTermMarkdown = Evt.create<string | undefined>(undefined);
|
17
19
|
|
@@ -22,7 +24,7 @@ export type KcContextLike = {
|
|
22
24
|
};
|
23
25
|
};
|
24
26
|
|
25
|
-
assert<KcContextBase
|
27
|
+
assert<Extends<KcContextBase, KcContextLike>>();
|
26
28
|
|
27
29
|
/** Allow to avoid bundling the terms and download it on demand*/
|
28
30
|
export function useDownloadTerms(params: {
|
@@ -54,61 +56,63 @@ export function useDownloadTerms(params: {
|
|
54
56
|
}, []);
|
55
57
|
}
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
}: { kcContext: KcContextBase.Terms; i18n: I18n; doFetchDefaultThemeResources?: boolean } & KcProps) => {
|
64
|
-
const { msg, msgStr } = i18n;
|
59
|
+
export type TermsProps = KcProps & {
|
60
|
+
kcContext: KcContextBase.Terms;
|
61
|
+
i18n: I18n;
|
62
|
+
doFetchDefaultThemeResources?: boolean;
|
63
|
+
Template?: (props: TemplateProps) => JSX.Element | null;
|
64
|
+
};
|
65
65
|
|
66
|
-
|
66
|
+
const Terms = memo((props: TermsProps) => {
|
67
|
+
const { kcContext, i18n, doFetchDefaultThemeResources = true, Template = DefaultTemplate, ...kcProps } = props;
|
67
68
|
|
68
|
-
|
69
|
+
const { msg, msgStr } = i18n;
|
69
70
|
|
70
|
-
|
71
|
+
useRerenderOnStateChange(evtTermMarkdown);
|
71
72
|
|
72
|
-
|
73
|
-
return null;
|
74
|
-
}
|
73
|
+
const { cx } = useCssAndCx();
|
75
74
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
headerNode={msg("termsTitle")}
|
81
|
-
formNode={
|
82
|
-
<>
|
83
|
-
<div id="kc-terms-text">{evtTermMarkdown.state && <Markdown>{evtTermMarkdown.state}</Markdown>}</div>
|
84
|
-
<form className="form-actions" action={url.loginAction} method="POST">
|
85
|
-
<input
|
86
|
-
className={cx(
|
87
|
-
props.kcButtonClass,
|
88
|
-
props.kcButtonClass,
|
89
|
-
props.kcButtonClass,
|
90
|
-
props.kcButtonPrimaryClass,
|
91
|
-
props.kcButtonLargeClass
|
92
|
-
)}
|
93
|
-
name="accept"
|
94
|
-
id="kc-accept"
|
95
|
-
type="submit"
|
96
|
-
value={msgStr("doAccept")}
|
97
|
-
/>
|
98
|
-
<input
|
99
|
-
className={cx(props.kcButtonClass, props.kcButtonDefaultClass, props.kcButtonLargeClass)}
|
100
|
-
name="cancel"
|
101
|
-
id="kc-decline"
|
102
|
-
type="submit"
|
103
|
-
value={msgStr("doDecline")}
|
104
|
-
/>
|
105
|
-
</form>
|
106
|
-
<div className="clearfix" />
|
107
|
-
</>
|
108
|
-
}
|
109
|
-
/>
|
110
|
-
);
|
75
|
+
const { url } = kcContext;
|
76
|
+
|
77
|
+
if (evtTermMarkdown.state === undefined) {
|
78
|
+
return null;
|
111
79
|
}
|
112
|
-
|
80
|
+
|
81
|
+
return (
|
82
|
+
<Template
|
83
|
+
{...{ kcContext, i18n, doFetchDefaultThemeResources, ...kcProps }}
|
84
|
+
displayMessage={false}
|
85
|
+
headerNode={msg("termsTitle")}
|
86
|
+
formNode={
|
87
|
+
<>
|
88
|
+
<div id="kc-terms-text">{evtTermMarkdown.state && <Markdown>{evtTermMarkdown.state}</Markdown>}</div>
|
89
|
+
<form className="form-actions" action={url.loginAction} method="POST">
|
90
|
+
<input
|
91
|
+
className={cx(
|
92
|
+
kcProps.kcButtonClass,
|
93
|
+
kcProps.kcButtonClass,
|
94
|
+
kcProps.kcButtonClass,
|
95
|
+
kcProps.kcButtonPrimaryClass,
|
96
|
+
kcProps.kcButtonLargeClass
|
97
|
+
)}
|
98
|
+
name="accept"
|
99
|
+
id="kc-accept"
|
100
|
+
type="submit"
|
101
|
+
value={msgStr("doAccept")}
|
102
|
+
/>
|
103
|
+
<input
|
104
|
+
className={cx(kcProps.kcButtonClass, kcProps.kcButtonDefaultClass, kcProps.kcButtonLargeClass)}
|
105
|
+
name="cancel"
|
106
|
+
id="kc-decline"
|
107
|
+
type="submit"
|
108
|
+
value={msgStr("doDecline")}
|
109
|
+
/>
|
110
|
+
</form>
|
111
|
+
<div className="clearfix" />
|
112
|
+
</>
|
113
|
+
}
|
114
|
+
/>
|
115
|
+
);
|
116
|
+
});
|
113
117
|
|
114
118
|
export default Terms;
|