BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/@cinatra-ai/utils

cn utility

cinatra-ai/utils
FreeUtility

Tailwind class-merge helper (clsx + tailwind-merge).

Live preview

live · rendered by the registry
Rendered by @cinatra-ai on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/cinatra-ai/cinatra/main/public/r/utils.json

Source

src/lib/utils.tsraw.githubusercontent.com/cinatra-ai/cinatra/main/public/r/utils.json
1import { clsx, type ClassValue } from "clsx";
2import { twMerge } from "tailwind-merge";
3
4export function cn(...inputs: ClassValue[]) {
5 return twMerge(clsx(inputs));
6}
7
8export function slugify(value: string) {
9 return value
10 .toLowerCase()
11 .normalize("NFKD")
12 .replace(/[^\w\s-]/g, "")
13 .trim()
14 .replace(/[\s_-]+/g, "-")
15 .replace(/^-+|-+$/g, "");
16}
17
18export function formatCurrencyMillions(value?: number | null) {
19 if (value === undefined || value === null || Number.isNaN(value)) {
20 return "Undisclosed";
21 }
22
23 return `$${value.toFixed(2)}M`;
24}
25
26export function firstName(fullName?: string) {
27 if (!fullName) {
28 return undefined;
29 }
30
31 return fullName.split(/\s+/)[0];
32}
33
34export function quarterLabel(quarterId: string) {
35 return quarterId.replace("-", " ");
36}
37
38export function asArray(value: string | string[] | undefined) {
39 if (value === undefined) {
40 return [];
41 }
42
43 return Array.isArray(value) ? value : [value];
44}
45
46export function compareValues(a: string | number | null | undefined, b: string | number | null | undefined) {
47 if (typeof a === "number" && typeof b === "number") {
48 return a - b;
49 }
50
51 return String(a ?? "").localeCompare(String(b ?? ""), undefined, { sensitivity: "base" });
52}
53
54export function getPageNumbers(
55 currentPage: number,
56 totalPages: number
57): (number | '...')[] {
58 if (totalPages <= 7) {
59 return Array.from({ length: totalPages }, (_, i) => i + 1);
60 }
61 if (currentPage <= 4) {
62 return [1, 2, 3, 4, 5, '...', totalPages];
63 }
64 if (currentPage >= totalPages - 3) {
65 return [1, '...', totalPages - 4, totalPages - 3, totalPages - 2, totalPages - 1, totalPages];
66 }
67 return [1, '...', currentPage - 1, currentPage, currentPage + 1, '...', totalPages];
68}

What it pulls in

npm packages

  • clsx
  • tailwind-merge

Files it writes

  • src/lib/utils.ts

Facts

Registry
@cinatra-ai
Type
registry:lib
Access
Free
Files written
1
Licence
Apache-2.0
First indexed
2026-08-01
Last confirmed
yesterday

Go to the source

Docs on @cinatra-ai cinatra.ai cinatra-ai/cinatra on GitHub Raw registry item This item as JSON
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex