@drmhse/authos-react 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -407,6 +407,8 @@ If you prefer to completely style the components yourself, you can target the da
407
407
  [data-authos-oauth] { /* OAuth button */ }
408
408
  [data-authos-oauth][data-provider="github"] { /* GitHub button */ }
409
409
  [data-authos-divider] { /* "or" divider */ }
410
+ [data-authos-magic-link] { /* Magic Link container */ }
411
+ [data-authos-passkey] { /* Passkey container */ }
410
412
  ```
411
413
 
412
414
  ## Security Considerations
package/dist/index.d.mts CHANGED
@@ -199,6 +199,19 @@ interface SignUpProps {
199
199
  showSignIn?: boolean;
200
200
  /** Custom class name for the form container */
201
201
  className?: string;
202
+ /**
203
+ * OAuth providers to display as buttons.
204
+ * Set to false to hide all OAuth buttons, or provide an array of providers.
205
+ * @default false (no OAuth buttons shown by default)
206
+ * @example ['github', 'google', 'microsoft']
207
+ */
208
+ providers?: ('github' | 'google' | 'microsoft')[] | false;
209
+ /**
210
+ * Show a divider between OAuth and email/password forms.
211
+ * Only visible when providers are enabled.
212
+ * @default true
213
+ */
214
+ showDivider?: boolean;
202
215
  }
203
216
  /**
204
217
  * Props for the OrganizationSwitcher component
@@ -501,12 +514,13 @@ declare function SignIn({ onSuccess, onError, showForgotPassword, showSignUp, cl
501
514
  * <SignUp
502
515
  * onSuccess={() => console.log('Registration successful!')}
503
516
  * onError={(error) => console.error('Registration failed:', error)}
517
+ * providers={['github', 'google']}
504
518
  * />
505
519
  * );
506
520
  * }
507
521
  * ```
508
522
  */
509
- declare function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn, className }: SignUpProps): react_jsx_runtime.JSX.Element;
523
+ declare function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn, className, providers, showDivider, }: SignUpProps): react_jsx_runtime.JSX.Element;
510
524
 
511
525
  /**
512
526
  * Component for switching between organizations.
package/dist/index.d.ts CHANGED
@@ -199,6 +199,19 @@ interface SignUpProps {
199
199
  showSignIn?: boolean;
200
200
  /** Custom class name for the form container */
201
201
  className?: string;
202
+ /**
203
+ * OAuth providers to display as buttons.
204
+ * Set to false to hide all OAuth buttons, or provide an array of providers.
205
+ * @default false (no OAuth buttons shown by default)
206
+ * @example ['github', 'google', 'microsoft']
207
+ */
208
+ providers?: ('github' | 'google' | 'microsoft')[] | false;
209
+ /**
210
+ * Show a divider between OAuth and email/password forms.
211
+ * Only visible when providers are enabled.
212
+ * @default true
213
+ */
214
+ showDivider?: boolean;
202
215
  }
203
216
  /**
204
217
  * Props for the OrganizationSwitcher component
@@ -501,12 +514,13 @@ declare function SignIn({ onSuccess, onError, showForgotPassword, showSignUp, cl
501
514
  * <SignUp
502
515
  * onSuccess={() => console.log('Registration successful!')}
503
516
  * onError={(error) => console.error('Registration failed:', error)}
517
+ * providers={['github', 'google']}
504
518
  * />
505
519
  * );
506
520
  * }
507
521
  * ```
508
522
  */
509
- declare function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn, className }: SignUpProps): react_jsx_runtime.JSX.Element;
523
+ declare function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn, className, providers, showDivider, }: SignUpProps): react_jsx_runtime.JSX.Element;
510
524
 
511
525
  /**
512
526
  * Component for switching between organizations.
package/dist/index.js CHANGED
@@ -87,26 +87,37 @@ var AUTHOS_STYLES = `
87
87
  }
88
88
 
89
89
  /* ==========================================================================
90
- Base Form Styles
90
+ Base Form Styles (Card Layout)
91
91
  ========================================================================== */
92
92
 
93
93
  [data-authos-signin],
94
94
  [data-authos-signup],
