mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-11 09:51:40 +00:00
* feat: implement shadcn/registry * feat: add schema field * fix: import * chore: add changeset * chore: remove console * fix: tests * fix: diff command * feat: move to schema/registy-item.json * fix * ci: switch to node 20 * ci: build packages
31 lines
817 B
TypeScript
31 lines
817 B
TypeScript
"use server"
|
|
|
|
import { registryItemSchema } from "shadcn/registry"
|
|
import { z } from "zod"
|
|
|
|
import { Style } from "@/registry/registry-styles"
|
|
|
|
export async function getAllBlockIds(
|
|
types: z.infer<typeof registryItemSchema>["type"][] = [
|
|
"registry:block",
|
|
"registry:internal",
|
|
],
|
|
categories: string[] = [],
|
|
style: Style["name"] = "new-york"
|
|
): Promise<string[]> {
|
|
const { Index } = await import("@/__registry__")
|
|
const index = z.record(registryItemSchema).parse(Index[style])
|
|
|
|
return Object.values(index)
|
|
.filter(
|
|
(block) =>
|
|
types.includes(block.type) &&
|
|
(categories.length === 0 ||
|
|
block.categories?.some((category) =>
|
|
categories.includes(category)
|
|
)) &&
|
|
!block.name.startsWith("chart-")
|
|
)
|
|
.map((block) => block.name)
|
|
}
|