@kbach/react 0.5.34 → 0.5.35

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,7 +3,7 @@ import {
3
3
  InteractiveWrapper,
4
4
  useConditionalWidth,
5
5
  useGlobalDarkMode
6
- } from "./chunk-6AUSWRH2.mjs";
6
+ } from "./chunk-VRYE5CAE.mjs";
7
7
  import {
8
8
  flatten,
9
9
  getActiveBreakpoints,
@@ -11,7 +11,7 @@ import {
11
11
  getDefaultFontFamily,
12
12
  isWeb,
13
13
  resolve
14
- } from "./chunk-T3SOZ6AO.mjs";
14
+ } from "./chunk-YU55J6F6.mjs";
15
15
 
16
16
  // src/jsx-runtime.tsx
17
17
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -4,7 +4,7 @@ import {
4
4
  getGlobalWidth,
5
5
  isWeb,
6
6
  subscribeGlobalWidth
7
- } from "./chunk-T3SOZ6AO.mjs";
7
+ } from "./chunk-YU55J6F6.mjs";
8
8
 
9
9
  // src/core/darkModeStore.ts
10
10
  var KEY = "__kbach_dark_store__";
@@ -1249,7 +1249,7 @@ function parseClass(className) {
1249
1249
  const bracketStart = remaining.lastIndexOf("-[");
1250
1250
  if (bracketStart > 0 && remaining.endsWith("]")) {
1251
1251
  const utility = remaining.slice(0, bracketStart);
1252
- const value = remaining.slice(bracketStart + 2, -1);
1252
+ const value = remaining.slice(bracketStart + 2, -1).replace(/_/g, " ");
1253
1253
  return { original: trimmed, modifiers, negative, important, utility, value, isArbitrary: true };
1254
1254
  }
1255
1255
  if (STANDALONE_UTILITIES.has(remaining)) {
@@ -1278,10 +1278,29 @@ function parseClass(className) {
1278
1278
  }
1279
1279
  return { original: trimmed, modifiers, negative, important, utility: remaining, value: "", isArbitrary: false };
1280
1280
  }
1281
+ function splitClassTokens(classString) {
1282
+ const tokens = [];
1283
+ let current = "";
1284
+ let depth = 0;
1285
+ for (let i = 0; i < classString.length; i++) {
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 = "";
1293
+ }
1294
+ } else {
1295
+ current += ch;
1296
+ }
1297
+ }
1298
+ if (current) tokens.push(current);
1299
+ return tokens;
1300
+ }
1281
1301
  function parseClasses(classString) {
1282
1302
  const results = [];
1283
- for (const token of classString.split(/\s+/)) {
1284
- if (!token) continue;
1303
+ for (const token of splitClassTokens(classString)) {
1285
1304
  const parsed = parseClass(token);
1286
1305
  if (parsed) results.push(parsed);
1287
1306
  }
@@ -3559,6 +3578,7 @@ export {
3559
3578
  isWeb,
3560
3579
  setCSSGenMode,
3561
3580
  parseClass,
3581
+ splitClassTokens,
3562
3582
  parseClasses,
3563
3583
  syncGlobalWidth,
3564
3584
  syncGlobalScreens,
package/dist/index.js CHANGED
@@ -1412,7 +1412,7 @@ function parseClass(className) {
1412
1412
  const bracketStart = remaining.lastIndexOf("-[");
1413
1413
  if (bracketStart > 0 && remaining.endsWith("]")) {
1414
1414
  const utility = remaining.slice(0, bracketStart);
1415
- const value = remaining.slice(bracketStart + 2, -1);
1415
+ const value = remaining.slice(bracketStart + 2, -1).replace(/_/g, " ");
1416
1416
  return { original: trimmed, modifiers, negative, important, utility, value, isArbitrary: true };
1417
1417
  }
1418
1418
  if (STANDALONE_UTILITIES.has(remaining)) {
@@ -1441,10 +1441,29 @@ function parseClass(className) {
1441
1441
  }
1442
1442
  return { original: trimmed, modifiers, negative, important, utility: remaining, value: "", isArbitrary: false };
1443
1443
  }
1444
+ function splitClassTokens(classString) {
1445
+ const tokens = [];
1446
+ let current = "";
1447
+ let depth = 0;
1448
+ for (let i = 0; i < classString.length; i++) {
1449
+ 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 = "";
1456
+ }
1457
+ } else {
1458
+ current += ch;
1459
+ }
1460
+ }
1461
+ if (current) tokens.push(current);
1462
+ return tokens;
1463
+ }
1444
1464
  function parseClasses(classString) {
1445
1465
  const results = [];
1446
- for (const token of classString.split(/\s+/)) {
1447
- if (!token) continue;
1466
+ for (const token of splitClassTokens(classString)) {
1448
1467
  const parsed = parseClass(token);
1449
1468
  if (parsed) results.push(parsed);
1450
1469
  }
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  useConditionalWidth,
7
7
  useGlobalDarkMode,
8
8
  useGlobalWidth
9
- } from "./chunk-6AUSWRH2.mjs";
9
+ } from "./chunk-VRYE5CAE.mjs";
10
10
  import {
11
11
  __require,
12
12
  buildConfig,
@@ -25,7 +25,7 @@ import {
25
25
  syncGlobalScreens,
26
26
  syncGlobalWidth,
27
27
  updateConfig
28
- } from "./chunk-T3SOZ6AO.mjs";
28
+ } from "./chunk-YU55J6F6.mjs";
29
29
 
30
30
  // src/context.tsx
31
31
  import { createContext, useContext } from "react";
@@ -1316,7 +1316,7 @@ function parseClass(className) {
1316
1316
  const bracketStart = remaining.lastIndexOf("-[");
1317
1317
  if (bracketStart > 0 && remaining.endsWith("]")) {
1318
1318
  const utility = remaining.slice(0, bracketStart);
1319
- const value = remaining.slice(bracketStart + 2, -1);
1319
+ const value = remaining.slice(bracketStart + 2, -1).replace(/_/g, " ");
1320
1320
  return { original: trimmed, modifiers, negative, important, utility, value, isArbitrary: true };
1321
1321
  }
1322
1322
  if (STANDALONE_UTILITIES.has(remaining)) {
@@ -1345,10 +1345,29 @@ function parseClass(className) {
1345
1345
  }
1346
1346
  return { original: trimmed, modifiers, negative, important, utility: remaining, value: "", isArbitrary: false };
1347
1347
  }
1348
+ function splitClassTokens(classString) {
1349
+ const tokens = [];
1350
+ let current = "";
1351
+ let depth = 0;
1352
+ for (let i = 0; i < classString.length; i++) {
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 = "";
1360
+ }
1361
+ } else {
1362
+ current += ch;
1363
+ }
1364
+ }
1365
+ if (current) tokens.push(current);
1366
+ return tokens;
1367
+ }
1348
1368
  function parseClasses(classString) {
1349
1369
  const results = [];
1350
- for (const token of classString.split(/\s+/)) {
1351
- if (!token) continue;
1370
+ for (const token of splitClassTokens(classString)) {
1352
1371
  const parsed = parseClass(token);
1353
1372
  if (parsed) results.push(parsed);
1354
1373
  }
@@ -2,9 +2,9 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-LMCUZ3HI.mjs";
6
- import "./chunk-6AUSWRH2.mjs";
7
- import "./chunk-T3SOZ6AO.mjs";
5
+ } from "./chunk-65BTN2UR.mjs";
6
+ import "./chunk-VRYE5CAE.mjs";
7
+ import "./chunk-YU55J6F6.mjs";
8
8
 
9
9
  // src/jsx-dev-runtime.tsx
10
10
  function jsxDEV(type, props, key, isStaticChildren, _source, _self) {
@@ -1315,7 +1315,7 @@ function parseClass(className) {
1315
1315
  const bracketStart = remaining.lastIndexOf("-[");
1316
1316
  if (bracketStart > 0 && remaining.endsWith("]")) {
1317
1317
  const utility = remaining.slice(0, bracketStart);
1318
- const value = remaining.slice(bracketStart + 2, -1);
1318
+ const value = remaining.slice(bracketStart + 2, -1).replace(/_/g, " ");
1319
1319
  return { original: trimmed, modifiers, negative, important, utility, value, isArbitrary: true };
1320
1320
  }
1321
1321
  if (STANDALONE_UTILITIES.has(remaining)) {
@@ -1344,10 +1344,29 @@ function parseClass(className) {
1344
1344
  }
1345
1345
  return { original: trimmed, modifiers, negative, important, utility: remaining, value: "", isArbitrary: false };
1346
1346
  }
1347
+ function splitClassTokens(classString) {
1348
+ const tokens = [];
1349
+ let current = "";
1350
+ let depth = 0;
1351
+ for (let i = 0; i < classString.length; i++) {
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 = "";
1359
+ }
1360
+ } else {
1361
+ current += ch;
1362
+ }
1363
+ }
1364
+ if (current) tokens.push(current);
1365
+ return tokens;
1366
+ }
1347
1367
  function parseClasses(classString) {
1348
1368
  const results = [];
1349
- for (const token of classString.split(/\s+/)) {
1350
- if (!token) continue;
1369
+ for (const token of splitClassTokens(classString)) {
1351
1370
  const parsed = parseClass(token);
1352
1371
  if (parsed) results.push(parsed);
1353
1372
  }
@@ -2,9 +2,9 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-LMCUZ3HI.mjs";
6
- import "./chunk-6AUSWRH2.mjs";
7
- import "./chunk-T3SOZ6AO.mjs";
5
+ } from "./chunk-65BTN2UR.mjs";
6
+ import "./chunk-VRYE5CAE.mjs";
7
+ import "./chunk-YU55J6F6.mjs";
8
8
  export {
9
9
  Fragment,
10
10
  jsx,
@@ -2896,7 +2896,7 @@ function parseClass(className) {
2896
2896
  const bracketStart = remaining.lastIndexOf("-[");
2897
2897
  if (bracketStart > 0 && remaining.endsWith("]")) {
2898
2898
  const utility = remaining.slice(0, bracketStart);
2899
- const value = remaining.slice(bracketStart + 2, -1);
2899
+ const value = remaining.slice(bracketStart + 2, -1).replace(/_/g, " ");
2900
2900
  return { original: trimmed, modifiers, negative, important, utility, value, isArbitrary: true };
2901
2901
  }
2902
2902
  if (STANDALONE_UTILITIES.has(remaining)) {
@@ -2925,10 +2925,29 @@ function parseClass(className) {
2925
2925
  }
2926
2926
  return { original: trimmed, modifiers, negative, important, utility: remaining, value: "", isArbitrary: false };
2927
2927
  }
2928
+ function splitClassTokens(classString) {
2929
+ const tokens = [];
2930
+ let current = "";
2931
+ let depth = 0;
2932
+ for (let i = 0; i < classString.length; i++) {
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 = "";
2940
+ }
2941
+ } else {
2942
+ current += ch;
2943
+ }
2944
+ }
2945
+ if (current) tokens.push(current);
2946
+ return tokens;
2947
+ }
2928
2948
  function parseClasses(classString) {
2929
2949
  const results = [];
2930
- for (const token of classString.split(/\s+/)) {
2931
- if (!token) continue;
2950
+ for (const token of splitClassTokens(classString)) {
2932
2951
  const parsed = parseClass(token);
2933
2952
  if (parsed) results.push(parsed);
2934
2953
  }
@@ -3509,7 +3528,7 @@ function kbach(userConfig) {
3509
3528
  for (const dir of ["src", "app", "pages", "components", "views", "layouts"]) {
3510
3529
  scanDir((0, import_path.join)(root, dir), (code) => {
3511
3530
  for (const cls of extractClassStrings(code))
3512
- for (const token of cls.split(/\s+/).filter(Boolean))
3531
+ for (const token of splitClassTokens(cls))
3513
3532
  if (!tokenCSS.has(token)) {
3514
3533
  const css = generateClassCSS(token, cfg.theme, cfg.darkMode, screens);
3515
3534
  tokenCSS.set(token, css);
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  buildConfig,
3
3
  generateClassCSS,
4
- setCSSGenMode
5
- } from "./chunk-T3SOZ6AO.mjs";
4
+ setCSSGenMode,
5
+ splitClassTokens
6
+ } from "./chunk-YU55J6F6.mjs";
6
7
 
7
8
  // src/vite-plugin.ts
8
9
  import { readFileSync, writeFileSync, existsSync, readdirSync, statSync } from "fs";
@@ -150,7 +151,7 @@ function kbach(userConfig) {
150
151
  for (const dir of ["src", "app", "pages", "components", "views", "layouts"]) {
151
152
  scanDir(join(root, dir), (code) => {
152
153
  for (const cls of extractClassStrings(code))
153
- for (const token of cls.split(/\s+/).filter(Boolean))
154
+ for (const token of splitClassTokens(cls))
154
155
  if (!tokenCSS.has(token)) {
155
156
  const css = generateClassCSS(token, cfg.theme, cfg.darkMode, screens);
156
157
  tokenCSS.set(token, css);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/react",
3
- "version": "0.5.34",
3
+ "version": "0.5.35",
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",