@niibase/uniwind 1.0.0 → 1.0.10
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/dist/common/components/native/react-native-gesture-handler/BaseButton.js +18 -0
- package/dist/common/components/native/react-native-gesture-handler/BorderlessButton.js +18 -0
- package/dist/common/components/native/react-native-gesture-handler/DrawerLayoutAndroid.js +18 -0
- package/dist/common/components/native/react-native-gesture-handler/FlatList.js +30 -0
- package/dist/common/components/native/react-native-gesture-handler/GestureHandlerRootView.js +18 -0
- package/dist/common/components/native/react-native-gesture-handler/Pressable.js +29 -0
- package/dist/common/components/native/react-native-gesture-handler/PureNativeButton.js +18 -0
- package/dist/common/components/native/react-native-gesture-handler/RawButton.js +18 -0
- package/dist/common/components/native/react-native-gesture-handler/RectButton.js +18 -0
- package/dist/common/components/native/react-native-gesture-handler/RefreshControl.js +27 -0
- package/dist/common/components/native/react-native-gesture-handler/ScrollView.js +23 -0
- package/dist/common/components/native/react-native-gesture-handler/Switch.js +32 -0
- package/dist/common/components/native/react-native-gesture-handler/Text.js +36 -0
- package/dist/common/components/native/react-native-gesture-handler/TextInput.js +53 -0
- package/dist/common/components/native/react-native-gesture-handler/TouchableNativeFeedback.js +32 -0
- package/dist/common/components/native/react-native-gesture-handler/TouchableOpacity.js +32 -0
- package/dist/common/components/native/react-native-gesture-handler/TouchableWithoutFeedback.js +32 -0
- package/dist/common/components/native/react-native-gesture-handler/index.js +122 -0
- package/dist/common/components/native/react-native-svg/Svg.js +18 -0
- package/dist/common/components/native/react-native-svg/index.js +35 -0
- package/dist/common/core/native/runtime.js +2 -1
- package/dist/common/core/native/store.js +33 -3
- package/dist/metro/index.cjs +17 -3
- package/dist/metro/index.mjs +17 -3
- package/dist/metro/metro-transformer.cjs +56 -19
- package/dist/metro/metro-transformer.mjs +56 -19
- package/dist/module/components/native/react-native-gesture-handler/BaseButton.d.ts +3 -0
- package/dist/module/components/native/react-native-gesture-handler/BaseButton.js +15 -0
- package/dist/module/components/native/react-native-gesture-handler/BorderlessButton.d.ts +3 -0
- package/dist/module/components/native/react-native-gesture-handler/BorderlessButton.js +18 -0
- package/dist/module/components/native/react-native-gesture-handler/DrawerLayoutAndroid.d.ts +5 -0
- package/dist/module/components/native/react-native-gesture-handler/DrawerLayoutAndroid.js +18 -0
- package/dist/module/components/native/react-native-gesture-handler/FlatList.d.ts +4 -0
- package/dist/module/components/native/react-native-gesture-handler/FlatList.js +27 -0
- package/dist/module/components/native/react-native-gesture-handler/GestureHandlerRootView.d.ts +3 -0
- package/dist/module/components/native/react-native-gesture-handler/GestureHandlerRootView.js +18 -0
- package/dist/module/components/native/react-native-gesture-handler/Pressable.d.ts +3 -0
- package/dist/module/components/native/react-native-gesture-handler/Pressable.js +29 -0
- package/dist/module/components/native/react-native-gesture-handler/PureNativeButton.d.ts +3 -0
- package/dist/module/components/native/react-native-gesture-handler/PureNativeButton.js +15 -0
- package/dist/module/components/native/react-native-gesture-handler/RawButton.d.ts +3 -0
- package/dist/module/components/native/react-native-gesture-handler/RawButton.js +15 -0
- package/dist/module/components/native/react-native-gesture-handler/RectButton.d.ts +3 -0
- package/dist/module/components/native/react-native-gesture-handler/RectButton.js +15 -0
- package/dist/module/components/native/react-native-gesture-handler/RefreshControl.d.ts +3 -0
- package/dist/module/components/native/react-native-gesture-handler/RefreshControl.js +24 -0
- package/dist/module/components/native/react-native-gesture-handler/ScrollView.d.ts +3 -0
- package/dist/module/components/native/react-native-gesture-handler/ScrollView.js +20 -0
- package/dist/module/components/native/react-native-gesture-handler/Switch.d.ts +3 -0
- package/dist/module/components/native/react-native-gesture-handler/Switch.js +26 -0
- package/dist/module/components/native/react-native-gesture-handler/Text.d.ts +2 -0
- package/dist/module/components/native/react-native-gesture-handler/Text.js +33 -0
- package/dist/module/components/native/react-native-gesture-handler/TextInput.d.ts +3 -0
- package/dist/module/components/native/react-native-gesture-handler/TextInput.js +50 -0
- package/dist/module/components/native/react-native-gesture-handler/TouchableNativeFeedback.d.ts +2 -0
- package/dist/module/components/native/react-native-gesture-handler/TouchableNativeFeedback.js +32 -0
- package/dist/module/components/native/react-native-gesture-handler/TouchableOpacity.d.ts +3 -0
- package/dist/module/components/native/react-native-gesture-handler/TouchableOpacity.js +32 -0
- package/dist/module/components/native/react-native-gesture-handler/TouchableWithoutFeedback.d.ts +4 -0
- package/dist/module/components/native/react-native-gesture-handler/TouchableWithoutFeedback.js +34 -0
- package/dist/module/components/native/react-native-gesture-handler/index.d.ts +0 -0
- package/dist/module/components/native/react-native-gesture-handler/index.js +120 -0
- package/dist/module/components/native/react-native-svg/Svg.d.ts +3 -0
- package/dist/module/components/native/react-native-svg/Svg.js +15 -0
- package/dist/module/components/native/react-native-svg/index.d.ts +3 -0
- package/dist/module/components/native/react-native-svg/index.js +3 -0
- package/dist/module/core/native/runtime.js +2 -6
- package/dist/module/core/native/store.d.ts +2 -0
- package/dist/module/core/native/store.js +30 -3
- package/dist/module/core/types.d.ts +10 -0
- package/package.json +6 -1
- package/readme.md +3 -0
- package/src/components/native/react-native-gesture-handler/BaseButton.tsx +18 -0
- package/src/components/native/react-native-gesture-handler/BorderlessButton.tsx +19 -0
- package/src/components/native/react-native-gesture-handler/DrawerLayoutAndroid.tsx +20 -0
- package/src/components/native/react-native-gesture-handler/FlatList.tsx +29 -0
- package/src/components/native/react-native-gesture-handler/GestureHandlerRootView.tsx +20 -0
- package/src/components/native/react-native-gesture-handler/Pressable.tsx +31 -0
- package/src/components/native/react-native-gesture-handler/PureNativeButton.tsx +16 -0
- package/src/components/native/react-native-gesture-handler/RawButton.tsx +16 -0
- package/src/components/native/react-native-gesture-handler/RectButton.tsx +16 -0
- package/src/components/native/react-native-gesture-handler/RefreshControl.tsx +26 -0
- package/src/components/native/react-native-gesture-handler/ScrollView.tsx +22 -0
- package/src/components/native/react-native-gesture-handler/Switch.tsx +29 -0
- package/src/components/native/react-native-gesture-handler/Text.tsx +40 -0
- package/src/components/native/react-native-gesture-handler/TextInput.tsx +53 -0
- package/src/components/native/react-native-gesture-handler/TouchableNativeFeedback.tsx +35 -0
- package/src/components/native/react-native-gesture-handler/TouchableOpacity.tsx +34 -0
- package/src/components/native/react-native-gesture-handler/TouchableWithoutFeedback.tsx +37 -0
- package/src/components/native/react-native-gesture-handler/index.ts +121 -0
- package/src/components/native/react-native-svg/Svg.tsx +16 -0
- package/src/components/native/react-native-svg/index.ts +5 -0
- package/src/core/native/runtime.ts +2 -6
- package/src/core/native/store.ts +51 -5
- package/src/core/types.ts +10 -0
- package/src/metro/compileVirtual.ts +5 -1
- package/src/metro/processor/mq.ts +15 -10
- package/src/metro/processor/processor.ts +55 -16
- package/src/metro/resolvers.ts +22 -2
- package/src/metro/types.ts +3 -2
- package/src/metro/withUniwindConfig.ts +1 -1
- package/types.d.ts +38 -0
- package/uniwind.css +1 -6
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.UniwindRuntime = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
|
+
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
8
9
|
var _types = require("../../types");
|
|
9
10
|
var _nativeUtils = require("./native-utils");
|
|
10
11
|
const window = _reactNative.Dimensions.get("window");
|
|
@@ -20,7 +21,7 @@ const UniwindRuntime = exports.UniwindRuntime = {
|
|
|
20
21
|
fontScale: value => value * _reactNative.PixelRatio.getFontScale(),
|
|
21
22
|
hairlineWidth: _reactNative.StyleSheet.hairlineWidth,
|
|
22
23
|
rtl: _reactNative.I18nManager.isRTL,
|
|
23
|
-
insets: {
|
|
24
|
+
insets: _reactNativeSafeAreaContext.initialWindowMetrics?.insets ?? {
|
|
24
25
|
top: 0,
|
|
25
26
|
left: 0,
|
|
26
27
|
bottom: 0,
|
|
@@ -15,6 +15,7 @@ class UniwindStoreBuilder {
|
|
|
15
15
|
vars = {};
|
|
16
16
|
runtimeThemeVariables = /* @__PURE__ */new Map();
|
|
17
17
|
stylesheet = {};
|
|
18
|
+
varsWithMediaQueries = [];
|
|
18
19
|
cache = /* @__PURE__ */new Map();
|
|
19
20
|
generateStyleSheetCallbackResult = null;
|
|
20
21
|
getStyles(className, state) {
|
|
@@ -43,11 +44,15 @@ class UniwindStoreBuilder {
|
|
|
43
44
|
const {
|
|
44
45
|
scopedVars,
|
|
45
46
|
stylesheet,
|
|
46
|
-
vars
|
|
47
|
+
vars,
|
|
48
|
+
varsWithMediaQueries
|
|
47
49
|
} = config;
|
|
50
|
+
this.vars = varsWithMediaQueries.length > 0 ? {
|
|
51
|
+
...vars
|
|
52
|
+
} : vars;
|
|
53
|
+
this.varsWithMediaQueries = varsWithMediaQueries;
|
|
48
54
|
this.generateStyleSheetCallbackResult = config;
|
|
49
55
|
this.stylesheet = stylesheet;
|
|
50
|
-
this.vars = vars;
|
|
51
56
|
const themeVars = scopedVars[`__uniwind-theme-${this.runtime.currentThemeName}`];
|
|
52
57
|
const platformVars = scopedVars[`__uniwind-platform-${_reactNative.Platform.OS}`];
|
|
53
58
|
const runtimeThemeVars = this.runtimeThemeVariables.get(this.runtime.currentThemeName);
|
|
@@ -64,11 +69,36 @@ class UniwindStoreBuilder {
|
|
|
64
69
|
_listener.UniwindListener.notifyAll();
|
|
65
70
|
}
|
|
66
71
|
};
|
|
72
|
+
resolveMediaQueryVars(dependencies) {
|
|
73
|
+
for (const [varName, mqVariants] of this.varsWithMediaQueries) {
|
|
74
|
+
let bestMatch = null;
|
|
75
|
+
for (const variant of mqVariants) {
|
|
76
|
+
if (variant.orientation !== null) dependencies.add(_types.StyleDependency.Orientation);
|
|
77
|
+
if (variant.maxWidth !== null || variant.minWidth !== null) dependencies.add(_types.StyleDependency.Dimensions);
|
|
78
|
+
if (variant.colorScheme !== null) {
|
|
79
|
+
dependencies.add(_types.StyleDependency.ColorScheme);
|
|
80
|
+
dependencies.add(_types.StyleDependency.Theme);
|
|
81
|
+
}
|
|
82
|
+
if (variant.minWidth !== null && variant.minWidth > this.runtime.screen.width || variant.maxWidth !== null && variant.maxWidth !== Number.MAX_VALUE && variant.maxWidth < this.runtime.screen.width || variant.orientation !== null && this.runtime.orientation !== variant.orientation || variant.colorScheme !== null && this.runtime.currentThemeName !== variant.colorScheme) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (bestMatch === null || (variant.minWidth ?? 0) > (bestMatch.minWidth ?? 0)) bestMatch = variant;
|
|
86
|
+
}
|
|
87
|
+
if (bestMatch !== null) {
|
|
88
|
+
Object.defineProperty(this.vars, varName, {
|
|
89
|
+
configurable: true,
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: () => bestMatch.value
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return this.vars;
|
|
96
|
+
}
|
|
67
97
|
resolveStyles(classNames, state) {
|
|
68
98
|
const result = {};
|
|
69
|
-
let vars = this.vars;
|
|
70
99
|
const dependencies = /* @__PURE__ */new Set();
|
|
71
100
|
const bestBreakpoints = /* @__PURE__ */new Map();
|
|
101
|
+
let vars = this.resolveMediaQueryVars(dependencies);
|
|
72
102
|
for (const className of classNames.split(" ")) {
|
|
73
103
|
if (!(className in this.stylesheet)) {
|
|
74
104
|
continue;
|
package/dist/metro/index.cjs
CHANGED
|
@@ -71,7 +71,7 @@ const SUPPORTED_COMPONENTS = [
|
|
|
71
71
|
"View",
|
|
72
72
|
"VirtualizedList"
|
|
73
73
|
];
|
|
74
|
-
const nativeResolver = ({
|
|
74
|
+
const nativeResolver = (extraComponents) => ({
|
|
75
75
|
context,
|
|
76
76
|
moduleName,
|
|
77
77
|
platform,
|
|
@@ -88,6 +88,12 @@ const nativeResolver = ({
|
|
|
88
88
|
if (moduleName === "react-native") {
|
|
89
89
|
return resolver(context, `${common.name}/components`, platform);
|
|
90
90
|
}
|
|
91
|
+
if (moduleName === "react-native-gesture-handler") {
|
|
92
|
+
return resolver(context, `${common.name}/components/native/react-native-gesture-handler`, platform);
|
|
93
|
+
}
|
|
94
|
+
if (moduleName === "react-native-svg") {
|
|
95
|
+
return resolver(context, `${common.name}/components/native/react-native-svg`, platform);
|
|
96
|
+
}
|
|
91
97
|
if (resolution.filePath.includes(`${node_path.sep}react-native${node_path.sep}Libraries${node_path.sep}`)) {
|
|
92
98
|
const filename = node_path.basename(resolution.filePath.split(node_path.sep).at(-1) ?? "");
|
|
93
99
|
const module = filename.split(".").at(0);
|
|
@@ -95,9 +101,13 @@ const nativeResolver = ({
|
|
|
95
101
|
return resolver(context, `${common.name}/components/${module}`, platform);
|
|
96
102
|
}
|
|
97
103
|
}
|
|
104
|
+
if (moduleName in extraComponents) {
|
|
105
|
+
const componentPath = extraComponents[moduleName];
|
|
106
|
+
return resolver(context, componentPath, platform);
|
|
107
|
+
}
|
|
98
108
|
return resolution;
|
|
99
109
|
};
|
|
100
|
-
const webResolver = ({
|
|
110
|
+
const webResolver = (extraComponents) => ({
|
|
101
111
|
context,
|
|
102
112
|
moduleName,
|
|
103
113
|
platform,
|
|
@@ -107,6 +117,10 @@ const webResolver = ({
|
|
|
107
117
|
if (isFromThisModule(context.originModulePath) || resolution.type !== "sourceFile" || !resolution.filePath.includes(`${node_path.sep}react-native-web${node_path.sep}`)) {
|
|
108
118
|
return resolution;
|
|
109
119
|
}
|
|
120
|
+
if (moduleName in extraComponents) {
|
|
121
|
+
const componentPath = extraComponents[moduleName];
|
|
122
|
+
return resolver(context, componentPath, platform);
|
|
123
|
+
}
|
|
110
124
|
const segments = resolution.filePath.split(node_path.sep);
|
|
111
125
|
const isIndex = segments.at(-1)?.startsWith("index.");
|
|
112
126
|
const module = segments.at(-2);
|
|
@@ -150,7 +164,7 @@ const withUniwindConfig = (config, uniwindConfig) => {
|
|
|
150
164
|
),
|
|
151
165
|
resolveRequest: (context, moduleName, platform) => {
|
|
152
166
|
const resolver = config.resolver?.resolveRequest ?? context.resolveRequest;
|
|
153
|
-
const platformResolver = platform === types.Platform.Web ? webResolver : nativeResolver;
|
|
167
|
+
const platformResolver = (platform === types.Platform.Web ? webResolver : nativeResolver)(uniwindConfig.extraComponents ?? {});
|
|
154
168
|
const resolved = platformResolver({
|
|
155
169
|
context,
|
|
156
170
|
moduleName,
|
package/dist/metro/index.mjs
CHANGED
|
@@ -63,7 +63,7 @@ const SUPPORTED_COMPONENTS = [
|
|
|
63
63
|
"View",
|
|
64
64
|
"VirtualizedList"
|
|
65
65
|
];
|
|
66
|
-
const nativeResolver = ({
|
|
66
|
+
const nativeResolver = (extraComponents) => ({
|
|
67
67
|
context,
|
|
68
68
|
moduleName,
|
|
69
69
|
platform,
|
|
@@ -80,6 +80,12 @@ const nativeResolver = ({
|
|
|
80
80
|
if (moduleName === "react-native") {
|
|
81
81
|
return resolver(context, `${name}/components`, platform);
|
|
82
82
|
}
|
|
83
|
+
if (moduleName === "react-native-gesture-handler") {
|
|
84
|
+
return resolver(context, `${name}/components/native/react-native-gesture-handler`, platform);
|
|
85
|
+
}
|
|
86
|
+
if (moduleName === "react-native-svg") {
|
|
87
|
+
return resolver(context, `${name}/components/native/react-native-svg`, platform);
|
|
88
|
+
}
|
|
83
89
|
if (resolution.filePath.includes(`${sep}react-native${sep}Libraries${sep}`)) {
|
|
84
90
|
const filename = basename(resolution.filePath.split(sep).at(-1) ?? "");
|
|
85
91
|
const module = filename.split(".").at(0);
|
|
@@ -87,9 +93,13 @@ const nativeResolver = ({
|
|
|
87
93
|
return resolver(context, `${name}/components/${module}`, platform);
|
|
88
94
|
}
|
|
89
95
|
}
|
|
96
|
+
if (moduleName in extraComponents) {
|
|
97
|
+
const componentPath = extraComponents[moduleName];
|
|
98
|
+
return resolver(context, componentPath, platform);
|
|
99
|
+
}
|
|
90
100
|
return resolution;
|
|
91
101
|
};
|
|
92
|
-
const webResolver = ({
|
|
102
|
+
const webResolver = (extraComponents) => ({
|
|
93
103
|
context,
|
|
94
104
|
moduleName,
|
|
95
105
|
platform,
|
|
@@ -99,6 +109,10 @@ const webResolver = ({
|
|
|
99
109
|
if (isFromThisModule(context.originModulePath) || resolution.type !== "sourceFile" || !resolution.filePath.includes(`${sep}react-native-web${sep}`)) {
|
|
100
110
|
return resolution;
|
|
101
111
|
}
|
|
112
|
+
if (moduleName in extraComponents) {
|
|
113
|
+
const componentPath = extraComponents[moduleName];
|
|
114
|
+
return resolver(context, componentPath, platform);
|
|
115
|
+
}
|
|
102
116
|
const segments = resolution.filePath.split(sep);
|
|
103
117
|
const isIndex = segments.at(-1)?.startsWith("index.");
|
|
104
118
|
const module = segments.at(-2);
|
|
@@ -142,7 +156,7 @@ const withUniwindConfig = (config, uniwindConfig) => {
|
|
|
142
156
|
),
|
|
143
157
|
resolveRequest: (context, moduleName, platform) => {
|
|
144
158
|
const resolver = config.resolver?.resolveRequest ?? context.resolveRequest;
|
|
145
|
-
const platformResolver = platform === Platform.Web ? webResolver : nativeResolver;
|
|
159
|
+
const platformResolver = (platform === Platform.Web ? webResolver : nativeResolver)(uniwindConfig.extraComponents ?? {});
|
|
146
160
|
const resolved = platformResolver({
|
|
147
161
|
context,
|
|
148
162
|
moduleName,
|
|
@@ -898,23 +898,29 @@ class MQ {
|
|
|
898
898
|
}
|
|
899
899
|
processMediaQueries(mediaQueries) {
|
|
900
900
|
const mq = this.getInitialMediaQueryResolver();
|
|
901
|
-
|
|
901
|
+
for (const mediaQuery of mediaQueries) {
|
|
902
902
|
const { condition, mediaType } = mediaQuery;
|
|
903
903
|
if ([types.Platform.Android, types.Platform.iOS, types.Platform.Native].includes(mediaType)) {
|
|
904
904
|
mq.platform = mediaType;
|
|
905
|
-
|
|
906
|
-
}
|
|
907
|
-
if (condition?.type !== "feature") {
|
|
908
|
-
return;
|
|
905
|
+
continue;
|
|
909
906
|
}
|
|
907
|
+
if (condition) this.processCondition(condition, mq);
|
|
908
|
+
}
|
|
909
|
+
return mq;
|
|
910
|
+
}
|
|
911
|
+
processCondition(condition, mq) {
|
|
912
|
+
if (condition.type === "operation") {
|
|
913
|
+
condition.conditions.forEach((nestedCondition) => {
|
|
914
|
+
this.processCondition(nestedCondition, mq);
|
|
915
|
+
});
|
|
916
|
+
} else if (condition.type === "feature") {
|
|
910
917
|
if (condition.value.type === "range") {
|
|
911
918
|
this.processWidthMediaQuery(condition.value, mq);
|
|
912
919
|
}
|
|
913
920
|
if (condition.value.type === "plain") {
|
|
914
921
|
this.processPlainMediaQuery(condition.value, mq);
|
|
915
922
|
}
|
|
916
|
-
}
|
|
917
|
-
return mq;
|
|
923
|
+
}
|
|
918
924
|
}
|
|
919
925
|
processWidthMediaQuery(query, mq) {
|
|
920
926
|
const { operator, value } = query;
|
|
@@ -1250,6 +1256,7 @@ class ProcessorBuilder {
|
|
|
1250
1256
|
stylesheets = {};
|
|
1251
1257
|
vars = {};
|
|
1252
1258
|
scopedVars = {};
|
|
1259
|
+
varsWithMediaQueries = {};
|
|
1253
1260
|
CSS = new CSS(this);
|
|
1254
1261
|
RN = new RN(this);
|
|
1255
1262
|
Var = new Var(this);
|
|
@@ -1283,6 +1290,32 @@ class ProcessorBuilder {
|
|
|
1283
1290
|
disabled: null
|
|
1284
1291
|
};
|
|
1285
1292
|
}
|
|
1293
|
+
storeVarWithMediaQuery(varName, value, mq) {
|
|
1294
|
+
if (!Array.isArray(this.varsWithMediaQueries[varName])) {
|
|
1295
|
+
this.varsWithMediaQueries[varName] = [];
|
|
1296
|
+
}
|
|
1297
|
+
this.varsWithMediaQueries[varName].push({
|
|
1298
|
+
value,
|
|
1299
|
+
minWidth: mq.minWidth,
|
|
1300
|
+
maxWidth: mq.maxWidth,
|
|
1301
|
+
orientation: mq.orientation ? `'${mq.orientation}'` : null,
|
|
1302
|
+
colorScheme: mq.colorScheme ? `'${mq.colorScheme}'` : null
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
hasMediaQuery(mq) {
|
|
1306
|
+
return mq.minWidth !== 0 || mq.maxWidth !== Number.MAX_VALUE || mq.orientation !== null || mq.colorScheme !== null;
|
|
1307
|
+
}
|
|
1308
|
+
processDeclarationValue(mq, varName, processedValue, context) {
|
|
1309
|
+
const { isVar, style, important } = context;
|
|
1310
|
+
if (isVar && this.hasMediaQuery(mq)) {
|
|
1311
|
+
this.storeVarWithMediaQuery(varName, processedValue, mq);
|
|
1312
|
+
} else {
|
|
1313
|
+
style[varName] = processedValue;
|
|
1314
|
+
}
|
|
1315
|
+
if (!isVar && important) {
|
|
1316
|
+
style.importantProperties.push(varName);
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1286
1319
|
addDeclaration(declaration, important = false) {
|
|
1287
1320
|
const isVar = this.declarationConfig.root || this.declarationConfig.className === null;
|
|
1288
1321
|
const mq = this.MQ.processMediaQueries(this.declarationConfig.mediaQueries);
|
|
@@ -1312,24 +1345,22 @@ class ProcessorBuilder {
|
|
|
1312
1345
|
style.disabled = this.declarationConfig.disabled;
|
|
1313
1346
|
this.meta.className = this.declarationConfig.className;
|
|
1314
1347
|
}
|
|
1348
|
+
const context = { isVar, style, important };
|
|
1315
1349
|
if (declaration.property === "unparsed") {
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
}
|
|
1350
|
+
const varName2 = declaration.value.propertyId.property;
|
|
1351
|
+
const processedValue2 = this.CSS.processValue(declaration.value.value);
|
|
1352
|
+
this.processDeclarationValue(mq, varName2, processedValue2, context);
|
|
1320
1353
|
return;
|
|
1321
1354
|
}
|
|
1322
1355
|
if (declaration.property === "custom") {
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
}
|
|
1356
|
+
const varName2 = declaration.value.name;
|
|
1357
|
+
const processedValue2 = this.CSS.processValue(declaration.value.value);
|
|
1358
|
+
this.processDeclarationValue(mq, varName2, processedValue2, context);
|
|
1327
1359
|
return;
|
|
1328
1360
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
}
|
|
1361
|
+
const varName = declaration.property;
|
|
1362
|
+
const processedValue = this.CSS.processValue(declaration.value);
|
|
1363
|
+
this.processDeclarationValue(mq, varName, processedValue, context);
|
|
1333
1364
|
}
|
|
1334
1365
|
parseRuleRec(rule) {
|
|
1335
1366
|
if (this.declarationConfig.className !== null) {
|
|
@@ -1417,6 +1448,10 @@ class ProcessorBuilder {
|
|
|
1417
1448
|
this.parseRuleRec(rule2);
|
|
1418
1449
|
this.declarationConfig = this.getDeclarationConfig();
|
|
1419
1450
|
});
|
|
1451
|
+
this.declarationConfig.mediaQueries.splice(
|
|
1452
|
+
this.declarationConfig.mediaQueries.length - mediaQueries.length,
|
|
1453
|
+
mediaQueries.length
|
|
1454
|
+
);
|
|
1420
1455
|
return;
|
|
1421
1456
|
}
|
|
1422
1457
|
if (rule.type === "layer-block") {
|
|
@@ -1470,12 +1505,14 @@ const compileVirtual = async ({ css, cssPath, platform, themes, polyfills, debug
|
|
|
1470
1505
|
serializeJSObject(scopedVars2, (key, value) => `get "${key}"() { return ${value} }`)
|
|
1471
1506
|
])
|
|
1472
1507
|
);
|
|
1508
|
+
const varsWithMediaQueries = Object.entries(Processor.varsWithMediaQueries).map(([key, value]) => `["${key}", ${serialize(value)}]`).join(",");
|
|
1473
1509
|
const serializedScopedVars = Object.entries(scopedVars).map(([scopedVarsName, scopedVars2]) => `"${scopedVarsName}": ({ ${scopedVars2} }),`).join("");
|
|
1474
1510
|
const currentColorVar = `get currentColor() { return rt.colorScheme === 'dark' ? '#ffffff' : '#000000' },`;
|
|
1475
1511
|
return [
|
|
1476
1512
|
"({",
|
|
1477
1513
|
`scopedVars: ({ ${serializedScopedVars} }),`,
|
|
1478
1514
|
`vars: ({ ${currentColorVar} ${vars} }),`,
|
|
1515
|
+
`varsWithMediaQueries: ([ ${varsWithMediaQueries} ]),`,
|
|
1479
1516
|
`stylesheet: ({ ${stylesheet} }),`,
|
|
1480
1517
|
"})"
|
|
1481
1518
|
].join("");
|
|
@@ -891,23 +891,29 @@ class MQ {
|
|
|
891
891
|
}
|
|
892
892
|
processMediaQueries(mediaQueries) {
|
|
893
893
|
const mq = this.getInitialMediaQueryResolver();
|
|
894
|
-
|
|
894
|
+
for (const mediaQuery of mediaQueries) {
|
|
895
895
|
const { condition, mediaType } = mediaQuery;
|
|
896
896
|
if ([Platform.Android, Platform.iOS, Platform.Native].includes(mediaType)) {
|
|
897
897
|
mq.platform = mediaType;
|
|
898
|
-
|
|
899
|
-
}
|
|
900
|
-
if (condition?.type !== "feature") {
|
|
901
|
-
return;
|
|
898
|
+
continue;
|
|
902
899
|
}
|
|
900
|
+
if (condition) this.processCondition(condition, mq);
|
|
901
|
+
}
|
|
902
|
+
return mq;
|
|
903
|
+
}
|
|
904
|
+
processCondition(condition, mq) {
|
|
905
|
+
if (condition.type === "operation") {
|
|
906
|
+
condition.conditions.forEach((nestedCondition) => {
|
|
907
|
+
this.processCondition(nestedCondition, mq);
|
|
908
|
+
});
|
|
909
|
+
} else if (condition.type === "feature") {
|
|
903
910
|
if (condition.value.type === "range") {
|
|
904
911
|
this.processWidthMediaQuery(condition.value, mq);
|
|
905
912
|
}
|
|
906
913
|
if (condition.value.type === "plain") {
|
|
907
914
|
this.processPlainMediaQuery(condition.value, mq);
|
|
908
915
|
}
|
|
909
|
-
}
|
|
910
|
-
return mq;
|
|
916
|
+
}
|
|
911
917
|
}
|
|
912
918
|
processWidthMediaQuery(query, mq) {
|
|
913
919
|
const { operator, value } = query;
|
|
@@ -1243,6 +1249,7 @@ class ProcessorBuilder {
|
|
|
1243
1249
|
stylesheets = {};
|
|
1244
1250
|
vars = {};
|
|
1245
1251
|
scopedVars = {};
|
|
1252
|
+
varsWithMediaQueries = {};
|
|
1246
1253
|
CSS = new CSS(this);
|
|
1247
1254
|
RN = new RN(this);
|
|
1248
1255
|
Var = new Var(this);
|
|
@@ -1276,6 +1283,32 @@ class ProcessorBuilder {
|
|
|
1276
1283
|
disabled: null
|
|
1277
1284
|
};
|
|
1278
1285
|
}
|
|
1286
|
+
storeVarWithMediaQuery(varName, value, mq) {
|
|
1287
|
+
if (!Array.isArray(this.varsWithMediaQueries[varName])) {
|
|
1288
|
+
this.varsWithMediaQueries[varName] = [];
|
|
1289
|
+
}
|
|
1290
|
+
this.varsWithMediaQueries[varName].push({
|
|
1291
|
+
value,
|
|
1292
|
+
minWidth: mq.minWidth,
|
|
1293
|
+
maxWidth: mq.maxWidth,
|
|
1294
|
+
orientation: mq.orientation ? `'${mq.orientation}'` : null,
|
|
1295
|
+
colorScheme: mq.colorScheme ? `'${mq.colorScheme}'` : null
|
|
1296
|
+
});
|
|
1297
|
+
}
|
|
1298
|
+
hasMediaQuery(mq) {
|
|
1299
|
+
return mq.minWidth !== 0 || mq.maxWidth !== Number.MAX_VALUE || mq.orientation !== null || mq.colorScheme !== null;
|
|
1300
|
+
}
|
|
1301
|
+
processDeclarationValue(mq, varName, processedValue, context) {
|
|
1302
|
+
const { isVar, style, important } = context;
|
|
1303
|
+
if (isVar && this.hasMediaQuery(mq)) {
|
|
1304
|
+
this.storeVarWithMediaQuery(varName, processedValue, mq);
|
|
1305
|
+
} else {
|
|
1306
|
+
style[varName] = processedValue;
|
|
1307
|
+
}
|
|
1308
|
+
if (!isVar && important) {
|
|
1309
|
+
style.importantProperties.push(varName);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1279
1312
|
addDeclaration(declaration, important = false) {
|
|
1280
1313
|
const isVar = this.declarationConfig.root || this.declarationConfig.className === null;
|
|
1281
1314
|
const mq = this.MQ.processMediaQueries(this.declarationConfig.mediaQueries);
|
|
@@ -1305,24 +1338,22 @@ class ProcessorBuilder {
|
|
|
1305
1338
|
style.disabled = this.declarationConfig.disabled;
|
|
1306
1339
|
this.meta.className = this.declarationConfig.className;
|
|
1307
1340
|
}
|
|
1341
|
+
const context = { isVar, style, important };
|
|
1308
1342
|
if (declaration.property === "unparsed") {
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
}
|
|
1343
|
+
const varName2 = declaration.value.propertyId.property;
|
|
1344
|
+
const processedValue2 = this.CSS.processValue(declaration.value.value);
|
|
1345
|
+
this.processDeclarationValue(mq, varName2, processedValue2, context);
|
|
1313
1346
|
return;
|
|
1314
1347
|
}
|
|
1315
1348
|
if (declaration.property === "custom") {
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
}
|
|
1349
|
+
const varName2 = declaration.value.name;
|
|
1350
|
+
const processedValue2 = this.CSS.processValue(declaration.value.value);
|
|
1351
|
+
this.processDeclarationValue(mq, varName2, processedValue2, context);
|
|
1320
1352
|
return;
|
|
1321
1353
|
}
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
}
|
|
1354
|
+
const varName = declaration.property;
|
|
1355
|
+
const processedValue = this.CSS.processValue(declaration.value);
|
|
1356
|
+
this.processDeclarationValue(mq, varName, processedValue, context);
|
|
1326
1357
|
}
|
|
1327
1358
|
parseRuleRec(rule) {
|
|
1328
1359
|
if (this.declarationConfig.className !== null) {
|
|
@@ -1410,6 +1441,10 @@ class ProcessorBuilder {
|
|
|
1410
1441
|
this.parseRuleRec(rule2);
|
|
1411
1442
|
this.declarationConfig = this.getDeclarationConfig();
|
|
1412
1443
|
});
|
|
1444
|
+
this.declarationConfig.mediaQueries.splice(
|
|
1445
|
+
this.declarationConfig.mediaQueries.length - mediaQueries.length,
|
|
1446
|
+
mediaQueries.length
|
|
1447
|
+
);
|
|
1413
1448
|
return;
|
|
1414
1449
|
}
|
|
1415
1450
|
if (rule.type === "layer-block") {
|
|
@@ -1463,12 +1498,14 @@ const compileVirtual = async ({ css, cssPath, platform, themes, polyfills, debug
|
|
|
1463
1498
|
serializeJSObject(scopedVars2, (key, value) => `get "${key}"() { return ${value} }`)
|
|
1464
1499
|
])
|
|
1465
1500
|
);
|
|
1501
|
+
const varsWithMediaQueries = Object.entries(Processor.varsWithMediaQueries).map(([key, value]) => `["${key}", ${serialize(value)}]`).join(",");
|
|
1466
1502
|
const serializedScopedVars = Object.entries(scopedVars).map(([scopedVarsName, scopedVars2]) => `"${scopedVarsName}": ({ ${scopedVars2} }),`).join("");
|
|
1467
1503
|
const currentColorVar = `get currentColor() { return rt.colorScheme === 'dark' ? '#ffffff' : '#000000' },`;
|
|
1468
1504
|
return [
|
|
1469
1505
|
"({",
|
|
1470
1506
|
`scopedVars: ({ ${serializedScopedVars} }),`,
|
|
1471
1507
|
`vars: ({ ${currentColorVar} ${vars} }),`,
|
|
1508
|
+
`varsWithMediaQueries: ([ ${varsWithMediaQueries} ]),`,
|
|
1472
1509
|
`stylesheet: ({ ${stylesheet} }),`,
|
|
1473
1510
|
"})"
|
|
1474
1511
|
].join("");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BaseButton as RNGHBaseButton } from "react-native-gesture-handler";
|
|
3
|
+
import { copyComponentProperties } from "../../utils.js";
|
|
4
|
+
import { useStyle } from "../useStyle.js";
|
|
5
|
+
export const BaseButton = copyComponentProperties(RNGHBaseButton, (props) => {
|
|
6
|
+
const style = useStyle(props.className);
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
RNGHBaseButton,
|
|
9
|
+
{
|
|
10
|
+
...props,
|
|
11
|
+
style: [style, props.style]
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
export default BaseButton;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { BorderlessButtonProps } from 'react-native-gesture-handler';
|
|
2
|
+
export declare const BorderlessButton: import("react").ForwardRefExoticComponent<Omit<BorderlessButtonProps, "innerRef"> & import("react").RefAttributes<import("react").ComponentType<{}>>>;
|
|
3
|
+
export default BorderlessButton;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BorderlessButton as RNGHBorderlessButton } from "react-native-gesture-handler";
|
|
3
|
+
import { copyComponentProperties } from "../../utils.js";
|
|
4
|
+
import { useStyle } from "../useStyle.js";
|
|
5
|
+
export const BorderlessButton = copyComponentProperties(
|
|
6
|
+
RNGHBorderlessButton,
|
|
7
|
+
(props) => {
|
|
8
|
+
const style = useStyle(props.className);
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
RNGHBorderlessButton,
|
|
11
|
+
{
|
|
12
|
+
...props,
|
|
13
|
+
style: [style, props.style]
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
export default BorderlessButton;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DrawerLayoutAndroidProps } from 'react-native';
|
|
2
|
+
export declare const DrawerLayoutAndroid: import("react").ForwardRefExoticComponent<DrawerLayoutAndroidProps & {
|
|
3
|
+
children?: React.ReactNode | undefined;
|
|
4
|
+
} & import("react-native-gesture-handler").NativeViewGestureHandlerProps & import("react").RefAttributes<import("react").ComponentType<any>>>;
|
|
5
|
+
export default DrawerLayoutAndroid;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DrawerLayoutAndroid as RNGHDrawerLayoutAndroid } from "react-native-gesture-handler";
|
|
3
|
+
import { copyComponentProperties } from "../../utils.js";
|
|
4
|
+
import { useStyle } from "../useStyle.js";
|
|
5
|
+
export const DrawerLayoutAndroid = copyComponentProperties(
|
|
6
|
+
RNGHDrawerLayoutAndroid,
|
|
7
|
+
(props) => {
|
|
8
|
+
const style = useStyle(props.className);
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
RNGHDrawerLayoutAndroid,
|
|
11
|
+
{
|
|
12
|
+
...props,
|
|
13
|
+
style: [style, props.style]
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
export default DrawerLayoutAndroid;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FlatListProps } from 'react-native';
|
|
2
|
+
import { FlatList as RNGHFlatList } from 'react-native-gesture-handler';
|
|
3
|
+
export declare const FlatList: <ItemT = any>(props: import("react").PropsWithChildren<Omit<FlatListProps<ItemT>, "renderScrollComponent"> & import("react").RefAttributes<RNGHFlatList<ItemT>> & import("react-native-gesture-handler").NativeViewGestureHandlerProps>, ref?: import("react").ForwardedRef<RNGHFlatList<ItemT>>) => import("react").ReactElement | null;
|
|
4
|
+
export default FlatList;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FlatList as RNGHFlatList } from "react-native-gesture-handler";
|
|
3
|
+
import { useUniwindAccent } from "../../../hooks/index.js";
|
|
4
|
+
import { copyComponentProperties } from "../../utils.js";
|
|
5
|
+
import { useStyle } from "../useStyle.js";
|
|
6
|
+
export const FlatList = copyComponentProperties(RNGHFlatList, (props) => {
|
|
7
|
+
const style = useStyle(props.className);
|
|
8
|
+
const styleColumnWrapper = useStyle(props.columnWrapperClassName);
|
|
9
|
+
const styleContentContainer = useStyle(props.contentContainerClassName);
|
|
10
|
+
const styleListFooterComponent = useStyle(props.ListFooterComponentClassName);
|
|
11
|
+
const styleListHeaderComponent = useStyle(props.ListHeaderComponentClassName);
|
|
12
|
+
const endFillColor = useUniwindAccent(props.endFillColorClassName);
|
|
13
|
+
const hasSingleColumn = !("numColumns" in props) || props.numColumns === 1;
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
RNGHFlatList,
|
|
16
|
+
{
|
|
17
|
+
...props,
|
|
18
|
+
style: [style, props.style],
|
|
19
|
+
columnWrapperStyle: hasSingleColumn ? void 0 : [styleColumnWrapper, props.columnWrapperStyle],
|
|
20
|
+
contentContainerStyle: [styleContentContainer, props.contentContainerStyle],
|
|
21
|
+
ListFooterComponentStyle: [styleListFooterComponent, props.ListFooterComponentStyle],
|
|
22
|
+
ListHeaderComponentStyle: [styleListHeaderComponent, props.ListHeaderComponentStyle],
|
|
23
|
+
endFillColor: props.endFillColor ?? endFillColor
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
export default FlatList;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { GestureHandlerRootView as RNGestureHandlerRootView } from "react-native-gesture-handler";
|
|
3
|
+
import { copyComponentProperties } from "../../utils.js";
|
|
4
|
+
import { useStyle } from "../useStyle.js";
|
|
5
|
+
export const GestureHandlerRootView = copyComponentProperties(
|
|
6
|
+
RNGestureHandlerRootView,
|
|
7
|
+
(props) => {
|
|
8
|
+
const style = useStyle(props.className);
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
RNGestureHandlerRootView,
|
|
11
|
+
{
|
|
12
|
+
...props,
|
|
13
|
+
style: [style, props.style]
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
export default GestureHandlerRootView;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Pressable as RNGHPressable } from "react-native-gesture-handler";
|
|
3
|
+
import { UniwindStore } from "../../../core/native/index.js";
|
|
4
|
+
import { copyComponentProperties } from "../../utils.js";
|
|
5
|
+
import { useStyle } from "../useStyle.js";
|
|
6
|
+
export const Pressable = copyComponentProperties(RNGHPressable, (props) => {
|
|
7
|
+
const style = useStyle(props.className, {
|
|
8
|
+
isDisabled: Boolean(props.disabled)
|
|
9
|
+
});
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
RNGHPressable,
|
|
12
|
+
{
|
|
13
|
+
...props,
|
|
14
|
+
style: (state) => {
|
|
15
|
+
if (state.pressed) {
|
|
16
|
+
return [
|
|
17
|
+
UniwindStore.getStyles(
|
|
18
|
+
props.className,
|
|
19
|
+
{ isDisabled: Boolean(props.disabled), isPressed: true }
|
|
20
|
+
).styles,
|
|
21
|
+
typeof props.style === "function" ? props.style(state) : props.style
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
return [style, typeof props.style === "function" ? props.style(state) : props.style];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
export default Pressable;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PureNativeButton as RNGHPureNativeButton } from "react-native-gesture-handler";
|
|
3
|
+
import { copyComponentProperties } from "../../utils.js";
|
|
4
|
+
import { useStyle } from "../useStyle.js";
|
|
5
|
+
export const PureNativeButton = copyComponentProperties(RNGHPureNativeButton, (props) => {
|
|
6
|
+
const style = useStyle(props.className);
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
RNGHPureNativeButton,
|
|
9
|
+
{
|
|
10
|
+
...props,
|
|
11
|
+
style: [style, props.style]
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
export default PureNativeButton;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { RawButtonProps } from 'react-native-gesture-handler';
|
|
2
|
+
export declare const RawButton: import("react").ForwardRefExoticComponent<RawButtonProps & import("react-native-gesture-handler").NativeViewGestureHandlerProps & import("react").RefAttributes<import("react").ComponentType<any>>>;
|
|
3
|
+
export default RawButton;
|