@rqdhw3n/react-auth-flow 1.0.3 → 1.0.5

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 CHANGED
@@ -3,6 +3,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const reactRouterDom = require("react-router-dom");
6
+ const authStyles = ".rq-auth-container,\n.rq-auth-container * {\n box-sizing: border-box;\n}\n\n.rq-auth-container {\n --rq-auth-primary: #2563eb;\n --rq-auth-primary-hover: #1d4ed8;\n --rq-auth-primary-soft: rgba(37, 99, 235, 0.16);\n --rq-auth-border: #dbe4f0;\n --rq-auth-border-strong: #c7d4e5;\n --rq-auth-text: #0f172a;\n --rq-auth-muted: #64748b;\n --rq-auth-surface: #ffffff;\n --rq-auth-surface-alt: #f8fbff;\n --rq-auth-disabled: #eef2f7;\n --rq-auth-error: #b91c1c;\n --rq-auth-error-border: #fecaca;\n --rq-auth-error-bg: #fef2f2;\n --rq-auth-success: #047857;\n --rq-auth-success-border: #a7f3d0;\n --rq-auth-success-bg: #ecfdf5;\n width: min(100%, 28rem);\n margin: 0 auto;\n padding: clamp(1.25rem, 3vw, 2rem);\n border: 1px solid var(--rq-auth-border);\n border-radius: 1.5rem;\n background:\n radial-gradient(circle at top, rgba(96, 165, 250, 0.14), transparent 34%),\n linear-gradient(180deg, var(--rq-auth-surface) 0%, var(--rq-auth-surface-alt) 100%);\n box-shadow:\n 0 24px 48px rgba(15, 23, 42, 0.08),\n 0 8px 20px rgba(15, 23, 42, 0.05);\n color: var(--rq-auth-text);\n}\n\n.rq-auth-header {\n margin-bottom: 1.5rem;\n}\n\n.rq-auth-title {\n margin: 0;\n font-size: clamp(1.625rem, 4vw, 2rem);\n font-weight: 700;\n line-height: 1.15;\n letter-spacing: -0.02em;\n color: var(--rq-auth-text);\n}\n\n.rq-auth-subtitle {\n margin: 0.5rem 0 0;\n font-size: 0.95rem;\n line-height: 1.6;\n color: var(--rq-auth-muted);\n}\n\n.rq-auth-form {\n display: grid;\n gap: 1rem;\n}\n\n.rq-auth-field {\n display: grid;\n gap: 0.5rem;\n}\n\n.rq-auth-label {\n font-size: 0.94rem;\n font-weight: 600;\n line-height: 1.4;\n color: var(--rq-auth-text);\n}\n\n.rq-auth-input {\n width: 100%;\n min-width: 0;\n padding: 0.9rem 1rem;\n border: 1px solid var(--rq-auth-border);\n border-radius: 0.95rem;\n background: rgba(255, 255, 255, 0.92);\n color: var(--rq-auth-text);\n font: inherit;\n line-height: 1.5;\n outline: none;\n transition:\n border-color 0.2s ease,\n box-shadow 0.2s ease,\n background-color 0.2s ease,\n transform 0.2s ease;\n box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);\n}\n\n.rq-auth-input::placeholder {\n color: #94a3b8;\n}\n\n.rq-auth-input:hover {\n border-color: var(--rq-auth-border-strong);\n}\n\n.rq-auth-input:focus {\n border-color: var(--rq-auth-primary);\n box-shadow:\n 0 0 0 4px var(--rq-auth-primary-soft),\n inset 0 1px 2px rgba(15, 23, 42, 0.03);\n}\n\n.rq-auth-input:disabled {\n cursor: not-allowed;\n background: var(--rq-auth-disabled);\n color: #94a3b8;\n}\n\n.rq-auth-checkbox {\n display: flex;\n align-items: flex-start;\n gap: 0.75rem;\n font-size: 0.94rem;\n line-height: 1.5;\n color: var(--rq-auth-muted);\n}\n\n.rq-auth-checkbox-input {\n width: 1.05rem;\n height: 1.05rem;\n margin: 0.2rem 0 0;\n border-radius: 0.35rem;\n accent-color: var(--rq-auth-primary);\n flex: 0 0 auto;\n}\n\n.rq-auth-checkbox-input:disabled {\n cursor: not-allowed;\n}\n\n.rq-auth-checkbox-label {\n color: var(--rq-auth-muted);\n}\n\n.rq-auth-button {\n width: 100%;\n border: 0;\n border-radius: 0.95rem;\n padding: 0.95rem 1.15rem;\n background: linear-gradient(180deg, #3b82f6 0%, var(--rq-auth-primary) 100%);\n color: #ffffff;\n font: inherit;\n font-size: 0.98rem;\n font-weight: 600;\n line-height: 1.2;\n cursor: pointer;\n transition:\n background 0.2s ease,\n box-shadow 0.2s ease,\n transform 0.2s ease,\n opacity 0.2s ease;\n box-shadow:\n 0 14px 28px rgba(37, 99, 235, 0.22),\n inset 0 1px 0 rgba(255, 255, 255, 0.18);\n}\n\n.rq-auth-button:hover:not(:disabled) {\n background: linear-gradient(180deg, #2563eb 0%, var(--rq-auth-primary-hover) 100%);\n transform: translateY(-1px);\n}\n\n.rq-auth-button:focus-visible {\n outline: none;\n box-shadow:\n 0 0 0 4px var(--rq-auth-primary-soft),\n 0 14px 28px rgba(37, 99, 235, 0.22);\n}\n\n.rq-auth-button:disabled {\n cursor: not-allowed;\n opacity: 0.68;\n transform: none;\n box-shadow: none;\n}\n\n.rq-auth-button-content {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 0.625rem;\n}\n\n.rq-auth-button-spinner {\n width: 1rem;\n height: 1rem;\n border: 2px solid rgba(255, 255, 255, 0.4);\n border-top-color: #ffffff;\n border-radius: 999px;\n animation: rq-auth-spin 0.75s linear infinite;\n}\n\n.rq-auth-error,\n.rq-auth-success,\n.auth-loading,\n.auth-forbidden {\n padding: 0.95rem 1rem;\n border-radius: 1rem;\n border: 1px solid transparent;\n font-size: 0.94rem;\n line-height: 1.55;\n}\n\n.rq-auth-error {\n border-color: var(--rq-auth-error-border);\n background: var(--rq-auth-error-bg);\n color: var(--rq-auth-error);\n}\n\n.rq-auth-success {\n border-color: var(--rq-auth-success-border);\n background: var(--rq-auth-success-bg);\n color: var(--rq-auth-success);\n}\n\n.auth-loading {\n border-color: var(--rq-auth-border);\n background: var(--rq-auth-surface-alt);\n color: var(--rq-auth-muted);\n}\n\n.auth-forbidden {\n border-color: var(--rq-auth-error-border);\n background: var(--rq-auth-error-bg);\n color: var(--rq-auth-error);\n}\n\n@keyframes rq-auth-spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n@media (max-width: 640px) {\n .rq-auth-container {\n width: 100%;\n padding: 1.125rem;\n border-radius: 1.25rem;\n }\n\n .rq-auth-form {\n gap: 0.9rem;\n }\n\n .rq-auth-input,\n .rq-auth-button {\n padding-inline: 0.95rem;\n }\n}\n";
7
+ const STYLE_ELEMENT_ID = "rq-auth-flow-styles";
8
+ if (typeof document !== "undefined" && !document.getElementById(STYLE_ELEMENT_ID)) {
9
+ const styleElement = document.createElement("style");
10
+ styleElement.id = STYLE_ELEMENT_ID;
11
+ styleElement.textContent = authStyles;
12
+ document.head.appendChild(styleElement);
13
+ }
6
14
  const AuthContext = React.createContext(
7
15
  void 0
8
16
  );
