react-native-unistyles 2.0.0-rc.1 → 2.0.0-rc.2
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/core/UnistyleRegistry.js +15 -25
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.js +187 -2
- package/lib/commonjs/core/UnistylesModule.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.native.js +9 -0
- package/lib/commonjs/core/UnistylesModule.native.js.map +1 -0
- package/lib/commonjs/hooks/useCSS.js +36 -1
- package/lib/commonjs/hooks/useCSS.js.map +1 -1
- package/lib/commonjs/hooks/useCSS.native.js +9 -0
- package/lib/commonjs/hooks/useCSS.native.js.map +1 -0
- package/lib/commonjs/normalizer/normalizer.js +1 -2
- package/lib/commonjs/normalizer/normalizer.js.map +1 -1
- package/lib/commonjs/useStyles.js +1 -2
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js +2 -11
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/cssMediaQuery.js +3 -9
- package/lib/commonjs/utils/cssMediaQuery.js.map +1 -1
- package/lib/commonjs/utils/mq.js +12 -36
- package/lib/commonjs/utils/mq.js.map +1 -1
- package/lib/commonjs/utils/mqParser.js +1 -2
- package/lib/commonjs/utils/mqParser.js.map +1 -1
- package/lib/commonjs/utils/styles.js +34 -39
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/module/core/UnistyleRegistry.js +15 -25
- package/lib/module/core/UnistyleRegistry.js.map +1 -1
- package/lib/module/core/UnistylesModule.js +186 -2
- package/lib/module/core/UnistylesModule.js.map +1 -1
- package/lib/module/core/UnistylesModule.native.js +3 -0
- package/lib/module/core/UnistylesModule.native.js.map +1 -0
- package/lib/module/hooks/useCSS.js +36 -1
- package/lib/module/hooks/useCSS.js.map +1 -1
- package/lib/module/hooks/useCSS.native.js +2 -0
- package/lib/module/hooks/useCSS.native.js.map +1 -0
- package/lib/module/normalizer/normalizer.js +1 -2
- package/lib/module/normalizer/normalizer.js.map +1 -1
- package/lib/module/useStyles.js +1 -2
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/breakpoints.js +2 -11
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/cssMediaQuery.js +3 -9
- package/lib/module/utils/cssMediaQuery.js.map +1 -1
- package/lib/module/utils/mq.js +12 -36
- package/lib/module/utils/mq.js.map +1 -1
- package/lib/module/utils/mqParser.js +1 -2
- package/lib/module/utils/mqParser.js.map +1 -1
- package/lib/module/utils/styles.js +34 -39
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.d.ts +17 -4
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.native.d.ts +6 -0
- package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCSS.d.ts +1 -1
- package/lib/typescript/src/hooks/useCSS.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCSS.native.d.ts +3 -0
- package/lib/typescript/src/hooks/useCSS.native.d.ts.map +1 -0
- package/package.json +6 -8
- package/src/core/UnistylesModule.native.ts +7 -0
- package/src/core/UnistylesModule.ts +224 -4
- package/src/hooks/useCSS.native.ts +3 -0
- package/src/hooks/useCSS.ts +49 -1
- package/lib/commonjs/core/UnistylesModule.web.js +0 -199
- package/lib/commonjs/core/UnistylesModule.web.js.map +0 -1
- package/lib/commonjs/hooks/useCSS.web.js +0 -46
- package/lib/commonjs/hooks/useCSS.web.js.map +0 -1
- package/lib/module/core/UnistylesModule.web.js +0 -192
- package/lib/module/core/UnistylesModule.web.js.map +0 -1
- package/lib/module/hooks/useCSS.web.js +0 -39
- package/lib/module/hooks/useCSS.web.js.map +0 -1
- package/lib/typescript/src/core/UnistylesModule.web.d.ts +0 -19
- package/lib/typescript/src/core/UnistylesModule.web.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useCSS.web.d.ts +0 -3
- package/lib/typescript/src/hooks/useCSS.web.d.ts.map +0 -1
- package/src/core/UnistylesModule.web.ts +0 -227
- package/src/hooks/useCSS.web.ts +0 -51
@@ -67,35 +67,25 @@ class UnistyleRegistry {
|
|
67
67
|
}
|
68
68
|
throw new Error(_common.UnistylesError.ThemeNotSelected);
|
69
69
|
};
|
70
|
-
addPlugin = (
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
})) {
|
83
|
-
throw new Error(_common.UnistylesError.DuplicatePluginName);
|
84
|
-
}
|
85
|
-
_this.plugins = [plugin].concat(_this.plugins);
|
86
|
-
_this.unistylesBridge.addPlugin(plugin.name, notify);
|
87
|
-
};
|
88
|
-
})();
|
70
|
+
addPlugin = (plugin, notify = true) => {
|
71
|
+
if (plugin.name.startsWith('__unistyles')) {
|
72
|
+
throw new Error(_common.UnistylesError.InvalidPluginName);
|
73
|
+
}
|
74
|
+
if (this.plugins.some(({
|
75
|
+
name
|
76
|
+
}) => name === plugin.name)) {
|
77
|
+
throw new Error(_common.UnistylesError.DuplicatePluginName);
|
78
|
+
}
|
79
|
+
this.plugins = [plugin].concat(this.plugins);
|
80
|
+
this.unistylesBridge.addPlugin(plugin.name, notify);
|
81
|
+
};
|
89
82
|
removePlugin = plugin => {
|
90
83
|
if (plugin.name.startsWith('__unistyles')) {
|
91
84
|
throw new Error(_common.UnistylesError.CantRemoveInternalPlugin);
|
92
85
|
}
|
93
|
-
this.plugins = this.plugins.filter(
|
94
|
-
|
95
|
-
|
96
|
-
} = _ref2;
|
97
|
-
return name !== plugin.name;
|
98
|
-
});
|
86
|
+
this.plugins = this.plugins.filter(({
|
87
|
+
name
|
88
|
+
}) => name !== plugin.name);
|
99
89
|
this.unistylesBridge.removePlugin(plugin.name);
|
100
90
|
};
|
101
91
|
hasTheme = name => name in this.themes;
|
@@ -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","forEach","plugin","addPlugin","initialTheme","useTheme","experimentalCSSMediaQueries","cssMediaQueriesPlugin","concat","name","getTheme","forName","length","hasTheme","themeName","Error","UnistylesError","ThemeNotFound","ThemeNotSelected","
|
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","notify","startsWith","InvalidPluginName","some","DuplicatePluginName","removePlugin","CantRemoveInternalPlugin","filter","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,IA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C;IAC5D;IAEA,IAAI,CAACzC,OAAO,GAAG,IAAI,CAACA,OAAO,CAAC0C,MAAM,CAAC,CAAC;MAAEjB;IAAK,CAAC,KAAKA,IAAI,KAAKP,MAAM,CAACO,IAAI,CAAC;IACtE,IAAI,CAACjB,eAAe,CAACgC,YAAY,CAACtB,MAAM,CAACO,IAAI,CAAC;EAClD,CAAC;EAEMI,QAAQ,GAAIJ,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAACrB,MAAM;AAC1E;AAACuC,OAAA,CAAA7C,gBAAA,GAAAA,gBAAA"}
|
@@ -3,7 +3,192 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.UnistylesModule = void 0;
|
6
|
+
exports.UnistylesModule = exports.UnistylesBridgeWeb = void 0;
|
7
7
|
var _reactNative = require("react-native");
|
8
|
-
|
8
|
+
var _plugins = require("../plugins");
|
9
|
+
var _common = require("../common");
|
10
|
+
class UnistylesBridgeWeb {
|
11
|
+
#timerRef = undefined;
|
12
|
+
#hasAdaptiveThemes = false;
|
13
|
+
#supportsAutomaticColorScheme = false;
|
14
|
+
#screenWidth = _common.isServer ? undefined : window.innerWidth;
|
15
|
+
#screenHeight = _common.isServer ? undefined : window.innerHeight;
|
16
|
+
#themes = [];
|
17
|
+
#breakpoints = {};
|
18
|
+
#colorScheme = this.getPreferredColorScheme();
|
19
|
+
#themeName = '';
|
20
|
+
#enabledPlugins = [_plugins.normalizeWebStylesPlugin.name];
|
21
|
+
#unistylesEvents = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.Unistyles);
|
22
|
+
#sortedBreakpointPairs = [];
|
23
|
+
#breakpoint = '';
|
24
|
+
constructor() {
|
25
|
+
if (!_common.isServer) {
|
26
|
+
this.setupListeners();
|
27
|
+
this.#screenWidth = window.innerWidth;
|
28
|
+
this.#screenHeight = window.innerHeight;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
install() {
|
32
|
+
// @ts-ignore
|
33
|
+
// eslint-disable-next-line no-undef
|
34
|
+
globalThis.__UNISTYLES__ = new Proxy({}, {
|
35
|
+
get: (_target, prop) => {
|
36
|
+
switch (prop) {
|
37
|
+
case 'themeName':
|
38
|
+
return this.getTheme();
|
39
|
+
case 'screenWidth':
|
40
|
+
return this.#screenWidth;
|
41
|
+
case 'screenHeight':
|
42
|
+
return this.#screenHeight;
|
43
|
+
case 'breakpoint':
|
44
|
+
return this.#breakpoint || undefined;
|
45
|
+
case 'breakpoints':
|
46
|
+
return this.#breakpoints;
|
47
|
+
case 'hasAdaptiveThemes':
|
48
|
+
return this.#hasAdaptiveThemes;
|
49
|
+
case 'sortedBreakpointPairs':
|
50
|
+
return this.#sortedBreakpointPairs;
|
51
|
+
case 'enabledPlugins':
|
52
|
+
return this.#enabledPlugins;
|
53
|
+
case 'colorScheme':
|
54
|
+
return this.#colorScheme;
|
55
|
+
case 'useTheme':
|
56
|
+
return themeName => this.useTheme(themeName);
|
57
|
+
case 'useBreakpoints':
|
58
|
+
return breakpoints => this.useBreakpoints(breakpoints);
|
59
|
+
case 'useAdaptiveThemes':
|
60
|
+
return enable => this.useAdaptiveThemes(enable);
|
61
|
+
case 'addPlugin':
|
62
|
+
return (pluginName, notify) => this.addPlugin(pluginName, notify);
|
63
|
+
case 'removePlugin':
|
64
|
+
return pluginName => this.removePlugin(pluginName);
|
65
|
+
default:
|
66
|
+
return Reflect.get(this, prop);
|
67
|
+
}
|
68
|
+
},
|
69
|
+
set: (target, prop, newValue, receiver) => {
|
70
|
+
switch (prop) {
|
71
|
+
case 'themes':
|
72
|
+
{
|
73
|
+
this.#themes = newValue;
|
74
|
+
this.#supportsAutomaticColorScheme = newValue.includes('light') && newValue.includes('dark');
|
75
|
+
return true;
|
76
|
+
}
|
77
|
+
case 'themeName':
|
78
|
+
{
|
79
|
+
this.#themeName = newValue;
|
80
|
+
this.emitThemeChange();
|
81
|
+
return true;
|
82
|
+
}
|
83
|
+
default:
|
84
|
+
return Reflect.set(target, prop, newValue, receiver);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
});
|
88
|
+
return true;
|
89
|
+
}
|
90
|
+
useTheme(themeName) {
|
91
|
+
this.#themeName = themeName;
|
92
|
+
this.emitThemeChange();
|
93
|
+
}
|
94
|
+
useBreakpoints(breakpoints) {
|
95
|
+
this.#breakpoints = breakpoints;
|
96
|
+
this.#sortedBreakpointPairs = Object.entries(breakpoints).sort(([, a], [, b]) => (a ?? 0) - (b ?? 0));
|
97
|
+
if (!_common.isServer) {
|
98
|
+
this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
useAdaptiveThemes(enable) {
|
102
|
+
this.#hasAdaptiveThemes = enable;
|
103
|
+
if (!this.#hasAdaptiveThemes || !this.#supportsAutomaticColorScheme) {
|
104
|
+
return;
|
105
|
+
}
|
106
|
+
if (this.#themeName !== this.#colorScheme) {
|
107
|
+
this.#themeName = this.#colorScheme;
|
108
|
+
this.emitThemeChange();
|
109
|
+
}
|
110
|
+
}
|
111
|
+
addPlugin(pluginName, notify) {
|
112
|
+
this.#enabledPlugins = [pluginName].concat(this.#enabledPlugins);
|
113
|
+
if (notify) {
|
114
|
+
this.emitPluginChange();
|
115
|
+
}
|
116
|
+
}
|
117
|
+
removePlugin(pluginName) {
|
118
|
+
this.#enabledPlugins = this.#enabledPlugins.filter(name => name !== pluginName);
|
119
|
+
this.emitPluginChange();
|
120
|
+
}
|
121
|
+
getTheme() {
|
122
|
+
if (this.#themes.length === 1) {
|
123
|
+
return this.#themes.at(0);
|
124
|
+
}
|
125
|
+
return this.#themeName;
|
126
|
+
}
|
127
|
+
setupListeners() {
|
128
|
+
window.addEventListener('resize', () => {
|
129
|
+
clearTimeout(this.#timerRef);
|
130
|
+
this.#timerRef = setTimeout(() => {
|
131
|
+
this.#screenWidth = window.innerWidth;
|
132
|
+
this.#screenHeight = window.innerHeight;
|
133
|
+
this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
|
134
|
+
this.emitLayoutChange();
|
135
|
+
}, 100);
|
136
|
+
});
|
137
|
+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
138
|
+
this.#colorScheme = event.matches ? 'dark' : 'light';
|
139
|
+
if (!this.#supportsAutomaticColorScheme || !this.#hasAdaptiveThemes) {
|
140
|
+
return;
|
141
|
+
}
|
142
|
+
if (this.#colorScheme !== this.#themeName) {
|
143
|
+
this.#themeName = this.#colorScheme;
|
144
|
+
this.emitThemeChange();
|
145
|
+
}
|
146
|
+
});
|
147
|
+
}
|
148
|
+
getBreakpointFromScreenWidth(width) {
|
149
|
+
const breakpoint = this.#sortedBreakpointPairs.find(([, value], index, otherBreakpoints) => {
|
150
|
+
const minVal = value;
|
151
|
+
const maxVal = otherBreakpoints[index + 1]?.[1];
|
152
|
+
if (!maxVal) {
|
153
|
+
return true;
|
154
|
+
}
|
155
|
+
return width >= minVal && width < maxVal;
|
156
|
+
});
|
157
|
+
return breakpoint?.at(0);
|
158
|
+
}
|
159
|
+
getPreferredColorScheme() {
|
160
|
+
if (!_common.isServer && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
161
|
+
return 'dark';
|
162
|
+
}
|
163
|
+
return 'light';
|
164
|
+
}
|
165
|
+
emitPluginChange() {
|
166
|
+
this.#unistylesEvents.emit('__unistylesOnChange', {
|
167
|
+
type: 'plugin'
|
168
|
+
});
|
169
|
+
}
|
170
|
+
emitThemeChange() {
|
171
|
+
this.#unistylesEvents.emit('__unistylesOnChange', {
|
172
|
+
type: 'theme',
|
173
|
+
payload: {
|
174
|
+
themeName: this.#themeName
|
175
|
+
}
|
176
|
+
});
|
177
|
+
}
|
178
|
+
emitLayoutChange() {
|
179
|
+
this.#unistylesEvents.emit('__unistylesOnChange', {
|
180
|
+
type: 'layout',
|
181
|
+
payload: {
|
182
|
+
breakpoint: this.#breakpoint,
|
183
|
+
orientation: this.#screenWidth > this.#screenHeight ? 'landscape' : 'portrait',
|
184
|
+
screen: {
|
185
|
+
width: this.#screenWidth,
|
186
|
+
height: this.#screenHeight
|
187
|
+
}
|
188
|
+
}
|
189
|
+
});
|
190
|
+
}
|
191
|
+
}
|
192
|
+
exports.UnistylesBridgeWeb = UnistylesBridgeWeb;
|
193
|
+
const UnistylesModule = exports.UnistylesModule = new UnistylesBridgeWeb();
|
9
194
|
//# sourceMappingURL=UnistylesModule.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","
|
1
|
+
{"version":3,"names":["_reactNative","require","_plugins","_common","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","isServer","window","innerWidth","screenHeight","innerHeight","themes","breakpoints","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","normalizeWebStylesPlugin","name","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","sortedBreakpointPairs","breakpoint","constructor","setupListeners","install","globalThis","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","useBreakpoints","enable","useAdaptiveThemes","pluginName","notify","addPlugin","removePlugin","Reflect","set","target","newValue","receiver","includes","emitThemeChange","Object","entries","sort","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","width","find","value","index","otherBreakpoints","minVal","maxVal","emit","type","payload","orientation","screen","height","exports","UnistylesModule"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEO,MAAMG,kBAAkB,CAAC;EAC5B,CAACC,QAAQ,GAAmCC,SAAS;EACrD,CAACC,iBAAiB,GAAY,KAAK;EACnC,CAACC,4BAA4B,GAAG,KAAK;EACrC,CAACC,WAAW,GAAGC,gBAAQ,GAAGJ,SAAS,GAAGK,MAAM,CAACC,UA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I,CAAC,qBAAqB,EAAE;MAC9CC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE;QACLrD,UAAU,EAAE,IAAI,CAAC,CAACA,UAAU;QAC5BsD,WAAW,EAAG,IAAI,CAAC,CAACzE,WAAW,GAAe,IAAI,CAAC,CAACI,YAAuB,GACrE,WAAW,GACX,UAAU;QAChBsE,MAAM,EAAE;UACJX,KAAK,EAAE,IAAI,CAAC,CAAC/D,WAAW;UACxB2E,MAAM,EAAE,IAAI,CAAC,CAACvE;QAClB;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAACwE,OAAA,CAAAjF,kBAAA,GAAAA,kBAAA;AAEM,MAAMkF,eAAe,GAAAD,OAAA,CAAAC,eAAA,GAAG,IAAIlF,kBAAkB,CAAC,CAAC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.UnistylesModule = void 0;
|
7
|
+
var _reactNative = require("react-native");
|
8
|
+
const UnistylesModule = exports.UnistylesModule = _reactNative.NativeModules?.Unistyles;
|
9
|
+
//# sourceMappingURL=UnistylesModule.native.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_reactNative","require","UnistylesModule","exports","NativeModules","Unistyles"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.native.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMO,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAGE,0BAAa,EAAEC,SAAkC"}
|
@@ -4,6 +4,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.useCSS = void 0;
|
7
|
-
|
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(([_key, value]) => {
|
17
|
+
Object.entries(value).forEach(([prop, val]) => {
|
18
|
+
if (!val.toString().includes('@media')) {
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
const id = (0, _utils.generateReactNativeWebId)(prop, '""');
|
22
|
+
if (insertedIds.current.includes(id)) {
|
23
|
+
return;
|
24
|
+
}
|
25
|
+
const style = document.createElement('style');
|
26
|
+
style.id = id;
|
27
|
+
style.innerHTML = val;
|
28
|
+
document.head.appendChild(style);
|
29
|
+
insertedIds.current = [...insertedIds.current, id];
|
30
|
+
});
|
31
|
+
});
|
32
|
+
return () => {
|
33
|
+
insertedIds.current.forEach(id => {
|
34
|
+
const style = document.getElementById(id);
|
35
|
+
if (style) {
|
36
|
+
style.remove();
|
37
|
+
}
|
38
|
+
});
|
39
|
+
insertedIds.current = [];
|
40
|
+
};
|
41
|
+
}, [stylesheet]);
|
42
|
+
};
|
8
43
|
exports.useCSS = useCSS;
|
9
44
|
//# sourceMappingURL=useCSS.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useCSS","
|
1
|
+
{"version":3,"names":["_react","require","_core","_utils","useCSS","stylesheet","insertedIds","useRef","useInsertionEffect","unistyles","registry","config","experimentalCSSMediaQueries","Object","entries","forEach","_key","value","prop","val","toString","includes","id","generateReactNativeWebId","current","style","document","createElement","innerHTML","head","appendChild","getElementById","remove","exports"],"sourceRoot":"../../../src","sources":["hooks/useCSS.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;EA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;AAAA4B,OAAA,CAAA7B,MAAA,GAAAA,MAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["useCSS","_stylesheet","exports"],"sourceRoot":"../../../src","sources":["hooks/useCSS.native.ts"],"mappings":";;;;;;AAEO,MAAMA,MAAM,GAAOC,WAAqC,IAAW,CAAC,CAAC;AAAAC,OAAA,CAAAF,MAAA,GAAAA,MAAA"}
|
@@ -9,8 +9,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
9
9
|
// based on react-native-web normalizer
|
10
10
|
// https://github.com/necolas/react-native-web
|
11
11
|
|
12
|
-
const normalizeColor =
|
13
|
-
let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
12
|
+
const normalizeColor = (color, opacity = 1) => {
|
14
13
|
// If the opacity is 1 there's no need to normalize the color
|
15
14
|
if (opacity === 1) {
|
16
15
|
return color;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_normalizeColors","_interopRequireDefault","require","obj","__esModule","default","normalizeColor","color","opacity","
|
1
|
+
{"version":3,"names":["_normalizeColors","_interopRequireDefault","require","obj","__esModule","default","normalizeColor","color","opacity","integer","normalizeColors","hex","toString","padStart","length","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","undefined","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,GAAGA,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S,CAACnB,GAAG,CAA2B;EAEtD,QAAOA,GAAG;IACN,KAAK,QAAQ;IACb,KAAK,UAAU;MACX,OAAQ,GAAEA,GAAI,IAAIF,KAAK,CAAmByB,IAAI,CAAC,GAAG,CAAE,GAAE;IAC1D;MACI,OAAQ,GAAEvB,GAAI,IAAGD,kBAAkB,CAACC,GAAG,EAAEF,KAAK,CAAE,GAAE;EAC1D;AACJ,CAAC,CAAC,CACDL,MAAM,CAAC+B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEP,MAAME,YAA0B,GAAA7B,OAAA,CAAA6B,YAAA,GAAG;EACtCvB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
|
@@ -24,8 +24,7 @@ const useStyles = (stylesheet, variantsMap) => {
|
|
24
24
|
} = (0, _hooks.useUnistyles)();
|
25
25
|
const variants = (0, _hooks.useVariants)(variantsMap);
|
26
26
|
const parsedStyles = (0, _react.useMemo)(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet, layout]);
|
27
|
-
const dynamicStyleSheet = (0, _react.useMemo)(() => Object.entries(parsedStyles || {}).reduce((acc,
|
28
|
-
let [key, value] = _ref;
|
27
|
+
const dynamicStyleSheet = (0, _react.useMemo)(() => Object.entries(parsedStyles || {}).reduce((acc, [key, value]) => {
|
29
28
|
if (typeof value === 'function') {
|
30
29
|
return {
|
31
30
|
...acc,
|
@@ -1 +1 @@
|
|
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","
|
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","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,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAQA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMM,SAAS,GAAGA,CACrBC,UAAe,EACfC,WAAoD,KAC7B;EACvB,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAG,IAAAC,mBAAY,EAAC,CAAC;EACjD,MAAMC,QAAQ,GAAG,IAAAC,kBAAW,EAACN,WAAW,CAAC;EACzC,MAAMO,YAAY,GAAG,IAAAC,cAAO,EAAC,MAAM,OAAOT,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACE,KAAK,CAAC,GACjBF,UAAU,EAAE,CAACE,KAAK,EAAEF,UAAU,EAAEG,MAAM,CAAC,CAAC;EAE9C,MAAMO,iBAAiB,GAAG,IAAAD,cAAO,EAAC,MAAME,MAAM,CACzCC,OAAO,CAACJ,YAAY,IAAI,CAAC,CAAC,CAAC,CAC3BK,MAAM,CAAC,CAACC,GAAG,EAAE,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;IAC3B,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGF,GAAG;QACN,CAACC,GAAG,GAAG,IAAAE,sBAAe,EAACF,GAAG,EAAEC,KAAK;MACrC,CAAC;IACL;IAEA,OAAOE,uBAAU,CAACC,MAAM,CAAC;MACrB,GAAGL,GAAG;MACN,CAACC,GAAG,GAAG,IAAAK,kBAAW,EAACL,GAAG,EAAE,IAAAM,iBAAU,EAC9BL,KAAK,EACLV,QAAQ,EACR,CAACgB,aAAK,IAAI,CAACC,eAAS,CAACC,QAAQ,CAACC,MAAM,CAACC,2BAA2B,CACpE;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAClB,YAAY,EAAEF,QAAQ,EAAEF,OAAO,CAC5C,CAAC;EAED,IAAAuB,aAAM,EAACjB,iBAA8C,CAAC;EAEtD,OAAO;IACHR,KAAK;IACL0B,UAAU,EAAEzB,MAAM,CAACyB,UAAU;IAC7BC,MAAM,EAAEnB;EACZ,CAAC;AACL,CAAC;AAAAoB,OAAA,CAAA/B,SAAA,GAAAA,SAAA"}
|
@@ -25,17 +25,8 @@ const getValueForBreakpoint = value => {
|
|
25
25
|
return directBreakpoint;
|
26
26
|
}
|
27
27
|
const breakpointPairs = _core.unistyles.registry.sortedBreakpointPairs;
|
28
|
-
const currentBreakpointIndex = breakpointPairs.findIndex(
|
29
|
-
|
30
|
-
return key === breakpoint;
|
31
|
-
});
|
32
|
-
const availableBreakpoints = breakpointPairs.filter((_ref2, index) => {
|
33
|
-
let [key] = _ref2;
|
34
|
-
return index < currentBreakpointIndex && key in value;
|
35
|
-
}).map(_ref3 => {
|
36
|
-
let [key] = _ref3;
|
37
|
-
return key;
|
38
|
-
});
|
28
|
+
const currentBreakpointIndex = breakpointPairs.findIndex(([key]) => key === breakpoint);
|
29
|
+
const availableBreakpoints = breakpointPairs.filter(([key], index) => index < currentBreakpointIndex && key in value).map(([key]) => key);
|
39
30
|
return value[availableBreakpoints[availableBreakpoints.length - 1]];
|
40
31
|
};
|
41
32
|
exports.getValueForBreakpoint = getValueForBreakpoint;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_core","require","_common","_mqParser","getValueForBreakpoint","value","customMediaQueryKey","getKeyForUnistylesMediaQuery","Object","entries","unistyles","runtime","screen","hasBreakpoints","registry","sortedBreakpointPairs","length","isMobile","ScreenOrientation","Landscape","Portrait","orientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpointIndex","findIndex","
|
1
|
+
{"version":3,"names":["_core","require","_common","_mqParser","getValueForBreakpoint","value","customMediaQueryKey","getKeyForUnistylesMediaQuery","Object","entries","unistyles","runtime","screen","hasBreakpoints","registry","sortedBreakpointPairs","length","isMobile","ScreenOrientation","Landscape","Portrait","orientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpointIndex","findIndex","key","availableBreakpoints","filter","index","map","exports"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEO,MAAMG,qBAAqB,GAAIC,KAA8B,IAAwB;EACxF,MAAMC,mBAAmB,GAAG,IAAAC,sCAA4B,EACpDC,MAAM,CAACC,OAAO,CAACJ,KAAK,CAAC,EACrBK,eAAS,CAACC,OAAO,CAACC,MACtB,CAAuB;EAEvB,IAAIN,mBAAmB,EAAE;IACrB,OAAOD,KAAK,CAACC,mBAAmB,CAAC;EACrC;EAEA,MAAMO,cAAc,GAAGH,eAAS,CAACI,QAAQ,CAACC,qBAAqB,CAACC,MAAM,GAAG,CAAC;EAE1E,IAAI,CAACH,cAAc,IAAII,gBAAQ,KAAKC,yBAAiB,CAACC,SAAS,IAAId,KAAK,IAAIa,yBAAiB,CAACE,QAAQ,IAAIf,KAAK,CAAC,EAAE;IAC9G,OAAOA,KAAK,CAACK,eAAS,CAACC,OAAO,CAACU,WAAW,CAAC;EAC/C;EAEA,MAAMC,UAAU,GAAGZ,eAAS,CAACC,OAAO,CAACW,UAAU;EAE/C,IAAI,CAACA,UAAU,EAAE;IACb,OAAOC,SAAS;EACpB;EAEA,MAAMC,gBAAgB,GAAGnB,KAAK,CAACiB,UAAU,CAAC;EAE1C,IAAIE,gBAAgB,IAAKF,UAAU,IAAIjB,KAAM,EAAE;IAC3C,OAAOmB,gBAAgB;EAC3B;EAEA,MAAMC,eAAe,GAAGf,eAAS,CAACI,QAAQ,CAACC,qBAAqB;EAChE,MAAMW,sBAAsB,GAAGD,eAAe,CACzCE,SAAS,CAAC,CAAC,CAACC,GAAG,CAAC,KAAKA,GAAG,KAAKN,UAAU,CAAC;EAE7C,MAAMO,oBAAoB,GAAGJ,eAAe,CACvCK,MAAM,CAAC,CAAC,CAACF,GAAG,CAAC,EAAEG,KAAK,KAAKA,KAAK,GAAGL,sBAAsB,IAAIE,GAAG,IAAIvB,KAAK,CAAC,CACxE2B,GAAG,CAAC,CAAC,CAACJ,GAAG,CAAC,KAAKA,GAAG,CAAC;EAExB,OAAOvB,KAAK,CAACwB,oBAAoB,CAACA,oBAAoB,CAACb,MAAM,GAAG,CAAC,CAAC,CAAwC;AAC9G,CAAC;AAAAiB,OAAA,CAAA7B,qBAAA,GAAAA,qBAAA"}
|
@@ -8,11 +8,7 @@ var _normalizer = require("../normalizer");
|
|
8
8
|
var _mqParser = require("./mqParser");
|
9
9
|
var _generateId = require("./generateId");
|
10
10
|
const createMediaQueryForStyles = (styles, runtime) => {
|
11
|
-
const withMediaQueries = Object.entries(styles).filter(
|
12
|
-
let [, value] = _ref;
|
13
|
-
return typeof value === 'object';
|
14
|
-
}).reduce((acc, _ref2) => {
|
15
|
-
let [prop, value] = _ref2;
|
11
|
+
const withMediaQueries = Object.entries(styles).filter(([, value]) => typeof value === 'object').reduce((acc, [prop, value]) => {
|
16
12
|
const objectKeys = Object.keys(value);
|
17
13
|
const mediaQueries = objectKeys.filter(key => (0, _mqParser.isUnistylesMq)(key));
|
18
14
|
const breakpoints = objectKeys.filter(key => runtime.breakpoints[key]);
|
@@ -54,8 +50,7 @@ const getMaxHeightMediaQuery = height => {
|
|
54
50
|
}
|
55
51
|
return `and (max-height: ${height.to}px)`;
|
56
52
|
};
|
57
|
-
const getMediaQueriesFromMQ = (prop, value, className) => Object.entries(value).reduce((acc,
|
58
|
-
let [key, value] = _ref3;
|
53
|
+
const getMediaQueriesFromMQ = (prop, value, className) => Object.entries(value).reduce((acc, [key, value]) => {
|
59
54
|
const result = (0, _mqParser.parseMq)(key);
|
60
55
|
if (!(0, _mqParser.isValidMq)(result)) {
|
61
56
|
return acc;
|
@@ -92,8 +87,7 @@ const getMediaQueriesFromMQ = (prop, value, className) => Object.entries(value).
|
|
92
87
|
}
|
93
88
|
return acc;
|
94
89
|
}, '');
|
95
|
-
const getBreakpointsStyles = (prop, value, runtime, className) => Object.entries(value).reduce((acc,
|
96
|
-
let [key, value] = _ref4;
|
90
|
+
const getBreakpointsStyles = (prop, value, runtime, className) => Object.entries(value).reduce((acc, [key, value]) => {
|
97
91
|
const breakpoint = runtime.breakpoints[key];
|
98
92
|
if (breakpoint === undefined) {
|
99
93
|
return acc;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_normalizer","require","_mqParser","_generateId","createMediaQueryForStyles","styles","runtime","withMediaQueries","Object","entries","filter","
|
1
|
+
{"version":3,"names":["_normalizer","require","_mqParser","_generateId","createMediaQueryForStyles","styles","runtime","withMediaQueries","Object","entries","filter","value","reduce","acc","prop","objectKeys","keys","mediaQueries","key","isUnistylesMq","breakpoints","length","className","generateReactNativeWebId","breakpointsStyles","getBreakpointsStyles","mediaQueriesStyles","getMediaQueriesFromMQ","trim","exports","getMaxWidthMediaQuery","width","to","Infinity","getMaxHeightMediaQuery","height","result","parseMq","isValidMq","from","normalizePropName","normalizeWebValue","breakpoint","undefined","replace","toLowerCase","normalizeColor"],"sourceRoot":"../../../src","sources":["utils/cssMediaQuery.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAGO,MAAMG,yBAAyB,GAAGA,CAACC,MAAe,EAAEC,OAAyB,KAAc;EAC9F,MAAMC,gBAAgB,GAAGC,MAAM,CAC1BC,OAAO,CAACJ,MAAM,CAAC,CACfK,MAAM,CAAC,CAAC,GAAGC,KAAK,CAAC,KAAK,OAAOA,KAAK,KAAK,QAAQ,CA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MQValue = value => {
|
|
21
21
|
*/
|
22
22
|
const mq = exports.mq = {
|
23
23
|
only: {
|
24
|
-
width:
|
25
|
-
|
26
|
-
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
27
|
-
return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
|
28
|
-
},
|
29
|
-
height: function () {
|
30
|
-
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
31
|
-
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
32
|
-
return `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
33
|
-
}
|
34
|
-
},
|
35
|
-
width: function () {
|
36
|
-
let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
37
|
-
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
38
|
-
return {
|
39
|
-
and: {
|
40
|
-
height: function () {
|
41
|
-
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
42
|
-
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
43
|
-
return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
44
|
-
}
|
45
|
-
}
|
46
|
-
};
|
24
|
+
width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`,
|
25
|
+
height: (hMin = 0, hMax = Infinity) => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
47
26
|
},
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
}
|
59
|
-
};
|
60
|
-
}
|
27
|
+
width: (wMin = 0, wMax = Infinity) => ({
|
28
|
+
and: {
|
29
|
+
height: (hMin = 0, hMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
30
|
+
}
|
31
|
+
}),
|
32
|
+
height: (hMin = 0, hMax = Infinity) => ({
|
33
|
+
and: {
|
34
|
+
width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
35
|
+
}
|
36
|
+
})
|
61
37
|
};
|
62
38
|
//# sourceMappingURL=mq.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_core","require","getMQValue","value","unistyles","registry","breakpoints","mq","exports","only","width","wMin","
|
1
|
+
{"version":3,"names":["_core","require","getMQValue","value","unistyles","registry","breakpoints","mq","exports","only","width","wMin","wMax","Infinity","height","hMin","hMax","and"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAqBA,MAAMC,UAAU,GAAIC,KAAwB,IAAK;EAC7C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,CAAC;EACZ;EAEA,OAAOC,eAAS,CAACC,QAAQ,CAACC,WAAW,CAACH,KAAK,CAAC,IAAI,CAAC;AACrD,CAAC;;AAED;AACA;AACA;AACA;AACO,MAAMI,EAAa,GAAAC,OAAA,CAAAD,EAAA,GAAG;EACzBE,IAAI,EAAE;IACFC,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,KAAO,MAAKX,UAAU,CAACS,IAAI,CAAE,KAAIT,UAAU,CAACU,IAAI,CAAE,GAAwB;IACvIE,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,KAAO,MAAKX,UAAU,CAACa,IAAI,CAAE,KAAIb,UAAU,CAACc,IAAI,CAAE;EACpH,CAAC;EACDN,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,MAAM;IAC/DI,GAAG,EAAE;MACDH,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,KACxD,MAAKX,UAAU,CAACS,IAAI,CAAE,KAAIT,UAAU,CAACU,IAAI,CAAE,OAAMV,UAAU,CAACa,IAAI,CAAE,KAAIb,UAAU,CAACc,IAAI,CAAE;IACjG;EACJ,CAAC,CAAC;EACFF,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,MAAM;IAChEI,GAAG,EAAE;MACDP,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,KACvD,MAAKX,UAAU,CAACS,IAAI,CAAE,KAAIT,UAAU,CAACU,IAAI,CAAE,OAAMV,UAAU,CAACa,IAAI,CAAE,KAAIb,UAAU,CAACc,IAAI,CAAE;IACjG;EACJ,CAAC;AACL,CAAC"}
|
@@ -73,8 +73,7 @@ const isWithinTheHeight = (height, screenHeight) => {
|
|
73
73
|
return screenHeight >= from && screenHeight <= to;
|
74
74
|
};
|
75
75
|
const getKeyForUnistylesMediaQuery = (mediaQueries, screenSize) => {
|
76
|
-
const mq = mediaQueries.find(
|
77
|
-
let [key] = _ref;
|
76
|
+
const mq = mediaQueries.find(([key]) => {
|
78
77
|
if (!isUnistylesMq(key)) {
|
79
78
|
return false;
|
80
79
|
}
|