@moondreamsdev/dreamer-ui 1.7.12 → 1.7.13

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.
Files changed (34) hide show
  1. package/dist/{Toast-Dj3X8g0Q.cjs → Toast-BJPMjPG-.cjs} +2 -2
  2. package/dist/Toast-BJPMjPG-.cjs.map +1 -0
  3. package/dist/{Toast-DUpf_XxS.js → Toast-DXhZLxdl.js} +16 -12
  4. package/dist/Toast-DXhZLxdl.js.map +1 -0
  5. package/dist/components.cjs.js +2 -2
  6. package/dist/components.cjs.js.map +1 -1
  7. package/dist/components.esm.js +702 -717
  8. package/dist/components.esm.js.map +1 -1
  9. package/dist/hooks.cjs.js +1 -1
  10. package/dist/hooks.esm.js +8 -6
  11. package/dist/providers.cjs.js +1 -1
  12. package/dist/providers.cjs.js.map +1 -1
  13. package/dist/providers.esm.js +116 -68
  14. package/dist/providers.esm.js.map +1 -1
  15. package/dist/src/components/panel/Panel.d.ts +1 -4
  16. package/dist/src/hooks/index.d.ts +1 -0
  17. package/dist/src/hooks/useTheme.d.ts +9 -0
  18. package/dist/src/providers/ActionModalProvider.d.ts +11 -0
  19. package/dist/src/providers/DreamerUIProvider.d.ts +12 -0
  20. package/dist/src/providers/ThemeProvider.d.ts +15 -0
  21. package/dist/src/providers/ToastProvider.d.ts +6 -2
  22. package/dist/src/providers/index.d.ts +3 -1
  23. package/dist/useTheme-Bdg1t0Zr.cjs +2 -0
  24. package/dist/useTheme-Bdg1t0Zr.cjs.map +1 -0
  25. package/dist/useTheme-CYIEopvl.js +31 -0
  26. package/dist/useTheme-CYIEopvl.js.map +1 -0
  27. package/package.json +1 -1
  28. package/dist/Toast-DUpf_XxS.js.map +0 -1
  29. package/dist/Toast-Dj3X8g0Q.cjs.map +0 -1
  30. package/dist/src/components/panel/variants.d.ts +0 -12
  31. package/dist/useToast-CEKvEJVB.js +0 -22
  32. package/dist/useToast-CEKvEJVB.js.map +0 -1
  33. package/dist/useToast-CraVIawn.cjs +0 -2
  34. package/dist/useToast-CraVIawn.cjs.map +0 -1
package/dist/hooks.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useToast-CraVIawn.cjs"),o=require("./useScreenSize-UGyolnfn.cjs");exports.ActionModalContext=e.ActionModalContext;exports.useActionModal=e.useActionModal;exports.useToast=e.useToast;exports.useScreenSize=o.useScreenSize;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useTheme-Bdg1t0Zr.cjs"),t=require("./useScreenSize-UGyolnfn.cjs");exports.ActionModalContext=e.ActionModalContext;exports.ThemeContext=e.ThemeContext;exports.useActionModal=e.useActionModal;exports.useTheme=e.useTheme;exports.useToast=e.useToast;exports.useScreenSize=t.useScreenSize;
2
2
  //# sourceMappingURL=hooks.cjs.js.map
package/dist/hooks.esm.js CHANGED
@@ -1,9 +1,11 @@
1
- import { A as a, u as s, a as t } from "./useToast-CEKvEJVB.js";
2
- import { u } from "./useScreenSize-DiuQZBHb.js";
1
+ import { A as s, T as a, u as t, b as u, a as n } from "./useTheme-CYIEopvl.js";
2
+ import { u as m } from "./useScreenSize-DiuQZBHb.js";
3
3
  export {
4
- a as ActionModalContext,
5
- s as useActionModal,
6
- u as useScreenSize,
7
- t as useToast
4
+ s as ActionModalContext,
5
+ a as ThemeContext,
6
+ t as useActionModal,
7
+ m as useScreenSize,
8
+ u as useTheme,
9
+ n as useToast
8
10
  };
9
11
  //# sourceMappingURL=hooks.esm.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),s=require("react"),x=require("./Toast-Dj3X8g0Q.cjs"),g=require("./useToast-CraVIawn.cjs");require("react-dom");const b=require("./join-BVMUUvyP.cjs");function y({children:d}){const[e,n]=s.useState(null),m=s.useCallback(t=>new Promise(l=>{n({isOpen:!0,type:"confirm",title:t.title,message:t.message,confirmText:t.confirmText,cancelText:t.cancelText,destructive:t.destructive,resolve:l})}),[]),c=s.useCallback(t=>new Promise(l=>{n({isOpen:!0,type:"alert",title:t.title,message:t.message,confirmText:t.confirmText,destructive:t.destructive,resolve:l})}),[]),i=s.useCallback(()=>{e!=null&&e.resolve&&(e.type==="confirm"?e.resolve(!1):e.resolve()),n(null)},[e]),a=s.useCallback(()=>{e!=null&&e.resolve&&(e.type==="confirm"?e.resolve(!0):e.resolve()),n(null)},[e]),f={confirm:m,alert:c};return o.jsxs(g.ActionModalContext.Provider,{value:f,children:[d,e&&e.type==="alert"&&o.jsx(x.ActionModal,{type:"alert",isOpen:e.isOpen,onClose:i,title:e.title,message:e.message,confirmText:e.confirmText,destructive:e.destructive,onConfirm:a,className:"bg-white dark:bg-gray-800 rounded-lg"}),e&&e.type==="confirm"&&o.jsx(x.ActionModal,{type:"confirm",isOpen:e.isOpen,onClose:i,title:e.title,message:e.message,confirmText:e.confirmText,cancelText:e.cancelText,destructive:e.destructive,onConfirm:a,className:"bg-white dark:bg-gray-800 rounded-lg"})]})}const C={"top-right":"top-4 right-4","top-left":"top-4 left-4","bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-center":"top-4 left-1/2 -translate-x-1/2","bottom-center":"bottom-4 left-1/2 -translate-x-1/2"};function h({children:d,customTypes:e,customComponent:n,position:m="top-right",maxToasts:c=5}){const[i,a]=s.useState([]),f=s.useCallback(r=>{const v=`toast-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,u=r.id||v,T={id:u,title:r.title,description:r.description,type:r.type||"info",action:r.action,duration:r.duration??5e3};return a(p=>[T,...p].slice(0,c)),u},[c]),t=s.useCallback(r=>{a(v=>v.filter(u=>u.id!==r))},[]),l={addToast:f,removeToast:t,toasts:i};return o.jsxs(g.ToastContext.Provider,{value:l,children:[d,o.jsx("div",{className:b.join("fixed z-50 pointer-events-none max-w-sm w-full space-y-2",C[m]),role:"region","aria-label":"Notifications",children:i.map(r=>o.jsx("div",{className:"pointer-events-auto",children:o.jsx(x.Toast,{...r,onRemove:t,customTypes:e,customComponent:n})},r.id))})]})}exports.ActionModalProvider=y;exports.ToastProvider=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),n=require("react"),v=require("./Toast-BJPMjPG-.cjs"),g=require("./useTheme-Bdg1t0Zr.cjs");require("react-dom");const y=require("./join-BVMUUvyP.cjs");function x({children:u}){const[e,i]=n.useState(null),h=n.useCallback(r=>new Promise(f=>{i({isOpen:!0,type:"confirm",title:r.title,message:r.message,confirmText:r.confirmText,cancelText:r.cancelText,destructive:r.destructive,resolve:f})}),[]),c=n.useCallback(r=>new Promise(f=>{i({isOpen:!0,type:"alert",title:r.title,message:r.message,confirmText:r.confirmText,destructive:r.destructive,resolve:f})}),[]),s=n.useCallback(()=>{e!=null&&e.resolve&&(e.type==="confirm"?e.resolve(!1):e.resolve()),i(null)},[e]),m=n.useCallback(()=>{e!=null&&e.resolve&&(e.type==="confirm"?e.resolve(!0):e.resolve()),i(null)},[e]),d={confirm:h,alert:c};return a.jsxs(g.ActionModalContext.Provider,{value:d,children:[u,e&&e.type==="alert"&&a.jsx(v.ActionModal,{type:"alert",isOpen:e.isOpen,onClose:s,title:e.title,message:e.message,confirmText:e.confirmText,destructive:e.destructive,onConfirm:m,className:"bg-white dark:bg-gray-800 rounded-lg"}),e&&e.type==="confirm"&&a.jsx(v.ActionModal,{type:"confirm",isOpen:e.isOpen,onClose:s,title:e.title,message:e.message,confirmText:e.confirmText,cancelText:e.cancelText,destructive:e.destructive,onConfirm:m,className:"bg-white dark:bg-gray-800 rounded-lg"})]})}const b={"top-right":"top-4 right-4","top-left":"top-4 left-4","bottom-right":"bottom-4 right-4","bottom-left":"bottom-4 left-4","top-center":"top-4 left-1/2 -translate-x-1/2","bottom-center":"bottom-4 left-1/2 -translate-x-1/2"};function T({children:u,customTypes:e,customComponent:i,position:h="top-right",maxToasts:c=5}){const[s,m]=n.useState([]),d=n.useCallback(o=>{const t=`toast-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,l=o.id||t,w={id:l,title:o.title,description:o.description,type:o.type||"info",action:o.action,duration:o.duration??5e3};return m(k=>[w,...k].slice(0,c)),l},[c]),r=n.useCallback(o=>{m(t=>t.filter(l=>l.id!==o))},[]),f={addToast:d,removeToast:r,toasts:s};return a.jsxs(g.ToastContext.Provider,{value:f,children:[u,a.jsx("div",{className:y.join("fixed z-50 pointer-events-none max-w-sm w-full space-y-2",b[h]),role:"region","aria-label":"Notifications",children:s.map(o=>a.jsx("div",{className:"pointer-events-auto",children:a.jsx(v.Toast,{...o,onRemove:r,customTypes:e,customComponent:i})},o.id))})]})}function p({children:u,defaultTheme:e="system",storageKey:i="dreamer-ui-theme",attribute:h="data-theme",respectSystem:c=!0}){const[s,m]=n.useState(()=>{if(typeof window>"u")return e;const t=localStorage.getItem(i);return t&&["light","dark","system"].includes(t)?t:e}),[d,r]=n.useState(()=>typeof window>"u"?"light":s==="system"&&c?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":s==="dark"?"dark":"light"),f=n.useCallback(t=>{m(t),typeof window<"u"&&localStorage.setItem(i,t)},[i]);n.useEffect(()=>{if(typeof window>"u")return;const t=()=>{if(s==="system"&&c){const l=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";r(l)}else r(s==="dark"?"dark":"light")};if(t(),s==="system"&&c){const l=window.matchMedia("(prefers-color-scheme: dark)");return l.addEventListener("change",t),()=>l.removeEventListener("change",t)}},[s,c]),n.useEffect(()=>{if(typeof window>"u")return;const t=document.documentElement;t.setAttribute(h,d),d==="dark"?t.classList.add("dark"):t.classList.remove("dark")},[d,h]);const o={theme:s,setTheme:f,resolvedTheme:d};return a.jsx(g.ThemeContext.Provider,{value:o,children:u})}function C({children:u,theme:e={},toast:i={}}){return a.jsx(p,{...e,children:a.jsx(T,{...i,children:a.jsx(x,{children:u})})})}exports.ActionModalProvider=x;exports.DreamerUIProvider=C;exports.ThemeProvider=p;exports.ToastProvider=T;
