tailwind-ux-kit 1.0.100 → 1.0.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ import { BottomSheetProps } from '../../types/BottomSheetTypes';
2
+ export default function BottomSheet({ id, children, initialSnap, snapPoints, className, overlayClassName, closeOnBackdrop, lockScroll, zIndex, }: BottomSheetProps): import('react').ReactPortal | null;
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ import { BottomSheetContextType } from '../../types/BottomSheetTypes';
3
+ export declare const BottomSheetContext: import('react').Context<BottomSheetContextType | null>;
4
+ export default function BottomSheetProvider({ children, }: {
5
+ children: ReactNode;
6
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function useBottomSheet(): import('../..').BottomSheetContextType;
package/lib/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export { default as Dropdown } from './components/Dropdown';
6
6
  export { default as Tooltip } from './components/ToolTip';
7
7
  export { default as Badge } from './components/Badge';
8
8
  export { default as Toggler } from './components/Toggler/Toggler';
9
+ export * from './components/BottomSheet/useBottomSheet';
9
10
  export { default as Accordion } from './components/Accordion';
10
11
  export type { AccordionItemBase } from './components/Accordion';
11
12
  export { default as Modal } from './components/modal/Modal';
@@ -16,3 +17,4 @@ export { useModalInstance } from './components/modal/useModalInstance';
16
17
  export { default as Toast } from './components/Toast';
17
18
  export { showToast, setToastDefaults } from './utils/toast';
18
19
  export type { ToastType, ToastConfig, ToastDefaults } from './utils/toast';
20
+ export type { BottomSheetProps, BottomSheetContextType, SheetPosition, } from './types/BottomSheetTypes';
@@ -1,12 +1,12 @@
1
1
  "use client";
2
2
  import { jsxs as k, jsx as i } from "react/jsx-runtime";
3
- import T, { forwardRef as ae, useState as M, useMemo as z, useId as be, useRef as _, useCallback as A, useEffect as R, createContext as le, useContext as ie } from "react";
4
- const ee = {
3
+ import T, { forwardRef as le, useState as M, useMemo as z, useId as be, useRef as _, useCallback as A, useEffect as R, createContext as V, useContext as ie } from "react";
4
+ const te = {
5
5
  xs: "text-xs px-2 py-1",
6
6
  sm: "text-sm px-3 py-1.5",
7
7
  md: "text-sm px-3 py-3",
8
8
  lg: "text-lg px-5 py-3"
9
- }, te = {
9
+ }, ne = {
10
10
  flat: "rounded-none",
11
11
  rounded: "rounded-sm",
12
12
  pill: "rounded-full"
@@ -33,7 +33,7 @@ const ee = {
33
33
  default:
34
34
  return "border-gray-300 focus:ring-blue-500";
35
35
  }
36
- }, ye = ae((e, n) => {
36
+ }, ye = le((e, n) => {
37
37
  const {
38
38
  label: t,
39
39
  id: r,
@@ -61,7 +61,7 @@ const ee = {
61
61
  D(Z), u == null || u(j, Z), f == null || f(j);
62
62
  },
63
63
  [p, u, f]
64
- ), y = z(() => r || (typeof t == "string" ? `input-${t.toLowerCase().replace(/\s+/g, "-")}` : `input-${Math.random().toString(36).slice(2)}`), [r, t]), L = !!l, $ = ee[s] || ee.md, P = te[c] || te.flat, I = z(
64
+ ), y = z(() => r || (typeof t == "string" ? `input-${t.toLowerCase().replace(/\s+/g, "-")}` : `input-${Math.random().toString(36).slice(2)}`), [r, t]), L = !!l, $ = te[s] || te.md, P = ne[c] || ne.flat, I = z(
65
65
  () => he(w, x, g),
66
66
  [w, x, g]
67
67
  ), B = z(() => o === "start" || o === "left" ? "left-0 ps-3.5" : "right-0 pe-3.5", [o]), F = z(() => a ? o === "start" || o === "left" ? "ps-10" : "pe-10" : "", [a, o]), K = (j) => {
@@ -198,7 +198,7 @@ const we = {
198
198
  default:
199
199
  return "border-gray-300 focus:ring-blue-500";
200
200
  }
201
- }, Se = ae((e, n) => {
201
+ }, Se = le((e, n) => {
202
202
  const {
203
203
  label: t,
204
204
  id: r,
@@ -365,7 +365,7 @@ var ce = {
365
365
  className: void 0,
366
366
  style: void 0,
367
367
  attr: void 0
368
- }, ne = T.createContext && /* @__PURE__ */ T.createContext(ce), Oe = ["attr", "size", "title"];
368
+ }, re = T.createContext && /* @__PURE__ */ T.createContext(ce), Oe = ["attr", "size", "title"];
369
369
  function Pe(e, n) {
370
370
  if (e == null) return {};
371
371
  var t = De(e, n), r, s;
@@ -396,7 +396,7 @@ function G() {
396
396
  return e;
397
397
  }, G.apply(this, arguments);
398
398
  }
399
- function re(e, n) {
399
+ function se(e, n) {
400
400
  var t = Object.keys(e);
401
401
  if (Object.getOwnPropertySymbols) {
402
402
  var r = Object.getOwnPropertySymbols(e);
@@ -409,9 +409,9 @@ function re(e, n) {
409
409
  function q(e) {
410
410
  for (var n = 1; n < arguments.length; n++) {
411
411
  var t = arguments[n] != null ? arguments[n] : {};
412
- n % 2 ? re(Object(t), !0).forEach(function(r) {
412
+ n % 2 ? se(Object(t), !0).forEach(function(r) {
413
413
  Ie(e, r, t[r]);
414
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : re(Object(t)).forEach(function(r) {
414
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : se(Object(t)).forEach(function(r) {
415
415
  Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
416
416
  });
417
417
  }
@@ -439,7 +439,7 @@ function de(e) {
439
439
  key: t
440
440
  }, n.attr), de(n.child)));
441
441
  }
442
- function V(e) {
442
+ function ee(e) {
443
443
  return (n) => /* @__PURE__ */ T.createElement(Ae, G({
444
444
  attr: q({}, e.attr)
445
445
  }, n), de(e.child));
@@ -465,10 +465,10 @@ function Ae(e) {
465
465
  xmlns: "http://www.w3.org/2000/svg"
466
466
  }), c && /* @__PURE__ */ T.createElement("title", null, c), e.children);
467
467
  };
468
- return ne !== void 0 ? /* @__PURE__ */ T.createElement(ne.Consumer, null, (t) => n(t)) : n(ce);
468
+ return re !== void 0 ? /* @__PURE__ */ T.createElement(re.Consumer, null, (t) => n(t)) : n(ce);
469
469
  }
470
470
  function Me(e) {
471
- return V({ attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z" }, child: [] }] })(e);
471
+ return ee({ attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z" }, child: [] }] })(e);
472
472
  }
473
473
  const Te = {
474
474
  xs: "w-3 h-3 text-[10px]",
@@ -791,11 +791,11 @@ const Ve = ({
791
791
  }
792
792
  )
793
793
  ] });
794
- }, se = {
794
+ }, oe = {
795
795
  rounded: "rounded-md",
796
796
  pill: "rounded-full",
797
797
  flat: "rounded-none"
798
- }, oe = {
798
+ }, ae = {
799
799
  xs: {
800
800
  button: "px-2 py-1 text-xs"
801
801
  },
@@ -827,7 +827,7 @@ function nt({
827
827
  name: l,
828
828
  renderOption: f
829
829
  }) {
830
- const x = se[c] || se.rounded, g = oe[u] || oe.md, b = _(null), [C, S] = M({});
830
+ const x = oe[c] || oe.rounded, g = ae[u] || ae.md, b = _(null), [C, S] = M({});
831
831
  R(() => {
832
832
  if (!b.current) return;
833
833
  const h = e.findIndex((w) => w.value === n);
@@ -908,8 +908,11 @@ function nt({
908
908
  }
909
909
  );
910
910
  }
911
+ V(
912
+ null
913
+ );
911
914
  function He(e) {
912
- return V({ 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: [] }] })(e);
915
+ return ee({ 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: [] }] })(e);
913
916
  }
914
917
  const rt = ({
915
918
  items: e,
@@ -976,14 +979,14 @@ const rt = ({
976
979
  })
977
980
  }
978
981
  );
979
- }, ue = le(null), fe = () => {
982
+ }, ue = V(null), fe = () => {
980
983
  const e = ie(ue);
981
984
  if (!e)
982
985
  throw new Error(
983
986
  "useModalActions must be used within a ModalActionProvider"
984
987
  );
985
988
  return e;
986
- }, pe = le(null), ge = () => ie(pe);
989
+ }, pe = V(null), ge = () => ie(pe);
987
990
  function st({
988
991
  id: e,
989
992
  title: n,
@@ -1112,7 +1115,7 @@ function it(e, n, t = 3e3, r) {
1112
1115
  J ? J(e, n, t, r) : console.warn("Toast system is not mounted");
1113
1116
  }
1114
1117
  function qe(e) {
1115
- return V({ 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: [] }] })(e);
1118
+ return ee({ 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: [] }] })(e);
1116
1119
  }
1117
1120
  const Ue = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
1118
1121
  const n = Math.random() * 16 | 0;
@@ -12,4 +12,4 @@
12
12
  ${C?`text-white toggler-text-${b}`:"text-gray-700 hover:bg-gray-200"}
13
13
  ${s.option??""}
14
14
  ${C?s.selectedOption??"":""}
15
- `,children:g?g(k,C):k.label},String(k.value))})]})]})}function Kr(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 Zr=({items:r,allowMultipleOpen:e=!1,className:o="",tileClasses:t="",open:n,onChange:d,renderTitle:b,renderContent:h,showArrowIcon:u=!0,panelClasses:s=""})=>{const[c,i]=a.useState(new Set),g=a.useMemo(()=>n?new Set(n):c,[n,c]),y=a.useCallback(f=>{const v=new Set(g);v.has(f)?v.delete(f):(e||v.clear(),v.add(f)),n&&d?d(Array.from(v)):i(v)},[g,n,d,e]);return l.jsx("div",{className:"accordion",role:"region","aria-multiselectable":e,children:r.map(f=>{const v=g.has(f.id),$=`accordion-heading-${f.id}`,N=`accordion-panel-${f.id}`;return l.jsxs("div",{className:`accordion-item border rounded border-gray-300 dark:border-gray-700 ${o}`,children:[l.jsxs("button",{id:$,type:"button","aria-expanded":v,"aria-controls":N,onClick:()=>y(f.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(f,v):f.title,u?l.jsx(Kr,{}):null]}),l.jsx("div",{id:N,role:"region","aria-labelledby":$,hidden:!v,className:`p-4 border-t border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 ${s}`,children:h?h(f,v):f.content})]},f.id)})})},ir=a.createContext(null),W=()=>{const r=a.useContext(ir);if(!r)throw new Error("useModalActions must be used within a ModalActionProvider");return r},dr=a.createContext(null),q=()=>a.useContext(dr);function Hr({id:r,title:e,children:o,standalone:t=!1,showFloatingClose:n=!1,containerClasses:d="",headerClasses:b="",bodyClasses:h="",onClose:u,disableEscapeClose:s=!1,closeBtnStyle:c}){const i=q(),g=W(),y=!t&&!!i&&!!g,[f,v]=a.useState(!1),$=y?i.isOpen(r):f,N=y?i.getModalData(r):null,E=a.useCallback(()=>{y?g.closeModal(r):v(!1),u==null||u()},[y,g,r,u]),k=a.useRef(null);return a.useEffect(()=>{$&&(k.current=document.activeElement);const C=document.getElementById(r),p=["a[href]","button:not([disabled])","textarea:not([disabled])","input:not([disabled])","select:not([disabled])",'[tabindex]:not([tabindex="-1"])'],m=()=>{if(!C)return[];const w=C.querySelectorAll(p.join(","));return Array.from(w).filter(O=>O.offsetParent!==null)},j=w=>{if(w.key==="Tab"){const O=m();if(O.length===0)return;const S=O[0],M=O[O.length-1];w.shiftKey?document.activeElement===S&&(w.preventDefault(),M.focus()):document.activeElement===M&&(w.preventDefault(),S.focus())}},L=w=>{w.key==="Escape"&&!s&&E(),j(w)};return $&&(document.body.style.overflow="hidden",setTimeout(()=>{const w=m();w.length&&w[0].focus()},0),window.addEventListener("keydown",L)),()=>{var w;document.body.style.overflow="",(w=k.current)==null||w.focus(),window.removeEventListener("keydown",L)}},[$,s,E,r]),$?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:h,children:typeof o=="function"?o({modalData:N}):o})]})}):null}function Wr({children:r}){const[e,o]=a.useState({}),[t,n]=a.useState({}),d=a.useCallback((i,g)=>{o(y=>({...y,[i]:!0})),g&&n(y=>({...y,[i]:g}))},[]),b=a.useCallback(i=>{o(g=>({...g,[i]:!1})),n(g=>{const y={...g};return delete y[i],y})},[]),h=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:h,getModalData:u}),[h,u]);return l.jsx(ir.Provider,{value:s,children:l.jsx(dr.Provider,{value:c,children:r})})}function qr(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 Gr(r){G=r}function Ur(r){U={...U,...r}}function Xr(){return U}function Yr(r,e,o=3e3,t){G?G(r,e,o,t):console.warn("Toast system is not mounted")}function Jr(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 Qr=()=>"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)}),Vr=({containerStyle:r=""})=>{const[e,o]=a.useState([]);a.useEffect(()=>{Gr((n,d,b,h)=>{const u=Qr();o(s=>[...s,{id:u,type:n,message:d,config:h}]),setTimeout(()=>{o(s=>s.filter(c=>c.id!==u))},b)})},[]);const t=Xr();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,g,y,f,v,$,N,E,k,C,p,m;const d=((s=n.config)==null?void 0:s.icon)||((c=t.icons)==null?void 0:c[n.type])||Rr(n.type),b=((i=n.config)==null?void 0:i.bgColor)||((y=(g=t.colors)==null?void 0:g[n.type])==null?void 0:y.bg)||"bg-white dark:bg-gray-800",h=((f=n.config)==null?void 0:f.textColor)||(($=(v=t.colors)==null?void 0:v[n.type])==null?void 0:$.text)||"text-gray-700 dark:text-gray-300",u=`w-8 h-8 mr-3 text-xl flex items-center justify-center ${(N=n.config)==null?void 0:N.iconContainerClass}`;return l.jsxs("div",{className:`flex items-center w-full max-w-xs p-4 text-sm rounded-lg shadow ${b} ${h} ${(E=n.config)==null?void 0:E.containerBody}`,children:[d&&l.jsx("div",{className:u,children:d}),l.jsxs("div",{className:"flex-1",children:[((k=n.config)==null?void 0:k.title)&&l.jsx("div",{className:`font-semibold text-black ${(C=n.config)==null?void 0:C.titleClass}`,children:n.config.title}),((p=n.config)==null?void 0:p.description)&&l.jsx("div",{className:`text-sm text-gray-500 ${(m=n.config)==null?void 0:m.subTitleClass}`,children:n.config.description})]}),l.jsx("button",{onClick:()=>o(j=>j.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(Jr,{size:18})})]},n.id)})})};function Rr(r){switch(r){case"success":return"✅";case"error":return"❌";case"warning":return"⚠️";case"info":return"ℹ️"}}x.Accordion=Zr,x.Badge=Br,x.Button=xr,x.Checkbox=ar,x.Dropdown=Dr,x.Input=rr,x.Modal=Hr,x.ModalProvider=Wr,x.Select=or,x.Toast=Vr,x.Toggler=Fr,x.Tooltip=Tr,x.setToastDefaults=Ur,x.showToast=Yr,x.useModalActions=W,x.useModalInstance=qr,x.useModalState=q,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})}));
15
+ `,children:g?g(k,C):k.label},String(k.value))})]})]})}a.createContext(null);function Kr(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 Zr=({items:r,allowMultipleOpen:e=!1,className:o="",tileClasses:t="",open:n,onChange:d,renderTitle:b,renderContent:h,showArrowIcon:u=!0,panelClasses:s=""})=>{const[c,i]=a.useState(new Set),g=a.useMemo(()=>n?new Set(n):c,[n,c]),y=a.useCallback(f=>{const v=new Set(g);v.has(f)?v.delete(f):(e||v.clear(),v.add(f)),n&&d?d(Array.from(v)):i(v)},[g,n,d,e]);return l.jsx("div",{className:"accordion",role:"region","aria-multiselectable":e,children:r.map(f=>{const v=g.has(f.id),$=`accordion-heading-${f.id}`,N=`accordion-panel-${f.id}`;return l.jsxs("div",{className:`accordion-item border rounded border-gray-300 dark:border-gray-700 ${o}`,children:[l.jsxs("button",{id:$,type:"button","aria-expanded":v,"aria-controls":N,onClick:()=>y(f.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(f,v):f.title,u?l.jsx(Kr,{}):null]}),l.jsx("div",{id:N,role:"region","aria-labelledby":$,hidden:!v,className:`p-4 border-t border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 ${s}`,children:h?h(f,v):f.content})]},f.id)})})},ir=a.createContext(null),W=()=>{const r=a.useContext(ir);if(!r)throw new Error("useModalActions must be used within a ModalActionProvider");return r},dr=a.createContext(null),q=()=>a.useContext(dr);function Hr({id:r,title:e,children:o,standalone:t=!1,showFloatingClose:n=!1,containerClasses:d="",headerClasses:b="",bodyClasses:h="",onClose:u,disableEscapeClose:s=!1,closeBtnStyle:c}){const i=q(),g=W(),y=!t&&!!i&&!!g,[f,v]=a.useState(!1),$=y?i.isOpen(r):f,N=y?i.getModalData(r):null,E=a.useCallback(()=>{y?g.closeModal(r):v(!1),u==null||u()},[y,g,r,u]),k=a.useRef(null);return a.useEffect(()=>{$&&(k.current=document.activeElement);const C=document.getElementById(r),p=["a[href]","button:not([disabled])","textarea:not([disabled])","input:not([disabled])","select:not([disabled])",'[tabindex]:not([tabindex="-1"])'],m=()=>{if(!C)return[];const w=C.querySelectorAll(p.join(","));return Array.from(w).filter(O=>O.offsetParent!==null)},j=w=>{if(w.key==="Tab"){const O=m();if(O.length===0)return;const S=O[0],M=O[O.length-1];w.shiftKey?document.activeElement===S&&(w.preventDefault(),M.focus()):document.activeElement===M&&(w.preventDefault(),S.focus())}},L=w=>{w.key==="Escape"&&!s&&E(),j(w)};return $&&(document.body.style.overflow="hidden",setTimeout(()=>{const w=m();w.length&&w[0].focus()},0),window.addEventListener("keydown",L)),()=>{var w;document.body.style.overflow="",(w=k.current)==null||w.focus(),window.removeEventListener("keydown",L)}},[$,s,E,r]),$?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:h,children:typeof o=="function"?o({modalData:N}):o})]})}):null}function Wr({children:r}){const[e,o]=a.useState({}),[t,n]=a.useState({}),d=a.useCallback((i,g)=>{o(y=>({...y,[i]:!0})),g&&n(y=>({...y,[i]:g}))},[]),b=a.useCallback(i=>{o(g=>({...g,[i]:!1})),n(g=>{const y={...g};return delete y[i],y})},[]),h=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:h,getModalData:u}),[h,u]);return l.jsx(ir.Provider,{value:s,children:l.jsx(dr.Provider,{value:c,children:r})})}function qr(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 Gr(r){G=r}function Ur(r){U={...U,...r}}function Xr(){return U}function Yr(r,e,o=3e3,t){G?G(r,e,o,t):console.warn("Toast system is not mounted")}function Jr(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 Qr=()=>"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)}),Vr=({containerStyle:r=""})=>{const[e,o]=a.useState([]);a.useEffect(()=>{Gr((n,d,b,h)=>{const u=Qr();o(s=>[...s,{id:u,type:n,message:d,config:h}]),setTimeout(()=>{o(s=>s.filter(c=>c.id!==u))},b)})},[]);const t=Xr();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,g,y,f,v,$,N,E,k,C,p,m;const d=((s=n.config)==null?void 0:s.icon)||((c=t.icons)==null?void 0:c[n.type])||Rr(n.type),b=((i=n.config)==null?void 0:i.bgColor)||((y=(g=t.colors)==null?void 0:g[n.type])==null?void 0:y.bg)||"bg-white dark:bg-gray-800",h=((f=n.config)==null?void 0:f.textColor)||(($=(v=t.colors)==null?void 0:v[n.type])==null?void 0:$.text)||"text-gray-700 dark:text-gray-300",u=`w-8 h-8 mr-3 text-xl flex items-center justify-center ${(N=n.config)==null?void 0:N.iconContainerClass}`;return l.jsxs("div",{className:`flex items-center w-full max-w-xs p-4 text-sm rounded-lg shadow ${b} ${h} ${(E=n.config)==null?void 0:E.containerBody}`,children:[d&&l.jsx("div",{className:u,children:d}),l.jsxs("div",{className:"flex-1",children:[((k=n.config)==null?void 0:k.title)&&l.jsx("div",{className:`font-semibold text-black ${(C=n.config)==null?void 0:C.titleClass}`,children:n.config.title}),((p=n.config)==null?void 0:p.description)&&l.jsx("div",{className:`text-sm text-gray-500 ${(m=n.config)==null?void 0:m.subTitleClass}`,children:n.config.description})]}),l.jsx("button",{onClick:()=>o(j=>j.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(Jr,{size:18})})]},n.id)})})};function Rr(r){switch(r){case"success":return"✅";case"error":return"❌";case"warning":return"⚠️";case"info":return"ℹ️"}}x.Accordion=Zr,x.Badge=Br,x.Button=xr,x.Checkbox=ar,x.Dropdown=Dr,x.Input=rr,x.Modal=Hr,x.ModalProvider=Wr,x.Select=or,x.Toast=Vr,x.Toggler=Fr,x.Tooltip=Tr,x.setToastDefaults=Ur,x.showToast=Yr,x.useModalActions=W,x.useModalInstance=qr,x.useModalState=q,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,22 @@
1
+ import { ReactNode } from 'react';
2
+ export type SheetPosition = "closed" | "half" | "full";
3
+ export type BottomSheetContextType = {
4
+ showBottomSheet: (id: string) => void;
5
+ closeBottomSheet: (id: string) => void;
6
+ closeAllBottomSheet: () => void;
7
+ activeSheets: string[];
8
+ };
9
+ export type BottomSheetProps = {
10
+ id: string;
11
+ children: ReactNode;
12
+ initialSnap?: SheetPosition;
13
+ snapPoints?: {
14
+ half: number;
15
+ full: number;
16
+ };
17
+ className?: string;
18
+ overlayClassName?: string;
19
+ closeOnBackdrop?: boolean;
20
+ lockScroll?: boolean;
21
+ zIndex?: number;
22
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-ux-kit",
3
- "version": "1.0.100",
3
+ "version": "1.0.102",
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",