@rescui/ui-contexts
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -0,0 +0,0 @@ export { LayeringConsumer, withLayering, useLayeringContext } from './parts/layering-context'; |
@@ -1,5 +0,4 @@ | ||
export { LayeringConsumer, withLayering, useLayeringContext } from './parts/layering-context'; | ||
export { default as LayeringProvider } from './layering-provider'; | ||
export { ThemeConsumer, withTheme, useTheme, getInverseTheme } from './parts/theme-context'; | ||
export { default as ThemeProvider } from './theme-provider'; | ||
//# sourceMappingURL=index.js.map | ||
export { LayeringConsumer, useLayeringContext, withLayering } from './parts/layering-context.js'; | ||
export { default as LayeringProvider } from './layering-provider.js'; | ||
export { ThemeConsumer, getInverseTheme, useTheme, withTheme } from './parts/theme-context.js'; | ||
export { default as ThemeProvider } from './theme-provider.js'; |
@@ -0,0 +0,0 @@ import { PropsWithChildren } from 'react'; |
import React, { useMemo } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { LayeringContext, LayeringContextValue, useLayeringContext } from './parts/layering-context'; | ||
import { useLayeringContext, LayeringContextValue, LayeringContext } from './parts/layering-context.js'; | ||
function LayeringProvider(_a) { | ||
var baseLayer = _a.baseLayer, | ||
children = _a.children; | ||
function LayeringProvider(_ref) { | ||
var baseLayer = _ref.baseLayer, | ||
children = _ref.children; | ||
var _b = useLayeringContext(), | ||
popupZIndex = _b.popupZIndex, | ||
dropdownZIndex = _b.dropdownZIndex, | ||
tooltipZIndex = _b.tooltipZIndex, | ||
baseZIndex = _b.baseZIndex, | ||
isInPortal = _b.isInPortal; | ||
var _useLayeringContext = useLayeringContext(), | ||
popupZIndex = _useLayeringContext.popupZIndex, | ||
dropdownZIndex = _useLayeringContext.dropdownZIndex, | ||
tooltipZIndex = _useLayeringContext.tooltipZIndex, | ||
baseZIndex = _useLayeringContext.baseZIndex, | ||
isInPortal = _useLayeringContext.isInPortal; | ||
@@ -31,3 +31,3 @@ var contextValue = useMemo(function () { | ||
}, [baseLayer, baseZIndex, dropdownZIndex, isInPortal, popupZIndex, tooltipZIndex]); | ||
return React.createElement(LayeringContext.Provider, { | ||
return /*#__PURE__*/React.createElement(LayeringContext.Provider, { | ||
value: contextValue | ||
@@ -42,2 +42,1 @@ }, children); | ||
export default LayeringProvider; | ||
//# sourceMappingURL=layering-provider.js.map |
@@ -0,0 +0,0 @@ import React from 'react'; |
@@ -0,49 +1,46 @@ | ||
import _classCallCheck from "@babel/runtime-corejs3/helpers/esm/classCallCheck"; | ||
import "core-js/modules/es.function.name.js"; | ||
import { __assign } from "tslib"; | ||
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign"; | ||
import React, { createContext, useContext } from 'react'; | ||
var LAYER_STEP = 500; | ||
var LayeringContextValue = | ||
/** @class */ | ||
function () { | ||
function LayeringContextValue(baseZIndex, isInPortal) { | ||
var _this = this; | ||
var LayeringContextValue = function LayeringContextValue(baseZIndex, isInPortal) { | ||
var _this = this; | ||
Object.defineProperty(this, 'baseZIndex', { | ||
writable: false, | ||
enumerable: true, | ||
value: baseZIndex | ||
}); | ||
Object.defineProperty(this, 'isInPortal', { | ||
writable: false, | ||
enumerable: true, | ||
value: Boolean(isInPortal) | ||
}); | ||
Object.defineProperty(this, 'popupZIndex', { | ||
enumerable: true, | ||
get: function get() { | ||
return _this.baseZIndex + 3 * LAYER_STEP; | ||
} | ||
}); | ||
Object.defineProperty(this, 'dropdownZIndex', { | ||
enumerable: true, | ||
get: function get() { | ||
return _this.baseZIndex + 2 * LAYER_STEP; | ||
} | ||
}); | ||
Object.defineProperty(this, 'tooltipZIndex', { | ||
enumerable: true, | ||
get: function get() { | ||
return _this.baseZIndex + LAYER_STEP; | ||
} | ||
}); | ||
} | ||
_classCallCheck(this, LayeringContextValue); | ||
return LayeringContextValue; | ||
}(); | ||
Object.defineProperty(this, 'baseZIndex', { | ||
writable: false, | ||
enumerable: true, | ||
value: baseZIndex | ||
}); | ||
Object.defineProperty(this, 'isInPortal', { | ||
writable: false, | ||
enumerable: true, | ||
value: Boolean(isInPortal) | ||
}); | ||
Object.defineProperty(this, 'popupZIndex', { | ||
enumerable: true, | ||
get: function get() { | ||
return _this.baseZIndex + 3 * LAYER_STEP; | ||
} | ||
}); | ||
Object.defineProperty(this, 'dropdownZIndex', { | ||
enumerable: true, | ||
get: function get() { | ||
return _this.baseZIndex + 2 * LAYER_STEP; | ||
} | ||
}); | ||
Object.defineProperty(this, 'tooltipZIndex', { | ||
enumerable: true, | ||
get: function get() { | ||
return _this.baseZIndex + LAYER_STEP; | ||
} | ||
}); | ||
}; | ||
export { LayeringContextValue }; | ||
export var LayeringContext = createContext(new LayeringContextValue(0)); | ||
export var LayeringConsumer = LayeringContext.Consumer; | ||
export var useLayeringContext = function useLayeringContext() { | ||
var LayeringContext = /*#__PURE__*/createContext(new LayeringContextValue(0)); | ||
var LayeringConsumer = LayeringContext.Consumer; | ||
var useLayeringContext = function useLayeringContext() { | ||
return useContext(LayeringContext); | ||
@@ -55,12 +52,14 @@ }; | ||
export var withLayering = function withLayering(WrappedComponent) { | ||
var withLayering = function withLayering(WrappedComponent) { | ||
var component = function component(props) { | ||
return React.createElement(LayeringContext.Consumer, null, function (layering) { | ||
return React.createElement(WrappedComponent, __assign({}, layering, props)); | ||
return /*#__PURE__*/React.createElement(LayeringContext.Consumer, null, function (layering) { | ||
return /*#__PURE__*/React.createElement(WrappedComponent, _Object$assign({}, layering, props)); | ||
}); | ||
}; | ||
component.displayName = "WithLayering(" + (WrappedComponent.displayName || WrappedComponent.name) + ")"; | ||
component.displayName = "WithLayering(".concat(WrappedComponent.displayName || WrappedComponent.name, ")"); | ||
return component; | ||
}; | ||
//# sourceMappingURL=layering-context.js.map | ||
export { LayeringConsumer, LayeringContext, LayeringContextValue, useLayeringContext, withLayering }; |
@@ -0,0 +0,0 @@ import React, { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react'; |
@@ -0,10 +1,14 @@ | ||
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties"; | ||
var _excluded = ["theme"]; | ||
import "core-js/modules/es.function.name.js"; | ||
import { __assign, __rest } from "tslib"; | ||
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign"; | ||
import React, { createContext, useContext } from 'react'; | ||
export var ThemeContext = createContext('light'); | ||
export var ThemeConsumer = ThemeContext.Consumer; | ||
export var getInverseTheme = function getInverseTheme(theme) { | ||
var ThemeContext = /*#__PURE__*/createContext('light'); | ||
var ThemeConsumer = ThemeContext.Consumer; | ||
var getInverseTheme = function getInverseTheme(theme) { | ||
return theme === 'light' ? 'dark' : 'light'; | ||
}; | ||
export var useTheme = function useTheme(overwriteValue) { | ||
var useTheme = function useTheme(overwriteValue) { | ||
var themeFromContext = useContext(ThemeContext); | ||
@@ -17,10 +21,11 @@ return overwriteValue || themeFromContext; | ||
export var withTheme = function withTheme(wrappedComponent) { | ||
var withTheme = function withTheme(wrappedComponent) { | ||
var WrappedComponent = wrappedComponent; | ||
var ComponentWithTheme = React.forwardRef(function (_a, ref) { | ||
var theme = _a.theme, | ||
restProps = __rest(_a, ["theme"]); | ||
var ComponentWithTheme = /*#__PURE__*/React.forwardRef(function (_ref, ref) { | ||
var theme = _ref.theme, | ||
restProps = _objectWithoutProperties(_ref, _excluded); | ||
return React.createElement(ThemeConsumer, null, function (themeFromContext) { | ||
return React.createElement(WrappedComponent, __assign({ | ||
return /*#__PURE__*/React.createElement(ThemeConsumer, null, function (themeFromContext) { | ||
return /*#__PURE__*/React.createElement(WrappedComponent, _Object$assign({ | ||
ref: ref, | ||
@@ -31,5 +36,6 @@ theme: theme || themeFromContext | ||
}); | ||
ComponentWithTheme.displayName = "WithTheme(" + (WrappedComponent.displayName || WrappedComponent.name) + ")"; | ||
ComponentWithTheme.displayName = "WithTheme(".concat(WrappedComponent.displayName || WrappedComponent.name, ")"); | ||
return ComponentWithTheme; | ||
}; | ||
//# sourceMappingURL=theme-context.js.map | ||
export { ThemeConsumer, ThemeContext, getInverseTheme, useTheme, withTheme }; |
@@ -0,0 +0,0 @@ import React, { PropsWithChildren } from 'react'; |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { ThemeContext } from './parts/theme-context'; | ||
import { ThemeContext } from './parts/theme-context.js'; | ||
var ThemeProvider = function ThemeProvider(_a) { | ||
var theme = _a.theme, | ||
children = _a.children; | ||
return React.createElement(ThemeContext.Provider, { | ||
var ThemeProvider = function ThemeProvider(_ref) { | ||
var theme = _ref.theme, | ||
children = _ref.children; | ||
return /*#__PURE__*/React.createElement(ThemeContext.Provider, { | ||
value: theme | ||
@@ -17,2 +17,1 @@ }, children); | ||
export default ThemeProvider; | ||
//# sourceMappingURL=theme-provider.js.map |
{ | ||
"name": "@rescui/ui-contexts", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "", | ||
@@ -19,3 +19,3 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@babel/runtime-corejs3": "^7.13.10", | ||
"@babel/runtime-corejs3": "^7.14.0", | ||
"core-js": "^3.9.1" | ||
@@ -28,3 +28,3 @@ }, | ||
"devDependencies": { | ||
"@rescui/scripts": "^0.1.0" | ||
"@rescui/scripts": "^0.1.1" | ||
}, | ||
@@ -34,3 +34,3 @@ "scripts": { | ||
}, | ||
"gitHead": "4fff2c35d8b024e88629ee9a589c5c6433e2c8fd" | ||
"gitHead": "42f60242929cb7b0e9c371ecf99d658b32217c5f" | ||
} |
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
20402
13