react-native-unistyles 2.0.0-beta.7 → 2.0.0-rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. package/README.md +22 -35
  2. package/lib/commonjs/core/UnistyleRegistry.js +15 -25
  3. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
  4. package/lib/commonjs/core/UnistylesModule.js +187 -2
  5. package/lib/commonjs/core/UnistylesModule.js.map +1 -1
  6. package/lib/commonjs/core/UnistylesModule.native.js +9 -0
  7. package/lib/commonjs/core/UnistylesModule.native.js.map +1 -0
  8. package/lib/commonjs/core/UnistylesRuntime.js +64 -0
  9. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
  10. package/lib/commonjs/createStyleSheet.js +5 -0
  11. package/lib/commonjs/createStyleSheet.js.map +1 -1
  12. package/lib/commonjs/hooks/useCSS.js +36 -1
  13. package/lib/commonjs/hooks/useCSS.js.map +1 -1
  14. package/lib/commonjs/hooks/useCSS.native.js +9 -0
  15. package/lib/commonjs/hooks/useCSS.native.js.map +1 -0
  16. package/lib/commonjs/index.js +16 -0
  17. package/lib/commonjs/index.js.map +1 -1
  18. package/lib/commonjs/normalizer/normalizer.js +1 -2
  19. package/lib/commonjs/normalizer/normalizer.js.map +1 -1
  20. package/lib/commonjs/useStyles.js +7 -2
  21. package/lib/commonjs/useStyles.js.map +1 -1
  22. package/lib/commonjs/utils/breakpoints.js +2 -11
  23. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  24. package/lib/commonjs/utils/cssMediaQuery.js +3 -9
  25. package/lib/commonjs/utils/cssMediaQuery.js.map +1 -1
  26. package/lib/commonjs/utils/mq.js +17 -36
  27. package/lib/commonjs/utils/mq.js.map +1 -1
  28. package/lib/commonjs/utils/mqParser.js +1 -2
  29. package/lib/commonjs/utils/mqParser.js.map +1 -1
  30. package/lib/commonjs/utils/styles.js +34 -39
  31. package/lib/commonjs/utils/styles.js.map +1 -1
  32. package/lib/module/core/UnistyleRegistry.js +15 -25
  33. package/lib/module/core/UnistyleRegistry.js.map +1 -1
  34. package/lib/module/core/UnistylesModule.js +186 -2
  35. package/lib/module/core/UnistylesModule.js.map +1 -1
  36. package/lib/module/core/UnistylesModule.native.js +3 -0
  37. package/lib/module/core/UnistylesModule.native.js.map +1 -0
  38. package/lib/module/core/UnistylesRuntime.js +64 -0
  39. package/lib/module/core/UnistylesRuntime.js.map +1 -1
  40. package/lib/module/createStyleSheet.js +5 -0
  41. package/lib/module/createStyleSheet.js.map +1 -1
  42. package/lib/module/hooks/useCSS.js +36 -1
  43. package/lib/module/hooks/useCSS.js.map +1 -1
  44. package/lib/module/hooks/useCSS.native.js +2 -0
  45. package/lib/module/hooks/useCSS.native.js.map +1 -0
  46. package/lib/module/index.js +17 -0
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/normalizer/normalizer.js +1 -2
  49. package/lib/module/normalizer/normalizer.js.map +1 -1
  50. package/lib/module/useStyles.js +7 -2
  51. package/lib/module/useStyles.js.map +1 -1
  52. package/lib/module/utils/breakpoints.js +2 -11
  53. package/lib/module/utils/breakpoints.js.map +1 -1
  54. package/lib/module/utils/cssMediaQuery.js +3 -9
  55. package/lib/module/utils/cssMediaQuery.js.map +1 -1
  56. package/lib/module/utils/mq.js +17 -36
  57. package/lib/module/utils/mq.js.map +1 -1
  58. package/lib/module/utils/mqParser.js +1 -2
  59. package/lib/module/utils/mqParser.js.map +1 -1
  60. package/lib/module/utils/styles.js +34 -39
  61. package/lib/module/utils/styles.js.map +1 -1
  62. package/lib/typescript/src/core/UnistylesModule.d.ts +17 -4
  63. package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -1
  64. package/lib/typescript/src/core/UnistylesModule.native.d.ts +6 -0
  65. package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +1 -0
  66. package/lib/typescript/src/core/UnistylesRuntime.d.ts +52 -0
  67. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
  68. package/lib/typescript/src/createStyleSheet.d.ts +5 -0
  69. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -1
  70. package/lib/typescript/src/hooks/useCSS.d.ts +1 -1
  71. package/lib/typescript/src/hooks/useCSS.d.ts.map +1 -1
  72. package/lib/typescript/src/hooks/useCSS.native.d.ts +3 -0
  73. package/lib/typescript/src/hooks/useCSS.native.d.ts.map +1 -0
  74. package/lib/typescript/src/index.d.ts +16 -0
  75. package/lib/typescript/src/index.d.ts.map +1 -1
  76. package/lib/typescript/src/useStyles.d.ts +6 -0
  77. package/lib/typescript/src/useStyles.d.ts.map +1 -1
  78. package/lib/typescript/src/utils/mq.d.ts +4 -0
  79. package/lib/typescript/src/utils/mq.d.ts.map +1 -1
  80. package/package.json +14 -16
  81. package/src/core/UnistylesModule.native.ts +7 -0
  82. package/src/core/UnistylesModule.ts +224 -4
  83. package/src/core/UnistylesRuntime.ts +52 -0
  84. package/src/createStyleSheet.ts +5 -0
  85. package/src/hooks/useCSS.native.ts +3 -0
  86. package/src/hooks/useCSS.ts +49 -1
  87. package/src/index.ts +16 -0
  88. package/src/useStyles.ts +6 -0
  89. package/src/utils/mq.ts +4 -0
  90. package/lib/commonjs/core/UnistylesModule.web.js +0 -199
  91. package/lib/commonjs/core/UnistylesModule.web.js.map +0 -1
  92. package/lib/commonjs/hooks/useCSS.web.js +0 -46
  93. package/lib/commonjs/hooks/useCSS.web.js.map +0 -1
  94. package/lib/module/core/UnistylesModule.web.js +0 -192
  95. package/lib/module/core/UnistylesModule.web.js.map +0 -1
  96. package/lib/module/hooks/useCSS.web.js +0 -39
  97. package/lib/module/hooks/useCSS.web.js.map +0 -1
  98. package/lib/typescript/src/core/UnistylesModule.web.d.ts +0 -19
  99. package/lib/typescript/src/core/UnistylesModule.web.d.ts.map +0 -1
  100. package/lib/typescript/src/hooks/useCSS.web.d.ts +0 -3
  101. package/lib/typescript/src/hooks/useCSS.web.d.ts.map +0 -1
  102. package/src/core/UnistylesModule.web.ts +0 -227
  103. package/src/hooks/useCSS.web.ts +0 -51
