@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.
Files changed (138) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/common/common/utils.js +8 -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/generateDataSet.js +2 -1
  31. package/dist/common/components/web/useUniwindAccent.js +20 -0
  32. package/dist/common/core/web/getWebStyles.js +12 -1
  33. package/dist/common/hoc/withUniwind.js +14 -4
  34. package/dist/common/hoc/withUniwind.native.js +11 -4
  35. package/dist/common/hooks/index.js +0 -11
  36. package/dist/common/hooks/useResolveClassNames.js +1 -1
  37. package/dist/metro/index.cjs +1 -1
  38. package/dist/metro/index.mjs +1 -1
  39. package/dist/metro/metro-transformer.cjs +14 -11
  40. package/dist/metro/metro-transformer.mjs +8 -5
  41. package/dist/module/common/utils.d.ts +1 -0
  42. package/dist/module/common/utils.js +1 -0
  43. package/dist/module/components/native/ActivityIndicator.js +2 -1
  44. package/dist/module/components/native/Button.js +2 -2
  45. package/dist/module/components/native/FlatList.js +2 -1
  46. package/dist/module/components/native/Image.js +2 -1
  47. package/dist/module/components/native/ImageBackground.js +2 -1
  48. package/dist/module/components/native/InputAccessoryView.js +2 -1
  49. package/dist/module/components/native/Modal.js +2 -1
  50. package/dist/module/components/native/RefreshControl.js +5 -4
  51. package/dist/module/components/native/ScrollView.js +2 -1
  52. package/dist/module/components/native/SectionList.js +2 -1
  53. package/dist/module/components/native/Switch.js +5 -4
  54. package/dist/module/components/native/Text.js +2 -1
  55. package/dist/module/components/native/TextInput.js +6 -5
  56. package/dist/module/components/native/TouchableHighlight.js +2 -1
  57. package/dist/module/components/native/VirtualizedList.js +2 -1
  58. package/dist/module/components/native/useAccentColor.d.ts +2 -0
  59. package/dist/module/components/native/useAccentColor.js +14 -0
  60. package/dist/module/components/react-native-gesture-handler/native/FlatList.js +2 -1
  61. package/dist/module/components/react-native-gesture-handler/native/RefreshControl.js +5 -4
  62. package/dist/module/components/react-native-gesture-handler/native/Text.js +2 -1
  63. package/dist/module/components/react-native-gesture-handler/native/TextInput.js +5 -4
  64. package/dist/module/components/web/ActivityIndicator.js +1 -1
  65. package/dist/module/components/web/Button.js +1 -1
  66. package/dist/module/components/web/Image.js +2 -1
  67. package/dist/module/components/web/ImageBackground.js +1 -1
  68. package/dist/module/components/web/Switch.js +1 -1
  69. package/dist/module/components/web/TextInput.js +1 -1
  70. package/dist/module/components/web/TouchableHighlight.js +1 -1
  71. package/dist/module/components/web/generateDataSet.d.ts +1 -1
  72. package/dist/module/components/web/generateDataSet.js +2 -1
  73. package/dist/module/components/web/useUniwindAccent.js +15 -0
  74. package/dist/module/core/web/getWebStyles.d.ts +1 -1
  75. package/dist/module/core/web/getWebStyles.js +12 -1
  76. package/dist/module/hoc/withUniwind.js +16 -4
  77. package/dist/module/hoc/withUniwind.native.js +13 -4
  78. package/dist/module/hooks/index.d.ts +0 -1
  79. package/dist/module/hooks/index.js +0 -1
  80. package/dist/module/hooks/useResolveClassNames.js +2 -2
  81. package/dist/module/hooks/useUniwind.d.ts +2 -1
  82. package/dist/shared/{uniwind.C-rHhHOg.mjs → uniwind.BGiqYvxb.mjs} +1 -1
  83. package/dist/shared/{uniwind.nl8746mK.cjs → uniwind.Cv73KtI-.cjs} +0 -2
  84. package/dist/shared/{uniwind.F-0-Rr--.mjs → uniwind.PtWWxxnh.mjs} +1 -2
  85. package/dist/shared/{uniwind.BZyFsest.cjs → uniwind.r2i22V6d.cjs} +1 -1
  86. package/dist/vite/index.cjs +2 -2
  87. package/dist/vite/index.mjs +2 -2
  88. package/package.json +2 -1
  89. package/src/common/utils.ts +1 -0
  90. package/src/components/native/ActivityIndicator.tsx +2 -1
  91. package/src/components/native/Button.tsx +2 -2
  92. package/src/components/native/FlatList.tsx +2 -1
  93. package/src/components/native/Image.tsx +2 -1
  94. package/src/components/native/ImageBackground.tsx +2 -1
  95. package/src/components/native/InputAccessoryView.tsx +2 -1
  96. package/src/components/native/Modal.tsx +2 -1
  97. package/src/components/native/RefreshControl.tsx +5 -4
  98. package/src/components/native/ScrollView.tsx +2 -1
  99. package/src/components/native/SectionList.tsx +2 -1
  100. package/src/components/native/Switch.tsx +5 -4
  101. package/src/components/native/Text.tsx +2 -1
  102. package/src/components/native/TextInput.tsx +6 -5
  103. package/src/components/native/TouchableHighlight.tsx +2 -1
  104. package/src/components/native/VirtualizedList.tsx +2 -1
  105. package/src/components/native/useAccentColor.ts +19 -0
  106. package/src/components/react-native-gesture-handler/native/FlatList.tsx +2 -1
  107. package/src/components/react-native-gesture-handler/native/RefreshControl.tsx +5 -4
  108. package/src/components/react-native-gesture-handler/native/Text.tsx +2 -1
  109. package/src/components/react-native-gesture-handler/native/TextInput.tsx +5 -4
  110. package/src/components/web/ActivityIndicator.tsx +1 -1
  111. package/src/components/web/Button.tsx +1 -1
  112. package/src/components/web/Image.tsx +2 -1
  113. package/src/components/web/ImageBackground.tsx +1 -1
  114. package/src/components/web/Switch.tsx +1 -1
  115. package/src/components/web/TextInput.tsx +1 -1
  116. package/src/components/web/TouchableHighlight.tsx +1 -1
  117. package/src/components/web/generateDataSet.ts +4 -2
  118. package/src/components/web/useUniwindAccent.ts +21 -0
  119. package/src/core/web/getWebStyles.ts +20 -1
  120. package/src/hoc/withUniwind.native.tsx +15 -4
  121. package/src/hoc/withUniwind.tsx +16 -2
  122. package/src/hooks/index.ts +0 -1
  123. package/src/hooks/useResolveClassNames.ts +2 -2
  124. package/src/hooks/useUniwind.ts +2 -2
  125. package/src/metro/addMetaToStylesTemplate.ts +2 -1
  126. package/src/metro/metro-transformer.ts +2 -2
  127. package/src/metro/processor/color.ts +2 -1
  128. package/src/metro/processor/css.ts +3 -1
  129. package/src/metro/processor/rn.ts +2 -1
  130. package/src/metro/utils/common.ts +0 -2
  131. package/dist/common/components/native/TextInput.android.js +0 -52
  132. package/dist/common/hooks/useUniwindAccent.js +0 -13
  133. package/dist/module/components/native/TextInput.android.d.ts +0 -3
  134. package/dist/module/components/native/TextInput.android.js +0 -49
  135. package/dist/module/hooks/useUniwindAccent.js +0 -6
  136. package/src/components/native/TextInput.android.tsx +0 -51
  137. package/src/hooks/useUniwindAccent.ts +0 -10
  138. /package/dist/module/{hooks → components/web}/useUniwindAccent.d.ts +0 -0
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getWebVariable = exports.getWebStyles = void 0;
7
+ var _generateDataSet = require("../../components/web/generateDataSet");
7
8
  var _cssListener = require("./cssListener");
