@stackframe/stack 2.5.18 → 2.5.19

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 (58) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/components/credential-sign-in.js +1 -3
  3. package/dist/components/credential-sign-in.js.map +1 -1
  4. package/dist/components/elements/sidebar-layout.d.mts +21 -0
  5. package/dist/components/elements/sidebar-layout.d.ts +21 -0
  6. package/dist/components/elements/sidebar-layout.js +125 -0
  7. package/dist/components/elements/sidebar-layout.js.map +1 -0
  8. package/dist/components/elements/user-avatar.d.mts +5 -12
  9. package/dist/components/elements/user-avatar.d.ts +5 -12
  10. package/dist/components/elements/user-avatar.js.map +1 -1
  11. package/dist/components/selected-team-switcher.js +35 -5
  12. package/dist/components/selected-team-switcher.js.map +1 -1
  13. package/dist/components-page/account-settings.js +47 -49
  14. package/dist/components-page/account-settings.js.map +1 -1
  15. package/dist/components-page/stack-handler.js +20 -0
  16. package/dist/components-page/stack-handler.js.map +1 -1
  17. package/dist/components-page/team-creation.d.mts +7 -0
  18. package/dist/components-page/team-creation.d.ts +7 -0
  19. package/dist/components-page/team-creation.js +92 -0
  20. package/dist/components-page/team-creation.js.map +1 -0
  21. package/dist/components-page/team-settings.d.mts +8 -0
  22. package/dist/components-page/team-settings.d.ts +8 -0
  23. package/dist/components-page/team-settings.js +139 -0
  24. package/dist/components-page/team-settings.js.map +1 -0
  25. package/dist/esm/components/credential-sign-in.js +1 -3
  26. package/dist/esm/components/credential-sign-in.js.map +1 -1
  27. package/dist/esm/components/elements/sidebar-layout.js +90 -0
  28. package/dist/esm/components/elements/sidebar-layout.js.map +1 -0
  29. package/dist/esm/components/elements/user-avatar.js.map +1 -1
  30. package/dist/esm/components/selected-team-switcher.js +39 -7
  31. package/dist/esm/components/selected-team-switcher.js.map +1 -1
  32. package/dist/esm/components-page/account-settings.js +33 -35
  33. package/dist/esm/components-page/account-settings.js.map +1 -1
  34. package/dist/esm/components-page/stack-handler.js +20 -0
  35. package/dist/esm/components-page/stack-handler.js.map +1 -1
  36. package/dist/esm/components-page/team-creation.js +68 -0
  37. package/dist/esm/components-page/team-creation.js.map +1 -0
  38. package/dist/esm/components-page/team-settings.js +115 -0
  39. package/dist/esm/components-page/team-settings.js.map +1 -0
  40. package/dist/esm/generated/global-css.js +1 -1
  41. package/dist/esm/generated/global-css.js.map +1 -1
  42. package/dist/esm/lib/auth.js +4 -0
  43. package/dist/esm/lib/auth.js.map +1 -1
  44. package/dist/esm/lib/stack-app.js +178 -34
  45. package/dist/esm/lib/stack-app.js.map +1 -1
  46. package/dist/generated/global-css.d.mts +1 -1
  47. package/dist/generated/global-css.d.ts +1 -1
  48. package/dist/generated/global-css.js +1 -1
  49. package/dist/generated/global-css.js.map +1 -1
  50. package/dist/index.d.mts +1 -1
  51. package/dist/index.d.ts +1 -1
  52. package/dist/lib/auth.js +4 -0
  53. package/dist/lib/auth.js.map +1 -1
  54. package/dist/lib/stack-app.d.mts +35 -5
  55. package/dist/lib/stack-app.d.ts +35 -5
  56. package/dist/lib/stack-app.js +178 -34
  57. package/dist/lib/stack-app.js.map +1 -1
  58. package/package.json +7 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @stackframe/stack
2
2
 
3
+ ## 2.5.19
4
+
5
+ ### Patch Changes
6
+
7
+ - Team frontend components
8
+ - Updated dependencies
9
+ - @stackframe/stack-sc@2.5.19
10
+ - @stackframe/stack-shared@2.5.19
11
+ - @stackframe/stack-ui@2.5.19
12
+
3
13
  ## 2.5.18
4
14
 
5
15
  ### Patch Changes
