@tangle-network/ui 11.9.0 → 11.11.0

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 (155) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +14 -0
  3. package/dist/active-sessions-store-Gt1R0rFG.js +262 -0
  4. package/dist/{active-sessions-store-CeOmXgv5.d.ts → active-sessions-store-nl70ZnMC.d.ts} +40 -41
  5. package/dist/artifact-pane-BL_DFWNl.d.ts +32 -0
  6. package/dist/artifact-pane-DMXT9a8U.js +70 -0
  7. package/dist/auth-DixfCMCk.js +154 -0
  8. package/dist/auth.d.ts +2 -74
  9. package/dist/auth.js +2 -15
  10. package/dist/branding-26d5ARIr.d.ts +14 -0
  11. package/dist/button-uhNnwdsD.js +78 -0
  12. package/dist/button-yoIv77e2.d.ts +16 -0
  13. package/dist/chat-CPLL0Fd9.js +667 -0
  14. package/dist/chat.d.ts +2 -201
  15. package/dist/chat.js +2 -30
  16. package/dist/code-block-B9miUPht.d.ts +23 -0
  17. package/dist/code-block-CngSn37j.js +165 -0
  18. package/dist/diff-preview-cySuqowW.js +533 -0
  19. package/dist/document-editor-pane-BcoABlhn.d.ts +131 -0
  20. package/dist/document-editor-pane-Cz6oEF1o.js +1287 -0
  21. package/dist/dropdown-menu-BpcLa5vF.js +101 -0
  22. package/dist/editor.d.ts +76 -78
  23. package/dist/editor.js +2 -33
  24. package/dist/file-format-BgXbr-Ib.js +160 -0
  25. package/dist/files-CYlOo0mE.js +743 -0
  26. package/dist/files.d.ts +2 -243
  27. package/dist/files.js +3 -40
  28. package/dist/focus-Cw02pNSr.js +56 -0
  29. package/dist/format-DfcLWqMa.js +54 -0
  30. package/dist/hooks.d.ts +30 -37
  31. package/dist/hooks.js +111 -45
  32. package/dist/index-2UntyjBb.d.ts +52 -0
  33. package/dist/index-COgqsFAQ.d.ts +42 -0
  34. package/dist/index-CPDET_s1.d.ts +549 -0
  35. package/dist/index-CUhfHT_V.d.ts +204 -0
  36. package/dist/index-Cg6gYAqh.d.ts +73 -0
  37. package/dist/index-Cq-EJzqW.d.ts +16 -0
  38. package/dist/index-DhYmSaLF.d.ts +245 -0
  39. package/dist/index-DjKxO357.d.ts +128 -0
  40. package/dist/index-b56ew9aF.d.ts +107 -0
  41. package/dist/index.d.ts +26 -43
  42. package/dist/index.js +35 -460
  43. package/dist/markdown-BprL96Gl.js +45 -0
  44. package/dist/markdown.d.ts +3 -18
  45. package/dist/markdown.js +3 -14
  46. package/dist/message-vhUI0c5G.d.ts +16 -0
  47. package/dist/nav.d.ts +6 -8
  48. package/dist/nav.js +29 -11
  49. package/dist/openui-artifact-renderer-D3E5bIAI.d.ts +114 -0
  50. package/dist/openui-artifact-renderer-DT4xbvWt.js +266 -0
  51. package/dist/openui.d.ts +2 -115
  52. package/dist/openui.js +2 -12
  53. package/dist/parts-5mhy9yJ3.d.ts +37 -0
  54. package/dist/primitives-DE-blUz-.js +1239 -0
  55. package/dist/primitives.d.ts +5 -523
  56. package/dist/primitives.js +9 -211
  57. package/dist/redaction-CGGB2ENG.js +74 -0
  58. package/dist/redaction.d.ts +2 -42
  59. package/dist/redaction.js +2 -7
  60. package/dist/run-OyWmIDqu.d.ts +41 -0
  61. package/dist/run-ZsIKPA6J.js +17 -0
  62. package/dist/run-group-D1InSdQu.js +410 -0
  63. package/dist/run.d.ts +3 -126
  64. package/dist/run.js +5 -39
  65. package/dist/sdk-hooks.d.ts +2 -285
  66. package/dist/sdk-hooks.js +3 -35
  67. package/dist/stores.d.ts +13 -14
  68. package/dist/stores.js +34 -76
  69. package/dist/table-DHyqDPbU.js +146 -0
  70. package/dist/tabs-ujuqAdtb.js +40 -0
  71. package/dist/text-shimmer-BUUo6I-g.js +64 -0
  72. package/dist/tool-call-feed-BeB1_4pX.d.ts +47 -0
  73. package/dist/tool-call-feed-C1W1N54c.js +109 -0
  74. package/dist/tool-call-step-Bi3_YJRV.js +434 -0
  75. package/dist/tool-display-BAuAVa43.js +158 -0
  76. package/dist/{tool-display-z4JcDmMQ.d.ts → tool-display-DgmL5rIU.d.ts} +16 -16
  77. package/dist/tool-previews.d.ts +2 -48
  78. package/dist/tool-previews.js +2 -22
  79. package/dist/types.d.ts +6 -19
  80. package/dist/types.js +0 -1
  81. package/dist/use-auto-scroll-C5Pjeqon.js +153 -0
  82. package/dist/use-sse-stream-BjVBDbxK.js +884 -0
  83. package/dist/use-sse-stream-Dm6R5YWz.d.ts +282 -0
  84. package/dist/utils-Bl_CZ0Qp.js +37 -0
  85. package/dist/{chunk-RQHJBTEU.js → utils-C_uf36nf.js} +4 -6
  86. package/dist/utils.d.ts +2 -51
  87. package/dist/utils.js +6 -32
  88. package/package.json +39 -41
  89. package/src/auth/auth.tsx +5 -1
  90. package/src/chat/agent-timeline.tsx +6 -1
  91. package/src/chat/chat-container.tsx +2 -1
  92. package/src/editor/document-editor-pane.test.tsx +3 -1
  93. package/src/editor/document-editor-pane.tsx +5 -1
  94. package/src/editor/markdown-document-editor.test.tsx +9 -4
  95. package/src/files/file-artifact-pane.tsx +3 -2
  96. package/src/files/file-preview.tsx +3 -1
  97. package/src/files/file-tabs.tsx +9 -2
  98. package/src/lib/focus.ts +63 -0
  99. package/src/markdown/code-block.tsx +5 -1
  100. package/src/primitives/badge.tsx +2 -1
  101. package/src/primitives/button.tsx +2 -1
  102. package/src/primitives/card.tsx +1 -2
  103. package/src/primitives/dialog.tsx +7 -1
  104. package/src/primitives/input.tsx +15 -14
  105. package/src/primitives/segmented-control.tsx +5 -3
  106. package/src/primitives/select.tsx +3 -1
  107. package/src/primitives/switch.tsx +3 -1
  108. package/src/primitives/tabs.tsx +6 -4
  109. package/src/primitives/terminal-display.tsx +6 -8
  110. package/src/primitives/toast.tsx +5 -1
  111. package/src/tool-previews/command-preview.tsx +5 -1
  112. package/src/tool-previews/web-search-preview.tsx +2 -1
  113. package/src/utils/index.ts +7 -0
  114. package/dist/artifact-pane-DpuWcAiF.d.ts +0 -33
  115. package/dist/button-CMQuQEW_.d.ts +0 -17
  116. package/dist/chunk-34A66VBG.js +0 -214
  117. package/dist/chunk-3OI2QKFD.js +0 -0
  118. package/dist/chunk-3TI5DEHV.js +0 -299
  119. package/dist/chunk-4CLN43XT.js +0 -45
  120. package/dist/chunk-565EATZZ.js +0 -156
  121. package/dist/chunk-5Z5ZYMOJ.js +0 -0
  122. package/dist/chunk-6BGQA4BQ.js +0 -0
  123. package/dist/chunk-7YOCS6IF.js +0 -728
  124. package/dist/chunk-EOAX2ENE.js +0 -60
  125. package/dist/chunk-GYPQXTJU.js +0 -230
  126. package/dist/chunk-HFL6R6IF.js +0 -37
  127. package/dist/chunk-HGML45QH.js +0 -104
  128. package/dist/chunk-KNYSKNZX.js +0 -550
  129. package/dist/chunk-L57WRIND.js +0 -59
  130. package/dist/chunk-LDLOJKPC.js +0 -1585
  131. package/dist/chunk-LTEKI7YJ.js +0 -59
  132. package/dist/chunk-MKTSMWVD.js +0 -109
  133. package/dist/chunk-ND3ZFXQK.js +0 -179
  134. package/dist/chunk-NKDZ7GZE.js +0 -192
  135. package/dist/chunk-NWECTSOH.js +0 -589
  136. package/dist/chunk-OEX7NZE3.js +0 -321
  137. package/dist/chunk-Q56BYXQF.js +0 -61
  138. package/dist/chunk-REJESC5U.js +0 -117
  139. package/dist/chunk-RQGKSCEZ.js +0 -0
  140. package/dist/chunk-TN4FUEWY.js +0 -437
  141. package/dist/chunk-VPWY4I5O.js +0 -1048
  142. package/dist/chunk-WUQDUBJG.js +0 -168
  143. package/dist/chunk-XGKULLYE.js +0 -40
  144. package/dist/chunk-XU3HB5QL.js +0 -127
  145. package/dist/chunk-XYAIX4SU.js +0 -133
  146. package/dist/chunk-YJ6RE5WV.js +0 -875
  147. package/dist/chunk-YTO5V6QS.js +0 -19
  148. package/dist/chunk-ZKCEAIIZ.js +0 -1395
  149. package/dist/code-block-0kSpWMnf.d.ts +0 -25
  150. package/dist/document-editor-pane-EX25CEYW.js +0 -12
  151. package/dist/document-editor-pane-IAEQn_Dl.d.ts +0 -128
  152. package/dist/message-BHWbxBtT.d.ts +0 -15
  153. package/dist/parts-dj7AcUg0.d.ts +0 -36
  154. package/dist/run-PfLmDAox.d.ts +0 -41
  155. package/dist/tool-call-feed-D9iofJgW.d.ts +0 -46
