@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.
Files changed (150) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/common/common/utils.js +15 -0
  3. package/dist/common/components/native/ActivityIndicator.js +2 -1
  4. package/dist/common/components/native/Button.js +2 -2
  5. package/dist/common/components/native/FlatList.js +2 -1
  6. package/dist/common/components/native/Image.js +2 -1
  7. package/dist/common/components/native/ImageBackground.js +2 -1
  8. package/dist/common/components/native/InputAccessoryView.js +2 -1
  9. package/dist/common/components/native/Modal.js +2 -1
  10. package/dist/common/components/native/RefreshControl.js +5 -4
  11. package/dist/common/components/native/ScrollView.js +2 -1
  12. package/dist/common/components/native/SectionList.js +2 -1
  13. package/dist/common/components/native/Switch.js +5 -4
  14. package/dist/common/components/native/Text.js +2 -1
  15. package/dist/common/components/native/TextInput.js +6 -5
  16. package/dist/common/components/native/TouchableHighlight.js +2 -1
  17. package/dist/common/components/native/VirtualizedList.js +2 -1
  18. package/dist/common/components/native/useAccentColor.js +19 -0
  19. package/dist/common/components/react-native-gesture-handler/native/FlatList.js +2 -1
  20. package/dist/common/components/react-native-gesture-handler/native/RefreshControl.js +5 -4
  21. package/dist/common/components/react-native-gesture-handler/native/Text.js +2 -1
  22. package/dist/common/components/react-native-gesture-handler/native/TextInput.js +5 -4
  23. package/dist/common/components/web/ActivityIndicator.js +2 -2
  24. package/dist/common/components/web/Button.js +2 -2
  25. package/dist/common/components/web/Image.js +2 -1
  26. package/dist/common/components/web/ImageBackground.js +2 -2
  27. package/dist/common/components/web/Switch.js +4 -4
  28. package/dist/common/components/web/TextInput.js +2 -2
  29. package/dist/common/components/web/TouchableHighlight.js +2 -2
  30. package/dist/common/components/web/useUniwindAccent.js +20 -0
  31. package/dist/common/core/config/config.common.js +4 -7
  32. package/dist/common/core/config/config.js +42 -23
  33. package/dist/common/core/config/config.native.js +1 -3
  34. package/dist/common/core/web/cssListener.js +1 -1
  35. package/dist/common/hoc/withUniwind.js +7 -0
  36. package/dist/common/hoc/withUniwind.native.js +7 -0
  37. package/dist/common/hooks/index.js +0 -11
  38. package/dist/common/hooks/useCSSVariable/useCSSVariable.js +2 -7
  39. package/dist/metro/index.cjs +11 -5
  40. package/dist/metro/index.mjs +12 -6
  41. package/dist/metro/metro-transformer.cjs +14 -14
  42. package/dist/metro/metro-transformer.mjs +8 -8
  43. package/dist/module/common/utils.d.ts +2 -0
  44. package/dist/module/common/utils.js +7 -0
  45. package/dist/module/components/native/ActivityIndicator.js +2 -1
  46. package/dist/module/components/native/Button.js +2 -2
  47. package/dist/module/components/native/FlatList.js +2 -1
  48. package/dist/module/components/native/Image.js +2 -1
  49. package/dist/module/components/native/ImageBackground.js +2 -1
  50. package/dist/module/components/native/InputAccessoryView.js +2 -1
  51. package/dist/module/components/native/Modal.js +2 -1
  52. package/dist/module/components/native/RefreshControl.js +5 -4
  53. package/dist/module/components/native/ScrollView.js +2 -1
  54. package/dist/module/components/native/SectionList.js +2 -1
  55. package/dist/module/components/native/Switch.js +5 -4
  56. package/dist/module/components/native/Text.js +2 -1
  57. package/dist/module/components/native/TextInput.js +6 -5
  58. package/dist/module/components/native/TouchableHighlight.js +2 -1
  59. package/dist/module/components/native/VirtualizedList.js +2 -1
  60. package/dist/module/components/native/useAccentColor.d.ts +2 -0
  61. package/dist/module/components/native/useAccentColor.js +14 -0
  62. package/dist/module/components/react-native-gesture-handler/native/FlatList.js +2 -1
  63. package/dist/module/components/react-native-gesture-handler/native/RefreshControl.js +5 -4
  64. package/dist/module/components/react-native-gesture-handler/native/Text.js +2 -1
  65. package/dist/module/components/react-native-gesture-handler/native/TextInput.js +5 -4
  66. package/dist/module/components/web/ActivityIndicator.js +1 -1
  67. package/dist/module/components/web/Button.js +1 -1
  68. package/dist/module/components/web/Image.js +2 -1
  69. package/dist/module/components/web/ImageBackground.js +1 -1
  70. package/dist/module/components/web/Switch.js +1 -1
  71. package/dist/module/components/web/TextInput.js +1 -1
  72. package/dist/module/components/web/TouchableHighlight.js +1 -1
  73. package/dist/module/components/web/useUniwindAccent.js +15 -0
  74. package/dist/module/core/config/config.common.d.ts +1 -1
  75. package/dist/module/core/config/config.common.js +3 -4
  76. package/dist/module/core/config/config.d.ts +4 -4
  77. package/dist/module/core/config/config.js +44 -25
  78. package/dist/module/core/config/config.native.js +1 -3
  79. package/dist/module/core/web/cssListener.js +1 -1
  80. package/dist/module/hoc/withUniwind.js +9 -0
  81. package/dist/module/hoc/withUniwind.native.js +9 -0
  82. package/dist/module/hooks/index.d.ts +0 -1
  83. package/dist/module/hooks/index.js +0 -1
  84. package/dist/module/hooks/useCSSVariable/useCSSVariable.js +1 -6
  85. package/dist/shared/{uniwind.C-rHhHOg.mjs → uniwind.BGiqYvxb.mjs} +1 -1
  86. package/dist/shared/{uniwind.nl8746mK.cjs → uniwind.Cv73KtI-.cjs} +0 -2
  87. package/dist/shared/{uniwind.F-0-Rr--.mjs → uniwind.PtWWxxnh.mjs} +1 -2
  88. package/dist/shared/{uniwind.BZyFsest.cjs → uniwind.r2i22V6d.cjs} +1 -1
  89. package/dist/vite/index.cjs +2 -2
  90. package/dist/vite/index.mjs +2 -2
  91. package/package.json +3 -3
  92. package/src/common/utils.ts +9 -0
  93. package/src/components/native/ActivityIndicator.tsx +2 -1
  94. package/src/components/native/Button.tsx +2 -2
  95. package/src/components/native/FlatList.tsx +2 -1
  96. package/src/components/native/Image.tsx +2 -1
  97. package/src/components/native/ImageBackground.tsx +2 -1
  98. package/src/components/native/InputAccessoryView.tsx +2 -1
  99. package/src/components/native/Modal.tsx +2 -1
  100. package/src/components/native/RefreshControl.tsx +5 -4
  101. package/src/components/native/ScrollView.tsx +2 -1
  102. package/src/components/native/SectionList.tsx +2 -1
  103. package/src/components/native/Switch.tsx +5 -4
  104. package/src/components/native/Text.tsx +2 -1
  105. package/src/components/native/TextInput.tsx +6 -5
  106. package/src/components/native/TouchableHighlight.tsx +2 -1
  107. package/src/components/native/VirtualizedList.tsx +2 -1
  108. package/src/components/native/useAccentColor.ts +19 -0
  109. package/src/components/react-native-gesture-handler/native/FlatList.tsx +2 -1
  110. package/src/components/react-native-gesture-handler/native/RefreshControl.tsx +5 -4
  111. package/src/components/react-native-gesture-handler/native/Text.tsx +2 -1
  112. package/src/components/react-native-gesture-handler/native/TextInput.tsx +5 -4
  113. package/src/components/web/ActivityIndicator.tsx +1 -1
  114. package/src/components/web/Button.tsx +1 -1
  115. package/src/components/web/Image.tsx +2 -1
  116. package/src/components/web/ImageBackground.tsx +1 -1
  117. package/src/components/web/Switch.tsx +1 -1
  118. package/src/components/web/TextInput.tsx +1 -1
  119. package/src/components/web/TouchableHighlight.tsx +1 -1
  120. package/src/components/web/useUniwindAccent.ts +21 -0
  121. package/src/core/config/config.common.ts +4 -7
  122. package/src/core/config/config.native.ts +1 -3
  123. package/src/core/config/config.ts +61 -29
  124. package/src/core/logger.ts +0 -2
  125. package/src/core/native/parsers/transforms.ts +0 -1
  126. package/src/core/native/store.ts +0 -1
  127. package/src/core/web/cssListener.ts +2 -3
  128. package/src/hoc/withUniwind.native.tsx +11 -1
  129. package/src/hoc/withUniwind.tsx +11 -0
  130. package/src/hooks/index.ts +0 -1
  131. package/src/hooks/useCSSVariable/useCSSVariable.ts +1 -8
  132. package/src/metro/addMetaToStylesTemplate.ts +3 -3
  133. package/src/metro/logger.ts +0 -2
  134. package/src/metro/metro-css-patches.ts +1 -2
  135. package/src/metro/metro-transformer.ts +3 -3
  136. package/src/metro/processor/css.ts +3 -2
  137. package/src/metro/processor/functions.ts +0 -1
  138. package/src/metro/processor/rn.ts +2 -1
  139. package/src/metro/resolvers.ts +12 -13
  140. package/src/metro/utils/common.ts +0 -3
  141. package/src/metro/utils/serialize.ts +0 -1
  142. package/src/types.ts +0 -1
  143. package/dist/common/components/native/TextInput.android.js +0 -52
  144. package/dist/common/hooks/useUniwindAccent.js +0 -13
  145. package/dist/module/components/native/TextInput.android.d.ts +0 -3
  146. package/dist/module/components/native/TextInput.android.js +0 -49
  147. package/dist/module/hooks/useUniwindAccent.js +0 -6
  148. package/src/components/native/TextInput.android.tsx +0 -51
  149. package/src/hooks/useUniwindAccent.ts +0 -10
  150. /package/dist/module/{hooks → components/web}/useUniwindAccent.d.ts +0 -0
