@chakra-ui/theme-utils
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -26,2 +26,3 @@ "use strict"; | ||
__export(src_exports, { | ||
extendBaseTheme: () => extendBaseTheme, | ||
extendTheme: () => extendTheme, | ||
@@ -45,12 +46,16 @@ mergeThemeOverride: () => mergeThemeOverride, | ||
} | ||
function extendTheme(...extensions) { | ||
let overrides = [...extensions]; | ||
let baseTheme = extensions[extensions.length - 1]; | ||
if ((0, import_theme.isChakraTheme)(baseTheme) && overrides.length > 1) { | ||
overrides = overrides.slice(0, overrides.length - 1); | ||
} else { | ||
baseTheme = import_theme.theme; | ||
} | ||
return pipe(...overrides.map((extension) => (prevTheme) => isFunction(extension) ? extension(prevTheme) : mergeThemeOverride(prevTheme, extension)))(baseTheme); | ||
} | ||
var createExtendTheme = (theme2) => { | ||
return function extendTheme2(...extensions) { | ||
let overrides = [...extensions]; | ||
let activeTheme = extensions[extensions.length - 1]; | ||
if ((0, import_theme.isChakraTheme)(activeTheme) && overrides.length > 1) { | ||
overrides = overrides.slice(0, overrides.length - 1); | ||
} else { | ||
activeTheme = theme2; | ||
} | ||
return pipe(...overrides.map((extension) => (prevTheme) => isFunction(extension) ? extension(prevTheme) : mergeThemeOverride(prevTheme, extension)))(activeTheme); | ||
}; | ||
}; | ||
var extendTheme = createExtendTheme(import_theme.theme); | ||
var extendBaseTheme = createExtendTheme(import_theme.baseTheme); | ||
function mergeThemeOverride(...overrides) { | ||
@@ -169,2 +174,3 @@ return (0, import_lodash.default)({}, ...overrides, mergeThemeCustomizer); | ||
0 && (module.exports = { | ||
extendBaseTheme, | ||
extendTheme, | ||
@@ -171,0 +177,0 @@ mergeThemeOverride, |
@@ -20,3 +20,4 @@ import { Theme, ChakraTheme, ComponentDefaultProps } from '@chakra-ui/theme'; | ||
declare type BaseThemeWithExtensions<BaseTheme extends ChakraTheme, Extensions extends readonly [...any]> = BaseTheme & (Extensions extends [infer L, ...infer R] ? L extends AnyFunction ? ReturnType<L> & BaseThemeWithExtensions<BaseTheme, R> : L & BaseThemeWithExtensions<BaseTheme, R> : Extensions); | ||
declare function extendTheme(...extensions: Array<Record<string, any> | ((theme: Record<string, any>) => Record<string, any>)>): Record<string, any>; | ||
declare const extendTheme: (...extensions: (Record<string, any> | ((theme: Record<string, any>) => Record<string, any>))[]) => Record<string, any>; | ||
declare const extendBaseTheme: (...extensions: (Record<string, any> | ((theme: Record<string, any>) => Record<string, any>))[]) => Record<string, any>; | ||
declare function mergeThemeOverride(...overrides: any[]): any; | ||
@@ -44,2 +45,2 @@ | ||
export { BaseThemeWithExtensions, DeepPartial, ThemeExtension, ThemeOverride, extendTheme, mergeThemeOverride, withDefaultColorScheme, withDefaultProps, withDefaultSize, withDefaultVariant }; | ||
export { BaseThemeWithExtensions, DeepPartial, ThemeExtension, ThemeOverride, extendBaseTheme, extendTheme, mergeThemeOverride, withDefaultColorScheme, withDefaultProps, withDefaultSize, withDefaultVariant }; |
// src/extend-theme.ts | ||
import { theme, isChakraTheme } from "@chakra-ui/theme"; | ||
import { | ||
theme, | ||
baseTheme, | ||
isChakraTheme | ||
} from "@chakra-ui/theme"; | ||
import mergeWith from "lodash.mergewith"; | ||
@@ -10,12 +14,16 @@ function isFunction(value) { | ||
} | ||
function extendTheme(...extensions) { | ||
let overrides = [...extensions]; | ||
let baseTheme = extensions[extensions.length - 1]; | ||
if (isChakraTheme(baseTheme) && overrides.length > 1) { | ||
overrides = overrides.slice(0, overrides.length - 1); | ||
} else { | ||
baseTheme = theme; | ||
} | ||
return pipe(...overrides.map((extension) => (prevTheme) => isFunction(extension) ? extension(prevTheme) : mergeThemeOverride(prevTheme, extension)))(baseTheme); | ||
} | ||
var createExtendTheme = (theme2) => { | ||
return function extendTheme2(...extensions) { | ||
let overrides = [...extensions]; | ||
let activeTheme = extensions[extensions.length - 1]; | ||
if (isChakraTheme(activeTheme) && overrides.length > 1) { | ||
overrides = overrides.slice(0, overrides.length - 1); | ||
} else { | ||
activeTheme = theme2; | ||
} | ||
return pipe(...overrides.map((extension) => (prevTheme) => isFunction(extension) ? extension(prevTheme) : mergeThemeOverride(prevTheme, extension)))(activeTheme); | ||
}; | ||
}; | ||
var extendTheme = createExtendTheme(theme); | ||
var extendBaseTheme = createExtendTheme(baseTheme); | ||
function mergeThemeOverride(...overrides) { | ||
@@ -133,2 +141,3 @@ return mergeWith({}, ...overrides, mergeThemeCustomizer); | ||
export { | ||
extendBaseTheme, | ||
extendTheme, | ||
@@ -135,0 +144,0 @@ mergeThemeOverride, |
{ | ||
"name": "@chakra-ui/theme-utils", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "", | ||
@@ -30,10 +30,10 @@ "keywords": [ | ||
"devDependencies": { | ||
"@chakra-ui/shared-utils": "2.0.3", | ||
"@types/lodash.mergewith": "4.6.6", | ||
"clean-package": "2.1.1" | ||
"clean-package": "2.1.1", | ||
"@chakra-ui/shared-utils": "2.0.3" | ||
}, | ||
"dependencies": { | ||
"@chakra-ui/styled-system": "2.3.5", | ||
"@chakra-ui/theme": "2.2.1", | ||
"lodash.mergewith": "4.6.2" | ||
"lodash.mergewith": "4.6.2", | ||
"@chakra-ui/styled-system": "2.4.0", | ||
"@chakra-ui/theme": "2.2.2" | ||
}, | ||
@@ -40,0 +40,0 @@ "module": "dist/index.esm.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15880
354
+ Added@chakra-ui/styled-system@2.4.0(transitive)
+ Added@chakra-ui/theme@2.2.2(transitive)
+ Added@chakra-ui/theme-tools@2.0.14(transitive)
+ Addedcolor2k@2.0.3(transitive)
- Removed@chakra-ui/styled-system@2.3.5(transitive)
- Removed@chakra-ui/theme@2.2.1(transitive)
- Removed@chakra-ui/theme-tools@2.0.13(transitive)
- Removed@ctrl/tinycolor@3.6.1(transitive)
Updated@chakra-ui/theme@2.2.2