@theme-ui/theme-provider
Advanced tools
Comparing version 0.3.1 to 0.3.2-alpha.10
@@ -1,2 +0,2 @@ | ||
import { jsx, useThemeUI, ThemeProvider } from '@theme-ui/core'; | ||
import { useThemeUI, jsx, ThemeProvider as ThemeProvider$1 } from '@theme-ui/core'; | ||
import { ColorModeProvider } from '@theme-ui/color-modes'; | ||
@@ -6,3 +6,21 @@ import { MDXProvider } from '@theme-ui/mdx'; | ||
var get = function (obj, key, def, p, undef) { | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
var get = function get(obj, key, def, p, undef) { | ||
key = key && key.split ? key.split('.') : [key]; | ||
@@ -52,2 +70,4 @@ | ||
borderColor: 'colors', | ||
caretColor: 'colors', | ||
columnRuleColor: 'colors', | ||
margin: 'space', | ||
@@ -123,3 +143,3 @@ marginTop: 'space', | ||
var positiveOrNegative = function (scale, value) { | ||
var positiveOrNegative = function positiveOrNegative(scale, value) { | ||
if (typeof value !== 'number' || value >= 0) { | ||
@@ -131,7 +151,3 @@ return get(scale, value, value); | ||
var n = get(scale, absolute, absolute); | ||
if (typeof n === 'string') { | ||
return '-' + n; | ||
} | ||
if (typeof n === 'string') return '-' + n; | ||
return n * -1; | ||
@@ -141,7 +157,8 @@ }; | ||
var transforms = ['margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginX', 'marginY', 'top', 'bottom', 'left', 'right'].reduce(function (acc, curr) { | ||
var obj; | ||
return Object.assign({}, acc, (obj = {}, obj[curr] = positiveOrNegative, obj)); | ||
var _extends2; | ||
return _extends({}, acc, (_extends2 = {}, _extends2[curr] = positiveOrNegative, _extends2)); | ||
}, {}); | ||
var responsive = function (styles) { | ||
var responsive = function responsive(styles) { | ||
return function (theme) { | ||
@@ -156,7 +173,4 @@ var next = {}; | ||
var value = typeof styles[key] === 'function' ? styles[key](theme) : styles[key]; | ||
if (value == null) continue; | ||
if (value == null) { | ||
continue; | ||
} | ||
if (!Array.isArray(value)) { | ||
@@ -176,7 +190,3 @@ next[key] = value; | ||
next[media] = next[media] || {}; | ||
if (value[i] == null) { | ||
continue; | ||
} | ||
if (value[i] == null) continue; | ||
next[media][key] = value[i]; | ||
@@ -190,6 +200,10 @@ } | ||
var css = function (args) { | ||
var css = function css(args) { | ||
return function (props) { | ||
if (props === void 0) { props = {}; } | ||
var theme = Object.assign({}, defaultTheme, props.theme || props); | ||
if (props === void 0) { | ||
props = {}; | ||
} | ||
var theme = _extends({}, defaultTheme, props.theme || props); | ||
var result = {}; | ||
@@ -205,3 +219,3 @@ var obj = typeof args === 'function' ? args(theme) : args; | ||
var variant = css(get(theme, val))(theme); | ||
result = Object.assign({}, result, variant); | ||
result = _extends({}, result, variant); | ||
continue; | ||
@@ -236,27 +250,28 @@ } | ||
var BodyStyles = function () { return jsx(Global, { | ||
styles: function (theme) { | ||
if (theme.useBodyStyles === false || theme.styles && !theme.styles.root) { return false; } | ||
var boxSizing = theme.useBorderBox === false ? null : 'border-box'; | ||
return css({ | ||
'*': { | ||
boxSizing: boxSizing | ||
}, | ||
body: { | ||
margin: 0, | ||
variant: 'styles.root' | ||
} | ||
})(theme); | ||
} | ||
}); }; | ||
var BodyStyles = function BodyStyles() { | ||
return jsx(Global, { | ||
styles: function styles(theme) { | ||
if (theme.useBodyStyles === false || theme.styles && !theme.styles.root) return false; | ||
var boxSizing = theme.useBorderBox === false ? null : 'border-box'; | ||
return css({ | ||
'*': { | ||
boxSizing: boxSizing | ||
}, | ||
body: { | ||
margin: 0, | ||
variant: 'styles.root' | ||
} | ||
})(theme); | ||
} | ||
}); | ||
}; | ||
var ThemeProvider$1 = function (ref) { | ||
var theme = ref.theme; | ||
var components = ref.components; | ||
var children = ref.children; | ||
var ThemeProvider = function ThemeProvider(_ref) { | ||
var theme = _ref.theme, | ||
components = _ref.components, | ||
children = _ref.children; | ||
var outer = useThemeUI(); | ||
if (typeof outer.setColorMode === 'function') { | ||
return jsx(ThemeProvider, { | ||
return jsx(ThemeProvider$1, { | ||
theme: theme | ||
@@ -269,3 +284,3 @@ }, jsx(MDXProvider, { | ||
return jsx(ThemeProvider, { | ||
return jsx(ThemeProvider$1, { | ||
theme: theme | ||
@@ -278,3 +293,3 @@ }, jsx(ColorModeProvider, null, jsx(BodyStyles), jsx(MDXProvider, { | ||
export { ThemeProvider$1 as ThemeProvider }; | ||
export { ThemeProvider }; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -6,3 +6,21 @@ var core = require('@theme-ui/core'); | ||
var get = function (obj, key, def, p, undef) { | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
var get = function get(obj, key, def, p, undef) { | ||
key = key && key.split ? key.split('.') : [key]; | ||
@@ -52,2 +70,4 @@ | ||
borderColor: 'colors', | ||
caretColor: 'colors', | ||
columnRuleColor: 'colors', | ||
margin: 'space', | ||
@@ -123,3 +143,3 @@ marginTop: 'space', | ||
var positiveOrNegative = function (scale, value) { | ||
var positiveOrNegative = function positiveOrNegative(scale, value) { | ||
if (typeof value !== 'number' || value >= 0) { | ||
@@ -131,7 +151,3 @@ return get(scale, value, value); | ||
var n = get(scale, absolute, absolute); | ||
if (typeof n === 'string') { | ||
return '-' + n; | ||
} | ||
if (typeof n === 'string') return '-' + n; | ||
return n * -1; | ||
@@ -141,7 +157,8 @@ }; | ||
var transforms = ['margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginX', 'marginY', 'top', 'bottom', 'left', 'right'].reduce(function (acc, curr) { | ||
var obj; | ||
return Object.assign({}, acc, (obj = {}, obj[curr] = positiveOrNegative, obj)); | ||
var _extends2; | ||
return _extends({}, acc, (_extends2 = {}, _extends2[curr] = positiveOrNegative, _extends2)); | ||
}, {}); | ||
var responsive = function (styles) { | ||
var responsive = function responsive(styles) { | ||
return function (theme) { | ||
@@ -156,7 +173,4 @@ var next = {}; | ||
var value = typeof styles[key] === 'function' ? styles[key](theme) : styles[key]; | ||
if (value == null) continue; | ||
if (value == null) { | ||
continue; | ||
} | ||
if (!Array.isArray(value)) { | ||
@@ -176,7 +190,3 @@ next[key] = value; | ||
next[media] = next[media] || {}; | ||
if (value[i] == null) { | ||
continue; | ||
} | ||
if (value[i] == null) continue; | ||
next[media][key] = value[i]; | ||
@@ -190,6 +200,10 @@ } | ||
var css = function (args) { | ||
var css = function css(args) { | ||
return function (props) { | ||
if (props === void 0) { props = {}; } | ||
var theme = Object.assign({}, defaultTheme, props.theme || props); | ||
if (props === void 0) { | ||
props = {}; | ||
} | ||
var theme = _extends({}, defaultTheme, props.theme || props); | ||
var result = {}; | ||
@@ -205,3 +219,3 @@ var obj = typeof args === 'function' ? args(theme) : args; | ||
var variant = css(get(theme, val))(theme); | ||
result = Object.assign({}, result, variant); | ||
result = _extends({}, result, variant); | ||
continue; | ||
@@ -236,23 +250,24 @@ } | ||
var BodyStyles = function () { return core.jsx(core$1.Global, { | ||
styles: function (theme) { | ||
if (theme.useBodyStyles === false || theme.styles && !theme.styles.root) { return false; } | ||
var boxSizing = theme.useBorderBox === false ? null : 'border-box'; | ||
return css({ | ||
'*': { | ||
boxSizing: boxSizing | ||
}, | ||
body: { | ||
margin: 0, | ||
variant: 'styles.root' | ||
} | ||
})(theme); | ||
} | ||
}); }; | ||
var BodyStyles = function BodyStyles() { | ||
return core.jsx(core$1.Global, { | ||
styles: function styles(theme) { | ||
if (theme.useBodyStyles === false || theme.styles && !theme.styles.root) return false; | ||
var boxSizing = theme.useBorderBox === false ? null : 'border-box'; | ||
return css({ | ||
'*': { | ||
boxSizing: boxSizing | ||
}, | ||
body: { | ||
margin: 0, | ||
variant: 'styles.root' | ||
} | ||
})(theme); | ||
} | ||
}); | ||
}; | ||
var ThemeProvider = function (ref) { | ||
var theme = ref.theme; | ||
var components = ref.components; | ||
var children = ref.children; | ||
var ThemeProvider = function ThemeProvider(_ref) { | ||
var theme = _ref.theme, | ||
components = _ref.components, | ||
children = _ref.children; | ||
var outer = core.useThemeUI(); | ||
@@ -259,0 +274,0 @@ |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@theme-ui/core'), require('@theme-ui/color-modes'), require('@theme-ui/mdx'), require('@emotion/core')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@theme-ui/core', '@theme-ui/color-modes', '@theme-ui/mdx', '@emotion/core'], factory) : | ||
(factory((global.themeProvider = {}),global.core,global.colorModes,global.mdx,global.core$1)); | ||
}(this, (function (exports,core,colorModes,mdx,core$1) { | ||
var get = function (obj, key, def, p, undef) { | ||
(global = global || self, factory(global.themeProvider = {}, global.core, global.colorModes, global.mdx, global.core$1)); | ||
}(this, (function (exports, core, colorModes, mdx, core$1) { | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
var get = function get(obj, key, def, p, undef) { | ||
key = key && key.split ? key.split('.') : [key]; | ||
@@ -51,2 +69,4 @@ | ||
borderColor: 'colors', | ||
caretColor: 'colors', | ||
columnRuleColor: 'colors', | ||
margin: 'space', | ||
@@ -122,3 +142,3 @@ marginTop: 'space', | ||
var positiveOrNegative = function (scale, value) { | ||
var positiveOrNegative = function positiveOrNegative(scale, value) { | ||
if (typeof value !== 'number' || value >= 0) { | ||
@@ -130,7 +150,3 @@ return get(scale, value, value); | ||
var n = get(scale, absolute, absolute); | ||
if (typeof n === 'string') { | ||
return '-' + n; | ||
} | ||
if (typeof n === 'string') return '-' + n; | ||
return n * -1; | ||
@@ -140,7 +156,8 @@ }; | ||
var transforms = ['margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginX', 'marginY', 'top', 'bottom', 'left', 'right'].reduce(function (acc, curr) { | ||
var obj; | ||
return Object.assign({}, acc, (obj = {}, obj[curr] = positiveOrNegative, obj)); | ||
var _extends2; | ||
return _extends({}, acc, (_extends2 = {}, _extends2[curr] = positiveOrNegative, _extends2)); | ||
}, {}); | ||
var responsive = function (styles) { | ||
var responsive = function responsive(styles) { | ||
return function (theme) { | ||
@@ -155,7 +172,4 @@ var next = {}; | ||
var value = typeof styles[key] === 'function' ? styles[key](theme) : styles[key]; | ||
if (value == null) continue; | ||
if (value == null) { | ||
continue; | ||
} | ||
if (!Array.isArray(value)) { | ||
@@ -175,7 +189,3 @@ next[key] = value; | ||
next[media] = next[media] || {}; | ||
if (value[i] == null) { | ||
continue; | ||
} | ||
if (value[i] == null) continue; | ||
next[media][key] = value[i]; | ||
@@ -189,6 +199,10 @@ } | ||
var css = function (args) { | ||
var css = function css(args) { | ||
return function (props) { | ||
if (props === void 0) { props = {}; } | ||
var theme = Object.assign({}, defaultTheme, props.theme || props); | ||
if (props === void 0) { | ||
props = {}; | ||
} | ||
var theme = _extends({}, defaultTheme, props.theme || props); | ||
var result = {}; | ||
@@ -204,3 +218,3 @@ var obj = typeof args === 'function' ? args(theme) : args; | ||
var variant = css(get(theme, val))(theme); | ||
result = Object.assign({}, result, variant); | ||
result = _extends({}, result, variant); | ||
continue; | ||
@@ -235,23 +249,24 @@ } | ||
var BodyStyles = function () { return core.jsx(core$1.Global, { | ||
styles: function (theme) { | ||
if (theme.useBodyStyles === false || theme.styles && !theme.styles.root) { return false; } | ||
var boxSizing = theme.useBorderBox === false ? null : 'border-box'; | ||
return css({ | ||
'*': { | ||
boxSizing: boxSizing | ||
}, | ||
body: { | ||
margin: 0, | ||
variant: 'styles.root' | ||
} | ||
})(theme); | ||
} | ||
}); }; | ||
var BodyStyles = function BodyStyles() { | ||
return core.jsx(core$1.Global, { | ||
styles: function styles(theme) { | ||
if (theme.useBodyStyles === false || theme.styles && !theme.styles.root) return false; | ||
var boxSizing = theme.useBorderBox === false ? null : 'border-box'; | ||
return css({ | ||
'*': { | ||
boxSizing: boxSizing | ||
}, | ||
body: { | ||
margin: 0, | ||
variant: 'styles.root' | ||
} | ||
})(theme); | ||
} | ||
}); | ||
}; | ||
var ThemeProvider = function (ref) { | ||
var theme = ref.theme; | ||
var components = ref.components; | ||
var children = ref.children; | ||
var ThemeProvider = function ThemeProvider(_ref) { | ||
var theme = _ref.theme, | ||
components = _ref.components, | ||
children = _ref.children; | ||
var outer = core.useThemeUI(); | ||
@@ -258,0 +273,0 @@ |
{ | ||
"name": "@theme-ui/theme-provider", | ||
"version": "0.3.1", | ||
"version": "0.3.2-alpha.10+80ad9af6", | ||
"main": "dist/index.js", | ||
@@ -13,5 +13,5 @@ "module": "dist/index.esm.js", | ||
"@emotion/core": "^10.0.0", | ||
"@theme-ui/color-modes": "^0.3.1", | ||
"@theme-ui/core": "^0.3.1", | ||
"@theme-ui/mdx": "^0.3.0" | ||
"@theme-ui/color-modes": "^0.3.2-alpha.10+80ad9af6", | ||
"@theme-ui/core": "^0.3.2-alpha.10+80ad9af6", | ||
"@theme-ui/mdx": "^0.3.2-alpha.10+80ad9af6" | ||
}, | ||
@@ -24,3 +24,3 @@ "repository": "system-ui/theme-ui", | ||
}, | ||
"gitHead": "f6380fc356ce97e64bf50ba60e0bc6f38a25dabe" | ||
"gitHead": "80ad9af6483a680fb703d5ebd7b8564d06e7d6c7" | ||
} |
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
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
107391
15
1250
2