95
- [data-authos-magiclink],
95
+ [data-authos-magic-link],
96
96
  [data-authos-passkey] {
97
97
  font-family: var(--authos-font-family);
98
98
  font-size: var(--authos-font-size-sm);
99
99
  color: var(--authos-color-foreground);
100
+
101
+ /* Card Styling */
102
+ background-color: var(--authos-color-surface);
103
+ border: 1px solid var(--authos-color-border);
104
+ border-radius: var(--authos-border-radius-lg);
105
+ box-shadow: var(--authos-shadow);
106
+ padding: 2rem;
100
107
  width: 100%;
108
+ max-width: 25rem; /* 400px */
109
+ margin: 0 auto; /* Center horizontally */
101
110
  }
102
111
 
112
+ /* Ensure forms inside take full width */
103
113
  [data-authos-signin] form,
104
114
  [data-authos-signup] form,
105
- [data-authos-magiclink] form,
115
+ [data-authos-magic-link] form,
106
116
  [data-authos-passkey] form {
107
117
  display: flex;
108
118
  flex-direction: column;
109
119
  gap: var(--authos-spacing-md);
120
+ width: 100%;
110
121
  }
111
122
 
112
123
  /* ==========================================================================
@@ -430,39 +441,95 @@ var AUTHOS_STYLES = `
430
441
  ========================================================================== */
431
442
 
432
443
  [data-authos-orgswitcher] {
444
+ position: relative;
433
445
  font-family: var(--authos-font-family);
434
446
  font-size: var(--authos-font-size-sm);
447
+ color: var(--authos-color-foreground);
435
448
  }
436
449
 
437
- [data-authos-orgswitcher] select {
438
- padding: 0.5rem 2rem 0.5rem 0.75rem;
450
+ [data-authos-org-trigger] {
451
+ display: flex;
452
+ align-items: center;
453
+ justify-content: space-between;
454
+ gap: var(--authos-spacing-sm);
455
+ width: 100%;
456
+ padding: 0.5rem 0.75rem;
439
457
  font-size: var(--authos-font-size-sm);
440
458
  font-family: inherit;
441
459
  color: var(--authos-color-foreground);
442
- background-color: var(--authos-color-input);
443
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
444
- background-repeat: no-repeat;
445
- background-position: right 0.5rem center;
460
+ background-color: var(--authos-color-surface);
446
461
  border: 1px solid var(--authos-color-input-border);
447
462
  border-radius: var(--authos-border-radius);
448
463
  cursor: pointer;
449
464
  outline: none;
450
- appearance: none;
451
- -webkit-appearance: none;
452
- -moz-appearance: none;
453
465
  transition: border-color var(--authos-transition), box-shadow var(--authos-transition);
454
466
  }
455
467
 
456
- [data-authos-orgswitcher] select:focus {
468
+ [data-authos-org-trigger]:focus-visible {
457
469
  border-color: var(--authos-color-input-focus);
458
470
  box-shadow: 0 0 0 3px var(--authos-color-ring);
459
471
  }
460
472
 
461
- [data-authos-orgswitcher] select:disabled {
473
+ [data-authos-org-trigger][disabled] {
462
474
  opacity: 0.6;
463
475
  cursor: not-allowed;
464
476
  }
465
477
 
478
+ [data-authos-org-chevron] {
479
+ font-size: 0.625rem;
480
+ color: var(--authos-color-muted);
481
+ }
482
+
483
+ [data-authos-org-list] {
484
+ position: absolute;
485
+ top: 100%;
486
+ left: 0;
487
+ right: 0;
488
+ margin-top: var(--authos-spacing-xs);
489
+ padding: var(--authos-spacing-xs);
490
+ background-color: var(--authos-color-surface);
491
+ border: 1px solid var(--authos-color-border);
492
+ border-radius: var(--authos-border-radius);
493
+ box-shadow: var(--authos-shadow-lg);
494
+ list-style: none;
495
+ z-index: 50;
496
+ max-height: 240px;
497
+ overflow-y: auto;
498
+ animation: authos-fade-in 150ms ease-out;
499
+ }
500
+
501
+ [data-authos-org-item] {
502
+ display: flex;
503
+ align-items: center;
504
+ justify-content: space-between;
505
+ width: 100%;
506
+ padding: 0.5rem 0.75rem;
507
+ font-size: var(--authos-font-size-sm);
508
+ color: var(--authos-color-foreground);
509
+ background: transparent;
510
+ border: none;
511
+ border-radius: var(--authos-border-radius-sm);
512
+ cursor: pointer;
513
+ text-align: left;
514
+ transition: background-color var(--authos-transition);
515
+ }
516
+
517
+ [data-authos-org-item]:hover,
518
+ [data-authos-org-item]:focus-visible {
519
+ background-color: var(--authos-color-background);
520
+ outline: none;
521
+ }
522
+
523
+ [data-authos-org-item][data-active="true"] {
524
+ background-color: rgba(99, 102, 241, 0.05);
525
+ color: var(--authos-color-primary);
526
+ font-weight: 500;
527
+ }
528
+
529
+ [data-authos-org-item-check] {
530
+ color: var(--authos-color-primary);
531
+ }
532
+
466
533
  /* ==========================================================================
467
534
  Loading State
468
535
  ========================================================================== */
@@ -843,14 +910,25 @@ function SignIn({
843
910
  ] })
844
911
  ] });
