Restore Ultracite + fix sidebar (#1233)
This commit is contained in:
parent
8fbfc253fa
commit
947ed094a6
177 changed files with 6908 additions and 8306 deletions
|
|
@ -1,43 +1,37 @@
|
|||
import { Artifact } from '@/components/create-artifact';
|
||||
import { parse, unparse } from "papaparse";
|
||||
import { toast } from "sonner";
|
||||
import { Artifact } from "@/components/create-artifact";
|
||||
import {
|
||||
CopyIcon,
|
||||
LineChartIcon,
|
||||
RedoIcon,
|
||||
SparklesIcon,
|
||||
UndoIcon,
|
||||
} from '@/components/icons';
|
||||
import { SpreadsheetEditor } from '@/components/sheet-editor';
|
||||
import { parse, unparse } from 'papaparse';
|
||||
import { toast } from 'sonner';
|
||||
} from "@/components/icons";
|
||||
import { SpreadsheetEditor } from "@/components/sheet-editor";
|
||||
|
||||
type Metadata = any;
|
||||
|
||||
export const sheetArtifact = new Artifact<'sheet', Metadata>({
|
||||
kind: 'sheet',
|
||||
description: 'Useful for working with spreadsheets',
|
||||
initialize: async () => {},
|
||||
export const sheetArtifact = new Artifact<"sheet", Metadata>({
|
||||
kind: "sheet",
|
||||
description: "Useful for working with spreadsheets",
|
||||
initialize: () => null,
|
||||
onStreamPart: ({ setArtifact, streamPart }) => {
|
||||
if (streamPart.type === 'data-sheetDelta') {
|
||||
if (streamPart.type === "data-sheetDelta") {
|
||||
setArtifact((draftArtifact) => ({
|
||||
...draftArtifact,
|
||||
content: streamPart.data,
|
||||
isVisible: true,
|
||||
status: 'streaming',
|
||||
status: "streaming",
|
||||
}));
|
||||
}
|
||||
},
|
||||
content: ({
|
||||
content,
|
||||
currentVersionIndex,
|
||||
isCurrentVersion,
|
||||
onSaveContent,
|
||||
status,
|
||||
}) => {
|
||||
content: ({ content, currentVersionIndex, onSaveContent, status }) => {
|
||||
return (
|
||||
<SpreadsheetEditor
|
||||
content={content}
|
||||
currentVersionIndex={currentVersionIndex}
|
||||
isCurrentVersion={isCurrentVersion}
|
||||
isCurrentVersion={true}
|
||||
saveContent={onSaveContent}
|
||||
status={status}
|
||||
/>
|
||||
|
|
@ -46,9 +40,9 @@ export const sheetArtifact = new Artifact<'sheet', Metadata>({
|
|||
actions: [
|
||||
{
|
||||
icon: <UndoIcon size={18} />,
|
||||
description: 'View Previous version',
|
||||
description: "View Previous version",
|
||||
onClick: ({ handleVersionChange }) => {
|
||||
handleVersionChange('prev');
|
||||
handleVersionChange("prev");
|
||||
},
|
||||
isDisabled: ({ currentVersionIndex }) => {
|
||||
if (currentVersionIndex === 0) {
|
||||
|
|
@ -60,9 +54,9 @@ export const sheetArtifact = new Artifact<'sheet', Metadata>({
|
|||
},
|
||||
{
|
||||
icon: <RedoIcon size={18} />,
|
||||
description: 'View Next version',
|
||||
description: "View Next version",
|
||||
onClick: ({ handleVersionChange }) => {
|
||||
handleVersionChange('next');
|
||||
handleVersionChange("next");
|
||||
},
|
||||
isDisabled: ({ isCurrentVersion }) => {
|
||||
if (isCurrentVersion) {
|
||||
|
|
@ -74,44 +68,44 @@ export const sheetArtifact = new Artifact<'sheet', Metadata>({
|
|||
},
|
||||
{
|
||||
icon: <CopyIcon />,
|
||||
description: 'Copy as .csv',
|
||||
description: "Copy as .csv",
|
||||
onClick: ({ content }) => {
|
||||
const parsed = parse<string[]>(content, { skipEmptyLines: true });
|
||||
|
||||
const nonEmptyRows = parsed.data.filter((row) =>
|
||||
row.some((cell) => cell.trim() !== ''),
|
||||
row.some((cell) => cell.trim() !== "")
|
||||
);
|
||||
|
||||
const cleanedCsv = unparse(nonEmptyRows);
|
||||
|
||||
navigator.clipboard.writeText(cleanedCsv);
|
||||
toast.success('Copied csv to clipboard!');
|
||||
toast.success("Copied csv to clipboard!");
|
||||
},
|
||||
},
|
||||
],
|
||||
toolbar: [
|
||||
{
|
||||
description: 'Format and clean data',
|
||||
description: "Format and clean data",
|
||||
icon: <SparklesIcon />,
|
||||
onClick: ({ sendMessage }) => {
|
||||
sendMessage({
|
||||
role: 'user',
|
||||
role: "user",
|
||||
parts: [
|
||||
{ type: 'text', text: 'Can you please format and clean the data?' },
|
||||
{ type: "text", text: "Can you please format and clean the data?" },
|
||||
],
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
description: 'Analyze and visualize data',
|
||||
description: "Analyze and visualize data",
|
||||
icon: <LineChartIcon />,
|
||||
onClick: ({ sendMessage }) => {
|
||||
sendMessage({
|
||||
role: 'user',
|
||||
role: "user",
|
||||
parts: [
|
||||
{
|
||||
type: 'text',
|
||||
text: 'Can you please analyze and visualize the data by creating a new code artifact in python?',
|
||||
type: "text",
|
||||
text: "Can you please analyze and visualize the data by creating a new code artifact in python?",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue