@clarify-labs/renderer 0.10.1 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/output/{OpenApiOperation-DK46w2dq.cjs → OpenApiOperation-B52IWlKb.cjs} +136 -48
- package/output/OpenApiOperation-B52IWlKb.cjs.map +1 -0
- package/output/{OpenApiOperation-CqNM-no4.js → OpenApiOperation-DgrqzeiS.js} +135 -48
- package/output/OpenApiOperation-DgrqzeiS.js.map +1 -0
- package/output/components/HighlightedCode.d.ts +7 -0
- package/output/index.cjs +15 -15
- package/output/index.cjs.map +1 -1
- package/output/index.d.ts +2 -2
- package/output/index.js +15 -16
- package/output/index.js.map +1 -1
- package/output/markdown.cjs +2 -1
- package/output/markdown.d.ts +1 -1
- package/output/markdown.js +2 -2
- package/output/mdx/remark.d.ts +1 -0
- package/output/openapi/components/ExamplePanels.d.ts +2 -1
- package/output/preview.cjs +1 -1
- package/output/preview.js +1 -1
- package/output/{remark-Dd2WU50s.js → remark-C9iRQM0R.js} +4 -3
- package/output/remark-C9iRQM0R.js.map +1 -0
- package/output/{remark-zSQT0MBv.cjs → remark-DTLbG8PK.cjs} +9 -2
- package/output/remark-DTLbG8PK.cjs.map +1 -0
- package/output/renderer.css +180 -20
- package/package.json +3 -1
- package/output/OpenApiOperation-CqNM-no4.js.map +0 -1
- package/output/OpenApiOperation-DK46w2dq.cjs.map +0 -1
- package/output/remark-Dd2WU50s.js.map +0 -1
- package/output/remark-zSQT0MBv.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as useConfig, s as useLocale, t as useBuiltInText } from "./i18n-DnqZHFT7.js";
|
|
2
2
|
import { C as isExternalHref, E as copyTextToClipboard, c as lucideIconRegistry, h as useTheme, l as resolveLucideIconName, n as PageTitleActions, o as useSectionStore, s as remToPx, w as localizeHref } from "./PageActions-D7K9LDGf.js";
|
|
3
|
-
import { t as markdownRemarkPlugins } from "./remark-
|
|
3
|
+
import { t as markdownRemarkPlugins } from "./remark-C9iRQM0R.js";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { Children, Suspense, createContext, createElement, forwardRef, isValidElement, lazy, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
6
6
|
import { Link } from "react-router-dom";
|
|
@@ -10,7 +10,9 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
import { motion, useInView } from "framer-motion";
|
|
11
11
|
import { create } from "zustand";
|
|
12
12
|
import ReactMarkdown from "react-markdown";
|
|
13
|
+
import rehypeRaw from "rehype-raw";
|
|
13
14
|
import { slug } from "github-slugger";
|
|
15
|
+
import { codeToTokens, createCssVariablesTheme } from "shiki";
|
|
14
16
|
import { snippetz } from "@scalar/snippetz";
|
|
15
17
|
//#region \0rolldown/runtime.js
|
|
16
18
|
var __defProp = Object.defineProperty;
|
|
@@ -335,6 +337,14 @@ function getNodeText(node) {
|
|
|
335
337
|
if (isValidElement(node)) return getNodeText(node.props.children);
|
|
336
338
|
return "";
|
|
337
339
|
}
|
|
340
|
+
function getCodeLanguage(node) {
|
|
341
|
+
if (!isValidElement(node)) return void 0;
|
|
342
|
+
const { className, language, children } = node.props;
|
|
343
|
+
if (language) return language;
|
|
344
|
+
const languageClass = className?.split(/\s+/).find((value) => value.startsWith("language-"));
|
|
345
|
+
if (languageClass) return languageClass.slice(9);
|
|
346
|
+
return Children.toArray(children).map(getCodeLanguage).find(Boolean);
|
|
347
|
+
}
|
|
338
348
|
function CopyButton(arg0) {
|
|
339
349
|
const { code } = arg0;
|
|
340
350
|
const t = useBuiltInText();
|
|
@@ -404,6 +414,7 @@ function CodeGroupHeader(arg0) {
|
|
|
404
414
|
const { title, children, selectedIndex } = arg0;
|
|
405
415
|
const t = useBuiltInText();
|
|
406
416
|
const hasTabs = Children.count(children) > 1;
|
|
417
|
+
const indicatorLayoutId = useId();
|
|
407
418
|
if (!title && !hasTabs) return null;
|
|
408
419
|
return /* @__PURE__ */ jsxs("div", {
|
|
409
420
|
className: "clarify-code-group-header flex min-h-(--clarify-code-header-min-height) flex-wrap items-start gap-x-4 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-4",
|
|
@@ -411,13 +422,22 @@ function CodeGroupHeader(arg0) {
|
|
|
411
422
|
className: "mr-auto pt-3 text-xs font-semibold text-(--clarify-code-text)",
|
|
412
423
|
children: title
|
|
413
424
|
}) : null, hasTabs ? /* @__PURE__ */ jsx(TabList, {
|
|
414
|
-
className: "clarify-code-tabs -mb-px flex gap-
|
|
415
|
-
children: Children.map(children, (child, childIndex) => /* @__PURE__ */
|
|
416
|
-
className: clsx("clarify-code-tab border-b py-3 transition data-selected:not-data-focus:outline-hidden", childIndex === selectedIndex ? "
|
|
417
|
-
children: getPanelTitle({
|
|
425
|
+
className: "clarify-code-tabs -mr-2 -mb-px flex gap-0 text-xs font-medium",
|
|
426
|
+
children: Children.map(children, (child, childIndex) => /* @__PURE__ */ jsxs(Tab, {
|
|
427
|
+
className: clsx("clarify-code-tab relative border-b border-transparent px-2 py-3 transition-colors hover:bg-(--clarify-code-control-background-hover) data-selected:not-data-focus:outline-hidden", childIndex === selectedIndex ? "text-(--clarify-code-accent-text)" : "text-(--clarify-code-control-text) hover:text-(--clarify-code-text)"),
|
|
428
|
+
children: [getPanelTitle({
|
|
418
429
|
...isValidElement(child) ? child.props : {},
|
|
419
430
|
fallbackTitle: t("actions.code")
|
|
420
|
-
})
|
|
431
|
+
}), childIndex === selectedIndex ? /* @__PURE__ */ jsx(motion.span, {
|
|
432
|
+
layoutId: indicatorLayoutId,
|
|
433
|
+
className: "absolute inset-x-2 bottom-0 h-0.5 rounded-full bg-(--clarify-code-accent-text)",
|
|
434
|
+
transition: {
|
|
435
|
+
type: "spring",
|
|
436
|
+
stiffness: 460,
|
|
437
|
+
damping: 34,
|
|
438
|
+
mass: .7
|
|
439
|
+
}
|
|
440
|
+
}) : null]
|
|
421
441
|
}))
|
|
422
442
|
}) : null]
|
|
423
443
|
});
|
|
@@ -529,7 +549,9 @@ function Code(arg0) {
|
|
|
529
549
|
function Pre(arg0) {
|
|
530
550
|
const { children, language, code, ...props } = arg0;
|
|
531
551
|
const isGrouped = useContext(CodeGroupContext);
|
|
532
|
-
|
|
552
|
+
const resolvedLanguage = language ?? getCodeLanguage(children);
|
|
553
|
+
const resolvedCode = code ?? getNodeText(children);
|
|
554
|
+
if (resolvedLanguage === "mermaid") return /* @__PURE__ */ jsx(Mermaid, { chart: resolvedCode });
|
|
533
555
|
if (isGrouped) return children;
|
|
534
556
|
return /* @__PURE__ */ jsx(CodeGroup, {
|
|
535
557
|
...props,
|
|
@@ -868,16 +890,17 @@ function Tabs(arg0) {
|
|
|
868
890
|
onChange: handleChange,
|
|
869
891
|
className,
|
|
870
892
|
children: [/* @__PURE__ */ jsx(TabList, {
|
|
871
|
-
className: clsx("flex flex-wrap items-center gap-
|
|
893
|
+
className: clsx("-mx-2 flex flex-wrap items-center gap-2 border-b border-(--clarify-theme-tokens-colors-border) px-2 pb-0", listClassName),
|
|
872
894
|
children: items.map((item) => /* @__PURE__ */ jsx(Tab, {
|
|
873
|
-
className: ({ selected }) => clsx("clarify-ui-tab relative inline-flex h-10 shrink-0 items-center px-
|
|
895
|
+
className: ({ selected }) => clsx("clarify-content-tab clarify-ui-tab relative inline-flex h-10 shrink-0 items-center rounded-t-md px-2 py-0 text-sm font-medium transition-colors focus:outline-none", selected && "clarify-ui-tab-active"),
|
|
874
896
|
children: ({ selected }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", { children: item.label }), selected ? /* @__PURE__ */ jsx(motion.span, {
|
|
875
897
|
layoutId: indicatorLayoutId,
|
|
876
|
-
className: "absolute inset-x-
|
|
898
|
+
className: "absolute inset-x-2 bottom-0 h-0.5 rounded-full bg-(--clarify-ui-tab-indicator) shadow-[0_0_0.5rem_var(--clarify-ui-accent-glow)]",
|
|
877
899
|
transition: {
|
|
878
|
-
type: "
|
|
879
|
-
|
|
880
|
-
|
|
900
|
+
type: "spring",
|
|
901
|
+
stiffness: 460,
|
|
902
|
+
damping: 34,
|
|
903
|
+
mass: .7
|
|
881
904
|
}
|
|
882
905
|
}) : null] })
|
|
883
906
|
}, item.id))
|
|
@@ -1132,6 +1155,7 @@ function Markdown(arg0) {
|
|
|
1132
1155
|
children: /* @__PURE__ */ jsx(ReactMarkdown, {
|
|
1133
1156
|
components: markdownComponents,
|
|
1134
1157
|
remarkPlugins: markdownRemarkPlugins,
|
|
1158
|
+
rehypePlugins: [rehypeRaw],
|
|
1135
1159
|
children
|
|
1136
1160
|
})
|
|
1137
1161
|
});
|
|
@@ -1393,8 +1417,72 @@ function listOpenApiOperations(spec) {
|
|
|
1393
1417
|
return [...listOperationsFromPathItems(paths, "path", spec), ...isRecord(webhooks) ? listOperationsFromPathItems(webhooks, "webhook", spec) : []];
|
|
1394
1418
|
}
|
|
1395
1419
|
//#endregion
|
|
1420
|
+
//#region source/components/HighlightedCode.tsx
|
|
1421
|
+
var cssVariablesTheme = createCssVariablesTheme();
|
|
1422
|
+
function HighlightedCode(arg0) {
|
|
1423
|
+
const { code, language } = arg0;
|
|
1424
|
+
const [lines, setLines] = useState();
|
|
1425
|
+
useEffect(() => {
|
|
1426
|
+
let active = true;
|
|
1427
|
+
codeToTokens(code, {
|
|
1428
|
+
lang: language,
|
|
1429
|
+
theme: cssVariablesTheme
|
|
1430
|
+
}).then((result) => {
|
|
1431
|
+
if (active) setLines(result.tokens);
|
|
1432
|
+
}).catch(() => {
|
|
1433
|
+
if (active) setLines(void 0);
|
|
1434
|
+
});
|
|
1435
|
+
return () => {
|
|
1436
|
+
active = false;
|
|
1437
|
+
};
|
|
1438
|
+
}, [code, language]);
|
|
1439
|
+
if (!lines) return /* @__PURE__ */ jsx("code", {
|
|
1440
|
+
className: `language-${language}`,
|
|
1441
|
+
children: code
|
|
1442
|
+
});
|
|
1443
|
+
return /* @__PURE__ */ jsx("code", {
|
|
1444
|
+
className: `language-${language}`,
|
|
1445
|
+
children: lines.map((line, lineIndex) => /* @__PURE__ */ jsxs("span", {
|
|
1446
|
+
className: "line",
|
|
1447
|
+
children: [line.map((token, tokenIndex) => /* @__PURE__ */ jsx("span", {
|
|
1448
|
+
style: {
|
|
1449
|
+
color: token.color,
|
|
1450
|
+
...token.htmlStyle
|
|
1451
|
+
},
|
|
1452
|
+
children: token.content
|
|
1453
|
+
}, tokenIndex)), lineIndex < lines.length - 1 ? "\n" : null]
|
|
1454
|
+
}, lineIndex))
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
//#endregion
|
|
1396
1458
|
//#region source/openapi/lib/request-code.ts
|
|
1459
|
+
var snippetControlCharacters = [
|
|
1460
|
+
{
|
|
1461
|
+
character: "\n",
|
|
1462
|
+
placeholder: "",
|
|
1463
|
+
escape: "\\n"
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
character: "\r",
|
|
1467
|
+
placeholder: "",
|
|
1468
|
+
escape: "\\r"
|
|
1469
|
+
},
|
|
1470
|
+
{
|
|
1471
|
+
character: " ",
|
|
1472
|
+
placeholder: "",
|
|
1473
|
+
escape: "\\t"
|
|
1474
|
+
}
|
|
1475
|
+
];
|
|
1397
1476
|
var snippetGenerator = snippetz();
|
|
1477
|
+
function protectSnippetControlCharacters(value) {
|
|
1478
|
+
if (typeof value === "string") return snippetControlCharacters.reduce((result, item) => result.replaceAll(item.character, item.placeholder), value);
|
|
1479
|
+
if (Array.isArray(value)) return value.map(protectSnippetControlCharacters);
|
|
1480
|
+
if (!isRecord$1(value)) return value;
|
|
1481
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, protectSnippetControlCharacters(item)]));
|
|
1482
|
+
}
|
|
1483
|
+
function restoreSnippetControlCharacters(code) {
|
|
1484
|
+
return snippetControlCharacters.reduce((result, item) => result.replaceAll(item.placeholder, item.escape), code);
|
|
1485
|
+
}
|
|
1398
1486
|
function getDefaultServer(spec) {
|
|
1399
1487
|
const servers = spec.servers;
|
|
1400
1488
|
if (!Array.isArray(servers)) return { url: "https://api.example.com" };
|
|
@@ -1462,7 +1550,7 @@ function getRequestBody(requestContent) {
|
|
|
1462
1550
|
const params = getFormParams(value, requestContent);
|
|
1463
1551
|
return params.length > 0 ? { params } : void 0;
|
|
1464
1552
|
}
|
|
1465
|
-
return { serialized: stringifyExample(value) };
|
|
1553
|
+
return { serialized: stringifyExample(protectSnippetControlCharacters(value)) };
|
|
1466
1554
|
}
|
|
1467
1555
|
function getAuthorizationValue(auth) {
|
|
1468
1556
|
if (auth.scheme.type === "http" && auth.scheme.scheme?.toLowerCase() === "bearer") return `Bearer ${auth.value}`;
|
|
@@ -1515,7 +1603,7 @@ function buildSnippetErrorMessage(error) {
|
|
|
1515
1603
|
}
|
|
1516
1604
|
function buildSnippet(input, target) {
|
|
1517
1605
|
try {
|
|
1518
|
-
return decodeUrlPlaceholders(snippetGenerator.print(target.target, target.client, buildHarRequest(input)) || "");
|
|
1606
|
+
return restoreSnippetControlCharacters(decodeUrlPlaceholders(snippetGenerator.print(target.target, target.client, buildHarRequest(input)) || ""));
|
|
1519
1607
|
} catch (error) {
|
|
1520
1608
|
return buildSnippetErrorMessage(error);
|
|
1521
1609
|
}
|
|
@@ -1824,7 +1912,7 @@ function SelectControl(arg0) {
|
|
|
1824
1912
|
className: wrapperClassName,
|
|
1825
1913
|
children: [/* @__PURE__ */ jsxs(ListboxButton, {
|
|
1826
1914
|
"aria-label": label,
|
|
1827
|
-
className: `clarify-api-select-button flex ${buttonSizeClassName} items-center justify-between gap-2 rounded-lg bg-(--clarify-code-control-background) px-2 py-1 text-xs font-medium whitespace-nowrap text-(--clarify-code-text) outline-hidden transition hover:bg-(--clarify-code-control-background-hover) focus:ring-2 focus:ring-(--clarify-ui-accent-border) data-open:bg-(--clarify-code-control-background-
|
|
1915
|
+
className: `clarify-api-select-button flex min-h-8 ${buttonSizeClassName} items-center justify-between gap-2 rounded-lg border border-(--clarify-code-border) bg-(--clarify-code-control-background) px-2.5 py-1 text-xs font-medium whitespace-nowrap text-(--clarify-code-text) outline-hidden transition hover:border-white/20 hover:bg-(--clarify-code-control-background-hover) focus:ring-2 focus:ring-(--clarify-ui-accent-border) data-open:border-white/20 data-open:bg-(--clarify-code-control-background-active) data-open:ring-2 data-open:ring-(--clarify-ui-accent-border)`,
|
|
1828
1916
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
1829
1917
|
className: "flex min-w-0 items-center gap-1.5 overflow-hidden",
|
|
1830
1918
|
children: [icon ? /* @__PURE__ */ jsx("span", {
|
|
@@ -1843,7 +1931,7 @@ function SelectControl(arg0) {
|
|
|
1843
1931
|
className: "clarify-api-select-options z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-xl bg-(--clarify-code-surface) p-1 text-xs shadow-lg shadow-black/20 ring-1 ring-(--clarify-code-border) [--anchor-gap:--spacing(1)] focus:outline-none",
|
|
1844
1932
|
children: normalizedOptions.map((option) => /* @__PURE__ */ jsxs(ListboxOption, {
|
|
1845
1933
|
value: option.value,
|
|
1846
|
-
className: "clarify-api-select-option group flex cursor-default items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-xs whitespace-nowrap text-(--clarify-code-
|
|
1934
|
+
className: "clarify-api-select-option group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-xs whitespace-nowrap text-(--clarify-code-control-text) select-none data-focus:bg-(--clarify-code-control-background-hover) data-focus:text-(--clarify-code-text) data-selected:bg-(--clarify-code-accent-background) data-selected:text-(--clarify-code-accent-text)",
|
|
1847
1935
|
children: [/* @__PURE__ */ jsx("span", { children: option.label }), /* @__PURE__ */ jsx(CheckIcon, {
|
|
1848
1936
|
className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
|
|
1849
1937
|
"aria-hidden": "true"
|
|
@@ -1868,7 +1956,7 @@ function CopyCodeButton(arg0) {
|
|
|
1868
1956
|
setTimeout(() => setCopied(false), 1e3);
|
|
1869
1957
|
});
|
|
1870
1958
|
},
|
|
1871
|
-
className: "flex items-center gap-1.5 rounded-full bg-(--clarify-code-control-background) px-2.5 py-1.5 text-2xs font-medium text-(--clarify-code-muted) transition hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus:bg-(--clarify-code-control-background-hover) focus:text-(--clarify-code-text)",
|
|
1959
|
+
className: "ml-auto flex shrink-0 items-center gap-1.5 rounded-full bg-(--clarify-code-control-background) px-2.5 py-1.5 text-2xs font-medium whitespace-nowrap text-(--clarify-code-muted) transition hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus:bg-(--clarify-code-control-background-hover) focus:text-(--clarify-code-text)",
|
|
1872
1960
|
children: [copied ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
1873
1961
|
className: "h-3.5 w-3.5 text-(--clarify-theme-tokens-colors-primary)",
|
|
1874
1962
|
"aria-hidden": "true"
|
|
@@ -1895,9 +1983,9 @@ function CodeToolbar(arg0) {
|
|
|
1895
1983
|
const { code, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
1896
1984
|
const t = useBuiltInText();
|
|
1897
1985
|
return /* @__PURE__ */ jsxs("div", {
|
|
1898
|
-
className: "
|
|
1986
|
+
className: "clarify-api-code-toolbar flex items-center gap-2 px-4 pt-3",
|
|
1899
1987
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
1900
|
-
className: "flex min-w-0 items-center gap-2",
|
|
1988
|
+
className: "clarify-api-code-toolbar-controls flex min-w-0 flex-1 flex-wrap items-center gap-2",
|
|
1901
1989
|
children: [languageOptions && languageOptions.length > 1 && selectedLanguageKey && onSelectLanguage ? /* @__PURE__ */ jsx(SelectControl, {
|
|
1902
1990
|
label: t("openapi.language"),
|
|
1903
1991
|
value: selectedLanguageKey,
|
|
@@ -2002,7 +2090,7 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
2002
2090
|
className: "mr-auto min-w-16 truncate py-1 text-xs font-semibold text-(--clarify-code-text)",
|
|
2003
2091
|
children: title
|
|
2004
2092
|
}), /* @__PURE__ */ jsxs("div", {
|
|
2005
|
-
className: "ml-auto flex min-w-0 items-center gap-2 whitespace-nowrap",
|
|
2093
|
+
className: "clarify-api-example-header-controls ml-auto flex min-w-0 items-center gap-2 whitespace-nowrap",
|
|
2006
2094
|
children: [mediaTypes && mediaTypes.length > 1 && selectedMediaType && onSelectMediaType ? /* @__PURE__ */ jsx(SelectControl, {
|
|
2007
2095
|
label: t("openapi.mediaType"),
|
|
2008
2096
|
value: selectedMediaType,
|
|
@@ -2042,7 +2130,7 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
2042
2130
|
]
|
|
2043
2131
|
}) : null,
|
|
2044
2132
|
/* @__PURE__ */ jsxs("div", {
|
|
2045
|
-
className: "clarify-api-example-code group
|
|
2133
|
+
className: "clarify-api-example-code group bg-(--clarify-code-background)",
|
|
2046
2134
|
children: [/* @__PURE__ */ jsx(CodeToolbar, {
|
|
2047
2135
|
code,
|
|
2048
2136
|
languageOptions,
|
|
@@ -2052,10 +2140,10 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
2052
2140
|
selectedClientKey,
|
|
2053
2141
|
onSelectClient
|
|
2054
2142
|
}), /* @__PURE__ */ jsx("pre", {
|
|
2055
|
-
className:
|
|
2056
|
-
children: /* @__PURE__ */ jsx(
|
|
2057
|
-
|
|
2058
|
-
|
|
2143
|
+
className: "max-h-128 overflow-auto overscroll-contain px-4 pt-3 pb-4 text-xs text-(--clarify-code-text)",
|
|
2144
|
+
children: /* @__PURE__ */ jsx(HighlightedCode, {
|
|
2145
|
+
code,
|
|
2146
|
+
language
|
|
2059
2147
|
})
|
|
2060
2148
|
})]
|
|
2061
2149
|
})
|
|
@@ -2159,6 +2247,9 @@ function RequestExamplesPanel(arg0) {
|
|
|
2159
2247
|
function firstExampleKeyForResponseContent(content, spec) {
|
|
2160
2248
|
return getExampleEntries(content?.value, spec)[0]?.key ?? "";
|
|
2161
2249
|
}
|
|
2250
|
+
function getResponseExampleBody(content, example) {
|
|
2251
|
+
return content ? stringifyExample(example?.value) : "";
|
|
2252
|
+
}
|
|
2162
2253
|
function useResponseExamplesState(arg0) {
|
|
2163
2254
|
const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2164
2255
|
const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
|
|
@@ -2169,8 +2260,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2169
2260
|
if (!Number.isNaN(leftCode) && !Number.isNaN(rightCode)) return leftCode - rightCode;
|
|
2170
2261
|
return left.status.localeCompare(right.status);
|
|
2171
2262
|
});
|
|
2172
|
-
const
|
|
2173
|
-
const [internalSelectedStatus, setInternalSelectedStatus] = useState(defaultStatus);
|
|
2263
|
+
const [internalSelectedStatus, setInternalSelectedStatus] = useState(orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "");
|
|
2174
2264
|
const activeStatus = selectedStatus ?? internalSelectedStatus;
|
|
2175
2265
|
const selectedResponse = orderedResponses.find(({ status }) => status === activeStatus) ?? orderedResponses[0];
|
|
2176
2266
|
const responseContents = getMediaTypeEntries(selectedResponse?.response.content, spec);
|
|
@@ -2196,7 +2286,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2196
2286
|
selectedContent,
|
|
2197
2287
|
examples,
|
|
2198
2288
|
selectedExample,
|
|
2199
|
-
|
|
2289
|
+
responseBody: getResponseExampleBody(selectedContent, selectedExample),
|
|
2200
2290
|
onSelectStatus: (value) => {
|
|
2201
2291
|
const nextContents = getMediaTypeEntries(orderedResponses.find(({ status }) => status === value)?.response.content, spec);
|
|
2202
2292
|
if (typeof selectedStatus === "undefined") setInternalSelectedStatus(value);
|
|
@@ -2235,18 +2325,14 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2235
2325
|
selectedStatus,
|
|
2236
2326
|
onSelectStatus
|
|
2237
2327
|
});
|
|
2238
|
-
if (!state.
|
|
2328
|
+
if (!state.selectedContent || !state.responseBody) return null;
|
|
2239
2329
|
return /* @__PURE__ */ jsx(ApiExampleCodeGroup, {
|
|
2240
2330
|
title: title ?? t("openapi.response"),
|
|
2241
|
-
tag: state.selectedResponse.status,
|
|
2242
|
-
tagOptions: state.responses.map(({ status }) => status),
|
|
2243
|
-
onSelectTag: state.onSelectStatus,
|
|
2244
2331
|
label: state.selectedContent?.mediaType,
|
|
2245
2332
|
labelOptions: state.responseContents.map((content) => content.mediaType),
|
|
2246
2333
|
onSelectLabel: state.responseContents.length > 0 ? state.onSelectMediaType : void 0,
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
language: state.selectedContent ? codeLanguageForMediaType(state.selectedContent.mediaType) : "http",
|
|
2334
|
+
code: state.responseBody,
|
|
2335
|
+
language: codeLanguageForMediaType(state.selectedContent.mediaType),
|
|
2250
2336
|
examples: state.examples,
|
|
2251
2337
|
selectedExampleKey: state.selectedExample?.key,
|
|
2252
2338
|
onSelectExample: state.onSelectExample
|
|
@@ -2505,7 +2591,7 @@ function SchemaNode(arg0) {
|
|
|
2505
2591
|
className: "*:first:mt-0 *:last:mb-0",
|
|
2506
2592
|
children: node.description
|
|
2507
2593
|
}) : fallbackDescription, node.details ? /* @__PURE__ */ jsx("p", {
|
|
2508
|
-
className: "text-xs text-(--clarify-ui-text-
|
|
2594
|
+
className: "text-xs text-(--clarify-ui-text-soft)",
|
|
2509
2595
|
children: node.details
|
|
2510
2596
|
}) : null]
|
|
2511
2597
|
})]
|
|
@@ -2521,7 +2607,7 @@ function SchemaNode(arg0) {
|
|
|
2521
2607
|
"aria-label": expanded ? t("openapi.collapse") : t("openapi.expand"),
|
|
2522
2608
|
"aria-expanded": expanded,
|
|
2523
2609
|
onClick: () => setExpanded((value) => !value),
|
|
2524
|
-
className: clsx(rowClassName, "cursor-pointer transition"),
|
|
2610
|
+
className: clsx(rowClassName, "cursor-pointer transition hover:bg-(--clarify-ui-hover-background) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)"),
|
|
2525
2611
|
children: content
|
|
2526
2612
|
}) : /* @__PURE__ */ jsx("div", {
|
|
2527
2613
|
className: rowClassName,
|
|
@@ -2589,10 +2675,10 @@ function ResponseList(arg0) {
|
|
|
2589
2675
|
children: [
|
|
2590
2676
|
/* @__PURE__ */ jsxs("div", {
|
|
2591
2677
|
className: "flex flex-wrap items-center gap-2",
|
|
2592
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
2678
|
+
children: [orderedResponses.length === 1 ? /* @__PURE__ */ jsx("span", {
|
|
2593
2679
|
className: "text-sm/5 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
|
|
2594
2680
|
children: status
|
|
2595
|
-
}), type ? /* @__PURE__ */ jsx("span", {
|
|
2681
|
+
}) : null, type ? /* @__PURE__ */ jsx("span", {
|
|
2596
2682
|
className: "text-xs text-(--clarify-theme-tokens-colors-muted)",
|
|
2597
2683
|
children: type
|
|
2598
2684
|
}) : null]
|
|
@@ -2845,7 +2931,7 @@ function EndpointPath(arg0) {
|
|
|
2845
2931
|
"aria-label": copied ? t("actions.copied") : t("actions.copy"),
|
|
2846
2932
|
title: copied ? t("actions.copied") : t("actions.copy"),
|
|
2847
2933
|
onClick: onCopy,
|
|
2848
|
-
className: clsx("flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) text-(--clarify-ui-text-soft) transition hover:border-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground)", copied && "border-emerald-400/70 bg-emerald-50 text-emerald-700 dark:bg-emerald-400/10 dark:text-emerald-200"),
|
|
2934
|
+
className: clsx("flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) text-(--clarify-ui-text-soft) transition hover:border-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", copied && "border-emerald-400/70 bg-emerald-50 text-emerald-700 dark:bg-emerald-400/10 dark:text-emerald-200"),
|
|
2849
2935
|
children: copied ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
2850
2936
|
className: "h-3.5 w-3.5",
|
|
2851
2937
|
"aria-hidden": "true"
|
|
@@ -2866,7 +2952,7 @@ function InlineListbox(arg0) {
|
|
|
2866
2952
|
className: "pointer-events-auto relative inline-flex min-w-0",
|
|
2867
2953
|
children: [/* @__PURE__ */ jsxs(ListboxButton, {
|
|
2868
2954
|
"aria-label": label,
|
|
2869
|
-
className: clsx("inline-flex min-w-0 items-center gap-1 rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) font-semibold text-(--clarify-
|
|
2955
|
+
className: clsx("inline-flex min-w-0 items-center gap-1 rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) font-semibold text-(--clarify-ui-text-strong) shadow-xs outline-hidden transition hover:border-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) data-open:border-(--clarify-ui-accent-border) data-open:bg-(--clarify-ui-active-background) data-open:ring-2 data-open:ring-(--clarify-ui-accent-border)", compact ? "min-h-7 max-w-32 px-2 py-0.5 text-xs" : "min-h-8 w-full px-2.5 py-1.5 text-xs"),
|
|
2870
2956
|
children: [/* @__PURE__ */ jsx("span", {
|
|
2871
2957
|
className: "truncate",
|
|
2872
2958
|
children: selected?.label ?? value
|
|
@@ -2879,7 +2965,7 @@ function InlineListbox(arg0) {
|
|
|
2879
2965
|
className: "z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-xl bg-(--clarify-theme-tokens-colors-surface) p-1 text-xs shadow-lg shadow-black/10 ring-1 ring-(--clarify-theme-tokens-colors-border) [--anchor-gap:--spacing(1)] focus:outline-none",
|
|
2880
2966
|
children: options.map((option) => /* @__PURE__ */ jsxs(ListboxOption, {
|
|
2881
2967
|
value: option.value,
|
|
2882
|
-
className: "group flex cursor-default items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-xs text-(--clarify-ui-text) select-none data-focus:bg-(--clarify-ui-hover-background) data-
|
|
2968
|
+
className: "group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-xs text-(--clarify-ui-text) select-none data-focus:bg-(--clarify-ui-hover-background) data-focus:text-(--clarify-ui-text-strong) data-selected:bg-(--clarify-ui-active-background) data-selected:text-(--clarify-ui-accent-text)",
|
|
2883
2969
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
2884
2970
|
className: "min-w-0",
|
|
2885
2971
|
children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -2926,7 +3012,7 @@ function ServerUrlValue(arg0) {
|
|
|
2926
3012
|
const protocolLabel = getServerProtocolLabel(server, variables);
|
|
2927
3013
|
if (!interactive) return /* @__PURE__ */ jsxs("span", {
|
|
2928
3014
|
"aria-label": "Server",
|
|
2929
|
-
className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text
|
|
3015
|
+
className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text) sm:w-auto sm:min-w-16 sm:max-w-(--clarify-server-url-max-width) sm:px-1.5",
|
|
2930
3016
|
children: [/* @__PURE__ */ jsx("span", {
|
|
2931
3017
|
className: "sm:hidden",
|
|
2932
3018
|
children: /* @__PURE__ */ jsx(ServerIcon, {
|
|
@@ -2949,7 +3035,7 @@ function ServerUrlValue(arg0) {
|
|
|
2949
3035
|
"aria-expanded": open,
|
|
2950
3036
|
"aria-label": "Server",
|
|
2951
3037
|
onClick: onToggle,
|
|
2952
|
-
className: clsx("flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text
|
|
3038
|
+
className: clsx("flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary) sm:w-auto sm:min-w-16 sm:max-w-(--clarify-server-url-max-width) sm:px-1.5", open ? "bg-(--clarify-ui-active-background) text-(--clarify-theme-tokens-colors-foreground)" : null),
|
|
2953
3039
|
children: [/* @__PURE__ */ jsx("span", {
|
|
2954
3040
|
className: "sm:hidden",
|
|
2955
3041
|
children: /* @__PURE__ */ jsx(ServerIcon, {
|
|
@@ -3068,7 +3154,8 @@ function AuthPanel(arg0) {
|
|
|
3068
3154
|
className: "mr-2 shrink-0 text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
3069
3155
|
children: selectedAuth.scheme.type === "apiKey" ? selectedAuth.scheme.in ?? "apiKey" : selectedAuth.scheme.scheme ?? selectedAuth.scheme.type ?? "token"
|
|
3070
3156
|
}), /* @__PURE__ */ jsx("input", {
|
|
3071
|
-
value: authValues[selectedAuth.name] ??
|
|
3157
|
+
value: authValues[selectedAuth.name] ?? "",
|
|
3158
|
+
placeholder: authPlaceholder(selectedAuth),
|
|
3072
3159
|
onChange: (event) => onChangeAuthValue(selectedAuth.name, event.target.value),
|
|
3073
3160
|
className: "min-w-0 flex-1 border-0 bg-transparent px-0 py-0 text-xs font-semibold text-(--clarify-theme-tokens-colors-foreground) outline-hidden placeholder:text-(--clarify-ui-text-faint)"
|
|
3074
3161
|
})]
|
|
@@ -3115,7 +3202,7 @@ function EndpointIdentity(arg0) {
|
|
|
3115
3202
|
"aria-expanded": authOpen,
|
|
3116
3203
|
"aria-label": "Auth",
|
|
3117
3204
|
onClick: onToggleAuth,
|
|
3118
|
-
className: clsx("ml-auto flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-(--clarify-ui-text-soft) transition hover:bg-(--clarify-ui-hover-background) hover:text-emerald-700 dark:hover:text-emerald-200", authOpen ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-400/15 dark:text-emerald-100" : "bg-(--clarify-ui-subtle-background)"),
|
|
3205
|
+
className: clsx("ml-auto flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-(--clarify-ui-text-soft) transition hover:bg-(--clarify-ui-hover-background) hover:text-emerald-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary) dark:hover:text-emerald-200", authOpen ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-400/15 dark:text-emerald-100" : "bg-(--clarify-ui-subtle-background)"),
|
|
3119
3206
|
children: authOpen ? /* @__PURE__ */ jsx(UnlockKeyholeIcon, {
|
|
3120
3207
|
className: "h-4 w-4",
|
|
3121
3208
|
"aria-hidden": "true"
|
|
@@ -3224,4 +3311,4 @@ function OpenApiOperation(arg0) {
|
|
|
3224
3311
|
//#endregion
|
|
3225
3312
|
export { CardGroup as A, Feedback as C, Pre as D, CodeGroup as E, Button as M, Mermaid as O, Tag as S, Code as T, Prose as _, authPlaceholder as a, Logo as b, getServerKey as c, listOpenApiOperations as d, getMediaTypeEntries as f, WebFrame as g, primitives_exports as h, ResponseExamplesPanel as i, Callout as j, Card as k, getServers as l, Markdown as m, OpenApiOperation as n, defaultServerVariables as o, getRequestBody$1 as p, RequestExamplesPanel as r, getAuthOptions as s, EndpointIdentity as t, getOpenApiOperationEntry as u, GridPattern as v, Collapse as w, Heading as x, HeroPattern as y };
|
|
3226
3313
|
|
|
3227
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
3314
|
+
//# sourceMappingURL=OpenApiOperation-DgrqzeiS.js.map
|