@niibase/uniwind 1.6.1 → 1.6.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/CHANGELOG.md +47 -0
- package/dist/common/common/utils.js +15 -0
- package/dist/common/components/native/ActivityIndicator.js +2 -1
- package/dist/common/components/native/Button.js +2 -2
- package/dist/common/components/native/FlatList.js +2 -1
- package/dist/common/components/native/Image.js +2 -1
- package/dist/common/components/native/ImageBackground.js +2 -1
- package/dist/common/components/native/InputAccessoryView.js +2 -1
- package/dist/common/components/native/Modal.js +2 -1
- package/dist/common/components/native/RefreshControl.js +5 -4
- package/dist/common/components/native/ScrollView.js +2 -1
- package/dist/common/components/native/SectionList.js +2 -1
- package/dist/common/components/native/Switch.js +5 -4
- package/dist/common/components/native/Text.js +2 -1
- package/dist/common/components/native/TextInput.js +6 -5
- package/dist/common/components/native/TouchableHighlight.js +2 -1
- package/dist/common/components/native/VirtualizedList.js +2 -1
- package/dist/common/components/native/useAccentColor.js +19 -0
- package/dist/common/components/react-native-gesture-handler/native/FlatList.js +2 -1
- package/dist/common/components/react-native-gesture-handler/native/RefreshControl.js +5 -4
- package/dist/common/components/react-native-gesture-handler/native/Text.js +2 -1
- package/dist/common/components/react-native-gesture-handler/native/TextInput.js +5 -4
- package/dist/common/components/web/ActivityIndicator.js +2 -2
- package/dist/common/components/web/Button.js +2 -2
- package/dist/common/components/web/Image.js +2 -1
- package/dist/common/components/web/ImageBackground.js +2 -2
- package/dist/common/components/web/Switch.js +4 -4
- package/dist/common/components/web/TextInput.js +2 -2
- package/dist/common/components/web/TouchableHighlight.js +2 -2
- package/dist/common/components/web/useUniwindAccent.js +20 -0
- package/dist/common/core/config/config.common.js +4 -7
- package/dist/common/core/config/config.js +42 -23
- package/dist/common/core/config/config.native.js +1 -3
- package/dist/common/core/web/cssListener.js +1 -1
- package/dist/common/hoc/withUniwind.js +7 -0
- package/dist/common/hoc/withUniwind.native.js +7 -0
- package/dist/common/hooks/index.js +0 -11
- package/dist/common/hooks/useCSSVariable/useCSSVariable.js +2 -7
- package/dist/metro/index.cjs +11 -5
- package/dist/metro/index.mjs +12 -6
- package/dist/metro/metro-transformer.cjs +14 -14
- package/dist/metro/metro-transformer.mjs +8 -8
- package/dist/module/common/utils.d.ts +2 -0
- package/dist/module/common/utils.js +7 -0
- package/dist/module/components/native/ActivityIndicator.js +2 -1
- package/dist/module/components/native/Button.js +2 -2
- package/dist/module/components/native/FlatList.js +2 -1
- package/dist/module/components/native/Image.js +2 -1
- package/dist/module/components/native/ImageBackground.js +2 -1
- package/dist/module/components/native/InputAccessoryView.js +2 -1
- package/dist/module/components/native/Modal.js +2 -1
- package/dist/module/components/native/RefreshControl.js +5 -4
- package/dist/module/components/native/ScrollView.js +2 -1
- package/dist/module/components/native/SectionList.js +2 -1
- package/dist/module/components/native/Switch.js +5 -4
- package/dist/module/components/native/Text.js +2 -1
- package/dist/module/components/native/TextInput.js +6 -5
- package/dist/module/components/native/TouchableHighlight.js +2 -1
- package/dist/module/components/native/VirtualizedList.js +2 -1
- package/dist/module/components/native/useAccentColor.d.ts +2 -0
- package/dist/module/components/native/useAccentColor.js +14 -0
- package/dist/module/components/react-native-gesture-handler/native/FlatList.js +2 -1
- package/dist/module/components/react-native-gesture-handler/native/RefreshControl.js +5 -4
- package/dist/module/components/react-native-gesture-handler/native/Text.js +2 -1
- package/dist/module/components/react-native-gesture-handler/native/TextInput.js +5 -4
- package/dist/module/components/web/ActivityIndicator.js +1 -1
- package/dist/module/components/web/Button.js +1 -1
- package/dist/module/components/web/Image.js +2 -1
- package/dist/module/components/web/ImageBackground.js +1 -1
- package/dist/module/components/web/Switch.js +1 -1
- package/dist/module/components/web/TextInput.js +1 -1
- package/dist/module/components/web/TouchableHighlight.js +1 -1
- package/dist/module/components/web/useUniwindAccent.js +15 -0
- package/dist/module/core/config/config.common.d.ts +1 -1
- package/dist/module/core/config/config.common.js +3 -4
- package/dist/module/core/config/config.d.ts +4 -4
- package/dist/module/core/config/config.js +44 -25
- package/dist/module/core/config/config.native.js +1 -3
- package/dist/module/core/web/cssListener.js +1 -1
- package/dist/module/hoc/withUniwind.js +9 -0
- package/dist/module/hoc/withUniwind.native.js +9 -0
- package/dist/module/hooks/index.d.ts +0 -1
- package/dist/module/hooks/index.js +0 -1
- package/dist/module/hooks/useCSSVariable/useCSSVariable.js +1 -6
- package/dist/shared/{uniwind.C-rHhHOg.mjs → uniwind.BGiqYvxb.mjs} +1 -1
- package/dist/shared/{uniwind.nl8746mK.cjs → uniwind.Cv73KtI-.cjs} +0 -2
- package/dist/shared/{uniwind.F-0-Rr--.mjs → uniwind.PtWWxxnh.mjs} +1 -2
- package/dist/shared/{uniwind.BZyFsest.cjs → uniwind.r2i22V6d.cjs} +1 -1
- package/dist/vite/index.cjs +2 -2
- package/dist/vite/index.mjs +2 -2
- package/package.json +3 -3
- package/src/common/utils.ts +9 -0
- package/src/components/native/ActivityIndicator.tsx +2 -1
- package/src/components/native/Button.tsx +2 -2
- package/src/components/native/FlatList.tsx +2 -1
- package/src/components/native/Image.tsx +2 -1
- package/src/components/native/ImageBackground.tsx +2 -1
- package/src/components/native/InputAccessoryView.tsx +2 -1
- package/src/components/native/Modal.tsx +2 -1
- package/src/components/native/RefreshControl.tsx +5 -4
- package/src/components/native/ScrollView.tsx +2 -1
- package/src/components/native/SectionList.tsx +2 -1
- package/src/components/native/Switch.tsx +5 -4
- package/src/components/native/Text.tsx +2 -1
- package/src/components/native/TextInput.tsx +6 -5
- package/src/components/native/TouchableHighlight.tsx +2 -1
- package/src/components/native/VirtualizedList.tsx +2 -1
- package/src/components/native/useAccentColor.ts +19 -0
- package/src/components/react-native-gesture-handler/native/FlatList.tsx +2 -1
- package/src/components/react-native-gesture-handler/native/RefreshControl.tsx +5 -4
- package/src/components/react-native-gesture-handler/native/Text.tsx +2 -1
- package/src/components/react-native-gesture-handler/native/TextInput.tsx +5 -4
- package/src/components/web/ActivityIndicator.tsx +1 -1
- package/src/components/web/Button.tsx +1 -1
- package/src/components/web/Image.tsx +2 -1
- package/src/components/web/ImageBackground.tsx +1 -1
- package/src/components/web/Switch.tsx +1 -1
- package/src/components/web/TextInput.tsx +1 -1
- package/src/components/web/TouchableHighlight.tsx +1 -1
- package/src/components/web/useUniwindAccent.ts +21 -0
- package/src/core/config/config.common.ts +4 -7
- package/src/core/config/config.native.ts +1 -3
- package/src/core/config/config.ts +61 -29
- package/src/core/logger.ts +0 -2
- package/src/core/native/parsers/transforms.ts +0 -1
- package/src/core/native/store.ts +0 -1
- package/src/core/web/cssListener.ts +2 -3
- package/src/hoc/withUniwind.native.tsx +11 -1
- package/src/hoc/withUniwind.tsx +11 -0
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useCSSVariable/useCSSVariable.ts +1 -8
- package/src/metro/addMetaToStylesTemplate.ts +3 -3
- package/src/metro/logger.ts +0 -2
- package/src/metro/metro-css-patches.ts +1 -2
- package/src/metro/metro-transformer.ts +3 -3
- package/src/metro/processor/css.ts +3 -2
- package/src/metro/processor/functions.ts +0 -1
- package/src/metro/processor/rn.ts +2 -1
- package/src/metro/resolvers.ts +12 -13
- package/src/metro/utils/common.ts +0 -3
- package/src/metro/utils/serialize.ts +0 -1
- package/src/types.ts +0 -1
- package/dist/common/components/native/TextInput.android.js +0 -52
- package/dist/common/hooks/useUniwindAccent.js +0 -13
- package/dist/module/components/native/TextInput.android.d.ts +0 -3
- package/dist/module/components/native/TextInput.android.js +0 -49
- package/dist/module/hooks/useUniwindAccent.js +0 -6
- package/src/components/native/TextInput.android.tsx +0 -51
- package/src/hooks/useUniwindAccent.ts +0 -10
- /package/dist/module/{hooks → components/web}/useUniwindAccent.d.ts +0 -0
package/dist/vite/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizePath } from '@tailwindcss/node';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { u as uniq, n as name } from '../shared/uniwind.
|
|
4
|
-
import { s as stringifyThemes, U as UniwindCSSVisitor, a as buildCSS, b as buildDtsFile } from '../shared/uniwind.
|
|
3
|
+
import { u as uniq, n as name } from '../shared/uniwind.PtWWxxnh.mjs';
|
|
4
|
+
import { s as stringifyThemes, U as UniwindCSSVisitor, a as buildCSS, b as buildDtsFile } from '../shared/uniwind.BGiqYvxb.mjs';
|
|
5
5
|
import 'fs';
|
|
6
6
|
import 'lightningcss';
|
|
7
7
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@niibase/uniwind",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.3",
|
|
5
5
|
"description": "A fork of Uniwind with Reanimated 4 support",
|
|
6
6
|
"homepage": "https://uniwind.dev",
|
|
7
7
|
"author": "Unistack",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"precommit": "bun lint",
|
|
13
13
|
"build": "unbuild",
|
|
14
14
|
"check:typescript": "tsc --noEmit",
|
|
15
|
-
"lint": "
|
|
16
|
-
"lint:fix": "
|
|
15
|
+
"lint": "oxlint src",
|
|
16
|
+
"lint:fix": "oxlint src --fix",
|
|
17
17
|
"format": "dprint fmt",
|
|
18
18
|
"prepublishOnly": "bun run build",
|
|
19
19
|
"circular:check": "dpdm --no-warning --no-tree -T --exit-code circular:1 'src/**/*.ts' 'src/**/*.tsx'",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const isDefined = <T>(value: T): value is NonNullable<T> => value !== undefined && value !== null
|
|
2
|
+
|
|
3
|
+
export const arrayEquals = <T>(a: Array<T>, b: Array<T>) => {
|
|
4
|
+
if (a.length !== b.length) {
|
|
5
|
+
return false
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return a.every((value, index) => value === b[index])
|
|
9
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ActivityIndicator as RNActivityIndicator, ActivityIndicatorProps } from 'react-native'
|
|
2
2
|
import { copyComponentProperties } from '../utils'
|
|
3
|
+
import { useAccentColor } from './useAccentColor'
|
|
3
4
|
import { useStyle } from './useStyle'
|
|
4
5
|
|
|
5
6
|
export const ActivityIndicator = copyComponentProperties(RNActivityIndicator, (props: ActivityIndicatorProps) => {
|
|
6
7
|
const { Component, style } = useStyle(RNActivityIndicator, props.className, props, { isPressed: Boolean(props.animating) })
|
|
7
|
-
const color =
|
|
8
|
+
const color = useAccentColor(props.colorClassName, props)
|
|
8
9
|
|
|
9
10
|
return (
|
|
10
11
|
<Component
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Button as RNButton, ButtonProps } from 'react-native'
|
|
2
2
|
import { copyComponentProperties } from '../utils'
|
|
3
|
-
import {
|
|
3
|
+
import { useAccentColor } from './useAccentColor'
|
|
4
4
|
|
|
5
5
|
export const Button = copyComponentProperties(RNButton, (props: ButtonProps) => {
|
|
6
|
-
const color =
|
|
6
|
+
const color = useAccentColor(props.colorClassName, props)
|
|
7
7
|
|
|
8
8
|
return (
|
|
9
9
|
<RNButton
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FlatList as RNFlatList, FlatListProps } from 'react-native'
|
|
2
2
|
import { copyComponentProperties } from '../utils'
|
|
3
|
+
import { useAccentColor } from './useAccentColor'
|
|
3
4
|
import { useStyle } from './useStyle'
|
|
4
5
|
|
|
5
6
|
export const FlatList = copyComponentProperties(RNFlatList, (props: FlatListProps<unknown>) => {
|
|
@@ -8,7 +9,7 @@ export const FlatList = copyComponentProperties(RNFlatList, (props: FlatListProp
|
|
|
8
9
|
const styleContentContainer = useStyle(props.contentContainerClassName, props)
|
|
9
10
|
const styleListFooterComponent = useStyle(props.ListFooterComponentClassName, props)
|
|
10
11
|
const styleListHeaderComponent = useStyle(props.ListHeaderComponentClassName, props)
|
|
11
|
-
const endFillColor =
|
|
12
|
+
const endFillColor = useAccentColor(props.endFillColorClassName, props)
|
|
12
13
|
const hasSingleColumn = !('numColumns' in props) || props.numColumns === 1
|
|
13
14
|
|
|
14
15
|
return (
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Image as RNImage, ImageProps } from 'react-native'
|
|
2
2
|
import { copyComponentProperties } from '../utils'
|
|
3
|
+
import { useAccentColor } from './useAccentColor'
|
|
3
4
|
import { useStyle } from './useStyle'
|
|
4
5
|
|
|
5
6
|
export const Image = copyComponentProperties(RNImage, (props: ImageProps) => {
|
|
6
7
|
const { Component, style } = useStyle(RNImage, props.className, props)
|
|
7
|
-
const tintColor =
|
|
8
|
+
const tintColor = useAccentColor(props.tintColorClassName, props)
|
|
8
9
|
|
|
9
10
|
return (
|
|
10
11
|
<Component
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ImageBackground as RNImageBackground, ImageBackgroundProps } from 'react-native'
|
|
2
2
|
import { copyComponentProperties } from '../utils'
|
|
3
|
+
import { useAccentColor } from './useAccentColor'
|
|
3
4
|
import { useStyle } from './useStyle'
|
|
4
5
|
|
|
5
6
|
export const ImageBackground = copyComponentProperties(RNImageBackground, (props: ImageBackgroundProps) => {
|
|
6
7
|
const { Component, style } = useStyle(RNImageBackground, props.className, props)
|
|
7
8
|
const imageStyle = useStyle(props.imageClassName, props)
|
|
8
|
-
const tintColor =
|
|
9
|
+
const tintColor = useAccentColor(props.tintColorClassName, props)
|
|
9
10
|
|
|
10
11
|
return (
|
|
11
12
|
<Component
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { ForwardedRef } from 'react'
|
|
2
2
|
import { InputAccessoryView as RNInputAccessoryView, InputAccessoryViewProps } from 'react-native'
|
|
3
3
|
import { copyComponentProperties } from '../utils'
|
|
4
|
+
import { useAccentColor } from './useAccentColor'
|
|
4
5
|
import { useStyle } from './useStyle'
|
|
5
6
|
|
|
6
7
|
export const InputAccessoryView = copyComponentProperties(
|
|
7
8
|
RNInputAccessoryView,
|
|
8
9
|
(props: InputAccessoryViewProps & { ref?: ForwardedRef<RNInputAccessoryView> }) => {
|
|
9
10
|
const { Component, style } = useStyle(RNInputAccessoryView, props.className, props)
|
|
10
|
-
const backgroundColor =
|
|
11
|
+
const backgroundColor = useAccentColor(props.backgroundColorClassName, props)
|
|
11
12
|
|
|
12
13
|
return (
|
|
13
14
|
<Component
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Modal as RNModal, ModalProps } from 'react-native'
|
|
2
2
|
import { copyComponentProperties } from '../utils'
|
|
3
|
+
import { useAccentColor } from './useAccentColor'
|
|
3
4
|
import { useStyle } from './useStyle'
|
|
4
5
|
|
|
5
6
|
export const Modal = copyComponentProperties(RNModal, (props: ModalProps) => {
|
|
6
7
|
const { Component, style } = useStyle(RNModal, props.className, props)
|
|
7
|
-
const backdropColor =
|
|
8
|
+
const backdropColor = useAccentColor(props.backdropColorClassName, props)
|
|
8
9
|
|
|
9
10
|
return (
|
|
10
11
|
<Component
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { RefreshControl as RNRefreshControl, RefreshControlProps } from 'react-native'
|
|
2
2
|
import { copyComponentProperties } from '../utils'
|
|
3
|
+
import { useAccentColor } from './useAccentColor'
|
|
3
4
|
import { useStyle } from './useStyle'
|
|
4
5
|
|
|
5
6
|
export const RefreshControl = copyComponentProperties(RNRefreshControl, (props: RefreshControlProps) => {
|
|
6
7
|
const { Component, style } = useStyle(RNRefreshControl, props.className, props, {
|
|
7
8
|
isPressed: Boolean(props.refreshing),
|
|
8
9
|
})
|
|
9
|
-
const color =
|
|
10
|
-
const tintColor =
|
|
11
|
-
const titleColor =
|
|
12
|
-
const progressBackgroundColor =
|
|
10
|
+
const color = useAccentColor(props.colorsClassName, props)
|
|
11
|
+
const tintColor = useAccentColor(props.tintColorClassName, props)
|
|
12
|
+
const titleColor = useAccentColor(props.titleColorClassName, props)
|
|
13
|
+
const progressBackgroundColor = useAccentColor(props.progressBackgroundColorClassName, props)
|
|
13
14
|
|
|
14
15
|
return (
|
|
15
16
|
<Component
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ScrollView as RNScrollView, ScrollViewProps } from 'react-native'
|
|
2
2
|
import { copyComponentProperties } from '../utils'
|
|
3
|
+
import { useAccentColor } from './useAccentColor'
|
|
3
4
|
import { useStyle } from './useStyle'
|
|
4
5
|
|
|
5
6
|
export const ScrollView = copyComponentProperties(RNScrollView, (props: ScrollViewProps) => {
|
|
6
7
|
const { Component, style } = useStyle(RNScrollView, props.className, props)
|
|
7
8
|
const contentContainerStyle = useStyle(props.contentContainerClassName, props)
|
|
8
|
-
const endFillColor =
|
|
9
|
+
const endFillColor = useAccentColor(props.endFillColorClassName, props)
|
|
9
10
|
|
|
10
11
|
return (
|
|
11
12
|
<Component
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SectionList as RNSectionList, SectionListProps } from 'react-native'
|
|
2
2
|
import { copyComponentProperties } from '../utils'
|
|
3
|
+
import { useAccentColor } from './useAccentColor'
|
|
3
4
|
import { useStyle } from './useStyle'
|
|
4
5
|
|
|
5
6
|
export const SectionList = copyComponentProperties(RNSectionList, (props: SectionListProps<unknown, unknown>) => {
|
|
@@ -7,7 +8,7 @@ export const SectionList = copyComponentProperties(RNSectionList, (props: Sectio
|
|
|
7
8
|
const contentContainerStyle = useStyle(props.contentContainerClassName, props)
|
|
8
9
|
const listFooterComponentStyle = useStyle(props.ListFooterComponentClassName, props)
|
|
9
10
|
const listHeaderComponentStyle = useStyle(props.ListHeaderComponentClassName, props)
|
|
10
|
-
const endFillColor =
|
|
11
|
+
const endFillColor = useAccentColor(props.endFillColorClassName, props)
|
|
11
12
|
|
|
12
13
|
return (
|
|
13
14
|
<Component
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Switch as RNSwitch, SwitchProps } from 'react-native'
|
|
2
2
|
import { ComponentState } from '../../core/types'
|
|
3
3
|
import { copyComponentProperties } from '../utils'
|
|
4
|
+
import { useAccentColor } from './useAccentColor'
|
|
4
5
|
import { useStyle } from './useStyle'
|
|
5
6
|
|
|
6
7
|
export const Switch = copyComponentProperties(RNSwitch, (props: SwitchProps) => {
|
|
@@ -9,10 +10,10 @@ export const Switch = copyComponentProperties(RNSwitch, (props: SwitchProps) =>
|
|
|
9
10
|
isPressed: Boolean(props.value),
|
|
10
11
|
} satisfies ComponentState
|
|
11
12
|
const { Component, style } = useStyle(RNSwitch, props.className, props, state)
|
|
12
|
-
const trackColorOn =
|
|
13
|
-
const trackColorOff =
|
|
14
|
-
const thumbColor =
|
|
15
|
-
const ios_backgroundColor =
|
|
13
|
+
const trackColorOn = useAccentColor(props.trackColorOnClassName, props, state)
|
|
14
|
+
const trackColorOff = useAccentColor(props.trackColorOffClassName, props, state)
|
|
15
|
+
const thumbColor = useAccentColor(props.thumbColorClassName, props, state)
|
|
16
|
+
const ios_backgroundColor = useAccentColor(props.ios_backgroundColorClassName, props, state)
|
|
16
17
|
|
|
17
18
|
return (
|
|
18
19
|
<Component
|
|
@@ -2,6 +2,7 @@ import { useState } from 'react'
|
|
|
2
2
|
import { Text as RNText, TextProps } from 'react-native'
|
|
3
3
|
import { ComponentState } from '../../core/types'
|
|
4
4
|
import { copyComponentProperties } from '../utils'
|
|
5
|
+
import { useAccentColor } from './useAccentColor'
|
|
5
6
|
import { useStyle } from './useStyle'
|
|
6
7
|
|
|
7
8
|
type StyleWithWebkitLineClamp = {
|
|
@@ -15,7 +16,7 @@ export const Text = copyComponentProperties(RNText, (props: TextProps) => {
|
|
|
15
16
|
isDisabled: Boolean(props.disabled),
|
|
16
17
|
} satisfies ComponentState
|
|
17
18
|
const { Component, style } = useStyle(RNText, props.className, props, state)
|
|
18
|
-
const selectionColor =
|
|
19
|
+
const selectionColor = useAccentColor(props.selectionColorClassName, props, state)
|
|
19
20
|
|
|
20
21
|
return (
|
|
21
22
|
<Component
|
|
@@ -2,6 +2,7 @@ import { useState } from 'react'
|
|
|
2
2
|
import { TextInput as RNTextInput, TextInputProps } from 'react-native'
|
|
3
3
|
import { ComponentState } from '../../core/types'
|
|
4
4
|
import { copyComponentProperties } from '../utils'
|
|
5
|
+
import { useAccentColor } from './useAccentColor'
|
|
5
6
|
import { useStyle } from './useStyle'
|
|
6
7
|
|
|
7
8
|
export const TextInput = copyComponentProperties(RNTextInput, (props: TextInputProps) => {
|
|
@@ -13,11 +14,11 @@ export const TextInput = copyComponentProperties(RNTextInput, (props: TextInputP
|
|
|
13
14
|
isPressed,
|
|
14
15
|
} satisfies ComponentState
|
|
15
16
|
const { Component, style } = useStyle(RNTextInput, props.className, props, state)
|
|
16
|
-
const cursorColor =
|
|
17
|
-
const selectionColor =
|
|
18
|
-
const placeholderTextColor =
|
|
19
|
-
const selectionHandleColor =
|
|
20
|
-
const underlineColorAndroid =
|
|
17
|
+
const cursorColor = useAccentColor(props.cursorColorClassName, props, state)
|
|
18
|
+
const selectionColor = useAccentColor(props.selectionColorClassName, props, state)
|
|
19
|
+
const placeholderTextColor = useAccentColor(props.placeholderTextColorClassName, props, state)
|
|
20
|
+
const selectionHandleColor = useAccentColor(props.selectionHandleColorClassName, props, state)
|
|
21
|
+
const underlineColorAndroid = useAccentColor(props.underlineColorAndroidClassName, props, state)
|
|
21
22
|
|
|
22
23
|
return (
|
|
23
24
|
<Component
|
|
@@ -2,6 +2,7 @@ import { useState } from 'react'
|
|
|
2
2
|
import { TouchableHighlight as RNTouchableHighlight, TouchableHighlightProps } from 'react-native'
|
|
3
3
|
import { ComponentState } from '../../core/types'
|
|
4
4
|
import { copyComponentProperties } from '../utils'
|
|
5
|
+
import { useAccentColor } from './useAccentColor'
|
|
5
6
|
import { useStyle } from './useStyle'
|
|
6
7
|
|
|
7
8
|
export const TouchableHighlight = copyComponentProperties(RNTouchableHighlight, (props: TouchableHighlightProps) => {
|
|
@@ -13,7 +14,7 @@ export const TouchableHighlight = copyComponentProperties(RNTouchableHighlight,
|
|
|
13
14
|
isFocused,
|
|
14
15
|
} satisfies ComponentState
|
|
15
16
|
const { Component, style } = useStyle(RNTouchableHighlight, props.className, props, state)
|
|
16
|
-
const underlayColor =
|
|
17
|
+
const underlayColor = useAccentColor(props.underlayColorClassName, props, state)
|
|
17
18
|
|
|
18
19
|
return (
|
|
19
20
|
<Component
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { VirtualizedList as RNVirtualizedList, VirtualizedListProps } from 'react-native'
|
|
2
2
|
import { copyComponentProperties } from '../utils'
|
|
3
|
+
import { useAccentColor } from './useAccentColor'
|
|
3
4
|
import { useStyle } from './useStyle'
|
|
4
5
|
|
|
5
6
|
export const VirtualizedList = copyComponentProperties(RNVirtualizedList, (props: VirtualizedListProps<unknown>) => {
|
|
@@ -7,7 +8,7 @@ export const VirtualizedList = copyComponentProperties(RNVirtualizedList, (props
|
|
|
7
8
|
const contentContainerStyle = useStyle(props.contentContainerClassName, props)
|
|
8
9
|
const listFooterComponentStyle = useStyle(props.ListFooterComponentClassName, props)
|
|
9
10
|
const listHeaderComponentStyle = useStyle(props.ListHeaderComponentClassName, props)
|
|
10
|
-
const endFillColor =
|
|
11
|
+
const endFillColor = useAccentColor(props.endFillColorClassName, props)
|
|
11
12
|
|
|
12
13
|
return (
|
|
13
14
|
<Component
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isDefined } from '../../common/utils'
|
|
2
|
+
import { Logger } from '../../core/logger'
|
|
3
|
+
import { ComponentState } from '../../core/types'
|
|
4
|
+
import { useStyle } from './useStyle'
|
|
5
|
+
|
|
6
|
+
let warnedOnce = false
|
|
7
|
+
|
|
8
|
+
export const useAccentColor = (className: string | undefined, componentProps: Record<string, any>, state?: ComponentState) => {
|
|
9
|
+
const styles = useStyle(className, componentProps, state)
|
|
10
|
+
|
|
11
|
+
if (__DEV__ && !warnedOnce && isDefined(className) && className.trim() !== '' && styles.accentColor === undefined) {
|
|
12
|
+
warnedOnce = true
|
|
13
|
+
Logger.warn(
|
|
14
|
+
`className '${className}' was provided to extract accentColor but no color was found. Make sure the className includes a color utility (e.g., 'accent-red-500', 'accent-blue-600'). See https://docs.uniwind.dev/class-names#the-accent-prefix`,
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return styles.accentColor
|
|
19
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FlatListProps } from 'react-native'
|
|
2
2
|
import { FlatList as RNGHFlatList } from 'react-native-gesture-handler'
|
|
3
|
+
import { useAccentColor } from '../../native/useAccentColor'
|
|
3
4
|
import { useStyle } from '../../native/useStyle'
|
|
4
5
|
import { copyComponentProperties } from '../../utils'
|
|
5
6
|
|
|
@@ -9,7 +10,7 @@ export const FlatList = copyComponentProperties(RNGHFlatList, (props: FlatListPr
|
|
|
9
10
|
const styleContentContainer = useStyle(props.contentContainerClassName, props)
|
|
10
11
|
const styleListFooterComponent = useStyle(props.ListFooterComponentClassName, props)
|
|
11
12
|
const styleListHeaderComponent = useStyle(props.ListHeaderComponentClassName, props)
|
|
12
|
-
const endFillColor =
|
|
13
|
+
const endFillColor = useAccentColor(props.endFillColorClassName, props)
|
|
13
14
|
const hasSingleColumn = !('numColumns' in props) || props.numColumns === 1
|
|
14
15
|
|
|
15
16
|
return (
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { RefreshControlProps } from 'react-native'
|
|
2
2
|
import { RefreshControl as RNGHRefreshControl } from 'react-native-gesture-handler'
|
|
3
|
+
import { useAccentColor } from '../../native/useAccentColor'
|
|
3
4
|
import { useStyle } from '../../native/useStyle'
|
|
4
5
|
import { copyComponentProperties } from '../../utils'
|
|
5
6
|
|
|
6
7
|
export const RefreshControl = copyComponentProperties(RNGHRefreshControl, (props: RefreshControlProps) => {
|
|
7
8
|
const style = useStyle(props.className, props)
|
|
8
|
-
const color =
|
|
9
|
-
const tintColor =
|
|
10
|
-
const titleColor =
|
|
11
|
-
const progressBackgroundColor =
|
|
9
|
+
const color = useAccentColor(props.colorsClassName, props)
|
|
10
|
+
const tintColor = useAccentColor(props.tintColorClassName, props)
|
|
11
|
+
const titleColor = useAccentColor(props.titleColorClassName, props)
|
|
12
|
+
const progressBackgroundColor = useAccentColor(props.progressBackgroundColorClassName, props)
|
|
12
13
|
|
|
13
14
|
return (
|
|
14
15
|
<RNGHRefreshControl
|
|
@@ -2,6 +2,7 @@ import { useState } from 'react'
|
|
|
2
2
|
import { TextProps } from 'react-native'
|
|
3
3
|
import { Text as RNGHText } from 'react-native-gesture-handler'
|
|
4
4
|
import { ComponentState } from '../../../core/types'
|
|
5
|
+
import { useAccentColor } from '../../native/useAccentColor'
|
|
5
6
|
import { useStyle } from '../../native/useStyle'
|
|
6
7
|
import { copyComponentProperties } from '../../utils'
|
|
7
8
|
|
|
@@ -16,7 +17,7 @@ export const Text = copyComponentProperties(RNGHText, (props: TextProps) => {
|
|
|
16
17
|
isDisabled: Boolean(props.disabled),
|
|
17
18
|
} satisfies ComponentState
|
|
18
19
|
const style = useStyle(props.className, props, state)
|
|
19
|
-
const selectionColor =
|
|
20
|
+
const selectionColor = useAccentColor(props.selectionColorClassName, props, state)
|
|
20
21
|
|
|
21
22
|
return (
|
|
22
23
|
<RNGHText
|
|
@@ -2,6 +2,7 @@ import { useState } from 'react'
|
|
|
2
2
|
import { TextInputProps } from 'react-native'
|
|
3
3
|
import { TextInput as RNGHTextInput } from 'react-native-gesture-handler'
|
|
4
4
|
import { ComponentState } from '../../../core/types'
|
|
5
|
+
import { useAccentColor } from '../../native/useAccentColor'
|
|
5
6
|
import { useStyle } from '../../native/useStyle'
|
|
6
7
|
import { copyComponentProperties } from '../../utils'
|
|
7
8
|
|
|
@@ -15,10 +16,10 @@ export const TextInput = copyComponentProperties(RNGHTextInput, (props: TextInpu
|
|
|
15
16
|
} satisfies ComponentState
|
|
16
17
|
const style = useStyle(props.className, props, state)
|
|
17
18
|
const cursorColor = useStyle(props.cursorColorClassName, props, state).accentColor
|
|
18
|
-
const selectionColor =
|
|
19
|
-
const placeholderTextColor =
|
|
20
|
-
const selectionHandleColor =
|
|
21
|
-
const underlineColorAndroid =
|
|
19
|
+
const selectionColor = useAccentColor(props.selectionColorClassName, props, state)
|
|
20
|
+
const placeholderTextColor = useAccentColor(props.placeholderTextColorClassName, props, state)
|
|
21
|
+
const selectionHandleColor = useAccentColor(props.selectionHandleColorClassName, props, state)
|
|
22
|
+
const underlineColorAndroid = useAccentColor(props.underlineColorAndroidClassName, props, state)
|
|
22
23
|
|
|
23
24
|
return (
|
|
24
25
|
<RNGHTextInput
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ActivityIndicator as RNActivityIndicator, ActivityIndicatorProps } from 'react-native'
|
|
2
|
-
import { useUniwindAccent } from '../../hooks'
|
|
3
2
|
import { copyComponentProperties } from '../utils'
|
|
4
3
|
import { generateDataSet } from './generateDataSet'
|
|
5
4
|
import { toRNWClassName } from './rnw'
|
|
5
|
+
import { useUniwindAccent } from './useUniwindAccent'
|
|
6
6
|
|
|
7
7
|
export const ActivityIndicator = copyComponentProperties(RNActivityIndicator, (props: ActivityIndicatorProps) => {
|
|
8
8
|
const color = useUniwindAccent(props.colorClassName)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Button as RNButton, ButtonProps } from 'react-native'
|
|
2
|
-
import { useUniwindAccent } from '../../hooks'
|
|
3
2
|
import { copyComponentProperties } from '../utils'
|
|
4
3
|
import { generateDataSet } from './generateDataSet'
|
|
4
|
+
import { useUniwindAccent } from './useUniwindAccent'
|
|
5
5
|
|
|
6
6
|
export const Button = copyComponentProperties(RNButton, (props: ButtonProps) => {
|
|
7
7
|
const color = useUniwindAccent(props.colorClassName)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Image as RNImage, ImageProps } from 'react-native'
|
|
2
|
-
import { useResolveClassNames
|
|
2
|
+
import { useResolveClassNames } from '../../hooks'
|
|
3
3
|
import { copyComponentProperties } from '../utils'
|
|
4
4
|
import { generateDataSet } from './generateDataSet'
|
|
5
5
|
import { toRNWClassName } from './rnw'
|
|
6
|
+
import { useUniwindAccent } from './useUniwindAccent'
|
|
6
7
|
|
|
7
8
|
export const Image = copyComponentProperties(RNImage, (props: ImageProps) => {
|
|
8
9
|
const tintColor = useUniwindAccent(props.tintColorClassName)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ImageBackground as RNImageBackground, ImageBackgroundProps } from 'react-native'
|
|
2
|
-
import { useUniwindAccent } from '../../hooks'
|
|
3
2
|
import { copyComponentProperties } from '../utils'
|
|
4
3
|
import { generateDataSet } from './generateDataSet'
|
|
5
4
|
import { toRNWClassName } from './rnw'
|
|
5
|
+
import { useUniwindAccent } from './useUniwindAccent'
|
|
6
6
|
|
|
7
7
|
export const ImageBackground = copyComponentProperties(RNImageBackground, (props: ImageBackgroundProps) => {
|
|
8
8
|
const tintColor = useUniwindAccent(props.tintColorClassName)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Switch as RNSwitch, SwitchProps } from 'react-native'
|
|
2
|
-
import { useUniwindAccent } from '../../hooks'
|
|
3
2
|
import { copyComponentProperties } from '../utils'
|
|
4
3
|
import { generateDataSet } from './generateDataSet'
|
|
5
4
|
import { toRNWClassName } from './rnw'
|
|
5
|
+
import { useUniwindAccent } from './useUniwindAccent'
|
|
6
6
|
|
|
7
7
|
export const Switch = copyComponentProperties(RNSwitch, (props: SwitchProps) => {
|
|
8
8
|
const trackColorOn = useUniwindAccent(props.trackColorOnClassName)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TextInput as RNTextInput, TextInputProps } from 'react-native'
|
|
2
|
-
import { useUniwindAccent } from '../../hooks'
|
|
3
2
|
import { copyComponentProperties } from '../utils'
|
|
4
3
|
import { generateDataSet } from './generateDataSet'
|
|
5
4
|
import { toRNWClassName } from './rnw'
|
|
5
|
+
import { useUniwindAccent } from './useUniwindAccent'
|
|
6
6
|
|
|
7
7
|
export const TextInput = copyComponentProperties(RNTextInput, (props: TextInputProps) => {
|
|
8
8
|
const placeholderTextColor = useUniwindAccent(props.placeholderTextColorClassName)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TouchableHighlight as RNTouchableHighlight, TouchableHighlightProps } from 'react-native'
|
|
2
|
-
import { useUniwindAccent } from '../../hooks'
|
|
3
2
|
import { copyComponentProperties } from '../utils'
|
|
4
3
|
import { generateDataSet } from './generateDataSet'
|
|
5
4
|
import { toRNWClassName } from './rnw'
|
|
5
|
+
import { useUniwindAccent } from './useUniwindAccent'
|
|
6
6
|
|
|
7
7
|
export const TouchableHighlight = copyComponentProperties(RNTouchableHighlight, (props: TouchableHighlightProps) => {
|
|
8
8
|
const underlayColor = useUniwindAccent(props.underlayColorClassName)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isDefined } from '../../common/utils'
|
|
2
|
+
import { Logger } from '../../core/logger'
|
|
3
|
+
import { formatColor } from '../../core/web/formatColor'
|
|
4
|
+
import { useResolveClassNames } from '../../hooks/useResolveClassNames'
|
|
5
|
+
|
|
6
|
+
let warnedOnce = false
|
|
7
|
+
|
|
8
|
+
export const useUniwindAccent = (className: string | undefined) => {
|
|
9
|
+
const styles = useResolveClassNames(className ?? '')
|
|
10
|
+
|
|
11
|
+
if (__DEV__ && !warnedOnce && isDefined(className) && className.trim() !== '' && styles.accentColor === undefined) {
|
|
12
|
+
warnedOnce = true
|
|
13
|
+
Logger.warn(
|
|
14
|
+
`className '${className}' was provided to extract accentColor but no color was found. Make sure the className includes a color utility (e.g., 'accent-red-500', 'accent-blue-600'). See https://docs.uniwind.dev/class-names#the-accent-prefix`,
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return styles.accentColor !== undefined
|
|
19
|
+
? formatColor(styles.accentColor)
|
|
20
|
+
: undefined
|
|
21
|
+
}
|
|
@@ -7,8 +7,7 @@ import { UniwindListener } from '../listener'
|
|
|
7
7
|
import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types'
|
|
8
8
|
|
|
9
9
|
const SYSTEM_THEME = 'system' as const
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
10
|
+
// Platform.constants is not defined in RNW
|
|
12
11
|
const RN_VERSION = Platform.constants?.reactNativeVersion?.minor ?? 0
|
|
13
12
|
const UNSPECIFIED_THEME = RN_VERSION >= 82 ? 'unspecified' : undefined
|
|
14
13
|
|
|
@@ -21,7 +20,6 @@ export class UniwindConfigBuilder {
|
|
|
21
20
|
Appearance.addChangeListener(event => {
|
|
22
21
|
const colorScheme = event.colorScheme === 'unspecified'
|
|
23
22
|
? ColorScheme.Light
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
25
23
|
: event.colorScheme ?? ColorScheme.Light
|
|
26
24
|
const prevTheme = this.#currentTheme
|
|
27
25
|
|
|
@@ -108,15 +106,14 @@ export class UniwindConfigBuilder {
|
|
|
108
106
|
}
|
|
109
107
|
}
|
|
110
108
|
|
|
111
|
-
|
|
109
|
+
// oxlint-disable-next-line typescript/no-unused-vars
|
|
110
|
+
updateCSSVariables(theme: ThemeName, cssVariables: CSSVariables) {
|
|
112
111
|
// noop
|
|
113
|
-
theme
|
|
114
|
-
variables
|
|
115
112
|
}
|
|
116
113
|
|
|
114
|
+
// oxlint-disable-next-line typescript/no-unused-vars
|
|
117
115
|
updateInsets(insets: Insets) {
|
|
118
116
|
// noop
|
|
119
|
-
insets
|
|
120
117
|
}
|
|
121
118
|
|
|
122
119
|
protected __reinit(_: GenerateStyleSheetsCallback, themes: Array<string>) {
|
|
@@ -44,9 +44,7 @@ class UniwindConfigBuilder extends UniwindConfigBuilderBase {
|
|
|
44
44
|
})
|
|
45
45
|
})
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
UniwindListener.notify([StyleDependency.Variables])
|
|
49
|
-
}
|
|
47
|
+
UniwindListener.notify([StyleDependency.Variables])
|
|
50
48
|
}
|
|
51
49
|
|
|
52
50
|
updateInsets(insets: Insets) {
|