8
9
  var _parseCSSValue = require("./parseCSSValue");
9
10
  const dummyParent = typeof document !== "undefined" ? Object.assign(document.createElement("div"), {
@@ -38,7 +39,7 @@ const getActiveStylesForClass = className => {
38
39
  });
39
40
  return extractedStyles;
40
41
  };
41
- const getWebStyles = (className, uniwindContext) => {
42
+ const getWebStyles = (className, componentProps, uniwindContext) => {
42
43
  if (className === void 0) {
43
44
  return {};
44
45
  }
@@ -51,7 +52,17 @@ const getWebStyles = (className, uniwindContext) => {
51
52
  dummyParent?.removeAttribute("class");
52
53
  }
53
54
  dummy.className = className;
55
+ const dataSet = (0, _generateDataSet.generateDataSet)(componentProps ?? {});
56
+ Object.entries(dataSet).forEach(([key, value]) => {
57
+ if (value === false || value === void 0) {
58
+ return;
59
+ }
60
+ dummy.dataset[key] = String(value);
61
+ });
54
62
  const computedStyles = getActiveStylesForClass(className);
63
+ Object.keys(dataSet).forEach(key => {
64
+ delete dummy.dataset[key];
65
+ });
55
66
  return Object.fromEntries(Object.entries(computedStyles).map(([key, value]) => {
56
67
  const parsedKey = key[0] === "-" ? key : key.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
57
68
  return [parsedKey, (0, _parseCSSValue.parseCSSValue)(value)];
@@ -6,9 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.withUniwind = void 0;
7
7
  var _jsxRuntime = require("react/jsx-runtime");
8
8
  var _react = require("react");
9
+ var _utils = require("../common/utils");
10
+ var _generateDataSet = require("../components/web/generateDataSet");
9
11
  var _context = require("../core/context");
12
+ var _logger = require("../core/logger");
10
13
  var _web = require("../core/web");
11
14
  var _withUniwindUtils = require("./withUniwindUtils");
15
+ let warnedOnce = false;
12
16
  const withUniwind = (Component2, options) => options ? withManualUniwind(Component2, options) : withAutoUniwind(Component2);
13
17
  exports.withUniwind = withUniwind;
14
18
  const withAutoUniwind = Component2 => props => {
@@ -23,7 +27,11 @@ const withAutoUniwind = Component2 => props => {
23
27
  return acc;
24
28
  }
25
29
  const className = propValue;
26
- const color = (0, _web.getWebStyles)(className, uniwindContext).accentColor;
30
+ const color = (0, _web.getWebStyles)(className, props, uniwindContext).accentColor;
31
+ if (__DEV__ && !warnedOnce && (0, _utils.isDefined)(className) && className.trim() !== "" && color === void 0) {
32
+ warnedOnce = true;
33
+ _logger.Logger.warn(`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`);
34
+ }
27
35
  acc.generatedProps[colorProp] = color !== void 0 ? (0, _web.formatColor)(color) : void 0;
28
36
  acc.classNames += `${className} `;
29
37
  return acc;
@@ -54,7 +62,8 @@ const withAutoUniwind = Component2 => props => {
54
62
  }, [classNames]);
55
63
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(Component2, {
56
64
  ...props,
57
- ...generatedProps
65
+ ...generatedProps,
66
+ dataSet: (0, _generateDataSet.generateDataSet)(props)
58
67
  });
59
68
  };
60
69
  const withManualUniwind = (Component2, options) => props => {
@@ -71,7 +80,7 @@ const withManualUniwind = (Component2, options) => props => {
71
80
  if (props[propName] !== void 0) {
72
81
  return acc;
73
82
  }
74
- const value = (0, _web.getWebStyles)(className, uniwindContext)[option.styleProperty];
83
+ const value = (0, _web.getWebStyles)(className, props, uniwindContext)[option.styleProperty];
75
84
  const transformedValue = value !== void 0 && option.styleProperty.toLowerCase().includes("color") ? (0, _web.formatColor)(value) : value;
76
85
  acc.classNames += `${className} `;
77
86
  acc.generatedProps[propName] = transformedValue;
@@ -93,6 +102,7 @@ const withManualUniwind = (Component2, options) => props => {
93
102
  }, [classNames]);
94
103
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(Component2, {
95
104
  ...props,
96
- ...generatedProps
105
+ ...generatedProps,
106
+ dataSet: (0, _generateDataSet.generateDataSet)(props)
97
107
  });
98
108
  };
@@ -6,10 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.withUniwind = void 0;
7
7
  var _jsxRuntime = require("react/jsx-runtime");
8
8
  var _react = require("react");
9
+ var _utils = require("../common/utils");
9
10
  var _context = require("../core/context");
10
11
  var _listener = require("../core/listener");
12
+ var _logger = require("../core/logger");
11
13
  var _native = require("../core/native");
12
14
  var _withUniwindUtils = require("./withUniwindUtils");
15
+ let warnedOnce = false;
13
16
  const withUniwind = (Component2, options) => options ? withManualUniwind(Component2, options) : withAutoUniwind(Component2);
14
17
  exports.withUniwind = withUniwind;
15
18
  const withAutoUniwind = Component2 => props => {
@@ -26,7 +29,11 @@ const withAutoUniwind = Component2 => props => {
26
29
  const {
27
30
  styles,
28
31
  dependencies: dependencies2
29
- } = _native.UniwindStore.getStyles(propValue, void 0, void 0, uniwindContext);
32
+ } = _native.UniwindStore.getStyles(propValue, props, void 0, uniwindContext);
33
+ if (__DEV__ && !warnedOnce && (0, _utils.isDefined)(propValue) && propValue.trim() !== "" && styles.accentColor === void 0) {
34
+ warnedOnce = true;
35
+ _logger.Logger.warn(`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`);
36
+ }
30
37
  acc.dependencies.push(...dependencies2);
31
38
  acc.generatedProps[colorProp] = styles.accentColor;
32
39
  return acc;
@@ -36,7 +43,7 @@ const withAutoUniwind = Component2 => props => {
36
43
  const {
37
44
  styles,
38
45
  dependencies: dependencies2
39
- } = _native.UniwindStore.getStyles(propValue, void 0, void 0, uniwindContext);
46
+ } = _native.UniwindStore.getStyles(propValue, props, void 0, uniwindContext);
40
47
  acc.dependencies.push(...dependencies2);
41
48
  acc.generatedProps[styleProp] ??= [];
42
49
  acc.generatedProps[styleProp][0] = styles;
@@ -83,7 +90,7 @@ const withManualUniwind = (Component2, options) => props => {
83
90
  const {
84
91
  styles: styles2,
85
92
  dependencies: dependencies3
86
- } = _native.UniwindStore.getStyles(className, void 0, void 0, uniwindContext);
93
+ } = _native.UniwindStore.getStyles(className, props, void 0, uniwindContext);
87
94
  acc.generatedProps[propName] = styles2[option.styleProperty];
88
95
  acc.dependencies.push(...dependencies3);
89
96
  return acc;
@@ -91,7 +98,7 @@ const withManualUniwind = (Component2, options) => props => {
91
98
  const {
92
99
  styles,
93
100
  dependencies: dependencies2
94
- } = _native.UniwindStore.getStyles(className, void 0, void 0, uniwindContext);
101
+ } = _native.UniwindStore.getStyles(className, props, void 0, uniwindContext);
95
102
  acc.dependencies.push(...dependencies2);
96
103
  if (!(0, _withUniwindUtils.isStyleProperty)(propName)) {
97
104
  acc.generatedProps[propName] = styles;
@@ -35,15 +35,4 @@ Object.keys(_useUniwind).forEach(function (key) {
35
35
  return _useUniwind[key];
36
36
  }
37
37
  });
38
- });
39
- var _useUniwindAccent = require("./useUniwindAccent");
40
- Object.keys(_useUniwindAccent).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _useUniwindAccent[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _useUniwindAccent[key];
47
- }
48
- });
49
38
  });
