@codeandmoney/soelma 0.0.0-dev.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.
Files changed (111) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +31 -0
  3. package/.github/workflows/nodejs.yml +33 -0
  4. package/.size-limit.json +6 -0
  5. package/CHANGELOG.md +90 -0
  6. package/LICENSE +21 -0
  7. package/README.md +169 -0
  8. package/babel.config.js +3 -0
  9. package/docs/api.md +103 -0
  10. package/docs/appearance.md +54 -0
  11. package/docs/dark-mode.md +46 -0
  12. package/docs/dimensions.md +29 -0
  13. package/docs/i18n.md +67 -0
  14. package/docs/logo.png +0 -0
  15. package/docs/media-query.md +274 -0
  16. package/docs/orientation.md +44 -0
  17. package/docs/safe-area.md +62 -0
  18. package/docs/testting.md +51 -0
  19. package/docs/ts.md +127 -0
  20. package/example/AppStyleX/.watchmanconfig +1 -0
  21. package/example/AppStyleX/android/build.gradle +26 -0
  22. package/example/AppStyleX/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  23. package/example/AppStyleX/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  24. package/example/AppStyleX/android/gradle.properties +53 -0
  25. package/example/AppStyleX/android/gradlew +249 -0
  26. package/example/AppStyleX/android/gradlew.bat +92 -0
  27. package/example/AppStyleX/android/settings.gradle +12 -0
  28. package/example/AppStyleX/app.json +28 -0
  29. package/example/AppStyleX/babel.config.js +3 -0
  30. package/example/AppStyleX/index.js +9 -0
  31. package/example/AppStyleX/ios/Podfile +7 -0
  32. package/example/AppStyleX/ios/Podfile.lock +1252 -0
  33. package/example/AppStyleX/metro.config.js +54 -0
  34. package/example/AppStyleX/package.json +43 -0
  35. package/example/AppStyleX/react-native.config.js +23 -0
  36. package/example/AppStyleX/src/App.tsx +25 -0
  37. package/example/AppStyleX/src/BottomNav/index.tsx +32 -0
  38. package/example/AppStyleX/src/BottomNav/styles.ts +42 -0
  39. package/example/AppStyleX/src/Circle/index.tsx +53 -0
  40. package/example/AppStyleX/src/Circle/styles.ts +22 -0
  41. package/example/AppStyleX/src/Root/index.tsx +41 -0
  42. package/example/AppStyleX/src/Root/styles.ts +18 -0
  43. package/example/AppStyleX/src/ToggleButton/index.tsx +66 -0
  44. package/example/AppStyleX/src/ToggleButton/styles.ts +69 -0
  45. package/example/AppStyleX/src/style-system/hooks/useAnimatedBgColor.ts +5 -0
  46. package/example/AppStyleX/src/style-system/hooks/useAnimatedTextColor.ts +5 -0
  47. package/example/AppStyleX/src/style-system/hooks/useIsDark.ts +8 -0
  48. package/example/AppStyleX/src/style-system/palette.ts +11 -0
  49. package/example/AppStyleX/src/style-system/theme.ts +14 -0
  50. package/example/AppStyleX/src/style-system/utils.ts +11 -0
  51. package/example/AppStyleX/src/stylex.d.ts +6 -0
  52. package/example/AppStyleX/tsconfig.json +3 -0
  53. package/example/AppStyleX/yarn.lock +6767 -0
  54. package/jest.config.js +19 -0
  55. package/package.json +59 -0
  56. package/src/DefaultTheme.ts +4 -0
  57. package/src/__tests__/createBreakpoints.test.ts +152 -0
  58. package/src/__tests__/createBreakpointsMatcher.test.ts +188 -0
  59. package/src/__tests__/createBreakpointsMatcher.types-test.ts +81 -0
  60. package/src/__tests__/createEventEmitter.test.ts +37 -0
  61. package/src/__tests__/dark-mode.test.ts +56 -0
  62. package/src/__tests__/dependencyRegistry.test.ts +16 -0
  63. package/src/__tests__/dependencyUsage.test.ts +13 -0
  64. package/src/__tests__/dimensions.test.ts +36 -0
  65. package/src/__tests__/makeUseStyles.types-test.ts +69 -0
  66. package/src/__tests__/media-query.test.ts +204 -0
  67. package/src/__tests__/orientation.test.ts +61 -0
  68. package/src/__tests__/useTheme.test.ts +26 -0
  69. package/src/__tests__/withStyles.types-test.tsx +173 -0
  70. package/src/appearance/consts.ts +1 -0
  71. package/src/appearance/index.ts +37 -0
  72. package/src/appearance/init.ts +12 -0
  73. package/src/context.ts +9 -0
  74. package/src/createEventEmitter.ts +26 -0
  75. package/src/dark-mode/consts.ts +1 -0
  76. package/src/dark-mode/index.ts +29 -0
  77. package/src/dark-mode/init.ts +19 -0
  78. package/src/dark-mode/state.ts +5 -0
  79. package/src/dependencyRegistry.ts +21 -0
  80. package/src/dependencyUsage.ts +31 -0
  81. package/src/dimensions/consts.ts +2 -0
  82. package/src/dimensions/index.ts +20 -0
  83. package/src/dimensions/init.ts +37 -0
  84. package/src/dimensions/utils.ts +11 -0
  85. package/src/i18n.ts +18 -0
  86. package/src/index.ts +7 -0
  87. package/src/makeUseStyles/createUseStylesTheme.js +42 -0
  88. package/src/makeUseStyles/createUseStylesTheme.test.js +137 -0
  89. package/src/makeUseStyles/createUseStylesWithoutTheme.js +38 -0
  90. package/src/makeUseStyles/createUseStylesWithoutTheme.test.js +63 -0
  91. package/src/makeUseStyles/index.d.ts +7 -0
  92. package/src/makeUseStyles/index.js +12 -0
  93. package/src/makeUseStyles/index.test.js +28 -0
  94. package/src/makeUseStyles/test-type.js +28 -0
  95. package/src/makeUseStyles/utils.js +67 -0
  96. package/src/media-query/base.ts +43 -0
  97. package/src/media-query/breakpoints.ts +121 -0
  98. package/src/media-query/index.ts +12 -0
  99. package/src/orientation.ts +17 -0
  100. package/src/safe-area/SafeAreaProvider.tsx +17 -0
  101. package/src/safe-area/StylexSaveAreaConsumer.ts +23 -0
  102. package/src/safe-area/consts.ts +1 -0
  103. package/src/safe-area/eventEmitter.ts +4 -0
  104. package/src/safe-area/index.tsx +16 -0
  105. package/src/safe-area/init.tsx +6 -0
  106. package/src/safe-area/state.ts +12 -0
  107. package/src/safe-area/types.ts +10 -0
  108. package/src/useColorTransition.ts +50 -0
  109. package/src/useTheme.ts +16 -0
  110. package/src/withStyles.tsx +35 -0
  111. package/tsconfig.json +30 -0
