@clarify-labs/renderer 0.9.2 → 0.9.3

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.
Files changed (39) hide show
  1. package/output/{ClarifyShell-C38EkErX.js → ClarifyShell-BQ29N8P5.js} +26 -4
  2. package/output/ClarifyShell-BQ29N8P5.js.map +1 -0
  3. package/output/{ClarifyShell-DdYRgrfY.cjs → ClarifyShell-Dm--LZco.cjs} +27 -5
  4. package/output/ClarifyShell-Dm--LZco.cjs.map +1 -0
  5. package/output/{OpenApiOperation-DIFaYAe5.js → OpenApiOperation-C9xyRo5a.js} +293 -113
  6. package/output/OpenApiOperation-C9xyRo5a.js.map +1 -0
  7. package/output/{OpenApiOperation-CP_fxT_F.cjs → OpenApiOperation-DIWGdw29.cjs} +291 -111
  8. package/output/OpenApiOperation-DIWGdw29.cjs.map +1 -0
  9. package/output/{PageActions-tmnpzi23.js → PageActions-B_tSec1f.js} +6 -24
  10. package/output/PageActions-B_tSec1f.js.map +1 -0
  11. package/output/{PageActions-B08cDCzq.cjs → PageActions-DEuFHgyB.cjs} +5 -29
  12. package/output/PageActions-DEuFHgyB.cjs.map +1 -0
  13. package/output/client.cjs +3 -3
  14. package/output/client.js +3 -3
  15. package/output/components/Tabs.d.ts +16 -0
  16. package/output/components/index.d.ts +1 -0
  17. package/output/core/i18n.d.ts +1 -1
  18. package/output/index.cjs +4 -4
  19. package/output/index.js +4 -4
  20. package/output/openapi/components/EndpointSections.d.ts +2 -0
  21. package/output/openapi/components/ExamplePanels.d.ts +2 -0
  22. package/output/openapi/components/OpenApiOperation.d.ts +6 -0
  23. package/output/openapi/components/SchemaProperties.d.ts +2 -0
  24. package/output/preview.cjs +2 -2
  25. package/output/preview.js +2 -2
  26. package/output/{render-Bvf5ZMZb.cjs → render-BCGK1WpS.cjs} +2 -2
  27. package/output/{render-Bvf5ZMZb.cjs.map → render-BCGK1WpS.cjs.map} +1 -1
  28. package/output/{render-6gHfrR9h.js → render-CEWLJSmt.js} +2 -2
  29. package/output/{render-6gHfrR9h.js.map → render-CEWLJSmt.js.map} +1 -1
  30. package/output/renderer.css +43 -1
  31. package/output/server.cjs +2 -2
  32. package/output/server.js +2 -2
  33. package/package.json +1 -1
  34. package/output/ClarifyShell-C38EkErX.js.map +0 -1
  35. package/output/ClarifyShell-DdYRgrfY.cjs.map +0 -1
  36. package/output/OpenApiOperation-CP_fxT_F.cjs.map +0 -1
  37. package/output/OpenApiOperation-DIFaYAe5.js.map +0 -1
  38. package/output/PageActions-B08cDCzq.cjs.map +0 -1
  39. package/output/PageActions-tmnpzi23.js.map +0 -1
@@ -1,12 +1,12 @@
1
- import { D as copyTextToClipboard, M as useConfig, N as useLocale, O as useBuiltInText, T as localizeHref, c as remToPx, g as useTheme, l as lucideIconRegistry, n as PageTitleActions, s as useSectionStore, u as resolveLucideIconName, w as isExternalHref } from "./PageActions-tmnpzi23.js";
1
+ import { C as isExternalHref, D as useBuiltInText, E as copyTextToClipboard, M as useLocale, c as lucideIconRegistry, h as useTheme, j as useConfig, l as resolveLucideIconName, n as PageTitleActions, o as useSectionStore, s as remToPx, w as localizeHref } from "./PageActions-B_tSec1f.js";
2
2
  import { t as markdownRemarkPlugins } from "./remark-Dd2WU50s.js";
3
3
  import clsx from "clsx";
