the-omelet-ui 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import {a as a$3}from'./chunk-HDRQQXSB.js';import {a as a$4}from'./chunk-VJRZAASL.js';import {f,b}from'./chunk-AFEF2EXB.js';import {a as a$1}from'./chunk-DM45BGDQ.js';import {a as a$2}from'./chunk-Y3MG7XXZ.js';import*as a from'react';import*as l from'@radix-ui/react-popover';import {jsxs,jsx}from'react/jsx-runtime';function ae(i){return typeof i=="string"?{id:i,label:i}:i}var se={neutral:"border-neutral-900 bg-neutral-900 text-white",primary:"border-black bg-black text-white",red:"border-red-600 bg-red-600 text-white",green:"border-green-600 bg-green-600 text-white",blue:"border-blue-600 bg-blue-600 text-white",yellow:"border-yellow-500 bg-yellow-500 text-black",violet:"border-violet-600 bg-violet-600 text-white"};function le({trigger:i,triggerPlaceholder:v="Choose",items:x,selectionMode:b$1="multiple",value:y,defaultValue:q,onChange:z,searchable:w=true,placeholder:Q="Placeholder Text",searchButtonLabel:A="Search",onQueryChange:O,onSearch:V,loading:m=false,emptyLabel:j="No results",contentClassName:D,maxHeight:H=288,renderItem:k,buttonColor:W="primary",searchButtonColor:_,searchButtonClassName:$,checkedColor:E="primary",checkedClassName:F,renderTriggerValue:R,label:N,required:G}){let[C,P]=a.useState(false),[p,J]=a.useState(""),[g,K]=a.useState(""),s=b$1==="multiple",[U,X]=a.useState(q??(s?[]:"")),o=y??U,d=a.useMemo(()=>x.map(ae),[x]),S=a.useMemo(()=>{let e=g.trim().toLowerCase();return e?d.filter(r=>String(r.label).toLowerCase().includes(e)):d},[d,g]),I=e=>{z?.(e),y===void 0&&X(e);},Y=e=>{if(s){let r=new Set(o);r.has(e)?r.delete(e):r.add(e),I(Array.from(r));}else I(e),P(false);},Z=e=>s?o.includes(e):o===e,ee=()=>{K(p),V?.(p);},f$1=a.useMemo(()=>s?o:o?[o]:[],[o,s]),u=a.useMemo(()=>d.filter(e=>f$1.includes(e.id)),[d,f$1]),te=a.useMemo(()=>u.length===0?v:s?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${u.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:u[0].label,[u,s,v]);return jsxs(l.Root,{open:C,onOpenChange:P,children:[N&&jsx(a$1,{label:N,required:G}),jsx("div",{className:"mb-2"}),jsx(l.Trigger,{asChild:true,children:i??jsxs("button",{type:"button",className:a$2("flex w-full min-w-[260px] items-center justify-between","rounded-md border border-black/15 bg-white px-4 py-3 text-left","outline-none focus-visible:ring-2 ring-black/20"),children:[jsx("span",{className:a$2("flex-1 ",{"text-gray-400":s?o?.length===0:!o,"text-black":s?o?.length>0:!!o}),children:R?R(f$1,u):te}),jsx("svg",{className:a$2("ml-3 h-5 w-5 text-black/60 transition-transform",C?"rotate-180":"rotate-0"),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:jsx("path",{d:"M6 9l6 6 6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]})}),jsx(l.Portal,{children:jsxs(l.Content,{sideOffset:8,className:a$2("w-[420px] rounded-md border border-black/10 bg-white p-2 shadow-xl",D),children:[w&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:e=>{e.preventDefault(),ee();},children:[jsx(a$3,{start:jsx(f,{className:"h-3 w-3 text-black/50"}),value:p,onChange:e=>{J(e.currentTarget.value),O?.(e.currentTarget.value);},size:"sm",placeholder:Q}),jsx(a$4,{color:_??W,type:"submit",disabled:m||p.trim()===g.trim(),size:"md",className:$,children:A})]}),jsxs("div",{role:"listbox","aria-multiselectable":s||void 0,className:a$2(" overflow-y-auto rounded-md",{"mt-3":w}),style:{maxHeight:H},children:[m&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),!m&&S.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:j}),!m&&S.map(e=>{let r=Z(e.id),re=se[E],oe=jsxs(a$4,{type:"button",role:"option","aria-selected":r,onClick:()=>Y(e.id),disabled:e.disabled,size:"sm",className:a$2("group flex w-full items-center justify-between gap-3 rounded-md px-2 py-2 text-left bg-white","hover:bg-black/[0.04] disabled:opacity-50",{"bg-black/[0.04]":r&&b$1==="single"}),children:[jsx("span",{className:"text-md text-black",children:e.label}),b$1==="multiple"&&jsx("span",{className:a$2("grid h-5 w-5 place-items-center rounded-full border-2",r?re:"border-black/20",r&&F),children:r?jsx(b,{className:"h-2 w-2"}):null})]},e.id);return k?jsx("div",{children:k(e,false,r)},e.id):oe})]}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]})}var me=le;export{me as a};
@@ -0,0 +1 @@
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:[t&&jsx("span",{className:"text-red-500",children:"*"}),a]})}));l.displayName="LabelInput";var b=l;export{b as a};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-DM45BGDQ.js';import {a as a$1}from'./chunk-Y3MG7XXZ.js';import*as l from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var w=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-10 px-2 py-3 text-sm",md:"h-12 px-2 py-4 text-md",lg:"h-14 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"}}),o=l.forwardRef(({className:d,start:s,end:r,size:p,tone:u,withStart:b,withEnd:c,error:t,label:n,required:f,disabled:m=false,...x},g)=>jsxs("fieldset",{className:"relative flex flex-col gap-2 items-start text-start",children:[n&&jsx(a,{label:n,required:f}),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:g,"data-state":t?"invalid":void 0,className:a$1(w({size:p,tone:t?"danger":u,withStart:b??!!s,withEnd:c??!!r}),d),disabled:m,...x}),r?jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pe-3",children:r}):null,t&&jsx("small",{className:"text-red-500 text-xs",children:t})]}));o.displayName="TextInput";var S=o;export{S as a};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-Y3MG7XXZ.js';import*as t from'react';import {Slot}from'@radix-ui/react-slot';import {cva}from'class-variance-authority';import {jsx}from'react/jsx-runtime';var g=cva("inline-flex items-center justify-center rounded-md font-medium outline-none text-[18px] cursor-pointertransition-colors focus-visible:ring-2 ring-black/20 disabled:pointer-events-none disabled:bg-[#EBEBEB] disabled:text-[#878787]",{variants:{variant:{solid:"",outline:"border bg-transparent border-[#C9D7E3]",ghost:"bg-transparent"},size:{sm:"h-8 px-2 py-3 text-sm",md:"h-10 px-2 py-3 text-md",lg:"h-12 px-2 py-4 text-xl"},color:{neutral:"",primary:"",red:"",green:"",blue:"",yellow:"",violet:""}},compoundVariants:[{variant:"solid",color:"neutral",class:"bg-neutral-900 text-white hover:dark:bg-neutral-800"},{variant:"solid",color:"primary",class:"bg-black text-white hover:bg-black/85"},{variant:"solid",color:"red",class:"bg-red-600 text-white hover:bg-red-700"},{variant:"solid",color:"green",class:"bg-green-600 text-white hover:bg-green-700"},{variant:"solid",color:"blue",class:"bg-blue-600 text-white hover:bg-blue-700"},{variant:"solid",color:"yellow",class:"bg-yellow-500 text-black hover:bg-yellow-600"},{variant:"solid",color:"violet",class:"bg-violet-600 text-white hover:bg-violet-700"},{variant:"outline",color:"neutral",class:"border-[#C9D7E3] text-neutral-900 hover:bg-neutral-50"},{variant:"outline",color:"primary",class:"border-[#C9D7E3] text-black hover:bg-black/[0.06]"},{variant:"outline",color:"red",class:"border-red-600 text-red-700 hover:bg-red-50"},{variant:"outline",color:"green",class:"border-green-600 text-green-700 hover:bg-green-50"},{variant:"outline",color:"blue",class:"border-blue-600 text-blue-700 hover:bg-blue-50"},{variant:"outline",color:"yellow",class:"border-yellow-500 text-yellow-700 hover:bg-yellow-50"},{variant:"outline",color:"violet",class:"border-violet-600 text-violet-700 hover:bg-violet-50"},{variant:"ghost",color:"neutral",class:"text-neutral-900 hover:bg-neutral-50"},{variant:"ghost",color:"primary",class:"text-black hover:bg-black/[0.06]"},{variant:"ghost",color:"red",class:"text-red-700 hover:bg-red-50"},{variant:"ghost",color:"green",class:"text-green-700 hover:bg-green-50"},{variant:"ghost",color:"blue",class:"text-blue-700 hover:bg-blue-50"},{variant:"ghost",color:"yellow",class:"text-yellow-700 hover:bg-yellow-50"},{variant:"ghost",color:"violet",class:"text-violet-700 hover:bg-violet-50"}],defaultVariants:{variant:"solid",size:"md",color:"primary"}}),o=t.forwardRef(({className:r,variant:l,size:a$1,color:n,asChild:i,...s},b)=>jsx(i?Slot:"button",{ref:b,className:a(g({variant:l,size:a$1,color:n}),r),...s}));o.displayName="Button";var m=o;export{m as a};
@@ -0,0 +1,26 @@
1
+ import * as class_variance_authority_types from 'class-variance-authority/types';
2
+ import * as React from 'react';
3
+ import { VariantProps } from 'class-variance-authority';
4
+
5
+ /**
6
+ * variant: solid | outline | ghost
7
+ * color: neutral | primary | red | green | blue | yellow | violet
8
+ * size: sm | md | lg
9
+ *
10
+ * หมายเหตุ:
11
+ * - สามารถ override สีพื้นหลัง/เส้นขอบด้วย className เช่น "bg-rose-600 hover:bg-rose-700"
12
+ * โดย className จะมากลบของเดิม (twMerge)
13
+ */
14
+ declare const buttonStyles: (props?: ({
15
+ variant?: "solid" | "outline" | "ghost" | null | undefined;
16
+ size?: "sm" | "md" | "lg" | null | undefined;
17
+ color?: "neutral" | "primary" | "red" | "green" | "blue" | "yellow" | "violet" | null | undefined;
18
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
19
+ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonStyles> {
20
+ asChild?: boolean;
21
+ color?: "neutral" | "primary" | "red" | "green" | "blue" | "yellow" | "violet";
22
+ size?: "sm" | "md" | "lg";
23
+ }
24
+ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
25
+
26
+ export { type ButtonProps, Button as default };
@@ -0,0 +1 @@
1
+ export{a as default}from'../chunk-VJRZAASL.js';import'../chunk-Y3MG7XXZ.js';
@@ -1 +1 @@
1
- import {b as b$1}from'../chunk-AFEF2EXB.js';import {a}from'../chunk-QXOY2OGU.js';import {a as a$1}from'../chunk-Y3MG7XXZ.js';import*as e from'react';import {jsx,jsxs}from'react/jsx-runtime';var M={sm:{box:"h-4 w-4 rounded-md",icon:"h-2 w-2 text-white"},md:{box:"h-5 w-5 rounded-md",icon:"h-3 w-3 text-white"},lg:{box:"h-7 w-7 rounded-md",icon:"h-5 w-5 text-white"}},P=e.memo(function({label:a$2,required:s,className:o,id:n}){return a$2==null?null:typeof a$2=="string"?jsx(a,{label:a$2,required:s}):jsx("span",{className:a$1("text-[15px] text-black",o),children:a$2})}),b=e.forwardRef(function({checked:a,defaultChecked:s,onCheckedChange:o,id:n,name:p,value:h,disabled:u=false,required:c=false,size:g="md",label:f,labelPosition:x="right",className:k,boxClassName:C,labelClassName:w,indicatorClassName:R,checkedBg:N="#2f6af7",uncheckedBorderColor:y="rgb(0 0 0 / 0.2)"},v){let i=M[g],S=e.useCallback(I=>{o?.(I.currentTarget.checked);},[o]),L=e.useMemo(()=>a$1("inline-flex items-center justify-center border-2 bg-white transition-colors","peer-focus-visible:ring-2 ring-black/20","peer-disabled:opacity-50 peer-disabled:cursor-not-allowed","border-[var(--ubc)]","peer-checked:bg-[var(--cbg)] peer-checked:border-transparent"),[]),B=e.useMemo(()=>a$1("text-white transition-all duration-150","peer-checked:opacity-100 peer-checked:scale-100"),[]);return jsxs("label",{className:a$1("inline-flex items-center gap-3 select-none",x==="left"&&"flex-row-reverse justify-end",k),htmlFor:n,style:{"--cbg":N,"--ubc":y},children:[jsx("input",{ref:v,id:n,name:p,value:h,type:"checkbox",className:"peer sr-only",checked:a,defaultChecked:s,onChange:S,disabled:u,"aria-required":c||void 0}),jsx("span",{className:a$1(L,i.box,C),children:jsx(b$1,{className:a$1(i.icon,B,R)})}),jsx(P,{label:f,required:c,className:w,id:n})]})});b.displayName="Checkbox";var z=e.memo(b);export{z as default};
1
+ import {b as b$1}from'../chunk-AFEF2EXB.js';import {a}from'../chunk-DM45BGDQ.js';import {a as a$1}from'../chunk-Y3MG7XXZ.js';import*as e from'react';import {jsx,jsxs}from'react/jsx-runtime';var M={sm:{box:"h-4 w-4 rounded-md",icon:"h-2 w-2 text-white"},md:{box:"h-5 w-5 rounded-md",icon:"h-3 w-3 text-white"},lg:{box:"h-7 w-7 rounded-md",icon:"h-5 w-5 text-white"}},P=e.memo(function({label:a$2,required:s,className:o,id:n}){return a$2==null?null:typeof a$2=="string"?jsx(a,{label:a$2,required:s}):jsx("span",{className:a$1("text-[15px] text-black",o),children:a$2})}),b=e.forwardRef(function({checked:a,defaultChecked:s,onCheckedChange:o,id:n,name:p,value:h,disabled:u=false,required:c=false,size:g="md",label:f,labelPosition:x="right",className:k,boxClassName:C,labelClassName:w,indicatorClassName:R,checkedBg:N="#2f6af7",uncheckedBorderColor:y="rgb(0 0 0 / 0.2)"},v){let i=M[g],S=e.useCallback(I=>{o?.(I.currentTarget.checked);},[o]),L=e.useMemo(()=>a$1("inline-flex items-center justify-center border-2 bg-white transition-colors","peer-focus-visible:ring-2 ring-black/20","peer-disabled:opacity-50 peer-disabled:cursor-not-allowed","border-[var(--ubc)]","peer-checked:bg-[var(--cbg)] peer-checked:border-transparent"),[]),B=e.useMemo(()=>a$1("text-white transition-all duration-150","peer-checked:opacity-100 peer-checked:scale-100"),[]);return jsxs("label",{className:a$1("inline-flex items-center gap-3 select-none",x==="left"&&"flex-row-reverse justify-end",k),htmlFor:n,style:{"--cbg":N,"--ubc":y},children:[jsx("input",{ref:v,id:n,name:p,value:h,type:"checkbox",className:"peer sr-only",checked:a,defaultChecked:s,onChange:S,disabled:u,"aria-required":c||void 0}),jsx("span",{className:a$1(L,i.box,C),children:jsx(b$1,{className:a$1(i.icon,B,R)})}),jsx(P,{label:f,required:c,className:w,id:n})]})});b.displayName="Checkbox";var z=e.memo(b);export{z as default};
@@ -1 +1 @@
1
- import {a as a$2,c,d,e}from'../chunk-AFEF2EXB.js';import {a as a$1}from'../chunk-QXOY2OGU.js';import {a}from'../chunk-Y3MG7XXZ.js';import*as s from'react';import*as r from'@radix-ui/react-popover';import {jsx,jsxs}from'react/jsx-runtime';var pe=["\u0E21\u0E01\u0E23\u0E32\u0E04\u0E21","\u0E01\u0E38\u0E21\u0E20\u0E32\u0E1E\u0E31\u0E19\u0E18\u0E4C","\u0E21\u0E35\u0E19\u0E32\u0E04\u0E21","\u0E40\u0E21\u0E29\u0E32\u0E22\u0E19","\u0E1E\u0E24\u0E29\u0E20\u0E32\u0E04\u0E21","\u0E21\u0E34\u0E16\u0E38\u0E19\u0E32\u0E22\u0E19","\u0E01\u0E23\u0E01\u0E0E\u0E32\u0E04\u0E21","\u0E2A\u0E34\u0E07\u0E2B\u0E32\u0E04\u0E21","\u0E01\u0E31\u0E19\u0E22\u0E32\u0E22\u0E19","\u0E15\u0E38\u0E25\u0E32\u0E04\u0E21","\u0E1E\u0E24\u0E28\u0E08\u0E34\u0E01\u0E32\u0E22\u0E19","\u0E18\u0E31\u0E19\u0E27\u0E32\u0E04\u0E21"],G=["\u0E2D\u0E32","\u0E08","\u0E2D","\u0E1E","\u0E1E\u0E24","\u0E28","\u0E2A"],ge=["January","February","March","April","May","June","July","August","September","October","November","December"],J=["Su","Mo","Tu","We","Th","Fr","Sa"],E=o=>new Date(o.getFullYear(),o.getMonth(),1),W=(o,e)=>new Date(o.getFullYear(),o.getMonth()+e,1),$=(o,e)=>{let l=new Date(o);return l.setDate(l.getDate()+e),l},q=(o,e)=>!!o&&!!e&&o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate(),he=(o,e,l)=>e&&o<e?e:l&&o>l?l:o,ve=s.memo(function({d:e,inMonth:l,disabled:i,selected:p,isToday:d,onPick:n,dayClassName:u,outsideDayClassName:m,selectedDayClassName:M,todayClassName:N}){let R=s.useCallback(()=>{i||n(e);},[i,n,e]);return jsx("button",{type:"button",onClick:R,disabled:i,className:a("h-9 w-9 place-self-center text-sm transition-colors rounded-full","outline-none focus-visible:ring-2 ring-black/20",l?"text-black":m??"text-black/30",i&&"opacity-30 pointer-events-none",d&&!p&&(N??"bg-[#EDF6FF] text-[#004499] font-bold"),u,p?a("bg-blue-600 text-white hover:bg-blue-600",M):"hover:bg-black/5"),children:e.getDate()})},(o,e)=>o.inMonth===e.inMonth&&o.disabled===e.disabled&&o.selected===e.selected&&o.isToday===e.isToday&&o.d.getTime()===e.d.getTime()&&o.dayClassName===e.dayClassName&&o.outsideDayClassName===e.outsideDayClassName&&o.selectedDayClassName===e.selectedDayClassName&&o.todayClassName===e.todayClassName),ye=s.memo(function({months:e,activeMonth:l,onSelect:i}){let p=s.useCallback(d=>i(d),[i]);return jsx("div",{className:"grid grid-cols-3 gap-1",style:{gridTemplateColumns:"repeat(3, minmax(0,1fr))"},children:e.map((d,n)=>jsx("button",{type:"button",onClick:()=>p(n),className:a("rounded-md px-2 py-2 text-sm hover:bg-black/5",n===l&&"bg-black/10"),children:d},d))})}),fe=s.memo(function({years:e,activeYear:l,labelFromYear:i,onSelect:p}){let d=s.useCallback(n=>p(n),[p]);return jsx("div",{className:"max-h-72 w-28 overflow-y-auto rounded-md border border-black/10 bg-white p-1 shadow-lg",children:e.map(n=>jsx("button",{type:"button",onClick:()=>d(n),className:a("block w-full rounded-md px-2 py-2 text-left text-sm hover:bg-black/5",n===l&&"bg-black/10"),children:i(n)},n))})}),De=s.forwardRef(function({label:e$1,required:l,value:i,defaultValue:p=null,onChange:d$1,minDate:n,maxDate:u,locale:m="th",useBuddhistEra:M,format:N,className:R,inputClassName:V,contentClassName:j,dayClassName:z,todayClassName:Q,selectedDayClassName:U,outsideDayClassName:X="text-black/30",placeholderText:Z="dd/mm/yyyy",calendarIcon:ee,disabled:O=false,error:Y,closeOnSelect:A=true,yearRange:S,iconClassName:w},te){let [ae,I]=s.useState(false),[oe,se]=s.useState(p),T=i!==void 0,g=(T?i:oe)??null,P=M??m==="th",L=m==="th"?pe:ge,ne=g??new Date,[D,k]=s.useState(E(ne));s.useEffect(()=>{g&&k(E(g));},[g?.getFullYear(),g?.getMonth()]);let C=D.getFullYear(),x=D.getMonth(),re=s.useMemo(()=>N||(m==="th"?a=>{let b=P?a.getFullYear()+543:a.getFullYear(),v=String(a.getDate()).padStart(2,"0"),y=String(a.getMonth()+1).padStart(2,"0");return `${v}/${y}/${b}`}:a=>a.toLocaleDateString("en-GB")),[N,m,P]),le=s.useMemo(()=>{let a=E(D),b=a.getDay(),v=$(a,-b);return Array.from({length:42},(y,f)=>$(v,f))},[D]),ce=s.useMemo(()=>{let a=new Date().getFullYear(),b=S?.[0]??n?.getFullYear()??a-60,v=S?.[1]??u?.getFullYear()??a+40,y=[];for(let f=b;f<=v;f++)y.push(f);return y},[S,n,u]),ie=P?C+543:C,de=s.useCallback(a=>{let b=he(a,n,u);d$1?.(b),T||se(b),A&&I(false);},[T,n,u,d$1,A]),ue=s.useCallback(a=>{k(new Date(C,a,1));},[C]),me=s.useCallback(a=>{k(new Date(a,x,1));},[x]);return jsxs("fieldset",{ref:te,className:a("",R),children:[e$1&&jsx(a$1,{required:l,label:e$1}),jsxs(r.Root,{open:ae,onOpenChange:I,children:[jsxs("div",{className:"relative mt-2",children:[jsx(r.Trigger,{asChild:true,children:jsx("button",{type:"button",disabled:O,className:a("flex w-full items-center rounded-md border bg-white px-3 py-2 text-left","outline-none focus-visible:ring-2",Y?"border-red-500 ring-red-200":"border-black/15 ring-black/20",O&&"opacity-50 cursor-not-allowed","pr-10",V),children:jsx("span",{className:a("truncate text-black",!g&&"text-black/40"),children:g?re(g):Z})})}),jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-black/50",children:ee??jsx(a$2,{})})]}),Y&&jsx("small",{className:"text-red-500 text-xs",children:Y}),jsx(r.Portal,{children:jsxs(r.Content,{sideOffset:8,className:a("w-[300px] sm:w-[320px] rounded-md border border-black/10 bg-white p-3 shadow-xl",j),children:[jsxs("div",{className:"flex items-center justify-between px-1 py-1",children:[jsxs("div",{className:"flex items-center gap-1",children:[jsxs(r.Root,{modal:false,children:[jsx(r.Trigger,{asChild:true,children:jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-base font-semibold text-black hover:bg-black/5","aria-label":"\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E40\u0E14\u0E37\u0E2D\u0E19",children:[L[x],jsx(c,{className:w??"text-blue-500 w-3 h-3"})]})}),jsx(r.Portal,{children:jsxs(r.Content,{sideOffset:6,align:"start",className:"rounded-md border border-black/10 bg-white p-2 shadow-lg",children:[jsx(ye,{months:L,activeMonth:x,onSelect:ue}),jsx(r.Arrow,{className:"fill-white stroke-black/10"})]})})]}),jsxs(r.Root,{modal:false,children:[jsx(r.Trigger,{asChild:true,children:jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-base font-semibold text-black hover:bg-black/5","aria-label":"\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E1B\u0E35",children:[ie,jsx(c,{className:w??"text-blue-500 w-3 h-3"})]})}),jsx(r.Portal,{children:jsxs(r.Content,{sideOffset:6,align:"start",children:[jsx(fe,{years:ce,activeYear:C,labelFromYear:a=>P?a+543:a,onSelect:me}),jsx(r.Arrow,{className:"fill-white stroke-black/10"})]})})]})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",className:"rounded-md p-2 text-black/70 hover:bg-black/5",onClick:()=>k(W(D,-1)),"aria-label":m==="th"?"\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32":"Previous month",children:jsx(d,{className:w??"text-blue-500 w-3 h-3"})}),jsx("button",{type:"button",className:"rounded-md p-2 text-black/70 hover:bg-black/5",onClick:()=>k(W(D,1)),"aria-label":m==="th"?"\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E16\u0E31\u0E14\u0E44\u0E1B":"Next month",children:jsx(e,{className:w??"text-blue-500 w-3 h-3"})})]})]}),jsx("div",{className:"mt-1 grid grid-cols-7 gap-y-1 px-1 text-center text-xs text-black/50",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:(m==="th"?G:J).map(a=>jsx("div",{className:"h-7 leading-7 whitespace-nowrap",children:a},a))}),jsx("div",{className:"grid grid-cols-7 gap-1 px-1 pb-1 pt-1",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:le.map((a,b)=>{let v=a.getMonth()===x,y=n&&a<new Date(n.getFullYear(),n.getMonth(),n.getDate())||u&&a>new Date(u.getFullYear(),u.getMonth(),u.getDate()),f=q(a,g),be=q(a,new Date);return jsx(ve,{d:a,inMonth:v,disabled:!!y,selected:f,isToday:be,onPick:de,dayClassName:z,outsideDayClassName:X,selectedDayClassName:U,todayClassName:Q},b)})}),jsx(r.Arrow,{className:"fill-white stroke-black/10"})]})})]})]})}),Ne=s.memo(De);export{Ne as default};
1
+ import {a as a$2,c,d,e}from'../chunk-AFEF2EXB.js';import {a as a$1}from'../chunk-DM45BGDQ.js';import {a}from'../chunk-Y3MG7XXZ.js';import*as s from'react';import*as r from'@radix-ui/react-popover';import {jsx,jsxs}from'react/jsx-runtime';var pe=["\u0E21\u0E01\u0E23\u0E32\u0E04\u0E21","\u0E01\u0E38\u0E21\u0E20\u0E32\u0E1E\u0E31\u0E19\u0E18\u0E4C","\u0E21\u0E35\u0E19\u0E32\u0E04\u0E21","\u0E40\u0E21\u0E29\u0E32\u0E22\u0E19","\u0E1E\u0E24\u0E29\u0E20\u0E32\u0E04\u0E21","\u0E21\u0E34\u0E16\u0E38\u0E19\u0E32\u0E22\u0E19","\u0E01\u0E23\u0E01\u0E0E\u0E32\u0E04\u0E21","\u0E2A\u0E34\u0E07\u0E2B\u0E32\u0E04\u0E21","\u0E01\u0E31\u0E19\u0E22\u0E32\u0E22\u0E19","\u0E15\u0E38\u0E25\u0E32\u0E04\u0E21","\u0E1E\u0E24\u0E28\u0E08\u0E34\u0E01\u0E32\u0E22\u0E19","\u0E18\u0E31\u0E19\u0E27\u0E32\u0E04\u0E21"],G=["\u0E2D\u0E32","\u0E08","\u0E2D","\u0E1E","\u0E1E\u0E24","\u0E28","\u0E2A"],ge=["January","February","March","April","May","June","July","August","September","October","November","December"],J=["Su","Mo","Tu","We","Th","Fr","Sa"],E=o=>new Date(o.getFullYear(),o.getMonth(),1),W=(o,e)=>new Date(o.getFullYear(),o.getMonth()+e,1),$=(o,e)=>{let l=new Date(o);return l.setDate(l.getDate()+e),l},q=(o,e)=>!!o&&!!e&&o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate(),he=(o,e,l)=>e&&o<e?e:l&&o>l?l:o,ve=s.memo(function({d:e,inMonth:l,disabled:i,selected:p,isToday:d,onPick:n,dayClassName:u,outsideDayClassName:m,selectedDayClassName:M,todayClassName:N}){let R=s.useCallback(()=>{i||n(e);},[i,n,e]);return jsx("button",{type:"button",onClick:R,disabled:i,className:a("h-9 w-9 place-self-center text-sm transition-colors rounded-full","outline-none focus-visible:ring-2 ring-black/20",l?"text-black":m??"text-black/30",i&&"opacity-30 pointer-events-none",d&&!p&&(N??"bg-[#EDF6FF] text-[#004499] font-bold"),u,p?a("bg-blue-600 text-white hover:bg-blue-600",M):"hover:bg-black/5"),children:e.getDate()})},(o,e)=>o.inMonth===e.inMonth&&o.disabled===e.disabled&&o.selected===e.selected&&o.isToday===e.isToday&&o.d.getTime()===e.d.getTime()&&o.dayClassName===e.dayClassName&&o.outsideDayClassName===e.outsideDayClassName&&o.selectedDayClassName===e.selectedDayClassName&&o.todayClassName===e.todayClassName),ye=s.memo(function({months:e,activeMonth:l,onSelect:i}){let p=s.useCallback(d=>i(d),[i]);return jsx("div",{className:"grid grid-cols-3 gap-1",style:{gridTemplateColumns:"repeat(3, minmax(0,1fr))"},children:e.map((d,n)=>jsx("button",{type:"button",onClick:()=>p(n),className:a("rounded-md px-2 py-2 text-sm hover:bg-black/5",n===l&&"bg-black/10"),children:d},d))})}),fe=s.memo(function({years:e,activeYear:l,labelFromYear:i,onSelect:p}){let d=s.useCallback(n=>p(n),[p]);return jsx("div",{className:"max-h-72 w-28 overflow-y-auto rounded-md border border-black/10 bg-white p-1 shadow-lg",children:e.map(n=>jsx("button",{type:"button",onClick:()=>d(n),className:a("block w-full rounded-md px-2 py-2 text-left text-sm hover:bg-black/5",n===l&&"bg-black/10"),children:i(n)},n))})}),De=s.forwardRef(function({label:e$1,required:l,value:i,defaultValue:p=null,onChange:d$1,minDate:n,maxDate:u,locale:m="th",useBuddhistEra:M,format:N,className:R,inputClassName:V,contentClassName:j,dayClassName:z,todayClassName:Q,selectedDayClassName:U,outsideDayClassName:X="text-black/30",placeholderText:Z="dd/mm/yyyy",calendarIcon:ee,disabled:O=false,error:Y,closeOnSelect:A=true,yearRange:S,iconClassName:w},te){let [ae,I]=s.useState(false),[oe,se]=s.useState(p),T=i!==void 0,g=(T?i:oe)??null,P=M??m==="th",L=m==="th"?pe:ge,ne=g??new Date,[D,k]=s.useState(E(ne));s.useEffect(()=>{g&&k(E(g));},[g?.getFullYear(),g?.getMonth()]);let C=D.getFullYear(),x=D.getMonth(),re=s.useMemo(()=>N||(m==="th"?a=>{let b=P?a.getFullYear()+543:a.getFullYear(),v=String(a.getDate()).padStart(2,"0"),y=String(a.getMonth()+1).padStart(2,"0");return `${v}/${y}/${b}`}:a=>a.toLocaleDateString("en-GB")),[N,m,P]),le=s.useMemo(()=>{let a=E(D),b=a.getDay(),v=$(a,-b);return Array.from({length:42},(y,f)=>$(v,f))},[D]),ce=s.useMemo(()=>{let a=new Date().getFullYear(),b=S?.[0]??n?.getFullYear()??a-60,v=S?.[1]??u?.getFullYear()??a+40,y=[];for(let f=b;f<=v;f++)y.push(f);return y},[S,n,u]),ie=P?C+543:C,de=s.useCallback(a=>{let b=he(a,n,u);d$1?.(b),T||se(b),A&&I(false);},[T,n,u,d$1,A]),ue=s.useCallback(a=>{k(new Date(C,a,1));},[C]),me=s.useCallback(a=>{k(new Date(a,x,1));},[x]);return jsxs("fieldset",{ref:te,className:a("",R),children:[e$1&&jsx(a$1,{required:l,label:e$1}),jsxs(r.Root,{open:ae,onOpenChange:I,children:[jsxs("div",{className:"relative mt-2",children:[jsx(r.Trigger,{asChild:true,children:jsx("button",{type:"button",disabled:O,className:a("flex w-full items-center rounded-md border bg-white px-3 py-2 text-left","outline-none focus-visible:ring-2",Y?"border-red-500 ring-red-200":"border-black/15 ring-black/20",O&&"opacity-50 cursor-not-allowed","pr-10",V),children:jsx("span",{className:a("truncate text-black",!g&&"text-black/40"),children:g?re(g):Z})})}),jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-black/50",children:ee??jsx(a$2,{})})]}),Y&&jsx("small",{className:"text-red-500 text-xs",children:Y}),jsx(r.Portal,{children:jsxs(r.Content,{sideOffset:8,className:a("w-[300px] sm:w-[320px] rounded-md border border-black/10 bg-white p-3 shadow-xl",j),children:[jsxs("div",{className:"flex items-center justify-between px-1 py-1",children:[jsxs("div",{className:"flex items-center gap-1",children:[jsxs(r.Root,{modal:false,children:[jsx(r.Trigger,{asChild:true,children:jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-base font-semibold text-black hover:bg-black/5","aria-label":"\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E40\u0E14\u0E37\u0E2D\u0E19",children:[L[x],jsx(c,{className:w??"text-blue-500 w-3 h-3"})]})}),jsx(r.Portal,{children:jsxs(r.Content,{sideOffset:6,align:"start",className:"rounded-md border border-black/10 bg-white p-2 shadow-lg",children:[jsx(ye,{months:L,activeMonth:x,onSelect:ue}),jsx(r.Arrow,{className:"fill-white stroke-black/10"})]})})]}),jsxs(r.Root,{modal:false,children:[jsx(r.Trigger,{asChild:true,children:jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-base font-semibold text-black hover:bg-black/5","aria-label":"\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E1B\u0E35",children:[ie,jsx(c,{className:w??"text-blue-500 w-3 h-3"})]})}),jsx(r.Portal,{children:jsxs(r.Content,{sideOffset:6,align:"start",children:[jsx(fe,{years:ce,activeYear:C,labelFromYear:a=>P?a+543:a,onSelect:me}),jsx(r.Arrow,{className:"fill-white stroke-black/10"})]})})]})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",className:"rounded-md p-2 text-black/70 hover:bg-black/5",onClick:()=>k(W(D,-1)),"aria-label":m==="th"?"\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32":"Previous month",children:jsx(d,{className:w??"text-blue-500 w-3 h-3"})}),jsx("button",{type:"button",className:"rounded-md p-2 text-black/70 hover:bg-black/5",onClick:()=>k(W(D,1)),"aria-label":m==="th"?"\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E16\u0E31\u0E14\u0E44\u0E1B":"Next month",children:jsx(e,{className:w??"text-blue-500 w-3 h-3"})})]})]}),jsx("div",{className:"mt-1 grid grid-cols-7 gap-y-1 px-1 text-center text-xs text-black/50",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:(m==="th"?G:J).map(a=>jsx("div",{className:"h-7 leading-7 whitespace-nowrap",children:a},a))}),jsx("div",{className:"grid grid-cols-7 gap-1 px-1 pb-1 pt-1",style:{gridTemplateColumns:"repeat(7, minmax(0, 1fr))"},children:le.map((a,b)=>{let v=a.getMonth()===x,y=n&&a<new Date(n.getFullYear(),n.getMonth(),n.getDate())||u&&a>new Date(u.getFullYear(),u.getMonth(),u.getDate()),f=q(a,g),be=q(a,new Date);return jsx(ve,{d:a,inMonth:v,disabled:!!y,selected:f,isToday:be,onPick:de,dayClassName:z,outsideDayClassName:X,selectedDayClassName:U,todayClassName:Q},b)})}),jsx(r.Arrow,{className:"fill-white stroke-black/10"})]})})]})]})}),Ne=s.memo(De);export{Ne as default};
@@ -0,0 +1,22 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type District = {
4
+ id: string;
5
+ name_th: string;
6
+ name_en: string;
7
+ province_id: number;
8
+ };
9
+ type DistrictProps = {
10
+ locale?: "en" | "th";
11
+ searchPlaceholder?: string;
12
+ placeholder?: string;
13
+ label?: string;
14
+ searchButtonClassName?: string;
15
+ onChange?: (district: District) => void;
16
+ value?: string;
17
+ required?: boolean;
18
+ provinceId: number;
19
+ };
20
+ declare const DistrictDropdown: ({ locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required, provinceId }: DistrictProps) => react_jsx_runtime.JSX.Element;
21
+
22
+ export { type District, type DistrictProps, DistrictDropdown as default };
@@ -0,0 +1,2 @@
1
+ import {a}from'../chunk-4EUEP2BS.js';import'../chunk-HDRQQXSB.js';import'../chunk-VJRZAASL.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-Y3MG7XXZ.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var S=(t,s)=>s==="en"?{id:t.id,name:t.name_en,value:t.id,label:t.name_en}:{id:t.id,name:t.name_th,value:t.id,label:t.name_th},P=async t=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/district.json")).json()).filter(a=>a.province_id===t),w=({locale:t="th",searchPlaceholder:s="Search District",placeholder:c="Select District",label:l,searchButtonClassName:a$1="bg-blue-500",onChange:f,value:n,required:D=false,provinceId:o})=>{let[i,g]=useState([]),[b,d]=useState(null);useEffect(()=>{o&&P(o).then(g);},[o]),useEffect(()=>{if(n){let e=i.find(r=>t==="th"?r.name_th===n:r.name_en===n);e&&d(e);}},[i,n,t]);let _=useCallback(e=>{let r=i.find(v=>v.id===e);r&&(d(r),f?.(r));},[i]);return jsx("div",{children:jsx(a,{items:i.map(e=>S(e,t)),placeholder:s,triggerPlaceholder:c,label:l,selectionMode:"single",searchButtonClassName:a$1,onChange:e=>{typeof e=="string"&&_(e);},value:b?.id,required:D})})},x=w;
2
+ export{x as default};
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+
3
+ type LabelInputProps = {
4
+ required?: boolean;
5
+ label: string;
6
+ id?: string;
7
+ };
8
+ declare const LabelInput: React.ForwardRefExoticComponent<LabelInputProps & React.RefAttributes<HTMLDivElement>>;
9
+
10
+ export { LabelInput as default };
@@ -0,0 +1 @@
1
+ export{a as default}from'../chunk-DM45BGDQ.js';
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+
3
+ type ModalProps = {
4
+ open: boolean;
5
+ onClose?: () => void;
6
+ icon?: React.ReactNode;
7
+ title?: React.ReactNode;
8
+ description?: React.ReactNode;
9
+ footer?: React.ReactNode;
10
+ /** ปรับแต่ง */
11
+ wrapperClassName?: string;
12
+ contentClassName?: string;
13
+ showCloseX?: boolean;
14
+ closeOnEsc?: boolean;
15
+ closeOnOverlayClick?: boolean;
16
+ initialFocusRef?: React.RefObject<HTMLElement>;
17
+ children?: React.ReactNode;
18
+ };
19
+ declare function Modal({ open, onClose, icon, title, description, footer, wrapperClassName, contentClassName, showCloseX, closeOnEsc, closeOnOverlayClick, initialFocusRef, children, }: ModalProps): React.ReactPortal | null;
20
+
21
+ export { type ModalProps, Modal as default };
@@ -0,0 +1 @@
1
+ import {a}from'../chunk-Y3MG7XXZ.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};
@@ -0,0 +1,20 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type Province = {
4
+ id: string;
5
+ name_th: string;
6
+ name_en: string;
7
+ };
8
+ type ProvinceProps = {
9
+ locale?: "en" | "th";
10
+ searchPlaceholder?: string;
11
+ placeholder?: string;
12
+ label?: string;
13
+ searchButtonClassName?: string;
14
+ onChange?: (province: Province) => void;
15
+ value?: string;
16
+ required?: boolean;
17
+ };
18
+ declare const ProvinceDropdown: ({ locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required }: ProvinceProps) => react_jsx_runtime.JSX.Element;
19
+
20
+ export { type Province, type ProvinceProps, ProvinceDropdown as default };
@@ -0,0 +1,2 @@
1
+ import {a}from'../chunk-4EUEP2BS.js';import'../chunk-HDRQQXSB.js';import'../chunk-VJRZAASL.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-Y3MG7XXZ.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var C=(e,o)=>o==="en"?{id:e.id,name:e.name_en,value:e.id,label:e.name_en}:{id:e.id,name:e.name_th,value:e.id,label:e.name_th},S=async()=>await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province.json")).json(),w=({locale:e="th",searchPlaceholder:o="Search Province",placeholder:h="Select Province",label:u,searchButtonClassName:P="bg-blue-500",onChange:m,value:i,required:f=false})=>{let[r,v]=useState([]),[p,s]=useState(null);useEffect(()=>{S().then(v);},[]),useEffect(()=>{if(i){let n=r.find(t=>e==="th"?t.name_th===i:t.name_en===i);n&&s(n);}},[r,i,e]);let g=useCallback(n=>{let t=r.find(b=>b.id===n);t&&(s(t),m?.(t));},[r]);return jsx("div",{children:jsx(a,{items:r.map(n=>C(n,e)),placeholder:o,triggerPlaceholder:h,label:u,selectionMode:"single",searchButtonClassName:P,onChange:n=>{typeof n=="string"&&g(n);},value:p?.id,required:f})})},x=w;
2
+ export{x as default};
@@ -0,0 +1,46 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import Button from './button.js';
4
+ import 'class-variance-authority/types';
5
+ import 'class-variance-authority';
6
+
7
+ type BaseItem = {
8
+ id: string;
9
+ label: React.ReactNode;
10
+ disabled?: boolean;
11
+ };
12
+ type ItemLike = string | BaseItem;
13
+ type Palette = "neutral" | "primary" | "red" | "green" | "blue" | "yellow" | "violet";
14
+ type SearchSelectProps = {
15
+ trigger?: React.ReactNode;
16
+ triggerLabel?: React.ReactNode;
17
+ triggerPlaceholder?: React.ReactNode;
18
+ items: ItemLike[];
19
+ selectionMode?: "single" | "multiple";
20
+ value?: string[] | string;
21
+ defaultValue?: string[] | string;
22
+ onChange?: (value: string[] | string) => void;
23
+ searchable?: boolean;
24
+ placeholder?: string;
25
+ searchButtonLabel?: React.ReactNode;
26
+ onQueryChange?: (q: string) => void;
27
+ onSearch?: (q: string) => void;
28
+ loading?: boolean;
29
+ emptyLabel?: React.ReactNode;
30
+ className?: string;
31
+ contentClassName?: string;
32
+ maxHeight?: number;
33
+ renderItem?: (item: BaseItem, active: boolean, selected: boolean) => React.ReactNode;
34
+ buttonColor?: React.ComponentProps<typeof Button>["color"];
35
+ searchButtonColor?: React.ComponentProps<typeof Button>["color"];
36
+ searchButtonClassName?: string;
37
+ checkedColor?: Palette;
38
+ checkedClassName?: string;
39
+ /** สรุปค่าที่เลือกบน trigger (ถ้าไม่ส่ง: single=label, multi="เลือก n รายการ") */
40
+ renderTriggerValue?: (selectedIds: string[], selectedItems: BaseItem[]) => React.ReactNode;
41
+ label?: string;
42
+ required?: boolean;
43
+ };
44
+ declare function SearchSelect({ trigger, triggerPlaceholder, items, selectionMode, value, defaultValue, onChange, searchable, placeholder, searchButtonLabel, onQueryChange, onSearch, loading, emptyLabel, contentClassName, maxHeight, renderItem, buttonColor, searchButtonColor, searchButtonClassName, checkedColor, checkedClassName, renderTriggerValue, label, required }: SearchSelectProps): react_jsx_runtime.JSX.Element;
45
+
46
+ export { type SearchSelectProps, SearchSelect as default };
@@ -0,0 +1 @@
1
+ export{a as default}from'../chunk-4EUEP2BS.js';import'../chunk-HDRQQXSB.js';import'../chunk-VJRZAASL.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-Y3MG7XXZ.js';
@@ -0,0 +1,22 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type SubDistrict = {
4
+ id: string;
5
+ name_th: string;
6
+ name_en: string;
7
+ district_id: number;
8
+ };
9
+ type SubDistrictProps = {
10
+ locale?: "en" | "th";
11
+ searchPlaceholder?: string;
12
+ placeholder?: string;
13
+ label?: string;
14
+ searchButtonClassName?: string;
15
+ onChange?: (district: SubDistrict) => void;
16
+ value?: string;
17
+ required?: boolean;
18
+ districtId: number;
19
+ };
20
+ declare const SubDistrictDropdown: ({ locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required, districtId }: SubDistrictProps) => react_jsx_runtime.JSX.Element;
21
+
22
+ export { type SubDistrict, type SubDistrictProps, SubDistrictDropdown as default };
@@ -0,0 +1,2 @@
1
+ import {a}from'../chunk-4EUEP2BS.js';import'../chunk-HDRQQXSB.js';import'../chunk-VJRZAASL.js';import'../chunk-AFEF2EXB.js';import'../chunk-DM45BGDQ.js';import'../chunk-Y3MG7XXZ.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var v=(t,s)=>s==="en"?{id:t.id,name:t.name_en,value:t.id,label:t.name_en}:{id:t.id,name:t.name_th,value:t.id,label:t.name_th},P=async t=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/sub_district.json")).json()).filter(a=>a.district_id===t),w=({locale:t="th",searchPlaceholder:s="Search District",placeholder:c="Select District",label:l,searchButtonClassName:a$1="bg-blue-500",onChange:p,value:n,required:b=false,districtId:o})=>{let[r,S]=useState([]),[g,d]=useState(null);useEffect(()=>{o&&P(o).then(S);},[o]),useEffect(()=>{if(n){let e=r.find(i=>t==="th"?i.name_th===n:i.name_en===n);e&&d(e);}},[r,n,t]);let D=useCallback(e=>{let i=r.find(_=>_.id===e);i&&(d(i),p?.(i));},[r]);return jsx("div",{children:jsx(a,{items:r.map(e=>v(e,t)),placeholder:s,triggerPlaceholder:c,label:l,selectionMode:"single",searchButtonClassName:a$1,onChange:e=>{typeof e=="string"&&D(e);},value:g?.id,required:b})})},x=w;
2
+ export{x as default};
@@ -0,0 +1,33 @@
1
+ import * as class_variance_authority_types from 'class-variance-authority/types';
2
+ import * as React from 'react';
3
+ import { VariantProps } from 'class-variance-authority';
4
+
5
+ /**
6
+ * TextInput
7
+ * - size: sm | md | lg
8
+ * - tone: neutral | success | danger | warning | info
9
+ * - withStart / withEnd: เพิ่ม padding ให้ input เมื่อมี prefix/suffix
10
+ * - error: ใส่ data-state="invalid" อัตโนมัติ (ช่วยเขียน CSS เพิ่มได้ถ้าต้องการ)
11
+ *
12
+ * หมายเหตุ:
13
+ * - อยากปรับสีเอง ใช้ className เช่น "border-rose-600 focus-visible:ring-rose-300"
14
+ * className จะ override โทนเดิมให้โดยอัตโนมัติ (ผ่าน twMerge ใน cn)
15
+ */
16
+ declare const inputStyles: (props?: ({
17
+ size?: "sm" | "md" | "lg" | null | undefined;
18
+ tone?: "neutral" | "success" | "danger" | "warning" | "info" | null | undefined;
19
+ withStart?: boolean | null | undefined;
20
+ withEnd?: boolean | null | undefined;
21
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
22
+ interface TextInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">, VariantProps<typeof inputStyles> {
23
+ /** องค์ประกอบด้านซ้าย เช่น ไอคอน */
24
+ start?: React.ReactNode;
25
+ /** องค์ประกอบด้านขวา เช่น ปุ่ม clear / ไอคอน */
26
+ end?: React.ReactNode;
27
+ /** แสดงเป็นสถานะ error (ใส่ data-state="invalid") */
28
+ error?: string;
29
+ label?: string;
30
+ }
31
+ declare const TextInput: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<HTMLInputElement>>;
32
+
33
+ export { type TextInputProps, TextInput as default };
@@ -0,0 +1 @@
1
+ export{a as default}from'../chunk-HDRQQXSB.js';import'../chunk-DM45BGDQ.js';import'../chunk-Y3MG7XXZ.js';
@@ -1 +1 @@
1
- import {a}from'../chunk-QXOY2OGU.js';import {a as a$1}from'../chunk-Y3MG7XXZ.js';import*as e from'react';import*as o from'@radix-ui/react-switch';import {jsx,jsxs}from'react/jsx-runtime';var N={sm:{track:"h-[20px] w-[36px] p-[2px] rounded-full",thumb:"h-[16px] w-[16px] rounded-full"},md:{track:"h-[24px] w-[44px] p-[2px] rounded-full",thumb:"h-[20px] w-[20px] rounded-full"},lg:{track:"h-[28px] w-[56px] p-[2px] rounded-full",thumb:"h-[24px] w-[24px] rounded-full"}},S=e.memo(function({label:t,required:r}){return t==null?null:jsx(a,{label:t,required:r})}),u=e.forwardRef(function({checked:t,defaultChecked:r,onCheckedChange:s,disabled:n=false,id:b,size:m="md",label:p,labelPosition:f="right",className:g,trackClassName:h,thumbClassName:x,required:w},k){let i=N[m],y=e.useCallback(R=>s?.(R),[s]),C=e.useMemo(()=>a$1("inline-flex shrink-0 items-center transition-all duration-200 disabled:bg-gray-300 disabled:cursor-not-allowed disabled:opacity-50","data-[state=unchecked]:justify-start data-[state=checked]:justify-end","focus:outline-none focus-visible:ring-2 ring-black/20 disabled:cursor-not-allowed disabled:opacity-50",{"bg-blue-500":t,"bg-gray-300":!t}),[t]);return jsxs("label",{className:a$1("inline-flex select-none items-center gap-3",f==="left"&&"flex-row-reverse justify-end",g),children:[jsx(o.Root,{ref:k,id:b,checked:t,defaultChecked:r,onCheckedChange:y,disabled:n,className:a$1(C,i.track,h),children:jsx(o.Thumb,{"aria-disabled":n,className:a$1("bg-white shadow-sm transition-transform duration-200",i.thumb,x)})}),jsx(S,{label:p,required:w})]})});u.displayName="Toggle";var T=e.memo(u);export{T as default};
1
+ import {a}from'../chunk-DM45BGDQ.js';import {a as a$1}from'../chunk-Y3MG7XXZ.js';import*as e from'react';import*as o from'@radix-ui/react-switch';import {jsx,jsxs}from'react/jsx-runtime';var N={sm:{track:"h-[20px] w-[36px] p-[2px] rounded-full",thumb:"h-[16px] w-[16px] rounded-full"},md:{track:"h-[24px] w-[44px] p-[2px] rounded-full",thumb:"h-[20px] w-[20px] rounded-full"},lg:{track:"h-[28px] w-[56px] p-[2px] rounded-full",thumb:"h-[24px] w-[24px] rounded-full"}},S=e.memo(function({label:t,required:r}){return t==null?null:jsx(a,{label:t,required:r})}),u=e.forwardRef(function({checked:t,defaultChecked:r,onCheckedChange:s,disabled:n=false,id:b,size:m="md",label:p,labelPosition:f="right",className:g,trackClassName:h,thumbClassName:x,required:w},k){let i=N[m],y=e.useCallback(R=>s?.(R),[s]),C=e.useMemo(()=>a$1("inline-flex shrink-0 items-center transition-all duration-200 disabled:bg-gray-300 disabled:cursor-not-allowed disabled:opacity-50","data-[state=unchecked]:justify-start data-[state=checked]:justify-end","focus:outline-none focus-visible:ring-2 ring-black/20 disabled:cursor-not-allowed disabled:opacity-50",{"bg-blue-500":t,"bg-gray-300":!t}),[t]);return jsxs("label",{className:a$1("inline-flex select-none items-center gap-3",f==="left"&&"flex-row-reverse justify-end",g),children:[jsx(o.Root,{ref:k,id:b,checked:t,defaultChecked:r,onCheckedChange:y,disabled:n,className:a$1(C,i.track,h),children:jsx(o.Thumb,{"aria-disabled":n,className:a$1("bg-white shadow-sm transition-transform duration-200",i.thumb,x)})}),jsx(S,{label:p,required:w})]})});u.displayName="Toggle";var T=e.memo(u);export{T as default};
@@ -0,0 +1,38 @@
1
+ import * as class_variance_authority_types from 'class-variance-authority/types';
2
+ import { VariantProps } from 'class-variance-authority';
3
+ import Button from './button.js';
4
+ import 'react';
5
+
6
+ declare const iconWrapper: (props?: ({
7
+ iconColor?: "neutral" | "primary" | "red" | "green" | "blue" | "yellow" | "violet" | null | undefined;
8
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
9
+ interface UploadImageProps extends VariantProps<typeof iconWrapper> {
10
+ /** หัวข้อใหญ่กลางการ์ด */
11
+ title?: string;
12
+ /** ป้าย label มุมซ้ายบน (มี * ) */
13
+ label?: string;
14
+ /** เปลี่ยนสีปุ่ม (ยึดตาม Button ของคุณ) */
15
+ buttonColor?: React.ComponentProps<typeof Button>["color"];
16
+ /** ข้อความบนปุ่ม */
17
+ buttonLabel?: React.ReactNode;
18
+ /** ควบคุม input file */
19
+ accept?: string;
20
+ multiple?: boolean;
21
+ disabled?: boolean;
22
+ onFilesSelected?: (files: FileList) => void;
23
+ /** override class */
24
+ className?: string;
25
+ iconBgClassName?: string;
26
+ buttonClassName?: string;
27
+ /** ไอคอน (ถ้าไม่ส่ง ใช้ไอคอนดาวน์โหลดในตัว) */
28
+ icon?: React.ReactNode;
29
+ required?: boolean;
30
+ openCamera?: boolean;
31
+ openCameraButtonClassName?: string;
32
+ openCameraButtonLabel?: string;
33
+ value?: string;
34
+ error?: string;
35
+ }
36
+ declare const UploadImage: React.FC<UploadImageProps>;
37
+
38
+ export { type UploadImageProps, UploadImage as default };
@@ -0,0 +1 @@
1
+ import {a as a$2}from'../chunk-VJRZAASL.js';import {a as a$1}from'../chunk-DM45BGDQ.js';import {a}from'../chunk-Y3MG7XXZ.js';import {useRef,useCallback}from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var H=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"}}),v=({label:s,buttonLabel:x="Upload",buttonColor:c="primary",iconColor:C,iconBgClassName:N,buttonClassName:k,openCameraButtonClassName:y,openCameraButtonLabel:w="Open Camera",className:I,icon:R,accept:m,multiple:d,disabled:r,onFilesSelected:p,required:L,value:u,title:B="Upload Image",error:o})=>{let n=useRef(null),a$3=useRef(null),U=()=>n.current?.click(),M=useCallback(()=>{a$3.current&&a$3.current.click();},[]),g=f=>{f.target.files&&p&&p(f.target.files),n.current&&(n.current.value=""),a$3.current&&(a$3.current.value="");};return jsxs("div",{className:a("space-y-2",I),children:[s&&jsx(a$1,{label:s,required:L}),jsxs("div",{className:a("rounded-lg border border-dashed bg-white p-6 sm:p-8",o?"border-red-500":"border-black/20"),role:"group",children:[u?jsx("div",{className:"flex justify-center max-w-3/4 md:max-w-2/4 mx-auto",children:jsx("img",{src:u,alt:"Uploaded Image"})}):jsx("div",{className:a(H({iconColor:C}),N),children:R??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"})})}),jsx("h3",{className:"mt-4 text-center text-xl font-extrabold text-black",children:B}),jsxs("div",{className:"mt-6 flex justify-center gap-2",children:[jsx(a$2,{onClick:M,color:c,className:a("min-w-[180px]",y),disabled:r,size:"lg",variant:"outline",children:w}),jsx(a$2,{onClick:U,color:c,className:a("min-w-[180px]",k),disabled:r,size:"lg",children:x}),jsx("input",{ref:n,type:"file",className:"hidden",accept:m,multiple:d,onChange:g,disabled:r}),jsx("input",{ref:a$3,type:"file",className:"hidden",capture:true,accept:m,multiple:d,onChange:g,disabled:r})]})]}),o&&jsx("small",{className:"text-red-500 text-xs",children:o})]})};v.displayName="UploadImage";var j=v;export{j as default};
package/dist/index.d.ts CHANGED
@@ -1,206 +1,2 @@
1
- import * as class_variance_authority_types from 'class-variance-authority/types';
2
- import * as React$1 from 'react';
3
- import { VariantProps } from 'class-variance-authority';
4
- import * as react_jsx_runtime from 'react/jsx-runtime';
5
1
 
