'use client';
import { useCallback } from 'react';
import { useStore } from 'zustand';
import type { OpenAPIClientContext } from './context';
import { getOrCreateStoreByKey } from './getOrCreateStoreByKey';
import { OpenAPIPath } from './OpenAPIPath';
import type { Key } from './OpenAPISelect';
import { OpenAPISelect, type OpenAPISelectItem } from './OpenAPISelect';
import { StaticSection } from './StaticSection';
import type { OpenAPIOperationData } from './types';
function useCodeSampleState(initialKey: Key = 'default') {
const store = useStore(getOrCreateStoreByKey('codesample', initialKey));
return {
key: store.key,
setKey: useCallback((key: Key) => store.setKey(key), [store.setKey]),
};
}
type CodeSampleItem = OpenAPISelectItem & {
body: React.ReactNode;
footer?: React.ReactNode;
};
function OpenAPICodeSampleHeader(props: {
items: CodeSampleItem[];
data: OpenAPIOperationData;
selectIcon?: React.ReactNode;
context: OpenAPIClientContext;
}) {
const { data, items, selectIcon, context } = props;
return (
<>