TypeScript
Bump react-xlsx to 0.9.2
Andrew Luo2df0b855a699
diff --git a/apps/v4/app/globals.css b/apps/v4/app/globals.cssindex 8091491..00ce903 100644--- a/apps/v4/app/globals.css+++ b/apps/v4/app/globals.css@@ -93,7 +93,7 @@:root {--radius: 0.625rem;- --background: var(--color-white);+ --background: oklch(1 0 0);--foreground: var(--color-neutral-800);--card: var(--color-white);--card-foreground: var(--color-neutral-800);@@ -150,11 +150,7 @@}.dark {- --background: color-mix(- in srgb,- var(--color-neutral-950) 95%,- var(--color-white)- );+ --background: oklch(0.145 0 0);--foreground: var(--color-neutral-100);--card: color-mix(in srgb, var(--background) 98%, var(--color-white));--card-foreground: var(--color-neutral-100);@@ -309,7 +305,8 @@counter-increment: step;&:before {- @apply mr-2 inline-flex size-6 items-center justify-center rounded-full border-background bg-muted text-center -indent-px font-mono text-sm font-medium md:absolute md:mt-[-4px] md:ml-[-50px] md:size-9 md:border-4;+ @apply mr-2 inline-flex size-6 items-center justify-center rounded-full border-background bg-background text-center -indent-px font-mono text-sm font-medium md:absolute md:mt-[-4px] md:ml-[-50px] md:size-9 md:border-4;+ box-shadow: inset 0 0 0 9999px var(--muted);content: counter(step);}}diff --git a/apps/v4/components/human-review-docs.tsx b/apps/v4/components/human-review-docs.tsxindex 95ff113..8ad0c6f 100644--- a/apps/v4/components/human-review-docs.tsx+++ b/apps/v4/components/human-review-docs.tsx@@ -29,6 +29,7 @@ import { HugeiconsIcon } from "@hugeicons/react"import { MultiFileDiff, Virtualizer } from "@pierre/diffs/react"import { cn } from "@/lib/utils"+import { useMounted } from "@/hooks/use-mounted"import { Button } from "@/components/ui/button"import { PDFViewer, type PDFViewerHandle } from "@/components/ui/pdf-viewer"import { ScrollArea } from "@/components/ui/scroll-area"@@ -799,6 +800,7 @@ function HumanReviewArrayValueGrid({const rows = getArrayValue(value)const itemSchema = getArrayItemSchema(schema)const gridTheme = useHumanReviewGridTheme()+ const isMounted = useMounted()const isDark = useIsDarkTheme()const [localNestedStack, setLocalNestedStack] = React.useState<ArrayNestedView[]@@ -1170,25 +1172,29 @@ function HumanReviewArrayValueGrid({<span>{rows.length} rows</span></div><div className="h-[220px]">- <DataEditor- columns={columns}- rows={rows.length}- getCellContent={getCellContent}- cellActivationBehavior="double-click"- drawCell={drawCell}- gridSelection={gridSelection}- onCellEdited={updateCellValue}- onCellActivated={openNestedCell}- onGridSelectionChange={handleGridSelectionChange}- rowMarkers="number"- smoothScrollX- smoothScrollY- theme={gridTheme}- width="100%"- height="100%"- rowHeight={32}- headerHeight={34}- />+ {isMounted ? (+ <DataEditor+ columns={columns}+ rows={rows.length}+ getCellContent={getCellContent}+ cellActivationBehavior="double-click"+ drawCell={drawCell}+ gridSelection={gridSelection}+ onCellEdited={updateCellValue}+ onCellActivated={openNestedCell}+ onGridSelectionChange={handleGridSelectionChange}+ rowMarkers="number"+ smoothScrollX+ smoothScrollY+ theme={gridTheme}+ width="100%"+ height="100%"+ rowHeight={32}+ headerHeight={34}+ />+ ) : (+ <div className="h-full bg-muted/20" />+ )}</div></div>{activeNestedView ? (diff --git a/apps/v4/components/pdf-viewer-blocks.tsx b/apps/v4/components/pdf-viewer-blocks.tsxindex 7e9d21e..ce75287 100644--- a/apps/v4/components/pdf-viewer-blocks.tsx+++ b/apps/v4/components/pdf-viewer-blocks.tsx@@ -21,6 +21,7 @@ import {import type { ImperativePanelHandle } from "react-resizable-panels"import { siteConfig } from "@/lib/config"+import { useMounted } from "@/hooks/use-mounted"import { Button } from "@/components/ui/button"import {ResizableHandle,@@ -230,6 +231,7 @@ function PdfViewerBlockPreview({const [activeFile, setActiveFile] = React.useState<string | null>(codeSamples[0]?.targetPath ?? null)+ const isMounted = useMounted()const previewPanelRef = React.useRef<ImperativePanelHandle>(null)const Preview = block.componentconst activeCodeSample =@@ -363,7 +365,11 @@ function PdfViewerBlockPreview({minSize={30}className="min-w-0 overflow-hidden rounded-xl bg-background">- <Preview key={previewKey} />+ {isMounted ? (+ <Preview key={previewKey} />+ ) : (+ <BlockPreviewPlaceholder />+ )}</ResizablePanel><ResizableHandle className="relative w-3 bg-transparent p-0 after:absolute after:top-1/2 after:right-0 after:h-8 after:w-1.5 after:-translate-y-1/2 after:rounded-full after:bg-border after:transition-all after:hover:h-10" /><ResizablePanel defaultSize={0} minSize={0} />@@ -378,7 +384,11 @@ function PdfViewerBlockPreview({)}{view === "preview" ? (<div className="overflow-hidden rounded-xl border bg-background md:hidden">- <Preview key={previewKey} />+ {isMounted ? (+ <Preview key={previewKey} />+ ) : (+ <BlockPreviewPlaceholder />+ )}</div>) : null}</div>@@ -386,6 +396,10 @@ function PdfViewerBlockPreview({)}+function BlockPreviewPlaceholder() {+ return <div className="h-full min-h-[560px] bg-muted/20" />+}+function BlockCodePanel({codeSamples,activeFile,diff --git a/apps/v4/components/ui/xlsx-viewer.tsx b/apps/v4/components/ui/xlsx-viewer.tsxindex ce2eb67..ff5230a 100644--- a/apps/v4/components/ui/xlsx-viewer.tsx+++ b/apps/v4/components/ui/xlsx-viewer.tsx@@ -431,6 +431,12 @@ const WorkbookSheetTabsInner = React.memo(function WorkbookSheetTabsInner({left: 0,top: 0,})+ const { thumbnails } = useXlsxViewerThumbnails(+ XLSX_SHEET_TAB_THUMBNAIL_OPTIONS+ )+ const [thumbnailUrls, setThumbnailUrls] = React.useState<+ Record<number, string>+ >({})const scrollRef = React.useRef<HTMLDivElement | null>(null)const itemRefs = React.useRef<Record<number, HTMLButtonElement | null>>({})const openTimeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(@@ -530,8 +536,28 @@ const WorkbookSheetTabsInner = React.memo(function WorkbookSheetTabsInner({clearCloseTimeout()setVisiblePreviewIndex(null)setPreviewPosition({ left: 0, top: 0 })+ setThumbnailUrls({})}, [clearCloseTimeout, clearOpenTimeout, workbookIdentity])+ React.useEffect(() => {+ thumbnails.forEach((thumbnail) => {+ setThumbnailUrls((current) => {+ if (current[thumbnail.sheetIndex]) return current++ const canvas = document.createElement("canvas")+ canvas.width = thumbnail.width+ canvas.height = thumbnail.height++ if (!thumbnail.paint(canvas)) return current++ return {+ ...current,+ [thumbnail.sheetIndex]: canvas.toDataURL("image/png"),+ }+ })+ })+ }, [thumbnails])+React.useEffect(() => {if (visiblePreviewIndex === null) return@@ -554,6 +580,10 @@ const WorkbookSheetTabsInner = React.memo(function WorkbookSheetTabsInner({const previewSheet =visiblePreviewIndex === null ? null : sheets[visiblePreviewIndex]+ const previewUrl =+ visiblePreviewIndex === null+ ? null+ : (thumbnailUrls[visiblePreviewIndex] ?? null)return (<div@@ -593,7 +623,8 @@ const WorkbookSheetTabsInner = React.memo(function WorkbookSheetTabsInner({</Tabs>{typeof document !== "undefined" &&previewSheet &&- visiblePreviewIndex !== null+ visiblePreviewIndex !== null &&+ previewUrl? createPortal(<divclassName="pointer-events-none fixed z-[2147483647] translate-y-0 overflow-hidden rounded-lg border bg-background/95 opacity-100 shadow-xl backdrop-blur-md transition-[opacity,transform] duration-100"@@ -604,9 +635,11 @@ const WorkbookSheetTabsInner = React.memo(function WorkbookSheetTabsInner({}}><div className="relative aspect-[11/7] w-full overflow-hidden bg-muted/60">- <WorkbookSheetTabPreview- key={`${workbookIdentity}-${visiblePreviewIndex}`}- sheetIndex={visiblePreviewIndex}+ <img+ key={`${workbookIdentity}-${visiblePreviewIndex}-${previewUrl}`}+ src={previewUrl}+ alt={`${previewSheet.name} preview`}+ className="absolute inset-0 h-full w-full object-cover object-left-top"/></div></div>,@@ -617,46 +650,6 @@ const WorkbookSheetTabsInner = React.memo(function WorkbookSheetTabsInner({)})-function WorkbookSheetTabPreview({ sheetIndex }: { sheetIndex: number }) {- const { thumbnails } = useXlsxViewerThumbnails(- XLSX_SHEET_TAB_THUMBNAIL_OPTIONS- )- const canvasRef = React.useRef<HTMLCanvasElement | null>(null)- const [isPainted, setIsPainted] = React.useState(false)- const thumbnail = thumbnails.find(- (candidate) => candidate.sheetIndex === sheetIndex- )-- React.useEffect(() => {- setIsPainted(false)-- if (!thumbnail || !canvasRef.current) return-- canvasRef.current.width = thumbnail.width- canvasRef.current.height = thumbnail.height- setIsPainted(thumbnail.paint(canvasRef.current))- }, [thumbnail])-- return (- <>- {thumbnail ? (- <canvas- ref={canvasRef}- className={cn(- "absolute inset-0 size-full object-cover object-left-top transition-opacity duration-100",- isPainted ? "opacity-100" : "opacity-0"- )}- />- ) : null}- {!isPainted ? (- <div className="absolute inset-0 grid place-items-center">- <Spinner className="size-4 text-muted-foreground" />- </div>- ) : null}- </>- )-}-export function XlsxWorkbookSurface({className,isDark,diff --git a/apps/v4/components/xlsx-viewer-docs.tsx b/apps/v4/components/xlsx-viewer-docs.tsxindex 8a39f91..2843d39 100644--- a/apps/v4/components/xlsx-viewer-docs.tsx+++ b/apps/v4/components/xlsx-viewer-docs.tsx@@ -509,6 +509,12 @@ const WorkbookSheetTabsInner = React.memo(function WorkbookSheetTabsInner({left: 0,top: 0,})+ const { thumbnails } = useXlsxViewerThumbnails(+ XLSX_SHEET_TAB_THUMBNAIL_OPTIONS+ )+ const [thumbnailUrls, setThumbnailUrls] = React.useState<+ Record<number, string>+ >({})const scrollRef = React.useRef<HTMLDivElement | null>(null)const itemRefs = React.useRef<Record<number, HTMLButtonElement | null>>({})const openTimeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(@@ -608,8 +614,28 @@ const WorkbookSheetTabsInner = React.memo(function WorkbookSheetTabsInner({clearCloseTimeout()setVisiblePreviewIndex(null)setPreviewPosition({ left: 0, top: 0 })+ setThumbnailUrls({})}, [clearCloseTimeout, clearOpenTimeout, workbookIdentity])+ React.useEffect(() => {+ thumbnails.forEach((thumbnail) => {+ setThumbnailUrls((current) => {+ if (current[thumbnail.sheetIndex]) return current++ const canvas = document.createElement("canvas")+ canvas.width = thumbnail.width+ canvas.height = thumbnail.height++ if (!thumbnail.paint(canvas)) return current++ return {+ ...current,+ [thumbnail.sheetIndex]: canvas.toDataURL("image/png"),+ }+ })+ })+ }, [thumbnails])+React.useEffect(() => {if (visiblePreviewIndex === null) return@@ -632,6 +658,8 @@ const WorkbookSheetTabsInner = React.memo(function WorkbookSheetTabsInner({const previewSheet =visiblePreviewIndex === null ? null : sheets[visiblePreviewIndex]+ const previewUrl =+ visiblePreviewIndex === null ? null : (thumbnailUrls[visiblePreviewIndex] ?? null)return (<div@@ -671,7 +699,8 @@ const WorkbookSheetTabsInner = React.memo(function WorkbookSheetTabsInner({</Tabs>{typeof document !== "undefined" &&previewSheet &&- visiblePreviewIndex !== null+ visiblePreviewIndex !== null &&+ previewUrl? createPortal(<divclassName="pointer-events-none fixed z-[2147483647] translate-y-0 overflow-hidden rounded-lg border bg-background/95 opacity-100 shadow-xl backdrop-blur-md transition-[opacity,transform] duration-100"@@ -682,9 +711,11 @@ const WorkbookSheetTabsInner = React.memo(function WorkbookSheetTabsInner({}}><div className="relative aspect-[11/7] w-full overflow-hidden bg-muted/60">- <WorkbookSheetTabPreview- key={\`\${workbookIdentity}-\${visiblePreviewIndex}\`}- sheetIndex={visiblePreviewIndex}+ <img+ key={\`\${workbookIdentity}-\${visiblePreviewIndex}-\${previewUrl}\`}+ src={previewUrl}+ alt={\`\${previewSheet.name} preview\`}+ className="absolute inset-0 h-full w-full object-cover object-left-top"/></div></div>,@@ -695,46 +726,6 @@ const WorkbookSheetTabsInner = React.memo(function WorkbookSheetTabsInner({)})-function WorkbookSheetTabPreview({ sheetIndex }: { sheetIndex: number }) {- const { thumbnails } = useXlsxViewerThumbnails(- XLSX_SHEET_TAB_THUMBNAIL_OPTIONS- )- const canvasRef = React.useRef<HTMLCanvasElement | null>(null)- const [isPainted, setIsPainted] = React.useState(false)- const thumbnail = thumbnails.find(- (candidate) => candidate.sheetIndex === sheetIndex- )-- React.useEffect(() => {- setIsPainted(false)-- if (!thumbnail || !canvasRef.current) return-- canvasRef.current.width = thumbnail.width- canvasRef.current.height = thumbnail.height- setIsPainted(thumbnail.paint(canvasRef.current))- }, [thumbnail])-- return (- <>- {thumbnail ? (- <canvas- ref={canvasRef}- className={cn(- "absolute inset-0 size-full object-cover object-left-top transition-opacity duration-100",- isPainted ? "opacity-100" : "opacity-0"- )}- />- ) : null}- {!isPainted ? (- <div className="absolute inset-0 grid place-items-center">- <Spinner className="size-4 text-muted-foreground" />- </div>- ) : null}- </>- )-}-export function XlsxWorkbookSurface({className,isDark,diff --git a/apps/v4/package.json b/apps/v4/package.jsonindex e542668..97f2460 100644--- a/apps/v4/package.json+++ b/apps/v4/package.json@@ -23,7 +23,7 @@"@dnd-kit/sortable": "^10.0.0","@dnd-kit/utilities": "^3.2.2","@extend-ai/react-docx": "^0.6.6",- "@extend-ai/react-xlsx": "^0.9.1",+ "@extend-ai/react-xlsx": "^0.9.2","@glideapps/glide-data-grid": "6.0.4-alpha24","@hugeicons/core-free-icons": "^4.1.1","@hugeicons/react": "^1.1.6",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex a6f873e..760d10a 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -34,8 +34,8 @@ importers:specifier: ^0.6.6'@extend-ai/react-xlsx':- specifier: ^0.9.1+ specifier: ^0.9.2'@glideapps/glide-data-grid':specifier: 6.0.4-alpha24version: 6.0.4-alpha24([email protected])([email protected])([email protected]([email protected]))([email protected])([email protected])@@ -839,8 +839,8 @@ packages:react: '>=18'react-dom: '>=18'- '@extend-ai/[email protected]':- resolution: {integrity: sha512-fYHnwFQTx1A196mfrtLfrN/fcZybCY33Sge6vNFAB2fDBrpJkTkksEcxgq8CJT7nRP4Hc7EaTq2CHiTCUU2qGw==}+ '@extend-ai/[email protected]':+ resolution: {integrity: sha512-I/rZitA3UJIcw19n5FNUyIWhj0xZgTAHLfavS57hZq62RGLovlaLHAKrUlkbko5KSBTONKGx1HQQ9rEwJSjQlA==}peerDependencies:react: '>=18'react-dom: '>=18'@@ -5735,7 +5735,7 @@ snapshots:react-dom: 19.2.3([email protected])utif: 3.1.0dependencies:'@dukelib/sheets-wasm': 0.1.13