the-omelet-ui 1.3.6 → 1.3.7

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 {a as a$1}from'./chunk-DM45BGDQ.js';import {f,b}from'./chunk-AFEF2EXB.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 le(c){return typeof c=="string"?{id:c,label:c}:c}var ne={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:c,triggerPlaceholder:y="Choose",items:w,selectionMode:g="multiple",value:k,defaultValue:Q,onChange:A,searchable:R=true,placeholder:O="Placeholder Text",searchButtonLabel:V="Search",onQueryChange:j,onSearch:D,loading:m=false,emptyLabel:H="No results",contentClassName:W,maxHeight:_=288,renderItem:N,buttonColor:$="primary",searchButtonColor:E,searchButtonClassName:F,checkedColor:G="primary",checkedClassName:J,renderTriggerValue:C,label:P,required:K,errorMessage:f$1,disabled:p}){let[S,I]=a.useState(false),[b$1,U]=a.useState(""),[h,X]=a.useState(""),s=g==="multiple",[Y,Z]=a.useState(Q??(s?[]:"")),o=k??Y,d=a.useMemo(()=>w.map(le),[w]),B=a.useMemo(()=>{let e=h.trim().toLowerCase();return e?d.filter(r=>String(r.label).toLowerCase().includes(e)):d},[d,h]),L=e=>{A?.(e),k===void 0&&Z(e);},ee=e=>{if(s){let r=new Set(o);r.has(e)?r.delete(e):r.add(e),L(Array.from(r));}else L(e),I(false);},te=e=>s?o.includes(e):o===e,re=()=>{X(b$1),D?.(b$1);},v=a.useMemo(()=>s?o:o?[o]:[],[o,s]),u=a.useMemo(()=>d.filter(e=>v.includes(e.id)),[d,v]),oe=a.useMemo(()=>u.length===0?y:s?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${u.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:u[0].label,[u,s,y]);return jsxs("fieldset",{children:[P&&jsx(a$1,{label:P,required:K}),jsxs(l.Root,{open:S&&!p,onOpenChange:e=>!p&&I(e),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",f$1&&!p?"border-red-600":"",p?"opacity-50 cursor-not-allowed":""),children:[jsx("span",{className:a$2("flex-1 ",{"text-gray-400":s?o?.length===0:!o,"text-black":s?o?.length>0:!!o}),children:C?C(v,u):oe}),jsx("svg",{className:a$2("ml-3 h-5 w-5 text-black/60 transition-transform",S?"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",W),children:[R&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:e=>{e.preventDefault(),re();},children:[jsx(a$3,{start:jsx(f,{className:"h-3 w-3 text-black/50"}),value:b$1,onChange:e=>{U(e.currentTarget.value),j?.(e.currentTarget.value);},size:"sm",placeholder:O}),jsx(a$4,{color:E??$,type:"submit",disabled:m||b$1.trim()===h.trim(),size:"md",className:F,children:V})]}),jsxs("div",{role:"listbox","aria-multiselectable":s||void 0,className:a$2(" overflow-y-auto rounded-md",{"mt-3":R}),style:{maxHeight:_},children:[m&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),!m&&B.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:H}),!m&&B.map(e=>{let r=te(e.id),ae=ne[G],se=jsxs(a$4,{type:"button",role:"option","aria-selected":r,onClick:()=>ee(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&&g==="single"}),children:[jsx("span",{className:"text-md text-black",children:e.label}),g==="multiple"&&jsx("span",{className:a$2("grid h-5 w-5 place-items-center rounded-full border-2",r?ae:"border-black/20",r&&J),children:r?jsx(b,{className:"h-2 w-2"}):null})]},e.id);return N?jsx("div",{children:N(e,false,r)},e.id):se})]}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]}),f$1&&jsx("small",{className:"text-red-500 text-xs",children:f$1})]})}var be=ie;export{be as a};
@@ -15,7 +15,7 @@ type DistrictProps = {
15
15
  onChange?: (district: District) => void;
16
16
  value?: string;
17
17
  required?: boolean;
18
- provinceId: number;
18
+ provinceId?: number;
19
19
  };
20
20
  declare const DistrictDropdown: ({ locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required, provinceId }: DistrictProps) => react_jsx_runtime.JSX.Element;