@@ -405,11 +413,44 @@ function useAuth() {
405
413
  }
406
414
  return context;
407
415
  }
416
+ function cn(...classes) {
417
+ return classes.filter(Boolean).join(" ");
418
+ }
419
+ const AUTH_FORM_CLASSES = {
420
+ container: "rq-auth-container",
421
+ header: "rq-auth-header",
422
+ form: "rq-auth-form",
423
+ field: "rq-auth-field",
424
+ label: "rq-auth-label",
425
+ input: "rq-auth-input",
426
+ button: "rq-auth-button",
427
+ buttonContent: "rq-auth-button-content",
428
+ buttonSpinner: "rq-auth-button-spinner",
429
+ error: "rq-auth-error",
430
+ success: "rq-auth-success",
431
+ title: "rq-auth-title",
432
+ subtitle: "rq-auth-subtitle",
433
+ checkbox: "rq-auth-checkbox",
434
+ checkboxInput: "rq-auth-checkbox-input",
435
+ checkboxLabel: "rq-auth-checkbox-label"
436
+ };
408
437
  const LoginForm = ({
409
- className = "",
438
+ className,
439
+ formClassName,
440
+ fieldClassName,
441
+ labelClassName,
442
+ inputClassName,
443
+ buttonClassName,
444
+ errorClassName,
445
+ titleClassName,
446
+ subtitleClassName,
410
447
  labels = {},
411
448
  placeholders = {},
412
449
  submitButtonText = "Login",
450
+ loadingText = "Signing in...",
451
+ title,
452
+ subtitle,
453
+ showTitle = !!title,
413
454
  onSuccess,
414
455
  onError
415
456
  }) => {
@@ -439,71 +480,110 @@ const LoginForm = ({
439
480
  });
440
481
  }
441
482
  };