@@ -50,9 +50,7 @@ function CredentialSignIn() {
50
50
  const { email, password } = data;
51
51
  const error = await app.signInWithCredential({
52
52
  email,
53
- password,
54
- // TODO next-release remove
55
- ...{ __experimental_mfa: true }
53
+ password
56
54
  });
57
55
  setError("email", { type: "manual", message: error?.message });
58
56
  } finally {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/credential-sign-in.tsx"],"sourcesContent":["'use client';\n\nimport { useForm } from \"react-hook-form\";\nimport { yupResolver } from \"@hookform/resolvers/yup\";\nimport * as yup from \"yup\";\nimport { FormWarningText } from \"./elements/form-warning\";\nimport { useStackApp } from \"..\";\nimport { runAsynchronouslyWithAlert } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Button, Input, Label, PasswordInput, StyledLink } from \"@stackframe/stack-ui\";\nimport { useState } from \"react\";\nimport { yupObject, yupString, yupNumber, yupBoolean, yupArray, yupMixed } from \"@stackframe/stack-shared/dist/schema-fields\";\nimport { KnownErrors } from \"@stackframe/stack-shared\";\n\nconst schema = yupObject({\n email: yupString().email('Please enter a valid email').required('Please enter your email'),\n password: yupString().required('Please enter your password')\n});\n\nexport function CredentialSignIn() {\n const { register, handleSubmit, setError, formState: { errors } } = useForm({\n resolver: yupResolver(schema)\n });\n const app = useStackApp();\n const [loading, setLoading] = useState(false);\n\n const onSubmit = async (data: yup.InferType<typeof schema>) => {\n setLoading(true);\n\n try {\n const { email, password } = data;\n const error = await app.signInWithCredential({\n email,\n password,\n\n // TODO next-release remove\n ...{ __experimental_mfa: true },\n });\n setError('email', { type: 'manual', message: error?.message });\n } finally {\n setLoading(false);\n }\n };\n\n return (\n <form\n className=\"flex flex-col items-stretch stack-scope\"\n onSubmit={e => runAsynchronouslyWithAlert(handleSubmit(onSubmit)(e))}\n noValidate\n >\n <Label htmlFor=\"email\" className=\"mb-1\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n {...register('email')}\n />\n <FormWarningText text={errors.email?.message?.toString()} />\n\n <Label htmlFor=\"password\" className=\"mt-4 mb-1\">Password</Label>\n <PasswordInput\n id=\"password\"\n {...register('password')}\n />\n <FormWarningText text={errors.password?.message?.toString()} />\n\n <StyledLink href={app.urls.forgotPassword} className=\"mt-1 text-sm\">\n Forgot password?\n </StyledLink>\n\n <Button type=\"submit\" className=\"mt-6\" loading={loading}>\n Sign In\n </Button>\n </form>\n );\n}\n"],"mappings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B,MAAM,OAAO,OAAO,SAAS,SAAS,GAAG;AAAA,QAE1D,4CAAC,yBAAM,SAAQ,YAAW,WAAU,aAAY,sBAAQ;AAAA,QACxD;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACF,GAAG,SAAS,UAAU;AAAA;AAAA,QACzB;AAAA,QACA,4CAAC,uCAAgB,MAAM,OAAO,UAAU,SAAS,SAAS,GAAG;AAAA,QAE7D,4CAAC,8BAAW,MAAM,IAAI,KAAK,gBAAgB,WAAU,gBAAe,8BAEpE;AAAA,QAEA,4CAAC,0BAAO,MAAK,UAAS,WAAU,QAAO,SAAkB,qBAEzD;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/credential-sign-in.tsx"],"sourcesContent":["'use client';\n\nimport { useForm } from \"react-hook-form\";\nimport { yupResolver } from \"@hookform/resolvers/yup\";\nimport * as yup from \"yup\";\nimport { FormWarningText } from \"./elements/form-warning\";\nimport { useStackApp } from \"..\";\nimport { runAsynchronouslyWithAlert } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Button, Input, Label, PasswordInput, StyledLink } from \"@stackframe/stack-ui\";\nimport { useState } from \"react\";\nimport { yupObject, yupString, yupNumber, yupBoolean, yupArray, yupMixed } from \"@stackframe/stack-shared/dist/schema-fields\";\nimport { KnownErrors } from \"@stackframe/stack-shared\";\n\nconst schema = yupObject({\n email: yupString().email('Please enter a valid email').required('Please enter your email'),\n password: yupString().required('Please enter your password')\n});\n\nexport function CredentialSignIn() {\n const { register, handleSubmit, setError, formState: { errors } } = useForm({\n resolver: yupResolver(schema)\n });\n const app = useStackApp();\n const [loading, setLoading] = useState(false);\n\n const onSubmit = async (data: yup.InferType<typeof schema>) => {\n setLoading(true);\n\n try {\n const { email, password } = data;\n const error = await app.signInWithCredential({\n email,\n password,\n });\n setError('email', { type: 'manual', message: error?.message });\n } finally {\n setLoading(false);\n }\n };\n\n return (\n <form\n className=\"flex flex-col items-stretch stack-scope\"\n onSubmit={e => runAsynchronouslyWithAlert(handleSubmit(onSubmit)(e))}\n noValidate\n >\n <Label htmlFor=\"email\" className=\"mb-1\">Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n {...register('email')}\n />\n <FormWarningText text={errors.email?.message?.toString()} />\n\n <Label htmlFor=\"password\" className=\"mt-4 mb-1\">Password</Label>\n <PasswordInput\n id=\"password\"\n {...register('password')}\n />\n <FormWarningText text={errors.password?.message?.toString()} />\n\n <StyledLink href={app.urls.forgotPassword} className=\"mt-1 text-sm\">\n Forgot password?\n </StyledLink>\n\n <Button type=\"submit\" className=\"mt-6\" loading={loading}>\n Sign In\n </Button>\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,6BAAwB;AACxB,iBAA4B;AAE5B,0BAAgC;AAChC,eAA4B;AAC5B,sBAA2C;AAC3C,sBAAgE;AAChE,mBAAyB;AACzB,2BAAgF;AA+B5E;AA5BJ,IAAM,aAAS,gCAAU;AAAA,EACvB,WAAO,gCAAU,EAAE,MAAM,4BAA4B,EAAE,SAAS,yBAAyB;AAAA,EACzF,cAAU,gCAAU,EAAE,SAAS,4BAA4B;AAC7D,CAAC;AAEM,SAAS,mBAAmB;AACjC,QAAM,EAAE,UAAU,cAAc,UAAU,WAAW,EAAE,OAAO,EAAE,QAAI,gCAAQ;AAAA,IAC1E,cAAU,wBAAY,MAAM;AAAA,EAC9B,CAAC;AACD,QAAM,UAAM,sBAAY;AACxB,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,KAAK;AAE5C,QAAM,WAAW,OAAO,SAAuC;AAC7D,eAAW,IAAI;AAEf,QAAI;AACF,YAAM,EAAE,OAAO,SAAS,IAAI;AAC5B,YAAM,QAAQ,MAAM,IAAI,qBAAqB;AAAA,QAC3C;AAAA,QACA;AAAA,MACF,CAAC;AACD,eAAS,SAAS,EAAE,MAAM,UAAU,SAAS,OAAO,QAAQ,CAAC;AAAA,IAC/D,UAAE;AACA,iBAAW,KAAK;AAAA,IAClB;AAAA,EACF;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,UAAU,WAAK,4CAA2B,aAAa,QAAQ,EAAE,CAAC,CAAC;AAAA,MACnE,YAAU;AAAA,MAEV;AAAA,oDAAC,yBAAM,SAAQ,SAAQ,WAAU,QAAO,mBAAK;AAAA,QAC7C;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACH,MAAK;AAAA,YACJ,GAAG,SAAS,OAAO;AAAA;AAAA,QACtB;AAAA,QACA,4CAAC,uCAAgB,MAAM,OAAO,OAAO,SAAS,SAAS,GAAG;AAAA,QAE1D,4CAAC,yBAAM,SAAQ,YAAW,WAAU,aAAY,sBAAQ;AAAA,QACxD;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YACF,GAAG,SAAS,UAAU;AAAA;AAAA,QACzB;AAAA,QACA,4CAAC,uCAAgB,MAAM,OAAO,UAAU,SAAS,SAAS,GAAG;AAAA,QAE7D,4CAAC,8BAAW,MAAM,IAAI,KAAK,gBAAgB,WAAU,gBAAe,8BAEpE;AAAA,QAEA,4CAAC,0BAAO,MAAK,UAAS,WAAU,QAAO,SAAkB,qBAEzD;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
@@ -0,0 +1,21 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { LucideIcon } from 'lucide-react';
3
+ import React, { ReactNode } from 'react';
4
+
5
+ type Item = {
6
+ title: React.ReactNode;
7
+ description?: React.ReactNode;
8
+ icon?: LucideIcon;
9
+ content: React.ReactNode;
10
+ };
11
+ declare function SidebarNavItem(props: {
12
+ item: Item;
13
+ selected: boolean;
14
+ onClick: () => void;
15
+ }): react_jsx_runtime.JSX.Element;
16
+ declare function SidebarLayout(props: {
17
+ items: Item[];
18
+ title?: ReactNode;
19
+ }): react_jsx_runtime.JSX.Element;
20
+
21
+ export { SidebarLayout, SidebarNavItem };
@@ -0,0 +1,21 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { LucideIcon } from 'lucide-react';
3
+ import React, { ReactNode } from 'react';
4
+
5
+ type Item = {
6
+ title: React.ReactNode;
7
+ description?: React.ReactNode;
8
+ icon?: LucideIcon;
9
+ content: React.ReactNode;
10
+ };
11
+ declare function SidebarNavItem(props: {
12
+ item: Item;
13
+ selected: boolean;
14
+ onClick: () => void;
15
+ }): react_jsx_runtime.JSX.Element;
16
+ declare function SidebarLayout(props: {
17
+ items: Item[];
18
+ title?: ReactNode;
19
+ }): react_jsx_runtime.JSX.Element;
20
+
21
+ export { SidebarLayout, SidebarNavItem };
@@ -0,0 +1,125 @@
1
+ "use client";
2
+ "use strict";
3
+ "use client";
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // src/components/elements/sidebar-layout.tsx
33
+ var sidebar_layout_exports = {};
34
+ __export(sidebar_layout_exports, {
35
+ SidebarLayout: () => SidebarLayout,
36
+ SidebarNavItem: () => SidebarNavItem
37
+ });
38
+ module.exports = __toCommonJS(sidebar_layout_exports);
39
+ var import_stack_ui = require("@stackframe/stack-ui");
40
+ var import_lucide_react = require("lucide-react");
41
+ var import_react = __toESM(require("react"));
42
+ var import_jsx_runtime = require("react/jsx-runtime");
43
+ function SidebarNavItem(props) {
44
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
45
+ import_stack_ui.Button,
46
+ {
47
+ variant: "ghost",
48
+ size: "sm",
49
+ className: (0, import_stack_ui.cn)(
50
+ props.selected && "bg-muted",
51
+ "justify-start text-md text-zinc-800 dark:text-zinc-300 px-2"
52
+ ),
53
+ onClick: props.onClick,
54
+ children: [
55
+ props.item.icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(props.item.icon, { className: "mr-2 h-4 w-4" }),
56
+ props.item.title
57
+ ]
58
+ }
59
+ );
60
+ }
61
+ function SidebarLayout(props) {
62
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
63
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hidden sm:flex", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DesktopLayout, { items: props.items, title: props.title }) }),
64
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "sm:hidden", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileLayout, { items: props.items, title: props.title }) })
65
+ ] });
66
+ }
67
+ function DesktopLayout(props) {
68
+ const [selectedIndex, setSelectedIndex] = import_react.default.useState(0);
69
+ const currentItem = props.items[selectedIndex];
70
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "stack-scope flex p-2 w-full", children: [
71
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex w-[200px] border-r flex-col items-stretch gap-2 p-2", children: [
72
+ props.title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mb-2 ml-2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { type: "h2", className: "text-lg font-semibold text-zinc-800 dark:text-zinc-300", children: props.title }) }),
73
+ props.items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
74
+ SidebarNavItem,
75
+ {
76
+ item,
77
+ onClick: () => setSelectedIndex(index),
78
+ selected: index === selectedIndex
79
+ },
80
+ index
81
+ ))
82
+ ] }),
83
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex-1 flex flex-col gap-4 py-2 px-4", children: [
84
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mb-4", children: [
85
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { type: "h4", children: currentItem.title }),
86
+ currentItem.description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", type: "label", children: currentItem.description })
87
+ ] }),
88
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex-1", children: currentItem.content })
89
+ ] })
90
+ ] });
91
+ }
92
+ function MobileLayout(props) {
93
+ const [selectedIndex, setSelectedIndex] = import_react.default.useState(null);
94
+ if (selectedIndex === null) {
95
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-2 p-2", children: [
96
+ props.title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mb-2 ml-2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { type: "h2", className: "text-lg font-semibold text-zinc-800 dark:text-zinc-300", children: props.title }) }),
97
+ props.items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
98
+ SidebarNavItem,
99
+ {
100
+ item,
101
+ onClick: () => setSelectedIndex(index),
102
+ selected: false
103
+ },
104
+ index
105
+ ))
106
+ ] });
107
+ } else {
108
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex-1 flex flex-col gap-4 py-2 px-4", children: [
109
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col", children: [
110
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex justify-between", children: [
111
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { type: "h4", children: props.items[selectedIndex].title }),
112
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Button, { variant: "ghost", size: "icon", onClick: () => setSelectedIndex(null), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.XIcon, { className: "h-5 w-5" }) })
113
+ ] }),
114
+ props.items[selectedIndex].description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", type: "label", children: props.items[selectedIndex].description })
115
+ ] }),
116
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex-1", children: props.items[selectedIndex].content })
117
+ ] });
118
+ }
119
+ }
120
+ // Annotate the CommonJS export names for ESM import in node:
121
+ 0 && (module.exports = {
122
+ SidebarLayout,
123
+ SidebarNavItem
124
+ });
125
+ //# sourceMappingURL=sidebar-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/elements/sidebar-layout.tsx"],"sourcesContent":["'use client';\n\nimport { Button, Typography, cn } from '@stackframe/stack-ui';\nimport { ArrowLeft, LucideIcon, XIcon } from 'lucide-react';\nimport React, { ReactNode } from 'react';\n\ntype Item = {\n title: React.ReactNode,\n description?: React.ReactNode,\n icon?: LucideIcon,\n content: React.ReactNode,\n}\n\nexport function SidebarNavItem(props: { item: Item, selected: boolean, onClick: () => void }) {\n return (\n <Button\n variant='ghost'\n size='sm'\n className={cn(\n props.selected && \"bg-muted\",\n \"justify-start text-md text-zinc-800 dark:text-zinc-300 px-2\",\n )}\n onClick={props.onClick}\n >\n {props.item.icon && <props.item.icon className=\"mr-2 h-4 w-4\" />}\n {props.item.title}\n </Button>\n );\n}\n\nexport function SidebarLayout(props: { items: Item[], title?: ReactNode }) {\n return (\n <>\n <div className=\"hidden sm:flex\">\n <DesktopLayout items={props.items} title={props.title} />\n </div>\n <div className=\"sm:hidden\">\n <MobileLayout items={props.items} title={props.title} />\n </div>\n </>\n );\n}\n\nfunction DesktopLayout(props: { items: Item[], title?: ReactNode }) {\n const [selectedIndex, setSelectedIndex] = React.useState(0);\n const currentItem = props.items[selectedIndex];\n\n return (\n <div className=\"stack-scope flex p-2 w-full\">\n <div className=\"flex w-[200px] border-r flex-col items-stretch gap-2 p-2\">\n {props.title && <div className='mb-2 ml-2'>\n <Typography type='h2' className=\"text-lg font-semibold text-zinc-800 dark:text-zinc-300\">{props.title}</Typography>\n </div>}\n\n {props.items.map((item, index) => (\n <SidebarNavItem\n key={index}\n item={item}\n onClick={() => setSelectedIndex(index)}\n selected={index === selectedIndex}\n />\n ))}\n </div>\n <div className=\"flex-1 flex flex-col gap-4 py-2 px-4\">\n <div className='mb-4'>\n <Typography type='h4'>{currentItem.title}</Typography>\n {currentItem.description && <Typography variant='secondary' type='label'>{currentItem.description}</Typography>}\n </div>\n <div className='flex-1'>\n {currentItem.content}\n </div>\n </div>\n </div>\n );\n}\n\nfunction MobileLayout(props: { items: Item[], title?: ReactNode }) {\n const [selectedIndex, setSelectedIndex] = React.useState<number | null>(null);\n\n if (selectedIndex === null) {\n return (\n <div className=\"flex flex-col gap-2 p-2\">\n {props.title && <div className='mb-2 ml-2'>\n <Typography type='h2' className=\"text-lg font-semibold text-zinc-800 dark:text-zinc-300\">{props.title}</Typography>\n </div>}\n\n {props.items.map((item, index) => (\n <SidebarNavItem\n key={index}\n item={item}\n onClick={() => setSelectedIndex(index)}\n selected={false}\n />\n ))}\n </div>\n );\n } else {\n return (\n <div className=\"flex-1 flex flex-col gap-4 py-2 px-4\">\n <div className='flex flex-col'>\n <div className='flex justify-between'>\n <Typography type='h4'>{props.items[selectedIndex].title}</Typography>\n <Button variant='ghost' size='icon' onClick={() => setSelectedIndex(null)}>\n <XIcon className='h-5 w-5' />\n </Button>\n </div>\n {props.items[selectedIndex].description && <Typography variant='secondary' type='label'>{props.items[selectedIndex].description}</Typography>}\n </div>\n <div className='flex-1'>\n {props.items[selectedIndex].content}\n </div>\n </div>\n );\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAAuC;AACvC,0BAA6C;AAC7C,mBAAiC;AAW7B;AAFG,SAAS,eAAe,OAA+D;AAC5F,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,eAAW;AAAA,QACT,MAAM,YAAY;AAAA,QAClB;AAAA,MACF;AAAA,MACA,SAAS,MAAM;AAAA,MAEd;AAAA,cAAM,KAAK,QAAQ,4CAAC,MAAM,KAAK,MAAX,EAAgB,WAAU,gBAAe;AAAA,QAC7D,MAAM,KAAK;AAAA;AAAA;AAAA,EACd;AAEJ;AAEO,SAAS,cAAc,OAA6C;AACzE,SACE,4EACE;AAAA,gDAAC,SAAI,WAAU,kBACb,sDAAC,iBAAc,OAAO,MAAM,OAAO,OAAO,MAAM,OAAO,GACzD;AAAA,IACA,4CAAC,SAAI,WAAU,aACb,sDAAC,gBAAa,OAAO,MAAM,OAAO,OAAO,MAAM,OAAO,GACxD;AAAA,KACF;AAEJ;AAEA,SAAS,cAAc,OAA6C;AAClE,QAAM,CAAC,eAAe,gBAAgB,IAAI,aAAAA,QAAM,SAAS,CAAC;AAC1D,QAAM,cAAc,MAAM,MAAM,aAAa;AAE7C,SACE,6CAAC,SAAI,WAAU,+BACb;AAAA,iDAAC,SAAI,WAAU,4DACZ;AAAA,YAAM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AAS,MAAM,iBAAiB,IAAI,GACtE,sDAAC,6BAAM,WAAU,WAAU,GAC7B;AAAA,WACF;AAAA,QACC,MAAM,MAAM,aAAa,EAAE,eAAe,4CAAC,8BAAW,SAAQ,aAAY,MAAK,SAAS,gBAAM,MAAM,aAAa,EAAE,aAAY;AAAA,SAClI;AAAA,MACA,4CAAC,SAAI,WAAU,UACZ,gBAAM,MAAM,aAAa,EAAE,SAC9B;AAAA,OACF;AAAA,EAEJ;AACF;","names":["React"]}
@@ -1,19 +1,12 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { User } from '../../lib/stack-app.mjs';
3
- import '@stackframe/stack-shared';
4
- import '@stackframe/stack-shared/dist/helpers/production-mode';
5
- import '@stackframe/stack-shared/dist/interface/crud/api-keys';
6
- import '@stackframe/stack-shared/dist/interface/crud/current-user';
7
- import '@stackframe/stack-shared/dist/interface/crud/email-templates';
8
- import '@stackframe/stack-shared/dist/interface/crud/team-permissions';
9
- import '@stackframe/stack-shared/dist/sessions';
10
- import '@stackframe/stack-shared/dist/utils/json';
11
- import '@stackframe/stack-shared/dist/utils/oauth';
12
- import '@stackframe/stack-shared/dist/utils/results';
13
2
 
