MCPcopy
hub / github.com/vercel/chatbot / PureSpreadsheetEditor

Function PureSpreadsheetEditor

components/sheet-editor.tsx:22–131  ·  view source on GitHub ↗
({
  content,
  saveContent,
  status,
  isCurrentVersion,
}: SheetEditorProps)

Source from the content-addressed store, hash-verified

20const MIN_COLS = 26;
21
22const PureSpreadsheetEditor = ({
23 content,
24 saveContent,
25 status,
26 isCurrentVersion,
27}: SheetEditorProps) => {
28 const { resolvedTheme } = useTheme();
29
30 const parseData = useMemo(() => {
31 if (!content) return Array(MIN_ROWS).fill(Array(MIN_COLS).fill(''));
32 const result = parse<string[]>(content, { skipEmptyLines: true });
33
34 const paddedData = result.data.map((row) => {
35 const paddedRow = [...row];
36 while (paddedRow.length < MIN_COLS) {
37 paddedRow.push('');
38 }
39 return paddedRow;
40 });
41
42 while (paddedData.length < MIN_ROWS) {
43 paddedData.push(Array(MIN_COLS).fill(''));
44 }
45
46 return paddedData;
47 }, [content]);
48
49 const columns = useMemo(() => {
50 const rowNumberColumn = {
51 key: 'rowNumber',
52 name: '',
53 frozen: true,
54 width: 50,
55 renderCell: ({ rowIdx }: { rowIdx: number }) => rowIdx + 1,
56 cellClass: 'border-t border-r dark:bg-zinc-950 dark:text-zinc-50',
57 headerCellClass: 'border-t border-r dark:bg-zinc-900 dark:text-zinc-50',
58 };
59
60 const dataColumns = Array.from({ length: MIN_COLS }, (_, i) => ({
61 key: i.toString(),
62 name: String.fromCharCode(65 + i),
63 renderEditCell: textEditor,
64 width: 120,
65 cellClass: cn(`border-t dark:bg-zinc-950 dark:text-zinc-50`, {
66 'border-l': i !== 0,
67 }),
68 headerCellClass: cn(`border-t dark:bg-zinc-900 dark:text-zinc-50`, {
69 'border-l': i !== 0,
70 }),
71 }));
72
73 return [rowNumberColumn, ...dataColumns];
74 }, []);
75
76 const initialRows = useMemo(() => {
77 return parseData.map((row, rowIndex) => {
78 const rowData: any = {
79 id: rowIndex,

Callers

nothing calls this directly

Calls 1

cnFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…