@yamada-ui/core
Advanced tools
Comparing version 0.4.3 to 0.5.0
@@ -37,4 +37,5 @@ "use strict"; | ||
ColorModeScript: () => ColorModeScript, | ||
GlobalStyle: () => GlobalStyle, | ||
ResetStyle: () => ResetStyle, | ||
STORAGE_KEY: () => STORAGE_KEY, | ||
StylesProvider: () => StylesProvider, | ||
ThemeProvider: () => ThemeProvider, | ||
@@ -81,3 +82,2 @@ analyzeBreakpoints: () => analyzeBreakpoints, | ||
useMultiComponentStyle: () => useMultiComponentStyle, | ||
useStyles: () => useStyles, | ||
useTheme: () => useTheme | ||
@@ -1223,11 +1223,28 @@ }); | ||
var import_react3 = require("@emotion/react"); | ||
var import_utils9 = require("@yamada-ui/utils"); | ||
var import_react4 = require("react"); | ||
var import_jsx_runtime = require("react/jsx-runtime"); | ||
var ThemeProvider = ({ | ||
theme, | ||
themeScheme, | ||
changeThemeScheme, | ||
theme: initialTheme, | ||
config, | ||
children | ||
}) => { | ||
const [themeScheme, setThemeScheme] = (0, import_react4.useState)( | ||
config == null ? void 0 : config.initialThemeScheme | ||
); | ||
const theme = (0, import_react4.useMemo)( | ||
() => (0, import_utils9.isUndefined)(themeScheme) ? initialTheme : initialTheme[themeScheme], | ||
[initialTheme, themeScheme] | ||
); | ||
const changeThemeScheme = (0, import_react4.useCallback)( | ||
(themeSchemeOrFunc) => { | ||
if ((0, import_utils9.isUndefined)(themeScheme)) | ||
throw Error( | ||
"changeThemeScheme: `themeScheme` is undefined. Seems you forgot to wrap your config in `initialThemeScheme`" | ||
); | ||
const nextThemeScheme = (0, import_utils9.runIfFunc)(themeSchemeOrFunc, themeScheme); | ||
setThemeScheme(nextThemeScheme); | ||
}, | ||
[themeScheme] | ||
); | ||
const computedTheme = (0, import_react4.useMemo)(() => transformTheme(theme, config), [theme, config]); | ||
@@ -1242,2 +1259,32 @@ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react3.ThemeProvider, { theme: { themeScheme, changeThemeScheme, ...computedTheme }, children: [ | ||
}; | ||
var ResetStyle = () => { | ||
const { colorMode } = useColorMode(); | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
import_react3.Global, | ||
{ | ||
styles: (theme) => { | ||
let style = (0, import_utils9.getMemoizedObject)(theme, "styles.resetStyle", {}); | ||
const computedStyle = (0, import_utils9.runIfFunc)(style, { theme, colorMode }); | ||
if (!computedStyle) | ||
return void 0; | ||
return css(computedStyle)(theme); | ||
} | ||
} | ||
); | ||
}; | ||
var GlobalStyle = () => { | ||
const { colorMode } = useColorMode(); | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( | ||
import_react3.Global, | ||
{ | ||
styles: (theme) => { | ||
let style = (0, import_utils9.getMemoizedObject)(theme, "styles.globalStyle", {}); | ||
const computedStyle = (0, import_utils9.runIfFunc)(style, { theme, colorMode }); | ||
if (!computedStyle) | ||
return void 0; | ||
return css(computedStyle)(theme); | ||
} | ||
} | ||
); | ||
}; | ||
var useTheme = () => { | ||
@@ -1255,3 +1302,3 @@ const { themeScheme, changeThemeScheme, ...theme } = (0, import_react4.useContext)( | ||
// src/providers/color-scheme-provider.tsx | ||
var import_utils9 = require("@yamada-ui/utils"); | ||
var import_utils10 = require("@yamada-ui/utils"); | ||
var import_react5 = require("react"); | ||
@@ -1441,3 +1488,3 @@ | ||
}, [changeColorMode, resolvedValue]); | ||
(0, import_utils9.useSafeLayoutEffect)(() => { | ||
(0, import_utils10.useSafeLayoutEffect)(() => { | ||
if (initialColorMode === "system") | ||
@@ -1466,4 +1513,4 @@ setResolvedColorMode(getSystemColorMode()); | ||
colorMode: value != null ? value : resolvedValue, | ||
changeColorMode: value ? import_utils9.noop : changeColorMode, | ||
toggleScheme: value ? import_utils9.noop : toggleScheme, | ||
changeColorMode: value ? import_utils10.noop : changeColorMode, | ||
toggleScheme: value ? import_utils10.noop : toggleScheme, | ||
forced: value !== void 0 | ||
@@ -1486,9 +1533,2 @@ }), | ||
// src/providers/styles-provider.tsx | ||
var import_utils10 = require("@yamada-ui/utils"); | ||
var [StylesProvider, useStyles] = (0, import_utils10.createContext)({ | ||
name: "StylesContext", | ||
errorMessage: "useStyles: `styles` is undefined. Seems you forgot to wrap the components in `<StylesProvider />` " | ||
}); | ||
// src/styled.ts | ||
@@ -1599,4 +1639,5 @@ var _a; | ||
ColorModeScript, | ||
GlobalStyle, | ||
ResetStyle, | ||
STORAGE_KEY, | ||
StylesProvider, | ||
ThemeProvider, | ||
@@ -1643,4 +1684,3 @@ analyzeBreakpoints, | ||
useMultiComponentStyle, | ||
useStyles, | ||
useTheme | ||
}); |
{ | ||
"name": "@yamada-ui/core", | ||
"version": "0.4.3", | ||
"version": "0.5.0", | ||
"description": "Yamada UI core", | ||
@@ -45,4 +45,4 @@ "keywords": [ | ||
"csstype": "^3.1.1", | ||
"@yamada-ui/utils": "0.1.2", | ||
"@yamada-ui/portal": "0.2.1" | ||
"@yamada-ui/utils": "0.1.3", | ||
"@yamada-ui/portal": "0.2.2" | ||
}, | ||
@@ -49,0 +49,0 @@ "devDependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
290310
17
5682
+ Added@yamada-ui/portal@0.2.2(transitive)
+ Added@yamada-ui/utils@0.1.3(transitive)
- Removed@yamada-ui/portal@0.2.1(transitive)
- Removed@yamada-ui/utils@0.1.2(transitive)
Updated@yamada-ui/portal@0.2.2
Updated@yamada-ui/utils@0.1.3