@tamagui/create-context 2.7.7 → 3.0.0-beta.643.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.
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+
3
4
  var __create = Object.create;
4
5
  var __defProp = Object.defineProperty;
5
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7,156 +8,136 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
8
  var __getProtoOf = Object.getPrototypeOf;
8
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
10
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: true
13
- });
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
14
15
  };
15
16
  var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
18
- get: () => from[key],
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- return to;
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
22
+ }
23
+ return to;
23
24
  };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
- value: mod,
31
- enumerable: true
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
32
28
  }) : target, mod));
33
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
- value: true
35
- }), mod);
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
30
  var create_context_exports = {};
37
31
  __export(create_context_exports, {
38
- createContext: () => createContext,
39
- createContextScope: () => createContextScope
32
+ createContext: () => createContext,
33
+ createContextScope: () => createContextScope
40
34
  });
41
35
  module.exports = __toCommonJS(create_context_exports);
42
36
  var import_jsx_runtime = require("react/jsx-runtime");
43
37
  var React = __toESM(require("react"), 1);
44
38
  function createContext(rootComponentName, defaultContext) {
45
- var Context = /* @__PURE__ */React.createContext(defaultContext);
46
- function Provider(props) {
47
- var {
48
- children,
49
- ...context
50
- } = props;
51
- var value = React.useMemo(function () {
52
- return context;
53
- }, Object.values(context));
54
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Context.Provider, {
55
- value,
56
- children
57
- });
58
- }
59
- function useContext(consumerName) {
60
- var context = React.useContext(Context);
61
- if (context) return context;
62
- if (defaultContext !== void 0) return defaultContext;
63
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
64
- }
65
- return [Provider, useContext];
39
+ var Context = /* @__PURE__ */ React.createContext(defaultContext);
40
+ function Provider(props) {
41
+ var { children, ...context } = props;
42
+ var value = React.useMemo(function() {
43
+ return context;
44
+ }, Object.values(context));
45
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Provider, {
46
+ value,
47
+ children
48
+ });
49
+ }
50
+ function useContext(consumerName) {
51
+ var context = React.useContext(Context);
52
+ if (context) return context;
53
+ if (defaultContext !== void 0) return defaultContext;
54
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
55
+ }
56
+ return [Provider, useContext];
66
57
  }
