react-native-unistyles 3.0.0-nightly-20250428 → 3.0.0-nightly-20250503
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/README.md +1 -1
- package/Unistyles.podspec +1 -0
- package/components/native/ActivityIndicator/package.json +1 -0
- package/components/native/Animated/package.json +1 -0
- package/components/native/FlatList/package.json +1 -0
- package/components/native/Image/package.json +1 -0
- package/components/native/ImageBackground/package.json +1 -0
- package/components/native/KeyboardAvoidingView/package.json +1 -0
- package/components/native/NativeText/package.json +1 -0
- package/components/native/NativeView/package.json +1 -0
- package/components/native/Pressable/package.json +1 -0
- package/components/native/RefreshControl/package.json +1 -0
- package/components/native/ScrollView/package.json +2 -1
- package/components/native/SectionList/package.json +1 -0
- package/components/native/Switch/package.json +1 -0
- package/components/native/Text/package.json +1 -0
- package/components/native/TextInput/package.json +1 -0
- package/components/native/TouchableHighlight/package.json +1 -0
- package/components/native/TouchableOpacity/package.json +1 -0
- package/components/native/View/package.json +1 -0
- package/components/native/VirtualizedList/package.json +1 -0
- package/lib/commonjs/components/native/Image.js +2 -1
- package/lib/commonjs/components/native/Image.js.map +1 -1
- package/lib/commonjs/components/native/ImageBackground.js +3 -2
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/ScrollView.js +1 -25
- package/lib/commonjs/components/native/ScrollView.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js +17 -5
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.js +4 -4
- package/lib/commonjs/hooks/useMedia.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.native.js +4 -4
- package/lib/commonjs/hooks/useMedia.native.js.map +1 -1
- package/lib/commonjs/mocks.js +176 -0
- package/lib/commonjs/mocks.js.map +1 -0
- package/lib/commonjs/mq.js +3 -25
- package/lib/commonjs/mq.js.map +1 -1
- package/lib/commonjs/utils.js +23 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/convert/index.js +3 -3
- package/lib/commonjs/web/convert/index.js.map +1 -1
- package/lib/commonjs/web/convert/object/filter.js +7 -10
- package/lib/commonjs/web/convert/object/filter.js.map +1 -1
- package/lib/commonjs/web/css/state.js +1 -1
- package/lib/commonjs/web/css/state.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +2 -2
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/utils/index.js +0 -11
- package/lib/commonjs/web/utils/index.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +3 -3
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/components/native/Image.js +2 -1
- package/lib/module/components/native/Image.js.map +1 -1
- package/lib/module/components/native/ImageBackground.js +2 -1
- package/lib/module/components/native/ImageBackground.js.map +1 -1
- package/lib/module/components/native/ScrollView.js +2 -25
- package/lib/module/components/native/ScrollView.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js +18 -6
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/hooks/useMedia.js +1 -1
- package/lib/module/hooks/useMedia.js.map +1 -1
- package/lib/module/hooks/useMedia.native.js +1 -1
- package/lib/module/hooks/useMedia.native.js.map +1 -1
- package/lib/module/mocks.js +174 -0
- package/lib/module/mocks.js.map +1 -0
- package/lib/module/mq.js +1 -20
- package/lib/module/mq.js.map +1 -1
- package/lib/module/utils.js +19 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/convert/index.js +3 -3
- package/lib/module/web/convert/index.js.map +1 -1
- package/lib/module/web/convert/object/filter.js +3 -4
- package/lib/module/web/convert/object/filter.js.map +1 -1
- package/lib/module/web/css/state.js +1 -1
- package/lib/module/web/css/state.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +1 -1
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/utils/index.js +0 -1
- package/lib/module/web/utils/index.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/native/Image.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
- package/lib/typescript/src/mocks.d.ts +2 -0
- package/lib/typescript/src/mocks.d.ts.map +1 -0
- package/lib/typescript/src/mq.d.ts +0 -8
- package/lib/typescript/src/mq.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +8 -0
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/index.d.ts +2 -1
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/filter.d.ts +2 -1
- package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/index.d.ts +0 -1
- package/lib/typescript/src/web/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/package.json +18 -5
- package/plugin/index.js +6 -0
- package/src/components/native/Image.tsx +2 -1
- package/src/components/native/ImageBackground.tsx +2 -1
- package/src/components/native/ScrollView.tsx +3 -36
- package/src/core/createUnistylesElement.tsx +26 -9
- package/src/hooks/useMedia.native.ts +1 -1
- package/src/hooks/useMedia.ts +1 -1
- package/src/mocks.ts +191 -0
- package/src/mq.ts +1 -25
- package/src/utils.ts +25 -0
- package/src/web/convert/index.ts +4 -3
- package/src/web/convert/object/filter.ts +4 -4
- package/src/web/css/state.ts +1 -1
- package/src/web/shadowRegistry.ts +1 -1
- package/src/web/utils/index.ts +0 -1
- package/src/web/utils/unistyle.ts +2 -2
- package/lib/commonjs/components/native/ScrollView.native.js +0 -10
- package/lib/commonjs/components/native/ScrollView.native.js.map +0 -1
- package/lib/module/components/native/ScrollView.native.js +0 -6
- package/lib/module/components/native/ScrollView.native.js.map +0 -1
- package/lib/typescript/src/components/native/ScrollView.native.d.ts +0 -2
- package/lib/typescript/src/components/native/ScrollView.native.d.ts.map +0 -1
- package/src/components/native/ScrollView.native.tsx +0 -4
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"unistyle.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/unistyle.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"unistyle.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/unistyle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAA;AACzF,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAKpG,eAAO,MAAM,aAAa,WAAY,WAAW,qBAQhD,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC1B,iBAAiB,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAA;CAC/D,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,UAAU,CAAC,WAAW,eAAe,MAanE,CAAA;AAED,eAAO,MAAM,cAAc,WAAY,GAAG;;aAYzC,CAAA;AAED,eAAO,MAAM,kBAAkB,WAAY,eAAe,OAUzD,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,MAAM,kBAAkB,KAAK,CAAC,MAAM,CAAC,WA6BzE,CAAA;AAED,eAAO,MAAM,2BAA2B,UAAW,GAAG,yBAQrD,CAAA;AAED,eAAO,MAAM,YAAY,UAAW,GAAG,QAAQ,MAAM,KAAG,OAcvD,CAAA;AAED,eAAO,MAAM,gBAAgB,UAAW,GAAG,KAAG,OAgB7C,CAAA"}
|
package/package.json
CHANGED
@@ -1,32 +1,43 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "3.0.0-nightly-
|
3
|
+
"version": "3.0.0-nightly-20250503",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
|
-
"test": "jest",
|
7
|
-
"test:coverage": "jest --passWithNoTests --coverage",
|
6
|
+
"test": "NODE_ENV=babel-test jest ./plugin",
|
7
|
+
"test:coverage": "NODE_ENV=babel-test jest --passWithNoTests --coverage",
|
8
8
|
"tsc": "node_modules/typescript/bin/tsc --noEmit",
|
9
9
|
"lint": "biome lint",
|
10
10
|
"check": "biome check --write",
|
11
11
|
"check:ci": "biome check",
|
12
12
|
"prepare": "husky && bob build && yarn plugin:build",
|
13
|
-
"precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn check' 'yarn test'",
|
13
|
+
"precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn check' 'yarn test' 'yarn circular:check'",
|
14
14
|
"release": "release-it",
|
15
|
-
"plugin:build": "node plugin/esbuild.js"
|
15
|
+
"plugin:build": "node plugin/esbuild.js",
|
16
|
+
"circular:check": "dpdm --no-warning --no-tree -T --exit-code circular:1 src/**/*.ts",
|
17
|
+
"components:build": "node build-components.js"
|
16
18
|
},
|
17
19
|
"main": "lib/commonjs/index.js",
|
18
20
|
"module": "lib/module/index.js",
|
21
|
+
"browser": "lib/module/index.js",
|
19
22
|
"types": "lib/typescript/src/index.d.ts",
|
20
23
|
"source": "src/index",
|
21
24
|
"exports": {
|
22
25
|
".": {
|
23
26
|
"types": "./lib/typescript/src/index.d.ts",
|
24
27
|
"import": "./lib/module/index.js",
|
28
|
+
"browser": "./lib/module/index.js",
|
25
29
|
"react-native": "./src/index.ts",
|
26
30
|
"default": "./lib/commonjs/index.js"
|
27
31
|
},
|
32
|
+
"./mocks": {
|
33
|
+
"import": "./lib/module/mocks.js",
|
34
|
+
"browser": "./lib/module/mocks.js",
|
35
|
+
"react-native": "./src/mocks.ts",
|
36
|
+
"default": "./lib/commonjs/mocks.js"
|
37
|
+
},
|
28
38
|
"./components/native/*": {
|
29
39
|
"import": "./lib/module/components/native/*",
|
40
|
+
"browser": "./lib/module/components/native/*",
|
30
41
|
"react-native": "./src/components/native/*",
|
31
42
|
"default": "./lib/commonjs/components/native/*"
|
32
43
|
},
|
@@ -39,6 +50,7 @@
|
|
39
50
|
"./server": {
|
40
51
|
"types": "./lib/typescript/src/server/index.d.ts",
|
41
52
|
"import": "./lib/module/server/index.js",
|
53
|
+
"browser": "./lib/module/server/index.js",
|
42
54
|
"react-native": "./src/server.ts",
|
43
55
|
"default": "./lib/commonjs/server/index.js"
|
44
56
|
}
|
@@ -102,6 +114,7 @@
|
|
102
114
|
"babel-plugin-tester": "11.0.4",
|
103
115
|
"commitlint": "19.7.1",
|
104
116
|
"concurrently": "9.1.2",
|
117
|
+
"dpdm": "3.14.0",
|
105
118
|
"esbuild": "0.25.0",
|
106
119
|
"husky": "9.1.7",
|
107
120
|
"jest": "29.7.0",
|
package/plugin/index.js
CHANGED
@@ -715,6 +715,12 @@ function extractVariants(path2, state) {
|
|
715
715
|
|
716
716
|
// plugin/src/index.ts
|
717
717
|
function index_default() {
|
718
|
+
if (process.env.NODE_ENV === "test") {
|
719
|
+
return {
|
720
|
+
name: "babel-react-native-unistyles",
|
721
|
+
visitor: {}
|
722
|
+
};
|
723
|
+
}
|
718
724
|
return {
|
719
725
|
name: "babel-react-native-unistyles",
|
720
726
|
visitor: {
|
@@ -4,7 +4,8 @@ import { getClassName } from '../../core'
|
|
4
4
|
import { maybeWarnAboutMultipleUnistyles } from '../../core/warn'
|
5
5
|
import type { UnistylesValues } from '../../types'
|
6
6
|
import { copyComponentProperties } from '../../utils'
|
7
|
-
import { checkForProp
|
7
|
+
import { checkForProp } from '../../web/utils'
|
8
|
+
import { createUnistylesRef } from '../../web/utils/createUnistylesRef'
|
8
9
|
|
9
10
|
type Props = ComponentProps<typeof NativeImage> & {
|
10
11
|
style?: UnistylesValues
|
@@ -5,7 +5,8 @@ import { getClassName } from '../../core'
|
|
5
5
|
import { maybeWarnAboutMultipleUnistyles } from '../../core/warn'
|
6
6
|
import type { UnistylesValues } from '../../types'
|
7
7
|
import { copyComponentProperties } from '../../utils'
|
8
|
-
import {
|
8
|
+
import { keyInObject } from '../../web/utils'
|
9
|
+
import { createUnistylesRef } from '../../web/utils/createUnistylesRef'
|
9
10
|
|
10
11
|
type Props = {
|
11
12
|
style?: UnistylesValues
|
@@ -1,37 +1,4 @@
|
|
1
|
-
import
|
2
|
-
import {
|
3
|
-
import { ScrollView as NativeScrollView, type StyleProp, type ViewStyle } from 'react-native'
|
4
|
-
import { getClassName } from '../../core'
|
5
|
-
import { maybeWarnAboutMultipleUnistyles } from '../../core/warn'
|
6
|
-
import type { UnistylesValues } from '../../types'
|
7
|
-
import { copyComponentProperties } from '../../utils'
|
8
|
-
import { createUnistylesRef, isServer } from '../../web/utils'
|
1
|
+
import { ScrollView as NativeScrollView } from 'react-native'
|
2
|
+
import { createUnistylesElement } from '../../core'
|
9
3
|
|
10
|
-
|
11
|
-
style?: UnistylesValues
|
12
|
-
contentContainerStyle?: UnistylesValues
|
13
|
-
}
|
14
|
-
|
15
|
-
const UnistylesScrollView = forwardRef<unknown, Props>((props, forwardedRef) => {
|
16
|
-
const styleClassNames = getClassName(props.style)
|
17
|
-
const contentContainerStyleClassNames = getClassName(props.contentContainerStyle)
|
18
|
-
const ref = createUnistylesRef(styleClassNames, forwardedRef)
|
19
|
-
const contentContainerRef = createUnistylesRef(contentContainerStyleClassNames)
|
20
|
-
|
21
|
-
maybeWarnAboutMultipleUnistyles(props.style as ViewStyle, 'ScrollView')
|
22
|
-
maybeWarnAboutMultipleUnistyles(props.contentContainerStyle as ViewStyle, 'ScrollView')
|
23
|
-
|
24
|
-
return (
|
25
|
-
<NativeScrollView
|
26
|
-
{...props}
|
27
|
-
style={styleClassNames as StyleProp<ViewStyle>}
|
28
|
-
contentContainerStyle={contentContainerStyleClassNames as StyleProp<ViewStyle>}
|
29
|
-
ref={isServer() ? undefined : scrollRef => {
|
30
|
-
ref?.(scrollRef)
|
31
|
-
contentContainerRef?.(scrollRef)
|
32
|
-
}}
|
33
|
-
/>
|
34
|
-
)
|
35
|
-
})
|
36
|
-
|
37
|
-
export const ScrollView = copyComponentProperties(NativeScrollView, UnistylesScrollView)
|
4
|
+
export const ScrollView = createUnistylesElement(NativeScrollView)
|
@@ -2,26 +2,43 @@ import React from 'react'
|
|
2
2
|
import type { ViewStyle } from 'react-native'
|
3
3
|
import type { UnistylesValues } from '../types'
|
4
4
|
import { copyComponentProperties } from '../utils'
|
5
|
-
import {
|
5
|
+
import { isServer } from '../web/utils'
|
6
|
+
import { createUnistylesRef } from '../web/utils/createUnistylesRef'
|
6
7
|
import { getClassName } from './getClassname'
|
7
8
|
import { maybeWarnAboutMultipleUnistyles } from './warn'
|
8
9
|
|
10
|
+
const STYLE_PROPS = ['style', 'contentContainerStyle', 'columnWrapperStyle'] as const
|
11
|
+
|
9
12
|
type ComponentProps = {
|
10
|
-
|
13
|
+
[K in typeof STYLE_PROPS[number]]?: UnistylesValues
|
11
14
|
}
|
12
15
|
|
13
|
-
|
14
|
-
const
|
15
|
-
|
16
|
-
|
16
|
+
const buildUnistylesProps = (Component: any, props: ComponentProps, forwardedRef: React.ForwardedRef<unknown>) => {
|
17
|
+
const componentStyleProps = STYLE_PROPS.filter(styleProp => styleProp in props)
|
18
|
+
const classNames = Object.fromEntries(componentStyleProps.map(styleProp => [styleProp, getClassName(props[styleProp])]))
|
19
|
+
const refs = componentStyleProps.map(styleProp => {
|
20
|
+
return createUnistylesRef(
|
21
|
+
classNames[styleProp],
|
22
|
+
styleProp === 'style' ? forwardedRef : undefined
|
23
|
+
)
|
24
|
+
})
|
17
25
|
|
18
|
-
|
26
|
+
componentStyleProps.forEach(styleProp => {
|
27
|
+
maybeWarnAboutMultipleUnistyles(props[styleProp] as ViewStyle, Component.displayName)
|
28
|
+
})
|
29
|
+
|
30
|
+
return {
|
31
|
+
...classNames,
|
32
|
+
ref: isServer() ? undefined : (componentRef: any) => refs.forEach(ref => ref?.(componentRef))
|
33
|
+
}
|
34
|
+
}
|
19
35
|
|
36
|
+
export const createUnistylesElement = (Component: any) => {
|
37
|
+
const UnistylesComponent = React.forwardRef<unknown, ComponentProps>((props, forwardedRef) => {
|
20
38
|
return (
|
21
39
|
<Component
|
22
40
|
{...props}
|
23
|
-
|
24
|
-
ref={ref}
|
41
|
+
{...buildUnistylesProps(Component, props, forwardedRef)}
|
25
42
|
/>
|
26
43
|
)
|
27
44
|
})
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { useEffect, useLayoutEffect, useState } from 'react'
|
2
|
-
import { isUnistylesMq, isValidMq, parseMq } from '../mq'
|
3
2
|
import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs'
|
3
|
+
import { isUnistylesMq, isValidMq, parseMq } from '../utils'
|
4
4
|
|
5
5
|
export const useMedia = (config: { mq: symbol }) => {
|
6
6
|
const computeIsVisible = (): boolean => {
|
package/src/hooks/useMedia.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { useEffect, useRef, useState } from 'react'
|
2
|
-
import { isUnistylesMq, isValidMq, parseMq } from '../
|
2
|
+
import { isUnistylesMq, isValidMq, parseMq } from '../utils'
|
3
3
|
|
4
4
|
export const useMedia = (config: { mq: symbol }) => {
|
5
5
|
const disposeRef = useRef(() => {})
|
package/src/mocks.ts
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
import type { UnistylesBreakpoints, UnistylesThemes } from './global'
|
2
|
+
import type { UnistylesNavigationBar } from './specs/NavigtionBar'
|
3
|
+
import type { UnistylesStatusBar } from './specs/StatusBar'
|
4
|
+
import type { UnistylesConfig, UnistylesStyleSheet } from './specs/StyleSheet'
|
5
|
+
import type { UnistylesRuntimePrivate } from './specs/UnistylesRuntime'
|
6
|
+
import type { ColorScheme, Orientation } from './specs/types'
|
7
|
+
import type { IOSContentSizeCategory, UnistylesTheme } from './types'
|
8
|
+
|
9
|
+
type Registry = {
|
10
|
+
themes: UnistylesThemes
|
11
|
+
breakpoints: UnistylesBreakpoints
|
12
|
+
}
|
13
|
+
|
14
|
+
jest.mock('react-native', () => ({
|
15
|
+
TurboModuleRegistry: {
|
16
|
+
get: () => ({})
|
17
|
+
},
|
18
|
+
StyleSheet: {},
|
19
|
+
Platform: {
|
20
|
+
OS: 'headless'
|
21
|
+
}
|
22
|
+
}))
|
23
|
+
|
24
|
+
jest.mock('react-native-nitro-modules', () => ({
|
25
|
+
NitroModules: {
|
26
|
+
createHybridObject: () => ({
|
27
|
+
add: () => {},
|
28
|
+
init: () => {},
|
29
|
+
createHybridStatusBar: () => ({
|
30
|
+
setStyle: () => {},
|
31
|
+
}),
|
32
|
+
createHybridNavigationBar: () => {},
|
33
|
+
})
|
34
|
+
}
|
35
|
+
}))
|
36
|
+
|
37
|
+
jest.mock('react-native-unistyles', () => {
|
38
|
+
const _REGISTRY: Registry = {
|
39
|
+
themes: {},
|
40
|
+
breakpoints: {}
|
41
|
+
}
|
42
|
+
const miniRuntime = {
|
43
|
+
themeName: undefined,
|
44
|
+
breakpoint: undefined,
|
45
|
+
hasAdaptiveThemes: false,
|
46
|
+
colorScheme: 'unspecified' as ColorScheme,
|
47
|
+
contentSizeCategory: 'Medium' as IOSContentSizeCategory,
|
48
|
+
insets: {
|
49
|
+
top: 0,
|
50
|
+
left: 0,
|
51
|
+
right: 0,
|
52
|
+
bottom: 0,
|
53
|
+
ime: 0
|
54
|
+
},
|
55
|
+
pixelRatio: 1,
|
56
|
+
fontScale: 1,
|
57
|
+
rtl: false,
|
58
|
+
isLandscape: false,
|
59
|
+
isPortrait: true,
|
60
|
+
navigationBar: {
|
61
|
+
width: 0,
|
62
|
+
height: 0
|
63
|
+
},
|
64
|
+
screen: {
|
65
|
+
width: 0,
|
66
|
+
height: 0
|
67
|
+
},
|
68
|
+
statusBar: {
|
69
|
+
width: 0,
|
70
|
+
height: 0
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
return {
|
75
|
+
StyleSheet: {
|
76
|
+
absoluteFillObject: {
|
77
|
+
position: 'absolute',
|
78
|
+
left: 0,
|
79
|
+
right: 0,
|
80
|
+
top: 0,
|
81
|
+
bottom: 0
|
82
|
+
},
|
83
|
+
absoluteFill: {
|
84
|
+
position: 'absolute',
|
85
|
+
left: 0,
|
86
|
+
right: 0,
|
87
|
+
top: 0,
|
88
|
+
bottom: 0
|
89
|
+
} as unknown as UnistylesStyleSheet['absoluteFill'],
|
90
|
+
compose: (styles: any) => {
|
91
|
+
return styles
|
92
|
+
},
|
93
|
+
flatten: (styles: any) => {
|
94
|
+
return styles
|
95
|
+
},
|
96
|
+
create: (styles: any) => {
|
97
|
+
if (typeof styles === 'function') {
|
98
|
+
const firstTheme = Object.values(_REGISTRY.themes).at(0) ?? {}
|
99
|
+
|
100
|
+
return {
|
101
|
+
...styles(firstTheme, miniRuntime),
|
102
|
+
useVariants: () => {}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
return {
|
107
|
+
...styles,
|
108
|
+
useVariants: () => {}
|
109
|
+
}
|
110
|
+
},
|
111
|
+
configure: (config: UnistylesConfig) => {
|
112
|
+
if (config.breakpoints) {
|
113
|
+
_REGISTRY.breakpoints = config.breakpoints
|
114
|
+
}
|
115
|
+
|
116
|
+
if (config.themes) {
|
117
|
+
_REGISTRY.themes = config.themes
|
118
|
+
}
|
119
|
+
},
|
120
|
+
jsMethods: {
|
121
|
+
processColor: () => null
|
122
|
+
},
|
123
|
+
hairlineWidth: 1,
|
124
|
+
unid: -1,
|
125
|
+
addChangeListener: () => () => {},
|
126
|
+
init: () => {},
|
127
|
+
name: 'StyleSheetMock',
|
128
|
+
dispose: () => {},
|
129
|
+
equals: () => false
|
130
|
+
} satisfies UnistylesStyleSheet,
|
131
|
+
UnistylesRuntime: {
|
132
|
+
colorScheme: 'unspecified' as ColorScheme,
|
133
|
+
contentSizeCategory: 'Medium' as IOSContentSizeCategory,
|
134
|
+
orientation: 'portrait' as Orientation,
|
135
|
+
breakpoints: {},
|
136
|
+
dispose: () => { },
|
137
|
+
equals: () => false,
|
138
|
+
name: 'UnistylesRuntimeMock',
|
139
|
+
miniRuntime: miniRuntime,
|
140
|
+
statusBar: {
|
141
|
+
height: 0,
|
142
|
+
width: 0,
|
143
|
+
name: 'StatusBarMock',
|
144
|
+
equals: () => false,
|
145
|
+
setHidden: () => { },
|
146
|
+
setStyle: () => { }
|
147
|
+
},
|
148
|
+
navigationBar: {
|
149
|
+
height: 0,
|
150
|
+
width: 0,
|
151
|
+
name: 'NavigationBarMock',
|
152
|
+
equals: () => false,
|
153
|
+
setHidden: () => { },
|
154
|
+
dispose: () => { }
|
155
|
+
},
|
156
|
+
fontScale: 1,
|
157
|
+
hasAdaptiveThemes: false,
|
158
|
+
pixelRatio: 0,
|
159
|
+
rtl: false,
|
160
|
+
getTheme: () => {
|
161
|
+
return {} as UnistylesTheme
|
162
|
+
},
|
163
|
+
setTheme: () => {},
|
164
|
+
updateTheme: () => {},
|
165
|
+
setRootViewBackgroundColor: () => {},
|
166
|
+
_setRootViewBackgroundColor: () => {},
|
167
|
+
createHybridStatusBar: () => {
|
168
|
+
return {} as UnistylesStatusBar
|
169
|
+
},
|
170
|
+
createHybridNavigationBar: () => {
|
171
|
+
return {} as UnistylesNavigationBar
|
172
|
+
},
|
173
|
+
setAdaptiveThemes: () => {},
|
174
|
+
setImmersiveMode: () => {},
|
175
|
+
insets: {
|
176
|
+
top: 0,
|
177
|
+
left: 0,
|
178
|
+
right: 0,
|
179
|
+
bottom: 0,
|
180
|
+
ime: 0
|
181
|
+
},
|
182
|
+
screen: {
|
183
|
+
width: 0,
|
184
|
+
height: 0
|
185
|
+
},
|
186
|
+
breakpoint: undefined
|
187
|
+
} satisfies UnistylesRuntimePrivate
|
188
|
+
}
|
189
|
+
})
|
190
|
+
|
191
|
+
|
package/src/mq.ts
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
import type { UnistylesBreakpoints } from './global'
|
2
|
-
import { UnistylesRuntime } from './specs'
|
3
2
|
import type { Nullable } from './types'
|
4
|
-
|
5
|
-
const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/
|
6
|
-
const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/
|
7
|
-
const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/
|
3
|
+
import { UnistylesRuntime } from './web'
|
8
4
|
|
9
5
|
type MQValue = keyof UnistylesBreakpoints | number
|
10
6
|
|
@@ -62,23 +58,3 @@ export const mq: MQHandler = {
|
|
62
58
|
})
|
63
59
|
}
|
64
60
|
|
65
|
-
export const parseMq = (mq: string) => {
|
66
|
-
const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || []
|
67
|
-
const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || []
|
68
|
-
|
69
|
-
return {
|
70
|
-
minWidth: !width || fromW === 'Infinity' ? undefined : Number(fromW),
|
71
|
-
maxWidth: !width || toW === 'Infinity' ? undefined : Number(toW),
|
72
|
-
minHeight: !height || fromH === 'Infinity' ? undefined : Number(fromH),
|
73
|
-
maxHeight: !height || toH === 'Infinity' ? undefined : Number(toH),
|
74
|
-
}
|
75
|
-
}
|
76
|
-
|
77
|
-
export const isUnistylesMq = (mq: string) => IS_UNISTYLES_REGEX.test(mq)
|
78
|
-
|
79
|
-
export const isValidMq = (parsedMQ: ReturnType<typeof parseMq>) => {
|
80
|
-
const isWidthValid = parsedMQ.minWidth === undefined || parsedMQ.maxWidth === undefined || parsedMQ.minWidth <= parsedMQ.maxWidth
|
81
|
-
const isHeightValid = parsedMQ.minHeight === undefined || parsedMQ.maxHeight === undefined || parsedMQ.minHeight <= parsedMQ.maxHeight
|
82
|
-
|
83
|
-
return isWidthValid && isHeightValid
|
84
|
-
}
|
package/src/utils.ts
CHANGED
@@ -41,3 +41,28 @@ export const copyComponentProperties = (Component: any, UnistylesComponent: any)
|
|
41
41
|
|
42
42
|
return UnistylesComponent
|
43
43
|
}
|
44
|
+
|
45
|
+
const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/
|
46
|
+
const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/
|
47
|
+
const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/
|
48
|
+
|
49
|
+
export const isUnistylesMq = (mq: string) => IS_UNISTYLES_REGEX.test(mq)
|
50
|
+
|
51
|
+
export const parseMq = (mq: string) => {
|
52
|
+
const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || []
|
53
|
+
const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || []
|
54
|
+
|
55
|
+
return {
|
56
|
+
minWidth: !width || fromW === 'Infinity' ? undefined : Number(fromW),
|
57
|
+
maxWidth: !width || toW === 'Infinity' ? undefined : Number(toW),
|
58
|
+
minHeight: !height || fromH === 'Infinity' ? undefined : Number(fromH),
|
59
|
+
maxHeight: !height || toH === 'Infinity' ? undefined : Number(toH),
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
export const isValidMq = (parsedMQ: ReturnType<typeof parseMq>) => {
|
64
|
+
const isWidthValid = parsedMQ.minWidth === undefined || parsedMQ.maxWidth === undefined || parsedMQ.minWidth <= parsedMQ.maxWidth
|
65
|
+
const isHeightValid = parsedMQ.minHeight === undefined || parsedMQ.maxHeight === undefined || parsedMQ.minHeight <= parsedMQ.maxHeight
|
66
|
+
|
67
|
+
return isWidthValid && isHeightValid
|
68
|
+
}
|
package/src/web/convert/index.ts
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
import type { UnistylesValues } from '../../types'
|
2
2
|
import { deepMergeObjects } from '../../utils'
|
3
|
+
import type { UnistylesRuntime } from '../runtime'
|
3
4
|
import { getBoxShadow, getFilterStyle, getTransformStyle } from './object'
|
4
5
|
import { isPseudo } from './pseudo'
|
5
6
|
import { getBoxShadowStyle, getTextShadowStyle } from './shadow'
|
6
7
|
import { getStyle } from './style'
|
7
8
|
import { isBoxShadow, isFilter, isShadow, isTextShadow, isTransform } from './utils'
|
8
9
|
|
9
|
-
export const convertUnistyles = (value: UnistylesValues) => {
|
10
|
+
export const convertUnistyles = (value: UnistylesValues, runtime: UnistylesRuntime) => {
|
10
11
|
// Flag to mark if textShadow is already created
|
11
12
|
let hasTextShadow = false
|
12
13
|
// Flag to mark if boxShadow is already created
|
@@ -20,7 +21,7 @@ export const convertUnistyles = (value: UnistylesValues) => {
|
|
20
21
|
|
21
22
|
// Pseudo classes :hover, :before etc.
|
22
23
|
if (isPseudo(unistylesKey)) {
|
23
|
-
const flattenValues = convertUnistyles(unistylesValue as UnistylesValues)
|
24
|
+
const flattenValues = convertUnistyles(unistylesValue as UnistylesValues, runtime)
|
24
25
|
|
25
26
|
return { [unistylesKey]: flattenValues }
|
26
27
|
}
|
@@ -48,7 +49,7 @@ export const convertUnistyles = (value: UnistylesValues) => {
|
|
48
49
|
}
|
49
50
|
|
50
51
|
if (isFilter(unistylesKey, unistylesValue)) {
|
51
|
-
return getFilterStyle(unistylesValue)
|
52
|
+
return getFilterStyle(unistylesValue, runtime)
|
52
53
|
}
|
53
54
|
|
54
55
|
if (isBoxShadow(unistylesKey, unistylesValue)) {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { DropShadowValue } from 'react-native'
|
2
|
-
import { isUnistylesMq } from '../../../
|
3
|
-
import
|
2
|
+
import { isUnistylesMq } from '../../../utils'
|
3
|
+
import type { UnistylesRuntime } from '../../runtime'
|
4
4
|
import { hyphenate } from '../../utils'
|
5
5
|
import type { Filters } from '../types'
|
6
6
|
import { normalizeColor, normalizeNumericValue } from '../utils'
|
@@ -12,7 +12,7 @@ const getDropShadowStyle = (dropShadow: DropShadowValue) => {
|
|
12
12
|
return `${normalizeColor(String(color))} ${normalizeNumericValue(offsetX)} ${normalizeNumericValue(offsetY)} ${normalizeNumericValue(standardDeviation)}`
|
13
13
|
}
|
14
14
|
|
15
|
-
export const getFilterStyle = (filters: Array<Filters
|
15
|
+
export const getFilterStyle = (filters: Array<Filters>, runtime: UnistylesRuntime) => {
|
16
16
|
const restFilters = filters.filter(filter => Object.keys(filter)[0] !== 'dropShadow')
|
17
17
|
const dropShadow = (() => {
|
18
18
|
const dropShadowValue = filters.find(filter => Object.keys(filter)[0] === 'dropShadow')?.dropShadow as Record<string, any>
|
@@ -21,7 +21,7 @@ export const getFilterStyle = (filters: Array<Filters>) => {
|
|
21
21
|
return []
|
22
22
|
}
|
23
23
|
|
24
|
-
const breakpoints = Object.keys(dropShadowValue).filter(key => Object.keys(
|
24
|
+
const breakpoints = Object.keys(dropShadowValue).filter(key => Object.keys(runtime.breakpoints).includes(key) || isUnistylesMq(key))
|
25
25
|
const breakpointsDropShadow = Object.fromEntries(breakpoints.map(breakpoint => [breakpoint, getDropShadowStyle(dropShadowValue[breakpoint])]))
|
26
26
|
|
27
27
|
if (breakpoints.length === 0) {
|
package/src/web/css/state.ts
CHANGED
@@ -61,7 +61,7 @@ export class CSSState {
|
|
61
61
|
}
|
62
62
|
|
63
63
|
add = (hash: string, values: UnistylesValues) => {
|
64
|
-
convertToCSS(hash, convertUnistyles(values), this)
|
64
|
+
convertToCSS(hash, convertUnistyles(values, this.services.runtime), this)
|
65
65
|
|
66
66
|
if (this.styleTag) {
|
67
67
|
this.styleTag.innerText = this.getStyles()
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { UnistyleDependency } from '../specs'
|
1
|
+
import { UnistyleDependency } from '../specs/NativePlatform/NativePlatform.nitro'
|
2
2
|
import type { UnistylesTheme, UnistylesValues } from '../types'
|
3
3
|
import { deepMergeObjects } from '../utils'
|
4
4
|
import type { UnistylesServices } from './types'
|
package/src/web/utils/index.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import { Animated } from 'react-native'
|
2
2
|
import type { UnistylesBreakpoints } from '../../global'
|
3
|
-
import {
|
4
|
-
import type { UnistyleDependency } from '../../specs/NativePlatform'
|
3
|
+
import type { UnistyleDependency } from '../../specs/NativePlatform/NativePlatform.nitro'
|
5
4
|
import { ColorScheme, Orientation } from '../../specs/types'
|
6
5
|
import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../../types/stylesheet'
|
6
|
+
import { isUnistylesMq, parseMq } from '../../utils'
|
7
7
|
import * as unistyles from '../services'
|
8
8
|
import { keyInObject, reduceObject } from './common'
|
9
9
|
|
@@ -1,10 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.ScrollView = void 0;
|
7
|
-
var _reactNative = require("react-native");
|
8
|
-
var _core = require("../../core");
|
9
|
-
const ScrollView = exports.ScrollView = (0, _core.createUnistylesElement)(_reactNative.ScrollView);
|
10
|
-
//# sourceMappingURL=ScrollView.native.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_core","ScrollView","exports","createUnistylesElement","NativeScrollView"],"sourceRoot":"../../../../src","sources":["components/native/ScrollView.native.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEO,MAAME,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,IAAAE,4BAAsB,EAACC,uBAAgB,CAAC","ignoreList":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["ScrollView","NativeScrollView","createUnistylesElement"],"sourceRoot":"../../../../src","sources":["components/native/ScrollView.native.tsx"],"mappings":";;AAAA,SAASA,UAAU,IAAIC,gBAAgB,QAAQ,cAAc;AAC7D,SAASC,sBAAsB,QAAQ,YAAY;AAEnD,OAAO,MAAMF,UAAU,GAAGE,sBAAsB,CAACD,gBAAgB,CAAC","ignoreList":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ScrollView.native.d.ts","sourceRoot":"","sources":["../../../../../src/components/native/ScrollView.native.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,KAA2C,CAAA"}
|