@chakra-ui/react-utils
Advanced tools
Comparing version 1.2.0 to 1.2.1
# @chakra-ui/react-utils | ||
## 1.2.1 | ||
### Patch Changes | ||
- [#5075](https://github.com/chakra-ui/chakra-ui/pull/5075) | ||
[`b28142946`](https://github.com/chakra-ui/chakra-ui/commit/b281429462a099b7fd7f9352e837cd28d1a2da0e) | ||
Thanks [@cschroeter](https://github.com/cschroeter)! - Update babel config to | ||
transpile soruces for older browsers. This fixes issues with CRA and | ||
Storybook. | ||
- Updated dependencies | ||
[[`b28142946`](https://github.com/chakra-ui/chakra-ui/commit/b281429462a099b7fd7f9352e837cd28d1a2da0e)]: | ||
- @chakra-ui/utils@1.9.1 | ||
## 1.2.0 | ||
@@ -4,0 +17,0 @@ |
@@ -46,3 +46,3 @@ 'use strict'; | ||
} catch (error) { | ||
throw new Error(`Cannot assign value '${value}' to ref '${ref}'`); | ||
throw new Error("Cannot assign value '" + value + "' to ref '" + ref + "'"); | ||
} | ||
@@ -58,5 +58,11 @@ } | ||
function mergeRefs(...refs) { | ||
return node => { | ||
refs.forEach(ref => assignRef(ref, node)); | ||
function mergeRefs() { | ||
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) { | ||
refs[_key] = arguments[_key]; | ||
} | ||
return function (node) { | ||
refs.forEach(function (ref) { | ||
return assignRef(ref, node); | ||
}); | ||
}; | ||
@@ -70,18 +76,23 @@ } | ||
*/ | ||
function createContext(options = {}) { | ||
const { | ||
strict = true, | ||
errorMessage = "useContext: `context` is undefined. Seems you forgot to wrap component within the Provider", | ||
name | ||
} = options; | ||
const Context = /*#__PURE__*/React__namespace.createContext(undefined); | ||
function createContext(options) { | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
var _options = options, | ||
_options$strict = _options.strict, | ||
strict = _options$strict === void 0 ? true : _options$strict, | ||
_options$errorMessage = _options.errorMessage, | ||
errorMessage = _options$errorMessage === void 0 ? "useContext: `context` is undefined. Seems you forgot to wrap component within the Provider" : _options$errorMessage, | ||
name = _options.name; | ||
var Context = /*#__PURE__*/React__namespace.createContext(undefined); | ||
Context.displayName = name; | ||
function useContext() { | ||
const context = React__namespace.useContext(Context); | ||
var context = React__namespace.useContext(Context); | ||
if (!context && strict) { | ||
const error = new Error(errorMessage); | ||
var error = new Error(errorMessage); | ||
error.name = "ContextError"; | ||
Error.captureStackTrace?.(error, useContext); | ||
Error.captureStackTrace == null ? void 0 : Error.captureStackTrace(error, useContext); | ||
throw error; | ||
@@ -104,3 +115,5 @@ } | ||
function getValidChildren(children) { | ||
return React__namespace.Children.toArray(children).filter(child => /*#__PURE__*/React__namespace.isValidElement(child)); | ||
return React__namespace.Children.toArray(children).filter(function (child) { | ||
return /*#__PURE__*/React__namespace.isValidElement(child); | ||
}); | ||
} | ||
@@ -107,0 +120,0 @@ |
@@ -46,3 +46,3 @@ 'use strict'; | ||
} catch (error) { | ||
throw new Error(`Cannot assign value '${value}' to ref '${ref}'`); | ||
throw new Error("Cannot assign value '" + value + "' to ref '" + ref + "'"); | ||
} | ||
@@ -58,5 +58,11 @@ } | ||
function mergeRefs(...refs) { | ||
return node => { | ||
refs.forEach(ref => assignRef(ref, node)); | ||
function mergeRefs() { | ||
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) { | ||
refs[_key] = arguments[_key]; | ||
} | ||
return function (node) { | ||
refs.forEach(function (ref) { | ||
return assignRef(ref, node); | ||
}); | ||
}; | ||
@@ -70,18 +76,23 @@ } | ||
*/ | ||
function createContext(options = {}) { | ||
const { | ||
strict = true, | ||
errorMessage = "useContext: `context` is undefined. Seems you forgot to wrap component within the Provider", | ||
name | ||
} = options; | ||
const Context = /*#__PURE__*/React__namespace.createContext(undefined); | ||
function createContext(options) { | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
var _options = options, | ||
_options$strict = _options.strict, | ||
strict = _options$strict === void 0 ? true : _options$strict, | ||
_options$errorMessage = _options.errorMessage, | ||
errorMessage = _options$errorMessage === void 0 ? "useContext: `context` is undefined. Seems you forgot to wrap component within the Provider" : _options$errorMessage, | ||
name = _options.name; | ||
var Context = /*#__PURE__*/React__namespace.createContext(undefined); | ||
Context.displayName = name; | ||
function useContext() { | ||
const context = React__namespace.useContext(Context); | ||
var context = React__namespace.useContext(Context); | ||
if (!context && strict) { | ||
const error = new Error(errorMessage); | ||
var error = new Error(errorMessage); | ||
error.name = "ContextError"; | ||
Error.captureStackTrace?.(error, useContext); | ||
Error.captureStackTrace == null ? void 0 : Error.captureStackTrace(error, useContext); | ||
throw error; | ||
@@ -104,3 +115,5 @@ } | ||
function getValidChildren(children) { | ||
return React__namespace.Children.toArray(children).filter(child => /*#__PURE__*/React__namespace.isValidElement(child)); | ||
return React__namespace.Children.toArray(children).filter(function (child) { | ||
return /*#__PURE__*/React__namespace.isValidElement(child); | ||
}); | ||
} | ||
@@ -107,0 +120,0 @@ |
@@ -22,3 +22,3 @@ import { isFunction } from '@chakra-ui/utils'; | ||
} catch (error) { | ||
throw new Error(`Cannot assign value '${value}' to ref '${ref}'`); | ||
throw new Error("Cannot assign value '" + value + "' to ref '" + ref + "'"); | ||
} | ||
@@ -34,5 +34,11 @@ } | ||
function mergeRefs(...refs) { | ||
return node => { | ||
refs.forEach(ref => assignRef(ref, node)); | ||
function mergeRefs() { | ||
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) { | ||
refs[_key] = arguments[_key]; | ||
} | ||
return function (node) { | ||
refs.forEach(function (ref) { | ||
return assignRef(ref, node); | ||
}); | ||
}; | ||
@@ -46,18 +52,23 @@ } | ||
*/ | ||
function createContext(options = {}) { | ||
const { | ||
strict = true, | ||
errorMessage = "useContext: `context` is undefined. Seems you forgot to wrap component within the Provider", | ||
name | ||
} = options; | ||
const Context = /*#__PURE__*/React.createContext(undefined); | ||
function createContext(options) { | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
var _options = options, | ||
_options$strict = _options.strict, | ||
strict = _options$strict === void 0 ? true : _options$strict, | ||
_options$errorMessage = _options.errorMessage, | ||
errorMessage = _options$errorMessage === void 0 ? "useContext: `context` is undefined. Seems you forgot to wrap component within the Provider" : _options$errorMessage, | ||
name = _options.name; | ||
var Context = /*#__PURE__*/React.createContext(undefined); | ||
Context.displayName = name; | ||
function useContext() { | ||
const context = React.useContext(Context); | ||
var context = React.useContext(Context); | ||
if (!context && strict) { | ||
const error = new Error(errorMessage); | ||
var error = new Error(errorMessage); | ||
error.name = "ContextError"; | ||
Error.captureStackTrace?.(error, useContext); | ||
Error.captureStackTrace == null ? void 0 : Error.captureStackTrace(error, useContext); | ||
throw error; | ||
@@ -80,5 +91,7 @@ } | ||
function getValidChildren(children) { | ||
return React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child)); | ||
return React.Children.toArray(children).filter(function (child) { | ||
return /*#__PURE__*/React.isValidElement(child); | ||
}); | ||
} | ||
export { assignRef, createContext, getValidChildren, mergeRefs }; |
@@ -9,1 +9,2 @@ import * as React from "react"; | ||
export declare function getValidChildren(children: React.ReactNode): React.ReactElement<any, string | React.JSXElementConstructor<any>>[]; | ||
//# sourceMappingURL=children.d.ts.map |
@@ -25,1 +25,2 @@ import * as React from "react"; | ||
export {}; | ||
//# sourceMappingURL=context.d.ts.map |
@@ -5,1 +5,2 @@ export * from "./refs"; | ||
export * from "./children"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -19,1 +19,2 @@ /// <reference types="react" /> | ||
export {}; | ||
//# sourceMappingURL=refs.d.ts.map |
@@ -10,1 +10,2 @@ import { EventKeys, Merge } from "@chakra-ui/utils"; | ||
export {}; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@chakra-ui/react-utils", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "React utilities and helpers for Chakra UI", | ||
@@ -19,3 +19,4 @@ "keywords": [ | ||
"files": [ | ||
"dist" | ||
"dist", | ||
"src" | ||
], | ||
@@ -34,3 +35,3 @@ "publishConfig": { | ||
"dependencies": { | ||
"@chakra-ui/utils": "^1.9.0" | ||
"@chakra-ui/utils": "^1.9.1" | ||
}, | ||
@@ -37,0 +38,0 @@ "peerDependencies": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
23259
23
465
0
Updated@chakra-ui/utils@^1.9.1