react-native-unistyles 3.0.0-alpha.2 → 3.0.0-alpha.21
Sign up to get free protection for your applications and to get access to all the features.
- package/Unistyles.podspec +3 -2
- package/cxx/common/Constants.h +3 -0
- package/cxx/common/Helpers.h +97 -5
- package/cxx/core/HostStyle.cpp +19 -13
- package/cxx/core/HostStyle.h +4 -0
- package/cxx/core/StyleSheet.h +0 -2
- package/cxx/core/StyleSheetRegistry.cpp +10 -13
- package/cxx/core/StyleSheetRegistry.h +4 -4
- package/cxx/core/Unistyle.h +7 -10
- package/cxx/core/UnistyleData.h +23 -0
- package/cxx/core/UnistyleWrapper.h +58 -10
- package/cxx/core/UnistylesCommitHook.cpp +22 -13
- package/cxx/core/UnistylesCommitHook.h +8 -1
- package/cxx/core/UnistylesCommitShadowNode.h +13 -0
- package/cxx/core/UnistylesMountHook.cpp +37 -0
- package/cxx/core/UnistylesMountHook.h +31 -0
- package/cxx/core/UnistylesRegistry.cpp +56 -81
- package/cxx/core/UnistylesRegistry.h +15 -13
- package/cxx/core/UnistylesState.cpp +14 -8
- package/cxx/core/UnistylesState.h +1 -0
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +15 -9
- package/cxx/hybridObjects/HybridStyleSheet.cpp +43 -38
- package/cxx/hybridObjects/HybridStyleSheet.h +10 -7
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +35 -16
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -0
- package/cxx/parser/Parser.cpp +105 -164
- package/cxx/parser/Parser.h +8 -14
- package/cxx/shadowTree/ShadowLeafUpdate.h +1 -1
- package/cxx/shadowTree/ShadowTrafficController.h +33 -0
- package/cxx/shadowTree/ShadowTreeManager.cpp +13 -11
- package/cxx/shadowTree/ShadowTreeManager.h +1 -0
- package/ios/Unistyles.h +1 -0
- package/ios/UnistylesModuleOnLoad.h +2 -0
- package/ios/UnistylesModuleOnLoad.mm +8 -1
- package/lib/commonjs/index.js +4 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NavigtionBar/index.js +1 -1
- package/lib/commonjs/specs/NavigtionBar/index.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +7 -6
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/StatusBar/index.js +1 -1
- package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/commonjs/specs/index.web.js +1 -1
- package/lib/commonjs/web/convert/boxShadow.js +77 -0
- package/lib/commonjs/web/convert/boxShadow.js.map +1 -0
- package/lib/commonjs/web/convert/breakpoint.js +25 -0
- package/lib/commonjs/web/convert/breakpoint.js.map +1 -0
- package/lib/commonjs/web/convert/index.js +76 -0
- package/lib/commonjs/web/convert/index.js.map +1 -0
- package/lib/commonjs/web/convert/module.d.js +2 -0
- package/lib/commonjs/web/convert/module.d.js.map +1 -0
- package/lib/commonjs/web/convert/shadow.js +68 -0
- package/lib/commonjs/web/convert/shadow.js.map +1 -0
- package/lib/commonjs/web/convert/style.js +89 -0
- package/lib/commonjs/web/convert/style.js.map +1 -0
- package/lib/commonjs/web/convert/textShadow.js +73 -0
- package/lib/commonjs/web/convert/textShadow.js.map +1 -0
- package/lib/commonjs/web/convert/transform.js +72 -0
- package/lib/commonjs/web/convert/transform.js.map +1 -0
- package/lib/commonjs/web/convert/types.js +9 -0
- package/lib/commonjs/web/convert/types.js.map +1 -0
- package/lib/commonjs/web/convert/utils.js +55 -0
- package/lib/commonjs/web/convert/utils.js.map +1 -0
- package/lib/commonjs/web/create.js +51 -0
- package/lib/commonjs/web/create.js.map +1 -0
- package/lib/commonjs/web/createUnistylesComponent.js +61 -0
- package/lib/commonjs/web/createUnistylesComponent.js.map +1 -0
- package/lib/commonjs/web/index.js +60 -0
- package/lib/commonjs/web/index.js.map +1 -0
- package/lib/commonjs/web/listener/index.js +20 -0
- package/lib/commonjs/web/listener/index.js.map +1 -0
- package/lib/commonjs/web/listener/listenToDependencies.js +38 -0
- package/lib/commonjs/web/listener/listenToDependencies.js.map +1 -0
- package/lib/commonjs/web/listener/listener.js +35 -0
- package/lib/commonjs/web/listener/listener.js.map +1 -0
- package/lib/commonjs/web/mock.js +28 -0
- package/lib/commonjs/web/mock.js.map +1 -0
- package/lib/commonjs/web/mq.js +23 -0
- package/lib/commonjs/web/mq.js.map +1 -0
- package/lib/commonjs/web/pseudo.js +10 -0
- package/lib/commonjs/web/pseudo.js.map +1 -0
- package/lib/commonjs/web/registry.js +50 -0
- package/lib/commonjs/web/registry.js.map +1 -0
- package/lib/commonjs/web/runtime.js +163 -0
- package/lib/commonjs/web/runtime.js.map +1 -0
- package/lib/commonjs/web/shadowRegistry.js +123 -0
- package/lib/commonjs/web/shadowRegistry.js.map +1 -0
- package/lib/commonjs/web/state.js +81 -0
- package/lib/commonjs/web/state.js.map +1 -0
- package/lib/commonjs/web/utils.js +130 -0
- package/lib/commonjs/web/utils.js.map +1 -0
- package/lib/commonjs/web/variants/getVariants.js +39 -0
- package/lib/commonjs/web/variants/getVariants.js.map +1 -0
- package/lib/commonjs/web/variants/index.js +28 -0
- package/lib/commonjs/web/variants/index.js.map +1 -0
- package/lib/commonjs/web/variants/useVariants.js +59 -0
- package/lib/commonjs/web/variants/useVariants.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NavigtionBar/index.js +1 -1
- package/lib/module/specs/NavigtionBar/index.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +7 -6
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/StatusBar/index.js +1 -1
- package/lib/module/specs/StatusBar/index.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/module/specs/index.web.js +1 -1
- package/lib/module/specs/index.web.js.map +1 -1
- package/lib/module/web/convert/boxShadow.js +72 -0
- package/lib/module/web/convert/boxShadow.js.map +1 -0
- package/lib/module/web/convert/breakpoint.js +20 -0
- package/lib/module/web/convert/breakpoint.js.map +1 -0
- package/lib/module/web/convert/index.js +71 -0
- package/lib/module/web/convert/index.js.map +1 -0
- package/lib/module/web/convert/module.d.js +2 -0
- package/lib/module/web/convert/module.d.js.map +1 -0
- package/lib/module/web/convert/shadow.js +63 -0
- package/lib/module/web/convert/shadow.js.map +1 -0
- package/lib/module/web/convert/style.js +84 -0
- package/lib/module/web/convert/style.js.map +1 -0
- package/lib/module/web/convert/textShadow.js +68 -0
- package/lib/module/web/convert/textShadow.js.map +1 -0
- package/lib/module/web/convert/transform.js +67 -0
- package/lib/module/web/convert/transform.js.map +1 -0
- package/lib/module/web/convert/types.js +5 -0
- package/lib/module/web/convert/types.js.map +1 -0
- package/lib/module/web/convert/utils.js +43 -0
- package/lib/module/web/convert/utils.js.map +1 -0
- package/lib/module/web/create.js +46 -0
- package/lib/module/web/create.js.map +1 -0
- package/lib/module/web/createUnistylesComponent.js +54 -0
- package/lib/module/web/createUnistylesComponent.js.map +1 -0
- package/lib/module/web/index.js +26 -0
- package/lib/module/web/index.js.map +1 -0
- package/lib/module/web/listener/index.js +5 -0
- package/lib/module/web/listener/index.js.map +1 -0
- package/lib/module/web/listener/listenToDependencies.js +33 -0
- package/lib/module/web/listener/listenToDependencies.js.map +1 -0
- package/lib/module/web/listener/listener.js +31 -0
- package/lib/module/web/listener/listener.js.map +1 -0
- package/lib/module/web/mock.js +24 -0
- package/lib/module/web/mock.js.map +1 -0
- package/lib/module/web/mq.js +17 -0
- package/lib/module/web/mq.js.map +1 -0
- package/lib/module/web/pseudo.js +5 -0
- package/lib/module/web/pseudo.js.map +1 -0
- package/lib/module/web/registry.js +46 -0
- package/lib/module/web/registry.js.map +1 -0
- package/lib/module/web/runtime.js +159 -0
- package/lib/module/web/runtime.js.map +1 -0
- package/lib/module/web/shadowRegistry.js +119 -0
- package/lib/module/web/shadowRegistry.js.map +1 -0
- package/lib/module/web/state.js +77 -0
- package/lib/module/web/state.js.map +1 -0
- package/lib/module/web/utils.js +112 -0
- package/lib/module/web/utils.js.map +1 -0
- package/lib/module/web/variants/getVariants.js +34 -0
- package/lib/module/web/variants/getVariants.js.map +1 -0
- package/lib/module/web/variants/index.js +5 -0
- package/lib/module/web/variants/index.js.map +1 -0
- package/lib/module/web/variants/useVariants.js +54 -0
- package/lib/module/web/variants/useVariants.js.map +1 -0
- package/lib/typescript/example/App.d.ts.map +1 -1
- package/lib/typescript/example/Typography.d.ts +12 -0
- package/lib/typescript/example/Typography.d.ts.map +1 -0
- package/lib/typescript/expo-example/app/(tabs)/_layout.d.ts +3 -0
- package/lib/typescript/expo-example/app/(tabs)/_layout.d.ts.map +1 -0
- package/lib/typescript/expo-example/app/(tabs)/explore.d.ts +3 -0
- package/lib/typescript/expo-example/app/(tabs)/explore.d.ts.map +1 -0
- package/lib/typescript/expo-example/app/(tabs)/index.d.ts +3 -0
- package/lib/typescript/expo-example/app/(tabs)/index.d.ts.map +1 -0
- package/lib/typescript/expo-example/app/+html.d.ts +4 -0
- package/lib/typescript/expo-example/app/+html.d.ts.map +1 -0
- package/lib/typescript/expo-example/app/+not-found.d.ts +3 -0
- package/lib/typescript/expo-example/app/+not-found.d.ts.map +1 -0
- package/lib/typescript/expo-example/app/_layout.d.ts +3 -0
- package/lib/typescript/expo-example/app/_layout.d.ts.map +1 -0
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +3 -3
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +2 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.web.d.ts +1 -1
- package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +2 -2
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/boxShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/breakpoint.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/convert/index.d.ts +1 -1
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/style.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/textShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/transform.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/convert/types.d.ts +1 -1
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/create.d.ts +11 -11
- package/lib/typescript/{web → src/web}/create.d.ts.map +1 -1
- package/lib/typescript/src/web/createUnistylesComponent.d.ts +3 -0
- package/lib/typescript/src/web/createUnistylesComponent.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/index.d.ts +14 -13
- package/lib/typescript/{web → src/web}/index.d.ts.map +1 -1
- package/lib/typescript/src/web/listener/index.d.ts +3 -0
- package/lib/typescript/src/web/listener/index.d.ts.map +1 -0
- package/lib/typescript/src/web/listener/listenToDependencies.d.ts +12 -0
- package/lib/typescript/src/web/listener/listenToDependencies.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/listener/listener.d.ts +3 -2
- package/lib/typescript/src/web/listener/listener.d.ts.map +1 -0
- package/lib/typescript/src/web/mock.d.ts +5 -0
- package/lib/typescript/src/web/mock.d.ts.map +1 -0
- package/lib/typescript/src/web/mq.d.ts.map +1 -0
- package/lib/typescript/src/web/pseudo.d.ts +6 -0
- package/lib/typescript/src/web/pseudo.d.ts.map +1 -0
- package/lib/typescript/src/web/registry.d.ts +15 -0
- package/lib/typescript/src/web/registry.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/runtime.d.ts +6 -7
- package/lib/typescript/src/web/runtime.d.ts.map +1 -0
- package/lib/typescript/src/web/shadowRegistry.d.ts +17 -0
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/state.d.ts +4 -9
- package/lib/typescript/src/web/state.d.ts.map +1 -0
- package/lib/typescript/src/web/utils.d.ts +35 -0
- package/lib/typescript/src/web/utils.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/getVariants.d.ts +3 -0
- package/lib/typescript/src/web/variants/getVariants.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/index.d.ts +3 -0
- package/lib/typescript/src/web/variants/index.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/useVariants.d.ts +3 -0
- package/lib/typescript/src/web/variants/useVariants.d.ts.map +1 -0
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +6 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +8 -3
- package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +1 -1
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +14 -2
- package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +3 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +3 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +3 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +3 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +3 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +4 -1
- package/package.json +3 -3
- package/plugin/__tests__/dependencies.spec.js +199 -111
- package/plugin/__tests__/ref.spec.js +638 -202
- package/plugin/__tests__/stylesheet.spec.js +182 -71
- package/plugin/index.js +110 -23
- package/plugin/ref.js +64 -13
- package/plugin/style.js +82 -22
- package/plugin/stylesheet.js +44 -1
- package/plugin/variants.js +33 -0
- package/src/index.ts +3 -0
- package/src/specs/NavigtionBar/index.ts +1 -1
- package/src/specs/ShadowRegistry/index.ts +10 -9
- package/src/specs/StatusBar/index.ts +1 -1
- package/src/specs/StyleSheet/index.ts +3 -1
- package/src/specs/UnistylesRuntime/index.ts +1 -1
- package/src/specs/index.web.ts +1 -1
- package/src/types/stylesheet.ts +2 -2
- package/{web → src/web}/convert/breakpoint.ts +1 -1
- package/{web → src/web}/convert/index.ts +2 -2
- package/{web → src/web}/convert/types.ts +1 -1
- package/src/web/create.ts +50 -0
- package/src/web/createUnistylesComponent.tsx +54 -0
- package/{web → src/web}/index.ts +3 -2
- package/src/web/listener/index.ts +2 -0
- package/src/web/listener/listenToDependencies.ts +45 -0
- package/{web → src/web}/listener/listener.ts +2 -2
- package/{web → src/web}/mock.ts +2 -12
- package/src/web/pseudo.ts +137 -0
- package/src/web/registry.ts +60 -0
- package/{web → src/web}/runtime.ts +4 -6
- package/src/web/shadowRegistry.ts +124 -0
- package/{web → src/web}/state.ts +5 -49
- package/{web → src/web}/utils.ts +91 -17
- package/src/web/variants/getVariants.ts +42 -0
- package/src/web/variants/index.ts +2 -0
- package/src/web/variants/useVariants.ts +65 -0
- package/lib/typescript/web/convert/boxShadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/breakpoint.d.ts.map +0 -1
- package/lib/typescript/web/convert/index.d.ts.map +0 -1
- package/lib/typescript/web/convert/shadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/style.d.ts.map +0 -1
- package/lib/typescript/web/convert/textShadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/transform.d.ts.map +0 -1
- package/lib/typescript/web/convert/types.d.ts.map +0 -1
- package/lib/typescript/web/convert/utils.d.ts.map +0 -1
- package/lib/typescript/web/listener/index.d.ts +0 -2
- package/lib/typescript/web/listener/index.d.ts.map +0 -1
- package/lib/typescript/web/listener/listener.d.ts.map +0 -1
- package/lib/typescript/web/mock.d.ts +0 -14
- package/lib/typescript/web/mock.d.ts.map +0 -1
- package/lib/typescript/web/mq.d.ts.map +0 -1
- package/lib/typescript/web/pseudo.d.ts +0 -4
- package/lib/typescript/web/pseudo.d.ts.map +0 -1
- package/lib/typescript/web/registry.d.ts +0 -12
- package/lib/typescript/web/registry.d.ts.map +0 -1
- package/lib/typescript/web/runtime.d.ts.map +0 -1
- package/lib/typescript/web/state.d.ts.map +0 -1
- package/lib/typescript/web/useVariants.d.ts +0 -3
- package/lib/typescript/web/useVariants.d.ts.map +0 -1
- package/lib/typescript/web/utils.d.ts +0 -18
- package/lib/typescript/web/utils.d.ts.map +0 -1
- package/web/create.ts +0 -102
- package/web/listener/index.ts +0 -1
- package/web/pseudo.ts +0 -11
- package/web/registry.ts +0 -41
- package/web/useVariants.ts +0 -99
- /package/lib/typescript/{web → src/web}/convert/boxShadow.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/breakpoint.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/shadow.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/style.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/textShadow.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/transform.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/utils.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/mq.d.ts +0 -0
- /package/{web → src/web}/convert/boxShadow.ts +0 -0
- /package/{web → src/web}/convert/module.d.ts +0 -0
- /package/{web → src/web}/convert/shadow.ts +0 -0
- /package/{web → src/web}/convert/style.ts +0 -0
- /package/{web → src/web}/convert/textShadow.ts +0 -0
- /package/{web → src/web}/convert/transform.ts +0 -0
- /package/{web → src/web}/convert/utils.ts +0 -0
- /package/{web → src/web}/mq.ts +0 -0
@@ -16,6 +16,7 @@ pluginTester({
|
|
16
16
|
{
|
17
17
|
title: 'Should detect dependencies in variants',
|
18
18
|
code: `
|
19
|
+
import { View, Text } from 'react-native'
|
19
20
|
import { StyleSheet } from 'react-native-unistyles'
|
20
21
|
|
21
22
|
export const Example = () => {
|
@@ -44,15 +45,16 @@ pluginTester({
|
|
44
45
|
`,
|
45
46
|
output: `
|
46
47
|
import { UnistylesShadowRegistry } from 'react-native-unistyles'
|
48
|
+
import { View, Text } from 'react-native'
|
47
49
|
import { StyleSheet } from 'react-native-unistyles'
|
48
50
|
|
49
51
|
export const Example = () => {
|
50
52
|
return (
|
51
53
|
<View
|
52
|
-
style={styles.container}
|
54
|
+
style={[styles.container]}
|
53
55
|
ref={ref => {
|
54
|
-
UnistylesShadowRegistry.add(ref, styles.container)
|
55
|
-
return () => UnistylesShadowRegistry.remove(ref
|
56
|
+
UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
|
57
|
+
return () => UnistylesShadowRegistry.remove(ref)
|
56
58
|
}}
|
57
59
|
>
|
58
60
|
<Text>Hello world</Text>
|
@@ -60,25 +62,29 @@ pluginTester({
|
|
60
62
|
)
|
61
63
|
}
|
62
64
|
|
63
|
-
const styles = StyleSheet.create(
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
65
|
+
const styles = StyleSheet.create(
|
66
|
+
(theme, rt) => ({
|
67
|
+
container: {
|
68
|
+
variants: {
|
69
|
+
size: {
|
70
|
+
small: {
|
71
|
+
backgroundColor: theme.colors.blue,
|
72
|
+
paddingTop: theme.gap(10),
|
73
|
+
marginBottom: rt.insets.bottom === 0 ? theme.gap(20) : theme.gap(30)
|
74
|
+
}
|
71
75
|
}
|
72
|
-
}
|
73
|
-
|
74
|
-
|
75
|
-
}
|
76
|
-
|
76
|
+
},
|
77
|
+
uni__dependencies: [0, 9, 4]
|
78
|
+
}
|
79
|
+
}),
|
80
|
+
276736056
|
81
|
+
)
|
77
82
|
`
|
78
83
|
},
|
79
84
|
{
|
80
85
|
title: 'Should detect dependencies in breakpoints',
|
81
86
|
code: `
|
87
|
+
import { View, Text } from 'react-native'
|
82
88
|
import { StyleSheet } from 'react-native-unistyles'
|
83
89
|
|
84
90
|
export const Example = () => {
|
@@ -102,15 +108,16 @@ pluginTester({
|
|
102
108
|
`,
|
103
109
|
output: `
|
104
110
|
import { UnistylesShadowRegistry } from 'react-native-unistyles'
|
111
|
+
import { View, Text } from 'react-native'
|
105
112
|
import { StyleSheet } from 'react-native-unistyles'
|
106
113
|
|
107
114
|
export const Example = () => {
|
108
115
|
return (
|
109
116
|
<View
|
110
|
-
style={styles.container}
|
117
|
+
style={[styles.container]}
|
111
118
|
ref={ref => {
|
112
|
-
UnistylesShadowRegistry.add(ref, styles.container)
|
113
|
-
return () => UnistylesShadowRegistry.remove(ref
|
119
|
+
UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
|
120
|
+
return () => UnistylesShadowRegistry.remove(ref)
|
114
121
|
}}
|
115
122
|
>
|
116
123
|
<Text>Hello world</Text>
|
@@ -118,22 +125,26 @@ pluginTester({
|
|
118
125
|
)
|
119
126
|
}
|
120
127
|
|
121
|
-
const styles = StyleSheet.create(
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
128
|
+
const styles = StyleSheet.create(
|
129
|
+
(theme, rt) => ({
|
130
|
+
container: {
|
131
|
+
backgroundColor: {
|
132
|
+
sm: theme.colors.blue
|
133
|
+
},
|
134
|
+
padding: {
|
135
|
+
xs: rt.insets.top
|
136
|
+
},
|
137
|
+
uni__dependencies: [0, 9]
|
138
|
+
}
|
139
|
+
}),
|
140
|
+
276736056
|
141
|
+
)
|
132
142
|
`
|
133
143
|
},
|
134
144
|
{
|
135
145
|
title: 'Should detect dependencies in calculations',
|
136
146
|
code: `
|
147
|
+
import { View, Text } from 'react-native'
|
137
148
|
import { StyleSheet } from 'react-native-unistyles'
|
138
149
|
|
139
150
|
export const Example = () => {
|
@@ -154,15 +165,16 @@ pluginTester({
|
|
154
165
|
`,
|
155
166
|
output: `
|
156
167
|
import { UnistylesShadowRegistry } from 'react-native-unistyles'
|
168
|
+
import { View, Text } from 'react-native'
|
157
169
|
import { StyleSheet } from 'react-native-unistyles'
|
158
170
|
|
159
171
|
export const Example = () => {
|
160
172
|
return (
|
161
173
|
<View
|
162
|
-
style={styles.container}
|
174
|
+
style={[styles.container]}
|
163
175
|
ref={ref => {
|
164
|
-
UnistylesShadowRegistry.add(ref, styles.container)
|
165
|
-
return () => UnistylesShadowRegistry.remove(ref
|
176
|
+
UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
|
177
|
+
return () => UnistylesShadowRegistry.remove(ref)
|
166
178
|
}}
|
167
179
|
>
|
168
180
|
<Text>Hello world</Text>
|
@@ -170,19 +182,23 @@ pluginTester({
|
|
170
182
|
)
|
171
183
|
}
|
172
184
|
|
173
|
-
const styles = StyleSheet.create(
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
185
|
+
const styles = StyleSheet.create(
|
186
|
+
(theme, rt) => ({
|
187
|
+
container: {
|
188
|
+
marginTop: theme.gap(2) + rt.insets.bottom,
|
189
|
+
marginBottom: theme.gap(2) * rt.statusBar.height,
|
190
|
+
paddingTop: theme.gap(2) - rt.navigationBar.height,
|
191
|
+
uni__dependencies: [0, 9, 12, 13]
|
192
|
+
}
|
193
|
+
}),
|
194
|
+
276736056
|
195
|
+
)
|
181
196
|
`
|
182
197
|
},
|
183
198
|
{
|
184
199
|
title: 'Should detect dependencies in _web',
|
185
200
|
code: `
|
201
|
+
import { View, Text } from 'react-native'
|
186
202
|
import { StyleSheet } from 'react-native-unistyles'
|
187
203
|
|
188
204
|
export const Example = () => {
|
@@ -264,15 +280,16 @@ pluginTester({
|
|
264
280
|
`,
|
265
281
|
output: `
|
266
282
|
import { UnistylesShadowRegistry } from 'react-native-unistyles'
|
283
|
+
import { View, Text } from 'react-native'
|
267
284
|
import { StyleSheet } from 'react-native-unistyles'
|
268
285
|
|
269
286
|
export const Example = () => {
|
270
287
|
return (
|
271
288
|
<View
|
272
|
-
style={styles.container}
|
289
|
+
style={[styles.container]}
|
273
290
|
ref={ref => {
|
274
|
-
UnistylesShadowRegistry.add(ref, styles.container)
|
275
|
-
return () => UnistylesShadowRegistry.remove(ref
|
291
|
+
UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
|
292
|
+
return () => UnistylesShadowRegistry.remove(ref)
|
276
293
|
}}
|
277
294
|
>
|
278
295
|
<Text>Hello world</Text>
|
@@ -280,80 +297,151 @@ pluginTester({
|
|
280
297
|
)
|
281
298
|
}
|
282
299
|
|
283
|
-
const styles = StyleSheet.create(
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
static: {
|
289
|
-
backgroundColor: 'pink'
|
290
|
-
},
|
291
|
-
staticText: {
|
292
|
-
color: 'red'
|
293
|
-
},
|
294
|
-
theme: {
|
295
|
-
backgroundColor: theme.colors.backgroundColor,
|
296
|
-
uni__dependencies: [0]
|
297
|
-
},
|
298
|
-
themeText: {
|
299
|
-
color: theme.colors.typography,
|
300
|
-
uni__dependencies: [0]
|
301
|
-
},
|
302
|
-
themeButtonsContainer: {
|
303
|
-
marginTop: 20,
|
304
|
-
flexDirection: 'row',
|
305
|
-
gap: 10
|
306
|
-
},
|
307
|
-
dynamic: state => ({
|
308
|
-
backgroundColor: state % 2 === 0 ? theme.colors.fog : theme.colors.oak,
|
309
|
-
uni__dependencies: [0]
|
310
|
-
}),
|
311
|
-
whiteText: {
|
312
|
-
color: 'white',
|
313
|
-
textAlign: 'center'
|
314
|
-
},
|
315
|
-
hover: {
|
316
|
-
backgroundColor: theme.colors.blood,
|
317
|
-
cursor: 'pointer',
|
318
|
-
_web: {
|
319
|
-
_hover: {
|
320
|
-
backgroundColor: theme.colors.sky,
|
321
|
-
paddingTop: rt.insets.top
|
322
|
-
}
|
300
|
+
const styles = StyleSheet.create(
|
301
|
+
(theme, rt) => ({
|
302
|
+
container: {
|
303
|
+
flex: 1,
|
304
|
+
display: 'flex'
|
323
305
|
},
|
324
|
-
|
325
|
-
|
326
|
-
breakpoint: {
|
327
|
-
backgroundColor: {
|
328
|
-
xs: theme.colors.blood,
|
329
|
-
md: theme.colors.sky,
|
330
|
-
xl: theme.colors.aloes
|
306
|
+
static: {
|
307
|
+
backgroundColor: 'pink'
|
331
308
|
},
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
309
|
+
staticText: {
|
310
|
+
color: 'red'
|
311
|
+
},
|
312
|
+
theme: {
|
313
|
+
backgroundColor: theme.colors.backgroundColor,
|
314
|
+
uni__dependencies: [0]
|
315
|
+
},
|
316
|
+
themeText: {
|
317
|
+
color: theme.colors.typography,
|
318
|
+
uni__dependencies: [0]
|
319
|
+
},
|
320
|
+
themeButtonsContainer: {
|
321
|
+
marginTop: 20,
|
322
|
+
flexDirection: 'row',
|
323
|
+
gap: 10
|
324
|
+
},
|
325
|
+
dynamic: state => ({
|
326
|
+
backgroundColor: state % 2 === 0 ? theme.colors.fog : theme.colors.oak,
|
327
|
+
uni__dependencies: [0]
|
328
|
+
}),
|
329
|
+
whiteText: {
|
330
|
+
color: 'white',
|
331
|
+
textAlign: 'center'
|
332
|
+
},
|
333
|
+
hover: {
|
334
|
+
backgroundColor: theme.colors.blood,
|
335
|
+
cursor: 'pointer',
|
336
|
+
_web: {
|
337
|
+
_hover: {
|
338
|
+
backgroundColor: theme.colors.sky,
|
339
|
+
paddingTop: rt.insets.top
|
337
340
|
}
|
338
|
-
}
|
339
|
-
|
341
|
+
},
|
342
|
+
uni__dependencies: [0, 9]
|
343
|
+
},
|
344
|
+
breakpoint: {
|
345
|
+
backgroundColor: {
|
346
|
+
xs: theme.colors.blood,
|
347
|
+
md: theme.colors.sky,
|
348
|
+
xl: theme.colors.aloes
|
349
|
+
},
|
350
|
+
transform: [
|
351
|
+
{
|
352
|
+
translateX: {
|
353
|
+
xs: rt.fontScale * 10,
|
354
|
+
md: rt.pixelRatio * 10
|
355
|
+
}
|
356
|
+
}
|
357
|
+
],
|
340
358
|
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
359
|
+
position: 'relative',
|
360
|
+
_web: {
|
361
|
+
_after: {
|
362
|
+
fontWeight: 'bold',
|
363
|
+
content: rt.breakpoint,
|
364
|
+
color: 'white',
|
365
|
+
position: 'absolute',
|
366
|
+
top: '60%',
|
367
|
+
left: '50%',
|
368
|
+
transform: 'translate(-50%, -50%)',
|
369
|
+
backgroundColor: rt.colorScheme === 'dark' ? 'black' : 'white'
|
370
|
+
}
|
371
|
+
},
|
372
|
+
uni__dependencies: [0, 11, 10, 3, 5]
|
373
|
+
}
|
374
|
+
}),
|
375
|
+
276736056
|
376
|
+
)
|
377
|
+
`
|
378
|
+
},
|
379
|
+
{
|
380
|
+
title: 'Should allow user to use arrow functions with body for dynamic functions',
|
381
|
+
code: `
|
382
|
+
import { View, Text } from 'react-native'
|
383
|
+
import { StyleSheet } from 'react-native-unistyles'
|
384
|
+
|
385
|
+
export const Example = () => {
|
386
|
+
return (
|
387
|
+
<View style={styles.container}>
|
388
|
+
<Text>Hello world</Text>
|
389
|
+
</View>
|
390
|
+
)
|
391
|
+
}
|
392
|
+
|
393
|
+
const styles = StyleSheet.create((theme, rt) => ({
|
394
|
+
container: () => {
|
395
|
+
const b = 2 + 2
|
396
|
+
|
397
|
+
return {
|
398
|
+
backgroundColor: {
|
399
|
+
sm: theme.colors.blue
|
400
|
+
},
|
401
|
+
padding: {
|
402
|
+
xs: rt.insets.top + b
|
352
403
|
}
|
353
|
-
}
|
354
|
-
uni__dependencies: [0, 11, 10, 3, 5]
|
404
|
+
}
|
355
405
|
}
|
356
406
|
}))
|
407
|
+
`,
|
408
|
+
output: `
|
409
|
+
import { UnistylesShadowRegistry } from 'react-native-unistyles'
|
410
|
+
import { View, Text } from 'react-native'
|
411
|
+
import { StyleSheet } from 'react-native-unistyles'
|
412
|
+
|
413
|
+
export const Example = () => {
|
414
|
+
return (
|
415
|
+
<View
|
416
|
+
style={[styles.container]}
|
417
|
+
ref={ref => {
|
418
|
+
UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
|
419
|
+
return () => UnistylesShadowRegistry.remove(ref)
|
420
|
+
}}
|
421
|
+
>
|
422
|
+
<Text>Hello world</Text>
|
423
|
+
</View>
|
424
|
+
)
|
425
|
+
}
|
426
|
+
|
427
|
+
const styles = StyleSheet.create(
|
428
|
+
(theme, rt) => ({
|
429
|
+
container: () => {
|
430
|
+
const b = 2 + 2
|
431
|
+
|
432
|
+
return {
|
433
|
+
backgroundColor: {
|
434
|
+
sm: theme.colors.blue
|
435
|
+
},
|
436
|
+
padding: {
|
437
|
+
xs: rt.insets.top + b
|
438
|
+
},
|
439
|
+
uni__dependencies: [0, 9]
|
440
|
+
}
|
441
|
+
}
|
442
|
+
}),
|
443
|
+
276736056
|
444
|
+
)
|
357
445
|
`
|
358
446
|
},
|
359
447
|
]
|