@@ -1,59 +0,0 @@
1
- import {
2
- cn
3
- } from "./chunk-RQHJBTEU.js";
4
-
5
- // src/primitives/artifact-pane.tsx
6
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
- function ArtifactPane({
8
- eyebrow,
9
- title,
10
- subtitle,
11
- meta,
12
- headerActions,
13
- tabs,
14
- toolbar,
15
- footer,
16
- emptyState,
17
- children,
18
- className,
19
- contentClassName,
20
- headerClassName,
21
- hideTitleBlock = false
22
- }) {
23
- const hasContent = children !== void 0 && children !== null;
24
- const showTitleRow = !hideTitleBlock || Boolean(headerActions);
25
- const hasHeader = showTitleRow || Boolean(tabs) || Boolean(toolbar);
26
- const toolbarNeedsDivider = showTitleRow || Boolean(tabs);
27
- return /* @__PURE__ */ jsxs(
28
- "section",
29
- {
30
- className: cn(
31
- "flex h-full min-h-0 flex-col overflow-hidden bg-background text-foreground",
32
- className
33
- ),
34
- children: [
35
- hasHeader && /* @__PURE__ */ jsxs("header", { className: cn("border-b border-border bg-muted/10", headerClassName), children: [
36
- showTitleRow && /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3 px-3 py-2", children: [
37
- /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: !hideTitleBlock && /* @__PURE__ */ jsxs(Fragment, { children: [
38
- eyebrow && /* @__PURE__ */ jsx("div", { className: "mb-1 inline-flex max-w-full items-center px-1 py-0.5 text-[10px] font-bold uppercase tracking-wider text-muted-foreground", children: eyebrow }),
39
- /* @__PURE__ */ jsx("div", { className: "min-w-0 text-[13px] font-medium text-foreground", children: title }),
40
- (subtitle || meta) && /* @__PURE__ */ jsxs("div", { className: "mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs leading-relaxed text-muted-foreground", children: [
41
- subtitle && /* @__PURE__ */ jsx("span", { className: "truncate", children: subtitle }),
42
- meta && /* @__PURE__ */ jsx("span", { className: "flex items-center gap-2", children: meta })
43
- ] })
44
- ] }) }),
45
- headerActions && /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-1.5", children: headerActions })
46
- ] }),
47
- tabs,
48
- toolbar && /* @__PURE__ */ jsx("div", { className: cn("px-3 py-2", toolbarNeedsDivider && "border-t border-border"), children: toolbar })
49
- ] }),
50
- /* @__PURE__ */ jsx("div", { className: cn("min-h-0 flex-1 overflow-auto", contentClassName), children: hasContent ? children : emptyState ? /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center p-6", children: emptyState }) : null }),
51
- footer && /* @__PURE__ */ jsx("footer", { className: "shrink-0 border-t border-border bg-card px-3 py-2", children: footer })
52
- ]
53
- }
54
- );
55
- }
56
-
57
- export {
58
- ArtifactPane
59
- };
@@ -1,109 +0,0 @@
1
- import {
2
- cn
3
- } from "./chunk-RQHJBTEU.js";
4
-
5
- // src/primitives/button.tsx
6
- import { Slot } from "@radix-ui/react-slot";
7
- import { cva } from "class-variance-authority";
8
- import * as React from "react";
9
- import { jsx, jsxs } from "react/jsx-runtime";
10
- var buttonVariants = cva(
11
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-lg font-medium text-sm transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
12
- {
13
- variants: {
14
- variant: {
15
- default: "bg-primary text-primary-foreground hover:bg-primary/90 active:scale-[0.97] duration-[var(--transition-fast)]",
16
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90 active:scale-[0.97] duration-[var(--transition-fast)]",
17
- outline: "border border-border bg-card hover:bg-muted active:scale-[0.97] duration-[var(--transition-fast)] text-foreground",
18
- secondary: "bg-muted border border-border text-foreground hover:bg-muted/80 active:scale-[0.97] duration-[var(--transition-fast)]",
19
- ghost: "hover:bg-muted hover:text-foreground duration-[var(--transition-fast)] text-muted-foreground border border-transparent",
20
- link: "text-primary underline-offset-4 hover:underline",
21
- sandbox: "bg-[var(--btn-primary-bg)] text-[var(--btn-primary-text)] border border-[var(--border-accent)] hover:bg-[var(--btn-primary-hover)] active:scale-[0.97] duration-[var(--transition-fast)]"
22
- },
23
- size: {
24
- default: "h-[var(--control-height)] px-4 py-2",
25
- sm: "h-8 rounded-md px-3 text-xs",
26
- lg: "h-11 rounded-lg px-7 text-sm",
27
- xl: "h-13 rounded-xl px-9 text-base",
28
- icon: "h-[var(--control-height)] w-[var(--control-height)]"
29
- }
30
- },
31
- defaultVariants: {
32
- variant: "default",
33
- size: "default"
34
- }
35
- }
36
- );
37
- var Button = React.forwardRef(
38
- ({
39
- className,
40
- variant,
41
- size,
42
- asChild = false,
43
- loading = false,
44
- disabled,
45
- children,
46
- ...props
47
- }, ref) => {
48
- const Comp = asChild ? Slot : "button";
49
- if (asChild) {
50
- return /* @__PURE__ */ jsx(
51
- Comp,
52
- {
53
- className: cn(buttonVariants({ variant, size, className })),
54
- ref,
55
- ...props,
56
- children
57
- }
58
- );
59
- }
60
- return /* @__PURE__ */ jsxs(
61
- Comp,
62
- {
63
- className: cn(buttonVariants({ variant, size, className })),
64
- ref,
65
- disabled: disabled || loading,
66
- ...props,
67
- children: [
68
- loading && /* @__PURE__ */ jsxs(
69
- "svg",
70
- {
71
- className: "mr-2 -ml-1 h-4 w-4 animate-spin",
72
- fill: "none",
73
- viewBox: "0 0 24 24",
74
- children: [
75
- /* @__PURE__ */ jsx("title", { children: "Loading spinner" }),
76
- /* @__PURE__ */ jsx(
77
- "circle",
78
- {
79
- className: "opacity-25",
80
- cx: "12",
81
- cy: "12",
82
- r: "10",
83
- stroke: "currentColor",
84
- strokeWidth: "4"
85
- }
86
- ),
87
- /* @__PURE__ */ jsx(
88
- "path",
89
- {
90
- className: "opacity-75",
91
- fill: "currentColor",
92
- d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
93
- }
94
- )
95
- ]
96
- }
97
- ),
98
- children
99
- ]
100
- }
101
- );
102
- }
103
- );
104
- Button.displayName = "Button";
105
-
106
- export {
107
- buttonVariants,
108
- Button
109
- };
@@ -1,179 +0,0 @@
1
- // src/utils/tool-display.ts
2
- var TOOL_NAME_PREFIX = "tool:";
3
- function normalizeToolName(tool) {
4
- const n = tool?.toLowerCase() ?? "";
5
- return n.startsWith(TOOL_NAME_PREFIX) ? n.slice(TOOL_NAME_PREFIX.length) : n;
6
- }
7
- function extractString(obj, key) {
8
- if (typeof obj === "object" && obj !== null && key in obj) {
9
- const val = obj[key];
10
- if (typeof val === "string") return val;
11
- }
12
- return void 0;
13
- }
14
- function extractCommand(input) {
15
- if (typeof input === "string") return input;
16
- return extractString(input, "command") ?? extractString(input, "cmd");
17
- }
18
- function extractFilePath(input) {
19
- return extractString(input, "file_path") ?? extractString(input, "path") ?? extractString(input, "filePath") ?? extractString(input, "file");
20
- }
21
- var TOOL_CATEGORY_ICONS = {
22
- command: "terminal",
23
- write: "file-plus",
24
- read: "file-text",
25
- search: "search",
26
- edit: "file-edit",
27
- task: "cpu",
28
- web: "globe",
29
- todo: "check-square",
30
- other: "box"
31
- };
32
- function getToolCategory(toolName) {
33
- const name = normalizeToolName(toolName);
34
- switch (name) {
35
- case "bash":
36
- case "shell":
37
- case "command":
38
- case "execute":
39
- return "command";
40
- case "write":
41
- case "write_file":
42
- case "create_file":
43
- return "write";
44
- case "read":
45
- case "read_file":
46
- case "cat":
47
- return "read";
48
- case "grep":
49
- case "search":
50
- case "rg":
51
- return "search";
52
- case "edit":
53
- case "patch":
54
- case "sed":
55
- return "edit";
56
- case "glob":
57
- case "find":
58
- case "ls":
59
- return "search";
60
- case "web_search":
61
- case "web_fetch":
62
- case "fetch":
63
- return "web";
64
- case "task":
65
- case "agent":
66
- case "spawn":
67
- return "task";
68
- case "todo":
69
- case "todo_write":
70
- return "todo";
71
- default:
72
- return "other";
73
- }
74
- }
75
- function getToolDisplayMetadata(part) {
76
- const name = normalizeToolName(part.tool);
77
- const input = part.state.status !== "pending" ? part.state.input : void 0;
78
- const filePath = extractFilePath(input);
79
- const command = extractCommand(input);
80
- switch (name) {
81
- case "bash":
82
- case "shell":
83
- case "command":
84
- case "execute":
85
- return {
86
- title: "Shell",
87
- description: command ? truncateCommand(command) : void 0,
88
- displayVariant: "command",
89
- commandSnippet: command
90
- };
91
- case "write":
92
- case "write_file":
93
- case "create_file":
94
- return {
95
- title: "Write",
96
- description: filePath,
97
- displayVariant: "write-file",
98
- targetPath: filePath
99
- };
100
- case "edit":
101
- case "patch":
102
- return {
103
- title: "Edit",
104
- description: filePath,
105
- hasDiffOutput: true,
106
- diffFilePath: filePath,
107
- displayVariant: "diff",
108
- targetPath: filePath
109
- };
110
- case "read":
111
- case "read_file":
112
- case "cat":
113
- return {
114
- title: "Read",
115
- description: filePath,
116
- displayVariant: "read-file",
117
- targetPath: filePath
118
- };
119
- case "grep":
120
- case "search":
121
- case "rg": {
122
- const pattern = extractString(input, "pattern");
123
- return {
124
- title: "Search",
125
- description: pattern,
126
- displayVariant: "grep"
127
- };
128
- }
129
- case "glob":
130
- case "find":
131
- case "ls": {
132
- const pattern = extractString(input, "pattern");
133
- return {
134
- title: "Find",
135
- description: pattern,
136
- displayVariant: "glob"
137
- };
138
- }
139
- case "web_search":
140
- case "web_fetch":
141
- case "fetch": {
142
- const query = extractString(input, "query") ?? extractString(input, "url");
143
- return {
144
- title: name === "web_search" ? "Web search" : "Fetch",
145
- description: query ? truncateCommand(query) : void 0,
146
- displayVariant: "web-search"
147
- };
148
- }
149
- case "task":
150
- case "agent":
151
- case "spawn": {
152
- const desc = extractString(input, "description") ?? extractString(input, "prompt");
153
- return {
154
- title: "Task",
155
- description: desc ? truncateCommand(desc) : void 0
156
- };
157
- }
158
- default:
159
- return {
160
- title: part.tool || "Tool",
161
- description: command ?? filePath ?? extractString(input, "pattern") ?? extractString(input, "query")
162
- };
163
- }
164
- }
165
- function truncateCommand(cmd) {
166
- const first = cmd.split("\n")[0];
167
- return first.length > 60 ? first.slice(0, 57) + "..." : first;
168
- }
169
- function getToolErrorText(part, fallback) {
170
- if (part.state.status !== "error") return void 0;
171
- return part.state.error || fallback;
172
- }
173
-
174
- export {
175
- TOOL_CATEGORY_ICONS,
176
- getToolCategory,
177
- getToolDisplayMetadata,
178
- getToolErrorText
179
- };
@@ -1,192 +0,0 @@
1
- import {
2
- Avatar,
3
- AvatarFallback,
4
- AvatarImage,
5
- DropdownMenu,
6
- DropdownMenuContent,
7
- DropdownMenuItem,
8
- DropdownMenuLabel,
9
- DropdownMenuSeparator,
10
- DropdownMenuTrigger
11
- } from "./chunk-34A66VBG.js";
12
- import {
13
- Button
14
- } from "./chunk-MKTSMWVD.js";
15
- import {
16
- cn
17
- } from "./chunk-RQHJBTEU.js";
18
-
19
- // src/auth/auth.tsx
20
- import { jsx, jsxs } from "react/jsx-runtime";
21
- function GitHubIcon({ className }) {
22
- return /* @__PURE__ */ jsx(
23
- "svg",
24
- {
25
- className,
26
- viewBox: "0 0 24 24",
27
- fill: "currentColor",
28
- "aria-hidden": "true",
29
- children: /* @__PURE__ */ jsx(
30
- "path",
31
- {
32
- fillRule: "evenodd",
33
- clipRule: "evenodd",
34
- d: "M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"
35
- }
36
- )
37
- }
38
- );
39
- }
40
- function GitHubLoginButton({
41
- authUrl = "/auth/github",
42
- variant = "default",
43
- className,
44
- children,
45
- ...props
46
- }) {
47
- return /* @__PURE__ */ jsxs(
48
- Button,
49
- {
50
- variant,
51
- className: cn("gap-2", className),
52
- onClick: () => {
53
- window.location.href = authUrl;
54
- },
55
- ...props,
56
- children: [
57
- /* @__PURE__ */ jsx(GitHubIcon, { className: "h-5 w-5" }),
58
- children ?? "Sign in with GitHub"
59
- ]
60
- }
61
- );
62
- }
63
- function UserMenu({
64
- user,
65
- logoutUrl = "/auth/logout",
66
- links = [],
67
- variant = "sandbox",
68
- onLogout
69
- }) {
70
- const initials = user.name ? user.name.split(" ").map((n) => n[0]).join("").toUpperCase().slice(0, 2) : user.email.slice(0, 2).toUpperCase();
71
- const avatarGradient = {
72
- sandbox: "bg-[image:var(--accent-gradient-strong)]"
73
- }[variant];
74
- const handleLogout = () => {
75
- if (onLogout) {
76
- onLogout();
77
- }
78
- window.location.href = logoutUrl;
79
- };
80
- return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
81
- /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
82
- "button",
83
- {
84
- type: "button",
85
- className: "flex items-center gap-2 rounded-lg p-1.5 transition-colors hover:bg-accent focus:outline-none focus:ring-2 focus:ring-ring",
86
- children: [
87
- /* @__PURE__ */ jsxs(Avatar, { className: "h-8 w-8", children: [
88
- /* @__PURE__ */ jsx(AvatarImage, { src: void 0, alt: user.name ?? user.email }),
89
- /* @__PURE__ */ jsx(
90
- AvatarFallback,
91
- {
92
- className: cn(
93
- "text-white text-xs",
94
- avatarGradient
95
- ),
96
- children: initials
97
- }
98
- )
99
- ] }),
100
- /* @__PURE__ */ jsxs("div", { className: "hidden text-left md:block", children: [
101
- /* @__PURE__ */ jsx("p", { className: "font-medium text-sm", children: user.name ?? user.email }),
102
- user.tier && /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-xs capitalize", children: [
103
- user.tier,
104
- " Plan"
105
- ] })
106
- ] })
107
- ]
108
- }
109
- ) }),
110
- /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-56", children: [
111
- /* @__PURE__ */ jsx(DropdownMenuLabel, { className: "font-normal", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-1", children: [
112
- /* @__PURE__ */ jsx("p", { className: "font-medium text-sm", children: user.name ?? "Account" }),
113
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: user.email })
114
- ] }) }),
115
- /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
116
- links.map((link) => /* @__PURE__ */ jsx(DropdownMenuItem, { asChild: true, children: /* @__PURE__ */ jsxs("a", { href: link.href, className: "flex items-center gap-2", children: [
117
- link.icon,
118
- link.label
119
- ] }) }, link.href)),
120
- links.length > 0 && /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
121
- /* @__PURE__ */ jsx(
122
- DropdownMenuItem,
123
- {
124
- onClick: handleLogout,
125
- className: "text-[var(--surface-danger-text)] focus:text-[var(--surface-danger-text)]",
126
- children: "Sign out"
127
- }
128
- )
129
- ] })
130
- ] });
131
- }
132
- function AuthHeader({
133
- user,
134
- loading = false,
135
- variant = "sandbox",
136
- apiBaseUrl = "",
137
- menuLinks,
138
- className
139
- }) {
140
- if (loading) {
141
- return /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-2", className), children: [
142
- /* @__PURE__ */ jsx("div", { className: "h-8 w-8 animate-pulse rounded-full bg-muted" }),
143
- /* @__PURE__ */ jsx("div", { className: "hidden md:block", children: /* @__PURE__ */ jsx("div", { className: "h-4 w-20 animate-pulse rounded bg-muted" }) })
144
- ] });
145
- }
146
- if (!user) {
147
- return /* @__PURE__ */ jsx("div", { className: cn("flex items-center gap-2", className), children: /* @__PURE__ */ jsx(
148
- GitHubLoginButton,
149
- {
150
- authUrl: `${apiBaseUrl}/auth/github`,
151
- variant,
152
- size: "sm"
153
- }
154
- ) });
155
- }
156
- return /* @__PURE__ */ jsx(
157
- UserMenu,
158
- {
159
- user,
160
- variant,
161
- logoutUrl: `${apiBaseUrl}/auth/logout`,
162
- links: menuLinks
163
- }
164
- );
165
- }
166
-
167
- // src/auth/login-layout.tsx
168
- import { Terminal } from "lucide-react";
169
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
170
- function LoginLayout({
171
- title = "Welcome Back",
172
- subtitle = "Sign in to your workspace.",
173
- brandIcon,
174
- children,
175
- className
176
- }) {
177
- return /* @__PURE__ */ jsx2("div", { className: cn("relative flex min-h-screen items-center justify-center bg-background overflow-hidden antialiased font-sans flex-col", className), children: /* @__PURE__ */ jsxs2("div", { className: "z-10 w-full max-w-md px-6 animate-in flex flex-col items-center", children: [
178
- /* @__PURE__ */ jsxs2("div", { className: "mb-10 text-center flex flex-col items-center", children: [
179
- /* @__PURE__ */ jsx2("div", { className: "inline-flex h-14 w-14 mb-4 items-center justify-center rounded-lg bg-muted border border-border", children: brandIcon || /* @__PURE__ */ jsx2(Terminal, { className: "h-7 w-7 text-foreground" }) }),
180
- /* @__PURE__ */ jsx2("h1", { className: "text-2xl font-bold tracking-tight text-foreground font-display", children: title }),
181
- /* @__PURE__ */ jsx2("p", { className: "mt-2 text-sm text-muted-foreground", children: subtitle })
182
- ] }),
183
- /* @__PURE__ */ jsx2("div", { className: "w-full bg-card p-8 border border-border rounded-lg", children })
184
- ] }) });
185
- }
186
-
187
- export {
188
- GitHubLoginButton,
189
- UserMenu,
190
- AuthHeader,
191
- LoginLayout
192
- };