From 67fcb8fabdb7706a130c05bb0ca2e5fd37f828ae Mon Sep 17 00:00:00 2001 From: TalexDreamSoul Date: Thu, 2 Jul 2026 07:46:36 -0700 Subject: [PATCH] fix: make kumo adapters server safe --- components/ui/card.tsx | 12 ++-- components/ui/table.tsx | 155 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 161 insertions(+), 6 deletions(-) diff --git a/components/ui/card.tsx b/components/ui/card.tsx index 81e332a..2b747b2 100644 --- a/components/ui/card.tsx +++ b/components/ui/card.tsx @@ -1,19 +1,21 @@ import * as React from "react"; -import { LayerCard } from "@cloudflare/kumo/components/layer-card"; import { cn } from "@/lib/utils"; export function Card({ className, ...props }: React.HTMLAttributes): React.ReactElement { return ( - ); } export function CardHeader({ className, ...props }: React.HTMLAttributes): React.ReactElement { - return ; + return
; } export function CardTitle({ className, ...props }: React.HTMLAttributes): React.ReactElement { @@ -25,5 +27,5 @@ export function CardDescription({ className, ...props }: React.HTMLAttributes): React.ReactElement { - return ; + return
; } diff --git a/components/ui/table.tsx b/components/ui/table.tsx index df3d47f..0a010f3 100644 --- a/components/ui/table.tsx +++ b/components/ui/table.tsx @@ -1 +1,154 @@ -export { Table, type KumoTableLayout, type KumoTableRowVariant } from "@cloudflare/kumo/components/table"; +import * as React from "react"; + +import { cn } from "@/lib/utils"; + +export type KumoTableLayout = "auto" | "fixed"; +export type KumoTableRowVariant = "default" | "selected"; + +type TableProps = React.TableHTMLAttributes & { + layout?: KumoTableLayout; +}; + +type TableHeaderProps = React.HTMLAttributes & { + sticky?: boolean; + variant?: "default" | "compact"; +}; + +type StickyColumn = "left" | "right"; + +type TableHeadProps = React.ThHTMLAttributes & { + sticky?: StickyColumn; +}; + +type TableRowProps = React.HTMLAttributes & { + variant?: KumoTableRowVariant; +}; + +type TableCellProps = React.TdHTMLAttributes & { + sticky?: StickyColumn; +}; + +function stickyClass(sticky?: StickyColumn): string | undefined { + if (sticky === "left") { + return "sticky left-0 z-10 bg-kumo-base"; + } + + if (sticky === "right") { + return "sticky right-0 z-10 bg-kumo-base"; + } + + return undefined; +} + +const TableRoot = React.forwardRef(function Table( + { className, layout = "auto", ...props }, + ref, +): React.ReactElement { + return ( + + ); +}); + +const TableHeader = React.forwardRef(function TableHeader( + { className, sticky, variant, ...props }, + ref, +): React.ReactElement { + return ( + + ); +}); + +const TableHead = React.forwardRef(function TableHead( + { className, sticky, ...props }, + ref, +): React.ReactElement { + return ( + ; + }, +); + +const TableRow = React.forwardRef(function TableRow( + { className, variant = "default", ...props }, + ref, +): React.ReactElement { + return ( + + ); +}); + +const TableCell = React.forwardRef(function TableCell( + { className, sticky, ...props }, + ref, +): React.ReactElement { + return ; + }, +); + +const TableResizeHandle = React.forwardRef>( + function TableResizeHandle({ className, type = "button", ...props }, ref): React.ReactElement { + return ( +
+ ); +}); + +const TableBody = React.forwardRef>( + function TableBody({ className, ...props }, ref): React.ReactElement { + return
; +}); + +const TableFooter = React.forwardRef>( + function TableFooter({ className, ...props }, ref): React.ReactElement { + return