@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.
- package/LICENSE +21 -0
- package/package.json +110 -0
- package/src/assets/audio/alert-01.aac +0 -0
- package/src/assets/audio/alert-01.mp3 +0 -0
- package/src/assets/audio/alert-02.aac +0 -0
- package/src/assets/audio/alert-02.mp3 +0 -0
- package/src/assets/audio/alert-03.aac +0 -0
- package/src/assets/audio/alert-03.mp3 +0 -0
- package/src/assets/audio/alert-04.aac +0 -0
- package/src/assets/audio/alert-04.mp3 +0 -0
- package/src/assets/audio/alert-05.aac +0 -0
- package/src/assets/audio/alert-05.mp3 +0 -0
- package/src/assets/audio/alert-06.aac +0 -0
- package/src/assets/audio/alert-06.mp3 +0 -0
- package/src/assets/audio/alert-07.aac +0 -0
- package/src/assets/audio/alert-07.mp3 +0 -0
- package/src/assets/audio/alert-08.aac +0 -0
- package/src/assets/audio/alert-08.mp3 +0 -0
- package/src/assets/audio/alert-09.aac +0 -0
- package/src/assets/audio/alert-09.mp3 +0 -0
- package/src/assets/audio/alert-10.aac +0 -0
- package/src/assets/audio/alert-10.mp3 +0 -0
- package/src/assets/audio/bip-bop-01.aac +0 -0
- package/src/assets/audio/bip-bop-01.mp3 +0 -0
- package/src/assets/audio/bip-bop-02.aac +0 -0
- package/src/assets/audio/bip-bop-02.mp3 +0 -0
- package/src/assets/audio/bip-bop-03.aac +0 -0
- package/src/assets/audio/bip-bop-03.mp3 +0 -0
- package/src/assets/audio/bip-bop-04.aac +0 -0
- package/src/assets/audio/bip-bop-04.mp3 +0 -0
- package/src/assets/audio/bip-bop-05.aac +0 -0
- package/src/assets/audio/bip-bop-05.mp3 +0 -0
- package/src/assets/audio/bip-bop-06.aac +0 -0
- package/src/assets/audio/bip-bop-06.mp3 +0 -0
- package/src/assets/audio/bip-bop-07.aac +0 -0
- package/src/assets/audio/bip-bop-07.mp3 +0 -0
- package/src/assets/audio/bip-bop-08.aac +0 -0
- package/src/assets/audio/bip-bop-08.mp3 +0 -0
- package/src/assets/audio/bip-bop-09.aac +0 -0
- package/src/assets/audio/bip-bop-09.mp3 +0 -0
- package/src/assets/audio/bip-bop-10.aac +0 -0
- package/src/assets/audio/bip-bop-10.mp3 +0 -0
- package/src/assets/audio/nope-01.aac +0 -0
- package/src/assets/audio/nope-01.mp3 +0 -0
- package/src/assets/audio/nope-02.aac +0 -0
- package/src/assets/audio/nope-02.mp3 +0 -0
- package/src/assets/audio/nope-03.aac +0 -0
- package/src/assets/audio/nope-03.mp3 +0 -0
- package/src/assets/audio/nope-04.aac +0 -0
- package/src/assets/audio/nope-04.mp3 +0 -0
- package/src/assets/audio/nope-05.aac +0 -0
- package/src/assets/audio/nope-05.mp3 +0 -0
- package/src/assets/audio/nope-06.aac +0 -0
- package/src/assets/audio/nope-06.mp3 +0 -0
- package/src/assets/audio/nope-07.aac +0 -0
- package/src/assets/audio/nope-07.mp3 +0 -0
- package/src/assets/audio/nope-08.aac +0 -0
- package/src/assets/audio/nope-08.mp3 +0 -0
- package/src/assets/audio/nope-09.aac +0 -0
- package/src/assets/audio/nope-09.mp3 +0 -0
- package/src/assets/audio/nope-10.aac +0 -0
- package/src/assets/audio/nope-10.mp3 +0 -0
- package/src/assets/audio/nope-11.aac +0 -0
- package/src/assets/audio/nope-11.mp3 +0 -0
- package/src/assets/audio/nope-12.aac +0 -0
- package/src/assets/audio/nope-12.mp3 +0 -0
- package/src/assets/audio/staplebops-01.aac +0 -0
- package/src/assets/audio/staplebops-01.mp3 +0 -0
- package/src/assets/audio/staplebops-02.aac +0 -0
- package/src/assets/audio/staplebops-02.mp3 +0 -0
- package/src/assets/audio/staplebops-03.aac +0 -0
- package/src/assets/audio/staplebops-03.mp3 +0 -0
- package/src/assets/audio/staplebops-04.aac +0 -0
- package/src/assets/audio/staplebops-04.mp3 +0 -0
- package/src/assets/audio/staplebops-05.aac +0 -0
- package/src/assets/audio/staplebops-05.mp3 +0 -0
- package/src/assets/audio/staplebops-06.aac +0 -0
- package/src/assets/audio/staplebops-06.mp3 +0 -0
- package/src/assets/audio/staplebops-07.aac +0 -0
- package/src/assets/audio/staplebops-07.mp3 +0 -0
- package/src/assets/audio/yup-01.aac +0 -0
- package/src/assets/audio/yup-01.mp3 +0 -0
- package/src/assets/audio/yup-02.aac +0 -0
- package/src/assets/audio/yup-02.mp3 +0 -0
- package/src/assets/audio/yup-03.aac +0 -0
- package/src/assets/audio/yup-03.mp3 +0 -0
- package/src/assets/audio/yup-04.aac +0 -0
- package/src/assets/audio/yup-04.mp3 +0 -0
- package/src/assets/audio/yup-05.aac +0 -0
- package/src/assets/audio/yup-05.mp3 +0 -0
- package/src/assets/audio/yup-06.aac +0 -0
- package/src/assets/audio/yup-06.mp3 +0 -0
- package/src/assets/fonts/Inter.ttf +0 -0
- package/src/assets/fonts/JetBrainsMonoNerdFontMono-Regular.woff2 +0 -0
- package/src/assets/icons/app/android-studio.svg +369 -0
- package/src/assets/icons/app/antigravity.svg +97 -0
- package/src/assets/icons/app/cursor.svg +16 -0
- package/src/assets/icons/app/file-explorer.svg +20 -0
- package/src/assets/icons/app/finder.png +0 -0
- package/src/assets/icons/app/ghostty.svg +13 -0
- package/src/assets/icons/app/iterm2.svg +13 -0
- package/src/assets/icons/app/powershell.svg +14 -0
- package/src/assets/icons/app/sublimetext.svg +17 -0
- package/src/assets/icons/app/terminal.png +0 -0
- package/src/assets/icons/app/textmate.png +0 -0
- package/src/assets/icons/app/vscode.svg +39 -0
- package/src/assets/icons/app/warp.png +0 -0
- package/src/assets/icons/app/xcode.png +0 -0
- package/src/assets/icons/app/zed-dark.svg +15 -0
- package/src/assets/icons/app/zed.svg +15 -0
- package/src/components/accordion.css +123 -0
- package/src/components/accordion.tsx +92 -0
- package/src/components/animated-number.css +75 -0
- package/src/components/animated-number.tsx +109 -0
- package/src/components/app-icon.css +5 -0
- package/src/components/app-icon.tsx +85 -0
- package/src/components/app-icons/sprite.svg +114 -0
- package/src/components/app-icons/types.ts +21 -0
- package/src/components/avatar.css +49 -0
- package/src/components/avatar.tsx +55 -0
- package/src/components/button.css +194 -0
- package/src/components/button.tsx +33 -0
- package/src/components/card.css +94 -0
- package/src/components/card.tsx +123 -0
- package/src/components/checkbox.css +131 -0
- package/src/components/checkbox.tsx +43 -0
- package/src/components/collapsible.css +148 -0
- package/src/components/collapsible.tsx +48 -0
- package/src/components/context-menu.css +134 -0
- package/src/components/context-menu.tsx +308 -0
- package/src/components/dialog.css +181 -0
- package/src/components/dialog.tsx +72 -0
- package/src/components/diff-changes.css +42 -0
- package/src/components/diff-changes.tsx +115 -0
- package/src/components/dock-surface.css +23 -0
- package/src/components/dock-surface.tsx +54 -0
- package/src/components/dropdown-menu.css +135 -0
- package/src/components/dropdown-menu.tsx +308 -0
- package/src/components/favicon.tsx +13 -0
- package/src/components/file-icon.css +26 -0
- package/src/components/file-icon.tsx +588 -0
- package/src/components/file-icons/sprite.svg +11707 -0
- package/src/components/file-icons/types.ts +1095 -0
- package/src/components/font.tsx +1 -0
- package/src/components/hover-card.css +61 -0
- package/src/components/hover-card.tsx +32 -0
- package/src/components/icon-button.css +181 -0
- package/src/components/icon-button.tsx +29 -0
- package/src/components/icon.css +34 -0
- package/src/components/icon.tsx +169 -0
- package/src/components/image-preview.css +63 -0
- package/src/components/image-preview.tsx +32 -0
- package/src/components/inline-input.css +17 -0
- package/src/components/inline-input.tsx +22 -0
- package/src/components/keybind.css +18 -0
- package/src/components/keybind.tsx +20 -0
- package/src/components/list.css +331 -0
- package/src/components/list.tsx +394 -0
- package/src/components/logo.css +4 -0
- package/src/components/logo.tsx +62 -0
- package/src/components/motion-spring.tsx +58 -0
- package/src/components/popover.css +98 -0
- package/src/components/popover.tsx +153 -0
- package/src/components/progress-circle.css +12 -0
- package/src/components/progress-circle.tsx +57 -0
- package/src/components/progress.css +63 -0
- package/src/components/progress.tsx +39 -0
- package/src/components/provider-icon.css +5 -0
- package/src/components/provider-icon.tsx +25 -0
- package/src/components/provider-icons/sprite.svg +1135 -0
- package/src/components/provider-icons/types.ts +105 -0
- package/src/components/radio-group.css +187 -0
- package/src/components/radio-group.tsx +83 -0
- package/src/components/resize-handle.css +58 -0
- package/src/components/resize-handle.tsx +82 -0
- package/src/components/scroll-view.css +66 -0
- package/src/components/scroll-view.tsx +250 -0
- package/src/components/select.css +202 -0
- package/src/components/select.tsx +174 -0
- package/src/components/spinner.css +6 -0
- package/src/components/spinner.tsx +52 -0
- package/src/components/sticky-accordion-header.css +6 -0
- package/src/components/sticky-accordion-header.tsx +18 -0
- package/src/components/switch.css +132 -0
- package/src/components/switch.tsx +29 -0
- package/src/components/tabs.css +635 -0
- package/src/components/tabs.tsx +125 -0
- package/src/components/tag.css +37 -0
- package/src/components/tag.tsx +22 -0
- package/src/components/text-field.css +134 -0
- package/src/components/text-field.tsx +128 -0
- package/src/components/text-reveal.css +150 -0
- package/src/components/text-reveal.tsx +143 -0
- package/src/components/text-shimmer.css +119 -0
- package/src/components/text-shimmer.tsx +62 -0
- package/src/components/text-strikethrough.css +27 -0
- package/src/components/text-strikethrough.tsx +84 -0
- package/src/components/toast.css +236 -0
- package/src/components/toast.tsx +185 -0
- package/src/components/tooltip.css +74 -0
- package/src/components/tooltip.tsx +161 -0
- package/src/components/typewriter.css +14 -0
- package/src/components/typewriter.tsx +55 -0
- package/src/context/dialog.tsx +197 -0
- package/src/context/file.tsx +10 -0
- package/src/context/helper.tsx +38 -0
- package/src/context/i18n.tsx +38 -0
- package/src/context/index.ts +4 -0
- package/src/context/marked.tsx +522 -0
- package/src/context/worker-pool.tsx +20 -0
- package/src/custom-elements.d.ts +17 -0
- package/src/hooks/create-auto-scroll.tsx +237 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-filtered-list.tsx +134 -0
- package/src/i18n/ar.ts +168 -0
- package/src/i18n/br.ts +168 -0
- package/src/i18n/bs.ts +172 -0
- package/src/i18n/da.ts +167 -0
- package/src/i18n/de.ts +173 -0
- package/src/i18n/en.ts +176 -0
- package/src/i18n/es.ts +168 -0
- package/src/i18n/fr.ts +168 -0
- package/src/i18n/ja.ts +167 -0
- package/src/i18n/ko.ts +168 -0
- package/src/i18n/no.ts +171 -0
- package/src/i18n/pl.ts +167 -0
- package/src/i18n/ru.ts +167 -0
- package/src/i18n/th.ts +169 -0
- package/src/i18n/tr.ts +174 -0
- package/src/i18n/uk.ts +167 -0
- package/src/i18n/zh.ts +171 -0
- package/src/i18n/zht.ts +171 -0
- package/src/storybook/fixtures.ts +51 -0
- package/src/storybook/scaffold.tsx +62 -0
- package/src/styles/animations.css +141 -0
- package/src/styles/base.css +404 -0
- package/src/styles/colors.css +772 -0
- package/src/styles/index.css +53 -0
- package/src/styles/tailwind/colors.css +285 -0
- package/src/styles/tailwind/index.css +78 -0
- package/src/styles/tailwind/utilities.css +131 -0
- package/src/styles/theme.css +609 -0
- package/src/styles/utilities.css +118 -0
- package/src/theme/color.ts +299 -0
- package/src/theme/context.tsx +370 -0
- package/src/theme/default-themes.ts +116 -0
- package/src/theme/index.ts +78 -0
- package/src/theme/loader.ts +112 -0
- package/src/theme/resolve.ts +540 -0
- package/src/theme/themes/amoled.json +49 -0
- package/src/theme/themes/aura.json +51 -0
- package/src/theme/themes/ayu.json +51 -0
- package/src/theme/themes/carbonfox.json +53 -0
- package/src/theme/themes/catppuccin-frappe.json +85 -0
- package/src/theme/themes/catppuccin-macchiato.json +85 -0
- package/src/theme/themes/catppuccin.json +45 -0
- package/src/theme/themes/cobalt2.json +87 -0
- package/src/theme/themes/cursor.json +91 -0
- package/src/theme/themes/dracula.json +49 -0
- package/src/theme/themes/everforest.json +89 -0
- package/src/theme/themes/flexoki.json +86 -0
- package/src/theme/themes/github.json +85 -0
- package/src/theme/themes/gruvbox.json +45 -0
- package/src/theme/themes/kanagawa.json +89 -0
- package/src/theme/themes/lucent-orng.json +87 -0
- package/src/theme/themes/material.json +87 -0
- package/src/theme/themes/matrix.json +113 -0
- package/src/theme/themes/mercury.json +86 -0
- package/src/theme/themes/monokai.json +49 -0
- package/src/theme/themes/nightowl.json +46 -0
- package/src/theme/themes/nord.json +46 -0
- package/src/theme/themes/oc-2.json +468 -0
- package/src/theme/themes/one-dark.json +89 -0
- package/src/theme/themes/onedarkpro.json +45 -0
- package/src/theme/themes/opencode.json +89 -0
- package/src/theme/themes/orng.json +87 -0
- package/src/theme/themes/osaka-jade.json +88 -0
- package/src/theme/themes/palenight.json +85 -0
- package/src/theme/themes/rosepine.json +85 -0
- package/src/theme/themes/shadesofpurple.json +51 -0
- package/src/theme/themes/solarized.json +49 -0
- package/src/theme/themes/synthwave84.json +87 -0
- package/src/theme/themes/tokyonight.json +47 -0
- package/src/theme/themes/vercel.json +90 -0
- package/src/theme/themes/vesper.json +51 -0
- package/src/theme/themes/zenburn.json +87 -0
- package/src/theme/types.ts +75 -0
- package/src/theme/v2/avatar.ts +48 -0
- package/src/theme/v2/default-primitives.ts +114 -0
- package/src/theme/v2/foreground.ts +60 -0
- package/src/theme/v2/mapping.ts +138 -0
- package/src/theme/v2/resolve.ts +153 -0
- package/src/v2/components/accordion-v2.css +139 -0
- package/src/v2/components/accordion-v2.tsx +86 -0
- package/src/v2/components/avatar-v2.css +70 -0
- package/src/v2/components/avatar-v2.tsx +59 -0
- package/src/v2/components/badge-v2.css +27 -0
- package/src/v2/components/badge-v2.tsx +20 -0
- package/src/v2/components/button-v2.css +186 -0
- package/src/v2/components/button-v2.tsx +35 -0
- package/src/v2/components/checkbox-v2.css +184 -0
- package/src/v2/components/checkbox-v2.tsx +65 -0
- package/src/v2/components/dialog-v2.css +150 -0
- package/src/v2/components/dialog-v2.tsx +93 -0
- package/src/v2/components/diff-changes-v2.css +24 -0
- package/src/v2/components/diff-changes-v2.tsx +28 -0
- package/src/v2/components/field-v2.css +94 -0
- package/src/v2/components/field-v2.tsx +265 -0
- package/src/v2/components/icon-button-v2.css +155 -0
- package/src/v2/components/icon-button-v2.tsx +37 -0
- package/src/v2/components/icon.tsx +129 -0
- package/src/v2/components/inline-input-v2.css +218 -0
- package/src/v2/components/inline-input-v2.tsx +90 -0
- package/src/v2/components/keybind-v2.css +76 -0
- package/src/v2/components/keybind-v2.tsx +30 -0
- package/src/v2/components/line-comment-v2.css +204 -0
- package/src/v2/components/line-comment-v2.tsx +155 -0
- package/src/v2/components/menu-v2.css +190 -0
- package/src/v2/components/menu-v2.tsx +225 -0
- package/src/v2/components/project-avatar-v2.css +126 -0
- package/src/v2/components/project-avatar-v2.tsx +64 -0
- package/src/v2/components/radio-v2.css +202 -0
- package/src/v2/components/radio-v2.tsx +72 -0
- package/src/v2/components/segmented-control-v2.css +80 -0
- package/src/v2/components/segmented-control-v2.tsx +208 -0
- package/src/v2/components/select-v2.css +285 -0
- package/src/v2/components/select-v2.tsx +208 -0
- package/src/v2/components/switch-v2.css +154 -0
- package/src/v2/components/switch-v2.tsx +28 -0
- package/src/v2/components/tab-state-indicator.tsx +37 -0
- package/src/v2/components/tabs-v2.css +225 -0
- package/src/v2/components/tabs-v2.tsx +147 -0
- package/src/v2/components/text-input-v2.css +145 -0
- package/src/v2/components/text-input-v2.tsx +67 -0
- package/src/v2/components/text-shimmer-v2.css +125 -0
- package/src/v2/components/text-shimmer-v2.tsx +63 -0
- package/src/v2/components/textarea-v2.css +78 -0
- package/src/v2/components/textarea-v2.tsx +31 -0
- package/src/v2/components/toast-v2.css +215 -0
- package/src/v2/components/toast-v2.tsx +144 -0
- package/src/v2/components/tooltip-v2.css +53 -0
- package/src/v2/components/tooltip-v2.tsx +146 -0
- package/src/v2/components/wordmark-v2.tsx +92 -0
- package/src/v2/styles/colors.css +172 -0
- package/src/v2/styles/tailwind.css +2 -0
- package/src/v2/styles/theme.css +441 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { onMount, splitProps, type ComponentProps, Show, mergeProps } from "solid-js"
|
|
2
|
+
import { createResizeObserver } from "@solid-primitives/resize-observer"
|
|
3
|
+
import { createStore } from "solid-js/store"
|
|
4
|
+
import { useI18n } from "../context/i18n"
|
|
5
|
+
|
|
6
|
+
export interface ScrollViewProps extends ComponentProps<"div"> {
|
|
7
|
+
viewportRef?: (el: HTMLDivElement) => void
|
|
8
|
+
orientation?: "vertical" | "horizontal" // currently only vertical is fully implemented for thumb
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const scrollKey = (event: Pick<KeyboardEvent, "key" | "altKey" | "ctrlKey" | "metaKey" | "shiftKey">) => {
|
|
12
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return
|
|
13
|
+
|
|
14
|
+
switch (event.key) {
|
|
15
|
+
case "PageDown":
|
|
16
|
+
return "page-down"
|
|
17
|
+
case "PageUp":
|
|
18
|
+
return "page-up"
|
|
19
|
+
case "Home":
|
|
20
|
+
return "home"
|
|
21
|
+
case "End":
|
|
22
|
+
return "end"
|
|
23
|
+
case "ArrowUp":
|
|
24
|
+
return "up"
|
|
25
|
+
case "ArrowDown":
|
|
26
|
+
return "down"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function scrollTopFromThumbPointer(input: {
|
|
31
|
+
pointer: number
|
|
32
|
+
viewportTop: number
|
|
33
|
+
grabOffset: number
|
|
34
|
+
clientHeight: number
|
|
35
|
+
scrollHeight: number
|
|
36
|
+
thumbHeight: number
|
|
37
|
+
}) {
|
|
38
|
+
const padding = 8
|
|
39
|
+
const maxThumbTop = input.clientHeight - padding * 2 - input.thumbHeight
|
|
40
|
+
if (maxThumbTop <= 0) return 0
|
|
41
|
+
const thumbTop = Math.max(0, Math.min(input.pointer - input.viewportTop - padding - input.grabOffset, maxThumbTop))
|
|
42
|
+
return (thumbTop / maxThumbTop) * Math.max(0, input.scrollHeight - input.clientHeight)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function ScrollView(props: ScrollViewProps) {
|
|
46
|
+
const i18n = useI18n()
|
|
47
|
+
const merged = mergeProps({ orientation: "vertical" }, props)
|
|
48
|
+
const [local, events, rest] = splitProps(
|
|
49
|
+
merged,
|
|
50
|
+
["class", "children", "viewportRef", "orientation", "style"],
|
|
51
|
+
[
|
|
52
|
+
"onScroll",
|
|
53
|
+
"onWheel",
|
|
54
|
+
"onTouchStart",
|
|
55
|
+
"onTouchMove",
|
|
56
|
+
"onTouchEnd",
|
|
57
|
+
"onTouchCancel",
|
|
58
|
+
"onPointerDown",
|
|
59
|
+
"onClick",
|
|
60
|
+
"onKeyDown",
|
|
61
|
+
],
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
let rootRef!: HTMLDivElement
|
|
65
|
+
let viewportRef!: HTMLDivElement
|
|
66
|
+
let thumbRef!: HTMLDivElement
|
|
67
|
+
|
|
68
|
+
const [state, setState] = createStore({
|
|
69
|
+
isHovered: false,
|
|
70
|
+
isDragging: false,
|
|
71
|
+
thumbHeight: 0,
|
|
72
|
+
thumbTop: 0,
|
|
73
|
+
showThumb: false,
|
|
74
|
+
})
|
|
75
|
+
const isHovered = () => state.isHovered
|
|
76
|
+
const isDragging = () => state.isDragging
|
|
77
|
+
const thumbHeight = () => state.thumbHeight
|
|
78
|
+
const thumbTop = () => state.thumbTop
|
|
79
|
+
const showThumb = () => state.showThumb
|
|
80
|
+
|
|
81
|
+
const updateThumb = () => {
|
|
82
|
+
if (!viewportRef) return
|
|
83
|
+
const { scrollTop, scrollHeight, clientHeight } = viewportRef
|
|
84
|
+
|
|
85
|
+
if (scrollHeight <= clientHeight || scrollHeight === 0) {
|
|
86
|
+
setState("showThumb", false)
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
setState("showThumb", true)
|
|
91
|
+
const trackPadding = 8
|
|
92
|
+
const trackHeight = clientHeight - trackPadding * 2
|
|
93
|
+
|
|
94
|
+
const minThumbHeight = 32
|
|
95
|
+
// Calculate raw thumb height based on ratio
|
|
96
|
+
let height = (clientHeight / scrollHeight) * trackHeight
|
|
97
|
+
height = Math.max(height, minThumbHeight)
|
|
98
|
+
|
|
99
|
+
const maxScrollTop = scrollHeight - clientHeight
|
|
100
|
+
const maxThumbTop = trackHeight - height
|
|
101
|
+
|
|
102
|
+
const top = maxScrollTop > 0 ? (scrollTop / maxScrollTop) * maxThumbTop : 0
|
|
103
|
+
|
|
104
|
+
// Ensure thumb stays within bounds (shouldn't be necessary due to math above, but good for safety)
|
|
105
|
+
const boundedTop = trackPadding + Math.max(0, Math.min(top, maxThumbTop))
|
|
106
|
+
|
|
107
|
+
setState("thumbHeight", height)
|
|
108
|
+
setState("thumbTop", boundedTop)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
onMount(() => {
|
|
112
|
+
if (local.viewportRef) {
|
|
113
|
+
local.viewportRef(viewportRef)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
createResizeObserver([viewportRef, viewportRef.firstElementChild], updateThumb)
|
|
117
|
+
|
|
118
|
+
updateThumb()
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
const onThumbPointerDown = (e: PointerEvent) => {
|
|
122
|
+
e.preventDefault()
|
|
123
|
+
e.stopPropagation()
|
|
124
|
+
setState("isDragging", true)
|
|
125
|
+
const grabOffset = e.clientY - thumbRef.getBoundingClientRect().top
|
|
126
|
+
|
|
127
|
+
thumbRef.setPointerCapture(e.pointerId)
|
|
128
|
+
|
|
129
|
+
const onPointerMove = (e: PointerEvent) => {
|
|
130
|
+
const { scrollHeight, clientHeight } = viewportRef
|
|
131
|
+
viewportRef.scrollTop = scrollTopFromThumbPointer({
|
|
132
|
+
pointer: e.clientY,
|
|
133
|
+
viewportTop: viewportRef.getBoundingClientRect().top,
|
|
134
|
+
grabOffset,
|
|
135
|
+
clientHeight,
|
|
136
|
+
scrollHeight,
|
|
137
|
+
thumbHeight: thumbHeight(),
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const done = (e: PointerEvent) => {
|
|
142
|
+
setState("isDragging", false)
|
|
143
|
+
thumbRef.releasePointerCapture(e.pointerId)
|
|
144
|
+
thumbRef.removeEventListener("pointermove", onPointerMove)
|
|
145
|
+
thumbRef.removeEventListener("pointerup", done)
|
|
146
|
+
thumbRef.removeEventListener("pointercancel", done)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
thumbRef.addEventListener("pointermove", onPointerMove)
|
|
150
|
+
thumbRef.addEventListener("pointerup", done)
|
|
151
|
+
thumbRef.addEventListener("pointercancel", done)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Keybinds implementation
|
|
155
|
+
// We ensure the viewport has a tabindex so it can receive focus
|
|
156
|
+
// We can also explicitly catch PageUp/Down if we want smooth scroll or specific behavior,
|
|
157
|
+
// but native usually handles this perfectly. Let's explicitly ensure it behaves well.
|
|
158
|
+
const onKeyDown = (e: KeyboardEvent) => {
|
|
159
|
+
// If user is focused on an input inside the scroll view, don't hijack keys
|
|
160
|
+
if (document.activeElement && ["INPUT", "TEXTAREA", "SELECT"].includes(document.activeElement.tagName)) {
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const next = scrollKey(e)
|
|
165
|
+
if (!next) return
|
|
166
|
+
|
|
167
|
+
const scrollAmount = viewportRef.clientHeight * 0.8
|
|
168
|
+
const lineAmount = 40
|
|
169
|
+
|
|
170
|
+
switch (next) {
|
|
171
|
+
case "page-down":
|
|
172
|
+
e.preventDefault()
|
|
173
|
+
viewportRef.scrollBy({ top: scrollAmount, behavior: "smooth" })
|
|
174
|
+
break
|
|
175
|
+
case "page-up":
|
|
176
|
+
e.preventDefault()
|
|
177
|
+
viewportRef.scrollBy({ top: -scrollAmount, behavior: "smooth" })
|
|
178
|
+
break
|
|
179
|
+
case "home":
|
|
180
|
+
e.preventDefault()
|
|
181
|
+
viewportRef.scrollTo({ top: 0, behavior: "smooth" })
|
|
182
|
+
break
|
|
183
|
+
case "end":
|
|
184
|
+
e.preventDefault()
|
|
185
|
+
viewportRef.scrollTo({ top: viewportRef.scrollHeight, behavior: "smooth" })
|
|
186
|
+
break
|
|
187
|
+
case "up":
|
|
188
|
+
e.preventDefault()
|
|
189
|
+
viewportRef.scrollBy({ top: -lineAmount, behavior: "smooth" })
|
|
190
|
+
break
|
|
191
|
+
case "down":
|
|
192
|
+
e.preventDefault()
|
|
193
|
+
viewportRef.scrollBy({ top: lineAmount, behavior: "smooth" })
|
|
194
|
+
break
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return (
|
|
199
|
+
<div
|
|
200
|
+
ref={rootRef}
|
|
201
|
+
class={`scroll-view ${local.class || ""}`}
|
|
202
|
+
style={local.style}
|
|
203
|
+
onPointerEnter={() => setState("isHovered", true)}
|
|
204
|
+
onPointerLeave={() => setState("isHovered", false)}
|
|
205
|
+
{...rest}
|
|
206
|
+
>
|
|
207
|
+
{/* Viewport */}
|
|
208
|
+
<div
|
|
209
|
+
ref={viewportRef}
|
|
210
|
+
class="scroll-view__viewport"
|
|
211
|
+
onScroll={(e) => {
|
|
212
|
+
updateThumb()
|
|
213
|
+
if (typeof events.onScroll === "function") events.onScroll(e as any)
|
|
214
|
+
}}
|
|
215
|
+
onWheel={events.onWheel as any}
|
|
216
|
+
onTouchStart={events.onTouchStart as any}
|
|
217
|
+
onTouchMove={events.onTouchMove as any}
|
|
218
|
+
onTouchEnd={events.onTouchEnd as any}
|
|
219
|
+
onTouchCancel={events.onTouchCancel as any}
|
|
220
|
+
onPointerDown={events.onPointerDown as any}
|
|
221
|
+
onClick={events.onClick as any}
|
|
222
|
+
tabIndex={0}
|
|
223
|
+
role="region"
|
|
224
|
+
aria-label={i18n.t("ui.scrollView.ariaLabel")}
|
|
225
|
+
onKeyDown={(e) => {
|
|
226
|
+
onKeyDown(e)
|
|
227
|
+
if (typeof events.onKeyDown === "function") events.onKeyDown(e as any)
|
|
228
|
+
}}
|
|
229
|
+
>
|
|
230
|
+
{local.children}
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
{/* Thumb Overlay */}
|
|
234
|
+
<Show when={showThumb()}>
|
|
235
|
+
<div
|
|
236
|
+
ref={thumbRef}
|
|
237
|
+
onPointerDown={onThumbPointerDown}
|
|
238
|
+
class="scroll-view__thumb"
|
|
239
|
+
data-visible={isHovered() || isDragging()}
|
|
240
|
+
data-dragging={isDragging()}
|
|
241
|
+
style={{
|
|
242
|
+
height: `${thumbHeight()}px`,
|
|
243
|
+
transform: `translateY(${thumbTop()}px)`,
|
|
244
|
+
"z-index": 100, // ensure it displays over content
|
|
245
|
+
}}
|
|
246
|
+
/>
|
|
247
|
+
</Show>
|
|
248
|
+
</div>
|
|
249
|
+
)
|
|
250
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
[data-component="select"] {
|
|
2
|
+
[data-slot="select-select-trigger"] {
|
|
3
|
+
padding: 0 4px 0 8px;
|
|
4
|
+
box-shadow: none;
|
|
5
|
+
|
|
6
|
+
[data-slot="select-select-trigger-value"] {
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
text-overflow: ellipsis;
|
|
9
|
+
white-space: nowrap;
|
|
10
|
+
}
|
|
11
|
+
[data-slot="select-select-trigger-icon"] {
|
|
12
|
+
width: 16px;
|
|
13
|
+
height: 16px;
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
flex-shrink: 0;
|
|
18
|
+
color: var(--text-weak);
|
|
19
|
+
transition: transform 0.1s ease-in-out;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&[data-expanded] {
|
|
23
|
+
&[data-variant="secondary"] {
|
|
24
|
+
background-color: var(--button-secondary-hover);
|
|
25
|
+
}
|
|
26
|
+
&[data-variant="ghost"] {
|
|
27
|
+
background-color: var(--surface-raised-base-active);
|
|
28
|
+
}
|
|
29
|
+
&[data-variant="primary"] {
|
|
30
|
+
background-color: var(--icon-strong-active);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&:not([data-expanded]):focus-visible {
|
|
35
|
+
&[data-variant="secondary"] {
|
|
36
|
+
background-color: var(--button-secondary-base);
|
|
37
|
+
}
|
|
38
|
+
&[data-variant="ghost"] {
|
|
39
|
+
background-color: var(--surface-raised-base-hover);
|
|
40
|
+
}
|
|
41
|
+
&[data-variant="primary"] {
|
|
42
|
+
background-color: var(--icon-strong-base);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&[data-trigger-style="settings"] {
|
|
48
|
+
[data-slot="select-select-trigger"] {
|
|
49
|
+
padding: 6px 6px 6px 12px;
|
|
50
|
+
box-shadow: none;
|
|
51
|
+
border-radius: 6px;
|
|
52
|
+
min-width: 160px;
|
|
53
|
+
height: 32px;
|
|
54
|
+
justify-content: flex-end;
|
|
55
|
+
gap: 12px;
|
|
56
|
+
background-color: transparent;
|
|
57
|
+
|
|
58
|
+
[data-slot="select-select-trigger-value"] {
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
text-overflow: ellipsis;
|
|
61
|
+
white-space: nowrap;
|
|
62
|
+
font-size: var(--font-size-base);
|
|
63
|
+
font-weight: var(--font-weight-regular);
|
|
64
|
+
}
|
|
65
|
+
[data-slot="select-select-trigger-icon"] {
|
|
66
|
+
width: 16px;
|
|
67
|
+
height: 20px;
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
flex-shrink: 0;
|
|
72
|
+
color: var(--text-weak);
|
|
73
|
+
background-color: var(--surface-raised-base);
|
|
74
|
+
border-radius: 4px;
|
|
75
|
+
transition: transform 0.1s ease-in-out;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&[data-slot="select-select-trigger"]:hover:not(:disabled),
|
|
79
|
+
&[data-slot="select-select-trigger"][data-expanded],
|
|
80
|
+
&[data-slot="select-select-trigger"][data-expanded]:hover:not(:disabled) {
|
|
81
|
+
background-color: var(--input-base);
|
|
82
|
+
box-shadow: var(--shadow-xs-border-base);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&:not([data-expanded]):not(:focus-visible):focus {
|
|
86
|
+
background-color: transparent;
|
|
87
|
+
box-shadow: none;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[data-component="select-content"] {
|
|
94
|
+
min-width: 104px;
|
|
95
|
+
max-width: 23rem;
|
|
96
|
+
overflow: hidden;
|
|
97
|
+
border-radius: var(--radius-md);
|
|
98
|
+
background-color: var(--surface-raised-stronger-non-alpha);
|
|
99
|
+
padding: 4px;
|
|
100
|
+
box-shadow: var(--shadow-xs-border);
|
|
101
|
+
z-index: 60;
|
|
102
|
+
|
|
103
|
+
&[data-expanded] {
|
|
104
|
+
animation: select-open 0.15s ease-out;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
[data-slot="select-select-content-list"] {
|
|
108
|
+
overflow-y: auto;
|
|
109
|
+
max-height: 12rem;
|
|
110
|
+
white-space: nowrap;
|
|
111
|
+
overflow-x: hidden;
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
|
|
115
|
+
&:focus {
|
|
116
|
+
outline: none;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
> *:not([role="presentation"]) + *:not([role="presentation"]) {
|
|
120
|
+
margin-top: 2px;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
[data-slot="select-select-item"] {
|
|
125
|
+
position: relative;
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
padding: 2px 8px;
|
|
129
|
+
gap: 12px;
|
|
130
|
+
border-radius: 4px;
|
|
131
|
+
cursor: default;
|
|
132
|
+
|
|
133
|
+
/* text-12-medium */
|
|
134
|
+
font-family: var(--font-family-sans);
|
|
135
|
+
font-size: var(--font-size-small);
|
|
136
|
+
font-style: normal;
|
|
137
|
+
font-weight: var(--font-weight-medium);
|
|
138
|
+
line-height: var(--line-height-large); /* 166.667% */
|
|
139
|
+
letter-spacing: var(--letter-spacing-normal);
|
|
140
|
+
|
|
141
|
+
color: var(--text-strong);
|
|
142
|
+
|
|
143
|
+
transition:
|
|
144
|
+
background-color 0.2s ease-in-out,
|
|
145
|
+
color 0.2s ease-in-out;
|
|
146
|
+
outline: none;
|
|
147
|
+
user-select: none;
|
|
148
|
+
|
|
149
|
+
&[data-highlighted] {
|
|
150
|
+
background: var(--surface-raised-base-hover);
|
|
151
|
+
}
|
|
152
|
+
&[data-disabled] {
|
|
153
|
+
background-color: var(--surface-raised-base);
|
|
154
|
+
pointer-events: none;
|
|
155
|
+
}
|
|
156
|
+
[data-slot="select-select-item-indicator"] {
|
|
157
|
+
display: flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
justify-content: center;
|
|
160
|
+
margin-left: auto;
|
|
161
|
+
width: 16px;
|
|
162
|
+
height: 16px;
|
|
163
|
+
}
|
|
164
|
+
&:focus {
|
|
165
|
+
outline: none;
|
|
166
|
+
}
|
|
167
|
+
&:hover {
|
|
168
|
+
background: var(--surface-raised-base-hover);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
[data-component="select-content"][data-trigger-style="settings"] {
|
|
174
|
+
min-width: 160px;
|
|
175
|
+
border-radius: 8px;
|
|
176
|
+
padding: 0;
|
|
177
|
+
|
|
178
|
+
[data-slot="select-select-content-list"] {
|
|
179
|
+
padding: 4px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
[data-slot="select-select-item"] {
|
|
183
|
+
/* text-14-regular */
|
|
184
|
+
font-family: var(--font-family-sans);
|
|
185
|
+
font-size: var(--font-size-base);
|
|
186
|
+
font-style: normal;
|
|
187
|
+
font-weight: var(--font-weight-regular);
|
|
188
|
+
line-height: var(--line-height-large);
|
|
189
|
+
letter-spacing: var(--letter-spacing-normal);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
@keyframes select-open {
|
|
194
|
+
from {
|
|
195
|
+
opacity: 0;
|
|
196
|
+
transform: scale(0.95);
|
|
197
|
+
}
|
|
198
|
+
to {
|
|
199
|
+
opacity: 1;
|
|
200
|
+
transform: scale(1);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { Select as Kobalte } from "@kobalte/core/select"
|
|
2
|
+
import { createMemo, onCleanup, splitProps, type ComponentProps, type JSX } from "solid-js"
|
|
3
|
+
import { pipe, groupBy, entries, map } from "remeda"
|
|
4
|
+
import { Button, ButtonProps } from "./button"
|
|
5
|
+
import { Icon } from "./icon"
|
|
6
|
+
|
|
7
|
+
export type SelectProps<T> = Omit<ComponentProps<typeof Kobalte<T>>, "value" | "onSelect" | "children"> & {
|
|
8
|
+
placeholder?: string
|
|
9
|
+
options: T[]
|
|
10
|
+
current?: T
|
|
11
|
+
value?: (x: T) => string
|
|
12
|
+
label?: (x: T) => string
|
|
13
|
+
groupBy?: (x: T) => string
|
|
14
|
+
valueClass?: ComponentProps<"div">["class"]
|
|
15
|
+
onSelect?: (value: T | undefined) => void
|
|
16
|
+
onHighlight?: (value: T | undefined) => (() => void) | void
|
|
17
|
+
class?: ComponentProps<"div">["class"]
|
|
18
|
+
classList?: ComponentProps<"div">["classList"]
|
|
19
|
+
children?: (item: T | undefined) => JSX.Element
|
|
20
|
+
triggerStyle?: JSX.CSSProperties
|
|
21
|
+
triggerVariant?: "settings"
|
|
22
|
+
triggerProps?: Record<string, string | number | boolean | undefined>
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function Select<T>(props: SelectProps<T> & Omit<ButtonProps, "children">) {
|
|
26
|
+
const [local, others] = splitProps(props, [
|
|
27
|
+
"class",
|
|
28
|
+
"classList",
|
|
29
|
+
"placeholder",
|
|
30
|
+
"options",
|
|
31
|
+
"current",
|
|
32
|
+
"value",
|
|
33
|
+
"label",
|
|
34
|
+
"groupBy",
|
|
35
|
+
"valueClass",
|
|
36
|
+
"onSelect",
|
|
37
|
+
"onHighlight",
|
|
38
|
+
"onOpenChange",
|
|
39
|
+
"children",
|
|
40
|
+
"triggerStyle",
|
|
41
|
+
"triggerVariant",
|
|
42
|
+
"triggerProps",
|
|
43
|
+
])
|
|
44
|
+
|
|
45
|
+
const state = {
|
|
46
|
+
key: undefined as string | undefined,
|
|
47
|
+
cleanup: undefined as (() => void) | void,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const stop = () => {
|
|
51
|
+
state.cleanup?.()
|
|
52
|
+
state.cleanup = undefined
|
|
53
|
+
state.key = undefined
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const keyFor = (item: T) => (local.value ? local.value(item) : (item as string))
|
|
57
|
+
|
|
58
|
+
const move = (item: T | undefined) => {
|
|
59
|
+
if (!local.onHighlight) return
|
|
60
|
+
if (!item) {
|
|
61
|
+
stop()
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const key = keyFor(item)
|
|
66
|
+
if (state.key === key) return
|
|
67
|
+
state.cleanup?.()
|
|
68
|
+
state.cleanup = local.onHighlight(item)
|
|
69
|
+
state.key = key
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
onCleanup(stop)
|
|
73
|
+
|
|
74
|
+
const grouped = createMemo(() => {
|
|
75
|
+
const result = pipe(
|
|
76
|
+
local.options,
|
|
77
|
+
groupBy((x) => (local.groupBy ? local.groupBy(x) : "")),
|
|
78
|
+
// mapValues((x) => x.sort((a, b) => a.title.localeCompare(b.title))),
|
|
79
|
+
entries(),
|
|
80
|
+
map(([k, v]) => ({ category: k, options: v })),
|
|
81
|
+
)
|
|
82
|
+
return result
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
<Kobalte<T, { category: string; options: T[] }>
|
|
88
|
+
{...others}
|
|
89
|
+
data-component="select"
|
|
90
|
+
data-trigger-style={local.triggerVariant}
|
|
91
|
+
placement={local.triggerVariant === "settings" ? "bottom-end" : "bottom-start"}
|
|
92
|
+
gutter={4}
|
|
93
|
+
value={local.current}
|
|
94
|
+
options={grouped()}
|
|
95
|
+
optionValue={(x) => (local.value ? local.value(x) : (x as string))}
|
|
96
|
+
optionTextValue={(x) => (local.label ? local.label(x) : (x as string))}
|
|
97
|
+
optionGroupChildren="options"
|
|
98
|
+
placeholder={local.placeholder}
|
|
99
|
+
sectionComponent={(local) => (
|
|
100
|
+
<Kobalte.Section data-slot="select-section">{local.section.rawValue.category}</Kobalte.Section>
|
|
101
|
+
)}
|
|
102
|
+
itemComponent={(itemProps) => (
|
|
103
|
+
<Kobalte.Item
|
|
104
|
+
{...itemProps}
|
|
105
|
+
data-slot="select-select-item"
|
|
106
|
+
classList={{
|
|
107
|
+
...local.classList,
|
|
108
|
+
[local.class ?? ""]: !!local.class,
|
|
109
|
+
}}
|
|
110
|
+
onPointerEnter={() => move(itemProps.item.rawValue)}
|
|
111
|
+
onPointerMove={() => move(itemProps.item.rawValue)}
|
|
112
|
+
onFocus={() => move(itemProps.item.rawValue)}
|
|
113
|
+
>
|
|
114
|
+
<Kobalte.ItemLabel data-slot="select-select-item-label">
|
|
115
|
+
{local.children
|
|
116
|
+
? local.children(itemProps.item.rawValue)
|
|
117
|
+
: local.label
|
|
118
|
+
? local.label(itemProps.item.rawValue)
|
|
119
|
+
: (itemProps.item.rawValue as string)}
|
|
120
|
+
</Kobalte.ItemLabel>
|
|
121
|
+
<Kobalte.ItemIndicator data-slot="select-select-item-indicator">
|
|
122
|
+
<Icon name="check-small" size="small" />
|
|
123
|
+
</Kobalte.ItemIndicator>
|
|
124
|
+
</Kobalte.Item>
|
|
125
|
+
)}
|
|
126
|
+
onChange={(v) => {
|
|
127
|
+
local.onSelect?.(v ?? undefined)
|
|
128
|
+
stop()
|
|
129
|
+
}}
|
|
130
|
+
onOpenChange={(open) => {
|
|
131
|
+
local.onOpenChange?.(open)
|
|
132
|
+
if (!open) stop()
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
<Kobalte.Trigger
|
|
136
|
+
{...local.triggerProps}
|
|
137
|
+
disabled={props.disabled}
|
|
138
|
+
data-slot="select-select-trigger"
|
|
139
|
+
as={Button}
|
|
140
|
+
size={props.size}
|
|
141
|
+
variant={props.variant}
|
|
142
|
+
style={local.triggerStyle}
|
|
143
|
+
classList={{
|
|
144
|
+
...local.classList,
|
|
145
|
+
[local.class ?? ""]: !!local.class,
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
<Kobalte.Value<T> data-slot="select-select-trigger-value" class={local.valueClass}>
|
|
149
|
+
{(state) => {
|
|
150
|
+
const selected = state.selectedOption() ?? local.current
|
|
151
|
+
if (!selected) return local.placeholder || ""
|
|
152
|
+
if (local.label) return local.label(selected)
|
|
153
|
+
return selected as string
|
|
154
|
+
}}
|
|
155
|
+
</Kobalte.Value>
|
|
156
|
+
<Kobalte.Icon data-slot="select-select-trigger-icon">
|
|
157
|
+
<Icon name={local.triggerVariant === "settings" ? "selector" : "chevron-down"} size="small" />
|
|
158
|
+
</Kobalte.Icon>
|
|
159
|
+
</Kobalte.Trigger>
|
|
160
|
+
<Kobalte.Portal>
|
|
161
|
+
<Kobalte.Content
|
|
162
|
+
classList={{
|
|
163
|
+
...local.classList,
|
|
164
|
+
[local.class ?? ""]: !!local.class,
|
|
165
|
+
}}
|
|
166
|
+
data-component="select-content"
|
|
167
|
+
data-trigger-style={local.triggerVariant}
|
|
168
|
+
>
|
|
169
|
+
<Kobalte.Listbox data-slot="select-select-content-list" />
|
|
170
|
+
</Kobalte.Content>
|
|
171
|
+
</Kobalte.Portal>
|
|
172
|
+
</Kobalte>
|
|
173
|
+
)
|
|
174
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ComponentProps, For } from "solid-js"
|
|
2
|
+
|
|
3
|
+
const outerIndices = new Set([1, 2, 4, 7, 8, 11, 13, 14])
|
|
4
|
+
const cornerIndices = new Set([0, 3, 12, 15])
|
|
5
|
+
const squares = Array.from({ length: 16 }, (_, i) => ({
|
|
6
|
+
id: i,
|
|
7
|
+
x: (i % 4) * 4,
|
|
8
|
+
y: Math.floor(i / 4) * 4,
|
|
9
|
+
delay: Math.random() * 1.5,
|
|
10
|
+
duration: 1 + Math.random() * 1,
|
|
11
|
+
outer: outerIndices.has(i),
|
|
12
|
+
corner: cornerIndices.has(i),
|
|
13
|
+
}))
|
|
14
|
+
|
|
15
|
+
export function Spinner(props: {
|
|
16
|
+
class?: string
|
|
17
|
+
classList?: ComponentProps<"div">["classList"]
|
|
18
|
+
style?: ComponentProps<"div">["style"]
|
|
19
|
+
}) {
|
|
20
|
+
return (
|
|
21
|
+
<svg
|
|
22
|
+
{...props}
|
|
23
|
+
viewBox="0 0 15 15"
|
|
24
|
+
data-component="spinner"
|
|
25
|
+
classList={{
|
|
26
|
+
...props.classList,
|
|
27
|
+
[props.class ?? ""]: !!props.class,
|
|
28
|
+
}}
|
|
29
|
+
fill="currentColor"
|
|
30
|
+
>
|
|
31
|
+
<For each={squares}>
|
|
32
|
+
{(square) => (
|
|
33
|
+
<rect
|
|
34
|
+
x={square.x}
|
|
35
|
+
y={square.y}
|
|
36
|
+
width="3"
|
|
37
|
+
height="3"
|
|
38
|
+
rx="1"
|
|
39
|
+
style={{
|
|
40
|
+
opacity: square.corner ? 0 : undefined,
|
|
41
|
+
animation: square.corner
|
|
42
|
+
? undefined
|
|
43
|
+
: `${square.outer ? "pulse-opacity-dim" : "pulse-opacity"} ${square.duration}s ease-in-out infinite`,
|
|
44
|
+
"animation-fill-mode": square.corner ? undefined : "both",
|
|
45
|
+
"animation-delay": square.corner ? undefined : `${square.delay}s`,
|
|
46
|
+
}}
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
49
|
+
</For>
|
|
50
|
+
</svg>
|
|
51
|
+
)
|
|
52
|
+
}
|