@kbach/react 0.6.36 → 0.6.37

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.
@@ -26,7 +26,7 @@ import {
26
26
  transformToWebProps,
27
27
  useConditionalGlobalDarkMode,
28
28
  useConditionalWidth
29
- } from "./chunk-ATZF2VI7.mjs";
29
+ } from "./chunk-ZTDE7V7I.mjs";
30
30
 
31
31
  // src/jsx-runtime.tsx
32
32
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -3269,30 +3269,51 @@ function getConfig() {
3269
3269
  configStore.resolved = buildConfig({});
3270
3270
  return configStore.resolved;
3271
3271
  }
3272
- function resolveOneRef(ref, colors) {
3273
- const lastDash = ref.lastIndexOf("-");
3274
- if (lastDash <= 0) return null;
3275
- const name = ref.slice(0, lastDash);
3276
- const shade = ref.slice(lastDash + 1);
3277
- if (!/^\d+$/.test(shade)) return null;
3278
- const entry = colors[name];
3279
- if (!entry || typeof entry !== "object" || isModeAwareColor(entry)) return null;
3280
- const target = entry[shade];
3281
- return typeof target === "string" ? target : null;
3282
- }
3283
3272
  function resolveColorRefs(colors) {
3284
3273
  const MAX_DEPTH = 5;
3285
- function resolveChain(raw) {
3274
+ function resolveChain(raw, side) {
3286
3275
  let current = raw;
3287
3276
  for (let i = 0; i < MAX_DEPTH; i++) {
3288
- const next = resolveOneRef(current, colors);
3277
+ const next = resolveOneRef(current, side);
3289
3278
  if (!next || next === current) break;
3290
3279
  current = next;
3291
3280
  }
3292
3281
  return current;
3293
3282
  }
3283
+ function resolveOneRef(ref, side) {
3284
+ const slashIdx = ref.indexOf("/");
3285
+ if (slashIdx > 0) {
3286
+ const baseName = ref.slice(0, slashIdx);
3287
+ const opacity = Number(ref.slice(slashIdx + 1));
3288
+ if (!Number.isFinite(opacity)) return null;
3289
+ let baseRef;
3290
+ const entry2 = colors[baseName];
3291
+ if (typeof entry2 === "string") {
3292
+ baseRef = entry2;
3293
+ } else if (isModeAwareColor(entry2)) {
3294
+ if (!side) return null;
3295
+ baseRef = entry2[side];
3296
+ } else if (entry2 && typeof entry2 === "object" && "6" in entry2) {
3297
+ const v = entry2["6"];
3298
+ baseRef = typeof v === "string" ? v : void 0;
3299
+ }
3300
+ if (baseRef === void 0) return null;
3301
+ const baseHex = resolveChain(baseRef, side);
3302
+ const a = opacity > 1 ? opacity / 100 : opacity;
3303
+ return hexToRgba(baseHex, a);
3304
+ }
3305
+ const lastDash = ref.lastIndexOf("-");
3306
+ if (lastDash <= 0) return null;
3307
+ const name = ref.slice(0, lastDash);
3308
+ const shade = ref.slice(lastDash + 1);
3309
+ if (!/^\d+$/.test(shade)) return null;
3310
+ const entry = colors[name];
3311
+ if (!entry || typeof entry !== "object" || isModeAwareColor(entry)) return null;
3312
+ const target = entry[shade];
3313
+ return typeof target === "string" ? target : null;
3314
+ }
3294
3315
  function resolveValue(val) {
3295
- return typeof val === "string" ? resolveChain(val) : { light: resolveChain(val.light), dark: resolveChain(val.dark) };
3316
+ return typeof val === "string" ? resolveChain(val, null) : { light: resolveChain(val.light, "light"), dark: resolveChain(val.dark, "dark") };
3296
3317
  }
3297
3318
  const out = {};
3298
3319
  for (const [key, val] of Object.entries(colors)) {
@@ -3371,30 +3371,51 @@ function getConfig() {
3371
3371
  function resetConfig() {
3372
3372
  configStore.resolved = null;
3373
3373
  }
3374
- function resolveOneRef(ref, colors) {
3375
- const lastDash = ref.lastIndexOf("-");
3376
- if (lastDash <= 0) return null;
3377
- const name = ref.slice(0, lastDash);
3378
- const shade = ref.slice(lastDash + 1);
3379
- if (!/^\d+$/.test(shade)) return null;
3380
- const entry = colors[name];
3381
- if (!entry || typeof entry !== "object" || isModeAwareColor(entry)) return null;
3382
- const target = entry[shade];
3383
- return typeof target === "string" ? target : null;
3384
- }
3385
3374
  function resolveColorRefs(colors) {
3386
3375
  const MAX_DEPTH = 5;
3387
- function resolveChain(raw) {
3376
+ function resolveChain(raw, side) {
3388
3377
  let current = raw;
3389
3378
  for (let i = 0; i < MAX_DEPTH; i++) {
3390
- const next = resolveOneRef(current, colors);
3379
+ const next = resolveOneRef(current, side);
3391
3380
  if (!next || next === current) break;
3392
3381
  current = next;
3393
3382
  }
3394
3383
  return current;
3395
3384
  }
3385
+ function resolveOneRef(ref, side) {
3386
+ const slashIdx = ref.indexOf("/");
3387
+ if (slashIdx > 0) {
3388
+ const baseName = ref.slice(0, slashIdx);
3389
+ const opacity = Number(ref.slice(slashIdx + 1));
3390
+ if (!Number.isFinite(opacity)) return null;
3391
+ let baseRef;
3392
+ const entry2 = colors[baseName];
3393
+ if (typeof entry2 === "string") {
3394
+ baseRef = entry2;
3395
+ } else if (isModeAwareColor(entry2)) {
3396
+ if (!side) return null;
3397
+ baseRef = entry2[side];
3398
+ } else if (entry2 && typeof entry2 === "object" && "6" in entry2) {
3399
+ const v = entry2["6"];
3400
+ baseRef = typeof v === "string" ? v : void 0;
3401
+ }
3402
+ if (baseRef === void 0) return null;
3403
+ const baseHex = resolveChain(baseRef, side);
3404
+ const a = opacity > 1 ? opacity / 100 : opacity;
3405
+ return hexToRgba(baseHex, a);
3406
+ }
3407
+ const lastDash = ref.lastIndexOf("-");
3408
+ if (lastDash <= 0) return null;
3409
+ const name = ref.slice(0, lastDash);
3410
+ const shade = ref.slice(lastDash + 1);
3411
+ if (!/^\d+$/.test(shade)) return null;
3412
+ const entry = colors[name];
3413
+ if (!entry || typeof entry !== "object" || isModeAwareColor(entry)) return null;
3414
+ const target = entry[shade];
3415
+ return typeof target === "string" ? target : null;
3416
+ }
3396
3417
  function resolveValue(val) {
3397
- return typeof val === "string" ? resolveChain(val) : { light: resolveChain(val.light), dark: resolveChain(val.dark) };
3418
+ return typeof val === "string" ? resolveChain(val, null) : { light: resolveChain(val.light, "light"), dark: resolveChain(val.dark, "dark") };
3398
3419
  }
3399
3420
  const out = {};
3400
3421
  for (const [key, val] of Object.entries(colors)) {
package/dist/index.mjs CHANGED
@@ -45,7 +45,7 @@ import {
45
45
  useGlobalDarkMode,
46
46
  useGlobalWidth,
47
47
  useSyncExternalStore
48
- } from "./chunk-ATZF2VI7.mjs";
48
+ } from "./chunk-ZTDE7V7I.mjs";
49
49
 
50
50
  // src/context.tsx
51
51
  import { createContext, useContext } from "react";
@@ -3,8 +3,8 @@ import {
3
3
  Fragment,
4
4
  jsx,
5
5
  jsxs
6
- } from "./chunk-YDLZI5J6.mjs";
7
- import "./chunk-ATZF2VI7.mjs";
6
+ } from "./chunk-OUKVG4DI.mjs";
7
+ import "./chunk-ZTDE7V7I.mjs";
8
8
 
9
9
  // src/jsx-dev-runtime.tsx
10
10
  function jsxDEV(type, props, key, isStaticChildren, source, self) {
@@ -4,10 +4,10 @@ import {
4
4
  _invalidateDefaultFontCache,
5
5
  jsx,
6
6
  jsxs
7
- } from "./chunk-YDLZI5J6.mjs";
7
+ } from "./chunk-OUKVG4DI.mjs";
8
8
  import {
9
9
  registerWebElement
10
- } from "./chunk-ATZF2VI7.mjs";
10
+ } from "./chunk-ZTDE7V7I.mjs";
11
11
  export {
12
12
  Fragment,
13
13
  _invalidateDefaultFontCache,
@@ -3072,30 +3072,51 @@ function deepMerge(base, override) {
3072
3072
  return result;
3073
3073
  }
3074
3074
  var configStore = { resolved: null, listeners: /* @__PURE__ */ new Set(), customVariants: {} };
3075
- function resolveOneRef(ref, colors) {
3076
- const lastDash = ref.lastIndexOf("-");
3077
- if (lastDash <= 0) return null;
3078
- const name = ref.slice(0, lastDash);
3079
- const shade = ref.slice(lastDash + 1);
3080
- if (!/^\d+$/.test(shade)) return null;
3081
- const entry = colors[name];
3082
- if (!entry || typeof entry !== "object" || isModeAwareColor(entry)) return null;
3083
- const target = entry[shade];
3084
- return typeof target === "string" ? target : null;
3085
- }
3086
3075
  function resolveColorRefs(colors) {
3087
3076
  const MAX_DEPTH = 5;
3088
- function resolveChain(raw) {
3077
+ function resolveChain(raw, side) {
3089
3078
  let current = raw;
3090
3079
  for (let i = 0; i < MAX_DEPTH; i++) {
3091
- const next = resolveOneRef(current, colors);
3080
+ const next = resolveOneRef(current, side);
3092
3081
  if (!next || next === current) break;
3093
3082
  current = next;
3094
3083
  }
3095
3084
  return current;
3096
3085
  }
3086
+ function resolveOneRef(ref, side) {
3087
+ const slashIdx = ref.indexOf("/");
3088
+ if (slashIdx > 0) {
3089
+ const baseName = ref.slice(0, slashIdx);
3090
+ const opacity = Number(ref.slice(slashIdx + 1));
3091
+ if (!Number.isFinite(opacity)) return null;
3092
+ let baseRef;
3093
+ const entry2 = colors[baseName];
3094
+ if (typeof entry2 === "string") {
3095
+ baseRef = entry2;
3096
+ } else if (isModeAwareColor(entry2)) {
3097
+ if (!side) return null;
3098
+ baseRef = entry2[side];
3099
+ } else if (entry2 && typeof entry2 === "object" && "6" in entry2) {
3100
+ const v = entry2["6"];
3101
+ baseRef = typeof v === "string" ? v : void 0;
3102
+ }
3103
+ if (baseRef === void 0) return null;
3104
+ const baseHex = resolveChain(baseRef, side);
3105
+ const a = opacity > 1 ? opacity / 100 : opacity;
3106
+ return hexToRgba(baseHex, a);
3107
+ }
3108
+ const lastDash = ref.lastIndexOf("-");
3109
+ if (lastDash <= 0) return null;
3110
+ const name = ref.slice(0, lastDash);
3111
+ const shade = ref.slice(lastDash + 1);
3112
+ if (!/^\d+$/.test(shade)) return null;
3113
+ const entry = colors[name];
3114
+ if (!entry || typeof entry !== "object" || isModeAwareColor(entry)) return null;
3115
+ const target = entry[shade];
3116
+ return typeof target === "string" ? target : null;
3117
+ }
3097
3118
  function resolveValue(val) {
3098
- return typeof val === "string" ? resolveChain(val) : { light: resolveChain(val.light), dark: resolveChain(val.dark) };
3119
+ return typeof val === "string" ? resolveChain(val, null) : { light: resolveChain(val.light, "light"), dark: resolveChain(val.dark, "dark") };
3099
3120
  }
3100
3121
  const out = {};
3101
3122
  for (const [key, val] of Object.entries(colors)) {
@@ -3038,30 +3038,51 @@ function deepMerge(base, override) {
3038
3038
  return result;
3039
3039
  }
3040
3040
  var configStore = { resolved: null, listeners: /* @__PURE__ */ new Set(), customVariants: {} };
3041
- function resolveOneRef(ref, colors) {
3042
- const lastDash = ref.lastIndexOf("-");
3043
- if (lastDash <= 0) return null;
3044
- const name = ref.slice(0, lastDash);
3045
- const shade = ref.slice(lastDash + 1);
3046
- if (!/^\d+$/.test(shade)) return null;
3047
- const entry = colors[name];
3048
- if (!entry || typeof entry !== "object" || isModeAwareColor(entry)) return null;
3049
- const target = entry[shade];
3050
- return typeof target === "string" ? target : null;
3051
- }
3052
3041
  function resolveColorRefs(colors) {
3053
3042
  const MAX_DEPTH = 5;
3054
- function resolveChain(raw) {
3043
+ function resolveChain(raw, side) {
3055
3044
  let current = raw;
3056
3045
  for (let i = 0; i < MAX_DEPTH; i++) {
3057
- const next = resolveOneRef(current, colors);
3046
+ const next = resolveOneRef(current, side);
3058
3047
  if (!next || next === current) break;
3059
3048
  current = next;
3060
3049
  }
3061
3050
  return current;
3062
3051
  }
3052
+ function resolveOneRef(ref, side) {
3053
+ const slashIdx = ref.indexOf("/");
3054
+ if (slashIdx > 0) {
3055
+ const baseName = ref.slice(0, slashIdx);
3056
+ const opacity = Number(ref.slice(slashIdx + 1));
3057
+ if (!Number.isFinite(opacity)) return null;
3058
+ let baseRef;
3059
+ const entry2 = colors[baseName];
3060
+ if (typeof entry2 === "string") {
3061
+ baseRef = entry2;
3062
+ } else if (isModeAwareColor(entry2)) {
3063
+ if (!side) return null;
3064
+ baseRef = entry2[side];
3065
+ } else if (entry2 && typeof entry2 === "object" && "6" in entry2) {
3066
+ const v = entry2["6"];
3067
+ baseRef = typeof v === "string" ? v : void 0;
3068
+ }
3069
+ if (baseRef === void 0) return null;
3070
+ const baseHex = resolveChain(baseRef, side);
3071
+ const a = opacity > 1 ? opacity / 100 : opacity;
3072
+ return hexToRgba(baseHex, a);
3073
+ }
3074
+ const lastDash = ref.lastIndexOf("-");
3075
+ if (lastDash <= 0) return null;
3076
+ const name = ref.slice(0, lastDash);
3077
+ const shade = ref.slice(lastDash + 1);
3078
+ if (!/^\d+$/.test(shade)) return null;
3079
+ const entry = colors[name];
3080
+ if (!entry || typeof entry !== "object" || isModeAwareColor(entry)) return null;
3081
+ const target = entry[shade];
3082
+ return typeof target === "string" ? target : null;
3083
+ }
3063
3084
  function resolveValue(val) {
3064
- return typeof val === "string" ? resolveChain(val) : { light: resolveChain(val.light), dark: resolveChain(val.dark) };
3085
+ return typeof val === "string" ? resolveChain(val, null) : { light: resolveChain(val.light, "light"), dark: resolveChain(val.dark, "dark") };
3065
3086
  }
3066
3087
  const out = {};
3067
3088
  for (const [key, val] of Object.entries(colors)) {
package/kbach-react.md CHANGED
@@ -740,17 +740,21 @@ extend: {
740
740
  surface: { light: '#ffffff', dark: '#111827' },
741
741
  // each side can itself be an alias — resolved independently
742
742
  accent: { light: 'blue-6', dark: 'blue-4' },
743
+ // or derived from another color at an opacity — 'name/opacity', resolved
744
+ // once here instead of only being computable at runtime via colors.alpha()
745
+ accentSoft: { light: 'accent/30', dark: 'accent/40' },
743
746
  },
744
747
  },
745
748
  },
746
749
  ```
747
750
 
748
751
  ```jsx
749
- <div className="bg-surface text-accent" />
750
- // equivalent to writing bg-white dark:bg-gray-9 text-blue-6 dark:text-blue-4 by hand
752
+ <div className="bg-surface text-accent hover:bg-accentSoft" />
753
+ // equivalent to writing bg-white dark:bg-gray-9 text-blue-6 dark:text-blue-4
754
+ // hover:bg-[rgba(...)] dark:hover:bg-[rgba(...)] by hand
751
755
  ```
752
756
 
753
- Works everywhere a color does — `useColors()` (returns the active side directly), opacity composition (`bg-surface/50`), and per-shade within a scale (`brand: { 6: { light: '#3b82f6', dark: '#60a5fa' } }`). An explicit `dark:`/`light:` modifier stacked on an already mode-aware color is not supported (falls back to the light side) — the whole point is not needing `dark:` for these.
757
+ Works everywhere a color does — `useColors()` (returns the active side directly), opacity composition (`bg-surface/50`), per-shade within a scale (`brand: { 6: { light: '#3b82f6', dark: '#60a5fa' } }`), and stacked under an explicit modifier (`dark:hover:bg-accent` correctly uses the dark side, still scoped to dark mode + hover — the modifier doesn't need to be there in the first place, but it's respected if it is).
754
758
 
755
759
  ### Runtime update
756
760
  ```js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/react",
3
- "version": "0.6.36",
3
+ "version": "0.6.37",
4
4
  "description": "React / React Native components and hooks for the Kbach framework",
5
5
  "repository": {
6
6
  "type": "git",