mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
2 lines
2.7 KiB
JavaScript
2 lines
2.7 KiB
JavaScript
import{r as l,j as e,B as k,b8 as s,aI as v,aP as w}from"./index-Db-xuq0b.js";import{P as j,a as C,b as N}from"./popover-X-j_SRnG.js";import{C as S,a as P,b as O,c as I,d as z,e as E}from"./command-Cr0tMDDu.js";const m=t=>t.normalize("NFKC").toLocaleLowerCase().replace(/\s+/g," ").trim(),L=l.forwardRef(({options:t=[],value:o,placeholder:c="Select an option",onValueChange:g,className:x,...y},h)=>{const[n,i]=l.useState(!1),[d,p]=l.useState(""),u=m(d),b=t.filter(r=>m(r.label).includes(u)),a=t.find(r=>r.value===o),f=r=>{g(r),i(!1)};return e.jsxs(j,{open:n,onOpenChange:i,children:[e.jsx(C,{asChild:!0,children:e.jsxs(k,{ref:h,...y,className:s("flex h-10 w-full min-w-0 max-w-full shrink items-center justify-between overflow-hidden rounded-md border border-gray-300 bg-white text-gray-900","px-3 py-2 text-sm font-normal shadow-sm transition-all duration-150","hover:bg-gray-50 hover:border-gray-400 focus:ring-2 focus:ring-primary-200 focus:border-primary-500","dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200","dark:hover:bg-gray-600 dark:hover:border-gray-500",n&&"border-primary-500 ring-2 ring-primary-100 dark:ring-primary-900/40",x),children:[e.jsx("span",{className:s("block min-w-0 flex-1 truncate text-left",a?"font-medium text-gray-900 dark:text-gray-100":"font-normal text-gray-500 dark:text-gray-400"),title:a?a.label:void 0,children:a?a.label:c}),e.jsx(v,{className:s("ml-2 h-4 w-4 shrink-0 text-gray-500 transition-transform duration-200","dark:text-gray-400",n&&"rotate-180")})]})}),e.jsx(N,{className:"w-[var(--radix-popover-trigger-width)] max-w-sm p-0 border border-gray-200 rounded-lg shadow-lg bg-white dark:border-gray-600 dark:bg-gray-800",align:"start",children:e.jsxs(S,{shouldFilter:!1,children:[e.jsx(P,{placeholder:"Search...",value:d,onValueChange:p,className:"text-sm dark:text-gray-200 dark:placeholder:text-gray-500"}),e.jsxs(O,{className:"max-h-60 overflow-y-auto",onWheel:r=>r.stopPropagation(),children:[e.jsx(I,{className:"py-3 text-gray-500 text-sm text-center dark:text-gray-400",children:"No results found."}),e.jsx(z,{children:b?.map(r=>e.jsxs(E,{value:r.label,onSelect:()=>f(r.value),className:s("cursor-pointer flex items-center justify-between px-3 py-2 rounded-md text-sm transition-colors duration-100","hover:bg-primary-50 hover:text-primary-700 focus:bg-primary-50","dark:hover:bg-gray-700 dark:focus:bg-gray-700 dark:text-gray-200",o===r.value&&"bg-primary-100 text-primary-700 font-medium dark:bg-primary-900/50 dark:text-primary-300"),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.label}),o===r.value&&e.jsx(w,{className:"h-4 w-4 shrink-0 text-primary-600"})]},r.value))})]})]})})]})});L.displayName="SingleSelect";export{L as S};
|