the-omelet-ui 1.8.61 → 1.8.63

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 {a as a$2}from'../chunk-H7BTHYKO.js';import {a as a$1}from'../chunk-THE2HQGT.js';import {a}from'../chunk-6GLPXMGB.js';import*as n from'react';import*as l from'@radix-ui/react-popover';import {CalendarDays,ChevronUp,ChevronDown,ChevronLeft,ChevronRight}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';var ke=["\u0E21\u0E01\u0E23\u0E32\u0E04\u0E21","\u0E01\u0E38\u0E21\u0E20\u0E32\u0E1E\u0E31\u0E19\u0E18\u0E4C","\u0E21\u0E35\u0E19\u0E32\u0E04\u0E21","\u0E40\u0E21\u0E29\u0E32\u0E22\u0E19","\u0E1E\u0E24\u0E29\u0E20\u0E32\u0E04\u0E21","\u0E21\u0E34\u0E16\u0E38\u0E19\u0E32\u0E22\u0E19","\u0E01\u0E23\u0E01\u0E0E\u0E32\u0E04\u0E21","\u0E2A\u0E34\u0E07\u0E2B\u0E32\u0E04\u0E21","\u0E01\u0E31\u0E19\u0E22\u0E32\u0E22\u0E19","\u0E15\u0E38\u0E25\u0E32\u0E04\u0E21","\u0E1E\u0E24\u0E28\u0E08\u0E34\u0E01\u0E32\u0E22\u0E19","\u0E18\u0E31\u0E19\u0E27\u0E32\u0E04\u0E21"],K=["\u0E2D\u0E32","\u0E08","\u0E2D","\u0E1E","\u0E1E\u0E24","\u0E28","\u0E2A"],xe=["January","February","March","April","May","June","July","August","September","October","November","December"],G=["Su","Mo","Tu","We","Th","Fr","Sa"],I=o=>new Date(o.getFullYear(),o.getMonth(),1),J=(o,e)=>new Date(o.getFullYear(),o.getMonth()+e,1),V=(o,e)=>{let r=new Date(o);return r.setDate(r.getDate()+e),r},W=(o,e)=>!!o&&!!e&&o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate(),Pe=(o,e,r)=>e&&o<e?e:r&&o>r?r:o,M=18,we=n.memo(function({d:e,inMonth:r,disabled:i,selected:g,isToday:d,onPick:s,dayClassName:u,outsideDayClassName:m,selectedDayClassName:R,todayClassName:C}){let S=n.useCallback(()=>{i||s(e);},[i,s,e]);return jsx("button",{type:"button",onClick:S,disabled:i,className:a("h-9 w-9 place-self-center text-sm transition-colors rounded-full","outline-none focus-visible:ring-2 ring-black/20",r?"text-black":m??"text-black/30",i&&"opacity-30 pointer-events-none ",d&&!g&&(C??"bg-[#EDF6FF] text-[#004499] font-bold"),u,g?a("bg-blue-600 text-white hover:bg-blue-600",R):"hover:bg-black/5"),children:e.getDate()})},(o,e)=>o.inMonth===e.inMonth&&o.disabled===e.disabled&&o.selected===e.selected&&o.isToday===e.isToday&&o.d.getTime()===e.d.getTime()&&o.dayClassName===e.dayClassName&&o.outsideDayClassName===e.outsideDayClassName&&o.selectedDayClassName===e.selectedDayClassName&&o.todayClassName===e.todayClassName),Me=n.memo(function({months:e,activeMonth:r,onSelect:i}){let g=n.useCallback(d=>i(d),[i]);return jsx("div",{className:"grid grid-cols-3 gap-1",style:{gridTemplateColumns:"repeat(3, minmax(0,1fr))"},children:e.map((d,s)=>jsx("button",{type:"button",onClick:()=>g(s),className:a("rounded-md px-2 py-2 text-sm hover:bg-black/5",s===r&&"bg-black/10"),children:d},d))})}),Re=n.memo(function({years:e,activeYear:r,labelFromYear:i,onSelect:g}){let d=n.useCallback(s=>g(s),[g]);return jsx("div",{className:"p-1 overflow-y-auto bg-white border rounded-md shadow-lg max-h-72 w-28 border-black/10",children:e.map(s=>jsx("button",{type:"button",onClick:()=>d(s),className:a("block w-full rounded-md px-2 py-2 text-left text-sm hover:bg-black/5",s===r&&"bg-black/10"),children:i(s)},s))})}),Se=n.forwardRef(function({label:e,required:r,value:i,defaultValue:g=null,onChange:d,minDate:s,maxDate:u,locale:m="th",useBuddhistEra:R,format:C,className:S,inputClassName:$,contentClassName:q,dayClassName:U,todayClassName:Z,selectedDayClassName:j,outsideDayClassName:Q="text-black/30",placeholderText:X="dd/mm/yyyy",calendarIcon:ee,disabled:Y=false,error:T,closeOnSelect:L=true,yearRange:F,size:te="md",iconClassName:P},ae){let [oe,B]=n.useState(false),[ne,O]=n.useState(false),[se,E]=n.useState(false),[le,re]=n.useState(g),A=i!==void 0,h=(A?i:le)??null,w=R??m==="th",_=m==="th"?ke:xe,ce=h??new Date,[D,N]=n.useState(I(ce));n.useEffect(()=>{h&&N(I(h));},[h?.getFullYear(),h?.getMonth()]);let k=D.getFullYear(),x=D.getMonth(),ie=n.useMemo(()=>C||(m==="th"?t=>{let b=w?t.getFullYear()+543:t.getFullYear(),f=String(t.getDate()).padStart(2,"0"),v=String(t.getMonth()+1).padStart(2,"0");return `${f}/${v}/${b}`}:t=>t.toLocaleDateString("en-GB")),[C,m,w]),de=n.useMemo(()=>{let t=I(D),b=t.getDay(),f=V(t,-b);return Array.from({length:42},(v,y)=>V(f,y))},[D]),ue=n.useMemo(()=>{let t=new Date().getFullYear(),b=F?.[0]??s?.getFullYear()??t-60,f=F?.[1]??u?.getFullYear()??t+40,v=[];for(let y=b;y<=f;y++)v.push(y);return v},[F,s,u]),me=w?k+543:k,be=n.useCallback(t=>{let b=Pe(t,s,u);d?.(b),A||re(b),L&&B(false);},[A,s,u,d,L]),pe=n.useCallback(t=>{B(t),t||(O(false),E(false));},[]),ge=n.useCallback(t=>{N(new Date(k,t,1)),O(false);},[k]),he=n.useCallback(t=>{N(new Date(t,x,1)),E(false);},[x]);return jsxs("fieldset",{ref:ae,className:a("w-full",S),children:[e&&jsx(a$1,{required:r,label:e}),jsxs(l.Root,{open:oe,onOpenChange:pe,children:[jsxs("div",{className:a("relative",e?"mt-2":""),children:[jsx(l.Trigger,{asChild:true,children:jsx("button",{type:"button",disabled:Y,className:a("flex w-full items-center rounded-md border bg-white px-3 py-2 text-left","outline-none focus-visible:ring-2",T?"border-red-500 ring-red-200":"border-black/15 ring-black/20",Y&&"bg-[#f4f4f4] pointer-events-none text-[#BDC2BE] border-none",a$2[te??"md"],"pr-10",$),children:jsx("span",{className:a("truncate text-black",!h&&"text-black/40",Y&&"text-[#BDC2BE]"),children:h?ie(h):X})})}),jsx("span",{className:"absolute -translate-y-1/2 pointer-events-none right-2 top-1/2 text-black/50",children:ee??jsx(CalendarDays,{})})]}),T&&jsx("small",{className:"text-xs text-red-500",children:T}),jsx(l.Portal,{children:jsxs(l.Content,{sideOffset:8,className:a("w-[300px] sm:w-[320px] rounded-md border border-black/10 bg-white p-3 shadow-xl",q),children:[jsxs("div",{className:"flex items-center justify-between px-1 py-1",children:[jsxs("div",{className:"flex items-center gap-1",children:[jsxs(l.Root,{modal:false,open:ne,onOpenChange:O,children:[jsx(l.Trigger,{asChild:true,children:jsxs("button",{type:"button",className:"inline-flex items-center gap-1 px-2 py-1 text-base font-semibold text-black rounded-md hover:bg-black/5","aria-label":"\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E40\u0E14\u0E37\u0E2D\u0E19",children:[_[x],jsx(ChevronUp,{size:M,className:P??"text-blue-500"})]})}),jsx(l.Portal,{children:jsxs(l.Content,{sideOffset:6,align:"start",className:"p-2 bg-white border rounded-md shadow-lg border-black/10",children:[jsx(Me,{months:_,activeMonth:x,onSelect:ge}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]}),jsxs(l.Root,{modal:false,open:se,onOpenChange:E,children:[jsx(l.Trigger,{asChild:true,children:jsxs("button",{type:"button",className:"inline-flex items-center gap-1 px-2 py-1 text-base font-semibold text-black rounded-md hover:bg-black/5","aria-label":"\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E1B\u0E35",children:[me,jsx(ChevronDown,{size:M,className:P??"text-blue-500"})]})}),jsx(l.Portal,{children:jsxs(l.Content,{sideOffset:6,align:"start",children:[jsx(Re,{years:ue,activeYear:k,labelFromYear:t=>w?t+543:t,onSelect:he}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",className:"p-2 rounded-md text-black/70 hover:bg-black/5",onClick:()=>N(J(D,-1)),"aria-label":m==="th"?"\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32":"Previous month",children:jsx(ChevronLeft,{size:M,className:P??"text-blue-500"})}),jsx("button",{type:"button",className:"p-2 rounded-md text-black/70 hover:bg-black/5",onClick:()=>N(J(D,1)),"aria-label":m==="th"?"\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E16\u0E31\u0E14\u0E44\u0E1B":"Next month",children:jsx(ChevronRight,{size:M,className:P??"text-blue-500"})})]})]}),jsx("div",{className:"grid grid-cols-7 px-1 mt-1 text-xs text-center gap-y-1 text-black/50",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:(m==="th"?K:G).map(t=>jsx("div",{className:"leading-7 h-7 whitespace-nowrap",children:t},t))}),jsx("div",{className:"grid grid-cols-7 gap-1 px-1 pt-1 pb-1",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:de.map((t,b)=>{let f=t.getMonth()===x,v=s&&t<new Date(s.getFullYear(),s.getMonth(),s.getDate())||u&&t>new Date(u.getFullYear(),u.getMonth(),u.getDate()),y=W(t,h),fe=W(t,new Date);return jsx(we,{d:t,inMonth:f,disabled:!!v,selected:y,isToday:fe,onPick:be,dayClassName:U,outsideDayClassName:Q,selectedDayClassName:j,todayClassName:Z},b)})}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]})]})}),Ye=n.memo(Se);export{Ye as default};
1
+ import {a as a$2}from'../chunk-H7BTHYKO.js';import {a as a$1}from'../chunk-THE2HQGT.js';import {a}from'../chunk-6GLPXMGB.js';import*as s from'react';import*as l from'@radix-ui/react-popover';import {CalendarDays,ChevronUp,ChevronDown,ChevronLeft,ChevronRight}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';var ke=["\u0E21\u0E01\u0E23\u0E32\u0E04\u0E21","\u0E01\u0E38\u0E21\u0E20\u0E32\u0E1E\u0E31\u0E19\u0E18\u0E4C","\u0E21\u0E35\u0E19\u0E32\u0E04\u0E21","\u0E40\u0E21\u0E29\u0E32\u0E22\u0E19","\u0E1E\u0E24\u0E29\u0E20\u0E32\u0E04\u0E21","\u0E21\u0E34\u0E16\u0E38\u0E19\u0E32\u0E22\u0E19","\u0E01\u0E23\u0E01\u0E0E\u0E32\u0E04\u0E21","\u0E2A\u0E34\u0E07\u0E2B\u0E32\u0E04\u0E21","\u0E01\u0E31\u0E19\u0E22\u0E32\u0E22\u0E19","\u0E15\u0E38\u0E25\u0E32\u0E04\u0E21","\u0E1E\u0E24\u0E28\u0E08\u0E34\u0E01\u0E32\u0E22\u0E19","\u0E18\u0E31\u0E19\u0E27\u0E32\u0E04\u0E21"],W=["\u0E2D\u0E32","\u0E08","\u0E2D","\u0E1E","\u0E1E\u0E24","\u0E28","\u0E2A"],xe=["January","February","March","April","May","June","July","August","September","October","November","December"],$=["Su","Mo","Tu","We","Th","Fr","Sa"],z=o=>new Date(o.getFullYear(),o.getMonth(),1),q=(o,e)=>new Date(o.getFullYear(),o.getMonth()+e,1),U=(o,e)=>{let r=new Date(o);return r.setDate(r.getDate()+e),r},Z=(o,e)=>!!o&&!!e&&o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate(),Pe=(o,e,r)=>e&&o<e?e:r&&o>r?r:o,C=18,we=s.memo(function({d:e,inMonth:r,disabled:i,selected:g,isToday:u,onPick:n,dayClassName:d,outsideDayClassName:m,selectedDayClassName:R,todayClassName:k}){let S=s.useCallback(()=>{i||n(e);},[i,n,e]);return jsx("button",{type:"button",onClick:S,disabled:i,className:a("h-9 w-9 place-self-center text-sm transition-colors rounded-full","outline-none focus-visible:ring-2 ring-black/20",r?"text-black":m??"text-black/30",i&&"opacity-30 pointer-events-none ",u&&!g&&(k??"bg-[#EDF6FF] text-[#004499] font-bold"),d,g?a("bg-blue-600 text-white hover:bg-blue-600",R):"hover:bg-black/5"),children:e.getDate()})},(o,e)=>o.inMonth===e.inMonth&&o.disabled===e.disabled&&o.selected===e.selected&&o.isToday===e.isToday&&o.d.getTime()===e.d.getTime()&&o.dayClassName===e.dayClassName&&o.outsideDayClassName===e.outsideDayClassName&&o.selectedDayClassName===e.selectedDayClassName&&o.todayClassName===e.todayClassName),Me=s.memo(function({months:e,activeMonth:r,onSelect:i}){let g=s.useCallback(u=>i(u),[i]);return jsx("div",{className:"grid grid-cols-3 gap-1",style:{gridTemplateColumns:"repeat(3, minmax(0,1fr))"},children:e.map((u,n)=>jsx("button",{type:"button",onClick:()=>g(n),className:a("rounded-md px-2 py-2 text-sm hover:bg-black/5",n===r&&"bg-black/10"),children:u},u))})}),Re=s.memo(function({years:e,activeYear:r,labelFromYear:i,onSelect:g}){let u=s.useCallback(n=>g(n),[g]);return jsx("div",{className:"p-1 overflow-y-auto bg-white border rounded-md shadow-lg max-h-72 w-28 border-black/10",children:e.map(n=>jsx("button",{type:"button",onClick:()=>u(n),className:a("block w-full rounded-md px-2 py-2 text-left text-sm hover:bg-black/5",n===r&&"bg-black/10"),children:i(n)},n))})}),Se=s.forwardRef(function({label:e,required:r,value:i,defaultValue:g=null,onChange:u,minDate:n,maxDate:d,locale:m="th",useBuddhistEra:R,format:k,className:S,inputClassName:j,contentClassName:Q,dayClassName:X,todayClassName:ee,selectedDayClassName:te,outsideDayClassName:ae="text-black/30",placeholderText:oe="dd/mm/yyyy",calendarIcon:se,disabled:Y=false,error:T,closeOnSelect:I=true,yearRange:F,size:ne="md",iconClassName:D},le){let [re,L]=s.useState(false),[B,O]=s.useState(false),[_,E]=s.useState(false),[ce,ie]=s.useState(g),A=i!==void 0,h=(A?i:ce)??null,M=R??m==="th",H=m==="th"?ke:xe,ue=h??new Date,[N,x]=s.useState(z(ue));s.useEffect(()=>{h&&x(z(h));},[h?.getFullYear(),h?.getMonth()]);let P=N.getFullYear(),w=N.getMonth(),de=s.useMemo(()=>k||(m==="th"?t=>{let b=M?t.getFullYear()+543:t.getFullYear(),f=String(t.getDate()).padStart(2,"0"),v=String(t.getMonth()+1).padStart(2,"0");return `${f}/${v}/${b}`}:t=>t.toLocaleDateString("en-GB")),[k,m,M]),me=s.useMemo(()=>{let t=z(N),b=t.getDay(),f=U(t,-b);return Array.from({length:42},(v,y)=>U(f,y))},[N]),be=s.useMemo(()=>{let t=new Date().getFullYear(),b=F?.[0]??n?.getFullYear()??t-60,f=F?.[1]??d?.getFullYear()??t+40,v=[];for(let y=b;y<=f;y++)v.push(y);return v},[F,n,d]),pe=M?P+543:P,ge=s.useCallback(t=>{let b=Pe(t,n,d);u?.(b),A||ie(b),I&&L(false);},[A,n,d,u,I]),he=s.useCallback(t=>{L(t),t||(O(false),E(false));},[]),fe=s.useCallback(t=>{x(new Date(P,t,1)),O(false);},[P]),ve=s.useCallback(t=>{x(new Date(t,w,1)),E(false);},[w]);return jsxs("fieldset",{ref:le,className:a("w-full",S),children:[e&&jsx(a$1,{required:r,label:e}),jsxs(l.Root,{open:re,onOpenChange:he,children:[jsxs("div",{className:a("relative",e?"mt-2":""),children:[jsx(l.Trigger,{asChild:true,children:jsx("button",{type:"button",disabled:Y,className:a("flex w-full items-center rounded-md border bg-white px-3 py-2 text-left","outline-none focus-visible:ring-2",T?"border-red-500 ring-red-200":"border-black/15 ring-black/20",Y&&"bg-[#f4f4f4] pointer-events-none text-[#BDC2BE] border-none",a$2[ne??"md"],"pr-10",j),children:jsx("span",{className:a("truncate text-black",!h&&"text-black/40",Y&&"text-[#BDC2BE]"),children:h?de(h):oe})})}),jsx("span",{className:"absolute -translate-y-1/2 pointer-events-none right-2 top-1/2 text-black/50",children:se??jsx(CalendarDays,{})})]}),T&&jsx("small",{className:"text-xs text-red-500",children:T}),jsx(l.Portal,{children:jsxs(l.Content,{sideOffset:8,className:a("w-[300px] sm:w-[320px] rounded-md border border-black/10 bg-white p-3 shadow-xl",Q),children:[jsxs("div",{className:"flex items-center justify-between px-1 py-1",children:[jsxs("div",{className:"flex items-center gap-1",children:[jsxs(l.Root,{modal:false,open:B,onOpenChange:O,children:[jsx(l.Trigger,{asChild:true,children:jsxs("button",{type:"button",className:"inline-flex items-center gap-1 px-2 py-1 text-base font-semibold text-black rounded-md hover:bg-black/5","aria-label":"\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E40\u0E14\u0E37\u0E2D\u0E19",children:[H[w],B?jsx(ChevronUp,{size:C,className:D??"text-blue-500"}):jsx(ChevronDown,{size:C,className:D??"text-blue-500"})]})}),jsx(l.Portal,{children:jsxs(l.Content,{sideOffset:6,align:"start",className:"p-2 bg-white border rounded-md shadow-lg border-black/10",children:[jsx(Me,{months:H,activeMonth:w,onSelect:fe}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]}),jsxs(l.Root,{modal:false,open:_,onOpenChange:E,children:[jsx(l.Trigger,{asChild:true,children:jsxs("button",{type:"button",className:"inline-flex items-center gap-1 px-2 py-1 text-base font-semibold text-black rounded-md hover:bg-black/5","aria-label":"\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E1B\u0E35",children:[pe,_?jsx(ChevronUp,{size:C,className:D??"text-blue-500"}):jsx(ChevronDown,{size:C,className:D??"text-blue-500"})]})}),jsx(l.Portal,{children:jsxs(l.Content,{sideOffset:6,align:"start",children:[jsx(Re,{years:be,activeYear:P,labelFromYear:t=>M?t+543:t,onSelect:ve}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",className:"p-2 rounded-md text-black/70 hover:bg-black/5",onClick:()=>x(q(N,-1)),"aria-label":m==="th"?"\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32":"Previous month",children:jsx(ChevronLeft,{size:C,className:D??"text-blue-500"})}),jsx("button",{type:"button",className:"p-2 rounded-md text-black/70 hover:bg-black/5",onClick:()=>x(q(N,1)),"aria-label":m==="th"?"\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E16\u0E31\u0E14\u0E44\u0E1B":"Next month",children:jsx(ChevronRight,{size:C,className:D??"text-blue-500"})})]})]}),jsx("div",{className:"grid grid-cols-7 px-1 mt-1 text-xs text-center gap-y-1 text-black/50",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:(m==="th"?W:$).map(t=>jsx("div",{className:"leading-7 h-7 whitespace-nowrap",children:t},t))}),jsx("div",{className:"grid grid-cols-7 gap-1 px-1 pt-1 pb-1",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:me.map((t,b)=>{let f=t.getMonth()===w,v=n&&t<new Date(n.getFullYear(),n.getMonth(),n.getDate())||d&&t>new Date(d.getFullYear(),d.getMonth(),d.getDate()),y=Z(t,h),ye=Z(t,new Date);return jsx(we,{d:t,inMonth:f,disabled:!!v,selected:y,isToday:ye,onPick:ge,dayClassName:X,outsideDayClassName:ae,selectedDayClassName:te,todayClassName:ee},b)})}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]})]})}),Ye=s.memo(Se);export{Ye as default};
@@ -1,2 +1,2 @@
1
- import {c}from'../chunk-E7CR2CS6.js';import'../chunk-KYNNMWQA.js';import'../chunk-J2VIBL5U.js';import'../chunk-KA7C25YJ.js';import'../chunk-QRYSV225.js';import'../chunk-FUTRX3HX.js';import'../chunk-IX36POX2.js';import'../chunk-H7BTHYKO.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var y=(t,o)=>o==="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},B=async t=>{try{let c=(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/district.json")).json()).find(e=>e.name_th===t||e.name_en===t||e.id===t);c&&(t=c.id);let s=await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/sub_district.json");if(!s.ok)throw new Error(`HTTP ${s.status}`);let i=await s.json();return t&&(i=i.filter(e=>e.district_id===t)),i}catch{return []}},j=({locale:t="th",searchPlaceholder:o="Search Sub District",placeholder:b="Select Sub District",label:c$1,searchButtonClassName:s="bg-blue-500",onChange:i,value:e,required:g=false,districtId:u,error:f,searchLabel:D="Search",onSearchMode:_,debounceMs:v,onOpenChange:w,popoverZIndex:C})=>{let[a,P]=useState([]),[l,d]=useState(null);useEffect(()=>{B(u??void 0).then(P);},[u]),useEffect(()=>{if(!e){d(null);return}let r=a.find(n=>n.id===e||n.name_th===e||n.name_en===e);d(r??null);},[a,e,t]);let x=useCallback(r=>{let n=a.find(M=>M.id===r);n&&(d(n),i?.(n));},[a,i]);return jsx("div",{children:jsx(c,{items:a.map(r=>y(r,t)),placeholder:o,triggerPlaceholder:b,label:c$1,selectionMode:"single",searchButtonClassName:s,onChange:r=>{x(r);},searchButtonLabel:D,value:l?.id!=null?l.id:void 0,required:g,disabled:!u&&l==null,errorMessage:f,onSearchMode:_,debounceMs:v,onOpenChange:w,popoverZIndex:C})})},q=j;
2
- export{q as default};
1
+ import {c}from'../chunk-E7CR2CS6.js';import'../chunk-KYNNMWQA.js';import'../chunk-J2VIBL5U.js';import'../chunk-KA7C25YJ.js';import'../chunk-QRYSV225.js';import'../chunk-FUTRX3HX.js';import'../chunk-IX36POX2.js';import'../chunk-H7BTHYKO.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var y=(t,c)=>c==="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},B=async t=>{try{let u=(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/district.json")).json()).find(r=>r.name_th===t||r.name_en===t||r.id===t);u&&(t=u.id);let a=await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/sub_district.json");if(!a.ok)throw new Error(`HTTP ${a.status}`);let e=await a.json(),n=[{id:e.length+1,zip_code:10800,name_th:"\u0E27\u0E07\u0E28\u0E4C\u0E2A\u0E27\u0E48\u0E32\u0E07",name_en:"Wong Sawang",district_id:1029,lat:6.249,long:101.875,created_at:"2019-08-09T03:33:09.000+07:00",updated_at:"2025-09-20T06:31:26.000+07:00",deleted_at:null}];return e=[...e,...n],t&&(e=e.filter(r=>r.district_id===t)),e}catch{return []}},T=({locale:t="th",searchPlaceholder:c$1="Search Sub District",placeholder:h="Select Sub District",label:u,searchButtonClassName:a="bg-blue-500",onChange:e,value:n,required:r=false,districtId:l,error:f,searchLabel:D="Search",onSearchMode:_,debounceMs:w,onOpenChange:v,popoverZIndex:C})=>{let[o,P]=useState([]),[d,b]=useState(null);useEffect(()=>{B(l??void 0).then(P);},[l]),useEffect(()=>{if(!n){b(null);return}let i=o.find(s=>s.id===n||s.name_th===n||s.name_en===n);b(i??null);},[o,n,t]);let x=useCallback(i=>{let s=o.find(M=>M.id===i);s&&(b(s),e?.(s));},[o,e]);return jsx("div",{children:jsx(c,{items:o.map(i=>y(i,t)),placeholder:c$1,triggerPlaceholder:h,label:u,selectionMode:"single",searchButtonClassName:a,onChange:i=>{x(i);},searchButtonLabel:D,value:d?.id!=null?d.id:void 0,required:r,disabled:!l&&d==null,errorMessage:f,onSearchMode:_,debounceMs:w,onOpenChange:v,popoverZIndex:C})})},j=T;
2
+ export{j as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "the-omelet-ui",
3
- "version": "1.8.61",
3
+ "version": "1.8.63",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",