4
4
  import { Children, createContext, createElement, forwardRef, isValidElement, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
5
5
  import { Link } from "react-router-dom";
6
6
  import { Listbox, ListboxButton, ListboxOption, ListboxOptions, Tab, TabGroup, TabList, TabPanel, TabPanels, Transition } from "@headlessui/react";
7
- import { AlertTriangle, ArrowRight, Check, CheckCircle2, CheckIcon, ChevronDown, ChevronDownIcon, ChevronRight, ChevronsUpDownIcon, CircleCheck, Clipboard, ClipboardIcon, CodeIcon, Info, Lightbulb, LinkIcon, LockKeyholeIcon, Maximize2, PackageIcon, ServerIcon, UnlockKeyholeIcon, XCircle, ZoomIn, ZoomOut } from "lucide-react";
7
+ import { AlertTriangle, ArrowRight, Check, CheckCircle2, CheckIcon, ChevronDown, ChevronDownIcon, ChevronRight, ChevronsUpDownIcon, CircleCheck, Clipboard, ClipboardIcon, CodeIcon, CopyIcon, Info, Lightbulb, LinkIcon, LockKeyholeIcon, Maximize2, PackageIcon, ServerIcon, UnlockKeyholeIcon, XCircle, ZoomIn, ZoomOut } from "lucide-react";
8
8
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
- import { useInView } from "framer-motion";
9
+ import { motion, useInView } from "framer-motion";
10
10
  import { create } from "zustand";
11
11
  import { TransformComponent, TransformWrapper, useControls } from "react-zoom-pan-pinch";
12
12
  import ReactMarkdown from "react-markdown";
@@ -915,6 +915,44 @@ function Prose(arg0) {
915
915
  });
916
916
  }
917
917
  //#endregion
918
+ //#region source/components/Tabs.tsx
919
+ function Tabs(arg0) {
920
+ const { items, selectedIndex, onChange, className, listClassName, panelsClassName } = arg0;
921
+ const [internalIndex, setInternalIndex] = useState(0);
922
+ const resolvedIndex = typeof selectedIndex === "number" ? selectedIndex : internalIndex;
923
+ const indicatorLayoutId = useId();
924
+ const handleChange = (index) => {
925
+ if (typeof selectedIndex !== "number") setInternalIndex(index);
926
+ onChange?.(index);
927
+ };
928
+ return /* @__PURE__ */ jsxs(TabGroup, {
929
+ selectedIndex: resolvedIndex,
930
+ onChange: handleChange,
931
+ className,
932
+ children: [/* @__PURE__ */ jsx(TabList, {
933
+ className: clsx("flex flex-wrap items-center gap-6 border-b border-(--clarify-theme-tokens-colors-border) pb-0", listClassName),
934
+ children: items.map((item) => /* @__PURE__ */ jsx(Tab, {
935
+ className: ({ selected }) => clsx("clarify-ui-tab relative inline-flex h-10 shrink-0 items-center px-0 py-0 text-sm font-medium transition focus:outline-none", selected && "clarify-ui-tab-active"),
936
+ children: ({ selected }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", { children: item.label }), selected ? /* @__PURE__ */ jsx(motion.span, {
937
+ layoutId: indicatorLayoutId,
938
+ className: "absolute inset-x-0 bottom-0 h-0.5 rounded-full bg-(--clarify-theme-tokens-colors-foreground)",
939
+ transition: {
940
+ type: "tween",
941
+ duration: .16,
942
+ ease: "easeOut"
943
+ }
944
+ }) : null] })
945
+ }, item.id))
946
+ }), /* @__PURE__ */ jsx(TabPanels, {
947
+ className: clsx("mt-4", panelsClassName),
948
+ children: items.map((item) => /* @__PURE__ */ jsx(TabPanel, {
949
+ className: "focus:outline-none",
950
+ children: item.panel
951
+ }, item.id))
952
+ })]
953
+ });
954
+ }
955
+ //#endregion
918
956
  //#region source/components/WebFrame.tsx
