@kbach/react 0.3.3 → 0.3.4

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.
@@ -2082,6 +2082,28 @@ function getConfig() {
2082
2082
  store.resolved = buildConfig({});
2083
2083
  return store.resolved;
2084
2084
  }
2085
+ function resolveOneRef(ref, colors) {
2086
+ const m = /^([a-z][a-z0-9]*)-(\d+)$/.exec(ref);
2087
+ if (!m) return null;
2088
+ const entry = colors[m[1]];
2089
+ if (!entry || typeof entry !== "object") return null;
2090
+ return entry[m[2]] ?? null;
2091
+ }
2092
+ function resolveColorRefs(colors) {
2093
+ const out = {};
2094
+ for (const [key, val] of Object.entries(colors)) {
2095
+ if (typeof val === "string") {
2096
+ out[key] = resolveOneRef(val, colors) ?? val;
2097
+ } else {
2098
+ const shades = {};
2099
+ for (const [shade, hex] of Object.entries(val)) {
2100
+ shades[shade] = resolveOneRef(hex, colors) ?? hex;
2101
+ }
2102
+ out[key] = shades;
2103
+ }
2104
+ }
2105
+ return out;
2106
+ }
2085
2107
  function buildConfig(userConfig) {
2086
2108
  let theme = { ...defaultTheme };
2087
2109
  if (userConfig.theme) {
@@ -2100,6 +2122,7 @@ function buildConfig(userConfig) {
2100
2122
  }
2101
2123
  }
2102
2124
  }
2125
+ theme = { ...theme, colors: resolveColorRefs(theme.colors) };
2103
2126
  const resolved = {
2104
2127
  darkMode: userConfig.darkMode ?? "attribute",
2105
2128
  theme,
@@ -5,7 +5,7 @@ import {
5
5
  isWeb,
6
6
  resolve,
7
7
  useGlobalDarkMode
8
- } from "./chunk-7XL6VQDW.mjs";
8
+ } from "./chunk-ADRZPFQC.mjs";
9
9
 
10
10
  // src/jsx-runtime.tsx
11
11
  import { jsx as _jsx, jsxs as _jsxs, Fragment } from "react/jsx-runtime";
package/dist/index.js CHANGED
@@ -2210,6 +2210,28 @@ function getConfig() {
2210
2210
  store.resolved = buildConfig({});
2211
2211
  return store.resolved;
2212
2212
  }
2213
+ function resolveOneRef(ref, colors) {
2214
+ const m = /^([a-z][a-z0-9]*)-(\d+)$/.exec(ref);
2215
+ if (!m) return null;
2216
+ const entry = colors[m[1]];
2217
+ if (!entry || typeof entry !== "object") return null;
2218
+ return entry[m[2]] ?? null;
2219
+ }
2220
+ function resolveColorRefs(colors) {
2221
+ const out = {};
2222
+ for (const [key, val] of Object.entries(colors)) {
2223
+ if (typeof val === "string") {
2224
+ out[key] = resolveOneRef(val, colors) ?? val;
2225
+ } else {
2226
+ const shades = {};
2227
+ for (const [shade, hex] of Object.entries(val)) {
2228
+ shades[shade] = resolveOneRef(hex, colors) ?? hex;
2229
+ }
2230
+ out[key] = shades;
2231
+ }
2232
+ }
2233
+ return out;
2234
+ }
2213
2235
  function buildConfig(userConfig) {
2214
2236
  let theme = { ...defaultTheme };
2215
2237
  if (userConfig.theme) {
@@ -2228,6 +2250,7 @@ function buildConfig(userConfig) {
2228
2250
  }
2229
2251
  }
2230
2252
  }
2253
+ theme = { ...theme, colors: resolveColorRefs(theme.colors) };
2231
2254
  const resolved = {
2232
2255
  darkMode: userConfig.darkMode ?? "attribute",
2233
2256
  theme,
package/dist/index.mjs CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  syncGlobalDarkMode,
17
17
  updateConfig,
18
18
  useGlobalDarkMode
19
- } from "./chunk-7XL6VQDW.mjs";
19
+ } from "./chunk-ADRZPFQC.mjs";
20
20
 
