react-native-unistyles 2.0.0-alpha.16 → 2.0.0-alpha.18
Sign up to get free protection for your applications and to get access to all the features.
- package/cxx/UnistylesRuntime.h +3 -3
- package/lib/commonjs/common.js +11 -10
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistyleRegistry.js +17 -4
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/core/UnistylesRuntime.js +4 -1
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
- package/lib/commonjs/hooks/useVariants.js +1 -11
- package/lib/commonjs/hooks/useVariants.js.map +1 -1
- package/lib/commonjs/plugins/index.js +0 -7
- package/lib/commonjs/plugins/index.js.map +1 -1
- package/lib/commonjs/useStyles.js +4 -12
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/index.js +7 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mqParser.js.map +1 -1
- package/lib/commonjs/utils/styles.js +26 -18
- 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 +11 -10
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistyleRegistry.js +17 -4
- package/lib/module/core/UnistyleRegistry.js.map +1 -1
- package/lib/module/core/UnistylesRuntime.js +4 -1
- package/lib/module/core/UnistylesRuntime.js.map +1 -1
- package/lib/module/hooks/useVariants.js +1 -11
- package/lib/module/hooks/useVariants.js.map +1 -1
- package/lib/module/plugins/index.js +0 -1
- package/lib/module/plugins/index.js.map +1 -1
- package/lib/module/useStyles.js +5 -13
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/index.js +1 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mqParser.js.map +1 -1
- package/lib/module/utils/styles.js +26 -18
- 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 +11 -10
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistyleRegistry.d.ts +39 -3
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +1 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useVariants.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +48 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/plugins/index.d.ts +0 -1
- package/lib/typescript/src/plugins/index.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +2 -1
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts +2 -3
- 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 +5 -5
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/breakpoints.d.ts +2 -2
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +1 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mqParser.d.ts +2 -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 +1 -1
- package/src/common.ts +11 -10
- package/src/core/UnistyleRegistry.ts +19 -4
- package/src/core/UnistylesRuntime.ts +5 -1
- package/src/hooks/useVariants.ts +1 -14
- package/src/plugins/index.ts +0 -1
- package/src/types/breakpoints.ts +4 -1
- package/src/types/core.ts +2 -3
- package/src/types/index.ts +1 -2
- package/src/types/stylesheet.ts +5 -5
- package/src/useStyles.ts +8 -30
- package/src/utils/breakpoints.ts +3 -3
- package/src/utils/index.ts +1 -0
- package/src/utils/mqParser.ts +2 -2
- package/src/utils/styles.ts +40 -49
- package/src/utils/withPlugins.ts +13 -0
- package/lib/commonjs/plugins/withPlugins.js +0 -14
- package/lib/commonjs/plugins/withPlugins.js.map +0 -1
- package/lib/commonjs/utils/variants.js +0 -52
- package/lib/commonjs/utils/variants.js.map +0 -1
- package/lib/module/plugins/withPlugins.js +0 -7
- package/lib/module/plugins/withPlugins.js.map +0 -1
- package/lib/module/utils/variants.js +0 -45
- package/lib/module/utils/variants.js.map +0 -1
- package/lib/typescript/src/plugins/withPlugins.d.ts +0 -4
- package/lib/typescript/src/plugins/withPlugins.d.ts.map +0 -1
- package/lib/typescript/src/utils/variants.d.ts +0 -3
- package/lib/typescript/src/utils/variants.d.ts.map +0 -1
- package/src/plugins/withPlugins.ts +0 -15
- package/src/utils/variants.ts +0 -61
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 = "You are trying to register
|
16
|
-
const std::string UnistylesErrorBreakpointsMustStartFromZero = "
|
17
|
-
const std::string UnistylesErrorThemesCannotBeEmpty = "You are trying to register
|
15
|
+
const std::string UnistylesErrorBreakpointsCannotBeEmpty = "You are trying to register empty breakpoints object";
|
16
|
+
const std::string UnistylesErrorBreakpointsMustStartFromZero = "You are trying to register breakpoints that don't start from 0";
|
17
|
+
const std::string UnistylesErrorThemesCannotBeEmpty = "You are trying to register empty themes object";
|
18
18
|
|
19
19
|
class JSI_EXPORT UnistylesRuntime : public jsi::HostObject {
|
20
20
|
private:
|
package/lib/commonjs/common.js
CHANGED
@@ -9,10 +9,10 @@ const warn = message => {
|
|
9
9
|
console.warn(`🦄 [react-native-unistyles]: ${message}`);
|
10
10
|
};
|
11
11
|
exports.warn = warn;
|
12
|
-
const isMobile = exports.isMobile = _reactNative.Platform.OS === 'android' || _reactNative.Platform.OS === 'ios';
|
13
12
|
const isWeb = exports.isWeb = _reactNative.Platform.OS === 'web';
|
14
13
|
const isIOS = exports.isIOS = _reactNative.Platform.OS === 'ios';
|
15
14
|
const isAndroid = exports.isAndroid = _reactNative.Platform.OS === 'android';
|
15
|
+
const isMobile = exports.isMobile = isIOS || isAndroid;
|
16
16
|
const isServer = exports.isServer = typeof window === 'undefined';
|
17
17
|
const ScreenOrientation = exports.ScreenOrientation = {
|
18
18
|
Landscape: 'landscape',
|
@@ -25,15 +25,16 @@ let UnistylesEventType = exports.UnistylesEventType = /*#__PURE__*/function (Uni
|
|
25
25
|
return UnistylesEventType;
|
26
26
|
}({});
|
27
27
|
let UnistylesError = exports.UnistylesError = /*#__PURE__*/function (UnistylesError) {
|
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
|
31
|
-
UnistylesError["
|
32
|
-
UnistylesError["
|
33
|
-
UnistylesError["
|
34
|
-
UnistylesError["
|
35
|
-
UnistylesError["
|
36
|
-
UnistylesError["
|
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 with UnistylesRegistry";
|
30
|
+
UnistylesError["ThemeNotRegistered"] = "You are trying to set a theme that was not registered with UnistylesRegistry";
|
31
|
+
UnistylesError["ThemeNotSelected"] = "Your themes are registered, but you didn't select the initial theme";
|
32
|
+
UnistylesError["ThemesCannotBeEmpty"] = "You are trying to register empty themes object";
|
33
|
+
UnistylesError["BreakpointsCannotBeEmpty"] = "You are trying to register empty breakpoints object";
|
34
|
+
UnistylesError["BreakpointsMustStartFromZero"] = "You are trying to register breakpoints that don't start from 0";
|
35
|
+
UnistylesError["InvalidPluginName"] = "Plugin name can't start from reserved prefix __unistyles";
|
36
|
+
UnistylesError["DuplicatePluginName"] = "You are trying to register a plugin with a name that is already registered";
|
37
|
+
UnistylesError["CantRemoveInternalPlugin"] = "You are trying to remove an internal unistyles plugin";
|
37
38
|
return UnistylesError;
|
38
39
|
}({});
|
39
40
|
//# sourceMappingURL=common.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","warn","message","console","exports","
|
1
|
+
{"version":3,"names":["_reactNative","require","warn","message","console","exports","isWeb","Platform","OS","isIOS","isAndroid","isMobile","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,KAAK,GAAAD,OAAA,CAAAC,KAAA,GAAGC,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAMC,KAAK,GAAAJ,OAAA,CAAAI,KAAA,GAAGF,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAME,SAAS,GAAAL,OAAA,CAAAK,SAAA,GAAGH,qBAAQ,CAACC,EAAE,KAAK,SAAS;AAC3C,MAAMG,QAAQ,GAAAN,OAAA,CAAAM,QAAA,GAAGF,KAAK,IAAIC,SAAS;AACnC,MAAME,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;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
|
@@ -21,13 +21,19 @@ class UnistyleRegistry {
|
|
21
21
|
const keys = Object.keys(themes);
|
22
22
|
this.unistylesBridge.themes = keys;
|
23
23
|
this.themeNames = keys;
|
24
|
-
return
|
24
|
+
return {
|
25
|
+
addBreakpoints: this.addBreakpoints,
|
26
|
+
addConfig: this.addConfig
|
27
|
+
};
|
25
28
|
};
|
26
29
|
addBreakpoints = breakpoints => {
|
27
30
|
this.breakpoints = breakpoints;
|
28
31
|
this.unistylesBridge.useBreakpoints(breakpoints);
|
29
32
|
this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
|
30
|
-
return
|
33
|
+
return {
|
34
|
+
addThemes: this.addThemes,
|
35
|
+
addConfig: this.addConfig
|
36
|
+
};
|
31
37
|
};
|
32
38
|
addConfig = config => {
|
33
39
|
this.config = config;
|
@@ -40,15 +46,22 @@ class UnistyleRegistry {
|
|
40
46
|
if (config.initialTheme) {
|
41
47
|
this.unistylesBridge.useTheme(config.initialTheme);
|
42
48
|
}
|
49
|
+
return {
|
50
|
+
addBreakpoints: this.addBreakpoints,
|
51
|
+
addThemes: this.addThemes
|
52
|
+
};
|
43
53
|
};
|
44
54
|
getTheme = forName => {
|
45
55
|
if (this.themeNames.length === 0) {
|
46
56
|
return {};
|
47
57
|
}
|
48
|
-
if (
|
58
|
+
if (this.hasTheme(forName)) {
|
59
|
+
return this.themes[forName];
|
60
|
+
}
|
61
|
+
if (this.unistylesBridge.themeName) {
|
49
62
|
throw new Error(_common.UnistylesError.ThemeNotFound);
|
50
63
|
}
|
51
|
-
|
64
|
+
throw new Error(_common.UnistylesError.ThemeNotSelected);
|
52
65
|
};
|
53
66
|
addPlugin = (() => {
|
54
67
|
var _this = this;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_common","require","_plugins","UnistyleRegistry","config","plugins","isWeb","normalizeWebStylesPlugin","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","
|
1
|
+
{"version":3,"names":["_common","require","_plugins","UnistyleRegistry","config","plugins","isWeb","normalizeWebStylesPlugin","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","experimentalPlugins","forEach","plugin","addPlugin","initialTheme","useTheme","getTheme","forName","length","hasTheme","themeName","Error","UnistylesError","ThemeNotFound","ThemeNotSelected","_this","notify","arguments","undefined","name","startsWith","InvalidPluginName","some","_ref","DuplicatePluginName","concat","removePlugin","CantRemoveInternalPlugin","filter","_ref2","exports"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEO,MAAME,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,OAAO,GAA2BC,aAAK,GACxC,CAACC,iCAAwB,CAAC,GAC1B,EAAE;EACDC,UAAU,GAAiC,EAAE;EAC7CC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAy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,CAAC;EAAA;EAEMU,YAAY,GAAIxB,MAAuB,IAAK;IAC/C,IAAIA,MAAM,CAACiB,IAAI,CAACC,UAAU,CAAC,aAAa,CAAC,EAAE;MACvC,MAAM,IAAIT,KAAK,CAACC,sBAAc,CAACe,wBAAwB,CAAC;IAC5D;IAEA,IAAI,CAAC5C,OAAO,GAAG,IAAI,CAACA,OAAO,CAAC6C,MAAM,CAACC,KAAA;MAAA,IAAC;QAAEV;MAAK,CAAC,GAAAU,KAAA;MAAA,OAAKV,IAAI,KAAKjB,MAAM,CAACiB,IAAI;IAAA,EAAC;IACtE,IAAI,CAAC5B,eAAe,CAACmC,YAAY,CAACxB,MAAM,CAACiB,IAAI,CAAC;EAClD,CAAC;EAEMV,QAAQ,GAAIU,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAChC,MAAM;AAC1E;AAAC2C,OAAA,CAAAjD,gBAAA,GAAAA,gBAAA"}
|
@@ -42,7 +42,10 @@ class UnistylesRuntime {
|
|
42
42
|
return _common.ScreenOrientation.Portrait;
|
43
43
|
}
|
44
44
|
setTheme = name => {
|
45
|
-
if (name
|
45
|
+
if (name === this.themeName) {
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
if (this.unistylesRegistry.hasTheme(name)) {
|
46
49
|
this.unistylesBridge.useTheme(name);
|
47
50
|
return true;
|
48
51
|
}
|
@@ -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,IAAIA,IAAI,KAAK,IAAI,CAACb,SAAS,IAAI,IAAI,CAACH,iBAAiB,CAACiB,QAAQ,CAACD,IAAI,CAAC,EAAE;
|
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,IAAIA,IAAI,KAAK,IAAI,CAACb,SAAS,EAAE;MACzB;IACJ;IAEA,IAAI,IAAI,CAACH,iBAAiB,CAACiB,QAAQ,CAACD,IAAI,CAAC,EAAE;MACvC,IAAI,CAACjB,eAAe,CAACmB,QAAQ,CAACF,IAAI,CAAC;MAEnC,OAAO,IAAI;IACf;IAEA,MAAM,IAAIG,KAAK,CAACC,sBAAc,CAACC,kBAAkB,CAAC;EACtD,CAAC;EAEMC,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAACxB,eAAe,CAACyB,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;EAEME,SAAS,GAAIC,MAAuB,IAAK;IAC5C,IAAI,CAAC1B,iBAAiB,CAACyB,SAAS,CAACC,MAAM,CAAC;EAC5C,CAAC;EAEMC,YAAY,GAAID,MAAuB,IAAK;IAC/C,IAAI,CAAC1B,iBAAiB,CAAC2B,YAAY,CAACD,MAAM,CAAC;EAC/C,CAAC;AACL;AAACE,OAAA,CAAA/B,gBAAA,GAAAA,gBAAA"}
|
@@ -5,19 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.useVariants = void 0;
|
7
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
8
|
const useVariants = variantsMap => {
|
17
9
|
const variantsRef = (0, _react.useRef)(variantsMap);
|
18
|
-
|
19
|
-
variantsRef.current = variantsMap;
|
20
|
-
}
|
10
|
+
variantsRef.current = variantsMap;
|
21
11
|
return variantsRef.current;
|
22
12
|
};
|
23
13
|
exports.useVariants = useVariants;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","require","
|
1
|
+
{"version":3,"names":["_react","require","useVariants","variantsMap","variantsRef","useRef","current","exports"],"sourceRoot":"../../../src","sources":["hooks/useVariants.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,WAAW,GAAIC,WAA8C,IAAK;EAC3E,MAAMC,WAAW,GAAG,IAAAC,aAAM,EAA6CF,WAAW,CAAC;EAEnFC,WAAW,CAACE,OAAO,GAAGH,WAAW;EAEjC,OAAOC,WAAW,CAACE,OAAO;AAC9B,CAAC;AAAAC,OAAA,CAAAL,WAAA,GAAAA,WAAA"}
|
@@ -33,13 +33,6 @@ Object.defineProperty(exports, "preprocessor", {
|
|
33
33
|
return _normalizer.preprocessor;
|
34
34
|
}
|
35
35
|
});
|
36
|
-
Object.defineProperty(exports, "withPlugins", {
|
37
|
-
enumerable: true,
|
38
|
-
get: function () {
|
39
|
-
return _withPlugins.withPlugins;
|
40
|
-
}
|
41
|
-
});
|
42
36
|
var _normalizeWebStylesPlugin = require("./normalizeWebStylesPlugin");
|
43
37
|
var _normalizer = require("./normalizer");
|
44
|
-
var _withPlugins = require("./withPlugins");
|
45
38
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_normalizeWebStylesPlugin","require","_normalizer"
|
1
|
+
{"version":3,"names":["_normalizeWebStylesPlugin","require","_normalizer"],"sourceRoot":"../../../src","sources":["plugins/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,yBAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA"}
|
@@ -8,35 +8,27 @@ var _react = require("react");
|
|
8
8
|
var _reactNative = require("react-native");
|
9
9
|
var _utils = require("./utils");
|
10
10
|
var _hooks = require("./hooks");
|
11
|
-
var _core = require("./core");
|
12
11
|
const useStyles = (stylesheet, variantsMap) => {
|
13
12
|
const {
|
14
13
|
theme,
|
15
14
|
layout,
|
16
15
|
plugins
|
17
16
|
} = (0, _hooks.useUnistyles)();
|
18
|
-
if (!stylesheet) {
|
19
|
-
return {
|
20
|
-
theme,
|
21
|
-
breakpoint: layout.breakpoint,
|
22
|
-
styles: {}
|
23
|
-
};
|
24
|
-
}
|
25
17
|
const variants = (0, _hooks.useVariants)(variantsMap);
|
26
18
|
const parsedStyles = (0, _react.useMemo)(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet, layout]);
|
27
|
-
const dynamicStyleSheet = (0, _react.useMemo)(() => Object.entries(parsedStyles).reduce((acc, _ref) => {
|
19
|
+
const dynamicStyleSheet = (0, _react.useMemo)(() => Object.entries(parsedStyles || {}).reduce((acc, _ref) => {
|
28
20
|
let [key, value] = _ref;
|
29
21
|
if (typeof value === 'function') {
|
30
22
|
return {
|
31
23
|
...acc,
|
32
|
-
[key]: (0, _utils.proxifyFunction)(key, value
|
24
|
+
[key]: (0, _utils.proxifyFunction)(key, value)
|
33
25
|
};
|
34
26
|
}
|
35
27
|
return _reactNative.StyleSheet.create({
|
36
28
|
...acc,
|
37
|
-
[key]: (0, _utils.
|
29
|
+
[key]: (0, _utils.withPlugins)(key, (0, _utils.parseStyle)(value, variants))
|
38
30
|
});
|
39
|
-
}, {}), [
|
31
|
+
}, {}), [parsedStyles, variants, plugins]);
|
40
32
|
return {
|
41
33
|
theme,
|
42
34
|
breakpoint: layout.breakpoint,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_utils","_hooks","
|
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,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":["_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,
|
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"}
|
@@ -51,8 +51,15 @@ Object.defineProperty(exports, "proxifyFunction", {
|
|
51
51
|
return _styles.proxifyFunction;
|
52
52
|
}
|
53
53
|
});
|
54
|
+
Object.defineProperty(exports, "withPlugins", {
|
55
|
+
enumerable: true,
|
56
|
+
get: function () {
|
57
|
+
return _withPlugins.withPlugins;
|
58
|
+
}
|
59
|
+
});
|
54
60
|
var _mq = require("./mq");
|
55
61
|
var _mqParser = require("./mqParser");
|
56
62
|
var _breakpoints = require("./breakpoints");
|
57
63
|
var _styles = require("./styles");
|
64
|
+
var _withPlugins = require("./withPlugins");
|
58
65
|
//# sourceMappingURL=index.js.map
|
@@ -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","_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"}
|
@@ -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","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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E;IACjB,OAAOc,gBAAgB,CAAClB,KAAK,EAAEiB,UAAU,CAACjB,KAAK,CAAC,IAAImB,iBAAiB,CAACf,MAAM,EAAEa,UAAU,CAACb,MAAM,CAAC;EACpG;EAEA,IAAIJ,KAAK,EAAE;IACP,OAAOkB,gBAAgB,CAAClB,KAAK,EAAEiB,UAAU,CAACjB,KAAK,CAAC;EACpD;EAEA,IAAII,MAAM,EAAE;IACR,OAAOe,iBAAiB,CAACf,MAAM,EAAEa,UAAU,CAACb,MAAM,CAAC;EACvD;EAEA,OAAO,KAAK;AAChB,CAAC;AAAAO,OAAA,CAAAK,yBAAA,GAAAA,yBAAA;AAED,MAAME,gBAAgB,GAAGA,CAAClB,KAAiC,EAAEoB,WAAmB,KAAc;EAC1F,MAAM;IAAEb,IAAI;IAAEE;EAAG,CAAC,GAAGT,KAA0B;EAE/C,OAAOoB,WAAW,IAAIb,IAAI,IAAIa,WAAW,IAAIX,EAAE;AACnD,CAAC;AAED,MAAMU,iBAAiB,GAAGA,CAACf,MAAmC,EAAEiB,YAAoB,KAAc;EAC9F,MAAM;IAAEd,IAAI;IAAEE;EAAG,CAAC,GAAGL,MAA2B;EAEhD,OAAOiB,YAAY,IAAId,IAAI,IAAIc,YAAY,IAAIZ,EAAE;AACrD,CAAC;AAEM,MAAMa,4BAA4B,GAAGA,CAACC,
|
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,M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B,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,OAAOlB,EAAE,EAAE4B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC;AAAAhB,OAAA,CAAAW,4BAAA,GAAAA,4BAAA"}
|
@@ -6,10 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.proxifyFunction = exports.parseStyle = exports.isPlatformColor = void 0;
|
7
7
|
var _breakpoints = require("./breakpoints");
|
8
8
|
var _common = require("../common");
|
9
|
-
var
|
10
|
-
|
11
|
-
|
12
|
-
apply: (target, thisArg, argumentsList) => parseStyle(key, target.apply(thisArg, argumentsList), plugins, runtime, variant)
|
9
|
+
var _withPlugins = require("./withPlugins");
|
10
|
+
const proxifyFunction = (key, fn, variant) => new Proxy(fn, {
|
11
|
+
apply: (target, thisArg, argumentsList) => (0, _withPlugins.withPlugins)(key, parseStyle(target.apply(thisArg, argumentsList), variant))
|
13
12
|
});
|
14
13
|
exports.proxifyFunction = proxifyFunction;
|
15
14
|
const isPlatformColor = value => {
|
@@ -19,32 +18,41 @@ const isPlatformColor = value => {
|
|
19
18
|
return _common.isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
|
20
19
|
};
|
21
20
|
exports.isPlatformColor = isPlatformColor;
|
22
|
-
const parseStyle = (
|
23
|
-
|
24
|
-
|
21
|
+
const parseStyle = function (style) {
|
22
|
+
let variant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
23
|
+
return Object.entries(style || {}).reduce((acc, _ref) => {
|
25
24
|
let [key, value] = _ref;
|
26
|
-
// dynamic functions
|
27
|
-
if (typeof value === 'function') {
|
28
|
-
return [key, value];
|
29
|
-
}
|
30
|
-
|
31
25
|
// nested objects
|
32
26
|
if (key === 'shadowOffset' || key === 'textShadowOffset') {
|
33
|
-
|
27
|
+
acc[key] = parseStyle(value, variant);
|
28
|
+
return acc;
|
34
29
|
}
|
35
30
|
|
36
31
|
// transforms
|
37
32
|
if (key === 'transform' && Array.isArray(value)) {
|
38
|
-
|
33
|
+
acc[key] = value.map(value => parseStyle(value, variant));
|
34
|
+
return acc;
|
39
35
|
}
|
40
36
|
|
41
37
|
// values or platform colors
|
42
38
|
if (typeof value !== 'object' || isPlatformColor(value)) {
|
43
|
-
|
39
|
+
acc[key] = value;
|
40
|
+
return acc;
|
41
|
+
}
|
42
|
+
if (key === 'variants') {
|
43
|
+
return {
|
44
|
+
...acc,
|
45
|
+
...Object.keys(value).reduce((acc, key) => ({
|
46
|
+
...acc,
|
47
|
+
...parseStyle(value[key][variant[key] || 'default'] ?? {})
|
48
|
+
}), {})
|
49
|
+
};
|
44
50
|
}
|
45
|
-
return
|
46
|
-
|
47
|
-
|
51
|
+
return {
|
52
|
+
...acc,
|
53
|
+
[key]: (0, _breakpoints.getValueForBreakpoint)(value)
|
54
|
+
};
|
55
|
+
}, {});
|
48
56
|
};
|
49
57
|
exports.parseStyle = parseStyle;
|
50
58
|
//# sourceMappingURL=styles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_breakpoints","require","_common","
|
1
|
+
{"version":3,"names":["_breakpoints","require","_common","_withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","withPlugins","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","arguments","length","undefined","Object","entries","reduce","acc","_ref","Array","isArray","map","keys","getValueForBreakpoint"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEO,MAAMG,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAAE,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AAEV,OAAO,CAAC,CAAC;MAEzD,OAAOsB,GAAG;IACd;;IAEA;IACA,IAAI,OAAOZ,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC,EAAE;MACrDY,GAAG,CAACxB,GAAG,CAAY,GAAGY,KAAK;MAE3B,OAAOY,GAAG;IACd;IAEA,IAAIxB,GAAG,KAAK,UAAU,EAAE;MACpB,OAAO;QACH,GAAGwB,GAAG;QACN,GAAIH,MAAM,CACLQ,IAAI,CAACjB,KAAK,CAAC,CACXW,MAAM,CAAC,CAACC,GAAG,EAAExB,GAAG,MAAM;UACnB,GAAGwB,GAAG;UACN,GAAGf,UAAU,CAAEG,KAAK,CAAEZ,GAAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QACvF,CAAC,CAAC,EAAE,CAAC,CAAC;MACd,CAAC;IACL;IAEA,OAAO;MACH,GAAGwB,GAAG;MACN,CAACxB,GAAG,GAAG,IAAA8B,kCAAqB,EAAClB,KAAgC;IACjE,CAAC;EACL,CAAC,EAAE,CAAC,CAAM,CAAC;AAAA;AAAAF,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.withPlugins = void 0;
|
7
|
+
var _core = require("../core");
|
8
|
+
const withPlugins = (key, style) => _core.unistyles.registry.plugins.reduce((acc, plugin) => {
|
9
|
+
if (plugin.onParsedStyle) {
|
10
|
+
return plugin.onParsedStyle(key, style, _core.unistyles.runtime);
|
11
|
+
}
|
12
|
+
return acc;
|
13
|
+
}, style);
|
14
|
+
exports.withPlugins = withPlugins;
|
15
|
+
//# sourceMappingURL=withPlugins.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_core","require","withPlugins","key","style","unistyles","registry","plugins","reduce","acc","plugin","onParsedStyle","runtime","exports"],"sourceRoot":"../../../src","sources":["utils/withPlugins.ts"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AAEO,MAAMC,WAAW,GAAGA,CACvBC,GAAW,EACXC,KAAc,KACbC,eAAS,CAACC,QAAQ,CAACC,OAAO,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,MAAM,KAAK;EACpD,IAAIA,MAAM,CAACC,aAAa,EAAE;IACtB,OAAOD,MAAM,CAACC,aAAa,CAACR,GAAG,EAAEC,KAAK,EAAEC,eAAS,CAACO,OAAO,CAAC;EAC9D;EAEA,OAAOH,GAAG;AACd,CAAC,EAAEL,KAAK,CAAC;AAAAS,OAAA,CAAAX,WAAA,GAAAA,WAAA"}
|
package/lib/module/common.js
CHANGED
@@ -2,10 +2,10 @@ import { Platform } from 'react-native';
|
|
2
2
|
export const warn = message => {
|
3
3
|
console.warn(`🦄 [react-native-unistyles]: ${message}`);
|
4
4
|
};
|
5
|
-
export const isMobile = Platform.OS === 'android' || Platform.OS === 'ios';
|
6
5
|
export const isWeb = Platform.OS === 'web';
|
7
6
|
export const isIOS = Platform.OS === 'ios';
|
8
7
|
export const isAndroid = Platform.OS === 'android';
|
8
|
+
export const isMobile = isIOS || isAndroid;
|
9
9
|
export const isServer = typeof window === 'undefined';
|
10
10
|
export const ScreenOrientation = {
|
11
11
|
Landscape: 'landscape',
|
@@ -18,15 +18,16 @@ export let UnistylesEventType = /*#__PURE__*/function (UnistylesEventType) {
|
|
18
18
|
return UnistylesEventType;
|
19
19
|
}({});
|
20
20
|
export let UnistylesError = /*#__PURE__*/function (UnistylesError) {
|
21
|
-
UnistylesError["RuntimeUnavailable"] = "Unistyles runtime is not available. Make sure you followed the installation instructions
|
22
|
-
UnistylesError["ThemeNotFound"] = "You are trying to get a theme that is not registered
|
23
|
-
UnistylesError["ThemeNotRegistered"] = "You are trying to set a theme that
|
24
|
-
UnistylesError["
|
25
|
-
UnistylesError["
|
26
|
-
UnistylesError["
|
27
|
-
UnistylesError["
|
28
|
-
UnistylesError["
|
29
|
-
UnistylesError["
|
21
|
+
UnistylesError["RuntimeUnavailable"] = "Unistyles runtime is not available. Make sure you followed the installation instructions";
|
22
|
+
UnistylesError["ThemeNotFound"] = "You are trying to get a theme that is not registered with UnistylesRegistry";
|
23
|
+
UnistylesError["ThemeNotRegistered"] = "You are trying to set a theme that was not registered with UnistylesRegistry";
|
24
|
+
UnistylesError["ThemeNotSelected"] = "Your themes are registered, but you didn't select the initial theme";
|
25
|
+
UnistylesError["ThemesCannotBeEmpty"] = "You are trying to register empty themes object";
|
26
|
+
UnistylesError["BreakpointsCannotBeEmpty"] = "You are trying to register empty breakpoints object";
|
27
|
+
UnistylesError["BreakpointsMustStartFromZero"] = "You are trying to register breakpoints that don't start from 0";
|
28
|
+
UnistylesError["InvalidPluginName"] = "Plugin name can't start from reserved prefix __unistyles";
|
29
|
+
UnistylesError["DuplicatePluginName"] = "You are trying to register a plugin with a name that is already registered";
|
30
|
+
UnistylesError["CantRemoveInternalPlugin"] = "You are trying to remove an internal unistyles plugin";
|
30
31
|
return UnistylesError;
|
31
32
|
}({});
|
32
33
|
//# sourceMappingURL=common.js.map
|
package/lib/module/common.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Platform","warn","message","console","
|
1
|
+
{"version":3,"names":["Platform","warn","message","console","isWeb","OS","isIOS","isAndroid","isMobile","isServer","window","ScreenOrientation","Landscape","Portrait","UnistylesEventType","UnistylesError"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,IAAI,GAAIC,OAAe,IAAK;EACrCC,OAAO,CAACF,IAAI,CAAE,gCAA+BC,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAME,KAAK,GAAGJ,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMC,KAAK,GAAGN,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,SAAS,GAAGP,QAAQ,CAACK,EAAE,KAAK,SAAS;AAClD,OAAO,MAAMG,QAAQ,GAAGF,KAAK,IAAIC,SAAS;AAC1C,OAAO,MAAME,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW;AAErD,OAAO,MAAMC,iBAAiB,GAAG;EAC7BC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU;AAEV,WAAYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAM9B,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
|
@@ -15,13 +15,19 @@ export class UnistyleRegistry {
|
|
15
15
|
const keys = Object.keys(themes);
|
16
16
|
this.unistylesBridge.themes = keys;
|
17
17
|
this.themeNames = keys;
|
18
|
-
return
|
18
|
+
return {
|
19
|
+
addBreakpoints: this.addBreakpoints,
|
20
|
+
addConfig: this.addConfig
|
21
|
+
};
|
19
22
|
};
|
20
23
|
addBreakpoints = breakpoints => {
|
21
24
|
this.breakpoints = breakpoints;
|
22
25
|
this.unistylesBridge.useBreakpoints(breakpoints);
|
23
26
|
this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
|
24
|
-
return
|
27
|
+
return {
|
28
|
+
addThemes: this.addThemes,
|
29
|
+
addConfig: this.addConfig
|
30
|
+
};
|
25
31
|
};
|
26
32
|
addConfig = config => {
|
27
33
|
this.config = config;
|
@@ -34,15 +40,22 @@ export class UnistyleRegistry {
|
|
34
40
|
if (config.initialTheme) {
|
35
41
|
this.unistylesBridge.useTheme(config.initialTheme);
|
36
42
|
}
|
43
|
+
return {
|
44
|
+
addBreakpoints: this.addBreakpoints,
|
45
|
+
addThemes: this.addThemes
|
46
|
+
};
|
37
47
|
};
|
38
48
|
getTheme = forName => {
|
39
49
|
if (this.themeNames.length === 0) {
|
40
50
|
return {};
|
41
51
|
}
|
42
|
-
if (
|
52
|
+
if (this.hasTheme(forName)) {
|
53
|
+
return this.themes[forName];
|
54
|
+
}
|
55
|
+
if (this.unistylesBridge.themeName) {
|
43
56
|
throw new Error(UnistylesError.ThemeNotFound);
|
44
57
|
}
|
45
|
-
|
58
|
+
throw new Error(UnistylesError.ThemeNotSelected);
|
46
59
|
};
|
47
60
|
addPlugin = (() => {
|
48
61
|
var _this = this;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["isWeb","UnistylesError","normalizeWebStylesPlugin","UnistyleRegistry","config","plugins","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","
|
1
|
+
{"version":3,"names":["isWeb","UnistylesError","normalizeWebStylesPlugin","UnistyleRegistry","config","plugins","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","experimentalPlugins","forEach","plugin","addPlugin","initialTheme","useTheme","getTheme","forName","length","hasTheme","themeName","Error","ThemeNotFound","ThemeNotSelected","_this","notify","arguments","undefined","name","startsWith","InvalidPluginName","some","_ref","DuplicatePluginName","concat","removePlugin","CantRemoveInternalPlugin","filter","_ref2"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":"AAEA,SAASA,KAAK,EAAEC,cAAc,QAAQ,WAAW;AACjD,SAASC,wBAAwB,QAAQ,YAAY;AAErD,OAAO,MAAMC,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,OAAO,GAA2BL,KAAK,GACxC,CAACE,wBAAwB,CAAC,GAC1B,EAAE;EACDI,UAAU,GAAiC,EAAE;EA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,CAACY,SAAS,CAACD,MAAM,CAACgB,IAAI,EAAEH,MAAM,CAAC;IACvD,CAAC;EAAA;EAEMU,YAAY,GAAIvB,MAAuB,IAAK;IAC/C,IAAIA,MAAM,CAACgB,IAAI,CAACC,UAAU,CAAC,aAAa,CAAC,EAAE;MACvC,MAAM,IAAIR,KAAK,CAAC9B,cAAc,CAAC6C,wBAAwB,CAAC;IAC5D;IAEA,IAAI,CAACzC,OAAO,GAAG,IAAI,CAACA,OAAO,CAAC0C,MAAM,CAACC,KAAA;MAAA,IAAC;QAAEV;MAAK,CAAC,GAAAU,KAAA;MAAA,OAAKV,IAAI,KAAKhB,MAAM,CAACgB,IAAI;IAAA,EAAC;IACtE,IAAI,CAAC3B,eAAe,CAACkC,YAAY,CAACvB,MAAM,CAACgB,IAAI,CAAC;EAClD,CAAC;EAEMT,QAAQ,GAAIS,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAC/B,MAAM;AAC1E"}
|
@@ -36,7 +36,10 @@ export class UnistylesRuntime {
|
|
36
36
|
return ScreenOrientation.Portrait;
|
37
37
|
}
|
38
38
|
setTheme = name => {
|
39
|
-
if (name
|
39
|
+
if (name === this.themeName) {
|
40
|
+
return;
|
41
|
+
}
|
42
|
+
if (this.unistylesRegistry.hasTheme(name)) {
|
40
43
|
this.unistylesBridge.useTheme(name);
|
41
44
|
return true;
|
42
45
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","breakpoint","enabledPlugins","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,WAAW;AAK7D,OAAO,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,OAAOd,iBAAiB,CAACiB,SAAS;IACtC;IAEA,OAAOjB,iBAAiB,CAACkB,QAAQ;EACrC;EAEOC,QAAQ,GAAIC,IAA2B,IAAK;IAC/C,IAAIA,IAAI,KAAK,IAAI,CAACZ,SAAS,IAAI,IAAI,CAACH,iBAAiB,CAACgB,QAAQ,CAACD,IAAI,CAAC,EAAE;
|
1
|
+
{"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","breakpoint","enabledPlugins","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,WAAW;AAK7D,OAAO,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,OAAOd,iBAAiB,CAACiB,SAAS;IACtC;IAEA,OAAOjB,iBAAiB,CAACkB,QAAQ;EACrC;EAEOC,QAAQ,GAAIC,IAA2B,IAAK;IAC/C,IAAIA,IAAI,KAAK,IAAI,CAACZ,SAAS,EAAE;MACzB;IACJ;IAEA,IAAI,IAAI,CAACH,iBAAiB,CAACgB,QAAQ,CAACD,IAAI,CAAC,EAAE;MACvC,IAAI,CAAChB,eAAe,CAACkB,QAAQ,CAACF,IAAI,CAAC;MAEnC,OAAO,IAAI;IACf;IAEA,MAAM,IAAIG,KAAK,CAACtB,cAAc,CAACuB,kBAAkB,CAAC;EACtD,CAAC;EAEMC,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAACtB,eAAe,CAACuB,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;EAEME,SAAS,GAAIC,MAAuB,IAAK;IAC5C,IAAI,CAACxB,iBAAiB,CAACuB,SAAS,CAACC,MAAM,CAAC;EAC5C,CAAC;EAEMC,YAAY,GAAID,MAAuB,IAAK;IAC/C,IAAI,CAACxB,iBAAiB,CAACyB,YAAY,CAACD,MAAM,CAAC;EAC/C,CAAC;AACL"}
|
@@ -1,17 +1,7 @@
|
|
1
1
|
import { useRef } from 'react';
|
2
|
-
const compareVariants = (prevVariants, nextVariants) => {
|
3
|
-
const keysA = Object.keys(prevVariants ?? {});
|
4
|
-
const keysB = Object.keys(nextVariants ?? {});
|
5
|
-
if (keysA.length !== keysB.length) {
|
6
|
-
return false;
|
7
|
-
}
|
8
|
-
return keysA.every(key => prevVariants[key] === (nextVariants ?? {})[key]);
|
9
|
-
};
|
10
2
|
export const useVariants = variantsMap => {
|
11
3
|
const variantsRef = useRef(variantsMap);
|
12
|
-
|
13
|
-
variantsRef.current = variantsMap;
|
14
|
-
}
|
4
|
+
variantsRef.current = variantsMap;
|
15
5
|
return variantsRef.current;
|
16
6
|
};
|
17
7
|
//# sourceMappingURL=useVariants.js.map
|