@radix-ui/react-context
Advanced tools
Comparing version 1.1.0 to 1.1.1-rc.1
@@ -1,10 +0,6 @@ | ||
import * as react_jsx_runtime from 'react/jsx-runtime'; | ||
import * as React from 'react'; | ||
declare function createContext<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType): readonly [{ | ||
(props: ContextValueType & { | ||
children: React.ReactNode; | ||
}): react_jsx_runtime.JSX.Element; | ||
displayName: string; | ||
}, (consumerName: string) => ContextValueType]; | ||
declare function createContext<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType): readonly [React.FC<ContextValueType & { | ||
children: React.ReactNode; | ||
}>, (consumerName: string) => ContextValueType]; | ||
type Scope<C = any> = { | ||
@@ -20,10 +16,7 @@ [scopeName: string]: React.Context<C>[]; | ||
} | ||
declare function createContextScope(scopeName: string, createContextScopeDeps?: CreateScope[]): readonly [<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType | undefined) => readonly [{ | ||
(props: ContextValueType & { | ||
scope: Scope<ContextValueType>; | ||
children: React.ReactNode; | ||
}): react_jsx_runtime.JSX.Element; | ||
displayName: string; | ||
}, (consumerName: string, scope: Scope<ContextValueType | undefined>) => ContextValueType], CreateScope]; | ||
declare function createContextScope(scopeName: string, createContextScopeDeps?: CreateScope[]): readonly [<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType | undefined) => readonly [React.FC<ContextValueType & { | ||
scope: Scope<ContextValueType>; | ||
children: React.ReactNode; | ||
}>, (consumerName: string, scope: Scope<ContextValueType | undefined>) => ContextValueType], CreateScope]; | ||
export { type CreateScope, type Scope, createContext, createContextScope }; |
@@ -43,7 +43,8 @@ "use strict"; | ||
const Context = React.createContext(defaultContext); | ||
function Provider(props) { | ||
const Provider = (props) => { | ||
const { children, ...context } = props; | ||
const value = React.useMemo(() => context, Object.values(context)); | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Provider, { value, children }); | ||
} | ||
}; | ||
Provider.displayName = rootComponentName + "Provider"; | ||
function useContext2(consumerName) { | ||
@@ -55,3 +56,2 @@ const context = React.useContext(Context); | ||
} | ||
Provider.displayName = rootComponentName + "Provider"; | ||
return [Provider, useContext2]; | ||
@@ -65,3 +65,3 @@ } | ||
defaultContexts = [...defaultContexts, defaultContext]; | ||
function Provider(props) { | ||
const Provider = (props) => { | ||
const { scope, children, ...context } = props; | ||
@@ -71,3 +71,4 @@ const Context = scope?.[scopeName][index] || BaseContext; | ||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Provider, { value, children }); | ||
} | ||
}; | ||
Provider.displayName = rootComponentName + "Provider"; | ||
function useContext2(consumerName, scope) { | ||
@@ -80,3 +81,2 @@ const Context = scope?.[scopeName][index] || BaseContext; | ||
} | ||
Provider.displayName = rootComponentName + "Provider"; | ||
return [Provider, useContext2]; | ||
@@ -83,0 +83,0 @@ } |
{ | ||
"name": "@radix-ui/react-context", | ||
"version": "1.1.0", | ||
"version": "1.1.1-rc.1", | ||
"license": "MIT", | ||
@@ -46,3 +46,4 @@ "exports": { | ||
"url": "https://github.com/radix-ui/primitives/issues" | ||
} | ||
}, | ||
"stableVersion": "1.1.0" | ||
} |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
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
0
27892
212
1