@stackframe/stack 2.3.5 → 2.3.7

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 (261) hide show
  1. package/dist/components/card-frame.d.mts +9 -0
  2. package/dist/components/card-frame.d.ts +8 -5
  3. package/dist/components/card-frame.js +58 -23
  4. package/dist/components/credential-sign-in.d.mts +5 -0
  5. package/dist/components/credential-sign-in.d.ts +5 -1
  6. package/dist/components/credential-sign-in.js +109 -41
  7. package/dist/components/credential-sign-up.d.mts +5 -0
  8. package/dist/components/credential-sign-up.d.ts +5 -1
  9. package/dist/components/credential-sign-up.js +140 -62
  10. package/dist/components/forgot-password.d.mts +7 -0
  11. package/dist/components/forgot-password.d.ts +6 -2
  12. package/dist/components/forgot-password.js +83 -26
  13. package/dist/components/form-warning.d.mts +7 -0
  14. package/dist/components/form-warning.d.ts +6 -2
  15. package/dist/components/form-warning.js +34 -8
  16. package/dist/components/magic-link-sign-in.d.mts +5 -0
  17. package/dist/components/magic-link-sign-in.d.ts +5 -1
  18. package/dist/components/magic-link-sign-in.js +89 -31
  19. package/dist/components/message-card.d.mts +10 -0
  20. package/dist/components/message-card.d.ts +8 -4
  21. package/dist/components/message-card.js +45 -6
  22. package/dist/components/oauth-button.d.mts +8 -0
  23. package/dist/components/oauth-button.d.ts +6 -2
  24. package/dist/components/oauth-button.js +142 -63
  25. package/dist/components/oauth-group.d.mts +7 -0
  26. package/dist/components/oauth-group.d.ts +6 -2
  27. package/dist/components/oauth-group.js +46 -8
  28. package/dist/components/password-field.d.mts +5 -0
  29. package/dist/components/password-field.d.ts +5 -3
  30. package/dist/components/password-field.js +111 -41
  31. package/dist/components/password-reset-inner.d.mts +8 -0
  32. package/dist/components/password-reset-inner.d.ts +6 -2
  33. package/dist/components/password-reset-inner.js +120 -58
  34. package/dist/components/redirect-message-card.d.mts +8 -0
  35. package/dist/components/redirect-message-card.d.ts +6 -2
  36. package/dist/components/redirect-message-card.js +110 -58
  37. package/dist/components/separator-with-text.d.mts +7 -0
  38. package/dist/components/separator-with-text.d.ts +6 -2
  39. package/dist/components/separator-with-text.js +35 -5
  40. package/dist/components/user-avatar.d.mts +13 -0
  41. package/dist/components/user-avatar.d.ts +11 -3
  42. package/dist/components/user-avatar.js +34 -6
  43. package/dist/components/user-button.d.mts +15 -0
  44. package/dist/components/user-button.d.ts +12 -3
  45. package/dist/components/user-button.js +156 -26
  46. package/dist/components-core/avatar.d.mts +8 -0
  47. package/dist/components-core/avatar.d.ts +7 -5
  48. package/dist/components-core/avatar.js +73 -18
  49. package/dist/components-core/button.d.mts +12 -0
  50. package/dist/components-core/button.d.ts +8 -6
  51. package/dist/components-core/button.js +177 -113
  52. package/dist/components-core/card.d.mts +8 -0
  53. package/dist/components-core/card.d.ts +4 -2
  54. package/dist/components-core/card.js +73 -22
  55. package/dist/components-core/collapsible.d.mts +8 -0
  56. package/dist/components-core/collapsible.d.ts +8 -6
  57. package/dist/components-core/collapsible.js +48 -5
  58. package/dist/components-core/container.d.mts +8 -0
  59. package/dist/components-core/container.d.ts +5 -3
  60. package/dist/components-core/container.js +61 -11
  61. package/dist/components-core/dropdown.d.mts +15 -0
  62. package/dist/components-core/dropdown.d.ts +10 -8
  63. package/dist/components-core/dropdown.js +108 -36
  64. package/dist/components-core/index.d.mts +59 -0
  65. package/dist/components-core/index.d.ts +51 -40
  66. package/dist/components-core/index.js +144 -46
  67. package/dist/components-core/input.d.mts +6 -0
  68. package/dist/components-core/input.d.ts +5 -3
  69. package/dist/components-core/input.js +97 -28
  70. package/dist/components-core/label.d.mts +6 -0
  71. package/dist/components-core/label.d.ts +5 -3
  72. package/dist/components-core/label.js +65 -15
  73. package/dist/components-core/link.d.mts +10 -0
  74. package/dist/components-core/link.d.ts +7 -6
  75. package/dist/components-core/link.js +72 -18
  76. package/dist/components-core/loading-indicator.d.mts +13 -0
  77. package/dist/components-core/loading-indicator.d.ts +11 -4
  78. package/dist/components-core/loading-indicator.js +46 -6
  79. package/dist/components-core/popover.d.mts +8 -0
  80. package/dist/components-core/popover.d.ts +8 -6
  81. package/dist/components-core/popover.js +72 -16
  82. package/dist/components-core/separator.d.mts +6 -0
  83. package/dist/components-core/separator.d.ts +5 -3
  84. package/dist/components-core/separator.js +66 -16
  85. package/dist/components-core/skeleton.d.mts +7 -0
  86. package/dist/components-core/skeleton.d.ts +5 -3
  87. package/dist/components-core/skeleton.js +75 -21
  88. package/dist/components-core/tabs.d.mts +9 -0
  89. package/dist/components-core/tabs.d.ts +8 -6
  90. package/dist/components-core/tabs.js +87 -20
  91. package/dist/components-core/text.d.mts +10 -0
  92. package/dist/components-core/text.d.ts +5 -3
  93. package/dist/components-core/text.js +95 -40
  94. package/dist/components-core-joy/button.d.mts +6 -0
  95. package/dist/components-core-joy/button.d.ts +6 -2
  96. package/dist/components-core-joy/button.js +86 -28
  97. package/dist/components-core-joy/input.d.mts +5 -0
  98. package/dist/components-core-joy/input.d.ts +5 -2
  99. package/dist/components-core-joy/input.js +51 -6
  100. package/dist/components-core-joy/separator.d.mts +6 -0
  101. package/dist/components-core-joy/separator.d.ts +6 -2
  102. package/dist/components-core-joy/separator.js +50 -6
  103. package/dist/components-core-joy/tabs.d.mts +9 -0
  104. package/dist/components-core-joy/tabs.d.ts +9 -5
  105. package/dist/components-core-joy/tabs.js +62 -16
  106. package/dist/components-core-joy/text.d.mts +9 -0
  107. package/dist/components-core-joy/text.d.ts +6 -3
  108. package/dist/components-core-joy/text.js +68 -28
  109. package/dist/components-page/account-settings.d.mts +7 -0
  110. package/dist/components-page/account-settings.d.ts +6 -2
  111. package/dist/components-page/account-settings.js +213 -81
  112. package/dist/components-page/auth-page.d.mts +8 -0
  113. package/dist/components-page/auth-page.d.ts +6 -2
  114. package/dist/components-page/auth-page.js +79 -19
  115. package/dist/components-page/email-verification.d.mts +8 -0
  116. package/dist/components-page/email-verification.d.ts +6 -2
  117. package/dist/components-page/email-verification.js +65 -28
  118. package/dist/components-page/forgot-password.d.mts +7 -0
  119. package/dist/components-page/forgot-password.d.ts +6 -2
  120. package/dist/components-page/forgot-password.js +64 -20
  121. package/dist/components-page/magic-link-callback.d.mts +8 -0
  122. package/dist/components-page/magic-link-callback.d.ts +6 -2
  123. package/dist/components-page/magic-link-callback.js +72 -34
  124. package/dist/components-page/oauth-callback.d.mts +5 -0
  125. package/dist/components-page/oauth-callback.d.ts +5 -1
  126. package/dist/components-page/oauth-callback.js +52 -16
  127. package/dist/components-page/password-reset.d.mts +8 -0
  128. package/dist/components-page/password-reset.d.ts +6 -2
  129. package/dist/components-page/password-reset.js +70 -34
  130. package/dist/components-page/sign-in.d.mts +7 -0
  131. package/dist/components-page/sign-in.d.ts +6 -2
  132. package/dist/components-page/sign-in.js +41 -5
  133. package/dist/components-page/sign-out.d.mts +5 -0
  134. package/dist/components-page/sign-out.d.ts +5 -1
  135. package/dist/components-page/sign-out.js +47 -11
  136. package/dist/components-page/sign-up.d.mts +7 -0
  137. package/dist/components-page/sign-up.d.ts +6 -2
  138. package/dist/components-page/sign-up.js +41 -5
  139. package/dist/components-page/stack-handler.d.mts +16 -0
  140. package/dist/components-page/stack-handler.d.ts +11 -3
  141. package/dist/components-page/stack-handler.js +102 -64
  142. package/dist/esm/components/card-frame.js +39 -0
  143. package/dist/esm/components/credential-sign-in.js +82 -0
  144. package/dist/esm/components/credential-sign-up.js +114 -0
  145. package/dist/esm/components/forgot-password.js +55 -0
  146. package/dist/esm/components/form-warning.js +15 -0
  147. package/dist/esm/components/magic-link-sign-in.js +61 -0
  148. package/dist/esm/components/message-card.js +16 -0
  149. package/dist/esm/components/oauth-button.js +124 -0
  150. package/dist/esm/components/oauth-group.js +17 -0
  151. package/dist/esm/components/password-field.js +82 -0
  152. package/dist/esm/components/password-reset-inner.js +93 -0
  153. package/dist/esm/components/redirect-message-card.js +83 -0
  154. package/dist/esm/components/separator-with-text.js +16 -0
  155. package/dist/esm/components/user-avatar.js +14 -0
  156. package/dist/esm/components/user-button.js +133 -0
  157. package/dist/esm/components-core/avatar.js +56 -0
  158. package/dist/esm/components-core/button.js +165 -0
  159. package/dist/esm/components-core/card.js +51 -0
  160. package/dist/esm/components-core/collapsible.js +13 -0
  161. package/dist/esm/components-core/container.js +35 -0
  162. package/dist/esm/components-core/dropdown.js +106 -0
  163. package/dist/esm/components-core/index.js +93 -0
  164. package/dist/esm/components-core/input.js +80 -0
  165. package/dist/esm/components-core/label.js +38 -0
  166. package/dist/esm/components-core/link.js +38 -0
  167. package/dist/esm/components-core/loading-indicator.js +27 -0
  168. package/dist/esm/components-core/popover.js +43 -0
  169. package/dist/esm/components-core/separator.js +36 -0
  170. package/dist/esm/components-core/skeleton.js +52 -0
  171. package/dist/esm/components-core/tabs.js +79 -0
  172. package/dist/esm/components-core/text.js +63 -0
  173. package/dist/esm/components-core-joy/button.js +53 -0
  174. package/dist/esm/components-core-joy/input.js +18 -0
  175. package/dist/esm/components-core-joy/separator.js +17 -0
  176. package/dist/esm/components-core-joy/tabs.js +29 -0
  177. package/dist/esm/components-core-joy/text.js +35 -0
  178. package/dist/esm/components-page/account-settings.js +197 -0
  179. package/dist/esm/components-page/auth-page.js +50 -0
  180. package/dist/esm/components-page/email-verification.js +36 -0
  181. package/dist/esm/components-page/forgot-password.js +35 -0
  182. package/dist/esm/components-page/magic-link-callback.js +43 -0
  183. package/dist/esm/components-page/oauth-callback.js +23 -0
  184. package/dist/esm/components-page/password-reset.js +42 -0
  185. package/dist/esm/components-page/sign-in.js +12 -0
  186. package/dist/esm/components-page/sign-out.js +18 -0
  187. package/dist/esm/components-page/sign-up.js +12 -0
  188. package/dist/esm/components-page/stack-handler.js +75 -0
  189. package/dist/esm/index.js +47 -0
  190. package/dist/esm/joy.js +5 -0
  191. package/dist/esm/lib/auth.js +62 -0
  192. package/dist/esm/lib/cookie.js +185 -0
  193. package/dist/esm/lib/hooks.js +29 -0
  194. package/dist/esm/lib/stack-app.js +940 -0
  195. package/dist/esm/providers/component-provider.js +76 -0
  196. package/dist/esm/providers/design-provider.js +36 -0
  197. package/dist/esm/providers/joy-provider.js +35 -0
  198. package/dist/esm/providers/stack-provider-client.js +31 -0
  199. package/dist/esm/providers/stack-provider.js +21 -0
  200. package/dist/esm/providers/styled-components-registry.js +24 -0
  201. package/dist/esm/providers/theme-provider.js +22 -0
  202. package/dist/esm/utils/browser-script.js +25 -0
  203. package/dist/esm/utils/constants.js +34 -0
  204. package/dist/esm/utils/email.js +10 -0
  205. package/dist/esm/utils/next.js +7 -0
  206. package/dist/esm/utils/url.js +21 -0
  207. package/dist/index.d.mts +37 -0
  208. package/dist/index.d.ts +37 -22
  209. package/dist/index.js +106 -21
  210. package/dist/joy.d.mts +16 -0
  211. package/dist/joy.d.ts +16 -1
  212. package/dist/joy.js +30 -1
  213. package/dist/lib/auth.d.mts +11 -0
  214. package/dist/lib/auth.d.ts +8 -4
  215. package/dist/lib/auth.js +83 -57
  216. package/dist/lib/cookie.d.mts +14 -0
  217. package/dist/lib/cookie.d.ts +8 -6
  218. package/dist/lib/cookie.js +217 -45
  219. package/dist/lib/hooks.d.mts +35 -0
  220. package/dist/lib/hooks.d.ts +14 -8
  221. package/dist/lib/hooks.js +53 -28
  222. package/dist/lib/stack-app.d.mts +227 -0
  223. package/dist/lib/stack-app.d.ts +43 -41
  224. package/dist/lib/stack-app.js +937 -849
  225. package/dist/providers/component-provider.d.mts +113 -0
  226. package/dist/providers/component-provider.d.ts +95 -77
  227. package/dist/providers/component-provider.js +92 -58
  228. package/dist/providers/design-provider.d.mts +34 -0
  229. package/dist/providers/design-provider.d.ts +16 -21
  230. package/dist/providers/design-provider.js +57 -58
  231. package/dist/providers/joy-provider.d.mts +36 -0
  232. package/dist/providers/joy-provider.d.ts +30 -14
  233. package/dist/providers/joy-provider.js +58 -30
  234. package/dist/providers/stack-provider-client.d.mts +20 -0
  235. package/dist/providers/stack-provider-client.d.ts +15 -8
  236. package/dist/providers/stack-provider-client.js +64 -20
  237. package/dist/providers/stack-provider.d.mts +14 -0
  238. package/dist/providers/stack-provider.d.ts +13 -5
  239. package/dist/providers/stack-provider.js +39 -8
  240. package/dist/providers/styled-components-registry.d.mts +8 -0
  241. package/dist/providers/styled-components-registry.d.ts +8 -4
  242. package/dist/providers/styled-components-registry.js +43 -17
  243. package/dist/providers/theme-provider.d.mts +22 -0
  244. package/dist/providers/theme-provider.d.ts +21 -9
  245. package/dist/providers/theme-provider.js +55 -19
  246. package/dist/utils/browser-script.d.mts +5 -0
  247. package/dist/utils/browser-script.d.ts +5 -0
  248. package/dist/utils/browser-script.js +50 -0
  249. package/dist/utils/constants.d.mts +48 -0
  250. package/dist/utils/constants.d.ts +11 -9
  251. package/dist/utils/constants.js +66 -21
  252. package/dist/utils/email.d.mts +3 -0
  253. package/dist/utils/email.d.ts +3 -1
  254. package/dist/utils/email.js +44 -6
  255. package/dist/utils/next.d.mts +3 -0
  256. package/dist/utils/next.d.ts +3 -1
  257. package/dist/utils/next.js +31 -3
  258. package/dist/utils/url.d.mts +4 -0
  259. package/dist/utils/url.d.ts +4 -2
  260. package/dist/utils/url.js +44 -13
  261. package/package.json +19 -10
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-core/separator.tsx
5
+ import React from "react";
6
+ import * as SeparatorPrimitive from "@radix-ui/react-separator";
7
+ import styled from "styled-components";
8
+ import { useDesign } from "..";
9
+ import { jsx } from "react/jsx-runtime";
10
+ var StyledSeparator = styled(SeparatorPrimitive.Root)`
11
+ flex-shrink: 0;
12
+ ${(props) => props.$orientation === "horizontal" ? "height: 1px; width: 100%;" : "height: 100%; width: 1px;"}
13
+
14
+ background-color: ${(props) => props.$color.light.neutralColor};
15
+
16
+ html[data-theme='dark'] & {
17
+ background-color: ${(props) => props.$color.dark.neutralColor};
18
+ }
19
+ `;
20
+ var Separator = React.forwardRef(({ orientation = "horizontal", decorative = true, ...props }, ref) => {
21
+ const { colors } = useDesign();
22
+ return /* @__PURE__ */ jsx(
23
+ StyledSeparator,
24
+ {
25
+ ref,
26
+ decorative,
27
+ $orientation: orientation,
28
+ $color: colors,
29
+ ...props
30
+ }
31
+ );
32
+ });
33
+ Separator.displayName = "Separator";
34
+ export {
35
+ Separator
36
+ };
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-core/skeleton.tsx
5
+ import React from "react";
6
+ import styled, { keyframes } from "styled-components";
7
+ import { jsx } from "react/jsx-runtime";
8
+ var getFilterString = (brightness1, brightness2) => {
9
+ return `
10
+ 0% {
11
+ filter: grayscale(1) contrast(0) brightness(0) invert(1) brightness(${brightness1});
12
+ }
13
+ 100% {
14
+ filter: grayscale(1) contrast(0) brightness(0) invert(1) brightness(${brightness2});
15
+ }
16
+ `;
17
+ };
18
+ var animationLight = keyframes`${getFilterString(0.8, 0.9)}`;
19
+ var animationDark = keyframes`${getFilterString(0.2, 0.1)}`;
20
+ var Primitive = styled("span")`
21
+ &[data-stack-state="activated"], &[data-stack-state="activated"] * {
22
+ pointer-events: none !important;
23
+ -webkit-user-select: none !important;
24
+ -moz-user-select: none !important;
25
+ user-select: none !important;
26
+ cursor: default !important;
27
+ }
28
+
29
+ &[data-stack-state="activated"] {
30
+ animation: ${animationLight} 1s infinite alternate-reverse !important;
31
+ }
32
+
33
+ html[data-theme='dark'] &[data-stack-state="activated"] {
34
+ animation: ${animationDark} 1s infinite alternate-reverse !important;
35
+ }
36
+ `;
37
+ var Skeleton = React.forwardRef(
38
+ (props, ref) => {
39
+ return /* @__PURE__ */ jsx(
40
+ Primitive,
41
+ {
42
+ ref,
43
+ "data-stack-state": props.deactivated ? "deactivated" : "activated",
44
+ ...props
45
+ }
46
+ );
47
+ }
48
+ );
49
+ Skeleton.displayName = "Skeleton";
50
+ export {
51
+ Skeleton
52
+ };
@@ -0,0 +1,79 @@
1
+ // src/components-core/tabs.tsx
2
+ import * as React from "react";
3
+ import * as TabsPrimitive from "@radix-ui/react-tabs";
4
+ import styled from "styled-components";
5
+ import { useDesign } from "..";
6
+ import { jsx } from "react/jsx-runtime";
7
+ var Tabs = TabsPrimitive.Root;
8
+ var StyledTabsList = styled(TabsPrimitive.List)`
9
+ display: flex;
10
+ height: 2.5rem
11
+ align-items: center;
12
+ justify-content: center;
13
+ border-radius: 0.375rem;
14
+ padding: 0.25rem;
15
+
16
+ background-color: rgb(244, 244, 245);
17
+
18
+ html[data-theme='dark'] & {
19
+ background-color: rgb(39, 39, 42);
20
+ }
21
+ `;
22
+ var TabsList = React.forwardRef((props, ref) => {
23
+ return /* @__PURE__ */ jsx(
24
+ StyledTabsList,
25
+ {
26
+ ...props,
27
+ ref
28
+ }
29
+ );
30
+ });
31
+ var StayledTabsTrigger = styled(TabsPrimitive.Trigger)`
32
+ display: flex;
33
+ flex-grow: 1;
34
+ align-items: center;
35
+ justify-content: center;
36
+ white-space: nowrap;
37
+ border-radius: 0.25rem;
38
+ padding: 0.25rem 0.5rem;
39
+ transition: all;
40
+ outline: none;
41
+
42
+ &:disabled {
43
+ pointer-events: none;
44
+ opacity: 0.5;
45
+ }
46
+
47
+ &[data-state='active'] {
48
+ background-color: ${({ $colors }) => $colors.light.backgroundColor};
49
+ }
50
+
51
+ html[data-theme='dark'] & {
52
+ &[data-state='active'] {
53
+ background-color: ${({ $colors }) => $colors.dark.backgroundColor};
54
+ }
55
+ }
56
+ `;
57
+ var TabsTrigger = React.forwardRef((props, ref) => {
58
+ const { colors } = useDesign();
59
+ return /* @__PURE__ */ jsx(
60
+ StayledTabsTrigger,
61
+ {
62
+ $colors: colors,
63
+ ...props,
64
+ ref
65
+ }
66
+ );
67
+ });
68
+ var StyledTabsContent = styled(TabsPrimitive.Content)`
69
+ margin-top: 1.5rem;
70
+ `;
71
+ var TabsContent = React.forwardRef((props, ref) => {
72
+ return /* @__PURE__ */ jsx(StyledTabsContent, { ...props, ref });
73
+ });
74
+ export {
75
+ Tabs,
76
+ TabsContent,
77
+ TabsList,
78
+ TabsTrigger
79
+ };
@@ -0,0 +1,63 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-core/text.tsx
5
+ import React from "react";
6
+ import { createElement } from "react";
7
+ import { FONT_FAMILY, FONT_SIZES, LINE_HEIGHTS, PRIMARY_FONT_COLORS, SECONDARY_FONT_COLORS } from "../utils/constants";
8
+ import styled from "styled-components";
9
+ import { typedFromEntries } from "@stackframe/stack-shared/dist/utils/objects";
10
+ var components = ["p", "h6", "h5", "h4", "h3", "h2", "h1"];
11
+ var StyledComponents = typedFromEntries(components.map((component) => {
12
+ return [
13
+ component,
14
+ styled(component)`
15
+ font-family: ${FONT_FAMILY};
16
+ font-size: ${(props) => FONT_SIZES[props.$size]};
17
+ line-height: ${(props) => LINE_HEIGHTS[props.$size]};
18
+ margin: 0;
19
+ padding: 0;
20
+ color: ${(props) => props.$textColor.light};
21
+
22
+ html[data-theme='dark'] & {
23
+ color: ${(props) => props.$textColor.dark};
24
+ }
25
+ `
26
+ ];
27
+ }));
28
+ var Text = React.forwardRef(({
29
+ variant = "primary",
30
+ size = "md",
31
+ as = "p",
32
+ ...props
33
+ }, ref) => {
34
+ let textColor;
35
+ switch (variant) {
36
+ case "primary": {
37
+ textColor = PRIMARY_FONT_COLORS;
38
+ break;
39
+ }
40
+ case "secondary": {
41
+ textColor = SECONDARY_FONT_COLORS;
42
+ break;
43
+ }
44
+ case "warning": {
45
+ textColor = { light: "#b33b1d", dark: "#ff7b5c" };
46
+ break;
47
+ }
48
+ case "success": {
49
+ textColor = { light: "#3da63d", dark: "#3da63d" };
50
+ break;
51
+ }
52
+ }
53
+ return createElement(StyledComponents[as], {
54
+ $size: size,
55
+ $textColor: textColor,
56
+ ...props,
57
+ ref
58
+ });
59
+ });
60
+ Text.displayName = "Text";
61
+ export {
62
+ Text
63
+ };
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-core-joy/button.tsx
5
+ import React from "react";
6
+ import { Button as JoyButton } from "@mui/joy";
7
+ import Color from "color";
8
+ import { jsx } from "react/jsx-runtime";
9
+ var Button = React.forwardRef(({
10
+ variant = "primary",
11
+ color,
12
+ size = "md",
13
+ loading = false,
14
+ ...props
15
+ }, ref) => {
16
+ const muiVariant = {
17
+ primary: "primary",
18
+ secondary: "neutral",
19
+ warning: "danger"
20
+ }[variant] || "primary";
21
+ const { children, action, ref: _, ...validProps } = props;
22
+ const c = Color(color);
23
+ const changeColor = (value) => {
24
+ return c.hsl(
25
+ c.hue(),
26
+ c.saturationl(),
27
+ c.lightness() + (c.isDark() ? value : -value)
28
+ ).toString();
29
+ };
30
+ return /* @__PURE__ */ jsx(
31
+ JoyButton,
32
+ {
33
+ color: muiVariant,
34
+ sx: color ? {
35
+ backgroundColor: color,
36
+ color: c.isDark() ? "white" : "black",
37
+ "&:hover": {
38
+ backgroundColor: changeColor(10)
39
+ },
40
+ "&:active": {
41
+ backgroundColor: changeColor(20)
42
+ }
43
+ } : {},
44
+ size,
45
+ loading,
46
+ ...validProps,
47
+ children
48
+ }
49
+ );
50
+ });
51
+ export {
52
+ Button
53
+ };
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-core-joy/input.tsx
5
+ import React from "react";
6
+ import { Input as JoyInput } from "@mui/joy";
7
+ import { jsx } from "react/jsx-runtime";
8
+ var Input = React.forwardRef(({
9
+ color,
10
+ size,
11
+ ref: _,
12
+ ...validProps
13
+ }, ref) => {
14
+ return /* @__PURE__ */ jsx(JoyInput, { ...validProps });
15
+ });
16
+ export {
17
+ Input
18
+ };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-core-joy/separator.tsx
5
+ import React from "react";
6
+ import { Divider as JoySeparator } from "@mui/joy";
7
+ import { jsx } from "react/jsx-runtime";
8
+ var Separator = React.forwardRef(({
9
+ orientation,
10
+ ref: _,
11
+ ...validProps
12
+ }, ref) => {
13
+ return /* @__PURE__ */ jsx(JoySeparator, { ...validProps, orientation });
14
+ });
15
+ export {
16
+ Separator
17
+ };
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-core-joy/tabs.tsx
5
+ import React from "react";
6
+ import { Tabs as JoyTabs, TabList as JoyTabsList, Tab as JoyTabsTrigger, TabPanel as JoyTabssContent } from "@mui/joy";
7
+ import { jsx } from "react/jsx-runtime";
8
+ var Tabs = React.forwardRef((props, ref) => {
9
+ const { color, onChange, ref: _, ...validProps } = props;
10
+ return /* @__PURE__ */ jsx(JoyTabs, { ref, sx: { bgcolor: "transparent" }, ...validProps });
11
+ });
12
+ var TabsList = React.forwardRef((props, ref) => {
13
+ const { color, ref: _, ...validProps } = props;
14
+ return /* @__PURE__ */ jsx(JoyTabsList, { ref, ...validProps });
15
+ });
16
+ var TabsTrigger = React.forwardRef((props, ref) => {
17
+ const { style, color, onChange, ref: _, ...validProps } = props;
18
+ return /* @__PURE__ */ jsx(JoyTabsTrigger, { ref, ...validProps, style: { flexGrow: 1, ...style } });
19
+ });
20
+ var TabsContent = React.forwardRef((props, ref) => {
21
+ const { color, ref: _, ...validProps } = props;
22
+ return /* @__PURE__ */ jsx(JoyTabssContent, { ref, ...validProps });
23
+ });
24
+ export {
25
+ Tabs,
26
+ TabsContent,
27
+ TabsList,
28
+ TabsTrigger
29
+ };
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-core-joy/text.tsx
5
+ import React from "react";
6
+ import { Typography as JoyText } from "@mui/joy";
7
+ import { jsx } from "react/jsx-runtime";
8
+ var Text = React.forwardRef((props, ref) => {
9
+ const { color, size, as, variant, ref: _, ...validProps } = props;
10
+ const muiLevel = {
11
+ h1: "h1",
12
+ h2: "h2",
13
+ h3: "h3",
14
+ h4: "h4",
15
+ h5: "h4",
16
+ h6: "h4",
17
+ p: {
18
+ xl: "body-lg",
19
+ lg: "body-lg",
20
+ md: "body-md",
21
+ sm: "body-sm",
22
+ xs: "body-xs"
23
+ }[size || "md"]
24
+ }[as || "p"];
25
+ const muiColor = {
26
+ primary: void 0,
27
+ secondary: "neutral",
28
+ success: "success",
29
+ warning: "danger"
30
+ }[variant || "primary"];
31
+ return /* @__PURE__ */ jsx(JoyText, { level: muiLevel, color: muiColor, ...validProps });
32
+ });
33
+ export {
34
+ Text
35
+ };
@@ -0,0 +1,197 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-page/account-settings.tsx
5
+ import { PasswordField, useUser } from "..";
6
+ import RedirectMessageCard from "../components/redirect-message-card";
7
+ import { Text, Label, Input, Button, Card, CardHeader, CardContent, CardFooter, Container } from "../components-core";
8
+ import UserAvatar from "../components/user-avatar";
9
+ import { useState } from "react";
10
+ import FormWarningText from "../components/form-warning";
11
+ import { getPasswordError } from "@stackframe/stack-shared/dist/helpers/password";
12
+ import { jsx, jsxs } from "react/jsx-runtime";
13
+ function SettingSection(props) {
14
+ return /* @__PURE__ */ jsxs(Card, { children: [
15
+ /* @__PURE__ */ jsxs(CardHeader, { children: [
16
+ /* @__PURE__ */ jsx(Text, { size: "xl", as: "h2", children: props.title }),
17
+ /* @__PURE__ */ jsx(Text, { variant: "secondary", children: props.desc })
18
+ ] }),
19
+ props.children && /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "1.5rem" }, children: props.children }) }),
20
+ props.buttonText && /* @__PURE__ */ jsx(CardFooter, { children: /* @__PURE__ */ jsx("div", { style: { display: "flex", justifyContent: "flex-end", width: "100%" }, children: /* @__PURE__ */ jsx(
21
+ Button,
22
+ {
23
+ disabled: props.buttonDisabled,
24
+ onClick: props.onButtonClick,
25
+ variant: props.buttonVariant,
26
+ children: props.buttonText
27
+ }
28
+ ) }) })
29
+ ] });
30
+ }
31
+ function ProfileSection() {
32
+ const user = useUser();
33
+ const [userInfo, setUserInfo] = useState({ displayName: user?.displayName || "" });
34
+ const [changed, setChanged] = useState(false);
35
+ return /* @__PURE__ */ jsxs(
36
+ SettingSection,
37
+ {
38
+ title: "Profile",
39
+ desc: "Your profile information",
40
+ buttonDisabled: !changed,
41
+ buttonText: "Save",
42
+ onButtonClick: async () => {
43
+ await user?.update(userInfo);
44
+ setChanged(false);
45
+ },
46
+ children: [
47
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "1rem", alignItems: "center" }, children: [
48
+ /* @__PURE__ */ jsx(UserAvatar, { user, size: 60 }),
49
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
50
+ /* @__PURE__ */ jsx(Text, { size: "lg", children: user?.displayName }),
51
+ /* @__PURE__ */ jsx(Text, { variant: "secondary", size: "sm", children: user?.primaryEmail })
52
+ ] })
53
+ ] }),
54
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
55
+ /* @__PURE__ */ jsx(Label, { htmlFor: "display-name", children: "Display Name" }),
56
+ /* @__PURE__ */ jsx(
57
+ Input,
58
+ {
59
+ id: "display-name",
60
+ value: userInfo.displayName,
61
+ onChange: (e) => {
62
+ setUserInfo((i) => ({ ...i, displayName: e.target.value }));
63
+ setChanged(true);
64
+ }
65
+ }
66
+ )
67
+ ] })
68
+ ]
69
+ }
70
+ );
71
+ }
72
+ function EmailVerificationSection() {
73
+ const user = useUser();
74
+ const [emailSent, setEmailSent] = useState(false);
75
+ return /* @__PURE__ */ jsx(
76
+ SettingSection,
77
+ {
78
+ title: "Email Verification",
79
+ desc: "We want to make sure that you own the email address.",
80
+ buttonDisabled: emailSent,
81
+ buttonText: !user?.primaryEmailVerified ? emailSent ? "Email sent!" : "Send Email" : void 0,
82
+ onButtonClick: async () => {
83
+ await user?.sendVerificationEmail();
84
+ setEmailSent(true);
85
+ },
86
+ children: user?.primaryEmailVerified ? /* @__PURE__ */ jsx(Text, { variant: "success", children: "Your email has been verified" }) : /* @__PURE__ */ jsx(Text, { variant: "warning", children: "Your email has not been verified" })
87
+ }
88
+ );
89
+ }
90
+ function PasswordSection() {
91
+ const user = useUser();
92
+ const [oldPassword, setOldPassword] = useState("");
93
+ const [oldPasswordError, setOldPasswordError] = useState("");
94
+ const [newPassword, setNewPassword] = useState("");
95
+ const [newPasswordError, setNewPasswordError] = useState("");
96
+ if (!user?.hasPassword) {
97
+ return null;
98
+ }
99
+ return /* @__PURE__ */ jsxs(
100
+ SettingSection,
101
+ {
102
+ title: "Password",
103
+ desc: "Change your password here.",
104
+ buttonDisabled: !oldPassword || !newPassword,
105
+ buttonText: "Save",
106
+ onButtonClick: async () => {
107
+ if (oldPassword && newPassword) {
108
+ const errorMessage = getPasswordError(newPassword);
109
+ if (errorMessage) {
110
+ setNewPasswordError(errorMessage.message);
111
+ } else {
112
+ const errorCode = await user?.updatePassword({ oldPassword, newPassword });
113
+ if (errorCode) {
114
+ setOldPasswordError("Incorrect password");
115
+ } else {
116
+ setOldPassword("");
117
+ setNewPassword("");
118
+ }
119
+ }
120
+ } else if (oldPassword && !newPassword) {
121
+ setNewPasswordError("Please enter a new password");
122
+ } else if (newPassword && !oldPassword) {
123
+ setOldPasswordError("Please enter your old password");
124
+ }
125
+ },
126
+ children: [
127
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
128
+ /* @__PURE__ */ jsx(Label, { htmlFor: "old-password", children: "Old Password" }),
129
+ /* @__PURE__ */ jsx(
130
+ PasswordField,
131
+ {
132
+ id: "old-password",
133
+ value: oldPassword,
134
+ onChange: (e) => {
135
+ setOldPassword(e.target.value);
136
+ setOldPasswordError("");
137
+ }
138
+ }
139
+ ),
140
+ /* @__PURE__ */ jsx(FormWarningText, { text: oldPasswordError })
141
+ ] }),
142
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
143
+ /* @__PURE__ */ jsx(Label, { htmlFor: "new-password", children: "New Password" }),
144
+ /* @__PURE__ */ jsx(
145
+ PasswordField,
146
+ {
147
+ id: "new-password",
148
+ value: newPassword,
149
+ onChange: (e) => {
150
+ setNewPassword(e.target.value);
151
+ setNewPasswordError("");
152
+ }
153
+ }
154
+ ),
155
+ /* @__PURE__ */ jsx(FormWarningText, { text: newPasswordError })
156
+ ] })
157
+ ]
158
+ }
159
+ );
160
+ }
161
+ function SignOutSection() {
162
+ const user = useUser();
163
+ return /* @__PURE__ */ jsx(
164
+ SettingSection,
165
+ {
166
+ title: "Sign out",
167
+ desc: "Sign out of your account on this device.",
168
+ buttonVariant: "secondary",
169
+ buttonText: "Sign Out",
170
+ onButtonClick: () => user?.signOut()
171
+ }
172
+ );
173
+ }
174
+ function AccountSettings({ fullPage = false }) {
175
+ const user = useUser();
176
+ if (!user) {
177
+ return /* @__PURE__ */ jsx(RedirectMessageCard, { type: "signedOut", fullPage });
178
+ }
179
+ const inner = /* @__PURE__ */ jsxs("div", { style: { padding: fullPage ? "1rem" : 0, display: "flex", flexDirection: "column", gap: "1.5rem" }, children: [
180
+ /* @__PURE__ */ jsxs("div", { children: [
181
+ /* @__PURE__ */ jsx(Text, { size: "xl", as: "h2", style: { marginBottom: "0.5rem", fontWeight: "700" }, children: "Account Settings" }),
182
+ /* @__PURE__ */ jsx(Text, { variant: "secondary", children: "Manage your account" })
183
+ ] }),
184
+ /* @__PURE__ */ jsx(ProfileSection, {}),
185
+ /* @__PURE__ */ jsx(EmailVerificationSection, {}),
186
+ /* @__PURE__ */ jsx(PasswordSection, {}),
187
+ /* @__PURE__ */ jsx(SignOutSection, {})
188
+ ] });
189
+ if (fullPage) {
190
+ return /* @__PURE__ */ jsx(Container, { size: "sm", children: inner });
191
+ } else {
192
+ return inner;
193
+ }
194
+ }
195
+ export {
196
+ AccountSettings as default
197
+ };
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-page/auth-page.tsx
5
+ import CredentialSignIn from "../components/credential-sign-in";
6
+ import SeparatorWithText from "../components/separator-with-text";
7
+ import OAuthGroup from "../components/oauth-group";
8
+ import CardFrame from "../components/card-frame";
9
+ import { useUser, useStackApp, CredentialSignUp } from "..";
10
+ import RedirectMessageCard from "../components/redirect-message-card";
11
+ import { Link, Tabs, TabsContent, TabsList, TabsTrigger, Text } from "../components-core";
12
+ import MagicLinkSignIn from "../components/magic-link-sign-in";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
14
+ function AuthPage({
15
+ fullPage = false,
16
+ type
17
+ }) {
18
+ const stackApp = useStackApp();
19
+ const user = useUser();
20
+ const project = stackApp.useProject();
21
+ if (user) {
22
+ return /* @__PURE__ */ jsx(RedirectMessageCard, { type: "signedIn", fullPage });
23
+ }
24
+ const enableSeparator = (project.credentialEnabled || project.magicLinkEnabled) && project.oauthProviders.filter((p) => p.enabled).length > 0;
25
+ return /* @__PURE__ */ jsxs(CardFrame, { fullPage, children: [
26
+ /* @__PURE__ */ jsxs("div", { style: { textAlign: "center", marginBottom: "1.5rem" }, children: [
27
+ /* @__PURE__ */ jsx(Text, { size: "xl", as: "h2", children: type === "sign-in" ? "Sign in to your account" : "Create a new account" }),
28
+ type === "sign-in" ? /* @__PURE__ */ jsxs(Text, { children: [
29
+ "Don't have an account? ",
30
+ /* @__PURE__ */ jsx(Link, { href: stackApp.urls.signUp, children: "Sign up" })
31
+ ] }) : /* @__PURE__ */ jsxs(Text, { children: [
32
+ "Already have an account? ",
33
+ /* @__PURE__ */ jsx(Link, { href: stackApp.urls.signIn, children: "Sign in" })
34
+ ] })
35
+ ] }),
36
+ /* @__PURE__ */ jsx(OAuthGroup, { type: "signin" }),
37
+ enableSeparator && /* @__PURE__ */ jsx(SeparatorWithText, { text: "Or continue with" }),
38
+ project.credentialEnabled && project.magicLinkEnabled ? /* @__PURE__ */ jsxs(Tabs, { defaultValue: "magic-link", children: [
39
+ /* @__PURE__ */ jsxs(TabsList, { children: [
40
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "magic-link", children: "Magic Link" }),
41
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "password", children: "Password" })
42
+ ] }),
43
+ /* @__PURE__ */ jsx(TabsContent, { value: "magic-link", children: /* @__PURE__ */ jsx(MagicLinkSignIn, {}) }),
44
+ /* @__PURE__ */ jsx(TabsContent, { value: "password", children: type === "sign-up" ? /* @__PURE__ */ jsx(CredentialSignUp, {}) : /* @__PURE__ */ jsx(CredentialSignIn, {}) })
45
+ ] }) : project.credentialEnabled ? type === "sign-up" ? /* @__PURE__ */ jsx(CredentialSignUp, {}) : /* @__PURE__ */ jsx(CredentialSignIn, {}) : project.magicLinkEnabled ? /* @__PURE__ */ jsx(MagicLinkSignIn, {}) : null
46
+ ] });
47
+ }
48
+ export {
49
+ AuthPage as default
50
+ };
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/components-page/email-verification.tsx
5
+ import { use } from "react";
6
+ import { useStackApp } from "..";
7
+ import MessageCard from "../components/message-card";
8
+ import RedirectMessageCard from "../components/redirect-message-card";
9
+ import { KnownErrors } from "@stackframe/stack-shared";
10
+ import { jsx } from "react/jsx-runtime";
11
+ function EmailVerification({
12
+ searchParams: {
13
+ code = ""
14
+ } = {},
15
+ fullPage = false
16
+ }) {
17
+ const stackApp = useStackApp();
18
+ const invalidJsx = /* @__PURE__ */ jsx(MessageCard, { title: "Invalid Verification Link", fullPage, children: /* @__PURE__ */ jsx("p", { children: "Please check if you have the correct link. If you continue to have issues, please contact support." }) });
19
+ const expiredJsx = /* @__PURE__ */ jsx(MessageCard, { title: "Expired Verification Link", fullPage, children: /* @__PURE__ */ jsx("p", { children: "Your email verification link has expired. Please request a new verification link from your account settings." }) });
20
+ if (!code) {
21
+ return invalidJsx;
22
+ }
23
+ const error = use(stackApp.verifyEmail(code));
24
+ if (error instanceof KnownErrors.EmailVerificationCodeNotFound) {
25
+ return invalidJsx;
26
+ } else if (error instanceof KnownErrors.EmailVerificationCodeExpired) {
27
+ return expiredJsx;
28
+ } else if (error instanceof KnownErrors.EmailVerificationCodeAlreadyUsed) {
29
+ } else if (error) {
30
+ throw error;
31
+ }
32
+ return /* @__PURE__ */ jsx(RedirectMessageCard, { type: "emailVerified", fullPage });
33
+ }
34
+ export {
35
+ EmailVerification as default
36
+ };