@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.
Files changed (330) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -23
  3. package/package.json +33 -50
  4. package/scripts/generate-utility-docs.js +324 -0
  5. package/src/assets/icons/external/github.svg +3 -0
  6. package/src/assets/icons/external/maven.svg +152 -0
  7. package/src/assets/icons/external/npm.svg +4 -0
  8. package/src/assets/icons/external/nuget.svg +5 -0
  9. package/src/assets/icons/external/packagist.svg +1 -0
  10. package/src/assets/icons/external/pypi.svg +182 -0
  11. package/src/assets/icons/external/rubygems.svg +14 -0
  12. package/src/assets/icons/external/terraform.svg +1 -0
  13. package/src/assets/icons/languages/csharp.svg +1 -0
  14. package/src/assets/icons/languages/go.svg +1 -0
  15. package/src/assets/icons/languages/java.svg +1 -0
  16. package/src/assets/icons/languages/json.svg +2 -0
  17. package/src/assets/icons/languages/php.svg +1 -0
  18. package/src/assets/icons/languages/postman.svg +3 -0
  19. package/src/assets/icons/languages/python.svg +1 -0
  20. package/src/assets/icons/languages/ruby.svg +1 -0
  21. package/src/assets/icons/languages/swift.svg +1 -0
  22. package/src/assets/icons/languages/terraform.svg +1 -0
  23. package/src/assets/icons/languages/typescript.svg +1 -0
  24. package/src/assets/icons/languages/unity.svg +1 -0
  25. package/src/base.css +12 -12
  26. package/src/components/AIChat/AIChatContainer.tsx +71 -0
  27. package/src/components/AIChat/AIChatMessage.tsx +135 -0
  28. package/src/components/AIChat/AIChatMessageComposer.tsx +175 -0
  29. package/src/components/AIChat/AIChatMessageList.tsx +34 -0
  30. package/src/components/AIChat/AIChatModelSelector.tsx +159 -0
  31. package/src/components/AIChat/componentsTypes.ts +36 -0
  32. package/src/components/AIChat/context.ts +15 -0
  33. package/src/components/AIChat/index.ts +12 -0
  34. package/src/components/AIChat/parts/AIChatMessageFilePart.tsx +129 -0
  35. package/src/components/AIChat/parts/AIChatMessageReasoningPart.tsx +23 -0
  36. package/src/components/AIChat/parts/AIChatMessageSourcePart.tsx +58 -0
  37. package/src/components/AIChat/parts/AIChatMessageTextPart.tsx +33 -0
  38. package/src/components/AIChat/parts/AIChatMessageToolInvocationPart.tsx +53 -0
  39. package/src/components/AIChat/parts/AIChatMessageToolPart.tsx +395 -0
  40. package/src/components/AIChat/parts/AIChatMessageToolResultPart.tsx +46 -0
  41. package/src/components/AIChat/toolCallApproval.ts +61 -0
  42. package/src/components/AIChat/types.ts +97 -0
  43. package/src/components/ActionBar/index.tsx +184 -0
  44. package/src/components/Alert/index.tsx +118 -0
  45. package/src/components/Alert/types.ts +12 -0
  46. package/src/components/AppLayout/context.tsx +31 -0
  47. package/src/components/AppLayout/index.tsx +550 -0
  48. package/src/components/AppLayout/provider.tsx +40 -0
  49. package/src/components/AppLayout/useAppLayoutKeys.ts +26 -0
  50. package/src/components/Badge/index.tsx +227 -0
  51. package/src/components/Button/index.tsx +531 -0
  52. package/src/components/Card/index.tsx +193 -0
  53. package/src/components/CodeEditorLayout/index.tsx +394 -0
  54. package/src/components/CodeEditorLayout/styles.module.css +8 -0
  55. package/src/components/CodeHighlight/Pre.tsx +63 -0
  56. package/src/components/CodePlayground/index.tsx +411 -0
  57. package/src/components/CodeSnippet/codeSnippet.css +97 -0
  58. package/src/components/CodeSnippet/index.tsx +224 -0
  59. package/src/components/Combobox/index.tsx +193 -0
  60. package/src/components/Command/index.tsx +152 -0
  61. package/src/components/Container/index.tsx +31 -0
  62. package/src/components/ContextDropdown/index.tsx +150 -0
  63. package/src/components/Dialog/index.tsx +123 -0
  64. package/src/components/DragNDrop/DragNDropArea.tsx +30 -0
  65. package/src/components/DragNDrop/DragOverlay.tsx +4 -0
  66. package/src/components/DragNDrop/Draggable.tsx +97 -0
  67. package/src/components/DragNDrop/Droppable.tsx +51 -0
  68. package/src/components/Dropdown/index.tsx +201 -0
  69. package/src/components/ExternalPill/index.tsx +58 -0
  70. package/src/components/Facepile/index.tsx +309 -0
  71. package/src/components/GradientCircle/gradientCircle.css +34 -0
  72. package/src/components/GradientCircle/index.tsx +143 -0
  73. package/src/components/Grid/index.tsx +150 -0
  74. package/src/components/Heading/index.tsx +54 -0
  75. package/src/components/HighlightedText/index.tsx +152 -0
  76. package/src/components/Icon/customIcons/createCustomLucideIcon.ts +25 -0
  77. package/src/components/Icon/customIcons/gems.ts +26 -0
  78. package/{dist/go-CiWl_aXI.mjs → src/components/Icon/customIcons/go.ts} +21 -19
  79. package/src/components/Icon/customIcons/index.ts +11 -0
  80. package/{dist/maven-DhmnGXoB.mjs → src/components/Icon/customIcons/maven.ts} +17 -15
  81. package/src/components/Icon/customIcons/npm.ts +19 -0
  82. package/{dist/nuget-5a2icRS2.mjs → src/components/Icon/customIcons/nuget.ts} +17 -15
  83. package/src/components/Icon/customIcons/packagist.ts +124 -0
  84. package/{dist/pypi-DsuRYjdK.mjs → src/components/Icon/customIcons/pypi.ts} +16 -14
  85. package/src/components/Icon/index.tsx +83 -0
  86. package/src/components/Icon/isIconName.ts +10 -0
  87. package/src/components/Icon/names.ts +14 -0
  88. package/src/components/IconButton/index.tsx +51 -0
  89. package/src/components/Input/index.tsx +98 -0
  90. package/src/components/KeyHint/index.tsx +118 -0
  91. package/src/components/LanguageIndicator/index.tsx +68 -0
  92. package/src/components/Link/index.tsx +153 -0
  93. package/src/components/LoggedInUserMenu/index.tsx +116 -0
  94. package/src/components/Logo/Animated.tsx +191 -0
  95. package/src/components/Logo/index.tsx +17 -0
  96. package/src/components/Logo/speakeasy-logo.riv +0 -0
  97. package/src/components/Logo/svgs/index.tsx +126 -0
  98. package/src/components/Modal/index.tsx +104 -0
  99. package/src/components/PageHeader/index.tsx +227 -0
  100. package/src/components/PageHeader/styles.module.css +27 -0
  101. package/src/components/Popover/index.tsx +35 -0
  102. package/src/components/PromptInput/index.tsx +372 -0
  103. package/src/components/PullRequestLink/index.tsx +64 -0
  104. package/src/components/ResizablePanel/index.tsx +119 -0
  105. package/src/components/Score/index.module.css +32 -0
  106. package/src/components/Score/index.tsx +268 -0
  107. package/src/components/ScrollArea/index.tsx +48 -0
  108. package/src/components/SegmentedButton/index.module.css +19 -0
  109. package/src/components/SegmentedButton/index.tsx +101 -0
  110. package/src/components/Select/index.tsx +159 -0
  111. package/src/components/Separator/index.tsx +23 -0
  112. package/src/components/Skeleton/index.tsx +61 -0
  113. package/src/components/Skeleton/skeleton.css +52 -0
  114. package/src/components/Stack/index.tsx +137 -0
  115. package/src/components/Subnav/index.tsx +315 -0
  116. package/src/components/Switch/index.tsx +29 -0
  117. package/src/components/Table/context/context.tsx +19 -0
  118. package/src/components/Table/context/tableProvider.tsx +39 -0
  119. package/src/components/Table/index.tsx +707 -0
  120. package/src/components/Table/styles.module.css +25 -0
  121. package/src/components/Tabs/index.tsx +87 -0
  122. package/src/components/TargetLanguageIcon/index.tsx +84 -0
  123. package/src/components/Text/index.tsx +59 -0
  124. package/src/components/ThemeSwitcher/index.tsx +118 -0
  125. package/src/components/Timeline/index.tsx +290 -0
  126. package/src/components/Tooltip/index.tsx +41 -0
  127. package/src/components/UserAvatar/index.tsx +87 -0
  128. package/src/components/UserAvatar/sizeMap.ts +12 -0
  129. package/src/components/Wizard/index.tsx +208 -0
  130. package/src/components/Wizard/types.ts +17 -0
  131. package/src/components/WorkspaceSelector/CreateOrg.tsx +95 -0
  132. package/src/components/WorkspaceSelector/CreateWorkspace.tsx +196 -0
  133. package/src/components/WorkspaceSelector/OrgList.tsx +115 -0
  134. package/src/components/WorkspaceSelector/OrgSelector.tsx +207 -0
  135. package/src/components/WorkspaceSelector/RecentWorkspaces.tsx +83 -0
  136. package/src/components/WorkspaceSelector/ScrollingList.tsx +84 -0
  137. package/src/components/WorkspaceSelector/SearchBox.tsx +40 -0
  138. package/src/components/WorkspaceSelector/WorkspaceItem.tsx +37 -0
  139. package/src/components/WorkspaceSelector/WorkspaceList.tsx +107 -0
  140. package/src/components/WorkspaceSelector/index.tsx +400 -0
  141. package/src/components/WorkspaceSelector/styles.css +74 -0
  142. package/src/components/__beta__/CLIWizard/index.tsx +357 -0
  143. package/src/components/__beta__/CLIWizard/terminal-command.tsx +108 -0
  144. package/src/components/__beta__/CLIWizard/terminal.tsx +83 -0
  145. package/src/components/__beta__/README.md +3 -0
  146. package/src/components/index.mdx +38 -0
  147. package/src/context/ConfigContext.tsx +43 -0
  148. package/src/context/ModalContext.tsx +118 -0
  149. package/src/context/theme.ts +1 -0
  150. package/src/hooks/useAppLayout.ts +10 -0
  151. package/src/hooks/useConfig.ts +10 -0
  152. package/src/hooks/useIsMounted.ts +13 -0
  153. package/src/hooks/useModal.tsx +10 -0
  154. package/src/hooks/useTailwindBreakpoint.ts +47 -0
  155. package/src/hooks/useTheme.ts +13 -0
  156. package/src/index.ts +234 -0
  157. package/src/lib/assert.ts +9 -0
  158. package/src/lib/codeUtils.ts +177 -0
  159. package/src/lib/debounce.ts +9 -0
  160. package/src/lib/responsiveMappers.ts +69 -0
  161. package/src/lib/responsiveUtils.ts +23 -0
  162. package/src/lib/storybookUtils.tsx +26 -0
  163. package/src/lib/typeUtils.ts +109 -0
  164. package/src/lib/utils.ts +85 -0
  165. package/src/styles/codeSyntax.css +59 -0
  166. package/src/styles/globals.css +51 -0
  167. package/src/types.ts +200 -0
  168. package/src/utilities.css +347 -6
  169. package/src/vite-env.d.ts +6 -0
  170. package/types/utilities.d.ts +43 -1
  171. package/dist/components/AIChat/AIChatContainer.d.ts +0 -25
  172. package/dist/components/AIChat/AIChatMessage.d.ts +0 -19
  173. package/dist/components/AIChat/AIChatMessageComposer.d.ts +0 -22
  174. package/dist/components/AIChat/AIChatMessageList.d.ts +0 -6
  175. package/dist/components/AIChat/AIChatModelSelector.d.ts +0 -14
  176. package/dist/components/AIChat/componentsTypes.d.ts +0 -11
  177. package/dist/components/AIChat/context.d.ts +0 -3
  178. package/dist/components/AIChat/index.d.ts +0 -12
  179. package/dist/components/AIChat/parts/AIChatMessageFilePart.d.ts +0 -7
  180. package/dist/components/AIChat/parts/AIChatMessageReasoningPart.d.ts +0 -5
  181. package/dist/components/AIChat/parts/AIChatMessageSourcePart.d.ts +0 -9
  182. package/dist/components/AIChat/parts/AIChatMessageTextPart.d.ts +0 -5
  183. package/dist/components/AIChat/parts/AIChatMessageToolInvocationPart.d.ts +0 -6
  184. package/dist/components/AIChat/parts/AIChatMessageToolPart.d.ts +0 -33
  185. package/dist/components/AIChat/parts/AIChatMessageToolResultPart.d.ts +0 -5
  186. package/dist/components/AIChat/toolCallApproval.d.ts +0 -15
  187. package/dist/components/AIChat/types.d.ts +0 -78
  188. package/dist/components/ActionBar/index.d.ts +0 -36
  189. package/dist/components/Alert/index.d.ts +0 -18
  190. package/dist/components/Alert/types.d.ts +0 -4
  191. package/dist/components/Badge/index.d.ts +0 -10
  192. package/dist/components/Button/index.d.ts +0 -11
  193. package/dist/components/Card/index.d.ts +0 -47
  194. package/dist/components/CodeEditorLayout/index.d.ts +0 -101
  195. package/dist/components/CodePlayground/index.d.ts +0 -108
  196. package/dist/components/CodePlayground/lineNumbers.d.ts +0 -2
  197. package/dist/components/CodePlayground/tokenTransitions.d.ts +0 -2
  198. package/dist/components/CodePlayground/wordWrap.d.ts +0 -2
  199. package/dist/components/CodeSnippet/index.d.ts +0 -50
  200. package/dist/components/Combobox/index.d.ts +0 -35
  201. package/dist/components/Command/index.d.ts +0 -80
  202. package/dist/components/Container/index.d.ts +0 -9
  203. package/dist/components/ContextDropdown/index.d.ts +0 -7
  204. package/dist/components/ContextDropdown/provider.d.ts +0 -22
  205. package/dist/components/ContextDropdown/useModal.d.ts +0 -11
  206. package/dist/components/Dialog/index.d.ts +0 -19
  207. package/dist/components/DragNDrop/DragNDropArea.d.ts +0 -8
  208. package/dist/components/DragNDrop/DragOverlay.d.ts +0 -1
  209. package/dist/components/DragNDrop/Draggable.d.ts +0 -29
  210. package/dist/components/DragNDrop/Droppable.d.ts +0 -28
  211. package/dist/components/Dropdown/index.d.ts +0 -27
  212. package/dist/components/ExternalPill/index.d.ts +0 -12
  213. package/dist/components/Facepile/index.d.ts +0 -16
  214. package/dist/components/GradientCircle/index.d.ts +0 -10
  215. package/dist/components/Grid/index.d.ts +0 -80
  216. package/dist/components/Heading/index.d.ts +0 -12
  217. package/dist/components/HighlightedText/index.d.ts +0 -19
  218. package/dist/components/Icon/customIcons/createCustomLucideIcon.d.ts +0 -3
  219. package/dist/components/Icon/customIcons/gems.d.ts +0 -2
  220. package/dist/components/Icon/customIcons/go.d.ts +0 -2
  221. package/dist/components/Icon/customIcons/index.d.ts +0 -10
  222. package/dist/components/Icon/customIcons/maven.d.ts +0 -2
  223. package/dist/components/Icon/customIcons/npm.d.ts +0 -2
  224. package/dist/components/Icon/customIcons/nuget.d.ts +0 -2
  225. package/dist/components/Icon/customIcons/packagist.d.ts +0 -2
  226. package/dist/components/Icon/customIcons/pypi.d.ts +0 -2
  227. package/dist/components/Icon/index.d.ts +0 -10
  228. package/dist/components/Icon/isIconName.d.ts +0 -2
  229. package/dist/components/Icon/names.d.ts +0 -6
  230. package/dist/components/Input/index.d.ts +0 -8
  231. package/dist/components/KeyHint/index.d.ts +0 -16
  232. package/dist/components/LanguageIndicator/index.d.ts +0 -7
  233. package/dist/components/Link/index.d.ts +0 -19
  234. package/dist/components/LoggedInUserMenu/index.d.ts +0 -17
  235. package/dist/components/Logo/Animated.d.ts +0 -7
  236. package/dist/components/Logo/index.d.ts +0 -7
  237. package/dist/components/Logo/svgs/index.d.ts +0 -6
  238. package/dist/components/Navbar/Slim.d.ts +0 -33
  239. package/dist/components/Navbar/index.d.ts +0 -15
  240. package/dist/components/PageHeader/index.d.ts +0 -45
  241. package/dist/components/Popover/index.d.ts +0 -8
  242. package/dist/components/PromptInput/index.d.ts +0 -55
  243. package/dist/components/PullRequestLink/index.d.ts +0 -10
  244. package/dist/components/ResizablePanel/index.d.ts +0 -26
  245. package/dist/components/Score/index.d.ts +0 -37
  246. package/dist/components/ScrollArea/index.d.ts +0 -5
  247. package/dist/components/Select/index.d.ts +0 -13
  248. package/dist/components/Separator/index.d.ts +0 -6
  249. package/dist/components/Skeleton/index.d.ts +0 -27
  250. package/dist/components/Stack/index.d.ts +0 -33
  251. package/dist/components/Subnav/index.d.ts +0 -12
  252. package/dist/components/Switch/index.d.ts +0 -4
  253. package/dist/components/Table/context/context.d.ts +0 -8
  254. package/dist/components/Table/context/tableProvider.d.ts +0 -6
  255. package/dist/components/Table/index.d.ts +0 -94
  256. package/dist/components/Tabs/index.d.ts +0 -21
  257. package/dist/components/TargetLanguageIcon/index.d.ts +0 -7
  258. package/dist/components/Text/index.d.ts +0 -19
  259. package/dist/components/ThemeSwitcher/index.d.ts +0 -5
  260. package/dist/components/Tooltip/index.d.ts +0 -8
  261. package/dist/components/UserAvatar/index.d.ts +0 -9
  262. package/dist/components/UserAvatar/sizeMap.d.ts +0 -3
  263. package/dist/components/Wizard/index.d.ts +0 -19
  264. package/dist/components/Wizard/types.d.ts +0 -15
  265. package/dist/components/WorkspaceSelector/CreateOrg.d.ts +0 -6
  266. package/dist/components/WorkspaceSelector/CreateWorkspace.d.ts +0 -17
  267. package/dist/components/WorkspaceSelector/OrgList.d.ts +0 -11
  268. package/dist/components/WorkspaceSelector/OrgSelector.d.ts +0 -13
  269. package/dist/components/WorkspaceSelector/RecentWorkspaces.d.ts +0 -11
  270. package/dist/components/WorkspaceSelector/ScrollingList.d.ts +0 -21
  271. package/dist/components/WorkspaceSelector/SearchBox.d.ts +0 -9
  272. package/dist/components/WorkspaceSelector/WorkspaceItem.d.ts +0 -9
  273. package/dist/components/WorkspaceSelector/WorkspaceList.d.ts +0 -10
  274. package/dist/components/WorkspaceSelector/index.d.ts +0 -34
  275. package/dist/components/__beta__/CLIWizard/index.d.ts +0 -21
  276. package/dist/components/__beta__/CLIWizard/terminal-command.d.ts +0 -19
  277. package/dist/components/__beta__/CLIWizard/terminal.d.ts +0 -26
  278. package/dist/context/ConfigContext.d.ts +0 -18
  279. package/dist/context/theme.d.ts +0 -1
  280. package/dist/createCustomLucideIcon-YlrRX5h9.mjs +0 -19
  281. package/dist/createCustomLucideIcon-YlrRX5h9.mjs.map +0 -1
  282. package/dist/gems-BcsO9cXq.mjs +0 -24
  283. package/dist/gems-BcsO9cXq.mjs.map +0 -1
  284. package/dist/github-kgjMtfE7.mjs +0 -11
  285. package/dist/github-kgjMtfE7.mjs.map +0 -1
  286. package/dist/go-CiWl_aXI.mjs.map +0 -1
  287. package/dist/hooks/useConfig.d.ts +0 -2
  288. package/dist/hooks/useIsMounted.d.ts +0 -1
  289. package/dist/hooks/useTailwindBreakpoint.d.ts +0 -3
  290. package/dist/hooks/useTheme.d.ts +0 -6
  291. package/dist/index-COXZ9O-g.mjs +0 -50882
  292. package/dist/index-COXZ9O-g.mjs.map +0 -1
  293. package/dist/index.d.ts +0 -73
  294. package/dist/lib/assert.d.ts +0 -2
  295. package/dist/lib/codeUtils.d.ts +0 -35
  296. package/dist/lib/debounce.d.ts +0 -1
  297. package/dist/lib/responsiveMappers.d.ts +0 -10
  298. package/dist/lib/responsiveUtils.d.ts +0 -3
  299. package/dist/lib/storybookUtils.d.ts +0 -5
  300. package/dist/lib/typeUtils.d.ts +0 -24
  301. package/dist/lib/utils.d.ts +0 -23
  302. package/dist/lucide-icons-BDw0imyx.mjs +0 -28054
  303. package/dist/lucide-icons-BDw0imyx.mjs.map +0 -1
  304. package/dist/maven-DhmnGXoB.mjs.map +0 -1
  305. package/dist/maven-W_nkSDNW.mjs +0 -107
  306. package/dist/maven-W_nkSDNW.mjs.map +0 -1
  307. package/dist/moonshine.es.js +0 -114
  308. package/dist/moonshine.es.js.map +0 -1
  309. package/dist/npm-BWTcVvFH.mjs +0 -11
  310. package/dist/npm-BWTcVvFH.mjs.map +0 -1
  311. package/dist/npm-CvQ4GKW4.mjs +0 -17
  312. package/dist/npm-CvQ4GKW4.mjs.map +0 -1
  313. package/dist/nuget-5a2icRS2.mjs.map +0 -1
  314. package/dist/nuget-CV5HU1JR.mjs +0 -11
  315. package/dist/nuget-CV5HU1JR.mjs.map +0 -1
  316. package/dist/packagist-CET6q9hi.mjs +0 -118
  317. package/dist/packagist-CET6q9hi.mjs.map +0 -1
  318. package/dist/packagist-D01fn9N_.mjs +0 -11
  319. package/dist/packagist-D01fn9N_.mjs.map +0 -1
  320. package/dist/pypi-DLh6kIJe.mjs +0 -11
  321. package/dist/pypi-DLh6kIJe.mjs.map +0 -1
  322. package/dist/pypi-DsuRYjdK.mjs.map +0 -1
  323. package/dist/rubygems-DeiNjcDV.mjs +0 -11
  324. package/dist/rubygems-DeiNjcDV.mjs.map +0 -1
  325. package/dist/speakeasy-logo-ByBTXLWb.mjs +0 -5
  326. package/dist/speakeasy-logo-ByBTXLWb.mjs.map +0 -1
  327. package/dist/style.css +0 -1
  328. package/dist/terraform-C4aktQ0o.mjs +0 -11
  329. package/dist/terraform-C4aktQ0o.mjs.map +0 -1
  330. package/dist/types.d.ts +0 -80
@@ -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
+ }
@@ -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
+ }