react-native-unistyles 2.0.0-alpha.1 → 2.0.0-alpha.11
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -4
- package/cxx/UnistylesRuntime.cpp +255 -0
- package/cxx/UnistylesRuntime.h +60 -0
- package/ios/UnistylesHelpers.h +4 -0
- package/ios/UnistylesHelpers.mm +20 -0
- package/ios/UnistylesModule.h +10 -0
- package/ios/UnistylesModule.mm +158 -0
- package/lib/commonjs/common.js +26 -0
- package/lib/commonjs/common.js.map +1 -0
- package/lib/commonjs/core/UnistyleRegistry.js +38 -0
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -0
- package/lib/commonjs/core/Unistyles.js +31 -0
- package/lib/commonjs/core/Unistyles.js.map +1 -0
- package/lib/commonjs/core/UnistylesModule.js +9 -0
- package/lib/commonjs/core/UnistylesModule.js.map +1 -0
- package/lib/commonjs/core/UnistylesRuntime.js +66 -0
- 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/createStyleSheet.js +14 -0
- package/lib/commonjs/createStyleSheet.js.map +1 -0
- package/lib/commonjs/global.js +2 -0
- package/lib/commonjs/global.js.map +1 -0
- package/lib/commonjs/hooks/index.js +10 -3
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useInitialTheme.js +17 -0
- 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 +35 -6
- 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 +26 -0
- 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/normalizer.js +6 -0
- package/lib/commonjs/types/normalizer.js.map +1 -0
- package/lib/commonjs/types/unistyles.js +6 -0
- package/lib/commonjs/types/unistyles.js.map +1 -0
- package/lib/commonjs/types/variants.js +2 -0
- package/lib/commonjs/types/variants.js.map +1 -0
- package/lib/commonjs/useStyles.js +49 -0
- package/lib/commonjs/useStyles.js.map +1 -0
- package/lib/commonjs/utils/breakpoints.js +33 -80
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/common.js +10 -3
- package/lib/commonjs/utils/common.js.map +1 -1
- package/lib/commonjs/utils/index.js +46 -17
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/module.d.js +2 -0
- package/lib/commonjs/utils/module.d.js.map +1 -0
- 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/normalizeStyles.web.js +13 -13
- package/lib/commonjs/utils/normalizeStyles.web.js.map +1 -1
- package/lib/commonjs/utils/normalizer.js +89 -0
- package/lib/commonjs/utils/normalizer.js.map +1 -0
- package/lib/commonjs/utils/styles.js +29 -58
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/commonjs/utils/variants.js +17 -0
- package/lib/commonjs/utils/variants.js.map +1 -0
- package/lib/module/common.js +22 -0
- package/lib/module/common.js.map +1 -0
- package/lib/module/core/UnistyleRegistry.js +31 -0
- package/lib/module/core/UnistyleRegistry.js.map +1 -0
- package/lib/module/core/Unistyles.js +25 -0
- package/lib/module/core/Unistyles.js.map +1 -0
- package/lib/module/core/UnistylesModule.js +3 -0
- package/lib/module/core/UnistylesModule.js.map +1 -0
- package/lib/module/core/UnistylesRuntime.js +59 -0
- 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/createStyleSheet.js +7 -0
- package/lib/module/createStyleSheet.js.map +1 -0
- package/lib/module/global.js +2 -0
- package/lib/module/global.js.map +1 -0
- package/lib/module/hooks/index.js +2 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useInitialTheme.js +10 -0
- 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 +13 -2
- 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 +2 -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/normalizer.js +2 -0
- package/lib/module/types/normalizer.js.map +1 -0
- package/lib/module/types/unistyles.js +2 -0
- package/lib/module/types/unistyles.js.map +1 -0
- package/lib/module/types/variants.js +2 -0
- package/lib/module/types/variants.js.map +1 -0
- package/lib/module/useStyles.js +42 -0
- package/lib/module/useStyles.js.map +1 -0
- package/lib/module/utils/breakpoints.js +34 -82
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/common.js +9 -1
- package/lib/module/utils/common.js.map +1 -1
- package/lib/module/utils/index.js +5 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/module.d.js +2 -0
- package/lib/module/utils/module.d.js.map +1 -0
- 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/normalizeStyles.web.js +13 -13
- package/lib/module/utils/normalizeStyles.web.js.map +1 -1
- package/lib/module/utils/normalizer.js +79 -0
- package/lib/module/utils/normalizer.js.map +1 -0
- package/lib/module/utils/styles.js +28 -59
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/module/utils/variants.js +10 -0
- package/lib/module/utils/variants.js.map +1 -0
- package/lib/typescript/src/common.d.ts +17 -0
- package/lib/typescript/src/common.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistyleRegistry.d.ts +15 -0
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -0
- package/lib/typescript/src/core/Unistyles.d.ts +13 -0
- package/lib/typescript/src/core/Unistyles.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistylesModule.d.ts +6 -0
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -0
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +24 -0
- 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/createStyleSheet.d.ts +3 -0
- package/lib/typescript/src/createStyleSheet.d.ts.map +1 -0
- package/lib/typescript/src/global.d.ts +7 -0
- package/lib/typescript/src/global.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 +14 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +12 -13
- 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 +28 -18
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +7 -2
- 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/normalizer.d.ts +20 -0
- package/lib/typescript/src/types/normalizer.d.ts.map +1 -0
- package/lib/typescript/src/types/unistyles.d.ts +37 -0
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -0
- package/lib/typescript/src/types/variants.d.ts +8 -0
- package/lib/typescript/src/types/variants.d.ts.map +1 -0
- package/lib/typescript/src/useStyles.d.ts +10 -0
- package/lib/typescript/src/useStyles.d.ts.map +1 -0
- package/lib/typescript/src/utils/breakpoints.d.ts +5 -62
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/common.d.ts +9 -1
- package/lib/typescript/src/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +5 -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/normalizeStyles.web.d.ts +4 -1
- package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +1 -1
- package/lib/typescript/src/utils/normalizer.d.ts +11 -0
- package/lib/typescript/src/utils/normalizer.d.ts.map +1 -0
- package/lib/typescript/src/utils/styles.d.ts +5 -49
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/lib/typescript/src/utils/variants.d.ts +3 -0
- package/lib/typescript/src/utils/variants.d.ts.map +1 -0
- package/package.json +33 -15
- package/react-native-unistyles.podspec +22 -0
- package/src/common.ts +19 -0
- package/src/core/UnistyleRegistry.ts +41 -0
- package/src/core/Unistyles.ts +34 -0
- package/src/core/UnistylesModule.ts +7 -0
- package/src/core/UnistylesRuntime.ts +73 -0
- package/src/core/index.ts +1 -0
- package/src/createStyleSheet.ts +9 -0
- package/src/global.ts +5 -0
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useInitialTheme.ts +11 -0
- package/src/hooks/useUnistyles.ts +55 -0
- package/src/index.ts +30 -2
- package/src/types/breakpoints.ts +21 -20
- package/src/types/common.ts +2 -0
- package/src/types/core.ts +36 -24
- package/src/types/index.ts +7 -9
- package/src/types/mq.ts +3 -0
- package/src/types/normalizer.ts +29 -0
- package/src/types/unistyles.ts +45 -0
- package/src/types/variants.ts +11 -0
- package/src/useStyles.ts +62 -0
- package/src/utils/breakpoints.ts +46 -86
- package/src/utils/common.ts +10 -1
- package/src/utils/index.ts +5 -8
- package/src/utils/module.d.ts +3 -0
- package/src/utils/mq.ts +106 -0
- package/src/utils/mqParser.ts +99 -0
- package/src/utils/normalizeStyles.web.ts +21 -42
- package/src/utils/normalizer.ts +99 -0
- package/src/utils/styles.ts +46 -70
- package/src/utils/variants.ts +13 -0
- package/lib/commonjs/UnistylesTheme.js +0 -21
- package/lib/commonjs/UnistylesTheme.js.map +0 -1
- package/lib/commonjs/createUnistyles.js +0 -57
- package/lib/commonjs/createUnistyles.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 -31
- package/lib/commonjs/hooks/useDimensions.web.js.map +0 -1
- package/lib/commonjs/types/mediaQueries.js +0 -2
- package/lib/commonjs/utils/mediaQueries.js +0 -189
- package/lib/commonjs/utils/mediaQueries.js.map +0 -1
- package/lib/module/UnistylesTheme.js +0 -12
- package/lib/module/UnistylesTheme.js.map +0 -1
- package/lib/module/createUnistyles.js +0 -50
- package/lib/module/createUnistyles.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 -24
- package/lib/module/hooks/useDimensions.web.js.map +0 -1
- package/lib/module/types/mediaQueries.js +0 -2
- package/lib/module/utils/mediaQueries.js +0 -176
- package/lib/module/utils/mediaQueries.js.map +0 -1
- package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
- package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
- package/lib/typescript/src/createUnistyles.d.ts +0 -10
- package/lib/typescript/src/createUnistyles.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/mediaQueries.d.ts +0 -8
- package/lib/typescript/src/types/mediaQueries.d.ts.map +0 -1
- package/lib/typescript/src/utils/mediaQueries.d.ts +0 -130
- package/lib/typescript/src/utils/mediaQueries.d.ts.map +0 -1
- package/src/UnistylesTheme.tsx +0 -17
- package/src/__tests__/createUnistyles.spec.tsx +0 -192
- package/src/createUnistyles.ts +0 -70
- package/src/hooks/useDimensions.ts +0 -4
- package/src/hooks/useDimensions.web.ts +0 -30
- package/src/types/mediaQueries.ts +0 -10
- package/src/utils/mediaQueries.ts +0 -201
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","throwError","message","Error","exports","warn","console","
|
1
|
+
{"version":3,"names":["_reactNative","require","throwError","message","Error","exports","warn","console","isMobile","Platform","OS","isWeb","isIOS","isAndroid","isServer","window","Orientation","Landscape","Portrait"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAAAE,OAAA,CAAAH,UAAA,GAAAA,UAAA;AAEM,MAAMI,IAAI,GAAIH,OAAe,IAAK;EACrCI,OAAO,CAACD,IAAI,CAAE,gCAA+BH,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAAAE,OAAA,CAAAC,IAAA,GAAAA,IAAA;AAEM,MAAME,QAAQ,GAAAH,OAAA,CAAAG,QAAA,GAAGC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAID,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnE,MAAMC,KAAK,GAAAN,OAAA,CAAAM,KAAA,GAAGF,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAME,KAAK,GAAAP,OAAA,CAAAO,KAAA,GAAGH,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAMG,SAAS,GAAAR,OAAA,CAAAQ,SAAA,GAAGJ,qBAAQ,CAACC,EAAE,KAAK,SAAS;AAC3C,MAAMI,QAAQ,GAAAT,OAAA,CAAAS,QAAA,GAAG,OAAOC,MAAM,KAAK,WAAW;AAE9C,MAAMC,WAAW,GAAAX,OAAA,CAAAW,WAAA,GAAG;EACvBC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU"}
|
@@ -3,52 +3,66 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
|
6
|
+
var _exportNames = {
|
7
|
+
normalizeStyles: true,
|
8
|
+
mq: true,
|
9
|
+
MQSymbol: true,
|
10
|
+
getKeyForVariant: true,
|
11
|
+
getKeyForUnistylesMediaQuery: true,
|
12
|
+
getBreakpointFromScreenWidth: true,
|
13
|
+
sortAndValidateBreakpoints: true,
|
14
|
+
getValueForBreakpoint: true,
|
15
|
+
proxifyFunction: true,
|
16
|
+
parseStyle: true,
|
17
|
+
isServer: true,
|
18
|
+
Orientation: true
|
19
|
+
};
|
20
|
+
Object.defineProperty(exports, "MQSymbol", {
|
7
21
|
enumerable: true,
|
8
22
|
get: function () {
|
9
|
-
return
|
23
|
+
return _mq.MQSymbol;
|
10
24
|
}
|
11
25
|
});
|
12
|
-
Object.defineProperty(exports, "
|
26
|
+
Object.defineProperty(exports, "Orientation", {
|
13
27
|
enumerable: true,
|
14
28
|
get: function () {
|
15
|
-
return
|
29
|
+
return _common.Orientation;
|
16
30
|
}
|
17
31
|
});
|
18
|
-
Object.defineProperty(exports, "
|
32
|
+
Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
|
19
33
|
enumerable: true,
|
20
34
|
get: function () {
|
21
|
-
return
|
35
|
+
return _breakpoints.getBreakpointFromScreenWidth;
|
22
36
|
}
|
23
37
|
});
|
24
|
-
Object.defineProperty(exports, "
|
38
|
+
Object.defineProperty(exports, "getKeyForUnistylesMediaQuery", {
|
25
39
|
enumerable: true,
|
26
40
|
get: function () {
|
27
|
-
return
|
41
|
+
return _mqParser.getKeyForUnistylesMediaQuery;
|
28
42
|
}
|
29
43
|
});
|
30
|
-
Object.defineProperty(exports, "
|
44
|
+
Object.defineProperty(exports, "getKeyForVariant", {
|
31
45
|
enumerable: true,
|
32
46
|
get: function () {
|
33
|
-
return
|
47
|
+
return _variants.getKeyForVariant;
|
34
48
|
}
|
35
49
|
});
|
36
|
-
Object.defineProperty(exports, "
|
50
|
+
Object.defineProperty(exports, "getValueForBreakpoint", {
|
37
51
|
enumerable: true,
|
38
52
|
get: function () {
|
39
|
-
return
|
53
|
+
return _breakpoints.getValueForBreakpoint;
|
40
54
|
}
|
41
55
|
});
|
42
|
-
Object.defineProperty(exports, "
|
56
|
+
Object.defineProperty(exports, "isServer", {
|
43
57
|
enumerable: true,
|
44
58
|
get: function () {
|
45
|
-
return
|
59
|
+
return _common.isServer;
|
46
60
|
}
|
47
61
|
});
|
48
|
-
Object.defineProperty(exports, "
|
62
|
+
Object.defineProperty(exports, "mq", {
|
49
63
|
enumerable: true,
|
50
64
|
get: function () {
|
51
|
-
return
|
65
|
+
return _mq.mq;
|
52
66
|
}
|
53
67
|
});
|
54
68
|
Object.defineProperty(exports, "normalizeStyles", {
|
@@ -76,7 +90,22 @@ Object.defineProperty(exports, "sortAndValidateBreakpoints", {
|
|
76
90
|
}
|
77
91
|
});
|
78
92
|
var _normalizeStyles = require("./normalizeStyles");
|
93
|
+
var _normalizer = require("./normalizer");
|
94
|
+
Object.keys(_normalizer).forEach(function (key) {
|
95
|
+
if (key === "default" || key === "__esModule") return;
|
96
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
97
|
+
if (key in exports && exports[key] === _normalizer[key]) return;
|
98
|
+
Object.defineProperty(exports, key, {
|
99
|
+
enumerable: true,
|
100
|
+
get: function () {
|
101
|
+
return _normalizer[key];
|
102
|
+
}
|
103
|
+
});
|
104
|
+
});
|
105
|
+
var _mq = require("./mq");
|
106
|
+
var _variants = require("./variants");
|
107
|
+
var _mqParser = require("./mqParser");
|
79
108
|
var _breakpoints = require("./breakpoints");
|
80
109
|
var _styles = require("./styles");
|
81
|
-
var
|
110
|
+
var _common = require("./common");
|
82
111
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_normalizeStyles","require","_breakpoints","_styles","
|
1
|
+
{"version":3,"names":["_normalizeStyles","require","_normalizer","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_mq","_variants","_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,SAAA,GAAAhB,OAAA;AACA,IAAAiB,YAAA,GAAAjB,OAAA;AACA,IAAAkB,OAAA,GAAAlB,OAAA;AACA,IAAAmB,OAAA,GAAAnB,OAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/module.d.ts"],"mappings":""}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.mq = exports.MQSymbol = void 0;
|
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
|
+
const getMQValue = value => {
|
18
|
+
if (typeof value === 'number') {
|
19
|
+
return value;
|
20
|
+
}
|
21
|
+
if (value === null) {
|
22
|
+
return 0;
|
23
|
+
}
|
24
|
+
return _core.unistyles.registry.breakpoints[value] ?? 0;
|
25
|
+
};
|
26
|
+
const widthHandler = function () {
|
27
|
+
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
28
|
+
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
29
|
+
return new Proxy({}, {
|
30
|
+
get: (target, prop, receiver) => {
|
31
|
+
if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
|
32
|
+
return () => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
|
33
|
+
}
|
34
|
+
if (prop === MQProp.width || prop === MQProp.shortW) {
|
35
|
+
return function () {
|
36
|
+
let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
37
|
+
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
38
|
+
return 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);
|
49
|
+
}
|
50
|
+
});
|
51
|
+
};
|
52
|
+
const heightHandler = function () {
|
53
|
+
let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
54
|
+
let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
55
|
+
return new Proxy({}, {
|
56
|
+
get: (target, prop, receiver) => {
|
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 () {
|
62
|
+
let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
63
|
+
let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
|
64
|
+
return new Proxy({}, {
|
65
|
+
get: (target, prop, receiver) => {
|
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
|
+
};
|
73
|
+
}
|
74
|
+
return Reflect.get(target, prop, receiver);
|
75
|
+
}
|
76
|
+
});
|
77
|
+
};
|
78
|
+
const mq = exports.mq = new Proxy({}, {
|
79
|
+
get: (target, prop, receiver) => {
|
80
|
+
if (prop === MQProp.shortW || prop === MQProp.width) {
|
81
|
+
return heightHandler;
|
82
|
+
}
|
83
|
+
if (prop === MQProp.shortH || prop === MQProp.height) {
|
84
|
+
return widthHandler;
|
85
|
+
}
|
86
|
+
return Reflect.get(target, prop, receiver);
|
87
|
+
}
|
88
|
+
});
|
89
|
+
//# sourceMappingURL=mq.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_core","require","MQSymbol","exports","Symbol","MQProp","getMQValue","value","unistyles","registry","breakpoints","widthHandler","hMin","arguments","length","undefined","hMax","Infinity","Proxy","get","target","prop","receiver","toPrimitive","toString","width","shortW","wMin","wMax","Reflect","heightHandler","height","shortH","mq"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAEO,MAAMC,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAGE,MAAM,CAAC,cAAc,CAAC;AAAA,IAyBzCC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA,EAANA,MAAM;AAQX,MAAMC,UAAU,GAAIC,KAAwB,IAAK;EAC7C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,CAAC;EACZ;EAEA,OAAOC,eAAS,CAACC,QAAQ,CAACC,WAAW,CAACH,KAAK,CAAC,IAAI,CAAC;AACrD,CAAC;AAED,MAAMI,YAAY,GAAG,SAAAA,CAAA;EAAA,IAACC,IAAuB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAA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CAACsB,IAAI,CAAE,OAAMtB,UAAU,CAACM,IAAI,CAAE,KAAIN,UAAU,CAACU,IAAI,CAAE,GAAE;cAC3G;cAEA,OAAOa,OAAO,CAACV,GAAG,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,CAAC;YAC9C;UACJ,CAAC,CAAC;QAAA;MACN;MAEA,OAAOO,OAAO,CAACV,GAAG,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,CAAC;IAC9C;EACJ,CAAC,CAAC;AAAA;AAEK,MAAMW,EAAE,GAAA9B,OAAA,CAAA8B,EAAA,GAAG,IAAIf,KAAK,CAAC,CAAC,CAAC,EAAe;EACzCC,GAAG,EAAEA,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,KAAK;IAC7B,IAAID,IAAI,KAAKhB,MAAM,CAACqB,MAAM,IAAIL,IAAI,KAAKhB,MAAM,CAACoB,KAAK,EAAE;MACjD,OAAOK,aAAa;IACxB;IAEA,IAAIT,IAAI,KAAKhB,MAAM,CAAC2B,MAAM,IAAIX,IAAI,KAAKhB,MAAM,CAAC0B,MAAM,EAAE;MAClD,OAAOpB,YAAY;IACvB;IAEA,OAAOkB,OAAO,CAACV,GAAG,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,CAAC;EAC9C;AACJ,CAAC,CAAC"}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getKeyForUnistylesMediaQuery = void 0;
|
7
|
+
const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
8
|
+
const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
9
|
+
const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
|
10
|
+
const parseMq = mq => {
|
11
|
+
const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || [];
|
12
|
+
const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || [];
|
13
|
+
return {
|
14
|
+
width: width ? {
|
15
|
+
from: Number(fromW),
|
16
|
+
to: Number(toW)
|
17
|
+
} : undefined,
|
18
|
+
height: height ? {
|
19
|
+
from: Number(fromH),
|
20
|
+
to: Number(toH)
|
21
|
+
} : undefined
|
22
|
+
};
|
23
|
+
};
|
24
|
+
const isUnistylesMq = mq => IS_UNISTYLES_REGEX.test(mq);
|
25
|
+
const isValidMq = parsedMq => {
|
26
|
+
const {
|
27
|
+
width,
|
28
|
+
height
|
29
|
+
} = parsedMq;
|
30
|
+
if (width && height) {
|
31
|
+
return width.from <= width.to && height.from <= height.to;
|
32
|
+
}
|
33
|
+
if (width) {
|
34
|
+
return width.from <= width.to;
|
35
|
+
}
|
36
|
+
if (height) {
|
37
|
+
return height.from <= height.to;
|
38
|
+
}
|
39
|
+
return false;
|
40
|
+
};
|
41
|
+
const isWithinTheWidthAndHeight = (parsedMq, screenSize) => {
|
42
|
+
const {
|
43
|
+
width,
|
44
|
+
height
|
45
|
+
} = parsedMq;
|
46
|
+
if (width && height) {
|
47
|
+
return isWithinTheWidth(width, screenSize.width) && isWithinTheHeight(height, screenSize.height);
|
48
|
+
}
|
49
|
+
if (width) {
|
50
|
+
return isWithinTheWidth(width, screenSize.width);
|
51
|
+
}
|
52
|
+
if (height) {
|
53
|
+
return isWithinTheHeight(height, screenSize.height);
|
54
|
+
}
|
55
|
+
return false;
|
56
|
+
};
|
57
|
+
const isWithinTheWidth = (width, screenWidth) => {
|
58
|
+
const {
|
59
|
+
from,
|
60
|
+
to
|
61
|
+
} = width;
|
62
|
+
return screenWidth >= from && screenWidth <= to;
|
63
|
+
};
|
64
|
+
const isWithinTheHeight = (height, screenHeight) => {
|
65
|
+
const {
|
66
|
+
from,
|
67
|
+
to
|
68
|
+
} = height;
|
69
|
+
return screenHeight >= from && screenHeight <= to;
|
70
|
+
};
|
71
|
+
const getKeyForUnistylesMediaQuery = (mediaQueries, screenSize) => {
|
72
|
+
const mq = mediaQueries.find(_ref => {
|
73
|
+
let [key] = _ref;
|
74
|
+
if (!isUnistylesMq(key)) {
|
75
|
+
return false;
|
76
|
+
}
|
77
|
+
const parsedMq = parseMq(key);
|
78
|
+
if (!isValidMq(parsedMq)) {
|
79
|
+
return false;
|
80
|
+
}
|
81
|
+
return isWithinTheWidthAndHeight(parsedMq, screenSize);
|
82
|
+
});
|
83
|
+
return mq?.at(0);
|
84
|
+
};
|
85
|
+
exports.getKeyForUnistylesMediaQuery = getKeyForUnistylesMediaQuery;
|
86
|
+
//# sourceMappingURL=mqParser.js.map
|
@@ -0,0 +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","exports"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":";;;;;;AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAYpE,MAAMC,OAAO,GAAIC,EAAU,IAAwB;EAC/C,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,IAA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,MAAM,EAAEY,UAAU,CAACZ,MAAM,CAAC;EACvD;EAEA,OAAO,KAAK;AAChB,CAAC;AAED,MAAMa,gBAAgB,GAAGA,CAACjB,KAAiC,EAAEmB,WAAmB,KAAc;EAC1F,MAAM;IAAEZ,IAAI;IAAEE;EAAG,CAAC,GAAGT,KAA0B;EAE/C,OAAOmB,WAAW,IAAIZ,IAAI,IAAIY,WAAW,IAAIV,EAAE;AACnD,CAAC;AAED,MAAMS,iBAAiB,GAAGA,CAACd,MAAmC,EAAEgB,YAAoB,KAAc;EAC9F,MAAM;IAAEb,IAAI;IAAEE;EAAG,CAAC,GAAGL,MAA2B;EAEhD,OAAOgB,YAAY,IAAIb,IAAI,IAAIa,YAAY,IAAIX,EAAE;AACrD,CAAC;AAEM,MAAMY,4BAA4B,GAAGA,CAACC,YAA8B,EAAEN,UAAsB,KAAK;EACpG,MAAMjB,EAAE,GAAGuB,YAAY,CAACC,IAAI,CAACC,IAAA,IAAW;IAAA,IAAV,CAACC,GAAG,CAAC,GAAAD,IAAA;IAC/B,IAAI,CAACb,aAAa,CAACc,GAAa,CAAC,EAAE;MAC/B,OAAO,KAAK;IAChB;IAEA,MAAMX,QAAQ,GAAGhB,OAAO,CAAC2B,GAAa,CAAC;IAEvC,IAAI,CAACZ,SAAS,CAACC,QAAQ,CAAC,EAAE;MACtB,OAAO,KAAK;IAChB;IAEA,OAAOC,yBAAyB,CAACD,QAAQ,EAAEE,UAAU,CAAC;EAC1D,CAAC,CAAC;EAEF,OAAOjB,EAAE,EAAE2B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC;AAAAC,OAAA,CAAAN,4BAAA,GAAAA,4BAAA"}
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.normalizeStyles = void 0;
|
7
7
|
var _common = require("./common");
|
8
|
-
|
9
|
-
const normalizeBoxShadow =
|
8
|
+
var _normalizer = require("./normalizer");
|
9
|
+
const normalizeBoxShadow = style => {
|
10
10
|
const requiredBoxShadowProperties = ['shadowColor', 'shadowOffset', 'shadowOpacity', 'shadowRadius'];
|
11
|
-
if (!requiredBoxShadowProperties.every(prop => prop in
|
11
|
+
if (!requiredBoxShadowProperties.every(prop => prop in style)) {
|
12
12
|
(0, _common.warn)(`can't apply box shadow as you miss at least one of these properties: ${requiredBoxShadowProperties.join(', ')}`);
|
13
13
|
return {
|
14
14
|
shadowColor: undefined,
|
@@ -18,16 +18,16 @@ const normalizeBoxShadow = styles => {
|
|
18
18
|
};
|
19
19
|
}
|
20
20
|
return {
|
21
|
-
boxShadow: preprocessor.createBoxShadowValue(
|
21
|
+
boxShadow: _normalizer.preprocessor.createBoxShadowValue(style),
|
22
22
|
shadowColor: undefined,
|
23
23
|
shadowOffset: undefined,
|
24
24
|
shadowOpacity: undefined,
|
25
25
|
shadowRadius: undefined
|
26
26
|
};
|
27
27
|
};
|
28
|
-
const normalizeTextShadow =
|
28
|
+
const normalizeTextShadow = style => {
|
29
29
|
const requiredTextShadowProperties = ['textShadowColor', 'textShadowOffset', 'textShadowRadius'];
|
30
|
-
if (!requiredTextShadowProperties.every(prop => prop in
|
30
|
+
if (!requiredTextShadowProperties.every(prop => prop in style)) {
|
31
31
|
(0, _common.warn)(`can't apply text shadow as you miss at least one of these properties: ${requiredTextShadowProperties.join(', ')}`);
|
32
32
|
return {
|
33
33
|
textShadowColor: undefined,
|
@@ -36,20 +36,20 @@ const normalizeTextShadow = styles => {
|
|
36
36
|
};
|
37
37
|
}
|
38
38
|
return {
|
39
|
-
textShadow: preprocessor.createTextShadowValue(
|
39
|
+
textShadow: _normalizer.preprocessor.createTextShadowValue(style),
|
40
40
|
textShadowColor: undefined,
|
41
41
|
textShadowOffset: undefined,
|
42
42
|
textShadowRadius: undefined
|
43
43
|
};
|
44
44
|
};
|
45
|
-
const normalizeStyles =
|
46
|
-
const normalizedTransform = 'transform' in
|
47
|
-
transform: preprocessor.createTransformValue(
|
45
|
+
const normalizeStyles = style => {
|
46
|
+
const normalizedTransform = 'transform' in style && Array.isArray(style.transform) ? {
|
47
|
+
transform: _normalizer.preprocessor.createTransformValue(style.transform)
|
48
48
|
} : {};
|
49
|
-
const normalizedBoxShadow = 'shadowColor' in
|
50
|
-
const normalizedTextShadow = 'textShadowColor' in
|
49
|
+
const normalizedBoxShadow = 'shadowColor' in style || 'shadowOffset' in style || 'shadowOpacity' in style || 'shadowRadius' in style ? normalizeBoxShadow(style) : {};
|
50
|
+
const normalizedTextShadow = 'textShadowColor' in style || 'textShadowOffset' in style || 'textShadowRadius' in style ? normalizeTextShadow(style) : {};
|
51
51
|
return {
|
52
|
-
...
|
52
|
+
...style,
|
53
53
|
...normalizedTransform,
|
54
54
|
...normalizedBoxShadow,
|
55
55
|
...normalizedTextShadow
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_common","require","
|
1
|
+
{"version":3,"names":["_common","require","_normalizer","normalizeBoxShadow","style","requiredBoxShadowProperties","every","prop","warn","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","preprocessor","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyles","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow","exports"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.web.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,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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e,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,eAAA,GAAAA,eAAA"}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.preprocessor = exports.normalizeNumericValue = exports.normalizeColor = void 0;
|
7
|
+
var _normalizeColors = _interopRequireDefault(require("@react-native/normalize-colors"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
// based on react-native-web normalizer
|
10
|
+
// https://github.com/necolas/react-native-web
|
11
|
+
|
12
|
+
const normalizeColor = function (color) {
|
13
|
+
let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
14
|
+
// If the opacity is 1 there's no need to normalize the color
|
15
|
+
if (opacity === 1) {
|
16
|
+
return color;
|
17
|
+
}
|
18
|
+
const integer = (0, _normalizeColors.default)(color);
|
19
|
+
|
20
|
+
// If the colour is an unknown format, the return value is null
|
21
|
+
if (integer === null) {
|
22
|
+
return color;
|
23
|
+
}
|
24
|
+
const hex = integer.toString(16).padStart(8, '0');
|
25
|
+
if (hex.length === 8) {
|
26
|
+
const [r = 0, g = 0, b = 0, a = 1] = hex.split(/(?=(?:..)*$)/).map(x => parseInt(x, 16)).filter(num => !isNaN(num));
|
27
|
+
return `rgba(${r},${g},${b},${a / 255 * opacity})`;
|
28
|
+
}
|
29
|
+
return color;
|
30
|
+
};
|
31
|
+
exports.normalizeColor = normalizeColor;
|
32
|
+
const normalizeNumericValue = value => value ? `${value}px` : value;
|
33
|
+
exports.normalizeNumericValue = normalizeNumericValue;
|
34
|
+
const normalizeTransform = (key, value) => {
|
35
|
+
if (key.includes('scale')) {
|
36
|
+
return value;
|
37
|
+
}
|
38
|
+
if (typeof value === 'number') {
|
39
|
+
return normalizeNumericValue(value);
|
40
|
+
}
|
41
|
+
return value;
|
42
|
+
};
|
43
|
+
const createTextShadowValue = style => {
|
44
|
+
// at this point every prop is present
|
45
|
+
const {
|
46
|
+
textShadowColor,
|
47
|
+
textShadowOffset,
|
48
|
+
textShadowRadius
|
49
|
+
} = style;
|
50
|
+
const offsetX = normalizeNumericValue(textShadowOffset.width);
|
51
|
+
const offsetY = normalizeNumericValue(textShadowOffset.height);
|
52
|
+
const radius = normalizeNumericValue(textShadowRadius);
|
53
|
+
const color = normalizeColor(textShadowColor);
|
54
|
+
return `${offsetX} ${offsetY} ${radius} ${color}`;
|
55
|
+
};
|
56
|
+
const createBoxShadowValue = style => {
|
57
|
+
// at this point every prop is present
|
58
|
+
const {
|
59
|
+
shadowColor,
|
60
|
+
shadowOffset,
|
61
|
+
shadowOpacity,
|
62
|
+
shadowRadius
|
63
|
+
} = style;
|
64
|
+
const offsetX = normalizeNumericValue(shadowOffset.width);
|
65
|
+
const offsetY = normalizeNumericValue(shadowOffset.height);
|
66
|
+
const radius = normalizeNumericValue(shadowRadius);
|
67
|
+
const color = normalizeColor(shadowColor, shadowOpacity);
|
68
|
+
return `${offsetX} ${offsetY} ${radius} ${color}`;
|
69
|
+
};
|
70
|
+
const createTransformValue = transforms => transforms.map(transform => {
|
71
|
+
const [key] = Object.keys(transform);
|
72
|
+
if (!key) {
|
73
|
+
return undefined;
|
74
|
+
}
|
75
|
+
const value = transform[key];
|
76
|
+
switch (key) {
|
77
|
+
case 'matrix':
|
78
|
+
case 'matrix3d':
|
79
|
+
return `${key}(${value.join(',')})`;
|
80
|
+
default:
|
81
|
+
return `${key}(${normalizeTransform(key, value)})`;
|
82
|
+
}
|
83
|
+
}).filter(Boolean).join(' ');
|
84
|
+
const preprocessor = exports.preprocessor = {
|
85
|
+
createTextShadowValue,
|
86
|
+
createBoxShadowValue,
|
87
|
+
createTransformValue
|
88
|
+
};
|
89
|
+
//# sourceMappingURL=normalizer.js.map
|
@@ -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":["utils/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,CAAkB;;EAEvD;EACA,IAAIK,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOL,KAAK;EAChB;EAEA,MAAMO,GAAG,GAAGF,OAAO,CAACG,QAAQ,CAAC,EAAE,CAA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AC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEP,MAAME,YAA0B,GAAA5B,OAAA,CAAA4B,YAAA,GAAG;EACtCtB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
|
@@ -3,81 +3,52 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.proxifyFunction = exports.parseStyle = void 0;
|
6
|
+
exports.proxifyFunction = exports.parseStyle = exports.isPlatformColor = void 0;
|
7
7
|
var _breakpoints = require("./breakpoints");
|
8
8
|
var _normalizeStyles = require("./normalizeStyles");
|
9
9
|
var _common = require("./common");
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
* @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
|
14
|
-
*
|
15
|
-
* @param {Function} fn - The function to be proxified.
|
16
|
-
* @param {keyof B & string} breakpoint - The breakpoint name to check against.
|
17
|
-
* @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
|
18
|
-
* @param breakpointPairs - sorted pairs of breakpoints
|
19
|
-
*
|
20
|
-
* @returns {Function} Returns the proxified function
|
21
|
-
*
|
22
|
-
* @example
|
23
|
-
*
|
24
|
-
* const myFunction = () => ({ ':w[200]': 'value1', sm: 'value2' })
|
25
|
-
* const screenSize = { width: 250, height: 400 }
|
26
|
-
* const breakpoints = { sm: 300, md: 600 }
|
27
|
-
*
|
28
|
-
* const proxifiedFunction = proxifyFunction(myFunction, 'sm', screenSize, breakpoints)
|
29
|
-
* proxifiedFunction() // parsed style based on screenSize and breakpoints
|
30
|
-
*/
|
31
|
-
const proxifyFunction = (fn, breakpoint, screenSize, breakpointPairs) => new Proxy(fn, {
|
32
|
-
apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, breakpointPairs)
|
10
|
+
var _variants = require("./variants");
|
11
|
+
const proxifyFunction = (fn, breakpoint, screenSize, variant) => new Proxy(fn, {
|
12
|
+
apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, variant)
|
33
13
|
});
|
34
|
-
|
35
|
-
/**
|
36
|
-
* Parses a style object to resolve custom media queries or breakpoints based on the provided screen size and breakpoints.
|
37
|
-
*
|
38
|
-
* The function processes each key-value pair in the style object. If the value is a function or a valid style (not an object or a 'transform' key),
|
39
|
-
* it is returned as-is. Otherwise, the function attempts to resolve the value based on the provided breakpoint, screen size, and defined breakpoints.
|
40
|
-
*
|
41
|
-
* @template T - The type of the style object.
|
42
|
-
* @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
|
43
|
-
*
|
44
|
-
* @param {CustomNamedStyles<T, B>} style - The style object to be parsed.
|
45
|
-
* @param {keyof B & string} breakpoint - The breakpoint name to check against.
|
46
|
-
* @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
|
47
|
-
* @param breakpointPairs - sorted pairs of breakpoints
|
48
|
-
*
|
49
|
-
* @returns {Record<string, string | number | Function>} Returns the parsed style object with resolved custom media queries or breakpoints.
|
50
|
-
*
|
51
|
-
* @example
|
52
|
-
*
|
53
|
-
* const style = { fontSize: { sm: '12px', md: '16px' } }
|
54
|
-
* const screenSize = { width: 300, height: 400 }
|
55
|
-
* const breakpoints = { xs: 0, sm: 300, md: 600 }
|
56
|
-
*
|
57
|
-
* const parsedStyle = parseStyle(style, 'sm', screenSize, breakpoints)
|
58
|
-
* // { fontSize: '12px' }
|
59
|
-
*/
|
60
14
|
exports.proxifyFunction = proxifyFunction;
|
61
|
-
const
|
62
|
-
|
63
|
-
|
15
|
+
const isPlatformColor = value => {
|
16
|
+
if (_common.isIOS) {
|
17
|
+
return 'semantic' in value && typeof value.semantic === 'object';
|
18
|
+
}
|
19
|
+
return _common.isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
|
20
|
+
};
|
21
|
+
exports.isPlatformColor = isPlatformColor;
|
22
|
+
const parseStyle = (style, breakpoint, screenSize, variant) => {
|
23
|
+
const entries = Object.entries(style || {}).map(_ref => {
|
64
24
|
let [key, value] = _ref;
|
25
|
+
if (key !== 'variants') {
|
26
|
+
return [key, value];
|
27
|
+
}
|
28
|
+
const variantKey = (0, _variants.getKeyForVariant)(value, variant);
|
29
|
+
if (!variantKey) {
|
30
|
+
return undefined;
|
31
|
+
}
|
32
|
+
return Object.entries(value[variantKey]).flat();
|
33
|
+
}).filter(Boolean);
|
34
|
+
const parsedStyles = Object.fromEntries(entries.map(_ref2 => {
|
35
|
+
let [key, value] = _ref2;
|
65
36
|
const hasNestedProperties = key === 'shadowOffset' || key === 'textShadowOffset';
|
66
37
|
if (hasNestedProperties) {
|
67
|
-
return [key, parseStyle(value, breakpoint, screenSize,
|
38
|
+
return [key, parseStyle(value, breakpoint, screenSize, variant)];
|
68
39
|
}
|
69
40
|
const isTransform = key === 'transform';
|
70
41
|
if (isTransform && Array.isArray(value)) {
|
71
|
-
return [key, value.map(value => parseStyle(value, breakpoint, screenSize,
|
42
|
+
return [key, value.map(value => parseStyle(value, breakpoint, screenSize, variant))];
|
72
43
|
}
|
73
44
|
const isDynamicFunction = typeof value === 'function';
|
74
|
-
const isValidStyle = typeof value !== 'object';
|
45
|
+
const isValidStyle = typeof value !== 'object' || isPlatformColor(value);
|
75
46
|
if (isDynamicFunction || isValidStyle) {
|
76
47
|
return [key, value];
|
77
48
|
}
|
78
|
-
return [key, (0, _breakpoints.getValueForBreakpoint)(value
|
49
|
+
return [key, (0, _breakpoints.getValueForBreakpoint)(value)];
|
79
50
|
}));
|
80
|
-
return
|
51
|
+
return _common.isWeb ? (0, _normalizeStyles.normalizeStyles)(parsedStyles) : parsedStyles;
|
81
52
|
};
|
82
53
|
exports.parseStyle = parseStyle;
|
83
54
|
//# sourceMappingURL=styles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_breakpoints","require","_normalizeStyles","_common","proxifyFunction","fn","breakpoint","screenSize","
|
1
|
+
{"version":3,"names":["_breakpoints","require","_normalizeStyles","_common","_variants","proxifyFunction","fn","breakpoint","screenSize","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","entries","Object","map","_ref","key","variantKey","getKeyForVariant","undefined","flat","filter","Boolean","parsedStyles","fromEntries","_ref2","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle","getValueForBreakpoint","isWeb","normalizeStyles"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAEO,MAAMI,eAAe,GAAGA,CAC3BC,EAAY,EAAEC,UAA+C,EAC7DC,UAAsB,EACtBC,OAAgB,KACL,IAAIC,KAAK,CAACJ,EAAE,EAAE;EACzBK,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAClCC,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEP,UAAU,EAAEC,UAAU,EAAEC,OAAO;AACxF,CAAC,CAAC;AAAAO,OAAA,CAAAX,eAAA,GAAAA,eAAA;AAEK,MAAMY,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIC,aAAK,EAAE;IACP,OAAO,UAAU,IAAID,KAAK,IAAI,OAAOA,KAAK,CAACE,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOC,iBAAS,IAAI,gBAAgB,IAAIH,KAAK,IAAI,OAAOA,KAAK,CAACI,cAAc,KAAK,QAAQ;AAC7F,CAAC;AAAAN,OAAA,CAAAC,eAAA,GAAAA,eAAA;AAEM,MAAMF,UAAU,GAAGA,CACtBQ,KAA2B,EAC3BhB,UAA+C,EAC/CC,UAAsB,EACtBC,OAAgB,KACZ;EACJ,MAAMe,OAAO,GAAIC,MAAM,CAClBD,OAAO,CAACD,KAAK,IAAI,CAAC,CA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