442
- return /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className, children: [
443
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "auth-form-group", children: [
444
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", className: "auth-form-label", children: labels.email || "Email" }),
445
- /* @__PURE__ */ jsxRuntime.jsx(
446
- "input",
447
- {
448
- id: "email",
449
- type: "email",
450
- value: email,
451
- onChange: (e) => setEmail(e.target.value),
452
- placeholder: placeholders.email || "your@email.com",
453
- disabled: isLoading,
454
- className: "auth-form-input",
455
- required: true
456
- }
457
- )
458
- ] }),
459
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "auth-form-group", children: [
460
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", className: "auth-form-label", children: labels.password || "Password" }),
461
- /* @__PURE__ */ jsxRuntime.jsx(
462
- "input",
463
- {
464
- id: "password",
465
- type: "password",
466
- value: password,
467
- onChange: (e) => setPassword(e.target.value),
468
- placeholder: placeholders.password || "••••••••",
469
- disabled: isLoading,
470
- className: "auth-form-input",
471
- required: true
472
- }
473
- )
474
- ] }),
475
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "auth-form-group auth-form-checkbox", children: [
476
- /* @__PURE__ */ jsxRuntime.jsx(
477
- "input",
478
- {
479
- id: "rememberMe",
480
- type: "checkbox",
481
- checked: rememberMe,
482
- onChange: (e) => setRememberMe(e.target.checked),
483
- disabled: isLoading,
484
- className: "auth-form-input"
485
- }
486
- ),
487
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "rememberMe", className: "auth-form-label", children: labels.rememberMe || "Remember me" })
483
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.container, className), children: [
484
+ showTitle && title && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: AUTH_FORM_CLASSES.header, children: [
485
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: cn(AUTH_FORM_CLASSES.title, titleClassName), children: title }),
486
+ subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: cn(AUTH_FORM_CLASSES.subtitle, subtitleClassName), children: subtitle })
488
487
  ] }),
489
- error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "auth-form-error", children: error }),
490
- /* @__PURE__ */ jsxRuntime.jsx(
491
- "button",
488
+ /* @__PURE__ */ jsxRuntime.jsxs(
489
+ "form",
492
490
  {
493
- type: "submit",
494
- disabled: isLoading,
495
- className: "auth-form-button auth-form-button-primary",
496
- children: isLoading ? "Loading..." : submitButtonText
491
+ onSubmit: handleSubmit,
492
+ className: cn(AUTH_FORM_CLASSES.form, formClassName),
493
+ "aria-busy": isLoading,
494
+ children: [
495
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.field, fieldClassName), children: [
496
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", className: cn(AUTH_FORM_CLASSES.label, labelClassName), children: labels.email || "Email" }),
497
+ /* @__PURE__ */ jsxRuntime.jsx(
498
+ "input",
499
+ {
500
+ id: "email",
501
+ type: "email",
502
+ value: email,
503
+ onChange: (e) => setEmail(e.target.value),
504
+ placeholder: placeholders.email || "your@email.com",
505
+ disabled: isLoading,
506
+ className: cn(AUTH_FORM_CLASSES.input, inputClassName),
507
+ autoComplete: "username",
508
+ required: true
509
+ }
510
+ )
511
+ ] }),
512
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.field, fieldClassName), children: [
513
+ /* @__PURE__ */ jsxRuntime.jsx(
514
+ "label",
515
+ {
516
+ htmlFor: "password",
517
+ className: cn(AUTH_FORM_CLASSES.label, labelClassName),
518
+ children: labels.password || "Password"
519
+ }
520
+ ),
521
+ /* @__PURE__ */ jsxRuntime.jsx(
522
+ "input",
523
+ {
524
+ id: "password",
525
+ type: "password",
526
+ value: password,
527
+ onChange: (e) => setPassword(e.target.value),
528
+ placeholder: placeholders.password || "Enter your password",
529
+ disabled: isLoading,
530
+ className: cn(AUTH_FORM_CLASSES.input, inputClassName),
531
+ autoComplete: "current-password",
532
+ required: true
533
+ }
534
+ )
535
+ ] }),
536
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: "rememberMe", className: AUTH_FORM_CLASSES.checkbox, children: [
537
+ /* @__PURE__ */ jsxRuntime.jsx(
538
+ "input",
539
+ {
540
+ id: "rememberMe",
541
+ type: "checkbox",
542
+ checked: rememberMe,
543
+ onChange: (e) => setRememberMe(e.target.checked),
544
+ disabled: isLoading,
545
+ className: AUTH_FORM_CLASSES.checkboxInput
546
+ }
547
+ ),
548
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: AUTH_FORM_CLASSES.checkboxLabel, children: labels.rememberMe || "Remember me" })
549
+ ] }),
550
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(AUTH_FORM_CLASSES.error, errorClassName), role: "alert", children: error }),
551
+ /* @__PURE__ */ jsxRuntime.jsx(
552
+ "button",
553
+ {
554
+ type: "submit",
555
+ disabled: isLoading,
556
+ className: cn(AUTH_FORM_CLASSES.button, buttonClassName),
557
+ "aria-busy": isLoading,
558
+ children: isLoading ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: AUTH_FORM_CLASSES.buttonContent, children: [
559
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: AUTH_FORM_CLASSES.buttonSpinner, "aria-hidden": "true" }),
560
+ loadingText
561
+ ] }) : submitButtonText
562
+ }
563
+ )
564
+ ]
497
565
  }
498
566
  )
499
567
  ] });
500
568
  };
501
569
  LoginForm.displayName = "LoginForm";
