@moondreamsdev/dreamer-ui 1.7.13 → 1.7.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Toast-BJPMjPG-.cjs → Toast-D3CxHQiE.cjs} +2 -2
- package/dist/Toast-D3CxHQiE.cjs.map +1 -0
- package/dist/{Toast-DXhZLxdl.js → Toast-hLOCCnKb.js} +17 -12
- package/dist/Toast-hLOCCnKb.js.map +1 -0
- package/dist/components.cjs.js +2 -2
- package/dist/components.esm.js +62 -62
- package/dist/providers.cjs.js +1 -1
- package/dist/providers.cjs.js.map +1 -1
- package/dist/providers.esm.js +64 -61
- package/dist/providers.esm.js.map +1 -1
- package/dist/src/hooks/useTheme.d.ts +5 -0
- package/dist/useTheme-Bdg1t0Zr.cjs.map +1 -1
- package/dist/useTheme-CYIEopvl.js.map +1 -1
- package/package.json +1 -1
- package/dist/Toast-BJPMjPG-.cjs.map +0 -1
- package/dist/Toast-DXhZLxdl.js.map +0 -1
package/dist/providers.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as v, useCallback as
|
|
3
|
-
import { A as
|
|
1
|
+
import { jsxs as w, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useState as v, useCallback as d, useEffect as p } from "react";
|
|
3
|
+
import { A as T, T as y } from "./Toast-hLOCCnKb.js";
|
|
4
4
|
import { A as k, c as b, T as C } from "./useTheme-CYIEopvl.js";
|
|
5
5
|
import "react-dom";
|
|
6
6
|
import { j as P } from "./join-BmgR_f4v.js";
|
|
7
|
-
function M({ children:
|
|
8
|
-
const [e, i] = v(null),
|
|
7
|
+
function M({ children: m }) {
|
|
8
|
+
const [e, i] = v(null), u = d((r) => new Promise((c) => {
|
|
9
9
|
i({
|
|
10
10
|
isOpen: !0,
|
|
11
11
|
type: "confirm",
|
|
@@ -14,9 +14,9 @@ function M({ children: l }) {
|
|
|
14
14
|
confirmText: r.confirmText,
|
|
15
15
|
cancelText: r.cancelText,
|
|
16
16
|
destructive: r.destructive,
|
|
17
|
-
resolve:
|
|
17
|
+
resolve: c
|
|
18
18
|
});
|
|
19
|
-
}), []),
|
|
19
|
+
}), []), a = d((r) => new Promise((c) => {
|
|
20
20
|
i({
|
|
21
21
|
isOpen: !0,
|
|
22
22
|
type: "alert",
|
|
@@ -24,20 +24,20 @@ function M({ children: l }) {
|
|
|
24
24
|
message: r.message,
|
|
25
25
|
confirmText: r.confirmText,
|
|
26
26
|
destructive: r.destructive,
|
|
27
|
-
resolve:
|
|
27
|
+
resolve: c
|
|
28
28
|
});
|
|
29
|
-
}), []), o =
|
|
29
|
+
}), []), o = d(() => {
|
|
30
30
|
e != null && e.resolve && (e.type === "confirm" ? e.resolve(!1) : e.resolve()), i(null);
|
|
31
|
-
}, [e]),
|
|
31
|
+
}, [e]), f = d(() => {
|
|
32
32
|
e != null && e.resolve && (e.type === "confirm" ? e.resolve(!0) : e.resolve()), i(null);
|
|
33
|
-
}, [e]),
|
|
34
|
-
confirm:
|
|
35
|
-
alert:
|
|
33
|
+
}, [e]), s = {
|
|
34
|
+
confirm: u,
|
|
35
|
+
alert: a
|
|
36
36
|
};
|
|
37
|
-
return /* @__PURE__ */
|
|
38
|
-
|
|
39
|
-
e && e.type === "alert" && /* @__PURE__ */
|
|
40
|
-
|
|
37
|
+
return /* @__PURE__ */ w(k.Provider, { value: s, children: [
|
|
38
|
+
m,
|
|
39
|
+
e && e.type === "alert" && /* @__PURE__ */ l(
|
|
40
|
+
T,
|
|
41
41
|
{
|
|
42
42
|
type: "alert",
|
|
43
43
|
isOpen: e.isOpen,
|
|
@@ -46,12 +46,12 @@ function M({ children: l }) {
|
|
|
46
46
|
message: e.message,
|
|
47
47
|
confirmText: e.confirmText,
|
|
48
48
|
destructive: e.destructive,
|
|
49
|
-
onConfirm:
|
|
49
|
+
onConfirm: f,
|
|
50
50
|
className: "bg-white dark:bg-gray-800 rounded-lg"
|
|
51
51
|
}
|
|
52
52
|
),
|
|
53
|
-
e && e.type === "confirm" && /* @__PURE__ */
|
|
54
|
-
|
|
53
|
+
e && e.type === "confirm" && /* @__PURE__ */ l(
|
|
54
|
+
T,
|
|
55
55
|
{
|
|
56
56
|
type: "confirm",
|
|
57
57
|
isOpen: e.isOpen,
|
|
@@ -61,7 +61,7 @@ function M({ children: l }) {
|
|
|
61
61
|
confirmText: e.confirmText,
|
|
62
62
|
cancelText: e.cancelText,
|
|
63
63
|
destructive: e.destructive,
|
|
64
|
-
onConfirm:
|
|
64
|
+
onConfirm: f,
|
|
65
65
|
className: "bg-white dark:bg-gray-800 rounded-lg"
|
|
66
66
|
}
|
|
67
67
|
)
|
|
@@ -76,90 +76,93 @@ const A = {
|
|
|
76
76
|
"bottom-center": "bottom-4 left-1/2 -translate-x-1/2"
|
|
77
77
|
};
|
|
78
78
|
function O({
|
|
79
|
-
children:
|
|
79
|
+
children: m,
|
|
80
80
|
customTypes: e,
|
|
81
81
|
customComponent: i,
|
|
82
|
-
position:
|
|
83
|
-
maxToasts:
|
|
82
|
+
position: u = "top-right",
|
|
83
|
+
maxToasts: a = 5
|
|
84
84
|
}) {
|
|
85
|
-
const [o,
|
|
85
|
+
const [o, f] = v([]), s = d(
|
|
86
86
|
(n) => {
|
|
87
|
-
const
|
|
88
|
-
id:
|
|
87
|
+
const g = `toast-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, t = n.id || g, h = {
|
|
88
|
+
id: t,
|
|
89
89
|
title: n.title,
|
|
90
90
|
description: n.description,
|
|
91
91
|
type: n.type || "info",
|
|
92
92
|
action: n.action,
|
|
93
93
|
duration: n.duration ?? 5e3
|
|
94
94
|
};
|
|
95
|
-
return
|
|
95
|
+
return f((x) => [h, ...x].slice(0, a)), t;
|
|
96
96
|
},
|
|
97
|
-
[
|
|
98
|
-
), r =
|
|
99
|
-
|
|
100
|
-
}, []),
|
|
101
|
-
addToast:
|
|
97
|
+
[a]
|
|
98
|
+
), r = d((n) => {
|
|
99
|
+
f((g) => g.filter((t) => t.id !== n));
|
|
100
|
+
}, []), c = {
|
|
101
|
+
addToast: s,
|
|
102
102
|
removeToast: r,
|
|
103
103
|
toasts: o
|
|
104
104
|
};
|
|
105
|
-
return /* @__PURE__ */
|
|
106
|
-
|
|
107
|
-
/* @__PURE__ */
|
|
105
|
+
return /* @__PURE__ */ w(b.Provider, { value: c, children: [
|
|
106
|
+
m,
|
|
107
|
+
/* @__PURE__ */ l(
|
|
108
108
|
"div",
|
|
109
109
|
{
|
|
110
|
-
className: P("fixed z-50 pointer-events-none max-w-sm w-full space-y-2", A[
|
|
110
|
+
className: P("fixed z-50 pointer-events-none max-w-sm w-full space-y-2", A[u]),
|
|
111
111
|
role: "region",
|
|
112
112
|
"aria-label": "Notifications",
|
|
113
|
-
children: o.map((n) => /* @__PURE__ */
|
|
113
|
+
children: o.map((n) => /* @__PURE__ */ l("div", { className: "pointer-events-auto", children: /* @__PURE__ */ l(y, { ...n, onRemove: r, customTypes: e, customComponent: i }) }, n.id))
|
|
114
114
|
}
|
|
115
115
|
)
|
|
116
116
|
] });
|
|
117
117
|
}
|
|
118
118
|
function N({
|
|
119
|
-
children:
|
|
119
|
+
children: m,
|
|
120
120
|
defaultTheme: e = "system",
|
|
121
121
|
storageKey: i = "dreamer-ui-theme",
|
|
122
|
-
attribute:
|
|
123
|
-
respectSystem:
|
|
122
|
+
attribute: u = "data-theme",
|
|
123
|
+
respectSystem: a = !0
|
|
124
124
|
}) {
|
|
125
|
-
const [o,
|
|
125
|
+
const [o, f] = v(() => {
|
|
126
126
|
if (typeof window > "u")
|
|
127
127
|
return e;
|
|
128
128
|
const t = localStorage.getItem(i);
|
|
129
129
|
return t && ["light", "dark", "system"].includes(t) ? t : e;
|
|
130
|
-
}), [
|
|
130
|
+
}), [s, r] = v(() => typeof window > "u" ? "light" : o === "system" && a ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : o === "dark" ? "dark" : "light"), c = d(
|
|
131
131
|
(t) => {
|
|
132
|
-
|
|
132
|
+
f(t), typeof window < "u" && localStorage.setItem(i, t);
|
|
133
133
|
},
|
|
134
134
|
[i]
|
|
135
|
-
)
|
|
136
|
-
|
|
135
|
+
), n = d(() => {
|
|
136
|
+
c(s === "light" ? "dark" : "light");
|
|
137
|
+
}, [s, c]);
|
|
138
|
+
p(() => {
|
|
137
139
|
if (typeof window > "u") return;
|
|
138
140
|
const t = () => {
|
|
139
|
-
if (o === "system" &&
|
|
140
|
-
const
|
|
141
|
-
r(
|
|
141
|
+
if (o === "system" && a) {
|
|
142
|
+
const h = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
143
|
+
r(h);
|
|
142
144
|
} else
|
|
143
145
|
r(o === "dark" ? "dark" : "light");
|
|
144
146
|
};
|
|
145
|
-
if (t(), o === "system" &&
|
|
146
|
-
const
|
|
147
|
-
return
|
|
147
|
+
if (t(), o === "system" && a) {
|
|
148
|
+
const h = window.matchMedia("(prefers-color-scheme: dark)");
|
|
149
|
+
return h.addEventListener("change", t), () => h.removeEventListener("change", t);
|
|
148
150
|
}
|
|
149
|
-
}, [o,
|
|
151
|
+
}, [o, a]), p(() => {
|
|
150
152
|
if (typeof window > "u") return;
|
|
151
153
|
const t = document.documentElement;
|
|
152
|
-
t.setAttribute(
|
|
153
|
-
}, [
|
|
154
|
-
const
|
|
154
|
+
t.setAttribute(u, s), s === "dark" ? t.classList.add("dark") : t.classList.remove("dark");
|
|
155
|
+
}, [s, u]);
|
|
156
|
+
const g = {
|
|
155
157
|
theme: o,
|
|
156
|
-
setTheme:
|
|
157
|
-
resolvedTheme:
|
|
158
|
+
setTheme: c,
|
|
159
|
+
resolvedTheme: s,
|
|
160
|
+
toggleTheme: n
|
|
158
161
|
};
|
|
159
|
-
return /* @__PURE__ */
|
|
162
|
+
return /* @__PURE__ */ l(C.Provider, { value: g, children: m });
|
|
160
163
|
}
|
|
161
|
-
function $({ children:
|
|
162
|
-
return /* @__PURE__ */
|
|
164
|
+
function $({ children: m, theme: e = {}, toast: i = {} }) {
|
|
165
|
+
return /* @__PURE__ */ l(N, { ...e, children: /* @__PURE__ */ l(O, { ...i, children: /* @__PURE__ */ l(M, { children: m }) }) });
|
|
163
166
|
}
|
|
164
167
|
export {
|
|
165
168
|
M as ActionModalProvider,
|
|
@@ -1 +1 @@
|
|
|
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,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,EAAA,GACjB,CAACD,CAAU,CAAC,GAETS,IAAgBL,EAAY,MAAM;AACtC,IAAIJ,KAAA,QAAAA,EAAY,YACVA,EAAW,SAAS,YACrBA,EAAW,QAAqC,EAAI,IAEpDA,EAAW,QAAuB,IAGvCC,EAAc,IAAI;AAAA,EAAA,GACjB,CAACD,CAAU,CAAC,GAETU,IAAwC;AAAA,IAC5C,SAAAP;AAAA,IACA,OAAAI;AAAA,EACF;AAEA,SACG,gBAAAI,EAAAC,EAAmB,UAAnB,EA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AAAA,IACA,UAAAK;AAAA,IACA,eAAAF;AAAA,EACF;AAEA,2BAAQS,EAAa,UAAb,EAAsB,OAAOxC,GAAe,UAAAX,GAAS;AAC/D;ACtFgB,SAAAoD,EAAkB,EAAE,UAAApD,GAAU,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
|
+
{"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 const toggleTheme = useCallback(() => {\n const newTheme = resolvedTheme === 'light' ? 'dark' : 'light';\n setTheme(newTheme);\n }, [resolvedTheme, setTheme]);\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 toggleTheme,\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","toggleTheme","useEffect","updateResolvedTheme","systemTheme","mediaQuery","root","ThemeContext","DreamerUIProvider"],"mappings":";;;;;;AA8CgB,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,EAAA,GACjB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BAA8B;AACxD,aAAAA,EAAA,iBAAiB,UAAUF,CAAmB,GAClD,MAAME,EAAW,oBAAoB,UAAUF,CAAmB;AAAA,IAAA;AAAA,EAC3E,GACC,CAACT,GAAOD,CAAa,CAAC,GAEzBS,EAAU,MAAM;AACV,QAAA,OAAO,SAAW,IAAa;AAEnC,UAAMI,IAAO,SAAS;AACjB,IAAAA,EAAA,aAAad,GAAWK,CAAa,GAGtCA,MAAkB,SACfS,EAAA,UAAU,IAAI,MAAM,IAEpBA,EAAA,UAAU,OAAO,MAAM;AAAA,EAC9B,GACC,CAACT,GAAeL,CAAS,CAAC;AAE7B,QAAM1B,IAAkC;AAAA,IACtC,OAAA4B;AAAA,IACA,UAAAK;AAAA,IACA,eAAAF;AAAA,IACA,aAAAI;AAAA,EACF;AAEA,2BAAQM,EAAa,UAAb,EAAsB,OAAOzC,GAAe,UAAAX,GAAS;AAC/D;AC5FgB,SAAAqD,EAAkB,EAAE,UAAArD,GAAU,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,9 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export type Theme = 'light' | 'dark' | 'system';
|
|
3
3
|
export interface ThemeContextValue {
|
|
4
|
+
/** Current theme setting (can be 'light', 'dark', or 'system') */
|
|
4
5
|
theme: Theme;
|
|
6
|
+
/** Function to change the current theme */
|
|
5
7
|
setTheme: (theme: Theme) => void;
|
|
8
|
+
/** Resolved theme after system preference detection (always 'light' or 'dark') */
|
|
6
9
|
resolvedTheme: 'light' | 'dark';
|
|
10
|
+
/** Function to toggle between light and dark themes */
|
|
11
|
+
toggleTheme: () => void;
|
|
7
12
|
}
|
|
8
13
|
export declare const ThemeContext: import("react").Context<ThemeContextValue | undefined>;
|
|
9
14
|
export declare function useTheme(): ThemeContextValue;
|
|
@@ -1 +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,
|
|
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 /** Current theme setting (can be 'light', 'dark', or 'system') */\n theme: Theme;\n /** Function to change the current theme */\n setTheme: (theme: Theme) => void;\n /** Resolved theme after system preference detection (always 'light' or 'dark') */\n resolvedTheme: 'light' | 'dark';\n /** Function to toggle between light and dark themes */\n toggleTheme: () => void;\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,CCXa,MAAAI,EAAeN,gBAA6C,MAAS,EAE3E,SAASO,GAA8B,CACtC,MAAAL,EAAUC,aAAWG,CAAY,EACvC,GAAI,CAACJ,EACG,MAAA,IAAI,MAAM,8CAA8C,EAEzD,OAAAA,CACT"}
|
|
@@ -1 +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;
|
|
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 /** Current theme setting (can be 'light', 'dark', or 'system') */\n theme: Theme;\n /** Function to change the current theme */\n setTheme: (theme: Theme) => void;\n /** Resolved theme after system preference detection (always 'light' or 'dark') */\n resolvedTheme: 'light' | 'dark';\n /** Function to toggle between light and dark themes */\n toggleTheme: () => void;\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;ACXa,MAAAI,IAAeN,EAA6C,MAAS;AAE3E,SAASO,IAA8B;AACtC,QAAAL,IAAUC,EAAWG,CAAY;AACvC,MAAI,CAACJ;AACG,UAAA,IAAI,MAAM,8CAA8C;AAEzD,SAAAA;AACT;"}
|