@radix-ui/react-context 1.0.1 → 1.1.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,21 +1,22 @@
1
- import * as React from "react";
2
- export function createContext<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType): readonly [{
1
+ import * as React from 'react';
2
+
3
+ declare function createContext<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType): readonly [{
3
4
  (props: ContextValueType & {
4
5
  children: React.ReactNode;
5
6
  }): JSX.Element;
6
7
  displayName: string;
7
8
  }, (consumerName: string) => ContextValueType];
8
- export type Scope<C = any> = {
9
+ declare type Scope<C = any> = {
9
10
  [scopeName: string]: React.Context<C>[];
10
11
  } | undefined;
11
- type ScopeHook = (scope: Scope) => {
12
+ declare type ScopeHook = (scope: Scope) => {
12
13
  [__scopeProp: string]: Scope;
13
14
  };
14
- export interface CreateScope {
15
+ interface CreateScope {
15
16
  scopeName: string;
16
17
  (): ScopeHook;
17
18
  }
18
- export function createContextScope(scopeName: string, createContextScopeDeps?: CreateScope[]): readonly [<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType | undefined) => readonly [{
19
+ declare function createContextScope(scopeName: string, createContextScopeDeps?: CreateScope[]): readonly [<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType | undefined) => readonly [{
19
20
  (props: ContextValueType & {
20
21
  scope: Scope<ContextValueType>;
21
22
  children: React.ReactNode;
@@ -23,4 +24,4 @@ export function createContextScope(scopeName: string, createContextScopeDeps?: C
23
24
  displayName: string;
24
25
  }, (consumerName: string, scope: Scope<ContextValueType | undefined>) => ContextValueType], CreateScope];
25
26
 
26
- //# sourceMappingURL=index.d.ts.map
27
+ export { type CreateScope, type Scope, createContext, createContextScope };
package/dist/index.d.ts CHANGED
@@ -1,21 +1,22 @@
1
- import * as React from "react";
2
- export function createContext<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType): readonly [{
1
+ import * as React from 'react';
2
+
3
+ declare function createContext<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType): readonly [{
3
4
  (props: ContextValueType & {
4
5
  children: React.ReactNode;
5
6
  }): JSX.Element;
6
7
  displayName: string;
7
8
  }, (consumerName: string) => ContextValueType];
8
- export type Scope<C = any> = {
9
+ declare type Scope<C = any> = {
9
10
  [scopeName: string]: React.Context<C>[];
10
11
  } | undefined;
11
- type ScopeHook = (scope: Scope) => {
12
+ declare type ScopeHook = (scope: Scope) => {
12
13
  [__scopeProp: string]: Scope;
13
14
  };
14
- export interface CreateScope {
15
+ interface CreateScope {
15
16
  scopeName: string;
16
17
  (): ScopeHook;
17
18
  }
18
- export function createContextScope(scopeName: string, createContextScopeDeps?: CreateScope[]): readonly [<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType | undefined) => readonly [{
19
+ declare function createContextScope(scopeName: string, createContextScopeDeps?: CreateScope[]): readonly [<ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType | undefined) => readonly [{
19
20
  (props: ContextValueType & {
20
21
  scope: Scope<ContextValueType>;
21
22
  children: React.ReactNode;
@@ -23,4 +24,4 @@ export function createContextScope(scopeName: string, createContextScopeDeps?: C
23
24
  displayName: string;
24
25
  }, (consumerName: string, scope: Scope<ContextValueType | undefined>) => ContextValueType], CreateScope];
25
26
 
26
- //# sourceMappingURL=index.d.ts.map
27
+ export { type CreateScope, type Scope, createContext, createContextScope };
package/dist/index.js CHANGED
@@ -1,133 +1,109 @@
1
- var $4O1Ne$react = require("react");
2
-
3
- function $parcel$export(e, n, v, s) {
4
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
5
- }
6
-
7
- $parcel$export(module.exports, "createContext", () => $dec3cc0142d4f286$export$fd42f52fd3ae1109);
8
- $parcel$export(module.exports, "createContextScope", () => $dec3cc0142d4f286$export$50c7b4e9d9f19c1);
1
+ "use strict";
2
+ (() => {
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
+ }) : x)(function(x) {
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
9
31
 
10
- function $dec3cc0142d4f286$export$fd42f52fd3ae1109(rootComponentName, defaultContext) {
11
- const Context = /*#__PURE__*/ $4O1Ne$react.createContext(defaultContext);
32
+ // packages/react/context/src/createContext.tsx
33
+ var React = __toESM(__require("react"));
34
+ var import_jsx_runtime = __require("react/jsx-runtime");
35
+ function createContext2(rootComponentName, defaultContext) {
36
+ const Context = React.createContext(defaultContext);
12
37
  function Provider(props) {
13
- const { children: children , ...context } = props; // Only re-memoize when prop values change
14
- // eslint-disable-next-line react-hooks/exhaustive-deps
15
- const value = $4O1Ne$react.useMemo(()=>context
16
- , Object.values(context));
17
- return /*#__PURE__*/ $4O1Ne$react.createElement(Context.Provider, {
18
- value: value
19
- }, children);
38
+ const { children, ...context } = props;
39
+ const value = React.useMemo(() => context, Object.values(context));
40
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Provider, { value, children });
20
41
  }
21
- function useContext(consumerName) {
22
- const context = $4O1Ne$react.useContext(Context);
23
- if (context) return context;
24
- if (defaultContext !== undefined) return defaultContext; // if a defaultContext wasn't specified, it's a required context.
25
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
42
+ function useContext2(consumerName) {
43
+ const context = React.useContext(Context);
44
+ if (context) return context;
45
+ if (defaultContext !== void 0) return defaultContext;
46
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
26
47
  }
27
- Provider.displayName = rootComponentName + 'Provider';
28
- return [
29
- Provider,
30
- useContext
31
- ];
32
- }
33
- /* -------------------------------------------------------------------------------------------------
34
- * createContextScope
35
- * -----------------------------------------------------------------------------------------------*/ function $dec3cc0142d4f286$export$50c7b4e9d9f19c1(scopeName, createContextScopeDeps = []) {
48
+ Provider.displayName = rootComponentName + "Provider";
49
+ return [Provider, useContext2];
50
+ }
51
+ function createContextScope(scopeName, createContextScopeDeps = []) {
36
52
  let defaultContexts = [];
37
- /* -----------------------------------------------------------------------------------------------
38
- * createContext
39
- * ---------------------------------------------------------------------------------------------*/ function $dec3cc0142d4f286$export$fd42f52fd3ae1109(rootComponentName, defaultContext) {
40
- const BaseContext = /*#__PURE__*/ $4O1Ne$react.createContext(defaultContext);
41
- const index = defaultContexts.length;
42
- defaultContexts = [
43
- ...defaultContexts,
44
- defaultContext
45
- ];
46
- function Provider(props) {
47
- const { scope: scope , children: children , ...context } = props;
48
- const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index]) || BaseContext; // Only re-memoize when prop values change
49
- // eslint-disable-next-line react-hooks/exhaustive-deps
50
- const value = $4O1Ne$react.useMemo(()=>context
51
- , Object.values(context));
52
- return /*#__PURE__*/ $4O1Ne$react.createElement(Context.Provider, {
53
- value: value
54
- }, children);
55
- }
56
- function useContext(consumerName, scope) {
57
- const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index]) || BaseContext;
58
- const context = $4O1Ne$react.useContext(Context);
59
- if (context) return context;
60
- if (defaultContext !== undefined) return defaultContext; // if a defaultContext wasn't specified, it's a required context.
61
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
62
- }
63
- Provider.displayName = rootComponentName + 'Provider';
64
- return [
65
- Provider,
66
- useContext
67
- ];
53
+ function createContext3(rootComponentName, defaultContext) {
54
+ const BaseContext = React.createContext(defaultContext);
55
+ const index = defaultContexts.length;
56
+ defaultContexts = [...defaultContexts, defaultContext];
57
+ function Provider(props) {
58
+ const { scope, children, ...context } = props;
59
+ const Context = scope?.[scopeName][index] || BaseContext;
60
+ const value = React.useMemo(() => context, Object.values(context));
61
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Provider, { value, children });
62
+ }
63
+ function useContext2(consumerName, scope) {
64
+ const Context = scope?.[scopeName][index] || BaseContext;
65
+ const context = React.useContext(Context);
66
+ if (context) return context;
67
+ if (defaultContext !== void 0) return defaultContext;
68
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
69
+ }
70
+ Provider.displayName = rootComponentName + "Provider";
71
+ return [Provider, useContext2];
68
72
  }
69
- /* -----------------------------------------------------------------------------------------------
70
- * createScope
71
- * ---------------------------------------------------------------------------------------------*/ const createScope = ()=>{
72
- const scopeContexts = defaultContexts.map((defaultContext)=>{
73
- return /*#__PURE__*/ $4O1Ne$react.createContext(defaultContext);
74
- });
75
- return function useScope(scope) {
76
- const contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;
77
- return $4O1Ne$react.useMemo(()=>({
78
- [`__scope${scopeName}`]: {
79
- ...scope,
80
- [scopeName]: contexts
81
- }
82
- })
83
- , [
84
- scope,
85
- contexts
86
- ]);
87
- };
73
+ const createScope = () => {
74
+ const scopeContexts = defaultContexts.map((defaultContext) => {
75
+ return React.createContext(defaultContext);
76
+ });
77
+ return function useScope(scope) {
78
+ const contexts = scope?.[scopeName] || scopeContexts;
79
+ return React.useMemo(
80
+ () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
81
+ [scope, contexts]
82
+ );
83
+ };
88
84
  };
89
85
  createScope.scopeName = scopeName;
90
- return [
91
- $dec3cc0142d4f286$export$fd42f52fd3ae1109,
92
- $dec3cc0142d4f286$var$composeContextScopes(createScope, ...createContextScopeDeps)
93
- ];
94
- }
95
- /* -------------------------------------------------------------------------------------------------
96
- * composeContextScopes
97
- * -----------------------------------------------------------------------------------------------*/ function $dec3cc0142d4f286$var$composeContextScopes(...scopes) {
86
+ return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
87
+ }
88
+ function composeContextScopes(...scopes) {
98
89
  const baseScope = scopes[0];
99
90
  if (scopes.length === 1) return baseScope;
100
- const createScope1 = ()=>{
101
- const scopeHooks = scopes.map((createScope)=>({
102
- useScope: createScope(),
103
- scopeName: createScope.scopeName
104
- })
105
- );
106
- return function useComposedScopes(overrideScopes) {
107
- const nextScopes1 = scopeHooks.reduce((nextScopes, { useScope: useScope , scopeName: scopeName })=>{
108
- // We are calling a hook inside a callback which React warns against to avoid inconsistent
109
- // renders, however, scoping doesn't have render side effects so we ignore the rule.
110
- // eslint-disable-next-line react-hooks/rules-of-hooks
111
- const scopeProps = useScope(overrideScopes);
112
- const currentScope = scopeProps[`__scope${scopeName}`];
113
- return {
114
- ...nextScopes,
115
- ...currentScope
116
- };
117
- }, {});
118
- return $4O1Ne$react.useMemo(()=>({
119
- [`__scope${baseScope.scopeName}`]: nextScopes1
120
- })
121
- , [
122
- nextScopes1
123
- ]);
124
- };
91
+ const createScope = () => {
92
+ const scopeHooks = scopes.map((createScope2) => ({
93
+ useScope: createScope2(),
94
+ scopeName: createScope2.scopeName
95
+ }));
96
+ return function useComposedScopes(overrideScopes) {
97
+ const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
98
+ const scopeProps = useScope(overrideScopes);
99
+ const currentScope = scopeProps[`__scope${scopeName}`];
100
+ return { ...nextScopes2, ...currentScope };
101
+ }, {});
102
+ return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
103
+ };
125
104
  };
126
- createScope1.scopeName = baseScope.scopeName;
127
- return createScope1;
128
- }
129
-
130
-
131
-
132
-
105
+ createScope.scopeName = baseScope.scopeName;
106
+ return createScope;
107
+ }
108
+ })();
133
109
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1,7 @@
1
- {"mappings":";;;;;;;;ACAA;AAEA,SAASA,yCAAT,CACEG,iBADF,EAEEC,cAFF,EAGE;IACA,MAAMC,OAAO,GAAA,aAAGH,CAAAA,0BAAA,CAAkDE,cAAlD,CAAhB,AAAA;IAEA,SAASE,QAAT,CAAkBC,KAAlB,EAA2E;QACzE,MAAM,EATV,UASYC,QAAF,CAAA,EAAY,GAAGC,OAAH,EAAZ,GAA2BF,KAAjC,AADyE,EAEzE,0CADM;QAEN,uDAAA;QACA,MAAMG,KAAK,GAAGR,oBAAA,CAAc,IAAMO,OAApB;QAAA,EAA6BG,MAAM,CAACC,MAAP,CAAcJ,OAAd,CAA7B,CAAd,AAAA;QACA,OAAA,aAAO,CAAA,0BAAA,CAAC,OAAD,CAAS,QAAT,EAAP;YAAyB,KAAK,EAAEC,KAAP;SAAlB,EAAiCF,QAAjC,CAAP,CAAO;KACR;IAED,SAASM,UAAT,CAAoBC,YAApB,EAA0C;QACxC,MAAMN,OAAO,GAAGP,uBAAA,CAAiBG,OAAjB,CAAhB,AAAA;QACA,IAAII,OAAJ,EAAa,OAAOA,OAAP,CAAb;QACA,IAAIL,cAAc,KAAKY,SAAvB,EAAkC,OAAOZ,cAAP,CAHM,C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;oBAAE,CAAE,CAAA,OAAA,EAAS+B,SAAS,CAACd,SAAU,CAAA,CAA/B,CAAA,EAAmCkB,WAAnC;iBAAT,CAAA;YAAd,EAAyE;gBAACA,WAAD;aAAzE,CAAP,CAA4B;SAV9B,CAWC;KAjBH,AAkBC;IAEDX,YAAW,CAACP,SAAZ,GAAwBc,SAAS,CAACd,SAAlC,CAAAO;IACA,OAAOA,YAAP,CAAA;CACD;;ADjID","sources":["packages/react/context/src/index.ts","packages/react/context/src/createContext.tsx"],"sourcesContent":["export { createContext, createContextScope } from './createContext';\nexport type { CreateScope, Scope } from './createContext';\n","import * as React from 'react';\n\nfunction createContext<ContextValueType extends object | null>(\n rootComponentName: string,\n defaultContext?: ContextValueType\n) {\n const Context = React.createContext<ContextValueType | undefined>(defaultContext);\n\n function Provider(props: ContextValueType & { children: React.ReactNode }) {\n const { children, ...context } = props;\n // Only re-memoize when prop values change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const value = React.useMemo(() => context, Object.values(context)) as ContextValueType;\n return <Context.Provider value={value}>{children}</Context.Provider>;\n }\n\n function useContext(consumerName: string) {\n const context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== undefined) return defaultContext;\n // if a defaultContext wasn't specified, it's a required context.\n throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n }\n\n Provider.displayName = rootComponentName + 'Provider';\n return [Provider, useContext] as const;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * createContextScope\n * -----------------------------------------------------------------------------------------------*/\n\ntype Scope<C = any> = { [scopeName: string]: React.Context<C>[] } | undefined;\ntype ScopeHook = (scope: Scope) => { [__scopeProp: string]: Scope };\ninterface CreateScope {\n scopeName: string;\n (): ScopeHook;\n}\n\nfunction createContextScope(scopeName: string, createContextScopeDeps: CreateScope[] = []) {\n let defaultContexts: any[] = [];\n\n /* -----------------------------------------------------------------------------------------------\n * createContext\n * ---------------------------------------------------------------------------------------------*/\n\n function createContext<ContextValueType extends object | null>(\n rootComponentName: string,\n defaultContext?: ContextValueType\n ) {\n const BaseContext = React.createContext<ContextValueType | undefined>(defaultContext);\n const index = defaultContexts.length;\n defaultContexts = [...defaultContexts, defaultContext];\n\n function Provider(\n props: ContextValueType & { scope: Scope<ContextValueType>; children: React.ReactNode }\n ) {\n const { scope, children, ...context } = props;\n const Context = scope?.[scopeName][index] || BaseContext;\n // Only re-memoize when prop values change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const value = React.useMemo(() => context, Object.values(context)) as ContextValueType;\n return <Context.Provider value={value}>{children}</Context.Provider>;\n }\n\n function useContext(consumerName: string, scope: Scope<ContextValueType | undefined>) {\n const Context = scope?.[scopeName][index] || BaseContext;\n const context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== undefined) return defaultContext;\n // if a defaultContext wasn't specified, it's a required context.\n throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n }\n\n Provider.displayName = rootComponentName + 'Provider';\n return [Provider, useContext] as const;\n }\n\n /* -----------------------------------------------------------------------------------------------\n * createScope\n * ---------------------------------------------------------------------------------------------*/\n\n const createScope: CreateScope = () => {\n const scopeContexts = defaultContexts.map((defaultContext) => {\n return React.createContext(defaultContext);\n });\n return function useScope(scope: Scope) {\n const contexts = scope?.[scopeName] || scopeContexts;\n return React.useMemo(\n () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),\n [scope, contexts]\n );\n };\n };\n\n createScope.scopeName = scopeName;\n return [createContext, composeContextScopes(createScope, ...createContextScopeDeps)] as const;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * composeContextScopes\n * -----------------------------------------------------------------------------------------------*/\n\nfunction composeContextScopes(...scopes: CreateScope[]) {\n const baseScope = scopes[0];\n if (scopes.length === 1) return baseScope;\n\n const createScope: CreateScope = () => {\n const scopeHooks = scopes.map((createScope) => ({\n useScope: createScope(),\n scopeName: createScope.scopeName,\n }));\n\n return function useComposedScopes(overrideScopes) {\n const nextScopes = scopeHooks.reduce((nextScopes, { useScope, scopeName }) => {\n // We are calling a hook inside a callback which React warns against to avoid inconsistent\n // renders, however, scoping doesn't have render side effects so we ignore the rule.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const scopeProps = useScope(overrideScopes);\n const currentScope = scopeProps[`__scope${scopeName}`];\n return { ...nextScopes, ...currentScope };\n }, {});\n\n return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);\n };\n };\n\n createScope.scopeName = baseScope.scopeName;\n return createScope;\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nexport { createContext, createContextScope };\nexport type { CreateScope, Scope };\n"],"names":["createContext","createContextScope","React","rootComponentName","defaultContext","Context","Provider","props","children","context","value","useMemo","Object","values","useContext","consumerName","undefined","Error","displayName","scopeName","createContextScopeDeps","defaultContexts","BaseContext","index","length","scope","createScope","scopeContexts","map","useScope","contexts","composeContextScopes","scopes","baseScope","scopeHooks","useComposedScopes","overrideScopes","nextScopes","reduce","scopeProps","currentScope"],"version":3,"file":"index.js.map"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/createContext.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\n\nfunction createContext<ContextValueType extends object | null>(\n rootComponentName: string,\n defaultContext?: ContextValueType\n) {\n const Context = React.createContext<ContextValueType | undefined>(defaultContext);\n\n function Provider(props: ContextValueType & { children: React.ReactNode }) {\n const { children, ...context } = props;\n // Only re-memoize when prop values change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const value = React.useMemo(() => context, Object.values(context)) as ContextValueType;\n return <Context.Provider value={value}>{children}</Context.Provider>;\n }\n\n function useContext(consumerName: string) {\n const context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== undefined) return defaultContext;\n // if a defaultContext wasn't specified, it's a required context.\n throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n }\n\n Provider.displayName = rootComponentName + 'Provider';\n return [Provider, useContext] as const;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * createContextScope\n * -----------------------------------------------------------------------------------------------*/\n\ntype Scope<C = any> = { [scopeName: string]: React.Context<C>[] } | undefined;\ntype ScopeHook = (scope: Scope) => { [__scopeProp: string]: Scope };\ninterface CreateScope {\n scopeName: string;\n (): ScopeHook;\n}\n\nfunction createContextScope(scopeName: string, createContextScopeDeps: CreateScope[] = []) {\n let defaultContexts: any[] = [];\n\n /* -----------------------------------------------------------------------------------------------\n * createContext\n * ---------------------------------------------------------------------------------------------*/\n\n function createContext<ContextValueType extends object | null>(\n rootComponentName: string,\n defaultContext?: ContextValueType\n ) {\n const BaseContext = React.createContext<ContextValueType | undefined>(defaultContext);\n const index = defaultContexts.length;\n defaultContexts = [...defaultContexts, defaultContext];\n\n function Provider(\n props: ContextValueType & { scope: Scope<ContextValueType>; children: React.ReactNode }\n ) {\n const { scope, children, ...context } = props;\n const Context = scope?.[scopeName][index] || BaseContext;\n // Only re-memoize when prop values change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const value = React.useMemo(() => context, Object.values(context)) as ContextValueType;\n return <Context.Provider value={value}>{children}</Context.Provider>;\n }\n\n function useContext(consumerName: string, scope: Scope<ContextValueType | undefined>) {\n const Context = scope?.[scopeName][index] || BaseContext;\n const context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== undefined) return defaultContext;\n // if a defaultContext wasn't specified, it's a required context.\n throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n }\n\n Provider.displayName = rootComponentName + 'Provider';\n return [Provider, useContext] as const;\n }\n\n /* -----------------------------------------------------------------------------------------------\n * createScope\n * ---------------------------------------------------------------------------------------------*/\n\n const createScope: CreateScope = () => {\n const scopeContexts = defaultContexts.map((defaultContext) => {\n return React.createContext(defaultContext);\n });\n return function useScope(scope: Scope) {\n const contexts = scope?.[scopeName] || scopeContexts;\n return React.useMemo(\n () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),\n [scope, contexts]\n );\n };\n };\n\n createScope.scopeName = scopeName;\n return [createContext, composeContextScopes(createScope, ...createContextScopeDeps)] as const;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * composeContextScopes\n * -----------------------------------------------------------------------------------------------*/\n\nfunction composeContextScopes(...scopes: CreateScope[]) {\n const baseScope = scopes[0];\n if (scopes.length === 1) return baseScope;\n\n const createScope: CreateScope = () => {\n const scopeHooks = scopes.map((createScope) => ({\n useScope: createScope(),\n scopeName: createScope.scopeName,\n }));\n\n return function useComposedScopes(overrideScopes) {\n const nextScopes = scopeHooks.reduce((nextScopes, { useScope, scopeName }) => {\n // We are calling a hook inside a callback which React warns against to avoid inconsistent\n // renders, however, scoping doesn't have render side effects so we ignore the rule.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const scopeProps = useScope(overrideScopes);\n const currentScope = scopeProps[`__scope${scopeName}`];\n return { ...nextScopes, ...currentScope };\n }, {});\n\n return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);\n };\n };\n\n createScope.scopeName = baseScope.scopeName;\n return createScope;\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nexport { createContext, createContextScope };\nexport type { CreateScope, Scope };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAuB;AAaZ;AAXX,WAASA,eACP,mBACA,gBACA;AACA,UAAM,UAAgB,oBAA4C,cAAc;AAEhF,aAAS,SAAS,OAAyD;AACzE,YAAM,EAAE,UAAU,GAAG,QAAQ,IAAI;AAGjC,YAAM,QAAc,cAAQ,MAAM,SAAS,OAAO,OAAO,OAAO,CAAC;AACjE,aAAO,4CAAC,QAAQ,UAAR,EAAiB,OAAe,UAAS;AAAA,IACnD;AAEA,aAASC,YAAW,cAAsB;AACxC,YAAM,UAAgB,iBAAW,OAAO;AACxC,UAAI,QAAS,QAAO;AACpB,UAAI,mBAAmB,OAAW,QAAO;AAEzC,YAAM,IAAI,MAAM,KAAK,YAAY,4BAA4B,iBAAiB,IAAI;AAAA,IACpF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WAAO,CAACD,gBAAe,qBAAqB,aAAa,GAAG,sBAAsB,CAAC;AAAA,EACrF;AAMA,WAAS,wBAAwB,QAAuB;AACtD,UAAM,YAAY,OAAO,CAAC;AAC1B,QAAI,OAAO,WAAW,EAAG,QAAO;AAEhC,UAAM,cAA2B,MAAM;AACrC,YAAM,aAAa,OAAO,IAAI,CAACE,kBAAiB;AAAA,QAC9C,UAAUA,aAAY;AAAA,QACtB,WAAWA,aAAY;AAAA,MACzB,EAAE;AAEF,aAAO,SAAS,kBAAkB,gBAAgB;AAChD,cAAM,aAAa,WAAW,OAAO,CAACC,aAAY,EAAE,UAAU,UAAU,MAAM;AAI5E,gBAAM,aAAa,SAAS,cAAc;AAC1C,gBAAM,eAAe,WAAW,UAAU,SAAS,EAAE;AACrD,iBAAO,EAAE,GAAGA,aAAY,GAAG,aAAa;AAAA,QAC1C,GAAG,CAAC,CAAC;AAEL,eAAa,cAAQ,OAAO,EAAE,CAAC,UAAU,UAAU,SAAS,EAAE,GAAG,WAAW,IAAI,CAAC,UAAU,CAAC;AAAA,MAC9F;AAAA,IACF;AAEA,gBAAY,YAAY,UAAU;AAClC,WAAO;AAAA,EACT;",
6
+ "names": ["createContext", "useContext", "createScope", "nextScopes"]
7
+ }
package/dist/index.mjs CHANGED
@@ -1,128 +1,81 @@
1
- import {createContext as $3bkAK$createContext, useMemo as $3bkAK$useMemo, createElement as $3bkAK$createElement, useContext as $3bkAK$useContext} from "react";
2
-
3
-
4
- function $c512c27ab02ef895$export$fd42f52fd3ae1109(rootComponentName, defaultContext) {
5
- const Context = /*#__PURE__*/ $3bkAK$createContext(defaultContext);
1
+ // packages/react/context/src/createContext.tsx
2
+ import * as React from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ function createContext2(rootComponentName, defaultContext) {
5
+ const Context = React.createContext(defaultContext);
6
+ function Provider(props) {
7
+ const { children, ...context } = props;
8
+ const value = React.useMemo(() => context, Object.values(context));
9
+ return /* @__PURE__ */ jsx(Context.Provider, { value, children });
10
+ }
11
+ function useContext2(consumerName) {
12
+ const context = React.useContext(Context);
13
+ if (context) return context;
14
+ if (defaultContext !== void 0) return defaultContext;
15
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
16
+ }
17
+ Provider.displayName = rootComponentName + "Provider";
18
+ return [Provider, useContext2];
19
+ }
20
+ function createContextScope(scopeName, createContextScopeDeps = []) {
21
+ let defaultContexts = [];
22
+ function createContext3(rootComponentName, defaultContext) {
23
+ const BaseContext = React.createContext(defaultContext);
24
+ const index = defaultContexts.length;
25
+ defaultContexts = [...defaultContexts, defaultContext];
6
26
  function Provider(props) {
7
- const { children: children , ...context } = props; // Only re-memoize when prop values change
8
- // eslint-disable-next-line react-hooks/exhaustive-deps
9
- const value = $3bkAK$useMemo(()=>context
10
- , Object.values(context));
11
- return /*#__PURE__*/ $3bkAK$createElement(Context.Provider, {
12
- value: value
13
- }, children);
14
- }
15
- function useContext(consumerName) {
16
- const context = $3bkAK$useContext(Context);
17
- if (context) return context;
18
- if (defaultContext !== undefined) return defaultContext; // if a defaultContext wasn't specified, it's a required context.
19
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
27
+ const { scope, children, ...context } = props;
28
+ const Context = scope?.[scopeName][index] || BaseContext;
29
+ const value = React.useMemo(() => context, Object.values(context));
30
+ return /* @__PURE__ */ jsx(Context.Provider, { value, children });
20
31
  }
21
- Provider.displayName = rootComponentName + 'Provider';
22
- return [
23
- Provider,
24
- useContext
25
- ];
26
- }
27
- /* -------------------------------------------------------------------------------------------------
28
- * createContextScope
29
- * -----------------------------------------------------------------------------------------------*/ function $c512c27ab02ef895$export$50c7b4e9d9f19c1(scopeName, createContextScopeDeps = []) {
30
- let defaultContexts = [];
31
- /* -----------------------------------------------------------------------------------------------
32
- * createContext
33
- * ---------------------------------------------------------------------------------------------*/ function $c512c27ab02ef895$export$fd42f52fd3ae1109(rootComponentName, defaultContext) {
34
- const BaseContext = /*#__PURE__*/ $3bkAK$createContext(defaultContext);
35
- const index = defaultContexts.length;
36
- defaultContexts = [
37
- ...defaultContexts,
38
- defaultContext
39
- ];
40
- function Provider(props) {
41
- const { scope: scope , children: children , ...context } = props;
42
- const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index]) || BaseContext; // Only re-memoize when prop values change
43
- // eslint-disable-next-line react-hooks/exhaustive-deps
44
- const value = $3bkAK$useMemo(()=>context
45
- , Object.values(context));
46
- return /*#__PURE__*/ $3bkAK$createElement(Context.Provider, {
47
- value: value
48
- }, children);
49
- }
50
- function useContext(consumerName, scope) {
51
- const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index]) || BaseContext;
52
- const context = $3bkAK$useContext(Context);
53
- if (context) return context;
54
- if (defaultContext !== undefined) return defaultContext; // if a defaultContext wasn't specified, it's a required context.
55
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
56
- }
57
- Provider.displayName = rootComponentName + 'Provider';
58
- return [
59
- Provider,
60
- useContext
61
- ];
32
+ function useContext2(consumerName, scope) {
33
+ const Context = scope?.[scopeName][index] || BaseContext;
34
+ const context = React.useContext(Context);
35
+ if (context) return context;
36
+ if (defaultContext !== void 0) return defaultContext;
37
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
62
38
  }
63
- /* -----------------------------------------------------------------------------------------------
64
- * createScope
65
- * ---------------------------------------------------------------------------------------------*/ const createScope = ()=>{
66
- const scopeContexts = defaultContexts.map((defaultContext)=>{
67
- return /*#__PURE__*/ $3bkAK$createContext(defaultContext);
68
- });
69
- return function useScope(scope) {
70
- const contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;
71
- return $3bkAK$useMemo(()=>({
72
- [`__scope${scopeName}`]: {
73
- ...scope,
74
- [scopeName]: contexts
75
- }
76
- })
77
- , [
78
- scope,
79
- contexts
80
- ]);
81
- };
39
+ Provider.displayName = rootComponentName + "Provider";
40
+ return [Provider, useContext2];
41
+ }
42
+ const createScope = () => {
43
+ const scopeContexts = defaultContexts.map((defaultContext) => {
44
+ return React.createContext(defaultContext);
45
+ });
46
+ return function useScope(scope) {
47
+ const contexts = scope?.[scopeName] || scopeContexts;
48
+ return React.useMemo(
49
+ () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
50
+ [scope, contexts]
51
+ );
82
52
  };
83
- createScope.scopeName = scopeName;
84
- return [
85
- $c512c27ab02ef895$export$fd42f52fd3ae1109,
86
- $c512c27ab02ef895$var$composeContextScopes(createScope, ...createContextScopeDeps)
87
- ];
53
+ };
54
+ createScope.scopeName = scopeName;
55
+ return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
88
56
  }
89
- /* -------------------------------------------------------------------------------------------------
90
- * composeContextScopes
91
- * -----------------------------------------------------------------------------------------------*/ function $c512c27ab02ef895$var$composeContextScopes(...scopes) {
92
- const baseScope = scopes[0];
93
- if (scopes.length === 1) return baseScope;
94
- const createScope1 = ()=>{
95
- const scopeHooks = scopes.map((createScope)=>({
96
- useScope: createScope(),
97
- scopeName: createScope.scopeName
98
- })
99
- );
100
- return function useComposedScopes(overrideScopes) {
101
- const nextScopes1 = scopeHooks.reduce((nextScopes, { useScope: useScope , scopeName: scopeName })=>{
102
- // We are calling a hook inside a callback which React warns against to avoid inconsistent
103
- // renders, however, scoping doesn't have render side effects so we ignore the rule.
104
- // eslint-disable-next-line react-hooks/rules-of-hooks
105
- const scopeProps = useScope(overrideScopes);
106
- const currentScope = scopeProps[`__scope${scopeName}`];
107
- return {
108
- ...nextScopes,
109
- ...currentScope
110
- };
111
- }, {});
112
- return $3bkAK$useMemo(()=>({
113
- [`__scope${baseScope.scopeName}`]: nextScopes1
114
- })
115
- , [
116
- nextScopes1
117
- ]);
118
- };
57
+ function composeContextScopes(...scopes) {
58
+ const baseScope = scopes[0];
59
+ if (scopes.length === 1) return baseScope;
60
+ const createScope = () => {
61
+ const scopeHooks = scopes.map((createScope2) => ({
62
+ useScope: createScope2(),
63
+ scopeName: createScope2.scopeName
64
+ }));
65
+ return function useComposedScopes(overrideScopes) {
66
+ const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
67
+ const scopeProps = useScope(overrideScopes);
68
+ const currentScope = scopeProps[`__scope${scopeName}`];
69
+ return { ...nextScopes2, ...currentScope };
70
+ }, {});
71
+ return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
119
72
  };
120
- createScope1.scopeName = baseScope.scopeName;
121
- return createScope1;
73
+ };
74
+ createScope.scopeName = baseScope.scopeName;
75
+ return createScope;
122
76
  }
123
-
124
-
125
-
126
-
127
- export {$c512c27ab02ef895$export$fd42f52fd3ae1109 as createContext, $c512c27ab02ef895$export$50c7b4e9d9f19c1 as createContextScope};
77
+ export {
78
+ createContext2 as createContext,
79
+ createContextScope
80
+ };
128
81
  //# sourceMappingURL=index.mjs.map
@@ -1 +1,7 @@
1
- {"mappings":";;ACAA;AAEA,SAASA,yCAAT,CACEG,iBADF,EAEEC,cAFF,EAGE;IACA,MAAMC,OAAO,GAAA,aAAGH,CAAAA,oBAAA,CAAkDE,cAAlD,CAAhB,AAAA;IAEA,SAASE,QAAT,CAAkBC,KAAlB,EAA2E;QACzE,MAAM,EATV,UASYC,QAAF,CAAA,EAAY,GAAGC,OAAH,EAAZ,GAA2BF,KAAjC,AADyE,EAEzE,0CADM;QAEN,uDAAA;QACA,MAAMG,KAAK,GAAGR,cAAA,CAAc,IAAMO,OAApB;QAAA,EAA6BG,MAAM,CAACC,MAAP,CAAcJ,OAAd,CAA7B,CAAd,AAAA;QACA,OAAA,aAAO,CAAA,oBAAA,CAAC,OAAD,CAAS,QAAT,EAAP;YAAyB,KAAK,EAAEC,KAAP;SAAlB,EAAiCF,QAAjC,CAAP,CAAO;KACR;IAED,SAASM,UAAT,CAAoBC,YAApB,EAA0C;QACxC,MAAMN,OAAO,GAAGP,iBAAA,CAAiBG,OAAjB,CAAhB,AAAA;QACA,IAAII,OAAJ,EAAa,OAAOA,OAAP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,EAOhB,EAPgB,CAAnB,AAOC;YAED,OAAOtC,cAAA,CAAc,IAAO,CAAA;oBAAE,CAAE,CAAA,OAAA,EAAS+B,SAAS,CAACd,SAAU,CAAA,CAA/B,CAAA,EAAmCkB,WAAnC;iBAAT,CAAA;YAAd,EAAyE;gBAACA,WAAD;aAAzE,CAAP,CAA4B;SAV9B,CAWC;KAjBH,AAkBC;IAEDX,YAAW,CAACP,SAAZ,GAAwBc,SAAS,CAACd,SAAlC,CAAAO;IACA,OAAOA,YAAP,CAAA;CACD;;ADjID","sources":["packages/react/context/src/index.ts","packages/react/context/src/createContext.tsx"],"sourcesContent":["export { createContext, createContextScope } from './createContext';\nexport type { CreateScope, Scope } from './createContext';\n","import * as React from 'react';\n\nfunction createContext<ContextValueType extends object | null>(\n rootComponentName: string,\n defaultContext?: ContextValueType\n) {\n const Context = React.createContext<ContextValueType | undefined>(defaultContext);\n\n function Provider(props: ContextValueType & { children: React.ReactNode }) {\n const { children, ...context } = props;\n // Only re-memoize when prop values change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const value = React.useMemo(() => context, Object.values(context)) as ContextValueType;\n return <Context.Provider value={value}>{children}</Context.Provider>;\n }\n\n function useContext(consumerName: string) {\n const context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== undefined) return defaultContext;\n // if a defaultContext wasn't specified, it's a required context.\n throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n }\n\n Provider.displayName = rootComponentName + 'Provider';\n return [Provider, useContext] as const;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * createContextScope\n * -----------------------------------------------------------------------------------------------*/\n\ntype Scope<C = any> = { [scopeName: string]: React.Context<C>[] } | undefined;\ntype ScopeHook = (scope: Scope) => { [__scopeProp: string]: Scope };\ninterface CreateScope {\n scopeName: string;\n (): ScopeHook;\n}\n\nfunction createContextScope(scopeName: string, createContextScopeDeps: CreateScope[] = []) {\n let defaultContexts: any[] = [];\n\n /* -----------------------------------------------------------------------------------------------\n * createContext\n * ---------------------------------------------------------------------------------------------*/\n\n function createContext<ContextValueType extends object | null>(\n rootComponentName: string,\n defaultContext?: ContextValueType\n ) {\n const BaseContext = React.createContext<ContextValueType | undefined>(defaultContext);\n const index = defaultContexts.length;\n defaultContexts = [...defaultContexts, defaultContext];\n\n function Provider(\n props: ContextValueType & { scope: Scope<ContextValueType>; children: React.ReactNode }\n ) {\n const { scope, children, ...context } = props;\n const Context = scope?.[scopeName][index] || BaseContext;\n // Only re-memoize when prop values change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const value = React.useMemo(() => context, Object.values(context)) as ContextValueType;\n return <Context.Provider value={value}>{children}</Context.Provider>;\n }\n\n function useContext(consumerName: string, scope: Scope<ContextValueType | undefined>) {\n const Context = scope?.[scopeName][index] || BaseContext;\n const context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== undefined) return defaultContext;\n // if a defaultContext wasn't specified, it's a required context.\n throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n }\n\n Provider.displayName = rootComponentName + 'Provider';\n return [Provider, useContext] as const;\n }\n\n /* -----------------------------------------------------------------------------------------------\n * createScope\n * ---------------------------------------------------------------------------------------------*/\n\n const createScope: CreateScope = () => {\n const scopeContexts = defaultContexts.map((defaultContext) => {\n return React.createContext(defaultContext);\n });\n return function useScope(scope: Scope) {\n const contexts = scope?.[scopeName] || scopeContexts;\n return React.useMemo(\n () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),\n [scope, contexts]\n );\n };\n };\n\n createScope.scopeName = scopeName;\n return [createContext, composeContextScopes(createScope, ...createContextScopeDeps)] as const;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * composeContextScopes\n * -----------------------------------------------------------------------------------------------*/\n\nfunction composeContextScopes(...scopes: CreateScope[]) {\n const baseScope = scopes[0];\n if (scopes.length === 1) return baseScope;\n\n const createScope: CreateScope = () => {\n const scopeHooks = scopes.map((createScope) => ({\n useScope: createScope(),\n scopeName: createScope.scopeName,\n }));\n\n return function useComposedScopes(overrideScopes) {\n const nextScopes = scopeHooks.reduce((nextScopes, { useScope, scopeName }) => {\n // We are calling a hook inside a callback which React warns against to avoid inconsistent\n // renders, however, scoping doesn't have render side effects so we ignore the rule.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const scopeProps = useScope(overrideScopes);\n const currentScope = scopeProps[`__scope${scopeName}`];\n return { ...nextScopes, ...currentScope };\n }, {});\n\n return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);\n };\n };\n\n createScope.scopeName = baseScope.scopeName;\n return createScope;\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nexport { createContext, createContextScope };\nexport type { CreateScope, Scope };\n"],"names":["createContext","createContextScope","React","rootComponentName","defaultContext","Context","Provider","props","children","context","value","useMemo","Object","values","useContext","consumerName","undefined","Error","displayName","scopeName","createContextScopeDeps","defaultContexts","BaseContext","index","length","scope","createScope","scopeContexts","map","useScope","contexts","composeContextScopes","scopes","baseScope","scopeHooks","useComposedScopes","overrideScopes","nextScopes","reduce","scopeProps","currentScope"],"version":3,"file":"index.mjs.map"}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/createContext.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\n\nfunction createContext<ContextValueType extends object | null>(\n rootComponentName: string,\n defaultContext?: ContextValueType\n) {\n const Context = React.createContext<ContextValueType | undefined>(defaultContext);\n\n function Provider(props: ContextValueType & { children: React.ReactNode }) {\n const { children, ...context } = props;\n // Only re-memoize when prop values change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const value = React.useMemo(() => context, Object.values(context)) as ContextValueType;\n return <Context.Provider value={value}>{children}</Context.Provider>;\n }\n\n function useContext(consumerName: string) {\n const context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== undefined) return defaultContext;\n // if a defaultContext wasn't specified, it's a required context.\n throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n }\n\n Provider.displayName = rootComponentName + 'Provider';\n return [Provider, useContext] as const;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * createContextScope\n * -----------------------------------------------------------------------------------------------*/\n\ntype Scope<C = any> = { [scopeName: string]: React.Context<C>[] } | undefined;\ntype ScopeHook = (scope: Scope) => { [__scopeProp: string]: Scope };\ninterface CreateScope {\n scopeName: string;\n (): ScopeHook;\n}\n\nfunction createContextScope(scopeName: string, createContextScopeDeps: CreateScope[] = []) {\n let defaultContexts: any[] = [];\n\n /* -----------------------------------------------------------------------------------------------\n * createContext\n * ---------------------------------------------------------------------------------------------*/\n\n function createContext<ContextValueType extends object | null>(\n rootComponentName: string,\n defaultContext?: ContextValueType\n ) {\n const BaseContext = React.createContext<ContextValueType | undefined>(defaultContext);\n const index = defaultContexts.length;\n defaultContexts = [...defaultContexts, defaultContext];\n\n function Provider(\n props: ContextValueType & { scope: Scope<ContextValueType>; children: React.ReactNode }\n ) {\n const { scope, children, ...context } = props;\n const Context = scope?.[scopeName][index] || BaseContext;\n // Only re-memoize when prop values change\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const value = React.useMemo(() => context, Object.values(context)) as ContextValueType;\n return <Context.Provider value={value}>{children}</Context.Provider>;\n }\n\n function useContext(consumerName: string, scope: Scope<ContextValueType | undefined>) {\n const Context = scope?.[scopeName][index] || BaseContext;\n const context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== undefined) return defaultContext;\n // if a defaultContext wasn't specified, it's a required context.\n throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n }\n\n Provider.displayName = rootComponentName + 'Provider';\n return [Provider, useContext] as const;\n }\n\n /* -----------------------------------------------------------------------------------------------\n * createScope\n * ---------------------------------------------------------------------------------------------*/\n\n const createScope: CreateScope = () => {\n const scopeContexts = defaultContexts.map((defaultContext) => {\n return React.createContext(defaultContext);\n });\n return function useScope(scope: Scope) {\n const contexts = scope?.[scopeName] || scopeContexts;\n return React.useMemo(\n () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),\n [scope, contexts]\n );\n };\n };\n\n createScope.scopeName = scopeName;\n return [createContext, composeContextScopes(createScope, ...createContextScopeDeps)] as const;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * composeContextScopes\n * -----------------------------------------------------------------------------------------------*/\n\nfunction composeContextScopes(...scopes: CreateScope[]) {\n const baseScope = scopes[0];\n if (scopes.length === 1) return baseScope;\n\n const createScope: CreateScope = () => {\n const scopeHooks = scopes.map((createScope) => ({\n useScope: createScope(),\n scopeName: createScope.scopeName,\n }));\n\n return function useComposedScopes(overrideScopes) {\n const nextScopes = scopeHooks.reduce((nextScopes, { useScope, scopeName }) => {\n // We are calling a hook inside a callback which React warns against to avoid inconsistent\n // renders, however, scoping doesn't have render side effects so we ignore the rule.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const scopeProps = useScope(overrideScopes);\n const currentScope = scopeProps[`__scope${scopeName}`];\n return { ...nextScopes, ...currentScope };\n }, {});\n\n return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);\n };\n };\n\n createScope.scopeName = baseScope.scopeName;\n return createScope;\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nexport { createContext, createContextScope };\nexport type { CreateScope, Scope };\n"],
5
+ "mappings": ";AAAA,YAAY,WAAW;AAaZ;AAXX,SAASA,eACP,mBACA,gBACA;AACA,QAAM,UAAgB,oBAA4C,cAAc;AAEhF,WAAS,SAAS,OAAyD;AACzE,UAAM,EAAE,UAAU,GAAG,QAAQ,IAAI;AAGjC,UAAM,QAAc,cAAQ,MAAM,SAAS,OAAO,OAAO,OAAO,CAAC;AACjE,WAAO,oBAAC,QAAQ,UAAR,EAAiB,OAAe,UAAS;AAAA,EACnD;AAEA,WAASC,YAAW,cAAsB;AACxC,UAAM,UAAgB,iBAAW,OAAO;AACxC,QAAI,QAAS,QAAO;AACpB,QAAI,mBAAmB,OAAW,QAAO;AAEzC,UAAM,IAAI,MAAM,KAAK,YAAY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ACF;AAEA,cAAY,YAAY;AACxB,SAAO,CAACD,gBAAe,qBAAqB,aAAa,GAAG,sBAAsB,CAAC;AACrF;AAMA,SAAS,wBAAwB,QAAuB;AACtD,QAAM,YAAY,OAAO,CAAC;AAC1B,MAAI,OAAO,WAAW,EAAG,QAAO;AAEhC,QAAM,cAA2B,MAAM;AACrC,UAAM,aAAa,OAAO,IAAI,CAACE,kBAAiB;AAAA,MAC9C,UAAUA,aAAY;AAAA,MACtB,WAAWA,aAAY;AAAA,IACzB,EAAE;AAEF,WAAO,SAAS,kBAAkB,gBAAgB;AAChD,YAAM,aAAa,WAAW,OAAO,CAACC,aAAY,EAAE,UAAU,UAAU,MAAM;AAI5E,cAAM,aAAa,SAAS,cAAc;AAC1C,cAAM,eAAe,WAAW,UAAU,SAAS,EAAE;AACrD,eAAO,EAAE,GAAGA,aAAY,GAAG,aAAa;AAAA,MAC1C,GAAG,CAAC,CAAC;AAEL,aAAa,cAAQ,OAAO,EAAE,CAAC,UAAU,UAAU,SAAS,EAAE,GAAG,WAAW,IAAI,CAAC,UAAU,CAAC;AAAA,IAC9F;AAAA,EACF;AAEA,cAAY,YAAY,UAAU;AAClC,SAAO;AACT;",
6
+ "names": ["createContext", "useContext", "createScope", "nextScopes"]
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-context",
3
- "version": "1.0.1",
3
+ "version": "1.1.0-rc.1",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {
@@ -44,7 +44,5 @@
44
44
  "bugs": {
45
45
  "url": "https://github.com/radix-ui/primitives/issues"
46
46
  },
47
- "dependencies": {
48
- "@babel/runtime": "^7.13.10"
49
- }
47
+ "stableVersion": "1.0.1"
50
48
  }
@@ -1 +0,0 @@
1
- {"mappings":";AAEA,8BAAuB,gBAAgB,SAAS,MAAM,GAAG,IAAI,EAC3D,iBAAiB,EAAE,MAAM,EACzB,cAAc,CAAC,EAAE,gBAAgB;YAIR,gBAAgB,GAAG;QAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;KAAE;;kBAQvC,MAAM,uBAUzC;AAMD,kBAAW,CAAC,GAAG,GAAG,IAAI;IAAE,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;CAAE,GAAG,SAAS,CAAC;AAC9E,iBAAiB,CAAC,KAAK,EAAE,KAAK,KAAK;IAAE,CAAC,WAAW,EAAE,MAAM,GAAG,KAAK,CAAA;CAAE,CAAC;AACpE;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,SAAS,CAAC;CACf;AAED,mCAA4B,SAAS,EAAE,MAAM,EAAE,sBAAsB,GAAE,WAAW,EAAO,yEAQlE,MAAM;;;kBAQ+C,MAAM,SAAS;;;kBAUrD,MAAM,iFAgC3C","sources":["packages/react/context/src/packages/react/context/src/createContext.tsx","packages/react/context/src/packages/react/context/src/index.ts","packages/react/context/src/index.ts"],"sourcesContent":[null,null,"export { createContext, createContextScope } from './createContext';\nexport type { CreateScope, Scope } from './createContext';\n"],"names":[],"version":3,"file":"index.d.ts.map"}