14
3
  declare function UserAvatar(props: {
15
4
  size?: number;
16
- user: User | null;
5
+ user?: {
6
+ profileImageUrl?: string | null;
7
+ displayName?: string | null;
8
+ primaryEmail?: string | null;
9
+ } | null;
17
10
  }): react_jsx_runtime.JSX.Element;
18
11
 
19
12
  export { UserAvatar };
@@ -1,19 +1,12 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { User } from '../../lib/stack-app.js';
3
- import '@stackframe/stack-shared';
4
- import '@stackframe/stack-shared/dist/helpers/production-mode';
5
- import '@stackframe/stack-shared/dist/interface/crud/api-keys';
6
- import '@stackframe/stack-shared/dist/interface/crud/current-user';
7
- import '@stackframe/stack-shared/dist/interface/crud/email-templates';
8
- import '@stackframe/stack-shared/dist/interface/crud/team-permissions';
9
- import '@stackframe/stack-shared/dist/sessions';
10
- import '@stackframe/stack-shared/dist/utils/json';
11
- import '@stackframe/stack-shared/dist/utils/oauth';
12
- import '@stackframe/stack-shared/dist/utils/results';
13
2
 
14
3
  declare function UserAvatar(props: {
15
4
  size?: number;
16
- user: User | null;
5
+ user?: {
6
+ profileImageUrl?: string | null;
7
+ displayName?: string | null;
8
+ primaryEmail?: string | null;
9
+ } | null;
17
10
  }): react_jsx_runtime.JSX.Element;
