the-omelet-ui 1.4.8 → 1.5.0

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$4}from'./chunk-KYNNMWQA.js';import {a as a$3}from'./chunk-WSPTQJ57.js';import {a as a$5}from'./chunk-IX36POX2.js';import {a as a$1}from'./chunk-DM45BGDQ.js';import {a as a$2}from'./chunk-6GLPXMGB.js';import*as a from'react';import*as l from'@radix-ui/react-popover';import {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};
@@ -25,4 +25,4 @@ interface AvatarProps extends Omit<HTMLAttributes<HTMLDivElement>, "children">,
25
25
  }
26
26
  declare const _default: React__default.NamedExoticComponent<AvatarProps & React__default.RefAttributes<HTMLDivElement>>;
27
27
 
28
- export { type AvatarProps, _default as default };
28
+ export { _default as Avatar, type AvatarProps };
@@ -1 +1 @@
1
- import {a}from'../chunk-6GLPXMGB.js';import R,{forwardRef,useState,useEffect}from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var C=cva("relative inline-flex items-center justify-center overflow-hidden rounded-full bg-black/5 text-black/50 select-none",{variants:{size:{sm:"h-8 w-8 text-xs",md:"h-10 w-10 text-sm",lg:"h-12 w-12 text-base",xl:"h-16 w-16 text-lg"},ringed:{true:"ring-2 ring-black/10",false:""}},defaultVariants:{size:"md",ringed:false}}),c=forwardRef(({className:u,imageClassName:f,size:m,ringed:g,src:t,defaultSrc:l,alt:v="",fallback:p,loadingIndicator:h,onImageLoad:x,onImageError:k,...y},b)=>{let[a$1,r]=useState("idle"),[o,s]=useState(t);useEffect(()=>{s(t),r(t?"loading":"error");},[t]);let w=()=>{r("loaded"),x?.();},L=()=>{if(l&&o!==l){s(l),r("loading");return}r("error"),k?.();},N=p??jsxs("svg",{className:"h-1/2 w-1/2",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[jsx("circle",{cx:"12",cy:"8",r:"4",stroke:"currentColor",strokeWidth:"2"}),jsx("path",{d:"M4 20c1.5-3.5 4.6-5 8-5s6.5 1.5 8 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),E=h??jsxs("svg",{className:"h-5 w-5 animate-spin",viewBox:"0 0 24 24","aria-hidden":"true",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),jsx("path",{className:"opacity-90",d:"M4 12a8 8 0 0 1 8-8",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",fill:"none"})]});return jsxs("div",{ref:b,className:a(C({size:m,ringed:g}),u),"aria-busy":a$1==="loading"||void 0,...y,children:[o?jsx("img",{src:o,alt:v,onLoad:w,onError:L,className:a("absolute inset-0 h-full w-full object-cover transition-opacity",a$1==="loaded"?"opacity-100":"opacity-0",f),draggable:false}):null,jsxs("div",{className:"relative flex h-full w-full items-center justify-center",children:[a$1==="loading"?E:null,a$1==="error"||!o?N:null]})]})});c.displayName="Avatar";var T=R.memo(c);export{T as default};
1
+ import {a}from'../chunk-6GLPXMGB.js';import R,{forwardRef,useState,useEffect}from'react';import {cva}from'class-variance-authority';import {jsxs,jsx}from'react/jsx-runtime';var C=cva("relative inline-flex items-center justify-center overflow-hidden rounded-full bg-black/5 text-black/50 select-none",{variants:{size:{sm:"h-8 w-8 text-xs",md:"h-10 w-10 text-sm",lg:"h-12 w-12 text-base",xl:"h-16 w-16 text-lg"},ringed:{true:"ring-2 ring-black/10",false:""}},defaultVariants:{size:"md",ringed:false}}),c=forwardRef(({className:u,imageClassName:f,size:m,ringed:g,src:t,defaultSrc:l,alt:v="",fallback:p,loadingIndicator:h,onImageLoad:x,onImageError:k,...y},b)=>{let[a$1,r]=useState("idle"),[o,s]=useState(t);useEffect(()=>{s(t),r(t?"loading":"error");},[t]);let w=()=>{r("loaded"),x?.();},L=()=>{if(l&&o!==l){s(l),r("loading");return}r("error"),k?.();},N=p??jsxs("svg",{className:"h-1/2 w-1/2",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[jsx("circle",{cx:"12",cy:"8",r:"4",stroke:"currentColor",strokeWidth:"2"}),jsx("path",{d:"M4 20c1.5-3.5 4.6-5 8-5s6.5 1.5 8 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),E=h??jsxs("svg",{className:"h-5 w-5 animate-spin",viewBox:"0 0 24 24","aria-hidden":"true",children:[jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),jsx("path",{className:"opacity-90",d:"M4 12a8 8 0 0 1 8-8",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",fill:"none"})]});return jsxs("div",{ref:b,className:a(C({size:m,ringed:g}),u),"aria-busy":a$1==="loading"||void 0,...y,children:[o?jsx("img",{src:o,alt:v,onLoad:w,onError:L,className:a("absolute inset-0 h-full w-full object-cover transition-opacity",a$1==="loaded"?"opacity-100":"opacity-0",f),draggable:false}):null,jsxs("div",{className:"relative flex h-full w-full items-center justify-center",children:[a$1==="loading"?E:null,a$1==="error"||!o?N:null]})]})});c.displayName="Avatar";var T=R.memo(c);export{T as Avatar};
@@ -16,7 +16,9 @@ type DistrictProps = {
16
16
  value?: string;
17
17
  required?: boolean;
18
18
  provinceId?: number;
19
+ /** เพิ่ม error message */
20
+ error?: string;
19
21
  };
