@opencode-ai/ui 0.0.0-beta-202606251302

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 (346) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +110 -0
  3. package/src/assets/audio/alert-01.aac +0 -0
  4. package/src/assets/audio/alert-01.mp3 +0 -0
  5. package/src/assets/audio/alert-02.aac +0 -0
  6. package/src/assets/audio/alert-02.mp3 +0 -0
  7. package/src/assets/audio/alert-03.aac +0 -0
  8. package/src/assets/audio/alert-03.mp3 +0 -0
  9. package/src/assets/audio/alert-04.aac +0 -0
  10. package/src/assets/audio/alert-04.mp3 +0 -0
  11. package/src/assets/audio/alert-05.aac +0 -0
  12. package/src/assets/audio/alert-05.mp3 +0 -0
  13. package/src/assets/audio/alert-06.aac +0 -0
  14. package/src/assets/audio/alert-06.mp3 +0 -0
  15. package/src/assets/audio/alert-07.aac +0 -0
  16. package/src/assets/audio/alert-07.mp3 +0 -0
  17. package/src/assets/audio/alert-08.aac +0 -0
  18. package/src/assets/audio/alert-08.mp3 +0 -0
  19. package/src/assets/audio/alert-09.aac +0 -0
  20. package/src/assets/audio/alert-09.mp3 +0 -0
  21. package/src/assets/audio/alert-10.aac +0 -0
  22. package/src/assets/audio/alert-10.mp3 +0 -0
  23. package/src/assets/audio/bip-bop-01.aac +0 -0
  24. package/src/assets/audio/bip-bop-01.mp3 +0 -0
  25. package/src/assets/audio/bip-bop-02.aac +0 -0
  26. package/src/assets/audio/bip-bop-02.mp3 +0 -0
  27. package/src/assets/audio/bip-bop-03.aac +0 -0
  28. package/src/assets/audio/bip-bop-03.mp3 +0 -0
  29. package/src/assets/audio/bip-bop-04.aac +0 -0
  30. package/src/assets/audio/bip-bop-04.mp3 +0 -0
  31. package/src/assets/audio/bip-bop-05.aac +0 -0
  32. package/src/assets/audio/bip-bop-05.mp3 +0 -0
  33. package/src/assets/audio/bip-bop-06.aac +0 -0
  34. package/src/assets/audio/bip-bop-06.mp3 +0 -0
  35. package/src/assets/audio/bip-bop-07.aac +0 -0
  36. package/src/assets/audio/bip-bop-07.mp3 +0 -0
  37. package/src/assets/audio/bip-bop-08.aac +0 -0
  38. package/src/assets/audio/bip-bop-08.mp3 +0 -0
  39. package/src/assets/audio/bip-bop-09.aac +0 -0
  40. package/src/assets/audio/bip-bop-09.mp3 +0 -0
  41. package/src/assets/audio/bip-bop-10.aac +0 -0
  42. package/src/assets/audio/bip-bop-10.mp3 +0 -0
  43. package/src/assets/audio/nope-01.aac +0 -0
  44. package/src/assets/audio/nope-01.mp3 +0 -0
  45. package/src/assets/audio/nope-02.aac +0 -0
  46. package/src/assets/audio/nope-02.mp3 +0 -0
  47. package/src/assets/audio/nope-03.aac +0 -0
  48. package/src/assets/audio/nope-03.mp3 +0 -0
  49. package/src/assets/audio/nope-04.aac +0 -0
  50. package/src/assets/audio/nope-04.mp3 +0 -0
  51. package/src/assets/audio/nope-05.aac +0 -0
  52. package/src/assets/audio/nope-05.mp3 +0 -0
  53. package/src/assets/audio/nope-06.aac +0 -0
  54. package/src/assets/audio/nope-06.mp3 +0 -0
  55. package/src/assets/audio/nope-07.aac +0 -0
  56. package/src/assets/audio/nope-07.mp3 +0 -0
  57. package/src/assets/audio/nope-08.aac +0 -0
  58. package/src/assets/audio/nope-08.mp3 +0 -0
  59. package/src/assets/audio/nope-09.aac +0 -0
  60. package/src/assets/audio/nope-09.mp3 +0 -0
  61. package/src/assets/audio/nope-10.aac +0 -0
  62. package/src/assets/audio/nope-10.mp3 +0 -0
  63. package/src/assets/audio/nope-11.aac +0 -0
  64. package/src/assets/audio/nope-11.mp3 +0 -0
  65. package/src/assets/audio/nope-12.aac +0 -0
  66. package/src/assets/audio/nope-12.mp3 +0 -0
  67. package/src/assets/audio/staplebops-01.aac +0 -0
  68. package/src/assets/audio/staplebops-01.mp3 +0 -0
  69. package/src/assets/audio/staplebops-02.aac +0 -0
  70. package/src/assets/audio/staplebops-02.mp3 +0 -0
  71. package/src/assets/audio/staplebops-03.aac +0 -0
  72. package/src/assets/audio/staplebops-03.mp3 +0 -0
  73. package/src/assets/audio/staplebops-04.aac +0 -0
  74. package/src/assets/audio/staplebops-04.mp3 +0 -0
  75. package/src/assets/audio/staplebops-05.aac +0 -0
  76. package/src/assets/audio/staplebops-05.mp3 +0 -0
  77. package/src/assets/audio/staplebops-06.aac +0 -0
  78. package/src/assets/audio/staplebops-06.mp3 +0 -0
  79. package/src/assets/audio/staplebops-07.aac +0 -0
  80. package/src/assets/audio/staplebops-07.mp3 +0 -0
  81. package/src/assets/audio/yup-01.aac +0 -0
  82. package/src/assets/audio/yup-01.mp3 +0 -0
  83. package/src/assets/audio/yup-02.aac +0 -0
  84. package/src/assets/audio/yup-02.mp3 +0 -0
  85. package/src/assets/audio/yup-03.aac +0 -0
  86. package/src/assets/audio/yup-03.mp3 +0 -0
  87. package/src/assets/audio/yup-04.aac +0 -0
  88. package/src/assets/audio/yup-04.mp3 +0 -0
  89. package/src/assets/audio/yup-05.aac +0 -0
  90. package/src/assets/audio/yup-05.mp3 +0 -0
  91. package/src/assets/audio/yup-06.aac +0 -0
  92. package/src/assets/audio/yup-06.mp3 +0 -0
  93. package/src/assets/fonts/Inter.ttf +0 -0
  94. package/src/assets/fonts/JetBrainsMonoNerdFontMono-Regular.woff2 +0 -0
  95. package/src/assets/icons/app/android-studio.svg +369 -0
  96. package/src/assets/icons/app/antigravity.svg +97 -0
  97. package/src/assets/icons/app/cursor.svg +16 -0
  98. package/src/assets/icons/app/file-explorer.svg +20 -0
  99. package/src/assets/icons/app/finder.png +0 -0
  100. package/src/assets/icons/app/ghostty.svg +13 -0
  101. package/src/assets/icons/app/iterm2.svg +13 -0
  102. package/src/assets/icons/app/powershell.svg +14 -0
  103. package/src/assets/icons/app/sublimetext.svg +17 -0
  104. package/src/assets/icons/app/terminal.png +0 -0
  105. package/src/assets/icons/app/textmate.png +0 -0
  106. package/src/assets/icons/app/vscode.svg +39 -0
  107. package/src/assets/icons/app/warp.png +0 -0
  108. package/src/assets/icons/app/xcode.png +0 -0
  109. package/src/assets/icons/app/zed-dark.svg +15 -0
  110. package/src/assets/icons/app/zed.svg +15 -0
  111. package/src/components/accordion.css +123 -0
  112. package/src/components/accordion.tsx +92 -0
  113. package/src/components/animated-number.css +75 -0
  114. package/src/components/animated-number.tsx +109 -0
  115. package/src/components/app-icon.css +5 -0
  116. package/src/components/app-icon.tsx +85 -0
  117. package/src/components/app-icons/sprite.svg +114 -0
  118. package/src/components/app-icons/types.ts +21 -0
  119. package/src/components/avatar.css +49 -0
  120. package/src/components/avatar.tsx +55 -0
  121. package/src/components/button.css +194 -0
  122. package/src/components/button.tsx +33 -0
  123. package/src/components/card.css +94 -0
  124. package/src/components/card.tsx +123 -0
  125. package/src/components/checkbox.css +131 -0
  126. package/src/components/checkbox.tsx +43 -0
  127. package/src/components/collapsible.css +148 -0
  128. package/src/components/collapsible.tsx +48 -0
  129. package/src/components/context-menu.css +134 -0
  130. package/src/components/context-menu.tsx +308 -0
  131. package/src/components/dialog.css +181 -0
  132. package/src/components/dialog.tsx +72 -0
  133. package/src/components/diff-changes.css +42 -0
  134. package/src/components/diff-changes.tsx +115 -0
  135. package/src/components/dock-surface.css +23 -0
  136. package/src/components/dock-surface.tsx +54 -0
  137. package/src/components/dropdown-menu.css +135 -0
  138. package/src/components/dropdown-menu.tsx +308 -0
  139. package/src/components/favicon.tsx +13 -0
  140. package/src/components/file-icon.css +26 -0
  141. package/src/components/file-icon.tsx +588 -0
  142. package/src/components/file-icons/sprite.svg +11707 -0
  143. package/src/components/file-icons/types.ts +1095 -0
  144. package/src/components/font.tsx +1 -0
  145. package/src/components/hover-card.css +61 -0
  146. package/src/components/hover-card.tsx +32 -0
  147. package/src/components/icon-button.css +181 -0
  148. package/src/components/icon-button.tsx +29 -0
  149. package/src/components/icon.css +34 -0
  150. package/src/components/icon.tsx +169 -0
  151. package/src/components/image-preview.css +63 -0
  152. package/src/components/image-preview.tsx +32 -0
  153. package/src/components/inline-input.css +17 -0
  154. package/src/components/inline-input.tsx +22 -0
  155. package/src/components/keybind.css +18 -0
  156. package/src/components/keybind.tsx +20 -0
  157. package/src/components/list.css +331 -0
  158. package/src/components/list.tsx +394 -0
  159. package/src/components/logo.css +4 -0
  160. package/src/components/logo.tsx +62 -0
  161. package/src/components/motion-spring.tsx +58 -0
  162. package/src/components/popover.css +98 -0
  163. package/src/components/popover.tsx +153 -0
  164. package/src/components/progress-circle.css +12 -0
  165. package/src/components/progress-circle.tsx +57 -0
  166. package/src/components/progress.css +63 -0
  167. package/src/components/progress.tsx +39 -0
  168. package/src/components/provider-icon.css +5 -0
  169. package/src/components/provider-icon.tsx +25 -0
  170. package/src/components/provider-icons/sprite.svg +1135 -0
  171. package/src/components/provider-icons/types.ts +105 -0
  172. package/src/components/radio-group.css +187 -0
  173. package/src/components/radio-group.tsx +83 -0
  174. package/src/components/resize-handle.css +58 -0
  175. package/src/components/resize-handle.tsx +82 -0
  176. package/src/components/scroll-view.css +66 -0
  177. package/src/components/scroll-view.tsx +250 -0
  178. package/src/components/select.css +202 -0
  179. package/src/components/select.tsx +174 -0
  180. package/src/components/spinner.css +6 -0
  181. package/src/components/spinner.tsx +52 -0
  182. package/src/components/sticky-accordion-header.css +6 -0
  183. package/src/components/sticky-accordion-header.tsx +18 -0
  184. package/src/components/switch.css +132 -0
  185. package/src/components/switch.tsx +29 -0
  186. package/src/components/tabs.css +635 -0
  187. package/src/components/tabs.tsx +125 -0
  188. package/src/components/tag.css +37 -0
  189. package/src/components/tag.tsx +22 -0
  190. package/src/components/text-field.css +134 -0
  191. package/src/components/text-field.tsx +128 -0
  192. package/src/components/text-reveal.css +150 -0
  193. package/src/components/text-reveal.tsx +143 -0
  194. package/src/components/text-shimmer.css +119 -0
  195. package/src/components/text-shimmer.tsx +62 -0
  196. package/src/components/text-strikethrough.css +27 -0
  197. package/src/components/text-strikethrough.tsx +84 -0
  198. package/src/components/toast.css +236 -0
  199. package/src/components/toast.tsx +185 -0
  200. package/src/components/tooltip.css +74 -0
  201. package/src/components/tooltip.tsx +161 -0
  202. package/src/components/typewriter.css +14 -0
  203. package/src/components/typewriter.tsx +55 -0
  204. package/src/context/dialog.tsx +197 -0
  205. package/src/context/file.tsx +10 -0
  206. package/src/context/helper.tsx +38 -0
  207. package/src/context/i18n.tsx +38 -0
  208. package/src/context/index.ts +4 -0
  209. package/src/context/marked.tsx +522 -0
  210. package/src/context/worker-pool.tsx +20 -0
  211. package/src/custom-elements.d.ts +17 -0
  212. package/src/hooks/create-auto-scroll.tsx +237 -0
  213. package/src/hooks/index.ts +2 -0
  214. package/src/hooks/use-filtered-list.tsx +134 -0
  215. package/src/i18n/ar.ts +168 -0
  216. package/src/i18n/br.ts +168 -0
  217. package/src/i18n/bs.ts +172 -0
  218. package/src/i18n/da.ts +167 -0
  219. package/src/i18n/de.ts +173 -0
  220. package/src/i18n/en.ts +176 -0
  221. package/src/i18n/es.ts +168 -0
  222. package/src/i18n/fr.ts +168 -0
  223. package/src/i18n/ja.ts +167 -0
  224. package/src/i18n/ko.ts +168 -0
  225. package/src/i18n/no.ts +171 -0
  226. package/src/i18n/pl.ts +167 -0
  227. package/src/i18n/ru.ts +167 -0
  228. package/src/i18n/th.ts +169 -0
  229. package/src/i18n/tr.ts +174 -0
  230. package/src/i18n/uk.ts +167 -0
  231. package/src/i18n/zh.ts +171 -0
  232. package/src/i18n/zht.ts +171 -0
  233. package/src/storybook/fixtures.ts +51 -0
  234. package/src/storybook/scaffold.tsx +62 -0
  235. package/src/styles/animations.css +141 -0
  236. package/src/styles/base.css +404 -0
  237. package/src/styles/colors.css +772 -0
  238. package/src/styles/index.css +53 -0
  239. package/src/styles/tailwind/colors.css +285 -0
  240. package/src/styles/tailwind/index.css +78 -0
  241. package/src/styles/tailwind/utilities.css +131 -0
  242. package/src/styles/theme.css +609 -0
  243. package/src/styles/utilities.css +118 -0
  244. package/src/theme/color.ts +299 -0
  245. package/src/theme/context.tsx +370 -0
  246. package/src/theme/default-themes.ts +116 -0
  247. package/src/theme/index.ts +78 -0
  248. package/src/theme/loader.ts +112 -0
  249. package/src/theme/resolve.ts +540 -0
  250. package/src/theme/themes/amoled.json +49 -0
  251. package/src/theme/themes/aura.json +51 -0
  252. package/src/theme/themes/ayu.json +51 -0
  253. package/src/theme/themes/carbonfox.json +53 -0
  254. package/src/theme/themes/catppuccin-frappe.json +85 -0
  255. package/src/theme/themes/catppuccin-macchiato.json +85 -0
  256. package/src/theme/themes/catppuccin.json +45 -0
  257. package/src/theme/themes/cobalt2.json +87 -0
  258. package/src/theme/themes/cursor.json +91 -0
  259. package/src/theme/themes/dracula.json +49 -0
  260. package/src/theme/themes/everforest.json +89 -0
  261. package/src/theme/themes/flexoki.json +86 -0
  262. package/src/theme/themes/github.json +85 -0
  263. package/src/theme/themes/gruvbox.json +45 -0
  264. package/src/theme/themes/kanagawa.json +89 -0
  265. package/src/theme/themes/lucent-orng.json +87 -0
  266. package/src/theme/themes/material.json +87 -0
  267. package/src/theme/themes/matrix.json +113 -0
  268. package/src/theme/themes/mercury.json +86 -0
  269. package/src/theme/themes/monokai.json +49 -0
  270. package/src/theme/themes/nightowl.json +46 -0
  271. package/src/theme/themes/nord.json +46 -0
  272. package/src/theme/themes/oc-2.json +468 -0
  273. package/src/theme/themes/one-dark.json +89 -0
  274. package/src/theme/themes/onedarkpro.json +45 -0
  275. package/src/theme/themes/opencode.json +89 -0
  276. package/src/theme/themes/orng.json +87 -0
  277. package/src/theme/themes/osaka-jade.json +88 -0
  278. package/src/theme/themes/palenight.json +85 -0
  279. package/src/theme/themes/rosepine.json +85 -0
  280. package/src/theme/themes/shadesofpurple.json +51 -0
  281. package/src/theme/themes/solarized.json +49 -0
  282. package/src/theme/themes/synthwave84.json +87 -0
  283. package/src/theme/themes/tokyonight.json +47 -0
  284. package/src/theme/themes/vercel.json +90 -0
  285. package/src/theme/themes/vesper.json +51 -0
  286. package/src/theme/themes/zenburn.json +87 -0
  287. package/src/theme/types.ts +75 -0
  288. package/src/theme/v2/avatar.ts +48 -0
  289. package/src/theme/v2/default-primitives.ts +114 -0
  290. package/src/theme/v2/foreground.ts +60 -0
  291. package/src/theme/v2/mapping.ts +138 -0
  292. package/src/theme/v2/resolve.ts +153 -0
  293. package/src/v2/components/accordion-v2.css +139 -0
  294. package/src/v2/components/accordion-v2.tsx +86 -0
  295. package/src/v2/components/avatar-v2.css +70 -0
  296. package/src/v2/components/avatar-v2.tsx +59 -0
  297. package/src/v2/components/badge-v2.css +27 -0
  298. package/src/v2/components/badge-v2.tsx +20 -0
  299. package/src/v2/components/button-v2.css +186 -0
  300. package/src/v2/components/button-v2.tsx +35 -0
  301. package/src/v2/components/checkbox-v2.css +184 -0
  302. package/src/v2/components/checkbox-v2.tsx +65 -0
  303. package/src/v2/components/dialog-v2.css +150 -0
  304. package/src/v2/components/dialog-v2.tsx +93 -0
  305. package/src/v2/components/diff-changes-v2.css +24 -0
  306. package/src/v2/components/diff-changes-v2.tsx +28 -0
  307. package/src/v2/components/field-v2.css +94 -0
  308. package/src/v2/components/field-v2.tsx +265 -0
  309. package/src/v2/components/icon-button-v2.css +155 -0
  310. package/src/v2/components/icon-button-v2.tsx +37 -0
  311. package/src/v2/components/icon.tsx +129 -0
  312. package/src/v2/components/inline-input-v2.css +218 -0
  313. package/src/v2/components/inline-input-v2.tsx +90 -0
  314. package/src/v2/components/keybind-v2.css +76 -0
  315. package/src/v2/components/keybind-v2.tsx +30 -0
  316. package/src/v2/components/line-comment-v2.css +204 -0
  317. package/src/v2/components/line-comment-v2.tsx +155 -0
  318. package/src/v2/components/menu-v2.css +190 -0
  319. package/src/v2/components/menu-v2.tsx +225 -0
  320. package/src/v2/components/project-avatar-v2.css +126 -0
  321. package/src/v2/components/project-avatar-v2.tsx +64 -0
  322. package/src/v2/components/radio-v2.css +202 -0
  323. package/src/v2/components/radio-v2.tsx +72 -0
  324. package/src/v2/components/segmented-control-v2.css +80 -0
  325. package/src/v2/components/segmented-control-v2.tsx +208 -0
  326. package/src/v2/components/select-v2.css +285 -0
  327. package/src/v2/components/select-v2.tsx +208 -0
  328. package/src/v2/components/switch-v2.css +154 -0
  329. package/src/v2/components/switch-v2.tsx +28 -0
  330. package/src/v2/components/tab-state-indicator.tsx +37 -0
  331. package/src/v2/components/tabs-v2.css +225 -0
  332. package/src/v2/components/tabs-v2.tsx +147 -0
  333. package/src/v2/components/text-input-v2.css +145 -0
  334. package/src/v2/components/text-input-v2.tsx +67 -0
  335. package/src/v2/components/text-shimmer-v2.css +125 -0
  336. package/src/v2/components/text-shimmer-v2.tsx +63 -0
  337. package/src/v2/components/textarea-v2.css +78 -0
  338. package/src/v2/components/textarea-v2.tsx +31 -0
  339. package/src/v2/components/toast-v2.css +215 -0
  340. package/src/v2/components/toast-v2.tsx +144 -0
  341. package/src/v2/components/tooltip-v2.css +53 -0
  342. package/src/v2/components/tooltip-v2.tsx +146 -0
  343. package/src/v2/components/wordmark-v2.tsx +92 -0
  344. package/src/v2/styles/colors.css +172 -0
  345. package/src/v2/styles/tailwind.css +2 -0
  346. package/src/v2/styles/theme.css +441 -0
