softable-pixels-web 1.0.2 → 1.0.5
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/Checkbox-ChOwHDqG.js +149 -0
- package/dist/Checkbox-ChOwHDqG.js.map +1 -0
- package/dist/Icon-DP_mHQ2j.js +209 -0
- package/dist/Icon-DP_mHQ2j.js.map +1 -0
- package/dist/InfoSummary-DG1mzcP0.js +250 -0
- package/dist/InfoSummary-DG1mzcP0.js.map +1 -0
- package/dist/Input-DQA00Ogn.js +398 -0
- package/dist/Input-DQA00Ogn.js.map +1 -0
- package/dist/{TabSwitch-bxVgCnTw.js → TabSwitch-CXyetOBu.js} +3 -3
- package/dist/{TabSwitch-bxVgCnTw.js.map → TabSwitch-CXyetOBu.js.map} +1 -1
- package/dist/{ThemeContext-DiQ-_KUr.js → ThemeContext-C0tdHJcj.js} +46 -4
- package/dist/ThemeContext-C0tdHJcj.js.map +1 -0
- package/dist/{Typography-Dn1vnPBy.js → Typography-B9X7_xlT.js} +4 -3
- package/dist/{Typography-Dn1vnPBy.js.map → Typography-B9X7_xlT.js.map} +1 -1
- package/dist/checkbox.d.ts +3 -0
- package/dist/checkbox.js +5 -0
- package/dist/{index--nD5Wzza.d.ts → index-CCkDXM6z.d.ts} +4 -4
- package/dist/{index-B0CCFNqx.d.ts → index-CDW6xFdv.d.ts} +24 -2
- package/dist/index-CMnvjaqX.d.ts +31 -0
- package/dist/index-DmDV6MR_.d.ts +44 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.js +8 -4
- package/dist/info-summary.d.ts +62 -0
- package/dist/info-summary.js +4 -0
- package/dist/input.d.ts +3 -0
- package/dist/input.js +5 -0
- package/dist/tab-switch.d.ts +1 -1
- package/dist/tab-switch.js +2 -2
- package/dist/theme-context.d.ts +1 -1
- package/dist/theme-context.js +1 -1
- package/dist/{index-C_T04IuG.d.ts → types-2d-4sjMo.d.ts} +4 -7
- package/dist/typography.d.ts +8 -2
- package/dist/typography.js +1 -1
- package/dist/{useThemedStyles-DyrejrCM.d.ts → useThemedStyles-01zK-tbY.d.ts} +9 -2
- package/package.json +23 -2
- package/dist/ThemeContext-DiQ-_KUr.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "softable-pixels-web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "softable",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
18
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
19
|
-
"build": "
|
|
19
|
+
"build": "npm run generate:icons:node && rm -rf dist && tsdown",
|
|
20
20
|
"generate:icons": "chmod +x ./scripts/generate-icons.sh && ./scripts/generate-icons.sh",
|
|
21
21
|
"generate:icons:node": "node ./scripts/generate-icons.mjs"
|
|
22
22
|
},
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
"types": "./dist/mask-modules.d.ts",
|
|
30
30
|
"import": "./dist/mask-modules.js"
|
|
31
31
|
},
|
|
32
|
+
"./info-summary": {
|
|
33
|
+
"types": "./dist/info-summary.d.ts",
|
|
34
|
+
"import": "./dist/info-summary.js"
|
|
35
|
+
},
|
|
32
36
|
"./tab-switch": {
|
|
33
37
|
"types": "./dist/tab-switch.d.ts",
|
|
34
38
|
"import": "./dist/tab-switch.js"
|
|
@@ -37,9 +41,17 @@
|
|
|
37
41
|
"types": "./dist/typography.d.ts",
|
|
38
42
|
"import": "./dist/typography.js"
|
|
39
43
|
},
|
|
44
|
+
"./input": {
|
|
45
|
+
"types": "./dist/input.d.ts",
|
|
46
|
+
"import": "./dist/input.js"
|
|
47
|
+
},
|
|
40
48
|
"./theme-context": {
|
|
41
49
|
"types": "./dist/theme-context.d.ts",
|
|
42
50
|
"import": "./dist/theme-context.js"
|
|
51
|
+
},
|
|
52
|
+
"./checkbox": {
|
|
53
|
+
"types": "./dist/checkbox.d.ts",
|
|
54
|
+
"import": "./dist/checkbox.js"
|
|
43
55
|
}
|
|
44
56
|
},
|
|
45
57
|
"peerDependencies": {
|
|
@@ -64,14 +76,23 @@
|
|
|
64
76
|
"mask-modules": [
|
|
65
77
|
"dist/mask-modules/index.d.ts"
|
|
66
78
|
],
|
|
79
|
+
"info-summary": [
|
|
80
|
+
"dist/info-summary/index.d.ts"
|
|
81
|
+
],
|
|
67
82
|
"tab-switch": [
|
|
68
83
|
"dist/tab-switch/index.d.ts"
|
|
69
84
|
],
|
|
70
85
|
"typography": [
|
|
71
86
|
"dist/typography/index.d.ts"
|
|
72
87
|
],
|
|
88
|
+
"input": [
|
|
89
|
+
"dist/input/index.d.ts"
|
|
90
|
+
],
|
|
73
91
|
"theme-context": [
|
|
74
92
|
"dist/theme-context/index.d.ts"
|
|
93
|
+
],
|
|
94
|
+
"checkbox": [
|
|
95
|
+
"dist/checkbox/index.d.ts"
|
|
75
96
|
]
|
|
76
97
|
}
|
|
77
98
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeContext-DiQ-_KUr.js","names":["result: any","out: any","defaultThemes: ThemeRegistry","ThemeProvider: React.FC<ThemeProviderProps>"],"sources":["../src/utils/functions/deepMerge.ts","../src/contexts/ThemeContext/constants.ts","../src/contexts/ThemeContext/utils/general.ts","../src/contexts/ThemeContext/utils/themeToCSSVars.ts","../src/contexts/ThemeContext/index.tsx"],"sourcesContent":["/** biome-ignore-all lint/suspicious/noExplicitAny: <Not needed> */\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends Array<infer U>\n ? Array<DeepPartial<U>>\n : T[P] extends object\n ? DeepPartial<T[P]>\n : T[P]\n}\n\nexport function deepMerge<T>(base: T, override?: DeepPartial<T>): T {\n if (override === undefined) return clone(base)\n\n if (!isPlainObject(base) || !isPlainObject(override)) {\n return clone(override as T)\n }\n\n const result: any = Array.isArray(base) ? [] : {}\n\n const baseKeys = Object.keys(base as any) as (keyof T)[]\n const overrideKeys = Object.keys(override as any) as (keyof T)[]\n\n const allKeys = Array.from(new Set([...baseKeys, ...overrideKeys]))\n\n for (const k of allKeys) {\n const baseVal = (base as any)[k]\n const overrideVal = (override as any)[k]\n\n if (overrideVal === undefined) {\n result[k] = clone(baseVal)\n continue\n }\n\n if (isPlainObject(baseVal) && isPlainObject(overrideVal)) {\n result[k] = deepMerge(baseVal, overrideVal)\n continue\n }\n\n result[k] = clone(overrideVal)\n }\n\n return result as T\n}\n\nfunction isPlainObject(x: any): x is Record<string, any> {\n return !!x && typeof x === 'object' && !Array.isArray(x)\n}\n\nfunction clone<T>(v: T): T {\n if (v === undefined || v === null) return v\n if (Array.isArray(v)) return v.map(item => clone(item)) as unknown as T\n if (isPlainObject(v)) {\n const out: any = {}\n for (const k of Object.keys(v)) out[k] = clone((v as any)[k])\n return out\n }\n return v\n}\n","// theme/defaultThemes.ts\nimport type { ThemeRegistry } from './types'\n\nconst COMMON_MAP = {\n spacing: {\n xs: '0.25rem', // 4px\n sm: '0.5rem', // 8px\n md: '1rem', // 16px\n lg: '1.5rem', // 24px\n xl: '2rem', // 32px\n '2xl': '3rem' // 48px\n },\n borderRadius: {\n none: '0rem', // 0px\n sm: '0.25rem', // 4px\n md: '0.375rem', // 6px\n lg: '0.5rem', // 8px\n full: '9999rem' // \"infinite\" radius equivalent\n },\n fontSize: {\n xs: '0.75rem', // 12px\n sm: '0.875rem', // 14px\n md: '1rem', // 16px\n lg: '1.125rem', // 18px\n xl: '1.25rem', // 20px\n '2xl': '1.5rem' // 24px\n },\n fontWeight: { normal: 400, medium: 500, semibold: 600, bold: 700 }\n} as const\n\nexport const defaultThemes: ThemeRegistry = {\n light: {\n colors: {\n primary: '#0EB24C', // --color-brand-primary\n secondary: '#6C6C6C', // foreground-secondary\n success: '#0EB24C',\n warning: '#f59e0b',\n error: '#ef4444',\n info: '#06b6d4',\n\n background: '#FFFFFF', // --background\n surface: '#FBFBFB', // --background-secondary\n border: {\n primary: '#E8E8E9',\n secondary: '#E8E8E9'\n }, // --border-primary\n\n text: {\n primary: '#222222', // --foreground-primary\n secondary: '#6C6C6C', // --foreground-secondary\n disabled: '#A0A0A0',\n inverse: '#FFFFFF'\n }\n },\n\n ...COMMON_MAP,\n\n shadows: {\n sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',\n md: '0 4px 6px -1px rgba(0, 0, 0, 0.10)',\n lg: '0 10px 15px -3px rgba(0, 0, 0, 0.10)',\n xl: '0 20px 25px -5px rgba(0, 0, 0, 0.10)'\n }\n },\n\n dark: {\n colors: {\n primary: '#0EB24C', // brand se mantém (ou pode clarear depois)\n secondary: '#C7CFD8', // foreground-secondary dark\n success: '#0EB24C',\n warning: '#f59e0b',\n error: '#ef4444',\n info: '#06b6d4',\n\n background: '#090909', // --background dark\n surface: '#090909', // --background-secondary dark\n border: {\n primary: '#27282D',\n secondary: '#27282D'\n }, // --border-primary dark\n\n text: {\n primary: '#ECECEC', // --foreground-primary dark\n secondary: '#C7CFD8', // --foreground-secondary dark\n disabled: '#8B93A0',\n inverse: '#090909'\n }\n },\n\n ...COMMON_MAP,\n\n shadows: {\n sm: '0 1px 2px 0 rgba(0, 0, 0, 0.35)',\n md: '0 4px 6px -1px rgba(0, 0, 0, 0.45)',\n lg: '0 10px 15px -3px rgba(0, 0, 0, 0.50)',\n xl: '0 20px 25px -5px rgba(0, 0, 0, 0.55)'\n }\n }\n}\n","// Utils\n/** biome-ignore-all lint/suspicious/noExplicitAny: <Not needed> */\nimport { deepMerge } from '@utils/functions'\nimport { defaultThemes } from '../constants'\n\n// Types\nimport type { ThemeMode, ThemeRegistry, ThemeTokens } from '../types'\n\n/**\n * Theme Utilities\n * ===============\n * Small DOM utilities used by the ThemeProvider to:\n * - toggle dark mode class for Tailwind compatibility\n * - inject CSS variables (`--px-*`) into the document root\n * - read/watch the OS/browser theme preference (`prefers-color-scheme`)\n *\n * These helpers are:\n * - **client-safe** (guarded for SSR)\n * - **framework-agnostic** (only touch `documentElement`)\n * - **tiny** (no dependencies)\n */\n\n/**\n * CSSVarMap\n * ---------\n * A map of CSS custom properties to be applied on the document root.\n *\n * Notes:\n * - Keys must be valid CSS variable names (e.g. `\"--px-bg\"`, `\"--px-text-primary\"`).\n * - Values can be strings or numbers.\n * - If you store numbers (e.g. 16), you decide at consumption time whether it means px.\n *\n * You can keep it generic:\n * Record<`--${string}`, string | number>\n *\n * Or restrict to your library prefix:\n * Record<`--px-${string}`, string | number>\n */\nexport type CSSVarMap = Partial<Record<`--${string}`, string | number>>\n\n/**\n * applyThemeClass(themeName)\n * -------------------------\n * Applies the light/dark mode class to the `<html>` element.\n *\n * Tailwind’s dark mode (in the common \"class\" strategy) typically relies on a\n * `.dark` class. This function toggles ONLY the `dark` class:\n *\n * - themeName `\"dark\"` => adds `.dark`\n * - themeName `\"light\"` => removes `.dark`\n *\n * SSR:\n * - No-op on the server (when `document` is undefined).\n */\nexport function applyThemeClass(themeName: 'light' | 'dark') {\n if (typeof document === 'undefined') return\n const root = document.documentElement\n root.classList.toggle('dark', themeName === 'dark')\n}\n\n/**\n * applyCssVars(vars)\n * ------------------\n * Injects CSS variables into the document root (`<html>`).\n *\n * This is how the library exposes theme tokens as CSS variables.\n * Components can then use `var(--px-...)` in styles.\n *\n * Example:\n * ```ts\n * applyCssVars({ '--px-bg': '#fff', '--px-text-primary': '#111' })\n * ```\n *\n * Behavior:\n * - Ignores `null` / `undefined` values.\n * - Converts all values to string before applying.\n *\n * SSR:\n * - No-op on the server (when `document` is undefined).\n */\nexport function applyCssVars(vars: CSSVarMap) {\n if (typeof document === 'undefined') return\n const root = document.documentElement\n\n for (const [key, value] of Object.entries(vars)) {\n if (value == null) continue\n root.style.setProperty(key, String(value))\n }\n}\n\n/**\n * getSystemThemeName()\n * --------------------\n * Returns the current OS/browser color scheme preference.\n *\n * It reads `prefers-color-scheme: dark` using `window.matchMedia`.\n *\n * Returns:\n * - `\"dark\"` if the user prefers dark mode\n * - `\"light\"` otherwise\n *\n * SSR:\n * - Returns `\"light\"` on the server (safe default).\n */\nexport function getSystemThemeName(): 'light' | 'dark' {\n if (typeof window === 'undefined') return 'light'\n const prefersDark =\n window.matchMedia?.('(prefers-color-scheme: dark)').matches ?? false\n return prefersDark ? 'dark' : 'light'\n}\n\n/**\n * watchSystemTheme(onChange)\n * --------------------------\n * Subscribes to changes in OS/browser theme preference.\n *\n * Use this when your selected mode is `\"system\"` so the app immediately reacts\n * when the user changes their OS theme.\n *\n * - Calls `onChange('light' | 'dark')` whenever the preference changes.\n * - Returns an `unsubscribe()` function.\n *\n * Implementation details:\n * - Uses `matchMedia('(prefers-color-scheme: dark)')`.\n * - Supports both modern `addEventListener('change', ...)` and legacy Safari\n * `addListener(...)` APIs.\n *\n * SSR:\n * - Returns a no-op unsubscribe function on the server.\n */\nexport function watchSystemTheme(onChange: (name: 'light' | 'dark') => void) {\n if (typeof window === 'undefined') return () => {}\n\n const mq = window.matchMedia('(prefers-color-scheme: dark)')\n\n const handler = () => onChange(mq.matches ? 'dark' : 'light')\n\n // Optional: sync immediately on subscribe\n handler()\n\n // Modern browsers\n if (mq.addEventListener) {\n mq.addEventListener('change', handler)\n return () => mq.removeEventListener('change', handler)\n }\n\n // Legacy Safari\n mq.addListener(handler as any)\n return () => mq.removeListener(handler as any)\n}\n\n/**\n * Resolves an effective theme name from a mode.\n */\nexport function resolveName(mode: ThemeMode): string {\n if (mode !== 'system') return mode\n return getSystemThemeName()\n}\n\n/**\n * Builds a registry of user theme patches.\n */\nexport function buildRegistry(\n userThemes?: Partial<ThemeRegistry>\n): ThemeRegistry {\n return {\n light: {},\n dark: {},\n ...(userThemes ?? {})\n } as ThemeRegistry\n}\n\n/**\n * Builds the final resolved theme tokens.\n */\nexport function buildTheme(\n registry: ThemeRegistry,\n resolvedName: string,\n override?: Partial<ThemeTokens>\n): ThemeTokens {\n const base: ThemeTokens =\n resolvedName === 'dark'\n ? (defaultThemes.dark as ThemeTokens)\n : (defaultThemes.light as ThemeTokens)\n\n const selectedPatch = (registry[resolvedName] ?? registry.light) as any\n\n const merged = deepMerge(base, selectedPatch)\n return deepMerge(merged, override)\n}\n\nexport function isThemeMode(value: unknown): value is ThemeMode {\n return typeof value === 'string' && value.length > 0\n}\n\nexport function getLocalStorageSafe(): Storage | null {\n if (typeof window === 'undefined') return null\n try {\n return window.localStorage\n } catch {\n return null\n }\n}\n","// Types\nimport type { CSSVarMap } from './general'\nimport type { ThemeTokens } from '../types'\n\n/**\n * themeToCssVars(theme)\n * ---------------------\n * Converts a resolved `ThemeTokens` object into a CSS variable map (`CSSVarMap`).\n *\n * The ThemeProvider uses this function to inject `--px-*` variables into the\n * document root (`<html>`). Components can then rely on stable CSS variables,\n * making them framework-agnostic and compatible with Tailwind (via `.dark`).\n *\n * Why CSS variables?\n * - They are fast (native to the browser)\n * - They work across any styling strategy (inline styles, CSS modules, Tailwind, etc.)\n * - They enable dynamic theme switching without rerendering every component\n *\n * Requirements / Assumptions:\n * - The input `theme` must be **fully resolved** (i.e. complete `ThemeTokens`).\n * The ThemeProvider is responsible for merging partial theme patches on top\n * of a complete base theme (light/dark defaults).\n *\n * Variable naming:\n * - All variables are prefixed with `--px-` to avoid collisions.\n * - Tokens are grouped by category (colors, surfaces, borders, text, spacing, radius, typography, shadows).\n *\n * Notes:\n * - Spacing/radius/fontSize tokens are stored as numbers (e.g. `16`), which is valid\n * for CSS variables. When consuming them, you can:\n * - append `px` in JS (`${var}px`), or\n * - store them as strings here (e.g. `\"16px\"`) if you prefer.\n *\n * Example usage (component styles):\n * ```ts\n * const styles = {\n * background: 'var(--px-bg)',\n * color: 'var(--px-text-primary)',\n * borderColor: 'var(--px-border-primary)',\n * }\n * ```\n *\n * Example usage (Tailwind config / CSS):\n * ```css\n * .card {\n * background: var(--px-surface);\n * color: var(--px-text-primary);\n * border: 1px solid var(--px-border-primary);\n * }\n * ```\n */\nexport function themeToCssVars(theme: ThemeTokens): CSSVarMap {\n return {\n /**\n * Colors (semantic)\n * -----------------\n * Brand + intent colors. Prefer using these instead of raw palette values.\n */\n '--px-color-primary': theme.colors.primary,\n '--px-color-secondary': theme.colors.secondary,\n '--px-color-success': theme.colors.success,\n '--px-color-warning': theme.colors.warning,\n '--px-color-error': theme.colors.error,\n '--px-color-info': theme.colors.info,\n\n /**\n * Surfaces\n * --------\n * Neutral surfaces for layouts and elevated containers.\n */\n '--px-bg': theme.colors.background,\n '--px-surface': theme.colors.surface,\n\n /**\n * Borders\n * -------\n * Divider and outline colors.\n */\n '--px-border-primary': theme.colors.border.primary,\n '--px-border-secondary': theme.colors.border.secondary,\n\n /**\n * Text\n * ----\n * Text colors for different emphasis levels.\n */\n '--px-text-primary': theme.colors.text.primary,\n '--px-text-secondary': theme.colors.text.secondary,\n '--px-text-disabled': theme.colors.text.disabled,\n '--px-text-inverse': theme.colors.text.inverse,\n\n /**\n * Spacing scale\n * -------------\n * Numeric spacing tokens (commonly used as px in the component factories).\n */\n '--px-space-xs': theme.spacing.xs,\n '--px-space-sm': theme.spacing.sm,\n '--px-space-md': theme.spacing.md,\n '--px-space-lg': theme.spacing.lg,\n '--px-space-xl': theme.spacing.xl,\n '--px-space-2xl': theme.spacing['2xl'],\n\n /**\n * Border radius scale\n * -------------------\n * Numeric radius tokens (commonly used as px).\n */\n '--px-radius-none': theme.borderRadius.none,\n '--px-radius-sm': theme.borderRadius.sm,\n '--px-radius-md': theme.borderRadius.md,\n '--px-radius-lg': theme.borderRadius.lg,\n '--px-radius-full': theme.borderRadius.full,\n\n /**\n * Typography scale\n * ----------------\n * Font sizes and font weights.\n */\n '--px-fs-xs': theme.fontSize.xs,\n '--px-fs-sm': theme.fontSize.sm,\n '--px-fs-md': theme.fontSize.md,\n '--px-fs-lg': theme.fontSize.lg,\n '--px-fs-xl': theme.fontSize.xl,\n '--px-fs-2xl': theme.fontSize['2xl'],\n\n '--px-fw-normal': theme.fontWeight.normal,\n '--px-fw-medium': theme.fontWeight.medium,\n '--px-fw-semibold': theme.fontWeight.semibold,\n '--px-fw-bold': theme.fontWeight.bold,\n\n /**\n * Shadows\n * -------\n * CSS shadow strings for elevation.\n */\n '--px-shadow-sm': theme.shadows.sm,\n '--px-shadow-md': theme.shadows.md,\n '--px-shadow-lg': theme.shadows.lg,\n '--px-shadow-xl': theme.shadows.xl\n }\n}\n","/** biome-ignore-all lint/suspicious/noExplicitAny: <Not needed> */\n\n// External Libraries\nimport { useMemo, useState, useEffect, useContext, createContext } from 'react'\n\n// Utils\nimport {\n buildTheme,\n isThemeMode,\n resolveName,\n applyCssVars,\n buildRegistry,\n themeToCssVars,\n applyThemeClass,\n watchSystemTheme,\n getLocalStorageSafe\n} from './utils'\n\n// Types\nimport type { ThemeMode, ThemeContextData, ThemeProviderProps } from './types'\n\nexport * from './types'\n\n/**\n * Theme Context\n * -------------\n * Internal context used by `ThemeProvider` and consumed by `useTheme()`.\n *\n * The value is always non-null inside a `<ThemeProvider />`.\n */\nconst ThemeContext = createContext<ThemeContextData | null>(null)\n\n/**\n * ThemeProvider\n * -------------\n * Provides theme state + resolved theme tokens to your app.\n */\nexport const ThemeProvider: React.FC<ThemeProviderProps> = ({\n themes,\n children,\n override,\n persistence,\n persist = false,\n defaultMode = 'system',\n storageKey = 'px-theme'\n}) => {\n /**\n * Registry of user patches (stable unless `themes` changes).\n */\n const registry = useMemo(() => buildRegistry(themes), [themes])\n\n // States\n /**\n * Selected mode (with optional persistence).\n *\n * Priority:\n * 1) `persistence` adapter (advanced)\n * 2) `persist === true` + localStorage (quick)\n * 3) `defaultMode`\n */\n const [mode, setMode] = useState<ThemeMode>(makeInitialMode)\n\n /**\n * Loading flag (mainly useful if consumers want to wait for first mount).\n */\n const [isLoading, setLoading] = useState(true)\n\n // UseEffects\n useEffect(() => {\n setLoading(false)\n }, [])\n\n /**\n * Keep in sync with OS when mode === \"system\".\n */\n useEffect(() => {\n if (typeof window === 'undefined') return\n if (mode !== 'system') return\n\n return watchSystemTheme(() => {\n setMode('system')\n })\n }, [mode])\n\n /**\n * Resolved name is the actual currently applied theme name.\n * If `mode === \"system\"`, it becomes \"light\" or \"dark\".\n */\n const resolvedName = useMemo(() => {\n if (typeof window === 'undefined') return mode === 'system' ? 'light' : mode\n return resolveName(mode)\n }, [mode])\n\n /**\n * Build final resolved theme tokens (always complete).\n */\n const theme = useMemo(\n () => buildTheme(registry, resolvedName, override),\n [registry, resolvedName, override]\n )\n\n /**\n * Apply theme effects:\n * - toggles `.dark` class on <html> (Tailwind)\n * - injects --px-* variables on <html>\n */\n useEffect(() => {\n if (typeof window === 'undefined') return\n applyThemeClass(resolvedName === 'dark' ? 'dark' : 'light')\n applyCssVars(themeToCssVars(theme))\n }, [resolvedName, theme])\n\n /**\n * Persist mode changes (optional).\n *\n * We persist the selected `mode` (including \"system\"), not the resolvedName.\n *\n * Priority:\n * - If `persistence` exists, use it.\n * - Else if `persist === true`, use localStorage.\n */\n useEffect(() => {\n // advanced adapter\n if (persistence) {\n try {\n persistence.set(mode)\n } catch {\n // ignore\n }\n return\n }\n\n // quick localStorage mode\n if (!persist) return\n const ls = getLocalStorageSafe()\n if (!ls) return\n\n try {\n ls.setItem(storageKey, mode)\n } catch {\n // ignore\n }\n }, [mode, persist, storageKey, persistence])\n\n // Functions\n function makeInitialMode() {\n // 1) advanced adapter\n if (persistence) {\n try {\n const saved = persistence.get()\n return (saved ?? defaultMode) as ThemeMode\n } catch {\n return defaultMode\n }\n }\n\n // 2) quick localStorage mode\n // if (persist) {\n const ls = getLocalStorageSafe()\n if (!ls) return defaultMode\n const raw = ls.getItem(storageKey)\n return isThemeMode(raw) ? raw : defaultMode\n // }\n\n // 3) fallback\n // return defaultMode\n }\n\n /**\n * Sets the selected theme mode.\n */\n function setTheme(next: ThemeMode) {\n setMode(next)\n }\n\n /**\n * Toggles between two theme names (defaults to \"light\" and \"dark\").\n */\n function toggleTheme(a: string = 'light', b: string = 'dark') {\n setMode(resolvedName === a ? b : a)\n }\n\n return (\n <ThemeContext.Provider\n value={{ mode, resolvedName, theme, isLoading, setTheme, toggleTheme }}\n >\n {children}\n </ThemeContext.Provider>\n )\n}\n\n/**\n * useTheme()\n *\n * Returns the current theme context.\n *\n * @throws If called outside of `<ThemeProvider />`.\n */\nexport function useTheme(): ThemeContextData {\n const ctx = useContext(ThemeContext)\n if (!ctx) throw new Error('useTheme must be used within a ThemeProvider')\n return ctx\n}\n"],"mappings":";;;;AASA,SAAgB,UAAa,MAAS,UAA8B;AAClE,KAAI,aAAa,OAAW,QAAO,MAAM,KAAK;AAE9C,KAAI,CAAC,cAAc,KAAK,IAAI,CAAC,cAAc,SAAS,CAClD,QAAO,MAAM,SAAc;CAG7B,MAAMA,SAAc,MAAM,QAAQ,KAAK,GAAG,EAAE,GAAG,EAAE;CAEjD,MAAM,WAAW,OAAO,KAAK,KAAY;CACzC,MAAM,eAAe,OAAO,KAAK,SAAgB;CAEjD,MAAM,UAAU,MAAM,KAAK,IAAI,IAAI,CAAC,GAAG,UAAU,GAAG,aAAa,CAAC,CAAC;AAEnE,MAAK,MAAM,KAAK,SAAS;EACvB,MAAM,UAAW,KAAa;EAC9B,MAAM,cAAe,SAAiB;AAEtC,MAAI,gBAAgB,QAAW;AAC7B,UAAO,KAAK,MAAM,QAAQ;AAC1B;;AAGF,MAAI,cAAc,QAAQ,IAAI,cAAc,YAAY,EAAE;AACxD,UAAO,KAAK,UAAU,SAAS,YAAY;AAC3C;;AAGF,SAAO,KAAK,MAAM,YAAY;;AAGhC,QAAO;;AAGT,SAAS,cAAc,GAAkC;AACvD,QAAO,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC,MAAM,QAAQ,EAAE;;AAG1D,SAAS,MAAS,GAAS;AACzB,KAAI,MAAM,UAAa,MAAM,KAAM,QAAO;AAC1C,KAAI,MAAM,QAAQ,EAAE,CAAE,QAAO,EAAE,KAAI,SAAQ,MAAM,KAAK,CAAC;AACvD,KAAI,cAAc,EAAE,EAAE;EACpB,MAAMC,MAAW,EAAE;AACnB,OAAK,MAAM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