BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/retab-ui/csv-source

CSV source adapter

retab-ui/csv-source
FreeComponent

Bridges the document-source model to the CSV viewer: csvAnchorToTarget and sourceToCsvCell for csv_cell anchors.

Install it

npx shadcn@latest add https://ui.retab.com/r/csv-source.json

Source

registry/new-york-v4/ui/csv-source.tsxui.retab.com/r/csv-source.json
1"use client";
2
3import * as React from "react";
4
5import type { Source, SourceAnchor } from "@/lib/document-source";
6import type {
7 CsvCellAddress,
8 CsvViewerHandle,
9} from "@/components/ui/csv-viewer";
10
11export interface SourceTarget {
12 scrollTo?: (source: Source, options: { behavior: ScrollBehavior }) => void;
13}
14
15/** Spreadsheet column letter → 0-based index ("A" → 0, "C" → 2, "AA" → 26). */
16export function columnLetterToIndex(letter: string): number | null {
17 if (!/^[A-Za-z]+$/.test(letter)) return null;
18 let n = 0;
19 for (const ch of letter.toUpperCase()) {
20 n = n * 26 + (ch.charCodeAt(0) - 64);
21 if (!Number.isSafeInteger(n)) return null;
22 }
23 return n - 1;
24}
25
26/**
27 * A `csv_cell` anchor → 0-based data coordinates. `row` is the 1-based data
28 * row (the header is not a data row); `column` is a letter.
29 */
30export function csvAnchorToTarget(anchor: SourceAnchor): CsvCellAddress | null {
31 if (anchor.kind === "csv_cell") {
32 const columnIndex = columnLetterToIndex(anchor.column);
33 if (
34 columnIndex == null ||
35 !Number.isInteger(anchor.row) ||
36 anchor.row < 1
37 ) {
38 return null;
39 }
40 return {
41 rowIndex: anchor.row - 1,
42 columnIndex,
43 };
44 }
45 return null;
46}
47
48/** A stable source target over a `CsvViewer` ref. */
49export function useCsvSourceTarget(
50 viewerRef: React.RefObject<CsvViewerHandle | null>,
51): SourceTarget {
52 return React.useMemo<SourceTarget>(
53 () => ({
54 scrollTo: (source: Source, options) => {
55 const target = csvAnchorToTarget(source.anchor);
56 if (target) viewerRef.current?.scrollToCell(target, options);
57 },
58 }),
59 [viewerRef],
60 );
61}
62
63/**
64 * The `activeCell` prop for `CsvViewer` derived from a source.
65 */
66export function sourceToCsvCell(
67 source: Source | undefined,
68): CsvCellAddress | null {
69 return source ? csvAnchorToTarget(source.anchor) : null;
70}

What it pulls in

Other registry items

  • @retab/csv-viewer
  • @retab/document-source

Files it writes

  • registry/new-york-v4/ui/csv-source.tsx

Facts

Registry
retab-ui
Type
registry:ui
Access
Free
Files written
1
Licence
NOASSERTION
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

ui.retab.com retab-dev/retab-ui on GitHub Raw registry item This item as JSON

More from retab-ui

All 130 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Alertalertretab-uiComponentsFree1 dep
Alert Dialogalert-dialogretab-uiComponentsFree1 dep
Aspect Ratioaspect-ratioretab-uiComponentsFreeno deps
Attachment Sidebarattachment-sidebarretab-uiComponentsFree1 dep
Autocompleteautocompleteretab-uiComponentsFree2 deps
Calendarcalendarretab-uiComponentsFree2 deps
Code Viewercode-viewerretab-uiComponentsFree2 deps · 32 files
Commandcommandretab-uiComponentsFree2 deps
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