@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,69 @@
|
|
|
1
|
+
import { Alignment, Gap, Padding, PaddingPerSide } from '../types'
|
|
2
|
+
import {
|
|
3
|
+
isPaddingHorizontalOrVerticalAxis,
|
|
4
|
+
isPaddingPerSide,
|
|
5
|
+
isPaddingPerSideValue,
|
|
6
|
+
} from './typeUtils'
|
|
7
|
+
|
|
8
|
+
const directionClasses: Record<'horizontal' | 'vertical', string> = {
|
|
9
|
+
horizontal: 'flex-row',
|
|
10
|
+
vertical: 'flex-col',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const directionToFlexMapper = (direction: 'horizontal' | 'vertical') =>
|
|
14
|
+
directionClasses[direction]
|
|
15
|
+
export const gapMapper = (gap: Gap) => `gap-${gap}`
|
|
16
|
+
|
|
17
|
+
const paddingPerSideMapper = (padding: PaddingPerSide): string => {
|
|
18
|
+
if (isPaddingHorizontalOrVerticalAxis(padding)) {
|
|
19
|
+
const { x, y } = padding
|
|
20
|
+
return `px-${x} py-${y}`
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (isPaddingPerSideValue(padding)) {
|
|
24
|
+
const { top, right, bottom, left } = padding
|
|
25
|
+
return `pt-${top} pr-${right} pb-${bottom} pl-${left}`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return ''
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const paddingMapper = (padding: Padding): string => {
|
|
32
|
+
if (isPaddingPerSide(padding)) return paddingPerSideMapper(padding)
|
|
33
|
+
return `p-${padding}`
|
|
34
|
+
}
|
|
35
|
+
export const colSpanMapper = (colSpan: number) => `col-span-${colSpan}`
|
|
36
|
+
|
|
37
|
+
const alignmentClasses: Record<Alignment, string> = {
|
|
38
|
+
start: 'items-start',
|
|
39
|
+
center: 'items-center',
|
|
40
|
+
end: 'items-end',
|
|
41
|
+
stretch: 'items-stretch',
|
|
42
|
+
baseline: 'items-baseline',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const alignmentMapper = (alignment: Alignment) =>
|
|
46
|
+
alignmentClasses[alignment]
|
|
47
|
+
|
|
48
|
+
const justifyClasses: Record<
|
|
49
|
+
'start' | 'center' | 'end' | 'space-between' | 'space-evenly',
|
|
50
|
+
string
|
|
51
|
+
> = {
|
|
52
|
+
start: 'justify-start',
|
|
53
|
+
center: 'justify-center',
|
|
54
|
+
end: 'justify-end',
|
|
55
|
+
'space-between': 'justify-between',
|
|
56
|
+
'space-evenly': 'justify-evenly',
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const justifyMapper = (justify: keyof typeof justifyClasses) =>
|
|
60
|
+
justifyClasses[justify]
|
|
61
|
+
|
|
62
|
+
const wrapClasses: Record<'nowrap' | 'wrap' | 'wrap-reverse', string> = {
|
|
63
|
+
nowrap: 'flex-nowrap',
|
|
64
|
+
wrap: 'flex-wrap',
|
|
65
|
+
'wrap-reverse': 'flex-wrap-reverse',
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const wrapMapper = (wrap: 'nowrap' | 'wrap' | 'wrap-reverse') =>
|
|
69
|
+
wrapClasses[wrap]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Breakpoint, breakpoints, Gap, ResponsiveValue, Size } from '../types'
|
|
2
|
+
import { isResponsiveValueObject, isSize } from './typeUtils'
|
|
3
|
+
|
|
4
|
+
export const gapMapper = (gap: Gap) => `gap-${gap}`
|
|
5
|
+
|
|
6
|
+
export const resolveSizeForBreakpoint = (
|
|
7
|
+
currentBreakpoint: Breakpoint,
|
|
8
|
+
size: ResponsiveValue<Size>,
|
|
9
|
+
fallback: Size = 'medium'
|
|
10
|
+
): Size => {
|
|
11
|
+
if (!isResponsiveValueObject<Size>(size)) {
|
|
12
|
+
return isSize(size) ? size : fallback
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const currentBreakpointIndex = breakpoints.indexOf(currentBreakpoint)
|
|
16
|
+
|
|
17
|
+
for (let i = currentBreakpointIndex; i >= 0; i--) {
|
|
18
|
+
const breakpoint = breakpoints[i]
|
|
19
|
+
if (size[breakpoint]) return size[breakpoint]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return fallback
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Grid } from '../components/Grid'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Create a list of sample children for testing and rendering in storybook
|
|
5
|
+
*/
|
|
6
|
+
export function createSampleChildren(count: number, attachTestIds?: boolean) {
|
|
7
|
+
return Array.from({ length: count }).map((_, index) => {
|
|
8
|
+
return (
|
|
9
|
+
<div
|
|
10
|
+
key={index}
|
|
11
|
+
className="bg-muted text-body flex min-w-[100px] items-center justify-center rounded-md p-4 text-center"
|
|
12
|
+
data-testid={attachTestIds ? `sample-child-${index + 1}` : undefined}
|
|
13
|
+
>
|
|
14
|
+
{index + 1}
|
|
15
|
+
</div>
|
|
16
|
+
)
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function createSampleGridChildren(count: number) {
|
|
21
|
+
return createSampleChildren(count).map((child) => (
|
|
22
|
+
<Grid.Item key={child.key} {...child.props}>
|
|
23
|
+
{child}
|
|
24
|
+
</Grid.Item>
|
|
25
|
+
))
|
|
26
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Breakpoint,
|
|
3
|
+
breakpoints,
|
|
4
|
+
Direction,
|
|
5
|
+
PaddingPerAxis,
|
|
6
|
+
PaddingPerSide,
|
|
7
|
+
PaddingPerSides,
|
|
8
|
+
ResponsiveValue,
|
|
9
|
+
Size,
|
|
10
|
+
sizes,
|
|
11
|
+
} from '../types'
|
|
12
|
+
import { Group } from '../components/Table'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Create a range of numbers from 0 to N
|
|
16
|
+
* @example
|
|
17
|
+
* type Range0to100 = Range<100> // [0, 1, 2, ..., 100]
|
|
18
|
+
*/
|
|
19
|
+
export type Range<
|
|
20
|
+
N extends number,
|
|
21
|
+
Arr extends unknown[] = [],
|
|
22
|
+
> = Arr['length'] extends N
|
|
23
|
+
? [...Arr, N][number]
|
|
24
|
+
: Range<N, [...Arr, Arr['length']]>
|
|
25
|
+
|
|
26
|
+
export function isResponsiveValueObject<T>(
|
|
27
|
+
value: unknown
|
|
28
|
+
): value is ResponsiveValue<T> & Record<Breakpoint, T> {
|
|
29
|
+
return (
|
|
30
|
+
typeof value === 'object' &&
|
|
31
|
+
value !== null &&
|
|
32
|
+
Object.keys(value).every((key) => isBreakpoint(key))
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isSize(value: unknown): value is Size {
|
|
37
|
+
return (
|
|
38
|
+
typeof value === 'string' && (sizes as readonly string[]).includes(value)
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function isDirection(value: unknown): value is Direction {
|
|
43
|
+
return (
|
|
44
|
+
typeof value === 'string' &&
|
|
45
|
+
(['row', 'column'] as readonly string[]).includes(value)
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Checks if the value is an object with x and y properties
|
|
51
|
+
*/
|
|
52
|
+
export function isPaddingHorizontalOrVerticalAxis(
|
|
53
|
+
value: unknown
|
|
54
|
+
): value is PaddingPerAxis {
|
|
55
|
+
return (
|
|
56
|
+
typeof value === 'object' &&
|
|
57
|
+
value !== null &&
|
|
58
|
+
// x or y must be present
|
|
59
|
+
('x' in value || 'y' in value)
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function isPaddingPerSideValue(
|
|
64
|
+
value: unknown
|
|
65
|
+
): value is PaddingPerSides {
|
|
66
|
+
return (
|
|
67
|
+
typeof value === 'object' &&
|
|
68
|
+
value !== null &&
|
|
69
|
+
('top' in value || 'right' in value || 'bottom' in value || 'left' in value)
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function isPaddingPerSide(value: unknown): value is PaddingPerSide {
|
|
74
|
+
return isPaddingHorizontalOrVerticalAxis(value) || isPaddingPerSides(value)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function isPaddingPerSides(value: unknown): value is PaddingPerSides {
|
|
78
|
+
return (
|
|
79
|
+
typeof value === 'object' &&
|
|
80
|
+
value !== null &&
|
|
81
|
+
'top' in value &&
|
|
82
|
+
'right' in value &&
|
|
83
|
+
'bottom' in value &&
|
|
84
|
+
'left' in value
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Asserts that a condition is true, otherwise throws an error
|
|
90
|
+
* Can be used to narrow types
|
|
91
|
+
*/
|
|
92
|
+
export function assert(condition: unknown, message: string): asserts condition {
|
|
93
|
+
if (!condition) {
|
|
94
|
+
throw new Error(message)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function isBreakpoint(key: string): key is Breakpoint {
|
|
99
|
+
return (breakpoints as readonly string[]).includes(key)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function isGroupOf<T extends object>(data: unknown): data is Group<T> {
|
|
103
|
+
return (
|
|
104
|
+
typeof data === 'object' &&
|
|
105
|
+
data !== null &&
|
|
106
|
+
'key' in data &&
|
|
107
|
+
'items' in data
|
|
108
|
+
)
|
|
109
|
+
}
|
package/src/lib/utils.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Breakpoint, ResponsiveValue } from '../types'
|
|
2
|
+
import { clsx, type ClassValue } from 'clsx'
|
|
3
|
+
import { extendTailwindMerge } from 'tailwind-merge'
|
|
4
|
+
import { isResponsiveValueObject } from './typeUtils'
|
|
5
|
+
|
|
6
|
+
const customTwMerge = extendTailwindMerge({
|
|
7
|
+
extend: {
|
|
8
|
+
classGroups: {
|
|
9
|
+
'font-size': [
|
|
10
|
+
{
|
|
11
|
+
text: [
|
|
12
|
+
(value: string) =>
|
|
13
|
+
['heading', 'body', 'codeline', 'display'].some((element) =>
|
|
14
|
+
value.includes(element)
|
|
15
|
+
) &&
|
|
16
|
+
['xs', 'sm', 'md', 'lg', 'xl', '2xl'].some((element) =>
|
|
17
|
+
value.includes(element)
|
|
18
|
+
),
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
export function cn(...inputs: ClassValue[]) {
|
|
27
|
+
return customTwMerge(clsx(inputs))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Given an object of responsive values for T and a mapper function, return a string of class names
|
|
32
|
+
* that correspond to the responsive values.
|
|
33
|
+
*
|
|
34
|
+
* @param value - The responsive value
|
|
35
|
+
* @param mapper - A function that takes the value and returns a string of class names
|
|
36
|
+
* @returns A string of class names
|
|
37
|
+
* @example
|
|
38
|
+
* const gapMapper = (gap: number) => `gap-${gap}`
|
|
39
|
+
* const gap = getResponsiveClasses({ sm: 0, md: 10 }, gapMapper)
|
|
40
|
+
* // => 'gap-0 md:gap-10'
|
|
41
|
+
*/
|
|
42
|
+
export function getResponsiveClasses<T>(
|
|
43
|
+
value: ResponsiveValue<T>,
|
|
44
|
+
mapper: (val: T, breakpoint: Breakpoint) => string
|
|
45
|
+
): string {
|
|
46
|
+
if (isResponsiveValueObject(value)) {
|
|
47
|
+
return Object.entries(value)
|
|
48
|
+
.filter(([, val]) => val !== undefined)
|
|
49
|
+
.map(([breakpoint, val]) => {
|
|
50
|
+
const resolvedClasses = mapper(val as T, breakpoint as Breakpoint)
|
|
51
|
+
const classFragments = resolvedClasses.split(' ')
|
|
52
|
+
|
|
53
|
+
return classFragments
|
|
54
|
+
.map((fragment) => {
|
|
55
|
+
return breakpoint === 'xs' ? fragment : `${breakpoint}:${fragment}`
|
|
56
|
+
})
|
|
57
|
+
.join(' ')
|
|
58
|
+
})
|
|
59
|
+
.join(' ')
|
|
60
|
+
}
|
|
61
|
+
return mapper(value as T, 'xs')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Converts string to kebab case
|
|
66
|
+
*
|
|
67
|
+
* @param {string} string
|
|
68
|
+
* @returns {string} A kebabized string
|
|
69
|
+
*/
|
|
70
|
+
export const toKebabCase = (string: string) =>
|
|
71
|
+
string.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()
|
|
72
|
+
|
|
73
|
+
export const partitionBy = <T>(
|
|
74
|
+
array: T[],
|
|
75
|
+
predicate: (item: T) => boolean
|
|
76
|
+
): [T[], T[]] => {
|
|
77
|
+
return array.reduce(
|
|
78
|
+
(acc: [T[], T[]], item: T): [T[], T[]] => {
|
|
79
|
+
const key = predicate(item) ? 0 : 1
|
|
80
|
+
acc[key].push(item)
|
|
81
|
+
return acc
|
|
82
|
+
},
|
|
83
|
+
[[], []]
|
|
84
|
+
)
|
|
85
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
.light {
|
|
2
|
+
--ch-0: light;
|
|
3
|
+
--ch-1: #56565a;
|
|
4
|
+
--ch-2: #baa039;
|
|
5
|
+
--ch-3: #fc7989;
|
|
6
|
+
--ch-4: #787878;
|
|
7
|
+
--ch-5: #3794ff;
|
|
8
|
+
--ch-6: #54bc93;
|
|
9
|
+
--ch-7: #9075fc;
|
|
10
|
+
--ch-8: #54bc93;
|
|
11
|
+
--ch-9: #fda4af;
|
|
12
|
+
--ch-10: #f0f6fc;
|
|
13
|
+
--ch-11: #490202;
|
|
14
|
+
--ch-12: #04260f;
|
|
15
|
+
--ch-13: #5a1e02;
|
|
16
|
+
--ch-14: #161b22;
|
|
17
|
+
--ch-15: #8b949e;
|
|
18
|
+
--ch-16: #0d1117;
|
|
19
|
+
--ch-17: #6e76811a;
|
|
20
|
+
--ch-18: #ffffff0b;
|
|
21
|
+
--ch-19: #3794ff;
|
|
22
|
+
--ch-20: #264f78;
|
|
23
|
+
--ch-21: #1f6feb;
|
|
24
|
+
--ch-22: #010409;
|
|
25
|
+
--ch-23: #30363d;
|
|
26
|
+
--ch-24: #6e7681;
|
|
27
|
+
--ch-25: #6e768166;
|
|
28
|
+
--ch-26: #0d1117e6;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.dark {
|
|
32
|
+
--ch-0: dark;
|
|
33
|
+
--ch-1: #71717a;
|
|
34
|
+
--ch-2: #fef3c7;
|
|
35
|
+
--ch-3: #fda4af;
|
|
36
|
+
--ch-4: #e4e4e7;
|
|
37
|
+
--ch-5: #7dd3fc;
|
|
38
|
+
--ch-6: #6ee7b7;
|
|
39
|
+
--ch-7: #c4b5fd;
|
|
40
|
+
--ch-8: #6ee7b7;
|
|
41
|
+
--ch-9: #fda4af;
|
|
42
|
+
--ch-10: #f0f6fc;
|
|
43
|
+
--ch-11: #490202;
|
|
44
|
+
--ch-12: #04260f;
|
|
45
|
+
--ch-13: #5a1e02;
|
|
46
|
+
--ch-14: #161b22;
|
|
47
|
+
--ch-15: #8b949e;
|
|
48
|
+
--ch-16: #0d1117;
|
|
49
|
+
--ch-17: #6e76811a;
|
|
50
|
+
--ch-18: #ffffff0b;
|
|
51
|
+
--ch-19: #3794ff;
|
|
52
|
+
--ch-20: #264f78;
|
|
53
|
+
--ch-21: #1f6feb;
|
|
54
|
+
--ch-22: #010409;
|
|
55
|
+
--ch-23: #30363d;
|
|
56
|
+
--ch-24: #6e7681;
|
|
57
|
+
--ch-25: #6e768166;
|
|
58
|
+
--ch-26: #0d1117e6;
|
|
59
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
@keyframes fade-in {
|
|
2
|
+
from {
|
|
3
|
+
opacity: 0;
|
|
4
|
+
}
|
|
5
|
+
to {
|
|
6
|
+
opacity: 1;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@keyframes fade-out {
|
|
11
|
+
from {
|
|
12
|
+
opacity: 1;
|
|
13
|
+
}
|
|
14
|
+
to {
|
|
15
|
+
opacity: 0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@keyframes slide-in {
|
|
20
|
+
from {
|
|
21
|
+
transform: translateX(100%);
|
|
22
|
+
}
|
|
23
|
+
to {
|
|
24
|
+
transform: translateX(0);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@keyframes slide-out {
|
|
29
|
+
from {
|
|
30
|
+
transform: translateX(0);
|
|
31
|
+
}
|
|
32
|
+
to {
|
|
33
|
+
transform: translateX(-100%);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
::view-transition-old(workspace-content) {
|
|
38
|
+
animation: fade-out 0.3s ease-out;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
::view-transition-new(workspace-content) {
|
|
42
|
+
animation: fade-in 0.3s ease-out;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
::view-transition-old(create-dialog) {
|
|
46
|
+
animation: slide-out 0.3s ease-out;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
::view-transition-new(create-dialog) {
|
|
50
|
+
animation: slide-in 0.3s ease-out;
|
|
51
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { assertNever } from './lib/assert'
|
|
2
|
+
|
|
3
|
+
// Button variants
|
|
4
|
+
export const buttonVariants = [
|
|
5
|
+
'brand',
|
|
6
|
+
'primary',
|
|
7
|
+
'secondary',
|
|
8
|
+
'tertiary',
|
|
9
|
+
'destructive-primary',
|
|
10
|
+
'destructive-secondary',
|
|
11
|
+
] as const
|
|
12
|
+
export type ButtonVariant = (typeof buttonVariants)[number]
|
|
13
|
+
|
|
14
|
+
// Button sizes
|
|
15
|
+
export const buttonSizes = ['xs', 'sm', 'md', 'lg'] as const
|
|
16
|
+
export type ButtonSize = (typeof buttonSizes)[number]
|
|
17
|
+
|
|
18
|
+
// Button contexts
|
|
19
|
+
export const buttonContexts = ['product', 'marketing'] as const
|
|
20
|
+
export type ButtonContext = (typeof buttonContexts)[number]
|
|
21
|
+
|
|
22
|
+
// Badge variants
|
|
23
|
+
export const badgeVariants = [
|
|
24
|
+
'neutral',
|
|
25
|
+
'destructive',
|
|
26
|
+
'information',
|
|
27
|
+
'success',
|
|
28
|
+
'warning',
|
|
29
|
+
] as const
|
|
30
|
+
export type BadgeVariant = (typeof badgeVariants)[number]
|
|
31
|
+
|
|
32
|
+
// Generic
|
|
33
|
+
export type Orientation = 'horizontal' | 'vertical'
|
|
34
|
+
|
|
35
|
+
export const sizes = ['small', 'medium', 'large', 'xl', '2xl'] as const
|
|
36
|
+
export type Size = (typeof sizes)[number]
|
|
37
|
+
|
|
38
|
+
// Breakpoints
|
|
39
|
+
export const breakpoints = ['xs', 'sm', 'md', 'lg', 'xl', '2xl'] as const
|
|
40
|
+
export type Breakpoint = (typeof breakpoints)[number]
|
|
41
|
+
export type ResponsiveValue<T> = T | { [key in Breakpoint]?: T }
|
|
42
|
+
|
|
43
|
+
// Stack
|
|
44
|
+
export const directionOptions = ['row', 'column'] as const
|
|
45
|
+
export type Direction = (typeof directionOptions)[number]
|
|
46
|
+
|
|
47
|
+
export const tailwindScale = [
|
|
48
|
+
0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20, 24,
|
|
49
|
+
28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80, 96,
|
|
50
|
+
] as const
|
|
51
|
+
|
|
52
|
+
// Gap
|
|
53
|
+
export const gapValues = tailwindScale
|
|
54
|
+
export type Gap = (typeof gapValues)[number]
|
|
55
|
+
|
|
56
|
+
// Grid Columns
|
|
57
|
+
export const gridColumnValues = tailwindScale
|
|
58
|
+
export type Columns = (typeof gridColumnValues)[number]
|
|
59
|
+
|
|
60
|
+
// Padding
|
|
61
|
+
export const paddingValues = tailwindScale
|
|
62
|
+
export type PaddingValue = (typeof paddingValues)[number]
|
|
63
|
+
|
|
64
|
+
export type PaddingPerAxis = { x?: PaddingValue; y?: PaddingValue }
|
|
65
|
+
export type PaddingPerSides = {
|
|
66
|
+
top?: PaddingValue
|
|
67
|
+
right?: PaddingValue
|
|
68
|
+
bottom?: PaddingValue
|
|
69
|
+
left?: PaddingValue
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type PaddingPerSide =
|
|
73
|
+
/**
|
|
74
|
+
* x, y
|
|
75
|
+
*/
|
|
76
|
+
| PaddingPerAxis
|
|
77
|
+
/**
|
|
78
|
+
* top, right, bottom, left
|
|
79
|
+
*/
|
|
80
|
+
| PaddingPerSides
|
|
81
|
+
|
|
82
|
+
export type Padding = PaddingValue | PaddingPerSide
|
|
83
|
+
|
|
84
|
+
export const alignmentOptions = [
|
|
85
|
+
'start',
|
|
86
|
+
'center',
|
|
87
|
+
'end',
|
|
88
|
+
'stretch',
|
|
89
|
+
'baseline',
|
|
90
|
+
] as const
|
|
91
|
+
/**
|
|
92
|
+
* Alignment is an abstraction / amalgamation of the CSS `justify-content`
|
|
93
|
+
* and `align-items` properties.
|
|
94
|
+
*/
|
|
95
|
+
export type Alignment = (typeof alignmentOptions)[number]
|
|
96
|
+
|
|
97
|
+
export const supportedLanguages = [
|
|
98
|
+
'typescript',
|
|
99
|
+
'go',
|
|
100
|
+
'java',
|
|
101
|
+
'python',
|
|
102
|
+
'csharp',
|
|
103
|
+
'terraform',
|
|
104
|
+
'unity',
|
|
105
|
+
'php',
|
|
106
|
+
'swift',
|
|
107
|
+
'ruby',
|
|
108
|
+
'postman',
|
|
109
|
+
'json',
|
|
110
|
+
] as const
|
|
111
|
+
|
|
112
|
+
export type SupportedLanguage = (typeof supportedLanguages)[number]
|
|
113
|
+
|
|
114
|
+
export function isSupportedLanguage(
|
|
115
|
+
language: string
|
|
116
|
+
): language is SupportedLanguage {
|
|
117
|
+
return supportedLanguages.includes(language as SupportedLanguage)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function prettyLanguageName(language: SupportedLanguage) {
|
|
121
|
+
switch (language) {
|
|
122
|
+
case 'typescript':
|
|
123
|
+
return 'TypeScript'
|
|
124
|
+
case 'go':
|
|
125
|
+
return 'Go'
|
|
126
|
+
case 'ruby':
|
|
127
|
+
return 'Ruby'
|
|
128
|
+
case 'python':
|
|
129
|
+
return 'Python'
|
|
130
|
+
case 'csharp':
|
|
131
|
+
return 'C#'
|
|
132
|
+
case 'php':
|
|
133
|
+
return 'PHP'
|
|
134
|
+
case 'java':
|
|
135
|
+
return 'Java'
|
|
136
|
+
case 'swift':
|
|
137
|
+
return 'Swift'
|
|
138
|
+
case 'postman':
|
|
139
|
+
return 'Postman'
|
|
140
|
+
case 'terraform':
|
|
141
|
+
return 'Terraform'
|
|
142
|
+
case 'unity':
|
|
143
|
+
return 'Unity'
|
|
144
|
+
case 'json':
|
|
145
|
+
return 'JSON'
|
|
146
|
+
default:
|
|
147
|
+
assertNever(language)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export type ViewTransition = {
|
|
152
|
+
ready: Promise<void>
|
|
153
|
+
finished: Promise<void>
|
|
154
|
+
updateCallbackDone: Promise<void>
|
|
155
|
+
skipTransition: () => void
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export const wrapOptions = ['nowrap', 'wrap', 'wrap-reverse'] as const
|
|
159
|
+
export type Wrap = (typeof wrapOptions)[number]
|
|
160
|
+
|
|
161
|
+
export const programmingLanguages = [
|
|
162
|
+
'javascript',
|
|
163
|
+
'typescript',
|
|
164
|
+
'python',
|
|
165
|
+
'bash',
|
|
166
|
+
'json',
|
|
167
|
+
'go',
|
|
168
|
+
'dotnet',
|
|
169
|
+
'java',
|
|
170
|
+
] as const
|
|
171
|
+
export type ProgrammingLanguage = (typeof programmingLanguages)[number]
|
|
172
|
+
|
|
173
|
+
export function isProgrammingLanguage(
|
|
174
|
+
language: string
|
|
175
|
+
): language is ProgrammingLanguage {
|
|
176
|
+
return programmingLanguages.includes(language as ProgrammingLanguage)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Workspace selector - shared by Navbar and WorkspaceSelector
|
|
180
|
+
export interface Org {
|
|
181
|
+
id: string
|
|
182
|
+
label: string
|
|
183
|
+
slug: string
|
|
184
|
+
workspaces: Workspace[]
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface Workspace {
|
|
188
|
+
id: string
|
|
189
|
+
slug: string
|
|
190
|
+
label: string
|
|
191
|
+
active: boolean
|
|
192
|
+
createdAt: Date
|
|
193
|
+
updatedAt: Date
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface GlobalWorkspaceSelectorProps {
|
|
197
|
+
orgs: Org[]
|
|
198
|
+
value?: string
|
|
199
|
+
onSelect: (org: Org, workspace: Workspace) => void
|
|
200
|
+
}
|
package/types/utilities.d.ts
CHANGED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { AIChatMessageComponents } from './AIChatMessage';
|
|
3
|
-
import { AIChatMessageComposerComponents } from './AIChatMessageComposer';
|
|
4
|
-
import { AIChatContextValue, ToolCallApprovalProps } from './types';
|
|
5
|
-
export interface ModelSelectorConfig {
|
|
6
|
-
model: string;
|
|
7
|
-
onModelChange: (v: string) => void;
|
|
8
|
-
availableModels: {
|
|
9
|
-
label: string;
|
|
10
|
-
value: string;
|
|
11
|
-
}[];
|
|
12
|
-
}
|
|
13
|
-
export interface AIChatContainerProps extends Omit<AIChatContextValue, 'model' | 'onModelChange' | 'availableModels' | 'toolCallApproval'> {
|
|
14
|
-
modelSelector?: ModelSelectorConfig;
|
|
15
|
-
className?: string;
|
|
16
|
-
components?: Partial<AIChatComponents>;
|
|
17
|
-
toolCallApproval?: ToolCallApprovalProps;
|
|
18
|
-
children?: ReactNode;
|
|
19
|
-
initialInput?: string;
|
|
20
|
-
}
|
|
21
|
-
interface AIChatComponents {
|
|
22
|
-
composer: Partial<AIChatMessageComposerComponents>;
|
|
23
|
-
message: Partial<AIChatMessageComponents>;
|
|
24
|
-
}
|
|
25
|
-
export declare function AIChatContainer({ messages, isLoading, onSendMessage, modelSelector, className, components, toolCallApproval, children, initialInput, }: AIChatContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BaseComponents, FcOrClassName } from './componentsTypes';
|
|
2
|
-
import { AIChatMessageToolPartComponents } from './parts/AIChatMessageToolPart';
|
|
3
|
-
import { ChatMessage } from './types';
|
|
4
|
-
export interface AIChatMessageProps {
|
|
5
|
-
message: ChatMessage;
|
|
6
|
-
className?: string;
|
|
7
|
-
components?: Partial<AIChatMessageComponents>;
|
|
8
|
-
}
|
|
9
|
-
interface AvatarComponents extends BaseComponents {
|
|
10
|
-
user: FcOrClassName<unknown>;
|
|
11
|
-
assistant: FcOrClassName<unknown>;
|
|
12
|
-
system: FcOrClassName<unknown>;
|
|
13
|
-
}
|
|
14
|
-
export interface AIChatMessageComponents {
|
|
15
|
-
toolCall: Partial<AIChatMessageToolPartComponents>;
|
|
16
|
-
avatar: Partial<AvatarComponents>;
|
|
17
|
-
}
|
|
18
|
-
export declare function AIChatMessage({ message, className, components, }: AIChatMessageProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
export {};
|