@react-native-styled-system/core 1.2.2 → 1.3.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSxComponent.d.ts","sourceRoot":"","sources":["../../../../src/util/createSxComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAqB,MAAM,OAAO,CAAC;AAK1C,wBAAgB,iBAAiB,CAAC,KAAK,SAAS,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAYtF;AAED,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAY1F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-styled-system/core",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "description": "React Native Styled System",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "types": "lib/typescript/src/index.d.ts",
@@ -67,5 +67,5 @@
67
67
  "**/*.test.*"
68
68
  ]
69
69
  },
70
- "gitHead": "140df13db7628f158a4094252af671c584ebe8eb"
70
+ "gitHead": "d8939b5cb012a3d68bca99530c1c392f0ac1a477"
71
71
  }
package/src/index.ts CHANGED
@@ -6,3 +6,4 @@ export * from './hook/useSxStyle';
6
6
  export * from './hook/useSxTokens';
7
7
  export * from './provider/StyledSystemProvider';
8
8
  export * from './util/propsToThemedStyle';
9
+ export * from './util/createSxComponent';
@@ -0,0 +1,33 @@
1
+ import type { ComponentType } from 'react';
2
+ import React, { forwardRef } from 'react';
3
+
4
+ import type { SxProps, TextSxProps } from '../@types/SxProps';
5
+ import { useSx } from '../hook/useSx';
6
+
7
+ export function createSxComponent<Props extends object, Ref>(Base: ComponentType<Props>) {
8
+ return () => {
9
+ const Transformed = forwardRef<Ref, Props & SxProps>(function (props, ref) {
10
+ const { filteredProps, getStyle } = useSx(props);
11
+
12
+ return <Base {...(filteredProps as any)} style={getStyle()} ref={ref as any} />;
13
+ });
14
+
15
+ Transformed.displayName = `Sx.${Base.displayName || Base.name || 'NoName'}`;
16
+
17
+ return Transformed;
18
+ };
19
+ }
20
+
21
+ export function createSxTextComponent<Props extends object, Ref>(Base: ComponentType<Props>) {
22
+ return () => {
23
+ const Transformed = forwardRef<Ref, Props & TextSxProps>(function (props, ref) {
24
+ const { filteredProps, getStyle } = useSx(props, { styleType: 'TextStyle' });
25
+
26
+ return <Base {...(filteredProps as any)} style={getStyle()} ref={ref as any} />;
27
+ });
28
+
29
+ Transformed.displayName = `Sx.${Base.displayName || Base.name || 'NoName'}`;
30
+
31
+ return Transformed;
32
+ };
33
+ }