@kbach/react 0.5.35 → 0.5.36

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.
@@ -3,15 +3,16 @@ import {
3
3
  InteractiveWrapper,
4
4
  useConditionalWidth,
5
5
  useGlobalDarkMode
6
- } from "./chunk-VRYE5CAE.mjs";
6
+ } from "./chunk-D2LLZADB.mjs";
7
7
  import {
8
8
  flatten,
9
9
  getActiveBreakpoints,
10
10
  getConfig,
11
11
  getDefaultFontFamily,
12
12
  isWeb,
13
+ normalizeClassString,
13
14
  resolve
14
- } from "./chunk-YU55J6F6.mjs";
15
+ } from "./chunk-QTZGBGGJ.mjs";
15
16
 
16
17
  // src/jsx-runtime.tsx
17
18
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -214,7 +215,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
214
215
  return _jsx(InteractiveWrapper, {
215
216
  Component: actualType,
216
217
  resolvedStyle: resolved,
217
- ...isWeb && classStr ? { className: classStr } : {},
218
+ ...isWeb && classStr ? { className: normalizeClassString(classStr) } : {},
218
219
  style: userStyle,
219
220
  ...passProps
220
221
  }, key);
@@ -223,7 +224,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
223
224
  return _jsx(DarkWrapper, {
224
225
  Component: actualType,
225
226
  resolvedStyle: resolved,
226
- ...isWeb && classStr ? { className: classStr } : {},
227
+ ...isWeb && classStr ? { className: normalizeClassString(classStr) } : {},
227
228
  style: userStyle,
228
229
  ...passProps
229
230
  }, key);
@@ -235,7 +236,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
235
236
  return makeElement(isStaticChildren, actualType, {
236
237
  ...passProps,
237
238
  style: finalStyle,
238
- ...isWeb && classStr ? { className: classStr } : {}
239
+ ...isWeb && classStr ? { className: normalizeClassString(classStr) } : {}
239
240
  }, key);
240
241
  }
241
242
  function jsx(type, props, key) {
@@ -4,7 +4,7 @@ import {
4
4
  getGlobalWidth,
5
5
  isWeb,
6
6
  subscribeGlobalWidth
7
- } from "./chunk-YU55J6F6.mjs";
7
+ } from "./chunk-QTZGBGGJ.mjs";
8
8
 
9
9
  // src/core/darkModeStore.ts
10
10
  var KEY = "__kbach_dark_store__";