502
570
  const RegisterForm = ({
503
- className = "",
571
+ className,
572
+ formClassName,
573
+ fieldClassName,
574
+ labelClassName,
575
+ inputClassName,
576
+ buttonClassName,
577
+ errorClassName,
578
+ titleClassName,
579
+ subtitleClassName,
504
580
  labels = {},
505
581
  placeholders = {},
506
582
  submitButtonText = "Register",
583
+ loadingText = "Creating account...",
584
+ title,
585
+ subtitle,
586
+ showTitle = !!title,
507
587
  onSuccess,
508
588
  onError
509
589
  }) => {
@@ -547,89 +627,138 @@ const RegisterForm = ({
547
627
  });
548
628
  }
549
629
  };
550
- return /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className, children: [
551
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "auth-form-group", children: [
552
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "name", className: "auth-form-label", children: labels.name || "Full Name" }),
553
- /* @__PURE__ */ jsxRuntime.jsx(
554
- "input",
555
- {
556
- id: "name",
557
- type: "text",
558
- value: name,
559
- onChange: (e) => setName(e.target.value),
560
- placeholder: placeholders.name || "John Doe",
561
- disabled: isLoading,
562
- className: "auth-form-input",
563
- required: true
564
- }
565
- )
630
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.container, className), children: [
631
+ showTitle && title && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: AUTH_FORM_CLASSES.header, children: [
632
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: cn(AUTH_FORM_CLASSES.title, titleClassName), children: title }),
633
+ subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: cn(AUTH_FORM_CLASSES.subtitle, subtitleClassName), children: subtitle })
566
634
  ] }),
567
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "auth-form-group", children: [
568
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", className: "auth-form-label", children: labels.email || "Email" }),
569
- /* @__PURE__ */ jsxRuntime.jsx(
570
- "input",
571
- {
572
- id: "email",
573
- type: "email",
574
- value: email,
575
- onChange: (e) => setEmail(e.target.value),
576
- placeholder: placeholders.email || "your@email.com",
577
- disabled: isLoading,
578
- className: "auth-form-input",
579
- required: true
580
- }
581
- )
582
- ] }),
583
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "auth-form-group", children: [
584
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", className: "auth-form-label", children: labels.password || "Password" }),
585
- /* @__PURE__ */ jsxRuntime.jsx(
586
- "input",
587
- {
588
- id: "password",
589
- type: "password",
590
- value: password,
591
- onChange: (e) => setPassword(e.target.value),
592
- placeholder: placeholders.password || "••••••••",
593
- disabled: isLoading,
594
- className: "auth-form-input",
595
- required: true
596
- }
597
- )
598
- ] }),
599
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "auth-form-group", children: [
600
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "confirmPassword", className: "auth-form-label", children: labels.confirmPassword || "Confirm Password" }),
601
- /* @__PURE__ */ jsxRuntime.jsx(
602
- "input",
603
- {
604
- id: "confirmPassword",
605
- type: "password",
606
- value: confirmPassword,
607
- onChange: (e) => setConfirmPassword(e.target.value),
608
- placeholder: placeholders.confirmPassword || "••••••••",
609
- disabled: isLoading,
610
- className: "auth-form-input",
611
- required: true
612
- }
613
- )
614
- ] }),
615
- error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "auth-form-error", children: error }),
616
- /* @__PURE__ */ jsxRuntime.jsx(
617
- "button",
635
+ /* @__PURE__ */ jsxRuntime.jsxs(
636
+ "form",
618
637
  {
619
- type: "submit",
620
- disabled: isLoading,
621
- className: "auth-form-button auth-form-button-primary",
622
- children: isLoading ? "Loading..." : submitButtonText
638
+ onSubmit: handleSubmit,
639
+ className: cn(AUTH_FORM_CLASSES.form, formClassName),
640
+ "aria-busy": isLoading,
641
+ children: [
642
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.field, fieldClassName), children: [
643
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "name", className: cn(AUTH_FORM_CLASSES.label, labelClassName), children: labels.name || "Full Name" }),
644
+ /* @__PURE__ */ jsxRuntime.jsx(
645
+ "input",
646
+ {
647
+ id: "name",
648
+ type: "text",
649
+ value: name,
650
+ onChange: (e) => setName(e.target.value),
651
+ placeholder: placeholders.name || "John Doe",
652
+ disabled: isLoading,
653
+ className: cn(AUTH_FORM_CLASSES.input, inputClassName),
654
+ autoComplete: "name",
655
+ required: true
656
+ }
657
+ )
658
+ ] }),
659
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.field, fieldClassName), children: [
660
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", className: cn(AUTH_FORM_CLASSES.label, labelClassName), children: labels.email || "Email" }),
661
+ /* @__PURE__ */ jsxRuntime.jsx(
662
+ "input",
663
+ {
664
+ id: "email",
665
+ type: "email",
666
+ value: email,
667
+ onChange: (e) => setEmail(e.target.value),
668
+ placeholder: placeholders.email || "your@email.com",
669
+ disabled: isLoading,
670
+ className: cn(AUTH_FORM_CLASSES.input, inputClassName),
671
+ autoComplete: "email",
672
+ required: true
673
+ }
674
+ )
675
+ ] }),
676
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.field, fieldClassName), children: [
677
+ /* @__PURE__ */ jsxRuntime.jsx(
678
+ "label",
679
+ {
680
+ htmlFor: "password",
681
+ className: cn(AUTH_FORM_CLASSES.label, labelClassName),
682
+ children: labels.password || "Password"
683
+ }
684
+ ),
685
+ /* @__PURE__ */ jsxRuntime.jsx(
686
+ "input",
687
+ {
688
+ id: "password",
689
+ type: "password",
690
+ value: password,
691
+ onChange: (e) => setPassword(e.target.value),
692
+ placeholder: placeholders.password || "Create a password",
693
+ disabled: isLoading,
694
+ className: cn(AUTH_FORM_CLASSES.input, inputClassName),
695
+ autoComplete: "new-password",
696
+ required: true
697
+ }
698
+ )
699
+ ] }),
700
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.field, fieldClassName), children: [
701
+ /* @__PURE__ */ jsxRuntime.jsx(
702
+ "label",
703
+ {
704
+ htmlFor: "confirmPassword",
705
+ className: cn(AUTH_FORM_CLASSES.label, labelClassName),
706
+ children: labels.confirmPassword || "Confirm Password"
707
+ }
708
+ ),
709
+ /* @__PURE__ */ jsxRuntime.jsx(
710
+ "input",
711
+ {
712
+ id: "confirmPassword",
713
+ type: "password",
714
+ value: confirmPassword,
715
+ onChange: (e) => setConfirmPassword(e.target.value),
716
+ placeholder: placeholders.confirmPassword || "Confirm your password",
717
+ disabled: isLoading,
718
+ className: cn(AUTH_FORM_CLASSES.input, inputClassName),
719
+ autoComplete: "new-password",
720
+ required: true
721
+ }
722
+ )
723
+ ] }),
724
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(AUTH_FORM_CLASSES.error, errorClassName), role: "alert", children: error }),
725
+ /* @__PURE__ */ jsxRuntime.jsx(
726
+ "button",
727
+ {
728
+ type: "submit",
729
+ disabled: isLoading,
730
+ className: cn(AUTH_FORM_CLASSES.button, buttonClassName),
731
+ "aria-busy": isLoading,
732
+ children: isLoading ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: AUTH_FORM_CLASSES.buttonContent, children: [
733
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: AUTH_FORM_CLASSES.buttonSpinner, "aria-hidden": "true" }),
734
+ loadingText
735
+ ] }) : submitButtonText
736
+ }
737
+ )
738
+ ]
623
739
  }