919
957
  function WebFrame(arg0) {
920
958
  const { src, title = "Embedded content", children, showWindow = true, className, iframeClassName, height = 420, style, ...props } = arg0;
@@ -2086,19 +2124,36 @@ function firstExampleKeyForResponseContent(content) {
2086
2124
  return getExampleEntries(content?.value)[0]?.key ?? "";
2087
2125
  }
2088
2126
  function useResponseExamplesState(arg0) {
2089
- const { operation, spec, sharedExampleKey, onSelectExampleKey } = arg0;
2090
- const responses = getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0);
2091
- const [selectedStatus, setSelectedStatus] = useState(responses.find(({ status }) => status.startsWith("2"))?.status ?? responses[0]?.status ?? "");
2092
- const selectedResponse = responses.find(({ status }) => status === selectedStatus) ?? responses[0];
2127
+ const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
2128
+ const orderedResponses = [...getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0)].sort((left, right) => {
2129
+ if (left.status === "default") return -1;
2130
+ if (right.status === "default") return 1;
2131
+ const leftCode = Number(left.status);
2132
+ const rightCode = Number(right.status);
2133
+ if (!Number.isNaN(leftCode) && !Number.isNaN(rightCode)) return leftCode - rightCode;
2134
+ return left.status.localeCompare(right.status);
2135
+ });
2136
+ const [internalSelectedStatus, setInternalSelectedStatus] = useState(orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "");
2137
+ const activeStatus = selectedStatus ?? internalSelectedStatus;
2138
+ const selectedResponse = orderedResponses.find(({ status }) => status === activeStatus) ?? orderedResponses[0];
2093
2139
  const responseContents = getMediaTypeEntries(selectedResponse?.response.content, spec);
2094
- const [selectedMediaType, setSelectedMediaType] = useState(responseContents[0]?.mediaType ?? "");
2095
- const selectedContent = responseContents.find((content) => content.mediaType === selectedMediaType) ?? responseContents[0];
2140
+ const [selection, setSelection] = useState(() => ({
2141
+ status: activeStatus,
2142
+ mediaType: responseContents[0]?.mediaType ?? "",
2143
+ exampleKey: firstExampleKeyForResponseContent(responseContents[0])
2144
+ }));
2145
+ const resolvedSelection = selection.status === activeStatus ? selection : {
2146
+ status: activeStatus,
2147
+ mediaType: responseContents[0]?.mediaType ?? "",
2148
+ exampleKey: firstExampleKeyForResponseContent(responseContents[0])
2149
+ };
2150
+ const selectedContent = responseContents.find((content) => content.mediaType === resolvedSelection.mediaType) ?? responseContents[0];
2096
2151
  const examples = getExampleEntries(selectedContent?.value);
2097
- const [selectedExampleKey, setSelectedExampleKey] = useState(examples[0]?.key ?? "");
2152
+ const selectedExampleKey = examples.some((example) => example.key === resolvedSelection.exampleKey) ? resolvedSelection.exampleKey : examples[0]?.key ?? "";
2098
2153
  const currentExampleKey = (sharedExampleKey && examples.some((example) => example.key === sharedExampleKey) ? sharedExampleKey : void 0) ?? selectedExampleKey;
2099
2154
  const selectedExample = examples.find((example) => example.key === currentExampleKey) ?? examples[0];
2100
2155
  return {
2101
- responses,
2156
+ responses: orderedResponses,
2102
2157
  selectedResponse,
2103
2158
  responseContents,
2104
2159
  selectedContent,
@@ -2106,29 +2161,42 @@ function useResponseExamplesState(arg0) {
2106
2161
  selectedExample,
2107
2162
  responseCode: stringifyExample(selectedExample?.value),
2108
2163
  onSelectStatus: (value) => {
2109
- const nextContents = getMediaTypeEntries(responses.find(({ status }) => status === value)?.response.content, spec);
2110
- setSelectedStatus(value);
2111
- setSelectedMediaType(nextContents[0]?.mediaType ?? "");
2112
- setSelectedExampleKey(firstExampleKeyForResponseContent(nextContents[0]));
2164
+ const nextContents = getMediaTypeEntries(orderedResponses.find(({ status }) => status === value)?.response.content, spec);
2165
+ if (typeof selectedStatus === "undefined") setInternalSelectedStatus(value);
2166
+ onSelectStatus?.(value);
2167
+ setSelection({
2168
+ status: value,
2169
+ mediaType: nextContents[0]?.mediaType ?? "",
2170
+ exampleKey: firstExampleKeyForResponseContent(nextContents[0])
2171
+ });
2113
2172
  },
2114
2173
  onSelectMediaType: (value) => {
2115
- setSelectedMediaType(value);
2116
- setSelectedExampleKey(firstExampleKeyForResponseContent(responseContents.find((content) => content.mediaType === value)));
2174
+ const nextContent = responseContents.find((content) => content.mediaType === value);
2175
+ setSelection((current) => ({
2176
+ ...current,
2177
+ mediaType: value,
2178
+ exampleKey: firstExampleKeyForResponseContent(nextContent)
2179
+ }));
2117
2180
  },
2118
2181
  onSelectExample: (value) => {
2119
- setSelectedExampleKey(value);
2182
+ setSelection((current) => ({
2183
+ ...current,
2184
+ exampleKey: value
2185
+ }));
2120
2186
  onSelectExampleKey?.(value);
2121
2187
  }
2122
2188
  };
2123
2189
  }
