@speakeasy-api/moonshine 1.33.4 → 2.0.0-alpha.2
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/README.md +26 -10
- package/package.json +12 -23
- 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/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-DsW1bFpz.mjs → src/components/Icon/customIcons/go.ts} +21 -19
- package/src/components/Icon/customIcons/index.ts +11 -0
- package/{dist/maven-Dub5liK1.mjs → src/components/Icon/customIcons/maven.ts} +17 -15
- package/src/components/Icon/customIcons/npm.ts +19 -0
- package/{dist/nuget-D86y5HDl.mjs → src/components/Icon/customIcons/nuget.ts} +17 -15
- package/src/components/Icon/customIcons/packagist.ts +124 -0
- package/{dist/pypi-2SUX-2OR.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/vite-env.d.ts +6 -0
- package/types/utilities.d.ts +1 -1
- package/dist/components/AIChat/AIChatContainer.d.ts +0 -26
- 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 -79
- 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/AppLayout/context.d.ts +0 -16
- package/dist/components/AppLayout/index.d.ts +0 -131
- package/dist/components/AppLayout/provider.d.ts +0 -8
- package/dist/components/AppLayout/useAppLayoutKeys.d.ts +0 -1
- package/dist/components/Badge/index.d.ts +0 -21
- package/dist/components/Button/index.d.ts +0 -22
- package/dist/components/Card/index.d.ts +0 -47
- package/dist/components/CodeEditorLayout/index.d.ts +0 -101
- package/dist/components/CodeHighlight/Pre.d.ts +0 -8
- package/dist/components/CodePlayground/index.d.ts +0 -102
- package/dist/components/CodeSnippet/index.d.ts +0 -49
- 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/Dialog/index.d.ts +0 -21
- 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/IconButton/index.d.ts +0 -14
- 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 -15
- 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/Modal/index.d.ts +0 -8
- 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/SegmentedButton/index.d.ts +0 -23
- 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 -6
- package/dist/components/Timeline/index.d.ts +0 -49
- package/dist/components/Tooltip/index.d.ts +0 -9
- 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 -12
- 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 -11
- package/dist/components/WorkspaceSelector/index.d.ts +0 -36
- package/dist/components/__beta__/CLIWizard/index.d.ts +0 -19
- 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/ModalContext.d.ts +0 -22
- package/dist/context/theme.d.ts +0 -1
- package/dist/createCustomLucideIcon-CatlpFc0.mjs +0 -19
- package/dist/createCustomLucideIcon-CatlpFc0.mjs.map +0 -1
- package/dist/gems-DQ7pOLLr.mjs +0 -24
- package/dist/gems-DQ7pOLLr.mjs.map +0 -1
- package/dist/github-kgjMtfE7.mjs +0 -11
- package/dist/github-kgjMtfE7.mjs.map +0 -1
- package/dist/go-DsW1bFpz.mjs.map +0 -1
- package/dist/hooks/useAppLayout.d.ts +0 -1
- package/dist/hooks/useConfig.d.ts +0 -2
- package/dist/hooks/useIsMounted.d.ts +0 -1
- package/dist/hooks/useModal.d.ts +0 -11
- package/dist/hooks/useTailwindBreakpoint.d.ts +0 -3
- package/dist/hooks/useTheme.d.ts +0 -6
- package/dist/index-C9bJtuJ5.mjs +0 -16347
- package/dist/index-C9bJtuJ5.mjs.map +0 -1
- package/dist/index.d.ts +0 -80
- package/dist/lib/assert.d.ts +0 -2
- package/dist/lib/codeUtils.d.ts +0 -36
- 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 -24
- package/dist/maven-Dub5liK1.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 -125
- 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-BYcG5_q9.mjs +0 -17
- package/dist/npm-BYcG5_q9.mjs.map +0 -1
- package/dist/nuget-CV5HU1JR.mjs +0 -11
- package/dist/nuget-CV5HU1JR.mjs.map +0 -1
- package/dist/nuget-D86y5HDl.mjs.map +0 -1
- package/dist/packagist-BFSSrw4p.mjs +0 -118
- package/dist/packagist-BFSSrw4p.mjs.map +0 -1
- package/dist/packagist-D01fn9N_.mjs +0 -11
- package/dist/packagist-D01fn9N_.mjs.map +0 -1
- package/dist/pypi-2SUX-2OR.mjs.map +0 -1
- package/dist/pypi-DLh6kIJe.mjs +0 -11
- package/dist/pypi-DLh6kIJe.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 -85
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { Icon } from '../Icon/index'
|
|
2
|
+
import { IconName } from '../Icon/names'
|
|
3
|
+
import {
|
|
4
|
+
Tooltip,
|
|
5
|
+
TooltipContent,
|
|
6
|
+
TooltipProvider,
|
|
7
|
+
TooltipTrigger,
|
|
8
|
+
} from '../Tooltip/index'
|
|
9
|
+
import { cn } from '../../lib/utils'
|
|
10
|
+
import {
|
|
11
|
+
useDraggable,
|
|
12
|
+
DraggableAttributes,
|
|
13
|
+
useDndMonitor,
|
|
14
|
+
Translate,
|
|
15
|
+
DragEndEvent,
|
|
16
|
+
DragStartEvent,
|
|
17
|
+
Modifier,
|
|
18
|
+
} from '@dnd-kit/core'
|
|
19
|
+
import { SyntheticListenerMap } from '@dnd-kit/core/dist/hooks/utilities'
|
|
20
|
+
import { useState } from 'react'
|
|
21
|
+
import { DragNDropArea } from '../DragNDrop/DragNDropArea'
|
|
22
|
+
|
|
23
|
+
interface ActionBarProps {
|
|
24
|
+
children: React.ReactNode
|
|
25
|
+
id: string
|
|
26
|
+
initialPosition: Translate
|
|
27
|
+
onChangePosition?: (position: Translate) => void
|
|
28
|
+
onDragStart?: (event: DragStartEvent) => void
|
|
29
|
+
onDragEnd?: (event: DragEndEvent) => void
|
|
30
|
+
draggable?: boolean
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* dnd-kit modifiers (https://docs.dndkit.com/api-documentation/modifiers)
|
|
34
|
+
*/
|
|
35
|
+
modifiers?: Modifier[]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const ActionBarInternal = ({
|
|
39
|
+
children,
|
|
40
|
+
modifiers,
|
|
41
|
+
...props
|
|
42
|
+
}: ActionBarProps) => {
|
|
43
|
+
return (
|
|
44
|
+
<DragNDropArea modifiers={modifiers}>
|
|
45
|
+
<Root {...props}>{children}</Root>
|
|
46
|
+
</DragNDropArea>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
ActionBarInternal.displayName = 'ActionBar'
|
|
51
|
+
|
|
52
|
+
const Root = ({
|
|
53
|
+
children,
|
|
54
|
+
id,
|
|
55
|
+
initialPosition = { x: 0, y: 0 },
|
|
56
|
+
onChangePosition,
|
|
57
|
+
draggable = true,
|
|
58
|
+
onDragStart,
|
|
59
|
+
onDragEnd,
|
|
60
|
+
}: ActionBarProps) => {
|
|
61
|
+
const { setNodeRef, attributes, listeners, transform } = useDraggable({
|
|
62
|
+
id,
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const [state, setState] = useState<Translate>(initialPosition)
|
|
66
|
+
|
|
67
|
+
useDndMonitor({
|
|
68
|
+
onDragEnd: (event: DragEndEvent) => {
|
|
69
|
+
setState((prev) => ({
|
|
70
|
+
x: prev.x + event.delta.x,
|
|
71
|
+
y: prev.y + event.delta.y,
|
|
72
|
+
}))
|
|
73
|
+
onChangePosition?.({
|
|
74
|
+
x: state.x + event.delta.x,
|
|
75
|
+
y: state.y + event.delta.y,
|
|
76
|
+
})
|
|
77
|
+
onDragEnd?.(event)
|
|
78
|
+
},
|
|
79
|
+
onDragStart: (event: DragStartEvent) => {
|
|
80
|
+
onDragStart?.(event)
|
|
81
|
+
},
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const transformStyle: React.CSSProperties = transform
|
|
85
|
+
? {
|
|
86
|
+
transform: `translate3d(${transform.x}px, ${transform.y}px, 0)`,
|
|
87
|
+
}
|
|
88
|
+
: {}
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div
|
|
92
|
+
ref={setNodeRef}
|
|
93
|
+
style={{
|
|
94
|
+
top: state.y,
|
|
95
|
+
left: state.x,
|
|
96
|
+
...transformStyle,
|
|
97
|
+
}}
|
|
98
|
+
className="bg-card fixed flex min-w-36 flex-row items-center justify-center gap-3 rounded-lg border py-2 pr-2 pl-2 shadow-lg shadow-white/5"
|
|
99
|
+
>
|
|
100
|
+
{draggable && (
|
|
101
|
+
<>
|
|
102
|
+
<ActionBarHandle listeners={listeners} attributes={attributes} />
|
|
103
|
+
<ActionBarSeparator />
|
|
104
|
+
</>
|
|
105
|
+
)}
|
|
106
|
+
{children}
|
|
107
|
+
</div>
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
Root.displayName = 'ActionBar.Root'
|
|
112
|
+
|
|
113
|
+
interface ActionBarItemProps {
|
|
114
|
+
children: React.ReactNode
|
|
115
|
+
onClick?: () => void
|
|
116
|
+
disabled?: boolean
|
|
117
|
+
className?: string
|
|
118
|
+
iconName: IconName
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const ActionBarItem = ({
|
|
122
|
+
children,
|
|
123
|
+
onClick,
|
|
124
|
+
disabled,
|
|
125
|
+
className,
|
|
126
|
+
iconName,
|
|
127
|
+
}: ActionBarItemProps) => {
|
|
128
|
+
return (
|
|
129
|
+
<TooltipProvider>
|
|
130
|
+
<Tooltip delayDuration={100}>
|
|
131
|
+
<TooltipTrigger
|
|
132
|
+
onClick={onClick}
|
|
133
|
+
className={cn(
|
|
134
|
+
'text-foreground flex cursor-pointer items-center justify-center select-none last-of-type:mr-1',
|
|
135
|
+
'focus: focus:rounded-md focus:ring-1 focus:ring-blue-500/70 focus:ring-offset-4 focus:ring-offset-slate-900 focus:outline-none',
|
|
136
|
+
!disabled && 'hover:text-foreground cursor-pointer',
|
|
137
|
+
disabled && 'text-body-muted/70 cursor-not-allowed',
|
|
138
|
+
className
|
|
139
|
+
)}
|
|
140
|
+
>
|
|
141
|
+
<Icon name={iconName} size="small" />
|
|
142
|
+
</TooltipTrigger>
|
|
143
|
+
<TooltipContent className="border-zinc-100 px-2 py-1 text-xs shadow-none select-none dark:border-zinc-900">
|
|
144
|
+
{children}
|
|
145
|
+
</TooltipContent>
|
|
146
|
+
</Tooltip>
|
|
147
|
+
</TooltipProvider>
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
ActionBarItem.displayName = 'ActionBar.Item'
|
|
152
|
+
|
|
153
|
+
const ActionBarSeparator = () => {
|
|
154
|
+
return (
|
|
155
|
+
<div className="h-full min-h-4 w-[0.5px] bg-zinc-200 dark:bg-zinc-700" />
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
ActionBarSeparator.displayName = 'ActionBar.Separator'
|
|
160
|
+
|
|
161
|
+
const ActionBarHandle = ({
|
|
162
|
+
listeners,
|
|
163
|
+
attributes,
|
|
164
|
+
}: {
|
|
165
|
+
listeners: SyntheticListenerMap | undefined
|
|
166
|
+
attributes: DraggableAttributes | undefined
|
|
167
|
+
}) => {
|
|
168
|
+
return (
|
|
169
|
+
<div
|
|
170
|
+
{...listeners}
|
|
171
|
+
{...attributes}
|
|
172
|
+
className="text-body-muted hover:text-foreground active:text-foreground h-full cursor-move"
|
|
173
|
+
>
|
|
174
|
+
<Icon name="grip-vertical" className="h-4 w-4" />
|
|
175
|
+
</div>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export const ActionBar = Object.assign(ActionBarInternal, {
|
|
180
|
+
Item: ActionBarItem,
|
|
181
|
+
Separator: ActionBarSeparator,
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
export type { ActionBarProps, ActionBarItemProps }
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
2
|
+
import { Modifier, Variant } from './types'
|
|
3
|
+
import { Icon } from '../Icon'
|
|
4
|
+
import { iconNames } from '../Icon/names'
|
|
5
|
+
import { useState } from 'react'
|
|
6
|
+
import { cn } from '../../lib/utils'
|
|
7
|
+
|
|
8
|
+
const flexClasses = 'flex flex-row items-center gap-3'
|
|
9
|
+
|
|
10
|
+
const alertVariants = cva<{
|
|
11
|
+
variant: {
|
|
12
|
+
[k in Variant]: string
|
|
13
|
+
}
|
|
14
|
+
modifiers: {
|
|
15
|
+
[k in Modifier]: string
|
|
16
|
+
}
|
|
17
|
+
}>(
|
|
18
|
+
`min-w-48 max-h-fit flex flex-row subpixel-antialiased font-light items-center px-3 pr-2 py-2 w-full border`,
|
|
19
|
+
{
|
|
20
|
+
variants: {
|
|
21
|
+
variant: {
|
|
22
|
+
default: 'bg-card',
|
|
23
|
+
success:
|
|
24
|
+
'bg-success-softest text-default-success border-success-softest',
|
|
25
|
+
error:
|
|
26
|
+
'bg-destructive-softest text-default-destructive border-destructive-softest',
|
|
27
|
+
warning:
|
|
28
|
+
'bg-warning-softest text-default-warning border-warning-softest',
|
|
29
|
+
info: 'bg-information-softest text-default-information border-information-softest',
|
|
30
|
+
feature: 'bg-feature text-feature-foreground',
|
|
31
|
+
},
|
|
32
|
+
modifiers: {
|
|
33
|
+
inline: 'inline-flex',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
export type AlertProps = {
|
|
40
|
+
variant: NonNullable<VariantProps<typeof alertVariants>['variant']>
|
|
41
|
+
children: React.ReactNode
|
|
42
|
+
inline?: boolean
|
|
43
|
+
dismissible?: boolean
|
|
44
|
+
onDismiss?: () => void
|
|
45
|
+
iconName?: (typeof iconNames)[number]
|
|
46
|
+
useContainer?: boolean
|
|
47
|
+
className?: string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const iconForVariant: Record<Variant, (typeof iconNames)[number] | undefined> =
|
|
51
|
+
{
|
|
52
|
+
default: 'info',
|
|
53
|
+
success: 'check',
|
|
54
|
+
error: 'circle-alert',
|
|
55
|
+
warning: 'circle-alert',
|
|
56
|
+
info: 'info',
|
|
57
|
+
feature: 'star',
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function Alert({
|
|
61
|
+
variant = 'default',
|
|
62
|
+
children,
|
|
63
|
+
inline = false,
|
|
64
|
+
dismissible = true,
|
|
65
|
+
onDismiss,
|
|
66
|
+
iconName,
|
|
67
|
+
useContainer = false,
|
|
68
|
+
className,
|
|
69
|
+
}: AlertProps) {
|
|
70
|
+
const [isDismissing, setIsDismissing] = useState(false)
|
|
71
|
+
const handleDismiss = () => {
|
|
72
|
+
setIsDismissing(true)
|
|
73
|
+
onDismiss?.()
|
|
74
|
+
}
|
|
75
|
+
const icon = iconName ?? iconForVariant[variant]
|
|
76
|
+
const innerContent = (
|
|
77
|
+
<div className={flexClasses}>
|
|
78
|
+
<div className="flex-shrink-0">
|
|
79
|
+
{icon && <Icon name={icon} size="small" />}
|
|
80
|
+
</div>
|
|
81
|
+
<div>{children}</div>
|
|
82
|
+
</div>
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
const dismissableContent = dismissible && (
|
|
86
|
+
<div className="ml-auto self-start">
|
|
87
|
+
<button
|
|
88
|
+
className="hover:bg-accent/10 p-2 hover:rounded-lg"
|
|
89
|
+
onClick={handleDismiss}
|
|
90
|
+
>
|
|
91
|
+
<Icon name="x" />
|
|
92
|
+
</button>
|
|
93
|
+
</div>
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<div
|
|
98
|
+
role="alert"
|
|
99
|
+
className={cn(
|
|
100
|
+
alertVariants({ variant, modifiers: inline ? 'inline' : undefined }),
|
|
101
|
+
isDismissing && 'opacity-0 transition-opacity duration-500',
|
|
102
|
+
className
|
|
103
|
+
)}
|
|
104
|
+
>
|
|
105
|
+
{useContainer ? (
|
|
106
|
+
<div className="container flex">
|
|
107
|
+
{innerContent}
|
|
108
|
+
{dismissableContent}
|
|
109
|
+
</div>
|
|
110
|
+
) : (
|
|
111
|
+
<>
|
|
112
|
+
{innerContent}
|
|
113
|
+
{dismissableContent}
|
|
114
|
+
</>
|
|
115
|
+
)}
|
|
116
|
+
</div>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const variants = [
|
|
2
|
+
'default',
|
|
3
|
+
'success',
|
|
4
|
+
'error',
|
|
5
|
+
'warning',
|
|
6
|
+
'info',
|
|
7
|
+
'feature',
|
|
8
|
+
] as const
|
|
9
|
+
export type Variant = (typeof variants)[number]
|
|
10
|
+
|
|
11
|
+
export const modifiers = ['inline'] as const
|
|
12
|
+
export type Modifier = (typeof modifiers)[number]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createContext } from 'react'
|
|
2
|
+
|
|
3
|
+
export interface KeybindConfig {
|
|
4
|
+
/**
|
|
5
|
+
* The keybind to trigger the action
|
|
6
|
+
* Will be CMDOrCTRL + key
|
|
7
|
+
*/
|
|
8
|
+
key: string
|
|
9
|
+
description: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface AppLayoutContextType {
|
|
13
|
+
collapsed: boolean
|
|
14
|
+
setCollapsed: (collapsed: boolean) => void
|
|
15
|
+
|
|
16
|
+
// keybind config
|
|
17
|
+
keybinds: {
|
|
18
|
+
toggle: KeybindConfig
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const AppLayoutContext = createContext<AppLayoutContextType>({
|
|
23
|
+
collapsed: false,
|
|
24
|
+
setCollapsed: () => {},
|
|
25
|
+
keybinds: {
|
|
26
|
+
toggle: {
|
|
27
|
+
key: 'L',
|
|
28
|
+
description: 'Toggle',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})
|