@tamagui/web 1.30.25 → 1.30.27
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.js +3 -1
- package/dist/cjs/helpers/createStyledContext.js.map +1 -1
- package/dist/cjs/helpers/objectIdentityKey.js +47 -0
- package/dist/cjs/helpers/objectIdentityKey.js.map +6 -0
- package/dist/esm/helpers/createStyledContext.js +3 -1
- package/dist/esm/helpers/createStyledContext.js.map +1 -1
- package/dist/esm/helpers/objectIdentityKey.js +23 -0
- package/dist/esm/helpers/objectIdentityKey.js.map +6 -0
- package/package.json +9 -9
- package/src/helpers/createStyledContext.tsx +4 -5
- package/src/helpers/objectIdentityKey.tsx +20 -0
- package/types/helpers/createStyledContext.d.ts.map +1 -1
- package/types/helpers/objectIdentityKey.d.ts +2 -0
- package/types/helpers/objectIdentityKey.d.ts.map +1 -0
|
@@ -23,6 +23,7 @@ __export(createStyledContext_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(createStyledContext_exports);
|
|
24
24
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
25
|
var import_react = require("react");
|
|
26
|
+
var import_objectIdentityKey = require("./objectIdentityKey");
|
|
26
27
|
function createStyledContext(props) {
|
|
27
28
|
const OGContext = (0, import_react.createContext)(null);
|
|
28
29
|
const OGProvider = OGContext.Provider;
|
|
@@ -31,7 +32,8 @@ function createStyledContext(props) {
|
|
|
31
32
|
children,
|
|
32
33
|
...values
|
|
33
34
|
}) => {
|
|
34
|
-
|
|
35
|
+
const value = (0, import_react.useMemo)(() => values, [(0, import_objectIdentityKey.objectIdentityKey)(values)]);
|
|
36
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OGProvider, { value, children });
|
|
35
37
|
};
|
|
36
38
|
Context.Provider = Provider;
|
|
37
39
|
Context.props = props;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/createStyledContext.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BW;AA5BX,mBAA0D;AAE1D,+BAAkC;AAc3B,SAAS,oBACd,OAC6B;AAC7B,QAAM,gBAAY,4BAAmB,IAAI;AACzC,QAAM,aAAa,UAAU;AAC7B,QAAM,UAAU;AAEhB,QAAM,WAAW,CAAC;AAAA,IAChB;AAAA,IACA,GAAG;AAAA,EACL,MAAqD;AACnD,UAAM,YAAQ,sBAAQ,MAAM,QAAQ,KAAC,4CAAkB,MAAM,CAAC,CAAC;AAC/D,WAAO,4CAAC,cAAW,OAAe,UAAS;AAAA,EAC7C;AAGA,UAAQ,WAAW;AACnB,UAAQ,QAAQ;AAEhB,SAAO;AACT;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var objectIdentityKey_exports = {};
|
|
20
|
+
__export(objectIdentityKey_exports, {
|
|
21
|
+
objectIdentityKey: () => objectIdentityKey
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(objectIdentityKey_exports);
|
|
24
|
+
function objectIdentityKey(obj) {
|
|
25
|
+
let k = "";
|
|
26
|
+
for (const key in obj) {
|
|
27
|
+
k += key;
|
|
28
|
+
const arg = obj[key];
|
|
29
|
+
let type = typeof arg;
|
|
30
|
+
if (!arg || type !== "object") {
|
|
31
|
+
k += type + arg;
|
|
32
|
+
} else if (cache.has(arg)) {
|
|
33
|
+
k += cache.get(arg);
|
|
34
|
+
} else {
|
|
35
|
+
let v = Math.random();
|
|
36
|
+
cache.set(arg, v);
|
|
37
|
+
k += v;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return k;
|
|
41
|
+
}
|
|
42
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
objectIdentityKey
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=objectIdentityKey.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/objectIdentityKey.tsx"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,kBAAkB,KAAa;AAC7C,MAAI,IAAI;AACR,aAAW,OAAO,KAAK;AACrB,SAAK;AACL,UAAM,MAAM,IAAI,GAAG;AACnB,QAAI,OAAO,OAAO;AAClB,QAAI,CAAC,OAAO,SAAS,UAAU;AAC7B,WAAK,OAAO;AAAA,IACd,WAAW,MAAM,IAAI,GAAG,GAAG;AACzB,WAAK,MAAM,IAAI,GAAG;AAAA,IACpB,OAAO;AACL,UAAI,IAAI,KAAK,OAAO;AACpB,YAAM,IAAI,KAAK,CAAC;AAChB,WAAK;AAAA,IACP;AAAA,EACF;AACA,SAAO;AACT;AAEA,MAAM,QAAQ,oBAAI,QAAQ;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useMemo } from "react";
|
|
3
|
+
import { objectIdentityKey } from "./objectIdentityKey";
|
|
3
4
|
function createStyledContext(props) {
|
|
4
5
|
const OGContext = createContext(null);
|
|
5
6
|
const OGProvider = OGContext.Provider;
|
|
@@ -8,7 +9,8 @@ function createStyledContext(props) {
|
|
|
8
9
|
children,
|
|
9
10
|
...values
|
|
10
11
|
}) => {
|
|
11
|
-
|
|
12
|
+
const value = useMemo(() => values, [objectIdentityKey(values)]);
|
|
13
|
+
return /* @__PURE__ */ jsx(OGProvider, { value, children });
|
|
12
14
|
};
|
|
13
15
|
Context.Provider = Provider;
|
|
14
16
|
Context.props = props;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/createStyledContext.tsx"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": "AA4BW;AA5BX,SAAgB,eAA2B,eAAe;AAE1D,SAAS,yBAAyB;AAc3B,SAAS,oBACd,OAC6B;AAC7B,QAAM,YAAY,cAAmB,IAAI;AACzC,QAAM,aAAa,UAAU;AAC7B,QAAM,UAAU;AAEhB,QAAM,WAAW,CAAC;AAAA,IAChB;AAAA,IACA,GAAG;AAAA,EACL,MAAqD;AACnD,UAAM,QAAQ,QAAQ,MAAM,QAAQ,CAAC,kBAAkB,MAAM,CAAC,CAAC;AAC/D,WAAO,oBAAC,cAAW,OAAe,UAAS;AAAA,EAC7C;AAGA,UAAQ,WAAW;AACnB,UAAQ,QAAQ;AAEhB,SAAO;AACT;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function objectIdentityKey(obj) {
|
|
2
|
+
let k = "";
|
|
3
|
+
for (const key in obj) {
|
|
4
|
+
k += key;
|
|
5
|
+
const arg = obj[key];
|
|
6
|
+
let type = typeof arg;
|
|
7
|
+
if (!arg || type !== "object") {
|
|
8
|
+
k += type + arg;
|
|
9
|
+
} else if (cache.has(arg)) {
|
|
10
|
+
k += cache.get(arg);
|
|
11
|
+
} else {
|
|
12
|
+
let v = Math.random();
|
|
13
|
+
cache.set(arg, v);
|
|
14
|
+
k += v;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return k;
|
|
18
|
+
}
|
|
19
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
20
|
+
export {
|
|
21
|
+
objectIdentityKey
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=objectIdentityKey.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/helpers/objectIdentityKey.tsx"],
|
|
4
|
+
"mappings": "AAAO,SAAS,kBAAkB,KAAa;AAC7C,MAAI,IAAI;AACR,aAAW,OAAO,KAAK;AACrB,SAAK;AACL,UAAM,MAAM,IAAI,GAAG;AACnB,QAAI,OAAO,OAAO;AAClB,QAAI,CAAC,OAAO,SAAS,UAAU;AAC7B,WAAK,OAAO;AAAA,IACd,WAAW,MAAM,IAAI,GAAG,GAAG;AACzB,WAAK,MAAM,IAAI,GAAG;AAAA,IACpB,OAAO;AACL,UAAI,IAAI,KAAK,OAAO;AACpB,YAAM,IAAI,KAAK,CAAC;AAChB,WAAK;AAAA,IACP;AAAA,EACF;AACA,SAAO;AACT;AAEA,MAAM,QAAQ,oBAAI,QAAQ;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.27",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,19 +27,19 @@
|
|
|
27
27
|
"reset.css"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tamagui/compose-refs": "1.30.
|
|
31
|
-
"@tamagui/constants": "1.30.
|
|
32
|
-
"@tamagui/helpers": "1.30.
|
|
33
|
-
"@tamagui/normalize-css-color": "1.30.
|
|
34
|
-
"@tamagui/use-did-finish-ssr": "1.30.
|
|
35
|
-
"@tamagui/use-event": "1.30.
|
|
36
|
-
"@tamagui/use-force-update": "1.30.
|
|
30
|
+
"@tamagui/compose-refs": "1.30.27",
|
|
31
|
+
"@tamagui/constants": "1.30.27",
|
|
32
|
+
"@tamagui/helpers": "1.30.27",
|
|
33
|
+
"@tamagui/normalize-css-color": "1.30.27",
|
|
34
|
+
"@tamagui/use-did-finish-ssr": "1.30.27",
|
|
35
|
+
"@tamagui/use-event": "1.30.27",
|
|
36
|
+
"@tamagui/use-force-update": "1.30.27"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": "*"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "1.30.
|
|
42
|
+
"@tamagui/build": "1.30.27",
|
|
43
43
|
"@testing-library/react": "^13.4.0",
|
|
44
44
|
"csstype": "^3.0.10",
|
|
45
45
|
"react": "^18.2.0",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { createContext, useContext, useMemo } from 'react'
|
|
2
2
|
|
|
3
|
+
import { objectIdentityKey } from './objectIdentityKey'
|
|
4
|
+
|
|
3
5
|
export type StyledContext<Props extends Object = any> = Omit<
|
|
4
6
|
React.Context<Props>,
|
|
5
7
|
'Provider'
|
|
@@ -23,11 +25,8 @@ export function createStyledContext<VariantProps extends Record<string, any>>(
|
|
|
23
25
|
children,
|
|
24
26
|
...values
|
|
25
27
|
}: VariantProps & { children?: React.ReactNode }) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{children}
|
|
29
|
-
</OGProvider>
|
|
30
|
-
)
|
|
28
|
+
const value = useMemo(() => values, [objectIdentityKey(values)])
|
|
29
|
+
return <OGProvider value={value}>{children}</OGProvider>
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
// @ts-ignore
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function objectIdentityKey(obj: Object) {
|
|
2
|
+
let k = ''
|
|
3
|
+
for (const key in obj) {
|
|
4
|
+
k += key
|
|
5
|
+
const arg = obj[key]
|
|
6
|
+
let type = typeof arg
|
|
7
|
+
if (!arg || type !== 'object') {
|
|
8
|
+
k += type + arg
|
|
9
|
+
} else if (cache.has(arg)) {
|
|
10
|
+
k += cache.get(arg)
|
|
11
|
+
} else {
|
|
12
|
+
let v = Math.random()
|
|
13
|
+
cache.set(arg, v)
|
|
14
|
+
k += v
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return k
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const cache = new WeakMap()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createStyledContext.d.ts","sourceRoot":"","sources":["../../src/helpers/createStyledContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"createStyledContext.d.ts","sourceRoot":"","sources":["../../src/helpers/createStyledContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAA;AAIjE,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,MAAM,GAAG,GAAG,IAAI,IAAI,CAC1D,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EACpB,UAAU,CACX,GAAG;IACF,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,KAAK,CAAC,uBAAuB,CACrC,OAAO,CAAC,KAAK,CAAC,GAAG;QACf,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;KAC3B,CACF,CAAA;CACF,CAAA;AAED,wBAAgB,mBAAmB,CAAC,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1E,KAAK,EAAE,YAAY,GAClB,aAAa,CAAC,YAAY,CAAC,CAkB7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectIdentityKey.d.ts","sourceRoot":"","sources":["../../src/helpers/objectIdentityKey.tsx"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,UAiB5C"}
|