2
2
  //# sourceMappingURL=providers.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.cjs.js","sources":["../src/providers/ActionModalProvider.tsx","../src/providers/ToastProvider.tsx"],"sourcesContent":["import { ReactNode, useCallback, useState } from 'react';\nimport { ActionModal } from '../components';\nimport { ActionModalContext } from '../hooks';\n\nexport interface ConfirmOptions {\n title?: string;\n message: ReactNode;\n confirmText?: string;\n cancelText?: string;\n destructive?: boolean;\n}\n\nexport interface AlertOptions {\n title?: string;\n message: ReactNode;\n confirmText?: string;\n destructive?: boolean;\n}\n\nexport interface ActionModalContextValue {\n confirm: (options: ConfirmOptions) => Promise<boolean>;\n alert: (options: AlertOptions) => Promise<void>;\n}\n\ninterface ActionModalState {\n isOpen: boolean;\n type: 'alert' | 'confirm';\n title?: string;\n message: ReactNode;\n confirmText?: string;\n cancelText?: string;\n destructive?: boolean;\n resolve?: ((value: boolean) => void) | (() => void);\n}\n\nexport function ActionModalProvider({ children }: { children: ReactNode }) {\n const [modalState, setModalState] = useState<ActionModalState | null>(null);\n\n const confirm = useCallback((options: ConfirmOptions): Promise<boolean> => {\n return new Promise((resolve) => {\n setModalState({\n isOpen: true,\n type: 'confirm',\n title: options.title,\n message: options.message,\n confirmText: options.confirmText,\n cancelText: options.cancelText,\n destructive: options.destructive,\n resolve,\n });\n });\n }, []);\n\n const alert = useCallback((options: AlertOptions): Promise<void> => {\n return new Promise((resolve) => {\n setModalState({\n isOpen: true,\n type: 'alert',\n title: options.title,\n message: options.message,\n confirmText: options.confirmText,\n destructive: options.destructive,\n resolve,\n });\n });\n }, []);\n\n const handleClose = useCallback(() => {\n if (modalState?.resolve) {\n if (modalState.type === 'confirm') {\n (modalState.resolve as (value: boolean) => void)(false);\n } else {\n (modalState.resolve as () => void)();\n }\n }\n setModalState(null);\n }, [modalState]);\n\n const handleConfirm = useCallback(() => {\n if (modalState?.resolve) {\n if (modalState.type === 'confirm') {\n (modalState.resolve as (value: boolean) => void)(true);\n } else {\n (modalState.resolve as () => void)();\n }\n }\n setModalState(null);\n }, [modalState]);\n\n const contextValue: ActionModalContextValue = {\n confirm,\n alert,\n };\n\n return (\n <ActionModalContext.Provider value={contextValue}>\n {children}\n {modalState && modalState.type === 'alert' && (\n <ActionModal\n type='alert'\n isOpen={modalState.isOpen}\n onClose={handleClose}\n title={modalState.title}\n message={modalState.message}\n confirmText={modalState.confirmText}\n destructive={modalState.destructive}\n onConfirm={handleConfirm}\n className='bg-white dark:bg-gray-800 rounded-lg'\n />\n )}\n {modalState && modalState.type === 'confirm' && (\n <ActionModal\n type='confirm'\n isOpen={modalState.isOpen}\n onClose={handleClose}\n title={modalState.title}\n message={modalState.message}\n confirmText={modalState.confirmText}\n cancelText={modalState.cancelText}\n destructive={modalState.destructive}\n onConfirm={handleConfirm}\n className='bg-white dark:bg-gray-800 rounded-lg'\n />\n )}\n </ActionModalContext.Provider>\n );\n}\n","import { ReactNode, useCallback, useState } from 'react';\nimport { Toast, ToastData, ToastType } from '../components/toast';\nimport { AddToastOptions, ToastContextValue } from '../hooks/useToast';\nimport { ToastContext } from '../hooks/useToast';\nimport { join } from '../utils';\n\ninterface ToastProviderProps {\n children: ReactNode;\n customTypes?: Record<string, { className: string; icon?: ReactNode }>;\n customComponent?: React.ComponentType<ToastData>;\n position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';\n maxToasts?: number;\n}\n\nconst positionClasses = {\n 'top-right': 'top-4 right-4',\n 'top-left': 'top-4 left-4',\n 'bottom-right': 'bottom-4 right-4',\n 'bottom-left': 'bottom-4 left-4',\n 'top-center': 'top-4 left-1/2 -translate-x-1/2',\n 'bottom-center': 'bottom-4 left-1/2 -translate-x-1/2',\n};\n\nexport function ToastProvider({\n children,\n customTypes,\n customComponent,\n position = 'top-right',\n maxToasts = 5,\n}: ToastProviderProps) {\n const [toasts, setToasts] = useState<ToastData[]>([]);\n\n const addToast = useCallback(\n (options: AddToastOptions) => {\n const generatedId = `toast-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;\n const id = options.id || generatedId;\n\n const newToast: ToastData = {\n id,\n title: options.title,\n description: options.description,\n type: (options.type as ToastType) || 'info',\n action: options.action,\n duration: options.duration ?? 5000,\n };\n\n setToasts((prevToasts) => {\n const updatedToasts = [newToast, ...prevToasts];\n // Keep only the most recent toasts if we exceed maxToasts\n return updatedToasts.slice(0, maxToasts);\n });\n\n return id;\n },\n [maxToasts]\n );\n\n const removeToast = useCallback((id: string) => {\n setToasts((prevToasts) => prevToasts.filter((toast) => toast.id !== id));\n }, []);\n\n const contextValue: ToastContextValue = {\n addToast,\n removeToast,\n toasts,\n };\n\n return (\n <ToastContext.Provider value={contextValue}>\n {children}\n\n <div\n className={join('fixed z-50 pointer-events-none max-w-sm w-full space-y-2', positionClasses[position])}\n role='region'\n aria-label='Notifications'\n >\n {toasts.map((toast) => (\n <div key={toast.id} className='pointer-events-auto'>\n <Toast {...toast} onRemove={removeToast} customTypes={customTypes} customComponent={customComponent} />\n </div>\n ))}\n </div>\n </ToastContext.Provider>\n );\n}\n"],"names":["ActionModalProvider","children","modalState","setModalState","useState","confirm","useCallback","options","resolve","alert","handleClose","handleConfirm","contextValue","jsxs","ActionModalContext","jsx","ActionModal","positionClasses","ToastProvider","customTypes","customComponent","position","maxToasts","toasts","setToasts","addToast","generatedId","id","newToast","prevToasts","removeToast","toast","ToastContext","join","Toast"],"mappings":"2QAmCgB,SAAAA,EAAoB,CAAE,SAAAC,GAAqC,CACzE,KAAM,CAACC,EAAYC,CAAa,EAAIC,EAAAA,SAAkC,IAAI,EAEpEC,EAAUC,cAAaC,GACpB,IAAI,QAASC,GAAY,CAChBL,EAAA,CACZ,OAAQ,GACR,KAAM,UACN,MAAOI,EAAQ,MACf,QAASA,EAAQ,QACjB,YAAaA,EAAQ,YACrB,WAAYA,EAAQ,WACpB,YAAaA,EAAQ,YACrB,QAAAC,CAAA,CACD,CAAA,CAC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AEJ"}
