@homebound/truss 2.1.2 → 2.2.0

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.
@@ -501,9 +501,9 @@ var PSEUDO_CLASS_PRIORITIES = {
501
501
  ":past": 126,
502
502
  ":future": 127,
503
503
  ":hover": 130,
504
- ":focusWithin": 140,
504
+ ":focus-within": 140,
505
505
  ":focus": 150,
506
- ":focusVisible": 160,
506
+ ":focus-visible": 160,
507
507
  ":active": 170
508
508
  };
509
509
  var AT_RULE_PRIORITIES = {
@@ -520,7 +520,9 @@ function getPropertyPriority(property) {
520
520
  return 3e3;
521
521
  }
522
522
  function getPseudoClassPriority(pseudo) {
523
- const base = pseudo.split("(")[0];
523
+ const base = pseudo.split("(")[0].replace(/[A-Z]/g, function(match) {
524
+ return `-${match.toLowerCase()}`;
525
+ });
524
526
  return PSEUDO_CLASS_PRIORITIES[base] ?? 40;
525
527
  }
526
528
  function getAtRulePriority(atRule) {
@@ -581,6 +583,7 @@ var PSEUDO_SUFFIX = {
581
583
  ":hover": "_h",
582
584
  ":focus": "_f",
583
585
  ":focus-visible": "_fv",
586
+ ":focus-within": "_fw",
584
587
  ":active": "_a",
585
588
  ":disabled": "_d"
586
589
  };
@@ -1195,7 +1198,7 @@ function resolveChain(chain, mapping) {
1195
1198
  currentWhenPseudo = null;
1196
1199
  continue;
1197
1200
  }
1198
- if (abbr === "add") {
1201
+ if (abbr === "add" || abbr === "addCss") {
1199
1202
  const seg = resolveAddCall(
1200
1203
  node,
1201
1204
  mapping,
@@ -1450,6 +1453,24 @@ function buildParameterizedSegment(params) {
1450
1453
  return base;
1451
1454
  }
1452
1455
  function resolveAddCall(node, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo) {
1456
+ const isAddCss = node.name === "addCss";
1457
+ if (isAddCss) {
1458
+ if (node.args.length !== 1) {
1459
+ throw new UnsupportedPatternError(
1460
+ `addCss() requires exactly 1 argument (an existing CssProp/style hash expression)`
1461
+ );
1462
+ }
1463
+ const styleArg = node.args[0];
1464
+ if (styleArg.type === "SpreadElement") {
1465
+ throw new UnsupportedPatternError(`addCss() does not support spread arguments`);
1466
+ }
1467
+ return {
1468
+ abbr: "__composed_css_prop",
1469
+ defs: {},
1470
+ styleArrayArg: styleArg,
1471
+ isAddCss: true
1472
+ };
1473
+ }
1453
1474
  if (node.args.length === 1) {
1454
1475
  const styleArg = node.args[0];
1455
1476
  if (styleArg.type === "SpreadElement") {
@@ -1468,7 +1489,7 @@ function resolveAddCall(node, mapping, mediaQuery, pseudoClass, pseudoElement, w
1468
1489
  }
1469
1490
  if (node.args.length !== 2) {
1470
1491
  throw new UnsupportedPatternError(
1471
- `add() requires exactly 2 arguments (property name and value), got ${node.args.length}. Supported overloads are add(cssProp) and add("propName", value)`
1492
+ `add() requires exactly 2 arguments (property name and value), got ${node.args.length}. Supported overloads are add(cssProp), addCss(cssProp), and add("propName", value)`
1472
1493
  );
1473
1494
  }
1474
1495
  const propArg = node.args[0];
@@ -1555,6 +1576,7 @@ var PSEUDO_METHODS = {
1555
1576
  onHover: ":hover",
1556
1577
  onFocus: ":focus",
1557
1578
  onFocusVisible: ":focus-visible",
1579
+ onFocusWithin: ":focus-within",
1558
1580
  onActive: ":active",
1559
1581
  onDisabled: ":disabled"
1560
1582
  };
@@ -1993,7 +2015,11 @@ function buildStyleHashMembers(segments, options) {
1993
2015
  if (seg.error) continue;
1994
2016
  if (seg.styleArrayArg) {
1995
2017
  flushNormal();
1996
- members.push(t3.spreadElement(seg.styleArrayArg));
2018
+ if (seg.isAddCss && t3.isObjectExpression(seg.styleArrayArg)) {
2019
+ members.push(...buildAddCssObjectMembers(seg.styleArrayArg));
2020
+ } else {
2021
+ members.push(t3.spreadElement(seg.styleArrayArg));
2022
+ }
1997
2023
  continue;
1998
2024
  }
1999
2025
  if (seg.typographyLookup) {
@@ -2014,6 +2040,34 @@ function buildStyleHashMembers(segments, options) {
2014
2040
  flushNormal();
2015
2041
  return members;
2016
2042
  }
2043
+ function buildAddCssObjectMembers(styleObject) {
2044
+ const members = [];
2045
+ for (const property of styleObject.properties) {
2046
+ if (t3.isSpreadElement(property)) {
2047
+ members.push(t3.spreadElement(t3.cloneNode(property.argument, true)));
2048
+ continue;
2049
+ }
2050
+ if (!t3.isObjectProperty(property) || property.computed) {
2051
+ members.push(t3.spreadElement(t3.objectExpression([t3.cloneNode(property, true)])));
2052
+ continue;
2053
+ }
2054
+ const value = property.value;
2055
+ if (t3.isIdentifier(value) || t3.isMemberExpression(value) || t3.isOptionalMemberExpression(value)) {
2056
+ members.push(
2057
+ t3.spreadElement(
2058
+ t3.conditionalExpression(
2059
+ t3.binaryExpression("===", t3.cloneNode(value, true), t3.identifier("undefined")),
2060
+ t3.objectExpression([]),
2061
+ t3.objectExpression([t3.objectProperty(clonePropertyKey(property.key), t3.cloneNode(value, true))])
2062
+ )
2063
+ )
2064
+ );
2065
+ continue;
2066
+ }
2067
+ members.push(t3.spreadElement(t3.objectExpression([t3.cloneNode(property, true)])));
2068
+ }
2069
+ return members;
2070
+ }
2017
2071
  function collectConditionalOnlyProps(segments) {
2018
2072
  const allProps = /* @__PURE__ */ new Map();
2019
2073
  for (const seg of segments) {