@ttoss/react-auth 1.4.6 → 1.5.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/LICENSE +674 -0
- package/dist/esm/index.js +147 -88
- package/dist/index.js +146 -87
- package/package.json +23 -24
- package/src/AuthCard.tsx +51 -39
- package/src/AuthConfirmSignUp.tsx +1 -0
- package/src/AuthSignIn.tsx +61 -32
- package/src/AuthSignUp.tsx +9 -7
- package/src/useHidePassInput.ts +26 -0
package/dist/index.js
CHANGED
|
@@ -120,7 +120,7 @@ var useAuth = () => {
|
|
|
120
120
|
};
|
|
121
121
|
|
|
122
122
|
// src/Auth.tsx
|
|
123
|
-
var
|
|
123
|
+
var React4 = __toESM(require("react"));
|
|
124
124
|
var import_aws_amplify2 = require("aws-amplify");
|
|
125
125
|
|
|
126
126
|
// src/AuthCard.tsx
|
|
@@ -142,7 +142,8 @@ var AuthCard = ({
|
|
|
142
142
|
children,
|
|
143
143
|
title,
|
|
144
144
|
buttonLabel,
|
|
145
|
-
|
|
145
|
+
extraButton,
|
|
146
|
+
isValidForm
|
|
146
147
|
}) => {
|
|
147
148
|
const {
|
|
148
149
|
logo
|
|
@@ -150,59 +151,54 @@ var AuthCard = ({
|
|
|
150
151
|
const {
|
|
151
152
|
isLoading
|
|
152
153
|
} = (0, import_react_notifications.useNotifications)();
|
|
153
|
-
return /* @__PURE__ */(0, import_jsx_runtime2.
|
|
154
|
+
return /* @__PURE__ */(0, import_jsx_runtime2.jsxs)(import_ui.Box, {
|
|
154
155
|
sx: {
|
|
155
|
-
maxWidth: "
|
|
156
|
+
maxWidth: "390px",
|
|
157
|
+
border: "default",
|
|
158
|
+
borderColor: "primary",
|
|
159
|
+
paddingX: "2xl",
|
|
160
|
+
paddingY: "3xl",
|
|
161
|
+
backgroundColor: "surface"
|
|
156
162
|
},
|
|
157
|
-
children: /* @__PURE__ */(0, import_jsx_runtime2.
|
|
163
|
+
children: [logo && /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_ui.Flex, {
|
|
158
164
|
sx: {
|
|
159
|
-
|
|
160
|
-
|
|
165
|
+
width: "100%",
|
|
166
|
+
maxHeight: "90px",
|
|
167
|
+
justifyContent: "center",
|
|
168
|
+
marginBottom: "2xl"
|
|
161
169
|
},
|
|
162
|
-
children:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
170
|
+
children: logo
|
|
171
|
+
}), /* @__PURE__ */(0, import_jsx_runtime2.jsxs)(import_ui.Flex, {
|
|
172
|
+
sx: {
|
|
173
|
+
flexDirection: "column"
|
|
174
|
+
},
|
|
175
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_ui.Heading, {
|
|
176
|
+
as: "h2",
|
|
177
|
+
variant: "h2",
|
|
169
178
|
sx: {
|
|
170
|
-
|
|
171
|
-
marginY: "md",
|
|
172
|
-
fontSize: "xl"
|
|
179
|
+
marginBottom: "2xl"
|
|
173
180
|
},
|
|
174
181
|
children: title
|
|
175
|
-
}), children, /* @__PURE__ */(0, import_jsx_runtime2.
|
|
182
|
+
}), children, /* @__PURE__ */(0, import_jsx_runtime2.jsxs)(import_ui.Flex, {
|
|
176
183
|
sx: {
|
|
177
|
-
|
|
178
|
-
|
|
184
|
+
flexDirection: "column",
|
|
185
|
+
width: "100%",
|
|
186
|
+
gap: "xl",
|
|
187
|
+
marginTop: "2xl"
|
|
179
188
|
},
|
|
180
|
-
children: /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_ui.Button, {
|
|
189
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_ui.Button, {
|
|
181
190
|
type: "submit",
|
|
182
|
-
"aria-label": "submit-
|
|
183
|
-
variant: "
|
|
184
|
-
disabled: isLoading,
|
|
191
|
+
"aria-label": "submit-button",
|
|
192
|
+
variant: "accent",
|
|
193
|
+
disabled: isLoading || !isValidForm,
|
|
185
194
|
sx: {
|
|
186
|
-
|
|
195
|
+
textAlign: "center",
|
|
196
|
+
display: "initial"
|
|
187
197
|
},
|
|
188
198
|
children: buttonLabel
|
|
189
|
-
})
|
|
190
|
-
}), /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_ui.Flex, {
|
|
191
|
-
sx: {
|
|
192
|
-
justifyContent: "space-between",
|
|
193
|
-
flexDirection: "column",
|
|
194
|
-
gap: "sm",
|
|
195
|
-
marginTop: "md",
|
|
196
|
-
color: "text"
|
|
197
|
-
},
|
|
198
|
-
children: links.map(link => {
|
|
199
|
-
return link && /* @__PURE__ */(0, import_jsx_runtime2.jsx)(import_ui.Link, {
|
|
200
|
-
onClick: link.onClick,
|
|
201
|
-
children: link.label
|
|
202
|
-
}, link.label);
|
|
203
|
-
})
|
|
199
|
+
}), extraButton]
|
|
204
200
|
})]
|
|
205
|
-
})
|
|
201
|
+
})]
|
|
206
202
|
});
|
|
207
203
|
};
|
|
208
204
|
|
|
@@ -261,6 +257,7 @@ var AuthConfirmSignUp = ({
|
|
|
261
257
|
"value": "Confirm"
|
|
262
258
|
}]
|
|
263
259
|
}),
|
|
260
|
+
isValidForm: formMethods.formState.isValid,
|
|
264
261
|
title: intl.formatMessage({
|
|
265
262
|
id: "cGR2eI",
|
|
266
263
|
defaultMessage: [{
|
|
@@ -304,6 +301,7 @@ var AuthFullScreen = ({
|
|
|
304
301
|
};
|
|
305
302
|
|
|
306
303
|
// src/AuthSignIn.tsx
|
|
304
|
+
var import_ui3 = require("@ttoss/ui");
|
|
307
305
|
var import_forms2 = require("@ttoss/forms");
|
|
308
306
|
|
|
309
307
|
// ../cloud-auth/dist/esm/index.js
|
|
@@ -549,17 +547,48 @@ createAuthTemplate.CognitoUserPoolLogicalId = CognitoUserPoolLogicalId;
|
|
|
549
547
|
createAuthTemplate.CognitoUserPoolClientLogicalId = CognitoUserPoolClientLogicalId;
|
|
550
548
|
createAuthTemplate.CognitoIdentityPoolLogicalId = CognitoIdentityPoolLogicalId;
|
|
551
549
|
|
|
550
|
+
// src/useHidePassInput.ts
|
|
551
|
+
var React3 = __toESM(require("react"));
|
|
552
|
+
var useHidePassInput = (defaultValue = true) => {
|
|
553
|
+
const [hidePass, setHidePass] = React3.useState(Boolean(defaultValue));
|
|
554
|
+
const {
|
|
555
|
+
icon,
|
|
556
|
+
inputType
|
|
557
|
+
} = React3.useMemo(() => {
|
|
558
|
+
return {
|
|
559
|
+
icon: hidePass ? "view-off" : "view-on",
|
|
560
|
+
inputType: hidePass ? "password" : "text"
|
|
561
|
+
};
|
|
562
|
+
}, [hidePass]);
|
|
563
|
+
const handleClick = () => {
|
|
564
|
+
setHidePass(prev => {
|
|
565
|
+
return !prev;
|
|
566
|
+
});
|
|
567
|
+
};
|
|
568
|
+
return {
|
|
569
|
+
handleClick,
|
|
570
|
+
icon,
|
|
571
|
+
inputType
|
|
572
|
+
};
|
|
573
|
+
};
|
|
574
|
+
|
|
552
575
|
// src/AuthSignIn.tsx
|
|
553
576
|
var import_react_i18n2 = require("@ttoss/react-i18n");
|
|
554
577
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
555
578
|
var AuthSignIn = ({
|
|
556
579
|
onSignIn,
|
|
557
580
|
onSignUp,
|
|
558
|
-
defaultValues
|
|
581
|
+
defaultValues,
|
|
582
|
+
onForgotPassword
|
|
559
583
|
}) => {
|
|
560
584
|
const {
|
|
561
585
|
intl
|
|
562
586
|
} = (0, import_react_i18n2.useI18n)();
|
|
587
|
+
const {
|
|
588
|
+
handleClick,
|
|
589
|
+
icon,
|
|
590
|
+
inputType
|
|
591
|
+
} = useHidePassInput();
|
|
563
592
|
const schema = import_forms2.yup.object().shape({
|
|
564
593
|
email: import_forms2.yup.string().required(intl.formatMessage({
|
|
565
594
|
id: "r+QgO+",
|
|
@@ -595,7 +624,9 @@ var AuthSignIn = ({
|
|
|
595
624
|
}, {
|
|
596
625
|
value: PASSWORD_MINIMUM_LENGTH
|
|
597
626
|
})).trim()
|
|
627
|
+
// remember: yup.boolean(),
|
|
598
628
|
});
|
|
629
|
+
|
|
599
630
|
const formMethods = (0, import_forms2.useForm)({
|
|
600
631
|
defaultValues,
|
|
601
632
|
resolver: (0, import_forms2.yupResolver)(schema)
|
|
@@ -608,55 +639,79 @@ var AuthSignIn = ({
|
|
|
608
639
|
onSubmit: onSubmitForm,
|
|
609
640
|
children: /* @__PURE__ */(0, import_jsx_runtime5.jsxs)(AuthCard, {
|
|
610
641
|
title: intl.formatMessage({
|
|
611
|
-
id: "
|
|
642
|
+
id: "F2iS37",
|
|
612
643
|
defaultMessage: [{
|
|
613
644
|
"type": 0,
|
|
614
|
-
"value": "
|
|
645
|
+
"value": "Log in"
|
|
615
646
|
}]
|
|
616
647
|
}),
|
|
617
648
|
buttonLabel: intl.formatMessage({
|
|
618
|
-
id: "
|
|
649
|
+
id: "/J+02x",
|
|
619
650
|
defaultMessage: [{
|
|
620
651
|
"type": 0,
|
|
621
|
-
"value": "
|
|
652
|
+
"value": "Log in"
|
|
622
653
|
}]
|
|
623
654
|
}),
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
})
|
|
633
|
-
}, {
|
|
655
|
+
isValidForm: formMethods.formState.isValid,
|
|
656
|
+
extraButton: /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_ui3.Button, {
|
|
657
|
+
type: "button",
|
|
658
|
+
variant: "secondary",
|
|
659
|
+
sx: {
|
|
660
|
+
textAlign: "center",
|
|
661
|
+
display: "initial"
|
|
662
|
+
},
|
|
634
663
|
onClick: onSignUp,
|
|
635
|
-
label:
|
|
636
|
-
|
|
664
|
+
"aria-label": "sign-up",
|
|
665
|
+
children: intl.formatMessage({
|
|
666
|
+
id: "EZ3YF2",
|
|
637
667
|
defaultMessage: [{
|
|
638
668
|
"type": 0,
|
|
639
|
-
"value": "
|
|
669
|
+
"value": "Sign up"
|
|
640
670
|
}]
|
|
641
671
|
})
|
|
642
|
-
}
|
|
643
|
-
children: [/* @__PURE__ */(0, import_jsx_runtime5.
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
672
|
+
}),
|
|
673
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime5.jsxs)(import_ui3.Flex, {
|
|
674
|
+
sx: {
|
|
675
|
+
flexDirection: "column",
|
|
676
|
+
gap: "xl"
|
|
677
|
+
},
|
|
678
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_forms2.FormFieldInput, {
|
|
679
|
+
name: "email",
|
|
680
|
+
label: intl.formatMessage({
|
|
681
|
+
id: "5E12mO",
|
|
682
|
+
defaultMessage: [{
|
|
683
|
+
"type": 0,
|
|
684
|
+
"value": "Email"
|
|
685
|
+
}]
|
|
686
|
+
})
|
|
687
|
+
}), /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_forms2.FormFieldInput, {
|
|
688
|
+
name: "password",
|
|
689
|
+
trailingIcon: icon,
|
|
690
|
+
onTrailingIconClick: handleClick,
|
|
691
|
+
type: inputType,
|
|
692
|
+
label: intl.formatMessage({
|
|
693
|
+
id: "PylVqx",
|
|
694
|
+
defaultMessage: [{
|
|
695
|
+
"type": 0,
|
|
696
|
+
"value": "Password"
|
|
697
|
+
}]
|
|
698
|
+
})
|
|
699
|
+
})]
|
|
700
|
+
}), /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_ui3.Flex, {
|
|
701
|
+
sx: {
|
|
702
|
+
justifyContent: "space-between",
|
|
703
|
+
marginTop: "lg"
|
|
704
|
+
},
|
|
705
|
+
children: /* @__PURE__ */(0, import_jsx_runtime5.jsx)(import_ui3.Text, {
|
|
706
|
+
as: import_ui3.Link,
|
|
707
|
+
onClick: onForgotPassword,
|
|
708
|
+
children: intl.formatMessage({
|
|
709
|
+
id: "BtK6KR",
|
|
710
|
+
defaultMessage: [{
|
|
711
|
+
"type": 0,
|
|
712
|
+
"value": "Forgot password?"
|
|
713
|
+
}]
|
|
714
|
+
})
|
|
660
715
|
})
|
|
661
716
|
})]
|
|
662
717
|
})
|
|
@@ -665,6 +720,7 @@ var AuthSignIn = ({
|
|
|
665
720
|
|
|
666
721
|
// src/AuthSignUp.tsx
|
|
667
722
|
var import_forms3 = require("@ttoss/forms");
|
|
723
|
+
var import_ui4 = require("@ttoss/ui");
|
|
668
724
|
var import_react_i18n3 = require("@ttoss/react-i18n");
|
|
669
725
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
670
726
|
var AuthSignUp = ({
|
|
@@ -734,16 +790,18 @@ var AuthSignUp = ({
|
|
|
734
790
|
"value": "Register"
|
|
735
791
|
}]
|
|
736
792
|
}),
|
|
737
|
-
|
|
738
|
-
|
|
793
|
+
isValidForm: formMethods.formState.isValid,
|
|
794
|
+
extraButton: /* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_ui4.Text, {
|
|
795
|
+
onClick: onReturnToSignIn,
|
|
796
|
+
as: import_ui4.Link,
|
|
797
|
+
children: intl.formatMessage({
|
|
739
798
|
id: "LU2ddR",
|
|
740
799
|
defaultMessage: [{
|
|
741
800
|
"type": 0,
|
|
742
801
|
"value": "Do you already have an account? Sign in"
|
|
743
802
|
}]
|
|
744
|
-
})
|
|
745
|
-
|
|
746
|
-
}],
|
|
803
|
+
})
|
|
804
|
+
}),
|
|
747
805
|
children: [/* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_forms3.FormFieldInput, {
|
|
748
806
|
name: "email",
|
|
749
807
|
label: intl.formatMessage({
|
|
@@ -755,6 +813,7 @@ var AuthSignUp = ({
|
|
|
755
813
|
})
|
|
756
814
|
}), /* @__PURE__ */(0, import_jsx_runtime6.jsx)(import_forms3.FormFieldInput, {
|
|
757
815
|
name: "password",
|
|
816
|
+
type: "password",
|
|
758
817
|
label: intl.formatMessage({
|
|
759
818
|
id: "PylVqx",
|
|
760
819
|
defaultMessage: [{
|
|
@@ -824,7 +883,7 @@ var AuthLogic = () => {
|
|
|
824
883
|
const {
|
|
825
884
|
setLoading
|
|
826
885
|
} = (0, import_react_notifications2.useNotifications)();
|
|
827
|
-
const onSignIn =
|
|
886
|
+
const onSignIn = React4.useCallback(async ({
|
|
828
887
|
email,
|
|
829
888
|
password
|
|
830
889
|
}) => {
|
|
@@ -846,7 +905,7 @@ var AuthLogic = () => {
|
|
|
846
905
|
setLoading(false);
|
|
847
906
|
}
|
|
848
907
|
}, [send, setLoading]);
|
|
849
|
-
const onSignUp =
|
|
908
|
+
const onSignUp = React4.useCallback(async ({
|
|
850
909
|
email,
|
|
851
910
|
password
|
|
852
911
|
}) => {
|
|
@@ -867,7 +926,7 @@ var AuthLogic = () => {
|
|
|
867
926
|
setLoading(false);
|
|
868
927
|
}
|
|
869
928
|
}, [send, setLoading]);
|
|
870
|
-
const onConfirmSignUp =
|
|
929
|
+
const onConfirmSignUp = React4.useCallback(async ({
|
|
871
930
|
email,
|
|
872
931
|
code
|
|
873
932
|
}) => {
|
|
@@ -882,7 +941,7 @@ var AuthLogic = () => {
|
|
|
882
941
|
setLoading(false);
|
|
883
942
|
}
|
|
884
943
|
}, [send, setLoading]);
|
|
885
|
-
const onReturnToSignIn =
|
|
944
|
+
const onReturnToSignIn = React4.useCallback(() => {
|
|
886
945
|
send({
|
|
887
946
|
type: "RETURN_TO_SIGN_IN"
|
|
888
947
|
});
|
|
@@ -916,7 +975,7 @@ var Auth2 = ({
|
|
|
916
975
|
logo,
|
|
917
976
|
fullScreen = true
|
|
918
977
|
}) => {
|
|
919
|
-
const withLogoNode =
|
|
978
|
+
const withLogoNode = React4.useMemo(() => {
|
|
920
979
|
return /* @__PURE__ */(0, import_jsx_runtime7.jsx)(LogoProvider, {
|
|
921
980
|
logo,
|
|
922
981
|
children: /* @__PURE__ */(0, import_jsx_runtime7.jsx)(AuthLogic, {})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/react-auth",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "ttoss authentication module for React apps.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -14,38 +14,32 @@
|
|
|
14
14
|
"i18n",
|
|
15
15
|
"src"
|
|
16
16
|
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"prebuild": "pnpm i18n",
|
|
19
|
-
"build": "tsup",
|
|
20
|
-
"i18n": "ttoss-i18n --no-compile",
|
|
21
|
-
"test": "jest"
|
|
22
|
-
},
|
|
23
17
|
"sideEffects": false,
|
|
24
18
|
"typings": "./dist/index.d.ts",
|
|
25
19
|
"dependencies": {
|
|
26
|
-
"@ttoss/forms": "^0.16.6",
|
|
27
20
|
"@xstate/react": "^3.2.2",
|
|
28
|
-
"xstate": "^4.37.2"
|
|
21
|
+
"xstate": "^4.37.2",
|
|
22
|
+
"@ttoss/forms": "^0.17.1"
|
|
29
23
|
},
|
|
30
24
|
"peerDependencies": {
|
|
31
|
-
"@ttoss/react-i18n": "^",
|
|
32
|
-
"@ttoss/react-notifications": "^",
|
|
33
|
-
"@ttoss/ui": "^",
|
|
34
25
|
"aws-amplify": "^5.0.0",
|
|
35
|
-
"react": ">=16.8.0"
|
|
26
|
+
"react": ">=16.8.0",
|
|
27
|
+
"@ttoss/react-i18n": "^1.22.0",
|
|
28
|
+
"@ttoss/react-notifications": "^1.22.1",
|
|
29
|
+
"@ttoss/ui": "^1.36.1"
|
|
36
30
|
},
|
|
37
31
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@ttoss/config": "^1.30.0",
|
|
40
|
-
"@ttoss/i18n-cli": "^0.5.0",
|
|
41
|
-
"@ttoss/react-i18n": "^1.21.0",
|
|
42
|
-
"@ttoss/react-notifications": "^1.21.3",
|
|
43
|
-
"@ttoss/test-utils": "^1.22.0",
|
|
44
|
-
"@ttoss/ui": "^1.35.3",
|
|
45
|
-
"@types/react": "^18.2.0",
|
|
32
|
+
"@types/react": "^18.2.5",
|
|
46
33
|
"aws-amplify": "^5.0.25",
|
|
47
34
|
"jest": "^29.5.0",
|
|
48
|
-
"tsup": "^6.7.0"
|
|
35
|
+
"tsup": "^6.7.0",
|
|
36
|
+
"@ttoss/cloud-auth": "^0.9.1",
|
|
37
|
+
"@ttoss/config": "^1.30.0",
|
|
38
|
+
"@ttoss/i18n-cli": "^0.5.0",
|
|
39
|
+
"@ttoss/react-i18n": "^1.22.0",
|
|
40
|
+
"@ttoss/react-notifications": "^1.22.1",
|
|
41
|
+
"@ttoss/test-utils": "^1.23.0",
|
|
42
|
+
"@ttoss/ui": "^1.36.1"
|
|
49
43
|
},
|
|
50
44
|
"keywords": [
|
|
51
45
|
"React",
|
|
@@ -54,5 +48,10 @@
|
|
|
54
48
|
"publishConfig": {
|
|
55
49
|
"access": "public"
|
|
56
50
|
},
|
|
57
|
-
"
|
|
58
|
-
|
|
51
|
+
"scripts": {
|
|
52
|
+
"prebuild": "pnpm i18n",
|
|
53
|
+
"build": "tsup",
|
|
54
|
+
"i18n": "ttoss-i18n --no-compile",
|
|
55
|
+
"test": "jest"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/AuthCard.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Box, Button, Flex,
|
|
2
|
+
import { Box, Button, Flex, Heading } from '@ttoss/ui';
|
|
3
3
|
import { useNotifications } from '@ttoss/react-notifications';
|
|
4
4
|
|
|
5
5
|
export type LogoContextProps = {
|
|
@@ -13,68 +13,80 @@ export const LogoProvider = ({ children, ...values }: LogoContextProps) => {
|
|
|
13
13
|
return <LogoContext.Provider value={values}>{children}</LogoContext.Provider>;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
type LinkProps = {
|
|
17
|
-
label: string;
|
|
18
|
-
onClick: () => void;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
16
|
type AuthCardProps = {
|
|
22
17
|
children: React.ReactNode;
|
|
23
18
|
title: string;
|
|
24
19
|
buttonLabel: string;
|
|
25
|
-
|
|
20
|
+
extraButton?: React.ReactNode;
|
|
21
|
+
isValidForm?: boolean;
|
|
26
22
|
};
|
|
27
23
|
|
|
28
24
|
export const AuthCard = ({
|
|
29
25
|
children,
|
|
30
26
|
title,
|
|
31
27
|
buttonLabel,
|
|
32
|
-
|
|
28
|
+
extraButton,
|
|
29
|
+
isValidForm,
|
|
33
30
|
}: AuthCardProps) => {
|
|
34
31
|
const { logo } = React.useContext(LogoContext);
|
|
35
32
|
|
|
36
33
|
const { isLoading } = useNotifications();
|
|
37
34
|
|
|
38
35
|
return (
|
|
39
|
-
<Box
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
<Box
|
|
37
|
+
sx={{
|
|
38
|
+
maxWidth: '390px',
|
|
39
|
+
border: 'default',
|
|
40
|
+
borderColor: 'primary',
|
|
41
|
+
paddingX: '2xl',
|
|
42
|
+
paddingY: '3xl',
|
|
43
|
+
backgroundColor: 'surface',
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
{logo && (
|
|
47
|
+
<Flex
|
|
48
|
+
sx={{
|
|
49
|
+
width: '100%',
|
|
50
|
+
maxHeight: '90px',
|
|
51
|
+
justifyContent: 'center',
|
|
52
|
+
marginBottom: '2xl',
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
{logo}
|
|
56
|
+
</Flex>
|
|
57
|
+
)}
|
|
58
|
+
<Flex sx={{ flexDirection: 'column' }}>
|
|
59
|
+
<Heading
|
|
60
|
+
as="h2"
|
|
61
|
+
variant="h2"
|
|
62
|
+
sx={{
|
|
63
|
+
marginBottom: '2xl',
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
45
66
|
{title}
|
|
46
|
-
</
|
|
67
|
+
</Heading>
|
|
68
|
+
|
|
47
69
|
{children}
|
|
48
|
-
<Flex sx={{ justifyContent: 'space-between', marginTop: 'md' }}>
|
|
49
|
-
<Button
|
|
50
|
-
type="submit"
|
|
51
|
-
aria-label="submit-login"
|
|
52
|
-
variant="cta"
|
|
53
|
-
disabled={isLoading}
|
|
54
|
-
sx={{ width: '100%' }}
|
|
55
|
-
>
|
|
56
|
-
{buttonLabel}
|
|
57
|
-
</Button>
|
|
58
|
-
</Flex>
|
|
59
70
|
|
|
60
71
|
<Flex
|
|
61
72
|
sx={{
|
|
62
|
-
justifyContent: 'space-between',
|
|
63
73
|
flexDirection: 'column',
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
width: '100%',
|
|
75
|
+
gap: 'xl',
|
|
76
|
+
marginTop: '2xl',
|
|
67
77
|
}}
|
|
68
78
|
>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
<Button
|
|
80
|
+
type="submit"
|
|
81
|
+
aria-label="submit-button"
|
|
82
|
+
variant="accent"
|
|
83
|
+
disabled={isLoading || !isValidForm}
|
|
84
|
+
sx={{ textAlign: 'center', display: 'initial' }}
|
|
85
|
+
>
|
|
86
|
+
{buttonLabel}
|
|
87
|
+
</Button>
|
|
88
|
+
|
|
89
|
+
{extraButton}
|
|
78
90
|
</Flex>
|
|
79
91
|
</Flex>
|
|
80
92
|
</Box>
|