react-native-unistyles 2.0.0-rc.2 → 2.0.0-rc.4
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +1 -1
- package/README.md +10 -4
- package/android/src/main/cxx/cpp-adapter.cpp +26 -2
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +29 -3
- package/cxx/UnistylesRuntime.cpp +10 -0
- package/cxx/UnistylesRuntime.h +10 -2
- package/ios/UnistylesHelpers.h +0 -1
- package/ios/UnistylesHelpers.mm +0 -15
- package/ios/UnistylesModule.h +7 -1
- package/ios/UnistylesModule.mm +17 -47
- package/ios/platform/Platform_iOS.h +21 -0
- package/ios/platform/Platform_iOS.mm +132 -0
- package/ios/platform/Platform_macOS.h +20 -0
- package/ios/platform/Platform_macOS.mm +83 -0
- package/lib/commonjs/common.js +21 -1
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.js +3 -0
- package/lib/commonjs/core/UnistylesModule.js.map +1 -1
- package/lib/commonjs/core/UnistylesRuntime.js +8 -0
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
- package/lib/commonjs/hooks/useUnistyles.js +8 -1
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/normalizer/normalizer.js.map +1 -1
- package/lib/commonjs/normalizer/normalizer.macos.js +3 -0
- package/lib/commonjs/normalizer/normalizer.macos.js.map +1 -0
- package/lib/commonjs/useStyles.js +1 -1
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/index.js +6 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/common.js +20 -0
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistylesModule.js +3 -0
- package/lib/module/core/UnistylesModule.js.map +1 -1
- package/lib/module/core/UnistylesRuntime.js +8 -0
- package/lib/module/core/UnistylesRuntime.js.map +1 -1
- package/lib/module/hooks/useUnistyles.js +8 -1
- package/lib/module/hooks/useUnistyles.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/normalizer/normalizer.js.map +1 -1
- package/lib/module/normalizer/normalizer.macos.js +2 -0
- package/lib/module/normalizer/normalizer.macos.js.map +1 -0
- package/lib/module/useStyles.js +1 -1
- 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/typescript/src/common.d.ts +19 -1
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +5 -0
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useUnistyles.d.ts +1 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/normalizer/normalizer.macos.d.ts +1 -0
- package/lib/typescript/src/normalizer/normalizer.macos.d.ts.map +1 -0
- package/lib/typescript/src/types/unistyles.d.ts +9 -2
- package/lib/typescript/src/types/unistyles.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/package.json +11 -3
- package/react-native-unistyles.podspec +2 -2
- package/src/common.ts +21 -1
- package/src/core/UnistylesModule.ts +3 -0
- package/src/core/UnistylesRuntime.ts +8 -0
- package/src/hooks/useUnistyles.ts +9 -2
- package/src/index.ts +3 -1
- package/src/normalizer/normalizer.macos.ts +1 -0
- package/src/normalizer/normalizer.ts +1 -1
- package/src/types/unistyles.ts +10 -2
- package/src/useStyles.ts +1 -1
- package/src/utils/index.ts +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,YAAa,MAAM,SAE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AA4B,mEAAoE;IAChG,iBAAiB,6DAA8D;IAC/E,mBAAmB,+EAA+E;IAClG,wBAAwB,0DAA0D;CACrF"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"UnistylesModule.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesModule.ts"],"names":[],"mappings":"AAMA,qBAAa,kBAAkB;;;
|
1
|
+
{"version":3,"file":"UnistylesModule.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesModule.ts"],"names":[],"mappings":"AAMA,qBAAa,kBAAkB;;;IAwBpB,OAAO;IA+Dd,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,cAAc;IA6BtB,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,gBAAgB;CAe3B;AAED,eAAO,MAAM,eAAe,oBAA2B,CAAA"}
|
@@ -23,6 +23,11 @@ export declare class UnistylesRuntime {
|
|
23
23
|
* @returns - The current theme name
|
24
24
|
*/
|
25
25
|
get themeName(): never;
|
26
|
+
/**
|
27
|
+
* Get the current content size category
|
28
|
+
* @returns - The current content size category
|
29
|
+
*/
|
30
|
+
get contentSizeCategory(): import("../common").IOSContentSizeCategory | import("../common").AndroidContentSizeCategory;
|
26
31
|
/**
|
27
32
|
* Get the current breakpoint based on device size
|
28
33
|
* @returns - The current breakpoint
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D;;GAEG;AACH,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;gBAA3D,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAEjG;;;OAGG;IACH,IAAW,WAAW,uCAErB;IAED;;;OAGG;IACH,IAAW,iBAAiB,YAE3B;IAED;;;OAGG;IACH,IAAW,SAAS,UAEnB;IAED;;;OAGG;IACH,IAAW,UAAU,mDAEpB;IAED;;;OAGG;IACH,IAAW,WAAW,6CAErB;IAED;;;OAGG;IACH,IAAW,cAAc,aAExB;IAED;;;OAGG;IACH,IAAW,MAAM;;;MAKhB;IAED;;;OAGG;IACH,IAAW,WAAW,6BAQrB;IAED;;;;OAIG;IACI,QAAQ,SAAU,MAAM,eAAe,sBAY7C;IAED;;;OAGG;IACI,iBAAiB,WAAY,OAAO,UAE1C;IAED;;;OAGG;IACI,SAAS,WAAY,eAAe,UAE1C;IAED;;;OAGG;IACI,YAAY,WAAY,eAAe,UAE7C;CACJ"}
|
1
|
+
{"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D;;GAEG;AACH,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;gBAA3D,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAEjG;;;OAGG;IACH,IAAW,WAAW,uCAErB;IAED;;;OAGG;IACH,IAAW,iBAAiB,YAE3B;IAED;;;OAGG;IACH,IAAW,SAAS,UAEnB;IAED;;;OAGG;IACH,IAAW,mBAAmB,gGAE7B;IAED;;;OAGG;IACH,IAAW,UAAU,mDAEpB;IAED;;;OAGG;IACH,IAAW,WAAW,6CAErB;IAED;;;OAGG;IACH,IAAW,cAAc,aAExB;IAED;;;OAGG;IACH,IAAW,MAAM;;;MAKhB;IAED;;;OAGG;IACH,IAAW,WAAW,6BAQrB;IAED;;;;OAIG;IACI,QAAQ,SAAU,MAAM,eAAe,sBAY7C;IAED;;;OAGG;IACI,iBAAiB,WAAY,OAAO,UAE1C;IAED;;;OAGG;IACI,SAAS,WAAY,eAAe,UAE1C;IAED;;;OAGG;IACI,YAAY,WAAY,eAAe,UAE7C;CACJ"}
|
@@ -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;;;;;;;;;;;;CAuDxB,CAAA"}
|
@@ -2,7 +2,7 @@ import { mq } from './utils';
|
|
2
2
|
import { useInitialTheme } from './hooks';
|
3
3
|
import type { UnistylesPlugin } from './types';
|
4
4
|
import type { UnistylesThemes, UnistylesBreakpoints } from './global';
|
5
|
-
import { ScreenOrientation } from './common';
|
5
|
+
import { ScreenOrientation, AndroidContentSizeCategory, IOSContentSizeCategory } from './common';
|
6
6
|
import { useStyles } from './useStyles';
|
7
7
|
import { createStyleSheet } from './createStyleSheet';
|
8
8
|
/**
|
@@ -72,6 +72,6 @@ declare const UnistylesRegistry: {
|
|
72
72
|
};
|
73
73
|
};
|
74
74
|
declare const UnistylesRuntime: import("./core").UnistylesRuntime;
|
75
|
-
export { mq, useStyles, useInitialTheme, createStyleSheet, ScreenOrientation, UnistylesRegistry, UnistylesRuntime };
|
75
|
+
export { mq, useStyles, useInitialTheme, createStyleSheet, ScreenOrientation, AndroidContentSizeCategory, IOSContentSizeCategory, UnistylesRegistry, UnistylesRuntime };
|
76
76
|
export type { UnistylesThemes, UnistylesBreakpoints, UnistylesPlugin };
|
77
77
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAChG,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;GAGG;AACH,QAAA,MAAM,iBAAiB;IACnB;;;OAGG;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;CAEN,CAAA;AAED,QAAA,MAAM,gBAAgB,mCAAoB,CAAA;AAE1C,OAAO,EACH,EAAE,EACF,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EACnB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACpB,eAAe,EAClB,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
//# sourceMappingURL=normalizer.macos.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"normalizer.macos.d.ts","sourceRoot":"","sources":["../../../../src/normalizer/normalizer.macos.ts"],"names":[],"mappings":""}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { UnistylesEventType, ScreenOrientation } from '../common';
|
1
|
+
import { UnistylesEventType, ScreenOrientation, IOSContentSizeCategory, AndroidContentSizeCategory } from '../common';
|
2
2
|
import type { UnistylesThemes, UnistylesBreakpoints } from '../global';
|
3
3
|
import type { ScreenSize } from './core';
|
4
4
|
import type { UnistylesPlugin } from './plugin';
|
@@ -17,6 +17,7 @@ export type UnistylesBridge = {
|
|
17
17
|
themeName: keyof UnistylesThemes;
|
18
18
|
breakpoint: keyof UnistylesBreakpoints;
|
19
19
|
colorScheme: ColorSchemeName;
|
20
|
+
contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory;
|
20
21
|
sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>;
|
21
22
|
themes: Array<keyof UnistylesThemes>;
|
22
23
|
useBreakpoints(breakpoints: UnistylesBreakpoints): void;
|
@@ -42,5 +43,11 @@ export type UnistylesMobileLayoutEvent = {
|
|
42
43
|
export type UnistylesPluginEvent = {
|
43
44
|
type: UnistylesEventType.Plugin;
|
44
45
|
};
|
45
|
-
export type
|
46
|
+
export type UnistylesDynamicTypeSizeEvent = {
|
47
|
+
type: UnistylesEventType.DynamicTypeSize;
|
48
|
+
payload: {
|
49
|
+
contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory;
|
50
|
+
};
|
51
|
+
};
|
52
|
+
export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent | UnistylesDynamicTypeSizeEvent;
|
46
53
|
//# 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,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;
|
1
|
+
{"version":3,"file":"unistyles.d.ts","sourceRoot":"","sources":["../../../../src/types/unistyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AACrH,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,YAAY,CAAC,EAAE,MAAM,eAAe,CAAC;IACrC,OAAO,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IACjC,2BAA2B,CAAC,EAAE,OAAO,CAAA;CACxC,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,C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,GAAG,mBAAmB,GAAG,0BAA0B,GAAG,oBAAoB,GAAG,6BAA6B,CAAA"}
|
@@ -2,7 +2,7 @@ export { mq } from './mq';
|
|
2
2
|
export type { UnistylesParsedMq } from './mqParser';
|
3
3
|
export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq, isUnistylesMq } from './mqParser';
|
4
4
|
export { getValueForBreakpoint } from './breakpoints';
|
5
|
-
export { proxifyFunction, parseStyle } from './styles';
|
5
|
+
export { proxifyFunction, parseStyle, isPlatformColor } from './styles';
|
6
6
|
export { withPlugins } from './withPlugins';
|
7
7
|
export { generateReactNativeWebId } from './generateId';
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACvH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACvH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "2.0.0-rc.
|
3
|
+
"version": "2.0.0-rc.4",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
@@ -37,7 +37,10 @@
|
|
37
37
|
"keywords": [
|
38
38
|
"react-native",
|
39
39
|
"ios",
|
40
|
-
"android"
|
40
|
+
"android",
|
41
|
+
"react-native-macos",
|
42
|
+
"react-native-web",
|
43
|
+
"expo"
|
41
44
|
],
|
42
45
|
"repository": "https://github.com/jpudysz/react-native-unistyles",
|
43
46
|
"author": "Jacek Pudysz <jacekpudysz@gmail.com> (https://github.com/jpudysz)",
|
@@ -88,15 +91,20 @@
|
|
88
91
|
"@react-native/normalize-colors": "*",
|
89
92
|
"react": "*",
|
90
93
|
"react-native": "*",
|
94
|
+
"react-native-macos": "*",
|
91
95
|
"react-native-web": "*"
|
92
96
|
},
|
93
97
|
"peerDependenciesMeta": {
|
98
|
+
"react-native-macos": {
|
99
|
+
"optional": true
|
100
|
+
},
|
94
101
|
"react-native-web": {
|
95
102
|
"optional": true
|
96
103
|
}
|
97
104
|
},
|
98
105
|
"workspaces": [
|
99
106
|
"examples/expo",
|
107
|
+
"examples/macos",
|
100
108
|
"docs"
|
101
109
|
],
|
102
110
|
"packageManager": "yarn@3.6.1",
|
@@ -107,7 +115,7 @@
|
|
107
115
|
"preset": "react-native",
|
108
116
|
"modulePathIgnorePatterns": [
|
109
117
|
"<rootDir>/examples/expo/node_modules",
|
110
|
-
"<rootDir>/examples/
|
118
|
+
"<rootDir>/examples/macos/node_modules",
|
111
119
|
"<rootDir>/docs/node_modules",
|
112
120
|
"<rootDir>/lib/"
|
113
121
|
],
|
@@ -10,11 +10,11 @@ Pod::Spec.new do |s|
|
|
10
10
|
s.license = package["license"]
|
11
11
|
s.authors = package["author"]
|
12
12
|
|
13
|
-
s.platforms = { :ios => min_ios_version_supported }
|
13
|
+
s.platforms = { :ios => min_ios_version_supported, :osx => "10.14" }
|
14
14
|
s.source = { :git => package["repository"], :tag => "#{s.version}" }
|
15
15
|
|
16
16
|
s.source_files = [
|
17
|
-
"ios
|
17
|
+
"ios/**/*.{h,mm}",
|
18
18
|
"cxx/*.{h,cpp}"
|
19
19
|
]
|
20
20
|
|
package/src/common.ts
CHANGED
@@ -15,10 +15,30 @@ export const ScreenOrientation = {
|
|
15
15
|
Portrait: 'portrait'
|
16
16
|
} as const
|
17
17
|
|
18
|
+
export enum IOSContentSizeCategory {
|
19
|
+
ExtraExtraExtraLarge = 'xxxLarge',
|
20
|
+
ExtraExtraLarge = 'xxLarge',
|
21
|
+
ExtraLarge = 'xLarge',
|
22
|
+
Large = 'Large',
|
23
|
+
Medium = 'Medium',
|
24
|
+
Small = 'Small',
|
25
|
+
ExtraSmall = 'xSmall',
|
26
|
+
Unspecified = 'unspecified'
|
27
|
+
}
|
28
|
+
|
29
|
+
export enum AndroidContentSizeCategory {
|
30
|
+
Small = 'Small',
|
31
|
+
Default = 'Default',
|
32
|
+
Large = 'Large',
|
33
|
+
ExtraLarge = 'ExtraLarge',
|
34
|
+
Huge = 'Huge'
|
35
|
+
}
|
36
|
+
|
18
37
|
export enum UnistylesEventType {
|
19
38
|
Theme = 'theme',
|
20
39
|
Layout = 'layout',
|
21
|
-
Plugin = 'plugin'
|
40
|
+
Plugin = 'plugin',
|
41
|
+
DynamicTypeSize = 'dynamicTypeSize'
|
22
42
|
}
|
23
43
|
|
24
44
|
export enum UnistylesError {
|
@@ -18,6 +18,7 @@ export class UnistylesBridgeWeb {
|
|
18
18
|
#unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles)
|
19
19
|
#sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, number]> = []
|
20
20
|
#breakpoint: keyof UnistylesBreakpoints = '' as keyof UnistylesBreakpoints
|
21
|
+
#contentSizeCategory: string = 'unspecified'
|
21
22
|
|
22
23
|
constructor() {
|
23
24
|
if (!isServer) {
|
@@ -39,6 +40,8 @@ export class UnistylesBridgeWeb {
|
|
39
40
|
return this.#screenWidth
|
40
41
|
case 'screenHeight':
|
41
42
|
return this.#screenHeight
|
43
|
+
case 'contentSizeCategory':
|
44
|
+
return this.#contentSizeCategory
|
42
45
|
case 'breakpoint':
|
43
46
|
return this.#breakpoint || undefined
|
44
47
|
case 'breakpoints':
|
@@ -33,6 +33,14 @@ export class UnistylesRuntime {
|
|
33
33
|
return this.unistylesBridge.themeName
|
34
34
|
}
|
35
35
|
|
36
|
+
/**
|
37
|
+
* Get the current content size category
|
38
|
+
* @returns - The current content size category
|
39
|
+
*/
|
40
|
+
public get contentSizeCategory() {
|
41
|
+
return this.unistylesBridge.contentSizeCategory
|
42
|
+
}
|
43
|
+
|
36
44
|
/**
|
37
45
|
* Get the current breakpoint based on device size
|
38
46
|
* @returns - The current breakpoint
|
@@ -2,13 +2,14 @@ import { NativeEventEmitter, NativeModules } from 'react-native'
|
|
2
2
|
import { useEffect, useState } from 'react'
|
3
3
|
import { unistyles } from '../core'
|
4
4
|
import { UnistylesEventType } from '../common'
|
5
|
-
import type { UnistylesEvents, UnistylesMobileLayoutEvent, UnistylesThemeEvent } from '../types'
|
5
|
+
import type { UnistylesDynamicTypeSizeEvent, UnistylesEvents, UnistylesMobileLayoutEvent, UnistylesThemeEvent } from '../types'
|
6
6
|
|
7
7
|
const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles)
|
8
8
|
|
9
9
|
export const useUnistyles = () => {
|
10
10
|
const [plugins, setPlugins] = useState(unistyles.runtime.enabledPlugins)
|
11
11
|
const [theme, setTheme] = useState(unistyles.registry.getTheme(unistyles.runtime.themeName))
|
12
|
+
const [contentSizeCategory, setContentSizeCategory] = useState(unistyles.runtime.contentSizeCategory)
|
12
13
|
const [layout, setLayout] = useState({
|
13
14
|
breakpoint: unistyles.runtime.breakpoint,
|
14
15
|
orientation: unistyles.runtime.orientation,
|
@@ -40,6 +41,11 @@ export const useUnistyles = () => {
|
|
40
41
|
case UnistylesEventType.Plugin: {
|
41
42
|
return setPlugins(unistyles.runtime.enabledPlugins)
|
42
43
|
}
|
44
|
+
case UnistylesEventType.DynamicTypeSize: {
|
45
|
+
const dynamicTypeSizeEvent = event as UnistylesDynamicTypeSizeEvent
|
46
|
+
|
47
|
+
return setContentSizeCategory(dynamicTypeSizeEvent.payload.contentSizeCategory)
|
48
|
+
}
|
43
49
|
default:
|
44
50
|
return
|
45
51
|
}
|
@@ -52,6 +58,7 @@ export const useUnistyles = () => {
|
|
52
58
|
return {
|
53
59
|
plugins,
|
54
60
|
theme,
|
55
|
-
layout
|
61
|
+
layout,
|
62
|
+
contentSizeCategory
|
56
63
|
}
|
57
64
|
}
|
package/src/index.ts
CHANGED
@@ -3,7 +3,7 @@ import { mq } from './utils'
|
|
3
3
|
import { useInitialTheme } from './hooks'
|
4
4
|
import type { UnistylesPlugin } from './types'
|
5
5
|
import type { UnistylesThemes, UnistylesBreakpoints } from './global'
|
6
|
-
import { ScreenOrientation } from './common'
|
6
|
+
import { ScreenOrientation, AndroidContentSizeCategory, IOSContentSizeCategory } from './common'
|
7
7
|
import { useStyles } from './useStyles'
|
8
8
|
import { createStyleSheet } from './createStyleSheet'
|
9
9
|
|
@@ -37,6 +37,8 @@ export {
|
|
37
37
|
useInitialTheme,
|
38
38
|
createStyleSheet,
|
39
39
|
ScreenOrientation,
|
40
|
+
AndroidContentSizeCategory,
|
41
|
+
IOSContentSizeCategory,
|
40
42
|
UnistylesRegistry,
|
41
43
|
UnistylesRuntime
|
42
44
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
// keep it empty for macOS
|
@@ -38,7 +38,7 @@ export const normalizeColor = (color: string, opacity: number = 1) => {
|
|
38
38
|
|
39
39
|
export const normalizeNumericValue = (value: number) => value ? `${value}px` : value
|
40
40
|
|
41
|
-
const normalizeTransform = (key: string, value:
|
41
|
+
const normalizeTransform = <T>(key: string, value: T) => {
|
42
42
|
if (key.includes('scale')) {
|
43
43
|
return value
|
44
44
|
}
|
package/src/types/unistyles.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { UnistylesEventType, ScreenOrientation } from '../common'
|
1
|
+
import { UnistylesEventType, ScreenOrientation, IOSContentSizeCategory, AndroidContentSizeCategory } from '../common'
|
2
2
|
import type { UnistylesThemes, UnistylesBreakpoints } from '../global'
|
3
3
|
import type { ScreenSize } from './core'
|
4
4
|
import type { UnistylesPlugin } from './plugin'
|
@@ -21,6 +21,7 @@ export type UnistylesBridge = {
|
|
21
21
|
themeName: keyof UnistylesThemes,
|
22
22
|
breakpoint: keyof UnistylesBreakpoints,
|
23
23
|
colorScheme: ColorSchemeName,
|
24
|
+
contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory,
|
24
25
|
sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>,
|
25
26
|
|
26
27
|
// setters
|
@@ -52,4 +53,11 @@ export type UnistylesPluginEvent = {
|
|
52
53
|
type: UnistylesEventType.Plugin
|
53
54
|
}
|
54
55
|
|
55
|
-
export type
|
56
|
+
export type UnistylesDynamicTypeSizeEvent = {
|
57
|
+
type: UnistylesEventType.DynamicTypeSize,
|
58
|
+
payload: {
|
59
|
+
contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent | UnistylesDynamicTypeSizeEvent
|
package/src/useStyles.ts
CHANGED
package/src/utils/index.ts
CHANGED
@@ -2,6 +2,6 @@ export { mq } from './mq'
|
|
2
2
|
export type { UnistylesParsedMq } from './mqParser'
|
3
3
|
export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq, isUnistylesMq } from './mqParser'
|
4
4
|
export { getValueForBreakpoint } from './breakpoints'
|
5
|
-
export { proxifyFunction, parseStyle } from './styles'
|
5
|
+
export { proxifyFunction, parseStyle, isPlatformColor } from './styles'
|
6
6
|
export { withPlugins } from './withPlugins'
|
7
7
|
export { generateReactNativeWebId } from './generateId'
|