react-native-unistyles 2.0.0-alpha.6 → 2.0.0-alpha.7
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/useUnistyles.js.map +1 -1
- package/lib/commonjs/utils/index.js +8 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mq.js +75 -0
- package/lib/commonjs/utils/mq.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/useUnistyles.js.map +1 -1
- package/lib/module/utils/index.js +1 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mq.js +69 -0
- package/lib/module/utils/mq.js.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/useStyles.d.ts +1 -1
- package/lib/typescript/src/useUnistyles.d.ts +4 -5
- package/lib/typescript/src/useUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +1 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mq.d.ts +15 -0
- package/lib/typescript/src/utils/mq.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/useUnistyles.ts +11 -4
- package/src/utils/index.ts +1 -0
- package/src/utils/mq.ts +77 -0
package/lib/commonjs/index.js
CHANGED
@@ -16,6 +16,12 @@ 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 () {
|
@@ -30,6 +36,7 @@ Object.defineProperty(exports, "useStyles", {
|
|
30
36
|
});
|
31
37
|
var _Unistyles = require("./Unistyles");
|
32
38
|
var _types = require("./types");
|
39
|
+
var _utils = require("./utils");
|
33
40
|
var _useInitialTheme = require("./useInitialTheme");
|
34
41
|
var _useStyles = require("./useStyles");
|
35
42
|
var _createStyleSheet = require("./createStyleSheet");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_Unistyles","require","_types","_useInitialTheme","_useStyles","_createStyleSheet","addThemes","addBreakpoints","addConfig","unistyles","registry","UnistylesRuntime","exports","runtime","UnistylesRegistry","__dangerouslyUnregister","dangerouslyUnregister"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"
|
1
|
+
{"version":3,"names":["_Unistyles","require","_types","_utils","_useInitialTheme","_useStyles","_createStyleSheet","addThemes","addBreakpoints","addConfig","unistyles","registry","UnistylesRuntime","exports","runtime","UnistylesRegistry","__dangerouslyUnregister","dangerouslyUnregister"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAEA,MAAM;EAAEM,SAAS;EAAEC,cAAc;EAAEC;AAAW,CAAC,GAAGC,oBAAS,CAACC,QAAQ;AACpE,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAGF,oBAAS,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,oBAAS,CAACC,QAAQ,CAACM,qBAAqB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_react","_types","_Unistyles","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","useUnistyles","orientation","setOrientation","useState","unistyles","runtime","theme","setTheme","getTheme","themeName","breakpoint","setBreakpoint","screenSize","setScreenSize","width","screen","height","useEffect","subscription","addListener","event","type","CxxUnistylesEventTypes","Theme","themeEvent","payload","Layout","layoutEvent","remove","exports"],"sourceRoot":"../../src","sources":["useUnistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;
|
1
|
+
{"version":3,"names":["_reactNative","require","_react","_types","_Unistyles","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","useUnistyles","orientation","setOrientation","useState","unistyles","runtime","theme","setTheme","getTheme","themeName","breakpoint","setBreakpoint","screenSize","setScreenSize","width","screen","height","useEffect","subscription","addListener","event","type","CxxUnistylesEventTypes","Theme","themeEvent","payload","Layout","layoutEvent","remove","exports"],"sourceRoot":"../../src","sources":["useUnistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAQA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAGA,MAAMI,eAAe,GAAG,IAAIC,+BAAkB,CAACC,0BAAa,CAACC,SAAS,CAAC;AAEhE,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAG,IAAAC,eAAQ,EAAoBC,oBAAS,CAACC,OAAO,CAACJ,WAAW,CAAC;EAChG,MAAM,CAACK,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAJ,eAAQ,EAAiBC,oBAAS,CAACC,OAAO,CAACG,QAAQ,CAACJ,oBAAS,CAACC,OAAO,CAACI,SAAS,CAAC,CAAC;EAC3G,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAR,eAAQ,EAA6BC,oBAAS,CAACC,OAAO,CAACK,UAAU,CAAC;EACtG,MAAM,CAACE,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAV,eAAQ,EAAa;IACrDW,KAAK,EAAEV,oBAAS,CAACC,OAAO,CAACU,MAAM,CAACD,KAAK;IACrCE,MAAM,EAAEZ,oBAAS,CAACC,OAAO,CAACU,MAAM,CAACC;EACrC,CAAC,CAAC;EAEF,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,YAAY,GAAGtB,eAAe,CAACuB,WAAW,CAC5C,UAAU,EACTC,KAAsB,IAAK;MACxB,QAAQA,KAAK,CAACC,IAAI;QACd,KAAKC,6BAAsB,CAACC,KAAK;UAAE;YAC/B,MAAMC,UAAU,GAAGJ,KAA4B;YAE/Cb,QAAQ,CAACH,oBAAS,CAACC,OAAO,CAACG,QAAQ,CAACgB,UAAU,CAACC,OAAO,CAAChB,SAAS,CAAC,CAAC;YAElE;UACJ;QACA,KAAKa,6BAAsB,CAACI,MAAM;UAAE;YAChC,MAAMC,WAAW,GAAGP,KAAmC;YAEvDT,aAAa,CAACgB,WAAW,CAACF,OAAO,CAACf,UAAU,CAAC;YAC7CR,cAAc,CAACyB,WAAW,CAACF,OAAO,CAACxB,WAAW,CAAC;YAC/CY,aAAa,CAACc,WAAW,CAACF,OAAO,CAACV,MAAM,CAAC;YAEzC;UACJ;QACA;UACI;MACR;IACJ,CACJ,CAAC;IAED,OAAOG,YAAY,CAACU,MAAM;EAC9B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACHtB,KAAK;IACLL,WAAW;IACXS,UAAU;IACVE;EACJ,CAAC;AACL,CAAC;AAAAiB,OAAA,CAAA7B,YAAA,GAAAA,YAAA"}
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
var _exportNames = {
|
7
7
|
normalizeStyles: true,
|
8
|
+
mq: true,
|
8
9
|
getBreakpointFromScreenWidth: true,
|
9
10
|
sortAndValidateBreakpoints: true,
|
10
11
|
getValueForBreakpoint: true,
|
@@ -79,6 +80,12 @@ Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
|
|
79
80
|
return _mediaQueries.isWithinTheWidthAndHeight;
|
80
81
|
}
|
81
82
|
});
|
83
|
+
Object.defineProperty(exports, "mq", {
|
84
|
+
enumerable: true,
|
85
|
+
get: function () {
|
86
|
+
return _mq.mq;
|
87
|
+
}
|
88
|
+
});
|
82
89
|
Object.defineProperty(exports, "normalizeStyles", {
|
83
90
|
enumerable: true,
|
84
91
|
get: function () {
|
@@ -116,6 +123,7 @@ Object.keys(_normalizer).forEach(function (key) {
|
|
116
123
|
}
|
117
124
|
});
|
118
125
|
});
|
126
|
+
var _mq = require("./mq");
|
119
127
|
var _breakpoints = require("./breakpoints");
|
120
128
|
var _styles = require("./styles");
|
121
129
|
var _common = require("./common");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_normalizeStyles","require","_normalizer","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_breakpoints","_styles","_common","_mediaQueries"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"
|
1
|
+
{"version":3,"names":["_normalizeStyles","require","_normalizer","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_mq","_breakpoints","_styles","_common","_mediaQueries"],"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,YAAA,GAAAf,OAAA;AACA,IAAAgB,OAAA,GAAAhB,OAAA;AACA,IAAAiB,OAAA,GAAAjB,OAAA;AACA,IAAAkB,aAAA,GAAAlB,OAAA"}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.mq = void 0;
|
7
|
+
var _Unistyles = require("../Unistyles");
|
8
|
+
const MQSymbol = Symbol('unistyles-mq');
|
9
|
+
var MQProp = /*#__PURE__*/function (MQProp) {
|
10
|
+
MQProp["toString"] = "toString";
|
11
|
+
MQProp["width"] = "width";
|
12
|
+
MQProp["height"] = "height";
|
13
|
+
return MQProp;
|
14
|
+
}(MQProp || {});
|
15
|
+
const getMQValue = value => {
|
16
|
+
if (typeof value === 'number') {
|
17
|
+
return value;
|
18
|
+
}
|
19
|
+
return _Unistyles.unistyles.registry.breakpoints[value] ?? 0;
|
20
|
+
};
|
21
|
+
const mq = exports.mq = {
|
22
|
+
height: function () {
|
23
|
+
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
24
|
+
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
25
|
+
return new Proxy({}, {
|
26
|
+
get: (target, prop, receiver) => {
|
27
|
+
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
28
|
+
return () => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
29
|
+
}
|
30
|
+
if (prop === MQProp.width) {
|
31
|
+
return function () {
|
32
|
+
let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
33
|
+
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
34
|
+
return new Proxy({}, {
|
35
|
+
get: (target, prop, receiver) => {
|
36
|
+
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
37
|
+
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
38
|
+
}
|
39
|
+
return Reflect.get(target, prop, receiver);
|
40
|
+
}
|
41
|
+
});
|
42
|
+
};
|
43
|
+
}
|
44
|
+
return Reflect.get(target, prop, receiver);
|
45
|
+
}
|
46
|
+
});
|
47
|
+
},
|
48
|
+
width: function () {
|
49
|
+
let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
50
|
+
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
51
|
+
return new Proxy({}, {
|
52
|
+
get: (target, prop, receiver) => {
|
53
|
+
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
54
|
+
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
|
55
|
+
}
|
56
|
+
if (prop === MQProp.height) {
|
57
|
+
return function () {
|
58
|
+
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
59
|
+
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
60
|
+
return new Proxy({}, {
|
61
|
+
get: (target, prop, receiver) => {
|
62
|
+
if (prop === Symbol.toPrimitive || MQProp.toString) {
|
63
|
+
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
64
|
+
}
|
65
|
+
return Reflect.get(target, prop, receiver);
|
66
|
+
}
|
67
|
+
});
|
68
|
+
};
|
69
|
+
}
|
70
|
+
return Reflect.get(target, prop, receiver);
|
71
|
+
}
|
72
|
+
});
|
73
|
+
}
|
74
|
+
};
|
75
|
+
//# sourceMappingURL=mq.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_Unistyles","require","MQSymbol","Symbol","MQProp","getMQValue","value","unistyles","registry","breakpoints","mq","exports","height","hMin","arguments","length","undefined","hMax","Infinity","Proxy","get","target","prop","receiver","toPrimitive","toString","width","wMin","wMax","Reflect"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAEA,MAAMC,QAAQ,GAAGC,MAAM,CAAC,cAAc,CAAC;AAAA,IAgBlCC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA,EAANA,MAAM;AAMX,MAAMC,UAAU,GAAIC,KAAc,IAAK;EACnC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,OAAOC,oBAAS,CAACC,QAAQ,CAACC,WAAW,CAACH,KAAK,CAAC,IAAI,CAAC;AACrD,CAAC;AAEM,MAAMI,EAAE,GAAAC,OAAA,CAAAD,EAAA,GAAG;EACdE,MAAM,EAAE,SAAAA,CAAA;IAAA,IAACC,IAAa,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;IAAA,IAAEG,IAAa,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;IAAA,OAAK,IAAIC,KAAK,CAAgB,CAAC,CAAC,EAAmB;MACnGC,GAAG,EAAEA,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,KAAK;QAC7B,IAAID,IAAI,KAAKnB,MAAM,CAACqB,WAAW,IAAIF,IAAI,KAAKlB,MAAM,CAACqB,QAAQ,EAAE;UACzD,OAA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from './utils';
|
3
4
|
export { useInitialTheme } from './useInitialTheme';
|
4
5
|
export { useStyles } from './useStyles';
|
5
6
|
export { createStyleSheet } from './createStyleSheet';
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["unistyles","ScreenOrientation","useInitialTheme","useStyles","createStyleSheet","addThemes","addBreakpoints","addConfig","registry","UnistylesRuntime","runtime","UnistylesRegistry","__dangerouslyUnregister","dangerouslyUnregister"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,aAAa;AAEvC,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAM;EAAEC,SAAS;EAAEC,cAAc;EAAEC;AAAW,CAAC,
|
1
|
+
{"version":3,"names":["unistyles","ScreenOrientation","mq","useInitialTheme","useStyles","createStyleSheet","addThemes","addBreakpoints","addConfig","registry","UnistylesRuntime","runtime","UnistylesRegistry","__dangerouslyUnregister","dangerouslyUnregister"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,aAAa;AAEvC,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,SAASC,EAAE,QAAQ,SAAS;AAC5B,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAM;EAAEC,SAAS;EAAEC,cAAc;EAAEC;AAAW,CAAC,GAAGR,SAAS,CAACS,QAAQ;AACpE,MAAMC,gBAAgB,GAAGV,SAAS,CAACW,OAAO;AAC1C,MAAMC,iBAAiB,GAAG;EACtBN,SAAS;EACTC,cAAc;EACdC;AACJ,CAAC;AAED,OAAO,MAAMK,uBAAuB,GAAGb,SAAS,CAACS,QAAQ,CAACK,qBAAqB;AAE/E,SACIJ,gBAAgB,EAChBE,iBAAiB;AAGrB,SACIX,iBAAiB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","useEffect","useState","CxxUnistylesEventTypes","unistyles","unistylesEvents","Unistyles","useUnistyles","orientation","setOrientation","runtime","theme","setTheme","getTheme","themeName","breakpoint","setBreakpoint","screenSize","setScreenSize","width","screen","height","subscription","addListener","event","type","Theme","themeEvent","payload","Layout","layoutEvent","remove"],"sourceRoot":"../../src","sources":["useUnistyles.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAChE,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","useEffect","useState","CxxUnistylesEventTypes","unistyles","unistylesEvents","Unistyles","useUnistyles","orientation","setOrientation","runtime","theme","setTheme","getTheme","themeName","breakpoint","setBreakpoint","screenSize","setScreenSize","width","screen","height","subscription","addListener","event","type","Theme","themeEvent","payload","Layout","layoutEvent","remove"],"sourceRoot":"../../src","sources":["useUnistyles.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAChE,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAQ3C,SAASC,sBAAsB,QAA2B,SAAS;AACnE,SAASC,SAAS,QAAQ,aAAa;AAGvC,MAAMC,eAAe,GAAG,IAAIN,kBAAkB,CAACC,aAAa,CAACM,SAAS,CAAC;AAEvE,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGP,QAAQ,CAAoBE,SAAS,CAACM,OAAO,CAACF,WAAW,CAAC;EAChG,MAAM,CAACG,KAAK,EAAEC,QAAQ,CAAC,GAAGV,QAAQ,CAAiBE,SAAS,CAACM,OAAO,CAACG,QAAQ,CAACT,SAAS,CAACM,OAAO,CAACI,SAAS,CAAC,CAAC;EAC3G,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGd,QAAQ,CAA6BE,SAAS,CAACM,OAAO,CAACK,UAAU,CAAC;EACtG,MAAM,CAACE,UAAU,EAAEC,aAAa,CAAC,GAAGhB,QAAQ,CAAa;IACrDiB,KAAK,EAAEf,SAAS,CAACM,OAAO,CAACU,MAAM,CAACD,KAAK;IACrCE,MAAM,EAAEjB,SAAS,CAACM,OAAO,CAACU,MAAM,CAACC;EACrC,CAAC,CAAC;EAEFpB,SAAS,CAAC,MAAM;IACZ,MAAMqB,YAAY,GAAGjB,eAAe,CAACkB,WAAW,CAC5C,UAAU,EACTC,KAAsB,IAAK;MACxB,QAAQA,KAAK,CAACC,IAAI;QACd,KAAKtB,sBAAsB,CAACuB,KAAK;UAAE;YAC/B,MAAMC,UAAU,GAAGH,KAA4B;YAE/CZ,QAAQ,CAACR,SAAS,CAACM,OAAO,CAACG,QAAQ,CAACc,UAAU,CAACC,OAAO,CAACd,SAAS,CAAC,CAAC;YAElE;UACJ;QACA,KAAKX,sBAAsB,CAAC0B,MAAM;UAAE;YAChC,MAAMC,WAAW,GAAGN,KAAmC;YAEvDR,aAAa,CAACc,WAAW,CAACF,OAAO,CAACb,UAAU,CAAC;YAC7CN,cAAc,CAACqB,WAAW,CAACF,OAAO,CAACpB,WAAW,CAAC;YAC/CU,aAAa,CAACY,WAAW,CAACF,OAAO,CAACR,MAAM,CAAC;YAEzC;UACJ;QACA;UACI;MACR;IACJ,CACJ,CAAC;IAED,OAAOE,YAAY,CAACS,MAAM;EAC9B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACHpB,KAAK;IACLH,WAAW;IACXO,UAAU;IACVE;EACJ,CAAC;AACL,CAAC"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
export { normalizeStyles } from './normalizeStyles';
|
2
2
|
export * from './normalizer';
|
3
|
+
export { mq } from './mq';
|
3
4
|
export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints';
|
4
5
|
export { proxifyFunction, parseStyle } from './styles';
|
5
6
|
export { isServer, Orientation } from './common';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["normalizeStyles","getBreakpointFromScreenWidth","sortAndValidateBreakpoints","getValueForBreakpoint","proxifyFunction","parseStyle","isServer","Orientation","extractValues","getKeyForCustomMediaQuery","isMediaQuery","isWithinTheHeight","isWithinTheWidth","isWithinTheWidthAndHeight"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,cAAc,cAAc;AAC5B,SAASC,4BAA4B,EAAEC,0BAA0B,EAAEC,qBAAqB,QAAQ,eAAe;AAC/G,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;AACtD,SAASC,QAAQ,EAAEC,WAAW,QAAQ,UAAU;AAChD,SACIC,aAAa,EACbC,yBAAyB,EACzBC,YAAY,EACZC,iBAAiB,EACjBC,gBAAgB,EAChBC,yBAAyB,QACtB,gBAAgB"}
|
1
|
+
{"version":3,"names":["normalizeStyles","mq","getBreakpointFromScreenWidth","sortAndValidateBreakpoints","getValueForBreakpoint","proxifyFunction","parseStyle","isServer","Orientation","extractValues","getKeyForCustomMediaQuery","isMediaQuery","isWithinTheHeight","isWithinTheWidth","isWithinTheWidthAndHeight"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,cAAc,cAAc;AAC5B,SAASC,EAAE,QAAQ,MAAM;AACzB,SAASC,4BAA4B,EAAEC,0BAA0B,EAAEC,qBAAqB,QAAQ,eAAe;AAC/G,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;AACtD,SAASC,QAAQ,EAAEC,WAAW,QAAQ,UAAU;AAChD,SACIC,aAAa,EACbC,yBAAyB,EACzBC,YAAY,EACZC,iBAAiB,EACjBC,gBAAgB,EAChBC,yBAAyB,QACtB,gBAAgB"}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import { unistyles } from '../Unistyles';
|
2
|
+
const MQSymbol = Symbol('unistyles-mq');
|
3
|
+
var MQProp = /*#__PURE__*/function (MQProp) {
|
4
|
+
MQProp["toString"] = "toString";
|
5
|
+
MQProp["width"] = "width";
|
6
|
+
MQProp["height"] = "height";
|
7
|
+
return MQProp;
|
8
|
+
}(MQProp || {});
|
9
|
+
const getMQValue = value => {
|
10
|
+
if (typeof value === 'number') {
|
11
|
+
return value;
|
12
|
+
}
|
13
|
+
return unistyles.registry.breakpoints[value] ?? 0;
|
14
|
+
};
|
15
|
+
export const mq = {
|
16
|
+
height: function () {
|
17
|
+
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
18
|
+
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
19
|
+
return new Proxy({}, {
|
20
|
+
get: (target, prop, receiver) => {
|
21
|
+
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
22
|
+
return () => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
23
|
+
}
|
24
|
+
if (prop === MQProp.width) {
|
25
|
+
return function () {
|
26
|
+
let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
27
|
+
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
28
|
+
return new Proxy({}, {
|
29
|
+
get: (target, prop, receiver) => {
|
30
|
+
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
31
|
+
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
32
|
+
}
|
33
|
+
return Reflect.get(target, prop, receiver);
|
34
|
+
}
|
35
|
+
});
|
36
|
+
};
|
37
|
+
}
|
38
|
+
return Reflect.get(target, prop, receiver);
|
39
|
+
}
|
40
|
+
});
|
41
|
+
},
|
42
|
+
width: function () {
|
43
|
+
let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
44
|
+
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
45
|
+
return new Proxy({}, {
|
46
|
+
get: (target, prop, receiver) => {
|
47
|
+
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
48
|
+
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
|
49
|
+
}
|
50
|
+
if (prop === MQProp.height) {
|
51
|
+
return function () {
|
52
|
+
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
53
|
+
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
54
|
+
return new Proxy({}, {
|
55
|
+
get: (target, prop, receiver) => {
|
56
|
+
if (prop === Symbol.toPrimitive || MQProp.toString) {
|
57
|
+
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
58
|
+
}
|
59
|
+
return Reflect.get(target, prop, receiver);
|
60
|
+
}
|
61
|
+
});
|
62
|
+
};
|
63
|
+
}
|
64
|
+
return Reflect.get(target, prop, receiver);
|
65
|
+
}
|
66
|
+
});
|
67
|
+
}
|
68
|
+
};
|
69
|
+
//# sourceMappingURL=mq.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["unistyles","MQSymbol","Symbol","MQProp","getMQValue","value","registry","breakpoints","mq","height","hMin","arguments","length","undefined","hMax","Infinity","Proxy","get","target","prop","receiver","toPrimitive","toString","width","wMin","wMax","Reflect"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":"AACA,SAASA,SAAS,QAAQ,cAAc;AAExC,MAAMC,QAAQ,GAAGC,MAAM,CAAC,cAAc,CAAC;AAAA,IAgBlCC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA,EAANA,MAAM;AAMX,MAAMC,UAAU,GAAIC,KAAc,IAAK;EACnC,IAAI,OAAOA,KAAK,KA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,KAAK;gBAC7B,IAAID,IAAI,KAAKjB,MAAM,CAACmB,WAAW,IAAIlB,MAAM,CAACmB,QAAQ,EAAE;kBAChD,OAAO,MAAO,MAAKlB,UAAU,CAACoB,IAAI,CAAE,KAAIpB,UAAU,CAACqB,IAAI,CAAE,OAAMrB,UAAU,CAACM,IAAI,CAAE,KAAIN,UAAU,CAACU,IAAI,CAAE,GAAE;gBAC3G;gBAEA,OAAOY,OAAO,CAACT,GAAG,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,CAAC;cAC9C;YACJ,CAAC,CAAC;UAAA;QACN;QAEA,OAAOM,OAAO,CAACT,GAAG,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,CAAC;MAC9C;IACJ,CAAC,CAAC;EAAA;AACN,CAAC"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { UnistylesThemes, UnistylesBreakpoints } from './global';
|
2
2
|
import { ScreenOrientation } from './types';
|
3
|
+
export { mq } from './utils';
|
3
4
|
export { useInitialTheme } from './useInitialTheme';
|
4
5
|
export { useStyles } from './useStyles';
|
5
6
|
export { createStyleSheet } from './createStyleSheet';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD,QAAA,MAAM,gBAAgB,+CAAoB,CAAA;AAC1C,QAAA,MAAM,iBAAiB;;;;CAItB,CAAA;AAED,eAAO,MAAM,uBAAuB,YAA2C,CAAA;AAE/E,OAAO,EACH,gBAAgB,EAChB,iBAAiB,EACpB,CAAA;AAED,OAAO,EACH,iBAAiB,EACpB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACvB,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE3C,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD,QAAA,MAAM,gBAAgB,+CAAoB,CAAA;AAC1C,QAAA,MAAM,iBAAiB;;;;CAItB,CAAA;AAED,eAAO,MAAM,uBAAuB,YAA2C,CAAA;AAE/E,OAAO,EACH,gBAAgB,EAChB,iBAAiB,EACpB,CAAA;AAED,OAAO,EACH,iBAAiB,EACpB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACvB,CAAA"}
|
@@ -2,7 +2,7 @@ import type { CreateStylesFactory, CustomNamedStyles, ExtractBreakpoints, Remove
|
|
2
2
|
import type { UnistylesTheme } from './types';
|
3
3
|
export declare const useStyles: <ST extends CustomNamedStyles<ST>>(stylesheet?: ST | CreateStylesFactory<ST, never> | undefined) => {
|
4
4
|
theme: never;
|
5
|
-
breakpoint:
|
5
|
+
breakpoint: keyof import("./global").UnistylesBreakpoints;
|
6
6
|
styles: ExtractBreakpoints<RemoveKeysWithPrefix<ST>>;
|
7
7
|
};
|
8
8
|
//# sourceMappingURL=useStyles.d.ts.map
|
@@ -1,11 +1,10 @@
|
|
1
|
+
import type { ScreenSize } from './types';
|
1
2
|
import { ScreenOrientation } from './types';
|
3
|
+
import type { UnistylesBreakpoints } from './global';
|
2
4
|
export declare const useUnistyles: () => {
|
3
5
|
theme: never;
|
4
6
|
orientation: ScreenOrientation;
|
5
|
-
breakpoint:
|
6
|
-
screenSize:
|
7
|
-
width: number;
|
8
|
-
height: number;
|
9
|
-
};
|
7
|
+
breakpoint: keyof UnistylesBreakpoints;
|
8
|
+
screenSize: ScreenSize;
|
10
9
|
};
|
11
10
|
//# sourceMappingURL=useUnistyles.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../src/useUnistyles.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../src/useUnistyles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIR,UAAU,EAEb,MAAM,SAAS,CAAA;AAChB,OAAO,EAA0B,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAIpD,eAAO,MAAM,YAAY;;;;;CA6CxB,CAAA"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
export { normalizeStyles } from './normalizeStyles';
|
2
2
|
export * from './normalizer';
|
3
|
+
export { mq } from './mq';
|
3
4
|
export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints';
|
4
5
|
export { proxifyFunction, parseStyle } from './styles';
|
5
6
|
export { isServer, Orientation } from './common';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC/G,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EACH,aAAa,EACb,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EAC5B,MAAM,gBAAgB,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC/G,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EACH,aAAa,EACb,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EAC5B,MAAM,gBAAgB,CAAA"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import type { UnistylesBreakpoints } from '../global';
|
2
|
+
declare const MQSymbol: unique symbol;
|
3
|
+
type MQValue = keyof UnistylesBreakpoints | number;
|
4
|
+
type HeightHandler = {
|
5
|
+
width(wMin?: MQValue, wMax?: MQValue): typeof MQSymbol;
|
6
|
+
} & typeof MQSymbol;
|
7
|
+
type WidthHandler = {
|
8
|
+
height(hMin?: MQValue, hMax?: MQValue): typeof MQSymbol;
|
9
|
+
} & typeof MQSymbol;
|
10
|
+
export declare const mq: {
|
11
|
+
height: (hMin?: MQValue, hMax?: MQValue) => HeightHandler;
|
12
|
+
width: (wMin?: MQValue, wMax?: MQValue) => WidthHandler;
|
13
|
+
};
|
14
|
+
export {};
|
15
|
+
//# sourceMappingURL=mq.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../../../src/utils/mq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAGrD,QAAA,MAAM,QAAQ,eAAyB,CAAA;AAEvC,KAAK,OAAO,GAAG,MAAM,oBAAoB,GAAG,MAAM,CAAA;AAElD,KAAK,aAAa,GAAG;IACjB,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,QAAQ,CAAA;CACzD,GAAG,OAAO,QAAQ,CAAA;AAEnB,KAAK,YAAY,GAAG;IAChB,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,QAAQ,CAAA;CAC1D,GAAG,OAAO,QAAQ,CAAA;AAoBnB,eAAO,MAAM,EAAE;oBACI,OAAO,SAAY,OAAO;mBAqB3B,OAAO,SAAY,OAAO;CAqB3C,CAAA"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
@@ -2,6 +2,7 @@ import { unistyles } from './Unistyles'
|
|
2
2
|
import type { UnistylesThemes, UnistylesBreakpoints } from './global'
|
3
3
|
import { ScreenOrientation } from './types'
|
4
4
|
|
5
|
+
export { mq } from './utils'
|
5
6
|
export { useInitialTheme } from './useInitialTheme'
|
6
7
|
|
7
8
|
export { useStyles } from './useStyles'
|
package/src/useUnistyles.ts
CHANGED
@@ -1,16 +1,23 @@
|
|
1
1
|
import { NativeEventEmitter, NativeModules } from 'react-native'
|
2
2
|
import { useEffect, useState } from 'react'
|
3
|
-
import type {
|
3
|
+
import type {
|
4
|
+
UnistylesThemeEvent,
|
5
|
+
UnistylesMobileLayoutEvent,
|
6
|
+
UnistylesEvents,
|
7
|
+
ScreenSize,
|
8
|
+
UnistylesTheme
|
9
|
+
} from './types'
|
4
10
|
import { CxxUnistylesEventTypes, ScreenOrientation } from './types'
|
5
11
|
import { unistyles } from './Unistyles'
|
12
|
+
import type { UnistylesBreakpoints } from './global'
|
6
13
|
|
7
14
|
const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles)
|
8
15
|
|
9
16
|
export const useUnistyles = () => {
|
10
17
|
const [orientation, setOrientation] = useState<ScreenOrientation>(unistyles.runtime.orientation)
|
11
|
-
const [theme, setTheme] = useState(unistyles.runtime.getTheme(unistyles.runtime.themeName))
|
12
|
-
const [breakpoint, setBreakpoint] = useState(unistyles.runtime.breakpoint)
|
13
|
-
const [screenSize, setScreenSize] = useState({
|
18
|
+
const [theme, setTheme] = useState<UnistylesTheme>(unistyles.runtime.getTheme(unistyles.runtime.themeName))
|
19
|
+
const [breakpoint, setBreakpoint] = useState<keyof UnistylesBreakpoints>(unistyles.runtime.breakpoint)
|
20
|
+
const [screenSize, setScreenSize] = useState<ScreenSize>({
|
14
21
|
width: unistyles.runtime.screen.width,
|
15
22
|
height: unistyles.runtime.screen.height
|
16
23
|
})
|
package/src/utils/index.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
export { normalizeStyles } from './normalizeStyles'
|
2
2
|
export * from './normalizer'
|
3
|
+
export { mq } from './mq'
|
3
4
|
export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints'
|
4
5
|
export { proxifyFunction, parseStyle } from './styles'
|
5
6
|
export { isServer, Orientation } from './common'
|
package/src/utils/mq.ts
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
import type { UnistylesBreakpoints } from '../global'
|
2
|
+
import { unistyles } from '../Unistyles'
|
3
|
+
|
4
|
+
const MQSymbol = Symbol('unistyles-mq')
|
5
|
+
|
6
|
+
type MQValue = keyof UnistylesBreakpoints | number
|
7
|
+
|
8
|
+
type HeightHandler = {
|
9
|
+
width(wMin?: MQValue, wMax?: MQValue): typeof MQSymbol
|
10
|
+
} & typeof MQSymbol
|
11
|
+
|
12
|
+
type WidthHandler = {
|
13
|
+
height(hMin?: MQValue, hMax?: MQValue): typeof MQSymbol
|
14
|
+
} & typeof MQSymbol
|
15
|
+
|
16
|
+
type FinalHandler = {
|
17
|
+
[MQSymbol]: true
|
18
|
+
}
|
19
|
+
|
20
|
+
enum MQProp {
|
21
|
+
toString = 'toString',
|
22
|
+
width = 'width',
|
23
|
+
height = 'height'
|
24
|
+
}
|
25
|
+
|
26
|
+
const getMQValue = (value: MQValue) => {
|
27
|
+
if (typeof value === 'number') {
|
28
|
+
return value
|
29
|
+
}
|
30
|
+
|
31
|
+
return unistyles.registry.breakpoints[value] ?? 0
|
32
|
+
}
|
33
|
+
|
34
|
+
export const mq = {
|
35
|
+
height: (hMin: MQValue = 0, hMax: MQValue = Infinity) => new Proxy<HeightHandler>({} as HeightHandler, {
|
36
|
+
get: (target, prop, receiver) => {
|
37
|
+
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
38
|
+
return () => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
39
|
+
}
|
40
|
+
|
41
|
+
if (prop === MQProp.width) {
|
42
|
+
return (wMin: MQValue = 0, wMax: MQValue = Infinity) => new Proxy<FinalHandler>({} as FinalHandler, {
|
43
|
+
get: (target, prop, receiver) => {
|
44
|
+
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
45
|
+
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
46
|
+
}
|
47
|
+
|
48
|
+
return Reflect.get(target, prop, receiver)
|
49
|
+
}
|
50
|
+
})
|
51
|
+
}
|
52
|
+
|
53
|
+
return Reflect.get(target, prop, receiver)
|
54
|
+
}
|
55
|
+
}),
|
56
|
+
width: (wMin: MQValue = 0, wMax: MQValue = Infinity) => new Proxy({} as WidthHandler, {
|
57
|
+
get: (target, prop, receiver) => {
|
58
|
+
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
59
|
+
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`
|
60
|
+
}
|
61
|
+
|
62
|
+
if (prop === MQProp.height) {
|
63
|
+
return (hMin: MQValue = 0, hMax: MQValue = Infinity) => new Proxy<FinalHandler>({} as FinalHandler, {
|
64
|
+
get: (target, prop, receiver) => {
|
65
|
+
if (prop === Symbol.toPrimitive || MQProp.toString) {
|
66
|
+
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
|
67
|
+
}
|
68
|
+
|
69
|
+
return Reflect.get(target, prop, receiver)
|
70
|
+
}
|
71
|
+
})
|
72
|
+
}
|
73
|
+
|
74
|
+
return Reflect.get(target, prop, receiver)
|
75
|
+
}
|
76
|
+
})
|
77
|
+
}
|