@kbach/react 0.6.7 → 0.6.8

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.
@@ -791,6 +791,13 @@ function hexToRgba(hex, alpha) {
791
791
  const [r, g, b] = rgb;
792
792
  return `rgba(${r},${g},${b},${alpha})`;
793
793
  }
794
+ function withOpacityVar(color, varName) {
795
+ if (!color.startsWith("#")) return color;
796
+ const rgb = parseHexRgb(color);
797
+ if (!rgb) return color;
798
+ const [r, g, b] = rgb;
799
+ return `rgba(${r},${g},${b},var(${varName},1))`;
800
+ }
794
801
  function resolveSpacing(value, negative, spacing, isArbitrary) {
795
802
  if (isArbitrary) {
796
803
  const resolved = getEffectiveIsWeb() ? value : toNativeValue(value);
@@ -1237,7 +1244,8 @@ var RESOLVERS = {
1237
1244
  // ── Background ─────────────────────────────────────────────────────────────
1238
1245
  bg: ({ value, isArbitrary }, { colors }) => {
1239
1246
  const color = resolveColor(value, colors, isArbitrary);
1240
- return color ? { backgroundColor: color } : null;
1247
+ if (!color) return null;
1248
+ return { backgroundColor: getEffectiveIsWeb() ? withOpacityVar(color, "--bg-opacity") : color };
1241
1249
  },
1242
1250
  "bg-opacity": ({ value, isArbitrary }, _) => {
1243
1251
  if (!getEffectiveIsWeb()) return null;
@@ -1254,10 +1262,11 @@ var RESOLVERS = {
1254
1262
  if (/^\d/.test(value) || /^(calc|min|max|clamp)/.test(value)) {
1255
1263
  return { fontSize: getEffectiveIsWeb() ? value : toNativeValue(value) };
1256
1264
  }
1257
- return { color: value };
1265
+ return { color: getEffectiveIsWeb() ? withOpacityVar(value, "--text-opacity") : value };
1258
1266
  }
1259
1267
  const color = resolveColor(value, colors, false);
1260
- return color ? { color } : null;
1268
+ if (!color) return null;
1269
+ return { color: getEffectiveIsWeb() ? withOpacityVar(color, "--text-opacity") : color };
1261
1270
  },
1262
1271
  "text-opacity": ({ value, isArbitrary }, _) => {
1263
1272
  if (!getEffectiveIsWeb()) return null;
@@ -2807,7 +2816,8 @@ function styleValueToCSS(styles, forceImportant = false) {
2807
2816
  if (val === void 0 || val === null || typeof val === "object" || RN_ONLY_PROPS.has(prop)) continue;
2808
2817
  let cssVal;
2809
2818
  if (typeof val === "number") {
2810
- cssVal = val === 0 || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
2819
+ const isCustomProp = prop.startsWith("--");
2820
+ cssVal = val === 0 || isCustomProp || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
2811
2821
  } else {
2812
2822
  cssVal = String(val);
2813
2823
  }
@@ -23,7 +23,7 @@ import {
23
23
  transformToWebProps,
24
24
  useConditionalWidth,
25
25
  useGlobalDarkMode
26
- } from "./chunk-LXOMVLQI.mjs";
26
+ } from "./chunk-ELFAWQI6.mjs";
27
27
 
28
28
  // src/jsx-runtime.tsx
29
29
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
package/dist/index.js CHANGED
@@ -910,6 +910,13 @@ function hexToRgba(hex, alpha) {
910
910
  const [r, g, b] = rgb;
911
911
  return `rgba(${r},${g},${b},${alpha})`;
912
912
  }
913
+ function withOpacityVar(color, varName) {
914
+ if (!color.startsWith("#")) return color;
915
+ const rgb = parseHexRgb(color);
916
+ if (!rgb) return color;
917
+ const [r, g, b] = rgb;
918
+ return `rgba(${r},${g},${b},var(${varName},1))`;
919
+ }
913
920
  function resolveSpacing(value, negative, spacing, isArbitrary) {
914
921
  if (isArbitrary) {
915
922
  const resolved = getEffectiveIsWeb() ? value : toNativeValue(value);
@@ -1356,7 +1363,8 @@ var RESOLVERS = {
1356
1363
  // ── Background ─────────────────────────────────────────────────────────────
1357
1364
  bg: ({ value, isArbitrary }, { colors }) => {
1358
1365
  const color = resolveColor(value, colors, isArbitrary);
1359
- return color ? { backgroundColor: color } : null;
1366
+ if (!color) return null;
1367
+ return { backgroundColor: getEffectiveIsWeb() ? withOpacityVar(color, "--bg-opacity") : color };
1360
1368
  },
1361
1369
  "bg-opacity": ({ value, isArbitrary }, _) => {
1362
1370
  if (!getEffectiveIsWeb()) return null;
@@ -1373,10 +1381,11 @@ var RESOLVERS = {
1373
1381
  if (/^\d/.test(value) || /^(calc|min|max|clamp)/.test(value)) {
1374
1382
  return { fontSize: getEffectiveIsWeb() ? value : toNativeValue(value) };
1375
1383
  }
1376
- return { color: value };
1384
+ return { color: getEffectiveIsWeb() ? withOpacityVar(value, "--text-opacity") : value };
1377
1385
  }
1378
1386
  const color = resolveColor(value, colors, false);
1379
- return color ? { color } : null;
1387
+ if (!color) return null;
1388
+ return { color: getEffectiveIsWeb() ? withOpacityVar(color, "--text-opacity") : color };
1380
1389
  },
1381
1390
  "text-opacity": ({ value, isArbitrary }, _) => {
1382
1391
  if (!getEffectiveIsWeb()) return null;
@@ -2885,7 +2894,8 @@ function styleValueToCSS(styles, forceImportant = false) {
2885
2894
  if (val === void 0 || val === null || typeof val === "object" || RN_ONLY_PROPS.has(prop)) continue;
2886
2895
  let cssVal;
2887
2896
  if (typeof val === "number") {
2888
- cssVal = val === 0 || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
2897
+ const isCustomProp = prop.startsWith("--");
2898
+ cssVal = val === 0 || isCustomProp || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
2889
2899
  } else {
2890
2900
  cssVal = String(val);
2891
2901
  }
package/dist/index.mjs CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  useGlobalDarkMode,
37
37
  useGlobalWidth,
38
38
  useSyncExternalStore
39
- } from "./chunk-LXOMVLQI.mjs";
39
+ } from "./chunk-ELFAWQI6.mjs";
40
40
 
41
41
  // src/context.tsx
42
42
  import { createContext, useContext } from "react";
@@ -869,6 +869,13 @@ function hexToRgba(hex, alpha) {
869
869
  const [r, g, b] = rgb;
870
870
  return `rgba(${r},${g},${b},${alpha})`;
871
871
  }
872
+ function withOpacityVar(color, varName) {
873
+ if (!color.startsWith("#")) return color;
874
+ const rgb = parseHexRgb(color);
875
+ if (!rgb) return color;
876
+ const [r, g, b] = rgb;
877
+ return `rgba(${r},${g},${b},var(${varName},1))`;
878
+ }
872
879
  function resolveSpacing(value, negative, spacing, isArbitrary) {
873
880
  if (isArbitrary) {
874
881
  const resolved = getEffectiveIsWeb() ? value : toNativeValue(value);
@@ -1315,7 +1322,8 @@ var RESOLVERS = {
1315
1322
  // ── Background ─────────────────────────────────────────────────────────────
1316
1323
  bg: ({ value, isArbitrary }, { colors }) => {
1317
1324
  const color = resolveColor(value, colors, isArbitrary);
1318
- return color ? { backgroundColor: color } : null;
1325
+ if (!color) return null;
1326
+ return { backgroundColor: getEffectiveIsWeb() ? withOpacityVar(color, "--bg-opacity") : color };
1319
1327
  },
1320
1328
  "bg-opacity": ({ value, isArbitrary }, _) => {
1321
1329
  if (!getEffectiveIsWeb()) return null;
@@ -1332,10 +1340,11 @@ var RESOLVERS = {
1332
1340
  if (/^\d/.test(value) || /^(calc|min|max|clamp)/.test(value)) {
1333
1341
  return { fontSize: getEffectiveIsWeb() ? value : toNativeValue(value) };
1334
1342
  }
1335
- return { color: value };
1343
+ return { color: getEffectiveIsWeb() ? withOpacityVar(value, "--text-opacity") : value };
1336
1344
  }
1337
1345
  const color = resolveColor(value, colors, false);
1338
- return color ? { color } : null;
1346
+ if (!color) return null;
1347
+ return { color: getEffectiveIsWeb() ? withOpacityVar(color, "--text-opacity") : color };
1339
1348
  },
1340
1349
  "text-opacity": ({ value, isArbitrary }, _) => {
1341
1350
  if (!getEffectiveIsWeb()) return null;
@@ -2829,7 +2838,8 @@ function styleValueToCSS(styles, forceImportant = false) {
2829
2838
  if (val === void 0 || val === null || typeof val === "object" || RN_ONLY_PROPS.has(prop)) continue;
2830
2839
  let cssVal;
2831
2840
  if (typeof val === "number") {
2832
- cssVal = val === 0 || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
2841
+ const isCustomProp = prop.startsWith("--");
2842
+ cssVal = val === 0 || isCustomProp || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
2833
2843
  } else {
2834
2844
  cssVal = String(val);
2835
2845
  }
@@ -3,8 +3,8 @@ import {
3
3
  Fragment,
4
4
  jsx,
5
5
  jsxs
6
- } from "./chunk-5YN6PIXQ.mjs";
7
- import "./chunk-LXOMVLQI.mjs";
6
+ } from "./chunk-HOWJ3U6D.mjs";
7
+ import "./chunk-ELFAWQI6.mjs";
8
8
 
9
9
  // src/jsx-dev-runtime.tsx
10
10
  function jsxDEV(type, props, key, isStaticChildren, source, self) {
@@ -870,6 +870,13 @@ function hexToRgba(hex, alpha) {
870
870
  const [r, g, b] = rgb;
871
871
  return `rgba(${r},${g},${b},${alpha})`;
872
872
  }
873
+ function withOpacityVar(color, varName) {
874
+ if (!color.startsWith("#")) return color;
875
+ const rgb = parseHexRgb(color);
876
+ if (!rgb) return color;
877
+ const [r, g, b] = rgb;
878
+ return `rgba(${r},${g},${b},var(${varName},1))`;
879
+ }
873
880
  function resolveSpacing(value, negative, spacing, isArbitrary) {
874
881
  if (isArbitrary) {
875
882
  const resolved = getEffectiveIsWeb() ? value : toNativeValue(value);
@@ -1316,7 +1323,8 @@ var RESOLVERS = {
1316
1323
  // ── Background ─────────────────────────────────────────────────────────────
1317
1324
  bg: ({ value, isArbitrary }, { colors }) => {
1318
1325
  const color = resolveColor(value, colors, isArbitrary);
1319
- return color ? { backgroundColor: color } : null;
1326
+ if (!color) return null;
1327
+ return { backgroundColor: getEffectiveIsWeb() ? withOpacityVar(color, "--bg-opacity") : color };
1320
1328
  },
1321
1329
  "bg-opacity": ({ value, isArbitrary }, _) => {
1322
1330
  if (!getEffectiveIsWeb()) return null;
@@ -1333,10 +1341,11 @@ var RESOLVERS = {
1333
1341
  if (/^\d/.test(value) || /^(calc|min|max|clamp)/.test(value)) {
1334
1342
  return { fontSize: getEffectiveIsWeb() ? value : toNativeValue(value) };
1335
1343
  }
1336
- return { color: value };
1344
+ return { color: getEffectiveIsWeb() ? withOpacityVar(value, "--text-opacity") : value };
1337
1345
  }
1338
1346
  const color = resolveColor(value, colors, false);
1339
- return color ? { color } : null;
1347
+ if (!color) return null;
1348
+ return { color: getEffectiveIsWeb() ? withOpacityVar(color, "--text-opacity") : color };
1340
1349
  },
1341
1350
  "text-opacity": ({ value, isArbitrary }, _) => {
1342
1351
  if (!getEffectiveIsWeb()) return null;
@@ -2830,7 +2839,8 @@ function styleValueToCSS(styles, forceImportant = false) {
2830
2839
  if (val === void 0 || val === null || typeof val === "object" || RN_ONLY_PROPS.has(prop)) continue;
2831
2840
  let cssVal;
2832
2841
  if (typeof val === "number") {
2833
- cssVal = val === 0 || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
2842
+ const isCustomProp = prop.startsWith("--");
2843
+ cssVal = val === 0 || isCustomProp || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
2834
2844
  } else {
2835
2845
  cssVal = String(val);
2836
2846
  }
@@ -4,10 +4,10 @@ import {
4
4
  _invalidateDefaultFontCache,
5
5
  jsx,
6
6
  jsxs
7
- } from "./chunk-5YN6PIXQ.mjs";
7
+ } from "./chunk-HOWJ3U6D.mjs";
8
8
  import {
9
9
  registerWebElement
10
- } from "./chunk-LXOMVLQI.mjs";
10
+ } from "./chunk-ELFAWQI6.mjs";
11
11
  export {
12
12
  Fragment,
13
13
  _invalidateDefaultFontCache,
@@ -701,6 +701,13 @@ function hexToRgba(hex, alpha) {
701
701
  const [r, g, b] = rgb;
702
702
  return `rgba(${r},${g},${b},${alpha})`;
703
703
  }
704
+ function withOpacityVar(color, varName) {
705
+ if (!color.startsWith("#")) return color;
706
+ const rgb = parseHexRgb(color);
707
+ if (!rgb) return color;
708
+ const [r, g, b] = rgb;
709
+ return `rgba(${r},${g},${b},var(${varName},1))`;
710
+ }
704
711
  function resolveSpacing(value, negative, spacing, isArbitrary) {
705
712
  if (isArbitrary) {
706
713
  const resolved = getEffectiveIsWeb() ? value : toNativeValue(value);
@@ -1147,7 +1154,8 @@ var RESOLVERS = {
1147
1154
  // ── Background ─────────────────────────────────────────────────────────────
1148
1155
  bg: ({ value, isArbitrary }, { colors }) => {
1149
1156
  const color = resolveColor(value, colors, isArbitrary);
1150
- return color ? { backgroundColor: color } : null;
1157
+ if (!color) return null;
1158
+ return { backgroundColor: getEffectiveIsWeb() ? withOpacityVar(color, "--bg-opacity") : color };
1151
1159
  },
1152
1160
  "bg-opacity": ({ value, isArbitrary }, _) => {
1153
1161
  if (!getEffectiveIsWeb()) return null;
@@ -1164,10 +1172,11 @@ var RESOLVERS = {
1164
1172
  if (/^\d/.test(value) || /^(calc|min|max|clamp)/.test(value)) {
1165
1173
  return { fontSize: getEffectiveIsWeb() ? value : toNativeValue(value) };
1166
1174
  }
1167
- return { color: value };
1175
+ return { color: getEffectiveIsWeb() ? withOpacityVar(value, "--text-opacity") : value };
1168
1176
  }
1169
1177
  const color = resolveColor(value, colors, false);
1170
- return color ? { color } : null;
1178
+ if (!color) return null;
1179
+ return { color: getEffectiveIsWeb() ? withOpacityVar(color, "--text-opacity") : color };
1171
1180
  },
1172
1181
  "text-opacity": ({ value, isArbitrary }, _) => {
1173
1182
  if (!getEffectiveIsWeb()) return null;
@@ -2732,7 +2741,8 @@ function styleValueToCSS(styles, forceImportant = false) {
2732
2741
  if (val === void 0 || val === null || typeof val === "object" || RN_ONLY_PROPS.has(prop)) continue;
2733
2742
  let cssVal;
2734
2743
  if (typeof val === "number") {
2735
- cssVal = val === 0 || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
2744
+ const isCustomProp = prop.startsWith("--");
2745
+ cssVal = val === 0 || isCustomProp || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
2736
2746
  } else {
2737
2747
  cssVal = String(val);
2738
2748
  }
@@ -667,6 +667,13 @@ function hexToRgba(hex, alpha) {
667
667
  const [r, g, b] = rgb;
668
668
  return `rgba(${r},${g},${b},${alpha})`;
669
669
  }
670
+ function withOpacityVar(color, varName) {
671
+ if (!color.startsWith("#")) return color;
672
+ const rgb = parseHexRgb(color);
673
+ if (!rgb) return color;
674
+ const [r, g, b] = rgb;
675
+ return `rgba(${r},${g},${b},var(${varName},1))`;
676
+ }
670
677
  function resolveSpacing(value, negative, spacing, isArbitrary) {
671
678
  if (isArbitrary) {
672
679
  const resolved = getEffectiveIsWeb() ? value : toNativeValue(value);
@@ -1113,7 +1120,8 @@ var RESOLVERS = {
1113
1120
  // ── Background ─────────────────────────────────────────────────────────────
1114
1121
  bg: ({ value, isArbitrary }, { colors }) => {
1115
1122
  const color = resolveColor(value, colors, isArbitrary);
1116
- return color ? { backgroundColor: color } : null;
1123
+ if (!color) return null;
1124
+ return { backgroundColor: getEffectiveIsWeb() ? withOpacityVar(color, "--bg-opacity") : color };
1117
1125
  },
1118
1126
  "bg-opacity": ({ value, isArbitrary }, _) => {
1119
1127
  if (!getEffectiveIsWeb()) return null;
@@ -1130,10 +1138,11 @@ var RESOLVERS = {
1130
1138
  if (/^\d/.test(value) || /^(calc|min|max|clamp)/.test(value)) {
1131
1139
  return { fontSize: getEffectiveIsWeb() ? value : toNativeValue(value) };
1132
1140
  }
1133
- return { color: value };
1141
+ return { color: getEffectiveIsWeb() ? withOpacityVar(value, "--text-opacity") : value };
1134
1142
  }
1135
1143
  const color = resolveColor(value, colors, false);
1136
- return color ? { color } : null;
1144
+ if (!color) return null;
1145
+ return { color: getEffectiveIsWeb() ? withOpacityVar(color, "--text-opacity") : color };
1137
1146
  },
1138
1147
  "text-opacity": ({ value, isArbitrary }, _) => {
1139
1148
  if (!getEffectiveIsWeb()) return null;
@@ -2698,7 +2707,8 @@ function styleValueToCSS(styles, forceImportant = false) {
2698
2707
  if (val === void 0 || val === null || typeof val === "object" || RN_ONLY_PROPS.has(prop)) continue;
2699
2708
  let cssVal;
2700
2709
  if (typeof val === "number") {
2701
- cssVal = val === 0 || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
2710
+ const isCustomProp = prop.startsWith("--");
2711
+ cssVal = val === 0 || isCustomProp || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
2702
2712
  } else {
2703
2713
  cssVal = String(val);
2704
2714
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/react",
3
- "version": "0.6.7",
3
+ "version": "0.6.8",
4
4
  "description": "React / React Native components and hooks for the Kbach framework",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./dist/index.js",