@kbach/react 0.5.2 → 0.5.3

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.
@@ -8,7 +8,7 @@ import {
8
8
  resolve,
9
9
  useConditionalWidth,
10
10
  useGlobalDarkMode
11
- } from "./chunk-XVPIJMIR.mjs";
11
+ } from "./chunk-OKK7AJ2G.mjs";
12
12
 
13
13
  // src/jsx-runtime.tsx
14
14
  import { jsx as _jsx, jsxs as _jsxs, Fragment } from "react/jsx-runtime";
@@ -88,17 +88,12 @@ var INTERACTIVE_MODS = /* @__PURE__ */ new Set([
88
88
  "visited",
89
89
  "not-visited",
90
90
  "placeholder",
91
- "focus-within",
92
- "focus-visible",
93
91
  "group-hover",
94
92
  "group-focus",
95
93
  "peer-hover",
96
- "peer-focus",
97
- "first",
98
- "last",
99
- "odd",
100
- "even",
101
- "only"
94
+ "peer-focus"
95
+ // focus-within / focus-visible / first / last / odd / even / only are CSS-only —
96
+ // they have no JS state to track, so they don't need InteractiveWrapper.
102
97
  ]);
103
98
  var RESPONSIVE_MODS2 = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
104
99
  var MODE_MODS_JSX = /* @__PURE__ */ new Set(["dark", "light", "not-dark", "not-light"]);
@@ -3078,12 +3078,12 @@ function injectClassRule(cls, bucketKey, styles, darkMode, important = false) {
3078
3078
  injectRule(styles.__keyframe);
3079
3079
  }
3080
3080
  const isDivide = "__divideX" in styles || "__divideY" in styles || "__divideColor" in styles || "__divideStyle" in styles;
3081
- const cssDecls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, important);
3082
- if (!cssDecls) return;
3083
3081
  const escaped = escapeCSSSelector(cls);
3084
3082
  const childSuffix = isDivide ? " > * + *" : "";
3085
3083
  if (bucketKey === "base") {
3086
- injectRule(`.${escaped}${childSuffix} { ${cssDecls} }`);
3084
+ const baseCssDecls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, important);
3085
+ if (!baseCssDecls) return;
3086
+ injectRule(`.${escaped}${childSuffix} { ${baseCssDecls} }`);
3087
3087
  return;
3088
3088
  }
3089
3089
  const mods = bucketKey.split(":");
@@ -3103,6 +3103,18 @@ function injectClassRule(cls, bucketKey, styles, darkMode, important = false) {
3103
3103
  const ancestorPrefix = ancestorMods.length ? ancestorMods.map((m) => GROUP_PEER_PREFIX[m]).join(" ") + " " : "";
3104
3104
  const dirPrefix = dirMods.length ? dirMods.map((m) => DIR_MODS[m]).join(" ") + " " : "";
3105
3105
  const selector = `${dirPrefix}${ancestorPrefix}${elementSelector}`;
3106
+ const CSS_ONLY_PSEUDOS = /* @__PURE__ */ new Set([
3107
+ "first",
3108
+ "last",
3109
+ "odd",
3110
+ "even",
3111
+ "only",
3112
+ "focus-within",
3113
+ "focus-visible"
3114
+ ]);
3115
+ const needsImportant = important || hasPrint || mediaMods.length > 0 || dirMods.length > 0 || ancestorMods.length > 0 || pseudoMods.some((m) => CSS_ONLY_PSEUDOS.has(m));
3116
+ const cssDecls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, needsImportant);
3117
+ if (!cssDecls) return;
3106
3118
  let rule;
