react-native-unistyles 2.0.0-beta.2 → 2.0.0-beta.3
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/UnistylesModule.web.js +4 -0
- 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 +9 -0
- 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/UnistylesModule.web.js +4 -0
- 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 +9 -0
- 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/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/UnistylesModule.web.ts +4 -0
- 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 +10 -1
- 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
@@ -40,12 +40,16 @@ class UnistyleRegistry {
|
|
40
40
|
if (config.adaptiveThemes) {
|
41
41
|
this.unistylesBridge.useAdaptiveThemes(config.adaptiveThemes);
|
42
42
|
}
|
43
|
-
if (config.
|
44
|
-
config.
|
43
|
+
if (config.plugins) {
|
44
|
+
config.plugins.forEach(plugin => this.addPlugin(plugin, false));
|
45
45
|
}
|
46
46
|
if (config.initialTheme) {
|
47
47
|
this.unistylesBridge.useTheme(config.initialTheme);
|
48
48
|
}
|
49
|
+
if (config.experimentalCSSMediaQueries) {
|
50
|
+
this.plugins = [_plugins.cssMediaQueriesPlugin].concat(this.plugins);
|
51
|
+
this.unistylesBridge.addPlugin(_plugins.cssMediaQueriesPlugin.name, false);
|
52
|
+
}
|
49
53
|
return {
|
50
54
|
addBreakpoints: this.addBreakpoints,
|
51
55
|
addThemes: this.addThemes
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_common","require","_plugins","UnistyleRegistry","config","plugins","isWeb","normalizeWebStylesPlugin","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","
|
1
|
+
{"version":3,"names":["_common","require","_plugins","UnistyleRegistry","config","plugins","isWeb","normalizeWebStylesPlugin","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","forEach","plugin","addPlugin","initialTheme","useTheme","experimentalCSSMediaQueries","cssMediaQueriesPlugin","concat","name","getTheme","forName","length","hasTheme","themeName","Error","UnistylesError","ThemeNotFound","ThemeNotSelected","_this","notify","arguments","undefined","startsWith","InvalidPluginName","some","_ref","DuplicatePluginName","removePlugin","CantRemoveInternalPlugin","filter","_ref2","exports"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEO,MAAME,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,OAAO,GAA2BC,aAAK,GACxC,CAACC,iCAAwB,CAAC,GAC1B,EAAE;EACDC,UAAU,GAAiC,EAAE;EAC7CC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EAExHC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhDC,SAAS,GAAIL,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,MAAMM,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACN,MAAM,CAAiC;IAEhE,IAAI,CAACI,eAAe,CAACJ,MAAM,GAAGM,IAAI;IAClC,IAAI,CAACP,UAAU,GAAGO,IAAI;IAEtB,OAAO;MACHE,cAAc,EAAE,IAAI,CAACA,cAAc;MACnCC,SAAS,EAAE,IAAI,CAACA;IACpB,CAAC;EACL,CAAC;EAEMD,cAAc,GAAIP,WAAiC,IAAK;IAC3D,IAAI,CAACA,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACG,eAAe,CAACM,cAAc,CAACT,WAAW,CAAC;IAChD,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACE,eAAe,CAACF,qBAAqB;IAEvE,OAAO;MACHG,S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AC;EAEMI,QAAQ,GAAIJ,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAACrB,MAAM;AAC1E;AAAC4C,OAAA,CAAAlD,gBAAA,GAAAA,gBAAA"}
|
@@ -13,6 +13,7 @@ class UnistylesBridgeWeb {
|
|
13
13
|
#screenWidth = window.innerWidth;
|
14
14
|
#screenHeight = window.innerHeight;
|
15
15
|
#themes = [];
|
16
|
+
#breakpoints = {};
|
16
17
|
#colorScheme = this.getPreferredColorScheme();
|
17
18
|
#themeName = '';
|
18
19
|
#enabledPlugins = [_plugins.normalizeWebStylesPlugin.name];
|
@@ -35,6 +36,8 @@ class UnistylesBridgeWeb {
|
|
35
36
|
return this.#screenHeight;
|
36
37
|
case 'breakpoint':
|
37
38
|
return this.#breakpoint || undefined;
|
39
|
+
case 'breakpoints':
|
40
|
+
return this.#breakpoints;
|
38
41
|
case 'hasAdaptiveThemes':
|
39
42
|
return this.#hasAdaptiveThemes;
|
40
43
|
case 'sortedBreakpointPairs':
|
@@ -83,6 +86,7 @@ class UnistylesBridgeWeb {
|
|
83
86
|
this.emitThemeChange();
|
84
87
|
}
|
85
88
|
useBreakpoints(breakpoints) {
|
89
|
+
this.#breakpoints = breakpoints;
|
86
90
|
this.#sortedBreakpointPairs = Object.entries(breakpoints).sort((_ref, _ref2) => {
|
87
91
|
let [, a] = _ref;
|
88
92
|
let [, b] = _ref2;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_plugins","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","window","innerWidth","screenHeight","innerHeight","themes","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","normalizeWebStylesPlugin","name","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","sortedBreakpointPairs","breakpoint","constructor","setupListeners","install","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","
|
1
|
+
{"version":3,"names":["_reactNative","require","_plugins","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","window","innerWidth","screenHeight","innerHeight","themes","breakpoints","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","normalizeWebStylesPlugin","name","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","sortedBreakpointPairs","breakpoint","constructor","setupListeners","install","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","useBreakpoints","enable","useAdaptiveThemes","pluginName","notify","addPlugin","removePlugin","Reflect","set","target","newValue","receiver","includes","emitThemeChange","Object","entries","sort","_ref","_ref2","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","width","find","_ref3","index","otherBreakpoints","value","minVal","maxVal","emit","type","payload","orientation","screen","height","exports","UnistylesModule"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.web.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,IAAAC,QAAA,GAAAD,OAAA;AAEO,MAAME,kBAAkB,CAAC;EAC5B,CAACC,QAAQ,GAAmCC,SAAS;EACrD,CAACC,iBAAiB,GAAY,KAAK;EACnC,CAACC,4BAA4B,GAAG,KAAK;EACrC,CAACC,WAAW,GAAWC,MAAM,CAACC,UAAU;EACxC,CAACC,YAAY,GAAWF,MAAM,CAACG,WAAW;EAC1C,CAACC,MAAM,GAAiC,EAAE;EAC1C,CAACC,WAAW,GAAyB,CAAC,CAAC;EACvC,CAACC,WAAW,GAAoB,IAAI,CAACC,uBAAuB,CAAC,CAAC;EAC9D,CAACC,SAAS,GAA0B,EAAE;EACtC,CAACC,cAAc,GAAkB,CAACC,iCAAwB,CAACC,IAAI,CAAC;EAChE,CAACC,eAAe,GAAG,IAAIC,+BAAkB,CAACC,0BAAa,CAACC,SAAS,CAAC;EAClE,CAACC,qBAAqB,GAAgD,EAAE;EACxE,CAACC,UAAU,GAA+B,EAAE;EAE5CC,WAAWA,CAAA,EAAG;IACV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ylesRegistry","colorScheme","hasAdaptiveThemes","themeName","breakpoint","enabledPlugins","screen","width","screenWidth","height","screenHeight","orientation","ScreenOrientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","UnistylesError","ThemeNotRegistered","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin","exports"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,iBAAmC,EAAE;IAAA,KAA/ED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,iBAAmC,GAAnCA,iBAAmC;EAAG;EAEpG,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,eAAe,CAACE,WAAW;EAC3C;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,eAAe,CAACG,iBAAiB;EACjD;EAEA,IAAWC,SAASA,CAAA,EAAG;IACnB,OAAO,IAAI,CAACJ,eAAe,CAACI,SAAS;EACzC;EAEA,IAAWC,UAAUA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACL,eAAe,CAACK,UAAU;EAC1C;EAEA,IAAWC,cAAcA,CAAA,EAAG;IACxB,OAAO,IAAI,
|
1
|
+
{"version":3,"names":["_common","require","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","breakpoint","breakpoints","enabledPlugins","screen","width","screenWidth","height","screenHeight","orientation","ScreenOrientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","UnistylesError","ThemeNotRegistered","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin","exports"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,C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;IACf;IAEA,MAAM,IAAIG,KAAK,CAACC,sBAAc,CAACC,kBAAkB,CAAC;EACtD,CAAC;EAEMC,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAACzB,eAAe,CAAC0B,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;EAEME,SAAS,GAAIC,MAAuB,IAAK;IAC5C,IAAI,CAAC3B,iBAAiB,CAAC0B,SAAS,CAACC,MAAM,CAAC;EAC5C,CAAC;EAEMC,YAAY,GAAID,MAAuB,IAAK;IAC/C,IAAI,CAAC3B,iBAAiB,CAAC4B,YAAY,CAACD,MAAM,CAAC;EAC/C,CAAC;AACL;AAACE,OAAA,CAAAhC,gBAAA,GAAAA,gBAAA"}
|
@@ -3,6 +3,12 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
Object.defineProperty(exports, "useCSS", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function () {
|
9
|
+
return _useCSS.useCSS;
|
10
|
+
}
|
11
|
+
});
|
6
12
|
Object.defineProperty(exports, "useInitialTheme", {
|
7
13
|
enumerable: true,
|
8
14
|
get: function () {
|
@@ -24,4 +30,5 @@ Object.defineProperty(exports, "useVariants", {
|
|
24
30
|
var _useInitialTheme = require("./useInitialTheme");
|
25
31
|
var _useUnistyles = require("./useUnistyles");
|
26
32
|
var _useVariants = require("./useVariants");
|
33
|
+
var _useCSS = require("./useCSS");
|
27
34
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_useInitialTheme","require","_useUnistyles","_useVariants"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":"
|
1
|
+
{"version":3,"names":["_useInitialTheme","require","_useUnistyles","_useVariants","_useCSS"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["useCSS","_stylesheet","exports"],"sourceRoot":"../../../src","sources":["hooks/useCSS.ts"],"mappings":";;;;;;AAEO,MAAMA,MAAM,GAAOC,WAAqC,IAAW,CAAC,CAAC;AAAAC,OAAA,CAAAF,MAAA,GAAAA,MAAA"}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.useCSS = void 0;
|
7
|
+
var _react = require("react");
|
8
|
+
var _core = require("../core");
|
9
|
+
var _utils = require("../utils");
|
10
|
+
const useCSS = stylesheet => {
|
11
|
+
const insertedIds = (0, _react.useRef)([]);
|
12
|
+
(0, _react.useInsertionEffect)(() => {
|
13
|
+
if (!_core.unistyles.registry.config.experimentalCSSMediaQueries) {
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
Object.entries(stylesheet).forEach(_ref => {
|
17
|
+
let [_key, value] = _ref;
|
18
|
+
Object.entries(value).forEach(_ref2 => {
|
19
|
+
let [prop, val] = _ref2;
|
20
|
+
if (!val.toString().includes('@media')) {
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
const id = (0, _utils.generateReactNativeWebId)(prop, '""');
|
24
|
+
if (insertedIds.current.includes(id)) {
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
const style = document.createElement('style');
|
28
|
+
style.id = id;
|
29
|
+
style.innerHTML = val;
|
30
|
+
document.head.appendChild(style);
|
31
|
+
insertedIds.current = [...insertedIds.current, id];
|
32
|
+
});
|
33
|
+
});
|
34
|
+
return () => {
|
35
|
+
insertedIds.current.forEach(id => {
|
36
|
+
const style = document.getElementById(id);
|
37
|
+
if (style) {
|
38
|
+
style.remove();
|
39
|
+
}
|
40
|
+
});
|
41
|
+
insertedIds.current = [];
|
42
|
+
};
|
43
|
+
}, [stylesheet]);
|
44
|
+
};
|
45
|
+
exports.useCSS = useCSS;
|
46
|
+
//# sourceMappingURL=useCSS.web.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_react","require","_core","_utils","useCSS","stylesheet","insertedIds","useRef","useInsertionEffect","unistyles","registry","config","experimentalCSSMediaQueries","Object","entries","forEach","_ref","_key","value","_ref2","prop","val","toString","includes","id","generateReactNativeWebId","current","style","document","createElement","innerHTML","head","appendChild","getElementById","remove","exports"],"sourceRoot":"../../../src","sources":["hooks/useCSS.web.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAEO,MAAMG,MAAM,GAAOC,UAAoC,IAAK;EAC/D,MAAMC,WAAW,GAAG,IAAAC,aAAM,EAAgB,EAAE,CAAC;EAE7C,IAAAC,yBAAkB,EAAC,MAAM;IACrB,IAAI,CAACC,eAAS,CAACC,QAAQ,CAACC,MAAM,CAACC,2BAA2B,EAAE;MACxD;IACJ;IAEAC,MAAM,CACDC,OAAO,CAACT,UAAU,CAAC,CACnBU,OAAO,CAACC,IAAA,IAAmB;MAAA,IAAlB,CAACC,IAAI,EAAEC,KAAK,CAAC,GAAAF,IAAA;MACnBH,MAAM,CAACC,OAAO,CAACI,KAAM,CAAC,CACjBH,OAAO,CAACI,KAAA,IAAiB;QAAA,IAAhB,CAACC,IAAI,EAAEC,GAAG,CAAC,GAAAF,KAAA;QACjB,IAAI,CAACE,GAAG,CAACC,QAAQ,CAAC,CAAC,CAACC,QAAQ,CAAC,QAAQ,CAAC,EAAE;UACpC;QACJ;QAEA,MAAMC,EAAE,GAAG,IAAAC,+BAAwB,EAACL,IAAI,EAAE,IAAI,CAAC;QAE/C,IAAId,WAAW,CAACoB,OAAO,CAACH,QAAQ,CAACC,EAAE,CAAC,EAAE;UAClC;QACJ;QAEA,MAAMG,KAAK,GAAGC,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC;QAE7CF,KAAK,CAACH,EAAE,GAAGA,EAAE;QACbG,KAAK,CAACG,SAAS,GAAGT,GAAG;QAErBO,QAAQ,CAACG,IAAI,CAACC,WAAW,CAACL,KAAK,CAAC;QAChCrB,WAAW,CAACoB,OAAO,GAAG,CAAC,GAAGpB,WAAW,CAACoB,OAAO,EAAEF,EAAE,CAAC;MACtD,CAAC,CAAC;IACV,CAAC,CAAC;IAEN,OAAO,MAAM;MACTlB,WAAW,CAACoB,OAAO,CAACX,OAAO,CAACS,EAAE,IAAI;QAC9B,MAAMG,KAAK,GAAGC,QAAQ,CAACK,cAAc,CAACT,EAAE,CAAC;QAEzC,IAAIG,KAAK,EAAE;UACPA,KAAK,CAACO,MAAM,CAAC,CAAC;QAClB;MACJ,CAAC,CAAC;MAEF5B,WAAW,CAACoB,OAAO,GAAG,EAAE;IAC5B,CAAC;EACL,CAAC,EAAE,CAACrB,UAAU,CAAC,CAAC;AACpB,CAAC;AAAA8B,OAAA,CAAA/B,MAAA,GAAAA,MAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_normalizeStyle","require","_normalizer"],"sourceRoot":"../../../src","sources":["normalizer/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["normalizer/module.d.ts"],"mappings":""}
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.normalizeStyle = void 0;
|
7
7
|
var _normalizer = require("./normalizer");
|
8
|
-
var _common = require("
|
8
|
+
var _common = require("../common");
|
9
9
|
const normalizeBoxShadow = style => {
|
10
10
|
const requiredBoxShadowProperties = ['shadowColor', 'shadowOffset', 'shadowOpacity', 'shadowRadius'];
|
11
11
|
if (!requiredBoxShadowProperties.every(prop => prop in style)) {
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_normalizer","require","_common","normalizeBoxShadow","style","requiredBoxShadowProperties","every","prop","warn","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","preprocessor","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyle","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow","exports"],"sourceRoot":"../../../src","sources":["normalizer/normalizeStyle.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAGA,MAAME,kBAAkB,GAAyBC,KAAQ,IAA0B;EAC/E,MAAMC,2BAA2B,GAAG,CAChC,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,CACjB;EAED,IAAI,CAACA,2BAA2B,CAACC,KAAK,CAACC,IAAI,IAAIA,IAAI,IAAIH,KAAK,CAAC,EAAE;IAC3D,IAAAI,YAAI,EAAE,wEAAuEH,2BAA2B,CAACI,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;IAEtH,OAAO;MACHC,WAAW,EAAEC,SAAS;MACtBC,YAAY,EAAED,SAAS;MACvBE,aAAa,EAAEF,SAAS;MACxBG,YAAY,EAAEH;IAClB,CAAC;EACL;EAEA,OAAO;IACHI,SAAS,EAAEC,wBAAY,CAACC,oBAAoB,CAACb,KAAK,CAAC;IACnDM,WAAW,EAAEC,SAAS;IACtBC,YAAY,EAAED,SAAS;IACvBE,aAAa,EAAEF,SAAS;IACxBG,YAAY,EAAEH;EAClB,CAAC;AACL,CAAC;AAED,MAAMO,mBAAmB,GAA0Bd,KAAQ,IAA2B;EAClF,MAAMe,4BAA4B,GAAG,CACjC,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,CACrB;EAED,IAAI,CAACA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"names":["_normalizeColors","_interopRequireDefault","require","obj","__esModule","default","normalizeColor","color","opacity","arguments","length","undefined","integer","normalizeColors","hex","toString","padStart","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","exports","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","join","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["normalizer/normalizer.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAF5D;AACA;;AAUO,MAAMG,cAAc,GAAG,SAAAA,CAACC,KAAa,EAA0B;EAAA,IAAxBC,OAAe,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAC7D;EACA,IAAID,OAAO,KAAK,CAAC,EAAE;IACf,OAAOD,KAAK;EAChB;EAEA,MAAMK,OAAO,GAAG,IAAAC,wBAAe,EAACN,KAAK,CAAqB;;EAE1D;EACA,IAAIK,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOL,KAAK;EAChB;EAEA,MAAMO,GAAG,GAAGF,OAAO,CAACG,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAEjD,IAAIF,GAAG,CAACJ,MAAM,KAAK,CAAC,EAAE;IAClB,MAAM,CAACO,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,CAAC,GAAGN,GAAG,CACnCO,KAAK,CAAC,cAAc,CAAC,CACrBC,GAAG,CAACC,CAAC,IAAIC,QA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|
+
var _cssMediaQuery = require("../utils/cssMediaQuery");
|
8
|
+
// prevent recursive import
|
9
|
+
|
10
|
+
const cssMediaQueriesPlugin = exports.cssMediaQueriesPlugin = {
|
11
|
+
name: '__unistylesCSSMediaQueries',
|
12
|
+
onParsedStyle: (_key, styles, runtime) => (0, _cssMediaQuery.createMediaQueryForStyles)(styles, runtime)
|
13
|
+
};
|
14
|
+
//# sourceMappingURL=cssMediaQueriesPlugin.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_cssMediaQuery","require","cssMediaQueriesPlugin","exports","name","onParsedStyle","_key","styles","runtime","createMediaQueryForStyles"],"sourceRoot":"../../../src","sources":["plugins/cssMediaQueriesPlugin.ts"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AADA;;AAIO,MAAMC,qBAAsC,GAAAC,OAAA,CAAAD,qBAAA,GAAG;EAClDE,IAAI,EAAE,4BAA4B;EAClCC,aAAa,EAAEA,CAACC,IAAI,EAAEC,MAAM,EAAEC,OAAO,KAAK,IAAAC,wCAAyB,EAACF,MAAM,EAAEC,OAAO;AACvF,CAAC"}
|
@@ -3,22 +3,10 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
Object.defineProperty(exports, "
|
6
|
+
Object.defineProperty(exports, "cssMediaQueriesPlugin", {
|
7
7
|
enumerable: true,
|
8
8
|
get: function () {
|
9
|
-
return
|
10
|
-
}
|
11
|
-
});
|
12
|
-
Object.defineProperty(exports, "normalizeNumericValue", {
|
13
|
-
enumerable: true,
|
14
|
-
get: function () {
|
15
|
-
return _normalizer.normalizeNumericValue;
|
16
|
-
}
|
17
|
-
});
|
18
|
-
Object.defineProperty(exports, "normalizeStyle", {
|
19
|
-
enumerable: true,
|
20
|
-
get: function () {
|
21
|
-
return _normalizer.normalizeStyle;
|
9
|
+
return _cssMediaQueriesPlugin.cssMediaQueriesPlugin;
|
22
10
|
}
|
23
11
|
});
|
24
12
|
Object.defineProperty(exports, "normalizeWebStylesPlugin", {
|
@@ -27,12 +15,6 @@ Object.defineProperty(exports, "normalizeWebStylesPlugin", {
|
|
27
15
|
return _normalizeWebStylesPlugin.normalizeWebStylesPlugin;
|
28
16
|
}
|
29
17
|
});
|
30
|
-
Object.defineProperty(exports, "preprocessor", {
|
31
|
-
enumerable: true,
|
32
|
-
get: function () {
|
33
|
-
return _normalizer.preprocessor;
|
34
|
-
}
|
35
|
-
});
|
36
18
|
var _normalizeWebStylesPlugin = require("./normalizeWebStylesPlugin");
|
37
|
-
var
|
19
|
+
var _cssMediaQueriesPlugin = require("./cssMediaQueriesPlugin");
|
38
20
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_normalizeWebStylesPlugin","require","
|
1
|
+
{"version":3,"names":["_normalizeWebStylesPlugin","require","_cssMediaQueriesPlugin"],"sourceRoot":"../../../src","sources":["plugins/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,yBAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA"}
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.normalizeWebStylesPlugin = void 0;
|
7
|
-
var _normalizer = require("
|
7
|
+
var _normalizer = require("../normalizer");
|
8
8
|
const normalizeWebStylesPlugin = exports.normalizeWebStylesPlugin = {
|
9
9
|
name: '__unistylesNormalizeWebStyles',
|
10
10
|
onParsedStyle: (_key, styles) => (0, _normalizer.normalizeStyle)(styles)
|
@@ -8,6 +8,8 @@ var _react = require("react");
|
|
8
8
|
var _reactNative = require("react-native");
|
9
9
|
var _utils = require("./utils");
|
10
10
|
var _hooks = require("./hooks");
|
11
|
+
var _core = require("./core");
|
12
|
+
var _common = require("./common");
|
11
13
|
const useStyles = (stylesheet, variantsMap) => {
|
12
14
|
const {
|
13
15
|
theme,
|
@@ -26,9 +28,10 @@ const useStyles = (stylesheet, variantsMap) => {
|
|
26
28
|
}
|
27
29
|
return _reactNative.StyleSheet.create({
|
28
30
|
...acc,
|
29
|
-
[key]: (0, _utils.withPlugins)(key, (0, _utils.parseStyle)(value, variants))
|
31
|
+
[key]: (0, _utils.withPlugins)(key, (0, _utils.parseStyle)(value, variants, !_common.isWeb || !_core.unistyles.registry.config.experimentalCSSMediaQueries))
|
30
32
|
});
|
31
33
|
}, {}), [parsedStyles, variants, plugins]);
|
34
|
+
(0, _hooks.useCSS)(dynamicStyleSheet);
|
32
35
|
return {
|
33
36
|
theme,
|
34
37
|
breakpoint: layout.breakpoint,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_utils","_hooks","useStyles","stylesheet","variantsMap","theme","layout","plugins","useUnistyles","variants","useVariants","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","proxifyFunction","StyleSheet","create","withPlugins","parseStyle","breakpoint","styles","exports"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_utils","_hooks","_core","_common","useStyles","stylesheet","variantsMap","theme","layout","plugins","useUnistyles","variants","useVariants","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","proxifyFunction","StyleSheet","create","withPlugins","parseStyle","isWeb","unistyles","registry","config","experimentalCSSMediaQueries","useCSS","breakpoint","styles","exports"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAGA,IAAAI,KAAA,GAAAJ,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AAE1B,MAAM,CAAC0B,UAAU;IAC7BC,MAAM,EAAEpB;EACZ,CAAC;AACL,CAAC;AAAAqB,OAAA,CAAAhC,SAAA,GAAAA,SAAA"}
|
@@ -0,0 +1,250 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.createMediaQueryForStyles = void 0;
|
7
|
+
var _normalizer = require("../normalizer");
|
8
|
+
var _mqParser = require("./mqParser");
|
9
|
+
var _generateId = require("./generateId");
|
10
|
+
const createMediaQueryForStyles = (styles, runtime) => {
|
11
|
+
const withMediaQueries = Object.entries(styles).filter(_ref => {
|
12
|
+
let [, value] = _ref;
|
13
|
+
return typeof value === 'object';
|
14
|
+
}).reduce((acc, _ref2) => {
|
15
|
+
let [prop, value] = _ref2;
|
16
|
+
const objectKeys = Object.keys(value);
|
17
|
+
const mediaQueries = objectKeys.filter(key => (0, _mqParser.isUnistylesMq)(key));
|
18
|
+
const breakpoints = objectKeys.filter(key => runtime.breakpoints[key]);
|
19
|
+
if (mediaQueries.length === 0 && breakpoints.length === 0) {
|
20
|
+
return acc;
|
21
|
+
}
|
22
|
+
const className = (0, _generateId.generateReactNativeWebId)(prop, '""');
|
23
|
+
const breakpointsStyles = getBreakpointsStyles(prop, value, runtime, className);
|
24
|
+
const mediaQueriesStyles = getMediaQueriesFromMQ(prop, value, className);
|
25
|
+
return {
|
26
|
+
...acc,
|
27
|
+
[prop]: `
|
28
|
+
${breakpointsStyles}
|
29
|
+
${mediaQueriesStyles}
|
30
|
+
`.trim()
|
31
|
+
};
|
32
|
+
}, {});
|
33
|
+
return {
|
34
|
+
...styles,
|
35
|
+
...withMediaQueries
|
36
|
+
};
|
37
|
+
};
|
38
|
+
exports.createMediaQueryForStyles = createMediaQueryForStyles;
|
39
|
+
const getMaxWidthMediaQuery = width => {
|
40
|
+
if (!width) {
|
41
|
+
return '';
|
42
|
+
}
|
43
|
+
if (width.to === Infinity) {
|
44
|
+
return '';
|
45
|
+
}
|
46
|
+
return `and (max-width: ${width.to}px)`;
|
47
|
+
};
|
48
|
+
const getMaxHeightMediaQuery = height => {
|
49
|
+
if (!height) {
|
50
|
+
return '';
|
51
|
+
}
|
52
|
+
if (height.to === Infinity) {
|
53
|
+
return '';
|
54
|
+
}
|
55
|
+
return `and (max-height: ${height.to}px)`;
|
56
|
+
};
|
57
|
+
const getMediaQueriesFromMQ = (prop, value, className) => Object.entries(value).reduce((acc, _ref3) => {
|
58
|
+
let [key, value] = _ref3;
|
59
|
+
const result = (0, _mqParser.parseMq)(key);
|
60
|
+
if (!(0, _mqParser.isValidMq)(result)) {
|
61
|
+
return acc;
|
62
|
+
}
|
63
|
+
if (result.width && result.height) {
|
64
|
+
return `${acc}
|
65
|
+
|
66
|
+
@media screen and (min-width: ${result.width.from}px) and (min-height: ${result.height.from}px) ${getMaxWidthMediaQuery(result.width)} ${getMaxHeightMediaQuery(result.height)} {
|
67
|
+
.${className} {
|
68
|
+
${normalizePropName(prop)}: ${normalizeWebValue(prop, value)};
|
69
|
+
}
|
70
|
+
}
|
71
|
+
`;
|
72
|
+
}
|
73
|
+
if (result.width) {
|
74
|
+
return `${acc}
|
75
|
+
|
76
|
+
@media screen and (min-width: ${result.width.from}px) ${getMaxWidthMediaQuery(result.width)} {
|
77
|
+
.${className} {
|
78
|
+
${normalizePropName(prop)}: ${normalizeWebValue(prop, value)};
|
79
|
+
}
|
80
|
+
}
|
81
|
+
`;
|
82
|
+
}
|
83
|
+
if (result.height) {
|
84
|
+
return `${acc}
|
85
|
+
|
86
|
+
@media screen and (min-height: ${result.height.from}px) ${getMaxHeightMediaQuery(result.height)} {
|
87
|
+
.${className} {
|
88
|
+
${normalizePropName(prop)}: ${normalizeWebValue(prop, value)};
|
89
|
+
}
|
90
|
+
}
|
91
|
+
`;
|
92
|
+
}
|
93
|
+
return acc;
|
94
|
+
}, '');
|
95
|
+
const getBreakpointsStyles = (prop, value, runtime, className) => Object.entries(value).reduce((acc, _ref4) => {
|
96
|
+
let [key, value] = _ref4;
|
97
|
+
const breakpoint = runtime.breakpoints[key];
|
98
|
+
if (breakpoint === undefined) {
|
99
|
+
return acc;
|
100
|
+
}
|
101
|
+
return `${acc}
|
102
|
+
|
103
|
+
@media screen and (min-width: ${breakpoint}px) {
|
104
|
+
.${className} {
|
105
|
+
${normalizePropName(prop)}: ${normalizeWebValue(prop, value)};
|
106
|
+
}
|
107
|
+
}
|
108
|
+
`;
|
109
|
+
}, '');
|
110
|
+
const normalizePropName = prop => prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
111
|
+
const normalizeWebValue = (prop, value) => {
|
112
|
+
if (value === undefined) {
|
113
|
+
return 'unset';
|
114
|
+
}
|
115
|
+
switch (prop) {
|
116
|
+
// colors
|
117
|
+
case 'color':
|
118
|
+
case 'backgroundColor':
|
119
|
+
case 'borderColor':
|
120
|
+
case 'borderBottomColor':
|
121
|
+
case 'borderLeftColor':
|
122
|
+
case 'borderRightColor':
|
123
|
+
case 'borderTopColor':
|
124
|
+
case 'borderBlockColor':
|
125
|
+
case 'borderBlockEndColor':
|
126
|
+
case 'borderBlockStartColor':
|
127
|
+
case 'textDecorationColor':
|
128
|
+
return (0, _normalizer.normalizeColor)(value);
|
129
|
+
|
130
|
+
// dimensions
|
131
|
+
case 'width':
|
132
|
+
case 'height':
|
133
|
+
case 'minWidth':
|
134
|
+
case 'minHeight':
|
135
|
+
case 'maxWidth':
|
136
|
+
case 'maxHeight':
|
137
|
+
case 'borderRadius':
|
138
|
+
case 'borderWidth':
|
139
|
+
case 'borderBottomLeftRadius':
|
140
|
+
case 'borderBottomRightRadius':
|
141
|
+
case 'borderEndEndRadius':
|
142
|
+
case 'borderEndStartRadius':
|
143
|
+
case 'borderStartEndRadius':
|
144
|
+
case 'borderStartStartRadius':
|
145
|
+
case 'borderTopLeftRadius':
|
146
|
+
case 'borderTopRightRadius':
|
147
|
+
case 'borderBottomWidth':
|
148
|
+
case 'borderLeftWidth':
|
149
|
+
case 'borderRightWidth':
|
150
|
+
case 'borderTopWidth':
|
151
|
+
case 'bottom':
|
152
|
+
case 'left':
|
153
|
+
case 'right':
|
154
|
+
case 'top':
|
155
|
+
case 'marginTop':
|
156
|
+
case 'marginBottom':
|
157
|
+
case 'marginLeft':
|
158
|
+
case 'marginRight':
|
159
|
+
case 'paddingTop':
|
160
|
+
case 'paddingBottom':
|
161
|
+
case 'paddingLeft':
|
162
|
+
case 'paddingRight':
|
163
|
+
case 'flexBasis':
|
164
|
+
case 'rowGap':
|
165
|
+
case 'columnGap':
|
166
|
+
case 'gap':
|
167
|
+
case 'margin':
|
168
|
+
case 'padding':
|
169
|
+
case 'fontSize':
|
170
|
+
case 'letterSpacing':
|
171
|
+
return `${value}px`;
|
172
|
+
|
173
|
+
// without unit
|
174
|
+
case 'borderStyle':
|
175
|
+
case 'pointerEvents':
|
176
|
+
case 'backfaceVisibility':
|
177
|
+
case 'alignContent':
|
178
|
+
case 'alignItems':
|
179
|
+
case 'alignSelf':
|
180
|
+
case 'flexDirection':
|
181
|
+
case 'flexWrap':
|
182
|
+
case 'flex':
|
183
|
+
case 'aspectRatio':
|
184
|
+
case 'opacity':
|
185
|
+
case 'direction':
|
186
|
+
case 'zIndex':
|
187
|
+
case 'justifyContent':
|
188
|
+
case 'overflow':
|
189
|
+
case 'display':
|
190
|
+
case 'position':
|
191
|
+
case 'flexGrow':
|
192
|
+
case 'flexShrink':
|
193
|
+
case 'fontFamily':
|
194
|
+
case 'fontStyle':
|
195
|
+
case 'textDecorationLine':
|
196
|
+
case 'textAlign':
|
197
|
+
case 'textDecorationStyle':
|
198
|
+
case 'lineHeight':
|
199
|
+
case 'textTransform':
|
200
|
+
case 'fontVariant':
|
201
|
+
case 'verticalAlign':
|
202
|
+
case 'objectFit':
|
203
|
+
return value;
|
204
|
+
|
205
|
+
// to be transformed for now
|
206
|
+
// not supported
|
207
|
+
case 'marginHorizontal':
|
208
|
+
case 'paddingHorizontal':
|
209
|
+
case 'marginVertical':
|
210
|
+
case 'paddingVertical':
|
211
|
+
case 'shadowColor':
|
212
|
+
case 'shadowOffset':
|
213
|
+
case 'shadowOpacity':
|
214
|
+
case 'shadowRadius':
|
215
|
+
case 'transform':
|
216
|
+
case 'transformMatrix':
|
217
|
+
case 'fontWeight':
|
218
|
+
case 'textShadowOffset':
|
219
|
+
case 'textShadowRadius':
|
220
|
+
case 'textShadowColor':
|
221
|
+
return '';
|
222
|
+
|
223
|
+
// unsupported
|
224
|
+
case 'borderStartColor':
|
225
|
+
case 'borderEndColor':
|
226
|
+
case 'borderEndWidth':
|
227
|
+
case 'borderBottomEndRadius':
|
228
|
+
case 'borderBottomStartRadius':
|
229
|
+
case 'borderCurve':
|
230
|
+
case 'elevation':
|
231
|
+
case 'borderTopEndRadius':
|
232
|
+
case 'borderTopStartRadius':
|
233
|
+
case 'borderStartWidth':
|
234
|
+
case 'start':
|
235
|
+
case 'end':
|
236
|
+
case 'margin-end':
|
237
|
+
case 'margin-start':
|
238
|
+
case 'padding-end':
|
239
|
+
case 'padding-start':
|
240
|
+
case 'writingDirection':
|
241
|
+
case 'textAlignVertical':
|
242
|
+
case 'includeFontPadding':
|
243
|
+
case 'resizeMode':
|
244
|
+
case 'overlayColor':
|
245
|
+
case 'tintColor':
|
246
|
+
default:
|
247
|
+
return '';
|
248
|
+
}
|
249
|
+
};
|
250
|
+
//# sourceMappingURL=cssMediaQuery.js.map
|