845
912
  }
846
- function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn = true, className }) {
847
- const { client } = useAuthOSContext();
913
+ function SignUp({
914
+ onSuccess,
915
+ onError,
916
+ orgSlug,
917
+ serviceSlug,
918
+ showSignIn = true,
919
+ className,
920
+ providers = false,
921
+ showDivider = true
922
+ }) {
923
+ const { client, config } = useAuthOSContext();
848
924
  const [email, setEmail] = react.useState("");
849
925
  const [password, setPassword] = react.useState("");
850
926
  const [confirmPassword, setConfirmPassword] = react.useState("");
851
927
  const [error, setError] = react.useState(null);
852
928
  const [isLoading, setIsLoading] = react.useState(false);
853
929
  const [isSuccess, setIsSuccess] = react.useState(false);
930
+ const hasOAuthConfig = !!(config.org && config.service);
931
+ const oauthProviders = providers && Array.isArray(providers) ? providers : [];
854
932
  const handleSubmit = react.useCallback(
855
933
  async (e) => {
856
934
  e.preventDefault();
@@ -893,63 +971,77 @@ function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn = true, c
893
971
  ] })
894
972
  ] }) });
895
973
  }
896
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className, "data-authos-signup": true, "data-state": "form", children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
897
- /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-field": "email", children: [
898
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "authos-signup-email", children: "Email" }),
899
- /* @__PURE__ */ jsxRuntime.jsx(
900
- "input",
901
- {
902
- id: "authos-signup-email",
903
- type: "email",
904
- autoComplete: "email",
905
- value: email,
906
- onChange: (e) => setEmail(e.target.value),
907
- placeholder: "Enter your email",
908
- required: true,
909
- disabled: isLoading
910
- }
911
- )
912
- ] }),
913
- /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-field": "password", children: [
914
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "authos-signup-password", children: "Password" }),
915
- /* @__PURE__ */ jsxRuntime.jsx(
916
- "input",
917
- {
918
- id: "authos-signup-password",
919
- type: "password",
920
- autoComplete: "new-password",
921
- value: password,
922
- onChange: (e) => setPassword(e.target.value),
923
- placeholder: "Create a password",
924
- required: true,
925
- minLength: 8,
926
- disabled: isLoading
927
- }
928
- )
929
- ] }),
930
- /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-field": "confirm-password", children: [
931
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "authos-signup-confirm", children: "Confirm Password" }),
932
- /* @__PURE__ */ jsxRuntime.jsx(
933
- "input",
974
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, "data-authos-signup": true, "data-state": "form", children: [
975
+ oauthProviders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-oauth-section": "", children: [
976
+ oauthProviders.map((provider) => /* @__PURE__ */ jsxRuntime.jsx(
977
+ OAuthButton,
934
978
  {
935
- id: "authos-signup-confirm",
936
- type: "password",
937
- autoComplete: "new-password",
938
- value: confirmPassword,
939
- onChange: (e) => setConfirmPassword(e.target.value),
940
- placeholder: "Confirm your password",
941
- required: true,
942
- disabled: isLoading
943
- }
944
- )
979
+ provider,
980
+ disabled: isLoading || !hasOAuthConfig
981
+ },
982
+ provider
983
+ )),
984
+ !hasOAuthConfig && /* @__PURE__ */ jsxRuntime.jsx("p", { "data-authos-oauth-warning": "", style: { color: "orange", fontSize: "0.875rem" }, children: "OAuth requires org and service in AuthOSProvider config" })
945
985
  ] }),