@@ -10,7 +10,7 @@ var _web = require("../core/web");
10
10
  const emptyState = {};
11
11
  const useResolveClassNames = className => {
12
12
  const uniwindContext = (0, _context.useUniwindContext)();
13
- const [styles, recreate] = (0, _react.useReducer)(() => className !== "" ? (0, _web.getWebStyles)(className, uniwindContext) : emptyState, void 0, () => className !== "" ? (0, _web.getWebStyles)(className, uniwindContext) : emptyState);
13
+ const [styles, recreate] = (0, _react.useReducer)(() => className !== "" ? (0, _web.getWebStyles)(className, void 0, uniwindContext) : emptyState, void 0, () => className !== "" ? (0, _web.getWebStyles)(className, void 0, uniwindContext) : emptyState);
14
14
  (0, _react.useLayoutEffect)(() => {
15
15
  if (className === "") {
16
16
  return;
@@ -5,7 +5,7 @@ const FileStoreBase = require('metro-cache/private/stores/FileStore');
5
5
  const os = require('os');
6
6
  const path = require('path');
7
7
  const node_path = require('node:path');
8
- const common = require('../shared/uniwind.nl8746mK.cjs');
8
+ const common = require('../shared/uniwind.Cv73KtI-.cjs');
9
9
 
10
10
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
11
11
 
@@ -3,7 +3,7 @@ import FileStoreBase from 'metro-cache/private/stores/FileStore';
3
3
  import os from 'os';
4
4
  import path from 'path';
5
5
  import { join, dirname, sep, basename } from 'node:path';
6
- import { n as name, u as uniq } from '../shared/uniwind.F-0-Rr--.mjs';
6
+ import { n as name, u as uniq } from '../shared/uniwind.PtWWxxnh.mjs';
7
7
 
8
8
  class FileStore extends FileStoreBase {
9
9
  async set(key, value) {
@@ -2,12 +2,12 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
- const common = require('../shared/uniwind.nl8746mK.cjs');
5
+ const common = require('../shared/uniwind.Cv73KtI-.cjs');
6
6
  const consts = require('../shared/uniwind.B5q8hBGv.cjs');
7
7
  const node = require('@tailwindcss/node');
8
8
  const oxide = require('@tailwindcss/oxide');
9
9
  const lightningcss = require('lightningcss');
10
- const stringifyThemes = require('../shared/uniwind.BZyFsest.cjs');
10
+ const stringifyThemes = require('../shared/uniwind.r2i22V6d.cjs');
11
11
  const culori = require('culori');
12
12
 
13
13
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
@@ -114,6 +114,8 @@ const serializeJSObject = (obj, serializer) => {
114
114
  return serializedObject;
115
115
  };
116
116
 
117
+ const isDefined = (value) => value !== void 0 && value !== null;
118
+
117
119
  var StyleDependency = /* @__PURE__ */ ((StyleDependency2) => {
118
120
  StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
119
121
  StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
@@ -236,7 +238,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
236
238
  ].filter(Boolean).length
237
239
  };
238
240
  });
239
- const filteredStyles = styles.filter(common.isDefined);
241
+ const filteredStyles = styles.filter(isDefined);
240
242
  if (filteredStyles.length === 0) {
241
243
  return null;
242
244
  }
@@ -244,7 +246,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
244
246
  className,
245
247
  filteredStyles
246
248
  ];
247
- }).filter(common.isDefined);
249
+ }).filter(isDefined);
248
250
  const stylesheets = Object.fromEntries(stylesheetsEntries);
