the-omelet-ui 1.3.0 → 1.3.2

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$3}from'./chunk-A2DBYHBF.js';import {a as a$4}from'./chunk-IX36POX2.js';import {f,b}from'./chunk-AFEF2EXB.js';import {a as a$1}from'./chunk-DM45BGDQ.js';import {a as a$2}from'./chunk-6GLPXMGB.js';import*as a from'react';import*as l from'@radix-ui/react-popover';import {jsxs,jsx}from'react/jsx-runtime';function se(c){return typeof c=="string"?{id:c,label:c}:c}var le={neutral:"border-neutral-900 bg-neutral-900 text-white",primary:"border-black bg-black text-white",red:"border-red-600 bg-red-600 text-white",green:"border-green-600 bg-green-600 text-white",blue:"border-blue-600 bg-blue-600 text-white",yellow:"border-yellow-500 bg-yellow-500 text-black",violet:"border-violet-600 bg-violet-600 text-white"};function ne({trigger:c,triggerPlaceholder:x="Choose",items:y,selectionMode:b$1="multiple",value:w,defaultValue:z,onChange:Q,searchable:k=true,placeholder:A="Placeholder Text",searchButtonLabel:O="Search",onQueryChange:V,onSearch:j,loading:u=false,emptyLabel:D="No results",contentClassName:H,maxHeight:W=288,renderItem:R,buttonColor:_="primary",searchButtonColor:$,searchButtonClassName:E,checkedColor:F="primary",checkedClassName:G,renderTriggerValue:N,label:C,required:J,errorMessage:g}){let[P,S]=a.useState(false),[p,K]=a.useState(""),[f$1,U]=a.useState(""),s=b$1==="multiple",[X,Y]=a.useState(z??(s?[]:"")),o=w??X,d=a.useMemo(()=>y.map(se),[y]),I=a.useMemo(()=>{let e=f$1.trim().toLowerCase();return e?d.filter(r=>String(r.label).toLowerCase().includes(e)):d},[d,f$1]),B=e=>{Q?.(e),w===void 0&&Y(e);},Z=e=>{if(s){let r=new Set(o);r.has(e)?r.delete(e):r.add(e),B(Array.from(r));}else B(e),S(false);},ee=e=>s?o.includes(e):o===e,te=()=>{U(p),j?.(p);},h=a.useMemo(()=>s?o:o?[o]:[],[o,s]),m=a.useMemo(()=>d.filter(e=>h.includes(e.id)),[d,h]),re=a.useMemo(()=>m.length===0?x:s?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${m.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:m[0].label,[m,s,x]);return jsxs("fieldset",{children:[C&&jsx(a$1,{label:C,required:J}),jsxs(l.Root,{open:P,onOpenChange:S,children:[jsx("div",{className:"mb-2"}),jsx(l.Trigger,{asChild:true,children:c??jsxs("button",{type:"button",className:a$2("flex w-full min-w-[260px] items-center justify-between","rounded-md border border-black/15 bg-white px-4 py-3 text-left","outline-none focus-visible:ring-2 ring-black/20",g?"border-red-600":""),children:[jsx("span",{className:a$2("flex-1 ",{"text-gray-400":s?o?.length===0:!o,"text-black":s?o?.length>0:!!o}),children:N?N(h,m):re}),jsx("svg",{className:a$2("ml-3 h-5 w-5 text-black/60 transition-transform",P?"rotate-180":"rotate-0"),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:jsx("path",{d:"M6 9l6 6 6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]})}),jsx(l.Portal,{children:jsxs(l.Content,{sideOffset:8,className:a$2("w-[300px] rounded-md border border-black/10 bg-white p-2 shadow-xl",H),children:[k&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:e=>{e.preventDefault(),te();},children:[jsx(a$3,{start:jsx(f,{className:"h-3 w-3 text-black/50"}),value:p,onChange:e=>{K(e.currentTarget.value),V?.(e.currentTarget.value);},size:"sm",placeholder:A}),jsx(a$4,{color:$??_,type:"submit",disabled:u||p.trim()===f$1.trim(),size:"md",className:E,children:O})]}),jsxs("div",{role:"listbox","aria-multiselectable":s||void 0,className:a$2(" overflow-y-auto rounded-md",{"mt-3":k}),style:{maxHeight:W},children:[u&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),!u&&I.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:D}),!u&&I.map(e=>{let r=ee(e.id),oe=le[F],ae=jsxs(a$4,{type:"button",role:"option","aria-selected":r,onClick:()=>Z(e.id),disabled:e.disabled,size:"sm",className:a$2("group flex w-full items-center justify-between gap-3 rounded-md px-2 py-2 text-left bg-white","hover:bg-black/[0.04] disabled:opacity-50",{"bg-black/[0.04]":r&&b$1==="single"}),children:[jsx("span",{className:"text-md text-black",children:e.label}),b$1==="multiple"&&jsx("span",{className:a$2("grid h-5 w-5 place-items-center rounded-full border-2",r?oe:"border-black/20",r&&G),children:r?jsx(b,{className:"h-2 w-2"}):null})]},e.id);return R?jsx("div",{children:R(e,false,r)},e.id):ae})]}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]}),g&&jsx("small",{className:"text-red-500 text-xs",children:g})]})}var pe=ne;export{pe as a};
1
+ 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};
@@ -1 +1 @@
1
- import {b as b$1}from'../chunk-AFEF2EXB.js';import {a}from'../chunk-DM45BGDQ.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import*as e from'react';import {jsx,jsxs}from'react/jsx-runtime';var M={sm:{box:"h-4 w-4 rounded-md",icon:"h-2 w-2 text-white"},md:{box:"h-5 w-5 rounded-md",icon:"h-3 w-3 text-white"},lg:{box:"h-7 w-7 rounded-md",icon:"h-5 w-5 text-white"}},P=e.memo(function({label:a$2,required:s,className:o,id:n}){return a$2==null?null:typeof a$2=="string"?jsx(a,{label:a$2,required:s}):jsx("span",{className:a$1("text-[15px] text-black",o),children:a$2})}),b=e.forwardRef(function({checked:a,defaultChecked:s,onCheckedChange:o,id:n,name:p,value:h,disabled:u=false,required:c=false,size:g="md",label:f,labelPosition:x="right",className:k,boxClassName:C,labelClassName:w,indicatorClassName:R,checkedBg:N="#2f6af7",uncheckedBorderColor:y="rgb(0 0 0 / 0.2)"},v){let i=M[g],S=e.useCallback(I=>{o?.(I.currentTarget.checked);},[o]),L=e.useMemo(()=>a$1("inline-flex items-center justify-center border-2 bg-white transition-colors","peer-focus-visible:ring-2 ring-black/20","peer-disabled:opacity-50 peer-disabled:cursor-not-allowed","border-[var(--ubc)]","peer-checked:bg-[var(--cbg)] peer-checked:border-transparent"),[]),B=e.useMemo(()=>a$1("text-white transition-all duration-150","peer-checked:opacity-100 peer-checked:scale-100"),[]);return jsxs("label",{className:a$1("inline-flex items-center gap-3 select-none",x==="left"&&"flex-row-reverse justify-end",k),htmlFor:n,style:{"--cbg":N,"--ubc":y},children:[jsx("input",{ref:v,id:n,name:p,value:h,type:"checkbox",className:"peer sr-only",checked:a,defaultChecked:s,onChange:S,disabled:u,"aria-required":c||void 0}),jsx("span",{className:a$1(L,i.box,C),children:jsx(b$1,{className:a$1(i.icon,B,R)})}),jsx(P,{label:f,required:c,className:w,id:n})]})});b.displayName="Checkbox";var z=e.memo(b);export{z as default};
1
+ import {a}from'../chunk-DM45BGDQ.js';import {b as b$1}from'../chunk-AFEF2EXB.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import*as e from'react';import {jsx,jsxs}from'react/jsx-runtime';var M={sm:{box:"h-4 w-4 rounded-md",icon:"h-2 w-2 text-white"},md:{box:"h-5 w-5 rounded-md",icon:"h-3 w-3 text-white"},lg:{box:"h-7 w-7 rounded-md",icon:"h-5 w-5 text-white"}},P=e.memo(function({label:a$2,required:s,className:o,id:n}){return a$2==null?null:typeof a$2=="string"?jsx(a,{label:a$2,required:s}):jsx("span",{className:a$1("text-[15px] text-black",o),children:a$2})}),b=e.forwardRef(function({checked:a,defaultChecked:s,onCheckedChange:o,id:n,name:p,value:h,disabled:u=false,required:c=false,size:g="md",label:f,labelPosition:x="right",className:k,boxClassName:C,labelClassName:w,indicatorClassName:R,checkedBg:N="#2f6af7",uncheckedBorderColor:y="rgb(0 0 0 / 0.2)"},v){let i=M[g],S=e.useCallback(I=>{o?.(I.currentTarget.checked);},[o]),L=e.useMemo(()=>a$1("inline-flex items-center justify-center border-2 bg-white transition-colors","peer-focus-visible:ring-2 ring-black/20","peer-disabled:opacity-50 peer-disabled:cursor-not-allowed","border-[var(--ubc)]","peer-checked:bg-[var(--cbg)] peer-checked:border-transparent"),[]),B=e.useMemo(()=>a$1("text-white transition-all duration-150","peer-checked:opacity-100 peer-checked:scale-100"),[]);return jsxs("label",{className:a$1("inline-flex items-center gap-3 select-none",x==="left"&&"flex-row-reverse justify-end",k),htmlFor:n,style:{"--cbg":N,"--ubc":y},children:[jsx("input",{ref:v,id:n,name:p,value:h,type:"checkbox",className:"peer sr-only",checked:a,defaultChecked:s,onChange:S,disabled:u,"aria-required":c||void 0}),jsx("span",{className:a$1(L,i.box,C),children:jsx(b$1,{className:a$1(i.icon,B,R)})}),jsx(P,{label:f,required:c,className:w,id:n})]})});b.displayName="Checkbox";var z=e.memo(b);export{z as default};
@@ -1 +1 @@
1
- import {a as a$2,c,d,e}from'../chunk-AFEF2EXB.js';import {a as a$1}from'../chunk-DM45BGDQ.js';import {a}from'../chunk-6GLPXMGB.js';import*as s from'react';import*as r from'@radix-ui/react-popover';import {jsx,jsxs}from'react/jsx-runtime';var pe=["\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"],G=["\u0E2D\u0E32","\u0E08","\u0E2D","\u0E1E","\u0E1E\u0E24","\u0E28","\u0E2A"],ge=["January","February","March","April","May","June","July","August","September","October","November","December"],J=["Su","Mo","Tu","We","Th","Fr","Sa"],E=o=>new Date(o.getFullYear(),o.getMonth(),1),W=(o,e)=>new Date(o.getFullYear(),o.getMonth()+e,1),$=(o,e)=>{let l=new Date(o);return l.setDate(l.getDate()+e),l},q=(o,e)=>!!o&&!!e&&o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate(),he=(o,e,l)=>e&&o<e?e:l&&o>l?l:o,ve=s.memo(function({d:e,inMonth:l,disabled:i,selected:p,isToday:d,onPick:n,dayClassName:u,outsideDayClassName:m,selectedDayClassName:M,todayClassName:N}){let R=s.useCallback(()=>{i||n(e);},[i,n,e]);return jsx("button",{type:"button",onClick:R,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",l?"text-black":m??"text-black/30",i&&"opacity-30 pointer-events-none",d&&!p&&(N??"bg-[#EDF6FF] text-[#004499] font-bold"),u,p?a("bg-blue-600 text-white hover:bg-blue-600",M):"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),ye=s.memo(function({months:e,activeMonth:l,onSelect:i}){let p=s.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,n)=>jsx("button",{type:"button",onClick:()=>p(n),className:a("rounded-md px-2 py-2 text-sm hover:bg-black/5",n===l&&"bg-black/10"),children:d},d))})}),fe=s.memo(function({years:e,activeYear:l,labelFromYear:i,onSelect:p}){let d=s.useCallback(n=>p(n),[p]);return jsx("div",{className:"max-h-72 w-28 overflow-y-auto rounded-md border border-black/10 bg-white p-1 shadow-lg",children:e.map(n=>jsx("button",{type:"button",onClick:()=>d(n),className:a("block w-full rounded-md px-2 py-2 text-left text-sm hover:bg-black/5",n===l&&"bg-black/10"),children:i(n)},n))})}),De=s.forwardRef(function({label:e$1,required:l,value:i,defaultValue:p=null,onChange:d$1,minDate:n,maxDate:u,locale:m="th",useBuddhistEra:M,format:N,className:R,inputClassName:V,contentClassName:j,dayClassName:z,todayClassName:Q,selectedDayClassName:U,outsideDayClassName:X="text-black/30",placeholderText:Z="dd/mm/yyyy",calendarIcon:ee,disabled:O=false,error:Y,closeOnSelect:A=true,yearRange:S,iconClassName:w},te){let [ae,I]=s.useState(false),[oe,se]=s.useState(p),T=i!==void 0,g=(T?i:oe)??null,P=M??m==="th",L=m==="th"?pe:ge,ne=g??new Date,[D,k]=s.useState(E(ne));s.useEffect(()=>{g&&k(E(g));},[g?.getFullYear(),g?.getMonth()]);let C=D.getFullYear(),x=D.getMonth(),re=s.useMemo(()=>N||(m==="th"?a=>{let b=P?a.getFullYear()+543:a.getFullYear(),v=String(a.getDate()).padStart(2,"0"),y=String(a.getMonth()+1).padStart(2,"0");return `${v}/${y}/${b}`}:a=>a.toLocaleDateString("en-GB")),[N,m,P]),le=s.useMemo(()=>{let a=E(D),b=a.getDay(),v=$(a,-b);return Array.from({length:42},(y,f)=>$(v,f))},[D]),ce=s.useMemo(()=>{let a=new Date().getFullYear(),b=S?.[0]??n?.getFullYear()??a-60,v=S?.[1]??u?.getFullYear()??a+40,y=[];for(let f=b;f<=v;f++)y.push(f);return y},[S,n,u]),ie=P?C+543:C,de=s.useCallback(a=>{let b=he(a,n,u);d$1?.(b),T||se(b),A&&I(false);},[T,n,u,d$1,A]),ue=s.useCallback(a=>{k(new Date(C,a,1));},[C]),me=s.useCallback(a=>{k(new Date(a,x,1));},[x]);return jsxs("fieldset",{ref:te,className:a("",R),children:[e$1&&jsx(a$1,{required:l,label:e$1}),jsxs(r.Root,{open:ae,onOpenChange:I,children:[jsxs("div",{className:"relative mt-2",children:[jsx(r.Trigger,{asChild:true,children:jsx("button",{type:"button",disabled:O,className:a("flex w-full items-center rounded-md border bg-white px-3 py-2 text-left","outline-none focus-visible:ring-2",Y?"border-red-500 ring-red-200":"border-black/15 ring-black/20",O&&"opacity-50 cursor-not-allowed","pr-10",V),children:jsx("span",{className:a("truncate text-black",!g&&"text-black/40"),children:g?re(g):Z})})}),jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-black/50",children:ee??jsx(a$2,{})})]}),Y&&jsx("small",{className:"text-red-500 text-xs",children:Y}),jsx(r.Portal,{children:jsxs(r.Content,{sideOffset:8,className:a("w-[300px] sm:w-[320px] rounded-md border border-black/10 bg-white p-3 shadow-xl",j),children:[jsxs("div",{className:"flex items-center justify-between px-1 py-1",children:[jsxs("div",{className:"flex items-center gap-1",children:[jsxs(r.Root,{modal:false,children:[jsx(r.Trigger,{asChild:true,children:jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-base font-semibold text-black hover:bg-black/5","aria-label":"\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E40\u0E14\u0E37\u0E2D\u0E19",children:[L[x],jsx(c,{className:w??"text-blue-500 w-3 h-3"})]})}),jsx(r.Portal,{children:jsxs(r.Content,{sideOffset:6,align:"start",className:"rounded-md border border-black/10 bg-white p-2 shadow-lg",children:[jsx(ye,{months:L,activeMonth:x,onSelect:ue}),jsx(r.Arrow,{className:"fill-white stroke-black/10"})]})})]}),jsxs(r.Root,{modal:false,children:[jsx(r.Trigger,{asChild:true,children:jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-base font-semibold text-black hover:bg-black/5","aria-label":"\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E1B\u0E35",children:[ie,jsx(c,{className:w??"text-blue-500 w-3 h-3"})]})}),jsx(r.Portal,{children:jsxs(r.Content,{sideOffset:6,align:"start",children:[jsx(fe,{years:ce,activeYear:C,labelFromYear:a=>P?a+543:a,onSelect:me}),jsx(r.Arrow,{className:"fill-white stroke-black/10"})]})})]})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",className:"rounded-md p-2 text-black/70 hover:bg-black/5",onClick:()=>k(W(D,-1)),"aria-label":m==="th"?"\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32":"Previous month",children:jsx(d,{className:w??"text-blue-500 w-3 h-3"})}),jsx("button",{type:"button",className:"rounded-md p-2 text-black/70 hover:bg-black/5",onClick:()=>k(W(D,1)),"aria-label":m==="th"?"\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E16\u0E31\u0E14\u0E44\u0E1B":"Next month",children:jsx(e,{className:w??"text-blue-500 w-3 h-3"})})]})]}),jsx("div",{className:"mt-1 grid grid-cols-7 gap-y-1 px-1 text-center text-xs text-black/50",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:(m==="th"?G:J).map(a=>jsx("div",{className:"h-7 leading-7 whitespace-nowrap",children:a},a))}),jsx("div",{className:"grid grid-cols-7 gap-1 px-1 pb-1 pt-1",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:le.map((a,b)=>{let v=a.getMonth()===x,y=n&&a<new Date(n.getFullYear(),n.getMonth(),n.getDate())||u&&a>new Date(u.getFullYear(),u.getMonth(),u.getDate()),f=q(a,g),be=q(a,new Date);return jsx(ve,{d:a,inMonth:v,disabled:!!y,selected:f,isToday:be,onPick:de,dayClassName:z,outsideDayClassName:X,selectedDayClassName:U,todayClassName:Q},b)})}),jsx(r.Arrow,{className:"fill-white stroke-black/10"})]})})]})]})}),Ne=s.memo(De);export{Ne as default};
1
+ import {a as a$1}from'../chunk-DM45BGDQ.js';import {a as a$2,c,d,e}from'../chunk-AFEF2EXB.js';import {a}from'../chunk-6GLPXMGB.js';import*as s from'react';import*as r from'@radix-ui/react-popover';import {jsx,jsxs}from'react/jsx-runtime';var pe=["\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"],G=["\u0E2D\u0E32","\u0E08","\u0E2D","\u0E1E","\u0E1E\u0E24","\u0E28","\u0E2A"],ge=["January","February","March","April","May","June","July","August","September","October","November","December"],J=["Su","Mo","Tu","We","Th","Fr","Sa"],E=o=>new Date(o.getFullYear(),o.getMonth(),1),W=(o,e)=>new Date(o.getFullYear(),o.getMonth()+e,1),$=(o,e)=>{let l=new Date(o);return l.setDate(l.getDate()+e),l},q=(o,e)=>!!o&&!!e&&o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate(),he=(o,e,l)=>e&&o<e?e:l&&o>l?l:o,ve=s.memo(function({d:e,inMonth:l,disabled:i,selected:p,isToday:d,onPick:n,dayClassName:u,outsideDayClassName:m,selectedDayClassName:M,todayClassName:N}){let R=s.useCallback(()=>{i||n(e);},[i,n,e]);return jsx("button",{type:"button",onClick:R,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",l?"text-black":m??"text-black/30",i&&"opacity-30 pointer-events-none",d&&!p&&(N??"bg-[#EDF6FF] text-[#004499] font-bold"),u,p?a("bg-blue-600 text-white hover:bg-blue-600",M):"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),ye=s.memo(function({months:e,activeMonth:l,onSelect:i}){let p=s.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,n)=>jsx("button",{type:"button",onClick:()=>p(n),className:a("rounded-md px-2 py-2 text-sm hover:bg-black/5",n===l&&"bg-black/10"),children:d},d))})}),fe=s.memo(function({years:e,activeYear:l,labelFromYear:i,onSelect:p}){let d=s.useCallback(n=>p(n),[p]);return jsx("div",{className:"max-h-72 w-28 overflow-y-auto rounded-md border border-black/10 bg-white p-1 shadow-lg",children:e.map(n=>jsx("button",{type:"button",onClick:()=>d(n),className:a("block w-full rounded-md px-2 py-2 text-left text-sm hover:bg-black/5",n===l&&"bg-black/10"),children:i(n)},n))})}),De=s.forwardRef(function({label:e$1,required:l,value:i,defaultValue:p=null,onChange:d$1,minDate:n,maxDate:u,locale:m="th",useBuddhistEra:M,format:N,className:R,inputClassName:V,contentClassName:j,dayClassName:z,todayClassName:Q,selectedDayClassName:U,outsideDayClassName:X="text-black/30",placeholderText:Z="dd/mm/yyyy",calendarIcon:ee,disabled:O=false,error:Y,closeOnSelect:A=true,yearRange:S,iconClassName:w},te){let [ae,I]=s.useState(false),[oe,se]=s.useState(p),T=i!==void 0,g=(T?i:oe)??null,P=M??m==="th",L=m==="th"?pe:ge,ne=g??new Date,[D,k]=s.useState(E(ne));s.useEffect(()=>{g&&k(E(g));},[g?.getFullYear(),g?.getMonth()]);let C=D.getFullYear(),x=D.getMonth(),re=s.useMemo(()=>N||(m==="th"?a=>{let b=P?a.getFullYear()+543:a.getFullYear(),v=String(a.getDate()).padStart(2,"0"),y=String(a.getMonth()+1).padStart(2,"0");return `${v}/${y}/${b}`}:a=>a.toLocaleDateString("en-GB")),[N,m,P]),le=s.useMemo(()=>{let a=E(D),b=a.getDay(),v=$(a,-b);return Array.from({length:42},(y,f)=>$(v,f))},[D]),ce=s.useMemo(()=>{let a=new Date().getFullYear(),b=S?.[0]??n?.getFullYear()??a-60,v=S?.[1]??u?.getFullYear()??a+40,y=[];for(let f=b;f<=v;f++)y.push(f);return y},[S,n,u]),ie=P?C+543:C,de=s.useCallback(a=>{let b=he(a,n,u);d$1?.(b),T||se(b),A&&I(false);},[T,n,u,d$1,A]),ue=s.useCallback(a=>{k(new Date(C,a,1));},[C]),me=s.useCallback(a=>{k(new Date(a,x,1));},[x]);return jsxs("fieldset",{ref:te,className:a("",R),children:[e$1&&jsx(a$1,{required:l,label:e$1}),jsxs(r.Root,{open:ae,onOpenChange:I,children:[jsxs("div",{className:"relative mt-2",children:[jsx(r.Trigger,{asChild:true,children:jsx("button",{type:"button",disabled:O,className:a("flex w-full items-center rounded-md border bg-white px-3 py-2 text-left","outline-none focus-visible:ring-2",Y?"border-red-500 ring-red-200":"border-black/15 ring-black/20",O&&"opacity-50 cursor-not-allowed","pr-10",V),children:jsx("span",{className:a("truncate text-black",!g&&"text-black/40"),children:g?re(g):Z})})}),jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-black/50",children:ee??jsx(a$2,{})})]}),Y&&jsx("small",{className:"text-red-500 text-xs",children:Y}),jsx(r.Portal,{children:jsxs(r.Content,{sideOffset:8,className:a("w-[300px] sm:w-[320px] rounded-md border border-black/10 bg-white p-3 shadow-xl",j),children:[jsxs("div",{className:"flex items-center justify-between px-1 py-1",children:[jsxs("div",{className:"flex items-center gap-1",children:[jsxs(r.Root,{modal:false,children:[jsx(r.Trigger,{asChild:true,children:jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-base font-semibold text-black hover:bg-black/5","aria-label":"\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E40\u0E14\u0E37\u0E2D\u0E19",children:[L[x],jsx(c,{className:w??"text-blue-500 w-3 h-3"})]})}),jsx(r.Portal,{children:jsxs(r.Content,{sideOffset:6,align:"start",className:"rounded-md border border-black/10 bg-white p-2 shadow-lg",children:[jsx(ye,{months:L,activeMonth:x,onSelect:ue}),jsx(r.Arrow,{className:"fill-white stroke-black/10"})]})})]}),jsxs(r.Root,{modal:false,children:[jsx(r.Trigger,{asChild:true,children:jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-base font-semibold text-black hover:bg-black/5","aria-label":"\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E1B\u0E35",children:[ie,jsx(c,{className:w??"text-blue-500 w-3 h-3"})]})}),jsx(r.Portal,{children:jsxs(r.Content,{sideOffset:6,align:"start",children:[jsx(fe,{years:ce,activeYear:C,labelFromYear:a=>P?a+543:a,onSelect:me}),jsx(r.Arrow,{className:"fill-white stroke-black/10"})]})})]})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",className:"rounded-md p-2 text-black/70 hover:bg-black/5",onClick:()=>k(W(D,-1)),"aria-label":m==="th"?"\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32":"Previous month",children:jsx(d,{className:w??"text-blue-500 w-3 h-3"})}),jsx("button",{type:"button",className:"rounded-md p-2 text-black/70 hover:bg-black/5",onClick:()=>k(W(D,1)),"aria-label":m==="th"?"\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E16\u0E31\u0E14\u0E44\u0E1B":"Next month",children:jsx(e,{className:w??"text-blue-500 w-3 h-3"})})]})]}),jsx("div",{className:"mt-1 grid grid-cols-7 gap-y-1 px-1 text-center text-xs text-black/50",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:(m==="th"?G:J).map(a=>jsx("div",{className:"h-7 leading-7 whitespace-nowrap",children:a},a))}),jsx("div",{className:"grid grid-cols-7 gap-1 px-1 pb-1 pt-1",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:le.map((a,b)=>{let v=a.getMonth()===x,y=n&&a<new Date(n.getFullYear(),n.getMonth(),n.getDate())||u&&a>new Date(u.getFullYear(),u.getMonth(),u.getDate()),f=q(a,g),be=q(a,new Date);return jsx(ve,{d:a,inMonth:v,disabled:!!y,selected:f,isToday:be,onPick:de,dayClassName:z,outsideDayClassName:X,selectedDayClassName:U,todayClassName:Q},b)})}),jsx(r.Arrow,{className:"fill-white stroke-black/10"})]})})]})]})}),Ne=s.memo(De);export{Ne as default};
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-4KKSYTCZ.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var S=(t,s)=>s==="en"?{id:t.id,name:t.name_en,value:t.id,label:t.name_en}:{id:t.id,name:t.name_th,value:t.id,label:t.name_th},P=async t=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/district.json")).json()).filter(a=>a.province_id===t),w=({locale:t="th",searchPlaceholder:s="Search District",placeholder:c="Select District",label:l,searchButtonClassName:a$1="bg-blue-500",onChange:f,value:n,required:D=false,provinceId:o})=>{let[i,g]=useState([]),[b,d]=useState(null);useEffect(()=>{o&&P(o).then(g);},[o]),useEffect(()=>{if(n){let e=i.find(r=>t==="th"?r.name_th===n:r.name_en===n);e&&d(e);}},[i,n,t]);let _=useCallback(e=>{let r=i.find(v=>v.id===e);r&&(d(r),f?.(r));},[i]);return jsx("div",{children:jsx(a,{items:i.map(e=>S(e,t)),placeholder:s,triggerPlaceholder:c,label:l,selectionMode:"single",searchButtonClassName:a$1,onChange:e=>{typeof e=="string"&&_(e);},value:b?.id,required:D})})},x=w;
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;
2
2
  export{x as default};
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-4KKSYTCZ.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var C=(e,o)=>o==="en"?{id:e.id,name:e.name_en,value:e.id,label:e.name_en}:{id:e.id,name:e.name_th,value:e.id,label:e.name_th},S=async()=>await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province.json")).json(),w=({locale:e="th",searchPlaceholder:o="Search Province",placeholder:h="Select Province",label:u,searchButtonClassName:P="bg-blue-500",onChange:m,value:i,required:f=false})=>{let[r,v]=useState([]),[p,s]=useState(null);useEffect(()=>{S().then(v);},[]),useEffect(()=>{if(i){let n=r.find(t=>e==="th"?t.name_th===i:t.name_en===i);n&&s(n);}},[r,i,e]);let g=useCallback(n=>{let t=r.find(b=>b.id===n);t&&(s(t),m?.(t));},[r]);return jsx("div",{children:jsx(a,{items:r.map(n=>C(n,e)),placeholder:o,triggerPlaceholder:h,label:u,selectionMode:"single",searchButtonClassName:P,onChange:n=>{typeof n=="string"&&g(n);},value:p?.id,required:f})})},x=w;
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
2
  export{x as default};
@@ -1 +1 @@
1
- export{a as default}from'../chunk-4KKSYTCZ.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';
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 +1 @@
1
- import {a as a$2}from'../chunk-A2DBYHBF.js';import {a as a$3}from'../chunk-IX36POX2.js';import {f,b}from'../chunk-AFEF2EXB.js';import {a}from'../chunk-DM45BGDQ.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import*as r from'react';import*as c from'@radix-ui/react-popover';import {jsx,jsxs}from'react/jsx-runtime';var qe=o=>l=>{o(typeof l=="string"?l:l[0]||"");},ze=o=>l=>{o(Array.isArray(l)?l:[l]);};function K(o){return typeof o=="string"?{id:o,label:o}:o}var Se={neutral:"border-neutral-900 bg-neutral-900 text-white",primary:"border-black bg-black text-white",red:"border-red-600 bg-red-600 text-white",green:"border-green-600 bg-green-600 text-white",blue:"border-blue-600 bg-blue-600 text-white",yellow:"border-yellow-500 bg-yellow-500 text-black",violet:"border-violet-600 bg-violet-600 text-white"};function Ie({trigger:o,triggerPlaceholder:l="Choose",items:X,loadOptions:i,selectionMode:y="multiple",value:M,defaultValue:Y,onChange:Z,searchable:T=true,placeholder:O="Placeholder Text",searchButtonLabel:ee="Search",onQueryChange:te,onSearch:re,loading:se=false,emptyLabel:ae="No results",errorLabel:oe="Failed to load options",contentClassName:le,maxHeight:ne=288,renderItem:A,buttonColor:ce="primary",searchButtonColor:ie,searchButtonClassName:de,checkedColor:ue="primary",checkedClassName:me,renderTriggerValue:q,label:z,required:ge,enablePagination:p=false,pageSize:H=20,errorMessage:R}){let[x,Q]=r.useState(false),[b$1,pe]=r.useState(""),[k,E]=r.useState(""),[V,w]=r.useState([]),[N,W]=r.useState(false),[C,j]=r.useState(null),[be,D]=r.useState(1),[fe,he]=r.useState(true),n=y==="multiple",[xe,ve]=r.useState(Y??(n?[]:"")),a$4=M??xe,F=i?V:X||[],m=r.useMemo(()=>F.map(K),[F]),S=r.useCallback(async(e,s=1,h=false)=>{if(i){W(true),j(null);try{let B=(await i(e)).map(K);w(h?Ce=>[...Ce,...B]:B),p&&he(B.length===H);}catch(u){j(u instanceof Error?u.message:"Unknown error"),w([]);}finally{W(false);}}},[i,p,H]);r.useEffect(()=>{x&&i&&V.length===0&&S("");},[x,i]);let v=r.useMemo(()=>{if(i)return m;let e=k.trim().toLowerCase();return e?m.filter(s=>String(s.label).toLowerCase().includes(e)):m},[m,k,i]),U=e=>{Z?.(e),M===void 0&&ve(e);},ye=e=>{if(n){let s=new Set(a$4);s.has(e)?s.delete(e):s.add(e),U(Array.from(s));}else U(e),Q(false);},Re=e=>n?a$4.includes(e):a$4===e,ke=()=>{i?(D(1),S(b$1,1,false),E(b$1)):(E(b$1),re?.(b$1));},we=()=>{if(!N&&fe&&p){let e=be+1;D(e),S(k,e,true);}},I=r.useMemo(()=>n?a$4:a$4?[a$4]:[],[a$4,n]),f$1=r.useMemo(()=>m.filter(e=>I.includes(e.id)),[m,I]),Ne=r.useMemo(()=>f$1.length===0?l:n?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${f$1.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:f$1[0].label,[f$1,n,l]),P=N||se;return jsx("fieldset",{children:jsxs(c.Root,{open:x,onOpenChange:Q,children:[z&&jsx(a,{label:z,required:ge}),jsx("div",{className:"mb-2"}),jsx(c.Trigger,{asChild:true,children:o??jsxs("button",{type:"button",className:a$1("flex w-full min-w-[260px] items-center justify-between","rounded-md border border-black/15 bg-white px-4 py-3 text-left","outline-none focus-visible:ring-2 ring-black/20",R?"border-red-500":"border-black/20"),children:[jsx("span",{className:a$1("flex-1 ",{"text-gray-400":n?a$4?.length===0:!a$4,"text-black":n?a$4?.length>0:!!a$4}),children:q?q(I,f$1):Ne}),jsx("svg",{className:a$1("ml-3 h-5 w-5 text-black/60 transition-transform",x?"rotate-180":"rotate-0"),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:jsx("path",{d:"M6 9l6 6 6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]})}),R&&jsx("small",{className:"text-red-500 text-xs",children:R}),jsx(c.Portal,{children:jsxs(c.Content,{sideOffset:8,className:a$1("w-[300px] rounded-md border border-black/10 bg-white p-2 shadow-xl",le),children:[T&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:e=>{e.preventDefault(),ke();},children:[jsx(a$2,{start:jsx(f,{className:"h-3 w-3 text-black/50"}),value:b$1,onChange:e=>{pe(e.currentTarget.value),te?.(e.currentTarget.value);},size:"sm",placeholder:O}),jsx(a$3,{color:ie??ce,type:"submit",disabled:P,size:"md",className:de,children:ee})]}),jsxs("div",{role:"listbox","aria-multiselectable":n||void 0,className:a$1("overflow-y-auto rounded-md",{"mt-3":T}),style:{maxHeight:ne},onScroll:e=>{if(!p)return;let{scrollTop:s,scrollHeight:h,clientHeight:u}=e.currentTarget;h-s<=u+50&&we();},children:[P&&v.length===0&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),C&&jsx("div",{className:"p-6 text-center text-red-600",children:oe}),!P&&!C&&v.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:ae}),!C&&v.map(e=>{let s=Re(e.id),h=Se[ue],u=jsxs(a$3,{type:"button",role:"option","aria-selected":s,onClick:()=>ye(e.id),disabled:e.disabled,size:"sm",className:a$1("group flex w-full items-center justify-between gap-3 rounded-md px-2 py-2 text-left bg-white h-auto","hover:bg-black/[0.04] disabled:opacity-50",{"bg-black/[0.04]":s&&y==="single"}),children:[jsx("span",{className:"text-md text-black",children:e.label}),y==="multiple"&&jsx("span",{className:a$1("grid h-5 w-5 place-items-center rounded-full border-2",s?h:"border-black/20",s&&me),children:s?jsx(b,{className:"h-2 w-2"}):null})]},e.id);return A?jsx("div",{children:A(e,false,s)},e.id):u}),p&&N&&v.length>0&&jsx("div",{className:"p-2 text-center text-sm text-black/40",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21..."})]}),jsx(c.Arrow,{className:"fill-white stroke-black/10"})]})})]})})}var Pe=Ie;export{Pe as default,ze as handleMultipleChange,qe as handleSingleChange};
1
+ import {a as a$2}from'../chunk-A2DBYHBF.js';import {a as a$3}from'../chunk-IX36POX2.js';import {a}from'../chunk-DM45BGDQ.js';import {f,b}from'../chunk-AFEF2EXB.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import*as r from'react';import*as c from'@radix-ui/react-popover';import {jsx,jsxs}from'react/jsx-runtime';var qe=o=>l=>{o(typeof l=="string"?l:l[0]||"");},ze=o=>l=>{o(Array.isArray(l)?l:[l]);};function K(o){return typeof o=="string"?{id:o,label:o}:o}var Se={neutral:"border-neutral-900 bg-neutral-900 text-white",primary:"border-black bg-black text-white",red:"border-red-600 bg-red-600 text-white",green:"border-green-600 bg-green-600 text-white",blue:"border-blue-600 bg-blue-600 text-white",yellow:"border-yellow-500 bg-yellow-500 text-black",violet:"border-violet-600 bg-violet-600 text-white"};function Ie({trigger:o,triggerPlaceholder:l="Choose",items:X,loadOptions:i,selectionMode:y="multiple",value:M,defaultValue:Y,onChange:Z,searchable:T=true,placeholder:O="Placeholder Text",searchButtonLabel:ee="Search",onQueryChange:te,onSearch:re,loading:se=false,emptyLabel:ae="No results",errorLabel:oe="Failed to load options",contentClassName:le,maxHeight:ne=288,renderItem:A,buttonColor:ce="primary",searchButtonColor:ie,searchButtonClassName:de,checkedColor:ue="primary",checkedClassName:me,renderTriggerValue:q,label:z,required:ge,enablePagination:p=false,pageSize:H=20,errorMessage:R}){let[x,Q]=r.useState(false),[b$1,pe]=r.useState(""),[k,E]=r.useState(""),[V,w]=r.useState([]),[N,W]=r.useState(false),[C,j]=r.useState(null),[be,D]=r.useState(1),[fe,he]=r.useState(true),n=y==="multiple",[xe,ve]=r.useState(Y??(n?[]:"")),a$4=M??xe,F=i?V:X||[],m=r.useMemo(()=>F.map(K),[F]),S=r.useCallback(async(e,s=1,h=false)=>{if(i){W(true),j(null);try{let B=(await i(e)).map(K);w(h?Ce=>[...Ce,...B]:B),p&&he(B.length===H);}catch(u){j(u instanceof Error?u.message:"Unknown error"),w([]);}finally{W(false);}}},[i,p,H]);r.useEffect(()=>{x&&i&&V.length===0&&S("");},[x,i]);let v=r.useMemo(()=>{if(i)return m;let e=k.trim().toLowerCase();return e?m.filter(s=>String(s.label).toLowerCase().includes(e)):m},[m,k,i]),U=e=>{Z?.(e),M===void 0&&ve(e);},ye=e=>{if(n){let s=new Set(a$4);s.has(e)?s.delete(e):s.add(e),U(Array.from(s));}else U(e),Q(false);},Re=e=>n?a$4.includes(e):a$4===e,ke=()=>{i?(D(1),S(b$1,1,false),E(b$1)):(E(b$1),re?.(b$1));},we=()=>{if(!N&&fe&&p){let e=be+1;D(e),S(k,e,true);}},I=r.useMemo(()=>n?a$4:a$4?[a$4]:[],[a$4,n]),f$1=r.useMemo(()=>m.filter(e=>I.includes(e.id)),[m,I]),Ne=r.useMemo(()=>f$1.length===0?l:n?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${f$1.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:f$1[0].label,[f$1,n,l]),P=N||se;return jsx("fieldset",{children:jsxs(c.Root,{open:x,onOpenChange:Q,children:[z&&jsx(a,{label:z,required:ge}),jsx("div",{className:"mb-2"}),jsx(c.Trigger,{asChild:true,children:o??jsxs("button",{type:"button",className:a$1("flex w-full min-w-[260px] items-center justify-between","rounded-md border border-black/15 bg-white px-4 py-3 text-left","outline-none focus-visible:ring-2 ring-black/20",R?"border-red-500":"border-black/20"),children:[jsx("span",{className:a$1("flex-1 ",{"text-gray-400":n?a$4?.length===0:!a$4,"text-black":n?a$4?.length>0:!!a$4}),children:q?q(I,f$1):Ne}),jsx("svg",{className:a$1("ml-3 h-5 w-5 text-black/60 transition-transform",x?"rotate-180":"rotate-0"),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:jsx("path",{d:"M6 9l6 6 6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]})}),R&&jsx("small",{className:"text-red-500 text-xs",children:R}),jsx(c.Portal,{children:jsxs(c.Content,{sideOffset:8,className:a$1("w-[300px] rounded-md border border-black/10 bg-white p-2 shadow-xl",le),children:[T&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:e=>{e.preventDefault(),ke();},children:[jsx(a$2,{start:jsx(f,{className:"h-3 w-3 text-black/50"}),value:b$1,onChange:e=>{pe(e.currentTarget.value),te?.(e.currentTarget.value);},size:"sm",placeholder:O}),jsx(a$3,{color:ie??ce,type:"submit",disabled:P,size:"md",className:de,children:ee})]}),jsxs("div",{role:"listbox","aria-multiselectable":n||void 0,className:a$1("overflow-y-auto rounded-md",{"mt-3":T}),style:{maxHeight:ne},onScroll:e=>{if(!p)return;let{scrollTop:s,scrollHeight:h,clientHeight:u}=e.currentTarget;h-s<=u+50&&we();},children:[P&&v.length===0&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),C&&jsx("div",{className:"p-6 text-center text-red-600",children:oe}),!P&&!C&&v.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:ae}),!C&&v.map(e=>{let s=Re(e.id),h=Se[ue],u=jsxs(a$3,{type:"button",role:"option","aria-selected":s,onClick:()=>ye(e.id),disabled:e.disabled,size:"sm",className:a$1("group flex w-full items-center justify-between gap-3 rounded-md px-2 py-2 text-left bg-white h-auto","hover:bg-black/[0.04] disabled:opacity-50",{"bg-black/[0.04]":s&&y==="single"}),children:[jsx("span",{className:"text-md text-black",children:e.label}),y==="multiple"&&jsx("span",{className:a$1("grid h-5 w-5 place-items-center rounded-full border-2",s?h:"border-black/20",s&&me),children:s?jsx(b,{className:"h-2 w-2"}):null})]},e.id);return A?jsx("div",{children:A(e,false,s)},e.id):u}),p&&N&&v.length>0&&jsx("div",{className:"p-2 text-center text-sm text-black/40",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21..."})]}),jsx(c.Arrow,{className:"fill-white stroke-black/10"})]})})]})})}var Pe=Ie;export{Pe as default,ze as handleMultipleChange,qe as handleSingleChange};
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-4KKSYTCZ.js';import'../chunk-A2DBYHBF.js';import'../chunk-IX36POX2.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var v=(t,s)=>s==="en"?{id:t.id,name:t.name_en,value:t.id,label:t.name_en}:{id:t.id,name:t.name_th,value:t.id,label:t.name_th},P=async t=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/sub_district.json")).json()).filter(a=>a.district_id===t),w=({locale:t="th",searchPlaceholder:s="Search District",placeholder:c="Select District",label:l,searchButtonClassName:a$1="bg-blue-500",onChange:p,value:n,required:b=false,districtId:o})=>{let[r,S]=useState([]),[g,d]=useState(null);useEffect(()=>{o&&P(o).then(S);},[o]),useEffect(()=>{if(n){let e=r.find(i=>t==="th"?i.name_th===n:i.name_en===n);e&&d(e);}},[r,n,t]);let D=useCallback(e=>{let i=r.find(_=>_.id===e);i&&(d(i),p?.(i));},[r]);return jsx("div",{children:jsx(a,{items:r.map(e=>v(e,t)),placeholder:s,triggerPlaceholder:c,label:l,selectionMode:"single",searchButtonClassName:a$1,onChange:e=>{typeof e=="string"&&D(e);},value:g?.id,required:b})})},x=w;
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;
2
2
  export{x as default};
@@ -0,0 +1,57 @@
1
+ import React__default from 'react';
2
+
3
+ interface Tab {
4
+ /**
5
+ * Unique identifier for the tab
6
+ */
7
+ value: string;
8
+ /**
9
+ * Display label
10
+ */
11
+ label: string;
12
+ /**
13
+ * Disabled state
14
+ */
15
+ disabled?: boolean;
16
+ /**
17
+ * Badge count (optional)
18
+ */
19
+ badge?: number;
20
+ }
21
+ interface TabsProps {
22
+ /**
23
+ * Array of tabs
24
+ */
25
+ tabs: Tab[];
26
+ /**
27
+ * Currently selected tab value
28
+ */
29
+ value?: string;
30
+ /**
31
+ * Default selected tab (for uncontrolled)
32
+ */
33
+ defaultValue?: string;
34
+ /**
35
+ * Callback when tab changes
36
+ */
37
+ onChange?: (value: string) => void;
38
+ /**
39
+ * Custom className
40
+ */
41
+ className?: string;
42
+ /**
43
+ * Variant style
44
+ */
45
+ variant?: 'pill' | 'underline' | 'solid' | 'outline';
46
+ /**
47
+ * Size
48
+ */
49
+ size?: 'sm' | 'md' | 'lg';
50
+ /**
51
+ * Full width tabs
52
+ */
53
+ fullWidth?: boolean;
54
+ }
55
+ declare const Tabs: React__default.FC<TabsProps>;
56
+
57
+ export { type Tab, type TabsProps, Tabs as default };
@@ -0,0 +1,15 @@
1
+ import {useState}from'react';import {jsx,jsxs}from'react/jsx-runtime';var f=({tabs:o,value:l,defaultValue:s,onChange:d,className:g="",variant:n="pill",size:c="md",fullWidth:u=false})=>{let[b,p]=useState(s||o[0]?.value||""),x=l??b,v=(e,t)=>{t||(p(e),d?.(e));},y={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-base",lg:"px-5 py-3 text-lg"},a={pill:{container:"bg-gray-100 rounded-full p-1",tab:"rounded-full transition-all duration-200",active:"bg-white shadow-sm",inactive:"hover:bg-gray-50"},outline:{container:"gap-2",tab:"rounded-[24px] border-1 transition-all duration-200 focus:outline-none",active:"border-gray-900 text-gray-900 bg-white ",inactive:"border-gray-300 text-gray-600 hover:border-gray-400 hover:text-gray-900"},underline:{container:"border-b border-gray-200",tab:"border-b-2 border-transparent transition-colors duration-200 -mb-px",active:"border-gray-900 text-gray-900",inactive:"text-gray-500 hover:text-gray-700 hover:border-gray-300"},solid:{container:"gap-2",tab:"rounded-lg transition-all duration-200",active:"bg-gray-900 text-white",inactive:"bg-gray-100 text-gray-700 hover:bg-gray-200"}}[n];return jsx("div",{className:`inline-flex items-center ${a.container} ${g}`,role:"tablist",children:o.map(e=>{let t=x===e.value,r=e.disabled;return jsx("button",{role:"tab","aria-selected":t,"aria-disabled":r,disabled:r,onClick:()=>v(e.value,r),className:`
2
+ ${y[c]}
3
+ ${a.tab}
4
+ ${t?a.active:a.inactive}
5
+ ${r?"opacity-50 cursor-not-allowed":"cursor-pointer"}
6
+ ${u?"flex-1":""}
7
+ font-medium
8
+ whitespace-nowrap
9
+ focus:outline-none
10
+ `,children:jsxs("span",{className:"flex items-center gap-2",children:[e.label,e.badge!==void 0&&e.badge>0&&jsx("span",{className:`
11
+ inline-flex items-center justify-center
12
+ min-w-[20px] h-5 px-1.5
13
+ text-xs font-semibold rounded-full
14
+ ${t?n==="pill"||n==="outline"?"bg-gray-900 text-white":"bg-white text-gray-900":"bg-gray-200 text-gray-700"}
15
+ `,children:e.badge>99?"99+":e.badge})]})},e.value)})})},h=f;export{h as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "the-omelet-ui",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",