@homebound/truss 2.6.0 → 2.7.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.
- package/build/index.d.ts +0 -1
- package/build/index.js +16 -59
- package/build/index.js.map +1 -1
- package/build/plugin/index.js +6 -2
- package/build/plugin/index.js.map +1 -1
- package/build/vitest.d.ts +23 -3
- package/package.json +1 -1
- package/build/toHaveStyle-Y8DGA4JF.d.ts +0 -24
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -1070,7 +1070,15 @@ class CssBuilder<T extends Properties> {
|
|
|
1070
1070
|
get onFocusWithin() {
|
|
1071
1071
|
return this.newCss({ selector: ":focus-within" });
|
|
1072
1072
|
}
|
|
1073
|
-
|
|
1073
|
+
|
|
1074
|
+
get ifFirstOfType() {
|
|
1075
|
+
return this.newCss({ selector: ":first-of-type" });
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
get ifLastOfType() {
|
|
1079
|
+
return this.newCss({ selector: ":last-of-type" });
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1074
1082
|
ifContainer(props: ContainerProps) {
|
|
1075
1083
|
return this.newCss({ selector: Container(props) });
|
|
1076
1084
|
}
|
|
@@ -1299,6 +1307,12 @@ class CssBuilder<T extends Properties> {
|
|
|
1299
1307
|
get onDisabled() {
|
|
1300
1308
|
return this.newCss({ selector: ":disabled" });
|
|
1301
1309
|
}
|
|
1310
|
+
get ifFirstOfType() {
|
|
1311
|
+
return this.newCss({ selector: ":first-of-type" });
|
|
1312
|
+
}
|
|
1313
|
+
get ifLastOfType() {
|
|
1314
|
+
return this.newCss({ selector: ":last-of-type" });
|
|
1315
|
+
}
|
|
1302
1316
|
|
|
1303
1317
|
/** Marks this element as a default hover marker (for ancestor pseudo selectors). */
|
|
1304
1318
|
get marker(): CssBuilder<T> {
|
|
@@ -1547,62 +1561,6 @@ function condensedJson(mapping) {
|
|
|
1547
1561
|
lines.push("}");
|
|
1548
1562
|
return lines.join("\n");
|
|
1549
1563
|
}
|
|
1550
|
-
|
|
1551
|
-
// src/toHaveStyle.ts
|
|
1552
|
-
function toHaveStyle(received, expected) {
|
|
1553
|
-
if (!isElementLike(received)) {
|
|
1554
|
-
return {
|
|
1555
|
-
pass: false,
|
|
1556
|
-
message: () => `expected an Element, received ${printValue(this, "printReceived", received)}`
|
|
1557
|
-
};
|
|
1558
|
-
}
|
|
1559
|
-
const expectedStyles = parseExpectedStyles(received, expected);
|
|
1560
|
-
const mismatches = [];
|
|
1561
|
-
for (const [property, expectedValue] of expectedStyles) {
|
|
1562
|
-
const actualValue = getActualStyleValue(received, property);
|
|
1563
|
-
if (actualValue !== expectedValue) {
|
|
1564
|
-
mismatches.push(`${property}: expected ${expectedValue}, received ${actualValue || "<empty>"}`);
|
|
1565
|
-
}
|
|
1566
|
-
}
|
|
1567
|
-
return {
|
|
1568
|
-
pass: mismatches.length === 0,
|
|
1569
|
-
message: () => {
|
|
1570
|
-
const expectedLabel = printValue(this, "printExpected", expected);
|
|
1571
|
-
return mismatches.length === 0 ? `expected element not to have style ${expectedLabel}` : `expected element to have style ${expectedLabel}
|
|
1572
|
-
${mismatches.join("\n")}`;
|
|
1573
|
-
}
|
|
1574
|
-
};
|
|
1575
|
-
}
|
|
1576
|
-
function printValue(ctx, kind, value) {
|
|
1577
|
-
return ctx.utils?.[kind]?.(value) ?? JSON.stringify(value);
|
|
1578
|
-
}
|
|
1579
|
-
function isElementLike(value) {
|
|
1580
|
-
return typeof value === "object" && value !== null && "ownerDocument" in value && Boolean(value.ownerDocument?.defaultView);
|
|
1581
|
-
}
|
|
1582
|
-
function toKebabCase(property) {
|
|
1583
|
-
return property.startsWith("--") ? property : property.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
|
|
1584
|
-
}
|
|
1585
|
-
function parseExpectedStyles(el, expected) {
|
|
1586
|
-
const probe = el.ownerDocument.createElement("div");
|
|
1587
|
-
const styles = /* @__PURE__ */ new Map();
|
|
1588
|
-
if (typeof expected === "string") {
|
|
1589
|
-
probe.setAttribute("style", expected);
|
|
1590
|
-
} else {
|
|
1591
|
-
for (const [property, value] of Object.entries(expected)) {
|
|
1592
|
-
probe.style.setProperty(toKebabCase(property), String(value));
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
for (const property of Array.from(probe.style)) {
|
|
1596
|
-
styles.set(property, probe.style.getPropertyValue(property).trim());
|
|
1597
|
-
}
|
|
1598
|
-
return styles;
|
|
1599
|
-
}
|
|
1600
|
-
function getActualStyleValue(el, property) {
|
|
1601
|
-
if (property.startsWith("--")) {
|
|
1602
|
-
return el.style?.getPropertyValue(property).trim() ?? "";
|
|
1603
|
-
}
|
|
1604
|
-
return el.ownerDocument.defaultView.getComputedStyle(el).getPropertyValue(property).trim();
|
|
1605
|
-
}
|
|
1606
1564
|
export {
|
|
1607
1565
|
defaultSections,
|
|
1608
1566
|
defineConfig,
|
|
@@ -1616,7 +1574,6 @@ export {
|
|
|
1616
1574
|
newPxMethod,
|
|
1617
1575
|
newSetCssVariablesMethod,
|
|
1618
1576
|
startStylexCollection,
|
|
1619
|
-
stopStylexCollection
|
|
1620
|
-
toHaveStyle
|
|
1577
|
+
stopStylexCollection
|
|
1621
1578
|
};
|
|
1622
1579
|
//# sourceMappingURL=index.js.map
|