624
740
  )
625
741
  ] });
626
742
  };
627
743
  RegisterForm.displayName = "RegisterForm";
628
744
  const ForgotPasswordForm = ({
629
- className = "",
745
+ className,
746
+ formClassName,
747
+ fieldClassName,
748
+ labelClassName,
749
+ inputClassName,
750
+ buttonClassName,
751
+ errorClassName,
752
+ successClassName,
753
+ titleClassName,
754
+ subtitleClassName,
630
755
  labels = {},
631
756
  placeholders = {},
632
757
  submitButtonText = "Send Reset Link",
758
+ loadingText = "Sending...",
759
+ title,
760
+ subtitle,
761
+ showTitle = !!title,
633
762
  onSuccess,
634
763
  onError
635
764
  }) => {
@@ -666,33 +795,58 @@ const ForgotPasswordForm = ({
666
795
  }
667
796
  };
668
797
  if (successMessage) {
669
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `auth-form-success ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "auth-form-success-message", children: successMessage }) });
798
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.container, className), children: [
799
+ showTitle && title && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: AUTH_FORM_CLASSES.header, children: [
800
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: cn(AUTH_FORM_CLASSES.title, titleClassName), children: title }),
801
+ subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: cn(AUTH_FORM_CLASSES.subtitle, subtitleClassName), children: subtitle })
802
+ ] }),
803
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(AUTH_FORM_CLASSES.success, successClassName), role: "status", children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: successMessage }) })
804
+ ] });
670
805
  }
671
- return /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className, children: [
672
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "auth-form-group", children: [
673
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", className: "auth-form-label", children: labels.email || "Email" }),
674
- /* @__PURE__ */ jsxRuntime.jsx(
675
- "input",
676
- {
677
- id: "email",
678
- type: "email",
679
- value: email,
680
- onChange: (e) => setEmail(e.target.value),
681
- placeholder: placeholders.email || "your@email.com",
682
- disabled: isLoading,
683
- className: "auth-form-input",
684
- required: true
685
- }
686
- )
806
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.container, className), children: [
807
+ showTitle && title && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: AUTH_FORM_CLASSES.header, children: [
808
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: cn(AUTH_FORM_CLASSES.title, titleClassName), children: title }),
809
+ subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: cn(AUTH_FORM_CLASSES.subtitle, subtitleClassName), children: subtitle })
687
810
  ] }),
688
- error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "auth-form-error", children: error }),
689
- /* @__PURE__ */ jsxRuntime.jsx(
690
- "button",
811
+ /* @__PURE__ */ jsxRuntime.jsxs(
812
+ "form",
691
813
  {
692
- type: "submit",
693
- disabled: isLoading,
694
- className: "auth-form-button auth-form-button-primary",
695
- children: isLoading ? "Loading..." : submitButtonText
814
+ onSubmit: handleSubmit,
815
+ className: cn(AUTH_FORM_CLASSES.form, formClassName),
816
+ "aria-busy": isLoading,
817
+ children: [
818
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.field, fieldClassName), children: [
819
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", className: cn(AUTH_FORM_CLASSES.label, labelClassName), children: labels.email || "Email" }),
820
+ /* @__PURE__ */ jsxRuntime.jsx(
821
+ "input",
822
+ {
823
+ id: "email",
824
+ type: "email",
825
+ value: email,
826
+ onChange: (e) => setEmail(e.target.value),
827
+ placeholder: placeholders.email || "your@email.com",
828
+ disabled: isLoading,
829
+ className: cn(AUTH_FORM_CLASSES.input, inputClassName),
830
+ autoComplete: "email",
831
+ required: true
832
+ }
833
+ )
834
+ ] }),
835
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(AUTH_FORM_CLASSES.error, errorClassName), role: "alert", children: error }),
836
+ /* @__PURE__ */ jsxRuntime.jsx(
837
+ "button",
838
+ {
839
+ type: "submit",
840
+ disabled: isLoading,
841
+ className: cn(AUTH_FORM_CLASSES.button, buttonClassName),
842
+ "aria-busy": isLoading,
843
+ children: isLoading ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: AUTH_FORM_CLASSES.buttonContent, children: [
844
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: AUTH_FORM_CLASSES.buttonSpinner, "aria-hidden": "true" }),
845
+ loadingText
846
+ ] }) : submitButtonText
847
+ }
848
+ )
849
+ ]
696
850
  }
697
851
  )
698
852
  ] });
@@ -700,10 +854,23 @@ const ForgotPasswordForm = ({
700
854
  ForgotPasswordForm.displayName = "ForgotPasswordForm";
701
855
  const ResetPasswordForm = ({
702
856
  token,
703
- className = "",
857
+ className,
858
+ formClassName,
859
+ fieldClassName,
860
+ labelClassName,
861
+ inputClassName,
862
+ buttonClassName,
863
+ errorClassName,
864
+ successClassName,
865
+ titleClassName,
866
+ subtitleClassName,
704
867
  labels = {},
705
868
  placeholders = {},
706
869
  submitButtonText = "Reset Password",
870
+ loadingText = "Updating...",
871
+ title,
872
+ subtitle,
873
+ showTitle = !!title,
707
874
  onSuccess,
708
875
  onError
709
876
  }) => {
@@ -750,49 +917,89 @@ const ResetPasswordForm = ({
750
917
  }
751
918
  };
752
919
  if (successMessage) {
753
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `auth-form-success ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "auth-form-success-message", children: successMessage }) });
920
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.container, className), children: [
921
+ showTitle && title && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: AUTH_FORM_CLASSES.header, children: [
922
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: cn(AUTH_FORM_CLASSES.title, titleClassName), children: title }),
923
+ subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: cn(AUTH_FORM_CLASSES.subtitle, subtitleClassName), children: subtitle })
924
+ ] }),
925
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(AUTH_FORM_CLASSES.success, successClassName), role: "status", children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: successMessage }) })
926
+ ] });
754
927
  }
