@chakra-ui/system
Advanced tools
Comparing version
# Change Log | ||
## 1.7.3 | ||
### Patch Changes | ||
- [`01c913309`](https://github.com/chakra-ui/chakra-ui/commit/01c913309819c342806307291d2d60aea0122ecf) | ||
[#4611](https://github.com/chakra-ui/chakra-ui/pull/4611) Thanks | ||
[@segunadebayo](https://github.com/segunadebayo)! - Update `useStyleConfig` to | ||
read parts array from the new anatomy class | ||
- Updated dependencies []: | ||
- @chakra-ui/color-mode@1.1.12 | ||
## 1.7.2 | ||
@@ -4,0 +16,0 @@ |
@@ -20,3 +20,3 @@ "use strict"; | ||
function useStyleConfig(themeKey, props, opts) { | ||
var _styleConfig$defaultP, _opts2; | ||
var _styleConfig$defaultP; | ||
@@ -50,28 +50,27 @@ if (props === void 0) { | ||
var stylesRef = (0, _react.useRef)({}); | ||
return (0, _react.useMemo)(function () { | ||
if (styleConfig) { | ||
var _styleConfig$baseStyl, _styleConfig$variants, _styleConfig$variants2, _styleConfig$sizes$me, _styleConfig$sizes, _opts; | ||
var baseStyles = (0, _utils.runIfFn)((_styleConfig$baseStyl = styleConfig.baseStyle) != null ? _styleConfig$baseStyl : {}, mergedProps); | ||
var variants = (0, _utils.runIfFn)((_styleConfig$variants = (_styleConfig$variants2 = styleConfig.variants) == null ? void 0 : _styleConfig$variants2[mergedProps.variant]) != null ? _styleConfig$variants : {}, mergedProps); | ||
var sizes = (0, _utils.runIfFn)((_styleConfig$sizes$me = (_styleConfig$sizes = styleConfig.sizes) == null ? void 0 : _styleConfig$sizes[mergedProps.size]) != null ? _styleConfig$sizes$me : {}, mergedProps); | ||
var styles = (0, _utils.mergeWith)({}, baseStyles, sizes, variants); | ||
if (styleConfig) { | ||
var _styleConfig$baseStyl, _styleConfig$variants, _styleConfig$variants2, _styleConfig$sizes$me, _styleConfig$sizes, _opts; | ||
if ((_opts = opts) != null && _opts.isMultiPart && styleConfig.parts) { | ||
styleConfig.parts.forEach(function (part) { | ||
var _styles$part; | ||
var baseStyles = (0, _utils.runIfFn)((_styleConfig$baseStyl = styleConfig.baseStyle) != null ? _styleConfig$baseStyl : {}, mergedProps); | ||
var variants = (0, _utils.runIfFn)((_styleConfig$variants = (_styleConfig$variants2 = styleConfig.variants) == null ? void 0 : _styleConfig$variants2[mergedProps.variant]) != null ? _styleConfig$variants : {}, mergedProps); | ||
var sizes = (0, _utils.runIfFn)((_styleConfig$sizes$me = (_styleConfig$sizes = styleConfig.sizes) == null ? void 0 : _styleConfig$sizes[mergedProps.size]) != null ? _styleConfig$sizes$me : {}, mergedProps); | ||
var styles = (0, _utils.mergeWith)({}, baseStyles, sizes, variants); | ||
styles[part] = (_styles$part = styles[part]) != null ? _styles$part : {}; | ||
}); | ||
} | ||
if ((_opts = opts) != null && _opts.isMultiPart && styleConfig.parts) { | ||
styleConfig.parts.forEach(function (part) { | ||
var _styles$part; | ||
var isStyleEqual = (0, _reactFastCompare["default"])(stylesRef.current, styles); | ||
styles[part] = (_styles$part = styles[part]) != null ? _styles$part : {}; | ||
}); | ||
} | ||
if (!isStyleEqual) { | ||
stylesRef.current = styles; | ||
} | ||
var isStyleEqual = (0, _reactFastCompare["default"])(stylesRef.current, styles); | ||
if (!isStyleEqual) { | ||
stylesRef.current = styles; | ||
} | ||
} | ||
return stylesRef.current; | ||
}, [styleConfig, mergedProps, (_opts2 = opts) == null ? void 0 : _opts2.isMultiPart]); | ||
return stylesRef.current; | ||
} | ||
@@ -78,0 +77,0 @@ |
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
import { filterUndefined, memoizedGet as get, mergeWith, runIfFn, omit } from "@chakra-ui/utils"; | ||
import { useMemo, useRef } from "react"; | ||
import { useRef } from "react"; | ||
import isEqual from "react-fast-compare"; | ||
import { useChakra } from "./hooks"; | ||
export function useStyleConfig(themeKey, props, opts) { | ||
var _styleConfig$defaultP, _opts2; | ||
var _styleConfig$defaultP; | ||
@@ -38,28 +38,27 @@ if (props === void 0) { | ||
var stylesRef = useRef({}); | ||
return useMemo(() => { | ||
if (styleConfig) { | ||
var _styleConfig$baseStyl, _styleConfig$variants, _styleConfig$variants2, _styleConfig$sizes$me, _styleConfig$sizes, _opts; | ||
var baseStyles = runIfFn((_styleConfig$baseStyl = styleConfig.baseStyle) != null ? _styleConfig$baseStyl : {}, mergedProps); | ||
var variants = runIfFn((_styleConfig$variants = (_styleConfig$variants2 = styleConfig.variants) == null ? void 0 : _styleConfig$variants2[mergedProps.variant]) != null ? _styleConfig$variants : {}, mergedProps); | ||
var sizes = runIfFn((_styleConfig$sizes$me = (_styleConfig$sizes = styleConfig.sizes) == null ? void 0 : _styleConfig$sizes[mergedProps.size]) != null ? _styleConfig$sizes$me : {}, mergedProps); | ||
var styles = mergeWith({}, baseStyles, sizes, variants); | ||
if (styleConfig) { | ||
var _styleConfig$baseStyl, _styleConfig$variants, _styleConfig$variants2, _styleConfig$sizes$me, _styleConfig$sizes, _opts; | ||
if ((_opts = opts) != null && _opts.isMultiPart && styleConfig.parts) { | ||
styleConfig.parts.forEach(part => { | ||
var _styles$part; | ||
var baseStyles = runIfFn((_styleConfig$baseStyl = styleConfig.baseStyle) != null ? _styleConfig$baseStyl : {}, mergedProps); | ||
var variants = runIfFn((_styleConfig$variants = (_styleConfig$variants2 = styleConfig.variants) == null ? void 0 : _styleConfig$variants2[mergedProps.variant]) != null ? _styleConfig$variants : {}, mergedProps); | ||
var sizes = runIfFn((_styleConfig$sizes$me = (_styleConfig$sizes = styleConfig.sizes) == null ? void 0 : _styleConfig$sizes[mergedProps.size]) != null ? _styleConfig$sizes$me : {}, mergedProps); | ||
var styles = mergeWith({}, baseStyles, sizes, variants); | ||
styles[part] = (_styles$part = styles[part]) != null ? _styles$part : {}; | ||
}); | ||
} | ||
if ((_opts = opts) != null && _opts.isMultiPart && styleConfig.parts) { | ||
styleConfig.parts.forEach(part => { | ||
var _styles$part; | ||
var isStyleEqual = isEqual(stylesRef.current, styles); | ||
styles[part] = (_styles$part = styles[part]) != null ? _styles$part : {}; | ||
}); | ||
} | ||
if (!isStyleEqual) { | ||
stylesRef.current = styles; | ||
} | ||
var isStyleEqual = isEqual(stylesRef.current, styles); | ||
if (!isStyleEqual) { | ||
stylesRef.current = styles; | ||
} | ||
} | ||
return stylesRef.current; | ||
}, [styleConfig, mergedProps, (_opts2 = opts) == null ? void 0 : _opts2.isMultiPart]); | ||
return stylesRef.current; | ||
} | ||
@@ -66,0 +65,0 @@ export function useMultiStyleConfig(themeKey, props) { |
{ | ||
"name": "@chakra-ui/system", | ||
"version": "1.7.2", | ||
"version": "1.7.3", | ||
"description": "Chakra UI system primitives", | ||
@@ -58,3 +58,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@chakra-ui/color-mode": "1.1.11", | ||
"@chakra-ui/color-mode": "1.1.12", | ||
"@chakra-ui/react-utils": "1.1.2", | ||
@@ -61,0 +61,0 @@ "@chakra-ui/styled-system": "1.12.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
134276
-0.34%868
-0.46%+ Added
+ Added
- Removed
- Removed
Updated