249
251
  return stylesheets;
250
252
  };
@@ -340,8 +342,9 @@ class Color {
340
342
  mode: "rgb"
341
343
  });
342
344
  }
345
+ const colorType = color.type === "display-p3" ? "p3" : color.type;
343
346
  const result = this.toRgb({
344
- mode: color.type,
347
+ mode: colorType,
345
348
  ...color
346
349
  });
347
350
  return this.format(result);
@@ -542,7 +545,7 @@ class CSS {
542
545
  this.processValue(filter.value.yOffset),
543
546
  this.processValue(filter.value.blur),
544
547
  this.processValue(filter.value.color)
545
- ].filter(common.isDefined);
548
+ ].filter(isDefined);
546
549
  return `drop-shadow(${parts.join(" ")})`;
547
550
  }
548
551
  const value = this.processValue(filter.value);
@@ -775,7 +778,7 @@ class CSS {
775
778
  return [
776
779
  this.Processor.Color.processColor(declarationValue.color),
777
780
  declarationValue.position ? this.processValue(declarationValue.position) : null
778
- ].filter(common.isDefined).join(" ");
781
+ ].filter(isDefined).join(" ");
779
782
  case "side":
780
783
  return declarationValue.side;
781
784
  case "absolute":
@@ -910,7 +913,7 @@ class CSS {
910
913
  this.processValue(declarationValue.blur),
911
914
  this.processValue(declarationValue.spread),
912
915
  this.processValue(declarationValue.color)
913
- ].filter(common.isDefined).join(" ");
916
+ ].filter(isDefined).join(" ");
914
917
  }