2124
2190
  function ResponseExamplesPanel(arg0) {
2125
- const { operation, spec, sharedExampleKey, onSelectExampleKey } = arg0;
2191
+ const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
2126
2192
  const t = useBuiltInText();
2127
2193
  const state = useResponseExamplesState({
2128
2194
  operation,
2129
2195
  spec,
2130
2196
  sharedExampleKey,
2131
- onSelectExampleKey
2197
+ onSelectExampleKey,
2198
+ selectedStatus,
2199
+ onSelectStatus
2132
2200
  });
2133
2201
  if (!state.selectedResponse || !state.selectedContent || !state.responseCode) return null;
2134
2202
  return /* @__PURE__ */ jsx(ApiExampleCodeGroup, {
@@ -2378,97 +2446,172 @@ function SchemaProperties(arg0) {
2378
2446
  function ParameterList(arg0) {
2379
2447
  const { title, parameters } = arg0;
2380
2448
  const t = useBuiltInText();
2381
- if (parameters.length === 0) return null;
2382
- return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: title }), /* @__PURE__ */ jsx(Properties, { children: parameters.map((parameter) => /* @__PURE__ */ jsx(Property, {
2449
+ return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: title }), /* @__PURE__ */ jsx(Properties, { children: parameters.length > 0 ? parameters.map((parameter) => /* @__PURE__ */ jsx(Property, {
2383
2450
  name: parameter.name ?? t("openapi.parameter"),
2384
2451
  type: [schemaToType(parameter.schema), parameter.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0,
2385
2452
  children: parameter.description ? /* @__PURE__ */ jsx(Markdown, {
2386
2453
  className: "*:first:mt-0 *:last:mb-0",
2387
2454
  children: parameter.description
2388
2455
  }) : t("openapi.operationParameter")
2389
- }, `${parameter.in}-${parameter.name}`)) })] });
2456
+ }, `${parameter.in}-${parameter.name}`)) : /* @__PURE__ */ jsx("span", {
2457
+ className: "text-sm/5 text-(--clarify-ui-text-soft)",
2458
+ children: t("openapi.none")
2459
+ }) })] });
2390
2460
  }
