@colimuca123/nativewind 4.2.2-rc.1

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 (146) hide show
  1. package/LICENSE +21 -0
  2. package/README.OpenSource +11 -0
  3. package/babel.js +1 -0
  4. package/dist/doctor.d.ts +1 -0
  5. package/dist/doctor.js +21 -0
  6. package/dist/doctor.js.map +1 -0
  7. package/dist/index.d.ts +4 -0
  8. package/dist/index.js +20 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/metro/common.d.ts +4 -0
  11. package/dist/metro/common.js +8 -0
  12. package/dist/metro/common.js.map +1 -0
  13. package/dist/metro/index.d.ts +15 -0
  14. package/dist/metro/index.js +47 -0
  15. package/dist/metro/index.js.map +1 -0
  16. package/dist/metro/picocolors.d.ts +26 -0
  17. package/dist/metro/picocolors.js +53 -0
  18. package/dist/metro/picocolors.js.map +1 -0
  19. package/dist/metro/tailwind/index.d.ts +5 -0
  20. package/dist/metro/tailwind/index.js +25 -0
  21. package/dist/metro/tailwind/index.js.map +1 -0
  22. package/dist/metro/tailwind/types.d.ts +8 -0
  23. package/dist/metro/tailwind/types.js +3 -0
  24. package/dist/metro/tailwind/types.js.map +1 -0
  25. package/dist/metro/tailwind/v3/child.d.ts +0 -0
  26. package/dist/metro/tailwind/v3/child.js +45 -0
  27. package/dist/metro/tailwind/v3/child.js.map +1 -0
  28. package/dist/metro/tailwind/v3/index.d.ts +6 -0
  29. package/dist/metro/tailwind/v3/index.js +81 -0
  30. package/dist/metro/tailwind/v3/index.js.map +1 -0
  31. package/dist/metro/typescript.d.ts +1 -0
  32. package/dist/metro/typescript.js +46 -0
  33. package/dist/metro/typescript.js.map +1 -0
  34. package/dist/stylesheet.d.ts +5 -0
  35. package/dist/stylesheet.js +25 -0
  36. package/dist/stylesheet.js.map +1 -0
  37. package/dist/tailwind/color.d.ts +4 -0
  38. package/dist/tailwind/color.js +25 -0
  39. package/dist/tailwind/color.js.map +1 -0
  40. package/dist/tailwind/common.d.ts +2 -0
  41. package/dist/tailwind/common.js +24 -0
  42. package/dist/tailwind/common.js.map +1 -0
  43. package/dist/tailwind/dark-mode.d.ts +4 -0
  44. package/dist/tailwind/dark-mode.js +48 -0
  45. package/dist/tailwind/dark-mode.js.map +1 -0
  46. package/dist/tailwind/index.d.ts +0 -0
  47. package/dist/tailwind/index.js +13 -0
  48. package/dist/tailwind/index.js.map +1 -0
  49. package/dist/tailwind/native.d.ts +3 -0
  50. package/dist/tailwind/native.js +265 -0
  51. package/dist/tailwind/native.js.map +1 -0
  52. package/dist/tailwind/prop-modifier.d.ts +4 -0
  53. package/dist/tailwind/prop-modifier.js +13 -0
  54. package/dist/tailwind/prop-modifier.js.map +1 -0
  55. package/dist/tailwind/safe-area.d.ts +4 -0
  56. package/dist/tailwind/safe-area.js +216 -0
  57. package/dist/tailwind/safe-area.js.map +1 -0
  58. package/dist/tailwind/shadows.d.ts +4 -0
  59. package/dist/tailwind/shadows.js +79 -0
  60. package/dist/tailwind/shadows.js.map +1 -0
  61. package/dist/tailwind/switch.d.ts +8 -0
  62. package/dist/tailwind/switch.js +51 -0
  63. package/dist/tailwind/switch.js.map +1 -0
  64. package/dist/tailwind/translate.d.ts +2 -0
  65. package/dist/tailwind/translate.js +40 -0
  66. package/dist/tailwind/translate.js.map +1 -0
  67. package/dist/tailwind/verify.d.ts +4 -0
  68. package/dist/tailwind/verify.js +22 -0
  69. package/dist/tailwind/verify.js.map +1 -0
  70. package/dist/tailwind/web.d.ts +3 -0
  71. package/dist/tailwind/web.js +40 -0
  72. package/dist/tailwind/web.js.map +1 -0
  73. package/dist/test.d.ts +373 -0
  74. package/dist/test.js +161 -0
  75. package/dist/test.js.map +1 -0
  76. package/dist/theme.d.ts +1 -0
  77. package/dist/theme.js +9 -0
  78. package/dist/theme.js.map +1 -0
  79. package/expo-snack.js +71 -0
  80. package/jsx-dev-runtime/index.d.ts +1 -0
  81. package/jsx-dev-runtime/index.js +1 -0
  82. package/jsx-runtime/index.d.ts +1 -0
  83. package/jsx-runtime/index.js +1 -0
  84. package/metro/package.json +1 -0
  85. package/package.json +75 -0
  86. package/preset/package.json +3 -0
  87. package/src/__tests__/README.md +3 -0
  88. package/src/__tests__/accessibility.tsx +41 -0
  89. package/src/__tests__/backgrounds.tsx +239 -0
  90. package/src/__tests__/borders.tsx +355 -0
  91. package/src/__tests__/container-queries.tsx +59 -0
  92. package/src/__tests__/custom-theme.tsx +45 -0
  93. package/src/__tests__/custom.tsx +17 -0
  94. package/src/__tests__/dark-mode.ios.tsx +251 -0
  95. package/src/__tests__/doctor.tsx +13 -0
  96. package/src/__tests__/effects.ios.tsx +230 -0
  97. package/src/__tests__/elevation.tsx +22 -0
  98. package/src/__tests__/filters.tsx +201 -0
  99. package/src/__tests__/flexbox-grid.tsx +670 -0
  100. package/src/__tests__/groups.tsx +134 -0
  101. package/src/__tests__/interactivity.tsx +547 -0
  102. package/src/__tests__/layout.tsx +854 -0
  103. package/src/__tests__/modifier-{}.tsx +71 -0
  104. package/src/__tests__/platform-modifiers-test.ios.tsx +34 -0
  105. package/src/__tests__/preset.tsx +9 -0
  106. package/src/__tests__/reusing-styles.tsx +44 -0
  107. package/src/__tests__/safe-area.test.ios.tsx +427 -0
  108. package/src/__tests__/sizing.tsx +241 -0
  109. package/src/__tests__/spacing.tsx +106 -0
  110. package/src/__tests__/states.tsx +145 -0
  111. package/src/__tests__/svg.tsx +25 -0
  112. package/src/__tests__/tables.tsx +103 -0
  113. package/src/__tests__/theme.tsx +245 -0
  114. package/src/__tests__/transforms.tsx +509 -0
  115. package/src/__tests__/transition-animations.tsx +254 -0
  116. package/src/__tests__/typography.tsx +657 -0
  117. package/src/__tests__/unofficial-plugins.test.ios.tsx +171 -0
  118. package/src/doctor.ts +28 -0
  119. package/src/index.tsx +16 -0
  120. package/src/metro/common.ts +11 -0
  121. package/src/metro/index.ts +77 -0
  122. package/src/metro/picocolors.ts +76 -0
  123. package/src/metro/tailwind/index.ts +22 -0
  124. package/src/metro/tailwind/types.ts +9 -0
  125. package/src/metro/tailwind/v3/child.ts +61 -0
  126. package/src/metro/tailwind/v3/index.ts +103 -0
  127. package/src/metro/typescript.ts +69 -0
  128. package/src/stylesheet.ts +31 -0
  129. package/src/tailwind/color.ts +23 -0
  130. package/src/tailwind/common.ts +26 -0
  131. package/src/tailwind/dark-mode.ts +46 -0
  132. package/src/tailwind/index.ts +15 -0
  133. package/src/tailwind/native.ts +374 -0
  134. package/src/tailwind/prop-modifier.ts +7 -0
  135. package/src/tailwind/safe-area.ts +262 -0
  136. package/src/tailwind/shadows.ts +100 -0
  137. package/src/tailwind/switch.ts +59 -0
  138. package/src/tailwind/translate.ts +51 -0
  139. package/src/tailwind/verify.ts +16 -0
  140. package/src/tailwind/web.ts +38 -0
  141. package/src/tailwindcss-internals.d.ts +7 -0
  142. package/src/test.tsx +224 -0
  143. package/src/theme.ts +15 -0
  144. package/test/package.json +4 -0
  145. package/theme/package.json +3 -0
  146. package/types.d.ts +1 -0
