@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
package/src/core/native/store.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable max-depth */
|
|
2
2
|
import { Dimensions, Platform } from 'react-native'
|
|
3
|
-
import { Orientation, StyleDependency } from '../../types'
|
|
3
|
+
import { ColorScheme, Orientation, StyleDependency } from '../../types'
|
|
4
4
|
import { UniwindListener } from '../listener'
|
|
5
5
|
import { ComponentState, CSSVariables, GenerateStyleSheetsCallback, RNStyle, Style, StyleSheets, ThemeName } from '../types'
|
|
6
6
|
import { cloneWithAccessors } from './native-utils'
|
|
@@ -17,6 +17,16 @@ class UniwindStoreBuilder {
|
|
|
17
17
|
vars = {} as Record<string, unknown>
|
|
18
18
|
runtimeThemeVariables = new Map<ThemeName, CSSVariables>()
|
|
19
19
|
private stylesheet = {} as StyleSheets
|
|
20
|
+
private varsWithMediaQueries = [] as Array<[
|
|
21
|
+
string,
|
|
22
|
+
Array<{
|
|
23
|
+
value: unknown
|
|
24
|
+
minWidth: number | null
|
|
25
|
+
maxWidth: number | null
|
|
26
|
+
orientation: Orientation | null
|
|
27
|
+
colorScheme: ColorScheme | null
|
|
28
|
+
}>,
|
|
29
|
+
]>
|
|
20
30
|
private cache = new Map<string, StylesResult>()
|
|
21
31
|
private generateStyleSheetCallbackResult: ReturnType<GenerateStyleSheetsCallback> | null = null
|
|
22
32
|
|
|
@@ -53,11 +63,11 @@ class UniwindStoreBuilder {
|
|
|
53
63
|
return
|
|
54
64
|
}
|
|
55
65
|
|
|
56
|
-
const { scopedVars, stylesheet, vars } = config
|
|
57
|
-
|
|
66
|
+
const { scopedVars, stylesheet, vars, varsWithMediaQueries } = config
|
|
67
|
+
this.vars = varsWithMediaQueries.length > 0 ? { ...vars } : vars
|
|
68
|
+
this.varsWithMediaQueries = varsWithMediaQueries
|
|
58
69
|
this.generateStyleSheetCallbackResult = config
|
|
59
70
|
this.stylesheet = stylesheet
|
|
60
|
-
this.vars = vars
|
|
61
71
|
|
|
62
72
|
const themeVars = scopedVars[`__uniwind-theme-${this.runtime.currentThemeName}`]
|
|
63
73
|
const platformVars = scopedVars[`__uniwind-platform-${Platform.OS}`]
|
|
@@ -80,11 +90,47 @@ class UniwindStoreBuilder {
|
|
|
80
90
|
}
|
|
81
91
|
}
|
|
82
92
|
|
|
93
|
+
private resolveMediaQueryVars(dependencies: Set<StyleDependency>) {
|
|
94
|
+
for (const [varName, mqVariants] of this.varsWithMediaQueries) {
|
|
95
|
+
let bestMatch: { value: unknown; minWidth: number | null } | null = null
|
|
96
|
+
|
|
97
|
+
for (const variant of mqVariants) {
|
|
98
|
+
if (variant.orientation !== null) dependencies.add(StyleDependency.Orientation)
|
|
99
|
+
if (variant.maxWidth !== null || variant.minWidth !== null) dependencies.add(StyleDependency.Dimensions)
|
|
100
|
+
if (variant.colorScheme !== null) {
|
|
101
|
+
dependencies.add(StyleDependency.ColorScheme)
|
|
102
|
+
dependencies.add(StyleDependency.Theme)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (
|
|
106
|
+
(variant.minWidth !== null && variant.minWidth > this.runtime.screen.width)
|
|
107
|
+
|| (variant.maxWidth !== null && variant.maxWidth !== Number.MAX_VALUE && variant.maxWidth < this.runtime.screen.width)
|
|
108
|
+
|| (variant.orientation !== null && this.runtime.orientation !== variant.orientation)
|
|
109
|
+
|| (variant.colorScheme !== null && this.runtime.currentThemeName !== variant.colorScheme)
|
|
110
|
+
) {
|
|
111
|
+
continue
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (bestMatch === null || (variant.minWidth ?? 0) > (bestMatch.minWidth ?? 0)) bestMatch = variant
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (bestMatch !== null) {
|
|
118
|
+
Object.defineProperty(this.vars, varName, {
|
|
119
|
+
configurable: true,
|
|
120
|
+
enumerable: true,
|
|
121
|
+
get: () => bestMatch.value,
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return this.vars
|
|
127
|
+
}
|
|
128
|
+
|
|
83
129
|
private resolveStyles(classNames: string, state?: ComponentState) {
|
|
84
130
|
const result = {} as Record<string, any>
|
|
85
|
-
let vars = this.vars
|
|
86
131
|
const dependencies = new Set<StyleDependency>()
|
|
87
132
|
const bestBreakpoints = new Map<string, Style>()
|
|
133
|
+
let vars = this.resolveMediaQueryVars(dependencies)
|
|
88
134
|
|
|
89
135
|
for (const className of classNames.split(' ')) {
|
|
90
136
|
if (!(className in this.stylesheet)) {
|
package/src/core/types.ts
CHANGED
|
@@ -25,6 +25,16 @@ export type GenerateStyleSheetsCallback = (rt: UniwindRuntime) => {
|
|
|
25
25
|
stylesheet: StyleSheets
|
|
26
26
|
vars: Record<string, unknown>
|
|
27
27
|
scopedVars: Partial<Record<string, Record<string, unknown>>>
|
|
28
|
+
varsWithMediaQueries: Array<[
|
|
29
|
+
string,
|
|
30
|
+
Array<{
|
|
31
|
+
value: unknown
|
|
32
|
+
minWidth: number | null
|
|
33
|
+
maxWidth: number | null
|
|
34
|
+
orientation: Orientation | null
|
|
35
|
+
colorScheme: ColorScheme | null
|
|
36
|
+
}>,
|
|
37
|
+
]>
|
|
28
38
|
}
|
|
29
39
|
|
|
30
40
|
type UserThemes = UniwindConfig extends { themes: infer T extends readonly string[] } ? T
|
|
@@ -6,7 +6,7 @@ import { Logger } from './logger'
|
|
|
6
6
|
import { polyfillWeb } from './polyfillWeb'
|
|
7
7
|
import { ProcessorBuilder } from './processor'
|
|
8
8
|
import { Platform, Polyfills } from './types'
|
|
9
|
-
import { serializeJSObject } from './utils'
|
|
9
|
+
import { serialize, serializeJSObject } from './utils'
|
|
10
10
|
|
|
11
11
|
type CompileVirtualConfig = {
|
|
12
12
|
cssPath: string
|
|
@@ -59,6 +59,9 @@ export const compileVirtual = async ({ css, cssPath, platform, themes, polyfills
|
|
|
59
59
|
serializeJSObject(scopedVars, (key, value) => `get "${key}"() { return ${value} }`),
|
|
60
60
|
]),
|
|
61
61
|
)
|
|
62
|
+
const varsWithMediaQueries = Object.entries(Processor.varsWithMediaQueries)
|
|
63
|
+
.map(([key, value]) => `["${key}", ${serialize(value)}]`)
|
|
64
|
+
.join(',')
|
|
62
65
|
const serializedScopedVars = Object.entries(scopedVars)
|
|
63
66
|
.map(([scopedVarsName, scopedVars]) => `"${scopedVarsName}": ({ ${scopedVars} }),`)
|
|
64
67
|
.join('')
|
|
@@ -68,6 +71,7 @@ export const compileVirtual = async ({ css, cssPath, platform, themes, polyfills
|
|
|
68
71
|
'({',
|
|
69
72
|
`scopedVars: ({ ${serializedScopedVars} }),`,
|
|
70
73
|
`vars: ({ ${currentColorVar} ${vars} }),`,
|
|
74
|
+
`varsWithMediaQueries: ([ ${varsWithMediaQueries} ]),`,
|
|
71
75
|
`stylesheet: ({ ${stylesheet} }),`,
|
|
72
76
|
'})',
|
|
73
77
|
].join('')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MediaQuery, QueryFeatureFor_MediaFeatureId } from 'lightningcss'
|
|
1
|
+
import { MediaCondition, MediaQuery, QueryFeatureFor_MediaFeatureId } from 'lightningcss'
|
|
2
2
|
import { ColorScheme, Orientation } from '../../types'
|
|
3
3
|
import { MediaQueryResolver, Platform } from '../types'
|
|
4
4
|
import type { ProcessorBuilder } from './processor'
|
|
@@ -9,19 +9,26 @@ export class MQ {
|
|
|
9
9
|
processMediaQueries(mediaQueries: Array<MediaQuery>) {
|
|
10
10
|
const mq = this.getInitialMediaQueryResolver()
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
for (const mediaQuery of mediaQueries) {
|
|
13
13
|
const { condition, mediaType } = mediaQuery
|
|
14
14
|
|
|
15
15
|
if ([Platform.Android, Platform.iOS, Platform.Native].includes(mediaType as Platform)) {
|
|
16
16
|
mq.platform = mediaType as Platform
|
|
17
|
-
|
|
18
|
-
return
|
|
17
|
+
continue
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
if (condition
|
|
22
|
-
|
|
23
|
-
}
|
|
20
|
+
if (condition) this.processCondition(condition, mq)
|
|
21
|
+
}
|
|
24
22
|
|
|
23
|
+
return mq
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private processCondition(condition: MediaCondition, mq: MediaQueryResolver) {
|
|
27
|
+
if (condition.type === 'operation') {
|
|
28
|
+
condition.conditions.forEach(nestedCondition => {
|
|
29
|
+
this.processCondition(nestedCondition, mq)
|
|
30
|
+
})
|
|
31
|
+
} else if (condition.type === 'feature') {
|
|
25
32
|
if (condition.value.type === 'range') {
|
|
26
33
|
this.processWidthMediaQuery(condition.value, mq)
|
|
27
34
|
}
|
|
@@ -29,9 +36,7 @@ export class MQ {
|
|
|
29
36
|
if (condition.value.type === 'plain') {
|
|
30
37
|
this.processPlainMediaQuery(condition.value, mq)
|
|
31
38
|
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return mq
|
|
39
|
+
}
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
private processWidthMediaQuery(query: QueryFeatureFor_MediaFeatureId & { type: 'range' }, mq: MediaQueryResolver) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Declaration, MediaQuery, Rule, transform } from 'lightningcss'
|
|
2
|
-
import { Polyfills, ProcessMetaValues } from '../types'
|
|
2
|
+
import { MediaQueryResolver, Polyfills, ProcessMetaValues } from '../types'
|
|
3
3
|
import { Color } from './color'
|
|
4
4
|
import { CSS } from './css'
|
|
5
5
|
import { Functions } from './functions'
|
|
@@ -12,6 +12,7 @@ export class ProcessorBuilder {
|
|
|
12
12
|
stylesheets = {} as Record<string, Array<any>>
|
|
13
13
|
vars = {} as Record<string, any>
|
|
14
14
|
scopedVars = {} as Record<string, Record<string, any>>
|
|
15
|
+
varsWithMediaQueries = {} as Record<string, Array<any>>
|
|
15
16
|
CSS = new CSS(this)
|
|
16
17
|
RN = new RN(this)
|
|
17
18
|
Var = new Var(this)
|
|
@@ -54,6 +55,43 @@ export class ProcessorBuilder {
|
|
|
54
55
|
})
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
private storeVarWithMediaQuery(varName: string, value: any, mq: MediaQueryResolver) {
|
|
59
|
+
if (!Array.isArray(this.varsWithMediaQueries[varName])) {
|
|
60
|
+
this.varsWithMediaQueries[varName] = []
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this.varsWithMediaQueries[varName].push({
|
|
64
|
+
value,
|
|
65
|
+
minWidth: mq.minWidth,
|
|
66
|
+
maxWidth: mq.maxWidth,
|
|
67
|
+
orientation: mq.orientation ? `'${mq.orientation}'` : null,
|
|
68
|
+
colorScheme: mq.colorScheme ? `'${mq.colorScheme}'` : null,
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private hasMediaQuery(mq: MediaQueryResolver): boolean {
|
|
73
|
+
return mq.minWidth !== 0 || mq.maxWidth !== Number.MAX_VALUE || mq.orientation !== null || mq.colorScheme !== null
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private processDeclarationValue(
|
|
77
|
+
mq: MediaQueryResolver,
|
|
78
|
+
varName: string,
|
|
79
|
+
processedValue: any,
|
|
80
|
+
context: { isVar: boolean; style: any; important: boolean },
|
|
81
|
+
) {
|
|
82
|
+
const { isVar, style, important } = context
|
|
83
|
+
|
|
84
|
+
if (isVar && this.hasMediaQuery(mq)) {
|
|
85
|
+
this.storeVarWithMediaQuery(varName, processedValue, mq)
|
|
86
|
+
} else {
|
|
87
|
+
style[varName] = processedValue
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!isVar && important) {
|
|
91
|
+
style.importantProperties.push(varName)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
57
95
|
private addDeclaration(declaration: Declaration, important = false) {
|
|
58
96
|
const isVar = this.declarationConfig.root || this.declarationConfig.className === null
|
|
59
97
|
const mq = this.MQ.processMediaQueries(this.declarationConfig.mediaQueries)
|
|
@@ -90,31 +128,27 @@ export class ProcessorBuilder {
|
|
|
90
128
|
this.meta.className = this.declarationConfig.className
|
|
91
129
|
}
|
|
92
130
|
|
|
93
|
-
|
|
94
|
-
style[declaration.value.propertyId.property] = this.CSS.processValue(declaration.value.value)
|
|
131
|
+
const context = { isVar, style, important }
|
|
95
132
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
133
|
+
if (declaration.property === 'unparsed') {
|
|
134
|
+
const varName = declaration.value.propertyId.property
|
|
135
|
+
const processedValue = this.CSS.processValue(declaration.value.value)
|
|
136
|
+
this.processDeclarationValue(mq, varName, processedValue, context)
|
|
99
137
|
|
|
100
138
|
return
|
|
101
139
|
}
|
|
102
140
|
|
|
103
141
|
if (declaration.property === 'custom') {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
style.importantProperties.push(declaration.value.name)
|
|
108
|
-
}
|
|
142
|
+
const varName = declaration.value.name
|
|
143
|
+
const processedValue = this.CSS.processValue(declaration.value.value)
|
|
144
|
+
this.processDeclarationValue(mq, varName, processedValue, context)
|
|
109
145
|
|
|
110
146
|
return
|
|
111
147
|
}
|
|
112
148
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
style.importantProperties.push(declaration.property)
|
|
117
|
-
}
|
|
149
|
+
const varName = declaration.property
|
|
150
|
+
const processedValue = this.CSS.processValue(declaration.value)
|
|
151
|
+
this.processDeclarationValue(mq, varName, processedValue, context)
|
|
118
152
|
}
|
|
119
153
|
|
|
120
154
|
private parseRuleRec(rule: Rule<Declaration, MediaQuery>) {
|
|
@@ -226,6 +260,11 @@ export class ProcessorBuilder {
|
|
|
226
260
|
this.declarationConfig = this.getDeclarationConfig()
|
|
227
261
|
})
|
|
228
262
|
|
|
263
|
+
this.declarationConfig.mediaQueries.splice(
|
|
264
|
+
this.declarationConfig.mediaQueries.length - mediaQueries.length,
|
|
265
|
+
mediaQueries.length,
|
|
266
|
+
)
|
|
267
|
+
|
|
229
268
|
return
|
|
230
269
|
}
|
|
231
270
|
|
package/src/metro/resolvers.ts
CHANGED
|
@@ -39,7 +39,8 @@ const SUPPORTED_COMPONENTS = [
|
|
|
39
39
|
'VirtualizedList',
|
|
40
40
|
]
|
|
41
41
|
|
|
42
|
-
export const nativeResolver = (
|
|
42
|
+
export const nativeResolver = (extraComponents: Record<string, string>) =>
|
|
43
|
+
({
|
|
43
44
|
context,
|
|
44
45
|
moduleName,
|
|
45
46
|
platform,
|
|
@@ -59,6 +60,14 @@ export const nativeResolver = ({
|
|
|
59
60
|
return resolver(context, `${name}/components`, platform)
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
if (moduleName === 'react-native-gesture-handler') {
|
|
64
|
+
return resolver(context, `${name}/components/native/react-native-gesture-handler`, platform)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (moduleName === 'react-native-svg') {
|
|
68
|
+
return resolver(context, `${name}/components/native/react-native-svg`, platform)
|
|
69
|
+
}
|
|
70
|
+
|
|
62
71
|
if (
|
|
63
72
|
resolution.filePath.includes(`${sep}react-native${sep}Libraries${sep}`)
|
|
64
73
|
) {
|
|
@@ -70,10 +79,16 @@ export const nativeResolver = ({
|
|
|
70
79
|
}
|
|
71
80
|
}
|
|
72
81
|
|
|
82
|
+
if (moduleName in extraComponents) {
|
|
83
|
+
const componentPath = extraComponents[moduleName]!
|
|
84
|
+
return resolver(context, componentPath, platform)
|
|
85
|
+
}
|
|
86
|
+
|
|
73
87
|
return resolution
|
|
74
88
|
}
|
|
75
89
|
|
|
76
|
-
export const webResolver = (
|
|
90
|
+
export const webResolver = (extraComponents: Record<string, string>) =>
|
|
91
|
+
({
|
|
77
92
|
context,
|
|
78
93
|
moduleName,
|
|
79
94
|
platform,
|
|
@@ -89,6 +104,11 @@ export const webResolver = ({
|
|
|
89
104
|
return resolution
|
|
90
105
|
}
|
|
91
106
|
|
|
107
|
+
if (moduleName in extraComponents) {
|
|
108
|
+
const componentPath = extraComponents[moduleName]!
|
|
109
|
+
return resolver(context, componentPath, platform)
|
|
110
|
+
}
|
|
111
|
+
|
|
92
112
|
const segments = resolution.filePath.split(sep)
|
|
93
113
|
const isIndex = segments.at(-1)?.startsWith('index.')
|
|
94
114
|
const module = segments.at(-2)
|
package/src/metro/types.ts
CHANGED
|
@@ -21,14 +21,15 @@ export type UniwindConfig = {
|
|
|
21
21
|
cssEntryFile: string
|
|
22
22
|
themes: Array<string>
|
|
23
23
|
extraThemes?: Array<string>
|
|
24
|
+
extraComponents?: Record<string, string>
|
|
24
25
|
dtsFile?: string
|
|
25
26
|
polyfills?: Polyfills
|
|
26
27
|
debug?: boolean
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export type MediaQueryResolver = {
|
|
30
|
-
maxWidth:
|
|
31
|
-
minWidth:
|
|
31
|
+
maxWidth: number | null
|
|
32
|
+
minWidth: number | null
|
|
32
33
|
platform: Platform | null
|
|
33
34
|
rtl: boolean | null
|
|
34
35
|
important: boolean
|
|
@@ -45,7 +45,7 @@ export const withUniwindConfig = <T extends MetroConfig>(
|
|
|
45
45
|
),
|
|
46
46
|
resolveRequest: (context, moduleName, platform) => {
|
|
47
47
|
const resolver = config.resolver?.resolveRequest ?? context.resolveRequest
|
|
48
|
-
const platformResolver = platform === Platform.Web ? webResolver : nativeResolver
|
|
48
|
+
const platformResolver = (platform === Platform.Web ? webResolver : nativeResolver)(uniwindConfig.extraComponents ?? {})
|
|
49
49
|
const resolved = platformResolver({
|
|
50
50
|
context,
|
|
51
51
|
moduleName,
|
package/types.d.ts
CHANGED
|
@@ -106,4 +106,42 @@ declare module 'react-native' {
|
|
|
106
106
|
interface InputAccessoryViewProps {
|
|
107
107
|
backgroundColorClassName?: string
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
interface DrawerLayoutAndroidProps {
|
|
111
|
+
className?: string
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
declare module 'react-native-gesture-handler' {
|
|
116
|
+
// Button components
|
|
117
|
+
interface BaseButtonProps {
|
|
118
|
+
className?: string
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface BorderlessButtonProps {
|
|
122
|
+
className?: string
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
interface RawButtonProps {
|
|
126
|
+
className?: string
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface RectButtonProps {
|
|
130
|
+
className?: string
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Gesture handler specific components
|
|
134
|
+
interface GestureHandlerRootViewProps {
|
|
135
|
+
className?: string
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
interface PressableProps {
|
|
139
|
+
className?: string
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
declare module 'react-native-svg' {
|
|
144
|
+
interface SvgProps {
|
|
145
|
+
className?: string
|
|
146
|
+
}
|
|
109
147
|
}
|
package/uniwind.css
CHANGED
|
@@ -254,9 +254,4 @@
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
@custom-variant light (&:where(.light, .light *));
|
|
257
|
-
@custom-variant dark (&:where(.dark, .dark *));
|
|
258
|
-
@custom-variant premium (&:where(.premium, .premium *));
|
|
259
|
-
|
|
260
|
-
@theme {
|
|
261
|
-
--color-background: unset;
|
|
262
|
-
}
|
|
257
|
+
@custom-variant dark (&:where(.dark, .dark *));
|