2391
2461
  function ResponseList(arg0) {
2392
- const { operation, spec } = arg0;
2462
+ const { operation, spec, selectedStatus, onSelectStatus } = arg0;
2393
2463
  const t = useBuiltInText();
2394
- const responses = getResponseEntries(operation, spec);
2395
- if (responses.length === 0) return null;
2396
- return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: t("openapi.responses") }), /* @__PURE__ */ jsx(Properties, { children: responses.map(({ status, response }) => {
2397
- return /* @__PURE__ */ jsx(Property, {
2398
- name: status,
2399
- type: schemaToType(getJsonLikeContent(response.content, spec)?.value.schema),
2400
- children: response.description ? /* @__PURE__ */ jsx(Markdown, {
2401
- className: "*:first:mt-0 *:last:mb-0",
2402
- children: response.description
2403
- }) : `${t("openapi.response")}.`
2404
- }, status);
2405
- }) })] });
2464
+ const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
2465
+ if (left.status === "default") return -1;
2466
+ if (right.status === "default") return 1;
2467
+ const leftCode = Number(left.status);
2468
+ const rightCode = Number(right.status);
2469
+ if (!Number.isNaN(leftCode) && !Number.isNaN(rightCode)) return leftCode - rightCode;
2470
+ return left.status.localeCompare(right.status);
2471
+ });
2472
+ const activeStatus = selectedStatus ?? orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "";
2473
+ const selectedIndex = Math.max(0, orderedResponses.findIndex(({ status }) => status === activeStatus));
2474
+ if (orderedResponses.length === 0) return null;
2475
+ const renderResponsePanel = ({ status, response }) => {
2476
+ const responseSchema = getJsonLikeContent(response.content, spec)?.value.schema;
2477
+ const type = schemaToType(responseSchema);
2478
+ return /* @__PURE__ */ jsxs("div", {
2479
+ className: "rounded-(--clarify-theme-tokens-radius-xl) p-0",
2480
+ children: [
2481
+ /* @__PURE__ */ jsxs("div", {
2482
+ className: "flex flex-wrap items-center gap-2",
2483
+ children: [/* @__PURE__ */ jsx("span", {
2484
+ className: "text-sm/5 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
2485
+ children: status
2486
+ }), type ? /* @__PURE__ */ jsx("span", {
2487
+ className: "text-xs text-(--clarify-theme-tokens-colors-muted)",
2488
+ children: type
2489
+ }) : null]
2490
+ }),
2491
+ /* @__PURE__ */ jsx("div", {
2492
+ className: "mt-3 text-sm/6 text-(--clarify-ui-text-soft) *:first:mt-0 *:last:mb-0",
2493
+ children: response.description ? /* @__PURE__ */ jsx(Markdown, {
2494
+ className: "*:first:mt-0 *:last:mb-0",
2495
+ children: response.description
2496
+ }) : `${t("openapi.response")}.`
2497
+ }),
2498
+ responseSchema && spec ? /* @__PURE__ */ jsx("div", {
2499
+ className: "mt-4",
2500
+ children: /* @__PURE__ */ jsx(SchemaProperties, {
2501
+ title: t("openapi.responseBodyProperties"),
2502
+ schema: responseSchema,
2503
+ spec
2504
+ })
2505
+ }) : null
2506
+ ]
2507
+ });
2508
+ };
2509
+ if (orderedResponses.length === 1) {
2510
+ const [{ status, response }] = orderedResponses;
2511
+ return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: t("openapi.responses") }), renderResponsePanel({
2512
+ status,
2513
+ response
2514
+ })] });
2515
+ }
2516
+ return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: t("openapi.responses") }), /* @__PURE__ */ jsx(Tabs, {
2517
+ selectedIndex,
2518
+ onChange: (index) => {
2519
+ onSelectStatus?.(orderedResponses[index]?.status ?? "");
2520
+ },
2521
+ items: orderedResponses.map(({ status, response }) => ({
2522
+ id: status,
2523
+ label: status,
2524
+ panel: renderResponsePanel({
2525
+ status,
2526
+ response
2527
+ })
2528
+ })),
2529
+ panelsClassName: "mt-4"
2530
+ })] });
2406
2531
  }
2407
2532
  //#endregion
2408
2533
  //#region source/openapi/components/EndpointSections.tsx