@@ -1,13 +1,14 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { SectionList as RNSectionList } from "react-native";
3
3
  import { copyComponentProperties } from "../utils.js";
4
+ import { useAccentColor } from "./useAccentColor.js";
4
5
  import { useStyle } from "./useStyle.js";
5
6
  export const SectionList = copyComponentProperties(RNSectionList, (props) => {
6
7
  const { Component, style } = useStyle(RNSectionList, props.className, 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 = useStyle(props.endFillColorClassName, props).accentColor;
11
+ const endFillColor = useAccentColor(props.endFillColorClassName, props);
11
12
  return /* @__PURE__ */ jsx(
12
13
  Component,
13
14
  {
@@ -1,6 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Switch as RNSwitch } from "react-native";
3
3
  import { copyComponentProperties } from "../utils.js";
4
+ import { useAccentColor } from "./useAccentColor.js";
4
5
  import { useStyle } from "./useStyle.js";
5
6
  export const Switch = copyComponentProperties(RNSwitch, (props) => {
6
7
  const state = {
@@ -8,10 +9,10 @@ export const Switch = copyComponentProperties(RNSwitch, (props) => {
8
9
  isPressed: Boolean(props.value)
9
10
  };
10
11
  const { Component, style } = useStyle(RNSwitch, props.className, props, state);
11
- const trackColorOn = useStyle(props.trackColorOnClassName, props, state).accentColor;
12
- const trackColorOff = useStyle(props.trackColorOffClassName, props, state).accentColor;
13
- const thumbColor = useStyle(props.thumbColorClassName, props, state).accentColor;
14
- const ios_backgroundColor = useStyle(props.ios_backgroundColorClassName, props, state).accentColor;
12
+ const trackColorOn = useAccentColor(props.trackColorOnClassName, props, state);
13
+ const trackColorOff = useAccentColor(props.trackColorOffClassName, props, state);
14
+ const thumbColor = useAccentColor(props.thumbColorClassName, props, state);
15
+ const ios_backgroundColor = useAccentColor(props.ios_backgroundColorClassName, props, state);
15
16
  return /* @__PURE__ */ jsx(
16
17
  Component,
17
18
  {
@@ -2,6 +2,7 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
3
  import { Text as RNText } from "react-native";
4
4
  import { copyComponentProperties } from "../utils.js";
5
+ import { useAccentColor } from "./useAccentColor.js";
5
6
  import { useStyle } from "./useStyle.js";
6
7
  export const Text = copyComponentProperties(RNText, (props) => {
7
8
  const [isPressed, setIsPressed] = useState(false);
@@ -10,7 +11,7 @@ export const Text = copyComponentProperties(RNText, (props) => {
10
11
  isDisabled: Boolean(props.disabled)
11
12
  };
12
13
  const { Component, style } = useStyle(RNText, props.className, props, state);
13
- const selectionColor = useStyle(props.selectionColorClassName, props, state).accentColor;
14
+ const selectionColor = useAccentColor(props.selectionColorClassName, props, state);
14
15
  return /* @__PURE__ */ jsx(
15
16
  Component,
16
17
  {
@@ -2,6 +2,7 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
3
  import { TextInput as RNTextInput } from "react-native";
4
4
  import { copyComponentProperties } from "../utils.js";
5
+ import { useAccentColor } from "./useAccentColor.js";
5
6
  import { useStyle } from "./useStyle.js";
6
7
  export const TextInput = copyComponentProperties(RNTextInput, (props) => {
7
8
  const [isFocused, setIsFocused] = useState(false);
@@ -12,11 +13,11 @@ export const TextInput = copyComponentProperties(RNTextInput, (props) => {
12
13
  isPressed
13
14
  };
14
15
  const { Component, style } = useStyle(RNTextInput, props.className, props, state);
15
- const cursorColor = useStyle(props.cursorColorClassName, props, state).accentColor;
16
- const selectionColor = useStyle(props.selectionColorClassName, props, state).accentColor;
17
- const placeholderTextColor = useStyle(props.placeholderTextColorClassName, props, state).accentColor;
18
- const selectionHandleColor = useStyle(props.selectionHandleColorClassName, props, state).accentColor;
19
- const underlineColorAndroid = useStyle(props.underlineColorAndroidClassName, props, state).accentColor;
16
+ const cursorColor = useAccentColor(props.cursorColorClassName, props, state);
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
  Component,
22
23
  {
@@ -2,6 +2,7 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
3
  import { TouchableHighlight as RNTouchableHighlight } from "react-native";
4
4
  import { copyComponentProperties } from "../utils.js";
5
+ import { useAccentColor } from "./useAccentColor.js";
5
6
  import { useStyle } from "./useStyle.js";
6
7
  export const TouchableHighlight = copyComponentProperties(RNTouchableHighlight, (props) => {
7
8
  const [isPressed, setIsPressed] = useState(false);
@@ -12,7 +13,7 @@ export const TouchableHighlight = copyComponentProperties(RNTouchableHighlight,
12
13
  isFocused
13
14
  };
14
15
  const { Component, style } = useStyle(RNTouchableHighlight, props.className, props, state);
15
- const underlayColor = useStyle(props.underlayColorClassName, props, state).accentColor;
16
+ const underlayColor = useAccentColor(props.underlayColorClassName, props, state);
16
17
  return /* @__PURE__ */ jsx(
17
18
  Component,
18
19
  {
@@ -1,13 +1,14 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { VirtualizedList as RNVirtualizedList } from "react-native";
3
3
  import { copyComponentProperties } from "../utils.js";
4
+ import { useAccentColor } from "./useAccentColor.js";
4
5
  import { useStyle } from "./useStyle.js";
5
6
  export const VirtualizedList = copyComponentProperties(RNVirtualizedList, (props) => {
6
7
  const { Component, style } = useStyle(RNVirtualizedList, props.className, 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 = useStyle(props.endFillColorClassName, props).accentColor;
11
+ const endFillColor = useAccentColor(props.endFillColorClassName, props);
11
12
  return /* @__PURE__ */ jsx(
12
13
  Component,
13
14
  {
@@ -0,0 +1,2 @@
1
+ import { ComponentState } from '../../core/types';
2
+ export declare const useAccentColor: (className: string | undefined, componentProps: Record<string, any>, state?: ComponentState) => string | undefined;
@@ -0,0 +1,14 @@
1
+ import { isDefined } from "../../common/utils.js";
2
+ import { Logger } from "../../core/logger.js";
3
+ import { useStyle } from "./useStyle.js";
4
+ let warnedOnce = false;
5
+ export const useAccentColor = (className, componentProps, state) => {
6
+ const styles = useStyle(className, componentProps, state);
7
+ if (__DEV__ && !warnedOnce && isDefined(className) && className.trim() !== "" && styles.accentColor === void 0) {
8
+ warnedOnce = true;
9
+ Logger.warn(
10
+ `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`
11
+ );
12
+ }
13
+ return styles.accentColor;
14
+ };
@@ -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 = useStyle(props.endFillColorClassName, props).accentColor;
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 = useStyle(props.colorsClassName, props).accentColor;
8
- const tintColor = useStyle(props.tintColorClassName, props).accentColor;
9
- const titleColor = useStyle(props.titleColorClassName, props).accentColor;
10
- const progressBackgroundColor = useStyle(props.progressBackgroundColorClassName, props).accentColor;
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 = useStyle(props.selectionColorClassName, props, state).accentColor;
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 = useStyle(props.selectionColorClassName, props, state).accentColor;
17
- const placeholderTextColor = useStyle(props.placeholderTextColorClassName, props, state).accentColor;
18
- const selectionHandleColor = useStyle(props.selectionHandleColorClassName, props, state).accentColor;
19
- const underlineColorAndroid = useStyle(props.underlineColorAndroidClassName, props, state).accentColor;
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, useUniwindAccent } from "../../hooks/index.js";
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(
@@ -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
+ };
@@ -15,7 +15,7 @@ export declare class UniwindConfigBuilder {
15
15
  as: T;
16
16
  } & ApplyUniwind<Omit<ComponentPropsWithRef<T>, 'as'>>): import("react").FunctionComponentElement<any>;
17
17
  setTheme(theme: ThemeName | typeof SYSTEM_THEME): void;
18
- updateCSSVariables(theme: ThemeName, variables: CSSVariables): void;
18
+ updateCSSVariables(theme: ThemeName, cssVariables: CSSVariables): void;
19
19
  updateInsets(insets: Insets): void;
20
20
  protected __reinit(_: GenerateStyleSheetsCallback, themes: Array<string>): void;
21
21
  protected onThemeChange(): void;
@@ -76,12 +76,11 @@ export class UniwindConfigBuilder {
76
76
  }
77
77
  }
78
78
  }
79
- updateCSSVariables(theme, variables) {
80
- theme;
81
- variables;
79
+ // oxlint-disable-next-line typescript/no-unused-vars
80
+ updateCSSVariables(theme, cssVariables) {
82
81
  }
82
+ // oxlint-disable-next-line typescript/no-unused-vars
83
83
  updateInsets(insets) {
84
- insets;
85
84
  }
86
85
  __reinit(_, themes) {
87
86
  this._themes = themes;
@@ -1,11 +1,11 @@
1
- import { CSSVariables, ThemeName } from '../types';
1
+ import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types';
2
2
  import { UniwindConfigBuilder as UniwindConfigBuilderBase } from './config.common';
3
3
  declare class UniwindConfigBuilder extends UniwindConfigBuilderBase {
4
- private runtimeCSSVariables;
4
+ private cssRules?;
5
5
  constructor();
6
6
  updateCSSVariables(theme: ThemeName, variables: CSSVariables): void;
7
- protected onThemeChange(): void;
8
- private applyCSSVariable;
7
+ protected __reinit(generateStyleSheetCallback: GenerateStyleSheetsCallback, themes: Array<string>): void;
8
+ private getUniwindDynamicCSSRules;
9
9
  }
10
10
  export declare const Uniwind: UniwindConfigBuilder;
11
11
  export {};
@@ -1,50 +1,69 @@
1
+ import { arrayEquals } from "../../common/utils.js";
1
2
  import { StyleDependency } from "../../types.js";
2
3
  import { UniwindListener } from "../listener.js";
3
4
  import { Logger } from "../logger.js";
5
+ import { getWebVariable } from "../web/index.js";
4
6
  import { UniwindConfigBuilder as UniwindConfigBuilderBase } from "./config.common.js";
5
7
  class UniwindConfigBuilder extends UniwindConfigBuilderBase {
6
- runtimeCSSVariables = /* @__PURE__ */ new Map();
8
+ cssRules;
7
9
  constructor() {
8
10
  super();
9
11
  }
10
12
  updateCSSVariables(theme, variables) {
13
+ if (typeof document === "undefined") {
14
+ return;
15
+ }
16
+ const uniwindRules = this.getUniwindDynamicCSSRules();
11
17
  Object.entries(variables).forEach(([varName, varValue]) => {
12
18
  if (!varName.startsWith("--") && __DEV__) {
13
19
  Logger.error(`CSS variable name must start with "--", instead got: ${varName}`);
14
- return;
15
- }
16
- const runtimeCSSVariables = this.runtimeCSSVariables.get(theme) ?? {};
17
- runtimeCSSVariables[varName] = varValue;
18
- this.runtimeCSSVariables.set(theme, runtimeCSSVariables);
19
- if (theme === this.currentTheme) {
20
- this.applyCSSVariable(varName, varValue);
21
20
  }
21
+ const existingRules = Object.fromEntries(
22
+ uniwindRules.map((rule) => [rule.theme, getWebVariable(varName, { scopedTheme: rule.theme })])
23
+ );
24
+ uniwindRules.forEach((rule) => {
25
+ if (rule.theme === theme) {
26
+ rule.style.setProperty(
27
+ varName,
28
+ typeof varValue === "number" ? `${varValue}px` : varValue
29
+ );
30
+ return;
31
+ }
32
+ rule.style.setProperty(varName, existingRules[rule.theme] ?? null);
33
+ });
22
34
  });
23
- if (theme === this.currentTheme) {
24
- UniwindListener.notify([StyleDependency.Variables]);
25
- }
35
+ UniwindListener.notify([StyleDependency.Variables]);
26
36
  }
27
- onThemeChange() {
28
- if (typeof document === "undefined") {
37
+ __reinit(generateStyleSheetCallback, themes) {
38
+ const oldThemes = this.themes;
39
+ super.__reinit(generateStyleSheetCallback, themes);
40
+ if (arrayEquals(themes, oldThemes)) {
29
41
  return;
30
42
  }
31
- document.documentElement.removeAttribute("style");
32
- const runtimeCSSVariables = this.runtimeCSSVariables.get(this.currentTheme);
33
- if (!runtimeCSSVariables) {
34
- return;
43
+ this.cssRules = void 0;
44
+ if (typeof document !== "undefined") {
45
+ document.querySelector("#uniwind-dynamic-styles")?.remove();
35
46
  }
36
- Object.entries(runtimeCSSVariables).forEach(([varName, varValue]) => {
37
- this.applyCSSVariable(varName, varValue);
38
- });
39
47
  }
40
- applyCSSVariable(varName, varValue) {
48
+ getUniwindDynamicCSSRules() {
49
+ if (this.cssRules) {
50
+ return this.cssRules;
51
+ }
41
52
  if (typeof document === "undefined") {
42
- return;
53
+ return [];
43
54
  }
44
- document.documentElement.style.setProperty(
45
- varName,
46
- typeof varValue === "number" ? `${varValue}px` : varValue
55
+ const styleElement = document.createElement("style");
56
+ styleElement.innerText = this.themes.reduce(
57
+ (acc, theme) => {
58
+ return `${acc}.${theme}{}`;
59
+ },
60
+ ""
47
61
  );
62
+ styleElement.setAttribute("id", "uniwind-dynamic-styles");
63
+ document.head.appendChild(styleElement);
64
+ const cssRules = Array.from(styleElement.sheet?.cssRules ?? []).filter((rule) => "selectorText" in rule && "style" in rule).map((rule) => ({ style: rule.style, theme: rule.selectorText.replace(".", "") }));
65
+ this.cssRules = cssRules;
66
+ return cssRules;
48
67
  }
49
68
  }
50
69
  export const Uniwind = new UniwindConfigBuilder();
@@ -31,9 +31,7 @@ class UniwindConfigBuilder extends UniwindConfigBuilderBase {
31
31
  get: getValue
32
32
  });
33
33
  });
34
- if (theme === this.currentTheme) {
35
- UniwindListener.notify([StyleDependency.Variables]);
36
- }
34
+ UniwindListener.notify([StyleDependency.Variables]);
37
35
  }
38
36
  updateInsets(insets) {
39
37
  UniwindStore.runtime.insets.bottom = insets.bottom ?? 0;
@@ -49,7 +49,7 @@ class CSSListenerBuilder {
49
49
  listeners?.add(listener);
50
50
  disposables.push(() => listeners?.delete(listener));
51
51
  });
52
- const disposeThemeListener = UniwindListener.subscribe(listener, [StyleDependency.Theme]);
52
+ const disposeThemeListener = UniwindListener.subscribe(listener, [StyleDependency.Theme, StyleDependency.Variables]);
53
53
  return () => {
54
54
  disposables.forEach((disposable) => disposable());
55
55
  disposeThemeListener();
@@ -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;
@@ -1,4 +1,3 @@
1
1
  export * from './useCSSVariable';
2
2
  export * from './useResolveClassNames';
3
3
  export * from './useUniwind';
4
- export * from './useUniwindAccent';
@@ -1,4 +1,3 @@
1
1
  export * from "./useCSSVariable/index.js";
2
2
  export * from "./useResolveClassNames.js";
3
3
  export * from "./useUniwind.js";
4
- export * from "./useUniwindAccent.js";
@@ -1,16 +1,11 @@
1
1
  import { useLayoutEffect, useRef, useState } from "react";
2
+ import { arrayEquals } from "../../common/utils.js";
2
3
  import { useUniwindContext } from "../../core/context.js";
3
4
  import { UniwindListener } from "../../core/listener.js";
4
5
  import { Logger } from "../../core/logger.js";
5
6
  import { StyleDependency } from "../../types.js";
6
7
  import { getVariableValue } from "./getVariableValue.js";
7
8
  const getValue = (name, uniwindContext) => Array.isArray(name) ? name.map((name2) => getVariableValue(name2, uniwindContext)) : getVariableValue(name, uniwindContext);
8
- const arrayEquals = (a, b) => {
9
- if (a.length !== b.length) {
10
- return false;
11
- }
12
- return a.every((value, index) => value === b[index]);
13
- };
14
9
  let warned = false;
15
10
  const logDevError = (name) => {
16
11
  warned = true;
@@ -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.F-0-Rr--.mjs';
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, isDefined as c, deepEqual as d, shouldBeSerialized as e, removeKeys as f, isNumber as i, name as n, pipe as p, roundToPrecision as r, smartSplit as s, toCamelCase as t, uniq as u };
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.nl8746mK.cjs');
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
 
@@ -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.nl8746mK.cjs');
6
- const stringifyThemes = require('../shared/uniwind.BZyFsest.cjs');
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