18
11
 
19
12
  export { UserAvatar };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/elements/user-avatar.tsx"],"sourcesContent":["import { UserRound } from \"lucide-react\";\nimport { User } from \"../../lib/stack-app\";\nimport { Avatar, AvatarFallback, AvatarImage } from \"@stackframe/stack-ui\";\n\nexport function UserAvatar(props: { size?: number, user: User | null }) {\n const user = props.user;\n return (\n <Avatar style={{ height: props.size || '34px', width: props.size || '34px' }}>\n <AvatarImage src={user?.profileImageUrl || ''} />\n <AvatarFallback>\n {user ?\n <div className='font-medium'>\n {(user.displayName || user.primaryEmail)?.slice(0, 2).toUpperCase()}\n </div> :\n <UserRound className=\"h-5 w-5 text-zinc-500\" />}\n </AvatarFallback>\n </Avatar>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA0B;AAE1B,sBAAoD;AAKhD;AAHG,SAAS,WAAW,OAA6C;AACtE,QAAM,OAAO,MAAM;AACnB,SACE,6CAAC,0BAAO,OAAO,EAAE,QAAQ,MAAM,QAAQ,QAAQ,OAAO,MAAM,QAAQ,OAAO,GACzE;AAAA,gDAAC,+BAAY,KAAK,MAAM,mBAAmB,IAAI;AAAA,IAC/C,4CAAC,kCACE,iBACC,4CAAC,SAAI,WAAU,eACX,gBAAK,eAAe,KAAK,eAAe,MAAM,GAAG,CAAC,EAAE,YAAY,GACpE,IACA,4CAAC,iCAAU,WAAU,yBAAwB,GACjD;AAAA,KACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/elements/user-avatar.tsx"],"sourcesContent":["import { UserRound } from \"lucide-react\";\nimport { User } from \"../../lib/stack-app\";\nimport { Avatar, AvatarFallback, AvatarImage } from \"@stackframe/stack-ui\";\n\nexport function UserAvatar(props: {\n size?: number,\n user?: {\n profileImageUrl?: string | null,\n displayName?: string | null,\n primaryEmail?: string | null,\n } | null,\n}) {\n const user = props.user;\n return (\n <Avatar style={{ height: props.size || '34px', width: props.size || '34px' }}>\n <AvatarImage src={user?.profileImageUrl || ''} />\n <AvatarFallback>\n {user ?\n <div className='font-medium'>\n {(user.displayName || user.primaryEmail)?.slice(0, 2).toUpperCase()}\n </div> :\n <UserRound className=\"h-5 w-5 text-zinc-500\" />}\n </AvatarFallback>\n </Avatar>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA0B;AAE1B,sBAAoD;AAYhD;AAVG,SAAS,WAAW,OAOxB;AACD,QAAM,OAAO,MAAM;AACnB,SACE,6CAAC,0BAAO,OAAO,EAAE,QAAQ,MAAM,QAAQ,QAAQ,OAAO,MAAM,QAAQ,OAAO,GACzE;AAAA,gDAAC,+BAAY,KAAK,MAAM,mBAAmB,IAAI;AAAA,IAC/C,4CAAC,kCACE,iBACC,4CAAC,SAAI,WAAU,eACX,gBAAK,eAAe,KAAK,eAAe,MAAM,GAAG,CAAC,EAAE,YAAY,GACpE,IACA,4CAAC,iCAAU,WAAU,yBAAwB,GACjD;AAAA,KACF;AAEJ;","names":[]}