20
- declare const DistrictDropdown: ({ locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required, provinceId }: DistrictProps) => react_jsx_runtime.JSX.Element;
22
+ declare const DistrictDropdown: ({ locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required, provinceId, error }: DistrictProps) => react_jsx_runtime.JSX.Element;
21
23
 
22
24
  export { type District, type DistrictProps, DistrictDropdown as default };
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-Y2ECRCYO.js';import'../chunk-KYNNMWQA.js';import'../chunk-WSPTQJ57.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var C=(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(c=>c.province_id===t),w=({locale:t="th",searchPlaceholder:s="Search District",placeholder:o="Select District",label:l,searchButtonClassName:c="bg-blue-500",onChange:d,value:n,required:D=false,provinceId:a$1})=>{let[r,g]=useState([]),[b,u]=useState(null);useEffect(()=>{a$1&&P(a$1).then(g);},[a$1]),useEffect(()=>{if(n){let e=r.find(i=>t==="th"?i.name_th===n:i.name_en===n);e&&u(e);}},[r,n,t]);let _=useCallback(e=>{let i=r.find(v=>v.id===e);i&&(u(i),d?.(i));},[r,d]);return jsx("div",{children:jsx(a,{items:r.map(e=>C(e,t)),placeholder:s,triggerPlaceholder:o,label:l,selectionMode:"single",searchButtonClassName:c,onChange:e=>{_(e);},value:b?.id,required:D,disabled:!a$1})})},x=w;
2
- export{x as default};
1
+ import {a}from'../chunk-CAGUY2KE.js';import'../chunk-KYNNMWQA.js';import'../chunk-WSPTQJ57.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var P=(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},w=async t=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/district.json")).json()).filter(o=>o.province_id===t),x=({locale:t="th",searchPlaceholder:s="Search District",placeholder:c="Select District",label:l,searchButtonClassName:o="bg-blue-500",onChange:d,value:n,required:D=false,provinceId:a$1,error:g})=>{let[i,b]=useState([]),[_,u]=useState(null);useEffect(()=>{a$1&&w(a$1).then(b);},[a$1]),useEffect(()=>{if(n){let e=i.find(r=>t==="th"?r.name_th===n:r.name_en===n);e&&u(e);}},[i,n,t]);let v=useCallback(e=>{let r=i.find(S=>S.id===e);r&&(u(r),d?.(r));},[i,d]);return jsx("div",{children:jsx(a,{items:i.map(e=>P(e,t)),placeholder:s,triggerPlaceholder:c,label:l,selectionMode:"single",searchButtonClassName:o,onChange:e=>{v(e);},value:_?.id,required:D,disabled:!a$1,errorMessage:g})})},y=x;
2
+ export{y as default};
@@ -6,16 +6,20 @@ type Province = {
6
6
  name_en: string;
7
7
  };
8
8
  type ProvinceProps = {
9
+ /** รองรับภาษา */
9
10
  locale?: "en" | "th";
10
11
  searchPlaceholder?: string;
11
12
  placeholder?: string;
12
13
  label?: string;
14
+ /** custom class name in search button */
13
15
  searchButtonClassName?: string;
14
16
  onChange?: (province: Province) => void;
15
17
  value?: string;
16
18
  required?: boolean;
17
19
  disabled?: boolean;
20
+ /** เพิ่ม error message */
21
+ error?: string;
18
22
  };
19
- declare const ProvinceDropdown: ({ disabled, locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required }: ProvinceProps) => react_jsx_runtime.JSX.Element;
23
+ declare const ProvinceDropdown: ({ disabled, locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required, error }: ProvinceProps) => react_jsx_runtime.JSX.Element;
20
24
 
21
25
  export { type Province, type ProvinceProps, ProvinceDropdown as default };
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-Y2ECRCYO.js';import'../chunk-KYNNMWQA.js';import'../chunk-WSPTQJ57.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var C=(e,t)=>t==="en"?{id:e.id,name:e.name_en,value:e.id,label:e.name_en}:{id:e.id,name:e.name_th,value:e.id,label:e.name_th},w=async()=>await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province.json")).json(),x=({disabled:e,locale:t="th",searchPlaceholder:u="Search Province",placeholder:P="Select Province",label:v,searchButtonClassName:m="bg-blue-500",onChange:a$1,value:i,required:f=false})=>{let[o,p]=useState([]),[g,s]=useState(null);useEffect(()=>{w().then(p);},[]),useEffect(()=>{if(i){let n=o.find(r=>t==="th"?r.name_th===i:r.name_en===i);n&&s(n);}},[o,i,t]);let b=useCallback(n=>{let r=o.find(_=>_.id===n);r&&(s(r),a$1?.(r));},[o,a$1]);return jsx("div",{children:jsx(a,{items:o.map(n=>C(n,t)),placeholder:u,triggerPlaceholder:P,label:v,selectionMode:"single",searchButtonClassName:m,onChange:n=>{b(n);},value:g?.id,required:f,disabled:e})})},y=x;
2
- export{y as default};
1
+ import {a}from'../chunk-CAGUY2KE.js';import'../chunk-KYNNMWQA.js';import'../chunk-WSPTQJ57.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var w=(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},x=async()=>await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province.json")).json(),y=({disabled:e,locale:r="th",searchPlaceholder:u="Search Province",placeholder:P="Select Province",label:v,searchButtonClassName:m="bg-blue-500",onChange:s,value:i,required:f=false,error:g})=>{let[o,p]=useState([]),[b,a$1]=useState(null);useEffect(()=>{x().then(p);},[]),useEffect(()=>{if(i){let n=o.find(t=>r==="th"?t.name_th===i:t.name_en===i);n&&a$1(n);}},[o,i,r]);let _=useCallback(n=>{let t=o.find(S=>S.id===n);t&&(a$1(t),s?.(t));},[o,s]);return jsx("div",{children:jsx(a,{items:o.map(n=>w(n,r)),placeholder:u,triggerPlaceholder:P,label:v,selectionMode:"single",searchButtonClassName:m,onChange:n=>{_(n);},value:b?.id,required:f,disabled:e,errorMessage:g})})},k=y;
2
+ export{k as default};
@@ -0,0 +1,37 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface RichContentProps {
4
+ /**
5
+ * HTML string to render
6
+ */
7
+ html: string;
8
+ /**
9
+ * Typography size
10
+ * @default 'lg'
11
+ */
12
+ size?: 'sm' | 'base' | 'lg' | 'xl' | '2xl';
13
+ /**
14
+ * Additional className
15
+ */
16
+ className?: string;
17
+ }
18
+ /**
19
+ * RichContent - Safely render HTML with beautiful typography
20
+ *
21
+ * Features:
22
+ * - XSS protection with DOMPurify
23
+ * - Beautiful typography with Tailwind
24
+ * - Dark mode support
25
+ * - Responsive
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * <RichContent
30
+ * html="<h1>Title</h1><p>Content</p>"
31
+ * size="lg"
32
+ * />
33
+ * ```
34
+ */
35
+ declare function RichContent({ html, size, className }: RichContentProps): react_jsx_runtime.JSX.Element;
36
+
37
+ export { RichContent };
@@ -0,0 +1,64 @@
1
+ import a from'dompurify';import {useMemo}from'react';import {jsx}from'react/jsx-runtime';function r({html:e,size:o="lg",className:t=""}){let s=useMemo(()=>a.sanitize(e,{ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","strong","em","u","del","mark","small","a","ul","ol","li","blockquote","code","pre","table","thead","tbody","tr","th","td","br","hr","div","span"],ALLOWED_ATTR:["href","target","rel","class","id"]}),[e]),p={sm:"prose-sm",base:"prose-base",lg:"prose-lg",xl:"prose-xl","2xl":"prose-2xl"}[o];return jsx("article",{className:`
2
+ prose ${p}
3
+ max-w-none
4
+ dark:prose-invert
5
+
6
+ prose-headings:font-bold
7
+ prose-headings:tracking-tight
8
+
9
+ prose-h1:text-4xl
10
+ prose-h1:mb-4
11
+
12
+ prose-h2:text-3xl
13
+ prose-h2:mt-8
14
+ prose-h2:mb-4
15
+
16
+ prose-h3:text-2xl
17
+ prose-h3:mt-6
18
+ prose-h3:mb-3
19
+
20
+ prose-p:text-gray-700
21
+ prose-p:leading-relaxed
22
+ dark:prose-p:text-gray-300
23
+
24
+ prose-a:text-blue-600
25
+ prose-a:no-underline
26
+ prose-a:font-medium
27
+ hover:prose-a:underline
28
+ dark:prose-a:text-blue-400
29
+
30
+ prose-strong:text-gray-900
31
+ prose-strong:font-semibold
32
+ dark:prose-strong:text-gray-100
33
+
34
+ prose-code:text-pink-600
35
+ prose-code:bg-gray-100
36
+ prose-code:px-1.5
37
+ prose-code:py-0.5
38
+ prose-code:rounded
39
+ prose-code:text-sm
40
+ prose-code:font-mono
41
+ dark:prose-code:bg-gray-800
42
+ dark:prose-code:text-pink-400
43
+
44
+ prose-pre:bg-gray-900
45
+ prose-pre:text-gray-100
46
+ prose-pre:rounded-lg
47
+ prose-pre:shadow-lg
48
+ dark:prose-pre:bg-gray-950
49
+
50
+ prose-blockquote:border-l-4
51
+ prose-blockquote:border-gray-300
52
+ prose-blockquote:pl-4
53
+ prose-blockquote:italic
54
+ prose-blockquote:text-gray-600
55
+ dark:prose-blockquote:border-gray-700
56
+ dark:prose-blockquote:text-gray-400
57
+
58
+ prose-ul:list-disc
59
+ prose-ol:list-decimal
60
+ prose-li:text-gray-700
61
+ dark:prose-li:text-gray-300
62
+
63
+ ${t}
64
+ `,dangerouslySetInnerHTML:{__html:s}})}export{r as RichContent};
@@ -45,7 +45,9 @@ type SearchSelectProps = {
45
45
  searchIcon?: React.ReactNode;
46
46
  /** ขนาดของ SearchSelect Trigger */
47
47
  size?: "sm" | "md" | "lg";
48
+ /** Auto focus on search input when popover opens (default: false) */
49
+ autoFocus?: boolean;
48
50
  };
49
- 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, errorMessage, disabled, size }: SearchSelectProps): react_jsx_runtime.JSX.Element;
51
+ declare function SearchSelect({ autoFocus, 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, errorMessage, disabled, size }: SearchSelectProps): react_jsx_runtime.JSX.Element;
50
52
 
51
53
  export { type SearchSelectProps, SearchSelect as default };
@@ -1 +1 @@
1
- export{a as default}from'../chunk-Y2ECRCYO.js';import'../chunk-KYNNMWQA.js';import'../chunk-WSPTQJ57.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';
1
+ export{a as default}from'../chunk-CAGUY2KE.js';import'../chunk-KYNNMWQA.js';import'../chunk-WSPTQJ57.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';
@@ -46,8 +46,10 @@ type SearchSelectProps = {
46
46
  enablePagination?: boolean;
47
47
  pageSize?: number;
48
48
  errorMessage?: string;
49
+ /** Auto focus on search input when popover opens (default: false) */
50
+ autoFocus?: boolean;
49
51
  };
50
- declare function SearchSelectWithAPI({ trigger, triggerPlaceholder, items: propItems, loadOptions, // 👈 ใหม่
52
+ declare function SearchSelectWithAPI({ autoFocus, trigger, triggerPlaceholder, items: propItems, loadOptions, // 👈 ใหม่
51
53
  selectionMode, value, defaultValue, onChange, searchable, placeholder, searchButtonLabel, onQueryChange, onSearch, loading: externalLoading, emptyLabel, errorLabel, // 👈 ใหม่
52
54
  contentClassName, maxHeight, renderItem, buttonColor, searchButtonColor, searchButtonClassName, checkedColor, checkedClassName, renderTriggerValue, label, required, enablePagination, pageSize, errorMessage }: SearchSelectProps): react_jsx_runtime.JSX.Element;
53
55
 
@@ -1 +1 @@
1
- import {a as a$3}from'../chunk-KYNNMWQA.js';import {a as a$2}from'../chunk-WSPTQJ57.js';import {a as a$4}from'../chunk-IX36POX2.js';import {a}from'../chunk-DM45BGDQ.js';import {a as a$1}from'../chunk-6GLPXMGB.js';import*as r from'react';import*as i from'@radix-ui/react-popover';import {Check}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';var ze=a=>l=>{a(typeof l=="string"?l:l[0]||"");},He=a=>l=>{a(Array.isArray(l)?l:[l]);};function J(a){return typeof a=="string"?{id:a,label:a}:a}var Se={neutral:"border-neutral-900 bg-neutral-900 text-white",primary:"border-black bg-black text-white",red:"border-red-600 bg-red-600 text-white",green:"border-green-600 bg-green-600 text-white",blue:"border-blue-600 bg-blue-600 text-white",yellow:"border-yellow-500 bg-yellow-500 text-black",violet:"border-violet-600 bg-violet-600 text-white"};function Ie({trigger:a$5,triggerPlaceholder:l="Choose",items:K,loadOptions:c,selectionMode:y="multiple",value:M,defaultValue:X,onChange:Y,searchable:T=true,placeholder:Z="Placeholder Text",searchButtonLabel:O="Search",onQueryChange:ee,onSearch:te,loading:re=false,emptyLabel:se="No results",errorLabel:oe="Failed to load options",contentClassName:ae,maxHeight:le=288,renderItem:A,buttonColor:ne="primary",searchButtonColor:ie,searchButtonClassName:ce,checkedColor:de="primary",checkedClassName:ue,renderTriggerValue:q,label:z,required:me,enablePagination:p=false,pageSize:H=20,errorMessage:R}){let[x,Q]=r.useState(false),[b,ge]=r.useState(""),[k,E]=r.useState(""),[V,w]=r.useState([]),[N,W]=r.useState(false),[C,j]=r.useState(null),[pe,D]=r.useState(1),[be,fe]=r.useState(true),n=y==="multiple",[he,xe]=r.useState(X??(n?[]:"")),o=M??he,F=c?V:K||[],m=r.useMemo(()=>F.map(J),[F]),S=r.useCallback(async(e,s=1,h=false)=>{if(c){W(true),j(null);try{let B=(await c(e)).map(J);w(h?Ne=>[...Ne,...B]:B),p&&fe(B.length===H);}catch(u){j(u instanceof Error?u.message:"Unknown error"),w([]);}finally{W(false);}}},[c,p,H]);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(s=>String(s.label).toLowerCase().includes(e)):m},[m,k,c]),U=e=>{Y?.(e),M===void 0&&xe(e);},ve=e=>{if(n){let s=new Set(o);s.has(e)?s.delete(e):s.add(e),U(Array.from(s));}else U(e),Q(false);},ye=e=>n?o.includes(e):o===e,Re=()=>{c?(D(1),S(b,1,false),E(b)):(E(b),te?.(b));},ke=()=>{if(!N&&be&&p){let e=pe+1;D(e),S(k,e,true);}},I=r.useMemo(()=>n?o:o?[o]:[],[o,n]),f=r.useMemo(()=>m.filter(e=>I.includes(e.id)),[m,I]),we=r.useMemo(()=>f.length===0?l:n?`\u0E40\u0E25\u0E37\u0E2D\u0E01 ${f.length} \u0E23\u0E32\u0E22\u0E01\u0E32\u0E23`:f[0].label,[f,n,l]),P=N||re;return jsx("fieldset",{children:jsxs(i.Root,{open:x,onOpenChange:Q,children:[z&&jsx(a,{label:z,required:me}),jsx("div",{className:"mb-2"}),jsx(i.Trigger,{asChild:true,children:a$5??jsxs("button",{type:"button",className:a$1("flex w-full min-w-[260px] items-center justify-between","rounded-md border border-black/15 bg-white px-4 py-3 text-left","outline-none focus-visible:ring-2 ring-black/20",R?"border-red-500":"border-black/20"),children:[jsx("span",{className:a$1("flex-1 ",{"text-gray-400":n?o?.length===0:!o,"text-black":n?o?.length>0:!!o}),children:q?q(I,f):we}),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(i.Portal,{children:jsxs(i.Content,{sideOffset:8,className:a$1("w-[300px] rounded-md border border-black/10 bg-white p-2 shadow-xl",ae),children:[T&&jsxs("form",{className:"grid grid-cols-[1fr_auto] gap-3",onSubmit:e=>{e.preventDefault(),Re();},children:[jsx(a$2,{start:jsx(a$3,{}),value:b,onChange:e=>{ge(e.currentTarget.value),ee?.(e.currentTarget.value);},size:"sm",placeholder:Z}),jsx(a$4,{color:ie??ne,type:"submit",disabled:P,size:"md",className:ce,children:O})]}),jsxs("div",{role:"listbox","aria-multiselectable":n||void 0,className:a$1("overflow-y-auto rounded-md",{"mt-3":T}),style:{maxHeight:le},onScroll:e=>{if(!p)return;let{scrollTop:s,scrollHeight:h,clientHeight:u}=e.currentTarget;h-s<=u+50&&ke();},children:[P&&v.length===0&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),C&&jsx("div",{className:"p-6 text-center text-red-600",children:oe}),!P&&!C&&v.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:se}),!C&&v.map(e=>{let s=ye(e.id),h=Se[de],u=jsxs(a$4,{type:"button",role:"option","aria-selected":s,onClick:()=>ve(e.id),disabled:e.disabled,size:"sm",className:a$1("group flex w-full items-center justify-between gap-3 rounded-md px-2 py-2 text-left bg-white h-auto","hover:bg-black/[0.04] disabled:opacity-50",{"bg-black/[0.04]":s&&y==="single"}),children:[jsx("span",{className:"text-md text-black",children:e.label}),y==="multiple"&&jsx("span",{className:a$1("grid h-5 w-5 place-items-center rounded-full border-2",s?h:"border-black/20",s&&ue),children:s?jsx(Check,{size:14}):null})]},e.id);return A?jsx("div",{children:A(e,false,s)},e.id):u}),p&&N&&v.length>0&&jsx("div",{className:"p-2 text-center text-sm text-black/40",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21..."})]}),jsx(i.Arrow,{className:"fill-white stroke-black/10"})]})})]})})}var Pe=Ie;export{Pe as default,He as handleMultipleChange,ze as handleSingleChange};
1
+ import {a as a$3}from'../chunk-KYNNMWQA.js';import {a as a$2}from'../chunk-WSPTQJ57.js';import {a as a$4}from'../chunk-IX36POX2.js';import {a}from'../chunk-DM45BGDQ.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};
@@ -19,7 +19,9 @@ type SubDistrictProps = {
19
19
  value?: string;
20
20
  required?: boolean;
21
21
  districtId?: number;
22
+ /** เพิ่ม error message */
23
+ error?: string;
22
24
  };
23
- declare const SubDistrictDropdown: ({ locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required, districtId }: SubDistrictProps) => react_jsx_runtime.JSX.Element;
25
+ declare const SubDistrictDropdown: ({ locale, searchPlaceholder, placeholder, label, searchButtonClassName, onChange, value, required, districtId, error }: SubDistrictProps) => react_jsx_runtime.JSX.Element;
24
26
 
25
27
  export { type SubDistrict, type SubDistrictProps, SubDistrictDropdown as default };
@@ -1,2 +1,2 @@
1
- import {a}from'../chunk-Y2ECRCYO.js';import'../chunk-KYNNMWQA.js';import'../chunk-WSPTQJ57.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var C=(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(c=>c.district_id===t),w=({locale:t="th",searchPlaceholder:s="Search District",placeholder:o="Select District",label:l,searchButtonClassName:c="bg-blue-500",onChange:u,value:n,required:f=false,districtId:a$1})=>{let[i,S]=useState([]),[g,d]=useState(null);useEffect(()=>{a$1&&P(a$1).then(S);},[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 D=useCallback(e=>{let r=i.find(_=>_.id===e);r&&(d(r),u?.(r));},[i,u]);return jsx("div",{children:jsx(a,{items:i.map(e=>C(e,t)),placeholder:s,triggerPlaceholder:o,label:l,selectionMode:"single",searchButtonClassName:c,onChange:e=>{D(e);},value:g?.id,required:f,disabled:!a$1})})},x=w;
2
- export{x as default};
1
+ import {a}from'../chunk-CAGUY2KE.js';import'../chunk-KYNNMWQA.js';import'../chunk-WSPTQJ57.js';import'../chunk-IX36POX2.js';import'../chunk-DM45BGDQ.js';import'../chunk-6GLPXMGB.js';import {useState,useEffect,useCallback}from'react';import {jsx}from'react/jsx-runtime';var P=(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},w=async t=>(await(await fetch("https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/sub_district.json")).json()).filter(o=>o.district_id===t),x=({locale:t="th",searchPlaceholder:s="Search Sub District",placeholder:c="Select Sub District",label:l,searchButtonClassName:o="bg-blue-500",onChange:u,value:n,required:S=false,districtId:a$1,error:f})=>{let[i,g]=useState([]),[D,d]=useState(null);useEffect(()=>{a$1&&w(a$1).then(g);},[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 _=useCallback(e=>{let r=i.find(v=>v.id===e);r&&(d(r),u?.(r));},[i,u]);return jsx("div",{children:jsx(a,{items:i.map(e=>P(e,t)),placeholder:s,triggerPlaceholder:c,label:l,selectionMode:"single",searchButtonClassName:o,onChange:e=>{_(e);},value:D?.id,required:S,disabled:!a$1,errorMessage:f})})},y=x;
2
+ export{y as default};
@@ -1,10 +1,10 @@
1
- import {a}from'../chunk-DM45BGDQ.js';import {forwardRef}from'react';import {jsxs,jsx}from'react/jsx-runtime';var l=forwardRef(({label:t="\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 (\u0E1A\u0E49\u0E32\u0E19\u0E40\u0E25\u0E02\u0E17\u0E35\u0E48/\u0E0B\u0E2D\u0E22/\u0E16\u0E19\u0E19)",error:r,required:o=false,className:s="",...n},d)=>jsxs("fieldset",{className:"relative flex flex-col gap-2 items-start text-start",children:[t&&jsx(a,{label:t,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-DM45BGDQ.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:`
2
2
  w-full px-4 py-3
3
3
  border rounded-lg
4
4
  text-gray-900 placeholder-gray-400
5
5
  resize-none
6
6
  transition-colors
7
- focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent
8
- ${r?"border-red-500":"border-gray-300"}
7
+ focus:outline-none
8
+ ${t?"border-red-500":"border-gray-300"}
9
9
  ${s}
10
- `,...n})}),r&&jsx("small",{className:"text-red-500 text-xs",children:r})]}));l.displayName="TextAreaInput";var i=l;export{i as default};
10
+ `,...n})}),t&&jsx("small",{className:"text-red-500 text-xs",children:t})]}));l.displayName="TextAreaInput";var i=l;export{i as default};
package/package.json CHANGED
@@ -1,29 +1,42 @@
1
1
  {
2
2
  "name": "the-omelet-ui",
3
- "version": "1.4.8",
3
+ "version": "1.5.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "module": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
9
9
  "exports": {
10
- ".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
11
- "./*": { "types": "./dist/entries/*.d.ts", "default": "./dist/entries/*.js" }
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./*": {
15
+ "types": "./dist/entries/*.d.ts",
16
+ "default": "./dist/entries/*.js"
17
+ }
12
18
  },
13
- "sideEffects": ["**/*.css"],
19
+ "sideEffects": [
20
+ "**/*.css"
21
+ ],
14
22
  "peerDependencies": {
15
23
  "@radix-ui/react-slot": "^1.0.0",
16
24
  "react": ">=18",
17
25
  "react-dom": ">=18"
18
26
  },
19
27
  "peerDependenciesMeta": {
20
- "@radix-ui/react-slot": { "optional": true }
28
+ "@radix-ui/react-slot": {
29
+ "optional": true
30
+ }
21
31
  },
22
32
  "dependencies": {
33
+ "@tailwindcss/typography": "^0.5.19",
23
34
  "class-variance-authority": "^0.7.1",
35
+ "dompurify": "^3.3.0",
24
36
  "tailwind-merge": "^3.3.1"
25
37
  },
26
38
  "devDependencies": {
39
+ "@types/dompurify": "^3.2.0",
27
40
  "@types/react": "^19.1.15",
28
41
  "@types/react-dom": "^19.1.9",
29
42
  "tsup": "^8.0.0",
@@ -34,10 +47,14 @@
34
47
  "README.md",
35
48
  "LICENSE"
36
49
  ],
37
- "publishConfig": { "access": "public" },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
38
53
  "scripts": {
39
54
  "build": "tsup",
40
55
  "prepublishOnly": "pnpm build"
41
56
  },
42
- "engines": { "node": ">=18" }
57
+ "engines": {
58
+ "node": ">=18"
59
+ }
43
60
  }
@@ -1 +0,0 @@
1
- import {a as a$4}from'./chunk-KYNNMWQA.js';import {a as a$3}from'./chunk-WSPTQJ57.js';import {a as a$5}from'./chunk-IX36POX2.js';import {a as a$1}from'./chunk-DM45BGDQ.js';import {a as a$2}from'./chunk-6GLPXMGB.js';import*as a from'react';import*as l from'@radix-ui/react-popover';import {Check}from'lucide-react';import {jsxs,jsx}from'react/jsx-runtime';function ne(c){return typeof c=="string"?{id:c,label:c}:c}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"},ce={sm:"h-8",md:"h-10",lg:"h-12"};function de({trigger:c,triggerPlaceholder:R="Choose",items:y,selectionMode:b="multiple",value:w,defaultValue:q,onChange:Q,searchable:k=true,placeholder:A="Placeholder Text",searchButtonLabel:O="Search",onQueryChange:V,onSearch:j,loading:u=false,emptyLabel:D="No results",contentClassName:H,maxHeight:W=288,renderItem:N,buttonColor:_="primary",searchButtonColor:$,searchButtonClassName:E,checkedColor:F="primary",checkedClassName:G,renderTriggerValue:C,label:P,required:J,errorMessage:f,disabled:p,size:K="md"}){let[I,S]=a.useState(false),[g,U]=a.useState(""),[h,X]=a.useState(""),s=b==="multiple",[Y,Z]=a.useState(q??(s?[]:"")),o=w??Y,d=a.useMemo(()=>y.map(ne),[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=>{Q?.(e),w===void 0&&Z(e);},ee=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);},te=e=>s?o.includes(e):o===e,re=()=>{X(g),j?.(g);},v=a.useMemo(()=>s?o:o?[o]:[],[o,s]),m=a.useMemo(()=>d.filter(e=>v.includes(e.id)),[d,v]),oe=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:J}),jsxs(l.Root,{open:I&&!p,onOpenChange:e=>!p&&S(e),children:[jsx("div",{className:"mb-2"}),jsx(l.Trigger,{asChild:true,children:c??jsxs("button",{type:"button",className:a$2("flex w-full min-w-[260px] items-center justify-between","rounded-md border border-black/15 bg-white px-4 text-left","outline-none focus-visible:ring-2 ring-black/20",f&&!p?"border-red-600":"",p?"opacity-50 cursor-not-allowed":"",ce[K]),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):oe}),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,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(),re();},children:[jsx(a$3,{start:jsx(a$4,{}),value:g,onChange:e=>{U(e.currentTarget.value),V?.(e.currentTarget.value);},size:"md",placeholder:A}),jsx(a$5,{color:$??_,type:"submit",disabled:u||g.trim()===h.trim(),size:"md",className:E,children:O})]}),jsxs("div",{role:"listbox","aria-multiselectable":s||void 0,className:a$2(" overflow-y-auto rounded-md",{"mt-3":k}),style:{maxHeight:W},children:[u&&jsx("div",{className:"p-6 text-center text-black/60",children:"\u0E01\u0E33\u0E25\u0E31\u0E07\u0E42\u0E2B\u0E25\u0E14\u2026"}),!u&&B.length===0&&jsx("div",{className:"p-6 text-center text-black/50",children:D}),!u&&B.map(e=>{let r=te(e.id),ae=ie[F],se=jsxs(a$5,{type:"button",role:"option","aria-selected":r,onClick:()=>ee(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?ae:"border-black/20",r&&G),children:r?jsx(Check,{size:12}):null})]},e.id);return N?jsx("div",{children:N(e,false,r)},e.id):se})]}),jsx(l.Arrow,{className:"fill-white stroke-black/10"})]})})]}),f&&jsx("small",{className:"text-red-500 text-xs",children:f})]})}var he=de;export{he as a};