67
58
  function createContextScope(scopeName) {
68
- var createContextScopeDeps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
69
- var defaultContexts = [];
70
- function createContext2(rootComponentName, defaultContext) {
71
- var BaseContext = /* @__PURE__ */React.createContext(defaultContext);
72
- var index = defaultContexts.length;
73
- defaultContexts = [...defaultContexts, defaultContext];
74
- function Provider(props) {
75
- var _scope_scopeName;
76
- var {
77
- scope,
78
- children,
79
- ...context
80
- } = props;
81
- var Context = (scope === null || scope === void 0 ? void 0 : (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext;
82
- var value = React.useMemo(function () {
83
- return context;
84
- }, Object.values(context));
85
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Context.Provider, {
86
- value,
87
- children
88
- });
89
- }
90
- function useContext(consumerName, scope, options) {
91
- var _scope_scopeName;
92
- var Context = (scope === null || scope === void 0 ? void 0 : (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext;
93
- var context = React.useContext(Context);
94
- if (context) return context;
95
- if (defaultContext !== void 0) return defaultContext;
96
- var missingContextMessage = `\`${consumerName}\` must be used within \`${rootComponentName}\``;
97
- if (options === null || options === void 0 ? void 0 : options.fallback) {
98
- if ((options === null || options === void 0 ? void 0 : options.warn) !== false) {
99
- console.warn(missingContextMessage);
100
- }
101
- return options.fallback;
102
- }
103
- throw new Error(missingContextMessage);
104
- }
105
- return [Provider, useContext];
106
- }
107
- var createScope = function () {
108
- var scopeContexts = defaultContexts.map(function (defaultContext) {
109
- return /* @__PURE__ */React.createContext(defaultContext);
110
- });
111
- return function useScope(scope) {
112
- var contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;
113
- return React.useMemo(function () {
114
- return {
115
- [`__scope${scopeName}`]: {
116
- ...scope,
117
- [scopeName]: contexts
118
- }
119
- };
120
- }, [scope, contexts]);
121
- };
122
- };
123
- createScope.scopeName = scopeName;
124
- return [createContext2, composeContextScopes(createScope, ...createContextScopeDeps)];
59
+ var createContextScopeDeps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
60
+ var defaultContexts = [];
61
+ function createContext2(rootComponentName, defaultContext) {
62
+ var BaseContext = /* @__PURE__ */ React.createContext(defaultContext);
63
+ var index = defaultContexts.length;
64
+ defaultContexts = [...defaultContexts, defaultContext];
65
+ function Provider(props) {
66
+ var _scope_scopeName;
67
+ var { scope, children, ...context } = props;
68
+ var Context = (scope === null || scope === void 0 ? void 0 : (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext;
69
+ var value = React.useMemo(function() {
70
+ return context;
71
+ }, Object.values(context));
72
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Provider, {
73
+ value,
74
+ children
75
+ });
76
+ }
77
+ function useContext(consumerName, scope, options) {
78
+ var _scope_scopeName;
79
+ var Context = (scope === null || scope === void 0 ? void 0 : (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext;
80
+ var context = React.useContext(Context);
81
+ if (context) return context;
82
+ if (defaultContext !== void 0) return defaultContext;
83
+ var missingContextMessage = `\`${consumerName}\` must be used within \`${rootComponentName}\``;
84
+ if (options === null || options === void 0 ? void 0 : options.fallback) {
85
+ if ((options === null || options === void 0 ? void 0 : options.warn) !== false) {
86
+ console.warn(missingContextMessage);
87
+ }
88
+ return options.fallback;
89
+ }
90
+ throw new Error(missingContextMessage);
91
+ }
92
+ return [Provider, useContext];
93
+ }
94
+ var createScope = function() {
95
+ var scopeContexts = defaultContexts.map(function(defaultContext) {
96
+ return /* @__PURE__ */ React.createContext(defaultContext);
97
+ });
98
+ return function useScope(scope) {
99
+ var contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;
100
+ return React.useMemo(function() {
101
+ return { [`__scope${scopeName}`]: {
102
+ ...scope,
103
+ [scopeName]: contexts
104
+ } };
105
+ }, [scope, contexts]);
106
+ };
107
+ };
108
+ createScope.scopeName = scopeName;
109
+ return [createContext2, composeContextScopes(createScope, ...createContextScopeDeps)];
125
110
  }
126
111
  function composeContextScopes() {
127
- for (var _len = arguments.length, scopes = new Array(_len), _key = 0; _key < _len; _key++) {
128
- scopes[_key] = arguments[_key];
129
- }
130
- var baseScope = scopes[0];
131
- if (scopes.length === 1) return baseScope;
132
- var createScope = function () {
133
- var scopeHooks = scopes.map(function (createScope2) {
134
- return {
135
- useScope: createScope2(),
136
- scopeName: createScope2.scopeName
137
- };
138
- });
139
- return function useComposedScopes(overrideScopes) {
140
- var nextScopes = scopeHooks.reduce(function (nextScopes2, param) {
141
- var {
142
- useScope,
143
- scopeName
144
- } = param;
145
- var scopeProps = useScope(overrideScopes);
146
- var currentScope = scopeProps[`__scope${scopeName}`];
147
- return {
148
- ...nextScopes2,
149
- ...currentScope
150
- };
151
- }, {});
152
- return React.useMemo(function () {
153
- return {
154
- [`__scope${baseScope.scopeName}`]: nextScopes
155
- };
156
- }, [nextScopes]);
157
- };
158
- };
159
- createScope.scopeName = baseScope.scopeName;
160
- return createScope;
112
+ for (var _len = arguments.length, scopes = new Array(_len), _key = 0; _key < _len; _key++) {
113
+ scopes[_key] = arguments[_key];
114
+ }
115
+ var baseScope = scopes[0];
116
+ if (scopes.length === 1) return baseScope;
117
+ var createScope = function() {
118
+ var scopeHooks = scopes.map(function(createScope2) {
119
+ return {
120
+ useScope: createScope2(),
121
+ scopeName: createScope2.scopeName
122
+ };
123
+ });
124
+ return function useComposedScopes(overrideScopes) {
125
+ var nextScopes = scopeHooks.reduce(function(nextScopes2, param) {
126
+ var { useScope, scopeName } = param;
127
+ var scopeProps = useScope(overrideScopes);
128
+ var currentScope = scopeProps[`__scope${scopeName}`];
129
+ return {
130
+ ...nextScopes2,
131
+ ...currentScope
132
+ };
133
+ }, {});
134
+ return React.useMemo(function() {
135
+ return { [`__scope${baseScope.scopeName}`]: nextScopes };
136
+ }, [nextScopes]);
137
+ };
138
+ };
139
+ createScope.scopeName = baseScope.scopeName;
140
+ return createScope;
161
141
  }
142
+
162
143
  //# sourceMappingURL=create-context.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","create_context_exports","__export","createContext","createContextScope","module","exports","import_jsx_runtime","require","React","__toESM","rootComponentName","defaultContext","Context","Provider","props","children","context","useMemo","Object","values","jsx","useContext","consumerName","Error","scopeName","createContextScopeDeps","arguments","length","defaultContexts","createContext2","BaseContext","index","_scope_scopeName","scope","options","missingContextMessage","fallback","warn","console","createScope","scopeContexts","map","useScope","contexts"],"sources":["../../src/create-context.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,sBAAA;AAAAC,QAAA,CAAAD,sBAAA;EAAAE,aAAA,EAAAA,CAAA,KAAAA,aAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAGAC,MAAA,CAAAC,OAAuB,GAAAV,YAAA,CAAAK,sBAAA;AAkBZ,IAAAM,kBAAA,GAAAC,OAAA;AAdJ,IAAAC,KAAS,GAAAC,OAAA,CAAAF,OACd;AAMA,SAAML,aAAUA,CAAAQ,iBAAkD,EAAAC,cAAc;EAEhF,IAAAC,OAAS,kBAAkEJ,KAAA,CAAAN,aAAA,CAAAS,cAAA;EACzE,SAAME,QAAEA,CAAAC,KAAa;IAGrB;MAAMC,QAAQ;MAAA,GAAAC;IAAM,CAAQ,GAAAF,KAAM;IAClC,IAAAf,KAAO,GAAAS,KAAA,CAAAS,OAAA;MACT,OAAAD,OAAA;IAEA,GAAAE,MAAS,CAAAC,MAAA,CAAAH,OAAW;IAClB,OAAM,eAAgB,IAAAV,kBAAkB,CAAAc,GAAA,EAAAR,OAAA,CAAAC,QAAA;MACxCd,KAAI;MACJgB;IA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strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar create_context_exports = {};\n__export(create_context_exports, {\n createContext: () => createContext,\n createContextScope: () => createContextScope\n});\nmodule.exports = __toCommonJS(create_context_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar React = __toESM(require(\"react\"), 1);\nfunction createContext(rootComponentName, defaultContext) {\n var Context = /* @__PURE__ */ React.createContext(defaultContext);\n function Provider(props) {\n var { children, ...context } = props;\n var value = React.useMemo(function() {\n return context;\n }, Object.values(context));\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Provider, {\n value,\n children\n });\n }\n function useContext(consumerName) {\n var context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== void 0) return defaultContext;\n throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n }\n return [\n Provider,\n useContext\n ];\n}\nfunction createContextScope(scopeName) {\n var createContextScopeDeps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];\n var defaultContexts = [];\n function createContext2(rootComponentName, defaultContext) {\n var BaseContext = /* @__PURE__ */ React.createContext(defaultContext);\n var index = defaultContexts.length;\n defaultContexts = [\n ...defaultContexts,\n defaultContext\n ];\n function Provider(props) {\n var _scope_scopeName;\n var { scope, children, ...context } = props;\n var Context = (scope === null || scope === void 0 ? void 0 : (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext;\n var value = React.useMemo(function() {\n return context;\n }, Object.values(context));\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Provider, {\n value,\n children\n });\n }\n function useContext(consumerName, scope, options) {\n var _scope_scopeName;\n var Context = (scope === null || scope === void 0 ? void 0 : (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext;\n var context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== void 0) return defaultContext;\n var missingContextMessage = `\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``;\n if (options === null || options === void 0 ? void 0 : options.fallback) {\n if ((options === null || options === void 0 ? void 0 : options.warn) !== false) {\n console.warn(missingContextMessage);\n }\n return options.fallback;\n }\n throw new Error(missingContextMessage);\n }\n return [\n Provider,\n useContext\n ];\n }\n var createScope = function() {\n var scopeContexts = defaultContexts.map(function(defaultContext) {\n return /* @__PURE__ */ React.createContext(defaultContext);\n });\n return function useScope(scope) {\n var contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;\n return React.useMemo(function() {\n return {\n [`__scope${scopeName}`]: {\n ...scope,\n [scopeName]: contexts\n }\n };\n }, [\n scope,\n contexts\n ]);\n };\n };\n createScope.scopeName = scopeName;\n return [\n createContext2,\n composeContextScopes(createScope, ...createContextScopeDeps)\n ];\n}\nfunction composeContextScopes() {\n for (var _len = arguments.length, scopes = new Array(_len), _key = 0; _key < _len; _key++) {\n scopes[_key] = arguments[_key];\n }\n var baseScope = scopes[0];\n if (scopes.length === 1) return baseScope;\n var createScope = function() {\n var scopeHooks = scopes.map(function(createScope2) {\n return {\n useScope: createScope2(),\n scopeName: createScope2.scopeName\n };\n });\n return function useComposedScopes(overrideScopes) {\n var nextScopes = scopeHooks.reduce(function(nextScopes2, param) {\n var { useScope, scopeName } = param;\n var scopeProps = useScope(overrideScopes);\n var currentScope = scopeProps[`__scope${scopeName}`];\n return {\n ...nextScopes2,\n ...currentScope\n };\n }, {});\n return React.useMemo(function() {\n return {\n [`__scope${baseScope.scopeName}`]: nextScopes\n };\n }, [\n nextScopes\n ]);\n };\n };\n createScope.scopeName = baseScope.scopeName;\n return createScope;\n}\n//# sourceMappingURL=create-context.js.map\n"],"mappings":";;;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,WAAW,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAC,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AAO,GACJ,UAAU,cAAc;KACvB,GAAG;MACF,YAAY;IACf,EACF;GACF,GAAG,CACD,OACA,QACF,CAAC;EACH;CACF;CACA,YAAY,YAAY;CACxB,OAAO,CACL,gBACA,qBAAqB,aAAa,GAAG,sBAAsB,CAC7D;AACF;AACA,SAAS,uBAAuB;CAC9B,KAAK,IAAI,OAAO,UAAU,QAAQ,SAAS,IAAI,MAAM,IAAI,GAAG,OAAO,GAAG,OAAO,MAAM,QAAQ;EACzF,OAAO,QAAQ,UAAU;CAC3B;CACA,IAAI,YAAY,OAAO;CACvB,IAAI,OAAO,WAAW,GAAG,OAAO;CAChC,IAAI,cAAc,WAAW;EAC3B,IAAI,aAAa,OAAO,IAAI,SAAS,cAAc;GACjD,OAAO;IACL,UAAU,aAAa;IACvB,WAAW,aAAa;GAC1B;EACF,CAAC;EACD,OAAO,SAAS,kBAAkB,gBAAgB;GAChD,IAAI,aAAa,WAAW,OAAO,SAAS,aAAa,OAAO;IAC9D,IAAI,EAAE,UAAU,cAAc;IAC9B,IAAI,aAAa,SAAS,cAAc;IACxC,IAAI,eAAe,WAAW,UAAU;IACxC,OAAO;KACL,GAAG;KACH,GAAG;IACL;GACF,GAAG,CAAC,CAAC;GACL,OAAO,MAAM,QAAQ,WAAW;IAC9B,OAAO,GACJ,UAAU,UAAU,cAAc,WACrC;GACF,GAAG,CACD,UACF,CAAC;EACH;CACF;CACA,YAAY,YAAY,UAAU;CAClC,OAAO;AACT"}
@@ -1,20 +1,19 @@
1
+
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
6
  var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
8
- get: () => from[key],
9
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
10
- });
11
- }
12
- return to;
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
9
+ get: () => from[key],
10
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
+ });
12
+ }
13
+ return to;
13
14
  };