@@ -41,6 +41,7 @@ var import_navigation = require("next/navigation");
41
41
  var import_react = require("react");
42
42
  var import__ = require("..");
43
43
  var import_image = __toESM(require("next/image"));
44
+ var import_lucide_react = require("lucide-react");
44
45
  var import_jsx_runtime = require("react/jsx-runtime");
45
46
  function TeamIcon(props) {
46
47
  if (props.team.profileImageUrl) {
@@ -50,7 +51,9 @@ function TeamIcon(props) {
50
51
  }
51
52
  }
52
53
  function SelectedTeamSwitcher(props) {
54
+ const app = (0, import__.useStackApp)();
53
55
  const user = (0, import__.useUser)();
56
+ const project = app.useProject();
54
57
  const router = (0, import_navigation.useRouter)();
55
58
  const selectedTeam = user?.selectedTeam || props.selectedTeam;
56
59
  const rawTeams = user?.useTeams();
@@ -81,11 +84,38 @@ function SelectedTeamSwitcher(props) {
81
84
  children: [
82
85
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.SelectTrigger, { className: "stack-scope", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.SelectValue, { placeholder: "Select team" }) }),
83
86
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.SelectContent, { className: "stack-scope", children: [
84
- teams && teams.map((team) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.SelectItem, { value: team.id, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center", children: [
85
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TeamIcon, { team }),
86
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: team.displayName })
87
- ] }) }, team.id)),
88
- teams?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.SelectGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.SelectLabel, { children: "No teams" }) })
87
+ user?.selectedTeam ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.SelectGroup, { children: [
88
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.SelectLabel, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between", children: [
89
+ "Current team",
90
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => router.push(`${app.urls.handler}/team-settings/${user.selectedTeam?.id}`), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Settings, { className: "h-4 w-4" }) })
91
+ ] }) }),
92
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.SelectItem, { value: user.selectedTeam.id, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center", children: [
93
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TeamIcon, { team: user.selectedTeam }),
94
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: user.selectedTeam.displayName })
95
+ ] }) })
96
+ ] }) : void 0,
97
+ teams?.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.SelectGroup, { children: [
98
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.SelectLabel, { children: "Other teams" }),
99
+ teams.filter((team) => team.id !== user?.selectedTeam?.id).map((team) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.SelectItem, { value: team.id, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center", children: [
100
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TeamIcon, { team }),
101
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: team.displayName })
102
+ ] }) }, team.id))
103
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.SelectGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.SelectLabel, { children: "No teams yet" }) }),
104
+ project.config.clientTeamCreationEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
105
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.SelectSeparator, {}),
106
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
107
+ import_stack_ui.Button,
108
+ {
109
+ onClick: () => router.push(app.urls.teamCreation),
110
+ className: "w-full",
111
+ variant: "ghost",
112
+ children: [
113
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.PlusCircle, { className: "mr-2 h-4 w-4" }),
114
+ " Create a team"
115
+ ]
116
+ }
117
+ ) })
118
+ ] })
89
119
  ] })