1
+ {"version":3,"file":"providers.cjs.js","sources":["../src/providers/ActionModalProvider.tsx","../src/providers/ToastProvider.tsx","../src/providers/ThemeProvider.tsx","../src/providers/DreamerUIProvider.tsx"],"sourcesContent":["import { ReactNode, useCallback, useState } from 'react';\nimport { ActionModal } from '../components';\nimport { ActionModalContext } from '../hooks';\n\nexport interface ConfirmOptions {\n /** The title displayed in the confirmation modal header */\n title?: string;\n /** The main message content displayed in the modal body */\n message: ReactNode;\n /** Text for the confirm/accept button. Defaults to \"Confirm\" */\n confirmText?: string;\n /** Text for the cancel/dismiss button. Defaults to \"Cancel\" */\n cancelText?: string;\n /** Whether the action is destructive, affects button styling */\n destructive?: boolean;\n}\n\nexport interface AlertOptions {\n /** The title displayed in the alert modal header */\n title?: string;\n /** The main message content displayed in the modal body */\n message: ReactNode;\n /** Text for the confirm/dismiss button. Defaults to \"OK\" */\n confirmText?: string;\n /** Whether the alert represents a destructive action, affects button styling */\n destructive?: boolean;\n}\n\nexport interface ActionModalContextValue {\n /** Shows a confirmation modal and returns a promise that resolves to true if confirmed, false if cancelled */\n confirm: (options: ConfirmOptions) => Promise<boolean>;\n /** Shows an alert modal and returns a promise that resolves when dismissed */\n alert: (options: AlertOptions) => Promise<void>;\n}\n\ninterface ActionModalState {\n isOpen: boolean;\n type: 'alert' | 'confirm';\n title?: string;\n message: ReactNode;\n confirmText?: string;\n cancelText?: string;\n destructive?: boolean;\n resolve?: ((value: boolean) => void) | (() => void);\n}\n\nexport function ActionModalProvider({ children }: { children: ReactNode }) {\n const [modalState, setModalState] = useState<ActionModalState | null>(null);\n\n const confirm = useCallback((options: ConfirmOptions): Promise<boolean> => {\n return new Promise((resolve) => {\n setModalState({\n isOpen: true,\n type: 'confirm',\n title: options.title,\n message: options.message,\n confirmText: options.confirmText,\n cancelText: options.cancelText,\n destructive: options.destructive,\n resolve,\n });\n });\n }, []);\n\n const alert = useCallback((options: AlertOptions): Promise<void> => {\n return new Promise((resolve) => {\n setModalState({\n isOpen: true,\n type: 'alert',\n title: options.title,\n message: options.message,\n confirmText: options.confirmText,\n destructive: options.destructive,\n resolve,\n });\n });\n }, []);\n\n const handleClose = useCallback(() => {\n if (modalState?.resolve) {\n if (modalState.type === 'confirm') {\n (modalState.resolve as (value: boolean) => void)(false);\n } else {\n (modalState.resolve as () => void)();\n }\n }\n setModalState(null);\n }, [modalState]);\n\n const handleConfirm = useCallback(() => {\n if (modalState?.resolve) {\n if (modalState.type === 'confirm') {\n (modalState.resolve as (value: boolean) => void)(true);\n } else {\n (modalState.resolve as () => void)();\n }\n }\n setModalState(null);\n }, [modalState]);\n\n const contextValue: ActionModalContextValue = {\n confirm,\n alert,\n };\n\n return (\n <ActionModalContext.Provider value={contextValue}>\n {children}\n {modalState && modalState.type === 'alert' && (\n <ActionModal\n type='alert'\n isOpen={modalState.isOpen}\n onClose={handleClose}\n title={modalState.title}\n message={modalState.message}\n confirmText={modalState.confirmText}\n destructive={modalState.destructive}\n onConfirm={handleConfirm}\n className='bg-white dark:bg-gray-800 rounded-lg'\n />\n )}\n {modalState && modalState.type === 'confirm' && (\n <ActionModal\n type='confirm'\n isOpen={modalState.isOpen}\n onClose={handleClose}\n title={modalState.title}\n message={modalState.message}\n confirmText={modalState.confirmText}\n cancelText={modalState.cancelText}\n destructive={modalState.destructive}\n onConfirm={handleConfirm}\n className='bg-white dark:bg-gray-800 rounded-lg'\n />\n )}\n </ActionModalContext.Provider>\n );\n}\n","import { ReactNode, useCallback, useState } from 'react';\nimport { Toast, ToastData, ToastType } from '../components/toast';\nimport { AddToastOptions, ToastContextValue } from '../hooks/useToast';\nimport { ToastContext } from '../hooks/useToast';\nimport { join } from '../utils';\n\nexport interface ToastProviderProps {\n /** React children to be wrapped by the toast provider */\n children: ReactNode;\n /** Custom toast types with their own styling and icons */\n customTypes?: Record<string, { className: string; icon?: ReactNode }>;\n /** Custom toast component to replace the default Toast component */\n customComponent?: React.ComponentType<ToastData>;\n /** Position where toasts should appear on screen */\n position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';\n /** Maximum number of toasts to display at once */\n maxToasts?: number;\n}\n\nconst positionClasses = {\n 'top-right': 'top-4 right-4',\n 'top-left': 'top-4 left-4',\n 'bottom-right': 'bottom-4 right-4',\n 'bottom-left': 'bottom-4 left-4',\n 'top-center': 'top-4 left-1/2 -translate-x-1/2',\n 'bottom-center': 'bottom-4 left-1/2 -translate-x-1/2',\n};\n\nexport function ToastProvider({\n children,\n customTypes,\n customComponent,\n position = 'top-right',\n maxToasts = 5,\n}: ToastProviderProps) {\n const [toasts, setToasts] = useState<ToastData[]>([]);\n\n const addToast = useCallback(\n (options: AddToastOptions) => {\n const generatedId = `toast-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;\n const id = options.id || generatedId;\n\n const newToast: ToastData = {\n id,\n title: options.title,\n description: options.description,\n type: (options.type as ToastType) || 'info',\n action: options.action,\n duration: options.duration ?? 5000,\n };\n\n setToasts((prevToasts) => {\n const updatedToasts = [newToast, ...prevToasts];\n // Keep only the most recent toasts if we exceed maxToasts\n return updatedToasts.slice(0, maxToasts);\n });\n\n return id;\n },\n [maxToasts]\n );\n\n const removeToast = useCallback((id: string) => {\n setToasts((prevToasts) => prevToasts.filter((toast) => toast.id !== id));\n }, []);\n\n const contextValue: ToastContextValue = {\n addToast,\n removeToast,\n toasts,\n };\n\n return (\n <ToastContext.Provider value={contextValue}>\n {children}\n\n <div\n className={join('fixed z-50 pointer-events-none max-w-sm w-full space-y-2', positionClasses[position])}\n role='region'\n aria-label='Notifications'\n >\n {toasts.map((toast) => (\n <div key={toast.id} className='pointer-events-auto'>\n <Toast {...toast} onRemove={removeToast} customTypes={customTypes} customComponent={customComponent} />\n </div>\n ))}\n </div>\n </ToastContext.Provider>\n );\n}\n","import { ReactNode, useCallback, useEffect, useState } from 'react';\nimport { Theme, ThemeContext, ThemeContextValue } from '../hooks/useTheme';\n\nexport interface ThemeProviderProps {\n /** React children to be wrapped by the theme provider */\n children: ReactNode;\n /** The default theme to use on first load. Defaults to 'system' */\n defaultTheme?: Theme;\n /** Local storage key used to persist the theme selection. Defaults to 'dreamer-ui-theme' */\n storageKey?: string;\n /** HTML attribute name to set on document root. Defaults to 'data-theme' */\n attribute?: string;\n /** Whether to respect system theme when theme is set to 'system'. Defaults to true */\n respectSystem?: boolean;\n}\n\nexport function ThemeProvider({\n children,\n defaultTheme = 'system',\n storageKey = 'dreamer-ui-theme',\n attribute = 'data-theme',\n respectSystem = true,\n}: ThemeProviderProps) {\n const [theme, setThemeState] = useState<Theme>(() => {\n if (typeof window === 'undefined') {\n return defaultTheme;\n }\n\n const stored = localStorage.getItem(storageKey);\n if (stored && ['light', 'dark', 'system'].includes(stored)) {\n return stored as Theme;\n }\n\n return defaultTheme;\n });\n\n const [resolvedTheme, setResolvedTheme] = useState<'light' | 'dark'>(() => {\n if (typeof window === 'undefined') {\n return 'light';\n }\n\n if (theme === 'system' && respectSystem) {\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n }\n\n return theme === 'dark' ? 'dark' : 'light';\n });\n\n const setTheme = useCallback(\n (newTheme: Theme) => {\n setThemeState(newTheme);\n if (typeof window !== 'undefined') {\n localStorage.setItem(storageKey, newTheme);\n }\n },\n [storageKey]\n );\n\n useEffect(() => {\n if (typeof window === 'undefined') return;\n\n const updateResolvedTheme = () => {\n if (theme === 'system' && respectSystem) {\n const systemTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n setResolvedTheme(systemTheme);\n } else {\n setResolvedTheme(theme === 'dark' ? 'dark' : 'light');\n }\n };\n\n updateResolvedTheme();\n\n if (theme === 'system' && respectSystem) {\n const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n mediaQuery.addEventListener('change', updateResolvedTheme);\n return () => mediaQuery.removeEventListener('change', updateResolvedTheme);\n }\n }, [theme, respectSystem]);\n\n useEffect(() => {\n if (typeof window === 'undefined') return;\n\n const root = document.documentElement;\n root.setAttribute(attribute, resolvedTheme);\n \n // Also set class for Tailwind dark mode\n if (resolvedTheme === 'dark') {\n root.classList.add('dark');\n } else {\n root.classList.remove('dark');\n }\n }, [resolvedTheme, attribute]);\n\n const contextValue: ThemeContextValue = {\n theme,\n setTheme,\n resolvedTheme,\n };\n\n return <ThemeContext.Provider value={contextValue}>{children}</ThemeContext.Provider>;\n}","import { ReactNode } from 'react';\nimport { ActionModalProvider } from './ActionModalProvider';\nimport { ThemeProvider, ThemeProviderProps } from './ThemeProvider';\nimport { ToastProvider, ToastProviderProps } from './ToastProvider';\n\nexport interface DreamerUIProviderProps {\n\t/** React children to be wrapped by all DreamerUI providers */\n\tchildren: ReactNode;\n\t/** Configuration options for the ThemeProvider */\n\ttheme?: Omit<ThemeProviderProps, 'children'>;\n\t/** Configuration options for the ToastProvider */\n\ttoast?: Omit<ToastProviderProps, 'children'>;\n}\n\nexport function DreamerUIProvider({ children, theme = {}, toast = {} }: DreamerUIProviderProps) {\n\treturn (\n\t\t<ThemeProvider {...theme}>\n\t\t\t<ToastProvider {...toast}>\n\t\t\t\t<ActionModalProvider>{children}</ActionModalProvider>\n\t\t\t</ToastProvider>\n\t\t</ThemeProvider>\n\t);\n}\n"],"names":["ActionModalProvider","children","modalState","setModalState","useState","confirm","useCallback","options","resolve","alert","handleClose","handleConfirm","contextValue","jsxs","ActionModalContext","jsx","ActionModal","positionClasses","ToastProvider","customTypes","customComponent","position","maxToasts","toasts","setToasts","addToast","generatedId","id","newToast","prevToasts","removeToast","toast","ToastContext","join","Toast","ThemeProvider","defaultTheme","storageKey","attribute","respectSystem","theme","setThemeState","stored","resolvedTheme","setResolvedTheme","setTheme","newTheme","useEffect","updateResolvedTheme","systemTheme","mediaQuery","root","ThemeContext","DreamerUIProvider"],"mappings":"2QA8CgB,SAAAA,EAAoB,CAAE,SAAAC,GAAqC,CACzE,KAAM,CAACC,EAAYC,CAAa,EAAIC,EAAAA,SAAkC,IAAI,EAEpEC,EAAUC,cAAaC,GACpB,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AAW,oBAAoB,SAAUF,CAAmB,CAAA,CAC3E,EACC,CAACR,EAAOD,CAAa,CAAC,EAEzBQ,EAAAA,UAAU,IAAM,CACV,GAAA,OAAO,OAAW,IAAa,OAEnC,MAAMI,EAAO,SAAS,gBACjBA,EAAA,aAAab,EAAWK,CAAa,EAGtCA,IAAkB,OACfQ,EAAA,UAAU,IAAI,MAAM,EAEpBA,EAAA,UAAU,OAAO,MAAM,CAC9B,EACC,CAACR,EAAeL,CAAS,CAAC,EAE7B,MAAM1B,EAAkC,CACtC,MAAA4B,EACA,SAAAK,EACA,cAAAF,CACF,EAEA,aAAQS,EAAAA,aAAa,SAAb,CAAsB,MAAOxC,EAAe,SAAAX,EAAS,CAC/D,CCtFgB,SAAAoD,EAAkB,CAAE,SAAApD,EAAU,MAAAuC,EAAQ,CAAA,EAAI,MAAAT,EAAQ,CAAA,GAA8B,CAC/F,OACEhB,EAAAA,IAAAoB,EAAA,CAAe,GAAGK,EAClB,SAACzB,EAAA,IAAAG,EAAA,CAAe,GAAGa,EAClB,SAAChB,EAAAA,IAAAf,EAAA,CAAqB,SAAAC,CAAS,CAAA,CAChC,CAAA,EACD,CAEF"}
@@ -1,73 +1,73 @@
1
- import { jsxs as g, jsx as l } from "react/jsx-runtime";
2
- import { useState as x, useCallback as s } from "react";
3
- import { A as v, T as y } from "./Toast-DUpf_XxS.js";
4
- import { A as b, T as C } from "./useToast-CEKvEJVB.js";
1
+ import { jsxs as T, jsx as c } from "react/jsx-runtime";
2
+ import { useState as v, useCallback as u, useEffect as g } from "react";
3
+ import { A as p, T as y } from "./Toast-DXhZLxdl.js";
4
+ import { A as k, c as b, T as C } from "./useTheme-CYIEopvl.js";
5
5
  import "react-dom";