2409
2534
  function EndpointRequest(arg0) {
2410
2535
  const { spec, path, method, description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
2411
2536
  const t = useBuiltInText();
2412
- return /* @__PURE__ */ jsxs(Row, {
2537
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [description ? /* @__PURE__ */ jsx(Markdown, { children: description }) : null, /* @__PURE__ */ jsxs(Row, {
2413
2538
  className: "relative mt-6",
2414
- children: [/* @__PURE__ */ jsxs(Col, { children: [
2415
- description ? /* @__PURE__ */ jsx(Markdown, { children: description }) : null,
2416
- /* @__PURE__ */ jsx(ParameterList, {
2417
- title: t("openapi.pathParameters"),
2418
- parameters: groupedParameters.path
2419
- }),
2420
- /* @__PURE__ */ jsx(ParameterList, {
2421
- title: t("openapi.queryParameters"),
2422
- parameters: groupedParameters.query
2423
- }),
2424
- /* @__PURE__ */ jsx(ParameterList, {
2425
- title: t("openapi.headers"),
2426
- parameters: groupedParameters.header
2427
- }),
2428
- requestBody && requestContents.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
2429
- /* @__PURE__ */ jsx("h3", { children: t("openapi.requestBody") }),
2430
- typeof requestBody.description === "string" ? /* @__PURE__ */ jsx(Markdown, { children: requestBody.description }) : null,
2431
- /* @__PURE__ */ jsx(SchemaProperties, {
2432
- title: t("openapi.bodyProperties"),
2433
- schema: requestSchema,
2434
- spec
2435
- })
2436
- ] }) : null
2437
- ] }), /* @__PURE__ */ jsx(Col, {
2539
+ children: [/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsxs("div", {
2540
+ className: "w-full",
2541
+ children: [
2542
+ /* @__PURE__ */ jsx(ParameterList, {
2543
+ title: t("openapi.pathParameters"),
2544
+ parameters: groupedParameters.path
2545
+ }),
2546
+ /* @__PURE__ */ jsx(ParameterList, {
2547
+ title: t("openapi.queryParameters"),
2548
+ parameters: groupedParameters.query
2549
+ }),
2550
+ /* @__PURE__ */ jsx(ParameterList, {
2551
+ title: t("openapi.headers"),
2552
+ parameters: groupedParameters.header
2553
+ }),
2554
+ requestBody && requestContents.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
2555
+ /* @__PURE__ */ jsx("h3", { children: t("openapi.requestBody") }),
2556
+ typeof requestBody.description === "string" ? /* @__PURE__ */ jsx(Markdown, { children: requestBody.description }) : null,
2557
+ /* @__PURE__ */ jsx(SchemaProperties, {
2558
+ title: t("openapi.bodyProperties"),
2559
+ schema: requestSchema,
2560
+ spec
2561
+ })
2562
+ ] }) : null
2563
+ ]
2564
+ }) }), /* @__PURE__ */ jsx(Col, {
2438
2565
  sticky: true,
2439
- children: /* @__PURE__ */ jsx(RequestExamplesPanel, {
2440
- spec,
2441
- path,
2442
- method,
2443
- parameters,
2444
- requestContents,
2445
- selectedMediaType: selectedRequestMediaType,
2446
- onSelectMediaType: onSelectRequestMediaType,
2447
- selectedServer,
2448
- serverVariables,
2449
- auth,
2450
- sharedExampleKey,
2451
- onSelectExampleKey
2566
+ children: /* @__PURE__ */ jsx("div", {
2567
+ className: "w-full",
2568
+ children: /* @__PURE__ */ jsx(RequestExamplesPanel, {
2569
+ spec,
2570
+ path,
2571
+ method,
2572
+ parameters,
2573
+ requestContents,
2574
+ selectedMediaType: selectedRequestMediaType,
2575
+ onSelectMediaType: onSelectRequestMediaType,
2576
+ selectedServer,
2577
+ serverVariables,
2578
+ auth,
2579
+ sharedExampleKey,
2580
+ onSelectExampleKey
2581
+ })
2452
2582
  })
2453
2583
  })]
2454
- });
2584
+ })] });
2455
2585
  }
2456
2586
  function EndpointResponse(arg0) {
2457
- const { spec, operation, sharedExampleKey, onSelectExampleKey } = arg0;
2458
- return /* @__PURE__ */ jsxs(Row, {
2459
- className: "relative mt-6",
2460
- children: [/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx(ResponseList, {
2461
- operation,
2462
- spec
2463
- }) }), /* @__PURE__ */ jsx(Col, {
2464
- sticky: true,
2465
- children: /* @__PURE__ */ jsx(ResponseExamplesPanel, {
2466
- operation,
2467
- spec,
2468
- sharedExampleKey,
2469
- onSelectExampleKey
2470
- })
2471
- })]
2587
+ const { spec, operation, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
2588
+ return /* @__PURE__ */ jsx("div", {
2589
+ className: "mt-6",
2590
+ children: /* @__PURE__ */ jsxs(Row, {
2591
+ className: "relative",
2592
+ children: [/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx("div", {
2593
+ className: "w-full",
2594
+ children: /* @__PURE__ */ jsx(ResponseList, {
2595
+ operation,
2596
+ spec,
2597
+ selectedStatus,
2598
+ onSelectStatus
2599
+ })
2600
+ }) }), /* @__PURE__ */ jsx(Col, {
2601
+ sticky: true,
2602
+ children: /* @__PURE__ */ jsx("div", {
2603
+ className: "w-full",
2604
+ children: /* @__PURE__ */ jsx(ResponseExamplesPanel, {
2605
+ operation,
2606
+ spec,
2607
+ sharedExampleKey,
2608
+ onSelectExampleKey,
2609
+ selectedStatus,
2610
+ onSelectStatus
2611
+ })
2612
+ })
2613
+ })]
2614
+ })
2472
2615
  });