14
15
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
- value: true
17
- }), mod);
16
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
17
  var index_exports = {};
19
18
  module.exports = __toCommonJS(index_exports);
20
- __reExport(index_exports, require("./create-context.cjs"), module.exports);
19
+ __reExport(index_exports, require("./create-context.cjs"), module.exports);
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
11
+ get: () => from[key],
12
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
13
+ });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var index_exports = {};
20
+ module.exports = __toCommonJS(index_exports);
21
+ __reExport(index_exports, require("./create-context.native.js"), module.exports);
@@ -1,23 +1,23 @@
1
1
  "use strict";
2
2
 
3
+
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from === "object" || typeof from === "function") {
9
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
10
- get: () => from[key],
11
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
12
- });
13
- }
14
- return to;
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
11
+ get: () => from[key],
12
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
13
+ });
14
+ }
15
+ return to;
15
16
  };
16
17
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
18
- value: true
19
- }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
19
  var index_exports = {};
21
20
  module.exports = __toCommonJS(index_exports);
22
21
  __reExport(index_exports, require("./create-context.native.js"), module.exports);
22
+
23
23
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./create-context\"), module.exports);\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,cAAc,QAAQ,KAAK,kBAAkB,YAAY,QAAQ,KAAK,SAAS,GAAG,gBAAgB,YAAY,cAAc,KAAK,SAAS;AAC9I,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,OAAO,UAAU,aAAa,aAAa;AAC3C,WAAW,eAAe,QAAQ,4BAAkB,GAAG,OAAO,OAAO"}
@@ -1,105 +1,93 @@
1
1
  import * as React from "react";
