react-native-unistyles 2.0.0-alpha.17 → 2.0.0-alpha.18
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.
- package/cxx/UnistylesRuntime.h +3 -3
- package/lib/commonjs/common.js +1 -1
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistylesRuntime.js +4 -1
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
- package/lib/commonjs/hooks/useVariants.js +1 -11
- package/lib/commonjs/hooks/useVariants.js.map +1 -1
- package/lib/commonjs/plugins/index.js +0 -7
- package/lib/commonjs/plugins/index.js.map +1 -1
- package/lib/commonjs/useStyles.js +3 -4
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/index.js +7 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mqParser.js.map +1 -1
- package/lib/commonjs/utils/styles.js +26 -18
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/commonjs/utils/withPlugins.js +15 -0
- package/lib/commonjs/utils/withPlugins.js.map +1 -0
- package/lib/module/common.js +1 -1
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistylesRuntime.js +4 -1
- package/lib/module/core/UnistylesRuntime.js.map +1 -1
- package/lib/module/hooks/useVariants.js +1 -11
- package/lib/module/hooks/useVariants.js.map +1 -1
- package/lib/module/plugins/index.js +0 -1
- package/lib/module/plugins/index.js.map +1 -1
- package/lib/module/useStyles.js +4 -5
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/index.js +1 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mqParser.js.map +1 -1
- package/lib/module/utils/styles.js +26 -18
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/module/utils/withPlugins.js +8 -0
- package/lib/module/utils/withPlugins.js.map +1 -0
- package/lib/typescript/src/common.d.ts +1 -1
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +1 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useVariants.d.ts.map +1 -1
- package/lib/typescript/src/plugins/index.d.ts +0 -1
- package/lib/typescript/src/plugins/index.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +2 -1
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +2 -3
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +2 -2
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +5 -5
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/breakpoints.d.ts +2 -2
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +1 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mqParser.d.ts +2 -2
- package/lib/typescript/src/utils/mqParser.d.ts.map +1 -1
- package/lib/typescript/src/utils/styles.d.ts +3 -4
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/lib/typescript/src/utils/withPlugins.d.ts +3 -0
- package/lib/typescript/src/utils/withPlugins.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/common.ts +1 -1
- package/src/core/UnistylesRuntime.ts +5 -1
- package/src/hooks/useVariants.ts +1 -14
- package/src/plugins/index.ts +0 -1
- package/src/types/breakpoints.ts +4 -1
- package/src/types/core.ts +2 -3
- package/src/types/index.ts +1 -2
- package/src/types/stylesheet.ts +5 -5
- package/src/useStyles.ts +5 -17
- package/src/utils/breakpoints.ts +3 -3
- package/src/utils/index.ts +1 -0
- package/src/utils/mqParser.ts +2 -2
- package/src/utils/styles.ts +40 -49
- package/src/utils/withPlugins.ts +13 -0
- package/lib/commonjs/plugins/withPlugins.js +0 -14
- package/lib/commonjs/plugins/withPlugins.js.map +0 -1
- package/lib/commonjs/utils/variants.js +0 -52
- package/lib/commonjs/utils/variants.js.map +0 -1
- package/lib/module/plugins/withPlugins.js +0 -7
- package/lib/module/plugins/withPlugins.js.map +0 -1
- package/lib/module/utils/variants.js +0 -45
- package/lib/module/utils/variants.js.map +0 -1
- package/lib/typescript/src/plugins/withPlugins.d.ts +0 -4
- package/lib/typescript/src/plugins/withPlugins.d.ts.map +0 -1
- package/lib/typescript/src/utils/variants.d.ts +0 -3
- package/lib/typescript/src/utils/variants.d.ts.map +0 -1
- package/src/plugins/withPlugins.ts +0 -15
- package/src/utils/variants.ts +0 -61
@@ -1,8 +1,8 @@
|
|
1
1
|
export declare const warn: (message: string) => void;
|
2
|
-
export declare const isMobile: boolean;
|
3
2
|
export declare const isWeb: boolean;
|
4
3
|
export declare const isIOS: boolean;
|
5
4
|
export declare const isAndroid: boolean;
|
5
|
+
export declare const isMobile: boolean;
|
6
6
|
export declare const isServer: boolean;
|
7
7
|
export declare const ScreenOrientation: {
|
8
8
|
readonly Landscape: "landscape";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AAED,eAAO,MAAM,
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AAED,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,SAAS,SAA4B,CAAA;AAClD,eAAO,MAAM,QAAQ,SAAqB,CAAA;AAC1C,eAAO,MAAM,QAAQ,SAAgC,CAAA;AAErD,eAAO,MAAM,iBAAiB;;;CAGpB,CAAA;AAEV,oBAAY,kBAAkB;IAC1B,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED,oBAAY,cAAc;IACtB,kBAAkB,6FAA6F;IAC/G,aAAa,gFAAgF;IAC7F,kBAAkB,iFAAiF;IACnG,gBAAgB,wEAAyE;IACzF,mBAAmB,mDAAmD;IACtE,wBAAwB,wDAAwD;IAChF,4BAA4B,mEAAoE;IAChG,iBAAiB,6DAA8D;IAC/E,mBAAmB,+EAA+E;IAClG,wBAAwB,0DAA0D;CACrF"}
|
@@ -15,7 +15,7 @@ export declare class UnistylesRuntime {
|
|
15
15
|
height: number;
|
16
16
|
};
|
17
17
|
get orientation(): "landscape" | "portrait";
|
18
|
-
setTheme: (name: keyof UnistylesThemes) =>
|
18
|
+
setTheme: (name: keyof UnistylesThemes) => true | undefined;
|
19
19
|
setAdaptiveThemes: (enable: boolean) => void;
|
20
20
|
addPlugin: (plugin: UnistylesPlugin) => void;
|
21
21
|
removePlugin: (plugin: UnistylesPlugin) => void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;gBAA3D,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAEjG,IAAW,WAAW,uCAErB;IAED,IAAW,iBAAiB,YAE3B;IAED,IAAW,SAAS,UAEnB;IAED,IAAW,UAAU,mDAEpB;IAED,IAAW,cAAc,aAExB;IAED,IAAW,MAAM;;;MAKhB;IAED,IAAW,WAAW,6BAQrB;IAEM,QAAQ,SAAU,MAAM,eAAe,
|
1
|
+
{"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;gBAA3D,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAEjG,IAAW,WAAW,uCAErB;IAED,IAAW,iBAAiB,YAE3B;IAED,IAAW,SAAS,UAEnB;IAED,IAAW,UAAU,mDAEpB;IAED,IAAW,cAAc,aAExB;IAED,IAAW,MAAM;;;MAKhB;IAED,IAAW,WAAW,6BAQrB;IAEM,QAAQ,SAAU,MAAM,eAAe,sBAY7C;IAEM,iBAAiB,WAAY,OAAO,UAE1C;IAEM,SAAS,WAAY,eAAe,UAE1C;IAEM,YAAY,WAAY,eAAe,UAE7C;CACJ"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useVariants.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useVariants.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;
|
1
|
+
{"version":3,"file":"useVariants.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useVariants.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,eAAO,MAAM,WAAW,iBAAkB,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,+CAMzE,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA"}
|
@@ -18,7 +18,8 @@ type FlattenVariants<T> = T extends object ? {
|
|
18
18
|
[key in keyof T[K]]: T[K][key] extends object ? ParseNestedObject<T[K][key]> : never;
|
19
19
|
} : never;
|
20
20
|
} : never;
|
21
|
-
type ParseVariants<T> = T extends object ? T[keyof T] extends object ? ParseVariants<T[keyof T]
|
21
|
+
type ParseVariants<T> = T extends object ? T[keyof T] extends object ? UnionToIntersection<ParseVariants<T[keyof T]>> : T : T;
|
22
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
22
23
|
type ParseStyleKeys<T> = T extends object ? {
|
23
24
|
[K in keyof T]: ParseNestedObject<T[K]>;
|
24
25
|
} : never;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../../../src/types/breakpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAE7C,KAAK,qBAAqB,CAAC,CAAC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mBAAmB,CAAC,CAAC,IACtB,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAEvF,KAAK,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GACnC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC3C,KAAK,CAAA;AAEX,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC,GAC7E,cAAc,CAAC,CAAC,CAAC,GACjB,cAAc,CAAC,CAAC,CAAC,CAAA"}
|
@@ -10,10 +10,9 @@ export type ScreenSize = {
|
|
10
10
|
width: number;
|
11
11
|
height: number;
|
12
12
|
};
|
13
|
-
export type RNStyle = ViewStyle
|
14
|
-
export type RNValue =
|
13
|
+
export type RNStyle = ViewStyle & TextStyle & ImageStyle;
|
14
|
+
export type RNValue = ViewStyle[keyof ViewStyle] | TextStyle[keyof TextStyle] | ImageStyle[keyof ImageStyle];
|
15
15
|
export type NestedStyle = Record<keyof UnistylesBreakpoints | symbol, RNValue>;
|
16
16
|
export type NestedStylePairs = Array<[keyof UnistylesBreakpoints | symbol, RNValue]>;
|
17
17
|
export type UnistylesTheme = UnistylesThemes[keyof UnistylesThemes];
|
18
|
-
export type CreateStylesFactory<ST> = (theme: UnistylesTheme) => ST;
|
19
18
|
//# sourceMappingURL=core.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../src/types/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAEtE,MAAM,MAAM,YAAY,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,eAAe,GACrB,mBAAmB,GACnB,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,cAAc,GACd,cAAc,GACd,eAAe,CAAA;AAErB,MAAM,MAAM,UAAU,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAA;AACxD,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../src/types/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAEtE,MAAM,MAAM,YAAY,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,eAAe,GACrB,mBAAmB,GACnB,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,cAAc,GACd,cAAc,GACd,eAAe,CAAA;AAErB,MAAM,MAAM,UAAU,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAA;AACxD,MAAM,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,SAAS,CAAC,GAAG,SAAS,CAAC,MAAM,SAAS,CAAC,GAAG,UAAU,CAAC,MAAM,UAAU,CAAC,CAAA;AAC5G,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,EAAE,OAAO,CAAC,CAAA;AAC9E,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,CAAC,MAAM,oBAAoB,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AACpF,MAAM,MAAM,cAAc,GAAG,eAAe,CAAC,MAAM,eAAe,CAAC,CAAA"}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
export * from './normalizer';
|
2
2
|
export * from './unistyles';
|
3
3
|
export type { Optional, Nullable } from './common';
|
4
|
-
export type { NestedStylePairs, UnistylesTheme,
|
5
|
-
export type { StyleSheetWithSuperPowers, StyleSheet } from './stylesheet';
|
4
|
+
export type { NestedStylePairs, UnistylesTheme, ScreenSize, NestedStyle, RNValue, RNStyle } from './core';
|
5
|
+
export type { StyleSheetWithSuperPowers, StyleSheet, AllAvailableKeys } from './stylesheet';
|
6
6
|
export type { ReactNativeStyleSheet } from './breakpoints';
|
7
7
|
export type { ExtractVariantNames } from './variants';
|
8
8
|
export type { UnistylesPlugin } from './plugin';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAClD,YAAY,EACR,gBAAgB,EAChB,cAAc,EACd,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAClD,YAAY,EACR,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACV,MAAM,QAAQ,CAAA;AACf,YAAY,EAAE,yBAAyB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC3F,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC1D,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA"}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
2
2
|
import type { ShadowOffset, TransformStyles, UnistylesTheme } from './core';
|
3
3
|
import type { UnistylesBreakpoints } from '../global';
|
4
|
-
type
|
5
|
-
type UnistyleView = Omit<ViewStyle,
|
6
|
-
type UnistyleText = Omit<TextStyle,
|
7
|
-
type UnistyleImage = Omit<ImageStyle,
|
4
|
+
type NestedKeys = 'shadowOffset' | 'transform' | 'textShadowOffset';
|
5
|
+
type UnistyleView = Omit<ViewStyle, NestedKeys>;
|
6
|
+
type UnistyleText = Omit<TextStyle, NestedKeys>;
|
7
|
+
type UnistyleImage = Omit<ImageStyle, NestedKeys>;
|
8
8
|
type UnistyleNestedStyles = {
|
9
9
|
shadowOffset?: ToDeepUnistyles<ShadowOffset>;
|
10
10
|
textShadowOffset?: ToDeepUnistyles<ShadowOffset>;
|
@@ -30,7 +30,7 @@ export type UnistylesValues = {
|
|
30
30
|
[key in BreakpointsOrMediaQueries]?: AllAvailableStyles[propName];
|
31
31
|
};
|
32
32
|
} & Variants & {
|
33
|
-
[propName in
|
33
|
+
[propName in NestedKeys]?: UnistyleNestedStyles[propName];
|
34
34
|
};
|
35
35
|
export type StyleSheet = {
|
36
36
|
[styleName: string]: UnistylesValues | ((...args: any) => UnistylesValues);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"stylesheet.d.ts","sourceRoot":"","sources":["../../../../src/types/stylesheet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAC3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAGrD,KAAK,
|
1
|
+
{"version":3,"file":"stylesheet.d.ts","sourceRoot":"","sources":["../../../../src/types/stylesheet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAC3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAGrD,KAAK,UAAU,GAAG,cAAc,GAAG,WAAW,GAAG,kBAAkB,CAAA;AAEnE,KAAK,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;AAC/C,KAAK,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,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AED,MAAM,MAAM,UAAU,GAAG;IACrB,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,eAAe,CAAC,CAAA;CAC7E,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,EAAE,cAAc,KAAK,UAAU,CAAC,GAAG,UAAU,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;
|
1
|
+
{"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEpH,KAAK,gBAAgB,CAAC,EAAE,SAAS,yBAAyB,IAAI;IAC1D,KAAK,EAAE,cAAc,CAAC;IACtB,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,MAAM,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,SAAS,gJAgCrB,CAAA"}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import type {
|
2
|
-
export declare const getValueForBreakpoint: (value:
|
1
|
+
import type { Optional, RNValue } from '../types';
|
2
|
+
export declare const getValueForBreakpoint: (value: Record<string, RNValue>) => Optional<RNValue>;
|
3
3
|
//# sourceMappingURL=breakpoints.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../../../src/utils/breakpoints.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../../../src/utils/breakpoints.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAKjD,eAAO,MAAM,qBAAqB,UAAW,OAAO,MAAM,EAAE,OAAO,CAAC,KAAG,SAAS,OAAO,CAqCtF,CAAA"}
|
@@ -2,4 +2,5 @@ export { mq } from './mq';
|
|
2
2
|
export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq } from './mqParser';
|
3
3
|
export { getValueForBreakpoint } from './breakpoints';
|
4
4
|
export { proxifyFunction, parseStyle } from './styles';
|
5
|
+
export { withPlugins } from './withPlugins';
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACxG,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACxG,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type {
|
1
|
+
import type { Optional, RNValue, ScreenSize } from '../types';
|
2
2
|
type ParsedMqDimension = {
|
3
3
|
from: number;
|
4
4
|
to: number;
|
@@ -10,6 +10,6 @@ type UnistylesParsedMq = {
|
|
10
10
|
export declare const parseMq: (mq: string) => UnistylesParsedMq;
|
11
11
|
export declare const isValidMq: (parsedMq: UnistylesParsedMq) => boolean;
|
12
12
|
export declare const isWithinTheWidthAndHeight: (parsedMq: UnistylesParsedMq, screenSize: ScreenSize) => boolean;
|
13
|
-
export declare const getKeyForUnistylesMediaQuery: (mediaQueries:
|
13
|
+
export declare const getKeyForUnistylesMediaQuery: (mediaQueries: Array<[string, RNValue]>, screenSize: ScreenSize) => Optional<string>;
|
14
14
|
export {};
|
15
15
|
//# sourceMappingURL=mqParser.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mqParser.d.ts","sourceRoot":"","sources":["../../../../src/utils/mqParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"mqParser.d.ts","sourceRoot":"","sources":["../../../../src/utils/mqParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAM7D,KAAK,iBAAiB,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,iBAAiB,GAAG;IACrB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,MAAM,CAAC,EAAE,iBAAiB,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,OAAO,OAAQ,MAAM,KAAG,iBAcpC,CAAA;AAID,eAAO,MAAM,SAAS,aAAc,iBAAiB,YAgBpD,CAAA;AAED,eAAO,MAAM,yBAAyB,aAAc,iBAAiB,cAAc,UAAU,KAAG,OAgB/F,CAAA;AAcD,eAAO,MAAM,4BAA4B,iBAAkB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc,UAAU,KAAG,SAAS,MAAM,CAgB5H,CAAA"}
|
@@ -1,6 +1,5 @@
|
|
1
|
-
import type {
|
2
|
-
|
3
|
-
export declare const proxifyFunction: (key: string, fn: Function, plugins: Array<UnistylesPlugin>, runtime: UnistylesRuntime, variant?: Record<string, Optional<string>>) => Function;
|
1
|
+
import type { Optional, RNStyle } from '../types';
|
2
|
+
export declare const proxifyFunction: (key: string, fn: Function, variant?: Record<string, Optional<string>>) => Function;
|
4
3
|
export declare const isPlatformColor: <T extends {}>(value: T) => boolean;
|
5
|
-
export declare const parseStyle: <T extends
|
4
|
+
export declare const parseStyle: <T extends RNStyle>(style: T, variant?: Record<string, Optional<string>>) => T;
|
6
5
|
//# sourceMappingURL=styles.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAW,MAAM,UAAU,CAAA;AAK1D,eAAO,MAAM,eAAe,QACnB,MAAM,MACP,QAAQ,YACF,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,KAC3C,QAED,CAAA;AAEF,eAAO,MAAM,eAAe,8BAA6B,OAMxD,CAAA;AAED,eAAO,MAAM,UAAU,0CAEV,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,MAyC9B,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"withPlugins.d.ts","sourceRoot":"","sources":["../../../../src/utils/withPlugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAGvC,eAAO,MAAM,WAAW,QACf,MAAM,SACJ,OAAO,YAOT,CAAA"}
|
package/package.json
CHANGED
package/src/common.ts
CHANGED
@@ -4,10 +4,10 @@ export const warn = (message: string) => {
|
|
4
4
|
console.warn(`🦄 [react-native-unistyles]: ${message}`)
|
5
5
|
}
|
6
6
|
|
7
|
-
export const isMobile = Platform.OS === 'android' || Platform.OS === 'ios'
|
8
7
|
export const isWeb = Platform.OS === 'web'
|
9
8
|
export const isIOS = Platform.OS === 'ios'
|
10
9
|
export const isAndroid = Platform.OS === 'android'
|
10
|
+
export const isMobile = isIOS || isAndroid
|
11
11
|
export const isServer = typeof window === 'undefined'
|
12
12
|
|
13
13
|
export const ScreenOrientation = {
|
@@ -44,7 +44,11 @@ export class UnistylesRuntime {
|
|
44
44
|
}
|
45
45
|
|
46
46
|
public setTheme = (name: keyof UnistylesThemes) => {
|
47
|
-
if (name
|
47
|
+
if (name === this.themeName) {
|
48
|
+
return
|
49
|
+
}
|
50
|
+
|
51
|
+
if (this.unistylesRegistry.hasTheme(name)) {
|
48
52
|
this.unistylesBridge.useTheme(name)
|
49
53
|
|
50
54
|
return true
|
package/src/hooks/useVariants.ts
CHANGED
@@ -1,23 +1,10 @@
|
|
1
1
|
import { useRef } from 'react'
|
2
2
|
import type { Optional } from '../types'
|
3
3
|
|
4
|
-
const compareVariants = (prevVariants?: Record<string, Optional<string>>, nextVariants?: Record<string, Optional<string>>) => {
|
5
|
-
const keysA = Object.keys(prevVariants ?? {})
|
6
|
-
const keysB = Object.keys(nextVariants ?? {})
|
7
|
-
|
8
|
-
if (keysA.length !== keysB.length) {
|
9
|
-
return false
|
10
|
-
}
|
11
|
-
|
12
|
-
return keysA.every(key => prevVariants![key] === (nextVariants ?? {})[key])
|
13
|
-
}
|
14
|
-
|
15
4
|
export const useVariants = (variantsMap?: Record<string, Optional<string>>) => {
|
16
5
|
const variantsRef = useRef<Optional<Record<string, Optional<string>>>>(variantsMap)
|
17
6
|
|
18
|
-
|
19
|
-
variantsRef.current = variantsMap
|
20
|
-
}
|
7
|
+
variantsRef.current = variantsMap
|
21
8
|
|
22
9
|
return variantsRef.current
|
23
10
|
}
|
package/src/plugins/index.ts
CHANGED
package/src/types/breakpoints.ts
CHANGED
@@ -45,10 +45,13 @@ type FlattenVariants<T> = T extends object
|
|
45
45
|
|
46
46
|
type ParseVariants<T> = T extends object
|
47
47
|
? T[keyof T] extends object
|
48
|
-
? ParseVariants<T[keyof T]
|
48
|
+
? UnionToIntersection<ParseVariants<T[keyof T]>>
|
49
49
|
: T
|
50
50
|
: T
|
51
51
|
|
52
|
+
type UnionToIntersection<U> =
|
53
|
+
(U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never
|
54
|
+
|
52
55
|
type ParseStyleKeys<T> = T extends object
|
53
56
|
? { [K in keyof T]: ParseNestedObject<T[K]> }
|
54
57
|
: never
|
package/src/types/core.ts
CHANGED
@@ -41,9 +41,8 @@ export type ScreenSize = {
|
|
41
41
|
height: number
|
42
42
|
}
|
43
43
|
|
44
|
-
export type RNStyle = ViewStyle
|
45
|
-
export type RNValue =
|
44
|
+
export type RNStyle = ViewStyle & TextStyle & ImageStyle
|
45
|
+
export type RNValue = ViewStyle[keyof ViewStyle] | TextStyle[keyof TextStyle] | ImageStyle[keyof ImageStyle]
|
46
46
|
export type NestedStyle = Record<keyof UnistylesBreakpoints | symbol, RNValue>
|
47
47
|
export type NestedStylePairs = Array<[keyof UnistylesBreakpoints | symbol, RNValue]>
|
48
48
|
export type UnistylesTheme = UnistylesThemes[keyof UnistylesThemes]
|
49
|
-
export type CreateStylesFactory<ST> = (theme: UnistylesTheme) => ST
|
package/src/types/index.ts
CHANGED
@@ -4,13 +4,12 @@ export type { Optional, Nullable } from './common'
|
|
4
4
|
export type {
|
5
5
|
NestedStylePairs,
|
6
6
|
UnistylesTheme,
|
7
|
-
CreateStylesFactory,
|
8
7
|
ScreenSize,
|
9
8
|
NestedStyle,
|
10
9
|
RNValue,
|
11
10
|
RNStyle
|
12
11
|
} from './core'
|
13
|
-
export type { StyleSheetWithSuperPowers, StyleSheet } from './stylesheet'
|
12
|
+
export type { StyleSheetWithSuperPowers, StyleSheet, AllAvailableKeys } from './stylesheet'
|
14
13
|
export type { ReactNativeStyleSheet } from './breakpoints'
|
15
14
|
export type { ExtractVariantNames } from './variants'
|
16
15
|
export type { UnistylesPlugin } from './plugin'
|
package/src/types/stylesheet.ts
CHANGED
@@ -3,11 +3,11 @@ import type { ShadowOffset, TransformStyles, UnistylesTheme } from './core'
|
|
3
3
|
import type { UnistylesBreakpoints } from '../global'
|
4
4
|
|
5
5
|
// these props are treated differently to nest breakpoints and media queries
|
6
|
-
type
|
6
|
+
type NestedKeys = 'shadowOffset' | 'transform' | 'textShadowOffset'
|
7
7
|
|
8
|
-
type UnistyleView = Omit<ViewStyle,
|
9
|
-
type UnistyleText = Omit<TextStyle,
|
10
|
-
type UnistyleImage = Omit<ImageStyle,
|
8
|
+
type UnistyleView = Omit<ViewStyle, NestedKeys>
|
9
|
+
type UnistyleText = Omit<TextStyle, NestedKeys>
|
10
|
+
type UnistyleImage = Omit<ImageStyle, NestedKeys>
|
11
11
|
|
12
12
|
type UnistyleNestedStyles = {
|
13
13
|
shadowOffset?: ToDeepUnistyles<ShadowOffset>,
|
@@ -39,7 +39,7 @@ export type UnistylesValues = {
|
|
39
39
|
[key in BreakpointsOrMediaQueries]?: AllAvailableStyles[propName]
|
40
40
|
}
|
41
41
|
} & Variants & {
|
42
|
-
[propName in
|
42
|
+
[propName in NestedKeys]?: UnistyleNestedStyles[propName]
|
43
43
|
}
|
44
44
|
|
45
45
|
export type StyleSheet = {
|
package/src/useStyles.ts
CHANGED
@@ -1,15 +1,9 @@
|
|
1
1
|
import { useMemo } from 'react'
|
2
2
|
import { StyleSheet } from 'react-native'
|
3
|
-
import { parseStyle, proxifyFunction } from './utils'
|
3
|
+
import { parseStyle, proxifyFunction, withPlugins } from './utils'
|
4
4
|
import { useUnistyles, useVariants } from './hooks'
|
5
5
|
import type { UnistylesBreakpoints } from './global'
|
6
|
-
import {
|
7
|
-
import type {
|
8
|
-
ExtractVariantNames,
|
9
|
-
ReactNativeStyleSheet,
|
10
|
-
StyleSheetWithSuperPowers,
|
11
|
-
UnistylesTheme
|
12
|
-
} from './types'
|
6
|
+
import type { ExtractVariantNames, ReactNativeStyleSheet, StyleSheetWithSuperPowers, UnistylesTheme } from './types'
|
13
7
|
|
14
8
|
type ParsedStylesheet<ST extends StyleSheetWithSuperPowers> = {
|
15
9
|
theme: UnistylesTheme,
|
@@ -33,21 +27,15 @@ export const useStyles = <ST extends StyleSheetWithSuperPowers>(
|
|
33
27
|
if (typeof value === 'function') {
|
34
28
|
return {
|
35
29
|
...acc,
|
36
|
-
[key]: proxifyFunction(key, value
|
30
|
+
[key]: proxifyFunction(key, value)
|
37
31
|
}
|
38
32
|
}
|
39
33
|
|
40
34
|
return StyleSheet.create({
|
41
35
|
...acc,
|
42
|
-
[key]: parseStyle(
|
43
|
-
key,
|
44
|
-
value,
|
45
|
-
unistyles.registry.plugins,
|
46
|
-
unistyles.runtime,
|
47
|
-
variants
|
48
|
-
)
|
36
|
+
[key]: withPlugins(key, parseStyle(value, variants))
|
49
37
|
})
|
50
|
-
}, {}), [
|
38
|
+
}, {}), [parsedStyles, variants, plugins]
|
51
39
|
)
|
52
40
|
|
53
41
|
return {
|
package/src/utils/breakpoints.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
import { unistyles } from '../core'
|
2
|
-
import type {
|
2
|
+
import type { Optional, RNValue } from '../types'
|
3
3
|
import type { UnistylesBreakpoints } from '../global'
|
4
4
|
import { ScreenOrientation, isMobile } from '../common'
|
5
5
|
import { getKeyForUnistylesMediaQuery } from './mqParser'
|
6
6
|
|
7
|
-
export const getValueForBreakpoint = (value:
|
7
|
+
export const getValueForBreakpoint = (value: Record<string, RNValue>): Optional<RNValue> => {
|
8
8
|
const customMediaQueryKey = getKeyForUnistylesMediaQuery(
|
9
|
-
Object.entries(value)
|
9
|
+
Object.entries(value),
|
10
10
|
unistyles.runtime.screen
|
11
11
|
) as keyof typeof value
|
12
12
|
|
package/src/utils/index.ts
CHANGED
@@ -2,3 +2,4 @@ export { mq } from './mq'
|
|
2
2
|
export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq } from './mqParser'
|
3
3
|
export { getValueForBreakpoint } from './breakpoints'
|
4
4
|
export { proxifyFunction, parseStyle } from './styles'
|
5
|
+
export { withPlugins } from './withPlugins'
|
package/src/utils/mqParser.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type {
|
1
|
+
import type { Optional, RNValue, ScreenSize } from '../types'
|
2
2
|
|
3
3
|
const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/
|
4
4
|
const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/
|
@@ -80,7 +80,7 @@ const isWithinTheHeight = (height: UnistylesParsedMq['height'], screenHeight: nu
|
|
80
80
|
return screenHeight >= from && screenHeight <= to
|
81
81
|
}
|
82
82
|
|
83
|
-
export const getKeyForUnistylesMediaQuery = (mediaQueries:
|
83
|
+
export const getKeyForUnistylesMediaQuery = (mediaQueries: Array<[string, RNValue]>, screenSize: ScreenSize): Optional<string> => {
|
84
84
|
const mq = mediaQueries.find(([key]) => {
|
85
85
|
if (!isUnistylesMq(key as string)) {
|
86
86
|
return false
|
package/src/utils/styles.ts
CHANGED
@@ -1,19 +1,14 @@
|
|
1
|
-
import type {
|
1
|
+
import type { Optional, RNStyle, RNValue } from '../types'
|
2
2
|
import { getValueForBreakpoint } from './breakpoints'
|
3
|
-
import type { UnistylesRuntime } from '../core'
|
4
3
|
import { isAndroid, isIOS } from '../common'
|
5
|
-
import {
|
6
|
-
import { withPlugins } from '../plugins'
|
4
|
+
import { withPlugins } from './withPlugins'
|
7
5
|
|
8
6
|
export const proxifyFunction = (
|
9
7
|
key: string,
|
10
8
|
fn: Function,
|
11
|
-
plugins: Array<UnistylesPlugin>,
|
12
|
-
runtime: UnistylesRuntime,
|
13
9
|
variant?: Record<string, Optional<string>>
|
14
10
|
): Function => new Proxy(fn, {
|
15
|
-
apply: (target, thisArg, argumentsList) =>
|
16
|
-
parseStyle(key, target.apply(thisArg, argumentsList), plugins, runtime, variant)
|
11
|
+
apply: (target, thisArg, argumentsList) => withPlugins(key, parseStyle(target.apply(thisArg, argumentsList), variant))
|
17
12
|
})
|
18
13
|
|
19
14
|
export const isPlatformColor = <T extends {}>(value: T): boolean => {
|
@@ -24,51 +19,47 @@ export const isPlatformColor = <T extends {}>(value: T): boolean => {
|
|
24
19
|
return isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object'
|
25
20
|
}
|
26
21
|
|
27
|
-
export const parseStyle = <T extends
|
28
|
-
key: string,
|
22
|
+
export const parseStyle = <T extends RNStyle>(
|
29
23
|
style: T,
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
)
|
34
|
-
|
35
|
-
|
24
|
+
variant: Record<string, Optional<string>> = {}
|
25
|
+
): T => Object
|
26
|
+
.entries(style || {})
|
27
|
+
.reduce((acc, [key, value]) => {
|
28
|
+
// nested objects
|
29
|
+
if (key === 'shadowOffset' || key === 'textShadowOffset') {
|
30
|
+
acc[key] = parseStyle(value, variant)
|
36
31
|
|
37
|
-
|
38
|
-
|
39
|
-
.map(([key, value]) => {
|
40
|
-
// dynamic functions
|
41
|
-
if (typeof value === 'function') {
|
42
|
-
return [key, value]
|
43
|
-
}
|
32
|
+
return acc
|
33
|
+
}
|
44
34
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
key,
|
49
|
-
parseStyle(key, value, plugins, runtime, variant)
|
50
|
-
]
|
51
|
-
}
|
35
|
+
// transforms
|
36
|
+
if (key === 'transform' && Array.isArray(value)) {
|
37
|
+
acc[key] = value.map(value => parseStyle(value, variant))
|
52
38
|
|
53
|
-
|
54
|
-
|
55
|
-
return [
|
56
|
-
key,
|
57
|
-
value.map(value => parseStyle(key, value, plugins, runtime, variant))
|
58
|
-
]
|
59
|
-
}
|
39
|
+
return acc
|
40
|
+
}
|
60
41
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
}
|
42
|
+
// values or platform colors
|
43
|
+
if (typeof value !== 'object' || isPlatformColor(value)) {
|
44
|
+
acc[key as keyof T] = value
|
65
45
|
|
66
|
-
|
67
|
-
|
68
|
-
getValueForBreakpoint(value as NestedStyle)
|
69
|
-
]
|
70
|
-
})
|
71
|
-
) as T
|
46
|
+
return acc
|
47
|
+
}
|
72
48
|
|
73
|
-
|
74
|
-
|
49
|
+
if (key === 'variants') {
|
50
|
+
return {
|
51
|
+
...acc,
|
52
|
+
...(Object
|
53
|
+
.keys(value) as Array<keyof typeof value>)
|
54
|
+
.reduce((acc, key) => ({
|
55
|
+
...acc,
|
56
|
+
...parseStyle((value)[key][variant[key as keyof typeof variant] || 'default'] ?? {})
|
57
|
+
}), {})
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
return {
|
62
|
+
...acc,
|
63
|
+
[key]: getValueForBreakpoint(value as Record<string, RNValue>)
|
64
|
+
}
|
65
|
+
}, {} as T)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import type { RNStyle } from '../types'
|
2
|
+
import { unistyles } from '../core'
|
3
|
+
|
4
|
+
export const withPlugins = (
|
5
|
+
key: string,
|
6
|
+
style: RNStyle
|
7
|
+
) => unistyles.registry.plugins.reduce((acc, plugin) => {
|
8
|
+
if (plugin.onParsedStyle) {
|
9
|
+
return plugin.onParsedStyle(key, style, unistyles.runtime)
|
10
|
+
}
|
11
|
+
|
12
|
+
return acc
|
13
|
+
}, style)
|
@@ -1,14 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.withPlugins = void 0;
|
7
|
-
const withPlugins = (key, style, plugins, runtime) => plugins.reduce((acc, plugin) => {
|
8
|
-
if (plugin.onParsedStyle) {
|
9
|
-
return plugin.onParsedStyle(key, acc, runtime);
|
10
|
-
}
|
11
|
-
return acc;
|
12
|
-
}, style);
|
13
|
-
exports.withPlugins = withPlugins;
|
14
|
-
//# sourceMappingURL=withPlugins.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["withPlugins","key","style","plugins","runtime","reduce","acc","plugin","onParsedStyle","exports"],"sourceRoot":"../../../src","sources":["plugins/withPlugins.ts"],"mappings":";;;;;;AAGO,MAAMA,WAAW,GAAGA,CACvBC,GAAW,EACXC,KAAc,EACdC,OAA+B,EAC/BC,OAAyB,KACxBD,OAAO,CAACE,MAAM,CAAC,CAACC,GAAG,EAAEC,MAAM,KAAK;EACjC,IAAIA,MAAM,CAACC,aAAa,EAAE;IACtB,OAAOD,MAAM,CAACC,aAAa,CAACP,GAAG,EAAEK,GAAG,EAAEF,OAAO,CAAC;EAClD;EAEA,OAAOE,GAAG;AACd,CAAC,EAAEJ,KAAK,CAAC;AAAAO,OAAA,CAAAT,WAAA,GAAAA,WAAA"}
|