3107
3119
  if (hasDark) {
3108
3120
  if (darkMode === "media") {
@@ -3225,9 +3237,19 @@ function resolve(classString, theme, darkMode = "attribute") {
3225
3237
  return result;
3226
3238
  }
3227
3239
  function flatten(resolved, isDark, state = {}, breakpoints = /* @__PURE__ */ new Set()) {
3228
- const result = { ...resolved.base ?? {} };
3229
- for (const [key, styles] of Object.entries(resolved)) {
3230
- if (key === "base" || !styles) continue;
3240
+ const result = {};
3241
+ const entries = Object.entries(resolved);
3242
+ entries.sort((a, b) => {
3243
+ const pa = a[0] === "base" ? -1 : a[0].split(":").length;
3244
+ const pb = b[0] === "base" ? -1 : b[0].split(":").length;
3245
+ return pa - pb;
3246
+ });
3247
+ for (const [key, styles] of entries) {
3248
+ if (!styles) continue;
3249
+ if (key === "base") {
3250
+ Object.assign(result, styles);
3251
+ continue;
3252
+ }
3231
3253
  const mods = key.split(":");
3232
3254
  if (matchesMods(mods, isDark, state, breakpoints)) {
3233
3255
  Object.assign(result, styles);
package/dist/index.js CHANGED
@@ -3208,12 +3208,12 @@ function injectClassRule(cls, bucketKey, styles, darkMode, important = false) {
3208
3208
  injectRule(styles.__keyframe);
3209
3209
  }
3210
3210
  const isDivide = "__divideX" in styles || "__divideY" in styles || "__divideColor" in styles || "__divideStyle" in styles;
3211
- const cssDecls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, important);
3212
- if (!cssDecls) return;
3213
3211
  const escaped = escapeCSSSelector(cls);
3214
3212
  const childSuffix = isDivide ? " > * + *" : "";
3215
3213
  if (bucketKey === "base") {
3216
- injectRule(`.${escaped}${childSuffix} { ${cssDecls} }`);
3214
+ const baseCssDecls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, important);
3215
+ if (!baseCssDecls) return;
3216
+ injectRule(`.${escaped}${childSuffix} { ${baseCssDecls} }`);
3217
3217
  return;
3218
3218
  }
3219
3219
  const mods = bucketKey.split(":");
@@ -3233,6 +3233,18 @@ function injectClassRule(cls, bucketKey, styles, darkMode, important = false) {
3233
3233
  const ancestorPrefix = ancestorMods.length ? ancestorMods.map((m) => GROUP_PEER_PREFIX[m]).join(" ") + " " : "";
3234
3234
  const dirPrefix = dirMods.length ? dirMods.map((m) => DIR_MODS[m]).join(" ") + " " : "";
3235
3235
  const selector = `${dirPrefix}${ancestorPrefix}${elementSelector}`;
3236
+ const CSS_ONLY_PSEUDOS = /* @__PURE__ */ new Set([
3237
+ "first",
3238
+ "last",
3239
+ "odd",
3240
+ "even",
3241
+ "only",
3242
+ "focus-within",
3243
+ "focus-visible"
3244
+ ]);
3245
+ const needsImportant = important || hasPrint || mediaMods.length > 0 || dirMods.length > 0 || ancestorMods.length > 0 || pseudoMods.some((m) => CSS_ONLY_PSEUDOS.has(m));
3246
+ const cssDecls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, needsImportant);
3247
+ if (!cssDecls) return;
3236
3248
  let rule;
3237
3249
  if (hasDark) {
3238
3250
  if (darkMode === "media") {
@@ -3355,9 +3367,19 @@ function resolve(classString, theme, darkMode = "attribute") {
3355
3367
  return result;
3356
3368
  }
3357
3369
  function flatten(resolved, isDark, state = {}, breakpoints = /* @__PURE__ */ new Set()) {
3358
- const result = { ...resolved.base ?? {} };
3359
- for (const [key, styles] of Object.entries(resolved)) {
3360
- if (key === "base" || !styles) continue;
3370
+ const result = {};
3371
+ const entries = Object.entries(resolved);
3372
+ entries.sort((a, b) => {
3373
+ const pa = a[0] === "base" ? -1 : a[0].split(":").length;
3374
+ const pb = b[0] === "base" ? -1 : b[0].split(":").length;
3375
+ return pa - pb;
3376
+ });
3377
+ for (const [key, styles] of entries) {
3378
+ if (!styles) continue;
3379
+ if (key === "base") {
3380
+ Object.assign(result, styles);
3381
+ continue;
3382
+ }
3361
3383
  const mods = key.split(":");
3362
3384
  if (matchesMods(mods, isDark, state, breakpoints)) {
3363
3385
  Object.assign(result, styles);
package/dist/index.mjs CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  useConditionalWidth,
24
24
  useGlobalDarkMode,
25
25
  useGlobalWidth
26
- } from "./chunk-XVPIJMIR.mjs";
26
+ } from "./chunk-OKK7AJ2G.mjs";
27
27
 
28
28
  // src/context.tsx
29
29
  import { createContext, useContext } from "react";
@@ -3099,12 +3099,12 @@ function injectClassRule(cls, bucketKey, styles, darkMode, important = false) {
3099
3099
  injectRule(styles.__keyframe);
3100
3100
  }
3101
3101
  const isDivide = "__divideX" in styles || "__divideY" in styles || "__divideColor" in styles || "__divideStyle" in styles;
3102
- const cssDecls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, important);
3103
- if (!cssDecls) return;
3104
3102
  const escaped = escapeCSSSelector(cls);
3105
3103
  const childSuffix = isDivide ? " > * + *" : "";
3106
3104
  if (bucketKey === "base") {
3107
- injectRule(`.${escaped}${childSuffix} { ${cssDecls} }`);
3105
+ const baseCssDecls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, important);
3106
+ if (!baseCssDecls) return;
3107
+ injectRule(`.${escaped}${childSuffix} { ${baseCssDecls} }`);
3108
3108
  return;
3109
3109
  }
3110
3110
  const mods = bucketKey.split(":");
@@ -3124,6 +3124,18 @@ function injectClassRule(cls, bucketKey, styles, darkMode, important = false) {
3124
3124
  const ancestorPrefix = ancestorMods.length ? ancestorMods.map((m) => GROUP_PEER_PREFIX[m]).join(" ") + " " : "";
3125
3125
  const dirPrefix = dirMods.length ? dirMods.map((m) => DIR_MODS[m]).join(" ") + " " : "";
3126
3126
  const selector = `${dirPrefix}${ancestorPrefix}${elementSelector}`;
3127
+ const CSS_ONLY_PSEUDOS = /* @__PURE__ */ new Set([
3128
+ "first",
3129
+ "last",
3130
+ "odd",
3131
+ "even",
3132
+ "only",
3133
+ "focus-within",
3134
+ "focus-visible"
3135
+ ]);
3136
+ const needsImportant = important || hasPrint || mediaMods.length > 0 || dirMods.length > 0 || ancestorMods.length > 0 || pseudoMods.some((m) => CSS_ONLY_PSEUDOS.has(m));
3137
+ const cssDecls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, needsImportant);
3138
+ if (!cssDecls) return;
3127
3139
  let rule;
3128
3140
  if (hasDark) {
3129
3141
  if (darkMode === "media") {
@@ -3246,9 +3258,19 @@ function resolve(classString, theme, darkMode = "attribute") {
3246
3258
  return result;
3247
3259
  }
3248
3260
  function flatten(resolved, isDark, state = {}, breakpoints = /* @__PURE__ */ new Set()) {
3249
- const result = { ...resolved.base ?? {} };
3250
- for (const [key, styles] of Object.entries(resolved)) {
3251
- if (key === "base" || !styles) continue;
3261
+ const result = {};
3262
+ const entries = Object.entries(resolved);
3263
+ entries.sort((a, b) => {
3264
+ const pa = a[0] === "base" ? -1 : a[0].split(":").length;
3265
+ const pb = b[0] === "base" ? -1 : b[0].split(":").length;
3266
+ return pa - pb;
3267
+ });
3268
+ for (const [key, styles] of entries) {
3269
+ if (!styles) continue;
3270
+ if (key === "base") {
3271
+ Object.assign(result, styles);
3272
+ continue;
3273
+ }
3252
3274
  const mods = key.split(":");
3253
3275
  if (matchesMods(mods, isDark, state, breakpoints)) {
3254
3276
  Object.assign(result, styles);
@@ -3705,17 +3727,12 @@ var INTERACTIVE_MODS = /* @__PURE__ */ new Set([
3705
3727
  "visited",
3706
3728
  "not-visited",
3707
3729
  "placeholder",
3708
- "focus-within",
3709
- "focus-visible",
3710
3730
  "group-hover",
3711
3731
  "group-focus",
3712
3732
  "peer-hover",
3713
- "peer-focus",
3714
- "first",
3715
- "last",
3716
- "odd",
3717
- "even",
3718
- "only"
3733
+ "peer-focus"
3734
+ // focus-within / focus-visible / first / last / odd / even / only are CSS-only —
3735
+ // they have no JS state to track, so they don't need InteractiveWrapper.
3719
3736
  ]);
3720
3737
  var RESPONSIVE_MODS4 = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
3721
3738
  var MODE_MODS_JSX = /* @__PURE__ */ new Set(["dark", "light", "not-dark", "not-light"]);
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-XGWS3OQD.mjs";
6
- import "./chunk-XVPIJMIR.mjs";
5
+ } from "./chunk-7C3WGTMN.mjs";
6
+ import "./chunk-OKK7AJ2G.mjs";
7
7
 
8
8
  // src/jsx-dev-runtime.tsx
9
9
  function jsxDEV(type, props, key, isStaticChildren, _source, _self) {
@@ -3098,12 +3098,12 @@ function injectClassRule(cls, bucketKey, styles, darkMode, important = false) {
3098
3098
  injectRule(styles.__keyframe);
3099
3099
  }
3100
3100
  const isDivide = "__divideX" in styles || "__divideY" in styles || "__divideColor" in styles || "__divideStyle" in styles;
3101
- const cssDecls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, important);
3102
- if (!cssDecls) return;
3103
3101
  const escaped = escapeCSSSelector(cls);
3104
3102
  const childSuffix = isDivide ? " > * + *" : "";
3105
3103
  if (bucketKey === "base") {
3106
- injectRule(`.${escaped}${childSuffix} { ${cssDecls} }`);
3104
+ const baseCssDecls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, important);
3105
+ if (!baseCssDecls) return;
3106
+ injectRule(`.${escaped}${childSuffix} { ${baseCssDecls} }`);
3107
3107
  return;
3108
3108
  }
3109
3109
  const mods = bucketKey.split(":");
@@ -3123,6 +3123,18 @@ function injectClassRule(cls, bucketKey, styles, darkMode, important = false) {
3123
3123
  const ancestorPrefix = ancestorMods.length ? ancestorMods.map((m) => GROUP_PEER_PREFIX[m]).join(" ") + " " : "";
3124
3124
  const dirPrefix = dirMods.length ? dirMods.map((m) => DIR_MODS[m]).join(" ") + " " : "";
3125
3125
  const selector = `${dirPrefix}${ancestorPrefix}${elementSelector}`;
3126
+ const CSS_ONLY_PSEUDOS = /* @__PURE__ */ new Set([
3127
+ "first",
3128
+ "last",
3129
+ "odd",
3130
+ "even",
3131
+ "only",
3132
+ "focus-within",
3133
+ "focus-visible"
3134
+ ]);
3135
+ const needsImportant = important || hasPrint || mediaMods.length > 0 || dirMods.length > 0 || ancestorMods.length > 0 || pseudoMods.some((m) => CSS_ONLY_PSEUDOS.has(m));
3136
+ const cssDecls = isDivide ? buildDivideDecls(styles) : styleValueToCSS(styles, needsImportant);
3137
+ if (!cssDecls) return;
3126
3138
  let rule;
3127
3139
  if (hasDark) {
3128
3140
  if (darkMode === "media") {
@@ -3245,9 +3257,19 @@ function resolve(classString, theme, darkMode = "attribute") {
3245
3257
  return result;
3246
3258
  }
3247
3259
  function flatten(resolved, isDark, state = {}, breakpoints = /* @__PURE__ */ new Set()) {
3248
- const result = { ...resolved.base ?? {} };
3249
- for (const [key, styles] of Object.entries(resolved)) {
3250
- if (key === "base" || !styles) continue;
3260
+ const result = {};
3261
+ const entries = Object.entries(resolved);
3262
+ entries.sort((a, b) => {
3263
+ const pa = a[0] === "base" ? -1 : a[0].split(":").length;
3264
+ const pb = b[0] === "base" ? -1 : b[0].split(":").length;
3265
+ return pa - pb;
3266
+ });
3267
+ for (const [key, styles] of entries) {
3268
+ if (!styles) continue;
3269
+ if (key === "base") {
3270
+ Object.assign(result, styles);
3271
+ continue;
3272
+ }
3251
3273
  const mods = key.split(":");
3252
3274
  if (matchesMods(mods, isDark, state, breakpoints)) {
3253
3275
  Object.assign(result, styles);
@@ -3704,17 +3726,12 @@ var INTERACTIVE_MODS = /* @__PURE__ */ new Set([
3704
3726
  "visited",
3705
3727
  "not-visited",
3706
3728
  "placeholder",
3707
- "focus-within",
3708
- "focus-visible",
3709
3729
  "group-hover",
3710
3730
  "group-focus",
3711
3731
  "peer-hover",
3712
- "peer-focus",
3713
- "first",
3714
- "last",
3715
- "odd",
3716
- "even",
3717
- "only"
3732
+ "peer-focus"
3733
+ // focus-within / focus-visible / first / last / odd / even / only are CSS-only —
3734
+ // they have no JS state to track, so they don't need InteractiveWrapper.
3718
3735
  ]);
3719
3736
  var RESPONSIVE_MODS4 = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
3720
3737
  var MODE_MODS_JSX = /* @__PURE__ */ new Set(["dark", "light", "not-dark", "not-light"]);
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-XGWS3OQD.mjs";
6
- import "./chunk-XVPIJMIR.mjs";
5
+ } from "./chunk-7C3WGTMN.mjs";
6
+ import "./chunk-OKK7AJ2G.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.5.2",
3
+ "version": "0.5.3",
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",