the-omelet-ui 1.8.39 → 1.8.41

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.
@@ -1 +1 @@
1
- import {b,a as a$4}from'./chunk-RIPJ77V4.js';import {a as a$6}from'./chunk-LHW4VKJO.js';import {a as a$2}from'./chunk-VOTSEDLU.js';import {a as a$3}from'./chunk-BTXIMIJL.js';import {a as a$5}from'./chunk-IX36POX2.js';import {a}from'./chunk-THE2HQGT.js';import {a as a$1}from'./chunk-6GLPXMGB.js';import*as t from'react';import*as i from'@radix-ui/react-popover';import {jsx,jsxs}from'react/jsx-runtime';var Ke=s=>a=>{s(typeof a=="string"?a:a[0]||"");},Xe=s=>a=>{s(Array.isArray(a)?a:[a]);};function le(s){return typeof s=="string"?{id:s,label:s}:s}var Ve={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 He(s,a){let[C,L]=t.useState(s);return t.useEffect(()=>{let n=setTimeout(()=>L(s),a);return ()=>clearTimeout(n)},[s,a]),C}function Fe({autoFocus:s=false,trigger:a$7,triggerPlaceholder:C="Choose",items:L,loadOptions:n,selectionMode:A="multiple",value:U,defaultValue:ce,onChange:ie,searchable:W=true,placeholder:ue="Placeholder Text",searchButtonLabel:de="Search",onQueryChange:me,onSearch:z,loading:ge=false,emptyLabel:pe="No results",errorLabel:be="Failed to load options",contentClassName:fe,maxHeight:he=288,renderItem:Z,buttonColor:Re="primary",searchButtonColor:xe,searchButtonClassName:ye,checkedColor:ve="primary",checkedClassName:ke,renderTriggerValue:_,label:$,required:Ce,enablePagination:R=false,pageSize:G=20,errorMessage:M,size:Ne="md",onSearchMode:x="onClickButton",debounceMs:we=300,onOpenChange:J,popoverZIndex:Ie=1001,disabled:N=false}){let[w,K]=t.useState(false),[m,X]=t.useState(""),[I,y]=t.useState(""),[Se,S]=t.useState([]),[D,Y]=t.useState(false),[q,Q]=t.useState(null),[Pe,P]=t.useState(1),[Be,B]=t.useState(true),u=He(m,we),v=t.useRef(null),c=A==="multiple",[Te,Le]=t.useState(ce??(c?[]:"")),l=U??Te,O=n?Se:L||[],b$1=t.useMemo(()=>O.map(le),[O]),f=t.useCallback(async(e,o=1,g=false)=>{if(n){Y(true),Q(null);try{let F=(await n(e)).map(le);S(g?Ee=>[...Ee,...F]:F),R&&B(F.length===G);}catch(p){Q(p instanceof Error?p.message:"Unknown error"),S([]);}finally{Y(false);}}},[n,R,G]),Ae=t.useCallback(e=>{K(e),J?.(e),e&&(X(""),y(""),P(1),B(true),Q(null),S([]),v.current=null,n&&(f("",1,false),v.current=""));},[n,f,J]);t.useEffect(()=>{!w||x!=="onChange"||u!==v.current&&(v.current=u,n?(P(1),B(true),f(u,1,false),y(u)):(y(u),z?.(u)));},[u,w,x,n,f,z]);let T=t.useMemo(()=>{if(n)return b$1;let o=(x==="onChange"?u:I).trim().toLowerCase();return o?b$1.filter(g=>String(g.label).toLowerCase().includes(o)):b$1},[b$1,I,u,n,x]),ee=e=>{ie?.(e),U===void 0&&Le(e);},ze=e=>{if(c){let o=new Set(l);o.has(e)?o.delete(e):o.add(e),ee(Array.from(o));}else ee(e),K(false);},Me=e=>c?l.includes(e):l===e,De=()=>{n?(P(1),B(true),f(m,1,false),y(m),v.current=m):(y(m),z?.(m));},qe=()=>{if(!D&&Be&&R){let e=Pe+1;P(e),f(I,e,true);}},E=t.useMemo(()=>c?l:l?[l]:[],[l,c]),k=t.useMemo(()=>b$1.filter(e=>E.includes(e.id)),[b$1,E]),Qe=t.useMemo(()=>k.length===0?C:c?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${k.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:k[0].label,[k,c,C]),V=D||ge,H=x==="onClickButton";return jsx("fieldset",{children:jsxs(i.Root,{open:w&&!N,onOpenChange:N?void 0:Ae,children:[$&&jsx(a,{label:$,required:Ce}),jsx("div",{className:"mb-2"}),jsx(i.Trigger,{asChild:true,children:a$7??jsxs("button",{type:"button",className:a$1("flex w-full min-w-[260px] items-center justify-between","rounded-md border border-[#C9D7E3] bg-white px-2 py-3 text-left","outline-none focus-visible:ring-2 ring-black/20",M&&!N?"border-red-600":"",N?"opacity-50 cursor-not-allowed":"",b[Ne]),children:[jsx("span",{className:a$1("flex-1 line-clamp-1",{"text-[#A5A9AD]":c?l?.length===0:!l,"text-black":c?l?.length>0:!!l}),children:_?_(E,k):Qe}),jsx(a$2,{fontSize:16,className:a$1("ml-3 text-black/60 transition-transform",w?"rotate-180":"rotate-0")})]})}),M&&jsx("small",{className:"text-red-500 text-xs",children:M}),jsx(i.Portal,{children:jsxs(i.Content,{sideOffset:8,onOpenAutoFocus:e=>{if(!s){e.preventDefault();return}},style:{zIndex:Ie},className:a$1("w-[300px] rounded-md border border-black/10 bg-white p-2 shadow-xl","z-[1001]",fe),children:[W&&jsxs("form",{className:a$1("gap-3",H?"grid grid-cols-[1fr_auto]":"block"),onSubmit:e=>{e.preventDefault(),H&&De();},children:[jsx(a$3,{start:jsx(a$4,{}),value:m,onChange:e=>{X(e.currentTarget.value),me?.(e.currentTarget.value);},size:"sm",placeholder:ue}),H&&jsx(a$5,{color:xe??Re,type:"submit",disabled:V||m.trim()===I.trim(),size:"sm",className:ye,children:de})]}),jsxs("div",{role:"listbox","aria-multiselectable":c||void 0,className:a$1("overflow-y-auto rounded-md",{"mt-3":W}),style:{maxHeight:he},onScroll:e=>{if(!R)return;let{scrollTop:o,scrollHeight:g,clientHeight:p}=e.currentTarget;g-o<=p+50&&qe();},children:[V&&T.length===0&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),q&&jsx("div",{className:"p-6 text-center text-red-600",children:be}),!V&&!q&&T.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:pe}),!q&&T.map(e=>{let o=Me(e.id),g=Ve[ve],p=jsxs(a$5,{type:"button",role:"option","aria-selected":o,onClick:()=>ze(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]":o&&A==="single"}),children:[jsx("span",{className:"text-md text-black",children:e.label}),A==="multiple"&&jsx("span",{className:a$1("grid h-5 w-5 place-items-center rounded-full border-2",o?g:"border-black/20",o&&ke),children:o?jsx(a$6,{fontSize:10}):null})]},e.id);return Z?jsx("div",{children:Z(e,false,o)},e.id):p}),R&&D&&T.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(i.Arrow,{className:"fill-white stroke-black/10"})]})})]})})}var Ye=Fe;export{Ke as a,Xe as b,Ye as c};
1
+ import {b,a as a$4}from'./chunk-RIPJ77V4.js';import {a as a$6}from'./chunk-LHW4VKJO.js';import {a as a$2}from'./chunk-VOTSEDLU.js';import {a as a$3}from'./chunk-KA7C25YJ.js';import {a as a$5}from'./chunk-IX36POX2.js';import {a}from'./chunk-THE2HQGT.js';import {a as a$1}from'./chunk-6GLPXMGB.js';import*as t from'react';import*as i from'@radix-ui/react-popover';import {jsx,jsxs}from'react/jsx-runtime';var Ke=s=>a=>{s(typeof a=="string"?a:a[0]||"");},Xe=s=>a=>{s(Array.isArray(a)?a:[a]);};function le(s){return typeof s=="string"?{id:s,label:s}:s}var Ve={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 He(s,a){let[C,L]=t.useState(s);return t.useEffect(()=>{let n=setTimeout(()=>L(s),a);return ()=>clearTimeout(n)},[s,a]),C}function Fe({autoFocus:s=false,trigger:a$7,triggerPlaceholder:C="Choose",items:L,loadOptions:n,selectionMode:A="multiple",value:U,defaultValue:ce,onChange:ie,searchable:W=true,placeholder:ue="Placeholder Text",searchButtonLabel:de="Search",onQueryChange:me,onSearch:z,loading:ge=false,emptyLabel:pe="No results",errorLabel:be="Failed to load options",contentClassName:fe,maxHeight:he=288,renderItem:Z,buttonColor:Re="primary",searchButtonColor:xe,searchButtonClassName:ye,checkedColor:ve="primary",checkedClassName:ke,renderTriggerValue:_,label:$,required:Ce,enablePagination:R=false,pageSize:G=20,errorMessage:M,size:Ne="md",onSearchMode:x="onClickButton",debounceMs:we=300,onOpenChange:J,popoverZIndex:Ie=1001,disabled:N=false}){let[w,K]=t.useState(false),[m,X]=t.useState(""),[I,y]=t.useState(""),[Se,S]=t.useState([]),[D,Y]=t.useState(false),[q,Q]=t.useState(null),[Pe,P]=t.useState(1),[Be,B]=t.useState(true),u=He(m,we),v=t.useRef(null),c=A==="multiple",[Te,Le]=t.useState(ce??(c?[]:"")),l=U??Te,O=n?Se:L||[],b$1=t.useMemo(()=>O.map(le),[O]),f=t.useCallback(async(e,o=1,g=false)=>{if(n){Y(true),Q(null);try{let F=(await n(e)).map(le);S(g?Ee=>[...Ee,...F]:F),R&&B(F.length===G);}catch(p){Q(p instanceof Error?p.message:"Unknown error"),S([]);}finally{Y(false);}}},[n,R,G]),Ae=t.useCallback(e=>{K(e),J?.(e),e&&(X(""),y(""),P(1),B(true),Q(null),S([]),v.current=null,n&&(f("",1,false),v.current=""));},[n,f,J]);t.useEffect(()=>{!w||x!=="onChange"||u!==v.current&&(v.current=u,n?(P(1),B(true),f(u,1,false),y(u)):(y(u),z?.(u)));},[u,w,x,n,f,z]);let T=t.useMemo(()=>{if(n)return b$1;let o=(x==="onChange"?u:I).trim().toLowerCase();return o?b$1.filter(g=>String(g.label).toLowerCase().includes(o)):b$1},[b$1,I,u,n,x]),ee=e=>{ie?.(e),U===void 0&&Le(e);},ze=e=>{if(c){let o=new Set(l);o.has(e)?o.delete(e):o.add(e),ee(Array.from(o));}else ee(e),K(false);},Me=e=>c?l.includes(e):l===e,De=()=>{n?(P(1),B(true),f(m,1,false),y(m),v.current=m):(y(m),z?.(m));},qe=()=>{if(!D&&Be&&R){let e=Pe+1;P(e),f(I,e,true);}},E=t.useMemo(()=>c?l:l?[l]:[],[l,c]),k=t.useMemo(()=>b$1.filter(e=>E.includes(e.id)),[b$1,E]),Qe=t.useMemo(()=>k.length===0?C:c?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${k.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:k[0].label,[k,c,C]),V=D||ge,H=x==="onClickButton";return jsx("fieldset",{children:jsxs(i.Root,{open:w&&!N,onOpenChange:N?void 0:Ae,children:[$&&jsx(a,{label:$,required:Ce}),jsx("div",{className:"mb-2"}),jsx(i.Trigger,{asChild:true,children:a$7??jsxs("button",{type:"button",className:a$1("flex w-full min-w-[260px] items-center justify-between","rounded-md border border-[#C9D7E3] bg-white px-2 py-3 text-left","outline-none focus-visible:ring-2 ring-black/20",M&&!N?"border-red-600":"",N?"opacity-50 cursor-not-allowed":"",b[Ne]),children:[jsx("span",{className:a$1("flex-1 line-clamp-1",{"text-[#A5A9AD]":c?l?.length===0:!l,"text-black":c?l?.length>0:!!l}),children:_?_(E,k):Qe}),jsx(a$2,{fontSize:16,className:a$1("ml-3 text-black/60 transition-transform",w?"rotate-180":"rotate-0")})]})}),M&&jsx("small",{className:"text-red-500 text-xs",children:M}),jsx(i.Portal,{children:jsxs(i.Content,{sideOffset:8,onOpenAutoFocus:e=>{if(!s){e.preventDefault();return}},style:{zIndex:Ie},className:a$1("w-[300px] rounded-md border border-black/10 bg-white p-2 shadow-xl","z-[1001]",fe),children:[W&&jsxs("form",{className:a$1("gap-3",H?"grid grid-cols-[1fr_auto]":"block"),onSubmit:e=>{e.preventDefault(),H&&De();},children:[jsx(a$3,{start:jsx(a$4,{}),value:m,onChange:e=>{X(e.currentTarget.value),me?.(e.currentTarget.value);},size:"sm",placeholder:ue}),H&&jsx(a$5,{color:xe??Re,type:"submit",disabled:V||m.trim()===I.trim(),size:"sm",className:ye,children:de})]}),jsxs("div",{role:"listbox","aria-multiselectable":c||void 0,className:a$1("overflow-y-auto rounded-md",{"mt-3":W}),style:{maxHeight:he},onScroll:e=>{if(!R)return;let{scrollTop:o,scrollHeight:g,clientHeight:p}=e.currentTarget;g-o<=p+50&&qe();},children:[V&&T.length===0&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),q&&jsx("div",{className:"p-6 text-center text-red-600",children:be}),!V&&!q&&T.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:pe}),!q&&T.map(e=>{let o=Me(e.id),g=Ve[ve],p=jsxs(a$5,{type:"button",role:"option","aria-selected":o,onClick:()=>ze(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]":o&&A==="single"}),children:[jsx("span",{className:"text-md text-black",children:e.label}),A==="multiple"&&jsx("span",{className:a$1("grid h-5 w-5 place-items-center rounded-full border-2",o?g:"border-black/20",o&&ke),children:o?jsx(a$6,{fontSize:10}):null})]},e.id);return Z?jsx("div",{children:Z(e,false,o)},e.id):p}),R&&D&&T.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(i.Arrow,{className:"fill-white stroke-black/10"})]})})]})})}var Ye=Fe;export{Ke as a,Xe as b,Ye as c};
@@ -1 +1 @@
1
- import {a as a$2}from'./chunk-QRYSV225.js';import {a}from'./chunk-THE2HQGT.js';import {a as a$1}from'./chunk-6GLPXMGB.js';import*as u from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var E=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 placeholder:text-[#A5A9AD]",{variants:{size:{sm:"h-8 px-2 py-3 text-sm",md:"h-10 px-2 py-4 text-md",lg:"h-12 px-2 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"}}),b=u.forwardRef(({className:c,start:s,end:r,size:f,tone:m,withStart:x,withEnd:g,error:e,label:i,required:n,disabled:v=false,id:a$3,...h},w)=>jsxs("fieldset",{className:"relative flex flex-col space-y-2",children:[i&&jsx(a,{label:i,required:n,id:a$3}),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",{...h,id:a$3,ref:w,"data-state":e?"invalid":void 0,className:a$1(E({size:f,tone:e?"danger":m,withStart:x??!!s,withEnd:g??!!r}),c),disabled:v,"aria-describedby":e?`${a$3}-error`:void 0,"aria-invalid":!!e,required:n}),r?jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pe-3",children:r}):null]}),e&&jsx(a$2,{message:e})]}));b.displayName="TextInput";var A=b;export{A as a};
1
+ import {a as a$2}from'./chunk-QRYSV225.js';import {a}from'./chunk-THE2HQGT.js';import {a as a$1}from'./chunk-6GLPXMGB.js';import*as u from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var E=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 placeholder:text-[#A5A9AD]",{variants:{size:{sm:"h-8 px-2 py-3 text-sm",md:"h-10 px-2 py-4 text-md",lg:"h-12 px-2 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"}}),b=u.forwardRef(({className:c,start:s,end:r,size:f,tone:m,withStart:x,withEnd:g,error:e,label:i,required:n,disabled:v=false,id:a$3,...h},w)=>jsxs("fieldset",{className:"relative flex flex-col space-y-2 w-full",children:[i&&jsx(a,{label:i,required:n,id:a$3}),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",{...h,id:a$3,ref:w,"data-state":e?"invalid":void 0,className:a$1(E({size:f,tone:e?"danger":m,withStart:x??!!s,withEnd:g??!!r}),c),disabled:v,"aria-describedby":e?`${a$3}-error`:void 0,"aria-invalid":!!e,required:n}),r?jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pe-3",children:r}):null]}),e&&jsx(a$2,{message:e})]}));b.displayName="TextInput";var A=b;export{A as a};
@@ -1,2 +1,2 @@
1
- import {c}from'../chunk-HNWRZZOG.js';import'../chunk-RIPJ77V4.js';import'../chunk-LHW4VKJO.js';import'../chunk-VOTSEDLU.js';import'../chunk-BTXIMIJL.js';import'../chunk-IX36POX2.js';import'../chunk-QRYSV225.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var k=(e,r)=>r==="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},y=async e=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/district.json")).json()).filter(a=>a.province_id===e),q=({searchLabel:e="Search",locale:r="th",searchPlaceholder:c$1="Search District",placeholder:l="Select District",label:a,searchButtonClassName:b="bg-blue-500",onChange:d,value:s,required:f=false,provinceId:o,error:D,onSearchMode:_,debounceMs:v,onOpenChange:C,popoverZIndex:S})=>{let[i,x]=useState([]),[M,u]=useState(null);useEffect(()=>{o&&y(o).then(x);},[o]),useEffect(()=>{if(s){let t=i.find(n=>r==="th"?n.name_th===s:n.name_en===s);t&&u(t);}},[i,s,r]);let P=useCallback(t=>{let n=i.find(w=>w.id===t);n&&(u(n),d?.(n));},[i,d]);return jsx("div",{children:jsx(c,{items:i.map(t=>k(t,r)),placeholder:c$1,triggerPlaceholder:l,label:a,selectionMode:"single",searchButtonClassName:b,onChange:t=>{P(t);},searchButtonLabel:e,value:M?.id,required:f,disabled:!o,errorMessage:D,onSearchMode:_,debounceMs:v,onOpenChange:C,popoverZIndex:S})})},L=q;
1
+ import {c}from'../chunk-7GRVTCP3.js';import'../chunk-RIPJ77V4.js';import'../chunk-LHW4VKJO.js';import'../chunk-VOTSEDLU.js';import'../chunk-KA7C25YJ.js';import'../chunk-IX36POX2.js';import'../chunk-QRYSV225.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var k=(e,r)=>r==="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},y=async e=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/district.json")).json()).filter(a=>a.province_id===e),q=({searchLabel:e="Search",locale:r="th",searchPlaceholder:c$1="Search District",placeholder:l="Select District",label:a,searchButtonClassName:b="bg-blue-500",onChange:d,value:s,required:f=false,provinceId:o,error:D,onSearchMode:_,debounceMs:v,onOpenChange:C,popoverZIndex:S})=>{let[i,x]=useState([]),[M,u]=useState(null);useEffect(()=>{o&&y(o).then(x);},[o]),useEffect(()=>{if(s){let t=i.find(n=>r==="th"?n.name_th===s:n.name_en===s);t&&u(t);}},[i,s,r]);let P=useCallback(t=>{let n=i.find(w=>w.id===t);n&&(u(n),d?.(n));},[i,d]);return jsx("div",{children:jsx(c,{items:i.map(t=>k(t,r)),placeholder:c$1,triggerPlaceholder:l,label:a,selectionMode:"single",searchButtonClassName:b,onChange:t=>{P(t);},searchButtonLabel:e,value:M?.id,required:f,disabled:!o,errorMessage:D,onSearchMode:_,debounceMs:v,onOpenChange:C,popoverZIndex:S})})},L=q;
2
2
  export{L as default};
@@ -1 +1 @@
1
- import {a}from'../chunk-BTXIMIJL.js';import'../chunk-QRYSV225.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {jsx}from'react/jsx-runtime';var d=({allowDecimal:n=false,allowNegative:r=false,onKeyDown:a$1,onPaste:s,...u})=>jsx(a,{...u,type:"number",onKeyDown:e=>{let t=["e","E","+"];if(n||t.push("."),r||t.push("-"),t.includes(e.key)){e.preventDefault();return}a$1?.(e);},onPaste:e=>{let t=e.clipboardData.getData("text"),o="";if(r?o=n?"^-?\\d*\\.?\\d*$":"^-?\\d*$":o=n?"^\\d*\\.?\\d*$":"^\\d*$",!new RegExp(o).test(t)){e.preventDefault();return}s?.(e);}}),l=d;export{l as default};
1
+ import {a}from'../chunk-KA7C25YJ.js';import'../chunk-QRYSV225.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {jsx}from'react/jsx-runtime';var d=({allowDecimal:n=false,allowNegative:r=false,onKeyDown:a$1,onPaste:s,...u})=>jsx(a,{...u,type:"number",onKeyDown:e=>{let t=["e","E","+"];if(n||t.push("."),r||t.push("-"),t.includes(e.key)){e.preventDefault();return}a$1?.(e);},onPaste:e=>{let t=e.clipboardData.getData("text"),o="";if(r?o=n?"^-?\\d*\\.?\\d*$":"^-?\\d*$":o=n?"^\\d*\\.?\\d*$":"^\\d*$",!new RegExp(o).test(t)){e.preventDefault();return}s?.(e);}}),l=d;export{l as default};
@@ -0,0 +1,73 @@
1
+ import * as class_variance_authority_types from 'class-variance-authority/types';
2
+ import React__default, { FocusEvent } from 'react';
3
+ import { VariantProps } from 'class-variance-authority';
4
+
5
+ declare const otpContainerVariants: (props?: ({
6
+ size?: "sm" | "md" | "lg" | null | undefined;
7
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
8
+ declare const otpInputVariants: (props?: ({
9
+ size?: "sm" | "md" | "lg" | null | undefined;
10
+ variant?: "outline" | "default" | "filled" | null | undefined;
11
+ state?: "error" | "disabled" | "success" | "default" | null | undefined;
12
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
13
+ type OTPInputVariantProps = VariantProps<typeof otpInputVariants>;
14
+ type OTPContainerVariantProps = VariantProps<typeof otpContainerVariants>;
15
+ interface OTPInputClassNames {
16
+ /** Class สำหรับ container หลัก */
17
+ container?: string;
18
+ /** Class สำหรับ wrapper ของ inputs */
19
+ inputWrapper?: string;
20
+ /** Class สำหรับ input แต่ละช่อง */
21
+ input?: string;
22
+ /** Class สำหรับ input ที่ active/focused */
23
+ inputActive?: string;
24
+ /** Class สำหรับ separator (ถ้ามี) */
25
+ separator?: string;
26
+ }
27
+ interface OTPInputProps extends Omit<OTPInputVariantProps, "state">, OTPContainerVariantProps {
28
+ /** จำนวนช่อง OTP (default: 6) */
29
+ length?: number;
30
+ /** ค่า OTP ปัจจุบัน */
31
+ value: string;
32
+ /** Callback เมื่อค่าเปลี่ยน */
33
+ onChange: (value: string) => void;
34
+ /** Callback เมื่อกรอกครบ */
35
+ onComplete?: (value: string) => void;
36
+ /** Callback เมื่อ focus */
37
+ onFocus?: (e: FocusEvent<HTMLInputElement>) => void;
38
+ /** Callback เมื่อ blur */
39
+ onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
40
+ /** Disabled state */
41
+ disabled?: boolean;
42
+ /** Error state */
43
+ error?: boolean;
44
+ /** Success state */
45
+ success?: boolean;
46
+ /** Auto focus input แรก */
47
+ autoFocus?: boolean;
48
+ /** Placeholder สำหรับแต่ละช่อง */
49
+ placeholder?: string;
50
+ /** รับเฉพาะตัวเลข (default: true) */
51
+ numericOnly?: boolean;
52
+ /** Mask input (แสดงเป็น •) */
53
+ mask?: boolean;
54
+ /** แสดง separator หลังช่องที่กำหนด (เช่น [3] = แสดงหลังช่องที่ 3) */
55
+ separatorAfter?: number[];
56
+ /** Custom separator element */
57
+ separatorElement?: React__default.ReactNode;
58
+ /** Custom class names สำหรับแต่ละส่วน */
59
+ classNames?: OTPInputClassNames;
60
+ /** aria-label สำหรับ accessibility */
61
+ ariaLabel?: string;
62
+ }
63
+ interface OTPInputRef {
64
+ /** Focus ไปที่ช่องแรก */
65
+ focus: () => void;
66
+ /** Clear ค่าทั้งหมด */
67
+ clear: () => void;
68
+ /** Focus ไปที่ช่องที่กำหนด */
69
+ focusAt: (index: number) => void;
70
+ }
71
+ declare const OTPInput: React__default.ForwardRefExoticComponent<OTPInputProps & React__default.RefAttributes<OTPInputRef>>;
72
+
73
+ export { type OTPContainerVariantProps, OTPInput, type OTPInputClassNames, type OTPInputProps, type OTPInputRef, type OTPInputVariantProps, otpContainerVariants, otpInputVariants };
@@ -0,0 +1 @@
1
+ import {a}from'../chunk-6GLPXMGB.js';import _,{forwardRef,useRef,useState,useImperativeHandle,useEffect,useCallback}from'react';import {cva}from'class-variance-authority';import {jsx,jsxs}from'react/jsx-runtime';var V=cva("flex items-center justify-center",{variants:{size:{sm:"gap-2",md:"gap-3",lg:"gap-4"}},defaultVariants:{size:"md"}}),Q=cva(["text-center font-semibold transition-all duration-200 outline-none rounded-sm","disabled:cursor-not-allowed disabled:opacity-50"],{variants:{size:{sm:"h-[32px] w-[32px] text-sm ",md:"h-[40px] w-[40px] text-base ",lg:"h-[50px] w-[50px] text-lg "},variant:{default:["border-2 border-gray-300 bg-white text-gray-900","focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20"],outline:["border-2 border-gray-400 bg-transparent text-gray-900","focus:border-blue-600 focus:ring-2 focus:ring-blue-600/20"],filled:["border-2 border-transparent bg-gray-100 text-gray-900","focus:border-blue-500 focus:bg-white focus:ring-2 focus:ring-blue-500/20"]},state:{default:"",error:["border-red-500 ","focus:border-red-500 focus:ring-red-500/20","animate-shake"],success:["border-green-500 bg-green-50 text-green-900","focus:border-green-500 focus:ring-green-500/20"],disabled:"border-gray-200 bg-gray-100 text-gray-400 cursor-not-allowed"}},defaultVariants:{size:"md",variant:"default",state:"default"}}),R=forwardRef(({length:a$1=6,value:o,onChange:n,onComplete:g,onFocus:P,onBlur:I,disabled:b=false,error:y=false,success:x=false,autoFocus:T=true,placeholder:O="",numericOnly:c=true,mask:A=false,separatorAfter:F=[],separatorElement:H,size:v,variant:L,classNames:i,ariaLabel:E="OTP input"},M)=>{let s=useRef([]),[h,u]=useState(-1),m=useRef(false),N=b?"disabled":y?"error":x?"success":"default";useImperativeHandle(M,()=>({focus:()=>{s.current[0]?.focus();},clear:()=>{m.current=false,n(""),s.current[0]?.focus();},focusAt:e=>{e>=0&&e<a$1&&s.current[e]?.focus();}})),useEffect(()=>{if(T&&!b&&s.current[0]){let e=setTimeout(()=>{s.current[0]?.focus();},0);return ()=>clearTimeout(e)}},[T,b]),useEffect(()=>{o.length===a$1&&g&&!m.current&&(m.current=true,g(o)),o.length<a$1&&(m.current=false);},[o,a$1,g]);let j=useCallback((e,t)=>{let r=t;if(c?r=t.replace(/\D/g,"").slice(-1):r=t.slice(-1),!r&&t!=="")return;let p=o.split("");p[e]=r;let W=p.join("").slice(0,a$1);n(W),r&&e<a$1-1&&(s.current[e+1]?.focus(),u(e+1));},[o,a$1,c,n]),C=useCallback((e,t)=>{switch(t.key){case "Backspace":t.preventDefault();let r=o.split("");r[e]?(r[e]="",n(r.join(""))):e>0&&(r[e-1]="",n(r.join("")),s.current[e-1]?.focus(),u(e-1));break;case "ArrowLeft":t.preventDefault(),e>0&&(s.current[e-1]?.focus(),u(e-1));break;case "ArrowRight":t.preventDefault(),e<a$1-1&&(s.current[e+1]?.focus(),u(e+1));break;case "Delete":t.preventDefault();let p=o.split("");p[e]="",n(p.join(""));break;case "Home":t.preventDefault(),s.current[0]?.focus(),u(0);break;case "End":t.preventDefault(),s.current[a$1-1]?.focus(),u(a$1-1);break}},[o,a$1,n]),K=useCallback(e=>{e.preventDefault();let t=e.clipboardData.getData("text");if(c&&(t=t.replace(/\D/g,"")),t=t.slice(0,a$1),t){n(t);let r=Math.min(t.length,a$1)-1;s.current[r]?.focus(),u(r);}},[a$1,c,n]),B=useCallback((e,t)=>{u(e),t.target.select(),P?.(t);},[P]),$=useCallback(e=>{u(-1),I?.(e);},[I]),z=e=>F.includes(e+1)?jsx("span",{className:a("flex items-center justify-center text-gray-400",i?.separator),"aria-hidden":"true",children:H??jsx("span",{className:"w-2 h-0.5 bg-gray-300 rounded-full"})}):null,S=e=>{let t=o[e]||"";return A&&t?"\u2022":t};return jsx("div",{className:a(V({size:v}),i?.container),role:"group","aria-label":E,children:jsx("div",{className:a(V({size:v}),i?.inputWrapper),children:Array.from({length:a$1},(e,t)=>jsxs(_.Fragment,{children:[jsx("input",{ref:r=>{s.current[t]=r;},type:"text",inputMode:c?"numeric":"text",pattern:c?"[0-9]*":void 0,maxLength:1,value:S(t),onChange:r=>j(t,r.target.value),onKeyDown:r=>C(t,r),onPaste:K,onFocus:r=>B(t,r),onBlur:$,disabled:b,placeholder:O,autoComplete:"one-time-code",className:a(Q({size:v,variant:L,state:N}),h===t&&i?.inputActive,i?.input),"aria-label":`${E} digit ${t+1} of ${a$1}`,"aria-invalid":y}),z(t)]},t))})})});R.displayName="OTPInput";export{R as OTPInput,V as otpContainerVariants,Q as otpInputVariants};
@@ -1,2 +1,2 @@
1
- import {c}from'../chunk-HNWRZZOG.js';import'../chunk-RIPJ77V4.js';import'../chunk-LHW4VKJO.js';import'../chunk-VOTSEDLU.js';import'../chunk-BTXIMIJL.js';import'../chunk-IX36POX2.js';import'../chunk-QRYSV225.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var y=(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},q=async()=>await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province.json")).json(),I=({searchLabel:e="Search",disabled:t,locale:s="th",searchPlaceholder:p="Search Province",placeholder:v="Select Province",label:m,searchButtonClassName:P="bg-blue-500",onChange:i,value:a,required:g=false,error:b,onSearchMode:f,debounceMs:C,onOpenChange:S,popoverZIndex:_})=>{let[o,x]=useState([]),[M,c$1]=useState(null);useEffect(()=>{q().then(x);},[]),useEffect(()=>{if(a){let n=o.find(r=>s==="th"?r.name_th===a:r.name_en===a);n&&c$1(n);}},[o,a,s]);let w=useCallback(n=>{let r=o.find(B=>B.id===n);r&&(c$1(r),i?.(r));},[o,i]);return jsx("div",{children:jsx(c,{items:o.map(n=>y(n,s)),placeholder:p,triggerPlaceholder:v,label:m,selectionMode:"single",searchButtonClassName:P,onChange:n=>{w(n);},searchButtonLabel:e,value:M?.id,required:g,disabled:t,errorMessage:b,onSearchMode:f,debounceMs:C,onOpenChange:S,popoverZIndex:_})})},L=I;
1
+ import {c}from'../chunk-7GRVTCP3.js';import'../chunk-RIPJ77V4.js';import'../chunk-LHW4VKJO.js';import'../chunk-VOTSEDLU.js';import'../chunk-KA7C25YJ.js';import'../chunk-IX36POX2.js';import'../chunk-QRYSV225.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var y=(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},q=async()=>await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province.json")).json(),I=({searchLabel:e="Search",disabled:t,locale:s="th",searchPlaceholder:p="Search Province",placeholder:v="Select Province",label:m,searchButtonClassName:P="bg-blue-500",onChange:i,value:a,required:g=false,error:b,onSearchMode:f,debounceMs:C,onOpenChange:S,popoverZIndex:_})=>{let[o,x]=useState([]),[M,c$1]=useState(null);useEffect(()=>{q().then(x);},[]),useEffect(()=>{if(a){let n=o.find(r=>s==="th"?r.name_th===a:r.name_en===a);n&&c$1(n);}},[o,a,s]);let w=useCallback(n=>{let r=o.find(B=>B.id===n);r&&(c$1(r),i?.(r));},[o,i]);return jsx("div",{children:jsx(c,{items:o.map(n=>y(n,s)),placeholder:p,triggerPlaceholder:v,label:m,selectionMode:"single",searchButtonClassName:P,onChange:n=>{w(n);},searchButtonLabel:e,value:M?.id,required:g,disabled:t,errorMessage:b,onSearchMode:f,debounceMs:C,onOpenChange:S,popoverZIndex:_})})},L=I;
2
2
  export{L as default};
@@ -1 +1 @@
1
- import {b,a as a$5}from'../chunk-RIPJ77V4.js';import {a as a$7}from'../chunk-LHW4VKJO.js';import {a as a$3}from'../chunk-VOTSEDLU.js';import {a as a$4}from'../chunk-BTXIMIJL.js';import {a as a$6}from'../chunk-IX36POX2.js';import'../chunk-QRYSV225.js';import {a as a$1}from'../chunk-THE2HQGT.js';import {a as a$2}from'../chunk-6GLPXMGB.js';import*as a from'react';import*as s from'@radix-ui/react-popover';import {jsxs,jsx}from'react/jsx-runtime';function de(c){return typeof c=="string"?{id:c,label:c}:c}var me={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 ue({autoFocus:c=false,trigger:O,triggerPlaceholder:R="Choose",items:y,selectionMode:g="multiple",value:w,defaultValue:Q,onChange:V,searchable:N=true,placeholder:F="Placeholder Text",searchButtonLabel:j="Search",onQueryChange:E,onSearch:H,loading:u=false,emptyLabel:_="No results",contentClassName:$,maxHeight:G=288,renderItem:k,buttonColor:J="primary",searchButtonColor:K,searchButtonClassName:U,checkedColor:W="primary",checkedClassName:X,renderTriggerValue:C,label:P,required:Y,errorMessage:f,disabled:p,size:Z="md"}){let[S,I]=a.useState(false),[b$1,ee]=a.useState(""),[h,te]=a.useState(""),l=g==="multiple",[re,oe]=a.useState(Q??(l?[]:"")),o=w??re,d=a.useMemo(()=>y.map(de),[y]),B=a.useMemo(()=>{let e=h.trim().toLowerCase();return e?d.filter(r=>String(r.label).toLowerCase().includes(e)):d},[d,h]),L=e=>{V?.(e),w===void 0&&oe(e);},ae=e=>{if(l){let r=new Set(o);r.has(e)?r.delete(e):r.add(e),L(Array.from(r));}else L(e),I(false);},le=e=>l?o.includes(e):o===e,se=()=>{te(b$1),H?.(b$1);},v=a.useMemo(()=>l?o:o?[o]:[],[o,l]),m=a.useMemo(()=>d.filter(e=>v.includes(e.id)),[d,v]),ne=a.useMemo(()=>m.length===0?R:l?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${m.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:m[0].label,[m,l,R]);return jsxs("fieldset",{children:[P&&jsx(a$1,{label:P,required:Y}),jsxs(s.Root,{open:S&&!p,onOpenChange:e=>!p&&I(e),children:[jsx("div",{className:"mb-2"}),jsx(s.Trigger,{asChild:true,children:O??jsxs("button",{type:"button",className:a$2("flex w-full min-w-[260px] items-center justify-between","rounded-md border border-[#C9D7E3] bg-white px-2 text-left","outline-none focus-visible:ring-2 ring-black/20",f&&!p?"border-red-600":"",p?"opacity-50 cursor-not-allowed":"",b[Z]),children:[jsx("span",{className:a$2("flex-1 line-clamp-1",{"text-[#A5A9AD]":l?o?.length===0:!o,"text-black":l?o?.length>0:!!o}),children:C?C(v,m):ne}),jsx(a$3,{fontSize:16,className:a$2("ml-3 text-black/60 transition-transform",S?"rotate-180":"rotate-0")})]})}),jsx(s.Portal,{children:jsxs(s.Content,{sideOffset:8,onOpenAutoFocus:e=>{if(!c){e.preventDefault();return}},className:a$2("w-[300px] rounded-md border border-black/10 bg-white p-2 shadow-xl",$),children:[N&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:e=>{e.preventDefault(),se();},children:[jsx(a$4,{start:jsx(a$5,{}),value:b$1,onChange:e=>{ee(e.currentTarget.value),E?.(e.currentTarget.value);},size:"md",placeholder:F}),jsx(a$6,{color:K??J,type:"submit",disabled:u||b$1.trim()===h.trim(),size:"sm",className:U,children:j})]}),jsxs("div",{role:"listbox","aria-multiselectable":l||void 0,className:a$2(" overflow-y-auto rounded-md",{"mt-3":N}),style:{maxHeight:G},children:[u&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),!u&&B.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:_}),!u&&B.map(e=>{let r=le(e.id),ie=me[W],ce=jsxs(a$6,{type:"button",role:"option","aria-selected":r,onClick:()=>ae(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?ie:"border-black/20",r&&X),children:r?jsx(a$7,{fontSize:10}):null})]},e.id);return k?jsx("div",{children:k(e,false,r)},e.id):ce})]}),jsx(s.Arrow,{className:"fill-white stroke-black/10"})]})})]}),f&&jsx("small",{className:"text-red-500 text-xs",children:f})]})}var pe=ue;export{pe as default};
1
+ import {b,a as a$5}from'../chunk-RIPJ77V4.js';import {a as a$7}from'../chunk-LHW4VKJO.js';import {a as a$3}from'../chunk-VOTSEDLU.js';import {a as a$4}from'../chunk-KA7C25YJ.js';import {a as a$6}from'../chunk-IX36POX2.js';import'../chunk-QRYSV225.js';import {a as a$1}from'../chunk-THE2HQGT.js';import {a as a$2}from'../chunk-6GLPXMGB.js';import*as a from'react';import*as s from'@radix-ui/react-popover';import {jsxs,jsx}from'react/jsx-runtime';function de(c){return typeof c=="string"?{id:c,label:c}:c}var me={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 ue({autoFocus:c=false,trigger:O,triggerPlaceholder:R="Choose",items:y,selectionMode:g="multiple",value:w,defaultValue:Q,onChange:V,searchable:N=true,placeholder:F="Placeholder Text",searchButtonLabel:j="Search",onQueryChange:E,onSearch:H,loading:u=false,emptyLabel:_="No results",contentClassName:$,maxHeight:G=288,renderItem:k,buttonColor:J="primary",searchButtonColor:K,searchButtonClassName:U,checkedColor:W="primary",checkedClassName:X,renderTriggerValue:C,label:P,required:Y,errorMessage:f,disabled:p,size:Z="md"}){let[S,I]=a.useState(false),[b$1,ee]=a.useState(""),[h,te]=a.useState(""),l=g==="multiple",[re,oe]=a.useState(Q??(l?[]:"")),o=w??re,d=a.useMemo(()=>y.map(de),[y]),B=a.useMemo(()=>{let e=h.trim().toLowerCase();return e?d.filter(r=>String(r.label).toLowerCase().includes(e)):d},[d,h]),L=e=>{V?.(e),w===void 0&&oe(e);},ae=e=>{if(l){let r=new Set(o);r.has(e)?r.delete(e):r.add(e),L(Array.from(r));}else L(e),I(false);},le=e=>l?o.includes(e):o===e,se=()=>{te(b$1),H?.(b$1);},v=a.useMemo(()=>l?o:o?[o]:[],[o,l]),m=a.useMemo(()=>d.filter(e=>v.includes(e.id)),[d,v]),ne=a.useMemo(()=>m.length===0?R:l?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${m.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:m[0].label,[m,l,R]);return jsxs("fieldset",{children:[P&&jsx(a$1,{label:P,required:Y}),jsxs(s.Root,{open:S&&!p,onOpenChange:e=>!p&&I(e),children:[jsx("div",{className:"mb-2"}),jsx(s.Trigger,{asChild:true,children:O??jsxs("button",{type:"button",className:a$2("flex w-full min-w-[260px] items-center justify-between","rounded-md border border-[#C9D7E3] bg-white px-2 text-left","outline-none focus-visible:ring-2 ring-black/20",f&&!p?"border-red-600":"",p?"opacity-50 cursor-not-allowed":"",b[Z]),children:[jsx("span",{className:a$2("flex-1 line-clamp-1",{"text-[#A5A9AD]":l?o?.length===0:!o,"text-black":l?o?.length>0:!!o}),children:C?C(v,m):ne}),jsx(a$3,{fontSize:16,className:a$2("ml-3 text-black/60 transition-transform",S?"rotate-180":"rotate-0")})]})}),jsx(s.Portal,{children:jsxs(s.Content,{sideOffset:8,onOpenAutoFocus:e=>{if(!c){e.preventDefault();return}},className:a$2("w-[300px] rounded-md border border-black/10 bg-white p-2 shadow-xl",$),children:[N&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:e=>{e.preventDefault(),se();},children:[jsx(a$4,{start:jsx(a$5,{}),value:b$1,onChange:e=>{ee(e.currentTarget.value),E?.(e.currentTarget.value);},size:"md",placeholder:F}),jsx(a$6,{color:K??J,type:"submit",disabled:u||b$1.trim()===h.trim(),size:"sm",className:U,children:j})]}),jsxs("div",{role:"listbox","aria-multiselectable":l||void 0,className:a$2(" overflow-y-auto rounded-md",{"mt-3":N}),style:{maxHeight:G},children:[u&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),!u&&B.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:_}),!u&&B.map(e=>{let r=le(e.id),ie=me[W],ce=jsxs(a$6,{type:"button",role:"option","aria-selected":r,onClick:()=>ae(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?ie:"border-black/20",r&&X),children:r?jsx(a$7,{fontSize:10}):null})]},e.id);return k?jsx("div",{children:k(e,false,r)},e.id):ce})]}),jsx(s.Arrow,{className:"fill-white stroke-black/10"})]})})]}),f&&jsx("small",{className:"text-red-500 text-xs",children:f})]})}var pe=ue;export{pe as default};
@@ -1 +1 @@
1
- export{c as default,b as handleMultipleChange,a as handleSingleChange}from'../chunk-HNWRZZOG.js';import'../chunk-RIPJ77V4.js';import'../chunk-LHW4VKJO.js';import'../chunk-VOTSEDLU.js';import'../chunk-BTXIMIJL.js';import'../chunk-IX36POX2.js';import'../chunk-QRYSV225.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';
1
+ export{c as default,b as handleMultipleChange,a as handleSingleChange}from'../chunk-7GRVTCP3.js';import'../chunk-RIPJ77V4.js';import'../chunk-LHW4VKJO.js';import'../chunk-VOTSEDLU.js';import'../chunk-KA7C25YJ.js';import'../chunk-IX36POX2.js';import'../chunk-QRYSV225.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';
@@ -1,2 +1,2 @@
1
- import {c}from'../chunk-HNWRZZOG.js';import'../chunk-RIPJ77V4.js';import'../chunk-LHW4VKJO.js';import'../chunk-VOTSEDLU.js';import'../chunk-BTXIMIJL.js';import'../chunk-IX36POX2.js';import'../chunk-QRYSV225.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var k=(e,i)=>i==="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},y=async e=>(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===e),q=({locale:e="th",searchPlaceholder:i="Search Sub District",placeholder:c$1="Select Sub District",label:u,searchButtonClassName:a="bg-blue-500",onChange:l,value:s,required:S=false,districtId:o,error:g,searchLabel:f="Search",onSearchMode:D,debounceMs:_,onOpenChange:v,popoverZIndex:C})=>{let[n,x]=useState([]),[M,d]=useState(null);useEffect(()=>{o&&y(o).then(x);},[o]),useEffect(()=>{if(s){let t=n.find(r=>e==="th"?r.name_th===s:r.name_en===s);t&&d(t);}},[n,s,e]);let P=useCallback(t=>{let r=n.find(w=>w.id===t);r&&(d(r),l?.(r));},[n,l]);return jsx("div",{children:jsx(c,{items:n.map(t=>k(t,e)),placeholder:i,triggerPlaceholder:c$1,label:u,selectionMode:"single",searchButtonClassName:a,onChange:t=>{P(t);},searchButtonLabel:f,value:M?.id,required:S,disabled:!o,errorMessage:g,onSearchMode:D,debounceMs:_,onOpenChange:v,popoverZIndex:C})})},L=q;
1
+ import {c}from'../chunk-7GRVTCP3.js';import'../chunk-RIPJ77V4.js';import'../chunk-LHW4VKJO.js';import'../chunk-VOTSEDLU.js';import'../chunk-KA7C25YJ.js';import'../chunk-IX36POX2.js';import'../chunk-QRYSV225.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var k=(e,i)=>i==="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},y=async e=>(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===e),q=({locale:e="th",searchPlaceholder:i="Search Sub District",placeholder:c$1="Select Sub District",label:u,searchButtonClassName:a="bg-blue-500",onChange:l,value:s,required:S=false,districtId:o,error:g,searchLabel:f="Search",onSearchMode:D,debounceMs:_,onOpenChange:v,popoverZIndex:C})=>{let[n,x]=useState([]),[M,d]=useState(null);useEffect(()=>{o&&y(o).then(x);},[o]),useEffect(()=>{if(s){let t=n.find(r=>e==="th"?r.name_th===s:r.name_en===s);t&&d(t);}},[n,s,e]);let P=useCallback(t=>{let r=n.find(w=>w.id===t);r&&(d(r),l?.(r));},[n,l]);return jsx("div",{children:jsx(c,{items:n.map(t=>k(t,e)),placeholder:i,triggerPlaceholder:c$1,label:u,selectionMode:"single",searchButtonClassName:a,onChange:t=>{P(t);},searchButtonLabel:f,value:M?.id,required:S,disabled:!o,errorMessage:g,onSearchMode:D,debounceMs:_,onOpenChange:v,popoverZIndex:C})})},L=q;
2
2
  export{L as default};
@@ -1 +1 @@
1
- import {a as a$2}from'../chunk-QRYSV225.js';import {a}from'../chunk-THE2HQGT.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import {forwardRef}from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var I=cva("w-full px-2 py-2 border rounded-lg text-gray-900 resize-none transition-colors focus:outline-none bg-white placeholder:text-[#A5A9AD] border-[#C9D7E3]",{variants:{size:{sm:"text-sm",md:"text-md",lg:"text-xl"}},defaultVariants:{size:"md"}}),x=forwardRef(({label:o,error:t,required:d=false,className:c="",maxLength:e,value:a$3,size:u,onChange:g,id:l,name:T,placeholder:b,...v},A)=>{let h=a$3?String(a$3).length:0;return jsxs("fieldset",{className:"relative flex flex-col gap-2 items-start text-start",children:[o&&jsx(a,{label:o,required:d,id:l}),jsxs("div",{className:"relative w-full",children:[jsx("textarea",{...v,id:l,name:T,ref:A,placeholder:b,rows:4,value:a$3,maxLength:e,onChange:n=>{let r=n.target.value;e&&r.length>e&&(r=r.slice(0,e),n.target.value=r),g?.(n);},className:a$1(I({size:u}),t&&"border-red-500",c),"aria-describedby":t?`${l}-error`:void 0,"aria-invalid":!!t,required:d}),e&&jsxs("div",{className:"text-right font-semibold text-xs text-[#606876]",children:[h||0,"/",e]})]}),t&&jsx(a$2,{message:t})]})});x.displayName="TextAreaInput";var y=x;export{y as default};
1
+ import {a as a$2}from'../chunk-QRYSV225.js';import {a}from'../chunk-THE2HQGT.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import {forwardRef}from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var I=cva("w-full px-2 py-2 border rounded-lg text-gray-900 resize-none transition-colors focus:outline-none bg-white placeholder:text-[#A5A9AD] border-[#C9D7E3]",{variants:{size:{sm:"text-sm",md:"text-md",lg:"text-xl"}},defaultVariants:{size:"md"}}),u=forwardRef(({label:o,error:t,required:d=false,className:x="",maxLength:e,value:a$3,size:c,onChange:g,id:l,name:T,placeholder:b,...v},A)=>{let h=a$3?String(a$3).length:0;return jsxs("fieldset",{className:"relative flex flex-col gap-2 items-start text-start w-full",children:[o&&jsx(a,{label:o,required:d,id:l}),jsxs("div",{className:"relative w-full",children:[jsx("textarea",{...v,id:l,name:T,ref:A,placeholder:b,rows:4,value:a$3,maxLength:e,onChange:n=>{let r=n.target.value;e&&r.length>e&&(r=r.slice(0,e),n.target.value=r),g?.(n);},className:a$1(I({size:c}),t&&"border-red-500",x),"aria-describedby":t?`${l}-error`:void 0,"aria-invalid":!!t,required:d}),e&&jsxs("div",{className:"text-right font-semibold text-xs text-[#606876]",children:[h||0,"/",e]})]}),t&&jsx(a$2,{message:t})]})});u.displayName="TextAreaInput";var y=u;export{y as default};
@@ -1 +1 @@
1
- export{a as default}from'../chunk-BTXIMIJL.js';import'../chunk-QRYSV225.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';
1
+ export{a as default}from'../chunk-KA7C25YJ.js';import'../chunk-QRYSV225.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "the-omelet-ui",
3
- "version": "1.8.39",
3
+ "version": "1.8.41",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",