react-native-unistyles 2.0.0-alpha.9 → 2.0.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +28 -0
- package/android/build.gradle +40 -0
- package/android/src/main/cxx/cpp-adapter.cpp +108 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +159 -0
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +18 -0
- package/cxx/UnistylesRuntime.cpp +55 -2
- package/cxx/UnistylesRuntime.h +15 -9
- package/ios/UnistylesModule.mm +12 -2
- package/lib/commonjs/common.js +30 -16
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistyleRegistry.js +65 -3
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/core/UnistylesRuntime.js +15 -16
- 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 +11 -8
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
- package/lib/commonjs/hooks/useVariants.js +14 -0
- package/lib/commonjs/hooks/useVariants.js.map +1 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugins/index.js +38 -0
- package/lib/commonjs/plugins/index.js.map +1 -0
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +12 -0
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -0
- package/lib/commonjs/plugins/normalizer/index.js +32 -0
- package/lib/commonjs/plugins/normalizer/index.js.map +1 -0
- package/lib/commonjs/plugins/normalizer/module.d.js.map +1 -0
- package/lib/commonjs/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +5 -5
- package/lib/commonjs/plugins/normalizer/normalizeStyle.js.map +1 -0
- package/lib/commonjs/{utils → plugins/normalizer}/normalizer.js +1 -1
- package/lib/commonjs/plugins/normalizer/normalizer.js.map +1 -0
- package/lib/commonjs/types/{mq.js → plugin.js} +1 -1
- package/lib/commonjs/types/{mq.js.map → plugin.js.map} +1 -1
- package/lib/commonjs/types/stylesheet.js +6 -0
- package/lib/commonjs/types/stylesheet.js.map +1 -0
- package/lib/commonjs/types/variants.js +2 -0
- package/lib/commonjs/{utils/module.d.js.map → types/variants.js.map} +1 -1
- package/lib/commonjs/useStyles.js +10 -20
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js +13 -59
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/index.js +13 -51
- 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/mqParser.js +4 -1
- package/lib/commonjs/utils/mqParser.js.map +1 -1
- package/lib/commonjs/utils/styles.js +35 -20
- 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 +28 -17
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistyleRegistry.js +65 -3
- package/lib/module/core/UnistyleRegistry.js.map +1 -1
- package/lib/module/core/UnistylesRuntime.js +15 -16
- 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 +12 -9
- package/lib/module/hooks/useUnistyles.js.map +1 -1
- package/lib/module/hooks/useVariants.js +7 -0
- package/lib/module/hooks/useVariants.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugins/index.js +3 -0
- package/lib/module/plugins/index.js.map +1 -0
- package/lib/module/plugins/normalizeWebStylesPlugin.js +6 -0
- package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -0
- package/lib/module/plugins/normalizer/index.js +3 -0
- package/lib/module/plugins/normalizer/index.js.map +1 -0
- package/lib/module/plugins/normalizer/module.d.js.map +1 -0
- package/lib/module/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +3 -3
- package/lib/module/plugins/normalizer/normalizeStyle.js.map +1 -0
- package/lib/module/{utils → plugins/normalizer}/normalizer.js +1 -1
- package/lib/module/plugins/normalizer/normalizer.js.map +1 -0
- package/lib/module/types/plugin.js +2 -0
- package/lib/module/types/{mq.js.map → plugin.js.map} +1 -1
- package/lib/module/types/stylesheet.js +2 -0
- package/lib/module/types/stylesheet.js.map +1 -0
- package/lib/module/types/variants.js +2 -0
- package/lib/module/{utils/module.d.js.map → types/variants.js.map} +1 -1
- package/lib/module/useStyles.js +12 -22
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/breakpoints.js +12 -56
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/index.js +4 -6
- 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/mqParser.js +3 -3
- package/lib/module/utils/mqParser.js.map +1 -1
- package/lib/module/utils/styles.js +35 -20
- 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 +23 -12
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistyleRegistry.d.ts +45 -4
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +8 -9
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
- package/lib/typescript/src/core/index.d.ts +1 -0
- package/lib/typescript/src/core/index.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 +2 -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/index.d.ts +51 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugins/index.d.ts +3 -0
- package/lib/typescript/src/plugins/index.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +3 -0
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizer/index.d.ts +3 -0
- package/lib/typescript/src/plugins/normalizer/index.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts +3 -0
- package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts.map +1 -0
- package/lib/typescript/src/{utils → plugins/normalizer}/normalizer.d.ts +1 -1
- package/lib/typescript/src/plugins/normalizer/normalizer.d.ts.map +1 -0
- package/lib/typescript/src/types/breakpoints.d.ts +25 -12
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +6 -27
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +4 -2
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/plugin.d.ts +7 -0
- package/lib/typescript/src/types/plugin.d.ts.map +1 -0
- 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 +16 -11
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
- package/lib/typescript/src/types/variants.d.ts +14 -0
- package/lib/typescript/src/types/variants.d.ts.map +1 -0
- package/lib/typescript/src/useStyles.d.ts +3 -3
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/breakpoints.d.ts +2 -5
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +4 -6
- 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/mqParser.d.ts +14 -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 +19 -16
- package/src/__tests__/mocks.ts +24 -0
- package/src/common.ts +30 -14
- package/src/core/UnistyleRegistry.ts +66 -4
- package/src/core/UnistylesRuntime.ts +18 -20
- package/src/core/index.ts +1 -0
- package/src/createStyleSheet.ts +2 -8
- package/src/global.ts +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useUnistyles.ts +11 -9
- package/src/hooks/useVariants.ts +10 -0
- package/src/index.ts +3 -1
- package/src/plugins/index.ts +2 -0
- package/src/plugins/normalizeWebStylesPlugin.ts +7 -0
- package/src/plugins/normalizer/index.ts +2 -0
- package/src/{utils/normalizeStyles.web.ts → plugins/normalizer/normalizeStyle.ts} +3 -3
- package/src/{utils → plugins/normalizer}/normalizer.ts +3 -3
- package/src/types/breakpoints.ts +57 -25
- package/src/types/core.ts +9 -43
- package/src/types/index.ts +11 -2
- package/src/types/plugin.ts +7 -0
- package/src/types/stylesheet.ts +49 -0
- package/src/types/unistyles.ts +18 -13
- package/src/types/variants.ts +19 -0
- package/src/useStyles.ts +18 -25
- package/src/utils/breakpoints.ts +11 -67
- package/src/utils/index.ts +4 -6
- package/src/utils/mq.ts +31 -84
- package/src/utils/mqParser.ts +5 -5
- package/src/utils/styles.ts +44 -50
- package/src/utils/withPlugins.ts +13 -0
- package/lib/commonjs/utils/common.js +0 -25
- package/lib/commonjs/utils/common.js.map +0 -1
- package/lib/commonjs/utils/normalizeStyles.js +0 -10
- package/lib/commonjs/utils/normalizeStyles.js.map +0 -1
- package/lib/commonjs/utils/normalizeStyles.web.js.map +0 -1
- package/lib/commonjs/utils/normalizer.js.map +0 -1
- package/lib/module/types/mq.js +0 -2
- package/lib/module/utils/common.js +0 -17
- package/lib/module/utils/common.js.map +0 -1
- package/lib/module/utils/normalizeStyles.js +0 -3
- package/lib/module/utils/normalizeStyles.js.map +0 -1
- package/lib/module/utils/normalizeStyles.web.js.map +0 -1
- package/lib/module/utils/normalizer.js.map +0 -1
- package/lib/typescript/src/types/mq.d.ts +0 -3
- package/lib/typescript/src/types/mq.d.ts.map +0 -1
- package/lib/typescript/src/utils/common.d.ts +0 -12
- package/lib/typescript/src/utils/common.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizeStyles.d.ts +0 -2
- package/lib/typescript/src/utils/normalizeStyles.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts +0 -5
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizer.d.ts.map +0 -1
- package/src/types/mq.ts +0 -3
- package/src/utils/common.ts +0 -20
- package/src/utils/normalizeStyles.ts +0 -2
- /package/lib/commonjs/{utils → plugins/normalizer}/module.d.js +0 -0
- /package/lib/module/{utils → plugins/normalizer}/module.d.js +0 -0
- /package/src/{utils → plugins/normalizer}/module.d.ts +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/normalizer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"normalizeStyle.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/normalizer/normalizeStyle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoE,OAAO,EAAE,MAAM,aAAa,CAAA;AAuD5G,eAAO,MAAM,cAAc,oCAwB1B,CAAA"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { TextShadow, Transforms, BoxShadow } from '
|
1
|
+
import type { TextShadow, Transforms, BoxShadow } from '../../types';
|
2
2
|
type Preprocessor = {
|
3
3
|
createTextShadowValue(style: TextShadow): string;
|
4
4
|
createBoxShadowValue(style: Required<BoxShadow>): string;
|
@@ -0,0 +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,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,15 +1,28 @@
|
|
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
|
-
[K in keyof T
|
10
|
-
} : {
|
11
|
-
[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]>;
|
12
10
|
} : T;
|
13
|
-
|
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 ? 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;
|
23
|
+
type ParseStyleKeys<T> = T extends object ? {
|
24
|
+
[K in keyof T]: ParseNestedObject<T[K]>;
|
25
|
+
} : never;
|
26
|
+
export type ReactNativeStyleSheet<T> = T extends (theme: UnistylesTheme) => infer R ? ParseStyleKeys<R> : ParseStyleKeys<T>;
|
14
27
|
export {};
|
15
28
|
//# 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,CAAC,CAAA;AAEP,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,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AM,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"}
|
@@ -1,39 +1,18 @@
|
|
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
|
14
|
-
type
|
15
|
-
|
16
|
-
|
17
|
-
transform?: Array<DeepUniStyle<TransformStyles>>;
|
18
|
-
};
|
19
|
-
type UniStyle<V> = {
|
20
|
-
[innerKey in keyof UnistylesBreakpoints]?: V;
|
21
|
-
} | {
|
22
|
-
[innerKey in MediaQuery]: V;
|
23
|
-
};
|
24
|
-
type DeepUniStyle<T> = {
|
25
|
-
[K in keyof T]?: UniStyle<T[K]> | T[K];
|
26
|
-
};
|
27
|
-
type NestedTypes = 'shadowOffset' | 'transform' | 'textShadowOffset';
|
28
|
-
type UnistyleView = DeepUniStyle<Omit<ViewStyle, NestedTypes>>;
|
29
|
-
type UnistyleText = DeepUniStyle<Omit<TextStyle, NestedTypes>>;
|
30
|
-
type UnistyleImage = DeepUniStyle<Omit<ImageStyle, NestedTypes>>;
|
31
|
-
export type StaticStyles = UnistyleView | UnistyleText | UnistyleImage & UnistyleNested;
|
32
|
-
export type CustomNamedStyles<T> = {
|
33
|
-
[K in keyof T]: T[K] extends (...args: infer A) => StaticStyles ? (...args: A) => StaticStyles : StaticStyles;
|
34
|
-
};
|
35
|
-
export type NestedKeys = Array<[keyof UnistylesBreakpoints | MediaQuery, string | number | undefined]>;
|
13
|
+
export type RNStyle = ViewStyle & TextStyle & ImageStyle;
|
14
|
+
export type RNValue = ViewStyle[keyof ViewStyle] | TextStyle[keyof TextStyle] | ImageStyle[keyof ImageStyle];
|
15
|
+
export type NestedStyle = Record<keyof UnistylesBreakpoints | symbol, RNValue>;
|
16
|
+
export type NestedStylePairs = Array<[keyof UnistylesBreakpoints | symbol, RNValue]>;
|
36
17
|
export type UnistylesTheme = UnistylesThemes[keyof UnistylesThemes];
|
37
|
-
export type CreateStylesFactory<ST, Theme> = (theme: Theme) => ST;
|
38
|
-
export {};
|
39
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,OA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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,7 +1,9 @@
|
|
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, ScreenSize, NestedStyle, RNValue, RNStyle } from './core';
|
5
|
+
export type { StyleSheetWithSuperPowers, StyleSheet, AllAvailableKeys } from './stylesheet';
|
6
6
|
export type { ReactNativeStyleSheet } from './breakpoints';
|
7
|
+
export type { ExtractVariantNames } from './variants';
|
8
|
+
export type { UnistylesPlugin } from './plugin';
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
@@ -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,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"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type { RNStyle } from './core';
|
2
|
+
import type { UnistylesRuntime } from '../core';
|
3
|
+
export type UnistylesPlugin = {
|
4
|
+
name: string;
|
5
|
+
onParsedStyle?: (styleKey: string, style: RNStyle, runtime: UnistylesRuntime) => RNStyle;
|
6
|
+
};
|
7
|
+
//# sourceMappingURL=plugin.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/types/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,MAAM,MAAM,eAAe,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAA;CAC3F,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 NestedKeys = 'shadowOffset' | 'transform' | 'textShadowOffset';
|
5
|
+
type UnistyleView = Omit<ViewStyle, NestedKeys>;
|
6
|
+
type UnistyleText = Omit<TextStyle, NestedKeys>;
|
7
|
+
type UnistyleImage = Omit<ImageStyle, NestedKeys>;
|
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 NestedKeys]?: 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,U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G,IAAI,yBAAyB,CAAC,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC;KACpE;CACJ,GAAG,QAAQ,GAAG;KACV,QAAQ,IAAI,UAAU,CAAC,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC;CAC5D,CAAA;AAED,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,14 +1,17 @@
|
|
1
|
-
import {
|
1
|
+
import { UnistylesEventType, ScreenOrientation } from '../common';
|
2
2
|
import type { UnistylesThemes, UnistylesBreakpoints } from '../global';
|
3
|
-
import type {
|
4
|
-
import type {
|
5
|
-
export type ColorSchemeName =
|
3
|
+
import type { ScreenSize } from './core';
|
4
|
+
import type { UnistylesPlugin } from './plugin';
|
5
|
+
export type ColorSchemeName = 'light' | 'dark' | 'unspecified';
|
6
6
|
export type UnistylesConfig = {
|
7
7
|
adaptiveThemes?: boolean;
|
8
|
+
experimentalPlugins?: Array<UnistylesPlugin>;
|
9
|
+
initialTheme?: keyof UnistylesThemes;
|
8
10
|
};
|
9
11
|
export type UnistylesBridge = {
|
10
12
|
screenWidth: number;
|
11
13
|
screenHeight: number;
|
14
|
+
enabledPlugins: Array<string>;
|
12
15
|
hasAdaptiveThemes: boolean;
|
13
16
|
themeName: keyof UnistylesThemes;
|
14
17
|
breakpoint: keyof UnistylesBreakpoints;
|
@@ -18,23 +21,25 @@ export type UnistylesBridge = {
|
|
18
21
|
useBreakpoints(breakpoints: UnistylesBreakpoints): void;
|
19
22
|
useTheme(name: keyof UnistylesThemes): void;
|
20
23
|
useAdaptiveThemes(enable: boolean): void;
|
24
|
+
addPlugin(pluginName: string, notify: boolean): void;
|
25
|
+
removePlugin(pluginName: string): void;
|
21
26
|
};
|
22
27
|
export type UnistylesThemeEvent = {
|
23
|
-
type:
|
28
|
+
type: UnistylesEventType.Theme;
|
24
29
|
payload: {
|
25
30
|
themeName: keyof UnistylesThemes;
|
26
31
|
};
|
27
32
|
};
|
28
33
|
export type UnistylesMobileLayoutEvent = {
|
29
|
-
type:
|
34
|
+
type: UnistylesEventType.Layout;
|
30
35
|
payload: {
|
31
36
|
screen: ScreenSize;
|
32
37
|
breakpoint: keyof UnistylesBreakpoints;
|
33
|
-
orientation: ScreenOrientation;
|
38
|
+
orientation: typeof ScreenOrientation[keyof typeof ScreenOrientation];
|
34
39
|
};
|
35
40
|
};
|
36
|
-
export type
|
37
|
-
|
38
|
-
|
39
|
-
|
41
|
+
export type UnistylesPluginEvent = {
|
42
|
+
type: UnistylesEventType.Plugin;
|
43
|
+
};
|
44
|
+
export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent;
|
40
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,C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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"}
|
@@ -0,0 +1,14 @@
|
|
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 {};
|
14
|
+
//# sourceMappingURL=variants.d.ts.map
|
@@ -0,0 +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,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, 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;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,6 +1,3 @@
|
|
1
|
-
import type {
|
2
|
-
|
3
|
-
export declare const sortAndValidateBreakpoints: (breakpoints: UnistylesBreakpoints) => UnistylesBreakpoints;
|
4
|
-
export declare const getBreakpointFromScreenWidth: (width: number, breakpointEntries: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>) => keyof UnistylesBreakpoints & string;
|
5
|
-
export declare const getValueForBreakpoint: (value: Record<keyof UnistylesBreakpoints | MediaQuery, string | number | undefined>) => string | number | undefined;
|
1
|
+
import type { Optional, RNValue } from '../types';
|
2
|
+
export declare const getValueForBreakpoint: (value: Record<string, RNValue>) => Optional<RNValue>;
|
6
3
|
//# sourceMappingURL=breakpoints.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../../../src/utils/breakpoints.ts"],"names":[],"mappings":"
|
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"}
|
@@ -1,8 +1,6 @@
|
|
1
|
-
export {
|
2
|
-
export
|
3
|
-
export {
|
4
|
-
export { getKeyForUnistylesMediaQuery } from './mqParser';
|
5
|
-
export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints';
|
1
|
+
export { mq } from './mq';
|
2
|
+
export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq } from './mqParser';
|
3
|
+
export { getValueForBreakpoint } from './breakpoints';
|
6
4
|
export { proxifyFunction, parseStyle } from './styles';
|
7
|
-
export {
|
5
|
+
export { withPlugins } from './withPlugins';
|
8
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,
|
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,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,3 +1,15 @@
|
|
1
|
-
import type {
|
2
|
-
|
1
|
+
import type { Optional, RNValue, ScreenSize } from '../types';
|
2
|
+
type ParsedMqDimension = {
|
3
|
+
from: number;
|
4
|
+
to: number;
|
5
|
+
};
|
6
|
+
type UnistylesParsedMq = {
|
7
|
+
width?: ParsedMqDimension;
|
8
|
+
height?: ParsedMqDimension;
|
9
|
+
};
|
10
|
+
export declare const parseMq: (mq: string) => UnistylesParsedMq;
|
11
|
+
export declare const isValidMq: (parsedMq: UnistylesParsedMq) => boolean;
|
12
|
+
export declare const isWithinTheWidthAndHeight: (parsedMq: UnistylesParsedMq, screenSize: ScreenSize) => boolean;
|
13
|
+
export declare const getKeyForUnistylesMediaQuery: (mediaQueries: Array<[string, RNValue]>, screenSize: ScreenSize) => Optional<string>;
|
14
|
+
export {};
|
3
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: (fn: Function, breakpoint: keyof UnistylesBreakpoints & string, screenSize: ScreenSize) => 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>(style:
|
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,EAAE,
|
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
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "2.0.0-
|
3
|
+
"version": "2.0.0-beta.1",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
@@ -9,7 +9,7 @@
|
|
9
9
|
"lint": "eslint . --ext .ts,.tsx",
|
10
10
|
"prepare": "husky install && bob build",
|
11
11
|
"precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn test'",
|
12
|
-
"release": "release-it patch --preRelease=
|
12
|
+
"release": "release-it patch --preRelease=beta --npm.tag=next"
|
13
13
|
},
|
14
14
|
"main": "lib/commonjs/index",
|
15
15
|
"module": "lib/module/index",
|
@@ -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.39",
|
60
|
+
"@typescript-eslint/eslint-plugin": "6.13.1",
|
61
|
+
"@typescript-eslint/eslint-plugin-tslint": "6.13.1",
|
62
|
+
"@typescript-eslint/parser": "6.13.1",
|
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": "*",
|
@@ -111,6 +111,9 @@
|
|
111
111
|
"<rootDir>/docs/node_modules",
|
112
112
|
"<rootDir>/lib/"
|
113
113
|
],
|
114
|
+
"testMatch": [
|
115
|
+
"**/*.spec.(ts|tsx)"
|
116
|
+
],
|
114
117
|
"coverageReporters": [
|
115
118
|
"html"
|
116
119
|
]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import type { ScreenSize } from '../types'
|
2
|
+
|
3
|
+
const TEST_BREAKPOINTS = {
|
4
|
+
xs: 0,
|
5
|
+
sm: 300,
|
6
|
+
md: 500,
|
7
|
+
lg: 750,
|
8
|
+
xl: 1000
|
9
|
+
} as const
|
10
|
+
|
11
|
+
export const mockRuntime = (screenSize: ScreenSize) => ({
|
12
|
+
breakpoint: Object.entries(TEST_BREAKPOINTS)
|
13
|
+
.reverse()
|
14
|
+
.find(([, value]) => screenSize.width >= value)?.at(0),
|
15
|
+
orientation: screenSize.width > screenSize.height
|
16
|
+
? 'landscape'
|
17
|
+
: 'portrait',
|
18
|
+
screen: screenSize
|
19
|
+
})
|
20
|
+
|
21
|
+
export const mockRegistry = () => ({
|
22
|
+
sortedBreakpointPairs: Object.entries(TEST_BREAKPOINTS),
|
23
|
+
plugins: []
|
24
|
+
})
|