@@ -0,0 +1,274 @@
1
+ # Media Query support 💉
2
+
3
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
4
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
5
+
6
+ - [High level api](#high-level-api)
7
+ - [`createBreakpoints(breakpoints)`](#createbreakpointsbreakpoints)
8
+ - [`createBreakpointsMatcher(breakpoints, matcherFunction)`](#createbreakpointsmatcherbreakpoints-matcherfunction)
9
+ - [Inject into theme](#inject-into-theme)
10
+ - [Core media conditions:](#core-media-conditions)
11
+ - [`maxWidth(width: number, {/* styles */})`](#maxwidthwidth-number--styles-)
12
+ - [`minWidth(width: number, {/* styles */})`](#minwidthwidth-number--styles-)
13
+ - [`maxHeight(height: number, {/* styles */})`](#maxheightheight-number--styles-)
14
+ - [`minHeight(height: number, {/* styles */})`](#minheightheight-number--styles-)
15
+ - [`aspectRatio(ratio: number, {/* styles */})`](#aspectratioratio-number--styles-)
16
+ - [`maxAspectRatio(ratio: number, {/* styles */})`](#maxaspectratioratio-number--styles-)
17
+ - [`minAspectRatio(ratio: number, {/* styles */})`](#minaspectratioratio-number--styles-)
18
+
19
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
20
+
21
+ ## High level api
22
+
23
+ #### `createBreakpoints(breakpoints)`
24
+
25
+ Media queries are the idiomatic approach to make your UI responsive.
26
+
27
+ ```ts
28
+ import { createBreakpoints } from "react-native-stylex/media-query";
29
+
30
+ const config = {
31
+ sm: 600,
32
+ md: 960,
33
+ lg: 1280,
34
+ xl: 1920,
35
+ };
36
+
37
+ const breakpoints = createBreakpoints(config);
38
+
39
+ breakpoints.up("sm", value);
40
+ breakpoints.down("md", value);
41
+ breakpoints.only("lg", value);
42
+ breakpoints.between("sm", "lg", value);
43
+ ```
44
+
45
+ - `breakpoints.down<T>(key: string, value: T): T | null`
46
+
47
+ A media query matches screen widths less than and including the screen size given by the breakpoint key.
48
+
49
+ ```ts
50
+ makeUseStyles(() => ({
51
+ text: {
52
+ fontSize: 16,
53
+
54
+ // Match: [0, sm, md, lg] xl, ∞
55
+ // [0........1280]
56
+ ...breakpoints.down("lg", { fontSize: 18 }),
57
+
58
+ // Match: [0, sm] md, lg, xl, ∞
59
+ // [0...600]
60
+ ...breakpoints.down("sm", { fontSize: 20 }),
61
+ },
62
+ }));
63
+ ```
64
+
65
+ - `breakpoints.up<T>(key: string, value: T): T | null`
66
+ A media query which matches screen widths greater than and including the screen size given by the breakpoint key.
67
+
68
+ ```ts
69
+ makeUseStyles(() => ({
70
+ text: {
71
+ fontSize: 20,
72
+
73
+ // Match: 0, [sm, md, lg, xl, ∞]
74
+ // [600.............∞]
75
+ ...breakpoints.up("sm", { fontSize: 18 }),
76
+
77
+ // Match: 0, sm, md, [lg, xl, ∞]
78
+ // [1280....∞]
79
+ ...breakpoints.up("lg", { fontSize: 16 }),
80
+ },
81
+ }));
82
+ ```
83
+
84
+ - `breakpoints.only<T>(key: string, value: T): T | null`
85
+ A media query which matches screen widths including the screen size given by the breakpoint key.
86
+
87
+ ```ts
88
+ makeUseStyles(() => ({
89
+ text: {
90
+ fontSize: 16,
91
+
92
+ // Match: 0, sm, [md, lg], xl, ∞
93
+ // [960...1280]
94
+ ...breakpoints.only("md", { fontSize: 20 }),
95
+ },
96
+ }));
97
+ ```
98
+
99
+ - `breakpoints.between<T>(start: string, end: string, value: T): T | null`
100
+ A media query which matches screen widths greater than the screen width given by the breakpoint key in the first argument and less than the screen width given by the breakpoint key in the second argument
101
+
102
+ ```ts
103
+ makeUseStyles(() => ({
104
+ text: {
105
+ fontSize: 16,
106
+
107
+ // Match: 0, [sm, md, lg], xl, ∞
108
+ // [600...1280]
109
+ ...breakpoints.between("sm", "lg", { fontSize: 20 }),
110
+ },
111
+ }));
112
+ ```
113
+
114
+ ---
115
+
116
+ #### `createBreakpointsMatcher(breakpoints, matcherFunction)`
117
+
118
+ - `breakpoints: { [key: string]: number }` - object where keys have string type and values positive number
119
+ - `matcherFunction: ` - optional, (by default `minWidth`). One of the media query matcher function (maxAspectRatio, maxHeight, maxWidth, minAspectRatio, minHeight, minWidth)
120
+
121
+ To easily **understand** and **debug** you can use a [CSS analog](https://codepen.io/retyui/pen/dyOzKzV) of implementation `createBreakpointsMatcher` ([video preview...](https://user-images.githubusercontent.com/4661784/108605405-92456780-73bc-11eb-9ec1-eb2e765c4164.mp4))
122
+
123
+ **Example:**
124
+
125
+ ```tsx
126
+ import {
127
+ createBreakpointsMatcher,
128
+ maxHeight,
129
+ maxWidth,
130
+ minHeight,
131
+ minWidth,
132
+ minAspectRatio,
133
+ maxAspectRatio,
134
+ } from "react-native-stylex/media-query";
135
+
136
+ const applyBreakpoints = createBreakpointsMatcher(
137
+ {
138
+ // breakpoints config
139
+ xxs: 320,
140
+ xs: 480,
141
+ s: 640,
142
+ m: 768,
143
+ l: 1024,
144
+ xl: 1200,
145
+ xxl: 1920,
146
+ },
147
+ matcherFunction // Optional matcher function (be default 'minWidth')
148
+ );
149
+
150
+ /*
151
+ * ⚠ Pay attention that result of this function depends on the passed matcher function (mix\max)!
152
+ * ⬇️ See below to understand a difference ⬇️
153
+ */
154
+ const useStyles = makeUseStyles(() => ({
155
+ text: {
156
+ // !!! ⚠ WHEN 'matcherFunction' is 'maxWidth' ⚠ !!!
157
+ // if window width 0....320 => fontSize: 20
158
+ // if window width 321..480 => fontSize: 18
159
+ // if window width 481... => fontSize: 16
160
+ fontSize: applyBreakpoints({
161
+ default: 16,
162
+ xs: 18,
163
+ xxs: 20,
164
+ }),
165
+ },
166
+
167
+ title: {
168
+ // !!! ⚠ WHEN 'matcherFunction' is 'minWidth' ⚠ !!!
169
+ // if window width 0....319 => fontSize: 20
170
+ // if window width 320..479 => fontSize: 18
171
+ // if window width 480.. => fontSize: 16
172
+ fontSize: applyBreakpoints({
173
+ xs: 16,
174
+ xxs: 18,
175
+ default: 20,
176
+ }),
177
+ },
178
+ }));
179
+ ```
180
+
181
+ #### Inject into theme
182
+
183
+ > ⚠️ Note: I recommend you to add created breakpoints functions to your theme, and use them directly without importing
184
+
185
+ **Example:**
186
+
187
+ ```ts
188
+ // theme.ts
189
+ const config = { sm: 360, md: 600 /*...*/ };
190
+ const breakpoints = createBreakpoints(config);
191
+ const applyBreakpoints = createBreakpointsMatcher(config, matcherFunction);
192
+
193
+ const theme = {
194
+ pallete: { white: "#fff" /*...*/ },
195
+ breakpoints,
196
+ applyBreakpoints,
197
+ };
198
+
199
+ // -----------------------------------------------
200
+ // styles.ts
201
+ const useStyles = makeUseStyles(({ applyBreakpoints }) => ({
202
+ root: {
203
+ fontSize: utils.applyBreakpoints({
204
+ xxs: 20,
205
+ xs: 18,
206
+ default: 16,
207
+ }),
208
+ },
209
+ }));
210
+ ```
211
+
212
+ ---
213
+
214
+ ## Core media conditions:
215
+
216
+ #### `maxWidth(width: number, {/* styles */})`
217
+
218
+ Return styles when a window width is equal or less than passed `width`
219
+
220
+ #### `minWidth(width: number, {/* styles */})`
221
+
222
+ Return styles when a window width is equal or greater than passed `width`
223
+
224
+ #### `maxHeight(height: number, {/* styles */})`
225
+
226
+ Return styles when window height is equal or less than passed `height`
227
+
228
+ #### `minHeight(height: number, {/* styles */})`
229
+
230
+ Return styles when window height is equal or greater than passed `height`
231
+
232
+ #### `aspectRatio(ratio: number, {/* styles */})`
233
+
234
+ Return styles when a window aspect ratio is the same as a passed `ratio`
235
+
236
+ #### `maxAspectRatio(ratio: number, {/* styles */})`
237
+
238
+ Return styles when a window aspect ratio is equal or less than passed `ratio`
239
+
240
+ #### `minAspectRatio(ratio: number, {/* styles */})`
241
+
242
+ Return styles when a window aspect ratio is equal or greater than passed `ratio`
243
+
244
+ **Example:**
245
+
246
+ ```js
247
+ import { makeUseStyles } from "react-native-stylex";
248
+ import { minWidth } from "react-native-stylex/media-query";
249
+
250
+ const useStyles = makeUseStyles(() => ({
251
+ root: {
252
+ // default styles
253
+ height: 200,
254
+ width: 200,
255
+
256
+ ...minWidth(320, {
257
+ // if window width MORE then 320 apply next stylex
258
+ height: 160,
259
+ width: 160,
260
+ }),
261
+ },
262
+ panel: {
263
+ // default styles
264
+ height: 200,
265
+ width: 200,
266
+
267
+ ...maxWidth(320, {
268
+ // if window width LESS then 320 apply next stylex
269
+ height: 160,
270
+ width: 160,
271
+ }),
272
+ },
273
+ }));
274
+ ```
@@ -0,0 +1,44 @@
1
+ # Orientation 📲
2
+
3
+ #### `orientation({ portrait, landscape })`
4
+
5
+ This function given an object containing orientation variants as keys, returns the value for the orientation you are
6
+ currently. (inspired by [`Platform.select(...)`](https://facebook.github.io/reac-native/docs/platform-specific-code#platform-module))
7
+
8
+ #### `portraitOrientation(value)`
9
+
10
+ Return passed value when device in portrait orientation
11
+
12
+ #### `landscapeOrientation(value)`
13
+
14
+ Return passed value when device in landscape orientation
15
+
16
+ **Example:**
17
+
18
+ ```js
19
+ import { makeUseStyles } from "react-native-stylex";
20
+ import {
21
+ orientation,
22
+ portraitOrientation,
23
+ landscapeOrientation,
24
+ } from "react-native-stylex/orientation";
25
+
26
+ const useStyles = makeUseStyles(() => ({
27
+ cell: {
28
+ backgroundColor: "red",
29
+ ...orientation({
30
+ portrait: { alignSelf: "flex-start" },
31
+ landscape: { alignSelf: "flex-end" },
32
+ }),
33
+ },
34
+ row: {
35
+ width: portraitOrientation(100),
36
+ },
37
+ root: {
38
+ ...landscapeOrientation({
39
+ top: 10,
40
+ left: 10,
41
+ }),
42
+ },
43
+ }));
44
+ ```
@@ -0,0 +1,62 @@
1
+ # 🛡️ Safe area
2
+
3
+ It is really useful for fixed elements on screen
4
+
5
+ <img src="https://cdn.dribbble.com/users/261602/screenshots/5947654/bottom_search.png" width="500" />
6
+
7
+ To start using integration with [react-native-safe-area-context](https://github.com/th3rdwave/react-native-safe-area-context) module
8
+
9
+ You need install it using [instructions](https://github.com/th3rdwave/react-native-safe-area-context#getting-started)!
10
+
11
+ Then you need to render `<StylexSaveAreaConsumer/>` inside `SafeAreaProvider`.
12
+
13
+ ```jsx
14
+ import React, { useState } from "react";
15
+ import { SafeAreaProvider } from "react-native-safe-area-context";
16
+ import { StylexSaveAreaConsumer } from "react-native-stylex/safe-area";
17
+
18
+ import App from "./App";
19
+
20
+ const Root = () => {
21
+ return (
22
+ <SafeAreaProvider>
23
+ <App />
24
+ <StylexSaveAreaConsumer />
25
+ </SafeAreaProvider>
26
+ );
27
+ };
28
+ ```
29
+
30
+ Or you can use custom `SafeAreaProvider` from stylex
31
+
32
+ ```jsx
33
+ import React, { useState } from "react";
34
+ import { SafeAreaProvider } from "react-native-stylex/safe-area";
35
+
36
+ import App from "./App";
37
+
38
+ const Root = () => {
39
+ return (
40
+ <SafeAreaProvider>
41
+ <App />
42
+ </SafeAreaProvider>
43
+ );
44
+ };
45
+ ```
46
+
47
+ After that you can use `getSafeArea()` method to get edge insets
48
+
49
+ **Example:**
50
+
51
+ ```jsx
52
+ import { makeUseStyles } from "react-native-stylex";
53
+ import { getSafeArea } from "react-native-stylex/safe-area";
54
+
55
+ export const useStyles = makeUseStyles(() => ({
56
+ fixedButton: {
57
+ position: "absolute",
58
+ start: 20,
59
+ bottom: 30 + getSafeArea().bottom,
60
+ },
61
+ }));
62
+ ```
@@ -0,0 +1,51 @@
1
+ # Writing tests 📝
2
+
3
+ ## Using [Jest](https://jestjs.io/) for testing?
4
+
5
+ You should just use `<Provider>` and manually pass theme as a prop to every component that use `useStyles()` in unit tests
6
+
7
+ **./testing.js**
8
+
9
+ ```js
10
+ import React from "react";
11
+ import { ThemeProvider } from "react-native-stylex";
12
+
13
+ import { defaultTheme } from "./my-theme";
14
+
15
+ export const MockThemeProvider = (props) => (
16
+ <ThemeProvider {...props} value={defaultTheme} />
17
+ );
18
+ ```
19
+
20
+ **./MyComponent.text.js**
21
+
22
+ ```js
23
+ import React from "react";
24
+ import TestRenderer from "react-test-renderer";
25
+ import { MockThemeProvider } from "./testing";
26
+ import MyComponent from "./MyComponent";
27
+
28
+ const testRenderer = TestRenderer.create(
29
+ <MockThemeProvider>
30
+ <MyComponent />
31
+ </MockThemeProvider>
32
+ );
33
+
34
+ //...
35
+ ```
36
+
37
+ ## Troubleshooting
38
+
39
+ ### **`SyntaxError: Unexpected token export\import` in react-native-stylex/...**
40
+
41
+ You need to point Jest to transform this package. You can do so, by adding module path to `transformIgnorePatterns` setting in Jest's configuration.
42
+
43
+ ```json
44
+ {
45
+ "jest": {
46
+ "transformIgnorePatterns": [
47
+ 'node_modules/(?!((jest-)?react-native|react-native-stylex|@react-native(-community)?)/)',
48
+ ]
49
+ }
50
+ }
51
+ ```
package/docs/ts.md ADDED
@@ -0,0 +1,127 @@
1
+ # Typescript support ⛱️
2
+
3
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
4
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
5
+
6
+ - [DefaultTheme](#defaulttheme)
7
+ - [`withStyles()` HoC](#withstyles-hoc)
8
+
9
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
10
+
11
+ ### DefaultTheme
12
+
13
+ TypeScript definitions for stylex can be extended by using [declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation) since version `v4.1.4` of the definitions.
14
+
15
+ So the first step is creating a declarations file. Let's name it `stylex.d.ts` for example.
16
+
17
+ **./theme.ts**
18
+
19
+ ```ts
20
+ export const theme = {
21
+ colors: { textColor: "black" },
22
+ };
23
+
24
+ export type MyTheme = typeof theme;
25
+ ```
26
+
27
+ **./stylex.d.ts**
28
+
29
+ ```ts
30
+ import "react-native-stylex";
31
+ import type { MyTheme } from "./theme";
32
+
33
+ declare module "react-native-stylex" {
34
+ export interface DefaultTheme extends MyTheme {}
35
+ }
36
+ ```
37
+
38
+ `DefaultTheme` is being used as an interface of `makeUseStyles(theme => ...)` out of the box.
39
+
40
+ By default, the interface DefaultTheme is empty so that's why we need to extend it.
41
+
42
+ ---
43
+
44
+ ### `withStyles()` HoC
45
+
46
+ To make life developer easy was added helper type `InferInjectedStyledProps<TFunc>`
47
+
48
+ ```ts
49
+ const useStyles2 = makeUseStyles(() => ({
50
+ cell: { width: 10 },
51
+ root: { color: "red" },
52
+ }));
53
+
54
+ // {
55
+ // styles: {
56
+ // root: {...},
57
+ // cell: {...}
58
+ // }
59
+ // } <==> InferInjectedStyledProps<typeof useStyles>
60
+ ```
61
+
62
+ So final result should be looks like that:
63
+
64
+ **Example:**
65
+
66
+ ```tsx
67
+ import React, { Ref, forwardRef } from "react";
68
+ import { TextInput } from "react-native";
69
+ import {
70
+ makeUseStyles,
71
+ withStyles,
72
+ InferInjectedStyledProps,
73
+ } from "react-native-stylex";
74
+
75
+ const useStyles = makeUseStyles(() => ({
76
+ root: {
77
+ color: "red",
78
+ },
79
+ }));
80
+
81
+ interface Props extends InferInjectedStyledProps<typeof useStyles> {
82
+ value?: string;
83
+ }
84
+
85
+ function MyComponent(props: Props) {
86
+ return <TextInput style={props.styles.root} value={props.value} />;
87
+ }
88
+
89
+ const Styled = withStyles(useStyles)(MyComponent);
90
+
91
+ <Styled
92
+ value="str"
93
+ // @ts-expect-error: 'styles' Already injected
94
+ styles={{}}
95
+ />;
96
+ ```
97
+
98
+ > ⚠️ Ref support by default!
99
+
100
+ In `4.x.x` version was improved type detection for 'ref'
101
+
102
+ it works well with class and functional components
103
+
104
+ ```tsx
105
+ const MyFnc = forwardRef<TextInput, Props>((props, ref) => (
106
+ <TextInput ref={ref} style={props.styles.root} />
107
+ ));
108
+
109
+ class MyTextInput extends React.Component<Props> {
110
+ scrollTo() {}
111
+ }
112
+
113
+ const StyledCls = withStyles(useStyles)(MyTextInput);
114
+ const StyledFnc = withStyles(useStyles)(MyFnc);
115
+
116
+ <StyledCls
117
+ ref={(instance) => {
118
+ instance?.scrollTo();
119
+ }}
120
+ />;
121
+
122
+ <StyledFnc
123
+ ref={(instance) => {
124
+ instance?.blur();
125
+ }}
126
+ />;
127
+ ```
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1,26 @@
1
+ buildscript {
2
+ def androidTestAppDir = "../node_modules/react-native-test-app/android"
3
+ apply(from: "${androidTestAppDir}/dependencies.gradle")
4
+
5
+ repositories {
6
+ mavenCentral()
7
+ google()
8
+ }
9
+
10
+ dependencies {
11
+ getReactNativeDependencies().each { dependency ->
12
+ classpath(dependency)
13
+ }
14
+ }
15
+ }
16
+
17
+ allprojects {
18
+ repositories {
19
+ maven {
20
+ // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
21
+ url("${rootDir}/../node_modules/react-native/android")
22
+ }
23
+ mavenCentral()
24
+ google()
25
+ }
26
+ }
@@ -0,0 +1,7 @@
1
+ distributionBase=GRADLE_USER_HOME
2
+ distributionPath=wrapper/dists
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
4
+ networkTimeout=10000
5
+ validateDistributionUrl=true
6
+ zipStoreBase=GRADLE_USER_HOME
7
+ zipStorePath=wrapper/dists
@@ -0,0 +1,53 @@
1
+ # Project-wide Gradle settings.
2
+
3
+ # IDE (e.g. Android Studio) users:
4
+ # Gradle settings configured through the IDE *will override*
5
+ # any settings specified in this file.
6
+
7
+ # For more details on how to configure your build environment visit
8
+ # http://www.gradle.org/docs/current/userguide/build_environment.html
9
+
10
+ # Specifies the JVM arguments used for the Gradle Daemon. The setting is
11
+ # particularly useful for configuring JVM memory settings for build performance.
12
+ # This does not affect the JVM settings for the Gradle client VM.
13
+ # The default is `-Xmx512m -XX:MaxMetaspaceSize=256m`.
14
+ org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
15
+
16
+ # When configured, Gradle will fork up to org.gradle.workers.max JVMs to execute
17
+ # projects in parallel. To learn more about parallel task execution, see the
18
+ # section on Gradle build performance:
19
+ # https://docs.gradle.org/current/userguide/performance.html#parallel_execution.
20
+ # Default is `false`.
21
+ #org.gradle.parallel=true
22
+
23
+ # AndroidX package structure to make it clearer which packages are bundled with the
24
+ # Android operating system, and which are packaged with your app's APK
25
+ # https://developer.android.com/topic/libraries/support-library/androidx-rn
26
+ android.useAndroidX=true
27
+ # Automatically convert third-party libraries to use AndroidX
28
+ android.enableJetifier=true
29
+ # Jetifier randomly fails on these libraries
30
+ android.jetifier.ignorelist=hermes-android
31
+
32
+ # Version of Flipper to use with React Native. Default value is whatever React
33
+ # Native defaults to. To enable Flipper, set the value to `X.Y.Z` (version you want to use).
34
+ # To disable Flipper, set it to `false`.
35
+ FLIPPER_VERSION=false
36
+
37
+ # Use this property to specify which architecture you want to build.
38
+ # You can also override it from the CLI using
39
+ # ./gradlew <task> -PreactNativeArchitectures=x86_64
40
+ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
41
+
42
+ # Enable Fabric at runtime.
43
+ #USE_FABRIC=1
44
+
45
+ # Enable new architecture, i.e. Fabric + TurboModule - implies USE_FABRIC=1.
46
+ # Note that this is incompatible with web debugging.
47
+ #newArchEnabled=true
48
+
49
+ # Uncomment the line below if building react-native from source
50
+ #ANDROID_NDK_VERSION=23.1.7779620
51
+
52
+ # Version of Kotlin to build against.
53
+ #KOTLIN_VERSION=1.7.22