755
- return /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className, children: [
756
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "auth-form-group", children: [
757
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", className: "auth-form-label", children: labels.password || "New Password" }),
758
- /* @__PURE__ */ jsxRuntime.jsx(
759
- "input",
760
- {
761
- id: "password",
762
- type: "password",
763
- value: password,
764
- onChange: (e) => setPassword(e.target.value),
765
- placeholder: placeholders.password || "••••••••",
766
- disabled: isLoading,
767
- className: "auth-form-input",
768
- required: true
769
- }
770
- )
771
- ] }),
772
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "auth-form-group", children: [
773
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "confirmPassword", className: "auth-form-label", children: labels.confirmPassword || "Confirm Password" }),
774
- /* @__PURE__ */ jsxRuntime.jsx(
775
- "input",
776
- {
777
- id: "confirmPassword",
778
- type: "password",
779
- value: confirmPassword,
780
- onChange: (e) => setConfirmPassword(e.target.value),
781
- placeholder: placeholders.confirmPassword || "••••••••",
782
- disabled: isLoading,
783
- className: "auth-form-input",
784
- required: true
785
- }
786
- )
928
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.container, className), children: [
929
+ showTitle && title && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: AUTH_FORM_CLASSES.header, children: [
930
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: cn(AUTH_FORM_CLASSES.title, titleClassName), children: title }),
931
+ subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: cn(AUTH_FORM_CLASSES.subtitle, subtitleClassName), children: subtitle })
787
932
  ] }),
