@speakeasy-api/moonshine 2.0.0-alpha.1 → 2.0.0-alpha.3
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/LICENSE +21 -0
- package/README.md +49 -23
- package/package.json +33 -50
- package/scripts/generate-utility-docs.js +324 -0
- package/src/assets/icons/external/github.svg +3 -0
- package/src/assets/icons/external/maven.svg +152 -0
- package/src/assets/icons/external/npm.svg +4 -0
- package/src/assets/icons/external/nuget.svg +5 -0
- package/src/assets/icons/external/packagist.svg +1 -0
- package/src/assets/icons/external/pypi.svg +182 -0
- package/src/assets/icons/external/rubygems.svg +14 -0
- package/src/assets/icons/external/terraform.svg +1 -0
- package/src/assets/icons/languages/csharp.svg +1 -0
- package/src/assets/icons/languages/go.svg +1 -0
- package/src/assets/icons/languages/java.svg +1 -0
- package/src/assets/icons/languages/json.svg +2 -0
- package/src/assets/icons/languages/php.svg +1 -0
- package/src/assets/icons/languages/postman.svg +3 -0
- package/src/assets/icons/languages/python.svg +1 -0
- package/src/assets/icons/languages/ruby.svg +1 -0
- package/src/assets/icons/languages/swift.svg +1 -0
- package/src/assets/icons/languages/terraform.svg +1 -0
- package/src/assets/icons/languages/typescript.svg +1 -0
- package/src/assets/icons/languages/unity.svg +1 -0
- package/src/base.css +12 -12
- package/src/components/AIChat/AIChatContainer.tsx +71 -0
- package/src/components/AIChat/AIChatMessage.tsx +135 -0
- package/src/components/AIChat/AIChatMessageComposer.tsx +175 -0
- package/src/components/AIChat/AIChatMessageList.tsx +34 -0
- package/src/components/AIChat/AIChatModelSelector.tsx +159 -0
- package/src/components/AIChat/componentsTypes.ts +36 -0
- package/src/components/AIChat/context.ts +15 -0
- package/src/components/AIChat/index.ts +12 -0
- package/src/components/AIChat/parts/AIChatMessageFilePart.tsx +129 -0
- package/src/components/AIChat/parts/AIChatMessageReasoningPart.tsx +23 -0
- package/src/components/AIChat/parts/AIChatMessageSourcePart.tsx +58 -0
- package/src/components/AIChat/parts/AIChatMessageTextPart.tsx +33 -0
- package/src/components/AIChat/parts/AIChatMessageToolInvocationPart.tsx +53 -0
- package/src/components/AIChat/parts/AIChatMessageToolPart.tsx +395 -0
- package/src/components/AIChat/parts/AIChatMessageToolResultPart.tsx +46 -0
- package/src/components/AIChat/toolCallApproval.ts +61 -0
- package/src/components/AIChat/types.ts +97 -0
- package/src/components/ActionBar/index.tsx +184 -0
- package/src/components/Alert/index.tsx +118 -0
- package/src/components/Alert/types.ts +12 -0
- package/src/components/AppLayout/context.tsx +31 -0
- package/src/components/AppLayout/index.tsx +550 -0
- package/src/components/AppLayout/provider.tsx +40 -0
- package/src/components/AppLayout/useAppLayoutKeys.ts +26 -0
- package/src/components/Badge/index.tsx +227 -0
- package/src/components/Button/index.tsx +531 -0
- package/src/components/Card/index.tsx +193 -0
- package/src/components/CodeEditorLayout/index.tsx +394 -0
- package/src/components/CodeEditorLayout/styles.module.css +8 -0
- package/src/components/CodeHighlight/Pre.tsx +63 -0
- package/src/components/CodePlayground/index.tsx +411 -0
- package/src/components/CodeSnippet/codeSnippet.css +97 -0
- package/src/components/CodeSnippet/index.tsx +224 -0
- package/src/components/Combobox/index.tsx +193 -0
- package/src/components/Command/index.tsx +152 -0
- package/src/components/Container/index.tsx +31 -0
- package/src/components/ContextDropdown/index.tsx +150 -0
- package/src/components/Dialog/index.tsx +123 -0
- package/src/components/DragNDrop/DragNDropArea.tsx +30 -0
- package/src/components/DragNDrop/DragOverlay.tsx +4 -0
- package/src/components/DragNDrop/Draggable.tsx +97 -0
- package/src/components/DragNDrop/Droppable.tsx +51 -0
- package/src/components/Dropdown/index.tsx +201 -0
- package/src/components/ExternalPill/index.tsx +58 -0
- package/src/components/Facepile/index.tsx +309 -0
- package/src/components/GradientCircle/gradientCircle.css +34 -0
- package/src/components/GradientCircle/index.tsx +143 -0
- package/src/components/Grid/index.tsx +150 -0
- package/src/components/Heading/index.tsx +54 -0
- package/src/components/HighlightedText/index.tsx +152 -0
- package/src/components/Icon/customIcons/createCustomLucideIcon.ts +25 -0
- package/src/components/Icon/customIcons/gems.ts +26 -0
- package/{dist/go-CiWl_aXI.mjs → src/components/Icon/customIcons/go.ts} +21 -19
- package/src/components/Icon/customIcons/index.ts +11 -0
- package/{dist/maven-DhmnGXoB.mjs → src/components/Icon/customIcons/maven.ts} +17 -15
- package/src/components/Icon/customIcons/npm.ts +19 -0
- package/{dist/nuget-5a2icRS2.mjs → src/components/Icon/customIcons/nuget.ts} +17 -15
- package/src/components/Icon/customIcons/packagist.ts +124 -0
- package/{dist/pypi-DsuRYjdK.mjs → src/components/Icon/customIcons/pypi.ts} +16 -14
- package/src/components/Icon/index.tsx +83 -0
- package/src/components/Icon/isIconName.ts +10 -0
- package/src/components/Icon/names.ts +14 -0
- package/src/components/IconButton/index.tsx +51 -0
- package/src/components/Input/index.tsx +98 -0
- package/src/components/KeyHint/index.tsx +118 -0
- package/src/components/LanguageIndicator/index.tsx +68 -0
- package/src/components/Link/index.tsx +153 -0
- package/src/components/LoggedInUserMenu/index.tsx +116 -0
- package/src/components/Logo/Animated.tsx +191 -0
- package/src/components/Logo/index.tsx +17 -0
- package/src/components/Logo/speakeasy-logo.riv +0 -0
- package/src/components/Logo/svgs/index.tsx +126 -0
- package/src/components/Modal/index.tsx +104 -0
- package/src/components/PageHeader/index.tsx +227 -0
- package/src/components/PageHeader/styles.module.css +27 -0
- package/src/components/Popover/index.tsx +35 -0
- package/src/components/PromptInput/index.tsx +372 -0
- package/src/components/PullRequestLink/index.tsx +64 -0
- package/src/components/ResizablePanel/index.tsx +119 -0
- package/src/components/Score/index.module.css +32 -0
- package/src/components/Score/index.tsx +268 -0
- package/src/components/ScrollArea/index.tsx +48 -0
- package/src/components/SegmentedButton/index.module.css +19 -0
- package/src/components/SegmentedButton/index.tsx +101 -0
- package/src/components/Select/index.tsx +159 -0
- package/src/components/Separator/index.tsx +23 -0
- package/src/components/Skeleton/index.tsx +61 -0
- package/src/components/Skeleton/skeleton.css +52 -0
- package/src/components/Stack/index.tsx +137 -0
- package/src/components/Subnav/index.tsx +315 -0
- package/src/components/Switch/index.tsx +29 -0
- package/src/components/Table/context/context.tsx +19 -0
- package/src/components/Table/context/tableProvider.tsx +39 -0
- package/src/components/Table/index.tsx +707 -0
- package/src/components/Table/styles.module.css +25 -0
- package/src/components/Tabs/index.tsx +87 -0
- package/src/components/TargetLanguageIcon/index.tsx +84 -0
- package/src/components/Text/index.tsx +59 -0
- package/src/components/ThemeSwitcher/index.tsx +118 -0
- package/src/components/Timeline/index.tsx +290 -0
- package/src/components/Tooltip/index.tsx +41 -0
- package/src/components/UserAvatar/index.tsx +87 -0
- package/src/components/UserAvatar/sizeMap.ts +12 -0
- package/src/components/Wizard/index.tsx +208 -0
- package/src/components/Wizard/types.ts +17 -0
- package/src/components/WorkspaceSelector/CreateOrg.tsx +95 -0
- package/src/components/WorkspaceSelector/CreateWorkspace.tsx +196 -0
- package/src/components/WorkspaceSelector/OrgList.tsx +115 -0
- package/src/components/WorkspaceSelector/OrgSelector.tsx +207 -0
- package/src/components/WorkspaceSelector/RecentWorkspaces.tsx +83 -0
- package/src/components/WorkspaceSelector/ScrollingList.tsx +84 -0
- package/src/components/WorkspaceSelector/SearchBox.tsx +40 -0
- package/src/components/WorkspaceSelector/WorkspaceItem.tsx +37 -0
- package/src/components/WorkspaceSelector/WorkspaceList.tsx +107 -0
- package/src/components/WorkspaceSelector/index.tsx +400 -0
- package/src/components/WorkspaceSelector/styles.css +74 -0
- package/src/components/__beta__/CLIWizard/index.tsx +357 -0
- package/src/components/__beta__/CLIWizard/terminal-command.tsx +108 -0
- package/src/components/__beta__/CLIWizard/terminal.tsx +83 -0
- package/src/components/__beta__/README.md +3 -0
- package/src/components/index.mdx +38 -0
- package/src/context/ConfigContext.tsx +43 -0
- package/src/context/ModalContext.tsx +118 -0
- package/src/context/theme.ts +1 -0
- package/src/hooks/useAppLayout.ts +10 -0
- package/src/hooks/useConfig.ts +10 -0
- package/src/hooks/useIsMounted.ts +13 -0
- package/src/hooks/useModal.tsx +10 -0
- package/src/hooks/useTailwindBreakpoint.ts +47 -0
- package/src/hooks/useTheme.ts +13 -0
- package/src/index.ts +234 -0
- package/src/lib/assert.ts +9 -0
- package/src/lib/codeUtils.ts +177 -0
- package/src/lib/debounce.ts +9 -0
- package/src/lib/responsiveMappers.ts +69 -0
- package/src/lib/responsiveUtils.ts +23 -0
- package/src/lib/storybookUtils.tsx +26 -0
- package/src/lib/typeUtils.ts +109 -0
- package/src/lib/utils.ts +85 -0
- package/src/styles/codeSyntax.css +59 -0
- package/src/styles/globals.css +51 -0
- package/src/types.ts +200 -0
- package/src/utilities.css +347 -6
- package/src/vite-env.d.ts +6 -0
- package/types/utilities.d.ts +43 -1
- package/dist/components/AIChat/AIChatContainer.d.ts +0 -25
- package/dist/components/AIChat/AIChatMessage.d.ts +0 -19
- package/dist/components/AIChat/AIChatMessageComposer.d.ts +0 -22
- package/dist/components/AIChat/AIChatMessageList.d.ts +0 -6
- package/dist/components/AIChat/AIChatModelSelector.d.ts +0 -14
- package/dist/components/AIChat/componentsTypes.d.ts +0 -11
- package/dist/components/AIChat/context.d.ts +0 -3
- package/dist/components/AIChat/index.d.ts +0 -12
- package/dist/components/AIChat/parts/AIChatMessageFilePart.d.ts +0 -7
- package/dist/components/AIChat/parts/AIChatMessageReasoningPart.d.ts +0 -5
- package/dist/components/AIChat/parts/AIChatMessageSourcePart.d.ts +0 -9
- package/dist/components/AIChat/parts/AIChatMessageTextPart.d.ts +0 -5
- package/dist/components/AIChat/parts/AIChatMessageToolInvocationPart.d.ts +0 -6
- package/dist/components/AIChat/parts/AIChatMessageToolPart.d.ts +0 -33
- package/dist/components/AIChat/parts/AIChatMessageToolResultPart.d.ts +0 -5
- package/dist/components/AIChat/toolCallApproval.d.ts +0 -15
- package/dist/components/AIChat/types.d.ts +0 -78
- package/dist/components/ActionBar/index.d.ts +0 -36
- package/dist/components/Alert/index.d.ts +0 -18
- package/dist/components/Alert/types.d.ts +0 -4
- package/dist/components/Badge/index.d.ts +0 -10
- package/dist/components/Button/index.d.ts +0 -11
- package/dist/components/Card/index.d.ts +0 -47
- package/dist/components/CodeEditorLayout/index.d.ts +0 -101
- package/dist/components/CodePlayground/index.d.ts +0 -108
- package/dist/components/CodePlayground/lineNumbers.d.ts +0 -2
- package/dist/components/CodePlayground/tokenTransitions.d.ts +0 -2
- package/dist/components/CodePlayground/wordWrap.d.ts +0 -2
- package/dist/components/CodeSnippet/index.d.ts +0 -50
- package/dist/components/Combobox/index.d.ts +0 -35
- package/dist/components/Command/index.d.ts +0 -80
- package/dist/components/Container/index.d.ts +0 -9
- package/dist/components/ContextDropdown/index.d.ts +0 -7
- package/dist/components/ContextDropdown/provider.d.ts +0 -22
- package/dist/components/ContextDropdown/useModal.d.ts +0 -11
- package/dist/components/Dialog/index.d.ts +0 -19
- package/dist/components/DragNDrop/DragNDropArea.d.ts +0 -8
- package/dist/components/DragNDrop/DragOverlay.d.ts +0 -1
- package/dist/components/DragNDrop/Draggable.d.ts +0 -29
- package/dist/components/DragNDrop/Droppable.d.ts +0 -28
- package/dist/components/Dropdown/index.d.ts +0 -27
- package/dist/components/ExternalPill/index.d.ts +0 -12
- package/dist/components/Facepile/index.d.ts +0 -16
- package/dist/components/GradientCircle/index.d.ts +0 -10
- package/dist/components/Grid/index.d.ts +0 -80
- package/dist/components/Heading/index.d.ts +0 -12
- package/dist/components/HighlightedText/index.d.ts +0 -19
- package/dist/components/Icon/customIcons/createCustomLucideIcon.d.ts +0 -3
- package/dist/components/Icon/customIcons/gems.d.ts +0 -2
- package/dist/components/Icon/customIcons/go.d.ts +0 -2
- package/dist/components/Icon/customIcons/index.d.ts +0 -10
- package/dist/components/Icon/customIcons/maven.d.ts +0 -2
- package/dist/components/Icon/customIcons/npm.d.ts +0 -2
- package/dist/components/Icon/customIcons/nuget.d.ts +0 -2
- package/dist/components/Icon/customIcons/packagist.d.ts +0 -2
- package/dist/components/Icon/customIcons/pypi.d.ts +0 -2
- package/dist/components/Icon/index.d.ts +0 -10
- package/dist/components/Icon/isIconName.d.ts +0 -2
- package/dist/components/Icon/names.d.ts +0 -6
- package/dist/components/Input/index.d.ts +0 -8
- package/dist/components/KeyHint/index.d.ts +0 -16
- package/dist/components/LanguageIndicator/index.d.ts +0 -7
- package/dist/components/Link/index.d.ts +0 -19
- package/dist/components/LoggedInUserMenu/index.d.ts +0 -17
- package/dist/components/Logo/Animated.d.ts +0 -7
- package/dist/components/Logo/index.d.ts +0 -7
- package/dist/components/Logo/svgs/index.d.ts +0 -6
- package/dist/components/Navbar/Slim.d.ts +0 -33
- package/dist/components/Navbar/index.d.ts +0 -15
- package/dist/components/PageHeader/index.d.ts +0 -45
- package/dist/components/Popover/index.d.ts +0 -8
- package/dist/components/PromptInput/index.d.ts +0 -55
- package/dist/components/PullRequestLink/index.d.ts +0 -10
- package/dist/components/ResizablePanel/index.d.ts +0 -26
- package/dist/components/Score/index.d.ts +0 -37
- package/dist/components/ScrollArea/index.d.ts +0 -5
- package/dist/components/Select/index.d.ts +0 -13
- package/dist/components/Separator/index.d.ts +0 -6
- package/dist/components/Skeleton/index.d.ts +0 -27
- package/dist/components/Stack/index.d.ts +0 -33
- package/dist/components/Subnav/index.d.ts +0 -12
- package/dist/components/Switch/index.d.ts +0 -4
- package/dist/components/Table/context/context.d.ts +0 -8
- package/dist/components/Table/context/tableProvider.d.ts +0 -6
- package/dist/components/Table/index.d.ts +0 -94
- package/dist/components/Tabs/index.d.ts +0 -21
- package/dist/components/TargetLanguageIcon/index.d.ts +0 -7
- package/dist/components/Text/index.d.ts +0 -19
- package/dist/components/ThemeSwitcher/index.d.ts +0 -5
- package/dist/components/Tooltip/index.d.ts +0 -8
- package/dist/components/UserAvatar/index.d.ts +0 -9
- package/dist/components/UserAvatar/sizeMap.d.ts +0 -3
- package/dist/components/Wizard/index.d.ts +0 -19
- package/dist/components/Wizard/types.d.ts +0 -15
- package/dist/components/WorkspaceSelector/CreateOrg.d.ts +0 -6
- package/dist/components/WorkspaceSelector/CreateWorkspace.d.ts +0 -17
- package/dist/components/WorkspaceSelector/OrgList.d.ts +0 -11
- package/dist/components/WorkspaceSelector/OrgSelector.d.ts +0 -13
- package/dist/components/WorkspaceSelector/RecentWorkspaces.d.ts +0 -11
- package/dist/components/WorkspaceSelector/ScrollingList.d.ts +0 -21
- package/dist/components/WorkspaceSelector/SearchBox.d.ts +0 -9
- package/dist/components/WorkspaceSelector/WorkspaceItem.d.ts +0 -9
- package/dist/components/WorkspaceSelector/WorkspaceList.d.ts +0 -10
- package/dist/components/WorkspaceSelector/index.d.ts +0 -34
- package/dist/components/__beta__/CLIWizard/index.d.ts +0 -21
- package/dist/components/__beta__/CLIWizard/terminal-command.d.ts +0 -19
- package/dist/components/__beta__/CLIWizard/terminal.d.ts +0 -26
- package/dist/context/ConfigContext.d.ts +0 -18
- package/dist/context/theme.d.ts +0 -1
- package/dist/createCustomLucideIcon-YlrRX5h9.mjs +0 -19
- package/dist/createCustomLucideIcon-YlrRX5h9.mjs.map +0 -1
- package/dist/gems-BcsO9cXq.mjs +0 -24
- package/dist/gems-BcsO9cXq.mjs.map +0 -1
- package/dist/github-kgjMtfE7.mjs +0 -11
- package/dist/github-kgjMtfE7.mjs.map +0 -1
- package/dist/go-CiWl_aXI.mjs.map +0 -1
- package/dist/hooks/useConfig.d.ts +0 -2
- package/dist/hooks/useIsMounted.d.ts +0 -1
- package/dist/hooks/useTailwindBreakpoint.d.ts +0 -3
- package/dist/hooks/useTheme.d.ts +0 -6
- package/dist/index-COXZ9O-g.mjs +0 -50882
- package/dist/index-COXZ9O-g.mjs.map +0 -1
- package/dist/index.d.ts +0 -73
- package/dist/lib/assert.d.ts +0 -2
- package/dist/lib/codeUtils.d.ts +0 -35
- package/dist/lib/debounce.d.ts +0 -1
- package/dist/lib/responsiveMappers.d.ts +0 -10
- package/dist/lib/responsiveUtils.d.ts +0 -3
- package/dist/lib/storybookUtils.d.ts +0 -5
- package/dist/lib/typeUtils.d.ts +0 -24
- package/dist/lib/utils.d.ts +0 -23
- package/dist/lucide-icons-BDw0imyx.mjs +0 -28054
- package/dist/lucide-icons-BDw0imyx.mjs.map +0 -1
- package/dist/maven-DhmnGXoB.mjs.map +0 -1
- package/dist/maven-W_nkSDNW.mjs +0 -107
- package/dist/maven-W_nkSDNW.mjs.map +0 -1
- package/dist/moonshine.es.js +0 -114
- package/dist/moonshine.es.js.map +0 -1
- package/dist/npm-BWTcVvFH.mjs +0 -11
- package/dist/npm-BWTcVvFH.mjs.map +0 -1
- package/dist/npm-CvQ4GKW4.mjs +0 -17
- package/dist/npm-CvQ4GKW4.mjs.map +0 -1
- package/dist/nuget-5a2icRS2.mjs.map +0 -1
- package/dist/nuget-CV5HU1JR.mjs +0 -11
- package/dist/nuget-CV5HU1JR.mjs.map +0 -1
- package/dist/packagist-CET6q9hi.mjs +0 -118
- package/dist/packagist-CET6q9hi.mjs.map +0 -1
- package/dist/packagist-D01fn9N_.mjs +0 -11
- package/dist/packagist-D01fn9N_.mjs.map +0 -1
- package/dist/pypi-DLh6kIJe.mjs +0 -11
- package/dist/pypi-DLh6kIJe.mjs.map +0 -1
- package/dist/pypi-DsuRYjdK.mjs.map +0 -1
- package/dist/rubygems-DeiNjcDV.mjs +0 -11
- package/dist/rubygems-DeiNjcDV.mjs.map +0 -1
- package/dist/speakeasy-logo-ByBTXLWb.mjs +0 -5
- package/dist/speakeasy-logo-ByBTXLWb.mjs.map +0 -1
- package/dist/style.css +0 -1
- package/dist/terraform-C4aktQ0o.mjs +0 -11
- package/dist/terraform-C4aktQ0o.mjs.map +0 -1
- package/dist/types.d.ts +0 -80
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { Command, CommandEmpty } from '../Command'
|
|
5
|
+
import { CreateWorkspace, CreateResult } from './CreateWorkspace'
|
|
6
|
+
import { OrgList } from './OrgList'
|
|
7
|
+
import { WorkspaceList } from './WorkspaceList'
|
|
8
|
+
import './styles.css'
|
|
9
|
+
import { RecentWorkspaces } from './RecentWorkspaces'
|
|
10
|
+
import { Text } from '../Text'
|
|
11
|
+
import { Logo } from '../Logo'
|
|
12
|
+
import { Stack } from '../Stack'
|
|
13
|
+
import { CreateOrg } from './CreateOrg'
|
|
14
|
+
import { Heading } from '../Heading'
|
|
15
|
+
import { GlobalWorkspaceSelectorProps } from '../../types'
|
|
16
|
+
|
|
17
|
+
export interface Org {
|
|
18
|
+
id: string
|
|
19
|
+
label: string
|
|
20
|
+
slug: string
|
|
21
|
+
workspaces: Workspace[]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Workspace {
|
|
25
|
+
id: string
|
|
26
|
+
slug: string
|
|
27
|
+
label: string
|
|
28
|
+
active: boolean
|
|
29
|
+
createdAt: Date
|
|
30
|
+
updatedAt: Date
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface WorkspaceSelectorProps extends GlobalWorkspaceSelectorProps {
|
|
34
|
+
onCreateOrg: (newOrgName: string) => Promise<Org>
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Returns a promise that resolves to true if the workspace was created, false otherwise.
|
|
38
|
+
*/
|
|
39
|
+
onCreate: (org: Org, newWorkspaceName: string) => Promise<CreateResult>
|
|
40
|
+
placeholder?: string
|
|
41
|
+
emptyText?: string
|
|
42
|
+
recents?: Org[]
|
|
43
|
+
height?: string | number
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* If true, creating a new workspace will trigger the onSelect callback.
|
|
47
|
+
*/
|
|
48
|
+
createTriggersSelection?: boolean
|
|
49
|
+
|
|
50
|
+
showCreateWorkspaceView?: boolean
|
|
51
|
+
|
|
52
|
+
defaultSelectedOrg?: Org
|
|
53
|
+
|
|
54
|
+
filterOrgFunc: (org: Org, search: string) => boolean
|
|
55
|
+
filterWorkspaceFunc: (workspace: Workspace, search: string) => boolean
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const useViewTransition = () => {
|
|
59
|
+
const [isTransitioning, setIsTransitioning] = React.useState(false)
|
|
60
|
+
|
|
61
|
+
const startTransition = React.useCallback(
|
|
62
|
+
(callback: () => void, finished?: () => void) => {
|
|
63
|
+
if ('startViewTransition' in document) {
|
|
64
|
+
setIsTransitioning(true)
|
|
65
|
+
const transition = document.startViewTransition(callback)
|
|
66
|
+
transition.finished.then(() => {
|
|
67
|
+
setIsTransitioning(false)
|
|
68
|
+
finished?.()
|
|
69
|
+
})
|
|
70
|
+
} else {
|
|
71
|
+
callback()
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
[]
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
isTransitioning,
|
|
79
|
+
startTransition,
|
|
80
|
+
setIsTransitioning,
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function WorkspaceSelector({
|
|
85
|
+
orgs,
|
|
86
|
+
onSelect,
|
|
87
|
+
onCreate,
|
|
88
|
+
emptyText = 'No workspaces found.',
|
|
89
|
+
recents = [],
|
|
90
|
+
height = '500px',
|
|
91
|
+
onCreateOrg,
|
|
92
|
+
createTriggersSelection = false,
|
|
93
|
+
showCreateWorkspaceView = false,
|
|
94
|
+
defaultSelectedOrg,
|
|
95
|
+
filterOrgFunc,
|
|
96
|
+
filterWorkspaceFunc,
|
|
97
|
+
}: WorkspaceSelectorProps) {
|
|
98
|
+
const [selectedWorkspace, setSelectedWorkspace] =
|
|
99
|
+
React.useState<Workspace | null>(null)
|
|
100
|
+
const [selectedOrg, setSelectedOrg] = React.useState<Org | null>(
|
|
101
|
+
defaultSelectedOrg ?? orgs[0]
|
|
102
|
+
)
|
|
103
|
+
const [createWorkspaceViewOpen, setCreateWorkspaceViewOpen] = React.useState(
|
|
104
|
+
showCreateWorkspaceView ?? false
|
|
105
|
+
)
|
|
106
|
+
const [createOrgViewOpen, setCreateOrgViewOpen] = React.useState(
|
|
107
|
+
orgs.length === 0
|
|
108
|
+
)
|
|
109
|
+
const [newWorkspaceName, setNewWorkspaceName] = React.useState('')
|
|
110
|
+
const containerRef = React.useRef<HTMLDivElement>(null)
|
|
111
|
+
const [showRecents, setShowRecents] = React.useState(recents.length > 0)
|
|
112
|
+
const { isTransitioning, startTransition, setIsTransitioning } =
|
|
113
|
+
useViewTransition()
|
|
114
|
+
const [previousView, setPreviousView] = React.useState<
|
|
115
|
+
'workspace' | 'org' | null
|
|
116
|
+
>(null)
|
|
117
|
+
|
|
118
|
+
React.useLayoutEffect(() => {
|
|
119
|
+
if (createOrgViewOpen) {
|
|
120
|
+
setPreviousView('org')
|
|
121
|
+
setIsTransitioning(true)
|
|
122
|
+
}
|
|
123
|
+
}, [createOrgViewOpen])
|
|
124
|
+
|
|
125
|
+
const handleSelect = React.useCallback(
|
|
126
|
+
(org: Org, workspace: Workspace) => {
|
|
127
|
+
onSelect(org, workspace)
|
|
128
|
+
setSelectedOrg(org)
|
|
129
|
+
setSelectedWorkspace(workspace)
|
|
130
|
+
},
|
|
131
|
+
[onSelect]
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
const handleSelectOrg = React.useCallback((org: Org) => {
|
|
135
|
+
setSelectedOrg(org)
|
|
136
|
+
setShowRecents(false)
|
|
137
|
+
}, [])
|
|
138
|
+
|
|
139
|
+
const handleCreateNewWorkspace = React.useCallback(
|
|
140
|
+
async (org: Org, newWorkspaceName: string): Promise<CreateResult> => {
|
|
141
|
+
if (newWorkspaceName) {
|
|
142
|
+
const result = await onCreate(org, newWorkspaceName)
|
|
143
|
+
|
|
144
|
+
if (!result.success) {
|
|
145
|
+
return result
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const workspace: Workspace = {
|
|
149
|
+
id: newWorkspaceName,
|
|
150
|
+
label: newWorkspaceName,
|
|
151
|
+
slug: newWorkspaceName,
|
|
152
|
+
active: true,
|
|
153
|
+
createdAt: new Date(),
|
|
154
|
+
updatedAt: new Date(),
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (createTriggersSelection) {
|
|
158
|
+
onSelect(org, workspace)
|
|
159
|
+
return { success: true }
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
startTransition(() => {
|
|
163
|
+
setSelectedOrg((prev) =>
|
|
164
|
+
prev
|
|
165
|
+
? {
|
|
166
|
+
...prev,
|
|
167
|
+
workspaces: [...prev.workspaces, workspace],
|
|
168
|
+
}
|
|
169
|
+
: null
|
|
170
|
+
)
|
|
171
|
+
setNewWorkspaceName('')
|
|
172
|
+
setCreateWorkspaceViewOpen(false)
|
|
173
|
+
setSelectedWorkspace(workspace)
|
|
174
|
+
setPreviousView(null)
|
|
175
|
+
setShowRecents(false)
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
return { success: true }
|
|
179
|
+
}
|
|
180
|
+
return { success: false, error: 'No workspace name provided' }
|
|
181
|
+
},
|
|
182
|
+
[onCreate, createTriggersSelection, onSelect, startTransition]
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
const handleCreateOrg = React.useCallback(
|
|
186
|
+
async (newOrgName: string): Promise<Org> => {
|
|
187
|
+
const result = await onCreateOrg(newOrgName)
|
|
188
|
+
|
|
189
|
+
function updateState() {
|
|
190
|
+
setSelectedOrg(result)
|
|
191
|
+
setCreateOrgViewOpen(false)
|
|
192
|
+
setCreateWorkspaceViewOpen(true)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (document.startViewTransition) {
|
|
196
|
+
document.startViewTransition(() => updateState())
|
|
197
|
+
} else {
|
|
198
|
+
updateState()
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return result
|
|
202
|
+
},
|
|
203
|
+
[onCreateOrg]
|
|
204
|
+
)
|
|
205
|
+
const handleCreateWorkspaceViewOpen = React.useCallback(() => {
|
|
206
|
+
startTransition(() => {
|
|
207
|
+
if (containerRef.current && height) {
|
|
208
|
+
containerRef.current.style.height = `${height}px`
|
|
209
|
+
}
|
|
210
|
+
setCreateWorkspaceViewOpen(true)
|
|
211
|
+
})
|
|
212
|
+
}, [startTransition])
|
|
213
|
+
|
|
214
|
+
const backToWorkspaceSelector = React.useCallback(() => {
|
|
215
|
+
const root = document.documentElement
|
|
216
|
+
root.classList.add('view-transition-reverse')
|
|
217
|
+
startTransition(
|
|
218
|
+
() => {
|
|
219
|
+
setCreateWorkspaceViewOpen(false)
|
|
220
|
+
setCreateOrgViewOpen(false)
|
|
221
|
+
},
|
|
222
|
+
() => {
|
|
223
|
+
root.classList.remove('view-transition-reverse')
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
}, [startTransition])
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<div
|
|
230
|
+
ref={containerRef}
|
|
231
|
+
style={{ height }}
|
|
232
|
+
className="workspace-selector border-neutral-softest flex w-full flex-grow overflow-hidden rounded-md border"
|
|
233
|
+
>
|
|
234
|
+
{createOrgViewOpen ? (
|
|
235
|
+
<div
|
|
236
|
+
style={{ viewTransitionName: isTransitioning ? 'create-dialog' : '' }}
|
|
237
|
+
className="h-full w-full"
|
|
238
|
+
>
|
|
239
|
+
<CreateOrg onSubmit={handleCreateOrg} />
|
|
240
|
+
</div>
|
|
241
|
+
) : createWorkspaceViewOpen ? (
|
|
242
|
+
<div
|
|
243
|
+
style={{
|
|
244
|
+
viewTransitionName: isTransitioning ? 'create-dialog' : '',
|
|
245
|
+
}}
|
|
246
|
+
className="h-full w-full"
|
|
247
|
+
>
|
|
248
|
+
<CreateWorkspace
|
|
249
|
+
backButtonEnabled={orgs.length > 0}
|
|
250
|
+
open={createWorkspaceViewOpen}
|
|
251
|
+
selectedOrg={selectedOrg!}
|
|
252
|
+
onBack={previousView === null ? backToWorkspaceSelector : undefined}
|
|
253
|
+
allOrgs={orgs}
|
|
254
|
+
onSubmit={(org, name) => handleCreateNewWorkspace(org, name)}
|
|
255
|
+
newWorkspaceName={newWorkspaceName}
|
|
256
|
+
setNewWorkspaceName={setNewWorkspaceName}
|
|
257
|
+
/>
|
|
258
|
+
</div>
|
|
259
|
+
) : (
|
|
260
|
+
<div
|
|
261
|
+
style={{
|
|
262
|
+
viewTransitionName: isTransitioning ? 'workspace-content' : '',
|
|
263
|
+
}}
|
|
264
|
+
className="flex w-full"
|
|
265
|
+
>
|
|
266
|
+
<WorkspaceViewContents
|
|
267
|
+
orgs={orgs}
|
|
268
|
+
selectedOrg={selectedOrg}
|
|
269
|
+
selectedWorkspace={selectedWorkspace}
|
|
270
|
+
handleSelect={handleSelect}
|
|
271
|
+
showRecents={showRecents}
|
|
272
|
+
setShowRecents={setShowRecents}
|
|
273
|
+
emptyText={emptyText}
|
|
274
|
+
height={height}
|
|
275
|
+
recents={recents}
|
|
276
|
+
handleCreateWorkspaceViewOpen={handleCreateWorkspaceViewOpen}
|
|
277
|
+
handleSelectOrg={handleSelectOrg}
|
|
278
|
+
filterOrgFunc={filterOrgFunc}
|
|
279
|
+
filterWorkspaceFunc={filterWorkspaceFunc}
|
|
280
|
+
/>
|
|
281
|
+
</div>
|
|
282
|
+
)}
|
|
283
|
+
</div>
|
|
284
|
+
)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
interface WorkspaceViewContentsProps {
|
|
288
|
+
orgs: Org[]
|
|
289
|
+
selectedOrg: Org | null
|
|
290
|
+
selectedWorkspace: Workspace | null
|
|
291
|
+
handleSelect: (org: Org, workspace: Workspace, clearSearch: boolean) => void
|
|
292
|
+
showRecents: boolean
|
|
293
|
+
setShowRecents: (show: boolean) => void
|
|
294
|
+
emptyText: string
|
|
295
|
+
height: string | number
|
|
296
|
+
recents: Org[]
|
|
297
|
+
handleCreateWorkspaceViewOpen: () => void
|
|
298
|
+
handleSelectOrg: (org: Org) => void
|
|
299
|
+
filterOrgFunc: (org: Org, search: string) => boolean
|
|
300
|
+
filterWorkspaceFunc: (workspace: Workspace, search: string) => boolean
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function WorkspaceViewContents({
|
|
304
|
+
orgs,
|
|
305
|
+
selectedOrg,
|
|
306
|
+
selectedWorkspace,
|
|
307
|
+
handleSelect,
|
|
308
|
+
showRecents,
|
|
309
|
+
setShowRecents,
|
|
310
|
+
emptyText,
|
|
311
|
+
height,
|
|
312
|
+
recents,
|
|
313
|
+
handleCreateWorkspaceViewOpen,
|
|
314
|
+
handleSelectOrg,
|
|
315
|
+
filterOrgFunc,
|
|
316
|
+
filterWorkspaceFunc,
|
|
317
|
+
}: WorkspaceViewContentsProps) {
|
|
318
|
+
const showRecentsView = React.useMemo(
|
|
319
|
+
() => recents.length > 0 && showRecents,
|
|
320
|
+
[recents, showRecents]
|
|
321
|
+
)
|
|
322
|
+
return (
|
|
323
|
+
<>
|
|
324
|
+
<div className="bg-surface-primary border-neutral-softest flex h-full flex-1/3 flex-col items-center justify-center border-r">
|
|
325
|
+
<div className="flex h-full max-w-80 flex-col items-center justify-center px-8 text-center">
|
|
326
|
+
<Stack align="center" gap={4}>
|
|
327
|
+
<div className="flex h-16 w-16 items-center justify-center">
|
|
328
|
+
<Logo variant="icon" className="size-12" />
|
|
329
|
+
</div>
|
|
330
|
+
<Stack align="center" gap={2}>
|
|
331
|
+
<Heading variant="xl" className="whitespace-nowrap">
|
|
332
|
+
Select your workspace
|
|
333
|
+
</Heading>
|
|
334
|
+
<Text muted>
|
|
335
|
+
Select or create the workspace you want to use for this project.
|
|
336
|
+
</Text>
|
|
337
|
+
</Stack>
|
|
338
|
+
</Stack>
|
|
339
|
+
</div>
|
|
340
|
+
</div>
|
|
341
|
+
|
|
342
|
+
<div className="w-full flex-2/3">
|
|
343
|
+
<Command shouldFilter={false}>
|
|
344
|
+
{showRecentsView ? (
|
|
345
|
+
<div className="flex w-full flex-grow flex-row">
|
|
346
|
+
<OrgList
|
|
347
|
+
orgs={orgs}
|
|
348
|
+
selectedOrg={selectedOrg}
|
|
349
|
+
setSelectedOrg={handleSelectOrg}
|
|
350
|
+
onSelectRecent={() => setShowRecents(true)}
|
|
351
|
+
showRecents={showRecents}
|
|
352
|
+
enableRecents={recents.length > 0}
|
|
353
|
+
filterOrgFunc={(org, search) => filterOrgFunc(org, search)}
|
|
354
|
+
/>
|
|
355
|
+
<RecentWorkspaces
|
|
356
|
+
onSelect={(org, workspace) =>
|
|
357
|
+
handleSelect(org, workspace, false)
|
|
358
|
+
}
|
|
359
|
+
handleCreateViewOpen={handleCreateWorkspaceViewOpen}
|
|
360
|
+
orgsWithFilteredWorkspaces={recents}
|
|
361
|
+
selectedOrg={selectedOrg}
|
|
362
|
+
selectedWorkspace={selectedWorkspace}
|
|
363
|
+
/>
|
|
364
|
+
</div>
|
|
365
|
+
) : orgs.length > 0 ? (
|
|
366
|
+
<div className="flex h-full flex-row">
|
|
367
|
+
<OrgList
|
|
368
|
+
orgs={orgs}
|
|
369
|
+
selectedOrg={selectedOrg}
|
|
370
|
+
setSelectedOrg={handleSelectOrg}
|
|
371
|
+
onSelectRecent={() => setShowRecents(true)}
|
|
372
|
+
showRecents={showRecents}
|
|
373
|
+
enableRecents={recents.length > 0}
|
|
374
|
+
filterOrgFunc={(org, search) => filterOrgFunc(org, search)}
|
|
375
|
+
/>
|
|
376
|
+
<WorkspaceList
|
|
377
|
+
selectedOrg={selectedOrg!}
|
|
378
|
+
handleCreateViewOpen={handleCreateWorkspaceViewOpen}
|
|
379
|
+
handleSelect={(org, workspace) =>
|
|
380
|
+
handleSelect(org, workspace, false)
|
|
381
|
+
}
|
|
382
|
+
selectedWorkspace={selectedWorkspace}
|
|
383
|
+
filterWorkspaceFunc={(workspace, search) =>
|
|
384
|
+
filterWorkspaceFunc(workspace, search)
|
|
385
|
+
}
|
|
386
|
+
/>
|
|
387
|
+
</div>
|
|
388
|
+
) : (
|
|
389
|
+
<CommandEmpty
|
|
390
|
+
style={{ height }}
|
|
391
|
+
className="text-md text-muted-foreground p-6"
|
|
392
|
+
>
|
|
393
|
+
{emptyText}
|
|
394
|
+
</CommandEmpty>
|
|
395
|
+
)}
|
|
396
|
+
</Command>
|
|
397
|
+
</div>
|
|
398
|
+
</>
|
|
399
|
+
)
|
|
400
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
@reference '../../global.css';
|
|
2
|
+
|
|
3
|
+
::view-transition-group(workspace-content),
|
|
4
|
+
::view-transition-group(create-dialog) {
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
::view-transition-old(workspace-content) {
|
|
9
|
+
animation: 300ms var(--ease-in-out-quad) slide-fade-out;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
::view-transition-new(workspace-content) {
|
|
13
|
+
animation: 300ms var(--ease-in-out-quad) slide-fade-in;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
::view-transition-old(create-dialog) {
|
|
17
|
+
animation: 300ms var(--ease-in-out-quad) slide-fade-out;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
::view-transition-new(create-dialog) {
|
|
21
|
+
animation: 300ms ease-out slide-fade-in;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.workspace-selector div[cmdk-list-sizer] {
|
|
25
|
+
display: flex;
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.create-dialog-select-trigger > span {
|
|
31
|
+
text-overflow: ellipsis;
|
|
32
|
+
white-space: pre-wrap;
|
|
33
|
+
@apply max-w-32;
|
|
34
|
+
@apply min-w-16;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.workspace-selector div[cmdk-input-wrapper] {
|
|
38
|
+
border-bottom: none !important;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.workspace-selector div[cmdk-group-heading] {
|
|
42
|
+
font-size: 0.95rem !important;
|
|
43
|
+
margin: 0.5rem 0 !important;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@keyframes slide-fade-in-reverse {
|
|
47
|
+
from {
|
|
48
|
+
opacity: 0;
|
|
49
|
+
transform: translateX(-100%);
|
|
50
|
+
}
|
|
51
|
+
to {
|
|
52
|
+
opacity: 1;
|
|
53
|
+
transform: translateX(0);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@keyframes slide-fade-out-reverse {
|
|
58
|
+
from {
|
|
59
|
+
opacity: 1;
|
|
60
|
+
transform: translateX(0);
|
|
61
|
+
}
|
|
62
|
+
to {
|
|
63
|
+
opacity: 0;
|
|
64
|
+
transform: translateX(100%);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.view-transition-reverse::view-transition-old(create-dialog) {
|
|
69
|
+
animation: 300ms var(--ease-in-out-quad) slide-fade-out-reverse;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.view-transition-reverse::view-transition-new(create-dialog) {
|
|
73
|
+
animation: 300ms var(--ease-in-out-quad) slide-fade-in-reverse;
|
|
74
|
+
}
|