@tamagui/web 2.0.0-rc.13 → 2.0.0-rc.13-1771253253067
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/cjs/helpers/createStyledContext.cjs +9 -6
- package/dist/cjs/helpers/createStyledContext.js +6 -5
- package/dist/cjs/helpers/createStyledContext.js.map +1 -1
- package/dist/cjs/helpers/createStyledContext.native.js +10 -7
- package/dist/cjs/helpers/createStyledContext.native.js.map +1 -1
- package/dist/esm/helpers/createStyledContext.js +7 -6
- package/dist/esm/helpers/createStyledContext.js.map +1 -1
- package/dist/esm/helpers/createStyledContext.mjs +10 -7
- package/dist/esm/helpers/createStyledContext.mjs.map +1 -1
- package/dist/esm/helpers/createStyledContext.native.js +10 -7
- package/dist/esm/helpers/createStyledContext.native.js.map +1 -1
- package/package.json +13 -13
- package/src/helpers/createStyledContext.tsx +19 -14
- package/types/helpers/createStyledContext.d.ts.map +1 -1
|
@@ -38,17 +38,20 @@ var import_react = __toESM(require("react"), 1),
|
|
|
38
38
|
import_mergeProps = require("./mergeProps.cjs"),
|
|
39
39
|
import_objectIdentityKey = require("./objectIdentityKey.cjs"),
|
|
40
40
|
import_jsx_runtime = require("react/jsx-runtime");
|
|
41
|
+
const createReactContext = import_react.default[Math.random(), "createContext"],
|
|
42
|
+
useReactMemo = import_react.default[Math.random(), "useMemo"],
|
|
43
|
+
useReactContext = import_react.default[Math.random(), "useContext"];
|
|
41
44
|
function createStyledContext(defaultValues, namespace = "") {
|
|
42
45
|
"use no memo";
|
|
43
46
|
|
|
44
|
-
const OGContext =
|
|
47
|
+
const OGContext = createReactContext(defaultValues),
|
|
45
48
|
OGProvider = OGContext.Provider,
|
|
46
49
|
Context = OGContext,
|
|
47
50
|
scopedContexts = /* @__PURE__ */new Map(),
|
|
48
|
-
LastScopeInNamespace =
|
|
51
|
+
LastScopeInNamespace = createReactContext(namespace);
|
|
49
52
|
function getOrCreateScopedContext(scope) {
|
|
50
53
|
let ScopedContext = scopedContexts.get(scope);
|
|
51
|
-
return ScopedContext || (ScopedContext =
|
|
54
|
+
return ScopedContext || (ScopedContext = createReactContext(defaultValues), scopedContexts.set(scope, ScopedContext)), ScopedContext;
|
|
52
55
|
}
|
|
53
56
|
const getNamespacedScope = scope => namespace ? `${namespace}--${scope}` : scope,
|
|
54
57
|
Provider = ({
|
|
@@ -59,7 +62,7 @@ function createStyledContext(defaultValues, namespace = "") {
|
|
|
59
62
|
...values
|
|
60
63
|
}) => {
|
|
61
64
|
const scope = getNamespacedScope(scopeIn),
|
|
62
|
-
next =
|
|
65
|
+
next = useReactMemo(() => __disableMergeDefaultValues ? values : (0, import_mergeProps.mergeProps)(defaultValues, values), [(0, import_objectIdentityKey.objectIdentityKey)(values)]);
|
|
63
66
|
let ScopedProvider = OGProvider;
|
|
64
67
|
return scope && (ScopedProvider = getOrCreateScopedContext(scope).Provider), /* @__PURE__ */(0, import_jsx_runtime.jsx)(LastScopeInNamespace.Provider, {
|
|
65
68
|
value: scope,
|
|
@@ -70,10 +73,10 @@ function createStyledContext(defaultValues, namespace = "") {
|
|
|
70
73
|
});
|
|
71
74
|
},
|
|
72
75
|
useStyledContext = (scopeIn = "") => {
|
|
73
|
-
const lastScopeInNamespace = (
|
|
76
|
+
const lastScopeInNamespace = useReactContext(LastScopeInNamespace),
|
|
74
77
|
scope = namespace ? scopeIn ? getNamespacedScope(scopeIn) : lastScopeInNamespace : scopeIn,
|
|
75
78
|
context = scope ? getOrCreateScopedContext(scope) : OGContext;
|
|
76
|
-
return
|
|
79
|
+
return useReactContext(context);
|
|
77
80
|
};
|
|
78
81
|
return Context.Provider = Provider, Context.props = defaultValues, Context.context = OGContext, Context.useStyledContext = useStyledContext, Context;
|
|
79
82
|
}
|
|
@@ -26,12 +26,13 @@ __export(createStyledContext_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(createStyledContext_exports);
|
|
28
28
|
var import_react = __toESM(require("react"), 1), import_mergeProps = require("./mergeProps"), import_objectIdentityKey = require("./objectIdentityKey"), import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
const createReactContext = import_react.default[Math.random(), "createContext"], useReactMemo = import_react.default[Math.random(), "useMemo"], useReactContext = import_react.default[Math.random(), "useContext"];
|
|
29
30
|
function createStyledContext(defaultValues, namespace = "") {
|
|
30
31
|
"use no memo";
|
|
31
|
-
const OGContext =
|
|
32
|
+
const OGContext = createReactContext(defaultValues), OGProvider = OGContext.Provider, Context = OGContext, scopedContexts = /* @__PURE__ */ new Map(), LastScopeInNamespace = createReactContext(namespace);
|
|
32
33
|
function getOrCreateScopedContext(scope) {
|
|
33
34
|
let ScopedContext = scopedContexts.get(scope);
|
|
34
|
-
return ScopedContext || (ScopedContext =
|
|
35
|
+
return ScopedContext || (ScopedContext = createReactContext(defaultValues), scopedContexts.set(scope, ScopedContext)), ScopedContext;
|
|
35
36
|
}
|
|
36
37
|
const getNamespacedScope = (scope) => namespace ? `${namespace}--${scope}` : scope, Provider = ({
|
|
37
38
|
children,
|
|
@@ -40,12 +41,12 @@ function createStyledContext(defaultValues, namespace = "") {
|
|
|
40
41
|
__disableMergeDefaultValues,
|
|
41
42
|
...values
|
|
42
43
|
}) => {
|
|
43
|
-
const scope = getNamespacedScope(scopeIn), next =
|
|
44
|
+
const scope = getNamespacedScope(scopeIn), next = useReactMemo(() => __disableMergeDefaultValues ? values : (0, import_mergeProps.mergeProps)(defaultValues, values), [(0, import_objectIdentityKey.objectIdentityKey)(values)]);
|
|
44
45
|
let ScopedProvider = OGProvider;
|
|
45
46
|
return scope && (ScopedProvider = getOrCreateScopedContext(scope).Provider), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LastScopeInNamespace.Provider, { value: scope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ScopedProvider, { value: next, children }) });
|
|
46
47
|
}, useStyledContext = (scopeIn = "") => {
|
|
47
|
-
const lastScopeInNamespace = (
|
|
48
|
-
return
|
|
48
|
+
const lastScopeInNamespace = useReactContext(LastScopeInNamespace), scope = namespace ? scopeIn ? getNamespacedScope(scopeIn) : lastScopeInNamespace : scopeIn, context = scope ? getOrCreateScopedContext(scope) : OGContext;
|
|
49
|
+
return useReactContext(context);
|
|
49
50
|
};
|
|
50
51
|
return Context.Provider = Provider, Context.props = defaultValues, Context.context = OGContext, Context.useStyledContext = useStyledContext, Context;
|
|
51
52
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/createStyledContext.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB,8BAElB,oBAA2B,yBAC3B,2BAAkC,gCAgE1B;AAzDR,MAAM,qBAAqB,aAAAA,QACzB,KAAK,OAAO,GAAI,eAClB,GACM,eAAe,aAAAA,QAAM,KAAK,OAAO,GAAI,SAAqB,GAC1D,kBAAkB,aAAAA,QACtB,KAAK,OAAO,GAAI,YAClB;AAEO,SAAS,oBACd,eACA,YAAY,IACiB;AAG7B;AAEA,QAAM,YAAY,mBAA6C,aAAa,GACtE,aAAa,UAAU,UACvB,UAAU,WACV,iBAAiB,oBAAI,IAA+C,GACpE,uBAAuB,mBAA2B,SAAS;AAEjE,WAAS,yBAAyB,OAAe;AAC/C,QAAI,gBAAgB,eAAe,IAAI,KAAK;AAC5C,WAAK,kBACH,gBAAgB,mBAA6C,aAAa,GAC1E,eAAe,IAAI,OAAO,aAAa,IAElC;AAAA,EACT;AAEA,QAAM,qBAAqB,CAAC,UAC1B,YAAY,GAAG,SAAS,KAAK,KAAK,KAAK,OAEnC,WAAW,CAAC;AAAA,IAChB;AAAA,IACA,OAAO;AAAA;AAAA,IAEP;AAAA,IACA,GAAG;AAAA,EACL,MAA8D;AAC5D,UAAM,QAAQ,mBAAmB,OAAO,GAElC,OAAO,aAAa,MACpB,8BAEK,aAEF,8BAAW,eAAgB,MAAM,GACvC,KAAC,4CAAkB,MAAM,CAAC,CAAC;AAE9B,QAAI,iBAAiB;AACrB,WAAI,UACF,iBAAiB,yBAAyB,KAAK,EAAE,WAGjD,4CAAC,qBAAqB,UAArB,EAA8B,OAAO,OACpC,sDAAC,kBAAe,OAAO,MAAuB,UAAS,GACzD;AAAA,EAEJ,GAGM,mBAAmB,CAAC,UAAU,OAAO;AACzC,UAAM,uBAAuB,gBAAgB,oBAAoB,GAC3D,QAAQ,YACV,UACE,mBAAmB,OAAO,IAC1B,uBACF,SACE,UAAU,QAAQ,yBAAyB,KAAK,IAAI;AAE1D,WADc,gBAAgB,OAAQ;AAAA,EAExC;AAGA,iBAAQ,WAAW,UACnB,QAAQ,QAAQ,eAChB,QAAQ,UAAU,WAClB,QAAQ,mBAAmB,kBAEpB;AACT;",
|
|
5
5
|
"names": ["React"]
|
|
6
6
|
}
|
|
@@ -39,19 +39,22 @@ module.exports = __toCommonJS(createStyledContext_exports);
|
|
|
39
39
|
var import_jsx_runtime = require("react/jsx-runtime"),
|
|
40
40
|
import_react = __toESM(require("react"), 1),
|
|
41
41
|
import_mergeProps = require("./mergeProps.native.js"),
|
|
42
|
-
import_objectIdentityKey = require("./objectIdentityKey.native.js")
|
|
42
|
+
import_objectIdentityKey = require("./objectIdentityKey.native.js"),
|
|
43
|
+
createReactContext = import_react.default[Math.random(), "createContext"],
|
|
44
|
+
useReactMemo = import_react.default[Math.random(), "useMemo"],
|
|
45
|
+
useReactContext = import_react.default[Math.random(), "useContext"];
|
|
43
46
|
function createStyledContext(defaultValues) {
|
|
44
47
|
"use no memo";
|
|
45
48
|
|
|
46
49
|
var namespace = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "",
|
|
47
|
-
OGContext =
|
|
50
|
+
OGContext = createReactContext(defaultValues),
|
|
48
51
|
OGProvider = OGContext.Provider,
|
|
49
52
|
Context = OGContext,
|
|
50
53
|
scopedContexts = /* @__PURE__ */new Map(),
|
|
51
|
-
LastScopeInNamespace =
|
|
54
|
+
LastScopeInNamespace = createReactContext(namespace);
|
|
52
55
|
function getOrCreateScopedContext(scope) {
|
|
53
56
|
var ScopedContext = scopedContexts.get(scope);
|
|
54
|
-
return ScopedContext || (ScopedContext =
|
|
57
|
+
return ScopedContext || (ScopedContext = createReactContext(defaultValues), scopedContexts.set(scope, ScopedContext)), ScopedContext;
|
|
55
58
|
}
|
|
56
59
|
var getNamespacedScope = function (scope) {
|
|
57
60
|
return namespace ? `${namespace}--${scope}` : scope;
|
|
@@ -65,7 +68,7 @@ function createStyledContext(defaultValues) {
|
|
|
65
68
|
...values
|
|
66
69
|
} = param,
|
|
67
70
|
scope = getNamespacedScope(scopeIn),
|
|
68
|
-
next =
|
|
71
|
+
next = useReactMemo(function () {
|
|
69
72
|
return __disableMergeDefaultValues ? values : (0, import_mergeProps.mergeProps)(defaultValues, values);
|
|
70
73
|
}, [(0, import_objectIdentityKey.objectIdentityKey)(values)]),
|
|
71
74
|
ScopedProvider = OGProvider;
|
|
@@ -79,10 +82,10 @@ function createStyledContext(defaultValues) {
|
|
|
79
82
|
},
|
|
80
83
|
useStyledContext = function () {
|
|
81
84
|
var scopeIn = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "",
|
|
82
|
-
lastScopeInNamespace = (
|
|
85
|
+
lastScopeInNamespace = useReactContext(LastScopeInNamespace),
|
|
83
86
|
scope = namespace ? scopeIn ? getNamespacedScope(scopeIn) : lastScopeInNamespace : scopeIn,
|
|
84
87
|
context = scope ? getOrCreateScopedContext(scope) : OGContext,
|
|
85
|
-
value =
|
|
88
|
+
value = useReactContext(context);
|
|
86
89
|
return value;
|
|
87
90
|
};
|
|
88
91
|
return Context.Provider = Provider, Context.props = defaultValues, Context.context = OGContext, Context.useStyledContext = useStyledContext, Context;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","createStyledContext_exports","__export","createStyledContext","module","exports","import_jsx_runtime","require","import_react","__toESM","import_mergeProps","import_objectIdentityKey","
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","createStyledContext_exports","__export","createStyledContext","module","exports","import_jsx_runtime","require","import_react","__toESM","import_mergeProps","import_objectIdentityKey","createReactContext","default","Math","random","useReactMemo","useReactContext","defaultValues","namespace","arguments","length","OGContext","OGProvider","Provider","Context","scopedContexts","Map","LastScopeInNamespace","getOrCreateScopedContext","scope","ScopedContext","get","set","getNamespacedScope","param","children","scopeIn","__disableMergeDefaultValues","values","next","mergeProps","objectIdentityKey","ScopedProvider","jsx"],"sources":["../../../src/helpers/createStyledContext.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,2BAAA;AAAAC,QAAA,CAAAD,2BAAA;EAAAE,mBAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAAkB,CAAAK,2BAElB;AAQA,IAAAK,kBAAM,GAAAC,OAAqB,oBACzB,CAAK;EAAAC,YAAW,GAAAC,OAAA,CAClBF,OACM,WAAe;EAAAG,iBAAM,GAAAH,OAAK,yBAAgC;EAC1DI,wBAAkB,GAAAJ,OAAA,gCACN;EAAAK,kBAClB,GAAAJ,YAAA,CAAAK,OAAA,CAAAC,IAAA,CAAAC,MAAA;EAAAC,YAAA,GAAAR,YAAA,CAAAK,OAAA,CAAAC,IAAA,CAAAC,MAAA;EAAAE,eAAA,GAAAT,YAAA,CAAAK,OAAA,CAAAC,IAAA,CAAAC,MAAA;AAEO,SAASZ,oBACde,aAAA,EACA;EAIA;;EAEA,IAAAC,SAAM,GAAAC,SAAY,CAAAC,MAAA,QAA6CD,SAAA,CAAa,OACtE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
|
|
3
3
|
import { objectIdentityKey } from "./objectIdentityKey";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
const createReactContext = React[Math.random(), "createContext"], useReactMemo = React[Math.random(), "useMemo"], useReactContext = React[Math.random(), "useContext"];
|
|
5
6
|
function createStyledContext(defaultValues, namespace = "") {
|
|
6
7
|
"use no memo";
|
|
7
|
-
const OGContext =
|
|
8
|
+
const OGContext = createReactContext(defaultValues), OGProvider = OGContext.Provider, Context = OGContext, scopedContexts = /* @__PURE__ */ new Map(), LastScopeInNamespace = createReactContext(namespace);
|
|
8
9
|
function getOrCreateScopedContext(scope) {
|
|
9
10
|
let ScopedContext = scopedContexts.get(scope);
|
|
10
|
-
return ScopedContext || (ScopedContext =
|
|
11
|
+
return ScopedContext || (ScopedContext = createReactContext(defaultValues), scopedContexts.set(scope, ScopedContext)), ScopedContext;
|
|
11
12
|
}
|
|
12
13
|
const getNamespacedScope = (scope) => namespace ? `${namespace}--${scope}` : scope, Provider = ({
|
|
13
14
|
children,
|
|
@@ -16,12 +17,12 @@ function createStyledContext(defaultValues, namespace = "") {
|
|
|
16
17
|
__disableMergeDefaultValues,
|
|
17
18
|
...values
|
|
18
19
|
}) => {
|
|
19
|
-
const scope = getNamespacedScope(scopeIn), next =
|
|
20
|
+
const scope = getNamespacedScope(scopeIn), next = useReactMemo(() => __disableMergeDefaultValues ? values : mergeProps(defaultValues, values), [objectIdentityKey(values)]);
|
|
20
21
|
let ScopedProvider = OGProvider;
|
|
21
22
|
return scope && (ScopedProvider = getOrCreateScopedContext(scope).Provider), /* @__PURE__ */ jsx(LastScopeInNamespace.Provider, { value: scope, children: /* @__PURE__ */ jsx(ScopedProvider, { value: next, children }) });
|
|
22
23
|
}, useStyledContext = (scopeIn = "") => {
|
|
23
|
-
const lastScopeInNamespace =
|
|
24
|
-
return
|
|
24
|
+
const lastScopeInNamespace = useReactContext(LastScopeInNamespace), scope = namespace ? scopeIn ? getNamespacedScope(scopeIn) : lastScopeInNamespace : scopeIn, context = scope ? getOrCreateScopedContext(scope) : OGContext;
|
|
25
|
+
return useReactContext(context);
|
|
25
26
|
};
|
|
26
27
|
return Context.Provider = Provider, Context.props = defaultValues, Context.context = OGContext, Context.useStyledContext = useStyledContext, Context;
|
|
27
28
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/createStyledContext.tsx"],
|
|
4
|
-
"mappings": "AACA,OAAO,
|
|
4
|
+
"mappings": "AACA,OAAO,WAAW;AAElB,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAgE1B;AAzDR,MAAM,qBAAqB,MACzB,KAAK,OAAO,GAAI,eAClB,GACM,eAAe,MAAM,KAAK,OAAO,GAAI,SAAqB,GAC1D,kBAAkB,MACtB,KAAK,OAAO,GAAI,YAClB;AAEO,SAAS,oBACd,eACA,YAAY,IACiB;AAG7B;AAEA,QAAM,YAAY,mBAA6C,aAAa,GACtE,aAAa,UAAU,UACvB,UAAU,WACV,iBAAiB,oBAAI,IAA+C,GACpE,uBAAuB,mBAA2B,SAAS;AAEjE,WAAS,yBAAyB,OAAe;AAC/C,QAAI,gBAAgB,eAAe,IAAI,KAAK;AAC5C,WAAK,kBACH,gBAAgB,mBAA6C,aAAa,GAC1E,eAAe,IAAI,OAAO,aAAa,IAElC;AAAA,EACT;AAEA,QAAM,qBAAqB,CAAC,UAC1B,YAAY,GAAG,SAAS,KAAK,KAAK,KAAK,OAEnC,WAAW,CAAC;AAAA,IAChB;AAAA,IACA,OAAO;AAAA;AAAA,IAEP;AAAA,IACA,GAAG;AAAA,EACL,MAA8D;AAC5D,UAAM,QAAQ,mBAAmB,OAAO,GAElC,OAAO,aAAa,MACpB,8BAEK,SAEF,WAAW,eAAgB,MAAM,GACvC,CAAC,kBAAkB,MAAM,CAAC,CAAC;AAE9B,QAAI,iBAAiB;AACrB,WAAI,UACF,iBAAiB,yBAAyB,KAAK,EAAE,WAGjD,oBAAC,qBAAqB,UAArB,EAA8B,OAAO,OACpC,8BAAC,kBAAe,OAAO,MAAuB,UAAS,GACzD;AAAA,EAEJ,GAGM,mBAAmB,CAAC,UAAU,OAAO;AACzC,UAAM,uBAAuB,gBAAgB,oBAAoB,GAC3D,QAAQ,YACV,UACE,mBAAmB,OAAO,IAC1B,uBACF,SACE,UAAU,QAAQ,yBAAyB,KAAK,IAAI;AAE1D,WADc,gBAAgB,OAAQ;AAAA,EAExC;AAGA,iBAAQ,WAAW,UACnB,QAAQ,QAAQ,eAChB,QAAQ,UAAU,WAClB,QAAQ,mBAAmB,kBAEpB;AACT;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { mergeProps } from "./mergeProps.mjs";
|
|
3
3
|
import { objectIdentityKey } from "./objectIdentityKey.mjs";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
const createReactContext = React[Math.random(), "createContext"],
|
|
6
|
+
useReactMemo = React[Math.random(), "useMemo"],
|
|
7
|
+
useReactContext = React[Math.random(), "useContext"];
|
|
5
8
|
function createStyledContext(defaultValues, namespace = "") {
|
|
6
9
|
"use no memo";
|
|
7
10
|
|
|
8
|
-
const OGContext =
|
|
11
|
+
const OGContext = createReactContext(defaultValues),
|
|
9
12
|
OGProvider = OGContext.Provider,
|
|
10
13
|
Context = OGContext,
|
|
11
14
|
scopedContexts = /* @__PURE__ */new Map(),
|
|
12
|
-
LastScopeInNamespace =
|
|
15
|
+
LastScopeInNamespace = createReactContext(namespace);
|
|
13
16
|
function getOrCreateScopedContext(scope) {
|
|
14
17
|
let ScopedContext = scopedContexts.get(scope);
|
|
15
|
-
return ScopedContext || (ScopedContext =
|
|
18
|
+
return ScopedContext || (ScopedContext = createReactContext(defaultValues), scopedContexts.set(scope, ScopedContext)), ScopedContext;
|
|
16
19
|
}
|
|
17
20
|
const getNamespacedScope = scope => namespace ? `${namespace}--${scope}` : scope,
|
|
18
21
|
Provider = ({
|
|
@@ -23,7 +26,7 @@ function createStyledContext(defaultValues, namespace = "") {
|
|
|
23
26
|
...values
|
|
24
27
|
}) => {
|
|
25
28
|
const scope = getNamespacedScope(scopeIn),
|
|
26
|
-
next =
|
|
29
|
+
next = useReactMemo(() => __disableMergeDefaultValues ? values : mergeProps(defaultValues, values), [objectIdentityKey(values)]);
|
|
27
30
|
let ScopedProvider = OGProvider;
|
|
28
31
|
return scope && (ScopedProvider = getOrCreateScopedContext(scope).Provider), /* @__PURE__ */jsx(LastScopeInNamespace.Provider, {
|
|
29
32
|
value: scope,
|
|
@@ -34,10 +37,10 @@ function createStyledContext(defaultValues, namespace = "") {
|
|
|
34
37
|
});
|
|
35
38
|
},
|
|
36
39
|
useStyledContext = (scopeIn = "") => {
|
|
37
|
-
const lastScopeInNamespace =
|
|
40
|
+
const lastScopeInNamespace = useReactContext(LastScopeInNamespace),
|
|
38
41
|
scope = namespace ? scopeIn ? getNamespacedScope(scopeIn) : lastScopeInNamespace : scopeIn,
|
|
39
42
|
context = scope ? getOrCreateScopedContext(scope) : OGContext;
|
|
40
|
-
return
|
|
43
|
+
return useReactContext(context);
|
|
41
44
|
};
|
|
42
45
|
return Context.Provider = Provider, Context.props = defaultValues, Context.context = OGContext, Context.useStyledContext = useStyledContext, Context;
|
|
43
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","mergeProps","objectIdentityKey","jsx","createReactContext","Math","random","useReactMemo","useReactContext","createStyledContext","defaultValues","namespace","OGContext","OGProvider","Provider","Context","scopedContexts","Map","LastScopeInNamespace","getOrCreateScopedContext","scope","ScopedContext","get","set","getNamespacedScope","children","scopeIn","__disableMergeDefaultValues","values","next","ScopedProvider","value","useStyledContext","lastScopeInNamespace","context","props"],"sources":["../../../src/helpers/createStyledContext.tsx"],"sourcesContent":[null],"mappings":"AACA,OAAOA,KA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,GAAiBjB,UAAA;MACrB,OAAIO,KAAA,KACFU,cAAA,GAAiBX,wBAAA,CAAyBC,KAAK,EAAEN,QAAA,GAGjD,eAAAX,GAAA,CAACe,oBAAA,CAAqBJ,QAAA,EAArB;QAA8BiB,KAAA,EAAOX,KAAA;QACpCK,QAAA,iBAAAtB,GAAA,CAAC2B,cAAA;UAAeC,KAAA,EAAOF,IAAA;UAAuBJ;QAAA,CAAS;MAAA,CACzD;IAEJ;IAGMO,gBAAA,GAAmBA,CAACN,OAAA,GAAU,OAAO;MACzC,MAAMO,oBAAA,GAAuBzB,eAAA,CAAgBU,oBAAoB;QAC3DE,KAAA,GAAQT,SAAA,GACVe,OAAA,GACEF,kBAAA,CAAmBE,OAAO,IAC1BO,oBAAA,GACFP,OAAA;QACEQ,OAAA,GAAUd,KAAA,GAAQD,wBAAA,CAAyBC,KAAK,IAAIR,SAAA;MAE1D,OADcJ,eAAA,CAAgB0B,OAAQ;IAExC;EAGA,OAAAnB,OAAA,CAAQD,QAAA,GAAWA,QAAA,EACnBC,OAAA,CAAQoB,KAAA,GAAQzB,aAAA,EAChBK,OAAA,CAAQmB,OAAA,GAAUtB,SAAA,EAClBG,OAAA,CAAQiB,gBAAA,GAAmBA,gBAAA,EAEpBjB,OAAA;AACT","ignoreList":[]}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React
|
|
2
|
+
import React from "react";
|
|
3
3
|
import { mergeProps } from "./mergeProps.native.js";
|
|
4
4
|
import { objectIdentityKey } from "./objectIdentityKey.native.js";
|
|
5
|
+
var createReactContext = React[Math.random(), "createContext"],
|
|
6
|
+
useReactMemo = React[Math.random(), "useMemo"],
|
|
7
|
+
useReactContext = React[Math.random(), "useContext"];
|
|
5
8
|
function createStyledContext(defaultValues) {
|
|
6
9
|
"use no memo";
|
|
7
10
|
|
|
8
11
|
var namespace = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "",
|
|
9
|
-
OGContext =
|
|
12
|
+
OGContext = createReactContext(defaultValues),
|
|
10
13
|
OGProvider = OGContext.Provider,
|
|
11
14
|
Context = OGContext,
|
|
12
15
|
scopedContexts = /* @__PURE__ */new Map(),
|
|
13
|
-
LastScopeInNamespace =
|
|
16
|
+
LastScopeInNamespace = createReactContext(namespace);
|
|
14
17
|
function getOrCreateScopedContext(scope) {
|
|
15
18
|
var ScopedContext = scopedContexts.get(scope);
|
|
16
|
-
return ScopedContext || (ScopedContext =
|
|
19
|
+
return ScopedContext || (ScopedContext = createReactContext(defaultValues), scopedContexts.set(scope, ScopedContext)), ScopedContext;
|
|
17
20
|
}
|
|
18
21
|
var getNamespacedScope = function (scope) {
|
|
19
22
|
return namespace ? `${namespace}--${scope}` : scope;
|
|
@@ -27,7 +30,7 @@ function createStyledContext(defaultValues) {
|
|
|
27
30
|
...values
|
|
28
31
|
} = param,
|
|
29
32
|
scope = getNamespacedScope(scopeIn),
|
|
30
|
-
next =
|
|
33
|
+
next = useReactMemo(function () {
|
|
31
34
|
return __disableMergeDefaultValues ? values : mergeProps(defaultValues, values);
|
|
32
35
|
}, [objectIdentityKey(values)]),
|
|
33
36
|
ScopedProvider = OGProvider;
|
|
@@ -41,10 +44,10 @@ function createStyledContext(defaultValues) {
|
|
|
41
44
|
},
|
|
42
45
|
useStyledContext = function () {
|
|
43
46
|
var scopeIn = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "",
|
|
44
|
-
lastScopeInNamespace =
|
|
47
|
+
lastScopeInNamespace = useReactContext(LastScopeInNamespace),
|
|
45
48
|
scope = namespace ? scopeIn ? getNamespacedScope(scopeIn) : lastScopeInNamespace : scopeIn,
|
|
46
49
|
context = scope ? getOrCreateScopedContext(scope) : OGContext,
|
|
47
|
-
value =
|
|
50
|
+
value = useReactContext(context);
|
|
48
51
|
return value;
|
|
49
52
|
};
|
|
50
53
|
return Context.Provider = Provider, Context.props = defaultValues, Context.context = OGContext, Context.useStyledContext = useStyledContext, Context;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["jsx","_jsx","React","
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","React","mergeProps","objectIdentityKey","createReactContext","Math","random","useReactMemo","useReactContext","createStyledContext","defaultValues","namespace","arguments","length","OGContext","OGProvider","Provider","Context","scopedContexts","Map","LastScopeInNamespace","getOrCreateScopedContext","scope","ScopedContext","get","set","getNamespacedScope","param","children","scopeIn","__disableMergeDefaultValues","values","next","ScopedProvider","value"],"sources":["../../../src/helpers/createStyledContext.tsx"],"sourcesContent":[null],"mappings":"AACA,SAAOA,GAAA,IAAAC,IAAW;AAElB,OAAAC,KAAS;AACT,SAASC,UAAA,gCAAyB;AAgE1B,SAAAC,iBAAA;AAzDR,IAAAC,kBAAM,GAAAH,KAAqB,CAAAI,IACzB,CAAAC,MAAK,IAAO,eAAI;EAClBC,YACM,GAAAN,KAAe,CAAAI,IAAM,CAAAC,MAAK,IAAO,SAAI;EAAqBE,eAC1D,GAAAP,KAAkB,CAAAI,IACtB,CAAAC,MAAK,IAAO,YAAI;AAGX,SAASG,oBACdC,aAAA,EACA;EAIA;;EAEA,IAAAC,SAAM,GAAAC,SAAY,CAAAC,MAAA,QAA6CD,SAAA,CAAa,OACtE,SAAaA,SAAA,CAAU;IAAAE,SACvB,GAAUV,kBACV,CAAAM,aAAiB;IAAAK,UAAA,GAAID,SACrB,CAAAE,QAAA;IAAAC,OAAA,GAAuBH,SAAA;IAAAI,cAA2B,GAAS,mBAAAC,GAAA;IAAAC,oBAAA,GAAAhB,kBAAA,CAAAO,SAAA;EAEjE,SAASU,yBAAyBC,KAAA,EAAe;IAC/C,IAAIC,aAAA,GAAgBL,cAAA,CAAeM,GAAA,CAAIF,KAAK;IAC5C,OAAKC,aAAA,KACHA,aAAA,GAAgBnB,kBAAA,CAA6CM,aAAa,GAC1EQ,cAAA,CAAeO,GAAA,CAAIH,KAAA,EAAOC,aAAa,IAElCA,aAAA;EACT;EAEA,IAAAG,kBAAM,YAAAA,CAAsBJ,KAC1B;MAGA,OAAAX,SAAA,MAAAA,SAAA,KAAAW,KAAA,KAAAA,KAAA;IAAA;IACAN,QAAO,YAAAA,CAAAW,KAAA;MAAA;UAEPC,QAAA;UACAN,KAAG,EAAAO,OAAA;UACL;UACEC,2BAAc;UAUd,GAAIC;QACJ,IAAAJ,KAAI;QAAAL,KAAA,GACFI,kBAAiB,CAAAG,OAAA;QAAAG,IAAA,GAAAzB,YAAgC,aAGjD;UAOE,OAAAuB,2BAA8B,GAAOC,MAAA,GAAA7B,UAAA,CAAAQ,aAAA,EAAAqB,MAAA;QACzC,IAQA5B,iBADc,CAAA4B,MAAgB,EAEhC;QAAAE,cAAA,GAAAlB,UAAA;MAGA,OAAAO,KAAA,KAAQW,cAAW,GACnBZ,wBAAgB,CAAAC,KAAA,CAChB,CAAAN,QAAQ,kBAAUhB,IAClB,CAAAoB,oBAAQ,CAAAJ,QAAmB;QAG7BkB,KAAA,EAAAZ,KAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "2.0.0-rc.13",
|
|
3
|
+
"version": "2.0.0-rc.13-1771253253067",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Nate Wienert"
|
|
@@ -55,20 +55,20 @@
|
|
|
55
55
|
"clean:build": "tamagui-build clean:build"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@tamagui/compose-refs": "2.0.0-rc.13",
|
|
59
|
-
"@tamagui/constants": "2.0.0-rc.13",
|
|
60
|
-
"@tamagui/helpers": "2.0.0-rc.13",
|
|
61
|
-
"@tamagui/is-equal-shallow": "2.0.0-rc.13",
|
|
62
|
-
"@tamagui/native": "2.0.0-rc.13",
|
|
63
|
-
"@tamagui/normalize-css-color": "2.0.0-rc.13",
|
|
64
|
-
"@tamagui/timer": "2.0.0-rc.13",
|
|
65
|
-
"@tamagui/types": "2.0.0-rc.13",
|
|
66
|
-
"@tamagui/use-did-finish-ssr": "2.0.0-rc.13",
|
|
67
|
-
"@tamagui/use-event": "2.0.0-rc.13",
|
|
68
|
-
"@tamagui/use-force-update": "2.0.0-rc.13"
|
|
58
|
+
"@tamagui/compose-refs": "2.0.0-rc.13-1771253253067",
|
|
59
|
+
"@tamagui/constants": "2.0.0-rc.13-1771253253067",
|
|
60
|
+
"@tamagui/helpers": "2.0.0-rc.13-1771253253067",
|
|
61
|
+
"@tamagui/is-equal-shallow": "2.0.0-rc.13-1771253253067",
|
|
62
|
+
"@tamagui/native": "2.0.0-rc.13-1771253253067",
|
|
63
|
+
"@tamagui/normalize-css-color": "2.0.0-rc.13-1771253253067",
|
|
64
|
+
"@tamagui/timer": "2.0.0-rc.13-1771253253067",
|
|
65
|
+
"@tamagui/types": "2.0.0-rc.13-1771253253067",
|
|
66
|
+
"@tamagui/use-did-finish-ssr": "2.0.0-rc.13-1771253253067",
|
|
67
|
+
"@tamagui/use-event": "2.0.0-rc.13-1771253253067",
|
|
68
|
+
"@tamagui/use-force-update": "2.0.0-rc.13-1771253253067"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@tamagui/build": "2.0.0-rc.13",
|
|
71
|
+
"@tamagui/build": "2.0.0-rc.13-1771253253067",
|
|
72
72
|
"@testing-library/react": "^16.1.0",
|
|
73
73
|
"csstype": "^3.0.10",
|
|
74
74
|
"react": ">=19",
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import type { Context, ReactNode } from 'react'
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react'
|
|
3
3
|
import type { StyledContext } from '../types'
|
|
4
4
|
import { mergeProps } from './mergeProps'
|
|
5
5
|
import { objectIdentityKey } from './objectIdentityKey'
|
|
6
6
|
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
// workaround for vite ssr deps hmr corruption - Math.random() prevents esbuild
|
|
8
|
+
// from statically analyzing and converting to import_react.default pattern
|
|
9
|
+
// which breaks during hmr due to lazy __esm initialization order issues
|
|
10
|
+
// futher, specifically React.createContext is optimized oddly by React compiler
|
|
11
|
+
// and our uncommon usage confuses it
|
|
12
|
+
const createReactContext = React[
|
|
13
|
+
Math.random() ? 'createContext' : 'createContext'
|
|
14
|
+
] as typeof React.createContext
|
|
15
|
+
const useReactMemo = React[Math.random() ? 'useMemo' : 'useMemo'] as typeof React.useMemo
|
|
16
|
+
const useReactContext = React[
|
|
17
|
+
Math.random() ? 'useContext' : 'useContext'
|
|
18
|
+
] as typeof React.useContext
|
|
14
19
|
|
|
15
20
|
export function createStyledContext<VariantProps extends Record<string, any>>(
|
|
16
21
|
defaultValues?: VariantProps,
|
|
@@ -20,16 +25,16 @@ export function createStyledContext<VariantProps extends Record<string, any>>(
|
|
|
20
25
|
// how we change the context value
|
|
21
26
|
'use no memo'
|
|
22
27
|
|
|
23
|
-
const OGContext =
|
|
28
|
+
const OGContext = createReactContext<VariantProps | undefined>(defaultValues)
|
|
24
29
|
const OGProvider = OGContext.Provider
|
|
25
30
|
const Context = OGContext as any as StyledContext<VariantProps>
|
|
26
31
|
const scopedContexts = new Map<string, Context<VariantProps | undefined>>()
|
|
27
|
-
const LastScopeInNamespace =
|
|
32
|
+
const LastScopeInNamespace = createReactContext<string>(namespace)
|
|
28
33
|
|
|
29
34
|
function getOrCreateScopedContext(scope: string) {
|
|
30
35
|
let ScopedContext = scopedContexts.get(scope)
|
|
31
36
|
if (!ScopedContext) {
|
|
32
|
-
ScopedContext =
|
|
37
|
+
ScopedContext = createReactContext<VariantProps | undefined>(defaultValues)
|
|
33
38
|
scopedContexts.set(scope, ScopedContext)
|
|
34
39
|
}
|
|
35
40
|
return ScopedContext!
|
|
@@ -47,7 +52,7 @@ export function createStyledContext<VariantProps extends Record<string, any>>(
|
|
|
47
52
|
}: VariantProps & { children?: ReactNode; scope: string }) => {
|
|
48
53
|
const scope = getNamespacedScope(scopeIn)
|
|
49
54
|
|
|
50
|
-
const next =
|
|
55
|
+
const next = useReactMemo(() => {
|
|
51
56
|
if (__disableMergeDefaultValues) {
|
|
52
57
|
// we already merged and want to keep ordering
|
|
53
58
|
return values
|
|
@@ -68,14 +73,14 @@ export function createStyledContext<VariantProps extends Record<string, any>>(
|
|
|
68
73
|
|
|
69
74
|
// use consumerComponent just to give a better error message
|
|
70
75
|
const useStyledContext = (scopeIn = '') => {
|
|
71
|
-
const lastScopeInNamespace =
|
|
76
|
+
const lastScopeInNamespace = useReactContext(LastScopeInNamespace)
|
|
72
77
|
const scope = namespace
|
|
73
78
|
? scopeIn
|
|
74
79
|
? getNamespacedScope(scopeIn)
|
|
75
80
|
: lastScopeInNamespace
|
|
76
81
|
: scopeIn
|
|
77
82
|
const context = scope ? getOrCreateScopedContext(scope) : OGContext
|
|
78
|
-
const value =
|
|
83
|
+
const value = useReactContext(context!) as VariantProps
|
|
79
84
|
return value
|
|
80
85
|
}
|
|
81
86
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createStyledContext.d.ts","sourceRoot":"","sources":["../../src/helpers/createStyledContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"createStyledContext.d.ts","sourceRoot":"","sources":["../../src/helpers/createStyledContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAiB7C,wBAAgB,mBAAmB,CAAC,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1E,aAAa,CAAC,EAAE,YAAY,EAC5B,SAAS,SAAK,GACb,aAAa,CAAC,YAAY,CAAC,CAuE7B"}
|