2473
2616
  }
2474
2617
  //#endregion
@@ -2563,26 +2706,30 @@ function EndpointMethodBadge(arg0) {
2563
2706
  });
2564
2707
  }
2565
2708
  function EndpointPath(arg0) {
2566
- const { path } = arg0;
2567
- const segments = path.split("/").filter(Boolean);
2568
- return /* @__PURE__ */ jsx("div", {
2569
- className: "flex min-w-0 flex-1 items-center overflow-x-auto text-sm font-bold leading-6 whitespace-nowrap",
2570
- children: segments.length > 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
2571
- className: "text-(--clarify-ui-text-faint)",
2572
- children: "/"
2573
- }), segments.map((segment, index) => /* @__PURE__ */ jsxs("span", {
2574
- className: "flex items-center",
2575
- children: [index > 0 ? /* @__PURE__ */ jsx("span", {
2576
- className: "text-(--clarify-ui-text-faint)",
2577
- children: "/"
2578
- }) : null, /* @__PURE__ */ jsx("span", {
2579
- className: "font-bold text-(--clarify-theme-tokens-colors-foreground)",
2580
- children: segment
2581
- })]
2582
- }, `${segment}-${index}`))] }) : /* @__PURE__ */ jsx("span", {
2583
- className: "font-bold text-(--clarify-theme-tokens-colors-foreground)",
2584
- children: "/"
2585
- })
2709
+ const { path, copied = false, onCopy } = arg0;
2710
+ const t = useBuiltInText();
2711
+ return /* @__PURE__ */ jsxs("div", {
2712
+ className: "flex min-w-0 flex-1 items-center gap-2 overflow-hidden",
2713
+ children: [/* @__PURE__ */ jsx("div", {
2714
+ className: "min-w-0 flex-1 overflow-x-auto text-sm font-bold leading-6 whitespace-nowrap",
2715
+ children: /* @__PURE__ */ jsx("span", {
2716
+ className: "select-text font-mono text-(--clarify-theme-tokens-colors-foreground)",
2717
+ children: path || "/"
2718
+ })
2719
+ }), onCopy ? /* @__PURE__ */ jsx("button", {
2720
+ type: "button",
2721
+ "aria-label": copied ? t("actions.copied") : t("actions.copy"),
2722
+ title: copied ? t("actions.copied") : t("actions.copy"),
2723
+ onClick: onCopy,
2724
+ 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"),
2725
+ children: copied ? /* @__PURE__ */ jsx(CheckIcon, {
2726
+ className: "h-3.5 w-3.5",
2727
+ "aria-hidden": "true"
2728
+ }) : /* @__PURE__ */ jsx(CopyIcon, {
2729
+ className: "h-3.5 w-3.5",
2730
+ "aria-hidden": "true"
2731
+ })
2732
+ }) : null]
2586
2733
  });
2587
2734
  }
