react-native-unistyles 2.0.0-alpha.9 → 2.0.0-beta.2
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +28 -0
- package/android/build.gradle +40 -0
- package/android/src/main/cxx/cpp-adapter.cpp +108 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +159 -0
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +18 -0
- package/cxx/UnistylesRuntime.cpp +55 -2
- package/cxx/UnistylesRuntime.h +15 -9
- package/ios/UnistylesModule.mm +16 -6
- package/lib/commonjs/common.js +30 -16
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistyleRegistry.js +65 -3
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/core/Unistyles.js +1 -1
- package/lib/commonjs/core/Unistyles.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.web.js +187 -0
- package/lib/commonjs/core/UnistylesModule.web.js.map +1 -0
- package/lib/commonjs/core/UnistylesRuntime.js +15 -16
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
- package/lib/commonjs/createStyleSheet.js +1 -6
- package/lib/commonjs/createStyleSheet.js.map +1 -1
- package/lib/commonjs/hooks/index.js +7 -0
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useUnistyles.js +12 -9
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
- package/lib/commonjs/hooks/useVariants.js +14 -0
- package/lib/commonjs/hooks/useVariants.js.map +1 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/plugins/index.js +38 -0
- package/lib/commonjs/plugins/index.js.map +1 -0
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +12 -0
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -0
- package/lib/commonjs/plugins/normalizer/index.js +32 -0
- package/lib/commonjs/plugins/normalizer/index.js.map +1 -0
- package/lib/commonjs/plugins/normalizer/module.d.js.map +1 -0
- package/lib/commonjs/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +5 -5
- package/lib/commonjs/plugins/normalizer/normalizeStyle.js.map +1 -0
- package/lib/commonjs/{utils → plugins/normalizer}/normalizer.js +1 -1
- package/lib/commonjs/plugins/normalizer/normalizer.js.map +1 -0
- package/lib/commonjs/types/{mq.js → plugin.js} +1 -1
- package/lib/commonjs/types/{mq.js.map → plugin.js.map} +1 -1
- package/lib/commonjs/types/stylesheet.js +6 -0
- package/lib/commonjs/types/stylesheet.js.map +1 -0
- package/lib/commonjs/types/variants.js +2 -0
- package/lib/commonjs/{utils/module.d.js.map → types/variants.js.map} +1 -1
- package/lib/commonjs/useStyles.js +10 -20
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js +13 -59
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/index.js +13 -51
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mq.js +36 -68
- package/lib/commonjs/utils/mq.js.map +1 -1
- package/lib/commonjs/utils/mqParser.js +4 -1
- package/lib/commonjs/utils/mqParser.js.map +1 -1
- package/lib/commonjs/utils/styles.js +35 -20
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/commonjs/utils/withPlugins.js +15 -0
- package/lib/commonjs/utils/withPlugins.js.map +1 -0
- package/lib/module/common.js +28 -17
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistyleRegistry.js +65 -3
- package/lib/module/core/UnistyleRegistry.js.map +1 -1
- package/lib/module/core/Unistyles.js +2 -2
- package/lib/module/core/Unistyles.js.map +1 -1
- package/lib/module/core/UnistylesModule.web.js +180 -0
- package/lib/module/core/UnistylesModule.web.js.map +1 -0
- package/lib/module/core/UnistylesRuntime.js +15 -16
- package/lib/module/core/UnistylesRuntime.js.map +1 -1
- package/lib/module/createStyleSheet.js +1 -6
- package/lib/module/createStyleSheet.js.map +1 -1
- package/lib/module/hooks/index.js +1 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useUnistyles.js +13 -10
- package/lib/module/hooks/useUnistyles.js.map +1 -1
- package/lib/module/hooks/useVariants.js +7 -0
- package/lib/module/hooks/useVariants.js.map +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/plugins/index.js +3 -0
- package/lib/module/plugins/index.js.map +1 -0
- package/lib/module/plugins/normalizeWebStylesPlugin.js +6 -0
- package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -0
- package/lib/module/plugins/normalizer/index.js +3 -0
- package/lib/module/plugins/normalizer/index.js.map +1 -0
- package/lib/module/plugins/normalizer/module.d.js.map +1 -0
- package/lib/module/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +3 -3
- package/lib/module/plugins/normalizer/normalizeStyle.js.map +1 -0
- package/lib/module/{utils → plugins/normalizer}/normalizer.js +1 -1
- package/lib/module/plugins/normalizer/normalizer.js.map +1 -0
- package/lib/module/types/plugin.js +2 -0
- package/lib/module/types/{mq.js.map → plugin.js.map} +1 -1
- package/lib/module/types/stylesheet.js +2 -0
- package/lib/module/types/stylesheet.js.map +1 -0
- package/lib/module/types/variants.js +2 -0
- package/lib/module/{utils/module.d.js.map → types/variants.js.map} +1 -1
- package/lib/module/useStyles.js +12 -22
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/breakpoints.js +12 -56
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/index.js +4 -6
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mq.js +35 -67
- package/lib/module/utils/mq.js.map +1 -1
- package/lib/module/utils/mqParser.js +3 -3
- package/lib/module/utils/mqParser.js.map +1 -1
- package/lib/module/utils/styles.js +35 -20
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/module/utils/withPlugins.js +8 -0
- package/lib/module/utils/withPlugins.js.map +1 -0
- package/lib/typescript/src/common.d.ts +23 -12
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistyleRegistry.d.ts +45 -4
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.web.d.ts +19 -0
- package/lib/typescript/src/core/UnistylesModule.web.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +8 -9
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
- package/lib/typescript/src/core/index.d.ts +1 -0
- package/lib/typescript/src/core/index.d.ts.map +1 -1
- package/lib/typescript/src/createStyleSheet.d.ts +2 -2
- package/lib/typescript/src/createStyleSheet.d.ts.map +1 -1
- package/lib/typescript/src/global.d.ts.map +1 -1
- package/lib/typescript/src/hooks/index.d.ts +1 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useUnistyles.d.ts +2 -1
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useVariants.d.ts +3 -0
- package/lib/typescript/src/hooks/useVariants.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +51 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugins/index.d.ts +3 -0
- package/lib/typescript/src/plugins/index.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +3 -0
- package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizer/index.d.ts +3 -0
- package/lib/typescript/src/plugins/normalizer/index.d.ts.map +1 -0
- package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts +3 -0
- package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts.map +1 -0
- package/lib/typescript/src/{utils → plugins/normalizer}/normalizer.d.ts +1 -1
- package/lib/typescript/src/plugins/normalizer/normalizer.d.ts.map +1 -0
- package/lib/typescript/src/types/breakpoints.d.ts +25 -12
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +6 -27
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +4 -2
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/plugin.d.ts +7 -0
- package/lib/typescript/src/types/plugin.d.ts.map +1 -0
- package/lib/typescript/src/types/stylesheet.d.ts +40 -0
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -0
- package/lib/typescript/src/types/unistyles.d.ts +16 -11
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
- package/lib/typescript/src/types/variants.d.ts +14 -0
- package/lib/typescript/src/types/variants.d.ts.map +1 -0
- package/lib/typescript/src/useStyles.d.ts +3 -3
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/breakpoints.d.ts +2 -5
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +4 -6
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mq.d.ts +15 -14
- package/lib/typescript/src/utils/mq.d.ts.map +1 -1
- package/lib/typescript/src/utils/mqParser.d.ts +14 -2
- package/lib/typescript/src/utils/mqParser.d.ts.map +1 -1
- package/lib/typescript/src/utils/styles.d.ts +3 -4
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/lib/typescript/src/utils/withPlugins.d.ts +3 -0
- package/lib/typescript/src/utils/withPlugins.d.ts.map +1 -0
- package/package.json +19 -16
- package/src/__tests__/mocks.ts +24 -0
- package/src/common.ts +30 -14
- package/src/core/UnistyleRegistry.ts +66 -4
- package/src/core/Unistyles.ts +2 -2
- package/src/core/UnistylesModule.web.ts +214 -0
- package/src/core/UnistylesRuntime.ts +18 -20
- package/src/core/index.ts +1 -0
- package/src/createStyleSheet.ts +2 -8
- package/src/global.ts +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useUnistyles.ts +12 -10
- package/src/hooks/useVariants.ts +10 -0
- package/src/index.ts +3 -1
- package/src/plugins/index.ts +2 -0
- package/src/plugins/normalizeWebStylesPlugin.ts +7 -0
- package/src/plugins/normalizer/index.ts +2 -0
- package/src/{utils/normalizeStyles.web.ts → plugins/normalizer/normalizeStyle.ts} +3 -3
- package/src/{utils → plugins/normalizer}/normalizer.ts +3 -3
- package/src/types/breakpoints.ts +57 -25
- package/src/types/core.ts +9 -43
- package/src/types/index.ts +11 -2
- package/src/types/plugin.ts +7 -0
- package/src/types/stylesheet.ts +49 -0
- package/src/types/unistyles.ts +18 -13
- package/src/types/variants.ts +19 -0
- package/src/useStyles.ts +18 -25
- package/src/utils/breakpoints.ts +11 -67
- package/src/utils/index.ts +4 -6
- package/src/utils/mq.ts +31 -84
- package/src/utils/mqParser.ts +5 -5
- package/src/utils/styles.ts +44 -50
- package/src/utils/withPlugins.ts +13 -0
- package/lib/commonjs/utils/common.js +0 -25
- package/lib/commonjs/utils/common.js.map +0 -1
- package/lib/commonjs/utils/normalizeStyles.js +0 -10
- package/lib/commonjs/utils/normalizeStyles.js.map +0 -1
- package/lib/commonjs/utils/normalizeStyles.web.js.map +0 -1
- package/lib/commonjs/utils/normalizer.js.map +0 -1
- package/lib/module/types/mq.js +0 -2
- package/lib/module/utils/common.js +0 -17
- package/lib/module/utils/common.js.map +0 -1
- package/lib/module/utils/normalizeStyles.js +0 -3
- package/lib/module/utils/normalizeStyles.js.map +0 -1
- package/lib/module/utils/normalizeStyles.web.js.map +0 -1
- package/lib/module/utils/normalizer.js.map +0 -1
- package/lib/typescript/src/types/mq.d.ts +0 -3
- package/lib/typescript/src/types/mq.d.ts.map +0 -1
- package/lib/typescript/src/utils/common.d.ts +0 -12
- package/lib/typescript/src/utils/common.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizeStyles.d.ts +0 -2
- package/lib/typescript/src/utils/normalizeStyles.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts +0 -5
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +0 -1
- package/lib/typescript/src/utils/normalizer.d.ts.map +0 -1
- package/src/types/mq.ts +0 -3
- package/src/utils/common.ts +0 -20
- package/src/utils/normalizeStyles.ts +0 -2
- /package/lib/commonjs/{utils → plugins/normalizer}/module.d.js +0 -0
- /package/lib/module/{utils → plugins/normalizer}/module.d.js +0 -0
- /package/src/{utils → plugins/normalizer}/module.d.ts +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["plugins/normalizer/module.d.ts"],"mappings":""}
|
@@ -3,9 +3,9 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
7
|
-
var _common = require("./common");
|
6
|
+
exports.normalizeStyle = void 0;
|
8
7
|
var _normalizer = require("./normalizer");
|
8
|
+
var _common = require("../../common");
|
9
9
|
const normalizeBoxShadow = style => {
|
10
10
|
const requiredBoxShadowProperties = ['shadowColor', 'shadowOffset', 'shadowOpacity', 'shadowRadius'];
|
11
11
|
if (!requiredBoxShadowProperties.every(prop => prop in style)) {
|
@@ -42,7 +42,7 @@ const normalizeTextShadow = style => {
|
|
42
42
|
textShadowRadius: undefined
|
43
43
|
};
|
44
44
|
};
|
45
|
-
const
|
45
|
+
const normalizeStyle = style => {
|
46
46
|
const normalizedTransform = 'transform' in style && Array.isArray(style.transform) ? {
|
47
47
|
transform: _normalizer.preprocessor.createTransformValue(style.transform)
|
48
48
|
} : {};
|
@@ -55,5 +55,5 @@ const normalizeStyles = style => {
|
|
55
55
|
...normalizedTextShadow
|
56
56
|
};
|
57
57
|
};
|
58
|
-
exports.
|
59
|
-
//# sourceMappingURL=
|
58
|
+
exports.normalizeStyle = normalizeStyle;
|
59
|
+
//# sourceMappingURL=normalizeStyle.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_normalizer","require","_common","normalizeBoxShadow","style","requiredBoxShadowProperties","every","prop","warn","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","preprocessor","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyle","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow","exports"],"sourceRoot":"../../../../src","sources":["plugins/normalizer/normalizeStyle.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAGA,MAAME,kBAAkB,GAAyBC,KAAQ,IAA0B;EAC/E,MAAMC,2BAA2B,GAAG,CAChC,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,CACjB;EAED,IAAI,CAACA,2BAA2B,CAACC,KAAK,CAACC,IAAI,IAAIA,IAAI,IAAIH,KAAK,CAAC,EAAE;IAC3D,IAAAI,YAAI,EAAE,wEAAuEH,2BAA2B,CAACI,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;IAEtH,OAAO;MACHC,WAAW,EAAEC,SAAS;MACtBC,YAAY,EAAED,SAAS;MACvBE,aAAa,EAAEF,SAAS;MACxBG,YAAY,EAAEH;IAClB,CAAC;EACL;EAEA,OAAO;IACHI,SAAS,EAAEC,wBAAY,CAACC,oBAAoB,CAACb,KAAK,CAAC;IACnDM,WAAW,EAAEC,SAAS;IACtBC,YAAY,EAAED,SAAS;IACvBE,aAAa,EAAEF,SAAS;IACxBG,YAAY,EAAEH;EAClB,CAAC;AACL,CAAC;AAED,MAAMO,mBAAmB,GAA0Bd,KAAQ,IAA2B;EAClF,MAAMe,4BAA4B,GAAG,CACjC,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,CACrB;EAED,IAAI,CAACA,4BAA4B,CAACb,KAAK,CAACC,IAAI,IAAIA,IAAI,IAAIH,KAAK,CAAC,EAAE;IAC5D,IAAAI,YAAI,EAAE,yEAAwEW,4BAA4B,CAACV,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;IAExH,OAAO;MACHW,eAAe,EAAET,SAAS;MAC1BU,gBAAgB,EAAEV,SAAS;MAC3BW,gBAAgB,EAAEX;IACtB,CAAC;EACL;EAEA,OAAO;IACHY,UAAU,EAAEP,wBAAY,CAACQ,qBAAqB,CAACpB,KAAK,CAAC;IACrDgB,eAAe,EAAET,SAAS;IAC1BU,gBAAgB,EAAEV,SAAS;IAC3BW,gBAAgB,EAAEX;EACtB,CAAC;AACL,CAAC;AAEM,MAAMc,cAAc,GAAuBrB,KAAQ,IAAQ;EAC9D,MAAMsB,mBAAmB,GAAI,WAAW,IAAItB,KAAK,IAAIuB,KAAK,CAACC,OAAO,CAACxB,KAAK,CAACyB,SAAS,CAAC,GAC7E;IAAEA,SAAS,EAAEb,wBAAY,CAACc,oBAAoB,CAAC1B,KAAK,CAACyB,SAAS;EAAE,CAAC,GACjE,CAAC,CAAC;EAER,MAAME,mBAAmB,GACrB,aAAa,IAAI3B,KAAK,IACtB,cAAc,IAAIA,KAAK,IACvB,eAAe,IAAIA,KAAK,IACxB,cAAc,IAAIA,KAAK,GACvBD,kBAAkB,CAACC,KAAkB,CAAC,GAAG,CAAC,CAAC;EAE/C,MAAM4B,oBAAoB,GACtB,iBAAiB,IAAI5B,KAAK,IAC1B,kBAAkB,IAAIA,KAAK,IAC3B,kBAAkB,IAAIA,KAAK,GAC3Bc,mBAAmB,CAACd,KAAmB,CAAC,GAAG,CAAC,CAAC;EAEjD,OAAO;IACH,GAAGA,KAAK;IACR,GAAGsB,mBAAmB;IACtB,GAAGK,mBAAmB;IACtB,GAAGC;EACP,CAAC;AACL,CAAC;AAAAC,OAAA,CAAAR,cAAA,GAAAA,cAAA"}
|
@@ -17,7 +17,7 @@ const normalizeColor = function (color) {
|
|
17
17
|
}
|
18
18
|
const integer = (0, _normalizeColors.default)(color);
|
19
19
|
|
20
|
-
// If the
|
20
|
+
// If the color is an unknown format, the return value is null
|
21
21
|
if (integer === null) {
|
22
22
|
return color;
|
23
23
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_normalizeColors","_interopRequireDefault","require","obj","__esModule","default","normalizeColor","color","opacity","arguments","length","undefined","integer","normalizeColors","hex","toString","padStart","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","exports","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","join","Boolean","preprocessor"],"sourceRoot":"../../../../src","sources":["plugins/normalizer/normalizer.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAF5D;AACA;;AAUO,MAAMG,cAAc,GAAG,SAAAA,CAACC,KAAa,EAA0B;EAAA,IAAxBC,OAAe,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAC7D;EACA,IAAID,OAAO,KAAK,CAAC,EAAE;IACf,OAAOD,KAAK;EAChB;EAEA,MAAMK,OAAO,GAAG,IAAAC,wBAAe,EAACN,KAAK,CAAqB;;EAE1D;EACA,IAAIK,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOL,KAAK;EAChB;EAEA,MAAMO,GAAG,GAAGF,OAAO,CAACG,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAEjD,IAAIF,GAAG,CAACJ,MAAM,KAAK,CAAC,EAAE;IAClB,MAAM,CAACO,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,CAAC,GAAGN,GAAG,CACnCO,KAAK,CAAC,cAAc,CAAC,CACrBC,GAAG,CAACC,CAAC,IAAIC,QA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AAEC,aAAa;IAAEC;EAAa,CAAC,GAAGb,KAAK;EACxE,MAAMI,OAAO,GAAGV,qBAAqB,CAACiB,YAAY,CAACN,KAAK,CAAC;EACzD,MAAMC,OAAO,GAAGZ,qBAAqB,CAACiB,YAAY,CAACJ,MAAM,CAAC;EAC1D,MAAMC,MAAM,GAAGd,qBAAqB,CAACmB,YAAY,CAAC;EAClD,MAAMzC,KAAK,GAAGD,cAAc,CAACuC,WAAW,EAAYE,aAAuB,CAAC;EAE5E,OAAQ,GAAER,OAAQ,IAAGE,OAAQ,IAAGE,MAAO,IAAGpC,KAAM,EAAC;AACrD,CAAC;AAED,MAAM0C,oBAAoB,GAAIC,UAAsB,IAAKA,UAAU,CAC9D5B,GAAG,CAAC6B,SAAS,IAAI;EACd,MAAM,CAACnB,GAAG,CAAC,GAAGoB,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC;EAEpC,IAAI,CAACnB,GAAG,EAAE;IACN,OAAOrB,SAAS;EACpB;EAEA,MAAMmB,KAAK,GAAGqB,SAAS,CAACnB,GAAG,CAA2B;EAEtD,QAAOA,GAAG;IACN,KAAK,QAAQ;IACb,KAAK,UAAU;MACX,OAAQ,GAAEA,GAAI,IAAIF,KAAK,CAAmBwB,IAAI,CAAC,GAAG,CAAE,GAAE;IAC1D;MACI,OAAQ,GAAEtB,GAAI,IAAGD,kBAAkB,CAACC,GAAG,EAAEF,KAAK,CAAE,GAAE;EAC1D;AACJ,CAAC,CAAC,CACDL,MAAM,CAAC8B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEP,MAAME,YAA0B,GAAA5B,OAAA,CAAA4B,YAAA,GAAG;EACtCtB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/plugin.ts"],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/stylesheet.ts"],"mappings":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/variants.ts"],"mappings":""}
|
@@ -8,40 +8,30 @@ var _react = require("react");
|
|
8
8
|
var _reactNative = require("react-native");
|
9
9
|
var _utils = require("./utils");
|
10
10
|
var _hooks = require("./hooks");
|
11
|
-
const useStyles = stylesheet => {
|
11
|
+
const useStyles = (stylesheet, variantsMap) => {
|
12
12
|
const {
|
13
13
|
theme,
|
14
|
-
layout
|
14
|
+
layout,
|
15
|
+
plugins
|
15
16
|
} = (0, _hooks.useUnistyles)();
|
16
|
-
const
|
17
|
-
|
18
|
-
|
19
|
-
} = layout;
|
20
|
-
if (!stylesheet) {
|
21
|
-
return {
|
22
|
-
theme,
|
23
|
-
breakpoint,
|
24
|
-
styles: {}
|
25
|
-
};
|
26
|
-
}
|
27
|
-
const parsedStyles = (0, _react.useMemo)(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet]);
|
28
|
-
const dynamicStyleSheet = (0, _react.useMemo)(() => Object.entries(parsedStyles).reduce((acc, _ref) => {
|
17
|
+
const variants = (0, _hooks.useVariants)(variantsMap);
|
18
|
+
const parsedStyles = (0, _react.useMemo)(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet, layout]);
|
19
|
+
const dynamicStyleSheet = (0, _react.useMemo)(() => Object.entries(parsedStyles || {}).reduce((acc, _ref) => {
|
29
20
|
let [key, value] = _ref;
|
30
|
-
const style = value;
|
31
21
|
if (typeof value === 'function') {
|
32
22
|
return {
|
33
23
|
...acc,
|
34
|
-
[key]: (0, _utils.proxifyFunction)(
|
24
|
+
[key]: (0, _utils.proxifyFunction)(key, value)
|
35
25
|
};
|
36
26
|
}
|
37
27
|
return _reactNative.StyleSheet.create({
|
38
28
|
...acc,
|
39
|
-
[key]: (0, _utils.
|
29
|
+
[key]: (0, _utils.withPlugins)(key, (0, _utils.parseStyle)(value, variants))
|
40
30
|
});
|
41
|
-
}, {}), [
|
31
|
+
}, {}), [parsedStyles, variants, plugins]);
|
42
32
|
return {
|
43
33
|
theme,
|
44
|
-
breakpoint,
|
34
|
+
breakpoint: layout.breakpoint,
|
45
35
|
styles: dynamicStyleSheet
|
46
36
|
};
|
47
37
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_utils","_hooks","useStyles","stylesheet","theme","layout","
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_utils","_hooks","useStyles","stylesheet","variantsMap","theme","layout","plugins","useUnistyles","variants","useVariants","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","proxifyFunction","StyleSheet","create","withPlugins","parseStyle","breakpoint","styles","exports"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAUO,MAAMI,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,EAAAC,IAAA,KAAmB;IAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;IACtB,IAAI,OAAOE,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGH,GAAG;QACN,CAACE,GAAG,GAAG,IAAAE,sBAAe,EAACF,GAAG,EAAEC,KAAK;MACrC,CAAC;IACL;IAEA,OAAOE,uBAAU,CAACC,MAAM,CAAC;MACrB,GAAGN,GAAG;MACN,CAACE,GAAG,GAAG,IAAAK,kBAAW,EAACL,GAAG,EAAE,IAAAM,iBAAU,EAACL,KAAK,EAAEX,QAAQ,CAAC;IACvD,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAACE,YAAY,EAAEF,QAAQ,EAAEF,OAAO,CAC5C,CAAC;EAED,OAAO;IACHF,KAAK;IACLqB,UAAU,EAAEpB,MAAM,CAACoB,UAAU;IAC7BC,MAAM,EAAEd;EACZ,CAAC;AACL,CAAC;AAAAe,OAAA,CAAA1B,SAAA,GAAAA,SAAA"}
|
@@ -3,86 +3,40 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.getValueForBreakpoint = void 0;
|
7
7
|
var _core = require("../core");
|
8
|
-
var _common = require("
|
9
|
-
var _common2 = require("../common");
|
8
|
+
var _common = require("../common");
|
10
9
|
var _mqParser = require("./mqParser");
|
11
|
-
const sortAndValidateBreakpoints = breakpoints => {
|
12
|
-
const sortedPairs = Object.entries(breakpoints).sort((breakpoint1, breakpoint2) => {
|
13
|
-
const [, value1] = breakpoint1;
|
14
|
-
const [, value2] = breakpoint2;
|
15
|
-
return value1 - value2;
|
16
|
-
});
|
17
|
-
const sortedBreakpoints = Object.freeze(Object.fromEntries(sortedPairs));
|
18
|
-
const breakpointValues = Object.values(sortedBreakpoints);
|
19
|
-
const [firstBreakpoint] = breakpointValues;
|
20
|
-
if (firstBreakpoint !== 0) {
|
21
|
-
(0, _common.throwError)('first breakpoint must start with 0');
|
22
|
-
}
|
23
|
-
if (breakpointValues.length !== new Set(breakpointValues).size) {
|
24
|
-
(0, _common.throwError)('breakpoint values are duplicated');
|
25
|
-
}
|
26
|
-
return sortedBreakpoints;
|
27
|
-
};
|
28
|
-
exports.sortAndValidateBreakpoints = sortAndValidateBreakpoints;
|
29
|
-
const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
|
30
|
-
const [key] = breakpointEntries.find((_ref, index, otherBreakpoints) => {
|
31
|
-
let [, value] = _ref;
|
32
|
-
const minVal = value;
|
33
|
-
const maxVal = otherBreakpoints[index + 1]?.[1];
|
34
|
-
if (!maxVal) {
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
return width >= minVal && width < maxVal;
|
38
|
-
});
|
39
|
-
return key;
|
40
|
-
};
|
41
|
-
exports.getBreakpointFromScreenWidth = getBreakpointFromScreenWidth;
|
42
10
|
const getValueForBreakpoint = value => {
|
43
|
-
// the highest priority is for custom media queries
|
44
11
|
const customMediaQueryKey = (0, _mqParser.getKeyForUnistylesMediaQuery)(Object.entries(value), _core.unistyles.runtime.screen);
|
45
12
|
if (customMediaQueryKey) {
|
46
13
|
return value[customMediaQueryKey];
|
47
14
|
}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
const hasBreakpoints = _core.unistyles.runtime.sortedBreakpoints.length > 0;
|
52
|
-
|
53
|
-
// if not then we can fall back to horizontal and portrait (mobile only)
|
54
|
-
if (!hasBreakpoints && _common.isMobile && (_common.Orientation.Landscape in value || _common.Orientation.Portrait in value)) {
|
55
|
-
return value[_core.unistyles.runtime.orientation === _common2.ScreenOrientation.Portrait ? _common.Orientation.Portrait : _common.Orientation.Landscape];
|
15
|
+
const hasBreakpoints = _core.unistyles.registry.sortedBreakpointPairs.length > 0;
|
16
|
+
if (!hasBreakpoints && _common.isMobile && (_common.ScreenOrientation.Landscape in value || _common.ScreenOrientation.Portrait in value)) {
|
17
|
+
return value[_core.unistyles.runtime.orientation];
|
56
18
|
}
|
57
|
-
|
58
|
-
// let's get the current breakpoint
|
59
19
|
const breakpoint = _core.unistyles.runtime.breakpoint;
|
60
20
|
if (!breakpoint) {
|
61
21
|
return undefined;
|
62
22
|
}
|
63
|
-
|
64
|
-
// if user defined breakpoints, then we look for the valid one
|
65
23
|
const directBreakpoint = value[breakpoint];
|
66
|
-
|
67
|
-
// if there is a direct key like 'sm' or 'md', or value for this key exists but its undefined
|
68
24
|
if (directBreakpoint || breakpoint in value) {
|
69
25
|
return directBreakpoint;
|
70
26
|
}
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
const currentBreakpoint = breakpointPairs.findIndex(_ref2 => {
|
75
|
-
let [key] = _ref2;
|
27
|
+
const breakpointPairs = _core.unistyles.registry.sortedBreakpointPairs;
|
28
|
+
const currentBreakpointIndex = breakpointPairs.findIndex(_ref => {
|
29
|
+
let [key] = _ref;
|
76
30
|
return key === breakpoint;
|
77
31
|
});
|
78
|
-
const availableBreakpoints = breakpointPairs.filter((
|
32
|
+
const availableBreakpoints = breakpointPairs.filter((_ref2, index) => {
|
33
|
+
let [key] = _ref2;
|
34
|
+
return index < currentBreakpointIndex && key in value;
|
35
|
+
}).map(_ref3 => {
|
79
36
|
let [key] = _ref3;
|
80
|
-
return index < currentBreakpoint && key && key in value;
|
81
|
-
}).map(_ref4 => {
|
82
|
-
let [key] = _ref4;
|
83
37
|
return key;
|
84
38
|
});
|
85
|
-
return
|
39
|
+
return value[availableBreakpoints[availableBreakpoints.length - 1]];
|
86
40
|
};
|
87
41
|
exports.getValueForBreakpoint = getValueForBreakpoint;
|
88
42
|
//# sourceMappingURL=breakpoints.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_core","require","_common","
|
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","_ref","key","availableBreakpoints","filter","_ref2","index","map","_ref3","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,CAACC,IAAA;IAAA,IAAC,CAACC,GAAG,CAAC,GAAAD,IAAA;IAAA,OAAKC,GAAG,KAAKP,UAAU;EAAA,EAAC;EAE7C,MAAMQ,oBAAoB,GAAGL,eAAe,CACvCM,MAAM,CAAC,CAAAC,KAAA,EAAQC,KAAK;IAAA,IAAZ,CAACJ,GAAG,CAAC,GAAAG,KAAA;IAAA,OAAYC,KAAK,GAAGP,sBAAsB,IAAIG,GAAG,IAAIxB,KAAK;EAAA,EAAC,CACxE6B,GAAG,CAACC,KAAA;IAAA,IAAC,CAACN,GAAG,CAAC,GAAAM,KAAA;IAAA,OAAKN,GAAG;EAAA,EAAC;EAExB,OAAOxB,KAAK,CAACyB,oBAAoB,CAACA,oBAAoB,CAACd,MAAM,GAAG,CAAC,CAAC,CAAwC;AAC9G,CAAC;AAAAoB,OAAA,CAAAhC,qBAAA,GAAAA,qBAAA"}
|
@@ -3,37 +3,6 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
var _exportNames = {
|
7
|
-
normalizeStyles: true,
|
8
|
-
mq: true,
|
9
|
-
MQSymbol: true,
|
10
|
-
getKeyForUnistylesMediaQuery: true,
|
11
|
-
getBreakpointFromScreenWidth: true,
|
12
|
-
sortAndValidateBreakpoints: true,
|
13
|
-
getValueForBreakpoint: true,
|
14
|
-
proxifyFunction: true,
|
15
|
-
parseStyle: true,
|
16
|
-
isServer: true,
|
17
|
-
Orientation: true
|
18
|
-
};
|
19
|
-
Object.defineProperty(exports, "MQSymbol", {
|
20
|
-
enumerable: true,
|
21
|
-
get: function () {
|
22
|
-
return _mq.MQSymbol;
|
23
|
-
}
|
24
|
-
});
|
25
|
-
Object.defineProperty(exports, "Orientation", {
|
26
|
-
enumerable: true,
|
27
|
-
get: function () {
|
28
|
-
return _common.Orientation;
|
29
|
-
}
|
30
|
-
});
|
31
|
-
Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
|
32
|
-
enumerable: true,
|
33
|
-
get: function () {
|
34
|
-
return _breakpoints.getBreakpointFromScreenWidth;
|
35
|
-
}
|
36
|
-
});
|
37
6
|
Object.defineProperty(exports, "getKeyForUnistylesMediaQuery", {
|
38
7
|
enumerable: true,
|
39
8
|
get: function () {
|
@@ -46,10 +15,16 @@ Object.defineProperty(exports, "getValueForBreakpoint", {
|
|
46
15
|
return _breakpoints.getValueForBreakpoint;
|
47
16
|
}
|
48
17
|
});
|
49
|
-
Object.defineProperty(exports, "
|
18
|
+
Object.defineProperty(exports, "isValidMq", {
|
19
|
+
enumerable: true,
|
20
|
+
get: function () {
|
21
|
+
return _mqParser.isValidMq;
|
22
|
+
}
|
23
|
+
});
|
24
|
+
Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
|
50
25
|
enumerable: true,
|
51
26
|
get: function () {
|
52
|
-
return
|
27
|
+
return _mqParser.isWithinTheWidthAndHeight;
|
53
28
|
}
|
54
29
|
});
|
55
30
|
Object.defineProperty(exports, "mq", {
|
@@ -58,10 +33,10 @@ Object.defineProperty(exports, "mq", {
|
|
58
33
|
return _mq.mq;
|
59
34
|
}
|
60
35
|
});
|
61
|
-
Object.defineProperty(exports, "
|
36
|
+
Object.defineProperty(exports, "parseMq", {
|
62
37
|
enumerable: true,
|
63
38
|
get: function () {
|
64
|
-
return
|
39
|
+
return _mqParser.parseMq;
|
65
40
|
}
|
66
41
|
});
|
67
42
|
Object.defineProperty(exports, "parseStyle", {
|
@@ -76,28 +51,15 @@ Object.defineProperty(exports, "proxifyFunction", {
|
|
76
51
|
return _styles.proxifyFunction;
|
77
52
|
}
|
78
53
|
});
|
79
|
-
Object.defineProperty(exports, "
|
54
|
+
Object.defineProperty(exports, "withPlugins", {
|
80
55
|
enumerable: true,
|
81
56
|
get: function () {
|
82
|
-
return
|
57
|
+
return _withPlugins.withPlugins;
|
83
58
|
}
|
84
59
|
});
|
85
|
-
var _normalizeStyles = require("./normalizeStyles");
|
86
|
-
var _normalizer = require("./normalizer");
|
87
|
-
Object.keys(_normalizer).forEach(function (key) {
|
88
|
-
if (key === "default" || key === "__esModule") return;
|
89
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
90
|
-
if (key in exports && exports[key] === _normalizer[key]) return;
|
91
|
-
Object.defineProperty(exports, key, {
|
92
|
-
enumerable: true,
|
93
|
-
get: function () {
|
94
|
-
return _normalizer[key];
|
95
|
-
}
|
96
|
-
});
|
97
|
-
});
|
98
60
|
var _mq = require("./mq");
|
99
61
|
var _mqParser = require("./mqParser");
|
100
62
|
var _breakpoints = require("./breakpoints");
|
101
63
|
var _styles = require("./styles");
|
102
|
-
var
|
64
|
+
var _withPlugins = require("./withPlugins");
|
103
65
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_mq","require","_mqParser","_breakpoints","_styles","_withPlugins"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA"}
|
package/lib/commonjs/utils/mq.js
CHANGED
@@ -3,17 +3,8 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.mq =
|
6
|
+
exports.mq = void 0;
|
7
7
|
var _core = require("../core");
|
8
|
-
const MQSymbol = exports.MQSymbol = Symbol('unistyles-mq');
|
9
|
-
var MQProp = /*#__PURE__*/function (MQProp) {
|
10
|
-
MQProp["toString"] = "toString";
|
11
|
-
MQProp["width"] = "width";
|
12
|
-
MQProp["height"] = "height";
|
13
|
-
MQProp["shortW"] = "w";
|
14
|
-
MQProp["shortH"] = "h";
|
15
|
-
return MQProp;
|
16
|
-
}(MQProp || {});
|
17
8
|
const getMQValue = value => {
|
18
9
|
if (typeof value === 'number') {
|
19
10
|
return value;
|
@@ -23,67 +14,44 @@ const getMQValue = value => {
|
|
23
14
|
}
|
24
15
|
return _core.unistyles.registry.breakpoints[value] ?? 0;
|
25
16
|
};
|
26
|
-
const
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
38
|
-
return new Proxy({}, {
|
39
|
-
get: (target, prop, receiver) => {
|
40
|
-
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
41
|
-
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
42
|
-
}
|
43
|
-
return Reflect.get(target, prop, receiver);
|
44
|
-
}
|
45
|
-
});
|
46
|
-
};
|
47
|
-
}
|
48
|
-
return Reflect.get(target, prop, receiver);
|
17
|
+
const mq = exports.mq = {
|
18
|
+
only: {
|
19
|
+
width: function () {
|
20
|
+
let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
21
|
+
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
22
|
+
return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
|
23
|
+
},
|
24
|
+
height: function () {
|
25
|
+
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
26
|
+
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
27
|
+
return `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
49
28
|
}
|
50
|
-
}
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
58
|
-
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
|
59
|
-
}
|
60
|
-
if (prop === MQProp.height || prop === MQProp.shortH) {
|
61
|
-
return function () {
|
29
|
+
},
|
30
|
+
width: function () {
|
31
|
+
let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
32
|
+
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
33
|
+
return {
|
34
|
+
and: {
|
35
|
+
height: function () {
|
62
36
|
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
63
37
|
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
64
|
-
return
|
65
|
-
|
66
|
-
if (prop === Symbol.toPrimitive || MQProp.toString) {
|
67
|
-
return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
68
|
-
}
|
69
|
-
return Reflect.get(target, prop, receiver);
|
70
|
-
}
|
71
|
-
});
|
72
|
-
};
|
38
|
+
return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
39
|
+
}
|
73
40
|
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
41
|
+
};
|
42
|
+
},
|
43
|
+
height: function () {
|
44
|
+
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
45
|
+
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
46
|
+
return {
|
47
|
+
and: {
|
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 `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
};
|
87
55
|
}
|
88
|
-
}
|
56
|
+
};
|
89
57
|
//# sourceMappingURL=mq.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_core","require","
|
1
|
+
{"version":3,"names":["_core","require","getMQValue","value","unistyles","registry","breakpoints","mq","exports","only","width","wMin","arguments","length","undefined","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;AAEM,MAAMI,EAAa,GAAAC,OAAA,CAAAD,EAAA,GAAG;EACzBE,IAAI,EAAE;IACFC,KAAK,EAAE,SAAAA,CAAA;MAAA,IAACC,IAAuB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;MAAA,IAAEG,IAAa,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;MAAA,OAAO,MAAKd,UAAU,CAACS,IAAI,CAAE,KAAIT,UAAU,CAACa,IAAI,CAAE,GAAE;IAAA,CAAsB;IACvIE,MAAM,EAAE,SAAAA,CAAA;MAAA,IAACC,IAAuB,GAAAN,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;MAAA,IAAEO,IAAa,GAAAP,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAA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,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;UAAA,OACvD,MAAKd,UAAU,CAACS,IAAI,CAAE,KAAIT,UAAU,CAACa,IAAI,CAAE,OAAMb,UAAU,CAACgB,IAAI,CAAE,KAAIhB,UAAU,CAACiB,IAAI,CAAE,GAAE;QAAA;MACnG;IACJ,CAAC;EAAA;AACL,CAAC"}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.getKeyForUnistylesMediaQuery = void 0;
|
6
|
+
exports.parseMq = exports.isWithinTheWidthAndHeight = exports.isValidMq = exports.getKeyForUnistylesMediaQuery = void 0;
|
7
7
|
const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
8
8
|
const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
9
9
|
const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
@@ -21,6 +21,7 @@ const parseMq = mq => {
|
|
21
21
|
} : undefined
|
22
22
|
};
|
23
23
|
};
|
24
|
+
exports.parseMq = parseMq;
|
24
25
|
const isUnistylesMq = mq => IS_UNISTYLES_REGEX.test(mq);
|
25
26
|
const isValidMq = parsedMq => {
|
26
27
|
const {
|
@@ -38,6 +39,7 @@ const isValidMq = parsedMq => {
|
|
38
39
|
}
|
39
40
|
return false;
|
40
41
|
};
|
42
|
+
exports.isValidMq = isValidMq;
|
41
43
|
const isWithinTheWidthAndHeight = (parsedMq, screenSize) => {
|
42
44
|
const {
|
43
45
|
width,
|
@@ -54,6 +56,7 @@ const isWithinTheWidthAndHeight = (parsedMq, screenSize) => {
|
|
54
56
|
}
|
55
57
|
return false;
|
56
58
|
};
|
59
|
+
exports.isWithinTheWidthAndHeight = isWithinTheWidthAndHeight;
|
57
60
|
const isWithinTheWidth = (width, screenWidth) => {
|
58
61
|
const {
|
59
62
|
from,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","from","Number","to","undefined","isUnistylesMq","test","isValidMq","parsedMq","isWithinTheWidthAndHeight","screenSize","isWithinTheWidth","isWithinTheHeight","screenWidth","screenHeight","getKeyForUnistylesMediaQuery","mediaQueries","find","_ref","key","at"
|
1
|
+
{"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","from","Number","to","undefined","exports","isUnistylesMq","test","isValidMq","parsedMq","isWithinTheWidthAndHeight","screenSize","isWithinTheWidth","isWithinTheHeight","screenWidth","screenHeight","getKeyForUnistylesMediaQuery","mediaQueries","find","_ref","key","at"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":";;;;;;AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAY7D,MAAMC,OAAO,GAAIC,EAAU,IAAwB;EACtD,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAEpE,OAAO;IACHC,KAAK,EAAEA,KAAK,GAAG;MACXO,IAAI,EAAEC,MAAM,CAACP,KAAK,CAAC;MACnBQ,EAAE,EAAED,MAAM,CAACN,GAAG;IAClB,CAAC,GAAGQ,SAAS;IACbN,MAAM,EAAEA,MAAM,GAAG;MACbG,I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