788
- error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "auth-form-error", children: error }),
789
- /* @__PURE__ */ jsxRuntime.jsx(
790
- "button",
933
+ /* @__PURE__ */ jsxRuntime.jsxs(
934
+ "form",
791
935
  {
792
- type: "submit",
793
- disabled: isLoading,
794
- className: "auth-form-button auth-form-button-primary",
795
- children: isLoading ? "Loading..." : submitButtonText
936
+ onSubmit: handleSubmit,
937
+ className: cn(AUTH_FORM_CLASSES.form, formClassName),
938
+ "aria-busy": isLoading,
939
+ children: [
940
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.field, fieldClassName), children: [
941
+ /* @__PURE__ */ jsxRuntime.jsx(
942
+ "label",
943
+ {
944
+ htmlFor: "password",
945
+ className: cn(AUTH_FORM_CLASSES.label, labelClassName),
946
+ children: labels.password || "New Password"
947
+ }
948
+ ),
949
+ /* @__PURE__ */ jsxRuntime.jsx(
950
+ "input",
951
+ {
952
+ id: "password",
953
+ type: "password",
954
+ value: password,
955
+ onChange: (e) => setPassword(e.target.value),
956
+ placeholder: placeholders.password || "Enter a new password",
957
+ disabled: isLoading,
958
+ className: cn(AUTH_FORM_CLASSES.input, inputClassName),
959
+ autoComplete: "new-password",
960
+ required: true
961
+ }
962
+ )
963
+ ] }),
964
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.field, fieldClassName), children: [
965
+ /* @__PURE__ */ jsxRuntime.jsx(
966
+ "label",
967
+ {
968
+ htmlFor: "confirmPassword",
969
+ className: cn(AUTH_FORM_CLASSES.label, labelClassName),
970
+ children: labels.confirmPassword || "Confirm Password"
971
+ }
972
+ ),
973
+ /* @__PURE__ */ jsxRuntime.jsx(
974
+ "input",
975
+ {
976
+ id: "confirmPassword",
977
+ type: "password",
978
+ value: confirmPassword,
979
+ onChange: (e) => setConfirmPassword(e.target.value),
980
+ placeholder: placeholders.confirmPassword || "Confirm your new password",
981
+ disabled: isLoading,
982
+ className: cn(AUTH_FORM_CLASSES.input, inputClassName),
983
+ autoComplete: "new-password",
984
+ required: true
985
+ }
986
+ )
987
+ ] }),
988
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(AUTH_FORM_CLASSES.error, errorClassName), role: "alert", children: error }),
989
+ /* @__PURE__ */ jsxRuntime.jsx(
990
+ "button",
991
+ {
992
+ type: "submit",
993
+ disabled: isLoading,
994
+ className: cn(AUTH_FORM_CLASSES.button, buttonClassName),
995
+ "aria-busy": isLoading,
996
+ children: isLoading ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: AUTH_FORM_CLASSES.buttonContent, children: [
997
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: AUTH_FORM_CLASSES.buttonSpinner, "aria-hidden": "true" }),
998
+ loadingText
999
+ ] }) : submitButtonText
1000
+ }
1001
+ )
1002
+ ]
796
1003
  }
797
1004
  )
798
1005
  ] });
