@unizap/uniui 1.0.13 → 1.0.14
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 +3 -2
- package/dist/uniui.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/uniui.js
CHANGED
|
@@ -6814,7 +6814,7 @@ const Wa = {
|
|
|
6814
6814
|
var f, m;
|
|
6815
6815
|
const p = a || g;
|
|
6816
6816
|
return /* @__PURE__ */ s.jsxs(
|
|
6817
|
-
"
|
|
6817
|
+
"div",
|
|
6818
6818
|
{
|
|
6819
6819
|
className: `relative flex items-center cursor-pointer select-none transition ${p ? "opacity-50 cursor-not-allowed" : "hover:opacity-90"}`,
|
|
6820
6820
|
children: [
|
|
@@ -6824,6 +6824,7 @@ const Wa = {
|
|
|
6824
6824
|
type: "radio",
|
|
6825
6825
|
name: e,
|
|
6826
6826
|
value: d,
|
|
6827
|
+
id: `radio-${e}-${d}`,
|
|
6827
6828
|
disabled: p,
|
|
6828
6829
|
checked: t === d,
|
|
6829
6830
|
onChange: () => !p && (r == null ? void 0 : r(d)),
|
|
@@ -6836,7 +6837,7 @@ const Wa = {
|
|
|
6836
6837
|
className: `w-5 h-5 rounded-full border-2 border-color-gray-400 peer-checked:border-[7px] transition-all duration-150 ${(f = ge[i]) == null ? void 0 : f.peer} ${c}`
|
|
6837
6838
|
}
|
|
6838
6839
|
),
|
|
6839
|
-
/* @__PURE__ */ s.jsx("
|
|
6840
|
+
/* @__PURE__ */ s.jsx("label", { htmlFor: `radio-${e}-${d}`, className: `ml-2 text-sm text-color-gray-800 cursor-pointer ${(m = ge[i]) == null ? void 0 : m.peer}`, children: u })
|
|
6840
6841
|
]
|
|
6841
6842
|
},
|
|
6842
6843
|
d
|
package/dist/uniui.umd.cjs
CHANGED
|
@@ -160,7 +160,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
160
160
|
${r}
|
|
161
161
|
${n==="inset"?o?"pl-4":"pt-4":""}`,children:s.jsxs("div",{className:i,children:[s.jsx("div",{className:l}),s.jsx("span",{children:t}),s.jsx("div",{className:l})]})})}const a=o?"h-px w-full bg-color-gray-300":"w-px h-full bg-color-gray-300";return s.jsx("div",{role:"separator",className:`flex ${o?"w-full items-center":"h-full flex-col justify-center"}
|
|
162
162
|
${r}
|
|
163
|
-
${n==="inset"?o?"pl-4":"pt-4":""} ${a}`})},Xa=({name:e,options:n,selectedValue:t,onChange:r,direction:o="column",disabled:a=!1,color:i="blue",className:l="",radioClass:c})=>s.jsx("div",{className:`flex ${o==="row"?"flex-row gap-6":"flex-col gap-3"} ${l}`,children:n.map(({label:u,value:d,disabled:g})=>{var f,m;const p=a||g;return s.jsxs("
|
|
163
|
+
${n==="inset"?o?"pl-4":"pt-4":""} ${a}`})},Xa=({name:e,options:n,selectedValue:t,onChange:r,direction:o="column",disabled:a=!1,color:i="blue",className:l="",radioClass:c})=>s.jsx("div",{className:`flex ${o==="row"?"flex-row gap-6":"flex-col gap-3"} ${l}`,children:n.map(({label:u,value:d,disabled:g})=>{var f,m;const p=a||g;return s.jsxs("div",{className:`relative flex items-center cursor-pointer select-none transition ${p?"opacity-50 cursor-not-allowed":"hover:opacity-90"}`,children:[s.jsx("input",{type:"radio",name:e,value:d,id:`radio-${e}-${d}`,disabled:p,checked:t===d,onChange:()=>!p&&(r==null?void 0:r(d)),className:"sr-only peer"}),s.jsx("div",{className:`w-5 h-5 rounded-full border-2 border-color-gray-400 peer-checked:border-[7px] transition-all duration-150 ${(f=pe[i])==null?void 0:f.peer} ${c}`}),s.jsx("label",{htmlFor:`radio-${e}-${d}`,className:`ml-2 text-sm text-color-gray-800 cursor-pointer ${(m=pe[i])==null?void 0:m.peer}`,children:u})]},d)})}),Ja=({label:e,value:n,onChange:t,options:r,className:o="",labelClass:a="",disabled:i=!1,size:l="medium",variant:c="outlined",rounded:u="medium",shadow:d=!1})=>{const g={small:"p-2",medium:"p-3",large:"p-4"},p={small:"rounded-md",medium:"rounded-lg",full:"rounded-full"},f={filled:"bg-color-gray-100 border-color-gray-200",outlined:"border-color-gray-300 bg-color-transparent"};return s.jsxs("div",{className:`relative w-full ${o}`,children:[e&&s.jsx("label",{className:`text-sm text-color-gray-500 pointer-events-none block mb-1 ${a}`,children:e}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{disabled:i,value:n,onChange:m=>t(m.target.value),className:`appearance-none focus:ring-1 text-color-gray-800 w-full border outline-none transition-all ${p[u]} ${g[l]} ${f[c]} ${i?"!bg-color-gray-50 opacity-60 cursor-not-allowed":""} ${d?"shadow-md shadow-color-zinc-100":""}`,children:r.map(m=>s.jsx("option",{value:m.value,className:"text-color-gray-900",children:m.label},m.value))}),s.jsx("span",{className:`absolute right-3 text-sm top-1/2 -translate-y-1/2 ${i?"opacity-60":""}`,children:s.jsx("svg",{className:"size-4",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.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"})})})]})]})},Qa=({content:e,children:n,position:t="top"})=>{const[r,o]=w.useState(!1),[a,i]=w.useState({top:0,left:0}),l=w.useRef(null),c=w.useRef(null);return w.useEffect(()=>{if(r&&l.current&&c.current){const u=l.current.getBoundingClientRect(),d=c.current.getBoundingClientRect();let g=0,p=0;switch(t){case"top":g=u.top-d.height-8,p=u.left+u.width/2-d.width/2;break;case"bottom":g=u.bottom+8,p=u.left+u.width/2-d.width/2;break;case"left":g=u.top+u.height/2-d.height/2,p=u.left-d.width-8;break;case"right":g=u.top+u.height/2-d.height/2,p=u.right+8;break}i({top:g,left:p})}},[r,t]),s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:l,className:"inline-block",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:n}),r&&De.createPortal(s.jsx("div",{ref:c,style:{top:a.top,left:a.left},className:"fixed z-50 px-2 py-1 text-sm text-color-white bg-color-gray-800 rounded shadow-md whitespace-nowrap pointer-events-none",children:e}),document.body)]})};function ei(...e){return e.filter(Boolean).join(" ")}const ti={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"},xr=w.forwardRef(({open:e,onClose:n,className:t,title:r,children:o,actions:a,showCloseIcon:i=!0,fullscreen:l=!1,fullWidth:c=!1,maxWidth:u},d)=>{const[g,p]=w.useState(e||!1),[f,m]=w.useState(!1),[v,b]=w.useState(!1);w.useEffect(()=>{e!==void 0&&p(e)},[e]),w.useImperativeHandle(d,()=>({open:()=>p(!0),close:()=>{b(!1),setTimeout(()=>p(!1),300)}})),w.useEffect(()=>{let P;return g?(m(!0),P=setTimeout(()=>b(!0),10)):b(!1),()=>clearTimeout(P)},[g]);const x=()=>{g||m(!1)};return w.useEffect(()=>{const P=y=>{y.key==="Escape"&&(n==null||n())};return g&&document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[g,n]),w.useEffect(()=>(g?(document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden"):(document.body.style.overflow="",document.documentElement.style.overflow=""),()=>{document.body.style.overflow="",document.documentElement.style.overflow=""}),[g]),f?De.createPortal(s.jsxs("div",{className:ei("fixed inset-0 z-50 flex items-center justify-center transition-opacity duration-300",v?"opacity-100":"opacity-0 pointer-events-none"),children:[s.jsx("div",{className:"fixed inset-0 bg-color-black/50",onClick:()=>{n==null||n(),p(!1)}}),s.jsxs("div",{className:`relative flex flex-col z-50 bg-color-white rounded-xl shadow-lg transition-all duration-300 transform p-6 ${v?"opacity-100 scale-100":"opacity-0 scale-95"} ${l?"w-full h-[calc(100%_-_40px)] m-5":`${c?"w-full":"w-auto"} ${u?ti[u]:""} mx-5`} ${t}`,onTransitionEnd:x,children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r&&s.jsx("h2",{className:"text-xl font-semibold",children:r}),i&&s.jsx(be,{color:"gray",icon:s.jsx("svg",{className:"size-5",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:s.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:()=>{n==null||n(),p(!1)},variant:"transparent"})]}),s.jsx("div",{className:"grow lg:max-h-[calc(100vh_-_200px)] max-h-[calc(100vh_-_130px)] overflow-y-auto",children:o}),a&&s.jsx("div",{className:"mt-8",children:a})]})]}),document.body):null});function ni({items:e,trigger:n,className:t,dropdownItemClass:r}){const[o,a]=w.useState(!1),[i,l]=w.useState({top:0,left:0}),[c,u]=w.useState(!1),d=w.useRef(null),g=w.useRef(null),p=m=>{m.stopPropagation(),a(v=>!v),u(!1)};w.useLayoutEffect(()=>{if(o&&d.current&&g.current){const m=d.current.getBoundingClientRect(),v=g.current.getBoundingClientRect(),b=window.innerWidth,x=window.innerHeight;let P=m.left+window.scrollX,y=m.bottom+window.scrollY;m.right+v.width>b&&(P=m.right+window.scrollX-v.width),P+v.width>b&&(P=b-v.width-12),y+v.height>x&&(y=m.top+window.scrollY-v.height),l({top:y,left:P}),setTimeout(()=>{u(!0)},150)}},[o]),w.useEffect(()=>{const m=v=>{var b;g.current&&!g.current.contains(v.target)&&!((b=d.current)!=null&&b.contains(v.target))&&a(!1)};return o&&document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[o]);const f=s.jsx("div",{ref:g,className:`absolute mt-2 z-50 rounded-xl bg-color-white shadow-xl p-2 min-w-[160px] transition-all duration-200 transform ${c?"opacity-100 scale-100":"opacity-0 scale-95"} ${t}`,style:{top:i.top,left:i.left},children:e.map((m,v)=>s.jsxs("button",{disabled:m.disabled,onClick:()=>{var b;(b=m.onClick)==null||b.call(m),a(!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 ${m.disabled?"opacity-50 hover:bg-color-transparent !cursor-not-allowed":""} ${r} ${m.itemClass}`,children:[m.icon&&s.jsx("span",{children:m.icon}),s.jsx("span",{children:m.label})]},v))});return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:d,onClick:p,className:"cursor-pointer",children:n}),o&&De.createPortal(f,document.body)]})}function ri(...e){return e.filter(Boolean).join(" ")}const br=({open:e,onClose:n,className:t,title:r,children:o,childrenClass:a,actions:i,showCloseIcon:l=!0,anchor:c="left"})=>{const[u,d]=w.useState(!1),[g,p]=w.useState(!1);w.useEffect(()=>{let b;return e?(d(!0),b=setTimeout(()=>{p(!0)},10)):p(!1),()=>clearTimeout(b)},[e]);const f=()=>{e||d(!1)};if(w.useEffect(()=>{const b=x=>{x.key==="Escape"&&(n==null||n())};return e&&document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,n]),w.useEffect(()=>(e?(document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden"):(document.body.style.overflow="",document.documentElement.style.overflow=""),()=>{document.body.style.overflow="",document.documentElement.style.overflow=""}),[e]),!u)return null;const m={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:g?"translate-x-0":"-translate-x-full",right:g?"translate-x-0":"translate-x-full",top:g?"translate-y-0":"-translate-y-full",bottom:g?"translate-y-0":"translate-y-full"};return De.createPortal(s.jsxs("div",{className:ri("fixed inset-0 z-50 transition-opacity duration-300",g?"opacity-100":"opacity-0 pointer-events-none"),children:[s.jsx("div",{className:"fixed inset-0 bg-color-black/50",onClick:n}),s.jsxs("div",{className:`
|
|
164
164
|
fixed bg-color-white shadow-lg z-50 p-6 flex flex-col
|
|
165
165
|
${m[c]}
|
|
166
166
|
${v[c]}
|