@ttoss/react-auth-core 0.2.10 → 0.2.12
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 +486 -539
- package/dist/index.js +485 -539
- package/i18n/compiled/en.json +18 -0
- package/i18n/lang/en.json +12 -0
- package/package.json +11 -11
package/dist/esm/index.js
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
4
|
+
value,
|
|
5
|
+
configurable: true
|
|
6
|
+
});
|
|
2
7
|
|
|
3
8
|
// src/Auth.tsx
|
|
4
9
|
import { useNotifications as useNotifications2 } from "@ttoss/react-notifications";
|
|
5
10
|
import { Flex as Flex5 } from "@ttoss/ui";
|
|
6
|
-
import * as
|
|
11
|
+
import * as React5 from "react";
|
|
7
12
|
|
|
8
13
|
// src/AuthCard.tsx
|
|
9
14
|
import { useNotifications } from "@ttoss/react-notifications";
|
|
10
15
|
import { Box, Button, Flex, Heading } from "@ttoss/ui";
|
|
11
|
-
import * as
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
var LogoProvider = ({
|
|
16
|
+
import * as React2 from "react";
|
|
17
|
+
var LogoContext = /* @__PURE__ */React2.createContext({});
|
|
18
|
+
var LogoProvider = /* @__PURE__ */__name(({
|
|
15
19
|
children,
|
|
16
20
|
...values
|
|
17
21
|
}) => {
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
-
value: values
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var AuthCard = ({
|
|
22
|
+
return /* @__PURE__ */React2.createElement(LogoContext.Provider, {
|
|
23
|
+
value: values
|
|
24
|
+
}, children);
|
|
25
|
+
}, "LogoProvider");
|
|
26
|
+
var AuthCard = /* @__PURE__ */__name(({
|
|
24
27
|
children,
|
|
25
28
|
title,
|
|
26
29
|
buttonLabel,
|
|
@@ -29,11 +32,11 @@ var AuthCard = ({
|
|
|
29
32
|
}) => {
|
|
30
33
|
const {
|
|
31
34
|
logo
|
|
32
|
-
} =
|
|
35
|
+
} = React2.useContext(LogoContext);
|
|
33
36
|
const {
|
|
34
37
|
isLoading
|
|
35
38
|
} = useNotifications();
|
|
36
|
-
return /* @__PURE__ */
|
|
39
|
+
return /* @__PURE__ */React2.createElement(Box, {
|
|
37
40
|
sx: {
|
|
38
41
|
maxWidth: "400px",
|
|
39
42
|
width: "full",
|
|
@@ -42,100 +45,90 @@ var AuthCard = ({
|
|
|
42
45
|
paddingX: "8",
|
|
43
46
|
paddingY: "9",
|
|
44
47
|
backgroundColor: "surface"
|
|
48
|
+
}
|
|
49
|
+
}, logo && /* @__PURE__ */React2.createElement(Flex, {
|
|
50
|
+
sx: {
|
|
51
|
+
width: "full",
|
|
52
|
+
maxHeight: "90px",
|
|
53
|
+
justifyContent: "center",
|
|
54
|
+
marginBottom: "8"
|
|
55
|
+
}
|
|
56
|
+
}, logo), /* @__PURE__ */React2.createElement(Flex, {
|
|
57
|
+
sx: {
|
|
58
|
+
flexDirection: "column"
|
|
59
|
+
}
|
|
60
|
+
}, /* @__PURE__ */React2.createElement(Heading, {
|
|
61
|
+
as: "h2",
|
|
62
|
+
variant: "h2",
|
|
63
|
+
sx: {
|
|
64
|
+
marginBottom: "8"
|
|
65
|
+
}
|
|
66
|
+
}, title), children, /* @__PURE__ */React2.createElement(Flex, {
|
|
67
|
+
sx: {
|
|
68
|
+
flexDirection: "column",
|
|
69
|
+
width: "100%",
|
|
70
|
+
gap: "7",
|
|
71
|
+
marginTop: "8"
|
|
72
|
+
}
|
|
73
|
+
}, /* @__PURE__ */React2.createElement(Button, {
|
|
74
|
+
type: "submit",
|
|
75
|
+
variant: "accent",
|
|
76
|
+
disabled: isLoading || !isValidForm,
|
|
77
|
+
sx: {
|
|
78
|
+
textAlign: "center",
|
|
79
|
+
display: "initial"
|
|
45
80
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
maxHeight: "90px",
|
|
50
|
-
justifyContent: "center",
|
|
51
|
-
marginBottom: "8"
|
|
52
|
-
},
|
|
53
|
-
children: logo
|
|
54
|
-
}), /* @__PURE__ */jsxs(Flex, {
|
|
55
|
-
sx: {
|
|
56
|
-
flexDirection: "column"
|
|
57
|
-
},
|
|
58
|
-
children: [/* @__PURE__ */jsx(Heading, {
|
|
59
|
-
as: "h2",
|
|
60
|
-
variant: "h2",
|
|
61
|
-
sx: {
|
|
62
|
-
marginBottom: "8"
|
|
63
|
-
},
|
|
64
|
-
children: title
|
|
65
|
-
}), children, /* @__PURE__ */jsxs(Flex, {
|
|
66
|
-
sx: {
|
|
67
|
-
flexDirection: "column",
|
|
68
|
-
width: "100%",
|
|
69
|
-
gap: "7",
|
|
70
|
-
marginTop: "8"
|
|
71
|
-
},
|
|
72
|
-
children: [/* @__PURE__ */jsx(Button, {
|
|
73
|
-
type: "submit",
|
|
74
|
-
variant: "accent",
|
|
75
|
-
disabled: isLoading || !isValidForm,
|
|
76
|
-
sx: {
|
|
77
|
-
textAlign: "center",
|
|
78
|
-
display: "initial"
|
|
79
|
-
},
|
|
80
|
-
loading: isLoading,
|
|
81
|
-
children: buttonLabel
|
|
82
|
-
}), extraButton]
|
|
83
|
-
})]
|
|
84
|
-
})]
|
|
85
|
-
});
|
|
86
|
-
};
|
|
81
|
+
loading: isLoading
|
|
82
|
+
}, buttonLabel), extraButton)));
|
|
83
|
+
}, "AuthCard");
|
|
87
84
|
|
|
88
85
|
// src/AuthConfirmSignUpCheckEmail.tsx
|
|
89
86
|
import { NotificationCard } from "@ttoss/components/NotificationCard";
|
|
90
87
|
import { useI18n } from "@ttoss/react-i18n";
|
|
91
|
-
|
|
92
|
-
var AuthConfirmSignUpCheckEmail = ({
|
|
88
|
+
var AuthConfirmSignUpCheckEmail = /* @__PURE__ */__name(({
|
|
93
89
|
onConfirmSignUpCheckEmail
|
|
94
90
|
}) => {
|
|
95
91
|
const {
|
|
96
92
|
intl
|
|
97
93
|
} = useI18n();
|
|
98
|
-
return /* @__PURE__ */
|
|
99
|
-
onSubmit: e => {
|
|
94
|
+
return /* @__PURE__ */React.createElement("form", {
|
|
95
|
+
onSubmit: /* @__PURE__ */__name(e => {
|
|
100
96
|
e.preventDefault();
|
|
101
97
|
onConfirmSignUpCheckEmail();
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}),
|
|
119
|
-
children: /* @__PURE__ */jsx2(NotificationCard, {
|
|
120
|
-
type: "info",
|
|
121
|
-
message: intl.formatMessage({
|
|
122
|
-
id: "qTQ4hP",
|
|
123
|
-
defaultMessage: [{
|
|
124
|
-
"type": 0,
|
|
125
|
-
"value": "An email has been sent to your address. Please check your inbox and follow the instructions to confirm your sign up."
|
|
126
|
-
}]
|
|
127
|
-
})
|
|
128
|
-
})
|
|
98
|
+
}, "onSubmit")
|
|
99
|
+
}, /* @__PURE__ */React.createElement(AuthCard, {
|
|
100
|
+
isValidForm: true,
|
|
101
|
+
buttonLabel: intl.formatMessage({
|
|
102
|
+
id: "38HSjr",
|
|
103
|
+
defaultMessage: [{
|
|
104
|
+
"type": 0,
|
|
105
|
+
"value": "Sign In"
|
|
106
|
+
}]
|
|
107
|
+
}),
|
|
108
|
+
title: intl.formatMessage({
|
|
109
|
+
id: "cGR2eI",
|
|
110
|
+
defaultMessage: [{
|
|
111
|
+
"type": 0,
|
|
112
|
+
"value": "Confirmation"
|
|
113
|
+
}]
|
|
129
114
|
})
|
|
130
|
-
}
|
|
131
|
-
|
|
115
|
+
}, /* @__PURE__ */React.createElement(NotificationCard, {
|
|
116
|
+
type: "info",
|
|
117
|
+
message: intl.formatMessage({
|
|
118
|
+
id: "qTQ4hP",
|
|
119
|
+
defaultMessage: [{
|
|
120
|
+
"type": 0,
|
|
121
|
+
"value": "An email has been sent to your address. Please check your inbox and follow the instructions to confirm your sign up."
|
|
122
|
+
}]
|
|
123
|
+
})
|
|
124
|
+
})));
|
|
125
|
+
}, "AuthConfirmSignUpCheckEmail");
|
|
132
126
|
|
|
133
127
|
// src/AuthConfirmSignUpWithCode.tsx
|
|
134
128
|
import { NotificationCard as NotificationCard2 } from "@ttoss/components/NotificationCard";
|
|
135
129
|
import { Form, FormFieldInput, useForm, yup, yupResolver } from "@ttoss/forms";
|
|
136
130
|
import { useI18n as useI18n2 } from "@ttoss/react-i18n";
|
|
137
|
-
|
|
138
|
-
var AuthConfirmSignUpWithCode = ({
|
|
131
|
+
var AuthConfirmSignUpWithCode = /* @__PURE__ */__name(({
|
|
139
132
|
email,
|
|
140
133
|
onConfirmSignUpWithCode
|
|
141
134
|
}) => {
|
|
@@ -168,65 +161,62 @@ var AuthConfirmSignUpWithCode = ({
|
|
|
168
161
|
const formMethods = useForm({
|
|
169
162
|
resolver: yupResolver(schema)
|
|
170
163
|
});
|
|
171
|
-
return /* @__PURE__ */
|
|
164
|
+
return /* @__PURE__ */React.createElement(Form, {
|
|
172
165
|
...formMethods,
|
|
173
|
-
onSubmit: ({
|
|
166
|
+
onSubmit: /* @__PURE__ */__name(({
|
|
174
167
|
code
|
|
175
168
|
}) => {
|
|
176
169
|
return onConfirmSignUpWithCode({
|
|
177
170
|
code,
|
|
178
171
|
email
|
|
179
172
|
});
|
|
173
|
+
}, "onSubmit")
|
|
174
|
+
}, /* @__PURE__ */React.createElement(AuthCard, {
|
|
175
|
+
buttonLabel: intl.formatMessage({
|
|
176
|
+
id: "UNttd+",
|
|
177
|
+
defaultMessage: [{
|
|
178
|
+
"type": 0,
|
|
179
|
+
"value": "Confirm"
|
|
180
|
+
}]
|
|
181
|
+
}),
|
|
182
|
+
isValidForm: formMethods.formState.isValid,
|
|
183
|
+
title: intl.formatMessage({
|
|
184
|
+
id: "cGR2eI",
|
|
185
|
+
defaultMessage: [{
|
|
186
|
+
"type": 0,
|
|
187
|
+
"value": "Confirmation"
|
|
188
|
+
}]
|
|
189
|
+
})
|
|
190
|
+
}, /* @__PURE__ */React.createElement(NotificationCard2, {
|
|
191
|
+
type: "info",
|
|
192
|
+
message: intl.formatMessage({
|
|
193
|
+
id: "pwv2cR",
|
|
194
|
+
defaultMessage: [{
|
|
195
|
+
"type": 0,
|
|
196
|
+
"value": "We have sent a confirmation code to your email address. Please enter the code below."
|
|
197
|
+
}]
|
|
198
|
+
})
|
|
199
|
+
}), /* @__PURE__ */React.createElement(FormFieldInput, {
|
|
200
|
+
sx: {
|
|
201
|
+
marginTop: "6"
|
|
180
202
|
},
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}),
|
|
189
|
-
isValidForm: formMethods.formState.isValid,
|
|
190
|
-
title: intl.formatMessage({
|
|
191
|
-
id: "cGR2eI",
|
|
192
|
-
defaultMessage: [{
|
|
193
|
-
"type": 0,
|
|
194
|
-
"value": "Confirmation"
|
|
195
|
-
}]
|
|
196
|
-
}),
|
|
197
|
-
children: [/* @__PURE__ */jsx3(NotificationCard2, {
|
|
198
|
-
type: "info",
|
|
199
|
-
message: intl.formatMessage({
|
|
200
|
-
id: "pwv2cR",
|
|
201
|
-
defaultMessage: [{
|
|
202
|
-
"type": 0,
|
|
203
|
-
"value": "We have sent a confirmation code to your email address. Please enter the code below."
|
|
204
|
-
}]
|
|
205
|
-
})
|
|
206
|
-
}), /* @__PURE__ */jsx3(FormFieldInput, {
|
|
207
|
-
sx: {
|
|
208
|
-
marginTop: "6"
|
|
209
|
-
},
|
|
210
|
-
name: "code",
|
|
211
|
-
label: intl.formatMessage({
|
|
212
|
-
id: "KY2T6J",
|
|
213
|
-
defaultMessage: [{
|
|
214
|
-
"type": 0,
|
|
215
|
-
"value": "Code"
|
|
216
|
-
}]
|
|
217
|
-
})
|
|
218
|
-
})]
|
|
203
|
+
name: "code",
|
|
204
|
+
label: intl.formatMessage({
|
|
205
|
+
id: "KY2T6J",
|
|
206
|
+
defaultMessage: [{
|
|
207
|
+
"type": 0,
|
|
208
|
+
"value": "Code"
|
|
209
|
+
}]
|
|
219
210
|
})
|
|
220
|
-
});
|
|
221
|
-
};
|
|
211
|
+
})));
|
|
212
|
+
}, "AuthConfirmSignUpWithCode");
|
|
222
213
|
|
|
223
214
|
// src/AuthForgotPassword.tsx
|
|
224
215
|
import { Form as Form2, FormFieldInput as FormFieldInput2, useForm as useForm2, yup as yup2, yupResolver as yupResolver2 } from "@ttoss/forms";
|
|
225
216
|
import { useI18n as useI18n3 } from "@ttoss/react-i18n";
|
|
226
217
|
import { NotificationsBox } from "@ttoss/react-notifications";
|
|
227
218
|
import { Button as Button2, Link, Text } from "@ttoss/ui";
|
|
228
|
-
|
|
229
|
-
var AuthForgotPassword = props => {
|
|
219
|
+
var AuthForgotPassword = /* @__PURE__ */__name(props => {
|
|
230
220
|
const {
|
|
231
221
|
intl
|
|
232
222
|
} = useI18n3();
|
|
@@ -243,84 +233,79 @@ var AuthForgotPassword = props => {
|
|
|
243
233
|
resolver: yupResolver2(schema),
|
|
244
234
|
mode: "onChange"
|
|
245
235
|
});
|
|
246
|
-
return /* @__PURE__ */
|
|
236
|
+
return /* @__PURE__ */React.createElement(Form2, {
|
|
247
237
|
...formMethods,
|
|
248
238
|
sx: {
|
|
249
239
|
maxWidth: "390px"
|
|
250
240
|
},
|
|
251
|
-
onSubmit: ({
|
|
241
|
+
onSubmit: /* @__PURE__ */__name(({
|
|
252
242
|
email
|
|
253
243
|
}) => {
|
|
254
244
|
return props.onForgotPassword({
|
|
255
245
|
email
|
|
256
246
|
});
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}]
|
|
297
|
-
})
|
|
298
|
-
}), /* @__PURE__ */jsx4(NotificationsBox, {}), props.onGoToSignUp && /* @__PURE__ */jsx4(Text, {
|
|
299
|
-
sx: {
|
|
300
|
-
marginTop: "xl",
|
|
301
|
-
cursor: "pointer"
|
|
302
|
-
},
|
|
303
|
-
as: Link,
|
|
304
|
-
onClick: props.onGoToSignUp,
|
|
305
|
-
children: intl.formatMessage({
|
|
306
|
-
id: "lZvoYL",
|
|
307
|
-
defaultMessage: [{
|
|
308
|
-
"type": 0,
|
|
309
|
-
"value": "Sign up now"
|
|
310
|
-
}]
|
|
311
|
-
})
|
|
312
|
-
})]
|
|
247
|
+
}, "onSubmit")
|
|
248
|
+
}, /* @__PURE__ */React.createElement(AuthCard, {
|
|
249
|
+
buttonLabel: intl.formatMessage({
|
|
250
|
+
id: "mZzmNV",
|
|
251
|
+
defaultMessage: [{
|
|
252
|
+
"type": 0,
|
|
253
|
+
"value": "Recover Password"
|
|
254
|
+
}]
|
|
255
|
+
}),
|
|
256
|
+
isValidForm: formMethods.formState.isValid,
|
|
257
|
+
title: intl.formatMessage({
|
|
258
|
+
id: "S4bbEj",
|
|
259
|
+
defaultMessage: [{
|
|
260
|
+
"type": 0,
|
|
261
|
+
"value": "Recovering Password"
|
|
262
|
+
}]
|
|
263
|
+
}),
|
|
264
|
+
extraButton: /* @__PURE__ */React.createElement(Button2, {
|
|
265
|
+
sx: {
|
|
266
|
+
textAlign: "center",
|
|
267
|
+
display: "initial"
|
|
268
|
+
},
|
|
269
|
+
variant: "secondary",
|
|
270
|
+
onClick: props.onGoToSignIn
|
|
271
|
+
}, intl.formatMessage({
|
|
272
|
+
id: "6PdOcy",
|
|
273
|
+
defaultMessage: [{
|
|
274
|
+
"type": 0,
|
|
275
|
+
"value": "Cancel"
|
|
276
|
+
}]
|
|
277
|
+
}))
|
|
278
|
+
}, /* @__PURE__ */React.createElement(FormFieldInput2, {
|
|
279
|
+
name: "email",
|
|
280
|
+
label: intl.formatMessage({
|
|
281
|
+
id: "XreZg+",
|
|
282
|
+
defaultMessage: [{
|
|
283
|
+
"type": 0,
|
|
284
|
+
"value": "Registered Email"
|
|
285
|
+
}]
|
|
313
286
|
})
|
|
314
|
-
})
|
|
315
|
-
|
|
287
|
+
}), /* @__PURE__ */React.createElement(NotificationsBox, null), props.onGoToSignUp && /* @__PURE__ */React.createElement(Text, {
|
|
288
|
+
sx: {
|
|
289
|
+
marginTop: "xl",
|
|
290
|
+
cursor: "pointer"
|
|
291
|
+
},
|
|
292
|
+
as: Link,
|
|
293
|
+
onClick: props.onGoToSignUp
|
|
294
|
+
}, intl.formatMessage({
|
|
295
|
+
id: "lZvoYL",
|
|
296
|
+
defaultMessage: [{
|
|
297
|
+
"type": 0,
|
|
298
|
+
"value": "Sign up now"
|
|
299
|
+
}]
|
|
300
|
+
}))));
|
|
301
|
+
}, "AuthForgotPassword");
|
|
316
302
|
|
|
317
303
|
// src/AuthForgotPasswordResetPassword.tsx
|
|
318
304
|
import { Form as Form3, FormFieldInput as FormFieldInput3, FormFieldPassword, useForm as useForm3, yup as yup3, yupResolver as yupResolver3 } from "@ttoss/forms";
|
|
319
305
|
import { useI18n as useI18n4 } from "@ttoss/react-i18n";
|
|
320
306
|
import { NotificationsBox as NotificationsBox2 } from "@ttoss/react-notifications";
|
|
321
307
|
import { Button as Button3 } from "@ttoss/ui";
|
|
322
|
-
|
|
323
|
-
var AuthForgotPasswordResetPassword = props => {
|
|
308
|
+
var AuthForgotPasswordResetPassword = /* @__PURE__ */__name(props => {
|
|
324
309
|
const {
|
|
325
310
|
intl
|
|
326
311
|
} = useI18n4();
|
|
@@ -372,12 +357,12 @@ var AuthForgotPasswordResetPassword = props => {
|
|
|
372
357
|
resolver: yupResolver3(schema),
|
|
373
358
|
mode: "onChange"
|
|
374
359
|
});
|
|
375
|
-
return /* @__PURE__ */
|
|
360
|
+
return /* @__PURE__ */React.createElement(Form3, {
|
|
376
361
|
...formMethods,
|
|
377
362
|
sx: {
|
|
378
363
|
maxWidth: "390px"
|
|
379
364
|
},
|
|
380
|
-
onSubmit: ({
|
|
365
|
+
onSubmit: /* @__PURE__ */__name(({
|
|
381
366
|
code,
|
|
382
367
|
newPassword
|
|
383
368
|
}) => {
|
|
@@ -386,69 +371,65 @@ var AuthForgotPasswordResetPassword = props => {
|
|
|
386
371
|
code,
|
|
387
372
|
newPassword
|
|
388
373
|
});
|
|
389
|
-
},
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}]
|
|
430
|
-
})
|
|
431
|
-
}), /* @__PURE__ */jsx5(FormFieldPassword, {
|
|
432
|
-
name: "newPassword",
|
|
433
|
-
label: intl.formatMessage({
|
|
434
|
-
id: "e3IQoc",
|
|
435
|
-
defaultMessage: [{
|
|
436
|
-
"type": 0,
|
|
437
|
-
"value": "New Password"
|
|
438
|
-
}]
|
|
439
|
-
})
|
|
440
|
-
}), /* @__PURE__ */jsx5(NotificationsBox2, {})]
|
|
374
|
+
}, "onSubmit")
|
|
375
|
+
}, /* @__PURE__ */React.createElement(AuthCard, {
|
|
376
|
+
buttonLabel: intl.formatMessage({
|
|
377
|
+
id: "HT4tSM",
|
|
378
|
+
defaultMessage: [{
|
|
379
|
+
"type": 0,
|
|
380
|
+
"value": "Reset Password"
|
|
381
|
+
}]
|
|
382
|
+
}),
|
|
383
|
+
isValidForm: formMethods.formState.isValid,
|
|
384
|
+
title: intl.formatMessage({
|
|
385
|
+
id: "HT4tSM",
|
|
386
|
+
defaultMessage: [{
|
|
387
|
+
"type": 0,
|
|
388
|
+
"value": "Reset Password"
|
|
389
|
+
}]
|
|
390
|
+
}),
|
|
391
|
+
extraButton: props.onGoToSignIn ? /* @__PURE__ */React.createElement(Button3, {
|
|
392
|
+
type: "button",
|
|
393
|
+
sx: {
|
|
394
|
+
textAlign: "center",
|
|
395
|
+
display: "initial"
|
|
396
|
+
},
|
|
397
|
+
variant: "secondary",
|
|
398
|
+
onClick: props.onGoToSignIn
|
|
399
|
+
}, intl.formatMessage({
|
|
400
|
+
id: "6PdOcy",
|
|
401
|
+
defaultMessage: [{
|
|
402
|
+
"type": 0,
|
|
403
|
+
"value": "Cancel"
|
|
404
|
+
}]
|
|
405
|
+
})) : null
|
|
406
|
+
}, /* @__PURE__ */React.createElement(FormFieldInput3, {
|
|
407
|
+
name: "code",
|
|
408
|
+
label: intl.formatMessage({
|
|
409
|
+
id: "s1OmP0",
|
|
410
|
+
defaultMessage: [{
|
|
411
|
+
"type": 0,
|
|
412
|
+
"value": "Confirmation code"
|
|
413
|
+
}]
|
|
441
414
|
})
|
|
442
|
-
})
|
|
443
|
-
|
|
415
|
+
}), /* @__PURE__ */React.createElement(FormFieldPassword, {
|
|
416
|
+
name: "newPassword",
|
|
417
|
+
label: intl.formatMessage({
|
|
418
|
+
id: "e3IQoc",
|
|
419
|
+
defaultMessage: [{
|
|
420
|
+
"type": 0,
|
|
421
|
+
"value": "New Password"
|
|
422
|
+
}]
|
|
423
|
+
})
|
|
424
|
+
}), /* @__PURE__ */React.createElement(NotificationsBox2, null)));
|
|
425
|
+
}, "AuthForgotPasswordResetPassword");
|
|
444
426
|
|
|
445
427
|
// src/AuthFullScreen.tsx
|
|
446
428
|
import { Flex as Flex2 } from "@ttoss/ui";
|
|
447
|
-
|
|
448
|
-
var AuthFullScreen = ({
|
|
429
|
+
var AuthFullScreen = /* @__PURE__ */__name(({
|
|
449
430
|
children
|
|
450
431
|
}) => {
|
|
451
|
-
return /* @__PURE__ */
|
|
432
|
+
return /* @__PURE__ */React.createElement(Flex2, {
|
|
452
433
|
sx: {
|
|
453
434
|
height: "100vh",
|
|
454
435
|
width: "100vw",
|
|
@@ -458,18 +439,16 @@ var AuthFullScreen = ({
|
|
|
458
439
|
backgroundPosition: "center",
|
|
459
440
|
backgroundRepeat: "no-repeat",
|
|
460
441
|
backgroundSize: "cover"
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
};
|
|
442
|
+
}
|
|
443
|
+
}, children);
|
|
444
|
+
}, "AuthFullScreen");
|
|
465
445
|
|
|
466
446
|
// src/AuthSignIn.tsx
|
|
467
447
|
import { Form as Form4, FormFieldInput as FormFieldInput4, FormFieldPassword as FormFieldPassword2, useForm as useForm4, yup as yup4, yupResolver as yupResolver4 } from "@ttoss/forms";
|
|
468
448
|
import { useI18n as useI18n5 } from "@ttoss/react-i18n";
|
|
469
449
|
import { NotificationsBox as NotificationsBox3 } from "@ttoss/react-notifications";
|
|
470
450
|
import { Button as Button4, Flex as Flex3, Link as Link2, Text as Text2 } from "@ttoss/ui";
|
|
471
|
-
|
|
472
|
-
var AuthSignIn = ({
|
|
451
|
+
var AuthSignIn = /* @__PURE__ */__name(({
|
|
473
452
|
onSignIn,
|
|
474
453
|
onGoToSignUp,
|
|
475
454
|
defaultValues,
|
|
@@ -520,112 +499,105 @@ var AuthSignIn = ({
|
|
|
520
499
|
mode: "onChange",
|
|
521
500
|
resolver: yupResolver4(schema)
|
|
522
501
|
});
|
|
523
|
-
const onSubmitForm = data => {
|
|
502
|
+
const onSubmitForm = /* @__PURE__ */__name(data => {
|
|
524
503
|
return onSignIn(data);
|
|
525
|
-
};
|
|
526
|
-
return /* @__PURE__ */
|
|
504
|
+
}, "onSubmitForm");
|
|
505
|
+
return /* @__PURE__ */React.createElement(Form4, {
|
|
527
506
|
sx: {
|
|
528
507
|
maxWidth: "390px",
|
|
529
508
|
width: "100%"
|
|
530
509
|
},
|
|
531
510
|
...formMethods,
|
|
532
|
-
onSubmit: onSubmitForm
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}]
|
|
578
|
-
})
|
|
579
|
-
}), /* @__PURE__ */jsx7(FormFieldPassword2, {
|
|
580
|
-
name: "password",
|
|
581
|
-
label: intl.formatMessage({
|
|
582
|
-
id: "PylVqx",
|
|
583
|
-
defaultMessage: [{
|
|
584
|
-
"type": 0,
|
|
585
|
-
"value": "Password"
|
|
586
|
-
}]
|
|
587
|
-
})
|
|
588
|
-
})]
|
|
589
|
-
}), onGoToForgotPassword && /* @__PURE__ */jsx7(Flex3, {
|
|
590
|
-
sx: {
|
|
591
|
-
justifyContent: "space-between",
|
|
592
|
-
marginTop: "lg"
|
|
593
|
-
},
|
|
594
|
-
children: /* @__PURE__ */jsx7(Text2, {
|
|
595
|
-
sx: {
|
|
596
|
-
marginLeft: "auto",
|
|
597
|
-
cursor: "pointer"
|
|
598
|
-
},
|
|
599
|
-
as: Link2,
|
|
600
|
-
onClick: onGoToForgotPassword,
|
|
601
|
-
children: intl.formatMessage({
|
|
602
|
-
id: "BtK6KR",
|
|
603
|
-
defaultMessage: [{
|
|
604
|
-
"type": 0,
|
|
605
|
-
"value": "Forgot password?"
|
|
606
|
-
}]
|
|
607
|
-
})
|
|
608
|
-
})
|
|
609
|
-
}), /* @__PURE__ */jsx7(NotificationsBox3, {})]
|
|
511
|
+
onSubmit: onSubmitForm
|
|
512
|
+
}, /* @__PURE__ */React.createElement(AuthCard, {
|
|
513
|
+
title: intl.formatMessage({
|
|
514
|
+
id: "SQJto2",
|
|
515
|
+
defaultMessage: [{
|
|
516
|
+
"type": 0,
|
|
517
|
+
"value": "Sign in"
|
|
518
|
+
}]
|
|
519
|
+
}),
|
|
520
|
+
buttonLabel: intl.formatMessage({
|
|
521
|
+
id: "SQJto2",
|
|
522
|
+
defaultMessage: [{
|
|
523
|
+
"type": 0,
|
|
524
|
+
"value": "Sign in"
|
|
525
|
+
}]
|
|
526
|
+
}),
|
|
527
|
+
isValidForm: formMethods.formState.isValid,
|
|
528
|
+
extraButton: onGoToSignUp ? /* @__PURE__ */React.createElement(Button4, {
|
|
529
|
+
type: "button",
|
|
530
|
+
variant: "secondary",
|
|
531
|
+
sx: {
|
|
532
|
+
textAlign: "center",
|
|
533
|
+
display: "initial"
|
|
534
|
+
},
|
|
535
|
+
onClick: onGoToSignUp
|
|
536
|
+
}, intl.formatMessage({
|
|
537
|
+
id: "EZ3YF2",
|
|
538
|
+
defaultMessage: [{
|
|
539
|
+
"type": 0,
|
|
540
|
+
"value": "Sign up"
|
|
541
|
+
}]
|
|
542
|
+
})) : null
|
|
543
|
+
}, /* @__PURE__ */React.createElement(Flex3, {
|
|
544
|
+
sx: {
|
|
545
|
+
flexDirection: "column",
|
|
546
|
+
gap: "xl"
|
|
547
|
+
}
|
|
548
|
+
}, /* @__PURE__ */React.createElement(FormFieldInput4, {
|
|
549
|
+
name: "email",
|
|
550
|
+
label: intl.formatMessage({
|
|
551
|
+
id: "5E12mO",
|
|
552
|
+
defaultMessage: [{
|
|
553
|
+
"type": 0,
|
|
554
|
+
"value": "Email"
|
|
555
|
+
}]
|
|
610
556
|
})
|
|
611
|
-
})
|
|
612
|
-
|
|
557
|
+
}), /* @__PURE__ */React.createElement(FormFieldPassword2, {
|
|
558
|
+
name: "password",
|
|
559
|
+
label: intl.formatMessage({
|
|
560
|
+
id: "PylVqx",
|
|
561
|
+
defaultMessage: [{
|
|
562
|
+
"type": 0,
|
|
563
|
+
"value": "Password"
|
|
564
|
+
}]
|
|
565
|
+
})
|
|
566
|
+
})), onGoToForgotPassword && /* @__PURE__ */React.createElement(Flex3, {
|
|
567
|
+
sx: {
|
|
568
|
+
justifyContent: "space-between",
|
|
569
|
+
marginTop: "lg"
|
|
570
|
+
}
|
|
571
|
+
}, /* @__PURE__ */React.createElement(Text2, {
|
|
572
|
+
sx: {
|
|
573
|
+
marginLeft: "auto",
|
|
574
|
+
cursor: "pointer"
|
|
575
|
+
},
|
|
576
|
+
as: Link2,
|
|
577
|
+
onClick: onGoToForgotPassword
|
|
578
|
+
}, intl.formatMessage({
|
|
579
|
+
id: "BtK6KR",
|
|
580
|
+
defaultMessage: [{
|
|
581
|
+
"type": 0,
|
|
582
|
+
"value": "Forgot password?"
|
|
583
|
+
}]
|
|
584
|
+
}))), /* @__PURE__ */React.createElement(NotificationsBox3, null)));
|
|
585
|
+
}, "AuthSignIn");
|
|
613
586
|
|
|
614
587
|
// src/AuthSignUp.tsx
|
|
615
588
|
import { Form as Form5, FormFieldCheckbox, FormFieldInput as FormFieldInput5, FormFieldPassword as FormFieldPassword3, useForm as useForm5, yup as yup5, yupResolver as yupResolver5 } from "@ttoss/forms";
|
|
616
589
|
import { useI18n as useI18n6 } from "@ttoss/react-i18n";
|
|
617
590
|
import { NotificationsBox as NotificationsBox4 } from "@ttoss/react-notifications";
|
|
618
591
|
import { Flex as Flex4, Link as Link3, Text as Text3 } from "@ttoss/ui";
|
|
619
|
-
import * as
|
|
620
|
-
|
|
621
|
-
var AuthSignUp = props => {
|
|
592
|
+
import * as React3 from "react";
|
|
593
|
+
var AuthSignUp = /* @__PURE__ */__name(props => {
|
|
622
594
|
const {
|
|
623
595
|
intl
|
|
624
596
|
} = useI18n6();
|
|
625
597
|
const {
|
|
626
598
|
passwordMinimumLength = 8
|
|
627
599
|
} = props;
|
|
628
|
-
const schema =
|
|
600
|
+
const schema = React3.useMemo(() => {
|
|
629
601
|
return yup5.object().shape({
|
|
630
602
|
email: yup5.string().required(intl.formatMessage({
|
|
631
603
|
id: "d1YCuH",
|
|
@@ -683,7 +655,7 @@ var AuthSignUp = props => {
|
|
|
683
655
|
})) : yup5.boolean()
|
|
684
656
|
});
|
|
685
657
|
}, [intl, props.signUpTerms?.isRequired, passwordMinimumLength]);
|
|
686
|
-
const signUpTermsLabel =
|
|
658
|
+
const signUpTermsLabel = React3.useMemo(() => {
|
|
687
659
|
if (!props.signUpTerms) {
|
|
688
660
|
return null;
|
|
689
661
|
}
|
|
@@ -696,163 +668,152 @@ var AuthSignUp = props => {
|
|
|
696
668
|
});
|
|
697
669
|
const termsLinks = props.signUpTerms.terms.map((term, index, terms) => {
|
|
698
670
|
const finalPunctuation = index === terms.length - 1 ? "." : ", ";
|
|
699
|
-
return /* @__PURE__ */
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
},
|
|
707
|
-
});
|
|
708
|
-
const label = /* @__PURE__ */jsxs6(Text3, {
|
|
709
|
-
children: [signUpTermsFirstMessage, " ", termsLinks]
|
|
671
|
+
return /* @__PURE__ */React3.createElement(React3.Fragment, {
|
|
672
|
+
key: index
|
|
673
|
+
}, /* @__PURE__ */React3.createElement(Link3, {
|
|
674
|
+
key: index,
|
|
675
|
+
href: term.url,
|
|
676
|
+
target: "_blank",
|
|
677
|
+
rel: "noreferrer"
|
|
678
|
+
}, term.label), finalPunctuation);
|
|
710
679
|
});
|
|
680
|
+
const label = /* @__PURE__ */React3.createElement(Text3, null, signUpTermsFirstMessage, " ", termsLinks);
|
|
711
681
|
return label;
|
|
712
682
|
}, [intl, props.signUpTerms]);
|
|
713
|
-
const signUpTermsNode =
|
|
683
|
+
const signUpTermsNode = React3.useMemo(() => {
|
|
714
684
|
if (!props.signUpTerms) {
|
|
715
685
|
return null;
|
|
716
686
|
}
|
|
717
687
|
if (props.signUpTerms.isRequired) {
|
|
718
|
-
return /* @__PURE__ */
|
|
688
|
+
return /* @__PURE__ */React3.createElement(FormFieldCheckbox, {
|
|
719
689
|
name: "signUpTerms",
|
|
720
690
|
label: signUpTermsLabel
|
|
721
691
|
});
|
|
722
692
|
} else {
|
|
723
|
-
return /* @__PURE__ */
|
|
724
|
-
children: signUpTermsLabel
|
|
725
|
-
});
|
|
693
|
+
return /* @__PURE__ */React3.createElement(React3.Fragment, null, signUpTermsLabel);
|
|
726
694
|
}
|
|
727
695
|
}, [props.signUpTerms, signUpTermsLabel]);
|
|
728
696
|
const formMethods = useForm5({
|
|
729
697
|
mode: "onChange",
|
|
730
698
|
resolver: yupResolver5(schema)
|
|
731
699
|
});
|
|
732
|
-
const onSubmitForm = data => {
|
|
700
|
+
const onSubmitForm = /* @__PURE__ */__name(data => {
|
|
733
701
|
return props.onSignUp(data);
|
|
734
|
-
};
|
|
735
|
-
return /* @__PURE__ */
|
|
702
|
+
}, "onSubmitForm");
|
|
703
|
+
return /* @__PURE__ */React3.createElement(Form5, {
|
|
736
704
|
sx: {
|
|
737
705
|
maxWidth: "390px",
|
|
738
706
|
width: "100%"
|
|
739
707
|
},
|
|
740
708
|
...formMethods,
|
|
741
|
-
onSubmit: onSubmitForm
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
}]
|
|
785
|
-
})
|
|
786
|
-
}), /* @__PURE__ */jsx8(FormFieldPassword3, {
|
|
787
|
-
name: "password",
|
|
788
|
-
label: intl.formatMessage({
|
|
789
|
-
id: "PylVqx",
|
|
790
|
-
defaultMessage: [{
|
|
791
|
-
"type": 0,
|
|
792
|
-
"value": "Password"
|
|
793
|
-
}]
|
|
794
|
-
})
|
|
795
|
-
}), /* @__PURE__ */jsx8(FormFieldPassword3, {
|
|
796
|
-
name: "confirmPassword",
|
|
797
|
-
label: intl.formatMessage({
|
|
798
|
-
id: "lY+cuM",
|
|
799
|
-
defaultMessage: [{
|
|
800
|
-
"type": 0,
|
|
801
|
-
"value": "Confirm password"
|
|
802
|
-
}]
|
|
803
|
-
})
|
|
804
|
-
}), signUpTermsNode]
|
|
805
|
-
}), /* @__PURE__ */jsx8(NotificationsBox4, {})]
|
|
709
|
+
onSubmit: onSubmitForm
|
|
710
|
+
}, /* @__PURE__ */React3.createElement(AuthCard, {
|
|
711
|
+
buttonLabel: intl.formatMessage({
|
|
712
|
+
id: "URJDrG",
|
|
713
|
+
defaultMessage: [{
|
|
714
|
+
"type": 0,
|
|
715
|
+
"value": "Sign up"
|
|
716
|
+
}]
|
|
717
|
+
}),
|
|
718
|
+
title: intl.formatMessage({
|
|
719
|
+
id: "oayEC3",
|
|
720
|
+
defaultMessage: [{
|
|
721
|
+
"type": 0,
|
|
722
|
+
"value": "Sign up"
|
|
723
|
+
}]
|
|
724
|
+
}),
|
|
725
|
+
isValidForm: formMethods.formState.isValid,
|
|
726
|
+
extraButton: /* @__PURE__ */React3.createElement(Text3, {
|
|
727
|
+
sx: {
|
|
728
|
+
cursor: "pointer"
|
|
729
|
+
},
|
|
730
|
+
onClick: props.onGoToSignIn,
|
|
731
|
+
as: Link3
|
|
732
|
+
}, intl.formatMessage({
|
|
733
|
+
id: "8GMUPk",
|
|
734
|
+
defaultMessage: [{
|
|
735
|
+
"type": 0,
|
|
736
|
+
"value": "I'm already registered"
|
|
737
|
+
}]
|
|
738
|
+
}))
|
|
739
|
+
}, /* @__PURE__ */React3.createElement(Flex4, {
|
|
740
|
+
sx: {
|
|
741
|
+
flexDirection: "column",
|
|
742
|
+
gap: "xl"
|
|
743
|
+
}
|
|
744
|
+
}, /* @__PURE__ */React3.createElement(FormFieldInput5, {
|
|
745
|
+
name: "email",
|
|
746
|
+
label: intl.formatMessage({
|
|
747
|
+
id: "5E12mO",
|
|
748
|
+
defaultMessage: [{
|
|
749
|
+
"type": 0,
|
|
750
|
+
"value": "Email"
|
|
751
|
+
}]
|
|
806
752
|
})
|
|
807
|
-
})
|
|
808
|
-
|
|
753
|
+
}), /* @__PURE__ */React3.createElement(FormFieldPassword3, {
|
|
754
|
+
name: "password",
|
|
755
|
+
label: intl.formatMessage({
|
|
756
|
+
id: "PylVqx",
|
|
757
|
+
defaultMessage: [{
|
|
758
|
+
"type": 0,
|
|
759
|
+
"value": "Password"
|
|
760
|
+
}]
|
|
761
|
+
})
|
|
762
|
+
}), /* @__PURE__ */React3.createElement(FormFieldPassword3, {
|
|
763
|
+
name: "confirmPassword",
|
|
764
|
+
label: intl.formatMessage({
|
|
765
|
+
id: "lY+cuM",
|
|
766
|
+
defaultMessage: [{
|
|
767
|
+
"type": 0,
|
|
768
|
+
"value": "Confirm password"
|
|
769
|
+
}]
|
|
770
|
+
})
|
|
771
|
+
}), signUpTermsNode), /* @__PURE__ */React3.createElement(NotificationsBox4, null)));
|
|
772
|
+
}, "AuthSignUp");
|
|
809
773
|
|
|
810
774
|
// src/ErrorBoundary.tsx
|
|
811
775
|
import { NotificationCard as NotificationCard3 } from "@ttoss/components/NotificationCard";
|
|
812
776
|
import { notify } from "@ttoss/logger";
|
|
813
777
|
import { useI18n as useI18n7 } from "@ttoss/react-i18n";
|
|
778
|
+
import * as React4 from "react";
|
|
814
779
|
import { ErrorBoundary as ReactErrorBoundary } from "react-error-boundary";
|
|
815
|
-
|
|
816
|
-
var ErrorFallback = ({
|
|
780
|
+
var ErrorFallback = /* @__PURE__ */__name(({
|
|
817
781
|
resetErrorBoundary
|
|
818
782
|
}) => {
|
|
819
783
|
const {
|
|
820
784
|
intl
|
|
821
785
|
} = useI18n7();
|
|
822
|
-
return /* @__PURE__ */
|
|
823
|
-
role: "alert"
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
var ErrorBoundary = ({
|
|
786
|
+
return /* @__PURE__ */React4.createElement("div", {
|
|
787
|
+
role: "alert"
|
|
788
|
+
}, /* @__PURE__ */React4.createElement(NotificationCard3, {
|
|
789
|
+
type: "error",
|
|
790
|
+
message: intl.formatMessage({
|
|
791
|
+
id: "khMx/2",
|
|
792
|
+
defaultMessage: [{
|
|
793
|
+
"type": 0,
|
|
794
|
+
"value": "An error occurred with your authentication. Please try again."
|
|
795
|
+
}]
|
|
796
|
+
}),
|
|
797
|
+
onClose: resetErrorBoundary
|
|
798
|
+
}));
|
|
799
|
+
}, "ErrorFallback");
|
|
800
|
+
var ErrorBoundary = /* @__PURE__ */__name(({
|
|
838
801
|
children
|
|
839
802
|
}) => {
|
|
840
|
-
return /* @__PURE__ */
|
|
803
|
+
return /* @__PURE__ */React4.createElement(ReactErrorBoundary, {
|
|
841
804
|
FallbackComponent: ErrorFallback,
|
|
842
|
-
onError: error => {
|
|
805
|
+
onError: /* @__PURE__ */__name(error => {
|
|
843
806
|
notify({
|
|
844
807
|
type: "error",
|
|
845
808
|
title: "Authentication Error",
|
|
846
809
|
message: error.message
|
|
847
810
|
});
|
|
848
|
-
},
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
};
|
|
811
|
+
}, "onError")
|
|
812
|
+
}, children);
|
|
813
|
+
}, "ErrorBoundary");
|
|
852
814
|
|
|
853
815
|
// src/Auth.tsx
|
|
854
|
-
|
|
855
|
-
var AuthLogic = props => {
|
|
816
|
+
var AuthLogic = /* @__PURE__ */__name(props => {
|
|
856
817
|
const {
|
|
857
818
|
screen,
|
|
858
819
|
setScreen,
|
|
@@ -869,18 +830,18 @@ var AuthLogic = props => {
|
|
|
869
830
|
clearNotifications,
|
|
870
831
|
setLoading
|
|
871
832
|
} = useNotifications2();
|
|
872
|
-
|
|
833
|
+
React5.useEffect(() => {
|
|
873
834
|
clearNotifications();
|
|
874
835
|
}, [screen.value, clearNotifications]);
|
|
875
|
-
|
|
836
|
+
React5.useEffect(() => {
|
|
876
837
|
return clearNotifications;
|
|
877
838
|
}, [clearNotifications]);
|
|
878
|
-
const onGoToSignIn = () => {
|
|
839
|
+
const onGoToSignIn = /* @__PURE__ */__name(() => {
|
|
879
840
|
setScreen({
|
|
880
841
|
value: "signIn"
|
|
881
842
|
});
|
|
882
|
-
};
|
|
883
|
-
const onGoToSignUp =
|
|
843
|
+
}, "onGoToSignIn");
|
|
844
|
+
const onGoToSignUp = React5.useCallback(() => {
|
|
884
845
|
if (!onSignUp) {
|
|
885
846
|
return void 0;
|
|
886
847
|
}
|
|
@@ -888,7 +849,7 @@ var AuthLogic = props => {
|
|
|
888
849
|
value: "signUp"
|
|
889
850
|
});
|
|
890
851
|
}, [onSignUp, setScreen]);
|
|
891
|
-
const onGoToForgotPassword =
|
|
852
|
+
const onGoToForgotPassword = React5.useCallback(() => {
|
|
892
853
|
if (!onForgotPassword) {
|
|
893
854
|
return void 0;
|
|
894
855
|
}
|
|
@@ -896,7 +857,7 @@ var AuthLogic = props => {
|
|
|
896
857
|
value: "forgotPassword"
|
|
897
858
|
});
|
|
898
859
|
}, [onForgotPassword, setScreen]);
|
|
899
|
-
const notificationsWrapper = fn => {
|
|
860
|
+
const notificationsWrapper = /* @__PURE__ */__name(fn => {
|
|
900
861
|
return async input => {
|
|
901
862
|
if (fn) {
|
|
902
863
|
clearNotifications();
|
|
@@ -906,9 +867,9 @@ var AuthLogic = props => {
|
|
|
906
867
|
return result;
|
|
907
868
|
}
|
|
908
869
|
};
|
|
909
|
-
};
|
|
870
|
+
}, "notificationsWrapper");
|
|
910
871
|
if (screen.value === "signIn") {
|
|
911
|
-
return /* @__PURE__ */
|
|
872
|
+
return /* @__PURE__ */React5.createElement(AuthSignIn, {
|
|
912
873
|
onSignIn: notificationsWrapper(onSignIn),
|
|
913
874
|
onGoToSignUp: onSignUp && onGoToSignUp,
|
|
914
875
|
onGoToForgotPassword: onForgotPassword && onGoToForgotPassword,
|
|
@@ -916,7 +877,7 @@ var AuthLogic = props => {
|
|
|
916
877
|
});
|
|
917
878
|
}
|
|
918
879
|
if (screen.value === "signUp" && onSignUp) {
|
|
919
|
-
return /* @__PURE__ */
|
|
880
|
+
return /* @__PURE__ */React5.createElement(AuthSignUp, {
|
|
920
881
|
onSignUp: notificationsWrapper(onSignUp),
|
|
921
882
|
passwordMinimumLength,
|
|
922
883
|
onGoToSignIn,
|
|
@@ -924,97 +885,84 @@ var AuthLogic = props => {
|
|
|
924
885
|
});
|
|
925
886
|
}
|
|
926
887
|
if (screen.value === "forgotPassword" && onForgotPassword) {
|
|
927
|
-
return /* @__PURE__ */
|
|
888
|
+
return /* @__PURE__ */React5.createElement(AuthForgotPassword, {
|
|
928
889
|
onForgotPassword: notificationsWrapper(onForgotPassword),
|
|
929
890
|
onGoToSignIn,
|
|
930
891
|
onGoToSignUp: onSignUp && onGoToSignUp
|
|
931
892
|
});
|
|
932
893
|
}
|
|
933
894
|
if (screen.value === "confirmResetPassword" && onForgotPasswordResetPassword) {
|
|
934
|
-
return /* @__PURE__ */
|
|
895
|
+
return /* @__PURE__ */React5.createElement(AuthForgotPasswordResetPassword, {
|
|
935
896
|
onForgotPasswordResetPassword: notificationsWrapper(onForgotPasswordResetPassword),
|
|
936
897
|
onGoToSignIn,
|
|
937
898
|
email: screen.context.email
|
|
938
899
|
});
|
|
939
900
|
}
|
|
940
901
|
if (screen.value === "confirmSignUpWithCode" && onConfirmSignUpWithCode) {
|
|
941
|
-
return /* @__PURE__ */
|
|
902
|
+
return /* @__PURE__ */React5.createElement(AuthConfirmSignUpWithCode, {
|
|
942
903
|
onConfirmSignUpWithCode: notificationsWrapper(onConfirmSignUpWithCode),
|
|
943
904
|
email: screen.context.email
|
|
944
905
|
});
|
|
945
906
|
}
|
|
946
907
|
if (screen.value === "confirmSignUpCheckEmail" && onConfirmSignUpCheckEmail) {
|
|
947
|
-
return /* @__PURE__ */
|
|
908
|
+
return /* @__PURE__ */React5.createElement(AuthConfirmSignUpCheckEmail, {
|
|
948
909
|
onConfirmSignUpCheckEmail
|
|
949
910
|
});
|
|
950
911
|
}
|
|
951
912
|
return null;
|
|
952
|
-
};
|
|
953
|
-
var Auth = props => {
|
|
913
|
+
}, "AuthLogic");
|
|
914
|
+
var Auth = /* @__PURE__ */__name(props => {
|
|
954
915
|
const {
|
|
955
916
|
layout = {
|
|
956
917
|
fullScreen: true
|
|
957
918
|
}
|
|
958
919
|
} = props;
|
|
959
|
-
const withLogoNode =
|
|
960
|
-
return /* @__PURE__ */
|
|
961
|
-
logo: props.logo
|
|
962
|
-
|
|
963
|
-
children: /* @__PURE__ */jsx10(AuthLogic, {
|
|
964
|
-
...props
|
|
965
|
-
})
|
|
966
|
-
})
|
|
967
|
-
});
|
|
920
|
+
const withLogoNode = React5.useMemo(() => {
|
|
921
|
+
return /* @__PURE__ */React5.createElement(LogoProvider, {
|
|
922
|
+
logo: props.logo
|
|
923
|
+
}, /* @__PURE__ */React5.createElement(ErrorBoundary, null, /* @__PURE__ */React5.createElement(AuthLogic, props)));
|
|
968
924
|
}, [props]);
|
|
969
925
|
if (layout.fullScreen) {
|
|
970
926
|
if (layout.sideContentPosition) {
|
|
971
|
-
return /* @__PURE__ */
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
},
|
|
995
|
-
children: withLogoNode
|
|
996
|
-
})]
|
|
997
|
-
})
|
|
998
|
-
});
|
|
927
|
+
return /* @__PURE__ */React5.createElement(AuthFullScreen, null, /* @__PURE__ */React5.createElement(Flex5, {
|
|
928
|
+
sx: {
|
|
929
|
+
width: "100%",
|
|
930
|
+
height: "100%",
|
|
931
|
+
flexDirection: layout.sideContentPosition === "left" ? "row" : "row-reverse"
|
|
932
|
+
}
|
|
933
|
+
}, /* @__PURE__ */React5.createElement(Flex5, {
|
|
934
|
+
sx: {
|
|
935
|
+
width: "100%",
|
|
936
|
+
height: "100%",
|
|
937
|
+
flex: [0, 0, 1],
|
|
938
|
+
justifyContent: "center",
|
|
939
|
+
alignItems: "center"
|
|
940
|
+
}
|
|
941
|
+
}, layout.sideContent), /* @__PURE__ */React5.createElement(Flex5, {
|
|
942
|
+
sx: {
|
|
943
|
+
width: "100%",
|
|
944
|
+
height: "100%",
|
|
945
|
+
flex: [1],
|
|
946
|
+
justifyContent: "center",
|
|
947
|
+
alignItems: "center"
|
|
948
|
+
}
|
|
949
|
+
}, withLogoNode)));
|
|
999
950
|
}
|
|
1000
|
-
return /* @__PURE__ */
|
|
1001
|
-
children: withLogoNode
|
|
1002
|
-
});
|
|
951
|
+
return /* @__PURE__ */React5.createElement(AuthFullScreen, null, withLogoNode);
|
|
1003
952
|
}
|
|
1004
953
|
return withLogoNode;
|
|
1005
|
-
};
|
|
954
|
+
}, "Auth");
|
|
1006
955
|
|
|
1007
956
|
// src/AuthProvider.tsx
|
|
1008
957
|
import { useNotifications as useNotifications3 } from "@ttoss/react-notifications";
|
|
1009
|
-
import * as
|
|
1010
|
-
|
|
1011
|
-
var AuthContext = React4.createContext(null);
|
|
958
|
+
import * as React6 from "react";
|
|
959
|
+
var AuthContext = /* @__PURE__ */React6.createContext(null);
|
|
1012
960
|
var UNAUTHENTICATED_USER = {
|
|
1013
961
|
user: null,
|
|
1014
962
|
tokens: null,
|
|
1015
963
|
isAuthenticated: false
|
|
1016
964
|
};
|
|
1017
|
-
var AuthProvider = props => {
|
|
965
|
+
var AuthProvider = /* @__PURE__ */__name(props => {
|
|
1018
966
|
const {
|
|
1019
967
|
getAuthData,
|
|
1020
968
|
signOut: signOutProp
|
|
@@ -1022,16 +970,16 @@ var AuthProvider = props => {
|
|
|
1022
970
|
const {
|
|
1023
971
|
setLoading
|
|
1024
972
|
} = useNotifications3();
|
|
1025
|
-
const [authData, setAuthData] =
|
|
973
|
+
const [authData, setAuthData] = React6.useState({
|
|
1026
974
|
user: null,
|
|
1027
975
|
tokens: null,
|
|
1028
976
|
isAuthenticated: void 0
|
|
1029
977
|
});
|
|
1030
|
-
|
|
978
|
+
React6.useEffect(() => {
|
|
1031
979
|
setLoading(authData.isAuthenticated === void 0);
|
|
1032
980
|
}, [authData.isAuthenticated, setLoading]);
|
|
1033
|
-
|
|
1034
|
-
const fetchAuthData = async () => {
|
|
981
|
+
React6.useEffect(() => {
|
|
982
|
+
const fetchAuthData = /* @__PURE__ */__name(async () => {
|
|
1035
983
|
try {
|
|
1036
984
|
const data = await getAuthData?.();
|
|
1037
985
|
if (data) {
|
|
@@ -1042,44 +990,43 @@ var AuthProvider = props => {
|
|
|
1042
990
|
} catch {
|
|
1043
991
|
setAuthData(UNAUTHENTICATED_USER);
|
|
1044
992
|
}
|
|
1045
|
-
};
|
|
993
|
+
}, "fetchAuthData");
|
|
1046
994
|
fetchAuthData();
|
|
1047
995
|
}, [getAuthData]);
|
|
1048
|
-
const signOut =
|
|
996
|
+
const signOut = React6.useCallback(async () => {
|
|
1049
997
|
await signOutProp?.();
|
|
1050
998
|
setAuthData(UNAUTHENTICATED_USER);
|
|
1051
999
|
}, [signOutProp]);
|
|
1052
1000
|
if (authData.isAuthenticated === void 0) {
|
|
1053
1001
|
return null;
|
|
1054
1002
|
}
|
|
1055
|
-
return /* @__PURE__ */
|
|
1003
|
+
return /* @__PURE__ */React6.createElement(AuthContext.Provider, {
|
|
1056
1004
|
value: {
|
|
1057
1005
|
signOut,
|
|
1058
1006
|
isAuthenticated: authData.isAuthenticated ?? false,
|
|
1059
1007
|
user: authData.user,
|
|
1060
1008
|
tokens: authData.tokens,
|
|
1061
1009
|
setAuthData
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
const context = React4.useContext(AuthContext);
|
|
1010
|
+
}
|
|
1011
|
+
}, props.children);
|
|
1012
|
+
}, "AuthProvider");
|
|
1013
|
+
var useAuth = /* @__PURE__ */__name(() => {
|
|
1014
|
+
const context = React6.useContext(AuthContext);
|
|
1068
1015
|
if (!context) {
|
|
1069
1016
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1070
1017
|
}
|
|
1071
1018
|
return context;
|
|
1072
|
-
};
|
|
1019
|
+
}, "useAuth");
|
|
1073
1020
|
|
|
1074
1021
|
// src/useAuthScreen.ts
|
|
1075
|
-
import * as
|
|
1076
|
-
var useAuthScreen = initialScreen => {
|
|
1077
|
-
const [screen, setScreen] =
|
|
1022
|
+
import * as React7 from "react";
|
|
1023
|
+
var useAuthScreen = /* @__PURE__ */__name(initialScreen => {
|
|
1024
|
+
const [screen, setScreen] = React7.useState(initialScreen || {
|
|
1078
1025
|
value: "signIn"
|
|
1079
1026
|
});
|
|
1080
1027
|
return {
|
|
1081
1028
|
screen,
|
|
1082
1029
|
setScreen
|
|
1083
1030
|
};
|
|
1084
|
-
};
|
|
1031
|
+
}, "useAuthScreen");
|
|
1085
1032
|
export { Auth, AuthConfirmSignUpCheckEmail, AuthConfirmSignUpWithCode, AuthForgotPassword, AuthForgotPasswordResetPassword, AuthFullScreen, AuthProvider, AuthSignIn, AuthSignUp, ErrorBoundary, useAuth, useAuthScreen };
|