@stackframe/stack 2.5.18 → 2.5.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/components/credential-sign-in.js +1 -3
- package/dist/components/credential-sign-in.js.map +1 -1
- package/dist/components/elements/sidebar-layout.d.mts +20 -0
- package/dist/components/elements/sidebar-layout.d.ts +20 -0
- package/dist/components/elements/sidebar-layout.js +111 -0
- package/dist/components/elements/sidebar-layout.js.map +1 -0
- package/dist/components/elements/user-avatar.d.mts +5 -12
- package/dist/components/elements/user-avatar.d.ts +5 -12
- package/dist/components/elements/user-avatar.js.map +1 -1
- package/dist/components/selected-team-switcher.js +36 -23
- package/dist/components/selected-team-switcher.js.map +1 -1
- package/dist/components/team-icon.d.mts +18 -0
- package/dist/components/team-icon.d.ts +18 -0
- package/dist/components/team-icon.js +50 -0
- package/dist/components/team-icon.js.map +1 -0
- package/dist/components-page/account-settings.d.mts +2 -1
- package/dist/components-page/account-settings.d.ts +2 -1
- package/dist/components-page/account-settings.js +405 -220
- package/dist/components-page/account-settings.js.map +1 -1
- package/dist/components-page/stack-handler.js +3 -5
- package/dist/components-page/stack-handler.js.map +1 -1
- package/dist/components-page/team-creation.d.mts +7 -0
- package/dist/components-page/team-creation.d.ts +7 -0
- package/dist/components-page/team-creation.js +92 -0
- package/dist/components-page/team-creation.js.map +1 -0
- package/dist/esm/components/credential-sign-in.js +1 -3
- package/dist/esm/components/credential-sign-in.js.map +1 -1
- package/dist/esm/components/elements/sidebar-layout.js +87 -0
- package/dist/esm/components/elements/sidebar-layout.js.map +1 -0
- package/dist/esm/components/elements/user-avatar.js.map +1 -1
- package/dist/esm/components/selected-team-switcher.js +40 -15
- package/dist/esm/components/selected-team-switcher.js.map +1 -1
- package/dist/esm/components/team-icon.js +15 -0
- package/dist/esm/components/team-icon.js.map +1 -0
- package/dist/esm/components-page/account-settings.js +399 -215
- package/dist/esm/components-page/account-settings.js.map +1 -1
- package/dist/esm/components-page/stack-handler.js +3 -5
- package/dist/esm/components-page/stack-handler.js.map +1 -1
- package/dist/esm/components-page/team-creation.js +68 -0
- package/dist/esm/components-page/team-creation.js.map +1 -0
- package/dist/esm/generated/global-css.js +1 -1
- package/dist/esm/generated/global-css.js.map +1 -1
- package/dist/esm/lib/auth.js +4 -0
- package/dist/esm/lib/auth.js.map +1 -1
- package/dist/esm/lib/stack-app.js +184 -34
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/generated/global-css.d.mts +1 -1
- package/dist/generated/global-css.d.ts +1 -1
- package/dist/generated/global-css.js +1 -1
- package/dist/generated/global-css.js.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/lib/auth.js +4 -0
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/stack-app.d.mts +39 -5
- package/dist/lib/stack-app.d.ts +39 -5
- package/dist/lib/stack-app.js +184 -34
- package/dist/lib/stack-app.js.map +1 -1
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @stackframe/stack
|
|
2
2
|
|
|
3
|
+
## 2.5.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Improved account settings
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @stackframe/stack-shared@2.5.20
|
|
10
|
+
- @stackframe/stack-ui@2.5.20
|
|
11
|
+
- @stackframe/stack-sc@2.5.20
|
|
12
|
+
|
|
13
|
+
## 2.5.19
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Team frontend components
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @stackframe/stack-sc@2.5.19
|
|
20
|
+
- @stackframe/stack-shared@2.5.19
|
|
21
|
+
- @stackframe/stack-ui@2.5.19
|
|
22
|
+
|
|
3
23
|
## 2.5.18
|
|
4
24
|
|
|
5
25
|
### 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
|
|
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,M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,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,20 @@
|
|
|
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 SidebarItem = {
|
|
6
|
+
title: React.ReactNode;
|
|
7
|
+
type: 'item' | 'divider';
|
|
8
|
+
description?: React.ReactNode;
|
|
9
|
+
subpath?: string;
|
|
10
|
+
icon?: LucideIcon;
|
|
11
|
+
content?: React.ReactNode;
|
|
12
|
+
contentTitle?: React.ReactNode;
|
|
13
|
+
};
|
|
14
|
+
declare function SidebarLayout(props: {
|
|
15
|
+
items: SidebarItem[];
|
|
16
|
+
title?: ReactNode;
|
|
17
|
+
basePath: string;
|
|
18
|
+
}): react_jsx_runtime.JSX.Element;
|
|
19
|
+
|
|
20
|
+
export { type SidebarItem, SidebarLayout };
|
|
@@ -0,0 +1,20 @@
|
|
|
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 SidebarItem = {
|
|
6
|
+
title: React.ReactNode;
|
|
7
|
+
type: 'item' | 'divider';
|
|
8
|
+
description?: React.ReactNode;
|
|
9
|
+
subpath?: string;
|
|
10
|
+
icon?: LucideIcon;
|
|
11
|
+
content?: React.ReactNode;
|
|
12
|
+
contentTitle?: React.ReactNode;
|
|
13
|
+
};
|
|
14
|
+
declare function SidebarLayout(props: {
|
|
15
|
+
items: SidebarItem[];
|
|
16
|
+
title?: ReactNode;
|
|
17
|
+
basePath: string;
|
|
18
|
+
}): react_jsx_runtime.JSX.Element;
|
|
19
|
+
|
|
20
|
+
export { type SidebarItem, SidebarLayout };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/components/elements/sidebar-layout.tsx
|
|
23
|
+
var sidebar_layout_exports = {};
|
|
24
|
+
__export(sidebar_layout_exports, {
|
|
25
|
+
SidebarLayout: () => SidebarLayout
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(sidebar_layout_exports);
|
|
28
|
+
var import_stack_ui = require("@stackframe/stack-ui");
|
|
29
|
+
var import_lucide_react = require("lucide-react");
|
|
30
|
+
var import_navigation = require("next/navigation");
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
function SidebarLayout(props) {
|
|
33
|
+
const pathname = (0, import_navigation.usePathname)();
|
|
34
|
+
const selectedIndex = props.items.findIndex((item) => item.subpath && props.basePath + item.subpath === pathname);
|
|
35
|
+
const router = (0, import_navigation.useRouter)();
|
|
36
|
+
if (pathname !== props.basePath && selectedIndex === -1) {
|
|
37
|
+
router.push(props.basePath);
|
|
38
|
+
}
|
|
39
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
40
|
+
/* @__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, selectedIndex, basePath: props.basePath }) }),
|
|
41
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "sm:hidden", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MobileLayout, { items: props.items, title: props.title, selectedIndex, basePath: props.basePath }) })
|
|
42
|
+
] });
|
|
43
|
+
}
|
|
44
|
+
function Items(props) {
|
|
45
|
+
const router = (0, import_navigation.useRouter)();
|
|
46
|
+
return props.items.map((item, index) => item.type === "item" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
47
|
+
import_stack_ui.Button,
|
|
48
|
+
{
|
|
49
|
+
variant: "ghost",
|
|
50
|
+
size: "sm",
|
|
51
|
+
className: (0, import_stack_ui.cn)(
|
|
52
|
+
props.selectedIndex === index && "bg-muted",
|
|
53
|
+
"justify-start text-md text-zinc-800 dark:text-zinc-300 px-2"
|
|
54
|
+
),
|
|
55
|
+
onClick: () => {
|
|
56
|
+
if (item.subpath) {
|
|
57
|
+
router.push(props.basePath + item.subpath);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
children: [
|
|
61
|
+
item.icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(item.icon, { className: "mr-2 h-4 w-4" }),
|
|
62
|
+
item.title
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
index
|
|
66
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: item.title }, index));
|
|
67
|
+
}
|
|
68
|
+
function DesktopLayout(props) {
|
|
69
|
+
const selectedItem = props.items[props.selectedIndex === -1 ? 0 : props.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", 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
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Items, { items: props.items, basePath: props.basePath, selectedIndex: props.selectedIndex })
|
|
74
|
+
] }),
|
|
75
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex-1 flex flex-col gap-4 py-2 px-4", children: [
|
|
76
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mb-4", children: [
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { type: "h4", children: selectedItem.title }),
|
|
78
|
+
selectedItem.description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", type: "label", children: selectedItem.description })
|
|
79
|
+
] }),
|
|
80
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex-1", children: selectedItem.content })
|
|
81
|
+
] })
|
|
82
|
+
] });
|
|
83
|
+
}
|
|
84
|
+
function MobileLayout(props) {
|
|
85
|
+
const selectedItem = props.items[props.selectedIndex];
|
|
86
|
+
const router = (0, import_navigation.useRouter)();
|
|
87
|
+
if (props.selectedIndex === -1) {
|
|
88
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-2 p-2", children: [
|
|
89
|
+
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 }) }),
|
|
90
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Items, { items: props.items, basePath: props.basePath, selectedIndex: props.selectedIndex })
|
|
91
|
+
] });
|
|
92
|
+
} else {
|
|
93
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex-1 flex flex-col gap-4 py-2 px-4", children: [
|
|
94
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col", children: [
|
|
95
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex justify-between", children: [
|
|
96
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { type: "h4", children: selectedItem.title }),
|
|
97
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Button, { variant: "ghost", size: "icon", onClick: () => {
|
|
98
|
+
router.push(props.basePath);
|
|
99
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.XIcon, { className: "h-5 w-5" }) })
|
|
100
|
+
] }),
|
|
101
|
+
selectedItem.description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", type: "label", children: selectedItem.description })
|
|
102
|
+
] }),
|
|
103
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex-1", children: selectedItem.content })
|
|
104
|
+
] });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
+
0 && (module.exports = {
|
|
109
|
+
SidebarLayout
|
|
110
|
+
});
|
|
111
|
+
//# 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 { LucideIcon, XIcon } from 'lucide-react';\nimport { usePathname, useRouter } from 'next/navigation';\nimport React, { ReactNode } from 'react';\n\nexport type SidebarItem = {\n title: React.ReactNode,\n type: 'item' | 'divider',\n description?: React.ReactNode,\n subpath?: string,\n icon?: LucideIcon,\n content?: React.ReactNode,\n contentTitle?: React.ReactNode,\n}\n\nexport function SidebarLayout(props: { items: SidebarItem[], title?: ReactNode, basePath: string }) {\n const pathname = usePathname();\n const selectedIndex = props.items.findIndex(item => item.subpath && (props.basePath + item.subpath === pathname));\n const router = useRouter();\n if (pathname !== props.basePath && selectedIndex === -1) {\n router.push(props.basePath);\n }\n\n return (\n <>\n <div className=\"hidden sm:flex\">\n <DesktopLayout items={props.items} title={props.title} selectedIndex={selectedIndex} basePath={props.basePath} />\n </div>\n <div className=\"sm:hidden\">\n <MobileLayout items={props.items} title={props.title} selectedIndex={selectedIndex} basePath={props.basePath} />\n </div>\n </>\n );\n}\n\nfunction Items(props: { items: SidebarItem[], basePath: string, selectedIndex: number }) {\n const router = useRouter();\n\n return props.items.map((item, index) => (\n item.type === 'item' ?\n <Button\n key={index}\n variant='ghost'\n size='sm'\n className={cn(\n props.selectedIndex === index && \"bg-muted\",\n \"justify-start text-md text-zinc-800 dark:text-zinc-300 px-2\",\n )}\n onClick={() => {\n if (item.subpath) {\n router.push(props.basePath + item.subpath);\n }\n }}\n >\n {item.icon && <item.icon className=\"mr-2 h-4 w-4\" />}\n {item.title}\n </Button> :\n <Typography key={index}>\n {item.title}\n </Typography>\n ));\n\n}\n\nfunction DesktopLayout(props: { items: SidebarItem[], title?: ReactNode, selectedIndex: number, basePath: string }) {\n const selectedItem = props.items[props.selectedIndex === -1 ? 0 : props.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'>\n <Typography type='h2' className=\"text-lg font-semibold text-zinc-800 dark:text-zinc-300\">{props.title}</Typography>\n </div>}\n\n <Items items={props.items} basePath={props.basePath} selectedIndex={props.selectedIndex} />\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'>{selectedItem.title}</Typography>\n {selectedItem.description && <Typography variant='secondary' type='label'>{selectedItem.description}</Typography>}\n </div>\n <div className='flex-1'>\n {selectedItem.content}\n </div>\n </div>\n </div>\n );\n}\n\nfunction MobileLayout(props: { items: SidebarItem[], title?: ReactNode, selectedIndex: number, basePath: string }) {\n const selectedItem = props.items[props.selectedIndex];\n const router = useRouter();\n\n if (props.selectedIndex === -1) {\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 <Items items={props.items} basePath={props.basePath} selectedIndex={props.selectedIndex} />\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'>{selectedItem.title}</Typography>\n <Button variant='ghost' size='icon' onClick={() => {\n router.push(props.basePath);\n }}>\n <XIcon className='h-5 w-5' />\n </Button>\n </div>\n {selectedItem.description && <Typography variant='secondary' type='label'>{selectedItem.description}</Typography>}\n </div>\n <div className='flex-1'>\n {selectedItem.content}\n </div>\n </div>\n );\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,sBAAuC;AACvC,0BAAkC;AAClC,wBAAuC;AAsBnC;AATG,SAAS,cAAc,OAAsE;AAClG,QAAM,eAAW,+BAAY;AAC7B,QAAM,gBAAgB,MAAM,MAAM,UAAU,UAAQ,KAAK,WAAY,MAAM,WAAW,KAAK,YAAY,QAAS;AAChH,QAAM,aAAS,6BAAU;AACzB,MAAI,aAAa,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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
|
|
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
|
|
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: {
|
|
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":[]}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use strict";
|
|
3
3
|
"use client";
|
|
4
|
-
var __create = Object.create;
|
|
5
4
|
var __defProp = Object.defineProperty;
|
|
6
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
8
|
var __export = (target, all) => {
|
|
11
9
|
for (var name in all)
|
|
@@ -19,14 +17,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
17
|
}
|
|
20
18
|
return to;
|
|
21
19
|
};
|
|
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
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
21
|
|
|
32
22
|
// src/components/selected-team-switcher.tsx
|
|
@@ -37,20 +27,16 @@ __export(selected_team_switcher_exports, {
|
|
|
37
27
|
module.exports = __toCommonJS(selected_team_switcher_exports);
|
|
38
28
|
var import_promises = require("@stackframe/stack-shared/dist/utils/promises");
|
|
39
29
|
var import_stack_ui = require("@stackframe/stack-ui");
|
|
30
|
+
var import_lucide_react = require("lucide-react");
|
|
40
31
|
var import_navigation = require("next/navigation");
|
|
41
32
|
var import_react = require("react");
|
|
42
33
|
var import__ = require("..");
|
|
43
|
-
var
|
|
34
|
+
var import_team_icon = require("./team-icon");
|
|
44
35
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
-
function TeamIcon(props) {
|
|
46
|
-
if (props.team.profileImageUrl) {
|
|
47
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-6 h-6 mr-2 rounded bg-gray-200 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_image.default, { src: props.team.profileImageUrl, alt: props.team.displayName, className: "w-6 h-6" }) });
|
|
48
|
-
} else {
|
|
49
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex items-center justify-center w-6 h-6 mr-2 rounded bg-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: props.team.displayName.slice(0, 1).toUpperCase() }) });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
36
|
function SelectedTeamSwitcher(props) {
|
|
37
|
+
const app = (0, import__.useStackApp)();
|
|
53
38
|
const user = (0, import__.useUser)();
|
|
39
|
+
const project = app.useProject();
|
|
54
40
|
const router = (0, import_navigation.useRouter)();
|
|
55
41
|
const selectedTeam = user?.selectedTeam || props.selectedTeam;
|
|
56
42
|
const rawTeams = user?.useTeams();
|
|
@@ -81,11 +67,38 @@ function SelectedTeamSwitcher(props) {
|
|
|
81
67
|
children: [
|
|
82
68
|
/* @__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
69
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.SelectContent, { className: "stack-scope", children: [
|
|
84
|
-
|
|
85
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
70
|
+
user?.selectedTeam ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.SelectGroup, { children: [
|
|
71
|
+
/* @__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: [
|
|
72
|
+
"Current team",
|
|
73
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => router.push(`${app.urls.accountSettings}/teams/${user.selectedTeam?.id}`), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Settings, { className: "h-4 w-4" }) })
|
|
74
|
+
] }) }),
|
|
75
|
+
/* @__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 gap-2", children: [
|
|
76
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_team_icon.TeamIcon, { team: user.selectedTeam }),
|
|
77
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: user.selectedTeam.displayName })
|
|
78
|
+
] }) })
|
|
79
|
+
] }) : void 0,
|
|
80
|
+
teams?.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.SelectGroup, { children: [
|
|
81
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.SelectLabel, { children: "Other teams" }),
|
|
82
|
+
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 gap-2", children: [
|
|
83
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_team_icon.TeamIcon, { team }),
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: team.displayName })
|
|
85
|
+
] }) }, team.id))
|
|
86
|
+
] }) : /* @__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" }) }),
|
|
87
|
+
project.config.clientTeamCreationEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.SelectSeparator, {}),
|
|
89
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
90
|
+
import_stack_ui.Button,
|
|
91
|
+
{
|
|
92
|
+
onClick: () => router.push(`${app.urls.accountSettings}/team-creation`),
|
|
93
|
+
className: "w-full",
|
|
94
|
+
variant: "ghost",
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.PlusCircle, { className: "mr-2 h-4 w-4" }),
|
|
97
|
+
" Create a team"
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
) })
|
|
101
|
+
] })
|
|
89
102
|
] })
|
|
90
103
|
]
|
|
91
104
|
}
|
|
@@ -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
|
|
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 { PlusCircle, Settings } from \"lucide-react\";\nimport { useRouter } from \"next/navigation\";\nimport { useEffect, useMemo } from \"react\";\nimport { Team, useStackApp, useUser } from \"..\";\nimport { TeamIcon } from \"./team-icon\";\n\ntype SelectedTeamSwitcherProps = {\n urlMap?: (team: Team) => string,\n selectedTeam?: Team,\n noUpdateSelectedTeam?: boolean,\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.accountSettings}/teams/${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 gap-2\">\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 gap-2\">\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.accountSettings}/team-creation`)}\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,0BAAqC;AACrC,wBAA0B;AAC1B,mBAAmC;AACnC,eAA2C;AAC3C,uBAAyB;AA2CjB;AAnCD,SAAS,qBAAqB,OAAkC;AACrE,QAAM,UAAM,sBAAY;AACxB,QAAM,WAAO,kBAAQ;AACrB,QAAM,UAAU,IAAI,WAAW;AAC/B,QAAM,aAAS,6BAAU;AACzB,QAAM,eAAe,MAAM,gBAAgB,MAAM;AACjD,QAAM,WAAW,MAAM,SAAS;AAChC,QAAM,YAAQ,sBAAQ,MAAM,UAAU,KAAK,CAAC,GAAG,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AAAA,eAC7C,GACF;AAAA,aACF,IAAiB;AAAA,UAEhB,OAAO,SACN,6CAAC,+BACC;AAAA,wDAAC,+BAAY,yBAAW;AAAA,YACvB,MAAM,OAAO,UAAQ,KAAK,OAAO,MAAM,cAAc,EAAE,EACrD,IAAI,UACH,4CAAC,8BAAW,OAAO,KAAK,IACtB,uDAAC,SAAI,WAAU,2BACb;AAAA,0DAAC,6BAAS,MAAY;AAAA,cACtB,4CAAC,8BAAY,eAAK,aAAY;AAAA,eAChC,KAJ+B,KAAK,EAKtC,CACD;AAAA,aACL,IACA,4CAAC,+BACC,sDAAC,+BAAY,0BAAY,GAC3B;AAAA,UAED,QAAQ,OAAO,6BAA6B,4EAC3C;AAAA,wDAAC,mCAAe;AAAA,YAChB,4CAAC,SACC;AAAA,cAAC;AAAA;AAAA,gBACC,SAAS,MAAM,OAAO,KAAK,GAAG,IAAI,KAAK,eAAe,gBAAgB;AAAA,gBACtE,WAAU;AAAA,gBACV,SAAQ;AAAA,gBAER;AAAA,8DAAC,kCAAW,WAAU,gBAAc;AAAA,kBAAE;AAAA;AAAA;AAAA,YACxC,GACF;AAAA,aACF;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["team"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Team } 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
|
+
|
|
14
|
+
declare function TeamIcon(props: {
|
|
15
|
+
team: Team;
|
|
16
|
+
}): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { TeamIcon };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Team } 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
|
+
|
|
14
|
+
declare function TeamIcon(props: {
|
|
15
|
+
team: Team;
|
|
16
|
+
}): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { TeamIcon };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/components/team-icon.tsx
|
|
31
|
+
var team_icon_exports = {};
|
|
32
|
+
__export(team_icon_exports, {
|
|
33
|
+
TeamIcon: () => TeamIcon
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(team_icon_exports);
|
|
36
|
+
var import_image = __toESM(require("next/image"));
|
|
37
|
+
var import_stack_ui = require("@stackframe/stack-ui");
|
|
38
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
|
+
function TeamIcon(props) {
|
|
40
|
+
if (props.team.profileImageUrl) {
|
|
41
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-6 h-6 rounded bg-gray-200 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_image.default, { src: props.team.profileImageUrl, alt: props.team.displayName, className: "w-6 h-6" }) });
|
|
42
|
+
} else {
|
|
43
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex items-center justify-center w-6 h-6 rounded bg-gray-200", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: props.team.displayName.slice(0, 1).toUpperCase() }) });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
TeamIcon
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=team-icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/team-icon.tsx"],"sourcesContent":["import Image from \"next/image\";\nimport { Team } from \"..\";\nimport { Typography } from \"@stackframe/stack-ui\";\n\nexport function TeamIcon(props: { team: Team }) {\n if (props.team.profileImageUrl) {\n return (\n <div className=\"w-6 h-6 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 rounded bg-gray-200\">\n <Typography>{props.team.displayName.slice(0, 1).toUpperCase()}</Typography>\n </div>\n );\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,sBAA2B;AAMnB;AAJD,SAAS,SAAS,OAAuB;AAC9C,MAAI,MAAM,KAAK,iBAAiB;AAC9B,WACE,4CAAC,SAAI,WAAU,+CACb,sDAAC,aAAAA,SAAA,EAAM,KAAK,MAAM,KAAK,iBAAiB,KAAK,MAAM,KAAK,aAAa,WAAU,WAAU,GAC3F;AAAA,EAEJ,OAAO;AACL,WACE,4CAAC,SAAI,WAAU,gEACb,sDAAC,8BAAY,gBAAM,KAAK,YAAY,MAAM,GAAG,CAAC,EAAE,YAAY,GAAE,GAChE;AAAA,EAEJ;AACF;","names":["Image"]}
|
|
@@ -3,5 +3,6 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
3
3
|
declare function AccountSettings({ fullPage }: {
|
|
4
4
|
fullPage?: boolean;
|
|
5
5
|
}): react_jsx_runtime.JSX.Element;
|
|
6
|
+
declare function TeamCreation(): react_jsx_runtime.JSX.Element;
|
|
6
7
|
|
|
7
|
-
export { AccountSettings };
|
|
8
|
+
export { AccountSettings, TeamCreation };
|
|
@@ -3,5 +3,6 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
3
3
|
declare function AccountSettings({ fullPage }: {
|
|
4
4
|
fullPage?: boolean;
|
|
5
5
|
}): react_jsx_runtime.JSX.Element;
|
|
6
|
+
declare function TeamCreation(): react_jsx_runtime.JSX.Element;
|
|
6
7
|
|
|
7
|
-
export { AccountSettings };
|
|
8
|
+
export { AccountSettings, TeamCreation };
|