21
21
 
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-Q66YUYSD.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-AFEF2EXB.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-LGK5OJYE.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-AFEF2EXB.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/district.json")).json()).filter(o=>o.province_id===t),w=({locale:t="th",searchPlaceholder:s="Search District",placeholder:c="Select District",label:l,searchButtonClassName:o="bg-blue-500",onChange:p,value:n,required:D=false,provinceId:a$1})=>{let[r,g]=useState([]),[b,d]=useState(null);useEffect(()=>{a$1&&P(a$1).then(g);},[a$1]),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 _=useCallback(e=>{let i=r.find(C=>C.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:o,onChange:e=>{typeof e=="string"&&_(e);},value:b?.id,required:D,disabled:!a$1})})},x=w;
2
2
  export{x as default};
@@ -14,7 +14,8 @@ type ProvinceProps = {
14
14
  onChange?: (province: Province) => void;
15
15
  value?: string;
16
16
  required?: boolean;
17
+ disabled?: boolean;
17
18
  };
18
- declare const ProvinceDropdown: ({ locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required }: ProvinceProps) => react_jsx_runtime.JSX.Element;
19
+ declare const ProvinceDropdown: ({ disabled, locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required }: ProvinceProps) => react_jsx_runtime.JSX.Element;
19
20
 
20
21
  export { type Province, type ProvinceProps, ProvinceDropdown as default };
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-Q66YUYSD.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-AFEF2EXB.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
- export{x as default};
1
+ import {a}from'../chunk-LGK5OJYE.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-AFEF2EXB.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var C=(e,t)=>t==="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},w=async()=>await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province.json")).json(),x=({disabled:e,locale:t="th",searchPlaceholder:u="Search Province",placeholder:P="Select Province",label:v,searchButtonClassName:m="bg-blue-500",onChange:a$1,value:i,required:f=false})=>{let[o,p]=useState([]),[g,s]=useState(null);useEffect(()=>{w().then(p);},[]),useEffect(()=>{if(i){let n=o.find(r=>t==="th"?r.name_th===i:r.name_en===i);n&&s(n);}},[o,i,t]);let b=useCallback(n=>{let r=o.find(_=>_.id===n);r&&(s(r),a$1?.(r));},[o,a$1]);return jsx("div",{children:jsx(a,{items:o.map(n=>C(n,t)),placeholder:u,triggerPlaceholder:P,label:v,selectionMode:"single",searchButtonClassName:m,onChange:n=>{b(n);},value:g?.id,required:f,disabled:e})})},y=x;
2
+ export{y as default};
@@ -41,7 +41,8 @@ type SearchSelectProps = {
41
41
  label?: string;
42
42
  required?: boolean;
43
43
  errorMessage?: string;
44
+ disabled?: boolean;
44
45
  };
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;
46
+ 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, disabled }: SearchSelectProps): react_jsx_runtime.JSX.Element;
46
47
 
47
48
  export { type SearchSelectProps, SearchSelect as default };
@@ -1 +1 @@
1
- export{a as default}from'../chunk-Q66YUYSD.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-AFEF2EXB.js';import'../chunk-6GLPXMGB.js';
1
+ export{a as default}from'../chunk-LGK5OJYE.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-AFEF2EXB.js';import'../chunk-6GLPXMGB.js';
@@ -15,7 +15,7 @@ type SubDistrictProps = {
15
15
  onChange?: (district: SubDistrict) => void;
16
16
  value?: string;
17
17
  required?: boolean;
18
- districtId: number;
18
+ districtId?: number;
19
19
  };
20
20
  declare const SubDistrictDropdown: ({ locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required, districtId }: SubDistrictProps) => react_jsx_runtime.JSX.Element;
21
21
 
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-Q66YUYSD.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-AFEF2EXB.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-LGK5OJYE.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-AFEF2EXB.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(o=>o.district_id===t),w=({locale:t="th",searchPlaceholder:s="Search District",placeholder:c="Select District",label:l,searchButtonClassName:o="bg-blue-500",onChange:f,value:n,required:p=false,districtId:a$1})=>{let[r,S]=useState([]),[g,d]=useState(null);useEffect(()=>{a$1&&P(a$1).then(S);},[a$1]),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),f?.(i));},[r]);return jsx("div",{children:jsx(a,{items:r.map(e=>v(e,t)),placeholder:s,triggerPlaceholder:c,label:l,selectionMode:"single",searchButtonClassName:o,onChange:e=>{typeof e=="string"&&D(e);},value:g?.id,required:p,disabled:!a$1})})},x=w;
2
2
  export{x as default};