2
2
  import { jsx } from "react/jsx-runtime";
3
+
3
4
  function createContext(rootComponentName, defaultContext) {
4
- const Context = React.createContext(defaultContext);
5
- function Provider(props) {
6
- const {
7
- children,
8
- ...context
9
- } = props;
10
- const value = React.useMemo(() => context, Object.values(context));
11
- return /* @__PURE__ */jsx(Context.Provider, {
12
- value,
13
- children
14
- });
15
- }
16
- function useContext(consumerName) {
17
- const context = React.useContext(Context);
18
- if (context) return context;
19
- if (defaultContext !== void 0) return defaultContext;
20
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
21
- }
22
- return [Provider, useContext];
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, {
10
+ value,
11
+ children
12
+ });
13
+ }
14
+ function useContext(consumerName) {
15
+ const context = React.useContext(Context);
16
+ if (context) return context;
17
+ if (defaultContext !== void 0) return defaultContext;
18
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
19
+ }
20
+ return [Provider, useContext];
23
21
  }
24
22
  function createContextScope(scopeName, createContextScopeDeps = []) {
25
- let defaultContexts = [];
26
- function createContext2(rootComponentName, defaultContext) {
27
- const BaseContext = React.createContext(defaultContext);
28
- const index = defaultContexts.length;
29
- defaultContexts = [...defaultContexts, defaultContext];
30
- function Provider(props) {
31
- const {
32
- scope,
33
- children,
34
- ...context
35
- } = props;
36
- const Context = scope?.[scopeName]?.[index] || BaseContext;
37
- const value = React.useMemo(() => context, Object.values(context));
38
- return /* @__PURE__ */jsx(Context.Provider, {
39
- value,
40
- children
41
- });
42
- }
43
- function useContext(consumerName, scope, options) {
44
- const Context = scope?.[scopeName]?.[index] || BaseContext;
45
- const context = React.useContext(Context);
46
- if (context) return context;
47
- if (defaultContext !== void 0) return defaultContext;
48
- const missingContextMessage = `\`${consumerName}\` must be used within \`${rootComponentName}\``;
49
- if (options?.fallback) {
50
- if (options?.warn !== false) {
51
- console.warn(missingContextMessage);
52
- }
53
- return options.fallback;
54
- }
55
- throw new Error(missingContextMessage);
56
- }
57
- return [Provider, useContext];
58
- }
59
- const createScope = () => {
60
- const scopeContexts = defaultContexts.map(defaultContext => {
61
- return React.createContext(defaultContext);
62
- });
63
- return function useScope(scope) {
64
- const contexts = scope?.[scopeName] || scopeContexts;
65
- return React.useMemo(() => ({
66
- [`__scope${scopeName}`]: {
67
- ...scope,
68
- [scopeName]: contexts
69
- }
70
- }), [scope, contexts]);
71
- };
72
- };
73
- createScope.scopeName = scopeName;
74
- return [createContext2, composeContextScopes(createScope, ...createContextScopeDeps)];
23
+ let defaultContexts = [];
24
+ function createContext2(rootComponentName, defaultContext) {
25
+ const BaseContext = React.createContext(defaultContext);
26
+ const index = defaultContexts.length;
27
+ defaultContexts = [...defaultContexts, defaultContext];
28
+ function Provider(props) {
29
+ const { scope, children, ...context } = props;
30
+ const Context = scope?.[scopeName]?.[index] || BaseContext;
31
+ const value = React.useMemo(() => context, Object.values(context));
32
+ return /* @__PURE__ */ jsx(Context.Provider, {
33
+ value,
34
+ children
35
+ });
36
+ }
37
+ function useContext(consumerName, scope, options) {
38
+ const Context = scope?.[scopeName]?.[index] || BaseContext;
39
+ const context = React.useContext(Context);
40
+ if (context) return context;
41
+ if (defaultContext !== void 0) return defaultContext;
42
+ const missingContextMessage = `\`${consumerName}\` must be used within \`${rootComponentName}\``;
43
+ if (options?.fallback) {
44
+ if (options?.warn !== false) {
45
+ console.warn(missingContextMessage);
46
+ }
47
+ return options.fallback;
48
+ }
49
+ throw new Error(missingContextMessage);
50
+ }
51
+ return [Provider, useContext];
52
+ }
53
+ const createScope = () => {
54
+ const scopeContexts = defaultContexts.map((defaultContext) => {
55
+ return React.createContext(defaultContext);
56
+ });
57
+ return function useScope(scope) {
58
+ const contexts = scope?.[scopeName] || scopeContexts;
59
+ return React.useMemo(() => ({ [`__scope${scopeName}`]: {
60
+ ...scope,
61
+ [scopeName]: contexts
62
+ } }), [scope, contexts]);
63
+ };
64
+ };
65
+ createScope.scopeName = scopeName;
66
+ return [createContext2, composeContextScopes(createScope, ...createContextScopeDeps)];
75
67
  }