21
21
  // src/context.tsx
22
22
  import { createContext, useContext } from "react";
@@ -2112,6 +2112,28 @@ function getConfig() {
2112
2112
  store.resolved = buildConfig({});
2113
2113
  return store.resolved;
2114
2114
  }
2115
+ function resolveOneRef(ref, colors) {
2116
+ const m = /^([a-z][a-z0-9]*)-(\d+)$/.exec(ref);
2117
+ if (!m) return null;
2118
+ const entry = colors[m[1]];
2119
+ if (!entry || typeof entry !== "object") return null;
2120
+ return entry[m[2]] ?? null;
2121
+ }
2122
+ function resolveColorRefs(colors) {
2123
+ const out = {};
2124
+ for (const [key, val] of Object.entries(colors)) {
2125
+ if (typeof val === "string") {
2126
+ out[key] = resolveOneRef(val, colors) ?? val;
2127
+ } else {
2128
+ const shades = {};
2129
+ for (const [shade, hex] of Object.entries(val)) {
2130
+ shades[shade] = resolveOneRef(hex, colors) ?? hex;
2131
+ }
2132
+ out[key] = shades;
2133
+ }
2134
+ }
2135
+ return out;
2136
+ }
2115
2137
  function buildConfig(userConfig) {
2116
2138
  let theme = { ...defaultTheme };
2117
2139
  if (userConfig.theme) {
@@ -2130,6 +2152,7 @@ function buildConfig(userConfig) {
2130
2152
  }
2131
2153
  }
2132
2154
  }
2155
+ theme = { ...theme, colors: resolveColorRefs(theme.colors) };
2133
2156
  const resolved = {
2134
2157
  darkMode: userConfig.darkMode ?? "attribute",
2135
2158
  theme,
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-NFPYOE5K.mjs";
6
- import "./chunk-7XL6VQDW.mjs";
5
+ } from "./chunk-J322Q3UR.mjs";
6
+ import "./chunk-ADRZPFQC.mjs";
7
7
 
8
8
  // src/jsx-dev-runtime.tsx
9
9
  function jsxDEV(type, props, key, isStaticChildren, _source, _self) {
@@ -2111,6 +2111,28 @@ function getConfig() {
2111
2111
  store.resolved = buildConfig({});
2112
2112
  return store.resolved;
2113
2113
  }
2114
+ function resolveOneRef(ref, colors) {
2115
+ const m = /^([a-z][a-z0-9]*)-(\d+)$/.exec(ref);
2116
+ if (!m) return null;
2117
+ const entry = colors[m[1]];
2118
+ if (!entry || typeof entry !== "object") return null;
2119
+ return entry[m[2]] ?? null;
2120
+ }
2121
+ function resolveColorRefs(colors) {
2122
+ const out = {};
2123
+ for (const [key, val] of Object.entries(colors)) {
2124
+ if (typeof val === "string") {
2125
+ out[key] = resolveOneRef(val, colors) ?? val;
2126
+ } else {
2127
+ const shades = {};
2128
+ for (const [shade, hex] of Object.entries(val)) {
2129
+ shades[shade] = resolveOneRef(hex, colors) ?? hex;
2130
+ }
2131
+ out[key] = shades;
2132
+ }
2133
+ }
2134
+ return out;
2135
+ }
2114
2136
  function buildConfig(userConfig) {
2115
2137
  let theme = { ...defaultTheme };
2116
2138
  if (userConfig.theme) {
@@ -2129,6 +2151,7 @@ function buildConfig(userConfig) {
2129
2151
  }
2130
2152
  }
2131
2153
  }
2154
+ theme = { ...theme, colors: resolveColorRefs(theme.colors) };
2132
2155
  const resolved = {
2133
2156
  darkMode: userConfig.darkMode ?? "attribute",
2134
2157
  theme,
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-NFPYOE5K.mjs";
6
- import "./chunk-7XL6VQDW.mjs";
5
+ } from "./chunk-J322Q3UR.mjs";
6
+ import "./chunk-ADRZPFQC.mjs";
7
7
  export {
8
8
  Fragment,
9
9
  jsx,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/react",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
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",