@unizap/uniui 1.1.7 → 1.1.8
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.
- package/dist/uniui.js +2 -2
- package/dist/uniui.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/uniui.js
CHANGED
|
@@ -577,7 +577,7 @@ const Pe = ({
|
|
|
577
577
|
return () => {
|
|
578
578
|
window.removeEventListener("scroll", B, !0), window.removeEventListener("resize", B);
|
|
579
579
|
};
|
|
580
|
-
}, [K, d, B, n.length, _, c, u]);
|
|
580
|
+
}, [K, d, B, n.length, _.length, c, u]);
|
|
581
581
|
const W = (h) => {
|
|
582
582
|
h.key === "ArrowDown" ? (h.preventDefault(), K ? E(($) => Math.min($ + 1, k.length - 1)) : (G(!0), E(0))) : h.key === "ArrowUp" ? (h.preventDefault(), E(($) => Math.max($ - 1, 0))) : h.key === "Enter" ? (h.preventDefault(), b >= 0 && k[b] && (O(k[b]), k[b].onClick(k[b]))) : h.key === "Escape" && (h.preventDefault(), G(!1), E(-1), V(""));
|
|
583
583
|
}, de = () => {
|
|
@@ -7555,7 +7555,7 @@ const Xa = ({
|
|
|
7555
7555
|
children: o.map((m) => /* @__PURE__ */ s("option", { value: m.value, className: "text-color-gray-900", children: m.label }, m.value))
|
|
7556
7556
|
}
|
|
7557
7557
|
),
|
|
7558
|
-
/* @__PURE__ */ s("span", { className: `absolute right-3 text-sm top-1/2 -translate-y-1/2 ${l ? "opacity-60" : ""}`, children: /* @__PURE__ */ s("svg", { className: "size-4", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ s("path", { d: "M11.9999 13.1714L16.9497 8.22168L18.3639 9.63589L11.9999 15.9999L5.63599 9.63589L7.0502 8.22168L11.9999 13.1714Z" }) }) })
|
|
7558
|
+
/* @__PURE__ */ s("span", { className: `absolute right-3 text-sm top-1/2 -translate-y-1/2 pointer-events-none ${l ? "opacity-60" : ""}`, children: /* @__PURE__ */ s("svg", { className: "size-4", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ s("path", { d: "M11.9999 13.1714L16.9497 8.22168L18.3639 9.63589L11.9999 15.9999L5.63599 9.63589L7.0502 8.22168L11.9999 13.1714Z" }) }) })
|
|
7559
7559
|
] })
|
|
7560
7560
|
] });
|
|
7561
7561
|
}, il = ({
|
package/dist/uniui.umd.cjs
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
checked:after:content-[✓] checked:after:text-color-white
|
|
22
22
|
${t?"cursor-not-allowed !bg-color-gray-200 !border-color-gray-300":"cursor-pointer"}
|
|
23
23
|
${r}
|
|
24
|
-
`,checked:p,onChange:f}),e&&i.jsx("span",{className:`text-sm text-color-gray-700 ${a}`,children:e})]})},zn=(e,o)=>{const[t,n]=m.useState(e);return m.useEffect(()=>{const r=setTimeout(()=>{n(e)},o);return()=>{clearTimeout(r)}},[e,o]),t},Mn=({selected:e,items:o=[],className:t="",menuClassName:n="",stayOpenOnSelect:r=!1,onSelect:a,open:s,onToggle:l,maxHeight:c=200,position:u="auto",searchable:d=!1,searchPlaceholder:f="Search...",searchClassName:p="",multiple:g=!1,placeholder:h="Select",showClearAll:v=!1,disabled:k=!1,searchOn:b,groupedItems:_=[]})=>{const[y,S]=m.useState(!1),[w,F]=m.useState(-1),[A,B]=m.useState(""),[oe,R]=m.useState({}),ae=m.useRef(null),de=m.useRef(null),ie=m.useRef(null),T=m.useRef(null),G=zn(A,300),X=s!==void 0?s:y,Z=x=>{s===void 0&&S(x),x||B(""),l==null||l(x)},ne=g?Array.isArray(e)?e:[]:e&&!Array.isArray(e)?[e]:[],Y=G?o.filter(x=>{const $=typeof x.label=="string"?x.label:String(x.label),W=x.value?String(x.value):"",j=G.toLowerCase(),te=b||"label";if(te==="label")return $.toLowerCase().includes(j);if(te==="value")return W.toLowerCase().includes(j);if(te==="both")return $.toLowerCase().includes(j)||W.toLowerCase().includes(j);{const O=x[te];return typeof O=="string"?O.toLowerCase().includes(j):!1}}):o,z=Y.filter(x=>ne.some($=>$.label===x.label&&$.value===x.value)),L=Y.filter(x=>!ne.some($=>$.label===x.label&&$.value===x.value)),C=[...z,...L],M=z.length>0&&L.length>0,E=x=>ne.some($=>$.label===x.label&&$.value===x.value),V=x=>{if(g){const $=Array.isArray(e)?e:[],j=$.some(te=>te.label===x.label&&te.value===x.value)?$.filter(te=>!(te.label===x.label&&te.value===x.value)):[...$,x];a==null||a(j)}else a==null||a(x),r||(Z(!1),B(""))},N=(x,$)=>{if($.stopPropagation(),g&&Array.isArray(e)){const W=e.filter(j=>!(j.label===x.label&&j.value===x.value));a==null||a(W)}},I=x=>{x.stopPropagation(),a==null||a(g?[]:null)};m.useEffect(()=>{const x=$=>{var O,ee;const W=$.target,j=(O=ae.current)==null?void 0:O.contains(W),te=(ee=de.current)==null?void 0:ee.contains(W);!j&&!te&&(Z(!1),F(-1))};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[]);const D=m.useRef(!1),q=m.useCallback(()=>{if(ae.current){const x=ae.current.getBoundingClientRect(),$=D.current;R({position:"fixed",top:$?void 0:x.bottom+4,bottom:$?window.innerHeight-x.top+4:void 0,left:x.left,width:x.width,zIndex:9999})}},[]);m.useEffect(()=>{if(X&&ae.current){const x=ae.current.getBoundingClientRect(),$=o.length+_.reduce((O,ee)=>O+ee.items.length+1,0),W=Math.min($*44+(d?48:0),c+16),j=window.innerHeight-x.bottom,te=x.top;D.current=u==="top"||u==="auto"&&j<W&&te>=W,q(),d&&T.current&&T.current.focus(),window.addEventListener("scroll",q,!0),window.addEventListener("resize",q)}return()=>{window.removeEventListener("scroll",q,!0),window.removeEventListener("resize",q)}},[X,d,q,o.length,_,c,u]);const U=x=>{x.key==="ArrowDown"?(x.preventDefault(),X?F($=>Math.min($+1,C.length-1)):(Z(!0),F(0))):x.key==="ArrowUp"?(x.preventDefault(),F($=>Math.max($-1,0))):x.key==="Enter"?(x.preventDefault(),w>=0&&C[w]&&(V(C[w]),C[w].onClick(C[w]))):x.key==="Escape"&&(x.preventDefault(),Z(!1),F(-1),B(""))},le=()=>{if(g){if(ne.length===0)return i.jsx("span",{className:"text-color-gray-400",children:h});const $=ne[0],W=ne.length-1;return i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs bg-color-gray-100 rounded-md",children:[i.jsx("span",{children:$.label}),i.jsx("span",{role:"button",tabIndex:0,onClick:j=>N($,j),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&N($,j)},className:"ml-1 text-color-gray-500 hover:text-color-gray-700 cursor-pointer",children:i.jsx("svg",{className:"size-3",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636l4.95 4.95z"})})})]}),W>0&&i.jsxs("span",{className:"text-sm text-color-gray-500",children:["+",W," more"]})]})}const x=ne[0];return x?i.jsx("span",{children:x.label}):i.jsx("span",{className:"text-color-gray-400",children:h})};return i.jsxs("div",{ref:ae,className:"relative inline-block w-full",children:[i.jsxs("button",{type:"button",onClick:()=>{k||Z(!X)},onKeyDown:U,disabled:k,className:`flex items-center justify-between w-full px-4 py-3 bg-color-white rounded-sm border border-color-gray-200 text-sm font-medium text-color-gray-700 hover:bg-color-gray-50 focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed ${t}`,children:[i.jsx("div",{className:"flex-1 text-left truncate",children:le()}),i.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[ne.length>0&&v&&i.jsx("span",{role:"button",onClick:I,className:"p-0.5 text-color-gray-400 hover:text-color-gray-600",children:i.jsx("svg",{className:"size-4",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636l4.95 4.95z"})})}),X?i.jsx("svg",{className:"text-color-gray-500 size-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M11.9999 10.8284L7.0502 15.7782L5.63599 14.364L11.9999 8L18.3639 14.364L16.9497 15.7782L11.9999 10.8284Z"})}):i.jsx("svg",{className:"text-color-gray-500 size-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M11.9999 13.1714L16.9497 8.22168L18.3639 9.63589L11.9999 15.9999L5.63599 9.63589L7.0502 8.22168L11.9999 13.1714Z"})})]})]}),X&&typeof document<"u"&&Me.createPortal(i.jsxs("div",{ref:de,className:`rounded-xl bg-color-white shadow-lg shadow-color-zinc-200 dark:shadow-color-gray-900 border border-color-gray-100 py-2 ${n}`,style:oe,children:[d&&i.jsx("div",{className:"px-2 pb-2",children:i.jsx("input",{ref:T,type:"text",value:A,onChange:x=>{B(x.target.value),F(0)},onKeyDown:U,placeholder:f,className:`w-full px-3 py-2 text-sm bg-color-white border border-color-gray-200 rounded-lg focus:outline-none focus:border-color-gray-400 ${p}`})}),i.jsxs("ul",{ref:ie,className:"overflow-y-auto",style:{maxHeight:`${c}px`},children:[C.length>0?i.jsxs(i.Fragment,{children:[z.map((x,$)=>i.jsxs("li",{onClick:()=>{V(x),x.onClick(x)},className:`flex items-center gap-3 cursor-pointer w-full px-4 py-2 text-left text-sm text-color-gray-700 bg-color-gray-200 hover:bg-color-gray-100
|
|
24
|
+
`,checked:p,onChange:f}),e&&i.jsx("span",{className:`text-sm text-color-gray-700 ${a}`,children:e})]})},zn=(e,o)=>{const[t,n]=m.useState(e);return m.useEffect(()=>{const r=setTimeout(()=>{n(e)},o);return()=>{clearTimeout(r)}},[e,o]),t},Mn=({selected:e,items:o=[],className:t="",menuClassName:n="",stayOpenOnSelect:r=!1,onSelect:a,open:s,onToggle:l,maxHeight:c=200,position:u="auto",searchable:d=!1,searchPlaceholder:f="Search...",searchClassName:p="",multiple:g=!1,placeholder:h="Select",showClearAll:v=!1,disabled:k=!1,searchOn:b,groupedItems:_=[]})=>{const[y,S]=m.useState(!1),[w,F]=m.useState(-1),[A,B]=m.useState(""),[oe,R]=m.useState({}),ae=m.useRef(null),de=m.useRef(null),ie=m.useRef(null),T=m.useRef(null),G=zn(A,300),X=s!==void 0?s:y,Z=x=>{s===void 0&&S(x),x||B(""),l==null||l(x)},ne=g?Array.isArray(e)?e:[]:e&&!Array.isArray(e)?[e]:[],Y=G?o.filter(x=>{const $=typeof x.label=="string"?x.label:String(x.label),W=x.value?String(x.value):"",j=G.toLowerCase(),te=b||"label";if(te==="label")return $.toLowerCase().includes(j);if(te==="value")return W.toLowerCase().includes(j);if(te==="both")return $.toLowerCase().includes(j)||W.toLowerCase().includes(j);{const O=x[te];return typeof O=="string"?O.toLowerCase().includes(j):!1}}):o,z=Y.filter(x=>ne.some($=>$.label===x.label&&$.value===x.value)),L=Y.filter(x=>!ne.some($=>$.label===x.label&&$.value===x.value)),C=[...z,...L],M=z.length>0&&L.length>0,E=x=>ne.some($=>$.label===x.label&&$.value===x.value),V=x=>{if(g){const $=Array.isArray(e)?e:[],j=$.some(te=>te.label===x.label&&te.value===x.value)?$.filter(te=>!(te.label===x.label&&te.value===x.value)):[...$,x];a==null||a(j)}else a==null||a(x),r||(Z(!1),B(""))},N=(x,$)=>{if($.stopPropagation(),g&&Array.isArray(e)){const W=e.filter(j=>!(j.label===x.label&&j.value===x.value));a==null||a(W)}},I=x=>{x.stopPropagation(),a==null||a(g?[]:null)};m.useEffect(()=>{const x=$=>{var O,ee;const W=$.target,j=(O=ae.current)==null?void 0:O.contains(W),te=(ee=de.current)==null?void 0:ee.contains(W);!j&&!te&&(Z(!1),F(-1))};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[]);const D=m.useRef(!1),q=m.useCallback(()=>{if(ae.current){const x=ae.current.getBoundingClientRect(),$=D.current;R({position:"fixed",top:$?void 0:x.bottom+4,bottom:$?window.innerHeight-x.top+4:void 0,left:x.left,width:x.width,zIndex:9999})}},[]);m.useEffect(()=>{if(X&&ae.current){const x=ae.current.getBoundingClientRect(),$=o.length+_.reduce((O,ee)=>O+ee.items.length+1,0),W=Math.min($*44+(d?48:0),c+16),j=window.innerHeight-x.bottom,te=x.top;D.current=u==="top"||u==="auto"&&j<W&&te>=W,q(),d&&T.current&&T.current.focus(),window.addEventListener("scroll",q,!0),window.addEventListener("resize",q)}return()=>{window.removeEventListener("scroll",q,!0),window.removeEventListener("resize",q)}},[X,d,q,o.length,_.length,c,u]);const U=x=>{x.key==="ArrowDown"?(x.preventDefault(),X?F($=>Math.min($+1,C.length-1)):(Z(!0),F(0))):x.key==="ArrowUp"?(x.preventDefault(),F($=>Math.max($-1,0))):x.key==="Enter"?(x.preventDefault(),w>=0&&C[w]&&(V(C[w]),C[w].onClick(C[w]))):x.key==="Escape"&&(x.preventDefault(),Z(!1),F(-1),B(""))},le=()=>{if(g){if(ne.length===0)return i.jsx("span",{className:"text-color-gray-400",children:h});const $=ne[0],W=ne.length-1;return i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs bg-color-gray-100 rounded-md",children:[i.jsx("span",{children:$.label}),i.jsx("span",{role:"button",tabIndex:0,onClick:j=>N($,j),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&N($,j)},className:"ml-1 text-color-gray-500 hover:text-color-gray-700 cursor-pointer",children:i.jsx("svg",{className:"size-3",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636l4.95 4.95z"})})})]}),W>0&&i.jsxs("span",{className:"text-sm text-color-gray-500",children:["+",W," more"]})]})}const x=ne[0];return x?i.jsx("span",{children:x.label}):i.jsx("span",{className:"text-color-gray-400",children:h})};return i.jsxs("div",{ref:ae,className:"relative inline-block w-full",children:[i.jsxs("button",{type:"button",onClick:()=>{k||Z(!X)},onKeyDown:U,disabled:k,className:`flex items-center justify-between w-full px-4 py-3 bg-color-white rounded-sm border border-color-gray-200 text-sm font-medium text-color-gray-700 hover:bg-color-gray-50 focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed ${t}`,children:[i.jsx("div",{className:"flex-1 text-left truncate",children:le()}),i.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[ne.length>0&&v&&i.jsx("span",{role:"button",onClick:I,className:"p-0.5 text-color-gray-400 hover:text-color-gray-600",children:i.jsx("svg",{className:"size-4",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636l4.95 4.95z"})})}),X?i.jsx("svg",{className:"text-color-gray-500 size-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M11.9999 10.8284L7.0502 15.7782L5.63599 14.364L11.9999 8L18.3639 14.364L16.9497 15.7782L11.9999 10.8284Z"})}):i.jsx("svg",{className:"text-color-gray-500 size-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M11.9999 13.1714L16.9497 8.22168L18.3639 9.63589L11.9999 15.9999L5.63599 9.63589L7.0502 8.22168L11.9999 13.1714Z"})})]})]}),X&&typeof document<"u"&&Me.createPortal(i.jsxs("div",{ref:de,className:`rounded-xl bg-color-white shadow-lg shadow-color-zinc-200 dark:shadow-color-gray-900 border border-color-gray-100 py-2 ${n}`,style:oe,children:[d&&i.jsx("div",{className:"px-2 pb-2",children:i.jsx("input",{ref:T,type:"text",value:A,onChange:x=>{B(x.target.value),F(0)},onKeyDown:U,placeholder:f,className:`w-full px-3 py-2 text-sm bg-color-white border border-color-gray-200 rounded-lg focus:outline-none focus:border-color-gray-400 ${p}`})}),i.jsxs("ul",{ref:ie,className:"overflow-y-auto",style:{maxHeight:`${c}px`},children:[C.length>0?i.jsxs(i.Fragment,{children:[z.map((x,$)=>i.jsxs("li",{onClick:()=>{V(x),x.onClick(x)},className:`flex items-center gap-3 cursor-pointer w-full px-4 py-2 text-left text-sm text-color-gray-700 bg-color-gray-200 hover:bg-color-gray-100
|
|
25
25
|
${w===$?"bg-color-gray-100":""}`,children:[g&&i.jsx("span",{className:"flex items-center justify-center size-4 border rounded bg-color-blue-500 border-color-blue-500",children:i.jsx("svg",{className:"size-3 text-color-white",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z"})})}),i.jsx("span",{className:"flex-1",children:x.label})]},`selected-${$}`)),M&&i.jsx("li",{className:"border-t border-color-gray-200 my-1"}),L.map((x,$)=>{const W=z.length+(M?1:0)+$;return i.jsxs("li",{onClick:()=>{V(x),x.onClick(x)},className:`flex items-center gap-3 cursor-pointer w-full px-4 py-2 text-left text-sm text-color-gray-700 hover:bg-color-gray-100
|
|
26
26
|
${w===W?"bg-color-gray-100":""}`,children:[g&&i.jsx("span",{className:"flex items-center justify-center size-4 border rounded border-color-gray-300"}),i.jsx("span",{className:"flex-1",children:x.label})]},`unselected-${$}`)})]}):_.length===0&&i.jsx("li",{className:"px-4 py-2 text-sm text-color-gray-500",children:"No results found"}),_.length>0&&_.map((x,$)=>{const W=G?x.items.filter(j=>{const te=typeof j.label=="string"?j.label:String(j.label),O=j.value?String(j.value):"",ee=G.toLowerCase(),he=b||"label";return he==="label"?te.toLowerCase().includes(ee):he==="value"?O.toLowerCase().includes(ee):he==="both"?te.toLowerCase().includes(ee)||O.toLowerCase().includes(ee):!1}):x.items;return W.length===0?null:i.jsxs("li",{children:[(C.length>0||$>0)&&i.jsx("div",{className:"border-t border-color-gray-200 my-1"}),i.jsx("div",{className:"px-4 py-1 text-xs font-semibold text-color-gray-400 uppercase tracking-wide sticky top-0 bg-color-white z-1",children:x.label}),i.jsx("ul",{children:W.map((j,te)=>i.jsxs("li",{onClick:()=>{V(j),j.onClick(j)},className:`flex items-center gap-3 cursor-pointer w-full px-4 py-2 text-left text-sm text-color-gray-700 hover:bg-color-gray-100
|
|
27
27
|
${E(j)?"bg-color-gray-200":""}`,children:[g&&(E(j)?i.jsx("span",{className:"flex items-center justify-center size-4 border rounded bg-color-blue-500 border-color-blue-500",children:i.jsx("svg",{className:"size-3 text-color-white",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z"})})}):i.jsx("span",{className:"flex items-center justify-center size-4 border rounded border-color-gray-300"})),i.jsx("span",{className:"flex-1",children:j.label})]},`group-${$}-item-${te}`))})]},`group-${$}`)})]})]}),document.body)]})};function Xt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var et={exports:{}},tt={exports:{}},se={};/** @license React v16.13.1
|
|
@@ -145,7 +145,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
145
145
|
${D?q?"border-color-red-500 bg-red-50":`${w}`:"border-color-gray-300 bg-white hover:border-color-gray-400"}
|
|
146
146
|
${I?"":"hover:shadow-md"}
|
|
147
147
|
${S}
|
|
148
|
-
`,onClick:U=>{U.stopPropagation(),!I&&Z(M,N)},children:[D&&q&&i.jsx("div",{className:"absolute top-2 right-2 w-6 h-6 bg-color-red-500 rounded-full flex items-center justify-center",children:i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),!R&&D&&!q&&F&&i.jsx("div",{className:`absolute rounded-full flex items-center justify-center shadow-sm ${B}`,children:A||i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`${oe} text-color-white`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),i.jsxs("div",{className:`flex items-start gap-3 ${q?"text-color-red-700":""}`,children:[R&&i.jsx("button",{type:"button",onClick:U=>{U.stopPropagation(),I||Z(M,N)},disabled:I,className:`mt-1 flex-shrink-0 rounded-full bg-color-gray-300 transition-all duration-150 ${G(p)} ${I?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,"aria-checked":D,children:D&&!q&&i.jsx("div",{className:"w-full h-full flex items-center justify-center",children:ae||A||i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:`${oe} text-color-green-500`,fill:"currentColor",viewBox:"0 0 24 24",children:[i.jsx("circle",{cx:"12",cy:"12",r:"8"}),i.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor"})]})})}),i.jsx("div",{className:"flex-1",children:C})]})]})},M)})}),g&&!h&&i.jsx("div",{id:L,className:"mt-2 text-sm text-color-gray-600",children:g}),h&&!v&&g&&i.jsx("div",{id:L,className:"mt-2 text-sm text-color-red-600",children:g})]}):i.jsxs("div",{className:"w-full",children:[h&&v&&i.jsx("div",{className:"mb-3 p-3 bg-red-50 rounded text-color-red-700 text-sm",role:"alert",id:`${e}-error`,children:v}),i.jsx("div",{role:"radiogroup","aria-label":b,"aria-labelledby":_,"aria-describedby":L,"aria-required":k,className:`flex ${l==="row"?"flex-row gap-6":"flex-col gap-3"} ${d}`,children:o.map(({label:C,value:M,disabled:E,id:V},N)=>{const I=c||E,D=T===M,q=h&&D;return i.jsxs("label",{className:`relative flex items-center cursor-pointer select-none transition ${I?"opacity-50 cursor-not-allowed":"hover:opacity-90"}`,children:[i.jsx("input",{type:"radio",name:e,value:M,disabled:I,checked:D,onChange:()=>!I&&Z(M,N),onBlur:ne,onFocus:U=>Y(U,N),className:"sr-only peer","aria-invalid":h,...V&&{id:V}}),i.jsx("div",{className:`rounded-full border-2 transition-all duration-150 ${q?"border-color-red-500 peer-checked:border-[7px] peer-checked:border-color-red-500":`border-color-gray-400 peer-checked:border-[7px] ${z.border}`} ${f} ${G(p)}`}),i.jsx("span",{className:`ml-2 text-sm ${q?"text-color-red-500":z.text}`,children:C})]},M)})}),g&&!h&&i.jsx("div",{id:L,className:"mt-2 text-sm text-color-gray-600",children:g}),h&&!v&&g&&i.jsx("div",{id:L,className:"mt-2 text-sm text-color-red-600",children:g})]})},Ua=({label:e,value:o,onChange:t,options:n,className:r="",labelClass:a="",inputClass:s="",disabled:l=!1,size:c="medium",variant:u="outlined",rounded:d="medium",shadow:f=!1})=>{const p={small:"p-2",medium:"p-3",large:"p-4"},g={small:"rounded-md",medium:"rounded-lg",full:"rounded-full"},h={filled:"bg-color-gray-100 border-color-gray-200",outlined:"border-color-gray-300 bg-color-transparent"};return i.jsxs("div",{className:`relative w-full ${r}`,children:[e&&i.jsx("label",{className:`text-sm text-color-gray-500 pointer-events-none block mb-1 ${a}`,children:e}),i.jsxs("div",{className:"relative",children:[i.jsx("select",{disabled:l,value:o,onChange:v=>t(v.target.value),className:`appearance-none focus:ring-1 text-color-gray-800 w-full border outline-none transition-all ${g[d]} ${p[c]} ${h[u]} ${l?"!bg-color-gray-50 opacity-60 cursor-not-allowed":""} ${f?"shadow-md shadow-color-zinc-100":""} ${s}`,children:n.map(v=>i.jsx("option",{value:v.value,className:"text-color-gray-900",children:v.label},v.value))}),i.jsx("span",{className:`absolute right-3 text-sm top-1/2 -translate-y-1/2 ${l?"opacity-60":""}`,children:i.jsx("svg",{className:"size-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M11.9999 13.1714L16.9497 8.22168L18.3639 9.63589L11.9999 15.9999L5.63599 9.63589L7.0502 8.22168L11.9999 13.1714Z"})})})]})]})},Ka=({content:e,children:o,position:t="top"})=>{const[n,r]=m.useState(!1),[a,s]=m.useState({top:0,left:0}),l=m.useRef(null),c=m.useRef(null);return m.useEffect(()=>{if(n&&l.current&&c.current){const u=l.current.getBoundingClientRect(),d=c.current.getBoundingClientRect();let f=0,p=0;switch(t){case"top":f=u.top-d.height-8,p=u.left+u.width/2-d.width/2;break;case"bottom":f=u.bottom+8,p=u.left+u.width/2-d.width/2;break;case"left":f=u.top+u.height/2-d.height/2,p=u.left-d.width-8;break;case"right":f=u.top+u.height/2-d.height/2,p=u.right+8;break}s({top:f,left:p})}},[n,t]),i.jsxs(i.Fragment,{children:[i.jsx("div",{ref:l,className:"inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:o}),n&&Me.createPortal(i.jsx("div",{ref:c,style:{top:a.top,left:a.left},className:"fixed z-50 text-center px-2 max-w-xs py-1 text-sm text-color-white bg-color-gray-800 rounded shadow-md pointer-events-none",children:e}),document.body)]})},Xa=({content:e,children:o,position:t="top"})=>{const[n,r]=m.useState(!1),[a,s]=m.useState({top:0,left:0}),l=m.useRef(null),c=m.useRef(null),u=m.useRef(null),d=()=>{u.current&&clearTimeout(u.current),r(!0)},f=()=>{u.current=setTimeout(()=>{r(!1)},100)};return m.useEffect(()=>{if(!n||!l.current||!c.current)return;const p=l.current.getBoundingClientRect(),g=c.current.getBoundingClientRect(),h=8,v=_=>{let y=0,S=0;switch(_){case"top":y=p.top-g.height-h,S=p.left+p.width/2-g.width/2;break;case"bottom":y=p.bottom+h,S=p.left+p.width/2-g.width/2;break;case"left":y=p.top+p.height/2-g.height/2,S=p.left-g.width-h;break;case"right":y=p.top+p.height/2-g.height/2,S=p.right+h;break}return{top:y,left:S}},k={top:["top","bottom","right","left"],bottom:["bottom","top","right","left"],left:["left","right","top","bottom"],right:["right","left","top","bottom"]};for(const _ of k[t]){const{top:y,left:S}=v(_);if(!(y<0||S<0||y+g.height>window.innerHeight||S+g.width>window.innerWidth)){s({top:y,left:S});return}}const b=v(t);s(b)},[n,t]),i.jsxs(i.Fragment,{children:[i.jsx("div",{ref:l,className:"inline-block",onMouseEnter:d,onMouseLeave:f,children:o}),n&&Me.createPortal(i.jsx("div",{ref:c,style:{top:a.top,left:a.left},className:"fixed z-50 p-4 bg-color-white rounded shadow-lg",onMouseEnter:d,onMouseLeave:f,children:e}),document.body)]})};function Ja(...e){return e.filter(Boolean).join(" ")}const Qa={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl","4xl":"max-w-4xl","6xl":"max-w-6xl"},qe=m.forwardRef(({id:e="dialog",open:o,onClose:t,shouldClose:n=!1,className:r,title:a,children:s,actions:l,showCloseIcon:c=!0,fullscreen:u=!1,fullWidth:d=!1,maxWidth:f},p)=>{const[g,h]=m.useState(o||!1),[v,k]=m.useState(!1),[b,_]=m.useState(!1),y=e,S=`${y}-overlay`,w=`${y}-title`,F=`${y}-close`,A=`${y}-content`,B=`${y}-actions`;m.useEffect(()=>{o!==void 0&&h(o)},[o]),m.useImperativeHandle(p,()=>({open:()=>h(!0),close:()=>{_(!1),setTimeout(()=>h(!1),300)}})),m.useEffect(()=>{let R;return g?(k(!0),R=setTimeout(()=>_(!0),10)):_(!1),()=>clearTimeout(R)},[g]);const oe=()=>{g||k(!1)};return m.useEffect(()=>{const R=ae=>{ae.key==="Escape"&&(t==null||t())};return g&&document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[g,t]),m.useEffect(()=>(g?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[g]),v?Me.createPortal(i.jsxs("div",{className:Ja("fixed inset-0 z-50 flex items-center justify-center transition-opacity duration-300",b?"opacity-100":"opacity-0 pointer-events-none"),children:[i.jsx("div",{id:S,className:"fixed inset-0 bg-color-black/50",onClick:()=>{n&&(t(),h(!1))}}),i.jsxs("div",{id:y,className:`relative flex flex-col z-50 bg-color-white rounded-xl shadow-lg transition-all duration-300 transform p-6 ${b?"opacity-100 scale-100":"opacity-0 scale-95"} ${u?"w-full h-[calc(100%_-_40px)] m-5":`${d?"w-full":"w-auto"} ${f?Qa[f]:""} mx-5`} ${r}`,onTransitionEnd:oe,children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a&&i.jsx("h2",{id:w,className:"text-xl font-semibold",children:a}),c&&i.jsx(ke,{id:F,color:"gray",icon:i.jsx("svg",{className:"size-5",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M11.9997 10.5865L16.9495 5.63672L18.3637 7.05093L13.4139 12.0007L18.3637 16.9504L16.9495 18.3646L11.9997 13.4149L7.04996 18.3646L5.63574 16.9504L10.5855 12.0007L5.63574 7.05093L7.04996 5.63672L11.9997 10.5865Z"})}),size:"small",roundedFull:!0,onClick:()=>{t==null||t(),h(!1)},variant:"transparent"})]}),i.jsx("div",{id:A,className:"grow lg:max-h-[calc(100vh_-_200px)] max-h-[calc(100vh_-_130px)] overflow-y-auto",children:s}),l&&i.jsx("div",{id:B,className:"mt-8",children:l})]})]}),document.body):null});function pt(e,o,t){return Math.min(Math.max(e,o),t)}function Ra(e,o){const{innerWidth:t,innerHeight:n}=window,r=pt(e.left,12,t-o.width-12),a=e.top+o.height>n?e.top-o.height:e.top;return{left:r,top:pt(a,12,n-12)}}function ei(e,o){const{innerWidth:t,innerHeight:n}=window,{scrollX:r,scrollY:a}=window,s=pt(e.left,r+12,r+t-o.width-12),l=e.top-a+o.height>n?e.top-o.height:e.top;return{left:s,top:pt(l,a+12,1/0)}}function ti({items:e,trigger:o,className:t,dropdownItemClass:n,positioning:r="fixed"}){const[a,s]=m.useState(!1),[l,c]=m.useState({top:0,left:0}),[u,d]=m.useState(!1),f=m.useRef(null),p=m.useRef(null),g=v=>{v.stopPropagation(),s(k=>!k),d(!1),a||c(r==="fixed"?{top:v.clientY,left:v.clientX}:{top:v.clientY+window.scrollY,left:v.clientX+window.scrollX})};m.useLayoutEffect(()=>{if(!a||!p.current)return;const v=p.current.getBoundingClientRect(),{top:k,left:b}=l,_=r==="fixed"?Ra(l,v):ei(l,v);(_.left!==b||_.top!==k)&&c(_),setTimeout(()=>d(!0),150)},[a,r]),m.useEffect(()=>{const v=k=>{var b;p.current&&!p.current.contains(k.target)&&!((b=f.current)!=null&&b.contains(k.target))&&s(!1)};return a&&document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[a]);const h=i.jsx("div",{ref:p,className:`${r} mt-2 z-50 rounded-xl bg-color-white shadow-xl p-2 min-w-[160px] transition-all duration-200 transform ${u?"opacity-100 scale-100":"opacity-0 scale-95"} ${t}`,style:{top:l.top,left:l.left},children:e.map((v,k)=>i.jsxs("button",{type:"button",disabled:v.disabled,onClick:()=>{var b;(b=v.onClick)==null||b.call(v),s(!1)},className:`flex items-center gap-3 w-full text-left px-3 py-2 bg-color-transparent hover:bg-color-gray-100 transition-all cursor-pointer rounded-md text-md text-color-gray-700 ${v.disabled?"opacity-50 hover:bg-color-transparent !cursor-not-allowed":""} ${n} ${v.itemClass}`,children:[v.icon&&i.jsx("span",{children:v.icon}),i.jsx("span",{children:v.label})]},k))});return i.jsxs(i.Fragment,{children:[i.jsx("div",{ref:f,onClick:g,className:"cursor-pointer",children:o}),a&&Me.createPortal(h,document.body)]})}function oi(...e){return e.filter(Boolean).join(" ")}const sn=({open:e,onClose:o,className:t,title:n,children:r,childrenClass:a,actions:s,showCloseIcon:l=!0,anchor:c="left"})=>{const[u,d]=m.useState(!1),[f,p]=m.useState(!1);m.useEffect(()=>{let k;return e?(d(!0),k=setTimeout(()=>{p(!0)},10)):p(!1),()=>clearTimeout(k)},[e]);const g=()=>{e||d(!1)};if(m.useEffect(()=>{const k=b=>{b.key==="Escape"&&(o==null||o())};return e&&document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[e,o]),m.useEffect(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),!u)return null;const h={left:"left-0 top-0 h-full min-w-96 transition-all duration-300",right:"right-0 top-0 h-full min-w-96 transition-all duration-300",top:"top-0 left-0 w-full min-h-40 transition-all duration-300",bottom:"bottom-0 left-0 w-full min-h-40 transition-all duration-300"},v={left:f?"translate-x-0":"-translate-x-full",right:f?"translate-x-0":"translate-x-full",top:f?"translate-y-0":"-translate-y-full",bottom:f?"translate-y-0":"translate-y-full"};return Me.createPortal(i.jsxs("div",{className:oi("fixed inset-0 z-50 transition-opacity duration-300",f?"opacity-100":"opacity-0 pointer-events-none"),children:[i.jsx("div",{className:"fixed inset-0 bg-color-black/50",onClick:o}),i.jsxs("div",{className:`
|
|
148
|
+
`,onClick:U=>{U.stopPropagation(),!I&&Z(M,N)},children:[D&&q&&i.jsx("div",{className:"absolute top-2 right-2 w-6 h-6 bg-color-red-500 rounded-full flex items-center justify-center",children:i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"w-4 h-4 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),!R&&D&&!q&&F&&i.jsx("div",{className:`absolute rounded-full flex items-center justify-center shadow-sm ${B}`,children:A||i.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`${oe} text-color-white`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),i.jsxs("div",{className:`flex items-start gap-3 ${q?"text-color-red-700":""}`,children:[R&&i.jsx("button",{type:"button",onClick:U=>{U.stopPropagation(),I||Z(M,N)},disabled:I,className:`mt-1 flex-shrink-0 rounded-full bg-color-gray-300 transition-all duration-150 ${G(p)} ${I?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,"aria-checked":D,children:D&&!q&&i.jsx("div",{className:"w-full h-full flex items-center justify-center",children:ae||A||i.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:`${oe} text-color-green-500`,fill:"currentColor",viewBox:"0 0 24 24",children:[i.jsx("circle",{cx:"12",cy:"12",r:"8"}),i.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor"})]})})}),i.jsx("div",{className:"flex-1",children:C})]})]})},M)})}),g&&!h&&i.jsx("div",{id:L,className:"mt-2 text-sm text-color-gray-600",children:g}),h&&!v&&g&&i.jsx("div",{id:L,className:"mt-2 text-sm text-color-red-600",children:g})]}):i.jsxs("div",{className:"w-full",children:[h&&v&&i.jsx("div",{className:"mb-3 p-3 bg-red-50 rounded text-color-red-700 text-sm",role:"alert",id:`${e}-error`,children:v}),i.jsx("div",{role:"radiogroup","aria-label":b,"aria-labelledby":_,"aria-describedby":L,"aria-required":k,className:`flex ${l==="row"?"flex-row gap-6":"flex-col gap-3"} ${d}`,children:o.map(({label:C,value:M,disabled:E,id:V},N)=>{const I=c||E,D=T===M,q=h&&D;return i.jsxs("label",{className:`relative flex items-center cursor-pointer select-none transition ${I?"opacity-50 cursor-not-allowed":"hover:opacity-90"}`,children:[i.jsx("input",{type:"radio",name:e,value:M,disabled:I,checked:D,onChange:()=>!I&&Z(M,N),onBlur:ne,onFocus:U=>Y(U,N),className:"sr-only peer","aria-invalid":h,...V&&{id:V}}),i.jsx("div",{className:`rounded-full border-2 transition-all duration-150 ${q?"border-color-red-500 peer-checked:border-[7px] peer-checked:border-color-red-500":`border-color-gray-400 peer-checked:border-[7px] ${z.border}`} ${f} ${G(p)}`}),i.jsx("span",{className:`ml-2 text-sm ${q?"text-color-red-500":z.text}`,children:C})]},M)})}),g&&!h&&i.jsx("div",{id:L,className:"mt-2 text-sm text-color-gray-600",children:g}),h&&!v&&g&&i.jsx("div",{id:L,className:"mt-2 text-sm text-color-red-600",children:g})]})},Ua=({label:e,value:o,onChange:t,options:n,className:r="",labelClass:a="",inputClass:s="",disabled:l=!1,size:c="medium",variant:u="outlined",rounded:d="medium",shadow:f=!1})=>{const p={small:"p-2",medium:"p-3",large:"p-4"},g={small:"rounded-md",medium:"rounded-lg",full:"rounded-full"},h={filled:"bg-color-gray-100 border-color-gray-200",outlined:"border-color-gray-300 bg-color-transparent"};return i.jsxs("div",{className:`relative w-full ${r}`,children:[e&&i.jsx("label",{className:`text-sm text-color-gray-500 pointer-events-none block mb-1 ${a}`,children:e}),i.jsxs("div",{className:"relative",children:[i.jsx("select",{disabled:l,value:o,onChange:v=>t(v.target.value),className:`appearance-none focus:ring-1 text-color-gray-800 w-full border outline-none transition-all ${g[d]} ${p[c]} ${h[u]} ${l?"!bg-color-gray-50 opacity-60 cursor-not-allowed":""} ${f?"shadow-md shadow-color-zinc-100":""} ${s}`,children:n.map(v=>i.jsx("option",{value:v.value,className:"text-color-gray-900",children:v.label},v.value))}),i.jsx("span",{className:`absolute right-3 text-sm top-1/2 -translate-y-1/2 pointer-events-none ${l?"opacity-60":""}`,children:i.jsx("svg",{className:"size-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M11.9999 13.1714L16.9497 8.22168L18.3639 9.63589L11.9999 15.9999L5.63599 9.63589L7.0502 8.22168L11.9999 13.1714Z"})})})]})]})},Ka=({content:e,children:o,position:t="top"})=>{const[n,r]=m.useState(!1),[a,s]=m.useState({top:0,left:0}),l=m.useRef(null),c=m.useRef(null);return m.useEffect(()=>{if(n&&l.current&&c.current){const u=l.current.getBoundingClientRect(),d=c.current.getBoundingClientRect();let f=0,p=0;switch(t){case"top":f=u.top-d.height-8,p=u.left+u.width/2-d.width/2;break;case"bottom":f=u.bottom+8,p=u.left+u.width/2-d.width/2;break;case"left":f=u.top+u.height/2-d.height/2,p=u.left-d.width-8;break;case"right":f=u.top+u.height/2-d.height/2,p=u.right+8;break}s({top:f,left:p})}},[n,t]),i.jsxs(i.Fragment,{children:[i.jsx("div",{ref:l,className:"inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:o}),n&&Me.createPortal(i.jsx("div",{ref:c,style:{top:a.top,left:a.left},className:"fixed z-50 text-center px-2 max-w-xs py-1 text-sm text-color-white bg-color-gray-800 rounded shadow-md pointer-events-none",children:e}),document.body)]})},Xa=({content:e,children:o,position:t="top"})=>{const[n,r]=m.useState(!1),[a,s]=m.useState({top:0,left:0}),l=m.useRef(null),c=m.useRef(null),u=m.useRef(null),d=()=>{u.current&&clearTimeout(u.current),r(!0)},f=()=>{u.current=setTimeout(()=>{r(!1)},100)};return m.useEffect(()=>{if(!n||!l.current||!c.current)return;const p=l.current.getBoundingClientRect(),g=c.current.getBoundingClientRect(),h=8,v=_=>{let y=0,S=0;switch(_){case"top":y=p.top-g.height-h,S=p.left+p.width/2-g.width/2;break;case"bottom":y=p.bottom+h,S=p.left+p.width/2-g.width/2;break;case"left":y=p.top+p.height/2-g.height/2,S=p.left-g.width-h;break;case"right":y=p.top+p.height/2-g.height/2,S=p.right+h;break}return{top:y,left:S}},k={top:["top","bottom","right","left"],bottom:["bottom","top","right","left"],left:["left","right","top","bottom"],right:["right","left","top","bottom"]};for(const _ of k[t]){const{top:y,left:S}=v(_);if(!(y<0||S<0||y+g.height>window.innerHeight||S+g.width>window.innerWidth)){s({top:y,left:S});return}}const b=v(t);s(b)},[n,t]),i.jsxs(i.Fragment,{children:[i.jsx("div",{ref:l,className:"inline-block",onMouseEnter:d,onMouseLeave:f,children:o}),n&&Me.createPortal(i.jsx("div",{ref:c,style:{top:a.top,left:a.left},className:"fixed z-50 p-4 bg-color-white rounded shadow-lg",onMouseEnter:d,onMouseLeave:f,children:e}),document.body)]})};function Ja(...e){return e.filter(Boolean).join(" ")}const Qa={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl","4xl":"max-w-4xl","6xl":"max-w-6xl"},qe=m.forwardRef(({id:e="dialog",open:o,onClose:t,shouldClose:n=!1,className:r,title:a,children:s,actions:l,showCloseIcon:c=!0,fullscreen:u=!1,fullWidth:d=!1,maxWidth:f},p)=>{const[g,h]=m.useState(o||!1),[v,k]=m.useState(!1),[b,_]=m.useState(!1),y=e,S=`${y}-overlay`,w=`${y}-title`,F=`${y}-close`,A=`${y}-content`,B=`${y}-actions`;m.useEffect(()=>{o!==void 0&&h(o)},[o]),m.useImperativeHandle(p,()=>({open:()=>h(!0),close:()=>{_(!1),setTimeout(()=>h(!1),300)}})),m.useEffect(()=>{let R;return g?(k(!0),R=setTimeout(()=>_(!0),10)):_(!1),()=>clearTimeout(R)},[g]);const oe=()=>{g||k(!1)};return m.useEffect(()=>{const R=ae=>{ae.key==="Escape"&&(t==null||t())};return g&&document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[g,t]),m.useEffect(()=>(g?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[g]),v?Me.createPortal(i.jsxs("div",{className:Ja("fixed inset-0 z-50 flex items-center justify-center transition-opacity duration-300",b?"opacity-100":"opacity-0 pointer-events-none"),children:[i.jsx("div",{id:S,className:"fixed inset-0 bg-color-black/50",onClick:()=>{n&&(t(),h(!1))}}),i.jsxs("div",{id:y,className:`relative flex flex-col z-50 bg-color-white rounded-xl shadow-lg transition-all duration-300 transform p-6 ${b?"opacity-100 scale-100":"opacity-0 scale-95"} ${u?"w-full h-[calc(100%_-_40px)] m-5":`${d?"w-full":"w-auto"} ${f?Qa[f]:""} mx-5`} ${r}`,onTransitionEnd:oe,children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a&&i.jsx("h2",{id:w,className:"text-xl font-semibold",children:a}),c&&i.jsx(ke,{id:F,color:"gray",icon:i.jsx("svg",{className:"size-5",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("path",{d:"M11.9997 10.5865L16.9495 5.63672L18.3637 7.05093L13.4139 12.0007L18.3637 16.9504L16.9495 18.3646L11.9997 13.4149L7.04996 18.3646L5.63574 16.9504L10.5855 12.0007L5.63574 7.05093L7.04996 5.63672L11.9997 10.5865Z"})}),size:"small",roundedFull:!0,onClick:()=>{t==null||t(),h(!1)},variant:"transparent"})]}),i.jsx("div",{id:A,className:"grow lg:max-h-[calc(100vh_-_200px)] max-h-[calc(100vh_-_130px)] overflow-y-auto",children:s}),l&&i.jsx("div",{id:B,className:"mt-8",children:l})]})]}),document.body):null});function pt(e,o,t){return Math.min(Math.max(e,o),t)}function Ra(e,o){const{innerWidth:t,innerHeight:n}=window,r=pt(e.left,12,t-o.width-12),a=e.top+o.height>n?e.top-o.height:e.top;return{left:r,top:pt(a,12,n-12)}}function ei(e,o){const{innerWidth:t,innerHeight:n}=window,{scrollX:r,scrollY:a}=window,s=pt(e.left,r+12,r+t-o.width-12),l=e.top-a+o.height>n?e.top-o.height:e.top;return{left:s,top:pt(l,a+12,1/0)}}function ti({items:e,trigger:o,className:t,dropdownItemClass:n,positioning:r="fixed"}){const[a,s]=m.useState(!1),[l,c]=m.useState({top:0,left:0}),[u,d]=m.useState(!1),f=m.useRef(null),p=m.useRef(null),g=v=>{v.stopPropagation(),s(k=>!k),d(!1),a||c(r==="fixed"?{top:v.clientY,left:v.clientX}:{top:v.clientY+window.scrollY,left:v.clientX+window.scrollX})};m.useLayoutEffect(()=>{if(!a||!p.current)return;const v=p.current.getBoundingClientRect(),{top:k,left:b}=l,_=r==="fixed"?Ra(l,v):ei(l,v);(_.left!==b||_.top!==k)&&c(_),setTimeout(()=>d(!0),150)},[a,r]),m.useEffect(()=>{const v=k=>{var b;p.current&&!p.current.contains(k.target)&&!((b=f.current)!=null&&b.contains(k.target))&&s(!1)};return a&&document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[a]);const h=i.jsx("div",{ref:p,className:`${r} mt-2 z-50 rounded-xl bg-color-white shadow-xl p-2 min-w-[160px] transition-all duration-200 transform ${u?"opacity-100 scale-100":"opacity-0 scale-95"} ${t}`,style:{top:l.top,left:l.left},children:e.map((v,k)=>i.jsxs("button",{type:"button",disabled:v.disabled,onClick:()=>{var b;(b=v.onClick)==null||b.call(v),s(!1)},className:`flex items-center gap-3 w-full text-left px-3 py-2 bg-color-transparent hover:bg-color-gray-100 transition-all cursor-pointer rounded-md text-md text-color-gray-700 ${v.disabled?"opacity-50 hover:bg-color-transparent !cursor-not-allowed":""} ${n} ${v.itemClass}`,children:[v.icon&&i.jsx("span",{children:v.icon}),i.jsx("span",{children:v.label})]},k))});return i.jsxs(i.Fragment,{children:[i.jsx("div",{ref:f,onClick:g,className:"cursor-pointer",children:o}),a&&Me.createPortal(h,document.body)]})}function oi(...e){return e.filter(Boolean).join(" ")}const sn=({open:e,onClose:o,className:t,title:n,children:r,childrenClass:a,actions:s,showCloseIcon:l=!0,anchor:c="left"})=>{const[u,d]=m.useState(!1),[f,p]=m.useState(!1);m.useEffect(()=>{let k;return e?(d(!0),k=setTimeout(()=>{p(!0)},10)):p(!1),()=>clearTimeout(k)},[e]);const g=()=>{e||d(!1)};if(m.useEffect(()=>{const k=b=>{b.key==="Escape"&&(o==null||o())};return e&&document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[e,o]),m.useEffect(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),!u)return null;const h={left:"left-0 top-0 h-full min-w-96 transition-all duration-300",right:"right-0 top-0 h-full min-w-96 transition-all duration-300",top:"top-0 left-0 w-full min-h-40 transition-all duration-300",bottom:"bottom-0 left-0 w-full min-h-40 transition-all duration-300"},v={left:f?"translate-x-0":"-translate-x-full",right:f?"translate-x-0":"translate-x-full",top:f?"translate-y-0":"-translate-y-full",bottom:f?"translate-y-0":"translate-y-full"};return Me.createPortal(i.jsxs("div",{className:oi("fixed inset-0 z-50 transition-opacity duration-300",f?"opacity-100":"opacity-0 pointer-events-none"),children:[i.jsx("div",{className:"fixed inset-0 bg-color-black/50",onClick:o}),i.jsxs("div",{className:`
|
|
149
149
|
fixed bg-color-white shadow-lg z-50 p-6 flex flex-col
|
|
150
150
|
${h[c]}
|
|
151
151
|
${v[c]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unizap/uniui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "UniUi helps developers and designers build beautiful, responsive UIs faster with ready-made, customizable components. Simplify your workflow and create stunning user interfaces effortlessly.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|