@@ -1284,12 +1284,22 @@ function splitClassTokens(classString) {
1284
1284
  let depth = 0;
1285
1285
  for (let i = 0; i < classString.length; i++) {
1286
1286
  const ch = classString[i];
1287
- if (ch === "[") depth++;
1288
- else if (ch === "]") depth--;
1289
- if (/\s/.test(ch) && depth === 0) {
1290
- if (current) {
1291
- tokens.push(current);
1292
- current = "";
1287
+ if (ch === "[") {
1288
+ depth++;
1289
+ current += ch;
1290
+ continue;
1291
+ }
1292
+ if (ch === "]") {
1293
+ depth--;
1294
+ current += ch;
1295
+ continue;
1296
+ }
1297
+ if (/\s/.test(ch)) {
1298
+ if (depth === 0) {
1299
+ if (current) {
1300
+ tokens.push(current);
1301
+ current = "";
1302
+ }
1293
1303
  }
1294
1304
  } else {
1295
1305
  current += ch;
@@ -1298,6 +1308,9 @@ function splitClassTokens(classString) {
1298
1308
  if (current) tokens.push(current);
1299
1309
  return tokens;
1300
1310
  }
1311
+ function normalizeClassString(classString) {
1312
+ return splitClassTokens(classString).join(" ");
1313
+ }
1301
1314
  function parseClasses(classString) {
1302
1315
  const results = [];
1303
1316
  for (const token of splitClassTokens(classString)) {
@@ -3579,6 +3592,7 @@ export {
3579
3592
  setCSSGenMode,
3580
3593
  parseClass,
3581
3594
  splitClassTokens,
3595
+ normalizeClassString,
3582
3596
  parseClasses,
3583
3597
  syncGlobalWidth,
3584
3598
  syncGlobalScreens,
package/dist/index.d.mts CHANGED
@@ -7,6 +7,19 @@ declare const defaultColors: ThemeColors;
7
7
  declare const defaultTheme: ThemeConfig;
8
8
 
9
9
  declare function parseClass(className: string): ParsedClass | null;
10
+ /**
11
+ * Split a class string into tokens. Whitespace at bracket depth > 0 is STRIPPED
12
+ * (not just skipped as a delimiter) so that arbitrary values like rgb(41, 172, 15)
13
+ * become valid CSS class name tokens: bg-[rgb(41,172,15)].
14
+ * Spaces inside brackets are illegal in HTML class attributes and would cause the
15
+ * browser to split the class into multiple broken tokens.
16
+ */
17
+ declare function splitClassTokens(classString: string): string[];
18
+ /**
19
+ * Normalize a full class string so it is safe to use as an HTML className value.
20
+ * Strips spaces inside brackets: "bg-[rgb(41, 172, 15)] p-4" → "bg-[rgb(41,172,15)] p-4"
21
+ */
22
+ declare function normalizeClassString(classString: string): string;
10
23
  /** Parse a space-separated class string into individual ParsedClass objects. */
11
24
  declare function parseClasses(classString: string): ParsedClass[];
12
25
 
@@ -301,4 +314,4 @@ declare function kb(classString: string, isDark?: boolean): StyleValue | string;
301
314
  */
302
315
  declare function cx(...classes: Array<string | false | null | undefined>): string;
303
316
 
304
- export { type ColorScale, type ColorsAPI, FrameworkConfig, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, ParsedClass, ResolvedConfig, ResolvedStyle, StyleValue, type StyledProps, ThemeConfig, ThemeContext, type ThemeContextValue, ThemeMode, ThemeProvider, type ThemeProviderProps, ThemeToggle, type ThemeToggleProps, type ToggleVariant, buildConfig, cx, defaultColors, defaultTheme, flatten, getConfig, initConfig, kb, parseClass, parseClasses, resolve, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
317
+ export { type ColorScale, type ColorsAPI, FrameworkConfig, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, ParsedClass, ResolvedConfig, ResolvedStyle, StyleValue, type StyledProps, ThemeConfig, ThemeContext, type ThemeContextValue, ThemeMode, ThemeProvider, type ThemeProviderProps, ThemeToggle, type ThemeToggleProps, type ToggleVariant, buildConfig, cx, defaultColors, defaultTheme, flatten, getConfig, initConfig, kb, normalizeClassString, parseClass, parseClasses, resolve, splitClassTokens, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
package/dist/index.d.ts CHANGED
@@ -7,6 +7,19 @@ declare const defaultColors: ThemeColors;
7
7
  declare const defaultTheme: ThemeConfig;
8
8
 
9
9
  declare function parseClass(className: string): ParsedClass | null;
10
+ /**
11
+ * Split a class string into tokens. Whitespace at bracket depth > 0 is STRIPPED
12
+ * (not just skipped as a delimiter) so that arbitrary values like rgb(41, 172, 15)
13
+ * become valid CSS class name tokens: bg-[rgb(41,172,15)].
14
+ * Spaces inside brackets are illegal in HTML class attributes and would cause the
15
+ * browser to split the class into multiple broken tokens.
16
+ */
17
+ declare function splitClassTokens(classString: string): string[];
18
+ /**
19
+ * Normalize a full class string so it is safe to use as an HTML className value.
20
+ * Strips spaces inside brackets: "bg-[rgb(41, 172, 15)] p-4" → "bg-[rgb(41,172,15)] p-4"
21
+ */
22
+ declare function normalizeClassString(classString: string): string;
10
23
  /** Parse a space-separated class string into individual ParsedClass objects. */
11
24
  declare function parseClasses(classString: string): ParsedClass[];
12
25
 
@@ -301,4 +314,4 @@ declare function kb(classString: string, isDark?: boolean): StyleValue | string;
301
314
  */
302
315
  declare function cx(...classes: Array<string | false | null | undefined>): string;
303
316
 
304
- export { type ColorScale, type ColorsAPI, FrameworkConfig, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, ParsedClass, ResolvedConfig, ResolvedStyle, StyleValue, type StyledProps, ThemeConfig, ThemeContext, type ThemeContextValue, ThemeMode, ThemeProvider, type ThemeProviderProps, ThemeToggle, type ThemeToggleProps, type ToggleVariant, buildConfig, cx, defaultColors, defaultTheme, flatten, getConfig, initConfig, kb, parseClass, parseClasses, resolve, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
317
+ export { type ColorScale, type ColorsAPI, FrameworkConfig, type InteractionState, InteractiveWrapper, type InteractiveWrapperProps, ParsedClass, ResolvedConfig, ResolvedStyle, StyleValue, type StyledProps, ThemeConfig, ThemeContext, type ThemeContextValue, ThemeMode, ThemeProvider, type ThemeProviderProps, ThemeToggle, type ThemeToggleProps, type ToggleVariant, buildConfig, cx, defaultColors, defaultTheme, flatten, getConfig, initConfig, kb, normalizeClassString, parseClass, parseClasses, resolve, splitClassTokens, styled, updateConfig, useBreakpoint, useColors, useGlobalDarkMode, useIsDark, useResolvedStyle, useResponsive, useStyles, useTheme, wrapColors };
package/dist/index.js CHANGED
@@ -42,9 +42,11 @@ __export(index_exports, {
42
42
  getConfig: () => getConfig,
43
43
  initConfig: () => initConfig,
44
44
  kb: () => kb,
45
+ normalizeClassString: () => normalizeClassString,
45
46
  parseClass: () => parseClass,
46
47
  parseClasses: () => parseClasses,
47
48
  resolve: () => resolve,
49
+ splitClassTokens: () => splitClassTokens,
48
50
  styled: () => styled,
49
51
  updateConfig: () => updateConfig,
50
52
  useBreakpoint: () => useBreakpoint,
@@ -1447,12 +1449,22 @@ function splitClassTokens(classString) {
1447
1449
  let depth = 0;
1448
1450
  for (let i = 0; i < classString.length; i++) {
1449
1451
  const ch = classString[i];
1450
- if (ch === "[") depth++;
1451
- else if (ch === "]") depth--;
1452
- if (/\s/.test(ch) && depth === 0) {
1453
- if (current) {
1454
- tokens.push(current);
1455
- current = "";
1452
+ if (ch === "[") {
1453
+ depth++;
1454
+ current += ch;
1455
+ continue;
1456
+ }
1457
+ if (ch === "]") {
1458
+ depth--;
1459
+ current += ch;
1460
+ continue;
1461
+ }
1462
+ if (/\s/.test(ch)) {
1463
+ if (depth === 0) {
1464
+ if (current) {
1465
+ tokens.push(current);
1466
+ current = "";
1467
+ }
1456
1468
  }
1457
1469
  } else {
1458
1470
  current += ch;
@@ -1461,6 +1473,9 @@ function splitClassTokens(classString) {
1461
1473
  if (current) tokens.push(current);
1462
1474
  return tokens;
1463
1475
  }
1476
+ function normalizeClassString(classString) {
1477
+ return splitClassTokens(classString).join(" ");
1478
+ }
1464
1479
  function parseClasses(classString) {
1465
1480
  const results = [];
1466
1481
  for (const token of splitClassTokens(classString)) {
@@ -4118,7 +4133,7 @@ function styled(Component, baseClasses = "") {
4118
4133
  ...rest,
4119
4134
  style: finalStyle,
4120
4135
  // className lets injected CSS rules (group-hover:, before:, print:, etc.) match the element.
4121
- ...isWeb && combined ? { className: combined } : {},
4136
+ ...isWeb && combined ? { className: normalizeClassString(combined) } : {},
4122
4137
  // onPressIn / onPressOut are React Native-only; on web use Pointer Events instead.
4123
4138
  ...isWeb ? { onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onPointerLeave: handlePointerLeave } : { onPressIn: handlePressIn, onPressOut: handlePressOut },
4124
4139
  onMouseEnter: handleMouseEnter,
@@ -4325,9 +4340,11 @@ function cx(...classes) {
4325
4340
  getConfig,
4326
4341
  initConfig,
4327
4342
  kb,
4343
+ normalizeClassString,
4328
4344
  parseClass,
4329
4345
  parseClasses,
4330
4346
  resolve,
4347
+ splitClassTokens,
4331
4348
  styled,
4332
4349
  updateConfig,
4333
4350
  useBreakpoint,
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  useConditionalWidth,
7
7
  useGlobalDarkMode,
8
8
  useGlobalWidth
9
- } from "./chunk-VRYE5CAE.mjs";
9
+ } from "./chunk-D2LLZADB.mjs";
10
10
  import {
11
11
  __require,
12
12
  buildConfig,
@@ -17,15 +17,17 @@ import {
17
17
  getConfig,
18
18
  initConfig,
19
19
  isWeb,
20
+ normalizeClassString,
20
21
  onConfigChange,
21
22
  parseClass,
22
23
  parseClasses,
23
24
  resolve,
24
25
  setGlobalWidth,
26
+ splitClassTokens,
25
27
  syncGlobalScreens,
26
28
  syncGlobalWidth,
27
29
  updateConfig
28
- } from "./chunk-YU55J6F6.mjs";
30
+ } from "./chunk-QTZGBGGJ.mjs";
29
31
 
30
32
  // src/context.tsx
31
33
  import { createContext, useContext } from "react";
@@ -458,7 +460,7 @@ function styled(Component, baseClasses = "") {
458
460
  ...rest,
459
461
  style: finalStyle,
460
462
  // className lets injected CSS rules (group-hover:, before:, print:, etc.) match the element.
461
- ...isWeb && combined ? { className: combined } : {},
463
+ ...isWeb && combined ? { className: normalizeClassString(combined) } : {},
462
464
  // onPressIn / onPressOut are React Native-only; on web use Pointer Events instead.
463
465
  ...isWeb ? { onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onPointerLeave: handlePointerLeave } : { onPressIn: handlePressIn, onPressOut: handlePressOut },
464
466
  onMouseEnter: handleMouseEnter,
@@ -541,9 +543,11 @@ export {
541
543
  getConfig,
542
544
  initConfig,
543
545
  kb,
546
+ normalizeClassString,
544
547
  parseClass,
545
548
  parseClasses,
546
549
  resolve,
550
+ splitClassTokens,
547
551
  styled,
548
552
  updateConfig,
549
553
  useBreakpoint,
@@ -1351,12 +1351,22 @@ function splitClassTokens(classString) {
1351
1351
  let depth = 0;
1352
1352
  for (let i = 0; i < classString.length; i++) {
1353
1353
  const ch = classString[i];
1354
- if (ch === "[") depth++;
1355
- else if (ch === "]") depth--;
1356
- if (/\s/.test(ch) && depth === 0) {
1357
- if (current) {
1358
- tokens.push(current);
1359
- current = "";
1354
+ if (ch === "[") {
1355
+ depth++;
1356
+ current += ch;
1357
+ continue;
1358
+ }
1359
+ if (ch === "]") {
1360
+ depth--;
1361
+ current += ch;
1362
+ continue;
1363
+ }
1364
+ if (/\s/.test(ch)) {
1365
+ if (depth === 0) {
1366
+ if (current) {
1367
+ tokens.push(current);
1368
+ current = "";
1369
+ }
1360
1370
  }
1361
1371
  } else {
1362
1372
  current += ch;
@@ -1365,6 +1375,9 @@ function splitClassTokens(classString) {
1365
1375
  if (current) tokens.push(current);
1366
1376
  return tokens;
1367
1377
  }
1378
+ function normalizeClassString(classString) {
1379
+ return splitClassTokens(classString).join(" ");
1380
+ }
1368
1381
  function parseClasses(classString) {
1369
1382
  const results = [];
1370
1383
  for (const token of splitClassTokens(classString)) {
@@ -3941,7 +3954,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
3941
3954
  return (0, import_jsx_runtime.jsx)(InteractiveWrapper, {
3942
3955
  Component: actualType,
3943
3956
  resolvedStyle: resolved,
3944
- ...isWeb && classStr ? { className: classStr } : {},
3957
+ ...isWeb && classStr ? { className: normalizeClassString(classStr) } : {},
3945
3958
  style: userStyle,
3946
3959
  ...passProps
3947
3960
  }, key);
@@ -3950,7 +3963,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
3950
3963
  return (0, import_jsx_runtime.jsx)(DarkWrapper, {
3951
3964
  Component: actualType,
3952
3965
  resolvedStyle: resolved,
3953
- ...isWeb && classStr ? { className: classStr } : {},
3966
+ ...isWeb && classStr ? { className: normalizeClassString(classStr) } : {},
3954
3967
  style: userStyle,
3955
3968
  ...passProps
3956
3969
  }, key);
@@ -3962,7 +3975,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
3962
3975
  return makeElement(isStaticChildren, actualType, {
3963
3976
  ...passProps,
3964
3977
  style: finalStyle,
3965
- ...isWeb && classStr ? { className: classStr } : {}
3978
+ ...isWeb && classStr ? { className: normalizeClassString(classStr) } : {}
3966
3979
  }, key);
3967
3980
  }
3968
3981
  function jsx(type, props, key) {
@@ -2,9 +2,9 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-65BTN2UR.mjs";
6
- import "./chunk-VRYE5CAE.mjs";
7
- import "./chunk-YU55J6F6.mjs";
5
+ } from "./chunk-AZJVYYAX.mjs";
6
+ import "./chunk-D2LLZADB.mjs";
7
+ import "./chunk-QTZGBGGJ.mjs";
8
8
 
9
9
  // src/jsx-dev-runtime.tsx
10
10
  function jsxDEV(type, props, key, isStaticChildren, _source, _self) {
@@ -1350,12 +1350,22 @@ function splitClassTokens(classString) {
1350
1350
  let depth = 0;
1351
1351
  for (let i = 0; i < classString.length; i++) {
1352
1352
  const ch = classString[i];
1353
- if (ch === "[") depth++;
1354
- else if (ch === "]") depth--;
1355
- if (/\s/.test(ch) && depth === 0) {
1356
- if (current) {
1357
- tokens.push(current);
1358
- current = "";
1353
+ if (ch === "[") {
1354
+ depth++;
1355
+ current += ch;
1356
+ continue;
1357
+ }
1358
+ if (ch === "]") {
1359
+ depth--;
1360
+ current += ch;
1361
+ continue;
1362
+ }
1363
+ if (/\s/.test(ch)) {
1364
+ if (depth === 0) {
1365
+ if (current) {
1366
+ tokens.push(current);
1367
+ current = "";
1368
+ }
1359
1369
  }
1360
1370
  } else {
1361
1371
  current += ch;
@@ -1364,6 +1374,9 @@ function splitClassTokens(classString) {
1364
1374
  if (current) tokens.push(current);
1365
1375
  return tokens;
1366
1376
  }
1377
+ function normalizeClassString(classString) {
1378
+ return splitClassTokens(classString).join(" ");
1379
+ }
1367
1380
  function parseClasses(classString) {
1368
1381
  const results = [];
1369
1382
  for (const token of splitClassTokens(classString)) {
@@ -3940,7 +3953,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
3940
3953
  return (0, import_jsx_runtime.jsx)(InteractiveWrapper, {
3941
3954
  Component: actualType,
3942
3955
  resolvedStyle: resolved,
3943
- ...isWeb && classStr ? { className: classStr } : {},
3956
+ ...isWeb && classStr ? { className: normalizeClassString(classStr) } : {},
3944
3957
  style: userStyle,
3945
3958
  ...passProps
3946
3959
  }, key);
@@ -3949,7 +3962,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
3949
3962
  return (0, import_jsx_runtime.jsx)(DarkWrapper, {
3950
3963
  Component: actualType,
3951
3964
  resolvedStyle: resolved,
3952
- ...isWeb && classStr ? { className: classStr } : {},
3965
+ ...isWeb && classStr ? { className: normalizeClassString(classStr) } : {},
3953
3966
  style: userStyle,
3954
3967
  ...passProps
3955
3968
  }, key);
@@ -3961,7 +3974,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
3961
3974
  return makeElement(isStaticChildren, actualType, {
3962
3975
  ...passProps,
3963
3976
  style: finalStyle,
3964
- ...isWeb && classStr ? { className: classStr } : {}
3977
+ ...isWeb && classStr ? { className: normalizeClassString(classStr) } : {}
3965
3978
  }, key);
3966
3979
  }
3967
3980
  function jsx(type, props, key) {
@@ -2,9 +2,9 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-65BTN2UR.mjs";
6
- import "./chunk-VRYE5CAE.mjs";
7
- import "./chunk-YU55J6F6.mjs";
5
+ } from "./chunk-AZJVYYAX.mjs";
6
+ import "./chunk-D2LLZADB.mjs";
7
+ import "./chunk-QTZGBGGJ.mjs";
8
8
  export {
9
9
  Fragment,
10
10
  jsx,
@@ -2931,12 +2931,22 @@ function splitClassTokens(classString) {
2931
2931
  let depth = 0;
2932
2932
  for (let i = 0; i < classString.length; i++) {
2933
2933
  const ch = classString[i];
2934
- if (ch === "[") depth++;
2935
- else if (ch === "]") depth--;
2936
- if (/\s/.test(ch) && depth === 0) {
2937
- if (current) {
2938
- tokens.push(current);
2939
- current = "";
2934
+ if (ch === "[") {
2935
+ depth++;
2936
+ current += ch;
2937
+ continue;
2938
+ }
2939
+ if (ch === "]") {
2940
+ depth--;
2941
+ current += ch;
2942
+ continue;
2943
+ }
2944
+ if (/\s/.test(ch)) {
2945
+ if (depth === 0) {
2946
+ if (current) {
2947
+ tokens.push(current);
2948
+ current = "";
2949
+ }
2940
2950
  }
2941
2951
  } else {
2942
2952
  current += ch;
@@ -3,7 +3,7 @@ import {
3
3
  generateClassCSS,
4
4
  setCSSGenMode,
5
5
  splitClassTokens
6
- } from "./chunk-YU55J6F6.mjs";
6
+ } from "./chunk-QTZGBGGJ.mjs";
7
7
 
8
8
  // src/vite-plugin.ts
9
9
  import { readFileSync, writeFileSync, existsSync, readdirSync, statSync } from "fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/react",
3
- "version": "0.5.35",
3
+ "version": "0.5.36",
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",