the-omelet-ui 1.2.4 → 1.2.6

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.
@@ -0,0 +1 @@
1
+ import {a as a$3}from'./chunk-A2DBYHBF.js';import {a as a$4}from'./chunk-IX36POX2.js';import {f,b}from'./chunk-AFEF2EXB.js';import {a as a$1}from'./chunk-DM45BGDQ.js';import {a as a$2}from'./chunk-6GLPXMGB.js';import*as a from'react';import*as l from'@radix-ui/react-popover';import {jsxs,jsx}from'react/jsx-runtime';function se(c){return typeof c=="string"?{id:c,label:c}:c}var le={neutral:"border-neutral-900 bg-neutral-900 text-white",primary:"border-black bg-black text-white",red:"border-red-600 bg-red-600 text-white",green:"border-green-600 bg-green-600 text-white",blue:"border-blue-600 bg-blue-600 text-white",yellow:"border-yellow-500 bg-yellow-500 text-black",violet:"border-violet-600 bg-violet-600 text-white"};function ne({trigger:c,triggerPlaceholder:x="Choose",items:y,selectionMode:b$1="multiple",value:w,defaultValue:z,onChange:Q,searchable:k=true,placeholder:A="Placeholder Text",searchButtonLabel:O="Search",onQueryChange:V,onSearch:j,loading:u=false,emptyLabel:D="No results",contentClassName:H,maxHeight:W=288,renderItem:R,buttonColor:_="primary",searchButtonColor:$,searchButtonClassName:E,checkedColor:F="primary",checkedClassName:G,renderTriggerValue:N,label:C,required:J,errorMessage:g}){let[P,S]=a.useState(false),[p,K]=a.useState(""),[f$1,U]=a.useState(""),s=b$1==="multiple",[X,Y]=a.useState(z??(s?[]:"")),o=w??X,d=a.useMemo(()=>y.map(se),[y]),I=a.useMemo(()=>{let e=f$1.trim().toLowerCase();return e?d.filter(r=>String(r.label).toLowerCase().includes(e)):d},[d,f$1]),B=e=>{Q?.(e),w===void 0&&Y(e);},Z=e=>{if(s){let r=new Set(o);r.has(e)?r.delete(e):r.add(e),B(Array.from(r));}else B(e),S(false);},ee=e=>s?o.includes(e):o===e,te=()=>{U(p),j?.(p);},h=a.useMemo(()=>s?o:o?[o]:[],[o,s]),m=a.useMemo(()=>d.filter(e=>h.includes(e.id)),[d,h]),re=a.useMemo(()=>m.length===0?x:s?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${m.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:m[0].label,[m,s,x]);return jsxs("fieldset",{children:[C&&jsx(a$1,{label:C,required:J}),jsxs(l.Root,{open:P,onOpenChange:S,children:[jsx("div",{className:"mb-2"}),jsx(l.Trigger,{asChild:true,children:c??jsxs("button",{type:"button",className:a$2("flex w-full min-w-[260px] items-center justify-between","rounded-md border border-black/15 bg-white px-4 py-3 text-left","outline-none focus-visible:ring-2 ring-black/20",g?"border-red-600":""),children:[jsx("span",{className:a$2("flex-1 ",{"text-gray-400":s?o?.length===0:!o,"text-black":s?o?.length>0:!!o}),children:N?N(h,m):re}),jsx("svg",{className:a$2("ml-3 h-5 w-5 text-black/60 transition-transform",P?"rotate-180":"rotate-0"),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:jsx("path",{d:"M6 9l6 6 6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]})}),jsx(l.Portal,{children:jsxs(l.Content,{sideOffset:8,className:a$2("w-[300px] rounded-md border border-black/10 bg-white p-2 shadow-xl",H),children:[k&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:e=>{e.preventDefault(),te();},children:[jsx(a$3,{start:jsx(f,{className:"h-3 w-3 text-black/50"}),value:p,onChange:e=>{K(e.currentTarget.value),V?.(e.currentTarget.value);},size:"sm",placeholder:A}),jsx(a$4,{color:$??_,type:"submit",disabled:u||p.trim()===f$1.trim(),size:"md",className:E,children:O})]}),jsxs("div",{role:"listbox","aria-multiselectable":s||void 0,className:a$2(" overflow-y-auto rounded-md",{"mt-3":k}),style:{maxHeight:W},children:[u&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),!u&&I.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:D}),!u&&I.map(e=>{let r=ee(e.id),oe=le[F],ae=jsxs(a$4,{type:"button",role:"option","aria-selected":r,onClick:()=>Z(e.id),disabled:e.disabled,size:"sm",className:a$2("group flex w-full items-center justify-between gap-3 rounded-md px-2 py-2 text-left bg-white","hover:bg-black/[0.04] disabled:opacity-50",{"bg-black/[0.04]":r&&b$1==="single"}),children:[jsx("span",{className:"text-md text-black",children:e.label}),b$1==="multiple"&&jsx("span",{className:a$2("grid h-5 w-5 place-items-center rounded-full border-2",r?oe:"border-black/20",r&&G),children:r?jsx(b,{className:"h-2 w-2"}):null})]},e.id);return R?jsx("div",{children:R(e,false,r)},e.id):ae})]}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]}),g&&jsx("small",{className:"text-red-500 text-xs",children:g})]})}var pe=ne;export{pe as a};
@@ -1 +1 @@
1
- import {a}from'./chunk-DM45BGDQ.js';import {a as a$1}from'./chunk-6GLPXMGB.js';import*as o from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var w=cva("block w-full rounded-md bg-white outline-none text-sm borderborder disabled:border-none transition-shadow disabled:bg-[#f4f4f4] disabled:pointer-events-none disabled:text-[#BDC2BE] disabled:font-boldfocus-visible:ring-2",{variants:{size:{sm:"h-10 px-2 py-3 text-sm",md:"h-12 px-2 py-4 text-md",lg:"h-14 px-4 py-6 text-xl"},tone:{neutral:"border border-[#C9D7E3] focus-visible:ring-black/20",success:"border border-green-500/60 focus-visible:ring-green-300",danger:"border border-red-500/60 focus-visible:ring-red-300",warning:"border border-yellow-500/60 focus-visible:ring-yellow-300",info:"border border-blue-500/60 focus-visible:ring-blue-300"},withStart:{true:"",false:""},withEnd:{true:"",false:""}},compoundVariants:[{withStart:true,class:"ps-10"},{withEnd:true,class:"pe-10"}],defaultVariants:{size:"md",tone:"neutral"}}),d=o.forwardRef(({className:p,start:s,end:a$2,size:u,tone:b,withStart:c,withEnd:f,error:t,label:r,required:m,disabled:x=false,...g},v)=>jsxs("fieldset",{className:"relative flex flex-col gap-2 ",children:[r&&jsx(a,{label:r,required:m}),jsxs("div",{className:"relative flex flex-col gap-2 items-start text-start",children:[s?jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center ps-3","aria-hidden":"true",children:jsx("span",{className:"text-black/50",children:s})}):null,jsx("input",{ref:v,"data-state":t?"invalid":void 0,className:a$1(w({size:u,tone:t?"danger":b,withStart:c??!!s,withEnd:f??!!a$2}),p),disabled:x,...g}),a$2?jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pe-3",children:a$2}):null]}),t&&jsx("small",{className:"text-red-500 text-xs",children:t})]}));d.displayName="TextInput";var S=d;export{S as a};
1
+ import {a}from'./chunk-DM45BGDQ.js';import {a as a$1}from'./chunk-6GLPXMGB.js';import*as o from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var w=cva("block w-full rounded-md bg-white outline-none text-sm borderborder disabled:border-none transition-shadow disabled:bg-[#f4f4f4] disabled:pointer-events-none disabled:text-[#BDC2BE] disabled:font-boldfocus-visible:ring-2",{variants:{size:{sm:"h-10 px-2 py-3 text-sm",md:"h-12 px-2 py-4 text-md",lg:"h-14 px-4 py-6 text-xl"},tone:{neutral:"border border-[#C9D7E3] focus-visible:ring-black/20",success:"border border-green-500/60 focus-visible:ring-green-300",danger:"border border-red-500/60 focus-visible:ring-red-300",warning:"border border-yellow-500/60 focus-visible:ring-yellow-300",info:"border border-blue-500/60 focus-visible:ring-blue-300"},withStart:{true:"",false:""},withEnd:{true:"",false:""}},compoundVariants:[{withStart:true,class:"ps-10"},{withEnd:true,class:"pe-10"}],defaultVariants:{size:"md",tone:"neutral"}}),d=o.forwardRef(({className:p,start:s,end:a$2,size:u,tone:c,withStart:b,withEnd:f,error:t,label:r,required:m,disabled:x=false,...v},g)=>jsxs("fieldset",{className:"relative flex flex-col space-y-2",children:[r&&jsx(a,{label:r,required:m}),jsxs("div",{className:"relative flex flex-col gap-2 items-start text-start",children:[s?jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center ps-3","aria-hidden":"true",children:jsx("span",{className:"text-black/50",children:s})}):null,jsx("input",{ref:g,"data-state":t?"invalid":void 0,className:a$1(w({size:u,tone:t?"danger":c,withStart:b??!!s,withEnd:f??!!a$2}),p),disabled:x,...v}),a$2?jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pe-3",children:a$2}):null]}),t&&jsx("small",{className:"text-red-500 text-xs",children:t})]}));d.displayName="TextInput";var S=d;export{S as a};
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-GTDIQTTP.js';import'../chunk-M4JODKXJ.js';import'../chunk-IX36POX2.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var S=(t,s)=>s==="en"?{id:t.id,name:t.name_en,value:t.id,label:t.name_en}:{id:t.id,name:t.name_th,value:t.id,label:t.name_th},P=async t=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/district.json")).json()).filter(a=>a.province_id===t),w=({locale:t="th",searchPlaceholder:s="Search District",placeholder:c="Select District",label:l,searchButtonClassName:a$1="bg-blue-500",onChange:f,value:n,required:D=false,provinceId:o})=>{let[i,g]=useState([]),[b,d]=useState(null);useEffect(()=>{o&&P(o).then(g);},[o]),useEffect(()=>{if(n){let e=i.find(r=>t==="th"?r.name_th===n:r.name_en===n);e&&d(e);}},[i,n,t]);let _=useCallback(e=>{let r=i.find(v=>v.id===e);r&&(d(r),f?.(r));},[i]);return jsx("div",{children:jsx(a,{items:i.map(e=>S(e,t)),placeholder:s,triggerPlaceholder:c,label:l,selectionMode:"single",searchButtonClassName:a$1,onChange:e=>{typeof e=="string"&&_(e);},value:b?.id,required:D})})},x=w;
1
+ import {a}from'../chunk-4KKSYTCZ.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var S=(t,s)=>s==="en"?{id:t.id,name:t.name_en,value:t.id,label:t.name_en}:{id:t.id,name:t.name_th,value:t.id,label:t.name_th},P=async t=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/district.json")).json()).filter(a=>a.province_id===t),w=({locale:t="th",searchPlaceholder:s="Search District",placeholder:c="Select District",label:l,searchButtonClassName:a$1="bg-blue-500",onChange:f,value:n,required:D=false,provinceId:o})=>{let[i,g]=useState([]),[b,d]=useState(null);useEffect(()=>{o&&P(o).then(g);},[o]),useEffect(()=>{if(n){let e=i.find(r=>t==="th"?r.name_th===n:r.name_en===n);e&&d(e);}},[i,n,t]);let _=useCallback(e=>{let r=i.find(v=>v.id===e);r&&(d(r),f?.(r));},[i]);return jsx("div",{children:jsx(a,{items:i.map(e=>S(e,t)),placeholder:s,triggerPlaceholder:c,label:l,selectionMode:"single",searchButtonClassName:a$1,onChange:e=>{typeof e=="string"&&_(e);},value:b?.id,required:D})})},x=w;
2
2
  export{x as default};
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-GTDIQTTP.js';import'../chunk-M4JODKXJ.js';import'../chunk-IX36POX2.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var C=(e,o)=>o==="en"?{id:e.id,name:e.name_en,value:e.id,label:e.name_en}:{id:e.id,name:e.name_th,value:e.id,label:e.name_th},S=async()=>await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province.json")).json(),w=({locale:e="th",searchPlaceholder:o="Search Province",placeholder:h="Select Province",label:u,searchButtonClassName:P="bg-blue-500",onChange:m,value:i,required:f=false})=>{let[r,v]=useState([]),[p,s]=useState(null);useEffect(()=>{S().then(v);},[]),useEffect(()=>{if(i){let n=r.find(t=>e==="th"?t.name_th===i:t.name_en===i);n&&s(n);}},[r,i,e]);let g=useCallback(n=>{let t=r.find(b=>b.id===n);t&&(s(t),m?.(t));},[r]);return jsx("div",{children:jsx(a,{items:r.map(n=>C(n,e)),placeholder:o,triggerPlaceholder:h,label:u,selectionMode:"single",searchButtonClassName:P,onChange:n=>{typeof n=="string"&&g(n);},value:p?.id,required:f})})},x=w;
1
+ import {a}from'../chunk-4KKSYTCZ.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var C=(e,o)=>o==="en"?{id:e.id,name:e.name_en,value:e.id,label:e.name_en}:{id:e.id,name:e.name_th,value:e.id,label:e.name_th},S=async()=>await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province.json")).json(),w=({locale:e="th",searchPlaceholder:o="Search Province",placeholder:h="Select Province",label:u,searchButtonClassName:P="bg-blue-500",onChange:m,value:i,required:f=false})=>{let[r,v]=useState([]),[p,s]=useState(null);useEffect(()=>{S().then(v);},[]),useEffect(()=>{if(i){let n=r.find(t=>e==="th"?t.name_th===i:t.name_en===i);n&&s(n);}},[r,i,e]);let g=useCallback(n=>{let t=r.find(b=>b.id===n);t&&(s(t),m?.(t));},[r]);return jsx("div",{children:jsx(a,{items:r.map(n=>C(n,e)),placeholder:o,triggerPlaceholder:h,label:u,selectionMode:"single",searchButtonClassName:P,onChange:n=>{typeof n=="string"&&g(n);},value:p?.id,required:f})})},x=w;
2
2
  export{x as default};
@@ -40,7 +40,8 @@ type SearchSelectProps = {
40
40
  renderTriggerValue?: (selectedIds: string[], selectedItems: BaseItem[]) => React.ReactNode;
41
41
  label?: string;
42
42
  required?: boolean;
43
+ errorMessage?: string;
43
44
  };
44
- declare function SearchSelect({ trigger, triggerPlaceholder, items, selectionMode, value, defaultValue, onChange, searchable, placeholder, searchButtonLabel, onQueryChange, onSearch, loading, emptyLabel, contentClassName, maxHeight, renderItem, buttonColor, searchButtonColor, searchButtonClassName, checkedColor, checkedClassName, renderTriggerValue, label, required }: SearchSelectProps): react_jsx_runtime.JSX.Element;
45
+ declare function SearchSelect({ trigger, triggerPlaceholder, items, selectionMode, value, defaultValue, onChange, searchable, placeholder, searchButtonLabel, onQueryChange, onSearch, loading, emptyLabel, contentClassName, maxHeight, renderItem, buttonColor, searchButtonColor, searchButtonClassName, checkedColor, checkedClassName, renderTriggerValue, label, required, errorMessage }: SearchSelectProps): react_jsx_runtime.JSX.Element;
45
46
 
46
47
  export { type SearchSelectProps, SearchSelect as default };
@@ -1 +1 @@
1
- export{a as default}from'../chunk-GTDIQTTP.js';import'../chunk-M4JODKXJ.js';import'../chunk-IX36POX2.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';
1
+ export{a as default}from'../chunk-4KKSYTCZ.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';
@@ -45,9 +45,10 @@ type SearchSelectProps = {
45
45
  required?: boolean;
46
46
  enablePagination?: boolean;
47
47
  pageSize?: number;
48
+ errorMessage?: string;
48
49
  };
49
50
  declare function SearchSelectWithAPI({ trigger, triggerPlaceholder, items: propItems, loadOptions, // 👈 ใหม่
50
51
  selectionMode, value, defaultValue, onChange, searchable, placeholder, searchButtonLabel, onQueryChange, onSearch, loading: externalLoading, emptyLabel, errorLabel, // 👈 ใหม่
51
- contentClassName, maxHeight, renderItem, buttonColor, searchButtonColor, searchButtonClassName, checkedColor, checkedClassName, renderTriggerValue, label, required, enablePagination, pageSize, }: SearchSelectProps): react_jsx_runtime.JSX.Element;
52
+ contentClassName, maxHeight, renderItem, buttonColor, searchButtonColor, searchButtonClassName, checkedColor, checkedClassName, renderTriggerValue, label, required, enablePagination, pageSize, errorMessage }: SearchSelectProps): react_jsx_runtime.JSX.Element;
52
53
 
53
54
  export { type SearchSelectProps, SearchSelectWithAPI as default, handleMultipleChange, handleSingleChange };
@@ -1 +1 @@
1
- import {a as a$2}from'../chunk-M4JODKXJ.js';import {a as a$3}from'../chunk-IX36POX2.js';import {f,b}from'../chunk-AFEF2EXB.js';import {a}from'../chunk-DM45BGDQ.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import*as t from'react';import*as c from'@radix-ui/react-popover';import {jsxs,jsx}from'react/jsx-runtime';var Ae=o=>l=>{o(typeof l=="string"?l:l[0]||"");},qe=o=>l=>{o(Array.isArray(l)?l:[l]);};function J(o){return typeof o=="string"?{id:o,label:o}:o}var Ce={neutral:"border-neutral-900 bg-neutral-900 text-white",primary:"border-black bg-black text-white",red:"border-red-600 bg-red-600 text-white",green:"border-green-600 bg-green-600 text-white",blue:"border-blue-600 bg-blue-600 text-white",yellow:"border-yellow-500 bg-yellow-500 text-black",violet:"border-violet-600 bg-violet-600 text-white"};function Se({trigger:o,triggerPlaceholder:l="Choose",items:K,loadOptions:i,selectionMode:y="multiple",value:L,defaultValue:X,onChange:Y,searchable:M=true,placeholder:Z="Placeholder Text",searchButtonLabel:O="Search",onQueryChange:ee,onSearch:te,loading:re=false,emptyLabel:se="No results",errorLabel:ae="Failed to load options",contentClassName:oe,maxHeight:le=288,renderItem:T,buttonColor:ne="primary",searchButtonColor:ce,searchButtonClassName:ie,checkedColor:de="primary",checkedClassName:ue,renderTriggerValue:A,label:q,required:ge,enablePagination:p=false,pageSize:z=20}){let[x,H]=t.useState(false),[b$1,me]=t.useState(""),[R,Q]=t.useState(""),[E,k]=t.useState([]),[w,V]=t.useState(false),[N,W]=t.useState(null),[pe,j]=t.useState(1),[be,fe]=t.useState(true),n=y==="multiple",[he,xe]=t.useState(X??(n?[]:"")),a$4=L??he,D=i?E:K||[],g=t.useMemo(()=>D.map(J),[D]),C=t.useCallback(async(e,s=1,h=false)=>{if(i){V(true),W(null);try{let P=(await i(e)).map(J);k(h?Ne=>[...Ne,...P]:P),p&&fe(P.length===z);}catch(u){W(u instanceof Error?u.message:"Unknown error"),k([]);}finally{V(false);}}},[i,p,z]);t.useEffect(()=>{x&&i&&E.length===0&&C("");},[x,i]);let v=t.useMemo(()=>{if(i)return g;let e=R.trim().toLowerCase();return e?g.filter(s=>String(s.label).toLowerCase().includes(e)):g},[g,R,i]),F=e=>{Y?.(e),L===void 0&&xe(e);},ve=e=>{if(n){let s=new Set(a$4);s.has(e)?s.delete(e):s.add(e),F(Array.from(s));}else F(e),H(false);},ye=e=>n?a$4.includes(e):a$4===e,Re=()=>{i?(j(1),C(b$1,1,false),Q(b$1)):(Q(b$1),te?.(b$1));},ke=()=>{if(!w&&be&&p){let e=pe+1;j(e),C(R,e,true);}},S=t.useMemo(()=>n?a$4:a$4?[a$4]:[],[a$4,n]),f$1=t.useMemo(()=>g.filter(e=>S.includes(e.id)),[g,S]),we=t.useMemo(()=>f$1.length===0?l:n?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${f$1.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:f$1[0].label,[f$1,n,l]),I=w||re;return jsxs(c.Root,{open:x,onOpenChange:H,children:[q&&jsx(a,{label:q,required:ge}),jsx("div",{className:"mb-2"}),jsx(c.Trigger,{asChild:true,children:o??jsxs("button",{type:"button",className:a$1("flex w-full min-w-[260px] items-center justify-between","rounded-md border border-black/15 bg-white px-4 py-3 text-left","outline-none focus-visible:ring-2 ring-black/20"),children:[jsx("span",{className:a$1("flex-1 ",{"text-gray-400":n?a$4?.length===0:!a$4,"text-black":n?a$4?.length>0:!!a$4}),children:A?A(S,f$1):we}),jsx("svg",{className:a$1("ml-3 h-5 w-5 text-black/60 transition-transform",x?"rotate-180":"rotate-0"),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:jsx("path",{d:"M6 9l6 6 6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]})}),jsx(c.Portal,{children:jsxs(c.Content,{sideOffset:8,className:a$1("w-[300px] rounded-md border border-black/10 bg-white p-2 shadow-xl",oe),children:[M&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:e=>{e.preventDefault(),Re();},children:[jsx(a$2,{start:jsx(f,{className:"h-3 w-3 text-black/50"}),value:b$1,onChange:e=>{me(e.currentTarget.value),ee?.(e.currentTarget.value);},size:"sm",placeholder:Z}),jsx(a$3,{color:ce??ne,type:"submit",disabled:I,size:"md",className:ie,children:O})]}),jsxs("div",{role:"listbox","aria-multiselectable":n||void 0,className:a$1("overflow-y-auto rounded-md",{"mt-3":M}),style:{maxHeight:le},onScroll:e=>{if(!p)return;let{scrollTop:s,scrollHeight:h,clientHeight:u}=e.currentTarget;h-s<=u+50&&ke();},children:[I&&v.length===0&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),N&&jsx("div",{className:"p-6 text-center text-red-600",children:ae}),!I&&!N&&v.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:se}),!N&&v.map(e=>{let s=ye(e.id),h=Ce[de],u=jsxs(a$3,{type:"button",role:"option","aria-selected":s,onClick:()=>ve(e.id),disabled:e.disabled,size:"sm",className:a$1("group flex w-full items-center justify-between gap-3 rounded-md px-2 py-2 text-left bg-white h-auto","hover:bg-black/[0.04] disabled:opacity-50",{"bg-black/[0.04]":s&&y==="single"}),children:[jsx("span",{className:"text-md text-black",children:e.label}),y==="multiple"&&jsx("span",{className:a$1("grid h-5 w-5 place-items-center rounded-full border-2",s?h:"border-black/20",s&&ue),children:s?jsx(b,{className:"h-2 w-2"}):null})]},e.id);return T?jsx("div",{children:T(e,false,s)},e.id):u}),p&&w&&v.length>0&&jsx("div",{className:"p-2 text-center text-sm text-black/40",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21..."})]}),jsx(c.Arrow,{className:"fill-white stroke-black/10"})]})})]})}var Ie=Se;export{Ie as default,qe as handleMultipleChange,Ae as handleSingleChange};
1
+ import {a as a$2}from'../chunk-A2DBYHBF.js';import {a as a$3}from'../chunk-IX36POX2.js';import {f,b}from'../chunk-AFEF2EXB.js';import {a}from'../chunk-DM45BGDQ.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import*as r from'react';import*as c from'@radix-ui/react-popover';import {jsx,jsxs}from'react/jsx-runtime';var qe=o=>l=>{o(typeof l=="string"?l:l[0]||"");},ze=o=>l=>{o(Array.isArray(l)?l:[l]);};function K(o){return typeof o=="string"?{id:o,label:o}:o}var Se={neutral:"border-neutral-900 bg-neutral-900 text-white",primary:"border-black bg-black text-white",red:"border-red-600 bg-red-600 text-white",green:"border-green-600 bg-green-600 text-white",blue:"border-blue-600 bg-blue-600 text-white",yellow:"border-yellow-500 bg-yellow-500 text-black",violet:"border-violet-600 bg-violet-600 text-white"};function Ie({trigger:o,triggerPlaceholder:l="Choose",items:X,loadOptions:i,selectionMode:y="multiple",value:M,defaultValue:Y,onChange:Z,searchable:T=true,placeholder:O="Placeholder Text",searchButtonLabel:ee="Search",onQueryChange:te,onSearch:re,loading:se=false,emptyLabel:ae="No results",errorLabel:oe="Failed to load options",contentClassName:le,maxHeight:ne=288,renderItem:A,buttonColor:ce="primary",searchButtonColor:ie,searchButtonClassName:de,checkedColor:ue="primary",checkedClassName:me,renderTriggerValue:q,label:z,required:ge,enablePagination:p=false,pageSize:H=20,errorMessage:R}){let[x,Q]=r.useState(false),[b$1,pe]=r.useState(""),[k,E]=r.useState(""),[V,w]=r.useState([]),[N,W]=r.useState(false),[C,j]=r.useState(null),[be,D]=r.useState(1),[fe,he]=r.useState(true),n=y==="multiple",[xe,ve]=r.useState(Y??(n?[]:"")),a$4=M??xe,F=i?V:X||[],m=r.useMemo(()=>F.map(K),[F]),S=r.useCallback(async(e,s=1,h=false)=>{if(i){W(true),j(null);try{let B=(await i(e)).map(K);w(h?Ce=>[...Ce,...B]:B),p&&he(B.length===H);}catch(u){j(u instanceof Error?u.message:"Unknown error"),w([]);}finally{W(false);}}},[i,p,H]);r.useEffect(()=>{x&&i&&V.length===0&&S("");},[x,i]);let v=r.useMemo(()=>{if(i)return m;let e=k.trim().toLowerCase();return e?m.filter(s=>String(s.label).toLowerCase().includes(e)):m},[m,k,i]),U=e=>{Z?.(e),M===void 0&&ve(e);},ye=e=>{if(n){let s=new Set(a$4);s.has(e)?s.delete(e):s.add(e),U(Array.from(s));}else U(e),Q(false);},Re=e=>n?a$4.includes(e):a$4===e,ke=()=>{i?(D(1),S(b$1,1,false),E(b$1)):(E(b$1),re?.(b$1));},we=()=>{if(!N&&fe&&p){let e=be+1;D(e),S(k,e,true);}},I=r.useMemo(()=>n?a$4:a$4?[a$4]:[],[a$4,n]),f$1=r.useMemo(()=>m.filter(e=>I.includes(e.id)),[m,I]),Ne=r.useMemo(()=>f$1.length===0?l:n?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${f$1.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:f$1[0].label,[f$1,n,l]),P=N||se;return jsx("fieldset",{children:jsxs(c.Root,{open:x,onOpenChange:Q,children:[z&&jsx(a,{label:z,required:ge}),jsx("div",{className:"mb-2"}),jsx(c.Trigger,{asChild:true,children:o??jsxs("button",{type:"button",className:a$1("flex w-full min-w-[260px] items-center justify-between","rounded-md border border-black/15 bg-white px-4 py-3 text-left","outline-none focus-visible:ring-2 ring-black/20",R?"border-red-500":"border-black/20"),children:[jsx("span",{className:a$1("flex-1 ",{"text-gray-400":n?a$4?.length===0:!a$4,"text-black":n?a$4?.length>0:!!a$4}),children:q?q(I,f$1):Ne}),jsx("svg",{className:a$1("ml-3 h-5 w-5 text-black/60 transition-transform",x?"rotate-180":"rotate-0"),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:jsx("path",{d:"M6 9l6 6 6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]})}),R&&jsx("small",{className:"text-red-500 text-xs",children:R}),jsx(c.Portal,{children:jsxs(c.Content,{sideOffset:8,className:a$1("w-[300px] rounded-md border border-black/10 bg-white p-2 shadow-xl",le),children:[T&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:e=>{e.preventDefault(),ke();},children:[jsx(a$2,{start:jsx(f,{className:"h-3 w-3 text-black/50"}),value:b$1,onChange:e=>{pe(e.currentTarget.value),te?.(e.currentTarget.value);},size:"sm",placeholder:O}),jsx(a$3,{color:ie??ce,type:"submit",disabled:P,size:"md",className:de,children:ee})]}),jsxs("div",{role:"listbox","aria-multiselectable":n||void 0,className:a$1("overflow-y-auto rounded-md",{"mt-3":T}),style:{maxHeight:ne},onScroll:e=>{if(!p)return;let{scrollTop:s,scrollHeight:h,clientHeight:u}=e.currentTarget;h-s<=u+50&&we();},children:[P&&v.length===0&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),C&&jsx("div",{className:"p-6 text-center text-red-600",children:oe}),!P&&!C&&v.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:ae}),!C&&v.map(e=>{let s=Re(e.id),h=Se[ue],u=jsxs(a$3,{type:"button",role:"option","aria-selected":s,onClick:()=>ye(e.id),disabled:e.disabled,size:"sm",className:a$1("group flex w-full items-center justify-between gap-3 rounded-md px-2 py-2 text-left bg-white h-auto","hover:bg-black/[0.04] disabled:opacity-50",{"bg-black/[0.04]":s&&y==="single"}),children:[jsx("span",{className:"text-md text-black",children:e.label}),y==="multiple"&&jsx("span",{className:a$1("grid h-5 w-5 place-items-center rounded-full border-2",s?h:"border-black/20",s&&me),children:s?jsx(b,{className:"h-2 w-2"}):null})]},e.id);return A?jsx("div",{children:A(e,false,s)},e.id):u}),p&&N&&v.length>0&&jsx("div",{className:"p-2 text-center text-sm text-black/40",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21..."})]}),jsx(c.Arrow,{className:"fill-white stroke-black/10"})]})})]})})}var Pe=Ie;export{Pe as default,ze as handleMultipleChange,qe as handleSingleChange};
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-GTDIQTTP.js';import'../chunk-M4JODKXJ.js';import'../chunk-IX36POX2.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var v=(t,s)=>s==="en"?{id:t.id,name:t.name_en,value:t.id,label:t.name_en}:{id:t.id,name:t.name_th,value:t.id,label:t.name_th},P=async t=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/sub_district.json")).json()).filter(a=>a.district_id===t),w=({locale:t="th",searchPlaceholder:s="Search District",placeholder:c="Select District",label:l,searchButtonClassName:a$1="bg-blue-500",onChange:p,value:n,required:b=false,districtId:o})=>{let[r,S]=useState([]),[g,d]=useState(null);useEffect(()=>{o&&P(o).then(S);},[o]),useEffect(()=>{if(n){let e=r.find(i=>t==="th"?i.name_th===n:i.name_en===n);e&&d(e);}},[r,n,t]);let D=useCallback(e=>{let i=r.find(_=>_.id===e);i&&(d(i),p?.(i));},[r]);return jsx("div",{children:jsx(a,{items:r.map(e=>v(e,t)),placeholder:s,triggerPlaceholder:c,label:l,selectionMode:"single",searchButtonClassName:a$1,onChange:e=>{typeof e=="string"&&D(e);},value:g?.id,required:b})})},x=w;
1
+ import {a}from'../chunk-4KKSYTCZ.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var v=(t,s)=>s==="en"?{id:t.id,name:t.name_en,value:t.id,label:t.name_en}:{id:t.id,name:t.name_th,value:t.id,label:t.name_th},P=async t=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/sub_district.json")).json()).filter(a=>a.district_id===t),w=({locale:t="th",searchPlaceholder:s="Search District",placeholder:c="Select District",label:l,searchButtonClassName:a$1="bg-blue-500",onChange:p,value:n,required:b=false,districtId:o})=>{let[r,S]=useState([]),[g,d]=useState(null);useEffect(()=>{o&&P(o).then(S);},[o]),useEffect(()=>{if(n){let e=r.find(i=>t==="th"?i.name_th===n:i.name_en===n);e&&d(e);}},[r,n,t]);let D=useCallback(e=>{let i=r.find(_=>_.id===e);i&&(d(i),p?.(i));},[r]);return jsx("div",{children:jsx(a,{items:r.map(e=>v(e,t)),placeholder:s,triggerPlaceholder:c,label:l,selectionMode:"single",searchButtonClassName:a$1,onChange:e=>{typeof e=="string"&&D(e);},value:g?.id,required:b})})},x=w;
2
2
  export{x as default};
@@ -1 +1 @@
1
- export{a as default}from'../chunk-M4JODKXJ.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';
1
+ export{a as default}from'../chunk-A2DBYHBF.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';
@@ -1 +1 @@
1
- import {a as a$2}from'../chunk-IX36POX2.js';import {a as a$1}from'../chunk-DM45BGDQ.js';import {a}from'../chunk-6GLPXMGB.js';import {useRef,useState,useCallback}from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var D=cva("mx-auto flex h-16 w-16 items-center justify-center rounded-full text-white",{variants:{iconColor:{neutral:"bg-neutral-800",primary:"bg-black",red:"bg-red-700",green:"bg-green-600",blue:"bg-blue-600",yellow:"bg-yellow-500",violet:"bg-violet-600"}},defaultVariants:{iconColor:"primary"}}),C=({label:d,buttonLabel:w="Upload",buttonColor:u="primary",iconColor:N,iconBgClassName:y,buttonClassName:k,openCameraButtonClassName:R,openCameraButtonLabel:I="Open Camera",className:L,icon:B,accept:m,multiple:p,disabled:o,onFilesSelected:g,required:P,value:U,title:j="Upload Image",error:i,onClearPreview:M,showClearButton:E=false,imageClassName:H})=>{let r=useRef(null),t=useRef(null),[W,f]=useState(null),F=()=>r.current?.click(),T=useCallback(()=>{t.current&&t.current.click();},[]),b=l=>{if(l.target.files&&l.target.files.length>0){let q=l.target.files[0],s=new FileReader;s.onloadend=()=>{f(s.result);},s.readAsDataURL(q),g&&g(l.target.files);}r.current&&(r.current.value=""),t.current&&(t.current.value="");},V=()=>{f(null),M?.(),r.current&&(r.current.value=""),t.current&&(t.current.value="");},v=W||U;return jsxs("div",{className:a("space-y-2",L),children:[d&&jsx(a$1,{label:d,required:P}),jsxs("div",{className:a("rounded-lg border border-dashed bg-white p-6 sm:p-8",i?"border-red-500":"border-black/20"),role:"group",children:[v?jsxs("div",{className:"relative flex justify-center max-w-3/4 md:max-w-2/4 mx-auto",children:[jsx("img",{src:v,alt:"Preview",className:a("rounded-lg max-h-[400px] object-contain",H)}),E&&jsx("button",{type:"button",onClick:V,className:"absolute top-2 right-2 p-2 bg-red-500 text-white rounded-full hover:bg-red-600 transition-colors shadow-lg","aria-label":"Remove image",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):jsx("div",{className:a(D({iconColor:N}),y),children:B??jsx("svg",{width:"34",height:"34",viewBox:"0 0 24 24",fill:"none",className:"shrink-0","aria-hidden":"true",children:jsx("path",{d:"M12 3v10m0 0 4-4m-4 4-4-4M5 21h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx("h3",{className:"mt-4 text-center text-xl font-extrabold text-black",children:j}),jsxs("div",{className:"mt-6 flex justify-center gap-2",children:[jsx(a$2,{onClick:T,color:u,className:a("min-w-[180px]",R),disabled:o,size:"lg",variant:"outline",children:I}),jsx(a$2,{onClick:F,color:u,className:a("min-w-[180px]",k),disabled:o,size:"lg",children:w}),jsx("input",{ref:r,type:"file",className:"hidden",accept:m,multiple:p,onChange:b,disabled:o}),jsx("input",{ref:t,type:"file",className:"hidden",capture:"environment",accept:m,multiple:p,onChange:b,disabled:o})]})]}),i&&jsx("small",{className:"text-red-500 text-xs",children:i})]})};C.displayName="UploadImage";var S=C;export{S as default};
1
+ import {a as a$2}from'../chunk-IX36POX2.js';import {a as a$1}from'../chunk-DM45BGDQ.js';import {a}from'../chunk-6GLPXMGB.js';import {useRef,useState,useCallback}from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var D=cva("mx-auto flex h-16 w-16 items-center justify-center rounded-full text-white",{variants:{iconColor:{neutral:"bg-neutral-800",primary:"bg-black",red:"bg-red-700",green:"bg-green-600",blue:"bg-blue-600",yellow:"bg-yellow-500",violet:"bg-violet-600"}},defaultVariants:{iconColor:"primary"}}),C=({label:u,buttonLabel:w="Upload",buttonColor:m="primary",iconColor:N,iconBgClassName:k,buttonClassName:y,openCameraButtonClassName:R,openCameraButtonLabel:I="Open Camera",className:L,icon:B,accept:p,multiple:g,disabled:l,onFilesSelected:f,required:P,value:U,title:j="Upload Image",error:i,onClearPreview:M,showClearButton:E=false,imageClassName:H})=>{let r=useRef(null),t=useRef(null),[W,b]=useState(null),F=()=>r.current?.click(),T=useCallback(()=>{t.current&&t.current.click();},[]),v=o=>{if(o.target.files&&o.target.files.length>0){let q=o.target.files[0],c=new FileReader;c.onloadend=()=>{b(c.result);},c.readAsDataURL(q),f&&f(o.target.files);}r.current&&(r.current.value=""),t.current&&(t.current.value="");},V=()=>{b(null),M?.(),r.current&&(r.current.value=""),t.current&&(t.current.value="");},s=W||U;return jsxs("fieldset",{className:a("flex flex-col gap-2",L),children:[u&&jsx(a$1,{label:u,required:P}),jsxs("div",{className:a("rounded-lg border border-dashed bg-white p-6 sm:p-8",i?"border-red-500":"border-black/20"),role:"group",children:[s?jsxs("div",{className:"relative flex justify-center max-w-3/4 md:max-w-2/4 mx-auto",children:[jsx("img",{src:s,alt:"Preview",className:a("rounded-lg max-h-[400px] object-contain",H)}),E&&jsx("button",{type:"button",onClick:V,className:"absolute top-2 right-2 p-2 bg-red-500 text-white rounded-full hover:bg-red-600 transition-colors shadow-lg","aria-label":"Remove image",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):jsx("div",{className:a(D({iconColor:N}),k),children:B??jsx("svg",{width:"34",height:"34",viewBox:"0 0 24 24",fill:"none",className:"shrink-0","aria-hidden":"true",children:jsx("path",{d:"M12 3v10m0 0 4-4m-4 4-4-4M5 21h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),!s&&jsx("h3",{className:"mt-4 text-center text-xl font-extrabold text-black",children:j}),jsxs("div",{className:"mt-6 flex justify-center gap-2",children:[jsx(a$2,{onClick:T,color:m,className:a("min-w-[180px]",R),disabled:l,size:"lg",variant:"outline",children:I}),jsx(a$2,{onClick:F,color:m,className:a("min-w-[180px]",y),disabled:l,size:"lg",children:w}),jsx("input",{ref:r,type:"file",className:"hidden",accept:p,multiple:g,onChange:v,disabled:l}),jsx("input",{ref:t,type:"file",className:"hidden",capture:"environment",accept:p,multiple:g,onChange:v,disabled:l})]})]}),i&&jsx("small",{className:"text-red-500 text-xs",children:i})]})};C.displayName="UploadImage";var S=C;export{S as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "the-omelet-ui",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- import {a as a$3}from'./chunk-M4JODKXJ.js';import {a as a$4}from'./chunk-IX36POX2.js';import {f,b}from'./chunk-AFEF2EXB.js';import {a as a$1}from'./chunk-DM45BGDQ.js';import {a as a$2}from'./chunk-6GLPXMGB.js';import*as a from'react';import*as l from'@radix-ui/react-popover';import {jsxs,jsx}from'react/jsx-runtime';function ae(i){return typeof i=="string"?{id:i,label:i}:i}var se={neutral:"border-neutral-900 bg-neutral-900 text-white",primary:"border-black bg-black text-white",red:"border-red-600 bg-red-600 text-white",green:"border-green-600 bg-green-600 text-white",blue:"border-blue-600 bg-blue-600 text-white",yellow:"border-yellow-500 bg-yellow-500 text-black",violet:"border-violet-600 bg-violet-600 text-white"};function le({trigger:i,triggerPlaceholder:v="Choose",items:x,selectionMode:b$1="multiple",value:y,defaultValue:q,onChange:z,searchable:w=true,placeholder:Q="Placeholder Text",searchButtonLabel:A="Search",onQueryChange:O,onSearch:V,loading:m=false,emptyLabel:j="No results",contentClassName:D,maxHeight:H=288,renderItem:k,buttonColor:W="primary",searchButtonColor:_,searchButtonClassName:$,checkedColor:E="primary",checkedClassName:F,renderTriggerValue:R,label:N,required:G}){let[C,P]=a.useState(false),[p,J]=a.useState(""),[g,K]=a.useState(""),s=b$1==="multiple",[U,X]=a.useState(q??(s?[]:"")),o=y??U,d=a.useMemo(()=>x.map(ae),[x]),S=a.useMemo(()=>{let e=g.trim().toLowerCase();return e?d.filter(r=>String(r.label).toLowerCase().includes(e)):d},[d,g]),I=e=>{z?.(e),y===void 0&&X(e);},Y=e=>{if(s){let r=new Set(o);r.has(e)?r.delete(e):r.add(e),I(Array.from(r));}else I(e),P(false);},Z=e=>s?o.includes(e):o===e,ee=()=>{K(p),V?.(p);},f$1=a.useMemo(()=>s?o:o?[o]:[],[o,s]),u=a.useMemo(()=>d.filter(e=>f$1.includes(e.id)),[d,f$1]),te=a.useMemo(()=>u.length===0?v:s?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${u.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:u[0].label,[u,s,v]);return jsxs(l.Root,{open:C,onOpenChange:P,children:[N&&jsx(a$1,{label:N,required:G}),jsx("div",{className:"mb-2"}),jsx(l.Trigger,{asChild:true,children:i??jsxs("button",{type:"button",className:a$2("flex w-full min-w-[260px] items-center justify-between","rounded-md border border-black/15 bg-white px-4 py-3 text-left","outline-none focus-visible:ring-2 ring-black/20"),children:[jsx("span",{className:a$2("flex-1 ",{"text-gray-400":s?o?.length===0:!o,"text-black":s?o?.length>0:!!o}),children:R?R(f$1,u):te}),jsx("svg",{className:a$2("ml-3 h-5 w-5 text-black/60 transition-transform",C?"rotate-180":"rotate-0"),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:jsx("path",{d:"M6 9l6 6 6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]})}),jsx(l.Portal,{children:jsxs(l.Content,{sideOffset:8,className:a$2("w-[300px] rounded-md border border-black/10 bg-white p-2 shadow-xl",D),children:[w&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:e=>{e.preventDefault(),ee();},children:[jsx(a$3,{start:jsx(f,{className:"h-3 w-3 text-black/50"}),value:p,onChange:e=>{J(e.currentTarget.value),O?.(e.currentTarget.value);},size:"sm",placeholder:Q}),jsx(a$4,{color:_??W,type:"submit",disabled:m||p.trim()===g.trim(),size:"md",className:$,children:A})]}),jsxs("div",{role:"listbox","aria-multiselectable":s||void 0,className:a$2(" overflow-y-auto rounded-md",{"mt-3":w}),style:{maxHeight:H},children:[m&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),!m&&S.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:j}),!m&&S.map(e=>{let r=Z(e.id),re=se[E],oe=jsxs(a$4,{type:"button",role:"option","aria-selected":r,onClick:()=>Y(e.id),disabled:e.disabled,size:"sm",className:a$2("group flex w-full items-center justify-between gap-3 rounded-md px-2 py-2 text-left bg-white","hover:bg-black/[0.04] disabled:opacity-50",{"bg-black/[0.04]":r&&b$1==="single"}),children:[jsx("span",{className:"text-md text-black",children:e.label}),b$1==="multiple"&&jsx("span",{className:a$2("grid h-5 w-5 place-items-center rounded-full border-2",r?re:"border-black/20",r&&F),children:r?jsx(b,{className:"h-2 w-2"}):null})]},e.id);return k?jsx("div",{children:k(e,false,r)},e.id):oe})]}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]})}var me=le;export{me as a};