react-native-unistyles 3.0.0-beta.2 → 3.0.0-beta.3
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/components/native/ActivityIndicator/package.json +4 -0
- package/components/native/FlatList/package.json +4 -0
- package/components/native/Image/package.json +4 -0
- package/components/native/ImageBackground/package.json +4 -0
- package/components/native/KeyboardAvoidingView/package.json +4 -0
- package/components/native/Pressable/package.json +5 -0
- package/components/native/RefreshControl/package.json +4 -0
- package/components/native/ScrollView/package.json +4 -0
- package/components/native/SectionList/package.json +4 -0
- package/components/native/Switch/package.json +4 -0
- package/components/native/Text/package.json +4 -0
- package/components/native/TextInput/package.json +4 -0
- package/components/native/TouchableHighlight/package.json +4 -0
- package/components/native/TouchableOpacity/package.json +4 -0
- package/components/native/View/package.json +4 -0
- package/components/native/VirtualizedList/package.json +4 -0
- package/cxx/core/HostStyle.cpp +6 -1
- package/cxx/core/UnistyleWrapper.h +2 -2
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +9 -0
- package/cxx/hybridObjects/HybridShadowRegistry.h +9 -4
- package/cxx/parser/Parser.cpp +5 -3
- package/lib/commonjs/components/Variants.js +4 -1
- package/lib/commonjs/components/Variants.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js +10 -7
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/useDependencies.js +5 -1
- package/lib/commonjs/core/withUnistyles/useDependencies.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +2 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/index.js +24 -20
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/web/create.js +1 -4
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/index.js +15 -16
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +1 -6
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +1 -1
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/components/Variants.js +4 -1
- package/lib/module/components/Variants.js.map +1 -1
- package/lib/module/components/native/Pressable.native.js +10 -7
- package/lib/module/components/native/Pressable.native.js.map +1 -1
- package/lib/module/core/withUnistyles/useDependencies.js +5 -1
- package/lib/module/core/withUnistyles/useDependencies.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.native.js +2 -1
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/web/create.js +1 -4
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/index.js +3 -2
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +2 -7
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +1 -1
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/typescript/src/components/Variants.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/useDependencies.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts +5 -24
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/package.json +17 -1
- package/plugin/import.js +2 -2
- package/plugin/variants.js +16 -10
- package/src/components/Variants.tsx +2 -1
- package/src/components/native/Pressable.native.tsx +10 -8
- package/src/core/withUnistyles/useDependencies.ts +6 -1
- package/src/core/withUnistyles/withUnistyles.native.tsx +2 -1
- package/src/index.ts +1 -1
- package/src/web/create.ts +1 -4
- package/src/web/index.ts +9 -6
- package/src/web/shadowRegistry.ts +2 -8
- package/src/web/utils/unistyle.ts +1 -1
package/src/web/create.ts
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
import type { StyleSheetWithSuperPowers, StyleSheet } from '../types/stylesheet'
|
2
2
|
import { assignSecrets, error, removeInlineStyles } from './utils'
|
3
3
|
import { UnistylesRuntime } from './runtime'
|
4
|
-
import { UnistylesShadowRegistry } from '../specs'
|
5
4
|
|
6
|
-
const useVariants = ['useVariants', (
|
7
|
-
UnistylesShadowRegistry.selectVariants(variants)
|
8
|
-
}]
|
5
|
+
const useVariants = ['useVariants', () => {}]
|
9
6
|
|
10
7
|
export const create = (stylesheet: StyleSheetWithSuperPowers<StyleSheet>, id?: string) => {
|
11
8
|
if (!id) {
|
package/src/web/index.ts
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
import { create } from './create'
|
2
2
|
import { UnistylesState } from './state'
|
3
3
|
import { deepMergeObjects } from '../utils'
|
4
|
-
import type {
|
4
|
+
import type { StyleSheet as NativeStyleSheet } from '../specs/StyleSheet'
|
5
|
+
import { UnistylesRuntime as UnistylesRuntimeWeb } from './runtime'
|
6
|
+
import type { Runtime as NativeUnistylesRuntime } from '../specs/UnistylesRuntime'
|
5
7
|
|
6
8
|
export const StyleSheet = {
|
7
9
|
configure: UnistylesState.init,
|
8
|
-
create: create
|
10
|
+
create: create,
|
9
11
|
absoluteFill: {
|
10
12
|
position: 'absolute',
|
11
13
|
left: 0,
|
@@ -22,9 +24,10 @@ export const StyleSheet = {
|
|
22
24
|
},
|
23
25
|
compose: (a: object, b: object) => deepMergeObjects(a, b),
|
24
26
|
flatten: (...styles: Array<object>) => deepMergeObjects(...styles),
|
25
|
-
hairlineWidth: 1
|
26
|
-
}
|
27
|
+
hairlineWidth: 1
|
28
|
+
} as unknown as typeof NativeStyleSheet
|
29
|
+
|
30
|
+
export const UnistylesRuntime = UnistylesRuntimeWeb as unknown as typeof NativeUnistylesRuntime
|
27
31
|
|
28
|
-
export { UnistylesRuntime } from './runtime'
|
29
|
-
export { UnistylesShadowRegistry } from './shadowRegistry'
|
30
32
|
export * from './mock'
|
33
|
+
export * from './shadowRegistry'
|
@@ -2,7 +2,7 @@ import type { UnistylesTheme, UnistylesValues } from '../types'
|
|
2
2
|
import { UnistylesListener } from './listener'
|
3
3
|
import { UnistylesRegistry } from './registry'
|
4
4
|
import { deepMergeObjects } from '../utils'
|
5
|
-
import { equal, extractSecrets, extractUnistyleDependencies, isInDocument
|
5
|
+
import { equal, extractSecrets, extractUnistyleDependencies, isInDocument } from './utils'
|
6
6
|
import { getVariants } from './variants'
|
7
7
|
|
8
8
|
type Style = UnistylesValues | ((...args: Array<any>) => UnistylesValues)
|
@@ -67,13 +67,6 @@ class UnistylesShadowRegistryBuilder {
|
|
67
67
|
|
68
68
|
// Regular style
|
69
69
|
if (!secrets) {
|
70
|
-
Object.keys(unistyleStyle).forEach(key => {
|
71
|
-
if (keyInObject(ref.style, key)) {
|
72
|
-
// @ts-expect-error - Styles won't have read only properties
|
73
|
-
ref.style[key] = ''
|
74
|
-
}
|
75
|
-
})
|
76
|
-
|
77
70
|
return unistyleStyle as UnistylesValues
|
78
71
|
}
|
79
72
|
|
@@ -133,6 +126,7 @@ class UnistylesShadowRegistryBuilder {
|
|
133
126
|
this.classNamesMap.set(ref, newClassNames)
|
134
127
|
// Add new classnames to the ref
|
135
128
|
ref.classList.add(...newClassNames)
|
129
|
+
ref.removeAttribute('styles')
|
136
130
|
|
137
131
|
return newClassNames
|
138
132
|
}
|
@@ -30,7 +30,7 @@ export const assignSecrets = <T>(object: T, secrets: UnistyleSecrets) => {
|
|
30
30
|
}
|
31
31
|
|
32
32
|
export const extractSecrets = (object: any) => {
|
33
|
-
return keyInObject(object, '__uni__secrets__') ? object.__uni__secrets__ as UnistyleSecrets : undefined
|
33
|
+
return object && keyInObject(object, '__uni__secrets__') ? object.__uni__secrets__ as UnistyleSecrets : undefined
|
34
34
|
}
|
35
35
|
|
36
36
|
export const removeInlineStyles = (values: UnistylesValues) => {
|