react-native-unistyles 2.0.0-alpha.13 → 2.0.0-alpha.15
Sign up to get free protection for your applications and to get access to all the features.
- package/cxx/UnistylesRuntime.h +6 -6
- package/lib/commonjs/common.js +15 -15
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistyleRegistry.js +3 -2
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/core/UnistylesRuntime.js +1 -1
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
- package/lib/commonjs/createStyleSheet.js +1 -6
- package/lib/commonjs/createStyleSheet.js.map +1 -1
- package/lib/commonjs/hooks/index.js +7 -0
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useUnistyles.js +4 -7
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
- package/lib/commonjs/hooks/useVariants.js +24 -0
- package/lib/commonjs/hooks/useVariants.js.map +1 -0
- package/lib/commonjs/plugins/normalizer/normalizer.js +1 -1
- package/lib/commonjs/plugins/normalizer/normalizer.js.map +1 -1
- package/lib/commonjs/plugins/withPlugins.js +2 -6
- package/lib/commonjs/plugins/withPlugins.js.map +1 -1
- package/lib/commonjs/types/stylesheet.js +6 -0
- package/lib/commonjs/types/stylesheet.js.map +1 -0
- package/lib/commonjs/useStyles.js +8 -11
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/index.js +22 -5
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mq.js +42 -28
- package/lib/commonjs/utils/mq.js.map +1 -1
- package/lib/commonjs/utils/styles.js +19 -23
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/commonjs/utils/variants.js +43 -8
- package/lib/commonjs/utils/variants.js.map +1 -1
- package/lib/module/common.js +14 -14
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistyleRegistry.js +4 -3
- package/lib/module/core/UnistyleRegistry.js.map +1 -1
- package/lib/module/core/UnistylesRuntime.js +1 -1
- package/lib/module/core/UnistylesRuntime.js.map +1 -1
- package/lib/module/createStyleSheet.js +1 -6
- package/lib/module/createStyleSheet.js.map +1 -1
- package/lib/module/hooks/index.js +1 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useUnistyles.js +5 -8
- package/lib/module/hooks/useUnistyles.js.map +1 -1
- package/lib/module/hooks/useVariants.js +17 -0
- package/lib/module/hooks/useVariants.js.map +1 -0
- package/lib/module/plugins/normalizer/normalizer.js +1 -1
- package/lib/module/plugins/normalizer/normalizer.js.map +1 -1
- package/lib/module/plugins/withPlugins.js +2 -6
- package/lib/module/plugins/withPlugins.js.map +1 -1
- package/lib/module/types/stylesheet.js +2 -0
- package/lib/module/types/stylesheet.js.map +1 -0
- package/lib/module/useStyles.js +9 -12
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/index.js +1 -2
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mq.js +41 -27
- package/lib/module/utils/mq.js.map +1 -1
- package/lib/module/utils/styles.js +20 -24
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/module/utils/variants.js +41 -6
- package/lib/module/utils/variants.js.map +1 -1
- package/lib/typescript/src/common.d.ts +10 -10
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
- package/lib/typescript/src/createStyleSheet.d.ts +2 -2
- package/lib/typescript/src/createStyleSheet.d.ts.map +1 -1
- package/lib/typescript/src/global.d.ts.map +1 -1
- package/lib/typescript/src/hooks/index.d.ts +1 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useVariants.d.ts +3 -0
- package/lib/typescript/src/hooks/useVariants.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizer/normalizer.d.ts.map +1 -1
- package/lib/typescript/src/plugins/withPlugins.d.ts +3 -2
- package/lib/typescript/src/plugins/withPlugins.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +20 -14
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +3 -26
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +2 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/mq.d.ts +2 -2
- package/lib/typescript/src/types/mq.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +47 -0
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -0
- package/lib/typescript/src/types/unistyles.d.ts +5 -6
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
- package/lib/typescript/src/types/variants.d.ts +13 -7
- package/lib/typescript/src/types/variants.d.ts.map +1 -1
- package/lib/typescript/src/useStyles.d.ts +3 -3
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +1 -2
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mq.d.ts +19 -13
- package/lib/typescript/src/utils/mq.d.ts.map +1 -1
- package/lib/typescript/src/utils/styles.d.ts +4 -4
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/lib/typescript/src/utils/variants.d.ts +2 -2
- package/lib/typescript/src/utils/variants.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/common.ts +10 -10
- package/src/core/UnistyleRegistry.ts +6 -3
- package/src/core/UnistylesRuntime.ts +1 -1
- package/src/createStyleSheet.ts +2 -8
- package/src/global.ts +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useUnistyles.ts +5 -8
- package/src/hooks/useVariants.ts +23 -0
- package/src/plugins/normalizer/normalizer.ts +3 -3
- package/src/plugins/withPlugins.ts +13 -15
- package/src/types/breakpoints.ts +47 -26
- package/src/types/core.ts +6 -42
- package/src/types/index.ts +1 -1
- package/src/types/mq.ts +2 -2
- package/src/types/stylesheet.ts +56 -0
- package/src/types/unistyles.ts +5 -6
- package/src/types/variants.ts +17 -9
- package/src/useStyles.ts +22 -16
- package/src/utils/index.ts +1 -2
- package/src/utils/mq.ts +56 -41
- package/src/utils/styles.ts +28 -45
- package/src/utils/variants.ts +55 -7
@@ -1,9 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { UnistylesEventType, ScreenOrientation } from '../common';
|
2
2
|
import type { UnistylesThemes, UnistylesBreakpoints } from '../global';
|
3
3
|
import type { ScreenSize } from './core';
|
4
|
-
import type { Optional } from './common';
|
5
4
|
import type { UnistylesPlugin } from './plugin';
|
6
|
-
export type ColorSchemeName =
|
5
|
+
export type ColorSchemeName = 'light' | 'dark' | 'unspecified';
|
7
6
|
export type UnistylesConfig = {
|
8
7
|
adaptiveThemes?: boolean;
|
9
8
|
experimentalPlugins?: Array<UnistylesPlugin>;
|
@@ -26,13 +25,13 @@ export type UnistylesBridge = {
|
|
26
25
|
removePlugin(pluginName: string): void;
|
27
26
|
};
|
28
27
|
export type UnistylesThemeEvent = {
|
29
|
-
type:
|
28
|
+
type: UnistylesEventType.Theme;
|
30
29
|
payload: {
|
31
30
|
themeName: keyof UnistylesThemes;
|
32
31
|
};
|
33
32
|
};
|
34
33
|
export type UnistylesMobileLayoutEvent = {
|
35
|
-
type:
|
34
|
+
type: UnistylesEventType.Layout;
|
36
35
|
payload: {
|
37
36
|
screen: ScreenSize;
|
38
37
|
breakpoint: keyof UnistylesBreakpoints;
|
@@ -40,7 +39,7 @@ export type UnistylesMobileLayoutEvent = {
|
|
40
39
|
};
|
41
40
|
};
|
42
41
|
export type UnistylesPluginEvent = {
|
43
|
-
type:
|
42
|
+
type: UnistylesEventType.Plugin;
|
44
43
|
};
|
45
44
|
export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent;
|
46
45
|
//# sourceMappingURL=unistyles.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"unistyles.d.ts","sourceRoot":"","sources":["../../../../src/types/unistyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"unistyles.d.ts","sourceRoot":"","sources":["../../../../src/types/unistyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,CAAA;AAE9D,MAAM,MAAM,eAAe,GAAG;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAC7C,YAAY,CAAC,EAAE,MAAM,eAAe,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAE1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,MAAM,eAAe,CAAC;IACjC,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,WAAW,EAAE,eAAe,CAAC;IAC7B,qBAAqB,EAAE,KAAK,CAAC,CAAC,MAAM,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAG7G,MAAM,EAAE,KAAK,CAAC,MAAM,eAAe,CAAC,CAAC;IACrC,cAAc,CAAC,WAAW,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,eAAe,GAAG,IAAI,CAAC;IAC5C,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACzC,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACrD,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CACzC,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC;IAC/B,OAAO,EAAE;QACL,SAAS,EAAE,MAAM,eAAe,CAAA;KACnC,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACrC,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC;IAChC,OAAO,EAAE;QACL,MAAM,EAAE,UAAU,CAAC;QACnB,UAAU,EAAE,MAAM,oBAAoB,CAAC;QACvC,WAAW,EAAE,OAAO,iBAAiB,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAA;KACxE,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAC/B,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,0BAA0B,GAAG,oBAAoB,CAAA"}
|
@@ -1,8 +1,14 @@
|
|
1
|
-
export type ExtractVariantNames<T> = T extends
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
export type ExtractVariantNames<T> = T extends (...args: any) => infer R ? ExtractVariantKeys<R> : ExtractVariantKeys<T>;
|
2
|
+
type ExtractVariantKeys<T> = T extends object ? ExtractVariant<T[keyof T]> : never;
|
3
|
+
type ExtractSubVariantKeys<T> = T extends object ? keyof Omit<T, 'default'> | undefined : never;
|
4
|
+
type ExtractVariant<T> = T extends (...args: any) => infer R ? R extends {
|
5
|
+
variants: infer V;
|
6
|
+
} ? {
|
7
|
+
[key in keyof V]?: ExtractSubVariantKeys<V[key]>;
|
8
|
+
} : never : T extends {
|
9
|
+
variants: infer V;
|
10
|
+
} ? {
|
11
|
+
[key in keyof V]?: ExtractSubVariantKeys<V[key]>;
|
12
|
+
} : never;
|
13
|
+
export {};
|
8
14
|
//# sourceMappingURL=variants.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/types/variants.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,
|
1
|
+
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/types/variants.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,GAClE,kBAAkB,CAAC,CAAC,CAAC,GACrB,kBAAkB,CAAC,CAAC,CAAC,CAAA;AAE3B,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GACvC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAC1B,KAAK,CAAA;AAEX,KAAK,qBAAqB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAC1C,MAAM,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,SAAS,GACpC,KAAK,CAAA;AAEX,KAAK,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,GACtD,CAAC,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;CAAE,GAC3B;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,GACpD,KAAK,GACT,CAAC,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;CAAE,GAC3B;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,GACpD,KAAK,CAAA"}
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import type { CreateStylesFactory, CustomNamedStyles, ExtractVariantNames, ReactNativeStyleSheet, UnistylesTheme } from './types';
|
2
1
|
import type { UnistylesBreakpoints } from './global';
|
3
|
-
type
|
2
|
+
import type { ExtractVariantNames, ReactNativeStyleSheet, StyleSheetWithSuperPowers, UnistylesTheme } from './types';
|
3
|
+
type ParsedStylesheet<ST extends StyleSheetWithSuperPowers> = {
|
4
4
|
theme: UnistylesTheme;
|
5
5
|
breakpoint: keyof UnistylesBreakpoints;
|
6
6
|
styles: ReactNativeStyleSheet<ST>;
|
7
7
|
};
|
8
|
-
export declare const useStyles: <ST extends
|
8
|
+
export declare const useStyles: <ST extends StyleSheetWithSuperPowers>(stylesheet?: ST | undefined, variantsMap?: ExtractVariantNames<ST> | undefined) => ParsedStylesheet<ST>;
|
9
9
|
export {};
|
10
10
|
//# sourceMappingURL=useStyles.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEpD,OAAO,KAAK,EACR,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EACzB,cAAc,EACjB,MAAM,SAAS,CAAA;AAEhB,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,gJAgDrB,CAAA"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
export { mq, MQSymbol } from './mq';
|
2
|
-
export { getKeyForVariant } from './variants';
|
1
|
+
export { mq, MQSymbol, MQHeight, MQWidth, MQHeightAndWidth, MQWidthAndHeight } from './mq';
|
3
2
|
export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq } from './mqParser';
|
4
3
|
export { getValueForBreakpoint } from './breakpoints';
|
5
4
|
export { proxifyFunction, parseStyle } from './styles';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAA;AAC1F,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,21 +1,27 @@
|
|
1
|
-
import type {
|
1
|
+
import type { Nullable } from '../types';
|
2
2
|
import type { UnistylesBreakpoints } from '../global';
|
3
3
|
export declare const MQSymbol: unique symbol;
|
4
|
+
export declare const MQWidth: unique symbol;
|
5
|
+
export declare const MQHeight: unique symbol;
|
6
|
+
export declare const MQWidthAndHeight: unique symbol;
|
7
|
+
export declare const MQHeightAndWidth: unique symbol;
|
4
8
|
type MQValue = keyof UnistylesBreakpoints | number;
|
5
9
|
type MQHandler = {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
only: {
|
11
|
+
width(wMin?: Nullable<MQValue>, wMax?: MQValue): typeof MQWidth;
|
12
|
+
height(hMin?: Nullable<MQValue>, hMax?: MQValue): typeof MQHeight;
|
13
|
+
};
|
14
|
+
width(wMin?: Nullable<MQValue>, wMax?: MQValue): {
|
15
|
+
and: {
|
16
|
+
height(hMin?: Nullable<MQValue>, hMax?: MQValue): typeof MQWidthAndHeight;
|
17
|
+
};
|
18
|
+
};
|
19
|
+
height(hMin?: Nullable<MQValue>, hMax?: MQValue): {
|
20
|
+
and: {
|
21
|
+
width(wMin?: Nullable<MQValue>, wMax?: MQValue): typeof MQHeightAndWidth;
|
22
|
+
};
|
23
|
+
};
|
10
24
|
};
|
11
|
-
type HeightHandler = {
|
12
|
-
w(wMin?: Nullable<MQValue>, wMax?: MQValue): MediaQuery;
|
13
|
-
width(wMin?: Nullable<MQValue>, wMax?: MQValue): MediaQuery;
|
14
|
-
} & MediaQuery;
|
15
|
-
type WidthHandler = {
|
16
|
-
h(hMin?: Nullable<MQValue>, hMax?: MQValue): MediaQuery;
|
17
|
-
height(hMin?: Nullable<MQValue>, hMax?: MQValue): MediaQuery;
|
18
|
-
} & MediaQuery;
|
19
25
|
export declare const mq: MQHandler;
|
20
26
|
export {};
|
21
27
|
//# sourceMappingURL=mq.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../../../src/utils/mq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../../../src/utils/mq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAGrD,eAAO,MAAM,QAAQ,eAAyB,CAAA;AAC9C,eAAO,MAAM,OAAO,eAA+B,CAAA;AACnD,eAAO,MAAM,QAAQ,eAAgC,CAAA;AACrD,eAAO,MAAM,gBAAgB,eAA0C,CAAA;AACvE,eAAO,MAAM,gBAAgB,eAA0C,CAAA;AAEvE,KAAK,OAAO,GAAG,MAAM,oBAAoB,GAAG,MAAM,CAAA;AAElD,KAAK,SAAS,GAAG;IACb,IAAI,EAAE;QACF,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,OAAO,CAAC;QAChE,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,QAAQ,CAAC;KACrE,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG;QAC7C,GAAG,EAAE;YACD,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,gBAAgB,CAAA;SAC5E,CAAA;KACJ,CAAC;IACF,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG;QAC9C,GAAG,EAAE;YACD,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,gBAAgB,CAAA;SAC3E,CAAA;KACJ,CAAA;CACJ,CAAA;AA0ED,eAAO,MAAM,EAAE,WAmBb,CAAA"}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
3
|
-
export declare const proxifyFunction: (key: string, fn: Function,
|
1
|
+
import type { UnistylesPlugin, StyleSheet, Optional } from '../types';
|
2
|
+
import type { UnistylesRuntime } from '../core';
|
3
|
+
export declare const proxifyFunction: (key: string, fn: Function, plugins: Array<UnistylesPlugin>, runtime: UnistylesRuntime, variant?: Record<string, Optional<string>>) => Function;
|
4
4
|
export declare const isPlatformColor: <T extends {}>(value: T) => boolean;
|
5
|
-
export declare const parseStyle: <T extends
|
5
|
+
export declare const parseStyle: <T extends StyleSheet>(key: string, style: T, plugins: Array<UnistylesPlugin>, runtime: UnistylesRuntime, variant?: Record<string, Optional<string>>) => T;
|
6
6
|
//# 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,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAElF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAK/C,eAAO,MAAM,eAAe,QACnB,MAAM,MACP,QAAQ,WACH,MAAM,eAAe,CAAC,WACtB,gBAAgB,YACf,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,KAC3C,QAGD,CAAA;AAEF,eAAO,MAAM,eAAe,8BAA6B,OAMxD,CAAA;AAED,eAAO,MAAM,UAAU,8BACd,MAAM,qBAEF,MAAM,eAAe,CAAC,WACtB,gBAAgB,YACf,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,MA0C7C,CAAA"}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import type { Optional,
|
2
|
-
export declare const
|
1
|
+
import type { Optional, StyleSheet } from '../types';
|
2
|
+
export declare const getStyleWithVariants: (style: StyleSheet, variantValues?: Record<string, Optional<string>>) => StyleSheet;
|
3
3
|
//# sourceMappingURL=variants.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/utils/variants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,
|
1
|
+
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/utils/variants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAe,MAAM,UAAU,CAAA;AAqCjE,eAAO,MAAM,oBAAoB,UACtB,UAAU,kBACD,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,eAqBnD,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "2.0.0-alpha.
|
3
|
+
"version": "2.0.0-alpha.15",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
@@ -50,23 +50,23 @@
|
|
50
50
|
"registry": "https://registry.npmjs.org/"
|
51
51
|
},
|
52
52
|
"devDependencies": {
|
53
|
-
"@commitlint/config-conventional": "18.
|
53
|
+
"@commitlint/config-conventional": "18.4.3",
|
54
54
|
"@react-native/eslint-config": "0.74.0",
|
55
55
|
"@react-native/normalize-colors": "0.74.1",
|
56
|
-
"@release-it/conventional-changelog": "
|
56
|
+
"@release-it/conventional-changelog": "8.0.1",
|
57
57
|
"@testing-library/react-hooks": "8.0.1",
|
58
|
-
"@types/jest": "29.5.
|
59
|
-
"@types/react": "18.2.
|
60
|
-
"@typescript-eslint/eslint-plugin": "6.
|
61
|
-
"@typescript-eslint/eslint-plugin-tslint": "6.
|
62
|
-
"@typescript-eslint/parser": "6.
|
63
|
-
"commitlint": "18.
|
58
|
+
"@types/jest": "29.5.10",
|
59
|
+
"@types/react": "18.2.38",
|
60
|
+
"@typescript-eslint/eslint-plugin": "6.12.0",
|
61
|
+
"@typescript-eslint/eslint-plugin-tslint": "6.12.0",
|
62
|
+
"@typescript-eslint/parser": "6.12.0",
|
63
|
+
"commitlint": "18.4.3",
|
64
64
|
"concurrently": "8.2.2",
|
65
|
-
"eslint": "8.
|
65
|
+
"eslint": "8.54.0",
|
66
66
|
"eslint-config-codemask": "1.1.7",
|
67
67
|
"eslint-plugin-functional": "6.0.0",
|
68
68
|
"eslint-plugin-import": "2.29.0",
|
69
|
-
"eslint-plugin-jsdoc": "46.
|
69
|
+
"eslint-plugin-jsdoc": "46.9.0",
|
70
70
|
"eslint-plugin-jsx-a11y": "6.8.0",
|
71
71
|
"eslint-plugin-nested-if": "1.0.0",
|
72
72
|
"eslint-plugin-no-else": "0.2.2",
|
@@ -77,11 +77,11 @@
|
|
77
77
|
"husky": "8.0.3",
|
78
78
|
"jest": "29.7.0",
|
79
79
|
"react": "18.2.0",
|
80
|
-
"react-native": "0.72.
|
81
|
-
"react-native-builder-bob": "0.23.
|
80
|
+
"react-native": "0.72.7",
|
81
|
+
"react-native-builder-bob": "0.23.2",
|
82
82
|
"react-native-web": "0.19.9",
|
83
83
|
"react-test-renderer": "18.2.0",
|
84
|
-
"release-it": "
|
84
|
+
"release-it": "17.0.0",
|
85
85
|
"typescript": "5.2.2"
|
86
86
|
},
|
87
87
|
"peerDependencies": {
|
package/src/common.ts
CHANGED
@@ -15,20 +15,20 @@ export const ScreenOrientation = {
|
|
15
15
|
Portrait: 'portrait'
|
16
16
|
} as const
|
17
17
|
|
18
|
-
export enum
|
18
|
+
export enum UnistylesEventType {
|
19
19
|
Theme = 'theme',
|
20
20
|
Layout = 'layout',
|
21
21
|
Plugin = 'plugin'
|
22
22
|
}
|
23
23
|
|
24
24
|
export enum UnistylesError {
|
25
|
-
RuntimeUnavailable = '
|
26
|
-
ThemeNotFound = '
|
27
|
-
ThemeNotRegistered = '
|
28
|
-
ThemesCannotBeEmpty = '
|
29
|
-
BreakpointsCannotBeEmpty = '
|
30
|
-
BreakpointsMustStartFromZero = '
|
31
|
-
InvalidPluginName = '
|
32
|
-
DuplicatePluginName = '
|
33
|
-
CantRemoveInternalPlugin = '
|
25
|
+
RuntimeUnavailable = 'Unistyles runtime is not available. Make sure you followed the installation instructions.',
|
26
|
+
ThemeNotFound = 'You are trying to get a theme that is not registered.',
|
27
|
+
ThemeNotRegistered = 'You are trying to set a theme that is not registered.',
|
28
|
+
ThemesCannotBeEmpty = 'You are trying to register an empty themes object.',
|
29
|
+
BreakpointsCannotBeEmpty = 'You are trying to register an empty breakpoints object.',
|
30
|
+
BreakpointsMustStartFromZero = 'One breakpoint must start from 0.',
|
31
|
+
InvalidPluginName = 'Plugin name can\'t start from reserved prefix. Use another name.',
|
32
|
+
DuplicatePluginName = 'You are trying to register a plugin with a name that is already registered.',
|
33
|
+
CantRemoveInternalPlugin = 'You are trying to remove an internal unistyles plugin.'
|
34
34
|
}
|
@@ -1,10 +1,13 @@
|
|
1
1
|
import type { UnistylesBridge, UnistylesConfig, UnistylesPlugin } from '../types'
|
2
2
|
import type { UnistylesBreakpoints, UnistylesThemes } from '../global'
|
3
|
-
import { UnistylesError } from '../common'
|
3
|
+
import { isWeb, UnistylesError } from '../common'
|
4
|
+
import { normalizeWebStylesPlugin } from '../plugins'
|
4
5
|
|
5
6
|
export class UnistyleRegistry {
|
6
7
|
public config: UnistylesConfig = {}
|
7
|
-
public plugins: Array<UnistylesPlugin> =
|
8
|
+
public plugins: Array<UnistylesPlugin> = isWeb
|
9
|
+
? [normalizeWebStylesPlugin]
|
10
|
+
: []
|
8
11
|
public themeNames: Array<keyof UnistylesThemes> = []
|
9
12
|
public themes: UnistylesThemes = {} as UnistylesThemes
|
10
13
|
public breakpoints: UnistylesBreakpoints = {} as UnistylesBreakpoints
|
@@ -68,7 +71,7 @@ export class UnistyleRegistry {
|
|
68
71
|
throw new Error(UnistylesError.DuplicatePluginName)
|
69
72
|
}
|
70
73
|
|
71
|
-
this.plugins = this.plugins
|
74
|
+
this.plugins = [plugin].concat(this.plugins)
|
72
75
|
this.unistylesBridge.addPlugin(plugin.name, notify)
|
73
76
|
}
|
74
77
|
|
@@ -44,7 +44,7 @@ export class UnistylesRuntime {
|
|
44
44
|
}
|
45
45
|
|
46
46
|
public setTheme = (name: keyof UnistylesThemes) => {
|
47
|
-
if (this.unistylesRegistry.hasTheme(name)) {
|
47
|
+
if (name !== this.themeName && this.unistylesRegistry.hasTheme(name)) {
|
48
48
|
this.unistylesBridge.useTheme(name)
|
49
49
|
|
50
50
|
return true
|
package/src/createStyleSheet.ts
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
import type {
|
1
|
+
import type { StyleSheetWithSuperPowers } from './types'
|
2
2
|
|
3
|
-
export const createStyleSheet = <S
|
4
|
-
if (typeof styles === 'function') {
|
5
|
-
return styles as X
|
6
|
-
}
|
7
|
-
|
8
|
-
return styles as S
|
9
|
-
}
|
3
|
+
export const createStyleSheet = <S extends StyleSheetWithSuperPowers>(stylesheet: S): S => stylesheet
|
package/src/global.ts
CHANGED
package/src/hooks/index.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { NativeEventEmitter, NativeModules } from 'react-native'
|
2
2
|
import { useEffect, useState } from 'react'
|
3
3
|
import { unistyles } from '../core'
|
4
|
-
import {
|
4
|
+
import { UnistylesEventType } from '../common'
|
5
5
|
import type { UnistylesEvents, UnistylesMobileLayoutEvent, UnistylesThemeEvent } from '../types'
|
6
6
|
|
7
7
|
const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles)
|
@@ -23,24 +23,21 @@ export const useUnistyles = () => {
|
|
23
23
|
'onChange',
|
24
24
|
(event: UnistylesEvents) => {
|
25
25
|
switch (event.type) {
|
26
|
-
case
|
26
|
+
case UnistylesEventType.Theme: {
|
27
27
|
const themeEvent = event as UnistylesThemeEvent
|
28
28
|
|
29
29
|
return setTheme(unistyles.registry.getTheme(themeEvent.payload.themeName))
|
30
30
|
}
|
31
|
-
case
|
31
|
+
case UnistylesEventType.Layout: {
|
32
32
|
const layoutEvent = event as UnistylesMobileLayoutEvent
|
33
33
|
|
34
34
|
return setLayout({
|
35
35
|
breakpoint: layoutEvent.payload.breakpoint,
|
36
36
|
orientation: layoutEvent.payload.orientation,
|
37
|
-
screenSize:
|
38
|
-
width: layoutEvent.payload.screen.width,
|
39
|
-
height: layoutEvent.payload.screen.height
|
40
|
-
}
|
37
|
+
screenSize: layoutEvent.payload.screen
|
41
38
|
})
|
42
39
|
}
|
43
|
-
case
|
40
|
+
case UnistylesEventType.Plugin: {
|
44
41
|
return setPlugins(unistyles.runtime.enabledPlugins)
|
45
42
|
}
|
46
43
|
default:
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { useRef } from 'react'
|
2
|
+
import type { Optional } from '../types'
|
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
|
+
export const useVariants = (variantsMap?: Record<string, Optional<string>>) => {
|
16
|
+
const variantsRef = useRef<Optional<Record<string, Optional<string>>>>(variantsMap)
|
17
|
+
|
18
|
+
if (!compareVariants(variantsRef.current, variantsMap)) {
|
19
|
+
variantsRef.current = variantsMap
|
20
|
+
}
|
21
|
+
|
22
|
+
return variantsRef.current
|
23
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// based on react-native-web normalizer
|
2
2
|
// https://github.com/necolas/react-native-web
|
3
3
|
import normalizeColors from '@react-native/normalize-colors'
|
4
|
-
import type { TextShadow, Transforms, BoxShadow } from '../../types'
|
4
|
+
import type { TextShadow, Transforms, BoxShadow, Nullable } from '../../types'
|
5
5
|
|
6
6
|
type Preprocessor = {
|
7
7
|
createTextShadowValue(style: TextShadow): string,
|
@@ -15,9 +15,9 @@ export const normalizeColor = (color: string, opacity: number = 1) => {
|
|
15
15
|
return color
|
16
16
|
}
|
17
17
|
|
18
|
-
const integer = normalizeColors(color) as number
|
18
|
+
const integer = normalizeColors(color) as Nullable<number>
|
19
19
|
|
20
|
-
// If the
|
20
|
+
// If the color is an unknown format, the return value is null
|
21
21
|
if (integer === null) {
|
22
22
|
return color
|
23
23
|
}
|
@@ -1,17 +1,15 @@
|
|
1
|
-
import type { RNStyle } from '../types'
|
2
|
-
import {
|
3
|
-
import { isWeb } from '../common'
|
4
|
-
import { unistyles } from '../core'
|
1
|
+
import type { RNStyle, UnistylesPlugin } from '../types'
|
2
|
+
import type { UnistylesRuntime } from '../core'
|
5
3
|
|
6
|
-
const
|
7
|
-
|
8
|
-
:
|
4
|
+
export const withPlugins = (
|
5
|
+
key: string,
|
6
|
+
style: RNStyle,
|
7
|
+
plugins: Array<UnistylesPlugin>,
|
8
|
+
runtime: UnistylesRuntime
|
9
|
+
) => plugins.reduce((acc, plugin) => {
|
10
|
+
if (plugin.onParsedStyle) {
|
11
|
+
return plugin.onParsedStyle(key, acc, runtime)
|
12
|
+
}
|
9
13
|
|
10
|
-
|
11
|
-
|
12
|
-
if (plugin.onParsedStyle) {
|
13
|
-
return plugin.onParsedStyle(key, acc, unistyles.runtime)
|
14
|
-
}
|
15
|
-
|
16
|
-
return acc
|
17
|
-
}, style)
|
14
|
+
return acc
|
15
|
+
}, style)
|
package/src/types/breakpoints.ts
CHANGED
@@ -1,34 +1,55 @@
|
|
1
|
-
import type { OpaqueColorValue } from 'react-native'
|
2
|
-
import type {
|
3
|
-
import type {
|
1
|
+
import type { ColorValue, OpaqueColorValue } from 'react-native'
|
2
|
+
import type { UnistylesTheme } from '../types'
|
3
|
+
import type { AllAvailableKeys, BreakpointsOrMediaQueries } from './stylesheet'
|
4
4
|
|
5
5
|
type WithEmptyObject<V> = keyof V extends never ? {} : V
|
6
6
|
|
7
|
-
type ExtractBreakpoints<T> = T extends Partial<Record<
|
8
|
-
? WithEmptyObject<
|
9
|
-
:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
type ExtractBreakpoints<T> = T extends Partial<Record<BreakpointsOrMediaQueries, infer R>>
|
8
|
+
? WithEmptyObject<R>
|
9
|
+
: {
|
10
|
+
[K in keyof T]: T[K] extends object
|
11
|
+
? T[K] extends OpaqueColorValue
|
12
|
+
? ColorValue
|
13
|
+
: ExtractBreakpoints<T[K]>
|
14
|
+
: T[K]
|
15
|
+
}
|
16
|
+
|
17
|
+
type ParseNestedObject<T> = T extends (...args: infer A) => infer R
|
18
|
+
? (...args: A) => ParseNestedObject<R>
|
19
|
+
: keyof T extends AllAvailableKeys
|
20
|
+
? ExtractBreakpoints<T>
|
21
|
+
: T extends { variants: infer R }
|
22
|
+
? ParseVariants<FlattenVariants<R>> & ParseNestedObject<Omit<T, 'variants'>>
|
23
|
+
: {
|
24
|
+
[K in keyof T]: T[K] extends object
|
25
|
+
? T[K] extends OpaqueColorValue
|
26
|
+
? ColorValue
|
27
|
+
: ExtractBreakpoints<T[K]>
|
16
28
|
: T[K]
|
17
|
-
|
29
|
+
}
|
18
30
|
|
19
|
-
type
|
20
|
-
|
31
|
+
type FlattenVariants<T> = T extends object
|
32
|
+
? {
|
33
|
+
[K in keyof T]: T[K] extends object
|
34
|
+
? {
|
35
|
+
[key in keyof T[K]]: T[K][key] extends object
|
36
|
+
? ParseNestedObject<T[K][key]>
|
37
|
+
: never
|
38
|
+
}
|
39
|
+
: never
|
40
|
+
}
|
41
|
+
: never
|
21
42
|
|
22
|
-
type
|
23
|
-
?
|
24
|
-
|
25
|
-
? T extends OpaqueColorValue
|
26
|
-
? string
|
27
|
-
: T extends Record<string, infer _V>
|
28
|
-
? T extends { variants: infer _V }
|
29
|
-
? Omit<T, 'variants'> & UnionToIntersection<_V[keyof _V]>
|
30
|
-
: { [K in keyof T as K extends MediaQuery ? keyof UnistylesBreakpoints & string : K]: RemoveKeysWithPrefix<T[K]> }
|
31
|
-
: { [K in keyof T]: RemoveKeysWithPrefix<T[K]> }
|
43
|
+
type ParseVariants<T> = T extends object
|
44
|
+
? T[keyof T] extends object
|
45
|
+
? ParseVariants<T[keyof T]>
|
32
46
|
: T
|
47
|
+
: T
|
48
|
+
|
49
|
+
type ParseStyleKeys<T> = T extends object
|
50
|
+
? { [K in keyof T]: ParseNestedObject<T[K]> }
|
51
|
+
: never
|
33
52
|
|
34
|
-
export type ReactNativeStyleSheet<T> =
|
53
|
+
export type ReactNativeStyleSheet<T> = T extends (theme: UnistylesTheme) => infer R
|
54
|
+
? ParseStyleKeys<R>
|
55
|
+
: ParseStyleKeys<T>
|
package/src/types/core.ts
CHANGED
@@ -17,17 +17,12 @@ import type { ImageStyle, TextStyle, ViewStyle } from 'react-native'
|
|
17
17
|
import type { UnistylesBreakpoints, UnistylesThemes } from '../global'
|
18
18
|
import type { MediaQuery } from './mq'
|
19
19
|
|
20
|
-
type ShadowOffset = {
|
20
|
+
export type ShadowOffset = {
|
21
21
|
width: number,
|
22
22
|
height: number
|
23
23
|
}
|
24
24
|
|
25
|
-
export type
|
26
|
-
width: number,
|
27
|
-
height: number
|
28
|
-
}
|
29
|
-
|
30
|
-
type TransformStyles =
|
25
|
+
export type TransformStyles =
|
31
26
|
& PerpectiveTransform
|
32
27
|
& RotateTransform
|
33
28
|
& RotateXTransform
|
@@ -42,40 +37,9 @@ type TransformStyles =
|
|
42
37
|
& SkewYTransform
|
43
38
|
& MatrixTransform
|
44
39
|
|
45
|
-
type
|
46
|
-
|
47
|
-
|
48
|
-
transform?: Array<DeepUniStyle<TransformStyles>>,
|
49
|
-
variants?: Record<string, UnistyleView | UnistyleText | UnistyleImage & Omit<UnistyleNested, 'variants'>>
|
50
|
-
}
|
51
|
-
|
52
|
-
type UniStyle<V> = {
|
53
|
-
[innerKey in keyof UnistylesBreakpoints]?: V
|
54
|
-
} | {
|
55
|
-
[innerKey in MediaQuery]: V
|
56
|
-
}
|
57
|
-
|
58
|
-
type DeepUniStyle<T> = {
|
59
|
-
[K in keyof T]?: UniStyle<T[K]> | T[K]
|
60
|
-
}
|
61
|
-
|
62
|
-
// these props are treated differently to nest breakpoints and media queries
|
63
|
-
type NestedTypes = 'shadowOffset' | 'transform' | 'textShadowOffset'
|
64
|
-
|
65
|
-
type UnistyleView = DeepUniStyle<Omit<ViewStyle, NestedTypes>>
|
66
|
-
type UnistyleText = DeepUniStyle<Omit<TextStyle, NestedTypes>>
|
67
|
-
type UnistyleImage = DeepUniStyle<Omit<ImageStyle, NestedTypes>>
|
68
|
-
|
69
|
-
export type StaticStyles =
|
70
|
-
| UnistyleView
|
71
|
-
| UnistyleText
|
72
|
-
| UnistyleImage
|
73
|
-
& UnistyleNested
|
74
|
-
|
75
|
-
export type CustomNamedStyles<T> = {
|
76
|
-
[K in keyof T]: T[K] extends (...args: infer A) => StaticStyles
|
77
|
-
? (...args: A) => StaticStyles
|
78
|
-
: StaticStyles
|
40
|
+
export type ScreenSize = {
|
41
|
+
width: number,
|
42
|
+
height: number
|
79
43
|
}
|
80
44
|
|
81
45
|
export type RNStyle = ViewStyle | TextStyle | ImageStyle
|
@@ -83,4 +47,4 @@ export type RNValue = number | string | undefined
|
|
83
47
|
export type NestedStyle = Record<keyof UnistylesBreakpoints | MediaQuery, RNValue>
|
84
48
|
export type NestedStylePairs = Array<[keyof UnistylesBreakpoints | MediaQuery, RNValue]>
|
85
49
|
export type UnistylesTheme = UnistylesThemes[keyof UnistylesThemes]
|
86
|
-
export type CreateStylesFactory<ST
|
50
|
+
export type CreateStylesFactory<ST> = (theme: UnistylesTheme) => ST
|