tailwind-ux-kit 1.0.91 → 1.0.94

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.
@@ -1119,14 +1119,14 @@ const Ue = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, functio
1119
1119
  className: `fixed top-5 right-5 z-9999 flex flex-col gap-2 ${e}`,
1120
1120
  children: n.map((s) => {
1121
1121
  var a, o, l, u, g, b, x, k, $, N, w, y, h, v;
1122
- const c = ((a = s.config) == null ? void 0 : a.icon) || ((o = r.icons) == null ? void 0 : o[s.type]) || Xe(s.type), p = ((l = s.config) == null ? void 0 : l.bgColor) || ((g = (u = r.colors) == null ? void 0 : u[s.type]) == null ? void 0 : g.bg) || "bg-white dark:bg-gray-800", f = ((b = s.config) == null ? void 0 : b.textColor) || ((k = (x = r.colors) == null ? void 0 : x[s.type]) == null ? void 0 : k.text) || "text-gray-700 dark:text-gray-300", d = (($ = s.config) == null ? void 0 : $.iconContainerClass) || "w-8 h-8 mr-3 text-xl flex items-center justify-center";
1122
+ const c = ((a = s.config) == null ? void 0 : a.icon) || ((o = r.icons) == null ? void 0 : o[s.type]) || Xe(s.type), p = ((l = s.config) == null ? void 0 : l.bgColor) || ((g = (u = r.colors) == null ? void 0 : u[s.type]) == null ? void 0 : g.bg) || "bg-white dark:bg-gray-800", f = ((b = s.config) == null ? void 0 : b.textColor) || ((k = (x = r.colors) == null ? void 0 : x[s.type]) == null ? void 0 : k.text) || "text-gray-700 dark:text-gray-300", d = `w-8 h-8 mr-3 text-xl flex items-center justify-center ${($ = s.config) == null ? void 0 : $.iconContainerClass}`;
1123
1123
  return /* @__PURE__ */ S(
1124
1124
  "div",
1125
1125
  {
1126
1126
  className: `flex items-center w-full max-w-xs p-4 text-sm rounded-lg shadow ${p} ${f} ${(N = s.config) == null ? void 0 : N.containerBody}`,
1127
1127
  children: [
1128
1128
  c && /* @__PURE__ */ i("div", { className: d, children: c }),
1129
- /* @__PURE__ */ S("div", { className: "flex-1 me-3", children: [
1129
+ /* @__PURE__ */ S("div", { className: "flex-1", children: [
1130
1130
  ((w = s.config) == null ? void 0 : w.title) && /* @__PURE__ */ i(
1131
1131
  "div",
1132
1132
  {
@@ -12,4 +12,4 @@
12
12
  ${w?`text-white toggler-text-${b}`:"text-gray-700 hover:bg-gray-200"}
13
13
  ${s.option??""}
14
14
  ${w?s.selectedOption??"":""}
15
- `,children:h?h(m,w):m.label},String(m.value))})]})]})}function Fr(r){return H({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 294.1L383 167c9.4-9.4 24.6-9.4 33.9 0s9.3 24.6 0 34L273 345c-9.1 9.1-23.7 9.3-33.1.7L95 201.1c-4.7-4.7-7-10.9-7-17s2.3-12.3 7-17c9.4-9.4 24.6-9.4 33.9 0l127.1 127z"},child:[]}]})(r)}const Kr=({items:r,allowMultipleOpen:e=!1,className:o="",tileClasses:t="",open:n,onChange:d,renderTitle:b,renderContent:g,showArrowIcon:u=!0,panelClasses:s=""})=>{const[c,i]=a.useState(new Set),h=a.useMemo(()=>n?new Set(n):c,[n,c]),f=a.useCallback(v=>{const y=new Set(h);y.has(v)?y.delete(v):(e||y.clear(),y.add(v)),n&&d?d(Array.from(y)):i(y)},[h,n,d,e]);return l.jsx("div",{className:"accordion",role:"region","aria-multiselectable":e,children:r.map(v=>{const y=h.has(v.id),N=`accordion-heading-${v.id}`,S=`accordion-panel-${v.id}`;return l.jsxs("div",{className:`accordion-item border rounded border-gray-300 dark:border-gray-700 ${o}`,children:[l.jsxs("button",{id:N,type:"button","aria-expanded":y,"aria-controls":S,onClick:()=>f(v.id),className:`flex justify-between items-center w-full p-1.5 text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none gap-3 ${t}`,children:[b?b(v,y):v.title,u?l.jsx(Fr,{}):null]}),l.jsx("div",{id:S,role:"region","aria-labelledby":N,hidden:!y,className:`p-4 border-t border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 ${s}`,children:g?g(v,y):v.content})]},v.id)})})},sr=a.createContext(null),W=()=>{const r=a.useContext(sr);if(!r)throw new Error("useModalActions must be used within a ModalActionProvider");return r},ir=a.createContext(null),q=()=>a.useContext(ir);function Zr({id:r,title:e,children:o,standalone:t=!1,showFloatingClose:n=!1,containerClasses:d="",headerClasses:b="",bodyClasses:g="",onClose:u,disableEscapeClose:s=!1,closeBtnStyle:c}){const i=q(),h=W(),f=!t&&!!i&&!!h,[v,y]=a.useState(!1),N=f?i.isOpen(r):v,S=f?i.getModalData(r):null,E=a.useCallback(()=>{f?h.closeModal(r):y(!1),u==null||u()},[f,h,r,u]);return a.useEffect(()=>{const m=document.activeElement,w=document.getElementById(r),k=["a[href]","button:not([disabled])","textarea:not([disabled])","input:not([disabled])","select:not([disabled])",'[tabindex]:not([tabindex="-1"])'],C=()=>{if(!w)return[];const p=w.querySelectorAll(k.join(","));return Array.from(p).filter($=>$.offsetParent!==null)},P=p=>{if(p.key==="Tab"){const $=C();if($.length===0)return;const M=$[0],j=$[$.length-1];p.shiftKey?document.activeElement===M&&(p.preventDefault(),j.focus()):document.activeElement===j&&(p.preventDefault(),M.focus())}},L=p=>{p.key==="Escape"&&!s&&E(),P(p)};return N&&(document.body.style.overflow="hidden",setTimeout(()=>{const p=C();p.length&&p[0].focus()},0),window.addEventListener("keydown",L)),()=>{document.body.style.overflow="",m&&m.focus(),window.removeEventListener("keydown",L)}},[N,s,E,r]),N?l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-[2px]",id:r,children:l.jsxs("div",{className:`bg-white rounded-lg shadow-lg w-full max-w-md p-4 transform transition-all duration-300 scale-100 ${d}`,children:[l.jsxs("div",{className:`flex justify-between items-center relative ${b}`,children:[e&&l.jsx("h2",{className:"text-lg font-semibold",children:e}),n&&l.jsx("button",{onClick:E,className:`text-gray-500 hover:text-black absolute top-0 right-3 hover:bg-gray-200 rounded-full aspect-square w-8 ${c}`,"aria-label":"Close modal",children:"✕"})]}),l.jsx("div",{className:g,children:typeof o=="function"?o({modalData:S}):o})]})}):null}function Hr({children:r}){const[e,o]=a.useState({}),[t,n]=a.useState({}),d=a.useCallback((i,h)=>{o(f=>({...f,[i]:!0})),h&&n(f=>({...f,[i]:h}))},[]),b=a.useCallback(i=>{o(h=>({...h,[i]:!1})),n(h=>{const f={...h};return delete f[i],f})},[]),g=a.useCallback(i=>!!e[i],[e]),u=a.useCallback(i=>t[i],[t]),s=a.useMemo(()=>({openModal:d,closeModal:b}),[d,b]),c=a.useMemo(()=>({isOpen:g,getModalData:u}),[g,u]);return l.jsx(sr.Provider,{value:s,children:l.jsx(ir.Provider,{value:c,children:r})})}function Wr(r){const{openModal:e,closeModal:o}=W(),{isOpen:t,getModalData:n}=q();return{open:d=>e(r,d),close:()=>o(r),isOpen:t(r),data:n(r)}}let G=null,U={};function qr(r){G=r}function Gr(r){U={...U,...r}}function Ur(){return U}function Xr(r,e,o=3e3,t){G?G(r,e,o,t):console.warn("Toast system is not mounted")}function Yr(r){return H({attr:{viewBox:"0 0 15 15",fill:"none"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:"currentColor"},child:[]}]})(r)}const Jr=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)}),Qr=({containerStyle:r=""})=>{const[e,o]=a.useState([]);a.useEffect(()=>{qr((n,d,b,g)=>{const u=Jr();o(s=>[...s,{id:u,type:n,message:d,config:g}]),setTimeout(()=>{o(s=>s.filter(c=>c.id!==u))},b)})},[]);const t=Ur();return l.jsx("div",{className:`fixed top-5 right-5 z-9999 flex flex-col gap-2 ${r}`,children:e.map(n=>{var s,c,i,h,f,v,y,N,S,E,m,w,k,C;const d=((s=n.config)==null?void 0:s.icon)||((c=t.icons)==null?void 0:c[n.type])||Vr(n.type),b=((i=n.config)==null?void 0:i.bgColor)||((f=(h=t.colors)==null?void 0:h[n.type])==null?void 0:f.bg)||"bg-white dark:bg-gray-800",g=((v=n.config)==null?void 0:v.textColor)||((N=(y=t.colors)==null?void 0:y[n.type])==null?void 0:N.text)||"text-gray-700 dark:text-gray-300",u=((S=n.config)==null?void 0:S.iconContainerClass)||"w-8 h-8 mr-3 text-xl flex items-center justify-center";return l.jsxs("div",{className:`flex items-center w-full max-w-xs p-4 text-sm rounded-lg shadow ${b} ${g} ${(E=n.config)==null?void 0:E.containerBody}`,children:[d&&l.jsx("div",{className:u,children:d}),l.jsxs("div",{className:"flex-1 me-3",children:[((m=n.config)==null?void 0:m.title)&&l.jsx("div",{className:`font-semibold text-black ${(w=n.config)==null?void 0:w.titleClass}`,children:n.config.title}),((k=n.config)==null?void 0:k.description)&&l.jsx("div",{className:`text-sm text-gray-500 ${(C=n.config)==null?void 0:C.subTitleClass}`,children:n.config.description})]}),l.jsx("button",{onClick:()=>o(P=>P.filter(L=>L.id!==n.id)),className:"ml-auto text-gray-400 hover:text-gray-700 dark:text-gray-500 dark:hover:text-white","aria-label":"Close",children:l.jsx(Yr,{size:18})})]},n.id)})})};function Vr(r){switch(r){case"success":return"✅";case"error":return"❌";case"warning":return"⚠️";case"info":return"ℹ️"}}x.Accordion=Kr,x.Badge=_r,x.Button=mr,x.Checkbox=nr,x.Dropdown=jr,x.Input=R,x.Modal=Zr,x.ModalProvider=Hr,x.Select=rr,x.Toast=Qr,x.Toggler=Br,x.Tooltip=Tr,x.setToastDefaults=Gr,x.showToast=Xr,x.useModalActions=W,x.useModalInstance=Wr,x.useModalState=q,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})}));
15
+ `,children:h?h(m,w):m.label},String(m.value))})]})]})}function Fr(r){return H({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 294.1L383 167c9.4-9.4 24.6-9.4 33.9 0s9.3 24.6 0 34L273 345c-9.1 9.1-23.7 9.3-33.1.7L95 201.1c-4.7-4.7-7-10.9-7-17s2.3-12.3 7-17c9.4-9.4 24.6-9.4 33.9 0l127.1 127z"},child:[]}]})(r)}const Kr=({items:r,allowMultipleOpen:e=!1,className:o="",tileClasses:t="",open:n,onChange:d,renderTitle:b,renderContent:g,showArrowIcon:u=!0,panelClasses:s=""})=>{const[c,i]=a.useState(new Set),h=a.useMemo(()=>n?new Set(n):c,[n,c]),f=a.useCallback(v=>{const y=new Set(h);y.has(v)?y.delete(v):(e||y.clear(),y.add(v)),n&&d?d(Array.from(y)):i(y)},[h,n,d,e]);return l.jsx("div",{className:"accordion",role:"region","aria-multiselectable":e,children:r.map(v=>{const y=h.has(v.id),N=`accordion-heading-${v.id}`,S=`accordion-panel-${v.id}`;return l.jsxs("div",{className:`accordion-item border rounded border-gray-300 dark:border-gray-700 ${o}`,children:[l.jsxs("button",{id:N,type:"button","aria-expanded":y,"aria-controls":S,onClick:()=>f(v.id),className:`flex justify-between items-center w-full p-1.5 text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none gap-3 ${t}`,children:[b?b(v,y):v.title,u?l.jsx(Fr,{}):null]}),l.jsx("div",{id:S,role:"region","aria-labelledby":N,hidden:!y,className:`p-4 border-t border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 ${s}`,children:g?g(v,y):v.content})]},v.id)})})},sr=a.createContext(null),W=()=>{const r=a.useContext(sr);if(!r)throw new Error("useModalActions must be used within a ModalActionProvider");return r},ir=a.createContext(null),q=()=>a.useContext(ir);function Zr({id:r,title:e,children:o,standalone:t=!1,showFloatingClose:n=!1,containerClasses:d="",headerClasses:b="",bodyClasses:g="",onClose:u,disableEscapeClose:s=!1,closeBtnStyle:c}){const i=q(),h=W(),f=!t&&!!i&&!!h,[v,y]=a.useState(!1),N=f?i.isOpen(r):v,S=f?i.getModalData(r):null,E=a.useCallback(()=>{f?h.closeModal(r):y(!1),u==null||u()},[f,h,r,u]);return a.useEffect(()=>{const m=document.activeElement,w=document.getElementById(r),k=["a[href]","button:not([disabled])","textarea:not([disabled])","input:not([disabled])","select:not([disabled])",'[tabindex]:not([tabindex="-1"])'],C=()=>{if(!w)return[];const p=w.querySelectorAll(k.join(","));return Array.from(p).filter($=>$.offsetParent!==null)},P=p=>{if(p.key==="Tab"){const $=C();if($.length===0)return;const M=$[0],j=$[$.length-1];p.shiftKey?document.activeElement===M&&(p.preventDefault(),j.focus()):document.activeElement===j&&(p.preventDefault(),M.focus())}},L=p=>{p.key==="Escape"&&!s&&E(),P(p)};return N&&(document.body.style.overflow="hidden",setTimeout(()=>{const p=C();p.length&&p[0].focus()},0),window.addEventListener("keydown",L)),()=>{document.body.style.overflow="",m&&m.focus(),window.removeEventListener("keydown",L)}},[N,s,E,r]),N?l.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-[2px]",id:r,children:l.jsxs("div",{className:`bg-white rounded-lg shadow-lg w-full max-w-md p-4 transform transition-all duration-300 scale-100 ${d}`,children:[l.jsxs("div",{className:`flex justify-between items-center relative ${b}`,children:[e&&l.jsx("h2",{className:"text-lg font-semibold",children:e}),n&&l.jsx("button",{onClick:E,className:`text-gray-500 hover:text-black absolute top-0 right-3 hover:bg-gray-200 rounded-full aspect-square w-8 ${c}`,"aria-label":"Close modal",children:"✕"})]}),l.jsx("div",{className:g,children:typeof o=="function"?o({modalData:S}):o})]})}):null}function Hr({children:r}){const[e,o]=a.useState({}),[t,n]=a.useState({}),d=a.useCallback((i,h)=>{o(f=>({...f,[i]:!0})),h&&n(f=>({...f,[i]:h}))},[]),b=a.useCallback(i=>{o(h=>({...h,[i]:!1})),n(h=>{const f={...h};return delete f[i],f})},[]),g=a.useCallback(i=>!!e[i],[e]),u=a.useCallback(i=>t[i],[t]),s=a.useMemo(()=>({openModal:d,closeModal:b}),[d,b]),c=a.useMemo(()=>({isOpen:g,getModalData:u}),[g,u]);return l.jsx(sr.Provider,{value:s,children:l.jsx(ir.Provider,{value:c,children:r})})}function Wr(r){const{openModal:e,closeModal:o}=W(),{isOpen:t,getModalData:n}=q();return{open:d=>e(r,d),close:()=>o(r),isOpen:t(r),data:n(r)}}let G=null,U={};function qr(r){G=r}function Gr(r){U={...U,...r}}function Ur(){return U}function Xr(r,e,o=3e3,t){G?G(r,e,o,t):console.warn("Toast system is not mounted")}function Yr(r){return H({attr:{viewBox:"0 0 15 15",fill:"none"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:"currentColor"},child:[]}]})(r)}const Jr=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)}),Qr=({containerStyle:r=""})=>{const[e,o]=a.useState([]);a.useEffect(()=>{qr((n,d,b,g)=>{const u=Jr();o(s=>[...s,{id:u,type:n,message:d,config:g}]),setTimeout(()=>{o(s=>s.filter(c=>c.id!==u))},b)})},[]);const t=Ur();return l.jsx("div",{className:`fixed top-5 right-5 z-9999 flex flex-col gap-2 ${r}`,children:e.map(n=>{var s,c,i,h,f,v,y,N,S,E,m,w,k,C;const d=((s=n.config)==null?void 0:s.icon)||((c=t.icons)==null?void 0:c[n.type])||Vr(n.type),b=((i=n.config)==null?void 0:i.bgColor)||((f=(h=t.colors)==null?void 0:h[n.type])==null?void 0:f.bg)||"bg-white dark:bg-gray-800",g=((v=n.config)==null?void 0:v.textColor)||((N=(y=t.colors)==null?void 0:y[n.type])==null?void 0:N.text)||"text-gray-700 dark:text-gray-300",u=`w-8 h-8 mr-3 text-xl flex items-center justify-center ${(S=n.config)==null?void 0:S.iconContainerClass}`;return l.jsxs("div",{className:`flex items-center w-full max-w-xs p-4 text-sm rounded-lg shadow ${b} ${g} ${(E=n.config)==null?void 0:E.containerBody}`,children:[d&&l.jsx("div",{className:u,children:d}),l.jsxs("div",{className:"flex-1",children:[((m=n.config)==null?void 0:m.title)&&l.jsx("div",{className:`font-semibold text-black ${(w=n.config)==null?void 0:w.titleClass}`,children:n.config.title}),((k=n.config)==null?void 0:k.description)&&l.jsx("div",{className:`text-sm text-gray-500 ${(C=n.config)==null?void 0:C.subTitleClass}`,children:n.config.description})]}),l.jsx("button",{onClick:()=>o(P=>P.filter(L=>L.id!==n.id)),className:"ml-auto text-gray-400 hover:text-gray-700 dark:text-gray-500 dark:hover:text-white","aria-label":"Close",children:l.jsx(Yr,{size:18})})]},n.id)})})};function Vr(r){switch(r){case"success":return"✅";case"error":return"❌";case"warning":return"⚠️";case"info":return"ℹ️"}}x.Accordion=Kr,x.Badge=_r,x.Button=mr,x.Checkbox=nr,x.Dropdown=jr,x.Input=R,x.Modal=Zr,x.ModalProvider=Hr,x.Select=rr,x.Toast=Qr,x.Toggler=Br,x.Tooltip=Tr,x.setToastDefaults=Gr,x.showToast=Xr,x.useModalActions=W,x.useModalInstance=Wr,x.useModalState=q,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-ux-kit",
3
- "version": "1.0.91",
3
+ "version": "1.0.94",
4
4
  "main": "lib/tailwind-ux-kit.es.js",
5
5
  "module": "lib/tailwind-ux-kit.umd.js",
6
6
  "types": "lib/tailwind-ux-kit.es.d.ts",