@pradip1995/segment-login-template 0.5.25 → 0.5.27

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.
Files changed (38) hide show
  1. package/package.json +2 -2
  2. package/src/account-addresses.tsx +287 -287
  3. package/src/account-guest-orders.tsx +98 -98
  4. package/src/account-orders.tsx +260 -260
  5. package/src/account-overview.tsx +133 -133
  6. package/src/account-payment-methods.tsx +328 -328
  7. package/src/account-profile-logic.ts +282 -282
  8. package/src/account-profile.tsx +111 -111
  9. package/src/account-theme.ts +91 -91
  10. package/src/account-utils.ts +20 -20
  11. package/src/auth-server.ts +442 -442
  12. package/src/commerce-auth-otp-modal.css +125 -125
  13. package/src/commerce-auth-otp-modal.tsx +121 -121
  14. package/src/forgot-password-form.tsx +109 -109
  15. package/src/google-auth-section.tsx +22 -22
  16. package/src/google-sign-in-section.tsx +67 -67
  17. package/src/guest-order-modal.tsx +215 -215
  18. package/src/index.ts +7 -7
  19. package/src/is-next-redirect.ts +60 -60
  20. package/src/login-brand-panel.tsx +6 -5
  21. package/src/login-form.tsx +469 -469
  22. package/src/manifest.ts +11 -11
  23. package/src/order-history-status.test.ts +224 -224
  24. package/src/order-history-status.ts +244 -244
  25. package/src/otp-component.ts +14 -14
  26. package/src/otp-input.tsx +46 -46
  27. package/src/otp-unified-form.tsx +333 -333
  28. package/src/otp-verification-modal.tsx +112 -112
  29. package/src/payment-methods-actions.ts +243 -243
  30. package/src/profile-email-field.tsx +116 -116
  31. package/src/profile-email.test.ts +182 -182
  32. package/src/profile-email.ts +54 -54
  33. package/src/profile-phone-field.tsx +119 -119
  34. package/src/register-form.tsx +339 -339
  35. package/src/reorder-checkout-address.ts +101 -101
  36. package/src/reset-password-form.tsx +103 -103
  37. package/src/reset-password-page.tsx +12 -12
  38. package/src/segment.tsx +272 -272