76
68
  function composeContextScopes(...scopes) {
77
- const baseScope = scopes[0];
78
- if (scopes.length === 1) return baseScope;
79
- const createScope = () => {
80
- const scopeHooks = scopes.map(createScope2 => ({
81
- useScope: createScope2(),
82
- scopeName: createScope2.scopeName
83
- }));
84
- return function useComposedScopes(overrideScopes) {
85
- const nextScopes = scopeHooks.reduce((nextScopes2, {
86
- useScope,
87
- scopeName
88
- }) => {
89
- const scopeProps = useScope(overrideScopes);
90
- const currentScope = scopeProps[`__scope${scopeName}`];
91
- return {
92
- ...nextScopes2,
93
- ...currentScope
94
- };
95
- }, {});
96
- return React.useMemo(() => ({
97
- [`__scope${baseScope.scopeName}`]: nextScopes
98
- }), [nextScopes]);
99
- };
100
- };
101
- createScope.scopeName = baseScope.scopeName;
102
- return createScope;
69
+ const baseScope = scopes[0];
70
+ if (scopes.length === 1) return baseScope;
71
+ const createScope = () => {
72
+ const scopeHooks = scopes.map((createScope2) => ({
73
+ useScope: createScope2(),
74
+ scopeName: createScope2.scopeName
75
+ }));
76
+ return function useComposedScopes(overrideScopes) {
77
+ const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
78
+ const scopeProps = useScope(overrideScopes);
79
+ const currentScope = scopeProps[`__scope${scopeName}`];
80
+ return {
81
+ ...nextScopes2,
82
+ ...currentScope
83
+ };
84
+ }, {});
85
+ return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
86
+ };
87
+ };
88
+ createScope.scopeName = baseScope.scopeName;
89
+ return createScope;
103
90
  }
91
+
104
92
  export { createContext, createContextScope };
105
93
  //# sourceMappingURL=create-context.mjs.map