946
- error && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-authos-error": true, children: error }),
947
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", disabled: isLoading, "data-authos-submit": true, children: isLoading ? "Creating account..." : "Create Account" }),
948
- showSignIn && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-signin-prompt": true, children: [
949
- "Already have an account? ",
950
- /* @__PURE__ */ jsxRuntime.jsx("a", { href: "/signin", "data-authos-link": "signin", children: "Sign in" })
986
+ oauthProviders.length > 0 && showDivider && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-authos-divider": "", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "or" }) }),
987
+ /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
988
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-field": "email", children: [
989
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "authos-signup-email", children: "Email" }),
990
+ /* @__PURE__ */ jsxRuntime.jsx(
991
+ "input",
992
+ {
993
+ id: "authos-signup-email",
994
+ type: "email",
995
+ autoComplete: "email",
996
+ value: email,
997
+ onChange: (e) => setEmail(e.target.value),
998
+ placeholder: "Enter your email",
999
+ required: true,
1000
+ disabled: isLoading
1001
+ }
1002
+ )
1003
+ ] }),
1004
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-field": "password", children: [
1005
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "authos-signup-password", children: "Password" }),
1006
+ /* @__PURE__ */ jsxRuntime.jsx(
1007
+ "input",
1008
+ {
1009
+ id: "authos-signup-password",
1010
+ type: "password",
1011
+ autoComplete: "new-password",
1012
+ value: password,
1013
+ onChange: (e) => setPassword(e.target.value),
1014
+ placeholder: "Create a password",
1015
+ required: true,
1016
+ minLength: 8,
1017
+ disabled: isLoading
1018
+ }
1019
+ )
1020
+ ] }),
1021
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-field": "confirm-password", children: [
1022
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "authos-signup-confirm", children: "Confirm Password" }),
1023
+ /* @__PURE__ */ jsxRuntime.jsx(
1024
+ "input",
1025
+ {
1026
+ id: "authos-signup-confirm",
1027
+ type: "password",
1028
+ autoComplete: "new-password",
1029
+ value: confirmPassword,
1030
+ onChange: (e) => setConfirmPassword(e.target.value),
1031
+ placeholder: "Confirm your password",
1032
+ required: true,
1033
+ disabled: isLoading
1034
+ }
1035
+ )
1036
+ ] }),
1037
+ error && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-authos-error": true, children: error }),
1038
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", disabled: isLoading, "data-authos-submit": true, children: isLoading ? "Creating account..." : "Create Account" }),
1039
+ showSignIn && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-authos-signin-prompt": true, children: [
1040
+ "Already have an account? ",
1041
+ /* @__PURE__ */ jsxRuntime.jsx("a", { href: "/signin", "data-authos-link": "signin", children: "Sign in" })
1042
+ ] })
951
1043
  ] })
952
- ] }) });
1044
+ ] });
953
1045
  }
