@rqdhw3n/react-auth-flow 1.0.1 → 1.0.2
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/index.cjs.js +1865 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +293 -0
- package/dist/index.es.js +1865 -0
- package/dist/index.es.js.map +1 -0
- package/package.json +12 -10
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,1865 @@
|
|
|
1
|
+
import require$$0, { createContext, useReducer, useCallback, useEffect, useContext, useState } from "react";
|
|
2
|
+
import { Navigate } from "react-router-dom";
|
|
3
|
+
var jsxRuntime = { exports: {} };
|
|
4
|
+
var reactJsxRuntime_production_min = {};
|
|
5
|
+
/**
|
|
6
|
+
* @license React
|
|
7
|
+
* react-jsx-runtime.production.min.js
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the MIT license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*/
|
|
14
|
+
var hasRequiredReactJsxRuntime_production_min;
|
|
15
|
+
function requireReactJsxRuntime_production_min() {
|
|
16
|
+
if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
|
|
17
|
+
hasRequiredReactJsxRuntime_production_min = 1;
|
|
18
|
+
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
|
|
19
|
+
function q(c, a, g) {
|
|
20
|
+
var b, d = {}, e = null, h = null;
|
|
21
|
+
void 0 !== g && (e = "" + g);
|
|
22
|
+
void 0 !== a.key && (e = "" + a.key);
|
|
23
|
+
void 0 !== a.ref && (h = a.ref);
|
|
24
|
+
for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
25
|
+
if (c && c.defaultProps) for (b in a = c.defaultProps, a) void 0 === d[b] && (d[b] = a[b]);
|
|
26
|
+
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
27
|
+
}
|
|
28
|
+
reactJsxRuntime_production_min.Fragment = l;
|
|
29
|
+
reactJsxRuntime_production_min.jsx = q;
|
|
30
|
+
reactJsxRuntime_production_min.jsxs = q;
|
|
31
|
+
return reactJsxRuntime_production_min;
|
|
32
|
+
}
|
|
33
|
+
var reactJsxRuntime_development = {};
|
|
34
|
+
/**
|
|
35
|
+
* @license React
|
|
36
|
+
* react-jsx-runtime.development.js
|
|
37
|
+
*
|
|
38
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the MIT license found in the
|
|
41
|
+
* LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/
|
|
43
|
+
var hasRequiredReactJsxRuntime_development;
|
|
44
|
+
function requireReactJsxRuntime_development() {
|
|
45
|
+
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
46
|
+
hasRequiredReactJsxRuntime_development = 1;
|
|
47
|
+
if (process.env.NODE_ENV !== "production") {
|
|
48
|
+
(function() {
|
|
49
|
+
var React = require$$0;
|
|
50
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.element");
|
|
51
|
+
var REACT_PORTAL_TYPE = Symbol.for("react.portal");
|
|
52
|
+
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
53
|
+
var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
|
|
54
|
+
var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
|
55
|
+
var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
|
|
56
|
+
var REACT_CONTEXT_TYPE = Symbol.for("react.context");
|
|
57
|
+
var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
|
|
58
|
+
var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
|
|
59
|
+
var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
|
|
60
|
+
var REACT_MEMO_TYPE = Symbol.for("react.memo");
|
|
61
|
+
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
|
62
|
+
var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
|
|
63
|
+
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
|
64
|
+
var FAUX_ITERATOR_SYMBOL = "@@iterator";
|
|
65
|
+
function getIteratorFn(maybeIterable) {
|
|
66
|
+
if (maybeIterable === null || typeof maybeIterable !== "object") {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
70
|
+
if (typeof maybeIterator === "function") {
|
|
71
|
+
return maybeIterator;
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
76
|
+
function error(format) {
|
|
77
|
+
{
|
|
78
|
+
{
|
|
79
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
80
|
+
args[_key2 - 1] = arguments[_key2];
|
|
81
|
+
}
|
|
82
|
+
printWarning("error", format, args);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function printWarning(level, format, args) {
|
|
87
|
+
{
|
|
88
|
+
var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
89
|
+
var stack = ReactDebugCurrentFrame2.getStackAddendum();
|
|
90
|
+
if (stack !== "") {
|
|
91
|
+
format += "%s";
|
|
92
|
+
args = args.concat([stack]);
|
|
93
|
+
}
|
|
94
|
+
var argsWithFormat = args.map(function(item) {
|
|
95
|
+
return String(item);
|
|
96
|
+
});
|
|
97
|
+
argsWithFormat.unshift("Warning: " + format);
|
|
98
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
var enableScopeAPI = false;
|
|
102
|
+
var enableCacheElement = false;
|
|
103
|
+
var enableTransitionTracing = false;
|
|
104
|
+
var enableLegacyHidden = false;
|
|
105
|
+
var enableDebugTracing = false;
|
|
106
|
+
var REACT_MODULE_REFERENCE;
|
|
107
|
+
{
|
|
108
|
+
REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
|
|
109
|
+
}
|
|
110
|
+
function isValidElementType(type) {
|
|
111
|
+
if (typeof type === "string" || typeof type === "function") {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
if (typeof type === "object" && type !== null) {
|
|
118
|
+
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
|
|
119
|
+
// types supported by any Flight configuration anywhere since
|
|
120
|
+
// we don't know which Flight build this will end up being used
|
|
121
|
+
// with.
|
|
122
|
+
type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
function getWrappedName(outerType, innerType, wrapperName) {
|
|
129
|
+
var displayName = outerType.displayName;
|
|
130
|
+
if (displayName) {
|
|
131
|
+
return displayName;
|
|
132
|
+
}
|
|
133
|
+
var functionName = innerType.displayName || innerType.name || "";
|
|
134
|
+
return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
|
|
135
|
+
}
|
|
136
|
+
function getContextName(type) {
|
|
137
|
+
return type.displayName || "Context";
|
|
138
|
+
}
|
|
139
|
+
function getComponentNameFromType(type) {
|
|
140
|
+
if (type == null) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
{
|
|
144
|
+
if (typeof type.tag === "number") {
|
|
145
|
+
error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (typeof type === "function") {
|
|
149
|
+
return type.displayName || type.name || null;
|
|
150
|
+
}
|
|
151
|
+
if (typeof type === "string") {
|
|
152
|
+
return type;
|
|
153
|
+
}
|
|
154
|
+
switch (type) {
|
|
155
|
+
case REACT_FRAGMENT_TYPE:
|
|
156
|
+
return "Fragment";
|
|
157
|
+
case REACT_PORTAL_TYPE:
|
|
158
|
+
return "Portal";
|
|
159
|
+
case REACT_PROFILER_TYPE:
|
|
160
|
+
return "Profiler";
|
|
161
|
+
case REACT_STRICT_MODE_TYPE:
|
|
162
|
+
return "StrictMode";
|
|
163
|
+
case REACT_SUSPENSE_TYPE:
|
|
164
|
+
return "Suspense";
|
|
165
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
166
|
+
return "SuspenseList";
|
|
167
|
+
}
|
|
168
|
+
if (typeof type === "object") {
|
|
169
|
+
switch (type.$$typeof) {
|
|
170
|
+
case REACT_CONTEXT_TYPE:
|
|
171
|
+
var context = type;
|
|
172
|
+
return getContextName(context) + ".Consumer";
|
|
173
|
+
case REACT_PROVIDER_TYPE:
|
|
174
|
+
var provider = type;
|
|
175
|
+
return getContextName(provider._context) + ".Provider";
|
|
176
|
+
case REACT_FORWARD_REF_TYPE:
|
|
177
|
+
return getWrappedName(type, type.render, "ForwardRef");
|
|
178
|
+
case REACT_MEMO_TYPE:
|
|
179
|
+
var outerName = type.displayName || null;
|
|
180
|
+
if (outerName !== null) {
|
|
181
|
+
return outerName;
|
|
182
|
+
}
|
|
183
|
+
return getComponentNameFromType(type.type) || "Memo";
|
|
184
|
+
case REACT_LAZY_TYPE: {
|
|
185
|
+
var lazyComponent = type;
|
|
186
|
+
var payload = lazyComponent._payload;
|
|
187
|
+
var init = lazyComponent._init;
|
|
188
|
+
try {
|
|
189
|
+
return getComponentNameFromType(init(payload));
|
|
190
|
+
} catch (x) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
var assign = Object.assign;
|
|
199
|
+
var disabledDepth = 0;
|
|
200
|
+
var prevLog;
|
|
201
|
+
var prevInfo;
|
|
202
|
+
var prevWarn;
|
|
203
|
+
var prevError;
|
|
204
|
+
var prevGroup;
|
|
205
|
+
var prevGroupCollapsed;
|
|
206
|
+
var prevGroupEnd;
|
|
207
|
+
function disabledLog() {
|
|
208
|
+
}
|
|
209
|
+
disabledLog.__reactDisabledLog = true;
|
|
210
|
+
function disableLogs() {
|
|
211
|
+
{
|
|
212
|
+
if (disabledDepth === 0) {
|
|
213
|
+
prevLog = console.log;
|
|
214
|
+
prevInfo = console.info;
|
|
215
|
+
prevWarn = console.warn;
|
|
216
|
+
prevError = console.error;
|
|
217
|
+
prevGroup = console.group;
|
|
218
|
+
prevGroupCollapsed = console.groupCollapsed;
|
|
219
|
+
prevGroupEnd = console.groupEnd;
|
|
220
|
+
var props = {
|
|
221
|
+
configurable: true,
|
|
222
|
+
enumerable: true,
|
|
223
|
+
value: disabledLog,
|
|
224
|
+
writable: true
|
|
225
|
+
};
|
|
226
|
+
Object.defineProperties(console, {
|
|
227
|
+
info: props,
|
|
228
|
+
log: props,
|
|
229
|
+
warn: props,
|
|
230
|
+
error: props,
|
|
231
|
+
group: props,
|
|
232
|
+
groupCollapsed: props,
|
|
233
|
+
groupEnd: props
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
disabledDepth++;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function reenableLogs() {
|
|
240
|
+
{
|
|
241
|
+
disabledDepth--;
|
|
242
|
+
if (disabledDepth === 0) {
|
|
243
|
+
var props = {
|
|
244
|
+
configurable: true,
|
|
245
|
+
enumerable: true,
|
|
246
|
+
writable: true
|
|
247
|
+
};
|
|
248
|
+
Object.defineProperties(console, {
|
|
249
|
+
log: assign({}, props, {
|
|
250
|
+
value: prevLog
|
|
251
|
+
}),
|
|
252
|
+
info: assign({}, props, {
|
|
253
|
+
value: prevInfo
|
|
254
|
+
}),
|
|
255
|
+
warn: assign({}, props, {
|
|
256
|
+
value: prevWarn
|
|
257
|
+
}),
|
|
258
|
+
error: assign({}, props, {
|
|
259
|
+
value: prevError
|
|
260
|
+
}),
|
|
261
|
+
group: assign({}, props, {
|
|
262
|
+
value: prevGroup
|
|
263
|
+
}),
|
|
264
|
+
groupCollapsed: assign({}, props, {
|
|
265
|
+
value: prevGroupCollapsed
|
|
266
|
+
}),
|
|
267
|
+
groupEnd: assign({}, props, {
|
|
268
|
+
value: prevGroupEnd
|
|
269
|
+
})
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
if (disabledDepth < 0) {
|
|
273
|
+
error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
278
|
+
var prefix;
|
|
279
|
+
function describeBuiltInComponentFrame(name, source, ownerFn) {
|
|
280
|
+
{
|
|
281
|
+
if (prefix === void 0) {
|
|
282
|
+
try {
|
|
283
|
+
throw Error();
|
|
284
|
+
} catch (x) {
|
|
285
|
+
var match = x.stack.trim().match(/\n( *(at )?)/);
|
|
286
|
+
prefix = match && match[1] || "";
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return "\n" + prefix + name;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
var reentry = false;
|
|
293
|
+
var componentFrameCache;
|
|
294
|
+
{
|
|
295
|
+
var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
|
|
296
|
+
componentFrameCache = new PossiblyWeakMap();
|
|
297
|
+
}
|
|
298
|
+
function describeNativeComponentFrame(fn, construct) {
|
|
299
|
+
if (!fn || reentry) {
|
|
300
|
+
return "";
|
|
301
|
+
}
|
|
302
|
+
{
|
|
303
|
+
var frame = componentFrameCache.get(fn);
|
|
304
|
+
if (frame !== void 0) {
|
|
305
|
+
return frame;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
var control;
|
|
309
|
+
reentry = true;
|
|
310
|
+
var previousPrepareStackTrace = Error.prepareStackTrace;
|
|
311
|
+
Error.prepareStackTrace = void 0;
|
|
312
|
+
var previousDispatcher;
|
|
313
|
+
{
|
|
314
|
+
previousDispatcher = ReactCurrentDispatcher.current;
|
|
315
|
+
ReactCurrentDispatcher.current = null;
|
|
316
|
+
disableLogs();
|
|
317
|
+
}
|
|
318
|
+
try {
|
|
319
|
+
if (construct) {
|
|
320
|
+
var Fake = function() {
|
|
321
|
+
throw Error();
|
|
322
|
+
};
|
|
323
|
+
Object.defineProperty(Fake.prototype, "props", {
|
|
324
|
+
set: function() {
|
|
325
|
+
throw Error();
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
if (typeof Reflect === "object" && Reflect.construct) {
|
|
329
|
+
try {
|
|
330
|
+
Reflect.construct(Fake, []);
|
|
331
|
+
} catch (x) {
|
|
332
|
+
control = x;
|
|
333
|
+
}
|
|
334
|
+
Reflect.construct(fn, [], Fake);
|
|
335
|
+
} else {
|
|
336
|
+
try {
|
|
337
|
+
Fake.call();
|
|
338
|
+
} catch (x) {
|
|
339
|
+
control = x;
|
|
340
|
+
}
|
|
341
|
+
fn.call(Fake.prototype);
|
|
342
|
+
}
|
|
343
|
+
} else {
|
|
344
|
+
try {
|
|
345
|
+
throw Error();
|
|
346
|
+
} catch (x) {
|
|
347
|
+
control = x;
|
|
348
|
+
}
|
|
349
|
+
fn();
|
|
350
|
+
}
|
|
351
|
+
} catch (sample) {
|
|
352
|
+
if (sample && control && typeof sample.stack === "string") {
|
|
353
|
+
var sampleLines = sample.stack.split("\n");
|
|
354
|
+
var controlLines = control.stack.split("\n");
|
|
355
|
+
var s = sampleLines.length - 1;
|
|
356
|
+
var c = controlLines.length - 1;
|
|
357
|
+
while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
|
|
358
|
+
c--;
|
|
359
|
+
}
|
|
360
|
+
for (; s >= 1 && c >= 0; s--, c--) {
|
|
361
|
+
if (sampleLines[s] !== controlLines[c]) {
|
|
362
|
+
if (s !== 1 || c !== 1) {
|
|
363
|
+
do {
|
|
364
|
+
s--;
|
|
365
|
+
c--;
|
|
366
|
+
if (c < 0 || sampleLines[s] !== controlLines[c]) {
|
|
367
|
+
var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
|
|
368
|
+
if (fn.displayName && _frame.includes("<anonymous>")) {
|
|
369
|
+
_frame = _frame.replace("<anonymous>", fn.displayName);
|
|
370
|
+
}
|
|
371
|
+
{
|
|
372
|
+
if (typeof fn === "function") {
|
|
373
|
+
componentFrameCache.set(fn, _frame);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return _frame;
|
|
377
|
+
}
|
|
378
|
+
} while (s >= 1 && c >= 0);
|
|
379
|
+
}
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
} finally {
|
|
385
|
+
reentry = false;
|
|
386
|
+
{
|
|
387
|
+
ReactCurrentDispatcher.current = previousDispatcher;
|
|
388
|
+
reenableLogs();
|
|
389
|
+
}
|
|
390
|
+
Error.prepareStackTrace = previousPrepareStackTrace;
|
|
391
|
+
}
|
|
392
|
+
var name = fn ? fn.displayName || fn.name : "";
|
|
393
|
+
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
|
|
394
|
+
{
|
|
395
|
+
if (typeof fn === "function") {
|
|
396
|
+
componentFrameCache.set(fn, syntheticFrame);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return syntheticFrame;
|
|
400
|
+
}
|
|
401
|
+
function describeFunctionComponentFrame(fn, source, ownerFn) {
|
|
402
|
+
{
|
|
403
|
+
return describeNativeComponentFrame(fn, false);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
function shouldConstruct(Component) {
|
|
407
|
+
var prototype = Component.prototype;
|
|
408
|
+
return !!(prototype && prototype.isReactComponent);
|
|
409
|
+
}
|
|
410
|
+
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
|
411
|
+
if (type == null) {
|
|
412
|
+
return "";
|
|
413
|
+
}
|
|
414
|
+
if (typeof type === "function") {
|
|
415
|
+
{
|
|
416
|
+
return describeNativeComponentFrame(type, shouldConstruct(type));
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
if (typeof type === "string") {
|
|
420
|
+
return describeBuiltInComponentFrame(type);
|
|
421
|
+
}
|
|
422
|
+
switch (type) {
|
|
423
|
+
case REACT_SUSPENSE_TYPE:
|
|
424
|
+
return describeBuiltInComponentFrame("Suspense");
|
|
425
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
426
|
+
return describeBuiltInComponentFrame("SuspenseList");
|
|
427
|
+
}
|
|
428
|
+
if (typeof type === "object") {
|
|
429
|
+
switch (type.$$typeof) {
|
|
430
|
+
case REACT_FORWARD_REF_TYPE:
|
|
431
|
+
return describeFunctionComponentFrame(type.render);
|
|
432
|
+
case REACT_MEMO_TYPE:
|
|
433
|
+
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
|
|
434
|
+
case REACT_LAZY_TYPE: {
|
|
435
|
+
var lazyComponent = type;
|
|
436
|
+
var payload = lazyComponent._payload;
|
|
437
|
+
var init = lazyComponent._init;
|
|
438
|
+
try {
|
|
439
|
+
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
|
|
440
|
+
} catch (x) {
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return "";
|
|
446
|
+
}
|
|
447
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
448
|
+
var loggedTypeFailures = {};
|
|
449
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
450
|
+
function setCurrentlyValidatingElement(element) {
|
|
451
|
+
{
|
|
452
|
+
if (element) {
|
|
453
|
+
var owner = element._owner;
|
|
454
|
+
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
455
|
+
ReactDebugCurrentFrame.setExtraStackFrame(stack);
|
|
456
|
+
} else {
|
|
457
|
+
ReactDebugCurrentFrame.setExtraStackFrame(null);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
462
|
+
{
|
|
463
|
+
var has = Function.call.bind(hasOwnProperty);
|
|
464
|
+
for (var typeSpecName in typeSpecs) {
|
|
465
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
466
|
+
var error$1 = void 0;
|
|
467
|
+
try {
|
|
468
|
+
if (typeof typeSpecs[typeSpecName] !== "function") {
|
|
469
|
+
var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
470
|
+
err.name = "Invariant Violation";
|
|
471
|
+
throw err;
|
|
472
|
+
}
|
|
473
|
+
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
474
|
+
} catch (ex) {
|
|
475
|
+
error$1 = ex;
|
|
476
|
+
}
|
|
477
|
+
if (error$1 && !(error$1 instanceof Error)) {
|
|
478
|
+
setCurrentlyValidatingElement(element);
|
|
479
|
+
error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
|
|
480
|
+
setCurrentlyValidatingElement(null);
|
|
481
|
+
}
|
|
482
|
+
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
|
483
|
+
loggedTypeFailures[error$1.message] = true;
|
|
484
|
+
setCurrentlyValidatingElement(element);
|
|
485
|
+
error("Failed %s type: %s", location, error$1.message);
|
|
486
|
+
setCurrentlyValidatingElement(null);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
var isArrayImpl = Array.isArray;
|
|
493
|
+
function isArray(a) {
|
|
494
|
+
return isArrayImpl(a);
|
|
495
|
+
}
|
|
496
|
+
function typeName(value) {
|
|
497
|
+
{
|
|
498
|
+
var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
|
|
499
|
+
var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
|
500
|
+
return type;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
function willCoercionThrow(value) {
|
|
504
|
+
{
|
|
505
|
+
try {
|
|
506
|
+
testStringCoercion(value);
|
|
507
|
+
return false;
|
|
508
|
+
} catch (e) {
|
|
509
|
+
return true;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
function testStringCoercion(value) {
|
|
514
|
+
return "" + value;
|
|
515
|
+
}
|
|
516
|
+
function checkKeyStringCoercion(value) {
|
|
517
|
+
{
|
|
518
|
+
if (willCoercionThrow(value)) {
|
|
519
|
+
error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
|
|
520
|
+
return testStringCoercion(value);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
|
525
|
+
var RESERVED_PROPS = {
|
|
526
|
+
key: true,
|
|
527
|
+
ref: true,
|
|
528
|
+
__self: true,
|
|
529
|
+
__source: true
|
|
530
|
+
};
|
|
531
|
+
var specialPropKeyWarningShown;
|
|
532
|
+
var specialPropRefWarningShown;
|
|
533
|
+
function hasValidRef(config) {
|
|
534
|
+
{
|
|
535
|
+
if (hasOwnProperty.call(config, "ref")) {
|
|
536
|
+
var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
|
|
537
|
+
if (getter && getter.isReactWarning) {
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return config.ref !== void 0;
|
|
543
|
+
}
|
|
544
|
+
function hasValidKey(config) {
|
|
545
|
+
{
|
|
546
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
547
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
548
|
+
if (getter && getter.isReactWarning) {
|
|
549
|
+
return false;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return config.key !== void 0;
|
|
554
|
+
}
|
|
555
|
+
function warnIfStringRefCannotBeAutoConverted(config, self) {
|
|
556
|
+
{
|
|
557
|
+
if (typeof config.ref === "string" && ReactCurrentOwner.current && self) ;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
561
|
+
{
|
|
562
|
+
var warnAboutAccessingKey = function() {
|
|
563
|
+
if (!specialPropKeyWarningShown) {
|
|
564
|
+
specialPropKeyWarningShown = true;
|
|
565
|
+
error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
569
|
+
Object.defineProperty(props, "key", {
|
|
570
|
+
get: warnAboutAccessingKey,
|
|
571
|
+
configurable: true
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
function defineRefPropWarningGetter(props, displayName) {
|
|
576
|
+
{
|
|
577
|
+
var warnAboutAccessingRef = function() {
|
|
578
|
+
if (!specialPropRefWarningShown) {
|
|
579
|
+
specialPropRefWarningShown = true;
|
|
580
|
+
error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
warnAboutAccessingRef.isReactWarning = true;
|
|
584
|
+
Object.defineProperty(props, "ref", {
|
|
585
|
+
get: warnAboutAccessingRef,
|
|
586
|
+
configurable: true
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
var ReactElement = function(type, key, ref, self, source, owner, props) {
|
|
591
|
+
var element = {
|
|
592
|
+
// This tag allows us to uniquely identify this as a React Element
|
|
593
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
594
|
+
// Built-in properties that belong on the element
|
|
595
|
+
type,
|
|
596
|
+
key,
|
|
597
|
+
ref,
|
|
598
|
+
props,
|
|
599
|
+
// Record the component responsible for creating this element.
|
|
600
|
+
_owner: owner
|
|
601
|
+
};
|
|
602
|
+
{
|
|
603
|
+
element._store = {};
|
|
604
|
+
Object.defineProperty(element._store, "validated", {
|
|
605
|
+
configurable: false,
|
|
606
|
+
enumerable: false,
|
|
607
|
+
writable: true,
|
|
608
|
+
value: false
|
|
609
|
+
});
|
|
610
|
+
Object.defineProperty(element, "_self", {
|
|
611
|
+
configurable: false,
|
|
612
|
+
enumerable: false,
|
|
613
|
+
writable: false,
|
|
614
|
+
value: self
|
|
615
|
+
});
|
|
616
|
+
Object.defineProperty(element, "_source", {
|
|
617
|
+
configurable: false,
|
|
618
|
+
enumerable: false,
|
|
619
|
+
writable: false,
|
|
620
|
+
value: source
|
|
621
|
+
});
|
|
622
|
+
if (Object.freeze) {
|
|
623
|
+
Object.freeze(element.props);
|
|
624
|
+
Object.freeze(element);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return element;
|
|
628
|
+
};
|
|
629
|
+
function jsxDEV(type, config, maybeKey, source, self) {
|
|
630
|
+
{
|
|
631
|
+
var propName;
|
|
632
|
+
var props = {};
|
|
633
|
+
var key = null;
|
|
634
|
+
var ref = null;
|
|
635
|
+
if (maybeKey !== void 0) {
|
|
636
|
+
{
|
|
637
|
+
checkKeyStringCoercion(maybeKey);
|
|
638
|
+
}
|
|
639
|
+
key = "" + maybeKey;
|
|
640
|
+
}
|
|
641
|
+
if (hasValidKey(config)) {
|
|
642
|
+
{
|
|
643
|
+
checkKeyStringCoercion(config.key);
|
|
644
|
+
}
|
|
645
|
+
key = "" + config.key;
|
|
646
|
+
}
|
|
647
|
+
if (hasValidRef(config)) {
|
|
648
|
+
ref = config.ref;
|
|
649
|
+
warnIfStringRefCannotBeAutoConverted(config, self);
|
|
650
|
+
}
|
|
651
|
+
for (propName in config) {
|
|
652
|
+
if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
653
|
+
props[propName] = config[propName];
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
if (type && type.defaultProps) {
|
|
657
|
+
var defaultProps = type.defaultProps;
|
|
658
|
+
for (propName in defaultProps) {
|
|
659
|
+
if (props[propName] === void 0) {
|
|
660
|
+
props[propName] = defaultProps[propName];
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
if (key || ref) {
|
|
665
|
+
var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
|
|
666
|
+
if (key) {
|
|
667
|
+
defineKeyPropWarningGetter(props, displayName);
|
|
668
|
+
}
|
|
669
|
+
if (ref) {
|
|
670
|
+
defineRefPropWarningGetter(props, displayName);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
|
677
|
+
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
678
|
+
function setCurrentlyValidatingElement$1(element) {
|
|
679
|
+
{
|
|
680
|
+
if (element) {
|
|
681
|
+
var owner = element._owner;
|
|
682
|
+
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
683
|
+
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
|
|
684
|
+
} else {
|
|
685
|
+
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
var propTypesMisspellWarningShown;
|
|
690
|
+
{
|
|
691
|
+
propTypesMisspellWarningShown = false;
|
|
692
|
+
}
|
|
693
|
+
function isValidElement(object) {
|
|
694
|
+
{
|
|
695
|
+
return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
function getDeclarationErrorAddendum() {
|
|
699
|
+
{
|
|
700
|
+
if (ReactCurrentOwner$1.current) {
|
|
701
|
+
var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
|
|
702
|
+
if (name) {
|
|
703
|
+
return "\n\nCheck the render method of `" + name + "`.";
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return "";
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
function getSourceInfoErrorAddendum(source) {
|
|
710
|
+
{
|
|
711
|
+
return "";
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
var ownerHasKeyUseWarning = {};
|
|
715
|
+
function getCurrentComponentErrorInfo(parentType) {
|
|
716
|
+
{
|
|
717
|
+
var info = getDeclarationErrorAddendum();
|
|
718
|
+
if (!info) {
|
|
719
|
+
var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
|
|
720
|
+
if (parentName) {
|
|
721
|
+
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
return info;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
function validateExplicitKey(element, parentType) {
|
|
728
|
+
{
|
|
729
|
+
if (!element._store || element._store.validated || element.key != null) {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
element._store.validated = true;
|
|
733
|
+
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
734
|
+
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
|
738
|
+
var childOwner = "";
|
|
739
|
+
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
|
|
740
|
+
childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
|
|
741
|
+
}
|
|
742
|
+
setCurrentlyValidatingElement$1(element);
|
|
743
|
+
error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
744
|
+
setCurrentlyValidatingElement$1(null);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
function validateChildKeys(node, parentType) {
|
|
748
|
+
{
|
|
749
|
+
if (typeof node !== "object") {
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
if (isArray(node)) {
|
|
753
|
+
for (var i = 0; i < node.length; i++) {
|
|
754
|
+
var child = node[i];
|
|
755
|
+
if (isValidElement(child)) {
|
|
756
|
+
validateExplicitKey(child, parentType);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
} else if (isValidElement(node)) {
|
|
760
|
+
if (node._store) {
|
|
761
|
+
node._store.validated = true;
|
|
762
|
+
}
|
|
763
|
+
} else if (node) {
|
|
764
|
+
var iteratorFn = getIteratorFn(node);
|
|
765
|
+
if (typeof iteratorFn === "function") {
|
|
766
|
+
if (iteratorFn !== node.entries) {
|
|
767
|
+
var iterator = iteratorFn.call(node);
|
|
768
|
+
var step;
|
|
769
|
+
while (!(step = iterator.next()).done) {
|
|
770
|
+
if (isValidElement(step.value)) {
|
|
771
|
+
validateExplicitKey(step.value, parentType);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
function validatePropTypes(element) {
|
|
780
|
+
{
|
|
781
|
+
var type = element.type;
|
|
782
|
+
if (type === null || type === void 0 || typeof type === "string") {
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
var propTypes;
|
|
786
|
+
if (typeof type === "function") {
|
|
787
|
+
propTypes = type.propTypes;
|
|
788
|
+
} else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
|
789
|
+
// Inner props are checked in the reconciler.
|
|
790
|
+
type.$$typeof === REACT_MEMO_TYPE)) {
|
|
791
|
+
propTypes = type.propTypes;
|
|
792
|
+
} else {
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
if (propTypes) {
|
|
796
|
+
var name = getComponentNameFromType(type);
|
|
797
|
+
checkPropTypes(propTypes, element.props, "prop", name, element);
|
|
798
|
+
} else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
|
|
799
|
+
propTypesMisspellWarningShown = true;
|
|
800
|
+
var _name = getComponentNameFromType(type);
|
|
801
|
+
error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
|
|
802
|
+
}
|
|
803
|
+
if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
|
|
804
|
+
error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
function validateFragmentProps(fragment) {
|
|
809
|
+
{
|
|
810
|
+
var keys = Object.keys(fragment.props);
|
|
811
|
+
for (var i = 0; i < keys.length; i++) {
|
|
812
|
+
var key = keys[i];
|
|
813
|
+
if (key !== "children" && key !== "key") {
|
|
814
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
815
|
+
error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
|
|
816
|
+
setCurrentlyValidatingElement$1(null);
|
|
817
|
+
break;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
if (fragment.ref !== null) {
|
|
821
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
822
|
+
error("Invalid attribute `ref` supplied to `React.Fragment`.");
|
|
823
|
+
setCurrentlyValidatingElement$1(null);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
var didWarnAboutKeySpread = {};
|
|
828
|
+
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
|
829
|
+
{
|
|
830
|
+
var validType = isValidElementType(type);
|
|
831
|
+
if (!validType) {
|
|
832
|
+
var info = "";
|
|
833
|
+
if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
|
|
834
|
+
info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
|
|
835
|
+
}
|
|
836
|
+
var sourceInfo = getSourceInfoErrorAddendum();
|
|
837
|
+
if (sourceInfo) {
|
|
838
|
+
info += sourceInfo;
|
|
839
|
+
} else {
|
|
840
|
+
info += getDeclarationErrorAddendum();
|
|
841
|
+
}
|
|
842
|
+
var typeString;
|
|
843
|
+
if (type === null) {
|
|
844
|
+
typeString = "null";
|
|
845
|
+
} else if (isArray(type)) {
|
|
846
|
+
typeString = "array";
|
|
847
|
+
} else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
848
|
+
typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
|
|
849
|
+
info = " Did you accidentally export a JSX literal instead of a component?";
|
|
850
|
+
} else {
|
|
851
|
+
typeString = typeof type;
|
|
852
|
+
}
|
|
853
|
+
error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
|
|
854
|
+
}
|
|
855
|
+
var element = jsxDEV(type, props, key, source, self);
|
|
856
|
+
if (element == null) {
|
|
857
|
+
return element;
|
|
858
|
+
}
|
|
859
|
+
if (validType) {
|
|
860
|
+
var children = props.children;
|
|
861
|
+
if (children !== void 0) {
|
|
862
|
+
if (isStaticChildren) {
|
|
863
|
+
if (isArray(children)) {
|
|
864
|
+
for (var i = 0; i < children.length; i++) {
|
|
865
|
+
validateChildKeys(children[i], type);
|
|
866
|
+
}
|
|
867
|
+
if (Object.freeze) {
|
|
868
|
+
Object.freeze(children);
|
|
869
|
+
}
|
|
870
|
+
} else {
|
|
871
|
+
error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
872
|
+
}
|
|
873
|
+
} else {
|
|
874
|
+
validateChildKeys(children, type);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
{
|
|
879
|
+
if (hasOwnProperty.call(props, "key")) {
|
|
880
|
+
var componentName = getComponentNameFromType(type);
|
|
881
|
+
var keys = Object.keys(props).filter(function(k) {
|
|
882
|
+
return k !== "key";
|
|
883
|
+
});
|
|
884
|
+
var beforeExample = keys.length > 0 ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
885
|
+
if (!didWarnAboutKeySpread[componentName + beforeExample]) {
|
|
886
|
+
var afterExample = keys.length > 0 ? "{" + keys.join(": ..., ") + ": ...}" : "{}";
|
|
887
|
+
error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
|
|
888
|
+
didWarnAboutKeySpread[componentName + beforeExample] = true;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
|
893
|
+
validateFragmentProps(element);
|
|
894
|
+
} else {
|
|
895
|
+
validatePropTypes(element);
|
|
896
|
+
}
|
|
897
|
+
return element;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
function jsxWithValidationStatic(type, props, key) {
|
|
901
|
+
{
|
|
902
|
+
return jsxWithValidation(type, props, key, true);
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
function jsxWithValidationDynamic(type, props, key) {
|
|
906
|
+
{
|
|
907
|
+
return jsxWithValidation(type, props, key, false);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
var jsx = jsxWithValidationDynamic;
|
|
911
|
+
var jsxs = jsxWithValidationStatic;
|
|
912
|
+
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
913
|
+
reactJsxRuntime_development.jsx = jsx;
|
|
914
|
+
reactJsxRuntime_development.jsxs = jsxs;
|
|
915
|
+
})();
|
|
916
|
+
}
|
|
917
|
+
return reactJsxRuntime_development;
|
|
918
|
+
}
|
|
919
|
+
if (process.env.NODE_ENV === "production") {
|
|
920
|
+
jsxRuntime.exports = requireReactJsxRuntime_production_min();
|
|
921
|
+
} else {
|
|
922
|
+
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
923
|
+
}
|
|
924
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
|
925
|
+
const AuthContext = createContext(
|
|
926
|
+
void 0
|
|
927
|
+
);
|
|
928
|
+
AuthContext.displayName = "AuthContext";
|
|
929
|
+
function normalizeError(error) {
|
|
930
|
+
if (isAuthError(error)) {
|
|
931
|
+
return error;
|
|
932
|
+
}
|
|
933
|
+
if (error instanceof Error) {
|
|
934
|
+
return {
|
|
935
|
+
code: "ERROR",
|
|
936
|
+
message: error.message,
|
|
937
|
+
statusCode: void 0
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
if (typeof error === "object" && error !== null && "status" in error && "statusText" in error) {
|
|
941
|
+
const fetchError = error;
|
|
942
|
+
return {
|
|
943
|
+
code: `HTTP_${fetchError.status}`,
|
|
944
|
+
message: fetchError.statusText || "Request failed",
|
|
945
|
+
statusCode: fetchError.status
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
if (typeof error === "object" && error !== null && "error" in error && typeof error.error === "object") {
|
|
949
|
+
const apiError = error.error;
|
|
950
|
+
return {
|
|
951
|
+
code: apiError.code || "API_ERROR",
|
|
952
|
+
message: apiError.message || "An error occurred",
|
|
953
|
+
statusCode: apiError.statusCode || void 0,
|
|
954
|
+
details: apiError.details
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
if (typeof error === "object" && error !== null && "message" in error) {
|
|
958
|
+
const objError = error;
|
|
959
|
+
return {
|
|
960
|
+
code: objError.code || "ERROR",
|
|
961
|
+
message: typeof objError.message === "string" ? objError.message : "An unknown error occurred"
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
if (typeof error === "string") {
|
|
965
|
+
return {
|
|
966
|
+
code: "ERROR",
|
|
967
|
+
message: error
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
return {
|
|
971
|
+
code: "UNKNOWN_ERROR",
|
|
972
|
+
message: "An unknown error occurred"
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
function isAuthError(error) {
|
|
976
|
+
return typeof error === "object" && error !== null && "code" in error && "message" in error && typeof error.code === "string" && typeof error.message === "string";
|
|
977
|
+
}
|
|
978
|
+
const DEFAULT_ENDPOINTS = {
|
|
979
|
+
login: "/auth/login",
|
|
980
|
+
register: "/auth/register",
|
|
981
|
+
logout: "/auth/logout",
|
|
982
|
+
me: "/auth/me",
|
|
983
|
+
refresh: "/auth/refresh",
|
|
984
|
+
forgotPassword: "/auth/forgot-password",
|
|
985
|
+
resetPassword: "/auth/reset-password",
|
|
986
|
+
verifyEmail: "/auth/verify-email"
|
|
987
|
+
};
|
|
988
|
+
const defaultAdapter = async (url, options) => {
|
|
989
|
+
const response = await fetch(url, options);
|
|
990
|
+
return response;
|
|
991
|
+
};
|
|
992
|
+
function createAuthClient(config = {}) {
|
|
993
|
+
const {
|
|
994
|
+
baseURL = "",
|
|
995
|
+
endpoints = {},
|
|
996
|
+
headers = {},
|
|
997
|
+
credentials = "include",
|
|
998
|
+
adapter = defaultAdapter
|
|
999
|
+
} = config;
|
|
1000
|
+
const finalEndpoints = { ...DEFAULT_ENDPOINTS, ...endpoints };
|
|
1001
|
+
async function request(method, endpoint, data) {
|
|
1002
|
+
const url = `${baseURL}${endpoint}`;
|
|
1003
|
+
const options = {
|
|
1004
|
+
method,
|
|
1005
|
+
credentials,
|
|
1006
|
+
headers: {
|
|
1007
|
+
"Content-Type": "application/json",
|
|
1008
|
+
...headers
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
if (data) {
|
|
1012
|
+
options.body = JSON.stringify(data);
|
|
1013
|
+
}
|
|
1014
|
+
try {
|
|
1015
|
+
const response = await adapter(url, options);
|
|
1016
|
+
if (!response.ok) {
|
|
1017
|
+
let errorData = null;
|
|
1018
|
+
try {
|
|
1019
|
+
errorData = await response.json();
|
|
1020
|
+
} catch {
|
|
1021
|
+
errorData = {
|
|
1022
|
+
error: {
|
|
1023
|
+
message: response.statusText,
|
|
1024
|
+
statusCode: response.status
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
throw errorData;
|
|
1029
|
+
}
|
|
1030
|
+
const contentType = response.headers.get("content-type");
|
|
1031
|
+
if (contentType && contentType.includes("application/json")) {
|
|
1032
|
+
return await response.json();
|
|
1033
|
+
}
|
|
1034
|
+
return {};
|
|
1035
|
+
} catch (error) {
|
|
1036
|
+
throw normalizeError(error);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
return {
|
|
1040
|
+
/**
|
|
1041
|
+
* Login with email and password
|
|
1042
|
+
*/
|
|
1043
|
+
async login(email, password, rememberMe) {
|
|
1044
|
+
const response = await request(
|
|
1045
|
+
"POST",
|
|
1046
|
+
finalEndpoints.login,
|
|
1047
|
+
{ email, password, rememberMe }
|
|
1048
|
+
);
|
|
1049
|
+
return response;
|
|
1050
|
+
},
|
|
1051
|
+
/**
|
|
1052
|
+
* Register a new account
|
|
1053
|
+
*/
|
|
1054
|
+
async register(payload) {
|
|
1055
|
+
const response = await request(
|
|
1056
|
+
"POST",
|
|
1057
|
+
finalEndpoints.register,
|
|
1058
|
+
payload
|
|
1059
|
+
);
|
|
1060
|
+
return response;
|
|
1061
|
+
},
|
|
1062
|
+
/**
|
|
1063
|
+
* Logout the user
|
|
1064
|
+
*/
|
|
1065
|
+
async logout() {
|
|
1066
|
+
await request("POST", finalEndpoints.logout);
|
|
1067
|
+
},
|
|
1068
|
+
/**
|
|
1069
|
+
* Get current user
|
|
1070
|
+
*/
|
|
1071
|
+
async me() {
|
|
1072
|
+
const response = await request(
|
|
1073
|
+
"GET",
|
|
1074
|
+
finalEndpoints.me
|
|
1075
|
+
);
|
|
1076
|
+
return response;
|
|
1077
|
+
},
|
|
1078
|
+
/**
|
|
1079
|
+
* Refresh the authentication session
|
|
1080
|
+
*/
|
|
1081
|
+
async refresh() {
|
|
1082
|
+
const response = await request(
|
|
1083
|
+
"POST",
|
|
1084
|
+
finalEndpoints.refresh
|
|
1085
|
+
);
|
|
1086
|
+
return response;
|
|
1087
|
+
},
|
|
1088
|
+
/**
|
|
1089
|
+
* Request a password reset
|
|
1090
|
+
*/
|
|
1091
|
+
async forgotPassword(email) {
|
|
1092
|
+
await request("POST", finalEndpoints.forgotPassword, { email });
|
|
1093
|
+
},
|
|
1094
|
+
/**
|
|
1095
|
+
* Reset password with token
|
|
1096
|
+
*/
|
|
1097
|
+
async resetPassword(token, password, confirmPassword) {
|
|
1098
|
+
await request("POST", finalEndpoints.resetPassword, {
|
|
1099
|
+
token,
|
|
1100
|
+
password,
|
|
1101
|
+
confirmPassword
|
|
1102
|
+
});
|
|
1103
|
+
},
|
|
1104
|
+
/**
|
|
1105
|
+
* Verify email with token
|
|
1106
|
+
*/
|
|
1107
|
+
async verifyEmail(token, email) {
|
|
1108
|
+
await request("POST", finalEndpoints.verifyEmail, { token, email });
|
|
1109
|
+
},
|
|
1110
|
+
/**
|
|
1111
|
+
* Set custom headers for subsequent requests
|
|
1112
|
+
*/
|
|
1113
|
+
setHeaders(newHeaders) {
|
|
1114
|
+
Object.assign(headers, newHeaders);
|
|
1115
|
+
},
|
|
1116
|
+
/**
|
|
1117
|
+
* Get current endpoints configuration
|
|
1118
|
+
*/
|
|
1119
|
+
getEndpoints() {
|
|
1120
|
+
return finalEndpoints;
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
const initialState = {
|
|
1125
|
+
user: null,
|
|
1126
|
+
isAuthenticated: false,
|
|
1127
|
+
isLoading: false,
|
|
1128
|
+
error: null
|
|
1129
|
+
};
|
|
1130
|
+
function authReducer(state, action) {
|
|
1131
|
+
switch (action.type) {
|
|
1132
|
+
case "SET_LOADING":
|
|
1133
|
+
return { ...state, isLoading: action.payload };
|
|
1134
|
+
case "SET_ERROR":
|
|
1135
|
+
return { ...state, error: action.payload, isLoading: false };
|
|
1136
|
+
case "SET_USER":
|
|
1137
|
+
return {
|
|
1138
|
+
...state,
|
|
1139
|
+
user: action.payload,
|
|
1140
|
+
isAuthenticated: action.payload !== null,
|
|
1141
|
+
error: null,
|
|
1142
|
+
isLoading: false
|
|
1143
|
+
};
|
|
1144
|
+
case "LOGOUT":
|
|
1145
|
+
return initialState;
|
|
1146
|
+
default:
|
|
1147
|
+
return state;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
const AuthProvider = ({
|
|
1151
|
+
children,
|
|
1152
|
+
baseURL = "",
|
|
1153
|
+
endpoints = {},
|
|
1154
|
+
onAuthError,
|
|
1155
|
+
autoRefresh = true,
|
|
1156
|
+
refreshInterval = 5 * 60 * 1e3
|
|
1157
|
+
// 5 minutes
|
|
1158
|
+
}) => {
|
|
1159
|
+
const [state, dispatch] = useReducer(authReducer, initialState);
|
|
1160
|
+
const clientRef = require$$0.useRef(
|
|
1161
|
+
createAuthClient({
|
|
1162
|
+
baseURL,
|
|
1163
|
+
endpoints,
|
|
1164
|
+
credentials: "include"
|
|
1165
|
+
})
|
|
1166
|
+
);
|
|
1167
|
+
const client = clientRef.current;
|
|
1168
|
+
const handleError = useCallback(
|
|
1169
|
+
(error) => {
|
|
1170
|
+
dispatch({ type: "SET_ERROR", payload: error });
|
|
1171
|
+
onAuthError?.(error);
|
|
1172
|
+
},
|
|
1173
|
+
[onAuthError]
|
|
1174
|
+
);
|
|
1175
|
+
const restoreSession = useCallback(async () => {
|
|
1176
|
+
dispatch({ type: "SET_LOADING", payload: true });
|
|
1177
|
+
try {
|
|
1178
|
+
const response = await client.me();
|
|
1179
|
+
if (response.user) {
|
|
1180
|
+
dispatch({ type: "SET_USER", payload: response.user });
|
|
1181
|
+
} else {
|
|
1182
|
+
dispatch({ type: "LOGOUT" });
|
|
1183
|
+
}
|
|
1184
|
+
} catch (_error) {
|
|
1185
|
+
dispatch({ type: "SET_LOADING", payload: false });
|
|
1186
|
+
}
|
|
1187
|
+
}, [client]);
|
|
1188
|
+
const refreshSession = useCallback(async () => {
|
|
1189
|
+
try {
|
|
1190
|
+
const response = await client.refresh();
|
|
1191
|
+
if (response.user) {
|
|
1192
|
+
dispatch({ type: "SET_USER", payload: response.user });
|
|
1193
|
+
}
|
|
1194
|
+
} catch (error) {
|
|
1195
|
+
const authError = normalizeError(error);
|
|
1196
|
+
handleError(authError);
|
|
1197
|
+
}
|
|
1198
|
+
}, [client, handleError]);
|
|
1199
|
+
const login = useCallback(
|
|
1200
|
+
async (payload) => {
|
|
1201
|
+
dispatch({ type: "SET_LOADING", payload: true });
|
|
1202
|
+
try {
|
|
1203
|
+
const response = await client.login(payload.email, payload.password);
|
|
1204
|
+
if (!response.user) {
|
|
1205
|
+
throw new Error("No user data in response");
|
|
1206
|
+
}
|
|
1207
|
+
dispatch({ type: "SET_USER", payload: response.user });
|
|
1208
|
+
return response.user;
|
|
1209
|
+
} catch (error) {
|
|
1210
|
+
const authError = normalizeError(error);
|
|
1211
|
+
handleError(authError);
|
|
1212
|
+
throw authError;
|
|
1213
|
+
}
|
|
1214
|
+
},
|
|
1215
|
+
[client, handleError]
|
|
1216
|
+
);
|
|
1217
|
+
const register = useCallback(
|
|
1218
|
+
async (payload) => {
|
|
1219
|
+
dispatch({ type: "SET_LOADING", payload: true });
|
|
1220
|
+
try {
|
|
1221
|
+
const response = await client.register(payload);
|
|
1222
|
+
if (!response.user) {
|
|
1223
|
+
throw new Error("No user data in response");
|
|
1224
|
+
}
|
|
1225
|
+
dispatch({ type: "SET_USER", payload: response.user });
|
|
1226
|
+
return response.user;
|
|
1227
|
+
} catch (error) {
|
|
1228
|
+
const authError = normalizeError(error);
|
|
1229
|
+
handleError(authError);
|
|
1230
|
+
throw authError;
|
|
1231
|
+
}
|
|
1232
|
+
},
|
|
1233
|
+
[client, handleError]
|
|
1234
|
+
);
|
|
1235
|
+
const logout = useCallback(async () => {
|
|
1236
|
+
dispatch({ type: "SET_LOADING", payload: true });
|
|
1237
|
+
try {
|
|
1238
|
+
await client.logout();
|
|
1239
|
+
} catch (error) {
|
|
1240
|
+
console.error("Logout error:", error);
|
|
1241
|
+
} finally {
|
|
1242
|
+
dispatch({ type: "LOGOUT" });
|
|
1243
|
+
}
|
|
1244
|
+
}, [client]);
|
|
1245
|
+
const forgotPassword = useCallback(
|
|
1246
|
+
async (payload) => {
|
|
1247
|
+
dispatch({ type: "SET_LOADING", payload: true });
|
|
1248
|
+
try {
|
|
1249
|
+
await client.forgotPassword(payload.email);
|
|
1250
|
+
dispatch({ type: "SET_LOADING", payload: false });
|
|
1251
|
+
} catch (error) {
|
|
1252
|
+
const authError = normalizeError(error);
|
|
1253
|
+
handleError(authError);
|
|
1254
|
+
throw authError;
|
|
1255
|
+
}
|
|
1256
|
+
},
|
|
1257
|
+
[client, handleError]
|
|
1258
|
+
);
|
|
1259
|
+
const resetPassword = useCallback(
|
|
1260
|
+
async (payload) => {
|
|
1261
|
+
dispatch({ type: "SET_LOADING", payload: true });
|
|
1262
|
+
try {
|
|
1263
|
+
await client.resetPassword(
|
|
1264
|
+
payload.token,
|
|
1265
|
+
payload.password,
|
|
1266
|
+
payload.confirmPassword
|
|
1267
|
+
);
|
|
1268
|
+
dispatch({ type: "SET_LOADING", payload: false });
|
|
1269
|
+
} catch (error) {
|
|
1270
|
+
const authError = normalizeError(error);
|
|
1271
|
+
handleError(authError);
|
|
1272
|
+
throw authError;
|
|
1273
|
+
}
|
|
1274
|
+
},
|
|
1275
|
+
[client, handleError]
|
|
1276
|
+
);
|
|
1277
|
+
const verifyEmail = useCallback(
|
|
1278
|
+
async (payload) => {
|
|
1279
|
+
dispatch({ type: "SET_LOADING", payload: true });
|
|
1280
|
+
try {
|
|
1281
|
+
await client.verifyEmail(payload.token, payload.email);
|
|
1282
|
+
dispatch({ type: "SET_LOADING", payload: false });
|
|
1283
|
+
} catch (error) {
|
|
1284
|
+
const authError = normalizeError(error);
|
|
1285
|
+
handleError(authError);
|
|
1286
|
+
throw authError;
|
|
1287
|
+
}
|
|
1288
|
+
},
|
|
1289
|
+
[client, handleError]
|
|
1290
|
+
);
|
|
1291
|
+
const setUser = useCallback((user) => {
|
|
1292
|
+
dispatch({ type: "SET_USER", payload: user });
|
|
1293
|
+
}, []);
|
|
1294
|
+
useEffect(() => {
|
|
1295
|
+
restoreSession();
|
|
1296
|
+
}, [restoreSession]);
|
|
1297
|
+
useEffect(() => {
|
|
1298
|
+
if (!autoRefresh || !state.isAuthenticated) {
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
const interval = setInterval(() => {
|
|
1302
|
+
refreshSession();
|
|
1303
|
+
}, refreshInterval);
|
|
1304
|
+
return () => clearInterval(interval);
|
|
1305
|
+
}, [autoRefresh, state.isAuthenticated, refreshSession, refreshInterval]);
|
|
1306
|
+
const value = {
|
|
1307
|
+
...state,
|
|
1308
|
+
login,
|
|
1309
|
+
register,
|
|
1310
|
+
logout,
|
|
1311
|
+
forgotPassword,
|
|
1312
|
+
resetPassword,
|
|
1313
|
+
verifyEmail,
|
|
1314
|
+
refreshSession,
|
|
1315
|
+
restoreSession,
|
|
1316
|
+
setUser
|
|
1317
|
+
};
|
|
1318
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(AuthContext.Provider, { value, children });
|
|
1319
|
+
};
|
|
1320
|
+
function useAuth() {
|
|
1321
|
+
const context = useContext(AuthContext);
|
|
1322
|
+
if (!context) {
|
|
1323
|
+
throw new Error("useAuth must be used within an AuthProvider");
|
|
1324
|
+
}
|
|
1325
|
+
return context;
|
|
1326
|
+
}
|
|
1327
|
+
const LoginForm = ({
|
|
1328
|
+
className = "",
|
|
1329
|
+
labels = {},
|
|
1330
|
+
placeholders = {},
|
|
1331
|
+
submitButtonText = "Login",
|
|
1332
|
+
onSuccess,
|
|
1333
|
+
onError
|
|
1334
|
+
}) => {
|
|
1335
|
+
const { login, isLoading: authLoading, error: authError } = useAuth();
|
|
1336
|
+
const [formError, setFormError] = useState("");
|
|
1337
|
+
const [email, setEmail] = useState("");
|
|
1338
|
+
const [password, setPassword] = useState("");
|
|
1339
|
+
const [rememberMe, setRememberMe] = useState(false);
|
|
1340
|
+
const isLoading = authLoading;
|
|
1341
|
+
const error = formError || authError?.message;
|
|
1342
|
+
const handleSubmit = async (e) => {
|
|
1343
|
+
e.preventDefault();
|
|
1344
|
+
setFormError("");
|
|
1345
|
+
if (!email || !password) {
|
|
1346
|
+
setFormError("Email and password are required");
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
try {
|
|
1350
|
+
const user = await login({ email, password, rememberMe });
|
|
1351
|
+
onSuccess?.(user);
|
|
1352
|
+
} catch (err) {
|
|
1353
|
+
const errorMsg = err instanceof Error ? err.message : "Login failed";
|
|
1354
|
+
setFormError(errorMsg);
|
|
1355
|
+
onError?.({
|
|
1356
|
+
code: "LOGIN_ERROR",
|
|
1357
|
+
message: errorMsg
|
|
1358
|
+
});
|
|
1359
|
+
}
|
|
1360
|
+
};
|
|
1361
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, className, children: [
|
|
1362
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
|
|
1363
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "email", className: "auth-form-label", children: labels.email || "Email" }),
|
|
1364
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1365
|
+
"input",
|
|
1366
|
+
{
|
|
1367
|
+
id: "email",
|
|
1368
|
+
type: "email",
|
|
1369
|
+
value: email,
|
|
1370
|
+
onChange: (e) => setEmail(e.target.value),
|
|
1371
|
+
placeholder: placeholders.email || "your@email.com",
|
|
1372
|
+
disabled: isLoading,
|
|
1373
|
+
className: "auth-form-input",
|
|
1374
|
+
required: true
|
|
1375
|
+
}
|
|
1376
|
+
)
|
|
1377
|
+
] }),
|
|
1378
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
|
|
1379
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "password", className: "auth-form-label", children: labels.password || "Password" }),
|
|
1380
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1381
|
+
"input",
|
|
1382
|
+
{
|
|
1383
|
+
id: "password",
|
|
1384
|
+
type: "password",
|
|
1385
|
+
value: password,
|
|
1386
|
+
onChange: (e) => setPassword(e.target.value),
|
|
1387
|
+
placeholder: placeholders.password || "••••••••",
|
|
1388
|
+
disabled: isLoading,
|
|
1389
|
+
className: "auth-form-input",
|
|
1390
|
+
required: true
|
|
1391
|
+
}
|
|
1392
|
+
)
|
|
1393
|
+
] }),
|
|
1394
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group auth-form-checkbox", children: [
|
|
1395
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1396
|
+
"input",
|
|
1397
|
+
{
|
|
1398
|
+
id: "rememberMe",
|
|
1399
|
+
type: "checkbox",
|
|
1400
|
+
checked: rememberMe,
|
|
1401
|
+
onChange: (e) => setRememberMe(e.target.checked),
|
|
1402
|
+
disabled: isLoading,
|
|
1403
|
+
className: "auth-form-input"
|
|
1404
|
+
}
|
|
1405
|
+
),
|
|
1406
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "rememberMe", className: "auth-form-label", children: labels.rememberMe || "Remember me" })
|
|
1407
|
+
] }),
|
|
1408
|
+
error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-form-error", children: error }),
|
|
1409
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1410
|
+
"button",
|
|
1411
|
+
{
|
|
1412
|
+
type: "submit",
|
|
1413
|
+
disabled: isLoading,
|
|
1414
|
+
className: "auth-form-button auth-form-button-primary",
|
|
1415
|
+
children: isLoading ? "Loading..." : submitButtonText
|
|
1416
|
+
}
|
|
1417
|
+
)
|
|
1418
|
+
] });
|
|
1419
|
+
};
|
|
1420
|
+
LoginForm.displayName = "LoginForm";
|
|
1421
|
+
const RegisterForm = ({
|
|
1422
|
+
className = "",
|
|
1423
|
+
labels = {},
|
|
1424
|
+
placeholders = {},
|
|
1425
|
+
submitButtonText = "Register",
|
|
1426
|
+
onSuccess,
|
|
1427
|
+
onError
|
|
1428
|
+
}) => {
|
|
1429
|
+
const { register, isLoading: authLoading, error: authError } = useAuth();
|
|
1430
|
+
const [formError, setFormError] = useState("");
|
|
1431
|
+
const [name, setName] = useState("");
|
|
1432
|
+
const [email, setEmail] = useState("");
|
|
1433
|
+
const [password, setPassword] = useState("");
|
|
1434
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
1435
|
+
const isLoading = authLoading;
|
|
1436
|
+
const error = formError || authError?.message;
|
|
1437
|
+
const handleSubmit = async (e) => {
|
|
1438
|
+
e.preventDefault();
|
|
1439
|
+
setFormError("");
|
|
1440
|
+
if (!name || !email || !password || !confirmPassword) {
|
|
1441
|
+
setFormError("All fields are required");
|
|
1442
|
+
return;
|
|
1443
|
+
}
|
|
1444
|
+
if (password !== confirmPassword) {
|
|
1445
|
+
setFormError("Passwords do not match");
|
|
1446
|
+
return;
|
|
1447
|
+
}
|
|
1448
|
+
if (password.length < 8) {
|
|
1449
|
+
setFormError("Password must be at least 8 characters");
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
try {
|
|
1453
|
+
const user = await register({
|
|
1454
|
+
name,
|
|
1455
|
+
email,
|
|
1456
|
+
password,
|
|
1457
|
+
confirmPassword
|
|
1458
|
+
});
|
|
1459
|
+
onSuccess?.(user);
|
|
1460
|
+
} catch (err) {
|
|
1461
|
+
const errorMsg = err instanceof Error ? err.message : "Registration failed";
|
|
1462
|
+
setFormError(errorMsg);
|
|
1463
|
+
onError?.({
|
|
1464
|
+
code: "REGISTER_ERROR",
|
|
1465
|
+
message: errorMsg
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
};
|
|
1469
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, className, children: [
|
|
1470
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
|
|
1471
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "name", className: "auth-form-label", children: labels.name || "Full Name" }),
|
|
1472
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1473
|
+
"input",
|
|
1474
|
+
{
|
|
1475
|
+
id: "name",
|
|
1476
|
+
type: "text",
|
|
1477
|
+
value: name,
|
|
1478
|
+
onChange: (e) => setName(e.target.value),
|
|
1479
|
+
placeholder: placeholders.name || "John Doe",
|
|
1480
|
+
disabled: isLoading,
|
|
1481
|
+
className: "auth-form-input",
|
|
1482
|
+
required: true
|
|
1483
|
+
}
|
|
1484
|
+
)
|
|
1485
|
+
] }),
|
|
1486
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
|
|
1487
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "email", className: "auth-form-label", children: labels.email || "Email" }),
|
|
1488
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1489
|
+
"input",
|
|
1490
|
+
{
|
|
1491
|
+
id: "email",
|
|
1492
|
+
type: "email",
|
|
1493
|
+
value: email,
|
|
1494
|
+
onChange: (e) => setEmail(e.target.value),
|
|
1495
|
+
placeholder: placeholders.email || "your@email.com",
|
|
1496
|
+
disabled: isLoading,
|
|
1497
|
+
className: "auth-form-input",
|
|
1498
|
+
required: true
|
|
1499
|
+
}
|
|
1500
|
+
)
|
|
1501
|
+
] }),
|
|
1502
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
|
|
1503
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "password", className: "auth-form-label", children: labels.password || "Password" }),
|
|
1504
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1505
|
+
"input",
|
|
1506
|
+
{
|
|
1507
|
+
id: "password",
|
|
1508
|
+
type: "password",
|
|
1509
|
+
value: password,
|
|
1510
|
+
onChange: (e) => setPassword(e.target.value),
|
|
1511
|
+
placeholder: placeholders.password || "••••••••",
|
|
1512
|
+
disabled: isLoading,
|
|
1513
|
+
className: "auth-form-input",
|
|
1514
|
+
required: true
|
|
1515
|
+
}
|
|
1516
|
+
)
|
|
1517
|
+
] }),
|
|
1518
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
|
|
1519
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "confirmPassword", className: "auth-form-label", children: labels.confirmPassword || "Confirm Password" }),
|
|
1520
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1521
|
+
"input",
|
|
1522
|
+
{
|
|
1523
|
+
id: "confirmPassword",
|
|
1524
|
+
type: "password",
|
|
1525
|
+
value: confirmPassword,
|
|
1526
|
+
onChange: (e) => setConfirmPassword(e.target.value),
|
|
1527
|
+
placeholder: placeholders.confirmPassword || "••••••••",
|
|
1528
|
+
disabled: isLoading,
|
|
1529
|
+
className: "auth-form-input",
|
|
1530
|
+
required: true
|
|
1531
|
+
}
|
|
1532
|
+
)
|
|
1533
|
+
] }),
|
|
1534
|
+
error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-form-error", children: error }),
|
|
1535
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1536
|
+
"button",
|
|
1537
|
+
{
|
|
1538
|
+
type: "submit",
|
|
1539
|
+
disabled: isLoading,
|
|
1540
|
+
className: "auth-form-button auth-form-button-primary",
|
|
1541
|
+
children: isLoading ? "Loading..." : submitButtonText
|
|
1542
|
+
}
|
|
1543
|
+
)
|
|
1544
|
+
] });
|
|
1545
|
+
};
|
|
1546
|
+
RegisterForm.displayName = "RegisterForm";
|
|
1547
|
+
const ForgotPasswordForm = ({
|
|
1548
|
+
className = "",
|
|
1549
|
+
labels = {},
|
|
1550
|
+
placeholders = {},
|
|
1551
|
+
submitButtonText = "Send Reset Link",
|
|
1552
|
+
onSuccess,
|
|
1553
|
+
onError
|
|
1554
|
+
}) => {
|
|
1555
|
+
const {
|
|
1556
|
+
forgotPassword,
|
|
1557
|
+
isLoading: authLoading,
|
|
1558
|
+
error: authError
|
|
1559
|
+
} = useAuth();
|
|
1560
|
+
const [formError, setFormError] = useState("");
|
|
1561
|
+
const [email, setEmail] = useState("");
|
|
1562
|
+
const [successMessage, setSuccessMessage] = useState("");
|
|
1563
|
+
const isLoading = authLoading;
|
|
1564
|
+
const error = formError || authError?.message;
|
|
1565
|
+
const handleSubmit = async (e) => {
|
|
1566
|
+
e.preventDefault();
|
|
1567
|
+
setFormError("");
|
|
1568
|
+
setSuccessMessage("");
|
|
1569
|
+
if (!email) {
|
|
1570
|
+
setFormError("Email is required");
|
|
1571
|
+
return;
|
|
1572
|
+
}
|
|
1573
|
+
try {
|
|
1574
|
+
await forgotPassword({ email });
|
|
1575
|
+
setSuccessMessage("Password reset link has been sent to your email");
|
|
1576
|
+
setEmail("");
|
|
1577
|
+
onSuccess?.();
|
|
1578
|
+
} catch (err) {
|
|
1579
|
+
const errorMsg = err instanceof Error ? err.message : "Request failed";
|
|
1580
|
+
setFormError(errorMsg);
|
|
1581
|
+
onError?.({
|
|
1582
|
+
code: "FORGOT_PASSWORD_ERROR",
|
|
1583
|
+
message: errorMsg
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
};
|
|
1587
|
+
if (successMessage) {
|
|
1588
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `auth-form-success ${className}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "auth-form-success-message", children: successMessage }) });
|
|
1589
|
+
}
|
|
1590
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, className, children: [
|
|
1591
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
|
|
1592
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "email", className: "auth-form-label", children: labels.email || "Email" }),
|
|
1593
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1594
|
+
"input",
|
|
1595
|
+
{
|
|
1596
|
+
id: "email",
|
|
1597
|
+
type: "email",
|
|
1598
|
+
value: email,
|
|
1599
|
+
onChange: (e) => setEmail(e.target.value),
|
|
1600
|
+
placeholder: placeholders.email || "your@email.com",
|
|
1601
|
+
disabled: isLoading,
|
|
1602
|
+
className: "auth-form-input",
|
|
1603
|
+
required: true
|
|
1604
|
+
}
|
|
1605
|
+
)
|
|
1606
|
+
] }),
|
|
1607
|
+
error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-form-error", children: error }),
|
|
1608
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1609
|
+
"button",
|
|
1610
|
+
{
|
|
1611
|
+
type: "submit",
|
|
1612
|
+
disabled: isLoading,
|
|
1613
|
+
className: "auth-form-button auth-form-button-primary",
|
|
1614
|
+
children: isLoading ? "Loading..." : submitButtonText
|
|
1615
|
+
}
|
|
1616
|
+
)
|
|
1617
|
+
] });
|
|
1618
|
+
};
|
|
1619
|
+
ForgotPasswordForm.displayName = "ForgotPasswordForm";
|
|
1620
|
+
const ResetPasswordForm = ({
|
|
1621
|
+
token,
|
|
1622
|
+
className = "",
|
|
1623
|
+
labels = {},
|
|
1624
|
+
placeholders = {},
|
|
1625
|
+
submitButtonText = "Reset Password",
|
|
1626
|
+
onSuccess,
|
|
1627
|
+
onError
|
|
1628
|
+
}) => {
|
|
1629
|
+
const {
|
|
1630
|
+
resetPassword,
|
|
1631
|
+
isLoading: authLoading,
|
|
1632
|
+
error: authError
|
|
1633
|
+
} = useAuth();
|
|
1634
|
+
const [formError, setFormError] = useState("");
|
|
1635
|
+
const [password, setPassword] = useState("");
|
|
1636
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
1637
|
+
const [successMessage, setSuccessMessage] = useState("");
|
|
1638
|
+
const isLoading = authLoading;
|
|
1639
|
+
const error = formError || authError?.message;
|
|
1640
|
+
const handleSubmit = async (e) => {
|
|
1641
|
+
e.preventDefault();
|
|
1642
|
+
setFormError("");
|
|
1643
|
+
setSuccessMessage("");
|
|
1644
|
+
if (!password || !confirmPassword) {
|
|
1645
|
+
setFormError("Both password fields are required");
|
|
1646
|
+
return;
|
|
1647
|
+
}
|
|
1648
|
+
if (password !== confirmPassword) {
|
|
1649
|
+
setFormError("Passwords do not match");
|
|
1650
|
+
return;
|
|
1651
|
+
}
|
|
1652
|
+
if (password.length < 8) {
|
|
1653
|
+
setFormError("Password must be at least 8 characters");
|
|
1654
|
+
return;
|
|
1655
|
+
}
|
|
1656
|
+
try {
|
|
1657
|
+
await resetPassword({ token, password, confirmPassword });
|
|
1658
|
+
setSuccessMessage("Password has been reset successfully");
|
|
1659
|
+
setPassword("");
|
|
1660
|
+
setConfirmPassword("");
|
|
1661
|
+
onSuccess?.();
|
|
1662
|
+
} catch (err) {
|
|
1663
|
+
const errorMsg = err instanceof Error ? err.message : "Reset failed";
|
|
1664
|
+
setFormError(errorMsg);
|
|
1665
|
+
onError?.({
|
|
1666
|
+
code: "RESET_PASSWORD_ERROR",
|
|
1667
|
+
message: errorMsg
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
if (successMessage) {
|
|
1672
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `auth-form-success ${className}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "auth-form-success-message", children: successMessage }) });
|
|
1673
|
+
}
|
|
1674
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, className, children: [
|
|
1675
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
|
|
1676
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "password", className: "auth-form-label", children: labels.password || "New Password" }),
|
|
1677
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1678
|
+
"input",
|
|
1679
|
+
{
|
|
1680
|
+
id: "password",
|
|
1681
|
+
type: "password",
|
|
1682
|
+
value: password,
|
|
1683
|
+
onChange: (e) => setPassword(e.target.value),
|
|
1684
|
+
placeholder: placeholders.password || "••••••••",
|
|
1685
|
+
disabled: isLoading,
|
|
1686
|
+
className: "auth-form-input",
|
|
1687
|
+
required: true
|
|
1688
|
+
}
|
|
1689
|
+
)
|
|
1690
|
+
] }),
|
|
1691
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
|
|
1692
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "confirmPassword", className: "auth-form-label", children: labels.confirmPassword || "Confirm Password" }),
|
|
1693
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1694
|
+
"input",
|
|
1695
|
+
{
|
|
1696
|
+
id: "confirmPassword",
|
|
1697
|
+
type: "password",
|
|
1698
|
+
value: confirmPassword,
|
|
1699
|
+
onChange: (e) => setConfirmPassword(e.target.value),
|
|
1700
|
+
placeholder: placeholders.confirmPassword || "••••••••",
|
|
1701
|
+
disabled: isLoading,
|
|
1702
|
+
className: "auth-form-input",
|
|
1703
|
+
required: true
|
|
1704
|
+
}
|
|
1705
|
+
)
|
|
1706
|
+
] }),
|
|
1707
|
+
error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-form-error", children: error }),
|
|
1708
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1709
|
+
"button",
|
|
1710
|
+
{
|
|
1711
|
+
type: "submit",
|
|
1712
|
+
disabled: isLoading,
|
|
1713
|
+
className: "auth-form-button auth-form-button-primary",
|
|
1714
|
+
children: isLoading ? "Loading..." : submitButtonText
|
|
1715
|
+
}
|
|
1716
|
+
)
|
|
1717
|
+
] });
|
|
1718
|
+
};
|
|
1719
|
+
ResetPasswordForm.displayName = "ResetPasswordForm";
|
|
1720
|
+
const VerifyEmailForm = ({
|
|
1721
|
+
token: initialToken,
|
|
1722
|
+
email: initialEmail,
|
|
1723
|
+
className = "",
|
|
1724
|
+
labels = {},
|
|
1725
|
+
placeholders = {},
|
|
1726
|
+
submitButtonText = "Verify Email",
|
|
1727
|
+
onSuccess,
|
|
1728
|
+
onError
|
|
1729
|
+
}) => {
|
|
1730
|
+
const {
|
|
1731
|
+
verifyEmail,
|
|
1732
|
+
isLoading: authLoading,
|
|
1733
|
+
error: authError
|
|
1734
|
+
} = useAuth();
|
|
1735
|
+
const [formError, setFormError] = useState("");
|
|
1736
|
+
const [email, setEmail] = useState(initialEmail || "");
|
|
1737
|
+
const [token, setToken] = useState(initialToken || "");
|
|
1738
|
+
const [successMessage, setSuccessMessage] = useState("");
|
|
1739
|
+
const isLoading = authLoading;
|
|
1740
|
+
const error = formError || authError?.message;
|
|
1741
|
+
useEffect(() => {
|
|
1742
|
+
if (token && email && !successMessage && !error) {
|
|
1743
|
+
handleSubmit({ preventDefault: () => {
|
|
1744
|
+
} });
|
|
1745
|
+
}
|
|
1746
|
+
}, [token, email]);
|
|
1747
|
+
const handleSubmit = async (e) => {
|
|
1748
|
+
e.preventDefault();
|
|
1749
|
+
setFormError("");
|
|
1750
|
+
setSuccessMessage("");
|
|
1751
|
+
if (!token) {
|
|
1752
|
+
setFormError("Verification token is required");
|
|
1753
|
+
return;
|
|
1754
|
+
}
|
|
1755
|
+
if (!email) {
|
|
1756
|
+
setFormError("Email is required");
|
|
1757
|
+
return;
|
|
1758
|
+
}
|
|
1759
|
+
try {
|
|
1760
|
+
await verifyEmail({ token, email });
|
|
1761
|
+
setSuccessMessage("Email has been verified successfully");
|
|
1762
|
+
onSuccess?.();
|
|
1763
|
+
} catch (err) {
|
|
1764
|
+
const errorMsg = err instanceof Error ? err.message : "Verification failed";
|
|
1765
|
+
setFormError(errorMsg);
|
|
1766
|
+
onError?.({
|
|
1767
|
+
code: "VERIFY_EMAIL_ERROR",
|
|
1768
|
+
message: errorMsg
|
|
1769
|
+
});
|
|
1770
|
+
}
|
|
1771
|
+
};
|
|
1772
|
+
if (successMessage) {
|
|
1773
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `auth-form-success ${className}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "auth-form-success-message", children: successMessage }) });
|
|
1774
|
+
}
|
|
1775
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: handleSubmit, className, children: [
|
|
1776
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
|
|
1777
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "email", className: "auth-form-label", children: labels.email || "Email" }),
|
|
1778
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1779
|
+
"input",
|
|
1780
|
+
{
|
|
1781
|
+
id: "email",
|
|
1782
|
+
type: "email",
|
|
1783
|
+
value: email,
|
|
1784
|
+
onChange: (e) => setEmail(e.target.value),
|
|
1785
|
+
placeholder: placeholders.email || "your@email.com",
|
|
1786
|
+
disabled: isLoading,
|
|
1787
|
+
className: "auth-form-input",
|
|
1788
|
+
required: true
|
|
1789
|
+
}
|
|
1790
|
+
)
|
|
1791
|
+
] }),
|
|
1792
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "auth-form-group", children: [
|
|
1793
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "token", className: "auth-form-label", children: labels.token || "Verification Code" }),
|
|
1794
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1795
|
+
"input",
|
|
1796
|
+
{
|
|
1797
|
+
id: "token",
|
|
1798
|
+
type: "text",
|
|
1799
|
+
value: token,
|
|
1800
|
+
onChange: (e) => setToken(e.target.value),
|
|
1801
|
+
placeholder: placeholders.token || "Enter verification code",
|
|
1802
|
+
disabled: isLoading,
|
|
1803
|
+
className: "auth-form-input",
|
|
1804
|
+
required: true
|
|
1805
|
+
}
|
|
1806
|
+
)
|
|
1807
|
+
] }),
|
|
1808
|
+
error && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-form-error", children: error }),
|
|
1809
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1810
|
+
"button",
|
|
1811
|
+
{
|
|
1812
|
+
type: "submit",
|
|
1813
|
+
disabled: isLoading,
|
|
1814
|
+
className: "auth-form-button auth-form-button-primary",
|
|
1815
|
+
children: isLoading ? "Loading..." : submitButtonText
|
|
1816
|
+
}
|
|
1817
|
+
)
|
|
1818
|
+
] });
|
|
1819
|
+
};
|
|
1820
|
+
VerifyEmailForm.displayName = "VerifyEmailForm";
|
|
1821
|
+
const ProtectedRoute = ({
|
|
1822
|
+
children,
|
|
1823
|
+
redirectTo = "/login",
|
|
1824
|
+
fallback,
|
|
1825
|
+
roles,
|
|
1826
|
+
permissions
|
|
1827
|
+
}) => {
|
|
1828
|
+
const { isAuthenticated, isLoading, user } = useAuth();
|
|
1829
|
+
if (isLoading) {
|
|
1830
|
+
return fallback || /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-loading", children: "Loading..." });
|
|
1831
|
+
}
|
|
1832
|
+
if (!isAuthenticated) {
|
|
1833
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Navigate, { to: redirectTo, replace: true });
|
|
1834
|
+
}
|
|
1835
|
+
if (roles && roles.length > 0) {
|
|
1836
|
+
const hasRole = user?.roles?.some((role) => roles.includes(role));
|
|
1837
|
+
if (!hasRole) {
|
|
1838
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-forbidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "You do not have permission to access this page." }) });
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
if (permissions && permissions.length > 0) {
|
|
1842
|
+
const hasPermission = user?.permissions?.some(
|
|
1843
|
+
(permission) => permissions.includes(permission)
|
|
1844
|
+
);
|
|
1845
|
+
if (!hasPermission) {
|
|
1846
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "auth-forbidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "You do not have permission to access this page." }) });
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children });
|
|
1850
|
+
};
|
|
1851
|
+
ProtectedRoute.displayName = "ProtectedRoute";
|
|
1852
|
+
export {
|
|
1853
|
+
AuthContext,
|
|
1854
|
+
AuthProvider,
|
|
1855
|
+
ForgotPasswordForm,
|
|
1856
|
+
LoginForm,
|
|
1857
|
+
ProtectedRoute,
|
|
1858
|
+
RegisterForm,
|
|
1859
|
+
ResetPasswordForm,
|
|
1860
|
+
VerifyEmailForm,
|
|
1861
|
+
createAuthClient,
|
|
1862
|
+
normalizeError,
|
|
1863
|
+
useAuth
|
|
1864
|
+
};
|
|
1865
|
+
//# sourceMappingURL=index.es.js.map
|