@@ -1,125 +1,125 @@
1
- .sr-otp-modal {
2
- position: fixed;
3
- inset: 0;
4
- z-index: 90;
5
- display: flex;
6
- align-items: center;
7
- justify-content: center;
8
- padding: 1rem;
9
- }
10
-
11
- .sr-otp-modal__backdrop {
12
- position: absolute;
13
- inset: 0;
14
- border: 0;
15
- background: rgba(10, 16, 28, 0.48);
16
- cursor: pointer;
17
- }
18
-
19
- .sr-otp-modal__panel {
20
- position: relative;
21
- z-index: 1;
22
- width: min(100%, 22rem);
23
- max-height: min(92vh, 36rem);
24
- overflow: auto;
25
- padding: 1.35rem 1.15rem 1.2rem;
26
- border-radius: 1rem;
27
- background: #ffffff;
28
- box-shadow: 0 18px 44px rgba(19, 38, 77, 0.22);
29
- }
30
-
31
- .sr-otp-modal__panel > div {
32
- display: flex;
33
- flex-direction: column;
34
- gap: 1.15rem;
35
- }
36
-
37
- .sr-otp-modal__title {
38
- margin: 0;
39
- font-family: var(--font-heading, Georgia, serif);
40
- font-size: 1.65rem;
41
- font-weight: 500;
42
- line-height: 1.2;
43
- color: #0a0a0a;
44
- text-align: center;
45
- }
46
-
47
- .sr-otp-modal__copy,
48
- .sr-otp-modal__hint,
49
- .sr-otp-modal__success {
50
- margin: 0.4rem 0 0;
51
- font-size: 0.875rem;
52
- line-height: 1.5;
53
- color: #5c6570;
54
- text-align: center;
55
- }
56
-
57
- .sr-otp-modal__panel [class*="justify-center"] {
58
- display: flex;
59
- justify-content: center;
60
- gap: 0.45rem;
61
- width: 100%;
62
- }
63
-
64
- .sr-otp-modal__cell {
65
- display: flex;
66
- align-items: center;
67
- justify-content: center;
68
- width: 2.35rem;
69
- height: 2.85rem;
70
- border: 1.5px solid #d5dde6;
71
- border-radius: 0.55rem;
72
- background: #f7fafc;
73
- font-size: 1.15rem;
74
- font-weight: 700;
75
- color: #13264d;
76
- }
77
-
78
- .sr-otp-modal__cell.is-active,
79
- .sr-otp-modal__cell.is-filled {
80
- border-color: #13264d;
81
- background: #ffffff;
82
- }
83
-
84
- .sr-otp-modal__error {
85
- margin: 0;
86
- color: #b42318;
87
- text-align: center;
88
- }
89
-
90
- .sr-otp-modal__verify,
91
- .sr-otp-modal__resend {
92
- display: block;
93
- width: 100%;
94
- min-height: 2.75rem;
95
- border-radius: 999px;
96
- font-size: 0.75rem;
97
- font-weight: 700;
98
- letter-spacing: 0.12em;
99
- text-transform: uppercase;
100
- cursor: pointer;
101
- }
102
-
103
- .sr-otp-modal__verify {
104
- border: 1px solid #13264d;
105
- background: #13264d;
106
- color: #ffffff;
107
- }
108
-
109
- .sr-otp-modal__verify:disabled {
110
- opacity: 0.55;
111
- cursor: not-allowed;
112
- }
113
-
114
- .sr-otp-modal__resend {
115
- border: 0;
116
- background: transparent;
117
- color: #13264d;
118
- }
119
-
120
- @media (max-width: 380px) {
121
- .sr-otp-modal__cell {
122
- width: 2.05rem;
123
- height: 2.55rem;
124
- }
125
- }
1
+ .sr-otp-modal {
2
+ position: fixed;
3
+ inset: 0;
4
+ z-index: 90;
5
+ display: flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ padding: 1rem;
9
+ }
10
+
11
+ .sr-otp-modal__backdrop {
12
+ position: absolute;
13
+ inset: 0;
14
+ border: 0;
15
+ background: rgba(10, 16, 28, 0.48);
16
+ cursor: pointer;
17
+ }
18
+
19
+ .sr-otp-modal__panel {
20
+ position: relative;
21
+ z-index: 1;
22
+ width: min(100%, 22rem);
23
+ max-height: min(92vh, 36rem);
24
+ overflow: auto;
25
+ padding: 1.35rem 1.15rem 1.2rem;
26
+ border-radius: 1rem;
27
+ background: #ffffff;
28
+ box-shadow: 0 18px 44px rgba(19, 38, 77, 0.22);
29
+ }
30
+
31
+ .sr-otp-modal__panel > div {
32
+ display: flex;
33
+ flex-direction: column;
34
+ gap: 1.15rem;
35
+ }
36
+
37
+ .sr-otp-modal__title {
38
+ margin: 0;
39
+ font-family: var(--font-heading, Georgia, serif);
40
+ font-size: 1.65rem;
41
+ font-weight: 500;
42
+ line-height: 1.2;
43
+ color: #0a0a0a;
44
+ text-align: center;
45
+ }
46
+
47
+ .sr-otp-modal__copy,
48
+ .sr-otp-modal__hint,
49
+ .sr-otp-modal__success {
50
+ margin: 0.4rem 0 0;
51
+ font-size: 0.875rem;
52
+ line-height: 1.5;
53
+ color: #5c6570;
54
+ text-align: center;
55
+ }
56
+
57
+ .sr-otp-modal__panel [class*="justify-center"] {
58
+ display: flex;
59
+ justify-content: center;
60
+ gap: 0.45rem;
61
+ width: 100%;
62
+ }
63
+
64
+ .sr-otp-modal__cell {
65
+ display: flex;
66
+ align-items: center;
67
+ justify-content: center;
68
+ width: 2.35rem;
69
+ height: 2.85rem;
70
+ border: 1.5px solid #d5dde6;
71
+ border-radius: 0.55rem;
72
+ background: #f7fafc;
73
+ font-size: 1.15rem;
74
+ font-weight: 700;
75
+ color: #13264d;
76
+ }
77
+
78
+ .sr-otp-modal__cell.is-active,
79
+ .sr-otp-modal__cell.is-filled {
80
+ border-color: #13264d;
81
+ background: #ffffff;
82
+ }
83
+
84
+ .sr-otp-modal__error {
85
+ margin: 0;
86
+ color: #b42318;
87
+ text-align: center;
88
+ }
89
+
90
+ .sr-otp-modal__verify,
91
+ .sr-otp-modal__resend {
92
+ display: block;
93
+ width: 100%;
94
+ min-height: 2.75rem;
95
+ border-radius: 999px;
96
+ font-size: 0.75rem;
97
+ font-weight: 700;
98
+ letter-spacing: 0.12em;
99
+ text-transform: uppercase;
100
+ cursor: pointer;
101
+ }
102
+
103
+ .sr-otp-modal__verify {
104
+ border: 1px solid #13264d;
105
+ background: #13264d;
106
+ color: #ffffff;
107
+ }
108
+
109
+ .sr-otp-modal__verify:disabled {
110
+ opacity: 0.55;
111
+ cursor: not-allowed;
112
+ }
113
+
114
+ .sr-otp-modal__resend {
115
+ border: 0;
116
+ background: transparent;
117
+ color: #13264d;
118
+ }
119
+
120
+ @media (max-width: 380px) {
121
+ .sr-otp-modal__cell {
122
+ width: 2.05rem;
123
+ height: 2.55rem;
124
+ }
125
+ }
@@ -1,121 +1,121 @@
1
- "use client"
2
-
3
- import { useEffect, useState } from "react"
4
- import { createPortal } from "react-dom"
5
- import OtpInput from "@pradip1995/commerce-auth/components/otp-input"
6
- import type { OtpVerificationModalProps } from "./otp-verification-modal"
7
- import "./commerce-auth-otp-modal.css"
8
-
9
- /**
10
- * OTP modal styled like commerce-auth/chocomelon, compatible with segment-login-template props.
11
- * Use in pages.config: `"otpComponent": "@pradip1995/segment-login-template/commerce-auth-otp-modal"`
12
- */
13
- export default function CommerceAuthOtpModal({
14
- open,
15
- title,
16
- description,
17
- otp,
18
- onOtpChange,
19
- error,
20
- pending,
21
- success = false,
22
- successTitle = "Verified",
23
- successMessage = "Verification successful!",
24
- verifyLabel = "Verify",
25
- onVerify,
26
- onResend,
27
- onClose,
28
- preventClose = false,
29
- extraContent,
30
- }: OtpVerificationModalProps) {
31
- const [mounted, setMounted] = useState(false)
32
-
33
- useEffect(() => {
34
- setMounted(true)
35
- }, [])
36
-
37
- if (!open || !mounted) return null
38
-
39
- function handleBackdropClick() {
40
- if (preventClose || pending || success) return
41
- onClose?.()
42
- }
43
-
44
- return createPortal(
45
- <div className="sr-otp-modal" role="presentation">
46
- <button
47
- type="button"
48
- className="sr-otp-modal__backdrop absolute inset-0"
49
- aria-label="Close verification dialog"
50
- onClick={handleBackdropClick}
51
- />
52
- <div className="sr-otp-modal__panel relative w-full max-w-md p-6">
53
- <div className="flex flex-col gap-6 py-4 px-2">
54
- <div className="text-center">
55
- <h2 className="sr-otp-modal__title text-2xl font-bold mb-2">
56
- {success ? successTitle : title}
57
- </h2>
58
- {!success && (
59
- <p className="sr-otp-modal__copy text-sm leading-relaxed max-w-[320px] mx-auto">
60
- {description}
61
- </p>
62
- )}
63
- </div>
64
-
65
- {success ? (
66
- <div className="text-center py-6">
67
- <p className="sr-otp-modal__success font-bold">{successMessage}</p>
68
- </div>
69
- ) : (
70
- <>
71
- {extraContent}
72
-
73
- <OtpInput
74
- value={otp}
75
- onChange={onOtpChange}
76
- autoFocus
77
- activeClassName="sr-otp-modal__cell is-active"
78
- filledClassName="sr-otp-modal__cell is-filled"
79
- emptyClassName="sr-otp-modal__cell"
80
- />
81
-
82
- {error && (
83
- <p className="sr-otp-modal__error text-xs text-center" role="alert">
84
- {error}
85
- </p>
86
- )}
87
-
88
- <div className="space-y-3">
89
- <button
90
- type="button"
91
- onClick={onVerify}
92
- disabled={pending || otp.length < 6}
93
- className="sr-otp-modal__verify w-full"
94
- >
95
- {pending ? "Verifying…" : verifyLabel}
96
- </button>
97
-
98
- <button
99
- type="button"
100
- onClick={onResend}
101
- disabled={pending}
102
- className="sr-otp-modal__resend w-full text-center disabled:opacity-60"
103
- >
104
- Resend code
105
- </button>
106
- </div>
107
-
108
- {preventClose && (
109
- <p className="sr-otp-modal__hint text-xs text-center">
110
- Verification is required to complete{" "}
111
- {verifyLabel.toLowerCase().includes("sign in") ? "sign in" : "registration"}.
112
- </p>
113
- )}
114
- </>
115
- )}
116
- </div>
117
- </div>
118
- </div>,
119
- document.body
120
- )
121
- }
1
+ "use client"
2
+
3
+ import { useEffect, useState } from "react"
4
+ import { createPortal } from "react-dom"
5
+ import OtpInput from "@pradip1995/commerce-auth/components/otp-input"
6
+ import type { OtpVerificationModalProps } from "./otp-verification-modal"
7
+ import "./commerce-auth-otp-modal.css"
8
+
9
+ /**
10
+ * OTP modal styled like commerce-auth/chocomelon, compatible with segment-login-template props.
11
+ * Use in pages.config: `"otpComponent": "@pradip1995/segment-login-template/commerce-auth-otp-modal"`
12
+ */
13
+ export default function CommerceAuthOtpModal({
14
+ open,
15
+ title,
16
+ description,
17
+ otp,
18
+ onOtpChange,
19
+ error,
20
+ pending,
21
+ success = false,
22
+ successTitle = "Verified",
23
+ successMessage = "Verification successful!",
24
+ verifyLabel = "Verify",
25
+ onVerify,
26
+ onResend,
27
+ onClose,
28
+ preventClose = false,
29
+ extraContent,
30
+ }: OtpVerificationModalProps) {
31
+ const [mounted, setMounted] = useState(false)
32
+
33
+ useEffect(() => {
34
+ setMounted(true)
35
+ }, [])
36
+
37
+ if (!open || !mounted) return null
38
+
39
+ function handleBackdropClick() {
40
+ if (preventClose || pending || success) return
41
+ onClose?.()
42
+ }
43
+
44
+ return createPortal(
45
+ <div className="sr-otp-modal" role="presentation">
46
+ <button
47
+ type="button"
48
+ className="sr-otp-modal__backdrop absolute inset-0"
49
+ aria-label="Close verification dialog"
50
+ onClick={handleBackdropClick}
51
+ />
52
+ <div className="sr-otp-modal__panel relative w-full max-w-md p-6">
53
+ <div className="flex flex-col gap-6 py-4 px-2">
54
+ <div className="text-center">
55
+ <h2 className="sr-otp-modal__title text-2xl font-bold mb-2">
56
+ {success ? successTitle : title}
57
+ </h2>
58
+ {!success && (
59
+ <p className="sr-otp-modal__copy text-sm leading-relaxed max-w-[320px] mx-auto">
60
+ {description}
61
+ </p>
62
+ )}
63
+ </div>
64
+
65
+ {success ? (
66
+ <div className="text-center py-6">
67
+ <p className="sr-otp-modal__success font-bold">{successMessage}</p>
68
+ </div>
69
+ ) : (
70
+ <>
71
+ {extraContent}
72
+
73
+ <OtpInput
74
+ value={otp}
75
+ onChange={onOtpChange}
76
+ autoFocus
77
+ activeClassName="sr-otp-modal__cell is-active"
78
+ filledClassName="sr-otp-modal__cell is-filled"
79
+ emptyClassName="sr-otp-modal__cell"
80
+ />
81
+
82
+ {error && (
83
+ <p className="sr-otp-modal__error text-xs text-center" role="alert">
84
+ {error}
85
+ </p>
86
+ )}
87
+
88
+ <div className="space-y-3">
89
+ <button
90
+ type="button"
91
+ onClick={onVerify}
92
+ disabled={pending || otp.length < 6}
93
+ className="sr-otp-modal__verify w-full"
94
+ >
95
+ {pending ? "Verifying…" : verifyLabel}
96
+ </button>
97
+
98
+ <button
99
+ type="button"
100
+ onClick={onResend}
101
+ disabled={pending}
102
+ className="sr-otp-modal__resend w-full text-center disabled:opacity-60"
103
+ >
104
+ Resend code
105
+ </button>
106
+ </div>
107
+
108
+ {preventClose && (
109
+ <p className="sr-otp-modal__hint text-xs text-center">
110
+ Verification is required to complete{" "}
111
+ {verifyLabel.toLowerCase().includes("sign in") ? "sign in" : "registration"}.
112
+ </p>
113
+ )}
114
+ </>
115
+ )}
116
+ </div>
117
+ </div>
118
+ </div>,
119
+ document.body
120
+ )
121
+ }