@tamagui/web 1.47.2 → 1.47.4
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/withStaticProperties.js +12 -7
- package/dist/cjs/helpers/withStaticProperties.js.map +1 -1
- package/dist/esm/helpers/withStaticProperties.js +12 -7
- package/dist/esm/helpers/withStaticProperties.js.map +1 -1
- package/package.json +9 -9
- package/src/helpers/withStaticProperties.tsx +20 -11
- package/types/helpers/withStaticProperties.d.ts.map +1 -1
|
@@ -21,18 +21,23 @@ __export(withStaticProperties_exports, {
|
|
|
21
21
|
withStaticProperties: () => withStaticProperties
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(withStaticProperties_exports);
|
|
24
|
-
|
|
24
|
+
var import_react = require("react");
|
|
25
|
+
const Decorated = Symbol();
|
|
25
26
|
const withStaticProperties = function(component, staticProps) {
|
|
26
|
-
const next =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
`Error: You're calling withStaticProperties() on a component that already has withStaticProperties() assigned to it! This will cause super strange errors.`
|
|
27
|
+
const next = (() => {
|
|
28
|
+
if (component[Decorated]) {
|
|
29
|
+
return (0, import_react.forwardRef)(
|
|
30
|
+
(props, ref) => (0, import_react.createElement)(component, { ...props, ref })
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
return component;
|
|
34
|
+
})();
|
|
35
|
+
for (const key in component) {
|
|
36
|
+
const v = component[key];
|
|
37
|
+
next[key] = v && typeof v === "object" ? { ...v } : v;
|
|
34
38
|
}
|
|
35
39
|
Object.assign(next, staticProps);
|
|
40
|
+
next[Decorated] = true;
|
|
36
41
|
return next;
|
|
37
42
|
};
|
|
38
43
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/withStaticProperties.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0C;AAE1C,MAAM,YAAY,OAAO;AAElB,MAAM,uBAAuB,SAClC,WACA,aACO;AAEP,QAAM,QAAQ,MAAM;AAClB,QAAI,UAAU,SAAS,GAAG;AACxB,iBAAO;AAAA,QAAW,CAAC,OAAO,YACxB,4BAAc,WAAkB,EAAE,GAAG,OAAO,IAAI,CAAC;AAAA,MACnD;AAAA,IACF;AACA,WAAO;AAAA,EACT,GAAG;AAGH,aAAW,OAAO,WAAW;AAC3B,UAAM,IAAI,UAAU,GAAG;AAEvB,SAAK,GAAG,IAAI,KAAK,OAAO,MAAM,WAAW,EAAE,GAAG,EAAE,IAAI;AAAA,EACtD;AAGA,SAAO,OAAO,MAAM,WAAW;AAC/B,OAAK,SAAS,IAAI;AAElB,SAAO;AACT;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import { createElement, forwardRef } from "react";
|
|
2
|
+
const Decorated = Symbol();
|
|
2
3
|
const withStaticProperties = function(component, staticProps) {
|
|
3
|
-
const next =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
`Error: You're calling withStaticProperties() on a component that already has withStaticProperties() assigned to it! This will cause super strange errors.`
|
|
4
|
+
const next = (() => {
|
|
5
|
+
if (component[Decorated]) {
|
|
6
|
+
return forwardRef(
|
|
7
|
+
(props, ref) => createElement(component, { ...props, ref })
|
|
8
8
|
);
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
return component;
|
|
11
|
+
})();
|
|
12
|
+
for (const key in component) {
|
|
13
|
+
const v = component[key];
|
|
14
|
+
next[key] = v && typeof v === "object" ? { ...v } : v;
|
|
11
15
|
}
|
|
12
16
|
Object.assign(next, staticProps);
|
|
17
|
+
next[Decorated] = true;
|
|
13
18
|
return next;
|
|
14
19
|
};
|
|
15
20
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/withStaticProperties.tsx"],
|
|
4
|
-
"mappings": "AAAA,MAAM,
|
|
4
|
+
"mappings": "AAAA,SAAS,eAAe,kBAAkB;AAE1C,MAAM,YAAY,OAAO;AAElB,MAAM,uBAAuB,SAClC,WACA,aACO;AAEP,QAAM,QAAQ,MAAM;AAClB,QAAI,UAAU,SAAS,GAAG;AACxB,aAAO;AAAA,QAAW,CAAC,OAAO,QACxB,cAAc,WAAkB,EAAE,GAAG,OAAO,IAAI,CAAC;AAAA,MACnD;AAAA,IACF;AACA,WAAO;AAAA,EACT,GAAG;AAGH,aAAW,OAAO,WAAW;AAC3B,UAAM,IAAI,UAAU,GAAG;AAEvB,SAAK,GAAG,IAAI,KAAK,OAAO,MAAM,WAAW,EAAE,GAAG,EAAE,IAAI;AAAA,EACtD;AAGA,SAAO,OAAO,MAAM,WAAW;AAC/B,OAAK,SAAS,IAAI;AAElB,SAAO;AACT;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "1.47.
|
|
3
|
+
"version": "1.47.4",
|
|
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.47.
|
|
31
|
-
"@tamagui/constants": "1.47.
|
|
32
|
-
"@tamagui/helpers": "1.47.
|
|
33
|
-
"@tamagui/normalize-css-color": "1.47.
|
|
34
|
-
"@tamagui/use-did-finish-ssr": "1.47.
|
|
35
|
-
"@tamagui/use-event": "1.47.
|
|
36
|
-
"@tamagui/use-force-update": "1.47.
|
|
30
|
+
"@tamagui/compose-refs": "1.47.4",
|
|
31
|
+
"@tamagui/constants": "1.47.4",
|
|
32
|
+
"@tamagui/helpers": "1.47.4",
|
|
33
|
+
"@tamagui/normalize-css-color": "1.47.4",
|
|
34
|
+
"@tamagui/use-did-finish-ssr": "1.47.4",
|
|
35
|
+
"@tamagui/use-event": "1.47.4",
|
|
36
|
+
"@tamagui/use-force-update": "1.47.4"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": "*"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@tamagui/build": "1.47.
|
|
42
|
+
"@tamagui/build": "1.47.4",
|
|
43
43
|
"@testing-library/react": "^13.4.0",
|
|
44
44
|
"csstype": "^3.0.10",
|
|
45
45
|
"react": "^18.2.0",
|
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
const Decorated = Symbol()
|
|
2
4
|
|
|
3
5
|
export const withStaticProperties = function <A extends Function, B>(
|
|
4
6
|
component: A,
|
|
5
7
|
staticProps: B
|
|
6
8
|
): A & B {
|
|
7
|
-
// clone if
|
|
8
|
-
const next =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (next[WarnReAssignSymbol]) {
|
|
13
|
-
throw new Error(
|
|
14
|
-
`Error: You're calling withStaticProperties() on a component that already has withStaticProperties() assigned to it! This will cause super strange errors.`
|
|
9
|
+
// clone component if already wrapped once
|
|
10
|
+
const next = (() => {
|
|
11
|
+
if (component[Decorated]) {
|
|
12
|
+
return forwardRef((props, ref) =>
|
|
13
|
+
createElement(component as any, { ...props, ref })
|
|
15
14
|
)
|
|
16
15
|
}
|
|
17
|
-
|
|
16
|
+
return component
|
|
17
|
+
})()
|
|
18
|
+
|
|
19
|
+
// attach existing things again
|
|
20
|
+
for (const key in component) {
|
|
21
|
+
const v = component[key]
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
next[key] = v && typeof v === 'object' ? { ...v } : v
|
|
18
24
|
}
|
|
19
25
|
|
|
26
|
+
// add new things
|
|
20
27
|
Object.assign(next, staticProps)
|
|
21
|
-
|
|
28
|
+
next[Decorated] = true
|
|
29
|
+
|
|
30
|
+
return next as any as A & B
|
|
22
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withStaticProperties.d.ts","sourceRoot":"","sources":["../../src/helpers/withStaticProperties.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"withStaticProperties.d.ts","sourceRoot":"","sources":["../../src/helpers/withStaticProperties.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,gEA0BhC,CAAA"}
|