react-native-unistyles 2.0.0-alpha.6 → 2.0.0-alpha.8
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/{types/cxx.js → common.js} +6 -6
- package/lib/commonjs/common.js.map +1 -0
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -0
- package/lib/commonjs/{Unistyles.js → core/Unistyles.js} +2 -7
- package/lib/commonjs/core/Unistyles.js.map +1 -0
- package/lib/commonjs/core/UnistylesModule.js.map +1 -0
- package/lib/commonjs/{UnistylesRuntime.js → core/UnistylesRuntime.js} +5 -5
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -0
- package/lib/commonjs/core/index.js +13 -0
- package/lib/commonjs/core/index.js.map +1 -0
- package/lib/commonjs/hooks/index.js +10 -3
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/{useInitialTheme.js → hooks/useInitialTheme.js} +2 -2
- package/lib/commonjs/hooks/useInitialTheme.js.map +1 -0
- package/lib/commonjs/hooks/useUnistyles.js +54 -0
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -0
- package/lib/commonjs/index.js +15 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/common.js +2 -0
- package/lib/commonjs/types/{mediaQueries.js.map → common.js.map} +1 -1
- package/lib/commonjs/types/index.js +4 -4
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/mq.js +6 -0
- package/lib/{module/types/mediaQueries.js.map → commonjs/types/mq.js.map} +1 -1
- package/lib/commonjs/types/unistyles.js +6 -0
- package/lib/commonjs/types/unistyles.js.map +1 -0
- package/lib/commonjs/useStyles.js +7 -4
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js +18 -20
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/index.js +14 -34
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mq.js +89 -0
- package/lib/commonjs/utils/mq.js.map +1 -0
- package/lib/commonjs/utils/mqParser.js +86 -0
- package/lib/commonjs/utils/mqParser.js.map +1 -0
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/module/{types/cxx.js → common.js} +6 -6
- package/lib/module/common.js.map +1 -0
- package/lib/module/core/UnistyleRegistry.js.map +1 -0
- package/lib/module/{Unistyles.js → core/Unistyles.js} +1 -6
- package/lib/module/core/Unistyles.js.map +1 -0
- package/lib/module/core/UnistylesModule.js.map +1 -0
- package/lib/module/{UnistylesRuntime.js → core/UnistylesRuntime.js} +1 -1
- package/lib/module/core/UnistylesRuntime.js.map +1 -0
- package/lib/module/core/index.js +2 -0
- package/lib/module/core/index.js.map +1 -0
- package/lib/module/hooks/index.js +2 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/{useInitialTheme.js → hooks/useInitialTheme.js} +1 -1
- package/lib/module/hooks/useInitialTheme.js.map +1 -0
- package/lib/module/hooks/useUnistyles.js +47 -0
- package/lib/module/hooks/useUnistyles.js.map +1 -0
- package/lib/module/index.js +7 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/common.js +2 -0
- package/lib/module/types/common.js.map +1 -0
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/mq.js +2 -0
- package/lib/module/types/mq.js.map +1 -0
- package/lib/module/types/unistyles.js +2 -0
- package/lib/module/types/unistyles.js.map +1 -0
- package/lib/module/useStyles.js +6 -3
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/breakpoints.js +14 -16
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/index.js +2 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mq.js +83 -0
- package/lib/module/utils/mq.js.map +1 -0
- package/lib/module/utils/mqParser.js +79 -0
- package/lib/module/utils/mqParser.js.map +1 -0
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/typescript/src/common.d.ts +17 -0
- package/lib/typescript/src/common.d.ts.map +1 -0
- package/lib/typescript/src/{UnistyleRegistry.d.ts → core/UnistyleRegistry.d.ts} +2 -2
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -0
- package/lib/typescript/src/{Unistyles.d.ts → core/Unistyles.d.ts} +0 -3
- package/lib/typescript/src/core/Unistyles.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -0
- package/lib/typescript/src/{UnistylesRuntime.d.ts → core/UnistylesRuntime.d.ts} +6 -6
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +2 -0
- package/lib/typescript/src/core/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +2 -1
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useInitialTheme.d.ts +3 -0
- package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts +12 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +10 -9
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +5 -9
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/common.d.ts +3 -0
- package/lib/typescript/src/types/common.d.ts.map +1 -0
- package/lib/typescript/src/types/core.d.ts +9 -4
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +5 -4
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/mq.d.ts +3 -0
- package/lib/typescript/src/types/mq.d.ts.map +1 -0
- package/lib/typescript/src/types/{cxx.d.ts → unistyles.d.ts} +4 -22
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -0
- package/lib/typescript/src/useStyles.d.ts +8 -6
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/breakpoints.d.ts +2 -2
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +2 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mq.d.ts +21 -0
- package/lib/typescript/src/utils/mq.d.ts.map +1 -0
- package/lib/typescript/src/utils/mqParser.d.ts +3 -0
- package/lib/typescript/src/utils/mqParser.d.ts.map +1 -0
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common.ts +18 -0
- package/src/{UnistyleRegistry.ts → core/UnistyleRegistry.ts} +2 -2
- package/src/{Unistyles.ts → core/Unistyles.ts} +2 -9
- package/src/{UnistylesRuntime.ts → core/UnistylesRuntime.ts} +3 -3
- package/src/core/index.ts +1 -0
- package/src/hooks/index.ts +2 -1
- package/src/{useInitialTheme.ts → hooks/useInitialTheme.ts} +2 -2
- package/src/hooks/useUnistyles.ts +55 -0
- package/src/index.ts +10 -7
- package/src/types/breakpoints.ts +6 -11
- package/src/types/common.ts +2 -0
- package/src/types/core.ts +10 -4
- package/src/types/index.ts +5 -9
- package/src/types/mq.ts +3 -0
- package/src/types/{cxx.ts → unistyles.ts} +3 -24
- package/src/useStyles.ts +15 -8
- package/src/utils/breakpoints.ts +13 -12
- package/src/utils/index.ts +2 -8
- package/src/utils/mq.ts +106 -0
- package/src/utils/mqParser.ts +99 -0
- package/src/utils/styles.ts +2 -2
- package/lib/commonjs/UnistyleRegistry.js.map +0 -1
- package/lib/commonjs/Unistyles.js.map +0 -1
- package/lib/commonjs/UnistylesEngine.js +0 -26
- package/lib/commonjs/UnistylesEngine.js.map +0 -1
- package/lib/commonjs/UnistylesModule.js.map +0 -1
- package/lib/commonjs/UnistylesRuntime.js.map +0 -1
- package/lib/commonjs/hooks/useDimensions.js +0 -10
- package/lib/commonjs/hooks/useDimensions.js.map +0 -1
- package/lib/commonjs/hooks/useDimensions.web.js +0 -34
- package/lib/commonjs/hooks/useDimensions.web.js.map +0 -1
- package/lib/commonjs/types/cxx.js.map +0 -1
- package/lib/commonjs/types/mediaQueries.js +0 -2
- package/lib/commonjs/useInitialTheme.js.map +0 -1
- package/lib/commonjs/useUnistyles.js +0 -51
- package/lib/commonjs/useUnistyles.js.map +0 -1
- package/lib/commonjs/utils/mediaQueries.js +0 -98
- package/lib/commonjs/utils/mediaQueries.js.map +0 -1
- package/lib/module/UnistyleRegistry.js.map +0 -1
- package/lib/module/Unistyles.js.map +0 -1
- package/lib/module/UnistylesEngine.js +0 -19
- package/lib/module/UnistylesEngine.js.map +0 -1
- package/lib/module/UnistylesModule.js.map +0 -1
- package/lib/module/UnistylesRuntime.js.map +0 -1
- package/lib/module/hooks/useDimensions.js +0 -3
- package/lib/module/hooks/useDimensions.js.map +0 -1
- package/lib/module/hooks/useDimensions.web.js +0 -27
- package/lib/module/hooks/useDimensions.web.js.map +0 -1
- package/lib/module/types/cxx.js.map +0 -1
- package/lib/module/types/mediaQueries.js +0 -2
- package/lib/module/useInitialTheme.js.map +0 -1
- package/lib/module/useUnistyles.js +0 -44
- package/lib/module/useUnistyles.js.map +0 -1
- package/lib/module/utils/mediaQueries.js +0 -85
- package/lib/module/utils/mediaQueries.js.map +0 -1
- package/lib/typescript/src/UnistyleRegistry.d.ts.map +0 -1
- package/lib/typescript/src/Unistyles.d.ts.map +0 -1
- package/lib/typescript/src/UnistylesEngine.d.ts +0 -11
- package/lib/typescript/src/UnistylesEngine.d.ts.map +0 -1
- package/lib/typescript/src/UnistylesModule.d.ts.map +0 -1
- package/lib/typescript/src/UnistylesRuntime.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useDimensions.d.ts +0 -3
- package/lib/typescript/src/hooks/useDimensions.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useDimensions.web.d.ts +0 -3
- package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +0 -1
- package/lib/typescript/src/types/cxx.d.ts.map +0 -1
- package/lib/typescript/src/types/mediaQueries.d.ts +0 -10
- package/lib/typescript/src/types/mediaQueries.d.ts.map +0 -1
- package/lib/typescript/src/useInitialTheme.d.ts +0 -3
- package/lib/typescript/src/useInitialTheme.d.ts.map +0 -1
- package/lib/typescript/src/useUnistyles.d.ts +0 -11
- package/lib/typescript/src/useUnistyles.d.ts.map +0 -1
- package/lib/typescript/src/utils/mediaQueries.d.ts +0 -11
- package/lib/typescript/src/utils/mediaQueries.d.ts.map +0 -1
- package/src/UnistylesEngine.ts +0 -24
- package/src/hooks/useDimensions.ts +0 -4
- package/src/hooks/useDimensions.web.ts +0 -34
- package/src/types/mediaQueries.ts +0 -15
- package/src/useUnistyles.ts +0 -54
- package/src/utils/mediaQueries.ts +0 -152
- /package/lib/commonjs/{UnistyleRegistry.js → core/UnistyleRegistry.js} +0 -0
- /package/lib/commonjs/{UnistylesModule.js → core/UnistylesModule.js} +0 -0
- /package/lib/module/{UnistyleRegistry.js → core/UnistyleRegistry.js} +0 -0
- /package/lib/module/{UnistylesModule.js → core/UnistylesModule.js} +0 -0
- /package/lib/typescript/src/{UnistylesModule.d.ts → core/UnistylesModule.d.ts} +0 -0
- /package/src/{UnistylesModule.ts → core/UnistylesModule.ts} +0 -0
@@ -4,11 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.UnistylesError = exports.ScreenOrientation = exports.CxxUnistylesEventTypes = void 0;
|
7
|
-
let ScreenOrientation = exports.ScreenOrientation = /*#__PURE__*/function (ScreenOrientation) {
|
8
|
-
ScreenOrientation[ScreenOrientation["Portrait"] = 1] = "Portrait";
|
9
|
-
ScreenOrientation[ScreenOrientation["Landscape"] = 2] = "Landscape";
|
10
|
-
return ScreenOrientation;
|
11
|
-
}({});
|
12
7
|
let CxxUnistylesEventTypes = exports.CxxUnistylesEventTypes = /*#__PURE__*/function (CxxUnistylesEventTypes) {
|
13
8
|
CxxUnistylesEventTypes["Theme"] = "theme";
|
14
9
|
CxxUnistylesEventTypes["Layout"] = "layout";
|
@@ -23,4 +18,9 @@ let UnistylesError = exports.UnistylesError = /*#__PURE__*/function (UnistylesEr
|
|
23
18
|
UnistylesError["BreakpointsMustStartFromZero"] = "UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO";
|
24
19
|
return UnistylesError;
|
25
20
|
}({});
|
26
|
-
|
21
|
+
let ScreenOrientation = exports.ScreenOrientation = /*#__PURE__*/function (ScreenOrientation) {
|
22
|
+
ScreenOrientation[ScreenOrientation["Portrait"] = 1] = "Portrait";
|
23
|
+
ScreenOrientation[ScreenOrientation["Landscape"] = 2] = "Landscape";
|
24
|
+
return ScreenOrientation;
|
25
|
+
}({});
|
26
|
+
//# sourceMappingURL=common.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["CxxUnistylesEventTypes","exports","UnistylesError","ScreenOrientation"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":";;;;;;IAAYA,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAAA,IAKtBE,cAAc,GAAAD,OAAA,CAAAC,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAAA,IASdC,iBAAiB,GAAAF,OAAA,CAAAE,iBAAA,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistyleRegistry","config","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes","dangerouslyUnregister","unregister","exports"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":";;;;;;AAGO,MAAMA,gBAAgB,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AAA,gBAAA"}
|
@@ -6,21 +6,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.unistyles = void 0;
|
7
7
|
var _UnistylesModule = require("./UnistylesModule");
|
8
8
|
var _UnistylesRuntime = require("./UnistylesRuntime");
|
9
|
-
var _UnistylesEngine = require("./UnistylesEngine");
|
10
9
|
var _UnistyleRegistry = require("./UnistyleRegistry");
|
11
|
-
var
|
10
|
+
var _common = require("../common");
|
12
11
|
class Unistyles {
|
13
12
|
constructor() {
|
14
13
|
const isInstalled = _UnistylesModule.UnistylesModule?.install() ?? false;
|
15
14
|
if (!isInstalled) {
|
16
|
-
throw new Error(
|
15
|
+
throw new Error(_common.UnistylesError.RuntimeUnavailable);
|
17
16
|
}
|
18
17
|
|
19
18
|
// @ts-ignore
|
20
19
|
this._bridge = global.__UNISTYLES__;
|
21
20
|
this._registry = new _UnistyleRegistry.UnistyleRegistry(this._bridge);
|
22
21
|
this._runtime = new _UnistylesRuntime.UnistylesRuntime(this._bridge, this._registry);
|
23
|
-
this._engine = new _UnistylesEngine.UnistylesBuiltInEngine(this._registry, this._runtime);
|
24
22
|
}
|
25
23
|
get registry() {
|
26
24
|
return this._registry;
|
@@ -28,9 +26,6 @@ class Unistyles {
|
|
28
26
|
get runtime() {
|
29
27
|
return this._runtime;
|
30
28
|
}
|
31
|
-
get engine() {
|
32
|
-
return this._engine;
|
33
|
-
}
|
34
29
|
}
|
35
30
|
const unistyles = exports.unistyles = new Unistyles();
|
36
31
|
//# sourceMappingURL=Unistyles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_UnistylesModule","require","_UnistylesRuntime","_UnistyleRegistry","_common","Unistyles","constructor","isInstalled","UnistylesModule","install","Error","UnistylesError","RuntimeUnavailable","_bridge","global","__UNISTYLES__","_registry","UnistyleRegistry","_runtime","UnistylesRuntime","registry","runtime","unistyles","exports"],"sourceRoot":"../../../src","sources":["core/Unistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AAEA,MAAMI,SAAS,CAAC;EAKZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGC,gCAAe,EAAEC,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACF,WAAW,EAAE;MACd,MAAM,IAAIG,KAAK,CAACC,sBAAc,CAACC,kBAAkB,CAAC;IACtD;;IAEA;IACA,IAAI,CAACC,OAAO,GAAGC,MAAM,CAACC,aAAgC;IACtD,IAAI,CAACC,SAAS,GAAG,IAAIC,kCAAgB,CAAC,IAAI,CAACJ,OAAO,CAAC;IACnD,IAAI,CAACK,QAAQ,GAAG,IAAIC,kCAAgB,CAAC,IAAI,CAACN,OAAO,EAAE,IAAI,CAACG,SAAS,CAAC;EACtE;EAEA,IAAWI,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACJ,SAAS;EACzB;EAEA,IAAWK,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACH,QAAQ;EACxB;AACJ;AAEO,MAAMI,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,IAAIjB,SAAS,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_reactNative","require","UnistylesModule","exports","NativeModules","Unistyles"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMO,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAGE,0BAAa,EAAEC,SAAkC"}
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.UnistylesRuntime = void 0;
|
7
|
-
var
|
7
|
+
var _common = require("../common");
|
8
8
|
class UnistylesRuntime {
|
9
9
|
constructor(unistylesBridge, registry) {
|
10
10
|
this.unistylesBridge = unistylesBridge;
|
@@ -37,23 +37,23 @@ class UnistylesRuntime {
|
|
37
37
|
height
|
38
38
|
} = this.screen;
|
39
39
|
if (width > height) {
|
40
|
-
return
|
40
|
+
return _common.ScreenOrientation.Landscape;
|
41
41
|
}
|
42
|
-
return
|
42
|
+
return _common.ScreenOrientation.Portrait;
|
43
43
|
}
|
44
44
|
setTheme = name => {
|
45
45
|
if (name !== this.themeName && this.hasTheme(name)) {
|
46
46
|
this.unistylesBridge.useTheme(name);
|
47
47
|
return true;
|
48
48
|
}
|
49
|
-
throw new Error(
|
49
|
+
throw new Error(_common.UnistylesError.ThemeNotRegistered);
|
50
50
|
};
|
51
51
|
getTheme = forName => {
|
52
52
|
if (this.registry.themeNames.length === 0) {
|
53
53
|
return {};
|
54
54
|
}
|
55
55
|
if (!this.hasTheme(forName)) {
|
56
|
-
throw new Error(
|
56
|
+
throw new Error(_common.UnistylesError.ThemeNotFound);
|
57
57
|
}
|
58
58
|
return this.registry.themes[forName];
|
59
59
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_common","require","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","hasAdaptiveThemes","sortedBreakpoints","sortedBreakpointPairs","themeName","breakpoint","screen","width","screenWidth","height","screenHeight","orientation","ScreenOrientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","UnistylesError","ThemeNotRegistered","getTheme","forName","themeNames","length","ThemeNotFound","themes","setAdaptiveThemes","enable","useAdaptiveThemes","exports"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,QAA0B,EAAE;IAAA,KAAtED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,QAA0B,GAA1BA,QAA0B;EAAG;EAE3F,IAAWC,WAAWA,CAAA,EAAG;IACr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C,EAAE;MACzB,MAAM,IAAIJ,KAAK,CAACC,sBAAc,CAACM,aAAa,CAAC;IACjD;IAEA,OAAO,IAAI,CAAC3B,QAAQ,CAAC4B,MAAM,CAACJ,OAAO,CAAC;EACxC,CAAC;EAEMK,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAAC/B,eAAe,CAACgC,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;EAEOZ,QAAQ,GAAID,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAACjB,QAAQ,CAAC4B,MAAM;AACpF;AAACI,OAAA,CAAAnC,gBAAA,GAAAA,gBAAA"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
Object.defineProperty(exports, "unistyles", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function () {
|
9
|
+
return _Unistyles.unistyles;
|
10
|
+
}
|
11
|
+
});
|
12
|
+
var _Unistyles = require("./Unistyles");
|
13
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_Unistyles","require"],"sourceRoot":"../../../src","sources":["core/index.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA"}
|
@@ -3,11 +3,18 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
Object.defineProperty(exports, "
|
6
|
+
Object.defineProperty(exports, "useInitialTheme", {
|
7
7
|
enumerable: true,
|
8
8
|
get: function () {
|
9
|
-
return
|
9
|
+
return _useInitialTheme.useInitialTheme;
|
10
10
|
}
|
11
11
|
});
|
12
|
-
|
12
|
+
Object.defineProperty(exports, "useUnistyles", {
|
13
|
+
enumerable: true,
|
14
|
+
get: function () {
|
15
|
+
return _useUnistyles.useUnistyles;
|
16
|
+
}
|
17
|
+
});
|
18
|
+
var _useInitialTheme = require("./useInitialTheme");
|
19
|
+
var _useUnistyles = require("./useUnistyles");
|
13
20
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_useInitialTheme","require","_useUnistyles"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA"}
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.useInitialTheme = void 0;
|
7
7
|
var _react = require("react");
|
8
|
-
var
|
8
|
+
var _core = require("../core");
|
9
9
|
const useInitialTheme = forName => {
|
10
|
-
(0, _react.useMemo)(() =>
|
10
|
+
(0, _react.useMemo)(() => _core.unistyles.runtime.setTheme(forName), []);
|
11
11
|
};
|
12
12
|
exports.useInitialTheme = useInitialTheme;
|
13
13
|
//# sourceMappingURL=useInitialTheme.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_react","require","_core","useInitialTheme","forName","useMemo","unistyles","runtime","setTheme","exports"],"sourceRoot":"../../../src","sources":["hooks/useInitialTheme.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAGO,MAAME,eAAe,GAAIC,OAA8B,IAAK;EAC/D,IAAAC,cAAO,EAAC,MAAMC,eAAS,CAACC,OAAO,CAACC,QAAQ,CAACJ,OAAO,CAAC,EAAE,EAAE,CAAC;AAC1D,CAAC;AAAAK,OAAA,CAAAN,eAAA,GAAAA,eAAA"}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.useUnistyles = void 0;
|
7
|
+
var _reactNative = require("react-native");
|
8
|
+
var _react = require("react");
|
9
|
+
var _core = require("../core");
|
10
|
+
var _common = require("../common");
|
11
|
+
const unistylesEvents = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.Unistyles);
|
12
|
+
const useUnistyles = () => {
|
13
|
+
const [theme, setTheme] = (0, _react.useState)(_core.unistyles.runtime.getTheme(_core.unistyles.runtime.themeName));
|
14
|
+
const [layout, setLayout] = (0, _react.useState)({
|
15
|
+
breakpoint: _core.unistyles.runtime.breakpoint,
|
16
|
+
orientation: _core.unistyles.runtime.orientation,
|
17
|
+
screenSize: {
|
18
|
+
width: _core.unistyles.runtime.screen.width,
|
19
|
+
height: _core.unistyles.runtime.screen.height
|
20
|
+
}
|
21
|
+
});
|
22
|
+
(0, _react.useEffect)(() => {
|
23
|
+
const subscription = unistylesEvents.addListener('onChange', event => {
|
24
|
+
switch (event.type) {
|
25
|
+
case _common.CxxUnistylesEventTypes.Theme:
|
26
|
+
{
|
27
|
+
const themeEvent = event;
|
28
|
+
return setTheme(_core.unistyles.runtime.getTheme(themeEvent.payload.themeName));
|
29
|
+
}
|
30
|
+
case _common.CxxUnistylesEventTypes.Layout:
|
31
|
+
{
|
32
|
+
const layoutEvent = event;
|
33
|
+
return setLayout({
|
34
|
+
breakpoint: layoutEvent.payload.breakpoint,
|
35
|
+
orientation: layoutEvent.payload.orientation,
|
36
|
+
screenSize: {
|
37
|
+
width: layoutEvent.payload.screen.width,
|
38
|
+
height: layoutEvent.payload.screen.height
|
39
|
+
}
|
40
|
+
});
|
41
|
+
}
|
42
|
+
default:
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
});
|
46
|
+
return subscription.remove;
|
47
|
+
}, []);
|
48
|
+
return {
|
49
|
+
theme,
|
50
|
+
layout
|
51
|
+
};
|
52
|
+
};
|
53
|
+
exports.useUnistyles = useUnistyles;
|
54
|
+
//# sourceMappingURL=useUnistyles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_react","_core","_common","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","useUnistyles","theme","setTheme","useState","unistyles","runtime","getTheme","themeName","layout","setLayout","breakpoint","orientation","screenSize","width","screen","height","useEffect","subscription","addListener","event","type","CxxUnistylesEventTypes","Theme","themeEvent","payload","Layout","layoutEvent","remove","exports"],"sourceRoot":"../../../src","sources":["hooks/useUnistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAGA,MAAMI,eAAe,GAAG,IAAIC,+BAAkB,CAACC,0BAAa,CAACC,SAAS,CAAC;AAEhE,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAACC,eAAS,CAACC,OAAO,CAACC,QAAQ,CAACF,eAAS,CAACC,OAAO,CAACE,SAAS,CAAC,CAAC;EAC3F,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAG,IAAAN,eAAQ,EAAC;IACjCO,UAAU,EAAEN,eAAS,CAACC,OAAO,CAACK,UAAU;IACxCC,WAAW,EAAEP,eAAS,CAACC,OAAO,CAACM,WAAW;IAC1CC,UAAU,EAAE;MACRC,KAAK,EAAET,eAAS,CAACC,OAAO,CAACS,MAAM,CAACD,KAAK;MACrCE,MAAM,EAAEX,eAAS,CAACC,OAAO,CAACS,MAAM,CAACC;IACrC;EACJ,CAAC,CAAC;EAEF,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,YAAY,GAAGrB,eAAe,CAACsB,WAAW,CAC5C,UAAU,EACTC,KAAsB,IAAK;MACxB,QAAQA,KAAK,CAACC,IAAI;QACd,KAAKC,8BAAsB,CAACC,KAAK;UAAE;YAC/B,MAAMC,UAAU,GAAGJ,KAA4B;YAE/C,OAAOjB,QAAQ,CAACE,eAAS,CAACC,OAAO,CAACC,QAAQ,CAACiB,UAAU,CAACC,OAAO,CAACjB,SAAS,CAAC,CAAC;UAC7E;QACA,KAAKc,8BAAsB,CAACI,MAAM;UAAE;YAChC,MAAMC,WAAW,GAAGP,KAAmC;YAEvD,OAAOV,SAAS,CAAC;cACbC,UAAU,EAAEgB,WAAW,CAACF,OAAO,CAACd,UAAU;cAC1CC,WAAW,EAAEe,WAAW,CAACF,OAAO,CAACb,WAAW;cAC5CC,UAAU,EAAE;gBACRC,KAAK,EAAEa,WAAW,CAACF,OAAO,CAACV,MAAM,CAACD,KAAK;gBACvCE,MAAM,EAAEW,WAAW,CAACF,OAAO,CAACV,MAAM,CAACC;cACvC;YACJ,CAAC,CAAC;UACN;QACA;UACI;MACR;IACJ,CACJ,CAAC;IAED,OAAOE,YAAY,CAACU,MAAM;EAC9B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACH1B,KAAK;IACLO;EACJ,CAAC;AACL,CAAC;AAAAoB,OAAA,CAAA5B,YAAA,GAAAA,YAAA"}
|
package/lib/commonjs/index.js
CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
Object.defineProperty(exports, "ScreenOrientation", {
|
7
7
|
enumerable: true,
|
8
8
|
get: function () {
|
9
|
-
return
|
9
|
+
return _common.ScreenOrientation;
|
10
10
|
}
|
11
11
|
});
|
12
12
|
exports.__dangerouslyUnregister = exports.UnistylesRuntime = exports.UnistylesRegistry = void 0;
|
@@ -16,10 +16,16 @@ Object.defineProperty(exports, "createStyleSheet", {
|
|
16
16
|
return _createStyleSheet.createStyleSheet;
|
17
17
|
}
|
18
18
|
});
|
19
|
+
Object.defineProperty(exports, "mq", {
|
20
|
+
enumerable: true,
|
21
|
+
get: function () {
|
22
|
+
return _utils.mq;
|
23
|
+
}
|
24
|
+
});
|
19
25
|
Object.defineProperty(exports, "useInitialTheme", {
|
20
26
|
enumerable: true,
|
21
27
|
get: function () {
|
22
|
-
return
|
28
|
+
return _hooks.useInitialTheme;
|
23
29
|
}
|
24
30
|
});
|
25
31
|
Object.defineProperty(exports, "useStyles", {
|
@@ -28,21 +34,22 @@ Object.defineProperty(exports, "useStyles", {
|
|
28
34
|
return _useStyles.useStyles;
|
29
35
|
}
|
30
36
|
});
|
31
|
-
var
|
32
|
-
var
|
33
|
-
var
|
37
|
+
var _core = require("./core");
|
38
|
+
var _utils = require("./utils");
|
39
|
+
var _hooks = require("./hooks");
|
40
|
+
var _common = require("./common");
|
34
41
|
var _useStyles = require("./useStyles");
|
35
42
|
var _createStyleSheet = require("./createStyleSheet");
|
36
43
|
const {
|
37
44
|
addThemes,
|
38
45
|
addBreakpoints,
|
39
46
|
addConfig
|
40
|
-
} =
|
41
|
-
const UnistylesRuntime = exports.UnistylesRuntime =
|
47
|
+
} = _core.unistyles.registry;
|
48
|
+
const UnistylesRuntime = exports.UnistylesRuntime = _core.unistyles.runtime;
|
42
49
|
const UnistylesRegistry = exports.UnistylesRegistry = {
|
43
50
|
addThemes,
|
44
51
|
addBreakpoints,
|
45
52
|
addConfig
|
46
53
|
};
|
47
|
-
const __dangerouslyUnregister = exports.__dangerouslyUnregister =
|
54
|
+
const __dangerouslyUnregister = exports.__dangerouslyUnregister = _core.unistyles.registry.dangerouslyUnregister;
|
48
55
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_core","require","_utils","_hooks","_common","_useStyles","_createStyleSheet","addThemes","addBreakpoints","addConfig","unistyles","registry","UnistylesRuntime","exports","runtime","UnistylesRegistry","__dangerouslyUnregister","dangerouslyUnregister"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAEA,MAAM;EAAEM,SAAS;EAAEC,cAAc;EAAEC;AAAW,CAAC,GAAGC,eAAS,CAACC,QAAQ;AACpE,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAGF,eAAS,CAACI,OAAO;AAC1C,MAAMC,iBAAiB,GAAAF,OAAA,CAAAE,iBAAA,GAAG;EACtBR,SAAS;EACTC,cAAc;EACdC;AACJ,CAAC;AAEM,MAAMO,uBAAuB,GAAAH,OAAA,CAAAG,uBAAA,GAAGN,eAAS,CAACC,QAAQ,CAACM,qBAAqB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/common.ts"],"mappings":""}
|
@@ -14,14 +14,14 @@ Object.keys(_normalizer).forEach(function (key) {
|
|
14
14
|
}
|
15
15
|
});
|
16
16
|
});
|
17
|
-
var
|
18
|
-
Object.keys(
|
17
|
+
var _unistyles = require("./unistyles");
|
18
|
+
Object.keys(_unistyles).forEach(function (key) {
|
19
19
|
if (key === "default" || key === "__esModule") return;
|
20
|
-
if (key in exports && exports[key] ===
|
20
|
+
if (key in exports && exports[key] === _unistyles[key]) return;
|
21
21
|
Object.defineProperty(exports, key, {
|
22
22
|
enumerable: true,
|
23
23
|
get: function () {
|
24
|
-
return
|
24
|
+
return _unistyles[key];
|
25
25
|
}
|
26
26
|
});
|
27
27
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_normalizer","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","
|
1
|
+
{"version":3,"names":["_normalizer","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_unistyles"],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,UAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,UAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,UAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,UAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/mq.ts"],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/unistyles.ts"],"mappings":""}
|
@@ -7,13 +7,16 @@ exports.useStyles = void 0;
|
|
7
7
|
var _react = require("react");
|
8
8
|
var _reactNative = require("react-native");
|
9
9
|
var _utils = require("./utils");
|
10
|
-
var
|
10
|
+
var _hooks = require("./hooks");
|
11
11
|
const useStyles = stylesheet => {
|
12
12
|
const {
|
13
13
|
theme,
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
layout
|
15
|
+
} = (0, _hooks.useUnistyles)();
|
16
|
+
const {
|
17
|
+
screenSize,
|
18
|
+
breakpoint
|
19
|
+
} = layout;
|
17
20
|
if (!stylesheet) {
|
18
21
|
return {
|
19
22
|
theme,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_utils","
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_utils","_hooks","useStyles","stylesheet","theme","layout","useUnistyles","screenSize","breakpoint","styles","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","style","proxifyFunction","StyleSheet","create","parseStyle","exports"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AASO,MAAMI,SAAS,GAAsCC,UAAyD,IAA2B;EAC5I,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAG,IAAAC,mBAAY,EAAC,CAAC;EACxC,MAAM;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAEzC,IAAI,CAACF,UAAU,EAAE;IACb,OAAO;MACHC,KAAK;MACLI,UAAU;MACVC,MAAM,EAAE,CAAC;IACb,CAAC;EACL;EAEA,MAAMC,YAAY,GAAG,IAAAC,cAAO,EAAC,MAAM,OAAOR,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACC,KAAK,CAAC,GACjBD,UAAU,EAAE,CAACC,KAAK,EAAED,UAAU,CAAC,CAAC;EAEtC,MAAMS,iBAAiB,GAAG,IAAAD,cAAO,EAAC,MAAME,MAAM,CACzCC,OAAO,CAACJ,YAAY,CAAC,CACrBK,MAAM,CAAC,CAACC,GAAG,EAAAC,IAAA,KAAmB;IAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;IACtB,MAAMG,KAAK,GAAGD,KAA8B;IAE5C,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGH,GAAG;QACN,CAACE,GAAG,GAAG,IAAAG,sBAAe,EAACF,KAAK,EAAEX,UAAU,EAAED,UAAU;MACxD,CAAC;IACL;IAEA,OAAOe,uBAAU,CAACC,MAAM,CAAC;MACrB,GAAGP,GAAG;MACN,CAACE,GAAG,GAAG,IAAAM,iBAAU,EAAKJ,KAAK,EAAEZ,UAAU,EAAED,UAAU;IACvD,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAO,CAAC,EAAE,CAACC,UAAU,EAAED,UAAU,EAAEG,YAAY,CAAC,CAA8B;EAEtF,OAAO;IACHN,KAAK;IACLI,UAAU;IACVC,MAAM,EAAEG;EACZ,CAAC;AACL,CAAC;AAAAa,OAAA,CAAAvB,SAAA,GAAAA,SAAA"}
|
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.sortAndValidateBreakpoints = exports.getValueForBreakpoint = exports.getBreakpointFromScreenWidth = void 0;
|
7
|
-
var
|
7
|
+
var _core = require("../core");
|
8
8
|
var _common = require("./common");
|
9
|
-
var
|
9
|
+
var _common2 = require("../common");
|
10
|
+
var _mqParser = require("./mqParser");
|
10
11
|
const sortAndValidateBreakpoints = breakpoints => {
|
11
12
|
const sortedPairs = Object.entries(breakpoints).sort((breakpoint1, breakpoint2) => {
|
12
13
|
const [, value1] = breakpoint1;
|
@@ -40,25 +41,22 @@ const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
|
|
40
41
|
exports.getBreakpointFromScreenWidth = getBreakpointFromScreenWidth;
|
41
42
|
const getValueForBreakpoint = value => {
|
42
43
|
// the highest priority is for custom media queries
|
43
|
-
const
|
44
|
-
|
45
|
-
return _Unistyles.unistyles.engine.isMediaQuery(key);
|
46
|
-
});
|
47
|
-
// const customMediaQueryKey = getKeyForCustomMediaQuery(customMediaQueries, screenSize) as keyof typeof value
|
48
|
-
const customMediaQueryKey = _Unistyles.unistyles.engine.didMatchMediaQuery(customMediaQueries);
|
49
|
-
if (customMediaQueryKey && customMediaQueryKey in value) {
|
44
|
+
const customMediaQueryKey = (0, _mqParser.getKeyForUnistylesMediaQuery)(Object.entries(value), _core.unistyles.runtime.screen);
|
45
|
+
if (customMediaQueryKey) {
|
50
46
|
return value[customMediaQueryKey];
|
51
47
|
}
|
52
48
|
|
53
49
|
// at this point user didn't use custom media queries (:w, :h)
|
54
50
|
// check if user defined any breakpoints
|
55
|
-
const hasBreakpoints =
|
51
|
+
const hasBreakpoints = _core.unistyles.runtime.sortedBreakpoints.length > 0;
|
56
52
|
|
57
|
-
// if not then we can
|
53
|
+
// if not then we can fall back to horizontal and portrait (mobile only)
|
58
54
|
if (!hasBreakpoints && _common.isMobile && (_common.Orientation.Landscape in value || _common.Orientation.Portrait in value)) {
|
59
|
-
return value[
|
55
|
+
return value[_core.unistyles.runtime.orientation === _common2.ScreenOrientation.Portrait ? _common.Orientation.Portrait : _common.Orientation.Landscape];
|
60
56
|
}
|
61
|
-
|
57
|
+
|
58
|
+
// let's get the current breakpoint
|
59
|
+
const breakpoint = _core.unistyles.runtime.breakpoint;
|
62
60
|
if (!breakpoint) {
|
63
61
|
return undefined;
|
64
62
|
}
|
@@ -72,16 +70,16 @@ const getValueForBreakpoint = value => {
|
|
72
70
|
}
|
73
71
|
|
74
72
|
// there is no direct hit for breakpoint nor media-query, let's simulate CSS cascading
|
75
|
-
const breakpointPairs =
|
76
|
-
const currentBreakpoint = breakpointPairs.findIndex(
|
77
|
-
let [key] =
|
73
|
+
const breakpointPairs = _core.unistyles.runtime.sortedBreakpoints;
|
74
|
+
const currentBreakpoint = breakpointPairs.findIndex(_ref2 => {
|
75
|
+
let [key] = _ref2;
|
78
76
|
return key === breakpoint;
|
79
77
|
});
|
80
|
-
const availableBreakpoints = breakpointPairs.filter((
|
81
|
-
let [key] =
|
78
|
+
const availableBreakpoints = breakpointPairs.filter((_ref3, index) => {
|
79
|
+
let [key] = _ref3;
|
82
80
|
return index < currentBreakpoint && key && key in value;
|
83
|
-
}).map(
|
84
|
-
let [key] =
|
81
|
+
}).map(_ref4 => {
|
82
|
+
let [key] = _ref4;
|
85
83
|
return key;
|
86
84
|
});
|
87
85
|
return breakpointPairs.length > 0 ? value[availableBreakpoints[availableBreakpoints.length - 1]] : undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_core","require","_common","_common2","_mqParser","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","throwError","length","Set","size","exports","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","customMediaQueryKey","getKeyForUnistylesMediaQuery","unistyles","runtime","screen","hasBreakpoints","isMobile","Orientation","Landscape","Portrait","orientation","ScreenOrientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpoint","findIndex","_ref2","availableBreakpoints","filter","_ref3","map","_ref4"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAGA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAEO,MAAMI,0BAA0B,GAAIC,WAAiC,IAA2B;EACnG,MAAMC,WAAW,GAAGC,MAAM,CACrBC,OAAO,CAACH,WAAW,CAAC,CACpBI,IAAI,CAAC,CAACC,WAAW,EAAEC,WAAW,KAAK;IAChC,MAAM,GAAGC,MAAM,CAAC,GAAGF,WAAW;IAC9B,MAAM,GAAGG,MAAM,CAAC,GAAGF,WAAW;IAE9B,OAAQC,MAAM,GAAeC,MAAiB;EAClD,CAAC,CAAC;EAEN,MAAMC,iBAAiB,GAAIP,MAAM,CAACQ,MAAM,CAACR,MAAM,CAACS,WAAW,CAACV,WAAW,CAAC,CAAyB;EACjG,MAAMW,gBAAgB,GAAGV,MAAM,CAACW,MAAM,CAACJ,iBAAiB,CAAC;EACzD,MAAM,CAACK,e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,CAAC,CAAwC,GACnG6B,SAAS;AACnB,CAAC;AAAA1B,OAAA,CAAAY,qBAAA,GAAAA,qBAAA"}
|
@@ -5,30 +5,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
var _exportNames = {
|
7
7
|
normalizeStyles: true,
|
8
|
+
mq: true,
|
9
|
+
MQSymbol: true,
|
10
|
+
getKeyForUnistylesMediaQuery: true,
|
8
11
|
getBreakpointFromScreenWidth: true,
|
9
12
|
sortAndValidateBreakpoints: true,
|
10
13
|
getValueForBreakpoint: true,
|
11
14
|
proxifyFunction: true,
|
12
15
|
parseStyle: true,
|
13
16
|
isServer: true,
|
14
|
-
Orientation: true
|
15
|
-
extractValues: true,
|
16
|
-
getKeyForCustomMediaQuery: true,
|
17
|
-
isMediaQuery: true,
|
18
|
-
isWithinTheHeight: true,
|
19
|
-
isWithinTheWidth: true,
|
20
|
-
isWithinTheWidthAndHeight: true
|
17
|
+
Orientation: true
|
21
18
|
};
|
22
|
-
Object.defineProperty(exports, "
|
19
|
+
Object.defineProperty(exports, "MQSymbol", {
|
23
20
|
enumerable: true,
|
24
21
|
get: function () {
|
25
|
-
return
|
22
|
+
return _mq.MQSymbol;
|
26
23
|
}
|
27
24
|
});
|
28
|
-
Object.defineProperty(exports, "
|
25
|
+
Object.defineProperty(exports, "Orientation", {
|
29
26
|
enumerable: true,
|
30
27
|
get: function () {
|
31
|
-
return
|
28
|
+
return _common.Orientation;
|
32
29
|
}
|
33
30
|
});
|
34
31
|
Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
|
@@ -37,10 +34,10 @@ Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
|
|
37
34
|
return _breakpoints.getBreakpointFromScreenWidth;
|
38
35
|
}
|
39
36
|
});
|
40
|
-
Object.defineProperty(exports, "
|
37
|
+
Object.defineProperty(exports, "getKeyForUnistylesMediaQuery", {
|
41
38
|
enumerable: true,
|
42
39
|
get: function () {
|
43
|
-
return
|
40
|
+
return _mqParser.getKeyForUnistylesMediaQuery;
|
44
41
|
}
|
45
42
|
});
|
46
43
|
Object.defineProperty(exports, "getValueForBreakpoint", {
|
@@ -49,34 +46,16 @@ Object.defineProperty(exports, "getValueForBreakpoint", {
|
|
49
46
|
return _breakpoints.getValueForBreakpoint;
|
50
47
|
}
|
51
48
|
});
|
52
|
-
Object.defineProperty(exports, "isMediaQuery", {
|
53
|
-
enumerable: true,
|
54
|
-
get: function () {
|
55
|
-
return _mediaQueries.isMediaQuery;
|
56
|
-
}
|
57
|
-
});
|
58
49
|
Object.defineProperty(exports, "isServer", {
|
59
50
|
enumerable: true,
|
60
51
|
get: function () {
|
61
52
|
return _common.isServer;
|
62
53
|
}
|
63
54
|
});
|
64
|
-
Object.defineProperty(exports, "
|
65
|
-
enumerable: true,
|
66
|
-
get: function () {
|
67
|
-
return _mediaQueries.isWithinTheHeight;
|
68
|
-
}
|
69
|
-
});
|
70
|
-
Object.defineProperty(exports, "isWithinTheWidth", {
|
71
|
-
enumerable: true,
|
72
|
-
get: function () {
|
73
|
-
return _mediaQueries.isWithinTheWidth;
|
74
|
-
}
|
75
|
-
});
|
76
|
-
Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
|
55
|
+
Object.defineProperty(exports, "mq", {
|
77
56
|
enumerable: true,
|
78
57
|
get: function () {
|
79
|
-
return
|
58
|
+
return _mq.mq;
|
80
59
|
}
|
81
60
|
});
|
82
61
|
Object.defineProperty(exports, "normalizeStyles", {
|
@@ -116,8 +95,9 @@ Object.keys(_normalizer).forEach(function (key) {
|
|
116
95
|
}
|
117
96
|
});
|
118
97
|
});
|
98
|
+
var _mq = require("./mq");
|
99
|
+
var _mqParser = require("./mqParser");
|
119
100
|
var _breakpoints = require("./breakpoints");
|
120
101
|
var _styles = require("./styles");
|
121
102
|
var _common = require("./common");
|
122
|
-
var _mediaQueries = require("./mediaQueries");
|
123
103
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_normalizeStyles","require","_normalizer","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_breakpoints","_styles","_common"
|
1
|
+
{"version":3,"names":["_normalizeStyles","require","_normalizer","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_mq","_mqParser","_breakpoints","_styles","_common"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,WAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,WAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,GAAA,GAAAd,OAAA;AACA,IAAAe,SAAA,GAAAf,OAAA;AACA,IAAAgB,YAAA,GAAAhB,OAAA;AACA,IAAAiB,OAAA,GAAAjB,OAAA;AACA,IAAAkB,OAAA,GAAAlB,OAAA"}
|