react-native-unistyles 3.0.0-alpha.26 → 3.0.0-alpha.28
Sign up to get free protection for your applications and to get access to all the features.
- package/cxx/core/UnistylesRegistry.cpp +4 -8
- package/cxx/core/UnistylesRegistry.h +1 -1
- package/cxx/core/UnistylesState.cpp +6 -10
- package/cxx/core/UnistylesState.h +2 -1
- package/cxx/hybridObjects/HybridStyleSheet.cpp +5 -2
- package/cxx/parser/Parser.cpp +73 -4
- package/cxx/parser/Parser.h +2 -0
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/core/useTheme.js.map +1 -1
- package/lib/commonjs/core/useTheme.native.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mq.js +1 -4
- package/lib/commonjs/mq.js.map +2 -1
- package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +1 -0
- package/lib/commonjs/specs/NavigtionBar/UnistylesNavigationBar.nitro.js.map +1 -1
- package/lib/commonjs/specs/NavigtionBar/index.js.map +2 -1
- package/lib/commonjs/specs/ShadowRegistry/ShadowRegistry.nitro.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/types.js +3 -0
- package/lib/commonjs/specs/ShadowRegistry/types.js.map +1 -1
- package/lib/commonjs/specs/StatusBar/UnistylesStatusBar.nitro.js.map +1 -1
- package/lib/commonjs/specs/StatusBar/index.js.map +2 -1
- package/lib/commonjs/specs/StyleSheet/UnistylesStyleSheet.nitro.js +2 -4
- package/lib/commonjs/specs/StyleSheet/UnistylesStyleSheet.nitro.js.map +1 -1
- package/lib/commonjs/specs/index.js.map +1 -1
- package/lib/commonjs/specs/types.js +10 -10
- package/lib/commonjs/specs/types.js.map +1 -1
- package/lib/commonjs/types/stylesheet.js.map +1 -1
- package/lib/commonjs/web/convert/index.js +1 -7
- package/lib/commonjs/web/convert/shadow.js +1 -5
- package/lib/commonjs/web/convert/shadow.js.map +2 -1
- package/lib/commonjs/web/convert/textShadow.js +1 -4
- package/lib/commonjs/web/convert/textShadow.js.map +2 -1
- package/lib/commonjs/web/convert/transform.js.map +2 -1
- package/lib/commonjs/web/create.js +1 -5
- package/lib/commonjs/web/create.js.map +2 -1
- package/lib/commonjs/web/mock.js.map +2 -1
- package/lib/commonjs/web/runtime.js.map +2 -1
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/utils/common.js +1 -3
- package/lib/commonjs/web/utils/common.js.map +2 -1
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/commonjs/web/variants/index.js.map +1 -1
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/useBreakpoint.js.map +1 -1
- package/lib/module/core/useBreakpoint.native.js.map +2 -1
- package/lib/module/core/useTheme.js.map +2 -1
- package/lib/module/core/useTheme.native.js.map +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/mq.js +1 -4
- package/lib/module/mq.js.map +2 -1
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js +5 -6
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/module/specs/NavigtionBar/UnistylesNavigationBar.nitro.js.map +1 -1
- package/lib/module/specs/NavigtionBar/index.js.map +2 -1
- package/lib/module/specs/ShadowRegistry/ShadowRegistry.nitro.js.map +1 -0
- package/lib/module/specs/ShadowRegistry/index.js.map +2 -1
- package/lib/module/specs/ShadowRegistry/types.js +2 -0
- package/lib/module/specs/ShadowRegistry/types.js.map +1 -1
- package/lib/module/specs/StatusBar/UnistylesStatusBar.nitro.js.map +1 -1
- package/lib/module/specs/StyleSheet/UnistylesStyleSheet.nitro.js +1 -1
- package/lib/module/specs/StyleSheet/UnistylesStyleSheet.nitro.js.map +1 -0
- package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js +2 -3
- package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js.map +2 -1
- package/lib/module/specs/UnistylesRuntime/UnistylesRuntime.nitro.js.map +1 -1
- package/lib/module/specs/index.web.js.map +2 -1
- package/lib/module/specs/types.js.map +1 -1
- package/lib/module/types/stylesheet.js.map +1 -1
- package/lib/module/web/convert/boxShadow.js +1 -4
- package/lib/module/web/convert/boxShadow.js.map +2 -1
- package/lib/module/web/convert/pseudo.js.map +2 -1
- package/lib/module/web/convert/shadow.js +1 -5
- package/lib/module/web/convert/shadow.js.map +2 -1
- package/lib/module/web/convert/style.js.map +2 -1
- package/lib/module/web/convert/textShadow.js +1 -4
- package/lib/module/web/convert/textShadow.js.map +2 -1
- package/lib/module/web/convert/transform.js.map +2 -1
- package/lib/module/web/convert/utils.js.map +2 -1
- package/lib/module/web/index.js +1 -2
- package/lib/module/web/index.js.map +2 -1
- package/lib/module/web/listener.js.map +2 -1
- package/lib/module/web/mock.js.map +2 -1
- package/lib/module/web/registry.js +1 -3
- package/lib/module/web/registry.js.map +2 -1
- package/lib/module/web/runtime.js.map +2 -1
- package/lib/module/web/shadowRegistry.js +1 -9
- package/lib/module/web/shadowRegistry.js.map +2 -1
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/utils/index.js.map +1 -1
- package/lib/module/web/utils/unistyle.js.map +2 -1
- package/lib/module/web/variants/index.js.map +1 -1
- package/lib/module/web/variants/useVariants.js +1 -2
- package/lib/module/web/variants/useVariants.js.map +2 -1
- package/lib/typescript/src/core/useBreakpoint.d.ts +1 -1
- package/lib/typescript/src/core/useBreakpoint.d.ts.map +1 -1
- package/lib/typescript/src/core/useBreakpoint.native.d.ts +1 -1
- package/lib/typescript/src/core/useBreakpoint.native.d.ts.map +1 -1
- package/lib/typescript/src/core/useTheme.d.ts +2 -40
- package/lib/typescript/src/core/useTheme.d.ts.map +1 -1
- package/lib/typescript/src/core/useTheme.native.d.ts +2 -40
- package/lib/typescript/src/core/useTheme.native.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +4 -2
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/types/variants.d.ts +1 -1
- package/lib/typescript/src/types/variants.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts +214 -1220
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts +214 -1220
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +4 -4
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/state.d.ts +1 -2
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts +2 -2
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/package.json +15 -16
- package/src/common.js +4 -0
- package/src/core/index.js +2 -0
- package/src/core/useBreakpoint.js +14 -0
- package/src/core/useBreakpoint.native.js +16 -0
- package/src/core/useTheme.js +14 -0
- package/src/core/useTheme.native.js +16 -0
- package/src/core/useTheme.native.ts +2 -1
- package/src/core/useTheme.ts +2 -1
- package/src/index.js +3 -0
- package/src/mq.js +38 -0
- package/src/specs/NativePlatform/NativePlatform.nitro.js +18 -0
- package/src/specs/NativePlatform/index.js +1 -0
- package/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.js +1 -0
- package/src/specs/NavigtionBar/index.js +9 -0
- package/src/specs/ShadowRegistry/ShadowRegistry.nitro.js +1 -0
- package/src/specs/ShadowRegistry/index.js +26 -0
- package/src/specs/ShadowRegistry/types.js +1 -0
- package/src/specs/StatusBar/UnistylesStatusBar.nitro.js +1 -0
- package/src/specs/StatusBar/index.js +25 -0
- package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.js +1 -0
- package/src/specs/StyleSheet/index.js +13 -0
- package/src/specs/TurboUnistyles/NativeTurboUnistyles.js +2 -0
- package/src/specs/TurboUnistyles/index.js +1 -0
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.js +1 -0
- package/src/specs/UnistylesRuntime/index.js +20 -0
- package/src/specs/index.js +8 -0
- package/src/specs/index.web.js +2 -0
- package/src/specs/types.js +17 -0
- package/src/types/stylesheet.ts +5 -3
- package/src/types/variants.ts +1 -1
- package/src/web/convert/boxShadow.js +59 -0
- package/src/web/convert/index.js +56 -0
- package/src/web/convert/pseudo.js +131 -0
- package/src/web/convert/shadow.js +50 -0
- package/src/web/convert/style.js +137 -0
- package/src/web/convert/textShadow.js +56 -0
- package/src/web/convert/transform.js +65 -0
- package/src/web/convert/types.js +2 -0
- package/src/web/convert/utils.js +39 -0
- package/src/web/create.js +39 -0
- package/src/web/index.js +22 -0
- package/src/web/listener.js +26 -0
- package/src/web/mock.js +21 -0
- package/src/web/mq.js +14 -0
- package/src/web/registry.js +168 -0
- package/src/web/runtime.js +160 -0
- package/src/web/runtime.ts +1 -1
- package/src/web/shadowRegistry.js +99 -0
- package/src/web/state.ts +3 -3
- package/src/web/utils/common.js +79 -0
- package/src/web/utils/index.js +2 -0
- package/src/web/utils/unistyle.js +72 -0
- package/src/web/utils/unistyle.ts +2 -2
- package/src/web/variants/getVariants.js +26 -0
- package/src/web/variants/index.js +2 -0
- package/src/web/variants/useVariants.js +50 -0
- package/lib/typescript/example/App.d.ts +0 -4
- package/lib/typescript/example/App.d.ts.map +0 -1
- package/lib/typescript/example/Typography.d.ts +0 -35
- package/lib/typescript/example/Typography.d.ts.map +0 -1
- package/lib/typescript/example/unistyles.d.ts +0 -63
- package/lib/typescript/example/unistyles.d.ts.map +0 -1
- package/lib/typescript/expo-example/App.d.ts +0 -4
- package/lib/typescript/expo-example/App.d.ts.map +0 -1
- package/lib/typescript/expo-example/app/(tabs)/_layout.d.ts +0 -3
- package/lib/typescript/expo-example/app/(tabs)/_layout.d.ts.map +0 -1
- package/lib/typescript/expo-example/app/(tabs)/explore.d.ts +0 -3
- package/lib/typescript/expo-example/app/(tabs)/explore.d.ts.map +0 -1
- package/lib/typescript/expo-example/app/(tabs)/index.d.ts +0 -3
- package/lib/typescript/expo-example/app/(tabs)/index.d.ts.map +0 -1
- package/lib/typescript/expo-example/app/+html.d.ts +0 -4
- package/lib/typescript/expo-example/app/+html.d.ts.map +0 -1
- package/lib/typescript/expo-example/app/+not-found.d.ts +0 -3
- package/lib/typescript/expo-example/app/+not-found.d.ts.map +0 -1
- package/lib/typescript/expo-example/app/_layout.d.ts +0 -3
- package/lib/typescript/expo-example/app/_layout.d.ts.map +0 -1
- package/lib/typescript/expo-example/unistyles.d.ts +0 -63
- package/lib/typescript/expo-example/unistyles.d.ts.map +0 -1
- package/plugin/__tests__/dependencies.spec.js +0 -448
- package/plugin/__tests__/ref.spec.js +0 -1427
- package/plugin/__tests__/stylesheet.spec.js +0 -507
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/web/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/web/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAUN,MAAM,KAAK,MAAM;yBACT,KAAK,CAAC,MAAM,CAAC;;CAErC,CAAA;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,cAAc,QAAQ,CAAA;AAGtB,eAAO,MAAM,eAAe,eAAW,CAAA"}
|
@@ -7,11 +7,11 @@ declare class UnistylesRuntimeBuilder {
|
|
7
7
|
private getLightMedia;
|
8
8
|
private getDarkMedia;
|
9
9
|
get colorScheme(): ColorScheme;
|
10
|
-
get themeName():
|
10
|
+
get themeName(): undefined;
|
11
11
|
get contentSizeCategory(): WebContentSizeCategory;
|
12
|
-
get breakpoint(): keyof import("
|
12
|
+
get breakpoint(): keyof import("..").UnistylesBreakpoints | undefined;
|
13
13
|
get orientation(): Orientation;
|
14
|
-
get theme():
|
14
|
+
get theme(): never;
|
15
15
|
get pixelRatio(): number;
|
16
16
|
get screen(): {
|
17
17
|
width: number;
|
@@ -35,7 +35,7 @@ declare class UnistylesRuntimeBuilder {
|
|
35
35
|
setRootViewBackgroundColor: (hex: string, alpha?: number) => void;
|
36
36
|
setImmersiveMode: () => void;
|
37
37
|
updateTheme: (themeName: AppThemeName, updater: (currentTheme: AppTheme) => AppTheme) => void;
|
38
|
-
getTheme: (themeName?:
|
38
|
+
getTheme: (themeName?: undefined) => never;
|
39
39
|
}
|
40
40
|
export declare const UnistylesRuntime: UnistylesRuntimeBuilder;
|
41
41
|
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/web/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAMjD,cAAM,uBAAuB;IACzB,UAAU,wBAAuB;IACjC,SAAS,wBAAsB;IAE/B,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,YAAY;IAYpB,IAAI,WAAW,gBASd;IAED,IAAI,SAAS,
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/web/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAMjD,cAAM,uBAAuB;IACzB,UAAU,wBAAuB;IACjC,SAAS,wBAAsB;IAE/B,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,YAAY;IAYpB,IAAI,WAAW,gBASd;IAED,IAAI,SAAS,cAEZ;IAED,IAAI,mBAAmB,2BAEtB;IAED,IAAI,UAAU,wDAEb;IAED,IAAI,WAAW,gBAMd;IAED,IAAI,KAAK,UAER;IAED,IAAI,UAAU,WAEb;IAED,IAAI,MAAM;;;MAYT;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,MAAM;;;;;;MAQT;IAED,IAAI,SAAS,oDAEZ;IAED,IAAI,GAAG,YAEN;IAED,IAAI,iBAAiB,YAEpB;IAED,IAAI,aAAa,2DAEhB;IAED,IAAI,WAAW,IAAI,oBAAoB,CAuBtC;IAED,QAAQ,cAAe,YAAY,UAQlC;IAED,iBAAiB,cAAe,OAAO,UAQtC;IAED,0BAA0B,QAAS,MAAM,UAAU,MAAM,UAMxD;IAED,gBAAgB,aAAW;IAE3B,WAAW,cAAe,YAAY,WAAW,CAAC,YAAY,EAAE,QAAQ,KAAK,QAAQ,UAQpF;IAED,QAAQ,mCAYP;CACJ;AAED,eAAO,MAAM,gBAAgB,yBAAgC,CAAA"}
|
@@ -1,9 +1,8 @@
|
|
1
|
-
import type { UnistylesTheme } from '../types';
|
2
1
|
import type { UnistylesConfig } from '../specs/StyleSheet';
|
3
2
|
import type { AppBreakpoint, AppThemeName } from '../specs/types';
|
4
3
|
import type { UnistylesBreakpoints } from '../global';
|
5
4
|
declare class UnistylesStateBuilder {
|
6
|
-
themes: Map<string,
|
5
|
+
themes: Map<string, never>;
|
7
6
|
themeName?: AppThemeName;
|
8
7
|
private matchingBreakpoints;
|
9
8
|
get breakpoint(): AppBreakpoint | undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/web/state.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../src/web/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAY,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC3E,OAAO,KAAK,EAAE,oBAAoB,EAAmB,MAAM,WAAW,CAAA;AAMtE,cAAM,qBAAqB;IACvB,MAAM,qBAAoC;IAC1C,SAAS,CAAC,EAAE,YAAY,CAAA;IAExB,OAAO,CAAC,mBAAmB,CAA6B;IAExD,IAAI,UAAU,IAKkB,aAAa,GAAG,SAAS,CACxD;IAED,WAAW,CAAC,EAAE,oBAAoB,CAAA;IAElC,iBAAiB,UAAQ;IAEzB,IAAI,WAAY,eAAe,UAU9B;IAED,OAAO,CAAC,UAAU,CAIjB;IAED,OAAO,CAAC,YAAY,CAyBnB;IAED,OAAO,CAAC,eAAe,CAkBtB;CACJ;AAED,eAAO,MAAM,cAAc,uBAA8B,CAAA"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { UnistyleDependency } from '../../specs/NativePlatform';
|
2
|
-
import { ColorScheme
|
2
|
+
import { ColorScheme } from '../../specs/types';
|
3
3
|
import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../../types/stylesheet';
|
4
|
-
export declare const schemeToTheme: (scheme: ColorScheme) =>
|
4
|
+
export declare const schemeToTheme: (scheme: ColorScheme) => string;
|
5
5
|
export declare const hexToRGBA: (hex: string, opacity: number) => string;
|
6
6
|
export type UnistyleSecrets = {
|
7
7
|
__uni__stylesheet: StyleSheetWithSuperPowers<StyleSheet>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"unistyle.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/unistyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAe,
|
1
|
+
{"version":3,"file":"unistyle.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/unistyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAKpG,eAAO,MAAM,aAAa,WAAY,WAAW,KAAG,MAQnD,CAAA;AAED,eAAO,MAAM,SAAS,QAAS,MAAM,WAAW,MAAM,WAM5B,CAAA;AAE1B,MAAM,MAAM,eAAe,GAAG;IAC1B,iBAAiB,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,UAAU,CAAC,WAAW,eAAe,MAKnE,CAAA;AAED,eAAO,MAAM,cAAc,WAAY,GAAG,sBAUzC,CAAA;AAED,eAAO,MAAM,SAAS,WAAY,eAAe,OAUhD,CAAA;AAED,eAAO,MAAM,YAAY,YAAa,WAAW,YAAoC,CAAA;AAErF,eAAO,MAAM,sBAAsB,UAAW,MAAM,uBAUnD,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,MAAM,WAmB1C,CAAA;AAED,eAAO,MAAM,2BAA2B,UAAW,GAAG,yBAIrD,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "3.0.0-alpha.
|
3
|
+
"version": "3.0.0-alpha.28",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
@@ -27,7 +27,7 @@
|
|
27
27
|
"web",
|
28
28
|
"react-native.config.js",
|
29
29
|
"Unistyles.podspec",
|
30
|
-
"!
|
30
|
+
"!plugin/__tests__",
|
31
31
|
"!ios/build",
|
32
32
|
"!android/build",
|
33
33
|
"!android/gradle",
|
@@ -60,29 +60,28 @@
|
|
60
60
|
"registry": "https://registry.npmjs.org/"
|
61
61
|
},
|
62
62
|
"devDependencies": {
|
63
|
-
"@babel/plugin-syntax-jsx": "7.25.
|
64
|
-
"@biomejs/biome": "1.
|
65
|
-
"@commitlint/config-conventional": "19.
|
66
|
-
"@react-native/normalize-colors": "0.
|
67
|
-
"@release-it/conventional-changelog": "8.0.
|
63
|
+
"@babel/plugin-syntax-jsx": "7.25.9",
|
64
|
+
"@biomejs/biome": "1.9.4",
|
65
|
+
"@commitlint/config-conventional": "19.5.0",
|
66
|
+
"@react-native/normalize-colors": "0.76.0",
|
67
|
+
"@release-it/conventional-changelog": "8.0.2",
|
68
68
|
"@testing-library/react-hooks": "8.0.1",
|
69
|
-
"@types/jest": "29.5.
|
70
|
-
"@types/react": "18.3.
|
69
|
+
"@types/jest": "29.5.14",
|
70
|
+
"@types/react": "18.3.12",
|
71
71
|
"babel-plugin-tester": "11.0.4",
|
72
|
-
"commitlint": "19.
|
72
|
+
"commitlint": "19.5.0",
|
73
73
|
"concurrently": "8.2.2",
|
74
|
-
"husky": "9.1.
|
74
|
+
"husky": "9.1.6",
|
75
75
|
"jest": "29.7.0",
|
76
76
|
"metro-react-native-babel-preset": "0.77.0",
|
77
77
|
"nitro-codegen": "0.13.0",
|
78
78
|
"react": "18.3.1",
|
79
|
-
"react-native": "0.
|
80
|
-
"react-native-builder-bob": "0.30.
|
79
|
+
"react-native": "0.76.0",
|
80
|
+
"react-native-builder-bob": "0.30.2",
|
81
81
|
"react-native-nitro-modules": "0.13.0",
|
82
82
|
"react-test-renderer": "18.3.1",
|
83
|
-
"release-it": "17.
|
84
|
-
"typescript": "5.
|
85
|
-
"typestyle": "2.4.0"
|
83
|
+
"release-it": "17.10.0",
|
84
|
+
"typescript": "5.6.3"
|
86
85
|
},
|
87
86
|
"peerDependencies": {
|
88
87
|
"@react-native/normalize-colors": "*",
|
package/src/common.js
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
import { useEffect, useState } from 'react';
|
2
|
+
import { UnistylesRuntime } from '../web';
|
3
|
+
import { UnistylesListener } from '../web/listener';
|
4
|
+
import { UnistyleDependency } from '../specs/NativePlatform';
|
5
|
+
export const useBreakpoint = () => {
|
6
|
+
const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint);
|
7
|
+
useEffect(() => {
|
8
|
+
const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Breakpoints], () => setBreakpoint(UnistylesRuntime.breakpoint));
|
9
|
+
return () => {
|
10
|
+
removeChangeListener();
|
11
|
+
};
|
12
|
+
}, []);
|
13
|
+
return breakpoint;
|
14
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { useEffect, useState } from 'react';
|
2
|
+
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
|
3
|
+
export const useBreakpoint = () => {
|
4
|
+
const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint);
|
5
|
+
useEffect(() => {
|
6
|
+
const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
|
7
|
+
if (dependencies.includes(UnistyleDependency.Breakpoints)) {
|
8
|
+
setBreakpoint(UnistylesRuntime.breakpoint);
|
9
|
+
}
|
10
|
+
});
|
11
|
+
return () => {
|
12
|
+
removeChangeListener();
|
13
|
+
};
|
14
|
+
}, []);
|
15
|
+
return breakpoint;
|
16
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { useEffect, useState } from 'react';
|
2
|
+
import { UnistylesRuntime } from '../web';
|
3
|
+
import { UnistylesListener } from '../web/listener';
|
4
|
+
import { UnistyleDependency } from '../specs/NativePlatform';
|
5
|
+
export const useTheme = () => {
|
6
|
+
const [theme, setTheme] = useState(UnistylesRuntime.getTheme());
|
7
|
+
useEffect(() => {
|
8
|
+
const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Theme], () => setTheme(UnistylesRuntime.getTheme()));
|
9
|
+
return () => {
|
10
|
+
removeChangeListener();
|
11
|
+
};
|
12
|
+
}, []);
|
13
|
+
return theme;
|
14
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { useEffect, useState } from 'react';
|
2
|
+
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs';
|
3
|
+
export const useTheme = () => {
|
4
|
+
const [theme, setTheme] = useState(UnistylesRuntime.getTheme());
|
5
|
+
useEffect(() => {
|
6
|
+
const removeChangeListener = StyleSheet.addChangeListener(dependencies => {
|
7
|
+
if (dependencies.includes(UnistyleDependency.Theme)) {
|
8
|
+
setTheme(UnistylesRuntime.getTheme());
|
9
|
+
}
|
10
|
+
});
|
11
|
+
return () => {
|
12
|
+
removeChangeListener();
|
13
|
+
};
|
14
|
+
}, []);
|
15
|
+
return theme;
|
16
|
+
};
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import { useEffect, useState } from 'react'
|
2
2
|
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs'
|
3
3
|
import type { UnistylesStyleSheet } from '../specs'
|
4
|
+
import type { UnistylesTheme } from '../types'
|
4
5
|
|
5
|
-
export const useTheme = () => {
|
6
|
+
export const useTheme = (): UnistylesTheme => {
|
6
7
|
const [theme, setTheme] = useState(UnistylesRuntime.getTheme())
|
7
8
|
|
8
9
|
useEffect(() => {
|
package/src/core/useTheme.ts
CHANGED
@@ -2,8 +2,9 @@ import { useEffect, useState } from 'react'
|
|
2
2
|
import { UnistylesRuntime } from '../web'
|
3
3
|
import { UnistylesListener } from '../web/listener'
|
4
4
|
import { UnistyleDependency } from '../specs/NativePlatform'
|
5
|
+
import type { UnistylesTheme } from '../types'
|
5
6
|
|
6
|
-
export const useTheme = () => {
|
7
|
+
export const useTheme = (): UnistylesTheme => {
|
7
8
|
const [theme, setTheme] = useState(UnistylesRuntime.getTheme())
|
8
9
|
|
9
10
|
useEffect(() => {
|
package/src/index.js
ADDED
package/src/mq.js
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
const getMQValue = (value) => {
|
2
|
+
if (typeof value === 'number') {
|
3
|
+
return value;
|
4
|
+
}
|
5
|
+
if (value === null) {
|
6
|
+
return 0;
|
7
|
+
}
|
8
|
+
// todo take it from js
|
9
|
+
const breakpoints = {
|
10
|
+
xs: 0,
|
11
|
+
sm: 300,
|
12
|
+
md: 500,
|
13
|
+
lg: 800,
|
14
|
+
xl: 1200
|
15
|
+
};
|
16
|
+
// @ts-ignore
|
17
|
+
return breakpoints[value] ?? 0;
|
18
|
+
};
|
19
|
+
/**
|
20
|
+
* Utility to create cross-platform media queries
|
21
|
+
* @returns - JavaScript symbol to be used in your stylesheet
|
22
|
+
*/
|
23
|
+
export const mq = {
|
24
|
+
only: {
|
25
|
+
width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`,
|
26
|
+
height: (hMin = 0, hMax = Infinity) => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
27
|
+
},
|
28
|
+
width: (wMin = 0, wMax = Infinity) => ({
|
29
|
+
and: {
|
30
|
+
height: (hMin = 0, hMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
31
|
+
}
|
32
|
+
}),
|
33
|
+
height: (hMin = 0, hMax = Infinity) => ({
|
34
|
+
and: {
|
35
|
+
width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
36
|
+
}
|
37
|
+
})
|
38
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import {} from '../types';
|
2
|
+
export var UnistyleDependency;
|
3
|
+
(function (UnistyleDependency) {
|
4
|
+
UnistyleDependency[UnistyleDependency["Theme"] = 0] = "Theme";
|
5
|
+
UnistyleDependency[UnistyleDependency["ThemeName"] = 1] = "ThemeName";
|
6
|
+
UnistyleDependency[UnistyleDependency["AdaptiveThemes"] = 2] = "AdaptiveThemes";
|
7
|
+
UnistyleDependency[UnistyleDependency["Breakpoints"] = 3] = "Breakpoints";
|
8
|
+
UnistyleDependency[UnistyleDependency["Variants"] = 4] = "Variants";
|
9
|
+
UnistyleDependency[UnistyleDependency["ColorScheme"] = 5] = "ColorScheme";
|
10
|
+
UnistyleDependency[UnistyleDependency["Dimensions"] = 6] = "Dimensions";
|
11
|
+
UnistyleDependency[UnistyleDependency["Orientation"] = 7] = "Orientation";
|
12
|
+
UnistyleDependency[UnistyleDependency["ContentSizeCategory"] = 8] = "ContentSizeCategory";
|
13
|
+
UnistyleDependency[UnistyleDependency["Insets"] = 9] = "Insets";
|
14
|
+
UnistyleDependency[UnistyleDependency["PixelRatio"] = 10] = "PixelRatio";
|
15
|
+
UnistyleDependency[UnistyleDependency["FontScale"] = 11] = "FontScale";
|
16
|
+
UnistyleDependency[UnistyleDependency["StatusBar"] = 12] = "StatusBar";
|
17
|
+
UnistyleDependency[UnistyleDependency["NavigationBar"] = 13] = "NavigationBar";
|
18
|
+
})(UnistyleDependency || (UnistyleDependency = {}));
|
@@ -0,0 +1 @@
|
|
1
|
+
export { UnistyleDependency } from './NativePlatform.nitro';
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { processColor } from 'react-native';
|
2
|
+
export const attachNavigationBarJSMethods = (hybridObject) => {
|
3
|
+
const privateHybrid = hybridObject;
|
4
|
+
privateHybrid._setBackgroundColor = hybridObject.setBackgroundColor;
|
5
|
+
hybridObject.setBackgroundColor = (color) => {
|
6
|
+
const parsedColor = processColor(color) ?? 0;
|
7
|
+
privateHybrid._setBackgroundColor(parsedColor);
|
8
|
+
};
|
9
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
2
|
+
const HybridShadowRegistry = NitroModules.createHybridObject('UnistylesShadowRegistry');
|
3
|
+
const findShadowNodeForHandle = (handle) => {
|
4
|
+
const node = handle?.__internalInstanceHandle?.stateNode?.node
|
5
|
+
?? handle?.getScrollResponder?.()?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node
|
6
|
+
?? handle?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node;
|
7
|
+
if (!node) {
|
8
|
+
// todo extend log with file name / component name
|
9
|
+
throw new Error('Could not find shadow node for one of your components');
|
10
|
+
}
|
11
|
+
return node;
|
12
|
+
};
|
13
|
+
HybridShadowRegistry.add = (handle, style, variants, args) => {
|
14
|
+
// virtualized nodes can be null
|
15
|
+
if (!handle || !style) {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? []);
|
19
|
+
};
|
20
|
+
HybridShadowRegistry.remove = handle => {
|
21
|
+
if (!handle) {
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
HybridShadowRegistry.unlink(findShadowNodeForHandle(handle));
|
25
|
+
};
|
26
|
+
export const UnistylesShadowRegistry = HybridShadowRegistry;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { processColor, StatusBar as NativeStatusBar } from 'react-native';
|
2
|
+
import { StatusBarStyle } from '../types';
|
3
|
+
export const attachStatusBarJSMethods = (hybridObject) => {
|
4
|
+
hybridObject.setStyle = (style, animated) => {
|
5
|
+
switch (style) {
|
6
|
+
case StatusBarStyle.Light:
|
7
|
+
return NativeStatusBar.setBarStyle('light-content', animated);
|
8
|
+
case StatusBarStyle.Dark:
|
9
|
+
return NativeStatusBar.setBarStyle('dark-content', animated);
|
10
|
+
case StatusBarStyle.Default:
|
11
|
+
return NativeStatusBar.setBarStyle('default', animated);
|
12
|
+
}
|
13
|
+
};
|
14
|
+
const privateHybrid = hybridObject;
|
15
|
+
privateHybrid._setHidden = hybridObject.setHidden;
|
16
|
+
hybridObject.setHidden = (isHidden, animation) => {
|
17
|
+
NativeStatusBar.setHidden(isHidden, animation);
|
18
|
+
privateHybrid._setHidden(isHidden);
|
19
|
+
};
|
20
|
+
privateHybrid._setBackgroundColor = hybridObject.setBackgroundColor;
|
21
|
+
hybridObject.setBackgroundColor = (color) => {
|
22
|
+
const parsedColor = processColor(color) ?? 0;
|
23
|
+
privateHybrid._setBackgroundColor(parsedColor);
|
24
|
+
};
|
25
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
import { UnistyleDependency } from '../NativePlatform';
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
2
|
+
import { processColor, StyleSheet as NativeStyleSheet } from 'react-native';
|
3
|
+
const HybridUnistylesStyleSheet = NitroModules
|
4
|
+
.createHybridObject('UnistylesStyleSheet');
|
5
|
+
HybridUnistylesStyleSheet.absoluteFillObject = NativeStyleSheet.absoluteFillObject;
|
6
|
+
HybridUnistylesStyleSheet.absoluteFill = NativeStyleSheet.absoluteFill;
|
7
|
+
HybridUnistylesStyleSheet.flatten = NativeStyleSheet.flatten;
|
8
|
+
HybridUnistylesStyleSheet.compose = NativeStyleSheet.compose;
|
9
|
+
HybridUnistylesStyleSheet.jsMethods = {
|
10
|
+
processColor
|
11
|
+
};
|
12
|
+
HybridUnistylesStyleSheet.init();
|
13
|
+
export const StyleSheet = HybridUnistylesStyleSheet;
|
@@ -0,0 +1 @@
|
|
1
|
+
import './NativeTurboUnistyles';
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { processColor } from 'react-native';
|
2
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
3
|
+
import { attachStatusBarJSMethods } from '../StatusBar';
|
4
|
+
import { attachNavigationBarJSMethods } from '../NavigtionBar';
|
5
|
+
import { isIOS } from '../../common';
|
6
|
+
const HybridUnistylesRuntime = NitroModules
|
7
|
+
.createHybridObject('UnistylesRuntime');
|
8
|
+
HybridUnistylesRuntime.statusBar = HybridUnistylesRuntime.createHybridStatusBar();
|
9
|
+
HybridUnistylesRuntime.navigationBar = HybridUnistylesRuntime.createHybridNavigationBar();
|
10
|
+
HybridUnistylesRuntime._setRootViewBackgroundColor = HybridUnistylesRuntime.setRootViewBackgroundColor;
|
11
|
+
HybridUnistylesRuntime.setRootViewBackgroundColor = (color) => {
|
12
|
+
const parsedColor = processColor(color) ?? 0;
|
13
|
+
HybridUnistylesRuntime._setRootViewBackgroundColor(parsedColor);
|
14
|
+
};
|
15
|
+
if (isIOS) {
|
16
|
+
HybridUnistylesRuntime.setImmersiveMode = (isEnabled) => HybridUnistylesRuntime.statusBar.setHidden(isEnabled, 'fade');
|
17
|
+
}
|
18
|
+
attachStatusBarJSMethods(HybridUnistylesRuntime.statusBar);
|
19
|
+
attachNavigationBarJSMethods(HybridUnistylesRuntime.navigationBar);
|
20
|
+
export const Runtime = HybridUnistylesRuntime;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import './TurboUnistyles';
|
2
|
+
import { Runtime } from './UnistylesRuntime';
|
3
|
+
import { StyleSheet } from './StyleSheet';
|
4
|
+
import { UnistylesShadowRegistry } from './ShadowRegistry';
|
5
|
+
import { StatusBarStyle, ColorScheme, Orientation } from './types';
|
6
|
+
import { UnistyleDependency } from './NativePlatform';
|
7
|
+
export { StatusBarStyle, ColorScheme, Orientation, UnistyleDependency };
|
8
|
+
export { UnistylesShadowRegistry, Runtime as UnistylesRuntime, StyleSheet, };
|
@@ -0,0 +1,17 @@
|
|
1
|
+
export var ColorScheme;
|
2
|
+
(function (ColorScheme) {
|
3
|
+
ColorScheme["Light"] = "light";
|
4
|
+
ColorScheme["Dark"] = "dark";
|
5
|
+
ColorScheme["Unspecified"] = "unspecified";
|
6
|
+
})(ColorScheme || (ColorScheme = {}));
|
7
|
+
export var Orientation;
|
8
|
+
(function (Orientation) {
|
9
|
+
Orientation["Portrait"] = "portrait";
|
10
|
+
Orientation["Landscape"] = "landscape";
|
11
|
+
})(Orientation || (Orientation = {}));
|
12
|
+
export var StatusBarStyle;
|
13
|
+
(function (StatusBarStyle) {
|
14
|
+
StatusBarStyle["Default"] = "default";
|
15
|
+
StatusBarStyle["Light"] = "light";
|
16
|
+
StatusBarStyle["Dark"] = "dark";
|
17
|
+
})(StatusBarStyle || (StatusBarStyle = {}));
|
package/src/types/stylesheet.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native'
|
1
|
+
import type { BoxShadowValue, ImageStyle, TextStyle, ViewStyle, FilterFunction } from 'react-native'
|
2
2
|
import type { ShadowOffset, TransformStyles, UnistylesTheme } from './core'
|
3
3
|
import type { UnistylesBreakpoints } from '../global'
|
4
4
|
import type { UnistylesMiniRuntime } from '../specs'
|
@@ -8,7 +8,7 @@ import type { CSSProperties } from 'react'
|
|
8
8
|
import type { Pseudo } from '../web/convert/pseudo'
|
9
9
|
|
10
10
|
// these props are treated differently to nest breakpoints and media queries
|
11
|
-
type NestedKeys = 'shadowOffset' | 'transform' | 'textShadowOffset'
|
11
|
+
type NestedKeys = 'shadowOffset' | 'transform' | 'textShadowOffset' | 'boxShadow' | 'filter'
|
12
12
|
|
13
13
|
export type UnistyleView = Omit<ViewStyle, NestedKeys>
|
14
14
|
export type UnistyleText = Omit<TextStyle, NestedKeys>
|
@@ -17,7 +17,9 @@ export type UnistyleImage = Omit<ImageStyle, NestedKeys>
|
|
17
17
|
type UnistyleNestedStyles = {
|
18
18
|
shadowOffset?: ToDeepUnistyles<ShadowOffset>,
|
19
19
|
textShadowOffset?: ToDeepUnistyles<ShadowOffset>,
|
20
|
-
transform?: Array<ToDeepUnistyles<TransformStyles
|
20
|
+
transform?: Array<ToDeepUnistyles<TransformStyles>>,
|
21
|
+
boxShadow?: Array<ToDeepUnistyles<BoxShadowValue>> | string,
|
22
|
+
filter?: Array<ToDeepUnistyles<FilterFunction>> | string
|
21
23
|
}
|
22
24
|
|
23
25
|
type VariantsObject = {
|
package/src/types/variants.ts
CHANGED
@@ -20,7 +20,7 @@ type ExtractSubVariantKeys<T> = T extends object
|
|
20
20
|
|
21
21
|
type ExtractVariant<T> = T extends { variants: infer V }
|
22
22
|
? { [key in keyof V]?: ExtractSubVariantKeys<V[key]> }
|
23
|
-
:
|
23
|
+
: never
|
24
24
|
|
25
25
|
export type UnistylesVariants<ST> = ST extends { useVariants: infer V }
|
26
26
|
? V extends (variants: infer T) => void
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { deepMergeObjects, warn } from '../utils';
|
2
|
+
import { validateShadow } from './shadow';
|
3
|
+
import { BOX_SHADOW_STYLES } from './types';
|
4
|
+
import { extractShadowValue, normalizeColor, normalizeNumericValue } from './utils';
|
5
|
+
const createBoxShadowValue = (style) => {
|
6
|
+
// at this point every prop is present
|
7
|
+
const { shadowColor, shadowOffset, shadowOpacity, shadowRadius } = style;
|
8
|
+
const offsetX = normalizeNumericValue(shadowOffset.width);
|
9
|
+
const offsetY = normalizeNumericValue(shadowOffset.height);
|
10
|
+
const radius = normalizeNumericValue(shadowRadius);
|
11
|
+
const color = normalizeColor(shadowColor, shadowOpacity);
|
12
|
+
return `${offsetX} ${offsetY} ${radius} ${color}`;
|
13
|
+
};
|
14
|
+
export const getBoxShadowStyle = (styles) => {
|
15
|
+
const missingStyles = BOX_SHADOW_STYLES.filter(key => !(key in styles));
|
16
|
+
if (missingStyles.length) {
|
17
|
+
warn(`can't apply box shadow as you miss these properties: ${missingStyles.join(', ')}`);
|
18
|
+
return {};
|
19
|
+
}
|
20
|
+
const breakpointsSet = new Set();
|
21
|
+
try {
|
22
|
+
validateShadow(BOX_SHADOW_STYLES, styles, breakpointsSet);
|
23
|
+
}
|
24
|
+
catch (error) {
|
25
|
+
if (typeof error === 'string') {
|
26
|
+
warn(error);
|
27
|
+
}
|
28
|
+
return {};
|
29
|
+
}
|
30
|
+
const breakpoints = Array.from(breakpointsSet);
|
31
|
+
// If no breakpoints were used return styles without media queries
|
32
|
+
if (breakpoints.length === 0) {
|
33
|
+
return {
|
34
|
+
boxShadow: createBoxShadowValue(styles)
|
35
|
+
};
|
36
|
+
}
|
37
|
+
// Create boxShadow for each breakpoint
|
38
|
+
const breakpointStyles = breakpoints.map(breakpoint => {
|
39
|
+
const color = extractShadowValue('shadowColor', breakpoint, styles);
|
40
|
+
const { width, height } = extractShadowValue('shadowOffset', breakpoint, styles);
|
41
|
+
const radius = extractShadowValue('shadowRadius', breakpoint, styles);
|
42
|
+
const opacity = extractShadowValue('shadowOpacity', breakpoint, styles);
|
43
|
+
return {
|
44
|
+
[breakpoint]: {
|
45
|
+
boxShadow: createBoxShadowValue({
|
46
|
+
shadowColor: color,
|
47
|
+
shadowOffset: {
|
48
|
+
width,
|
49
|
+
height
|
50
|
+
},
|
51
|
+
shadowRadius: radius,
|
52
|
+
shadowOpacity: opacity
|
53
|
+
})
|
54
|
+
}
|
55
|
+
};
|
56
|
+
});
|
57
|
+
// Merge all breakpoints styles into one
|
58
|
+
return deepMergeObjects(...breakpointStyles);
|
59
|
+
};
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { isPseudo } from './pseudo';
|
2
|
+
import { getStyle } from './style';
|
3
|
+
import { deepMergeObjects } from '../utils';
|
4
|
+
import { getTransformStyle } from './transform';
|
5
|
+
import { isBoxShadow, isTextShadow, isTransform } from './utils';
|
6
|
+
import { getTextShadowStyle } from './textShadow';
|
7
|
+
import { getBoxShadowStyle } from './boxShadow';
|
8
|
+
export const convertUnistyles = (value) => {
|
9
|
+
// Flag to mark if textShadow is already created
|
10
|
+
let hasTextShadow = false;
|
11
|
+
// Flag to mark if boxShadow is already created
|
12
|
+
let hasBoxShadow = false;
|
13
|
+
const stylesArray = Object.entries({
|
14
|
+
...value,
|
15
|
+
...value._web
|
16
|
+
}).flatMap(([unistylesKey, unistylesValue]) => {
|
17
|
+
// Keys to omit
|
18
|
+
if (['_classNames', '_web', 'variants', 'compoundVariants', 'uni__dependencies', '__unistyles-secrets__'].includes(unistylesKey) || unistylesKey.startsWith('variant-')) {
|
19
|
+
return [];
|
20
|
+
}
|
21
|
+
// Pseudo classes :hover, :before etc.
|
22
|
+
if (isPseudo(unistylesKey)) {
|
23
|
+
const flattenValues = convertUnistyles(unistylesValue);
|
24
|
+
return { [unistylesKey]: flattenValues };
|
25
|
+
}
|
26
|
+
// Text shadow
|
27
|
+
if (isTextShadow(unistylesKey)) {
|
28
|
+
if (hasTextShadow) {
|
29
|
+
return [];
|
30
|
+
}
|
31
|
+
hasTextShadow = true;
|
32
|
+
return getTextShadowStyle(value);
|
33
|
+
}
|
34
|
+
// Box shadow
|
35
|
+
if (isBoxShadow(unistylesKey)) {
|
36
|
+
if (hasBoxShadow) {
|
37
|
+
return [];
|
38
|
+
}
|
39
|
+
hasBoxShadow = true;
|
40
|
+
return getBoxShadowStyle(value);
|
41
|
+
}
|
42
|
+
// Transforms
|
43
|
+
if (isTransform(unistylesKey, unistylesValue)) {
|
44
|
+
return getTransformStyle(unistylesValue);
|
45
|
+
}
|
46
|
+
// Breakpoints
|
47
|
+
if (typeof unistylesValue === 'object' && unistylesValue !== null) {
|
48
|
+
return Object.entries(unistylesValue).map(([breakpointKey, breakpointValue]) => {
|
49
|
+
return { [breakpointKey]: getStyle(unistylesKey, breakpointValue) };
|
50
|
+
});
|
51
|
+
}
|
52
|
+
// Regular styles
|
53
|
+
return getStyle(unistylesKey, unistylesValue);
|
54
|
+
});
|
55
|
+
return deepMergeObjects(...stylesArray);
|
56
|
+
};
|