954
1046
  function OrganizationSwitcher({ onSwitch, className, renderItem }) {
955
1047
  const { client, isAuthenticated } = useAuthOSContext();
package/dist/index.mjs CHANGED
@@ -86,26 +86,37 @@ var AUTHOS_STYLES = `
86
86
  }
87
87
 
88
88
  /* ==========================================================================
89
- Base Form Styles
89
+ Base Form Styles (Card Layout)
90
90
  ========================================================================== */
91
91
 
92
92
  [data-authos-signin],
93
93
  [data-authos-signup],
94
- [data-authos-magiclink],
94
+ [data-authos-magic-link],
95
95
  [data-authos-passkey] {
96
96
  font-family: var(--authos-font-family);
97
97
  font-size: var(--authos-font-size-sm);
98
98
  color: var(--authos-color-foreground);
99
+
100
+ /* Card Styling */
101
+ background-color: var(--authos-color-surface);
102
+ border: 1px solid var(--authos-color-border);
103
+ border-radius: var(--authos-border-radius-lg);
104
+ box-shadow: var(--authos-shadow);
105
+ padding: 2rem;
99
106
  width: 100%;
107
+ max-width: 25rem; /* 400px */
108
+ margin: 0 auto; /* Center horizontally */
100
109
  }
101
110
 
111
+ /* Ensure forms inside take full width */
102
112
  [data-authos-signin] form,
103
113
  [data-authos-signup] form,
104
- [data-authos-magiclink] form,
114
+ [data-authos-magic-link] form,
105
115
  [data-authos-passkey] form {
106
116
  display: flex;
107
117
  flex-direction: column;
108
118
  gap: var(--authos-spacing-md);
119
+ width: 100%;
109
120
  }
110
121
 
111
122
  /* ==========================================================================
@@ -429,39 +440,95 @@ var AUTHOS_STYLES = `
429
440
  ========================================================================== */
430
441
 
431
442
  [data-authos-orgswitcher] {
443
+ position: relative;
432
444
  font-family: var(--authos-font-family);
433
445
  font-size: var(--authos-font-size-sm);
446
+ color: var(--authos-color-foreground);
434
447
  }
435
448
 
436
- [data-authos-orgswitcher] select {
437
- padding: 0.5rem 2rem 0.5rem 0.75rem;
449
+ [data-authos-org-trigger] {
450
+ display: flex;
451
+ align-items: center;
452
+ justify-content: space-between;
453
+ gap: var(--authos-spacing-sm);
454
+ width: 100%;
455
+ padding: 0.5rem 0.75rem;
438
456
  font-size: var(--authos-font-size-sm);
439
457
  font-family: inherit;
440
458
  color: var(--authos-color-foreground);
441
- background-color: var(--authos-color-input);
442
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
443
- background-repeat: no-repeat;
444
- background-position: right 0.5rem center;
459
+ background-color: var(--authos-color-surface);
445
460
  border: 1px solid var(--authos-color-input-border);
446
461
  border-radius: var(--authos-border-radius);
447
462
  cursor: pointer;
448
463
  outline: none;
449
- appearance: none;
450
- -webkit-appearance: none;
451
- -moz-appearance: none;
452
464
  transition: border-color var(--authos-transition), box-shadow var(--authos-transition);
453
465
  }
454
466
 
455
- [data-authos-orgswitcher] select:focus {
467
+ [data-authos-org-trigger]:focus-visible {
456
468
  border-color: var(--authos-color-input-focus);
457
469
  box-shadow: 0 0 0 3px var(--authos-color-ring);
458
470
  }
459
471
 
460
- [data-authos-orgswitcher] select:disabled {
472
+ [data-authos-org-trigger][disabled] {
461
473
  opacity: 0.6;
462
474
  cursor: not-allowed;
463
475
  }
464
476
 
477
+ [data-authos-org-chevron] {
478
+ font-size: 0.625rem;
479
+ color: var(--authos-color-muted);
480
+ }
481
+
482
+ [data-authos-org-list] {
483
+ position: absolute;
484
+ top: 100%;
485
+ left: 0;
486
+ right: 0;
487
+ margin-top: var(--authos-spacing-xs);
488
+ padding: var(--authos-spacing-xs);
489
+ background-color: var(--authos-color-surface);
490
+ border: 1px solid var(--authos-color-border);
491
+ border-radius: var(--authos-border-radius);
492
+ box-shadow: var(--authos-shadow-lg);
493
+ list-style: none;
494
+ z-index: 50;
495
+ max-height: 240px;
496
+ overflow-y: auto;
497
+ animation: authos-fade-in 150ms ease-out;
498
+ }
499
+
500
+ [data-authos-org-item] {
501
+ display: flex;
502
+ align-items: center;
503
+ justify-content: space-between;
504
+ width: 100%;
505
+ padding: 0.5rem 0.75rem;
506
+ font-size: var(--authos-font-size-sm);
507
+ color: var(--authos-color-foreground);
508
+ background: transparent;
509
+ border: none;
510
+ border-radius: var(--authos-border-radius-sm);
511
+ cursor: pointer;
512
+ text-align: left;
513
+ transition: background-color var(--authos-transition);
514
+ }
515
+
516
+ [data-authos-org-item]:hover,
517
+ [data-authos-org-item]:focus-visible {
518
+ background-color: var(--authos-color-background);
519
+ outline: none;
520
+ }
521
+
522
+ [data-authos-org-item][data-active="true"] {
523
+ background-color: rgba(99, 102, 241, 0.05);
524
+ color: var(--authos-color-primary);
525
+ font-weight: 500;
526
+ }
527
+
528
+ [data-authos-org-item-check] {
529
+ color: var(--authos-color-primary);
530
+ }
531
+
465
532
  /* ==========================================================================
466
533
  Loading State
467
534
  ========================================================================== */
@@ -842,14 +909,25 @@ function SignIn({
842
909
  ] })
843
910
  ] });