@@ -1,3 +1,187 @@
1
- import { NativeModules } from 'react-native';
2
- export const UnistylesModule = NativeModules?.Unistyles;
1
+ import { NativeEventEmitter, NativeModules } from 'react-native';
2
+ import { normalizeWebStylesPlugin } from '../plugins';
3
+ import { isServer } from '../common';
4
+ export class UnistylesBridgeWeb {
5
+ #timerRef = undefined;
6
+ #hasAdaptiveThemes = false;
7
+ #supportsAutomaticColorScheme = false;
8
+ #screenWidth = isServer ? undefined : window.innerWidth;
9
+ #screenHeight = isServer ? undefined : window.innerHeight;
10
+ #themes = [];
11
+ #breakpoints = {};
12
+ #colorScheme = this.getPreferredColorScheme();
13
+ #themeName = '';
14
+ #enabledPlugins = [normalizeWebStylesPlugin.name];
15
+ #unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles);
16
+ #sortedBreakpointPairs = [];
17
+ #breakpoint = '';
18
+ constructor() {
19
+ if (!isServer) {
20
+ this.setupListeners();
21
+ this.#screenWidth = window.innerWidth;
22
+ this.#screenHeight = window.innerHeight;
23
+ }
24
+ }
25
+ install() {
26
+ // @ts-ignore
27
+ // eslint-disable-next-line no-undef
28
+ globalThis.__UNISTYLES__ = new Proxy({}, {
29
+ get: (_target, prop) => {
30
+ switch (prop) {
31
+ case 'themeName':
32
+ return this.getTheme();
33
+ case 'screenWidth':
34
+ return this.#screenWidth;
35
+ case 'screenHeight':
36
+ return this.#screenHeight;
37
+ case 'breakpoint':
38
+ return this.#breakpoint || undefined;
39
+ case 'breakpoints':
40
+ return this.#breakpoints;
41
+ case 'hasAdaptiveThemes':
42
+ return this.#hasAdaptiveThemes;
43
+ case 'sortedBreakpointPairs':
44
+ return this.#sortedBreakpointPairs;
45
+ case 'enabledPlugins':
46
+ return this.#enabledPlugins;
47
+ case 'colorScheme':
48
+ return this.#colorScheme;
49
+ case 'useTheme':
50
+ return themeName => this.useTheme(themeName);
51
+ case 'useBreakpoints':
52
+ return breakpoints => this.useBreakpoints(breakpoints);
53
+ case 'useAdaptiveThemes':
54
+ return enable => this.useAdaptiveThemes(enable);
55
+ case 'addPlugin':
56
+ return (pluginName, notify) => this.addPlugin(pluginName, notify);
57
+ case 'removePlugin':
58
+ return pluginName => this.removePlugin(pluginName);
59
+ default:
60
+ return Reflect.get(this, prop);
61
+ }
62
+ },
63
+ set: (target, prop, newValue, receiver) => {
64
+ switch (prop) {
65
+ case 'themes':
66
+ {
67
+ this.#themes = newValue;
68
+ this.#supportsAutomaticColorScheme = newValue.includes('light') && newValue.includes('dark');
69
+ return true;
70
+ }
71
+ case 'themeName':
72
+ {
73
+ this.#themeName = newValue;
74
+ this.emitThemeChange();
75
+ return true;
76
+ }
77
+ default:
78
+ return Reflect.set(target, prop, newValue, receiver);
79
+ }
80
+ }
81
+ });
82
+ return true;
83
+ }
84
+ useTheme(themeName) {
85
+ this.#themeName = themeName;
86
+ this.emitThemeChange();
87
+ }
88
+ useBreakpoints(breakpoints) {
89
+ this.#breakpoints = breakpoints;
90
+ this.#sortedBreakpointPairs = Object.entries(breakpoints).sort(([, a], [, b]) => (a ?? 0) - (b ?? 0));
91
+ if (!isServer) {
92
+ this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
93
+ }
94
+ }
95
+ useAdaptiveThemes(enable) {
96
+ this.#hasAdaptiveThemes = enable;
97
+ if (!this.#hasAdaptiveThemes || !this.#supportsAutomaticColorScheme) {
98
+ return;
99
+ }
100
+ if (this.#themeName !== this.#colorScheme) {
101
+ this.#themeName = this.#colorScheme;
102
+ this.emitThemeChange();
103
+ }
104
+ }
105
+ addPlugin(pluginName, notify) {
106
+ this.#enabledPlugins = [pluginName].concat(this.#enabledPlugins);
107
+ if (notify) {
108
+ this.emitPluginChange();
109
+ }
110
+ }
111
+ removePlugin(pluginName) {
112
+ this.#enabledPlugins = this.#enabledPlugins.filter(name => name !== pluginName);
113
+ this.emitPluginChange();
114
+ }
115
+ getTheme() {
116
+ if (this.#themes.length === 1) {
117
+ return this.#themes.at(0);
118
+ }
119
+ return this.#themeName;
120
+ }
121
+ setupListeners() {
122
+ window.addEventListener('resize', () => {
123
+ clearTimeout(this.#timerRef);
124
+ this.#timerRef = setTimeout(() => {
125
+ this.#screenWidth = window.innerWidth;
126
+ this.#screenHeight = window.innerHeight;
127
+ this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
128
+ this.emitLayoutChange();
129
+ }, 100);
130
+ });
131
+ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
132
+ this.#colorScheme = event.matches ? 'dark' : 'light';
133
+ if (!this.#supportsAutomaticColorScheme || !this.#hasAdaptiveThemes) {
134
+ return;
135
+ }
136
+ if (this.#colorScheme !== this.#themeName) {
137
+ this.#themeName = this.#colorScheme;
138
+ this.emitThemeChange();
139
+ }
140
+ });
141
+ }
142
+ getBreakpointFromScreenWidth(width) {
143
+ const breakpoint = this.#sortedBreakpointPairs.find(([, value], index, otherBreakpoints) => {
144
+ const minVal = value;
145
+ const maxVal = otherBreakpoints[index + 1]?.[1];
146
+ if (!maxVal) {
147
+ return true;
148
+ }
149
+ return width >= minVal && width < maxVal;
150
+ });
151
+ return breakpoint?.at(0);
152
+ }
153
+ getPreferredColorScheme() {
154
+ if (!isServer && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
155
+ return 'dark';
156
+ }
157
+ return 'light';
158
+ }
159
+ emitPluginChange() {
160
+ this.#unistylesEvents.emit('__unistylesOnChange', {
161
+ type: 'plugin'
162
+ });
163
+ }
164
+ emitThemeChange() {
165
+ this.#unistylesEvents.emit('__unistylesOnChange', {
166
+ type: 'theme',
167
+ payload: {
168
+ themeName: this.#themeName
169
+ }
170
+ });
171
+ }
172
+ emitLayoutChange() {
173
+ this.#unistylesEvents.emit('__unistylesOnChange', {
174
+ type: 'layout',
175
+ payload: {
176
+ breakpoint: this.#breakpoint,
177
+ orientation: this.#screenWidth > this.#screenHeight ? 'landscape' : 'portrait',
178
+ screen: {
179
+ width: this.#screenWidth,
180
+ height: this.#screenHeight
181
+ }
182
+ }
183
+ });
184
+ }
185
+ }
186
+ export const UnistylesModule = new UnistylesBridgeWeb();
3
187
  //# sourceMappingURL=UnistylesModule.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","UnistylesModule","Unistyles"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAM5C,OAAO,MAAMC,eAAe,GAAGD,aAAa,EAAEE,SAAkC"}
