@vritti/quantum-ui 0.2.6 → 0.2.8
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/Avatar.js +219 -0
- package/dist/Avatar.js.map +1 -0
- package/dist/Badge.js +32 -0
- package/dist/Badge.js.map +1 -0
- package/dist/Button2.js +2 -2
- package/dist/Chart.js +19003 -0
- package/dist/Chart.js.map +1 -0
- package/dist/Checkbox.js +6 -26
- package/dist/Checkbox.js.map +1 -1
- package/dist/Combination.js +3868 -0
- package/dist/Combination.js.map +1 -0
- package/dist/DatePicker.js +15 -3877
- package/dist/DatePicker.js.map +1 -1
- package/dist/DropdownMenu.js +1591 -0
- package/dist/DropdownMenu.js.map +1 -0
- package/dist/Form.js +7 -4
- package/dist/Form.js.map +1 -1
- package/dist/Label.js +1 -1
- package/dist/OTPField.js +16 -5
- package/dist/OTPField.js.map +1 -1
- package/dist/PasswordField.js +1 -14
- package/dist/PasswordField.js.map +1 -1
- package/dist/PhoneField.js +14 -6
- package/dist/PhoneField.js.map +1 -1
- package/dist/Progress.js +116 -0
- package/dist/Progress.js.map +1 -0
- package/dist/Separator.js +6 -0
- package/dist/Separator.js.map +1 -0
- package/dist/Sonner.js +1249 -0
- package/dist/Sonner.js.map +1 -0
- package/dist/Spinner.js +2 -21
- package/dist/Spinner.js.map +1 -1
- package/dist/Switch.js +210 -0
- package/dist/Switch.js.map +1 -0
- package/dist/ThemeContext.js +57 -0
- package/dist/ThemeContext.js.map +1 -0
- package/dist/ThemeToggle.js +4 -15
- package/dist/ThemeToggle.js.map +1 -1
- package/dist/Toggle.js +69 -0
- package/dist/Toggle.js.map +1 -0
- package/dist/_commonjsHelpers.js +6 -0
- package/dist/_commonjsHelpers.js.map +1 -0
- package/dist/assets/quantum-ui.css +59 -10
- package/dist/axios.js +61 -3
- package/dist/axios.js.map +1 -1
- package/dist/check.js +15 -0
- package/dist/check.js.map +1 -0
- package/dist/circle-check-big.js +18 -0
- package/dist/circle-check-big.js.map +1 -0
- package/dist/components/Avatar.js +2 -0
- package/dist/components/Avatar.js.map +1 -0
- package/dist/components/Badge.js +2 -0
- package/dist/components/Badge.js.map +1 -0
- package/dist/components/Chart.js +2 -0
- package/dist/components/Chart.js.map +1 -0
- package/dist/components/DropdownMenu.js +2 -0
- package/dist/components/DropdownMenu.js.map +1 -0
- package/dist/components/Progress.js +1 -174
- package/dist/components/Progress.js.map +1 -1
- package/dist/components/Separator.js +2 -0
- package/dist/components/Separator.js.map +1 -0
- package/dist/components/Sonner.js +3 -0
- package/dist/components/Sonner.js.map +1 -0
- package/dist/components/Switch.js +2 -0
- package/dist/components/Switch.js.map +1 -0
- package/dist/components/Toggle.js +2 -0
- package/dist/components/Toggle.js.map +1 -0
- package/dist/context/index.js +2 -0
- package/dist/context/index.js.map +1 -0
- package/dist/field.js +2 -49
- package/dist/field.js.map +1 -1
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/index10.js +105 -0
- package/dist/index10.js.map +1 -0
- package/dist/index11.js +101 -0
- package/dist/index11.js.map +1 -0
- package/dist/index12.js +205 -0
- package/dist/index12.js.map +1 -0
- package/dist/index13.js +199 -0
- package/dist/index13.js.map +1 -0
- package/dist/index2.js +55 -130
- package/dist/index2.js.map +1 -1
- package/dist/index3.js +10 -42
- package/dist/index3.js.map +1 -1
- package/dist/index4.js +125 -35
- package/dist/index4.js.map +1 -1
- package/dist/index5.js +26 -414
- package/dist/index5.js.map +1 -1
- package/dist/index6.js +8 -0
- package/dist/index6.js.map +1 -0
- package/dist/index7.js +16 -0
- package/dist/index7.js.map +1 -0
- package/dist/index8.js +45 -0
- package/dist/index8.js.map +1 -0
- package/dist/index9.js +41 -0
- package/dist/index9.js.map +1 -0
- package/dist/lib/components/Avatar/Avatar.d.ts +8 -0
- package/dist/lib/components/Avatar/Avatar.d.ts.map +1 -0
- package/dist/lib/components/Avatar/index.d.ts +2 -0
- package/dist/lib/components/Avatar/index.d.ts.map +1 -0
- package/dist/lib/components/Badge/Badge.d.ts +5 -0
- package/dist/lib/components/Badge/Badge.d.ts.map +1 -0
- package/dist/lib/components/Badge/index.d.ts +3 -0
- package/dist/lib/components/Badge/index.d.ts.map +1 -0
- package/dist/lib/components/Button/index.d.ts +1 -1
- package/dist/lib/components/Button/index.d.ts.map +1 -1
- package/dist/lib/components/Chart/Chart.d.ts +13 -0
- package/dist/lib/components/Chart/Chart.d.ts.map +1 -0
- package/dist/lib/components/Chart/index.d.ts +3 -0
- package/dist/lib/components/Chart/index.d.ts.map +1 -0
- package/dist/lib/components/DropdownMenu/DropdownMenu.d.ts +28 -0
- package/dist/lib/components/DropdownMenu/DropdownMenu.d.ts.map +1 -0
- package/dist/lib/components/DropdownMenu/index.d.ts +3 -0
- package/dist/lib/components/DropdownMenu/index.d.ts.map +1 -0
- package/dist/lib/components/DropdownMenu/types.d.ts +72 -0
- package/dist/lib/components/DropdownMenu/types.d.ts.map +1 -0
- package/dist/lib/components/Form/Form.d.ts.map +1 -1
- package/dist/lib/components/OTPField/OTPField.d.ts.map +1 -1
- package/dist/lib/components/PhoneField/PhoneField.d.ts.map +1 -1
- package/dist/lib/components/Separator/Separator.d.ts +3 -0
- package/dist/lib/components/Separator/Separator.d.ts.map +1 -0
- package/dist/lib/components/Separator/index.d.ts +2 -0
- package/dist/lib/components/Separator/index.d.ts.map +1 -0
- package/dist/lib/components/Sonner/Sonner.d.ts +5 -0
- package/dist/lib/components/Sonner/Sonner.d.ts.map +1 -0
- package/dist/lib/components/Sonner/index.d.ts +4 -0
- package/dist/lib/components/Sonner/index.d.ts.map +1 -0
- package/dist/lib/components/Sonner/toast.d.ts +29 -0
- package/dist/lib/components/Sonner/toast.d.ts.map +1 -0
- package/dist/lib/components/Switch/Switch.d.ts +9 -0
- package/dist/lib/components/Switch/Switch.d.ts.map +1 -0
- package/dist/lib/components/Switch/index.d.ts +3 -0
- package/dist/lib/components/Switch/index.d.ts.map +1 -0
- package/dist/lib/components/ThemeToggle/ThemeToggle.d.ts.map +1 -1
- package/dist/lib/components/Toggle/Toggle.d.ts +7 -0
- package/dist/lib/components/Toggle/Toggle.d.ts.map +1 -0
- package/dist/lib/components/Toggle/index.d.ts +2 -0
- package/dist/lib/components/Toggle/index.d.ts.map +1 -0
- package/dist/lib/components/index.d.ts +9 -0
- package/dist/lib/components/index.d.ts.map +1 -1
- package/dist/lib/context/ThemeContext.d.ts +18 -0
- package/dist/lib/context/ThemeContext.d.ts.map +1 -0
- package/dist/lib/context/index.d.ts +2 -0
- package/dist/lib/context/index.d.ts.map +1 -0
- package/dist/lib/hooks/index.d.ts +2 -0
- package/dist/lib/hooks/index.d.ts.map +1 -0
- package/dist/lib/hooks/useTheme.d.ts +8 -0
- package/dist/lib/hooks/useTheme.d.ts.map +1 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/theme/index.d.ts +13 -0
- package/dist/lib/theme/index.d.ts.map +1 -0
- package/dist/lib/utils/axios.d.ts +6 -0
- package/dist/lib/utils/axios.d.ts.map +1 -1
- package/dist/lib/utils/formHelpers.d.ts.map +1 -1
- package/dist/loader-circle.js +15 -0
- package/dist/loader-circle.js.map +1 -0
- package/dist/separator2.js +53 -0
- package/dist/separator2.js.map +1 -0
- package/dist/shadcn/index.d.ts +1 -0
- package/dist/shadcn/index.d.ts.map +1 -1
- package/dist/shadcn/shadcnAvatar/Avatar.d.ts +12 -0
- package/dist/shadcn/shadcnAvatar/Avatar.d.ts.map +1 -0
- package/dist/shadcn/shadcnAvatar/index.d.ts +2 -0
- package/dist/shadcn/shadcnAvatar/index.d.ts.map +1 -0
- package/dist/shadcn/shadcnBadge/Badge.d.ts +11 -0
- package/dist/shadcn/shadcnBadge/Badge.d.ts.map +1 -0
- package/dist/shadcn/shadcnBadge/index.d.ts +3 -0
- package/dist/shadcn/shadcnBadge/index.d.ts.map +1 -0
- package/dist/shadcn/shadcnButton/Button.d.ts +1 -1
- package/dist/shadcn/shadcnChart/Chart.d.ts +58 -0
- package/dist/shadcn/shadcnChart/Chart.d.ts.map +1 -0
- package/dist/shadcn/shadcnChart/index.d.ts +3 -0
- package/dist/shadcn/shadcnChart/index.d.ts.map +1 -0
- package/dist/shadcn/shadcnSonner/index.d.ts +2 -0
- package/dist/shadcn/shadcnSonner/index.d.ts.map +1 -0
- package/dist/shadcn/shadcnSonner/sonner.d.ts +4 -0
- package/dist/shadcn/shadcnSonner/sonner.d.ts.map +1 -0
- package/dist/shadcn/shadcnSpinner/Spinner.d.ts.map +1 -1
- package/dist/shadcn/shadcnSwitch/Switch.d.ts +7 -0
- package/dist/shadcn/shadcnSwitch/Switch.d.ts.map +1 -0
- package/dist/shadcn/shadcnSwitch/index.d.ts +2 -0
- package/dist/shadcn/shadcnSwitch/index.d.ts.map +1 -0
- package/dist/shadcn/shadcnToggle/Toggle.d.ts +10 -0
- package/dist/shadcn/shadcnToggle/Toggle.d.ts.map +1 -0
- package/dist/shadcn/shadcnToggle/index.d.ts +2 -0
- package/dist/shadcn/shadcnToggle/index.d.ts.map +1 -0
- package/dist/theme/index.js +11 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/toast.js +72 -0
- package/dist/toast.js.map +1 -0
- package/dist/useTheme.js +15 -0
- package/dist/useTheme.js.map +1 -0
- package/dist/utils/axios.js +1 -0
- package/dist/utils/axios.js.map +1 -1
- package/package.json +55 -5
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createContext, useState, useLayoutEffect, useCallback, useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
const THEME_STORAGE_KEY = "theme";
|
|
5
|
+
const ThemeContext = createContext(null);
|
|
6
|
+
ThemeContext.displayName = "ThemeContext";
|
|
7
|
+
function getInitialTheme(storageKey, defaultTheme) {
|
|
8
|
+
if (typeof window !== "undefined") {
|
|
9
|
+
const savedTheme = localStorage.getItem(storageKey);
|
|
10
|
+
if (savedTheme === "dark" || savedTheme === "light") {
|
|
11
|
+
return savedTheme;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (defaultTheme) {
|
|
15
|
+
return defaultTheme;
|
|
16
|
+
}
|
|
17
|
+
if (typeof window !== "undefined") {
|
|
18
|
+
const systemPrefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
19
|
+
return systemPrefersDark ? "dark" : "light";
|
|
20
|
+
}
|
|
21
|
+
return "light";
|
|
22
|
+
}
|
|
23
|
+
function ThemeProvider({
|
|
24
|
+
children,
|
|
25
|
+
defaultTheme,
|
|
26
|
+
storageKey = THEME_STORAGE_KEY
|
|
27
|
+
}) {
|
|
28
|
+
const [theme, setThemeState] = useState(
|
|
29
|
+
() => getInitialTheme(storageKey, defaultTheme)
|
|
30
|
+
);
|
|
31
|
+
useLayoutEffect(() => {
|
|
32
|
+
const isDark = theme === "dark";
|
|
33
|
+
document.documentElement.classList.toggle("dark", isDark);
|
|
34
|
+
}, [theme]);
|
|
35
|
+
useLayoutEffect(() => {
|
|
36
|
+
localStorage.setItem(storageKey, theme);
|
|
37
|
+
}, [theme, storageKey]);
|
|
38
|
+
const setTheme = useCallback((newTheme) => {
|
|
39
|
+
setThemeState(newTheme);
|
|
40
|
+
}, []);
|
|
41
|
+
const toggleTheme = useCallback(() => {
|
|
42
|
+
setThemeState((currentTheme) => currentTheme === "dark" ? "light" : "dark");
|
|
43
|
+
}, []);
|
|
44
|
+
const value = useMemo(
|
|
45
|
+
() => ({
|
|
46
|
+
theme,
|
|
47
|
+
toggleTheme,
|
|
48
|
+
setTheme
|
|
49
|
+
}),
|
|
50
|
+
[theme, toggleTheme, setTheme]
|
|
51
|
+
);
|
|
52
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children });
|
|
53
|
+
}
|
|
54
|
+
ThemeProvider.displayName = "ThemeProvider";
|
|
55
|
+
|
|
56
|
+
export { ThemeContext as T, ThemeProvider as a };
|
|
57
|
+
//# sourceMappingURL=ThemeContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeContext.js","sources":["../lib/context/ThemeContext.tsx"],"sourcesContent":["import {\n createContext,\n useCallback,\n useLayoutEffect,\n useMemo,\n useState,\n type ReactNode,\n} from 'react';\n\n/**\n * Theme mode type - either 'light' or 'dark'\n */\nexport type ThemeMode = 'light' | 'dark';\n\n/**\n * Shape of the theme context value\n */\nexport interface ThemeContextValue {\n /** Current theme mode ('light' or 'dark') */\n theme: ThemeMode;\n /** Function to toggle between light and dark themes */\n toggleTheme: () => void;\n /** Function to set a specific theme */\n setTheme: (theme: ThemeMode) => void;\n}\n\n/**\n * Props for the ThemeProvider component\n */\nexport interface ThemeProviderProps {\n /** Child components that will have access to the theme context */\n children: ReactNode;\n /** Optional initial theme (defaults to system preference or localStorage) */\n defaultTheme?: ThemeMode;\n /** localStorage key for persisting theme preference */\n storageKey?: string;\n}\n\nconst THEME_STORAGE_KEY = 'theme';\n\n/**\n * Theme context for sharing theme state across components.\n * Use the useTheme hook to access this context.\n */\nexport const ThemeContext = createContext<ThemeContextValue | null>(null);\n\nThemeContext.displayName = 'ThemeContext';\n\n/**\n * Determines the initial theme based on localStorage and system preferences.\n * @param storageKey - The localStorage key to check for saved theme\n * @param defaultTheme - Optional default theme to use if no preference is found\n * @returns The determined initial theme\n */\nfunction getInitialTheme(storageKey: string, defaultTheme?: ThemeMode): ThemeMode {\n // Check for saved theme in localStorage\n if (typeof window !== 'undefined') {\n const savedTheme = localStorage.getItem(storageKey);\n if (savedTheme === 'dark' || savedTheme === 'light') {\n return savedTheme;\n }\n }\n\n // Use default theme if provided\n if (defaultTheme) {\n return defaultTheme;\n }\n\n // Fall back to system preference\n if (typeof window !== 'undefined') {\n const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;\n return systemPrefersDark ? 'dark' : 'light';\n }\n\n // Ultimate fallback\n return 'light';\n}\n\n/**\n * ThemeProvider component that manages theme state and provides it to the component tree.\n *\n * Features:\n * - Single source of truth for theme state\n * - Persists theme preference to localStorage\n * - Detects system color scheme preference on initial load\n * - Toggles the 'dark' class on document.documentElement\n * - Avoids flash of incorrect theme using useLayoutEffect\n *\n * @example\n * ```tsx\n * // Wrap your app with ThemeProvider\n * function App() {\n * return (\n * <ThemeProvider>\n * <YourApp />\n * </ThemeProvider>\n * );\n * }\n *\n * // With default theme\n * <ThemeProvider defaultTheme=\"dark\">\n * <YourApp />\n * </ThemeProvider>\n *\n * // With custom storage key\n * <ThemeProvider storageKey=\"my-app-theme\">\n * <YourApp />\n * </ThemeProvider>\n * ```\n */\nexport function ThemeProvider({\n children,\n defaultTheme,\n storageKey = THEME_STORAGE_KEY,\n}: ThemeProviderProps) {\n const [theme, setThemeState] = useState<ThemeMode>(() =>\n getInitialTheme(storageKey, defaultTheme)\n );\n\n // Apply theme to document on initial mount and when theme changes\n useLayoutEffect(() => {\n const isDark = theme === 'dark';\n document.documentElement.classList.toggle('dark', isDark);\n }, [theme]);\n\n // Persist to localStorage whenever theme changes\n useLayoutEffect(() => {\n localStorage.setItem(storageKey, theme);\n }, [theme, storageKey]);\n\n const setTheme = useCallback((newTheme: ThemeMode) => {\n setThemeState(newTheme);\n }, []);\n\n const toggleTheme = useCallback(() => {\n setThemeState((currentTheme) => (currentTheme === 'dark' ? 'light' : 'dark'));\n }, []);\n\n const value = useMemo<ThemeContextValue>(\n () => ({\n theme,\n toggleTheme,\n setTheme,\n }),\n [theme, toggleTheme, setTheme]\n );\n\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\n}\n\nThemeProvider.displayName = 'ThemeProvider';\n"],"names":[],"mappings":";;;AAsCA,MAAM,iBAAA,GAAoB,OAAA;AAMnB,MAAM,YAAA,GAAe,cAAwC,IAAI;AAExE,YAAA,CAAa,WAAA,GAAc,cAAA;AAQ3B,SAAS,eAAA,CAAgB,YAAoB,YAAA,EAAqC;AAEhF,EAAA,IAAI,OAAO,WAAW,WAAA,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A,aAAA,CAAc,CAAC,YAAA,KAAkB,YAAA,KAAiB,MAAA,GAAS,UAAU,MAAO,CAAA;AAAA,EAC9E,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,KAAA,GAAQ,OAAA;AAAA,IACZ,OAAO;AAAA,MACL,KAAA;AAAA,MACA,WAAA;AAAA,MACA;AAAA,KACF,CAAA;AAAA,IACA,CAAC,KAAA,EAAO,WAAA,EAAa,QAAQ;AAAA,GAC/B;AAEA,EAAA,uBAAO,GAAA,CAAC,YAAA,CAAa,QAAA,EAAb,EAAsB,OAAe,QAAA,EAAS,CAAA;AACxD;AAEA,aAAA,CAAc,WAAA,GAAc,eAAA;;;;"}
|
package/dist/ThemeToggle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { u as useTheme } from './useTheme.js';
|
|
3
3
|
import { B as Button } from './Button.js';
|
|
4
4
|
import { c as createLucideIcon } from './createLucideIcon.js';
|
|
5
5
|
|
|
@@ -44,20 +44,8 @@ const __iconNode = [
|
|
|
44
44
|
const Sun = createLucideIcon("sun", __iconNode);
|
|
45
45
|
|
|
46
46
|
const ThemeToggle = ({ className, size = "md" }) => {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
const savedTheme = localStorage.getItem("theme");
|
|
50
|
-
const systemPrefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
51
|
-
const shouldUseDark = savedTheme === "dark" || !savedTheme && systemPrefersDark;
|
|
52
|
-
setIsDarkMode(shouldUseDark);
|
|
53
|
-
document.documentElement.classList.toggle("dark", shouldUseDark);
|
|
54
|
-
}, []);
|
|
55
|
-
const toggleTheme = () => {
|
|
56
|
-
const newDarkMode = !isDarkMode;
|
|
57
|
-
setIsDarkMode(newDarkMode);
|
|
58
|
-
document.documentElement.classList.toggle("dark", newDarkMode);
|
|
59
|
-
localStorage.setItem("theme", newDarkMode ? "dark" : "light");
|
|
60
|
-
};
|
|
47
|
+
const { theme, toggleTheme } = useTheme();
|
|
48
|
+
const isDarkMode = theme === "dark";
|
|
61
49
|
return /* @__PURE__ */ jsxs(
|
|
62
50
|
Button,
|
|
63
51
|
{
|
|
@@ -85,6 +73,7 @@ const ThemeToggle = ({ className, size = "md" }) => {
|
|
|
85
73
|
}
|
|
86
74
|
);
|
|
87
75
|
};
|
|
76
|
+
ThemeToggle.displayName = "ThemeToggle";
|
|
88
77
|
|
|
89
78
|
export { ThemeToggle as T };
|
|
90
79
|
//# sourceMappingURL=ThemeToggle.js.map
|
package/dist/ThemeToggle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeToggle.js","sources":["../node_modules/.pnpm/lucide-react@0.562.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/moon.js","../node_modules/.pnpm/lucide-react@0.562.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/sun.js","../lib/components/ThemeToggle/ThemeToggle.tsx"],"sourcesContent":["/**\n * @license lucide-react v0.562.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401\",\n key: \"kfwtm\"\n }\n ]\n];\nconst Moon = createLucideIcon(\"moon\", __iconNode);\n\nexport { __iconNode, Moon as default };\n//# sourceMappingURL=moon.js.map\n","/**\n * @license lucide-react v0.562.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"4\", key: \"4exip2\" }],\n [\"path\", { d: \"M12 2v2\", key: \"tus03m\" }],\n [\"path\", { d: \"M12 20v2\", key: \"1lh1kg\" }],\n [\"path\", { d: \"m4.93 4.93 1.41 1.41\", key: \"149t6j\" }],\n [\"path\", { d: \"m17.66 17.66 1.41 1.41\", key: \"ptbguv\" }],\n [\"path\", { d: \"M2 12h2\", key: \"1t8f8n\" }],\n [\"path\", { d: \"M20 12h2\", key: \"1q8mjw\" }],\n [\"path\", { d: \"m6.34 17.66-1.41 1.41\", key: \"1m8zz5\" }],\n [\"path\", { d: \"m19.07 4.93-1.41 1.41\", key: \"1shlcs\" }]\n];\nconst Sun = createLucideIcon(\"sun\", __iconNode);\n\nexport { __iconNode, Sun as default };\n//# sourceMappingURL=sun.js.map\n","import { Moon, Sun } from 'lucide-react';\nimport type React from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"ThemeToggle.js","sources":["../node_modules/.pnpm/lucide-react@0.562.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/moon.js","../node_modules/.pnpm/lucide-react@0.562.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/sun.js","../lib/components/ThemeToggle/ThemeToggle.tsx"],"sourcesContent":["/**\n * @license lucide-react v0.562.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401\",\n key: \"kfwtm\"\n }\n ]\n];\nconst Moon = createLucideIcon(\"moon\", __iconNode);\n\nexport { __iconNode, Moon as default };\n//# sourceMappingURL=moon.js.map\n","/**\n * @license lucide-react v0.562.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"4\", key: \"4exip2\" }],\n [\"path\", { d: \"M12 2v2\", key: \"tus03m\" }],\n [\"path\", { d: \"M12 20v2\", key: \"1lh1kg\" }],\n [\"path\", { d: \"m4.93 4.93 1.41 1.41\", key: \"149t6j\" }],\n [\"path\", { d: \"m17.66 17.66 1.41 1.41\", key: \"ptbguv\" }],\n [\"path\", { d: \"M2 12h2\", key: \"1t8f8n\" }],\n [\"path\", { d: \"M20 12h2\", key: \"1q8mjw\" }],\n [\"path\", { d: \"m6.34 17.66-1.41 1.41\", key: \"1m8zz5\" }],\n [\"path\", { d: \"m19.07 4.93-1.41 1.41\", key: \"1shlcs\" }]\n];\nconst Sun = createLucideIcon(\"sun\", __iconNode);\n\nexport { __iconNode, Sun as default };\n//# sourceMappingURL=sun.js.map\n","import { Moon, Sun } from 'lucide-react';\nimport type React from 'react';\nimport { useTheme } from '../../hooks/useTheme';\nimport { Button } from '../Button/Button';\n\nexport interface ThemeToggleProps {\n /**\n * Custom className for the toggle button\n */\n className?: string;\n\n /**\n * Size of the toggle button\n */\n size?: 'sm' | 'md' | 'lg';\n}\n\n/**\n * ThemeToggle component for switching between light and dark themes.\n *\n * Uses the useTheme hook internally for theme state management.\n *\n * @example\n * ```tsx\n * <ThemeToggle />\n * <ThemeToggle size=\"lg\" className=\"custom-class\" />\n * ```\n */\nexport const ThemeToggle: React.FC<ThemeToggleProps> = ({ className, size = 'md' }) => {\n const { theme, toggleTheme } = useTheme();\n const isDarkMode = theme === 'dark';\n\n return (\n <Button\n variant=\"ghost\"\n size={size === 'md' ? 'default' : size}\n onClick={toggleTheme}\n className={`text-foreground ${className}`}\n aria-label={`Switch to ${isDarkMode ? 'light' : 'dark'} theme`}\n >\n <Sun\n className={`h-4 w-4 transition-all ${isDarkMode ? 'scale-0 -rotate-90' : 'scale-100 rotate-0'}`}\n aria-hidden\n />\n <Moon\n className={`absolute h-4 w-4 transition-all ${isDarkMode ? 'scale-100 rotate-0' : 'scale-0 rotate-90'}`}\n aria-hidden\n />\n </Button>\n );\n};\n\nThemeToggle.displayName = 'ThemeToggle';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GAAG,GAAG,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC;;ACQxC,MAAM,cAA0C,CAAC,EAAE,SAAA,EAAW,IAAA,GAAO,MAAK,KAAM;AACrF,EAAA,MAAM,EAAE,KAAA,EAAO,WAAA,EAAY,GAAI,QAAA,EAAS;AACxC,EAAA,MAAM,aAAa,KAAA,KAAU,MAAA;AAE7B,EAAA,uBACE,IAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,OAAA,EAAQ,OAAA;AAAA,MACR,IAAA,EAAM,IAAA,KAAS,IAAA,GAAO,SAAA,GAAY,IAAA;AAAA,MAClC,OAAA,EAAS,WAAA;AAAA,MACT,SAAA,EAAW,mBAAmB,SAAS,CAAA,CAAA;AAAA,MACvC,YAAA,EAAY,CAAA,UAAA,EAAa,UAAA,GAAa,OAAA,GAAU,MAAM,CAAA,MAAA,CAAA;AAAA,MAEtD,QAAA,EAAA;AAAA,wBAAA,GAAA;AAAA,UAAC,GAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAW,CAAA,uBAAA,EAA0B,UAAA,GAAa,oBAAA,GAAuB,oBAAoB,CAAA,CAAA;AAAA,YAC7F,aAAA,EAAW;AAAA;AAAA,SACb;AAAA,wBACA,GAAA;AAAA,UAAC,IAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAW,CAAA,gCAAA,EAAmC,UAAA,GAAa,oBAAA,GAAuB,mBAAmB,CAAA,CAAA;AAAA,YACrG,aAAA,EAAW;AAAA;AAAA;AACb;AAAA;AAAA,GACF;AAEJ;AAEA,WAAA,CAAY,WAAA,GAAc,aAAA;;;;","x_google_ignoreList":[0,1]}
|
package/dist/Toggle.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { u as useControllableState, P as Primitive, c as composeEventHandlers } from './index12.js';
|
|
4
|
+
import { c as cva } from './index8.js';
|
|
5
|
+
import { c as cn } from './utils.js';
|
|
6
|
+
|
|
7
|
+
var NAME = "Toggle";
|
|
8
|
+
var Toggle$2 = React.forwardRef((props, forwardedRef) => {
|
|
9
|
+
const { pressed: pressedProp, defaultPressed, onPressedChange, ...buttonProps } = props;
|
|
10
|
+
const [pressed, setPressed] = useControllableState({
|
|
11
|
+
prop: pressedProp,
|
|
12
|
+
onChange: onPressedChange,
|
|
13
|
+
defaultProp: defaultPressed ?? false,
|
|
14
|
+
caller: NAME
|
|
15
|
+
});
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
17
|
+
Primitive.button,
|
|
18
|
+
{
|
|
19
|
+
type: "button",
|
|
20
|
+
"aria-pressed": pressed,
|
|
21
|
+
"data-state": pressed ? "on" : "off",
|
|
22
|
+
"data-disabled": props.disabled ? "" : void 0,
|
|
23
|
+
...buttonProps,
|
|
24
|
+
ref: forwardedRef,
|
|
25
|
+
onClick: composeEventHandlers(props.onClick, () => {
|
|
26
|
+
if (!props.disabled) {
|
|
27
|
+
setPressed(!pressed);
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
Toggle$2.displayName = NAME;
|
|
34
|
+
var Root = Toggle$2;
|
|
35
|
+
|
|
36
|
+
const toggleVariants$1 = cva(
|
|
37
|
+
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",
|
|
38
|
+
{
|
|
39
|
+
variants: {
|
|
40
|
+
variant: {
|
|
41
|
+
default: "bg-transparent",
|
|
42
|
+
outline: "border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"
|
|
43
|
+
},
|
|
44
|
+
size: {
|
|
45
|
+
default: "h-9 px-2 min-w-9",
|
|
46
|
+
sm: "h-8 px-1.5 min-w-8",
|
|
47
|
+
lg: "h-10 px-2.5 min-w-10"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
defaultVariants: {
|
|
51
|
+
variant: "default",
|
|
52
|
+
size: "default"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
function Toggle$1({
|
|
57
|
+
className,
|
|
58
|
+
variant,
|
|
59
|
+
size,
|
|
60
|
+
...props
|
|
61
|
+
}) {
|
|
62
|
+
return /* @__PURE__ */ jsx(Root, { "data-slot": "toggle", className: cn(toggleVariants$1({ variant, size, className })), ...props });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const Toggle = Toggle$1;
|
|
66
|
+
const toggleVariants = toggleVariants$1;
|
|
67
|
+
|
|
68
|
+
export { Toggle as T, toggleVariants as t };
|
|
69
|
+
//# sourceMappingURL=Toggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toggle.js","sources":["../node_modules/.pnpm/@radix-ui+react-toggle@1.1.10_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react_5be2ba4619ea932b5b17927c79378d5f/node_modules/@radix-ui/react-toggle/dist/index.mjs","../shadcn/shadcnToggle/Toggle.tsx","../lib/components/Toggle/Toggle.tsx"],"sourcesContent":["\"use client\";\n\n// src/toggle.tsx\nimport * as React from \"react\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { jsx } from \"react/jsx-runtime\";\nvar NAME = \"Toggle\";\nvar Toggle = React.forwardRef((props, forwardedRef) => {\n const { pressed: pressedProp, defaultPressed, onPressedChange, ...buttonProps } = props;\n const [pressed, setPressed] = useControllableState({\n prop: pressedProp,\n onChange: onPressedChange,\n defaultProp: defaultPressed ?? false,\n caller: NAME\n });\n return /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n \"aria-pressed\": pressed,\n \"data-state\": pressed ? \"on\" : \"off\",\n \"data-disabled\": props.disabled ? \"\" : void 0,\n ...buttonProps,\n ref: forwardedRef,\n onClick: composeEventHandlers(props.onClick, () => {\n if (!props.disabled) {\n setPressed(!pressed);\n }\n })\n }\n );\n});\nToggle.displayName = NAME;\nvar Root = Toggle;\nexport {\n Root,\n Toggle\n};\n//# sourceMappingURL=index.mjs.map\n","'use client';\n\nimport * as TogglePrimitive from '@radix-ui/react-toggle';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport type * as React from 'react';\n\nimport { cn } from '../utils';\n\nconst toggleVariants = cva(\n \"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap\",\n {\n variants: {\n variant: {\n default: 'bg-transparent',\n outline: 'border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground',\n },\n size: {\n default: 'h-9 px-2 min-w-9',\n sm: 'h-8 px-1.5 min-w-8',\n lg: 'h-10 px-2.5 min-w-10',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n },\n);\n\nfunction Toggle({\n className,\n variant,\n size,\n ...props\n}: React.ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>) {\n return (\n <TogglePrimitive.Root data-slot=\"toggle\" className={cn(toggleVariants({ variant, size, className }))} {...props} />\n );\n}\n\nexport { Toggle, toggleVariants };\n","import { Toggle as ShadcnToggle, toggleVariants as shadcnToggleVariants } from '../../../shadcn/shadcnToggle';\n\n/**\n * Toggle component - a two-state button for UI state changes (like toolbar buttons).\n *\n * **IMPORTANT: Toggle is NOT designed for form submission.**\n * - Toggle uses `pressed`/`onPressedChange` semantics (UI state, not form data)\n * - It doesn't provide `name`/`value` props required for form fields\n * - **For form-based on/off fields, use the `Switch` component instead**\n *\n * **Use Toggle for:**\n * - Toolbar buttons (bold, italic, underline in text editors)\n * - UI state toggles (show/hide panels, enable/disable features)\n * - Button-like interactions that don't need form submission\n *\n * **Use Switch for:**\n * - Form fields with on/off states\n * - Settings that need to be submitted with form data\n * - Fields that require validation and error display\n *\n * @example\n * ```tsx\n * // Toolbar button (Toggle) - CORRECT usage\n * <Toggle aria-label=\"Toggle italic\" onPressedChange={setItalic}>\n * <Italic className=\"h-4 w-4\" />\n * </Toggle>\n *\n * // Form field (Switch) - CORRECT usage\n * <Form form={form} onSubmit={handleSubmit}>\n * <Switch name=\"notifications\" label=\"Enable notifications\" />\n * </Form>\n *\n * // ❌ INCORRECT - Don't use Toggle in forms\n * <Form form={form} onSubmit={handleSubmit}>\n * <Toggle>Notifications</Toggle> // Won't work - use Switch instead\n * </Form>\n * ```\n */\nexport const Toggle = ShadcnToggle;\n\n/**\n * Toggle variants for custom styling.\n * Can be used with `cn()` to create custom toggle styles.\n */\nexport const toggleVariants = shadcnToggleVariants;\n"],"names":["Toggle","toggleVariants","TogglePrimitive.Root","ShadcnToggle","shadcnToggleVariants"],"mappings":";;;;;;AAQA,IAAI,IAAI,GAAG,QAAQ;AACnB,IAAIA,QAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,YAAY,KAAK;AACvD,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,WAAW,EAAE,GAAG,KAAK;AACzF,EAAE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,oBAAoB,CAAC;AAC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A,GAAG;AACL,CAAA,EAA4F;AAC1F,EAAA,2BACGE,IAAgB,EAAhB,EAAqB,WAAA,EAAU,UAAS,SAAA,EAAW,EAAA,CAAGD,gBAAA,CAAe,EAAE,SAAS,IAAA,EAAM,SAAA,EAAW,CAAC,CAAA,EAAI,GAAG,KAAA,EAAO,CAAA;AAErH;;ACAO,MAAM,MAAA,GAASE;AAMf,MAAM,cAAA,GAAiBC;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_commonjsHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -161,6 +161,8 @@
|
|
|
161
161
|
--warning-foreground: oklch(0.2302 0.0547 256.1829);
|
|
162
162
|
--success: oklch(0.65 0.15 145);
|
|
163
163
|
--success-foreground: oklch(1 0 0);
|
|
164
|
+
--info: oklch(0.65 0.15 200);
|
|
165
|
+
--info-foreground: oklch(1 0 0);
|
|
164
166
|
--border: oklch(0.9467 0.0207 248.0465);
|
|
165
167
|
--input: oklch(0.9467 0.0207 248.0465);
|
|
166
168
|
--ring: oklch(0.5789 0.1833 256.2496);
|
|
@@ -190,20 +192,20 @@
|
|
|
190
192
|
--shadow-2xs: 0rem 0.75rem 1.5rem 0.25rem hsl(214.0909 68.7500% 12.5490% / 0.04);
|
|
191
193
|
--shadow-xs: 0rem 0.75rem 1.5rem 0.25rem hsl(214.0909 68.7500% 12.5490% / 0.04);
|
|
192
194
|
--shadow-sm:
|
|
193
|
-
0rem 0.75rem 1.5rem 0.25rem hsl(214.0909 68.7500% 12.5490% / 0.08),
|
|
194
|
-
hsl(214.0909 68.7500% 12.5490% / 0.08);
|
|
195
|
+
0rem 0.75rem 1.5rem 0.25rem hsl(214.0909 68.7500% 12.5490% / 0.08),
|
|
196
|
+
0rem 1px 2px -0.75px hsl(214.0909 68.7500% 12.5490% / 0.08);
|
|
195
197
|
--shadow:
|
|
196
|
-
0rem 0.75rem 1.5rem 0.25rem hsl(214.0909 68.7500% 12.5490% / 0.08),
|
|
197
|
-
hsl(214.0909 68.7500% 12.5490% / 0.08);
|
|
198
|
+
0rem 0.75rem 1.5rem 0.25rem hsl(214.0909 68.7500% 12.5490% / 0.08),
|
|
199
|
+
0rem 1px 2px -0.75px hsl(214.0909 68.7500% 12.5490% / 0.08);
|
|
198
200
|
--shadow-md:
|
|
199
|
-
0rem 0.75rem 1.5rem 0.25rem hsl(214.0909 68.7500% 12.5490% / 0.08),
|
|
200
|
-
hsl(214.0909 68.7500% 12.5490% / 0.08);
|
|
201
|
+
0rem 0.75rem 1.5rem 0.25rem hsl(214.0909 68.7500% 12.5490% / 0.08),
|
|
202
|
+
0rem 2px 4px -0.75px hsl(214.0909 68.7500% 12.5490% / 0.08);
|
|
201
203
|
--shadow-lg:
|
|
202
|
-
0rem 0.75rem 1.5rem 0.25rem hsl(214.0909 68.7500% 12.5490% / 0.08),
|
|
203
|
-
hsl(214.0909 68.7500% 12.5490% / 0.08);
|
|
204
|
+
0rem 0.75rem 1.5rem 0.25rem hsl(214.0909 68.7500% 12.5490% / 0.08),
|
|
205
|
+
0rem 4px 6px -0.75px hsl(214.0909 68.7500% 12.5490% / 0.08);
|
|
204
206
|
--shadow-xl:
|
|
205
|
-
0rem 0.75rem 1.5rem 0.25rem hsl(214.0909 68.7500% 12.5490% / 0.08),
|
|
206
|
-
hsl(214.0909 68.7500% 12.5490% / 0.08);
|
|
207
|
+
0rem 0.75rem 1.5rem 0.25rem hsl(214.0909 68.7500% 12.5490% / 0.08),
|
|
208
|
+
0rem 8px 10px -0.75px hsl(214.0909 68.7500% 12.5490% / 0.08);
|
|
207
209
|
--shadow-2xl: 0rem 0.75rem 1.5rem 0.25rem hsl(214.0909 68.7500% 12.5490% / 0.2);
|
|
208
210
|
--tracking-normal: 0.01em;
|
|
209
211
|
--spacing: 0.25rem;
|
|
@@ -229,6 +231,8 @@
|
|
|
229
231
|
--warning-foreground: oklch(0.1591 0 0);
|
|
230
232
|
--success: oklch(0.7 0.16 150);
|
|
231
233
|
--success-foreground: oklch(0.1591 0 0);
|
|
234
|
+
--info: oklch(0.72 0.15 200);
|
|
235
|
+
--info-foreground: oklch(0.1591 0 0);
|
|
232
236
|
--border: oklch(0.2931 0 0);
|
|
233
237
|
--input: oklch(0.2931 0 0);
|
|
234
238
|
--ring: oklch(0.5789 0.1833 256.2496);
|
|
@@ -285,6 +289,8 @@
|
|
|
285
289
|
--color-warning-foreground: var(--warning-foreground);
|
|
286
290
|
--color-success: var(--success);
|
|
287
291
|
--color-success-foreground: var(--success-foreground);
|
|
292
|
+
--color-info: var(--info);
|
|
293
|
+
--color-info-foreground: var(--info-foreground);
|
|
288
294
|
--color-border: var(--border);
|
|
289
295
|
--color-input: var(--input);
|
|
290
296
|
--color-ring: var(--ring);
|
|
@@ -350,3 +356,46 @@ body {
|
|
|
350
356
|
width: 100%;
|
|
351
357
|
}
|
|
352
358
|
}
|
|
359
|
+
/* Sonner Toast Styling */
|
|
360
|
+
[data-sonner-toaster] [data-sonner-toast] {
|
|
361
|
+
background-color: var(--card);
|
|
362
|
+
color: var(--card-foreground);
|
|
363
|
+
border: 1px solid var(--border);
|
|
364
|
+
border-radius: var(--radius);
|
|
365
|
+
}
|
|
366
|
+
[data-sonner-toaster] [data-sonner-toast] [data-description] {
|
|
367
|
+
color: var(--muted-foreground);
|
|
368
|
+
}
|
|
369
|
+
[data-sonner-toaster] [data-sonner-toast][data-type="success"] {
|
|
370
|
+
border-left: 4px solid var(--success);
|
|
371
|
+
}
|
|
372
|
+
[data-sonner-toaster] [data-sonner-toast][data-type="error"] {
|
|
373
|
+
border-left: 4px solid var(--destructive);
|
|
374
|
+
}
|
|
375
|
+
[data-sonner-toaster] [data-sonner-toast][data-type="warning"] {
|
|
376
|
+
border-left: 4px solid var(--warning);
|
|
377
|
+
}
|
|
378
|
+
[data-sonner-toaster] [data-sonner-toast][data-type="info"] {
|
|
379
|
+
border-left: 4px solid var(--info);
|
|
380
|
+
}
|
|
381
|
+
[data-sonner-toaster] [data-sonner-toast][data-type="loading"] {
|
|
382
|
+
border-left: 4px solid var(--primary);
|
|
383
|
+
}
|
|
384
|
+
/* Override browser autofill styles */
|
|
385
|
+
input:-webkit-autofill,
|
|
386
|
+
input:-webkit-autofill:hover,
|
|
387
|
+
input:-webkit-autofill:focus,
|
|
388
|
+
input:-webkit-autofill:active,
|
|
389
|
+
textarea:-webkit-autofill,
|
|
390
|
+
textarea:-webkit-autofill:hover,
|
|
391
|
+
textarea:-webkit-autofill:focus,
|
|
392
|
+
textarea:-webkit-autofill:active,
|
|
393
|
+
select:-webkit-autofill,
|
|
394
|
+
select:-webkit-autofill:hover,
|
|
395
|
+
select:-webkit-autofill:focus,
|
|
396
|
+
select:-webkit-autofill:active {
|
|
397
|
+
-webkit-box-shadow: 0 0 0 1000px var(--input) inset !important;
|
|
398
|
+
-webkit-text-fill-color: var(--foreground) !important;
|
|
399
|
+
caret-color: var(--foreground) !important;
|
|
400
|
+
transition: background-color 5000s ease-in-out 0s;
|
|
401
|
+
}
|
package/dist/axios.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { g as generateToastId, t as toast } from './toast.js';
|
|
2
|
+
|
|
1
3
|
const defaultConfig = {
|
|
2
4
|
csrf: {
|
|
3
5
|
endpoint: "/csrf/token",
|
|
@@ -4151,16 +4153,72 @@ axios.interceptors.request.use(async (config) => {
|
|
|
4151
4153
|
if (!csrf) csrf = await fetchCsrfToken();
|
|
4152
4154
|
if (csrf) config.headers[quantumConfig.csrf.headerName] = csrf;
|
|
4153
4155
|
}
|
|
4156
|
+
const loadingMessage = config.loadingMessage;
|
|
4157
|
+
if (loadingMessage) {
|
|
4158
|
+
const toastId = generateToastId();
|
|
4159
|
+
config._toastId = toastId;
|
|
4160
|
+
toast.loading(loadingMessage, { id: toastId });
|
|
4161
|
+
}
|
|
4154
4162
|
return config;
|
|
4155
4163
|
});
|
|
4156
4164
|
axios.interceptors.response.use(
|
|
4157
|
-
(response) =>
|
|
4165
|
+
(response) => {
|
|
4166
|
+
const config = response.config;
|
|
4167
|
+
const method = config.method?.toUpperCase();
|
|
4168
|
+
const isMutation = ["POST", "PUT", "PATCH", "DELETE"].includes(method || "");
|
|
4169
|
+
const toastId = config._toastId;
|
|
4170
|
+
if (toastId) {
|
|
4171
|
+
const message = config.successMessage || response.data?.message;
|
|
4172
|
+
if (message) {
|
|
4173
|
+
toast.success(message, { id: toastId });
|
|
4174
|
+
} else {
|
|
4175
|
+
toast.success("Done", { id: toastId, duration: 1e3 });
|
|
4176
|
+
}
|
|
4177
|
+
} else {
|
|
4178
|
+
const showSuccess = config.showSuccessToast ?? isMutation;
|
|
4179
|
+
if (showSuccess) {
|
|
4180
|
+
const message = config.successMessage || response.data?.message;
|
|
4181
|
+
if (message) {
|
|
4182
|
+
toast.success(message);
|
|
4183
|
+
}
|
|
4184
|
+
}
|
|
4185
|
+
}
|
|
4186
|
+
return response;
|
|
4187
|
+
},
|
|
4158
4188
|
(error) => {
|
|
4159
|
-
const
|
|
4160
|
-
|
|
4189
|
+
const config = error.config;
|
|
4190
|
+
const showError = config?.showErrorToast ?? true;
|
|
4191
|
+
const status = error.response?.status;
|
|
4192
|
+
const errorData = error.response?.data;
|
|
4193
|
+
const isPublicRequest = config?.public === true;
|
|
4194
|
+
const toastId = config?._toastId;
|
|
4195
|
+
if (status === 401 && !isPublicRequest) {
|
|
4196
|
+
if (toastId) {
|
|
4197
|
+
toast.error("Session expired", { id: toastId });
|
|
4198
|
+
}
|
|
4161
4199
|
clearToken();
|
|
4162
4200
|
cancelTokenRefresh();
|
|
4163
4201
|
redirectToLogin();
|
|
4202
|
+
return Promise.reject(error);
|
|
4203
|
+
}
|
|
4204
|
+
if (showError && status && status >= 500) {
|
|
4205
|
+
const errorMessage = errorData?.message || errorData?.detail || "Something went wrong. Please try again.";
|
|
4206
|
+
if (toastId) {
|
|
4207
|
+
toast.error("Server Error", { id: toastId, description: errorMessage });
|
|
4208
|
+
} else {
|
|
4209
|
+
toast.error("Server Error", { description: errorMessage });
|
|
4210
|
+
}
|
|
4211
|
+
}
|
|
4212
|
+
if (showError && !error.response) {
|
|
4213
|
+
if (toastId) {
|
|
4214
|
+
toast.error("Network Error", { id: toastId, description: "Please check your internet connection." });
|
|
4215
|
+
} else {
|
|
4216
|
+
toast.error("Network Error", { description: "Please check your internet connection." });
|
|
4217
|
+
}
|
|
4218
|
+
}
|
|
4219
|
+
if (toastId && status && status >= 400 && status < 500 && status !== 401) {
|
|
4220
|
+
const errorMessage = errorData?.message || errorData?.detail || "Request failed";
|
|
4221
|
+
toast.error(errorMessage, { id: toastId });
|
|
4164
4222
|
}
|
|
4165
4223
|
return Promise.reject(error);
|
|
4166
4224
|
}
|