@niibase/uniwind 1.6.1 → 1.6.2
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 +24 -0
- package/dist/common/common/utils.js +8 -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/hoc/withUniwind.js +7 -0
- package/dist/common/hoc/withUniwind.native.js +7 -0
- package/dist/common/hooks/index.js +0 -11
- package/dist/metro/index.cjs +1 -1
- package/dist/metro/index.mjs +1 -1
- package/dist/metro/metro-transformer.cjs +12 -10
- package/dist/metro/metro-transformer.mjs +6 -4
- package/dist/module/common/utils.d.ts +1 -0
- package/dist/module/common/utils.js +1 -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/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/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 +1 -1
- package/src/common/utils.ts +1 -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/hoc/withUniwind.native.tsx +11 -0
- package/src/hoc/withUniwind.tsx +11 -0
- package/src/hooks/index.ts +0 -1
- package/src/metro/addMetaToStylesTemplate.ts +2 -1
- package/src/metro/metro-transformer.ts +2 -2
- package/src/metro/processor/css.ts +3 -1
- package/src/metro/processor/rn.ts +2 -1
- package/src/metro/utils/common.ts +0 -2
- 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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isDefined } from "../../common/utils.js";
|
|
2
|
+
import { Logger } from "../../core/logger.js";
|
|
3
|
+
import { formatColor } from "../../core/web/formatColor.js";
|
|
4
|
+
import { useResolveClassNames } from "../../hooks/useResolveClassNames.js";
|
|
5
|
+
let warnedOnce = false;
|
|
6
|
+
export const useUniwindAccent = (className) => {
|
|
7
|
+
const styles = useResolveClassNames(className ?? "");
|
|
8
|
+
if (__DEV__ && !warnedOnce && isDefined(className) && className.trim() !== "" && styles.accentColor === void 0) {
|
|
9
|
+
warnedOnce = true;
|
|
10
|
+
Logger.warn(
|
|
11
|
+
`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`
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
return styles.accentColor !== void 0 ? formatColor(styles.accentColor) : void 0;
|
|
15
|
+
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useLayoutEffect, useReducer } from "react";
|
|
3
|
+
import { isDefined } from "../common/utils.js";
|
|
3
4
|
import { generateDataSet } from "../components/web/generateDataSet.js";
|
|
4
5
|
import { useUniwindContext } from "../core/context.js";
|
|
6
|
+
import { Logger } from "../core/logger.js";
|
|
5
7
|
import { CSSListener, formatColor, getWebStyles } from "../core/web/index.js";
|
|
6
8
|
import { classToColor, classToStyle, isClassProperty, isColorClassProperty, isStyleProperty } from "./withUniwindUtils.js";
|
|
9
|
+
let warnedOnce = false;
|
|
7
10
|
export const withUniwind = (Component2, options) => options ? withManualUniwind(Component2, options) : withAutoUniwind(Component2);
|
|
8
11
|
const withAutoUniwind = (Component2) => (props) => {
|
|
9
12
|
const uniwindContext = useUniwindContext();
|
|
@@ -15,6 +18,12 @@ const withAutoUniwind = (Component2) => (props) => {
|
|
|
15
18
|
}
|
|
16
19
|
const className = propValue;
|
|
17
20
|
const color = getWebStyles(className, props, uniwindContext).accentColor;
|
|
21
|
+
if (__DEV__ && !warnedOnce && isDefined(className) && className.trim() !== "" && color === void 0) {
|
|
22
|
+
warnedOnce = true;
|
|
23
|
+
Logger.warn(
|
|
24
|
+
`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`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
18
27
|
acc.generatedProps[colorProp] = color !== void 0 ? formatColor(color) : void 0;
|
|
19
28
|
acc.classNames += `${className} `;
|
|
20
29
|
return acc;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useLayoutEffect, useReducer } from "react";
|
|
3
|
+
import { isDefined } from "../common/utils.js";
|
|
3
4
|
import { useUniwindContext } from "../core/context.js";
|
|
4
5
|
import { UniwindListener } from "../core/listener.js";
|
|
6
|
+
import { Logger } from "../core/logger.js";
|
|
5
7
|
import { UniwindStore } from "../core/native/index.js";
|
|
6
8
|
import { classToColor, classToStyle, isClassProperty, isColorClassProperty, isStyleProperty } from "./withUniwindUtils.js";
|
|
9
|
+
let warnedOnce = false;
|
|
7
10
|
export const withUniwind = (Component2, options) => options ? withManualUniwind(Component2, options) : withAutoUniwind(Component2);
|
|
8
11
|
const withAutoUniwind = (Component2) => (props) => {
|
|
9
12
|
const uniwindContext = useUniwindContext();
|
|
@@ -14,6 +17,12 @@ const withAutoUniwind = (Component2) => (props) => {
|
|
|
14
17
|
return acc;
|
|
15
18
|
}
|
|
16
19
|
const { styles, dependencies: dependencies2 } = UniwindStore.getStyles(propValue, props, void 0, uniwindContext);
|
|
20
|
+
if (__DEV__ && !warnedOnce && isDefined(propValue) && propValue.trim() !== "" && styles.accentColor === void 0) {
|
|
21
|
+
warnedOnce = true;
|
|
22
|
+
Logger.warn(
|
|
23
|
+
`className '${propValue}' 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`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
17
26
|
acc.dependencies.push(...dependencies2);
|
|
18
27
|
acc.generatedProps[colorProp] = styles.accentColor;
|
|
19
28
|
return acc;
|
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { compile } from '@tailwindcss/node';
|
|
4
4
|
import { transform } from 'lightningcss';
|
|
5
|
-
import { n as name } from './uniwind.
|
|
5
|
+
import { n as name } from './uniwind.PtWWxxnh.mjs';
|
|
6
6
|
|
|
7
7
|
const red = "\x1B[91m";
|
|
8
8
|
const yellow = "\x1B[33m";
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const name = "@niibase/uniwind";
|
|
4
4
|
|
|
5
|
-
const isDefined = (value) => value !== null && value !== void 0;
|
|
6
5
|
const toCamelCase = (str) => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
7
6
|
const pipe = (data) => ((...fns) => fns.reduce((acc, fn) => fn(acc), data));
|
|
8
7
|
const isNumber = (data) => {
|
|
@@ -75,7 +74,6 @@ const removeKeys = (obj, keysToRemove) => Object.fromEntries(
|
|
|
75
74
|
|
|
76
75
|
exports.addMissingSpaces = addMissingSpaces;
|
|
77
76
|
exports.deepEqual = deepEqual;
|
|
78
|
-
exports.isDefined = isDefined;
|
|
79
77
|
exports.isNumber = isNumber;
|
|
80
78
|
exports.isValidJSValue = isValidJSValue;
|
|
81
79
|
exports.name = name;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const name = "@niibase/uniwind";
|
|
2
2
|
|
|
3
|
-
const isDefined = (value) => value !== null && value !== void 0;
|
|
4
3
|
const toCamelCase = (str) => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
5
4
|
const pipe = (data) => ((...fns) => fns.reduce((acc, fn) => fn(acc), data));
|
|
6
5
|
const isNumber = (data) => {
|
|
@@ -71,4 +70,4 @@ const removeKeys = (obj, keysToRemove) => Object.fromEntries(
|
|
|
71
70
|
Object.entries(obj).filter(([key]) => !keysToRemove.includes(key))
|
|
72
71
|
);
|
|
73
72
|
|
|
74
|
-
export { isValidJSValue as a, addMissingSpaces as b,
|
|
73
|
+
export { isValidJSValue as a, addMissingSpaces as b, shouldBeSerialized as c, deepEqual as d, removeKeys as e, isNumber as i, name as n, pipe as p, roundToPrecision as r, smartSplit as s, toCamelCase as t, uniq as u };
|
|
@@ -4,7 +4,7 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const node = require('@tailwindcss/node');
|
|
6
6
|
const lightningcss = require('lightningcss');
|
|
7
|
-
const common = require('./uniwind.
|
|
7
|
+
const common = require('./uniwind.Cv73KtI-.cjs');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
10
10
|
|
package/dist/vite/index.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const node = require('@tailwindcss/node');
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const common = require('../shared/uniwind.
|
|
6
|
-
const stringifyThemes = require('../shared/uniwind.
|
|
5
|
+
const common = require('../shared/uniwind.Cv73KtI-.cjs');
|
|
6
|
+
const stringifyThemes = require('../shared/uniwind.r2i22V6d.cjs');
|
|
7
7
|
require('fs');
|
|
8
8
|
require('lightningcss');
|
|
9
9
|
|
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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isDefined = <T>(value: T): value is NonNullable<T> => value !== undefined && value !== null
|
|
@@ -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)
|