@unizap/uniui 1.0.72 → 1.0.73

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 CHANGED
@@ -7546,7 +7546,7 @@ const Ir = {
7546
7546
  ({
7547
7547
  open: e,
7548
7548
  onClose: o,
7549
- shouldClose: t = !0,
7549
+ shouldClose: t = !1,
7550
7550
  className: n,
7551
7551
  title: i,
7552
7552
  children: r,
@@ -7612,7 +7612,7 @@ const Ir = {
7612
7612
  size: "small",
7613
7613
  roundedFull: !0,
7614
7614
  onClick: () => {
7615
- t && (o(), d(!1));
7615
+ o == null || o(), d(!1);
7616
7616
  },
7617
7617
  variant: "transparent"
7618
7618
  }
@@ -153,7 +153,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
153
153
  ${L?H?"border-color-red-500 bg-red-50":`${k}`:"border-color-gray-300 bg-white hover:border-color-gray-400"}
154
154
  ${_?"":"hover:shadow-md"}
155
155
  ${$}
156
- `,onClick:B=>{B.stopPropagation(),!_&&R(E,N)},children:[L&&H&&a.jsx("div",{className:"absolute top-2 right-2 w-6 h-6 bg-color-red-500 rounded-full flex items-center justify-center",children:a.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:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),!X&&L&&!H&&V&&a.jsx("div",{className:`absolute rounded-full flex items-center justify-center shadow-sm ${Z}`,children:j||a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`${ee} text-color-white`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),a.jsxs("div",{className:`flex items-start gap-3 ${H?"text-color-red-700":""}`,children:[X&&a.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),_||R(E,N)},disabled:_,className:`mt-1 flex-shrink-0 rounded-full bg-color-gray-300 transition-all duration-150 ${D(p)} ${_?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,"aria-checked":L,children:L&&!H&&a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:G||j||a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:`${ee} text-color-green-500`,fill:"currentColor",viewBox:"0 0 24 24",children:[a.jsx("circle",{cx:"12",cy:"12",r:"8"}),a.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor"})]})})}),a.jsx("div",{className:"flex-1",children:A})]})]})},E)})}),d&&!x&&a.jsx("div",{id:S,className:"mt-2 text-sm text-color-gray-600",children:d}),x&&!f&&d&&a.jsx("div",{id:S,className:"mt-2 text-sm text-color-red-600",children:d})]}):a.jsxs("div",{className:"w-full",children:[x&&f&&a.jsx("div",{className:"mb-3 p-3 bg-red-50 rounded text-color-red-700 text-sm",role:"alert",id:`${e}-error`,children:f}),a.jsx("div",{role:"radiogroup","aria-label":b,"aria-labelledby":z,"aria-describedby":S,"aria-required":w,className:`flex ${s==="row"?"flex-row gap-6":"flex-col gap-3"} ${g}`,children:o.map(({label:A,value:E,disabled:O,id:Y},N)=>{const _=c||O,L=T===E,H=x&&L;return a.jsxs("label",{className:`relative flex items-center cursor-pointer select-none transition ${_?"opacity-50 cursor-not-allowed":"hover:opacity-90"}`,children:[a.jsx("input",{type:"radio",name:e,value:E,disabled:_,checked:L,onChange:()=>!_&&R(E,N),onBlur:pe,onFocus:B=>M(B,N),className:"sr-only peer","aria-invalid":x,...Y&&{id:Y}}),a.jsx("div",{className:`rounded-full border-2 transition-all duration-150 ${H?"border-color-red-500 peer-checked:border-[7px] peer-checked:border-color-red-500":`border-color-gray-400 peer-checked:border-[7px] ${C.border}`} ${m} ${D(p)}`}),a.jsx("span",{className:`ml-2 text-sm ${H?"text-color-red-500":C.text}`,children:A})]},E)})}),d&&!x&&a.jsx("div",{id:S,className:"mt-2 text-sm text-color-gray-600",children:d}),x&&!f&&d&&a.jsx("div",{id:S,className:"mt-2 text-sm text-color-red-600",children:d})]})},Ta=({label:e,value:o,onChange:t,options:n,className:r="",labelClass:i="",inputClass:l="",disabled:s=!1,size:c="medium",variant:u="outlined",rounded:g="medium",shadow:m=!1})=>{const p={small:"p-2",medium:"p-3",large:"p-4"},d={small:"rounded-md",medium:"rounded-lg",full:"rounded-full"},x={filled:"bg-color-gray-100 border-color-gray-200",outlined:"border-color-gray-300 bg-color-transparent"};return a.jsxs("div",{className:`relative w-full ${r}`,children:[e&&a.jsx("label",{className:`text-sm text-color-gray-500 pointer-events-none block mb-1 ${i}`,children:e}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{disabled:s,value:o,onChange:f=>t(f.target.value),className:`appearance-none focus:ring-1 text-color-gray-800 w-full border outline-none transition-all ${d[g]} ${p[c]} ${x[u]} ${s?"!bg-color-gray-50 opacity-60 cursor-not-allowed":""} ${m?"shadow-md shadow-color-zinc-100":""} ${l}`,children:n.map(f=>a.jsx("option",{value:f.value,className:"text-color-gray-900",children:f.label},f.value))}),a.jsx("span",{className:`absolute right-3 text-sm top-1/2 -translate-y-1/2 ${s?"opacity-60":""}`,children:a.jsx("svg",{className:"size-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:a.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"})})})]})]})},Ia=({content:e,children:o,position:t="top"})=>{const[n,r]=v.useState(!1),[i,l]=v.useState({top:0,left:0}),s=v.useRef(null),c=v.useRef(null);return v.useEffect(()=>{if(n&&s.current&&c.current){const u=s.current.getBoundingClientRect(),g=c.current.getBoundingClientRect();let m=0,p=0;switch(t){case"top":m=u.top-g.height-8,p=u.left+u.width/2-g.width/2;break;case"bottom":m=u.bottom+8,p=u.left+u.width/2-g.width/2;break;case"left":m=u.top+u.height/2-g.height/2,p=u.left-g.width-8;break;case"right":m=u.top+u.height/2-g.height/2,p=u.right+8;break}l({top:m,left:p})}},[n,t]),a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:s,className:"inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:o}),n&&qe.createPortal(a.jsx("div",{ref:c,style:{top:i.top,left:i.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)]})};function Da(...e){return e.filter(Boolean).join(" ")}const ja={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"},We=v.forwardRef(({open:e,onClose:o,shouldClose:t=!0,className:n,title:r,children:i,actions:l,showCloseIcon:s=!0,fullscreen:c=!1,fullWidth:u=!1,maxWidth:g},m)=>{const[p,d]=v.useState(e||!1),[x,f]=v.useState(!1),[w,b]=v.useState(!1);v.useEffect(()=>{e!==void 0&&d(e)},[e]),v.useImperativeHandle(m,()=>({open:()=>d(!0),close:()=>{b(!1),setTimeout(()=>d(!1),300)}})),v.useEffect(()=>{let y;return p?(f(!0),y=setTimeout(()=>b(!0),10)):b(!1),()=>clearTimeout(y)},[p]);const z=()=>{p||f(!1)};return v.useEffect(()=>{const y=$=>{$.key==="Escape"&&(o==null||o())};return p&&document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[p,o]),v.useEffect(()=>(p?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[p]),x?qe.createPortal(a.jsxs("div",{className:Da("fixed inset-0 z-50 flex items-center justify-center transition-opacity duration-300",w?"opacity-100":"opacity-0 pointer-events-none"),children:[a.jsx("div",{className:"fixed inset-0 bg-color-black/50",onClick:()=>{t&&(o(),d(!1))}}),a.jsxs("div",{className:`relative flex flex-col z-50 bg-color-white rounded-xl shadow-lg transition-all duration-300 transform p-6 ${w?"opacity-100 scale-100":"opacity-0 scale-95"} ${c?"w-full h-[calc(100%_-_40px)] m-5":`${u?"w-full":"w-auto"} ${g?ja[g]:""} mx-5`} ${n}`,onTransitionEnd:z,children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r&&a.jsx("h2",{className:"text-xl font-semibold",children:r}),s&&a.jsx(_e,{color:"gray",icon:a.jsx("svg",{className:"size-5",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:a.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&&(o(),d(!1))},variant:"transparent"})]}),a.jsx("div",{className:"grow lg:max-h-[calc(100vh_-_200px)] max-h-[calc(100vh_-_130px)] overflow-y-auto",children:i}),l&&a.jsx("div",{className:"mt-8",children:l})]})]}),document.body):null});function Oa({items:e,trigger:o,className:t,dropdownItemClass:n,positioning:r="fixed"}){const[i,l]=v.useState(!1),[s,c]=v.useState({top:0,left:0}),[u,g]=v.useState(!1),m=v.useRef(null),p=v.useRef(null),d=f=>{f.stopPropagation(),l(w=>!w),g(!1),i||c(r==="fixed"?{top:f.clientY,left:f.clientX}:{top:f.clientY+window.scrollY,left:f.clientX+window.scrollX})};v.useLayoutEffect(()=>{if(i&&p.current){const f=p.current.getBoundingClientRect(),w=window.innerWidth,b=window.innerHeight;let{left:z,top:y}=s;const $=z,k=y;if(r==="fixed")z+f.width>w&&(z=w-f.width-12),z<12&&(z=12),y+f.height>b&&(y=k-f.height),y<12&&(y=12);else{const V=window.scrollX,j=window.scrollY;z-V+f.width>w&&(z=V+w-f.width-12),z<V+12&&(z=V+12),y-j+f.height>b&&(y=k-f.height),y<j+12&&(y=j+12)}(z!==$||y!==k)&&c({top:y,left:z}),setTimeout(()=>{g(!0)},150)}},[i,r]),v.useEffect(()=>{const f=w=>{var b;p.current&&!p.current.contains(w.target)&&!((b=m.current)!=null&&b.contains(w.target))&&l(!1)};return i&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[i]);const x=a.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:s.top,left:s.left},children:e.map((f,w)=>a.jsxs("button",{type:"button",disabled:f.disabled,onClick:()=>{var b;(b=f.onClick)==null||b.call(f),l(!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 ${f.disabled?"opacity-50 hover:bg-color-transparent !cursor-not-allowed":""} ${n} ${f.itemClass}`,children:[f.icon&&a.jsx("span",{children:f.icon}),a.jsx("span",{children:f.label})]},w))});return a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:m,onClick:d,className:"cursor-pointer",children:o}),i&&qe.createPortal(x,document.body)]})}function Va(...e){return e.filter(Boolean).join(" ")}const sn=({open:e,onClose:o,className:t,title:n,children:r,childrenClass:i,actions:l,showCloseIcon:s=!0,anchor:c="left"})=>{const[u,g]=v.useState(!1),[m,p]=v.useState(!1);v.useEffect(()=>{let w;return e?(g(!0),w=setTimeout(()=>{p(!0)},10)):p(!1),()=>clearTimeout(w)},[e]);const d=()=>{e||g(!1)};if(v.useEffect(()=>{const w=b=>{b.key==="Escape"&&(o==null||o())};return e&&document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[e,o]),v.useEffect(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),!u)return null;const x={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"},f={left:m?"translate-x-0":"-translate-x-full",right:m?"translate-x-0":"translate-x-full",top:m?"translate-y-0":"-translate-y-full",bottom:m?"translate-y-0":"translate-y-full"};return qe.createPortal(a.jsxs("div",{className:Va("fixed inset-0 z-50 transition-opacity duration-300",m?"opacity-100":"opacity-0 pointer-events-none"),children:[a.jsx("div",{className:"fixed inset-0 bg-color-black/50",onClick:o}),a.jsxs("div",{className:`
156
+ `,onClick:B=>{B.stopPropagation(),!_&&R(E,N)},children:[L&&H&&a.jsx("div",{className:"absolute top-2 right-2 w-6 h-6 bg-color-red-500 rounded-full flex items-center justify-center",children:a.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:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),!X&&L&&!H&&V&&a.jsx("div",{className:`absolute rounded-full flex items-center justify-center shadow-sm ${Z}`,children:j||a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`${ee} text-color-white`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),a.jsxs("div",{className:`flex items-start gap-3 ${H?"text-color-red-700":""}`,children:[X&&a.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),_||R(E,N)},disabled:_,className:`mt-1 flex-shrink-0 rounded-full bg-color-gray-300 transition-all duration-150 ${D(p)} ${_?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,"aria-checked":L,children:L&&!H&&a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:G||j||a.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:`${ee} text-color-green-500`,fill:"currentColor",viewBox:"0 0 24 24",children:[a.jsx("circle",{cx:"12",cy:"12",r:"8"}),a.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor"})]})})}),a.jsx("div",{className:"flex-1",children:A})]})]})},E)})}),d&&!x&&a.jsx("div",{id:S,className:"mt-2 text-sm text-color-gray-600",children:d}),x&&!f&&d&&a.jsx("div",{id:S,className:"mt-2 text-sm text-color-red-600",children:d})]}):a.jsxs("div",{className:"w-full",children:[x&&f&&a.jsx("div",{className:"mb-3 p-3 bg-red-50 rounded text-color-red-700 text-sm",role:"alert",id:`${e}-error`,children:f}),a.jsx("div",{role:"radiogroup","aria-label":b,"aria-labelledby":z,"aria-describedby":S,"aria-required":w,className:`flex ${s==="row"?"flex-row gap-6":"flex-col gap-3"} ${g}`,children:o.map(({label:A,value:E,disabled:O,id:Y},N)=>{const _=c||O,L=T===E,H=x&&L;return a.jsxs("label",{className:`relative flex items-center cursor-pointer select-none transition ${_?"opacity-50 cursor-not-allowed":"hover:opacity-90"}`,children:[a.jsx("input",{type:"radio",name:e,value:E,disabled:_,checked:L,onChange:()=>!_&&R(E,N),onBlur:pe,onFocus:B=>M(B,N),className:"sr-only peer","aria-invalid":x,...Y&&{id:Y}}),a.jsx("div",{className:`rounded-full border-2 transition-all duration-150 ${H?"border-color-red-500 peer-checked:border-[7px] peer-checked:border-color-red-500":`border-color-gray-400 peer-checked:border-[7px] ${C.border}`} ${m} ${D(p)}`}),a.jsx("span",{className:`ml-2 text-sm ${H?"text-color-red-500":C.text}`,children:A})]},E)})}),d&&!x&&a.jsx("div",{id:S,className:"mt-2 text-sm text-color-gray-600",children:d}),x&&!f&&d&&a.jsx("div",{id:S,className:"mt-2 text-sm text-color-red-600",children:d})]})},Ta=({label:e,value:o,onChange:t,options:n,className:r="",labelClass:i="",inputClass:l="",disabled:s=!1,size:c="medium",variant:u="outlined",rounded:g="medium",shadow:m=!1})=>{const p={small:"p-2",medium:"p-3",large:"p-4"},d={small:"rounded-md",medium:"rounded-lg",full:"rounded-full"},x={filled:"bg-color-gray-100 border-color-gray-200",outlined:"border-color-gray-300 bg-color-transparent"};return a.jsxs("div",{className:`relative w-full ${r}`,children:[e&&a.jsx("label",{className:`text-sm text-color-gray-500 pointer-events-none block mb-1 ${i}`,children:e}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{disabled:s,value:o,onChange:f=>t(f.target.value),className:`appearance-none focus:ring-1 text-color-gray-800 w-full border outline-none transition-all ${d[g]} ${p[c]} ${x[u]} ${s?"!bg-color-gray-50 opacity-60 cursor-not-allowed":""} ${m?"shadow-md shadow-color-zinc-100":""} ${l}`,children:n.map(f=>a.jsx("option",{value:f.value,className:"text-color-gray-900",children:f.label},f.value))}),a.jsx("span",{className:`absolute right-3 text-sm top-1/2 -translate-y-1/2 ${s?"opacity-60":""}`,children:a.jsx("svg",{className:"size-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:a.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"})})})]})]})},Ia=({content:e,children:o,position:t="top"})=>{const[n,r]=v.useState(!1),[i,l]=v.useState({top:0,left:0}),s=v.useRef(null),c=v.useRef(null);return v.useEffect(()=>{if(n&&s.current&&c.current){const u=s.current.getBoundingClientRect(),g=c.current.getBoundingClientRect();let m=0,p=0;switch(t){case"top":m=u.top-g.height-8,p=u.left+u.width/2-g.width/2;break;case"bottom":m=u.bottom+8,p=u.left+u.width/2-g.width/2;break;case"left":m=u.top+u.height/2-g.height/2,p=u.left-g.width-8;break;case"right":m=u.top+u.height/2-g.height/2,p=u.right+8;break}l({top:m,left:p})}},[n,t]),a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:s,className:"inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:o}),n&&qe.createPortal(a.jsx("div",{ref:c,style:{top:i.top,left:i.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)]})};function Da(...e){return e.filter(Boolean).join(" ")}const ja={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"},We=v.forwardRef(({open:e,onClose:o,shouldClose:t=!1,className:n,title:r,children:i,actions:l,showCloseIcon:s=!0,fullscreen:c=!1,fullWidth:u=!1,maxWidth:g},m)=>{const[p,d]=v.useState(e||!1),[x,f]=v.useState(!1),[w,b]=v.useState(!1);v.useEffect(()=>{e!==void 0&&d(e)},[e]),v.useImperativeHandle(m,()=>({open:()=>d(!0),close:()=>{b(!1),setTimeout(()=>d(!1),300)}})),v.useEffect(()=>{let y;return p?(f(!0),y=setTimeout(()=>b(!0),10)):b(!1),()=>clearTimeout(y)},[p]);const z=()=>{p||f(!1)};return v.useEffect(()=>{const y=$=>{$.key==="Escape"&&(o==null||o())};return p&&document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[p,o]),v.useEffect(()=>(p?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[p]),x?qe.createPortal(a.jsxs("div",{className:Da("fixed inset-0 z-50 flex items-center justify-center transition-opacity duration-300",w?"opacity-100":"opacity-0 pointer-events-none"),children:[a.jsx("div",{className:"fixed inset-0 bg-color-black/50",onClick:()=>{t&&(o(),d(!1))}}),a.jsxs("div",{className:`relative flex flex-col z-50 bg-color-white rounded-xl shadow-lg transition-all duration-300 transform p-6 ${w?"opacity-100 scale-100":"opacity-0 scale-95"} ${c?"w-full h-[calc(100%_-_40px)] m-5":`${u?"w-full":"w-auto"} ${g?ja[g]:""} mx-5`} ${n}`,onTransitionEnd:z,children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r&&a.jsx("h2",{className:"text-xl font-semibold",children:r}),s&&a.jsx(_e,{color:"gray",icon:a.jsx("svg",{className:"size-5",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:a.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:()=>{o==null||o(),d(!1)},variant:"transparent"})]}),a.jsx("div",{className:"grow lg:max-h-[calc(100vh_-_200px)] max-h-[calc(100vh_-_130px)] overflow-y-auto",children:i}),l&&a.jsx("div",{className:"mt-8",children:l})]})]}),document.body):null});function Oa({items:e,trigger:o,className:t,dropdownItemClass:n,positioning:r="fixed"}){const[i,l]=v.useState(!1),[s,c]=v.useState({top:0,left:0}),[u,g]=v.useState(!1),m=v.useRef(null),p=v.useRef(null),d=f=>{f.stopPropagation(),l(w=>!w),g(!1),i||c(r==="fixed"?{top:f.clientY,left:f.clientX}:{top:f.clientY+window.scrollY,left:f.clientX+window.scrollX})};v.useLayoutEffect(()=>{if(i&&p.current){const f=p.current.getBoundingClientRect(),w=window.innerWidth,b=window.innerHeight;let{left:z,top:y}=s;const $=z,k=y;if(r==="fixed")z+f.width>w&&(z=w-f.width-12),z<12&&(z=12),y+f.height>b&&(y=k-f.height),y<12&&(y=12);else{const V=window.scrollX,j=window.scrollY;z-V+f.width>w&&(z=V+w-f.width-12),z<V+12&&(z=V+12),y-j+f.height>b&&(y=k-f.height),y<j+12&&(y=j+12)}(z!==$||y!==k)&&c({top:y,left:z}),setTimeout(()=>{g(!0)},150)}},[i,r]),v.useEffect(()=>{const f=w=>{var b;p.current&&!p.current.contains(w.target)&&!((b=m.current)!=null&&b.contains(w.target))&&l(!1)};return i&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[i]);const x=a.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:s.top,left:s.left},children:e.map((f,w)=>a.jsxs("button",{type:"button",disabled:f.disabled,onClick:()=>{var b;(b=f.onClick)==null||b.call(f),l(!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 ${f.disabled?"opacity-50 hover:bg-color-transparent !cursor-not-allowed":""} ${n} ${f.itemClass}`,children:[f.icon&&a.jsx("span",{children:f.icon}),a.jsx("span",{children:f.label})]},w))});return a.jsxs(a.Fragment,{children:[a.jsx("div",{ref:m,onClick:d,className:"cursor-pointer",children:o}),i&&qe.createPortal(x,document.body)]})}function Va(...e){return e.filter(Boolean).join(" ")}const sn=({open:e,onClose:o,className:t,title:n,children:r,childrenClass:i,actions:l,showCloseIcon:s=!0,anchor:c="left"})=>{const[u,g]=v.useState(!1),[m,p]=v.useState(!1);v.useEffect(()=>{let w;return e?(g(!0),w=setTimeout(()=>{p(!0)},10)):p(!1),()=>clearTimeout(w)},[e]);const d=()=>{e||g(!1)};if(v.useEffect(()=>{const w=b=>{b.key==="Escape"&&(o==null||o())};return e&&document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[e,o]),v.useEffect(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),!u)return null;const x={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"},f={left:m?"translate-x-0":"-translate-x-full",right:m?"translate-x-0":"translate-x-full",top:m?"translate-y-0":"-translate-y-full",bottom:m?"translate-y-0":"translate-y-full"};return qe.createPortal(a.jsxs("div",{className:Va("fixed inset-0 z-50 transition-opacity duration-300",m?"opacity-100":"opacity-0 pointer-events-none"),children:[a.jsx("div",{className:"fixed inset-0 bg-color-black/50",onClick:o}),a.jsxs("div",{className:`
157
157
  fixed bg-color-white shadow-lg z-50 p-6 flex flex-col
158
158
  ${x[c]}
159
159
  ${f[c]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unizap/uniui",
3
- "version": "1.0.72",
3
+ "version": "1.0.73",
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": [