844
911
  }
845
- function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn = true, className }) {
846
- const { client } = useAuthOSContext();
912
+ function SignUp({
913
+ onSuccess,
914
+ onError,
915
+ orgSlug,
916
+ serviceSlug,
917
+ showSignIn = true,
918
+ className,
919
+ providers = false,
920
+ showDivider = true
921
+ }) {
922
+ const { client, config } = useAuthOSContext();
847
923
  const [email, setEmail] = useState("");
848
924
  const [password, setPassword] = useState("");
849
925
  const [confirmPassword, setConfirmPassword] = useState("");
850
926
  const [error, setError] = useState(null);
851
927
  const [isLoading, setIsLoading] = useState(false);
852
928
  const [isSuccess, setIsSuccess] = useState(false);
929
+ const hasOAuthConfig = !!(config.org && config.service);
930
+ const oauthProviders = providers && Array.isArray(providers) ? providers : [];
853
931
  const handleSubmit = useCallback(
854
932
  async (e) => {
855
933
  e.preventDefault();
@@ -892,63 +970,77 @@ function SignUp({ onSuccess, onError, orgSlug, serviceSlug, showSignIn = true, c
892
970
  ] })
893
971
  ] }) });
894
972
  }
895
- return /* @__PURE__ */ jsx("div", { className, "data-authos-signup": true, "data-state": "form", children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
896
- /* @__PURE__ */ jsxs("div", { "data-authos-field": "email", children: [
897
- /* @__PURE__ */ jsx("label", { htmlFor: "authos-signup-email", children: "Email" }),
898
- /* @__PURE__ */ jsx(
899
- "input",
900
- {
901
- id: "authos-signup-email",
902
- type: "email",
903
- autoComplete: "email",
904
- value: email,
905
- onChange: (e) => setEmail(e.target.value),
906
- placeholder: "Enter your email",
907
- required: true,
908
- disabled: isLoading
909
- }
910
- )
911
- ] }),
912
- /* @__PURE__ */ jsxs("div", { "data-authos-field": "password", children: [
913
- /* @__PURE__ */ jsx("label", { htmlFor: "authos-signup-password", children: "Password" }),
914
- /* @__PURE__ */ jsx(
915
- "input",
916
- {
917
- id: "authos-signup-password",
918
- type: "password",
919
- autoComplete: "new-password",
920
- value: password,
921
- onChange: (e) => setPassword(e.target.value),
922
- placeholder: "Create a password",
923
- required: true,
924
- minLength: 8,
925
- disabled: isLoading
926
- }
927
- )
928
- ] }),
929
- /* @__PURE__ */ jsxs("div", { "data-authos-field": "confirm-password", children: [
930
- /* @__PURE__ */ jsx("label", { htmlFor: "authos-signup-confirm", children: "Confirm Password" }),
931
- /* @__PURE__ */ jsx(
932
- "input",
973
+ return /* @__PURE__ */ jsxs("div", { className, "data-authos-signup": true, "data-state": "form", children: [
974
+ oauthProviders.length > 0 && /* @__PURE__ */ jsxs("div", { "data-authos-oauth-section": "", children: [
975
+ oauthProviders.map((provider) => /* @__PURE__ */ jsx(
976
+ OAuthButton,
933
977
  {
934
- id: "authos-signup-confirm",
935
- type: "password",
936
- autoComplete: "new-password",
937
- value: confirmPassword,
938
- onChange: (e) => setConfirmPassword(e.target.value),
939
- placeholder: "Confirm your password",
940
- required: true,
941
- disabled: isLoading
942
- }
943
- )
978
+ provider,
979
+ disabled: isLoading || !hasOAuthConfig
980
+ },
981
+ provider
982
+ )),
983
+ !hasOAuthConfig && /* @__PURE__ */ jsx("p", { "data-authos-oauth-warning": "", style: { color: "orange", fontSize: "0.875rem" }, children: "OAuth requires org and service in AuthOSProvider config" })
944
984
  ] }),
945
- error && /* @__PURE__ */ jsx("div", { "data-authos-error": true, children: error }),
946
- /* @__PURE__ */ jsx("button", { type: "submit", disabled: isLoading, "data-authos-submit": true, children: isLoading ? "Creating account..." : "Create Account" }),
947
- showSignIn && /* @__PURE__ */ jsxs("div", { "data-authos-signin-prompt": true, children: [
948
- "Already have an account? ",
949
- /* @__PURE__ */ jsx("a", { href: "/signin", "data-authos-link": "signin", children: "Sign in" })
985
+ oauthProviders.length > 0 && showDivider && /* @__PURE__ */ jsx("div", { "data-authos-divider": "", children: /* @__PURE__ */ jsx("span", { children: "or" }) }),
986
+ /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
987
+ /* @__PURE__ */ jsxs("div", { "data-authos-field": "email", children: [
988
+ /* @__PURE__ */ jsx("label", { htmlFor: "authos-signup-email", children: "Email" }),
989
+ /* @__PURE__ */ jsx(
990
+ "input",
991
+ {
992
+ id: "authos-signup-email",
993
+ type: "email",
994
+ autoComplete: "email",
995
+ value: email,
996
+ onChange: (e) => setEmail(e.target.value),
997
+ placeholder: "Enter your email",
998
+ required: true,
999
+ disabled: isLoading
1000
+ }
1001
+ )
1002
+ ] }),
1003
+ /* @__PURE__ */ jsxs("div", { "data-authos-field": "password", children: [
1004
+ /* @__PURE__ */ jsx("label", { htmlFor: "authos-signup-password", children: "Password" }),
1005
+ /* @__PURE__ */ jsx(
1006
+ "input",
1007
+ {
1008
+ id: "authos-signup-password",
1009
+ type: "password",
1010
+ autoComplete: "new-password",
1011
+ value: password,
1012
+ onChange: (e) => setPassword(e.target.value),
1013
+ placeholder: "Create a password",
1014
+ required: true,
1015
+ minLength: 8,
1016
+ disabled: isLoading
1017
+ }
1018
+ )
1019
+ ] }),
1020
+ /* @__PURE__ */ jsxs("div", { "data-authos-field": "confirm-password", children: [
1021
+ /* @__PURE__ */ jsx("label", { htmlFor: "authos-signup-confirm", children: "Confirm Password" }),
1022
+ /* @__PURE__ */ jsx(
1023
+ "input",
1024
+ {
1025
+ id: "authos-signup-confirm",
1026
+ type: "password",
1027
+ autoComplete: "new-password",
1028
+ value: confirmPassword,
1029
+ onChange: (e) => setConfirmPassword(e.target.value),
1030
+ placeholder: "Confirm your password",
1031
+ required: true,
1032
+ disabled: isLoading
1033
+ }
1034
+ )
1035
+ ] }),
1036
+ error && /* @__PURE__ */ jsx("div", { "data-authos-error": true, children: error }),
1037
+ /* @__PURE__ */ jsx("button", { type: "submit", disabled: isLoading, "data-authos-submit": true, children: isLoading ? "Creating account..." : "Create Account" }),
1038
+ showSignIn && /* @__PURE__ */ jsxs("div", { "data-authos-signin-prompt": true, children: [
1039
+ "Already have an account? ",
1040
+ /* @__PURE__ */ jsx("a", { href: "/signin", "data-authos-link": "signin", children: "Sign in" })
1041
+ ] })
950
1042
  ] })
951
- ] }) });
1043
+ ] });
952
1044
  }
953
1045
  function OrganizationSwitcher({ onSwitch, className, renderItem }) {
954
1046
  const { client, isAuthenticated } = useAuthOSContext();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drmhse/authos-react",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "React and Next.js adapter for AuthOS authentication",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",