90
120
  ]
91
121
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/selected-team-switcher.tsx"],"sourcesContent":["'use client';\nimport { runAsynchronouslyWithAlert } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectTrigger,\n SelectValue,\n Typography\n} from \"@stackframe/stack-ui\";\nimport { useRouter } from \"next/navigation\";\nimport { useEffect, useMemo } from \"react\";\nimport { Team, useUser } from \"..\";\nimport Image from \"next/image\";\n\ntype SelectedTeamSwitcherProps = {\n urlMap?: (team: Team) => string,\n selectedTeam?: Team,\n noUpdateSelectedTeam?: boolean,\n};\n\nfunction TeamIcon(props: { team: Team }) {\n if (props.team.profileImageUrl) {\n return (\n <div className=\"w-6 h-6 mr-2 rounded bg-gray-200 overflow-hidden\">\n <Image src={props.team.profileImageUrl} alt={props.team.displayName} className=\"w-6 h-6\" />\n </div>\n );\n } else {\n return (\n <div className=\"flex items-center justify-center w-6 h-6 mr-2 rounded bg-gray-200\">\n <Typography>{props.team.displayName.slice(0, 1).toUpperCase()}</Typography>\n </div>\n );\n }\n}\n\nexport function SelectedTeamSwitcher(props: SelectedTeamSwitcherProps) {\n const user = useUser();\n const router = useRouter();\n const selectedTeam = user?.selectedTeam || props.selectedTeam;\n const rawTeams = user?.useTeams();\n const teams = useMemo(() => rawTeams?.sort((a, b) => b.id === selectedTeam?.id ? 1 : -1), [rawTeams, selectedTeam]);\n\n useEffect(() => {\n if (!props.noUpdateSelectedTeam && props.selectedTeam) {\n runAsynchronouslyWithAlert(user?.setSelectedTeam(props.selectedTeam));\n }\n }, [props.noUpdateSelectedTeam, props.selectedTeam]);\n\n return (\n <Select\n value={selectedTeam?.id}\n onValueChange={(value) => {\n runAsynchronouslyWithAlert(async () => {\n const team = teams?.find(team => team.id === value);\n if (!team) {\n throw new Error('Team not found, this should not happen');\n }\n\n if (!props.noUpdateSelectedTeam) {\n await user?.setSelectedTeam(team);\n }\n if (props.urlMap) {\n router.push(props.urlMap(team));\n }\n });\n }}\n >\n <SelectTrigger className=\"stack-scope\">\n <SelectValue placeholder=\"Select team\"/>\n </SelectTrigger>\n <SelectContent className=\"stack-scope\">\n {teams && teams.map(team => (\n <SelectItem value={team.id} key={team.id}>\n <div className=\"flex items-center\">\n <TeamIcon team={team} />\n <Typography>{team.displayName}</Typography>\n </div>\n </SelectItem>\n ))}\n\n {teams?.length === 0 && (\n <SelectGroup>\n <SelectLabel>No teams</SelectLabel>\n </SelectGroup>\n )}\n </SelectContent>\n </Select>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAA2C;AAC3C,sBASO;AACP,wBAA0B;AAC1B,mBAAmC;AACnC,eAA8B;AAC9B,mBAAkB;AAYV;AAJR,SAAS,SAAS,OAAuB;AACvC,MAAI,MAAM,KAAK,iBAAiB;AAC9B,WACE,4CAAC,SAAI,WAAU,oDACb,sDAAC,aAAAA,SAAA,EAAM,KAAK,MAAM,KAAK,iBAAiB,KAAK,MAAM,KAAK,aAAa,WAAU,WAAU,GAC3F;AAAA,EAEJ,OAAO;AACL,WACE,4CAAC,SAAI,WAAU,qEACb,sDAAC,8BAAY,gBAAM,KAAK,YAAY,MAAM,GAAG,CAAC,EAAE,YAAY,GAAE,GAChE;AAAA,EAEJ;AACF;AAEO,SAAS,qBAAqB,OAAkC;AACrE,QAAM,WAAO,kBAAQ;AACrB,QAAM,aAAS,6BAAU;AACzB,QAAM,eAAe,MAAM,gBAAgB,MAAM;AACjD,QAAM,WAAW,MAAM,SAAS;AAChC,QAAM,YAAQ,sBAAQ,MAAM,UAAU,KAAK,CAAC,GAAG,MAAM,EAAE,OAAO,cAAc,KAAK,IAAI,EAAE,GAAG,CAAC,UAAU,YAAY,CAAC;AAElH,8BAAU,MAAM;AACd,QAAI,CAAC,MAAM,wBAAwB,MAAM,cAAc;AACrD,sDAA2B,MAAM,gBAAgB,MAAM,YAAY,CAAC;AAAA,IACtE;AAAA,EACF,GAAG,CAAC,MAAM,sBAAsB,MAAM,YAAY,CAAC;AAEnD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,cAAc;AAAA,MACrB,eAAe,CAAC,UAAU;AACxB,wDAA2B,YAAY;AACrC,gBAAM,OAAO,OAAO,KAAK,CAAAC,UAAQA,MAAK,OAAO,KAAK;AAClD,cAAI,CAAC,MAAM;AACT,kBAAM,IAAI,MAAM,wCAAwC;AAAA,UAC1D;AAEA,cAAI,CAAC,MAAM,sBAAsB;AAC/B,kBAAM,MAAM,gBAAgB,IAAI;AAAA,UAClC;AACA,cAAI,MAAM,QAAQ;AAChB,mBAAO,KAAK,MAAM,OAAO,IAAI,CAAC;AAAA,UAChC;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MAEA;AAAA,oDAAC,iCAAc,WAAU,eACvB,sDAAC,+BAAY,aAAY,eAAa,GACxC;AAAA,QACA,6CAAC,iCAAc,WAAU,eACtB;AAAA,mBAAS,MAAM,IAAI,UAClB,4CAAC,8BAAW,OAAO,KAAK,IACtB,uDAAC,SAAI,WAAU,qBACb;AAAA,wDAAC,YAAS,MAAY;AAAA,YACtB,4CAAC,8BAAY,eAAK,aAAY;AAAA,aAChC,KAJ+B,KAAK,EAKtC,CACD;AAAA,UAEA,OAAO,WAAW,KACjB,4CAAC,+BACC,sDAAC,+BAAY,sBAAQ,GACvB;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["Image","team"]}
1
+ {"version":3,"sources":["../../src/components/selected-team-switcher.tsx"],"sourcesContent":["'use client';\nimport { runAsynchronouslyWithAlert } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport {\n Button,\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectSeparator,\n SelectTrigger,\n SelectValue,\n Typography\n} from \"@stackframe/stack-ui\";\nimport { useRouter } from \"next/navigation\";\nimport { useEffect, useMemo } from \"react\";\nimport { Team, useStackApp, useUser } from \"..\";\nimport Image from \"next/image\";\nimport { PlusCircle, Settings } from \"lucide-react\";\n\ntype SelectedTeamSwitcherProps = {\n urlMap?: (team: Team) => string,\n selectedTeam?: Team,\n noUpdateSelectedTeam?: boolean,\n};\n\nfunction TeamIcon(props: { team: Team }) {\n if (props.team.profileImageUrl) {\n return (\n <div className=\"w-6 h-6 mr-2 rounded bg-gray-200 overflow-hidden\">\n <Image src={props.team.profileImageUrl} alt={props.team.displayName} className=\"w-6 h-6\" />\n </div>\n );\n } else {\n return (\n <div className=\"flex items-center justify-center w-6 h-6 mr-2 rounded bg-gray-200\">\n <Typography>{props.team.displayName.slice(0, 1).toUpperCase()}</Typography>\n </div>\n );\n }\n}\n\nexport function SelectedTeamSwitcher(props: SelectedTeamSwitcherProps) {\n const app = useStackApp();\n const user = useUser();\n const project = app.useProject();\n const router = useRouter();\n const selectedTeam = user?.selectedTeam || props.selectedTeam;\n const rawTeams = user?.useTeams();\n const teams = useMemo(() => rawTeams?.sort((a, b) => b.id === selectedTeam?.id ? 1 : -1), [rawTeams, selectedTeam]);\n\n useEffect(() => {\n if (!props.noUpdateSelectedTeam && props.selectedTeam) {\n runAsynchronouslyWithAlert(user?.setSelectedTeam(props.selectedTeam));\n }\n }, [props.noUpdateSelectedTeam, props.selectedTeam]);\n\n return (\n <Select\n value={selectedTeam?.id}\n onValueChange={(value) => {\n runAsynchronouslyWithAlert(async () => {\n const team = teams?.find(team => team.id === value);\n if (!team) {\n throw new Error('Team not found, this should not happen');\n }\n\n if (!props.noUpdateSelectedTeam) {\n await user?.setSelectedTeam(team);\n }\n if (props.urlMap) {\n router.push(props.urlMap(team));\n }\n });\n }}\n >\n <SelectTrigger className=\"stack-scope\">\n <SelectValue placeholder=\"Select team\"/>\n </SelectTrigger>\n <SelectContent className=\"stack-scope\">\n {user?.selectedTeam ? <SelectGroup>\n <SelectLabel>\n <div className=\"flex items-center justify-between\">\n Current team\n <Button variant='ghost' size='icon' className=\"h-6 w-6\" onClick={() => router.push(`${app.urls.handler}/team-settings/${user.selectedTeam?.id}`)}>\n <Settings className=\"h-4 w-4\"/>\n </Button>\n </div>\n </SelectLabel>\n <SelectItem value={user.selectedTeam.id}>\n <div className=\"flex items-center\">\n <TeamIcon team={user.selectedTeam} />\n <Typography>{user.selectedTeam.displayName}</Typography>\n </div>\n </SelectItem>\n </SelectGroup> : undefined}\n\n {teams?.length ?\n <SelectGroup>\n <SelectLabel>Other teams</SelectLabel>\n {teams.filter(team => team.id !== user?.selectedTeam?.id)\n .map(team => (\n <SelectItem value={team.id} key={team.id}>\n <div className=\"flex items-center\">\n <TeamIcon team={team} />\n <Typography>{team.displayName}</Typography>\n </div>\n </SelectItem>\n ))}\n </SelectGroup> :\n <SelectGroup>\n <SelectLabel>No teams yet</SelectLabel>\n </SelectGroup>}\n\n {project.config.clientTeamCreationEnabled && <>\n <SelectSeparator/>\n <div>\n <Button\n onClick={() => router.push(app.urls.teamCreation)}\n className=\"w-full\"\n variant='ghost'\n >\n <PlusCircle className=\"mr-2 h-4 w-4\"/> Create a team\n </Button>\n </div>\n </>}\n </SelectContent>\n </Select>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAA2C;AAC3C,sBAWO;AACP,wBAA0B;AAC1B,mBAAmC;AACnC,eAA2C;AAC3C,mBAAkB;AAClB,0BAAqC;AAY7B;AAJR,SAAS,SAAS,OAAuB;AACvC,MAAI,MAAM,KAAK,iBAAiB;AAC9B,WACE,4CAAC,SAAI,WAAU,oDACb,sDAAC,aAAAA,SAAA,EAAM,KAAK,MAAM,KAAK,iBAAiB,KAAK,MAAM,KA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Settings: () => AccountSettings
36
36
  });