6
- import { j as w } from "./join-BmgR_f4v.js";
7
- function $({ children: d }) {
8
- const [e, o] = x(null), f = s((t) => new Promise((a) => {
9
- o({
6
+ import { j as P } from "./join-BmgR_f4v.js";
7
+ function M({ children: l }) {
8
+ const [e, i] = v(null), h = u((r) => new Promise((f) => {
9
+ i({
10
10
  isOpen: !0,
11
11
  type: "confirm",
12
- title: t.title,
13
- message: t.message,
14
- confirmText: t.confirmText,
15
- cancelText: t.cancelText,
16
- destructive: t.destructive,
17
- resolve: a
12
+ title: r.title,
13
+ message: r.message,
14
+ confirmText: r.confirmText,
15
+ cancelText: r.cancelText,
16
+ destructive: r.destructive,
17
+ resolve: f
18
18
  });
19
- }), []), c = s((t) => new Promise((a) => {
20
- o({
19
+ }), []), s = u((r) => new Promise((f) => {
20
+ i({
21
21
  isOpen: !0,
22
22
  type: "alert",
23
- title: t.title,
24
- message: t.message,
25
- confirmText: t.confirmText,
26
- destructive: t.destructive,
27
- resolve: a
23
+ title: r.title,
24
+ message: r.message,
25
+ confirmText: r.confirmText,
26
+ destructive: r.destructive,
27
+ resolve: f
28
28
  });
29
- }), []), i = s(() => {
30
- e != null && e.resolve && (e.type === "confirm" ? e.resolve(!1) : e.resolve()), o(null);
31
- }, [e]), n = s(() => {
32
- e != null && e.resolve && (e.type === "confirm" ? e.resolve(!0) : e.resolve()), o(null);
33
- }, [e]), u = {
34
- confirm: f,
35
- alert: c
29
+ }), []), o = u(() => {
30
+ e != null && e.resolve && (e.type === "confirm" ? e.resolve(!1) : e.resolve()), i(null);
31
+ }, [e]), m = u(() => {
32
+ e != null && e.resolve && (e.type === "confirm" ? e.resolve(!0) : e.resolve()), i(null);
33
+ }, [e]), d = {
34
+ confirm: h,
35
+ alert: s
36
36
  };
37
- return /* @__PURE__ */ g(b.Provider, { value: u, children: [
38
- d,
39
- e && e.type === "alert" && /* @__PURE__ */ l(
40
- v,
37
+ return /* @__PURE__ */ T(k.Provider, { value: d, children: [
38
+ l,
39
+ e && e.type === "alert" && /* @__PURE__ */ c(
40
+ p,
41
41
  {
42
42
  type: "alert",
43
43
  isOpen: e.isOpen,
44
- onClose: i,
44
+ onClose: o,
45
45
  title: e.title,
46
46
  message: e.message,
47
47
  confirmText: e.confirmText,
48
48
  destructive: e.destructive,
49
- onConfirm: n,
49
+ onConfirm: m,
50
50
  className: "bg-white dark:bg-gray-800 rounded-lg"
51
51
  }
52
52
  ),
53
- e && e.type === "confirm" && /* @__PURE__ */ l(
54
- v,
53
+ e && e.type === "confirm" && /* @__PURE__ */ c(
54
+ p,
55
55
  {
56
56
  type: "confirm",
57
57
  isOpen: e.isOpen,
58
- onClose: i,
58
+ onClose: o,
59
59
  title: e.title,
60
60
  message: e.message,
61
61
  confirmText: e.confirmText,
62
62
  cancelText: e.cancelText,
63
63
  destructive: e.destructive,
64
- onConfirm: n,
64
+ onConfirm: m,
65
65
  className: "bg-white dark:bg-gray-800 rounded-lg"
66
66
  }
67
67
  )
68
68
  ] });
69
69
  }
70
- const O = {
70
+ const A = {
71
71
  "top-right": "top-4 right-4",
72
72
  "top-left": "top-4 left-4",
73
73
  "bottom-right": "bottom-4 right-4",
@@ -75,48 +75,96 @@ const O = {
75
75
  "top-center": "top-4 left-1/2 -translate-x-1/2",
76
76
  "bottom-center": "bottom-4 left-1/2 -translate-x-1/2"
77
77
  };
78
- function z({
79
- children: d,
78
+ function O({
79
+ children: l,
80
80
  customTypes: e,
81
- customComponent: o,
82
- position: f = "top-right",
83
- maxToasts: c = 5
81
+ customComponent: i,
82
+ position: h = "top-right",
83
+ maxToasts: s = 5
84
84
  }) {
85
- const [i, n] = x([]), u = s(
86
- (r) => {
87
- const p = `toast-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, m = r.id || p, T = {
88
- id: m,
89
- title: r.title,
90
- description: r.description,
91
- type: r.type || "info",
92
- action: r.action,
93
- duration: r.duration ?? 5e3
85
+ const [o, m] = v([]), d = u(
86
+ (n) => {
87
+ const t = `toast-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, a = n.id || t, x = {
88
+ id: a,
89
+ title: n.title,
90
+ description: n.description,
91
+ type: n.type || "info",
92
+ action: n.action,
93
+ duration: n.duration ?? 5e3
94
94
  };
95
- return n((h) => [T, ...h].slice(0, c)), m;
95
+ return m((w) => [x, ...w].slice(0, s)), a;
96
96
  },
97
- [c]
98
- ), t = s((r) => {
99
- n((p) => p.filter((m) => m.id !== r));
100
- }, []), a = {
101
- addToast: u,
102
- removeToast: t,
103
- toasts: i
97
+ [s]
98
+ ), r = u((n) => {
99
+ m((t) => t.filter((a) => a.id !== n));
100
+ }, []), f = {
101
+ addToast: d,
102
+ removeToast: r,
103
+ toasts: o
104
104
  };
105
- return /* @__PURE__ */ g(C.Provider, { value: a, children: [
106
- d,
107
- /* @__PURE__ */ l(
105
+ return /* @__PURE__ */ T(b.Provider, { value: f, children: [
106
+ l,
107
+ /* @__PURE__ */ c(
108
108
  "div",
109
109
  {
110
- className: w("fixed z-50 pointer-events-none max-w-sm w-full space-y-2", O[f]),
110
+ className: P("fixed z-50 pointer-events-none max-w-sm w-full space-y-2", A[h]),
111
111
  role: "region",
112
112
  "aria-label": "Notifications",
113
- children: i.map((r) => /* @__PURE__ */ l("div", { className: "pointer-events-auto", children: /* @__PURE__ */ l(y, { ...r, onRemove: t, customTypes: e, customComponent: o }) }, r.id))
113
+ children: o.map((n) => /* @__PURE__ */ c("div", { className: "pointer-events-auto", children: /* @__PURE__ */ c(y, { ...n, onRemove: r, customTypes: e, customComponent: i }) }, n.id))
114
114
  }
115
115
  )
116
116
  ] });
117
117
  }
118
+ function N({
119
+ children: l,
120
+ defaultTheme: e = "system",
121
+ storageKey: i = "dreamer-ui-theme",
122
+ attribute: h = "data-theme",
123
+ respectSystem: s = !0
124
+ }) {
125
+ const [o, m] = v(() => {
126
+ if (typeof window > "u")
127
+ return e;
128
+ const t = localStorage.getItem(i);
129
+ return t && ["light", "dark", "system"].includes(t) ? t : e;
130
+ }), [d, r] = v(() => typeof window > "u" ? "light" : o === "system" && s ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : o === "dark" ? "dark" : "light"), f = u(
131
+ (t) => {
132
+ m(t), typeof window < "u" && localStorage.setItem(i, t);
133
+ },
134
+ [i]
135
+ );
136
+ g(() => {
137
+ if (typeof window > "u") return;
138
+ const t = () => {
139
+ if (o === "system" && s) {
140
+ const a = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
141
+ r(a);
142
+ } else
143
+ r(o === "dark" ? "dark" : "light");
144
+ };
145
+ if (t(), o === "system" && s) {
146
+ const a = window.matchMedia("(prefers-color-scheme: dark)");
147
+ return a.addEventListener("change", t), () => a.removeEventListener("change", t);
148
+ }
149
+ }, [o, s]), g(() => {
150
+ if (typeof window > "u") return;
151
+ const t = document.documentElement;
152
+ t.setAttribute(h, d), d === "dark" ? t.classList.add("dark") : t.classList.remove("dark");
153
+ }, [d, h]);
154
+ const n = {
155
+ theme: o,
156
+ setTheme: f,
157
+ resolvedTheme: d
158
+ };
159
+ return /* @__PURE__ */ c(C.Provider, { value: n, children: l });
160
+ }
161
+ function $({ children: l, theme: e = {}, toast: i = {} }) {
162
+ return /* @__PURE__ */ c(N, { ...e, children: /* @__PURE__ */ c(O, { ...i, children: /* @__PURE__ */ c(M, { children: l }) }) });
163
+ }
118
164
  export {
119
- $ as ActionModalProvider,
120
- z as ToastProvider
165
+ M as ActionModalProvider,
166
+ $ as DreamerUIProvider,
167
+ N as ThemeProvider,
168
+ O as ToastProvider
121
169
  };
122
170
  //# sourceMappingURL=providers.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.esm.js","sources":["../src/providers/ActionModalProvider.tsx","../src/providers/ToastProvider.tsx"],"sourcesContent":["import { ReactNode, useCallback, useState } from 'react';\nimport { ActionModal } from '../components';\nimport { ActionModalContext } from '../hooks';\n\nexport interface ConfirmOptions {\n title?: string;\n message: ReactNode;\n confirmText?: string;\n cancelText?: string;\n destructive?: boolean;\n}\n\nexport interface AlertOptions {\n title?: string;\n message: ReactNode;\n confirmText?: string;\n destructive?: boolean;\n}\n\nexport interface ActionModalContextValue {\n confirm: (options: ConfirmOptions) => Promise<boolean>;\n alert: (options: AlertOptions) => Promise<void>;\n}\n\ninterface ActionModalState {\n isOpen: boolean;\n type: 'alert' | 'confirm';\n title?: string;\n message: ReactNode;\n confirmText?: string;\n cancelText?: string;\n destructive?: boolean;\n resolve?: ((value: boolean) => void) | (() => void);\n}\n\nexport function ActionModalProvider({ children }: { children: ReactNode }) {\n const [modalState, setModalState] = useState<ActionModalState | null>(null);\n\n const confirm = useCallback((options: ConfirmOptions): Promise<boolean> => {\n return new Promise((resolve) => {\n setModalState({\n isOpen: true,\n type: 'confirm',\n title: options.title,\n message: options.message,\n confirmText: options.confirmText,\n cancelText: options.cancelText,\n destructive: options.destructive,\n resolve,\n });\n });\n }, []);\n\n const alert = useCallback((options: AlertOptions): Promise<void> => {\n return new Promise((resolve) => {\n setModalState({\n isOpen: true,\n type: 'alert',\n title: options.title,\n message: options.message,\n confirmText: options.confirmText,\n destructive: options.destructive,\n resolve,\n });\n });\n }, []);\n\n const handleClose = useCallback(() => {\n if (modalState?.resolve) {\n if (modalState.type === 'confirm') {\n (modalState.resolve as (value: boolean) => void)(false);\n } else {\n (modalState.resolve as () => void)();\n }\n }\n setModalState(null);\n }, [modalState]);\n\n const handleConfirm = useCallback(() => {\n if (modalState?.resolve) {\n if (modalState.type === 'confirm') {\n (modalState.resolve as (value: boolean) => void)(true);\n } else {\n (modalState.resolve as () => void)();\n }\n }\n setModalState(null);\n }, [modalState]);\n\n const contextValue: ActionModalContextValue = {\n confirm,\n alert,\n };\n\n return (\n <ActionModalContext.Provider value={contextValue}>\n {children}\n {modalState && modalState.type === 'alert' && (\n <ActionModal\n type='alert'\n isOpen={modalState.isOpen}\n onClose={handleClose}\n title={modalState.title}\n message={modalState.message}\n confirmText={modalState.confirmText}\n destructive={modalState.destructive}\n onConfirm={handleConfirm}\n className='bg-white dark:bg-gray-800 rounded-lg'\n />\n )}\n {modalState && modalState.type === 'confirm' && (\n <ActionModal\n type='confirm'\n isOpen={modalState.isOpen}\n onClose={handleClose}\n title={modalState.title}\n message={modalState.message}\n confirmText={modalState.confirmText}\n cancelText={modalState.cancelText}\n destructive={modalState.destructive}\n onConfirm={handleConfirm}\n className='bg-white dark:bg-gray-800 rounded-lg'\n />\n )}\n </ActionModalContext.Provider>\n );\n}\n","import { ReactNode, useCallback, useState } from 'react';\nimport { Toast, ToastData, ToastType } from '../components/toast';\nimport { AddToastOptions, ToastContextValue } from '../hooks/useToast';\nimport { ToastContext } from '../hooks/useToast';\nimport { join } from '../utils';\n\ninterface ToastProviderProps {\n children: ReactNode;\n customTypes?: Record<string, { className: string; icon?: ReactNode }>;\n customComponent?: React.ComponentType<ToastData>;\n position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';\n maxToasts?: number;\n}\n\nconst positionClasses = {\n 'top-right': 'top-4 right-4',\n 'top-left': 'top-4 left-4',\n 'bottom-right': 'bottom-4 right-4',\n 'bottom-left': 'bottom-4 left-4',\n 'top-center': 'top-4 left-1/2 -translate-x-1/2',\n 'bottom-center': 'bottom-4 left-1/2 -translate-x-1/2',\n};\n\nexport function ToastProvider({\n children,\n customTypes,\n customComponent,\n position = 'top-right',\n maxToasts = 5,\n}: ToastProviderProps) {\n const [toasts, setToasts] = useState<ToastData[]>([]);\n\n const addToast = useCallback(\n (options: AddToastOptions) => {\n const generatedId = `toast-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;\n const id = options.id || generatedId;\n\n const newToast: ToastData = {\n id,\n title: options.title,\n description: options.description,\n type: (options.type as ToastType) || 'info',\n action: options.action,\n duration: options.duration ?? 5000,\n };\n\n setToasts((prevToasts) => {\n const updatedToasts = [newToast, ...prevToasts];\n // Keep only the most recent toasts if we exceed maxToasts\n return updatedToasts.slice(0, maxToasts);\n });\n\n return id;\n },\n [maxToasts]\n );\n\n const removeToast = useCallback((id: string) => {\n setToasts((prevToasts) => prevToasts.filter((toast) => toast.id !== id));\n }, []);\n\n const contextValue: ToastContextValue = {\n addToast,\n removeToast,\n toasts,\n };\n\n return (\n <ToastContext.Provider value={contextValue}>\n {children}\n\n <div\n className={join('fixed z-50 pointer-events-none max-w-sm w-full space-y-2', positionClasses[position])}\n role='region'\n aria-label='Notifications'\n >\n {toasts.map((toast) => (\n <div key={toast.id} className='pointer-events-auto'>\n <Toast {...toast} onRemove={removeToast} customTypes={customTypes} customComponent={customComponent} />\n </div>\n ))}\n </div>\n </ToastContext.Provider>\n );\n}\n"],"names":["ActionModalProvider","children","modalState","setModalState","useState","confirm","useCallback","options","resolve","alert","handleClose","handleConfirm","contextValue","jsxs","ActionModalContext","jsx","ActionModal","positionClasses","ToastProvider","customTypes","customComponent","position","maxToasts","toasts","setToasts","addToast","generatedId","id","newToast","prevToasts","removeToast","toast","ToastContext","join","Toast"],"mappings":";;;;;;AAmCgB,SAAAA,EAAoB,EAAE,UAAAC,KAAqC;AACzE,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAkC,IAAI,GAEpEC,IAAUC,EAAY,CAACC,MACpB,IAAI,QAAQ,CAACC,MAAY;AAChB,IAAAL,EAAA;AAAA,MACZ,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,OAAOI,EAAQ;AAAA,MACf,SAASA,EAAQ;AAAA,MACjB,aAAaA,EAAQ;AAAA,MACrB,YAAYA,EAAQ;AAAA,MACpB,aAAaA,EAAQ;AAAA,MACrB,SAAAC;AAAA,IAAA,CACD;AAAA,EAAA,CACF,GACA,EAAE,GAECC,IAAQH,EAAY,CAACC,MAClB,IAAI,QAAQ,CAACC,MAAY;AAChB,IAAAL,EAAA;AAAA,MACZ,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,OAAOI,EAAQ;AAAA,MACf,SAASA,EAAQ;AAAA,MACjB,aAAaA,EAAQ;AAAA,MACrB,aAAaA,EAAQ;AAAA,MACrB,SAAAC;AAAA,IAAA,CACD;AAAA,EAAA,CACF,GACA,EAAE,GAECE,IAAcJ,EAAY,MAAM;AACpC,IAAIJ,KAAA,QAAAA,EAAY,YACVA,EAAW,SAAS,YACrBA,EAAW,QAAqC,EAAK,IAErDA,EAAW,QAAuB,IAGvCC,EAAc,IAAI;AAAA,E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EAEhB,CACD;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GACF;AAEJ;"}
1
+ {"version":3,"file":"providers.esm.js","sources":["../src/providers/ActionModalProvider.tsx","../src/providers/ToastProvider.tsx","../src/providers/ThemeProvider.tsx","../src/providers/DreamerUIProvider.tsx"],"sourcesContent":["import { ReactNode, useCallback, useState } from 'react';\nimport { ActionModal } from '../components';\nimport { ActionModalContext } from '../hooks';\n\nexport interface ConfirmOptions {\n /** The title displayed in the confirmation modal header */\n title?: string;\n /** The main message content displayed in the modal body */\n message: ReactNode;\n /** Text for the confirm/accept button. Defaults to \"Confirm\" */\n confirmText?: string;\n /** Text for the cancel/dismiss button. Defaults to \"Cancel\" */\n cancelText?: string;\n /** Whether the action is destructive, affects button styling */\n destructive?: boolean;\n}\n\nexport interface AlertOptions {\n /** The title displayed in the alert modal header */\n title?: string;\n /** The main message content displayed in the modal body */\n message: ReactNode;\n /** Text for the confirm/dismiss button. Defaults to \"OK\" */\n confirmText?: string;\n /** Whether the alert represents a destructive action, affects button styling */\n destructive?: boolean;\n}\n\nexport interface ActionModalContextValue {\n /** Shows a confirmation modal and returns a promise that resolves to true if confirmed, false if cancelled */\n confirm: (options: ConfirmOptions) => Promise<boolean>;\n /** Shows an alert modal and returns a promise that resolves when dismissed */\n alert: (options: AlertOptions) => Promise<void>;\n}\n\ninterface ActionModalState {\n isOpen: boolean;\n type: 'alert' | 'confirm';\n title?: string;\n message: ReactNode;\n confirmText?: string;\n cancelText?: string;\n destructive?: boolean;\n resolve?: ((value: boolean) => void) | (() => void);\n}\n\nexport function ActionModalProvider({ children }: { children: ReactNode }) {\n const [modalState, setModalState] = useState<ActionModalState | null>(null);\n\n const confirm = useCallback((options: ConfirmOptions): Promise<boolean> => {\n return new Promise((resolve) => {\n setModalState({\n isOpen: true,\n type: 'confirm',\n title: options.title,\n message: options.message,\n confirmText: options.confirmText,\n cancelText: options.cancelText,\n destructive: options.destructive,\n resolve,\n });\n });\n }, []);\n\n const alert = useCallback((options: AlertOptions): Promise<void> => {\n return new Promise((resolve) => {\n setModalState({\n isOpen: true,\n type: 'alert',\n title: options.title,\n message: options.message,\n confirmText: options.confirmText,\n destructive: options.destructive,\n resolve,\n });\n });\n }, []);\n\n const handleClose = useCallback(() => {\n if (modalState?.resolve) {\n if (modalState.type === 'confirm') {\n (modalState.resolve as (value: boolean) => void)(false);\n } else {\n (modalState.resolve as () => void)();\n }\n }\n setModalState(null);\n }, [modalState]);\n\n const handleConfirm = useCallback(() => {\n if (modalState?.resolve) {\n if (modalState.type === 'confirm') {\n (modalState.resolve as (value: boolean) => void)(true);\n } else {\n (modalState.resolve as () => void)();\n }\n }\n setModalState(null);\n }, [modalState]);\n\n const contextValue: ActionModalContextValue = {\n confirm,\n alert,\n };\n\n return (\n <ActionModalContext.Provider value={contextValue}>\n {children}\n {modalState && modalState.type === 'alert' && (\n <ActionModal\n type='alert'\n isOpen={modalState.isOpen}\n onClose={handleClose}\n title={modalState.title}\n message={modalState.message}\n confirmText={modalState.confirmText}\n destructive={modalState.destructive}\n onConfirm={handleConfirm}\n className='bg-white dark:bg-gray-800 rounded-lg'\n />\n )}\n {modalState && modalState.type === 'confirm' && (\n <ActionModal\n type='confirm'\n isOpen={modalState.isOpen}\n onClose={handleClose}\n title={modalState.title}\n message={modalState.message}\n confirmText={modalState.confirmText}\n cancelText={modalState.cancelText}\n destructive={modalState.destructive}\n onConfirm={handleConfirm}\n className='bg-white dark:bg-gray-800 rounded-lg'\n />\n )}\n </ActionModalContext.Provider>\n );\n}\n","import { ReactNode, useCallback, useState } from 'react';\nimport { Toast, ToastData, ToastType } from '../components/toast';\nimport { AddToastOptions, ToastContextValue } from '../hooks/useToast';\nimport { ToastContext } from '../hooks/useToast';\nimport { join } from '../utils';\n\nexport interface ToastProviderProps {\n /** React children to be wrapped by the toast provider */\n children: ReactNode;\n /** Custom toast types with their own styling and icons */\n customTypes?: Record<string, { className: string; icon?: ReactNode }>;\n /** Custom toast component to replace the default Toast component */\n customComponent?: React.ComponentType<ToastData>;\n /** Position where toasts should appear on screen */\n position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';\n /** Maximum number of toasts to display at once */\n maxToasts?: number;\n}\n\nconst positionClasses = {\n 'top-right': 'top-4 right-4',\n 'top-left': 'top-4 left-4',\n 'bottom-right': 'bottom-4 right-4',\n 'bottom-left': 'bottom-4 left-4',\n 'top-center': 'top-4 left-1/2 -translate-x-1/2',\n 'bottom-center': 'bottom-4 left-1/2 -translate-x-1/2',\n};\n\nexport function ToastProvider({\n children,\n customTypes,\n customComponent,\n position = 'top-right',\n maxToasts = 5,\n}: ToastProviderProps) {\n const [toasts, setToasts] = useState<ToastData[]>([]);\n\n const addToast = useCallback(\n (options: AddToastOptions) => {\n const generatedId = `toast-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;\n const id = options.id || generatedId;\n\n const newToast: ToastData = {\n id,\n title: options.title,\n description: options.description,\n type: (options.type as ToastType) || 'info',\n action: options.action,\n duration: options.duration ?? 5000,\n };\n\n setToasts((prevToasts) => {\n const updatedToasts = [newToast, ...prevToasts];\n // Keep only the most recent toasts if we exceed maxToasts\n return updatedToasts.slice(0, maxToasts);\n });\n\n return id;\n },\n [maxToasts]\n );\n\n const removeToast = useCallback((id: string) => {\n setToasts((prevToasts) => prevToasts.filter((toast) => toast.id !== id));\n }, []);\n\n const contextValue: ToastContextValue = {\n addToast,\n removeToast,\n toasts,\n };\n\n return (\n <ToastContext.Provider value={contextValue}>\n {children}\n\n <div\n className={join('fixed z-50 pointer-events-none max-w-sm w-full space-y-2', positionClasses[position])}\n role='region'\n aria-label='Notifications'\n >\n {toasts.map((toast) => (\n <div key={toast.id} className='pointer-events-auto'>\n <Toast {...toast} onRemove={removeToast} customTypes={customTypes} customComponent={customComponent} />\n </div>\n ))}\n </div>\n </ToastContext.Provider>\n );\n}\n","import { ReactNode, useCallback, useEffect, useState } from 'react';\nimport { Theme, ThemeContext, ThemeContextValue } from '../hooks/useTheme';\n\nexport interface ThemeProviderProps {\n /** React children to be wrapped by the theme provider */\n children: ReactNode;\n /** The default theme to use on first load. Defaults to 'system' */\n defaultTheme?: Theme;\n /** Local storage key used to persist the theme selection. Defaults to 'dreamer-ui-theme' */\n storageKey?: string;\n /** HTML attribute name to set on document root. Defaults to 'data-theme' */\n attribute?: string;\n /** Whether to respect system theme when theme is set to 'system'. Defaults to true */\n respectSystem?: boolean;\n}\n\nexport function ThemeProvider({\n children,\n defaultTheme = 'system',\n storageKey = 'dreamer-ui-theme',\n attribute = 'data-theme',\n respectSystem = true,\n}: ThemeProviderProps) {\n const [theme, setThemeState] = useState<Theme>(() => {\n if (typeof window === 'undefined') {\n return defaultTheme;\n }\n\n const stored = localStorage.getItem(storageKey);\n if (stored && ['light', 'dark', 'system'].includes(stored)) {\n return stored as Theme;\n }\n\n return defaultTheme;\n });\n\n const [resolvedTheme, setResolvedTheme] = useState<'light' | 'dark'>(() => {\n if (typeof window === 'undefined') {\n return 'light';\n }\n\n if (theme === 'system' && respectSystem) {\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n }\n\n return theme === 'dark' ? 'dark' : 'light';\n });\n\n const setTheme = useCallback(\n (newTheme: Theme) => {\n setThemeState(newTheme);\n if (typeof window !== 'undefined') {\n localStorage.setItem(storageKey, newTheme);\n }\n },\n [storageKey]\n );\n\n useEffect(() => {\n if (typeof window === 'undefined') return;\n\n const updateResolvedTheme = () => {\n if (theme === 'system' && respectSystem) {\n const systemTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n setResolvedTheme(systemTheme);\n } else {\n setResolvedTheme(theme === 'dark' ? 'dark' : 'light');\n }\n };\n\n updateResolvedTheme();\n\n if (theme === 'system' && respectSystem) {\n const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n mediaQuery.addEventListener('change', updateResolvedTheme);\n return () => mediaQuery.removeEventListener('change', updateResolvedTheme);\n }\n }, [theme, respectSystem]);\n\n useEffect(() => {\n if (typeof window === 'undefined') return;\n\n const root = document.documentElement;\n root.setAttribute(attribute, resolvedTheme);\n \n // Also set class for Tailwind dark mode\n if (resolvedTheme === 'dark') {\n root.classList.add('dark');\n } else {\n root.classList.remove('dark');\n }\n }, [resolvedTheme, attribute]);\n\n const contextValue: ThemeContextValue = {\n theme,\n setTheme,\n resolvedTheme,\n };\n\n return <ThemeContext.Provider value={contextValue}>{children}</ThemeContext.Provider>;\n}","import { ReactNode } from 'react';\nimport { ActionModalProvider } from './ActionModalProvider';\nimport { ThemeProvider, ThemeProviderProps } from './ThemeProvider';\nimport { ToastProvider, ToastProviderProps } from './ToastProvider';\n\nexport interface DreamerUIProviderProps {\n\t/** React children to be wrapped by all DreamerUI providers */\n\tchildren: ReactNode;\n\t/** Configuration options for the ThemeProvider */\n\ttheme?: Omit<ThemeProviderProps, 'children'>;\n\t/** Configuration options for the ToastProvider */\n\ttoast?: Omit<ToastProviderProps, 'children'>;\n}\n\nexport function DreamerUIProvider({ children, theme = {}, toast = {} }: DreamerUIProviderProps) {\n\treturn (\n\t\t<ThemeProvider {...theme}>\n\t\t\t<ToastProvider {...toast}>\n\t\t\t\t<ActionModalProvider>{children}</ActionModalProvider>\n\t\t\t</ToastProvider>\n\t\t</ThemeProvider>\n\t);\n}\n"],"names":["ActionModalProvider","children","modalState","setModalState","useState","confirm","useCallback","options","resolve","alert","handleClose","handleConfirm","contextValue","jsxs","ActionModalContext","jsx","ActionModal","positionClasses","ToastProvider","customTypes","customComponent","position","maxToasts","toasts","setToasts","addToast","generatedId","id","newToast","prevToasts","removeToast","toast","ToastContext","join","Toast","ThemeProvider","defaultTheme","storageKey","attribute","respectSystem","theme","setThemeState","stored","resolvedTheme","setResolvedTheme","setTheme","newTheme","useEffect","updateResolvedTheme","systemTheme","mediaQuery","root","ThemeContext","DreamerUIProvider"],"mappings":";;;;;;AA8CgB,SAAAA,EAAoB,EAAE,UAAAC,KAAqC;AACzE,QAAM,CAACC,GAAYC,CAAa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AU,OAAAuC,IAAQ,CAAA,GAAI,OAAAT,IAAQ,CAAA,KAA8B;AAC/F,SACE,gBAAAhB,EAAAoB,GAAA,EAAe,GAAGK,GAClB,UAAC,gBAAAzB,EAAAG,GAAA,EAAe,GAAGa,GAClB,UAAC,gBAAAhB,EAAAf,GAAA,EAAqB,UAAAC,EAAS,CAAA,EAChC,CAAA,GACD;AAEF;"}
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import { PanelSize } from './variants';
3
2
  export interface PanelProps {
4
3
  ref?: React.Ref<HTMLDivElement>;
5
4
  /** Unique identifier for the panel */
@@ -14,8 +13,6 @@ export interface PanelProps {
14
13
  children: React.ReactNode;
15
14
  /** Panel footer - can be a string or React node */
16
15
  footer?: React.ReactNode;
17
- /** Panel size variant */
18
- size?: PanelSize;
19
16
  /** Additional CSS classes for the panel */
20
17
  className?: string;
21
18
  /** Additional CSS classes for the overlay */
@@ -33,4 +30,4 @@ export interface PanelProps {
33
30
  * Panel component that slides in from the right side of the screen.
34
31
  * Provides an overlay and slide-in animation for side content display.
35
32
  */
36
- export declare function Panel({ ref, id, isOpen, onClose, title, children, footer, size, className, overlayClassName, hideCloseButton, disableCloseOnOverlayClick, ariaLabelledBy, ariaDescribedBy, }: PanelProps): import("react/jsx-runtime").JSX.Element | null;
33
+ export declare function Panel({ ref, id, isOpen, onClose, title, children, footer, className, overlayClassName, hideCloseButton, disableCloseOnOverlayClick, ariaLabelledBy, ariaDescribedBy, }: PanelProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,3 +1,4 @@
1
1
  export { ActionModalContext, useActionModal } from './useActionModal';
2
2
  export { useScreenSize, type ScreenSize, type ScreenSizeBreakpoints } from './useScreenSize';
3
3
  export { useToast, type AddToastOptions, type ToastContextValue } from './useToast';
4
+ export { useTheme, ThemeContext, type Theme, type ThemeContextValue } from './useTheme';
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export type Theme = 'light' | 'dark' | 'system';
3
+ export interface ThemeContextValue {
4
+ theme: Theme;
5
+ setTheme: (theme: Theme) => void;
6
+ resolvedTheme: 'light' | 'dark';
7
+ }
8
+ export declare const ThemeContext: import("react").Context<ThemeContextValue | undefined>;
9
+ export declare function useTheme(): ThemeContextValue;
@@ -1,19 +1,30 @@
1
1
  import { ReactNode } from 'react';
2
2
  export interface ConfirmOptions {
3
+ /** The title displayed in the confirmation modal header */
3
4
  title?: string;
5
+ /** The main message content displayed in the modal body */
4
6
  message: ReactNode;
7
+ /** Text for the confirm/accept button. Defaults to "Confirm" */
5
8
  confirmText?: string;
9
+ /** Text for the cancel/dismiss button. Defaults to "Cancel" */
6
10
  cancelText?: string;
11
+ /** Whether the action is destructive, affects button styling */
7
12
  destructive?: boolean;
8
13
  }
9
14
  export interface AlertOptions {
15
+ /** The title displayed in the alert modal header */
10
16
  title?: string;
17
+ /** The main message content displayed in the modal body */
11
18
  message: ReactNode;
19
+ /** Text for the confirm/dismiss button. Defaults to "OK" */
12
20
  confirmText?: string;
21
+ /** Whether the alert represents a destructive action, affects button styling */
13
22
  destructive?: boolean;
14
23
  }
15
24
  export interface ActionModalContextValue {
25
+ /** Shows a confirmation modal and returns a promise that resolves to true if confirmed, false if cancelled */
16
26
  confirm: (options: ConfirmOptions) => Promise<boolean>;
27
+ /** Shows an alert modal and returns a promise that resolves when dismissed */
17
28
  alert: (options: AlertOptions) => Promise<void>;
18
29
  }
19
30
  export declare function ActionModalProvider({ children }: {
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ import { ThemeProviderProps } from './ThemeProvider';
3
+ import { ToastProviderProps } from './ToastProvider';
4
+ export interface DreamerUIProviderProps {
5
+ /** React children to be wrapped by all DreamerUI providers */
6
+ children: ReactNode;
7
+ /** Configuration options for the ThemeProvider */
8
+ theme?: Omit<ThemeProviderProps, 'children'>;
9
+ /** Configuration options for the ToastProvider */
10
+ toast?: Omit<ToastProviderProps, 'children'>;
11
+ }
12
+ export declare function DreamerUIProvider({ children, theme, toast }: DreamerUIProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+ import { Theme } from '../hooks/useTheme';
3
+ export interface ThemeProviderProps {
4
+ /** React children to be wrapped by the theme provider */
5
+ children: ReactNode;
6
+ /** The default theme to use on first load. Defaults to 'system' */
7
+ defaultTheme?: Theme;
8
+ /** Local storage key used to persist the theme selection. Defaults to 'dreamer-ui-theme' */
9
+ storageKey?: string;
10
+ /** HTML attribute name to set on document root. Defaults to 'data-theme' */
11
+ attribute?: string;
12
+ /** Whether to respect system theme when theme is set to 'system'. Defaults to true */
13
+ respectSystem?: boolean;
14
+ }
15
+ export declare function ThemeProvider({ children, defaultTheme, storageKey, attribute, respectSystem, }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -1,14 +1,18 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { ToastData } from '../components/toast';
3
- interface ToastProviderProps {
3
+ export interface ToastProviderProps {
4
+ /** React children to be wrapped by the toast provider */
4
5
  children: ReactNode;
6
+ /** Custom toast types with their own styling and icons */
5
7
  customTypes?: Record<string, {
6
8
  className: string;
7
9
  icon?: ReactNode;
8
10
  }>;
11
+ /** Custom toast component to replace the default Toast component */
9
12
  customComponent?: React.ComponentType<ToastData>;
13
+ /** Position where toasts should appear on screen */
10
14
  position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
15
+ /** Maximum number of toasts to display at once */
11
16
  maxToasts?: number;
12
17
  }
13
18
  export declare function ToastProvider({ children, customTypes, customComponent, position, maxToasts, }: ToastProviderProps): import("react/jsx-runtime").JSX.Element;
14
- export {};
@@ -1,2 +1,4 @@
1
1
  export { ActionModalProvider, type ActionModalContextValue, type AlertOptions, type ConfirmOptions, } from './ActionModalProvider';
2
- export { ToastProvider } from './ToastProvider';
2
+ export { ToastProvider, type ToastProviderProps } from './ToastProvider';
3
+ export { ThemeProvider, type ThemeProviderProps } from './ThemeProvider';
4
+ export { DreamerUIProvider, type DreamerUIProviderProps } from './DreamerUIProvider';
@@ -0,0 +1,2 @@
1
+ "use strict";const e=require("react"),o=e.createContext(void 0);function r(){const t=e.useContext(o);if(!t)throw new Error("useActionModal must be used within an ActionModalProvider");return t}const n=e.createContext(void 0);function i(){const t=e.useContext(n);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const s=e.createContext(void 0);function u(){const t=e.useContext(s);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t}exports.ActionModalContext=o;exports.ThemeContext=s;exports.ToastContext=n;exports.useActionModal=r;exports.useTheme=u;exports.useToast=i;
2
+ //# sourceMappingURL=useTheme-Bdg1t0Zr.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTheme-Bdg1t0Zr.cjs","sources":["../src/hooks/useActionModal.ts","../src/hooks/useToast.ts","../src/hooks/useTheme.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport { ActionModalContextValue } from '../providers';\n\nexport const ActionModalContext = createContext<ActionModalContextValue | undefined>(undefined);\n\nexport function useActionModal(): ActionModalContextValue {\n const context = useContext(ActionModalContext);\n if (!context) {\n throw new Error('useActionModal must be used within an ActionModalProvider');\n }\n return context;\n}\n","import { createContext, useContext } from 'react';\nimport { ToastAction, ToastData, ToastType } from '../components/toast';\n\nexport interface AddToastOptions {\n id?: string;\n title: string;\n description?: string;\n type?: ToastType | string;\n action?: ToastAction;\n duration?: number;\n}\n\nexport interface ToastContextValue {\n addToast: (options: AddToastOptions) => string;\n removeToast: (id: string) => void;\n toasts: ToastData[];\n}\n\nexport const ToastContext = createContext<ToastContextValue | undefined>(undefined);\n\nexport function useToast(): ToastContextValue {\n const context = useContext(ToastContext);\n if (!context) {\n throw new Error('useToast must be used within a ToastProvider');\n }\n return context;\n}\n","import { createContext, useContext } from 'react';\n\nexport type Theme = 'light' | 'dark' | 'system';\n\nexport interface ThemeContextValue {\n theme: Theme;\n setTheme: (theme: Theme) => void;\n resolvedTheme: 'light' | 'dark';\n}\n\nexport const ThemeContext = createContext<ThemeContextValue | undefined>(undefined);\n\nexport function useTheme(): ThemeContextValue {\n const context = useContext(ThemeContext);\n if (!context) {\n throw new Error('useTheme must be used within a ThemeProvider');\n }\n return context;\n}"],"names":["ActionModalContext","createContext","useActionModal","context","useContext","ToastContext","useToast","ThemeContext","useTheme"],"mappings":"sCAGaA,EAAqBC,gBAAmD,MAAS,EAEvF,SAASC,GAA0C,CAClD,MAAAC,EAAUC,aAAWJ,CAAkB,EAC7C,GAAI,CAACG,EACG,MAAA,IAAI,MAAM,2DAA2D,EAEtE,OAAAA,CACT,CCOa,MAAAE,EAAeJ,gBAA6C,MAAS,EAE3E,SAASK,GAA8B,CACtC,MAAAH,EAAUC,aAAWC,CAAY,EACvC,GAAI,CAACF,EACG,MAAA,IAAI,MAAM,8CAA8C,EAEzD,OAAAA,CACT,CChBa,MAAAI,EAAeN,gBAA6C,MAAS,EAE3E,SAASO,GAA8B,CACtC,MAAAL,EAAUC,aAAWG,CAAY,EACvC,GAAI,CAACJ,EACG,MAAA,IAAI,MAAM,8CAA8C,EAEzD,OAAAA,CACT"}
@@ -0,0 +1,31 @@
1
+ import { createContext as o, useContext as e } from "react";
2
+ const n = o(void 0);
3
+ function u() {
4
+ const t = e(n);
5
+ if (!t)
6
+ throw new Error("useActionModal must be used within an ActionModalProvider");
7
+ return t;
8
+ }
9
+ const s = o(void 0);
10
+ function a() {
11
+ const t = e(s);
12
+ if (!t)
13
+ throw new Error("useToast must be used within a ToastProvider");
14
+ return t;
15
+ }
16
+ const r = o(void 0);
17
+ function c() {
18
+ const t = e(r);
19
+ if (!t)
20
+ throw new Error("useTheme must be used within a ThemeProvider");
21
+ return t;
22
+ }
23
+ export {
24
+ n as A,
25
+ r as T,
26
+ a,
27
+ c as b,
28
+ s as c,
29
+ u
30
+ };
31
+ //# sourceMappingURL=useTheme-CYIEopvl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTheme-CYIEopvl.js","sources":["../src/hooks/useActionModal.ts","../src/hooks/useToast.ts","../src/hooks/useTheme.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport { ActionModalContextValue } from '../providers';\n\nexport const ActionModalContext = createContext<ActionModalContextValue | undefined>(undefined);\n\nexport function useActionModal(): ActionModalContextValue {\n const context = useContext(ActionModalContext);\n if (!context) {\n throw new Error('useActionModal must be used within an ActionModalProvider');\n }\n return context;\n}\n","import { createContext, useContext } from 'react';\nimport { ToastAction, ToastData, ToastType } from '../components/toast';\n\nexport interface AddToastOptions {\n id?: string;\n title: string;\n description?: string;\n type?: ToastType | string;\n action?: ToastAction;\n duration?: number;\n}\n\nexport interface ToastContextValue {\n addToast: (options: AddToastOptions) => string;\n removeToast: (id: string) => void;\n toasts: ToastData[];\n}\n\nexport const ToastContext = createContext<ToastContextValue | undefined>(undefined);\n\nexport function useToast(): ToastContextValue {\n const context = useContext(ToastContext);\n if (!context) {\n throw new Error('useToast must be used within a ToastProvider');\n }\n return context;\n}\n","import { createContext, useContext } from 'react';\n\nexport type Theme = 'light' | 'dark' | 'system';\n\nexport interface ThemeContextValue {\n theme: Theme;\n setTheme: (theme: Theme) => void;\n resolvedTheme: 'light' | 'dark';\n}\n\nexport const ThemeContext = createContext<ThemeContextValue | undefined>(undefined);\n\nexport function useTheme(): ThemeContextValue {\n const context = useContext(ThemeContext);\n if (!context) {\n throw new Error('useTheme must be used within a ThemeProvider');\n }\n return context;\n}"],"names":["ActionModalContext","createContext","useActionModal","context","useContext","ToastContext","useToast","ThemeContext","useTheme"],"mappings":";AAGa,MAAAA,IAAqBC,EAAmD,MAAS;AAEvF,SAASC,IAA0C;AAClD,QAAAC,IAAUC,EAAWJ,CAAkB;AAC7C,MAAI,CAACG;AACG,UAAA,IAAI,MAAM,2DAA2D;AAEtE,SAAAA;AACT;ACOa,MAAAE,IAAeJ,EAA6C,MAAS;AAE3E,SAASK,IAA8B;AACtC,QAAAH,IAAUC,EAAWC,CAAY;AACvC,MAAI,CAACF;AACG,UAAA,IAAI,MAAM,8CAA8C;AAEzD,SAAAA;AACT;AChBa,MAAAI,IAAeN,EAA6C,MAAS;AAE3E,SAASO,IAA8B;AACtC,QAAAL,IAAUC,EAAWG,CAAY;AACvC,MAAI,CAACJ;AACG,UAAA,IAAI,MAAM,8CAA8C;AAEzD,SAAAA;AACT;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moondreamsdev/dreamer-ui",
3
- "version": "1.7.12",
3
+ "version": "1.7.13",
4
4
  "homepage": "https://ui.moondreams.dev",
5
5
  "publishConfig": {
6
6
  "access": "public"