Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/packages/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@
"@vitest/ui": "catalog:",
"blob-polyfill": "^9.0.20240710",
"globals": "^17.7.0",
"rolldown": "^1.1.4",
"happy-dom": "catalog:",
"js-yaml": "^4.3.0",
"jsdom": "catalog:",
Expand All @@ -123,6 +122,7 @@
"postcss-prefix-selector": "^2.1.1",
"prettier": "^3.2.5",
"qs": "catalog:",
"rolldown": "^1.1.4",
"rollup-plugin-license": "^3.6.0",
"rollup-plugin-visualizer": "^5.12.0",
"storybook": "catalog:",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { Flex, Spinner } from '@nvidia/foundations-react-core';
import type { FC } from 'react';

/** Placeholder while a payload is too large to render immediately, or its renderer is loading. */
export const PayloadPending: FC = () => (
<Flex
align="center"
justify="center"
className="min-h-[160px] rounded-md border border-base bg-surface-raised p-density-xl"
>
<Spinner size="medium" aria-label="Rendering payload" />
</Flex>
);

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { Button, Flex, Tooltip } from '@nvidia/foundations-react-core';
import type {
SpanPayloadFormat,
SpanPayloadFormatState,
} from '@studio/components/IntakeDetail/IntakeComponents/spanPayloadFormat';
import { type FC, type MouseEvent } from 'react';

const FORMAT_OPTIONS: readonly { format: SpanPayloadFormat; label: string; name: string }[] = [
{ format: 'raw', label: 'raw', name: 'raw text' },
{ format: 'md', label: 'md', name: 'markdown' },
{ format: 'json', label: 'json', name: 'JSON' },
];

interface SpanPayloadFormatToggleProps {
state: SpanPayloadFormatState;
/** Names the payload in labels and tooltips, e.g. `input` → "View input as JSON". */
payloadLabel: string;
}

export const SpanPayloadFormatToggle: FC<SpanPayloadFormatToggleProps> = ({
state,
payloadLabel,
}) => {
if (state.isEmpty) {
return null;
}

// The trigger row is a <summary>; keep clicks from toggling/collapsing it.
const withoutToggle = (handler: () => void) => (event: MouseEvent) => {
event.preventDefault();
event.stopPropagation();
handler();
};

return (
<Flex align="center" gap="density-xs" className="shrink-0">
{FORMAT_OPTIONS.map(({ format, label, name }) => {
const unavailable = format === 'json' && !state.isJson;
const active = state.format === format;
const button = (
<Button
type="button"
size="tiny"
kind="tertiary"
className="font-mono"
color={active ? 'brand' : 'neutral'}
aria-label={`View ${payloadLabel} as ${name}`}
aria-pressed={active}
disabled={unavailable}
onClick={withoutToggle(() => state.select(format))}
>
{label}
</Button>
);
return (
<Tooltip
key={format}
side="top"
slotContent={unavailable ? `This ${payloadLabel} is not valid JSON` : `View as ${name}`}
>
{/* A disabled button fires no hover or focus events, so its
tooltip needs a focusable wrapper. */}
{unavailable ? <span tabIndex={0}>{button}</span> : button}
</Tooltip>
);
})}
</Flex>
);
};
Loading
Loading