react-native-unistyles 3.0.0-alpha.7 → 3.0.0-alpha.8
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/specs/index.web.js +1 -1
- package/lib/commonjs/web/convert/boxShadow.js +77 -0
- package/lib/commonjs/web/convert/boxShadow.js.map +1 -0
- package/lib/commonjs/web/convert/breakpoint.js +25 -0
- package/lib/commonjs/web/convert/breakpoint.js.map +1 -0
- package/lib/commonjs/web/convert/index.js +76 -0
- package/lib/commonjs/web/convert/index.js.map +1 -0
- package/lib/commonjs/web/convert/module.d.js +2 -0
- package/lib/commonjs/web/convert/module.d.js.map +1 -0
- package/lib/commonjs/web/convert/shadow.js +68 -0
- package/lib/commonjs/web/convert/shadow.js.map +1 -0
- package/lib/commonjs/web/convert/style.js +89 -0
- package/lib/commonjs/web/convert/style.js.map +1 -0
- package/lib/commonjs/web/convert/textShadow.js +73 -0
- package/lib/commonjs/web/convert/textShadow.js.map +1 -0
- package/lib/commonjs/web/convert/transform.js +72 -0
- package/lib/commonjs/web/convert/transform.js.map +1 -0
- package/lib/commonjs/web/convert/types.js +9 -0
- package/lib/commonjs/web/convert/types.js.map +1 -0
- package/lib/commonjs/web/convert/utils.js +55 -0
- package/lib/commonjs/web/convert/utils.js.map +1 -0
- package/lib/commonjs/web/create.js +89 -0
- package/lib/commonjs/web/create.js.map +1 -0
- package/lib/commonjs/web/index.js +51 -0
- package/lib/commonjs/web/index.js.map +1 -0
- package/lib/commonjs/web/listener/index.js +13 -0
- package/lib/commonjs/web/listener/index.js.map +1 -0
- package/lib/commonjs/web/listener/listener.js +36 -0
- package/lib/commonjs/web/listener/listener.js.map +1 -0
- package/lib/commonjs/web/mock.js +37 -0
- package/lib/commonjs/web/mock.js.map +1 -0
- package/lib/commonjs/web/mq.js +23 -0
- package/lib/commonjs/web/mq.js.map +1 -0
- package/lib/commonjs/web/pseudo.js +11 -0
- package/lib/commonjs/web/pseudo.js.map +1 -0
- package/lib/commonjs/web/registry.js +37 -0
- package/lib/commonjs/web/registry.js.map +1 -0
- package/lib/commonjs/web/runtime.js +164 -0
- package/lib/commonjs/web/runtime.js.map +1 -0
- package/lib/commonjs/web/state.js +121 -0
- package/lib/commonjs/web/state.js.map +1 -0
- package/lib/commonjs/web/utils.js +78 -0
- package/lib/commonjs/web/utils.js.map +1 -0
- package/lib/commonjs/web/variants/getVariants.js +39 -0
- package/lib/commonjs/web/variants/getVariants.js.map +1 -0
- package/lib/commonjs/web/variants/index.js +28 -0
- package/lib/commonjs/web/variants/index.js.map +1 -0
- package/lib/commonjs/web/variants/useVariants.js +75 -0
- package/lib/commonjs/web/variants/useVariants.js.map +1 -0
- package/lib/module/specs/index.web.js +1 -1
- package/lib/module/specs/index.web.js.map +1 -1
- package/lib/module/web/convert/boxShadow.js +72 -0
- package/lib/module/web/convert/boxShadow.js.map +1 -0
- package/lib/module/web/convert/breakpoint.js +20 -0
- package/lib/module/web/convert/breakpoint.js.map +1 -0
- package/lib/module/web/convert/index.js +71 -0
- package/lib/module/web/convert/index.js.map +1 -0
- package/lib/module/web/convert/module.d.js +2 -0
- package/lib/module/web/convert/module.d.js.map +1 -0
- package/lib/module/web/convert/shadow.js +63 -0
- package/lib/module/web/convert/shadow.js.map +1 -0
- package/lib/module/web/convert/style.js +84 -0
- package/lib/module/web/convert/style.js.map +1 -0
- package/lib/module/web/convert/textShadow.js +68 -0
- package/lib/module/web/convert/textShadow.js.map +1 -0
- package/lib/module/web/convert/transform.js +67 -0
- package/lib/module/web/convert/transform.js.map +1 -0
- package/lib/module/web/convert/types.js +5 -0
- package/lib/module/web/convert/types.js.map +1 -0
- package/lib/module/web/convert/utils.js +43 -0
- package/lib/module/web/convert/utils.js.map +1 -0
- package/lib/module/web/create.js +84 -0
- package/lib/module/web/create.js.map +1 -0
- package/lib/module/web/index.js +24 -0
- package/lib/module/web/index.js.map +1 -0
- package/lib/module/web/listener/index.js +4 -0
- package/lib/module/web/listener/index.js.map +1 -0
- package/lib/module/web/listener/listener.js +31 -0
- package/lib/module/web/listener/listener.js.map +1 -0
- package/lib/module/web/mock.js +33 -0
- package/lib/module/web/mock.js.map +1 -0
- package/lib/module/web/mq.js +17 -0
- package/lib/module/web/mq.js.map +1 -0
- package/lib/module/web/pseudo.js +6 -0
- package/lib/module/web/pseudo.js.map +1 -0
- package/lib/module/web/registry.js +33 -0
- package/lib/module/web/registry.js.map +1 -0
- package/lib/module/web/runtime.js +160 -0
- package/lib/module/web/runtime.js.map +1 -0
- package/lib/module/web/state.js +117 -0
- package/lib/module/web/state.js.map +1 -0
- package/lib/module/web/utils.js +65 -0
- package/lib/module/web/utils.js.map +1 -0
- package/lib/module/web/variants/getVariants.js +34 -0
- package/lib/module/web/variants/getVariants.js.map +1 -0
- package/lib/module/web/variants/index.js +5 -0
- package/lib/module/web/variants/index.js.map +1 -0
- package/lib/module/web/variants/useVariants.js +70 -0
- package/lib/module/web/variants/useVariants.js.map +1 -0
- package/lib/typescript/src/specs/index.web.d.ts +1 -1
- package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/boxShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/breakpoint.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/convert/index.d.ts +1 -1
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/shadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/style.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/textShadow.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/transform.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/convert/types.d.ts +1 -1
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/create.d.ts +11 -11
- package/lib/typescript/{web → src/web}/create.d.ts.map +1 -1
- package/lib/typescript/{web → src/web}/index.d.ts +12 -12
- package/lib/typescript/{web → src/web}/index.d.ts.map +1 -1
- package/lib/typescript/src/web/listener/index.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/listener/listener.d.ts +1 -1
- package/lib/typescript/src/web/listener/listener.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/mock.d.ts +2 -2
- package/lib/typescript/src/web/mock.d.ts.map +1 -0
- package/lib/typescript/src/web/mq.d.ts.map +1 -0
- package/lib/typescript/src/web/pseudo.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/registry.d.ts +1 -1
- package/lib/typescript/src/web/registry.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/runtime.d.ts +6 -6
- package/lib/typescript/src/web/runtime.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/state.d.ts +4 -4
- package/lib/typescript/src/web/state.d.ts.map +1 -0
- package/lib/typescript/{web → src/web}/utils.d.ts +5 -3
- package/lib/typescript/src/web/utils.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/getVariants.d.ts +3 -0
- package/lib/typescript/src/web/variants/getVariants.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/index.d.ts +3 -0
- package/lib/typescript/src/web/variants/index.d.ts.map +1 -0
- package/lib/typescript/src/web/variants/useVariants.d.ts +3 -0
- package/lib/typescript/src/web/variants/useVariants.d.ts.map +1 -0
- package/package.json +1 -1
- package/plugin/__tests__/ref.spec.js +130 -4
- package/plugin/index.js +12 -13
- package/plugin/ref.js +38 -14
- package/plugin/style.js +13 -7
- package/src/specs/index.web.ts +1 -1
- package/src/types/stylesheet.ts +1 -1
- package/{web → src/web}/convert/breakpoint.ts +1 -1
- package/{web → src/web}/convert/index.ts +1 -1
- package/{web → src/web}/convert/types.ts +1 -1
- package/{web → src/web}/create.ts +36 -33
- package/{web → src/web}/listener/listener.ts +1 -1
- package/{web → src/web}/mock.ts +2 -2
- package/{web → src/web}/registry.ts +1 -1
- package/{web → src/web}/runtime.ts +4 -4
- package/{web → src/web}/state.ts +5 -5
- package/{web → src/web}/utils.ts +5 -5
- package/src/web/variants/getVariants.ts +42 -0
- package/src/web/variants/index.ts +2 -0
- package/{web → src/web/variants}/useVariants.ts +24 -44
- package/lib/typescript/web/convert/boxShadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/breakpoint.d.ts.map +0 -1
- package/lib/typescript/web/convert/index.d.ts.map +0 -1
- package/lib/typescript/web/convert/shadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/style.d.ts.map +0 -1
- package/lib/typescript/web/convert/textShadow.d.ts.map +0 -1
- package/lib/typescript/web/convert/transform.d.ts.map +0 -1
- package/lib/typescript/web/convert/types.d.ts.map +0 -1
- package/lib/typescript/web/convert/utils.d.ts.map +0 -1
- package/lib/typescript/web/listener/index.d.ts.map +0 -1
- package/lib/typescript/web/listener/listener.d.ts.map +0 -1
- package/lib/typescript/web/mock.d.ts.map +0 -1
- package/lib/typescript/web/mq.d.ts.map +0 -1
- package/lib/typescript/web/pseudo.d.ts.map +0 -1
- package/lib/typescript/web/registry.d.ts.map +0 -1
- package/lib/typescript/web/runtime.d.ts.map +0 -1
- package/lib/typescript/web/state.d.ts.map +0 -1
- package/lib/typescript/web/useVariants.d.ts +0 -3
- package/lib/typescript/web/useVariants.d.ts.map +0 -1
- package/lib/typescript/web/utils.d.ts.map +0 -1
- /package/lib/typescript/{web → src/web}/convert/boxShadow.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/breakpoint.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/shadow.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/style.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/textShadow.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/transform.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/convert/utils.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/listener/index.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/mq.d.ts +0 -0
- /package/lib/typescript/{web → src/web}/pseudo.d.ts +0 -0
- /package/{web → src/web}/convert/boxShadow.ts +0 -0
- /package/{web → src/web}/convert/module.d.ts +0 -0
- /package/{web → src/web}/convert/shadow.ts +0 -0
- /package/{web → src/web}/convert/style.ts +0 -0
- /package/{web → src/web}/convert/textShadow.ts +0 -0
- /package/{web → src/web}/convert/transform.ts +0 -0
- /package/{web → src/web}/convert/utils.ts +0 -0
- /package/{web → src/web}/index.ts +0 -0
- /package/{web → src/web}/listener/index.ts +0 -0
- /package/{web → src/web}/mq.ts +0 -0
- /package/{web → src/web}/pseudo.ts +0 -0
@@ -0,0 +1,160 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { UnistyleDependency } from '../specs/NativePlatform';
|
4
|
+
import { ColorScheme, Orientation } from '../specs/types';
|
5
|
+
import { WebContentSizeCategory } from '../types';
|
6
|
+
import { UnistylesListener } from './listener';
|
7
|
+
import { NavigationBar, StatusBar } from './mock';
|
8
|
+
import { UnistylesState } from './state';
|
9
|
+
import { hexToRGBA, isServer, schemeToTheme } from './utils';
|
10
|
+
class UnistylesRuntimeBuilder {
|
11
|
+
lightMedia = this.getLightMedia();
|
12
|
+
darkMedia = this.getDarkMedia();
|
13
|
+
getLightMedia() {
|
14
|
+
if (isServer()) {
|
15
|
+
return null;
|
16
|
+
}
|
17
|
+
if (!this.lightMedia) {
|
18
|
+
this.lightMedia = window.matchMedia('(prefers-color-scheme: light)');
|
19
|
+
}
|
20
|
+
return this.lightMedia;
|
21
|
+
}
|
22
|
+
getDarkMedia() {
|
23
|
+
if (isServer()) {
|
24
|
+
return null;
|
25
|
+
}
|
26
|
+
if (!this.darkMedia) {
|
27
|
+
this.darkMedia = window.matchMedia('(prefers-color-scheme: dark)');
|
28
|
+
}
|
29
|
+
return this.darkMedia;
|
30
|
+
}
|
31
|
+
get colorScheme() {
|
32
|
+
switch (true) {
|
33
|
+
case this.getLightMedia()?.matches:
|
34
|
+
return ColorScheme.Light;
|
35
|
+
case this.getDarkMedia()?.matches:
|
36
|
+
return ColorScheme.Dark;
|
37
|
+
default:
|
38
|
+
return ColorScheme.Unspecified;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
get themeName() {
|
42
|
+
return UnistylesState.themeName;
|
43
|
+
}
|
44
|
+
get contentSizeCategory() {
|
45
|
+
return WebContentSizeCategory.Unspecified;
|
46
|
+
}
|
47
|
+
get breakpoint() {
|
48
|
+
return UnistylesState.breakpoint;
|
49
|
+
}
|
50
|
+
get orientation() {
|
51
|
+
if (isServer()) {
|
52
|
+
return Orientation.Portrait;
|
53
|
+
}
|
54
|
+
return screen.orientation.type.includes('portrait') ? Orientation.Portrait : Orientation.Landscape;
|
55
|
+
}
|
56
|
+
get theme() {
|
57
|
+
if (!this.themeName) {
|
58
|
+
throw new Error('🦄 No theme selected!');
|
59
|
+
}
|
60
|
+
const theme = UnistylesState.themes.get(this.themeName);
|
61
|
+
if (!theme) {
|
62
|
+
throw new Error(`🦄 Theme "${this.themeName}" is not registered!`);
|
63
|
+
}
|
64
|
+
return theme;
|
65
|
+
}
|
66
|
+
get pixelRatio() {
|
67
|
+
return isServer() ? 1 : window.devicePixelRatio;
|
68
|
+
}
|
69
|
+
get screen() {
|
70
|
+
if (isServer()) {
|
71
|
+
return {
|
72
|
+
width: 0,
|
73
|
+
height: 0
|
74
|
+
};
|
75
|
+
}
|
76
|
+
return {
|
77
|
+
width: window.innerWidth,
|
78
|
+
height: window.innerHeight
|
79
|
+
};
|
80
|
+
}
|
81
|
+
get fontScale() {
|
82
|
+
return 1;
|
83
|
+
}
|
84
|
+
get insets() {
|
85
|
+
return {
|
86
|
+
top: 0,
|
87
|
+
bottom: 0,
|
88
|
+
left: 0,
|
89
|
+
right: 0,
|
90
|
+
ime: 0
|
91
|
+
};
|
92
|
+
}
|
93
|
+
get statusBar() {
|
94
|
+
return StatusBar;
|
95
|
+
}
|
96
|
+
get rtl() {
|
97
|
+
return isServer() ? true : document.documentElement.dir === 'rtl';
|
98
|
+
}
|
99
|
+
get hasAdaptiveThemes() {
|
100
|
+
return UnistylesState.hasAdaptiveThemes;
|
101
|
+
}
|
102
|
+
get navigationBar() {
|
103
|
+
return NavigationBar;
|
104
|
+
}
|
105
|
+
get miniRuntime() {
|
106
|
+
return {
|
107
|
+
colorScheme: this.colorScheme,
|
108
|
+
themeName: this.themeName,
|
109
|
+
contentSizeCategory: this.contentSizeCategory,
|
110
|
+
breakpoint: this.breakpoint,
|
111
|
+
orientation: this.orientation,
|
112
|
+
pixelRatio: this.pixelRatio,
|
113
|
+
screen: this.screen,
|
114
|
+
fontScale: this.fontScale,
|
115
|
+
insets: this.insets,
|
116
|
+
statusBar: {
|
117
|
+
width: this.statusBar.width,
|
118
|
+
height: this.statusBar.height
|
119
|
+
},
|
120
|
+
navigationBar: {
|
121
|
+
width: this.navigationBar.width,
|
122
|
+
height: this.navigationBar.height
|
123
|
+
},
|
124
|
+
rtl: this.rtl,
|
125
|
+
hasAdaptiveThemes: this.hasAdaptiveThemes
|
126
|
+
};
|
127
|
+
}
|
128
|
+
setTheme = themeName => {
|
129
|
+
if (themeName === UnistylesRuntime.themeName) {
|
130
|
+
return;
|
131
|
+
}
|
132
|
+
UnistylesState.themeName = themeName;
|
133
|
+
UnistylesListener.emitChange(UnistyleDependency.Theme);
|
134
|
+
UnistylesListener.emitChange(UnistyleDependency.ThemeName);
|
135
|
+
};
|
136
|
+
setAdaptiveThemes = isEnabled => {
|
137
|
+
UnistylesState.hasAdaptiveThemes = isEnabled;
|
138
|
+
if (!isEnabled) {
|
139
|
+
return;
|
140
|
+
}
|
141
|
+
this.setTheme(schemeToTheme(UnistylesRuntime.colorScheme));
|
142
|
+
};
|
143
|
+
setRootViewBackgroundColor = (hex, alpha) => {
|
144
|
+
if (isServer()) {
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
document.documentElement.style.backgroundColor = alpha ? hexToRGBA(hex, alpha) : hex;
|
148
|
+
};
|
149
|
+
setImmersiveMode = () => {};
|
150
|
+
updateTheme = (themeName, updater) => {
|
151
|
+
const oldTheme = UnistylesState.themes.get(themeName);
|
152
|
+
if (!oldTheme) {
|
153
|
+
throw new Error(`🦄 Theme "${themeName}" is not registered!`);
|
154
|
+
}
|
155
|
+
UnistylesState.themes.set(themeName, updater(oldTheme));
|
156
|
+
};
|
157
|
+
getSSRUnistyles = () => UnistylesState.tags;
|
158
|
+
}
|
159
|
+
export const UnistylesRuntime = new UnistylesRuntimeBuilder();
|
160
|
+
//# sourceMappingURL=runtime.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["UnistyleDependency","ColorScheme","Orientation","WebContentSizeCategory","UnistylesListener","NavigationBar","StatusBar","UnistylesState","hexToRGBA","isServer","schemeToTheme","UnistylesRuntimeBuilder","lightMedia","getLightMedia","darkMedia","getDarkMedia","window","matchMedia","colorScheme","matches","Light","Dark","Unspecified","themeName","contentSizeCategory","breakpoint","orientation","Portrait","screen","type","includes","Landscape","theme","Error","themes","get","pixelRatio","devicePixelRatio","width","height","innerWidth","innerHeight","fontScale","insets","top","bottom","left","right","ime","statusBar","rtl","document","documentElement","dir","hasAdaptiveThemes","navigationBar","miniRuntime","setTheme","UnistylesRuntime","emitChange","Theme","ThemeName","setAdaptiveThemes","isEnabled","setRootViewBackgroundColor","hex","alpha","style","backgroundColor","setImmersiveMode","updateTheme","updater","oldTheme","set","getSSRUnistyles","tags"],"sourceRoot":"../../../src","sources":["web/runtime.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,WAAW,EAAEC,WAAW,QAA0C,gBAAgB;AAE3F,SAASC,sBAAsB,QAAQ,UAAU;AACjD,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,aAAa,EAAEC,SAAS,QAAQ,QAAQ;AACjD,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,SAAS,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,SAAS;AAE5D,MAAMC,uBAAuB,CAAC;EAC1BC,UAAU,GAAG,IAAI,CAACC,aAAa,CAAC,C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S,EAAE;MACZ;IACJ;IAEA,IAAI,CAACN,QAAQ,CAAC/C,aAAa,CAACgD,gBAAgB,CAACxC,WAAW,CAAC,CAAC;EAC9D,CAAC;EAED8C,0BAA0B,GAAGA,CAACC,GAAW,EAAEC,KAAc,KAAK;IAC1D,IAAIzD,QAAQ,CAAC,CAAC,EAAE;MACZ;IACJ;IAEA0C,QAAQ,CAACC,eAAe,CAACe,KAAK,CAACC,eAAe,GAAGF,KAAK,GAAG1D,SAAS,CAACyD,GAAG,EAAEC,KAAK,CAAC,GAAGD,GAAG;EACxF,CAAC;EAEDI,gBAAgB,GAAGA,CAAA,KAAM,CAAC,CAAC;EAE3BC,WAAW,GAAGA,CAAC/C,SAAuB,EAAEgD,OAA6C,KAAK;IACtF,MAAMC,QAAQ,GAAGjE,cAAc,CAAC2B,MAAM,CAACC,GAAG,CAACZ,SAAS,CAAC;IAErD,IAAI,CAACiD,QAAQ,EAAE;MACX,MAAM,IAAIvC,KAAK,CAAC,aAAaV,SAAS,sBAAsB,CAAC;IACjE;IAEAhB,cAAc,CAAC2B,MAAM,CAACuC,GAAG,CAAClD,SAAS,EAAEgD,OAAO,CAACC,QAAQ,CAAC,CAAC;EAC3D,CAAC;EAEDE,eAAe,GAAGA,CAAA,KAAMnE,cAAc,CAACoE,IAAI;AAC/C;AAEA,OAAO,MAAMjB,gBAAgB,GAAG,IAAI/C,uBAAuB,CAAC,CAAC","ignoreList":[]}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { createElement, createRef } from 'react';
|
4
|
+
import { UnistylesRuntime } from './runtime';
|
5
|
+
import { isServer, schemeToTheme } from './utils';
|
6
|
+
import { UnistylesListener } from './listener';
|
7
|
+
import { UnistyleDependency } from '../specs/NativePlatform';
|
8
|
+
class UnistylesStateBuilder {
|
9
|
+
isSSR = isServer();
|
10
|
+
tags = [];
|
11
|
+
themes = new Map();
|
12
|
+
hasAdaptiveThemes = false;
|
13
|
+
init = config => {
|
14
|
+
this.initThemes(config.themes);
|
15
|
+
this.initBreakpoints(config.breakpoints);
|
16
|
+
this.initSettings(config.settings);
|
17
|
+
if (this.isSSR) {
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
UnistylesListener.initListeners();
|
21
|
+
};
|
22
|
+
initThemes = (themes = {}) => {
|
23
|
+
Object.entries(themes).forEach(([themeName, theme]) => {
|
24
|
+
this.themes.set(themeName, theme);
|
25
|
+
});
|
26
|
+
};
|
27
|
+
initSettings = settings => {
|
28
|
+
this.hasAdaptiveThemes = settings?.adaptiveThemes ?? false;
|
29
|
+
const themeNames = Array.from(this.themes.keys());
|
30
|
+
|
31
|
+
// Single theme + no settings
|
32
|
+
if (!settings?.adaptiveThemes && !settings?.initialTheme && themeNames.length === 1) {
|
33
|
+
this.themeName = themeNames[0];
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
|
37
|
+
// No settings
|
38
|
+
if (!settings?.adaptiveThemes && !settings?.initialTheme) {
|
39
|
+
throw new Error('🦄 You need to specify either "initialTheme" or "adaptiveThemes" in your config');
|
40
|
+
}
|
41
|
+
|
42
|
+
// Adaptive themes
|
43
|
+
if (settings.adaptiveThemes) {
|
44
|
+
this.themeName = schemeToTheme(UnistylesRuntime.colorScheme);
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
|
48
|
+
// Initial theme
|
49
|
+
this.themeName = typeof settings.initialTheme === 'function' ? settings.initialTheme() : settings.initialTheme;
|
50
|
+
};
|
51
|
+
initBreakpoints = (breakpoints = {}) => {
|
52
|
+
const breakpointsMap = new Map();
|
53
|
+
this.breakpoints = breakpoints;
|
54
|
+
Object.entries(breakpoints).sort(([, a], [, b]) => a - b).forEach(([breakpoint, value]) => {
|
55
|
+
if (isServer()) {
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
const mediaQuery = window.matchMedia(`(min-width: ${value}px)`);
|
59
|
+
breakpointsMap.set(breakpoint, mediaQuery);
|
60
|
+
if (mediaQuery.matches) {
|
61
|
+
this.breakpoint = breakpoint;
|
62
|
+
}
|
63
|
+
mediaQuery.addEventListener('change', event => {
|
64
|
+
if (!event.matches) {
|
65
|
+
const [currentBreakpoint] = Array.from(breakpointsMap).find(([, mq]) => mq.matches) ?? [];
|
66
|
+
if (currentBreakpoint) {
|
67
|
+
this.breakpoint = currentBreakpoint;
|
68
|
+
UnistylesListener.emitChange(UnistyleDependency.Breakpoints);
|
69
|
+
}
|
70
|
+
return;
|
71
|
+
}
|
72
|
+
this.breakpoint = breakpoint;
|
73
|
+
UnistylesListener.emitChange(UnistyleDependency.Breakpoints);
|
74
|
+
});
|
75
|
+
});
|
76
|
+
};
|
77
|
+
createTag() {
|
78
|
+
if (!this.isSSR) {
|
79
|
+
const tag = document.createElement('style');
|
80
|
+
document.head.appendChild(tag);
|
81
|
+
return tag;
|
82
|
+
}
|
83
|
+
const tagRef = new Proxy(/*#__PURE__*/createRef(), {
|
84
|
+
set: (target, prop, value) => {
|
85
|
+
// When ref is assigned
|
86
|
+
if ('textContent' in value) {
|
87
|
+
value.textContent = tag.textContent;
|
88
|
+
}
|
89
|
+
return Reflect.set(target, prop, value);
|
90
|
+
}
|
91
|
+
});
|
92
|
+
const tagElement = /*#__PURE__*/createElement('style', {
|
93
|
+
ref: tagRef,
|
94
|
+
key: this.tags.length
|
95
|
+
}, '');
|
96
|
+
const tag = new Proxy({
|
97
|
+
textContent: ''
|
98
|
+
}, {
|
99
|
+
set: (target, prop, value) => {
|
100
|
+
if (prop !== 'textContent') {
|
101
|
+
return false;
|
102
|
+
}
|
103
|
+
|
104
|
+
// When css is updated
|
105
|
+
target.textContent = value;
|
106
|
+
if (tagRef.current) {
|
107
|
+
tagRef.current.textContent = value;
|
108
|
+
}
|
109
|
+
return true;
|
110
|
+
}
|
111
|
+
});
|
112
|
+
this.tags.push(tagElement);
|
113
|
+
return tag;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
export const UnistylesState = new UnistylesStateBuilder();
|
117
|
+
//# sourceMappingURL=state.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["createElement","createRef","UnistylesRuntime","isServer","schemeToTheme","UnistylesListener","UnistyleDependency","UnistylesStateBuilder","isSSR","tags","themes","Map","hasAdaptiveThemes","init","config","initThemes","initBreakpoints","breakpoints","initSettings","settings","initListeners","Object","entries","forEach","themeName","theme","set","adaptiveThemes","themeNames","Array","from","keys","initialTheme","length","Error","colorScheme","breakpointsMap","sort","a","b","breakpoint","value","mediaQuery","window","matchMedia","matches","addEventListener","event","currentBreakpoint","find","mq","emitChange","Breakpoints","createTag","tag","document","head","appendChild","tagRef","Proxy","target","prop","textContent","Reflect","tagElement","ref","key","current","push","UnistylesState"],"sourceRoot":"../../../src","sources":["web/state.ts"],"mappings":";;AAAA,SAA4BA,aAAa,EAAEC,SAAS,QAAQ,OAAO;AAKnE,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,QAAQ,EAAEC,aAAa,QAAQ,SAAS;AACjD,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,kBAAkB,QAAQ,yBAAyB;AAE5D,MAAMC,qBAAqB,CAAC;EACPC,KAAK,GAAGL,QAAQ,CAAC,CAAC;EAC1BM,IAAI,GAAG,EAAE;EAElBC,MAAM,GAAG,IAAIC,GAAG,CAAyB,CAAC;EAM1CC,iBAAiB,GAAG,KAAK;EAEzBC,IAAI,GAAIC,MAAuB,IAAK;IAChC,IAAI,CAACC,UAAU,CAACD,MAAM,CAACJ,MAAM,CAAC;IAC9B,IAAI,CAACM,eAAe,CAACF,MAAM,CAACG,WAAW,CAAC;IACxC,IAAI,CAACC,YAAY,CAACJ,MAAM,CAACK,QAAQ,CAAC;IAElC,IAAI,IAAI,CAACX,KAAK,EAAE;MACZ;IACJ;IAEAH,iBAAiB,CAACe,aAAa,CAAC,CAAC;EACrC,CAAC;EAEOL,UAAU,GAAGA,CAACL,MAAM,GAAG,CAAC,CAAoB,KAAK;IACrDW,MAAM,CAACC,OAAO,CAACZ,MAAM,CAAC,CAACa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C,EAAE;MACpDyB,GAAG,EAAEA,CAACkC,MAAM,EAAEC,IAAI,EAAEpB,KAAK,KAAK;QAC1B;QACA,IAAI,aAAa,IAAIA,KAAK,EAAE;UACxBA,KAAK,CAACqB,WAAW,GAAGR,GAAG,CAACQ,WAAW;QACvC;QAEA,OAAOC,OAAO,CAACrC,GAAG,CAACkC,MAAM,EAAEC,IAAI,EAAEpB,KAAK,CAAC;MAC3C;IACJ,CAAC,CAAC;IACF,MAAMuB,UAAU,gBAAGhE,aAAa,CAAC,OAAO,EAAE;MAAEiE,GAAG,EAAEP,MAAM;MAAEQ,GAAG,EAAE,IAAI,CAACzD,IAAI,CAACwB;IAAO,CAAC,EAAE,EAAE,CAAC;IACrF,MAAMqB,GAAG,GAAG,IAAIK,KAAK,CAAC;MAAEG,WAAW,EAAE;IAAG,CAAC,EAAE;MACvCpC,GAAG,EAAEA,CAACkC,MAAM,EAAEC,IAAI,EAAEpB,KAAK,KAAK;QAC1B,IAAIoB,IAAI,KAAK,aAAa,EAAE;UACxB,OAAO,KAAK;QAChB;;QAEA;QACAD,MAAM,CAACE,WAAW,GAAGrB,KAAK;QAE1B,IAAIiB,MAAM,CAACS,OAAO,EAAE;UAChBT,MAAM,CAACS,OAAO,CAACL,WAAW,GAAGrB,KAAK;QACtC;QAEA,OAAO,IAAI;MACf;IACJ,CAAC,CAAC;IAEF,IAAI,CAAChC,IAAI,CAAC2D,IAAI,CAACJ,UAAU,CAAC;IAE1B,OAAOV,GAAG;EACd;AACJ;AAEA,OAAO,MAAMe,cAAc,GAAG,IAAI9D,qBAAqB,CAAC,CAAC","ignoreList":[]}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { ColorScheme } from '../specs/types';
|
4
|
+
export const reduceObject = (obj, reducer) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, reducer(value, key)]));
|
5
|
+
export const toReactNativeClassName = (className, values) => {
|
6
|
+
const returnValue = className ? {
|
7
|
+
$$css: true,
|
8
|
+
[className]: className
|
9
|
+
} : {};
|
10
|
+
Object.defineProperties(returnValue, reduceObject(values, value => ({
|
11
|
+
value,
|
12
|
+
enumerable: false,
|
13
|
+
configurable: true
|
14
|
+
})));
|
15
|
+
return returnValue;
|
16
|
+
};
|
17
|
+
export const keyInObject = (obj, key) => key in obj;
|
18
|
+
export const schemeToTheme = scheme => {
|
19
|
+
switch (scheme) {
|
20
|
+
case ColorScheme.Dark:
|
21
|
+
return 'dark';
|
22
|
+
case ColorScheme.Light:
|
23
|
+
default:
|
24
|
+
return 'light';
|
25
|
+
}
|
26
|
+
};
|
27
|
+
export const hexToRGBA = (hex, opacity) => hex.replace('#', '').split(/(?=(?:..)*$)/).map(x => parseInt(x, 16)).filter(num => !isNaN(num)).reduce((acc, color) => `${acc}${color},`, 'rgba(').concat(`${opacity})`);
|
28
|
+
export const isServer = () => typeof window === 'undefined';
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Deeply merges properties of passed object
|
32
|
+
*/
|
33
|
+
export const deepMergeObjects = (...sources) => {
|
34
|
+
const target = {};
|
35
|
+
sources.forEach(source => {
|
36
|
+
Object.keys(source).forEach(key => {
|
37
|
+
const sourceValue = source[key];
|
38
|
+
const targetValue = target[key];
|
39
|
+
if (Object(sourceValue) == sourceValue && Object(targetValue) === targetValue) {
|
40
|
+
// @ts-expect-error - can't assign to generic
|
41
|
+
target[key] = deepMergeObjects(targetValue, sourceValue);
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
|
45
|
+
// @ts-expect-error - can't assign to generic
|
46
|
+
target[key] = sourceValue;
|
47
|
+
});
|
48
|
+
});
|
49
|
+
return target;
|
50
|
+
};
|
51
|
+
export const warn = message => console.warn(`🦄 [react-native-unistyles] ${message}`);
|
52
|
+
export const equal = (a, b) => {
|
53
|
+
if (Object.is(a, b)) {
|
54
|
+
return true;
|
55
|
+
}
|
56
|
+
if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) {
|
57
|
+
return false;
|
58
|
+
}
|
59
|
+
const keysA = Object.keys(a);
|
60
|
+
if (keysA.length !== Object.keys(b).length) {
|
61
|
+
return false;
|
62
|
+
}
|
63
|
+
return keysA.every(key => Object.is(a[key], b[key]) && Object.prototype.hasOwnProperty.call(b, key));
|
64
|
+
};
|
65
|
+
//# sourceMappingURL=utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["ColorScheme","reduceObject","obj","reducer","Object","fromEntries","entries","map","key","value","toReactNativeClassName","className","values","returnValue","$$css","defineProperties","enumerable","configurable","keyInObject","schemeToTheme","scheme","Dark","Light","hexToRGBA","hex","opacity","replace","split","x","parseInt","filter","num","isNaN","reduce","acc","color","concat","isServer","window","deepMergeObjects","sources","target","forEach","source","keys","sourceValue","targetValue","warn","message","console","equal","a","b","is","keysA","length","every","prototype","hasOwnProperty","call"],"sourceRoot":"../../../src","sources":["web/utils.ts"],"mappings":";;AAAA,SAASA,WAAW,QAA0B,gBAAgB;AAG9D,OAAO,MAAMC,YAAY,GAAGA,CACxBC,GAAS,EACTC,OAA+D,KAC9DC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACJ,GAAG,CAAC,CAACK,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK,CAACD,GAAG,EAAEL,OAAO,CAACM,KAAK,EAAsBD,GAAG,CAAC,CAAC,CAAC,CAAoC;AAErJ,OAAO,MAAME,sBAAsB,GAAGA,CAACC,SAAwB,EAAEC,MAAuB,KAAK;EACzF,MAAMC,WAAW,GAAGF,SAAS,GAAG;IAC5BG,KAAK,EAAE,IAAI;IACX,CAACH,SAAS,GAAGA;EACjB,CAAC,GAAG,CAAC,CAAC;EAENP,MAAM,CAACW,gBAAgB,CAACF,WAAW,EAAEZ,YAAY,CAACW,MAAM,EAAEH,KAAK,KAAK;IAChEA,KAAK;IACLO,UAAU,EAAE,KAAK;IACjBC,YAAY,EAAE;EAClB,CAAC,CAAC,CAAC,CAAC;EAEJ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,CAAC0C,WAAW,CAAC,KAAKA,WAAW,EAAE;QAC3E;QACAL,MAAM,CAACjC,GAAG,CAAC,GAAG+B,gBAAgB,CAACO,WAAW,EAAED,WAAW,CAAC;QAExD;MACJ;;MAEA;MACAJ,MAAM,CAACjC,GAAG,CAAC,GAAGqC,WAAW;IAC7B,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,OAAOJ,MAAM;AACjB,CAAC;AAED,OAAO,MAAMM,IAAI,GAAIC,OAAe,IAAKC,OAAO,CAACF,IAAI,CAAC,+BAA+BC,OAAO,EAAE,CAAC;AAE/F,OAAO,MAAME,KAAK,GAAGA,CAAIC,CAAI,EAAEC,CAAI,KAAK;EACpC,IAAIhD,MAAM,CAACiD,EAAE,CAACF,CAAC,EAAEC,CAAC,CAAC,EAAE;IACjB,OAAO,IAAI;EACf;EAEA,IACI,OAAOD,CAAC,KAAK,QAAQ,IAClBA,CAAC,KAAK,IAAI,IACV,OAAOC,CAAC,KAAK,QAAQ,IACrBA,CAAC,KAAK,IAAI,EACf;IACE,OAAO,KAAK;EAChB;EAEA,MAAME,KAAK,GAAGlD,MAAM,CAACwC,IAAI,CAACO,CAAC,CAAmB;EAE9C,IAAIG,KAAK,CAACC,MAAM,KAAKnD,MAAM,CAACwC,IAAI,CAACQ,CAAC,CAAC,CAACG,MAAM,EAAE;IACxC,OAAO,KAAK;EAChB;EAEA,OAAOD,KAAK,CAACE,KAAK,CAAChD,GAAG,IAAIJ,MAAM,CAACiD,EAAE,CAACF,CAAC,CAAC3C,GAAG,CAAC,EAAE4C,CAAC,CAAC5C,GAAG,CAAC,CAAC,IAAIJ,MAAM,CAACqD,SAAS,CAACC,cAAc,CAACC,IAAI,CAACP,CAAC,EAAE5C,GAAG,CAAC,CAAC;AACxG,CAAC","ignoreList":[]}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { deepMergeObjects } from '../utils';
|
4
|
+
const hasVariants = value => 'variants' in value[1];
|
5
|
+
export const getVariants = (styles, selectedVariants) => {
|
6
|
+
return Object.entries(styles).filter(hasVariants).filter(([_key, {
|
7
|
+
variants
|
8
|
+
}]) => Object.keys(variants).some(variant => variant in variants)).map(([key, {
|
9
|
+
variants,
|
10
|
+
compoundVariants = []
|
11
|
+
}]) => {
|
12
|
+
const variantStyles = Object.entries(variants).flatMap(([variant, styles]) => {
|
13
|
+
const selectedVariant = selectedVariants[variant];
|
14
|
+
const selectedVariantStyles = styles[selectedVariant] ?? styles['default'];
|
15
|
+
if (!selectedVariantStyles) {
|
16
|
+
return [];
|
17
|
+
}
|
18
|
+
return selectedVariantStyles;
|
19
|
+
});
|
20
|
+
const compoundVariantStyles = compoundVariants.flatMap(compoundVariant => {
|
21
|
+
const {
|
22
|
+
styles,
|
23
|
+
...conditions
|
24
|
+
} = compoundVariant;
|
25
|
+
if (Object.entries(conditions).some(([variant, value]) => String(selectedVariants[variant]) !== String(value))) {
|
26
|
+
return [];
|
27
|
+
}
|
28
|
+
return styles;
|
29
|
+
});
|
30
|
+
const mergedVariantStyles = deepMergeObjects(...variantStyles, ...compoundVariantStyles);
|
31
|
+
return [key, mergedVariantStyles];
|
32
|
+
});
|
33
|
+
};
|
34
|
+
//# sourceMappingURL=getVariants.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["deepMergeObjects","hasVariants","value","getVariants","styles","selectedVariants","Object","entries","filter","_key","variants","keys","some","variant","map","key","compoundVariants","variantStyles","flatMap","selectedVariant","selectedVariantStyles","compoundVariantStyles","compoundVariant","conditions","String","mergedVariantStyles"],"sourceRoot":"../../../../src","sources":["web/variants/getVariants.ts"],"mappings":";;AACA,SAASA,gBAAgB,QAAQ,UAAU;AAQ3C,MAAMC,WAAW,GAAsBC,KAAkB,IAAgD,UAAU,IAAIA,KAAK,CAAC,CAAC,CAAC;AAE/H,OAAO,MAAMC,WAAW,GAAGA,CAACC,MAAyC,EAAEC,gBAAqC,KAAK;EAC7G,OAAOC,MAAM,CAACC,OA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C;EACrC,CAAC,CAAC;AACV,CAAC","ignoreList":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["web/variants/index.ts"],"mappings":";;AAAA,cAAc,eAAe;AAC7B,cAAc,eAAe","ignoreList":[]}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
import { useMemo, useRef, useState } from 'react';
|
4
|
+
import { equal, reduceObject } from '../utils';
|
5
|
+
import { UnistylesRegistry } from '../registry';
|
6
|
+
import { getVariants } from './getVariants';
|
7
|
+
export const createUseVariants = (styles, setSelectedVariants) => {
|
8
|
+
const useVariants = selectedVariants => {
|
9
|
+
const [unistylesMap] = useState(() => new Map());
|
10
|
+
const [classNameMap] = useState(() => new Map());
|
11
|
+
const [selectedVariantStylesMap] = useState(() => new Map());
|
12
|
+
const lastSelectedVariantsRef = useRef();
|
13
|
+
// Variable that determines if variants have changed and we need to recalculate styles
|
14
|
+
const variantsChanged = !equal(lastSelectedVariantsRef.current, selectedVariants);
|
15
|
+
if (variantsChanged) {
|
16
|
+
lastSelectedVariantsRef.current = selectedVariants;
|
17
|
+
setSelectedVariants(selectedVariants);
|
18
|
+
}
|
19
|
+
const combinedVariantStyles = useMemo(() => {
|
20
|
+
const result = getVariants(styles, selectedVariants);
|
21
|
+
result.forEach(([key, value]) => {
|
22
|
+
selectedVariantStylesMap.set(key, value);
|
23
|
+
});
|
24
|
+
return result;
|
25
|
+
}, [lastSelectedVariantsRef.current]);
|
26
|
+
if (unistylesMap.size === 0 && combinedVariantStyles.length > 0) {
|
27
|
+
combinedVariantStyles.forEach(([key, value]) => {
|
28
|
+
const {
|
29
|
+
className,
|
30
|
+
unistyles
|
31
|
+
} = UnistylesRegistry.createStyles(value, `variant-${key}`);
|
32
|
+
unistylesMap.set(key, unistyles);
|
33
|
+
classNameMap.set(key, className);
|
34
|
+
});
|
35
|
+
}
|
36
|
+
combinedVariantStyles.forEach(([key, value]) => {
|
37
|
+
const styleEntry = styles[key];
|
38
|
+
const unistyles = unistylesMap.get(key);
|
39
|
+
const className = classNameMap.get(key);
|
40
|
+
const selectedVariantStyles = selectedVariantStylesMap.get(key);
|
41
|
+
if (!unistyles || !className) {
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
if (variantsChanged) {
|
45
|
+
UnistylesRegistry.updateStyles(unistyles, value, className);
|
46
|
+
}
|
47
|
+
Object.defineProperties(styleEntry, reduceObject(selectedVariantStyles ?? {}, value => ({
|
48
|
+
value,
|
49
|
+
enumerable: false,
|
50
|
+
configurable: true
|
51
|
+
})));
|
52
|
+
if (styleEntry) {
|
53
|
+
Object.keys(styleEntry ?? {}).forEach(key => {
|
54
|
+
if (!key.startsWith('variant-')) {
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
|
58
|
+
// @ts-expect-error - remove old variants
|
59
|
+
delete styleEntry[key];
|
60
|
+
});
|
61
|
+
// @ts-expect-error - apply variant className
|
62
|
+
styleEntry[className] = className;
|
63
|
+
}
|
64
|
+
});
|
65
|
+
};
|
66
|
+
Object.defineProperty(styles, 'useVariants', {
|
67
|
+
value: useVariants
|
68
|
+
});
|
69
|
+
};
|
70
|
+
//# sourceMappingURL=useVariants.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["useMemo","useRef","useState","equal","reduceObject","UnistylesRegistry","getVariants","createUseVariants","styles","setSelectedVariants","useVariants","selectedVariants","unistylesMap","Map","classNameMap","selectedVariantStylesMap","lastSelectedVariantsRef","variantsChanged","current","combinedVariantStyles","result","forEach","key","value","set","size","length","className","unistyles","createStyles","styleEntry","get","selectedVariantStyles","updateStyles","Object","defineProperties","enumerable","configurable","keys","startsWith","defineProperty"],"sourceRoot":"../../../../src","sources":["web/variants/useVariants.ts"],"mappings":";;AAAA,SAASA,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAGjD,SAASC,KAAK,EAAEC,YAAY,QAAQ,UAAU;AAC9C,SAASC,iBAA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J,CAAC,CAAC;EACN,CAAC;EAEDO,MAAM,CAACM,cAAc,CAAChC,MAAM,EAAE,aAAa,EAAE;IACzCe,KAAK,EAAEb;EACX,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/specs/index.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEzC,eAAO,MAAM,eAAe,QAAe,KAAK,CAAC,YAAY,CAAC,CAAA;AAE9D,cAAc,
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/specs/index.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEzC,eAAO,MAAM,eAAe,QAAe,KAAK,CAAC,YAAY,CAAC,CAAA;AAE9D,cAAc,QAAQ,CAAA"}
|
@@ -5,7 +5,7 @@ import type { UnistylesMiniRuntime } from '../specs';
|
|
5
5
|
import type { ReactNativeStyleSheet } from './breakpoints';
|
6
6
|
import type { ExtractVariantNames } from './variants';
|
7
7
|
import type { CSSProperties } from 'react';
|
8
|
-
import type { Pseudo } from '
|
8
|
+
import type { Pseudo } from '../web/pseudo';
|
9
9
|
type NestedKeys = 'shadowOffset' | 'transform' | 'textShadowOffset';
|
10
10
|
export type UnistyleView = Omit<ViewStyle, NestedKeys>;
|
11
11
|
export type UnistyleText = Omit<TextStyle, NestedKeys>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"stylesheet.d.ts","sourceRoot":"","sources":["../../../../src/types/stylesheet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAC3E,OAAO,KAAK,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AY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,mBAoD/D,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"breakpoint.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/breakpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAMrD,eAAO,MAAM,iBAAiB,eAAgB,MAAM,KAAG,UActD,CAAA"}
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import type { NestedCSSProperties } from 'typestyle/lib/types';
|
2
|
-
import type { UnistylesValues } from '../../
|
2
|
+
import type { UnistylesValues } from '../../types';
|
3
3
|
export declare const convertToTypeStyle: (value: UnistylesValues) => NestedCSSProperties;
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAWlD,eAAO,MAAM,kBAAkB,UAAW,eAAe,wBAiExD,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"shadow.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/shadow.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,qBAAsB,aAAa,CAAC,MAAM,CAAC,UAAU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,eAAe,GAAG,CAAC,MAAM,CAAC,SAiE5H,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/style.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAgF9D,eAAO,MAAM,QAAQ,QAAS,MAAM,SAAS,GAAG,wBAY/C,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"textShadow.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/textShadow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAiB9D,eAAO,MAAM,kBAAkB,WAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,mBAkDhE,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/transform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAK9D,KAAK,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;AAmC5C,eAAO,MAAM,iBAAiB,eAAgB,UAAU,KAAG,mBA+C1D,CAAA"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { TextStyle, ViewStyle } from 'react-native';
|
2
|
-
import type { ToDeepUnistyles } from '../../
|
2
|
+
import type { ToDeepUnistyles } from '../../types/stylesheet';
|
3
3
|
export type ShadowOffset = ToDeepUnistyles<{
|
4
4
|
width: number;
|
5
5
|
height: number;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/web/convert/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE7D,MAAM,MAAM,YAAY,GAAG,eAAe,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAE7E,eAAO,MAAM,kBAAkB,sEAAuE,CAAA;AAEtG,MAAM,MAAM,UAAU,GAAG,Q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