@niibase/uniwind 1.6.0 → 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 +45 -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/generateDataSet.js +2 -1
- package/dist/common/components/web/useUniwindAccent.js +20 -0
- package/dist/common/core/web/getWebStyles.js +12 -1
- package/dist/common/hoc/withUniwind.js +14 -4
- package/dist/common/hoc/withUniwind.native.js +11 -4
- package/dist/common/hooks/index.js +0 -11
- package/dist/common/hooks/useResolveClassNames.js +1 -1
- package/dist/metro/index.cjs +1 -1
- package/dist/metro/index.mjs +1 -1
- package/dist/metro/metro-transformer.cjs +14 -11
- package/dist/metro/metro-transformer.mjs +8 -5
- 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/generateDataSet.d.ts +1 -1
- package/dist/module/components/web/generateDataSet.js +2 -1
- package/dist/module/components/web/useUniwindAccent.js +15 -0
- package/dist/module/core/web/getWebStyles.d.ts +1 -1
- package/dist/module/core/web/getWebStyles.js +12 -1
- package/dist/module/hoc/withUniwind.js +16 -4
- package/dist/module/hoc/withUniwind.native.js +13 -4
- package/dist/module/hooks/index.d.ts +0 -1
- package/dist/module/hooks/index.js +0 -1
- package/dist/module/hooks/useResolveClassNames.js +2 -2
- package/dist/module/hooks/useUniwind.d.ts +2 -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 +2 -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/generateDataSet.ts +4 -2
- package/src/components/web/useUniwindAccent.ts +21 -0
- package/src/core/web/getWebStyles.ts +20 -1
- package/src/hoc/withUniwind.native.tsx +15 -4
- package/src/hoc/withUniwind.tsx +16 -2
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useResolveClassNames.ts +2 -2
- package/src/hooks/useUniwind.ts +2 -2
- package/src/metro/addMetaToStylesTemplate.ts +2 -1
- package/src/metro/metro-transformer.ts +2 -2
- package/src/metro/processor/color.ts +2 -1
- 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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { FlatList as RNGHFlatList } from "react-native-gesture-handler";
|
|
3
|
+
import { useAccentColor } from "../../native/useAccentColor.js";
|
|
3
4
|
import { useStyle } from "../../native/useStyle.js";
|
|
4
5
|
import { copyComponentProperties } from "../../utils.js";
|
|
5
6
|
export const FlatList = copyComponentProperties(RNGHFlatList, (props) => {
|
|
@@ -8,7 +9,7 @@ export const FlatList = copyComponentProperties(RNGHFlatList, (props) => {
|
|
|
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
|
return /* @__PURE__ */ jsx(
|
|
14
15
|
RNGHFlatList,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { RefreshControl as RNGHRefreshControl } from "react-native-gesture-handler";
|
|
3
|
+
import { useAccentColor } from "../../native/useAccentColor.js";
|
|
3
4
|
import { useStyle } from "../../native/useStyle.js";
|
|
4
5
|
import { copyComponentProperties } from "../../utils.js";
|
|
5
6
|
export const RefreshControl = copyComponentProperties(RNGHRefreshControl, (props) => {
|
|
6
7
|
const style = useStyle(props.className, props);
|
|
7
|
-
const color =
|
|
8
|
-
const tintColor =
|
|
9
|
-
const titleColor =
|
|
10
|
-
const progressBackgroundColor =
|
|
8
|
+
const color = useAccentColor(props.colorsClassName, props);
|
|
9
|
+
const tintColor = useAccentColor(props.tintColorClassName, props);
|
|
10
|
+
const titleColor = useAccentColor(props.titleColorClassName, props);
|
|
11
|
+
const progressBackgroundColor = useAccentColor(props.progressBackgroundColorClassName, props);
|
|
11
12
|
return /* @__PURE__ */ jsx(
|
|
12
13
|
RNGHRefreshControl,
|
|
13
14
|
{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { Text as RNGHText } from "react-native-gesture-handler";
|
|
4
|
+
import { useAccentColor } from "../../native/useAccentColor.js";
|
|
4
5
|
import { useStyle } from "../../native/useStyle.js";
|
|
5
6
|
import { copyComponentProperties } from "../../utils.js";
|
|
6
7
|
export const Text = copyComponentProperties(RNGHText, (props) => {
|
|
@@ -10,7 +11,7 @@ export const Text = copyComponentProperties(RNGHText, (props) => {
|
|
|
10
11
|
isDisabled: Boolean(props.disabled)
|
|
11
12
|
};
|
|
12
13
|
const style = useStyle(props.className, props, state);
|
|
13
|
-
const selectionColor =
|
|
14
|
+
const selectionColor = useAccentColor(props.selectionColorClassName, props, state);
|
|
14
15
|
return /* @__PURE__ */ jsx(
|
|
15
16
|
RNGHText,
|
|
16
17
|
{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { TextInput as RNGHTextInput } from "react-native-gesture-handler";
|
|
4
|
+
import { useAccentColor } from "../../native/useAccentColor.js";
|
|
4
5
|
import { useStyle } from "../../native/useStyle.js";
|
|
5
6
|
import { copyComponentProperties } from "../../utils.js";
|
|
6
7
|
export const TextInput = copyComponentProperties(RNGHTextInput, (props) => {
|
|
@@ -13,10 +14,10 @@ export const TextInput = copyComponentProperties(RNGHTextInput, (props) => {
|
|
|
13
14
|
};
|
|
14
15
|
const style = useStyle(props.className, props, state);
|
|
15
16
|
const cursorColor = useStyle(props.cursorColorClassName, props, state).accentColor;
|
|
16
|
-
const selectionColor =
|
|
17
|
-
const placeholderTextColor =
|
|
18
|
-
const selectionHandleColor =
|
|
19
|
-
const underlineColorAndroid =
|
|
17
|
+
const selectionColor = useAccentColor(props.selectionColorClassName, props, state);
|
|
18
|
+
const placeholderTextColor = useAccentColor(props.placeholderTextColorClassName, props, state);
|
|
19
|
+
const selectionHandleColor = useAccentColor(props.selectionHandleColorClassName, props, state);
|
|
20
|
+
const underlineColorAndroid = useAccentColor(props.underlineColorAndroidClassName, props, state);
|
|
20
21
|
return /* @__PURE__ */ jsx(
|
|
21
22
|
RNGHTextInput,
|
|
22
23
|
{
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ActivityIndicator as RNActivityIndicator } from "react-native";
|
|
3
|
-
import { useUniwindAccent } from "../../hooks/index.js";
|
|
4
3
|
import { copyComponentProperties } from "../utils.js";
|
|
5
4
|
import { generateDataSet } from "./generateDataSet.js";
|
|
6
5
|
import { toRNWClassName } from "./rnw.js";
|
|
6
|
+
import { useUniwindAccent } from "./useUniwindAccent.js";
|
|
7
7
|
export const ActivityIndicator = copyComponentProperties(RNActivityIndicator, (props) => {
|
|
8
8
|
const color = useUniwindAccent(props.colorClassName);
|
|
9
9
|
return /* @__PURE__ */ jsx(
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Button as RNButton } from "react-native";
|
|
3
|
-
import { useUniwindAccent } from "../../hooks/index.js";
|
|
4
3
|
import { copyComponentProperties } from "../utils.js";
|
|
5
4
|
import { generateDataSet } from "./generateDataSet.js";
|
|
5
|
+
import { useUniwindAccent } from "./useUniwindAccent.js";
|
|
6
6
|
export const Button = copyComponentProperties(RNButton, (props) => {
|
|
7
7
|
const color = useUniwindAccent(props.colorClassName);
|
|
8
8
|
return /* @__PURE__ */ jsx(
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Image as RNImage } from "react-native";
|
|
3
|
-
import { useResolveClassNames
|
|
3
|
+
import { useResolveClassNames } from "../../hooks/index.js";
|
|
4
4
|
import { copyComponentProperties } from "../utils.js";
|
|
5
5
|
import { generateDataSet } from "./generateDataSet.js";
|
|
6
6
|
import { toRNWClassName } from "./rnw.js";
|
|
7
|
+
import { useUniwindAccent } from "./useUniwindAccent.js";
|
|
7
8
|
export const Image = copyComponentProperties(RNImage, (props) => {
|
|
8
9
|
const tintColor = useUniwindAccent(props.tintColorClassName);
|
|
9
10
|
const styles = useResolveClassNames(props.className ?? "");
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ImageBackground as RNImageBackground } from "react-native";
|
|
3
|
-
import { useUniwindAccent } from "../../hooks/index.js";
|
|
4
3
|
import { copyComponentProperties } from "../utils.js";
|
|
5
4
|
import { generateDataSet } from "./generateDataSet.js";
|
|
6
5
|
import { toRNWClassName } from "./rnw.js";
|
|
6
|
+
import { useUniwindAccent } from "./useUniwindAccent.js";
|
|
7
7
|
export const ImageBackground = copyComponentProperties(RNImageBackground, (props) => {
|
|
8
8
|
const tintColor = useUniwindAccent(props.tintColorClassName);
|
|
9
9
|
return /* @__PURE__ */ jsx(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Switch as RNSwitch } from "react-native";
|
|
3
|
-
import { useUniwindAccent } from "../../hooks/index.js";
|
|
4
3
|
import { copyComponentProperties } from "../utils.js";
|
|
5
4
|
import { generateDataSet } from "./generateDataSet.js";
|
|
6
5
|
import { toRNWClassName } from "./rnw.js";
|
|
6
|
+
import { useUniwindAccent } from "./useUniwindAccent.js";
|
|
7
7
|
export const Switch = copyComponentProperties(RNSwitch, (props) => {
|
|
8
8
|
const trackColorOn = useUniwindAccent(props.trackColorOnClassName);
|
|
9
9
|
const trackColorOff = useUniwindAccent(props.trackColorOffClassName);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { TextInput as RNTextInput } from "react-native";
|
|
3
|
-
import { useUniwindAccent } from "../../hooks/index.js";
|
|
4
3
|
import { copyComponentProperties } from "../utils.js";
|
|
5
4
|
import { generateDataSet } from "./generateDataSet.js";
|
|
6
5
|
import { toRNWClassName } from "./rnw.js";
|
|
6
|
+
import { useUniwindAccent } from "./useUniwindAccent.js";
|
|
7
7
|
export const TextInput = copyComponentProperties(RNTextInput, (props) => {
|
|
8
8
|
const placeholderTextColor = useUniwindAccent(props.placeholderTextColorClassName);
|
|
9
9
|
return /* @__PURE__ */ jsx(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { TouchableHighlight as RNTouchableHighlight } from "react-native";
|
|
3
|
-
import { useUniwindAccent } from "../../hooks/index.js";
|
|
4
3
|
import { copyComponentProperties } from "../utils.js";
|
|
5
4
|
import { generateDataSet } from "./generateDataSet.js";
|
|
6
5
|
import { toRNWClassName } from "./rnw.js";
|
|
6
|
+
import { useUniwindAccent } from "./useUniwindAccent.js";
|
|
7
7
|
export const TouchableHighlight = copyComponentProperties(RNTouchableHighlight, (props) => {
|
|
8
8
|
const underlayColor = useUniwindAccent(props.underlayColorClassName);
|
|
9
9
|
return /* @__PURE__ */ jsx(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const generateDataSet: (props: Record<PropertyKey, any>) => DataSet;
|
|
2
|
-
type DataSet = Record<string, string | boolean>;
|
|
2
|
+
type DataSet = Record<string, string | boolean | undefined>;
|
|
3
3
|
declare module 'react-native' {
|
|
4
4
|
interface SwitchProps {
|
|
5
5
|
dataSet?: DataSet;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
const toCamelCase = (str) => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
1
2
|
export const generateDataSet = (props) => {
|
|
2
3
|
const dataSet = props.dataSet !== void 0 ? { ...props.dataSet } : {};
|
|
3
4
|
Object.entries(props).forEach(([key, value]) => {
|
|
4
5
|
if (key.startsWith("data-")) {
|
|
5
|
-
dataSet[key.slice(5)] = value;
|
|
6
|
+
dataSet[toCamelCase(key.slice(5))] = value;
|
|
6
7
|
}
|
|
7
8
|
});
|
|
8
9
|
return dataSet;
|
|
@@ -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,3 +1,3 @@
|
|
|
1
1
|
import { RNStyle, UniwindContextType } from '../types';
|
|
2
|
-
export declare const getWebStyles: (className: string | undefined, uniwindContext: UniwindContextType) => RNStyle;
|
|
2
|
+
export declare const getWebStyles: (className: string | undefined, componentProps: Record<string, unknown> | undefined, uniwindContext: UniwindContextType) => RNStyle;
|
|
3
3
|
export declare const getWebVariable: (name: string, uniwindContext: UniwindContextType) => string | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { generateDataSet } from "../../components/web/generateDataSet.js";
|
|
1
2
|
import { CSSListener } from "./cssListener.js";
|
|
2
3
|
import { parseCSSValue } from "./parseCSSValue.js";
|
|
3
4
|
const dummyParent = typeof document !== "undefined" ? Object.assign(document.createElement("div"), {
|
|
@@ -33,7 +34,7 @@ const getActiveStylesForClass = (className) => {
|
|
|
33
34
|
});
|
|
34
35
|
return extractedStyles;
|
|
35
36
|
};
|
|
36
|
-
export const getWebStyles = (className, uniwindContext) => {
|
|
37
|
+
export const getWebStyles = (className, componentProps, uniwindContext) => {
|
|
37
38
|
if (className === void 0) {
|
|
38
39
|
return {};
|
|
39
40
|
}
|
|
@@ -46,7 +47,17 @@ export const getWebStyles = (className, uniwindContext) => {
|
|
|
46
47
|
dummyParent?.removeAttribute("class");
|
|
47
48
|
}
|
|
48
49
|
dummy.className = className;
|
|
50
|
+
const dataSet = generateDataSet(componentProps ?? {});
|
|
51
|
+
Object.entries(dataSet).forEach(([key, value]) => {
|
|
52
|
+
if (value === false || value === void 0) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
dummy.dataset[key] = String(value);
|
|
56
|
+
});
|
|
49
57
|
const computedStyles = getActiveStylesForClass(className);
|
|
58
|
+
Object.keys(dataSet).forEach((key) => {
|
|
59
|
+
delete dummy.dataset[key];
|
|
60
|
+
});
|
|
50
61
|
return Object.fromEntries(
|
|
51
62
|
Object.entries(computedStyles).map(([key, value]) => {
|
|
52
63
|
const parsedKey = key[0] === "-" ? key : key.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useLayoutEffect, useReducer } from "react";
|
|
3
|
+
import { isDefined } from "../common/utils.js";
|
|
4
|
+
import { generateDataSet } from "../components/web/generateDataSet.js";
|
|
3
5
|
import { useUniwindContext } from "../core/context.js";
|
|
6
|
+
import { Logger } from "../core/logger.js";
|
|
4
7
|
import { CSSListener, formatColor, getWebStyles } from "../core/web/index.js";
|
|
5
8
|
import { classToColor, classToStyle, isClassProperty, isColorClassProperty, isStyleProperty } from "./withUniwindUtils.js";
|
|
9
|
+
let warnedOnce = false;
|
|
6
10
|
export const withUniwind = (Component2, options) => options ? withManualUniwind(Component2, options) : withAutoUniwind(Component2);
|
|
7
11
|
const withAutoUniwind = (Component2) => (props) => {
|
|
8
12
|
const uniwindContext = useUniwindContext();
|
|
@@ -13,7 +17,13 @@ const withAutoUniwind = (Component2) => (props) => {
|
|
|
13
17
|
return acc;
|
|
14
18
|
}
|
|
15
19
|
const className = propValue;
|
|
16
|
-
const color = getWebStyles(className, uniwindContext).accentColor;
|
|
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
|
+
}
|
|
17
27
|
acc.generatedProps[colorProp] = color !== void 0 ? formatColor(color) : void 0;
|
|
18
28
|
acc.classNames += `${className} `;
|
|
19
29
|
return acc;
|
|
@@ -40,7 +50,8 @@ const withAutoUniwind = (Component2) => (props) => {
|
|
|
40
50
|
Component2,
|
|
41
51
|
{
|
|
42
52
|
...props,
|
|
43
|
-
...generatedProps
|
|
53
|
+
...generatedProps,
|
|
54
|
+
dataSet: generateDataSet(props)
|
|
44
55
|
}
|
|
45
56
|
);
|
|
46
57
|
};
|
|
@@ -55,7 +66,7 @@ const withManualUniwind = (Component2, options) => (props) => {
|
|
|
55
66
|
if (props[propName] !== void 0) {
|
|
56
67
|
return acc;
|
|
57
68
|
}
|
|
58
|
-
const value = getWebStyles(className, uniwindContext)[option.styleProperty];
|
|
69
|
+
const value = getWebStyles(className, props, uniwindContext)[option.styleProperty];
|
|
59
70
|
const transformedValue = value !== void 0 && option.styleProperty.toLowerCase().includes("color") ? formatColor(value) : value;
|
|
60
71
|
acc.classNames += `${className} `;
|
|
61
72
|
acc.generatedProps[propName] = transformedValue;
|
|
@@ -73,7 +84,8 @@ const withManualUniwind = (Component2, options) => (props) => {
|
|
|
73
84
|
Component2,
|
|
74
85
|
{
|
|
75
86
|
...props,
|
|
76
|
-
...generatedProps
|
|
87
|
+
...generatedProps,
|
|
88
|
+
dataSet: generateDataSet(props)
|
|
77
89
|
}
|
|
78
90
|
);
|
|
79
91
|
};
|
|
@@ -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();
|
|
@@ -13,14 +16,20 @@ const withAutoUniwind = (Component2) => (props) => {
|
|
|
13
16
|
if (props[colorProp] !== void 0) {
|
|
14
17
|
return acc;
|
|
15
18
|
}
|
|
16
|
-
const { styles, dependencies: dependencies2 } = UniwindStore.getStyles(propValue,
|
|
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;
|
|
20
29
|
}
|
|
21
30
|
if (isClassProperty(propName)) {
|
|
22
31
|
const styleProp = classToStyle(propName);
|
|
23
|
-
const { styles, dependencies: dependencies2 } = UniwindStore.getStyles(propValue,
|
|
32
|
+
const { styles, dependencies: dependencies2 } = UniwindStore.getStyles(propValue, props, void 0, uniwindContext);
|
|
24
33
|
acc.dependencies.push(...dependencies2);
|
|
25
34
|
acc.generatedProps[styleProp] ??= [];
|
|
26
35
|
acc.generatedProps[styleProp][0] = styles;
|
|
@@ -61,12 +70,12 @@ const withManualUniwind = (Component2, options) => (props) => {
|
|
|
61
70
|
if (props[propName] !== void 0) {
|
|
62
71
|
return acc;
|
|
63
72
|
}
|
|
64
|
-
const { styles: styles2, dependencies: dependencies3 } = UniwindStore.getStyles(className,
|
|
73
|
+
const { styles: styles2, dependencies: dependencies3 } = UniwindStore.getStyles(className, props, void 0, uniwindContext);
|
|
65
74
|
acc.generatedProps[propName] = styles2[option.styleProperty];
|
|
66
75
|
acc.dependencies.push(...dependencies3);
|
|
67
76
|
return acc;
|
|
68
77
|
}
|
|
69
|
-
const { styles, dependencies: dependencies2 } = UniwindStore.getStyles(className,
|
|
78
|
+
const { styles, dependencies: dependencies2 } = UniwindStore.getStyles(className, props, void 0, uniwindContext);
|
|
70
79
|
acc.dependencies.push(...dependencies2);
|
|
71
80
|
if (!isStyleProperty(propName)) {
|
|
72
81
|
acc.generatedProps[propName] = styles;
|
|
@@ -5,9 +5,9 @@ const emptyState = {};
|
|
|
5
5
|
export const useResolveClassNames = (className) => {
|
|
6
6
|
const uniwindContext = useUniwindContext();
|
|
7
7
|
const [styles, recreate] = useReducer(
|
|
8
|
-
() => className !== "" ? getWebStyles(className, uniwindContext) : emptyState,
|
|
8
|
+
() => className !== "" ? getWebStyles(className, void 0, uniwindContext) : emptyState,
|
|
9
9
|
void 0,
|
|
10
|
-
() => className !== "" ? getWebStyles(className, uniwindContext) : emptyState
|
|
10
|
+
() => className !== "" ? getWebStyles(className, void 0, uniwindContext) : emptyState
|
|
11
11
|
);
|
|
12
12
|
useLayoutEffect(() => {
|
|
13
13
|
if (className === "") {
|
|
@@ -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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@niibase/uniwind",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.2",
|
|
5
5
|
"description": "A fork of Uniwind with Reanimated 4 support",
|
|
6
6
|
"homepage": "https://uniwind.dev",
|
|
7
7
|
"author": "Unistack",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"postinstall": "node scripts/postinstall.mjs",
|
|
22
22
|
"test:native": "jest --config jest.config.native.js",
|
|
23
23
|
"test:web": "jest --config jest.config.web.js",
|
|
24
|
+
"test:types": "tsc --project tests/type-test/tsconfig.json",
|
|
24
25
|
"test:e2e": "playwright test",
|
|
25
26
|
"release": "release-it"
|
|
26
27
|
},
|
|
@@ -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
|