@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.
@@ -21,18 +21,23 @@ __export(withStaticProperties_exports, {
21
21
  withStaticProperties: () => withStaticProperties
22
22
  });
23
23
  module.exports = __toCommonJS(withStaticProperties_exports);
24
- const WarnReAssignSymbol = Symbol();
24
+ var import_react = require("react");
25
+ const Decorated = Symbol();
25
26
  const withStaticProperties = function(component, staticProps) {
26
- const next = typeof component === "function" ? component : { ...component };
27
- if (process.env.NODE_ENV === "development") {
28
- if (next[WarnReAssignSymbol]) {
29
- throw new Error(
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
- next[WarnReAssignSymbol] = true;
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,qBAAqB,OAAO;AAE3B,MAAM,uBAAuB,SAClC,WACA,aACO;AAEP,QAAM,OAAO,OAAO,cAAc,aAAa,YAAY,EAAE,GAAI,UAAkB;AAGnF,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,KAAK,kBAAkB,GAAG;AAC5B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,SAAK,kBAAkB,IAAI;AAAA,EAC7B;AAEA,SAAO,OAAO,MAAM,WAAW;AAC/B,SAAO;AACT;",
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
- const WarnReAssignSymbol = Symbol();
1
+ import { createElement, forwardRef } from "react";
2
+ const Decorated = Symbol();
2
3
  const withStaticProperties = function(component, staticProps) {
3
- const next = typeof component === "function" ? component : { ...component };
4
- if (process.env.NODE_ENV === "development") {
5
- if (next[WarnReAssignSymbol]) {
6
- throw new Error(
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
- next[WarnReAssignSymbol] = true;
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,qBAAqB,OAAO;AAE3B,MAAM,uBAAuB,SAClC,WACA,aACO;AAEP,QAAM,OAAO,OAAO,cAAc,aAAa,YAAY,EAAE,GAAI,UAAkB;AAGnF,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,QAAI,KAAK,kBAAkB,GAAG;AAC5B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,SAAK,kBAAkB,IAAI;AAAA,EAC7B;AAEA,SAAO,OAAO,MAAM,WAAW;AAC/B,SAAO;AACT;",
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.2",
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.2",
31
- "@tamagui/constants": "1.47.2",
32
- "@tamagui/helpers": "1.47.2",
33
- "@tamagui/normalize-css-color": "1.47.2",
34
- "@tamagui/use-did-finish-ssr": "1.47.2",
35
- "@tamagui/use-event": "1.47.2",
36
- "@tamagui/use-force-update": "1.47.2"
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.2",
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
- const WarnReAssignSymbol = Symbol()
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 object to stay immutable
8
- const next = typeof component === 'function' ? component : { ...(component as any) }
9
-
10
- // nice dev helper that avoids super confusing errors
11
- if (process.env.NODE_ENV === 'development') {
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
- next[WarnReAssignSymbol] = true
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
- return next as A & B
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":"AAEA,eAAO,MAAM,oBAAoB,gEAmBhC,CAAA"}
1
+ {"version":3,"file":"withStaticProperties.d.ts","sourceRoot":"","sources":["../../src/helpers/withStaticProperties.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,gEA0BhC,CAAA"}