@ttoss/react-auth 1.1.0 → 1.2.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/esm/index.js +43 -43
- package/dist/index.d.ts +4 -10
- package/dist/index.js +43 -44
- package/i18n/lang/en.json +1 -1
- package/package.json +4 -4
- package/src/Auth.tsx +14 -11
- package/src/{AuthContainer.tsx → AuthFullScreen.tsx} +10 -6
- package/src/index.ts +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -172,6 +172,28 @@ var AuthConfirmSignUp = ({
|
|
|
172
172
|
);
|
|
173
173
|
};
|
|
174
174
|
|
|
175
|
+
// src/AuthFullScreen.tsx
|
|
176
|
+
import { Flex as Flex2 } from "@ttoss/ui";
|
|
177
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
178
|
+
var AuthFullScreen = ({ children }) => {
|
|
179
|
+
return /* @__PURE__ */ jsx4(
|
|
180
|
+
Flex2,
|
|
181
|
+
{
|
|
182
|
+
sx: {
|
|
183
|
+
height: "100vh",
|
|
184
|
+
width: "100vw",
|
|
185
|
+
justifyContent: "center",
|
|
186
|
+
alignItems: "center",
|
|
187
|
+
margin: 0,
|
|
188
|
+
backgroundPosition: "center",
|
|
189
|
+
backgroundRepeat: "no-repeat",
|
|
190
|
+
backgroundSize: "cover"
|
|
191
|
+
},
|
|
192
|
+
children
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
};
|
|
196
|
+
|
|
175
197
|
// src/AuthSignIn.tsx
|
|
176
198
|
import { Form as Form2, FormFieldInput as FormFieldInput2, useForm as useForm2, yup as yup2, yupResolver as yupResolver2 } from "@ttoss/forms";
|
|
177
199
|
|
|
@@ -180,7 +202,7 @@ var PASSWORD_MINIMUM_LENGTH = 8;
|
|
|
180
202
|
|
|
181
203
|
// src/AuthSignIn.tsx
|
|
182
204
|
import { useI18n as useI18n2 } from "@ttoss/react-i18n";
|
|
183
|
-
import { jsx as
|
|
205
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
184
206
|
var AuthSignIn = ({
|
|
185
207
|
onSignIn,
|
|
186
208
|
onSignUp,
|
|
@@ -222,7 +244,7 @@ var AuthSignIn = ({
|
|
|
222
244
|
const onSubmitForm = (data) => {
|
|
223
245
|
return onSignIn(data);
|
|
224
246
|
};
|
|
225
|
-
return /* @__PURE__ */
|
|
247
|
+
return /* @__PURE__ */ jsx5(Form2, { ...formMethods, onSubmit: onSubmitForm, children: /* @__PURE__ */ jsxs2(
|
|
226
248
|
AuthCard,
|
|
227
249
|
{
|
|
228
250
|
title: intl.formatMessage({
|
|
@@ -250,7 +272,7 @@ var AuthSignIn = ({
|
|
|
250
272
|
}
|
|
251
273
|
],
|
|
252
274
|
children: [
|
|
253
|
-
/* @__PURE__ */
|
|
275
|
+
/* @__PURE__ */ jsx5(
|
|
254
276
|
FormFieldInput2,
|
|
255
277
|
{
|
|
256
278
|
name: "email",
|
|
@@ -260,7 +282,7 @@ var AuthSignIn = ({
|
|
|
260
282
|
})
|
|
261
283
|
}
|
|
262
284
|
),
|
|
263
|
-
/* @__PURE__ */
|
|
285
|
+
/* @__PURE__ */ jsx5(
|
|
264
286
|
FormFieldInput2,
|
|
265
287
|
{
|
|
266
288
|
name: "password",
|
|
@@ -278,7 +300,7 @@ var AuthSignIn = ({
|
|
|
278
300
|
// src/AuthSignUp.tsx
|
|
279
301
|
import { Form as Form3, FormFieldInput as FormFieldInput3, useForm as useForm3, yup as yup3, yupResolver as yupResolver3 } from "@ttoss/forms";
|
|
280
302
|
import { useI18n as useI18n3 } from "@ttoss/react-i18n";
|
|
281
|
-
import { jsx as
|
|
303
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
282
304
|
var AuthSignUp = ({ onSignUp, onReturnToSignIn }) => {
|
|
283
305
|
const { intl } = useI18n3();
|
|
284
306
|
const schema = yup3.object().shape({
|
|
@@ -315,7 +337,7 @@ var AuthSignUp = ({ onSignUp, onReturnToSignIn }) => {
|
|
|
315
337
|
const onSubmitForm = (data) => {
|
|
316
338
|
return onSignUp(data);
|
|
317
339
|
};
|
|
318
|
-
return /* @__PURE__ */
|
|
340
|
+
return /* @__PURE__ */ jsx6(Form3, { ...formMethods, onSubmit: onSubmitForm, children: /* @__PURE__ */ jsxs3(
|
|
319
341
|
AuthCard,
|
|
320
342
|
{
|
|
321
343
|
buttonLabel: intl.formatMessage({
|
|
@@ -336,7 +358,7 @@ var AuthSignUp = ({ onSignUp, onReturnToSignIn }) => {
|
|
|
336
358
|
}
|
|
337
359
|
],
|
|
338
360
|
children: [
|
|
339
|
-
/* @__PURE__ */
|
|
361
|
+
/* @__PURE__ */ jsx6(
|
|
340
362
|
FormFieldInput3,
|
|
341
363
|
{
|
|
342
364
|
name: "email",
|
|
@@ -346,7 +368,7 @@ var AuthSignUp = ({ onSignUp, onReturnToSignIn }) => {
|
|
|
346
368
|
})
|
|
347
369
|
}
|
|
348
370
|
),
|
|
349
|
-
/* @__PURE__ */
|
|
371
|
+
/* @__PURE__ */ jsx6(
|
|
350
372
|
FormFieldInput3,
|
|
351
373
|
{
|
|
352
374
|
name: "password",
|
|
@@ -365,7 +387,7 @@ var AuthSignUp = ({ onSignUp, onReturnToSignIn }) => {
|
|
|
365
387
|
import { assign, createMachine } from "xstate";
|
|
366
388
|
import { useMachine } from "@xstate/react";
|
|
367
389
|
import { useNotifications as useNotifications2 } from "@ttoss/react-notifications";
|
|
368
|
-
import { jsx as
|
|
390
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
369
391
|
var authMachine = createMachine(
|
|
370
392
|
{
|
|
371
393
|
predictableActionArguments: true,
|
|
@@ -409,7 +431,7 @@ var authMachine = createMachine(
|
|
|
409
431
|
}
|
|
410
432
|
}
|
|
411
433
|
);
|
|
412
|
-
var
|
|
434
|
+
var AuthLogic = () => {
|
|
413
435
|
const { isAuthenticated } = useAuth();
|
|
414
436
|
const [state, send] = useMachine(authMachine);
|
|
415
437
|
const { setLoading } = useNotifications2();
|
|
@@ -469,10 +491,10 @@ var AuthWithoutLogo = () => {
|
|
|
469
491
|
return null;
|
|
470
492
|
}
|
|
471
493
|
if (state.matches("signUp")) {
|
|
472
|
-
return /* @__PURE__ */
|
|
494
|
+
return /* @__PURE__ */ jsx7(AuthSignUp, { onSignUp, onReturnToSignIn });
|
|
473
495
|
}
|
|
474
496
|
if (state.matches("signUpConfirm")) {
|
|
475
|
-
return /* @__PURE__ */
|
|
497
|
+
return /* @__PURE__ */ jsx7(
|
|
476
498
|
AuthConfirmSignUp,
|
|
477
499
|
{
|
|
478
500
|
onConfirmSignUp,
|
|
@@ -480,7 +502,7 @@ var AuthWithoutLogo = () => {
|
|
|
480
502
|
}
|
|
481
503
|
);
|
|
482
504
|
}
|
|
483
|
-
return /* @__PURE__ */
|
|
505
|
+
return /* @__PURE__ */ jsx7(
|
|
484
506
|
AuthSignIn,
|
|
485
507
|
{
|
|
486
508
|
onSignIn,
|
|
@@ -491,39 +513,17 @@ var AuthWithoutLogo = () => {
|
|
|
491
513
|
}
|
|
492
514
|
);
|
|
493
515
|
};
|
|
494
|
-
var
|
|
495
|
-
const
|
|
496
|
-
return /* @__PURE__ */
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
// src/AuthContainer.tsx
|
|
504
|
-
import { Flex as Flex2 } from "@ttoss/ui";
|
|
505
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
506
|
-
var AuthContainer = ({ sx, ...props }) => {
|
|
507
|
-
return /* @__PURE__ */ jsx7(
|
|
508
|
-
Flex2,
|
|
509
|
-
{
|
|
510
|
-
...props,
|
|
511
|
-
sx: {
|
|
512
|
-
height: "100vh",
|
|
513
|
-
justifyContent: "center",
|
|
514
|
-
alignItems: "center",
|
|
515
|
-
margin: 0,
|
|
516
|
-
backgroundPosition: "center",
|
|
517
|
-
backgroundRepeat: "no-repeat",
|
|
518
|
-
backgroundSize: "cover",
|
|
519
|
-
...sx
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
);
|
|
516
|
+
var Auth2 = ({ logo, fullScreen = true }) => {
|
|
517
|
+
const withLogoNode = React3.useMemo(() => {
|
|
518
|
+
return /* @__PURE__ */ jsx7(LogoProvider, { logo, children: /* @__PURE__ */ jsx7(AuthLogic, {}) });
|
|
519
|
+
}, [logo]);
|
|
520
|
+
if (fullScreen) {
|
|
521
|
+
return /* @__PURE__ */ jsx7(AuthFullScreen, { children: withLogoNode });
|
|
522
|
+
}
|
|
523
|
+
return withLogoNode;
|
|
523
524
|
};
|
|
524
525
|
export {
|
|
525
526
|
Auth2 as Auth,
|
|
526
|
-
AuthContainer,
|
|
527
527
|
AuthProvider_default as AuthProvider,
|
|
528
528
|
useAuth
|
|
529
529
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { FlexProps } from '@ttoss/ui';
|
|
3
2
|
|
|
4
3
|
type User = {
|
|
5
4
|
id: string;
|
|
@@ -26,15 +25,10 @@ type LogoContextProps = {
|
|
|
26
25
|
children?: React.ReactNode;
|
|
27
26
|
};
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
displayName: string;
|
|
28
|
+
type AuthProps = LogoContextProps & {
|
|
29
|
+
fullScreen?: boolean;
|
|
32
30
|
};
|
|
33
|
-
|
|
34
|
-
type AuthContainerProps = FlexProps & {
|
|
35
|
-
backgroundImageUrl?: string;
|
|
36
|
-
};
|
|
37
|
-
declare const AuthContainer: ({ sx, ...props }: AuthContainerProps) => JSX.Element;
|
|
31
|
+
declare const Auth: ({ logo, fullScreen }: AuthProps) => JSX.Element;
|
|
38
32
|
|
|
39
33
|
type OnSignInInput = {
|
|
40
34
|
email: string;
|
|
@@ -51,4 +45,4 @@ type OnConfirmSignUp = (input: {
|
|
|
51
45
|
code: string;
|
|
52
46
|
}) => void;
|
|
53
47
|
|
|
54
|
-
export { Auth,
|
|
48
|
+
export { Auth, AuthProvider, OnConfirmSignUp, OnSignIn, OnSignInInput, OnSignUp, OnSignUpInput, useAuth };
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
28
28
|
var src_exports = {};
|
|
29
29
|
__export(src_exports, {
|
|
30
30
|
Auth: () => Auth2,
|
|
31
|
-
AuthContainer: () => AuthContainer,
|
|
32
31
|
AuthProvider: () => AuthProvider_default,
|
|
33
32
|
useAuth: () => useAuth
|
|
34
33
|
});
|
|
@@ -206,6 +205,28 @@ var AuthConfirmSignUp = ({
|
|
|
206
205
|
);
|
|
207
206
|
};
|
|
208
207
|
|
|
208
|
+
// src/AuthFullScreen.tsx
|
|
209
|
+
var import_ui2 = require("@ttoss/ui");
|
|
210
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
211
|
+
var AuthFullScreen = ({ children }) => {
|
|
212
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
213
|
+
import_ui2.Flex,
|
|
214
|
+
{
|
|
215
|
+
sx: {
|
|
216
|
+
height: "100vh",
|
|
217
|
+
width: "100vw",
|
|
218
|
+
justifyContent: "center",
|
|
219
|
+
alignItems: "center",
|
|
220
|
+
margin: 0,
|
|
221
|
+
backgroundPosition: "center",
|
|
222
|
+
backgroundRepeat: "no-repeat",
|
|
223
|
+
backgroundSize: "cover"
|
|
224
|
+
},
|
|
225
|
+
children
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
};
|
|
229
|
+
|
|
209
230
|
// src/AuthSignIn.tsx
|
|
210
231
|
var import_forms2 = require("@ttoss/forms");
|
|
211
232
|
|
|
@@ -214,7 +235,7 @@ var PASSWORD_MINIMUM_LENGTH = 8;
|
|
|
214
235
|
|
|
215
236
|
// src/AuthSignIn.tsx
|
|
216
237
|
var import_react_i18n2 = require("@ttoss/react-i18n");
|
|
217
|
-
var
|
|
238
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
218
239
|
var AuthSignIn = ({
|
|
219
240
|
onSignIn,
|
|
220
241
|
onSignUp,
|
|
@@ -256,7 +277,7 @@ var AuthSignIn = ({
|
|
|
256
277
|
const onSubmitForm = (data) => {
|
|
257
278
|
return onSignIn(data);
|
|
258
279
|
};
|
|
259
|
-
return /* @__PURE__ */ (0,
|
|
280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_forms2.Form, { ...formMethods, onSubmit: onSubmitForm, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
260
281
|
AuthCard,
|
|
261
282
|
{
|
|
262
283
|
title: intl.formatMessage({
|
|
@@ -284,7 +305,7 @@ var AuthSignIn = ({
|
|
|
284
305
|
}
|
|
285
306
|
],
|
|
286
307
|
children: [
|
|
287
|
-
/* @__PURE__ */ (0,
|
|
308
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
288
309
|
import_forms2.FormFieldInput,
|
|
289
310
|
{
|
|
290
311
|
name: "email",
|
|
@@ -294,7 +315,7 @@ var AuthSignIn = ({
|
|
|
294
315
|
})
|
|
295
316
|
}
|
|
296
317
|
),
|
|
297
|
-
/* @__PURE__ */ (0,
|
|
318
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
298
319
|
import_forms2.FormFieldInput,
|
|
299
320
|
{
|
|
300
321
|
name: "password",
|
|
@@ -312,7 +333,7 @@ var AuthSignIn = ({
|
|
|
312
333
|
// src/AuthSignUp.tsx
|
|
313
334
|
var import_forms3 = require("@ttoss/forms");
|
|
314
335
|
var import_react_i18n3 = require("@ttoss/react-i18n");
|
|
315
|
-
var
|
|
336
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
316
337
|
var AuthSignUp = ({ onSignUp, onReturnToSignIn }) => {
|
|
317
338
|
const { intl } = (0, import_react_i18n3.useI18n)();
|
|
318
339
|
const schema = import_forms3.yup.object().shape({
|
|
@@ -349,7 +370,7 @@ var AuthSignUp = ({ onSignUp, onReturnToSignIn }) => {
|
|
|
349
370
|
const onSubmitForm = (data) => {
|
|
350
371
|
return onSignUp(data);
|
|
351
372
|
};
|
|
352
|
-
return /* @__PURE__ */ (0,
|
|
373
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_forms3.Form, { ...formMethods, onSubmit: onSubmitForm, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
353
374
|
AuthCard,
|
|
354
375
|
{
|
|
355
376
|
buttonLabel: intl.formatMessage({
|
|
@@ -370,7 +391,7 @@ var AuthSignUp = ({ onSignUp, onReturnToSignIn }) => {
|
|
|
370
391
|
}
|
|
371
392
|
],
|
|
372
393
|
children: [
|
|
373
|
-
/* @__PURE__ */ (0,
|
|
394
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
374
395
|
import_forms3.FormFieldInput,
|
|
375
396
|
{
|
|
376
397
|
name: "email",
|
|
@@ -380,7 +401,7 @@ var AuthSignUp = ({ onSignUp, onReturnToSignIn }) => {
|
|
|
380
401
|
})
|
|
381
402
|
}
|
|
382
403
|
),
|
|
383
|
-
/* @__PURE__ */ (0,
|
|
404
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
384
405
|
import_forms3.FormFieldInput,
|
|
385
406
|
{
|
|
386
407
|
name: "password",
|
|
@@ -399,7 +420,7 @@ var AuthSignUp = ({ onSignUp, onReturnToSignIn }) => {
|
|
|
399
420
|
var import_xstate = require("xstate");
|
|
400
421
|
var import_react = require("@xstate/react");
|
|
401
422
|
var import_react_notifications2 = require("@ttoss/react-notifications");
|
|
402
|
-
var
|
|
423
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
403
424
|
var authMachine = (0, import_xstate.createMachine)(
|
|
404
425
|
{
|
|
405
426
|
predictableActionArguments: true,
|
|
@@ -443,7 +464,7 @@ var authMachine = (0, import_xstate.createMachine)(
|
|
|
443
464
|
}
|
|
444
465
|
}
|
|
445
466
|
);
|
|
446
|
-
var
|
|
467
|
+
var AuthLogic = () => {
|
|
447
468
|
const { isAuthenticated } = useAuth();
|
|
448
469
|
const [state, send] = (0, import_react.useMachine)(authMachine);
|
|
449
470
|
const { setLoading } = (0, import_react_notifications2.useNotifications)();
|
|
@@ -503,10 +524,10 @@ var AuthWithoutLogo = () => {
|
|
|
503
524
|
return null;
|
|
504
525
|
}
|
|
505
526
|
if (state.matches("signUp")) {
|
|
506
|
-
return /* @__PURE__ */ (0,
|
|
527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AuthSignUp, { onSignUp, onReturnToSignIn });
|
|
507
528
|
}
|
|
508
529
|
if (state.matches("signUpConfirm")) {
|
|
509
|
-
return /* @__PURE__ */ (0,
|
|
530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
510
531
|
AuthConfirmSignUp,
|
|
511
532
|
{
|
|
512
533
|
onConfirmSignUp,
|
|
@@ -514,7 +535,7 @@ var AuthWithoutLogo = () => {
|
|
|
514
535
|
}
|
|
515
536
|
);
|
|
516
537
|
}
|
|
517
|
-
return /* @__PURE__ */ (0,
|
|
538
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
518
539
|
AuthSignIn,
|
|
519
540
|
{
|
|
520
541
|
onSignIn,
|
|
@@ -525,40 +546,18 @@ var AuthWithoutLogo = () => {
|
|
|
525
546
|
}
|
|
526
547
|
);
|
|
527
548
|
};
|
|
528
|
-
var
|
|
529
|
-
const
|
|
530
|
-
return /* @__PURE__ */ (0,
|
|
531
|
-
};
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
// src/AuthContainer.tsx
|
|
538
|
-
var import_ui2 = require("@ttoss/ui");
|
|
539
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
540
|
-
var AuthContainer = ({ sx, ...props }) => {
|
|
541
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
542
|
-
import_ui2.Flex,
|
|
543
|
-
{
|
|
544
|
-
...props,
|
|
545
|
-
sx: {
|
|
546
|
-
height: "100vh",
|
|
547
|
-
justifyContent: "center",
|
|
548
|
-
alignItems: "center",
|
|
549
|
-
margin: 0,
|
|
550
|
-
backgroundPosition: "center",
|
|
551
|
-
backgroundRepeat: "no-repeat",
|
|
552
|
-
backgroundSize: "cover",
|
|
553
|
-
...sx
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
);
|
|
549
|
+
var Auth2 = ({ logo, fullScreen = true }) => {
|
|
550
|
+
const withLogoNode = React3.useMemo(() => {
|
|
551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LogoProvider, { logo, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AuthLogic, {}) });
|
|
552
|
+
}, [logo]);
|
|
553
|
+
if (fullScreen) {
|
|
554
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AuthFullScreen, { children: withLogoNode });
|
|
555
|
+
}
|
|
556
|
+
return withLogoNode;
|
|
557
557
|
};
|
|
558
558
|
// Annotate the CommonJS export names for ESM import in node:
|
|
559
559
|
0 && (module.exports = {
|
|
560
560
|
Auth,
|
|
561
|
-
AuthContainer,
|
|
562
561
|
AuthProvider,
|
|
563
562
|
useAuth
|
|
564
563
|
});
|
package/i18n/lang/en.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/react-auth",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "ttoss authentication module for React apps.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
},
|
|
22
22
|
"typings": "./dist/index.d.ts",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@ttoss/cloud-auth": "^0.2.0",
|
|
25
24
|
"@ttoss/forms": "^0.11.4",
|
|
26
25
|
"@xstate/react": "^3.0.1",
|
|
27
26
|
"xstate": "^4.35.0"
|
|
@@ -34,9 +33,10 @@
|
|
|
34
33
|
"react": ">=16.8.0"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
36
|
+
"@ttoss/cloud-auth": "^0.3.0",
|
|
37
37
|
"@ttoss/config": "^1.25.0",
|
|
38
38
|
"@ttoss/i18n-cli": "^0.2.0",
|
|
39
|
-
"@ttoss/react-i18n": "^1.
|
|
39
|
+
"@ttoss/react-i18n": "^1.18.0",
|
|
40
40
|
"@ttoss/react-notifications": "^1.19.0",
|
|
41
41
|
"@ttoss/test-utils": "^1.18.3",
|
|
42
42
|
"@ttoss/ui": "^1.27.0",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "b697061d84f3b079619befbfb150e587f455dd1c"
|
|
53
53
|
}
|
package/src/Auth.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Auth as AmplifyAuth } from 'aws-amplify';
|
|
3
3
|
import { AuthConfirmSignUp } from './AuthConfirmSignUp';
|
|
4
|
+
import { AuthFullScreen } from './AuthFullScreen';
|
|
4
5
|
import { AuthSignIn } from './AuthSignIn';
|
|
5
6
|
import { AuthSignUp } from './AuthSignUp';
|
|
6
7
|
import { LogoContextProps, LogoProvider } from './AuthCard';
|
|
@@ -81,7 +82,7 @@ const authMachine = createMachine<AuthContext, AuthEvent, AuthState>(
|
|
|
81
82
|
}
|
|
82
83
|
);
|
|
83
84
|
|
|
84
|
-
const
|
|
85
|
+
const AuthLogic = () => {
|
|
85
86
|
const { isAuthenticated } = useAuth();
|
|
86
87
|
|
|
87
88
|
const [state, send] = useMachine(authMachine);
|
|
@@ -180,20 +181,22 @@ const AuthWithoutLogo = () => {
|
|
|
180
181
|
);
|
|
181
182
|
};
|
|
182
183
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
type AuthProps = LogoContextProps & {
|
|
185
|
+
fullScreen?: boolean;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export const Auth = ({ logo, fullScreen = true }: AuthProps) => {
|
|
189
|
+
const withLogoNode = React.useMemo(() => {
|
|
187
190
|
return (
|
|
188
191
|
<LogoProvider logo={logo}>
|
|
189
|
-
<
|
|
192
|
+
<AuthLogic />
|
|
190
193
|
</LogoProvider>
|
|
191
194
|
);
|
|
192
|
-
};
|
|
195
|
+
}, [logo]);
|
|
193
196
|
|
|
194
|
-
|
|
197
|
+
if (fullScreen) {
|
|
198
|
+
return <AuthFullScreen>{withLogoNode}</AuthFullScreen>;
|
|
199
|
+
}
|
|
195
200
|
|
|
196
|
-
return
|
|
201
|
+
return withLogoNode;
|
|
197
202
|
};
|
|
198
|
-
|
|
199
|
-
export const Auth = withLogo(AuthWithoutLogo);
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import { Flex
|
|
1
|
+
import { Flex } from '@ttoss/ui';
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type AuthFullScreenProps = {
|
|
4
|
+
backgroundImageUrl?: string;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
};
|
|
4
7
|
|
|
5
|
-
export const
|
|
8
|
+
export const AuthFullScreen = ({ children }: AuthFullScreenProps) => {
|
|
6
9
|
return (
|
|
7
10
|
<Flex
|
|
8
|
-
{...props}
|
|
9
11
|
sx={{
|
|
10
12
|
height: '100vh',
|
|
13
|
+
width: '100vw',
|
|
11
14
|
justifyContent: 'center',
|
|
12
15
|
alignItems: 'center',
|
|
13
16
|
margin: 0,
|
|
14
17
|
backgroundPosition: 'center',
|
|
15
18
|
backgroundRepeat: 'no-repeat',
|
|
16
19
|
backgroundSize: 'cover',
|
|
17
|
-
...sx,
|
|
18
20
|
}}
|
|
19
|
-
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
</Flex>
|
|
20
24
|
);
|
|
21
25
|
};
|
package/src/index.ts
CHANGED