2588
2735
  function InlineListbox(arg0) {
@@ -2630,6 +2777,22 @@ function InlineListbox(arg0) {
2630
2777
  function getServerPreviewUrl(server, variables) {
2631
2778
  return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
2632
2779
  }
2780
+ function getFullEndpointUrl(server, variables, path) {
2781
+ const base = getServerPreviewUrl(server, variables);
2782
+ if (!base) return path;
2783
+ return `${base.endsWith("/") ? base.slice(0, -1) : base}${path.startsWith("/") ? path : `/${path}`}`;
2784
+ }
2785
+ function getDefaultResponseStatus(operation, spec) {
2786
+ const orderedResponses = [...getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0)].sort((left, right) => {
2787
+ if (left.status === "default") return -1;
2788
+ if (right.status === "default") return 1;
2789
+ const leftCode = Number(left.status);
2790
+ const rightCode = Number(right.status);
2791
+ if (!Number.isNaN(leftCode) && !Number.isNaN(rightCode)) return leftCode - rightCode;
2792
+ return left.status.localeCompare(right.status);
2793
+ });
2794
+ return orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "";
2795
+ }
2633
2796
  function ServerUrlValue(arg0) {
2634
2797
  const { server, variables, open, interactive, onToggle } = arg0;
2635
2798
  const url = getServerPreviewUrl(server, variables);
@@ -2779,6 +2942,16 @@ function AuthPanel(arg0) {
2779
2942
  function EndpointIdentity(arg0) {
2780
2943
  const { method, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
2781
2944
  const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
2945
+ const [copiedUrl, setCopiedUrl] = useState(false);
2946
+ const fullUrl = getFullEndpointUrl(selectedServer, serverVariables, path);
2947
+ useEffect(() => {
2948
+ if (!copiedUrl) return void 0;
2949
+ const timeout = window.setTimeout(() => setCopiedUrl(false), 1200);
2950
+ return () => window.clearTimeout(timeout);
2951
+ }, [copiedUrl]);
2952
+ async function handleCopyUrl() {
2953
+ if (await copyTextToClipboard(fullUrl)) setCopiedUrl(true);
2954
+ }
2782
2955
  return /* @__PURE__ */ jsxs("div", {
2783
2956
  className: "not-prose flex w-full flex-col overflow-hidden rounded-xl border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) shadow-xs",
2784
2957
  children: [
@@ -2793,7 +2966,11 @@ function EndpointIdentity(arg0) {
2793
2966
  interactive: serverInteractive,
2794
2967
  onToggle: onToggleServer
2795
2968
  }),
2796
- /* @__PURE__ */ jsx(EndpointPath, { path }),
2969
+ /* @__PURE__ */ jsx(EndpointPath, {
2970
+ path,
2971
+ copied: copiedUrl,
2972
+ onCopy: handleCopyUrl
2973
+ }),
2797
2974
  authOptions.length > 0 ? /* @__PURE__ */ jsx("button", {
2798
2975
  type: "button",
2799
2976
  "aria-expanded": authOpen,
@@ -2838,6 +3015,7 @@ function OpenApiOperation(arg0) {
2838
3015
  const serverState = useOperationServerState(spec, operation, path);
2839
3016
  const authState = useOperationAuthState(spec, operation);
2840
3017
  const [linkedExampleKey, setLinkedExampleKey] = useState("");
3018
+ const [selectedResponseStatus, setSelectedResponseStatus] = useState(() => getDefaultResponseStatus(operation, spec));
2841
3019
  return /* @__PURE__ */ jsxs("section", {
2842
3020
  className: "clarify-api-endpoint scroll-mt-24 pb-16 first:pt-0 last:pb-0",
2843
3021
  "aria-labelledby": id,
@@ -2894,7 +3072,9 @@ function OpenApiOperation(arg0) {
2894
3072
  spec,
2895
3073
  operation,
2896
3074
  sharedExampleKey: linkedExampleKey,
2897
- onSelectExampleKey: setLinkedExampleKey
3075
+ onSelectExampleKey: setLinkedExampleKey,
3076
+ selectedStatus: selectedResponseStatus,
3077
+ onSelectStatus: setSelectedResponseStatus
2898
3078
  })
2899
3079
  ]
2900
3080
  });
@@ -2902,4 +3082,4 @@ function OpenApiOperation(arg0) {
2902
3082
  //#endregion
2903
3083
  export { Button as A, Code as C, Card as D, Mermaid as E, CardGroup as O, Collapse as S, Pre as T, HeroPattern as _, authPlaceholder as a, Tag as b, getServerKey as c, getRequestBody$1 as d, Markdown as f, GridPattern as g, Prose as h, ResponseExamplesPanel as i, Callout as k, getServers as l, WebFrame as m, OpenApiOperation as n, defaultServerVariables as o, primitives_exports as p, RequestExamplesPanel as r, getAuthOptions as s, EndpointIdentity as t, getMediaTypeEntries as u, Logo as v, CodeGroup as w, Feedback as x, Heading as y };
2904
3084
 
2905
- //# sourceMappingURL=OpenApiOperation-DIFaYAe5.js.map
3085
+ //# sourceMappingURL=OpenApiOperation-C9xyRo5a.js.map