Files
shadcn-ui/apps/v4/lib/blocks.ts
shadcn 82d94eee38 feat: calendar v2 (#7551)
* feat(v4): upgrade calendar

* feat: more calendar examples

* fix: remove grid

* feat: more examples

* feat: more examples

* fix

* feat: update examples

* fix: dark mode

* fix: calendar in dark mode

* fix: examples

* fix

* docs: update calendar docs

* feat: update cmdk

* fix: block viewer patterns

* feat: update new-york and default

* fix: docs and examples

* fix: command menu

* feat: remove blocks from cmdk

* fix

* fix: calendar 13

* fix: format

* fix

* feat: update calendar default
2025-06-06 20:09:53 +04:00

36 lines
935 B
TypeScript

"use server"
import { registryItemSchema } from "shadcn/registry"
import { z } from "zod"
export async function getAllBlockIds(
types: z.infer<typeof registryItemSchema>["type"][] = [
"registry:block",
"registry:internal",
],
categories: string[] = []
): Promise<string[]> {
const blocks = await getAllBlocks(types, categories)
return blocks.map((block) => block.name)
}
export async function getAllBlocks(
types: z.infer<typeof registryItemSchema>["type"][] = [
"registry:block",
"registry:internal",
],
categories: string[] = []
) {
const { Index } = await import("@/registry/__index__")
const index = z.record(registryItemSchema).parse(Index)
return Object.values(index).filter(
(block) =>
types.includes(block.type) &&
(categories.length === 0 ||
block.categories?.some((category) => categories.includes(category))) &&
!block.name.startsWith("chart-")
)
}