6
- /**
7
- * variant: solid | outline | ghost
8
- * color: neutral | primary | red | green | blue | yellow | violet
9
- * size: sm | md | lg
10
- *
11
- * หมายเหตุ:
12
- * - สามารถ override สีพื้นหลัง/เส้นขอบด้วย className เช่น "bg-rose-600 hover:bg-rose-700"
13
- * โดย className จะมากลบของเดิม (twMerge)
14
- */
15
- declare const buttonStyles: (props?: ({
16
- variant?: "solid" | "outline" | "ghost" | null | undefined;
17
- size?: "sm" | "md" | "lg" | null | undefined;
18
- color?: "neutral" | "primary" | "red" | "green" | "blue" | "yellow" | "violet" | null | undefined;
19
- } & class_variance_authority_types.ClassProp) | undefined) => string;
20
- interface ButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonStyles> {
21
- asChild?: boolean;
22
- color?: "neutral" | "primary" | "red" | "green" | "blue" | "yellow" | "violet";
23
- size?: "sm" | "md" | "lg";
24
- }
25
- declare const Button: React$1.ForwardRefExoticComponent<ButtonProps & React$1.RefAttributes<HTMLButtonElement>>;
26
-
27
- /**
28
- * TextInput
29
- * - size: sm | md | lg
30
- * - tone: neutral | success | danger | warning | info
31
- * - withStart / withEnd: เพิ่ม padding ให้ input เมื่อมี prefix/suffix
32
- * - error: ใส่ data-state="invalid" อัตโนมัติ (ช่วยเขียน CSS เพิ่มได้ถ้าต้องการ)
33
- *
34
- * หมายเหตุ:
35
- * - อยากปรับสีเอง ใช้ className เช่น "border-rose-600 focus-visible:ring-rose-300"
36
- * className จะ override โทนเดิมให้โดยอัตโนมัติ (ผ่าน twMerge ใน cn)
37
- */
38
- declare const inputStyles: (props?: ({
39
- size?: "sm" | "md" | "lg" | null | undefined;
40
- tone?: "neutral" | "success" | "danger" | "warning" | "info" | null | undefined;
41
- withStart?: boolean | null | undefined;
42
- withEnd?: boolean | null | undefined;
43
- } & class_variance_authority_types.ClassProp) | undefined) => string;
44
- interface TextInputProps extends Omit<React$1.InputHTMLAttributes<HTMLInputElement>, "size">, VariantProps<typeof inputStyles> {
45
- /** องค์ประกอบด้านซ้าย เช่น ไอคอน */
46
- start?: React$1.ReactNode;
47
- /** องค์ประกอบด้านขวา เช่น ปุ่ม clear / ไอคอน */
48
- end?: React$1.ReactNode;
49
- /** แสดงเป็นสถานะ error (ใส่ data-state="invalid") */
50
- error?: string;
51
- label?: string;
52
- }
53
- declare const TextInput: React$1.ForwardRefExoticComponent<TextInputProps & React$1.RefAttributes<HTMLInputElement>>;
54
-
55
- declare const iconWrapper: (props?: ({
56
- iconColor?: "neutral" | "primary" | "red" | "green" | "blue" | "yellow" | "violet" | null | undefined;
57
- } & class_variance_authority_types.ClassProp) | undefined) => string;
58
- interface UploadImageProps extends VariantProps<typeof iconWrapper> {
59
- /** หัวข้อใหญ่กลางการ์ด */
60
- title?: string;
61
- /** ป้าย label มุมซ้ายบน (มี * ) */
62
- label?: string;
63
- /** เปลี่ยนสีปุ่ม (ยึดตาม Button ของคุณ) */
64
- buttonColor?: React.ComponentProps<typeof Button>["color"];
65
- /** ข้อความบนปุ่ม */
66
- buttonLabel?: React.ReactNode;
67
- /** ควบคุม input file */
68
- accept?: string;
69
- multiple?: boolean;
70
- disabled?: boolean;
71
- onFilesSelected?: (files: FileList) => void;
72
- /** override class */
73
- className?: string;
74
- iconBgClassName?: string;
75
- buttonClassName?: string;
76
- /** ไอคอน (ถ้าไม่ส่ง ใช้ไอคอนดาวน์โหลดในตัว) */
77
- icon?: React.ReactNode;
78
- required?: boolean;
79
- openCamera?: boolean;
80
- openCameraButtonClassName?: string;
81
- openCameraButtonLabel?: string;
82
- value?: string;
83
- error?: string;
84
- }
85
- declare const UploadImage: React.FC<UploadImageProps>;
86
-
87
- type LabelInputProps = {
88
- required?: boolean;
89
- label: string;
90
- id?: string;
91
- };
92
- declare const LabelInput: React$1.ForwardRefExoticComponent<LabelInputProps & React$1.RefAttributes<HTMLDivElement>>;
93
-
94
- type BaseItem = {
95
- id: string;
96
- label: React$1.ReactNode;
97
- disabled?: boolean;
98
- };
99
- type ItemLike = string | BaseItem;
100
- type Palette = "neutral" | "primary" | "red" | "green" | "blue" | "yellow" | "violet";
101
- type SearchSelectProps = {
102
- trigger?: React$1.ReactNode;
103
- triggerLabel?: React$1.ReactNode;
104
- triggerPlaceholder?: React$1.ReactNode;
105
- items: ItemLike[];
106
- selectionMode?: "single" | "multiple";
107
- value?: string[] | string;
108
- defaultValue?: string[] | string;
109
- onChange?: (value: string[] | string) => void;
110
- searchable?: boolean;
111
- placeholder?: string;
112
- searchButtonLabel?: React$1.ReactNode;
113
- onQueryChange?: (q: string) => void;
114
- onSearch?: (q: string) => void;
115
- loading?: boolean;
116
- emptyLabel?: React$1.ReactNode;
117
- className?: string;
118
- contentClassName?: string;
119
- maxHeight?: number;
120
- renderItem?: (item: BaseItem, active: boolean, selected: boolean) => React$1.ReactNode;
121
- buttonColor?: React$1.ComponentProps<typeof Button>["color"];
122
- searchButtonColor?: React$1.ComponentProps<typeof Button>["color"];
123
- searchButtonClassName?: string;
124
- checkedColor?: Palette;
125
- checkedClassName?: string;
126
- /** สรุปค่าที่เลือกบน trigger (ถ้าไม่ส่ง: single=label, multi="เลือก n รายการ") */
127
- renderTriggerValue?: (selectedIds: string[], selectedItems: BaseItem[]) => React$1.ReactNode;
128
- label?: string;
129
- required?: boolean;
130
- };
131
- declare function SearchSelect({ trigger, triggerPlaceholder, items, selectionMode, value, defaultValue, onChange, searchable, placeholder, searchButtonLabel, onQueryChange, onSearch, loading, emptyLabel, contentClassName, maxHeight, renderItem, buttonColor, searchButtonColor, searchButtonClassName, checkedColor, checkedClassName, renderTriggerValue, label, required }: SearchSelectProps): react_jsx_runtime.JSX.Element;
132
-
133
- type District = {
134
- id: string;
135
- name_th: string;
136
- name_en: string;
137
- province_id: number;
138
- };
139
- type DistrictProps = {
140
- locale?: "en" | "th";
141
- searchPlaceholder?: string;
142
- placeholder?: string;
143
- label?: string;
144
- searchButtonClassName?: string;
145
- onChange?: (district: District) => void;
146
- value?: string;
147
- required?: boolean;
148
- provinceId: number;
149
- };
150
- declare const DistrictDropdown: ({ locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required, provinceId }: DistrictProps) => react_jsx_runtime.JSX.Element;
151
-
152
- type Province = {
153
- id: string;
154
- name_th: string;
155
- name_en: string;
156
- };
157
- type ProvinceProps = {
158
- locale?: "en" | "th";
159
- searchPlaceholder?: string;
160
- placeholder?: string;
161
- label?: string;
162
- searchButtonClassName?: string;
163
- onChange?: (province: Province) => void;
164
- value?: string;
165
- required?: boolean;
166
- };
167
- declare const ProvinceDropdown: ({ locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required }: ProvinceProps) => react_jsx_runtime.JSX.Element;
168
-
169
- type SubDistrict = {
170
- id: string;
171
- name_th: string;
172
- name_en: string;
173
- district_id: number;
174
- };
175
- type SubDistrictProps = {
176
- locale?: "en" | "th";
177
- searchPlaceholder?: string;
178
- placeholder?: string;
179
- label?: string;
180
- searchButtonClassName?: string;
181
- onChange?: (district: SubDistrict) => void;
182
- value?: string;
183
- required?: boolean;
184
- districtId: number;
185
- };
186
- declare const SubDistrictDropdown: ({ locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required, districtId }: SubDistrictProps) => react_jsx_runtime.JSX.Element;
187
-
188
- type ModalProps = {
189
- open: boolean;
190
- onClose?: () => void;
191
- icon?: React$1.ReactNode;
192
- title?: React$1.ReactNode;
193
- description?: React$1.ReactNode;
194
- footer?: React$1.ReactNode;
195
- /** ปรับแต่ง */
196
- wrapperClassName?: string;
197
- contentClassName?: string;
198
- showCloseX?: boolean;
199
- closeOnEsc?: boolean;
200
- closeOnOverlayClick?: boolean;
201
- initialFocusRef?: React$1.RefObject<HTMLElement>;
202
- children?: React$1.ReactNode;
203
- };
204
- declare function Modal({ open, onClose, icon, title, description, footer, wrapperClassName, contentClassName, showCloseX, closeOnEsc, closeOnOverlayClick, initialFocusRef, children, }: ModalProps): React$1.ReactPortal | null;
205
-
206
- export { Button, type ButtonProps, type District, DistrictDropdown, type DistrictProps, LabelInput, Modal, type ModalProps, type Province, ProvinceDropdown, type ProvinceProps, SearchSelect, type SearchSelectProps, type SubDistrict, SubDistrictDropdown, type SubDistrictProps, TextInput, type TextInputProps, UploadImage, type UploadImageProps };
2
+ export { }
package/dist/index.js CHANGED
@@ -1,2 +0,0 @@
1
- import {f,b}from'./chunk-AFEF2EXB.js';import {a as a$1}from'./chunk-QXOY2OGU.js';export{a as LabelInput}from'./chunk-QXOY2OGU.js';import {a}from'./chunk-Y3MG7XXZ.js';import*as N from'react';import {useRef,useCallback,useState,useEffect}from'react';import {Slot}from'@radix-ui/react-slot';import {cva}from'class-variance-authority';import {jsx,jsxs}from'react/jsx-runtime';import*as D from'@radix-ui/react-popover';import {createPortal}from'react-dom';var Re=cva("inline-flex items-center justify-center rounded-md font-medium outline-none text-[18px] cursor-pointertransition-colors focus-visible:ring-2 ring-black/20 disabled:pointer-events-none disabled:bg-[#EBEBEB] disabled:text-[#878787]",{variants:{variant:{solid:"",outline:"border bg-transparent border-[#C9D7E3]",ghost:"bg-transparent"},size:{sm:"h-8 px-2 py-3 text-sm",md:"h-10 px-2 py-3 text-md",lg:"h-12 px-2 py-4 text-xl"},color:{neutral:"",primary:"",red:"",green:"",blue:"",yellow:"",violet:""}},compoundVariants:[{variant:"solid",color:"neutral",class:"bg-neutral-900 text-white hover:dark:bg-neutral-800"},{variant:"solid",color:"primary",class:"bg-black text-white hover:bg-black/85"},{variant:"solid",color:"red",class:"bg-red-600 text-white hover:bg-red-700"},{variant:"solid",color:"green",class:"bg-green-600 text-white hover:bg-green-700"},{variant:"solid",color:"blue",class:"bg-blue-600 text-white hover:bg-blue-700"},{variant:"solid",color:"yellow",class:"bg-yellow-500 text-black hover:bg-yellow-600"},{variant:"solid",color:"violet",class:"bg-violet-600 text-white hover:bg-violet-700"},{variant:"outline",color:"neutral",class:"border-[#C9D7E3] text-neutral-900 hover:bg-neutral-50"},{variant:"outline",color:"primary",class:"border-[#C9D7E3] text-black hover:bg-black/[0.06]"},{variant:"outline",color:"red",class:"border-red-600 text-red-700 hover:bg-red-50"},{variant:"outline",color:"green",class:"border-green-600 text-green-700 hover:bg-green-50"},{variant:"outline",color:"blue",class:"border-blue-600 text-blue-700 hover:bg-blue-50"},{variant:"outline",color:"yellow",class:"border-yellow-500 text-yellow-700 hover:bg-yellow-50"},{variant:"outline",color:"violet",class:"border-violet-600 text-violet-700 hover:bg-violet-50"},{variant:"ghost",color:"neutral",class:"text-neutral-900 hover:bg-neutral-50"},{variant:"ghost",color:"primary",class:"text-black hover:bg-black/[0.06]"},{variant:"ghost",color:"red",class:"text-red-700 hover:bg-red-50"},{variant:"ghost",color:"green",class:"text-green-700 hover:bg-green-50"},{variant:"ghost",color:"blue",class:"text-blue-700 hover:bg-blue-50"},{variant:"ghost",color:"yellow",class:"text-yellow-700 hover:bg-yellow-50"},{variant:"ghost",color:"violet",class:"text-violet-700 hover:bg-violet-50"}],defaultVariants:{variant:"solid",size:"md",color:"primary"}}),_=N.forwardRef(({className:e,variant:r,size:a$1,color:o,asChild:i,...f},s)=>jsx(i?Slot:"button",{ref:s,className:a(Re({variant:r,size:a$1,color:o}),e),...f}));_.displayName="Button";var Be=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-10 px-2 py-3 text-sm",md:"h-12 px-2 py-4 text-md",lg:"h-14 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"}}),K=N.forwardRef(({className:e,start:r,end:a$2,size:o,tone:i,withStart:f,withEnd:s,error:b,label:c,required:d,disabled:v=false,...h},u)=>jsxs("fieldset",{className:"relative flex flex-col gap-2 items-start text-start",children:[c&&jsx(a$1,{label:c,required:d}),r?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:r})}):null,jsx("input",{ref:u,"data-state":b?"invalid":void 0,className:a(Be({size:o,tone:b?"danger":i,withStart:f??!!r,withEnd:s??!!a$2}),e),disabled:v,...h}),a$2?jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pe-3",children:a$2}):null,b&&jsx("small",{className:"text-red-500 text-xs",children:b})]}));K.displayName="TextInput";var Me=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"}}),Ie=({label:e,buttonLabel:r="Upload",buttonColor:a$2="primary",iconColor:o,iconBgClassName:i,buttonClassName:f,openCameraButtonClassName:s,openCameraButtonLabel:b="Open Camera",className:c,icon:d,accept:v,multiple:h,disabled:u,onFilesSelected:m,required:t,value:l,title:R="Upload Image",error:E})=>{let M=useRef(null),P=useRef(null),w=()=>M.current?.click(),T=useCallback(()=>{P.current&&P.current.click();},[]),S=I=>{I.target.files&&m&&m(I.target.files),M.current&&(M.current.value=""),P.current&&(P.current.value="");};return jsxs("div",{className:a("space-y-2",c),children:[e&&jsx(a$1,{label:e,required:t}),jsxs("div",{className:a("rounded-lg border border-dashed bg-white p-6 sm:p-8",E?"border-red-500":"border-black/20"),role:"group",children:[l?jsx("div",{className:"flex justify-center max-w-3/4 md:max-w-2/4 mx-auto",children:jsx("img",{src:l,alt:"Uploaded Image"})}):jsx("div",{className:a(Me({iconColor:o}),i),children:d??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"})})}),jsx("h3",{className:"mt-4 text-center text-xl font-extrabold text-black",children:R}),jsxs("div",{className:"mt-6 flex justify-center gap-2",children:[jsx(_,{onClick:T,color:a$2,className:a("min-w-[180px]",s),disabled:u,size:"lg",variant:"outline",children:b}),jsx(_,{onClick:w,color:a$2,className:a("min-w-[180px]",f),disabled:u,size:"lg",children:r}),jsx("input",{ref:M,type:"file",className:"hidden",accept:v,multiple:h,onChange:S,disabled:u}),jsx("input",{ref:P,type:"file",className:"hidden",capture:true,accept:v,multiple:h,onChange:S,disabled:u})]})]}),E&&jsx("small",{className:"text-red-500 text-xs",children:E})]})};Ie.displayName="UploadImage";function _e(e){return typeof e=="string"?{id:e,label:e}:e}var Te={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 z({trigger:e,triggerPlaceholder:r="Choose",items:a$2,selectionMode:o="multiple",value:i,defaultValue:f$1,onChange:s,searchable:b$1=true,placeholder:c="Placeholder Text",searchButtonLabel:d="Search",onQueryChange:v,onSearch:h,loading:u=false,emptyLabel:m="No results",contentClassName:t,maxHeight:l=288,renderItem:R,buttonColor:E="primary",searchButtonColor:M,searchButtonClassName:P,checkedColor:w="primary",checkedClassName:T,renderTriggerValue:S,label:I,required:U}){let[j,$]=N.useState(false),[W,pe]=N.useState(""),[F,be]=N.useState(""),B=o==="multiple",[ge,fe]=N.useState(f$1??(B?[]:"")),k=i??ge,A=N.useMemo(()=>a$2.map(_e),[a$2]),G=N.useMemo(()=>{let n=F.trim().toLowerCase();return n?A.filter(x=>String(x.label).toLowerCase().includes(n)):A},[A,F]),J=n=>{s?.(n),i===void 0&&fe(n);},he=n=>{if(B){let x=new Set(k);x.has(n)?x.delete(n):x.add(n),J(Array.from(x));}else J(n),$(false);},ve=n=>B?k.includes(n):k===n,xe=()=>{be(W),h?.(W);},Q=N.useMemo(()=>B?k:k?[k]:[],[k,B]),O=N.useMemo(()=>A.filter(n=>Q.includes(n.id)),[A,Q]),ye=N.useMemo(()=>O.length===0?r:B?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${O.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:O[0].label,[O,B,r]);return jsxs(D.Root,{open:j,onOpenChange:$,children:[I&&jsx(a$1,{label:I,required:U}),jsx("div",{className:"mb-2"}),jsx(D.Trigger,{asChild:true,children:e??jsxs("button",{type:"button",className:a("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"),children:[jsx("span",{className:a("flex-1 ",{"text-gray-400":B?k?.length===0:!k,"text-black":B?k?.length>0:!!k}),children:S?S(Q,O):ye}),jsx("svg",{className:a("ml-3 h-5 w-5 text-black/60 transition-transform",j?"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(D.Portal,{children:jsxs(D.Content,{sideOffset:8,className:a("w-[420px] rounded-md border border-black/10 bg-white p-2 shadow-xl",t),children:[b$1&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:n=>{n.preventDefault(),xe();},children:[jsx(K,{start:jsx(f,{className:"h-3 w-3 text-black/50"}),value:W,onChange:n=>{pe(n.currentTarget.value),v?.(n.currentTarget.value);},size:"sm",placeholder:c}),jsx(_,{color:M??E,type:"submit",disabled:u||W.trim()===F.trim(),size:"md",className:P,children:d})]}),jsxs("div",{role:"listbox","aria-multiselectable":B||void 0,className:a(" overflow-y-auto rounded-md",{"mt-3":b$1}),style:{maxHeight:l},children:[u&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),!u&&G.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:m}),!u&&G.map(n=>{let x=ve(n.id),we=Te[w],ke=jsxs(_,{type:"button",role:"option","aria-selected":x,onClick:()=>he(n.id),disabled:n.disabled,size:"sm",className:a("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]":x&&o==="single"}),children:[jsx("span",{className:"text-md text-black",children:n.label}),o==="multiple"&&jsx("span",{className:a("grid h-5 w-5 place-items-center rounded-full border-2",x?we:"border-black/20",x&&T),children:x?jsx(b,{className:"h-2 w-2"}):null})]},n.id);return R?jsx("div",{children:R(n,false,x)},n.id):ke})]}),jsx(D.Arrow,{className:"fill-white stroke-black/10"})]})})]})}var qe=(e,r)=>r==="en"?{id:e.id,name:e.name_en,value:e.id,label:e.name_en}:{id:e.id,name:e.name_th,value:e.id,label:e.name_th},Ve=async e=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/district.json")).json()).filter(i=>i.province_id===e),yt=({locale:e="th",searchPlaceholder:r="Search District",placeholder:a="Select District",label:o,searchButtonClassName:i="bg-blue-500",onChange:f,value:s,required:b=false,provinceId:c})=>{let[d,v]=useState([]),[h,u]=useState(null);useEffect(()=>{c&&Ve(c).then(v);},[c]),useEffect(()=>{if(s){let t=d.find(l=>e==="th"?l.name_th===s:l.name_en===s);t&&u(t);}},[d,s,e]);let m=useCallback(t=>{let l=d.find(R=>R.id===t);l&&(u(l),f?.(l));},[d]);return jsx("div",{children:jsx(z,{items:d.map(t=>qe(t,e)),placeholder:r,triggerPlaceholder:a,label:o,selectionMode:"single",searchButtonClassName:i,onChange:t=>{typeof t=="string"&&m(t);},value:h?.id,required:b})})};var je=(e,r)=>r==="en"?{id:e.id,name:e.name_en,value:e.id,label:e.name_en}:{id:e.id,name:e.name_th,value:e.id,label:e.name_th},Ae=async()=>await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province.json")).json(),Rt=({locale:e="th",searchPlaceholder:r="Search Province",placeholder:a="Select Province",label:o,searchButtonClassName:i="bg-blue-500",onChange:f,value:s,required:b=false})=>{let[c,d]=useState([]),[v,h]=useState(null);useEffect(()=>{Ae().then(d);},[]),useEffect(()=>{if(s){let m=c.find(t=>e==="th"?t.name_th===s:t.name_en===s);m&&h(m);}},[c,s,e]);let u=useCallback(m=>{let t=c.find(l=>l.id===m);t&&(h(t),f?.(t));},[c]);return jsx("div",{children:jsx(z,{items:c.map(m=>je(m,e)),placeholder:r,triggerPlaceholder:a,label:o,selectionMode:"single",searchButtonClassName:i,onChange:m=>{typeof m=="string"&&u(m);},value:v?.id,required:b})})};var Ue=(e,r)=>r==="en"?{id:e.id,name:e.name_en,value:e.id,label:e.name_en}:{id:e.id,name:e.name_th,value:e.id,label:e.name_th},We=async e=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/sub_district.json")).json()).filter(i=>i.district_id===e),Et=({locale:e="th",searchPlaceholder:r="Search District",placeholder:a="Select District",label:o,searchButtonClassName:i="bg-blue-500",onChange:f,value:s,required:b=false,districtId:c})=>{let[d,v]=useState([]),[h,u]=useState(null);useEffect(()=>{c&&We(c).then(v);},[c]),useEffect(()=>{if(s){let t=d.find(l=>e==="th"?l.name_th===s:l.name_en===s);t&&u(t);}},[d,s,e]);let m=useCallback(t=>{let l=d.find(R=>R.id===t);l&&(u(l),f?.(l));},[d]);return jsx("div",{children:jsx(z,{items:d.map(t=>Ue(t,e)),placeholder:r,triggerPlaceholder:a,label:o,selectionMode:"single",searchButtonClassName:i,onChange:t=>{typeof t=="string"&&m(t);},value:h?.id,required:b})})};function Qe(e="ui-portal"){let[r,a]=N.useState(null);return N.useLayoutEffect(()=>{let o=document.getElementById(e);return o||(o=document.createElement("div"),o.id=e,document.body.appendChild(o)),a(o),()=>{o&&o.childElementCount===0&&o.remove();}},[e]),r}function Tt({open:e,onClose:r,icon:a$1,title:o,description:i,footer:f,wrapperClassName:s,contentClassName:b,showCloseX:c=false,closeOnEsc:d=true,closeOnOverlayClick:v=true,initialFocusRef:h,children:u}){let m=Qe(),t=N.useRef(null),l=N.useRef(null),R=N.useCallback(()=>{v&&r?.();},[v,r]);return N.useEffect(()=>{if(!e)return;l.current=document.activeElement??null;let E=document.body.style.overflow;document.body.style.overflow="hidden";let M=h?.current||t.current;requestAnimationFrame(()=>M?.focus());let P=w=>{if(w.key==="Escape"&&d&&(w.stopPropagation(),r?.()),w.key==="Tab"){let T=t.current;if(!T)return;let S=T.querySelectorAll('a[href],button,textarea,input,select,[tabindex]:not([tabindex="-1"])');if(!S.length)return;let I=S[0],U=S[S.length-1],j=document.activeElement;w.shiftKey&&j===I?(w.preventDefault(),U.focus()):!w.shiftKey&&j===U&&(w.preventDefault(),I.focus());}};return document.addEventListener("keydown",P),()=>{document.body.style.overflow=E,document.removeEventListener("keydown",P),l.current?.focus?.();}},[e,d,r,h]),!e||!m?null:createPortal(jsx("div",{className:a("fixed inset-0 z-[1000] grid place-items-center p-4 bg-black/60",s),onMouseDown:R,"aria-live":"polite",children:jsxs("div",{role:"dialog","aria-modal":"true",ref:t,tabIndex:-1,onMouseDown:E=>E.stopPropagation(),className:a("relative w-full max-w-[480px] rounded-2xl bg-white shadow-xl outline-none px-6 py-6",b),children:[c&&jsx("button",{"aria-label":"Close",onClick:r,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"})})}),(a$1||o||i)&&jsxs("div",{className:"text-center",children:[a$1&&jsx("div",{className:"mb-4 flex justify-center",children:a$1}),o&&jsx("h2",{className:"text-xl font-semibold text-black",children:o}),i&&jsx("p",{className:"mt-2 text-black/70",children:i})]}),u&&jsx("div",{className:"mt-4",children:u}),f&&jsx("div",{className:"mt-6 flex items-center justify-center gap-3",children:f})]})}),m)}
2
- export{_ as Button,yt as DistrictDropdown,Tt as Modal,Rt as ProvinceDropdown,z as SearchSelect,Et as SubDistrictDropdown,K as TextInput,Ie as UploadImage};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "the-omelet-ui",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
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 n=forwardRef(({required:l,label:t,id:a},r)=>jsx("div",{className:"flex items-center ",ref:r,children:jsxs("label",{className:"block text-sm text-[#444] font-bold",htmlFor:a,children:[l&&jsx("span",{className:"text-red-500",children:"*"}),t]})}));n.displayName="LabelInput";export{n as a};