@barocss/kit 0.10.0 → 0.10.2

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.
package/dist/index.js CHANGED
@@ -1447,6 +1447,7 @@ function themeToCssVarsAll(theme) {
1447
1447
  ...spacingToCssVars(theme.spacing),
1448
1448
  ...containerToCssVars(theme.container),
1449
1449
  ...borderRadiusToCssVars(theme.borderRadius),
1450
+ ...Object.fromEntries(Object.entries(theme.borderWidth ?? {}).filter(([k]) => k !== "DEFAULT").map(([k, v]) => [`--border-width-${escapeKey(k)}`, String(v)])),
1450
1451
  ...zIndexToCssVars(theme.zIndex),
1451
1452
  ...opacityToCssVars(theme.opacity),
1452
1453
  ...animationToCssVars({
@@ -6671,6 +6672,20 @@ var stopsDecls = (stop, color) => {
6671
6672
  category: "background"
6672
6673
  });
6673
6674
  });
6675
+ var BG_HINTS = {
6676
+ position: "background-position",
6677
+ percentage: "background-position",
6678
+ size: "background-size",
6679
+ length: "background-size",
6680
+ "bg-size": "background-size",
6681
+ image: "background-image",
6682
+ url: "background-image"
6683
+ };
6684
+ function bgHint(value) {
6685
+ const m = /^([a-z-]+):(.+)$/.exec(value);
6686
+ const prop = m ? BG_HINTS[m[1]] : void 0;
6687
+ return m && prop ? [prop, m[2]] : null;
6688
+ }
6674
6689
  /**
6675
6690
  * background-size utility (arbitrary, custom property supported)
6676
6691
  * bg-[length] → background-size: [length]
@@ -6688,7 +6703,8 @@ functionalUtility({
6688
6703
  supportsOpacity: true,
6689
6704
  handle: (value, context, token, extra) => {
6690
6705
  if (value.startsWith("url(")) return [decl("background-image", value)];
6691
- if (value.startsWith("length:")) return [decl("background-size", value.replace("length:", ""))];
6706
+ const hinted = bgHint(value);
6707
+ if (hinted) return [decl(hinted[0], hinted[1])];
6692
6708
  if (extra?.realThemeValue) return themeColorDecls("background-color", value, extra);
6693
6709
  if (parseColor(value)) {
6694
6710
  const parsedColor = parseColor(value);
@@ -6698,7 +6714,10 @@ functionalUtility({
6698
6714
  if (parseLength(value)) return [decl("background-size", value)];
6699
6715
  return null;
6700
6716
  },
6701
- handleCustomProperty: (value) => value.startsWith("length:") ? [decl("background-size", `var(${value.slice(7)})`)] : [decl("background-color", `var(${value})`)],
6717
+ handleCustomProperty: (value) => {
6718
+ const hinted = bgHint(value);
6719
+ return hinted ? [decl(hinted[0], `var(${hinted[1]})`)] : [decl("background-color", `var(${value})`)];
6720
+ },
6702
6721
  description: "background-size utility (arbitrary, custom property supported)",
6703
6722
  category: "background"
6704
6723
  });
@@ -6783,6 +6802,7 @@ functionalUtility({
6783
6802
  category: "borders"
6784
6803
  });
6785
6804
  var borderStyleProperty = () => atRoot([property("--baro-border-style", "solid")]);
6805
+ var borderWidthRef = (value, extra) => extra?.themeKey && extra.themeKey !== "DEFAULT" ? `var(--border-width-${extra.themeKey.replace(".", "\\.")})` : value;
6786
6806
  var withBorderStyle = (props, width) => [
6787
6807
  borderStyleProperty(),
6788
6808
  ...props.map((prop) => decl(prop.replace("width", "style"), "var(--baro-border-style)")),
@@ -6802,8 +6822,8 @@ var withBorderStyle = (props, width) => [
6802
6822
  ], { category: "borders" });
6803
6823
  });
6804
6824
  [
6805
- ["border-x", ["border-left-width", "border-right-width"]],
6806
- ["border-y", ["border-top-width", "border-bottom-width"]],
6825
+ ["border-x", ["border-inline-width"]],
6826
+ ["border-y", ["border-block-width"]],
6807
6827
  ["border-bs", ["border-block-start-width"]],
6808
6828
  ["border-be", ["border-block-end-width"]],
6809
6829
  ["border-s", ["border-inline-start-width"]],
@@ -6835,10 +6855,11 @@ var withBorderStyle = (props, width) => [
6835
6855
  return null;
6836
6856
  },
6837
6857
  handle: (value, ctx, token, extra) => {
6838
- if (extra?.themeNamespace === "borderWidth") return withBorderStyle(propList, value);
6858
+ if (extra?.themeNamespace === "borderWidth") return withBorderStyle(propList, borderWidthRef(value, extra));
6839
6859
  if (extra?.realThemeValue) return propList.flatMap((prop) => themeColorDecls(prop.replace("width", "color"), value, extra));
6840
6860
  if (parseColor(value)) return propList.map((prop) => decl(prop.replace("width", "color"), value));
6841
6861
  if (token.arbitrary) return withBorderStyle(propList, value);
6862
+ if (parseLength(value)) return withBorderStyle(propList, value);
6842
6863
  return null;
6843
6864
  },
6844
6865
  handleCustomProperty: (value) => {
@@ -6884,8 +6905,10 @@ Object.entries({
6884
6905
  name: `divide-${axis}`,
6885
6906
  themeKeys: ["divideWidth", "borderWidth"],
6886
6907
  supportsArbitrary: true,
6908
+ supportsCustomProperty: true,
6909
+ handleCustomProperty: (value) => divide(`var(${value.replace(/^length:/, "")})`),
6887
6910
  handleBareValue: ({ value }) => /^\d+$/.test(value) ? `${value}px` : null,
6888
- handle: (value) => divide(value),
6911
+ handle: (value, _ctx, _token, extra) => divide(extra?.themeNamespace === "borderWidth" ? borderWidthRef(value, extra) : value),
6889
6912
  description: `divide-${axis} width utility`,
6890
6913
  category: "borders"
6891
6914
  });
@@ -6897,7 +6920,7 @@ functionalUtility({
6897
6920
  supportsCustomProperty: true,
6898
6921
  supportsOpacity: true,
6899
6922
  handle: (value, ctx, token, extra) => {
6900
- if (extra?.themeNamespace === "borderWidth") return withBorderStyle(["border-width"], value);
6923
+ if (extra?.themeNamespace === "borderWidth") return withBorderStyle(["border-width"], borderWidthRef(value, extra));
6901
6924
  if (extra?.realThemeValue) return themeColorDecls("border-color", value, extra);
6902
6925
  if (token.arbitrary) {
6903
6926
  if (parseLength(value)) return withBorderStyle(["border-width"], value);
@@ -7019,12 +7042,13 @@ functionalUtility({
7019
7042
  supportsArbitrary: true,
7020
7043
  supportsCustomProperty: true,
7021
7044
  supportsOpacity: true,
7022
- handle: (value, _ctx, _token, extra) => {
7045
+ handle: (value, _ctx, token, extra) => {
7046
+ if (token.prefix !== "divide") return null;
7023
7047
  if (extra?.realThemeValue) return [rule(":where(& > :not(:last-child))", themeColorDecls("border-color", value, extra))];
7024
7048
  if (parseColor(value)) return divideColor(value);
7025
7049
  return null;
7026
7050
  },
7027
- handleCustomProperty: (value) => divideColor(`var(${value})`),
7051
+ handleCustomProperty: (value, _ctx, token) => token.prefix === "divide" ? divideColor(`var(${value})`) : [],
7028
7052
  description: "divide-color utility (theme, alpha, arbitrary, custom property)",
7029
7053
  category: "borders"
7030
7054
  });
@@ -7428,6 +7452,8 @@ functionalUtility({
7428
7452
  });
7429
7453
  //#endregion
7430
7454
  //#region src/presets/svg.ts
7455
+ var STROKE_WIDTH_HINT = /^(length|number|percentage):(.+)$/;
7456
+ var STROKE_LENGTH = /^(\d*\.)?\d+(px|em|rem|vh|vw|vmin|vmax|%|in|cm|mm|pt|pc|ex|ch|q|lh|rlh|svh|lvh|dvh|cqw|cqh)$/i;
7431
7457
  staticUtility("fill-inherit", [["fill", "inherit"]], { category: "svg" });
7432
7458
  staticUtility("fill-current", [["fill", "currentColor"]], { category: "svg" });
7433
7459
  staticUtility("fill-transparent", [["fill", "transparent"]], { category: "svg" });
@@ -7457,11 +7483,17 @@ functionalUtility({
7457
7483
  supportsCustomProperty: true,
7458
7484
  handle: (value, ctx, token, extra) => {
7459
7485
  if (parseNumber(value) || extra?.themeNamespace === "strokeWidth") return [decl("stroke-width", value)];
7486
+ if (token.arbitrary) {
7487
+ const hint = STROKE_WIDTH_HINT.exec(value);
7488
+ if (hint) return [decl("stroke-width", hint[2])];
7489
+ if (!parseColor(value) && (STROKE_LENGTH.test(value) || /^calc\(/.test(value))) return [decl("stroke-width", value)];
7490
+ }
7460
7491
  if (extra?.realThemeValue) return [decl("stroke", `var(--color-${extra.realThemeValue})`)];
7461
7492
  return [decl("stroke", value)];
7462
7493
  },
7463
7494
  handleCustomProperty: (value) => {
7464
- if (value.startsWith("length:")) return [decl("stroke-width", `var(${value.replace("length:", "")})`)];
7495
+ const hint = STROKE_WIDTH_HINT.exec(value);
7496
+ if (hint) return [decl("stroke-width", `var(${hint[2]})`)];
7465
7497
  return [decl("stroke", `var(${value})`)];
7466
7498
  },
7467
7499
  description: "stroke utility (static, theme, arbitrary, custom property supported)",
@@ -7539,6 +7571,21 @@ staticModifier("prefers-contrast-less", ["&"], {
7539
7571
  wrap: () => [atRule("media", "(prefers-contrast: less)", [], "media")],
7540
7572
  source: "media"
7541
7573
  });
7574
+ staticModifier("contrast-more", ["&"], {
7575
+ order: 5,
7576
+ wrap: () => [atRule("media", "(prefers-contrast: more)", [], "media")],
7577
+ source: "media"
7578
+ });
7579
+ staticModifier("contrast-less", ["&"], {
7580
+ order: 5,
7581
+ wrap: () => [atRule("media", "(prefers-contrast: less)", [], "media")],
7582
+ source: "media"
7583
+ });
7584
+ staticModifier("noscript", ["&"], {
7585
+ order: 5,
7586
+ wrap: () => [atRule("media", "(scripting: none)", [], "media")],
7587
+ source: "media"
7588
+ });
7542
7589
  staticModifier("forced-colors", ["&"], {
7543
7590
  order: 5,
7544
7591
  wrap: () => [atRule("media", "(forced-colors: active)", [], "media")],
@@ -7784,6 +7831,30 @@ function negatedAtRuleOf(name, ctx) {
7784
7831
  nodes: []
7785
7832
  };
7786
7833
  }
7834
+ /**
7835
+ * #354: the at-rule for `not-[@<name> <params>]` (`_` decoded to a space), as Tailwind 4.3.3 emits it:
7836
+ * `@media`/`@supports` → `not <params>` (a leading `not` is removed instead), `@container [name] <query>` →
7837
+ * `@container [name] not <query>`. Null for any other at-rule, an empty condition or a top-level comma list,
7838
+ * where Tailwind emits nothing or an invalid prelude.
7839
+ */
7840
+ function negatedArbitraryAtRuleOf(value) {
7841
+ const m = /^@(media|supports|container)(?:\s+|(?=\()|$)([\s\S]*)$/.exec(decodeArbitrarySelector(value).trim());
7842
+ if (!m) return null;
7843
+ const name = m[1];
7844
+ let params = (m[2] ?? "").trim();
7845
+ let prefix = "";
7846
+ if (name === "container") {
7847
+ const n = /^(?!not\b)([a-zA-Z_-][a-zA-Z0-9_-]*)\s+([\s\S]*)$/.exec(params);
7848
+ if (n) {
7849
+ prefix = `${n[1]} `;
7850
+ params = n[2].trim();
7851
+ }
7852
+ }
7853
+ if (!params || hasTopLevelComma(params)) return null;
7854
+ const neg = /^not\s+/i.test(params) ? params.replace(/^not\s+/i, "") : `not ${params}`;
7855
+ if (!neg) return null;
7856
+ return atRule(name, `${prefix}${neg}`, [], name);
7857
+ }
7787
7858
  //#endregion
7788
7859
  //#region src/presets/variants/responsive.ts
7789
7860
  functionalModifier((mod, context) => {
@@ -8033,7 +8104,11 @@ functionalModifier((mod, context) => /^not-(?!@)/.test(mod) && !!negatedAtRuleOf
8033
8104
  const node = negatedAtRuleOf(mod.type.slice(4), context);
8034
8105
  return node ? [node] : [];
8035
8106
  });
8036
- functionalModifier((mod) => /^not-\[.*\]$/.test(mod), ({ selector, mod }) => {
8107
+ functionalModifier((mod) => /^not-\[@.*\]$/.test(mod) && !!negatedArbitraryAtRuleOf(mod.slice(5, -1)), () => "&", (mod) => {
8108
+ const node = negatedArbitraryAtRuleOf(mod.type.slice(5, -1));
8109
+ return node ? [node] : [];
8110
+ });
8111
+ functionalModifier((mod) => /^not-\[(?!@).*\]$/.test(mod), ({ selector, mod }) => {
8037
8112
  const m = /^not-\[(.+)\]$/.exec(mod.type);
8038
8113
  if (m) {
8039
8114
  if (!/^[a-zA-Z0-9_-]+(=.+)?$/.test(m[1])) return {
@@ -8054,7 +8129,7 @@ functionalModifier((mod) => /^not-\[.*\]$/.test(mod), ({ selector, mod }) => {
8054
8129
  source: "attribute"
8055
8130
  };
8056
8131
  });
8057
- functionalModifier((mod) => /^not-/.test(mod) && !mod.startsWith("not-@"), ({ selector, mod, context }) => {
8132
+ functionalModifier((mod) => /^not-/.test(mod) && !mod.startsWith("not-@") && !mod.startsWith("not-[@"), ({ selector, mod, context }) => {
8058
8133
  const m = /^not-(.+)$/.exec(mod.type);
8059
8134
  const inner = m ? negatableSelectorOf(m[1], context) : null;
8060
8135
  if (m && !inner) return null;
@@ -8119,7 +8194,7 @@ functionalModifier((mod) => /^aria-/.test(mod), ({ selector, mod }) => {
8119
8194
  source: "aria"
8120
8195
  };
8121
8196
  }, void 0);
8122
- functionalModifier((mod) => mod.startsWith("not-") && !mod.startsWith("not-@"), ({ selector, mod, context }) => {
8197
+ functionalModifier((mod) => mod.startsWith("not-") && !mod.startsWith("not-@") && !mod.startsWith("not-[@"), ({ selector, mod, context }) => {
8123
8198
  const pseudo = mod.type.replace("not-", "");
8124
8199
  if (pseudo.startsWith("[")) {
8125
8200
  const inner = pseudo.slice(1, -1);
@@ -8222,10 +8297,16 @@ functionalModifier((mod) => /^where-\[.*\]$/.test(mod), ({ selector, mod }) => {
8222
8297
  }, void 0);
8223
8298
  //#endregion
8224
8299
  //#region src/presets/variants/at-rules.ts
8225
- functionalModifier((mod) => /^supports-\[.*\]$/.test(mod), void 0, (mod) => {
8226
- const m = /^supports-\[(.+)\]$/.exec(mod.type);
8227
- if (m) return [atRule("supports", `(${m[1]})`, [], "supports")];
8228
- return [];
8300
+ function supportsCondition(value) {
8301
+ if (/^[\w-]*\s*\(/.test(value)) return value;
8302
+ let v = value.includes(":") ? value : `${value}: var(--tw)`;
8303
+ if (v[0] !== "(" || v[v.length - 1] !== ")") v = `(${v})`;
8304
+ return v;
8305
+ }
8306
+ functionalModifier((mod) => /^supports-(?:\[.+\]|[a-zA-Z-][a-zA-Z0-9-]*)$/.test(mod), void 0, (mod) => {
8307
+ const m = /^supports-(?:\[(.+)\]|([a-zA-Z-][a-zA-Z0-9-]*))$/.exec(mod.type);
8308
+ if (!m) return [];
8309
+ return [atRule("supports", supportsCondition(m[1] !== void 0 ? decodeArbitrarySelector(m[1]) : m[2]), [], "supports")];
8229
8310
  });
8230
8311
  functionalModifier((mod) => /^layer-\[.*\]$/.test(mod), void 0, (mod) => {
8231
8312
  const m = /^layer-\[(.+)\]$/.exec(mod.type);
@@ -8253,6 +8334,7 @@ functionalModifier((mod) => /^(group|peer)-hover(\/[a-zA-Z0-9_-]+)?$/.test(mod),
8253
8334
  }, () => [atRule("media", "(hover: hover)", [])]);
8254
8335
  function negated(value, ctx) {
8255
8336
  const v = value.slice(4);
8337
+ if (v.startsWith("[@")) return null;
8256
8338
  if (v.startsWith("[") && v.endsWith("]")) return `:not(*:is(${decodeArbitrarySelector(v.slice(1, -1))}))`;
8257
8339
  const inner = negatableSelectorOf(v, ctx);
8258
8340
  return inner ? `:not(${inner})` : null;