@@ -0,0 +1,185 @@
1
+ import { Toast as Kobalte, toaster } from "@kobalte/core/toast"
2
+ import type { ToastRootProps, ToastCloseButtonProps, ToastTitleProps, ToastDescriptionProps } from "@kobalte/core/toast"
3
+ import type { ComponentProps, JSX } from "solid-js"
4
+ import { Show } from "solid-js"
5
+ import { Portal } from "solid-js/web"
6
+ import { useI18n } from "../context/i18n"
7
+ import { Icon, type IconProps } from "./icon"
8
+ import { IconButton } from "./icon-button"
9
+
10
+ export interface ToastRegionProps extends ComponentProps<typeof Kobalte.Region> {}
11
+
12
+ function ToastRegion(props: ToastRegionProps) {
13
+ return (
14
+ <Portal>
15
+ <Kobalte.Region data-component="toast-region" {...props}>
16
+ <Kobalte.List data-slot="toast-list" />
17
+ </Kobalte.Region>
18
+ </Portal>
19
+ )
20
+ }
21
+
22
+ export interface ToastRootComponentProps extends ToastRootProps {
23
+ class?: string
24
+ classList?: ComponentProps<"li">["classList"]
25
+ children?: JSX.Element
26
+ }
27
+
28
+ function ToastRoot(props: ToastRootComponentProps) {
29
+ return (
30
+ <Kobalte
31
+ data-component="toast"
32
+ classList={{
33
+ ...props.classList,
34
+ [props.class ?? ""]: !!props.class,
35
+ }}
36
+ {...props}
37
+ />
38
+ )
39
+ }
40
+
41
+ function ToastIcon(props: { name: IconProps["name"] }) {
42
+ return (
43
+ <div data-slot="toast-icon">
44
+ <Icon name={props.name} />
45
+ </div>
46
+ )
47
+ }
48
+
49
+ function ToastContent(props: ComponentProps<"div">) {
50
+ return <div data-slot="toast-content" {...props} />
51
+ }
52
+
53
+ function ToastTitle(props: ToastTitleProps & ComponentProps<"div">) {
54
+ return <Kobalte.Title data-slot="toast-title" {...props} />
55
+ }
56
+
57
+ function ToastDescription(props: ToastDescriptionProps & ComponentProps<"div">) {
58
+ return <Kobalte.Description data-slot="toast-description" {...props} />
59
+ }
60
+
61
+ function ToastActions(props: ComponentProps<"div">) {
62
+ return <div data-slot="toast-actions" {...props} />
63
+ }
64
+
65
+ function ToastCloseButton(props: ToastCloseButtonProps & ComponentProps<"button">) {
66
+ const i18n = useI18n()
67
+ return (
68
+ <Kobalte.CloseButton
69
+ data-slot="toast-close-button"
70
+ as={IconButton}
71
+ icon="close"
72
+ variant="ghost"
73
+ aria-label={i18n.t("ui.common.dismiss")}
74
+ {...props}
75
+ />
76
+ )
77
+ }
78
+
79
+ function ToastProgressTrack(props: ComponentProps<typeof Kobalte.ProgressTrack>) {
80
+ return <Kobalte.ProgressTrack data-slot="toast-progress-track" {...props} />
81
+ }
82
+
83
+ function ToastProgressFill(props: ComponentProps<typeof Kobalte.ProgressFill>) {
84
+ return <Kobalte.ProgressFill data-slot="toast-progress-fill" {...props} />
85
+ }
86
+
87
+ export const Toast = Object.assign(ToastRoot, {
88
+ Region: ToastRegion,
89
+ Icon: ToastIcon,
90
+ Content: ToastContent,
91
+ Title: ToastTitle,
92
+ Description: ToastDescription,
93
+ Actions: ToastActions,
94
+ CloseButton: ToastCloseButton,
95
+ ProgressTrack: ToastProgressTrack,
96
+ ProgressFill: ToastProgressFill,
97
+ })
98
+
99
+ export { toaster }
100
+
101
+ export type ToastVariant = "default" | "success" | "error" | "loading"
102
+
103
+ export interface ToastAction {
104
+ label: string
105
+ onClick: "dismiss" | (() => void)
106
+ }
107
+
108
+ export interface ToastOptions {
109
+ title?: string
110
+ description?: string
111
+ icon?: IconProps["name"]
112
+ variant?: ToastVariant
113
+ duration?: number
114
+ persistent?: boolean
115
+ actions?: ToastAction[]
116
+ }
117
+
118
+ export function showToast(options: ToastOptions | string) {
119
+ const opts = typeof options === "string" ? { description: options } : options
120
+ return toaster.show((props) => (
121
+ <Toast
122
+ toastId={props.toastId}
123
+ duration={opts.duration}
124
+ persistent={opts.persistent}
125
+ data-variant={opts.variant ?? "default"}
126
+ >
127
+ <Show when={opts.icon}>
128
+ <Toast.Icon name={opts.icon!} />
129
+ </Show>
130
+ <Toast.Content>
131
+ <Show when={opts.title}>
132
+ <Toast.Title>{opts.title}</Toast.Title>
133
+ </Show>
134
+ <Show when={opts.description}>
135
+ <Toast.Description>{opts.description}</Toast.Description>
136
+ </Show>
137
+ <Show when={opts.actions?.length}>
138
+ <Toast.Actions>
139
+ {opts.actions!.map((action) => (
140
+ <button
141
+ data-slot="toast-action"
142
+ onClick={() => {
143
+ if (typeof action.onClick === "function") {
144
+ action.onClick()
145
+ }
146
+ toaster.dismiss(props.toastId)
147
+ }}
148
+ >
149
+ {action.label}
150
+ </button>
151
+ ))}
152
+ </Toast.Actions>
153
+ </Show>
154
+ </Toast.Content>
155
+ <Toast.CloseButton />
156
+ </Toast>
157
+ ))
158
+ }
159
+
160
+ export interface ToastPromiseOptions<T, U = unknown> {
161
+ loading?: JSX.Element
162
+ success?: (data: T) => JSX.Element
163
+ error?: (error: U) => JSX.Element
164
+ }
165
+
166
+ export function showPromiseToast<T, U = unknown>(
167
+ promise: Promise<T> | (() => Promise<T>),
168
+ options: ToastPromiseOptions<T, U>,
169
+ ) {
170
+ return toaster.promise(promise, (props) => (
171
+ <Toast
172
+ toastId={props.toastId}
173
+ data-variant={props.state === "pending" ? "loading" : props.state === "fulfilled" ? "success" : "error"}
174
+ >
175
+ <Toast.Content>
176
+ <Toast.Description>
177
+ {props.state === "pending" && options.loading}
178
+ {props.state === "fulfilled" && options.success?.(props.data!)}
179
+ {props.state === "rejected" && options.error?.(props.error)}
180
+ </Toast.Description>
181
+ </Toast.Content>
182
+ <Toast.CloseButton />
183
+ </Toast>
184
+ ))
185
+ }
@@ -0,0 +1,74 @@
1
+ [data-component="tooltip-trigger"] {
2
+ display: flex;
3
+ }
4
+
5
+ [data-slot="tooltip-keybind"] {
6
+ display: flex;
7
+ align-items: center;
8
+ gap: 12px;
9
+ }
10
+
11
+ [data-slot="tooltip-keybind-key"] {
12
+ color: var(--text-invert-base);
13
+ font-size: var(--font-size-small);
14
+ font-weight: var(--font-weight-medium);
15
+ line-height: var(--line-height-large);
16
+ }
17
+
18
+ [data-component="tooltip"] {
19
+ z-index: 1000;
20
+ max-width: 320px;
21
+ border-radius: var(--radius-sm);
22
+ background-color: var(--surface-float-base);
23
+ color: var(--text-invert-strong);
24
+ background: var(--surface-float-base);
25
+ padding: 2px 8px;
26
+ border: 1px solid var(--border-weak-base, rgba(0, 0, 0, 0.07));
27
+
28
+ box-shadow: var(--shadow-md);
29
+ pointer-events: none !important;
30
+ /* transition: all 150ms ease-out; */
31
+ /* transform: translate3d(0, 0, 0); */
32
+ /* transform-origin: var(--kb-tooltip-content-transform-origin); */
33
+
34
+ /* text-12-medium */
35
+ font-family: var(--font-family-sans);
36
+ font-size: var(--font-size-small);
37
+ font-style: normal;
38
+ font-weight: var(--font-weight-medium);
39
+ line-height: var(--line-height-large); /* 166.667% */
40
+ letter-spacing: var(--letter-spacing-normal);
41
+
42
+ &[data-expanded] {
43
+ opacity: 1;
44
+ /* transform: translate3d(0, 0, 0); */
45
+ }
46
+
47
+ &[data-closed]:not([data-force-open="true"]) {
48
+ opacity: 0;
49
+ }
50
+
51
+ /* &[data-placement="top"] { */
52
+ /* &[data-closed] { */
53
+ /* transform: translate3d(0, 4px, 0); */
54
+ /* } */
55
+ /* } */
56
+ /**/
57
+ /* &[data-placement="bottom"] { */
58
+ /* &[data-closed] { */
59
+ /* transform: translate3d(0, -4px, 0); */
60
+ /* } */
61
+ /* } */
62
+ /**/
63
+ /* &[data-placement="left"] { */
64
+ /* &[data-closed] { */
65
+ /* transform: translate3d(4px, 0, 0); */
66
+ /* } */
67
+ /* } */
68
+ /**/
69
+ /* &[data-placement="right"] { */
70
+ /* &[data-closed] { */
71
+ /* transform: translate3d(-4px, 0, 0); */
72
+ /* } */
73
+ /* } */
74
+ }
@@ -0,0 +1,161 @@
1
+ import { Tooltip as KobalteTooltip } from "@kobalte/core/tooltip"
2
+ import { createEffect, Match, onCleanup, splitProps, Switch, type JSX } from "solid-js"
3
+ import type { ComponentProps } from "solid-js"
4
+ import { createStore } from "solid-js/store"
5
+
6
+ export interface TooltipProps extends ComponentProps<typeof KobalteTooltip> {
7
+ value: JSX.Element
8
+ class?: string
9
+ contentClass?: string
10
+ contentStyle?: JSX.CSSProperties
11
+ inactive?: boolean
12
+ forceOpen?: boolean
13
+ }
14
+
15
+ export interface TooltipKeybindProps extends Omit<TooltipProps, "value"> {
16
+ title: string
17
+ keybind: string
18
+ }
19
+
20
+ export function TooltipKeybind(props: TooltipKeybindProps) {
21
+ const [local, others] = splitProps(props, ["title", "keybind"])
22
+ return (
23
+ <Tooltip
24
+ {...others}
25
+ value={
26
+ <div data-slot="tooltip-keybind">
27
+ <span>{local.title}</span>
28
+ <span data-slot="tooltip-keybind-key">{local.keybind}</span>
29
+ </div>
30
+ }
31
+ />
32
+ )
33
+ }
34
+
35
+ export function Tooltip(props: TooltipProps) {
36
+ let ref: HTMLDivElement | undefined
37
+ const [state, setState] = createStore({
38
+ open: false,
39
+ block: false,
40
+ expand: false,
41
+ })
42
+ const [local, others] = splitProps(props, [
43
+ "children",
44
+ "class",
45
+ "contentClass",
46
+ "contentStyle",
47
+ "inactive",
48
+ "forceOpen",
49
+ "ignoreSafeArea",
50
+ "value",
51
+ ])
52
+
53
+ const close = () => setState("open", false)
54
+
55
+ const inside = () => {
56
+ const active = document.activeElement
57
+ if (!ref || !active) return false
58
+ return ref.contains(active)
59
+ }
60
+
61
+ const drop = (expand = state.expand) => {
62
+ if (expand) return
63
+ if (ref?.matches(":hover")) return
64
+ if (inside()) return
65
+ setState("block", false)
66
+ }
67
+
68
+ const sync = () => {
69
+ const expand = !!ref?.querySelector('[aria-expanded="true"], [data-expanded]')
70
+ setState("expand", expand)
71
+ if (expand) {
72
+ setState("block", true)
73
+ close()
74
+ return
75
+ }
76
+ drop(expand)
77
+ }
78
+
79
+ const arm = () => {
80
+ setState("block", true)
81
+ close()
82
+ }
83
+
84
+ const leave = () => {
85
+ if (!inside()) close()
86
+ drop()
87
+ }
88
+
89
+ createEffect(() => {
90
+ if (!ref) return
91
+ sync()
92
+ const obs = new MutationObserver(sync)
93
+ obs.observe(ref, {
94
+ subtree: true,
95
+ childList: true,
96
+ attributes: true,
97
+ attributeFilter: ["aria-expanded", "data-expanded"],
98
+ })
99
+ onCleanup(() => obs.disconnect())
100
+ })
101
+
102
+ let justClickedTrigger = false
103
+
104
+ return (
105
+ <Switch>
106
+ <Match when={local.inactive}>{local.children}</Match>
107
+ <Match when={true}>
108
+ <KobalteTooltip
109
+ gutter={4}
110
+ {...others}
111
+ closeDelay={0}
112
+ ignoreSafeArea={local.ignoreSafeArea ?? true}
113
+ open={local.forceOpen || state.open}
114
+ onOpenChange={(open) => {
115
+ if (local.forceOpen) return
116
+ if (state.block && open) return
117
+ if (justClickedTrigger) {
118
+ justClickedTrigger = false
119
+ return
120
+ }
121
+ setState("open", open)
122
+ }}
123
+ >
124
+ <KobalteTooltip.Trigger
125
+ ref={ref}
126
+ as={"div"}
127
+ data-component="tooltip-trigger"
128
+ class={local.class}
129
+ onPointerDownCapture={arm}
130
+ onKeyDownCapture={(event: KeyboardEvent) => {
131
+ if (event.key !== "Enter" && event.key !== " ") return
132
+ arm()
133
+ }}
134
+ onPointerLeave={leave}
135
+ onFocusOut={() => requestAnimationFrame(() => drop())}
136
+ >
137
+ {local.children}
138
+ </KobalteTooltip.Trigger>
139
+ <KobalteTooltip.Portal>
140
+ <KobalteTooltip.Content
141
+ data-component="tooltip"
142
+ data-placement={props.placement}
143
+ data-force-open={local.forceOpen}
144
+ class={local.contentClass}
145
+ style={local.contentStyle}
146
+ onPointerDownOutside={(e) => {
147
+ if (ref === e.target || (e.target instanceof Node && ref?.contains(e.target))) {
148
+ justClickedTrigger = true
149
+ }
150
+ e.preventDefault()
151
+ }}
152
+ >
153
+ {local.value}
154
+ {/* <KobalteTooltip.Arrow data-slot="tooltip-arrow" /> */}
155
+ </KobalteTooltip.Content>
156
+ </KobalteTooltip.Portal>
157
+ </KobalteTooltip>
158
+ </Match>
159
+ </Switch>
160
+ )
161
+ }
@@ -0,0 +1,14 @@
1
+ @keyframes blink {
2
+ 0%,
3
+ 50% {
4
+ opacity: 1;
5
+ }
6
+ 51%,
7
+ 100% {
8
+ opacity: 0;
9
+ }
10
+ }
11
+
12
+ .blinking-cursor {
13
+ animation: blink 1s step-end infinite;
14
+ }
@@ -0,0 +1,55 @@
1
+ import { createEffect, onCleanup, Show, type ValidComponent } from "solid-js"
2
+ import { createStore } from "solid-js/store"
3
+ import { Dynamic } from "solid-js/web"
4
+
5
+ export const Typewriter = <T extends ValidComponent = "p">(props: { text?: string; class?: string; as?: T }) => {
6
+ const [store, setStore] = createStore({
7
+ typing: false,
8
+ displayed: "",
9
+ cursor: true,
10
+ })
11
+
12
+ createEffect(() => {
13
+ const text = props.text
14
+ if (!text) return
15
+
16
+ let i = 0
17
+ const timeouts: ReturnType<typeof setTimeout>[] = []
18
+ setStore("typing", true)
19
+ setStore("displayed", "")
20
+ setStore("cursor", true)
21
+
22
+ const getTypingDelay = () => {
23
+ const random = Math.random()
24
+ if (random < 0.05) return 150 + Math.random() * 100
25
+ if (random < 0.15) return 80 + Math.random() * 60
26
+ return 30 + Math.random() * 50
27
+ }
28
+
29
+ const type = () => {
30
+ if (i < text.length) {
31
+ setStore("displayed", text.slice(0, i + 1))
32
+ i++
33
+ timeouts.push(setTimeout(type, getTypingDelay()))
34
+ } else {
35
+ setStore("typing", false)
36
+ timeouts.push(setTimeout(() => setStore("cursor", false), 2000))
37
+ }
38
+ }
39
+
40
+ timeouts.push(setTimeout(type, 200))
41
+
42
+ onCleanup(() => {
43
+ for (const timeout of timeouts) clearTimeout(timeout)
44
+ })
45
+ })
46
+
47
+ return (
48
+ <Dynamic component={props.as || "p"} class={props.class}>
49
+ {store.displayed}
50
+ <Show when={store.cursor}>
51
+ <span classList={{ "blinking-cursor": !store.typing }}>│</span>
52
+ </Show>
53
+ </Dynamic>
54
+ )
55
+ }
@@ -0,0 +1,197 @@
1
+ import {
2
+ createContext,
3
+ createEffect,
4
+ createRoot,
5
+ createSignal,
6
+ getOwner,
7
+ onCleanup,
8
+ type Owner,
9
+ type ParentProps,
10
+ runWithOwner,
11
+ useContext,
12
+ type JSX,
13
+ startTransition,
14
+ For,
15
+ } from "solid-js"
16
+ import { Dialog as Kobalte } from "@kobalte/core/dialog"
17
+ import { makeEventListener } from "@solid-primitives/event-listener"
18
+
19
+ type DialogElement = () => JSX.Element
20
+
21
+ type Active = {
22
+ id: string
23
+ node: JSX.Element
24
+ dispose: () => void
25
+ owner: Owner
26
+ onClose?: () => void
27
+ setClosing: (closing: boolean) => void
28
+ }
29
+
30
+ const Context = createContext<ReturnType<typeof init>>()
31
+
32
+ function init() {
33
+ const [stack, setStack] = createSignal<Active[]>([])
34
+ const timer = { current: undefined as ReturnType<typeof setTimeout> | undefined }
35
+ const lock = { value: false }
36
+
37
+ onCleanup(() => {
38
+ if (timer.current === undefined) return
39
+ clearTimeout(timer.current)
40
+ timer.current = undefined
41
+ })
42
+
43
+ const close = (id?: string) => {
44
+ const items = stack()
45
+ const current = id ? items.find((item) => item.id === id) : items.at(-1)
46
+ if (!current || lock.value) return
47
+ lock.value = true
48
+ current.onClose?.()
49
+ current.setClosing(true)
50
+
51
+ const closed = current.id
52
+ if (timer.current !== undefined) {
53
+ clearTimeout(timer.current)
54
+ timer.current = undefined
55
+ }
56
+
57
+ timer.current = setTimeout(() => {
58
+ timer.current = undefined
59
+ current.dispose()
60
+ setStack((items) => items.filter((item) => item.id !== closed))
61
+ lock.value = false
62
+ }, 100)
63
+ }
64
+
65
+ createEffect(() => {
66
+ if (stack().length === 0) return
67
+
68
+ const onKeyDown = (event: KeyboardEvent) => {
69
+ if (event.key !== "Escape") return
70
+ close()
71
+ event.preventDefault()
72
+ event.stopPropagation()
73
+ }
74
+
75
+ makeEventListener(window, "keydown", onKeyDown, { capture: true })
76
+ })
77
+
78
+ const mount = (element: DialogElement, owner: Owner, onClose: (() => void) | undefined, layer: number) => {
79
+ const id = Math.random().toString(36).slice(2)
80
+ const zIndex = 50 + layer * 10
81
+ let dispose: (() => void) | undefined
82
+ let setClosing: ((closing: boolean) => void) | undefined
83
+
84
+ const node = runWithOwner(owner, () =>
85
+ createRoot((d: () => void) => {
86
+ dispose = d
87
+ const [closing, setClosingSignal] = createSignal(false)
88
+ setClosing = setClosingSignal
89
+ return (
90
+ <Kobalte
91
+ modal
92
+ open={!closing()}
93
+ onOpenChange={(open: boolean) => {
94
+ if (open) return
95
+ close(id)
96
+ }}
97
+ >
98
+ <Kobalte.Portal>
99
+ <Kobalte.Overlay
100
+ data-component="dialog-overlay"
101
+ style={{ "z-index": String(zIndex) }}
102
+ onClick={() => close(id)}
103
+ />
104
+ <div
105
+ data-dialog-layer={layer}
106
+ style={{
107
+ position: "fixed",
108
+ inset: "0",
109
+ "z-index": String(zIndex),
110
+ display: "flex",
111
+ "align-items": "center",
112
+ "justify-content": "center",
113
+ "pointer-events": "none",
114
+ }}
115
+ >
116
+ {element()}
117
+ </div>
118
+ </Kobalte.Portal>
119
+ </Kobalte>
120
+ )
121
+ }),
122
+ )
123
+
124
+ if (!dispose || !setClosing) return
125
+
126
+ const active: Active = { id, node, dispose, owner, onClose, setClosing }
127
+ setStack((items) => [...items, active])
128
+ }
129
+
130
+ const push = (element: DialogElement, owner: Owner, onClose?: () => void) => {
131
+ if (timer.current !== undefined) {
132
+ clearTimeout(timer.current)
133
+ timer.current = undefined
134
+ }
135
+ lock.value = false
136
+ mount(element, owner, onClose, stack().length)
137
+ }
138
+
139
+ const show = (element: DialogElement, owner: Owner, onClose?: () => void) => {
140
+ for (const item of stack()) item.dispose()
141
+ setStack([])
142
+ if (timer.current !== undefined) {
143
+ clearTimeout(timer.current)
144
+ timer.current = undefined
145
+ }
146
+ lock.value = false
147
+ mount(element, owner, onClose, 0)
148
+ }
149
+
150
+ return {
151
+ stack,
152
+ close,
153
+ show,
154
+ push,
155
+ }
156
+ }
157
+
158
+ export function DialogProvider(props: ParentProps) {
159
+ const ctx = init()
160
+ return (
161
+ <Context.Provider value={ctx}>
162
+ {props.children}
163
+ <div data-component="dialog-stack">
164
+ <For each={ctx.stack()}>{(item) => item.node}</For>
165
+ </div>
166
+ </Context.Provider>
167
+ )
168
+ }
169
+
170
+ export function useDialog() {
171
+ const ctx = useContext(Context)
172
+ const owner = getOwner()
173
+
174
+ if (!owner) {
175
+ throw new Error("useDialog must be used within a DialogProvider")
176
+ }
177
+ if (!ctx) {
178
+ throw new Error("useDialog must be used within a DialogProvider")
179
+ }
180
+
181
+ return {
182
+ get active() {
183
+ return ctx.stack().at(-1)
184
+ },
185
+ show(element: DialogElement, onClose?: () => void) {
186
+ const base = ctx.stack().at(-1)?.owner ?? owner
187
+ return startTransition(() => ctx.show(element, base, onClose))
188
+ },
189
+ push(element: DialogElement, onClose?: () => void) {
190
+ const base = ctx.stack().at(-1)?.owner ?? owner
191
+ return startTransition(() => ctx.push(element, base, onClose))
192
+ },
193
+ close() {
194
+ ctx.close()
195
+ },
196
+ }
197
+ }
@@ -0,0 +1,10 @@
1
+ import type { ValidComponent } from "solid-js"
2
+ import { createSimpleContext } from "./helper"
3
+
4
+ const ctx = createSimpleContext<ValidComponent, { component: ValidComponent }>({
5
+ name: "FileComponent",
6
+ init: (props) => props.component,
7
+ })
8
+
9
+ export const FileComponentProvider = ctx.provider
10
+ export const useFileComponent = ctx.use