the-omelet-ui 1.8.2 → 1.8.4

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-QRYSV225.js';import {a}from'./chunk-FK7R34ZH.js';import {a as a$1}from'./chunk-6GLPXMGB.js';import*as d from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var y=cva("block w-full rounded-md bg-white outline-none text-sm borderborder disabled:border-none transition-shadow disabled:bg-[#f4f4f4] disabled:pointer-events-none disabled:text-[#BDC2BE] disabled:font-boldfocus-visible:ring-2",{variants:{size:{sm:"h-8 px-2 py-3 text-sm",md:"h-10 px-2 py-4 text-md",lg:"h-12 px-4 py-6 text-xl"},tone:{neutral:"border border-[#C9D7E3] focus-visible:ring-black/20",success:"border border-green-500/60 focus-visible:ring-green-300",danger:"border border-red-500/60 focus-visible:ring-red-300",warning:"border border-yellow-500/60 focus-visible:ring-yellow-300",info:"border border-blue-500/60 focus-visible:ring-blue-300"},withStart:{true:"",false:""},withEnd:{true:"",false:""}},compoundVariants:[{withStart:true,class:"ps-10"},{withEnd:true,class:"pe-10"}],defaultVariants:{size:"md",tone:"neutral"}}),p=d.forwardRef(({className:u,start:s,end:r,size:b,tone:c,withStart:f,withEnd:m,error:t,label:a$3,required:x,disabled:g=false,...v},h)=>jsxs("fieldset",{className:"relative flex flex-col space-y-2",children:[a$3&&jsx(a,{label:a$3,required:x}),jsxs("div",{className:"relative flex flex-col gap-2 items-start text-start",children:[s?jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center ps-3","aria-hidden":"true",children:jsx("span",{className:"text-black/50",children:s})}):null,jsx("input",{ref:h,"data-state":t?"invalid":void 0,className:a$1(y({size:b,tone:t?"danger":c,withStart:f??!!s,withEnd:m??!!r}),u),disabled:g,...v}),r?jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pe-3",children:r}):null]}),t&&jsx(a$2,{message:t})]}));p.displayName="TextInput";var B=p;export{B 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 d from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var y=cva("block w-full rounded-md bg-white outline-none text-sm borderborder disabled:border-none transition-shadow disabled:bg-[#f4f4f4] disabled:pointer-events-none disabled:text-[#BDC2BE] disabled:font-boldfocus-visible:ring-2",{variants:{size:{sm:"h-8 px-2 py-3 text-sm",md:"h-10 px-2 py-4 text-md",lg:"h-12 px-4 py-6 text-xl"},tone:{neutral:"border border-[#C9D7E3] focus-visible:ring-black/20",success:"border border-green-500/60 focus-visible:ring-green-300",danger:"border border-red-500/60 focus-visible:ring-red-300",warning:"border border-yellow-500/60 focus-visible:ring-yellow-300",info:"border border-blue-500/60 focus-visible:ring-blue-300"},withStart:{true:"",false:""},withEnd:{true:"",false:""}},compoundVariants:[{withStart:true,class:"ps-10"},{withEnd:true,class:"pe-10"}],defaultVariants:{size:"md",tone:"neutral"}}),p=d.forwardRef(({className:u,start:s,end:r,size:b,tone:c,withStart:f,withEnd:m,error:t,label:a$3,required:x,disabled:g=false,...v},h)=>jsxs("fieldset",{className:"relative flex flex-col space-y-2",children:[a$3&&jsx(a,{label:a$3,required:x}),jsxs("div",{className:"relative flex flex-col gap-2 items-start text-start",children:[s?jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center ps-3","aria-hidden":"true",children:jsx("span",{className:"text-black/50",children:s})}):null,jsx("input",{ref:h,"data-state":t?"invalid":void 0,className:a$1(y({size:b,tone:t?"danger":c,withStart:f??!!s,withEnd:m??!!r}),u),disabled:g,...v}),r?jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pe-3",children:r}):null]}),t&&jsx(a$2,{message:t})]}));p.displayName="TextInput";var B=p;export{B as a};
@@ -1 +1 @@
1
- import {a as a$4}from'./chunk-KYNNMWQA.js';import {a as a$3}from'./chunk-HR6IGUYJ.js';import {a as a$5}from'./chunk-IX36POX2.js';import {a as a$1}from'./chunk-FK7R34ZH.js';import {a as a$2}from'./chunk-6GLPXMGB.js';import*as a from'react';import*as l from'@radix-ui/react-popover';import {Check}from'lucide-react';import {jsxs,jsx}from'react/jsx-runtime';function ie(c){return typeof c=="string"?{id:c,label:c}:c}var ce={neutral:"border-neutral-900 bg-neutral-900 text-white",primary:"border-black bg-black text-white",red:"border-red-600 bg-red-600 text-white",green:"border-green-600 bg-green-600 text-white",blue:"border-blue-600 bg-blue-600 text-white",yellow:"border-yellow-500 bg-yellow-500 text-black",violet:"border-violet-600 bg-violet-600 text-white"},de={sm:"h-8",md:"h-10",lg:"h-12"};function me({autoFocus:c=false,trigger:q,triggerPlaceholder:R="Choose",items:y,selectionMode:b="multiple",value:w,defaultValue:A,onChange:O,searchable:k=true,placeholder:Q="Placeholder Text",searchButtonLabel:V="Search",onQueryChange:D,onSearch:F,loading:u=false,emptyLabel:j="No results",contentClassName:H,maxHeight:W=288,renderItem:N,buttonColor:_="primary",searchButtonColor:$,searchButtonClassName:E,checkedColor:G="primary",checkedClassName:J,renderTriggerValue:C,label:P,required:K,errorMessage:f,disabled:p,size:U="md"}){let[I,S]=a.useState(false),[g,X]=a.useState(""),[h,Y]=a.useState(""),s=b==="multiple",[Z,ee]=a.useState(A??(s?[]:"")),o=w??Z,d=a.useMemo(()=>y.map(ie),[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=>{O?.(e),w===void 0&&ee(e);},te=e=>{if(s){let r=new Set(o);r.has(e)?r.delete(e):r.add(e),L(Array.from(r));}else L(e),S(false);},re=e=>s?o.includes(e):o===e,oe=()=>{Y(g),F?.(g);},v=a.useMemo(()=>s?o:o?[o]:[],[o,s]),m=a.useMemo(()=>d.filter(e=>v.includes(e.id)),[d,v]),ae=a.useMemo(()=>m.length===0?R:s?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${m.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:m[0].label,[m,s,R]);return jsxs("fieldset",{children:[P&&jsx(a$1,{label:P,required:K}),jsxs(l.Root,{open:I&&!p,onOpenChange:e=>!p&&S(e),children:[jsx("div",{className:"mb-2"}),jsx(l.Trigger,{asChild:true,children:q??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 text-left","outline-none focus-visible:ring-2 ring-black/20",f&&!p?"border-red-600":"",p?"opacity-50 cursor-not-allowed":"",de[U]),children:[jsx("span",{className:a$2("flex-1 ",{"text-gray-400":s?o?.length===0:!o,"text-black":s?o?.length>0:!!o}),children:C?C(v,m):ae}),jsx("svg",{className:a$2("ml-3 h-5 w-5 text-black/60 transition-transform",I?"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,onOpenAutoFocus:e=>{if(!c){e.preventDefault();return}},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(),oe();},children:[jsx(a$3,{start:jsx(a$4,{}),value:g,onChange:e=>{X(e.currentTarget.value),D?.(e.currentTarget.value);},size:"md",placeholder:Q}),jsx(a$5,{color:$??_,type:"submit",disabled:u||g.trim()===h.trim(),size:"md",className:E,children:V})]}),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&&B.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:j}),!u&&B.map(e=>{let r=re(e.id),se=ce[G],le=jsxs(a$5,{type:"button",role:"option","aria-selected":r,onClick:()=>te(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==="single"}),children:[jsx("span",{className:"text-md text-black",children:e.label}),b==="multiple"&&jsx("span",{className:a$2("grid h-5 w-5 place-items-center rounded-full border-2",r?se:"border-black/20",r&&J),children:r?jsx(Check,{size:12}):null})]},e.id);return N?jsx("div",{children:N(e,false,r)},e.id):le})]}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]}),f&&jsx("small",{className:"text-red-500 text-xs",children:f})]})}var ve=me;export{ve as a};
1
+ import {a as a$4}from'./chunk-KYNNMWQA.js';import {a as a$3}from'./chunk-2CWZ4OAO.js';import {a as a$5}from'./chunk-IX36POX2.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 l from'@radix-ui/react-popover';import {Check}from'lucide-react';import {jsxs,jsx}from'react/jsx-runtime';function ie(c){return typeof c=="string"?{id:c,label:c}:c}var ce={neutral:"border-neutral-900 bg-neutral-900 text-white",primary:"border-black bg-black text-white",red:"border-red-600 bg-red-600 text-white",green:"border-green-600 bg-green-600 text-white",blue:"border-blue-600 bg-blue-600 text-white",yellow:"border-yellow-500 bg-yellow-500 text-black",violet:"border-violet-600 bg-violet-600 text-white"},de={sm:"h-8",md:"h-10",lg:"h-12"};function me({autoFocus:c=false,trigger:q,triggerPlaceholder:R="Choose",items:y,selectionMode:b="multiple",value:w,defaultValue:A,onChange:O,searchable:k=true,placeholder:Q="Placeholder Text",searchButtonLabel:V="Search",onQueryChange:D,onSearch:F,loading:u=false,emptyLabel:j="No results",contentClassName:H,maxHeight:W=288,renderItem:N,buttonColor:_="primary",searchButtonColor:$,searchButtonClassName:E,checkedColor:G="primary",checkedClassName:J,renderTriggerValue:C,label:P,required:K,errorMessage:f,disabled:p,size:U="md"}){let[I,S]=a.useState(false),[g,X]=a.useState(""),[h,Y]=a.useState(""),s=b==="multiple",[Z,ee]=a.useState(A??(s?[]:"")),o=w??Z,d=a.useMemo(()=>y.map(ie),[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=>{O?.(e),w===void 0&&ee(e);},te=e=>{if(s){let r=new Set(o);r.has(e)?r.delete(e):r.add(e),L(Array.from(r));}else L(e),S(false);},re=e=>s?o.includes(e):o===e,oe=()=>{Y(g),F?.(g);},v=a.useMemo(()=>s?o:o?[o]:[],[o,s]),m=a.useMemo(()=>d.filter(e=>v.includes(e.id)),[d,v]),ae=a.useMemo(()=>m.length===0?R:s?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${m.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:m[0].label,[m,s,R]);return jsxs("fieldset",{children:[P&&jsx(a$1,{label:P,required:K}),jsxs(l.Root,{open:I&&!p,onOpenChange:e=>!p&&S(e),children:[jsx("div",{className:"mb-2"}),jsx(l.Trigger,{asChild:true,children:q??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 text-left","outline-none focus-visible:ring-2 ring-black/20",f&&!p?"border-red-600":"",p?"opacity-50 cursor-not-allowed":"",de[U]),children:[jsx("span",{className:a$2("flex-1 ",{"text-gray-400":s?o?.length===0:!o,"text-black":s?o?.length>0:!!o}),children:C?C(v,m):ae}),jsx("svg",{className:a$2("ml-3 h-5 w-5 text-black/60 transition-transform",I?"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,onOpenAutoFocus:e=>{if(!c){e.preventDefault();return}},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(),oe();},children:[jsx(a$3,{start:jsx(a$4,{}),value:g,onChange:e=>{X(e.currentTarget.value),D?.(e.currentTarget.value);},size:"md",placeholder:Q}),jsx(a$5,{color:$??_,type:"submit",disabled:u||g.trim()===h.trim(),size:"md",className:E,children:V})]}),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&&B.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:j}),!u&&B.map(e=>{let r=re(e.id),se=ce[G],le=jsxs(a$5,{type:"button",role:"option","aria-selected":r,onClick:()=>te(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==="single"}),children:[jsx("span",{className:"text-md text-black",children:e.label}),b==="multiple"&&jsx("span",{className:a$2("grid h-5 w-5 place-items-center rounded-full border-2",r?se:"border-black/20",r&&J),children:r?jsx(Check,{size:12}):null})]},e.id);return N?jsx("div",{children:N(e,false,r)},e.id):le})]}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]}),f&&jsx("small",{className:"text-red-500 text-xs",children:f})]})}var ve=me;export{ve as a};
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-6GLPXMGB.js';import {forwardRef}from'react';import {jsx,jsxs}from'react/jsx-runtime';var a=forwardRef(({required:t,label:r,id:s,labelClassName:n},o)=>jsx("div",{className:"flex items-center ",ref:o,children:jsxs("label",{className:a$1("block text-sm text-black font-bold",n),htmlFor:s,children:[r,t&&jsx("span",{className:"text-red-500",children:"*"})]})}));a.displayName="LabelInput";var d=a;export{d as a};
@@ -1 +1 @@
1
- import {a}from'../chunk-FK7R34ZH.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import*as e from'react';import {Check}from'lucide-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})}),d=e.forwardRef(function({checked:a,defaultChecked:s,onCheckedChange:o,id:n,name:m,value:p,disabled:h=false,required:c=false,size:u="md",label:g,labelPosition:f="right",className:x,boxClassName:k,labelClassName:C,indicatorClassName:w,checkedBg:R="#2f6af7",uncheckedBorderColor:N="rgb(0 0 0 / 0.2)"},y){let i=M[u],v=e.useCallback(B=>{o?.(B.currentTarget.checked);},[o]),S=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"),[]),L=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",f==="left"&&"flex-row-reverse justify-end",x),htmlFor:n,style:{"--cbg":R,"--ubc":N},children:[jsx("input",{ref:y,id:n,name:m,value:p,type:"checkbox",className:"peer sr-only",checked:a,defaultChecked:s,onChange:v,disabled:h,"aria-required":c||void 0}),jsx("span",{className:a$1(S,i.box,k),children:jsx(Check,{className:a$1(i.icon,L,w)})}),jsx(P,{label:g,required:c,className:C,id:n})]})});d.displayName="Checkbox";var z=e.memo(d);export{z as default};
1
+ import {a}from'../chunk-THE2HQGT.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import*as e from'react';import {Check}from'lucide-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})}),d=e.forwardRef(function({checked:a,defaultChecked:s,onCheckedChange:o,id:n,name:m,value:p,disabled:h=false,required:c=false,size:u="md",label:g,labelPosition:f="right",className:x,boxClassName:k,labelClassName:C,indicatorClassName:w,checkedBg:R="#2f6af7",uncheckedBorderColor:N="rgb(0 0 0 / 0.2)"},y){let i=M[u],v=e.useCallback(B=>{o?.(B.currentTarget.checked);},[o]),S=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"),[]),L=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",f==="left"&&"flex-row-reverse justify-end",x),htmlFor:n,style:{"--cbg":R,"--ubc":N},children:[jsx("input",{ref:y,id:n,name:m,value:p,type:"checkbox",className:"peer sr-only",checked:a,defaultChecked:s,onChange:v,disabled:h,"aria-required":c||void 0}),jsx("span",{className:a$1(S,i.box,k),children:jsx(Check,{className:a$1(i.icon,L,w)})}),jsx(P,{label:g,required:c,className:C,id:n})]})});d.displayName="Checkbox";var z=e.memo(d);export{z as default};
@@ -1 +1 @@
1
- import {a as a$1}from'../chunk-FK7R34ZH.js';import {a}from'../chunk-6GLPXMGB.js';import*as s from'react';import*as r from'@radix-ui/react-popover';import {CalendarDays,ChevronUp,ChevronDown,ChevronLeft,ChevronRight}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';var ye=["\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"],H=["\u0E2D\u0E32","\u0E08","\u0E2D","\u0E1E","\u0E1E\u0E24","\u0E28","\u0E2A"],he=["January","February","March","April","May","June","July","August","September","October","November","December"],z=["Su","Mo","Tu","We","Th","Fr","Sa"],E=o=>new Date(o.getFullYear(),o.getMonth(),1),K=(o,e)=>new Date(o.getFullYear(),o.getMonth()+e,1),B=(o,e)=>{let l=new Date(o);return l.setDate(l.getDate()+e),l},G=(o,e)=>!!o&&!!e&&o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate(),ve=(o,e,l)=>e&&o<e?e:l&&o>l?l:o,M=18,fe=s.memo(function({d:e,inMonth:l,disabled:i,selected:p,isToday:d,onPick:n,dayClassName:u,outsideDayClassName:m,selectedDayClassName:R,todayClassName:N}){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",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",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),De=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))})}),Ne=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))})}),ke=s.forwardRef(function({label:e,required:l,value:i,defaultValue:p=null,onChange:d,minDate:n,maxDate:u,locale:m="th",useBuddhistEra:R,format:N,className:S,inputClassName:J,contentClassName:V,dayClassName:W,todayClassName:$,selectedDayClassName:q,outsideDayClassName:U="text-black/30",placeholderText:Z="dd/mm/yyyy",calendarIcon:j,disabled:O=false,error:Y,closeOnSelect:A=true,yearRange:T,iconClassName:P},Q){let [X,I]=s.useState(false),[ee,te]=s.useState(p),F=i!==void 0,g=(F?i:ee)??null,w=R??m==="th",L=m==="th"?ye:he,ae=g??new Date,[D,k]=s.useState(E(ae));s.useEffect(()=>{g&&k(E(g));},[g?.getFullYear(),g?.getMonth()]);let C=D.getFullYear(),x=D.getMonth(),oe=s.useMemo(()=>N||(m==="th"?a=>{let b=w?a.getFullYear()+543:a.getFullYear(),h=String(a.getDate()).padStart(2,"0"),v=String(a.getMonth()+1).padStart(2,"0");return `${h}/${v}/${b}`}:a=>a.toLocaleDateString("en-GB")),[N,m,w]),se=s.useMemo(()=>{let a=E(D),b=a.getDay(),h=B(a,-b);return Array.from({length:42},(v,f)=>B(h,f))},[D]),ne=s.useMemo(()=>{let a=new Date().getFullYear(),b=T?.[0]??n?.getFullYear()??a-60,h=T?.[1]??u?.getFullYear()??a+40,v=[];for(let f=b;f<=h;f++)v.push(f);return v},[T,n,u]),re=w?C+543:C,le=s.useCallback(a=>{let b=ve(a,n,u);d?.(b),F||te(b),A&&I(false);},[F,n,u,d,A]),ce=s.useCallback(a=>{k(new Date(C,a,1));},[C]),ie=s.useCallback(a=>{k(new Date(a,x,1));},[x]);return jsxs("fieldset",{ref:Q,className:a("",S),children:[e&&jsx(a$1,{required:l,label:e}),jsxs(r.Root,{open:X,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",J),children:jsx("span",{className:a("truncate text-black",!g&&"text-black/40"),children:g?oe(g):Z})})}),jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-black/50",children:j??jsx(CalendarDays,{})})]}),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",V),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(ChevronUp,{size:M,className:P??"text-blue-500"})]})}),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(De,{months:L,activeMonth:x,onSelect:ce}),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:[re,jsx(ChevronDown,{size:M,className:P??"text-blue-500"})]})}),jsx(r.Portal,{children:jsxs(r.Content,{sideOffset:6,align:"start",children:[jsx(Ne,{years:ne,activeYear:C,labelFromYear:a=>w?a+543:a,onSelect:ie}),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(K(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:"rounded-md p-2 text-black/70 hover:bg-black/5",onClick:()=>k(K(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:"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"?H:z).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:se.map((a,b)=>{let h=a.getMonth()===x,v=n&&a<new Date(n.getFullYear(),n.getMonth(),n.getDate())||u&&a>new Date(u.getFullYear(),u.getMonth(),u.getDate()),f=G(a,g),de=G(a,new Date);return jsx(fe,{d:a,inMonth:h,disabled:!!v,selected:f,isToday:de,onPick:le,dayClassName:W,outsideDayClassName:U,selectedDayClassName:q,todayClassName:$},b)})}),jsx(r.Arrow,{className:"fill-white stroke-black/10"})]})})]})]})}),Ce=s.memo(ke);export{Ce as default};
1
+ 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 ye=["\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"],H=["\u0E2D\u0E32","\u0E08","\u0E2D","\u0E1E","\u0E1E\u0E24","\u0E28","\u0E2A"],he=["January","February","March","April","May","June","July","August","September","October","November","December"],z=["Su","Mo","Tu","We","Th","Fr","Sa"],E=o=>new Date(o.getFullYear(),o.getMonth(),1),K=(o,e)=>new Date(o.getFullYear(),o.getMonth()+e,1),B=(o,e)=>{let r=new Date(o);return r.setDate(r.getDate()+e),r},G=(o,e)=>!!o&&!!e&&o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate(),ve=(o,e,r)=>e&&o<e?e:r&&o>r?r:o,M=18,fe=s.memo(function({d:e,inMonth:r,disabled:i,selected:p,isToday:d,onPick:n,dayClassName:u,outsideDayClassName:m,selectedDayClassName:R,todayClassName:N}){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",d&&!p&&(N??"bg-[#EDF6FF] text-[#004499] font-bold"),u,p?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),De=s.memo(function({months:e,activeMonth:r,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===r&&"bg-black/10"),children:d},d))})}),Ne=s.memo(function({years:e,activeYear:r,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===r&&"bg-black/10"),children:i(n)},n))})}),ke=s.forwardRef(function({label:e,required:r,value:i,defaultValue:p=null,onChange:d,minDate:n,maxDate:u,locale:m="th",useBuddhistEra:R,format:N,className:S,inputClassName:J,contentClassName:V,dayClassName:W,todayClassName:$,selectedDayClassName:q,outsideDayClassName:U="text-black/30",placeholderText:Z="dd/mm/yyyy",calendarIcon:j,disabled:O=false,error:Y,closeOnSelect:A=true,yearRange:T,iconClassName:P},Q){let [X,I]=s.useState(false),[ee,te]=s.useState(p),F=i!==void 0,g=(F?i:ee)??null,w=R??m==="th",L=m==="th"?ye:he,ae=g??new Date,[D,k]=s.useState(E(ae));s.useEffect(()=>{g&&k(E(g));},[g?.getFullYear(),g?.getMonth()]);let C=D.getFullYear(),x=D.getMonth(),oe=s.useMemo(()=>N||(m==="th"?a=>{let b=w?a.getFullYear()+543:a.getFullYear(),h=String(a.getDate()).padStart(2,"0"),v=String(a.getMonth()+1).padStart(2,"0");return `${h}/${v}/${b}`}:a=>a.toLocaleDateString("en-GB")),[N,m,w]),se=s.useMemo(()=>{let a=E(D),b=a.getDay(),h=B(a,-b);return Array.from({length:42},(v,f)=>B(h,f))},[D]),ne=s.useMemo(()=>{let a=new Date().getFullYear(),b=T?.[0]??n?.getFullYear()??a-60,h=T?.[1]??u?.getFullYear()??a+40,v=[];for(let f=b;f<=h;f++)v.push(f);return v},[T,n,u]),le=w?C+543:C,re=s.useCallback(a=>{let b=ve(a,n,u);d?.(b),F||te(b),A&&I(false);},[F,n,u,d,A]),ce=s.useCallback(a=>{k(new Date(C,a,1));},[C]),ie=s.useCallback(a=>{k(new Date(a,x,1));},[x]);return jsxs("fieldset",{ref:Q,className:a("w-full",S),children:[e&&jsx(a$1,{required:r,label:e}),jsxs(l.Root,{open:X,onOpenChange:I,children:[jsxs("div",{className:"relative mt-2",children:[jsx(l.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",J),children:jsx("span",{className:a("truncate text-black",!g&&"text-black/40"),children:g?oe(g):Z})})}),jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-black/50",children:j??jsx(CalendarDays,{})})]}),Y&&jsx("small",{className:"text-red-500 text-xs",children:Y}),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",V),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,children:[jsx(l.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(ChevronUp,{size:M,className:P??"text-blue-500"})]})}),jsx(l.Portal,{children:jsxs(l.Content,{sideOffset:6,align:"start",className:"rounded-md border border-black/10 bg-white p-2 shadow-lg",children:[jsx(De,{months:L,activeMonth:x,onSelect:ce}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]}),jsxs(l.Root,{modal:false,children:[jsx(l.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:[le,jsx(ChevronDown,{size:M,className:P??"text-blue-500"})]})}),jsx(l.Portal,{children:jsxs(l.Content,{sideOffset:6,align:"start",children:[jsx(Ne,{years:ne,activeYear:C,labelFromYear:a=>w?a+543:a,onSelect:ie}),jsx(l.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(K(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:"rounded-md p-2 text-black/70 hover:bg-black/5",onClick:()=>k(K(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:"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"?H:z).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:se.map((a,b)=>{let h=a.getMonth()===x,v=n&&a<new Date(n.getFullYear(),n.getMonth(),n.getDate())||u&&a>new Date(u.getFullYear(),u.getMonth(),u.getDate()),f=G(a,g),de=G(a,new Date);return jsx(fe,{d:a,inMonth:h,disabled:!!v,selected:f,isToday:de,onPick:re,dayClassName:W,outsideDayClassName:U,selectedDayClassName:q,todayClassName:$},b)})}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]})]})}),Ce=s.memo(ke);export{Ce as default};
@@ -10,6 +10,8 @@ interface ConfirmOptions {
10
10
  cancelVariant?: ButtonVariant;
11
11
  confirmClassName?: string;
12
12
  cancelClassName?: string;
13
+ icon?: ReactNode;
14
+ iconClassName?: string;
13
15
  }
14
16
  interface ConfirmContextType {
15
17
  confirm: (options?: ConfirmOptions) => Promise<boolean>;
@@ -1,4 +1,4 @@
1
- import {a}from'../chunk-SDCZDRHR.js';import {createContext,useState,useCallback,useContext}from'react';import {jsxs,jsx}from'react/jsx-runtime';var c=createContext(void 0),l={primary:"bg-blue-600 hover:bg-blue-700 text-white",danger:"bg-[#FF382D] hover:bg-red-600 text-white",success:"bg-green-600 hover:bg-green-700 text-white",warning:"bg-yellow-500 hover:bg-yellow-600 text-white",secondary:"bg-gray-600 hover:bg-gray-700 text-white",ghost:"bg-transparent hover:bg-gray-100 text-gray-700 border border-gray-300"},b=({children:r})=>{let[t,a$1]=useState({isOpen:false,title:"\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19",message:"\u0E04\u0E38\u0E13\u0E41\u0E19\u0E48\u0E43\u0E08\u0E27\u0E48\u0E32\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48",confirmText:"\u0E43\u0E0A\u0E48 \u0E22\u0E37\u0E19\u0E22\u0E31\u0E19",cancelText:"\u0E44\u0E21\u0E48 \u0E22\u0E01\u0E40\u0E25\u0E34\u0E01",confirmVariant:"danger",cancelVariant:"ghost",resolve:()=>{}}),m=useCallback(e=>new Promise(g=>{a$1({isOpen:true,title:e?.title||"\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19",message:e?.message||"\u0E04\u0E38\u0E13\u0E41\u0E19\u0E48\u0E43\u0E08\u0E27\u0E48\u0E32\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48",confirmText:e?.confirmText||"\u0E43\u0E0A\u0E48 \u0E22\u0E37\u0E19\u0E22\u0E31\u0E19",cancelText:e?.cancelText||"\u0E44\u0E21\u0E48 \u0E22\u0E01\u0E40\u0E25\u0E34\u0E01",confirmVariant:e?.confirmVariant||"danger",cancelVariant:e?.cancelVariant||"ghost",confirmClassName:e?.confirmClassName,cancelClassName:e?.cancelClassName,resolve:g});}),[]),f=()=>{t.resolve(true),a$1(e=>({...e,isOpen:false}));},d=()=>{t.resolve(false),a$1(e=>({...e,isOpen:false}));},i=()=>{t.resolve(false),a$1(e=>({...e,isOpen:false}));};return jsxs(c.Provider,{value:{confirm:m},children:[r,t.isOpen&&jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-20 px-4",children:[jsx("div",{className:"fixed inset-0 bg-black/50",onClick:i}),jsxs("div",{className:"relative bg-white rounded-3xl shadow-2xl max-w-md w-full py-9 px-10 animate-slide-down",children:[jsx("button",{onClick:i,className:"absolute top-4 right-4 text-[#C9D7E3] hover:text-gray-600 transition-colors cursor-pointer","aria-label":"\u0E1B\u0E34\u0E14",children:jsx(a,{fontSize:14})}),jsx("h2",{className:"text-2xl font-semibold text-center text-gray-900 mb-4",children:t.title}),jsx("p",{className:"text-center text-gray-600 mb-8 leading-relaxed",children:t.message}),jsxs("div",{className:"flex gap-4",children:[jsx("button",{onClick:d,className:`flex-1 px-6 py-3.5 font-medium rounded-lg transition-colors ${t.cancelClassName||l[t.cancelVariant||"ghost"]}`,children:t.cancelText}),jsx("button",{onClick:f,className:`flex-1 px-6 py-3.5 font-medium rounded-lg transition-colors ${t.confirmClassName||l[t.confirmVariant||"danger"]}`,children:t.confirmText})]})]})]}),jsx("style",{children:`
1
+ import {a}from'../chunk-SDCZDRHR.js';import {createContext,useState,useCallback,useContext}from'react';import {jsxs,jsx}from'react/jsx-runtime';var c=createContext(void 0),l={primary:"bg-blue-600 hover:bg-blue-700 text-white",danger:"bg-[#FF382D] hover:bg-red-600 text-white",success:"bg-green-600 hover:bg-green-700 text-white",warning:"bg-yellow-500 hover:bg-yellow-600 text-white",secondary:"bg-gray-600 hover:bg-gray-700 text-white",ghost:"bg-transparent hover:bg-gray-100 text-gray-700 border border-gray-300"},b=({children:r})=>{let[t,o]=useState({isOpen:false,title:"\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19",message:"\u0E04\u0E38\u0E13\u0E41\u0E19\u0E48\u0E43\u0E08\u0E27\u0E48\u0E32\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48",confirmText:"\u0E43\u0E0A\u0E48 \u0E22\u0E37\u0E19\u0E22\u0E31\u0E19",cancelText:"\u0E44\u0E21\u0E48 \u0E22\u0E01\u0E40\u0E25\u0E34\u0E01",confirmVariant:"danger",cancelVariant:"ghost",resolve:()=>{}}),m=useCallback(e=>new Promise(x=>{o({isOpen:true,title:e?.title||"\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19",message:e?.message||"\u0E04\u0E38\u0E13\u0E41\u0E19\u0E48\u0E43\u0E08\u0E27\u0E48\u0E32\u0E15\u0E49\u0E2D\u0E07\u0E01\u0E32\u0E23\u0E22\u0E37\u0E19\u0E22\u0E31\u0E19\u0E2B\u0E23\u0E37\u0E2D\u0E44\u0E21\u0E48",confirmText:e?.confirmText||"\u0E43\u0E0A\u0E48 \u0E22\u0E37\u0E19\u0E22\u0E31\u0E19",cancelText:e?.cancelText||"\u0E44\u0E21\u0E48 \u0E22\u0E01\u0E40\u0E25\u0E34\u0E01",confirmVariant:e?.confirmVariant||"danger",cancelVariant:e?.cancelVariant||"ghost",confirmClassName:e?.confirmClassName,cancelClassName:e?.cancelClassName,icon:e?.icon,iconClassName:e?.iconClassName,resolve:x});}),[]),f=()=>{t.resolve(true),o(e=>({...e,isOpen:false}));},d=()=>{t.resolve(false),o(e=>({...e,isOpen:false}));},i=()=>{t.resolve(false),o(e=>({...e,isOpen:false}));};return jsxs(c.Provider,{value:{confirm:m},children:[r,t.isOpen&&jsxs("div",{className:"fixed inset-0 z-50 grid place-items-center pt-20 px-4",children:[jsx("div",{className:"fixed inset-0 bg-black/50",onClick:i}),jsxs("div",{className:"relative bg-white rounded-3xl shadow-2xl max-w-md w-full py-9 px-10 animate-slide-down",children:[jsx("button",{onClick:i,className:"absolute top-4 right-4 text-[#C9D7E3] hover:text-gray-600 transition-colors cursor-pointer","aria-label":"\u0E1B\u0E34\u0E14",children:jsx(a,{fontSize:14})}),t.icon&&jsx("div",{className:`flex justify-center mb-4 ${t.iconClassName||""}`,children:t.icon}),jsxs("div",{className:"space-y-1",children:[jsx("h2",{className:"text-2xl font-semibold text-center text-black",children:t.title}),jsx("p",{className:"text-center text-gray-600 mb-6 leading-relaxed text-[16px]",children:t.message})]}),jsxs("div",{className:"flex gap-6",children:[jsx("button",{onClick:d,className:`flex-1 px-6 h-[42px] font-medium rounded-lg transition-colors ${t.cancelClassName||l[t.cancelVariant||"ghost"]}`,children:t.cancelText}),jsx("button",{onClick:f,className:`flex-1 px-6 h-[42px] font-medium rounded-lg transition-colors ${t.confirmClassName||l[t.confirmVariant||"danger"]}`,children:t.confirmText})]})]})]}),jsx("style",{children:`
2
2
  @keyframes slide-down {
3
3
  from {
4
4
  opacity: 0;
@@ -12,4 +12,4 @@ import {a}from'../chunk-SDCZDRHR.js';import {createContext,useState,useCallback,
12
12
  .animate-slide-down {
13
13
  animation: slide-down 0.3s ease-out;
14
14
  }
15
- `})]})},y=()=>{let r=useContext(c);if(!r)throw new Error("useConfirm must be used within a ConfirmProvider");return r};export{b as ConfirmProvider,y as useConfirm};
15
+ `})]})},v=()=>{let r=useContext(c);if(!r)throw new Error("useConfirm must be used within a ConfirmProvider");return r};export{b as ConfirmProvider,v as useConfirm};
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-32LB6SHS.js';import'../chunk-KYNNMWQA.js';import'../chunk-HR6IGUYJ.js';import'../chunk-QRYSV225.js';import'../chunk-IX36POX2.js';import'../chunk-FK7R34ZH.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var w=(t,r)=>r==="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},x=async t=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/district.json")).json()).filter(c=>c.province_id===t),y=({searchLabel:t="Search",locale:r="th",searchPlaceholder:o="Search District",placeholder:l="Select District",label:c,searchButtonClassName:D="bg-blue-500",onChange:d,value:n,required:g=false,provinceId:a$1,error:b})=>{let[s,_]=useState([]),[S,u]=useState(null);useEffect(()=>{a$1&&x(a$1).then(_);},[a$1]),useEffect(()=>{if(n){let e=s.find(i=>r==="th"?i.name_th===n:i.name_en===n);e&&u(e);}},[s,n,r]);let v=useCallback(e=>{let i=s.find(C=>C.id===e);i&&(u(i),d?.(i));},[s,d]);return jsx("div",{children:jsx(a,{items:s.map(e=>w(e,r)),placeholder:o,triggerPlaceholder:l,label:c,selectionMode:"single",searchButtonClassName:D,onChange:e=>{v(e);},searchButtonLabel:t,value:S?.id,required:g,disabled:!a$1,errorMessage:b})})},B=y;
1
+ import {a}from'../chunk-FWCSTLF4.js';import'../chunk-KYNNMWQA.js';import'../chunk-2CWZ4OAO.js';import'../chunk-QRYSV225.js';import'../chunk-IX36POX2.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var w=(t,r)=>r==="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},x=async t=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/district.json")).json()).filter(c=>c.province_id===t),y=({searchLabel:t="Search",locale:r="th",searchPlaceholder:o="Search District",placeholder:l="Select District",label:c,searchButtonClassName:D="bg-blue-500",onChange:d,value:n,required:g=false,provinceId:a$1,error:b})=>{let[s,_]=useState([]),[S,u]=useState(null);useEffect(()=>{a$1&&x(a$1).then(_);},[a$1]),useEffect(()=>{if(n){let e=s.find(i=>r==="th"?i.name_th===n:i.name_en===n);e&&u(e);}},[s,n,r]);let v=useCallback(e=>{let i=s.find(C=>C.id===e);i&&(u(i),d?.(i));},[s,d]);return jsx("div",{children:jsx(a,{items:s.map(e=>w(e,r)),placeholder:o,triggerPlaceholder:l,label:c,selectionMode:"single",searchButtonClassName:D,onChange:e=>{v(e);},searchButtonLabel:t,value:S?.id,required:g,disabled:!a$1,errorMessage:b})})},B=y;
2
2
  export{B as default};
@@ -1,2 +1,2 @@
1
- import {a as a$2}from'../chunk-QRYSV225.js';import {a as a$1}from'../chunk-FK7R34ZH.js';import {a}from'../chunk-6GLPXMGB.js';import {forwardRef,memo,useState,useRef}from'react';import {jsxs,jsx}from'react/jsx-runtime';import {cva}from'class-variance-authority';var K=({title:l,titleId:o,...i},g)=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em",ref:g,"aria-labelledby":o,...i,children:[l?jsx("title",{id:o,children:l}):null,jsx("path",{fill:"currentColor",d:"M0 13.687c0-.36.325-.653.727-.653s.727.293.727.653v.84c.195.107.423.167.66.167h11.771c.238 0 .466-.06.66-.167v-.84c0-.36.326-.653.728-.653s.727.293.727.653v1.156c0 .176-.08.345-.22.467a2.88 2.88 0 0 1-1.895.69H2.115c-.708 0-1.39-.246-1.896-.69A.62.62 0 0 1 0 14.843zm7.274-3.285V2.146L4.01 4.857a.786.786 0 0 1-1.027-.035.608.608 0 0 1 .04-.924L7.507.174l.111-.077a.79.79 0 0 1 .877.077l4.484 3.724a.608.608 0 0 1 .04.924.786.786 0 0 1-1.027.035l-3.264-2.71v8.255c0 .36-.325.653-.727.653s-.727-.292-.727-.653"})]}),Q=forwardRef(K),W=memo(Q),L=W;var Y=cva("w-full space-y-2",{variants:{size:{sm:"",md:"",lg:""}},defaultVariants:{size:"md"}}),Z=cva("relative overflow-hidden flex-shrink-0 transition-all duration-200 ",{variants:{size:{sm:"w-20 h-20 rounded-lg",md:"w-30 h-30 rounded-xl",lg:"w-40 h-40 rounded-2xl"},state:{default:"bg-blue-50 border-2 border-blue-100",dragging:"bg-blue-50 border-2 border-blue-100 ring-2 ring-blue-400 ring-offset-2",error:"bg-red-50 border-2 border-red-200",disabled:"bg-gray-50 border-2 border-gray-200 opacity-50 cursor-not-allowed"},cursor:{pointer:"cursor-pointer",notAllowed:"cursor-not-allowed"}},defaultVariants:{size:"md",state:"default",cursor:"pointer"}}),_=cva("inline-flex items-center gap-2 font-medium border-2 transition-colors duration-200",{variants:{size:{sm:"py-1 px-2 text-sm rounded-md",md:"py-1 px-3 text-base rounded-lg",lg:"py-1 px-4 text-lg rounded-xl"},variant:{default:"text-blue-600 border-blue-600 hover:bg-blue-50 active:bg-blue-100",outline:"text-gray-700 border-gray-300 hover:bg-gray-50 active:bg-gray-100",ghost:"text-blue-600 border-transparent hover:bg-blue-50 active:bg-blue-100"},state:{default:"",disabled:"cursor-not-allowed opacity-50"}},defaultVariants:{size:"md",variant:"default",state:"default"}}),$=cva("",{variants:{size:{sm:"w-16 h-16",md:"w-32 h-32",lg:"w-40 h-40"}},defaultVariants:{size:"md"}}),ee=({src:l,defaultSrc:o,label:i,uploadButtonText:g="\u0E2D\u0E31\u0E1B\u0E42\u0E2B\u0E25\u0E14\u0E23\u0E39\u0E1B\u0E20\u0E32\u0E1E",acceptedFormatsText:N,error:p,accept:b="image/jpeg,image/jpg,image/png",onChange:f,maxSizeMB:P=5,disabled:r=false,className:R,required:C=false,size:s="md",buttonVariant:F="default",buttonClassName:B})=>{let[I,M]=useState(null),[S,m]=useState(false),h=useRef(null),x=l||I||o,T=e=>{let a=e.target.files?.[0];w(a);},w=e=>{if(!e)return;let a=b.split(",").map(d=>d.trim()),q=e.type;if(!a.includes(q)){f?.(null,null);return}if(e.size/(1024*1024)>P){f?.(null,null);return}let v=new FileReader;v.onloadend=()=>{let d=v.result;M(d),f?.(e,d);},v.readAsDataURL(e);},y=()=>{h.current?.click();},U=e=>{e.preventDefault(),e.stopPropagation(),r||m(true);},j=e=>{e.preventDefault(),e.stopPropagation(),m(false);},k=e=>{e.preventDefault(),e.stopPropagation();},A=e=>{if(e.preventDefault(),e.stopPropagation(),m(false),r)return;let a=e.dataTransfer.files?.[0];w(a);},H=()=>r?"disabled":S?"dragging":p?"error":"default";return jsxs("div",{className:a(Y({size:s}),R),children:[i&&jsx(a$1,{label:i,required:C}),jsxs("div",{className:"flex items-center gap-4",children:[jsxs("div",{className:a(Z({size:s,state:H(),cursor:r?"notAllowed":"pointer"})),onDragEnter:U,onDragOver:k,onDragLeave:j,onDrop:A,onClick:r?void 0:y,children:[jsx("input",{ref:h,type:"file",accept:b,onChange:T,className:"hidden",disabled:r}),jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:x?jsx("img",{src:x,alt:"Preview",className:"w-full h-full object-cover"}):jsx("svg",{className:a($({size:s}),"text-blue-200"),fill:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})})]}),jsx("div",{children:jsxs("button",{type:"button",onClick:y,disabled:r,className:a(_({size:s,variant:F,state:r?"disabled":"default"}),"mt-2",B),children:[jsx(L,{fontSize:14}),g]})})]}),jsx("p",{className:"text-sm text-gray-500",children:N}),p&&jsx(a$2,{message:p})]})},te=ee;
1
+ import {a as a$2}from'../chunk-QRYSV225.js';import {a as a$1}from'../chunk-THE2HQGT.js';import {a}from'../chunk-6GLPXMGB.js';import {forwardRef,memo,useState,useRef}from'react';import {jsxs,jsx}from'react/jsx-runtime';import {cva}from'class-variance-authority';var K=({title:l,titleId:o,...i},g)=>jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em",ref:g,"aria-labelledby":o,...i,children:[l?jsx("title",{id:o,children:l}):null,jsx("path",{fill:"currentColor",d:"M0 13.687c0-.36.325-.653.727-.653s.727.293.727.653v.84c.195.107.423.167.66.167h11.771c.238 0 .466-.06.66-.167v-.84c0-.36.326-.653.728-.653s.727.293.727.653v1.156c0 .176-.08.345-.22.467a2.88 2.88 0 0 1-1.895.69H2.115c-.708 0-1.39-.246-1.896-.69A.62.62 0 0 1 0 14.843zm7.274-3.285V2.146L4.01 4.857a.786.786 0 0 1-1.027-.035.608.608 0 0 1 .04-.924L7.507.174l.111-.077a.79.79 0 0 1 .877.077l4.484 3.724a.608.608 0 0 1 .04.924.786.786 0 0 1-1.027.035l-3.264-2.71v8.255c0 .36-.325.653-.727.653s-.727-.292-.727-.653"})]}),Q=forwardRef(K),W=memo(Q),L=W;var Y=cva("w-full space-y-2",{variants:{size:{sm:"",md:"",lg:""}},defaultVariants:{size:"md"}}),Z=cva("relative overflow-hidden flex-shrink-0 transition-all duration-200 ",{variants:{size:{sm:"w-20 h-20 rounded-lg",md:"w-30 h-30 rounded-xl",lg:"w-40 h-40 rounded-2xl"},state:{default:"bg-blue-50 border-2 border-blue-100",dragging:"bg-blue-50 border-2 border-blue-100 ring-2 ring-blue-400 ring-offset-2",error:"bg-red-50 border-2 border-red-200",disabled:"bg-gray-50 border-2 border-gray-200 opacity-50 cursor-not-allowed"},cursor:{pointer:"cursor-pointer",notAllowed:"cursor-not-allowed"}},defaultVariants:{size:"md",state:"default",cursor:"pointer"}}),_=cva("inline-flex items-center gap-2 font-medium border-2 transition-colors duration-200",{variants:{size:{sm:"py-1 px-2 text-sm rounded-md",md:"py-1 px-3 text-base rounded-lg",lg:"py-1 px-4 text-lg rounded-xl"},variant:{default:"text-blue-600 border-blue-600 hover:bg-blue-50 active:bg-blue-100",outline:"text-gray-700 border-gray-300 hover:bg-gray-50 active:bg-gray-100",ghost:"text-blue-600 border-transparent hover:bg-blue-50 active:bg-blue-100"},state:{default:"",disabled:"cursor-not-allowed opacity-50"}},defaultVariants:{size:"md",variant:"default",state:"default"}}),$=cva("",{variants:{size:{sm:"w-16 h-16",md:"w-32 h-32",lg:"w-40 h-40"}},defaultVariants:{size:"md"}}),ee=({src:l,defaultSrc:o,label:i,uploadButtonText:g="\u0E2D\u0E31\u0E1B\u0E42\u0E2B\u0E25\u0E14\u0E23\u0E39\u0E1B\u0E20\u0E32\u0E1E",acceptedFormatsText:N,error:p,accept:b="image/jpeg,image/jpg,image/png",onChange:f,maxSizeMB:P=5,disabled:r=false,className:R,required:C=false,size:s="md",buttonVariant:F="default",buttonClassName:B})=>{let[I,M]=useState(null),[S,m]=useState(false),h=useRef(null),x=l||I||o,T=e=>{let a=e.target.files?.[0];w(a);},w=e=>{if(!e)return;let a=b.split(",").map(d=>d.trim()),q=e.type;if(!a.includes(q)){f?.(null,null);return}if(e.size/(1024*1024)>P){f?.(null,null);return}let v=new FileReader;v.onloadend=()=>{let d=v.result;M(d),f?.(e,d);},v.readAsDataURL(e);},y=()=>{h.current?.click();},U=e=>{e.preventDefault(),e.stopPropagation(),r||m(true);},j=e=>{e.preventDefault(),e.stopPropagation(),m(false);},k=e=>{e.preventDefault(),e.stopPropagation();},A=e=>{if(e.preventDefault(),e.stopPropagation(),m(false),r)return;let a=e.dataTransfer.files?.[0];w(a);},H=()=>r?"disabled":S?"dragging":p?"error":"default";return jsxs("div",{className:a(Y({size:s}),R),children:[i&&jsx(a$1,{label:i,required:C}),jsxs("div",{className:"flex items-center gap-4",children:[jsxs("div",{className:a(Z({size:s,state:H(),cursor:r?"notAllowed":"pointer"})),onDragEnter:U,onDragOver:k,onDragLeave:j,onDrop:A,onClick:r?void 0:y,children:[jsx("input",{ref:h,type:"file",accept:b,onChange:T,className:"hidden",disabled:r}),jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:x?jsx("img",{src:x,alt:"Preview",className:"w-full h-full object-cover"}):jsx("svg",{className:a($({size:s}),"text-blue-200"),fill:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})})]}),jsx("div",{children:jsxs("button",{type:"button",onClick:y,disabled:r,className:a(_({size:s,variant:F,state:r?"disabled":"default"}),"mt-2",B),children:[jsx(L,{fontSize:14}),g]})})]}),jsx("p",{className:"text-sm text-gray-500",children:N}),p&&jsx(a$2,{message:p})]})},te=ee;
2
2
  export{ee as FileUpload,te as default};
@@ -0,0 +1,31 @@
1
+ import React__default from 'react';
2
+
3
+ interface ImagePreviewModalProps {
4
+ /**
5
+ * Image URL to display
6
+ */
7
+ imageUrl: string;
8
+ /**
9
+ * Alt text for the image
10
+ */
11
+ alt?: string;
12
+ /**
13
+ * Whether the modal is open
14
+ */
15
+ isOpen: boolean;
16
+ /**
17
+ * Callback when modal should close
18
+ */
19
+ onClose: () => void;
20
+ /**
21
+ * Custom className for the image
22
+ */
23
+ imageClassName?: string;
24
+ /**
25
+ * Custom className for the backdrop
26
+ */
27
+ backdropClassName?: string;
28
+ }
29
+ declare const ImagePreviewModal: React__default.FC<ImagePreviewModalProps>;
30
+
31
+ export { type ImagePreviewModalProps, ImagePreviewModal as default };
@@ -0,0 +1 @@
1
+ import {useEffect}from'react';import {createPortal}from'react-dom';import {jsx}from'react/jsx-runtime';var f=({imageUrl:a,alt:n="Preview",isOpen:e,onClose:o,imageClassName:i,backdropClassName:l})=>{if(useEffect(()=>{let t=s=>{s.key==="Escape"&&e&&o();};return e&&(document.addEventListener("keydown",t),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",t),document.body.style.overflow="unset";}},[e,o]),!e)return null;let d=jsx("div",{className:`fixed inset-0 z-50 flex items-center justify-center p-4 ${l||"bg-black/90"}`,onClick:o,children:jsx("img",{src:a,alt:n,className:i||"max-w-full max-h-full object-contain cursor-pointer",onClick:t=>{t.stopPropagation();}})});return createPortal(d,document.body)},u=f;export{u as default};
@@ -4,6 +4,7 @@ type LabelInputProps = {
4
4
  required?: boolean;
5
5
  label: string;
6
6
  id?: string;
7
+ labelClassName?: string;
7
8
  };
8
9
  declare const LabelInput: React.ForwardRefExoticComponent<LabelInputProps & React.RefAttributes<HTMLDivElement>>;
9
10
 
@@ -1 +1 @@
1
- export{a as default}from'../chunk-FK7R34ZH.js';
1
+ export{a as default}from'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';
@@ -1 +1,15 @@
1
- import {a}from'../chunk-6GLPXMGB.js';import*as t from'react';import {createPortal}from'react-dom';import {jsx,jsxs}from'react/jsx-runtime';function P(n="ui-portal"){let[a,r]=t.useState(null);return t.useLayoutEffect(()=>{let e=document.getElementById(n);return e||(e=document.createElement("div"),e.id=n,document.body.appendChild(e)),r(e),()=>{e&&e.childElementCount===0&&e.remove();}},[n]),a}function D({open:n,onClose:a$1,icon:r,title:e,description:s,footer:m,wrapperClassName:N,contentClassName:M,showCloseX:L=false,closeOnEsc:f=true,closeOnOverlayClick:v=true,initialFocusRef:p,children:b}){let y=P(),i=t.useRef(null),R=t.useRef(null),C=t.useCallback(()=>{v&&a$1?.();},[v,a$1]);return t.useEffect(()=>{if(!n)return;R.current=document.activeElement??null;let u=document.body.style.overflow;document.body.style.overflow="hidden";let H=p?.current||i.current;requestAnimationFrame(()=>H?.focus());let h=l=>{if(l.key==="Escape"&&f&&(l.stopPropagation(),a$1?.()),l.key==="Tab"){let x=i.current;if(!x)return;let c=x.querySelectorAll('a[href],button,textarea,input,select,[tabindex]:not([tabindex="-1"])');if(!c.length)return;let g=c[0],E=c[c.length-1],k=document.activeElement;l.shiftKey&&k===g?(l.preventDefault(),E.focus()):!l.shiftKey&&k===E&&(l.preventDefault(),g.focus());}};return document.addEventListener("keydown",h),()=>{document.body.style.overflow=u,document.removeEventListener("keydown",h),R.current?.focus?.();}},[n,f,a$1,p]),!n||!y?null:createPortal(jsx("div",{className:a("fixed inset-0 z-[1000] grid place-items-center p-4 bg-black/60",N),onMouseDown:C,"aria-live":"polite",children:jsxs("div",{role:"dialog","aria-modal":"true",ref:i,tabIndex:-1,onMouseDown:u=>u.stopPropagation(),className:a("relative w-full max-w-[480px] rounded-2xl bg-white shadow-xl outline-none px-6 py-6",M),children:[L&&jsx("button",{"aria-label":"Close",onClick:a$1,className:"absolute right-3 top-3 grid h-8 w-8 place-items-center rounded-full text-black/60 hover:bg-black/5 focus-visible:ring-2 ring-black/20",children:jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":true,children:jsx("path",{d:"M6 6l12 12M18 6L6 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}),(r||e||s)&&jsxs("div",{className:"text-center",children:[r&&jsx("div",{className:"mb-4 flex justify-center",children:r}),e&&jsx("h2",{className:"text-xl font-semibold text-black",children:e}),s&&jsx("p",{className:"mt-2 text-black/70",children:s})]}),b&&jsx("div",{className:"mt-4",children:b}),m&&jsx("div",{className:"mt-6 flex items-center justify-center gap-3",children:m})]})}),y)}var A=D;export{A as default};
1
+ import {a as a$1}from'../chunk-SDCZDRHR.js';import {a}from'../chunk-6GLPXMGB.js';import*as t from'react';import {createPortal}from'react-dom';import {jsxs,jsx}from'react/jsx-runtime';function P(n="ui-portal"){let[a,r]=t.useState(null);return t.useLayoutEffect(()=>{let e=document.getElementById(n);return e||(e=document.createElement("div"),e.id=n,document.body.appendChild(e)),r(e),()=>{e&&e.childElementCount===0&&e.remove();}},[n]),a}function A({open:n,onClose:a$2,icon:r,title:e,description:c,footer:f,wrapperClassName:k,contentClassName:L,showCloseX:C=false,closeOnEsc:p=true,closeOnOverlayClick:v=true,initialFocusRef:y,children:b}){let x=P(),i=t.useRef(null),R=t.useRef(null),H=t.useCallback(()=>{v&&a$2?.();},[v,a$2]);return t.useEffect(()=>{if(!n)return;R.current=document.activeElement??null;let u=document.body.style.overflow;document.body.style.overflow="hidden";let T=y?.current||i.current;requestAnimationFrame(()=>T?.focus());let E=l=>{if(l.key==="Escape"&&p&&(l.stopPropagation(),a$2?.()),l.key==="Tab"){let w=i.current;if(!w)return;let s=w.querySelectorAll('a[href],button,textarea,input,select,[tabindex]:not([tabindex="-1"])');if(!s.length)return;let h=s[0],N=s[s.length-1],g=document.activeElement;l.shiftKey&&g===h?(l.preventDefault(),N.focus()):!l.shiftKey&&g===N&&(l.preventDefault(),h.focus());}};return document.addEventListener("keydown",E),()=>{document.body.style.overflow=u,document.removeEventListener("keydown",E),R.current?.focus?.();}},[n,p,a$2,y]),!n||!x?null:createPortal(jsxs("div",{className:a("fixed inset-0 z-[1000] grid place-items-center p-4 bg-black/50",k),onMouseDown:H,"aria-live":"polite",children:[jsxs("div",{role:"dialog","aria-modal":"true",ref:i,tabIndex:-1,onMouseDown:u=>u.stopPropagation(),className:a("relative w-full max-w-[480px] rounded-2xl bg-white shadow-xl outline-none px-6 py-6 animate-slide-down",L),children:[C&&jsx("button",{"aria-label":"Close",onClick:a$2,className:"absolute right-3 top-3 grid h-8 w-8 place-items-center rounded-full text-[#C9D7E3] hover:text-gray-600 transition-colors cursor-pointer",children:jsx(a$1,{fontSize:14})}),(r||e||c)&&jsxs("div",{className:"text-center",children:[r&&jsx("div",{className:"mb-4 flex justify-center",children:r}),e&&jsx("h2",{className:"text-xl font-semibold text-black",children:e}),c&&jsx("p",{className:"mt-2 text-black/70",children:c})]}),b&&jsx("div",{className:"mt-4",children:b}),f&&jsx("div",{className:"mt-6 flex items-center justify-center gap-3",children:f})]}),jsx("style",{children:`
2
+ @keyframes slide-down {
3
+ from {
4
+ opacity: 0;
5
+ transform: translateY(-20px);
6
+ }
7
+ to {
8
+ opacity: 1;
9
+ transform: translateY(0);
10
+ }
11
+ }
12
+ .animate-slide-down {
13
+ animation: slide-down 0.3s ease-out;
14
+ }
15
+ `})]}),x)}var K=A;export{K as default};
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-32LB6SHS.js';import'../chunk-KYNNMWQA.js';import'../chunk-HR6IGUYJ.js';import'../chunk-QRYSV225.js';import'../chunk-IX36POX2.js';import'../chunk-FK7R34ZH.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var x=(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},y=async()=>await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province.json")).json(),B=({searchLabel:e="Search",disabled:o,locale:s="th",searchPlaceholder:P="Search Province",placeholder:v="Select Province",label:m,searchButtonClassName:g="bg-blue-500",onChange:i,value:a$1,required:f=false,error:p})=>{let[t,b]=useState([]),[_,c]=useState(null);useEffect(()=>{y().then(b);},[]),useEffect(()=>{if(a$1){let r=t.find(n=>s==="th"?n.name_th===a$1:n.name_en===a$1);r&&c(r);}},[t,a$1,s]);let S=useCallback(r=>{let n=t.find(C=>C.id===r);n&&(c(n),i?.(n));},[t,i]);return jsx("div",{children:jsx(a,{items:t.map(r=>x(r,s)),placeholder:P,triggerPlaceholder:v,label:m,selectionMode:"single",searchButtonClassName:g,onChange:r=>{S(r);},searchButtonLabel:e,value:_?.id,required:f,disabled:o,errorMessage:p})})},k=B;
1
+ import {a}from'../chunk-FWCSTLF4.js';import'../chunk-KYNNMWQA.js';import'../chunk-2CWZ4OAO.js';import'../chunk-QRYSV225.js';import'../chunk-IX36POX2.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var x=(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},y=async()=>await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province.json")).json(),B=({searchLabel:e="Search",disabled:o,locale:s="th",searchPlaceholder:P="Search Province",placeholder:v="Select Province",label:m,searchButtonClassName:g="bg-blue-500",onChange:i,value:a$1,required:f=false,error:p})=>{let[t,b]=useState([]),[_,c]=useState(null);useEffect(()=>{y().then(b);},[]),useEffect(()=>{if(a$1){let r=t.find(n=>s==="th"?n.name_th===a$1:n.name_en===a$1);r&&c(r);}},[t,a$1,s]);let S=useCallback(r=>{let n=t.find(C=>C.id===r);n&&(c(n),i?.(n));},[t,i]);return jsx("div",{children:jsx(a,{items:t.map(r=>x(r,s)),placeholder:P,triggerPlaceholder:v,label:m,selectionMode:"single",searchButtonClassName:g,onChange:r=>{S(r);},searchButtonLabel:e,value:_?.id,required:f,disabled:o,errorMessage:p})})},k=B;
2
2
  export{k as default};
@@ -1 +1 @@
1
- import {a as a$1}from'../chunk-P7O33B4C.js';import {a as a$2}from'../chunk-QRYSV225.js';import {a}from'../chunk-FK7R34ZH.js';import'../chunk-6GLPXMGB.js';import {memo,useCallback}from'react';import {jsxs,jsx}from'react/jsx-runtime';function p(...r){return r.filter(Boolean).join(" ")}var u=memo(({name:r,options:m,value:f,onChange:o,size:c="md",direction:g="vertical",error:i,label:l,required:t=false,className:v="",disabled:b=false,radioClassName:R})=>{let x=useCallback(e=>{o&&o(e.target.value);},[o]);return jsxs("div",{className:p("flex flex-col gap-2",v),children:[l&&jsx(a,{label:l,required:t}),jsx("div",{className:p("flex gap-4",g==="vertical"?"flex-col":"flex-row flex-wrap"),role:"radiogroup","aria-label":l,"aria-required":t,children:m.map(e=>jsx(a$1,{name:r,label:e.label,value:e.value,description:e.description,checked:f===e.value,disabled:b||e.disabled,onChange:x,size:c,radioClassName:R,error:!!i},e.value))}),i&&jsx(a$2,{message:i})]})});u.displayName="RadioGroup";var C=u;export{C as default};
1
+ import {a as a$1}from'../chunk-P7O33B4C.js';import {a as a$2}from'../chunk-QRYSV225.js';import {a}from'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {memo,useCallback}from'react';import {jsxs,jsx}from'react/jsx-runtime';function p(...r){return r.filter(Boolean).join(" ")}var u=memo(({name:r,options:m,value:f,onChange:o,size:c="md",direction:g="vertical",error:i,label:l,required:t=false,className:v="",disabled:b=false,radioClassName:R})=>{let x=useCallback(e=>{o&&o(e.target.value);},[o]);return jsxs("div",{className:p("flex flex-col gap-2",v),children:[l&&jsx(a,{label:l,required:t}),jsx("div",{className:p("flex gap-4",g==="vertical"?"flex-col":"flex-row flex-wrap"),role:"radiogroup","aria-label":l,"aria-required":t,children:m.map(e=>jsx(a$1,{name:r,label:e.label,value:e.value,description:e.description,checked:f===e.value,disabled:b||e.disabled,onChange:x,size:c,radioClassName:R,error:!!i},e.value))}),i&&jsx(a$2,{message:i})]})});u.displayName="RadioGroup";var C=u;export{C as default};
@@ -1 +1 @@
1
- export{a as default}from'../chunk-32LB6SHS.js';import'../chunk-KYNNMWQA.js';import'../chunk-HR6IGUYJ.js';import'../chunk-QRYSV225.js';import'../chunk-IX36POX2.js';import'../chunk-FK7R34ZH.js';import'../chunk-6GLPXMGB.js';
1
+ export{a as default}from'../chunk-FWCSTLF4.js';import'../chunk-KYNNMWQA.js';import'../chunk-2CWZ4OAO.js';import'../chunk-QRYSV225.js';import'../chunk-IX36POX2.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';
@@ -1 +1 @@
1
- import {a as a$3}from'../chunk-KYNNMWQA.js';import {a as a$2}from'../chunk-HR6IGUYJ.js';import'../chunk-QRYSV225.js';import {a as a$4}from'../chunk-IX36POX2.js';import {a}from'../chunk-FK7R34ZH.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import*as r from'react';import*as n from'@radix-ui/react-popover';import {Check}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';var He=a=>i=>{a(typeof i=="string"?i:i[0]||"");},Qe=a=>i=>{a(Array.isArray(i)?i:[i]);};function K(a){return typeof a=="string"?{id:a,label:a}:a}var Ie={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 Pe({autoFocus:a$5=false,trigger:i,triggerPlaceholder:M="Choose",items:X,loadOptions:c,selectionMode:y="multiple",value:T,defaultValue:Y,onChange:Z,searchable:A=true,placeholder:O="Placeholder Text",searchButtonLabel:ee="Search",onQueryChange:te,onSearch:re,loading:oe=false,emptyLabel:se="No results",errorLabel:ae="Failed to load options",contentClassName:le,maxHeight:ne=288,renderItem:q,buttonColor:ie="primary",searchButtonColor:ce,searchButtonClassName:de,checkedColor:ue="primary",checkedClassName:me,renderTriggerValue:z,label:H,required:ge,enablePagination:p=false,pageSize:Q=20,errorMessage:R}){let[x,E]=r.useState(false),[b,pe]=r.useState(""),[k,F]=r.useState(""),[V,w]=r.useState([]),[N,D]=r.useState(false),[C,W]=r.useState(null),[be,j]=r.useState(1),[fe,he]=r.useState(true),l=y==="multiple",[xe,ve]=r.useState(Y??(l?[]:"")),s=T??xe,U=c?V:X||[],m=r.useMemo(()=>U.map(K),[U]),S=r.useCallback(async(e,o=1,h=false)=>{if(c){D(true),W(null);try{let B=(await c(e)).map(K);w(h?Ce=>[...Ce,...B]:B),p&&he(B.length===Q);}catch(u){W(u instanceof Error?u.message:"Unknown error"),w([]);}finally{D(false);}}},[c,p,Q]);r.useEffect(()=>{x&&c&&V.length===0&&S("");},[x,c]);let v=r.useMemo(()=>{if(c)return m;let e=k.trim().toLowerCase();return e?m.filter(o=>String(o.label).toLowerCase().includes(e)):m},[m,k,c]),_=e=>{Z?.(e),T===void 0&&ve(e);},ye=e=>{if(l){let o=new Set(s);o.has(e)?o.delete(e):o.add(e),_(Array.from(o));}else _(e),E(false);},Re=e=>l?s.includes(e):s===e,ke=()=>{c?(j(1),S(b,1,false),F(b)):(F(b),re?.(b));},we=()=>{if(!N&&fe&&p){let e=be+1;j(e),S(k,e,true);}},I=r.useMemo(()=>l?s:s?[s]:[],[s,l]),f=r.useMemo(()=>m.filter(e=>I.includes(e.id)),[m,I]),Ne=r.useMemo(()=>f.length===0?M:l?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${f.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:f[0].label,[f,l,M]),P=N||oe;return jsx("fieldset",{children:jsxs(n.Root,{open:x,onOpenChange:E,children:[H&&jsx(a,{label:H,required:ge}),jsx("div",{className:"mb-2"}),jsx(n.Trigger,{asChild:true,children:i??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":l?s?.length===0:!s,"text-black":l?s?.length>0:!!s}),children:z?z(I,f):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(n.Portal,{children:jsxs(n.Content,{sideOffset:8,onOpenAutoFocus:e=>{if(!a$5){e.preventDefault();return}},className:a$1("w-[300px] rounded-md border border-black/10 bg-white p-2 shadow-xl",le),children:[A&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:e=>{e.preventDefault(),ke();},children:[jsx(a$2,{start:jsx(a$3,{}),value:b,onChange:e=>{pe(e.currentTarget.value),te?.(e.currentTarget.value);},size:"sm",placeholder:O}),jsx(a$4,{color:ce??ie,type:"submit",disabled:P,size:"md",className:de,children:ee})]}),jsxs("div",{role:"listbox","aria-multiselectable":l||void 0,className:a$1("overflow-y-auto rounded-md",{"mt-3":A}),style:{maxHeight:ne},onScroll:e=>{if(!p)return;let{scrollTop:o,scrollHeight:h,clientHeight:u}=e.currentTarget;h-o<=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:ae}),!P&&!C&&v.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:se}),!C&&v.map(e=>{let o=Re(e.id),h=Ie[ue],u=jsxs(a$4,{type:"button",role:"option","aria-selected":o,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]":o&&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",o?h:"border-black/20",o&&me),children:o?jsx(Check,{size:14}):null})]},e.id);return q?jsx("div",{children:q(e,false,o)},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(n.Arrow,{className:"fill-white stroke-black/10"})]})})]})})}var Be=Pe;export{Be as default,Qe as handleMultipleChange,He as handleSingleChange};
1
+ import {a as a$3}from'../chunk-KYNNMWQA.js';import {a as a$2}from'../chunk-2CWZ4OAO.js';import'../chunk-QRYSV225.js';import {a as a$4}from'../chunk-IX36POX2.js';import {a}from'../chunk-THE2HQGT.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import*as r from'react';import*as n from'@radix-ui/react-popover';import {Check}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';var He=a=>i=>{a(typeof i=="string"?i:i[0]||"");},Qe=a=>i=>{a(Array.isArray(i)?i:[i]);};function K(a){return typeof a=="string"?{id:a,label:a}:a}var Ie={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 Pe({autoFocus:a$5=false,trigger:i,triggerPlaceholder:M="Choose",items:X,loadOptions:c,selectionMode:y="multiple",value:T,defaultValue:Y,onChange:Z,searchable:A=true,placeholder:O="Placeholder Text",searchButtonLabel:ee="Search",onQueryChange:te,onSearch:re,loading:oe=false,emptyLabel:se="No results",errorLabel:ae="Failed to load options",contentClassName:le,maxHeight:ne=288,renderItem:q,buttonColor:ie="primary",searchButtonColor:ce,searchButtonClassName:de,checkedColor:ue="primary",checkedClassName:me,renderTriggerValue:z,label:H,required:ge,enablePagination:p=false,pageSize:Q=20,errorMessage:R}){let[x,E]=r.useState(false),[b,pe]=r.useState(""),[k,F]=r.useState(""),[V,w]=r.useState([]),[N,D]=r.useState(false),[C,W]=r.useState(null),[be,j]=r.useState(1),[fe,he]=r.useState(true),l=y==="multiple",[xe,ve]=r.useState(Y??(l?[]:"")),s=T??xe,U=c?V:X||[],m=r.useMemo(()=>U.map(K),[U]),S=r.useCallback(async(e,o=1,h=false)=>{if(c){D(true),W(null);try{let B=(await c(e)).map(K);w(h?Ce=>[...Ce,...B]:B),p&&he(B.length===Q);}catch(u){W(u instanceof Error?u.message:"Unknown error"),w([]);}finally{D(false);}}},[c,p,Q]);r.useEffect(()=>{x&&c&&V.length===0&&S("");},[x,c]);let v=r.useMemo(()=>{if(c)return m;let e=k.trim().toLowerCase();return e?m.filter(o=>String(o.label).toLowerCase().includes(e)):m},[m,k,c]),_=e=>{Z?.(e),T===void 0&&ve(e);},ye=e=>{if(l){let o=new Set(s);o.has(e)?o.delete(e):o.add(e),_(Array.from(o));}else _(e),E(false);},Re=e=>l?s.includes(e):s===e,ke=()=>{c?(j(1),S(b,1,false),F(b)):(F(b),re?.(b));},we=()=>{if(!N&&fe&&p){let e=be+1;j(e),S(k,e,true);}},I=r.useMemo(()=>l?s:s?[s]:[],[s,l]),f=r.useMemo(()=>m.filter(e=>I.includes(e.id)),[m,I]),Ne=r.useMemo(()=>f.length===0?M:l?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${f.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:f[0].label,[f,l,M]),P=N||oe;return jsx("fieldset",{children:jsxs(n.Root,{open:x,onOpenChange:E,children:[H&&jsx(a,{label:H,required:ge}),jsx("div",{className:"mb-2"}),jsx(n.Trigger,{asChild:true,children:i??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":l?s?.length===0:!s,"text-black":l?s?.length>0:!!s}),children:z?z(I,f):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(n.Portal,{children:jsxs(n.Content,{sideOffset:8,onOpenAutoFocus:e=>{if(!a$5){e.preventDefault();return}},className:a$1("w-[300px] rounded-md border border-black/10 bg-white p-2 shadow-xl",le),children:[A&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:e=>{e.preventDefault(),ke();},children:[jsx(a$2,{start:jsx(a$3,{}),value:b,onChange:e=>{pe(e.currentTarget.value),te?.(e.currentTarget.value);},size:"sm",placeholder:O}),jsx(a$4,{color:ce??ie,type:"submit",disabled:P,size:"md",className:de,children:ee})]}),jsxs("div",{role:"listbox","aria-multiselectable":l||void 0,className:a$1("overflow-y-auto rounded-md",{"mt-3":A}),style:{maxHeight:ne},onScroll:e=>{if(!p)return;let{scrollTop:o,scrollHeight:h,clientHeight:u}=e.currentTarget;h-o<=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:ae}),!P&&!C&&v.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:se}),!C&&v.map(e=>{let o=Re(e.id),h=Ie[ue],u=jsxs(a$4,{type:"button",role:"option","aria-selected":o,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]":o&&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",o?h:"border-black/20",o&&me),children:o?jsx(Check,{size:14}):null})]},e.id);return q?jsx("div",{children:q(e,false,o)},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(n.Arrow,{className:"fill-white stroke-black/10"})]})})]})})}var Be=Pe;export{Be as default,Qe as handleMultipleChange,He as handleSingleChange};
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-32LB6SHS.js';import'../chunk-KYNNMWQA.js';import'../chunk-HR6IGUYJ.js';import'../chunk-QRYSV225.js';import'../chunk-IX36POX2.js';import'../chunk-FK7R34ZH.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var w=(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},x=async t=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/sub_district.json")).json()).filter(c=>c.district_id===t),y=({locale:t="th",searchPlaceholder:s="Search Sub District",placeholder:o="Select Sub District",label:l,searchButtonClassName:c="bg-blue-500",onChange:u,value:n,required:p=false,districtId:a$1,error:f,searchLabel:g="Search"})=>{let[i,D]=useState([]),[_,d]=useState(null);useEffect(()=>{a$1&&x(a$1).then(D);},[a$1]),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 v=useCallback(e=>{let r=i.find(C=>C.id===e);r&&(d(r),u?.(r));},[i,u]);return jsx("div",{children:jsx(a,{items:i.map(e=>w(e,t)),placeholder:s,triggerPlaceholder:o,label:l,selectionMode:"single",searchButtonClassName:c,onChange:e=>{v(e);},searchButtonLabel:g,value:_?.id,required:p,disabled:!a$1,errorMessage:f})})},B=y;
1
+ import {a}from'../chunk-FWCSTLF4.js';import'../chunk-KYNNMWQA.js';import'../chunk-2CWZ4OAO.js';import'../chunk-QRYSV225.js';import'../chunk-IX36POX2.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var w=(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},x=async t=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/sub_district.json")).json()).filter(c=>c.district_id===t),y=({locale:t="th",searchPlaceholder:s="Search Sub District",placeholder:o="Select Sub District",label:l,searchButtonClassName:c="bg-blue-500",onChange:u,value:n,required:p=false,districtId:a$1,error:f,searchLabel:g="Search"})=>{let[i,D]=useState([]),[_,d]=useState(null);useEffect(()=>{a$1&&x(a$1).then(D);},[a$1]),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 v=useCallback(e=>{let r=i.find(C=>C.id===e);r&&(d(r),u?.(r));},[i,u]);return jsx("div",{children:jsx(a,{items:i.map(e=>w(e,t)),placeholder:s,triggerPlaceholder:o,label:l,selectionMode:"single",searchButtonClassName:c,onChange:e=>{v(e);},searchButtonLabel:g,value:_?.id,required:p,disabled:!a$1,errorMessage:f})})},B=y;
2
2
  export{B as default};
@@ -1,4 +1,4 @@
1
- import {a}from'../chunk-FK7R34ZH.js';import {forwardRef}from'react';import {jsxs,jsx}from'react/jsx-runtime';var l=forwardRef(({label:r="\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 (\u0E1A\u0E49\u0E32\u0E19\u0E40\u0E25\u0E02\u0E17\u0E35\u0E48/\u0E0B\u0E2D\u0E22/\u0E16\u0E19\u0E19)",error:t,required:o=false,className:s="",...n},d)=>jsxs("fieldset",{className:"relative flex flex-col gap-2 items-start text-start",children:[r&&jsx(a,{label:r,required:o}),jsx("div",{className:"relative w-full",children:jsx("textarea",{ref:d,placeholder:"\u0E01\u0E23\u0E2D\u0E01\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E08\u0E31\u0E14\u0E2A\u0E48\u0E07\u0E02\u0E2D\u0E07\u0E23\u0E32\u0E07\u0E27\u0E31\u0E25",rows:4,className:`
1
+ import {a}from'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';import {forwardRef}from'react';import {jsxs,jsx}from'react/jsx-runtime';var n=forwardRef(({label:l,error:e,required:i=false,className:d,maxLength:s,value:t,...x},f)=>{let p=t?String(t).length:0;return jsxs("fieldset",{className:"relative flex flex-col gap-2 items-start text-start",children:[l&&jsx(a,{label:l,required:i}),jsxs("div",{className:"relative w-full",children:[jsx("textarea",{ref:f,placeholder:"\u0E01\u0E23\u0E2D\u0E01\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E08\u0E31\u0E14\u0E2A\u0E48\u0E07\u0E02\u0E2D\u0E07\u0E23\u0E32\u0E07\u0E27\u0E31\u0E25",rows:4,value:t,className:`
2
2
  w-full px-4 py-3
3
3
  border rounded-lg
4
4
  text-gray-900 placeholder-gray-400
@@ -6,6 +6,6 @@ import {a}from'../chunk-FK7R34ZH.js';import {forwardRef}from'react';import {jsxs
6
6
  transition-colors
7
7
  focus:outline-none
8
8
  bg-white
9
- ${t?"border-red-500":"border-gray-300"}
10
- ${s}
11
- `,...n})}),t&&jsx("small",{className:"text-red-500 text-xs",children:t})]}));l.displayName="TextAreaInput";var x=l;export{x as default};
9
+ ${e?"border-red-500":"border-gray-300"}
10
+ ${d}
11
+ `,...x}),s&&jsxs("div",{className:"text-right font-semibold text-xs text-[#606876] mt-1.5",children:[p||0,"/",s]})]}),e&&jsx("small",{className:"text-red-500 text-xs",children:e})]})});n.displayName="TextAreaInput";var c=n;export{c as default};
@@ -1 +1 @@
1
- export{a as default}from'../chunk-HR6IGUYJ.js';import'../chunk-QRYSV225.js';import'../chunk-FK7R34ZH.js';import'../chunk-6GLPXMGB.js';
1
+ export{a as default}from'../chunk-2CWZ4OAO.js';import'../chunk-QRYSV225.js';import'../chunk-THE2HQGT.js';import'../chunk-6GLPXMGB.js';
@@ -1 +1 @@
1
- import {a}from'../chunk-FK7R34ZH.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import*as e from'react';import*as s from'@radix-ui/react-switch';import {cva}from'class-variance-authority';import {jsx,jsxs}from'react/jsx-runtime';var R=cva(["inline-flex shrink-0 items-center transition-all duration-200","focus:outline-none focus-visible:ring-2 ring-black/20","disabled:cursor-not-allowed disabled:opacity-50 disabled:!bg-gray-300","data-[state=unchecked]:justify-start data-[state=checked]:justify-end"],{variants:{size:{sm:"h-[20px] w-[36px] p-[2px] rounded-full",md:"h-[24px] w-[44px] p-[2px] rounded-full",lg:"h-[28px] w-[56px] p-[2px] rounded-full"},colorScheme:{blue:"data-[state=checked]:bg-blue-500 data-[state=unchecked]:bg-gray-300",red:"data-[state=checked]:bg-red-500 data-[state=unchecked]:bg-gray-300",green:"data-[state=checked]:bg-green-500 data-[state=unchecked]:bg-gray-300",purple:"data-[state=checked]:bg-purple-500 data-[state=unchecked]:bg-gray-300",orange:"data-[state=checked]:bg-orange-500 data-[state=unchecked]:bg-gray-300"}},defaultVariants:{size:"md",colorScheme:"blue"}}),P=cva("bg-white shadow-sm transition-transform duration-200",{variants:{size:{sm:"h-[16px] w-[16px] rounded-full",md:"h-[20px] w-[20px] rounded-full",lg:"h-[24px] w-[24px] rounded-full"}},defaultVariants:{size:"md"}}),L=e.memo(function({label:t,required:n}){return t==null?null:jsx(a,{label:t,required:n})}),m=e.forwardRef(function({checked:t,defaultChecked:n,onCheckedChange:p,disabled:h=false,required:i=false,name:f,value:k,id:x,size:c="md",colorScheme:y="blue",checkedBg:l,uncheckedBg:o,label:w,labelPosition:C="right",className:T,trackClassName:V,thumbClassName:N,labelClassName:M},S){let d=!!(l||o),v=e.useMemo(()=>d?a$1(l&&`data-[state=checked]:${l}`,o&&`data-[state=unchecked]:${o}`):null,[l,o,d]);return jsxs("label",{className:a$1("inline-flex select-none items-center gap-3",C==="left"&&"flex-row-reverse justify-end",T),children:[jsx(s.Root,{ref:S,id:x,name:f,value:k,checked:t,defaultChecked:n,onCheckedChange:p,disabled:h,required:i,className:a$1(R({size:c,colorScheme:d?void 0:y}),v,V),children:jsx(s.Thumb,{className:a$1(P({size:c}),N)})}),jsx(L,{label:w,required:i})]})});m.displayName="Toggle";var z=e.memo(m);export{z as default};
1
+ import {a}from'../chunk-THE2HQGT.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import*as e from'react';import*as s from'@radix-ui/react-switch';import {cva}from'class-variance-authority';import {jsx,jsxs}from'react/jsx-runtime';var R=cva(["inline-flex shrink-0 items-center transition-all duration-200","focus:outline-none focus-visible:ring-2 ring-black/20","disabled:cursor-not-allowed disabled:opacity-50 disabled:!bg-gray-300","data-[state=unchecked]:justify-start data-[state=checked]:justify-end"],{variants:{size:{sm:"h-[20px] w-[36px] p-[2px] rounded-full",md:"h-[24px] w-[44px] p-[2px] rounded-full",lg:"h-[28px] w-[56px] p-[2px] rounded-full"},colorScheme:{blue:"data-[state=checked]:bg-blue-500 data-[state=unchecked]:bg-gray-300",red:"data-[state=checked]:bg-red-500 data-[state=unchecked]:bg-gray-300",green:"data-[state=checked]:bg-green-500 data-[state=unchecked]:bg-gray-300",purple:"data-[state=checked]:bg-purple-500 data-[state=unchecked]:bg-gray-300",orange:"data-[state=checked]:bg-orange-500 data-[state=unchecked]:bg-gray-300"}},defaultVariants:{size:"md",colorScheme:"blue"}}),P=cva("bg-white shadow-sm transition-transform duration-200",{variants:{size:{sm:"h-[16px] w-[16px] rounded-full",md:"h-[20px] w-[20px] rounded-full",lg:"h-[24px] w-[24px] rounded-full"}},defaultVariants:{size:"md"}}),L=e.memo(function({label:t,required:n}){return t==null?null:jsx(a,{label:t,required:n})}),m=e.forwardRef(function({checked:t,defaultChecked:n,onCheckedChange:p,disabled:h=false,required:i=false,name:f,value:k,id:x,size:c="md",colorScheme:y="blue",checkedBg:l,uncheckedBg:o,label:w,labelPosition:C="right",className:T,trackClassName:V,thumbClassName:N,labelClassName:M},S){let d=!!(l||o),v=e.useMemo(()=>d?a$1(l&&`data-[state=checked]:${l}`,o&&`data-[state=unchecked]:${o}`):null,[l,o,d]);return jsxs("label",{className:a$1("inline-flex select-none items-center gap-3",C==="left"&&"flex-row-reverse justify-end",T),children:[jsx(s.Root,{ref:S,id:x,name:f,value:k,checked:t,defaultChecked:n,onCheckedChange:p,disabled:h,required:i,className:a$1(R({size:c,colorScheme:d?void 0:y}),v,V),children:jsx(s.Thumb,{className:a$1(P({size:c}),N)})}),jsx(L,{label:w,required:i})]})});m.displayName="Toggle";var z=e.memo(m);export{z as default};
@@ -1 +1 @@
1
- import {a as a$2}from'../chunk-IX36POX2.js';import {a as a$1}from'../chunk-FK7R34ZH.js';import {a}from'../chunk-6GLPXMGB.js';import {useRef,useState,useCallback}from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var D=cva("mx-auto flex h-16 w-16 items-center justify-center rounded-full text-white",{variants:{iconColor:{neutral:"bg-neutral-800",primary:"bg-black",red:"bg-red-700",green:"bg-green-600",blue:"bg-blue-600",yellow:"bg-yellow-500",violet:"bg-violet-600"}},defaultVariants:{iconColor:"primary"}}),C=({label:u,buttonLabel:w="Upload",buttonColor:m="primary",iconColor:N,iconBgClassName:k,buttonClassName:y,openCameraButtonClassName:R,openCameraButtonLabel:I="Open Camera",className:L,icon:B,accept:p,multiple:g,disabled:l,onFilesSelected:f,required:P,value:U,title:j="Upload Image",error:i,onClearPreview:M,showClearButton:E=false,imageClassName:H})=>{let r=useRef(null),t=useRef(null),[W,b]=useState(null),F=()=>r.current?.click(),T=useCallback(()=>{t.current&&t.current.click();},[]),v=o=>{if(o.target.files&&o.target.files.length>0){let q=o.target.files[0],c=new FileReader;c.onloadend=()=>{b(c.result);},c.readAsDataURL(q),f&&f(o.target.files);}r.current&&(r.current.value=""),t.current&&(t.current.value="");},V=()=>{b(null),M?.(),r.current&&(r.current.value=""),t.current&&(t.current.value="");},s=W||U;return jsxs("fieldset",{className:a("flex flex-col gap-2",L),children:[u&&jsx(a$1,{label:u,required:P}),jsxs("div",{className:a("rounded-lg border border-dashed bg-white p-6 sm:p-8",i?"border-red-500":"border-black/20"),role:"group",children:[s?jsxs("div",{className:"relative flex justify-center max-w-3/4 md:max-w-2/4 mx-auto",children:[jsx("img",{src:s,alt:"Preview",className:a("rounded-lg max-h-[400px] object-contain",H)}),E&&jsx("button",{type:"button",onClick:V,className:"absolute top-2 right-2 p-2 bg-red-500 text-white rounded-full hover:bg-red-600 transition-colors shadow-lg","aria-label":"Remove image",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):jsx("div",{className:a(D({iconColor:N}),k),children:B??jsx("svg",{width:"34",height:"34",viewBox:"0 0 24 24",fill:"none",className:"shrink-0","aria-hidden":"true",children:jsx("path",{d:"M12 3v10m0 0 4-4m-4 4-4-4M5 21h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),!s&&jsx("h3",{className:"mt-4 text-center text-xl font-extrabold text-black",children:j}),jsxs("div",{className:"mt-6 flex justify-center gap-2",children:[jsx(a$2,{onClick:T,color:m,className:a("min-w-[180px]",R),disabled:l,size:"lg",variant:"outline",children:I}),jsx(a$2,{onClick:F,color:m,className:a("min-w-[180px]",y),disabled:l,size:"lg",children:w}),jsx("input",{ref:r,type:"file",className:"hidden",accept:p,multiple:g,onChange:v,disabled:l}),jsx("input",{ref:t,type:"file",className:"hidden",capture:"environment",accept:p,multiple:g,onChange:v,disabled:l})]})]}),i&&jsx("small",{className:"text-red-500 text-xs",children:i})]})};C.displayName="UploadImage";var S=C;export{S as default};
1
+ import {a as a$2}from'../chunk-IX36POX2.js';import {a as a$1}from'../chunk-THE2HQGT.js';import {a}from'../chunk-6GLPXMGB.js';import {useRef,useState,useCallback}from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var D=cva("mx-auto flex h-16 w-16 items-center justify-center rounded-full text-white",{variants:{iconColor:{neutral:"bg-neutral-800",primary:"bg-black",red:"bg-red-700",green:"bg-green-600",blue:"bg-blue-600",yellow:"bg-yellow-500",violet:"bg-violet-600"}},defaultVariants:{iconColor:"primary"}}),C=({label:u,buttonLabel:w="Upload",buttonColor:m="primary",iconColor:N,iconBgClassName:k,buttonClassName:y,openCameraButtonClassName:R,openCameraButtonLabel:I="Open Camera",className:L,icon:B,accept:p,multiple:g,disabled:l,onFilesSelected:f,required:P,value:U,title:j="Upload Image",error:i,onClearPreview:M,showClearButton:E=false,imageClassName:H})=>{let r=useRef(null),t=useRef(null),[W,b]=useState(null),F=()=>r.current?.click(),T=useCallback(()=>{t.current&&t.current.click();},[]),v=o=>{if(o.target.files&&o.target.files.length>0){let q=o.target.files[0],c=new FileReader;c.onloadend=()=>{b(c.result);},c.readAsDataURL(q),f&&f(o.target.files);}r.current&&(r.current.value=""),t.current&&(t.current.value="");},V=()=>{b(null),M?.(),r.current&&(r.current.value=""),t.current&&(t.current.value="");},s=W||U;return jsxs("fieldset",{className:a("flex flex-col gap-2",L),children:[u&&jsx(a$1,{label:u,required:P}),jsxs("div",{className:a("rounded-lg border border-dashed bg-white p-6 sm:p-8",i?"border-red-500":"border-black/20"),role:"group",children:[s?jsxs("div",{className:"relative flex justify-center max-w-3/4 md:max-w-2/4 mx-auto",children:[jsx("img",{src:s,alt:"Preview",className:a("rounded-lg max-h-[400px] object-contain",H)}),E&&jsx("button",{type:"button",onClick:V,className:"absolute top-2 right-2 p-2 bg-red-500 text-white rounded-full hover:bg-red-600 transition-colors shadow-lg","aria-label":"Remove image",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):jsx("div",{className:a(D({iconColor:N}),k),children:B??jsx("svg",{width:"34",height:"34",viewBox:"0 0 24 24",fill:"none",className:"shrink-0","aria-hidden":"true",children:jsx("path",{d:"M12 3v10m0 0 4-4m-4 4-4-4M5 21h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),!s&&jsx("h3",{className:"mt-4 text-center text-xl font-extrabold text-black",children:j}),jsxs("div",{className:"mt-6 flex justify-center gap-2",children:[jsx(a$2,{onClick:T,color:m,className:a("min-w-[180px]",R),disabled:l,size:"lg",variant:"outline",children:I}),jsx(a$2,{onClick:F,color:m,className:a("min-w-[180px]",y),disabled:l,size:"lg",children:w}),jsx("input",{ref:r,type:"file",className:"hidden",accept:p,multiple:g,onChange:v,disabled:l}),jsx("input",{ref:t,type:"file",className:"hidden",capture:"environment",accept:p,multiple:g,onChange:v,disabled:l})]})]}),i&&jsx("small",{className:"text-red-500 text-xs",children:i})]})};C.displayName="UploadImage";var S=C;export{S as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "the-omelet-ui",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- import {forwardRef}from'react';import {jsx,jsxs}from'react/jsx-runtime';var l=forwardRef(({required:t,label:a,id:r},s)=>jsx("div",{className:"flex items-center ",ref:s,children:jsxs("label",{className:"block text-sm text-[#444] font-bold",htmlFor:r,children:[a,t&&jsx("span",{className:"text-red-500",children:"*"})]})}));l.displayName="LabelInput";var b=l;export{b as a};