1
+ {"version":3,"names":["NativeEventEmitter","NativeModules","normalizeWebStylesPlugin","isServer","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","window","innerWidth","screenHeight","innerHeight","themes","breakpoints","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","name","unistylesEvents","Unistyles","sortedBreakpointPairs","breakpoint","constructor","setupListeners","install","globalThis","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","useBreakpoints","enable","useAdaptiveThemes","pluginName","notify","addPlugin","removePlugin","Reflect","set","target","newValue","receiver","includes","emitThemeChange","Object","entries","sort","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","width","find","value","index","otherBreakpoints","minVal","maxVal","emit","type","payload","orientation","screen","height","UnistylesModule"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAGhE,SAASC,wBAAwB,QAAQ,YAAY;AACrD,SAASC,QAAQ,QAAQ,WAAW;AAEpC,OAAO,MAAMC,kBAAkB,CAAC;EAC5B,CAACC,QAAQ,GAAmCC,SAAS;EACrD,CAACC,iBAAiB,GAAY,KAAK;EACnC,CAACC,4BAA4B,GAAG,KAAK;EACrC,CAACC,WAAW,GAAGN,QAAQ,GAAGG,SAAS,GAAGI,MAAM,CAACC,UAAU;EACvD,CAACC,YAAY,GAAGT,QAAQ,GAAGG,SAAS,GAAGI,MAAM,CAACG,WAAW;EACzD,CA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U,EAAE,IAAI,CAAC,CAACA,UAAU;QAC5BsD,WAAW,EAAG,IAAI,CAAC,CAACrE,WAAW,GAAe,IAAI,CAAC,CAACG,YAAuB,GACrE,WAAW,GACX,UAAU;QAChBmE,MAAM,EAAE;UACJX,KAAK,EAAE,IAAI,CAAC,CAAC3D,WAAW;UACxBuE,MAAM,EAAE,IAAI,CAAC,CAACpE;QAClB;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMqE,eAAe,GAAG,IAAI7E,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { NativeModules } from 'react-native';
2
+ export const UnistylesModule = NativeModules?.Unistyles;
3
+ //# sourceMappingURL=UnistylesModule.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","UnistylesModule","Unistyles"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.native.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAM5C,OAAO,MAAMC,eAAe,GAAGD,aAAa,EAAEE,SAAkC"}
@@ -1,33 +1,76 @@
1
1
  import { ScreenOrientation, UnistylesError } from '../common';
2
+ /**
3
+ * Utility to interact with the Unistyles during runtime
4
+ */
2
5
  export class UnistylesRuntime {
3
6
  constructor(unistylesBridge, unistylesRegistry) {
4
7
  this.unistylesBridge = unistylesBridge;
5
8
  this.unistylesRegistry = unistylesRegistry;
6
9
  }
10
+
11
+ /**
12
+ * Get the current color scheme
13
+ * @returns - The current color scheme
14
+ */
7
15
  get colorScheme() {
8
16
  return this.unistylesBridge.colorScheme;
9
17
  }
18
+
19
+ /**
20
+ * Get info about adaptive themes
21
+ * @returns - boolean indicating if the adaptive themes are enabled
22
+ */
10
23
  get hasAdaptiveThemes() {
11
24
  return this.unistylesBridge.hasAdaptiveThemes;
12
25
  }
26
+
27
+ /**
28
+ * Get the current theme name
29
+ * @returns - The current theme name
30
+ */
13
31
  get themeName() {
14
32
  return this.unistylesBridge.themeName;
15
33
  }
34
+
35
+ /**
36
+ * Get the current breakpoint based on device size
37
+ * @returns - The current breakpoint
38
+ */
16
39
  get breakpoint() {
17
40
  return this.unistylesBridge.breakpoint;
18
41
  }
42
+
43
+ /**
44
+ * Get registered breakpoints with UnitylesRegistry
45
+ * @returns - The registered breakpoints
46
+ */
19
47
  get breakpoints() {
20
48
  return this.unistylesRegistry.breakpoints;
21
49
  }
50
+
51
+ /**
52
+ * Get the names of currently enabled plugins
53
+ * @returns - The names of currently enabled plugins
54
+ */
22
55
  get enabledPlugins() {
23
56
  return this.unistylesBridge.enabledPlugins;
24
57
  }
58
+
59
+ /**
60
+ * Get the screen size
61
+ * @returns - The screen size { width, height }
62
+ */
25
63
  get screen() {
26
64
  return {
27
65
  width: this.unistylesBridge.screenWidth,
28
66
  height: this.unistylesBridge.screenHeight
29
67
  };
30
68
  }
69
+
70
+ /**
71
+ * Get the screen orientation
72
+ * @returns - The screen orientation
73
+ */
31
74
  get orientation() {
32
75
  const {
33
76
  width,
@@ -38,6 +81,12 @@ export class UnistylesRuntime {
38
81
  }
39
82
  return ScreenOrientation.Portrait;
40
83
  }
84
+
85
+ /**
86
+ * Switch to a different theme
87
+ * @param name - The name of the theme to switch to
88
+ * @returns - boolean indicating if the theme was switched
89
+ */
41
90
  setTheme = name => {
42
91
  if (name === this.themeName) {
43
92
  return;
@@ -48,12 +97,27 @@ export class UnistylesRuntime {
48
97
  }
49
98
  throw new Error(UnistylesError.ThemeNotRegistered);
50
99
  };
100
+
101
+ /**
102
+ * Enable or disable adaptive themes
103
+ * @param enable - boolean indicating if adaptive themes should be enabled
104
+ */
51
105
  setAdaptiveThemes = enable => {
52
106
  this.unistylesBridge.useAdaptiveThemes(enable);
53
107
  };
108
+
109
+ /**
110
+ * Enable a plugin
111
+ * @param plugin - Plugin that conforms to UnistylesPlugin interface
112
+ */
54
113
  addPlugin = plugin => {
55
114
  this.unistylesRegistry.addPlugin(plugin);
56
115
  };
116
+
117
+ /**
118
+ * Disable a plugin
119
+ * @param plugin - Plugin that conforms to UnistylesPlugin interface
120
+ */
57
121
  removePlugin = plugin => {
58
122
  this.unistylesRegistry.removePlugin(plugin);
59
123
  };
@@ -1 +1 @@
1
- {"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","breakpoint","breakpoints","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,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACL,iBAAiB,CAACK,WAAW;EAC7C;EAEA,IAAWC,cAAcA,CAAA,EAAG;IACxB,OAAO,IAAI,CAACP,eAAe,CAACO,cAAc;EAC9C;EAEA,IAAWC,MAAMA,CAAA,EAAG;IAChB,OAAO;MACHC,KAAK,EAAE,IAAI,CAACT,eAAe,CAACU,WAAW;MACvCC,MAAM,EAAE,IAAI,CAACX,eAAe,CAACY;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,OAAOf,iBAAiB,CAACkB,SAAS;IACtC;IAEA,OAAOlB,iBAAiB,CAACmB,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,CAACvB,cAAc,CAACwB,kBAAkB,CAAC;EACtD,CAAC;EAEMC,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAACvB,eAAe,CAACwB,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;EAEME,SAAS,GAAIC,MAAuB,IAAK;IAC5C,IAAI,CAACzB,iBAAiB,CAACwB,SAAS,CAACC,MAAM,CAAC;EAC5C,CAAC;EAEMC,YAAY,GAAID,MAAuB,IAAK;IAC/C,IAAI,CAACzB,iBAAiB,CAAC0B,YAAY,CAACD,MAAM,CAAC;EAC/C,CAAC;AACL"}
1
+ {"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","breakpoint","breakpoints","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,iBAA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iBAAiB,CAACmB,QAAQ;EACrC;;EAEA;AACJ;AACA;AACA;AACA;EACWC,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,CAACvB,cAAc,CAACwB,kBAAkB,CAAC;EACtD,CAAC;;EAED;AACJ;AACA;AACA;EACWC,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAACvB,eAAe,CAACwB,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;;EAED;AACJ;AACA;AACA;EACWE,SAAS,GAAIC,MAAuB,IAAK;IAC5C,IAAI,CAACzB,iBAAiB,CAACwB,SAAS,CAACC,MAAM,CAAC;EAC5C,CAAC;;EAED;AACJ;AACA;AACA;EACWC,YAAY,GAAID,MAAuB,IAAK;IAC/C,IAAI,CAACzB,iBAAiB,CAAC0B,YAAY,CAACD,MAAM,CAAC;EAC/C,CAAC;AACL"}
@@ -1,2 +1,7 @@
1
+ /**
2
+ * Utility to create a stylesheet with superpowers
3
+ * Compatible with React Native StyleSheet.create
4
+ * @param stylesheet - The stylesheet with superpowers to be used
5
+ */
1
6
  export const createStyleSheet = stylesheet => stylesheet;
2
7
  //# sourceMappingURL=createStyleSheet.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createStyleSheet","stylesheet"],"sourceRoot":"../../src","sources":["createStyleSheet.ts"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,GAAyCC,UAAa,IAAQA,UAAU"}
1
+ {"version":3,"names":["createStyleSheet","stylesheet"],"sourceRoot":"../../src","sources":["createStyleSheet.ts"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,gBAAgB,GAAyCC,UAAa,IAAQA,UAAU"}
@@ -1,2 +1,37 @@
1
- export const useCSS = _stylesheet => {};
1
+ import { useInsertionEffect, useRef } from 'react';
2
+ import { unistyles } from '../core';
3
+ import { generateReactNativeWebId } from '../utils';
4
+ export const useCSS = stylesheet => {
5
+ const insertedIds = useRef([]);
6
+ useInsertionEffect(() => {
7
+ if (!unistyles.registry.config.experimentalCSSMediaQueries) {
8
+ return;
9
+ }
10
+ Object.entries(stylesheet).forEach(([_key, value]) => {
11
+ Object.entries(value).forEach(([prop, val]) => {
12
+ if (!val.toString().includes('@media')) {
13
+ return;
14
+ }
15
+ const id = generateReactNativeWebId(prop, '""');
16
+ if (insertedIds.current.includes(id)) {
17
+ return;
18
+ }
19
+ const style = document.createElement('style');
20
+ style.id = id;
21
+ style.innerHTML = val;
22
+ document.head.appendChild(style);
23
+ insertedIds.current = [...insertedIds.current, id];
24
+ });
25
+ });
26
+ return () => {
27
+ insertedIds.current.forEach(id => {
28
+ const style = document.getElementById(id);
29
+ if (style) {
30
+ style.remove();
31
+ }
32
+ });
33
+ insertedIds.current = [];
34
+ };
35
+ }, [stylesheet]);
36
+ };
2
37
  //# sourceMappingURL=useCSS.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useCSS","_stylesheet"],"sourceRoot":"../../../src","sources":["hooks/useCSS.ts"],"mappings":"AAEA,OAAO,MAAMA,MAAM,GAAOC,WAAqC,IAAW,CAAC,CAAC"}
1
+ {"version":3,"names":["useInsertionEffect","useRef","unistyles","generateReactNativeWebId","useCSS","stylesheet","insertedIds","registry","config","experimentalCSSMediaQueries","Object","entries","forEach","_key","value","prop","val","toString","includes","id","current","style","document","createElement","innerHTML","head","appendChild","getElementById","remove"],"sourceRoot":"../../../src","sources":["hooks/useCSS.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,MAAM,QAAQ,OAAO;AAClD,SAASC,SAAS,QAAQ,SAAS;AAEnC,SAASC,wBAAwB,QAAQ,UAAU;AAEnD,OAAO,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AC5B,CAAC;EACL,CAAC,EAAE,CAACf,UAAU,CAAC,CAAC;AACpB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const useCSS = _stylesheet => {};
2
+ //# sourceMappingURL=useCSS.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCSS","_stylesheet"],"sourceRoot":"../../../src","sources":["hooks/useCSS.native.ts"],"mappings":"AAEA,OAAO,MAAMA,MAAM,GAAOC,WAAqC,IAAW,CAAC,CAAC"}
@@ -4,9 +4,26 @@ import { useInitialTheme } from './hooks';
4
4
  import { ScreenOrientation } from './common';
5
5
  import { useStyles } from './useStyles';
6
6
  import { createStyleSheet } from './createStyleSheet';
7
+
8
+ /**
9
+ * Utility to interact with the Unistyles
10
+ * (should be called only once)
11
+ */
7
12
  const UnistylesRegistry = {
13
+ /**
14
+ * Register themes to be used in the app
15
+ * @param themes - Key value pair of themes
16
+ */
8
17
  addThemes: unistyles.registry.addThemes,
18
+ /**
19
+ * Register breakpoints to be used in the app
20
+ * @param breakpoints - Key value pair of breakpoints
21
+ */
9
22
  addBreakpoints: unistyles.registry.addBreakpoints,
23
+ /**
24
+ * Register additional config to customize the Unistyles
25
+ * @param config - Key value pair of config
26
+ */
10
27
  addConfig: unistyles.registry.addConfig
11
28
  };
12
29
  const UnistylesRuntime = unistyles.runtime;
@@ -1 +1 @@
1
- {"version":3,"names":["unistyles","mq","useInitialTheme","ScreenOrientation","useStyles","createStyleSheet","UnistylesRegistry","addThemes","registry","addBreakpoints","addConfig","UnistylesRuntime","runtime"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,QAAQ;AAClC,SAASC,EAAE,QAAQ,SAAS;AAC5B,SAASC,eAAe,QAAQ,SAAS;AAGzC,SAASC,iBAAiB,QAAQ,UAAU;AAC5C,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAMC,iBAAiB,GAAG;EACtBC,SAAS,EAAEP,SAAS,CAACQ,QAAQ,CAACD,SAAS;EACvCE,cAAc,EAAET,SAAS,CAACQ,QAAQ,CAACC,cAAc;EACjDC,SAAS,EAAEV,SAAS,CAACQ,QAAQ,CAACE;AAClC,CAAC;AAED,MAAMC,gBAAgB,GAAGX,SAAS,CAACY,OAAO;AAE1C,SACIX,EAAE,EACFG,SAAS,EACTF,eAAe,EACfG,gBAAgB,EAChBF,iBAAiB,EACjBG,iBAAiB,EACjBK,gBAAgB"}
1
+ {"version":3,"names":["unistyles","mq","useInitialTheme","ScreenOrientation","useStyles","createStyleSheet","UnistylesRegistry","addThemes","registry","addBreakpoints","addConfig","UnistylesRuntime","runtime"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,QAAQ;AAClC,SAASC,EAAE,QAAQ,SAAS;AAC5B,SAASC,eAAe,QAAQ,SAAS;AAGzC,SAASC,iBAAiB,QAAQ,UAAU;AAC5C,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG;EACtB;AACJ;AACA;AACA;EACIC,SAAS,EAAEP,SAAS,CAACQ,QAAQ,CAACD,SAAS;EACvC;AACJ;AACA;AACA;EACIE,cAAc,EAAET,SAAS,CAACQ,QAAQ,CAACC,cAAc;EACjD;AACJ;AACA;AACA;EACIC,SAAS,EAAEV,SAAS,CAACQ,QAAQ,CAACE;AAClC,CAAC;AAED,MAAMC,gBAAgB,GAAGX,SAAS,CAACY,OAAO;AAE1C,SACIX,EAAE,EACFG,SAAS,EACTF,eAAe,EACfG,gBAAgB,EAChBF,iBAAiB,EACjBG,iBAAiB,EACjBK,gBAAgB"}
@@ -1,8 +1,7 @@
1
1
  // based on react-native-web normalizer
2
2
  // https://github.com/necolas/react-native-web
3
3
  import normalizeColors from '@react-native/normalize-colors';
4
- export const normalizeColor = function (color) {
5
- let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4
+ export const normalizeColor = (color, opacity = 1) => {
6
5
  // If the opacity is 1 there's no need to normalize the color
7
6
  if (opacity === 1) {
8
7
  return color;
@@ -1 +1 @@
1
- {"version":3,"names":["normalizeColors","normalizeColor","color","opacity","arguments","length","undefined","integer","hex","toString","padStart","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","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":["normalizer/normalizer.ts"],"mappings":"AAAA;AACA;AACA,OAAOA,eAAe,MAAM,gCAAgC;AAS5D,OAAO,MAAMC,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,GAAGP,eAAe,CAACE,KAAK,CAAqB;;EAE1D;EACA,IAAIK,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOL,KAAK;EAChB;EAEA,MAAMM,GAAG,GAAGD,OAAO,CAACE,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAEjD,IAAIF,GAAG,CAACH,MAAM,KAAK,CAAC,EAAE;IAClB,MAAM,CAACM,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,CAAC,GAAGN,GAAG,CACnCO,KAAK,CAAC,cAAc,CAAC,CACrBC,GAAG,CAACC,CAAC,IAAIC,QAAQ,CAACD,CAAC,EAAE,EAAE,CAAC,CAAC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AAMC,OAAO,GAAGZ,qBAAqB,CAACiB,YAAY,CAACJ,MAAM,CAAC;EAC1D,MAAMC,MAAM,GAAGd,qBAAqB,CAACmB,YAAY,CAAC;EAClD,MAAMvC,KAAK,GAAGD,cAAc,CAACqC,WAAW,EAAYE,aAAuB,CAAC;EAE5E,OAAQ,GAAER,OAAQ,IAAGE,OAAQ,IAAGE,MAAO,IAAGlC,KAAM,EAAC;AACrD,CAAC;AAED,MAAMwC,oBAAoB,GAAIC,UAAsB,IAAKA,UAAU,CAC9D3B,GAAG,CAAC4B,SAAS,IAAI;EACd,MAAM,CAACnB,GAAG,CAAC,GAAGoB,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC;EAEpC,IAAI,CAACnB,GAAG,EAAE;IACN,OAAOnB,SAAS;EACpB;EAEA,MAAMiB,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,CACDJ,MAAM,CAAC6B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEd,OAAO,MAAME,YAA0B,GAAG;EACtCtB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
1
+ {"version":3,"names":["normalizeColors","normalizeColor","color","opacity","integer","hex","toString","padStart","length","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","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","undefined","join","Boolean","preprocessor"],"sourceRoot":"../../../src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AMxB,KAAK,GAAGqB,SAAS,CAACnB,GAAG,CAA2B;EAEtD,QAAOA,GAAG;IACN,KAAK,QAAQ;IACb,KAAK,UAAU;MACX,OAAQ,GAAEA,GAAI,IAAIF,KAAK,CAAmByB,IAAI,CAAC,GAAG,CAAE,GAAE;IAC1D;MACI,OAAQ,GAAEvB,GAAI,IAAGD,kBAAkB,CAACC,GAAG,EAAEF,KAAK,CAAE,GAAE;EAC1D;AACJ,CAAC,CAAC,CACDJ,MAAM,CAAC8B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEd,OAAO,MAAME,YAA0B,GAAG;EACtCvB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
@@ -4,6 +4,12 @@ import { parseStyle, proxifyFunction, withPlugins } from './utils';
4
4
  import { useCSS, useUnistyles, useVariants } from './hooks';
5
5
  import { unistyles } from './core';
6
6
  import { isWeb } from './common';
7
+ /**
8
+ * Hook that enables all the features of Unistyles
9
+ * @param stylesheet - The stylesheet with superpowers to be used
10
+ * @param variantsMap - The map of variants to be used
11
+ * @returns - The theme, current breakpoint and RN compatible styles
12
+ */
7
13
  export const useStyles = (stylesheet, variantsMap) => {
8
14
  const {
9
15
  theme,
@@ -12,8 +18,7 @@ export const useStyles = (stylesheet, variantsMap) => {
12
18
  } = useUnistyles();
13
19
  const variants = useVariants(variantsMap);
14
20
  const parsedStyles = useMemo(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet, layout]);
15
- const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles || {}).reduce((acc, _ref) => {
16
- let [key, value] = _ref;
21
+ const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles || {}).reduce((acc, [key, value]) => {
17
22
  if (typeof value === 'function') {
18
23
  return {
19
24
  ...acc,
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","StyleSheet","parseStyle","proxifyFunction","withPlugins","useCSS","useUnistyles","useVariants","unistyles","isWeb","useStyles","stylesheet","variantsMap","theme","layout","plugins","variants","parsedStyles","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","create","registry","config","experimentalCSSMediaQueries","breakpoint","styles"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,EAAEC,eAAe,EAAEC,WAAW,QAAQ,SAAS;AAClE,SAASC,MAAM,EAAEC,YAAY,EAAEC,WAAW,QAAQ,SAAS;AAG3D,SAASC,SAAS,QAAQ,QAAQ;AAClC,SAASC,KAAK,QAAQ,UAAU;AAQhC,OAAO,MAAMC,SAAS,GAAGA,CACrBC,UAAe,EACfC,WAAoD,KAC7B;EACvB,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGT,YAAY,CAAC,CAAC;EACjD,MAAMU,QAAQ,GAAGT,WAAW,CAACK,WAAW,CAAC;EACzC,MAAMK,YAAY,GAAGjB,OAAO,CAAC,MAAM,OAAOW,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACE,KAAK,CAAC,GACjBF,UAAU,EAAE,CAACE,KAAK,EAAEF,UAAU,EAAEG,MAAM,CAAC,CAAC;EAE9C,MAAMI,iBAAiB,GAAGlB,OAAO,CAAC,MAAMmB,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,GAAGrB,eAAe,CAACqB,GAAG,EAAEC,KAAK;MACrC,CAAC;IACL;IAEA,OAAOxB,UAAU,CAACyB,MAAM,CAAC;MACrB,GAAGJ,GAAG;MACN,CAACE,GAAG,GAAGpB,WAAW,CAACoB,GAAG,EAAEtB,UAAU,CAC9BuB,KAAK,EACLT,QAAQ,EACR,CAACP,KAAK,IAAI,CAACD,SAAS,CAACmB,QAAQ,CAACC,MAAM,CAACC,2BAA2B,CACpE;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAACZ,YAAY,EAAED,QAAQ,EAAED,OAAO,CAC5C,CAAC;EAEDV,MAAM,CAACa,iBAA8C,CAAC;EAEtD,OAAO;IACHL,KAAK;IACLiB,UAAU,EAAEhB,MAAM,CAACgB,UAAU;IAC7BC,MAAM,EAAEb;EACZ,CAAC;AACL,CAAC"}
1
+ {"version":3,"names":["useMemo","StyleSheet","parseStyle","proxifyFunction","withPlugins","useCSS","useUnistyles","useVariants","unistyles","isWeb","useStyles","stylesheet","variantsMap","theme","layout","plugins","variants","parsedStyles","dynamicStyleSheet","Object","entries","reduce","acc","key","value","create","registry","config","experimentalCSSMediaQueries","breakpoint","styles"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,EAAEC,eAAe,EAAEC,WAAW,QAAQ,SAAS;AAClE,SAASC,MAAM,EAAEC,YAAY,EAAEC,WAAW,QAAQ,SAAS;AAG3D,SAASC,SAAS,QAAQ,QAAQ;AAClC,SAASC,KAAK,QAAQ,UAAU;AAQhC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAGA,CACrBC,UAAe,EACfC,WAAoD,KAC7B;EACvB,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGT,YAAY,CAAC,CAAC;EACjD,MAAMU,QAAQ,GAAGT,WAAW,CAACK,WAAW,CAAC;EACzC,MAAMK,YAAY,GAAGjB,OAAO,CAAC,MAAM,OAAOW,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACE,KAAK,CAAC,GACjBF,UAAU,EAAE,CAACE,KAAK,EAAEF,UAAU,EAAEG,MAAM,CAAC,CAAC;EAE9C,MAAMI,iBAAiB,GAAGlB,OAAO,CAAC,MAAMmB,MAAM,CACzCC,OAAO,CAACH,YAAY,IAAI,CAAC,CAAC,CAAC,CAC3BI,MAAM,CAAC,CAACC,GAAG,EAAE,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;IAC3B,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGF,GAAG;QACN,CAACC,GAAG,GAAGpB,eAAe,CAACoB,GAAG,EAAEC,KAAK;MACrC,CAAC;IACL;IAEA,OAAOvB,UAAU,CAACwB,MAAM,CAAC;MACrB,GAAGH,GAAG;MACN,CAACC,GAAG,GAAGnB,WAAW,CAACmB,GAAG,EAAErB,UAAU,CAC9BsB,KAAK,EACLR,QAAQ,EACR,CAACP,KAAK,IAAI,CAACD,SAAS,CAACkB,QAAQ,CAACC,MAAM,CAACC,2BAA2B,CACpE;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAACX,YAAY,EAAED,QAAQ,EAAED,OAAO,CAC5C,CAAC;EAEDV,MAAM,CAACa,iBAA8C,CAAC;EAEtD,OAAO;IACHL,KAAK;IACLgB,UAAU,EAAEf,MAAM,CAACe,UAAU;IAC7BC,MAAM,EAAEZ;EACZ,CAAC;AACL,CAAC"}
@@ -19,17 +19,8 @@ export const getValueForBreakpoint = value => {
19
19
  return directBreakpoint;
20
20
  }
21
21
  const breakpointPairs = unistyles.registry.sortedBreakpointPairs;
22
- const currentBreakpointIndex = breakpointPairs.findIndex(_ref => {
23
- let [key] = _ref;
24
- return key === breakpoint;
25
- });
26
- const availableBreakpoints = breakpointPairs.filter((_ref2, index) => {
27
- let [key] = _ref2;
28
- return index < currentBreakpointIndex && key in value;
29
- }).map(_ref3 => {
30
- let [key] = _ref3;
31
- return key;
32
- });
22
+ const currentBreakpointIndex = breakpointPairs.findIndex(([key]) => key === breakpoint);
23
+ const availableBreakpoints = breakpointPairs.filter(([key], index) => index < currentBreakpointIndex && key in value).map(([key]) => key);
33
24
  return value[availableBreakpoints[availableBreakpoints.length - 1]];
34
25
  };
35
26
  //# sourceMappingURL=breakpoints.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["unistyles","ScreenOrientation","isMobile","getKeyForUnistylesMediaQuery","getValueForBreakpoint","value","customMediaQueryKey","Object","entries","runtime","screen","hasBreakpoints","registry","sortedBreakpointPairs","length","Landscape","Portrait","orientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpointIndex","findIndex","_ref","key","availableBreakpoints","filter","_ref2","index","map","_ref3"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,SAAS;AAGnC,SAASC,iBAAiB,EAAEC,QAAQ,QAAQ,WAAW;AACvD,SAASC,4BAA4B,QAAQ,YAAY;AAEzD,OAAO,MAAMC,qBAAqB,GAAIC,KAA8B,IAAwB;EACxF,MAAMC,mBAAmB,GAAGH,4BAA4B,CACpDI,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC,EACrBL,SAAS,CAACS,OAAO,CAACC,MACtB,CAAuB;EAEvB,IAAIJ,mBAAmB,EAAE;IACrB,OAAOD,KAAK,CAACC,mBAAmB,CAAC;EACrC;EAEA,MAAMK,cAAc,GAAGX,SAAS,CAACY,QAAQ,CAACC,qBAAqB,CAACC,MAAM,GAAG,CAAC;EAE1E,IAAI,CAACH,cAAc,IAAIT,QAAQ,KAAKD,iBAAiB,CAACc,SAAS,IAAIV,KAAK,IAAIJ,iBAAiB,CAACe,QAAQ,IAAIX,KAAK,CAAC,EAAE;IAC9G,OAAOA,KAAK,CAACL,SAAS,CAACS,OAAO,CAACQ,WAAW,CAAC;EAC/C;EAEA,MAAMC,UAAU,GAAGlB,SAAS,CAACS,OAAO,CAACS,UAAU;EAE/C,IAAI,CAACA,UAAU,EAAE;IACb,OAAOC,SAAS;EACpB;EAEA,MAAMC,gBAAgB,GAAGf,KAAK,CAACa,UAAU,CAAC;EAE1C,IAAIE,gBAAgB,IAAKF,UAAU,IAAIb,KAAM,EAAE;IAC3C,OAAOe,gBAAgB;EAC3B;EAEA,MAAMC,eAAe,GAAGrB,SAAS,CAACY,QAAQ,CAACC,qBAAqB;EAChE,MAAMS,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,IAAIpB,KAAK;EAAA,EAAC,CACxEyB,GAAG,CAACC,KAAA;IAAA,IAAC,CAACN,GAAG,CAAC,GAAAM,KAAA;IAAA,OAAKN,GAAG;EAAA,EAAC;EAExB,OAAOpB,KAAK,CAACqB,oBAAoB,CAACA,oBAAoB,CAACZ,MAAM,GAAG,CAAC,CAAC,CAAwC;AAC9G,CAAC"}
1
+ {"version":3,"names":["unistyles","ScreenOrientation","isMobile","getKeyForUnistylesMediaQuery","getValueForBreakpoint","value","customMediaQueryKey","Object","entries","runtime","screen","hasBreakpoints","registry","sortedBreakpointPairs","length","Landscape","Portrait","orientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpointIndex","findIndex","key","availableBreakpoints","filter","index","map"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,SAAS;AAGnC,SAASC,iBAAiB,EAAEC,QAAQ,QAAQ,WAAW;AACvD,SAASC,4BAA4B,QAAQ,YAAY;AAEzD,OAAO,MAAMC,qBAAqB,GAAIC,KAA8B,IAAwB;EACxF,MAAMC,mBAAmB,GAAGH,4BAA4B,CACpDI,MA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
2
2
  import { isUnistylesMq, isValidMq, parseMq } from './mqParser';
3
3
  import { generateReactNativeWebId } from './generateId';
4
4
  export const createMediaQueryForStyles = (styles, runtime) => {
5
- const withMediaQueries = Object.entries(styles).filter(_ref => {
6
- let [, value] = _ref;
7
- return typeof value === 'object';
8
- }).reduce((acc, _ref2) => {
9
- let [prop, value] = _ref2;
5
+ const withMediaQueries = Object.entries(styles).filter(([, value]) => typeof value === 'object').reduce((acc, [prop, value]) => {
10
6
  const objectKeys = Object.keys(value);
11
7
  const mediaQueries = objectKeys.filter(key => isUnistylesMq(key));
12
8
  const breakpoints = objectKeys.filter(key => runtime.breakpoints[key]);
@@ -47,8 +43,7 @@ const getMaxHeightMediaQuery = height => {
47
43
  }
48
44
  return `and (max-height: ${height.to}px)`;
49
45
  };
50
- const getMediaQueriesFromMQ = (prop, value, className) => Object.entries(value).reduce((acc, _ref3) => {
51
- let [key, value] = _ref3;
46
+ const getMediaQueriesFromMQ = (prop, value, className) => Object.entries(value).reduce((acc, [key, value]) => {
52
47
  const result = parseMq(key);
53
48
  if (!isValidMq(result)) {
54
49
  return acc;
@@ -85,8 +80,7 @@ const getMediaQueriesFromMQ = (prop, value, className) => Object.entries(value).
85
80
  }
86
81
  return acc;
87
82
  }, '');
88
- const getBreakpointsStyles = (prop, value, runtime, className) => Object.entries(value).reduce((acc, _ref4) => {
89
- let [key, value] = _ref4;
83
+ const getBreakpointsStyles = (prop, value, runtime, className) => Object.entries(value).reduce((acc, [key, value]) => {
90
84
  const breakpoint = runtime.breakpoints[key];
91
85
  if (breakpoint === undefined) {
92
86
  return acc;
@@ -1 +1 @@
1
- {"version":3,"names":["normalizeColor","isUnistylesMq","isValidMq","parseMq","generateReactNativeWebId","createMediaQueryForStyles","styles","runtime","withMediaQueries","Object","entries","filter","_ref","value","reduce","acc","_ref2","prop","objectKeys","keys","mediaQueries","key","breakpoints","length","className","breakpointsStyles","getBreakpointsStyles","mediaQueriesStyles","getMediaQueriesFromMQ","trim","getMaxWidthMediaQuery","width","to","Infinity","getMaxHeightMediaQuery","height","_ref3","result","from","normalizePropName","normalizeWebValue","_ref4","breakpoint","undefined","replace","toLowerCase"],"sourceRoot":"../../../src","sources":["utils/cssMediaQuery.ts"],"mappings":"AAAA,SAASA,cAAc,QAAQ,eAAe;AAC9C,SAASC,aAAa,EAAEC,SAAS,EAAEC,OAAO,QAAgC,YAAY;AAEtF,SAASC,wBAAwB,QAAQ,cAAc;AAGvD,OAAO,MAAMC,yBAAyB,GAAGA,CAACC,MAAe,EAAEC,OAAyB,KAAc;EAC9F,MAAMC,gBAAgB,GAAGC,MAAM,CAC1BC,OAAO,CAACJ,MAAM,CAAC,CACfK,MAAM,CAACC,IAAA;IAAA,IAAC,GAAGC,KAAK,CAAC,GAAAD,IAAA;IAAA,OAAK,OAAOC,KAAK,KAAK,QAAQ;EAAA,EAAC,CAChDC,MAAM,CAAC,CAACC,GAAG,EAAAC,KAAA,KAAoB;IAAA,IAAlB,CAACC,IAAI,EAAEJ,KAAK,CAAC,GAAAG,KAAA;IACvB,MAAME,UAAU,GAAGT,MAAM,CAACU,IAAI,CAACN,KAAK,CAAC;IACrC,MAAMO,YAAY,GAAGF,UAAU,CAACP,MAAM,CAACU,GAAG,IAAIpB,aAAa,CAACoB,GAAG,CAAC,CAAC;IACjE,MAAMC,WAAW,GAAGJ,UAAU,CAACP,MAAM,CAACU,GAAG,IAAId,OAAO,CAACe,WAAW,CAACD,GAAG,CAAqC,CAAC;IAE1G,IAAID,YAAY,CAACG,MAAM,KAAK,CAAC,IAAID,WAAW,CAACC,MAAM,KAAK,CAAC,EAAE;MACvD,OAAOR,GAAG;IACd;IAEA,MAAMS,SAAS,GAAGpB,wBAAwB,CAACa,IAAI,EAAE,IAAI,CAAC;IACtD,MAAMQ,iBAAiB,GAAGC,oBAAoB,CAACT,IAAI,EAAEJ,KAAK,EAA6BN,OAAO,EAAEiB,SAAS,CAAC;IAC1G,MAAMG,kBAAkB,GAAGC,qBAAqB,CAACX,IAA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AAiB;MAClB,OAAO,EAAE;;IAEb;IACA,KAAK,kBAAkB;IACvB,KAAK,gBAAgB;IACrB,KAAK,gBAAgB;IACrB,KAAK,uBAAuB;IAC5B,KAAK,yBAAyB;IAC9B,KAAK,aAAa;IAClB,KAAK,WAAW;IAChB,KAAK,oBAAoB;IACzB,KAAK,sBAAsB;IAC3B,KAAK,kBAAkB;IACvB,KAAK,OAAO;IACZ,KAAK,KAAK;IACV,KAAK,YAAY;IACjB,KAAK,cAAc;IACnB,KAAK,aAAa;IAClB,KAAK,eAAe;IACpB,KAAK,kBAAkB;IACvB,KAAK,mBAAmB;IACxB,KAAK,oBAAoB;IACzB,KAAK,YAAY;IACjB,KAAK,cAAc;IACnB,KAAK,WAAW;IAChB;MACI,OAAO,EAAE;EACjB;AACJ,CAAC"}
1
+ {"version":3,"names":["normalizeColor","isUnistylesMq","isValidMq","parseMq","generateReactNativeWebId","createMediaQueryForStyles","styles","runtime","withMediaQueries","Object","entries","filter","value","reduce","acc","prop","objectKeys","keys","mediaQueries","key","breakpoints","length","className","breakpointsStyles","getBreakpointsStyles","mediaQueriesStyles","getMediaQueriesFromMQ","trim","getMaxWidthMediaQuery","width","to","Infinity","getMaxHeightMediaQuery","height","result","from","normalizePropName","normalizeWebValue","breakpoint","undefined","replace","toLowerCase"],"sourceRoot":"../../../src","sources":["utils/cssMediaQuery.ts"],"mappings":"AAAA,SAASA,cAAc,QAAQ,eAAe;AAC9C,SAASC,aAAa,EAAEC,SAAS,EAAEC,OAAO,QAAgC,YAAY;AAEtF,SAASC,wBAAwB,QAAQ,cAAc;AAGvD,OAAO,MAAMC,yBAAyB,GAAGA,CAACC,MAAe,EAAEC,OAAyB,KAAc;EAC9F,MAAMC,gBAAgB,GAAGC,MAAM,CAC1BC,OAAO,CAACJ,MAAM,CAAC,CACfK,MAAM,CAAC,CAAC,GAAGC,KAAK,CAAC,KAAK,OAAOA,KAAK,KAAK,QAAQ,CAAC,CAChDC,MAAM,CAAC,CAACC,GAAG,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