37
37
  module.exports = __toCommonJS(account_settings_exports);
38
- var import_react = require("react");
39
- var import__ = require("..");
40
- var import_predefined_message_card = require("../components/message-cards/predefined-message-card");
41
- var import_user_avatar = require("../components/elements/user-avatar");
42
- var import_react2 = require("react");
43
- var import_form_warning = require("../components/elements/form-warning");
44
38
  var import_password = require("@stackframe/stack-shared/dist/helpers/password");
45
- var import_stack_ui = require("@stackframe/stack-ui");
39
+ var import_use_async_callback = require("@stackframe/stack-shared/dist/hooks/use-async-callback");
46
40
  var import_crypto = require("@stackframe/stack-shared/dist/utils/crypto");
47
- var import_otp = require("oslo/otp");
48
- var QRCode = __toESM(require("qrcode"));
49
41
  var import_errors = require("@stackframe/stack-shared/dist/utils/errors");
50
- var import_use_async_callback = require("@stackframe/stack-shared/dist/hooks/use-async-callback");
51
42
  var import_promises = require("@stackframe/stack-shared/dist/utils/promises");
43
+ var import_stack_ui = require("@stackframe/stack-ui");
44
+ var import_lucide_react = require("lucide-react");
45
+ var import_otp = require("oslo/otp");
46
+ var QRCode = __toESM(require("qrcode"));
47
+ var import_react = require("react");
48
+ var import__ = require("..");
49
+ var import_form_warning = require("../components/elements/form-warning");
50
+ var import_sidebar_layout = require("../components/elements/sidebar-layout");
51
+ var import_user_avatar = require("../components/elements/user-avatar");
52
52
  var import_jsx_runtime = require("react/jsx-runtime");