915
918
  if ("blockStart" in declarationValue) {
916
919
  const startValue = this.processValue(declarationValue.blockStart);
@@ -1503,7 +1506,7 @@ class RN {
1503
1506
  typeof value === "string" ? common.addMissingSpaces(value) : value
1504
1507
  );
1505
1508
  const joinedStyles = this.joinStyles(rn);
1506
- return Object.entries(joinedStyles).filter(([, value2]) => common.isDefined(value2));
1509
+ return Object.entries(joinedStyles).filter(([, value2]) => isDefined(value2));
1507
1510
  }
1508
1511
  transformProperty(property, value) {
1509
1512
  if (property in cssToRNMap) {
@@ -2071,7 +2074,7 @@ try {
2071
2074
  worker = require("metro-transform-worker");
2072
2075
  }
2073
2076
  const transform = async (config, projectRoot, filePath, data, options) => {
2074
- const isCss = options.type !== "asset" && path__default.join(process.cwd(), config.uniwind.cssEntryFile) === path__default.join(process.cwd(), filePath);
2077
+ const isCss = options.type !== "asset" && path__default.join(process.cwd(), config.uniwind.cssEntryFile) === path__default.join(projectRoot, filePath);
2075
2078
  if (filePath.endsWith("/components/web/metro-injected.js")) {
2076
2079
  const cssPath2 = path__default.join(process.cwd(), config.uniwind.cssEntryFile);
2077
2080
  const injectedThemesCode2 = await injectThemes({
@@ -2108,7 +2111,7 @@ const transform = async (config, projectRoot, filePath, data, options) => {
2108
2111
  themes: config.uniwind.themes,
2109
2112
  dtsPath: config.uniwind.dtsFile
2110
2113
  });
2111
- const css = fs__default.readFileSync(filePath, "utf-8");
2114
+ const css = fs__default.readFileSync(cssPath, "utf-8");
2112
2115
  const platform = getPlatform();
2113
2116
  const virtualCode = await compileVirtual({
2114
2117
  css,
@@ -1,11 +1,11 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import { p as pipe, r as roundToPrecision, i as isNumber, a as isValidJSValue, s as smartSplit, b as addMissingSpaces, t as toCamelCase, c as isDefined, d as deepEqual, e as shouldBeSerialized, f as removeKeys, n as name } from '../shared/uniwind.F-0-Rr--.mjs';
3
+ import { p as pipe, r as roundToPrecision, i as isNumber, a as isValidJSValue, s as smartSplit, b as addMissingSpaces, t as toCamelCase, d as deepEqual, c as shouldBeSerialized, e as removeKeys, n as name } from '../shared/uniwind.PtWWxxnh.mjs';
4
4
  import { P as Platform, U as UNIWIND_PLATFORM_VARIABLES, a as UNIWIND_THEME_VARIABLES } from '../shared/uniwind.JSWK3vHl.mjs';
5
5
  import { compile } from '@tailwindcss/node';
6
6
  import { Scanner } from '@tailwindcss/oxide';
7
7
  import { transform as transform$1 } from 'lightningcss';
8
- import { L as Logger, U as UniwindCSSVisitor, s as stringifyThemes, b as buildDtsFile, a as buildCSS } from '../shared/uniwind.C-rHhHOg.mjs';
8
+ import { L as Logger, U as UniwindCSSVisitor, s as stringifyThemes, b as buildDtsFile, a as buildCSS } from '../shared/uniwind.BGiqYvxb.mjs';
9
9
  import { converter, parse, formatHex, formatHex8 } from 'culori';
10
10
 
11
11
  const parseStringValue = (value) => {
@@ -107,6 +107,8 @@ const serializeJSObject = (obj, serializer) => {
107
107
  return serializedObject;
108
108
  };
109
109
 
110
+ const isDefined = (value) => value !== void 0 && value !== null;
111
+
110
112
  var StyleDependency = /* @__PURE__ */ ((StyleDependency2) => {
111
113
  StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
112
114
  StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
@@ -333,8 +335,9 @@ class Color {
333
335
  mode: "rgb"
334
336
  });
335
337
  }
338
+ const colorType = color.type === "display-p3" ? "p3" : color.type;
336
339
  const result = this.toRgb({
337
- mode: color.type,
340
+ mode: colorType,
338
341
  ...color
339
342
  });
340
343
  return this.format(result);
@@ -2064,7 +2067,7 @@ try {
2064
2067
  worker = require("metro-transform-worker");
2065
2068
  }
2066
2069
  const transform = async (config, projectRoot, filePath, data, options) => {
2067
- const isCss = options.type !== "asset" && path.join(process.cwd(), config.uniwind.cssEntryFile) === path.join(process.cwd(), filePath);
2070
+ const isCss = options.type !== "asset" && path.join(process.cwd(), config.uniwind.cssEntryFile) === path.join(projectRoot, filePath);
2068
2071
  if (filePath.endsWith("/components/web/metro-injected.js")) {
2069
2072
  const cssPath2 = path.join(process.cwd(), config.uniwind.cssEntryFile);
2070
2073
  const injectedThemesCode2 = await injectThemes({
@@ -2101,7 +2104,7 @@ const transform = async (config, projectRoot, filePath, data, options) => {
2101
2104
  themes: config.uniwind.themes,
2102
2105
  dtsPath: config.uniwind.dtsFile
2103
2106
  });
2104
- const css = fs.readFileSync(filePath, "utf-8");
2107
+ const css = fs.readFileSync(cssPath, "utf-8");
2105
2108
  const platform = getPlatform();
2106
2109
  const virtualCode = await compileVirtual({
2107
2110
  css,
@@ -0,0 +1 @@
1
+ export declare const isDefined: <T>(value: T) => value is NonNullable<T>;
@@ -0,0 +1 @@
1
+ export const isDefined = (value) => value !== void 0 && value !== null;
@@ -1,10 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { ActivityIndicator as RNActivityIndicator } 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 ActivityIndicator = copyComponentProperties(RNActivityIndicator, (props) => {
6
7
  const { Component, style } = useStyle(RNActivityIndicator, props.className, props, { isPressed: Boolean(props.animating) });
7
- const color = useStyle(props.colorClassName, props).accentColor;
8
+ const color = useAccentColor(props.colorClassName, props);
8
9
  return /* @__PURE__ */ jsx(
9
10
  Component,
10
11
  {
@@ -1,9 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Button as RNButton } from "react-native";
3
3
  import { copyComponentProperties } from "../utils.js";
4
- import { useStyle } from "./useStyle.js";
4
+ import { useAccentColor } from "./useAccentColor.js";
5
5
  export const Button = copyComponentProperties(RNButton, (props) => {
6
- const color = useStyle(props.colorClassName, props).accentColor;
6
+ const color = useAccentColor(props.colorClassName, props);
7
7
  return /* @__PURE__ */ jsx(
8
8
  RNButton,
9
9
  {
@@ -1,6 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { FlatList as RNFlatList } 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 FlatList = copyComponentProperties(RNFlatList, (props) => {
6
7
  const { Component, style } = useStyle(RNFlatList, props.className, props);
@@ -8,7 +9,7 @@ export const FlatList = copyComponentProperties(RNFlatList, (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
  Component,
@@ -1,10 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Image as RNImage } 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 Image = copyComponentProperties(RNImage, (props) => {
6
7
  const { Component, style } = useStyle(RNImage, props.className, props);
7
- const tintColor = useStyle(props.tintColorClassName, props).accentColor;
8
+ const tintColor = useAccentColor(props.tintColorClassName, props);
8
9
  return /* @__PURE__ */ jsx(
9
10
  Component,
10
11
  {
@@ -1,11 +1,12 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { ImageBackground as RNImageBackground } 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 ImageBackground = copyComponentProperties(RNImageBackground, (props) => {
6
7
  const { Component, style } = useStyle(RNImageBackground, props.className, props);
7
8
  const imageStyle = useStyle(props.imageClassName, props);
8
- const tintColor = useStyle(props.tintColorClassName, props).accentColor;
9
+ const tintColor = useAccentColor(props.tintColorClassName, props);
9
10
  return /* @__PURE__ */ jsx(
10
11
  Component,
11
12
  {
@@ -1,12 +1,13 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { InputAccessoryView as RNInputAccessoryView } 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 InputAccessoryView = copyComponentProperties(
6
7
  RNInputAccessoryView,
7
8
  (props) => {
8
9
  const { Component, style } = useStyle(RNInputAccessoryView, props.className, props);
9
- const backgroundColor = useStyle(props.backgroundColorClassName, props).accentColor;
10
+ const backgroundColor = useAccentColor(props.backgroundColorClassName, props);
10
11
  return /* @__PURE__ */ jsx(
11
12
  Component,
12
13
  {
@@ -1,10 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Modal as RNModal } 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 Modal = copyComponentProperties(RNModal, (props) => {
6
7
  const { Component, style } = useStyle(RNModal, props.className, props);
7
- const backdropColor = useStyle(props.backdropColorClassName, props).accentColor;
8
+ const backdropColor = useAccentColor(props.backdropColorClassName, props);
8
9
  return /* @__PURE__ */ jsx(
9
10
  Component,
10
11
  {
@@ -1,15 +1,16 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { RefreshControl as RNRefreshControl } 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 RefreshControl = copyComponentProperties(RNRefreshControl, (props) => {
6
7
  const { Component, style } = useStyle(RNRefreshControl, props.className, props, {
7
8
  isPressed: Boolean(props.refreshing)
8
9
  });
9
- const color = useStyle(props.colorsClassName, props).accentColor;
10
- const tintColor = useStyle(props.tintColorClassName, props).accentColor;
11
- const titleColor = useStyle(props.titleColorClassName, props).accentColor;
12
- const progressBackgroundColor = useStyle(props.progressBackgroundColorClassName, props).accentColor;
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
  return /* @__PURE__ */ jsx(
14
15
  Component,
15
16
  {
@@ -1,11 +1,12 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { ScrollView as RNScrollView } 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 ScrollView = copyComponentProperties(RNScrollView, (props) => {
6
7
  const { Component, style } = useStyle(RNScrollView, props.className, props);
7
8
  const contentContainerStyle = useStyle(props.contentContainerClassName, props);
8
- const endFillColor = useStyle(props.endFillColorClassName, props).accentColor;
9
+ const endFillColor = useAccentColor(props.endFillColorClassName, props);
9
10
  return /* @__PURE__ */ jsx(
10
11
  Component,
11
12
  {
@@ -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
+ };