@@ -801,10 +1008,23 @@ ResetPasswordForm.displayName = "ResetPasswordForm";
801
1008
  const VerifyEmailForm = ({
802
1009
  token: initialToken,
803
1010
  email: initialEmail,
804
- className = "",
1011
+ className,
1012
+ formClassName,
1013
+ fieldClassName,
1014
+ labelClassName,
1015
+ inputClassName,
1016
+ buttonClassName,
1017
+ errorClassName,
1018
+ successClassName,
1019
+ titleClassName,
1020
+ subtitleClassName,
805
1021
  labels = {},
806
1022
  placeholders = {},
807
1023
  submitButtonText = "Verify Email",
1024
+ loadingText = "Verifying...",
1025
+ title,
1026
+ subtitle,
1027
+ showTitle = !!title,
808
1028
  onSuccess,
809
1029
  onError
810
1030
  }) => {
@@ -819,12 +1039,6 @@ const VerifyEmailForm = ({
819
1039
  const [successMessage, setSuccessMessage] = React.useState("");
820
1040
  const isLoading = authLoading;
821
1041
  const error = formError || authError?.message;
822
- React.useEffect(() => {
823
- if (token && email && !successMessage && !error) {
824
- handleSubmit({ preventDefault: () => {
825
- } });
826
- }
827
- }, [token, email]);
828
1042
  const handleSubmit = async (e) => {
829
1043
  e.preventDefault();
830
1044
  setFormError("");
@@ -850,50 +1064,82 @@ const VerifyEmailForm = ({
850
1064
  });
851
1065
  }
852
1066
  };
1067
+ React.useEffect(() => {
1068
+ if (token && email && !successMessage && !error) {
1069
+ void handleSubmit({ preventDefault: () => {
1070
+ } });
1071
+ }
1072
+ }, [token, email]);
853
1073
  if (successMessage) {
854
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `auth-form-success ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "auth-form-success-message", children: successMessage }) });
1074
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.container, className), children: [
1075
+ showTitle && title && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: AUTH_FORM_CLASSES.header, children: [
1076
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: cn(AUTH_FORM_CLASSES.title, titleClassName), children: title }),
1077
+ subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: cn(AUTH_FORM_CLASSES.subtitle, subtitleClassName), children: subtitle })
1078
+ ] }),
1079
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(AUTH_FORM_CLASSES.success, successClassName), role: "status", children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: successMessage }) })
1080
+ ] });
855
1081
  }
856
- return /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className, children: [
857
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "auth-form-group", children: [
858
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", className: "auth-form-label", children: labels.email || "Email" }),
859
- /* @__PURE__ */ jsxRuntime.jsx(
860
- "input",
861
- {
862
- id: "email",
863
- type: "email",
864
- value: email,
865
- onChange: (e) => setEmail(e.target.value),
866
- placeholder: placeholders.email || "your@email.com",
867
- disabled: isLoading,
868
- className: "auth-form-input",
869
- required: true
870
- }
871
- )
872
- ] }),
873
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "auth-form-group", children: [
874
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "token", className: "auth-form-label", children: labels.token || "Verification Code" }),
875
- /* @__PURE__ */ jsxRuntime.jsx(
876
- "input",
877
- {
878
- id: "token",
879
- type: "text",
880
- value: token,
881
- onChange: (e) => setToken(e.target.value),
882
- placeholder: placeholders.token || "Enter verification code",
883
- disabled: isLoading,
884
- className: "auth-form-input",
885
- required: true
886
- }
887
- )
1082
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.container, className), children: [
1083
+ showTitle && title && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: AUTH_FORM_CLASSES.header, children: [
1084
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: cn(AUTH_FORM_CLASSES.title, titleClassName), children: title }),
1085
+ subtitle && /* @__PURE__ */ jsxRuntime.jsx("p", { className: cn(AUTH_FORM_CLASSES.subtitle, subtitleClassName), children: subtitle })
888
1086
  ] }),
889
- error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "auth-form-error", children: error }),
890
- /* @__PURE__ */ jsxRuntime.jsx(
891
- "button",
1087
+ /* @__PURE__ */ jsxRuntime.jsxs(
1088
+ "form",
892
1089
  {
893
- type: "submit",
894
- disabled: isLoading,
895
- className: "auth-form-button auth-form-button-primary",
896
- children: isLoading ? "Loading..." : submitButtonText
1090
+ onSubmit: handleSubmit,
1091
+ className: cn(AUTH_FORM_CLASSES.form, formClassName),
1092
+ "aria-busy": isLoading,
1093
+ children: [
1094
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.field, fieldClassName), children: [
1095
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", className: cn(AUTH_FORM_CLASSES.label, labelClassName), children: labels.email || "Email" }),
1096
+ /* @__PURE__ */ jsxRuntime.jsx(
1097
+ "input",
1098
+ {
1099
+ id: "email",
1100
+ type: "email",
1101
+ value: email,
1102
+ onChange: (e) => setEmail(e.target.value),
1103
+ placeholder: placeholders.email || "your@email.com",
1104
+ disabled: isLoading,
1105
+ className: cn(AUTH_FORM_CLASSES.input, inputClassName),
1106
+ autoComplete: "email",
1107
+ required: true
1108
+ }
1109
+ )
1110
+ ] }),
1111
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(AUTH_FORM_CLASSES.field, fieldClassName), children: [
1112
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "token", className: cn(AUTH_FORM_CLASSES.label, labelClassName), children: labels.token || "Verification Code" }),
1113
+ /* @__PURE__ */ jsxRuntime.jsx(
1114
+ "input",
1115
+ {
1116
+ id: "token",
1117
+ type: "text",
1118
+ value: token,
1119
+ onChange: (e) => setToken(e.target.value),
1120
+ placeholder: placeholders.token || "Enter verification code",
1121
+ disabled: isLoading,
1122
+ className: cn(AUTH_FORM_CLASSES.input, inputClassName),
1123
+ autoComplete: "one-time-code",
1124
+ required: true
1125
+ }
1126
+ )
1127
+ ] }),
1128
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(AUTH_FORM_CLASSES.error, errorClassName), role: "alert", children: error }),
1129
+ /* @__PURE__ */ jsxRuntime.jsx(
1130
+ "button",
1131
+ {
1132
+ type: "submit",
1133
+ disabled: isLoading,
1134
+ className: cn(AUTH_FORM_CLASSES.button, buttonClassName),
1135
+ "aria-busy": isLoading,
1136
+ children: isLoading ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: AUTH_FORM_CLASSES.buttonContent, children: [
1137
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: AUTH_FORM_CLASSES.buttonSpinner, "aria-hidden": "true" }),
1138
+ loadingText
1139
+ ] }) : submitButtonText
1140
+ }
1141
+ )
1142
+ ]
897
1143
  }
898
1144
  )
899
1145
  ] });
@@ -938,6 +1184,7 @@ exports.ProtectedRoute = ProtectedRoute;
938
1184
  exports.RegisterForm = RegisterForm;
939
1185
  exports.ResetPasswordForm = ResetPasswordForm;
940
1186
  exports.VerifyEmailForm = VerifyEmailForm;
1187
+ exports.cn = cn;
941
1188
  exports.createAuthClient = createAuthClient;
942
1189
  exports.normalizeError = normalizeError;
943
1190
  exports.useAuth = useAuth;