{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "button-split", "type": "registry:ui", "title": "Button Split", "description": "iOS 26 liquid-glass two-zone pill with primary action and dropdown options.", "dependencies": [ "motion" ], "files": [ { "path": "registry/ruixenui/button-split.tsx", "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence } from \"motion/react\";\n\n/* ── sound ── */\nlet _a: AudioContext, _b: AudioBuffer;\nconst tick = () => {\n if (typeof window === \"undefined\") return;\n if (!_a) {\n _a = new AudioContext();\n _b = _a.createBuffer(1, (_a.sampleRate * 0.003) | 0, _a.sampleRate);\n const d = _b.getChannelData(0);\n for (let i = 0; i < d.length; i++)\n d[i] = (Math.random() * 2 - 1) * (1 - i / d.length) ** 4;\n }\n const s = _a.createBufferSource();\n s.buffer = _b;\n const g = _a.createGain();\n g.gain.value = 0.08;\n s.connect(g).connect(_a.destination);\n s.start();\n};\n\n/* ── theme ── */\nconst CSS = `\n.bs{\n --bs-glass:linear-gradient(180deg,rgba(255,255,255,0.78),rgba(255,255,255,0.62));\n --bs-border:rgba(0,0,0,0.06);\n --bs-shadow:0 0 1px rgba(0,0,0,0.04),0 2px 8px rgba(0,0,0,0.04),inset 0 1px 0 rgba(255,255,255,0.8);\n --bs-hi:rgba(0,0,0,0.88);\n --bs-dim:rgba(0,0,0,0.42);\n --bs-sep:rgba(0,0,0,0.08);\n --bs-hover:rgba(0,0,0,0.03);\n --bs-menu-shadow:0 8px 32px rgba(0,0,0,0.12),0 0 1px rgba(0,0,0,0.06)\n}\n.dark .bs,[data-theme=\"dark\"] .bs{\n --bs-glass:linear-gradient(180deg,rgba(255,255,255,0.05),rgba(255,255,255,0.02));\n --bs-border:rgba(255,255,255,0.07);\n --bs-shadow:0 1px 3px rgba(0,0,0,0.08),inset 0 1px 0 rgba(255,255,255,0.04);\n --bs-hi:rgba(255,255,255,0.88);\n --bs-dim:rgba(255,255,255,0.28);\n --bs-sep:rgba(255,255,255,0.08);\n --bs-hover:rgba(255,255,255,0.04);\n --bs-menu-shadow:0 8px 32px rgba(0,0,0,0.3),0 0 1px rgba(255,255,255,0.06)\n}`;\n\n/* ── types ── */\nexport interface SplitButtonOption {\n label: string;\n onClick: () => void;\n}\n\nexport interface ButtonSplitProps {\n label: string;\n onClick: () => void;\n options: SplitButtonOption[];\n sound?: boolean;\n style?: React.CSSProperties;\n}\n\n/* ── component ── */\nexport function ButtonSplit({\n label,\n onClick,\n options,\n sound = true,\n style,\n}: ButtonSplitProps) {\n const [open, setOpen] = React.useState(false);\n const ref = React.useRef(null);\n\n React.useEffect(() => {\n if (!open) return;\n const close = (e: MouseEvent) => {\n if (ref.current && !ref.current.contains(e.target as Node))\n setOpen(false);\n };\n const esc = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") setOpen(false);\n };\n document.addEventListener(\"mousedown\", close);\n document.addEventListener(\"keydown\", esc);\n return () => {\n document.removeEventListener(\"mousedown\", close);\n document.removeEventListener(\"keydown\", esc);\n };\n }, [open]);\n\n const shared: React.CSSProperties = {\n border: \"none\",\n background: \"transparent\",\n color: \"var(--bs-hi)\",\n fontSize: 13,\n fontWeight: 500,\n cursor: \"pointer\",\n outline: \"none\",\n };\n\n return (\n <>\n