@@ -1,4 +1,4 @@
1
- import {a}from'../chunk-DM45BGDQ.js';import {forwardRef}from'react';import {jsxs,jsx}from'react/jsx-runtime';var l=forwardRef(({label:t="\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 (\u0E1A\u0E49\u0E32\u0E19\u0E40\u0E25\u0E02\u0E17\u0E35\u0E48/\u0E0B\u0E2D\u0E22/\u0E16\u0E19\u0E19)",error:r,required:o=false,className:s="",...n},d)=>jsxs("fieldset",{className:"relative flex flex-col gap-2 items-start text-start",children:[t&&jsx(a,{label:t,required:o}),jsx("div",{className:"relative",children:jsx("textarea",{ref:d,placeholder:"\u0E01\u0E23\u0E2D\u0E01\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E08\u0E31\u0E14\u0E2A\u0E48\u0E07\u0E02\u0E2D\u0E07\u0E23\u0E32\u0E07\u0E27\u0E31\u0E25",rows:4,className:`
1
+ import {a}from'../chunk-DM45BGDQ.js';import {forwardRef}from'react';import {jsxs,jsx}from'react/jsx-runtime';var l=forwardRef(({label:t="\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 (\u0E1A\u0E49\u0E32\u0E19\u0E40\u0E25\u0E02\u0E17\u0E35\u0E48/\u0E0B\u0E2D\u0E22/\u0E16\u0E19\u0E19)",error:r,required:o=false,className:s="",...n},d)=>jsxs("fieldset",{className:"relative flex flex-col gap-2 items-start text-start",children:[t&&jsx(a,{label:t,required:o}),jsx("div",{className:"relative w-full",children:jsx("textarea",{ref:d,placeholder:"\u0E01\u0E23\u0E2D\u0E01\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E08\u0E31\u0E14\u0E2A\u0E48\u0E07\u0E02\u0E2D\u0E07\u0E23\u0E32\u0E07\u0E27\u0E31\u0E25",rows:4,className:`
2
2
  w-full px-4 py-3
3
3
  border rounded-lg
4
4
  text-gray-900 placeholder-gray-400
@@ -7,4 +7,4 @@ import {a}from'../chunk-DM45BGDQ.js';import {forwardRef}from'react';import {jsxs
7
7
  focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent
8
8
  ${r?"border-red-500":"border-gray-300"}
9
9
  ${s}
10
- `,...n})}),r&&jsx("small",{className:"text-red-500 text-xs",children:r})]}));l.displayName="TextAreaInput";var f=l;export{f as default};
10
+ `,...n})}),r&&jsx("small",{className:"text-red-500 text-xs",children:r})]}));l.displayName="TextAreaInput";var i=l;export{i as default};
@@ -7,4 +7,4 @@ import {jsxs,jsx}from'react/jsx-runtime';var c=({imageSrc:o,header:e,body:t,foot
7
7
  `,onClick:l,children:[o&&jsx("div",{className:"relative w-full aspect-[4/3] bg-gray-100 overflow-hidden",children:jsx("img",{src:o,alt:"Reward",className:`
8
8
  w-full h-full object-cover
9
9
  ${s?"grayscale":""}
10
- `,loading:"lazy"})}),jsxs("div",{className:"p-6",children:[jsx("div",{className:"mb-4",children:typeof e=="string"?jsx("h3",{className:"text-2xl font-bold text-gray-900",children:e}):e}),jsx("div",{className:"mb-4",children:typeof t=="string"?jsx("p",{className:"text-gray-700",children:t}):t}),r&&jsx("div",{className:"mt-6",children:r})]})]}),m=c;export{m as default};
10
+ `,loading:"lazy"})}),jsxs("div",{className:"p-4",children:[jsx("div",{className:"mb-4",children:typeof e=="string"?jsx("h3",{className:"text-2xl font-bold text-gray-900",children:e}):e}),jsx("div",{className:"mb-4",children:typeof t=="string"?jsx("p",{className:"text-gray-700",children:t}):t}),r&&jsx("div",{className:"mt-6",children:r})]})]}),m=c;export{m as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "the-omelet-ui",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- import {a as a$3}from'./chunk-A2DBYHBF.js';import {a as a$4}from'./chunk-IX36POX2.js';import {a as a$1}from'./chunk-DM45BGDQ.js';import {f,b}from'./chunk-AFEF2EXB.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};
File without changes