@@ -0,0 +1,245 @@
1
+ /** @jsxImportSource nativewind */
2
+ import {
3
+ PixelRatio,
4
+ Platform,
5
+ PlatformColor,
6
+ StyleSheet,
7
+ View,
8
+ } from "react-native";
9
+
10
+ import { screen } from "@testing-library/react-native";
11
+
12
+ import { render } from "../test";
13
+ import {
14
+ fontScaleSelect,
15
+ getPixelSizeForLayoutSize,
16
+ hairlineWidth,
17
+ pixelScaleSelect,
18
+ platformColor,
19
+ platformSelect,
20
+ roundToNearestPixel,
21
+ } from "../theme";
22
+
23
+ const testA = "a";
24
+ const testB = "b";
25
+
26
+ test("hairlineWidth()", async () => {
27
+ await render(<View testID={testA} className="border-custom" />, {
28
+ config: {
29
+ theme: {
30
+ extend: {
31
+ borderWidth: {
32
+ custom: hairlineWidth(),
33
+ },
34
+ },
35
+ },
36
+ },
37
+ });
38
+
39
+ const component = screen.getByTestId(testA);
40
+
41
+ expect(component).toHaveStyle({ borderWidth: StyleSheet.hairlineWidth });
42
+ });
43
+
44
+ test("platformSelect()", async () => {
45
+ await render(
46
+ <>
47
+ <View testID={testA} className="text-match" />
48
+ <View testID={testB} className="text-default" />
49
+ </>,
50
+ {
51
+ config: {
52
+ theme: {
53
+ extend: {
54
+ colors: {
55
+ match: platformSelect({
56
+ [Platform.OS]: "black",
57
+ default: "white",
58
+ }),
59
+ default: platformSelect({
60
+ [Platform.OS === "ios" ? "android" : "ios"]: "black",
61
+ default: "white",
62
+ }),
63
+ },
64
+ },
65
+ },
66
+ },
67
+ },
68
+ );
69
+
70
+ expect(screen.getByTestId(testA)).toHaveStyle({ color: "black" });
71
+ expect(screen.getByTestId(testB)).toHaveStyle({ color: "white" });
72
+ });
73
+
74
+ test("pixelScaleSelect()", async () => {
75
+ const currentPixelRatio = PixelRatio.get();
76
+
77
+ await render(
78
+ <>
79
+ <View testID={testA} className="text-match" />
80
+ <View testID={testB} className="text-default" />
81
+ </>,
82
+ {
83
+ config: {
84
+ theme: {
85
+ extend: {
86
+ colors: {
87
+ match: pixelScaleSelect({
88
+ [currentPixelRatio]: "black",
89
+ default: "white",
90
+ }),
91
+ default: pixelScaleSelect({
92
+ [currentPixelRatio + 1]: "black",
93
+ default: "white",
94
+ }),
95
+ },
96
+ },
97
+ },
98
+ },
99
+ },
100
+ );
101
+
102
+ expect(screen.getByTestId(testA)).toHaveStyle({ color: "black" });
103
+ expect(screen.getByTestId(testB)).toHaveStyle({ color: "white" });
104
+ });
105
+
106
+ test("fontScaleSelect()", async () => {
107
+ const fontScale = PixelRatio.getFontScale();
108
+
109
+ await render(
110
+ <>
111
+ <View testID={testA} className="text-match" />
112
+ <View testID={testB} className="text-default" />
113
+ </>,
114
+ {
115
+ config: {
116
+ theme: {
117
+ extend: {
118
+ colors: {
119
+ match: fontScaleSelect({
120
+ [fontScale]: "black",
121
+ default: "white",
122
+ }),
123
+ default: fontScaleSelect({
124
+ [fontScale + 1]: "black",
125
+ default: "white",
126
+ }),
127
+ },
128
+ },
129
+ },
130
+ },
131
+ },
132
+ );
133
+
134
+ expect(screen.getByTestId(testA)).toHaveStyle({ color: "black" });
135
+ expect(screen.getByTestId(testB)).toHaveStyle({ color: "white" });
136
+ });
137
+
138
+ test("roundToNearestPixel()", async () => {
139
+ await render(<View testID={testA} className="border-custom" />, {
140
+ config: {
141
+ theme: {
142
+ extend: {
143
+ borderWidth: {
144
+ custom: roundToNearestPixel(2.5),
145
+ },
146
+ },
147
+ },
148
+ },
149
+ });
150
+
151
+ expect(screen.getByTestId(testA)).toHaveStyle({
152
+ borderWidth: PixelRatio.roundToNearestPixel(2.5),
153
+ });
154
+ });
155
+
156
+ test("getPixelSizeForLayoutSize()", async () => {
157
+ await render(<View testID={testA} className="border-custom" />, {
158
+ config: {
159
+ theme: {
160
+ extend: {
161
+ borderWidth: {
162
+ custom: getPixelSizeForLayoutSize(2),
163
+ },
164
+ },
165
+ },
166
+ },
167
+ });
168
+
169
+ expect(screen.getByTestId(testA)).toHaveStyle({
170
+ borderWidth: PixelRatio.getPixelSizeForLayoutSize(2),
171
+ });
172
+ });
173
+
174
+ test("platformColor()", async () => {
175
+ await render(<View testID={testA} className="text-custom" />, {
176
+ config: {
177
+ theme: {
178
+ extend: {
179
+ colors: {
180
+ custom: platformColor(
181
+ "systemTealColor",
182
+ "?android:attr/textColor",
183
+ "blue",
184
+ ),
185
+ },
186
+ },
187
+ },
188
+ },
189
+ });
190
+
191
+ expect(screen.getByTestId(testA)).toHaveStyle({
192
+ color: PlatformColor("systemTealColor", "?android:attr/textColor", "blue"),
193
+ });
194
+ });
195
+
196
+ test("nested functions", async () => {
197
+ await render(
198
+ <View testID={testA} className="border-custom [--test:123px]" />,
199
+ {
200
+ config: {
201
+ theme: {
202
+ extend: {
203
+ borderWidth: {
204
+ custom: platformSelect({
205
+ [Platform.OS]: pixelScaleSelect({
206
+ [PixelRatio.get()]: "var(--test)",
207
+ }),
208
+ }),
209
+ },
210
+ },
211
+ },
212
+ },
213
+ },
214
+ );
215
+
216
+ expect(screen.getByTestId(testA)).toHaveStyle({
217
+ borderWidth: 123,
218
+ });
219
+ });
220
+
221
+ test("custom color w/ css variable", async () => {
222
+ await render(
223
+ <View
224
+ testID={testA}
225
+ className="text-primary-50 [--color-primary-50:240,253,250]"
226
+ />,
227
+ {
228
+ config: {
229
+ theme: {
230
+ extend: {
231
+ colors: {
232
+ primary: {
233
+ 50: "rgb(var(--color-primary-50) / <alpha-value>)",
234
+ },
235
+ },
236
+ },
237
+ },
238
+ },
239
+ },
240
+ );
241
+
242
+ expect(screen.getByTestId(testA)).toHaveStyle({
243
+ color: "rgba(240, 253, 250, 1)",
244
+ });
245
+ });