53
+ function AccountSettings({ fullPage = false }) {
54
+ const user = (0, import__.useUser)({ or: "redirect" });
55
+ const inner = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
56
+ import_sidebar_layout.SidebarLayout,
57
+ {
58
+ items: [
59
+ { title: "My Profile", content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProfileSection, {}), icon: import_lucide_react.Contact },
60
+ { title: "Security", content: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-4", children: [
61
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmailVerificationSection, {}),
62
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PasswordSection, {}),
63
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MfaSection, {})
64
+ ] }), icon: import_lucide_react.ShieldCheck },
65
+ { title: "Settings", content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SignOutSection, {}), icon: import_lucide_react.Settings }
66
+ ].filter(({ content }) => content),
67
+ title: "Team Settings"
68
+ }
69
+ );
70
+ if (fullPage) {
71
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Container, { size: 800, className: "stack-scope", children: inner });
72
+ } else {
73
+ return inner;
74
+ }
75
+ }
53
76
  function SettingSection(props) {
54
77
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.Card, { children: [
55
78
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.CardHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
@@ -70,8 +93,8 @@ function SettingSection(props) {
70
93
  }
71
94
  function ProfileSection() {
72
95
  const user = (0, import__.useUser)();
73
- const [userInfo, setUserInfo] = (0, import_react2.useState)({ displayName: user.displayName || "" });
74
- const [changed, setChanged] = (0, import_react2.useState)(false);
96
+ const [userInfo, setUserInfo] = (0, import_react.useState)({ displayName: user.displayName || "" });
97
+ const [changed, setChanged] = (0, import_react.useState)(false);
75
98
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
76
99
  SettingSection,
77
100
  {
@@ -111,7 +134,7 @@ function ProfileSection() {
111
134
  }
112
135
  function EmailVerificationSection() {
113
136
  const user = (0, import__.useUser)();
114
- const [emailSent, setEmailSent] = (0, import_react2.useState)(false);
137
+ const [emailSent, setEmailSent] = (0, import_react.useState)(false);
115
138
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
116
139
  SettingSection,
117
140
  {
@@ -129,13 +152,13 @@ function EmailVerificationSection() {
129
152
  }
130
153
  function PasswordSection() {
131
154
  const user = (0, import__.useUser)({ or: "throw" });
132
- const [oldPassword, setOldPassword] = (0, import_react2.useState)("");
133
- const [oldPasswordError, setOldPasswordError] = (0, import_react2.useState)("");
134
- const [newPassword, setNewPassword] = (0, import_react2.useState)("");
135
- const [newPasswordError, setNewPasswordError] = (0, import_react2.useState)("");
136
- const [repeatNewPassword, setRepeatNewPassword] = (0, import_react2.useState)("");
137
- const [repeatNewPasswordError, setRepeatNewPasswordError] = (0, import_react2.useState)("");
138
- const [passwordChanged, setPasswordChanged] = (0, import_react2.useState)(false);
155
+ const [oldPassword, setOldPassword] = (0, import_react.useState)("");
156
+ const [oldPasswordError, setOldPasswordError] = (0, import_react.useState)("");
157
+ const [newPassword, setNewPassword] = (0, import_react.useState)("");
158
+ const [newPasswordError, setNewPasswordError] = (0, import_react.useState)("");
159
+ const [repeatNewPassword, setRepeatNewPassword] = (0, import_react.useState)("");
160
+ const [repeatNewPasswordError, setRepeatNewPasswordError] = (0, import_react.useState)("");
161
+ const [passwordChanged, setPasswordChanged] = (0, import_react.useState)(false);
139
162
  if (!user.hasPassword) {
140
163
  return null;
141
164
  }
@@ -235,14 +258,11 @@ function PasswordSection() {
235
258
  }
236
259
  function MfaSection() {
237
260
  const project = (0, import__.useStackApp)().useProject();
238
- if (project.config.oauthProviders.length !== 0 || project.config.magicLinkEnabled) {
239
- return null;
240
- }
241
261
  const user = (0, import__.useUser)({ or: "throw" });
242
- const [generatedSecret, setGeneratedSecret] = (0, import_react2.useState)(null);
243
- const [qrCodeUrl, setQrCodeUrl] = (0, import_react2.useState)(null);
244
- const [mfaCode, setMfaCode] = (0, import_react2.useState)("");
245
- const [isMaybeWrong, setIsMaybeWrong] = (0, import_react2.useState)(false);
262
+ const [generatedSecret, setGeneratedSecret] = (0, import_react.useState)(null);
263
+ const [qrCodeUrl, setQrCodeUrl] = (0, import_react.useState)(null);
264
+ const [mfaCode, setMfaCode] = (0, import_react.useState)("");
265
+ const [isMaybeWrong, setIsMaybeWrong] = (0, import_react.useState)(false);
246
266
  const isEnabled = user.isMultiFactorRequired;
247
267
  const [handleSubmit, isLoading] = (0, import_use_async_callback.useAsyncCallback)(async () => {
248
268
  await user.update({
@@ -322,28 +342,6 @@ function SignOutSection() {
322
342
  }
323
343
  );
324
344
  }
325
- function AccountSettings({ fullPage = false }) {
326
- const user = (0, import__.useUser)();
327
- if (!user) {
328
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_predefined_message_card.PredefinedMessageCard, { type: "signedOut", fullPage });
329
- }
330
- const inner = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_stack_ui.cn)(fullPage ? "p-4" : "", "flex flex-col gap-4"), children: [
331
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
332
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { type: "h2", children: "Account Settings" }),
333
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", type: "label", children: "Manage your account" })
334
- ] }),
335
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProfileSection, {}),
336
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmailVerificationSection, {}),
337
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PasswordSection, {}),
338
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MfaSection, {}),
339
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SignOutSection, {})
340
- ] });
341
- if (fullPage) {
342
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Container, { size: 600, className: "stack-scope", children: inner });
343
- } else {
344
- return inner;
345
- }
346
- }
347
345
  // Annotate the CommonJS export names for ESM import in node:
348
346
  0 && (module.exports = {
349
347
  AccountSettings