react-native-unistyles 2.0.0-alpha.14 → 2.0.0-alpha.16
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/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/types/{mq.js → stylesheet.js} +1 -1
- package/lib/commonjs/types/{mq.js.map → stylesheet.js.map} +1 -1
- package/lib/commonjs/useStyles.js +5 -4
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/index.js +0 -6
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mq.js +36 -68
- package/lib/commonjs/utils/mq.js.map +1 -1
- package/lib/commonjs/utils/styles.js +14 -8
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/commonjs/utils/variants.js +33 -13
- 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/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/types/stylesheet.js +2 -0
- package/lib/module/types/{mq.js.map → stylesheet.js.map} +1 -1
- package/lib/module/useStyles.js +6 -5
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/index.js +1 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mq.js +35 -67
- package/lib/module/utils/mq.js.map +1 -1
- package/lib/module/utils/styles.js +15 -9
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/module/utils/variants.js +31 -11
- 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/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/types/breakpoints.d.ts +24 -15
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +5 -29
- 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 +40 -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 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mq.d.ts +15 -14
- package/lib/typescript/src/utils/mq.d.ts.map +1 -1
- package/lib/typescript/src/utils/styles.d.ts +3 -3
- 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 +15 -15
- package/src/common.ts +10 -10
- 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/types/breakpoints.ts +51 -27
- package/src/types/core.ts +8 -45
- package/src/types/index.ts +1 -2
- package/src/types/stylesheet.ts +49 -0
- package/src/types/unistyles.ts +5 -6
- package/src/types/variants.ts +17 -9
- package/src/useStyles.ts +15 -15
- package/src/utils/index.ts +1 -1
- package/src/utils/mq.ts +31 -84
- package/src/utils/styles.ts +18 -17
- package/src/utils/variants.ts +41 -17
- package/lib/module/types/mq.js +0 -2
- package/lib/typescript/src/types/mq.d.ts +0 -3
- package/lib/typescript/src/types/mq.d.ts.map +0 -1
- package/src/types/mq.ts +0 -3
@@ -1,3 +1,3 @@
|
|
1
|
-
import type {
|
2
|
-
export declare const createStyleSheet: <S
|
1
|
+
import type { StyleSheetWithSuperPowers } from './types';
|
2
|
+
export declare const createStyleSheet: <S extends StyleSheetWithSuperPowers>(stylesheet: S) => S;
|
3
3
|
//# sourceMappingURL=createStyleSheet.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createStyleSheet.d.ts","sourceRoot":"","sources":["../../../src/createStyleSheet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"createStyleSheet.d.ts","sourceRoot":"","sources":["../../../src/createStyleSheet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAExD,eAAO,MAAM,gBAAgB,2DAAwE,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../src/global.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;CAAG;AACnC,MAAM,WAAW,oBAAoB;
|
1
|
+
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../src/global.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;CAAG;AACnC,MAAM,WAAW,oBAAoB;IAEjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useUnistyles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useUnistyles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY;;;;;;;;;;;CAgDxB,CAAA"}
|
@@ -0,0 +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;AAaxC,eAAO,MAAM,WAAW,iBAAkB,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,+CAQzE,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/normalizer/normalizer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,
|
1
|
+
{"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/normalizer/normalizer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAY,MAAM,aAAa,CAAA;AAE9E,KAAK,YAAY,GAAG;IAChB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAAC;IACjD,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;IACzD,oBAAoB,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;CAClE,CAAA;AAED,eAAO,MAAM,cAAc,UAAW,MAAM,YAAW,MAAM,WAyB5D,CAAA;AAED,eAAO,MAAM,qBAAqB,UAAW,MAAM,oBAAiC,CAAA;AAwDpF,eAAO,MAAM,YAAY,EAAE,YAI1B,CAAA"}
|
@@ -1,18 +1,27 @@
|
|
1
|
-
import type { OpaqueColorValue } from 'react-native';
|
2
|
-
import type {
|
3
|
-
import type {
|
4
|
-
type
|
5
|
-
type
|
6
|
-
[K in keyof T]:
|
7
|
-
};
|
8
|
-
type
|
9
|
-
|
10
|
-
variants: infer _V;
|
11
|
-
} ? Omit<T, 'variants'> & UnionToIntersection<_V[keyof _V]> : {
|
12
|
-
[K in keyof T as K extends MediaQuery ? keyof UnistylesBreakpoints & string : K]: RemoveKeysWithPrefix<T[K]>;
|
13
|
-
} : {
|
14
|
-
[K in keyof T]: RemoveKeysWithPrefix<T[K]>;
|
1
|
+
import type { ColorValue, OpaqueColorValue } from 'react-native';
|
2
|
+
import type { UnistylesTheme } from '../types';
|
3
|
+
import type { BreakpointsOrMediaQueries, ToDeepUnistyles } from './stylesheet';
|
4
|
+
import type { TransformStyles } from './core';
|
5
|
+
type ExtractTransformArray<T> = T extends object ? {
|
6
|
+
[K in keyof T]: ExtractBreakpoints<T[K]>;
|
7
|
+
} : never;
|
8
|
+
type ExtractBreakpoints<T> = T extends object ? keyof T extends BreakpointsOrMediaQueries ? T[keyof T] : T extends Array<ToDeepUnistyles<TransformStyles>> ? Array<ExtractTransformArray<T[number]>> : {
|
9
|
+
[K in keyof T]: ExtractBreakpoints<T[K]>;
|
15
10
|
} : T;
|
16
|
-
|
11
|
+
type ParseNestedObject<T> = T extends (...args: infer A) => infer R ? (...args: A) => ParseNestedObject<R> : T extends object ? T extends {
|
12
|
+
variants: infer R;
|
13
|
+
} ? ParseVariants<FlattenVariants<R>> & ParseNestedObject<Omit<T, 'variants'>> : {
|
14
|
+
[K in keyof T]: T[K] extends object ? T[K] extends OpaqueColorValue ? ColorValue : ExtractBreakpoints<T[K]> : T[K];
|
15
|
+
} : T;
|
16
|
+
type FlattenVariants<T> = T extends object ? {
|
17
|
+
[K in keyof T]: T[K] extends object ? {
|
18
|
+
[key in keyof T[K]]: T[K][key] extends object ? ParseNestedObject<T[K][key]> : never;
|
19
|
+
} : never;
|
20
|
+
} : never;
|
21
|
+
type ParseVariants<T> = T extends object ? T[keyof T] extends object ? ParseVariants<T[keyof T]> : T : T;
|
22
|
+
type ParseStyleKeys<T> = T extends object ? {
|
23
|
+
[K in keyof T]: ParseNestedObject<T[K]>;
|
24
|
+
} : never;
|
25
|
+
export type ReactNativeStyleSheet<T> = T extends (theme: UnistylesTheme) => infer R ? ParseStyleKeys<R> : ParseStyleKeys<T>;
|
17
26
|
export {};
|
18
27
|
//# sourceMappingURL=breakpoints.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../../../src/types/breakpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;
|
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,IAAI,CAAC,SAAS,MAAM,GAC1C;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC5C,KAAK,CAAA;AAEX,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GACvC,MAAM,CAAC,SAAS,yBAAyB,GACrC,CAAC,CAAC,MAAM,CAAC,CAAC,GACV,CAAC,SAAS,KAAK,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,GAC7C,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GACvC;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3C,GACP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;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"}
|
@@ -1,43 +1,19 @@
|
|
1
1
|
import type { MatrixTransform, PerpectiveTransform, RotateTransform, RotateXTransform, RotateYTransform, RotateZTransform, ScaleTransform, ScaleXTransform, ScaleYTransform, SkewXTransform, SkewYTransform, TranslateXTransform, TranslateYTransform } from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
|
2
2
|
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
3
3
|
import type { UnistylesBreakpoints, UnistylesThemes } from '../global';
|
4
|
-
|
5
|
-
type ShadowOffset = {
|
4
|
+
export type ShadowOffset = {
|
6
5
|
width: number;
|
7
6
|
height: number;
|
8
7
|
};
|
8
|
+
export type TransformStyles = PerpectiveTransform & RotateTransform & RotateXTransform & RotateYTransform & RotateZTransform & ScaleTransform & ScaleXTransform & ScaleYTransform & TranslateXTransform & TranslateYTransform & SkewXTransform & SkewYTransform & MatrixTransform;
|
9
9
|
export type ScreenSize = {
|
10
10
|
width: number;
|
11
11
|
height: number;
|
12
12
|
};
|
13
|
-
type TransformStyles = PerpectiveTransform & RotateTransform & RotateXTransform & RotateYTransform & RotateZTransform & ScaleTransform & ScaleXTransform & ScaleYTransform & TranslateXTransform & TranslateYTransform & SkewXTransform & SkewYTransform & MatrixTransform;
|
14
|
-
type UnistyleNested = {
|
15
|
-
shadowOffset?: DeepUniStyle<ShadowOffset>;
|
16
|
-
textShadowOffset?: DeepUniStyle<ShadowOffset>;
|
17
|
-
transform?: Array<DeepUniStyle<TransformStyles>>;
|
18
|
-
variants?: Record<string, UnistyleView | UnistyleText | UnistyleImage & Omit<UnistyleNested, 'variants'>>;
|
19
|
-
};
|
20
|
-
type UniStyle<V> = {
|
21
|
-
[innerKey in keyof UnistylesBreakpoints]?: V;
|
22
|
-
} | {
|
23
|
-
[innerKey in MediaQuery]: V;
|
24
|
-
};
|
25
|
-
type DeepUniStyle<T> = {
|
26
|
-
[K in keyof T]?: UniStyle<T[K]> | T[K];
|
27
|
-
};
|
28
|
-
type NestedTypes = 'shadowOffset' | 'transform' | 'textShadowOffset';
|
29
|
-
type UnistyleView = DeepUniStyle<Omit<ViewStyle, NestedTypes>>;
|
30
|
-
type UnistyleText = DeepUniStyle<Omit<TextStyle, NestedTypes>>;
|
31
|
-
type UnistyleImage = DeepUniStyle<Omit<ImageStyle, NestedTypes>>;
|
32
|
-
export type StaticStyles = UnistyleView | UnistyleText | UnistyleImage & UnistyleNested;
|
33
|
-
export type CustomNamedStyles<T> = {
|
34
|
-
[K in keyof T]: T[K] extends (...args: infer A) => StaticStyles ? (...args: A) => StaticStyles : StaticStyles;
|
35
|
-
};
|
36
13
|
export type RNStyle = ViewStyle | TextStyle | ImageStyle;
|
37
14
|
export type RNValue = number | string | undefined;
|
38
|
-
export type NestedStyle = Record<keyof UnistylesBreakpoints |
|
39
|
-
export type NestedStylePairs = Array<[keyof UnistylesBreakpoints |
|
15
|
+
export type NestedStyle = Record<keyof UnistylesBreakpoints | symbol, RNValue>;
|
16
|
+
export type NestedStylePairs = Array<[keyof UnistylesBreakpoints | symbol, RNValue]>;
|
40
17
|
export type UnistylesTheme = UnistylesThemes[keyof UnistylesThemes];
|
41
|
-
export type CreateStylesFactory<ST
|
42
|
-
export {};
|
18
|
+
export type CreateStylesFactory<ST> = (theme: UnistylesTheme) => ST;
|
43
19
|
//# 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;
|
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,SAAS,CAAA;AACjD,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;AACnE,MAAM,MAAM,mBAAmB,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,cAAc,KAAK,EAAE,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 {
|
5
|
-
export type {
|
4
|
+
export type { NestedStylePairs, UnistylesTheme, CreateStylesFactory, ScreenSize, NestedStyle, RNValue, RNStyle } from './core';
|
5
|
+
export type { StyleSheetWithSuperPowers, StyleSheet } 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,
|
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,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACV,MAAM,QAAQ,CAAA;AACf,YAAY,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzE,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC1D,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA"}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
2
|
+
import type { ShadowOffset, TransformStyles, UnistylesTheme } from './core';
|
3
|
+
import type { UnistylesBreakpoints } from '../global';
|
4
|
+
type NestedTypes = 'shadowOffset' | 'transform' | 'textShadowOffset';
|
5
|
+
type UnistyleView = Omit<ViewStyle, NestedTypes>;
|
6
|
+
type UnistyleText = Omit<TextStyle, NestedTypes>;
|
7
|
+
type UnistyleImage = Omit<ImageStyle, NestedTypes>;
|
8
|
+
type UnistyleNestedStyles = {
|
9
|
+
shadowOffset?: ToDeepUnistyles<ShadowOffset>;
|
10
|
+
textShadowOffset?: ToDeepUnistyles<ShadowOffset>;
|
11
|
+
transform?: Array<ToDeepUnistyles<TransformStyles>>;
|
12
|
+
};
|
13
|
+
type Variants = {
|
14
|
+
variants?: {
|
15
|
+
[variantName: string]: {
|
16
|
+
[variant: string]: Omit<UnistylesValues, 'variants'>;
|
17
|
+
};
|
18
|
+
};
|
19
|
+
};
|
20
|
+
export type ToDeepUnistyles<T> = {
|
21
|
+
[K in keyof T]?: T[K] | {
|
22
|
+
[key in BreakpointsOrMediaQueries]?: T[K];
|
23
|
+
};
|
24
|
+
};
|
25
|
+
type AllAvailableStyles = UnistyleView & UnistyleText & UnistyleImage & UnistyleNestedStyles;
|
26
|
+
export type AllAvailableKeys = keyof (UnistyleView & UnistyleText & UnistyleImage);
|
27
|
+
export type BreakpointsOrMediaQueries = keyof UnistylesBreakpoints | symbol;
|
28
|
+
export type UnistylesValues = {
|
29
|
+
[propName in AllAvailableKeys]?: AllAvailableStyles[propName] | {
|
30
|
+
[key in BreakpointsOrMediaQueries]?: AllAvailableStyles[propName];
|
31
|
+
};
|
32
|
+
} & Variants & {
|
33
|
+
[propName in NestedTypes]?: UnistyleNestedStyles[propName];
|
34
|
+
};
|
35
|
+
export type StyleSheet = {
|
36
|
+
[styleName: string]: UnistylesValues | ((...args: any) => UnistylesValues);
|
37
|
+
};
|
38
|
+
export type StyleSheetWithSuperPowers = ((theme: UnistylesTheme) => StyleSheet) | StyleSheet;
|
39
|
+
export {};
|
40
|
+
//# sourceMappingURL=stylesheet.d.ts.map
|
@@ -0,0 +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,WAAW,GAAG,cAAc,GAAG,WAAW,GAAG,kBAAkB,CAAA;AAEpE,KAAK,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAChD,KAAK,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAChD,KAAK,aAAa,GAAG,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA;AAElD,KAAK,oBAAoB,GAAG;IACxB,YAAY,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IAC7C,gBAAgB,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IACjD,SAAS,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAAA;CACtD,CAAA;AAED,KAAK,QAAQ,GAAG;I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../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,eA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AAK,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,4 +1,4 @@
|
|
1
|
-
export { mq
|
1
|
+
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';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,
|
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,21 +1,22 @@
|
|
1
|
-
import type {
|
1
|
+
import type { Nullable } from '../types';
|
2
2
|
import type { UnistylesBreakpoints } from '../global';
|
3
|
-
export declare const MQSymbol: unique symbol;
|
4
3
|
type MQValue = keyof UnistylesBreakpoints | number;
|
5
4
|
type MQHandler = {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
only: {
|
6
|
+
width(wMin?: Nullable<MQValue>, wMax?: MQValue): symbol;
|
7
|
+
height(hMin?: Nullable<MQValue>, hMax?: MQValue): symbol;
|
8
|
+
};
|
9
|
+
width(wMin?: Nullable<MQValue>, wMax?: MQValue): {
|
10
|
+
and: {
|
11
|
+
height(hMin?: Nullable<MQValue>, hMax?: MQValue): symbol;
|
12
|
+
};
|
13
|
+
};
|
14
|
+
height(hMin?: Nullable<MQValue>, hMax?: MQValue): {
|
15
|
+
and: {
|
16
|
+
width(wMin?: Nullable<MQValue>, wMax?: MQValue): symbol;
|
17
|
+
};
|
18
|
+
};
|
10
19
|
};
|
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
20
|
export declare const mq: MQHandler;
|
20
21
|
export {};
|
21
22
|
//# 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,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,MAAM,CAAC;QACxD,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;KAC5D,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,MAAM,CAAA;SAC3D,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,MAAM,CAAA;SAC1D,CAAA;KACJ,CAAA;CACJ,CAAA;AAcD,eAAO,MAAM,EAAE,EAAE,SAiBhB,CAAA"}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type {
|
1
|
+
import type { UnistylesPlugin, StyleSheet, Optional } from '../types';
|
2
2
|
import type { UnistylesRuntime } from '../core';
|
3
|
-
export declare const proxifyFunction: (key: string, fn: Function, plugins: Array<UnistylesPlugin>, runtime: UnistylesRuntime, variant?: string) => Function;
|
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 {
|
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,
|
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.16",
|
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,12 +77,12 @@
|
|
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": "
|
85
|
-
"typescript": "5.
|
84
|
+
"release-it": "17.0.0",
|
85
|
+
"typescript": "5.3.2"
|
86
86
|
},
|
87
87
|
"peerDependencies": {
|
88
88
|
"@react-native/normalize-colors": "*",
|
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
|
}
|
@@ -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:
|