fix(cli): fix add registry item with at-property css rule (#8451)

* Add fixture and test

* Handle at-property as regular CSS rules in updateCssPlugin

* Add changeset entry

---------

Co-authored-by: shadcn <m@shadcn.com>
This commit is contained in:
Haz
2025-10-14 17:11:29 +04:00
committed by GitHub
parent 6a534d7954
commit b83023034a
4 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"shadcn": patch
---
fix adding registry item with CSS at-property

View File

@@ -338,6 +338,10 @@ function updateCssPlugin(css: z.infer<typeof registryItemCssSchema>) {
}
}
}
}
// Handle at-property as regular CSS rules
else if (name === "property") {
processRule(root, selector, properties)
} else {
// Handle other at-rules normally
processAtRule(root, name, params, properties)

View File

@@ -0,0 +1,12 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "example-at-property",
"type": "registry:style",
"css": {
"@property --foo": {
"syntax": "'<number>'",
"inherits": "false",
"initial-value": "0"
}
}
}

View File

@@ -296,4 +296,31 @@ describe("shadcn add", () => {
await fs.readFile(path.join(fixturePath, "path/to/foo.txt"), "utf-8")
).toBe("Foo Bar")
})
it("should add at-property", async () => {
const fixturePath = await createFixtureTestDirectory("next-app-init")
await npxShadcn(fixturePath, [
"add",
"../../fixtures/registry/example-at-property.json",
"--yes",
])
const globalCssContent = await fs.readFile(
path.join(fixturePath, "app/globals.css"),
"utf-8"
)
expect(
cssHasProperties(globalCssContent, [
{
selector: "@property --foo",
properties: {
syntax: "'<number>'",
inherits: "false",
"initial-value": "0",
},
},
])
).toBe(true)
})
})