Spaces:
Running
Running
File size: 4,604 Bytes
eb60b6b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | import type { ReactNode } from "react";
import {
Button,
CodeBlock,
PageHeader,
PageHeaderActions,
PageHeaderContent,
PageHeaderDescription,
PageHeaderTitle,
} from "lumen-ui-kit";
import { CloseIcon, Icon } from "lumen-ui-kit/icons";
export function InlineField({
id,
label,
children,
className = "",
}: {
id: string;
label: ReactNode;
children: ReactNode;
className?: string;
}) {
return (
<div
className={`flex min-w-0 flex-row flex-wrap items-center gap-2 ${className}`.trim()}
>
<label
htmlFor={id}
className="mb-0 shrink-0 whitespace-nowrap text-sm font-medium text-lumen-muted-foreground"
>
{label}
</label>
<div className="min-w-0 [&_[data-slot=input]]:h-9 [&_[data-slot=select]]:h-9 [&_input]:h-9 [&_select]:h-9">
{children}
</div>
</div>
);
}
export function HeaderActions({
children,
className = "",
}: {
children: ReactNode;
className?: string;
}) {
return (
<PageHeaderActions
className={`flex flex-wrap items-center gap-2 ${className}`.trim()}
>
{children}
</PageHeaderActions>
);
}
export function FilterBar({
children,
className = "",
}: {
children: ReactNode;
className?: string;
}) {
return (
<div
className={`flex flex-wrap items-center gap-2 ${className}`.trim()}
role="group"
>
{children}
</div>
);
}
export function Workbench({
title,
description,
actions,
toolbar,
children,
inspector,
flush = false,
}: {
title: ReactNode;
description?: ReactNode;
actions?: ReactNode;
toolbar?: ReactNode;
children: ReactNode;
inspector?: ReactNode;
flush?: boolean;
}) {
return (
<div className="flex min-h-0 flex-1 flex-col">
<div className={"mb-4 px-4 pt-6 sm:px-6"}>
<PageHeader className="sm:items-center">
<PageHeaderContent>
<PageHeaderTitle>{title}</PageHeaderTitle>
{description ? (
<PageHeaderDescription>{description}</PageHeaderDescription>
) : null}
</PageHeaderContent>
{actions ? <HeaderActions>{actions}</HeaderActions> : null}
</PageHeader>
{toolbar ? <div className="mt-4">{toolbar}</div> : null}
</div>
<div
className={
flush
? "flex min-h-0 flex-1 px-4 pb-4 sm:px-6"
: "mt-4 flex min-h-0 flex-1 gap-0 px-4 pb-6 sm:px-6"
}
>
<div
className={
flush
? "flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden"
: "min-h-0 min-w-0 flex-1 overflow-auto border border-lumen-border bg-lumen-surface"
}
>
{children}
</div>
{inspector}
</div>
</div>
);
}
export function DetailInspector({
title,
subtitle,
onClose,
children,
}: {
title: ReactNode;
subtitle?: ReactNode;
onClose: () => void;
children: ReactNode;
}) {
return (
<aside
className="flex w-full shrink-0 flex-col border-t border-lumen-border bg-lumen-surface xl:w-[var(--lumen-layout-rail-width)] xl:border-l xl:border-t-0"
aria-label="Record detail"
>
<div className="flex items-center justify-between gap-3 border-b border-lumen-border px-4 py-3">
<div className="min-w-0">
<h2 className="truncate text-sm font-semibold text-lumen-foreground">
{title}
</h2>
{subtitle ? (
<p className="mt-0.5 truncate font-mono text-[11px] text-lumen-muted-foreground">
{subtitle}
</p>
) : null}
</div>
<Button
type="button"
size="icon"
variant="ghost"
aria-label="Close detail panel"
onClick={onClose}
>
<Icon source={CloseIcon} />
</Button>
</div>
<div className="min-h-0 flex-1 overflow-auto p-4">{children}</div>
</aside>
);
}
export function JsonInspector({
title,
subtitle,
value,
onClose,
}: {
title: ReactNode;
subtitle?: ReactNode;
value: unknown;
onClose: () => void;
}) {
return (
<DetailInspector
title={title}
subtitle={subtitle}
onClose={onClose}
>
<CodeBlock className="text-[11px] leading-relaxed">
{JSON.stringify(value, null, 2)}
</CodeBlock>
</DetailInspector>
);
}
export function PageFrame({
children,
className = "",
}: {
children: ReactNode;
className?: string;
}) {
return (
<div className={`px-4 py-6 sm:px-6 ${className}`.trim()}>{children}</div>
);
}
|