import {
cloneElement,
useEffect,
type CSSProperties,
type ElementType,
type KeyboardEvent,
type ReactElement,
} from "react";
import { createPortal } from "react-dom";
import type { DesignSystemComponents } from "../../design-system/types.js";
const css = {
control: {
border: "1px solid rgb(80 80 90)",
borderRadius: 6,
background: "rgb(250 250 252)",
color: "rgb(20 20 24)",
padding: "6px 10px",
font: "inherit",
} satisfies CSSProperties,
overlay: {
position: "fixed",
inset: "20% auto auto 20%",
zIndex: 120,
border: "1px solid rgb(80 80 90)",
borderRadius: 8,
background: "white",
color: "black",
padding: 12,
} satisfies CSSProperties,
stack: {
display: "grid",
gap: 6,
} satisfies CSSProperties,
};
function portal(content: ReactElement, container?: Element | null) {
return container
? createPortal(content, container)
: createPortal(content, document.body);
}
export const cssInJsFixtureAdapter: DesignSystemComponents = {
ActionButton: ({
children,
leadingIcon,
trailingIcon,
pending,
disabled,
onPress,
elementRef,
style,
...props
}) => (
),
IconButton: ({
label,
icon,
pending,
disabled,
onPress,
elementRef,
style,
...props
}) => (
),
TextField: ({
value,
onChange,
label,
description,
errorMessage,
inputRef,
leadingContent,
trailingContent,
style,
onKeyDown,
...props
}) => (
),
TextArea: ({
value,
onChange,
label,
description,
errorMessage,
textAreaRef,
style,
onKeyDown,
...props
}) => (
),
Spinner: ({ label, size: _size, ...props }) => (
Loading
),
Skeleton: ({ width, height, shape: _shape, style, ...props }) => (
),
Status: ({ children, icon, tone: _tone, size: _size, ...props }) => (
{icon}
{children}
),
Surface: ({
children,
as = "div",
interactive,
onPress,
elevation: _elevation,
padding: _padding,
style,
...props
}) => {
const Element = as as ElementType;
return (
) : (
(fallback ?? name.slice(0, 2))
)}
),
Tooltip: ({
trigger,
content,
open,
defaultOpen,
disabled,
portalContainer,
}) => (
<>
{trigger}
{!disabled && (open ?? defaultOpen)
? portal(
{description}
: null} {children} {footer}