react-native-unistyles 2.0.0-alpha.14 → 2.0.0-alpha.16
Sign up to get free protection for your applications and to get access to all the features.
- package/cxx/UnistylesRuntime.h +6 -6
- package/lib/commonjs/common.js +15 -15
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistylesRuntime.js +1 -1
- 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 +4 -7
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
- package/lib/commonjs/hooks/useVariants.js +24 -0
- package/lib/commonjs/hooks/useVariants.js.map +1 -0
- package/lib/commonjs/plugins/normalizer/normalizer.js +1 -1
- package/lib/commonjs/plugins/normalizer/normalizer.js.map +1 -1
- package/lib/commonjs/types/{mq.js → stylesheet.js} +1 -1
- package/lib/commonjs/types/{mq.js.map → stylesheet.js.map} +1 -1
- package/lib/commonjs/useStyles.js +5 -4
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/index.js +0 -6
- 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/styles.js +14 -8
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/commonjs/utils/variants.js +33 -13
- package/lib/commonjs/utils/variants.js.map +1 -1
- package/lib/module/common.js +14 -14
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistylesRuntime.js +1 -1
- 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 +5 -8
- package/lib/module/hooks/useUnistyles.js.map +1 -1
- package/lib/module/hooks/useVariants.js +17 -0
- package/lib/module/hooks/useVariants.js.map +1 -0
- package/lib/module/plugins/normalizer/normalizer.js +1 -1
- package/lib/module/plugins/normalizer/normalizer.js.map +1 -1
- package/lib/module/types/stylesheet.js +2 -0
- package/lib/module/types/{mq.js.map → stylesheet.js.map} +1 -1
- package/lib/module/useStyles.js +6 -5
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/index.js +1 -1
- 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/styles.js +15 -9
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/module/utils/variants.js +31 -11
- package/lib/module/utils/variants.js.map +1 -1
- package/lib/typescript/src/common.d.ts +10 -10
- package/lib/typescript/src/common.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.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/plugins/normalizer/normalizer.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +24 -15
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +5 -29
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +2 -2
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- 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 +5 -6
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
- package/lib/typescript/src/types/variants.d.ts +13 -7
- package/lib/typescript/src/types/variants.d.ts.map +1 -1
- package/lib/typescript/src/useStyles.d.ts +3 -3
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +1 -1
- 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/styles.d.ts +3 -3
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/lib/typescript/src/utils/variants.d.ts +2 -2
- package/lib/typescript/src/utils/variants.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/common.ts +10 -10
- package/src/core/UnistylesRuntime.ts +1 -1
- package/src/createStyleSheet.ts +2 -8
- package/src/global.ts +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useUnistyles.ts +5 -8
- package/src/hooks/useVariants.ts +23 -0
- package/src/plugins/normalizer/normalizer.ts +3 -3
- package/src/types/breakpoints.ts +51 -27
- package/src/types/core.ts +8 -45
- package/src/types/index.ts +1 -2
- package/src/types/stylesheet.ts +49 -0
- package/src/types/unistyles.ts +5 -6
- package/src/types/variants.ts +17 -9
- package/src/useStyles.ts +15 -15
- package/src/utils/index.ts +1 -1
- package/src/utils/mq.ts +31 -84
- package/src/utils/styles.ts +18 -17
- package/src/utils/variants.ts +41 -17
- package/lib/module/types/mq.js +0 -2
- package/lib/typescript/src/types/mq.d.ts +0 -3
- package/lib/typescript/src/types/mq.d.ts.map +0 -1
- package/src/types/mq.ts +0 -3
package/cxx/UnistylesRuntime.h
CHANGED
@@ -12,9 +12,9 @@ const std::string UnistylesDarkScheme = "dark";
|
|
12
12
|
const std::string UnistylesLightScheme = "light";
|
13
13
|
const std::string UnistylesUnspecifiedScheme = "unspecified";
|
14
14
|
|
15
|
-
const std::string UnistylesErrorBreakpointsCannotBeEmpty = "
|
16
|
-
const std::string UnistylesErrorBreakpointsMustStartFromZero = "
|
17
|
-
const std::string UnistylesErrorThemesCannotBeEmpty = "
|
15
|
+
const std::string UnistylesErrorBreakpointsCannotBeEmpty = "You are trying to register an empty breakpoints object.";
|
16
|
+
const std::string UnistylesErrorBreakpointsMustStartFromZero = "One breakpoint must start from 0.";
|
17
|
+
const std::string UnistylesErrorThemesCannotBeEmpty = "You are trying to register an empty themes object.";
|
18
18
|
|
19
19
|
class JSI_EXPORT UnistylesRuntime : public jsi::HostObject {
|
20
20
|
private:
|
@@ -41,15 +41,15 @@ public:
|
|
41
41
|
std::vector<std::string> pluginNames;
|
42
42
|
std::vector<std::string> themes;
|
43
43
|
std::vector<std::pair<std::string, double>> sortedBreakpointPairs;
|
44
|
-
|
44
|
+
|
45
45
|
void onThemeChange(std::function<void(std::string)> callback) {
|
46
46
|
this->onThemeChangeCallback = callback;
|
47
47
|
}
|
48
|
-
|
48
|
+
|
49
49
|
void onLayoutChange(std::function<void(std::string breakpoint, std::string orientation, int screenWidth, int screenHeight)> callback) {
|
50
50
|
this->onLayoutChangeCallback = callback;
|
51
51
|
}
|
52
|
-
|
52
|
+
|
53
53
|
void onPluginChange(std::function<void()> callback) {
|
54
54
|
this->onPluginChangeCallback = callback;
|
55
55
|
}
|
package/lib/commonjs/common.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.warn = exports.isWeb = exports.isServer = exports.isMobile = exports.isIOS = exports.isAndroid = exports.
|
6
|
+
exports.warn = exports.isWeb = exports.isServer = exports.isMobile = exports.isIOS = exports.isAndroid = exports.UnistylesEventType = exports.UnistylesError = exports.ScreenOrientation = void 0;
|
7
7
|
var _reactNative = require("react-native");
|
8
8
|
const warn = message => {
|
9
9
|
console.warn(`🦄 [react-native-unistyles]: ${message}`);
|
@@ -18,22 +18,22 @@ const ScreenOrientation = exports.ScreenOrientation = {
|
|
18
18
|
Landscape: 'landscape',
|
19
19
|
Portrait: 'portrait'
|
20
20
|
};
|
21
|
-
let
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
return
|
21
|
+
let UnistylesEventType = exports.UnistylesEventType = /*#__PURE__*/function (UnistylesEventType) {
|
22
|
+
UnistylesEventType["Theme"] = "theme";
|
23
|
+
UnistylesEventType["Layout"] = "layout";
|
24
|
+
UnistylesEventType["Plugin"] = "plugin";
|
25
|
+
return UnistylesEventType;
|
26
26
|
}({});
|
27
27
|
let UnistylesError = exports.UnistylesError = /*#__PURE__*/function (UnistylesError) {
|
28
|
-
UnistylesError["RuntimeUnavailable"] = "
|
29
|
-
UnistylesError["ThemeNotFound"] = "
|
30
|
-
UnistylesError["ThemeNotRegistered"] = "
|
31
|
-
UnistylesError["ThemesCannotBeEmpty"] = "
|
32
|
-
UnistylesError["BreakpointsCannotBeEmpty"] = "
|
33
|
-
UnistylesError["BreakpointsMustStartFromZero"] = "
|
34
|
-
UnistylesError["InvalidPluginName"] = "
|
35
|
-
UnistylesError["DuplicatePluginName"] = "
|
36
|
-
UnistylesError["CantRemoveInternalPlugin"] = "
|
28
|
+
UnistylesError["RuntimeUnavailable"] = "Unistyles runtime is not available. Make sure you followed the installation instructions.";
|
29
|
+
UnistylesError["ThemeNotFound"] = "You are trying to get a theme that is not registered.";
|
30
|
+
UnistylesError["ThemeNotRegistered"] = "You are trying to set a theme that is not registered.";
|
31
|
+
UnistylesError["ThemesCannotBeEmpty"] = "You are trying to register an empty themes object.";
|
32
|
+
UnistylesError["BreakpointsCannotBeEmpty"] = "You are trying to register an empty breakpoints object.";
|
33
|
+
UnistylesError["BreakpointsMustStartFromZero"] = "One breakpoint must start from 0.";
|
34
|
+
UnistylesError["InvalidPluginName"] = "Plugin name can't start from reserved prefix. Use another name.";
|
35
|
+
UnistylesError["DuplicatePluginName"] = "You are trying to register a plugin with a name that is already registered.";
|
36
|
+
UnistylesError["CantRemoveInternalPlugin"] = "You are trying to remove an internal unistyles plugin.";
|
37
37
|
return UnistylesError;
|
38
38
|
}({});
|
39
39
|
//# sourceMappingURL=common.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","warn","message","console","exports","isMobile","Platform","OS","isWeb","isIOS","isAndroid","isServer","window","ScreenOrientation","Landscape","Portrait","
|
1
|
+
{"version":3,"names":["_reactNative","require","warn","message","console","exports","isMobile","Platform","OS","isWeb","isIOS","isAndroid","isServer","window","ScreenOrientation","Landscape","Portrait","UnistylesEventType","UnistylesError"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,IAAI,GAAIC,OAAe,IAAK;EACrCC,OAAO,CAACF,IAAI,CAAE,gCAA+BC,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAAAE,OAAA,CAAAH,IAAA,GAAAA,IAAA;AAEM,MAAMI,QAAQ,GAAAD,OAAA,CAAAC,QAAA,GAAGC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAID,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnE,MAAMC,KAAK,GAAAJ,OAAA,CAAAI,KAAA,GAAGF,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAME,KAAK,GAAAL,OAAA,CAAAK,KAAA,GAAGH,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAMG,SAAS,GAAAN,OAAA,CAAAM,SAAA,GAAGJ,qBAAQ,CAACC,EAAE,KAAK,SAAS;AAC3C,MAAMI,QAAQ,GAAAP,OAAA,CAAAO,QAAA,GAAG,OAAOC,MAAM,KAAK,WAAW;AAE9C,MAAMC,iBAAiB,GAAAT,OAAA,CAAAS,iBAAA,GAAG;EAC7BC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU;AAAA,IAEEC,kBAAkB,GAAAZ,OAAA,CAAAY,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAAA,IAMlBC,cAAc,GAAAb,OAAA,CAAAa,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
|
@@ -42,7 +42,7 @@ class UnistylesRuntime {
|
|
42
42
|
return _common.ScreenOrientation.Portrait;
|
43
43
|
}
|
44
44
|
setTheme = name => {
|
45
|
-
if (this.unistylesRegistry.hasTheme(name)) {
|
45
|
+
if (name !== this.themeName && this.unistylesRegistry.hasTheme(name)) {
|
46
46
|
this.unistylesBridge.useTheme(name);
|
47
47
|
return true;
|
48
48
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_common","require","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","breakpoint","enabledPlugins","screen","width","screenWidth","height","screenHeight","orientation","ScreenOrientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","UnistylesError","ThemeNotRegistered","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin","exports"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,iBAAmC,EAAE;IAAA,KAA/ED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,iBAAmC,GAAnCA,iBAAmC;EAAG;EAEpG,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,eAAe,CAACE,WAAW;EAC3C;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,eAAe,CAACG,iBAAiB;EACjD;EAEA,IAAWC,SAASA,CAAA,EAAG;IACnB,OAAO,IAAI,CAACJ,eAAe,CAACI,SAAS;EACzC;EAEA,IAAWC,UAAUA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACL,eAAe,CAACK,UAAU;EAC1C;EAEA,IAAWC,cAAcA,CAAA,EAAG;IACxB,OAAO,IAAI,CAACN,eAAe,CAACM,cAAc;EAC9C;EAEA,IAAWC,MAAMA,CAAA,EAAG;IAChB,OAAO;MACHC,KAAK,EAAE,IAAI,CAACR,eAAe,CAACS,WAAW;MACvCC,MAAM,EAAE,IAAI,CAACV,eAAe,CAACW;IACjC,CAAC;EACL;EAEA,IAAWC,WAAWA,CAAA,EAAG;IACrB,MAAM;MAAEJ,KAAK;MAAEE;IAAO,CAAC,GAAG,IAAI,CAACH,MAAM;IAErC,IAAIC,KAAK,GAAGE,MAAM,EAAE;MAChB,OAAOG,yBAAiB,CAACC,SAAS;IACtC;IAEA,OAAOD,yBAAiB,CAACE,QAAQ;EACrC;EAEOC,QAAQ,GAAIC,IAA2B,IAAK;IAC/C,IAAI,IAAI,
|
1
|
+
{"version":3,"names":["_common","require","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","breakpoint","enabledPlugins","screen","width","screenWidth","height","screenHeight","orientation","ScreenOrientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","UnistylesError","ThemeNotRegistered","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin","exports"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,iBAAmC,EAAE;IAAA,KAA/ED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,iBAAmC,GAAnCA,iBAAmC;EAAG;EAEpG,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,eAAe,CAACE,WAAW;EAC3C;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI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B,YAAY,CAACD,MAAM,CAAC;EAC/C,CAAC;AACL;AAACE,OAAA,CAAA/B,gBAAA,GAAAA,gBAAA"}
|
@@ -4,11 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createStyleSheet = void 0;
|
7
|
-
const createStyleSheet =
|
8
|
-
if (typeof styles === 'function') {
|
9
|
-
return styles;
|
10
|
-
}
|
11
|
-
return styles;
|
12
|
-
};
|
7
|
+
const createStyleSheet = stylesheet => stylesheet;
|
13
8
|
exports.createStyleSheet = createStyleSheet;
|
14
9
|
//# sourceMappingURL=createStyleSheet.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createStyleSheet","
|
1
|
+
{"version":3,"names":["createStyleSheet","stylesheet","exports"],"sourceRoot":"../../src","sources":["createStyleSheet.ts"],"mappings":";;;;;;AAEO,MAAMA,gBAAgB,GAAyCC,UAAa,IAAQA,UAAU;AAAAC,OAAA,CAAAF,gBAAA,GAAAA,gBAAA"}
|
@@ -15,6 +15,13 @@ Object.defineProperty(exports, "useUnistyles", {
|
|
15
15
|
return _useUnistyles.useUnistyles;
|
16
16
|
}
|
17
17
|
});
|
18
|
+
Object.defineProperty(exports, "useVariants", {
|
19
|
+
enumerable: true,
|
20
|
+
get: function () {
|
21
|
+
return _useVariants.useVariants;
|
22
|
+
}
|
23
|
+
});
|
18
24
|
var _useInitialTheme = require("./useInitialTheme");
|
19
25
|
var _useUnistyles = require("./useUnistyles");
|
26
|
+
var _useVariants = require("./useVariants");
|
20
27
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_useInitialTheme","require","_useUnistyles"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":"
|
1
|
+
{"version":3,"names":["_useInitialTheme","require","_useUnistyles","_useVariants"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA"}
|
@@ -23,24 +23,21 @@ const useUnistyles = () => {
|
|
23
23
|
(0, _react.useEffect)(() => {
|
24
24
|
const subscription = unistylesEvents.addListener('onChange', event => {
|
25
25
|
switch (event.type) {
|
26
|
-
case _common.
|
26
|
+
case _common.UnistylesEventType.Theme:
|
27
27
|
{
|
28
28
|
const themeEvent = event;
|
29
29
|
return setTheme(_core.unistyles.registry.getTheme(themeEvent.payload.themeName));
|
30
30
|
}
|
31
|
-
case _common.
|
31
|
+
case _common.UnistylesEventType.Layout:
|
32
32
|
{
|
33
33
|
const layoutEvent = event;
|
34
34
|
return setLayout({
|
35
35
|
breakpoint: layoutEvent.payload.breakpoint,
|
36
36
|
orientation: layoutEvent.payload.orientation,
|
37
|
-
screenSize:
|
38
|
-
width: layoutEvent.payload.screen.width,
|
39
|
-
height: layoutEvent.payload.screen.height
|
40
|
-
}
|
37
|
+
screenSize: layoutEvent.payload.screen
|
41
38
|
});
|
42
39
|
}
|
43
|
-
case _common.
|
40
|
+
case _common.UnistylesEventType.Plugin:
|
44
41
|
{
|
45
42
|
return setPlugins(_core.unistyles.runtime.enabledPlugins);
|
46
43
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_react","_core","_common","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","useUnistyles","plugins","setPlugins","useState","unistyles","runtime","enabledPlugins","theme","setTheme","registry","getTheme","themeName","layout","setLayout","breakpoint","orientation","screenSize","width","screen","height","useEffect","subscription","addListener","event","type","
|
1
|
+
{"version":3,"names":["_reactNative","require","_react","_core","_common","unistylesEvents","NativeEventEmitter","NativeModules","Unistyles","useUnistyles","plugins","setPlugins","useState","unistyles","runtime","enabledPlugins","theme","setTheme","registry","getTheme","themeName","layout","setLayout","breakpoint","orientation","screenSize","width","screen","height","useEffect","subscription","addListener","event","type","UnistylesEventType","Theme","themeEvent","payload","Layout","layoutEvent","Plugin","remove","exports"],"sourceRoot":"../../../src","sources":["hooks/useUnistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAGA,MAAMI,eAAe,GAAG,IAAIC,+BAAkB,CAACC,0BAAa,CAACC,SAAS,CAAC;AAEhE,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAG,IAAAC,eAAQ,EAACC,eAAS,CAACC,OAAO,CAACC,cAAc,CAAC;EACxE,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAL,eAAQ,EAACC,eAAS,CAACK,QAAQ,CAACC,QAAQ,CAACN,eAAS,CAACC,OAAO,CAACM,SAAS,CAAC,CAAC;EAC5F,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAG,IAAAV,eAAQ,EAAC;IACjCW,UAAU,EAAEV,eAAS,CAACC,OAAO,CAACS,UAAU;IACxCC,WAAW,EAAEX,eAAS,CAACC,OAAO,CAACU,WAAW;IAC1CC,UAAU,EAAE;MACRC,KAAK,EAAEb,eAAS,CAACC,OAAO,CAACa,MAAM,CAACD,KAAK;MACrCE,MAAM,EAAEf,eAAS,CAACC,OAAO,CAACa,MAAM,CAACC;IACrC;EACJ,CAAC,CAAC;EAEF,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,YAAY,GAAGzB,eAAe,CAAC0B,WAAW,CAC5C,UAAU,EACTC,KAAsB,IAAK;MACxB,QAAQA,KAAK,CAACC,IAAI;QACd,KAAKC,0BAAkB,CAACC,KAAK;UAAE;YAC3B,MAAMC,UAAU,GAAGJ,KAA4B;YAE/C,OAAOf,QAAQ,CAACJ,eAAS,CAACK,QAAQ,CAACC,QAAQ,CAACiB,UAAU,CAACC,OAAO,CAACjB,SAAS,CAAC,CAAC;UAC9E;QACA,KAAKc,0BAAkB,CAACI,MAAM;UAAE;YAC5B,MAAMC,WAAW,GAAGP,KAAmC;YAEvD,OAAOV,SAAS,CAAC;cACbC,UAAU,EAAEgB,WAAW,CAACF,OAAO,CAACd,UAAU;cAC1CC,WAAW,EAAEe,WAAW,CAACF,OAAO,CAACb,WAAW;cAC5CC,UAAU,EAAEc,WAAW,CAACF,OAAO,CAACV;YACpC,CAAC,CAAC;UACN;QACA,KAAKO,0BAAkB,CAACM,MAAM;UAAE;YAC5B,OAAO7B,UAAU,CAACE,eAAS,CAACC,OAAO,CAACC,cAAc,CAAC;UACvD;QACA;UACI;MACR;IACJ,CACJ,CAAC;IAED,OAAOe,YAAY,CAACW,MAAM;EAC9B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACH/B,OAAO;IACPM,KAAK;IACLK;EACJ,CAAC;AACL,CAAC;AAAAqB,OAAA,CAAAjC,YAAA,GAAAA,YAAA"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.useVariants = void 0;
|
7
|
+
var _react = require("react");
|
8
|
+
const compareVariants = (prevVariants, nextVariants) => {
|
9
|
+
const keysA = Object.keys(prevVariants ?? {});
|
10
|
+
const keysB = Object.keys(nextVariants ?? {});
|
11
|
+
if (keysA.length !== keysB.length) {
|
12
|
+
return false;
|
13
|
+
}
|
14
|
+
return keysA.every(key => prevVariants[key] === (nextVariants ?? {})[key]);
|
15
|
+
};
|
16
|
+
const useVariants = variantsMap => {
|
17
|
+
const variantsRef = (0, _react.useRef)(variantsMap);
|
18
|
+
if (!compareVariants(variantsRef.current, variantsMap)) {
|
19
|
+
variantsRef.current = variantsMap;
|
20
|
+
}
|
21
|
+
return variantsRef.current;
|
22
|
+
};
|
23
|
+
exports.useVariants = useVariants;
|
24
|
+
//# sourceMappingURL=useVariants.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_react","require","compareVariants","prevVariants","nextVariants","keysA","Object","keys","keysB","length","every","key","useVariants","variantsMap","variantsRef","useRef","current","exports"],"sourceRoot":"../../../src","sources":["hooks/useVariants.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,MAAMC,eAAe,GAAGA,CAACC,YAA+C,EAAEC,YAA+C,KAAK;EAC1H,MAAMC,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACJ,YAAY,IAAI,CAAC,CAAC,CAAC;EAC7C,MAAMK,KAAK,GAAGF,MAAM,CAACC,IAAI,CAACH,YAAY,IAAI,CAAC,CAAC,CAAC;EAE7C,IAAIC,KAAK,CAACI,MAAM,KAAKD,KAAK,CAACC,MAAM,EAAE;IAC/B,OAAO,KAAK;EAChB;EAEA,OAAOJ,KAAK,CAACK,KAAK,CAACC,GAAG,IAAIR,YAAY,CAAEQ,GAAG,CAAC,KAAK,CAACP,YAAY,IAAI,CAAC,CAAC,EAAEO,GAAG,CAAC,CAAC;AAC/E,CAAC;AAEM,MAAMC,WAAW,GAAIC,WAA8C,IAAK;EAC3E,MAAMC,WAAW,GAAG,IAAAC,aAAM,EAA6CF,WAAW,CAAC;EAEnF,IAAI,CAACX,eAAe,CAACY,WAAW,CAACE,OAAO,EAAEH,WAAW,CAAC,EAAE;IACpDC,WAAW,CAACE,OAAO,GAAGH,WAAW;EACrC;EAEA,OAAOC,WAAW,CAACE,OAAO;AAC9B,CAAC;AAAAC,OAAA,CAAAL,WAAA,GAAAA,WAAA"}
|
@@ -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
|
}
|
@@ -1 +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,
|
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,SAA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AAsB,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/stylesheet.ts"],"mappings":""}
|
@@ -9,7 +9,7 @@ var _reactNative = require("react-native");
|
|
9
9
|
var _utils = require("./utils");
|
10
10
|
var _hooks = require("./hooks");
|
11
11
|
var _core = require("./core");
|
12
|
-
const useStyles = (stylesheet,
|
12
|
+
const useStyles = (stylesheet, variantsMap) => {
|
13
13
|
const {
|
14
14
|
theme,
|
15
15
|
layout,
|
@@ -22,20 +22,21 @@ const useStyles = (stylesheet, variant) => {
|
|
22
22
|
styles: {}
|
23
23
|
};
|
24
24
|
}
|
25
|
+
const variants = (0, _hooks.useVariants)(variantsMap);
|
25
26
|
const parsedStyles = (0, _react.useMemo)(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet, layout]);
|
26
27
|
const dynamicStyleSheet = (0, _react.useMemo)(() => Object.entries(parsedStyles).reduce((acc, _ref) => {
|
27
28
|
let [key, value] = _ref;
|
28
29
|
if (typeof value === 'function') {
|
29
30
|
return {
|
30
31
|
...acc,
|
31
|
-
[key]: (0, _utils.proxifyFunction)(key, value, _core.unistyles.registry.plugins, _core.unistyles.runtime,
|
32
|
+
[key]: (0, _utils.proxifyFunction)(key, value, _core.unistyles.registry.plugins, _core.unistyles.runtime, variants)
|
32
33
|
};
|
33
34
|
}
|
34
35
|
return _reactNative.StyleSheet.create({
|
35
36
|
...acc,
|
36
|
-
[key]: (0, _utils.parseStyle)(key, value, _core.unistyles.registry.plugins, _core.unistyles.runtime,
|
37
|
+
[key]: (0, _utils.parseStyle)(key, value, _core.unistyles.registry.plugins, _core.unistyles.runtime, variants)
|
37
38
|
});
|
38
|
-
}, {}), [layout, parsedStyles,
|
39
|
+
}, {}), [layout, parsedStyles, variants, plugins]);
|
39
40
|
return {
|
40
41
|
theme,
|
41
42
|
breakpoint: layout.breakpoint,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_utils","_hooks","_core","useStyles","stylesheet","
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_utils","_hooks","_core","useStyles","stylesheet","variantsMap","theme","layout","plugins","useUnistyles","breakpoint","styles","variants","useVariants","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","proxifyFunction","unistyles","registry","runtime","StyleSheet","create","parseStyle","exports"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AAcO,MAAMK,SAAS,GAAGA,CACrBC,UAAe,EACfC,WAAoD,KAC7B;EACvB,MAAM;IAAEC,KAA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,UAAU,EAAEH,MAAM,CAACG,UAAU;IAC7BC,MAAM,EAAEK;EACZ,CAAC;AACL,CAAC;AAAAe,OAAA,CAAA5B,SAAA,GAAAA,SAAA"}
|
@@ -3,12 +3,6 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
Object.defineProperty(exports, "MQSymbol", {
|
7
|
-
enumerable: true,
|
8
|
-
get: function () {
|
9
|
-
return _mq.MQSymbol;
|
10
|
-
}
|
11
|
-
});
|
12
6
|
Object.defineProperty(exports, "getKeyForUnistylesMediaQuery", {
|
13
7
|
enumerable: true,
|
14
8
|
get: function () {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_mq","require","_mqParser","_breakpoints","_styles"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"
|
1
|
+
{"version":3,"names":["_mq","require","_mqParser","_breakpoints","_styles"],"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"}
|
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 || prop === 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,QAAAE,SAA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,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"}
|
@@ -20,20 +20,26 @@ const isPlatformColor = value => {
|
|
20
20
|
};
|
21
21
|
exports.isPlatformColor = isPlatformColor;
|
22
22
|
const parseStyle = (key, style, plugins, runtime, variant) => {
|
23
|
-
const entries = Object.entries((0, _variants.
|
23
|
+
const entries = Object.entries((0, _variants.getStyleWithVariants)(style || {}, variant));
|
24
24
|
const parsedStyles = Object.fromEntries(entries.map(_ref => {
|
25
25
|
let [key, value] = _ref;
|
26
|
-
|
27
|
-
if (
|
26
|
+
// dynamic functions
|
27
|
+
if (typeof value === 'function') {
|
28
|
+
return [key, value];
|
29
|
+
}
|
30
|
+
|
31
|
+
// nested objects
|
32
|
+
if (key === 'shadowOffset' || key === 'textShadowOffset') {
|
28
33
|
return [key, parseStyle(key, value, plugins, runtime, variant)];
|
29
34
|
}
|
30
|
-
|
31
|
-
|
35
|
+
|
36
|
+
// transforms
|
37
|
+
if (key === 'transform' && Array.isArray(value)) {
|
32
38
|
return [key, value.map(value => parseStyle(key, value, plugins, runtime, variant))];
|
33
39
|
}
|
34
|
-
|
35
|
-
|
36
|
-
if (
|
40
|
+
|
41
|
+
// values or platform colors
|
42
|
+
if (typeof value !== 'object' || isPlatformColor(value)) {
|
37
43
|
return [key, value];
|
38
44
|
}
|
39
45
|
return [key, (0, _breakpoints.getValueForBreakpoint)(value)];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_breakpoints","require","_common","_variants","_plugins","proxifyFunction","key","fn","plugins","runtime","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","entries","Object","
|
1
|
+
{"version":3,"names":["_breakpoints","require","_common","_variants","_plugins","proxifyFunction","key","fn","plugins","runtime","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","entries","Object","getStyleWithVariants","parsedStyles","fromEntries","map","_ref","Array","isArray","getValueForBreakpoint","withPlugins"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEO,MAAMI,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA+B,EAC/BC,OAAyB,EACzBC,OAA0C,KAC/B,IAAIC,KAAK,CAACJ,EAAE,EAAE;EACzBK,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAClCC,UAAU,CAACV,GAAG,EAAEO,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEP,OAAO,EAAEC,OAAO,EAAEC,OAAO;AACvF,CAAC,CAAC;AAAAO,OAAA,CAAAZ,eAAA,GAAAA,eAAA;AAEK,MAAMa,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,CACtBV,GAAW,EACXkB,KAAQ,EACRhB,OAA+B,EAC/BC,OAAyB,EACzBC,OAA0C,KACtC;EACJ,MAAMe,OAAO,GAAGC,MAAM,CACjBD,OAAO,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exports.
|
7
|
-
const
|
8
|
-
|
9
|
-
|
6
|
+
exports.getStyleWithVariants = void 0;
|
7
|
+
const getKeysForVariants = (value, variants) => {
|
8
|
+
// case for no specified variants by user, we should fallback to 'default'
|
9
|
+
if (!variants.length) {
|
10
|
+
return Object.entries(value).map(_ref => {
|
11
|
+
let [key, value] = _ref;
|
12
|
+
if ('default' in value) {
|
13
|
+
return [key, 'default'];
|
14
|
+
}
|
15
|
+
return undefined;
|
16
|
+
}).filter(Boolean);
|
10
17
|
}
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
18
|
+
return variants.map(_ref2 => {
|
19
|
+
let [variantKey, variantValue] = _ref2;
|
20
|
+
const variantStyle = value[variantKey];
|
21
|
+
if (variantStyle && variantValue && variantValue in variantStyle) {
|
22
|
+
return [variantKey, variantValue];
|
23
|
+
}
|
24
|
+
if (variantStyle && 'default' in variantStyle) {
|
25
|
+
return [variantKey, 'default'];
|
26
|
+
}
|
27
|
+
return undefined;
|
28
|
+
}).filter(Boolean);
|
15
29
|
};
|
16
|
-
const
|
30
|
+
const getStyleWithVariants = (style, variantValues) => {
|
17
31
|
if (!('variants' in style)) {
|
18
32
|
return style;
|
19
33
|
}
|
20
|
-
const
|
21
|
-
const
|
34
|
+
const keys = getKeysForVariants(style.variants, Object.entries(variantValues || {}));
|
35
|
+
const variantsValues = keys.map(_ref3 => {
|
36
|
+
let [key, nestedKey] = _ref3;
|
37
|
+
return style.variants[key][nestedKey];
|
38
|
+
}).reduce((acc, styles) => ({
|
39
|
+
...acc,
|
40
|
+
...styles
|
41
|
+
}), {});
|
22
42
|
const {
|
23
43
|
variants,
|
24
44
|
...otherStyles
|
25
45
|
} = style;
|
26
46
|
return {
|
27
47
|
...otherStyles,
|
28
|
-
...
|
48
|
+
...variantsValues
|
29
49
|
};
|
30
50
|
};
|
31
|
-
exports.
|
51
|
+
exports.getStyleWithVariants = getStyleWithVariants;
|
32
52
|
//# sourceMappingURL=variants.js.map
|