react-native-unistyles 2.0.0-alpha.16 → 2.0.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/common.js +10 -9
- 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/useStyles.js +1 -8
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/module/common.js +10 -9
- 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/useStyles.js +1 -8
- package/lib/module/useStyles.js.map +1 -1
- package/lib/typescript/src/common.d.ts +10 -9
- 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/index.d.ts +48 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common.ts +10 -9
- package/src/core/UnistyleRegistry.ts +19 -4
- package/src/useStyles.ts +4 -14
package/lib/commonjs/common.js
CHANGED
@@ -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","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"}
|
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;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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KJ,IAAI,KAAKjB,MAAM,CAACiB,IAAI;MAAA,EAAC,EAAE;QACvD,MAAM,IAAIR,KAAK,CAACC,sBAAc,CAACY,mBAAmB,CAAC;MACvD;MAEAT,KAAI,CAAChC,OAAO,GAAG,CAACmB,MAAM,CAAC,CAACuB,MAAM,CAACV,KAAI,CAAChC,OAAO,CAAC;MAC5CgC,KAAI,CAACxB,eAAe,CAACY,SAAS,CAACD,MAAM,CAACiB,IAAI,EAAEH,MAAM,CAAC;IACvD,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"}
|
@@ -15,16 +15,9 @@ const useStyles = (stylesheet, variantsMap) => {
|
|
15
15
|
layout,
|
16
16
|
plugins
|
17
17
|
} = (0, _hooks.useUnistyles)();
|
18
|
-
if (!stylesheet) {
|
19
|
-
return {
|
20
|
-
theme,
|
21
|
-
breakpoint: layout.breakpoint,
|
22
|
-
styles: {}
|
23
|
-
};
|
24
|
-
}
|
25
18
|
const variants = (0, _hooks.useVariants)(variantsMap);
|
26
19
|
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) => {
|
20
|
+
const dynamicStyleSheet = (0, _react.useMemo)(() => Object.entries(parsedStyles || {}).reduce((acc, _ref) => {
|
28
21
|
let [key, value] = _ref;
|
29
22
|
if (typeof value === 'function') {
|
30
23
|
return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_utils","_hooks","_core","useStyles","stylesheet","variantsMap","theme","layout","plugins","useUnistyles","
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_utils","_hooks","_core","useStyles","stylesheet","variantsMap","theme","layout","plugins","useUnistyles","variants","useVariants","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","proxifyFunction","unistyles","registry","runtime","StyleSheet","create","parseStyle","breakpoint","styles","exports"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AAcO,MAAMK,SAAS,GAAGA,CACrBC,UAAe,EACfC,WAAoD,KAC7B;EACvB,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAG,IAAAC,mBAAY,EAAC,CAAC;EACjD,MAAMC,QAAQ,GAAG,IAAAC,kBAAW,EAACN,WAAW,CAAC;EACzC,MAAMO,YAAY,GAAG,IAAAC,cAAO,EAAC,MAAM,OAAOT,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACE,KAAK,CAAC,GACjBF,UAAU,EAAE,CAACE,KAAK,EAAEF,UAAU,EAAEG,MAAM,CAAC,CAAC;EAE9C,MAAMO,iBAAiB,GAAG,IAAAD,cAAO,EAAC,MAAME,MAAM,CACzCC,OAAO,CAACJ,YAAY,IAAI,CAAC,CAAC,CAAC,CAC3BK,MAAM,CAAC,CAACC,GAAG,EAAAC,IAAA,KAAmB;IAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;IACtB,IAAI,OAAOE,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGH,GAAG;QACN,CAACE,GAAG,GAAG,IAAAE,sBAAe,EAACF,GAAG,EAAEC,KAAK,EAACE,eAAS,CAACC,QAAQ,CAAChB,OAAO,EAAEe,eAAS,CAACE,OAAO,EAAEf,QAAQ;MAC7F,CAAC;IACL;IAEA,OAAOgB,uBAAU,CAACC,MAAM,CAAC;MACrB,GAAGT,GAAG;MACN,CAACE,GAAG,GAAG,IAAAQ,iBAAU,EACbR,GAAG,EACHC,KAAK,EACLE,eAAS,CAACC,QAAQ,CAAChB,OAAO,EAC1Be,eAAS,CAACE,OAAO,EACjBf,QACJ;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAACH,MAAM,EAAEK,YAAY,EAAEF,QAAQ,EAAEF,OAAO,CACpD,CAAC;EAED,OAAO;IACHF,KAAK;IACLuB,UAAU,EAAEtB,MAAM,CAACsB,UAAU;IAC7BC,MAAM,EAAEhB;EACZ,CAAC;AACL,CAAC;AAAAiB,OAAA,CAAA5B,SAAA,GAAAA,SAAA"}
|
package/lib/module/common.js
CHANGED
@@ -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","isMobile","OS","isWeb","isIOS","isAndroid","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,QAAQ,GAAGJ,QAAQ,CAACK,EAAE,KAAK,SAAS,IAAIL,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1E,OAAO,MAAMC,KAAK,GAAGN,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,KAAK,GAAGP,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMG,SAAS,GAAGR,QAAQ,CAACK,EAAE,KAAK,SAAS;AAClD,OAAO,MAAMI,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;EAAA,OAAdA,cAAc;AAAA"}
|
1
|
+
{"version":3,"names":["Platform","warn","message","console","isMobile","OS","isWeb","isIOS","isAndroid","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,QAAQ,GAAGJ,QAAQ,CAACK,EAAE,KAAK,SAAS,IAAIL,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1E,OAAO,MAAMC,KAAK,GAAGN,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,KAAK,GAAGP,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMG,SAAS,GAAGR,QAAQ,CAACK,EAAE,KAAK,SAAS;AAClD,OAAO,MAAMI,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;EAC7CC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EAExHC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhD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AE;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"}
|
package/lib/module/useStyles.js
CHANGED
@@ -9,16 +9,9 @@ export const useStyles = (stylesheet, variantsMap) => {
|
|
9
9
|
layout,
|
10
10
|
plugins
|
11
11
|
} = useUnistyles();
|
12
|
-
if (!stylesheet) {
|
13
|
-
return {
|
14
|
-
theme,
|
15
|
-
breakpoint: layout.breakpoint,
|
16
|
-
styles: {}
|
17
|
-
};
|
18
|
-
}
|
19
12
|
const variants = useVariants(variantsMap);
|
20
13
|
const parsedStyles = useMemo(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet, layout]);
|
21
|
-
const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles).reduce((acc, _ref) => {
|
14
|
+
const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles || {}).reduce((acc, _ref) => {
|
22
15
|
let [key, value] = _ref;
|
23
16
|
if (typeof value === 'function') {
|
24
17
|
return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useMemo","StyleSheet","parseStyle","proxifyFunction","useUnistyles","useVariants","unistyles","useStyles","stylesheet","variantsMap","theme","layout","plugins","
|
1
|
+
{"version":3,"names":["useMemo","StyleSheet","parseStyle","proxifyFunction","useUnistyles","useVariants","unistyles","useStyles","stylesheet","variantsMap","theme","layout","plugins","variants","parsedStyles","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","registry","runtime","create","breakpoint","styles"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,EAAEC,eAAe,QAAQ,SAAS;AACrD,SAASC,YAAY,EAAEC,WAAW,QAAQ,SAAS;AAEnD,SAASC,SAAS,QAAQ,QAAQ;AAclC,OAAO,MAAMC,SAAS,GAAGA,CACrBC,UAAe,EACfC,WAAoD,KAC7B;EACvB,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGR,YAAY,CAAC,CAAC;EACjD,MAAMS,QAAQ,GAAGR,WAAW,CAACI,WAAW,CAAC;EACzC,MAAMK,YAAY,GAAGd,OAAO,CAAC,MAAM,OAAOQ,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACE,KAAK,CAAC,GACjBF,UAAU,EAAE,CAACE,KAAK,EAAEF,UAAU,EAAEG,MAAM,CAAC,CAAC;EAE9C,MAAMI,iBAAiB,GAAGf,OAAO,CAAC,MAAMgB,MAAM,CACzCC,OAAO,CAACH,YAAY,IAAI,CAAC,CAAC,CAAC,CAC3BI,MAAM,CAAC,CAACC,GAAG,EAAAC,IAAA,KAAmB;IAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;IACtB,IAAI,OAAOE,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGH,GAAG;QACN,CAACE,GAAG,GAAGlB,eAAe,CAACkB,GAAG,EAAEC,KAAK,EAAChB,SAAS,CAACiB,QAAQ,CAACX,OAAO,EAAEN,SAAS,CAACkB,OAAO,EAAEX,QAAQ;MAC7F,CAAC;IACL;IAEA,OAAOZ,UAAU,CAACwB,MAAM,CAAC;MACrB,GAAGN,GAAG;MACN,CAACE,GAAG,GAAGnB,UAAU,CACbmB,GAAG,EACHC,KAAK,EACLhB,SAAS,CAACiB,QAAQ,CAACX,OAAO,EAC1BN,SAAS,CAACkB,OAAO,EACjBX,QACJ;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAACF,MAAM,EAAEG,YAAY,EAAED,QAAQ,EAAED,OAAO,CACpD,CAAC;EAED,OAAO;IACHF,KAAK;IACLgB,UAAU,EAAEf,MAAM,CAACe,UAAU;IAC7BC,MAAM,EAAEZ;EACZ,CAAC;AACL,CAAC"}
|
@@ -14,14 +14,15 @@ export declare enum UnistylesEventType {
|
|
14
14
|
Plugin = "plugin"
|
15
15
|
}
|
16
16
|
export declare enum UnistylesError {
|
17
|
-
RuntimeUnavailable = "Unistyles runtime is not available. Make sure you followed the installation instructions
|
18
|
-
ThemeNotFound = "You are trying to get a theme that is not registered
|
19
|
-
ThemeNotRegistered = "You are trying to set a theme that
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
RuntimeUnavailable = "Unistyles runtime is not available. Make sure you followed the installation instructions",
|
18
|
+
ThemeNotFound = "You are trying to get a theme that is not registered with UnistylesRegistry",
|
19
|
+
ThemeNotRegistered = "You are trying to set a theme that was not registered with UnistylesRegistry",
|
20
|
+
ThemeNotSelected = "Your themes are registered, but you didn't select the initial theme",
|
21
|
+
ThemesCannotBeEmpty = "You are trying to register empty themes object",
|
22
|
+
BreakpointsCannotBeEmpty = "You are trying to register empty breakpoints object",
|
23
|
+
BreakpointsMustStartFromZero = "You are trying to register breakpoints that don't start from 0",
|
24
|
+
InvalidPluginName = "Plugin name can't start from reserved prefix __unistyles",
|
25
|
+
DuplicatePluginName = "You are trying to register a plugin with a name that is already registered",
|
26
|
+
CantRemoveInternalPlugin = "You are trying to remove an internal unistyles plugin"
|
26
27
|
}
|
27
28
|
//# sourceMappingURL=common.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AAED,eAAO,MAAM,QAAQ,SAAqD,CAAA;AAC1E,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,SAAS,SAA4B,CAAA;AAClD,eAAO,MAAM,QAAQ,SAAgC,CAAA;AAErD,eAAO,MAAM,iBAAiB;;;CAGpB,CAAA;AAEV,oBAAY,kBAAkB;IAC1B,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED,oBAAY,cAAc;IACtB,kBAAkB,
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AAED,eAAO,MAAM,QAAQ,SAAqD,CAAA;AAC1E,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,SAAS,SAA4B,CAAA;AAClD,eAAO,MAAM,QAAQ,SAAgC,CAAA;AAErD,eAAO,MAAM,iBAAiB;;;CAGpB,CAAA;AAEV,oBAAY,kBAAkB;IAC1B,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED,oBAAY,cAAc;IACtB,kBAAkB,6FAA6F;IAC/G,aAAa,gFAAgF;IAC7F,kBAAkB,iFAAiF;IACnG,gBAAgB,wEAAyE;IACzF,mBAAmB,mDAAmD;IACtE,wBAAwB,wDAAwD;IAChF,4BAA4B,mEAAoE;IAChG,iBAAiB,6DAA8D;IAC/E,mBAAmB,+EAA+E;IAClG,wBAAwB,0DAA0D;CACrF"}
|
@@ -9,9 +9,45 @@ export declare class UnistyleRegistry {
|
|
9
9
|
breakpoints: UnistylesBreakpoints;
|
10
10
|
sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>;
|
11
11
|
constructor(unistylesBridge: UnistylesBridge);
|
12
|
-
addThemes: (themes: UnistylesThemes) =>
|
13
|
-
|
14
|
-
|
12
|
+
addThemes: (themes: UnistylesThemes) => {
|
13
|
+
addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
|
14
|
+
addThemes: any;
|
15
|
+
addConfig: (config: UnistylesConfig) => {
|
16
|
+
addBreakpoints: any;
|
17
|
+
addThemes: any;
|
18
|
+
};
|
19
|
+
};
|
20
|
+
addConfig: (config: UnistylesConfig) => {
|
21
|
+
addBreakpoints: any;
|
22
|
+
addThemes: any;
|
23
|
+
};
|
24
|
+
};
|
25
|
+
addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
|
26
|
+
addThemes: (themes: UnistylesThemes) => {
|
27
|
+
addBreakpoints: any;
|
28
|
+
addConfig: (config: UnistylesConfig) => {
|
29
|
+
addBreakpoints: any;
|
30
|
+
addThemes: any;
|
31
|
+
};
|
32
|
+
};
|
33
|
+
addConfig: (config: UnistylesConfig) => {
|
34
|
+
addBreakpoints: any;
|
35
|
+
addThemes: any;
|
36
|
+
};
|
37
|
+
};
|
38
|
+
addConfig: (config: UnistylesConfig) => {
|
39
|
+
addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
|
40
|
+
addThemes: (themes: UnistylesThemes) => {
|
41
|
+
addBreakpoints: any;
|
42
|
+
addConfig: any;
|
43
|
+
};
|
44
|
+
addConfig: any;
|
45
|
+
};
|
46
|
+
addThemes: (themes: UnistylesThemes) => {
|
47
|
+
addBreakpoints: any;
|
48
|
+
addConfig: any;
|
49
|
+
};
|
50
|
+
};
|
15
51
|
getTheme: (forName: keyof UnistylesThemes) => never;
|
16
52
|
addPlugin: (plugin: UnistylesPlugin, notify?: boolean) => void;
|
17
53
|
removePlugin: (plugin: UnistylesPlugin) => void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"UnistyleRegistry.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistyleRegistry.ts"],"names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,oBAAoB;;gCAW9B,eAAe;;;;;4BAAf,eAAe;;;;MAb1C;IAEM,cAAc,gBAAiB,oBAAoB;4BAd9B,eAAe;;gCAyBf,eAAe;;;;;4BAAf,eAAe;;;;MAF1C;IAEM,SAAS,WAAY,eAAe;sCAXL,oBAAoB;gCAd9B,eAAe;;;;;;4BAAf,eAAe;;;;MA4C1C;IAEM,QAAQ,YAAa,MAAM,eAAe,WAchD;IAEM,SAAS,WAAY,eAAe,WAAU,OAAO,UAW3D;IAEM,YAAY,WAAY,eAAe,UAO7C;IAEM,QAAQ,SAAU,MAAM,eAAe,aAAwB;CACzE"}
|
@@ -6,9 +6,54 @@ import { ScreenOrientation } from './common';
|
|
6
6
|
import { useStyles } from './useStyles';
|
7
7
|
import { createStyleSheet } from './createStyleSheet';
|
8
8
|
declare const UnistylesRegistry: {
|
9
|
-
addThemes: (themes: UnistylesThemes) =>
|
10
|
-
|
11
|
-
|
9
|
+
addThemes: (themes: UnistylesThemes) => {
|
10
|
+
addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
|
11
|
+
addThemes: any;
|
12
|
+
addConfig: (config: import("./types").UnistylesConfig) => {
|
13
|
+
addBreakpoints: any;
|
14
|
+
addThemes: any;
|
15
|
+
};
|
16
|
+
};
|
17
|
+
addConfig: (config: import("./types").UnistylesConfig) => {
|
18
|
+
addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
|
19
|
+
addThemes: any;
|
20
|
+
addConfig: any;
|
21
|
+
};
|
22
|
+
addThemes: any;
|
23
|
+
};
|
24
|
+
};
|
25
|
+
addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
|
26
|
+
addThemes: (themes: UnistylesThemes) => {
|
27
|
+
addBreakpoints: any;
|
28
|
+
addConfig: (config: import("./types").UnistylesConfig) => {
|
29
|
+
addBreakpoints: any;
|
30
|
+
addThemes: any;
|
31
|
+
};
|
32
|
+
};
|
33
|
+
addConfig: (config: import("./types").UnistylesConfig) => {
|
34
|
+
addBreakpoints: any;
|
35
|
+
addThemes: (themes: UnistylesThemes) => {
|
36
|
+
addBreakpoints: any;
|
37
|
+
addConfig: any;
|
38
|
+
};
|
39
|
+
};
|
40
|
+
};
|
41
|
+
addConfig: (config: import("./types").UnistylesConfig) => {
|
42
|
+
addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
|
43
|
+
addThemes: (themes: UnistylesThemes) => {
|
44
|
+
addBreakpoints: any;
|
45
|
+
addConfig: any;
|
46
|
+
};
|
47
|
+
addConfig: any;
|
48
|
+
};
|
49
|
+
addThemes: (themes: UnistylesThemes) => {
|
50
|
+
addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
|
51
|
+
addThemes: any;
|
52
|
+
addConfig: any;
|
53
|
+
};
|
54
|
+
addConfig: any;
|
55
|
+
};
|
56
|
+
};
|
12
57
|
};
|
13
58
|
declare const UnistylesRuntime: import("./core").UnistylesRuntime;
|
14
59
|
export { mq, useStyles, useInitialTheme, createStyleSheet, ScreenOrientation, UnistylesRegistry, UnistylesRuntime };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,QAAA,MAAM,iBAAiB
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAItB,CAAA;AAED,QAAA,MAAM,gBAAgB,mCAAoB,CAAA;AAE1C,OAAO,EACH,EAAE,EACF,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EACnB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACpB,eAAe,EAClB,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEpD,OAAO,KAAK,EACR,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EACzB,cAAc,EACjB,MAAM,SAAS,CAAA;AAEhB,KAAK,gBAAgB,CAAC,EAAE,SAAS,yBAAyB,IAAI;IAC1D,KAAK,EAAE,cAAc,CAAC;IACtB,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,MAAM,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,SAAS,
|
1
|
+
{"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEpD,OAAO,KAAK,EACR,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EACzB,cAAc,EACjB,MAAM,SAAS,CAAA;AAEhB,KAAK,gBAAgB,CAAC,EAAE,SAAS,yBAAyB,IAAI;IAC1D,KAAK,EAAE,cAAc,CAAC;IACtB,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,MAAM,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,SAAS,gJAsCrB,CAAA"}
|
package/package.json
CHANGED
package/src/common.ts
CHANGED
@@ -22,13 +22,14 @@ export enum UnistylesEventType {
|
|
22
22
|
}
|
23
23
|
|
24
24
|
export enum UnistylesError {
|
25
|
-
RuntimeUnavailable = 'Unistyles runtime is not available. Make sure you followed the installation instructions
|
26
|
-
ThemeNotFound = 'You are trying to get a theme that is not registered
|
27
|
-
ThemeNotRegistered = 'You are trying to set a theme that
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
RuntimeUnavailable = 'Unistyles runtime is not available. Make sure you followed the installation instructions',
|
26
|
+
ThemeNotFound = 'You are trying to get a theme that is not registered with UnistylesRegistry',
|
27
|
+
ThemeNotRegistered = 'You are trying to set a theme that was not registered with UnistylesRegistry',
|
28
|
+
ThemeNotSelected = 'Your themes are registered, but you didn\'t select the initial theme',
|
29
|
+
ThemesCannotBeEmpty = 'You are trying to register empty themes object',
|
30
|
+
BreakpointsCannotBeEmpty = 'You are trying to register empty breakpoints object',
|
31
|
+
BreakpointsMustStartFromZero = 'You are trying to register breakpoints that don\'t start from 0',
|
32
|
+
InvalidPluginName = 'Plugin name can\'t start from reserved prefix __unistyles',
|
33
|
+
DuplicatePluginName = 'You are trying to register a plugin with a name that is already registered',
|
34
|
+
CantRemoveInternalPlugin = 'You are trying to remove an internal unistyles plugin'
|
34
35
|
}
|
@@ -23,7 +23,10 @@ export class UnistyleRegistry {
|
|
23
23
|
this.unistylesBridge.themes = keys
|
24
24
|
this.themeNames = keys
|
25
25
|
|
26
|
-
return
|
26
|
+
return {
|
27
|
+
addBreakpoints: this.addBreakpoints,
|
28
|
+
addConfig: this.addConfig
|
29
|
+
}
|
27
30
|
}
|
28
31
|
|
29
32
|
public addBreakpoints = (breakpoints: UnistylesBreakpoints) => {
|
@@ -31,7 +34,10 @@ export class UnistyleRegistry {
|
|
31
34
|
this.unistylesBridge.useBreakpoints(breakpoints)
|
32
35
|
this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs
|
33
36
|
|
34
|
-
return
|
37
|
+
return {
|
38
|
+
addThemes: this.addThemes,
|
39
|
+
addConfig: this.addConfig
|
40
|
+
}
|
35
41
|
}
|
36
42
|
|
37
43
|
public addConfig = (config: UnistylesConfig) => {
|
@@ -48,6 +54,11 @@ export class UnistyleRegistry {
|
|
48
54
|
if (config.initialTheme) {
|
49
55
|
this.unistylesBridge.useTheme(config.initialTheme)
|
50
56
|
}
|
57
|
+
|
58
|
+
return {
|
59
|
+
addBreakpoints: this.addBreakpoints,
|
60
|
+
addThemes: this.addThemes
|
61
|
+
}
|
51
62
|
}
|
52
63
|
|
53
64
|
public getTheme = (forName: keyof UnistylesThemes) => {
|
@@ -55,11 +66,15 @@ export class UnistyleRegistry {
|
|
55
66
|
return {} as UnistylesThemes[keyof UnistylesThemes]
|
56
67
|
}
|
57
68
|
|
58
|
-
if (
|
69
|
+
if (this.hasTheme(forName)) {
|
70
|
+
return this.themes[forName]
|
71
|
+
}
|
72
|
+
|
73
|
+
if (this.unistylesBridge.themeName) {
|
59
74
|
throw new Error(UnistylesError.ThemeNotFound)
|
60
75
|
}
|
61
76
|
|
62
|
-
|
77
|
+
throw new Error(UnistylesError.ThemeNotSelected)
|
63
78
|
}
|
64
79
|
|
65
80
|
public addPlugin = (plugin: UnistylesPlugin, notify: boolean = true) => {
|
package/src/useStyles.ts
CHANGED
@@ -22,22 +22,13 @@ export const useStyles = <ST extends StyleSheetWithSuperPowers>(
|
|
22
22
|
variantsMap?: ExtractVariantNames<typeof stylesheet>
|
23
23
|
): ParsedStylesheet<ST> => {
|
24
24
|
const { theme, layout, plugins } = useUnistyles()
|
25
|
-
|
26
|
-
if (!stylesheet) {
|
27
|
-
return {
|
28
|
-
theme,
|
29
|
-
breakpoint: layout.breakpoint,
|
30
|
-
styles: {} as ReactNativeStyleSheet<ST>
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
25
|
const variants = useVariants(variantsMap)
|
35
26
|
const parsedStyles = useMemo(() => typeof stylesheet === 'function'
|
36
27
|
? stylesheet(theme)
|
37
28
|
: stylesheet, [theme, stylesheet, layout])
|
38
29
|
|
39
30
|
const dynamicStyleSheet = useMemo(() => Object
|
40
|
-
.entries(parsedStyles)
|
31
|
+
.entries(parsedStyles || {})
|
41
32
|
.reduce((acc, [key, value]) => {
|
42
33
|
if (typeof value === 'function') {
|
43
34
|
return {
|
@@ -56,13 +47,12 @@ export const useStyles = <ST extends StyleSheetWithSuperPowers>(
|
|
56
47
|
variants
|
57
48
|
)
|
58
49
|
})
|
59
|
-
}, {}),
|
60
|
-
|
61
|
-
) as ReactNativeStyleSheet<ST>
|
50
|
+
}, {}), [layout, parsedStyles, variants, plugins]
|
51
|
+
)
|
62
52
|
|
63
53
|
return {
|
64
54
|
theme,
|
65
55
|
breakpoint: layout.breakpoint,
|
66
|
-
styles: dynamicStyleSheet
|
56
|
+
styles: dynamicStyleSheet as ReactNativeStyleSheet<ST>
|
67
57
|
}
|
68
58
|
}
|