react-native-unistyles 2.0.0-beta.2 → 2.0.0-beta.4
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/core/UnistyleRegistry.js +6 -2
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/core/Unistyles.js +2 -1
- package/lib/commonjs/core/Unistyles.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.web.js +18 -6
- package/lib/commonjs/core/UnistylesModule.web.js.map +1 -1
- package/lib/commonjs/core/UnistylesRuntime.js +3 -0
- package/lib/commonjs/core/UnistylesRuntime.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/useCSS.js +9 -0
- package/lib/commonjs/hooks/useCSS.js.map +1 -0
- package/lib/commonjs/hooks/useCSS.web.js +46 -0
- package/lib/commonjs/hooks/useCSS.web.js.map +1 -0
- package/lib/commonjs/normalizer/index.js.map +1 -0
- package/lib/commonjs/normalizer/module.d.js.map +1 -0
- package/lib/commonjs/{plugins/normalizer → normalizer}/normalizeStyle.js +1 -1
- package/lib/commonjs/normalizer/normalizeStyle.js.map +1 -0
- package/lib/commonjs/normalizer/normalizer.js.map +1 -0
- package/lib/commonjs/plugins/cssMediaQueriesPlugin.js +14 -0
- package/lib/commonjs/plugins/cssMediaQueriesPlugin.js.map +1 -0
- package/lib/commonjs/plugins/index.js +3 -21
- package/lib/commonjs/plugins/index.js.map +1 -1
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +1 -1
- package/lib/commonjs/useStyles.js +4 -1
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/cssMediaQuery.js +250 -0
- package/lib/commonjs/utils/cssMediaQuery.js.map +1 -0
- package/lib/commonjs/utils/generateId.js +15 -0
- package/lib/commonjs/utils/generateId.js.map +1 -0
- package/lib/commonjs/utils/hash32.js +43 -0
- package/lib/commonjs/utils/hash32.js.map +1 -0
- package/lib/commonjs/utils/index.js +13 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mqParser.js +2 -1
- package/lib/commonjs/utils/mqParser.js.map +1 -1
- package/lib/commonjs/utils/styles.js +11 -1
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/module/core/UnistyleRegistry.js +7 -3
- package/lib/module/core/UnistyleRegistry.js.map +1 -1
- package/lib/module/core/Unistyles.js +2 -1
- package/lib/module/core/Unistyles.js.map +1 -1
- package/lib/module/core/UnistylesModule.web.js +18 -6
- package/lib/module/core/UnistylesModule.web.js.map +1 -1
- package/lib/module/core/UnistylesRuntime.js +3 -0
- package/lib/module/core/UnistylesRuntime.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/useCSS.js +2 -0
- package/lib/module/hooks/useCSS.js.map +1 -0
- package/lib/module/hooks/useCSS.web.js +39 -0
- package/lib/module/hooks/useCSS.web.js.map +1 -0
- package/lib/module/normalizer/index.js.map +1 -0
- package/lib/module/normalizer/module.d.js.map +1 -0
- package/lib/module/{plugins/normalizer → normalizer}/normalizeStyle.js +1 -1
- package/lib/module/normalizer/normalizeStyle.js.map +1 -0
- package/lib/module/normalizer/normalizer.js.map +1 -0
- package/lib/module/plugins/cssMediaQueriesPlugin.js +7 -0
- package/lib/module/plugins/cssMediaQueriesPlugin.js.map +1 -0
- package/lib/module/plugins/index.js +1 -1
- package/lib/module/plugins/index.js.map +1 -1
- package/lib/module/plugins/normalizeWebStylesPlugin.js +1 -1
- package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -1
- package/lib/module/useStyles.js +5 -2
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/cssMediaQuery.js +243 -0
- package/lib/module/utils/cssMediaQuery.js.map +1 -0
- package/lib/module/utils/generateId.js +7 -0
- package/lib/module/utils/generateId.js.map +1 -0
- package/lib/module/utils/hash32.js +36 -0
- package/lib/module/utils/hash32.js.map +1 -0
- package/lib/module/utils/index.js +2 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mqParser.js +1 -1
- package/lib/module/utils/mqParser.js.map +1 -1
- package/lib/module/utils/styles.js +11 -1
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
- package/lib/typescript/src/core/Unistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.web.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +1 -0
- package/lib/typescript/src/core/UnistylesRuntime.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/useCSS.d.ts +3 -0
- package/lib/typescript/src/hooks/useCSS.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCSS.web.d.ts +3 -0
- package/lib/typescript/src/hooks/useCSS.web.d.ts.map +1 -0
- package/lib/typescript/src/normalizer/index.d.ts.map +1 -0
- package/lib/typescript/src/normalizer/normalizeStyle.d.ts +3 -0
- package/lib/typescript/src/normalizer/normalizeStyle.d.ts.map +1 -0
- package/lib/typescript/src/{plugins/normalizer → normalizer}/normalizer.d.ts +1 -1
- package/lib/typescript/src/normalizer/normalizer.d.ts.map +1 -0
- package/lib/typescript/src/plugins/cssMediaQueriesPlugin.d.ts +3 -0
- package/lib/typescript/src/plugins/cssMediaQueriesPlugin.d.ts.map +1 -0
- package/lib/typescript/src/plugins/index.d.ts +1 -1
- package/lib/typescript/src/plugins/index.d.ts.map +1 -1
- package/lib/typescript/src/types/unistyles.d.ts +2 -1
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/cssMediaQuery.d.ts +4 -0
- package/lib/typescript/src/utils/cssMediaQuery.d.ts.map +1 -0
- package/lib/typescript/src/utils/generateId.d.ts +2 -0
- package/lib/typescript/src/utils/generateId.d.ts.map +1 -0
- package/lib/typescript/src/utils/hash32.d.ts +2 -0
- package/lib/typescript/src/utils/hash32.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +3 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mqParser.d.ts +2 -1
- package/lib/typescript/src/utils/mqParser.d.ts.map +1 -1
- package/lib/typescript/src/utils/styles.d.ts +1 -1
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/core/UnistyleRegistry.ts +8 -3
- package/src/core/Unistyles.ts +2 -1
- package/src/core/UnistylesModule.web.ts +20 -7
- package/src/core/UnistylesRuntime.ts +4 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useCSS.ts +3 -0
- package/src/hooks/useCSS.web.ts +51 -0
- package/src/{plugins/normalizer → normalizer}/normalizeStyle.ts +2 -2
- package/src/{plugins/normalizer → normalizer}/normalizer.ts +2 -1
- package/src/plugins/cssMediaQueriesPlugin.ts +8 -0
- package/src/plugins/index.ts +1 -1
- package/src/plugins/normalizeWebStylesPlugin.ts +1 -1
- package/src/types/unistyles.ts +3 -2
- package/src/useStyles.ts +10 -2
- package/src/utils/cssMediaQuery.ts +268 -0
- package/src/utils/generateId.ts +10 -0
- package/src/utils/hash32.ts +53 -0
- package/src/utils/index.ts +3 -1
- package/src/utils/mqParser.ts +2 -2
- package/src/utils/styles.ts +12 -2
- package/lib/commonjs/plugins/normalizer/index.js.map +0 -1
- package/lib/commonjs/plugins/normalizer/module.d.js.map +0 -1
- package/lib/commonjs/plugins/normalizer/normalizeStyle.js.map +0 -1
- package/lib/commonjs/plugins/normalizer/normalizer.js.map +0 -1
- package/lib/module/plugins/normalizer/index.js.map +0 -1
- package/lib/module/plugins/normalizer/module.d.js.map +0 -1
- package/lib/module/plugins/normalizer/normalizeStyle.js.map +0 -1
- package/lib/module/plugins/normalizer/normalizer.js.map +0 -1
- package/lib/typescript/src/plugins/normalizer/index.d.ts.map +0 -1
- package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts +0 -3
- package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts.map +0 -1
- package/lib/typescript/src/plugins/normalizer/normalizer.d.ts.map +0 -1
- /package/lib/commonjs/{plugins/normalizer → normalizer}/index.js +0 -0
- /package/lib/commonjs/{plugins/normalizer → normalizer}/module.d.js +0 -0
- /package/lib/commonjs/{plugins/normalizer → normalizer}/normalizer.js +0 -0
- /package/lib/module/{plugins/normalizer → normalizer}/index.js +0 -0
- /package/lib/module/{plugins/normalizer → normalizer}/module.d.js +0 -0
- /package/lib/module/{plugins/normalizer → normalizer}/normalizer.js +0 -0
- /package/lib/typescript/src/{plugins/normalizer → normalizer}/index.d.ts +0 -0
- /package/src/{plugins/normalizer → normalizer}/index.ts +0 -0
- /package/src/{plugins/normalizer → normalizer}/module.d.ts +0 -0
@@ -9,6 +9,7 @@ export declare class UnistylesRuntime {
|
|
9
9
|
get hasAdaptiveThemes(): boolean;
|
10
10
|
get themeName(): never;
|
11
11
|
get breakpoint(): keyof import("../global").UnistylesBreakpoints;
|
12
|
+
get breakpoints(): import("../global").UnistylesBreakpoints;
|
12
13
|
get enabledPlugins(): string[];
|
13
14
|
get screen(): {
|
14
15
|
width: number;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;gBAA3D,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAEjG,IAAW,WAAW,uCAErB;IAED,IAAW,iBAAiB,YAE3B;IAED,IAAW,SAAS,UAEnB;IAED,IAAW,UAAU,mDAEpB;IAED,IAAW,cAAc,aAExB;IAED,IAAW,MAAM;;;MAKhB;IAED,IAAW,WAAW,6BAQrB;IAEM,QAAQ,SAAU,MAAM,eAAe,sBAY7C;IAEM,iBAAiB,WAAY,OAAO,UAE1C;IAEM,SAAS,WAAY,eAAe,UAE1C;IAEM,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,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;gBAA3D,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAEjG,IAAW,WAAW,uCAErB;IAED,IAAW,iBAAiB,YAE3B;IAED,IAAW,SAAS,UAEnB;IAED,IAAW,UAAU,mDAEpB;IAED,IAAW,WAAW,6CAErB;IAED,IAAW,cAAc,aAExB;IAED,IAAW,MAAM;;;MAKhB;IAED,IAAW,WAAW,6BAQrB;IAEM,QAAQ,SAAU,MAAM,eAAe,sBAY7C;IAEM,iBAAiB,WAAY,OAAO,UAE1C;IAEM,SAAS,WAAY,eAAe,UAE1C;IAEM,YAAY,WAAY,eAAe,UAE7C;CACJ"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"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
|
+
{"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;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useCSS.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCSS.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAErD,eAAO,MAAM,MAAM,gDAA+C,IAAU,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useCSS.web.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCSS.web.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAGrD,eAAO,MAAM,MAAM,mDA6ClB,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/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/normalizer/normalizeStyle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoE,OAAO,EAAE,MAAM,UAAU,CAAA;AAuDzG,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/normalizer/normalizer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAY,MAAM,UAAU,CAAA;AAE3E,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;AAyDpF,eAAO,MAAM,YAAY,EAAE,YAI1B,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"cssMediaQueriesPlugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/cssMediaQueriesPlugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,eAAO,MAAM,qBAAqB,EAAE,eAGnC,CAAA"}
|
@@ -1,3 +1,3 @@
|
|
1
1
|
export { normalizeWebStylesPlugin } from './normalizeWebStylesPlugin';
|
2
|
-
export {
|
2
|
+
export { cssMediaQueriesPlugin } from './cssMediaQueriesPlugin';
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA"}
|
@@ -5,8 +5,9 @@ import type { UnistylesPlugin } from './plugin';
|
|
5
5
|
export type ColorSchemeName = 'light' | 'dark' | 'unspecified';
|
6
6
|
export type UnistylesConfig = {
|
7
7
|
adaptiveThemes?: boolean;
|
8
|
-
experimentalPlugins?: Array<UnistylesPlugin>;
|
9
8
|
initialTheme?: keyof UnistylesThemes;
|
9
|
+
plugins?: Array<UnistylesPlugin>;
|
10
|
+
experimentalCSSMediaQueries?: boolean;
|
10
11
|
};
|
11
12
|
export type UnistylesBridge = {
|
12
13
|
screenWidth: number;
|
@@ -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;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,CAAA;AAE9D,MAAM,MAAM,eAAe,GAAG;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,
|
1
|
+
{"version":3,"file":"unistyles.d.ts","sourceRoot":"","sources":["../../../../src/types/unistyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,CAAA;AAE9D,MAAM,MAAM,eAAe,GAAG;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,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,CAAC;IAC7B,qBAAqB,EAAE,KAAK,CAAC,CAAC,MAAM,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAG7G,MAAM,EAAE,KAAK,CAAC,MAAM,eAAe,CAAC,CAAC;IACrC,cAAc,CAAC,WAAW,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,eAAe,GAAG,IAAI,CAAC;IAC5C,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACzC,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACrD,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CACzC,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC;IAC/B,OAAO,EAAE;QACL,SAAS,EAAE,MAAM,eAAe,CAAA;KACnC,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACrC,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC;IAChC,OAAO,EAAE;QACL,MAAM,EAAE,UAAU,CAAC;QACnB,UAAU,EAAE,MAAM,oBAAoB,CAAC;QACvC,WAAW,EAAE,OAAO,iBAAiB,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAA;KACxE,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAC/B,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,0BAA0B,GAAG,oBAAoB,CAAA"}
|
@@ -1 +1 @@
|
|
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;
|
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;AAIpH,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,gJAsCrB,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"cssMediaQuery.d.ts","sourceRoot":"","sources":["../../../../src/utils/cssMediaQuery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAW,MAAM,UAAU,CAAA;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,eAAO,MAAM,yBAAyB,WAAY,OAAO,WAAW,gBAAgB,KAAG,OA8BtF,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"generateId.d.ts","sourceRoot":"","sources":["../../../../src/utils/generateId.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,QAAS,MAAM,SAAS,MAAM,KAAG,MAMrE,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"hash32.d.ts","sourceRoot":"","sources":["../../../../src/utils/hash32.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB,QAAS,MAAM,QAAQ,MAAM,WA+C1D,CAAA"}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
export { mq } from './mq';
|
2
|
-
export {
|
2
|
+
export type { UnistylesParsedMq } from './mqParser';
|
3
|
+
export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq, isUnistylesMq } from './mqParser';
|
3
4
|
export { getValueForBreakpoint } from './breakpoints';
|
4
5
|
export { proxifyFunction, parseStyle } from './styles';
|
5
6
|
export { withPlugins } from './withPlugins';
|
7
|
+
export { generateReactNativeWebId } from './generateId';
|
6
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,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,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,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA"}
|
@@ -3,11 +3,12 @@ type ParsedMqDimension = {
|
|
3
3
|
from: number;
|
4
4
|
to: number;
|
5
5
|
};
|
6
|
-
type UnistylesParsedMq = {
|
6
|
+
export type UnistylesParsedMq = {
|
7
7
|
width?: ParsedMqDimension;
|
8
8
|
height?: ParsedMqDimension;
|
9
9
|
};
|
10
10
|
export declare const parseMq: (mq: string) => UnistylesParsedMq;
|
11
|
+
export declare const isUnistylesMq: (mq: string) => boolean;
|
11
12
|
export declare const isValidMq: (parsedMq: UnistylesParsedMq) => boolean;
|
12
13
|
export declare const isWithinTheWidthAndHeight: (parsedMq: UnistylesParsedMq, screenSize: ScreenSize) => boolean;
|
13
14
|
export declare const getKeyForUnistylesMediaQuery: (mediaQueries: Array<[string, RNValue]>, screenSize: ScreenSize) => Optional<string>;
|
@@ -1 +1 @@
|
|
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,
|
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,MAAM,MAAM,iBAAiB,GAAG;IAC5B,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,MAAM,CAAC,EAAE,iBAAiB,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,OAAO,OAAQ,MAAM,KAAG,iBAcpC,CAAA;AAED,eAAO,MAAM,aAAa,OAAQ,MAAM,YAAgC,CAAA;AAExE,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,5 +1,5 @@
|
|
1
1
|
import type { Optional, RNStyle } from '../types';
|
2
2
|
export declare const proxifyFunction: (key: string, fn: Function, variant?: Record<string, Optional<string>>) => Function;
|
3
3
|
export declare const isPlatformColor: <T extends {}>(value: T) => boolean;
|
4
|
-
export declare const parseStyle: <T extends RNStyle>(style: T, variant?: Record<string, Optional<string
|
4
|
+
export declare const parseStyle: <T extends RNStyle>(style: T, variant?: Record<string, Optional<string>>, parseMediaQueries?: boolean) => T;
|
5
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,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,
|
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,mCAmD9B,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "2.0.0-beta.
|
3
|
+
"version": "2.0.0-beta.4",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
@@ -144,7 +144,8 @@
|
|
144
144
|
},
|
145
145
|
"eslintIgnore": [
|
146
146
|
"node_modules/",
|
147
|
-
"lib/"
|
147
|
+
"lib/",
|
148
|
+
"src/utils/hash32.ts"
|
148
149
|
],
|
149
150
|
"react-native-builder-bob": {
|
150
151
|
"source": "src",
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { UnistylesBridge, UnistylesConfig, UnistylesPlugin } from '../types'
|
2
2
|
import type { UnistylesBreakpoints, UnistylesThemes } from '../global'
|
3
3
|
import { isWeb, UnistylesError } from '../common'
|
4
|
-
import { normalizeWebStylesPlugin } from '../plugins'
|
4
|
+
import { cssMediaQueriesPlugin, normalizeWebStylesPlugin } from '../plugins'
|
5
5
|
|
6
6
|
export class UnistyleRegistry {
|
7
7
|
public config: UnistylesConfig = {}
|
@@ -47,14 +47,19 @@ export class UnistyleRegistry {
|
|
47
47
|
this.unistylesBridge.useAdaptiveThemes(config.adaptiveThemes)
|
48
48
|
}
|
49
49
|
|
50
|
-
if (config.
|
51
|
-
config.
|
50
|
+
if (config.plugins) {
|
51
|
+
config.plugins.forEach(plugin => this.addPlugin(plugin, false))
|
52
52
|
}
|
53
53
|
|
54
54
|
if (config.initialTheme) {
|
55
55
|
this.unistylesBridge.useTheme(config.initialTheme)
|
56
56
|
}
|
57
57
|
|
58
|
+
if (config.experimentalCSSMediaQueries) {
|
59
|
+
this.plugins = [cssMediaQueriesPlugin].concat(this.plugins)
|
60
|
+
this.unistylesBridge.addPlugin(cssMediaQueriesPlugin.name, false)
|
61
|
+
}
|
62
|
+
|
58
63
|
return {
|
59
64
|
addBreakpoints: this.addBreakpoints,
|
60
65
|
addThemes: this.addThemes
|
package/src/core/Unistyles.ts
CHANGED
@@ -17,7 +17,8 @@ class Unistyles {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
// @ts-ignore
|
20
|
-
|
20
|
+
// eslint-disable-next-line no-undef
|
21
|
+
this._bridge = (isWeb ? globalThis : global).__UNISTYLES__ as UnistylesBridge
|
21
22
|
this._registry = new UnistyleRegistry(this._bridge)
|
22
23
|
this._runtime = new UnistylesRuntime(this._bridge, this._registry)
|
23
24
|
}
|
@@ -2,14 +2,16 @@ import { NativeEventEmitter, NativeModules } from 'react-native'
|
|
2
2
|
import type { UnistylesThemes, UnistylesBreakpoints } from 'react-native-unistyles'
|
3
3
|
import type { ColorSchemeName } from '../types'
|
4
4
|
import { normalizeWebStylesPlugin } from '../plugins'
|
5
|
+
import { isServer } from '../common'
|
5
6
|
|
6
7
|
export class UnistylesBridgeWeb {
|
7
8
|
#timerRef?: ReturnType<typeof setTimeout> = undefined
|
8
9
|
#hasAdaptiveThemes: boolean = false
|
9
10
|
#supportsAutomaticColorScheme = false
|
10
|
-
#screenWidth
|
11
|
-
#screenHeight
|
11
|
+
#screenWidth = isServer ? undefined : window.innerWidth
|
12
|
+
#screenHeight = isServer ? undefined : window.innerHeight
|
12
13
|
#themes: Array<keyof UnistylesThemes> = []
|
14
|
+
#breakpoints: UnistylesBreakpoints = {} as UnistylesBreakpoints
|
13
15
|
#colorScheme: ColorSchemeName = this.getPreferredColorScheme()
|
14
16
|
#themeName: keyof UnistylesThemes = '' as keyof UnistylesThemes
|
15
17
|
#enabledPlugins: Array<string> = [normalizeWebStylesPlugin.name]
|
@@ -18,12 +20,17 @@ export class UnistylesBridgeWeb {
|
|
18
20
|
#breakpoint: keyof UnistylesBreakpoints = '' as keyof UnistylesBreakpoints
|
19
21
|
|
20
22
|
constructor() {
|
21
|
-
|
23
|
+
if (!isServer) {
|
24
|
+
this.setupListeners()
|
25
|
+
this.#screenWidth = window.innerWidth
|
26
|
+
this.#screenHeight = window.innerHeight
|
27
|
+
}
|
22
28
|
}
|
23
29
|
|
24
30
|
public install() {
|
25
31
|
// @ts-ignore
|
26
|
-
|
32
|
+
// eslint-disable-next-line no-undef
|
33
|
+
globalThis.__UNISTYLES__ = new Proxy({}, {
|
27
34
|
get: (_target, prop) => {
|
28
35
|
switch (prop) {
|
29
36
|
case 'themeName':
|
@@ -34,6 +41,8 @@ export class UnistylesBridgeWeb {
|
|
34
41
|
return this.#screenHeight
|
35
42
|
case 'breakpoint':
|
36
43
|
return this.#breakpoint || undefined
|
44
|
+
case 'breakpoints':
|
45
|
+
return this.#breakpoints
|
37
46
|
case 'hasAdaptiveThemes':
|
38
47
|
return this.#hasAdaptiveThemes
|
39
48
|
case 'sortedBreakpointPairs':
|
@@ -85,10 +94,14 @@ export class UnistylesBridgeWeb {
|
|
85
94
|
}
|
86
95
|
|
87
96
|
private useBreakpoints(breakpoints: UnistylesBreakpoints) {
|
97
|
+
this.#breakpoints = breakpoints
|
88
98
|
this.#sortedBreakpointPairs = Object
|
89
99
|
.entries(breakpoints)
|
90
100
|
.sort(([, a], [, b]) => (a ?? 0) - (b ?? 0)) as Array<[keyof UnistylesBreakpoints, number]>
|
91
|
-
|
101
|
+
|
102
|
+
if (!isServer) {
|
103
|
+
this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth as number)
|
104
|
+
}
|
92
105
|
}
|
93
106
|
|
94
107
|
private useAdaptiveThemes(enable: boolean) {
|
@@ -172,7 +185,7 @@ export class UnistylesBridgeWeb {
|
|
172
185
|
}
|
173
186
|
|
174
187
|
private getPreferredColorScheme() {
|
175
|
-
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
188
|
+
if (!isServer && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
176
189
|
return 'dark'
|
177
190
|
}
|
178
191
|
|
@@ -199,7 +212,7 @@ export class UnistylesBridgeWeb {
|
|
199
212
|
type: 'layout',
|
200
213
|
payload: {
|
201
214
|
breakpoint: this.#breakpoint,
|
202
|
-
orientation: this.#screenWidth > this.#screenHeight
|
215
|
+
orientation: (this.#screenWidth as number) > (this.#screenHeight as number)
|
203
216
|
? 'landscape'
|
204
217
|
: 'portrait',
|
205
218
|
screen: {
|
package/src/hooks/index.ts
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
import { useInsertionEffect, useRef } from 'react'
|
2
|
+
import { unistyles } from '../core'
|
3
|
+
import type { ReactNativeStyleSheet } from '../types'
|
4
|
+
import { generateReactNativeWebId } from '../utils'
|
5
|
+
|
6
|
+
export const useCSS = <T>(stylesheet: ReactNativeStyleSheet<T>) => {
|
7
|
+
const insertedIds = useRef<Array<string>>([])
|
8
|
+
|
9
|
+
useInsertionEffect(() => {
|
10
|
+
if (!unistyles.registry.config.experimentalCSSMediaQueries) {
|
11
|
+
return
|
12
|
+
}
|
13
|
+
|
14
|
+
Object
|
15
|
+
.entries(stylesheet)
|
16
|
+
.forEach(([_key, value]) => {
|
17
|
+
Object.entries(value!)
|
18
|
+
.forEach(([prop, val]) => {
|
19
|
+
if (!val.toString().includes('@media')) {
|
20
|
+
return
|
21
|
+
}
|
22
|
+
|
23
|
+
const id = generateReactNativeWebId(prop, '""')
|
24
|
+
|
25
|
+
if (insertedIds.current.includes(id)) {
|
26
|
+
return
|
27
|
+
}
|
28
|
+
|
29
|
+
const style = document.createElement('style')
|
30
|
+
|
31
|
+
style.id = id
|
32
|
+
style.innerHTML = val
|
33
|
+
|
34
|
+
document.head.appendChild(style)
|
35
|
+
insertedIds.current = [...insertedIds.current, id]
|
36
|
+
})
|
37
|
+
})
|
38
|
+
|
39
|
+
return () => {
|
40
|
+
insertedIds.current.forEach(id => {
|
41
|
+
const style = document.getElementById(id)
|
42
|
+
|
43
|
+
if (style) {
|
44
|
+
style.remove()
|
45
|
+
}
|
46
|
+
})
|
47
|
+
|
48
|
+
insertedIds.current = []
|
49
|
+
}
|
50
|
+
}, [stylesheet])
|
51
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { preprocessor } from './normalizer'
|
2
|
-
import { warn } from '
|
3
|
-
import type { NormalizedBoxShadow, NormalizedTextShadow, BoxShadow, TextShadow, RNStyle } from '
|
2
|
+
import { warn } from '../common'
|
3
|
+
import type { NormalizedBoxShadow, NormalizedTextShadow, BoxShadow, TextShadow, RNStyle } from '../types'
|
4
4
|
|
5
5
|
const normalizeBoxShadow = <T extends BoxShadow>(style: T): NormalizedBoxShadow => {
|
6
6
|
const requiredBoxShadowProperties = [
|
@@ -1,7 +1,7 @@
|
|
1
1
|
// based on react-native-web normalizer
|
2
2
|
// https://github.com/necolas/react-native-web
|
3
3
|
import normalizeColors from '@react-native/normalize-colors'
|
4
|
-
import type { TextShadow, Transforms, BoxShadow, Nullable } from '
|
4
|
+
import type { TextShadow, Transforms, BoxShadow, Nullable } from '../types'
|
5
5
|
|
6
6
|
type Preprocessor = {
|
7
7
|
createTextShadowValue(style: TextShadow): string,
|
@@ -37,6 +37,7 @@ export const normalizeColor = (color: string, opacity: number = 1) => {
|
|
37
37
|
}
|
38
38
|
|
39
39
|
export const normalizeNumericValue = (value: number) => value ? `${value}px` : value
|
40
|
+
|
40
41
|
const normalizeTransform = (key: string, value: number | string) => {
|
41
42
|
if (key.includes('scale')) {
|
42
43
|
return value
|
@@ -0,0 +1,8 @@
|
|
1
|
+
// prevent recursive import
|
2
|
+
import { createMediaQueryForStyles } from '../utils/cssMediaQuery'
|
3
|
+
import type { UnistylesPlugin } from '../types'
|
4
|
+
|
5
|
+
export const cssMediaQueriesPlugin: UnistylesPlugin = {
|
6
|
+
name: '__unistylesCSSMediaQueries',
|
7
|
+
onParsedStyle: (_key, styles, runtime) => createMediaQueryForStyles(styles, runtime)
|
8
|
+
}
|
package/src/plugins/index.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
export { normalizeWebStylesPlugin } from './normalizeWebStylesPlugin'
|
2
|
-
export {
|
2
|
+
export { cssMediaQueriesPlugin } from './cssMediaQueriesPlugin'
|
package/src/types/unistyles.ts
CHANGED
@@ -7,8 +7,9 @@ export type ColorSchemeName = 'light' | 'dark' | 'unspecified'
|
|
7
7
|
|
8
8
|
export type UnistylesConfig = {
|
9
9
|
adaptiveThemes?: boolean,
|
10
|
-
|
11
|
-
|
10
|
+
initialTheme?: keyof UnistylesThemes,
|
11
|
+
plugins?: Array<UnistylesPlugin>,
|
12
|
+
experimentalCSSMediaQueries?: boolean
|
12
13
|
}
|
13
14
|
|
14
15
|
export type UnistylesBridge = {
|
package/src/useStyles.ts
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
import { useMemo } from 'react'
|
2
2
|
import { StyleSheet } from 'react-native'
|
3
3
|
import { parseStyle, proxifyFunction, withPlugins } from './utils'
|
4
|
-
import { useUnistyles, useVariants } from './hooks'
|
4
|
+
import { useCSS, useUnistyles, useVariants } from './hooks'
|
5
5
|
import type { UnistylesBreakpoints } from './global'
|
6
6
|
import type { ExtractVariantNames, ReactNativeStyleSheet, StyleSheetWithSuperPowers, UnistylesTheme } from './types'
|
7
|
+
import { unistyles } from './core'
|
8
|
+
import { isWeb } from './common'
|
7
9
|
|
8
10
|
type ParsedStylesheet<ST extends StyleSheetWithSuperPowers> = {
|
9
11
|
theme: UnistylesTheme,
|
@@ -33,11 +35,17 @@ export const useStyles = <ST extends StyleSheetWithSuperPowers>(
|
|
33
35
|
|
34
36
|
return StyleSheet.create({
|
35
37
|
...acc,
|
36
|
-
[key]: withPlugins(key, parseStyle(
|
38
|
+
[key]: withPlugins(key, parseStyle(
|
39
|
+
value,
|
40
|
+
variants,
|
41
|
+
!isWeb || !unistyles.registry.config.experimentalCSSMediaQueries)
|
42
|
+
)
|
37
43
|
})
|
38
44
|
}, {}), [parsedStyles, variants, plugins]
|
39
45
|
)
|
40
46
|
|
47
|
+
useCSS(dynamicStyleSheet as ReactNativeStyleSheet<ST>)
|
48
|
+
|
41
49
|
return {
|
42
50
|
theme,
|
43
51
|
breakpoint: layout.breakpoint,
|