@vaneui/ui 0.2.1-alpha.20250812182914.4e44540 → 0.2.1-alpha.20250813170000.4050860
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/components/themeContext.d.ts +3 -1
- package/dist/index.esm.js +9 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -126,13 +126,15 @@ export type ThemeExtraClasses = {
|
|
|
126
126
|
label?: Partial<StringValueKeys<LabelProps>>;
|
|
127
127
|
img?: Partial<StringValueKeys<ImgProps>>;
|
|
128
128
|
};
|
|
129
|
+
export type MergeStrategy = 'merge' | 'replace';
|
|
129
130
|
export interface ThemeProviderProps {
|
|
130
131
|
children: React.ReactNode;
|
|
131
132
|
theme?: PartialTheme;
|
|
132
133
|
themeDefaults?: ThemeDefaults;
|
|
133
134
|
extraClasses?: ThemeExtraClasses;
|
|
134
135
|
themeOverride?: (theme: ThemeProps) => ThemeProps;
|
|
136
|
+
mergeStrategy?: MergeStrategy;
|
|
135
137
|
}
|
|
136
|
-
export declare function ThemeProvider({ children, theme: themeObject, themeDefaults, extraClasses, themeOverride }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
138
|
+
export declare function ThemeProvider({ children, theme: themeObject, themeDefaults, extraClasses, themeOverride, mergeStrategy }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
137
139
|
export declare function useTheme(): ThemeProps;
|
|
138
140
|
export {};
|
package/dist/index.esm.js
CHANGED
|
@@ -4855,12 +4855,17 @@ function applyExtraClassesRecursively(themeObject, extraClassesObject) {
|
|
|
4855
4855
|
}
|
|
4856
4856
|
}
|
|
4857
4857
|
const ThemeContext = createContext(defaultTheme);
|
|
4858
|
-
function ThemeProvider({ children, theme: themeObject = {}, themeDefaults, extraClasses, themeOverride }) {
|
|
4858
|
+
function ThemeProvider({ children, theme: themeObject = {}, themeDefaults, extraClasses, themeOverride, mergeStrategy = 'merge' }) {
|
|
4859
|
+
const parentTheme = useContext(ThemeContext);
|
|
4859
4860
|
const mergedTheme = useMemo(() => {
|
|
4861
|
+
// Determine the base theme based on merge strategy
|
|
4862
|
+
const baseTheme = mergeStrategy === 'replace'
|
|
4863
|
+
? defaultTheme
|
|
4864
|
+
: parentTheme;
|
|
4860
4865
|
// Always start with a deep clone to ensure isolation
|
|
4861
4866
|
let finalTheme = themeObject
|
|
4862
|
-
? deepMerge(deepClone(
|
|
4863
|
-
: deepClone(
|
|
4867
|
+
? deepMerge(deepClone(baseTheme), themeObject)
|
|
4868
|
+
: deepClone(baseTheme);
|
|
4864
4869
|
if (typeof themeOverride === 'function') {
|
|
4865
4870
|
const themeToModify = deepClone(finalTheme);
|
|
4866
4871
|
finalTheme = themeOverride(themeToModify);
|
|
@@ -4878,7 +4883,7 @@ function ThemeProvider({ children, theme: themeObject = {}, themeDefaults, extra
|
|
|
4878
4883
|
applyExtraClassesRecursively(finalTheme, extraClasses);
|
|
4879
4884
|
}
|
|
4880
4885
|
return finalTheme;
|
|
4881
|
-
}, [themeObject, themeDefaults, extraClasses, themeOverride]);
|
|
4886
|
+
}, [themeObject, themeDefaults, extraClasses, themeOverride, mergeStrategy, parentTheme]);
|
|
4882
4887
|
return (jsx(ThemeContext.Provider, { value: mergedTheme, children: children }));
|
|
4883
4888
|
}
|
|
4884
4889
|
function useTheme() {
|